diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 58 |
1 files changed, 40 insertions, 18 deletions
@@ -446,22 +446,22 @@ static int bouncing_animation[] = { | |||
446 | 0, 0, 0, | 446 | 0, 0, 0, |
447 | 0, 0, 0, | 447 | 0, 0, 0, |
448 | 0, 0, 0, | 448 | 0, 0, 0, |
449 | 0, 0, 0, | ||
450 | 1, 1, 1, | 449 | 1, 1, 1, |
450 | 2, 2, 2, | ||
451 | 3, 3, 3, | 451 | 3, 3, 3, |
452 | 5, 5, 5, | 452 | 5, 5, 5, |
453 | 5, 5, 5, | 453 | 6, 6, 6, |
454 | 7, 7, 7, | 454 | 7, 7, 7, |
455 | 8, 8, 8, | 455 | 8, 8, 8, |
456 | 7, 7, 7, | 456 | 7, 7, 7, |
457 | 5, 5, 5, | 457 | 6, 6, 6, |
458 | 5, 5, 5, | 458 | 5, 5, 5, |
459 | 3, 3, 3, | 459 | 3, 3, 3, |
460 | 2, 2, 2, | ||
460 | 1, 1, 1, | 461 | 1, 1, 1, |
461 | 0, 0, 0, | 462 | 0, 0, 0, |
462 | 0, 0, 0, | 463 | 0, 0, 0, |
463 | 0, 0, 0, | 464 | 0, 0, 0, |
464 | 0, 0, 0, | ||
465 | }; | 465 | }; |
466 | 466 | ||
467 | typedef struct FontSprite { | 467 | typedef struct FontSprite { |
@@ -472,6 +472,21 @@ typedef struct FontSprite { | |||
472 | u32 pal_bank; | 472 | u32 pal_bank; |
473 | } FontSprite; | 473 | } FontSprite; |
474 | 474 | ||
475 | |||
476 | static u32 test_tiles[][8] = { | ||
477 | {0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111}, | ||
478 | {0x00044000, 0x00044000, 0x00044000, 0x44444444, 0x44444444, 0x00044000, 0x00044000, 0x00044000}, | ||
479 | {0x44400444, 0x44400444, 0x44400444, 0x00000000, 0x00000000, 0x44400444, 0x44400444, 0x44400444}, | ||
480 | {0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333}, | ||
481 | }; | ||
482 | |||
483 | static u16 test_palette[16] = { | ||
484 | 0x0000, 0x001f, 0x03e0, 0x7c00, | ||
485 | 0x7fff, 0x0000, 0x0000, 0x0000, | ||
486 | 0x0000, 0x0000, 0x0000, 0x0000, | ||
487 | 0x0000, 0x0000, 0x0000, 0x0000 | ||
488 | }; | ||
489 | |||
475 | int main(void) { | 490 | int main(void) { |
476 | // Configure the display in mode 0 to show OBJs, where tile memory is | 491 | // Configure the display in mode 0 to show OBJs, where tile memory is |
477 | // sequential. | 492 | // sequential. |
@@ -479,14 +494,10 @@ int main(void) { | |||
479 | 494 | ||
480 | // Add colors to the sprite color palette. Tiles with color number 0 are | 495 | // Add colors to the sprite color palette. Tiles with color number 0 are |
481 | // treated as transparent. | 496 | // treated as transparent. |
482 | PAL_BUFFER_SPRITES[1] = COLOR_WHITE; | 497 | for (size_t i = 0; i < 16; ++i) { |
483 | PAL_BUFFER_SPRITES[2] = COLOR_RED; | 498 | PAL_BUFFER_SPRITES[i] = test_palette[i]; |
484 | PAL_BUFFER_SPRITES[3] = COLOR_CYAN; | 499 | PAL_BUFFER_SPRITES[i + 16] = COLOR_WHITE; |
485 | PAL_BUFFER_SPRITES[4] = COLOR_BLUE; | 500 | } |
486 | PAL_BUFFER_SPRITES[5] = COLOR_WHITE; | ||
487 | PAL_BUFFER_SPRITES[6] = COLOR_RED; | ||
488 | PAL_BUFFER_SPRITES[7] = COLOR_CYAN; | ||
489 | PAL_BUFFER_SPRITES[8] = COLOR_BLUE; | ||
490 | 501 | ||
491 | // Initialize all attributes by disabling rendering. If we don't do this, | 502 | // Initialize all attributes by disabling rendering. If we don't do this, |
492 | // glitches may appear. | 503 | // glitches may appear. |
@@ -502,19 +513,26 @@ int main(void) { | |||
502 | // uppercase A letter will be at tile index of 512 + 65. | 513 | // uppercase A letter will be at tile index of 512 + 65. |
503 | copy_font_to_tile_memory(tile_mem); | 514 | copy_font_to_tile_memory(tile_mem); |
504 | 515 | ||
516 | // Test copying the exported tiles. | ||
517 | for (size_t i = 0; i < 4; ++i) { | ||
518 | for (size_t j = 0; j < 8; ++j) { | ||
519 | (tile_mem + i)->data[j] = test_tiles[i][j]; | ||
520 | } | ||
521 | } | ||
522 | |||
505 | // Initialize character sprites for all font chars. | 523 | // Initialize character sprites for all font chars. |
506 | FontSprite font_sprites[256] = {0}; | 524 | FontSprite font_sprites[256] = {0}; |
507 | size_t x = 49; | 525 | size_t x = 49; |
508 | size_t y = 0; | 526 | size_t y = 8; |
509 | for (size_t i = 0; i < 256; ++i) { | 527 | for (size_t i = 0; i < 256; ++i) { |
528 | if ((i % 16) == 0 && i != 0) { | ||
529 | y += 16; | ||
530 | x = 49; | ||
531 | } | ||
510 | font_sprites[i].x = x; | 532 | font_sprites[i].x = x; |
511 | font_sprites[i].y = y; | 533 | font_sprites[i].y = y; |
512 | font_sprites[i].tile_index = initial_tile + i; | 534 | font_sprites[i].tile_index = initial_tile + i; |
513 | font_sprites[i].animation_state = i % 56; | 535 | font_sprites[i].animation_state = i % 56; |
514 | if ((i % 16) == 0) { | ||
515 | y += 16; | ||
516 | x = 49; | ||
517 | } | ||
518 | x += 8; | 536 | x += 8; |
519 | } | 537 | } |
520 | 538 | ||
@@ -523,7 +541,11 @@ int main(void) { | |||
523 | for (size_t i = 0; i < n_chars; ++i) { | 541 | for (size_t i = 0; i < n_chars; ++i) { |
524 | OBJ_ATTR_0(i) = font_sprites[i].y; | 542 | OBJ_ATTR_0(i) = font_sprites[i].y; |
525 | OBJ_ATTR_1(i) = font_sprites[i].x; | 543 | OBJ_ATTR_1(i) = font_sprites[i].x; |
526 | OBJ_ATTR_2(i) = font_sprites[i].tile_index; | 544 | if (i < 4) { |
545 | OBJ_ATTR_2(i) = font_sprites[i].tile_index; | ||
546 | } else { | ||
547 | OBJ_ATTR_2(i) = font_sprites[i].tile_index | (1 << 0xC); | ||
548 | } | ||
527 | } | 549 | } |
528 | 550 | ||
529 | // draw_logo(); | 551 | // draw_logo(); |