GBHawk: Begin to seperate GBC and GBC-in-GB-compatibility-mode ppus.

This commit is contained in:
alyosha-tas 2019-09-15 22:51:50 -04:00
parent d5c9f32095
commit 32c2c4b78e
5 changed files with 2027 additions and 4 deletions

View File

@ -939,6 +939,9 @@
<Compile Include="Consoles\Nintendo\GBHawk\PPU.cs" />
<Compile Include="Consoles\Nintendo\GBHawk\GBC_PPU.cs">
<DependentUpon>PPU.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Nintendo\GBHawk\GBC_PPU_GB.cs">
<DependentUpon>PPU.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Nintendo\GBHawk\GB_PPU.cs">
<DependentUpon>PPU.cs</DependentUpon>

View File

@ -2,6 +2,7 @@
using BizHawk.Common.NumberExtensions;
using BizHawk.Common;
// GBC ppu, closer to the GB ppu in timing and quirks
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
public class GBC_PPU : PPU
@ -1626,6 +1627,190 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
last_HBL = 0;
HBL_HDMA_go = false;
HBL_test = false;
}
}
public override void Reg_Copy(GBC_PPU ppu2)
{
BG_transfer_byte = ppu2.BG_transfer_byte;
OBJ_transfer_byte = ppu2.OBJ_transfer_byte;
HDMA_src_hi = ppu2.HDMA_src_hi;
HDMA_src_lo = ppu2.HDMA_src_lo;
HDMA_dest_hi = ppu2.HDMA_dest_hi;
HDMA_dest_lo = ppu2.HDMA_dest_lo;
HDMA_tick = ppu2.HDMA_tick;
HDMA_byte = ppu2.HDMA_byte;
VRAM_sel = ppu2.VRAM_sel;
BG_V_flip = ppu2.BG_V_flip;
HDMA_mode = ppu2.HDMA_mode;
cur_DMA_src = ppu2.cur_DMA_src;
cur_DMA_dest = ppu2.cur_DMA_dest;
HDMA_length = ppu2.HDMA_length;
HDMA_countdown = ppu2.HDMA_countdown;
HBL_HDMA_count = ppu2.HBL_HDMA_count;
last_HBL = ppu2.last_HBL;
HBL_HDMA_go = ppu2.HBL_HDMA_go;
HBL_test = ppu2.HBL_test;
for (int i = 0; i < BG_bytes.Length; i++)
{
BG_bytes[i] = ppu2.BG_bytes[i];
}
for (int i = 0; i < OBJ_bytes.Length; i++)
{
OBJ_bytes[i] = ppu2.OBJ_bytes[i];
}
BG_bytes_inc = ppu2.BG_bytes_inc;
OBJ_bytes_inc = ppu2.OBJ_bytes_inc;
BG_bytes_index = ppu2.BG_bytes_index;
OBJ_bytes_index = ppu2.OBJ_bytes_index;
LYC_t = ppu2.LYC_t;
LYC_cd = ppu2.LYC_cd;
for (int i = 0; i < BG_palette.Length; i++)
{
BG_palette[i] = ppu2.BG_palette[i];
}
for (int i = 0; i < OBJ_palette.Length; i++)
{
OBJ_palette[i] = ppu2.OBJ_palette[i];
}
HDMA_active = ppu2.HDMA_active;
LCDC = ppu2.LCDC;
STAT = ppu2.STAT;
scroll_y = ppu2.scroll_y;
scroll_x = ppu2.scroll_x;
LY = ppu2.LY;
LY_actual = ppu2.LY_actual;
LY_inc = ppu2.LY_inc;
LYC = ppu2.LYC;
DMA_addr = ppu2.DMA_addr;
BGP = ppu2.BGP;
obj_pal_0 = ppu2.obj_pal_0;
obj_pal_1 = ppu2.obj_pal_1;
window_y = ppu2.window_y;
window_x = ppu2.window_x;
DMA_start = ppu2.DMA_start;
DMA_clock = ppu2.DMA_clock;
DMA_inc = ppu2.DMA_inc;
DMA_byte = ppu2.DMA_byte;
cycle = ppu2.cycle;
LYC_INT = ppu2.LYC_INT;
HBL_INT = ppu2.HBL_INT;
VBL_INT = ppu2.VBL_INT;
OAM_INT = ppu2.OAM_INT;
stat_line = ppu2.stat_line;
stat_line_old = ppu2.stat_line_old;
LCD_was_off = ppu2.LCD_was_off;
OAM_scan_index = ppu2.OAM_scan_index;
SL_sprites_index = ppu2.SL_sprites_index;
for (int i = 0; i < SL_sprites.Length; i++)
{
SL_sprites[i] = ppu2.SL_sprites[i];
}
write_sprite = ppu2.write_sprite;
no_scan = ppu2.no_scan;
DMA_OAM_access = ppu2.DMA_OAM_access;
OAM_access_read = ppu2.OAM_access_read;
OAM_access_write = ppu2.OAM_access_write;
VRAM_access_read = ppu2.VRAM_access_read;
VRAM_access_write = ppu2.VRAM_access_write;
read_case = ppu2.read_case;
internal_cycle = ppu2.internal_cycle;
y_tile = ppu2.y_tile;
y_scroll_offset = ppu2.y_scroll_offset;
x_tile = ppu2.x_tile;
x_scroll_offset = ppu2.x_scroll_offset;
tile_byte = ppu2.tile_byte;
sprite_fetch_cycles = ppu2.sprite_fetch_cycles;
fetch_sprite = ppu2.fetch_sprite;
going_to_fetch = ppu2.going_to_fetch;
first_fetch = ppu2.first_fetch;
sprite_fetch_counter = ppu2.sprite_fetch_counter;
for (int i = 0; i < sprite_attr_list.Length; i++)
{
sprite_attr_list[i] = ppu2.sprite_attr_list[i];
}
for (int i = 0; i < sprite_pixel_list.Length; i++)
{
sprite_pixel_list[i] = ppu2.sprite_pixel_list[i];
}
for (int i = 0; i < sprite_present_list.Length; i++)
{
sprite_present_list[i] = ppu2.sprite_present_list[i];
}
temp_fetch = ppu2.temp_fetch;
tile_inc = ppu2.tile_inc;
pre_render = ppu2.pre_render;
pre_render_2 = ppu2.pre_render_2;
for (int i = 0; i < tile_data.Length; i++)
{
tile_data[i] = ppu2.tile_data[i];
}
for (int i = 0; i < tile_data_latch.Length; i++)
{
tile_data_latch[i] = ppu2.tile_data_latch[i];
}
latch_counter = ppu2.latch_counter;
latch_new_data = ppu2.latch_new_data;
render_counter = ppu2.render_counter;
render_offset = ppu2.render_offset;
pixel_counter = ppu2.pixel_counter;
pixel = ppu2.pixel;
for (int i = 0; i < sprite_data.Length; i++)
{
sprite_data[i] = ppu2.sprite_data[i];
}
sl_use_index = ppu2.sl_use_index;
for (int i = 0; i < sprite_sel.Length; i++)
{
sprite_sel[i] = ppu2.sprite_sel[i];
}
no_sprites = ppu2.no_sprites;
evaled_sprites = ppu2.evaled_sprites;
for (int i = 0; i < SL_sprites_ordered.Length; i++)
{
SL_sprites_ordered[i] = ppu2.SL_sprites_ordered[i];
}
sprite_ordered_index = ppu2.sprite_ordered_index;
blank_frame = ppu2.blank_frame;
window_latch = ppu2.window_latch;
consecutive_sprite = ppu2.consecutive_sprite;
last_eval = ppu2.last_eval;
window_counter = ppu2.window_counter;
window_pre_render = ppu2.window_pre_render;
window_started = ppu2.window_started;
window_is_reset = ppu2.window_is_reset;
window_tile_inc = ppu2.window_tile_inc;
window_y_tile = ppu2.window_y_tile;
window_x_tile = ppu2.window_x_tile;
window_y_tile_inc = ppu2.window_y_tile_inc;
window_x_latch = ppu2.window_x_latch;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -346,11 +346,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// GBC compatibility register (I think)
case 0xFF4C:
if ((value != 0xC0) && (value != 0x80))
if ((value != 0xC0) && (value != 0x80))// && (value != 0xFF) && (value != 0x04))
{
Console.Write("GBC Compatibility? ");
Console.WriteLine(value);
GBC_compat = false;
if (GB_bios_register == 0)
{
var ppu2 = new GBC_PPU();
ppu2.Reg_Copy(ppu as GBC_PPU);
ppu = new GBC_PPU_GB();
ppu.Core = this;
ppu.Reg_Copy(ppu2);
}
// cpu operation is a function of hardware only
//cpu.is_GBC = GBC_compat;
}
@ -374,8 +386,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// Bios control register. Writing 1 permanently disables BIOS until a power cycle occurs
case 0xFF50:
//Console.WriteLine(value);
if (GB_bios_register != 1)
// Console.WriteLine(value);
if (GB_bios_register == 0)
{
GB_bios_register = value;
}

View File

@ -152,6 +152,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
}
public virtual void Reg_Copy(GBC_PPU ppu2)
{
}
// order sprites according to x coordinate
// note that for sprites of equal x coordinate, priority goes to first on the list
public virtual void reorder_and_assemble_sprites()