Add CGB-A support

This commit is contained in:
Lior Halphon 2022-01-05 21:55:46 +02:00
parent ab1d4cd26e
commit b7f03dea8d
7 changed files with 17 additions and 7 deletions

View File

@ -402,7 +402,7 @@
<menu key="menu" autoenablesItems="NO" id="bbF-hB-Hv7">
<items>
<menuItem title="CPU-CGB 0 (Experimental)" tag="512" id="2Uk-u3-6Gw"/>
<menuItem title="CPU-CGB A" tag="513" enabled="NO" id="axv-yk-RWM"/>
<menuItem title="CPU-CGB A (Experimental)" tag="513" id="axv-yk-RWM"/>
<menuItem title="CPU-CGB B (Experimental)" tag="514" id="NtJ-oo-IM2"/>
<menuItem title="CPU-CGB C (Experimental)" tag="515" id="9YL-u8-12z"/>
<menuItem title="CPU-CGB D" tag="516" id="c76-oF-fkU"/>
@ -854,7 +854,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" id="5Al-aC-tq8">
<rect key="frame" x="1" y="1" width="158" height="316"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="sourceList" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" id="ZVn-bk-duk">
<rect key="frame" x="0.0" y="0.0" width="158" height="316"/>

View File

@ -901,7 +901,7 @@ static inline uint16_t effective_channel4_counter(GB_gameboy_t *gb)
case GB_MODEL_SGB2:
case GB_MODEL_SGB2_NO_SFC:
case GB_MODEL_CGB_0:
// case GB_MODEL_CGB_A:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_C:
if (effective_counter & 8) {
effective_counter |= 0xE; // Sometimes F on some instances

View File

@ -169,6 +169,9 @@ void GB_display_vblank(GB_gameboy_t *gb)
if (gb->model == GB_MODEL_CGB_0) {
index = 1; // CGB 0 was only available in Indigo!
}
else if (gb->model == GB_MODEL_CGB_A) {
index = 0; // CGB 0 was only available in Indigo!
}
gb->borrowed_border.palette[0] = LE16(colors[index]);
gb->borrowed_border.palette[10] = LE16(colors[5 + index]);
gb->borrowed_border.palette[14] = LE16(colors[10 + index]);

View File

@ -1409,6 +1409,7 @@ static void reset_ram(GB_gameboy_t *gb)
break;
case GB_MODEL_CGB_0:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_B:
case GB_MODEL_CGB_C:
for (unsigned i = 0; i < gb->ram_size; i++) {
@ -1436,6 +1437,7 @@ static void reset_ram(GB_gameboy_t *gb)
/* HRAM */
switch (gb->model) {
case GB_MODEL_CGB_0:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_B:
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D:
@ -1468,6 +1470,7 @@ static void reset_ram(GB_gameboy_t *gb)
/* OAM */
switch (gb->model) {
case GB_MODEL_CGB_0:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_B:
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D:
@ -1501,6 +1504,7 @@ static void reset_ram(GB_gameboy_t *gb)
/* Wave RAM */
switch (gb->model) {
case GB_MODEL_CGB_0:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_B:
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D:
@ -1578,6 +1582,7 @@ static void request_boot_rom(GB_gameboy_t *gb)
case GB_MODEL_CGB_0:
type = GB_BOOT_ROM_CGB_0;
break;
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_B:
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_D:

View File

@ -97,7 +97,7 @@ typedef enum {
GB_MODEL_SGB2 = 0x101,
GB_MODEL_SGB2_NO_SFC = GB_MODEL_SGB2 | GB_MODEL_NO_SFC_BIT,
GB_MODEL_CGB_0 = 0x200,
// GB_MODEL_CGB_A = 0x201,
GB_MODEL_CGB_A = 0x201,
GB_MODEL_CGB_B = 0x202,
GB_MODEL_CGB_C = 0x203,
GB_MODEL_CGB_D = 0x204,

View File

@ -567,8 +567,8 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_B:
// case GB_MODEL_CGB_A:
case GB_MODEL_CGB_0:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_0:
addr &= ~0x18;
return gb->extra_oam[addr - 0xfea0];
@ -1228,7 +1228,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
break;
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_B:
// case GB_MODEL_CGB_A:
case GB_MODEL_CGB_A:
case GB_MODEL_CGB_0:
addr &= ~0x18;
gb->extra_oam[addr - 0xfea0] = value;

View File

@ -318,6 +318,7 @@ static bool verify_and_update_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t
case GB_MODEL_SGB2: return true;
case GB_MODEL_SGB2_NO_SFC: return true;
case GB_MODEL_CGB_0: return true;
case GB_MODEL_CGB_A: return true;
case GB_MODEL_CGB_B: return true;
case GB_MODEL_CGB_C: return true;
case GB_MODEL_CGB_D: return true;
@ -575,6 +576,7 @@ static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool appe
bess_core.full_model = BE32('S2 '); break;
case GB_MODEL_CGB_0: bess_core.full_model = BE32('CC0 '); break;
case GB_MODEL_CGB_A: bess_core.full_model = BE32('CCA '); break;
case GB_MODEL_CGB_B: bess_core.full_model = BE32('CCB '); break;
case GB_MODEL_CGB_C: bess_core.full_model = BE32('CCC '); break;
case GB_MODEL_CGB_D: bess_core.full_model = BE32('CCD '); break;