- True Virtual ][ style logging so we can compare logs easier

- Fix: RAM Expansion Card now works
This commit is contained in:
tudnai 2020-05-28 12:37:32 -07:00
parent f79be51bb1
commit b9efc3e009
2 changed files with 208 additions and 159 deletions

View File

@ -413,123 +413,7 @@ void auxMemorySelect() {
uint8_t * current_RAM_bank = Apple2_64K_AUX + 0xC000;
INLINE uint8_t ioRead( uint16_t addr ) {
// if (outdev) fprintf(outdev, "ioRead:%04X\n", addr);
// printf("ioRead:%04X (PC:%04X)\n", addr, m6502.PC);
uint8_t currentMagnet = 0;
// TODO: This is for checking only, should be either removed or the entire ioRead should based on binary search, whatever is faster
if ( addr == io_KBD ) {
// clk_6502_per_frm_max = clk_6502_per_frm_max > 32768 ? clk_6502_per_frm_max - 32768 : 0; // ECO Mode!
return Apple2_64K_RAM[io_KBD];
}
switch ( (uint8_t)addr ) {
case (uint8_t)io_KBD:
// if ( RAM[io_KBD] > 0x7F ) printf("io_KBD:%04X\n", addr);
return Apple2_64K_RAM[io_KBD];
case (uint8_t)io_KBDSTRB:
// TODO: This is very slow!
// printf("io_KBDSTRB\n");
Apple2_64K_RAM[io_KBD] &= 0x7F;
return Apple2_64K_RAM[io_KBDSTRB];
case (uint8_t)io_SPKR:
spkr_toggle();
return Apple2_64K_RAM[io_SPKR];
case (uint8_t)io_VID_RDTEXT:
return videoMode.text << 7;
case (uint8_t)io_VID_ALTCHAR:
return videoMode.altChr << 7;
case (uint8_t)io_VID_RD80VID:
return videoMode.col80 << 7;
case (uint8_t)io_TAPEIN:
return MEMcfg.txt_page_2 << 7;
case (uint8_t)io_RDCXROM:
return MEMcfg.int_Cx_ROM << 7;
case (uint8_t)io_RDALTZP:
return MEMcfg.ALT_ZP << 7;
case (uint8_t)io_RDC3ROM:
return MEMcfg.slot_C3_ROM << 7;
case (uint8_t)io_RD80STORE:
return MEMcfg.is_80STORE << 7;
case (uint8_t)io_VID_TXTPAGE1:
// printf("io_VID_TXTPAGE1\n");
MEMcfg.txt_page_2 = 0;
textPageSelect();
break;
case (uint8_t)io_VID_TXTPAGE2:
// printf("io_VID_TXTPAGE2\n");
MEMcfg.txt_page_2 = 1;
textPageSelect();
break;
case (uint8_t)io_VID_Text_OFF:
videoMode.text = 0;
break;
case (uint8_t)io_VID_Text_ON:
videoMode.text = 1;
break;
case (uint8_t)io_VID_Mixed_OFF:
videoMode.mixed = 0;
break;
case (uint8_t)io_VID_Mixed_ON:
videoMode.mixed = 1;
break;
case (uint8_t)io_VID_Hires_OFF:
videoMode.hires = 0;
break;
case (uint8_t)io_VID_Hires_ON:
videoMode.hires = 1;
break;
case (uint8_t)io_PDL0:
case (uint8_t)io_PDL1:
case (uint8_t)io_PDL2:
case (uint8_t)io_PDL3:
printf("PDL%d: %d\n", addr - io_PDL0, pdl_read( addr - io_PDL0 ));
return pdl_read( addr - io_PDL0 );
case (uint8_t)io_PDL_STROBE:
return pdl_reset();
case (uint8_t)io_MEM_RDRAM_NOWR_2:
case (uint8_t)io_MEM_RDROM_WRAM_2:
case (uint8_t)io_MEM_RDROM_NOWR_2:
case (uint8_t)io_MEM_RDRAM_WRAM_2:
case (uint8_t)io_MEM_RDRAM_NOWR_2_:
case (uint8_t)io_MEM_RDROM_WRAM_2_:
case (uint8_t)io_MEM_RDROM_NOWR_2_:
case (uint8_t)io_MEM_RDRAM_WRAM_2_:
case (uint8_t)io_MEM_RDRAM_NOWR_1:
case (uint8_t)io_MEM_RDROM_WRAM_1:
case (uint8_t)io_MEM_RDROM_NOWR_1:
case (uint8_t)io_MEM_RDRAM_WRAM_1:
case (uint8_t)io_MEM_RDRAM_NOWR_1_:
case (uint8_t)io_MEM_RDROM_WRAM_1_:
case (uint8_t)io_MEM_RDROM_NOWR_1_:
case (uint8_t)io_MEM_RDRAM_WRAM_1_:
INLINE void io_RAM_EXP( uint16_t addr ) {
if ( MEMcfg.RAM_16K || MEMcfg.RAM_128K ) {
uint8_t * RAM_BANK = Apple2_64K_AUX + 0xC000;
@ -652,6 +536,128 @@ INLINE uint8_t ioRead( uint16_t addr ) {
} // if there is RAM expansion card installed
}
INLINE uint8_t ioRead( uint16_t addr ) {
// if (outdev) fprintf(outdev, "ioRead:%04X\n", addr);
// printf("ioRead:%04X (PC:%04X)\n", addr, m6502.PC);
uint8_t currentMagnet = 0;
// TODO: This is for checking only, should be either removed or the entire ioRead should based on binary search, whatever is faster
if ( addr == io_KBD ) {
// clk_6502_per_frm_max = clk_6502_per_frm_max > 32768 ? clk_6502_per_frm_max - 32768 : 0; // ECO Mode!
return Apple2_64K_RAM[io_KBD];
}
switch ( (uint8_t)addr ) {
case (uint8_t)io_KBD:
// if ( RAM[io_KBD] > 0x7F ) printf("io_KBD:%04X\n", addr);
return Apple2_64K_RAM[io_KBD];
case (uint8_t)io_KBDSTRB:
// TODO: This is very slow!
// printf("io_KBDSTRB\n");
Apple2_64K_RAM[io_KBD] &= 0x7F;
return Apple2_64K_RAM[io_KBDSTRB];
case (uint8_t)io_SPKR:
spkr_toggle();
return Apple2_64K_RAM[io_SPKR];
case (uint8_t)io_VID_RDTEXT:
return videoMode.text << 7;
case (uint8_t)io_VID_ALTCHAR:
return videoMode.altChr << 7;
case (uint8_t)io_VID_RD80VID:
return videoMode.col80 << 7;
case (uint8_t)io_TAPEIN:
return MEMcfg.txt_page_2 << 7;
case (uint8_t)io_RDCXROM:
return MEMcfg.int_Cx_ROM << 7;
case (uint8_t)io_RDALTZP:
return MEMcfg.ALT_ZP << 7;
case (uint8_t)io_RDC3ROM:
return MEMcfg.slot_C3_ROM << 7;
case (uint8_t)io_RD80STORE:
return MEMcfg.is_80STORE << 7;
case (uint8_t)io_VID_TXTPAGE1:
// printf("io_VID_TXTPAGE1\n");
MEMcfg.txt_page_2 = 0;
textPageSelect();
break;
case (uint8_t)io_VID_TXTPAGE2:
// printf("io_VID_TXTPAGE2\n");
MEMcfg.txt_page_2 = 1;
textPageSelect();
break;
case (uint8_t)io_VID_Text_OFF:
videoMode.text = 0;
break;
case (uint8_t)io_VID_Text_ON:
videoMode.text = 1;
break;
case (uint8_t)io_VID_Mixed_OFF:
videoMode.mixed = 0;
break;
case (uint8_t)io_VID_Mixed_ON:
videoMode.mixed = 1;
break;
case (uint8_t)io_VID_Hires_OFF:
videoMode.hires = 0;
break;
case (uint8_t)io_VID_Hires_ON:
videoMode.hires = 1;
break;
case (uint8_t)io_PDL0:
case (uint8_t)io_PDL1:
case (uint8_t)io_PDL2:
case (uint8_t)io_PDL3:
printf("PDL%d: %d\n", addr - io_PDL0, pdl_read( addr - io_PDL0 ));
return pdl_read( addr - io_PDL0 );
case (uint8_t)io_PDL_STROBE:
return pdl_reset();
case (uint8_t)io_MEM_RDRAM_NOWR_2:
case (uint8_t)io_MEM_RDROM_WRAM_2:
case (uint8_t)io_MEM_RDROM_NOWR_2:
case (uint8_t)io_MEM_RDRAM_WRAM_2:
case (uint8_t)io_MEM_RDRAM_NOWR_2_:
case (uint8_t)io_MEM_RDROM_WRAM_2_:
case (uint8_t)io_MEM_RDROM_NOWR_2_:
case (uint8_t)io_MEM_RDRAM_WRAM_2_:
case (uint8_t)io_MEM_RDRAM_NOWR_1:
case (uint8_t)io_MEM_RDROM_WRAM_1:
case (uint8_t)io_MEM_RDROM_NOWR_1:
case (uint8_t)io_MEM_RDRAM_WRAM_1:
case (uint8_t)io_MEM_RDRAM_NOWR_1_:
case (uint8_t)io_MEM_RDROM_WRAM_1_:
case (uint8_t)io_MEM_RDROM_NOWR_1_:
case (uint8_t)io_MEM_RDRAM_WRAM_1_:
io_RAM_EXP(addr);
break;
// TODO: Make code "card insertable to slot" / aka slot independent and dynamically add/remove
@ -761,114 +767,136 @@ void kbdUp () {
INLINE void ioWrite( uint16_t addr, uint8_t val ) {
// if (outdev) fprintf(outdev, "ioWrite:%04X (A:%02X)\n", addr, m6502.A);
switch (addr) {
case io_KBDSTRB:
switch ( (uint8_t)addr ) {
case (uint8_t)io_KBDSTRB:
Apple2_64K_RAM[io_KBD] &= 0x7F;
break;
case io_SPKR:
case (uint8_t)io_SPKR:
spkr_toggle();
break;
case io_RDMAINRAM:
case (uint8_t)io_RDMAINRAM:
// printf("io_RDMAINRAM\n");
MEMcfg.RD_AUX_MEM = 0;
auxMemorySelect();
break;
case io_RDCARDRAM:
case (uint8_t)io_RDCARDRAM:
// printf("io_RDCARDRAM\n");
MEMcfg.RD_AUX_MEM = 1;
auxMemorySelect();
break;
case io_WRMAINRAM:
case (uint8_t)io_WRMAINRAM:
// printf("io_WRMAINRAM\n");
MEMcfg.WR_AUX_MEM = 0;
auxMemorySelect();
break;
case io_WRCARDRAM:
case (uint8_t)io_WRCARDRAM:
// printf("io_WRCARDRAM\n");
MEMcfg.WR_AUX_MEM = 1;
auxMemorySelect();
break;
case io_SETSTDZP:
case (uint8_t)io_SETSTDZP:
MEMcfg.ALT_ZP = 0;
// TODO: set zero page table to RAM
break;
case io_SETALTZP:
case (uint8_t)io_SETALTZP:
MEMcfg.ALT_ZP = 1;
// TODO: set zero page table to AUX
break;
case io_SETSLOTCXROM:
case (uint8_t)io_SETSLOTCXROM:
// printf("io_SETSLOTCXROM\n");
MEMcfg.int_Cx_ROM = 0;
// TODO: set Cx00 ROM area table to SLOT
break;
case io_SETINTCXROM:
case (uint8_t)io_SETINTCXROM:
// printf("io_SETINTCXROM\n");
MEMcfg.int_Cx_ROM = 1;
// TODO: set Cx00 ROM area table to INT
break;
case io_SETSLOTC3ROM:
case (uint8_t)io_SETSLOTC3ROM:
// printf("io_SETSLOTC3ROM\n");
MEMcfg.slot_C3_ROM = 1;
// TODO: set C300 ROM area table to SLOT
break;
case io_SETINTC3ROM:
case (uint8_t)io_SETINTC3ROM:
// printf("io_SETINTC3ROM\n");
MEMcfg.slot_C3_ROM = 0;
// TODO: set C300 ROM area table to INT
break;
case io_VID_CLR80VID:
case (uint8_t)io_VID_CLR80VID:
// printf("io_VID_CLR80VID\n");
videoMode.col80 = 0;
break;
case io_VID_SET80VID:
case (uint8_t)io_VID_SET80VID:
videoMode.col80 = 1;
break;
case io_VID_CLRALTCHAR:
case (uint8_t)io_VID_CLRALTCHAR:
videoMode.altChr = 0;
break;
case io_VID_SETALTCHAR:
case (uint8_t)io_VID_SETALTCHAR:
videoMode.altChr = 1;
break;
case io_80STOREOFF:
case (uint8_t)io_80STOREOFF:
// printf("io_80STOREOFF\n");
MEMcfg.is_80STORE = 0;
textPageSelect();
break;
case io_80STOREON:
case (uint8_t)io_80STOREON:
// printf("io_80STOREON\n");
MEMcfg.is_80STORE = 1;
textPageSelect();
break;
case io_VID_TXTPAGE1:
case (uint8_t)io_VID_TXTPAGE1:
// printf("io_VID_TXTPAGE1\n");
MEMcfg.txt_page_2 = 0;
textPageSelect();
break;
case io_VID_TXTPAGE2:
case (uint8_t)io_VID_TXTPAGE2:
// printf("io_VID_TXTPAGE2\n");
MEMcfg.txt_page_2 = 1;
textPageSelect();
break;
case (uint8_t)io_MEM_RDRAM_NOWR_2:
case (uint8_t)io_MEM_RDROM_WRAM_2:
case (uint8_t)io_MEM_RDROM_NOWR_2:
case (uint8_t)io_MEM_RDRAM_WRAM_2:
case (uint8_t)io_MEM_RDRAM_NOWR_2_:
case (uint8_t)io_MEM_RDROM_WRAM_2_:
case (uint8_t)io_MEM_RDROM_NOWR_2_:
case (uint8_t)io_MEM_RDRAM_WRAM_2_:
case (uint8_t)io_MEM_RDRAM_NOWR_1:
case (uint8_t)io_MEM_RDROM_WRAM_1:
case (uint8_t)io_MEM_RDROM_NOWR_1:
case (uint8_t)io_MEM_RDRAM_WRAM_1:
case (uint8_t)io_MEM_RDRAM_NOWR_1_:
case (uint8_t)io_MEM_RDROM_WRAM_1_:
case (uint8_t)io_MEM_RDROM_NOWR_1_:
case (uint8_t)io_MEM_RDRAM_WRAM_1_:
io_RAM_EXP(addr);
break;
default:
break;
}
@ -1010,7 +1038,12 @@ INLINE uint16_t fetch16() {
}
#endif
m6502.PC += 2;
disHexW( disassembly.pOpcode, word );
// disHexW( disassembly.pOpcode, word );
// Virtual ][ Style
disHexB( disassembly.pOpcode, (uint8_t)word );
disHexB( disassembly.pOpcode, (uint8_t)(word >> 8));
return word;
}

View File

@ -89,7 +89,24 @@ INLINE void printDisassembly( FILE * f ) {
// m6502.C ? 'C' : 'c'
// );
fprintf( f, "%llu\t%llu %s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t;\t%s\n", // Virtual ][ style
// fprintf( f, "%llu\t%llu %s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t;\t%s\n", // Virtual ][ style
// ++discnt,
// m6502.clktime + clkfrm,
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper,
// m6502.A,
// m6502.X,
// m6502.Y,
// 0,
// //getFlags2(),
// m6502.SP,
// disassembly.comment
// );
// Virtual ][ Style
fprintf( f, "%llu\t%llu\t%s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\n", // Virtual ][ style
++discnt,
m6502.clktime + clkfrm,
disassembly.addr,
@ -99,11 +116,10 @@ INLINE void printDisassembly( FILE * f ) {
m6502.A,
m6502.X,
m6502.Y,
0,
//getFlags2(),
m6502.SP,
disassembly.comment
getFlags2().SR,
m6502.SP
);
}
}