You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
6.7 KiB
C

void showscreen(char *screen, int frame, int cx, int cy, int blink);
void showdebug();
void showmemory(int memorypos);
int getinst(char *str,int ip);
void showinst(int memorypos,struct cpustruct cpu);
extern int mempos;
//---------------------------------------------------------------------------
//- Debugging datas ---------------------------------------------------------
//---------------------------------------------------------------------------
static char opcodes[256][4]={
"brk\0","ora\0","nxt\0","ora\0","tsb\0","ora\0","asl\0","ora\0","php\0","ora\0","asl\0","rhi\0","tsb\0","ora\0","asl\0","mul\0", // 0x00
"bpl\0","ora\0","ora\0","ora\0","trb\0","ora\0","asl\0","ora\0","clc\0","ora\0","inc\0","rhx\0","trb\0","ora\0","asl\0","mul\0", // 0x10
"jsr\0","and\0","ent\0","and\0","bit\0","and\0","rol\0","and\0","plp\0","and\0","rol\0","rli\0","bit\0","and\0","rol\0","mul\0", // 0x20
"bmi\0","and\0","and\0","and\0","bit\0","and\0","rol\0","and\0","sec\0","and\0","dec\0","rlx\0","bit\0","and\0","rol\0","mul\0", // 0x30
"rti\0","eor\0","nxa\0","eor\0","rea\0","eor\0","lsr\0","eor\0","pha\0","eor\0","lsr\0","rha\0","jmp\0","eor\0","lsr\0","div\0", // 0x40
"bvc\0","eor\0","eor\0","eor\0","rei\0","eor\0","lsr\0","eor\0","cli\0","eor\0","phy\0","rhy\0","txi\0","eor\0","lsr\0","div\0", // 0x50
"rts\0","adc\0","per\0","adc\0","stz\0","adc\0","ror\0","adc\0","pla\0","adc\0","ror\0","rla\0","jmp\0","adc\0","ror\0","div\0", // 0x60
"bvs\0","adc\0","adc\0","adc\0","stz\0","adc\0","ror\0","adc\0","sei\0","adc\0","ply\0","rly\0","jmp\0","adc\0","ror\0","div\0", // 0x70
"bra\0","sta\0","rer\0","sta\0","sty\0","sta\0","stx\0","sta\0","dey\0","bit\0","txa\0","txr\0","sty\0","sta\0","stx\0","zea\0", // 0x80
"bcc\0","sta\0","sta\0","sta\0","sty\0","sta\0","stx\0","sta\0","tya\0","sta\0","txs\0","txy\0","stz\0","sta\0","stz\0","sea\0", // 0x90
"ldy\0","lda\0","ldx\0","lda\0","ldy\0","lda\0","ldx\0","lda\0","tay\0","lda\0","tax\0","trx\0","ldy\0","lda\0","ldx\0","tda\0", // 0xa0
"bcs\0","lda\0","lda\0","lda\0","ldy\0","lda\0","ldx\0","lda\0","clv\0","lda\0","tsx\0","tyx\0","ldy\0","lda\0","ldx\0","tad\0", // 0xb0
"cpy\0","cmp\0","rep\0","cmp\0","cpy\0","cmp\0","dec\0","cmp\0","iny\0","cmp\0","dex\0","wai\0","cpy\0","cmp\0","dec\0","pld\0", // 0xc0
"bne\0","cmp\0","cmp\0","cmp\0","pei\0","cmp\0","dec\0","cmp\0","cld\0","cmp\0","phx\0","stp\0","tix\0","cmp\0","dec\0","phd\0", // 0xd0
"cpx\0","sbc\0","sep\0","sbc\0","cpx\0","sbc\0","inc\0","sbc\0","inx\0","sbc\0","nop\0","xba\0","cpx\0","sbc\0","inc\0","mmu\0", // 0xe0
"beq\0","sbc\0","sbc\0","sbc\0","pea\0","sbc\0","inc\0","sbc\0","sed\0","sbc\0","plx\0","xce\0","jsr\0","sbc\0","inc\0","???\0"};
/* 0 - nothing
1 - ix ($xx,x)
2 - zp $xx
3 - abs $xxyy
4 - iy ($xx),y
5 - zpx $xx,x
6 - aby $xxyy,y
7 - abx $xxyy,x
8 - rel +-127
9 - ind ($xxyy)
10 - zpy $xx,y
11 - dir #$xx
12 - ajm $xxxx
13 - abs $xx,s
14 - isy ($xx,s),y
15 - zp ($xx)
16 - abs $xx,r
17 - isy ($xx,r),y
18 - dir #$xxyy
*/
static char codesizetable[]=
{1,2,2,3,2,2,3,3,2,3,2,2,3,2,2,2,2,2,3};
static char addrmode[4][256]={
{
0,1, 0, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 2, // 0x00
8,4,15, 14, 2,5, 5,17,0, 6,0,0, 3,7,7, 5, // 0x10
12,1, 0, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 3, // 0x20
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x30
0,1, 0, 13, 3,2, 2,16,0,18,0,0,12,3,3, 2, // 0x40
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 5, // 0x50
0,1, 8, 13, 2,2, 2,16,0,18,0,0, 9,3,3, 3, // 0x60
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x70
8,1, 8, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 0, // 0x80
8,4,15, 14, 5,5,10,17,0, 6,0,0, 3,7,7, 0, // 0x90
18,1,18, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 0, // 0xa0
8,4,15, 14, 5,5,10,17,0, 6,0,0, 7,7,6, 0, // 0xb0
18,1,11, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 0, // 0xc0
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 0, // 0xd0
18,1,11, 13, 2,2, 2,16,0,18,0,0, 3,3,3,11, // 0xe0
8,4,15, 14, 3,5, 5,17,0, 6,0,0, 3,7,7, 0}, // 0xf0
{
0,1, 0, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 2, // 0x00
8,4,15, 14, 2,5, 5,17,0, 6,0,0, 3,7,7, 5, // 0x10
12,1, 0, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 3, // 0x20
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x30
0,1, 0, 13, 3,2, 2,16,0,11,0,0,12,3,3, 2, // 0x40
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 5, // 0x50
0,1, 8, 13, 2,2, 2,16,0,11,0,0, 9,3,3, 3, // 0x60
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x70
8,1, 8, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 0, // 0x80
8,4,15, 14, 5,5,10,17,0, 6,0,0, 3,7,7, 0, // 0x90
11,1,11, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 0, // 0xa0
8,4,15, 14, 5,5,10,17,0, 6,0,0, 7,7,6, 0, // 0xb0
11,1,11, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 0, // 0xc0
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 0, // 0xd0
11,1,11, 13, 2,2, 2,16,0,11,0,0, 3,3,3,11, // 0xe0
8,4,15, 14, 3,5, 5,17,0, 6,0,0, 3,7,7, 0}, // 0xf0
{
0,1, 0, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 2, // 0x00
8,4,15, 14, 2,5, 5,17,0, 6,0,0, 3,7,7, 5, // 0x10
12,1, 0, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 3, // 0x20
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x30
0,1, 0, 13, 3,2, 2,16,0,18,0,0,12,3,3, 2, // 0x40
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 5, // 0x50
0,1, 8, 13, 2,2, 2,16,0,18,0,0, 9,3,3, 3, // 0x60
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x70
8,1, 8, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 0, // 0x80
8,4,15, 14, 5,5,10,17,0, 6,0,0, 3,7,7, 0, // 0x90
18,1,18, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 0, // 0xa0
8,4,15, 14, 5,5,10,17,0, 6,0,0, 7,7,6, 0, // 0xb0
18,1,11, 13, 2,2, 2,16,0,18,0,0, 3,3,3, 0, // 0xc0
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 0, // 0xd0
18,1,11, 13, 2,2, 2,16,0,18,0,0, 3,3,3,11, // 0xe0
8,4,15, 14, 3,5, 5,17,0, 6,0,0, 3,7,7, 0}, // 0xf0
{
0,1, 0, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 2, // 0x00
8,4,15, 14, 2,5, 5,17,0, 6,0,0, 3,7,7, 5, // 0x10
12,1, 0, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 3, // 0x20
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x30
0,1, 0, 13, 3,2, 2,16,0,11,0,0,12,3,3, 2, // 0x40
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 5, // 0x50
0,1, 8, 13, 2,2, 2,16,0,11,0,0, 9,3,3, 3, // 0x60
8,4,15, 14, 5,5, 5,17,0, 6,0,0, 3,7,7, 7, // 0x70
8,1, 8, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 0, // 0x80
8,4,15, 14, 5,5,10,17,0, 6,0,0, 3,7,7, 0, // 0x90
11,1,11, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 0, // 0xa0
8,4,15, 14, 5,5,10,17,0, 6,0,0, 7,7,6, 0, // 0xb0
11,1,11, 13, 2,2, 2,16,0,11,0,0, 3,3,3, 0, // 0xc0
8,4,15, 14,15,5, 5,17,0, 6,0,0, 0,7,7, 0, // 0xd0
11,1,11, 13, 2,2, 2,16,0,11,0,0, 3,3,3,11, // 0xe0
8,4,15, 14, 3,5, 5,17,0, 6,0,0, 3,7,7, 0}}; // 0xf0