ref: 3e48e5e879677f7b285803feb799ad4a31ceeffb
parent: 3e6ad74336a451061ca2be070565e34f7215c2de
author: Jean-André Santoni <jean.andre.santoni@gmail.com>
date: Thu Aug 28 05:30:42 EDT 2025
have z80.c compiled
--- a/mkfile
+++ b/mkfile
@@ -3,6 +3,7 @@
BIN=/$objtype/bin/games
TARG=sms
OFILES=\
+ z80.$O\
mem.$O\
vdp.$O\
psg.$O\
--- a/z80.c
+++ b/z80.c
@@ -193,7 +193,7 @@
static int
branch(int cc, int t)
{- u16int v = (int8_t)fetch8();
+ u16int v = (s8int)fetch8();
if(!cc)
return t + 7;
pc += v;
@@ -492,12 +492,12 @@
v = z80read(HL());
z80write(HL(), v >> 4 | s[rA] << 4);
s[rA] = s[rA] & 0xf0 | v & 0x0f;
-#if 0
+ if (0){case 0x6f:
v = z80read(HL());
z80write(HL(), v << 4 | s[rA] & 0xf);
s[rA] = s[rA] & 0xf0 | v >> 4;
-#endif
+ }
s[rF] &= FLAGC;
if(s[rA] == 0)
s[rF] |= FLAGZ;
@@ -570,7 +570,6 @@
return 16;
}
sysfatal("undefined z80 opcode ed%.2x at pc=%#.4x", op, curpc);- return 0;
}
static int
@@ -645,7 +644,6 @@
case 0x2e: ix[n] = ix[n] & 0xff00 | fetch8(); return 11;
}
sysfatal("undefined z80 opcode %.2x%.2x at pc=%#.4x", n ? 0xfd : 0xdd, op, curpc);- return 0;
}
int
@@ -655,7 +653,7 @@
u16int v, w;
if((z80bus & RESET) != 0){- printf("reset\n");+ print("reset");curpc = pc = 0;
intm = 0;
ipage = 0;
@@ -662,18 +660,18 @@
return 1;
}
if((z80bus & BUSACK) != 0){- printf("busack\n");+ print("busack");if((z80bus & BUSREQ) == 0)
z80bus &= ~BUSACK;
return 1;
}
if((z80bus & BUSREQ) != 0){- printf("busreq\n");+ print("busreq");z80bus |= BUSACK;
return 1;
}
if(z80irq != 0 && (intm & 0x80) != 0){- //printf("irq\n");+ print("irq");push16(pc);
intm &= 0x3f;
switch(intm & 3){@@ -685,9 +683,9 @@
}
}
curpc = pc;
- // printf("%x AF %.2x%.2x BC %.2x%.2x DE %.2x%.2x HL %.2x%.2x IX %.4x IY %.4x\n", curpc, s[rA], s[rF], s[rB], s[rC], s[rD], s[rE], s[rH], s[rL], ix[0], ix[1]);+ // print("%x AF %.2x%.2x BC %.2x%.2x DE %.2x%.2x HL %.2x%.2x IX %.4x IY %.4x", curpc, s[rA], s[rF], s[rB], s[rC], s[rD], s[rE], s[rH], s[rL], ix[0], ix[1]);op = fetch8();
- // printf("op: %x\n", op);+ // print("op: %x", op); switch(op >> 6){case 1: return move(op >> 3 & 7, op & 7);
case 2: return alu(op >> 3 & 7, op & 7);
@@ -889,5 +887,4 @@
case 0xff: return call2(0x38, 1);
}
sysfatal("undefined z80 opcode %#.2x at pc=%#.4x", op, curpc);- return 0;
}
--
⑨