Skip to content

Commit c035ead

Browse files
committed
MEGA65: fix some VIC4 reg default values
Inspirated by the two initial reports from FPhoton, doing some more as well.
1 parent f7b56ef commit c035ead

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

targets/mega65/vic4.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ void vic_reset ( void )
191191
// turn off possible remained sprite collision info
192192
vic_registers[0x1E] = 0;
193193
vic_registers[0x1F] = 0;
194+
vic_write_reg(0x56, 0x15); // VHDL init value for "sprite_extended_height_size" signal
195+
vic_write_reg(0x5B, 0x01); // VHDL init value for "chargen_y_scale" signal
196+
vic_write_reg(0x73, 0x11); // VHDL init value for "vicii_ycounter_scale_minus_zero" signal (unknown for the reg_alpha_Delay part ...)
197+
vic_write_reg(0x75, 0x80); // VHDL init value for "sprite_alpha_blend_value"
198+
vic_write_reg(0x7C, 0xD0); // it seems $D07C is initialized to $D0 (and then ROM to set lower bits to '2') on real MEGA65 by unknown mechanism. Let's do it here as a workaround
194199
vic4_reset_display_counters();
195200
SET_PHYSICAL_RASTER(0);
196201
chary16 = false;
@@ -616,6 +621,11 @@ static const char vic_registers_internal_mode_names[] = {'4', '3', '2'};
616621
*/
617622
void vic_write_reg ( unsigned int addr, Uint8 data )
618623
{
624+
#if 0
625+
// Used during testing
626+
if (addr == 0x56)
627+
DEBUGPRINT("TEST: writing $D0%02X with data $%02X at PC $%04X in hypervisor_mode=%d" NL, addr, data, cpu65.old_pc, (int)in_hypervisor);
628+
#endif
619629
//DEBUGPRINT("VIC4: write VIC%c reg $%02X (internally $%03X) with data $%02X" NL, XEMU_LIKELY(addr < 0x180) ? vic_registers_internal_mode_names[addr >> 7] : '?', addr & 0x7F, addr, data);
620630
// IMPORTANT NOTE: writing of vic_registers[] happens only *AFTER* this switch/case construct! This means if you need to do this before, you must do it manually at the right "case"!!!!
621631
// if you do so, you can even use "return" instead of "break" to save the then-redundant write of the register
@@ -661,7 +671,7 @@ void vic_write_reg ( unsigned int addr, Uint8 data )
661671
interrupt_checker();
662672
break;
663673
CASE_VIC_ALL(0x1A):
664-
data &= 0xF;
674+
data &= 0xF; // technically bit 4 is missing (raster-x interrupt), but Xemu can't support that anyway (same for D019?)
665675
break;
666676
CASE_VIC_ALL(0x1B): // sprite data priority
667677
CASE_VIC_ALL(0x1C): // sprite multicolour
@@ -908,10 +918,10 @@ Uint8 vic_read_reg ( int unsigned addr )
908918
//DEBUGPRINT("VIC4: $D018 is read as $%02X @ PC=$%04X" NL, result, cpu65.pc);
909919
break;
910920
CASE_VIC_ALL(0x19):
911-
result = interrupt_status | (64 + 32 + 16);
921+
result = interrupt_status | (64 + 32);
912922
break;
913923
CASE_VIC_ALL(0x1A):
914-
result |= 0xF0;
924+
result |= (128 + 64 + 32);
915925
break;
916926
CASE_VIC_ALL(0x1B): // sprite data priority
917927
CASE_VIC_ALL(0x1C): // sprite multicolour

0 commit comments

Comments
 (0)