From 881dd11bf2f805db6d4b7a6dfc4366bfd223b3dd Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 13 Jan 2022 21:51:23 -0800 Subject: [PATCH] GB Video: Add default SGB border --- CHANGES | 1 + res/sgb-border.png | Bin 0 -> 582 bytes src/gb/video.c | 249 +++++++++++++++++++++++++++++++++++++++++++++ tools/snes-tile.py | 76 ++++++++++++++ 4 files changed, 326 insertions(+) create mode 100644 res/sgb-border.png create mode 100644 tools/snes-tile.py diff --git a/CHANGES b/CHANGES index 3460772c3..69160760c 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ Other fixes: - FFmpeg: Fix crash when encoding audio with some containers Misc: - Core: Suspend runloop when a core crashes + - GB Video: Add default SGB border - mGUI: Add margin to right-aligned menu text (fixes mgba.io/i/871) - Qt: Rearrange menus some - Qt: Clean up cheats dialog diff --git a/res/sgb-border.png b/res/sgb-border.png new file mode 100644 index 0000000000000000000000000000000000000000..4482b846dab651078ece54d699a885ab72a1adee GIT binary patch literal 582 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K59&j)N$=mZil7JLrage(c!@6@aFM%Az0G|+7 zApPOP40t<%%4TFH^c~d8Ybe0791v5B2yO9QDAM5LA@7KX~e&{+0dvJ~X)%a5dB&f8)6Q^|q;( za%S$Uob^Mr*m&j)+m&mVo!`Ag#s*>_f^68q5W9niahKkz1ELRKd9>&P$`L^Na> zu`|DLV>ssK)lkH8ppj9|FQ4IR`y=h%wT!i`r_I9lOsT5*i tSa8z)VZwXnL(EUEzkk2hfPvxQXJ(79o-38LO!tGV@^tlcS?83{1OWFvm%;!5 literal 0 HcmV?d00001 diff --git a/src/gb/video.c b/src/gb/video.c index 98c83da4b..e4059a3e1 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -40,6 +40,246 @@ static void _endMode2(struct mTiming* timing, void* context, uint32_t cyclesLate static void _endMode3(struct mTiming* timing, void* context, uint32_t cyclesLate); static void _updateFrameCount(struct mTiming* timing, void* context, uint32_t cyclesLate); +static const uint16_t _defaultBorderPalette[16] = { + 0x0000, + 0x7FDE, + 0x7FFF, + 0x739A, + 0x2929, + 0x24E7, + 0x1CC6, + 0x0400, + 0x514A, + 0x3907, + 0x28C5, +}; + +static const uint8_t _defaultBorderTilemap[] = { + 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, + 0x12, 0x10, 0x14, 0x10, 0x16, 0x10, 0x17, 0x10, 0x17, 0x10, 0x17, 0x10, 0x17, 0x10, 0x17, 0x10, + 0x17, 0x10, 0x17, 0x10, 0x17, 0x10, 0x17, 0x10, 0x17, 0x10, 0x16, 0x50, 0x14, 0x10, 0x12, 0x50, + 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, + 0x02, 0x10, 0x06, 0x10, 0x0A, 0x10, 0x0D, 0x10, 0x0E, 0x10, 0x0F, 0x10, 0x10, 0x10, 0x11, 0x10, + 0x13, 0x10, 0x15, 0x10, 0x15, 0x10, 0x18, 0x10, 0x1B, 0x10, 0x1B, 0x10, 0x1B, 0x10, 0x1B, 0x10, + 0x1B, 0x10, 0x1B, 0x10, 0x1B, 0x10, 0x1B, 0x10, 0x18, 0x50, 0x15, 0x10, 0x15, 0x10, 0x13, 0x10, + 0x11, 0x10, 0x10, 0x50, 0x0F, 0x50, 0x0E, 0x50, 0x0D, 0x50, 0x0A, 0x50, 0x06, 0x50, 0x02, 0x50, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x04, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, + 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, + 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, + 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x07, 0x10, 0x04, 0x50, + 0x05, 0x10, 0x08, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, + 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, + 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, + 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x0B, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x05, 0x10, 0x09, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, + 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, + 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, + 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x0C, 0x10, 0x05, 0x50, + 0x04, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, + 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x1F, 0x10, 0x23, 0x10, 0x23, 0x10, + 0x23, 0x10, 0x23, 0x10, 0x23, 0x10, 0x23, 0x10, 0x34, 0x10, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, + 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x07, 0x90, 0x04, 0xD0, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x19, 0x10, 0x1C, 0x10, 0x20, 0x10, 0x24, 0x10, 0x26, 0x10, + 0x29, 0x10, 0x2B, 0x10, 0x2E, 0x10, 0x31, 0x10, 0x35, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x1A, 0x10, 0x1D, 0x10, 0x21, 0x10, 0x25, 0x10, 0x27, 0x10, + 0x2A, 0x10, 0x2C, 0x10, 0x2F, 0x10, 0x32, 0x10, 0x1A, 0x50, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x19, 0x90, 0x1E, 0x10, 0x22, 0x10, 0x1C, 0x90, 0x28, 0x10, + 0x1C, 0x90, 0x2D, 0x10, 0x30, 0x10, 0x33, 0x10, 0x19, 0xD0, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, + 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, 0x03, 0x10, +}; + +static const uint8_t _defaultBorderChardata[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, 0x03, 0xFC, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0xFF, 0x03, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x3F, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x3F, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xE0, 0x1F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x7F, 0x80, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x1F, 0x00, 0x7E, 0x80, 0x01, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFC, 0x03, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0x00, 0xF8, 0x07, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x07, 0xF8, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x3F, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0xC0, 0x3F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x07, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFE, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFE, 0x00, + 0x0F, 0xFE, 0x0F, 0xFE, 0x0F, 0xFE, 0x0F, 0xFE, 0x0F, 0xFE, 0x0F, 0xFE, 0x0F, 0xFE, 0x0F, 0xFE, + 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 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 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0xC7, 0xFF, 0xC7, 0xFF, 0xC7, 0xFF, 0x07, 0xFF, 0x07, + 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0xC7, 0x00, 0xC7, 0x00, 0xC7, 0x00, 0x07, 0x00, 0x07, 0x00, + 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x07, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, + 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xF1, 0xFF, 0xF1, 0xFF, 0xF1, + 0xFF, 0x00, 0xFF, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xF1, 0x00, 0xF1, 0x00, 0xF1, 0x00, + 0xFF, 0x03, 0xFF, 0x07, 0xFF, 0x03, 0xFF, 0xF1, 0xFF, 0xF1, 0xFF, 0xF1, 0xFF, 0x01, 0xFF, 0x01, + 0x03, 0x00, 0x07, 0x00, 0x03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, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, + 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFC, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xE0, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, + 0xFF, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, +}; + void GBVideoInit(struct GBVideo* video) { video->renderer = NULL; video->vram = anonymousMemoryMap(GB_SIZE_VRAM); @@ -92,16 +332,25 @@ void GBVideoReset(struct GBVideo* video) { } else { video->renderer->sgbCharRam = anonymousMemoryMap(SGB_SIZE_CHAR_RAM); } + memcpy(video->renderer->sgbCharRam, _defaultBorderChardata, sizeof(_defaultBorderChardata)); + if (video->renderer->sgbMapRam) { memset(video->renderer->sgbMapRam, 0, SGB_SIZE_MAP_RAM); } else { video->renderer->sgbMapRam = anonymousMemoryMap(SGB_SIZE_MAP_RAM); } + memcpy(video->renderer->sgbMapRam, _defaultBorderTilemap, sizeof(_defaultBorderTilemap)); + int i; + for (i = 0; i < 16; ++i) { + STORE_16LE(_defaultBorderPalette[i], 0x800 + i * 2, video->renderer->sgbMapRam); + } + if (video->renderer->sgbPalRam) { memset(video->renderer->sgbPalRam, 0, SGB_SIZE_PAL_RAM); } else { video->renderer->sgbPalRam = anonymousMemoryMap(SGB_SIZE_PAL_RAM); } + if (video->renderer->sgbAttributeFiles) { memset(video->renderer->sgbAttributeFiles, 0, SGB_SIZE_ATF_RAM); } else { diff --git a/tools/snes-tile.py b/tools/snes-tile.py new file mode 100644 index 000000000..62541ec20 --- /dev/null +++ b/tools/snes-tile.py @@ -0,0 +1,76 @@ +import numpy as np +import PIL.Image +import sys + +X_FLIP = 0x4000 +Y_FLIP = 0x8000 +PAL = 0x1000 + +im = PIL.Image.open(sys.argv[1]) +tiles = np.array(np.split(np.array(np.split(np.array(im), 28, 0)), 32, 2)) +tilemapRaw = bytearray(32 * 28 * 2) +tilemap = np.ndarray(shape=(28, 32), dtype='> 0) << (7 - x) + tileData[1] |= ((t & 2) >> 1) << (7 - x) + tileData[2] |= ((t & 4) >> 2) << (7 - x) + tileData[3] |= ((t & 8) >> 3) << (7 - x) + tileBase = i * 32 + y * 2 + print(tileBase) + chardataRaw[tileBase + 0x00] = tileData[0] + chardataRaw[tileBase + 0x01] = tileData[1] + chardataRaw[tileBase + 0x10] = tileData[2] + chardataRaw[tileBase + 0x11] = tileData[3] + +def printMem(mem): + for i in range(len(mem) // 16): + line = mem[i * 16:(i + 1) * 16] + print(', '.join([f'0x{b:02X}' for b in line]) + ',')