diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 921500b7..49122583 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -25,19 +25,37 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
- sudo apt install -y \
- sdcc binutils make curl cpm
- - name: Install M80
+ sudo apt install -y binutils make curl cpm
+
+ curl -Lo sdcc.tar.bz2 https://sourceforge.net/projects/sdcc/files/sdcc-linux-amd64/4.2.0/sdcc-4.2.0-amd64-unknown-linux2.5.tar.bz2/download
+ mkdir sdcc
+ cd sdcc
+ tar xjf ../sdcc.tar.bz2
+ sudo cp -r sdcc-4.2.0/* /usr/local/
+ sdcc -v
+ - name: Install Nestor80
env:
- VERSION: 1.1
+ N80_VERSION: '1.1'
+ LK80_VERSION: '1.0'
+ LB80_VERSION: '1.0'
run: |
- curl -Lo m80.zip https://github.com/Konamiman/M80dotNet/releases/download/v${VERSION}/M80dotNet_${VERSION}_SelfContained_linux_x64.zip
- unzip m80.zip
- for NAME in M80 L80 LIB80; do
- sudo install -v ${NAME} /usr/local/bin
- rm ${NAME}
- done
- rm m80.zip
+ curl -Lo n80.zip https://github.com/Konamiman/Nestor80/releases/download/n80-v${N80_VERSION}/N80_${N80_VERSION}_SelfContained_linux-x64.zip
+ unzip n80.zip
+ sudo install -v N80 /usr/local/bin
+ rm N80
+ rm n80.zip
+
+ curl -Lo lk80.zip https://github.com/Konamiman/Nestor80/releases/download/lk80-v1.0/LK80_1.0_SelfContained_linux-x64.zip
+ unzip lk80.zip
+ sudo install -v LK80 /usr/local/bin
+ rm LK80
+ rm lk80.zip
+
+ curl -Lo lb80.zip https://github.com/Konamiman/Nestor80/releases/download/lb80-v${LB80_VERSION}/LB80_${LB80_VERSION}_SelfContained_linux-x64.zip
+ unzip lb80.zip
+ sudo install -v LB80 /usr/local/bin
+ rm LB80
+ rm lb80.zip
- name: Add buildtools
run: |
for NAME in buildtools/linux/*; do
diff --git a/.gitignore b/.gitignore
index 33460904..e90eb86e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,7 +30,6 @@ source/kernel/bank*/*.inc
source/kernel/drivers/*.inc
source/kernel/drivers/**/*.inc
source/kernel/drivers/**/*.lst
-!source/kernel/drivers/MegaFlashRomSD/*.bin
source/kernel/drivers/**/*.rom
source/kernel/drivers/**/*.ROM
source/kernel/bank5/*.dat
@@ -51,3 +50,5 @@ source/tools/data.mac
NEXTOR.SYS
NEXTORK.SYS
nextor_base.dat
+*.LST
+
diff --git a/README.md b/README.md
index 1a8f931b..20ad2ac5 100644
--- a/README.md
+++ b/README.md
@@ -24,17 +24,14 @@ Note that there is no `master` branch, but branches for each major version of Ne
## How to build Nextor
-The "official" environment for building Nextor is Linux. Legacy support for Windows is still offered but it's deprecated. Read on for the ugly details.
+Nextor requires Linux to be built. It should work on macOs too, but that hasn't been tested. If you are on Windows 10 or 11 you can use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
-### Linux
-
-To build Nextor on Linux you'll need:
+To build Nextor you'll need:
* `make`. On Debian/Ubuntu-ish systems you can just `apt-get install make`.
-* The native MACRO80 tools provided by [the M80dotNet project](https://github.com/Konamiman/M80dotNet). Go to [the releases section](https://github.com/Konamiman/M80dotNet/releases) and download the appropriate variant of the latest version.
-* [SDCC](http://sdcc.sourceforge.net/), for FDISK and the command line tools written in C. On Debian/Ubuntu-ish systems you can just `apt-get install sdcc`.
+* [The Nestor80 tools](https://github.com/Konamiman/Nestor80). Go to [the releases section](https://github.com/Konamiman/Nestor80/releases) and download the appropriate variant of the latest version for the assembler (N80), the linker (LK80) and the library manager (LB80).
+* [SDCC](http://sdcc.sourceforge.net/) **v4.2 or newer**, for FDISK and the command line tools written in C. On Debian/Ubuntu-ish systems you can just `apt-get install sdcc`.
* `objcopy` from [the binutils package](https://www.gnu.org/software/binutils/). On Debian/Ubuntu-ish systems you can just `apt-get install binutils`.
-* `sjasm` v0.39 to assemble some of the drivers. You have it in the `buildtools/Linux` folder, but you can also build it from [the sources](https://github.com/Konamiman/Sjasm/tree/v0.39) (remember to switch to the `v0.39` branch).
* `mknexrom` to generate the ROM files with the drivers. You have it in the `buildtools/Linux` folder, but you can also build it from the source in the `buildtools/sources` directory.
Except for those obtained via `apt`, you'll need to place these tools at a suitable location to be able to use them, e.g. `/usr/bin`.
@@ -49,16 +46,3 @@ There are five makefiles that will take care of building the different component
You may want to take a look at [this now closed pull request from Dean Netherton](https://github.com/Konamiman/Nextor/pull/79) that contains a different attempt at writing makefiles for bulding Nextor. It even has some nice extra features like building FDD and HDD images with Nextor, and building the `mknexrom` tool itself.
-## Windows
-
-If you use Windows 10 the recommended approach is to use the Linux tools and scripts with [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10). If you use an older Windows the recommended approach is to upgrade to Windows 10 (or to install Linux in a separate partition or disk, or in a virtual machine).
-
-However, if for some reason you are still using a non-WSL capable Windows, support for building Nextor is available as well; but note that it will probably be removed at some point in the future, as it's a maintenance burden (seriously, give Windows 10 and WSL a try, it's really worth it).
-
-To build Nextor on Windows you need:
-
-* The tools in the `buildtools/Windows` folder. These must be placed in some folder included in the `PATH` environment variable.
-* [SDCC](http://sdcc.sourceforge.net/), for FDISK and the command line tools written in C.
-* .NET Framework 2.0 or higher, for the `SymToEqus` tool.
-
-You'll find a number of `.bat` files available at the same locations of the Linux makefiles except for the one in `source` (see "Linux" section above). These are not "makefile-ish" and always build the whole set of kernels/tools.
diff --git a/buildtools/linux/sjasm b/buildtools/linux/sjasm
deleted file mode 100644
index 5570da51..00000000
Binary files a/buildtools/linux/sjasm and /dev/null differ
diff --git a/buildtools/sources/SymToEqus.cs b/buildtools/sources/SymToEqus.cs
deleted file mode 100644
index 39092d97..00000000
--- a/buildtools/sources/SymToEqus.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Text;
-using System.IO;
-using System.Text.RegularExpressions;
-
-namespace Konamiman.SymToEqus
-{
- class Program
- {
- static int Main(string[] args)
- {
- Console.WriteLine("SymToEqus 1.0 - (c) 2008 by Nestor Soriano");
-
- if(args.Length<2) {
- Console.WriteLine(
-@"
-Usage: SymToEqus []
-
-This program converts a .SYM file generated by M80 assembler into a
-file containing an EQU and a PUBLIC label for each symbol.
-
-The label filter regular expression selects which symbols will be
-included, it should explicitly reject spaces and tabs.
-Default label filter accepts all symbols, it is: [^ \t]+"
-);
- return 0;
- }
-
- //* Parse parameters
-
- string inputFile=null;
- try {
- inputFile=File.ReadAllText(args[0]);
- }
- catch(Exception ex) {
- Console.WriteLine("*** Error when reading input file: {0}", ex.Message);
- return 1;
- }
-
- string labelPattern=@"[^ \t]+";
- if(args.Length>2) {
- labelPattern=args[2];
- }
-
- Regex regex = null;
- try {
- regex = new Regex(@"(?[0-9A-Fa-f]{4})[ \t](?"+labelPattern+")");
- }
- catch(Exception ex) {
- Console.WriteLine("*** Error when parsing label filter: {0}", ex.Message);
- return 1;
- }
-
- StringBuilder outputFile=new StringBuilder();
-
- //* Process input file
-
- try {
- MatchCollection matches = regex.Matches(inputFile);
- foreach(Match match in matches) {
- outputFile.AppendFormat("{0} equ {1}h{2}\tpublic {0}{2}", match.Groups["label"].Value, match.Groups["value"].Value, Environment.NewLine);
- }
- }
- catch(Exception ex) {
- Console.WriteLine("*** Error when parsing input file: {0}", ex.Message);
- return 1;
- }
-
- //* Generate output file
-
- try {
- File.WriteAllText(args[1], outputFile.ToString());
- }
- catch(Exception ex) {
- Console.WriteLine("*** Error when creating output file: {0}", ex.Message);
- return 1;
- }
-
- return 0;
- }
- }
-}
diff --git a/buildtools/windows/CPM32.EXE b/buildtools/windows/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/buildtools/windows/CPM32.EXE and /dev/null differ
diff --git a/buildtools/windows/HEX2BIN.EXE b/buildtools/windows/HEX2BIN.EXE
deleted file mode 100644
index be16e9a9..00000000
Binary files a/buildtools/windows/HEX2BIN.EXE and /dev/null differ
diff --git a/buildtools/windows/SymToEqus.exe b/buildtools/windows/SymToEqus.exe
deleted file mode 100644
index cd12f824..00000000
Binary files a/buildtools/windows/SymToEqus.exe and /dev/null differ
diff --git a/buildtools/windows/dd.exe b/buildtools/windows/dd.exe
deleted file mode 100644
index 8cf719cf..00000000
Binary files a/buildtools/windows/dd.exe and /dev/null differ
diff --git a/buildtools/windows/mknexrom.exe b/buildtools/windows/mknexrom.exe
deleted file mode 100644
index 63e24354..00000000
Binary files a/buildtools/windows/mknexrom.exe and /dev/null differ
diff --git a/buildtools/windows/sjasm.exe b/buildtools/windows/sjasm.exe
deleted file mode 100644
index dc125129..00000000
Binary files a/buildtools/windows/sjasm.exe and /dev/null differ
diff --git a/source/command/chkdsk/const.inc b/source/command/chkdsk/const.inc
index 8ab8d93a..1feb670e 100644
--- a/source/command/chkdsk/const.inc
+++ b/source/command/chkdsk/const.inc
@@ -89,11 +89,11 @@ CF_TE EQU 4 ;Set => filename terminator
;
DR_FILE equ 0 ;Filename
DR_EXT equ 8 ;Filename extension
-DR_ATTR equ 11 ;Attributes byte
-DR_DCHAR equ 12 ;Deleted filename character
-DR_TIME equ 22 ;Time of last update
+DR_ATTRIBUTES equ 11 ;Attributes byte
+DR_DELETED_FIRST_CHAR equ 12 ;Deleted filename character
+DR_UPDATED_TIME equ 22 ;Time of last update
DR_DATE equ 24 ;Date of last update
-DR_CLU equ 26 ;Fisrt cluster number
+DR_FIRST_CLUSTER equ 26 ;Fisrt cluster number
DR_SIZE equ 28 ;File size
;
;
diff --git a/source/command/chkdsk/dir.mac b/source/command/chkdsk/dir.mac
index 85197302..32996759 100644
--- a/source/command/chkdsk/dir.mac
+++ b/source/command/chkdsk/dir.mac
@@ -279,8 +279,8 @@ memory_ok: ld hl,(DIR_START##) ;Remember start cluster for
pop hl ;Record start cluster of
ld (DIR_PARENT##),hl ; sub-directories parent
;
- ld l,(ix+DR_CLU)
- ld h,(ix+DR_CLU+1) ;Setup DIR_START ready to
+ ld l,(ix+DR_FIRST_CLUSTER)
+ ld h,(ix+DR_FIRST_CLUSTER+1) ;Setup DIR_START ready to
ld (DIR_START##),hl ; search this sub-directory.
;
ld hl,(FILE_PTR##) ;Store the address of this
@@ -389,13 +389,13 @@ flst_new_2: ld hl,ER_FLAGS## ;If file list is not being
ld (RAM_TOP##),hl ;Record new top of RAM and
ld (FILE_PTR##),hl ; pointer to this record.
;
-use_dummy_rec: ld a,(ix+DR_ATTR) ;Store attributes byte in
+use_dummy_rec: ld a,(ix+DR_ATTRIBUTES) ;Store attributes byte in
ld (hl),a ; the file record.
inc hl
- ld a,(ix+DR_CLU)
+ ld a,(ix+DR_FIRST_CLUSTER)
ld (hl),a ;Store this entry's cluster
inc hl ; number in the file record.
- ld a,(ix+DR_CLU+1)
+ ld a,(ix+DR_FIRST_CLUSTER+1)
ld (hl),a
inc hl
;
diff --git a/source/command/chkdsk/main.mac b/source/command/chkdsk/main.mac
index 710bfdad..8531ae98 100644
--- a/source/command/chkdsk/main.mac
+++ b/source/command/chkdsk/main.mac
@@ -352,8 +352,8 @@ scan_dir_entry: push hl ;Point IX at directory entry
cp 0E5h
jr nz,not_deleted ;If entry is deleted then
xor a ; remove the saved first
- cp (ix+DR_DCHAR) ; character so it can't be
- ld (ix+DR_DCHAR),a ; un-deleted and mark buffer
+ cp (ix+DR_DELETED_FIRST_CHAR) ; character so it can't be
+ ld (ix+DR_DELETED_FIRST_CHAR),a ; un-deleted and mark buffer
call nz,DIRTY_BUFFER## ; as dirty if it was non-zero.
jr scan_dir_next
;
@@ -364,7 +364,7 @@ scan_dir_entry: push hl ;Point IX at directory entry
not_deleted: call FLST_NEW## ;Create a new record for this
call ENT_DEBUG## ; entry in the file list.
;
- ld a,(ix+DR_ATTR) ;Test volume-name bit and
+ ld a,(ix+DR_ATTRIBUTES) ;Test volume-name bit and
bit AT_VOL,a ; skip if not set.
jr z,not_vol_name
;
@@ -389,7 +389,7 @@ kill_vol_name: call QER_MSG## ;Give error message
;
not_vol_name: call CHECK_CHAIN ;Check that chain is valid
ex af,af' ;Save file size check flag
- bit AT_DIR,(ix+DR_ATTR) ;If entry is a file then skip
+ bit AT_DIR,(ix+DR_ATTRIBUTES) ;If entry is a file then skip
jr z,not_sub_dir ; to file size checking.
;
call DRE_SV## ;Setup for sub-dir search
@@ -401,7 +401,7 @@ not_vol_name: call CHECK_CHAIN ;Check that chain is valid
call DRE_SAME## ; back to its parent.
ld a,__CVD_MSG## ;Print out an error message.
call QER_MSG##
- ld (ix+DR_ATTR),ATM_ARC ;Convert the directory into
+ ld (ix+DR_ATTRIBUTES),ATM_ARC ;Convert the directory into
call DIRTY_BUFFER## ; a file, both in the sector
ld hl,(FILE_PTR##) ; buffer and in the file
ld (hl),ATM_ARC ; list record.
@@ -440,8 +440,8 @@ CHECK_CHAIN:
ld bc,0 ;Start cluster count
exx ; at zero.
;
- ld e,(ix+DR_CLU) ;Get first cluster from
- ld d,(ix+DR_CLU+1) ; directory entry and if
+ ld e,(ix+DR_FIRST_CLUSTER) ;Get first cluster from
+ ld d,(ix+DR_FIRST_CLUSTER+1) ; directory entry and if
ld a,d ; it is zero then return
or e ; immediately with BC=0
jr z,chain_done_z ; to indicate null chain.
@@ -481,8 +481,8 @@ invalid_first: ld hl,(FILE_PTR##) ;First cluster number is
ld (hl),0 ; number both in the file
inc hl ; list record and also in the
ld (hl),0 ; directory entry itself.
- ld (ix+DR_CLU),0
- ld (ix+DR_CLU+1),0 ;Flag sector as dirty to
+ ld (ix+DR_FIRST_CLUSTER),0
+ ld (ix+DR_FIRST_CLUSTER+1),0 ;Flag sector as dirty to
call DIRTY_BUFFER## ; ensure it gets written out
ld a,__IENT_MSG##
call QER_MSG## ;Print an error message.
@@ -508,7 +508,7 @@ endif
chain_done_z: xor a ;Allow file size check.
chain_done: push af ;Save file size check flag
exx
- ld a,(ix+DR_ATTR)
+ ld a,(ix+DR_ATTRIBUTES)
ld hl,DIR_COUNT## ;Point HL at correct count
bit AT_DIR,a ; variable for this directory
jr nz,got_count_addr ; entry. There are seperate
@@ -662,7 +662,7 @@ dot_fail_nz_1: pop bc ; failure.
ld bc,0 ; this is what should be in
not_root_clu: ; the entry.
;
- ld de,DR_CLU-DR_ATTR ;Get cluster number from
+ ld de,DR_FIRST_CLUSTER-DR_ATTRIBUTES ;Get cluster number from
add hl,de ; directory entry and compare
ld e,(hl) ; it with the one passed in BC.
inc hl
diff --git a/source/command/command/cli.mac b/source/command/command/cli.mac
index 51964c65..03adca67 100644
--- a/source/command/command/cli.mac
+++ b/source/command/command/cli.mac
@@ -1496,7 +1496,7 @@ if 1
CALL _BDOS ; we can proceed.
RET NZ ; Report any errors.
- LD A,(BUFF##+20) ; We had better define "FIB_ID".
+ LD A,(BUFF##+20) ; We had better define "FIB_VOLUME_ID".
BIT 7,A ; This is not actuall a
LD A,.BADVER## ; "Wrong DOS version" what the error
RET NZ ; code was intended for.
diff --git a/source/command/msxdos/CPM32.EXE b/source/command/msxdos/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/command/msxdos/CPM32.EXE and /dev/null differ
diff --git a/source/command/msxdos/L80.CPM b/source/command/msxdos/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/command/msxdos/L80.CPM and /dev/null differ
diff --git a/source/command/msxdos/LIB80.CPM b/source/command/msxdos/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/command/msxdos/LIB80.CPM and /dev/null differ
diff --git a/source/command/msxdos/M80.CPM b/source/command/msxdos/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/command/msxdos/M80.CPM and /dev/null differ
diff --git a/source/command/msxdos/Makefile b/source/command/msxdos/Makefile
index 3d9b00c2..29dcc962 100644
--- a/source/command/msxdos/Makefile
+++ b/source/command/msxdos/Makefile
@@ -1,23 +1,33 @@
# Makefile for NEXTOR.SYS
-# The generated NEXTOR.SYS and NEXTOR.SYS.japanese are copied to the bin/tools directory.
+# The generated NEXTOR.SYS and NEXTOR.SYS.japanese files are copied to the bin/tools directory.
-export X80_COMMAND_LINE=-t -nb
-export M80_COMMAND_LINE=-8
+ifeq ($(strip $(N80)),)
+N80=N80
+endif
-define hex2bin
- objcopy -I ihex -O binary $(1) $(2)
-endef
+export N80_ARGS=--no-string-escapes --no-show-banner --build-type rel --verbosity 0 --output-file-case lower --include-directory ../../kernel
+
+ifeq ($(strip $(LK80)),)
+LK80=LK80
+endif
+
+export LK80_ARGS=--no-show-banner --verbosity 0 --output-file-case lower --output-format bin
define copy_to_bin
cp $(1) ../../../bin/tools/$(2)
endef
+define assemble
+ @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1)
+ @$(N80) $(1) $(2)
+endef
+
nextor-sys: NEXTOR.SYS NEXTORK.SYS
.phony: prerequisites
-TOOLS := M80 L80 objcopy
+TOOLS := N80 LK80
prerequisites:
@mkdir -p ../../../bin/tools
@@ -27,61 +37,49 @@ prerequisites:
-include prerequisites
INCS := ../../kernel/macros.inc ../../kernel/const.inc ../../kernel/condasm.inc
-RELS := KMSG.REL MESSAGES.REL REAL.REL REF.REL RELOC.REL VER.REL END.REL
+RELS := messages.rel real.rel ref.rel reloc.rel ver.rel end.rel
+JRELS := $(RELS) kmsg.rel
NEXTOR.SYS: \
$(RELS) \
- CODES.REL \
- DATA.REL \
- sys.mac \
- kmsg.mac \
- nokmsg.mac
-
- cp nokmsg.mac USEKMSG.MAC
- M80 -p ../../kernel =SYS
- L80 /P:100,CODES,DATA,RELOC,VER,REF,SYS,REAL,SYS,MESSAGES,END,NEXTOR/n/x/y/e
- $(call hex2bin,NEXTOR.HEX,NEXTOR.SYS)
+ codes.rel \
+ data.rel \
+ sys.mac
+
+ $(call assemble,sys.mac,--define-symbols NO_J_MSG)
+ @$(LK80) --output-file NEXTOR.SYS --code 0100h codes.rel data.rel reloc.rel ver.rel ref.rel sys.rel real.rel sys.rel messages.rel end.rel
$(call copy_to_bin,NEXTOR.SYS)
NEXTORK.SYS: \
- $(RELS) \
- CODES.REL \
- DATA.REL \
- KMSG.REL \
- sys.mac \
- yeskmsg.mac
-
- cp yeskmsg.mac USEKMSG.MAC
- M80 -p ../../kernel =SYS
- L80 /P:100,CODES,DATA,RELOC,VER,REF,SYS,REAL,SYS,MESSAGES,KMSG,END,NEXTORK/n/x/y/e
- $(call hex2bin,NEXTORK.HEX,NEXTORK.SYS)
- $(call copy_to_bin,NEXTORK.SYS,NEXTOR.SYS.japanese)
-
-lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,\
- $(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,\
- $(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
+ $(JRELS) \
+ codes.rel \
+ data.rel \
+ sys.mac
+
+ $(call assemble,sys.mac)
+ @$(LK80) --output-file NEXTOR.SYS.japanese --code 0100h codes.rel data.rel reloc.rel ver.rel ref.rel sys.rel real.rel sys.rel messages.rel kmsg.rel end.rel
+ $(call copy_to_bin,NEXTOR.SYS.japanese)
.SECONDEXPANSION:
-$(RELS): \
- $$(patsubst %.rel,%.mac,$$(call lc, $$@)) \
- $(INCS)
+$(JRELS): \
+ $$(patsubst %.rel,%.mac,$$@) \
+ $(INCS) \
- M80 =$(notdir $(patsubst %.REL,%,$@))
+ $(call assemble,$(patsubst %.rel,%.mac,$@))
-CODES.REL: \
+codes.rel: \
../../kernel/codes.mac \
$(INCS)
- M80 -p ../../kernel =CODES
+ $(call assemble,../../kernel/codes.mac)
-DATA.REL: \
+data.rel: \
../../kernel/data.mac \
$(INCS)
- M80 -p ../../kernel =DATA
+ $(call assemble,../../kernel/data.mac)
.PHONY: clean
clean:
- for ext in BIN HEX REL SYM; do find . -type f -name "*.$$ext" -delete; done
- rm -f USEKMSG.MAC
+ for ext in BIN HEX REL rel SYM; do find . -type f -name "*.$$ext" -delete; done
diff --git a/source/command/msxdos/NEXTOR.SYS.japanese b/source/command/msxdos/NEXTOR.SYS.japanese
new file mode 100644
index 00000000..d900ad8d
Binary files /dev/null and b/source/command/msxdos/NEXTOR.SYS.japanese differ
diff --git a/source/command/msxdos/compile.bat b/source/command/msxdos/compile.bat
deleted file mode 100644
index 680c5944..00000000
--- a/source/command/msxdos/compile.bat
+++ /dev/null
@@ -1,27 +0,0 @@
-@echo off
-cls
-
-copy ..\..\kernel\*.inc
-copy ..\..\kernel\codes.mac
-copy ..\..\kernel\data.mac
-for %%A in (CODES,DATA,KMSG,MESSAGES,REAL,REF,RELOC,VER,END) do cpm32 M80 =%%A
-copy NOKMSG.MAC USEKMSG.MAC
-cpm32 M80 =SYS
-cpm32 l80 /P:100,CODES,DATA,RELOC,VER,REF,SYS,REAL,SYS,MESSAGES,END,NEXTOR/n/x/y/e
-copy YESKMSG.MAC USEKMSG.MAC
-cpm32 M80 =SYS
-cpm32 l80 /P:100,CODES,DATA,RELOC,VER,REF,SYS,REAL,SYS,MESSAGES,KMSG,END,NEXTORK/n/x/y/e
-del USEKMSG.MAC
-hex2bin -s 100 nextor.hex
-hex2bin -s 100 nextork.hex
-del nextor.sys
-del nextork.sys
-ren nextor.bin NEXTOR.SYS
-ren nextork.bin NEXTORK.SYS
-del *.bin
-del *.hex
-del *.rel
-del *.sym
-if not exist ..\..\..\bin\tools md ..\..\..\bin\tools
-copy NEXTOR.SYS ..\..\..\bin\tools
-copy NEXTORK.SYS ..\..\..\bin\tools
diff --git a/source/command/msxdos/end.mac b/source/command/msxdos/end.mac
index 1d8f65e6..e0800726 100644
--- a/source/command/msxdos/end.mac
+++ b/source/command/msxdos/end.mac
@@ -1,3 +1,4 @@
+ name('END')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
SUBTTL End Module
;
diff --git a/source/command/msxdos/kmsg.mac b/source/command/msxdos/kmsg.mac
index 16da5842..e762df36 100644
--- a/source/command/msxdos/kmsg.mac
+++ b/source/command/msxdos/kmsg.mac
@@ -1,5 +1,6 @@
- .Z80
+ .Z80
;
+ name('KMSG')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd
SUBTTL Sample Messages File (Kanji)
;
@@ -28,6 +29,9 @@
; line. Don't forget a DEFB 0 at the end though !.
;
;
+
+ .strenc shift_jis
+
MSG MACRO NAME,TEXT
__&NAME EQU MSGNO ;; Define message number label.
if 0
@@ -97,13 +101,13 @@ CR EQU 0DH
;
MSG READING ; Part (c), one leading space.
- DEFB " (“Ç‚Ý",0
+ DEFB " (èªã¿",0
;
MSG WRITING ; Part (d), one leading psace.
- DEFB " (‘‚«",0
+ DEFB " (書ã",0
;
MSG DRIVE ; Part (e).
- DEFB "ž‚Ý’†) ƒhƒ‰ƒCƒu‚Í",0
+ DEFB "è¾¼ã¿ä¸) ドライブã¯",0
;
MSG ARIDRV ; Printed after the drive letter.
DEFB ':',0
@@ -118,10 +122,10 @@ CR EQU 0DH
;
;
MSG AR ; Message for when 'ignore' is not recommended.
- DEFB "’†Ž~(A)/ÄŽŽs(R)? ",0
+ DEFB "ä¸æ¢(A)/å†è©¦è¡Œ(R)? ",0
;
MSG ARI ; Message for when 'ignore' isn't so dangerous.
- DEFB "’†Ž~(A)/ÄŽŽs(R)/–³Ž‹(I)? ",0
+ DEFB "ä¸æ¢(A)/å†è©¦è¡Œ(R)/無視(I)? ",0
;
;
;
@@ -178,21 +182,23 @@ CR EQU 0DH
DEFB 0
;
MSG INSERT ; Part (d)
- DEFB "COMMAND2.COM‚Ì“ü‚Á‚½ƒfƒBƒXƒN‚ðƒhƒ‰ƒCƒu ",0
+ DEFB "COMMAND2.COMã®å…¥ã£ãŸãƒ‡ã‚£ã‚¹ã‚¯ã‚’ドライブ ",0
;
MSG INSDRV ; Part (e).
- DEFB ": ‚É“ü‚ê‚Ä",0
+ DEFB ": ã«å…¥ã‚Œã¦",0
;
MSG PAUSE ; Part (f), one
; trailing space.
- DEFB "‰½‚©ƒL[‚ð‰Ÿ‚µ‚Ä‚‚¾‚³‚¢. ",0
+ DEFB "何ã‹ã‚ーを押ã—ã¦ãã ã•ã„. ",0
;
MSG NOMEM
- DEFB "ƒƒ‚ƒŠ‚ª‘«‚è‚Ü‚¹‚ñ. ƒVƒXƒeƒ€‚Í’âŽ~‚µ‚Ü‚µ‚½",0
+ DEFB "メモリãŒè¶³ã‚Šã¾ã›ã‚“. システムã¯åœæ¢ã—ã¾ã—ãŸ",0
;
MSG BADVER
- DEFB "MSX-DOS‚̃o[ƒWƒ‡ƒ“‚ªˆá‚¢‚Ü‚·. ƒVƒXƒeƒ€‚Í’âŽ~‚µ‚Ü‚µ‚½",0
+ DEFB "MSX-DOSã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒé•ã„ã¾ã™. システムã¯åœæ¢ã—ã¾ã—ãŸ",0
;
;
;
+ .strenc default
+
END
diff --git a/source/command/msxdos/messages.mac b/source/command/msxdos/messages.mac
index 675aad99..4483b4dd 100644
--- a/source/command/msxdos/messages.mac
+++ b/source/command/msxdos/messages.mac
@@ -1,3 +1,4 @@
+ name('MESSAGES')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
SUBTTL Sample Messages File (English)
;
diff --git a/source/command/msxdos/nokmsg.mac b/source/command/msxdos/nokmsg.mac
deleted file mode 100644
index d9740afc..00000000
--- a/source/command/msxdos/nokmsg.mac
+++ /dev/null
@@ -1 +0,0 @@
-NOKMSG equ 1
diff --git a/source/command/msxdos/real.mac b/source/command/msxdos/real.mac
index a856dd31..919b09ed 100644
--- a/source/command/msxdos/real.mac
+++ b/source/command/msxdos/real.mac
@@ -1,3 +1,4 @@
+ name('REAL')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
SUBTTL Start of Second Copy of Main Code
;
diff --git a/source/command/msxdos/ref.mac b/source/command/msxdos/ref.mac
index d40ddab8..70be3fa7 100644
--- a/source/command/msxdos/ref.mac
+++ b/source/command/msxdos/ref.mac
@@ -1,3 +1,4 @@
+ name('REF')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
SUBTTL Start of First Copy of Main Code
.Z80
diff --git a/source/command/msxdos/reloc.mac b/source/command/msxdos/reloc.mac
index 45039fac..e51e71f3 100644
--- a/source/command/msxdos/reloc.mac
+++ b/source/command/msxdos/reloc.mac
@@ -1,3 +1,4 @@
+ name('RELOC')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
SUBTTL Booting Up Relocation
diff --git a/source/command/msxdos/sys.mac b/source/command/msxdos/sys.mac
index eca152bc..9075b2ab 100644
--- a/source/command/msxdos/sys.mac
+++ b/source/command/msxdos/sys.mac
@@ -1,1957 +1,1955 @@
- TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
- SUBTTL BDOS and BIOS
-;
- .Z80
- include MACROS.INC
- include USEKMSG.MAC
-;
-;
-FALSE EQU 0
-TRUE EQU NOT FALSE
-;
-TEST EQU FALSE ; TRUE for testing version.
-;
-;
-; This file contains all the code of MSX-DOS2.SYS once in memory. It is
-; re-located to high memory on start up and is always put on a page boundary,
-; so that the BIOS jump table can be on a page boundary.
-;
-; The re-location in memory is done by comparing linking the .REL file
-; twice on page boundaries, and comparing the two images. Any differences are
-; the high bytes of addresses that need re-locating (the low bytes being
-; correct).
-;
-; For this reason, this file cannot be split into two or more .REL
-; files and it must contain no global symbol declarations and no references to
-; external symbols that would need relocation.
-;
-; The start of the file, which is the thing which must be on a page
-; boundary, is the BIOS jump table. The first entry is jumped to in order to
-; start MSX-DOS.SYS up properly. Below this on the next page boundary is the
-; destination of the BDOS jump at 5. This jump is not included in MSX-DOS.SYS
-; but is set up during the initialization. The 250 bytes or so between this
-; jump and the BIOS jump table is used as the BDOS stack. The BIOS also needs
-; to switch to a separate stack, although this one does not need to be so
-; large.
-;
-START:
-;
-;
-CODE MACRO OPCODE,ARG
- .8080
- DB (OPCODE ARG)
- .Z80
- ENDM
-;
-;
-LF EQU 0AH
-CR EQU 0DH
-ESC EQU 1BH
-;
-;
-P3BDOS EQU 0F37DH ; Disk BASIC BDOS entry point in page 3.
-
-MFLAGS EQU 0F2EFH ; Miscellaneous flags
-;
-;
-;
- SUBTTL BIOS Table and Routines
-;******************************************************************************
-;
-; This is the dummy CP/M BIOS jump table. The first entry, as in CP/M,
-; is the cold start entry point and is jumped to by the loader code to
-; actually start up MSX-DOS.SYS. It has to jump to the loaded code at a well
-; known entry point because this code is not allowed to declare any externals.
-;
-; The character entry points just end up calling the BIOS entry points
-; in the disk ROM, which then do all the dirty stuff necessary to call the MSX
-; BIOS ROM.
-;
-;
-BIOS_TAB:
- JP STARTUP ; Initial start-up entry point.
-JREBOOT:JP REBOOT ; Re-load COMMAND.COM.
- JP CONST ; Console status.
- JP CONIN ; Console input.
- JP CONOUT ; Console output.
- JP LIST ; Printer output.
- JP PUNCH ; Auxiliary output.
- JP READER ; Auxiliary input.
- JP DISK ; Disk functions, return errors where possible.
- JP DISK
- JP DISK
- JP DISK
- JP DISK
- JP DISK
- JP DISK
- JP LISTST ; Printer status.
- JP DISK
-;
-;
- DEFW VERMSG ; Pointer to version message.
-VERNUM:
- defb RELEASE##+(RELEASE##/256)*16
- defb VERSION##
-;
-;
-VERMSG: DEFB 'NEXTOR.SYS version '
- DEFB VERSION##+'0', '.', RELEASE##/256+'0', RELEASE##+'0'
- DEFB 0
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-; This is the sign-on message that gets printed when MSX-DOS.SYS starts
-; up. If the testing version is assembled, then extra text is included as a
-; warning.
-;
-if 0
-SIGNON: DEFB 'Nextor version '
- DEFB VERSION##+'0', '.', RELEASE##/256+'0', RELEASE##+'0'
- DEFB CR,LF
- DEFB 'Copyright ('
- DEFB CRYEAR##/1000 MOD 10 +'0'
- DEFB CRYEAR##/ 100 MOD 10 +'0'
- DEFB CRYEAR##/ 10 MOD 10 +'0'
- DEFB CRYEAR## MOD 10 +'0'
- DEFB ') Konamiman',CR,LF
-;
- IF TEST
- DEFB CR,LF
- DEFB '*** MZED-compatible testing version ***'
- DEFB CR,LF
- ENDIF
-;
- DEFB CR,LF
- DEFB 0
-endif
-;
-;
-;------------------------------------------------------------------------------
-;
-; This is the initial start up entry point. As in CP/M, this is entered
-; via the first BIOS jump and should not normally be re-entered. If it is,
-; however, it will probably not do any real harm as the system will just
-; re-start. It is assumed, however, that characters can be output without
-; getting disk errors, which would otherwise cause the disk error & possibly
-; the abort routine to be called, which are not yet defined. The sign-on and
-; 'not enough memory' messages are printed by calling the disk BASIC BDOS
-; entry point at F37D, since when these messages need printing the normal BDOS
-; entry point is not yet set up properly.
-;
-; The disk BASIC entry point at F37D is not supported in MSX-DOS 2, and
-; so once MSX-DOS.SYS has started up a jump is put at F37D to jump to the
-; normal BDOS entry code. If anything is trying to call F37D, this stands more
-; of a chance of working than anything else that could be done to F37D.
-;
-STARTUP:LD HL,P3BDOS ; Character outputs initially go through page 3
- LD (OVEC),HL ; entry point.
-;
-if 0 ;v2.31
- LD A,(NOTFIRST##) ; Print sign-on message through page 3 entry,
- LD DE,SIGNON ; but only if the first time.
- OR A
- CALL Z,DSTR
-;
-endif
- LD C,_DOSVER## ; Get the version number.
- CALL P3BDOS ; In case it's an old system.
- LD A,B
- CP 2 ; Check KBDOS is 2.00 or later.
- LD A,__BADVER## ; Print error & halt if not.
- JP C,HANG
-;
- LD HL,SERIAL## ; Copy the serial number (will probably be
- LD DE,SERNO ; wrong if this is entered a second time
- LD BC,4 ; via the BIOS jump table, but that doesn't
- LDIR ; particularly matter).
-;
-RESTART:LD HL,0 ; Zero main and secondary errors returned by
- LD (ERROR2),HL ; process.
-;
-ifdef ver880722
- LD DE,80H ; DE -> command line buffer.
- LD A,(DE) ; Command (from _SYSTEM command from BASIC)?
- OR A
- JR NZ,BOOT ; Leave it there if it is.
-;
-endif
- LD A,(BOOT_DRV##) ; Else set up AUTOEXEC.BAT if the first boot or
- ADD A,'A'-1 ; REBOOT otherwise, with the boot drive as
- LD (AUTPAT),A ; a parameter (so that the batch files can
- LD (REBPAT),A ; access the boot drive as %1).
- LD (AUTOCMD+1),A ; Load AUTOEXEC from the boot drive.
- LD (REBCMD+1),A ; Load REBOOT from the boot drive.
- LD (CMNDM),A ; Load COMMAND.COM from the boot drive.
-;
-ifndef ver880722
- LD DE,80H ; DE -> command line buffer.
- LD A,(DE) ; Command (from _SYSTEM command from BASIC)?
- OR A
- JR NZ,BOOT ; Leave it there if it is.
-;
-endif
- LD HL,NOTFIRST## ; NZ => not the first boot.
- LD A,(HL)
- LD (HL),H ; (set flag => not first time any more)
-;
- LD HL,AUTOCMD
- OR A
- JR Z,COPYCMD
-;
- LD HL,REBCMD
-COPYCMD:LD C,(HL) ; Get length of command.
- INC C ; Include length byte (B=0 from above).
- INC C ; Include null on end.
- LDIR
-;
- JR BOOT ; Jump to re-booting code to load COMMAND.COM.
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-; This is the re-booting code for the BIOS jump table entry. It gets
-; entered when a transient program that was previously loaded terminates (by
-; RETurning with the same stack, jumping to zero or one of the 101 other ways
-; of terminating), and just loads COMMAND.COM at 100H and calls it (as a
-; transient program). The standard MSX-DOS2 COMMAND.COM patches the BIOS jump
-; table re-boot entry point to point to a bit of code in high memory that
-; checksums the area of memory that COMMAND.COM was saved in so that it only
-; re-loads it off disk if it has to.
-;
-; COMMAND.COM is executed as a standard CP/M transient program. The
-; BIOS jump at 0 and the BDOS jump at 5 are set up appropriately and jump to
-; addresses of the form xx03 and xx06 respectively as in CP/M. A command line
-; was put there by whatever code loaded and executed MSX-DOS.SYS, and this is
-; left intact for the command interpreter to look at. If no command was given,
-; however, then MSX-DOS.SYS provides one. This is either AUTOEXEC.BAT or
-; REBOOT.BAT, depending upon whether a variable is zero (first start-up) or
-; non-zero (re-booting). Although a CP/M-compatible command line is provided,
-; the default CP/M FCBs are not set up, as this is rather a lot of bother to
-; do. The FCBs are instead just zeroed.
-;
-; In principle then it should be possible to rename any CP/M or MSX-DOS
-; program as COMMAND.COM and MSX-DOS will boot up into it. The preferred
-; method of doing this, however, is to load the program in the REBOOT batch
-; file.
-;
-; The BOOT entry point below is used when booting COMMAND.COM for the
-; first time after MSX-DOS.SYS is loaded. The REBOOT entry point is used when
-; COMMAND.COM terminates, and it clears the command buffer which the first
-; time contained a command to execute or a AUTOEXEC.BAT or REBOOT.BAT command.
-;
-; The error returned from the last process (as returned from the JOIN
-; function call) is zeroed initially by STARTUP. After that, the error code
-; will actually be the error code returned by the last invocation of COMMAND.
-; If this is not .BADCMD or .OKCMD (or if the first time round) then COMMAND
-; will simply be loaded from disk at 100H and executed. If however the error
-; code was .BADCMD or .OKCMD , then it is assumed that COMMAND is still intact
-; in memory and it simply gets jumped to at 100H without re-loading.
-;
-; This is a fiddle for the initial boot. COMMAND is passed the name of
-; the batch file ('AUTOEXEC' or 'REBOOT') as a command to execute, and if it
-; does not find the batch file then it returns .BADCMD. If the batch file was
-; executed OK then it returns .OKCMD. The fiddle described above is done to
-; prevent a re-load of COMMAND in this perfectly valid and not particularly
-; uncommon case. COMMAND co-operates in this scheme by guaranteeing that if
-; it terminates with .BADCMD or .OKCMD then it is still in memory.
-;
-;
-
-REBOOT: XOR A ; Zero command in command buffer so that when
- LD (80H),A ; it is re-loaded it does not get a command.
-;
-BOOT: CALL $DOSOFF## ; Set up page 1.
-;
- LD HL,DISK_ERROR ; Set up disk error handler vector.
- LD (KDSK_VECT##),HL
- LD HL,ABORT ; Set up abort routine vector.
- LD (KAB_VECT##),HL
-;
- LD DE,0 ; Undefine user's routines.
- CALL @DEFER
- CALL @DEFAB
-;
- LD HL,REBOOT ; Make sure re-boot BIOS jump is set up.
- LD (JREBOOT+1),HL
- LD A,0FFH ; Initialize BDOS re-entrancy count.
- LD (ENTERS),A
-;
- LD HL,0 ; Set up jump vectors at bottom of memory.
- CODE MVI A
- CODE JMP
- LD (HL),A
- INC HL
- LD (HL),LOW BIOS_TAB+3
- INC HL
- LD (HL),HIGH BIOS_TAB
- INC HL
- LD (HL),0 ; I/O byte not implemented.
- INC HL
- INC HL ; Current drive set up later.
- LD (HL),A ; 5 = BDOS jump, address set up later.
- LD HL,JBDOS+8 ; Last byte of destination of JP at 5.
-;
- LD (HL),HIGH BDOS ; Set up jump address.
- DEC HL
- LD (HL),LOW BDOS
- DEC HL
- LD (HL),A ; Set up actual JP opcode.
- LD (6),HL ; Set up address in jump at 5.
- DEC HL
- EX DE,HL ; Copy serial number which was copied to SERNO
- LD HL,SERNO+3 ; from the start of the MSX-DOS.SYS file.
- LD BC,4
- LDDR
- EX DE,HL
- LD (HL),22 ; Put in CP/M version number.
- DEC HL
- LD (HL),0
-;
- LD A,H ; If out of page 3, then print out of memory
- CP 0C0H ; error & hang.
- JR NC,MEMOK
-;
- LD A,__NOMEM## ; Get DE -> message.
-HANG: CALL MESSAGE
- CALL DERRM ; Print error.
- CALL CRLF
- DI
- HALT
-;
-MEMOK: LD SP,BIOS_STACK ; Use MSX-DOS.SYS's own stack in page 3.
- LD HL,BDOS ; OK to use the normal BDOS entry point now.
- LD (OVEC),HL
-;
- LD C,_CURDRV## ; Get the current drive and put it at 4 for
- CALL BDOS ; CP/M compatibility.
- LD (4),A
-;
-if 0 ;Hal_F
- LD HL,(6) ; Make the F37D entry point jump to the same
- LD (P3BDOS+1),HL ; place as the normal entry point at 5.
- CODE MVI A
- CODE JMP
- LD (P3BDOS),A
-endif
-;
- LD A,(ERROR) ; Get error code from COMMAND without doing a
- CP .BADCMD## ; JOIN, and don't reload if .BADCMD or .OKCMD
- JR Z,LOADOK ; =>COMMAND is still in memory. Go with NC.
-;
- CP .OKCMD## ; (ERROR will be 0 first time round)
- JR Z,LOADOK ; Go with NC.
-;
- CP .BATEND## ; Means AUTOEXEC/REBOOT were terminated by the
- JR Z,LOADOK ; user. Go with NC.
-;
-REJOIN: LD BC,0*256+_JOIN##; Reset file handles etc.
- CALL BDOS
- JR NZ,REJOIN ; May fail first time, but should then be OK.
-;
- OR B ; Any error from previous process?
- JR Z,NPERR ; Go if not.
-;
- CALL DERR ; Else print error message.
- CALL CRLF
-NPERR: LD DE,CMNDM ; DE -> '\COMMAND.COM'.
- LD C,_OPEN##
- XOR A
- CALL BDOS ; Attempt to open COMMAND.COM.
- JR NZ,LDERR ; Go if error.
-;
- LD DE,100H ; Else load program to here.
- LD HL,JBDOS-100H ; Maximum number of bytes loadable.
- PUSH HL
- PUSH BC ; Save file handle.
- LD C,_READ##
- CALL BDOS ; Read COMMAND.COM to 100H.
- POP BC ; Restore file handle.
- POP DE ; Restore maximum number of bytes usable.
- JR NZ,LDERR ; Go if error.
-;
- SBC HL,DE ; All of memory filled up?
- LD A,.NORAM## ; (should not really occur)
- JR Z,LDERR ; Print 'Not enough memory' if yes.
-;
- LD C,_CLOSE## ; Close file handle.
- CALL BDOS
- JR NZ,LDERR
-;
- SCF ; Cy => set LOAD_FLAG to FF.
-LOADOK: ; COMMAND.COM is sitting at 100H.
- PUSH AF ; Save LOAD_FLAG.
- LD HL,5CH ; Zero CP/M FCBs.
- LD B,H ; B=0 for later.
-ZLOOP: LD (HL),H
- INC L
- JP P,ZLOOP ; Zero until 80H, which is the command line.
-;
- EX DE,HL ; Set up default DMA address to 80H.
- LD C,_SETDTA##
- CALL BDOS
-;
- POP AF ; Set LOAD_FLAG to FF if a real load => loaded
- SBC A,A ; by MSX-DOS.SYS.
- LD (LOAD_FLAG##),A
-;
- XOR A ; Put address 0 on the stack so that when
- LD L,A ; the COMMAND terminates MSX-DOS.SYS
- LD H,A ; re-loads and executes it.
- PUSH HL
- LD DE,BIOS_TAB-1 ; CP/M seems to execute transient programs
- LD C,0FFH ; with the registers set up this way.
- LD B,A
- JP 100H ; Jump to the program.
-;
-;
-AUTOCMD:DEFB 18,'A:\AUTOEXEC.BAT ' ; A: patched to the boot drive.
-AUTPAT: DEFB 'A:',0 ; A: patched to the boot drive.
-REBCMD: DEFB 16,'A:\REBOOT.BAT ' ; A: patched to the boot drive.
-REBPAT: DEFB 'A:',0 ; A: patched to the boot drive.
-;
-CMNDM: DEFB 'A:\COMMAND2.COM',0 ; A: patched to the boot drive.
-CMDLEN EQU $-CMNDM
-;
-;
-LDERR: ; Error during re-loading - A=error code.
- CP .NOFILE## ; If 'file not found', then suppress error
- LD B,A ; message & just prompt for COMMAND disk.
- CALL NZ,DERR
- CALL CRLF
- LD A,__INSERT##
- CALL DMSG ; Print 'Insert COMMAND.COM disk' etc.
- LD C,_CURDRV##
- CALL BDOS ; Get current drive.
- ADD A,'A' ; Convert to drive letter and print it.
- CALL OUTCH
- LD A,__INSDRV## ; Print rest of message (':' in English).
- CALL DMSG
- CALL CRLF
- LD A,__PAUSE## ; Print 'Press any key to continue' etc.
- CALL DMSG
- CALL INCH ; Wait for a keypress.
- JP REBOOT ; Try again.
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-; The BIOS character I/O routines follow. These are fairly simple
-; because all they really do is call the disk ROM, which has suitable entry
-; points for the BIOS routines.
-;
-;
-CONST: LD HL,KCONST##
- JR BIOS
-;
-CONIN: LD HL,KCONIN##
- JR BIOS
-;
-CONOUT: LD HL,KCONOUT##
- JR BIOS
-;
-LIST: LD HL,KLIST##
- JR BIOS
-;
-PUNCH: LD HL,KPUNCH##
- JR BIOS
-;
-READER: LD HL,KREADER##
- JR BIOS
-;
-LISTST: LD HL,KLISTST##
-;
-BIOS: LD (BIOS_SP),SP ; Save user's stack and switch to
- LD SP,BIOS_STACK ; stack in page 3.
-;
- CALL GO_BIOS##
-;
- LD SP,(BIOS_SP) ; Restore user's stack.
- RET
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-; This is the routine entered for the disk BIOS functions, which are
-; not supported. They return errors where possible but otherwise just return.
-; No CP/M program calling one of these is going to work in any sensible way
-; anyway.
-;
-;
-DISK: XOR A
- LD L,A ; HL = 0 => error from SELDSK function.
- LD H,A
- DEC A ; A = FF => error from read/write.
- RET
-;
-;
-;
- SUBTTL BDOS Entry/Exit Code.
-;******************************************************************************
-;
-; When a program does a BDOS call, it calls location 5. This contains a
-; jump to another jump at an address of the form xx06 (for CP/M compatibility)
-; which then jumps to here. This code can then call the KBDOS.
-;
-;
-; If a user's disk error routine is defined and a disk error occurs,
-; then it is likely to want to do character I/O calls. Thus this entry code
-; has to be re-entrant for at least the direct console I/O function, although
-; no steps are taken to prevent an attempted re-entry of other functions. The
-; reason they may not work is that another disk error could occur. It is
-; inadvisable to call even the other character functions re-entrantly since
-; these can still result in a disk error through re-direction and so on.
-;
-; During a BDOS call, the ABORT routine may be jumped to. This gets
-; jumped to with an error code in A from somewhere within the mysterious
-; depths of the KBDOS. When this happens, the user's abort routine (if
-; defined) is called also with the error code in A. If that returns, then the
-; error code (which may have been modified) is stored in the ERROR variable.
-; If it chooses not to return, then ERROR is zero because it is zeroed before
-; calling a transient program. ERROR2 is treated similarly, but contains the
-; secondary error code.
-;
-; In order to ensure that the user's routine is called in a state where
-; he may return or may continue, the user's error routine is called by
-; patching the 'RET' at the end of the BDOS return code to a NOP, so execution
-; falls through to the code below which does the actual calling. This ensures
-; that the stack etc. is OK.
-;
-;
-; When the KBDOS performs a read or write, it uses the segments defined
-; by the variables P0_TPA..P3_TPA. These are set up when a stack switched
-; occurs (ie. when the BDOS is called non-reentrantly) but not at other times.
-; On return, the paging will always by set up to P0_TPA..P3_TPA. On return
-; from a re-entrant call from a disk error routine therefore the paging will
-; be set up to the paging state when the BDOS was first called.
-;
-; For all calls, all other parameters must either be in registers or in
-; page 3 RAM. Since many BDOS calls pass pointers etc., the items that are
-; pointed to are copied to a page 3 buffer, and pointers to this buffer passed
-; to the KBDOS. The things which are copied are FCBs, ASCIIZ
-; drive/path/filename strings, File Info Blocks and strings to be printed.
-; Since the latter is of arbitrary length, a little print string routine is
-; implemented here.
-;
-; All other copied data structures are 64 bytes or less, although some
-; functions require more than one thing to be copied.
-;
-; A few functions alter the values of IX and IY. These are pushed onto
-; the stack immediately before the return address when calling the function
-; routines, and so these functions can change them in a slightly naughty way.
-;
-; On every BDOS call, the fixed page 3 variable LOAD_FLAG is set to
-; zero. This is used by COMMAND.COM and specially-written programs to check
-; whether it was loaded from COMMAND.COM or MSX-DOS.SYS.
-;
-BDOS:
- LD (A_SAVE),A ; Save A parameter to function.
- LD A,(ENTERS) ; Get re-entrancy count.
- INC A ; First entry?
- LD (ENTERS),A
-if 1
- jr z,BDOS05
- ld (BIOS_SP),sp
- ld sp,BIOS_STACK-100
- push hl
- push bc
- ld hl,(BDOS_STACK##)
- ld bc,(BIOS_SP)
- or a
- sbc hl,bc
- jr c,BDOS02
- ld bc,BDS_SZ##
- sbc hl,bc
- ccf
-BDOS02: pop bc
- pop hl
- ld sp,(BIOS_SP)
- jr nc,BDOS10
- xor a
- ld (ENTERS),a
-BDOS05:
-else
- JR NZ,BDOS10 ; Go if not, else switch stacks.
-endif
-;
- LD (LOAD_FLAG##),A ; Gets set to 0 on every BDOS call.
- LD (BDOS_SP),SP
- LD SP,(BDOS_STACK##)
-;
-BDOS10: EX AF,AF' ; Save alternate register set, as the KBDOS
- PUSH AF ; doesn't.
- EXX ; Save BDOS parameters in alternate registers.
- PUSH HL
- PUSH DE
- PUSH BC
- LD HL,(SP_SAVE) ; Save SP_SAVE for re-entrancy reasons.
- PUSH HL
- PUSH IX ; A couple of routines below change the values
- PUSH IY ; of these saved IX and IYs.
- LD (SP_SAVE),SP ; Save SP for abort entry.
-if 1 ;v2.30
- LD HL,DISK_ERROR ; Set up disk error handler vector.
- LD (KDSK_VECT##),HL
- LD HL,ABORT ; Set up abort routine vector.
- LD (KAB_VECT##),HL
-endif
- LD HL,BDOS_DONE ; Call KBDOS then return to BDOS_DONE.
- PUSH HL
-;
- EXX ; Get back BDOS call parameters.
- PUSH HL
- LD A,C ; Get function number.
- CP MAXFN ; If function number is greater than we know
- JR C,OKFN ; about, then just pass it through to KBDOS.
-;
- LD A,BADNO
-OKFN: LD HL,FNTAB ; HL -> table of function routine addresses.
- ADD A,A ; *2 (addresses in table are 2 bytes)
- ADD A,L
- LD L,A
- JR NC,NOINC
-;
- INC H
-NOINC: LD A,(HL)
- INC HL
- LD H,(HL)
- LD L,A
- EX (SP),HL ; Save routine address, get HL back.
- CODE MVI A ; Get A back again.
-A_SAVE: DEFB 0
- RET ; Jump to routine for this function.
-;
-;
-BDOS_DONE:
- EX AF,AF' ; Save returned A.
- CODE MVI A ; Ensure final 'RET' is set up.
- CODE RET
- LD (RETPAT),A
- EX AF,AF'
-BDOS_RET:
- CODE LXI SP
-SP_SAVE: DEFW 0 ; Restore stack pointer.
- EXX ; Save returned registers.
- EX AF,AF'
- POP IY ; Restore index registers.
- POP IX
- POP HL
- LD (SP_SAVE),HL ; Restore saved value of SP_SAVE.
- POP BC ; Restore saved alternate register set.
- POP DE
- POP HL
- EXX
- POP AF
- EX AF,AF'
- PUSH AF
-;
- LD A,(ENTERS) ; Switch back to user's stack if
- DEC A ; returning from first call.
- LD (ENTERS),A
- JP P,BDOS20
-;
- POP AF ; Pop AF again over stack switch.
- LD SP,(BDOS_SP)
- PUSH AF
-BDOS20:
- POP AF ; Restore A returned from KBDOS.
- OR A ; Set flags.
-RETPAT: RET ; Patched to a 'NOP' for abort.
-;
-; ;
- ;
- ;
-JP_ABORT: ; Abort user's BDOS or BIOS call.
- PUSH HL
- PUSH AF ; Save error code.
- LD HL,(ABORT_VECT) ; Get user's abort routine address.
- LD A,H
- OR L
- POP HL ; H=error code.
- LD A,H ; AF=error code.
- POP HL
- CODE CNZ ; Call user's routine if defined.
-ABORT_VECT:
- DEFW 0
- LD (ERROR),A ; Save error and re-boot if no user routine or
- LD A,B ; if it returned the error.
- LD (ERROR2),A ; Save secondary error code.
-;
-; Simulate DOS1 compatible Control-C handler.
-;
- ld a,(ERROR)
- or a
- JR Z,GO_REBOOT
-;
-OLD_BREAK:
- ld hl,(BREAKVECT##)
- ld e,(hl)
- inc hl
- ld d,(hl)
- ex de,hl
- jp (hl)
-;
-GO_REBOOT:
- JP 0
-;
-;
-;------------------------------------------------------------------------------
-;
-FNTAB: ; Table of routine addresses for the functions.
- DEFW @TERM0 ; Terminate program with no error.
- DEFW @CONIN ; Console input.
- DEFW @CONOUT ; Console output.
- DEFW @AUXIN ; Auxiliary input.
- DEFW @AUXOUT ; Auxiliary output.
- DEFW @LSTOUT ; List output.
- DEFW @DIRIO ; Direct console I/O.
- DEFW @DIRIN ; Direct console input, no echo.
- DEFW @INNOE ; Console input, no echo.
- DEFW @STROUT ; String output.
- DEFW @BUFIN ; Buffered line input.
- DEFW @CONST ; Console status.
-;
- DEFW @CPMVER ; Return CP/M version number.
- DEFW @DSKRST ; Disk reset.
- DEFW @SELDSK ; Select disk.
-;
- DEFW @FOPEN ; Open file (FCB).
- DEFW @FCLOSE ; Close file (FCB).
- DEFW @SFIRST ; Search for first (FCB).
- DEFW @SNEXT ; Search fir next (FCB).
- DEFW @FDEL ; Delete file (FCB).
- DEFW @RDSEQ ; Read sequential (FCB).
- DEFW @WRSEQ ; Write sequential (FCB).
- DEFW @FMAKE ; Create file (FCB).
- DEFW @FREN ; Rename file (FCB).
-;
- DEFW @LOGIN ; Get login vector.
- DEFW @CURDRV ; Get current drive.
- DEFW @SETDTA ; Set disk transfer address.
- DEFW @ALLOC ; Get allocation information.
-;
- DEFW @BADCPM ; Write protect disk in CP/M.
- DEFW @BADCPM ; Get read only vector in CP/M.
- DEFW @BADCPM ; Set file attributes in CP/M.
- DEFW @BADCPM ; Get Disk Parameter Block in CP/M.
- DEFW @BADCPM ; Get/set user code in CP/M.
-;
- DEFW @RDRND ; Read random (FCB).
- DEFW @WRRND ; Write random (FCB).
- DEFW @FSIZE ; Get file size (FCB).
- DEFW @SETRND ; Set random record (FCB).
- DEFW @BADFN ; Undefined function in CP/M.
- DEFW @WRBLK ; Write random block (FCB).
- DEFW @RDBLK ; Read random block (FCB).
- DEFW @WRZER ; Write random with zero fill (FCB).
- DEFW @BADFN ; Unused.
-;
- DEFW @GDATE ; Get date.
- DEFW @SDATE ; Set date.
- DEFW @GTIME ; Get time.
- DEFW @STIME ; Set time.
- DEFW @VERIFY ; Set/reset verify flag.
-;
- DEFW @RDABS ; Absolute sector read.
- DEFW @WRABS ; Absolute sector write.
-;
- DEFW @DPARM ; Get disk parameters.
-;
-BADNO EQU 32H ; Function no. used for un-implemented fns.
- DEFW @BADFN ; Un-implemented functions.
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
- DEFW @BADFN
-;
- ; Start of MSX-DOS 2 functions.
- DEFW @FFIRST ; Find first entry.
- DEFW @FNEXT ; Find next entry.
- DEFW @FNEW ; Find new entry.
-;
- DEFW @OPEN ; Open file handle.
- DEFW @CREATE ; Create file and open file handle.
- DEFW @CLOSE ; Close file handle.
- DEFW @ENSURE ; Ensure file handle.
- DEFW @DUP ; Duplicate file handle.
- DEFW @READ ; Read from file handle.
- DEFW @WRITE ; Write to file handle.
- DEFW @SEEK ; Seek (position file pointer).
- DEFW @IOCTL ; I/O control for devices.
- DEFW @HTEST ; Test file handle.
-;
- DEFW @DELETE ; Delete file or sub-directory.
- DEFW @RENAME ; Rename file or sub-directory.
- DEFW @MOVE ; Move file or sub-directory.
- DEFW @ATTR ; Get/set file attributes.
- DEFW @FTIME ; Get/set file time.
-;
- DEFW @HDELETE ; Delete file handle.
- DEFW @HRENAME ; Rename file handle.
- DEFW @HMOVE ; Move file handle.
- DEFW @HATTR ; Get/set file handle attributes.
- DEFW @HFTIME ; Get/set file handle time.
-;
- DEFW @GETDTA ; Get disk transfer address.
- DEFW @GETVFY ; Get verify flag setting.
- DEFW @GETCD ; Get current directory.
- DEFW @CHDIR ; Set current directory.
- DEFW @PARSE ; Parse path-name string.
- DEFW @PFILE ; Parse filename.
- DEFW @CHKCHR ; Check character.
- DEFW @WPATH ; Get whole path string.
- DEFW @FLUSH ; Flush disk buffers.
-;
- DEFW @FORK ; Fork to process.
- DEFW @JOIN ; Join to process.
- DEFW @TERM ; Terminate with error code.
- DEFW @DEFAB ; Define abort exit routine.
- DEFW @DEFER ; Define critical error handler routine.
- DEFW @ERROR ; Get previous error code.
- DEFW @EXPLAIN ; Explain error code.
- DEFW @FORMAT ; Format a disk.
- DEFW @RAMD ; Create or destroy RAM-disk.
- DEFW @BUFFER ; Allocate sector buffers.
- DEFW @ASSIGN ; Logical drive assignment.
-;
- DEFW @GENV ; Get environment string.
- DEFW @SENV ; Set environment string.
- DEFW @FENV ; Find environment name.
-;
- DEFW @DSKCHK ; Get/set disk check status.
- DEFW @DOSVER ; Get version number.
- DEFW @REDIR ; Get/set redirection status (missing in the original???)
-
- DEFW @FOUT ; Get/set fast STROUT mode.
- DEFW @ZSTROUT ; Zero-terminated string output.
-
- DEFW @RDDRV ; Absolute drive sector read.
- DEFW @WRDRV ; Absolute drive sector write.
-
- DEFW @RALLOC ; Get/set reduced allocation information mode vector
- DEFW @DSPACE ; Get disk space information
-
- DEFW @LOCK ; Lock/unlock drive
-
- DEFW @GDRVR ; Get driver information
- DEFW @GDLI ; Get drive letter information
- DEFW @GPART ; Get information about disk partition
- DEFW @CDRVR ; Call a routine in a disk driver
- DEFW @MAPDRV ; Map a drive to a driver/device/LUN/sector
-
- DEFW @Z80MODE ; Enable or disable the Z80 access mode for a driver
- DEFW @GETCLUS ; Get information about a cluster in a FAT drive
-;
-MAXFN EQU ($-FNTAB)/2 ; Largest function number.
-;
-;
-;
- SUBTTL BDOS CP/M Character I/O Functions
-;******************************************************************************
-;
-@CONIN:
-@CONOUT:
-@AUXIN:
-@AUXOUT:
-@LSTOUT:
-@DIRIO:
-@DIRIN:
-@INNOE:
-@CONST:
-@CPMVER:
-if 0
-@DSKRST:
-@SELDSK:
-endif
-@SNEXT:
-@LOGIN:
-@CURDRV:
-@SETDTA:
-@VERIFY:
-@BADCPM:
- CALL KBDOS
- LD A,L ; Get value to return in A, L.
- LD B,H ; Get value to return in B, H.
- RET
-;
-;
-if 1
-@DSKRST:
- LD E,0
-@SELDSK:
- PUSH DE ; Save drive over call.
- CALL KBDOS
- POP DE
- OR A
- LD A,E
- JR NZ,BAD_DRIVE ; If drive was good put it at 4 for
- LD (4),A ; CP/M compatibility.
-BAD_DRIVE:
- LD A,L
- LD B,H
- RET
-endif
-;
-;
-;------------------------------------------------------------------------------
-;
-
-@STROUT:
- ld a,(MFLAGS)
- and 1
- jr z,strout_slow ;If fast STROUT not enabled, use the slow version.
-
- ;--- STROUT, fast version
-
- ex de,hl
- ld de,($SECBUF##)
- ld bc,511
- ldir
- ld a,"$"
- ld (de),a
- ld c,_STROUT##
- call KBDOS
- jr CPMRET
-
- ;--- STROUT, slow version
-
-strout_slow:
-
- do_strout KBDOS,CPMRET,1 ;Macro defined in macros.inc
-;
-;
-;------------------------------------------------------------------------------
-;
-@BUFIN: PUSH DE
- LD A,(DE) ; Copy only the max. length byte at the start.
- LD DE,BUFF1 ; Use this as the input buffer.
- LD (DE),A
- CALL KBDOS
- POP DE ; Copy the characters back again.
- LD A,(DE) ; Copy back the number of characters specified
- INC DE ; by the max. length byte+1 for the actual
- LD HL,BUFF1+1 ; length byte. Cannot just copy the right
- LD C,A ; number of characters because there is a
- LD B,0 ; CR character on the end which may or may
- INC BC ; not be there.
- LDIR
-;
-CPMRET: XOR A
- LD B,A
- LD L,A
- LD H,A
- RET
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-;
-@ZSTROUT:
- ld a,(MFLAGS)
- and 1
- jr z,zstr_slow ;If fast STROUT not enabled, use the slow version.
-
- ;--- ZSTROUT, fast version
-
- ex de,hl
- ld de,($SECBUF##)
- ld bc,511
- ldir
- xor a
- ld (de),a
- ld c,_ZSTROUT##
- call KBDOS
- xor a
- ret
-
- ;--- ZSTROUT, slow version
-
-zstr_slow:
- LD A,(DE) ;Cannot call the KBDOS routine because the
- INC DE ; string may be any length so cannot be
- or a
- ret z
- PUSH DE
- LD E,A
- LD C,_CONOUT##
- CALL KBDOS
- POP DE
- JR zstr_slow
-;
-;
- SUBTTL BDOS CP/M FCB File Functions
-;******************************************************************************
-;
-; Most of the CP/M file functions involve copying FCBs backwards and
-; forwards. For the sequential operations, 33 bytes need to by copied. For
-; the random operations, 36 bytes need to be copied. For the MSX-DOS 1 block
-; operations, either 36 or 37 bytes need to be copied depending on whether the
-; block size is greater than 63 bytes or not respectively.
-;
-;
-@ALLOC:
- call FUNC_WITH_IXIY
- LD A,C ; Return sectors/cluster in A, not C.
- LD C,(IX+2) ; Return sector size.
- LD B,(IX+3)
- RET
-
-@DOSVER:
- call FUNC_WITH_IXIY
- ld de,(VERNUM)
- ;LD D,VERSION## ; Return MSX-DOS.SYS version too.
- ;LD E,RELEASE##+(RELEASE##/256)*16
- ret
-
-@GPART:
- ;Needs CALL (can't use JP) due to how FUNC_WITH_IXIY manages stack
- call FUNC_WITH_IXIY
- ret
-
-FUNC_WITH_IXIY:
- EXX
- pop bc
- POP HL ; Get return address, and pop off the saved
- POP DE ; values of IX and IY.
- POP DE
- PUSH HL
- push bc
- EXX
- CALL KBDOS ; Call KBDOS, which returns stuff in IY & IX.
- EXX ; Save returned values.
- pop bc
- POP HL ; Get the return address again.
- PUSH IX ; Push new 'saved' IX and IY values.
- PUSH IY
- PUSH HL
- push bc
- EXX
- RET
-
-;
-;
-;------------------------------------------------------------------------------
-;
-@FOPEN:
-@FCLOSE:
-@SFIRST:
-@FDEL:
-@RDSEQ:
-@WRSEQ:
-@FMAKE:
-@FREN:
- LD A,33 ; Ordinary FCBs are 33 bytes long.
- CODE LXI H ; Skip 36 byte FCB entry point.
-;
-; ;
- ;
- ;
-;
-;
-;------------------------------------------------------------------------------
-;
-@RDRND:
-@WRRND:
-@FSIZE:
-@SETRND:
-@WRZER: LD A,36 ; Random FCBs are 36 bytes long.
-;
- PUSH DE ; Save pointer to user's FCB.
- EXX ; Save parameters to BDOS call.
- POP HL ; HL -> user's FCB.
- LD C,A
- LD B,0 ; BC = number of bytes in FCB.
-;
-RW: ; HL->user's FCB, BC=length, '=other params.
- PUSH HL ; Save it again for after the KBDOS call.
- PUSH BC ; Save number of bytes in FCB.
- LD DE,BUFF1 ; Copy to buffer.
- PUSH DE
- LDIR
- EXX ; Get back other parameters.
- POP DE ; DE -> FCB in page 3.
- PUSH DE
- CALL KBDOS
- EXX ; Save return parameters,
- POP HL ; HL -> FCB in page 3.
- POP BC ; Get number of bytes in FCB to copy.
- POP DE ; Get pointer to user's FCB.
- LDIR ; Copy FCB back again.
- EXX ; Get returned values.
- LD A,L
- LD B,H
- RET
-;
-;
-;------------------------------------------------------------------------------
-;
-@WRBLK:
-@RDBLK: PUSH DE ; Save user's FCB pointer for after KBDOS call.
- EXX ; Save function number and HL.
- POP HL ; HL -> user's FCB.
- PUSH HL
- LD BC,14+1
- ADD HL,BC ; HL -> high byte of record size.
- LD C,36
- LD A,(HL)
- OR A
- JR NZ,BLK10 ; Copy 36 bytes if record size >63, else 37.
-;
- DEC HL
- LD A,(HL)
- CP 64
- JR NC,BLK10
-;
- INC C
-BLK10: POP HL ; HL -> user's FCB.
- CALL RW ; Do read/write operation, copy FCB back.
- EX DE,HL ; Return KBDOS's DE in HL for block functions.
- RET
-;
-;
-;------------------------------------------------------------------------------
-;
-@GDATE:
-@GTIME:
-@SDATE:
-@STIME: CALL KBDOS
- LD A,C ; Return day in A.
- RET
-;
-;
-@DPARM: PUSH DE ; Save buffer pointer.
- LD DE,BUFF1
- CALL KBDOS ; Get disk parameters into BUFF1.
- EX DE,HL ; HL -> disk parameters.
- POP DE ; DE -> user's buffer.
- PUSH DE ; Return original DE un-corrupted.
- LD BC,32
- LDIR ; Copy disk parameters to user's buffer.
- POP DE
- RET
-;
-;
-;
- SUBTTL BDOS MSX 2 File Functions
-;******************************************************************************
-;
-@FFIRST:
-@FNEW:
- CALL ?COPYDE ; Copy string or FIB at DE.
- CALL C,COPYHL ; Copy string at HL if DE -> FIB.
- RET NZ ; Return if error.
-;
-;
-@FNEXT:
- PUSH IX
- POP HL ; HL -> user's FIB.
- PUSH HL
- LD DE,BUFF2 ; DE -> buffer for FIB.
- PUSH BC
- LD BC,64
- LDIR ; Copy user's FIB for FNEXT.
- POP BC
-;
- CALL _KBDOS
- POP DE ; DE -> user's FIB space (IX will be returned
- LD HL,BUFF2 ; pointing here because the BDOS entry code
- LD BC,64 ; preserves IX).
- LDIR ; Copy FIB to user's space.
- RET ; Error from function not corrupted.
-;
-;
-;
-;
-@RENAME:
-@MOVE:
- CALL COPYHL ; Copy new filename into BUFF3.
- LD HL,BUFF3 ; Copy string at (DE), HL -> other string.
-;
-@DELETE:
-@ATTR:
-@FTIME:
-@OPEN:
-@CREATE:
-@HTEST: EX AF,AF' ; Save parameter passed in A.
- PUSH DE ; Save pointer to user's FIB.
- CALL ?COPYDE ; Copy FIB or string at DE.
- PUSH AF ; Save FIB/string copied flag (Cy => FIB).
- EX AF,AF' ; Get back the user's A.
- CALL _KBSDE ; Sets DE -> string, HL preserved.
- EX AF,AF' ; Save the error code.
- EXX ; Save the returned registers.
- POP AF ; Cy set => FIB copied, must copy back.
- POP DE ; DE -> user's FIB.
- JR NC,XRET ; Return with error code if not FIB function.
-;
- LD HL,BUFF1 ; HL -> Updated FIB.
- LD BC,64
- LDIR ; Update user's FIB.
-XRET: EX AF,AF' ; Get back error code.
- EXX ; Get back the returned registers.
- RET
-
-
-;
-;
-@HRENAME:
-@HMOVE:
- EX AF,AF' ; Save parameter passed in A.
- CALL COPYHL ; Copy new filename into BUFF3.
- EX AF,AF'
-;
- ;
- ;
- ;
-;
-;------------------------------------------------------------------------------
-;
-; The _KBDOS entry point points the registers at the buffers that FIBs
-; and strings have been copied too, and falls through to KBDOS. This then does
-; the actual calling of the real KBDOS.
-;
-_KBDOS: LD IX,BUFF2 ; IX -> buffer possibly containing FIB.
- LD HL,BUFF3 ; HL -> buffer possibly containing string.
-_KBSDE: LD DE,BUFF1 ; DE -> buffer containing FIB or string.
-;
- ;
- ;
- ;
-;
-;
-@TERM0:
-@RDABS:
-@WRABS:
-@CLOSE:
-@ENSURE:
-@DUP:
-@READ:
-@WRITE:
-@SEEK:
-@IOCTL:
-@HDELETE:
-@HATTR:
-@HFTIME:
-@GETDTA:
-@GETVFY:
-@CHKCHR:
-@FLUSH:
-@TERM:
-@FORMAT:
-@RAMD:
-@BUFFER:
-@FILES:
-@ASSIGN:
-@ERROR:
-@GENV:
-@SENV:
-@FENV:
-@DSKCHK:
-@REDIR:
-@FOUT:
-@RDDRV:
-@WRDRV:
-@RALLOC:
-@DSPACE:
-@LOCK:
-@Z80MODE:
-
-;
-@BADFN: ; Undefined functions go straight through.
-KBDOS:
- JP GO_BDOS## ; Call the KBDOS in kernel page-0 and
- ; return with the KBDOS results.
-;
-;
-;------------------------------------------------------------------------------
-;
-@PARSE: PUSH DE
- CALL COPYDE ; Copy path string.
- POP DE
-@GETCD:
-@WPATH:
- EX DE,HL ; HL -> user's buffer.
- PUSH HL
- LD DE,BUFF1 ; KBDOS puts it's string here.
- OR A
- SBC HL,DE ; HL = offset from BUFF1 to user's buffer.
- PUSH HL
- PUSH DE ; Save BUFF1 address.
- CALL KBDOS ; Get the string to BUFF1.
- EXX ; Save the returned registers.
- POP HL ; BUFF1.
- POP BC ; Offset to user's buffer.
- POP DE ; User's buffer.
- PUSH BC ; Save offset to user's buffer.
- LD BC,64
- LDIR ; Copy the string to the user's buffer.
- EXX
- EX (SP),HL ; Save returned HL, get offset.
- EX DE,HL ; DE=offset to user's buffer.
- ADD HL,DE ; Adjust returned DE.
- EX (SP),HL ; Save adjusted DE, get returned HL.
- ADD HL,DE ; Adjust returned HL.
- POP DE ; Get back adjusted DE.
- RET ; Return with BC and error code intact.
-;
-;
-@PFILE: PUSH HL ; Save pointer to user's buffer twice.
- PUSH HL
- LD L,E ; Save user's string pointer in HL.
- LD H,D
- CALL COPYDE ; Copy filename string to BUFF1.
- LD DE,BUFF1 ; Calculate offset from BUFF1 to user's string.
- OR A
- SBC HL,DE
- EX (SP),HL ; Save offset, get pointer to buffer.
- PUSH HL ; Save pointer again.
- CALL _KBDOS ; Get the parsed filename to BUFF3.
- EXX ; Save the returned registers.
- POP DE ; Get pointer to user's buffer.
- LD BC,11 ; 11 bytes in buffer.
- LD HL,BUFF3 ; Copy the updated filename buffer to the
- LDIR ; user's buffer.
- EXX
- POP HL ; Get offset to user's string, & point pointer
- ADD HL,DE ; to terminating character there.
- EX DE,HL
- POP HL ; Return the original pointer to user's buffer.
- RET ; Return with BC and error code intact.
-;
-;
-;
-@FORK: LD HL,0 ; Zero returned main and secondary error code.
- LD (ERROR2),HL
- JR KBDOS ; Do a KBDOS fork.
-
-;
-;
-@CHDIR:
- CALL COPYDE ; Copy string to BUFF1.
- JR _KBSDE
-;
-;
-@JOIN: CALL KBDOS ; Do a KBDOS join.
- LD BC,(ERROR2) ; B=error code, C=secondary error code.
- LD HL,0 ; Zero them just in case.
- LD (ERROR2),HL
- RET ; With error code from KBDOS.
-;
-;
-@EXPLAIN:
- PUSH DE ; Save pointer to user's buffer.
- LD DE,ERRBUF ; Get message to here.
- CALL KBDOS
- EX DE,HL ; HL -> message in ERRBUF.
- POP DE ; DE -> user's buffer.
- PUSH DE
- PUSH BC ; Save returned B.
- LD BC,64 ; Copy all bytes of message buffer back.
- LDIR
- POP BC ; Return B as returned from the function.
- POP DE ; Return DE -> message in user's buffer.
- RET ; Error code un-corrupted.
-;
-;
-@DEFAB: LD (ABORT_VECT),DE ; Save address of user's abort
- XOR A ; routine.
-;
- LD HL,GO_REBOOT
- LD (BRK_ERRV),HL ; Cancel any setting of MSX-DOS 1.0
- LD HL,BRK_ERRV ; compatible control-C handler.
- LD (BREAKVECT##),HL
-;
- RET ; Return with no error.
-;
-;
-@DEFER: LD (DISK_VECT),DE ; Save address of user's disk error
- XOR A ; routine.
-;
- LD HL,DSK_ERR
- LD (DSK_ERRV),HL ; Cancel any setting MSX-DOS 1.0
- LD HL,DSK_ERRV ; compatible disk-error handler.
- LD (DISKVECT##),HL
-;
- RET ; Return with no error.
-;
-;
-;@DOSVER:CALL KBDOS ; Get KBDOS version number.
-; LD D,VERSION## ; Return MSX-DOS.SYS version too.
-; LD E,RELEASE##+(RELEASE##/256)*16
-; RET
-
-@GDRVR:
-@GDLI:
-@GETCLUS:
- push hl
- LD HL,BUFF3
- call GO_BDOS##
- pop hl
- or a
- ret nz
- push hl
- ex de,hl
- ld hl,BUFF3
- ld bc,64
- ldir
- pop hl
- ret
-
-@CDRVR:
- push de
- push bc
- ld de,BUFF3
- ld bc,8
- ldir
- pop bc
- pop de
- ld hl,BUFF3
-
- EXX
- POP HL ; Get return address, and pop off the saved
- POP DE ; values of IX and IY.
- POP DE
- PUSH HL
- EXX
- push iy
- CALL KBDOS ; Call KBDOS, which returns stuff in IY & IX.
- pop iy
- EXX ; Save returned values.
- POP HL ; Get the return address again.
- PUSH IX ; Push new 'saved' IX and IY values.
- PUSH IY
- PUSH HL
- EXX
- ret
-
-@MAPDRV:
- push de
- push bc
- ld de,BUFF3
- ld bc,64
- ldir
- pop bc
- pop de
- ld hl,BUFF3
- jp KBDOS
-;
-;
-;------------------------------------------------------------------------------
-;
-; These miscellaneous routines do various copying operations needed by
-; the MSX-DOS 2 functions.
-;
-; ?COPYDE copies either a FIB or a string at DE to BUFF1. If a string, then a
-; check is made that the string is not too long, and an error is returned if
-; it is. If a FIB is copied, then an error code is not returned but the carry
-; is returned set.
-;
-; COPYDE always copies a FIB to BUFF1 from DE, and returns with the carry set
-; as described above.
-;
-; COPYHL always copies a string from HL to BUFF3 and returns an error code.
-;
-?COPYDE: ; Copies string or FIB at DE to BUFF1.
- LD A,(DE) ; FIB?
- INC A
- JR NZ,CDE10 ; Copy a string if not.
-;
-COPYDE: PUSH HL
- PUSH BC
- EX DE,HL ; HL -> FIB/string.
- LD DE,BUFF1
- LD BC,64
- LDIR
- POP BC ; Restore BC and HL.
- POP HL
- SCF ; Cy set => FIB copied (not string).
- RET
-;
-CDE10: PUSH HL ; Save HL.
- PUSH BC
- EX DE,HL ; HL -> string.
- LD DE,BUFF1 ; Copy string to here.
- LD B,LEN1
- CALL STRCPY
- POP BC
- POP HL
- RET
-;
-;
-COPYHL: ; Copies the string at HL to BUFF3.
- PUSH DE
- PUSH BC
- LD DE,BUFF3
- LD B,LEN3
- CALL STRCPY
- POP BC
- POP DE
- RET
-;
-;
-STRCPY: LD A,(HL) ; Get character from string.
- INC HL
- LD (DE),A ; Copy into buffer.
- INC DE
- OR A
- RET Z ; Return with no error & NC if end of string.
-;
- DJNZ STRCPY ; Else copy up to 64 bytes.
- LD A,.PLONG## ; String too long if null not encountered.
- RET ; Still NC.
-;
-;
-;
- SUBTTL Abort Routine
-;******************************************************************************
-;
-; This is MSX-DOS.SYS's abort routine, which calls the user's abort
-; routine and then aborts the program by jumping to 0 if it returns or is not
-; defined.
-;
-; In order to call the user's routine, the original BDOS call is
-; returned from, but the 'RET' at the end is patched to a NOP so that it drops
-; through into the code to call the user's routine. This ensures that the
-; user's routine is entered in a state where the user does not have to return
-; (ie. on the user's stack and with the alternate register set preserved etc.)
-;
-ABORT: PUSH AF ; Save error code.
- LD A,(ENTERS) ; In a BDOS call?
- INC A
- JR Z,ABIOS ; Go if not (BIOS call).
-;
- XOR A ; Patch out the 'RET' instruction in the BDOS
- LD (RETPAT),A ; return code to call user abort routine.
- LD (ENTERS),A ; Switch back to user's stack on return.
- POP AF ; Get back error code.
- JP BDOS_RET
-;
-;
-ABIOS: POP AF ; Get back error code.
- LD SP,(BIOS_SP) ; Jump to user's abort routine on his BIOS
- JP JP_ABORT ; stack.
-;
-;
-;
- SUBTTL Disk Error Handler
-;******************************************************************************
-;
-; This is the disk error handler routine, which is always defined as
-; long as MSX-DOS.SYS is running. It is patched into the disk error vector at
-; startup and is the routine that normally prints out 'Abort, Retry' type
-; messages when a low-level disk error occurs.
-;
-; The transient program can define it's own disk error routine by a
-; BDOS call that is handled by MSX-DOS.SYS (not KBDOS). Thus it is this
-; routines job also to call the user's routine.
-;
-; On entry from KBDOS, A=error code.
-; B=logical drive number.
-; C=flags: b0 => read/write error.
-; b1 => ignore OK/ ignore dangerous.
-; b2 => normal/auto-abort error (eg. .IFAT)
-; b3 => sector number in DE is valid.
-; DE=logical sector number or error (if bit 3,C=1).
-;
-; On return to KBDOS, A=1, 2 or 3 for Abort, Retry, Ignore (any other aborts).
-; Any registers (including alternates) may be corrupted.
-; On entry to the user's routine, The registers are set up as above.
-; On return from the user's routine, the registers are set up as above with
-; the addition that A=0 => use the default error handling.
-;
-;
-DISK_ERROR:
- PUSH AF ; Save error on SP for user's
- EX AF,AF' ; routine.
- PUSH AF
- PUSH BC ; Save drive in B, flags in C.
- LD HL,(DISK_VECT) ; Get user's error routine address.
- LD A,H
- OR L ; Defined?
- CALL NZ,JP_USERS ; Go if yes (restores error code first).
- POP BC ; Restore saved drive and flags in BC.
- EX AF,AF'
- POP AF ; Restore saved old error code in A'.
- EX AF,AF'
- POP HL ; Restore error code in H.
- OR A ; User's routine defined & returned a result?
- RET NZ ; Return it to KBDOS if yes.
-;
-; Pass control through old DISKVECT interface.
-;
-; Entry: A' = Old error code (passed to DISKVECT in C)
-; H = New error code (passed to DISKVECT in A')
-; B = Drive number (decremented & passed to DISKVECT in A)
-; C = New Flags (passed to DISKVECT in B)
-; DE = Sector number (passed to DISKVECT in DE)
-;
- LD A,H
- EX AF,AF' ;A':= new error code
- PUSH BC ;Save drive number for routine
- LD B,C ;B := flags
- LD C,A ;C := MSX-DOS 1.0 error flag
-;
- LD HL,(DISKVECT##)
- LD A,(HL) ;Get the address of the user's
- INC HL ; disk error handler routine.
- LD H,(HL)
- LD L,A
-;
- POP AF ;Get drive number back
- DEC A ;A := drive number (0=>A: etc)
-;
- CALL JPHL ;Call the user's disk error handler.
-;
- LD A,3 ;Translate the action code
- SUB C ; for the KBDOS values.
- RET
-;
-;
-;------------------------------------------------------------------------------
-;
-; Entry: A = Drive number (0=A:,1=B: etc)
-; C = Old error code
-; A' = New error code
-; B = New Flags - b0 set => writing
-; b1 set => ignore not recommended
-; b2 set => auto-abort error
-; b3 set => sector number is valid
-; DE = Sector number
-;
-; Results: C = 0 => Ignore
-; 1 => Retry
-; 2 => Abort
-;
-DSK_ERR:
- LD C,B ; Set flags
- INC A
- LD B,A ; Set drive number
- PUSH BC ; Save drive and flags.
- EX AF,AF'
- LD B,A ; B=error number.
- EX AF,AF'
- LD DE,ERRBUF ; Point to buffer for error message.
- LD C,_EXPLAIN## ; Function number.
- CALL BDOS ; Get error message.
- CALL CRLF ; Print new line and error message.
- PUSH DE
- LD A,__PRERR## ; Print a message first (null in English).
- CALL DMSG
- POP DE
- CALL DSTR ; Print actual error message.
- POP BC ; Get back flags.
-;
- LD A,__READ## ; In case reading.
- BIT 0,C
- JR Z,RDERR ; Go if reading.
-;
- LD A,__WRITE## ; Else writing.
-RDERR: PUSH BC ; Save drive and flags again.
- CALL DMSG ; Print 'reading' or 'writing' message.
- LD A,__DRIVE## ; Print 'drive'.
- CALL DMSG
- POP BC ; Get drive.
- LD A,B
- ADD A,'A'-1 ; Convert to upper case letter and print it.
- CALL OUTCH
- LD A,__ARIDRV## ; Print message after drive (':' in English).
- CALL DMSG
-;
- CALL CRLF
- BIT 2,C ; If an 'auto abort' error (eg. .IFAT) then
- LD L,1 ; return A=1 for Abort without giving an
- JR NZ,DERRET ; Abort, Retry prompt.
-;
-ERRLOOP:LD A,__AR## ; Assume 'Abort, Retry' message.
- BIT 1,C
- JR NZ,ABRET ; Go if ignore not recommended.
-;
- LD A,__ARI## ; Else include ignore option.
-ABRET: CALL DMSG ; Print message, flags in C preserved.
- CALL INCH ; Get a keypress in H.
- LD L,0 ; L=0 initially => abort.
- LD A,__ABORT##
- CALL ARITEST ; Test for abort character.
- LD A,__RETRY##
- CALL NC,ARITEST ; Test for retry character.
- LD A,__IGNORE##
- CALL NC,ARITEST ; Test for ignore character.
- JR NC,ERRLOOP ; If invalid character, then re-print message.
-;
-DERRET: LD A,3
- SUB L
- LD C,A ; Return with the MSX-DOS1 response in C.
- RET
-;
-JP_USERS:
- EX AF,AF' ; Restore error code.
-JPHL: JP (HL) ; Jump to user's disk error routine.
-;
-;
-;
-;
-; This little subroutine takes a message number in A and tests to see if the
-; character in H is in the appropriate string. This is used to test to see if
-; the character in H is an appropriate one for Abort, retry or Ignore.
-;
-; B, DE and AF are corrupted, and the carry is set on return if the character
-; was in the string. Also L is returned incremented (this is the code returned
-; to the KBDOS).
-;
-ARITEST:
- INC L ; Return with L incremented.
- CALL MESSAGE ; DE -> string containing valid characters.
-ARIT10: LD A,(DE)
- OR A
- RET Z ; Return with C clear if end of string.
-;
- INC DE
- CP H ; Character in string.
- JR NZ,ARIT10 ; Compare with next if not.
- SCF ; Else return with carry set.
- RET
-;
-;
-;
- SUBTTL I/O Routines
-;******************************************************************************
-;
-; DERR below takes an error number in B and prints the appropriate
-; error message, without a CR,LF on the end. DERRM is similar, but on entry DE
-; already points to the message.
-;
-; DERRM may be called whilst the normal BDOS routine is not yes
-; callable, and so it must only call OUTCH which in this case goes through
-; F37D. DERR is OK since the BDOS is set up properly when it is called.
-;
-;
-DERR: LD DE,ERRBUF ; Point DE to buffer for message.
- LD C,_EXPLAIN## ; C=function code to get error message.
- CALL BDOS ; Attempt to get a message for the error.
-;
-DERRM: PUSH DE ; Save message pointer.
- CALL CRLF
- LD A,__SPLATS##
- CALL DMSG ; Print '***' before message.
- POP DE
- CALL DSTR ; Print actual message.
- LD A,__EREND## ; Print a string after message.
- ;
- ;
- ;
-;
-; DMSG below takes a message number in A and prints the appropriate
-; message. DSTR prints the 0 terminated string at (DE).
-;
-;
-DMSG: CALL MESSAGE ; Point DE at message whose code is in A.
-;
-DSTR: LD A,(DE) ; Get character from message.
- INC DE
- OR A
- RET Z ; Return if end of string.
-;
- CALL OUTCH ; Print character.
- JR DSTR
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-; This routine takes a message number in A and returns DE pointing to
-; the message, which is terminated by a 0. B and A are corrupted.
-;
-;
-MESSAGE:LD B,A ; B=message number.
-if NOKMSG
- LD DE,MESSAGES+2 ; Point DE to messages table.
-else
- xor a
- ld de,1100h ; See if Kanji driver is active.
- call 0FFCAh ; FCALL
- LD DE,MESSAGES+2 ; Point DE to messages table.
- or a
- jr z,ank_msg
- ld a,(MFLAGS)
- and 8
- jr nz,ank_msg
- push hl
- ex de,hl
- dec hl
- ld d,(hl)
- dec hl
- ld e,(hl)
- add hl,de
- ex de,hl
- pop hl
-ank_msg:
-endif
- INC B ; For first time round.
-;
-GMSG10: DEC B ; Message found?
- RET Z ; Return with DE pointing to message if yes.
-;
-GMSG20: LD A,(DE)
- INC DE ; Else find end of message.
- OR A
- JR Z,GMSG10 ; Test again with DE -> next message.
-;
- JR GMSG20
-;
-;
-;
-;------------------------------------------------------------------------------
-;
-; INCH waits for a key to be pressed, and returns it's ASCII value in
-; A, without corrupting BC. It first gobbles up any characters that are
-; waiting to be read (ie. flushes the keyboard buffer) before reading a
-; keypress. It is called when prompting for the insertion of the COMMAND.COM
-; disk and for Abort, Retry disk error prompting.
-;
-;
-INCH: PUSH BC
-;
-IN10: LD C,_CONST## ; See if a key has already been pressed.
- CALL BDOS
- PUSH AF
-;
- LD C,_INNOE## ; Get a keypress anyway.
- CALL BDOS
- LD H,A ; Return it in H.
-;
- POP AF ; If a character was ready then read another
- JR NZ,IN10 ; (this flushes the keyboard buffer)
-;
- LD A,H
- CP ' ' ; Echo it if a printing character.
- CALL NC,OUTCH
- POP BC ; End with a CRLF.
-;
- ;
- ;
- ;
-;
-;
-;------------------------------------------------------------------------------
-;
-; OUTCH takes a character in A and prints it, corrupting only A. CRLF
-; prints a carriage return followed by a line feed. Guess what SPACE does.
-;
-;
-;
-CRLF: LD A,CR ; Output a CR followed by an LF.
- CALL OUTCH
- LD A,LF
- JR OUTCH
-;
-SPACE: LD A,' '
-;
-OUTCH: PUSH HL
- PUSH DE
- PUSH BC
- LD E,A
- LD C,_CONOUT##
- CODE CALL ; This CALL either points to F37D (initially)
-OVEC: DEFW P3BDOS ; or to the normal BDOS entry.
- POP BC
- POP DE
- POP HL
- RET
-;
-;
-;
- SUBTTL Variables
-;******************************************************************************
-;
-; The variable declarations for MSX-DOS.SYS are here. They are not
-; defined using DEFBs etc. so that they do not form part of the MSX-DOS.SYS
-; file, making it considerably smaller, especially considering the fact that
-; two copies of this file are linked.
-;
-; The variables live in the gap that exists between the BIOS jump table and
-; the BDOS entry jump. The BIOS jump table is defined at the start of this
-; module and the BDOS jump is created at initialization time.
-;
-;
-VAR MACRO NAME, SIZE
-OFF DEFL OFF-(SIZE) ; New offset from BIOS jump table.
-NAME EQU BIOS_TAB+OFF ; Variable defined as offset from BIOS table.
- ENDM
-;
-OFF DEFL 0 ; Offset of current variable from BIOS table.
-;
-PRINT MACRO SIZE, TEXT
- IF1
- .PRINTX % SIZE TEXT
- ENDIF
- ENDM
-;
-;
- VAR BIOS_STACK,0
- VAR YYY, 128 ; BIOS stack.
-;
-LEN1 EQU 100 ; Length of buffer 1 (must be >63).
-LEN3 EQU 100 ; Length of buffer 3 (must be >63).
- VAR BUFF3, LEN3 ; Copy buffer for strings at (HL).
- VAR BUFF2, 64 ; Copy buffer for FIBs at (IX).
- VAR BUFF1, LEN1 ; Copy buffer for strings/FIBs at (DE).
- VAR ERRBUF, 64 ; Buffer for error messages.
-;
- VAR SERNO, 4 ; Copy of MSX-DOS.SYS serial number.
-;
- VAR ENTERS, 1 ; BDOS re-entrancy count, -1 => not in BDOS.
- VAR BDOS_SP, 2 ; BDOS SP save for stack switching.
- VAR BIOS_SP, 2 ; BIOS SP save for stack switching.
-;
- VAR DISK_VECT, 2 ; User's disk error routine address.
-;
- VAR ERROR, 1 ; Main error code. These two must be
- VAR ERROR2, 1 ; Secondary error code. in this order
-;
-;
- VAR BDOS_STUFF, 9+2+2
- ; Error vectors + BDOS entries
-;
-VARP EQU (0-OFF+0FFH)/256; Number of 256 byte pages used by variables.
-;
-;
- PRINT %VARP, ; No. pages used.
- PRINT %(VARP*256-(0-OFF)), ; No. unused bytes.
-;
-;
- IF TEST
-JBDOS EQU 0C100H ; BDOS entry jump goes here to avoid MZED.
- ELSE
-JBDOS EQU BIOS_TAB-256*VARP ; Destination address of BDOS JP at 5.
-DSK_ERRV EQU JBDOS+9
-BRK_ERRV EQU JBDOS+11
- ENDIF
-;
-;
-SIZE EQU $-START
- IF LOW (256-LOW SIZE)
- DEFS 256-LOW SIZE,0 ; Pad out to page boundary.
- ENDIF
-;
- PRINT %SIZE, ; No. bytes for code.
-;
-MESSAGES: ; Start of messages when linked.
-;
-;
-;
- SUBTTL
- END
+ name('SYS')
+ TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
+ SUBTTL BDOS and BIOS
+;
+ .Z80
+ include macros.inc
+
+ ;NO_J_MSG constant must be defined externally
+ ;when Japanese error messages aren't included in the build.
+;
+;
+FALSE EQU 0
+TRUE EQU NOT FALSE
+;
+TEST EQU FALSE ; TRUE for testing version.
+;
+;
+; This file contains all the code of MSX-DOS2.SYS once in memory. It is
+; re-located to high memory on start up and is always put on a page boundary,
+; so that the BIOS jump table can be on a page boundary.
+;
+; The re-location in memory is done by comparing linking the .REL file
+; twice on page boundaries, and comparing the two images. Any differences are
+; the high bytes of addresses that need re-locating (the low bytes being
+; correct).
+;
+; For this reason, this file cannot be split into two or more .REL
+; files and it must contain no global symbol declarations and no references to
+; external symbols that would need relocation.
+;
+; The start of the file, which is the thing which must be on a page
+; boundary, is the BIOS jump table. The first entry is jumped to in order to
+; start MSX-DOS.SYS up properly. Below this on the next page boundary is the
+; destination of the BDOS jump at 5. This jump is not included in MSX-DOS.SYS
+; but is set up during the initialization. The 250 bytes or so between this
+; jump and the BIOS jump table is used as the BDOS stack. The BIOS also needs
+; to switch to a separate stack, although this one does not need to be so
+; large.
+;
+START:
+;
+;
+;
+;
+LF EQU 0AH
+CR EQU 0DH
+ESC EQU 1BH
+;
+;
+P3BDOS EQU 0F37DH ; Disk BASIC BDOS entry point in page 3.
+
+MFLAGS EQU 0F2EFH ; Miscellaneous flags
+;
+;
+;
+ SUBTTL BIOS Table and Routines
+;******************************************************************************
+;
+; This is the dummy CP/M BIOS jump table. The first entry, as in CP/M,
+; is the cold start entry point and is jumped to by the loader code to
+; actually start up MSX-DOS.SYS. It has to jump to the loaded code at a well
+; known entry point because this code is not allowed to declare any externals.
+;
+; The character entry points just end up calling the BIOS entry points
+; in the disk ROM, which then do all the dirty stuff necessary to call the MSX
+; BIOS ROM.
+;
+;
+BIOS_TAB:
+ JP STARTUP ; Initial start-up entry point.
+JREBOOT:JP REBOOT ; Re-load COMMAND.COM.
+ JP CONST ; Console status.
+ JP CONIN ; Console input.
+ JP CONOUT ; Console output.
+ JP LIST ; Printer output.
+ JP PUNCH ; Auxiliary output.
+ JP READER ; Auxiliary input.
+ JP DISK ; Disk functions, return errors where possible.
+ JP DISK
+ JP DISK
+ JP DISK
+ JP DISK
+ JP DISK
+ JP DISK
+ JP LISTST ; Printer status.
+ JP DISK
+;
+;
+ DEFW VERMSG ; Pointer to version message.
+VERNUM:
+ defb RELEASE##+(RELEASE##/256)*16
+ defb VERSION##
+;
+;
+VERMSG: DEFB 'NEXTOR.SYS version '
+ DEFB VERSION##+'0', '.', RELEASE##/256+'0', RELEASE##+'0'
+ DEFB 0
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+; This is the sign-on message that gets printed when MSX-DOS.SYS starts
+; up. If the testing version is assembled, then extra text is included as a
+; warning.
+;
+if 0
+SIGNON: DEFB 'Nextor version '
+ DEFB VERSION##+'0', '.', RELEASE##/256+'0', RELEASE##+'0'
+ DEFB CR,LF
+ DEFB 'Copyright ('
+ DEFB CRYEAR##/1000 MOD 10 +'0'
+ DEFB CRYEAR##/ 100 MOD 10 +'0'
+ DEFB CRYEAR##/ 10 MOD 10 +'0'
+ DEFB CRYEAR## MOD 10 +'0'
+ DEFB ') Konamiman',CR,LF
+;
+ IF TEST
+ DEFB CR,LF
+ DEFB '*** MZED-compatible testing version ***'
+ DEFB CR,LF
+ ENDIF
+;
+ DEFB CR,LF
+ DEFB 0
+endif
+;
+;
+;------------------------------------------------------------------------------
+;
+; This is the initial start up entry point. As in CP/M, this is entered
+; via the first BIOS jump and should not normally be re-entered. If it is,
+; however, it will probably not do any real harm as the system will just
+; re-start. It is assumed, however, that characters can be output without
+; getting disk errors, which would otherwise cause the disk error & possibly
+; the abort routine to be called, which are not yet defined. The sign-on and
+; 'not enough memory' messages are printed by calling the disk BASIC BDOS
+; entry point at F37D, since when these messages need printing the normal BDOS
+; entry point is not yet set up properly.
+;
+; The disk BASIC entry point at F37D is not supported in MSX-DOS 2, and
+; so once MSX-DOS.SYS has started up a jump is put at F37D to jump to the
+; normal BDOS entry code. If anything is trying to call F37D, this stands more
+; of a chance of working than anything else that could be done to F37D.
+;
+STARTUP:LD HL,P3BDOS ; Character outputs initially go through page 3
+ LD (OVEC),HL ; entry point.
+;
+if 0 ;v2.31
+ LD A,(NOTFIRST##) ; Print sign-on message through page 3 entry,
+ LD DE,SIGNON ; but only if the first time.
+ OR A
+ CALL Z,DSTR
+;
+endif
+ LD C,_DOSVER## ; Get the version number.
+ CALL P3BDOS ; In case it's an old system.
+ LD A,B
+ CP 2 ; Check KBDOS is 2.00 or later.
+ LD A,__BADVER## ; Print error & halt if not.
+ JP C,HANG
+;
+ LD HL,SERIAL## ; Copy the serial number (will probably be
+ LD DE,SERNO ; wrong if this is entered a second time
+ LD BC,4 ; via the BIOS jump table, but that doesn't
+ LDIR ; particularly matter).
+;
+RESTART:LD HL,0 ; Zero main and secondary errors returned by
+ LD (ERROR2),HL ; process.
+;
+ifdef ver880722
+ LD DE,80H ; DE -> command line buffer.
+ LD A,(DE) ; Command (from _SYSTEM command from BASIC)?
+ OR A
+ JR NZ,BOOT ; Leave it there if it is.
+;
+endif
+ LD A,(BOOT_DRV##) ; Else set up AUTOEXEC.BAT if the first boot or
+ ADD A,'A'-1 ; REBOOT otherwise, with the boot drive as
+ LD (AUTPAT),A ; a parameter (so that the batch files can
+ LD (REBPAT),A ; access the boot drive as %1).
+ LD (AUTOCMD+1),A ; Load AUTOEXEC from the boot drive.
+ LD (REBCMD+1),A ; Load REBOOT from the boot drive.
+ LD (CMNDM),A ; Load COMMAND.COM from the boot drive.
+;
+ifndef ver880722
+ LD DE,80H ; DE -> command line buffer.
+ LD A,(DE) ; Command (from _SYSTEM command from BASIC)?
+ OR A
+ JR NZ,BOOT ; Leave it there if it is.
+;
+endif
+ LD HL,NOTFIRST## ; NZ => not the first boot.
+ LD A,(HL)
+ LD (HL),H ; (set flag => not first time any more)
+;
+ LD HL,AUTOCMD
+ OR A
+ JR Z,COPYCMD
+;
+ LD HL,REBCMD
+COPYCMD:LD C,(HL) ; Get length of command.
+ INC C ; Include length byte (B=0 from above).
+ INC C ; Include null on end.
+ LDIR
+;
+ JR BOOT ; Jump to re-booting code to load COMMAND.COM.
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+; This is the re-booting code for the BIOS jump table entry. It gets
+; entered when a transient program that was previously loaded terminates (by
+; RETurning with the same stack, jumping to zero or one of the 101 other ways
+; of terminating), and just loads COMMAND.COM at 100H and calls it (as a
+; transient program). The standard MSX-DOS2 COMMAND.COM patches the BIOS jump
+; table re-boot entry point to point to a bit of code in high memory that
+; checksums the area of memory that COMMAND.COM was saved in so that it only
+; re-loads it off disk if it has to.
+;
+; COMMAND.COM is executed as a standard CP/M transient program. The
+; BIOS jump at 0 and the BDOS jump at 5 are set up appropriately and jump to
+; addresses of the form xx03 and xx06 respectively as in CP/M. A command line
+; was put there by whatever code loaded and executed MSX-DOS.SYS, and this is
+; left intact for the command interpreter to look at. If no command was given,
+; however, then MSX-DOS.SYS provides one. This is either AUTOEXEC.BAT or
+; REBOOT.BAT, depending upon whether a variable is zero (first start-up) or
+; non-zero (re-booting). Although a CP/M-compatible command line is provided,
+; the default CP/M FCBs are not set up, as this is rather a lot of bother to
+; do. The FCBs are instead just zeroed.
+;
+; In principle then it should be possible to rename any CP/M or MSX-DOS
+; program as COMMAND.COM and MSX-DOS will boot up into it. The preferred
+; method of doing this, however, is to load the program in the REBOOT batch
+; file.
+;
+; The BOOT entry point below is used when booting COMMAND.COM for the
+; first time after MSX-DOS.SYS is loaded. The REBOOT entry point is used when
+; COMMAND.COM terminates, and it clears the command buffer which the first
+; time contained a command to execute or a AUTOEXEC.BAT or REBOOT.BAT command.
+;
+; The error returned from the last process (as returned from the JOIN
+; function call) is zeroed initially by STARTUP. After that, the error code
+; will actually be the error code returned by the last invocation of COMMAND.
+; If this is not .BADCMD or .OKCMD (or if the first time round) then COMMAND
+; will simply be loaded from disk at 100H and executed. If however the error
+; code was .BADCMD or .OKCMD , then it is assumed that COMMAND is still intact
+; in memory and it simply gets jumped to at 100H without re-loading.
+;
+; This is a fiddle for the initial boot. COMMAND is passed the name of
+; the batch file ('AUTOEXEC' or 'REBOOT') as a command to execute, and if it
+; does not find the batch file then it returns .BADCMD. If the batch file was
+; executed OK then it returns .OKCMD. The fiddle described above is done to
+; prevent a re-load of COMMAND in this perfectly valid and not particularly
+; uncommon case. COMMAND co-operates in this scheme by guaranteeing that if
+; it terminates with .BADCMD or .OKCMD then it is still in memory.
+;
+;
+
+REBOOT: XOR A ; Zero command in command buffer so that when
+ LD (80H),A ; it is re-loaded it does not get a command.
+;
+BOOT: CALL $DOSOFF## ; Set up page 1.
+;
+ LD HL,DISK_ERROR ; Set up disk error handler vector.
+ LD (KDSK_VECT##),HL
+ LD HL,ABORT ; Set up abort routine vector.
+ LD (KAB_VECT##),HL
+;
+ LD DE,0 ; Undefine user's routines.
+ CALL @DEFER
+ CALL @DEFAB
+;
+ LD HL,REBOOT ; Make sure re-boot BIOS jump is set up.
+ LD (JREBOOT+1),HL
+ LD A,0FFH ; Initialize BDOS re-entrancy count.
+ LD (ENTERS),A
+;
+ LD HL,0 ; Set up jump vectors at bottom of memory.
+ CODE MVI A
+ CODE JMP
+ LD (HL),A
+ INC HL
+ LD (HL),LOW BIOS_TAB+3
+ INC HL
+ LD (HL),HIGH BIOS_TAB
+ INC HL
+ LD (HL),0 ; I/O byte not implemented.
+ INC HL
+ INC HL ; Current drive set up later.
+ LD (HL),A ; 5 = BDOS jump, address set up later.
+ LD HL,JBDOS+8 ; Last byte of destination of JP at 5.
+;
+ LD (HL),HIGH BDOS ; Set up jump address.
+ DEC HL
+ LD (HL),LOW BDOS
+ DEC HL
+ LD (HL),A ; Set up actual JP opcode.
+ LD (6),HL ; Set up address in jump at 5.
+ DEC HL
+ EX DE,HL ; Copy serial number which was copied to SERNO
+ LD HL,SERNO+3 ; from the start of the MSX-DOS.SYS file.
+ LD BC,4
+ LDDR
+ EX DE,HL
+ LD (HL),22 ; Put in CP/M version number.
+ DEC HL
+ LD (HL),0
+;
+ LD A,H ; If out of page 3, then print out of memory
+ CP 0C0H ; error & hang.
+ JR NC,MEMOK
+;
+ LD A,__NOMEM## ; Get DE -> message.
+HANG: CALL MESSAGE
+ CALL DERRM ; Print error.
+ CALL CRLF
+ DI
+ HALT
+;
+MEMOK: LD SP,BIOS_STACK ; Use MSX-DOS.SYS's own stack in page 3.
+ LD HL,BDOS ; OK to use the normal BDOS entry point now.
+ LD (OVEC),HL
+;
+ LD C,_CURDRV## ; Get the current drive and put it at 4 for
+ CALL BDOS ; CP/M compatibility.
+ LD (4),A
+;
+if 0 ;Hal_F
+ LD HL,(6) ; Make the F37D entry point jump to the same
+ LD (P3BDOS+1),HL ; place as the normal entry point at 5.
+ CODE MVI A
+ CODE JMP
+ LD (P3BDOS),A
+endif
+;
+ LD A,(ERROR) ; Get error code from COMMAND without doing a
+ CP .BADCMD## ; JOIN, and don't reload if .BADCMD or .OKCMD
+ JR Z,LOADOK ; =>COMMAND is still in memory. Go with NC.
+;
+ CP .OKCMD## ; (ERROR will be 0 first time round)
+ JR Z,LOADOK ; Go with NC.
+;
+ CP .BATEND## ; Means AUTOEXEC/REBOOT were terminated by the
+ JR Z,LOADOK ; user. Go with NC.
+;
+REJOIN: LD BC,0*256+_JOIN##; Reset file handles etc.
+ CALL BDOS
+ JR NZ,REJOIN ; May fail first time, but should then be OK.
+;
+ OR B ; Any error from previous process?
+ JR Z,NPERR ; Go if not.
+;
+ CALL DERR ; Else print error message.
+ CALL CRLF
+NPERR: LD DE,CMNDM ; DE -> '\COMMAND.COM'.
+ LD C,_OPEN##
+ XOR A
+ CALL BDOS ; Attempt to open COMMAND.COM.
+ JR NZ,LDERR ; Go if error.
+;
+ LD DE,100H ; Else load program to here.
+ LD HL,JBDOS-100H ; Maximum number of bytes loadable.
+ PUSH HL
+ PUSH BC ; Save file handle.
+ LD C,_READ##
+ CALL BDOS ; Read COMMAND.COM to 100H.
+ POP BC ; Restore file handle.
+ POP DE ; Restore maximum number of bytes usable.
+ JR NZ,LDERR ; Go if error.
+;
+ SBC HL,DE ; All of memory filled up?
+ LD A,.NORAM## ; (should not really occur)
+ JR Z,LDERR ; Print 'Not enough memory' if yes.
+;
+ LD C,_CLOSE## ; Close file handle.
+ CALL BDOS
+ JR NZ,LDERR
+;
+ SCF ; Cy => set LOAD_FLAG to FF.
+LOADOK: ; COMMAND.COM is sitting at 100H.
+ PUSH AF ; Save LOAD_FLAG.
+ LD HL,5CH ; Zero CP/M FCBs.
+ LD B,H ; B=0 for later.
+ZLOOP: LD (HL),H
+ INC L
+ JP P,ZLOOP ; Zero until 80H, which is the command line.
+;
+ EX DE,HL ; Set up default DMA address to 80H.
+ LD C,_SETDTA##
+ CALL BDOS
+;
+ POP AF ; Set LOAD_FLAG to FF if a real load => loaded
+ SBC A,A ; by MSX-DOS.SYS.
+ LD (LOAD_FLAG##),A
+;
+ XOR A ; Put address 0 on the stack so that when
+ LD L,A ; the COMMAND terminates MSX-DOS.SYS
+ LD H,A ; re-loads and executes it.
+ PUSH HL
+ LD DE,BIOS_TAB-1 ; CP/M seems to execute transient programs
+ LD C,0FFH ; with the registers set up this way.
+ LD B,A
+ JP 100H ; Jump to the program.
+;
+;
+AUTOCMD:DEFB 18,'A:\AUTOEXEC.BAT ' ; A: patched to the boot drive.
+AUTPAT: DEFB 'A:',0 ; A: patched to the boot drive.
+REBCMD: DEFB 16,'A:\REBOOT.BAT ' ; A: patched to the boot drive.
+REBPAT: DEFB 'A:',0 ; A: patched to the boot drive.
+;
+CMNDM: DEFB 'A:\COMMAND2.COM',0 ; A: patched to the boot drive.
+CMDLEN EQU $-CMNDM
+;
+;
+LDERR: ; Error during re-loading - A=error code.
+ CP .NOFIL## ; If 'file not found', then suppress error
+ LD B,A ; message & just prompt for COMMAND disk.
+ CALL NZ,DERR
+ CALL CRLF
+ LD A,__INSERT##
+ CALL DMSG ; Print 'Insert COMMAND.COM disk' etc.
+ LD C,_CURDRV##
+ CALL BDOS ; Get current drive.
+ ADD A,'A' ; Convert to drive letter and print it.
+ CALL OUTCH
+ LD A,__INSDRV## ; Print rest of message (':' in English).
+ CALL DMSG
+ CALL CRLF
+ LD A,__PAUSE## ; Print 'Press any key to continue' etc.
+ CALL DMSG
+ CALL INCH ; Wait for a keypress.
+ JP REBOOT ; Try again.
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+; The BIOS character I/O routines follow. These are fairly simple
+; because all they really do is call the disk ROM, which has suitable entry
+; points for the BIOS routines.
+;
+;
+CONST: LD HL,KCONST##
+ JR BIOS
+;
+CONIN: LD HL,KCONIN##
+ JR BIOS
+;
+CONOUT: LD HL,KCONOUT##
+ JR BIOS
+;
+LIST: LD HL,KLIST##
+ JR BIOS
+;
+PUNCH: LD HL,KPUNCH##
+ JR BIOS
+;
+READER: LD HL,KREADER##
+ JR BIOS
+;
+LISTST: LD HL,KLISTST##
+;
+BIOS: LD (BIOS_SP),SP ; Save user's stack and switch to
+ LD SP,BIOS_STACK ; stack in page 3.
+;
+ CALL GO_BIOS##
+;
+ LD SP,(BIOS_SP) ; Restore user's stack.
+ RET
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+; This is the routine entered for the disk BIOS functions, which are
+; not supported. They return errors where possible but otherwise just return.
+; No CP/M program calling one of these is going to work in any sensible way
+; anyway.
+;
+;
+DISK: XOR A
+ LD L,A ; HL = 0 => error from SELDSK function.
+ LD H,A
+ DEC A ; A = FF => error from read/write.
+ RET
+;
+;
+;
+ SUBTTL BDOS Entry/Exit Code.
+;******************************************************************************
+;
+; When a program does a BDOS call, it calls location 5. This contains a
+; jump to another jump at an address of the form xx06 (for CP/M compatibility)
+; which then jumps to here. This code can then call the KBDOS.
+;
+;
+; If a user's disk error routine is defined and a disk error occurs,
+; then it is likely to want to do character I/O calls. Thus this entry code
+; has to be re-entrant for at least the direct console I/O function, although
+; no steps are taken to prevent an attempted re-entry of other functions. The
+; reason they may not work is that another disk error could occur. It is
+; inadvisable to call even the other character functions re-entrantly since
+; these can still result in a disk error through re-direction and so on.
+;
+; During a BDOS call, the ABORT routine may be jumped to. This gets
+; jumped to with an error code in A from somewhere within the mysterious
+; depths of the KBDOS. When this happens, the user's abort routine (if
+; defined) is called also with the error code in A. If that returns, then the
+; error code (which may have been modified) is stored in the ERROR variable.
+; If it chooses not to return, then ERROR is zero because it is zeroed before
+; calling a transient program. ERROR2 is treated similarly, but contains the
+; secondary error code.
+;
+; In order to ensure that the user's routine is called in a state where
+; he may return or may continue, the user's error routine is called by
+; patching the 'RET' at the end of the BDOS return code to a NOP, so execution
+; falls through to the code below which does the actual calling. This ensures
+; that the stack etc. is OK.
+;
+;
+; When the KBDOS performs a read or write, it uses the segments defined
+; by the variables P0_TPA..P3_TPA. These are set up when a stack switched
+; occurs (ie. when the BDOS is called non-reentrantly) but not at other times.
+; On return, the paging will always by set up to P0_TPA..P3_TPA. On return
+; from a re-entrant call from a disk error routine therefore the paging will
+; be set up to the paging state when the BDOS was first called.
+;
+; For all calls, all other parameters must either be in registers or in
+; page 3 RAM. Since many BDOS calls pass pointers etc., the items that are
+; pointed to are copied to a page 3 buffer, and pointers to this buffer passed
+; to the KBDOS. The things which are copied are FCBs, ASCIIZ
+; drive/path/filename strings, File Info Blocks and strings to be printed.
+; Since the latter is of arbitrary length, a little print string routine is
+; implemented here.
+;
+; All other copied data structures are 64 bytes or less, although some
+; functions require more than one thing to be copied.
+;
+; A few functions alter the values of IX and IY. These are pushed onto
+; the stack immediately before the return address when calling the function
+; routines, and so these functions can change them in a slightly naughty way.
+;
+; On every BDOS call, the fixed page 3 variable LOAD_FLAG is set to
+; zero. This is used by COMMAND.COM and specially-written programs to check
+; whether it was loaded from COMMAND.COM or MSX-DOS.SYS.
+;
+BDOS:
+ LD (A_SAVE),A ; Save A parameter to function.
+ LD A,(ENTERS) ; Get re-entrancy count.
+ INC A ; First entry?
+ LD (ENTERS),A
+if 1
+ jr z,BDOS05
+ ld (BIOS_SP),sp
+ ld sp,BIOS_STACK-100
+ push hl
+ push bc
+ ld hl,(BDOS_STACK##)
+ ld bc,(BIOS_SP)
+ or a
+ sbc hl,bc
+ jr c,BDOS02
+ ld bc,BDS_SZ##
+ sbc hl,bc
+ ccf
+BDOS02: pop bc
+ pop hl
+ ld sp,(BIOS_SP)
+ jr nc,BDOS10
+ xor a
+ ld (ENTERS),a
+BDOS05:
+else
+ JR NZ,BDOS10 ; Go if not, else switch stacks.
+endif
+;
+ LD (LOAD_FLAG##),A ; Gets set to 0 on every BDOS call.
+ LD (BDOS_SP),SP
+ LD SP,(BDOS_STACK##)
+;
+BDOS10: EX AF,AF' ; Save alternate register set, as the KBDOS
+ PUSH AF ; doesn't.
+ EXX ; Save BDOS parameters in alternate registers.
+ PUSH HL
+ PUSH DE
+ PUSH BC
+ LD HL,(SP_SAVE) ; Save SP_SAVE for re-entrancy reasons.
+ PUSH HL
+ PUSH IX ; A couple of routines below change the values
+ PUSH IY ; of these saved IX and IYs.
+ LD (SP_SAVE),SP ; Save SP for abort entry.
+if 1 ;v2.30
+ LD HL,DISK_ERROR ; Set up disk error handler vector.
+ LD (KDSK_VECT##),HL
+ LD HL,ABORT ; Set up abort routine vector.
+ LD (KAB_VECT##),HL
+endif
+ LD HL,BDOS_DONE ; Call KBDOS then return to BDOS_DONE.
+ PUSH HL
+;
+ EXX ; Get back BDOS call parameters.
+ PUSH HL
+ LD A,C ; Get function number.
+ CP MAXFN ; If function number is greater than we know
+ JR C,OKFN ; about, then just pass it through to KBDOS.
+;
+ LD A,BADNO
+OKFN: LD HL,FNTAB ; HL -> table of function routine addresses.
+ ADD A,A ; *2 (addresses in table are 2 bytes)
+ ADD A,L
+ LD L,A
+ JR NC,NOINC
+;
+ INC H
+NOINC: LD A,(HL)
+ INC HL
+ LD H,(HL)
+ LD L,A
+ EX (SP),HL ; Save routine address, get HL back.
+ CODE MVI A ; Get A back again.
+A_SAVE: DEFB 0
+ RET ; Jump to routine for this function.
+;
+;
+BDOS_DONE:
+ EX AF,AF' ; Save returned A.
+ CODE MVI A ; Ensure final 'RET' is set up.
+ CODE RET
+ LD (RETPAT),A
+ EX AF,AF'
+BDOS_RET:
+ CODE LXI SP
+SP_SAVE: DEFW 0 ; Restore stack pointer.
+ EXX ; Save returned registers.
+ EX AF,AF'
+ POP IY ; Restore index registers.
+ POP IX
+ POP HL
+ LD (SP_SAVE),HL ; Restore saved value of SP_SAVE.
+ POP BC ; Restore saved alternate register set.
+ POP DE
+ POP HL
+ EXX
+ POP AF
+ EX AF,AF'
+ PUSH AF
+;
+ LD A,(ENTERS) ; Switch back to user's stack if
+ DEC A ; returning from first call.
+ LD (ENTERS),A
+ JP P,BDOS20
+;
+ POP AF ; Pop AF again over stack switch.
+ LD SP,(BDOS_SP)
+ PUSH AF
+BDOS20:
+ POP AF ; Restore A returned from KBDOS.
+ OR A ; Set flags.
+RETPAT: RET ; Patched to a 'NOP' for abort.
+;
+; ;
+ ;
+ ;
+JP_ABORT: ; Abort user's BDOS or BIOS call.
+ PUSH HL
+ PUSH AF ; Save error code.
+ LD HL,(ABORT_VECT) ; Get user's abort routine address.
+ LD A,H
+ OR L
+ POP HL ; H=error code.
+ LD A,H ; AF=error code.
+ POP HL
+ CODE CNZ ; Call user's routine if defined.
+ABORT_VECT:
+ DEFW 0
+ LD (ERROR),A ; Save error and re-boot if no user routine or
+ LD A,B ; if it returned the error.
+ LD (ERROR2),A ; Save secondary error code.
+;
+; Simulate DOS1 compatible Control-C handler.
+;
+ ld a,(ERROR)
+ or a
+ JR Z,GO_REBOOT
+;
+OLD_BREAK:
+ ld hl,(BREAKVECT##)
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ ex de,hl
+ jp (hl)
+;
+GO_REBOOT:
+ JP 0
+;
+;
+;------------------------------------------------------------------------------
+;
+FNTAB: ; Table of routine addresses for the functions.
+ DEFW @TERM0 ; Terminate program with no error.
+ DEFW @CONIN ; Console input.
+ DEFW @CONOUT ; Console output.
+ DEFW @AUXIN ; Auxiliary input.
+ DEFW @AUXOUT ; Auxiliary output.
+ DEFW @LSTOUT ; List output.
+ DEFW @DIRIO ; Direct console I/O.
+ DEFW @DIRIN ; Direct console input, no echo.
+ DEFW @INNOE ; Console input, no echo.
+ DEFW @STROUT ; String output.
+ DEFW @BUFIN ; Buffered line input.
+ DEFW @CONST ; Console status.
+;
+ DEFW @CPMVER ; Return CP/M version number.
+ DEFW @DSKRST ; Disk reset.
+ DEFW @SELDSK ; Select disk.
+;
+ DEFW @FOPEN ; Open file (FCB).
+ DEFW @FCLOSE ; Close file (FCB).
+ DEFW @SFIRST ; Search for first (FCB).
+ DEFW @SNEXT ; Search fir next (FCB).
+ DEFW @FDEL ; Delete file (FCB).
+ DEFW @RDSEQ ; Read sequential (FCB).
+ DEFW @WRSEQ ; Write sequential (FCB).
+ DEFW @FMAKE ; Create file (FCB).
+ DEFW @FREN ; Rename file (FCB).
+;
+ DEFW @LOGIN ; Get login vector.
+ DEFW @CURDRV ; Get current drive.
+ DEFW @SETDTA ; Set disk transfer address.
+ DEFW @ALLOC ; Get allocation information.
+;
+ DEFW @BADCPM ; Write protect disk in CP/M.
+ DEFW @BADCPM ; Get read only vector in CP/M.
+ DEFW @BADCPM ; Set file attributes in CP/M.
+ DEFW @BADCPM ; Get Disk Parameter Block in CP/M.
+ DEFW @BADCPM ; Get/set user code in CP/M.
+;
+ DEFW @RDRND ; Read random (FCB).
+ DEFW @WRRND ; Write random (FCB).
+ DEFW @FSIZE ; Get file size (FCB).
+ DEFW @SETRND ; Set random record (FCB).
+ DEFW @BADFN ; Undefined function in CP/M.
+ DEFW @WRBLK ; Write random block (FCB).
+ DEFW @RDBLK ; Read random block (FCB).
+ DEFW @WRZER ; Write random with zero fill (FCB).
+ DEFW @BADFN ; Unused.
+;
+ DEFW @GDATE ; Get date.
+ DEFW @SDATE ; Set date.
+ DEFW @GTIME ; Get time.
+ DEFW @STIME ; Set time.
+ DEFW @VERIFY ; Set/reset verify flag.
+;
+ DEFW @RDABS ; Absolute sector read.
+ DEFW @WRABS ; Absolute sector write.
+;
+ DEFW @DPARM ; Get disk parameters.
+;
+BADNO EQU 32H ; Function no. used for un-implemented fns.
+ DEFW @BADFN ; Un-implemented functions.
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+ DEFW @BADFN
+;
+ ; Start of MSX-DOS 2 functions.
+ DEFW @FFIRST ; Find first entry.
+ DEFW @FNEXT ; Find next entry.
+ DEFW @FNEW ; Find new entry.
+;
+ DEFW @OPEN ; Open file handle.
+ DEFW @CREATE ; Create file and open file handle.
+ DEFW @CLOSE ; Close file handle.
+ DEFW @ENSURE ; Ensure file handle.
+ DEFW @DUP ; Duplicate file handle.
+ DEFW @READ ; Read from file handle.
+ DEFW @WRITE ; Write to file handle.
+ DEFW @SEEK ; Seek (position file pointer).
+ DEFW @IOCTL ; I/O control for devices.
+ DEFW @HTEST ; Test file handle.
+;
+ DEFW @DELETE ; Delete file or sub-directory.
+ DEFW @RENAME ; Rename file or sub-directory.
+ DEFW @MOVE ; Move file or sub-directory.
+ DEFW @ATTR ; Get/set file attributes.
+ DEFW @FTIME ; Get/set file time.
+;
+ DEFW @HDELETE ; Delete file handle.
+ DEFW @HRENAME ; Rename file handle.
+ DEFW @HMOVE ; Move file handle.
+ DEFW @HATTR ; Get/set file handle attributes.
+ DEFW @HFTIME ; Get/set file handle time.
+;
+ DEFW @GETDTA ; Get disk transfer address.
+ DEFW @GETVFY ; Get verify flag setting.
+ DEFW @GETCD ; Get current directory.
+ DEFW @CHDIR ; Set current directory.
+ DEFW @PARSE ; Parse path-name string.
+ DEFW @PFILE ; Parse filename.
+ DEFW @CHKCHR ; Check character.
+ DEFW @WPATH ; Get whole path string.
+ DEFW @FLUSH ; Flush disk buffers.
+;
+ DEFW @FORK ; Fork to process.
+ DEFW @JOIN ; Join to process.
+ DEFW @TERM ; Terminate with error code.
+ DEFW @DEFAB ; Define abort exit routine.
+ DEFW @DEFER ; Define critical error handler routine.
+ DEFW @ERROR ; Get previous error code.
+ DEFW @EXPLAIN ; Explain error code.
+ DEFW @FORMAT ; Format a disk.
+ DEFW @RAMD ; Create or destroy RAM-disk.
+ DEFW @BUFFER ; Allocate sector buffers.
+ DEFW @ASSIGN ; Logical drive assignment.
+;
+ DEFW @GENV ; Get environment string.
+ DEFW @SENV ; Set environment string.
+ DEFW @FENV ; Find environment name.
+;
+ DEFW @DSKCHK ; Get/set disk check status.
+ DEFW @DOSVER ; Get version number.
+ DEFW @REDIR ; Get/set redirection status (missing in the original???)
+
+ DEFW @FOUT ; Get/set fast STROUT mode.
+ DEFW @ZSTROUT ; Zero-terminated string output.
+
+ DEFW @RDDRV ; Absolute drive sector read.
+ DEFW @WRDRV ; Absolute drive sector write.
+
+ DEFW @RALLOC ; Get/set reduced allocation information mode vector
+ DEFW @DSPACE ; Get disk space information
+
+ DEFW @LOCK ; Lock/unlock drive
+
+ DEFW @GDRVR ; Get driver information
+ DEFW @GDLI ; Get drive letter information
+ DEFW @GPART ; Get information about disk partition
+ DEFW @CDRVR ; Call a routine in a disk driver
+ DEFW @MAPDRV ; Map a drive to a driver/device/LUN/sector
+
+ DEFW @Z80MODE ; Enable or disable the Z80 access mode for a driver
+ DEFW @GETCLUS ; Get information about a cluster in a FAT drive
+;
+MAXFN EQU ($-FNTAB)/2 ; Largest function number.
+;
+;
+;
+ SUBTTL BDOS CP/M Character I/O Functions
+;******************************************************************************
+;
+@CONIN:
+@CONOUT:
+@AUXIN:
+@AUXOUT:
+@LSTOUT:
+@DIRIO:
+@DIRIN:
+@INNOE:
+@CONST:
+@CPMVER:
+if 0
+@DSKRST:
+@SELDSK:
+endif
+@SNEXT:
+@LOGIN:
+@CURDRV:
+@SETDTA:
+@VERIFY:
+@BADCPM:
+ CALL KBDOS
+ LD A,L ; Get value to return in A, L.
+ LD B,H ; Get value to return in B, H.
+ RET
+;
+;
+if 1
+@DSKRST:
+ LD E,0
+@SELDSK:
+ PUSH DE ; Save drive over call.
+ CALL KBDOS
+ POP DE
+ OR A
+ LD A,E
+ JR NZ,BAD_DRIVE ; If drive was good put it at 4 for
+ LD (4),A ; CP/M compatibility.
+BAD_DRIVE:
+ LD A,L
+ LD B,H
+ RET
+endif
+;
+;
+;------------------------------------------------------------------------------
+;
+
+@STROUT:
+ ld a,(MFLAGS)
+ and 1
+ jr z,strout_slow ;If fast STROUT not enabled, use the slow version.
+
+ ;--- STROUT, fast version
+
+ ex de,hl
+ ld de,($SECBUF##)
+ ld bc,511
+ ldir
+ ld a,"$"
+ ld (de),a
+ ld c,_STROUT##
+ call KBDOS
+ jr CPMRET
+
+ ;--- STROUT, slow version
+
+strout_slow:
+
+ do_strout KBDOS,CPMRET,1 ;Macro defined in macros.inc
+;
+;
+;------------------------------------------------------------------------------
+;
+@BUFIN: PUSH DE
+ LD A,(DE) ; Copy only the max. length byte at the start.
+ LD DE,BUFF1 ; Use this as the input buffer.
+ LD (DE),A
+ CALL KBDOS
+ POP DE ; Copy the characters back again.
+ LD A,(DE) ; Copy back the number of characters specified
+ INC DE ; by the max. length byte+1 for the actual
+ LD HL,BUFF1+1 ; length byte. Cannot just copy the right
+ LD C,A ; number of characters because there is a
+ LD B,0 ; CR character on the end which may or may
+ INC BC ; not be there.
+ LDIR
+;
+CPMRET: XOR A
+ LD B,A
+ LD L,A
+ LD H,A
+ RET
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+;
+@ZSTROUT:
+ ld a,(MFLAGS)
+ and 1
+ jr z,zstr_slow ;If fast STROUT not enabled, use the slow version.
+
+ ;--- ZSTROUT, fast version
+
+ ex de,hl
+ ld de,($SECBUF##)
+ ld bc,511
+ ldir
+ xor a
+ ld (de),a
+ ld c,_ZSTROUT##
+ call KBDOS
+ xor a
+ ret
+
+ ;--- ZSTROUT, slow version
+
+zstr_slow:
+ LD A,(DE) ;Cannot call the KBDOS routine because the
+ INC DE ; string may be any length so cannot be
+ or a
+ ret z
+ PUSH DE
+ LD E,A
+ LD C,_CONOUT##
+ CALL KBDOS
+ POP DE
+ JR zstr_slow
+;
+;
+ SUBTTL BDOS CP/M FCB File Functions
+;******************************************************************************
+;
+; Most of the CP/M file functions involve copying FCBs backwards and
+; forwards. For the sequential operations, 33 bytes need to by copied. For
+; the random operations, 36 bytes need to be copied. For the MSX-DOS 1 block
+; operations, either 36 or 37 bytes need to be copied depending on whether the
+; block size is greater than 63 bytes or not respectively.
+;
+;
+@ALLOC:
+ call FUNC_WITH_IXIY
+ LD A,C ; Return sectors/cluster in A, not C.
+ LD C,(IX+2) ; Return sector size.
+ LD B,(IX+3)
+ RET
+
+@DOSVER:
+ call FUNC_WITH_IXIY
+ ld de,(VERNUM)
+ ;LD D,VERSION## ; Return MSX-DOS.SYS version too.
+ ;LD E,RELEASE##+(RELEASE##/256)*16
+ ret
+
+@GPART:
+ ;Needs CALL (can't use JP) due to how FUNC_WITH_IXIY manages stack
+ call FUNC_WITH_IXIY
+ ret
+
+FUNC_WITH_IXIY:
+ EXX
+ pop bc
+ POP HL ; Get return address, and pop off the saved
+ POP DE ; values of IX and IY.
+ POP DE
+ PUSH HL
+ push bc
+ EXX
+ CALL KBDOS ; Call KBDOS, which returns stuff in IY & IX.
+ EXX ; Save returned values.
+ pop bc
+ POP HL ; Get the return address again.
+ PUSH IX ; Push new 'saved' IX and IY values.
+ PUSH IY
+ PUSH HL
+ push bc
+ EXX
+ RET
+
+;
+;
+;------------------------------------------------------------------------------
+;
+@FOPEN:
+@FCLOSE:
+@SFIRST:
+@FDEL:
+@RDSEQ:
+@WRSEQ:
+@FMAKE:
+@FREN:
+ LD A,33 ; Ordinary FCBs are 33 bytes long.
+ CODE LXI H ; Skip 36 byte FCB entry point.
+;
+; ;
+ ;
+ ;
+;
+;
+;------------------------------------------------------------------------------
+;
+@RDRND:
+@WRRND:
+@FSIZE:
+@SETRND:
+@WRZER: LD A,36 ; Random FCBs are 36 bytes long.
+;
+ PUSH DE ; Save pointer to user's FCB.
+ EXX ; Save parameters to BDOS call.
+ POP HL ; HL -> user's FCB.
+ LD C,A
+ LD B,0 ; BC = number of bytes in FCB.
+;
+RW: ; HL->user's FCB, BC=length, '=other params.
+ PUSH HL ; Save it again for after the KBDOS call.
+ PUSH BC ; Save number of bytes in FCB.
+ LD DE,BUFF1 ; Copy to buffer.
+ PUSH DE
+ LDIR
+ EXX ; Get back other parameters.
+ POP DE ; DE -> FCB in page 3.
+ PUSH DE
+ CALL KBDOS
+ EXX ; Save return parameters,
+ POP HL ; HL -> FCB in page 3.
+ POP BC ; Get number of bytes in FCB to copy.
+ POP DE ; Get pointer to user's FCB.
+ LDIR ; Copy FCB back again.
+ EXX ; Get returned values.
+ LD A,L
+ LD B,H
+ RET
+;
+;
+;------------------------------------------------------------------------------
+;
+@WRBLK:
+@RDBLK: PUSH DE ; Save user's FCB pointer for after KBDOS call.
+ EXX ; Save function number and HL.
+ POP HL ; HL -> user's FCB.
+ PUSH HL
+ LD BC,14+1
+ ADD HL,BC ; HL -> high byte of record size.
+ LD C,36
+ LD A,(HL)
+ OR A
+ JR NZ,BLK10 ; Copy 36 bytes if record size >63, else 37.
+;
+ DEC HL
+ LD A,(HL)
+ CP 64
+ JR NC,BLK10
+;
+ INC C
+BLK10: POP HL ; HL -> user's FCB.
+ CALL RW ; Do read/write operation, copy FCB back.
+ EX DE,HL ; Return KBDOS's DE in HL for block functions.
+ RET
+;
+;
+;------------------------------------------------------------------------------
+;
+@GDATE:
+@GTIME:
+@SDATE:
+@STIME: CALL KBDOS
+ LD A,C ; Return day in A.
+ RET
+;
+;
+@DPARM: PUSH DE ; Save buffer pointer.
+ LD DE,BUFF1
+ CALL KBDOS ; Get disk parameters into BUFF1.
+ EX DE,HL ; HL -> disk parameters.
+ POP DE ; DE -> user's buffer.
+ PUSH DE ; Return original DE un-corrupted.
+ LD BC,32
+ LDIR ; Copy disk parameters to user's buffer.
+ POP DE
+ RET
+;
+;
+;
+ SUBTTL BDOS MSX 2 File Functions
+;******************************************************************************
+;
+@FFIRST:
+@FNEW:
+ CALL ?COPYDE ; Copy string or FIB at DE.
+ CALL C,COPYHL ; Copy string at HL if DE -> FIB.
+ RET NZ ; Return if error.
+;
+;
+@FNEXT:
+ PUSH IX
+ POP HL ; HL -> user's FIB.
+ PUSH HL
+ LD DE,BUFF2 ; DE -> buffer for FIB.
+ PUSH BC
+ LD BC,64
+ LDIR ; Copy user's FIB for FNEXT.
+ POP BC
+;
+ CALL _KBDOS
+ POP DE ; DE -> user's FIB space (IX will be returned
+ LD HL,BUFF2 ; pointing here because the BDOS entry code
+ LD BC,64 ; preserves IX).
+ LDIR ; Copy FIB to user's space.
+ RET ; Error from function not corrupted.
+;
+;
+;
+;
+@RENAME:
+@MOVE:
+ CALL COPYHL ; Copy new filename into BUFF3.
+ LD HL,BUFF3 ; Copy string at (DE), HL -> other string.
+;
+@DELETE:
+@ATTR:
+@FTIME:
+@OPEN:
+@CREATE:
+@HTEST: EX AF,AF' ; Save parameter passed in A.
+ PUSH DE ; Save pointer to user's FIB.
+ CALL ?COPYDE ; Copy FIB or string at DE.
+ PUSH AF ; Save FIB/string copied flag (Cy => FIB).
+ EX AF,AF' ; Get back the user's A.
+ CALL _KBSDE ; Sets DE -> string, HL preserved.
+ EX AF,AF' ; Save the error code.
+ EXX ; Save the returned registers.
+ POP AF ; Cy set => FIB copied, must copy back.
+ POP DE ; DE -> user's FIB.
+ JR NC,XRET ; Return with error code if not FIB function.
+;
+ LD HL,BUFF1 ; HL -> Updated FIB.
+ LD BC,64
+ LDIR ; Update user's FIB.
+XRET: EX AF,AF' ; Get back error code.
+ EXX ; Get back the returned registers.
+ RET
+
+
+;
+;
+@HRENAME:
+@HMOVE:
+ EX AF,AF' ; Save parameter passed in A.
+ CALL COPYHL ; Copy new filename into BUFF3.
+ EX AF,AF'
+;
+ ;
+ ;
+ ;
+;
+;------------------------------------------------------------------------------
+;
+; The _KBDOS entry point points the registers at the buffers that FIBs
+; and strings have been copied too, and falls through to KBDOS. This then does
+; the actual calling of the real KBDOS.
+;
+_KBDOS: LD IX,BUFF2 ; IX -> buffer possibly containing FIB.
+ LD HL,BUFF3 ; HL -> buffer possibly containing string.
+_KBSDE: LD DE,BUFF1 ; DE -> buffer containing FIB or string.
+;
+ ;
+ ;
+ ;
+;
+;
+@TERM0:
+@RDABS:
+@WRABS:
+@CLOSE:
+@ENSURE:
+@DUP:
+@READ:
+@WRITE:
+@SEEK:
+@IOCTL:
+@HDELETE:
+@HATTR:
+@HFTIME:
+@GETDTA:
+@GETVFY:
+@CHKCHR:
+@FLUSH:
+@TERM:
+@FORMAT:
+@RAMD:
+@BUFFER:
+@FILES:
+@ASSIGN:
+@ERROR:
+@GENV:
+@SENV:
+@FENV:
+@DSKCHK:
+@REDIR:
+@FOUT:
+@RDDRV:
+@WRDRV:
+@RALLOC:
+@DSPACE:
+@LOCK:
+@Z80MODE:
+
+;
+@BADFN: ; Undefined functions go straight through.
+KBDOS:
+ JP GO_BDOS## ; Call the KBDOS in kernel page-0 and
+ ; return with the KBDOS results.
+;
+;
+;------------------------------------------------------------------------------
+;
+@PARSE: PUSH DE
+ CALL COPYDE ; Copy path string.
+ POP DE
+@GETCD:
+@WPATH:
+ EX DE,HL ; HL -> user's buffer.
+ PUSH HL
+ LD DE,BUFF1 ; KBDOS puts it's string here.
+ OR A
+ SBC HL,DE ; HL = offset from BUFF1 to user's buffer.
+ PUSH HL
+ PUSH DE ; Save BUFF1 address.
+ CALL KBDOS ; Get the string to BUFF1.
+ EXX ; Save the returned registers.
+ POP HL ; BUFF1.
+ POP BC ; Offset to user's buffer.
+ POP DE ; User's buffer.
+ PUSH BC ; Save offset to user's buffer.
+ LD BC,64
+ LDIR ; Copy the string to the user's buffer.
+ EXX
+ EX (SP),HL ; Save returned HL, get offset.
+ EX DE,HL ; DE=offset to user's buffer.
+ ADD HL,DE ; Adjust returned DE.
+ EX (SP),HL ; Save adjusted DE, get returned HL.
+ ADD HL,DE ; Adjust returned HL.
+ POP DE ; Get back adjusted DE.
+ RET ; Return with BC and error code intact.
+;
+;
+@PFILE: PUSH HL ; Save pointer to user's buffer twice.
+ PUSH HL
+ LD L,E ; Save user's string pointer in HL.
+ LD H,D
+ CALL COPYDE ; Copy filename string to BUFF1.
+ LD DE,BUFF1 ; Calculate offset from BUFF1 to user's string.
+ OR A
+ SBC HL,DE
+ EX (SP),HL ; Save offset, get pointer to buffer.
+ PUSH HL ; Save pointer again.
+ CALL _KBDOS ; Get the parsed filename to BUFF3.
+ EXX ; Save the returned registers.
+ POP DE ; Get pointer to user's buffer.
+ LD BC,11 ; 11 bytes in buffer.
+ LD HL,BUFF3 ; Copy the updated filename buffer to the
+ LDIR ; user's buffer.
+ EXX
+ POP HL ; Get offset to user's string, & point pointer
+ ADD HL,DE ; to terminating character there.
+ EX DE,HL
+ POP HL ; Return the original pointer to user's buffer.
+ RET ; Return with BC and error code intact.
+;
+;
+;
+@FORK: LD HL,0 ; Zero returned main and secondary error code.
+ LD (ERROR2),HL
+ JR KBDOS ; Do a KBDOS fork.
+
+;
+;
+@CHDIR:
+ CALL COPYDE ; Copy string to BUFF1.
+ JR _KBSDE
+;
+;
+@JOIN: CALL KBDOS ; Do a KBDOS join.
+ LD BC,(ERROR2) ; B=error code, C=secondary error code.
+ LD HL,0 ; Zero them just in case.
+ LD (ERROR2),HL
+ RET ; With error code from KBDOS.
+;
+;
+@EXPLAIN:
+ PUSH DE ; Save pointer to user's buffer.
+ LD DE,ERRBUF ; Get message to here.
+ CALL KBDOS
+ EX DE,HL ; HL -> message in ERRBUF.
+ POP DE ; DE -> user's buffer.
+ PUSH DE
+ PUSH BC ; Save returned B.
+ LD BC,64 ; Copy all bytes of message buffer back.
+ LDIR
+ POP BC ; Return B as returned from the function.
+ POP DE ; Return DE -> message in user's buffer.
+ RET ; Error code un-corrupted.
+;
+;
+@DEFAB: LD (ABORT_VECT),DE ; Save address of user's abort
+ XOR A ; routine.
+;
+ LD HL,GO_REBOOT
+ LD (BRK_ERRV),HL ; Cancel any setting of MSX-DOS 1.0
+ LD HL,BRK_ERRV ; compatible control-C handler.
+ LD (BREAKVECT##),HL
+;
+ RET ; Return with no error.
+;
+;
+@DEFER: LD (DISK_VECT),DE ; Save address of user's disk error
+ XOR A ; routine.
+;
+ LD HL,DSK_ERR
+ LD (DSK_ERRV),HL ; Cancel any setting MSX-DOS 1.0
+ LD HL,DSK_ERRV ; compatible disk-error handler.
+ LD (DISKVECT##),HL
+;
+ RET ; Return with no error.
+;
+;
+;@DOSVER:CALL KBDOS ; Get KBDOS version number.
+; LD D,VERSION## ; Return MSX-DOS.SYS version too.
+; LD E,RELEASE##+(RELEASE##/256)*16
+; RET
+
+@GDRVR:
+@GDLI:
+@GETCLUS:
+ push hl
+ LD HL,BUFF3
+ call GO_BDOS##
+ pop hl
+ or a
+ ret nz
+ push hl
+ ex de,hl
+ ld hl,BUFF3
+ ld bc,64
+ ldir
+ pop hl
+ ret
+
+@CDRVR:
+ push de
+ push bc
+ ld de,BUFF3
+ ld bc,8
+ ldir
+ pop bc
+ pop de
+ ld hl,BUFF3
+
+ EXX
+ POP HL ; Get return address, and pop off the saved
+ POP DE ; values of IX and IY.
+ POP DE
+ PUSH HL
+ EXX
+ push iy
+ CALL KBDOS ; Call KBDOS, which returns stuff in IY & IX.
+ pop iy
+ EXX ; Save returned values.
+ POP HL ; Get the return address again.
+ PUSH IX ; Push new 'saved' IX and IY values.
+ PUSH IY
+ PUSH HL
+ EXX
+ ret
+
+@MAPDRV:
+ push de
+ push bc
+ ld de,BUFF3
+ ld bc,64
+ ldir
+ pop bc
+ pop de
+ ld hl,BUFF3
+ jp KBDOS
+;
+;
+;------------------------------------------------------------------------------
+;
+; These miscellaneous routines do various copying operations needed by
+; the MSX-DOS 2 functions.
+;
+; ?COPYDE copies either a FIB or a string at DE to BUFF1. If a string, then a
+; check is made that the string is not too long, and an error is returned if
+; it is. If a FIB is copied, then an error code is not returned but the carry
+; is returned set.
+;
+; COPYDE always copies a FIB to BUFF1 from DE, and returns with the carry set
+; as described above.
+;
+; COPYHL always copies a string from HL to BUFF3 and returns an error code.
+;
+?COPYDE: ; Copies string or FIB at DE to BUFF1.
+ LD A,(DE) ; FIB?
+ INC A
+ JR NZ,CDE10 ; Copy a string if not.
+;
+COPYDE: PUSH HL
+ PUSH BC
+ EX DE,HL ; HL -> FIB/string.
+ LD DE,BUFF1
+ LD BC,64
+ LDIR
+ POP BC ; Restore BC and HL.
+ POP HL
+ SCF ; Cy set => FIB copied (not string).
+ RET
+;
+CDE10: PUSH HL ; Save HL.
+ PUSH BC
+ EX DE,HL ; HL -> string.
+ LD DE,BUFF1 ; Copy string to here.
+ LD B,LEN1
+ CALL STRCPY
+ POP BC
+ POP HL
+ RET
+;
+;
+COPYHL: ; Copies the string at HL to BUFF3.
+ PUSH DE
+ PUSH BC
+ LD DE,BUFF3
+ LD B,LEN3
+ CALL STRCPY
+ POP BC
+ POP DE
+ RET
+;
+;
+STRCPY: LD A,(HL) ; Get character from string.
+ INC HL
+ LD (DE),A ; Copy into buffer.
+ INC DE
+ OR A
+ RET Z ; Return with no error & NC if end of string.
+;
+ DJNZ STRCPY ; Else copy up to 64 bytes.
+ LD A,.PLONG## ; String too long if null not encountered.
+ RET ; Still NC.
+;
+;
+;
+ SUBTTL Abort Routine
+;******************************************************************************
+;
+; This is MSX-DOS.SYS's abort routine, which calls the user's abort
+; routine and then aborts the program by jumping to 0 if it returns or is not
+; defined.
+;
+; In order to call the user's routine, the original BDOS call is
+; returned from, but the 'RET' at the end is patched to a NOP so that it drops
+; through into the code to call the user's routine. This ensures that the
+; user's routine is entered in a state where the user does not have to return
+; (ie. on the user's stack and with the alternate register set preserved etc.)
+;
+ABORT: PUSH AF ; Save error code.
+ LD A,(ENTERS) ; In a BDOS call?
+ INC A
+ JR Z,ABIOS ; Go if not (BIOS call).
+;
+ XOR A ; Patch out the 'RET' instruction in the BDOS
+ LD (RETPAT),A ; return code to call user abort routine.
+ LD (ENTERS),A ; Switch back to user's stack on return.
+ POP AF ; Get back error code.
+ JP BDOS_RET
+;
+;
+ABIOS: POP AF ; Get back error code.
+ LD SP,(BIOS_SP) ; Jump to user's abort routine on his BIOS
+ JP JP_ABORT ; stack.
+;
+;
+;
+ SUBTTL Disk Error Handler
+;******************************************************************************
+;
+; This is the disk error handler routine, which is always defined as
+; long as MSX-DOS.SYS is running. It is patched into the disk error vector at
+; startup and is the routine that normally prints out 'Abort, Retry' type
+; messages when a low-level disk error occurs.
+;
+; The transient program can define it's own disk error routine by a
+; BDOS call that is handled by MSX-DOS.SYS (not KBDOS). Thus it is this
+; routines job also to call the user's routine.
+;
+; On entry from KBDOS, A=error code.
+; B=logical drive number.
+; C=flags: b0 => read/write error.
+; b1 => ignore OK/ ignore dangerous.
+; b2 => normal/auto-abort error (eg. .IFAT)
+; b3 => sector number in DE is valid.
+; DE=logical sector number or error (if bit 3,C=1).
+;
+; On return to KBDOS, A=1, 2 or 3 for Abort, Retry, Ignore (any other aborts).
+; Any registers (including alternates) may be corrupted.
+; On entry to the user's routine, The registers are set up as above.
+; On return from the user's routine, the registers are set up as above with
+; the addition that A=0 => use the default error handling.
+;
+;
+DISK_ERROR:
+ PUSH AF ; Save error on SP for user's
+ EX AF,AF' ; routine.
+ PUSH AF
+ PUSH BC ; Save drive in B, flags in C.
+ LD HL,(DISK_VECT) ; Get user's error routine address.
+ LD A,H
+ OR L ; Defined?
+ CALL NZ,JP_USERS ; Go if yes (restores error code first).
+ POP BC ; Restore saved drive and flags in BC.
+ EX AF,AF'
+ POP AF ; Restore saved old error code in A'.
+ EX AF,AF'
+ POP HL ; Restore error code in H.
+ OR A ; User's routine defined & returned a result?
+ RET NZ ; Return it to KBDOS if yes.
+;
+; Pass control through old DISKVECT interface.
+;
+; Entry: A' = Old error code (passed to DISKVECT in C)
+; H = New error code (passed to DISKVECT in A')
+; B = Drive number (decremented & passed to DISKVECT in A)
+; C = New Flags (passed to DISKVECT in B)
+; DE = Sector number (passed to DISKVECT in DE)
+;
+ LD A,H
+ EX AF,AF' ;A':= new error code
+ PUSH BC ;Save drive number for routine
+ LD B,C ;B := flags
+ LD C,A ;C := MSX-DOS 1.0 error flag
+;
+ LD HL,(DISKVECT##)
+ LD A,(HL) ;Get the address of the user's
+ INC HL ; disk error handler routine.
+ LD H,(HL)
+ LD L,A
+;
+ POP AF ;Get drive number back
+ DEC A ;A := drive number (0=>A: etc)
+;
+ CALL JPHL ;Call the user's disk error handler.
+;
+ LD A,3 ;Translate the action code
+ SUB C ; for the KBDOS values.
+ RET
+;
+;
+;------------------------------------------------------------------------------
+;
+; Entry: A = Drive number (0=A:,1=B: etc)
+; C = Old error code
+; A' = New error code
+; B = New Flags - b0 set => writing
+; b1 set => ignore not recommended
+; b2 set => auto-abort error
+; b3 set => sector number is valid
+; DE = Sector number
+;
+; Results: C = 0 => Ignore
+; 1 => Retry
+; 2 => Abort
+;
+DSK_ERR:
+ LD C,B ; Set flags
+ INC A
+ LD B,A ; Set drive number
+ PUSH BC ; Save drive and flags.
+ EX AF,AF'
+ LD B,A ; B=error number.
+ EX AF,AF'
+ LD DE,ERRBUF ; Point to buffer for error message.
+ LD C,_EXPLAIN## ; Function number.
+ CALL BDOS ; Get error message.
+ CALL CRLF ; Print new line and error message.
+ PUSH DE
+ LD A,__PRERR## ; Print a message first (null in English).
+ CALL DMSG
+ POP DE
+ CALL DSTR ; Print actual error message.
+ POP BC ; Get back flags.
+;
+ LD A,__READING## ; In case reading.
+ BIT 0,C
+ JR Z,RDERR ; Go if reading.
+;
+ LD A,__WRITING## ; Else writing.
+RDERR: PUSH BC ; Save drive and flags again.
+ CALL DMSG ; Print 'reading' or 'writing' message.
+ LD A,__DRIVE## ; Print 'drive'.
+ CALL DMSG
+ POP BC ; Get drive.
+ LD A,B
+ ADD A,'A'-1 ; Convert to upper case letter and print it.
+ CALL OUTCH
+ LD A,__ARIDRV## ; Print message after drive (':' in English).
+ CALL DMSG
+;
+ CALL CRLF
+ BIT 2,C ; If an 'auto abort' error (eg. .IFAT) then
+ LD L,1 ; return A=1 for Abort without giving an
+ JR NZ,DERRET ; Abort, Retry prompt.
+;
+ERRLOOP:LD A,__AR## ; Assume 'Abort, Retry' message.
+ BIT 1,C
+ JR NZ,ABRET ; Go if ignore not recommended.
+;
+ LD A,__ARI## ; Else include ignore option.
+ABRET: CALL DMSG ; Print message, flags in C preserved.
+ CALL INCH ; Get a keypress in H.
+ LD L,0 ; L=0 initially => abort.
+ LD A,__ABORT##
+ CALL ARITEST ; Test for abort character.
+ LD A,__RETRY##
+ CALL NC,ARITEST ; Test for retry character.
+ LD A,__IGNORE##
+ CALL NC,ARITEST ; Test for ignore character.
+ JR NC,ERRLOOP ; If invalid character, then re-print message.
+;
+DERRET: LD A,3
+ SUB L
+ LD C,A ; Return with the MSX-DOS1 response in C.
+ RET
+;
+JP_USERS:
+ EX AF,AF' ; Restore error code.
+JPHL: JP (HL) ; Jump to user's disk error routine.
+;
+;
+;
+;
+; This little subroutine takes a message number in A and tests to see if the
+; character in H is in the appropriate string. This is used to test to see if
+; the character in H is an appropriate one for Abort, retry or Ignore.
+;
+; B, DE and AF are corrupted, and the carry is set on return if the character
+; was in the string. Also L is returned incremented (this is the code returned
+; to the KBDOS).
+;
+ARITEST:
+ INC L ; Return with L incremented.
+ CALL MESSAGE ; DE -> string containing valid characters.
+ARIT10: LD A,(DE)
+ OR A
+ RET Z ; Return with C clear if end of string.
+;
+ INC DE
+ CP H ; Character in string.
+ JR NZ,ARIT10 ; Compare with next if not.
+ SCF ; Else return with carry set.
+ RET
+;
+;
+;
+ SUBTTL I/O Routines
+;******************************************************************************
+;
+; DERR below takes an error number in B and prints the appropriate
+; error message, without a CR,LF on the end. DERRM is similar, but on entry DE
+; already points to the message.
+;
+; DERRM may be called whilst the normal BDOS routine is not yes
+; callable, and so it must only call OUTCH which in this case goes through
+; F37D. DERR is OK since the BDOS is set up properly when it is called.
+;
+;
+DERR: LD DE,ERRBUF ; Point DE to buffer for message.
+ LD C,_EXPLAIN## ; C=function code to get error message.
+ CALL BDOS ; Attempt to get a message for the error.
+;
+DERRM: PUSH DE ; Save message pointer.
+ CALL CRLF
+ LD A,__SPLATS##
+ CALL DMSG ; Print '***' before message.
+ POP DE
+ CALL DSTR ; Print actual message.
+ LD A,__EREND## ; Print a string after message.
+ ;
+ ;
+ ;
+;
+; DMSG below takes a message number in A and prints the appropriate
+; message. DSTR prints the 0 terminated string at (DE).
+;
+;
+DMSG: CALL MESSAGE ; Point DE at message whose code is in A.
+;
+DSTR: LD A,(DE) ; Get character from message.
+ INC DE
+ OR A
+ RET Z ; Return if end of string.
+;
+ CALL OUTCH ; Print character.
+ JR DSTR
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+; This routine takes a message number in A and returns DE pointing to
+; the message, which is terminated by a 0. B and A are corrupted.
+;
+;
+MESSAGE:LD B,A ; B=message number.
+ifdef NO_J_MSG
+ LD DE,MESSAGES+2 ; Point DE to messages table.
+else
+ xor a
+ ld de,1100h ; See if Kanji driver is active.
+ call 0FFCAh ; FCALL
+ LD DE,MESSAGES+2 ; Point DE to messages table.
+ or a
+ jr z,ank_msg
+ ld a,(MFLAGS)
+ and 8
+ jr nz,ank_msg
+ push hl
+ ex de,hl
+ dec hl
+ ld d,(hl)
+ dec hl
+ ld e,(hl)
+ add hl,de
+ ex de,hl
+ pop hl
+ank_msg:
+endif
+ INC B ; For first time round.
+;
+GMSG10: DEC B ; Message found?
+ RET Z ; Return with DE pointing to message if yes.
+;
+GMSG20: LD A,(DE)
+ INC DE ; Else find end of message.
+ OR A
+ JR Z,GMSG10 ; Test again with DE -> next message.
+;
+ JR GMSG20
+;
+;
+;
+;------------------------------------------------------------------------------
+;
+; INCH waits for a key to be pressed, and returns it's ASCII value in
+; A, without corrupting BC. It first gobbles up any characters that are
+; waiting to be read (ie. flushes the keyboard buffer) before reading a
+; keypress. It is called when prompting for the insertion of the COMMAND.COM
+; disk and for Abort, Retry disk error prompting.
+;
+;
+INCH: PUSH BC
+;
+IN10: LD C,_CONST## ; See if a key has already been pressed.
+ CALL BDOS
+ PUSH AF
+;
+ LD C,_INNOE## ; Get a keypress anyway.
+ CALL BDOS
+ LD H,A ; Return it in H.
+;
+ POP AF ; If a character was ready then read another
+ JR NZ,IN10 ; (this flushes the keyboard buffer)
+;
+ LD A,H
+ CP ' ' ; Echo it if a printing character.
+ CALL NC,OUTCH
+ POP BC ; End with a CRLF.
+;
+ ;
+ ;
+ ;
+;
+;
+;------------------------------------------------------------------------------
+;
+; OUTCH takes a character in A and prints it, corrupting only A. CRLF
+; prints a carriage return followed by a line feed. Guess what SPACE does.
+;
+;
+;
+CRLF: LD A,CR ; Output a CR followed by an LF.
+ CALL OUTCH
+ LD A,LF
+ JR OUTCH
+;
+SPACE: LD A,' '
+;
+OUTCH: PUSH HL
+ PUSH DE
+ PUSH BC
+ LD E,A
+ LD C,_CONOUT##
+ CODE CALL ; This CALL either points to F37D (initially)
+OVEC: DEFW P3BDOS ; or to the normal BDOS entry.
+ POP BC
+ POP DE
+ POP HL
+ RET
+;
+;
+;
+ SUBTTL Variables
+;******************************************************************************
+;
+; The variable declarations for MSX-DOS.SYS are here. They are not
+; defined using DEFBs etc. so that they do not form part of the MSX-DOS.SYS
+; file, making it considerably smaller, especially considering the fact that
+; two copies of this file are linked.
+;
+; The variables live in the gap that exists between the BIOS jump table and
+; the BDOS entry jump. The BIOS jump table is defined at the start of this
+; module and the BDOS jump is created at initialization time.
+;
+;
+VAR MACRO NAME, SIZE
+OFF DEFL OFF-(SIZE) ; New offset from BIOS jump table.
+NAME EQU BIOS_TAB+OFF ; Variable defined as offset from BIOS table.
+ ENDM
+;
+OFF DEFL 0 ; Offset of current variable from BIOS table.
+;
+PRINT MACRO SIZE, TEXT
+ IF1
+ .PRINTX % SIZE TEXT
+ ENDIF
+ ENDM
+;
+;
+ VAR BIOS_STACK,0
+ VAR YYY, 128 ; BIOS stack.
+;
+LEN1 EQU 100 ; Length of buffer 1 (must be >63).
+LEN3 EQU 100 ; Length of buffer 3 (must be >63).
+ VAR BUFF3, LEN3 ; Copy buffer for strings at (HL).
+ VAR BUFF2, 64 ; Copy buffer for FIBs at (IX).
+ VAR BUFF1, LEN1 ; Copy buffer for strings/FIBs at (DE).
+ VAR ERRBUF, 64 ; Buffer for error messages.
+;
+ VAR SERNO, 4 ; Copy of MSX-DOS.SYS serial number.
+;
+ VAR ENTERS, 1 ; BDOS re-entrancy count, -1 => not in BDOS.
+ VAR BDOS_SP, 2 ; BDOS SP save for stack switching.
+ VAR BIOS_SP, 2 ; BIOS SP save for stack switching.
+;
+ VAR DISK_VECT, 2 ; User's disk error routine address.
+;
+ VAR ERROR, 1 ; Main error code. These two must be
+ VAR ERROR2, 1 ; Secondary error code. in this order
+;
+;
+ VAR BDOS_STUFF, 9+2+2
+ ; Error vectors + BDOS entries
+;
+VARP EQU (0-OFF+0FFH)/256; Number of 256 byte pages used by variables.
+;
+;
+ PRINT %VARP, ; No. pages used.
+ PRINT %(VARP*256-(0-OFF)), ; No. unused bytes.
+;
+;
+ IF TEST
+JBDOS EQU 0C100H ; BDOS entry jump goes here to avoid MZED.
+ ELSE
+JBDOS EQU BIOS_TAB-256*VARP ; Destination address of BDOS JP at 5.
+DSK_ERRV EQU JBDOS+9
+BRK_ERRV EQU JBDOS+11
+ ENDIF
+;
+;
+SIZE EQU $-START
+ IF LOW (256-LOW SIZE)
+ DEFS 256-LOW SIZE,0 ; Pad out to page boundary.
+ ENDIF
+;
+ PRINT %SIZE, ; No. bytes for code.
+;
+MESSAGES: ; Start of messages when linked.
+;
+;
+;
+ SUBTTL
+ END
diff --git a/source/command/msxdos/ver.mac b/source/command/msxdos/ver.mac
index d71b1d7f..e19faec7 100644
--- a/source/command/msxdos/ver.mac
+++ b/source/command/msxdos/ver.mac
@@ -1,3 +1,4 @@
+ name('ver')
TITLE MSX-DOS 2 - MSX-DOS.SYS copyright (1986) IS Systems Ltd.
SUBTTL Version number
;
diff --git a/source/command/msxdos/yeskmsg.mac b/source/command/msxdos/yeskmsg.mac
deleted file mode 100644
index 30719753..00000000
--- a/source/command/msxdos/yeskmsg.mac
+++ /dev/null
@@ -1 +0,0 @@
-NOKMSG equ 0
diff --git a/source/command/undel/const.inc b/source/command/undel/const.inc
index b692f1f8..20ec2cb8 100644
--- a/source/command/undel/const.inc
+++ b/source/command/undel/const.inc
@@ -85,17 +85,17 @@ CF_TE EQU 4 ;Set => filename terminator character
; ====================
;
FIB_FILNAME EQU 1 ;ASCII version of filename.
-FIB_ATTR EQU 14 ;Attributes byte.
-FIB_TIME EQU 15
-FIB_DATE EQU 17
-FIB_CLUSTER EQU 19 ;Start cluster.
-FIB_SIZE EQU 21 ;File size.
+FIB_ATTRIBUTES EQU 14 ;Attributes byte.
+FIB_MODIFIED_TIME EQU 15
+FIB_MODIFIED_DATE EQU 17
+FIB_START_CLUSTER EQU 19 ;Start cluster.
+FIB_FILE_SIZE EQU 21 ;File size.
FIB_DRIVE EQU 25 ;Drive number.
FIB_VOL_ID EQU 26 ;Volume ID.
FIB_DEV EQU 30 ;Device number.
-FIB_SA EQU 31 ;Search attributes.
-FIB_PAT EQU 32 ;Extended pattern filename (FCB form).
-FIB_DVAR EQU 43 ;Directory variables.
+FIB_SEARCH_ATTRIBUTES EQU 31 ;Search attributes.
+FIB_EXPANDED_SEARCH_PATTERN EQU 32 ;Extended pattern filename (FCB form).
+FIB_DIRECTORY_VARIABLES EQU 43 ;Directory variables.
;
D_START EQU 10 ;Start of directory information.
D_CLUSTER EQU 8
@@ -113,11 +113,11 @@ D_ODD EQU 0
;
DR_FILE equ 0 ;Filename
DR_EXT equ 8 ;Filename extension
-DR_ATTR equ 11 ;Attributes byte
-DR_DCHAR equ 12 ;Deleted filename character
-DR_TIME equ 22 ;Time of last update
+DR_ATTRIBUTES equ 11 ;Attributes byte
+DR_DELETED_FIRST_CHAR equ 12 ;Deleted filename character
+DR_UPDATED_TIME equ 22 ;Time of last update
DR_DATE equ 24 ;Date of last update
-DR_CLU equ 26 ;Fisrt cluster number
+DR_FIRST_CLUSTER equ 26 ;Fisrt cluster number
DR_SIZE equ 28 ;File size
;
;
diff --git a/source/command/undel/main.mac b/source/command/undel/main.mac
index fc692e4b..e1d91b6a 100644
--- a/source/command/undel/main.mac
+++ b/source/command/undel/main.mac
@@ -168,13 +168,13 @@ not_null_fname:
pop bc
jr nz,first_err ;Skip if any error.
;
- BIT AT_DEV,(IX+FIB_ATTR) ;Check if it is actually a
+ BIT AT_DEV,(IX+FIB_ATTRIBUTES) ;Check if it is actually a
LD A,.NOFIL## ; device, and give error if so.
JP NZ,EXIT
;
bit PF_AMB,b
jr nz,first_ok ;Jump if search was ambiguous
- BIT AT_DIR,(IX+FIB_ATTR) ;What have we found ??
+ BIT AT_DIR,(IX+FIB_ATTRIBUTES) ;What have we found ??
jr z,first_ok ;Jump if not a sub-directory
;
LD HL,FIB## ;Pretend FIB is the path.
@@ -541,7 +541,7 @@ SCAN_DIR:
ld hl,(FILE_LIST##) ;Initialise file list to
ld (hl),0 ; be empty.
;
- ld hl,(FIB##+FIB_DVAR+D_START)
+ ld hl,(FIB##+FIB_DIRECTORY_VARIABLES+D_START)
;Initialise a search of the
ld (DIR_START##),hl ; required directory.
;
@@ -583,7 +583,7 @@ CHECK_ENTRY:
; follows: 1. Must be a deleted entry (first byte 0E5h). 2. Must not be a
; volume name or sub-directory entry. 3. The name must not contain any
; invalid filename characters after the first chracater is restored from
-; DR_DCHAR. 4. The cluster number field must contain a valid cluster number.
+; DR_DELETED_FIRST_CHAR. 4. The cluster number field must contain a valid cluster number.
; 5. The cluster referred to must be the start of an "undeletable" file chain
;
; If all of these points are satisfied then the entry is a candidate for
@@ -619,7 +619,7 @@ uncase_loop: ld a,(hl)
djnz uncase_loop
;
ld de,ENT_BUF## ;Compare the filename in the
- ld hl,FIB+FIB_PAT ; entry with the one we
+ ld hl,FIB+FIB_EXPANDED_SEARCH_PATTERN ; entry with the one we
call CMP_FNAME## ; are looking for and return
ret nz ; if no match.
;
@@ -681,7 +681,7 @@ NAME_CHK:
; any candidate files in the list which exactly match the name from disk.
;
;
- ld hl,(FIB##+FIB_DVAR+D_START)
+ ld hl,(FIB##+FIB_DIRECTORY_VARIABLES+D_START)
ld (DIR_START##),hl ;Initialise a search of the
; required directory.
;
@@ -775,7 +775,7 @@ clu_chk_loop: ld a,(hl) ;Look at next item in list and
;
;
push hl
- ld de,1+DR_CLU ;Get the cluster number from
+ ld de,1+DR_FIRST_CLUSTER ;Get the cluster number from
add hl,de ; out of this item and store
ld e,(hl) ; it at CC_CLUSTER so we can
inc hl ; look for same cluster
@@ -809,7 +809,7 @@ cc_loop2: ld bc,1+32+SV_SIZE## ;Step onto next item in list
jr z,cc_loop2_done
;
push hl
- ld bc,1+DR_CLU ;Get the cluster number from
+ ld bc,1+DR_FIRST_CLUSTER ;Get the cluster number from
add hl,bc ; this item compare with
ld c,(hl) ; the cluster number for this
inc hl ; iteration of the main loop.
@@ -935,7 +935,7 @@ EXAMINE_ENTRY:
;
set 0,(hl) ;Flag item has been examined
push hl ;Must preserve item pointer
- ld de,1+DR_ATTR
+ ld de,1+DR_ATTRIBUTES
add hl,de
bit AT_DIR,(hl) ;Look at attributes and
jr z,examine_file ; skip if it is a file.
@@ -950,7 +950,7 @@ EXAMINE_ENTRY:
;
;
examine_file: ld (hl),ATM_ARC ;FILE - set default attributes
- ld de,DR_SIZE-DR_ATTR
+ ld de,DR_SIZE-DR_ATTRIBUTES
add hl,de
push hl
ld e,(hl) ;Get file size from the item
@@ -1052,7 +1052,7 @@ CHECK_DIR:
call DRE_NEXT## ;Similarly check that the 2nd
jr nz,invalid_dir ; entry is present & cluster
ld de,dot_dot_name ; no. of main search dir.
- ld bc,(FIB##+FIB_DVAR+D_START)
+ ld bc,(FIB##+FIB_DIRECTORY_VARIABLES+D_START)
call CHECK_DOT_DIR
jr nz,invalid_dir ;Reject if not.
;
@@ -1112,7 +1112,7 @@ dot_fail_nz_1: pop bc ; failure.
ld bc,0 ; this is what is in entry.
not_root_clu:
;
- ld de,DR_CLU-DR_ATTR ;Get cluster number from
+ ld de,DR_FIRST_CLUSTER-DR_ATTRIBUTES ;Get cluster number from
add hl,de ; directory entry and compare
ld e,(hl) ; it with the one passed in BC.
inc hl
@@ -1215,7 +1215,7 @@ dont_rename: ex de,hl
;
pop hl
push hl ;Get start cluster number
- ld bc,1+DR_CLU ; from the item.
+ ld bc,1+DR_FIRST_CLUSTER ; from the item.
add hl,bc
ld e,(hl)
inc hl
@@ -1280,7 +1280,7 @@ undel_inc_loop: inc (hl) ; in the undelete filename
dec hl
jr undel_inc_loop
;
-rename_check: ld hl,(FIB##+FIB_DVAR+D_START)
+rename_check: ld hl,(FIB##+FIB_DIRECTORY_VARIABLES+D_START)
ld (DIR_START##),hl ;Initialise a search of the
; directory.
;
diff --git a/source/kernel/CPM32.EXE b/source/kernel/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/L80.CPM b/source/kernel/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/L80.CPM and /dev/null differ
diff --git a/source/kernel/LIB80.CPM b/source/kernel/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/M80.CPM b/source/kernel/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/M80.CPM and /dev/null differ
diff --git a/source/kernel/Makefile b/source/kernel/Makefile
index c91fdd63..7221205a 100644
--- a/source/kernel/Makefile
+++ b/source/kernel/Makefile
@@ -4,28 +4,57 @@
# See the "all" main rule for some handy aliases to generate specific ROMs
# (e.g. you can run "make base" or "make ide").
+# The N80 and LK80 binaries to use can be overriden with environment variables, e.g.:
+# N80=/path/to/N80 make
+
+
VERSION := 2.1.1
-export X80_COMMAND_LINE=-t -nb
-export M80_COMMAND_LINE=-8
+ifeq ($(strip $(N80)),)
+N80=N80
+endif
+
+export N80_ARGS=--no-string-escapes --no-show-banner --build-type rel --verbosity 0 --output-file-case lower
+
+ifeq ($(strip $(LK80)),)
+LK80=LK80
+endif
+
+export LK80_ARGS=--no-show-banner --verbosity 0 --output-file-case lower --output-format bin
+
+ifeq ($(strip $(LB80)),)
+LB80=LB80
+endif
+
+export LB80_ARGS=--no-show-banner --verbosity 0
define SymToEqus
$(eval REGEX:=([0-9A-F]{4}) ($(3)))
cat $(1) | grep -Eo "$(REGEX)" | sed -r "s/$(REGEX)/\2 equ \1h\n\tpublic \2\n/g" > $(2)
endef
-define hex2bin_full
- objcopy -I ihex -O binary $(1) $(2)
-endef
-
define hex2bin
- $(call hex2bin_full,$(1).HEX,$(1).BIN)
+ objcopy -I ihex -O binary $(1) $(2)
endef
define copy_to_bin
cp $(1) ../../bin/kernels/$(2)
endef
+define assemble
+ @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1)
+ @$(N80) $(1) $$ $(2)
+endef
+
+define assemble_as
+ @printf "\n\033[0;36mAssembling %s as %s\033[0m\n\n" $(1) $(2)
+ @$(N80) $(1) $(2) $(3)
+endef
+
+define print_linking
+ @printf "\n\033[0;36mLinking %s\033[0m\n\n" $(1)
+endef
+
###################
### MAIN RULE ###
@@ -33,7 +62,7 @@ endef
all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm
-TOOLS := M80 L80 LIB80 objcopy sdcc mknexrom dd
+TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc mknexrom dd
.phony: prerequisites
@@ -44,6 +73,7 @@ prerequisites:
-include prerequisites
+
#################################
### RULES FOR THE ROM FILES ###
#################################
@@ -62,16 +92,16 @@ ide: drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.ROM
drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.ROM: \
nextor_base.dat \
- drivers/SunriseIDE/sunride.BIN \
- drivers/SunriseIDE/CHGBNK.BIN
+ drivers/SunriseIDE/sunride.bin \
+ drivers/SunriseIDE/chgbnk.bin
- mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.BIN /m:drivers/SunriseIDE/CHGBNK.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.bin /m:drivers/SunriseIDE/chgbnk.bin
$(call copy_to_bin,$@)
-drivers/SunriseIDE/sunride.BIN: \
+drivers/SunriseIDE/sunride.bin: \
drivers/SunriseIDE/sunride.asm
- sjasm -c drivers/SunriseIDE/sunride.asm drivers/SunriseIDE/sunride.BIN
+ $(call assemble,drivers/SunriseIDE/sunride.asm,--build-type abs --output-file-extension bin --define-symbols BAD_POPS)
### Sunrise IDE, normal ROM, master device only
@@ -80,18 +110,16 @@ ide-masteronly: drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.MasterOnly.ROM
drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.MasterOnly.ROM: \
nextor_base.dat \
- drivers/SunriseIDE/sunride.masteronly.BIN \
- drivers/SunriseIDE/CHGBNK.BIN
+ drivers/SunriseIDE/sunride.masteronly.bin \
+ drivers/SunriseIDE/chgbnk.bin
- mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.masteronly.BIN /m:drivers/SunriseIDE/CHGBNK.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/sunride.masteronly.bin /m:drivers/SunriseIDE/chgbnk.bin
$(call copy_to_bin,$@)
-drivers/SunriseIDE/sunride.masteronly.BIN: \
+drivers/SunriseIDE/sunride.masteronly.bin: \
drivers/SunriseIDE/sunride.asm
- sed 's/MASTER_ONLY equ 0/MASTER_ONLY equ 1/g' drivers/SunriseIDE/sunride.asm > drivers/SunriseIDE/sunride.masteronly.asm
-
- sjasm -c drivers/SunriseIDE/sunride.masteronly.asm drivers/SunriseIDE/sunride.masteronly.BIN
+ $(call assemble_as,drivers/SunriseIDE/sunride.asm,$$/sunride.masteronly.bin,--build-type abs --output-file-extension bin --define-symbols MASTER_ONLY,BAD_POPS)
### Sunrise IDE, ROM for emulators
@@ -100,20 +128,18 @@ ide-emu: drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.emulators.ROM
drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.emulators.ROM: \
nextor_base.dat \
- drivers/SunriseIDE/DRIVER.BIN \
- drivers/SunriseIDE/CHGBNK.BIN \
+ drivers/SunriseIDE/driver.bin \
+ drivers/SunriseIDE/chgbnk.bin \
256.bytes
- cat 256.bytes drivers/SunriseIDE/DRIVER.BIN > drivers/SunriseIDE/_driver.BIN
- mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/CHGBNK.BIN
+ cat 256.bytes drivers/SunriseIDE/driver.bin > drivers/SunriseIDE/_driver.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/chgbnk.bin
$(call copy_to_bin,$@)
-drivers/SunriseIDE/DRIVER.BIN: \
+drivers/SunriseIDE/driver.bin: \
drivers/SunriseIDE/driver.mac
- M80 -w drivers/SunriseIDE -p ../.. =DRIVER
- L80 -w drivers/SunriseIDE -p ../../ /P:4100,DRIVER,DRIVER/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
+ $(call assemble,drivers/SunriseIDE/driver.mac,--build-type abs --output-file-extension bin)
### Sunrise IDE, ROM for emulators, master device only
@@ -122,32 +148,26 @@ ide-masteronly-emu: drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.MasterOnly.e
drivers/SunriseIDE/Nextor-$(VERSION).SunriseIDE.MasterOnly.emulators.ROM: \
nextor_base.dat \
- drivers/SunriseIDE/DRVMONLY.BIN \
- drivers/SunriseIDE/CHGBNK.BIN \
+ drivers/SunriseIDE/drvmonly.bin \
+ drivers/SunriseIDE/chgbnk.bin \
256.bytes
- cat 256.bytes drivers/SunriseIDE/DRVMONLY.BIN > drivers/SunriseIDE/_driver.BIN
- mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/CHGBNK.BIN
+ cat 256.bytes drivers/SunriseIDE/drvmonly.bin > drivers/SunriseIDE/_driver.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/SunriseIDE/_driver.BIN /m:drivers/SunriseIDE/chgbnk.bin
$(call copy_to_bin,$@)
-drivers/SunriseIDE/DRVMONLY.BIN: \
+drivers/SunriseIDE/drvmonly.bin: \
drivers/SunriseIDE/driver.mac
- sed 's/MASTER_ONLY equ 0/MASTER_ONLY equ 1/g' drivers/SunriseIDE/driver.mac > drivers/SunriseIDE/drvmonly.mac
-
- M80 -w drivers/SunriseIDE -p ../.. =DRVMONLY
- L80 -w drivers/SunriseIDE -p ../../ /P:4100,DRVMONLY,DRVMONLY/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
+ $(call assemble_as,drivers/SunriseIDE/driver.mac,$$/drvmonly.bin,--build-type abs --output-file-extension bin --define-symbols MASTER_ONLY)
### Sunrise IDE, common rules
-drivers/SunriseIDE/CHGBNK.BIN: \
+drivers/SunriseIDE/chgbnk.bin: \
drivers/SunriseIDE/chgbnk.mac
- M80 -w drivers/SunriseIDE -p ../.. =CHGBNK
- L80 -w drivers/SunriseIDE /P:7fd0,CHGBNK,CHGBNK/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
+ $(call assemble,drivers/SunriseIDE/chgbnk.mac,--build-type abs --output-file-extension bin)
### Standalone ASCII8
@@ -156,27 +176,23 @@ ascii8: drivers/StandaloneASCII8/Nextor-$(VERSION).StandaloneASCII8.ROM
drivers/StandaloneASCII8/Nextor-$(VERSION).StandaloneASCII8.ROM: \
nextor_base.dat \
- drivers/StandaloneASCII8/DRIVER.BIN \
- drivers/StandaloneASCII8/CHGBNK.BIN \
+ drivers/StandaloneASCII8/driver.bin \
+ drivers/StandaloneASCII8/chgbnk.bin \
256.bytes
- cat 256.bytes drivers/StandaloneASCII8/DRIVER.BIN > drivers/StandaloneASCII8/_driver.BIN
- mknexrom nextor_base.dat $@ /d:drivers/StandaloneASCII8/_driver.BIN /m:drivers/StandaloneASCII8/CHGBNK.BIN
+ cat 256.bytes drivers/StandaloneASCII8/driver.bin > drivers/StandaloneASCII8/_driver.bin
+ mknexrom nextor_base.dat $@ /d:drivers/StandaloneASCII8/_driver.bin /m:drivers/StandaloneASCII8/chgbnk.bin
$(call copy_to_bin,$@)
-drivers/StandaloneASCII8/DRIVER.BIN: \
+drivers/StandaloneASCII8/driver.bin: \
drivers/StandaloneASCII8/driver.mac
- M80 -w drivers/StandaloneASCII8 -p ../.. =DRIVER
- L80 -w drivers/StandaloneASCII8 -p ../../ /P:4100,DRIVER,DRIVER/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
+ $(call assemble,drivers/StandaloneASCII8/driver.mac,--build-type abs --output-file-extension bin)
-drivers/StandaloneASCII8/CHGBNK.BIN: \
+drivers/StandaloneASCII8/chgbnk.bin: \
drivers/StandaloneASCII8/chgbnk.mac
- M80 -w drivers/StandaloneASCII8 -p ../.. =CHGBNK
- L80 -w drivers/StandaloneASCII8 /P:7fd0,CHGBNK,CHGBNK/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
+ $(call assemble,drivers/StandaloneASCII8/chgbnk.mac,--build-type abs --output-file-extension bin)
### Standalone ASCII16
@@ -185,27 +201,18 @@ ascii16: drivers/StandaloneASCII16/Nextor-$(VERSION).StandaloneASCII16.ROM
drivers/StandaloneASCII16/Nextor-$(VERSION).StandaloneASCII16.ROM: \
nextor_base.dat \
- drivers/StandaloneASCII16/DRIVER.BIN \
- drivers/StandaloneASCII16/CHGBNK.BIN \
+ drivers/StandaloneASCII8/driver.bin \
+ drivers/StandaloneASCII16/chgbnk.bin \
256.bytes
- cat 256.bytes drivers/StandaloneASCII16/DRIVER.BIN > drivers/StandaloneASCII16/_driver.BIN
- mknexrom nextor_base.dat $@ /d:drivers/StandaloneASCII16/_driver.BIN /m:drivers/StandaloneASCII16/CHGBNK.BIN
+ cat 256.bytes drivers/StandaloneASCII8/driver.bin > drivers/StandaloneASCII16/_driver.bin
+ mknexrom nextor_base.dat $@ /d:drivers/StandaloneASCII16/_driver.bin /m:drivers/StandaloneASCII16/chgbnk.bin
$(call copy_to_bin,$@)
-drivers/StandaloneASCII16/DRIVER.BIN: \
- drivers/StandaloneASCII16/driver.mac
-
- M80 -w drivers/StandaloneASCII16 -p ../.. =DRIVER
- L80 -w drivers/StandaloneASCII16 -p ../../ /P:4100,DRIVER,DRIVER/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
-
-drivers/StandaloneASCII16/CHGBNK.BIN: \
+drivers/StandaloneASCII16/chgbnk.bin: \
drivers/StandaloneASCII16/chgbnk.mac
- M80 -w drivers/StandaloneASCII16 -p ../.. =CHGBNK
- L80 -w drivers/StandaloneASCII16 /P:7fd0,CHGBNK,CHGBNK/N/X/Y/E
- $(call hex2bin,$(patsubst %.BIN,%,$@))
+ $(call assemble,drivers/StandaloneASCII16/chgbnk.mac,--build-type abs --output-file-extension bin)
### MegaFlashROM SCC+ SD
@@ -216,34 +223,55 @@ mfrsd: \
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.ROM \
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.Recovery.ROM \
+drivers/MegaFlashRomSD/mfrsd-1slot.bin: \
+ drivers/MegaFlashRomSD/mfrsd.asm
+
+ $(call assemble_as,drivers/MegaFlashRomSD/mfrsd.asm,$$/mfrsd-1slot.bin,--build-type abs --output-file-extension bin --define-symbols NUM_SLOTS=1)
+
+drivers/MegaFlashRomSD/mfrsd-2slots.bin: \
+ drivers/MegaFlashRomSD/mfrsd.asm
+
+ $(call assemble_as,drivers/MegaFlashRomSD/mfrsd.asm,$$/mfrsd-2slots.bin,--build-type abs --output-file-extension bin --define-symbols NUM_SLOTS=2)
+
+drivers/MegaFlashRomSD/recovery_header.bin: \
+ drivers/MegaFlashRomSD/recovery_header.asm
+
+ $(call assemble,drivers/MegaFlashRomSD/recovery_header.asm,--build-type abs --output-file-extension bin)
+
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.ROM: \
nextor_base.dat \
- drivers/StandaloneASCII8/CHGBNK.BIN
+ drivers/StandaloneASCII8/chgbnk.bin \
+ drivers/MegaFlashRomSD/mfrsd-1slot.bin
- mknexrom nextor_base.dat $@ /d:drivers/MegaFlashRomSD/driver-1slot.dat /m:drivers/StandaloneASCII8/CHGBNK.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/MegaFlashRomSD/mfrsd-1slot.bin /m:drivers/StandaloneASCII8/chgbnk.bin
$(call copy_to_bin,$@)
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.Recovery.ROM: \
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.ROM \
- drivers/MegaFlashRomSD/makerecoverykernel.asm
+ drivers/MegaFlashRomSD/recovery_header.bin
+
+ cat drivers/MegaFlashRomSD/recovery_header.bin \
+ drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.ROM \
+ > drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.Recovery.ROM
- cp drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.1-slot.ROM drivers/MegaFlashRomSD/nextor2.rom
- sjasm drivers/MegaFlashRomSD/makerecoverykernel.asm $@
$(call copy_to_bin,$@)
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.ROM: \
nextor_base.dat \
- drivers/StandaloneASCII8/CHGBNK.BIN
+ drivers/StandaloneASCII8/chgbnk.bin \
+ drivers/MegaFlashRomSD/mfrsd-2slots.bin
- mknexrom nextor_base.dat $@ /d:drivers/MegaFlashRomSD/driver-2slots.dat /m:drivers/StandaloneASCII8/CHGBNK.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/MegaFlashRomSD/mfrsd-2slots.bin /m:drivers/StandaloneASCII8/chgbnk.bin
$(call copy_to_bin,$@)
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.Recovery.ROM: \
drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.ROM \
- drivers/MegaFlashRomSD/makerecoverykernel.asm
+ drivers/MegaFlashRomSD/recovery_header.bin
+
+ cat drivers/MegaFlashRomSD/recovery_header.bin \
+ drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.ROM \
+ > drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.Recovery.ROM
- cp drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.ROM drivers/MegaFlashRomSD/nextor2.rom
- sjasm drivers/MegaFlashRomSD/makerecoverykernel.asm $@
$(call copy_to_bin,$@)
@@ -251,12 +279,17 @@ drivers/MegaFlashRomSD/Nextor-$(VERSION).MegaFlashSDSCC.2-slots.Recovery.ROM: \
flashjacks: drivers/Flashjacks/Nextor-$(VERSION).Flashjacks.ROM
+drivers/Flashjacks/flashjacks.bin: \
+ drivers/Flashjacks/flashjacks.asm
+
+ $(call assemble,drivers/Flashjacks/flashjacks.asm,--build-type abs --output-file-extension bin)
+
drivers/Flashjacks/Nextor-$(VERSION).Flashjacks.ROM: \
nextor_base.dat \
- drivers/Flashjacks/flashjacks.asm
+ drivers/Flashjacks/flashjacks.bin \
+ drivers/SunriseIDE/chgbnk.bin
- sjasm drivers/Flashjacks/flashjacks.asm drivers/Flashjacks/driver.BIN
- mknexrom nextor_base.dat $@ /d:drivers/Flashjacks/driver.BIN /m:drivers/Flashjacks/chgbnk.dat
+ mknexrom nextor_base.dat $@ /d:drivers/Flashjacks/flashjacks.bin /m:drivers/SunriseIDE/chgbnk.bin
$(call copy_to_bin,$@)
@@ -266,9 +299,9 @@ ocm: drivers/OCM/Nextor-$(VERSION).OCM.ROM
drivers/OCM/Nextor-$(VERSION).OCM.ROM: \
nextor_base.dat \
- drivers/StandaloneASCII8/CHGBNK.BIN
+ drivers/StandaloneASCII8/chgbnk.bin
- mknexrom nextor_base.dat $@ /d:drivers/OCM/driver.dat /m:drivers/StandaloneASCII8/CHGBNK.BIN
+ mknexrom nextor_base.dat $@ /d:drivers/OCM/driver.dat /m:drivers/StandaloneASCII8/chgbnk.bin
$(call copy_to_bin,$@)
@@ -311,44 +344,42 @@ nextor_base.dat: \
255.bytes:
dd if=/dev/zero of=255.bytes bs=1 count=255
-COMRELS = CODES.REL KVAR.REL DATA.REL CHGBNK.REL
-B0RELS = $(addprefix bank0/,DOSHEAD.REL 40FF.REL B0.REL INIT.REL ALLOC.REL DSKBASIC.REL DOSBOOT.REL BDOS.REL RAMDRV.REL)
-B1RELS = $(addprefix bank1/,DOSINIT.REL MAPINIT.REL MSG.REL)
-B2RELS = $(addprefix bank2/,B2.REL KINIT.REL CHAR.REL DEV.REL KBIOS.REL MISC.REL SEG.REL PATH.REL FIND.REL DIR.REL HANDLES.REL DEL.REL RW.REL FILES.REL BUF.REL FAT.REL VAL.REL ERR.REL)
-B3RELS = $(addprefix bank3/,DOS1KER.REL)
-B4RELS = $(addprefix bank4/,JUMP.REL ENV.REL CPM.REL PARTIT.REL RAMDRV.REL TIME.REL SEG.REL MISC.REL DSKAB.REL)
-B5RELS = $(addprefix bank5/,B5.REL)
-B6RELS = $(addprefix bank6/,B6.REL)
+COMRELS = codes.rel kvar.rel data.rel chgbnk.rel
+B0RELS = $(addprefix bank0/,doshead.rel 40ff.rel b0.rel init.rel alloc.rel dskbasic.rel dosboot.rel bdos.rel ramdrv.rel)
+B1RELS = $(addprefix bank1/,dosinit.rel mapinit.rel msg.rel)
+B2RELS = $(addprefix bank2/,kinit.rel char.rel dev.rel kbios.rel misc.rel seg.rel path.rel find.rel dir.rel handles.rel del.rel rw.rel files.rel buf.rel fat.rel val.rel err.rel)
+B3RELS = $(addprefix bank3/,dos1ker.rel)
+B4RELS = $(addprefix bank4/,jump.rel env.rel cpm.rel partit.rel ramdrv.rel time.rel seg.rel misc.rel dskab.rel)
+B5RELS = $(addprefix bank5/,b5.rel)
+B6RELS = $(addprefix bank6/,b6.rel)
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,\
$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,\
$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
.SECONDEXPANSION:
-$(COMRELS) $(B0RELS) $(B1RELS) $(B2RELS) $(B3RELS) $(B4RELS) $(B5RELS) $(B6RELS) DRV.REL REL.REL: \
+$(COMRELS) $(B0RELS) $(B1RELS) $(B2RELS) $(B3RELS) $(B4RELS) $(B5RELS) $(B6RELS) drv.rel rel.rel: \
macros.inc \
const.inc \
condasm.inc \
- $$(patsubst %.rel,%.mac,$$(call lc,$$@))
+ $$(patsubst %.rel,%.mac,$$@)
- M80 -w $(dir $@) -p ..,../bank0,../bank2 =$(notdir $(patsubst %.REL,%,$@))
+ $(call assemble,$(patsubst %.rel,%.mac,$@))
### Bank 0
-bank0/B0.BIN: \
- bank0/B0.HEX
-
- $(call hex2bin,bank0/B0)
-
-bank0/B0.HEX bank0/B0.SYM: \
+bank0/B0.BIN bank0/B0.SYM: \
$(COMRELS) \
$(B0RELS) \
- DRV.REL \
- REL.REL
+ drv.rel \
+ rel.rel
- L80 -w bank0 -p .. /p:4000,CODES,KVAR,DATA,REL,DOSHEAD,40FF,B0,INIT,ALLOC,DSKBASIC,DOSBOOT,BDOS,RAMDRV,/p:7700,drv,/p:7fd0,chgbnk,b0/n/x/y/e
- $(call hex2bin,bank0/B0)
+ $(call print_linking,"bank 0")
+ @$(LK80) --working-dir bank0 --symbols-file B0.SYM --output-file B0.BIN \
+ --code 4000h ../codes.rel ../kvar.rel ../data.rel ../rel.rel doshead.rel 40ff.rel b0.rel init.rel alloc.rel dskbasic.rel dosboot.rel bdos.rel ramdrv.rel \
+ --code 7700h ../drv.rel \
+ --code 7fd0h ../chgbnk.rel
bank0/b0labels.inc: \
bank0/B0.SYM
@@ -363,43 +394,48 @@ bank0/b0lab_b3.inc: \
### Bank 1
-bank1/B1.REL: \
+bank1/b1.rel: \
bank1/b1.mac \
bank0/b0labels.inc
- M80 -w bank1 -p ..,../bank0 M80 =B1
+ $(call assemble,bank1/b1.mac)
bank1/B1.BIN: \
- bank1/B1.HEX
-
- $(call hex2bin,bank1/B1)
-
-bank1/B1.HEX: \
$(COMRELS) \
$(B1RELS) \
- bank1/B1.REL \
- bank0/ALLOC.REL \
+ bank1/msg.rel \
+ bank1/b1.rel \
+ bank0/alloc.rel \
bank0/b0labels.inc
- L80 -w bank1 -p ..,../bank0 /P:40FF,CODES,KVAR,DATA,B1,DOSINIT,MAPINIT,ALLOC,MSG,/p:7fd0,chgbnk,B1/N/X/Y/E
+ $(call print_linking,"bank 1")
+ @$(LK80) --working-dir bank1 --symbols-file B1.SYM --output-file B1.BIN \
+ --code 40FFh ../codes.rel ../kvar.rel ../data.rel b1.rel dosinit.rel mapinit.rel ../bank0/alloc.rel msg.rel \
+ --code 7fd0h ../chgbnk.rel
### Bank 2
-bank2/B2.BIN: \
- bank2/B2.HEX
+bank2/b2.rel: \
+ bank2/b2.mac \
+ bank0/b0labels.inc
- $(call hex2bin,bank2/B2)
+ $(call assemble,bank2/b2.mac)
-bank2/B2.HEX bank2/B2.SYM: \
+bank2/B2.BIN bank2/B2.SYM: \
$(COMRELS) \
$(B2RELS) \
+ bank2/b2.rel \
bank0/b0labels.inc
- LIB80 -w bank2 TEMP21=char.rel,dev.rel,kbios.rel,misc.rel,seg.rel/E
- LIB80 -w bank2 TEMP22=path.rel,find.rel,dir.rel,handles.rel,del.rel,rw.rel,files.rel/E
- LIB80 -w bank2 TEMP23=buf.rel,fat.rel,val.rel,err.rel/E
- L80 -w bank2 -p .. /P:40FF,CODES,KVAR,DATA,B2,KINIT,TEMP21,TEMP22,TEMP23,/p:7fd0,chgbnk,B2/N/X/Y/E
+ @$(LB80) --working-dir bank2 create TEMP21.REL char.rel dev.rel kbios.rel misc.rel seg.rel
+ @$(LB80) --working-dir bank2 create TEMP22.REL path.rel find.rel dir.rel handles.rel del.rel rw.rel files.rel
+ @$(LB80) --working-dir bank2 create TEMP23.REL buf.rel fat.rel val.rel err.rel
+
+ $(call print_linking,"bank 2")
+ @$(LK80) --working-dir bank2 --symbols-file B2.SYM --output-file B2.BIN \
+ --code 40FFh ../codes.rel ../kvar.rel ../data.rel b2.rel kinit.rel TEMP21.REL TEMP22.REL TEMP23.REL \
+ --code 7fd0h ../chgbnk.rel
bank2/b2labels.inc: \
bank2/B2.SYM
@@ -409,26 +445,25 @@ bank2/b2labels.inc: \
### Bank 3
-bank3/B3.REL: \
+bank3/b3.rel: \
bank3/b3.mac \
bank0/b0lab_b3.inc
- M80 -w bank3 -p ..,../bank0 M80 =B3
+ $(call assemble,bank3/b3.mac)
bank3/B3.BIN: \
- bank3/B3.HEX
-
- $(call hex2bin,bank3/B3)
-
-bank3/B3.HEX: \
$(COMRELS) \
$(B3RELS) \
- bank3/B3.REL \
+ bank3/b3.rel \
bank0/b0lab_b3.inc \
- bank0/DOSHEAD.REL \
- bank0/40FF.REL
+ bank0/doshead.rel \
+ bank0/40ff.rel
- L80 -w bank3 -p ..,../bank0 /p:4000,CODES,KVAR,DATA,DOSHEAD,40FF,B3,DOS1KER,/p:7700,drv,/p:7fd0,chgbnk,b3/N/X/Y/E
+ $(call print_linking,"bank 3")
+ @$(LK80) --working-dir bank3 --symbols-file B3.SYM --output-file B3.BIN \
+ --code 4000h ../codes.rel ../kvar.rel ../data.rel ../bank0/doshead.rel ../bank0/40ff.rel b3.rel dos1ker.rel \
+ --code 7700h ../drv.rel \
+ --code 7fd0h ../chgbnk.rel
### Bank 4
@@ -438,71 +473,65 @@ bank4/b4rdlabs.inc: \
$(call SymToEqus,bank4/B4.SYM,bank4/b4rdlabs.inc,R4_[1-9])
-bank4/B4.REL: \
+bank4/b4.rel: \
bank.inc \
bank4/b4.mac \
bank2/b2labels.inc
- M80 -w bank4 -p ..,../bank2 =B4
+ $(call assemble,bank4/b4.mac)
-bank4/RAMDRVH.REL: \
+bank4/ramdrvh.rel: \
macros.inc \
const.inc \
+ bank4/ramdrvh.mac \
bank4/b4rdlabs.inc
- M80 -w bank4 -p .. =RAMDRVH
-
-bank4/B4.BIN: \
- bank4/B4.HEX
-
- $(call hex2bin,bank4/B4)
+ $(call assemble,bank4/ramdrvh.mac)
bank4/B4RD.BIN: \
- bank4/B4RD.HEX
-
- $(call hex2bin,bank4/B4RD)
-
-bank4/B4RD.HEX: \
- bank4/RAMDRVH.REL \
+ bank4/ramdrvh.rel \
bank4/b4rdlabs.inc
- L80 -w bank4 -p .. /P:4080,RAMDRVH,B4RD/N/X/Y/E
+ $(call print_linking,"bank 4 B4RD")
+ @$(LK80) --working-dir bank4 --symbols-file B4RD.SYM --output-file B4RD.BIN \
+ --code 4080h ramdrvh.rel
-bank4/B4.HEX bank4/B4.SYM: \
+bank4/B4.BIN bank4/B4.SYM: \
$(COMRELS) \
$(B4RELS) \
- bank4/B4.REL \
+ bank4/b4.rel \
+ bank4/ramdrv.rel \
bank0/b0labels.inc \
bank2/b2labels.inc \
- L80 -w bank4 -p ..,../bank0,../bank2 /P:40FF,CODES,KVAR,DATA,B4,JUMP,ENV,CPM,PARTIT,RAMDRV,TIME,SEG,MISC,/p:7bc0,DSKAB,/p:7fd0,chgbnk,B4/N/X/Y/E
+ $(call print_linking,"bank 4")
+ @$(LK80) --working-dir bank4 --symbols-file B4.SYM --output-file B4.BIN \
+ --code 40FFh ../codes.rel ../kvar.rel ../data.rel b4.rel jump.rel env.rel cpm.rel partit.rel ramdrv.rel time.rel seg.rel misc.rel \
+ --code 7BC0h dskab.rel \
+ --code 7fd0h ../chgbnk.rel
### Banks 5 and 6 (FDISK)
bank5/B5.BIN: \
- bank5/B5.HEX
-
- $(call hex2bin,bank5/B5)
-
-bank5/B5.HEX: \
$(COMRELS) \
$(B5RELS) \
- bank0/40FF.REL
+ bank0/40ff.rel
- L80 -w bank5 -p .. /P:40FF,CODES,KVAR,DATA,B5,/p:7fd0,chgbnk,B5/N/X/Y/E
+ $(call print_linking,"bank 5")
+ @$(LK80) --working-dir bank5 --symbols-file B5.SYM --output-file B5.BIN \
+ --code 40FFh ../codes.rel ../kvar.rel ../data.rel b5.rel \
+ --code 7fd0h ../chgbnk.rel
bank6/B6.BIN: \
- bank6/B6.HEX
-
- $(call hex2bin,bank6/B6)
-
-bank6/B6.HEX: \
$(COMRELS) \
$(B6RELS) \
- bank0/40FF.REL
+ bank0/40ff.rel
- L80 -w bank6 -p .. /P:40FF,CODES,KVAR,DATA,B6,/p:7fd0,chgbnk,B6/N/X/Y/E
+ $(call print_linking,"bank 6")
+ @$(LK80) --working-dir bank6 --symbols-file B6.SYM --output-file B6.BIN \
+ --code 40FFh ../codes.rel ../kvar.rel ../data.rel b6.rel \
+ --code 7fd0h ../chgbnk.rel
bank5/fdisk.dat bank5/fdisk2.dat: \
bank5/fdisk_crt0.rel \
@@ -521,7 +550,7 @@ bank5/fdisk.dat bank5/fdisk2.dat: \
sdcc -o bank5/ --code-loc 0x4120 --data-loc 0x8020 -mz80 --disable-warning 196 --disable-warning 84 --disable-warning 85 \
--max-allocs-per-node 1000 --allow-unsafe-read --opt-code-size --no-std-crt0 bank5/fdisk_crt0.rel $(patsubst %.dat,%.c,$@)
- $(call hex2bin_full,$(patsubst %.dat,%.ihx,$@),$@)
+ $(call hex2bin,$(patsubst %.dat,%.ihx,$@),$@)
bank5/fdisk_crt0.rel: \
bank5/fdisk_crt0.s
diff --git a/source/kernel/SymToEqus.exe b/source/kernel/SymToEqus.exe
deleted file mode 100644
index cd12f824..00000000
Binary files a/source/kernel/SymToEqus.exe and /dev/null differ
diff --git a/source/kernel/bank0/40ff.mac b/source/kernel/bank0/40ff.mac
index a6340152..ecb64cfa 100644
--- a/source/kernel/bank0/40ff.mac
+++ b/source/kernel/bank0/40ff.mac
@@ -1,3 +1,5 @@
+ name('h40ff')
+
aseg
; org 40FFh
org 40FEh
diff --git a/source/kernel/bank0/B0.SYM.old b/source/kernel/bank0/B0.SYM.old
new file mode 100644
index 00000000..f81ea9e0
--- /dev/null
+++ b/source/kernel/bank0/B0.SYM.old
@@ -0,0 +1,254 @@
+0000 _TERM0 0001 _CONIN 0002 _CONOU 0003 _AUXIN
+0004 _AUXOU 0005 _LSTOU 0006 _DIRIO 0007 _DIRIN
+0008 _INNOE 0009 _STROU 000A _BUFIN 000B _CONST
+000C _CPMVE 000D _DSKRS 000E _SELDS 000F _FOPEN
+0010 _FCLOS 0011 _SFIRS 0012 _SNEXT 0013 _FDEL
+0014 _RDSEQ 0015 _WRSEQ 0016 _FMAKE 0017 _FREN
+0018 _LOGIN 0019 _CURDR 001A _SETDT 001B _ALLOC
+0021 _RDRND 0022 _WRRND 0023 _FSIZE 0024 _SETRN
+0026 _WRBLK 0027 _RDBLK 0028 _WRZER 002A _GDATE
+002B _SDATE 002C _GTIME 002D _STIME 002E _VERIF
+002F _RDABS 0030 _WRABS 0031 _DPARM 0040 _FFIRS
+0041 _FNEXT 0042 _FNEW 0043 _OPEN 0044 _CREAT
+0045 _CLOSE 0046 _ENSUR 0047 _DUP 0048 _READ
+0049 _WRITE 004A _SEEK 004B _IOCTL 004C _HTEST
+004D _DELET 004E _RENAM 004F _MOVE 0050 _ATTR
+0051 _FTIME 0052 _HDELE 0053 _HRENA 0054 _HMOVE
+0055 _HATTR 0056 _HFTIM 0057 _GETDT 0058 _GETVF
+0059 _GETCD 005A _CHDIR 005B _PARSE 005C _PFILE
+005D _CHKCH 005E _WPATH 005F _FLUSH 0060 _FORK
+0061 _JOIN 0062 _TERM 0063 _DEFAB 0064 _DEFER
+0065 _ERROR 0066 _EXPLA 0067 _FORMA 0068 _RAMD
+0069 _BUFFE 006A _ASSIG 006B _GENV 006C _SENV
+006D _FENV 006E _DSKCH 006F _DOSVE 0070 _REDIR
+0071 _FOUT 0072 _ZSTRO 0073 _RDDRV 0074 _WRDRV
+0075 _RALLO 0076 _DSPAC 0077 _LOCK 0078 _GDRVR
+0079 _GDLI 007A _GPART 007B _CDRVR 007C _MAPDR
+007D _Z80MO 007E _GETCL 00FF .NCOMP 00FE .WRERR
+00FD .DISK 00FC .NRDY 00FB .VERFY 00FA .DATA
+00F9 .RNF 00F8 .WPROT 00F7 .UFORM 00F6 .NDOS
+00F5 .WDISK 00F4 .WFILE 00F3 .SEEK 00F2 .IFAT
+00F1 .NOUPB 00F0 .IFORM 00DF .INTER 00DE .NORAM
+00DC .IBDOS 00DB .IDRV 00DA .IFNM 00D9 .IPATH
+00D8 .PLONG 00D7 .NOFIL 00D6 .NODIR 00D5 .DRFUL
+00D4 .DKFUL 00D3 .DUPF 00D2 .DIRE 00D1 .FILRO
+00D0 .DIRNE 00CF .IATTR 00CE .DOT 00CD .SYSX
+00CC .DIRX 00CB .FILEX 00CA .FOPEN 00C9 .OV64K
+00C8 .FILE 00C7 .EOF 00C6 .ACCV 00C5 .IPROC
+00C4 .NHAND 00C3 .IHAND 00C2 .NOPEN 00C1 .IDEV
+00C0 .IENV 00BF .ELONG 00BE .IDATE 00BD .ITIME
+00BC .RAMDX 00BB .NRAMD 00BA .HDEAD 00B9 .EOL
+00B8 .ISBFN 00B7 .IFCB 00B6 .IDRVR 00B5 .IDEVL
+00B4 .IPART 00B3 .PUSED 00B2 .FMNT 00B1 .BFSZ
+00B0 .ICLUS 009F .STOP 009E .CTRLC 009D .ABORT
+009C .OUTER 009B .INERR 008F .BADCO 008E .BADCM
+008D .BUFUL 008C .OKCMD 008B .IPARM 008A .INP
+0089 .NOPAR 0088 .IOPT 0087 .BADNO 0086 .NOHEL
+0085 .BADVE 0084 .NOCAT 0083 .BADES 0082 .COPY
+0081 .OVDES 0080 .BATEN 007F .INSDS 007E .PRAK
+0000 STDIN 0001 STDOUT 0002 STDERR 0003 STDAUX
+0004 STDLST 0002 DOSVER 0003 DOSV_H 0001 DOSV_L
+0002 NXTVER 0001 NXTV_H 0001 NXTV_L 0002 MIN_BU
+0005 DEF_BU 003F MAX_HA 0007 UD_TMO 0002 CH_TMO
+0065 ST_TMO 0000 UD_SLO 0001 UD_OFF 0001 UD_DI
+0002 UD_DPB 0004 UD_FLA 0005 UD_DFL 0006 UD_LI
+0007 UD_SEG 0008 UD_PHY 0009 UD_TIM 000A UD_CMS
+000B UD_CSH 000C UD_RES 000E UD_NFA 000F UD_ODE
+0010 UD_WDS 0011 UD_SFA 0012 UD_SDI 0014 UD_SDA
+0016 UD_NCL 0018 UD_DIR 0019 UD_ID 001D UD_MBY
+001E UD_CDI 0020 UD_PAT 0060 UD_RDC 0062 UD_FSE
+0066 UD_CHK 0068 UD_REL 0069 UD_ACL 006B UD_MFL
+006C UD_DRV 006D UD_MXS 006F UD_SCL 0071 UD_SSE
+0074 UD_MNA 0081 UD_MSZ 006B UD_SZ 0000 UD1_SL
+0001 UD1_RE 0002 UD1_DI 0003 UD1_LI 0004 UD1_FS
+0008 UD1_SZ 0000 DSK_ID 0001 EMU_DE 0002 DSK_DE
+0003 DSK_LU 0004 DSK_FS 0008 DSK_SI 000A DSK_CO
+000B EMU_FS 000F EMU_SZ F980 BOOT_T F980 EMU_TM
+F98F IN_EMU F990 EMU_WK F992 BOOTKE F997 I_AM_R
+FFFE DD_NEX 0000 DD_ADD 0008 DD_MOD 0009 DD_NAM
+002B DD_SZ 0000 BD_LIN 0002 BD_UNI 0003 BD_FLA
+0004 BD_SEC 0006 BD_COP 0007 BD_SEP 0008 BD_EX_
+0009 BD_UD 000B BD_DAT 020B BD_SZ 0000 FIB_FL
+0001 FIB_NA 000E FIB_AT 000F FIB_TI 0011 FIB_DA
+0013 FIB_CL 0015 FIB_SI 0019 FIB_DR 001A FIB_ID
+001E FIB_MO 001F FIB_SA 0020 FIB_PA 002B FIB_DV
+0040 FIB_SZ FFFD FAB_NE FFFF FAB_CN 0000 FAB_FL
+0001 FAB_NA 000E FAB_AT 000F FAB_TI 0011 FAB_DA
+0013 FAB_CL 0015 FAB_SI 0019 FAB_DR 001A FAB_ID
+001E FAB_MO 001F FAB_SA 0020 FAB_FI 0020 FAB_UD
+0022 FAB_DS 0024 FAB_EX 0025 FAB_EN 0026 FAB_FD
+0028 FAB_FP 002A FAB_LP 002C FAB_LL 002E FAB_PT
+0032 FAB_AC 0033 FAB_PG 0037 FAB_SZ 0000 CP_DRV
+0001 CP_FN 0009 CP_EXT 000C CP_EXL 000D CP_S1
+000E CP_EXH 000E CP_RS 000F CP_RC 0010 CP_SIZ
+0014 CP_ID 0018 CP_FDC 001A CP_FPC 001C CP_LPC
+001E CP_LLC 0020 CP_CR 0021 CP_RR 0025 CP_SZ
+0000 UPB_JP 0003 UPB_MA 000B UPB_SS 000D UPB_CS
+000E UPB_RE 0010 UPB_NF 0011 UPB_ND 0013 UPB_SE
+0015 UPB_MB 0016 UPB_SF 0018 UPB_ST 001A UPB_HE
+001C UPB_HS 001E UPB_BO 0020 UPB_VO 0026 UPB_DI
+0027 UPB_ID 0030 UPB_SP 0020 UPB_BI 0024 UPB_PH
+0025 UPB_RS 0026 UPB_EB 002B UPB_VN 0036 UPB_FI
+0000 DR_FIL 0008 DR_EXT 000B DR_ATT 000C DR_DCH
+0016 DR_TIM 0018 DR_DAT 001A DR_CLU 001C DR_SIZ
+C000 RD_END BE00 RD_LIS BDFF RD_COU BDCF RD_BOO
+BDCD IY_SAV BDCC A_SAVE BD4C RAM_BA BDCC VAR_TO
+BDCB LAZY 007F @LAZY BDCA PROC_I 007E @PROC_
+BDC9 LAST_E 007D @LAST_ BDC7 RM_UD 007B @RM_UD
+BDC6 B_COUN 007A @B_COU BDC4 B_CHAI 0078 @B_CHA
+BDC2 B_CACH 0076 @B_CAC BDC0 DEV_CH 0074 @DEV_C
+BDBE FAB_CH 0072 @FAB_C BDBC HANDLE 0070 @HANDL
+BDBA ENV_PT 006E @ENV_P BDB9 EV_PG 006D @EV_PG
+BDB8 IGNORE 006C @IGNOR BDB7 PHYS_U 006B @PHYS_
+BDB6 DSK_RW 006A @DSK_R BDB6 DE_LST 006A @DE_LS
+BDB4 DE_STA 0068 @DE_ST BDB2 DE_CLU 0066 @DE_CL
+BDB0 DE_NEX 0064 @DE_NE BDAE DE_SEC 0062 @DE_SE
+BDAD DE_EX_ 0061 @DE_EX BDAC DE_S_L 0060 @DE_S_
+BDAB DE_E_L 005F @DE_E_ BDAA DE_ENT 005E @DE_EN
+BDA9 DE_ODD 005D @DE_OD BDA9 DE_FST 005D @DE_FS
+BD9C DE_SV 0050 @DE_SV BD8F DE_2SV 0043 @DE_2S
+BD8E CH1_BU 0042 @CH1_B BD8D RW_FLA 0041 @RW_FL
+BD8B RW_DTA 003F @RW_DT BD89 RW_SIZ 003D @RW_SI
+BD87 RW_SZ_ 003B @RW_SZ BD85 RW_LCL 0039 @RW_LC
+BD84 RW_LSE 0038 @RW_LS BD82 RW_SOF 0036 @RW_SO
+BD81 RW_MSE 0035 @RW_MS BD7F RW_PCL 0033 @RW_PC
+BD7D RW_PSE 0031 @RW_PS BD7C RW_EX_ 0030 @RW_EX
+BD7A RW_OVE 002E @RW_OV BD78 STR_2 002C @STR_2
+BD77 SE_FLA 002B @SE_FL BD75 FNM_PT 0029 @FNM_P
+BD73 CHK_CL 0027 @CHK_C BD72 AL_FLA 0026 @AL_FL
+BD71 FAT_FL 0025 @FAT_F BD6F FAT_OS 0023 @FAT_O
+BD6D FAT_HA 0021 @FAT_H BD6B FAT_CH 001F @FAT_C
+BD6A READ_C 001E @READ_ BD69 DIO_EX 001D @DIO_E
+BD68 ERR_EX 001C @ERR_E BD67 CH_FLA 001B @CH_FL
+BD66 PC_FLA 001A @PC_FL BD64 STR_PT 0018 @STR_P
+BD62 STR2_P 0016 @STR2_ BD60 WPTH_P 0014 @WPTH_
+BD5F WP_ERR 0013 @WP_ER BD5E RALL_V 0012 @RALL_
+BD5A TURBO_ 000E @TURBO BD52 MB_DEF 0006 @MB_DE
+BD51 APPEND 0005 @APPEN BD4F FCB_AD 0003 @FCB_A
+BD4E SFN_EX 0002 @SFN_E BD4B BUF_RE FFFF @BUF_R
+BD4A BUF_CO FFFE @BUF_C BD49 BUF_UN FFFD @BUF_U
+BD47 BUF_FP FFFB @BUF_F BD46 CHAR_B FFFA @CHAR_
+BD44 CUR_CO FFF8 @CUR_C BD43 PR_ECH FFF7 @PR_EC
+BD42 IO_RDR FFF6 @IO_RD BD40 PROM_C FFF4 @PROM_
+BD3F IN_COU FFF3 @IN_CO BD3D IN_STA FFF1 @IN_ST
+BD3B CUR_LI FFEF @CUR_L BD39 END_LI FFED @END_L
+BD38 BUF_EM FFEC @BUF_E BD36 MAX_CU FFEA @MAX_C
+BD35 FLAG_F FFE9 @FLAG_ BD34 INS_FL FFE8 @INS_F
+BD33 CNL_EC FFE7 @CNL_E BD31 LN_PTR FFE5 @LN_PT
+BD30 CH_PTR FFE4 @CH_PT BD2F CH_16F FFE3 @CH_16
+BD2E CBF_CT FFE2 @CBF_C BC2E UC_TAB BBEE MAP_TB
+BBDC UNIT_T BBD3 ASG_TA BB93 FIB_1 BB53 SRCH_F
+BB2E TEMP_F BAEA WPTH_B BADF FNAME_ BAD4 FNM2_B
+BAC9 CDIR_B BABA SQN_BU BAAD SQN2_B BA8D DEV_EN
+B88D UPB_BU 0008 SECT_B B48D CPM_BU 00FF LNB_SZ
+B389 LN_BUF B389 BUFF_E B289 CIRC_B 0064 CHB_SZ
+B225 CH_BUF B21F ESEQ_B B219 TMP_FA B217 RAM_PT
+B215 VAR_BO F1C9 DATABA F1C9 PRTBUF F1D0 BK4_AD
+F1D2 TMP_SE F1D6 JUMPBA F1D6 RD_LDI F1D9 P0_LDI
+F1DC P0_CAL F1DF $FLUSH F1E2 GO_DRV F1E5 JP_VEC
+F1E8 $RDSLT F1EB $WRSLT F1EE $CALSL F1F1 $ENASL
+F1F4 $CALLF F1F7 PUT_BD F1FA PUT_US F1FD P0_RAM
+F200 MAP_VE F200 ALL_SE F203 FRE_SE F206 RD_SEG
+F209 WR_SEG F20C CAL_SE F20F CALLS F212 PUT_PH
+F215 GET_PH F218 PUT_P0 F21B GET_P0 F21E PUT_P1
+F221 GET_P1 F224 PUT_P2 F227 GET_P2 F22A PUT_P3
+F22D GET_P3 F230 CALL_M F233 RD_MAP F236 CLL_MA
+F239 WR_MAP F23C CUR_DR F23D DTA_AD F23F $IRQ
+F242 RAM_AB F246 DIRBFD F247 KNJWRK F24F HOOKBE
+F24F H.PROM F252 H_BDOS F255 H_UP F258 H_16CH
+F25B H_CHIN F25E H_CHOU F261 H_CHST F264 H_CHFL
+F267 H_LSTO F26A H_LSTS F27F H.DIV3 0069 HOOKLE
+F2B8 TIM_RA F2B9 TIM_CO F2BA RANDOM F2BD ST_COU
+F2BE CH_COU F2BF TIM_TI F2C0 TIMI_S F2C5 MAP_TA
+F2C7 P0_SEG F2C8 P1_SEG F2C9 P2_SEG F2CA P3_SEG
+F2CB P0_TPA F2CC P1_TPA F2CD P2_TPA F2CE P3_TPA
+F2CF DATA_S F2D0 CODE_S F2D1 SP_IRQ 00C8 IRQS_S
+F2D3 IRQ_ST F2D5 FCALSA F2DA $ERR_M F2DC $PROMP
+F2DE $BDOS F2E0 SS_TEM F2E1 RD_ADD F2E3 RD_SNU
+F2E5 RD_SCN F2E6 IX_BDO F2E8 SP_BDO F2EA PS_BDO
+F2EB SS_BDO F2EC DSK_CH F2EF MFLAGS 0000 FASTOU
+0001 FIRSTL 0002 ZALLOC 0003 ERRL 0004 KILLD
+0007 SYST2 F2F1 BLDCHK F2F3 BSVCHK 0064 LEN_1
+F2F5 BUF_1 0040 LEN_2 F2F7 BUF_2 0064 LEN_3
+F2F9 BUF_3 F2FB ERR_BU F2FD BOOT_D 012C BDS_SZ
+F2FE BDOS_S F300 KDSK_V F302 KAB_VE F304 SPSAVE
+F306 CPMCAL F307 SRCHFC F30D RAWFLG F30E COUNTR
+F30F KANJTA F313 DOS_VE F314 P0_64K F315 P1_64K
+F316 P2_64K F317 P3_64K F314 DVB_TA F316 KSLOT
+F318 NXT_VE F319 MAIN_B F31A KER250 F31E TM1_SA
+F323 DISKVE F325 BREAKV F327 AUXBOD F333 $DOS1
+F336 KEYVLD F337 KEYCHR F338 TIMFLG F33B PATHNA
+F33D RECSIZ F33F TARGET F340 NOTFIR F341 RAMAD0
+F342 RAMAD1 F343 RAMAD2 F344 RAMAD3 F345 FILMAX
+F346 DOSFLG F347 $NUMDR F348 MASTER F349 HIMSAV
+F34B DOSHIM F34D $SECBU F34F $MAXSE F351 $DIRBU
+F353 RM_DPB F355 $DPBLI F365 RSLREG F368 $DOSON
+F36B $DOSOF F36E XFER F371 $AUXIN F374 $AUXOU
+F377 GO_BIO F37A GO_BDO F37D BDOS 01B7 DATASI
+000C RDSLT 0014 WRSLT 001C CALSLT 0024 ENASLT
+002B ID_BYT 0030 CALLF 0037 LOAD_F 0038 INTRPT
+003B SSLOT 0046 SSLOTL 004B SSLOTE 001A SSLSZ
+0000 KINIT 0005 KBDOS 005C $ALL_S 005F $FRE_S
+0080 KCONIN 0083 KCONOU 0086 KCONST 0089 KLIST
+008C KLISTS 008F KPUNCH 0092 KREADE 402D GSLOT1
+403C RDBANK 403F CALBAS 4042 CALBNK 4045 GWORK
+4048 CALDRV FB21 DRVTBL FC48 BOTTOM FC4A HIMEM
+FC9B INTFLG FCA7 ESCCNT FCC1 EXPTBL FCC5 SLTTBL
+FCC9 SLTATR FD09 SLTWRK F41F KBUF F55E BUF
+F41F MAP_RE F41F CH_TYP FD9A H.KEYI FD9F H.TIMI
+4100 F_GENV 4103 F_SENV 4106 F_FENV 4109 GET_EN
+410C F_FOPE 410F F_FCLO 4112 F_SFIR 4115 F_SNEX
+4118 F_RDSE 411B F_WRSE 411E F_FMAK 4121 F_FDEL
+4124 F_FREN 4127 F_RDRN 412A F_WRRN 412D F_WRZE
+4130 F_FSIZ 4133 F_SETR 4136 F_RDBL 4139 F_WRBL
+413C F_GPAR 413F GDRIVE 4142 AUTODR 4145 MKDPB
+4148 F_GDRV 414B F_GDLI 414E F_CDRV 4151 F_MAPD
+4154 F_Z80M 4157 UNMAPA 415A DOSV1 415D CMAPDR
+4160 CLOCKD 4163 CUSR 4166 CCURDR 4169 CNEXTO
+416C CCHDRV 416F CDRVIN 4172 CDRIVE 4175 F_GDAT
+4178 F_SDAT 417B F_GTIM 417E F_STIM 4181 CLK_IN
+4184 GT_DAT 4187 ALLSEG 418A FRESEG 418D FREUSE
+4190 F_LOCK 4193 F_FOUT 4196 F_RALL 4199 F_DSPA
+419C DRVS2 419F AUTO_A 41A2 F_GETC 41A5 F_RAMD
+41A8 ZAP_RA 0007 DV_BAN 403C DH_RDB 403F DH_CAL
+4042 DH_CAB 4045 DH_GWO 4100 DV_SIG 410E DV_TYP
+4110 DV_NAM 4130 DV_TIM 4133 DV_VER 4136 DV_INI
+4139 DV_OEM 413C DV_BAS 413F DV_EXT 4142 DV_D0
+4145 DV_D1 4148 DV_D2 414B DV_D3 414E DV_D4
+4151 DV_CON 4160 DV_DSK 4160 DEV_RW 4163 DV_CHG
+4163 DEV_IN 4166 DV_GET 4166 DEV_ST 4169 DV_CHO
+4169 LUN_IN 416C DV_FOR 416C DEV_FO 416F DV_MTO
+416F DEV_CM 07DE R_YEAR 006B R_DATE 4000 ROMST
+4010 DRVENT 4010 DKRWEN 4013 DKCHGE 4016 GTDPBE
+4019 CHOIEN 401C DKFMTE 401F MTOFFE 4022 BASENT
+4025 FORENT 4038 $DOSVE 404B @EXTBI 4080 RAMENT
+4092 C4PBK 40C0 DV_TIR 40E4 @TIME_ 40FD HEADEN
+59AA STATEM 786B DIO_EN 79DC CHG_EN 7A24 DPB_EN
+7A86 CHO_EN 7A94 FMT_EN 7AA2 MOF_EN 4C21 BASIC
+5716 $FORMA 4DDA $MTOFF 4EF6 GSLT1 4176 BIOS_S
+411E _$DOSV 5648 GWRK 410C MAPBIO 417B BIOS_I
+7358 R_DSKI 7348 R_DSKC 7508 R_GETD 750A R_CHOI
+750E R_DSKF 4180 BIOS_O 40FF BNK_ID 4DFA TIMINT
+47D6 INIT 0000 B.MAIN 0001 B.INIT 0002 B.KERN
+0003 B.KANJ 4100 $LOCAL 0001 __TOOM 0002 __NOEM
+0003 __BADD 0004 __INIT 0005 __BHIM 0006 __FMT1
+0007 __FMT2 0008 __STRI 0009 __ABOR 000A __FORM
+000B __PRM1 000C __PRM2 000D __PRM3 000E __ASTS
+000F __SYS_ 0010 __USR_ 4100 MAP_SC 4103 DOSINI
+4106 ROM_MS 4109 ERR_MS 0002 BASVER 0001 BASV_H
+0000 BASV_L FFCF DISINT FFD4 ENAINT 411E DOSV0
+413A _$DSKB 4202 SCANKE 430A SCEND 4725 CHK_DU
+47C3 GETWRK 47D6 $$INIT 47DC BSC 4A0B CLEAN
+4F03 GSLOT2 4F12 GSLOT3 51BE OLDDOS 4BAF NO_TEX
+4CF6 SET_DI 4BD8 REBOOT 580A TO_BAS 4DA4 DSKRW
+4EE9 GSLOT0 53CC DIV16 5715 HOKFMT 5852 ALLOC
+6FE8 BDOS_G 6FEC DOS1_G 0200 R_SECL 58F3 SETHOO
+6E30 READ_B 6D99 TRYBOO 6F6C DB_INI 6980 DBERR
+6985 DBABOR 58AA DEFILE 60E6 BLOAD 6022 BSAVE
+6FAA TIME_I 7BAA DEFDPB 6F43 SBDAVE 6E92 RBSAVE
+6EC6 RBLOAD 58F3 $$BASI 5C09 FDISK 697A BDOSE
+6272 DAC2LO 69FC GETERR 6EC8 TRY_MS 6F7F KABR
+6F8C KDERR
+
+E 6E92 RBSAVE
+6EC6 RBLOAD 58F3 $$BASI 5C09 FDI
\ No newline at end of file
diff --git a/source/kernel/bank0/CPM32.EXE b/source/kernel/bank0/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank0/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank0/L80.CPM b/source/kernel/bank0/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank0/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank0/LIB80.CPM b/source/kernel/bank0/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank0/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank0/M80.CPM b/source/kernel/bank0/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank0/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank0/alloc.mac b/source/kernel/bank0/alloc.mac
index ca2f2bec..288cd63c 100644
--- a/source/kernel/bank0/alloc.mac
+++ b/source/kernel/bank0/alloc.mac
@@ -1,4 +1,5 @@
.z80
+ name('alloc')
title ALLOC - Allocate Memory in Page-3
;
;-----------------------------------------------------------------------
diff --git a/source/kernel/bank0/b0.mac b/source/kernel/bank0/b0.mac
index 0ed6442b..32e2b257 100644
--- a/source/kernel/bank0/b0.mac
+++ b/source/kernel/bank0/b0.mac
@@ -1,6 +1,7 @@
.z80
+ name('b0')
BANK equ 0
;
- include BANK.INC
+ include ../bank.inc
;
end
diff --git a/source/kernel/bank0/bdos.mac b/source/kernel/bank0/bdos.mac
index 0cad21dd..f8c18175 100644
--- a/source/kernel/bank0/bdos.mac
+++ b/source/kernel/bank0/bdos.mac
@@ -1,10 +1,11 @@
.z80
+ name('bdos')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl MSX Environment Setup and BDOS Entry Code
;*****************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;
;-----------------------------------------------------------------------------
;
@@ -157,7 +158,7 @@ TIME_IRQ::
ld (CH_COUNT##),a ; leave it unaltered.
;
ld a,(TIM_TICK##) ;If deferred UD timeout ticks
- cp UD_TMOUT## ; is less than UD_TMOUT
+ cp UD_MEDIA_CHECK_TIMEOUT## ; is less than UD_MEDIA_CHECK_TIMEOUT
adc a,0 ; then increment it, else
ld (TIM_TICK##),a ; leave it unaltered.
;
diff --git a/source/kernel/bank0/dosboot.mac b/source/kernel/bank0/dosboot.mac
index 5d6065d5..02b87c60 100644
--- a/source/kernel/bank0/dosboot.mac
+++ b/source/kernel/bank0/dosboot.mac
@@ -1,10 +1,11 @@
.z80
+ name('dosboot')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl MSX-DOS Booting up code
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;
;-----------------------------------------------------------------------------
;
diff --git a/source/kernel/bank0/doshead.mac b/source/kernel/bank0/doshead.mac
index 5b310f15..e7ebd764 100644
--- a/source/kernel/bank0/doshead.mac
+++ b/source/kernel/bank0/doshead.mac
@@ -1,10 +1,11 @@
.z80
+ name('doshead')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl ROM Header for MSX-DOS 2.0 ROM
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;
;
; This is the ROM header for the MSX-DOS ROM. It must always be linked first
diff --git a/source/kernel/bank0/dskab.mac b/source/kernel/bank0/dskab.mac
index 9c61f934..5744beb0 100644
--- a/source/kernel/bank0/dskab.mac
+++ b/source/kernel/bank0/dskab.mac
@@ -1,4 +1,5 @@
.z80
+ name('dskab')
INCLUDE MACROS.INC
INCLUDE CONST.INC
diff --git a/source/kernel/bank0/dskbasic.mac b/source/kernel/bank0/dskbasic.mac
index f0838b5f..7d981f2e 100644
--- a/source/kernel/bank0/dskbasic.mac
+++ b/source/kernel/bank0/dskbasic.mac
@@ -1,4 +1,5 @@
.z80
+ name('dskbasic')
title DSKBASIC - disk BASIC statement handler -
;
; Conditional assembly switches
diff --git a/source/kernel/bank0/init.mac b/source/kernel/bank0/init.mac
index 365fc339..5e10dc70 100644
--- a/source/kernel/bank0/init.mac
+++ b/source/kernel/bank0/init.mac
@@ -1,10 +1,11 @@
.z80
+ name('init')
title INIT - MSXDOS and DISK BASIC initializer
;===== start add DOS2.50 (build type)
;
- INCLUDE CONDASM.INC
- INCLUDE CONST.INC
+ INCLUDE ../condasm.inc
+ INCLUDE ../const.inc
;
;===== end add DOS2.50
;
@@ -157,7 +158,7 @@ START:
subttl ROM header
if BANKED
- include BANK.INC
+ include ../bank.inc
endif
;
; Version and copyright strings.
@@ -165,10 +166,10 @@ endif
_$DOSVER::
DOSV0::
defb "Nextor kernel version "
- defb NXTVER##+"0", ".", NXTV_HI##+"0"
+ defb MAIN_NEXTOR_VERSION##+"0", ".", SEC_NEXTOR_VERSION_HIGH##+"0"
if 1
- defb ".", NXTV_LO##+"0"
+ defb ".", SEC_NEXTOR_VERSION_LOW##+"0"
endif
INCLUDE betainfo.mac
@@ -977,14 +978,14 @@ VER_CHK:
;
; I am not the first. check to see if I can be the new master.
;
- ld a,(IN_EMU##) ;If in disk emulation mode, disable myself
+ ld a,(IN_EMU_MODE##) ;If in disk emulation mode, disable myself
or a
ret nz
ld a,(NXT_VER##) ;If previous master is MSX-DOS (not Nextor) then I become master.
or a
jr z,MAST_OK
- cp 16*NXTVER##+NXTV_HI## ;If old master is same or newer than I
+ cp 16*MAIN_NEXTOR_VERSION##+SEC_NEXTOR_VERSION_HIGH## ;If old master is same or newer than I
jr nc,SLAVE ; become its slave.
;
MAST_OK:
@@ -1003,9 +1004,9 @@ OVERRIDE:
;
; I am the real master or am overriding the old one.
;
- ld a,99h ;16*DOSVER##+DOSV_HI##
+ ld a,99h ;16*DOSVER##+SEC_DOS_VERSION_HIGH##
ld (DOS_VER##),a ;set new DOS version
- ld a,16*NXTVER##+NXTV_HI##
+ ld a,16*MAIN_NEXTOR_VERSION##+SEC_NEXTOR_VERSION_HIGH##
ld (NXT_VER##),a
;
; Set up hook for clean up procedure
@@ -1059,7 +1060,7 @@ SLAVE:
;PROCNM+6: Number of drives actually assigned
;PROCNM+7: 1 to boot in DOS 1 mode
;PROCNM+8: 1 if device-based driver
- ;IN_EMU: 1 if in disk emulation mode (set by AUTODRV in partit.mac)
+ ;IN_EMU_MODE: 1 if in disk emulation mode (set by AUTODRV in partit.mac)
;PROCNM+10: <>0 if the driver provides configuration
;Calculate how many work area space can be allocated, it will be:
@@ -2623,7 +2624,7 @@ CHECK_1KEY:
;===== start mod DOS2.50 (build type)
jr nz,OLDDOS ;OLDDOS will do the rest of work.
- ld a,(IN_EMU##) ;If in disk emulation mode (set by AUTODRV from DOSINIT),
+ ld a,(IN_EMU_MODE##) ;If in disk emulation mode (set by AUTODRV from DOSINIT),
or a ;switch to DOS 1 mode
jr nz,OLDDOS
@@ -2725,7 +2726,7 @@ endif
;the work area is already created in BUF_1,
;so just jump to area relocation procedure.
- ld a,(IN_EMU##)
+ ld a,(IN_EMU_MODE##)
or a
jr nz,MK_EMU_TBL
@@ -2749,7 +2750,7 @@ MK_EMU_TBL:
;then just copy from BUF_1 to it.
;Otherwise allocate space in page 3.
- ld hl,(EMU_WK_AREA##)
+ ld hl,(EMU_WORK_AREA_ADDRESS##)
ld a,h
or l
jr nz,OK_EMU_WK
@@ -3113,7 +3114,7 @@ VERIFY: CALLDOS 2Eh ;Set/reset verify flag
BSEC_TYPE:
;1) Check for "VOL_ID", if found, return type 1
- ld hl,BOOTAD + UPB_VOLID##
+ ld hl,BOOTAD + UPB_VOLUME_ID##
ld de,VID_STR
ld b,6
call CP_FLSTR
@@ -3122,7 +3123,7 @@ BSEC_TYPE:
;2) Check for sector count >65535, if so, return type 2
- ld hl,BOOTAD + UPB_SEC##
+ ld hl,BOOTAD + UPB_TOTAL_SECTORS##
ld a,(hl)
inc hl
or (hl)
@@ -3131,12 +3132,12 @@ BSEC_TYPE:
;3) Check for EBS, if found, return type 2
- ld a,(BOOTAD + UPB_EBS##)
+ ld a,(BOOTAD + UPB_EXTENDED_SIGNATURE##)
and 028h
cp 028h
jr nz,NOEBS
- ld hl,BOOTAD + UPB_FILESYS##
+ ld hl,BOOTAD + UPB_FILESYSTEM##
ld de,FAT_STR
ld b,4
call CP_FLSTR
diff --git a/source/kernel/bank0/ramdrv.mac b/source/kernel/bank0/ramdrv.mac
index fc414740..c68b2982 100644
--- a/source/kernel/bank0/ramdrv.mac
+++ b/source/kernel/bank0/ramdrv.mac
@@ -1,10 +1,11 @@
.z80
+ name('ramdrv')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl RAM disk driver
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;
SLOT_REG equ 0A8h
;
@@ -19,12 +20,12 @@ R_SECLEN equ 512 ;Sector size is always 512.
R_DSKCHG::
;
; This is the "media check" function. It always returns "not changed" if
-; the "UPB_VOLID" byte of the boot sector is "V", otherwise it returns "disk
+; the "UPB_VOLUME_ID" byte of the boot sector is "V", otherwise it returns "disk
; changed" as this will force a "BUILD_UPB" function call and the next read
; will re-build the UPB in the boot sector.
;
;
- ld hl,RD_BOOT##+UPB_VOLID##
+ ld hl,RD_BOOT##+UPB_VOLUME_ID##
ld a,(DATA_SEG##)
call RD_SEG##
cp "V"
@@ -81,7 +82,7 @@ endif
ld (RD_SCNT##),a ;Save sector count.
;
ex af,af' ;Read write flag -> carry'
- ld hl,RD_BOOT##+UPB_VOLID##
+ ld hl,RD_BOOT##+UPB_VOLUME_ID##
ld a,(DATA_SEG##)
call RD_SEG## ;If no UPB currently exists
ei
@@ -331,7 +332,7 @@ MAKE_UPB:
ret
;
make_upb_ok: exx
- ld hl,RD_BOOT##+UPB_SSZ##
+ ld hl,RD_BOOT##+UPB_SECTOR_SIZE##
ld (hl),low 512
inc hl ;Sector size is 512 bytes
ld (hl),high 512
@@ -423,7 +424,7 @@ endif
inc hl
;
ld hl,RAMDISK_VOLID ;Copy the fixed volume
- ld de,RD_BOOT##+UPB_VOLID## ; id and dirt disk flag
+ ld de,RD_BOOT##+UPB_VOLUME_ID## ; id and dirt disk flag
ld bc,RAMDISK_VEND-RAMDISK_VOLID ; from below into the
ldir ; boot sector.
;
diff --git a/source/kernel/bank1/CPM32.EXE b/source/kernel/bank1/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank1/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank1/L80.CPM b/source/kernel/bank1/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank1/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank1/LIB80.CPM b/source/kernel/bank1/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank1/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank1/M80.CPM b/source/kernel/bank1/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank1/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank1/b1.mac b/source/kernel/bank1/b1.mac
index 81337113..32714247 100644
--- a/source/kernel/bank1/b1.mac
+++ b/source/kernel/bank1/b1.mac
@@ -1,7 +1,8 @@
.z80
+ name('b1')
BANK equ 1
;
- include BANK.INC
- include B0LABELS.INC
+ include ../bank.inc
+ include ../bank0/b0labels.inc
;
end
diff --git a/source/kernel/bank1/dosinit.mac b/source/kernel/bank1/dosinit.mac
index 5223938a..3ac53654 100644
--- a/source/kernel/bank1/dosinit.mac
+++ b/source/kernel/bank1/dosinit.mac
@@ -1,11 +1,12 @@
.z80
+ name('dosinit')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl ROM Resident Part of Kernel Initialisation
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
- INCLUDE CONDASM.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
+ INCLUDE ../condasm.inc
MAXDRV equ 8 ;max number of drives supported by disk
DRVTBL equ 0FB21h
@@ -1563,7 +1564,7 @@ _U_CALLRAM:
ex af,af
... < call _GET_P1 >
push af
- ld_a_iyl
+ ld a,iyl
... < call _PUT_P1 >
ex af,af
call CALSLT##
@@ -1650,7 +1651,7 @@ _U_CALLRAM2:
dec ix
dec ix
push ix
- ld_iyl_e
+ ld iyl,e
ld a,d
and 00111111b
@@ -1674,7 +1675,7 @@ _U_CALLRAM2:
ld bc,(MAP_TAB##)
add hl,bc
ld a,(hl) ;A = Slot to call
- ld_iyh_a
+ ld iyh,a
ex af,af'
exx
diff --git a/source/kernel/bank1/mapinit.mac b/source/kernel/bank1/mapinit.mac
index 22d68ca2..68a225bf 100644
--- a/source/kernel/bank1/mapinit.mac
+++ b/source/kernel/bank1/mapinit.mac
@@ -1,11 +1,12 @@
.z80
+ name('mapinit')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl Mapper Initialisation
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
- INCLUDE CONDASM.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
+ INCLUDE ../condasm.inc
;
P0_REG equ 0FCh
P1_REG equ 0FDh
diff --git a/source/kernel/bank1/msg.mac b/source/kernel/bank1/msg.mac
index 55cebc1d..ad323722 100644
--- a/source/kernel/bank1/msg.mac
+++ b/source/kernel/bank1/msg.mac
@@ -1,4 +1,5 @@
- .z80
+ .z80
+ name('msg')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl Messages for disk ROM
;-----------------------------------------------------------------------------
@@ -258,7 +259,7 @@ ERR_MSG_TABLE:
; useful to return some of these errors.
;
err .BADCOM,<"Wrong version of command">
- err .BADCM, <"Unrecognized command">
+ err .BADCMD,<"Unrecognized command">
err .BUFUL, <"Command too long">
;
err .IPARM, <"Invalid parameter">
@@ -285,200 +286,170 @@ ERR_MSG_TABLE:
;
msg_num defl 0
;
-msg macro name,text
- local length,start ;;Macro to assign mesage numbers,
-msg_num defl msg_num+1 ;; declare them external, and add the
-__&name equ msg_num ;; message to the message table.
- public __&name
- defb __&name
- defb length
-start: defb text
- defb 0
-length equ $-start
- endm
;
; ----------------------------------------
;
ROM_KMSG_TABLE:
;
- ;msg NORAM, <"ƒƒ‚ƒŠ‚ª‘«‚è‚Ü‚¹‚ñ">
+ .strenc shift_jis
+
+ ;msg NORAM, <"メモリãŒè¶³ã‚Šã¾ã›ã‚“">
;msg TOOMD, <"Driver table is corrupted:",13,10,"Too many drives allocated">
- msg TOOMD, <"ƒhƒ‰ƒCƒo‚̃e[ƒuƒ‹‚ª‰ó‚ê‚Ä‚¢‚Ü‚·:",13,10,"ƒhƒ‰ƒCƒu‚ÌŠ„‚è“–‚Ä‚ª‘½‚·‚¬‚Ü‚·">
+ msg TOOMD, <"ドライãƒã®ãƒ†ãƒ¼ãƒ–ルãŒå£Šã‚Œã¦ã„ã¾ã™:",13,10,"ドライブã®å‰²ã‚Šå½“ã¦ãŒå¤šã™ãŽã¾ã™">
;msg NOEMP, <"Driver table is corrupted:",13,10,"Unexpected non-empty",13,10,"entry found">
- msg NOEMP, <"ƒhƒ‰ƒCƒo‚̃e[ƒuƒ‹‚ª‰ó‚ê‚Ä‚¢‚Ü‚·:",13,10,"—\‘zŠO‚Ì”ñ‹ó‚̃Gƒ“ƒgƒŠ‚ªŒ©‚‚©‚è‚Ü‚µ‚½">
+ msg NOEMP, <"ドライãƒã®ãƒ†ãƒ¼ãƒ–ルãŒå£Šã‚Œã¦ã„ã¾ã™:",13,10,"予想外ã®éžç©ºã®ã‚¨ãƒ³ãƒˆãƒªãŒè¦‹ã¤ã‹ã‚Šã¾ã—ãŸ">
;msg BADDI, <"Boot error: disk controller",13,10,"ID does not match size of",13,10,"driver table">
- msg BADDI, <"‹N“®ƒGƒ‰[F",13,10,"ƒfƒBƒXƒNƒRƒ“ƒgƒ[ƒ‰”Ô†ƒhƒ‰ƒCƒo[ƒe[ƒuƒ‹‚̃TƒCƒY‚ƈê’v‚µ‚Ü‚¹‚ñ">
+ msg BADDI, <"起動エラー:",13,10,"ディスクコントãƒãƒ¼ãƒ©ç•ªå·ãƒ‰ãƒ©ã‚¤ãƒãƒ¼ãƒ†ãƒ¼ãƒ–ルã®ã‚µã‚¤ã‚ºã¨ä¸€è‡´ã—ã¾ã›ã‚“">
;msg INITE, <"Boot error:",13,10,"Kernel initialization code",13,10,"failed, code: ">
- msg INITE, <"‹N“®ƒGƒ‰[F",13,10,"ƒJ[ƒlƒ‹‚̉Šú‰»ƒR[ƒh‚ÉŽ¸”s‚µ‚Ü‚µ‚½B ƒR[ƒh: ">
+ msg INITE, <"起動エラー:",13,10,"カーãƒãƒ«ã®åˆæœŸåŒ–コードã«å¤±æ•—ã—ã¾ã—ãŸã€‚ コード: ">
;msg BHIM, <"Boot error:",13,10,"Not enough memory for",13,10,"BASIC variables">
- msg BHIM, <"‹N“®ƒGƒ‰[F",13,10,"BASIC•Ï”‚̃ƒ‚ƒŠ‚ª‘«‚è‚Ü‚¹‚ñ">
+ msg BHIM, <"起動エラー:",13,10,"BASIC変数ã®ãƒ¡ãƒ¢ãƒªãŒè¶³ã‚Šã¾ã›ã‚“">
;
- msg FMT1, <"ƒhƒ‰ƒCƒu–¼‚Í? (">
+ msg FMT1, <"ドライブåã¯? (">
msg FMT2, <") ">
- msg STRIKE, <"‰½‚©ƒL[‚ð‰Ÿ‚µ‚ĉº‚³‚¢ ">
- msg ABORT, <"‘Å‚¿Ø‚ç‚ê‚Ü‚µ‚½">
- msg FORMAT, <"ƒtƒH[ƒ}ƒbƒg‚ªŠ®—¹‚µ‚Ü‚µ‚½">
+ msg STRIKE, <"何ã‹ã‚ーを押ã—ã¦ä¸‹ã•ã„ ">
+ msg ABORT, <"打ã¡åˆ‡ã‚‰ã‚Œã¾ã—ãŸ">
+ msg FORMAT, <"フォーマットãŒå®Œäº†ã—ã¾ã—ãŸ">
;
- msg PRM1, <"ƒhƒ‰ƒCƒu">
- msg PRM2, <":—p‚̃fƒBƒXƒN‚ð“ü‚ê‚Ä">
- msg PRM3, <"‰½‚©ƒL[‚ð‰Ÿ‚µ‚ĉº‚³‚¢">
+ msg PRM1, <"ドライブ">
+ msg PRM2, <":用ã®ãƒ‡ã‚£ã‚¹ã‚¯ã‚’入れã¦">
+ msg PRM3, <"何ã‹ã‚ーを押ã—ã¦ä¸‹ã•ã„">
;
msg ASTS, <"*** ">
;
- msg SYS_ER, <"ƒVƒXƒeƒ€ƒGƒ‰[ ">
- msg USR_ER, <"ƒ†[ƒU[ƒGƒ‰[ ">
+ msg SYS_ER, <"システムエラー ">
+ msg USR_ER, <"ユーザーエラー ">
;
defb 0 ;End of table
;
;
;-----------------------------------------------------------------------------
;
-warn macro text
- if1
- .printx % text
- endif
- endm
-;
-;
-err macro code,text
- local start,length
- defb code#
- defb length
-start: defb text
- defb 0
-length equ $-start
- if1
- if length gt 64
- warn
- endif
- endif
- endm
-;
-; ----------------------------------------
-;
ERR_KMSG_TABLE:
;
; The following errors are those which a disk error routine may normally
; expect to be passed, although such a routine should be general enough to
; handle any error code.
;
- err .NCOMP, <"‚±‚̃fƒBƒXƒN‚ÍŽg—p‚Å‚«‚Ü‚¹‚ñ">
- err .WRERR, <"‘‚«ž‚݈Ùí‚Å‚·">
- err .DISK, <"ƒfƒBƒXƒN‚ªˆÙí‚Å‚·">
- err .NRDY, <"ƒfƒBƒXƒN‚ª“ü‚Á‚Ä‚¢‚Ü‚¹‚ñ">
- err .VERFY, <"³‚µ‚‘‚«ž‚Ü‚ê‚Ü‚¹‚ñ‚Å‚µ‚½">
- err .DATA, <"ƒfƒBƒXƒN‚̃f[ƒ^‚ªˆÙí‚Å‚·">
- err .RNF, <"ƒZƒNƒ^[‚ªŒ©‚‚©‚è‚Ü‚¹‚ñ">
- err .WPROT, <"ƒfƒBƒXƒN‚ª‘‚«ž‚ݕی삳‚ê‚Ä‚¢‚Ü‚·">
- err .UFORM, <"ƒfƒBƒXƒN‚ªƒtƒH[ƒ}ƒbƒg‚³‚ê‚Ä‚¢‚Ü‚¹‚ñ">
- err .NDOS, <"MSX-DOSƒfƒBƒXƒN‚Å‚Í‚ ‚è‚Ü‚¹‚ñ">
- err .WDISK, <"ƒfƒBƒXƒN‚ªˆá‚¢‚Ü‚·">
- err .WFILE, <"‚±‚̃tƒ@ƒCƒ‹—p‚̃fƒBƒXƒN‚Å‚Í‚ ‚è‚Ü‚¹‚ñ">
- err .SEEK, <"ƒV[ƒNƒGƒ‰[‚Å‚·">
- err .IFAT, <"FATˆÙí‚Å‚·">
- err .IFORM, <"‚±‚̃hƒ‰ƒCƒu‚̓tƒH[ƒ}ƒbƒg‚Å‚«‚Ü‚¹‚ñ">
+ err .NCOMP, <"ã“ã®ãƒ‡ã‚£ã‚¹ã‚¯ã¯ä½¿ç”¨ã§ãã¾ã›ã‚“">
+ err .WRERR, <"書ãè¾¼ã¿ç•°å¸¸ã§ã™">
+ err .DISK, <"ディスクãŒç•°å¸¸ã§ã™">
+ err .NRDY, <"ディスクãŒå…¥ã£ã¦ã„ã¾ã›ã‚“">
+ err .VERFY, <"æ£ã—ã書ãè¾¼ã¾ã‚Œã¾ã›ã‚“ã§ã—ãŸ">
+ err .DATA, <"ディスクã®ãƒ‡ãƒ¼ã‚¿ãŒç•°å¸¸ã§ã™">
+ err .RNF, <"セクターãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“">
+ err .WPROT, <"ディスクãŒæ›¸ãè¾¼ã¿ä¿è·ã•ã‚Œã¦ã„ã¾ã™">
+ err .UFORM, <"ディスクãŒãƒ•ã‚©ãƒ¼ãƒžãƒƒãƒˆã•ã‚Œã¦ã„ã¾ã›ã‚“">
+ err .NDOS, <"MSX-DOSディスクã§ã¯ã‚ã‚Šã¾ã›ã‚“">
+ err .WDISK, <"ディスクãŒé•ã„ã¾ã™">
+ err .WFILE, <"ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«ç”¨ã®ãƒ‡ã‚£ã‚¹ã‚¯ã§ã¯ã‚ã‚Šã¾ã›ã‚“">
+ err .SEEK, <"シークエラーã§ã™">
+ err .IFAT, <"FAT異常ã§ã™">
+ err .IFORM, <"ã“ã®ãƒ‰ãƒ©ã‚¤ãƒ–ã¯ãƒ•ã‚©ãƒ¼ãƒžãƒƒãƒˆã§ãã¾ã›ã‚“">
;
;
; The following errors are those which may be returned by KBDOS functions.
;
- err .INTER, <"DOS‚ªˆÙí‚Å‚·">
-;
- err .NORAM, <"ƒƒ‚ƒŠ[•s‘«‚Å‚·">
- err .IBDOS, <"–³Œø‚ÈMSX-DOSƒtƒ@ƒ“ƒNƒVƒ‡ƒ“”Ô†‚Å‚·">
-;
- err .IDRV, <"–³Œø‚ȃhƒ‰ƒCƒu–¼‚Å‚·">
- err .IFNM, <"•s³‚ȃtƒ@ƒCƒ‹–¼‚Å‚·">
- err .IPATH, <"–³Œø‚ȃpƒX–¼‚Å‚·">
- err .PLONG, <"ƒpƒX–¼‚ª’·‰ß‚¬‚Ü‚·">
-;
- err .NOFIL, <"ƒtƒ@ƒCƒ‹‚ªŒ©‚‚©‚è‚Ü‚¹‚ñ">
- err .NODIR, <"ƒfƒBƒŒƒNƒgƒŠ‚ªŒ©‚‚©‚è‚Ü‚¹‚ñ">
- err .DRFUL, <"ƒ‹[ƒgƒfƒBƒŒƒNƒgƒŠ‚ª‚¢‚Á‚Ï‚¢‚Å‚·">
- err .DKFUL, <"ƒfƒBƒXƒN‚ª‚¢‚Á‚Ï‚¢‚Å‚·">
- err .DUPF, <"ƒtƒ@ƒCƒ‹–¼‚ªd•¡‚µ‚Ä‚¢‚Ü‚·">
- err .DIRE, <"ƒfƒBƒŒƒNƒgƒŠ‚ªˆÚ“®‚Å‚«‚Ü‚¹‚ñ">
- err .FILRO, <"ƒtƒ@ƒCƒ‹‚ª“Ç‚Ýo‚µê—p‚Å‚·">
- err .DIRNE, <"ƒfƒBƒŒƒNƒgƒŠ‚ª‹ó‚Å‚Í‚ ‚è‚Ü‚¹‚ñ">
- err .IATTR, <"–³Œø‚È‘®«‚Å‚·">
- err .DOT, <".‚â..‚ɑ΂µ‚Ä‚Í‘€ì‚Å‚«‚Ü‚¹‚ñ">
- err .SYSX, <"ƒVƒXƒeƒ€ƒtƒ@ƒCƒ‹‚ªŠù‚É‚ ‚è‚Ü‚·">
- err .DIRX, <"ƒfƒBƒŒƒNƒgƒŠ‚ªŠù‚É‚ ‚è‚Ü‚·">
- err .FILEX, <"ƒtƒ@ƒCƒ‹‚ªŠù‚É‚ ‚è‚Ü‚·">
- err .FOPEN, <"ƒtƒ@ƒCƒ‹‚ªŽg—p’†‚Å‚·">
-;
- err .OV64K, <"64K‚ð‰z‚¦‚é“]‘—‚Í‚Å‚«‚Ü‚¹‚ñ">
- err .FILE, <"ƒtƒ@ƒCƒ‹‚ÌŠ„“–ˆÙí‚Å‚·">
- err .EOF, <"ƒtƒ@ƒCƒ‹‚ÌI‚í‚è‚Å‚·">
- err .ACCV, <"ƒtƒ@ƒCƒ‹ƒAƒNƒZƒXˆÙí‚Å‚·">
-;
- err .IPROC, <"–³Œø‚ȃvƒƒZƒXID‚Å‚·">
- err .NHAND, <"ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹‚ª‘«‚è‚Ü‚¹‚ñ">
- err .IHAND, <"–³Œø‚ȃtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹‚Å‚·">
- err .NOPEN, <"ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹‚ªƒI[ƒvƒ“‚³‚ê‚Ä‚¢‚Ü‚¹‚ñ">
- err .IDEV, <"–³Œø‚ȃfƒoƒCƒXƒIƒyƒŒ[ƒVƒ‡ƒ“‚Å‚·">
-;
- err .IENV, <"–³Œø‚Ȋ‹«•Ï”‚Å‚·">
- err .ELONG, <"ŠÂ‹«•Ï”‚ª’·‰ß‚¬‚Ü‚·">
-;
- err .IDATE, <"–³Œø‚È“ú•t‚¯‚Å‚·">
- err .ITIME, <"–³Œø‚ÈŽžŠÔ‚Å‚·">
-;
- err .RAMDX, <"RAM DISK(ƒhƒ‰ƒCƒuH:)‚ÍŠù‚É‚ ‚è‚Ü‚·">
- err .NRAMD, <"RAM DISK‚ª‚ ‚è‚Ü‚¹‚ñ">
-;
- err .HDEAD, <"ƒtƒ@ƒCƒ‹‚ªÁ‹Ž‚³‚ê‚Ä‚¢‚Ü‚·">
- err .ISBFN, <"–³Œø‚ȃTƒuƒtƒ@ƒ“ƒNƒVƒ‡ƒ“”Ô†‚Å‚·">
- err .IFCB, <"–³Œø‚ÈFCB‚Å‚·">
+ err .INTER, <"DOSãŒç•°å¸¸ã§ã™">
+;
+ err .NORAM, <"メモリーä¸è¶³ã§ã™">
+ err .IBDOS, <"無効ãªMSX-DOSファンクション番å·ã§ã™">
+;
+ err .IDRV, <"無効ãªãƒ‰ãƒ©ã‚¤ãƒ–åã§ã™">
+ err .IFNM, <"ä¸æ£ãªãƒ•ã‚¡ã‚¤ãƒ«åã§ã™">
+ err .IPATH, <"無効ãªãƒ‘スåã§ã™">
+ err .PLONG, <"パスåãŒé•·éŽãŽã¾ã™">
+;
+ err .NOFIL, <"ファイルãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“">
+ err .NODIR, <"ディレクトリãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“">
+ err .DRFUL, <"ルートディレクトリãŒã„ã£ã±ã„ã§ã™">
+ err .DKFUL, <"ディスクãŒã„ã£ã±ã„ã§ã™">
+ err .DUPF, <"ファイルåãŒé‡è¤‡ã—ã¦ã„ã¾ã™">
+ err .DIRE, <"ディレクトリãŒç§»å‹•ã§ãã¾ã›ã‚“">
+ err .FILRO, <"ファイルãŒèªã¿å‡ºã—専用ã§ã™">
+ err .DIRNE, <"ディレクトリãŒç©ºã§ã¯ã‚ã‚Šã¾ã›ã‚“">
+ err .IATTR, <"無効ãªå±žæ€§ã§ã™">
+ err .DOT, <".ã‚„..ã«å¯¾ã—ã¦ã¯æ“作ã§ãã¾ã›ã‚“">
+ err .SYSX, <"システムファイルãŒæ—¢ã«ã‚ã‚Šã¾ã™">
+ err .DIRX, <"ディレクトリãŒæ—¢ã«ã‚ã‚Šã¾ã™">
+ err .FILEX, <"ファイルãŒæ—¢ã«ã‚ã‚Šã¾ã™">
+ err .FOPEN, <"ファイルãŒä½¿ç”¨ä¸ã§ã™">
+;
+ err .OV64K, <"64Kを越ãˆã‚‹è»¢é€ã¯ã§ãã¾ã›ã‚“">
+ err .FILE, <"ファイルã®å‰²å½“異常ã§ã™">
+ err .EOF, <"ファイルã®çµ‚ã‚ã‚Šã§ã™">
+ err .ACCV, <"ファイルアクセス異常ã§ã™">
+;
+ err .IPROC, <"無効ãªãƒ—ãƒã‚»ã‚¹IDã§ã™">
+ err .NHAND, <"ファイルãƒãƒ³ãƒ‰ãƒ«ãŒè¶³ã‚Šã¾ã›ã‚“">
+ err .IHAND, <"無効ãªãƒ•ã‚¡ã‚¤ãƒ«ãƒãƒ³ãƒ‰ãƒ«ã§ã™">
+ err .NOPEN, <"ファイルãƒãƒ³ãƒ‰ãƒ«ãŒã‚ªãƒ¼ãƒ—ンã•ã‚Œã¦ã„ã¾ã›ã‚“">
+ err .IDEV, <"無効ãªãƒ‡ãƒã‚¤ã‚¹ã‚ªãƒšãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã§ã™">
+;
+ err .IENV, <"無効ãªç’°å¢ƒå¤‰æ•°ã§ã™">
+ err .ELONG, <"環境変数ãŒé•·éŽãŽã¾ã™">
+;
+ err .IDATE, <"無効ãªæ—¥ä»˜ã‘ã§ã™">
+ err .ITIME, <"無効ãªæ™‚é–“ã§ã™">
+;
+ err .RAMDX, <"RAM DISK(ドライブH:)ã¯æ—¢ã«ã‚ã‚Šã¾ã™">
+ err .NRAMD, <"RAM DISKãŒã‚ã‚Šã¾ã›ã‚“">
+;
+ err .HDEAD, <"ファイルãŒæ¶ˆåŽ»ã•ã‚Œã¦ã„ã¾ã™">
+ err .ISBFN, <"無効ãªã‚µãƒ–ファンクション番å·ã§ã™">
+ err .IFCB, <"無効ãªFCBã§ã™">
;TODO: Check these translations
- err .IDRVR, <"–³Œø‚ȃfƒBƒXƒNƒhƒ‰ƒCƒo‚Å‚·"> ;<"Invalid disk driver">
- err .IDEVL, <"–³Œø‚ȃfƒoƒCƒX‚Ü‚½‚͘_—ƒ†ƒjƒbƒg‚Å‚·"> ;<"Invalid device or logical unit">
- err .IPART, <"–³Œø‚ȃp[ƒeƒBƒVƒ‡ƒ“”Ô†"> ;<"Invalid partition number">
- err .PUSED, <"ƒp[ƒeƒBƒVƒ‡ƒ“‚ªŽg—p’†‚Å‚·"> ;<"Partition is already in use">
- err .FMNT, <"ƒtƒ@ƒCƒ‹‚ªƒ}ƒEƒ“ƒg‚³‚ê‚Ä‚¢‚Ü‚·"> ;<"File is mounted">
- err .BFSZ, <"–³Œø‚ȃtƒ@ƒCƒ‹ƒTƒCƒY"> ;<"Bad file size">
- err .ICLUS, <"–³Œø‚ȃNƒ‰ƒXƒ^[”Ô†‚Ü‚½‚̓V[ƒPƒ“ƒX"> ;<"Invalid cluster number or sequence">
+ err .IDRVR, <"無効ãªãƒ‡ã‚£ã‚¹ã‚¯ãƒ‰ãƒ©ã‚¤ãƒã§ã™"> ;<"Invalid disk driver">
+ err .IDEVL, <"無効ãªãƒ‡ãƒã‚¤ã‚¹ã¾ãŸã¯è«–ç†ãƒ¦ãƒ‹ãƒƒãƒˆã§ã™"> ;<"Invalid device or logical unit">
+ err .IPART, <"無効ãªãƒ‘ーティション番å·"> ;<"Invalid partition number">
+ err .PUSED, <"パーティションãŒä½¿ç”¨ä¸ã§ã™"> ;<"Partition is already in use">
+ err .FMNT, <"ファイルãŒãƒžã‚¦ãƒ³ãƒˆã•ã‚Œã¦ã„ã¾ã™"> ;<"File is mounted">
+ err .BFSZ, <"無効ãªãƒ•ã‚¡ã‚¤ãƒ«ã‚µã‚¤ã‚º"> ;<"Bad file size">
+ err .ICLUS, <"無効ãªã‚¯ãƒ©ã‚¹ã‚¿ãƒ¼ç•ªå·ã¾ãŸã¯ã‚·ãƒ¼ã‚±ãƒ³ã‚¹"> ;<"Invalid cluster number or sequence">
;
;
; The following are errors which the KBDOS may pass to the ABORT routine.
; Of cource a user abort routine may see any other error but these are the
; ones which are generated internally and may require special case handling.
;
- err .STOP, <"Ctrl-STOP‚ª‰Ÿ‚³‚ê‚Ü‚µ‚½">
- err .CTRLC, <"Ctrl-C‚ª‰Ÿ‚³‚ê‚Ü‚µ‚½">
- err .ABORT, <"ƒfƒBƒXƒN“üo—Í‚ª‘Å‚¿Ø‚ç‚ê‚Ü‚µ‚½">
- err .OUTERR,<"•W€o—͂ŃGƒ‰[‚ª‹N‚«‚Ü‚µ‚½">
- err .INERR, <"•W€“ü—͂ŃGƒ‰[‚ª‹N‚«‚Ü‚µ‚½">
+ err .STOP, <"Ctrl-STOPãŒæŠ¼ã•ã‚Œã¾ã—ãŸ">
+ err .CTRLC, <"Ctrl-CãŒæŠ¼ã•ã‚Œã¾ã—ãŸ">
+ err .ABORT, <"ディスク入出力ãŒæ‰“ã¡åˆ‡ã‚‰ã‚Œã¾ã—ãŸ">
+ err .OUTERR,<"標準出力ã§ã‚¨ãƒ©ãƒ¼ãŒèµ·ãã¾ã—ãŸ">
+ err .INERR, <"標準入力ã§ã‚¨ãƒ©ãƒ¼ãŒèµ·ãã¾ã—ãŸ">
;
;
; The following errors are those generated by COMMAND.COM. These will not
; be returned from KBDOS functions, but user application programs may find it
; useful to return some of these errors.
;
- err .BADCOM,<"ƒRƒ}ƒ“ƒh‚̃o[ƒWƒ‡ƒ“‚ªˆá‚¢‚Ü‚·">
- err .BADCMD,<"ƒRƒ}ƒ“ƒh‚ªˆá‚¢‚Ü‚·">
- err .BUFUL, <"ƒRƒ}ƒ“ƒh‚ª’·‚·‚¬‚Ü‚·">
+ err .BADCOM,<"コマンドã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒé•ã„ã¾ã™">
+ err .BADCMD,<"コマンドãŒé•ã„ã¾ã™">
+ err .BUFUL, <"コマンドãŒé•·ã™ãŽã¾ã™">
;
- err .IPARM, <"–³Œø‚ȃpƒ‰ƒ[ƒ^‚Å‚·">
- err .INP, <"ƒpƒ‰ƒ[ƒ^‚ª‘½‚·‚¬‚Ü‚·">
- err .NOPAR, <"ƒpƒ‰ƒ[ƒ^‚ª•s‘«‚µ‚Ä‚¢‚Ü‚·">
- err .IOPT, <"–³Œø‚ȃIƒvƒVƒ‡ƒ“Žw’è‚Å‚·">
- err .BADNO, <"–³Œø‚È”’l‚Å‚·">
+ err .IPARM, <"無効ãªãƒ‘ラメータã§ã™">
+ err .INP, <"パラメータãŒå¤šã™ãŽã¾ã™">
+ err .NOPAR, <"パラメータãŒä¸è¶³ã—ã¦ã„ã¾ã™">
+ err .IOPT, <"無効ãªã‚ªãƒ—ション指定ã§ã™">
+ err .BADNO, <"無効ãªæ•°å€¤ã§ã™">
;
- err .NOHELP,<"HELPƒtƒ@ƒCƒ‹‚ªŒ©‚‚©‚è‚Ü‚¹‚ñ">
- err .BADVER,<"MSX-DOS‚̃o[ƒWƒ‡ƒ“‚ªˆá‚¢‚Ü‚·">
+ err .NOHELP,<"HELPファイルãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“">
+ err .BADVER,<"MSX-DOSã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ãŒé•ã„ã¾ã™">
;
- err .NOCAT, <"•¡ŽÊæƒtƒ@ƒCƒ‹‚ÍŒ‹‡‚Å‚«‚Ü‚¹‚ñ">
- err .BADEST,<"ƒtƒ@ƒCƒ‹‚ð쬂ł«‚Ü‚¹‚ñ">
- err .COPY, <"Ž©•ªŽ©g‚ɂ̓Rƒs[‚Å‚«‚Ü‚¹‚ñ">
- err .OVDEST,<"ƒtƒ@ƒCƒ‹‚Ìd‚Ë‘‚«‚ª‚Å‚«‚Ü‚¹‚ñ">
+ err .NOCAT, <"複写先ファイルã¯çµåˆã§ãã¾ã›ã‚“">
+ err .BADEST,<"ファイルを作æˆã§ãã¾ã›ã‚“">
+ err .COPY, <"自分自身ã«ã¯ã‚³ãƒ”ーã§ãã¾ã›ã‚“">
+ err .OVDEST,<"ファイルã®é‡ã書ããŒã§ãã¾ã›ã‚“">
;
- err .INSDSK,<"MSX-DOS2 ‚̃fƒBƒXƒN‚ðƒhƒ‰ƒCƒu ",7,": ‚É“ü‚ê‚Ä">
- err .PRAK, <"‰½‚©ƒL[‚ð‰Ÿ‚µ‚ĉº‚³‚¢ ">
+ err .INSDSK,<"MSX-DOS2 ã®ãƒ‡ã‚£ã‚¹ã‚¯ã‚’ドライブ ",7,": ã«å…¥ã‚Œã¦">
+ err .PRAK, <"何ã‹ã‚ーを押ã—ã¦ä¸‹ã•ã„ ">
;
defb 0 ;End of table
+
+ .strenc default
;
;
;-----------------------------------------------------------------------------
diff --git a/source/kernel/bank2/CPM32.EXE b/source/kernel/bank2/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank2/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank2/L80.CPM b/source/kernel/bank2/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank2/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank2/LIB80.CPM b/source/kernel/bank2/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank2/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank2/M80.CPM b/source/kernel/bank2/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank2/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank2/b2.mac b/source/kernel/bank2/b2.mac
index fac5a257..b8a78a38 100644
--- a/source/kernel/bank2/b2.mac
+++ b/source/kernel/bank2/b2.mac
@@ -1,7 +1,8 @@
.z80
+ name('b2')
BANK equ 2
;
- include BANK.INC
- include B0LABELS.INC
+ include ../bank.inc
+ include ../bank0/b0labels.inc
;
end
diff --git a/source/kernel/bank2/buf.mac b/source/kernel/bank2/buf.mac
index f026fafe..3be23d89 100644
--- a/source/kernel/bank2/buf.mac
+++ b/source/kernel/bank2/buf.mac
@@ -1,10 +1,11 @@
.z80
+ name('buf')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Sector Buffer Handling
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -12,7 +13,7 @@
; This routine gets a given sector from a given unit number into a buffer.
; It has two entry points, one for normal sectors and one for FAT sectors.
; The FAT sector entry point ("BF_FAT_SECTOR") sets up the number of copies to
-; read to UD_NFAT if the disk is clean and UD_NFAT-1 if the disk is dirty.
+; read to UD_NUMBER_OF_FATS if the disk is clean and UD_NUMBER_OF_FATS-1 if the disk is dirty.
; The normal sector entry point ("BF_SECTOR") always sets the number of copies
; to one.
;
@@ -40,9 +41,9 @@
; Preserves: DE,IX,AF',BC',DE',HL'
; Corrupts: AF,BC,HL
;
-; Assumes: BD_LINK=0 BD_UNIT=2 BD_FLAGS=3 BD_SECT=4
-; BD_COPY=6 BD_SEP=7 BD_UD=9 BD_DATA=11
-; BD_EX_SECT=8
+; Assumes: BD_NEXT_DESC_ADDRESS=0 BD_PHYSICAL_UNIT_NUMBER=2 BD_FLAGS=3 BD_SECTOR_NUMBER=4
+; BD_NUMBER_OF_COPIES=6 BD_SECTORS_BETWEEN_COPIES=7 BD_UNIT_DESCRIPTOR_ADDRESS=9 BD_DATA=11
+; BD_EX_SECTOR_NUMBER=8
;
;
PROC BF_FAT_SECTOR
@@ -51,8 +52,8 @@
ld bc,0100h ;B = Flag read required & no ignore / C = 0 (sector number (bit16-22))
;; ld b,1
;===== end mod FAT16
- ld a,(ix+UD_NFAT##) ;If disk is clean then set
- bit 0,(ix+UD_DIRT##) ; number of copies to UD_NFAT
+ ld a,(ix+UD_NUMBER_OF_FATS##) ;If disk is clean then set
+ bit 0,(ix+UD_DIRTY_DISK_FLAG##) ; number of copies to UD_NUMBER_OF_FATS
jr z,bf_a_copies ; (all copies of the FAT).
dec a ;If dirty disk, read one less
jr nz,bf_a_copies ; copy, unless there is only
@@ -76,8 +77,8 @@ bf_a_copies: ld (READ_COPIES##),a ;Remember number of copies
ld a,h
sub 1 ;If cache<>0 then test if it
ld a,c ;A := sector number (bit16-22)
- ld c,(ix+UD_PHYS##) ;C := physical unit number
-;; ld c,(ix+UD_PHYS##)
+ ld c,(ix+UD_PHYSICAL_UNIT##) ;C := physical unit number
+;; ld c,(ix+UD_PHYSICAL_UNIT##)
;; ld hl,(B_CACHE##)
;; ld a,h
;; sub 1
@@ -89,7 +90,7 @@ bf_a_copies: ld (READ_COPIES##),a ;Remember number of copies
push hl ; save this address in case
; sector not found.
;===== start mod FAT16 (support BUF_1/BUF_2/SECNUM/REDBUF patch)
-bf_sector_loop: ld c,(ix+UD_PHYS##) ;C := physical unit number
+bf_sector_loop: ld c,(ix+UD_PHYSICAL_UNIT##) ;C := physical unit number
call BF_CMP ;See if this buffer has the
;;bf_sector_loop:call BF_CMP
;===== end mod FAT16
@@ -133,7 +134,7 @@ first_buf_ok:
inc hl
inc hl
;===== start mod FAT16 (support BUF_1/BUF_2/SECNUM/REDBUF patch)
- ld a,(ix+UD_PHYS##) ;Record physical unit number
+ ld a,(ix+UD_PHYSICAL_UNIT##) ;Record physical unit number
ld (hl),a
;; ld (hl),c
;===== end mod FAT16
@@ -154,14 +155,14 @@ first_buf_ok:
inc hl
;
;===== start mod FAT16 (SECNUM/REDBUF patch)
- ld a,(ix+UD_SFAT##) ;Record copy separation in
+ ld a,(ix+UD_SECTORS_PER_FAT##) ;Record copy separation in
ld (hl),a ; buffer descriptor. This is
inc hl ; just the number of sectors
; per FAT.
ld (hl),c ;Record sector number (bit16-22)
ld (iy+@DIO_EX_SECTOR##),c ;DIO_EX_SECTOR := Sector number (bit16-22)
ld c,a
-;; ld c,(ix+UD_SFAT##)
+;; ld c,(ix+UD_SECTORS_PER_FAT##)
;; ld (hl),c
;; inc hl
;===== end mod FAT16
@@ -275,7 +276,7 @@ BF_CMP:
; Preserves: A,BC,DE,HL,IX,AF',BC',DE',HL'
; Corrupts: F :FAT16
;
-; Assumes: BD_UNIT=2 BD_SECT=4 BD_EX_SECT=8 :FAT16
+; Assumes: BD_PHYSICAL_UNIT_NUMBER=2 BD_SECTOR_NUMBER=4 BD_EX_SECTOR_NUMBER=8 :FAT16
;
;
push hl
@@ -399,7 +400,7 @@ flush_loop: call FLG_NEXT ;Find next buffer and return
; Preserves: BC,DE,HL,IX,AF',BC',DE',HL'
; Corrupts: AF
;
-; Assumes: BD_UNIT=2
+; Assumes: BD_PHYSICAL_UNIT_NUMBER=2
;
;
call FLG_BUFS ;Flag appropriate buffers
@@ -423,7 +424,7 @@ FLG_BUFS: jr c,FLG_PHYS ;Skip if drive in A
;
push hl
push bc ;Get physical drive number
- ld bc,UD_PHYS## ; from unit descriptor.
+ ld bc,UD_PHYSICAL_UNIT## ; from unit descriptor.
add hl,bc
ld a,(hl)
pop bc
@@ -446,7 +447,7 @@ FLG_PHYS:
; Preserves: BC,DE,HL,IX,AF',BC',DE',HL'
; Corrupts: AF
;
-; Assumes: BD_LINK=0 BD_UNIT=2 BD_FLAGS=3
+; Assumes: BD_NEXT_DESC_ADDRESS=0 BD_PHYSICAL_UNIT_NUMBER=2 BD_FLAGS=3
;
;
push hl
@@ -499,7 +500,7 @@ POP_UD_RET: pop hl ;Also used as return from the
; Preserves: BC,DE,IX,AF',BC',DE',HL'
; Corrupts: AF,HL
;
-; Assumes: BD_LINK=0 BD_FLAGS=3
+; Assumes: BD_NEXT_DESC_ADDRESS=0 BD_FLAGS=3
;
;
ld hl,(B_CHAIN##) ;HL -> start of buffer chain
@@ -538,7 +539,7 @@ find_flag_loop: push hl
; Preserves: A,BC,DE,HL,IX,AF',BC',DE',HL' : FAT16
; Corrupts: F : FAT16
;
-; Assumes: BD_LINK=0
+; Assumes: BD_NEXT_DESC_ADDRESS=0
;
;
push de ;Preserve DE
@@ -560,7 +561,7 @@ find_flag_loop: push hl
ld b,(hl) ; this one and save for later
push bc
ld (hl),d ;Put address of buffer which
- dec hl ; used to be first in BD_LINK
+ dec hl ; used to be first in BD_NEXT_DESC_ADDRESS
ld (hl),e ; pointer for this buffer so it
; will end up second.
;
@@ -590,12 +591,12 @@ BF_END:
; Preserves: BC,DE,HL,IX,AF',BC',DE',HL'
; Corrupts: AF
;
-; Assumes: BD_LINK=0
+; Assumes: BD_NEXT_DESC_ADDRESS=0
;
;
ld a,(hl)
inc hl ;If buffer is already last one
- or (hl) ; (BD_LINK=0) then return
+ or (hl) ; (BD_NEXT_DESC_ADDRESS=0) then return
dec hl ; immediately.
ret z
;
@@ -620,7 +621,7 @@ BF_END:
; DE->buffer before it. HL=(DE)=BC
;
ex de,hl
- pop de ;Set BD_LINK pointer in buffer which
+ pop de ;Set BD_NEXT_DESC_ADDRESS pointer in buffer which
ld (hl),e ; was before this one, to point to
inc hl ; the buffer which was after this one,
ld (hl),d ; thus removing this buffer from chain.
@@ -657,10 +658,10 @@ BF_FIND:
; Preserves: BC,IX,AF',BC',DE',HL'
; Corrupts: DE,HL,AF
;
-; Assumes: BD_LINK=0
+; Assumes: BD_NEXT_DESC_ADDRESS=0
;
;
-bf_find_loop: ld e,(hl) ;Get next buffer address (BD_LINK)
+bf_find_loop: ld e,(hl) ;Get next buffer address (BD_NEXT_DESC_ADDRESS)
inc hl ; from this buffer.
ld d,(hl)
dec hl
@@ -684,14 +685,14 @@ bf_find_loop: ld e,(hl) ;Get next buffer address (BD_LINK)
; This routine makes sure that a given buffer is empty. If it is not empty
; then the contents will be flushed if it is dirty, and it will be marked
; empty. When the contents are flushed, multiple copies will be written if
-; required by the BD_COPY field of the buffer descriptor. However if bit-6 of
+; required by the BD_NUMBER_OF_COPIES field of the buffer descriptor. However if bit-6 of
; the buffer flags is set then the buffer will only be written to the last
; copy of the FAT. This facility is only used in "CLEAN_DISK".
;
; This routine always sets the flag "FF_DBUF" in "FAT_FLAGS" to force
; "DIRE_NEXT" to check that its sector is still buffered, since this routine
; could use that buffer for something else. Note that the buffer will be
-; marked as non-dirty but will NOT be marked as invalid (BD_UNIT is not
+; marked as non-dirty but will NOT be marked as invalid (BD_PHYSICAL_UNIT_NUMBER is not
; changed).
;
; Entry: HL = Address of buffer to flush
@@ -699,9 +700,9 @@ bf_find_loop: ld e,(hl) ;Get next buffer address (BD_LINK)
; Preserves: BC,DE,HL,IX,AF',BC',DE',HL'
; Corrupts: AF
;
-; Assumes: BD_UNIT=2 BD_FLAGS=3 BD_SECT=4
-; BD_COPY=6 BD_UD=9 BD_DATA=11
-; BD_EX_SECT=8
+; Assumes: BD_PHYSICAL_UNIT_NUMBER=2 BD_FLAGS=3 BD_SECTOR_NUMBER=4
+; BD_NUMBER_OF_COPIES=6 BD_UNIT_DESCRIPTOR_ADDRESS=9 BD_DATA=11
+; BD_EX_SECTOR_NUMBER=8
;
;
set FF_DBUF,(iy+@FAT_FLAGS##) ;Set directory buffer flag
@@ -729,21 +730,21 @@ flush_retry: push hl
inc hl ; descriptor
ld d,(hl)
inc hl
- ld b,(hl) ;B := BD_COPY from buffer descriptor
+ ld b,(hl) ;B := BD_NUMBER_OF_COPIES from buffer descriptor
inc hl
;
jr z,not_last_fat ;If the "last FAT only" flag is set
ld a,e ; then adjust the sector number by
;===== start mod FAT16 (FSIZE1 patch)
-last_fat_loop: inc (hl) ; adding BD_COPY*BD_SEP on to it.
+last_fat_loop: inc (hl) ; adding BD_NUMBER_OF_COPIES*BD_SECTORS_BETWEEN_COPIES on to it.
dec (hl)
- jr z,no_lfat_8bit ;force incriment D if BD_SEP = 0(UPB_SFAT = 256)
+ jr z,no_lfat_8bit ;force incriment D if BD_SECTORS_BETWEEN_COPIES = 0(UPB_SECTORS_PER_FAT = 256)
add a,(hl)
jr nc,no_lfat_carry ;This is used by clean disk and
;;last_fat_loop:add a,(hl)
;; jr nc,no_lfat_carry
;===== end mod FAT16
-no_lfat_8bit: inc d ; BD_COPY must be UD_NFAT-1 so that
+no_lfat_8bit: inc d ; BD_NUMBER_OF_COPIES must be UD_NUMBER_OF_FATS-1 so that
no_lfat_carry: djnz last_fat_loop ; this points to the last copy of
ld e,a ; the FAT sector.
ld b,1 ;Only write out one copy.
@@ -757,7 +758,7 @@ not_last_fat:
;===== end add FAT16
inc hl
ld e,(hl) ;DE := address of unit descriptor
- inc hl ; from BD_UD field of buffer
+ inc hl ; from BD_UNIT_DESCRIPTOR_ADDRESS field of buffer
ld d,(hl) ; descriptor.
inc hl
ex de,hl ;HL := unit descriptor address
@@ -795,12 +796,12 @@ not_noupb_err: ; by DISK_ERR.
;
push af
;===== start mod FAT16 (FSIZE2 patch)
- ld a,(ix+BD_SEP##-BD_DATA##);DE+:=BD_SEP, i.e. adjust
+ ld a,(ix+BD_SECTORS_BETWEEN_COPIES##-BD_DATA##);DE+:=BD_SECTORS_BETWEEN_COPIES, i.e. adjust
or a ; sector number for next
- jr z,flush_no_8bit ; copy of data to write. ;force incriment D if BD_SEP = 0 (UPB_SFAT = 256)
+ jr z,flush_no_8bit ; copy of data to write. ;force incriment D if BD_SECTORS_BETWEEN_COPIES = 0 (UPB_SECTORS_PER_FAT = 256)
add a,e
;; ld a,e
-;; add a,(ix+BD_SEP##-BD_DATA##)
+;; add a,(ix+BD_SECTORS_BETWEEN_COPIES##-BD_DATA##)
;===== end mod FAT16
ld e,a
jr nc,flush_no_cy
diff --git a/source/kernel/bank2/char.mac b/source/kernel/bank2/char.mac
index 2e237468..f9f9c5bf 100644
--- a/source/kernel/bank2/char.mac
+++ b/source/kernel/bank2/char.mac
@@ -1,10 +1,11 @@
.z80
+ name('char')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl CP/M character Functions
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
diff --git a/source/kernel/bank2/del.mac b/source/kernel/bank2/del.mac
index b7184bbc..2f5cf730 100644
--- a/source/kernel/bank2/del.mac
+++ b/source/kernel/bank2/del.mac
@@ -1,10 +1,11 @@
.z80
+ name('del')
TITLE MSX-DOS KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Delete, Rename, Move, Attribute and Date/Time Routines
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -52,7 +53,7 @@
ret nz ; for this same file.
;
push hl ;Get the attributes byte from
- ld hl,DR_ATTR## ; the directory entry.
+ ld hl,DR_ATTRIBUTES## ; the directory entry.
add hl,de ;
ld b,(hl)
pop hl
@@ -89,7 +90,7 @@ dir_end:
delete_file: pcall DI_SAME ;Ensure entry is still buffered
ld a,c ;A := "DIRTY_DISK" flag
push hl
- ld hl,DR_CLU##
+ ld hl,DR_FIRST_CLUSTER##
add hl,de
ld c,(hl) ;BC := cluster number from
inc hl ; directory entry.
@@ -108,8 +109,8 @@ delete_file: pcall DI_SAME ;Ensure entry is still buffered
; into a buffer.
;
push hl
- ld hl,DR_DCHAR## ;Save first character of the
- add hl,de ; entry in the DR_DCHAR byte of
+ ld hl,DR_DELETED_FIRST_CHAR## ;Save first character of the
+ add hl,de ; entry in the DR_DELETED_FIRST_CHAR byte of
ld a,(de) ; the entry which is otherwise
ld (hl),a ; unused.
ld a,0E5h ;Set the first byte to 0E5h
@@ -275,7 +276,7 @@ not_E5h_fiddle: ld (de),a
ret c ; or ".." entries.
;
push hl
- ld hl,DR_CLU## ;Store start cluster of the
+ ld hl,DR_FIRST_CLUSTER## ;Store start cluster of the
add hl,de ; directory or file in
ld a,(hl) ; "CHK_CLU" so that "SE_ERR"
inc hl ; flag will get set if this
@@ -283,7 +284,7 @@ not_E5h_fiddle: ld (de),a
ld l,a ; new path string. The is to
ld (CHK_CLU##),hl ; avoid creating loops.)
;
- ld hl,DR_ATTR## ;Look at attributes byte in
+ ld hl,DR_ATTRIBUTES## ;Look at attributes byte in
add hl,de ; the directory entry and if
ld a,(hl) ; it is a sub-directory then
pop hl ; zap current dir cluster to
@@ -312,8 +313,8 @@ not_05h_fiddle: ld (hl),a ; being 05h.
pop de ;DE -> new path string
;
ld c,PCM_DI+PCM_LA+PCM_ND ;Parse the new pathname string
- ld b,(ix+FIB_SA##) ; accessing disk, including
- ld a,(ix+FIB_DRV##) ; last item and not allowing
+ ld b,(ix+FIB_SEARCH_ATTRIBUTES##) ; accessing disk, including
+ ld a,(ix+FIB_DRIVE_NUMBER##) ; last item and not allowing
ld (iy+@SE_FLAGS##),0 ; a drive name. SE_ERR flag
pcall PAR_PATH ; cleared for "CHK_CLU" test.
ret nz ;Give up if any error or
@@ -405,7 +406,7 @@ not_05h_fiddle: ld (hl),a ; being 05h.
ld bc,0 ; rather than -ve.
not_root_parent:
push hl
- ld hl,DR_CLU## ;Insert new parent directory
+ ld hl,DR_FIRST_CLUSTER## ;Insert new parent directory
add hl,de ; cluster into the ".." entry.
ld (hl),c
inc hl
@@ -450,7 +451,7 @@ not_root_parent:
ret nz ; on a different FAB.
;
push hl
- ld hl,DR_ATTR## ;Point to attributes byte
+ ld hl,DR_ATTRIBUTES## ;Point to attributes byte
add hl,de ; in directory entry and
ld a,(hl) ; get current value.
;
@@ -501,7 +502,7 @@ attr_fib_ret: pop hl ; and return with no error
push hl
push de
pcall DI_SAME ;Get the directory entry
- ld hl,DR_TIME## ; back and copy the new
+ ld hl,DR_UPDATED_TIME## ; back and copy the new
add hl,de ; date and time values
ex de,hl ; into the appropriate
ex (sp),hl ; fields of it.
@@ -517,7 +518,7 @@ attr_fib_ret: pop hl ; and return with no error
pop hl ; with DEL, REN and MOVE
;
CHANGED_ENTRY: push hl
- ld hl,DR_ATTR## ;Look at attributes byte of
+ ld hl,DR_ATTRIBUTES## ;Look at attributes byte of
add hl,de ; the entry and if it is not
bit AT_DIR,(hl) ; a sub-directory then set the
jr nz,no_set_archive ; archive bit.
diff --git a/source/kernel/bank2/dev.mac b/source/kernel/bank2/dev.mac
index b3f55e5a..a99ab6d3 100644
--- a/source/kernel/bank2/dev.mac
+++ b/source/kernel/bank2/dev.mac
@@ -1,10 +1,11 @@
.z80
+ name('dev')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Character devices
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
diff --git a/source/kernel/bank2/dir.mac b/source/kernel/bank2/dir.mac
index 9110f80d..3c78b8e2 100644
--- a/source/kernel/bank2/dir.mac
+++ b/source/kernel/bank2/dir.mac
@@ -1,10 +1,11 @@
.z80
+ name('dir')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Directory Entry and Fileinfo Block Handling
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;-----------------------------------------------------------------------------
@@ -31,7 +32,7 @@
;
;
push hl
- ld hl,DR_CLU## ;Get start cluster number from
+ ld hl,DR_FIRST_CLUSTER## ;Get start cluster number from
add hl,de ; directory entry and jump to
ld e,(hl) ; START_DIR to store it in the
inc hl ; DE_START variable.
@@ -79,7 +80,7 @@ no_chk_clu: pop hl
; NZ => entry in use, or deleted
; Corrupts: AF,DE
;
-; Assumes: UD_WDS=UD_ODE+1 UD_SDIR=UD_WDS+2
+; Assumes: UD_WHOLE_DIR_SECTORS=UD_ODD_DIR_ENTRIES+1 UD_FIRST_ROOT_DIR_SECTOR=UD_WHOLE_DIR_SECTORS+2
;
;
;Get first directory cluster
@@ -101,7 +102,7 @@ no_chk_clu: pop hl
;===== end add FAT16
push bc ;Save user's BC
push hl
- ld bc,UD_ODE##
+ ld bc,UD_ODD_DIR_ENTRIES##
add hl,bc
ld c,(hl) ;C := number of odd entries
inc hl ; in last directory sector
@@ -245,7 +246,7 @@ SUB_DI_FIRST: push bc
;===== end add FAT16
;
ex de,hl
- ld hl,UD_CMSK## ;Get UD_CMSK+1 from unit
+ ld hl,UD_CLUSTER_MASK## ;Get UD_CLUSTER_MASK+1 from unit
add hl,de ; descriptor which will be
ld a,(hl) ; recorded as number of sectors
inc a ; in this cluster.
@@ -314,7 +315,7 @@ got_dev_entry:
push ix ;If it's an used entry and the attributes byte is 0Fh
push de ;then it's along filename entry, so ignore it
pop ix ;and go get the next one
- ld a,(ix+DR_ATTR##)
+ ld a,(ix+DR_ATTRIBUTES##)
cp 0Fh
jr nz,got_dev_entry_end
pop ix
diff --git a/source/kernel/bank2/err.mac b/source/kernel/bank2/err.mac
index cf493a3d..4e30a632 100644
--- a/source/kernel/bank2/err.mac
+++ b/source/kernel/bank2/err.mac
@@ -1,10 +1,11 @@
.z80
+ name('err')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Error handling
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -43,7 +44,7 @@ else
; Preserves: BC,DE,HL,IX,AF',BC',DE',HL'
; Corrupts: AF
;
-; Assumes: UD_TIME=UD_PHYS+1
+; Assumes: UD_TIME=UD_PHYSICAL_UNIT+1
;
;
push bc
@@ -89,7 +90,7 @@ sector_invalid:
push ix
push hl
pop ix
- ld b,(ix+UD_PHYS##)
+ ld b,(ix+UD_PHYSICAL_UNIT##)
bit UF_DBD,(ix+UD_DFLAGS##)
jr nz,err_no_upb
ld a,(ix+UD_TIME##) ;If UD_TIME is non-zero (UPB is defined) then set it to
diff --git a/source/kernel/bank2/fat.mac b/source/kernel/bank2/fat.mac
index 2f47ff95..b5abc60b 100644
--- a/source/kernel/bank2/fat.mac
+++ b/source/kernel/bank2/fat.mac
@@ -1,10 +1,11 @@
.z80
+ name('fat')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL File Attribute Table (FAT) Handling
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -116,12 +117,12 @@ return_0ffffh:
ex (sp),ix
push bc ;save user BC
;
- ld b,(ix+UD_CSHFT##) ;Get cluster shift from
+ ld b,(ix+UD_CLUSTER_SHIFT##) ;Get cluster shift from
; unit descriptor and add
; one to it for the loop
;; push hl
;; push bc
-;; ld bc,UD_CSHFT##
+;; ld bc,UD_CLUSTER_SHIFT##
;; add hl,bc
;; ld b,(hl)
;===== end mod FAT16
@@ -136,7 +137,7 @@ endif
jr sft_cshft_loop ;Skip "ADD HL,HL" and "RL C" first time
cshft_loop: add hl,hl ;Double the cluster number
rl c
-sft_cshft_loop: djnz cshft_loop ; UD_CSHFT times.
+sft_cshft_loop: djnz cshft_loop ; UD_CLUSTER_SHIFT times.
;; code mvi c
;;cshft_loop: add hl,hl
;; djnz cshft_loop
@@ -146,14 +147,14 @@ sft_cshft_loop: djnz cshft_loop ; UD_CSHFT times.
ld l,a ; number.
;
;===== start mod FAT16 (2DD4/GETSEC patch)
- ld e,(ix+UD_SDAT##)
- ld d,(ix+UD_SDAT##+1)
+ ld e,(ix+UD_FIRST_DATA_SECTOR##)
+ ld d,(ix+UD_FIRST_DATA_SECTOR##+1)
add hl,de
ld a,c
;assume B=0 (set "djnz")
adc a,b
;; ex de,hl
-;; ld c,UD_SDAT##-UD_CSHFT##
+;; ld c,UD_FIRST_DATA_SECTOR##-UD_CLUSTER_SHIFT##
;; add hl,bc
;; ld a,(hl)
;; inc hl
@@ -312,7 +313,7 @@ FIND_FAT_ENTRY:
; returned.
;
; If the FAT entry number is not within the cluster range of the disk (as
-; defined by UD_NCLU in the unit descriptor) then it returns with the Z-flag
+; defined by UD_CLUSTER_COUNT in the unit descriptor) then it returns with the Z-flag
; clear to indicate the error. In this case the address in DE is not valid.
;
; Entry: HL = Address of unit descriptor
@@ -334,8 +335,8 @@ FIND_FAT_ENTRY:
pop ix ; passing to BF_SECTOR
res FF_OVR,(iy+@FAT_FLAGS##) ;Clear sector boundary flag
;
- ld l,(ix+UD_NCLU##) ;Get cluster number from
- ld h,(ix+UD_NCLU##+1) ; unit descriptor and check
+ ld l,(ix+UD_CLUSTER_COUNT##) ;Get cluster number from
+ ld h,(ix+UD_CLUSTER_COUNT##+1) ; unit descriptor and check
if 0
dec hl ; that it is within valid
endif
@@ -370,8 +371,8 @@ find_fat16: push af ;Save odd/even flag (carry)
;; srl e
;; ld d,a
;===== end mod FAT16
- ld l,(ix+UD_RES##)
- ld h,(ix+UD_RES##+1) ;Add on reserved sectors to get
+ ld l,(ix+UD_RESERVED_SECTORS##)
+ ld h,(ix+UD_RESERVED_SECTORS##+1) ;Add on reserved sectors to get
add hl,de ; sector number required.
ld (TMP_FAT##),hl ; Save FAT sector number, needed by F_GETCLUS
ex de,hl
@@ -458,7 +459,7 @@ CLEAN_DISK:
;
push hl
ex (sp),ix
- bit 0,(ix+UD_DIRT##) ;Return without doing anything
+ bit 0,(ix+UD_DIRTY_DISK_FLAG##) ;Return without doing anything
jr z,CL_DIRT_RET ; if disk is already clean.
;
xor a ;Jump into "DIRTY_DISK" code
@@ -481,27 +482,27 @@ CLEAN_DISK:
; Corrupts: AF
; Preserves: BC,DE,HL,AF',BC',DE',HL'
;
-; Assumes: BD_UNIT=2
+; Assumes: BD_PHYSICAL_UNIT_NUMBER=2
;
;
push hl
ex (sp),ix
bit UF_UNDL,(ix+UD_FLAGS##) ;Don't do anyting if disk does
jr z,cl_dirt_ret ; not support un-deleting
- bit 0,(ix+UD_DIRT##) ;Also do nothing if disk is
+ bit 0,(ix+UD_DIRTY_DISK_FLAG##) ;Also do nothing if disk is
jr nz,cl_dirt_ret ; already dirty.
;
ld a,1 ;New value for dirty disk flag
;
CL_DIRT_DISK: push bc
push de
- ld b,(ix+UD_NFAT##) ;If only one copy of the FAT
+ ld b,(ix+UD_NUMBER_OF_FATS##) ;If only one copy of the FAT
dec b ; then just clear the
jr z,set_dirt_flag ; dirty disk flag.
;
- ld e,(ix+UD_RES##) ;DE := first FAT sector
- ld d,(ix+UD_RES##+1)
- ld b,(ix+UD_SFAT##) ;B := number of sectors to do
+ ld e,(ix+UD_RESERVED_SECTORS##) ;DE := first FAT sector
+ ld d,(ix+UD_RESERVED_SECTORS##+1)
+ ld b,(ix+UD_SECTORS_PER_FAT##) ;B := number of sectors to do
;
cl_dirt_loop: push bc
push af ;If dirtying disk then just
@@ -538,7 +539,7 @@ fat_flush: pcall BF_SFL ;Flush the buffer if necessary
;
ld b,a ;B := required dirty disk flag
set_dirt_flag: ld a,b ;If dirty disk flag is already
- cp (ix+UD_DIRT##) ; in the correct state then
+ cp (ix+UD_DIRTY_DISK_FLAG##) ; in the correct state then
jr z,dirt_flag_ok ; return.
;
push bc ;Save dirty disk flag value
@@ -558,7 +559,7 @@ set_dirt_flag: ld a,b ;If dirty disk flag is already
call DTY_ADD
pop bc
ld (hl),b ;Record new dirty disk flag
- ld (ix+UD_DIRT##),b ;in boot sector and UPB.
+ ld (ix+UD_DIRTY_DISK_FLAG##),b ;in boot sector and UPB.
;
dirt_flag_ok: pop de
pop bc
@@ -597,7 +598,7 @@ init_fat_loop: inc de
ld bc,0 ;Now loop to set each FAT
call FAT_ASET ; entry to zero until we
push hl ; reach the maximum cluster
- ld bc,UD_NCLU## ; number as specified in the
+ ld bc,UD_CLUSTER_COUNT## ; number as specified in the
add hl,bc ; unit decriptor.
ld a,(hl)
inc hl
@@ -661,7 +662,7 @@ all_clu_loop: push bc ;Remember cluster count
push de ;Remember previous cluster
all_clu_loop_2: inc de ;Try next cluster number
push hl
- ld bc,UD_NCLU## ;Get total number of clusters
+ ld bc,UD_CLUSTER_COUNT## ;Get total number of clusters
add hl,bc ; from unit descriptor and
ld a,(hl) ; compare this with the next
inc hl ; cluster which we are about
@@ -771,14 +772,14 @@ disk_full: pop de ;Disk full. Free all clusters
;
push hl
;===== start mod FAT16 (support BUF_5/BUF_2 patch)
- ld c,(ix+UD_SDIR##) ;BC := first root dir sector
- ld b,(ix+UD_SDIR##+1)
- ld e,(ix+UD_SDAT##) ;DE := first data sector
- ld d,(ix+UD_SDAT##+1)
+ ld c,(ix+UD_FIRST_ROOT_DIR_SECTOR##) ;BC := first root dir sector
+ ld b,(ix+UD_FIRST_ROOT_DIR_SECTOR##+1)
+ ld e,(ix+UD_FIRST_DATA_SECTOR##) ;DE := first data sector
+ ld d,(ix+UD_FIRST_DATA_SECTOR##+1)
ld h,d
ld l,e ;Number of root directory
sbc hl,bc ; sectors is the difference
-;; ld bc,UD_SDIR##
+;; ld bc,UD_FIRST_ROOT_DIR_SECTOR##
;; add hl,bc
;; ld c,(hl)
;; inc hl
@@ -801,17 +802,17 @@ disk_full: pop de ;Disk full. Free all clusters
jr now_zero_clu
;
;===== start mod FAT16 (suport BUF_2 patch)
-not_root_dir: ld a,(ix+UD_CMSK##) ;Get number of sectors per
+not_root_dir: ld a,(ix+UD_CLUSTER_MASK##) ;Get number of sectors per
; cluster - 1 from unit
; descriptor.
call CLU_TO_SEC ;Find sector number of last
; sector in cluster.
ld c,a ; C := last root dir sector. (bit16-22)
- ld b,(ix+UD_CMSK##) ; B := sector count
+ ld b,(ix+UD_CLUSTER_MASK##) ; B := sector count
;
now_zero_clu: inc b
;;not_root_dir: push hl
-;; ld bc,UD_CMSK##
+;; ld bc,UD_CLUSTER_MASK##
;; add hl,bc
;; ld b,(hl)
;; pop hl
@@ -886,13 +887,13 @@ zero_dsec_loop: ld (hl),c ; the data area of buffer
call free_chain_lp
- ;Update UD_ACLU to the number of the lowest cluster that has been
+ ;Update UD_ALLOCATION_CLUSTER to the number of the lowest cluster that has been
;freed -1, but only if the new value would be smaller than the
- ;current value. This is to ensure that UD_ACLU is always either 1
+ ;current value. This is to ensure that UD_ALLOCATION_CLUSTER is always either 1
;or the lower free cluster number available -1.
push hl ;Preserve address of unit descriptor
- call ACLU_GET ;DE = current value of UD_ACLU
+ call ACLU_GET ;DE = current value of UD_ALLOCATION_CLUSTER
ld hl,(FAT_CHAIN##) ;HL = Lowest cluster number freed (new value+1)
ex de,hl ;HL = current value, DE = new value+1
dec de ;DE = new value
@@ -950,7 +951,7 @@ frchlp2:
DTY_ADD:
push bc
- ld bc,UPB_EBS##
+ ld bc,UPB_EXTENDED_SIGNATURE##
add hl,bc
pop bc
ld a,(hl)
@@ -965,7 +966,7 @@ DTY_ADD:
;
PROC ACLU_SET
;
-; Sets the UD_ACLU field of a unit descriptor.
+; Sets the UD_ALLOCATION_CLUSTER field of a unit descriptor.
;
; Entry: DE = Value to set
; HL = Address of unit descriptor
@@ -974,7 +975,7 @@ DTY_ADD:
;
push hl
push de
- ld de, UD_ACLU##
+ ld de, UD_ALLOCATION_CLUSTER##
add hl,de
pop de
ld (hl),e
@@ -986,7 +987,7 @@ DTY_ADD:
;
;------------------------------------------------------------------------------
;
-; Gets the UD_ACLU field of a unit descriptor.
+; Gets the UD_ALLOCATION_CLUSTER field of a unit descriptor.
;
; Entry: HL = Address of unit descriptor
; Returns: DE = Value
@@ -994,7 +995,7 @@ DTY_ADD:
;
ACLU_GET:
push hl
- ld de,UD_ACLU##
+ ld de,UD_ALLOCATION_CLUSTER##
add hl,de
ld e,(hl)
inc hl
diff --git a/source/kernel/bank2/files.mac b/source/kernel/bank2/files.mac
index e048ebac..7769583c 100644
--- a/source/kernel/bank2/files.mac
+++ b/source/kernel/bank2/files.mac
@@ -1,10 +1,11 @@
.z80
+ name('files')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL File Read and Write Routines
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -82,15 +83,15 @@
ld bc,(RW_SZ_DONE##) ;BC := amount transferred
ld de,(RW_DTA##) ;DE := updated DTA address
;
-rdwr_dev_done: ld l,(ix+FAB_PTR##) ;Add the amount transferred
- ld h,(ix+FAB_PTR##+1) ; on to the file pointer in
+rdwr_dev_done: ld l,(ix+FAB_FILE_POINTER##) ;Add the amount transferred
+ ld h,(ix+FAB_FILE_POINTER##+1) ; on to the file pointer in
add hl,bc ; the FAB, remembering to
- ld (ix+FAB_PTR##),l ; carry into the top two
- ld (ix+FAB_PTR##+1),h ; bytes if required.
+ ld (ix+FAB_FILE_POINTER##),l ; carry into the top two
+ ld (ix+FAB_FILE_POINTER##+1),h ; bytes if required.
jr nc,no_ptr_carry
- inc (ix+FAB_PTR##+2)
+ inc (ix+FAB_FILE_POINTER##+2)
jr nz,no_ptr_carry
- inc (ix+FAB_PTR##+3)
+ inc (ix+FAB_FILE_POINTER##+3)
no_ptr_carry:
rdwr_error: or a
ret nz ;Return if error
@@ -112,7 +113,7 @@ rdwr_ret_ok: xor a ; of file error.
rdwr_device:
ld h,a ;Store the paging mode
and RFM_PG ; flag in the FAB ready for
- ld (ix+FAB_PG##),a ; passing to GET_SEGMENT
+ ld (ix+FAB_TEMP_PAGING_MODE##),a ; passing to GET_SEGMENT
;
ld a,b ;Do nothing if zero bytes
or c ; requested
@@ -121,15 +122,15 @@ rdwr_device:
bit RF_READ,h
jr nz,read_device ;Skip if read.
;
- ld l,(ix+FAB_ID##+2) ;Get device jump table
- ld h,(ix+FAB_ID##+3) ; address into HL and point
+ ld l,(ix+FAB_VOLUME_ID##+2) ;Get device jump table
+ ld h,(ix+FAB_VOLUME_ID##+3) ; address into HL and point
inc hl ; to second entry which is
inc hl ; the WRCH routine.
inc hl
;
push bc ;Save total number of bytes
wr_dev_loop: push de
- ld a,(ix+FAB_PG##) ;Get next byte to write from
+ ld a,(ix+FAB_TEMP_PAGING_MODE##) ;Get next byte to write from
pcall GET_SEGMENT ; the correct segment as
ex de,hl ; determined by the paging
call RD_SEG## ; mode.
@@ -171,8 +172,8 @@ rdwr_dev_done2: jp rdwr_dev_done ;Check for BC=0 & return
;
;
;
-read_device: ld l,(ix+FAB_ID##+2) ;HL -> first entry in jump
- ld h,(ix+FAB_ID##+3) ; table which is READ routine.
+read_device: ld l,(ix+FAB_VOLUME_ID##+2) ;HL -> first entry in jump
+ ld h,(ix+FAB_VOLUME_ID##+3) ; table which is READ routine.
;
push bc ;Save total number of bytes
if 0
@@ -208,7 +209,7 @@ file_end_ch: inc c ;C=1 => end of file
rdch_normal:
push de
push hl
- ld a,(ix+FAB_PG##) ;Find the address to write the
+ ld a,(ix+FAB_TEMP_PAGING_MODE##) ;Find the address to write the
pcall GET_SEGMENT ; byte to according to the
ex de,hl ; paging mode and then write
ld e,b ; the character there.
@@ -278,20 +279,20 @@ READ_WRITE:
;
;
ld a,.HDEAD## ;Don't do anything if the
- bit AC_DEAD,(ix+FAB_ACC##) ; file has been deleted on
+ bit AC_DEAD,(ix+FAB_ACCESS_MODE##) ; file has been deleted on
ret nz ; us.
;
ld a,.ACCV##
bit RF_READ,(iy+@RW_FLAGS##)
jr z,write_check
- bit AC_RD,(ix+FAB_ACC##) ;For a read operation, error
+ bit AC_RD,(ix+FAB_ACCESS_MODE##) ;For a read operation, error
ret nz ; if read inhibit access flag
jr access_ok ; is set.
;
-write_check: bit AC_WR,(ix+FAB_ACC##) ;For a write operation, error
+write_check: bit AC_WR,(ix+FAB_ACCESS_MODE##) ;For a write operation, error
ret nz ; if write inhibit bit is
ld a,.FILRO## ; set or if it is a read
- bit AT_RO,(ix+FAB_ATTR##) ; only file.
+ bit AT_RO,(ix+FAB_ATTRIBUTES##) ; only file.
ret nz
;
if 0
@@ -309,7 +310,7 @@ access_ok: bit 0,(iy+@LAZY##)
skip_ov64k:
endif
;
- ld c,(ix+FAB_DRV##) ;Validate the drive specified
+ ld c,(ix+FAB_DRIVE_NUMBER##) ;Validate the drive specified
ld b,1 ; in the FAB and give up if
pcall VAL_FIB ; any error.
or a
@@ -397,12 +398,12 @@ whole_sec_done: ld bc,0 ;Transfer last partial sector,
ret nz
;
ld de,(RW_PCLU##) ;Record physical cluster in
- ld (ix+FAB_LPC##),e ; FAB as last accessed cluster.
- ld (ix+FAB_LPC##+1),d
+ ld (ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##),e ; FAB as last accessed cluster.
+ ld (ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1),d
;
ld de,(RW_LCLU##) ;Record logical cluster in
- ld (ix+FAB_LLC##),e ; FAB as last accessed cluster.
- ld (ix+FAB_LLC##+1),d
+ ld (ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##),e ; FAB as last accessed cluster.
+ ld (ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##+1),d
ret
;
;
@@ -589,10 +590,10 @@ START_RW:
;
;
push hl ;LV1
- ld c,(ix+FAB_PTR##)
- ld b,(ix+FAB_PTR##+1)
- ld e,(ix+FAB_PTR##+2)
- ld d,(ix+FAB_PTR##+3) ;Get file pointer from FAB and
+ ld c,(ix+FAB_FILE_POINTER##)
+ ld b,(ix+FAB_FILE_POINTER##+1)
+ ld e,(ix+FAB_FILE_POINTER##+2)
+ ld d,(ix+FAB_FILE_POINTER##+3) ;Get file pointer from FAB and
push de ;LV2 ; put on stack for later.
push bc ;LV3 ;Split file pointer into
call DECODE_PTR ; cluster, sector and byte.
@@ -629,10 +630,10 @@ not_zero_sz: adc hl,de
push de ;LV4 ;Save final cluster number
; (only used for WRITE).
;
- ld c,(ix+FAB_SIZE##)
- ld b,(ix+FAB_SIZE##+1)
- ld e,(ix+FAB_SIZE##+2)
- ld d,(ix+FAB_SIZE##+3) ;Get file size from FAB.
+ ld c,(ix+FAB_FILE_SIZE##)
+ ld b,(ix+FAB_FILE_SIZE##+1)
+ ld e,(ix+FAB_FILE_SIZE##+2)
+ ld d,(ix+FAB_FILE_SIZE##+3) ;Get file size from FAB.
ld a,b
or c
dec bc
@@ -703,8 +704,8 @@ ret_err_3_nz: jr nz,ret_err_3 ;(Error if DECODE_PTR failed)
;; ld b,0FFh
;===== end mod FAT16
pcall FAT_ASET ; cluster chain.
- ld c,(ix+FAB_FPC##) ;Jump to reset cached cluster
- ld b,(ix+FAB_FPC##+1) ; to start of file in case it
+ ld c,(ix+FAB_FIRST_PHYSICAL_CLUSTER##) ;Jump to reset cached cluster
+ ld b,(ix+FAB_FIRST_PHYSICAL_CLUSTER##+1) ; to start of file in case it
scf ; has been freed. Set carry'
ex af,af' ; to ensure that file size
jr first_cluster ; is updated.
@@ -713,8 +714,8 @@ new_size_zero: exx ;DE':BC' = -1 => file size 0
ex af,af' ;Set NZ' to ensure that
; file size is updated later.
pop hl ;LV2 ;Get unit descriptor back
- ld e,(ix+FAB_FPC##) ;Free the whole cluster
- ld d,(ix+FAB_FPC##+1) ; chain for the file, if
+ ld e,(ix+FAB_FIRST_PHYSICAL_CLUSTER##) ;Free the whole cluster
+ ld d,(ix+FAB_FIRST_PHYSICAL_CLUSTER##+1) ; chain for the file, if
ld a,d ; there is one.
or e
pcall nz,FR_CHAIN
@@ -752,17 +753,17 @@ ret_err_1: pop de ;LV1 ;Clean up stack before
;
;
;
-first_cluster: ld (ix+FAB_FPC##),c ;For new file, store the first
- ld (ix+FAB_FPC##+1),b ; cluster in FAB for writing
+first_cluster: ld (ix+FAB_FIRST_PHYSICAL_CLUSTER##),c ;For new file, store the first
+ ld (ix+FAB_FIRST_PHYSICAL_CLUSTER##+1),b ; cluster in FAB for writing
; to directory entry later.
xor a
- ld (ix+FAB_LPC##),c ;Also store as last cluster
- ld (ix+FAB_LPC##+1),b ; accessed (both physical and
- ld (ix+FAB_LLC##),a ; logical) since file is not
- ld (ix+FAB_LLC##+1),a ; null any more. (A=0)
+ ld (ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##),c ;Also store as last cluster
+ ld (ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1),b ; accessed (both physical and
+ ld (ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##),a ; logical) since file is not
+ ld (ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##+1),a ; null any more. (A=0)
;
;
-extend_done: set AC_MOD,(ix+FAB_ACC##) ;Set the "written to" flag
+extend_done: set AC_MOD,(ix+FAB_ACCESS_MODE##) ;Set the "written to" flag
exx
ex af,af' ;If file size has not increased
jr nz,do_enlarge ; at all then don't alter size.
@@ -773,10 +774,10 @@ do_enlarge: inc bc ;If end_pointer is bigger
or c ; the file size to end_pointer
jr nz,no_inc32_carry ; in anticipation of the
inc de ; operation working.
-no_inc32_carry: ld (ix+FAB_SIZE##),c ;Note the 32 bit increment
- ld (ix+FAB_SIZE##+1),b ; first since we had the last
- ld (ix+FAB_SIZE##+2),e ; byte pointer, rather than
- ld (ix+FAB_SIZE##+3),d ; the next byte pointer.
+no_inc32_carry: ld (ix+FAB_FILE_SIZE##),c ;Note the 32 bit increment
+ ld (ix+FAB_FILE_SIZE##+1),b ; first since we had the last
+ ld (ix+FAB_FILE_SIZE##+2),e ; byte pointer, rather than
+ ld (ix+FAB_FILE_SIZE##+3),d ; the next byte pointer.
;
no_enlarge: pop bc ;LV2 ;CALCULATE OVERFLOW PAST EOF
pop de ;Clean up stack
@@ -847,12 +848,12 @@ DECODE_PTR:
; Entry: HL = Pointer to unit descriptor
; D:E:B:C = File pointer value
; Returns: A = If Z-flag clear (NZ) - Error code (.FILE)
-; Z-flag set (Z) - Sector within cluster (0..UD_CMSK)
+; Z-flag set (Z) - Sector within cluster (0..UD_CLUSTER_MASK)
; BC = Byte offset within sector (0...1FFh)
; DE = Logical cluster number (0...07FFFh)
; Corrupts: AF,BC,DE
;
-; Assumes: UD_CSHFT=UD_CMSK+1
+; Assumes: UD_CLUSTER_SHIFT=UD_CLUSTER_MASK+1
;
;
push hl
@@ -865,7 +866,7 @@ DECODE_PTR:
rl b ; into B and save it for
push bc ; returning.
;
- ld bc,UD_CMSK##
+ ld bc,UD_CLUSTER_MASK##
add hl,bc ;Get cluster mask from unit
push af ; descriptor and mask with
and (hl) ; logical sector to get start
@@ -920,19 +921,19 @@ LOG_PHYS_CLU:
;
push hl
ex de,hl
- ld e,(ix+FAB_LPC##) ;Get last accessed physical
- ld d,(ix+FAB_LPC##+1) ; cluster.
+ ld e,(ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##) ;Get last accessed physical
+ ld d,(ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1) ; cluster.
ld a,d ;If it is zero then the file
or e ; has no clusters so jump
jr z,null_file ; to return an error.
;
- ld c,(ix+FAB_LLC##) ;Get last accessed logical
- ld b,(ix+FAB_LLC##+1) ; cluster (BC). If required
+ ld c,(ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##) ;Get last accessed logical
+ ld b,(ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##+1) ; cluster (BC). If required
sbc hl,bc ; logical cluster (HL) is the
jr nc,chain_start ; same or bigger then start
add hl,bc ; here. If not then start
- ld e,(ix+FAB_FPC##) ; from first cluster of file.
- ld d,(ix+FAB_FPC##+1)
+ ld e,(ix+FAB_FIRST_PHYSICAL_CLUSTER##) ; from first cluster of file.
+ ld d,(ix+FAB_FIRST_PHYSICAL_CLUSTER##+1)
chain_start: ex (sp),hl ;HL -> unit descriptor
pop bc ;BC = cluster chain count
;
diff --git a/source/kernel/bank2/find.mac b/source/kernel/bank2/find.mac
index fcfc3d55..72077c48 100644
--- a/source/kernel/bank2/find.mac
+++ b/source/kernel/bank2/find.mac
@@ -1,10 +1,11 @@
.z80
+ name('find')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Find Functions and Pathname Handling Functions
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -62,7 +63,7 @@ null_path: db 0 ;Null string for parsing
ld a,.IPATH## ; after pathname.
ret nz
;
- ld bc,UD_CDIR##
+ ld bc,UD_CURRENT_DIR_FIRST_CLUSTER##
add hl,bc
ld de,(DE_START##) ;Get the validated cluster
ld (hl),e ; number for the new directory
@@ -95,7 +96,7 @@ null_path: db 0 ;Null string for parsing
ld ix,FIB_1##
xor a ;Current drive is default
pcall PAR_PATH
- ld c,(ix+FIB_DRV##) ;Get logical drive number
+ ld c,(ix+FIB_DRIVE_NUMBER##) ;Get logical drive number
ld de,(STR_PTR##)
ld hl,(STR2_PTR##)
ret
@@ -245,14 +246,14 @@ find_fib: push hl ;Save ASCIIZ filename pointer
push de ;Validate the drive specified
ex (sp),ix ; by old FIB and download
call O_FIB ; the directory variables.
- ld c,(ix+FIB_DRV##) ;C := drive from the old FIB
+ ld c,(ix+FIB_DRIVE_NUMBER##) ;C := drive from the old FIB
pop ix
jp nz,find_ret_1 ;Return if error, or if it
ld a,.IDEV## ; is a device FIB.
jp c,find_ret_1
;
push hl ;Get the attributes byte
- ld hl,DR_ATTR## ; from the directory entry
+ ld hl,DR_ATTRIBUTES## ; from the directory entry
add hl,de ; so that we can check that
ld a,(hl) ; it is a sub-directory.
pop hl
@@ -269,12 +270,12 @@ find_fib: push hl ;Save ASCIIZ filename pointer
;
push bc
push hl ;Copy the volume-id from the
- ld bc,UD_ID## ; unit descriptor to the
+ ld bc,UD_VOLUME_ID## ; unit descriptor to the
add hl,bc ; new fileinfo block.
push ix
pop de
ex de,hl
- ld bc,FIB_ID##
+ ld bc,FIB_VOLUME_ID##
add hl,bc
ex de,hl
ld bc,4
@@ -301,7 +302,7 @@ find_rejoin: bit SE_SRCH,(iy+@SE_FLAGS##) ;If search then don't
;
push ix
ex (sp),hl ;Parse the template filename
- ld bc,FIB_NAME## ; as a single filename item
+ ld bc,FIB_FILENAME## ; as a single filename item
add hl,bc ; into the second filename
ld (STR_PTR##),hl ; buffer "FNM2_BUF".
pop hl
@@ -326,7 +327,7 @@ no_template: ld de,FNAME_BUF##
;
push ix ;Copy the search filename
ex (sp),hl ; into the "pattern" field
- ld bc,FIB_PAT## ; of the fileinfo block so
+ ld bc,FIB_EXPANDED_SEARCH_PATTERN## ; of the fileinfo block so
add hl,bc ; that it will be ready
ex de,hl ; for "find next"
push de
@@ -352,9 +353,9 @@ find_ret_1: pop de ;Clean up stack and
ret nz ; ready to continue search.
push ix
ex (sp),hl
- ld de,FIB_PAT##
+ ld de,FIB_EXPANDED_SEARCH_PATTERN##
add hl,de ;DE -> search filename at
- ex de,hl ; FIB_PAT.
+ ex de,hl ; FIB_EXPANDED_SEARCH_PATTERN.
pop hl
call FND_NEXT ;Find the next matching file
;
@@ -396,14 +397,14 @@ find_fn_done: push af ;Fill the user information
not_05h_fiddle: pcall SQ_NAME ; it into the fileinfo block.
pop hl
;
- ld bc,FIB_ATTR## ;Get attributes byte from
+ ld bc,FIB_ATTRIBUTES## ;Get attributes byte from
add hl,bc ; directory entry and put
ld a,(de) ; it into the fileinfo
ld (hl),a ; block.
;
ex de,hl
inc de ;DE -> time field of FIB
- ld bc,DR_TIME##-DR_ATTR##
+ ld bc,DR_UPDATED_TIME##-DR_ATTRIBUTES##
add hl,bc ;Copy the date, time, cluster
ld bc,2+2+2+4 ; number and size into the
ldir ; fileinfo block.
@@ -440,14 +441,14 @@ MOCF_LOOP:
pop iy ;IY = Unit descriptor
bit UF_MNT,(iy+UD_FLAGS##)
jr z,MOCF_NEXT
- ld a,(iy+UD_DRV##)
+ ld a,(iy+UD_MOUNT_DRIVE##)
inc a
cp (ix+25)
jr nz,MOCF_NEXT
- ld a,(iy+UD_SCLU##)
+ ld a,(iy+UD_MOUNT_START_CLUSTER##)
cp (ix+19)
jr nz,MOCF_NEXT
- ld a,(iy+UD_SCLU##+1)
+ ld a,(iy+UD_MOUNT_START_CLUSTER##+1)
cp (ix+20)
jr nz,MOCF_NEXT
@@ -544,7 +545,7 @@ reloc_fib: push de ;We have been passed an old
call O_FIB ; it and moan if there is
ret nz ; any problem.
;
- bit AT_VOL,(ix+FIB_SA##) ;Refuse to do anything with
+ bit AT_VOL,(ix+FIB_SEARCH_ATTRIBUTES##) ;Refuse to do anything with
ld a,.IATTR## ; a volume name FIB.
ret nz
xor a
@@ -555,7 +556,7 @@ loc_fib_done: or a ;If error then return
ret nz ; with Z-flag clear.
;
push hl
- ld hl,DR_ATTR## ;If no error then return
+ ld hl,DR_ATTRIBUTES## ;If no error then return
add hl,de ; with Z-flag set and
ld a,(hl) ; the attributes byte in
pop hl ; register A.
@@ -596,7 +597,7 @@ loc_fib_done: or a ;If error then return
not_device_fib: call GT_DVARS ;Download directory variables
ldir ; from the fileinfo block
;
- ld c,(ix+FIB_DRV##)
+ ld c,(ix+FIB_DRIVE_NUMBER##)
ld b,1
pcall VAL_FIB ;Validate the drive
pop bc
@@ -624,18 +625,18 @@ not_device_fib: call GT_DVARS ;Download directory variables
; Corrupts: AF,BC,DE,HL
;
;
- ld l,(ix+FIB_ID##)
- ld h,(ix+FIB_ID##+1) ;Get device descriptor address
+ ld l,(ix+FIB_VOLUME_ID##)
+ ld h,(ix+FIB_VOLUME_ID##+1) ;Get device descriptor address
push hl ; and save it for return.
- ld de,DD_NAME##
+ ld de,DD_DEVICE_NAME##
add hl,de ;Get address of the directory
push hl ; entry and save it for return
- ld de,DR_TIME##
+ ld de,DR_UPDATED_TIME##
add hl,de ;Point DE at place for date &
ex de,hl ; time in the directory entry
push ix
pop hl
- ld bc,FIB_TIME## ;Point HL at the date and time
+ ld bc,FIB_MODIFIED_TIME## ;Point HL at the date and time
add hl,bc ; in the FIB or FAB.
ld bc,4 ;Copy the date and time to
ldir ; the directory entry.
@@ -663,7 +664,7 @@ not_device_fib: call GT_DVARS ;Download directory variables
ld de,DE_FSTV##
push ix
pop hl
- ld bc,FIB_DVAR##
+ ld bc,FIB_DIRECTORY_VARIABLES##
add hl,bc
ld bc,DE_LSTV##-DE_FSTV##
ret
@@ -675,7 +676,7 @@ not_device_fib: call GT_DVARS ;Download directory variables
;
; This routine does the work of searching for a match to a file. The
; filename must be in an expanded format (11 byte) buffer and there must also
-; be validated fileinfo block, with the "FIB_SA" and "FIB_MODE" fields set up.
+; be validated fileinfo block, with the "FIB_SEARCH_ATTRIBUTES" and "FIB_MODE" fields set up.
; A pointer to the unit descriptor or device descriptor (depending on
; "FIB_MODE") must also be passed. The variable "SE_FLAGS" must be set up with
; all bits clear except the "SE_SRCH" bit which indicates whether it is a
@@ -685,7 +686,7 @@ not_device_fib: call GT_DVARS ;Download directory variables
; ".IFNM" error returned if it is invalid. It returns an error code and also
; a pointer to the located (or newly created) directory entry. For some
; errors, register DE is not valid and this is indicated by the Z-flag being
-; clear. Also for a "create", if the AT_DEV bit of the FIB_SA files is set
+; clear. Also for a "create", if the AT_DEV bit of the FIB_SEARCH_ATTRIBUTES files is set
; then the "SE_NEW" flag is set to ensure that an existing file will not be
; over-written.
;
@@ -705,17 +706,17 @@ not_device_fib: call GT_DVARS ;Download directory variables
bit SE_SRCH,(iy+@SE_FLAGS##);If we are doing a "create"
jr nz,fnd_not_create ; then check that the filename
push de ; being created is legal,
- ld a,(ix+FIB_SA##) ; including rejecting device
+ ld a,(ix+FIB_SEARCH_ATTRIBUTES##) ; including rejecting device
and ATM_DIR ; names if creating a directory
pcall TST_NAME ; and return an error if not.
pop de
ret nz
- bit AT_DEV,(ix+FIB_SA##) ;If "create" and the device
+ bit AT_DEV,(ix+FIB_SEARCH_ATTRIBUTES##) ;If "create" and the device
jr z,not_create_new ; bit or required attributes
set SE_NEW,(iy+@SE_FLAGS##) ; is set then set a flag to
not_create_new: ; prevent overwriting of
; existing files.
-fnd_not_create: res AT_DEV,(ix+FIB_SA##)
+fnd_not_create: res AT_DEV,(ix+FIB_SEARCH_ATTRIBUTES##)
ld (FNM_PTR##),de ;Save pointer to filename
;
bit MD_DEV,(ix+FIB_MODE##) ;Jump if we are being asked
@@ -728,7 +729,7 @@ fnd_not_create: res AT_DEV,(ix+FIB_SA##)
;
;
fnd_device: push hl ;For a device, point to the
- ld de,DD_NAME## ; directory entry in the
+ ld de,DD_DEVICE_NAME## ; directory entry in the
add hl,de ; device descriptor.
ex de,hl ;DE -> directory entry
call DATE_TIME ;Put current date/time in
@@ -761,7 +762,7 @@ got_name_match: bit SE_SRCH,(iy+@SE_FLAGS##);GOT MATCHING ENTRY, always
jr nz,found_return ; (NM_SEARCH checks this).
and ATM_HID+ATM_SYS+ATM_DIR ;If entry is hidden, system or
cpl ; a sub-directory then only
- or (ix+FIB_SA##) ; match it if the appropriate
+ or (ix+FIB_SEARCH_ATTRIBUTES##) ; match it if the appropriate
inc a ; bits are also set in the
jr nz,fnd_loop ; search attributes.
jr found_return
@@ -776,7 +777,7 @@ got_ent_create: ld b,a
bit AT_DIR,b ; directory then jump to return
ld a,.DIRX## ; an appropriate error code.
jr nz,found_inv_ret
- bit AT_DIR,(ix+FIB_SA##) ;In these cases the user fields
+ bit AT_DIR,(ix+FIB_SEARCH_ATTRIBUTES##) ;In these cases the user fields
file_exists: ld a,.FILEX## ; of the FIB will be set up as
jr nz,found_inv_ret ; if it was successful.
;
@@ -796,7 +797,7 @@ create_entry: ld de,(FNM_PTR##) ;Refuse to create a "." or
ret ; pointer.
;
not_dot_reject: ld bc,0 ;CREATE ENTRY. If not creating
- bit AT_DIR,(ix+FIB_SA##) ; sub-directory then jump with
+ bit AT_DIR,(ix+FIB_SEARCH_ATTRIBUTES##) ; sub-directory then jump with
jr z,create_not_dir ; BC=0 (cluster number)
;
ld a,0FFh ;CREATE SUB-DIR. Allocate one
@@ -807,9 +808,9 @@ not_dot_reject: ld bc,0 ;CREATE ENTRY. If not creating
;
create_not_dir: pcall DI_SAME ;Ensure entry still bufferred
ld a,ATM_VOL+ATM_ARC ;If creating volume name then
- bit AT_VOL,(ix+FIB_SA##) ; make sure just volume name
+ bit AT_VOL,(ix+FIB_SEARCH_ATTRIBUTES##) ; make sure just volume name
jr nz,got_new_attrs ; and archive bits are set.
- ld a,(ix+FIB_SA##) ;If creating directory then
+ ld a,(ix+FIB_SEARCH_ATTRIBUTES##) ;If creating directory then
set AT_ARC,a ; clear archive, read only
bit AT_DIR,a ; and system bits, else
jr z,not_dir_attrs ; set archive bit and leave
@@ -964,7 +965,7 @@ not_root: ld bc,-4 ;Point back at start cluster
push bc ;Save registers for return
push de
;
- ld hl,DR_TIME## ;Point HL at TIME field in
+ ld hl,DR_UPDATED_TIME## ;Point HL at TIME field in
add hl,de ; the directory entry and get
push hl ; current date and time.
@@ -1029,7 +1030,7 @@ NM_SEARCH_MORE:
; by the SEARCH/MAKE/CREATE function above. In addition it is used by the
; RENAME and MOVE functions to check for possible name clashes. The directory
; search must have been initiated with a suitable DI_FIRST or DI_NEXT call.
-; The filename must be pointed to by the variable "FNM_PTR". The "FIB_SA"
+; The filename must be pointed to by the variable "FNM_PTR". The "FIB_SEARCH_ATTRIBUTES"
; field of the FIB is used to determine whether it is a volume name search or
; an ordinary filename search.
;
@@ -1051,7 +1052,7 @@ search_loop: pcall DI_NEXT ;Get next directory entry
push ix
ex (sp),hl ;Point HL at filename to
ld hl,(FNM_PTR##) ; be matched and compare
- ld a,(ix+FIB_SA##) ; with name in directory
+ ld a,(ix+FIB_SEARCH_ATTRIBUTES##) ; with name in directory
pcall CMP_NAME ; entry (DE). A = volume
pop hl ; name flag.
ret c ;Return C-set if names match
diff --git a/source/kernel/bank2/handles.mac b/source/kernel/bank2/handles.mac
index be934786..ee2776ac 100644
--- a/source/kernel/bank2/handles.mac
+++ b/source/kernel/bank2/handles.mac
@@ -1,10 +1,11 @@
.z80
+ name('handles')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL File Handle Functions and File Access Block Routines
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;-----------------------------------------------------------------------------
@@ -35,8 +36,8 @@
bit MD_DEV,(ix+FAB_MODE##) ;Skip if the FAB is for a
jr z,wrch_disk_file ; disk file.
;
- ld l,(ix+FAB_ID##+2) ;Get jump table address
- ld h,(ix+FAB_ID##+3) ; into HL.
+ ld l,(ix+FAB_VOLUME_ID##+2) ;Get jump table address
+ ld h,(ix+FAB_VOLUME_ID##+3) ; into HL.
inc hl
inc hl
inc hl ;HL -> WRITE routine
@@ -85,8 +86,8 @@ wrch_disk_file: ex af,af'
jr z,rdch_disk_file ; disk file.
;
res MD_EOF,(ix+FAB_MODE##) ;Clear end-of-file condition
- ld l,(ix+FAB_ID##+2) ;Get jump table address
- ld h,(ix+FAB_ID##+3) ; into HL.
+ ld l,(ix+FAB_VOLUME_ID##+2) ;Get jump table address
+ ld h,(ix+FAB_VOLUME_ID##+3) ; into HL.
push bc
call JP_HL ;Call the driver's RDCH
pop de ; routine to read a character.
@@ -203,21 +204,21 @@ endif
push de ;Copy the compatible portion
ex (sp),ix ; of the FIB into the new
pop hl ; FAB as a start for
- ld bc,FAB_FIB## ; setting it up.
+ ld bc,FAB_END_OF_FIB## ; setting it up.
ldir
pop bc ;Get file handle back
pop de ;DE -> directory entry
;
- ld (ix+FAB_SA##),ATM_HID+ATM_SYS ;Set search attributes
+ ld (ix+FAB_SEARCH_ATTRIBUTES##),ATM_HID+ATM_SYS ;Set search attributes
; so that any file, but
; no sub-directories
; will be found.
;
xor a
- ld (ix+FAB_PTR##),a ;Set the four byte file
- ld (ix+FAB_PTR##+1),a ; pointer to zero in the
- ld (ix+FAB_PTR##+2),a ; file access block.
- ld (ix+FAB_PTR##+3),a
+ ld (ix+FAB_FILE_POINTER##),a ;Set the four byte file
+ ld (ix+FAB_FILE_POINTER##+1),a ; pointer to zero in the
+ ld (ix+FAB_FILE_POINTER##+2),a ; file access block.
+ ld (ix+FAB_FILE_POINTER##+3),a
;
pop hl
ex af,af' ;Get access mode byte back
@@ -280,7 +281,7 @@ open_ret_1: pop hl ;Return with error code
PROC M_ENSURE
do_ensure: call ENSURE_FAB ;Update dir entry if required
- ld a,(ix+FAB_DRV##) ;Flush any dirty buffers for
+ ld a,(ix+FAB_DRIVE_NUMBER##) ;Flush any dirty buffers for
pcall FL_LOG ; this drive.
xor a
ret ;Return with no error.
@@ -388,7 +389,7 @@ do_ensure: call ENSURE_FAB ;Update dir entry if required
PROC F_SEEK
;
; This routine does the "move file handle pointer" KBDOS function call. It
-; simply locates the FAB for this file handle and modifies the FAB_PTR field
+; simply locates the FAB for this file handle and modifies the FAB_FILE_POINTER field
; according to the offset and method code passed.
;
; Entry: B = File handle
@@ -417,26 +418,26 @@ do_ensure: call ENSURE_FAB ;Update dir entry if required
ld bc,0 ;Jump with BC:HL=0 if offset
or a ; is from start of the file.
jr z,seek_got_start
- ld l,(ix+FAB_PTR##)
- ld h,(ix+FAB_PTR##+1)
- ld c,(ix+FAB_PTR##+2) ;Jump with BC:HL = current
- ld b,(ix+FAB_PTR##+3) ; position if offset if from
+ ld l,(ix+FAB_FILE_POINTER##)
+ ld h,(ix+FAB_FILE_POINTER##+1)
+ ld c,(ix+FAB_FILE_POINTER##+2) ;Jump with BC:HL = current
+ ld b,(ix+FAB_FILE_POINTER##+3) ; position if offset if from
dec a ; current position.
jr z,seek_got_start
- ld l,(ix+FAB_SIZE##)
- ld h,(ix+FAB_SIZE##+1) ;Else set BC:HL = file size
- ld c,(ix+FAB_SIZE##+2) ; if offset is from end of
- ld b,(ix+FAB_SIZE##+3) ; the file.
+ ld l,(ix+FAB_FILE_SIZE##)
+ ld h,(ix+FAB_FILE_SIZE##+1) ;Else set BC:HL = file size
+ ld c,(ix+FAB_FILE_SIZE##+2) ; if offset is from end of
+ ld b,(ix+FAB_FILE_SIZE##+3) ; the file.
seek_got_start:
add hl,de ;Add low word of offset to
ex (sp),hl ; base and get result into
pop de ; register DE.
adc hl,bc ;Add high word of offset
ex de,hl ; to base and get whole
- ld (ix+FAB_PTR##),l ; result into DE:HL.
- ld (ix+FAB_PTR##+1),h
- ld (ix+FAB_PTR##+2),e ;Store the new file pointer
- ld (ix+FAB_PTR##+3),d ; and return with no error.
+ ld (ix+FAB_FILE_POINTER##),l ; result into DE:HL.
+ ld (ix+FAB_FILE_POINTER##+1),h
+ ld (ix+FAB_FILE_POINTER##+2),e ;Store the new file pointer
+ ld (ix+FAB_FILE_POINTER##+3),d ; and return with no error.
xor a
ret
;
@@ -478,8 +479,8 @@ seek_got_start:
ret z
ex af,af'
;
- ld l,(ix+FAB_ID##+2) ;HL -> device jump table
- ld h,(ix+FAB_ID##+3) ; in anticipation.
+ ld l,(ix+FAB_VOLUME_ID##+2) ;HL -> device jump table
+ ld h,(ix+FAB_VOLUME_ID##+3) ; in anticipation.
;
or a
jr z,get_handle_mode ;Get file handle info
@@ -513,11 +514,11 @@ get_handle_mode:ld e,(ix+FAB_MODE##) ;Get mode flags into register
bit MD_DEV,e ; file handle.
ret nz
;
-chk_file_end: ld e,(ix+FAB_DRV##) ;E := logical drive number
+chk_file_end: ld e,(ix+FAB_DRIVE_NUMBER##) ;E := logical drive number
dec e ; (0=>A: etc).
ld b,4
-test_eof_loop: ld a,(ix+FAB_PTR##+3) ;Loop to compare the file
- cp (ix+FAB_SIZE##+3) ; pointer with the file size
+test_eof_loop: ld a,(ix+FAB_FILE_POINTER##+3) ;Loop to compare the file
+ cp (ix+FAB_FILE_SIZE##+3) ; pointer with the file size
jr c,not_file_eof ; and set the EOF bit if the
jr nz,is_file_eof ; pointer is at or beyond the
dec ix ; end of the file.
@@ -529,7 +530,7 @@ not_file_eof: xor a
;
; ----------------------------------------
;
-chk_in_status: bit AC_RD,(ix+FAB_ACC##) ;Never ready from input if
+chk_in_status: bit AC_RD,(ix+FAB_ACCESS_MODE##) ;Never ready from input if
jr nz,status_not_rdy ; open in write only mode
bit MD_DEV,(ix+FAB_MODE##)
jr nz,chk_dev_status
@@ -543,7 +544,7 @@ else
endif
ret
;
-chk_out_status: bit AC_WR,(ix+FAB_ACC##) ;Never ready for output if
+chk_out_status: bit AC_WR,(ix+FAB_ACCESS_MODE##) ;Never ready for output if
jr nz,status_not_rdy ; open in read only mode
inc hl
inc hl ;Adjust HL for WRST device
@@ -622,7 +623,7 @@ screen_sz_dev: ld bc,3*4 ;For a device, ask the device
call CHECK_REDIR ; if required.
;
call ENSURE_FAB_1 ;Update and find the directory
- set AC_DEAD,(ix+FAB_ACC##) ; entry for this FAB and mark
+ set AC_DEAD,(ix+FAB_ACCESS_MODE##) ; entry for this FAB and mark
or a ; it as dead now.
ret nz
;
@@ -798,7 +799,7 @@ FATTR3:
ret nz
;
pcall DI_SAME ;Get the directory entry back
- ld hl,DR_ATTR## ; and extract the attributes
+ ld hl,DR_ATTRIBUTES## ; and extract the attributes
add hl,de ; byte from it.
ld l,(hl)
xor a
@@ -848,7 +849,7 @@ FATTR3:
ret nz ; and moan if error.
call REOPEN_FAB ;Update the FAB
;
-get_hattrs: ld l,(ix+FAB_ATTR##) ;Get the attributes byte
+get_hattrs: ld l,(ix+FAB_ATTRIBUTES##) ;Get the attributes byte
xor a ; from the file access block
ret ; and return with no error.
;
@@ -900,7 +901,7 @@ FTIME3:
ret nz ; error.
;
pcall DI_SAME ;Get the directory entry back
- ld hl,DR_TIME## ; and extract the date and
+ ld hl,DR_UPDATED_TIME## ; and extract the date and
add hl,de ; time from it into DE and
ld e,(hl) ; HL for return.
inc hl
@@ -961,10 +962,10 @@ FTIME3:
ret nz ; in the directory entry and
call REOPEN_FAB ; update the FAB if OK.
;
-get_hdate_time: ld e,(ix+FAB_TIME##) ;Get date and time into
- ld d,(ix+FAB_TIME##+1) ; DE and HL from the file
- ld l,(ix+FAB_DATE##) ; access block, and return
- ld h,(ix+FAB_DATE##+1) ; with no error.
+get_hdate_time: ld e,(ix+FAB_MODIFIED_TIME##) ;Get date and time into
+ ld d,(ix+FAB_MODIFIED_TIME##+1) ; DE and HL from the file
+ ld l,(ix+FAB_MODIFIED_DATE##) ; access block, and return
+ ld h,(ix+FAB_MODIFIED_DATE##+1) ; with no error.
xor a
ret
;
@@ -1026,7 +1027,7 @@ no_handle_match:xor a ;If there is no match then
; B = Parent process id (if A=0)
;
;
- ld hl,MAX_HAND##+1 ;Allocate another file handle
+ ld hl,MAX_FILE_HANDLES##+1 ;Allocate another file handle
add hl,hl ; vector and give up if not
pcall ALL_P2 ; enough memory.
ret nz
@@ -1041,7 +1042,7 @@ no_handle_match:xor a ;If there is no match then
jr z,no_inheritance ; to inherit anything.
;
inc de
- ld b,MAX_HAND## ;Loop to duplicate any file
+ ld b,MAX_FILE_HANDLES## ;Loop to duplicate any file
inherit_loop: push bc ; handles which want to be
inc hl ; inherited.
inc de
@@ -1055,7 +1056,7 @@ inherit_loop: push bc ; handles which want to be
;
push bc
pop ix ;Skip if this file access
- bit AC_INH,(ix+FAB_ACC##) ; block doesn't want to
+ bit AC_INH,(ix+FAB_ACCESS_MODE##) ; block doesn't want to
jr z,dont_inherit ; be inherited.
;
call INC_FAB_REF ;Bump the reference count but
@@ -1175,7 +1176,7 @@ close_hand_lp1: pop hl ;Get pointer to next "freed
ld d,(hl) ; "freed vector".
push de
- ld b,MAX_HAND##
+ ld b,MAX_FILE_HANDLES##
close_hand_lp2: inc hl
ld e,(hl) ;Walk through this file
inc hl ; handle vector looking
@@ -1324,7 +1325,7 @@ FIND_HANDLE_B:
;
;
ld a,b ;Return with carry clear
- cp MAX_HAND## ; if file handle number is
+ cp MAX_FILE_HANDLES## ; if file handle number is
jr nc,find_hand_inv ; totally stupid
;
ld hl,(HANDLES##) ;Also return NC if there
@@ -1373,10 +1374,10 @@ INC_FAB_REF:
; Corrupts: AF
;
;
- ld a,(ix+FAB_CNT##) ;Bump the file access block's
+ ld a,(ix+FAB_REFERENCE_COUNT##) ;Bump the file access block's
inc a ; reference count but don't
jr z,dont_inc_ref ; let it wrap around.
- ld (ix+FAB_CNT##),a
+ ld (ix+FAB_REFERENCE_COUNT##),a
xor a
ret
;
@@ -1402,12 +1403,12 @@ DEC_FAB_REF:
;
;
;===== start mod DOS2.50
- dec (ix+FAB_CNT##) ;Decrement the reference
- ld a,(ix+FAB_CNT##) ; count by one and return
+ dec (ix+FAB_REFERENCE_COUNT##) ;Decrement the reference
+ ld a,(ix+FAB_REFERENCE_COUNT##) ; count by one and return
; if it is not zero.
-;; ld a,(ix+FAB_CNT##)
+;; ld a,(ix+FAB_REFERENCE_COUNT##)
;; dec a
-;; ld (ix+FAB_CNT##),a
+;; ld (ix+FAB_REFERENCE_COUNT##),a
;===== end mod DOS2.50
ret nz
;
@@ -1415,7 +1416,7 @@ DEC_FAB_REF:
push bc
push ix
ex (sp),hl
- ld bc,FAB_NEXT## ;Point DE to the start of
+ ld bc,FAB_NEXT_ADDRESS## ;Point DE to the start of
add hl,bc ; the file access block
ex de,hl ; in the chain.
ld hl,FAB_CHAIN## ;HL -> start of chain
@@ -1475,7 +1476,7 @@ unlink_loop: ld e,(hl) ; for the one we want to
NEW_FAB:
;
; This routine is called to allocate a new file access block and link it
-; into the chain. Only the "FAB_NEXT" and "FAB_COUNT" fields are set up by
+; into the chain. Only the "FAB_NEXT_ADDRESS" and "FAB_COUNT" fields are set up by
; this routine.
;
; Entry: None
@@ -1484,7 +1485,7 @@ NEW_FAB:
; Corrupts: AF,HL
;
;
- ld hl,FAB_SZ## ;Allocate RAM for the FAB
+ ld hl,FAB_DESC_SIZE## ;Allocate RAM for the FAB
pcall ALL_P2 ; and give up if there is
ret nz ; none spare.
;
@@ -1583,19 +1584,19 @@ OLD_FAB:
xor a ; the descriptor.
ret
;
-old_fab_not_dev:ld c,(ix+FAB_DRV##) ;Validate the drive and
+old_fab_not_dev:ld c,(ix+FAB_DRIVE_NUMBER##) ;Validate the drive and
ld b,1 ; give up if any error.
pcall VAL_FIB
or a
ret nz
;
- ld e,(ix+FAB_FDC##) ;Get first directory cluster
- ld d,(ix+FAB_FDC##+1) ; and store it ready to start
+ ld e,(ix+FAB_FIRST_DIR_CLUSTER##) ;Get first directory cluster
+ ld d,(ix+FAB_FIRST_DIR_CLUSTER##+1) ; and store it ready to start
ld (DE_START##),de ; a directory search
;
push ix
ex (sp),hl ;Point DE at the filename
- ld bc,FAB_NAME## ; in the FAB and expand
+ ld bc,FAB_FILENAME## ; in the FAB and expand
add hl,bc ; it into "FNAME_BUF" ready
ld (STR_PTR##),hl ; for searching for a match
pop hl ; with it.
@@ -1636,10 +1637,10 @@ find_fab_ret: or a ; in the FAB and return
;
;
xor a ;Return immediately if
- bit AC_MOD,(ix+FAB_ACC##) ; file has not been
+ bit AC_MOD,(ix+FAB_ACCESS_MODE##) ; file has not been
ret z ; written to.
;
-ENSURE_FAB_1: bit AC_DEAD,(ix+FAB_ACC##) ;Winge if someone has deleted
+ENSURE_FAB_1: bit AC_DEAD,(ix+FAB_ACCESS_MODE##) ;Winge if someone has deleted
ld a,.HDEAD## ; the file on us.
ret nz
;
@@ -1649,25 +1650,25 @@ ENSURE_FAB_1: bit AC_DEAD,(ix+FAB_ACC##) ;Winge if someone has deleted
bit MD_DEV,(ix+FAB_MODE##) ;Do nothing except return
ret nz ; A=0 if it is a device FAB.
;
- bit AC_MOD,(ix+FAB_ACC##) ;Also do nothing if it has
+ bit AC_MOD,(ix+FAB_ACCESS_MODE##) ;Also do nothing if it has
ret z ; not been written to.
;
pcall DATE_TIME ;Update date and time in
; directory entry.
push ix
ex (sp),hl
- ld bc,FAB_SIZE## ;DE -> file size in FAB
+ ld bc,FAB_FILE_SIZE## ;DE -> file size in FAB
add hl,bc ; used below.
ex de,hl
;
- ld bc,DR_ATTR## ;Set the archive bit in
+ ld bc,DR_ATTRIBUTES## ;Set the archive bit in
add hl,bc ; directory entry since file
set AT_ARC,(hl) ; has been altered.
;
- ld bc,DR_CLU##-DR_ATTR##
+ ld bc,DR_FIRST_CLUSTER##-DR_ATTRIBUTES##
add hl,bc
- ld c,(ix+FAB_FPC##) ;Copy the first cluster
- ld b,(ix+FAB_FPC##+1) ; number from the FAB
+ ld c,(ix+FAB_FIRST_PHYSICAL_CLUSTER##) ;Copy the first cluster
+ ld b,(ix+FAB_FIRST_PHYSICAL_CLUSTER##+1) ; number from the FAB
ld (hl),c ; into the directory
inc hl ; entry.
ld (hl),b
@@ -1687,13 +1688,13 @@ ENSURE_FAB_1: bit AC_DEAD,(ix+FAB_ACC##) ;Winge if someone has deleted
;
REOPEN_FAB: pcall DI_SAME ;Make sure entry is still
; buffered and DE points to it.
- ld a,(ix+FAB_ACC##) ;Use same access mode
+ ld a,(ix+FAB_ACCESS_MODE##) ;Use same access mode
;
PROC OPEN_FAB
;
; This routine is given a file access block and a directory entry and it
; sets up the file access block for accessing that particular file. It is
-; assumed that the "FAB_DRV", "FAB_ID" and "FAB_MODE" fields are already set
+; assumed that the "FAB_DRIVE_NUMBER", "FAB_VOLUME_ID" and "FAB_MODE" fields are already set
; up and this routine sets up the remaining fields. It must also be passed a
; set of file access flags which will be stored in the FAB. The directory
; variables must be set up for the correct directory entry unless it is a
@@ -1713,34 +1714,34 @@ REOPEN_FAB: pcall DI_SAME ;Make sure entry is still
ex af,af'
;
and 00000111b ;Record the access mode byte
- ld (ix+FAB_ACC##),a ; in the FAB.
+ ld (ix+FAB_ACCESS_MODE##),a ; in the FAB.
;
- ld (ix+FAB_UD##),l ;Record the unit descriptor
- ld (ix+FAB_UD##+1),h ; address, directory sector and
+ ld (ix+FAB_UNIT_DESCRIPTOR_ADDRESS##),l ;Record the unit descriptor
+ ld (ix+FAB_UNIT_DESCRIPTOR_ADDRESS##+1),h ; address, directory sector and
ld bc,(DE_SECTOR##) ; entry number within this
- ld (ix+FAB_DSEC##),c ; sector.
- ld (ix+FAB_DSEC##+1),b ;These fields are only used in
+ ld (ix+FAB_DIRECTORY_SECTOR##),c ; sector.
+ ld (ix+FAB_DIRECTORY_SECTOR##+1),b ;These fields are only used in
;===== start add FAT16 (STOR_3 patch)
ld a,(DE_EX_SECTOR##)
- ld (ix+FAB_EX_DSEC##),a
+ ld (ix+FAB_EX_DIRECTORY_SECTOR##),a
;===== end add FAT16
ld a,(DE_ENT##) ; "FAB_SCAN" to check for the
sub (iy+@DE_E_LEFT##) ; same file being accessed.
- ld (ix+FAB_ENT##),a
+ ld (ix+FAB_ENTRIES_PER_SECTOR##),a
;
ld bc,(DE_START##) ;Set the "first directory
- ld (ix+FAB_FDC##),c ; cluster" to the start of
- ld (ix+FAB_FDC##+1),b ; the appropriate directory.
-;
- ld c,(ix+FAB_CLU##) ;Get the start cluster of
- ld b,(ix+FAB_CLU##+1) ; the file and store it
- ld (ix+FAB_FPC##),c ; in the "first physical
- ld (ix+FAB_FPC##+1),b ; cluster" field of the FAB.
- ld (ix+FAB_LPC##),c ;Also store it as "last
- ld (ix+FAB_LPC##+1),b ; accessed physical cluster"
+ ld (ix+FAB_FIRST_DIR_CLUSTER##),c ; cluster" to the start of
+ ld (ix+FAB_FIRST_DIR_CLUSTER##+1),b ; the appropriate directory.
+;
+ ld c,(ix+FAB_START_CLUSTER##) ;Get the start cluster of
+ ld b,(ix+FAB_START_CLUSTER##+1) ; the file and store it
+ ld (ix+FAB_FIRST_PHYSICAL_CLUSTER##),c ; in the "first physical
+ ld (ix+FAB_FIRST_PHYSICAL_CLUSTER##+1),b ; cluster" field of the FAB.
+ ld (ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##),c ;Also store it as "last
+ ld (ix+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1),b ; accessed physical cluster"
xor a ; and set the "last accessed
- ld (ix+FAB_LLC##),a ; logical cluster" field
- ld (ix+FAB_LLC##+1),a ; to zero.
+ ld (ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##),a ; logical cluster" field
+ ld (ix+FAB_LAST_ACCESSED_LOGICAL_CLUSTER##+1),a ; to zero.
;
pop bc ;Restore BC and return
ret ; with A=0.
@@ -1794,15 +1795,15 @@ REOPEN_FAB: pcall DI_SAME ;Make sure entry is still
push ix
pop bc ;BC = address of this FAB
;
- ld ix,FAB_CHAIN##-FAB_NEXT##
-fab_scan_loop: ld l,(ix+FAB_NEXT##) ;Get next entry in FAB
- ld h,(ix+FAB_NEXT##+1) ; chain and jump to
+ ld ix,FAB_CHAIN##-FAB_NEXT_ADDRESS##
+fab_scan_loop: ld l,(ix+FAB_NEXT_ADDRESS##) ;Get next entry in FAB
+ ld h,(ix+FAB_NEXT_ADDRESS##+1) ; chain and jump to
ld a,h ; exit with no error
or l ; if it is end of chain.
jr z,no_fab_match
;
push de
- ld de,-FAB_NEXT## ;Set IX to point to the FAB
+ ld de,-FAB_NEXT_ADDRESS## ;Set IX to point to the FAB
add hl,de ; for this entry in the
pop de ; chain (offset is for link
push hl ; and reference count).
@@ -1850,30 +1851,30 @@ no_fab_match: push bc
;
ld a,(DE_ENT##) ;Return with no match if it is
sub (iy+@DE_E_LEFT##) ; not the same entry within
- cp (ix+FAB_ENT##) ; the directory sector.
+ cp (ix+FAB_ENTRIES_PER_SECTOR##) ; the directory sector.
ret nz
;
push hl
;===== start mod FAT16 (STOR_4 patch)
ld hl,(DE_SECTOR##) ;Return with no match if it
ld a,(DE_EX_SECTOR##)
- ld e,(ix+FAB_DSEC##) ; is not the same directory
- ld d,(ix+FAB_DSEC##+1) ; sector number.
+ ld e,(ix+FAB_DIRECTORY_SECTOR##) ; is not the same directory
+ ld d,(ix+FAB_DIRECTORY_SECTOR##+1) ; sector number.
;assume Cy=0 (check "ret nz")
sbc hl,de
pop hl
ret nz
- sub (ix+FAB_EX_DSEC##)
+ sub (ix+FAB_EX_DIRECTORY_SECTOR##)
;; ld de,(DE_SECTOR##)
-;; ld l,(ix+FAB_DSEC##)
-;; ld h,(ix+FAB_DSEC##+1)
+;; ld l,(ix+FAB_DIRECTORY_SECTOR##)
+;; ld h,(ix+FAB_DIRECTORY_SECTOR##+1)
;; or a
;; sbc hl,de
;===== end mod FAT16
ret nz
;
- ld e,(ix+FAB_UD##) ;Return with no match if it is
- ld d,(ix+FAB_UD##+1) ; not the same unit descriptor
+ ld e,(ix+FAB_UNIT_DESCRIPTOR_ADDRESS##) ;Return with no match if it is
+ ld d,(ix+FAB_UNIT_DESCRIPTOR_ADDRESS##+1) ; not the same unit descriptor
xor a ; address, and with a match
sbc hl,de ; if it is the same.
add hl,de
@@ -1882,12 +1883,12 @@ if 1 ;v2.30
;
push hl
push bc
- ld hl,UD_ID## ;Return with no match if it is
+ ld hl,UD_VOLUME_ID## ;Return with no match if it is
add hl,de ; not the same volume id.
ex de,hl ;DE -> volume id of UD.
push ix
pop hl
- ld bc,FAB_ID## ;HL -> volume id of FAB.
+ ld bc,FAB_VOLUME_ID## ;HL -> volume id of FAB.
add hl,bc
PCALL CP_VOLID
pop bc
diff --git a/source/kernel/bank2/kbios.mac b/source/kernel/bank2/kbios.mac
index 4fcf3e6c..eeed92f4 100644
--- a/source/kernel/bank2/kbios.mac
+++ b/source/kernel/bank2/kbios.mac
@@ -1,10 +1,11 @@
.z80
+ name('kbios')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Kernel BIOS Level Character I/O Routines
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
MSX_CHSNS equ 0009Ch
@@ -92,7 +93,7 @@ MSX_CNSDFG equ 0F3DEh
ld a,0FFh ; return A=FFh and NZ, with
ret nz ; ST_COUNT left as 1.
;
- ld a,ST_TMOUT## ;No character ready so start
+ ld a,CONSOLE_STATUS_CHECK_TIMEOUT## ;No character ready so start
ld (ST_COUNT##),a ; timeout counter going again.
no_char_ready: xor a ;No character ready so return
ret ; A=0 and Z-flag set.
@@ -136,7 +137,7 @@ endif
; jr nc,not_16_char ; character and set or clear
; set 0,(hl) ; the flag appropriately.
;not_16_char:
-; ld a,CH_TMOUT## ;Reset buffer flush timeout
+; ld a,SCREEN_BUFFER_TIMEOUT## ;Reset buffer flush timeout
; ld (CH_COUNT##),a ; to its maximum value
; ld a,(CH_PTR##) ;Get character buffer index
; ld c,a ; and turn it into a buffer
diff --git a/source/kernel/bank2/kinit.mac b/source/kernel/bank2/kinit.mac
index 6cf415fc..79b03d6c 100644
--- a/source/kernel/bank2/kinit.mac
+++ b/source/kernel/bank2/kinit.mac
@@ -1,10 +1,11 @@
.z80
+ name('kinit')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Main Kernel Initialisation Section
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;-----------------------------------------------------------------------------
@@ -178,7 +179,7 @@ link_dev_loop: ld a,(hl) ;Look at next device
inc hl
;
push hl
- ld hl,DD_SZ## ;Allocate RAM for another
+ ld hl,DD_DESC_SIZE## ;Allocate RAM for another
call ALL_P2 ; device descriptor and
pop de ; die if not enough memory.
ld a,6
@@ -193,7 +194,7 @@ kinit_fail_nz: jr nz,kinit_fail
ldi ;Copy address of device
ldi ; handler into descriptor.
ex de,hl
- ld bc,DD_MODE##-(DD_NEXT##+4) ;Copy the device flags and
+ ld bc,DD_MODE##-(DD_NEXT_DESC_ADDRESS##+4) ;Copy the device flags and
add hl,bc ; device name into the
ex de,hl ; device descriptor.
ld bc,1+8+3
@@ -211,7 +212,7 @@ link_dev_done:
;
; +++++ SETUP SECTOR BUFFER CHAIN +++++
;
- ld b,DEF_BUFS## ;Allocate the default number
+ ld b,DEFAULT_SECTOR_BUFFERS## ;Allocate the default number
pcall F_BUFFER ; of sector buffers.
;
; +++++ INITIALISE FILE HANDLE SYSTEM +++++
@@ -300,7 +301,7 @@ INIT_UNITS:
; This routine creates and initialises all the unit descriptors for a
; particular disk driver (including the RAM disk). A pointer to the MSX DPB is
; put in the unit descriptor. The unit descriptor has its UD_SLOT, UD_OFFSET,
-; UD_DPB, UD_REL and UD_PHYS fields set up and UD_CDIR is set -ve to indicate
+; UD_DPB_ADDRESS, UD_RELATIVE_UNIT_NUMBER and UD_PHYSICAL_UNIT fields set up and UD_CURRENT_DIR_FIRST_CLUSTER is set -ve to indicate
; the root directory. The rest of the unit descriptor is zeroed. A pointer
; to the unit descriptor is store in the appropriate place in UNIT_TAB unless
; it is the RAM unit being initialised (physical unit zero) in which case it
@@ -320,7 +321,7 @@ INIT_UNITS:
init_unit_loop: ex af,af'
push hl ;Save entry table offset
;
- ld hl,UD_SZ## ;Allocate RAM for a unit
+ ld hl,UD_SIZE## ;Allocate RAM for a unit
call ALL_P2 ; descriptor.
jr nz,init_unit_fail ;Error if not enough RAM.
ex de,hl ;Get UD address into DE and
@@ -333,18 +334,18 @@ init_unit_loop: ex af,af'
ld b,(hl) ; pointer for next one.
inc hl
push hl ;Save new DPB pointer address
- ld (ix+UD_DPB##),c ;Store a pointer to the DPB
- ld (ix+UD_DPB##+1),b ; in the unit descriptor.
+ ld (ix+UD_DPB_ADDRESS##),c ;Store a pointer to the DPB
+ ld (ix+UD_DPB_ADDRESS##+1),b ; in the unit descriptor.
;
ld a,(bc) ;Get physical unit number
inc a ; from DPB and store it in
- ld (ix+UD_PHYS##),a ; unit descriptor after
+ ld (ix+UD_PHYSICAL_UNIT##),a ; unit descriptor after
ld l,a ; adjusting it.
ld h,0 ;HL := unit number (1...8)
;
inc bc ;Get media descriptor from
ld a,(bc) ; DPB and store it in the
- ld (ix+UD_MBYTE##),a ; unit descriptor.
+ ld (ix+UD_MEDIA_DESC_BYTE##),a ; unit descriptor.
;
ld bc,RM_UD## ;If physical unit is non-zero
jr z,init_ramunit ; (ie. not RAM disk) then
@@ -363,14 +364,14 @@ init_ramunit: add hl,hl ; UNIT_TAB depending on the
ld (ix+UD_OFFSET##),l ; .. entry table offset
;
ex af,af'
- ld (ix+UD_REL##),a ;Store relative unit number
+ ld (ix+UD_RELATIVE_UNIT_NUMBER##),a ;Store relative unit number
inc a ; and increment for next time.
- ld (ix+UD_CDIR##+1),0FFh ;set current dir -ve => root
+ ld (ix+UD_CURRENT_DIR_FIRST_CLUSTER##+1),0FFh ;set current dir -ve => root
;===== start add FAT16 (01BDh patch)
- ld (ix+UD_CDIR##),0FFh
+ ld (ix+UD_CURRENT_DIR_FIRST_CLUSTER##),0FFh
;===== end add FAT16
;
- ld (ix+UD_SEG##),0FFh
+ ld (ix+UD_RAM_SEGMENT##),0FFh
djnz init_unit_loop ;Loop for next unit
xor a
ret ;Return with no error
@@ -779,7 +780,7 @@ kbdos_table:
dw f_invalid ; 61h (define abort routine)
dw f_invalid ; 62h (define error routine)
dw ?F_ERROR## -OFFSET ;Get previous error code
- dw ?F_EXPLAI##-OFFSET ;Explain error code
+ dw ?F_EXPLAIN##-OFFSET ;Explain error code
;
dw ?F_FMT## -OFFSET ;Format a disk
dw F_RAMD## ;Create or destroy RAMdisk
diff --git a/source/kernel/bank2/misc.mac b/source/kernel/bank2/misc.mac
index 487e73b0..7949dc67 100644
--- a/source/kernel/bank2/misc.mac
+++ b/source/kernel/bank2/misc.mac
@@ -1,10 +1,11 @@
.z80
+ name('misc')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Miscellaneous KBDOS functions
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -176,8 +177,8 @@ not_login: djnz login_loop ;Loop 'til done all drives
;
push hl ;Get total number of
pop ix ; clusters from UPB and
- ld e,(ix+UD_NCLU##) ; save it on the stack
- ld d,(ix+UD_NCLU##+1) ; for loop testing.
+ ld e,(ix+UD_CLUSTER_COUNT##) ; save it on the stack
+ ld d,(ix+UD_CLUSTER_COUNT##+1) ; for loop testing.
push de
;
ld a,(MFLAGS##)
@@ -202,8 +203,8 @@ NO_ZALLOC:
bit UF_RALL,(ix+UD_FLAGS##)
jr z,ALLOC_NOR
- ld c,(ix+UD_RDCLUS##)
- ld b,(ix+UD_RDCLUS##+1)
+ ld c,(ix+UD_REDUCED_CLUSTER_COUNT##)
+ ld b,(ix+UD_REDUCED_CLUSTER_COUNT##+1)
bit 7,h
jr nz,ALLOC_R
@@ -255,8 +256,8 @@ not_free:
;--- Common code for FAT12 and FAT16
ALLOC_COMMON:
- ld e,(ix+UD_RES##)
- ld d,(ix+UD_RES##+1) ;Get the first FAT sector
+ ld e,(ix+UD_RESERVED_SECTORS##)
+ ld d,(ix+UD_RESERVED_SECTORS##+1) ;Get the first FAT sector
xor a
pcall BF_FAT_SECTOR ; into a buffer.
ld de,BD_DATA##
@@ -278,14 +279,14 @@ endif
bit UF_RALL,(ix+UD_FLAGS##)
jr z,no_reduced_total
- ld e,(ix+UD_RDCLUS##)
- ld d,(ix+UD_RDCLUS##+1) ;Return reduced total size if necessary
+ ld e,(ix+UD_REDUCED_CLUSTER_COUNT##)
+ ld d,(ix+UD_REDUCED_CLUSTER_COUNT##+1) ;Return reduced total size if necessary
no_reduced_total:
- ld c,(ix+UD_DPB##)
- ld b,(ix+UD_DPB##+1) ;Get DPB address and save it
+ ld c,(ix+UD_DPB_ADDRESS##)
+ ld b,(ix+UD_DPB_ADDRESS##+1) ;Get DPB address and save it
push bc ; on stack.
- ld c,(ix+UD_CMSK##)
+ ld c,(ix+UD_CLUSTER_MASK##)
inc c ; C := sectors/cluster
pop ix ;IX := DPB address
xor a
@@ -307,8 +308,8 @@ ALLOC_FAT16:
inc hl
inc hl
- ld e,(ix+UD_RES##)
- ld d,(ix+UD_RES##+1) ;DE = First FAT sector
+ ld e,(ix+UD_RESERVED_SECTORS##)
+ ld d,(ix+UD_RESERVED_SECTORS##+1) ;DE = First FAT sector
ld b,h
ld c,l
@@ -429,7 +430,7 @@ FCISN:
pop ix ; for later and save user's
push de ; pointer for return.
;
- ld bc,UD_PHYS## ;Copy physical unit number
+ ld bc,UD_PHYSICAL_UNIT## ;Copy physical unit number
add hl,bc ; from unit descriptor
ldi ; into the data block.
;
@@ -500,13 +501,13 @@ dp_clear_loop: ld (de),a ;Clear the rest of the
pop de
ldi ;Copy media byte in.
;
- ld l,(ix+UD_NCLU##) ;Get maximum cluster number
- ld h,(ix+UD_NCLU##+1) ; and subtract 2 to get the
+ ld l,(ix+UD_CLUSTER_COUNT##) ;Get maximum cluster number
+ ld h,(ix+UD_CLUSTER_COUNT##+1) ; and subtract 2 to get the
dec hl ; actual number of data
if 0
dec hl ; clusters.
endif
- ld b,(ix+UD_CSHFT##)
+ ld b,(ix+UD_CLUSTER_SHIFT##)
if 0
inc b
endif
@@ -519,8 +520,8 @@ dp_shift_lp: add hl,hl ;Shift this according to the
;;dp_shift_lp: add hl,hl
;===== end mod FAT16
dp_shift_st: djnz dp_shift_lp ; number of data sectors.
- ld c,(ix+UD_SDAT##)
- ld b,(ix+UD_SDAT##+1) ;Add on the first data sector
+ ld c,(ix+UD_FIRST_DATA_SECTOR##)
+ ld b,(ix+UD_FIRST_DATA_SECTOR##+1) ;Add on the first data sector
add hl,bc ; number to get the total
;===== start add FAT16 (0CBAh patch)
adc a,0
@@ -825,7 +826,7 @@ got_buf_bc: set 7,d
; B = Current number of buffers
;
ld a,b ;Don't do anything if too
- cp MIN_BUFS## ; few buffers requested.
+ cp MIN_SECTOR_BUFFERS## ; few buffers requested.
jr c,buffers_done
;
alter_buf_loop: ld a,b ;See how many buffer we have
@@ -847,7 +848,7 @@ alter_buf_loop: ld a,b ;See how many buffer we have
dec (hl) ;Count one less buffer and
jr alter_buf_loop ; loop to check again.
;
-alloc_buffer: ld hl,BD_SZ## ;Too few so allocate one more.
+alloc_buffer: ld hl,BD_DESC_SIZE## ;Too few so allocate one more.
pcall ALL_P2 ;Allocate RAM for the buffer
jr nz,buffers_done ; and stop if out of memory.
ld de,(B_CHAIN##)
@@ -989,13 +990,13 @@ dont_set_dchk:
cp 0CDh
jr nz,DOSVER2
- ld ix,256 + NXTVER##
- ld iy,256*NXTV_HI## + NXTV_LO##
+ ld ix,256 + MAIN_NEXTOR_VERSION##
+ ld iy,256*SEC_NEXTOR_VERSION_HIGH## + SEC_NEXTOR_VERSION_LOW##
ld hl,DOSV0##
DOSVER2:
- ld b,DOSVER##
- ld c,DOSV_LO##+16*DOSV_HI##
+ ld b,MAIN_DOS_VERSION##
+ ld c,SEC_DOS_VERSION_LOW##+16*SEC_DOS_VERSION_HIGH##
xor a
ld d,a
ld e,a
diff --git a/source/kernel/bank2/path.mac b/source/kernel/bank2/path.mac
index 2b93038e..7399106a 100644
--- a/source/kernel/bank2/path.mac
+++ b/source/kernel/bank2/path.mac
@@ -1,10 +1,11 @@
.z80
+ name('path')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Pathname String Handling
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;-----------------------------------------------------------------------------
@@ -42,8 +43,8 @@
; Corrupts: AF,BC,DE,HL,BC',DE',HL'
;
;
- ld (ix+FIB_FLG##),0FFh ;Make sure FIB is flagged
- ld (ix+FIB_SA##),b ;Record search attributes
+ ld (ix+FIB_ID_BYTE##),0FFh ;Make sure FIB is flagged
+ ld (ix+FIB_SEARCH_ATTRIBUTES##),b ;Record search attributes
ld (iy+@PC_FLAGS##),c ;Store parse control flags.
ld (STR_PTR##),de ;Initialise string pointer
;
@@ -60,9 +61,9 @@ given_default: ld d,a
bit PC_NDRV,(iy+@PC_FLAGS##); then give an error if NDRV
ld a,.IDRV## ; flag was set, otherwise use
ret nz ; the specified drive.
-default_drive: ld (ix+FIB_DRV##),d
+default_drive: ld (ix+FIB_DRIVE_NUMBER##),d
;
- bit AT_VOL,(ix+FIB_SA##) ;If volume name flag is set
+ bit AT_VOL,(ix+FIB_SEARCH_ATTRIBUTES##) ;If volume name flag is set
jr nz,force_root ; then force root directory.
;
call GET_CHAR ;If first character after drive
@@ -83,7 +84,7 @@ no_rootdir: call nz,UNGET_CHAR ;If not "\" then put char back
call INIT_WPTH ;Initialise whole path string
;
;
- bit AT_VOL,(ix+FIB_SA##) ;If volume name flag was set
+ bit AT_VOL,(ix+FIB_SEARCH_ATTRIBUTES##) ;If volume name flag was set
jr z,item_loop ; then use separate parsing
ld de,FNAME_BUF## ; routine and don't check for
call PAR_VOL ; device names.
@@ -115,9 +116,9 @@ item_loop: ld de,FNAME_BUF## ;Parse next item out of string
;
PROC PAR_FNM
;
- ld (ix+FIB_FLG##),0FFh ;Make sure FIB is flagged
- ld (ix+FIB_SA##),b ;Record search attributes
- ld (ix+FIB_DRV##),a ;Record logical drive number
+ ld (ix+FIB_ID_BYTE##),0FFh ;Make sure FIB is flagged
+ ld (ix+FIB_SEARCH_ATTRIBUTES##),b ;Record search attributes
+ ld (ix+FIB_DRIVE_NUMBER##),a ;Record logical drive number
ld (iy+@PC_FLAGS##),c ;Store parse control flags
ld (STR_PTR##),de ;Initialise string pointer
ld (STR2_PTR##),de ; and last item pointer.
@@ -476,7 +477,7 @@ NEXT_ITEM:
; located if the "PC_LAST" flag is set and if it is not a totally null item.
;
-; Entry: IX = Pointer to fileinfo block (FIB_DRV accessed)
+; Entry: IX = Pointer to fileinfo block (FIB_DRIVE_NUMBER accessed)
; DE = Pointer to filename in buffer
; HL = Pointer to validated unit descriptor (if PC_VAL
; and PC_DISK flags are both set)
@@ -518,7 +519,7 @@ next_not_last: call NEXT_DIR
; and if so it returns with the device descriptor pointer in HL, otherwise HL
; is preserved, since it may be a unit descriptor pointer. It must be passed
; a pointer to the fileinfo block so that it can store the device descriptor
-; and device entry table address at "FIB_ID" if a device match is found. It
+; and device entry table address at "FIB_VOLUME_ID" if a device match is found. It
; is a global routine because "find_new" must use it after applying its
; template filename in case this gives a device name.
;
@@ -536,17 +537,17 @@ next_not_last: call NEXT_DIR
jr nc,check_not_dev ; with A=0 if it is not.
;
pop af
- ld (ix+FIB_ID##),l ;Store the device descriptor
- ld (ix+FIB_ID##+1),h ; pointer in the FIB.
+ ld (ix+FIB_VOLUME_ID##),l ;Store the device descriptor
+ ld (ix+FIB_VOLUME_ID##+1),h ; pointer in the FIB.
push hl
- ld bc,DD_ADDR##
+ ld bc,DD_DEVICE_HANDLER_ADDRESS##
add hl,bc ;Also get the jump table
ld c,(hl) ; address from the descriptor
inc hl ; and store it in the FIB
ld b,(hl) ; as well.
- ld (ix+FIB_ID##+2),c
- ld (ix+FIB_ID##+3),b
- ld bc,DD_MODE##-(DD_ADDR##+1) ;Get device flags from
+ ld (ix+FIB_VOLUME_ID##+2),c
+ ld (ix+FIB_VOLUME_ID##+3),b
+ ld bc,DD_MODE##-(DD_DEVICE_HANDLER_ADDRESS##+1) ;Get device flags from
add hl,bc ; the device descriptor
ld a,(hl)
;
@@ -569,16 +570,16 @@ FIRST_DIR:
; the first cluster of the directory (which will be -ve if it is the root
; directory) in the variable "DE_START".
;
-; Entry: IX = Address of fileinfo block (FIB_DRV must be set up)
+; Entry: IX = Address of fileinfo block (FIB_DRIVE_NUMBER must be set up)
; Returns: A = Error code (flags not set)
; HL = Address of validated unit descriptor
; Corrupts: AF,DE,HL
;
-; Assumes: UD_PATH=UD_CDIR+2
+; Assumes: UD_CURRENT_DIR_PATH=UD_CURRENT_DIR_FIRST_CLUSTER+2
;
;
push bc
- ld c,(ix+FIB_DRV##) ;Validate the drive in
+ ld c,(ix+FIB_DRIVE_NUMBER##) ;Validate the drive in
ld b,0 ; question and give up
pcall VAL_FIB ; if there was any error.
pop bc
@@ -590,7 +591,7 @@ FIRST_DIR:
bit PC_ROOT,(iy+@PC_FLAGS##);Skip if root directory
jr nz,start_root_nz ; is required.
;
- ld de,UD_CDIR## ;Get current directory cluster
+ ld de,UD_CURRENT_DIR_FIRST_CLUSTER## ;Get current directory cluster
add hl,de ; number from unit descriptor.
ld e,(hl)
inc hl
@@ -610,7 +611,7 @@ FIRST_DIR:
;
ld bc,(STR_PTR##) ;Save string pointer
push bc
- push hl ;Save UD_CDIR pointer
+ push hl ;Save UD_CURRENT_DIR_FIRST_CLUSTER pointer
;
ld a,d ;If cluster is known (<>0) then
or e ; clear flag to suppress disk
@@ -619,7 +620,7 @@ FIRST_DIR:
relocate_dir:
inc hl ;Set string pointer to point
ld (STR_PTR##),hl ; to current directory string.
- ld bc,-UD_PATH##
+ ld bc,-UD_CURRENT_DIR_PATH##
add hl,bc ;Point back at unit descr.
push de
call start_root ;Start at root directory
@@ -923,7 +924,7 @@ not_dot_name: push hl
jr c,tst_name_ret
;
ld bc,11*256+CFM_UP+CFM_VOL;If volume name bit set then
- bit AT_VOL,(ix+FIB_SA##) ; treat all 11 bytes as
+ bit AT_VOL,(ix+FIB_SEARCH_ATTRIBUTES##) ; treat all 11 bytes as
jr nz,tst_vol_name ; one name.
;
ld bc,8*256+0 ;Check that 8 character
@@ -1007,7 +1008,7 @@ tst_dev_loop: pop hl
;
push hl
push de
- ld bc,DD_NAME##
+ ld bc,DD_DEVICE_NAME##
add hl,bc ;Compare the name in the
ld b,8 ; device descriptor with
cmp_dev_loop: ld a,(de) ; the 8 bytes of the given
@@ -1088,7 +1089,7 @@ ADD_WPTH:
; "SQ_NAME" is called to convert the name into an ASCIIZ string in a buffer
; before adding it to the whole path string.
-; Entry: IX -> Fileinfo block, (only FIB_SA examined)
+; Entry: IX -> Fileinfo block, (only FIB_SEARCH_ATTRIBUTES examined)
; DE -> New item to be added (11 byte buffer)
; B = Parse flags for this item (PF_DOT and PF_2DOT are tested)
; Returns: A = Error code if overflow or underflow (flags set)
@@ -1164,14 +1165,14 @@ allow_errors: or a ; whole path string with
; The first character of the filename is passed in register A rather than at
; (DE) to allow for the special 05h fiddle if the filename is in a directory
; entry. A pointer to a fileinfo block must also be passed in register IX, and
-; this is only used to look at the search attributes ("FIB_SA" field) to see
+; this is only used to look at the search attributes ("FIB_SEARCH_ATTRIBUTES" field) to see
; whether it is a volume name or not. The buffer is pre filled wil nulls just
; to keep things nice and tidy.
;
; Entry: DE -> Expanded 11 byte filename
; HL -> Space for ASCIIZ string (13 bytes)
; A = First character of filename
-; IX -> Fileinfo block (only FIB_SA is used)
+; IX -> Fileinfo block (only FIB_SEARCH_ATTRIBUTES is used)
; Returns: DE = DE+11
; HL -> Terminating null of ASCIIZ string
; Corrupts: AF,DE,HL
@@ -1186,7 +1187,7 @@ sq_zero_loop: ld (hl),0 ; with nulls for neatness'
pop hl
;
ld bc,11*256+CFM_UP+CFM_VOL;If volume name flag is set
- bit AT_VOL,(ix+FIB_SA##) ; then treat whole 11 bytes
+ bit AT_VOL,(ix+FIB_SEARCH_ATTRIBUTES##) ; then treat whole 11 bytes
jr nz,sq_volume_name ; as one name & don't upper
; case it.
;
diff --git a/source/kernel/bank2/rw.mac b/source/kernel/bank2/rw.mac
index 1a8286c1..0b2f39d3 100644
--- a/source/kernel/bank2/rw.mac
+++ b/source/kernel/bank2/rw.mac
@@ -1,10 +1,11 @@
.z80
+ name('rw')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Disk Read and Write Routines
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;------------------------------------------------------------------------------
@@ -368,7 +369,7 @@ CORRECT_BUF:
; Returns: None
; Corrupts: AF,AF',BC',DE',HL'
;
-; Assumes: BD_UNIT=2 BD_FLAGS=3 BD_SECT=4 BD_EX_SECT=8
+; Assumes: BD_PHYSICAL_UNIT_NUMBER=2 BD_FLAGS=3 BD_SECTOR_NUMBER=4 BD_EX_SECTOR_NUMBER=8
;
;
pcall FLG_UD ;Flag all buffers for this unit
@@ -377,13 +378,13 @@ correct_loop: push bc
exx
pcall FLG_NEXT ;Get next buffer for this unit
jr z,correct_done ; and jump to return if no more
- ld bc,BD_SECT##
+ ld bc,BD_SECTOR_NUMBER##
add hl,bc
ld e,(hl) ;DE := sector number from this
inc hl ; buffer.
ld d,(hl)
;===== start add FAT16 (DSKBUF patch)
- ld bc,BD_EX_SECT##-BD_SECT##-1
+ ld bc,BD_EX_SECTOR_NUMBER##-BD_SECTOR_NUMBER##-1
add hl,bc
ld a,(hl) ;A := sector number (bit16-22)
; from this buffer
diff --git a/source/kernel/bank2/seg.mac b/source/kernel/bank2/seg.mac
index 8d8947d3..f1c58703 100644
--- a/source/kernel/bank2/seg.mac
+++ b/source/kernel/bank2/seg.mac
@@ -1,10 +1,11 @@
.z80
+ name('seg')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl Allocate or Free Mapper Segment
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
;
;-----------------------------------------------------------------------------
diff --git a/source/kernel/bank2/val.mac b/source/kernel/bank2/val.mac
index ae956865..f9abb6f6 100644
--- a/source/kernel/bank2/val.mac
+++ b/source/kernel/bank2/val.mac
@@ -1,10 +1,11 @@
.z80
+ name('val')
TITLE MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
SUBTTL Validate Disk and Interface to Disk Drivers
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
RAMMOD
MBR_PSTART equ 01BEh ;Start of partition table in MBR
@@ -142,8 +143,8 @@ new_boot_sec: push af
call FIND_UPB
ld de,1 ;Try to read the first FAT
jr nz,upb_no_valid
- ld e,(ix+UPB_RES##)
- ld d,(ix+UPB_RES##+1)
+ ld e,(ix+UPB_RESERVED_SECTORS##)
+ ld d,(ix+UPB_RESERVED_SECTORS##+1)
upb_no_valid:
ld bc,(DATA_SEG##) ; sector and if there was
ld b,1 ; any error then give up
@@ -189,7 +190,7 @@ got_boot_sec: push hl
call SET_RANDOM_VOLID ; Write new volume id even if there is already one,
; for compatibility with previous DOS version
ld hl,UPB_BUF##+NEW_BOOT_SZ+1Eh
- ld de,512-NEW_BOOT_SZ-1Eh ;UPB_BOOT##+NEW_BOOT_SZ-256
+ ld de,512-NEW_BOOT_SZ-1Eh ;UPB_BOOT_CODE##+NEW_BOOT_SZ-256
ld b,0
zero_old_upb: ld (hl),b ;Zero the rest of the boot
inc hl ; sector to keep things
@@ -276,11 +277,11 @@ do_quick_format:
ld bc,512-1
ldir
- ld e,(ix+UD_RES##)
- ld d,(ix+UD_RES##+1) ;DE = First FAT sector
+ ld e,(ix+UD_RESERVED_SECTORS##)
+ ld d,(ix+UD_RESERVED_SECTORS##+1) ;DE = First FAT sector
xor a ;Assume we will work exclusively
ld (DIO_EX_SECTOR##),a ; on the first 32MB of the disk.
- ld b,(ix+UD_NFAT##) ;B = Number of FATs
+ ld b,(ix+UD_NUMBER_OF_FATS##) ;B = Number of FATs
;--- Loop for all FATs
@@ -289,7 +290,7 @@ qf_fats_loop: push bc
;* Clear the first FAT sector
ld hl,UPB_BUF##
- ld a,(ix+UD_MBYTE##)
+ ld a,(ix+UD_MEDIA_DESC_BYTE##)
ld (hl),a
inc hl
ld (hl),0FFh
@@ -310,7 +311,7 @@ qf_is_notfat16:
;* Clear other FAT sectors, if any
- ld a,(ix+UD_SFAT##)
+ ld a,(ix+UD_SECTORS_PER_FAT##)
dec a
jr z,qf_okfat
@@ -325,10 +326,10 @@ qf_okfat: pop bc
;--- Now clear the root directory
- ld e,(ix+UD_SDIR##) ;DE = first directory sector
- ld d,(ix+UD_SDIR##+1)
- ld b,(ix+UD_WDS##) ;B = whole sectors for root directory
- ld a,(ix+UD_ODE##)
+ ld e,(ix+UD_FIRST_ROOT_DIR_SECTOR##) ;DE = first directory sector
+ ld d,(ix+UD_FIRST_ROOT_DIR_SECTOR##+1)
+ ld b,(ix+UD_WHOLE_DIR_SECTORS##) ;B = whole sectors for root directory
+ ld a,(ix+UD_ODD_DIR_ENTRIES##)
or a
jr z,qf_no_ode
inc b
@@ -400,10 +401,10 @@ SET_BOOT_EX:
call GET_VOLID
ld a,b
dec a
- ld hl,UPB_BUF##+UPB_DIRT##
+ ld hl,UPB_BUF##+UPB_DIRTY_FLAG##
jr z,set_boot_ex_end
ld hl,NEW_BOOT
- ld de,UPB_BUF##+UPB_BOOT##
+ ld de,UPB_BUF##+UPB_BOOT_CODE##
ld bc,NEW_BOOT_SZ
ldir
pop hl
@@ -418,25 +419,25 @@ set_boot_ex_std:
call GET_VOLID
ld a,b
cp 2
- ld hl,UPB_BUF##+UPB_RSV##
+ ld hl,UPB_BUF##+UPB_RESERVED##
jr z,set_boot_ex_end
ld hl,NEW_BOOT_STD
- ld de,UPB_BUF##+UPB_PHY##
+ ld de,UPB_BUF##+UPB_PHYSICAL_DRIVE##
ld bc,NEW_STDBOOT_SZ
ldir
ld ix,UPB_BUF## ;Set big sector count to zero
- ld a,(ix+UPB_SEC##) ;if small sector count is not zero
- or (ix+UPB_SEC##+1)
+ ld a,(ix+UPB_TOTAL_SECTORS##) ;if small sector count is not zero
+ or (ix+UPB_TOTAL_SECTORS##+1)
jr z,set_boot_ex_bigs
- ld (ix+UPB_BIGSEC##),0
- ld (ix+UPB_BIGSEC##+1),0
- ld (ix+UPB_BIGSEC##+2),0
- ld (ix+UPB_BIGSEC##+3),0
+ ld (ix+UPB_BIG_TOTAL_SECTORS##),0
+ ld (ix+UPB_BIG_TOTAL_SECTORS##+1),0
+ ld (ix+UPB_BIG_TOTAL_SECTORS##+2),0
+ ld (ix+UPB_BIG_TOTAL_SECTORS##+3),0
set_boot_ex_bigs:
- ld (ix+UPB_BOOT##),0 ;Clear old DOS1 jump, if any
- ld (ix+UPB_BOOT##+1),0
+ ld (ix+UPB_BOOT_CODE##),0 ;Clear old DOS1 jump, if any
+ ld (ix+UPB_BOOT_CODE##+1),0
pop hl
ld bc,UD_FLAGS##
@@ -444,7 +445,7 @@ set_boot_ex_bigs:
bit UF_F16,(hl)
ld a,"2"
jr nz,fatmark_ok
- ld (UPB_BUF##+UPB_FILESYS##+4),a ;Set "FAT12" mark if necessary
+ ld (UPB_BUF##+UPB_FILESYSTEM##+4),a ;Set "FAT12" mark if necessary
fatmark_ok:
or a
ret
@@ -472,8 +473,8 @@ SET_RANDOM_VOLID:
srl b
rla
ld c,a
- ld (UPB_BUF##+UPB_ID##),hl ;Store this as the volume-id
- ld (UPB_BUF##+UPB_ID##+2),bc ; in the boot sector.
+ ld (UPB_BUF##+UPB_RANDOM_ID##),hl ;Store this as the volume-id
+ ld (UPB_BUF##+UPB_RANDOM_ID##+2),bc ; in the boot sector.
ret
; ------------------------------------
@@ -597,7 +598,7 @@ NEW_BOOT_SZ equ $-NEW_BOOT
; HL -> Unit descriptor for this unit (if A=0)
; Corrupts: AF,BC,DE,HL,PAGE1
;
-; Assumes: UD_ID > UD_TIME
+; Assumes: UD_VOLUME_ID > UD_TIME
;
; Note: the flag returned by BUILD_UPB is not checked when B=1,
; since this flag only makes sense when invoked from F_RDDRV/F_WRDRV,
@@ -643,7 +644,7 @@ valfib2:
wfile_loop: push ix
pop hl ;DE -> required volume-id
- ld bc,FIB_ID## ; in the FIB.
+ ld bc,FIB_VOLUME_ID## ; in the FIB.
add hl,bc
ex de,hl
;
@@ -659,7 +660,7 @@ endif
or a ; UPB for this unit.
jr z,no_cur_upb
;
- ld c,UD_ID##-UD_TIME## ;HL -> current volume-id in
+ ld c,UD_VOLUME_ID##-UD_TIME## ;HL -> current volume-id in
add hl,bc ; unit descriptor.
ld c,a ;C := media check timeout
;
@@ -796,10 +797,10 @@ got_old_volid:
push de ;DE -> FIB
push hl
;
- ld bc,UD_ID##
+ ld bc,UD_VOLUME_ID##
add hl,bc
ex de,hl ;Copy the four byte volume-id
- ld c,FIB_ID## ; from the unit descriptor
+ ld c,FIB_VOLUME_ID## ; from the unit descriptor
add hl,bc ; into the FIB.
ex de,hl
ld c,4
@@ -859,7 +860,7 @@ CHECK_MNT:
; done internally by the "BUILD_UPB" routine. It first calls VAL_SAME to
; ensure that the correct disk is in the drive and then does the operation.
; Any error from the operation will be returned to the caller. The UD_TIME
-; field will be set to UD_TMOUT to start the MEDIA CHECK timeout going again.
+; field will be set to UD_MEDIA_CHECK_TIMEOUT to start the MEDIA CHECK timeout going again.
;
; Entry: HL = Address of unit descriptor
; A = Command code (RD_CMD or WR_CMD)
@@ -878,7 +879,7 @@ if 1
call UD_TICK ;Make UD_TIME up to date.
endif
ex (sp),ix ; maximum value since unit
- ld (ix+UD_TIME##),UD_TMOUT##; has just been accessed. If
+ ld (ix+UD_TIME##),UD_MEDIA_CHECK_TIMEOUT##; has just been accessed. If
ex (sp),ix ; DISK_ERR is called then this
pop hl ; will be set back to 1.
;
@@ -906,7 +907,7 @@ VAL_SAME:
; Returns: None
; Corrupts: None
;
-; Assumes: UD_MBYTE=UD_ID+4
+; Assumes: UD_MEDIA_DESC_BYTE=UD_VOLUME_ID+4
;
;
push af
@@ -1079,7 +1080,7 @@ _MCHECK:
;
if 0
push hl
- ld de,UD_DPB##
+ ld de,UD_DPB_ADDRESS##
add hl,de
ld a,(hl) ;Get DPB pointer from
inc hl ; unit descriptor into
@@ -1130,7 +1131,7 @@ TEST_SAME_DISK:
; IX -> UPB as read in by BUILD_UPB
; Returns: Z-flag - Set (Z) => volid and media byte are the same
; Clear (NZ) => volid or media byte are different
-; DE -> UD_ID+4 (only if Z-flag set)
+; DE -> UD_VOLUME_ID+4 (only if Z-flag set)
; Corrupts: AF,BC,DE
;
;
@@ -1140,12 +1141,12 @@ TEST_SAME_DISK:
pop hl
;
push hl ;Now compare volume-id with
- ld bc,UD_ID## ; the current one for this
+ ld bc,UD_VOLUME_ID## ; the current one for this
add hl,bc ; unit
call CP_VOLID
jr nz,pop_hl_ret ;Jump if volume-id different
ld a,(hl)
- cp (ix+UPB_MBYTE##)
+ cp (ix+UPB_MEDIA_DESC_BYTE##)
pop_hl_ret: pop hl ; then assume it is same disk.
ret
;
@@ -1167,12 +1168,12 @@ GET_VOLID:
; 2: standard boot sector
; Corrupts: AF,B,DE,HL
;
-; Assumes: UPB_DIRT=UPB_VOLID+6 UPB_ID=UPB_DIRT+1
+; Assumes: UPB_DIRTY_FLAG=UPB_VOLUME_ID+6 UPB_RANDOM_ID=UPB_DIRTY_FLAG+1
;
;
push ix
pop hl
- ld de,UPB_VOLID##
+ ld de,UPB_VOLUME_ID##
add hl,de
ld de,vid_str
ld b,6
@@ -1180,14 +1181,14 @@ GET_VOLID:
ld b,1
jr z,ok_volid
- ld a,(ix+UPB_EBS##)
+ ld a,(ix+UPB_EXTENDED_SIGNATURE##)
and 28h ;Test for EBS signature (standard disk)
cp 28h
jr nz,no_volid
push ix
pop hl
- ld de,UPB_FILESYS##
+ ld de,UPB_FILESYSTEM##
add hl,de
ld de,fat_str
ld b,4
@@ -1199,7 +1200,7 @@ GET_VOLID:
ok_volid: push ix
pop hl
- ld de,UPB_ID##
+ ld de,UPB_RANDOM_ID##
add hl,de
xor a
ret
@@ -1271,9 +1272,9 @@ DO_MEDIA_CHANGE:
push iy
ld b,(ix+UD_SLOT##)
- ld c,(ix+UD_SEG##)
- ld d,(ix+UD_DI##)
- ld e,(ix+UD_LI##)
+ ld c,(ix+UD_RAM_SEGMENT##)
+ ld d,(ix+UD_DEVICE_INDEX##)
+ ld e,(ix+UD_LUN_INDEX##)
ld ix,UNMAPALL##
call CALL4_PRESERVE_ALT
@@ -1343,10 +1344,10 @@ bupc:
bit UF_FOK,(ix+UD_DFLAGS##)
jr nz,build_upb_okfsec
- ld (ix+UD_FSEC##),0 ;Start by reading the MBR
- ld (ix+UD_FSEC##+1),0 ;(for device-based drivers only)
- ld (ix+UD_FSEC##+2),0
- ld (ix+UD_FSEC##+3),0
+ ld (ix+UD_FIRST_DEVICE_SECTOR##),0 ;Start by reading the MBR
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+1),0 ;(for device-based drivers only)
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+2),0
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+3),0
build_upb_okfsec:
pop af
@@ -1377,7 +1378,7 @@ try_build_upb: ld de,0 ;Try to read the boot sector
push hl
;
- ;If device-based driver, and UD_FSEC not valid,
+ ;If device-based driver, and UD_FIRST_DEVICE_SECTOR not valid,
;find the first available FAT12 or FAT16 partition
ex (sp),ix
@@ -1389,8 +1390,8 @@ try_build_upb: ld de,0 ;Try to read the boot sector
build_upb_do_findpart:
ex (sp),ix
- ld b,(ix+UD_DI##)
- ld c,(ix+UD_LI##)
+ ld b,(ix+UD_DEVICE_INDEX##)
+ ld c,(ix+UD_LUN_INDEX##)
ex (sp),ix
pop hl
@@ -1492,7 +1493,7 @@ found_upb2: pop de
;; call MAKE_UPB ;Create UPB from FATID byte.
;;if 1
;; jr nz,build_upb_err
-;; ld (IX+UPB_VOLID##),0 ;Ensure no "VOL_ID" string
+;; ld (IX+UPB_VOLUME_ID##),0 ;Ensure no "VOL_ID" string
;; ; present.
;;endif
;;found_upb: pop de
@@ -1523,7 +1524,7 @@ FIND_UPB:
;
push ix
ex (sp),hl
- ld de,UPB_SSZ##
+ ld de,UPB_SECTOR_SIZE##
add hl,de
ld d,(hl) ;Sector size must always
inc hl ; be 200h.
@@ -1558,7 +1559,7 @@ FIND_UPB:
or (hl)
jr z,upb_not_found
- ld de,UPB_SFAT##-(UPB_NDIR##+1);Ignore "total sectors"
+ ld de,UPB_SECTORS_PER_FAT##-(UPB_NUM_ROOT_DIR_ENTRIES##+1);Ignore "total sectors"
add hl,de ; and "media byte".
;===== start mod FAT16 (3389h patch)
@@ -1576,7 +1577,7 @@ FIND_UPB:
pop hl ;Here, IX=boot sector, HL=unit desc
jr nz,MKDPB_DEVBASED
- ld b,(ix+UPB_MBYTE##)
+ ld b,(ix+UPB_MEDIA_DESC_BYTE##)
ld a,DP_CMD
call CALL_UNIT
;; ld a,(hl)
@@ -1588,7 +1589,7 @@ FIND_UPB:
;; or a
;; pop hl ;Return with Z-flag set
;;if 1 ;v2.3
-;; ld b,(ix+UPB_MBYTE##)
+;; ld b,(ix+UPB_MEDIA_DESC_BYTE##)
;; ld a,DP_CMD
;; call z,CALL_UNIT
;;endif
@@ -1612,8 +1613,8 @@ MKDPB_DEVBASED:
push ix
ex (sp),hl
pop ix
- ld e,(ix+UD_DPB##)
- ld d,(ix+UD_DPB##+1)
+ ld e,(ix+UD_DPB_ADDRESS##)
+ ld d,(ix+UD_DPB_ADDRESS##+1)
inc de
ld ix,MKDPB##
@@ -1649,13 +1650,13 @@ if 0
ld c,a ;Also keep FATID in C
;
if 0
- ld de,UPB_VOLID##+6 ;Zero enough of the UPB to
+ ld de,UPB_VOLUME_ID##+6 ;Zero enough of the UPB to
add hl,de ; ensure that there is no
- ld b,UPB_VOLID##+6-UPB_SSZ## ; "VOL_ID" string present.
+ ld b,UPB_VOLUME_ID##+6-UPB_SECTOR_SIZE## ; "VOL_ID" string present.
else
- ld de,UPB_BOOT## ;Zero enough of the UPB.
+ ld de,UPB_BOOT_CODE## ;Zero enough of the UPB.
add hl,de
- ld b,UPB_BOOT##-UPB_SSZ##
+ ld b,UPB_BOOT_CODE##-UPB_SECTOR_SIZE##
endif
zero_upb_loop: dec hl
ld (hl),0
@@ -1753,7 +1754,7 @@ else
ret nz ; not supported.
;
push hl
- ld de,UD_DPB##
+ ld de,UD_DPB_ADDRESS##
add hl,de
ld e,(hl) ;DE -> address of DPB
inc hl
@@ -1762,7 +1763,7 @@ else
ex (sp),ix ;IX -> address of DPB
pop hl ;HL -> buffer
push hl
- ld de,UPB_SSZ##
+ ld de,UPB_SECTOR_SIZE##
add hl,de ;Start from UPB.
;
ld c,(ix+2) ;Get sector size.
@@ -1849,10 +1850,10 @@ endif
; Returns: None
; Corrupts: AF,BC,DE
;
-; Assumes: UPB_DIRT=UPB_VOLID+6 UPB_ID=UPB_DIRT+1
-; (UD_CMSK, UD_CSHFT, UD_RES, UD_NFAT, UD_ODE, UD_WDS
-; UD_SFAT, UD_SDIR, UD_SDAT, UD_NCLU, UD_DIRT, UD_ID,
-; and UD_MBYTE) must all be sequential.
+; Assumes: UPB_DIRTY_FLAG=UPB_VOLUME_ID+6 UPB_RANDOM_ID=UPB_DIRTY_FLAG+1
+; (UD_CLUSTER_MASK, UD_CLUSTER_SHIFT, UD_RESERVED_SECTORS, UD_NUMBER_OF_FATS, UD_ODD_DIR_ENTRIES, UD_WHOLE_DIR_SECTORS
+; UD_SECTORS_PER_FAT, UD_FIRST_ROOT_DIR_SECTOR, UD_FIRST_DATA_SECTOR, UD_CLUSTER_COUNT, UD_DIRTY_DISK_FLAG, UD_VOLUME_ID,
+; and UD_MEDIA_DESC_BYTE) must all be sequential.
;
;
call _NEW_UPB
@@ -1900,10 +1901,10 @@ _NEW_UPB:
or UFM_F2
ld (hl),a ;Assume first a FAT12 drive
- ld bc,UD_CMSK##-UD_FLAGS##
+ ld bc,UD_CLUSTER_MASK##-UD_FLAGS##
add hl,bc
;
- ld a,(ix+UPB_CS##) ;Set CLUSTER MASK to:
+ ld a,(ix+UPB_SECTORS_PER_CLUSTER##) ;Set CLUSTER MASK to:
dec a ; (sectors per cluster) - 1.
ld (hl),a
inc hl
@@ -1919,23 +1920,23 @@ cshft_loop: inc c ;Set CLUSTER SHIFT to:
ld (hl),c
inc hl
;
- ld e,(ix+UPB_RES##)
+ ld e,(ix+UPB_RESERVED_SECTORS##)
ld (hl),e ;Copy RESERVED SECTORS straight
inc hl ; from UPB to unit descriptor.
- ld d,(ix+UPB_RES##+1)
+ ld d,(ix+UPB_RESERVED_SECTORS##+1)
ld (hl),d
inc hl
push de
;
- ld b,(ix+UPB_NFAT##) ;Copy NUMBER OF FATs straight
+ ld b,(ix+UPB_NUM_FATS##) ;Copy NUMBER OF FATs straight
ld (hl),b ; from UPB to unit descriptor.
inc hl
;
- ld e,(ix+UPB_NDIR##) ;Get number of root directory
- ld d,(ix+UPB_NDIR##+1) ; entries from UPB.
+ ld e,(ix+UPB_NUM_ROOT_DIR_ENTRIES##) ;Get number of root directory
+ ld d,(ix+UPB_NUM_ROOT_DIR_ENTRIES##+1) ; entries from UPB.
;
ld a,e ;Set ODD DIRECTORY ENTRIES
- and 512/32-1 ; (UD_ODE) to the number of
+ and 512/32-1 ; (UD_ODD_DIR_ENTRIES) to the number of
ld (hl),a ; entries in the last directory
; sector (0...0Fh)
;
@@ -1945,7 +1946,7 @@ dir_sec_loop: srl d ; entries by 16 to get number
dec a
jr nz,dir_sec_loop
cp (hl) ;Set carry if there is a
- inc hl ; partial sector (UD_ODE<>0).
+ inc hl ; partial sector (UD_ODD_DIR_ENTRIES<>0).
ld (hl),e ;Record WHOLE DIRECTORY SECTORS
inc hl ; in unit descriptor
;
@@ -1953,7 +1954,7 @@ dir_sec_loop: srl d ; entries by 16 to get number
inc de ; then count one extra sector
no_partial_sec: ; reserved for directory.
- ld a,(ix+UPB_SFAT##) ;Copy SECTORS PER FAT straight
+ ld a,(ix+UPB_SECTORS_PER_FAT##) ;Copy SECTORS PER FAT straight
ld (hl),a ; from UPB to unit descriptor.
inc hl
;
@@ -1995,16 +1996,16 @@ sfat_no_cy: djnz sfat_loop
inc hl
;
push hl
- ld l,(ix+UPB_SEC##) ;Get total number of sectors
- ld h,(ix+UPB_SEC##+1)
+ ld l,(ix+UPB_TOTAL_SECTORS##) ;Get total number of sectors
+ ld h,(ix+UPB_TOTAL_SECTORS##+1)
;===== start mod FAT16 (TALCLS patch)
ld a,l
or h
ld a,0
jr nz,nclu_fat12
- ld l,(ix+UPB_BIGSEC##) ;Get total number of sectors (23bit)
- ld h,(ix+UPB_BIGSEC##+1)
- ld a,(ix+UPB_BIGSEC##+2)
+ ld l,(ix+UPB_BIG_TOTAL_SECTORS##) ;Get total number of sectors (23bit)
+ ld h,(ix+UPB_BIG_TOTAL_SECTORS##+1)
+ ld a,(ix+UPB_BIG_TOTAL_SECTORS##+2)
nclu_fat12: sbc hl,de ;HL := (data sectors)
sbc a,0
;; or a
@@ -2061,7 +2062,7 @@ endif
push de
push ix
pop hl
- ld de,UPB_FILESYS##
+ ld de,UPB_FILESYSTEM##
add hl,de
ld de,FAT16_S
ld b,5
@@ -2102,7 +2103,7 @@ if 0
push de
push ix
pop hl
- ld bc,UPB_MANU## ;Check if manufacturer starts with "MSXDOS"
+ ld bc,UPB_MANUFACTURER## ;Check if manufacturer starts with "MSXDOS"
add hl,bc
ld de,msxdos_str
ld b,6
@@ -2115,7 +2116,7 @@ if 0
push de
push ix
pop hl
- ld bc,UPB_MANU## ;Check if manufacturer starts with "NEXTOR"
+ ld bc,UPB_MANUFACTURER## ;Check if manufacturer starts with "NEXTOR"
add hl,bc
ld de,nextor_str
ld b,6
@@ -2153,13 +2154,13 @@ upb_dos220:
ldir
ex de,hl
;
- ld a,(ix+UPB_MBYTE##) ;Copy MEDIA DESCRIPTOR BYTE
+ ld a,(ix+UPB_MEDIA_DESC_BYTE##) ;Copy MEDIA DESCRIPTOR BYTE
; from UPB to unit descriptor
ld (hl),a
pop hl
push hl
- ld bc,UD_ACLU##
+ ld bc,UD_ALLOCATION_CLUSTER##
add hl,bc
ld (hl),1 ;Initialize next cluster to check for allocation to 2
inc hl ;(it's stored as value-1)
@@ -2177,10 +2178,10 @@ upb_dos220:
bit UF_F16,(ix+UD_FLAGS##)
jr z,reduce_end
- ld e,(ix+UD_NCLU##)
- ld d,(ix+UD_NCLU##+1)
+ ld e,(ix+UD_CLUSTER_COUNT##)
+ ld d,(ix+UD_CLUSTER_COUNT##+1)
dec de ;DE=Actual cluster count
- ld a,(ix+UD_CMSK##)
+ ld a,(ix+UD_CLUSTER_MASK##)
ld h,80h ;Start by assuming 32768 clusters...
srl a ;...and 2 sectors/cluster...
reduce_clus_lp:
@@ -2201,13 +2202,13 @@ end_reduce_clus:
jr nc,reduce_set ;cluster count and actual count.
ex de,hl
reduce_set:
- ld (ix+UD_RDCLUS##),e
- ld (ix+UD_RDCLUS##+1),d
+ ld (ix+UD_REDUCED_CLUSTER_COUNT##),e
+ ld (ix+UD_REDUCED_CLUSTER_COUNT##+1),d
;--- Set the reduced allocation information mode flag
; if necessary
- ld b,(ix+UD_PHYS##)
+ ld b,(ix+UD_PHYSICAL_UNIT##)
;*** NOTE: M80 gives a R error on "if MAX_UNITS" lines
; and compiles always the else clause.
@@ -2255,7 +2256,7 @@ z80mode_done:
if 1
;
; Build MSX DPB from unit descriptor.
-; Assumes: UD_DPB=2, ...etc.
+; Assumes: UD_DPB_ADDRESS=2, ...etc.
;
push hl
inc hl
@@ -2276,11 +2277,11 @@ if 1
ld (hl),4
inc hl
ex de,hl
- ld bc,UD_CMSK##-UD_DPB##-1 ;Copy down
- add hl,bc ; UD_CMSK, UD_CSHFT,
- ld bc,1+1+2+1 ; UD_RES and UD_NFAT.
+ ld bc,UD_CLUSTER_MASK##-UD_DPB_ADDRESS##-1 ;Copy down
+ add hl,bc ; UD_CLUSTER_MASK, UD_CLUSTER_SHIFT,
+ ld bc,1+1+2+1 ; UD_RESERVED_SECTORS and UD_NUMBER_OF_FATS.
ldir
- ld c,(hl) ;Get UD_ODE and UD_WDS
+ ld c,(hl) ;Get UD_ODD_DIR_ENTRIES and UD_WHOLE_DIR_SECTORS
inc hl
ld a,(hl) ;Calc number of directory
inc hl ; entries.
@@ -2291,14 +2292,14 @@ if 1
or c
ld (de),a ;Store low byte
inc de
- push hl ;Save pointer to UD_SFAT
+ push hl ;Save pointer to UD_SECTORS_PER_FAT
inc hl
inc hl
inc hl
- ld bc,2+2 ;Copy down UD_SDAT and UD_NCLU
+ ld bc,2+2 ;Copy down UD_FIRST_DATA_SECTOR and UD_CLUSTER_COUNT
ldir
pop hl
- ld bc,1+2 ;Copy down UD_SFAT and UD_SDIR
+ ld bc,1+2 ;Copy down UD_SECTORS_PER_FAT and UD_FIRST_ROOT_DIR_SECTOR
ldir
pop hl
;
@@ -2309,7 +2310,7 @@ endif
push hl
push bc
;===== start mod FAT16 (CLST_A patch)
- ld bc,UD_CDIR##
+ ld bc,UD_CURRENT_DIR_FIRST_CLUSTER##
add hl,bc ;Look at current dir cluster
pop bc
ld a,(hl)
@@ -2318,7 +2319,7 @@ endif
inc a ;Skip if it is -ve (root dir)
jr z,no_cur_dir
xor a
-;; ld bc,UD_CDIR##+1
+;; ld bc,UD_CURRENT_DIR_FIRST_CLUSTER##+1
;; add hl,bc
;; pop bc
;; xor a
@@ -2484,11 +2485,11 @@ _CUN_RW:
ld b,0
add hl,bc
dec hl ;HL = Last sector to access
- ld a,(iy+UD_MXS##+1)
+ ld a,(iy+UD_MOUNT_MAX_SECTOR##+1)
cp h
jp c,RET_EXX_RNF_POP
jr nz,CUN_OKSEC
- ld a,(iy+UD_MXS##)
+ ld a,(iy+UD_MOUNT_MAX_SECTOR##)
cp l
jp c,RET_EXX_RNF_POP
CUN_OKSEC:
@@ -2500,7 +2501,7 @@ CUN_OKSEC:
push af
cp WR_CMD
jr nz,CUN_OKWP
- bit 0,(iy+UD_MFLAGS##) ;Mounted as read only?
+ bit 0,(iy+UD_MOUNT_FLAGS##) ;Mounted as read only?
jp nz,RET_WP_POP
CUN_OKWP:
@@ -2508,7 +2509,7 @@ CUN_OKWP:
push de
- ld e,(iy+UD_DRV##)
+ ld e,(iy+UD_MOUNT_DRIVE##)
sla e
ld d,0
ld hl,UNIT_TAB##+2
@@ -2519,11 +2520,11 @@ CUN_OKWP:
ex de,hl ;HL=Address of unit descriptor for the drive of the mounted file
ex (sp),hl ;HL=Sector number, address of unit descriptor in stack
- ld e,(iy+UD_SSEC##)
- ld d,(iy+UD_SSEC##+1)
+ ld e,(iy+UD_MOUNT_FIRST_DRIVE_SECTOR##)
+ ld d,(iy+UD_MOUNT_FIRST_DRIVE_SECTOR##+1)
add hl,de
ld a,0
- adc a,(iy+UD_SSEC##+2)
+ adc a,(iy+UD_MOUNT_FIRST_DRIVE_SECTOR##+2)
ld (DIO_EX_SECTOR##),a
ex de,hl ;DE=Updated sector number
@@ -2545,10 +2546,10 @@ CUN_NO_MOUNT:
ex af,af'
push af
;
- ld a,(ix+UD_PHYS##) ;Record target drive number
+ ld a,(ix+UD_PHYSICAL_UNIT##) ;Record target drive number
dec a ; for "prompt" routine.
ld (TARGET##),a
- ld a,(ix+UD_REL##) ;Get relative unit number
+ ld a,(ix+UD_RELATIVE_UNIT_NUMBER##) ;Get relative unit number
ex af,af' ; into A' for disk driver.
ld c,a ;C := command code
;
@@ -2652,14 +2653,14 @@ rd_wr_cmd: ex af,af' ;Put unit number in A'
;===== start mod FAT16 (SETNUM patch/add 23bit sector address support)
push af
bit UF_F16,(ix+UD_FLAGS##) ;Check FAT16 flag
- ld a,(ix+UD_MBYTE##)
+ ld a,(ix+UD_MEDIA_DESC_BYTE##)
jr z,rd_wr_cmd_16bit_sec ;C := media descriptor byte
ld a,(DIO_EX_SECTOR##) ;C := sector number (bit16-22)
rd_wr_cmd_16bit_sec:
ld c,a
pop af
-;; ld c,(ix+UD_MBYTE##)
+;; ld c,(ix+UD_MEDIA_DESC_BYTE##)
;===== end mod FAT16
push bc ;Save sector count (in B)
call CALL_DRV ;Call the disk driver
@@ -2681,13 +2682,13 @@ mc_cmd_routine: ex af,af' ;Put unit number in A'
ld hl,4003h ;DSKCHG is 2nd jump in table
exx
ld b,0 ;B := 0 initially
- ld c,(ix+UD_MBYTE##) ;C := media descriptor byte
+ ld c,(ix+UD_MEDIA_DESC_BYTE##) ;C := media descriptor byte
;===== start add FAT16 (DOS2.50 original patch)
set 7,c ;ignore FAT12 flag
;===== end add FAT16
if 1
- ld l,(ix+UD_DPB##) ;HL := DPB pointer
- ld h,(ix+UD_DPB##+1)
+ ld l,(ix+UD_DPB_ADDRESS##) ;HL := DPB pointer
+ ld h,(ix+UD_DPB_ADDRESS##+1)
endif
call CALL_DRV ;Call the disk driver
jr c,mchk_cmd_err
@@ -2703,13 +2704,13 @@ dp_cmd_routine: ex af,af' ;Put unit number in A'
ld hl,4006h ;GETDPB is 3rd jump in table
exx
;B := FATid byte
- ld c,(ix+UD_MBYTE##) ;C := media descriptor byte
+ ld c,(ix+UD_MEDIA_DESC_BYTE##) ;C := media descriptor byte
;===== start add FAT16 (DOS2.50 original patch)
set 7,c ;ignore FAT12 flag
;===== end add FAT16
if 1
- ld l,(ix+UD_DPB##) ;HL := DPB pointer
- ld h,(ix+UD_DPB##+1)
+ ld l,(ix+UD_DPB_ADDRESS##) ;HL := DPB pointer
+ ld h,(ix+UD_DPB_ADDRESS##+1)
endif
call CALL_DRV ;Call the disk driver
ld a,.NCOMP## ;Incompatible media if error
@@ -2813,12 +2814,12 @@ rdwr_devcmd:
push af ;Save read/write flag and required segment
push hl
- ld l,(ix+UD_FSEC##) ;Calculate sector number
- ld h,(ix+UD_FSEC##+1)
+ ld l,(ix+UD_FIRST_DEVICE_SECTOR##) ;Calculate sector number
+ ld h,(ix+UD_FIRST_DEVICE_SECTOR##+1)
add hl,de
ld (TMP_SEC##),hl
- ld l,(ix+UD_FSEC##+2)
- ld h,(ix+UD_FSEC##+3)
+ ld l,(ix+UD_FIRST_DEVICE_SECTOR##+2)
+ ld h,(ix+UD_FIRST_DEVICE_SECTOR##+3)
ld a,(DIO_EX_SECTOR##)
ld e,a
ld d,0
@@ -2830,10 +2831,10 @@ rdwr_devcmd:
ex af,af'
pop af ;Cy'=read/write flag
ld c,a
- ld a,(ix+UD_DI##) ;A'=Device index
+ ld a,(ix+UD_DEVICE_INDEX##) ;A'=Device index
ex af,af'
ld a,c ;A=Required segment
- ld c,(ix+UD_LI##) ;C=LUN index
+ ld c,(ix+UD_LUN_INDEX##) ;C=LUN index
ld de,TMP_SEC##
push bc
@@ -2864,9 +2865,9 @@ mc_devcmd_remv:
exx
ex af,af'
- ld a,(ix+UD_DI##) ;A'=Device index
+ ld a,(ix+UD_DEVICE_INDEX##) ;A'=Device index
ex af,af'
- ld b,(ix+UD_LI##) ;B=LUN index
+ ld b,(ix+UD_LUN_INDEX##) ;B=LUN index
call CALL_DRV
or a
jr z,mc_devcmd_err
diff --git a/source/kernel/bank3/CPM32.EXE b/source/kernel/bank3/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank3/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank3/L80.CPM b/source/kernel/bank3/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank3/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank3/LIB80.CPM b/source/kernel/bank3/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank3/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank3/M80.CPM b/source/kernel/bank3/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank3/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank3/b3.mac b/source/kernel/bank3/b3.mac
index 9caf8935..62247c32 100644
--- a/source/kernel/bank3/b3.mac
+++ b/source/kernel/bank3/b3.mac
@@ -1,7 +1,7 @@
.z80
BANK equ 3
;
- include BANK.INC
- include B0LAB_B3.INC
+ include ../bank.inc
+ include ../bank0/b0lab_b3.inc
;
end
diff --git a/source/kernel/bank3/dos1ker.mac b/source/kernel/bank3/dos1ker.mac
index 8d4dc66e..3e048370 100644
--- a/source/kernel/bank3/dos1ker.mac
+++ b/source/kernel/bank3/dos1ker.mac
@@ -14,6 +14,7 @@
.Z80
+ name('dos1ker')
;ASEG
;ORG 04100H
@@ -9056,7 +9057,7 @@ NEW_ERRS:
;many games to not work)
ALLFBUF:
- ld a,(IN_EMU##)
+ ld a,(IN_EMU_MODE##)
or a
jp z,A5EC8 ;Jump to actual allocation if not in emulation mode...
diff --git a/source/kernel/bank4/40ff.mac b/source/kernel/bank4/40ff.mac
index a6340152..f1c05dd7 100644
--- a/source/kernel/bank4/40ff.mac
+++ b/source/kernel/bank4/40ff.mac
@@ -1,3 +1,4 @@
+ name('40ff')
aseg
; org 40FFh
org 40FEh
diff --git a/source/kernel/bank4/CPM32.EXE b/source/kernel/bank4/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank4/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank4/L80.CPM b/source/kernel/bank4/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank4/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank4/LIB80.CPM b/source/kernel/bank4/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank4/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank4/M80.CPM b/source/kernel/bank4/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank4/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank4/b4.mac b/source/kernel/bank4/b4.mac
index c661b1c5..3eb204df 100644
--- a/source/kernel/bank4/b4.mac
+++ b/source/kernel/bank4/b4.mac
@@ -1,7 +1,8 @@
.z80
+ name('b4')
BANK equ 4
;
- include BANK.INC
- include B2LABELS.INC
+ include ../bank.inc
+ include ../bank2/b2labels.inc
;
end
diff --git a/source/kernel/bank4/bkalloc.mac b/source/kernel/bank4/bkalloc.mac
index 092f0e01..ff1d7318 100644
--- a/source/kernel/bank4/bkalloc.mac
+++ b/source/kernel/bank4/bkalloc.mac
@@ -1,10 +1,11 @@
.z80
+ name('bkalloc')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Block memory allocation
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;
;WARNING: These routines are no longer part of Nextor as of v2.1.0.
diff --git a/source/kernel/bank4/cpm.mac b/source/kernel/bank4/cpm.mac
index 0dc261e7..d5b811e1 100644
--- a/source/kernel/bank4/cpm.mac
+++ b/source/kernel/bank4/cpm.mac
@@ -1,10 +1,11 @@
.z80
+ name('cpm')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl CP/M Disc Functions
;*****************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;RAMMOD ;Removed since now this code is ran from bank 4 of ROM
;
;-----------------------------------------------------------------------------
@@ -62,7 +63,7 @@ OPEN_ENTRY: CALL M_F_F ;Locate the file and moan
LD A,(APPEND_FLAG##) ;If this was an append, then
OR A ; set up drive in the FCB, so
JR Z,NOT_APPEND ; reads/writes will work.
- LD A,(FIB_1##+FAB_DRV##) ;Drive in FAB.
+ LD A,(FIB_1##+FAB_DRIVE_NUMBER##) ;Drive in FAB.
LD (HL),A
NOT_APPEND: CALL SAVE_FNAME ;Copy the filename across.
INC HL ;HL returned pointing to low
@@ -77,7 +78,7 @@ NOT_APPEND: CALL SAVE_FNAME ;Copy the filename across.
CALL SET_EXT_REC ;Set up file pointer, simply in
CALL SET_REC_COUNT ; order to calculate extent no.
if 1
- LD A,(FIB_1##+FAB_DRV##) ;Flush any dirty buffers for
+ LD A,(FIB_1##+FAB_DRIVE_NUMBER##) ;Flush any dirty buffers for
PCALL FL_LOG ; this drive. [HF]
endif
;
@@ -111,7 +112,7 @@ endif
PCALL ENSURE_FAB ;Update directory entry if
OR A ; required.
JR NZ,RET_ERR
- LD A,(IX+FAB_DRV##) ;Flush any dirty buffers for
+ LD A,(IX+FAB_DRIVE_NUMBER##) ;Flush any dirty buffers for
PCALL FL_LOG ; this drive.
JR RET_NO_ERR
;
@@ -142,7 +143,7 @@ endif
;
ld iy,RAM_BASE##
- LD HL,CP_EXL
+ LD HL,FCB_EXTENT_LOW
ADD HL,DE ;-> low extent byte.
LD A,(HL) ;Remember search extent for
LD (SFN_EX##),A ; future search for next calls.
@@ -175,7 +176,7 @@ if 0 ;No FCB address. [HF]
endif
SNEXT2: LD DE,FIB_1## ;Get information about file
LD HL,SRCH_FIB## ; to search for.
- LD BC,FIB_SZ##
+ LD BC,FIB_DESC_SIZE##
LD A,(HL) ;Check to see if a previous
CP 0FFh ; S_F_F has really been done
LD A,.NOFIL## ; by seeing if the FCB that
@@ -188,12 +189,12 @@ SNEXT2: LD DE,FIB_1## ;Get information about file
GOT_SEARCH: PUSH DE ;Address of directory entry.
LD HL,FIB_1## ;Copy search FIB into an
LD DE,SRCH_FIB## ; internal buffer search
- LD BC,FIB_SZ## ; for next search for
+ LD BC,FIB_DESC_SIZE## ; for next search for
LDIR ; next.
POP DE ;Address of directory entry.
;
LD HL,TEMP_FCB## ;Create a temporary version
- LD A,(FIB_1##+FIB_DRV##) ; as DTA will be in another
+ LD A,(FIB_1##+FIB_DRIVE_NUMBER##) ; as DTA will be in another
LD (HL),A ; page, so copy later.
CALL SAVE_FNAME ;Save filename entry there.
;
@@ -313,9 +314,9 @@ endif
CALL INC_CURR_RECORD ;Increment current record
CALL SAVE_FAB ;Save stuff back in CP/M FCB
;
- ld a,(IX+CP_CR##) ;A := current record
+ ld a,(IX+FCB_CURRENT_RECORD##) ;A := current record
ld hl,(FCB_ADR##) ;HL -> record count
- LD BC,CP_RC##
+ LD BC,FCB_RECORD_COUNT##
ADD HL,BC
CP (HL) ;If current record is bigger
JR C,REC_COUNT_OK ; than record count then
@@ -340,7 +341,7 @@ REC_COUNT_OK: JP RET_NO_ERR ;Successful
;
ld iy,RAM_BASE##
- LD HL,CP_EXL
+ LD HL,FCB_EXTENT_LOW
ADD HL,DE ;-> low byte of extent.
LD A,(HL) ;If extent number is non-zero
OR A ; then try to open an existing
@@ -395,7 +396,7 @@ DELETE_LOOP_OK: POP BC ;Flag that a file has been
;
DELETE_LOOP: CALL M_F_N ;Find next file and stop
START_DELETE: JR NZ,DELETE_ERR ; if not found
- BIT AT_RO,(IX+FIB_ATTR##) ;Don't delete read only files.
+ BIT AT_RO,(IX+FIB_ATTRIBUTES##) ;Don't delete read only files.
JR NZ,DELETE_LOOP
LD A,1 ;Make disc dirty.
PCALL DEL_FIB ;Actually do the delete. The
@@ -424,7 +425,7 @@ START_DELETE: JR NZ,DELETE_ERR ; if not found
PUSH DE ;FCB address.
;
LD IX,FIB_1## ;In order to squash the file
- LD (IX+FIB_SA##),0 ; name, need to set up search
+ LD (IX+FIB_SEARCH_ATTRIBUTES##),0 ; name, need to set up search
LD HL,17 ; attributes => not volume.
ADD HL,DE ;Point to renamed version.
LD DE,TEMP_FCB## ;Some spare memory where we
@@ -453,7 +454,7 @@ START_RENAME: JR NZ,RENAME_ERR ; if not found
DELETE_ERR:
RENAME_ERR: LD B,A ;Save any error code.
if 1
- LD A,(FIB_1##+FAB_DRV##) ;Flush any dirty buffers for
+ LD A,(FIB_1##+FAB_DRIVE_NUMBER##) ;Flush any dirty buffers for
PCALL FL_LOG ; this drive. [HF]
endif
POP HL ;Return HL=FFh if no files
@@ -532,10 +533,10 @@ RAND_ERR: LD HL,0001 ;If error from read or write
CALL S_F_F ;Look for a matching file
JP NZ,RET_ERR ;Error if no match
;
- LD C,(IX+FIB_SIZE##) ;Get file size into
- LD B,(IX+FIB_SIZE##+1) ; DE:BC
- LD E,(IX+FIB_SIZE##+2)
- LD D,(IX+FIB_SIZE##+3)
+ LD C,(IX+FIB_FILE_SIZE##) ;Get file size into
+ LD B,(IX+FIB_FILE_SIZE##+1) ; DE:BC
+ LD E,(IX+FIB_FILE_SIZE##+2)
+ LD D,(IX+FIB_FILE_SIZE##+3)
;
XOR A ;Round file size up to nearest
LD H,A ; whole 128 byte sector to
@@ -553,9 +554,9 @@ NO_SIZE_CARRY:
ADC HL,HL ; bytes (HL:A)
;
LD IX,(FCB_ADR##)
- LD (IX+CP_RR##),a ;Record number of records in
- LD (IX+CP_RR##+1),L ; the random record of FCB.
- LD (IX+CP_RR##+2),H
+ LD (IX+FCB_RANDOM_RECORD##),a ;Record number of records in
+ LD (IX+FCB_RANDOM_RECORD##+1),L ; the random record of FCB.
+ LD (IX+FCB_RANDOM_RECORD##+2),H
;
JP RET_NO_ERR
;
@@ -602,47 +603,47 @@ GET_FAB:
LD (FCB_ADR##),HL ;Remember user's FCB address.
;
LD IX,FIB_1## ;Where to create a FAB.
- LD (IX+FAB_FLG##),0FFh
+ LD (IX+FAB_ID_BYTE##),0FFh
LD A,(HL) ;Drive in CP/M FCB.
if 1
AND 0Fh ;Ignore user code. [HF]
endif
- LD (IX+FAB_DRV##),A
+ LD (IX+FAB_DRIVE_NUMBER##),A
;===== start add FAT16 (CLUST patch)
- ld bc,CP_S1## ;restore FAB_ATTR and FAB_ACC
+ ld bc,FCB_S1## ;restore FAB_ATTRIBUTES and FAB_ACCESS_MODE
add hl,bc
ld a,(hl)
bit AT_RES,a
- ;assume B=0 (CP_S1 < 256)
+ ;assume B=0 (FCB_S1 < 256)
jr z,NOT_MOD2
ld b,ACM_MOD
-NOT_MOD2: ld (ix+FAB_ACC##),b
- ld (ix+FAB_ATTR##),a
+NOT_MOD2: ld (ix+FAB_ACCESS_MODE##),b
+ ld (ix+FAB_ATTRIBUTES##),a
and ATM_DEV ;restore FAB_MODE
jr z,NOT_DEV2
ld a,MDM_DEV+MDM_CPM+MDM_ASC
NOT_DEV2: ld (ix+FAB_MODE##),a
;===== end add FAT16
- LD DE,FIB_1##+FAB_SIZE## ;Copy size field.
+ LD DE,FIB_1##+FAB_FILE_SIZE## ;Copy size field.
;===== start mod FAT16 (support CLUST patch)
- ld bc,CP_SIZ##-CP_S1##
-;; LD BC,CP_SIZ##
+ ld bc,FCB_FILE_SIZE##-FCB_S1##
+;; LD BC,FCB_FILE_SIZE##
;===== end mod FAT16
ADD HL,BC ;Point to the FCB size field.
;===== start mod DOS2.50
- ;assume B=0 (CP_SIZ-CP_S1 < 256)
+ ;assume B=0 (FCB_FILE_SIZE-FCB_S1 < 256)
ld c,4
;; LD BC,4
;===== end mod DOS2.50
LDIR
- LD DE,FIB_1##+FAB_ID## ;Now the volume id.
+ LD DE,FIB_1##+FAB_VOLUME_ID## ;Now the volume id.
;===== start mod DOS2.50
;assume B=0 (set "ldir")
ld c,4
;; LD BC,4
;===== end mod DOS2.50
LDIR
- LD DE,FIB_1##+FAB_FDC## ;Now the cluster bytes.
+ LD DE,FIB_1##+FAB_FIRST_DIR_CLUSTER## ;Now the cluster bytes.
;===== start mod DOS2.50
;assume B=0 (set "ldir")
ld c,8
@@ -650,12 +651,12 @@ NOT_DEV2: ld (ix+FAB_MODE##),a
;===== end mod DOS2.50
LDIR
;===== start del FAT16 (support CLUST patch)
-;; LD A,(IX+FAB_LPC##+1) ;Contains the saved flags.
+;; LD A,(IX+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1) ;Contains the saved flags.
;; LD B,0 ;Check R/O first.
;; BIT CP_RO,A
;; JR Z,NOT_RO2
;; LD B,ATM_RO
-;;NOT_RO2: LD (IX+FAB_ATTR##),B
+;;NOT_RO2: LD (IX+FAB_ATTRIBUTES##),B
;; LD B,0
;; BIT CP_DEV,A ;Now check device flag and
;; JR Z,NOT_DEV2 ; if it is a device, then
@@ -668,21 +669,21 @@ NOT_DEV2: ld (ix+FAB_MODE##),a
;; BIT CP_MOD,A
;; JR Z,NOT_MOD2
;; LD B,ACM_MOD
-;;NOT_MOD2: LD (IX+FAB_ACC##),B
+;;NOT_MOD2: LD (IX+FAB_ACCESS_MODE##),B
;; AND 00001111b ;Remove flags from cluster
-;; LD (IX+FAB_LPC##+1),A ; number.
+;; LD (IX+FAB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1),A ; number.
;===== end del FAT16
if 1
XOR A
BIT MD_DEV,(IX+FAB_MODE##) ;If this seems to be device FCB
RET Z ; error if device handler
- LD L,(IX+FAB_ID##) ; address does not match with
- LD H,(IX+FAB_ID##+1) ; itself extracted from
+ LD L,(IX+FAB_VOLUME_ID##) ; address does not match with
+ LD H,(IX+FAB_VOLUME_ID##+1) ; itself extracted from
LD E,(HL) ; device descriptor address.
INC HL
LD D,(HL)
- LD L,(IX+FAB_ID##+2)
- LD H,(IX+FAB_ID##+3)
+ LD L,(IX+FAB_VOLUME_ID##+2)
+ LD H,(IX+FAB_VOLUME_ID##+3)
SBC HL,DE
RET Z
LD A,.IFCB##
@@ -705,10 +706,10 @@ GET_FNAME:
LD IX,FIB_1##
- LD HL,FIB_1##+FIB_NAME## ;Where to store ASCIIZ version
+ LD HL,FIB_1##+FIB_FILENAME## ;Where to store ASCIIZ version
INC DE ;Point to filename field.
LD A,(DE) ;Need to pass first ch. in A.
- LD (IX+FIB_SA##),ATM_HID ;Type of name.
+ LD (IX+FIB_SEARCH_ATTRIBUTES##),ATM_HID ;Type of name.
pcall SQ_NAME ;Go and squash the name.
RET
;
@@ -790,7 +791,7 @@ S_F_F:
PUSH BC ;Save append flag.
LD (FCB_ADR##),DE ;Save address of the FCB.
LD IX,FIB_1## ;Address of an internal buffer
- LD (IX+FIB_SA##),A ; suitable for an FIB.
+ LD (IX+FIB_SEARCH_ATTRIBUTES##),A ; suitable for an FIB.
PUSH AF
PUSH DE ;Save FCB address.
INC DE ;Point to expanded filename.
@@ -814,7 +815,7 @@ APPEND_ENTRY: LD C,PCM_DI ;Access disc if needed.
JR NZ,S_F_F_ERR ; HL -> unit descriptor.
PUSH HL ;Unit descriptor.
LD HL,FNAME_BUF## ;Expanded filename.
- LD DE,FIB_1##+FIB_PAT## ;Copy into FIB.
+ LD DE,FIB_1##+FIB_EXPANDED_SEARCH_PATTERN## ;Copy into FIB.
LD BC,8+3
PUSH DE
LDIR
@@ -932,7 +933,7 @@ M_F_N:
LD (IY+@SE_FLAGS),SEM_SR ;Flag not doing create.
PCALL O_FIB ;Download directory variables
RET NZ ; ready to continue search.
- LD DE,FIB_1##+FIB_PAT## ;Expanded version of filename.
+ LD DE,FIB_1##+FIB_EXPANDED_SEARCH_PATTERN## ;Expanded version of filename.
PCALL FND_NEXT
jr nz,M_F_N2
@@ -953,7 +954,7 @@ S_F_N:
LD (IY+@SE_FLAGS),SEM_SR ;Flag not doing create.
PCALL O_FIB ;Download directory variables
RET NZ ; ready to continue search.
- LD DE,FIB_1##+FIB_PAT## ;Expanded version of filename.
+ LD DE,FIB_1##+FIB_EXPANDED_SEARCH_PATTERN## ;Expanded version of filename.
PCALL FND_NEXT
LD C,0 ;Make sure don't do funny
PUSH BC ; things with append.
@@ -986,9 +987,9 @@ if 1
RET NZ
endif
LD IX,(FCB_ADR##) ;Need IX pointing to FCB, for
- LD A,(IX+CP_RR##) ; routines called before the
- LD C,(IX+CP_RR##+1) ; main MSX-DOS one.
- LD B,(IX+CP_RR##+2) ;Set up the FAB file pointer
+ LD A,(IX+FCB_RANDOM_RECORD##) ; routines called before the
+ LD C,(IX+FCB_RANDOM_RECORD##+1) ; main MSX-DOS one.
+ LD B,(IX+FCB_RANDOM_RECORD##+2) ;Set up the FAB file pointer
PUSH AF ; from random record number.
PUSH BC ;And save on stack for use in
CALL SET_RAND_PTR ; calculating extent number.
@@ -1000,22 +1001,22 @@ endif
;===== start mod DOS2.50
add a,a
adc hl,hl ;Calculate extent number by
- ld (ix+CP_EXL##),l ; multiplying top 17 bits
+ ld (ix+FCB_EXTENT_LOW##),l ; multiplying top 17 bits
; by two (effectively divide
- ld (ix+CP_EXH##),h ; by 128).
+ ld (ix+FCB_EXTENT_HIGH##),h ; by 128).
;Record current extent.
srl a ;Record bottom 7 bits as the
- ld (ix+CP_CR##),a ; current record number.
+ ld (ix+FCB_CURRENT_RECORD##),a ; current record number.
;; LD B,A
;; ADD A,A
;; ADC HL,HL ;Calculate extent number by
;; LD A,L
-;; LD (IX+CP_EXL##),A
+;; LD (IX+FCB_EXTENT_LOW##),A
;; LD A,H
-;; LD (IX+CP_EXH##),A
+;; LD (IX+FCB_EXTENT_HIGH##),A
;; LD A,B
;; AND 07Fh ;Record bottom 7 bits as the
-;; LD (IX+CP_CR##),A ; current record number.
+;; LD (IX+FCB_CURRENT_RECORD##),A ; current record number.
;===== end mod DOS2.50
;
XOR A ;User paging mode -> A'.
@@ -1051,9 +1052,9 @@ BUFFER_SECTOR:
;; LD B,A
;===== end mod DOS2.50
LD DE,(BUF_REC##+1)
- LD A,(IX+CP_RR##) ;Get required logical sector
- LD L,(IX+CP_RR##+1) ; into HL:A
- LD H,(IX+CP_RR##+2)
+ LD A,(IX+FCB_RANDOM_RECORD##) ;Get required logical sector
+ LD L,(IX+FCB_RANDOM_RECORD##+1) ; into HL:A
+ LD H,(IX+FCB_RANDOM_RECORD##+2)
;
SUB B
SBC HL,DE
@@ -1094,18 +1095,18 @@ PURGE_BUF: CALL CHK_FILE_BUF ;Test if buffer is for this
CHK_FILE_BUF:
;===== start mod DOS2.50
ld a,(BUF_UNIT##) ;Compare unit number in CP/M
- cp (IX+CP_DRV##) ; FCB with the one for the
+ cp (IX+FCB_DRIVE_NUMBER##) ; FCB with the one for the
; buffer and return NZ if
; they are different.
-;; LD A,(IX+CP_DRV##)
+;; LD A,(IX+FCB_DRIVE_NUMBER##)
;; LD B,A
;; LD A,(BUF_UNIT##)
;; CP B
;===== end mod DOS2.50
RET NZ
;
- LD L,(IX+CP_FPC##) ;Compare first physical
- LD H,(IX+CP_FPC##+1)
+ LD L,(IX+FCB_FIRST_PHYSICAL_CLUSTER##) ;Compare first physical
+ LD H,(IX+FCB_FIRST_PHYSICAL_CLUSTER##+1)
LD DE,(BUF_FPC##) ; clusters and return Z or NZ
SBC HL,DE ; to show whether equal.
RET
@@ -1140,7 +1141,7 @@ READ_BUFFER:
;; LD (BUF_UNIT##),A
;===== end mod DOS2.50
;
- LD A,(IX+CP_RR##) ;Number of 128 byte records to
+ LD A,(IX+FCB_RANDOM_RECORD##) ;Number of 128 byte records to
AND 03h ; read is the size of the
LD B,A ; buffer, reduced by any odd
LD A,SECT_BUFF## ; sectors at start. This makes
@@ -1188,26 +1189,26 @@ endif
;
PUSH IX ;-> FCB.
POP HL
- LD BC,CP_RR##
+ LD BC,FCB_RANDOM_RECORD##
ADD HL,BC ;Save random record number
LD DE,BUF_REC## ; in "BUF_REC" for later
;===== start mod DOS2.50
- ;assume B=0 (CP_RR < 256)
+ ;assume B=0 (FCB_RANDOM_RECORD < 256)
LD C,3 ; testing in "BUFFER_SECTOR".
;; LD BC,3
;===== end mod DOS2.50
LDIR
;
;===== start mod DOS2.50
- ld l,(ix+CP_FPC##) ;Record unit number and first
- ld h,(ix+CP_FPC##+1) ; checking for same file.
+ ld l,(ix+FCB_FIRST_PHYSICAL_CLUSTER##) ;Record unit number and first
+ ld h,(ix+FCB_FIRST_PHYSICAL_CLUSTER##+1) ; checking for same file.
ld (BUF_FPC##),hl ; physical cluster number for
-;; LD A,(IX+CP_FPC##)
+;; LD A,(IX+FCB_FIRST_PHYSICAL_CLUSTER##)
;; LD (BUF_FPC##),A
-;; LD A,(IX+CP_FPC##+1)
+;; LD A,(IX+FCB_FIRST_PHYSICAL_CLUSTER##+1)
;; LD (BUF_FPC##+1),A
;===== end mod DOS2.50
- LD A,(IX+CP_DRV##)
+ LD A,(IX+FCB_DRIVE_NUMBER##)
LD (BUF_UNIT##),A
;
XOR A ;Return with zero error code
@@ -1293,30 +1294,30 @@ INC_CURR_RECORD:
;
;
;===== start mod DOS2.50
- inc (ix+CP_CR##) ;Increment current record and
+ inc (ix+FCB_CURRENT_RECORD##) ;Increment current record and
ret p ; return if same extent
;
- ld (ix+CP_CR##),0 ;Record new record number
+ ld (ix+FCB_CURRENT_RECORD##),0 ;Record new record number
; start next extent.
- inc (ix+CP_EXL##) ;If record goes to 80h then
+ inc (ix+FCB_EXTENT_LOW##) ;If record goes to 80h then
jr nz,no_carry_cur_ext ; start next extent.
- inc (ix+CP_EXH##)
+ inc (ix+FCB_EXTENT_HIGH##)
no_carry_cur_ext:
-;; LD A,(IX+CP_EXL##)
+;; LD A,(IX+FCB_EXTENT_LOW##)
;; LD L,A
-;; LD A,(IX+CP_EXH##)
+;; LD A,(IX+FCB_EXTENT_HIGH##)
;; LD H,A
-;; LD A,(IX+CP_CR##)
+;; LD A,(IX+FCB_CURRENT_RECORD##)
;; INC A
;; JP P,SAME_EXTENT
;; INC HL
;; LD A,0
;;SAME_EXTENT:
-;; LD (IX+CP_CR##),A
+;; LD (IX+FCB_CURRENT_RECORD##),A
;; LD A,L
-;; LD (IX+CP_EXL##),A
+;; LD (IX+FCB_EXTENT_LOW##),A
;; LD A,H
-;; LD (IX+CP_EXH##),A
+;; LD (IX+FCB_EXTENT_HIGH##),A
;; RET P
;===== end mod DOS2.50
; ;
@@ -1344,18 +1345,18 @@ SET_REC_COUNT:
; Corrupts: AF,BC,DE,HL
;
;
- LD HL,(FIB_1##+FAB_SIZE##)
+ LD HL,(FIB_1##+FAB_FILE_SIZE##)
XOR A ; Get rounded file size into
LD B,A ; BCHL.
SUB L
AND 127
LD C,A
ADD HL,BC
- LD BC,(FIB_1##+FAB_SIZE##+2)
+ LD BC,(FIB_1##+FAB_FILE_SIZE##+2)
JR NC,SRC10
;
INC BC
-SRC10: LD A,(FIB_1##+FAB_PTR##+1)
+SRC10: LD A,(FIB_1##+FAB_FILE_POINTER##+1)
AND 0C0H ; Subtract file pointer rounded
LD D,A ; down to the nearest extent.
XOR A
@@ -1363,7 +1364,7 @@ SRC10: LD A,(FIB_1##+FAB_PTR##+1)
SBC HL,DE
PUSH BC
EX (SP),HL
- LD BC,(FIB_1##+FAB_PTR##+2)
+ LD BC,(FIB_1##+FAB_FILE_POINTER##+2)
SBC HL,BC
POP HL
LD B,A ;Record count is zero if
@@ -1382,10 +1383,10 @@ SRC10: LD A,(FIB_1##+FAB_PTR##+1)
PAST_EOF_EXT:
FULL_EXTENT:
;===== start mod DOS2.50
- ld (ix+CP_RC##),b ;Record the record count
+ ld (ix+FCB_RECORD_COUNT##),b ;Record the record count
; for this extent.
;; LD A,B
-;; LD (IX+CP_RC##),A
+;; LD (IX+FCB_RECORD_COUNT##),A
;===== end mod DOS2.50
;
RET
@@ -1407,15 +1408,15 @@ FULL_EXTENT:
; FAB stored at FIB_1.
; Corrupts: AF, BC, HL
;
-SET_RAND_REC: LD A,(IX+CP_CR##)
+SET_RAND_REC: LD A,(IX+FCB_CURRENT_RECORD##)
SET_EXT_REC:
;===== start mod DOS2.50
- ld b,(IX+CP_EXH##) ;Get current extent and record
- ld c,(IX+CP_EXL##) ; number into HL and A.
+ ld b,(IX+FCB_EXTENT_HIGH##) ;Get current extent and record
+ ld c,(IX+FCB_EXTENT_LOW##) ; number into HL and A.
;; PUSH AF
-;; LD A,(IX+CP_EXH##)
+;; LD A,(IX+FCB_EXTENT_HIGH##)
;; LD B,A
-;; LD A,(IX+CP_EXL##)
+;; LD A,(IX+FCB_EXTENT_LOW##)
;; LD C,A
;; POP AF
;===== end mod DOS2.50
@@ -1425,11 +1426,11 @@ SET_EXT_REC:
RR C ; dividing EXTENT:(REC*2)
RRA ; by two.
;
- LD (IX+CP_RR##),A ;Store logical record number
- LD (IX+CP_RR##+1),C ; random record field of FCB.
- LD (IX+CP_RR##+2),B
+ LD (IX+FCB_RANDOM_RECORD##),A ;Store logical record number
+ LD (IX+FCB_RANDOM_RECORD##+1),C ; random record field of FCB.
+ LD (IX+FCB_RANDOM_RECORD##+2),B
;
-SET_RAND_PTR: LD HL,FIB_1##+FAB_PTR## ; Zero low byte of file ptr.
+SET_RAND_PTR: LD HL,FIB_1##+FAB_FILE_POINTER## ; Zero low byte of file ptr.
LD (HL),0
;
SRL B ;Convert logical record to
@@ -1468,24 +1469,24 @@ SAVE_FAB:
;
PUSH IX ;FCB address.
POP HL
- LD BC,CP_SIZ##
+ LD BC,FCB_FILE_SIZE##
ADD HL,BC ;Address in FCB to store size.
EX DE,HL
- LD HL,FIB_1##+FAB_SIZE## ;File size.
+ LD HL,FIB_1##+FAB_FILE_SIZE## ;File size.
;===== start mod DOS2.50
- ;assume B=0 (CP_SIZ < 256)
+ ;assume B=0 (FCB_FILE_SIZE < 256)
LD C,4 ;Size is 4 bytes long.
;; LD BC,4
;===== end mod DOS2.50
LDIR
- LD HL,FIB_1##+FAB_ID## ;Volume id in FAB.
+ LD HL,FIB_1##+FAB_VOLUME_ID## ;Volume id in FAB.
;===== start mod DOS2.50
;assume B=0 (set "ldir")
LD C,4 ;Again 4 bytes long.
;; LD BC,4
;===== end mod DOS2.50
LDIR ;Follows after size in FCB.
- LD HL,FIB_1##+FAB_FDC## ;Start of 8 data bytes to copy.
+ LD HL,FIB_1##+FAB_FIRST_DIR_CLUSTER## ;Start of 8 data bytes to copy.
;===== start mod DOS2.50
;assume B=0 (set "ldir")
LD C,8
@@ -1494,17 +1495,17 @@ SAVE_FAB:
LDIR ;Again follows on directly.
;
;===== start mod FAT16 (CLUST2 patch)
- ld a,(FIB_1##+FAB_ACC##) ;CP_S1(file attribute) <- all FAB_ATTR bits and AC_MOD bit
+ ld a,(FIB_1##+FAB_ACCESS_MODE##) ;FCB_S1(file attribute) <- all FAB_ATTRIBUTES bits and AC_MOD bit
bit AC_MOD,a
- ld a,(FIB_1##+FAB_ATTR##)
+ ld a,(FIB_1##+FAB_ATTRIBUTES##)
res AT_RES,a
jr z,NOT_MOD
set AT_RES,a
-NOT_MOD: ld (ix+CP_S1##),a
-;; LD A,(IX+CP_LPC##+1) ;Where to store flags.
+NOT_MOD: ld (ix+FCB_S1##),a
+;; LD A,(IX+FCB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1) ;Where to store flags.
;; AND 00001111b ;Clear all the flags.
;; LD B,A
-;; LD A,(FIB_1##+FAB_ATTR##) ;RO bit of attr byte.
+;; LD A,(FIB_1##+FAB_ATTRIBUTES##) ;RO bit of attr byte.
;; BIT AT_RO,A
;; JR Z,NOT_RO ;Nothing to do, if not set.
;; SET CP_RO,B ;Use bit 6 of first physical.
@@ -1516,11 +1517,11 @@ NOT_MOD: ld (ix+CP_S1##),a
;; BIT MD_EOF,A
;; JR Z,NOT_EOF
;; SET CP_EOF,B
-;;NOT_EOF: LD A,(FIB_1##+FAB_ACC##) ;Get modified flag.
+;;NOT_EOF: LD A,(FIB_1##+FAB_ACCESS_MODE##) ;Get modified flag.
;; BIT AC_MOD,A
;; JR Z,NOT_MOD
;; SET CP_MOD,B
-;;NOT_MOD: LD (IX+CP_LPC##+1),B ;Put back in FCB.
+;;NOT_MOD: LD (IX+FCB_LAST_ACCESSED_PHYSICAL_CLUSTER##+1),B ;Put back in FCB.
;===== end mod FAT16
;
RET
@@ -1597,14 +1598,14 @@ endif
; +++++++ Calculate file pointer for FAB ++++++
;
;
- LD C,(IX+CP_RS##) ;BC := Record size.
- LD B,(IX+CP_RS##+1)
+ LD C,(IX+FCB_RECORD_SIZE##) ;BC := Record size.
+ LD B,(IX+FCB_RECORD_SIZE##+1)
LD HL,63
XOR A ;Test whether record size
SBC HL,BC ; is 64 bytes or greater.
;
- LD E,(IX+CP_RR##+2) ;Get top word of random record
- LD D,(IX+CP_RR##+3) ; number into DE and zero top
+ LD E,(IX+FCB_RANDOM_RECORD##+2) ;Get top word of random record
+ LD D,(IX+FCB_RANDOM_RECORD##+3) ; number into DE and zero top
JR NC,FOUR_BYTE_REC ; byte if record size is 64
LD D,A ; bytes or greater.
FOUR_BYTE_REC: CALL MULTIPLY ;Multiply top word of record
@@ -1613,15 +1614,15 @@ FOUR_BYTE_REC: CALL MULTIPLY ;Multiply top word of record
JP NZ,MSX_FAIL_1
PUSH DE ;Save partial result.
;
- LD E,(IX+CP_RR##) ;Multiply low word of record
- LD D,(IX+CP_RR##+1) ; number by record size and
+ LD E,(IX+FCB_RANDOM_RECORD##) ;Multiply low word of record
+ LD D,(IX+FCB_RANDOM_RECORD##+1) ; number by record size and
CALL MULTIPLY ; add the partial result
POP BC ; from above to top word.
ADD HL,BC
JP C,MSX_FAIL_1 ;Moan if overflows 32 bits.
;
- LD (FIB_1##+FAB_PTR##),DE ;Save final file ptr in FAB.
- LD (FIB_1##+FAB_PTR##+2),HL
+ LD (FIB_1##+FAB_FILE_POINTER##),DE ;Save final file ptr in FAB.
+ LD (FIB_1##+FAB_FILE_POINTER##+2),HL
;
;
; +++++++ Calculate transfer size & call MSX-DOS 2 ++++++
@@ -1629,8 +1630,8 @@ FOUR_BYTE_REC: CALL MULTIPLY ;Multiply top word of record
;
POP DE ;Multiply record size by number
PUSH DE ; of records to transfer to
- LD C,(IX+CP_RS##) ; get required transfer size
- LD B,(IX+CP_RS##+1)
+ LD C,(IX+FCB_RECORD_SIZE##) ; get required transfer size
+ LD B,(IX+FCB_RECORD_SIZE##+1)
CALL MULTIPLY
LD A,H ;Complain if the transfer size
OR L ; is greater than 64k.
@@ -1670,8 +1671,8 @@ if 0
POP HL ;Ignore requested record count.
endif
LD (TEMP_FCB##+2),DE ;-> Next free DTA.
- LD E,(IX+CP_RS##) ;Divide amount transferred (BC)
- LD D,(IX+CP_RS##+1) ; by record size (DE).
+ LD E,(IX+FCB_RECORD_SIZE##) ;Divide amount transferred (BC)
+ LD D,(IX+FCB_RECORD_SIZE##+1) ; by record size (DE).
CALL DIVIDE
LD A,H
OR L
@@ -1710,21 +1711,21 @@ MSX_WHOLE:
CALL SAVE_FAB ;Update CP/M FCB from FAB.
;
POP DE ;DE := records transferred
- LD L,(IX+CP_RR##)
- LD H,(IX+CP_RR##+1)
+ LD L,(IX+FCB_RANDOM_RECORD##)
+ LD H,(IX+FCB_RANDOM_RECORD##+1)
ADD HL,DE ;Add this to random record
- LD (IX+CP_RR##),L ; number in CP/M FCB.
- LD (IX+CP_RR##+1),H
+ LD (IX+FCB_RANDOM_RECORD##),L ; number in CP/M FCB.
+ LD (IX+FCB_RANDOM_RECORD##+1),H
JR NC,NO_RR_CARRY
;===== start mod DOS2.50
- inc (IX+CP_RR##+2) ;Increment high word if any
+ inc (IX+FCB_RANDOM_RECORD##+2) ;Increment high word if any
jr nz,NO_RR_CARRY ; overflow from low word.
- inc (IX+CP_RR##+3)
-;; LD L,(IX+CP_RR##+2)
-;; LD H,(IX+CP_RR##+3)
+ inc (IX+FCB_RANDOM_RECORD##+3)
+;; LD L,(IX+FCB_RANDOM_RECORD##+2)
+;; LD H,(IX+FCB_RANDOM_RECORD##+3)
;; INC HL
-;; LD (IX+CP_RR##+2),L
-;; LD (IX+CP_RR##+3),H
+;; LD (IX+FCB_RANDOM_RECORD##+2),L
+;; LD (IX+FCB_RANDOM_RECORD##+3),H
;===== end mod DOS2.50
NO_RR_CARRY:
EX AF,AF' ;A := 0/1 return code
diff --git a/source/kernel/bank4/dskab.mac b/source/kernel/bank4/dskab.mac
index 82ca4408..e7a5624c 100644
--- a/source/kernel/bank4/dskab.mac
+++ b/source/kernel/bank4/dskab.mac
@@ -1,11 +1,12 @@
.z80
+ name('dskab')
; Disk error handler and abort hooks for page 4.
; See KABJ and KDERJ at the end of bank0/drv.mac
; for an explanation of why this is needed.
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;org 7FC0h
diff --git a/source/kernel/bank4/env.mac b/source/kernel/bank4/env.mac
index 48aee33e..5a918351 100644
--- a/source/kernel/bank4/env.mac
+++ b/source/kernel/bank4/env.mac
@@ -1,10 +1,11 @@
.z80
+ name('env')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Environment String Functions
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;RAMMOD ;Removed since now this code is ran from bank 4 of ROM
;
;-----------------------------------------------------------------------------
diff --git a/source/kernel/bank4/jump.mac b/source/kernel/bank4/jump.mac
index 99b5a007..3f863c8c 100644
--- a/source/kernel/bank4/jump.mac
+++ b/source/kernel/bank4/jump.mac
@@ -1,10 +1,11 @@
.z80
+ name('jump')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl Jump table for MSX-DOS 2.0 ROM bank 4 public routines
;-----------------------------------------------------------------------------
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
; Jump table to routines called from outside this bank.
diff --git a/source/kernel/bank4/misc.mac b/source/kernel/bank4/misc.mac
index 01a10ed6..bb0d7ae5 100644
--- a/source/kernel/bank4/misc.mac
+++ b/source/kernel/bank4/misc.mac
@@ -1,10 +1,11 @@
.z80
+ name('misc')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Miscellaneous KBDOS functions (bank 4 part)
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;RAMMOD
CHPUT equ 00A2h
@@ -267,8 +268,8 @@ dspace_okfn:
push hl
pop ix
- ld e,(ix+UD_NCLU##)
- ld d,(ix+UD_NCLU##+1)
+ ld e,(ix+UD_CLUSTER_COUNT##)
+ ld d,(ix+UD_CLUSTER_COUNT##+1)
dec de ;DE = Total cluster count
or a
@@ -327,7 +328,7 @@ DSP_NEXT:
; Transform it to KBytes + extra space.
dspace_tokbytes:
- ld a,(ix+UD_CMSK##) ;Cluster mask = sectors/cluster-1
+ ld a,(ix+UD_CLUSTER_MASK##) ;Cluster mask = sectors/cluster-1
ld bc,0
ld hl,0
or a
@@ -406,7 +407,7 @@ dspace_end:
push hl ;Unit descriptor
pop ix
- ld b,(ix+UD_CMSK##)
+ ld b,(ix+UD_CLUSTER_MASK##)
inc b ;Sectors per cluster
ld a,(ix+UD_FLAGS##)
@@ -607,11 +608,11 @@ no_free_seg:
ld a,RAMD_NUM
push hl ;Setup a few important fields
pop ix ; of the unit descriptor.
- ld (ix+UD_PHYS##),a ;Physical unit number
+ ld (ix+UD_PHYSICAL_UNIT##),a ;Physical unit number
ld (ix+UD_TIME##),0 ;No current UPB
- ld (ix+UD_CDIR##+1),0FFh ;Current directory is root
+ ld (ix+UD_CURRENT_DIR_FIRST_CLUSTER##+1),0FFh ;Current directory is root
;===== start add FAT16 (DOS2.50 original patch)
- ld (ix+UD_CDIR##),0FFh
+ ld (ix+UD_CURRENT_DIR_FIRST_CLUSTER##),0FFh
;===== end add FAT16
;
ld c,a ;Validate the RAM disk, this
diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac
index 4f2a5899..975f4dae 100644
--- a/source/kernel/bank4/partit.mac
+++ b/source/kernel/bank4/partit.mac
@@ -1,11 +1,12 @@
.z80
+ name('partit')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Disk partition management
;******************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
- INCLUDE b0labels.inc
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
+ INCLUDE ../bank0/b0labels.inc
;
EMU_RAM_ADDRESS equ 0A000h
@@ -208,14 +209,14 @@ DO_EXTPAR:
jp nz,UNEX_PART
ld a,(ix+POFF_PSTART) ;Save the start sector number of the outer extended partition
- ld_iyl_a ;(the one that includes all other extended partitions).
+ ld iyl,a ;(the one that includes all other extended partitions).
ld a,(ix+POFF_PSTART+1) ;We need it to calculate the offsets of the inner
- ld_iyh_a ;extended partitions.
+ ld iyh,a ;extended partitions.
push iy
ld a,(ix+POFF_PSTART+2)
- ld_iyl_a
+ ld iyl,a
ld a,(ix+POFF_PSTART+3)
- ld_iyh_a
+ ld iyh,a
push iy
;=== Loop for extended partition search ===
@@ -354,7 +355,7 @@ DEV_READ:
push de
push hl
- ld_iyh_c
+ ld iyh,c
ld ix,DEV_RW##
ld (BK4_ADD##),ix
ld ix,CALDRV##
@@ -596,17 +597,17 @@ AUTODRV_DRVLOOP:
; A = Relative drive for the driver
ld c,a
- ld_a_iyl
+ ld a,iyl
ld (ix+UD1_SLOT##),a ;Set slot number in table entry
ld a,c
- ld (ix+UD1_REL##),a
+ ld (ix+UD1_RELATIVE_DRIVE##),a
push af
xor a
push bc
push iy
push ix
- ld_a_iyh ;ld a,(iy+4)
+ ld a,iyh ;ld a,(iy+4)
and 00000100b ;Driver provides config?
jr z,AUTODRV_DRVL2
push ix
@@ -627,10 +628,10 @@ AUTODRV_DRVL1:
pop ix
push ix
ld a,-1
- ld (ix+UD1_FSEC##),a
- ld (ix+UD1_FSEC##+1),a
- ld (ix+UD1_FSEC##+2),a
- ld (ix+UD1_FSEC##+3),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##+1),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##+2),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##+3),a
inc a
jr AUTODRV_DRVL3
@@ -678,7 +679,7 @@ AUTODRV_END:
; have been created (INIT_UNITS invokation loop complete).
;
; Note that this routine calls AUTO_ASSIGN, which in turn asumes that
-; UD_SLOT and UD_PHYS are set for the unit descriptor. This is true
+; UD_SLOT and UD_PHYSICAL_UNIT are set for the unit descriptor. This is true
; since these fields are set by INIT_UNITS.
AUTODRV_DOS2:
@@ -707,7 +708,7 @@ AUTOD_UDFND:
;--- Check if it is assigned to a device based driver
ld a,(ix+UD_SLOT##)
- ld_iyh_a
+ ld iyh,a
ld c,a
ld a,(KER250##)
@@ -753,7 +754,7 @@ AUTOD_UDFND2:
jr z,AUTOD_UDFND3
ld b,0
- ld c,(ix+UD_REL##)
+ ld c,(ix+UD_RELATIVE_UNIT_NUMBER##)
ld a,1
call ASK_DRIVE_CONFIG
cp 1
@@ -873,7 +874,7 @@ SETNUMD_NOUD:
; This one is used if the device provides its own configuration.
;
; Input: HL = DOS 2 mode:
-; Address of unit descriptor, it must have UD_SLOT and UD_PHYS set
+; Address of unit descriptor, it must have UD_SLOT and UD_PHYSICAL_UNIT set
; DOS 1 mode:
; Address of entry in device-based drives table, must have UD_SLOT set
; B = Device index (AUTO_ASPART only)
@@ -1001,13 +1002,13 @@ AA_CHKDUP_LOOP1:
cp (ix+AAD_DRIVER_SLOT)
jr nz,AA_CHKDUP_NEXT1
- ld a,(iy+UD1_DI##)
+ ld a,(iy+UD1_DEVICE_INDEX##)
or a ;If device index is 0, it is an unused table entry
jr z,AA_CHKDUP_NEXT1
cp d
jr nz,AA_CHKDUP_NEXT1
- ld a,(iy+UD1_LI##) ;Check LUN index
+ ld a,(iy+UD1_LUN_INDEX##) ;Check LUN index
cp e
jr nz,AA_CHKDUP_NEXT1
@@ -1045,13 +1046,13 @@ AA_CHKDUP_LOOP:
cp (ix+AAD_DRIVER_SLOT)
jr nz,AA_CHKDUP_NEXT
- ld a,(iy+UD_DI##)
+ ld a,(iy+UD_DEVICE_INDEX##)
or a ;If device index is 0, it is an incomplete
jr z,AA_CHKDUP_NEXT ;unit descriptor (as created by INIT_UNITS)
cp d
jr nz,AA_CHKDUP_NEXT
- ld a,(iy+UD_LI##) ;Same thing if LUN index is 0
+ ld a,(iy+UD_LUN_INDEX##) ;Same thing if LUN index is 0
or a
jr z,AA_CHKDUP_NEXT
cp e
@@ -1066,7 +1067,7 @@ AA_CHKDUP_OK:
;--- Obtain device information
ld a,(ix+AAD_DRIVER_SLOT)
- ld_iyh_a
+ ld iyh,a
ld hl,LUN_INFO##
ld (BK4_ADD##),hl
ld hl,($SECBUF##)
@@ -1298,10 +1299,10 @@ AA_CHECK_BOOT2:
ld a,(DOS_VER##)
or a
jr nz,AA_SPC_OK
- ld a,(iy+UPB_SFAT##+1)
+ ld a,(iy+UPB_SECTORS_PER_FAT##+1)
or a
jp nz,AA_PLOOP_NEXT ;AA_LLOOP_NEXT
- ld a,(iy+UPB_SFAT##)
+ ld a,(iy+UPB_SECTORS_PER_FAT##)
cp 4
jp nc,AA_PLOOP_NEXT ;AA_LLOOP_NEXT
AA_SPC_OK:
@@ -1311,7 +1312,7 @@ AA_SPC_OK:
push ix
push iy
ld h,(ix+AAD_DRIVER_SLOT)
- ld l,0FFh ;(ix+UD_SEG##)
+ ld l,0FFh ;(ix+UD_RAM_SEGMENT##)
ld e,(ix+AAD_UNIT_DESCRIPTOR)
ld d,(ix+AAD_UNIT_DESCRIPTOR+1)
push de
@@ -1424,7 +1425,7 @@ AA_DO_ASSIGN:
set UF_FOK,(iy+UD_DFLAGS##) ;Tell that the partition information is valid
ld b,(iy+UD_SLOT##)
- ld c,(iy+UD_PHYS##)
+ ld c,(iy+UD_PHYSICAL_UNIT##)
push bc
ld a,(iy+UD_DFLAGS##)
@@ -1434,30 +1435,30 @@ AA_DO_ASSIGN:
pop de
inc de
ld (hl),0
- ld bc,UD_SZ##-1
+ ld bc,UD_SIZE##-1
ldir
ld (iy+UD_DFLAGS##),a
pop bc
ld (iy+UD_SLOT##),b
- ld (iy+UD_PHYS##),c
+ ld (iy+UD_PHYSICAL_UNIT##),c
ld b,(ix+AAD_LOOP_LUN_INDEX)
ld a,(ix+AAD_LOOP_DEV_INDEX)
- ld (iy+UD_LI##),b
- ld (iy+UD_DI##),a
- ld (iy+UD_SEG##),0FFh
+ ld (iy+UD_LUN_INDEX##),b
+ ld (iy+UD_DEVICE_INDEX##),a
+ ld (iy+UD_RAM_SEGMENT##),0FFh
ld l,(ix+AAD_CAND_PART_SECTOR)
ld h,(ix+AAD_CAND_PART_SECTOR+1)
- ld (iy+UD_FSEC##),l
- ld (iy+UD_FSEC##+1),h
+ ld (iy+UD_FIRST_DEVICE_SECTOR##),l
+ ld (iy+UD_FIRST_DEVICE_SECTOR##+1),h
ld l,(ix+AAD_CAND_PART_SECTOR+2)
ld h,(ix+AAD_CAND_PART_SECTOR+3)
- ld (iy+UD_FSEC##+2),l
- ld (iy+UD_FSEC##+3),h
+ ld (iy+UD_FIRST_DEVICE_SECTOR##+2),l
+ ld (iy+UD_FIRST_DEVICE_SECTOR##+3),h
- ld (iy+UD_CDIR##+1),0FFh ;set current dir -ve => root
- ld (iy+UD_CDIR##),0FFh
+ ld (iy+UD_CURRENT_DIR_FIRST_CLUSTER##+1),0FFh ;set current dir -ve => root
+ ld (iy+UD_CURRENT_DIR_FIRST_CLUSTER##),0FFh
ld a,(ix+AAD_CAND_PART_DEVLUN) ;Retrieve removable unit flag
rlca
@@ -1469,33 +1470,33 @@ AA_DO_ASSIGN:
ld (iy+UD_DFLAGS##),a
ld hl,$DPBLIST##
- ld c,(iy+UD_PHYS##)
+ ld c,(iy+UD_PHYSICAL_UNIT##)
dec c
sla c
ld b,0
add hl,bc
ld a,(hl)
- ld (iy+UD_DPB##),a
+ ld (iy+UD_DPB_ADDRESS##),a
inc hl
ld a,(hl)
- ld (iy+UD_DPB##+1),a
+ ld (iy+UD_DPB_ADDRESS##+1),a
xor a
ret
AA_DO_ASSDOS1:
ld a,(ix+AAD_LOOP_DEV_INDEX)
- ld (iy+UD1_DI##),a
+ ld (iy+UD1_DEVICE_INDEX##),a
ld a,(ix+AAD_LOOP_LUN_INDEX)
- ld (iy+UD1_LI##),a
+ ld (iy+UD1_LUN_INDEX##),a
ld l,(ix+AAD_CAND_PART_SECTOR)
ld h,(ix+AAD_CAND_PART_SECTOR+1)
- ld (iy+UD1_FSEC##),l
- ld (iy+UD1_FSEC##+1),h
+ ld (iy+UD1_FIRST_ABSOLUTE_SECTOR##),l
+ ld (iy+UD1_FIRST_ABSOLUTE_SECTOR##+1),h
ld l,(ix+AAD_CAND_PART_SECTOR+2)
ld h,(ix+AAD_CAND_PART_SECTOR+3)
- ld (iy+UD1_FSEC##+2),l
- ld (iy+UD1_FSEC##+3),h
+ ld (iy+UD1_FIRST_ABSOLUTE_SECTOR##+2),l
+ ld (iy+UD1_FIRST_ABSOLUTE_SECTOR##+3),h
xor a
ret
@@ -1565,7 +1566,7 @@ AA_WSEC:
AA_RSEC:
or a
AA_DOSEC:
- ld_iyh_c
+ ld iyh,c
ld hl,DEV_RW##
ld (BK4_ADD##),hl
ld c,b
@@ -1589,7 +1590,7 @@ AA_DOSEC:
CHECK_FAT_BOOT:
ld hl,($SECBUF##)
- ld de,UPB_SSZ##
+ ld de,UPB_SECTOR_SIZE##
add hl,de
ld d,(hl) ;Sector size must always
inc hl ; be 200h.
@@ -1621,7 +1622,7 @@ CHECK_FAT_BOOT:
or (hl)
jr z,upb_not_found
- ld de,UPB_SFAT##-(UPB_NDIR##+1);Ignore "total sectors"
+ ld de,UPB_SECTORS_PER_FAT##-(UPB_NUM_ROOT_DIR_ENTRIES##+1);Ignore "total sectors"
add hl,de ; and "media byte".
ld e,(hl) ;Number of sectors per
@@ -1639,21 +1640,21 @@ CHECK_FAT_BOOT:
;* We are in DOS 1: fail if FAT16 or if more than 3 sectors per FAT
ld iy,($SECBUF##)
- ld e,(iy+UPB_SEC##)
- ld d,(iy+UPB_SEC##+1) ;DE=Total sectors
+ ld e,(iy+UPB_TOTAL_SECTORS##)
+ ld d,(iy+UPB_TOTAL_SECTORS##+1) ;DE=Total sectors
ld a,d
or e
jr z,upb_not_found ;0 = >32 MB
- ld a,(iy+UPB_SFAT##+1)
+ ld a,(iy+UPB_SECTORS_PER_FAT##+1)
or a
jr nz,upb_not_found
- ld a,(iy+UPB_SFAT##)
+ ld a,(iy+UPB_SECTORS_PER_FAT##)
cp 4
jr nc,upb_not_found
- ld c,(iy+UPB_NDIR##)
- ld b,(iy+UPB_NDIR##+1) ;BC=Num of root dir entries
+ ld c,(iy+UPB_NUM_ROOT_DIR_ENTRIES##)
+ ld b,(iy+UPB_NUM_ROOT_DIR_ENTRIES##+1) ;BC=Num of root dir entries
ld a,c
and 11111b
ld hl,0
@@ -1670,13 +1671,13 @@ NO_ODD_ENTRIES:
rr c
add hl,bc ;HL=Num of root dir sectors
- ld c,(iy+UPB_RES##)
- ld b,(iy+UPB_RES##+1)
+ ld c,(iy+UPB_RESERVED_SECTORS##)
+ ld b,(iy+UPB_RESERVED_SECTORS##+1)
add hl,bc ;HL=Root dir sectors + reserved sectors
- ld a,(iy+UPB_NFAT##) ;A=Number of FATs
- ld c,(iy+UPB_SFAT##) ;BC=Sectors per FAT
- ld b,(iy+UPB_SFAT##+1)
+ ld a,(iy+UPB_NUM_FATS##) ;A=Number of FATs
+ ld c,(iy+UPB_SECTORS_PER_FAT##) ;BC=Sectors per FAT
+ ld b,(iy+UPB_SECTORS_PER_FAT##+1)
CALC_SECFAT:
add hl,bc
dec a
@@ -1686,7 +1687,7 @@ CALC_SECFAT:
or a
sbc hl,de ;HL=Total data sectors
- ld a,(iy+UPB_CS##) ;A = Sectors per cluster (power of 2)
+ ld a,(iy+UPB_SECTORS_PER_CLUSTER##) ;A = Sectors per cluster (power of 2)
rrca
jr c,CALC_CLUS_OK
CALC_CLUS:
@@ -1727,7 +1728,7 @@ upb_not_found: ;If anything was wrong with
; then returns with A=1. The format of the table is defined in kvar.mac (DSK_*).
;
; The definitve address of the work area as read from the emulation data file is temporarily
-; stored in EMU_WK_AREA, so that either the table it will be moved to this place
+; stored in EMU_WORK_AREA_ADDRESS, so that either the table it will be moved to this place
; or, if it is zero, the work area will be properly allocated.
GO_EMU:
@@ -1747,14 +1748,14 @@ GO_EMU:
ld a,c ;Dev
and 0Fh
or b
- ld (EMU_TMP##+EMU_DEVLUN##),a ;dev+lun of emulation data file
+ ld (EMU_TMP##+EMU_DEV_AND_LUN##),a ;dev+lun of emulation data file
pop bc
pop af
;--- Read file contents
- ld (EMU_TMP##+EMU_FSEC##),de
- ld (EMU_TMP##+EMU_FSEC##+2),hl
+ ld (EMU_TMP##+EMU_FILE_FIRST_SECTOR##),de
+ ld (EMU_TMP##+EMU_FILE_FIRST_SECTOR##+2),hl
ld (TMP_SEC##),de
ld (TMP_SEC##+2),hl
call AA_RSEC
@@ -1815,16 +1816,16 @@ GOEMU_WAOK:
;> Basic data
ld a,(ix+18) ;Work area address, low
- ld (EMU_WK_AREA##),a
+ ld (EMU_WORK_AREA_ADDRESS##),a
ld a,(ix+19) ;Work area address, high
- ld (EMU_WK_AREA##+1),a
+ ld (EMU_WORK_AREA_ADDRESS##+1),a
ld a,(ix+16)
- ld (iy+DSK_COUNT##),a ;Number of entries in table
+ ld (iy+DSK_EMULATED_FILES_COUNT##),a ;Number of entries in table
;> Current file data
ld a,(ix+17) ;Boot file index
- ld (iy+DSK_IDX##),a
+ ld (iy+DSK_CURRENT_FILE_INDEX##),a
set 7,(iy)
ld c,a
@@ -1846,30 +1847,30 @@ GOEMU_NORUS:
push ix
pop bc
add hl,bc ;HL = Pointer to boot file data
- ld de,EMU_TMP##+DSK_DEV##
+ ld de,EMU_TMP##+DSK_CURRENT_FILE_DEVICE_INDEX##
ld bc,8
ldir
- ld a,(iy+DSK_DEV##) ;set DSK_DEV and DSK_LUN as same of data file if 0
+ ld a,(iy+DSK_CURRENT_FILE_DEVICE_INDEX##) ;set DSK_CURRENT_FILE_DEVICE_INDEX and DSK_CURRENT_FILE_LUN_INDEX as same of data file if 0
or a
jr nz,GOEMU_END
- ld a,(iy+EMU_DEVLUN##)
+ ld a,(iy+EMU_DEV_AND_LUN##)
ld b,a
and 00000111b
- ld (iy+DSK_DEV##),a
+ ld (iy+DSK_CURRENT_FILE_DEVICE_INDEX##),a
ld a,b
rrca
rrca
rrca
rrca
and 00000111b
- ld (iy+DSK_LUN##),a
+ ld (iy+DSK_CURRENT_FILE_LUN_INDEX##),a
;--- All done
GOEMU_END:
ld a,1
- ld (IN_EMU##),a
+ ld (IN_EMU_MODE##),a
ret
EMUDATASIG: db "NEXTOR_EMU_DATA",0
@@ -2268,8 +2269,8 @@ F_GDLI_GO:
or a
jr z,NORDISK
ld hl,(RM_DPB##)
- ld e,(ix+UD_DPB##)
- ld d,(ix+UD_DPB##+1)
+ ld e,(ix+UD_DPB_ADDRESS##)
+ ld d,(ix+UD_DPB_ADDRESS##+1)
or a
sbc hl,de
jr nz,NORDISK
@@ -2284,15 +2285,15 @@ NORDISK:
;* Assigned to a mounted file
ld (iy+0),3
- ld a,(ix+UD_DRV##)
+ ld a,(ix+UD_MOUNT_DRIVE##)
ld (iy+1),a
- ld a,(ix+UD_MFLAGS##)
+ ld a,(ix+UD_MOUNT_FLAGS##)
ld (iy+2),a
ld (iy+3),0
push ix
pop hl
- ld bc,UD_MNAME##
+ ld bc,UD_MOUNT_FILENAME##
add hl,bc ;HL = Pointer to filename
push iy
@@ -2304,20 +2305,20 @@ NORDISK:
ld bc,13
ldir
- ld a,(ix+UD_SCLU##) ;Start cluster
+ ld a,(ix+UD_MOUNT_START_CLUSTER##) ;Start cluster
ld (de),a
inc de
- ld a,(ix+UD_SCLU##+1)
+ ld a,(ix+UD_MOUNT_START_CLUSTER##+1)
ld (de),a
inc de
- ld a,(ix+UD_SSEC##) ;Start sector
+ ld a,(ix+UD_MOUNT_FIRST_DRIVE_SECTOR##) ;Start sector
ld (de),a
inc de
- ld a,(ix+UD_SSEC##+1)
+ ld a,(ix+UD_MOUNT_FIRST_DRIVE_SECTOR##+1)
ld (de),a
inc de
- ld a,(ix+UD_SSEC##+2)
+ ld a,(ix+UD_MOUNT_FIRST_DRIVE_SECTOR##+2)
ld (de),a
;inc de ;The buffer has been zeroed previously
;xor a
@@ -2332,7 +2333,7 @@ NOMNT:
ld (iy+0),1 ;Block device mode is the only mode currently supported
ld a,(ix+UD_SLOT##)
ld (iy+1),a
- ld a,(ix+UD_SEG##)
+ ld a,(ix+UD_RAM_SEGMENT##)
ld (iy+2),a
ld a,(ix+UD_DFLAGS##)
and UFM_DB
@@ -2341,30 +2342,30 @@ NOMNT:
;--- Device-based drive
ld (iy+3),0FFh
- ld a,(ix+UD_DI##)
+ ld a,(ix+UD_DEVICE_INDEX##)
ld (iy+4),a
- ld a,(ix+UD_LI##)
+ ld a,(ix+UD_LUN_INDEX##)
ld (iy+5),a
bit UF_PAP,(ix+UD_DFLAGS##)
jr z,NOPAP
ld a,0FFh
- ld (ix+UD_FSEC##),a
- ld (ix+UD_FSEC##+1),a
- ld (ix+UD_FSEC##+2),a
- ld (ix+UD_FSEC##+3),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+1),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+2),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+3),a
cpl
ret
NOPAP:
- ld a,(ix+UD_FSEC##)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##)
ld (iy+6),a
- ld a,(ix+UD_FSEC##+1)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##+1)
ld (iy+7),a
- ld a,(ix+UD_FSEC##+2)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##+2)
ld (iy+8),a
- ld a,(ix+UD_FSEC##+3)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##+3)
ld (iy+9),a
xor a
ret
@@ -2372,7 +2373,7 @@ NOPAP:
;--- Drive-based drive
GDRV_DRVBASED:
- ld a,(ix+UD_REL##)
+ ld a,(ix+UD_RELATIVE_UNIT_NUMBER##)
ld (iy+3),a
xor a
ret
@@ -2481,7 +2482,7 @@ F_CDRVR_GO:
ret nz
ld (BK4_ADD##),de
- ld_iyh_c
+ ld iyh,c
ld l,(ix)
ld h,(ix+1)
push hl
@@ -2520,10 +2521,10 @@ CDRV_NODOS1:
; in place when the function was called; otherwise
; that TPA segment could be uninitialized.
- ld a,(PS_BDO##)
+ ld a,(PS_BDOS##)
and 11b
ld b,a ;Main slot number
- ld a,(SS_BDO##)
+ ld a,(SS_BDOS##)
rla
rla
and 1100b
@@ -2629,10 +2630,10 @@ UNMAP_LOOP:
inc hl
ld h,(hl)
ld l,a
- cp_iyl
+ cp iyl
jr nz,UNMAP_OK1
ld a,h
- cp_iyh
+ cp iyh
jr z,UNMAP_NEXT2 ;It is the unit not to be unassigned
UNMAP_OK1:
@@ -2651,13 +2652,13 @@ UNMAP_OK1:
ld a,(ix+UD_SLOT##)
cp h
jr nz,UNMAP_NEXT
- ld a,(ix+UD_SEG##)
+ ld a,(ix+UD_RAM_SEGMENT##)
cp l
jr nz,UNMAP_NEXT
- ld a,(ix+UD_DI##)
+ ld a,(ix+UD_DEVICE_INDEX##)
cp d
jr nz,UNMAP_NEXT
- ld a,(ix+UD_LI##)
+ ld a,(ix+UD_LUN_INDEX##)
cp e
jr nz,UNMAP_NEXT
@@ -2783,7 +2784,7 @@ ISMNT:
pop iy
bit UF_MNT,(iy+UD_FLAGS##)
jr z,ISMNT_NEXT
- ld a,(iy+UD_DRV##)
+ ld a,(iy+UD_MOUNT_DRIVE##)
cp c
jr nz,ISMNT_NEXT
@@ -2915,7 +2916,7 @@ MAP_FOUND:
pop bc
ret nz
ld (ix+UD_SLOT##),d
- ld (ix+UD_REL##),e ;Start assuming a legacy or drive-based driver
+ ld (ix+UD_RELATIVE_UNIT_NUMBER##),e ;Start assuming a legacy or drive-based driver
ld (ix+UD_OFFSET##),10h
;* Now check the type of driver, if it is device-based,
@@ -2943,13 +2944,13 @@ MAP_FOUND:
MAP_DEF_DRVB:
ld a,(iy+2) ;A = first drive allocated to the controller
- add a,(ix+UD_REL##)
+ add a,(ix+UD_RELATIVE_UNIT_NUMBER##)
ld e,a ;E = drive letter for the relative drive at boot time
ld d,0
ld hl,MB_DEF##
add hl,de
ld a,(hl)
- ld (ix+UD_MBYTE##),a
+ ld (ix+UD_MEDIA_DESC_BYTE##),a
xor a
jp SETNUMDRV
@@ -2960,7 +2961,7 @@ MAP_DEF_DEVB:
jr z,MAP_DEF_DEVB_NOCFG
ld b,0
- ld c,(ix+UD_REL##)
+ ld c,(ix+UD_RELATIVE_UNIT_NUMBER##)
xor a
push hl
call ASK_DRIVE_CONFIG
@@ -3083,7 +3084,7 @@ MAP_SPECIFIC:
ld c,(iy)
ld a,(iy+2)
ld b,(iy+3)
- ld_iyh_c
+ ld iyh,c
ld hl,($SECBUF##)
ld ix,CALDRV##
call CALSLT
@@ -3120,7 +3121,7 @@ MAP_SPECIFIC:
ld c,(iy)
ld a,(iy+2)
ld b,(iy+3)
- ld_iyh_c
+ ld iyh,c
ld ix,CALDRV##
call CALSLT
pop iy
@@ -3176,26 +3177,26 @@ MAP_DRV_UNCH:
ld a,(iy)
ld (ix+UD_SLOT##),a
ld a,(iy+1)
- ld (ix+UD_SEG##),a
+ ld (ix+UD_RAM_SEGMENT##),a
ld a,(iy+2)
- ld (ix+UD_DI##),a
+ ld (ix+UD_DEVICE_INDEX##),a
ld a,(iy+3)
- ld (ix+UD_LI##),a
+ ld (ix+UD_LUN_INDEX##),a
ld a,(iy+4)
- ld (ix+UD_FSEC##),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##),a
ld a,(iy+5)
- ld (ix+UD_FSEC##+1),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+1),a
ld a,(iy+6)
- ld (ix+UD_FSEC##+2),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+2),a
ld a,(iy+7)
- ld (ix+UD_FSEC##+3),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+3),a
ld iy,($SECBUF##)
ld a,(iy+7)
and 1 ;Set removable flag...
rlca
rlca
- or UFM_DB+UFM_FO ;...and also device-based and UD_FSEC OK flags
+ or UFM_DB+UFM_FO ;...and also device-based and UD_FIRST_DEVICE_SECTOR OK flags
ld (ix+UD_DFLAGS##),a
xor a
@@ -3308,14 +3309,14 @@ MF_CHK_ALRMNT:
ld a,(iy+25)
dec a
- cp (ix+UD_DRV##)
+ cp (ix+UD_MOUNT_DRIVE##)
jr nz,MF_ALRMNT_NEXT
ld a,(iy+19)
- cp (ix+UD_SCLU##)
+ cp (ix+UD_MOUNT_START_CLUSTER##)
jr nz,MF_ALRMNT_NEXT
ld a,(iy+20)
- cp (ix+UD_SCLU##+1)
+ cp (ix+UD_MOUNT_START_CLUSTER##+1)
jr nz,MF_ALRMNT_NEXT
pop ix
@@ -3366,9 +3367,9 @@ MF_OK_SIZE:
;* Check if cluster chain is consecutive
- ld a,(ix+FIB_DRIVE##)
- ld e,(ix+FIB_CLUSTER##)
- ld d,(ix+FIB_CLUSTER##+1)
+ ld a,(ix+FIB_DRIVE_NUMBER##)
+ ld e,(ix+FIB_START_CLUSTER##)
+ ld d,(ix+FIB_START_CLUSTER##+1)
push hl
push ix
call CLUSQ##
@@ -3406,7 +3407,7 @@ MF_UD_OK:
pop hl ;H=flags
ld a,h
and 1
- ld (ix+UD_MFLAGS##),a
+ ld (ix+UD_MOUNT_FLAGS##),a
ex de,hl ;Now HL = FIB
@@ -3414,9 +3415,9 @@ MF_UD_OK:
push ix
ex (sp),hl
- ld bc,UD_MNAME##
+ ld bc,UD_MOUNT_FILENAME##
add hl,bc
- ex de,hl ;Now DE points to UD_MNAME
+ ex de,hl ;Now DE points to UD_MOUNT_FILENAME
pop hl
push hl
inc hl ;Now HL points to filename in FIB
@@ -3426,13 +3427,13 @@ MF_UD_OK:
;Start cluster
- ld bc,FIB_CLU##
+ ld bc,FIB_START_CLUSTER##
add hl,bc ;Now HL points to start cluster in FIB
ld a,(hl)
- ld (ix+UD_SCLU##),a
+ ld (ix+UD_MOUNT_START_CLUSTER##),a
inc hl
ld a,(hl)
- ld (ix+UD_SCLU##+1),a
+ ld (ix+UD_MOUNT_START_CLUSTER##+1),a
;Maximum sector count = (File size / 512) - 1
@@ -3447,8 +3448,8 @@ MF_UD_OK:
ld e,(hl)
rr e
dec de
- ld (ix+UD_MXS##),e
- ld (ix+UD_MXS##+1),d
+ ld (ix+UD_MOUNT_MAX_SECTOR##),e
+ ld (ix+UD_MOUNT_MAX_SECTOR##+1),d
;Drive
@@ -3457,12 +3458,12 @@ MF_UD_OK:
inc hl
ld a,(hl)
dec a
- ld (ix+UD_DRV##),a
+ ld (ix+UD_MOUNT_DRIVE##),a
;First sector in file drive
ld hl,UNIT_TAB##+2
- ld c,(ix+UD_DRV##)
+ ld c,(ix+UD_MOUNT_DRIVE##)
sla c
ld b,0
add hl,bc
@@ -3470,13 +3471,13 @@ MF_UD_OK:
inc hl
ld d,(hl) ;DE=Address of unit descriptor
ex de,hl
- ld e,(ix+UD_SCLU##)
- ld d,(ix+UD_SCLU##+1)
+ ld e,(ix+UD_MOUNT_START_CLUSTER##)
+ ld d,(ix+UD_MOUNT_START_CLUSTER##+1)
xor a
pcall CLU_TO_SEC
- ld (ix+UD_SSEC##),e
- ld (ix+UD_SSEC##+1),d
- ld (ix+UD_SSEC##+2),a
+ ld (ix+UD_MOUNT_FIRST_DRIVE_SECTOR##),e
+ ld (ix+UD_MOUNT_FIRST_DRIVE_SECTOR##+1),d
+ ld (ix+UD_MOUNT_FIRST_DRIVE_SECTOR##+2),a
;Other parameters
@@ -3485,10 +3486,10 @@ MF_UD_OK:
ld a,10001b ;First sector is already valid
ld (ix+UD_DFLAGS##),a
xor a
- ld (ix+UD_FSEC##),a
- ld (ix+UD_FSEC##+1),a
- ld (ix+UD_FSEC##+2),a
- ld (ix+UD_FSEC##+3),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+1),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+2),a
+ ld (ix+UD_FIRST_DEVICE_SECTOR##+3),a
;--- All done
@@ -3508,7 +3509,7 @@ POPIX_RET:
; Cy = 1 to allocate extra space for mounted file info
;Output: IX = Address of unit descriptor
; A = .NORAM (and NZ) if can't create new unit descriptor
-;The unit descriptor will have filled: UD_PHYS, UD_CDIR, UD_DPB, UD_SEG.
+;The unit descriptor will have filled: UD_PHYSICAL_UNIT, UD_CURRENT_DIR_FIRST_CLUSTER, UD_DPB_ADDRESS, UD_RAM_SEGMENT.
;
;NOTE: Assumes that no unit descriptor is currently allocated
; (that is, address of unit descriptor pointed by HL is zero)
@@ -3520,9 +3521,9 @@ CREATE_UD:
ld e,(ix)
ld d,(ix+1) ;DE = Address of unit descriptor
- ld hl,UD_SZ##
+ ld hl,UD_SIZE##
jr nc,CRUD2
- ld hl,UD_MSZ##
+ ld hl,UD_SIZE_WITH_MOUNT##
CRUD2:
;* Allocate the memory for the unit descriptor
@@ -3540,17 +3541,17 @@ CRUD2:
ld e,l
ld d,h
inc de
- ld bc,UD_SZ##-1
+ ld bc,UD_SIZE##-1
ld (hl),0
ldir
pop bc
inc c
- ld (ix+UD_PHYS##),c
+ ld (ix+UD_PHYSICAL_UNIT##),c
ld a,0FFh
- ld (ix+UD_SEG##),a
- ld (ix+UD_CDIR##+1),a ;set current dir -ve => root
- ld (ix+UD_CDIR##),a
+ ld (ix+UD_RAM_SEGMENT##),a
+ ld (ix+UD_CURRENT_DIR_FIRST_CLUSTER##+1),a ;set current dir -ve => root
+ ld (ix+UD_CURRENT_DIR_FIRST_CLUSTER##),a
ld hl,$DPBLIST##
dec c
@@ -3558,10 +3559,10 @@ CRUD2:
ld b,0
add hl,bc
ld a,(hl)
- ld (ix+UD_DPB##),a
+ ld (ix+UD_DPB_ADDRESS##),a
inc hl
ld a,(hl)
- ld (ix+UD_DPB##+1),a
+ ld (ix+UD_DPB_ADDRESS##+1),a
xor a
ret
@@ -3635,7 +3636,7 @@ MAPDOS1_DPBOK:
or a
jr nz,MAPDOS1_NOUNMAP
- ld (ix+UD1_DI##),0 ;Set device index to 0
+ ld (ix+UD1_DEVICE_INDEX##),0 ;Set device index to 0
jp MAPDOS1_END_OK
MAPDOS1_NOUNMAP:
@@ -3649,7 +3650,7 @@ MAPDOS1_DEF:
push hl
push ix
ld a,(ix+UD1_SLOT##)
- ld_iyh_a
+ ld iyh,a
call GET_DV_TYPE
pop ix
pop hl
@@ -3658,7 +3659,7 @@ MAPDOS1_DEF:
push hl
push ix
- ld c,(ix+UD1_REL##)
+ ld c,(ix+UD1_RELATIVE_DRIVE##)
res 7,c ;Ignore "media changed" flag
ld b,1
xor a
@@ -3671,14 +3672,14 @@ MAPDOS1_DEF:
jr z,MAPDOS1_DEF_NOCFG
ld a,0FFh
- ld (ix+UD1_FSEC##),a
- ld (ix+UD1_FSEC##+1),a
- ld (ix+UD1_FSEC##+2),a
- ld (ix+UD1_FSEC##+3),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##+1),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##+2),a
+ ld (ix+UD1_FIRST_ABSOLUTE_SECTOR##+3),a
jr MAPDOS1_DEF_OK
MAPDOS1_DEF_NOCFG: ;No config provided by driver, use AUTO_ASSIGN
- ld (ix+UD1_DI##),0 ;At the moment leave the drive unmapped
+ ld (ix+UD1_DEVICE_INDEX##),0 ;At the moment leave the drive unmapped
push hl
push ix
pop hl
@@ -3695,11 +3696,11 @@ if 0
push hl
ld l,(ix) ;Driver slot
- ld h,(ix+UD1_REL##) ;Relative unit
- ld (ix+UD1_DI##),0 ;At the moment leave the drive unmapped
+ ld h,(ix+UD1_RELATIVE_DRIVE##) ;Relative unit
+ ld (ix+UD1_DEVICE_INDEX##),0 ;At the moment leave the drive unmapped
pop ix ;Use FAT buffer for the fake unit descriptor
ld (ix+UD_SLOT##),l
- ld (ix+UD_PHYS##),h
+ ld (ix+UD_PHYSICAL_UNIT##),h
push ix
pop hl
@@ -3715,17 +3716,17 @@ if 0
ld a,0
ret nz ;If no suitable partition found, leave drive unmapped and return no error
- ld a,(ix+UD_DI##)
+ ld a,(ix+UD_DEVICE_INDEX##)
ld (iy+2),a
- ld a,(ix+UD_LI##)
+ ld a,(ix+UD_LUN_INDEX##)
ld (iy+3),a
- ld a,(ix+UD_FSEC##)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##)
ld (iy+4),a
- ld a,(ix+UD_FSEC##+1)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##+1)
ld (iy+5),a
- ld a,(ix+UD_FSEC##+2)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##+2)
ld (iy+6),a
- ld a,(ix+UD_FSEC##+3)
+ ld a,(ix+UD_FIRST_DEVICE_SECTOR##+3)
ld (iy+7),a
push iy
@@ -3814,7 +3815,7 @@ MAPDOS1_CHK_NEXT:
ld c,(iy)
ld a,(iy+2)
ld b,(iy+3)
- ld_iyh_c
+ ld iyh,c
ld hl,($SECBUF##)
ld ix,CALDRV##
call CALSLT
@@ -3850,7 +3851,7 @@ MAPDOS1_CHK_NEXT:
ld (ix+7),a
MAPDOS1_END_OK:
- set 7,(ix+UD1_REL##) ;Set partition changed flag
+ set 7,(ix+UD1_RELATIVE_DRIVE##) ;Set partition changed flag
ld hl,0FFFFh
ld (0F23Fh),hl ;Make sector buffer invalid
ld a,h
@@ -3901,10 +3902,10 @@ CLOSE_HANDLES:
pop ix
push de
push bc
- ld c,(ix+UD_PHYS##)
+ ld c,(ix+UD_PHYSICAL_UNIT##)
ld hl,(HANDLES##)
- ld b,MAX_HAND##
+ ld b,MAX_FILE_HANDLES##
ld a,h
or l
jr z,CLOSE_HANDLES_END
@@ -3926,7 +3927,7 @@ CLOSE_HANDLES_LOOP:
bit 7,a
jr nz,CLOSE_HANDLES_NEXT ;Skip if device file handle
- ld a,(ix+FAB_DRV##) ;A = drive number (1 = A:, etc)
+ ld a,(ix+FAB_DRIVE_NUMBER##) ;A = drive number (1 = A:, etc)
cp c
jr nz,CLOSE_HANDLES_NEXT ;Skip if not our drive
@@ -3936,7 +3937,7 @@ CLOSE_HANDLES_LOOP:
dec hl
pcall CLOSE_FAB ;See F_CLOSE in handles.mac in bank 2
pcall ENSURE_FAB
- ld a,(ix+FAB_DRV##)
+ ld a,(ix+FAB_DRIVE_NUMBER##)
pcall FL_LOG
pop bc
pop hl
@@ -4159,8 +4160,8 @@ IDRVR_RET:
cp 0CDh
jr nz,DOSV1_2
- ld ix,256 + NXTVER##
- ld iy,256*NXTV_HI## + NXTV_LO##
+ ld ix,256 + MAIN_NEXTOR_VERSION##
+ ld iy,256*SEC_NEXTOR_VERSION_HIGH## + SEC_NEXTOR_VERSION_LOW##
ld bc,0100h
ld a,1
ld de,0
@@ -4337,7 +4338,7 @@ MAPDRV_OKLUN:
or a
jr nz,MAPDRV_NOPRIM
- ld a,(MASTER##)
+ ld a,(MASTER_SLOT##)
ld e,a
MAPDRV_NOPRIM:
@@ -5635,7 +5636,7 @@ COMMA_MSG:
FROM_MSG:
db ", from ",0
TO_MSG:
- ": to ",0
+ db ": to ",0
;-----------------------------------------------------------------------------
@@ -5961,7 +5962,7 @@ DRVS1LOOP:
pop de
jr c,DRVS1NEXT ;Skip if not a Nextor kernel
- ld_iyh_e
+ ld iyh,e
call GET_DV_TYPE
bit 0,a ;Device-based?
jr z,DRVS1NEXT ;No: skip
@@ -6077,26 +6078,26 @@ CMIU_NOTSAME:
cp (ix+UD_SLOT##)
jr nz,CMIU_CHECK_NEXT
ld a,l ;Compare segment number against mapping data
- cp (ix+UD_SEG##)
+ cp (ix+UD_RAM_SEGMENT##)
jr nz,CMIU_CHECK_NEXT
ld a,d ;Compare device index against mapping data
- cp (ix+UD_DI##)
+ cp (ix+UD_DEVICE_INDEX##)
jr nz,CMIU_CHECK_NEXT
ld a,e ;Compare LUN index against mapping data
- cp (ix+UD_LI##)
+ cp (ix+UD_LUN_INDEX##)
jr nz,CMIU_CHECK_NEXT
exx
ld a,e ;Compare starting sector number against mapping data
- cp (ix+UD_FSEC##)
+ cp (ix+UD_FIRST_DEVICE_SECTOR##)
jr nz,CMIU_CHECK_NEXX
ld a,d
- cp (ix+UD_FSEC##+1)
+ cp (ix+UD_FIRST_DEVICE_SECTOR##+1)
jr nz,CMIU_CHECK_NEXX
ld a,l
- cp (ix+UD_FSEC##+2)
+ cp (ix+UD_FIRST_DEVICE_SECTOR##+2)
jr nz,CMIU_CHECK_NEXX
ld a,h
- cp (ix+UD_FSEC##+3)
+ cp (ix+UD_FIRST_DEVICE_SECTOR##+3)
jr nz,CMIU_CHECK_NEXX
exx
@@ -6189,7 +6190,7 @@ CMIU1_NEXT:
; 1 driver did not provide info for that drive
; 2 driver provided info, but can't assign partition to drive
; 3 if disk emulation mode has been entered
-; If A=0 or 2, sets UD_DI, UD_LI and UD_SEG in the unit descriptor
+; If A=0 or 2, sets UD_DEVICE_INDEX, UD_LUN_INDEX and UD_RAM_SEGMENT in the unit descriptor
; If A=0, sets UF_FOK in UD_DFLAGS in the unit descriptor
; If A=3, returns B, C, HLDE from AUTO_ASPART
; Modifies: AF, BC, DE, HL, IY
@@ -6199,7 +6200,7 @@ ASK_DRIVE_CONFIG:
push de
push bc ;BC=DOS mode and relative unit
ld a,(ix+UD_SLOT##)
- ld_iyh_a
+ ld iyh,a
ld hl,DV_CONFIG##
ld (BK4_ADD##),hl
ld a,CFG_DEVLUN
@@ -6215,17 +6216,17 @@ ASK_DRIVE_CONFIG:
ld a,h
or a
jr nz,ASKDRVCFG_DOS1
- ld (ix+UD_REL##),l
- ld (ix+UD_DI##),b
- ld (ix+UD_LI##),c
- ld (ix+UD_SEG##),0FFh
+ ld (ix+UD_RELATIVE_UNIT_NUMBER##),l
+ ld (ix+UD_DEVICE_INDEX##),b
+ ld (ix+UD_LUN_INDEX##),c
+ ld (ix+UD_RAM_SEGMENT##),0FFh
ld (ix+UD_TIME##),0
set UF_DBD,(ix+UD_DFLAGS##)
jr ASKDRVCFG_NEXT
ASKDRVCFG_DOS1:
- ld (ix+UD1_REL##),l
- ld (ix+UD1_DI##),b
- ld (ix+UD1_LI##),c
+ ld (ix+UD1_RELATIVE_DRIVE##),l
+ ld (ix+UD1_DEVICE_INDEX##),b
+ ld (ix+UD1_LUN_INDEX##),c
ASKDRVCFG_NEXT:
push hl ;H=DOS mode
diff --git a/source/kernel/bank4/ramdrv.mac b/source/kernel/bank4/ramdrv.mac
index 20bb0803..3296e8bc 100644
--- a/source/kernel/bank4/ramdrv.mac
+++ b/source/kernel/bank4/ramdrv.mac
@@ -1,4 +1,5 @@
 .z80
+ name('ramdrv')
RAMENT equ 4080h
CALLB0 equ 403Fh
diff --git a/source/kernel/bank4/ramdrvh.mac b/source/kernel/bank4/ramdrvh.mac
index 72afd3f1..4620c5ef 100644
--- a/source/kernel/bank4/ramdrvh.mac
+++ b/source/kernel/bank4/ramdrvh.mac
@@ -1,5 +1,7 @@
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ name('ramdrvh')
+
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
include b4rdlabs.inc
diff --git a/source/kernel/bank4/seg.mac b/source/kernel/bank4/seg.mac
index b828db1a..66b4709d 100644
--- a/source/kernel/bank4/seg.mac
+++ b/source/kernel/bank4/seg.mac
@@ -1,10 +1,11 @@
.z80
+ name('seg')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl Allocate or Free Mapper Segment
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;RAMMOD ;Removed since now this code is ran from bank 4 of ROM
;
P0_REG equ 0FCh
diff --git a/source/kernel/bank4/time.mac b/source/kernel/bank4/time.mac
index 0b4e16ec..5664b31d 100644
--- a/source/kernel/bank4/time.mac
+++ b/source/kernel/bank4/time.mac
@@ -1,10 +1,11 @@
.z80
+ name('time')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Date and Time KBDOS functions
;*****************************************************************************
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../macros.inc
+ INCLUDE ../const.inc
;RAMMOD ;Removed since now this code is ran from bank 4 of ROM
;
;-----------------------------------------------------------------------------
diff --git a/source/kernel/bank5/CPM32.EXE b/source/kernel/bank5/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank5/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank5/L80.CPM b/source/kernel/bank5/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank5/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank5/LIB80.CPM b/source/kernel/bank5/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank5/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank5/M80.CPM b/source/kernel/bank5/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank5/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank5/b5.mac b/source/kernel/bank5/b5.mac
index 1b1d2dca..3687d599 100644
--- a/source/kernel/bank5/b5.mac
+++ b/source/kernel/bank5/b5.mac
@@ -1,6 +1,7 @@
.z80
+ name('b5')
BANK equ 5
;
- include BANK.INC
+ include ../bank.inc
;
end
diff --git a/source/kernel/bank5/compfdsk.bat b/source/kernel/bank5/compfdsk.bat
deleted file mode 100644
index 0df28b76..00000000
--- a/source/kernel/bank5/compfdsk.bat
+++ /dev/null
@@ -1,19 +0,0 @@
-echo Compiling, please be patient...
-
-sdasz80 -o fdisk_crt0.rel fdisk_crt0.s
-if errorlevel 1 goto :error
-
-sdcc --code-loc 0x4120 --data-loc 0x8020 -mz80 --disable-warning 196 --disable-warning 84 --disable-warning 85 --max-allocs-per-node 1000 --allow-unsafe-read --opt-code-size --no-std-crt0 fdisk_crt0.rel fdisk.c
-if errorlevel 1 goto :error
-hex2bin -e dat fdisk.ihx
-
-sdcc --code-loc 0x4120 --data-loc 0xA000 -mz80 --disable-warning 196 --disable-warning 84 --disable-warning 85 --max-allocs-per-node 1000 --allow-unsafe-read --opt-code-size --no-std-crt0 fdisk_crt0.rel fdisk2.c
-if errorlevel 1 goto :error
-hex2bin -e dat fdisk2.ihx
-
-goto :end
-
-:error
-exit /b 1
-
-:end
diff --git a/source/kernel/bank5/compile.bat b/source/kernel/bank5/compile.bat
deleted file mode 100644
index b10e0cc4..00000000
--- a/source/kernel/bank5/compile.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-@echo off
-cls
-
-call compfdsk.bat
-if errorlevel 1 goto :end
-
-for /R %%I in (..\..\..\bin\kernels\*.*) do (
-dd if=fdisk.dat of=%%I bs=1 count=16000 seek=82176
-dd if=fdisk2.dat of=%%I bs=1 count=8000 seek=98560
-)
-
-:end
-
diff --git a/source/kernel/bank5/fdisk.c b/source/kernel/bank5/fdisk.c
index 81986dd1..676019e6 100644
--- a/source/kernel/bank5/fdisk.c
+++ b/source/kernel/bank5/fdisk.c
@@ -1645,15 +1645,9 @@ void PrintStateMessage(char* string)
void chput(char ch) __naked
{
__asm
- push ix
- push iy
- ld ix,#6
- add ix,sp
- ld a,(ix)
- call CHPUT
- pop iy
- pop ix
- ret
+ ;A = ch
+
+ jp CHPUT
__endasm;
}
@@ -1661,11 +1655,9 @@ void chput(char ch) __naked
void print(char* string) __naked
{
__asm
- push ix
- ld ix,#4
- add ix,sp
- ld l,(ix)
- ld h,1(ix)
+
+ ;HL = string
+
PRLOOP:
ld a,(hl)
or a
@@ -1674,7 +1666,6 @@ void print(char* string) __naked
inc hl
jr PRLOOP
PREND:
- pop ix
ret
__endasm;
}
diff --git a/source/kernel/bank6/CPM32.EXE b/source/kernel/bank6/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/bank6/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/bank6/L80.CPM b/source/kernel/bank6/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/bank6/L80.CPM and /dev/null differ
diff --git a/source/kernel/bank6/LIB80.CPM b/source/kernel/bank6/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/bank6/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/bank6/M80.CPM b/source/kernel/bank6/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/bank6/M80.CPM and /dev/null differ
diff --git a/source/kernel/bank6/b6.mac b/source/kernel/bank6/b6.mac
index 43a87f3d..a6faa8e0 100644
--- a/source/kernel/bank6/b6.mac
+++ b/source/kernel/bank6/b6.mac
@@ -1,6 +1,7 @@
.z80
+ name('b6')
BANK equ 6
;
- include BANK.INC
+ include ../bank.inc
;
end
diff --git a/source/kernel/chgbnk.mac b/source/kernel/chgbnk.mac
index 3be90ed5..5701add2 100644
--- a/source/kernel/chgbnk.mac
+++ b/source/kernel/chgbnk.mac
@@ -1,4 +1,5 @@
.z80
+ name('chgbnk')
title CHGBNK - OEM Supplied Bank Switching Module
;
;-----------------------------------------------------------------------
diff --git a/source/kernel/codes.mac b/source/kernel/codes.mac
index 52097569..33c6d919 100644
--- a/source/kernel/codes.mac
+++ b/source/kernel/codes.mac
@@ -1,4 +1,5 @@
.z80
+ name('codes')
title MSX-DOS 2 Copyright (1988) ASCII Corporation
subttl Public constants declarations
.sall
diff --git a/source/kernel/compile.bat b/source/kernel/compile.bat
deleted file mode 100644
index 54df83ef..00000000
--- a/source/kernel/compile.bat
+++ /dev/null
@@ -1,286 +0,0 @@
-@echo off
-cls
-
-if .%1==.drivers goto :drivers
-
-echo .
-echo ****************
-echo *** COMMON ***
-echo ****************
-echo .
-
-if not exist ..\..\bin\kernels md ..\..\bin\kernels
-
-copy *.inc bank0\
-copy *.inc bank1\
-copy *.inc bank2\
-copy *.inc bank3\
-copy *.inc bank4\
-copy *.inc bank5\
-copy *.inc bank6\
-copy *.inc drivers\
-
-for %%A in (CODES,KVAR,DATA,REL,CHGBNK,DRV) do cpm32 M80 =%%A
-
-echo .
-echo ****************
-echo *** BANK 0 ***
-echo ****************
-echo .
-
-cd bank0
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\rel.rel
-copy ..\chgbnk.rel
-copy ..\drv.rel
-for %%A in (DOSHEAD,40FF,B0,INIT,ALLOC,DSKBASIC,DOSBOOT,BDOS,RAMDRV) do cpm32 M80 =%%A
-cpm32 l80 /p:4000,CODES,KVAR,DATA,REL,DOSHEAD,40FF,B0,INIT,ALLOC,DSKBASIC,DOSBOOT,BDOS,RAMDRV,/p:7700,drv,/p:7fd0,chgbnk,b0/n/x/y/e
-hex2bin b0.hex
-..\SymToEqus b0.sym b0labels.inc "\?[^ \t]+|DOSV0|GETERR|BDOSE|KDERR|KABR|C4PBK"
-..\SymToEqus b0.sym b0lab_b3.inc "INIT|TIMINT|MAPBIO|GWRK|R_[^ \t]+"
-
-echo .
-echo ****************
-echo *** BANK 1 ***
-echo ****************
-echo .
-
-cd ..\bank1
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\chgbnk.rel
-copy ..\bank0\alloc.rel
-copy ..\bank0\b0labels.inc
-copy ..\calbnk.rel
-for %%A in (B1,DOSINIT,MAPINIT,MSG) do cpm32 M80 =%%A
-cpm32 L80 /P:40FF,CODES,KVAR,DATA,B1,DOSINIT,MAPINIT,ALLOC,MSG,/p:7fd0,chgbnk,B1/N/X/Y/E
-hex2bin -s 4000 b1.hex
-
-echo .
-echo ****************
-echo *** BANK 2 ***
-echo ****************
-echo .
-
-cd ..\bank2
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\chgbnk.rel
-copy ..\bank0\b0labels.inc
-for %%A in (KINIT,CHAR,DEV,KBIOS,MISC,SEG,PATH,FIND,DIR,HANDLES,DEL,RW,FILES,BUF,FAT,VAL,ERR,B2) do cpm32 M80 =%%A
-cpm32 LIB80 TEMP21=char.rel,dev.rel,kbios.rel,misc.rel,seg.rel/E
-cpm32 LIB80 TEMP22=path.rel,find.rel,dir.rel,handles.rel,del.rel,rw.rel,files.rel/E
-cpm32 LIB80 TEMP23=buf.rel,fat.rel,val.rel,err.rel/E
-cpm32 L80 /P:40FF,CODES,KVAR,DATA,B2,KINIT,TEMP21,TEMP22,TEMP23,/p:7fd0,chgbnk,B2/N/X/Y/E
-del TEMP21.REL
-del TEMP22.REL
-del TEMP23.REL
-hex2bin -s 4000 b2.hex
-..\SymToEqus b2.sym b2labels.inc "\?[^ \t]+"
-
-echo .
-echo ****************
-echo *** BANK 3 ***
-echo ****************
-echo .
-
-cd ..\bank3
-copy ..\drv.rel
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\chgbnk.rel
-copy ..\bank0\doshead.rel
-copy ..\bank0\40FF.rel
-copy ..\bank0\b0lab_b3.inc
-for %%A in (DOS1KER,B3) do cpm32 M80 =%%A
-cpm32 l80 /p:4000,CODES,KVAR,DATA,DOSHEAD,40FF,B3,DOS1KER,/p:7700,drv,/p:7fd0,chgbnk,b3/N/X/Y/E
-hex2bin -s 4000 b3.hex
-
-echo .
-echo ****************
-echo *** BANK 4 ***
-echo ****************
-echo .
-
-cd ..\bank4
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\chgbnk.rel
-copy ..\bank2\b2labels.inc
-copy ..\bank0\b0labels.inc
-for %%A in (B4,JUMP,ENV,CPM,PARTIT,RAMDRV,TIME,SEG,MISC,DSKAB) do cpm32 M80 =%%A
-cpm32 L80 /P:40FF,CODES,KVAR,DATA,B4,JUMP,ENV,CPM,PARTIT,RAMDRV,TIME,SEG,MISC,/p:7bc0,DSKAB,/p:7fd0,chgbnk,B4/N/X/Y/E
-hex2bin -s 4000 b4.hex
-..\SymToEqus b4.sym b4rdlabs.inc "R4_[1-9]"
-for %%A in (RAMDRVH) do cpm32 M80 =%%A
-cpm32 L80 /P:4080,RAMDRVH,B4RD/N/X/Y/E
-hex2bin -s 4080 b4rd.hex
-
-echo .
-echo ****************
-echo *** BANK 5 ***
-echo ****************
-echo .
-
-cd ..\bank5
-
-if not exist fdisk.dat (
-echo !!! FDISK is not compiled!
-call compfdsk.bat
-echo !!! FDISK compiled. Resuming kernel compilation now...
-)
-
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\chgbnk.rel
-for %%A in (B5) do cpm32 M80 =%%A
-cpm32 L80 /P:40FF,CODES,KVAR,DATA,B5,/p:7fd0,chgbnk,B5/N/X/Y/E
-hex2bin -s 4000 b5.hex
-
-echo .
-echo ****************
-echo *** BANK 6 ***
-echo ****************
-echo .
-
-cd ..\bank6
-copy ..\codes.rel
-copy ..\kvar.rel
-copy ..\data.rel
-copy ..\chgbnk.rel
-for %%A in (B6) do cpm32 M80 =%%A
-cpm32 L80 /P:40FF,CODES,KVAR,DATA,B6,/p:7fd0,chgbnk,B6/N/X/Y/E
-hex2bin -s 4000 b6.hex
-
-echo .
-echo *******************
-echo *** BASE FILE ***
-echo *******************
-echo .
-
-cd ..
-copy /b bank0\b0.bin+bank1\b1.bin+bank2\b2.bin+bank3\b3.bin+bank4\b4.bin+bank5\b5.bin+bank6\b6.bin nextor_base.dat
-dd if=nextor_base.dat of=doshead.bin bs=1 count=255
-dd if=doshead.bin of=nextor_base.dat bs=1 count=255 seek=16k
-dd if=doshead.bin of=nextor_base.dat bs=1 count=255 seek=32k
-dd if=doshead.bin of=nextor_base.dat bs=1 count=255 seek=64k
-dd if=doshead.bin of=nextor_base.dat bs=1 count=255 seek=80k
-dd if=doshead.bin of=nextor_base.dat bs=1 count=255 seek=96k
-dd if=bank5\fdisk.dat of=nextor_base.dat bs=1 count=16000 seek=82176
-dd if=bank5\fdisk2.dat of=nextor_base.dat bs=1 count=8000 seek=98560
-copy bank4\b4rd.bin
-dd if=b4rd.bin of=nextor_base.dat bs=1 count=15 seek=65664
-copy nextor_base.dat Nextor-2.1.1-alpha2.base.dat
-copy nextor_base.dat ..\..\bin\kernels\Nextor-2.1.1-alpha2.base.dat
-
-:drivers
-
-echo .
-echo *****************
-echo *** DRIVERS ***
-echo *****************
-echo .
-
-cd drivers
-
-for /R %%c in (.) do (
-
-if exist %%~nc\driver.mac (
-
-echo .
-echo ***
-echo *** Driver: %%~nc
-echo ***
-echo .
-
-cd %%~nc
-copy ..\..\*.inc
-copy ..\..\codes.rel
-copy ..\..\kvar.rel
-copy ..\..\data.rel
-copy ..\..\chgbnk.rel
-copy ..\..\bank6\b6.mac
-copy ..\..\bank0\b0labels.inc
-for %%A in (B6,DRIVER,CHGBNK) do cpm32 M80 =%%A
-cpm32 L80 /P:4100,DRIVER,DRIVER/N/X/Y/E
-cpm32 L80 /P:7fd0,CHGBNK,CHGBNK/N/X/Y/E
-hex2bin -s 4000 driver.hex
-hex2bin -s 7FD0 CHGBNK.hex
-
-mknexrom ..\..\Nextor-2.1.1-alpha2.base.dat Nextor-2.1.1-alpha2.%%~nc.ROM /d:driver.bin /m:chgbnk.bin
-copy Nextor-2.1.1-alpha2.%%~nc.ROM ..\..\..\..\bin\kernels
-del b6.mac
-del *.rom
-cd ..
-)
-)
-
-echo .
-echo ***
-echo *** Driver: MegaFlashROM SD SCC+
-echo ***
-echo .
-
-cd MegaFlashRomSD
-copy ..\StandaloneASCII8\chgbnk.bin
-mknexrom ..\..\Nextor-2.1.1-alpha2.base.dat nextor2.rom /d:driver-1slot.dat /m:chgbnk.bin
-copy nextor2.rom ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.MegaFlashSDSCC.1-slot.ROM
-sjasm makerecoverykernel.asm kernel.dat
-copy kernel.dat ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.MegaFlashSDSCC.1-slot.Recovery.ROM
-del nextor2.rom
-mknexrom ..\..\Nextor-2.1.1-alpha2.base.dat nextor2.rom /d:driver-2slots.dat /m:chgbnk.bin
-copy nextor2.rom ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.MegaFlashSDSCC.2-slots.ROM
-sjasm makerecoverykernel.asm kernel.dat
-copy kernel.dat ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.MegaFlashSDSCC.2-slots.Recovery.ROM
-cd ..
-
-echo .
-echo ***
-echo *** Driver: Sunrise IDE
-echo ***
-echo .
-
-cd SunriseIDE
-
-del ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.SunriseIDE.emulators.ROM
-ren ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.SunriseIDE.ROM Nextor-2.1.1-alpha2.SunriseIDE.emulators.ROM
-sjasm -c sunride.asm driver.bin
-mknexrom ..\..\Nextor-2.1.1-alpha2.base.dat nextor2.rom /d:driver.bin /m:chgbnk.bin
-copy nextor2.rom ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.SunriseIDE.ROM
-:okide
-cd ..
-
-echo .
-echo ***
-echo *** Driver: Flashjacks
-echo ***
-echo .
-
-cd Flashjacks
-sjasm flashjacks.asm driver.bin
-mknexrom ..\..\Nextor-2.1.1-alpha2.base.dat nextor2.rom /d:driver.bin /m:chgbnk.dat
-copy nextor2.rom ..\..\..\..\bin\kernels\Nextor-2.1.1-alpha2.Flashjacks.ROM
-cd ..
-
-echo .
-echo *****************
-echo *** CLEANUP ***
-echo *****************
-echo .
-
-cd ..
-
-rem del *.bin /s > nul
-rem del *.hex /s >nul
-rem del *.sym /s > nul
-rem for %%A in (bank0, bank1, bank2, bank3, bank4, bank5, drivers) do del %%A\*.inc /s > nul
-rem for %%A in (., bank0, bank1, bank2, bank4, drivers) do del %%A\*.rel /s > nul
-rem del bank3\chgbnk.rel
-rem del bank3\drv.rel
diff --git a/source/kernel/const.inc b/source/kernel/const.inc
index 130996fd..d4262522 100644
--- a/source/kernel/const.inc
+++ b/source/kernel/const.inc
@@ -176,7 +176,7 @@ ATM_ARC equ (1 SHL AT_ARC)
ATM_DEV equ (1 SHL AT_DEV)
;
;
-; BITS IN "FAB_ACC" ACCESS MODE BYTE
+; BITS IN "FAB_ACCESS_MODE" ACCESS MODE BYTE
; =====================================
;
AC_WR equ 0 ;Set => Read only access
diff --git a/source/kernel/data.mac b/source/kernel/data.mac
index 4986472c..41235ece 100644
--- a/source/kernel/data.mac
+++ b/source/kernel/data.mac
@@ -1,10 +1,11 @@
.z80
+ name('data')
title MSX-DOS 2 Copyright (1986) IS Systems Ltd.
subttl Page-3 Fixed System Data Area
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE macros.inc
+ INCLUDE const.inc
;
;-----------------------------------------------------------------------------
;
diff --git a/source/kernel/drivers/CPM32.EXE b/source/kernel/drivers/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/drivers/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/drivers/Flashjacks/flashjacks.asm b/source/kernel/drivers/Flashjacks/flashjacks.asm
index 208fea1e..c8da122f 100644
--- a/source/kernel/drivers/Flashjacks/flashjacks.asm
+++ b/source/kernel/drivers/Flashjacks/flashjacks.asm
@@ -5,9 +5,9 @@
;output "sunride_aquijacks.bin"
- org $4000
+ org 4000h
- ds 256, $FF ; 256 dummy bytes
+ ds 256, 0FFh ; 256 dummy bytes
DRV_START:
diff --git a/source/kernel/drivers/MegaFlashRomSD/driver-1slot.dat b/source/kernel/drivers/MegaFlashRomSD/driver-1slot.dat
deleted file mode 100644
index cf812a68..00000000
Binary files a/source/kernel/drivers/MegaFlashRomSD/driver-1slot.dat and /dev/null differ
diff --git a/source/kernel/drivers/MegaFlashRomSD/driver-2slots.dat b/source/kernel/drivers/MegaFlashRomSD/driver-2slots.dat
deleted file mode 100644
index 68e00b59..00000000
Binary files a/source/kernel/drivers/MegaFlashRomSD/driver-2slots.dat and /dev/null differ
diff --git a/source/kernel/drivers/MegaFlashRomSD/makerecoverykernel.asm b/source/kernel/drivers/MegaFlashRomSD/makerecoverykernel.asm
deleted file mode 100644
index 875228fe..00000000
--- a/source/kernel/drivers/MegaFlashRomSD/makerecoverykernel.asm
+++ /dev/null
@@ -1,19 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Create the kernel recovery file.
-// It's aheader that acts as an identifier and tells the size of the kernel.
-// This file has to be saved in the SD card after formatting it,
-// then it's loaded from the recovery menu.
-//
-// Manuel Pazos 13/01/2013
-//
-//-----------------------------------------------------------------------------
-
- ;----------------
- db "MFRSD KERNEL 1.0"
- db (end-start) / (8*1024)
- ds 512-$,#ff
-start:
- incbin "nextor2.rom"
- ;incbin "nextor.dsk"
-end:
diff --git a/source/kernel/drivers/MegaFlashRomSD/mfrsd.asm b/source/kernel/drivers/MegaFlashRomSD/mfrsd.asm
new file mode 100644
index 00000000..63825574
--- /dev/null
+++ b/source/kernel/drivers/MegaFlashRomSD/mfrsd.asm
@@ -0,0 +1,2194 @@
+;-----------------------------------------------------------------------------
+;
+; MegaFlashROM SCC+ SD disk driver for Nextor
+; By Manuel Pazos 14/12/2012
+;
+; 24/07/2018 - v1.3 Implement DRV_CONFIG routine (Nextor 2.0.5)
+;-----------------------------------------------------------------------------
+
+DRIVER_VERSION equ 1
+DRIVER_SUBVERSION equ 3
+
+ .RELAB
+
+;---------------------------------------------------------------------------
+; MACROS
+;---------------------------------------------------------------------------
+
+ADD_HL_A macro
+ add a, l ; 4
+ ld l, a ; 4
+ adc a, h ; 4
+ sub l ; 4
+ ld h, a ; 4
+ ENDM
+
+ADD_DE_A macro
+ add a, e ; 4
+ ld e, a ; 4
+ adc a, d ; 4
+ sub e ; 4
+ ld d, a ; 4
+ ENDM
+
+;-----------------------------------------------------------------------------
+; Constants
+;-----------------------------------------------------------------------------
+
+WORK_AREA_SIZE equ 0 ; RAM needed by the driver
+
+ ;The NUM_SLOTS constant (SD card slots available) must be defined externally
+
+ ifndef NUM_SLOTS
+ .fatal NUM_SLOTS constant required with a value of 1 or 2
+ else
+ if (NUM_SLOTS NE 1) and (NUM_SLOTS NE 2)
+ .fatal The value of NUM_SLOTS must be either 1 or 2, got {NUM_SLOTS}
+ endif
+ endif
+
+; Work area offsets
+STATUS equ 0 ; Offset in work area to status byte
+
+BIT_SDHC equ 0 ; 0 = SDSC, 1 = SDHC
+BIT_SD_CHG equ 1 ; 0 = Not changed, 1 = Changed
+BIT_ROM_DSK equ 2 ; 0 = Not available, 1 = Available
+;CARD_TYPE equ 31
+
+; Cards types
+CARD_MMC equ 0
+CARD_SD1X equ 1
+CARD_SD2X equ 2
+CARD_SDHC equ 3
+
+
+;This is a 2 byte buffer to store the address of code to be executed.
+;It is used by some of the kernel page 0 routines.
+CODE_ADD: equ 0F2EDh
+
+; BIOS
+ENASLT: equ #24
+CHGET equ #9f
+CHPUT equ #A2 ;Character output
+RSLREG: equ #138
+EXPTBL: equ #FCC1
+SLTWRK: equ #FD09
+
+; SD
+DATA_TOKEN equ #FE
+MUL_DAT_TKN_STA equ #FC
+MUL_DAT_TKN_END equ #FD
+
+;Driver type:
+DRV_TYPE equ 1 ; 0 for drive-based, 1 for device-based
+
+;Driver version
+VER_MAIN equ 1
+VER_SEC equ 3
+VER_REV equ 0
+
+
+; Error codes for DEV_RW
+ IF DRV_TYPE = 1
+NCOMP equ 0FFh
+WRERR equ 0FEh
+DISK equ 0FDh
+NRDY equ 0FCh
+DATA equ 0FAh
+RNF equ 0F9h
+WPROT equ 0F8h
+UFORM equ 0F7h
+SEEK equ 0F3h
+IFORM equ 0F0h
+IDEVL equ 0B5h
+IPARM equ 08Bh
+ ENDIF
+
+
+;-----------------------------------------------------------------------------
+; Start
+;-----------------------------------------------------------------------------
+
+ org #4000
+
+ ds 256,0 ; Dummy bytes. Will be overwriten by Page 0 code
+
+DRV_START:
+
+;-----------------------------------------------------------------------------
+;
+; Routines and information available on kernel page 0
+;
+;-----------------------------------------------------------------------------
+;* Get in A the current slot for page 1. Corrupts F.
+; Must be called by using CALBNK to bank 0:
+; xor a
+; ld ix,GSLOT1
+; call CALBNK
+
+GSLOT1 equ 402Dh
+
+
+;* This routine reads a byte from another bank.
+; Must be called by using CALBNK to the desired bank,
+; passing the address to be read in HL:
+; ld a,
+; ld hl,
+; ld ix,RDBANK
+; call CALBNK
+
+RDBANK equ 403Ch
+
+
+;* This routine temporarily switches kernel main bank
+; (usually bank 0, but will be 3 when running in MSX-DOS 1 mode),
+; then invokes the routine whose address is at (CODE_ADD).
+; It is necessary to use this routine to invoke CALBAS
+; (so that kernel bank is correct in case of BASIC error)
+; and to invoke DOS functions via F37Dh hook.
+;
+; Input: Address of code to invoke in (CODE_ADD).
+; AF, BC, DE, HL, IX, IY passed to the called routine.
+; Output: AF, BC, DE, HL, IX, IY returned from the called routine.
+
+CALLB0 equ 403Fh
+
+
+;* Call a routine in another bank.
+; Must be used IF the driver spawns across more than one bank.
+;
+; Input: A = bank number
+; IX = routine address
+; AF' = AF for the routine
+; HL' = Ix for the routine
+; BC, DE, HL, IY = input for the routine
+; Output: AF, BC, DE, HL, IX, IY returned from the called routine.
+
+CALBNK equ 4042h
+
+
+;* Get in IX the address of the SLTWRK entry for the slot passed in A,
+; which will in turn contain a pointer to the allocated page 3
+; work area for that slot (0 IF no work area was allocated).
+; IF A=0, then it uses the slot currently switched in page 1.
+; Returns A=current slot for page 1, IF A=0 was passed.
+; Corrupts F.
+; Must be called by using CALBNK to bank 0:
+; ld a, (xor a for current page 1 slot)
+; ex af,af'
+; xor a
+; ld ix,GWORK
+; call CALBNK
+
+GWORK equ 4045h
+
+
+;* This address contains one byte that tells how many banks
+; form the Nextor kernel (or alternatively, the first bank
+; number of the driver).
+
+K_SIZE equ 40FEh
+
+
+;* This address contains one byte with the current bank number.
+
+CUR_BANK equ 40FFh
+
+
+;-----------------------------------------------------------------------------
+;
+; Built-in format choice strings
+;
+;-----------------------------------------------------------------------------
+NULL_MSG equ 781Fh ;Null string (disk can't be formatted)
+SING_DBL equ 7820h ;"1-Single side / 2-Double side"
+
+
+;-----------------------------------------------------------------------------
+;
+; Driver signature
+;
+;-----------------------------------------------------------------------------
+ db "NEXTOR_DRIVER",0
+
+
+;-----------------------------------------------------------------------------
+;
+; Driver flags:
+; bit 0: 0 for drive-based, 1 for device-based
+; bit 1: 1 for hot-plug devices supported (device-based drivers only)
+; bit 2: 1 if the driver provides configuration
+; (implements the DRV_CONFIG routine)
+;-----------------------------------------------------------------------------
+ IF DRV_TYPE = 0
+ db 0
+ ENDIF
+
+ IF DRV_TYPE = 1
+ db %00000111
+ ENDIF
+
+
+;-----------------------------------------------------------------------------
+;
+; Reserved byte
+;
+;-----------------------------------------------------------------------------
+ db 0
+
+
+;-----------------------------------------------------------------------------
+;
+; Driver name
+;
+;-----------------------------------------------------------------------------
+DRV_NAME:
+ db "MegaFlashROM SCC+ SD"
+ ds 32-($-DRV_NAME)," "
+
+
+;-----------------------------------------------------------------------------
+;
+; Jump table for the driver public routines
+;
+;-----------------------------------------------------------------------------
+ ; These routines are mandatory for all drivers
+ ; (but probably you need to implement only DRV_INIT)
+
+ jp DRV_TIMI
+ jp DRV_VERSION
+ jp DRV_INIT
+ jp DRV_BASSTAT
+ jp DRV_BASDEV
+ jp DRV_EXTBIO
+ jp DRV_DIRECT0
+ jp DRV_DIRECT1
+ jp DRV_DIRECT2
+ jp DRV_DIRECT3
+ jp DRV_DIRECT4
+ jp DRV_CONFIG
+
+ ds 12
+
+ IF DRV_TYPE = 0
+
+ ; These routines are mandatory for drive-based drivers
+
+ jp DRV_DSKIO
+ jp DRV_DSKCHG
+ jp DRV_GETDPB
+ jp DRV_CHOICE
+ jp DRV_DSKFMT
+ jp DRV_MTOFF
+ ENDIF
+
+ IF DRV_TYPE = 1
+
+ ; These routines are mandatory for device-based drivers
+
+ jp DEV_RW
+ jp DEV_INFO
+ jp DEV_STATUS
+ jp LUN_INFO
+ jp DEV_FORMAT
+ jp DEV_CMD
+ ENDIF
+
+
+;=====
+;===== END of data that must be at fixed addresses
+;=====
+
+;-----------------------------------------------------------------------------
+;
+; BASIC expanded statement ("CALL") handler.
+; Works the expected way, except that IF invoking CALBAS is needed,
+; it must be done via the CALLB0 routine in kernel page 0.
+;-----------------------------------------------------------------------------
+DRV_BASSTAT:
+ scf
+ ;include "expcall.asm"
+ ret
+
+;-----------------------------------------------------------------------------
+; Dejamos libre el area usada por los puertos del MegaSD #4000-#5FFF
+;-----------------------------------------------------------------------------
+ ds #6000-$
+
+
+;-----------------------------------------------------------------------------
+; Timer interrupt routine, it will be called on each timer interrupt
+; (at 50 or 60Hz), but only IF DRV_INIT returns Cy=1 on its first execution.
+;-----------------------------------------------------------------------------
+DRV_TIMI:
+ ret
+
+
+;-----------------------------------------------------------------------------
+;
+; Driver initialization routine, it is called twice:
+;
+; 1) First execution, for information gathering.
+; Input:
+; A = 0
+; B = number of available drives
+; HL = maximum size of allocatable work area in page 3
+; Output:
+; A = number of required drives (for drive-based driver only)
+; HL = size of required work area in page 3
+; Cy = 1 IF DRV_TIMI must be hooked to the timer interrupt, 0 otherwise
+;
+; 2) Second execution, for work area and hardware initialization.
+; Input:
+; A = 1
+; B = number of allocated drives for this controller
+;
+; The work area address can be obtained by using GWORK.
+;
+; IF first execution requests more work area than available,
+; second execution will not be done and DRV_TIMI will not be hooked
+; to the timer interrupt.
+;
+; IF first execution requests more drives than available,
+; as many drives as possible will be allocated, and the initialization
+; procedure will continue the normal way
+; (for drive-based drivers only. Device-based drivers always
+; get two allocated drives.)
+;-----------------------------------------------------------------------------
+DRV_INIT:
+ or a
+ jr nz,.secondExe ; Second execution
+
+ ld hl,WORK_AREA_SIZE
+ ;ld a,NUM_DRIVES
+ ret ;Note that Cy is 0 (no interrupt hooking needed)
+
+.secondExe:
+ ld de,TXT_INFO
+ call PRINT ; Driver info
+
+ ld c,0
+ call RomDiskCheck
+ jr nz,.notFound ; ROM disk not found
+
+ ld de,TXT_ROMDSKOK
+ call PRINT ; Print "Rom disk found"
+
+ ld c,1 ; Flag ROM disk found
+.notFound:
+ ld b,NUM_SLOTS
+.loop:
+ push bc
+ di
+
+ ld a,NUM_SLOTS
+ sub b
+ call GETWRK
+ dec c
+ jr nz,.notRomDisk
+
+ set BIT_ROM_DSK,(ix+0) ; ROM disk available
+.notRomDisk:
+
+ call SD_ON
+ ld a,NUM_SLOTS
+ sub b
+ ld c,a
+ push bc
+ ld (#5800),a ; Select SD slot
+ call InitSD ; Init SD card
+ call SD_OFF
+ pop bc ; C = SD slot
+ ei
+
+ .COMMENT *
+ push af
+ ld a,e
+ and #f
+ add a,"0"
+ call CHPUT ; Error code
+ pop af
+ ;*
+
+ jr c,.notCard
+ jr nz,.notCard
+
+ ld b,e ; Card type
+ ld de,TXT_INIT
+ call PRINT ; Card init text
+
+ ld a,c ; SD slot
+ add a,'1'
+ call CHPUT
+ ld a,':'
+ call CHPUT
+
+ ld a,b ; Card type
+ rlca
+ ld hl,IDX_TYPE
+ ADD_HL_A
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ call PRINT ; Shows card type
+.notCard:
+ pop bc
+ djnz .loop
+
+ ld de,TXT_EMPTY
+ call PRINT
+ ret
+
+;-----------------------------------------------------------------------------
+;
+; Obtain driver version
+;
+; Input: -
+; Output: A = Main version number
+; B = Secondary version number
+; C = Revision number
+;-----------------------------------------------------------------------------
+DRV_VERSION:
+ ld a,VER_MAIN
+ ld b,VER_SEC
+ ld c,VER_REV
+ ret
+
+
+
+
+
+;-----------------------------------------------------------------------------
+;
+; BASIC expanded device handler.
+; Works the expected way, except that IF invoking CALBAS is needed,
+; it must be done via the CALLB0 routine in kernel page 0.
+;-----------------------------------------------------------------------------
+DRV_BASDEV:
+ scf
+ ret
+
+
+;-----------------------------------------------------------------------------
+;
+; Extended BIOS hook.
+; Works the expected way, except that it must return
+; D'=1 IF the old hook must be called, D'=0 otherwise.
+; It is entered with D'=1.
+;-----------------------------------------------------------------------------
+DRV_EXTBIO:
+ ret
+
+
+;-----------------------------------------------------------------------------
+;
+; Direct calls entry points.
+; Calls to addresses 7450h, 7453h, 7456h, 7459h and 745Ch
+; in kernel banks 0 and 3 will be redirected
+; to DIRECT0/1/2/3/4 respectively.
+; Receives all register data from the caller except IX and AF'.
+;-----------------------------------------------------------------------------
+DRV_DIRECT0:
+DRV_DIRECT1:
+DRV_DIRECT2:
+DRV_DIRECT3:
+DRV_DIRECT4:
+ ret
+
+;-----------------------------------------------------------------------------
+;
+; Get driver configuration
+;
+; Input:
+; A = Configuration index
+; BC, DE, HL = Depends on the configuration
+;
+; Output:
+; A = 0: Ok
+; 1: Configuration not available for the supplied index
+; BC, DE, HL = Depends on the configuration
+;
+; * Get number of drives at boot time (for device-based drivers only):
+; Input:
+; A = 1
+; B = 0 for DOS 2 mode, 1 for DOS 1 mode
+; Output:
+; B = number of drives
+;
+; * Get default configuration for drive
+; Input:
+; A = 2
+; B = 0 for DOS 2 mode, 1 for DOS 1 mode
+; C = Relative drive number at boot time
+; Output:
+; B = Device index
+; C = LUN index
+
+DRV_CONFIG:
+ dec a
+ jr z,.GetNumDrives
+
+ dec a
+ jr z,.GetRelDrvNum
+
+.error:
+ ld a,1 ; Unknown configuration index
+ ret
+
+.GetNumDrives:
+ bit 5,c ;Single drive per driver requested?
+ ld b,1
+ ld a,0
+ ret nz
+
+ call RomDiskCheck
+ ld b,NUM_SLOTS+1 ; Three drives: ROM disk, SD 1 and SD 2
+ jr z,.GetNumDrives2
+
+ dec b ; ROM Disk not available
+
+.GetNumDrives2:
+ xor a
+ ret
+
+.GetRelDrvNum:
+
+ ld b,c
+ inc b
+ call RomDiskCheck
+
+ jr z,.ok
+
+ inc b
+
+.ok:
+ ld c,1
+ xor a
+ ret
+
+
+;=====
+;===== BEGIN of DRIVE-BASED specific routines
+;=====
+
+ IF DRV_TYPE = 0
+ include "drivebased.asm"
+ ENDIF
+
+;=====
+;===== END of DRIVE-BASED specific routines
+;=====
+
+
+
+;=====
+;===== BEGIN of DEVICE-BASED specific routines
+;=====
+
+ IF DRV_TYPE = 1
+
+;-----------------------------------------------------------------------------
+;
+; Read or write logical sectors from/to a logical unit
+;
+;Input: Cy=0 to read, 1 to write
+; A = Device number, 1 to 7
+; B = Number of sectors to read or write
+; C = Logical unit number, 1 to 7
+; HL = Source or destination memory address for the transfer
+; DE = Address where the 4 byte sector number is stored.
+;Output: A = Error code (the same codes of MSX-DOS are used):
+; 0: Ok
+; .IDEVL: Invalid device or LUN
+; .NRDY: Not ready
+; .DISK: General unknown disk error
+; .DATA: CRC error when reading
+; .RNF: Sector not found
+; .UFORM: Unformatted disk
+; .WPROT: Write protected media, or read-only logical unit
+; .WRERR: Write error
+; .NCOMP: Incompatible disk.
+; .SEEK: Seek error.
+; B = Number of sectors actually read (in case of error only)
+;-----------------------------------------------------------------------------
+DEV_RW:
+
+ push af
+ dec a
+ jp z,.romdisk ; ROM disk device
+
+ dec a
+ cp NUM_SLOTS ; Device number
+ jp nc,.error
+
+ dec c ; LUN
+ jp nz,.error
+
+ di
+ call SD_ON
+ ld (#5800),a ; SD slot select
+ call GETWRK
+
+ pop af ; Cy=0 to read, 1 to write
+
+ jr c,.write ; Write
+
+ ; Read
+ ;push af
+ ;ld a,#f6
+ ;call Color
+ ;pop af
+
+ .COMMENT *
+ ;Count read sectors ----------------------------
+ push hl
+ push af
+ ld a,b
+ ld hl,(#f9f0)
+ add a, l ; 4
+ ld l, a ; 4
+ adc a, h ; 4
+ sub l ; 4
+ ld h, a ; 4
+ ld (#f9f0),hl
+ pop af
+ pop hl
+ ;----------------------------
+ ;*
+
+ call ReadSD
+
+ ;push af
+ ;ld a,#f0
+ ;call Color
+ ;pop af
+
+
+ ;ld hl,(#f9f0)
+ ;inc hl
+ ;ld (#f9f0),hl ; Cuenta lecturas
+
+ call SD_OFF
+ ei
+ jr nc,.ok
+
+ ld b,0
+ ;ld a,DISK ; General unknown disk error
+ ret
+
+.ok:
+ xor a ; Ok
+ ret
+
+.write:
+ ; Write
+ call WriteSD
+ call SD_OFF
+ ei
+ jr nc,.ok ; Ok
+
+ .COMMENT *
+ ; DEBUG: Print error number in A
+ ld c,"0"
+ add a,c
+ ld ix,#a2
+ ld iy,(#fcc1-1)
+ call #1c
+ ;*
+
+.writeError:
+ ld b,0
+ ld a,WRERR ; Write error
+ ret ; Error
+
+.error:
+ pop af
+ ld b,0
+ ld a,IDEVL ; Invalid device or LUN
+ ret
+
+;----------
+; ROM disk
+;----------
+.romdisk:
+ dec c ; LUN
+ jp nz,.error
+
+ pop af
+ jr c,.writeError ; Can't write in ROM
+
+ jp RomDiskRead
+
+;-----------------------------------------------------------------------------
+;
+; Device information gathering
+;
+;Input: A = Device index, 1 to 7
+; B = Information to return:
+; 0: Basic information
+; 1: Manufacturer name string
+; 2: Device name string
+; 3: Serial number string
+; HL = Pointer to a buffer in RAM
+;Output: A = Error code:
+; 0: Ok
+; 1: Device not available or invalid device index
+; 2: Information not available, or invalid information index
+; When basic information is requested,
+; buffer filled with the following information:
+;
+;+0 (1): Numer of logical units, from 1 to 7. 1 IF the device has no logical
+; units (which is functionally equivalent to having only one).
+;+1 (1): Device flags, always zero in Alpha 2b.
+;
+; The strings must be printable ASCII string (ASCII codes 32 to 126),
+; left justified and padded with spaces. All the strings are optional,
+; IF not available, an error must be returned.
+; IF a string is provided by the device in binary format, it must be reported
+; as an hexadecimal, upper-cased string, preceded by the prefix "0x".
+; The maximum length for a string is 64 characters;
+; IF the string is actually longer, the leftmost 64 characters
+; should be provided.
+;
+; In the case of the serial number string, the same rules for the strings
+; apply, except that it must be provided right-justified,
+; and IF it is too long, the rightmost characters must be
+; provided, not the leftmost.
+;-----------------------------------------------------------------------------
+DEV_INFO:
+ dec a
+ jp z,RomDiskInfo ; ROM disk
+
+ dec a
+ cp NUM_SLOTS
+ jp nc,.DEV_INFO_ERROR
+
+ call GETWRK
+ push ix
+ pop de
+
+ di
+ call SD_ON
+ ld (#5800),a ; SD slot select
+
+ push bc
+ push hl
+ call GetCID
+ pop de ; DE = Buffer in RAM, HL = SD registers
+ pop bc
+ jp c,.DEV_INFO_ERROR
+
+ djnz .DEV_INFO2
+
+ ; 1: Manufacturer name string
+
+ ld a,(hl) ; ID
+ push af
+ ld b,15 + 2
+ call SkipBytes
+ call GetManufacName
+ ld b,0
+ ldir ; Copy manufacturer name to buffer
+ pop bc
+
+ ; Add [id] to the manufacturer name
+ ld a,"["
+ ld (de),a
+ inc de
+ ld a,b
+ call Num2Hex.Num1
+ ld a,b
+ call Num2Hex.Num2
+ ld a,"]"
+ ld (de),a
+ inc de
+ jr .DEV_END
+
+
+.DEV_INFO2:
+ djnz .DEV_INFO3
+
+ ; 2: Device name string
+ ld a,(hl) ; MID
+ ld a,(hl) ; OID byte 1
+ ld a,(hl) ; OID byte 2
+ ld bc,5
+ ldir
+
+ ld b,8 + 2
+ call SkipBytes
+ jr .DEV_END
+
+
+.DEV_INFO3:
+ djnz .DEV_INFO0
+
+ ; 3: Serial number string
+ ;ex de,hl
+ ld b,9
+ call SkipBytes
+
+ call .num
+ call .num
+
+ ld b,3 + 2
+ call SkipBytes
+ jr .DEV_END
+.num:
+ ld a,(hl)
+ ld l,(hl)
+ ld h,a
+ call Num2Hex
+ ld h,#40
+ ret
+
+.DEV_INFO0:
+ ; 0: Basic information
+ ld b,16 + 2
+ call SkipBytes
+ ex de,hl
+ ld (hl),1 ; Number of logical units
+ inc hl
+ ld (hl),0 ; Flags: always zero in Alpha 2b.
+ jr .DEV_END2
+ ;xor a
+ ;ret
+
+.DEV_END:
+ xor a
+ ld (de),a
+.DEV_END2:
+ call SD_OFF
+ ei
+ xor a
+ ret
+
+.DEV_INFO_ERROR:
+ call SD_OFF
+ ei
+ ld a,1
+ ret
+
+
+;------------------------------------------------------------------------------
+; Input: HL = number to convert, DE = location of ASCII string
+; Output: ASCII string at (DE)
+;------------------------------------------------------------------------------
+Num2Hex:
+ ld a,h
+ call .Num1
+ ld a,h
+ call .Num2
+ ld a,l
+ call .Num1
+ ld a,l
+ jr .Num2
+
+.Num1:
+ rra
+ rra
+ rra
+ rra
+.Num2:
+ or #F0
+ daa
+ add a,#A0
+ adc a,#40
+
+ ld (de),a
+ inc de
+ ret
+
+;-----------------------------------------------------------------------------
+; Get manufacturer name
+; In: A = ID
+; Out: HL = String
+; BC = String length
+;-----------------------------------------------------------------------------
+GetManufacName:
+ ld c,a
+ ld hl,Manufacturers
+.loop:
+ ld a,(hl)
+ inc hl
+ cp c
+ jr z,.found
+
+ or a
+ jr z,.found ; No more names in the list
+
+ push bc
+ call .found
+ add hl,bc
+ inc hl
+ pop bc
+ jr .loop
+.found:
+ ld c,0
+ push hl
+ ld a,"$"
+.cont:
+ inc c
+ inc hl
+ cp (hl)
+ jr nz,.cont
+.end:
+ pop hl
+ ld b,0
+ ret
+
+Manufacturers:
+ db #01,"Panasonic$"
+ db #02,"Toshiba$"
+ db #03,"SanDisk$"
+ db #04,"(SMI-S?)"
+ db #06,"Renesas$"
+ db #11,"Dane-Elec$"
+ db #15,"Samsumg$"
+ db #18,"Infineon$"
+ db #13,"(KingMax?)$"
+ db #1a,"(PQI?)$"
+ db #1b,"(Sony?)$"
+ db #1c,"(Transcend?)$"
+ db #1d,"(A-DATA?)$"
+ db #27,"Verbatim$"
+ db #37,"(KINGMAX?)$"
+ db #41,"OKI$"
+ db #73,"SilverHT$"
+ db #aa,"openMSX$"
+ db #00,"Unknown$"
+;-----------------------------------------------------------------------------
+;
+; Obtain device status
+;
+;Input: A = Device index, 1 to 7
+; B = Logical unit number, 1 to 7
+; 0 to return the status of the device itself.
+;Output: A = Status for the specified logical unit,
+; or for the whole device IF 0 was specified:
+; 0: The device or logical unit is not available, or the
+; device or logical unit number supplied is invalid.
+; 1: The device or logical unit is available and has not
+; changed since the last status request.
+; 2: The device or logical unit is available and has changed
+; since the last status request
+; (for devices, the device has been unplugged and a
+; different device has been plugged which has been
+; assigned the same device index; for logical units,
+; the media has been changed).
+; 3: The device or logical unit is available, but it is not
+; possible to determine whether it has been changed
+; or not since the last status request.
+;
+; Devices not supporting hot-plugging must always return status value 1.
+; Non removable logical units may return values 0 and 1.
+;-----------------------------------------------------------------------------
+DEV_STATUS:
+ dec a
+ jp z,RomDiskStatus ; ROM disk
+
+ dec a
+ cp NUM_SLOTS
+ jp nc,DEV_STAT1
+ ld c,a
+
+ ld a,b
+ cp 2
+ jp nc,DEV_STAT1
+
+ di
+ ld a,c
+ call GETWRK
+ call SD_ON
+ ld (#5800),a ; SD slot select
+
+ ;push ix
+ call TestCard ;call GetCID
+ ;pop de ; DE = Work area, HL = SD registers
+
+ call SD_OFF
+ ei
+
+ jr c,DEV_STAT0
+
+ bit BIT_SD_CHG,(ix+STATUS); Has been the card initiated?
+ jr z,.notChanged
+ ;ld a,3
+ ;ret
+ res BIT_SD_CHG,(ix+STATUS); Reset changed status
+
+ ;ld a,#f2
+ ;call Color
+ ;call Beep
+ ld a,2 ; Has changed
+ ret
+
+.notChanged:
+ ;ld a,#f6
+ ;call Color
+
+ ld a,1 ; Has not changed
+ ret
+DEV_STAT0:
+
+ ;ld a,#fa
+ ;call Color
+DEV_STAT1:
+ xor a
+ ret
+
+Color:
+ di
+ out (#99),a
+ ld a,#87
+ out (#99),a
+ ;ei
+ ret
+
+Beep:
+ ld ix,#c0
+ ld iy,(#fcc1-1)
+ call #1c
+ ret
+
+;-----------------------------------------------------------------------------
+;
+; Obtain logical unit information
+;
+;Input: A = Device index, 1 to 7
+; B = Logical unit number, 1 to 7
+; HL = Pointer to buffer in RAM.
+;Output: A = 0: Ok, buffer filled with information.
+; 1: Error, device or logical unit not available,
+; or device index or logical unit number invalid.
+; On success, buffer filled with the following information:
+;
+;+0 (1): Medium type:
+; 0: Block device
+; 1: CD or DVD reader or recorder
+; 2-254: Unused. Additional codes may be defined in the future.
+; 255: Other
+;+1 (2): Sector size, 0 IF this information does not apply or is
+; not available.
+;+3 (4): Total number of available sectors.
+; 0 IF this information does not apply or is not available.
+;+7 (1): Flags:
+; bit 0: 1 IF the medium is removable.
+; bit 1: 1 IF the medium is read only. A medium that can dinamically
+; be write protected or write enabled is not considered
+; to be read-only.
+; bit 2: 1 IF the LUN is a floppy disk drive.
+;+8 (2): Number of cylinders
+;+10 (1): Number of heads
+;+11 (1): Number of sectors per track
+;
+; Number of cylinders, heads and sectors apply to hard disks only.
+; For other types of device, these fields must be zero.
+;-----------------------------------------------------------------------------
+LUN_INFO:
+ dec a
+ jp z,RomDiskLUN_INFO
+
+ dec a
+ cp NUM_SLOTS
+ jp nc,LUN_ERROR
+ ld c,a
+
+ ld a,b
+ cp 1
+ jp nz,LUN_ERROR
+
+ push hl
+ di
+ call SD_ON
+ ld a,c
+ ld (#5800),a ; SD slot select
+ call GETWRK
+ call GetSectNum ; Get number of available sectors
+ ;call WaitReady
+ call nc,WaitBusy
+ call SD_OFF
+ ei
+
+ ld b,h
+ ld c,l ;DEBC = Available sectors
+ pop hl
+
+ jr c,LUN_ERROR
+
+ ld (hl),0 ; +0: Medium type = Block device
+ inc hl
+
+ ld (hl),0 ; +1: Sector size = #200
+ inc hl
+ ld (hl),2
+ inc hl
+
+ ld (hl),c ; +3: Total number of sectors
+ inc hl
+ ld (hl),b
+ inc hl
+ ld (hl),e
+ inc hl
+ ld (hl),d
+ inc hl
+
+ ld (hl),1 ; +7: Flags
+ inc hl
+
+ ld (hl),0 ; +8 Cylinders
+ inc hl
+ ld (hl),0
+ inc hl
+
+ ld (hl),0 ; +10: Heads
+ inc hl
+
+ ld (hl),0 ; +11: Sectors per tracks
+
+ xor a ; Ok, buffer filled with information.
+ ret
+
+LUN_ERROR:
+ ld a,1 ; Error
+ ret
+ ENDIF
+
+
+;-----------------------------------------------------------------------------
+;
+; Physical format a device
+;
+;Input: A = Device index, 1 to 7
+; B = Logical unit number, 1 to 7
+; C = Format choice, 0 to return choice string
+;Output:
+; When C=0 at input:
+; A = 0: Ok, address of choice string returned
+; .IFORM: Invalid device or logical unit number,
+; or device not formattable
+; HL = Address of format choice string (in bank 0 or 3),
+; only if A=0 returned.
+; Zero, if only one choice is available.
+;
+; When C<>0 at input:
+; A = 0: Ok, device formatted
+; Other: error code, same as DEV_RW plus:
+; .IPARM: Invalid format choice
+; .IFORM: Invalid device or logical unit number,
+; or device not formattable
+; B = Media ID if the device is a floppy disk, zero otherwise
+; (only if A=0 is returned)
+;
+; Media IDs are:
+; F0h: 3.5" Double Sided, 80 tracks per side, 18 sectors per track (1.44MB)
+; F8h: 3.5" Single sided, 80 tracks per side, 9 sectors per track (360K)
+; F9h: 3.5" Double sided, 80 tracks per side, 9 sectors per track (720K)
+; FAh: 5.25" Single sided, 80 tracks per side, 8 sectors per track (320K)
+; FBh: 3.5" Double sided, 80 tracks per side, 8 sectors per track (640K)
+; FCh: 5.25" Single sided, 40 tracks per side, 9 sectors per track (180K)
+; FDh: 5.25" Double sided, 40 tracks per side, 9 sectors per track (360K)
+; FEh: 5.25" Single sided, 40 tracks per side, 8 sectors per track (160K)
+; FFh: 5.25" Double sided, 40 tracks per side, 8 sectors per track (320K)
+
+DEV_FORMAT:
+ ld a,IFORM
+ ret
+
+
+;-----------------------------------------------------------------------------
+;
+; Execute direct command on a device
+;
+;Input: A = Device number, 1 to 7
+; B = Logical unit number, 1 to 7 (if applicable)
+; HL = Address of input buffer
+; DE = Address of output buffer, 0 if not necessary
+;Output: Output buffer appropriately filled (if applicable)
+; A = Error code:
+; 0: Ok
+; 1: Invalid device number or logical unit number,
+; or device not ready
+; 2: Invalid or unknown command
+; 3: Insufficient output buffer space
+; 4-15: Reserved
+; 16-255: Device specific error codes
+;
+; The first two bytes of the input and output buffers must contain the size
+; of the buffer, not incuding the size bytes themselves.
+; For example, if 16 bytes are needed for a buffer, then 18 bytes must
+; be allocated, and the first two bytes of the buffer must be 16, 0.
+
+DEV_CMD:
+ ld a,2
+ ret
+;=====
+;===== END of DEVICE-BASED specific routines
+;=====
+
+;-----------------------------------------------------------------------------
+; Obtain slot work area (32 bytes) on SLTWRK
+; In: A = 0 Slot 1, A= 1 slot 2
+; Output: IX = Work area address
+;-----------------------------------------------------------------------------
+GETWRK:
+ push af
+ push bc
+ push de
+ push hl
+
+ call GetSlot
+ ld b,a
+ rrca
+ rrca
+ rrca
+ and %01100000
+ ld c,a ;C = Slot * 32
+ ;ld a,b
+ ;rlca
+ ;and %00011000 ;A = Subslot * 8
+ ;or c
+ ;ld c,a
+ ld b,0
+ ld hl,SLTWRK
+ add hl,bc
+
+ push hl
+ pop ix
+
+ pop hl
+ pop de
+ pop bc
+ pop af
+ or a
+ ret z ; Slot 1
+ inc ix ; Slot 2
+ ret
+
+;---------------------------------------------------------------------------
+; Get slot
+;---------------------------------------------------------------------------
+GetSlot:
+ in a,(#a8);call RSLREG
+ rrca
+ rrca
+ and 3
+ ld c, a
+ ld b, 0
+ ld hl, EXPTBL
+ add hl, bc
+ ld a, (hl)
+ and 80h
+ or c
+ ld c, a
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+ ld a, (hl)
+ and 0Ch
+ or c
+ ret
+;-----------------------------------------------------------------------------
+; Set SD control area
+;-----------------------------------------------------------------------------
+SD_ON:
+ push af
+ ld a,#40
+ ld (#6000),a ;Switch bank to SD control area
+ pop af
+ ret
+
+SD_OFF:
+ push af
+ ld a,7 * 2
+ ld (#6000),a ;Restore kernel
+ pop af
+ ret
+
+;-----------------------------------------------------------------------------
+; SD initialize: set to SPI mode
+; Out: Cy = Timeout
+; NZ = Error
+;
+; Z = Ok
+; E = 0 MMC
+; E = 1 SDSC 1.x
+; E = 2 SDSC 2.0 or higher
+; E = 3 SDHC 2.0 or higher
+;-----------------------------------------------------------------------------
+InitSD:
+ call InitSD0
+ ret c ; Timeout (card removed or damaged?)
+ ret nz ; Command error
+
+ ;call GETWRK ; Ya deber�a tener en IX el workarea
+
+ res BIT_SDHC,(ix+STATUS) ; Set SDSC as default
+
+ ld a,CARD_SDHC ; Is a SDHC card?
+ cp e
+ jr nz,.notSDHC
+
+ set BIT_SDHC,(ix+STATUS) ; set SDHC flag
+
+.notSDHC:
+ set BIT_SD_CHG,(ix+STATUS) ; SD Card has changed
+ xor a
+ ret
+
+InitSD0:
+ ld b,10 ; Dummy cycle > 76 clocks
+InitSD1:
+ ld a,(#5000) ; Quitamos /CS a la tarjeta
+ djnz InitSD1
+
+ call SD_CMD
+ db #40,0,0,0,0,#95 ; CMD0: Reset
+
+ ;call SD_INIT ; CMD0: Reset & SPI. Hay que hacerlo de forma especial porque sin o falla en el FS-A1 (!?)
+
+ ld e,#89 ; Debug error code
+ ret c ;response timeout
+ and 0f3h ;F7=>F3h Changed to support Nokia
+ cp 01h
+ ld e,#88 ; Debug error code
+ ret nz
+
+InitSD2:
+ call SD_CMD
+ db #48,0,0,#01,#aa,#87 ; CMD8
+ ld e,#87 ; Debug error code
+ ret c
+ cp 1
+ jr nz,InitSD3 ; SD V1.X or MMC
+
+ ex de,hl
+ ld e,#86 ; Debug error code
+ ld a,(hl)
+ nop
+ ld a,(hl)
+ nop
+ ld a,(hl)
+ and #f
+ cp 1
+ ret nz
+ ld a,(hl)
+ cp #aa
+ ret nz ; Wrong voltage range
+
+InitSD2loop:
+ call SD_CMD
+ db #77,0,0,0,0,#95 ; CMD55
+ ret c
+
+ cp 1
+ ld e,#85 ; Debug error code
+ ret nz
+
+ call SD_CMD
+ db #69,#40,0,0,0,#95 ; ACMD41 (HCS = 1)
+
+ ld e,#84 ; Debug error code
+ ret c
+
+ and 1
+ cp 1
+ jr z,InitSD2loop
+
+ call SD_CMD
+ db #7a,#00,0,0,0,#95 ; CMD58
+
+ ld e,#83 ; Debug error code
+ ret c
+
+ ld e,#82 ; Debug error code
+ ;or a
+ ;ret nz
+ ex de,hl
+ ld a,(hl) ;CSS 32 bits
+ cp (hl)
+ cp (hl)
+ cp (hl)
+ bit 6,a ; bit 30
+
+ ld e,CARD_SD2X
+ jr z,NOT_SDHC
+ inc e
+NOT_SDHC:
+ xor a
+ ret
+
+InitSD3:
+ call SD_CMD
+ db #77,#00,0,0,0,#95
+ ret c
+
+ bit 2,a
+ jr nz,MMC_FOUND
+
+ cp 1
+ ld e,#92 ; Debug error code
+ ret nz
+
+ call SD_CMD
+ db #69,#00,0,0,0,#95
+ ld e,#93 ; Debug error code
+ ret c
+
+ bit 2,a
+ jr nz,MMC_FOUND
+
+ bit 0,a
+ jr nz,InitSD3
+
+ xor a
+ ld e,CARD_SD1X ; SD card v1.x
+ ret
+
+MMC_FOUND:
+ call SD_CMD
+ db #41,#00,0,0,0,#95
+ ret c ;response timeout
+
+ cp 01h
+ jr z,InitSD3
+
+ ;call SetBlockLen
+ ld e,CARD_MMC ; SD 1.x
+ or a ; z=1: OK z=0: error
+ ret
+
+;-----------------------------------------------------------------------------
+; Inicializa la SD y pone el modo SPI.
+; Si no se hace as� falla en el FS-A1.
+; Aparentemente, si se escribe el CRC (#95) desde un registro falla.
+;-----------------------------------------------------------------------------
+SD_INIT:
+ ld hl,#4000
+ ld a,(hl) ;dummy cycle 8 clocks
+ nop ; [SD_1]
+ nop
+ ld (hl),#40 ;command
+ nop
+ ld (hl),0 ;sector(H)
+ nop
+ ld (hl),0 ;sector(M)
+ nop
+ ld (hl),0 ;sector(L)
+ nop
+ ld (hl),0 ;sector(0)
+ nop
+ ld (hl),#95 ;CRC
+
+ ld a,(hl) ; CRC
+ ld a,(hl) ; CRC
+
+ ld bc,#10
+.wait: ld a,(hl)
+ cp #ff
+ ccf
+ ret nc
+
+ djnz .wait
+
+ scf ;timeout error
+ ret
+;-----------------------------------------------------------------------------
+; In:
+; (DE) = Sector number, 4 bytes
+; Out:
+; BCDE = Sector number
+;
+; Modify:
+;-----------------------------------------------------------------------------
+GetSector:
+ push de
+ exx
+ pop hl
+
+ ;ld a,(ix+CARD_TYPE)
+ ;cp CARD_SDHC
+ bit BIT_SDHC,(ix+STATUS)
+ jr z,GetSector2 ; Not an SDHC.
+
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ inc hl
+ ld c,(hl)
+ inc hl
+ ld b,(hl)
+ ret
+
+GetSector2:
+ ; Convert sector number to byte offset (sector * 512)
+ ld e,0 ; Address 0
+ ld d,(hl) ; Address 1
+ inc hl
+ ld c,(hl) ; Address 2
+ inc hl
+ ld b,(hl) ; Address 3
+
+ sla d
+ rl c
+ rl b ; Address * 2
+ ret
+
+;-----------------------------------------------------------------------------
+; SD / MMC Access routine
+; Input:
+; A = Command
+; BCDE = Access address
+;
+; Output: Cy = 0 Z=1 A=0 Successful
+; Cy = 1 Z=0 A=Error code
+;-----------------------------------------------------------------------------
+MMCCMD:
+ ld hl,#4000
+ ld l,(hl) ;dummy cycle 8 clocks
+ nop ; [SD_1]
+ nop
+ ld (hl),a ;command
+ nop
+ ld (hl),b ;sector(byte 3)
+ nop
+ ld (hl),c ;sector(byte 2)
+ nop
+ ld (hl),d ;sector(byte 1)
+ nop
+ ld (hl),e ;sector(byte 0)
+ nop
+ ld (hl),#95 ;CRC
+
+ ld a,(hl) ; CRC
+ ld a,(hl) ; CRC
+
+ ld l,#00 ; BC=#10? B=0
+CMD_L1:
+ ld a,(hl)
+ cp #ff
+ ccf
+ ret nc
+
+ dec l
+ jr nz,CMD_L1
+
+ scf ;timeout error
+ ret
+
+
+;-----------------------------------------------------------------------------
+; Sends a command to SD card
+; Modify: hl, bc, de, af
+; C = Error
+;-----------------------------------------------------------------------------
+SD_CMD:
+ ex (sp),hl
+ ld de,#4000
+ ld a,(de) ;dummy cycle 8 clocks
+ nop ; [SD_1]
+ nop
+ ldi ;command
+ ldi ;param 31-24
+ ldi ;param 23-16
+ ldi ;param 15-8
+ ldi ;param 7-0
+ ldi ;CRC
+
+ ex (sp),hl
+ ld a,(de) ; CRC
+ ld a,(de) ; CRC
+
+ ld b,0
+SD_CMD2:
+ ld a,(de)
+ cp #ff ; Aqu� se podr�a mirar solo el bit 7? 0=ready
+ ccf
+ ret nc
+
+ djnz SD_CMD2
+
+ scf ;timeout error
+ ret
+
+
+;-----------------------------------------------------------------------------
+; Read sectors
+; B = Number of sectors to read
+; (DE) = First sector number to read
+; HL = destination address for the transfer
+;-----------------------------------------------------------------------------
+ReadSD:
+ ld c,2
+ReadSD2:
+ call GetSector
+
+ ld a,#40 + 18 ; CMD18: READ_MULTIPLE_BLOCK
+ call MMCCMD
+ exx
+ jr c,.timeout ; Timeout
+
+ or a
+ jr nz,.error2 ;Cy=0 A=02
+
+ ex de,hl ;DE = Destination address
+ ld a,DATA_TOKEN ;start data token
+ ld l,b
+ ;ld c,0
+.loop:
+ ;ld b,2
+ ld h,#40
+.wait:
+ cp (hl) ;start data token ?
+ jr nz,.wait
+
+ call transfer
+
+ cp (hl) ;CRC (dummy)
+ cp (hl) ;CRC (dummy)
+ dec l ;Decrement sectors to read
+ jp nz,.loop
+
+ ld a,#40 + 12 ;CMD12 / stop multiblock read
+ call MMCCMD
+
+ ex de,hl
+ xor a ;A=00 Cy=0 Successful
+ ret
+ ;************************************************ STOP MULTIPLE BLOCK READ *************
+.error:
+ ld a,#40 + 12 ;CMD12 / stop multiblock read
+ call MMCCMD
+ scf ;Cy=1
+.exit:
+ ld a,NRDY ;error code
+ ret
+
+.error2:
+.timeout:
+ push bc
+ push de
+ push hl ; Destination address
+ call InitSD
+ pop hl
+ pop de
+ pop bc
+ jr nz,.error ;response error
+ jr c,.exit ;command error
+
+ dec c
+ jp nz,ReadSD2
+
+ ld a,DISK ;Other error [SD_1]
+ scf ;Card inserted or removed
+ ret
+
+
+;-----------------------------------------------------------------------------
+; Write sectors
+; B = Number of sectors to write
+; (DE) = First sector number to write
+; HL = source address for the transfer
+; Out:
+; Cy : 1 = Error
+;-----------------------------------------------------------------------------
+
+WriteSD:
+ push hl
+ call GetSector ;BCDE = Sector number
+ exx
+ pop hl
+.try:
+ ld a,b
+ dec a
+ jp z,Write1 ; Only 1 sector
+
+ exx ; BCDE = access address
+ ld a,#40 + 25 ; CMD25: WRITE_MULTIPLE_BLOCK
+ call MMCCMD
+ exx
+ jr c,.timeout
+
+ or a
+ ld a,2
+ jr nz,.exit ;command error
+
+ ld a,(#4000) ;dummy
+
+.loop:
+
+ ld de,#4000
+
+ ld a,#FC
+ ld (de),a
+
+ push bc
+ ; Transfer data
+ call transfer
+
+ ex (sp),hl
+ ld a,(de) ;CRC (dummy)
+ ex (sp),hl
+ ld a,(de) ;CRC (dummy)
+
+ pop bc
+
+ ld a,(de) ; Dummy
+
+ ld a,(de) ; Response
+ and #1f
+ cp #5
+ ;ld a,3
+ jp nz,.cancel ;response error
+
+ ;ACMD22 can be used to find the number of well written write blocks
+ call WaitBusy
+
+ ;ld b,e
+ djnz .loop
+
+ ld a,(de) ; Dummy
+ ld a,(de) ; Dummy
+
+ ld a,#fd ; Stop transmission
+ ld (de),a
+ nop
+ nop ; Extra wait for FS-A1
+ ld a,(de) ; Dummy
+ ld a,(de) ; Dummy
+
+ call WaitBusy
+
+ xor a ;A=00 Cy=0 Successful operation
+ ret
+
+
+.cancel:
+ call WaitBusy
+
+ ld a,(de) ; Dummy
+ ld a,(de) ; Dummy
+
+ ld a,#fd ; Stop transmission
+ ld (de),a
+ nop
+ nop ; Extra wait for FS-A1
+ ld a,(de) ; Dummy
+ ld a,(de) ; Dummy
+
+ call WaitBusy
+.exit:
+ scf ;Cy=1
+ ;ld a,02h ;Cy=1 A=02
+ ret
+
+.timeout:
+ push bc ; Number of sector
+ push hl ; Source address
+ call InitSD
+ pop hl
+ pop bc
+
+ ld a,1
+ jr nz,.exit ;response error
+ jr c,.exit ;command error
+ jp .try
+
+;
+; Write a single sector
+;
+Write1:
+ exx ; BCDE = access address
+ ld a,#40 + 24 ; CMD24: WRITE BLOCK
+ call MMCCMD
+ exx
+ jp c,.timeout
+ or a
+ jp nz,.exit ;command error
+
+ ld de,#4000
+ ld a,(de) ;dummy
+ ld a,DATA_TOKEN ;start data token
+ ld (de),a
+
+ call transfer
+
+ ex (sp),hl
+ ld a,(de) ;CRC (dummy)
+ ex (sp),hl
+ ld a,(de) ;CRC (dummy)
+
+ ld a,(de) ;dummy
+ nop
+ ld a,(de) ;receive data response
+
+ and #1f
+ cp #05
+ jr nz,.exit ;response error
+ ;ACMD22 can be used to find the number of well written write blocks
+
+.wait:
+ ld a,(de)
+ cp #ff
+ jr nz,.wait
+
+ xor a ; Read successfully
+ ret
+
+.timeout:
+ push bc ; Number of sector
+ push hl ; Source address
+ call InitSD
+ pop hl
+ pop bc
+
+ jr z,Write1
+ jr nc,Write1
+
+.exit:
+ scf ;Cy=1
+ ret
+
+;-----------------------------------------------------------------------------
+; Wait until card is not busy
+; Modify: AF
+;-----------------------------------------------------------------------------
+WaitBusy:
+ push bc
+
+ ld bc,#8000
+.loop:
+ ld a,(#4000)
+ or a
+ jr nz,.end
+
+ dec bc
+ ld a,b
+ or c
+ jr nz,.loop ; Wait while busy
+
+ pop bc
+ scf
+ ret
+.end:
+ pop bc
+ ret
+
+
+
+;-----------------------------------------------------------------------------
+; Wait until card is ready
+; Modify: AF
+;-----------------------------------------------------------------------------
+WaitReady:
+ push bc
+ ld bc,#8000
+.loop:
+ ld a,(#4000)
+ cp #ff
+ jr z,.end
+
+ dec bc
+ ld a,b
+ or c
+ jr nz,.loop
+ scf
+.end:
+ pop bc
+ ret
+
+;-----------------------------------------------------------------------------
+; 512 LDIs a bit faster than an LDIR
+;-----------------------------------------------------------------------------
+transfer:
+ REPT 512
+ ldi
+ ENDM
+ ret
+
+ .COMMENT *
+;-----------------------------------------------------------------------------
+; Set block length
+; Cy : 1 = Error 0 = Ok
+;-----------------------------------------------------------------------------
+SetBlockLen:
+ ld b,#40+16 ; SET_BLOCKLEN
+ ld c,0
+ ld de,#2
+ call MMCCMD
+ ret c ; Timeout
+
+ xor a
+ ret
+ ;*
+
+TestCard:
+ call SD_CMD
+ db #40+16,0,0,2,0,#95
+ ret nc
+
+ call InitSD
+ ret c
+ jr z,TestCard
+ scf
+ ret
+
+
+;-----------------------------------------------------------------------------
+; Read CID register
+; Out:
+; Cy : 1 = Error 0 = Ok
+; HL : SD data registers
+;-----------------------------------------------------------------------------
+GetCID:
+ call SD_CMD
+ db #4a,0,0,0,0,#95 ; CMD10: SEND_CID
+
+ jr c,GetCID4 ; Timeout
+
+ ld hl,#4000
+ ld a,DATA_TOKEN
+ ld b,0
+GetCID2:
+ cp (hl)
+ ret z
+ djnz GetCID2
+
+ scf
+ ret
+
+GetCID4:
+ call InitSD ; Modify all registers
+ ret c
+ jr z,GetCID
+ scf
+ ret
+
+;-----------------------------------------------------------------------------
+; Get number of available sectors in the card
+; Out:
+; DEHL = Number of sectors
+; Cy : 1 = Error 0 = Ok
+;-----------------------------------------------------------------------------
+GetSectNum:
+ ;ld a,#40+9 ; SEND_CSD CMD
+ ;ld bc,0
+ ;ld de,0
+ ;call MMCCMD
+ call SD_CMD
+ db #49,#00,0,0,0,#95 ;CMD9: SEND_CSD
+ ret c ; Timeout
+
+ ld hl,#4000
+ ld a,DATA_TOKEN
+ ld b,0
+GetSectNum2:
+ cp (hl)
+ jr z,GetSectNum3
+ djnz GetSectNum2
+
+ scf
+ ret
+
+GetSectNum3:
+ ;ld de,#c000
+ ;ld bc,17
+ ;ldir ; Read CSD
+
+ bit BIT_SDHC,(ix+STATUS)
+ jr nz,GetSectNumHC ; SDHC
+
+ ;ld a,(ix+CARD_TYPE)
+ ;cp CARD_SDHC
+ ;jr z,GetSectNumHC ; SDHC
+
+ ld b,5
+ call SkipBytes
+ ld a,(hl)
+ and %1111 ; READ_BL_LEN
+ ld c,a
+
+ ld a,(hl)
+ and %11 ; C_SIZE 11-10
+ ld d,a
+ ld e,(hl)
+ nop
+ ld a,(hl)
+ sla a
+ rl e
+ rl d
+ sla a
+ rl e
+ rl d
+ ; DE=C_SIZE
+
+
+ ld a,(hl)
+ and %11 ; C_SIZE_MULT 2-1
+ ld b,(hl)
+ sla b
+ rl a
+ ;A=C_SIZE_MULT
+
+ add a,c
+ sub 7 ; 512 = Sector size
+ call GetExp ; HL = Factor de multiplicacion
+
+ ld b,h
+ ld c,l ; BC = HL
+
+ inc de ; C_SIZE + 1
+
+ call Mul16 ; Numero de sectores = DEHL
+
+ ld b,5
+ call SkipBytes
+
+ or a ; NC = Ok
+ ret
+
+GetSectNumHC:
+ ld b,7
+ call SkipBytes
+ ld a,(hl)
+ and %00111111
+ ld c,a ; C_SIZE 21-16
+
+ ld d,(hl) ; C_SIZE 15-8
+ nop
+ ld e,(hl) ; C_SIZE 7-0
+
+ ld b,6
+ call SkipBytes
+
+ inc de
+ ld h,c
+ ld l,d
+ ld d,e
+ ld e,0
+
+ sla d
+ rl l
+ rl h
+
+ sla d
+ rl l
+ rl h
+
+ ex de,hl
+ or a
+ ret
+
+;-----------------------------------------------------------------------------
+; Skip B bytes from SD response
+;-----------------------------------------------------------------------------
+SkipBytes:
+ push af
+.loop:
+ ld a,(#4000)
+ djnz .loop
+ pop af
+ ret
+
+;-----------------------------------------------------------------------------
+; 2^A
+;-----------------------------------------------------------------------------
+GetExp:
+ ld hl,1
+ or a
+ ret z
+GetExp2:
+ sla l
+ rl h
+ dec a
+ ret z
+ jr GetExp2
+
+;-----------------------------------------------------------------------------
+; Multiplication 16 bits
+; DEHL = BC * DE
+;-----------------------------------------------------------------------------
+Mul16:
+ ld hl,0
+ ld a,16
+
+Mul16Loop:
+ add hl,hl
+ rl e
+ rl d
+ jp nc,NoMul16
+
+ add hl,bc
+ jp nc,NoMul16
+
+ inc de
+NoMul16:
+ dec a
+ jp nz,Mul16Loop
+
+ ret
+
+;-----------------------------------------------------------------------------
+; Print a zero-terminated string on screen
+; Input: DE = String address
+;-----------------------------------------------------------------------------
+PRINT:
+ ld a,(de)
+ or a
+ ret z
+
+ call CHPUT
+ inc de
+ jr PRINT
+
+
+;-----------------------------------------------------------------------------
+; Includes
+;-----------------------------------------------------------------------------
+ include "romdisk.asm"
+
+;-----------------------------------------------------------------------------
+; Strings
+;-----------------------------------------------------------------------------
+
+VERSION_STRING macro v_main, v_sub
+db "Version &v_main&.&v_sub&",13,10
+endm
+
+TXT_INFO:
+ db "MegaFlashROM SCC+ SD driver",13,10
+ VERSION_STRING %DRIVER_VERSION,%DRIVER_SUBVERSION
+ db "(c) Manuel Pazos 2013",13,10
+TXT_EMPTY:
+ db 13,10,0
+
+TXT_INIT:
+ db "SD card slot ",0
+
+TXT_ROMDSKOK:
+ db "ROM disk found.",13,10,0
+
+TXT_MMC:
+ db "MMC",13,10,0
+TXT_SD1x:
+ db "SDSC 1.x",13,10,0
+TXT_SD2x:
+ db "SDSC 2.x",13,10,0
+TXT_SDHC:
+ db "SDHC",13,10,0
+
+IDX_TYPE:
+ dw TXT_MMC
+ dw TXT_SD1x
+ dw TXT_SD2x
+ dw TXT_SDHC
+
+;-----------------------------------------------------------------------------
+; End of the driver code
+;-----------------------------------------------------------------------------
+DRV_END:
+
+ ;ds 3FD0h-(DRV_END-DRV_START)
+
+ end
diff --git a/source/kernel/drivers/MegaFlashRomSD/recovery_header.asm b/source/kernel/drivers/MegaFlashRomSD/recovery_header.asm
new file mode 100644
index 00000000..dcef561b
--- /dev/null
+++ b/source/kernel/drivers/MegaFlashRomSD/recovery_header.asm
@@ -0,0 +1,18 @@
+;-----------------------------------------------------------------------------
+;
+; Header for the kernel recovery file.
+; It's aheader that acts as an identifier and tells the size of the kernel.
+; This file has to be saved in the SD card after formatting it,
+; then it's loaded from the recovery menu.
+;
+; Manuel Pazos 13/01/2013
+;
+;-----------------------------------------------------------------------------
+
+ org 0
+ ;----------------
+ db "MFRSD KERNEL 1.0"
+ db 128/8 ;Size of the kernel ROM file in 8K blocks
+ ds 512-$,#ff
+
+ ;The full Nextor kernel ROM with the MFRSD driver goes here
diff --git a/source/kernel/drivers/MegaFlashRomSD/romdisk.asm b/source/kernel/drivers/MegaFlashRomSD/romdisk.asm
new file mode 100644
index 00000000..8123ee49
--- /dev/null
+++ b/source/kernel/drivers/MegaFlashRomSD/romdisk.asm
@@ -0,0 +1,335 @@
+;-----------------------------------------------------------------------------
+; ROM Disk driver
+;
+; 2013/30/01 Manuel Pazos
+;-----------------------------------------------------------------------------
+
+BANK4 equ #6000 ; address to select megarom bank in #4000-#5FFF
+BANK6 equ #6800 ; address to select megarom bank in #6000-#7FFF
+
+DSK_BANK equ #10+#80 ; Bank number of DSK
+DRIVER_BANK equ #07*2 ; Device driver bank number
+
+UPB_SSZ equ 0Bh
+UPB_SFAT equ 16h
+UPB_NDIR equ 11h
+
+;-----------------------------------------------------------------------------
+; Check if there is a DSK installed as ROM disk
+; Out: Z = Available, NZ = Not available
+;-----------------------------------------------------------------------------
+RomDiskCheck:
+ di
+ ld a,DSK_BANK
+ ld (BANK4),a
+
+ ld hl,#4000
+ ld de,UPB_SSZ
+ add hl,de
+ ld d,(hl) ;Sector size must always
+ inc hl ; be 200h.
+ ld a,(hl)
+ inc hl
+ sub 2
+ or d
+ jp nz,upb_not_found
+ ;
+ or (hl)
+ jp z,upb_not_found ;Sectors/cluster must be
+ neg ; a non-zero power of 2.
+ and (hl)
+ cp (hl)
+ inc hl
+ jp nz,upb_not_found
+ ;
+ inc hl ;Ignore number of reserved
+ inc hl ; sectors
+ ;
+ ld a,(hl)
+ dec a ;Number of FATs must be
+ cp 7 ; 1...7 (nobody has more
+ jp nc,upb_not_found ; than 7 copies of the FAT!)
+ ;
+ inc hl ;Zero directory entries
+ ld a,(hl) ;means FAT32 drive.
+ inc hl
+ or (hl)
+ jr z,upb_not_found
+
+ ld de,UPB_SFAT-(UPB_NDIR+1) ;Ignore "total sectors"
+ add hl,de ; and "media byte".
+
+ ld e,(hl) ;Number of sectors per
+ inc hl ; FAT less than 256.
+ ld d,(hl)
+ dec de
+ inc d
+ dec d
+ jr nz,upb_not_found
+
+upb_found:
+ ld a,DRIVER_BANK
+ ld (BANK4),a
+ xor a
+ ret ; if UPB was OK.
+
+upb_not_found: ;If anything was wrong with
+ ld a,DRIVER_BANK
+ ld (BANK4),a
+ or h ; the UPB then return with
+ ret ; Z-flag clear.
+
+;-----------------------------------------------------------------------------
+; Read sectors
+; B = Number of sectors to read
+; (DE) = First sector number to read
+; HL = destination address for the transfer
+;-----------------------------------------------------------------------------
+RomDiskRead:
+ di
+ ld a,(de)
+ ld c,a
+ inc de
+ ld a,(de)
+ ld d,a
+ ld e,c ; DE = Sector number.
+ ; Last two bytes of sector number are ignored.
+ ; (720KB disk = 1440 sectors)
+.loop:
+ push bc
+ push de
+ push hl
+
+ call .readSector
+
+ pop hl
+ inc h
+ inc h
+ pop de
+ inc de
+ pop bc
+ djnz .loop
+
+ ld a,DRIVER_BANK
+ ld (BANK4),a
+ ei
+
+ xor a ; Ok
+ ret
+
+.readSector:
+ push hl
+ ld c,e
+
+ srl d
+ rr e
+ srl d
+ rr e
+ srl d
+ rr e
+ srl d
+ rr e ; Sector / 16 = banco de 8k que lo contiene
+ ld a,e
+ add a,DSK_BANK ; Omite las paginas usadas por Nextor
+ ld (BANK4),a ; Cambia la p�gina de la ROM
+
+ ld a,c
+ and #0F
+ add a,a
+ add a,#40
+ ld h,a
+ ld l,#00
+
+ pop de ; Direcci�n de destino
+ jp transfer
+
+;-----------------------------------------------------------------------------
+;
+; Device information gathering
+;
+;Input: A = Device index 0
+; B = Information to return:
+; 0: Basic information
+; 1: Manufacturer name string
+; 2: Device name string
+; 3: Serial number string
+; HL = Pointer to a buffer in RAM
+;Output: A = Error code:
+; 0: Ok
+; 1: Device not available or invalid device index
+; 2: Information not available, or invalid information index
+; When basic information is requested,
+; buffer filled with the following information:
+;
+;+0 (1): Numer of logical units, from 1 to 7. 1 IF the device has no logical
+; units (which is functionally equivalent to having only one).
+;+1 (1): Device flags, always zero in Alpha 2b.
+;
+;-----------------------------------------------------------------------------
+RomDiskInfo:
+ call GETWRK
+ bit BIT_ROM_DSK,(IX+0) ; Is ROM disk available?
+ jr nz,.ok
+
+ ld a,1 ; Device not available
+ ret
+.ok:
+ djnz .INFO2
+ ; 1: Manufacturer name string
+ ld de,TXT_MANU
+ jr .end
+
+
+.INFO2:
+ djnz .INFO3
+ ; 2: Device name string
+ ld de,TXT_DEV
+ jr .end
+
+.INFO3:
+ djnz .INFO0
+ ; 3: Serial number string
+ ld de,TXT_SERIAL
+ jr .end
+
+.INFO0:
+ ; 0: Basic information
+ ld (hl),1 ; Number of logical units
+ inc hl
+ ld (hl),0 ; Flags: always zero in Alpha 2b.
+ xor a
+ ret
+
+.end:
+ ex de,hl
+ ld bc,16+1
+ ldir
+
+ xor a
+ ret
+
+;-----------------------------------------------------------------------------
+;
+; Obtain device status
+;
+;Input: A = Device index, 1 to 7
+; B = Logical unit number, 1 to 7
+; 0 to return the status of the device itself.
+;Output: A = Status for the specified logical unit,
+; or for the whole device IF 0 was specified:
+; 0: The device or logical unit is not available, or the
+; device or logical unit number supplied is invalid.
+; 1: The device or logical unit is available and has not
+; changed since the last status request.
+; 2: The device or logical unit is available and has changed
+; since the last status request
+; (for devices, the device has been unplugged and a
+; different device has been plugged which has been
+; assigned the same device index; for logical units,
+; the media has been changed).
+; 3: The device or logical unit is available, but it is not
+; possible to determine whether it has been changed
+; or not since the last status request.
+;
+; Devices not supporting hot-plugging must always return status value 1.
+; Non removable logical units may return values 0 and 1.
+;-----------------------------------------------------------------------------
+RomDiskStatus:
+ call GETWRK
+ bit BIT_ROM_DSK,(IX+0) ; Is ROM disk available?
+ jr z,.error
+
+ dec b
+ jr nz,.error
+
+ ld a,1 ; Device available and has not changed
+ ret
+.error:
+ xor a ; Device not available
+ ret
+
+;-----------------------------------------------------------------------------
+;
+; Obtain logical unit information
+;
+;Input: A = Device index, 1 to 7
+; B = Logical unit number, 1 to 7
+; HL = Pointer to buffer in RAM.
+;Output: A = 0: Ok, buffer filled with information.
+; 1: Error, device or logical unit not available,
+; or device index or logical unit number invalid.
+; On success, buffer filled with the following information:
+;
+;+0 (1): Medium type:
+; 0: Block device
+; 1: CD or DVD reader or recorder
+; 2-254: Unused. Additional codes may be defined in the future.
+; 255: Other
+;+1 (2): Sector size, 0 IF this information does not apply or is
+; not available.
+;+3 (4): Total number of available sectors.
+; 0 IF this information does not apply or is not available.
+;+7 (1): Flags:
+; bit 0: 1 IF the medium is removable.
+; bit 1: 1 IF the medium is read only. A medium that can dinamically
+; be write protected or write enabled is not considered
+; to be read-only.
+; bit 2: 1 IF the LUN is a floppy disk drive.
+;+8 (2): Number of cylinders
+;+10 (1): Number of heads
+;+11 (1): Number of sectors per track
+;
+; Number of cylinders, heads and sectors apply to hard disks only.
+; For other types of device, these fields must be zero.
+;-----------------------------------------------------------------------------
+RomDiskLUN_INFO:
+ dec b
+ jp nz,LUN_ERROR
+
+ call GETWRK
+ bit BIT_ROM_DSK,(IX+0) ; Is ROM disk available?
+ jr z,.error
+
+ ld (hl),0 ; +0: Medium type = Block device
+ inc hl
+
+ ld (hl),0 ; +1: Sector size = #200
+ inc hl
+ ld (hl),2
+ inc hl
+
+ ld bc,1440 ; Number of sector on a 720K FDD
+ ld (hl),c ; +3: Total number of sectors
+ inc hl
+ ld (hl),b
+ inc hl
+ ld (hl),0
+ inc hl
+ ld (hl),0
+ inc hl
+
+ ld (hl),%011 ; +7: Flags ;!!!!!!!
+ inc hl
+
+ ld (hl),0 ; +8 Cylinders
+ inc hl
+ ld (hl),0
+ inc hl
+
+ ld (hl),0 ; +10: Heads
+ inc hl
+
+ ld (hl),0 ; +11: Sectors per tracks
+
+ xor a ; Ok, buffer filled with information.
+ ret
+
+.error:
+ ld a,1 ; Error
+ ret
+;-----------------------------------------------------------------------------
+; Texts
+;-----------------------------------------------------------------------------
+TXT_MANU: db "Manuel Pazos ",0
+TXT_DEV: db "MFRSD ROM Disk ",0
+TXT_SERIAL: db "00-00-00-01 ",0
\ No newline at end of file
diff --git a/source/kernel/drivers/StandaloneASCII16/CPM32.EXE b/source/kernel/drivers/StandaloneASCII16/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/drivers/StandaloneASCII16/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII16/L80.CPM b/source/kernel/drivers/StandaloneASCII16/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/drivers/StandaloneASCII16/L80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII16/LIB80.CPM b/source/kernel/drivers/StandaloneASCII16/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/drivers/StandaloneASCII16/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII16/M80.CPM b/source/kernel/drivers/StandaloneASCII16/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/drivers/StandaloneASCII16/M80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII16/chgbnk.mac b/source/kernel/drivers/StandaloneASCII16/chgbnk.mac
index 2821de4b..38cb0b6a 100644
--- a/source/kernel/drivers/StandaloneASCII16/chgbnk.mac
+++ b/source/kernel/drivers/StandaloneASCII16/chgbnk.mac
@@ -29,6 +29,8 @@ BNKID equ 40FFh ;Where Bank ID is stored
;bank bit 1 -> register bit 6
;bank bit 2 -> register bit 5
+ org 7FD0h
+
CHGBNK:
ld (BNKREG),a
diff --git a/source/kernel/drivers/StandaloneASCII8/CPM32.EXE b/source/kernel/drivers/StandaloneASCII8/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/drivers/StandaloneASCII8/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII8/L80.CPM b/source/kernel/drivers/StandaloneASCII8/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/drivers/StandaloneASCII8/L80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII8/LIB80.CPM b/source/kernel/drivers/StandaloneASCII8/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/drivers/StandaloneASCII8/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII8/M80.CPM b/source/kernel/drivers/StandaloneASCII8/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/drivers/StandaloneASCII8/M80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/StandaloneASCII8/chgbnk.mac b/source/kernel/drivers/StandaloneASCII8/chgbnk.mac
index 8f3a1a79..a565fdd5 100644
--- a/source/kernel/drivers/StandaloneASCII8/chgbnk.mac
+++ b/source/kernel/drivers/StandaloneASCII8/chgbnk.mac
@@ -29,6 +29,8 @@ BNKID equ 40FFh ;Where Bank ID is stored
;bank bit 1 -> register bit 6
;bank bit 2 -> register bit 5
+ org 7FD0h
+
CHGBNK:
db 0FFh ;Header for MKNEXROM
diff --git a/source/kernel/drivers/StandaloneASCII8/driver.mac b/source/kernel/drivers/StandaloneASCII8/driver.mac
index bb61e84b..81962fe8 100644
--- a/source/kernel/drivers/StandaloneASCII8/driver.mac
+++ b/source/kernel/drivers/StandaloneASCII8/driver.mac
@@ -10,8 +10,8 @@
;-----------------------------------------------------------------------------
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE ../../macros.inc
+ INCLUDE ../../const.inc
;
; Routines available on kernel page 0
@@ -76,6 +76,8 @@ single_double equ 7420h
; (must be available in all banks actually).
+ org 4100h
+
;***************************
;*** DUMMY DRIVER CODE ***
;***************************
diff --git a/source/kernel/drivers/SunriseIDE/CPM32.EXE b/source/kernel/drivers/SunriseIDE/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/kernel/drivers/SunriseIDE/CPM32.EXE and /dev/null differ
diff --git a/source/kernel/drivers/SunriseIDE/L80.CPM b/source/kernel/drivers/SunriseIDE/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/drivers/SunriseIDE/L80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/SunriseIDE/LIB80.CPM b/source/kernel/drivers/SunriseIDE/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/drivers/SunriseIDE/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/SunriseIDE/M80.CPM b/source/kernel/drivers/SunriseIDE/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/drivers/SunriseIDE/M80.CPM and /dev/null differ
diff --git a/source/kernel/drivers/SunriseIDE/chgbnk.mac b/source/kernel/drivers/SunriseIDE/chgbnk.mac
index 72a1ab8b..6f9e3bda 100644
--- a/source/kernel/drivers/SunriseIDE/chgbnk.mac
+++ b/source/kernel/drivers/SunriseIDE/chgbnk.mac
@@ -31,6 +31,8 @@ BNKID equ 40FFh ;Where Bank ID is stored
;bank bit 3 -> register bit 4
;bank bit 2 -> register bit 3
+ org 7FD0h
+
CHGBNK:
push bc
srl a
diff --git a/source/kernel/drivers/SunriseIDE/driver.mac b/source/kernel/drivers/SunriseIDE/driver.mac
index 26933b18..5728e107 100644
--- a/source/kernel/drivers/SunriseIDE/driver.mac
+++ b/source/kernel/drivers/SunriseIDE/driver.mac
@@ -3,11 +3,17 @@
; Version Beta 5 by Piter Punk
; Based on version 0.1 by Konamiman
+ org 4100h
+
DRV_START:
-TESTADD equ 0F3F5h
+ ifdef MASTER_ONLY
+ .print1 Sunrise IDE - MASTER ONLY driver
+ else
+ .print1 Sunrise IDE - MASTER AND SLAVE driver
+ endif
-MASTER_ONLY equ 0
+TESTADD equ 0F3F5h
;-----------------------------------------------------------------------------
;
@@ -409,7 +415,7 @@ WAIT_RESET_END:
ld (ix),a
MASTER_CHECK1_END:
-if MASTER_ONLY eq 0
+ifndef MASTER_ONLY
ld a,46 ;Print dot
call CHPUT
@@ -515,7 +521,7 @@ NODEV_MASTER:
OK_MASTER:
-if MASTER_ONLY eq 0
+ifndef MASTER_ONLY
;--- Get info and show the name for the SLAVE
@@ -604,7 +610,7 @@ INIT_NO_DEV:
ld de,NODEVS_S
call PRINT
-if MASTER_ONLY eq 0
+ifndef MASTER_ONLY
ld de,SLAVE_S
call PRINT
@@ -1689,7 +1695,7 @@ INFO_S:
db "Sunrise IDE driver v"
db VER_MAIN+"0",".",VER_SEC+"0",".",VER_REV+"0",13,10
-if MASTER_ONLY eq 1
+ifdef MASTER_ONLY
db "Master device only edition",13,10
@@ -1706,7 +1712,7 @@ NODEVS_S:
MASTER_S:
db "Master device: ",0
-if MASTER_ONLY eq 0
+ifndef MASTER_ONLY
SLAVE_S:
db "Slave device: ",0
diff --git a/source/kernel/drivers/SunriseIDE/sunride.asm b/source/kernel/drivers/SunriseIDE/sunride.asm
index 41d17871..23cb6bdb 100644
--- a/source/kernel/drivers/SunriseIDE/sunride.asm
+++ b/source/kernel/drivers/SunriseIDE/sunride.asm
@@ -5,11 +5,13 @@
; By Piter Punk
; By FRS
+ ;MASTER_ONLY constant must be defined externally to generate the master-only variant.
+
org 4000h
ds 4100h-$,0 ; DRV_START must be at 4100h
DRV_START:
-MASTER_ONLY equ 0
+ .RELAB
TESTADD equ 0F3F5h
@@ -44,7 +46,7 @@ VER_REV equ 7
;Miscellaneous configuration
- DEFINE PIOMODE3 ; Configure devices to work on PIO MODE 3
+PIOMODE3 equ 0FFFFh ; Configure devices to work on PIO MODE 3
;This is a very barebones driver. It has important limitations:
@@ -119,19 +121,21 @@ M_SRST equ 100b ;(1 SHL SRST)
; IDE commands
-ATACMD:
+module ATACMD
.PRDSECTRT equ #20
.PWRSECTRT equ #30
.DEVDIAG equ #90
.IDENTIFY equ #EC
.SETFEATURES equ #EF
+endmod
-ATAPICMD:
+module ATAPICMD
.RESET equ #08
.PACKET equ #A0
.IDENTPACKET equ #A1
+endmod
-PACKETCMD:
+module PACKETCMD
.RQSENSE equ #03 ;
.RDCAPACITY equ #25 ; Read the media capacity
.READ10 equ #28 ; Read sectors (16bit)
@@ -139,6 +143,7 @@ PACKETCMD:
.WRITE10 equ #2A ; Write sectors (16bit)
.WRITE12 equ #AA ; Write sectors (32bit)
.GTMEDIASTAT equ #DA ; Get media status
+endmod
;-----------------------------------------------------------------------------
@@ -210,50 +215,79 @@ EXPTBL equ #FCC1
; LUN type bits are always 00.
- STRUCT DEVINFO ; Contains information about a specific device
-BASE ; Offset to the base of the data structure
-t321D db
-t7654 db
+;--- These macros allow defining a struct with fields of a given size,
+; a constant will be generated for each field with the format "structname.fieldname".
+; They will also have a BASE, FIELD and _SIZE fields.
+
+;* Macro start
+
+struct_start macro name
+module name
+root field_pointer
+field_pointer defl 0
+field BASE,0 ; Offset to the base of the data structure
+endm
+
+;* Macro end
+
+struct_end macro
+field END,0
+field _SIZE,(END-BASE)
+endmod
+endm
+
+;* Macro field
+
+field macro name,size
+name equ field_pointer
+field_pointer defl field_pointer+size
+endm
+
+
+struct_start DEVINFO ; Contains information about a specific device
+field t321D,1
+field t7654,1
;CHSRESERVED ds 2 ; Disabled to save space. 2 bytes won't be enough anyway
-SECTSIZE dw ; Sector size for this device
-pBASEWRK dw ; Cache pointer to go back to the base of the work area
- ENDS
-
- STRUCT WRKAREA
-BASE ; Offset to the base of the data structure
-BLKLEN dw ; Size of the block to be copied. ***Must be
- ; \the first element of the WRKAREA
-PCTBUFF ds 16 ; Buffer to send ATAPI PACKET commands
-LDIRHLPR ds 8 ; LDIR data transter helper routine. This is
- ; in RAM to speed up the R800 copy a lot.
-MASTER DEVINFO ; Offset to the MASTER data structure
-SLAVE DEVINFO ; Offset to the SLAVE data structure
- ; \*** It must follow the MASTER DEVINFO
- ENDS
-
- STRUCT WRKTEMP
-pDEVMSG dw ; Pointer to the text "Master:" or "Slave:"
-BUFFER ds 512 ; Buffer for the IDENTIFY info
- ENDS
+field SECTSIZE,2 ; Sector size for this device
+field pBASEWRK,2 ; Cache pointer to go back to the base of the work area
+struct_end
+
+
+struct_start WRKAREA
+field BLKLEN,2 ; Size of the block to be copied. ***Must be
+ ; \the first element of the WRKAREA
+field PCTBUFF,16 ; Buffer to send ATAPI PACKET commands
+field LDIRHLPR,8 ; LDIR data transter helper routine. This is
+ ; in RAM to speed up the R800 copy a lot.
+field MASTER,(:DEVINFO._SIZE) ; Offset to the MASTER data structure
+field SLAVE,(:DEVINFO._SIZE); Offset to the SLAVE data structure
+ ; \*** It must follow the MASTER DEVINFO
+struct_end
+
+
+struct_start WRKTEMP
+field pDEVMSG,2 ; Pointer to the text "Master:" or "Slave:"
+field BUFFER,512 ; Buffer for the IDENTIFY info
+struct_end
; ATAPI/SCSI packet structures
- STRUCT PCTRW10 ; PACKET READ10/WRITE10 structure
-OPCODE db
-OPTIONS db
-LBA dd
-GROUP db
-LENGHT dw
-CONTROL db
- ENDS
+struct_start PCTRW10 ; PACKET READ10/WRITE10 structure
+field OPCODE,1
+field OPTIONS,1
+field LBA,4
+field GROUP,1
+field LENGHT,2
+field CONTROL,1
+struct_end
- STRUCT PCTRW12 ; PACKET READ12/WRITE12 structure
-OPCODE db
-OPTIONS db
-LBA dd
-LENGHT dd
-GROUP db
-CONTROL db
- ENDS
+struct_start PCTRW12 ; PACKET READ12/WRITE12 structure
+field OPCODE,1
+field OPTIONS,1
+field LBA,4
+field LENGHT,4
+field GROUP,1
+field CONTROL,1
+struct_end
@@ -451,7 +485,7 @@ DRV_TIMI:
; get two allocated drives.)
DRV_INIT:
- ld hl,WRKAREA ; size of work area
+ ld hl,WRKAREA._SIZE ; size of work area
or a ; Clear Cy
ret z
@@ -474,7 +508,7 @@ DRV_INIT:
call INIWORK ; Initialize the work-area
call IDE_ON
-.init: ld (ix+WRKAREA.MASTER.t321D),#FE ; error: No master detected yet
+.init: ld (ix+WRKAREA.MASTER+DEVINFO.t321D),#FE ; error: No master detected yet
ld de,INIT_S ; Print "Initializing: "
call PRINT
ld a,M_DEV ; Select SLAVE
@@ -499,7 +533,7 @@ DRV_INIT:
ld a,(IDE_STATUS)
and M_ERR ; Error bit set?
jr nz,.diagchk ; on error, skip to diagnostics
- ld (ix+WRKAREA.MASTER.t321D),0 ; Clear undetected master error
+ ld (ix+WRKAREA.MASTER+DEVINFO.t321D),0 ; Clear undetected master error
.diagchk:
; Check the diagnostics and print the results
@@ -519,12 +553,12 @@ DRV_INIT:
call PRINT
; Check for DIAGNOSTICS errors
- ld a,(ix+WRKAREA.MASTER.t321D)
+ ld a,(ix+WRKAREA.MASTER+DEVINFO.t321D)
ld c,a
bit 7,a ; Any error detected by DIAGNOSE?
jr z,.detinit ; No, skip
call DIAGERRPRT ; Print the diagnostic error
- ld (ix+WRKAREA.MASTER.t321D),0 ; This device isn't available
+ ld (ix+WRKAREA.MASTER+DEVINFO.t321D),0 ; This device isn't available
; Errors 0 and 5 are critical and cannot proceed
ld a,c
and #7F ; Crop erro code
@@ -532,7 +566,7 @@ DRV_INIT:
cp 5 ; Microcontroller error on master?
jp nz,.chkslave ; No: slave can still be used safely
.critical:
- ld (ix+WRKAREA.SLAVE.t321D),0 ; No master = no slave
+ ld (ix+WRKAREA.SLAVE+DEVINFO.t321D),0 ; No master = no slave
jp DRV_INIT_END ; Finish DEV_INIT
.detinit:
@@ -540,7 +574,7 @@ DRV_INIT:
call SELDEV
call WAIT_RST ; wait until ready
jr nc,.detmaster
- ld (ix+WRKAREA.SLAVE.t321D),#80 ; Slave has an error
+ ld (ix+WRKAREA.SLAVE+DEVINFO.t321D),#80 ; Slave has an error
.detmaster:
call RESET_ALL.ataonly
@@ -550,29 +584,29 @@ DRV_INIT:
xor a ; Select MASTER
call DETDEV
pop ix
- ld a,(ix+WRKAREA.MASTER.t321D)
+ ld a,(ix+WRKAREA.MASTER+DEVINFO.t321D)
and 3 ; There can't be a slave without a master
jr z,INIT_MASTERFAIL ; Finish DEV_INIT
.chkslave:
- if MASTER_ONLY = 0
+ ifndef MASTER_ONLY
ld de,SLAVE_S
ld (TEMP_WORK+WRKTEMP.pDEVMSG),de
call PRINT
; Check for DIAGNOSTICS errors
- ld a,(ix+WRKAREA.SLAVE.t321D)
+ ld a,(ix+WRKAREA.SLAVE+DEVINFO.t321D)
bit 7,a ; Any error detected by DIAGNOSE?
jr z,.detslave ; No, skip to detection
call DIAGERRPRT ; Print the diagnostic error
- ld (ix+WRKAREA.SLAVE.t321D),0 ; This device isn't available
+ ld (ix+WRKAREA.SLAVE+DEVINFO.t321D),0 ; This device isn't available
jp DRV_INIT_END
.detslave:
push ix
- ld de,WRKAREA.SLAVE.BASE
+ ld de,WRKAREA.SLAVE+DEVINFO.BASE
add ix,de ; Point ix to the SLAVE work area
ld a,M_DEV ; Select SLAVE
call DETDEV
@@ -615,8 +649,8 @@ INIT_ABORTED:
INIT_MASTERFAIL:
ld de,DIAGS_S.nomaster ; Print "failed">
call PRINT
-.end: ld (ix+WRKAREA.MASTER.t321D),0
- ld (ix+WRKAREA.SLAVE.t321D),0
+.end: ld (ix+WRKAREA.MASTER+DEVINFO.t321D),0
+ ld (ix+WRKAREA.SLAVE+DEVINFO.t321D),0
jr DRV_INIT_END
@@ -1018,7 +1052,8 @@ DEV_RW2:
ld b,0
ret
DEV_RW_NO0SEC:
- ld iy,de
+ ld iyl,e
+ ld iyh,d
ld a,(iy+3)
and 11110000b
jp nz,DEV_RW_NOSEC ;Only 28 bit sector numbers supported
@@ -1091,7 +1126,8 @@ DEV_ATAPI_RW:
push de
ld e,(ix+DEVINFO.pBASEWRK) ; hl=pointer to WorkArea
ld d,(ix+DEVINFO.pBASEWRK+1)
- ld iy,de ; iy=WRKAREA pointer
+ ld iyl,e
+ ld iyh,d ; iy=WRKAREA pointer
pop de
; Set the block size
@@ -1135,12 +1171,28 @@ DEV_ATAPI_RD:
ld a,ATAPICMD.PACKET ; PIO send PACKET command
call PIO_CMD
jp c,DEV_RW_ERR
- push bc,hl,iy
+ push bc
+ push hl
+ push iy
ld iyl,1 ; 1 block
ld hl,WRKAREA.PCTBUFF
- ld bc,PCTRW10 ; block size=10 bytes
+ ld bc,PCTRW10._SIZE ; block size=10 bytes
call WRITE_DATA ; Send the packet to the device
- pop iy,hl,bc
+
+ ifdef BAD_POPS
+
+ pop bc
+ pop hl
+ pop iy
+
+ else
+
+ pop iy
+ pop hl
+ pop bc
+
+ endif
+
jp c,DEV_RW_ERR
.init1: ; Set the sector size and number of blocks
@@ -1158,7 +1210,8 @@ DEV_ATAPI_RD:
ld c,a ; c=number of 512-byte blocks per sector
push bc
- ld bc,de ; bc=block size
+ ld b,d
+ ld c,e ; bc=block size
call SETLDIRHLPR ; hl'=Pointer to LDIR helper in RAM
pop bc
ex de,hl ; de=destination address
@@ -1189,12 +1242,28 @@ DEV_ATAPI_WR:
ld a,ATAPICMD.PACKET ; PIO send PACKET command
call PIO_CMD
jp c,DEV_RW_ERR
- push bc,hl,iy
+ push bc
+ push hl
+ push iy
ld iyl,1 ; 1 block
ld hl,WRKAREA.PCTBUFF
- ld bc,PCTRW10 ; block size=10 bytes
+ ld bc,PCTRW10._SIZE ; block size=10 bytes
call WRITE_DATA ; Send the packet to the device
- pop iy,hl,bc
+
+ ifdef BAD_POPS
+
+ pop bc
+ pop hl
+ pop iy
+
+ else
+
+ pop iy
+ pop hl
+ pop bc
+
+ endif
+
jp c,DEV_RW_ERR
.init1: ; Set the sector size and number of blocks
@@ -1212,7 +1281,8 @@ DEV_ATAPI_WR:
ld c,a ; c=number of 512-byte blocks per sector
push bc
- ld bc,de ; bc=block size
+ ld b,d
+ ld c,e ; bc=block size
call SETLDIRHLPR ; hl'=Pointer to LDIR helper in RAM
pop bc
.loopsector:
@@ -1491,9 +1561,22 @@ DEV_STRING_GET:
; B=Size of the string
; Modifies: AF, BC
DEV_STRING_DIGEST:
- push bc,hl
+ push bc
+ push hl
call DEV_STRING_GET
- pop iy,bc
+
+ ifdef BAD_POPS
+
+ pop bc
+ pop iy
+
+ else
+
+ pop iy
+ pop bc
+
+ endif
+
ret c
ld b,c
@@ -2106,7 +2189,7 @@ WAIT_DRQ:
.wait1: ld a,(IDE_STATUS)
rrca ; ERR=1?
jr c,.end2 ; Yes, abort with error
- and (M_DRQ>>1) ; DRQ=1?
+ and (M_DRQ SHR 1) ; DRQ=1?
jr nz,.end ; Yes, quit
ex (sp),hl
ex (sp),hl
@@ -2136,7 +2219,7 @@ WAIT_DRQ:
ld a,(IDE_STATUS)
rrca ; error?
jr c,.tend2 ; Yes, abort with Cy=on
- and (M_DRQ>>1) ; DRQ=1?
+ and (M_DRQ SHR 1) ; DRQ=1?
jr nz,.tend ; Yes, quit
in a,(#E7)
cp 250 ; 250ms
@@ -2300,7 +2383,7 @@ RESET_ALL:
CHKDIAG:
- ld a,(ix+WRKAREA.MASTER.t321D)
+ ld a,(ix+WRKAREA.MASTER+DEVINFO.t321D)
inc a ; Undetected master?
scf
ret z ; Yes, quit with error
@@ -2311,7 +2394,7 @@ CHKDIAG:
jr z,.chkslave ; No, skip
.saveerrms: ; Save the error code from the master
or #80
- ld (ix+WRKAREA.MASTER.t321D),a
+ ld (ix+WRKAREA.MASTER+DEVINFO.t321D),a
bit 7,b ; Error on slave?
scf
ret z ; No, quit
@@ -2326,7 +2409,7 @@ CHKDIAG:
ret z ; No, quit
.saveerrsl: ; Save the error code from the slave
or #80
- ld (ix+WRKAREA.SLAVE.t321D),a
+ ld (ix+WRKAREA.SLAVE+DEVINFO.t321D),a
ld a,b
cp 1 ; Any error reported?
ret z ; No, quit with Cy=off
@@ -2404,518 +2487,10 @@ WRITE_DATA:
LDI512: ; Z80 optimized 512 byte transfer
exx
+ rept 512
ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
- ldi
+ endm
+
ret
@@ -2959,9 +2534,9 @@ MY_GWORK:
or a
jr z,.end
cp 1
- ld ix,WRKAREA.MASTER.BASE
+ ld ix,WRKAREA.MASTER+DEVINFO.BASE
jr z,.end
- ld ix,WRKAREA.SLAVE.BASE
+ ld ix,WRKAREA.SLAVE+DEVINFO.BASE
.end: add ix,de ; Point ix to the device work area
pop de
ret
@@ -3075,7 +2650,7 @@ INIWORK:
push ix
pop hl
push hl
- ld b,WRKAREA
+ ld b,WRKAREA._SIZE
xor a
.clrwork2:
ld (hl),a
@@ -3084,10 +2659,10 @@ INIWORK:
pop hl
; Set the pointers to go back to the base of the WorkArea
- ld (ix+WRKAREA.MASTER.pBASEWRK),l
- ld (ix+WRKAREA.MASTER.pBASEWRK+1),h
- ld (ix+WRKAREA.SLAVE.pBASEWRK),l
- ld (ix+WRKAREA.SLAVE.pBASEWRK+1),h
+ ld (ix+WRKAREA.MASTER+DEVINFO.pBASEWRK),l
+ ld (ix+WRKAREA.MASTER+DEVINFO.pBASEWRK+1),h
+ ld (ix+WRKAREA.SLAVE+DEVINFO.pBASEWRK),l
+ ld (ix+WRKAREA.SLAVE+DEVINFO.pBASEWRK+1),h
; Install the data transfer helper routine in the WorkArea
; This speeds up the LDIR speed a lot for the R800
@@ -3134,7 +2709,7 @@ MYSETSCR:
jp INITXT ; set screen0
.notMSX1:
- ld c,$23 ; Block-2, R#3
+ ld c,23h ; Block-2, R#3
ld ix,REDCLK
call EXTROM
and 1
@@ -3211,7 +2786,7 @@ INICHKSTOP:
call PRINT
.wait1: ld a,7
call SNSMAT
- and $10 ; Is STOP still pressed?
+ and 10h ; Is STOP still pressed?
jr z,.wait1 ; Wait for STOP to be released
xor a
ld (INTFLG),a ; Clear STOP flag
@@ -3258,9 +2833,9 @@ INICHKSTOP:
INFO_S:
db 13,"Sunrise compatible IDE driver v",27,'J'
- db VER_MAIN+$30,'.',VER_SEC+$30,'.',VER_REV+$30
+ db VER_MAIN+30h,'.',VER_SEC+30h,'.',VER_REV+30h
- if MASTER_ONLY = 1
+ ifdef MASTER_ONLY
db 13,10,"Master device only edition"
@@ -3287,7 +2862,7 @@ INIT_S:
MASTER_S:
db 13,"Master device: ",27,'J',0
- if MASTER_ONLY = 0
+ ifndef MASTER_ONLY
SLAVE_S:
db 13,"Slave device : ",27,'J',0
diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac
index 778966ce..f7fc0ff0 100644
--- a/source/kernel/drv.mac
+++ b/source/kernel/drv.mac
@@ -1,4 +1,5 @@
.z80
+ name('drv')
title MSX-DOS 2 ROM Copyright (1986) IS Systems Ltd.
subttl Substitute for the dummy disk driver module
@@ -7,8 +8,8 @@
;-----------------------------------------------------------------------------
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE macros.inc
+ INCLUDE const.inc
;
;-----------------------------------------------------------------------------
;
@@ -102,7 +103,7 @@ CHGF3:
;> Do nothing if chosen file is the same currently in use
- ld a,(ix+DSK_IDX##)
+ ld a,(ix+DSK_CURRENT_FILE_INDEX##)
and 3Fh
cp c
call z,CAPSOFF
@@ -112,7 +113,7 @@ CHGF3:
push bc
- ld a,(ix+EMU_DEVLUN##) ;data file dev index + 16 * LUN index
+ ld a,(ix+EMU_DEV_AND_LUN##) ;data file dev index + 16 * LUN index
ld d,a
rrca
rrca
@@ -123,11 +124,11 @@ CHGF3:
ld a,d
and 111b ;Device
- ld l,(ix+EMU_FSEC##)
- ld h,(ix+EMU_FSEC##+1)
+ ld l,(ix+EMU_FILE_FIRST_SECTOR##)
+ ld h,(ix+EMU_FILE_FIRST_SECTOR##+1)
ld (TMP_SEC##),hl
- ld l,(ix+EMU_FSEC##+2)
- ld h,(ix+EMU_FSEC##+3)
+ ld l,(ix+EMU_FILE_FIRST_SECTOR##+2)
+ ld h,(ix+EMU_FILE_FIRST_SECTOR##+3)
ld (TMP_SEC##+2),hl
ld iy,(0F348h-1) ;Master controller slot
@@ -150,13 +151,13 @@ CHGF3:
;> Set the new file data in work area
- ld a,(ix+DSK_IDX##)
+ ld a,(ix+DSK_CURRENT_FILE_INDEX##)
and 11000000b ;In emulation mode flag + Russian keyboard flag
ld b,a
ld a,c
or b
- ld (ix+DSK_IDX##),a
- set 7,(ix+EMU_DEVLUN##) ;File changed flag
+ ld (ix+DSK_CURRENT_FILE_INDEX##),a
+ set 7,(ix+EMU_DEV_AND_LUN##) ;File changed flag
dec a
add a,a ;Each entry is 8 bytes
@@ -171,24 +172,24 @@ CHGF3:
push ix
pop de
inc de
- inc de ;DE must point to DSK_DEV in work area
+ inc de ;DE must point to DSK_CURRENT_FILE_DEVICE_INDEX in work area
ld bc,8
ldir
- ld a,(ix+DSK_DEV##) ;set DSK_DEV and DSK_LUN as same of data file if 0
+ ld a,(ix+DSK_CURRENT_FILE_DEVICE_INDEX##) ;set DSK_CURRENT_FILE_DEVICE_INDEX and DSK_CURRENT_FILE_LUN_INDEX as same of data file if 0
or a
jr nz,CHGF4
- ld a,(ix+EMU_DEVLUN##)
+ ld a,(ix+EMU_DEV_AND_LUN##)
ld b,a
and 00000111b
- ld (ix+DSK_DEV##),a
+ ld (ix+DSK_CURRENT_FILE_DEVICE_INDEX##),a
ld a,b
rrca
rrca
rrca
rrca
and 00000111b
- ld (ix+DSK_LUN##),a
+ ld (ix+DSK_CURRENT_FILE_LUN_INDEX##),a
CHGF4:
xor a
@@ -206,7 +207,7 @@ WAIT_KEY_RELEASE:
;Input: IX = Pointer to emulation data area
GETCURKEY:
ex af,af'
- ld a,(ix+DSK_IDX##)
+ ld a,(ix+DSK_CURRENT_FILE_INDEX##)
rlca
rlca
rlca
@@ -221,7 +222,7 @@ GETCURKEY:
ld a,0FFh
ret nz
ld c,b
- ld b,(ix+DSK_COUNT##)
+ ld b,(ix+DSK_EMULATED_FILES_COUNT##)
ld a,1
;HLDEC = key statuses
@@ -312,7 +313,7 @@ DIO_ENTRY::
call IS_DVB
jp nc,DIO_ENTRY_DO
- ld a,(iy+UD1_DI##)
+ ld a,(iy+UD1_DEVICE_INDEX##)
or a
jp z,DISKERR
@@ -348,8 +349,8 @@ DIOCHGFOK:
push hl
push de
ld ix,(DVB_TABLE##)
- ld e,(ix+DSK_SIZE##)
- ld d,(ix+DSK_SIZE##+1) ;DE = dsk size in sectors
+ ld e,(ix+DSK_CURRENT_FILE_SECTORS_COUNT##)
+ ld d,(ix+DSK_CURRENT_FILE_SECTORS_COUNT##+1) ;DE = dsk size in sectors
pop hl
push hl
@@ -411,14 +412,14 @@ DIOEN3:
ld (KSLOT##),a ;KSLOT=1 -> device-based
push hl
- ld l,(iy+UD1_FSEC##)
- ld h,(iy+UD1_FSEC##+1)
+ ld l,(iy+UD1_FIRST_ABSOLUTE_SECTOR##)
+ ld h,(iy+UD1_FIRST_ABSOLUTE_SECTOR##+1)
add hl,de
ld ix,TMP_SEC##
ld (ix),l ;Calculate absolute sector number
ld (ix+1),h
- ld l,(iy+UD1_FSEC##+2)
- ld h,(iy+UD1_FSEC##+3)
+ ld l,(iy+UD1_FIRST_ABSOLUTE_SECTOR##+2)
+ ld h,(iy+UD1_FIRST_ABSOLUTE_SECTOR##+3)
ld de,0
adc hl,de
ld (ix+2),l
@@ -426,9 +427,9 @@ DIOEN3:
pop hl ;Restore transfer address
ld de,TMP_SEC##
- ld c,(iy+UD1_LI##) ;Set LUN index
+ ld c,(iy+UD1_LUN_INDEX##) ;Set LUN index
pop af ;From here Cy must be kept untouched
- ld a,(iy+UD1_DI##) ;Set device index
+ ld a,(iy+UD1_DEVICE_INDEX##) ;Set device index
jr DIO_ENTRY_DO_2
@@ -623,7 +624,7 @@ CHG_ENTRY::
jp nc,DO_CALBNK
ld d,a
- ld a,(iy+UD1_DI##)
+ ld a,(iy+UD1_DEVICE_INDEX##)
or a
jp z,DISKERR
@@ -641,8 +642,8 @@ CHG_ENTRY::
xor a
ld ix,(DVB_TABLE##)
- bit 7,(ix+EMU_DEVLUN##)
- res 7,(ix+EMU_DEVLUN##)
+ bit 7,(ix+EMU_DEV_AND_LUN##)
+ res 7,(ix+EMU_DEV_AND_LUN##)
ld b,1
ret z
ld a,d
@@ -655,9 +656,9 @@ CHGEN_NOEMU:
;Drive-based mapping:
;Return "changed" if partition has changed, "unchanged" otherwise
- ld a,(iy+UD1_REL##)
+ ld a,(iy+UD1_RELATIVE_DRIVE##)
ld c,a
- res 7,(iy+UD1_REL##)
+ res 7,(iy+UD1_RELATIVE_DRIVE##)
and 10000000b ;Check partition changed flag
ld b,-1
ld a,c
@@ -695,17 +696,17 @@ DO_MKDPB:
DPBEN2:
push hl
- ld a,(iy+UD1_FSEC##)
+ ld a,(iy+UD1_FIRST_ABSOLUTE_SECTOR##)
ld (TMP_SEC##),a
- ld a,(iy+UD1_FSEC##+1)
+ ld a,(iy+UD1_FIRST_ABSOLUTE_SECTOR##+1)
ld (TMP_SEC##+1),a
- ld a,(iy+UD1_FSEC##+2)
+ ld a,(iy+UD1_FIRST_ABSOLUTE_SECTOR##+2)
ld (TMP_SEC##+2),a
- ld a,(iy+UD1_FSEC##+3)
+ ld a,(iy+UD1_FIRST_ABSOLUTE_SECTOR##+3)
ld (TMP_SEC##+3),a
- ld a,(iy+UD1_DI##)
+ ld a,(iy+UD1_DEVICE_INDEX##)
ld b,1
- ld c,(iy+UD1_LI##)
+ ld c,(iy+UD1_LUN_INDEX##)
ld de,TMP_SEC##
ld hl,($SECBUF##)
or a
@@ -806,8 +807,8 @@ IS_DVB:
jr nz,IS_NOT_DVB
ld iy,(DVB_TABLE##)
- ld_a_iyh
- or_iyl
+ ld a,iyh
+ or iyl
jr z,IS_NOT_DVB
ld a,(iy)
@@ -839,7 +840,7 @@ IS_DVB_LOOP:
pop bc
jr nz,DIO_NEXT
- ld a,(iy+UD1_REL##)
+ ld a,(iy+UD1_RELATIVE_DRIVE##)
and 01111111b ;Ignore partition changed flag
cp c
jr nz,DIO_NEXT
@@ -888,10 +889,10 @@ IS_EMU:
; Return A=0, Z if partition assigned; A<>0, NZ if NO partition assigned.
HAS_PARTITION:
- ld a,(iy+UD1_FSEC##) ;No partition assigned
- and (iy+UD1_FSEC##+1) ;if sector number is -1
- and (iy+UD1_FSEC##+2)
- and (iy+UD1_FSEC##+3)
+ ld a,(iy+UD1_FIRST_ABSOLUTE_SECTOR##) ;No partition assigned
+ and (iy+UD1_FIRST_ABSOLUTE_SECTOR##+1) ;if sector number is -1
+ and (iy+UD1_FIRST_ABSOLUTE_SECTOR##+2)
+ and (iy+UD1_FIRST_ABSOLUTE_SECTOR##+3)
inc a
jr z,RET_NZ
xor a
@@ -924,8 +925,8 @@ ASSIGN_PARTITION:
pop hl
push hl
- ld b,(iy+UD1_DI##)
- ld c,(iy+UD1_LI##)
+ ld b,(iy+UD1_DEVICE_INDEX##)
+ ld c,(iy+UD1_LUN_INDEX##)
ld a,4
ld d,0
ld ix,AUTO_ASPART##
@@ -952,9 +953,9 @@ READ_BOOT:
ld de,0
ld (TMP_SEC##),de
ld (TMP_SEC##+2),de
- ld a,(iy+UD1_DI##)
+ ld a,(iy+UD1_DEVICE_INDEX##)
ld b,1
- ld c,(iy+UD1_LI##)
+ ld c,(iy+UD1_LUN_INDEX##)
ld de,TMP_SEC##
ld hl,($SECBUF##)
or a
diff --git a/source/kernel/kvar.mac b/source/kernel/kvar.mac
index 165d81d2..fc17e8ba 100644
--- a/source/kernel/kvar.mac
+++ b/source/kernel/kvar.mac
@@ -1,4 +1,5 @@
.z80
+ name('kvar')
title MSX-DOS 2 KERNEL Copyright (1986) IS Systems Ltd.
subttl Variable and Constants Declarations
.sall
@@ -14,32 +15,32 @@
; and checking is done that they are withing -128...+127 of IY. The variables
; are all declared backwards from the end of the page-2 RAM segment.
;
- INCLUDE MACROS.INC
- INCLUDE CONST.INC
+ INCLUDE macros.inc
+ INCLUDE const.inc
RAMMOD
;
;
;===== start mod DOS2.50 (change version number)
- const DOSVER,2 ;Major version number
- const DOSV_HI,3 ;Minor version number, high nybble
- const DOSV_LO,1 ;Minor version number, low nybble
- const NXTVER,2
- const NXTV_HI,1
- const NXTV_LO,1
+ const MAIN_DOS_VERSION,2 ;Major version number
+ const SEC_DOS_VERSION_HIGH,3 ;Minor version number, high nybble
+ const SEC_DOS_VERSION_LOW,1 ;Minor version number, low nybble
+ const MAIN_NEXTOR_VERSION,2
+ const SEC_NEXTOR_VERSION_HIGH,1
+ const SEC_NEXTOR_VERSION_LOW,1
;===== end mod DOS2.50
;
;
- const MIN_BUFS,2 ;Minimum number of sector buffers
- const DEF_BUFS,5 ;Default number of sector buffers
- const MAX_HAND,63 ;Number of file handles per process
+ const MIN_SECTOR_BUFFERS,2 ;Minimum number of sector buffers
+ const DEFAULT_SECTOR_BUFFERS,5 ;Default number of sector buffers
+ const MAX_FILE_HANDLES,63 ;Number of file handles per process
;
- const UD_TMOUT,5+2 ;Timeout for media check calls (100ms units)
- ; (+2 is because UD_TIME is only decremented
- ; down to 2, not to zero).
- const CH_TMOUT,1+1 ;Timeout for screen buffer (100ms units)
- ; (+1 is because CH_COUNT is only decremented
- ; down to 1, not to zero).
- const ST_TMOUT,100+1 ;Timeout counter for console status checks
+ const UD_MEDIA_CHECK_TIMEOUT,5+2 ;Timeout for media check calls (100ms units)
+ ; (+2 is because UD_TIME is only decremented
+ ; down to 2, not to zero).
+ const SCREEN_BUFFER_TIMEOUT,1+1 ;Timeout for screen buffer (100ms units)
+ ; (+1 is because CH_COUNT is only decremented
+ ; down to 1, not to zero).
+ const CONSOLE_STATUS_CHECK_TIMEOUT,100+1 ;Timeout counter for console status checks
;
;
;*****************************************************************************
@@ -147,8 +148,8 @@ size macro name
;
field 1,UD_SLOT ;Slot address of appropriate disk driver
field 0,UD_OFFSET ;Offset to entry table of disk driver (for drive-based drivers)
- field 1,UD_DI ;Device index (for device-based drivers)
- field 2,UD_DPB ;Address of MSX DPB in system RAM
+ field 1,UD_DEVICE_INDEX ;Device index (for device-based drivers)
+ field 2,UD_DPB_ADDRESS ;Address of MSX DPB in system RAM
field 1,UD_FLAGS ;Various flags for the unit:
; bit 0: disk is FAT12
; bit 1: disk is FAT16
@@ -163,65 +164,65 @@ size macro name
; bit 1: the device supports hot-plug (ignored)
; bit 2: the drive is removable
; bit 3: partition assignment is pending for this drive
- ; bit 4: value at UD_FSEC is valid
+ ; bit 4: value at UD_FIRST_DEVICE_SECTOR is valid
; (so that BUILD_UPB will not auto-assign partition)
; bit 5: value at UD_CHKSUM is valid
;
- field 1,UD_LI ;LUN index (for device-based drivers)
- field 1,UD_SEG ;Segment number for RAM based drivers, FFh for ROM based drivers
+ field 1,UD_LUN_INDEX ;LUN index (for device-based drivers)
+ field 1,UD_RAM_SEGMENT ;Segment number for RAM based drivers, FFh for ROM based drivers
;
- field 1,UD_PHYS ;Physical unit number.
+ field 1,UD_PHYSICAL_UNIT ;Physical unit number.
field 1,UD_TIME ;Down counter decremented every interrupt
- ; and set back to UD_TMOUT whenever the unit
+ ; and set back to UD_MEDIA_CHECK_TIMEOUT whenever the unit
; is accessed.
; 0 => No UPB defined (don't decrement)
; 1 => UPB must be verified (don't decrement)
; 2 => Timeout expired (don't decrement)
- field 1,UD_CMSK ;Cluster mask
- field 1,UD_CSHFT ;Cluster shift
- field 2,UD_RES ;Reserved sectors
- field 1,UD_NFAT ;Number of FAT's
- field 1,UD_ODE ;Odd directory entries (0...0Fh)
- field 1,UD_WDS ;Whole directory sectors
- field 1,UD_SFAT ;Sectors per FAT
- field 2,UD_SDIR ;First root directory sector
- field 2,UD_SDAT ;First data sector
- field 2,UD_NCLU ;Total number of clusters
-;
- field 1,UD_DIRT ;Dirty disk flag
- field 4,UD_ID ;Current volume ID
- field 1,UD_MBYTE ;Media descriptor byte
-
- field 2,UD_CDIR ;First cluster of current directory
+ field 1,UD_CLUSTER_MASK ;Cluster mask
+ field 1,UD_CLUSTER_SHIFT ;Cluster shift
+ field 2,UD_RESERVED_SECTORS ;Reserved sectors
+ field 1,UD_NUMBER_OF_FATS ;Number of FAT's
+ field 1,UD_ODD_DIR_ENTRIES ;Odd directory entries (0...0Fh)
+ field 1,UD_WHOLE_DIR_SECTORS ;Whole directory sectors
+ field 1,UD_SECTORS_PER_FAT ;Sectors per FAT
+ field 2,UD_FIRST_ROOT_DIR_SECTOR ;First root directory sector
+ field 2,UD_FIRST_DATA_SECTOR ;First data sector
+ field 2,UD_CLUSTER_COUNT ;Total number of clusters
+;
+ field 1,UD_DIRTY_DISK_FLAG ;Dirty disk flag
+ field 4,UD_VOLUME_ID ;Current volume ID
+ field 1,UD_MEDIA_DESC_BYTE ;Media descriptor byte
+
+ field 2,UD_CURRENT_DIR_FIRST_CLUSTER ;First cluster of current directory
; -ve => root directory
; 0000h => cluster not known
- field 64,UD_PATH ;Current directory path
- field 2,UD_RDCLUS ;Reduced total number of clusters
+ field 64,UD_CURRENT_DIR_PATH ;Current directory path
+ field 2,UD_REDUCED_CLUSTER_COUNT ;Reduced total number of clusters
- field 4,UD_FSEC ;First device sector (only for block devices on device-based drivers)
+ field 4,UD_FIRST_DEVICE_SECTOR ;First device sector (only for block devices on device-based drivers)
field 2,UD_CHKSUM
- field 1,UD_REL ;Relative unit number for unit handler
- ;(for device-based drivers this is only used if the driver
- ; provides configuration, in order to get the default mapping
- ; for the drive)
- field 2,UD_ACLU ;Next cluster to check for allocation -1
+ field 1,UD_RELATIVE_UNIT_NUMBER ;Relative unit number for unit handler
+ ;(for device-based drivers this is only used if the driver
+ ; provides configuration, in order to get the default mapping
+ ; for the drive)
+ field 2,UD_ALLOCATION_CLUSTER ;Next cluster to check for allocation -1
;
;--- Extra fields used when mounting files
; This extra space should NOT be allocated unless a file is mounted to the drive
- field 1,UD_MFLAGS ;Flags. Bit 0: read-only mount
- field 1,UD_DRV ;Drive where the mounted file is
- field 2,UD_MXS ;Maximum sector number
- field 2,UD_SCLU ;Start cluster (used to check if file is already mounted)
- field 3,UD_SSEC ;Start sector relative to the drive where the mounted file is
- field 13,UD_MNAME ;File name
+ field 1,UD_MOUNT_FLAGS ;Flags. Bit 0: read-only mount
+ field 1,UD_MOUNT_DRIVE ;Drive where the mounted file is
+ field 2,UD_MOUNT_MAX_SECTOR ;Maximum sector number
+ field 2,UD_MOUNT_START_CLUSTER ;Start cluster (used to check if file is already mounted)
+ field 3,UD_MOUNT_FIRST_DRIVE_SECTOR ;Start sector relative to the drive where the mounted file is
+ field 13,UD_MOUNT_FILENAME ;File name
- size UD_MSZ ;Total size of unit descriptor including extra fields
+ size UD_SIZE_WITH_MOUNT ;Total size of unit descriptor including extra fields
- const UD_SZ,UD_MSZ-22 ;Total size of unit descriptor without extra fields
+ const UD_SIZE,UD_SIZE_WITH_MOUNT-22 ;Total size of unit descriptor without extra fields
;*****************************************************************************
@@ -235,43 +236,43 @@ size macro name
ifield 0 ;Start at offset zero
;
- field 1,UD1_SLOT ;Slot address of appropriate disk driver
- field 1,UD1_REL ;Relative unit number
- ;bit 7 is set if partition has changed
- field 1,UD1_DI ;Device index
- field 1,UD1_LI ;LUN index
- field 4,UD1_FSEC ;First absolute sector number
+ field 1,UD1_SLOT ;Slot address of appropriate disk driver
+ field 1,UD1_RELATIVE_DRIVE ;Relative unit number
+ ;bit 7 is set if partition has changed
+ field 1,UD1_DEVICE_INDEX ;Device index
+ field 1,UD1_LUN_INDEX ;LUN index
+ field 4,UD1_FIRST_ABSOLUTE_SECTOR ;First absolute sector number
- size UD1_SZ ;Total size of unit descriptor
+ size UD1_SIZE ;Total size of unit descriptor
;-----------------------------------------------------------------------------
;
; Work area for the disk emulation mode (pointed by DVB_TABLE)
;
-; Bit 7 of DSK_IDX is kept set to indicate that we are in disk emulation mode
+; Bit 7 of DSK_CURRENT_FILE_INDEX is kept set to indicate that we are in disk emulation mode
; (if reset, it's the count of entries for the device-based drives table
; in normal DOS 1 mode, see UD1_*)
;
-; Bit 6 of DSK_IDX is set if we have a Russian keyboard
+; Bit 6 of DSK_CURRENT_FILE_INDEX is set if we have a Russian keyboard
;
-; Bit 7 of EMU_DEVLUN is set after the current image file is changed
+; Bit 7 of EMU_DEV_AND_LUN is set after the current image file is changed
; and reset again when disk change is checked.
;
-; WARNING: DSK_DEV, DSK_LUN and DSK_FSEC must have the same offset
+; WARNING: DSK_CURRENT_FILE_DEVICE_INDEX, DSK_CURRENT_FILE_LUN_INDEX and DSK_CURRENT_FILE_FIRST_SECTOR must have the same offset
; as the DI_* equivalents; this is required by DIO_ENTRY in drv.mac.
ifield 0 ;Start at offset zero
- field 1,DSK_IDX ;Index of current disk image file
- field 1,EMU_DEVLUN ;Device + 16 * LUN of emulation data mode
- field 1,DSK_DEV ;Device index of current disk image file
- field 1,DSK_LUN ;LUN index of current disk image file
- field 4,DSK_FSEC ;First sector of current disk image file
- field 2,DSK_SIZE ;Size of current disk image file in sectors
- field 1,DSK_COUNT ;Number of emulated disk images
- field 4,EMU_FSEC ;Sector number of the emulation data file
+ field 1,DSK_CURRENT_FILE_INDEX ;Index of current disk image file
+ field 1,EMU_DEV_AND_LUN ;Device + 16 * LUN of emulation data mode
+ field 1,DSK_CURRENT_FILE_DEVICE_INDEX ;Device index of current disk image file
+ field 1,DSK_CURRENT_FILE_LUN_INDEX ;LUN index of current disk image file
+ field 4,DSK_CURRENT_FILE_FIRST_SECTOR ;First sector of current disk image file
+ field 2,DSK_CURRENT_FILE_SECTORS_COUNT ;Size of current disk image file in sectors
+ field 1,DSK_EMULATED_FILES_COUNT ;Number of emulated disk images
+ field 4,EMU_FILE_FIRST_SECTOR ;Sector number of the emulation data file
- size EMU_SZ ;Total size of unit descriptor
+ size EMU_DESC_SIZE ;Total size of descriptor
;-----------------------------------------------------------------------------
@@ -281,11 +282,11 @@ size macro name
ifield BOOT_TMP
- field EMU_SZ,EMU_TMP ;Temporary location of work area used when setting up disk emulation mode
- field 1,IN_EMU ;Set to 1 when disk emulation mode has been entered
- field 2,EMU_WK_AREA ;Address of work area as read from the emulation data file
+ field EMU_DESC_SIZE,EMU_TMP ;Temporary location of work area used when setting up disk emulation mode
+ field 1,IN_EMU_MODE ;Set to 1 when disk emulation mode has been entered
+ field 2,EMU_WORK_AREA_ADDRESS ;Address of work area as read from the emulation data file
;NOTE! BOOTKEYS is used in dos1ker.mac, it must be manually updated if it changes
- field 5,BOOTKEYS ;To store the state of boot keys
+ field 5,BOOTKEYS ;To store the state of boot keys
field 1,I_AM_RUSSIAN
;
;-----------------------------------------------------------------------------
@@ -295,19 +296,19 @@ size macro name
;
ifield -2 ;Allow two bytes for the device chain link
;
- field 2,DD_NEXT ;Pointer to next device descriptor
- field 2,DD_ADDR ;Pointer to device handler
+ field 2,DD_NEXT_DESC_ADDRESS ;Pointer to next device descriptor
+ field 2,DD_DEVICE_HANDLER_ADDRESS ;Pointer to device handler
field 6 ;Reserved for unit handler compatability
;
- field 1,DD_MODE ;Device flags. copied to FAB_MODE when a
- ; file is opened.
- ; b7 - always set (=> device)
- ;b6..b1 - reserved
- ; b0 - set => CONSOLE device
- field 32,DD_NAME ;Device name as a directory entry
+ field 1,DD_MODE ;Device flags. copied to FAB_MODE when a
+ ; file is opened.
+ ; b7 - always set (=> device)
+ ;b6..b1 - reserved
+ ; b0 - set => CONSOLE device
+ field 32,DD_DEVICE_NAME ;Device name as a directory entry
;
;
- size DD_SZ ;Total size of device descriptor
+ size DD_DESC_SIZE ;Total size of device descriptor
;
;
;-----------------------------------------------------------------------------
@@ -317,31 +318,31 @@ size macro name
;
ifield 0 ;Start at offset zero.
;
- field 2,BD_LINK ;16 bit pointer to next buffer descriptor
- field 1,BD_UNIT ;Physical unit number of contents
- ; 00h => buffer empty
- ; 80h => buffer reserved
-;
- field 1,BD_FLAGS ;Flags, only valid if BD_UNIT<>0.
- ; b0 - Flag for marking buffers
- ; b1 - Ignore allowed flag
- ;b2...b5 - always 0
- ; b6 - Set => only write to last FAT copy
- ; b7 - set => dirty buffer
-;
- field 2,BD_SECT ;Absolute sector number of contents (bit0-15)
- field 1,BD_COPY ;Number of disk copies
- field 1,BD_SEP ;Number of sectors between copies
+ field 2,BD_NEXT_DESC_ADDRESS ;16 bit pointer to next buffer descriptor
+ field 1,BD_PHYSICAL_UNIT_NUMBER ;Physical unit number of contents
+ ; 00h => buffer empty
+ ; 80h => buffer reserved
+;
+ field 1,BD_FLAGS ;Flags, only valid if BD_PHYSICAL_UNIT_NUMBER<>0.
+ ; b0 - Flag for marking buffers
+ ; b1 - Ignore allowed flag
+ ;b2...b5 - always 0
+ ; b6 - Set => only write to last FAT copy
+ ; b7 - set => dirty buffer
+
+ field 2,BD_SECTOR_NUMBER ;Absolute sector number of contents (bit0-15)
+ field 1,BD_NUMBER_OF_COPIES ;Number of disk copies
+ field 1,BD_SECTORS_BETWEEN_COPIES ;Number of sectors between copies
;===== start mod FAT16 (DSKEX workarea)
- field 1,BD_EX_SECT ;Absolute sector number of contents (bit16-22) : compatible "DSKEX" in FAT16PATCH
+ field 1,BD_EX_SECTOR_NUMBER ;Absolute sector number of contents (bit16-22) : compatible "DSKEX" in FAT16PATCH
;; field 1
;===== end mod FAT16
- field 2,BD_UD ;Address of owning unit descriptor
+ field 2,BD_UNIT_DESCRIPTOR_ADDRESS ;Address of owning unit descriptor
;
field 512,BD_DATA ;Space for one sectors worth of data
;
;
- size BD_SZ ;Size of buffer descriptor
+ size BD_DESC_SIZE ;Size of buffer descriptor
;
;
;-----------------------------------------------------------------------------
@@ -349,38 +350,38 @@ size macro name
; FILEINFO Block
; ================
;
-; The first section of the fileinfo block (up to and including FIB_DRV) is
+; The first section of the fileinfo block (up to and including FIB_DRIVE_NUMBER) is
; defined and may be accessed by users. The remaining fields are not defined
; and should not be accessed let alone modified by users.
;
;
ifield 0 ;Start at offset zero
;
- field 1,FIB_FLG ;Always 0FFh - differentiates ASCIIZ string
- field 13,FIB_NAME ;ASCIIZ filename string
- field 1,FIB_ATTR ;Attributes byte
- field 2,FIB_TIME ;Last modified time
- field 2,FIB_DATE ;Last modified date
- field 2,FIB_CLU ;Start cluster number
- field 4,FIB_SIZE ;File size
- field 1,FIB_DRV ;Logical drive number (never zero)
-;
- field 4,FIB_ID ;Volume id. (or device descriptor & jump
- ; table address)
- field 1,FIB_MODE ;Device flag (bit-7)
- field 1,FIB_SA ;Search attributes
-;
- field 11,FIB_PAT ;Expanded pattern matching filename
+ field 1,FIB_ID_BYTE ;Always 0FFh - differentiates ASCIIZ string
+ field 13,FIB_FILENAME ;ASCIIZ filename string
+ field 1,FIB_ATTRIBUTES ;Attributes byte
+ field 2,FIB_MODIFIED_TIME ;Last modified time
+ field 2,FIB_MODIFIED_DATE ;Last modified date
+ field 2,FIB_START_CLUSTER ;Start cluster number
+ field 4,FIB_FILE_SIZE ;File size
+ field 1,FIB_DRIVE_NUMBER ;Logical drive number (never zero)
+;
+ field 4,FIB_VOLUME_ID ;Volume id. (or device descriptor & jump
+ ; table address)
+ field 1,FIB_MODE ;Device flag (bit-7)
+ field 1,FIB_SEARCH_ATTRIBUTES ;Search attributes
+;
+ field 11,FIB_EXPANDED_SEARCH_PATTERN ;Expanded pattern matching filename
;===== start mod FAT16 (SDIR_1/SDIR_2/SDIR_3 workarea)
- field 13,FIB_DVAR ;Storage for directory variables (size = DE_FSTV-DE_LSTV = 13) : compatible "SDIR_1", "SDIR_2", "SDIR_3" in FAT16PATCH
+ field 13,FIB_DIRECTORY_VARIABLES ;Storage for directory variables (size = DE_FSTV-DE_LSTV = 13) : compatible "SDIR_1", "SDIR_2", "SDIR_3" in FAT16PATCH
;
field 8 ;Spare
-;; field 12,FIB_DVAR
+;; field 12,FIB_DIRECTORY_VARIABLES
;; field 9
;===== end mod FAT16
;
;
- size FIB_SZ ;Size of fileinfo block (should be 64 bytes)
+ size FIB_DESC_SIZE ;Size of fileinfo block (should be 64 bytes)
;
;
; -----------------------------------
@@ -395,19 +396,19 @@ size macro name
ifield -3 ;Start at offset -3 to allow for link
; and reference count.
;
- field 2,FAB_NEXT ;Link into chain
- field 1,FAB_CNT ;Reference count
+ field 2,FAB_NEXT_ADDRESS ;Link into chain
+ field 1,FAB_REFERENCE_COUNT ;Reference count
;
- field 1,FAB_FLG ;Always 0FFh - differentiates ASCIIZ string
- field 13,FAB_NAME ;ASCIIZ filename string
- field 1,FAB_ATTR ;Attributes byte
- field 2,FAB_TIME ;Last modified time
- field 2,FAB_DATE ;Last modified date
- field 2,FAB_CLU ;Start cluster number
- field 4,FAB_SIZE ;File size
- field 1,FAB_DRV ;Logical drive number (never zero)
+ field 1,FAB_ID_BYTE ;Always 0FFh - differentiates ASCIIZ string
+ field 13,FAB_FILENAME ;ASCIIZ filename string
+ field 1,FAB_ATTRIBUTES ;Attributes byte
+ field 2,FAB_MODIFIED_TIME ;Last modified time
+ field 2,FAB_MODIFIED_DATE ;Last modified date
+ field 2,FAB_START_CLUSTER ;Start cluster number
+ field 4,FAB_FILE_SIZE ;File size
+ field 1,FAB_DRIVE_NUMBER ;Logical drive number (never zero)
;
- field 4,FAB_ID ;Volume id. (or device descriptor address)
+ field 4,FAB_VOLUME_ID ;Volume id. (or device descriptor address)
field 1,FAB_MODE ;File handle mode flags:
; b7 - set => device
; clear=> disk file
@@ -420,33 +421,33 @@ size macro name
; b4 - set => the FAB corresponds to a mounted file
; b3..b1 - reserved
; b0 - set => CONSOLE device
- field 1,FAB_SA ;Search attributes
+ field 1,FAB_SEARCH_ATTRIBUTES ;Search attributes
;
- field 0,FAB_FIB ;End of FIB compatability
+ field 0,FAB_END_OF_FIB ;End of FIB compatability
;
; +++++ UP TO HERE IS COMPATIBLE WITH FILEINFO BLOCKS +++++
;
- field 2,FAB_UD ;Unit descriptor address \ Only used for
- field 2,FAB_DSEC ;Directory sector > comparing in
+ field 2,FAB_UNIT_DESCRIPTOR_ADDRESS ;Unit descriptor address \ Only used for
+ field 2,FAB_DIRECTORY_SECTOR ;Directory sector > comparing in
;===== start add FAT16 (add Extended sector number in FAB)
- field 1,FAB_EX_DSEC ;Directory sector (bit16-22)
+ field 1,FAB_EX_DIRECTORY_SECTOR ;Directory sector (bit16-22)
;===== end add FAT16
- field 1,FAB_ENT ;Entries number in sector / "FAB_SCAN".
+ field 1,FAB_ENTRIES_PER_SECTOR ;Entries number in sector / "FAB_SCAN".
;
- field 2,FAB_FDC ;First directory cluster (-ve => root)
- field 2,FAB_FPC ;First physical cluster
- field 2,FAB_LPC ;Last accessed physical cluster
- field 2,FAB_LLC ;Last accessed logical cluster
- field 4,FAB_PTR ;File pointer
- field 1,FAB_ACC ;Access mode flags:
- ; b0 - set => deny write
- ; b1 - set => deny read
- ; b2 - set => inherited by child
- ; b3..b6 - reserved
- ; b7 - set => written to
- field 1,FAB_PG ;Temporary paging mode
+ field 2,FAB_FIRST_DIR_CLUSTER ;First directory cluster (-ve => root)
+ field 2,FAB_FIRST_PHYSICAL_CLUSTER ;First physical cluster
+ field 2,FAB_LAST_ACCESSED_PHYSICAL_CLUSTER ;Last accessed physical cluster
+ field 2,FAB_LAST_ACCESSED_LOGICAL_CLUSTER ;Last accessed logical cluster
+ field 4,FAB_FILE_POINTER ;File pointer
+ field 1,FAB_ACCESS_MODE ;Access mode flags:
+ ; b0 - set => deny write
+ ; b1 - set => deny read
+ ; b2 - set => inherited by child
+ ; b3..b6 - reserved
+ ; b7 - set => written to
+ field 1,FAB_TEMP_PAGING_MODE ;Temporary paging mode
;
- size FAB_SZ ;Size of file access block
+ size FAB_DESC_SIZE ;Size of file access block
;
;
;-----------------------------------------------------------------------------
@@ -456,27 +457,27 @@ size macro name
;
ifield 0
;
- field 1,CP_DRV ;Drive number 0=>default
- field 8,CP_FN ;Filename
- field 3,CP_EXT ;Filename extension
+ field 1,FCB_DRIVE_NUMBER ;Drive number 0=>default
+ field 8,FCB_FILENAME ;Filename
+ field 3,FCB_FILENAME_EXTENSION ;Filename extension
;
- field 1,CP_EXL ;Low byte of extent in sequential fns.
- field 1,CP_S1 ;Byte S1 in CP/M
- field 0,CP_EXH ;\ High byte of extent in sequential fns.
- field 1,CP_RS ;/ Record size (2 bytes) in MSX-DOS block fns.
- field 1,CP_RC ;Record count in CP/M compatible fns.
+ field 1,FCB_EXTENT_LOW ;Low byte of extent in sequential fns.
+ field 1,FCB_S1 ;Byte S1 in CP/M
+ field 0,FCB_EXTENT_HIGH ;\ High byte of extent in sequential fns.
+ field 1,FCB_RECORD_SIZE ;/ Record size (2 bytes) in MSX-DOS block fns.
+ field 1,FCB_RECORD_COUNT ;Record count in CP/M compatible fns.
;
- field 4,CP_SIZ ;File size (low byte first)
- field 4,CP_ID ;Volume id
- field 2,CP_FDC ;First directory cluster
- field 2,CP_FPC ;First physical cluster
- field 2,CP_LPC ;Last accessed physical cluster
- field 2,CP_LLC ;Last accessed logical cluster
+ field 4,FCB_FILE_SIZE ;File size (low byte first)
+ field 4,FCB_VOLUME_ID ;Volume id
+ field 2,FCB_FIRST_DIR_CLUSTER ;First directory cluster
+ field 2,FCB_FIRST_PHYSICAL_CLUSTER ;First physical cluster
+ field 2,FCB_LAST_ACCESSED_PHYSICAL_CLUSTER ;Last accessed physical cluster
+ field 2,FCB_LAST_ACCESSED_LOGICAL_CLUSTER ;Last accessed logical cluster
;
- field 1,CP_CR ;Current record (sequential fns.)
- field 4,CP_RR ;Random record (random and block fns.)
+ field 1,FCB_CURRENT_RECORD ;Current record (sequential fns.)
+ field 4,FCB_RANDOM_RECORD ;Random record (random and block fns.)
;
- size CP_SZ
+ size FCB_DESC_SIZE
;
;
;-----------------------------------------------------------------------------
@@ -488,46 +489,46 @@ size macro name
ifield 0 ; Start at offset zero
;
- field 3,UPB_JP ; 8086 compatible "JUMP" instruction
- field 8,UPB_MANU ; Manufacturer's name & version number
+ field 3,UPB_JP ; 8086 compatible "JUMP" instruction
+ field 8,UPB_MANUFACTURER ; Manufacturer's name & version number
;
- field 2,UPB_SSZ ; Sector size (must be 512 currently)
- field 1,UPB_CS ; Sectors per cluster (must be power of 2)
- field 2,UPB_RES ; Reserved sectors including boot sector
- field 1,UPB_NFAT ; Number of FATs
- field 2,UPB_NDIR ; Number of root directory entries
- field 2,UPB_SEC ; Total number of sectors on disk if <=65535
- field 1,UPB_MBYTE ; Media descriptor byte
- field 2,UPB_SFAT ; Sectors per FAT
+ field 2,UPB_SECTOR_SIZE ; Sector size (must be 512 currently)
+ field 1,UPB_SECTORS_PER_CLUSTER ; Sectors per cluster (must be power of 2)
+ field 2,UPB_RESERVED_SECTORS ; Reserved sectors including boot sector
+ field 1,UPB_NUM_FATS ; Number of FATs
+ field 2,UPB_NUM_ROOT_DIR_ENTRIES ; Number of root directory entries
+ field 2,UPB_TOTAL_SECTORS ; Total number of sectors on disk if <=65535
+ field 1,UPB_MEDIA_DESC_BYTE ; Media descriptor byte
+ field 2,UPB_SECTORS_PER_FAT ; Sectors per FAT
;
- field 2,UPB_STRK ; Sectors per track \ These are not used by
- field 2,UPB_HEAD ; Number of heads > MSX-DOS but may be used
- field 2,UPB_HSEC ; Hidden sectors / by the unit handler.
+ field 2,UPB_SECTORS_PER_TRACK ; Sectors per track \ These are not used by
+ field 2,UPB_NUM_HEADS ; Number of heads > MSX-DOS but may be used
+ field 2,UPB_HIDDEN_SECTORS ; Hidden sectors / by the unit handler.
;
; --- Fields for DOS 2 boot sector
ifield 1Eh
- field 2,UPB_BOOT ; Start of MSX-DOS boot code
- ; ('RET' or a jump to UPB_SPARE).
- field 6,UPB_VOLID ; "VOL_ID" string
- field 1,UPB_DIRT ; Dirty disk flag
- field 4,UPB_ID ; Random volume-id (each byte 0....7F)
+ field 2,UPB_BOOT_CODE ; Start of MSX-DOS boot code
+ ; ('RET' or a jump to UPB_SPARE).
+ field 6,UPB_VOLUME_ID ; "VOL_ID" string
+ field 1,UPB_DIRTY_FLAG ; Dirty disk flag
+ field 4,UPB_RANDOM_ID ; Random volume-id (each byte 0....7F)
field 5
- field 0,UPB_SPARE ; Space for more MSX-DOS boot code
+ field 0,UPB_SPARE ; Space for more MSX-DOS boot code
; --- Fields for standard boot sector
ifield 1Eh
field 2 ; Continuation of "hidden sectors"
- field 4,UPB_BIGSEC ; Total number of sectors on disk if >65535
- field 1,UPB_PHY ; Physical drive number
- field 1,UPB_RSV ; Reserved
- field 1,UPB_EBS ; Extended signature block (28h or 29h)
- field 4;,UPB_ID ; Volume id, in the same place as DOS 2 boot sector
- field 11,UPB_VN ; Volume name
- field 8,UPB_FILESYS ; FAT Filesystem string :"FAT12" or "FAT16"
+ field 4,UPB_BIG_TOTAL_SECTORS ; Total number of sectors on disk if >65535
+ field 1,UPB_PHYSICAL_DRIVE ; Physical drive number
+ field 1,UPB_RESERVED ; Reserved
+ field 1,UPB_EXTENDED_SIGNATURE ; Extended signature block (28h or 29h)
+ field 4;,UPB_RANDOM_ID ; Volume id, in the same place as DOS 2 boot sector
+ field 11,UPB_VOLUME_NAME ; Volume name
+ field 8,UPB_FILESYSTEM ; FAT Filesystem string :"FAT12" or "FAT16"
;
;
;-----------------------------------------------------------------------------
@@ -537,15 +538,15 @@ size macro name
;
ifield 0
;
- field 8,DR_FILE ; ASCII filename
- field 3,DR_EXT ; ASCII filename extension
- field 1,DR_ATTR ; File attributes
- field 1,DR_DCHAR ; First character of deleted entry.
- field 9 ; Unused space in directory entry
- field 2,DR_TIME ; Time of last update
- field 2,DR_DATE ; Date of last update
- field 2,DR_CLU ; First directory cluster
- field 4,DR_SIZE ; File size in bytes (low word first)
+ field 8,DR_FILENAME ; ASCII filename
+ field 3,DR_EXTENSION ; ASCII filename extension
+ field 1,DR_ATTRIBUTES ; File attributes
+ field 1,DR_DELETED_FIRST_CHAR ; First character of deleted entry.
+ field 9 ; Unused space in directory entry
+ field 2,DR_UPDATED_TIME ; Time of last update
+ field 2,DR_UPDATED_DATE ; Date of last update
+ field 2,DR_FIRST_CLUSTER ; First directory cluster
+ field 4,DR_FILE_SIZE ; File size in bytes (low word first)
;
;
;*****************************************************************************
@@ -764,9 +765,9 @@ endif
var ASG_TAB, MAX_UNITS+1 ;Logical to physical unit translation
; table (1st byte always 0).
;
- var FIB_1, FIB_SZ ;Internal fileinfo block
- var SRCH_FIB, FIB_SZ ;FIB for CP/M search functions
- var TEMP_FCB, CP_SZ ;Temporary CP/M FCB for search fns.
+ var FIB_1, FIB_DESC_SIZE ;Internal fileinfo block
+ var SRCH_FIB, FIB_DESC_SIZE ;FIB for CP/M search functions
+ var TEMP_FCB, FCB_DESC_SIZE ;Temporary CP/M FCB for search fns.
;
var WPTH_BUF, 63+5 ;Whole path buffer. 63 characters
; + 1 underflow byte + "\" at start
diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc
index e3f93127..755846f8 100644
--- a/source/kernel/macros.inc
+++ b/source/kernel/macros.inc
@@ -7,107 +7,6 @@ TRUE equ NOT FALSE
;
;
-;Macros for generating IXh/IXl/IYh/IYl instructions.
-;These instructions are generated by
-;appending a DDh byte to instructions referring to H, to access IXh,
-;or to instructions referring to L, to access IXl.
-;For IY, FDh is used instead of DDh.
-
-ld_iyh_a macro
- db 0FDh
- ld h,a
- endm
-
-ld_iyh_e macro
- db 0FDh
- ld h,e
- endm
-
-ld_iyl_a macro
- db 0FDh
- ld l,a
- endm
-
-ld_iyl_e macro
- db 0FDh
- ld l,e
- endm
-
-ld_iyh_b macro
- db 0FDh
- ld h,b
- endm
-
-ld_iyh_c macro
- db 0FDh
- ld h,c
- endm
-
-ld_a_iyh macro
- db 0FDh
- ld a,h
- endm
-
-ld_a_iyl macro
- db 0FDh
- ld a,l
- endm
-
-ld_c_ixh macro
- db 0DDh
- ld c,h
- endm
-
-ld_ixh_a macro
- db 0DDh
- ld h,a
- endm
-
-ld_a_ixh macro
- db 0DDh
- ld a,h
- endm
-
-ld_a_ixl macro
- db 0DDh
- ld a,l
- endm
-
-ld_a_iyh macro
- db 0FDh
- ld a,h
- endm
-
-or_ixl macro
- db 0DDh
- or l
- endm
-
-or_iyl macro
- db 0FDh
- or l
- endm
-
-cp_ixl macro
- db 0DDh
- cp l
- endm
-
-cp_ixh macro
- db 0DDh
- cp h
- endm
-
-cp_iyl macro
- db 0FDh
- cp l
- endm
-
-cp_iyh macro
- db 0FDh
- cp h
- endm
-
const macro name,value
name equ (value)
@@ -126,7 +25,7 @@ warn macro text
;
error macro text
if1
- .printx % text
+ .error text
endif
endm
;
@@ -143,10 +42,117 @@ pr_hex macro msg1,value,msg2
;
;
code macro instr,arg
- .8080
- db (instr arg)
- .z80
- endm
+
+_code_ defl 0
+
+ ifidn ,
+_code_ defl 0C9h
+ endif
+
+ ifidn ,
+_code_ defl 0C9h
+ endif
+
+ ifidn ,
+_code_ defl 0FEh
+ endif
+
+ ifidn ,
+_code_ defl 0FEh
+ endif
+
+ ifidn ,
+_code_ defl 032h
+ endif
+
+ ifidn ,
+_code_ defl 0CDh
+ endif
+
+ ifidn ,
+_code_ defl 0CDh
+ endif
+
+ ifidn ,
+_code_ defl 0CAh
+ endif
+
+ ifidn ,
+_code_ defl 0F6h
+ endif
+
+ ifidn ,
+_code_ defl 0C4h
+ endif
+
+ ifidn ,
+_code_ defl 0C3h
+ endif
+
+ ifidn ,
+ ifidn ,
+_code_ defl 0F5h
+ endif
+ endif
+
+ ifidn ,
+ ifidn ,
+_code_ defl 3Eh
+ endif
+ ifidn ,
+_code_ defl 36h
+ endif
+ ifidn ,
+_code_ defl 0Eh
+ endif
+ endif
+
+ ifidn ,
+ ifidn ,
+_code_ defl 3Eh
+ endif
+ ifidn ,
+_code_ defl 06h
+ endif
+ ifidn ,
+_code_ defl 36h
+ endif
+ ifidn ,
+_code_ defl 0Eh
+ endif
+ endif
+
+ ifidn ,
+ ifidn ,
+_code_ defl 21h
+ endif
+ ifidn ,
+_code_ defl 31h
+ endif
+ ifidn ,
+_code_ defl 21h
+ endif
+ endif
+
+ ifidn ,
+ ifidn ,
+_code_ defl 21h
+ endif
+ ifidn ,
+_code_ defl 21h
+ endif
+ endif
+
+ if _code_ eq 0
+ if1
+ .printx Undefined CODE arguments!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ .printx instr,arg
+ endif
+ endif
+
+db _code_
+
+endm
;
;
;-----------------------------------------------------------------------------
diff --git a/source/kernel/tool/L80.CPM b/source/kernel/tool/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/kernel/tool/L80.CPM and /dev/null differ
diff --git a/source/kernel/tool/LIB80.CPM b/source/kernel/tool/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/kernel/tool/LIB80.CPM and /dev/null differ
diff --git a/source/kernel/tool/M80.CPM b/source/kernel/tool/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/kernel/tool/M80.CPM and /dev/null differ
diff --git a/source/tools/C/asmcall.c b/source/tools/C/asmcall.c
index 49c296bd..349c3dc9 100644
--- a/source/tools/C/asmcall.c
+++ b/source/tools/C/asmcall.c
@@ -16,7 +16,7 @@ void DosCall(byte function, Z80_registers* regs, register_usage inRegistersDetai
}
-void AsmCallAlt(uint address, Z80_registers* regs, register_usage inRegistersDetail, register_usage outRegistersDetail, int alternateAf) __naked
+void AsmCallAlt(uint address, Z80_registers* regs, register_usage inRegistersDetail, register_usage outRegistersDetail, int alternateAf) __naked __sdcccall(0)
{
__asm
push ix
diff --git a/source/tools/C/asmcall.h b/source/tools/C/asmcall.h
index 29c82852..902b4070 100644
--- a/source/tools/C/asmcall.h
+++ b/source/tools/C/asmcall.h
@@ -57,6 +57,6 @@ typedef union {
#define AsmCall(dir, regs, in, out) AsmCallAlt(dir, regs, in, out, 0)
void DosCall(byte function, Z80_registers* regs, register_usage inRegistersDetail, register_usage outRegistersDetail);
-void AsmCallAlt(uint address, Z80_registers* regs, register_usage inRegistersDetail, register_usage outRegistersDetail, int alternateAf);
+void AsmCallAlt(uint address, Z80_registers* regs, register_usage inRegistersDetail, register_usage outRegistersDetail, int alternateAf) __sdcccall(0);
#endif //__ASMCALL_H
\ No newline at end of file
diff --git a/source/tools/C/compemu.bat b/source/tools/C/compemu.bat
deleted file mode 100644
index 4a78c809..00000000
--- a/source/tools/C/compemu.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-@echo off
-cls
-sdcc --code-loc 0x180 --data-loc 0 -mz80 --disable-warning 196 --disable-warning 85 --no-std-crt0 crt0msx_msxdos_advanced.rel emufile.c
-if errorlevel 1 goto :end
-hex2bin -e com emufile.ihx
-copy emufile.com ..\..\..\bin\tools\
-:end
diff --git a/source/tools/C/compfsize.bat b/source/tools/C/compfsize.bat
deleted file mode 100644
index 965f505a..00000000
--- a/source/tools/C/compfsize.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-@echo off
-cls
-sdcc --code-loc 0x180 --data-loc 0 -mz80 --disable-warning 196 --disable-warning 85 --no-std-crt0 crt0msx_msxdos_advanced.rel fsize.c
-if errorlevel 1 goto :end
-hex2bin -e com fsize.ihx
-copy fsize.com ..\..\..\bin\tools\
-:end
diff --git a/source/tools/C/compnexboot.bat b/source/tools/C/compnexboot.bat
deleted file mode 100644
index a62668b5..00000000
--- a/source/tools/C/compnexboot.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-@echo off
-cls
-sdcc --code-loc 0x180 --data-loc 0 -mz80 --disable-warning 196 --disable-warning 85 --no-std-crt0 crt0msx_msxdos_advanced.rel msxchar.lib nexboot.c
-if errorlevel 1 goto :end
-hex2bin -e com nexboot.ihx
-copy nexboot.com ..\..\..\bin\tools\
-:end
diff --git a/source/tools/C/compvsft.bat b/source/tools/C/compvsft.bat
deleted file mode 100644
index 600541a5..00000000
--- a/source/tools/C/compvsft.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-@echo off
-cls
-sdcc --code-loc 0x180 --data-loc 0 -mz80 --disable-warning 196 --disable-warning 85 --no-std-crt0 crt0msx_msxdos_advanced.rel vsft.c
-if errorlevel 1 goto :end
-hex2bin -e com vsft.ihx
-copy vsft.com ..\..\..\bin\tools\
-:end
diff --git a/source/tools/C/print_msxdos.c b/source/tools/C/print_msxdos.c
index 53735fca..09919d82 100644
--- a/source/tools/C/print_msxdos.c
+++ b/source/tools/C/print_msxdos.c
@@ -1,11 +1,9 @@
void print(char* s) __naked
{
__asm
- push ix
- ld ix,#4
- add ix,sp
- ld l,(ix)
- ld h,1(ix)
+
+ ;HL = *s
+
loop:
ld a,(hl)
or a
@@ -18,7 +16,6 @@ void print(char* s) __naked
inc hl
jr loop
end:
- pop ix
ret
__endasm;
}
diff --git a/source/tools/C/printf.c b/source/tools/C/printf.c
index 3e908e0f..dc719838 100644
--- a/source/tools/C/printf.c
+++ b/source/tools/C/printf.c
@@ -32,11 +32,11 @@
#define CONOUT 2
#ifdef SUPPORT_LONG
-extern void _ultoa(long val, char* buffer, char base);
-extern void _ltoa(long val, char* buffer, char base);
+extern void __ultoa(long val, char* buffer, char base);
+extern void __ltoa(long val, char* buffer, char base);
#endif
-extern void _uitoa(int val, char* buffer, char base);
-extern void _itoa(int val, char* buffer, char base);
+extern void __uitoa(int val, char* buffer, char base);
+extern void __itoa(int val, char* buffer, char base);
static int format_string(const char* buf, const char *fmt, va_list ap);
@@ -54,19 +54,17 @@ int sprintf(const char* buf, const char* fmt, ...)
return format_string(buf, fmt, arg);
}
-static void do_char(const char* buf, char c) __naked
+static void do_char(char c, const char* buf) __naked
{
__asm
- ld hl,#4
- add hl,sp
- ld e,(hl)
+ ;A = c
+ ;DE = *buf
- dec hl
- ld a,(hl)
- dec hl
- ld l,(hl)
- ld h,a
+ ex de,hl
+ ld e,a
+
+ ld a,h
or l
#ifdef COM_FILE
@@ -92,7 +90,7 @@ static void do_char(const char* buf, char c) __naked
__endasm;
}
-#define do_char_inc(c) {do_char(bufPnt,c); if(bufPnt) { bufPnt++; } count++;}
+#define do_char_inc(c) {do_char(c,bufPnt); if(bufPnt) { bufPnt++; } count++;}
static int format_string(const char* buf, const char *fmt, va_list ap)
{
@@ -174,20 +172,20 @@ static int format_string(const char* buf, const char *fmt, va_list ap)
val = va_arg(ap, int);
if(isUnsigned && isLong)
- _ultoa(val, buffer, base);
+ __ultoa(val, buffer, base);
else if(isUnsigned)
- _uitoa(val, buffer, base);
+ __uitoa(val, buffer, base);
else if(isLong)
- _ltoa(val, buffer, base);
+ __ltoa(val, buffer, base);
else
- _itoa(val, buffer, base);
+ __itoa(val, buffer, base);
#else
val = va_arg(ap, int);
if(isUnsigned)
- _uitoa(val, buffer, base);
+ __uitoa(val, buffer, base);
else
- _itoa(val, buffer, base);
+ __itoa(val, buffer, base);
#endif
strPnt = buffer;
diff --git a/source/tools/CPM32.EXE b/source/tools/CPM32.EXE
deleted file mode 100644
index 51eb6741..00000000
Binary files a/source/tools/CPM32.EXE and /dev/null differ
diff --git a/source/tools/DRIVERS.MAC b/source/tools/DRIVERS.MAC
index 3b828591..577e0de9 100644
--- a/source/tools/DRIVERS.MAC
+++ b/source/tools/DRIVERS.MAC
@@ -187,9 +187,9 @@ DRVASSIGN_MSG:
NUMDRIVES:
db "0, from "
FIRSTDRIVE:
- "A: to "
+ db "A: to "
LASTDRIVE:
- "Z:"
+ db "Z:"
CRLF:
db 13,10,0
diff --git a/source/tools/FASTOUT.MAC b/source/tools/FASTOUT.MAC
index b76c31ae..50566abc 100644
--- a/source/tools/FASTOUT.MAC
+++ b/source/tools/FASTOUT.MAC
@@ -73,7 +73,7 @@ DO_INFO:
jp 5
INFO_MSG:
- "Fast STROUT mode is currently ",0
+ db "Fast STROUT mode is currently ",0
ON_S: db "ON",13,10,0
OFF_S: db "OFF",13,10,0
diff --git a/source/tools/L80.CPM b/source/tools/L80.CPM
deleted file mode 100644
index ac1fedc9..00000000
Binary files a/source/tools/L80.CPM and /dev/null differ
diff --git a/source/tools/LIB80.CPM b/source/tools/LIB80.CPM
deleted file mode 100644
index 81b1d224..00000000
Binary files a/source/tools/LIB80.CPM and /dev/null differ
diff --git a/source/tools/M80.CPM b/source/tools/M80.CPM
deleted file mode 100644
index 0ae1e23d..00000000
Binary files a/source/tools/M80.CPM and /dev/null differ
diff --git a/source/tools/Makefile b/source/tools/Makefile
index 59a9e3fa..0224f31e 100644
--- a/source/tools/Makefile
+++ b/source/tools/Makefile
@@ -3,17 +3,27 @@
# The generated files are copied to the bin/tools directory.
-export X80_COMMAND_LINE=-t -nb
-export M80_COMMAND_LINE=-8
+ifeq ($(strip $(N80)),)
+N80=N80
+endif
-define hex2bin
- objcopy -I ihex -O binary $(1) $(2)
-endef
+export N80_ARGS=--no-string-escapes --no-show-banner --build-type rel --verbosity 0 --output-file-case upper --include-directory ../kernel
+
+ifeq ($(strip $(LK80)),)
+LK80=LK80
+endif
+
+export LK80_ARGS=--no-show-banner --verbosity 0 --output-file-case lower --output-format bin
define copy_to_bin
cp $(1) ../../bin/tools/$(2)
endef
+define assemble
+ @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1)
+ @$(N80) $(1) $(2)
+endef
+
COMS := CONCLUS.COM DELALL.COM DEVINFO.COM DRIVERS.COM DRVINFO.COM FASTOUT.COM LOCK.COM MAPDRV.COM NSYSVER.COM RALLOC.COM
INCS := ../kernel/macros.inc ../kernel/const.inc
RELS := CODES.REL DATA.REL SHARED.REL
@@ -22,7 +32,7 @@ asm-tools: $(COMS)
.phony: prerequisites
-TOOLS := M80 L80 objcopy
+TOOLS := N80 LK80
prerequisites:
@mkdir -p ../../bin/tools
@@ -39,31 +49,29 @@ $(COMS): \
DATA.REL \
SHARED.REL
- echo $(patsubst %.COM,%.MAC,$@)
- M80 =$(patsubst %.COM,%,$@)
- L80 /P:100,CODES,DATA,$(patsubst %.COM,%,$@),SHARED,$(patsubst %.COM,%,$@)/n/x/y/e
- $(call hex2bin,$(patsubst %.COM,%.HEX,$@),$@)
+ $(call assemble,$(patsubst %.COM,%.MAC,$@))
+ @$(LK80) --output-file $@ --code 0100h CODES.REL DATA.REL $(patsubst %.COM,%.REL,$@) SHARED.REL
$(call copy_to_bin,$@)
SHARED.REL: \
SHARED.MAC \
$(INCS)
- M80 -p ../kernel =SHARED
+ $(call assemble,SHARED.MAC)
CODES.REL: \
../kernel/codes.mac \
$(INCS)
- M80 -p ../kernel =CODES
+ $(call assemble,../kernel/codes.mac)
DATA.REL: \
../kernel/data.mac \
$(INCS)
- M80 -p ../kernel =DATA
+ $(call assemble,../kernel/data.mac)
.PHONY: clean
clean:
- for ext in REL SYM HEX COM; do find . -type f -name "*.$$ext" -delete; done
+ for ext in REL rel SYM sym HEX COM; do find . -type f -name "*.$$ext" -delete; done
diff --git a/source/tools/SHARED.MAC b/source/tools/SHARED.MAC
index 5e088fde..3f666d87 100644
--- a/source/tools/SHARED.MAC
+++ b/source/tools/SHARED.MAC
@@ -1,7 +1,7 @@
title MSX-DOS 2.50 - Common file for utility applications
.Z80
- include MACROS.INC
+ include macros.inc
;-----------------------------------------------------------------------------
;
@@ -98,7 +98,7 @@ EXTPAR:: or a ;Terminate with error if A = 0
push de
push ix
ld ix,0 ;IXl: Number of parameters
- ld_ixh_a ;IXh: Parameter to be extracted
+ ld ixh,a ;IXh: Parameter to be extracted
ld hl,81h
PASASPC:
@@ -119,9 +119,9 @@ PASAPAR: ld a,(hl) ;Traverse parameter characters
jr PASAPAR
ENDPNUM:
- ld_a_ixh ;Error if parameter index
+ ld a,ixh ;Error if parameter index
dec a ;is larger that the number of parameters
- cp_ixl
+ cp ixl
jr nc,EXTPERR
ld hl,81h
@@ -131,7 +131,7 @@ PASAP2: ld a,(hl) ;Skip spaces until finding next parameter
inc hl
jr z,PASAP2
- ld_a_ixh ;If it is the desired parameter, extract it.
+ ld a,ixh ;If it is the desired parameter, extract it.
cp B ;Otherwise...
jr z,PUTINDE0
@@ -161,7 +161,7 @@ ENDPUT: xor a
ld (de),a
dec b
- ld_a_ixl
+ ld a,ixl
or a
jr FINEXTP
EXTPERR:
diff --git a/source/tools/compile.bat b/source/tools/compile.bat
deleted file mode 100644
index ec9240fd..00000000
--- a/source/tools/compile.bat
+++ /dev/null
@@ -1,43 +0,0 @@
-@echo off
-cls
-
-copy ..\kernel\macros.inc
-copy ..\kernel\const.inc
-copy ..\kernel\codes.mac
-copy ..\kernel\data.mac
-for %%A in (CODES,DATA,SHARED) do cpm32 M80 =%%A
-del codes.mac
-del data.mac
-
-if .%1==. (
-set files=*.mac
-) else (
-set files=%1.mac
-)
-
-if not exist ..\..\bin\tools md ..\..\bin\tools
-
-for /r %%f in (%files%) do (
-
-if not %%~nf==SHARED (
-echo .
-echo ***
-echo *** %%~nf
-echo ***
-echo .
-cpm32 M80 =%%~nf
-cpm32 l80 /P:100,CODES,DATA,%%~nf,SHARED,%%~nf/n/x/y/e
-if exist %%~nf.hex (
-hex2bin -s 100 %%~nf.hex
-if exist %%~nf.COM del %%~nf.COM
-ren %%~nf.bin %%~nf.COM
-copy %%~nf.COM ..\..\bin\tools
-) else (echo *** ERROR: %%~nf not compiled)
-)
-)
-
-del *.bin
-del *.hex
-del *.rel
-rem del *.sym
-:end
diff --git a/source/tools/compile_vfd.bat b/source/tools/compile_vfd.bat
deleted file mode 100644
index b660b349..00000000
--- a/source/tools/compile_vfd.bat
+++ /dev/null
@@ -1,48 +0,0 @@
-@echo off
-cls
-
-copy ..\msxdos25\macros.inc
-copy ..\msxdos25\const.inc
-copy ..\msxdos25\codes.mac
-copy ..\msxdos25\data.mac
-for %%A in (CODES,DATA,SHARED) do cpm32 M80 =%%A
-del codes.mac
-del data.mac
-
-vfd ulink 0
-vfd link 0 x /L
-vfd open 0: utils.dsk /w /720
-
-if .%1==. (
-set files=*.mac
-) else (
-set files=%1.mac
-)
-
-for /r %%f in (%files%) do (
-
-if not %%~nf==SHARED (
-echo .
-echo ***
-echo *** %%~nf
-echo ***
-echo .
-cpm32 M80 =%%~nf
-cpm32 l80 /P:100,CODES,DATA,%%~nf,SHARED,%%~nf/n/x/y/e
-if exist %%~nf.hex (
-hex2bin -s 100 %%~nf.hex
-if exist %%~nf.COM del %%~nf.COM
-ren %%~nf.bin %%~nf.COM
-copy %%~nf.COM ..\..\bin
-copy %%~nf.COM x:\
-) else (echo *** ERROR: %%~nf not compiled)
-)
-)
-
-vfd close 0
-vfd ulink 0
-del *.bin
-del *.hex
-del *.rel
-del *.sym
-:end