diff --git a/.gitignore b/.gitignore
index 32ac5ae3..8ebc4587 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,6 +76,7 @@ Tools/unix/zx/zx
!Source/ver.lib
!Source/Apps/FAT/FAT.COM
+!Source/Apps/ZMP/zmpx.com
!Source/BPBIOS/bpbuild.com
!Source/BPBIOS/movp112.com
!Source/BPBIOS/Z34RCP11/cledinst.com
diff --git a/Binary/Apps/Clean.cmd b/Binary/Apps/Clean.cmd
index 1427d697..3b66f0e1 100644
--- a/Binary/Apps/Clean.cmd
+++ b/Binary/Apps/Clean.cmd
@@ -2,5 +2,9 @@
setlocal
if exist *.com del *.com
+
+if exist *.ovr del *.ovr
+if exist *.doc del *.doc
+if exist *.hlp del *.hlp
if exist Tunes\*.pt? del Tunes\*.pt?
if exist Tunes\*.mym del Tunes\*.mym
diff --git a/Binary/Apps/Makefile b/Binary/Apps/Makefile
index 7e63d751..2290ff2b 100644
--- a/Binary/Apps/Makefile
+++ b/Binary/Apps/Makefile
@@ -7,4 +7,4 @@ all::
mkdir -p Tunes
clobber::
- @rm -f *.bin *.com *.img *.rom *.pdf *.log *.eeprom *.COM *.BIN Tunes/*.mym Tunes/*.pt?
+ @rm -f *.bin *.com *.img *.rom *.pdf *.log *.eeprom *.ovr *.hlp *.doc *.COM *.BIN Tunes/*.mym Tunes/*.pt?
diff --git a/Source/Apps/Build.cmd b/Source/Apps/Build.cmd
index 87038f2e..2fdbb9ea 100644
--- a/Source/Apps/Build.cmd
+++ b/Source/Apps/Build.cmd
@@ -35,7 +35,7 @@ pushd Tune && call Build || exit /b & popd
pushd FAT && call Build || exit /b & popd
pushd I2C && call Build || exit /b & popd
pushd ramtest && call Build || exit /b & popd
-pushd zmodem && call Build || exit /b & popd
+pushd ZMP && call Build || exit /b & popd
copy *.com %APPBIN%\ || exit /b
diff --git a/Source/Apps/Clean.cmd b/Source/Apps/Clean.cmd
index 429b0c70..7aaa1702 100644
--- a/Source/Apps/Clean.cmd
+++ b/Source/Apps/Clean.cmd
@@ -13,3 +13,4 @@ pushd Tune && call Clean || exit /b 1 & popd
pushd FAT && call Clean || exit /b 1 & popd
pushd I2C && call Clean || exit /b 1 & popd
pushd ramtest && call Clean || exit /b 1 & popd
+pushd ZMP && call Clean || exit /b 1 & popd
diff --git a/Source/Apps/Makefile b/Source/Apps/Makefile
index 7f87a2d0..4b2d227b 100644
--- a/Source/Apps/Makefile
+++ b/Source/Apps/Makefile
@@ -2,7 +2,7 @@ OBJECTS = sysgen.com survey.com \
syscopy.com assign.com format.com talk.com mode.com rtc.com \
timer.com inttest.com rtchb.com ppidetst.com tstdskng.com
OTHERS = *.hex *.com
-SUBDIRS = XM FDU FAT Tune I2C ramtest
+SUBDIRS = XM FDU FAT Tune I2C ramtest ZMP
DEST = ../../Binary/Apps
TOOLS =../../Tools
diff --git a/Source/Apps/ZMODEM/Build.cmd b/Source/Apps/ZMP/Build.cmd
similarity index 85%
rename from Source/Apps/ZMODEM/Build.cmd
rename to Source/Apps/ZMP/Build.cmd
index 7063e7f3..71f79633 100644
--- a/Source/Apps/ZMODEM/Build.cmd
+++ b/Source/Apps/ZMP/Build.cmd
@@ -15,4 +15,4 @@ zx MLOAD25 -ZMP.COM=ZMPX.COM,ZMO-RW01 || exit /b
copy /Y zmp.com ..\..\..\Binary\Apps\ || exit /b
copy /Y *.ovr ..\..\..\Binary\Apps\ || exit /b
copy /Y *.hlp ..\..\..\Binary\Apps\ || exit /b
-copy /Y zmp.doc ..\..\..\Doc\ || exit /b
\ No newline at end of file
+copy /Y zmp.doc ..\..\..\Binary\Apps\ || exit /b
\ No newline at end of file
diff --git a/Source/Apps/ZMODEM/Clean.cmd b/Source/Apps/ZMP/Clean.cmd
similarity index 100%
rename from Source/Apps/ZMODEM/Clean.cmd
rename to Source/Apps/ZMP/Clean.cmd
diff --git a/Source/Apps/ZMP/Makefile b/Source/Apps/ZMP/Makefile
new file mode 100644
index 00000000..09abd053
--- /dev/null
+++ b/Source/Apps/ZMP/Makefile
@@ -0,0 +1,10 @@
+OBJECTS = zmp.com *.ovr *.hlp zmp.doc
+DEST = ../../../Binary/Apps
+TOOLS = ../../../Tools
+OTHERS = *.hex
+NODELETE = *.ovr zmp.doc *.hlp
+
+include $(TOOLS)/Makefile.inc
+
+zmp.com: zmo-rw01.hex
+ $(ZXCC) $(CPM)/MLOAD25 -ZMP.COM=ZMPX.COM,ZMO-RW01
diff --git a/Source/Apps/ZMP/Notes.txt b/Source/Apps/ZMP/Notes.txt
new file mode 100644
index 00000000..2424af33
--- /dev/null
+++ b/Source/Apps/ZMP/Notes.txt
@@ -0,0 +1,16 @@
+- Overlay files must reside on default drive at time program is
+ launched. This seems to preclude the path search feature of
+ ZSDOS/ZCPR which would be nice. Need to look into this.
+- Need some mechanism for user to select a CIO unit other than CIO 1
+ without modifying and rebuilding application.
+- Initialization messages refer to CIO 1 as CIO 0
+- System hangs after error message if there is no CIO 1 unit
+- When leaving program, terminal cursor remains hidden
+
+--WBW 1:42 PM 8/23/2021
+
+- When leaving program, terminal cursor remains hidden (fixed)
+- System hangs after error message if there is no CIO 1 unit (fixed)
+- Initialization messages refer to CIO 1 as CIO 0 (fixed)
+
+--WBW 1:58 PM 8/23/2021
\ No newline at end of file
diff --git a/Source/Apps/ZMODEM/zmconfig.ovr b/Source/Apps/ZMP/zmconfig.ovr
similarity index 100%
rename from Source/Apps/ZMODEM/zmconfig.ovr
rename to Source/Apps/ZMP/zmconfig.ovr
diff --git a/Source/Apps/ZMODEM/zminit.ovr b/Source/Apps/ZMP/zminit.ovr
similarity index 100%
rename from Source/Apps/ZMODEM/zminit.ovr
rename to Source/Apps/ZMP/zminit.ovr
diff --git a/Source/Apps/ZMODEM/zmo-rw01.z80 b/Source/Apps/ZMP/zmo-rw01.z80
similarity index 93%
rename from Source/Apps/ZMODEM/zmo-rw01.z80
rename to Source/Apps/ZMP/zmo-rw01.z80
index b2b8af4b..54435c31 100644
--- a/Source/Apps/ZMODEM/zmo-rw01.z80
+++ b/Source/Apps/ZMP/zmo-rw01.z80
@@ -457,7 +457,8 @@ init:
call print
db 'CIO device initialized: ',0
ld a,(port)
- add a,'0'-1
+ ;add a,'0'-1
+ add a,'0'
call cout
call print
db cr,lf,0
@@ -472,12 +473,16 @@ initerr:
call print
db 'Unable to initialize CIO device: ',0
ld a,(port)
- add a,'0'-1
+ ;add a,'0'-1
+ add a,'0'
call cout
call print
db cr,lf,0
- ret
+ ;ret
+
+ call show ; show cursor, then ...
+ jp 0 ; bail out to avoid system hang!
;--------------------------------------------------------------------------
stop: dw 1 ; stop bits
@@ -539,7 +544,8 @@ setport:
pop hl
ld a,l
- add a,'0'-1
+ ;add a,'0'-1
+ add a,'0'
call cout
call print
db cr,lf,0
@@ -550,7 +556,8 @@ seterr:
db 'Unable to set CIO device: ',0
pop hl
ld a,l
- add a,'0'-1
+ ;add a,'0'-1
+ add a,'0'
call cout
call print
db cr,lf,0
@@ -641,7 +648,7 @@ hide:
;Turn on cursor:
show:
call print
- db esc,'.3',0
+ db esc,'[?25h',0
ret
;Save cursor position:
diff --git a/Source/Apps/ZMODEM/zmp-blnk.z80 b/Source/Apps/ZMP/zmp-blnk.z80
similarity index 100%
rename from Source/Apps/ZMODEM/zmp-blnk.z80
rename to Source/Apps/ZMP/zmp-blnk.z80
diff --git a/Source/Apps/ZMODEM/zmp-ovl.upd b/Source/Apps/ZMP/zmp-ovl.upd
similarity index 100%
rename from Source/Apps/ZMODEM/zmp-ovl.upd
rename to Source/Apps/ZMP/zmp-ovl.upd
diff --git a/Source/Apps/ZMODEM/zmp.cfg b/Source/Apps/ZMP/zmp.cfg
similarity index 100%
rename from Source/Apps/ZMODEM/zmp.cfg
rename to Source/Apps/ZMP/zmp.cfg
diff --git a/Source/Apps/ZMODEM/zmp.doc b/Source/Apps/ZMP/zmp.doc
similarity index 100%
rename from Source/Apps/ZMODEM/zmp.doc
rename to Source/Apps/ZMP/zmp.doc
diff --git a/Source/Apps/ZMODEM/zmp.fon b/Source/Apps/ZMP/zmp.fon
similarity index 100%
rename from Source/Apps/ZMODEM/zmp.fon
rename to Source/Apps/ZMP/zmp.fon
diff --git a/Source/Apps/ZMODEM/zmp.for b/Source/Apps/ZMP/zmp.for
similarity index 100%
rename from Source/Apps/ZMODEM/zmp.for
rename to Source/Apps/ZMP/zmp.for
diff --git a/Source/Apps/ZMODEM/zmp.hlp b/Source/Apps/ZMP/zmp.hlp
similarity index 100%
rename from Source/Apps/ZMODEM/zmp.hlp
rename to Source/Apps/ZMP/zmp.hlp
diff --git a/Source/Apps/ZMODEM/zmp15+-.new b/Source/Apps/ZMP/zmp15+-.new
similarity index 100%
rename from Source/Apps/ZMODEM/zmp15+-.new
rename to Source/Apps/ZMP/zmp15+-.new
diff --git a/Source/Apps/ZMP/zmpx.com b/Source/Apps/ZMP/zmpx.com
new file mode 100644
index 00000000..69ca8392
Binary files /dev/null and b/Source/Apps/ZMP/zmpx.com differ
diff --git a/Source/Apps/ZMODEM/zmterm.ovr b/Source/Apps/ZMP/zmterm.ovr
similarity index 100%
rename from Source/Apps/ZMODEM/zmterm.ovr
rename to Source/Apps/ZMP/zmterm.ovr
diff --git a/Source/Apps/ZMODEM/zmxfer.ovr b/Source/Apps/ZMP/zmxfer.ovr
similarity index 100%
rename from Source/Apps/ZMODEM/zmxfer.ovr
rename to Source/Apps/ZMP/zmxfer.ovr
diff --git a/Source/Images/d_bp.txt b/Source/Images/d_bp.txt
index 1e5addd1..be17824c 100644
--- a/Source/Images/d_bp.txt
+++ b/Source/Images/d_bp.txt
@@ -26,6 +26,13 @@
../../Binary/Apps/timer.com 15:
../../Binary/Apps/tune.com 15:
../../Binary/Apps/xm.com 15:
+../../Binary/Apps/zmp.com 15:
+../../Binary/Apps/zmp.hlp 15:
+../../Binary/Apps/zmp.doc 15:
+../../Binary/Apps/zmxfer.ovr 15:
+../../Binary/Apps/zmterm.ovr 15:
+../../Binary/Apps/zminit.ovr 15:
+../../Binary/Apps/zmconfig.ovr 15:
#
../../Binary/Apps/i2clcd.com 2:
../../Binary/Apps/i2cscan.com 2:
diff --git a/Source/Images/d_cpm22.txt b/Source/Images/d_cpm22.txt
index b775469b..1f328f27 100644
--- a/Source/Images/d_cpm22.txt
+++ b/Source/Images/d_cpm22.txt
@@ -16,6 +16,13 @@
../../Binary/Apps/timer.com 0:
../../Binary/Apps/tune.com 0:
../../Binary/Apps/xm.com 0:
+../../Binary/Apps/zmp.com 0:
+../../Binary/Apps/zmp.hlp 0:
+../../Binary/Apps/zmp.doc 0:
+../../Binary/Apps/zmxfer.ovr 0:
+../../Binary/Apps/zmterm.ovr 0:
+../../Binary/Apps/zminit.ovr 0:
+../../Binary/Apps/zmconfig.ovr 0:
#
../../Binary/Apps/i2clcd.com 2:
../../Binary/Apps/i2cscan.com 2:
diff --git a/Source/Images/d_cpm3.txt b/Source/Images/d_cpm3.txt
index 8b5b4298..6c5eef3b 100644
--- a/Source/Images/d_cpm3.txt
+++ b/Source/Images/d_cpm3.txt
@@ -36,6 +36,13 @@
../../Binary/Apps/timer.com 0:
../../Binary/Apps/tune.com 0:
../../Binary/Apps/xm.com 0:
+../../Binary/Apps/zmp.com 0:
+../../Binary/Apps/zmp.hlp 0:
+../../Binary/Apps/zmp.doc 0:
+../../Binary/Apps/zmxfer.ovr 0:
+../../Binary/Apps/zmterm.ovr 0:
+../../Binary/Apps/zminit.ovr 0:
+../../Binary/Apps/zmconfig.ovr 0:
#
../../Binary/Apps/i2clcd.com 2:
../../Binary/Apps/i2cscan.com 2:
diff --git a/Source/Images/d_nzcom.txt b/Source/Images/d_nzcom.txt
index 4a245f37..b63994c2 100644
--- a/Source/Images/d_nzcom.txt
+++ b/Source/Images/d_nzcom.txt
@@ -16,6 +16,13 @@
../../Binary/Apps/timer.com 0:
../../Binary/Apps/tune.com 0:
../../Binary/Apps/xm.com 0:
+../../Binary/Apps/zmp.com 0:
+../../Binary/Apps/zmp.hlp 0:
+../../Binary/Apps/zmp.doc 0:
+../../Binary/Apps/zmxfer.ovr 0:
+../../Binary/Apps/zmterm.ovr 0:
+../../Binary/Apps/zminit.ovr 0:
+../../Binary/Apps/zmconfig.ovr 0:
#
../../Binary/Apps/i2clcd.com 2:
../../Binary/Apps/i2cscan.com 2:
diff --git a/Source/Images/d_zpm3.txt b/Source/Images/d_zpm3.txt
index 12b8d5d2..5be3b3a5 100644
--- a/Source/Images/d_zpm3.txt
+++ b/Source/Images/d_zpm3.txt
@@ -35,6 +35,13 @@
../../Binary/Apps/timer.com 15:
../../Binary/Apps/tune.com 15:
../../Binary/Apps/xm.com 15:
+../../Binary/Apps/zmp.com 15:
+../../Binary/Apps/zmp.hlp 15:
+../../Binary/Apps/zmp.doc 15:
+../../Binary/Apps/zmxfer.ovr 15:
+../../Binary/Apps/zmterm.ovr 15:
+../../Binary/Apps/zminit.ovr 15:
+../../Binary/Apps/zmconfig.ovr 15:
#
#../../Binary/Apps/i2clcd.com 2:
#../../Binary/Apps/i2cscan.com 2:
diff --git a/Source/Images/d_zsdos.txt b/Source/Images/d_zsdos.txt
index 805bd5c5..b3ca2e43 100644
--- a/Source/Images/d_zsdos.txt
+++ b/Source/Images/d_zsdos.txt
@@ -28,6 +28,13 @@ d_cpm22/u0/XSUB.COM 0:
../../Binary/Apps/timer.com 0:
../../Binary/Apps/tune.com 0:
../../Binary/Apps/xm.com 0:
+../../Binary/Apps/zmp.com 0:
+../../Binary/Apps/zmp.hlp 0:
+../../Binary/Apps/zmp.doc 0:
+../../Binary/Apps/zmxfer.ovr 0:
+../../Binary/Apps/zmterm.ovr 0:
+../../Binary/Apps/zminit.ovr 0:
+../../Binary/Apps/zmconfig.ovr 0:
#
../../Binary/Apps/i2clcd.com 2:
../../Binary/Apps/i2cscan.com 2:
diff --git a/Source/ver.inc b/Source/ver.inc
index 79f38bab..784c9ee1 100644
--- a/Source/ver.inc
+++ b/Source/ver.inc
@@ -2,4 +2,4 @@
#DEFINE RMN 1
#DEFINE RUP 1
#DEFINE RTP 03
-#DEFINE BIOSVER "3.1.1-pre.107"
+#DEFINE BIOSVER "3.1.1-pre.108"
diff --git a/Source/ver.lib b/Source/ver.lib
index 0efaf8fb..4c3ab409 100644
--- a/Source/ver.lib
+++ b/Source/ver.lib
@@ -3,5 +3,5 @@ rmn equ 1
rup equ 1
rtp equ 0
biosver macro
- db "3.1.1-pre.107"
+ db "3.1.1-pre.108"
endm
diff --git a/Tools/Makefile.inc b/Tools/Makefile.inc
index 48910ec8..b5a8bf44 100644
--- a/Tools/Makefile.inc
+++ b/Tools/Makefile.inc
@@ -93,6 +93,9 @@ CPM=$(TOOLS)/cpm/bin
%.rel: %.z80
$(ZXCC) $(CPM)/Z80ASM -$(basename $<)/MF
+%.hex: %.z80
+ $(ZXCC) $(CPM)/Z80ASM -$(basename $<)/HF
+
%.hex: %.180
$(ZXCC) $(CPM)/SLR180 -$(basename $<)/HF
diff --git a/Tools/unix/zx/cpmdrv.c b/Tools/unix/zx/cpmdrv.c
index 1faff21b..24042e5b 100644
--- a/Tools/unix/zx/cpmdrv.c
+++ b/Tools/unix/zx/cpmdrv.c
@@ -139,6 +139,7 @@ cpm_word fcb_purge()
#endif
}
+/* Generic 8MB disk definition */
static cpm_byte exdpb[0x11] = {
0x80, 0, /* 128 records/track */
@@ -154,61 +155,7 @@ static cpm_byte exdpb[0x11] = {
cpm_word fcb_getdpb(cpm_byte *dpb)
{
-#ifdef WIN32
- DWORD spc, bps, fc, tc;
- unsigned bsh, blm, psh, phm;
- char *hostd = drive_to_hostdrive(redir_cpmdrive);
-
- if (!hostd) return 0x01FF; /* Can't select */
-
- if (!GetDiskFreeSpace(hostd, &spc, &bps, &fc, &tc))
- return 0x01FF; /* Can't select */
-
- /* Store total clusters */
- //if (tc > 0x10000L) tc = 0x10000L;
- if (tc > 0xFFFFL) tc = 0xFFFFL;
-
- psh = 0; phm = 0;
-
- while (bps > 128) /* Get sector size */
- {
- bps /= 2;
- psh++;
- phm = (phm << 1) | 1;
- }
- bsh = psh; blm = phm;
- while (spc > 1) /* Get cluster size */
- {
- spc /= 2;
- bsh++;
- blm = (blm << 1) | 1;
- }
-
-
- exdpb[2] = bsh;
- exdpb[3] = blm;
- exdpb[5] = tc & 0xFF;
- exdpb[6] = tc >> 8;
-
- exdpb[15] = psh;
- exdpb[16] = phm;
-#else
- struct statfs buf;
- cpm_word nfiles;
-
- /* Get DPB for redir_cpmdrive. Currently just returns a dummy. */
- if (!statfs(redir_drive_prefix[redir_cpmdrive], &buf))
- {
- /* Store correct directory entry count */
-
- if (buf.f_files >= 0x10000L) nfiles = 0xFFFF;
- else nfiles = buf.f_files;
-
- exdpb[7] = nfiles & 0xFF;
- exdpb[8] = nfiles >> 8;
- }
-#endif
-
+ /* Return the example dpb */
memcpy(dpb, &exdpb, 0x11);
return 0x11;
}
@@ -223,7 +170,7 @@ cpm_word fcb_getalv(cpm_byte *alv, cpm_word max)
memset(alv, 0xFF, max / 2);
memset(alv + (max / 2), 0, max / 2);
-
+
return max;
}
@@ -231,45 +178,7 @@ cpm_word fcb_getalv(cpm_byte *alv, cpm_word max)
cpm_word fcb_dfree (cpm_byte drive, cpm_byte *dma)
{
-#ifdef WIN32
- DWORD spc, bps, fc, tc;
- DWORD freerec;
- char *hostd = drive_to_hostdrive(drive);
-
- if (!hostd) return 0x01FF;
- if (!hostd) return 0x01FF; /* Can't select */
-
- if (!GetDiskFreeSpace(hostd, &spc, &bps, &fc, &tc))
- return 0x01FF; /* Can't select */
-
- freerec = fc; /* Free clusters */
- freerec *= spc; /* Free sectors */
- freerec *= (bps / 128); /* Free CP/M records */
-
- /* Limit to maximum CP/M drive size */
- if (freerec > 4194303L) freerec = 4194303L;
- redir_wr24(dma, freerec);
-
-#else
- struct statfs buf;
- long dfree;
-
- if (!redir_drive_prefix[drive]) return 0x01FF; /* Can't select */
-
- if (statfs(redir_drive_prefix[drive], &buf)) return 0x01FF;
-
- dfree = (buf.f_bavail * (buf.f_bsize / 128));
-
- if (dfree < buf.f_bavail || /* Calculation has wrapped round */
- dfree > 4194303L) /* Bigger than max CP/M drive size */
- {
- dfree = 4194303L;
- }
-
- redir_wr24(dma, dfree);
-#endif
+ /* Return half of disk capacity */
+ redir_wr24(dma, 0x8000L); /* 8MB / 128 / 2 */
return 0;
}
-
-
-
diff --git a/Tools/unix/zx/cpmglob.c b/Tools/unix/zx/cpmglob.c
index 20306e09..5566d8a4 100644
--- a/Tools/unix/zx/cpmglob.c
+++ b/Tools/unix/zx/cpmglob.c
@@ -277,7 +277,11 @@ cpm_word redir_find(int n, cpm_byte *fcb, cpm_byte *dma)
while (n >= 0)
{
de = next_entry(hostdir, fcb, dma + 1, &st);
- if (!de) return 0xFF;
+ if (!de)
+ {
+ closedir(hostdir);
+ return 0xFF;
+ }
--n;
}
/* Valid entry found & statted. dma+1 holds filename. */
diff --git a/Tools/unix/zx/cpmint.h b/Tools/unix/zx/cpmint.h
index f0ec4237..e6878174 100644
--- a/Tools/unix/zx/cpmint.h
+++ b/Tools/unix/zx/cpmint.h
@@ -67,6 +67,9 @@
#ifdef HAVE_UNISTD_H
# include
#endif
+#ifdef WIN32
+# define strcasecmp _stricmp
+#endif
#ifdef __MSDOS__
diff --git a/Tools/unix/zx/edops.h b/Tools/unix/zx/edops.h
index 6b04c96a..433f0cb2 100644
--- a/Tools/unix/zx/edops.h
+++ b/Tools/unix/zx/edops.h
@@ -1,567 +1,572 @@
-/* Emulations of the ED operations of the Z80 instruction set.
- * Copyright (C) 1994 Ian Collier.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define input(var) { unsigned short u;\
- var=u=in(tstates,b,c);\
- tstates+=u>>8;\
- f=(f&1)|(var&0xa8)|((!var)<<6)|parity(var);\
- }
-#define sbchl(x) { unsigned short z=(x);\
- unsigned long t=(hl-z-cy)&0x1ffff;\
- f=((t>>8)&0xa8)|(t>>16)|2|\
- (((hl&0xfff)<(z&0xfff)+cy)<<4)|\
- (((hl^z)&(hl^t)&0x8000)>>13)|\
- ((!(t&0xffff))<<6)|2;\
- l=t;\
- h=t>>8;\
- }
-
-#define adchl(x) { unsigned short z=(x);\
- unsigned long t=hl+z+cy;\
- f=((t>>8)&0xa8)|(t>>16)|\
- (((hl&0xfff)+(z&0xfff)+cy>0xfff)<<4)|\
- (((~hl^z)&(hl^t)&0x8000)>>13)|\
- ((!(t&0xffff))<<6)/*|2*/;\
- l=t;\
- h=t>>8;\
- }
-/* [JCE] The "|2" should not be there, at least according to my tests on
- * a PCW16. The PCW16's ADC always resets that bit. */
-
-
-#define neg (a=-a,\
- f=(a&0xa8)|((!a)<<6)|(((a&15)>0)<<4)|((a==128)<<2)|2|(a>0))
-
-{
- unsigned char op=fetch(pc);
- pc++;
- radjust++;
- switch(op){
-instr(0x40,8);
- input(b);
-endinstr;
-
-instr(0x41,8);
- tstates+=out(tstates,b,c,b);
-endinstr;
-
-instr(0x42,11);
- sbchl(bc);
-endinstr;
-
-instr(0x43,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- store2b(addr,b,c);
- }
-endinstr;
-
-instr(0x44,4);
- neg;
-endinstr;
-
-instr(0x45,4);
- iff1=iff2;
- ret;
-endinstr;
-
-instr(0x46,4);
- im=0;
-endinstr;
-
-instr(0x47,5);
- i=a;
-endinstr;
-
-instr(0x48,8);
- input(c);
-endinstr;
-
-instr(0x49,8);
- tstates+=out(tstates,b,c,c);
-endinstr;
-
-instr(0x4a,11);
- adchl(bc);
-endinstr;
-
-instr(0x4b,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- c=fetch(addr);
- b=fetch(addr+1);
- }
-endinstr;
-
-instr(0x4c,4);
- neg;
-endinstr;
-
-instr(0x4d,4);
- ret;
-endinstr;
-
-instr(0x4e,4);
- im=1;
-endinstr;
-
-instr(0x4f,5);
- r=a;
- radjust=r;
-endinstr;
-
-instr(0x50,8);
- input(d);
-endinstr;
-
-instr(0x51,8);
- tstates+=out(tstates,b,c,d);
-endinstr;
-
-instr(0x52,11);
- sbchl(de);
-endinstr;
-
-instr(0x53,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- store2b(addr,d,e);
- }
-endinstr;
-
-instr(0x54,4);
- neg;
-endinstr;
-
-instr(0x55,4);
- ret;
-endinstr;
-
-instr(0x56,4);
- im=2;
-endinstr;
-
-instr(0x57,5);
- a=i;
- f=(f&1)|(a&0xa8)|((!a)<<6)|(iff2<<2);
-endinstr;
-
-instr(0x58,8);
- input(e);
-endinstr;
-
-instr(0x59,8);
- tstates+=out(tstates,b,c,e);
-endinstr;
-
-instr(0x5a,11);
- adchl(de);
-endinstr;
-
-instr(0x5b,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- e=fetch(addr);
- d=fetch(addr+1);
- }
-endinstr;
-
-instr(0x5c,4);
- neg;
-endinstr;
-
-instr(0x5d,4);
- ret;
-endinstr;
-
-instr(0x5e,4);
- im=3;
-endinstr;
-
-instr(0x5f,5);
- r=(r&0x80)|(radjust&0x7f);
- a=r;
- f=(f&1)|(a&0xa8)|((!a)<<6)|(iff2<<2);
-endinstr;
-
-instr(0x60,8);
- input(h);
-endinstr;
-
-instr(0x61,8);
- tstates+=out(tstates,b,c,h);
-endinstr;
-
-instr(0x62,11);
- sbchl(hl);
-endinstr;
-
-instr(0x63,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- store2b(addr,h,l);
- }
-endinstr;
-
-instr(0x64,4);
- neg;
-endinstr;
-
-instr(0x65,4);
- ret;
-endinstr;
-
-instr(0x66,4);
- im=0;
-endinstr;
-
-instr(0x67,14);
- {unsigned char t=fetch(hl);
- unsigned char u=(a<<4)|(t>>4);
- a=(a&0xf0)|(t&0x0f);
- store(hl,u);
- f=(f&1)|(a&0xa8)|((!a)<<6)|parity(a);
- }
-endinstr;
-
-instr(0x68,8);
- input(l);
-endinstr;
-
-instr(0x69,8);
- tstates+=out(tstates,b,c,l);
-endinstr;
-
-instr(0x6a,11);
- adchl(hl);
-endinstr;
-
-instr(0x6b,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- l=fetch(addr);
- h=fetch(addr+1);
- }
-endinstr;
-
-instr(0x6c,4);
- neg;
-endinstr;
-
-instr(0x6d,4);
- ret;
-endinstr;
-
-instr(0x6e,4);
- im=1;
-endinstr;
-
-instr(0x6f,5);
- {unsigned char t=fetch(hl);
- unsigned char u=(a&0x0f)|(t<<4);
- a=(a&0xf0)|(t>>4);
- store(hl,u);
- f=(f&1)|(a&0xa8)|((!a)<<6)|parity(a);
- }
-endinstr;
-
-instr(0x70,8);
- {unsigned char x;input(x);}
-endinstr;
-
-instr(0x71,8);
- tstates+=out(tstates,b,c,0);
-endinstr;
-
-instr(0x72,11);
- sbchl(sp);
-endinstr;
-
-instr(0x73,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- store2(addr,sp);
- }
-endinstr;
-
-instr(0x74,4);
- neg;
-endinstr;
-
-instr(0x75,4);
- ret;
-endinstr;
-
-instr(0x76,4);
- im=2;
-endinstr;
-
-instr(0x78,8);
- input(a);
-endinstr;
-
-instr(0x79,8);
- tstates+=out(tstates,b,c,a);
-endinstr;
-
-instr(0x7a,11);
- adchl(sp);
-endinstr;
-
-instr(0x7b,16);
- {unsigned short addr=fetch2(pc);
- pc+=2;
- sp=fetch2(addr);
- }
-endinstr;
-
-instr(0x7c,4);
- neg;
-endinstr;
-
-instr(0x7d,4);
- ret;
-endinstr;
-
-instr(0x7e,4);
- im=3;
-endinstr;
-
-instr(0xa0,12);
- {unsigned char x=fetch(hl);
- store(de,x);
- if(!++l)h++;
- if(!++e)d++;
- if(!c--)b--;
- f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
- }
-endinstr;
-
-instr(0xa1,12);
- {unsigned char carry=cy;
- cpa(fetch(hl));
- if(!++l)h++;
- if(!c--)b--;
- f=(f&0xfa)|carry|(((b|c)>0)<<2);
- }
-endinstr;
-
-instr(0xa2,12);
- {unsigned short t=in(tstates,b,c);
- store(hl,t);
- tstates+=t>>8;
- if(!++l)h++;
- b--;
- f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c)&4);
- }
-endinstr;
-
-instr(0xa3,12); /* I can't determine the correct flags outcome for the
- block OUT instructions. Spec says that the carry
- flag is left unchanged and N is set to 1, but that
- doesn't seem to be the case... */
- {unsigned char x=fetch(hl);
- tstates+=out(tstates,b,c,x);
- if(!++l)h++;
- b--;
- f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
- }
-endinstr;
-
-instr(0xa8,12);
- {unsigned char x=fetch(hl);
- store(de,x);
- if(!l--)h--;
- if(!e--)d--;
- if(!c--)b--;
- f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
- }
-endinstr;
-
-instr(0xa9,12);
- {unsigned char carry=cy;
- cpa(fetch(hl));
- if(!l--)h--;
- if(!c--)b--;
- f=(f&0xfa)|carry|(((b|c)>0)<<2);
- }
-endinstr;
-
-instr(0xaa,12);
- {unsigned short t=in(tstates,b,c);
- store(hl,t);
- tstates+=t>>8;
- if(!l--)h--;
- b--;
- f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c^4)&4);
- }
-endinstr;
-
-instr(0xab,12);
- {unsigned char x=fetch(hl);
- tstates+=out(tstates,b,c,x);
- if(!l--)h--;
- b--;
- f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
- }
-endinstr;
-
-/* Note: the Z80 implements "*R" as "*" followed by JR -2. No reason
- to change this... */
-
-instr(0xb0,12);
- {unsigned char x=fetch(hl);
- store(de,x);
- if(!++l)h++;
- if(!++e)d++;
- if(!c--)b--;
- f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
- if(b|c)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xb1,12);
- {unsigned char carry=cy;
- cpa(fetch(hl));
- if(!++l)h++;
- if(!c--)b--;
- f=(f&0xfa)|carry|(((b|c)>0)<<2);
- if((f&0x44)==4)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xb2,12);
- {unsigned short t=in(tstates,b,c);
- store(hl,t);
- tstates+=t>>8;
- if(!++l)h++;
- b--;
- f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c)&4);
- if(b)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xb3,12);
- {unsigned char x=fetch(hl);
- tstates+=out(tstates,b,c,x);
- if(!++l)h++;
- b--;
- f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
- if(b)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xb8,12);
- {unsigned char x=fetch(hl);
- store(de,x);
- if(!l--)h--;
- if(!e--)d--;
- if(!c--)b--;
- f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
- if(b|c)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xb9,12);
- {unsigned char carry=cy;
- cpa(fetch(hl));
- if(!l--)h--;
- if(!c--)b--;
- f=(f&0xfa)|carry|(((b|c)>0)<<2);
- if((f&0x44)==4)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xba,12);
- {unsigned short t=in(tstates,b,c);
- store(hl,t);
- tstates+=t>>8;
- if(!l--)h--;
- b--;
- f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c^4)&4);
- if(b)pc-=2,tstates+=5;
- }
-endinstr;
-
-instr(0xbb,12);
- {unsigned char x=fetch(hl);
- tstates+=out(tstates,b,c,x);
- if(!l--)h--;
- b--;
- f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
- if(b)pc-=2,tstates+=5;
- }
-endinstr;
-
-/* XZ80 Pseudo-ops
-instr(0xfb,4);
- multiloader(hl,a);
-endinstr;
-
-instr(0xfc,4);
- { int ans;
- stopwatch();
- ans=loader(pc,ix,de,a,cy);
- if(ans>=0){
- if(ans==1)pc=0x0806;
- else if(ans==2)f&=254;
- else f|=1;
- ix+=de;
- d=e=0;
- if(ans!=1)ret;
- }
- startwatch(1);
- }
-endinstr;
-
-instr(0xfd,4);
- { int ans;
- stopwatch();
- ans=saver(pc,ix,de,a);
- if(ans>0)pc=0x0806;
- else if(ans==0){
- ix+=de;
- d=e=0;
- ret;
- }
- startwatch(1);
- }
-endinstr;
-*/
-
-/* ZXCC pseudo-op */
-instr(0xfe, 4);
-{
- /* Create copies of the registers here so we can take their addresses
- * and not lose register optimisation in the rest of the CPU code */
- byte xa,xb,xc,xd,xe,xf,xxh,xxl;
- word xp,xx,xy;
-
- xa = a; xb = b; xc = c; xd = d; xe = e; xf = f; xxh = h; xxl = l;
- xp = pc; xx = ix; xy = iy;
-
- ed_fe(&xa,&xb,&xc,&xd,&xe,&xf,&xxh,&xxl,&xp,&xx,&xy);
-
- a = xa; b = xb; c = xc; d = xd; e = xe; f = xf; h = xxh; l = xxl;
- pc = xp; ix = xx; iy = xy;
-}
-endinstr;
-
-default: tstates+=4;
-
-}}
+/* Emulations of the ED operations of the Z80 instruction set.
+ * Copyright (C) 1994 Ian Collier.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define input(var) { unsigned short u;\
+ var=u=in(tstates,b,c);\
+ tstates+=u>>8;\
+ f=(f&1)|(var&0xa8)|((!var)<<6)|parity(var);\
+ }
+#define sbchl(x) { unsigned short z=(x);\
+ unsigned long t=(hl-z-cy)&0x1ffff;\
+ f=((t>>8)&0xa8)|(t>>16)|2|\
+ (((hl&0xfff)<(z&0xfff)+cy)<<4)|\
+ (((hl^z)&(hl^t)&0x8000)>>13)|\
+ ((!(t&0xffff))<<6)|2;\
+ l=t;\
+ h=t>>8;\
+ }
+
+#define adchl(x) { unsigned short z=(x);\
+ unsigned long t=hl+z+cy;\
+ f=((t>>8)&0xa8)|(t>>16)|\
+ (((hl&0xfff)+(z&0xfff)+cy>0xfff)<<4)|\
+ (((~hl^z)&(hl^t)&0x8000)>>13)|\
+ ((!(t&0xffff))<<6)/*|2*/;\
+ l=t;\
+ h=t>>8;\
+ }
+/* [JCE] The "|2" should not be there, at least according to my tests on
+ * a PCW16. The PCW16's ADC always resets that bit. */
+
+
+#define neg (a=-a,\
+ f=(a&0xa8)|((!a)<<6)|(((a&15)>0)<<4)|((a==128)<<2)|2|(a>0))
+
+{
+ unsigned char op=fetch(pc);
+ pc++;
+ radjust++;
+ switch(op){
+instr(0x40,8);
+ input(b);
+endinstr;
+
+instr(0x41,8);
+ tstates+=out(tstates,b,c,b);
+endinstr;
+
+instr(0x42,11);
+ sbchl(bc);
+endinstr;
+
+instr(0x43,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ store2b(addr,b,c);
+ }
+endinstr;
+
+instr(0x44,4);
+ neg;
+endinstr;
+
+instr(0x45,4);
+ iff1=iff2;
+ ret;
+endinstr;
+
+instr(0x46,4);
+ im=0;
+endinstr;
+
+instr(0x47,5);
+ i=a;
+endinstr;
+
+instr(0x48,8);
+ input(c);
+endinstr;
+
+instr(0x49,8);
+ tstates+=out(tstates,b,c,c);
+endinstr;
+
+instr(0x4a,11);
+ adchl(bc);
+endinstr;
+
+instr(0x4b,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ c=fetch(addr);
+ b=fetch(addr+1);
+ }
+endinstr;
+
+instr(0x4c,4);
+ neg;
+endinstr;
+
+instr(0x4d,4);
+ ret;
+endinstr;
+
+instr(0x4e,4);
+ im=1;
+endinstr;
+
+instr(0x4f,5);
+ r=a;
+ radjust=r;
+endinstr;
+
+instr(0x50,8);
+ input(d);
+endinstr;
+
+instr(0x51,8);
+ tstates+=out(tstates,b,c,d);
+endinstr;
+
+instr(0x52,11);
+ sbchl(de);
+endinstr;
+
+instr(0x53,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ store2b(addr,d,e);
+ }
+endinstr;
+
+instr(0x54,4);
+ neg;
+endinstr;
+
+instr(0x55,4);
+ ret;
+endinstr;
+
+instr(0x56,4);
+ im=2;
+endinstr;
+
+instr(0x57,5);
+ a=i;
+ f=(f&1)|(a&0xa8)|((!a)<<6)|(iff2<<2);
+endinstr;
+
+instr(0x58,8);
+ input(e);
+endinstr;
+
+instr(0x59,8);
+ tstates+=out(tstates,b,c,e);
+endinstr;
+
+instr(0x5a,11);
+ adchl(de);
+endinstr;
+
+instr(0x5b,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ e=fetch(addr);
+ d=fetch(addr+1);
+ }
+endinstr;
+
+instr(0x5c,4);
+ neg;
+endinstr;
+
+instr(0x5d,4);
+ ret;
+endinstr;
+
+instr(0x5e,4);
+ im=3;
+endinstr;
+
+instr(0x5f,5);
+ r=(r&0x80)|(radjust&0x7f);
+ a=r;
+ f=(f&1)|(a&0xa8)|((!a)<<6)|(iff2<<2);
+endinstr;
+
+instr(0x60,8);
+ input(h);
+endinstr;
+
+instr(0x61,8);
+ tstates+=out(tstates,b,c,h);
+endinstr;
+
+instr(0x62,11);
+ sbchl(hl);
+endinstr;
+
+instr(0x63,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ store2b(addr,h,l);
+ }
+endinstr;
+
+instr(0x64,4);
+ neg;
+endinstr;
+
+instr(0x65,4);
+ ret;
+endinstr;
+
+instr(0x66,4);
+ im=0;
+endinstr;
+
+instr(0x67,14);
+ {unsigned char t=fetch(hl);
+ unsigned char u=(a<<4)|(t>>4);
+ a=(a&0xf0)|(t&0x0f);
+ store(hl,u);
+ f=(f&1)|(a&0xa8)|((!a)<<6)|parity(a);
+ }
+endinstr;
+
+instr(0x68,8);
+ input(l);
+endinstr;
+
+instr(0x69,8);
+ tstates+=out(tstates,b,c,l);
+endinstr;
+
+instr(0x6a,11);
+ adchl(hl);
+endinstr;
+
+instr(0x6b,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ l=fetch(addr);
+ h=fetch(addr+1);
+ }
+endinstr;
+
+instr(0x6c,4);
+ neg;
+endinstr;
+
+instr(0x6d,4);
+ ret;
+endinstr;
+
+instr(0x6e,4);
+ im=1;
+endinstr;
+
+instr(0x6f,5);
+ {unsigned char t=fetch(hl);
+ unsigned char u=(a&0x0f)|(t<<4);
+ a=(a&0xf0)|(t>>4);
+ store(hl,u);
+ f=(f&1)|(a&0xa8)|((!a)<<6)|parity(a);
+ }
+endinstr;
+
+instr(0x70,8);
+ {unsigned char x;
+ input(x);
+ store(hl,x);
+ }
+endinstr;
+
+instr(0x71,8);
+ {unsigned char x=fetch(hl);
+ tstates+=out(tstates,b,c,x);
+ }
+endinstr;
+
+instr(0x72,11);
+ sbchl(sp);
+endinstr;
+
+instr(0x73,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ store2(addr,sp);
+ }
+endinstr;
+
+instr(0x74,4);
+ neg;
+endinstr;
+
+instr(0x75,4);
+ ret;
+endinstr;
+
+instr(0x76,4);
+ im=2;
+endinstr;
+
+instr(0x78,8);
+ input(a);
+endinstr;
+
+instr(0x79,8);
+ tstates+=out(tstates,b,c,a);
+endinstr;
+
+instr(0x7a,11);
+ adchl(sp);
+endinstr;
+
+instr(0x7b,16);
+ {unsigned short addr=fetch2(pc);
+ pc+=2;
+ sp=fetch2(addr);
+ }
+endinstr;
+
+instr(0x7c,4);
+ neg;
+endinstr;
+
+instr(0x7d,4);
+ ret;
+endinstr;
+
+instr(0x7e,4);
+ im=3;
+endinstr;
+
+instr(0xa0,12);
+ {unsigned char x=fetch(hl);
+ store(de,x);
+ if(!++l)h++;
+ if(!++e)d++;
+ if(!c--)b--;
+ f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
+ }
+endinstr;
+
+instr(0xa1,12);
+ {unsigned char carry=cy;
+ cpa(fetch(hl));
+ if(!++l)h++;
+ if(!c--)b--;
+ f=(f&0xfa)|carry|(((b|c)>0)<<2);
+ }
+endinstr;
+
+instr(0xa2,12);
+ {unsigned short t=in(tstates,b,c);
+ store(hl,t);
+ tstates+=t>>8;
+ if(!++l)h++;
+ b--;
+ f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c)&4);
+ }
+endinstr;
+
+instr(0xa3,12); /* I can't determine the correct flags outcome for the
+ block OUT instructions. Spec says that the carry
+ flag is left unchanged and N is set to 1, but that
+ doesn't seem to be the case... */
+ {unsigned char x=fetch(hl);
+ tstates+=out(tstates,b,c,x);
+ if(!++l)h++;
+ b--;
+ f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
+ }
+endinstr;
+
+instr(0xa8,12);
+ {unsigned char x=fetch(hl);
+ store(de,x);
+ if(!l--)h--;
+ if(!e--)d--;
+ if(!c--)b--;
+ f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
+ }
+endinstr;
+
+instr(0xa9,12);
+ {unsigned char carry=cy;
+ cpa(fetch(hl));
+ if(!l--)h--;
+ if(!c--)b--;
+ f=(f&0xfa)|carry|(((b|c)>0)<<2);
+ }
+endinstr;
+
+instr(0xaa,12);
+ {unsigned short t=in(tstates,b,c);
+ store(hl,t);
+ tstates+=t>>8;
+ if(!l--)h--;
+ b--;
+ f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c^4)&4);
+ }
+endinstr;
+
+instr(0xab,12);
+ {unsigned char x=fetch(hl);
+ tstates+=out(tstates,b,c,x);
+ if(!l--)h--;
+ b--;
+ f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
+ }
+endinstr;
+
+/* Note: the Z80 implements "*R" as "*" followed by JR -2. No reason
+ to change this... */
+
+instr(0xb0,12);
+ {unsigned char x=fetch(hl);
+ store(de,x);
+ if(!++l)h++;
+ if(!++e)d++;
+ if(!c--)b--;
+ f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
+ if(b|c)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xb1,12);
+ {unsigned char carry=cy;
+ cpa(fetch(hl));
+ if(!++l)h++;
+ if(!c--)b--;
+ f=(f&0xfa)|carry|(((b|c)>0)<<2);
+ if((f&0x44)==4)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xb2,12);
+ {unsigned short t=in(tstates,b,c);
+ store(hl,t);
+ tstates+=t>>8;
+ if(!++l)h++;
+ b--;
+ f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c)&4);
+ if(b)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xb3,12);
+ {unsigned char x=fetch(hl);
+ tstates+=out(tstates,b,c,x);
+ if(!++l)h++;
+ b--;
+ f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
+ if(b)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xb8,12);
+ {unsigned char x=fetch(hl);
+ store(de,x);
+ if(!l--)h--;
+ if(!e--)d--;
+ if(!c--)b--;
+ f=(f&0xc1)|(x&0x28)|(((b|c)>0)<<2);
+ if(b|c)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xb9,12);
+ {unsigned char carry=cy;
+ cpa(fetch(hl));
+ if(!l--)h--;
+ if(!c--)b--;
+ f=(f&0xfa)|carry|(((b|c)>0)<<2);
+ if((f&0x44)==4)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xba,12);
+ {unsigned short t=in(tstates,b,c);
+ store(hl,t);
+ tstates+=t>>8;
+ if(!l--)h--;
+ b--;
+ f=(b&0xa8)|((b==0)<<6)|2|((parity(b)^c^4)&4);
+ if(b)pc-=2,tstates+=5;
+ }
+endinstr;
+
+instr(0xbb,12);
+ {unsigned char x=fetch(hl);
+ tstates+=out(tstates,b,c,x);
+ if(!l--)h--;
+ b--;
+ f=(f&1)|0x12|(b&0xa8)|((b==0)<<6);
+ if(b)pc-=2,tstates+=5;
+ }
+endinstr;
+
+/* XZ80 Pseudo-ops
+instr(0xfb,4);
+ multiloader(hl,a);
+endinstr;
+
+instr(0xfc,4);
+ { int ans;
+ stopwatch();
+ ans=loader(pc,ix,de,a,cy);
+ if(ans>=0){
+ if(ans==1)pc=0x0806;
+ else if(ans==2)f&=254;
+ else f|=1;
+ ix+=de;
+ d=e=0;
+ if(ans!=1)ret;
+ }
+ startwatch(1);
+ }
+endinstr;
+
+instr(0xfd,4);
+ { int ans;
+ stopwatch();
+ ans=saver(pc,ix,de,a);
+ if(ans>0)pc=0x0806;
+ else if(ans==0){
+ ix+=de;
+ d=e=0;
+ ret;
+ }
+ startwatch(1);
+ }
+endinstr;
+*/
+
+/* ZXCC pseudo-op */
+instr(0xfe, 4);
+{
+ /* Create copies of the registers here so we can take their addresses
+ * and not lose register optimisation in the rest of the CPU code */
+ byte xa,xb,xc,xd,xe,xf,xxh,xxl;
+ word xp,xx,xy;
+
+ xa = a; xb = b; xc = c; xd = d; xe = e; xf = f; xxh = h; xxl = l;
+ xp = pc; xx = ix; xy = iy;
+
+ ed_fe(&xa,&xb,&xc,&xd,&xe,&xf,&xxh,&xxl,&xp,&xx,&xy);
+
+ a = xa; b = xb; c = xc; d = xd; e = xe; f = xf; h = xxh; l = xxl;
+ pc = xp; ix = xx; iy = xy;
+}
+endinstr;
+
+default: tstates+=4;
+
+}}
diff --git a/Tools/unix/zx/readme.txt b/Tools/unix/zx/readme.txt
index 31c3e320..15feb3e8 100644
--- a/Tools/unix/zx/readme.txt
+++ b/Tools/unix/zx/readme.txt
@@ -9,6 +9,9 @@ which is essentially just the zxcc command.
Please see http://www.seasip.info/Unix/Zxcc/ for more information on zxcc.
+Note that this is a Win32 build. The code has not been updated to build as a 64-bit
+binary. However, Win32 binaries run very nicely under 64 bit Windows.
+
To build under Open Watcom or Microsoft Visual C++, use the following command:
cl /Fe"zx.exe" zx.c cpmdrv.c cpmglob.c cpmparse.c cpmredir.c drdos.c util.c xlt.c zxbdos.c zxcbdos.c zxdbdos.c z80.c dirent.c
@@ -17,9 +20,9 @@ To build a debug version, use the following command:
cl /DDEBUG /Fe"zxdbg.exe" zx.c cpmdrv.c cpmglob.c cpmparse.c cpmredir.c drdos.c util.c xlt.c zxbdos.c zxcbdos.c zxdbdos.c z80.c dirent.c
-WARNING: There seems to be a rare scenario that breaks zx under the Open Watcom build. CP/M allows a file to be accessed
-under multiple FCB's without an error. Open Watcom will see this as an error. At present, the only tool I know of that does
-this is M80.
+WARNING: There seems to be a rare scenario that breaks zx under the Open Watcom build.
+CP/M allows a file to be accessed under multiple FCB's without an error. Open Watcom
+will see this as an error. At present, the only tool I know of that does this is M80.
December 5, 2014
@@ -43,5 +46,27 @@ March 15, 2017
- Implemented BDOS console status function.
- Set stdin and stdout to binary mode at startup.
+August 21, 2021
+
+- Incorporated filename case insensitivity changes from Curt Mayer
+- Incorporated fixes from Tony Nicholson at https://github.com/agn453/ZXCC
+ - Emulation of CP/M BDOS function 60 (call resident system extension)
+ should be disabled and return 0xFF in both the A and L registers.
+ - Change cpm_bdos_10() to return an unsigned result to avoid buffer
+ size being interpreted as negative.
+ - Fix the emulation of Z80 opcodes for IN (HL),(C) and
+ OUT (C),(HL) - opcodes 0xED,0x70 and 0xED,0x71 respectively.
+ This is noted in Fred Weigel's AM9511 arithmetic processing unit
+ emulation from https://github.com/ratboy666/am9511 in the howto.txt
+ description. NB: I have not included Fred's am9511 support at this
+ time into ZXCC.
+- Fixed parse_to_fcb function in zx.c to handle parsing second automatic
+ FCB from command line
+- I have not been able to reproduce the multiple FCBs referring to a
+ single file issue with Watcom documented above. Perhaps I fixed it
+ and don't remember or I found a bug-fixed version of M80. Not sure.
+
Wayne Warthen
-wwarthen@gmail.com
\ No newline at end of file
+wwarthen@gmail.com
+
+--WBW 4:09 PM 8/21/2021
\ No newline at end of file
diff --git a/Tools/unix/zx/zx.html b/Tools/unix/zx/zx.html
index b425ee1e..ff2da790 100644
--- a/Tools/unix/zx/zx.html
+++ b/Tools/unix/zx/zx.html
@@ -6,7 +6,7 @@
Windows command line. It is compatible with Windows XP and greater (both
32 and 64 bit).
-zx is basically a port of a subset of the zxcc package by John Elliott.
+
zx is basically a port of a subset of the zxcc program by John Elliott.
The GPLv2 licensing carries forward. Please refer to the
zxcc web page for more information.
@@ -15,7 +15,8 @@ zxcc web page for more information.
execution of the Hi-Tech C CP/M compiler under Unix, zx is slightly
more general and intended to allow running most CP/M tools. Specific
changes were incorporated to improve interactice console operation of
-CP/M applications.
+CP/M applications. Additionally, Curt Mayer added case insensitivity
+for filenames under Unix variants.
Setup
diff --git a/Tools/zx/zx-src.zip b/Tools/zx/zx-src.zip
index 1d51fd61..a2887f97 100644
Binary files a/Tools/zx/zx-src.zip and b/Tools/zx/zx-src.zip differ
diff --git a/Tools/zx/zx.exe b/Tools/zx/zx.exe
index d2cca5e4..73d83296 100644
Binary files a/Tools/zx/zx.exe and b/Tools/zx/zx.exe differ
diff --git a/Tools/zx/zx.html b/Tools/zx/zx.html
index b425ee1e..ff2da790 100644
--- a/Tools/zx/zx.html
+++ b/Tools/zx/zx.html
@@ -6,7 +6,7 @@
Windows command line. It is compatible with Windows XP and greater (both
32 and 64 bit).
-zx is basically a port of a subset of the zxcc package by John Elliott.
+
zx is basically a port of a subset of the zxcc program by John Elliott.
The GPLv2 licensing carries forward. Please refer to the
zxcc web page for more information.
@@ -15,7 +15,8 @@ zxcc web page for more information.
execution of the Hi-Tech C CP/M compiler under Unix, zx is slightly
more general and intended to allow running most CP/M tools. Specific
changes were incorporated to improve interactice console operation of
-CP/M applications.
+CP/M applications. Additionally, Curt Mayer added case insensitivity
+for filenames under Unix variants.
Setup
diff --git a/Tools/zx/zxdbg.exe b/Tools/zx/zxdbg.exe
index 070a9bf8..3079b506 100644
Binary files a/Tools/zx/zxdbg.exe and b/Tools/zx/zxdbg.exe differ