65C02 Emulator for esp32
Posted: Wed Apr 16, 2025 1:26 pm
I wont to run Taliforth2 with an esp32.
Is there a working version for emulating the 65C02 on the esp32?
Is there a working version for emulating the 65C02 on the esp32?
Code: Select all
//static void (*addrtable[256])();
//static void (*optable[256])();Code: Select all
static void (*optable[256])() = {
/* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | */
/* 0 */ brk_6502, ora, nop, nop, tsb, ora, asl, rmb0, php, ora, asl, nop, tsb, ora, asl, bbr0, /* 0 */
/* 1 */ bpl, ora, ora, nop, trb, ora, asl, rmb1, clc, ora, inc, nop, trb, ora, asl, bbr1, /* 1 */
/* 2 */ jsr, and_, nop, nop, bit_, and_, rol, rmb2, plp, and_, rol, nop, bit_, and_, rol, bbr2, /* 2 */
/* 3 */ bmi, and_, and_, nop, bit_, and_, rol, rmb3, sec, and_, dec, nop, bit_, and_, rol, bbr3, /* 3 */
/* 4 */ rti, eor, nop, nop, nop, eor, lsr, rmb4, pha, eor, lsr, nop, jmp, eor, lsr, bbr4, /* 4 */
/* 5 */ bvc, eor, eor, nop, nop, eor, lsr, rmb5, cli_, eor, phy, nop, nop, eor, lsr, bbr5, /* 5 */
/* 6 */ rts, adc, nop, nop, stz, adc, ror, rmb6, pla, adc, ror, nop, jmp, adc, ror, bbr6, /* 6 */
/* 7 */ bvs, adc, adc, nop, stz, adc, ror, rmb7, sei_, adc, ply, nop, jmp, adc, ror, bbr7, /* 7 */
/* 8 */ bra, sta_, nop, nop, sty, sta_, stx, smb0, dey,bit_imm,txa, nop, sty, sta_, stx, bbs0, /* 8 */
/* 9 */ bcc, sta_, sta_, nop, sty, sta_, stx, smb1, tya_, sta_, txs, nop, stz, sta_, stz, bbs1, /* 9 */
/* A */ ldy, lda, ldx, nop, ldy, lda, ldx, smb2, tay_, lda, tax, nop, ldy, lda, ldx, bbs2, /* A */
/* B */ bcs, lda, lda, nop, ldy, lda, ldx, smb3, clv, lda, tsx, nop, ldy, lda, ldx, bbs3, /* B */
/* C */ cpy, cmp, nop, nop, cpy, cmp, dec, smb4, iny, cmp, dex, wai, cpy, cmp, dec, bbs4, /* C */
/* D */ bne, cmp, cmp, nop, nop, cmp, dec, smb5, cld, cmp, phx,db6502, nop, cmp, dec, bbs5, /* D */
/* E */ cpx, sbc, nop, nop, cpx, sbc, inc, smb6, inx, sbc, nop, nop, cpx, sbc, inc, bbs6, /* E */
/* F */ beq, sbc, sbc, nop, nop, sbc, inc, smb7, sed_, sbc, plx, nop, nop, sbc, inc, bbs7 /* F */
};Code: Select all
(*addrtable[opcode])();
(*optable[opcode])();Code: Select all
uint8_t read6502(uint16_t address) {
if ( address == IO_AREA + 0x04) return(char_input());
return(RAM[address]);
}
void write6502(uint16_t address, uint8_t value) {
RAM[address] = value;
if (address == IO_AREA + 0x01){char_output(value);
//Serial.printf("char_output=%02x\n",value);
}
}Code: Select all
uint16_t blocknum = mem_6502_read16(x);
uint16_t buffer_address = mem_6502_read16(x + 2);Code: Select all
x+=4;Code: Select all
: myblockreader $f002 c@ ; \ Read a single byte from $f002 to start simulated block read.
' myblockreader BLOCK-READ-VECTOR ! ; \ Store the address of myblockreader in the BLOCK-READ-VECTOR.
: myblockwriter $f002 c! ; \ Write a single byte to $f002 to start a simulated block write.
' myblockwriter BLOCK-WRITE-VECTOR ! ; \ Store the address of myblockwriter in the BLOCK-WRITE-VECTOR.