1
0
mirror of https://github.com/jscrane/r65emu.git synced 2025-04-22 17:37:08 +00:00

More z80 ()

- improve cpm test harness
- speedup ldir / lddr
- fix prelim.com failure
This commit is contained in:
Stephen Crane 2025-03-22 17:19:06 +00:00 committed by GitHub
parent 653e26b13f
commit b761a3de79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 86 additions and 44 deletions

6
src/.gitignore vendored Normal file

@ -0,0 +1,6 @@
.*.swp
*.o
z80cpm/cpm
z80test/z80test
z80test/tests.me

@ -1307,7 +1307,7 @@ private:
HL++;
b += A;
flags.P = (BC != 0);
_35(b);
flags._3 = (b & 0x08) != 0;
flags._5 = ((b & 0x02) != 0);
flags.N = flags.H = 0;
}
@ -1416,24 +1416,30 @@ private:
_sz35(B);
}
inline void ldir() {
uint8_t b = _rb(HL);
BC--;
_sb(DE, b);
_mc(DE, 1);
_mc(DE, 1);
uint8_t b;
do {
b = _rb(HL);
_sb(DE, b);
_mc(DE, 1);
_mc(DE, 1);
if (--BC) {
_mc(DE, 1); _mc(DE, 1); _mc(DE, 1);
_mc(DE, 1); _mc(DE, 1);
_memptr = PC-1;
_mc(PC-2, 4);
DBG_MEM(printf("%5ld MR %04x %02x\n", _ts, PC-2, (uint8_t)_mem[PC-2]));
_mc(PC-1, 4);
DBG_MEM(printf("%5ld MR %04x %02x\n", _ts, PC-1, (uint8_t)_mem[PC-1]));
R += 2;
}
DE++;
HL++;
} while (BC);
b += A;
flags.P = (BC != 0);
flags._3 = (b & 0x08) != 0;
flags._5 = (b & 0x02) != 0;
flags.N = flags.H = 0;
if (BC) {
_mc(DE, 1); _mc(DE, 1); _mc(DE, 1);
_mc(DE, 1); _mc(DE, 1);
PC -= 2;
_memptr = PC+1;
}
DE++;
HL++;
flags.P = flags.N = flags.H = 0;
}
inline void cpir() {
uint8_t b = _rb(HL);
@ -1450,19 +1456,21 @@ private:
if (flags.H) b--;
flags._3 = ((b & 0x08) != 0);
flags._5 = ((b & 0x02) != 0);
_memptr++;
if (!flags.Z && flags.P) {
_mc(HL, 1); _mc(HL, 1); _mc(HL, 1);
_mc(HL, 1); _mc(HL, 1);
PC -= 2;
_memptr = PC+1;
}
_int_prot = true;
} else
_memptr++;
HL++;
}
inline void inir() {
_mc(IR, 1);
uint8_t b = _inr();
_sb(HL, b);
_memptr = BC+1;
B--;
uint8_t c = b + C + 1;
flags.N = (c & 0x80) != 0;
@ -1473,6 +1481,7 @@ private:
_mc(HL, 1); _mc(HL, 1); _mc(HL, 1);
_mc(HL, 1); _mc(HL, 1);
PC -= 2;
_int_prot = true;
}
HL++;
}
@ -1480,6 +1489,7 @@ private:
_mc(IR, 1);
uint8_t b = _rb(HL);
B--;
_memptr = BC+1;
_outr(b);
HL++;
uint8_t c = b + L;
@ -1491,27 +1501,34 @@ private:
_mc(BC, 1); _mc(BC, 1); _mc(BC, 1);
_mc(BC, 1); _mc(BC, 1);
PC -= 2;
_int_prot = true;
}
}
inline void lddr() {
uint8_t b = _rb(HL);
BC--;
_sb(DE, b);
_mc(DE, 1);
_mc(DE, 1);
uint8_t b;
do {
b = _rb(HL);
_sb(DE, b);
_mc(DE, 1);
_mc(DE, 1);
if (--BC) {
_mc(DE, 1); _mc(DE, 1); _mc(DE, 1);
_mc(DE, 1); _mc(DE, 1);
_memptr = PC-1;
_mc(PC-2, 4);
DBG_MEM(printf("%5ld MR %04x %02x\n", _ts, PC-2, (uint8_t)_mem[PC-2]));
_mc(PC-1, 4);
DBG_MEM(printf("%5ld MR %04x %02x\n", _ts, PC-1, (uint8_t)_mem[PC-1]));
R += 2;
}
DE--;
HL--;
} while (BC);
b += A;
flags.P = (BC != 0);
_35(b);
flags._5 = ((b & 0x02) != 0);
flags.N = flags.H = 0;
if (BC) {
_mc(DE, 1); _mc(DE, 1); _mc(DE, 1);
_mc(DE, 1); _mc(DE, 1);
PC -= 2;
_memptr = PC+1;
}
DE--;
HL--;
flags._3 = (b & 0x08) != 0;
flags._5 = (b & 0x02) != 0;
flags.P = flags.N = flags.H = 0;
}
inline void cpdr() {
uint8_t b = _rb(HL);
@ -1529,13 +1546,14 @@ private:
if (flags.H) b--;
flags._3 = (b & 0x08) != 0;
flags._5 = (b & 0x02) != 0;
_memptr--;
if (!flags.Z && flags.P) {
_mc(HL, 1); _mc(HL, 1); _mc(HL, 1);
_mc(HL, 1); _mc(HL, 1);
PC -= 2;
_memptr = PC+1;
}
_int_prot = true;
} else
_memptr--;
HL--;
}
inline void indr() {
@ -1553,6 +1571,7 @@ private:
_mc(HL, 1); _mc(HL, 1); _mc(HL, 1);
_mc(HL, 1); _mc(HL, 1);
PC -= 2;
_int_prot = true;
}
HL--;
}
@ -1572,6 +1591,7 @@ private:
_mc(BC, 1); _mc(BC, 1); _mc(BC, 1);
_mc(BC, 1); _mc(BC, 1);
PC -= 2;
_int_prot = true;
}
}

@ -12,6 +12,7 @@ void cons_init() {
tcgetattr(in, &term);
struct termios t = term;
cfmakeraw(&t);
t.c_oflag |= OPOST | ONLCR;
tcsetattr(in, 0, &t);
}

@ -77,10 +77,10 @@ void port_out(uint16_t p, uint8_t a) {
disk_status = disk_track(a);
break;
case FDC_SETSEC_L:
disk_status = disk_sector(a);
disk_status = disk_sector_lo(a);
break;
case FDC_SETSEC_H:
// ignore?
disk_status = disk_sector_hi(a);
break;
case FDC_SETDMA_L:
disk_dma(a | (disk_dma() & 0xff00));

@ -32,7 +32,8 @@ void close_disks() {
}
static int drive;
static uint8_t trk, sec, settrk, setsec;
static uint8_t trk, settrk;
static uint16_t sec, setsec;
static uint16_t setdma;
static bool disk_seek() {
@ -80,6 +81,7 @@ uint8_t disk_select(uint8_t a) {
}
uint8_t disk_track(uint8_t a) {
if (a >= TRACKS)
return ILLEGAL_TRACK;
@ -87,11 +89,23 @@ uint8_t disk_track(uint8_t a) {
return OK;
}
uint8_t disk_sector(uint8_t a) {
if (a > SECTORS_PER_TRACK)
uint8_t disk_sector_lo(uint8_t a) {
uint16_t s = (setsec & 0xff00) | a;
if (s > SECTORS_PER_TRACK)
return ILLEGAL_SECTOR;
setsec = a;
setsec = s;
return OK;
}
uint8_t disk_sector_hi(uint8_t a) {
uint16_t s = (setsec & 0xff) | (a << 8);
if (s > SECTORS_PER_TRACK)
return ILLEGAL_SECTOR;
setsec = s;
return OK;
}

@ -20,7 +20,8 @@ uint16_t disk_dma();
uint8_t disk_select(uint8_t);
uint8_t disk_track(uint8_t);
uint8_t disk_sector(uint8_t);
uint8_t disk_sector_lo(uint8_t);
uint8_t disk_sector_hi(uint8_t);
uint8_t disk_dma(uint16_t);
uint8_t disk_write(const Memory &);
uint8_t disk_read(Memory &);