1
0
mirror of https://github.com/mist64/perfect6502.git synced 2025-08-09 15:24:59 +00:00

fixed kernal calls, used PLP/RTS instead of buggy RTI, switched to bit-coded

node bitmap
This commit is contained in:
Michael Steil
2010-09-23 02:35:50 +00:00
parent ef30dcb753
commit 0dbfeded09
2 changed files with 16 additions and 25 deletions

View File

@@ -140,7 +140,7 @@ arrayContains(nodenum_t el)
typedef struct { typedef struct {
nodenum_t *list; nodenum_t *list;
count_t count; count_t count;
char *bitmap; int *bitmap;
} list_t; } list_t;
list_t recalc; list_t recalc;
@@ -148,14 +148,14 @@ list_t recalc;
void void
clearRecalc() clearRecalc()
{ {
bzero(recalc.bitmap, sizeof(*recalc.bitmap)*NODES); bzero(recalc.bitmap, sizeof(*recalc.bitmap)*NODES/sizeof(int));
recalc.count = 0; recalc.count = 0;
} }
BOOL BOOL
recalcListContains(nodenum_t el) recalcListContains(nodenum_t el)
{ {
return recalc.bitmap[el]; return (recalc.bitmap[el>>5] >> (el & 31)) & 1;
} }
void addNodeToGroup(nodenum_t i); void addNodeToGroup(nodenum_t i);
@@ -240,7 +240,7 @@ addRecalcNode(nodenum_t nn)
if (recalcListContains(nn)) if (recalcListContains(nn))
return; return;
recalc.list[recalc.count++] = nn; recalc.list[recalc.count++] = nn;
recalc.bitmap[nn] = 1; recalc.bitmap[nn>>5] |= 1 << (nn & 31);
} }
void void
@@ -322,8 +322,8 @@ recalcNodeList(nodenum_t *list, count_t count)
printarray(list, count); printarray(list, count);
#endif #endif
nodenum_t list1[NODES]; nodenum_t list1[NODES];
char bitmap1[NODES]; int bitmap1[NODES/sizeof(int)+1];
char bitmap2[NODES]; int bitmap2[NODES/sizeof(int)+1];
list_t current; list_t current;
current.list = list; current.list = list;
@@ -860,16 +860,20 @@ step()
Z = (P >> 1) & 1; Z = (P >> 1) & 1;
C = P & 1; C = P & 1;
#if 1
kernal_dispatch(); kernal_dispatch();
P &= 0x7C; // clear N, Z, C
P |= (N << 7) | (Z << 1) | C;
/* /*
LDA #P LDA #P
PHA PHA
LDA #A LDA #A
LDX #X LDX #X
LDY #Y LDY #Y
RTI PLP
RTS
//XXX we could do RTI instead, but RTI is broken!
*/ */
memory[0xf800] = 0xA9; memory[0xf800] = 0xA9;
memory[0xf801] = P; memory[0xf801] = P;
@@ -880,22 +884,9 @@ step()
memory[0xf806] = X; memory[0xf806] = X;
memory[0xf807] = 0xA0; memory[0xf807] = 0xA0;
memory[0xf808] = Y; memory[0xf808] = Y;
memory[0xf809] = 0x40; memory[0xf809] = 0x28;
memory[0xf80a] = 0x60;
#if 0
PC = memory[0x0100 + S+1] | memory[0x0100 + S + 2] << 8;
PC++;
S += 2;
P &= 0x7C; // clear N, Z, C
P |= (N << 7) | (Z << 1) | C;
setA(A);
setX(X);
setY(Y);
// setP(P);
// recalcAllNodes();
#endif
#endif
} }
} }

View File

@@ -399,6 +399,7 @@ CHRIN() {
/* CHROUT */ /* CHROUT */
static void static void
CHROUT() { CHROUT() {
exit(1);
#if 0 #if 0
int a = *(unsigned short*)(&RAM[0x0100+S+1]) + 1; int a = *(unsigned short*)(&RAM[0x0100+S+1]) + 1;
int b = *(unsigned short*)(&RAM[0x0100+S+3]) + 1; int b = *(unsigned short*)(&RAM[0x0100+S+3]) + 1;
@@ -872,8 +873,7 @@ IOBASE() {
int int
kernal_dispatch() { kernal_dispatch() {
{ printf("kernal_dispatch $%04X; ", PC); int i; printf("stack (%02X): ", S); for (i=S+1; i<0x100; i++) { printf("%02X ", RAM[0x0100+i]); } printf("\n"); } //{ printf("kernal_dispatch $%04X; ", PC); int i; printf("stack (%02X): ", S); for (i=S+1; i<0x100; i++) { printf("%02X ", RAM[0x0100+i]); } printf("\n"); }
exit(1);
unsigned int new_pc; unsigned int new_pc;
switch(PC) { switch(PC) {
case 0x0073: CHRGET(); break; case 0x0073: CHRGET(); break;