Skip to content

Commit

Permalink
Implement the V part of the H/V counter.
Browse files Browse the repository at this point in the history
Fixes #37 (Outrun's broken roads).
Fixes #38 (Outrun 2019's broken HUD).
Related to #23 (implementing the H/V counter).
Related to #19 (fixes Crue Ball failing to boot, Road Rash no longer
crashes).

Might get that Sonic hack which djohe mentioned working.
  • Loading branch information
Clownacy committed Feb 26, 2024
1 parent f0e84e1 commit 277a652
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions clownmdemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,10 @@ static cc_u16f M68kReadCallbackWithCycle(const void *user_data, cc_u32f address,
else if (address == 0xC00008 / 2)
{
/* H/V COUNTER */
/* TODO */
/* TODO: H counter. */
/* TODO: Double-resolution mode. */
/* TODO: The V counter emulation is incredibly inaccurate: the timing is likely wrong, and it should be incremented while in the blanking areas too. */
value = clownmdemu->state->current_scanline << 8;
}
else if (address >= 0xC00010 / 2 && address <= 0xC00016 / 2)
{
Expand Down Expand Up @@ -1619,7 +1622,6 @@ void ClownMDEmu_Parameters_Initialise(ClownMDEmu *clownmdemu, const ClownMDEmu_C

void ClownMDEmu_Iterate(const ClownMDEmu *clownmdemu, const ClownMDEmu_Callbacks *callbacks)
{
cc_u16f scanline;
Clown68000_ReadWriteCallbacks m68k_read_write_callbacks, mcd_m68k_read_write_callbacks;
CPUCallbackUserData cpu_callback_user_data;
cc_u8f h_int_counter;
Expand Down Expand Up @@ -1650,8 +1652,9 @@ void ClownMDEmu_Iterate(const ClownMDEmu *clownmdemu, const ClownMDEmu_Callbacks

clownmdemu->state->vdp.currently_in_vblank = cc_false;

for (scanline = 0; scanline < television_vertical_resolution; ++scanline)
for (clownmdemu->state->current_scanline = 0; clownmdemu->state->current_scanline < television_vertical_resolution; ++clownmdemu->state->current_scanline)
{
const cc_u16f scanline = clownmdemu->state->current_scanline;
const cc_u32f current_cycle = cycles_per_scanline * (1 + scanline);

/* Sync the 68k, since it's the one thing that can influence the VDP */
Expand Down
6 changes: 6 additions & 0 deletions clownmdemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,15 @@ typedef struct ClownMDEmu_State
cc_u8l control;
cc_u8l data;
} joypads[3];

cc_u16l current_scanline;

/* Z80 */
cc_u16l z80_bank;
cc_bool m68k_has_z80_bus;
cc_bool z80_reset;

/* Mega CD */
cc_bool m68k_has_mcd_m68k_bus;
cc_bool mcd_m68k_reset;
cc_u8l prg_ram_bank;
Expand Down

0 comments on commit 277a652

Please sign in to comment.