From ef0ceb6f3afabffc82385cb840aa647ead1cba2a Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Tue, 17 Oct 2023 15:33:33 -0700 Subject: [PATCH 1/9] Nextor Driver --- source/kernel/Makefile | 27 +- source/kernel/drivers/Tang/chgbnk.mac | 39 + source/kernel/drivers/Tang/driver.mac | 1425 +++++++++++++++++++++++++ 3 files changed, 1490 insertions(+), 1 deletion(-) create mode 100644 source/kernel/drivers/Tang/chgbnk.mac create mode 100644 source/kernel/drivers/Tang/driver.mac diff --git a/source/kernel/Makefile b/source/kernel/Makefile index 6692ca78..2cdead45 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -64,7 +64,7 @@ endef ### MAIN RULE ### ################### -all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm +all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm tang TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc $(MKNEXROM) dd @@ -593,3 +593,28 @@ clean: rm -f bank0/b0lab*.inc rm -f bank2/b2labels.inc rm -f bank4/b4rdlabs.inc + +### Tang + +tang: drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM + +drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM: \ + nextor_base.dat \ + drivers/Tang/driver.bin \ + drivers/Tang/chgbnk.bin \ + 256.bytes + + cat 256.bytes drivers/Tang/driver.bin > drivers/Tang/_driver.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/Tang/_driver.bin /m:drivers/Tang/chgbnk.bin + $(call copy_to_bin,$@) + cp $@ /mnt/d/src/fpga/wonderTANG/WonderTANG/fpga/src/roms/Nextor-$(VERSION).WonderTANG.ROM.bin + +drivers/Tang/chgbnk.bin: \ + drivers/Tang/chgbnk.mac + + $(call assemble,drivers/Tang/chgbnk.mac,--build-type abs --output-file-extension bin) + +drivers/Tang/driver.bin: \ + drivers/Tang/driver.mac + + $(call assemble,drivers/Tang/driver.mac,--build-type abs --output-file-extension bin) \ No newline at end of file diff --git a/source/kernel/drivers/Tang/chgbnk.mac b/source/kernel/drivers/Tang/chgbnk.mac new file mode 100644 index 00000000..9fb5d6c3 --- /dev/null +++ b/source/kernel/drivers/Tang/chgbnk.mac @@ -0,0 +1,39 @@ + .z80 + title CHGBNK - Bank Switching Module for the ASCII16 mapper +; +;----------------------------------------------------------------------- +; +; This is a manufacturer-supplied bank switching module. This module +; is placed at the tail of every local banks of DOS2-ROM. +; +; This is a sample program. DOS2-ROM has no assumptions on the +; mechanism of bank switching, for example, where the bank register is, +; which bits are assigned to bank switching, etc. The bank register +; does not have to be readable. +; +; Entry: Acc = 0 --- switch to bank #0 +; 1 --- switch to bank #1 +; 2 --- switch to bank #2 +; 3 --- switch to bank #3 +; 4 --- switch to bank #4 +; 5 --- switch to bank #5 +; 6 --- switch to bank #6 +; 7 --- switch to bank #7 +; Exit: None +; +; Only AF can be modified +; +; *** CODE STRTS HERE *** CAUTION!! This must be the first module. +; +BNKREG equ 6000h ;System IC version + + org 7FD0h + +CHGBNK: + + ld (BNKREG),a + ret +; + defs (8000h-7FD0h)-($-CHGBNK),0FFh +; + end diff --git a/source/kernel/drivers/Tang/driver.mac b/source/kernel/drivers/Tang/driver.mac new file mode 100644 index 00000000..3a2b12de --- /dev/null +++ b/source/kernel/drivers/Tang/driver.mac @@ -0,0 +1,1425 @@ + ; Device-based driver for the Tang Nano 20k interface for Nextor + ; + ; Version by Luis Antoniosi + ; Based on version 0.1 by Konamiman + + org 4100h + +DRV_START: + + .print1 MSX Tang uSD Driver + +;----------------------------------------------------------------------------- +; +; Driver configuration constants +; + +;Driver type: +; 0 for drive-based +; 1 for device-based + +DRV_TYPE equ 1 + +;Hot-plug devices support (device-based drivers only): +; 0 for no hot-plug support +; 1 for hot-plug support + +DRV_HOTPLUG equ 0 + +DEBUG equ 0 ;Set to 1 for debugging, 0 to normal operation + +;Driver version + +VER_MAIN equ 1 +VER_SEC equ 0 +VER_REV equ 0 + + +;----------------------------------------------------------------------------- +; +; SD Controller registers and bit definitions + +SDC_ENABLE equ 7E00h ; wo: 1: enable SDC register, 0: disable +SDC_CMD equ SDC_ENABLE+1 ; wo: cmd to SDC fpga: 1=read, 2=write +SDC_STATUS equ SDC_CMD+1 ; ro: SDC status bits +SDC_SADDR equ SDC_STATUS+1 ; wo: 4 bytes: sector addr for read/write +SDC_C_SIZE equ SDC_SADDR+4 ; ro: 3 bytes: device size blocks +SDC_C_SIZE_MULT equ SDC_C_SIZE+3 ; ro: 3 bits size multiplier +SDC_RD_BL_LEN equ SDC_C_SIZE_MULT+1 ; ro: 4 bits block length +SDC_CTYPE equ SDC_RD_BL_LEN+1 ; ro: SDC Card type: 0=unknown, 1=SDv1, 2=SDv2, 3=SDHCv2 +SDC_MID equ SDC_CTYPE+1 +SDC_OID equ SDC_MID+1 +SDC_PNM equ SDC_OID+2 +SDC_PSN equ SDC_PNM+5 +SDC_CRC16 equ SDC_PSN+4 + +SDC_SDATA equ 7C00h ; rw: 7C00h-7Dff - sector transfer area + +SDC_BUSY equ 080h +SDC_CRC equ 001h +SDC_TIMEOUT equ 002h + +SDC_READ equ 001h +SDC_WRITE equ 002h +SDC_INIT equ 080h +;----------------------------------------------------------------------------- +; +; Standard BIOS and work area entries + +CHPUT equ 00A2h ;Character output +CHGET equ 009Fh +INITXT equ 006Ch +CLS equ 0848H +MSXVER equ 002DH + +LINL40 equ 0F3AEh ; Width +LINLEN equ 0F3B0h +;----------------------------------------------------------------------------- +; +; Work area definition +; +;+0-3: Device size in sectors +;+4-7: current sector r/w +;----------------------------------------------------------------------------- +; +; Error codes for DEV_RW and DEV_FORMAT +; + +.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 +;----------------------------------------------------------------------------- +; +; Routines 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,bank +; ld hl,address +; ld ix,RDBANK +; call CALBNK + +RDBANK equ 403Ch + + +;* This routine temporarily switches kernel bank 0/3, +; then jumps to CALBAS in MSX BIOS. +; This is necessary so that kernel bank is correct in case of BASIC error. + +CALBAS equ 403Fh + + +;* Call a routine in another bank. +; Must be used if the driver spawns across more than one bank. +; Input: A = bank +; IX = routine address +; AF' = AF for the routine +; BC, DE, HL, IY = input for the 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,slot +; ex af,af' +; xor a +; ld ix,GWORK +; call CALBNK + +GWORK equ 4045h + + +;* Call a routine in the driver bank. +; Input: (BK4_ADD) = routine address +; AF, BC, DE, HL, IY = input for the routine +; +; Calls a routine in the driver bank. This routine is the same as CALBNK, +; except that the routine address is passed in address BK4_ADD (#F2ED) +; instead of IX, and the bank number is always 5. This is useful when used +; in combination with CALSLT to call a driver routine from outside +; the driver itself. +; +; Note that register IX can't be used as input parameter, it is +; corrupted before reaching the invoked code. + +CALDRV equ 4048h + + +;----------------------------------------------------------------------------- +; +; 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) + + db 1+(2*DRV_HOTPLUG)+4 + +;Reserved byte + db 0 + +;Driver name + +DRV_NAME: + db "WonderTANG! uSD Driver" + ds 32-($-DRV_NAME)," " + +;Jump table + + 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 + + jp DEV_RW + jp DEV_INFO + jp DEV_STATUS + jp LUN_INFO + jp DEV_FORMAT + jp DEV_CMD + + +;----------------------------------------------------------------------------- +; +; 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, it is called twice: +; +; 1) First execution, for information gathering. +; Input: +; A = 0 +; B = number of available drives (drive-based drivers only) +; 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 +; (255 if device-based driver, unless 4 is pressed at boot) +; +; 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: + ;--- If first execution, just inform that no work area is needed + ; (the 8 bytes in SLTWRK are enough) + + or a + ld hl,0 + ld a,0 + ret z ;Note that Cy is 0 (no interrupt hooking needed) + + ld a,(MSXVER) + cp 1 ; > MSX 2 + jr c,MSX1 + ld a,80 + jr SETSCRN +MSX1: + ld a,40 +SETSCRN: + ld (LINL40),a + call INITXT + + ld de,INFO_S + call PRINT + + ld de,SEARCH_S + call PRINT + + call MY_GWORK + call SDC_ON + ld a,SDC_INIT + ld (SDC_CMD),a + + ld (ix),0 ; clear device data + +WAIT_RESET: + ld de,2047 ;Timeout +WAIT_RESET1: + ld a,0 + cp e + jr nz,WAIT_DOT ;Print dots while waiting +; ld a,46 +; call CHPUT +WAIT_DOT: + call CHECK_ESC + jp c,INIT_NO_DEV + ld b,255 +WAIT_RESET2: + ld a,(SDC_STATUS) + and SDC_BUSY + jr z,WAIT_RESET_END ;Wait for BSY to clear and DRDY to set + djnz WAIT_RESET2 + dec de + ld a,d + or e + jr nz,WAIT_RESET1 + jp INIT_NO_DEV +WAIT_RESET_END: + + ld a,(SDC_CTYPE) + or a + jp z,INIT_NO_DEV + + ld de,SDV1 + cp 1 + jr z,PRINT_CTYPE + ld de,SDV2 + cp 2 + jr z,PRINT_CTYPE + ld de,SDHCV2 + cp 3 + jr z,PRINT_CTYPE + ld de,UNKNOWN + +PRINT_CTYPE: ; print card type + call PRINT + + ld de,CRLF_S + call PRINT + + ld hl,SDC_C_SIZE + ld e,(hl) + inc hl + ld d,(hl) + inc hl + ld c,(hl) ; c:de = c_size + inc hl + + ld hl,1 + add hl,de + ex de,hl + + ld a,0 + adc a,c ; c:de = c_size + 1 + ld c,a + jr nc,NO_OVL + ld a,1 ; overflow + jr OVL +NO_OVL: + xor a +OVL: + + ex af,af' ; preserve msb + push af + + ld hl,SDC_C_SIZE_MULT + ld b,(hl) ; b = c_size_mult + inc hl + inc b + inc b ; b = c_size_mult + 2 + + ld a,(hl) ; a = read_bl_len + + add a,b + sub 9 + jr z,NO_SHIFT + ld b,a ; b = read_bl_len + c_size_mult + 2 - 9 + + pop af + ex af,af' ; restore msb +CALC_SIZE: + sla e + rl d + rl c + rl a + djnz CALC_SIZE + jr ST_SIZE +NO_SHIFT: + pop af + ex af,af' ; restore msb + +ST_SIZE: + + ld (ix+0),e ; store card size in sectors (512 bytes) in work area (32-bit) + ld (ix+1),d + ld (ix+2),c + ld (ix+3),a + + ld de,CRLF_S + call PRINT + +;;;; + + ; wait some time + ld b,0 +outer: + push bc + ld b,0 +inner: + nop + push ix + pop ix + djnz inner + pop bc + djnz outer + + + jr DRV_INIT_END + +INIT_NO_DEV: + call CHECK_ESC + jr c,INIT_NO_DEV + + ld de,CRLF_S + call PRINT + ld de,NODEVS_S + call PRINT + + xor a + ld (ix+0),a + ld (ix+1),a + ld (ix+2),a + ld (ix+3),a + + ;--- End of the initialization procedure +DRV_INIT_END: + ;;;;;;;;;;;;;;;;;;; +; ld de,CRLF_S +; call PRINT +; ld de,CRLF_S +; call PRINT +; xor a +; ld (ix+4),a +; ld (ix+5),a +; ld (ix+6),a +; ld (ix+7),a + + +; next_sect: +; ld b,0 +; ld a,(ix+4) +; ld (SDC_SADDR+0),a +; add 1 ; increment sector +; ld (ix+4),a ; store back incremented +; ld a,(ix+5) +; ld (SDC_SADDR+1),a +; adc b +; ld (ix+5),a +; ld a,(ix+6) +; ld (SDC_SADDR+2),a +; adc b +; ld (ix+6),a +; ld a,(ix+7) +; ld (SDC_SADDR+3),a +; adc b +; ld (ix+7),a +; ld a,SDC_READ +; ld (SDC_CMD),a +; call WAIT_CMD_RDY + +; ld hl,SDC_SDATA ; src data + +; ld b,19 +; lines: +; push bc +; ld b,26 +; rows: +; ld a,(hl) +; inc hl +; call HEXPUT +; ld a,' ' +; call CHPUT +; djnz rows +; ld de,CRLF_S +; call PRINT +; pop bc +; djnz lines +; ld b,18 +; lastrow: +; ld a,(hl) +; inc hl +; call HEXPUT +; ld a,' ' +; call CHPUT +; djnz lastrow +; ld de,CRLF_S +; call PRINT +; call CHGET +; cp 27 +; jp nz,next_sect +;----------------------------------------------------------------------------- +; +; 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): + + ;;;;;;;;;;;;;;;;; + + call SDC_OFF + ret + +; HEXPUT: +; push af +; push bc +; ld b,a +; srl a +; srl a +; srl a +; srl a +; call HEXCHAR +; ld a,b +; and 00fh +; call HEXCHAR +; pop bc +; pop af +; ret + +; HEXCHAR: +; cp 10 +; jr c,digit +; add 'A'-10 +; jp CHPUT +; digit: +; add '0' +; jp CHPUT + + +BINTOHEX: + ld c,a + srl a + srl a + srl a + srl a + call HEXNIBLE + ld b,a + ld a,c + and 00fh + call HEXNIBLE + ld c,a + ret +HEXNIBLE: + cp 10 + jr c,ISDIGT + add 'A'-10 + ret +ISDIGT: + add '0' + 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 statement ("CALL") handler. +; Works the expected way, except that CALBAS in kernel page 0 +; must be called instead of CALBAS in MSX BIOS. + +DRV_BASSTAT: + scf + ret + + +;----------------------------------------------------------------------------- +; +; BASIC expanded device handler. +; Works the expected way, except that CALBAS in kernel page 0 +; must be called instead of CALBAS in MSX BIOS. + +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: + ld a,1 + ret + +;===== +;===== BEGIN of DEVICE-BASED specific routines +;===== + +;----------------------------------------------------------------------------- +; +; 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/written + +DEV_RW: + jp c,WRSECT +RDSECT: + + or a ;Check device index + jp z,RW_ERR1 + cp 2 + jp nc,RW_ERR1 + + call MY_GWORK + + call SDC_ON + call WAIT_CMD_RDY + ld a,(SDC_STATUS) + and SDC_BUSY + jp nz,RW_BUSY + + ld a,(de) + inc de + ld (ix+4),a + ld a,(de) + inc de + ld (ix+5),a + ld a,(de) + inc de + ld (ix+6),a + ld a,(de) + inc de + ld (ix+7),a ; current sector + + ex de,hl ; de = destination + push bc ; nr of sectors + +RD_LOOP: + push bc ; nr of sectors + ld b,0 + ld a,(ix+4) + ld (SDC_SADDR+0),a + add 1 ; increment sector + ld (ix+4),a ; store back incremented + ld a,(ix+5) + ld (SDC_SADDR+1),a + adc b + ld (ix+5),a + ld a,(ix+6) + ld (SDC_SADDR+2),a + adc b + ld (ix+6),a + ld a,(ix+7) + ld (SDC_SADDR+3),a + adc b + ld (ix+7),a + ld a,SDC_READ + ld (SDC_CMD),a + call WAIT_CMD_RDY + jr c,R_ERR_LOOP + ld bc,512 + ld hl,SDC_SDATA ; src data + ldir + pop bc + djnz RD_LOOP + pop bc ; nr of sectors + call SDC_OFF + + ld a,0 + or a + ret + + +R_ERR_LOOP: + ld a,(SDC_STATUS) + ld e,a ; save stat + call SDC_OFF + pop bc + ld d,b + pop bc + ld a,d + sub b + ld b,a ; sectors written + ld e,a + and SDC_TIMEOUT + jr nz,R_TIMEOUT + ld a,.DISK + scf + ret +R_TIMEOUT: + ld a,.NRDY + scf + ret + +W_ERR_LOOP: + ld a,(SDC_STATUS) + ld e,a ; save stat + call SDC_OFF + pop bc + ld d,b + pop bc + ld a,d + sub b + ld b,a ; sectors written + ld e,a + and SDC_CRC + jr nz,W_WRERR + ld a,.DISK + scf + ret +W_WRERR: + + ;ld a,0f3h + ;call SETBORDER + + ld a,.WRERR + scf + ret + +RW_DISK: + + ;ld a,0fDh + ;call SETBORDER + + ld b,.DISK + jr RW_ERR +RW_BUSY: + + ;ld a,0f5h + ;call SETBORDER + + ld b,.NRDY + jr RW_ERR +RW_ERR1: + + ;ld a,0f7h + ;call SETBORDER + + ld b,.IDEVL +RW_ERR: + + ;ld a,0feh + ;call SETBORDER + + call SDC_OFF + ld a,b + ld b,0 + scf + ret + +WRSECT: + or a ;Check device index + jr z,RW_ERR1 + cp 2 + jr nc,RW_ERR1 + + call MY_GWORK + + call SDC_ON + call WAIT_CMD_RDY + ld a,(SDC_STATUS) + and SDC_BUSY + jr nz,RW_BUSY + + ld a,(de) + inc de + ld (ix+4),a + ld a,(de) + inc de + ld (ix+5),a + ld a,(de) + inc de + ld (ix+6),a + ld a,(de) + inc de + ld (ix+7),a ; current sector + + push bc ; nr of sectors + +WR_LOOP: + push bc ; nr of sectors + ld b,0 + ld a,(ix+4) + ld (SDC_SADDR+0),a + add 1 ; increment sector + ld (ix+4),a + ld a,(ix+5) + ld (SDC_SADDR+1),a + adc b + ld (ix+5),a + ld a,(ix+6) + ld (SDC_SADDR+2),a + adc b + ld (ix+6),a + ld a,(ix+7) + ld (SDC_SADDR+3),a + adc b + ld (ix+7),a + + ld bc,512 + ld de,SDC_SDATA ; hl = src data + ldir + + ld a,SDC_WRITE + ld (SDC_CMD),a + call WAIT_CMD_RDY + jp c,W_ERR_LOOP + + pop bc + djnz WR_LOOP + pop bc ; nr of sectors + call SDC_OFF + + ld a,0 + or a + ret + + + + +;----------------------------------------------------------------------------- +; +; 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 8. 1 if the device has no logical +; drives (which is functionally equivalent to having only one). +;+1 (1): Flags, always zero +; +; 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: + + or a ;Check device index + jr z,DEV_INFO_ERR1 + cp 2 + jr nc,DEV_INFO_ERR1 + + call MY_GWORK + + call SDC_ON + + ld a,b + or a + jr z,BASIC_INFO + cp 1 + jr z,MANUFACTURER + cp 2 + jr z,DEVICE_NAME + cp 3 + jr z,SERIAL_NUMBER + +MANUFACTURER: +DEV_INFO_ERR2: + call SDC_OFF + ld a,2 + ret + +BASIC_INFO: + + ld a,1 + ld (hl),a + inc hl + xor a + ld (hl),a +DEV_INFO_OK: + xor a + call SDC_OFF + ret + +DEVICE_NAME: + ex de,hl + ld hl,SDC_OID + ld b,7 +COPNAME: + ld a,(hl) + cp 32 + jr c,NONASC + or 128 + jr nz,NONASC + jr STORASC +NONASC: + ld a,' ' +STORASC: + ld (de),a + inc de + inc hl + djnz COPNAME + ex de,hl + ld b,64-7 +STR_PAD: + ld a,' ' + ld (hl),a + inc hl + djnz STR_PAD + + jr DEV_INFO_OK + +SERIAL_NUMBER: + + ld de,SDC_PSN+3 + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld b,64-8 + jr STR_PAD + ;--- Termination with error + +DEV_INFO_ERR1: + call SDC_OFF + ld a,1 + 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. + +DEV_STATUS: + call CHECK_DEV_LUN + jr c,DEV_STAT_ERR + + ld a,(ix+0) + or a + jr nz,DEV_OK + ld a,(ix+1) + or a + jr nz,DEV_OK + ld a,(ix+2) + or a + jr nz,DEV_OK + ld a,(ix+3) + or a + jr nz,DEV_OK +DEV_STAT_ERR: + ld a,0 + ret + +DEV_OK: + ld a,1 + 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 (0, if not a hard disk) +;+10 (1): Number of heads (0, if not a hard disk) +;+11 (1): Number of sectors per track (0, if not a hard disk) + +LUN_INFO: + + call CHECK_DEV_LUN + jr c,LUN_INFO_ERROR + + call MY_GWORK + + xor a + ld (hl), a ; block device + inc hl + ld (hl),0 + inc hl + ld (hl),2 ; sector size + inc hl + ld a,(ix+0) + ld (hl),a + inc hl + ld a,(ix+1) + ld (hl),a + inc hl + ld a,(ix+2) + ld (hl),a + inc hl + ld a,(ix+3) + ld (hl),a ; total of sectors + inc hl + xor a + ld (hl),a ; medium flags + inc hl + ld (hl),a ; + inc hl + ld (hl),a ; num of cyls + inc hl + ld (hl),a ; num of heads + inc hl + ld (hl),a ; num of sectors per track + + xor a + ret + +LUN_INFO_ERROR: + ld a,1 + ret + + +;----------------------------------------------------------------------------- +; +; 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 +;===== + + +;======================= +; Subroutines +;======================= + +;----------------------------------------------------------------------------- +; +; Enable or disable the SPI registers + +SDC_ON: + ld a,1 + ld (SDC_ENABLE),a + ret + +SDC_OFF: + xor a + ld (SDC_ENABLE),a + ret + +;----------------------------------------------------------------------------- +; +; Wait the BSY flag to clear and RDY flag to be set +; if we wait for more than 30s, send a soft reset to IDE BUS +; if the soft reset didn't work after 30s return with error +; +; Input: Nothing +; Output: Cy=1 if timeout after soft reset +; Preserves: DE and BC + +WAIT_CMD_RDY: + push de + push bc + ld de,2047 ;8142 ;Limit the wait to 30s +WAIT_RDY1: + ld b,255 +WAIT_RDY2: + ld a,(SDC_STATUS) + and SDC_BUSY+SDC_TIMEOUT+SDC_CRC + or a + jr z,WAIT_RDY_END + djnz WAIT_RDY2 + dec de + ld a,d + or e + jr nz,WAIT_RDY1 + scf +WAIT_RDY_END: + pop bc + pop de + ret + +;----------------------------------------------------------------------------- +; +; Read the keyboard matrix to see if ESC is pressed +; Output: Cy = 1 if pressed, 0 otherwise + +CHECK_ESC: + ld b,7 + in a,(0AAh) + and 11110000b + or b + out (0AAh),a + in a,(0A9h) + bit 2,a + jr nz,CHECK_ESC_END + scf +CHECK_ESC_END: + 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 + +;----------------------------------------------------------------------------- +; +; Check the device index and LUN +; Input: A = device index, B = lun +; Output: Cy=0 if OK, 1 if device or LUN invalid +; IX = Work area for the device +; Modifies F, C + +CHECK_DEV_LUN: + or a ;Check device index + scf + ret z + cp 2 + ccf + ret c + + ld a,b ;Check LUN number + cp 1 + scf + ret nz + + or a + ret + + +;----------------------------------------------------------------------------- +; +; Obtain the work area address for the driver +; Input: A=1 to obtain the work area for the master, 2 for the slave +; Preserves A + +MY_GWORK: + xor a + EX AF,AF' + XOR A + LD IX,GWORK + call CALBNK + ret + +;SETBORDER: +; out (099h),a +; ld a,087h +; out (099h),a +; ret + +;======================= +; Strings +;======================= + +INFO_S: + db "WonderTANG! SMS v" + db VER_MAIN+"0",".",VER_SEC+"0",".",VER_REV+"0",13,10 + db "Synthetic Juice for your MSX",13,10,13,10 + db "2023 Luis Antoniosi",13,10 + db "Beautiful British Columbia",13,10 + db "Canada",13,10,13,10 + db "SS0: Nextor BIOS + MicroSD",13,10 + db "SS1: FM ROM + OPLL",13,10 + db "SS2: Super MegaRAM SCC+ 2MB",13,10 + db "SS3: Memory Mapper 4MB",13,10 + db "---: SMS VDP 16KB ",13,10,13,10,0 + +SEARCH_S: + db "Searching: ",0 + +NODEVS_S: + db "Not found",13,10,0 + +UNKNOWN: + db "UNKOWN",0 +SDV1: + db "SDV1",0 +SDV2: + db "SDV2",0 +SDHCV2: + db "SDHCV2",0 + +CRLF_S: + db 13,10,0 + + +;----------------------------------------------------------------------------- +; +; Padding up to the required driver size + +DRV_END: + + ds 3ED0h-(DRV_END-DRV_START) + + end From 88374eb575a7d2df1a095fcf338e5b51b222e0de Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Sat, 4 Nov 2023 17:52:54 -0700 Subject: [PATCH 2/9] Replace undocumented op-codes (HC-95 turbo mode support) --- source/kernel/Makefile | 27 +- source/kernel/bank0/init.mac | 8 +- source/kernel/bank1/dosinit.mac | 9 +- source/kernel/bank4/partit.mac | 38 +- source/kernel/condasm.inc | 1 + source/kernel/drivers/SunriseIDE/sunride.asm | 35 +- source/kernel/drivers/Tang/chgbnk.mac | 39 + source/kernel/drivers/Tang/driver.mac | 1425 ++++++++++++++++++ source/kernel/drv.mac | 63 +- source/kernel/macros.inc | 214 ++- source/tools/MAPDRV.MAC | 20 +- source/tools/SHARED.MAC | 10 +- 12 files changed, 1808 insertions(+), 81 deletions(-) create mode 100644 source/kernel/drivers/Tang/chgbnk.mac create mode 100644 source/kernel/drivers/Tang/driver.mac diff --git a/source/kernel/Makefile b/source/kernel/Makefile index 6692ca78..d3339ded 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -64,7 +64,7 @@ endef ### MAIN RULE ### ################### -all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm +all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm tang TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc $(MKNEXROM) dd @@ -593,3 +593,28 @@ clean: rm -f bank0/b0lab*.inc rm -f bank2/b2labels.inc rm -f bank4/b4rdlabs.inc + +### Tang + +tang: drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM + +drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM: \ + nextor_base.dat \ + drivers/Tang/driver.bin \ + drivers/Tang/chgbnk.bin \ + 256.bytes + + cat 256.bytes drivers/Tang/driver.bin > drivers/Tang/_driver.bin + $(MKNEXROM) nextor_base.dat $@ /d:drivers/Tang/_driver.bin /m:drivers/Tang/chgbnk.bin + $(call copy_to_bin,$@) + cp $@ /mnt/d/src/fpga/wonderTANG/WonderTANG/fpga/src/roms/Nextor-$(VERSION).WonderTANG-HC95.ROM.bin + +drivers/Tang/chgbnk.bin: \ + drivers/Tang/chgbnk.mac + + $(call assemble,drivers/Tang/chgbnk.mac,--build-type abs --output-file-extension bin) + +drivers/Tang/driver.bin: \ + drivers/Tang/driver.mac + + $(call assemble,drivers/Tang/driver.mac,--build-type abs --output-file-extension bin) \ No newline at end of file diff --git a/source/kernel/bank0/init.mac b/source/kernel/bank0/init.mac index 9bde2a32..97423cc5 100644 --- a/source/kernel/bank0/init.mac +++ b/source/kernel/bank0/init.mac @@ -2143,7 +2143,7 @@ scan_loop: ld e,(hl) inc hl ld d,(hl) - db 0FDh,67h ;LD IYh,A + LD_IYH_N a ;db 0FDh,67h ;LD IYh,A push de pop ix call CALSLT @@ -2173,10 +2173,10 @@ TNEX_LOOP: push hl push bc and 10001111b - db 0FDh,67h ;LD IYh,A + LD_IYH_N a ;db 0FDh,67h ;LD IYh,A ld a,(MASTER_SLOT##) - db 0FDh,0BCh ;CP IYh - db 0FDh,7Ch ;LD A,IYh + CP_IYH ;db 0FDh,0BCh ;CP IYh + LD_N_IYH a ;db 0FDh,7Ch ;LD A,IYh ld h,40h ld ix,DV_TIRQ## call call_drv diff --git a/source/kernel/bank1/dosinit.mac b/source/kernel/bank1/dosinit.mac index 3ac53654..d9ecd003 100644 --- a/source/kernel/bank1/dosinit.mac +++ b/source/kernel/bank1/dosinit.mac @@ -1564,7 +1564,8 @@ _U_CALLRAM: ex af,af ... < call _GET_P1 > push af - ld a,iyl + LD_N_IYL A + ;ld a,iyl ... < call _PUT_P1 > ex af,af call CALSLT## @@ -1651,7 +1652,7 @@ _U_CALLRAM2: dec ix dec ix push ix - ld iyl,e + LD_IYL_N e ;ld iyl,e ld a,d and 00111111b @@ -1675,13 +1676,13 @@ _U_CALLRAM2: ld bc,(MAP_TAB##) add hl,bc ld a,(hl) ;A = Slot to call - ld iyh,a + LD_IYH_N a ;ld iyh,a ex af,af' exx inc sp inc sp - jr _U_CALLRAM + jp _U_CALLRAM ; ;----------------------------------------------------------------------------- ; diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac index 94c0c441..ff4670d6 100644 --- a/source/kernel/bank4/partit.mac +++ b/source/kernel/bank4/partit.mac @@ -209,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_N a ;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_N a ;ld iyh,a ;extended partitions. push iy ld a,(ix+POFF_PSTART+2) - ld iyl,a + LD_IYL_N a ;ld iyl,a ld a,(ix+POFF_PSTART+3) - ld iyh,a + LD_IYH_N a ;ld iyh,a push iy ;=== Loop for extended partition search === @@ -355,7 +355,7 @@ DEV_READ: push de push hl - ld iyh,c + LD_IYH_N c ;ld iyh,c ld ix,DEV_RW## ld (BK4_ADD##),ix ld ix,CALDRV## @@ -597,7 +597,7 @@ AUTODRV_DRVLOOP: ; A = Relative drive for the driver ld c,a - ld a,iyl + LD_N_IYL A ;ld a,iyl ld (ix+UD1_SLOT##),a ;Set slot number in table entry ld a,c ld (ix+UD1_RELATIVE_DRIVE##),a @@ -607,7 +607,7 @@ AUTODRV_DRVLOOP: push iy push ix - ld a,iyh ;ld a,(iy+4) + LD_N_IYH a ;ld a,iyh ;ld a,(iy+4) and 00000100b ;Driver provides config? jr z,AUTODRV_DRVL2 push ix @@ -708,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_N a ;ld iyh,a ld c,a ld a,(KER250##) @@ -1067,7 +1067,7 @@ AA_CHKDUP_OK: ;--- Obtain device information ld a,(ix+AAD_DRIVER_SLOT) - ld iyh,a + LD_IYH_N a ;ld iyh,a ld hl,LUN_INFO## ld (BK4_ADD##),hl ld hl,($SECBUF##) @@ -1566,7 +1566,7 @@ AA_WSEC: AA_RSEC: or a AA_DOSEC: - ld iyh,c + LD_IYH_N c ;ld iyh,c ld hl,DEV_RW## ld (BK4_ADD##),hl ld c,b @@ -2482,7 +2482,7 @@ F_CDRVR_GO: ret nz ld (BK4_ADD##),de - ld iyh,c + LD_IYH_N c ;ld iyh,c ld l,(ix) ld h,(ix+1) push hl @@ -2630,10 +2630,10 @@ UNMAP_LOOP: inc hl ld h,(hl) ld l,a - cp iyl + CP_IYL ;cp iyl jr nz,UNMAP_OK1 ld a,h - cp iyh + CP_IYH ;cp iyh jr z,UNMAP_NEXT2 ;It is the unit not to be unassigned UNMAP_OK1: @@ -3084,7 +3084,7 @@ MAP_SPECIFIC: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - ld iyh,c + LD_IYH_N c ;ld iyh,c ld hl,($SECBUF##) ld ix,CALDRV## call CALSLT @@ -3121,7 +3121,7 @@ MAP_SPECIFIC: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - ld iyh,c + LD_IYH_N c ;ld iyh,c ld ix,CALDRV## call CALSLT pop iy @@ -3650,7 +3650,7 @@ MAPDOS1_DEF: push hl push ix ld a,(ix+UD1_SLOT##) - ld iyh,a + LD_IYH_N a ;ld iyh,a call GET_DV_TYPE pop ix pop hl @@ -3815,7 +3815,7 @@ MAPDOS1_CHK_NEXT: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - ld iyh,c + LD_IYH_N c ;ld iyh,c ld hl,($SECBUF##) ld ix,CALDRV## call CALSLT @@ -5954,7 +5954,7 @@ DRVS1LOOP: pop de jr c,DRVS1NEXT ;Skip if not a Nextor kernel - ld iyh,e + LD_IYH_N e ;ld iyh,e call GET_DV_TYPE bit 0,a ;Device-based? jr z,DRVS1NEXT ;No: skip @@ -6192,7 +6192,7 @@ ASK_DRIVE_CONFIG: push de push bc ;BC=DOS mode and relative unit ld a,(ix+UD_SLOT##) - ld iyh,a + LD_IYH_N a ;ld iyh,a ld hl,DV_CONFIG## ld (BK4_ADD##),hl ld a,CFG_DEVLUN diff --git a/source/kernel/condasm.inc b/source/kernel/condasm.inc index 18b06b76..254241f0 100644 --- a/source/kernel/condasm.inc +++ b/source/kernel/condasm.inc @@ -16,5 +16,6 @@ RR equ 0 ;Level of release (0: no release level) ; ;----------------------------------------------------------------------------- ; + .list ; diff --git a/source/kernel/drivers/SunriseIDE/sunride.asm b/source/kernel/drivers/SunriseIDE/sunride.asm index 23cb6bdb..cb9f058f 100644 --- a/source/kernel/drivers/SunriseIDE/sunride.asm +++ b/source/kernel/drivers/SunriseIDE/sunride.asm @@ -6,6 +6,7 @@ ; By FRS ;MASTER_ONLY constant must be defined externally to generate the master-only variant. + INCLUDE ../../macros.inc org 4000h ds 4100h-$,0 ; DRV_START must be at 4100h @@ -1052,8 +1053,8 @@ DEV_RW2: ld b,0 ret DEV_RW_NO0SEC: - ld iyl,e - ld iyh,d + LD_IYL_N e ;ld iyl,e + LD_IYH_N d ;ld iyh,d ld a,(iy+3) and 11110000b jp nz,DEV_RW_NOSEC ;Only 28 bit sector numbers supported @@ -1091,7 +1092,7 @@ DEV_ATA_RD: call CHK_RW_FAULT ret c - ld iyl,b ; iyl=number of blocks + LD_IYL_N b ;ld iyl,b ; iyl=number of blocks ex de,hl ; de=destination address ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) @@ -1108,7 +1109,7 @@ DEV_ATA_WR: ld a,ATACMD.PWRSECTRT ; PIO write sector with retry call PIO_CMD jp c,DEV_RW_ERR - ld iyl,b ; iyl=number of blocks + LD_IYL_N B ;ld iyl,b ; iyl=number of blocks ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) call WRITE_DATA @@ -1126,8 +1127,8 @@ DEV_ATAPI_RW: push de ld e,(ix+DEVINFO.pBASEWRK) ; hl=pointer to WorkArea ld d,(ix+DEVINFO.pBASEWRK+1) - ld iyl,e - ld iyh,d ; iy=WRKAREA pointer + LD_IYL_N e ;ld iyl,e + LD_IYH_N d ;ld iyh,d ; iy=WRKAREA pointer pop de ; Set the block size @@ -1174,7 +1175,7 @@ DEV_ATAPI_RD: push bc push hl push iy - ld iyl,1 ; 1 block + LD_IYL_N 1 ;ld iyl,1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1217,13 +1218,13 @@ DEV_ATAPI_RD: ex de,hl ; de=destination address .loopsector: push bc - ld iyl,c ; get the number of blocks per sector + LD_IYL_N C ;ld iyl,c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr ld hl,IDE_DATA call RUN_HLPR - dec iyl + DEC_IYL ;dec iyl jr nz,.loopblock pop bc djnz .loopsector @@ -1245,7 +1246,7 @@ DEV_ATAPI_WR: push bc push hl push iy - ld iyl,1 ; 1 block + LD_IYL_N 1 ;ld iyl,1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1287,7 +1288,7 @@ DEV_ATAPI_WR: pop bc .loopsector: push bc - ld iyl,c ; get the number of blocks per sector + LD_IYL_N C ;ld iyl,c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr @@ -1295,7 +1296,7 @@ DEV_ATAPI_WR: call RUN_HLPR call CHK_RW_FAULT jr c,.rderr - dec iyl + DEC_IYL ;dec iyl jp nz,.loopblock pop bc djnz .loopsector @@ -1841,13 +1842,13 @@ LUN_NFO_ATAPI: ld a,ATAPICMD.PACKET ; PIO send PACKET command call PIO_CMD - jr c,.errorpop + jp c,.errorpop pop hl push hl ; Source=PCTBUF ld bc,12 ; 12 byte packet push iy - ld iyl,1 + LD_IYL_N 1 ;ld iyl,1 call WRITE_DATA ; Send the packet to the device pop iy jr nc,.rdmediapropr ; No error? Then read media proprieties @@ -1865,7 +1866,7 @@ LUN_NFO_ATAPI: pop de ; Destination=PCTBUFF ld bc,8 ; 8 byte response push iy - ld iyl,1 + LD_IYL_N 1 ;ld iyl,1 call READ_DATA pop iy jr c,LUN_INFO_ERROR @@ -2462,7 +2463,7 @@ READ_DATA: ret c ld hl,IDE_DATA call RUN_HLPR - dec iyl + DEC_IYL ;dec iyl jp nz,.loop ret @@ -2481,7 +2482,7 @@ WRITE_DATA: call RUN_HLPR call CHK_RW_FAULT ret c - dec iyl + DEC_IYL ;dec iyl jp nz,.loop ret diff --git a/source/kernel/drivers/Tang/chgbnk.mac b/source/kernel/drivers/Tang/chgbnk.mac new file mode 100644 index 00000000..9fb5d6c3 --- /dev/null +++ b/source/kernel/drivers/Tang/chgbnk.mac @@ -0,0 +1,39 @@ + .z80 + title CHGBNK - Bank Switching Module for the ASCII16 mapper +; +;----------------------------------------------------------------------- +; +; This is a manufacturer-supplied bank switching module. This module +; is placed at the tail of every local banks of DOS2-ROM. +; +; This is a sample program. DOS2-ROM has no assumptions on the +; mechanism of bank switching, for example, where the bank register is, +; which bits are assigned to bank switching, etc. The bank register +; does not have to be readable. +; +; Entry: Acc = 0 --- switch to bank #0 +; 1 --- switch to bank #1 +; 2 --- switch to bank #2 +; 3 --- switch to bank #3 +; 4 --- switch to bank #4 +; 5 --- switch to bank #5 +; 6 --- switch to bank #6 +; 7 --- switch to bank #7 +; Exit: None +; +; Only AF can be modified +; +; *** CODE STRTS HERE *** CAUTION!! This must be the first module. +; +BNKREG equ 6000h ;System IC version + + org 7FD0h + +CHGBNK: + + ld (BNKREG),a + ret +; + defs (8000h-7FD0h)-($-CHGBNK),0FFh +; + end diff --git a/source/kernel/drivers/Tang/driver.mac b/source/kernel/drivers/Tang/driver.mac new file mode 100644 index 00000000..99ff3517 --- /dev/null +++ b/source/kernel/drivers/Tang/driver.mac @@ -0,0 +1,1425 @@ + ; Device-based driver for the Tang Nano 20k interface for Nextor + ; + ; Version by Luis Antoniosi + ; Based on version 0.1 by Konamiman + + org 4100h + +DRV_START: + + .print1 MSX Tang uSD Driver + +;----------------------------------------------------------------------------- +; +; Driver configuration constants +; + +;Driver type: +; 0 for drive-based +; 1 for device-based + +DRV_TYPE equ 1 + +;Hot-plug devices support (device-based drivers only): +; 0 for no hot-plug support +; 1 for hot-plug support + +DRV_HOTPLUG equ 0 + +DEBUG equ 0 ;Set to 1 for debugging, 0 to normal operation + +;Driver version + +VER_MAIN equ 1 +VER_SEC equ 0 +VER_REV equ 0 + + +;----------------------------------------------------------------------------- +; +; SD Controller registers and bit definitions + +SDC_ENABLE equ 7E00h ; wo: 1: enable SDC register, 0: disable +SDC_CMD equ SDC_ENABLE+1 ; wo: cmd to SDC fpga: 1=read, 2=write +SDC_STATUS equ SDC_CMD+1 ; ro: SDC status bits +SDC_SADDR equ SDC_STATUS+1 ; wo: 4 bytes: sector addr for read/write +SDC_C_SIZE equ SDC_SADDR+4 ; ro: 3 bytes: device size blocks +SDC_C_SIZE_MULT equ SDC_C_SIZE+3 ; ro: 3 bits size multiplier +SDC_RD_BL_LEN equ SDC_C_SIZE_MULT+1 ; ro: 4 bits block length +SDC_CTYPE equ SDC_RD_BL_LEN+1 ; ro: SDC Card type: 0=unknown, 1=SDv1, 2=SDv2, 3=SDHCv2 +SDC_MID equ SDC_CTYPE+1 +SDC_OID equ SDC_MID+1 +SDC_PNM equ SDC_OID+2 +SDC_PSN equ SDC_PNM+5 +SDC_CRC16 equ SDC_PSN+4 + +SDC_SDATA equ 7C00h ; rw: 7C00h-7Dff - sector transfer area + +SDC_BUSY equ 080h +SDC_CRC equ 001h +SDC_TIMEOUT equ 002h + +SDC_READ equ 001h +SDC_WRITE equ 002h +SDC_INIT equ 080h +;----------------------------------------------------------------------------- +; +; Standard BIOS and work area entries + +CHPUT equ 00A2h ;Character output +CHGET equ 009Fh +INITXT equ 006Ch +CLS equ 0848H +MSXVER equ 002DH + +LINL40 equ 0F3AEh ; Width +LINLEN equ 0F3B0h +;----------------------------------------------------------------------------- +; +; Work area definition +; +;+0-3: Device size in sectors +;+4-7: current sector r/w +;----------------------------------------------------------------------------- +; +; Error codes for DEV_RW and DEV_FORMAT +; + +.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 +;----------------------------------------------------------------------------- +; +; Routines 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,bank +; ld hl,address +; ld ix,RDBANK +; call CALBNK + +RDBANK equ 403Ch + + +;* This routine temporarily switches kernel bank 0/3, +; then jumps to CALBAS in MSX BIOS. +; This is necessary so that kernel bank is correct in case of BASIC error. + +CALBAS equ 403Fh + + +;* Call a routine in another bank. +; Must be used if the driver spawns across more than one bank. +; Input: A = bank +; IX = routine address +; AF' = AF for the routine +; BC, DE, HL, IY = input for the 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,slot +; ex af,af' +; xor a +; ld ix,GWORK +; call CALBNK + +GWORK equ 4045h + + +;* Call a routine in the driver bank. +; Input: (BK4_ADD) = routine address +; AF, BC, DE, HL, IY = input for the routine +; +; Calls a routine in the driver bank. This routine is the same as CALBNK, +; except that the routine address is passed in address BK4_ADD (#F2ED) +; instead of IX, and the bank number is always 5. This is useful when used +; in combination with CALSLT to call a driver routine from outside +; the driver itself. +; +; Note that register IX can't be used as input parameter, it is +; corrupted before reaching the invoked code. + +CALDRV equ 4048h + + +;----------------------------------------------------------------------------- +; +; 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) + + db 1+(2*DRV_HOTPLUG) + +;Reserved byte + db 0 + +;Driver name + +DRV_NAME: + db "WonderTANG! uSD Driver" + ds 32-($-DRV_NAME)," " + +;Jump table + + 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 15 + + jp DEV_RW + jp DEV_INFO + jp DEV_STATUS + jp LUN_INFO + jp DEV_FORMAT + jp DEV_CMD + + +;----------------------------------------------------------------------------- +; +; 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, it is called twice: +; +; 1) First execution, for information gathering. +; Input: +; A = 0 +; B = number of available drives (drive-based drivers only) +; 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 +; (255 if device-based driver, unless 4 is pressed at boot) +; +; 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: + ;--- If first execution, just inform that no work area is needed + ; (the 8 bytes in SLTWRK are enough) + + or a + ld hl,0 + ld a,0 + ret z ;Note that Cy is 0 (no interrupt hooking needed) + + ld a,(MSXVER) + cp 1 ; > MSX 2 + jr c,MSX1 + ld a,80 + jr SETSCRN +MSX1: + ld a,40 +SETSCRN: + ld (LINL40),a + call INITXT + + ld de,INFO_S + call PRINT + + ld de,SEARCH_S + call PRINT + + call MY_GWORK + call SDC_ON + ld a,SDC_INIT + ld (SDC_CMD),a + + ld (ix),0 ; clear device data + +WAIT_RESET: + ld de,2047 ;Timeout +WAIT_RESET1: + ld a,0 + cp e + jr nz,WAIT_DOT ;Print dots while waiting +; ld a,46 +; call CHPUT +WAIT_DOT: + call CHECK_ESC + jp c,INIT_NO_DEV + ld b,255 +WAIT_RESET2: + ld a,(SDC_STATUS) + and SDC_BUSY + jr z,WAIT_RESET_END ;Wait for BSY to clear and DRDY to set + djnz WAIT_RESET2 + dec de + ld a,d + or e + jr nz,WAIT_RESET1 + jp INIT_NO_DEV +WAIT_RESET_END: + + ld a,(SDC_CTYPE) + or a + jp z,INIT_NO_DEV + + ld de,SDV1 + cp 1 + jr z,PRINT_CTYPE + ld de,SDV2 + cp 2 + jr z,PRINT_CTYPE + ld de,SDHCV2 + cp 3 + jr z,PRINT_CTYPE + ld de,UNKNOWN + +PRINT_CTYPE: ; print card type + call PRINT + + ld de,CRLF_S + call PRINT + + ld hl,SDC_C_SIZE + ld e,(hl) + inc hl + ld d,(hl) + inc hl + ld c,(hl) ; c:de = c_size + inc hl + + ld hl,1 + add hl,de + ex de,hl + + ld a,0 + adc a,c ; c:de = c_size + 1 + ld c,a + jr nc,NO_OVL + ld a,1 ; overflow + jr OVL +NO_OVL: + xor a +OVL: + + ex af,af' ; preserve msb + push af + + ld hl,SDC_C_SIZE_MULT + ld b,(hl) ; b = c_size_mult + inc hl + inc b + inc b ; b = c_size_mult + 2 + + ld a,(hl) ; a = read_bl_len + + add a,b + sub 9 + jr z,NO_SHIFT + ld b,a ; b = read_bl_len + c_size_mult + 2 - 9 + + pop af + ex af,af' ; restore msb +CALC_SIZE: + sla e + rl d + rl c + rl a + djnz CALC_SIZE + jr ST_SIZE +NO_SHIFT: + pop af + ex af,af' ; restore msb + +ST_SIZE: + + ld (ix+0),e ; store card size in sectors (512 bytes) in work area (32-bit) + ld (ix+1),d + ld (ix+2),c + ld (ix+3),a + + ld de,CRLF_S + call PRINT + +;;;; + + ; wait some time + ld b,0 +outer: + push bc + ld b,0 +inner: + nop + push ix + pop ix + djnz inner + pop bc + djnz outer + + + jr DRV_INIT_END + +INIT_NO_DEV: + call CHECK_ESC + jr c,INIT_NO_DEV + + ld de,CRLF_S + call PRINT + ld de,NODEVS_S + call PRINT + + xor a + ld (ix+0),a + ld (ix+1),a + ld (ix+2),a + ld (ix+3),a + + ;--- End of the initialization procedure +DRV_INIT_END: + ;;;;;;;;;;;;;;;;;;; +; ld de,CRLF_S +; call PRINT +; ld de,CRLF_S +; call PRINT +; xor a +; ld (ix+4),a +; ld (ix+5),a +; ld (ix+6),a +; ld (ix+7),a + + +; next_sect: +; ld b,0 +; ld a,(ix+4) +; ld (SDC_SADDR+0),a +; add 1 ; increment sector +; ld (ix+4),a ; store back incremented +; ld a,(ix+5) +; ld (SDC_SADDR+1),a +; adc b +; ld (ix+5),a +; ld a,(ix+6) +; ld (SDC_SADDR+2),a +; adc b +; ld (ix+6),a +; ld a,(ix+7) +; ld (SDC_SADDR+3),a +; adc b +; ld (ix+7),a +; ld a,SDC_READ +; ld (SDC_CMD),a +; call WAIT_CMD_RDY + +; ld hl,SDC_SDATA ; src data + +; ld b,19 +; lines: +; push bc +; ld b,26 +; rows: +; ld a,(hl) +; inc hl +; call HEXPUT +; ld a,' ' +; call CHPUT +; djnz rows +; ld de,CRLF_S +; call PRINT +; pop bc +; djnz lines +; ld b,18 +; lastrow: +; ld a,(hl) +; inc hl +; call HEXPUT +; ld a,' ' +; call CHPUT +; djnz lastrow +; ld de,CRLF_S +; call PRINT +; call CHGET +; cp 27 +; jp nz,next_sect +;----------------------------------------------------------------------------- +; +; 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): + + ;;;;;;;;;;;;;;;;; + + call SDC_OFF + ret + +; HEXPUT: +; push af +; push bc +; ld b,a +; srl a +; srl a +; srl a +; srl a +; call HEXCHAR +; ld a,b +; and 00fh +; call HEXCHAR +; pop bc +; pop af +; ret + +; HEXCHAR: +; cp 10 +; jr c,digit +; add 'A'-10 +; jp CHPUT +; digit: +; add '0' +; jp CHPUT + + +BINTOHEX: + ld c,a + srl a + srl a + srl a + srl a + call HEXNIBLE + ld b,a + ld a,c + and 00fh + call HEXNIBLE + ld c,a + ret +HEXNIBLE: + cp 10 + jr c,ISDIGT + add 'A'-10 + ret +ISDIGT: + add '0' + 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 statement ("CALL") handler. +; Works the expected way, except that CALBAS in kernel page 0 +; must be called instead of CALBAS in MSX BIOS. + +DRV_BASSTAT: + scf + ret + + +;----------------------------------------------------------------------------- +; +; BASIC expanded device handler. +; Works the expected way, except that CALBAS in kernel page 0 +; must be called instead of CALBAS in MSX BIOS. + +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: +; ld a,1 +; ret + +;===== +;===== BEGIN of DEVICE-BASED specific routines +;===== + +;----------------------------------------------------------------------------- +; +; 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/written + +DEV_RW: + jp c,WRSECT +RDSECT: + + or a ;Check device index + jp z,RW_ERR1 + cp 2 + jp nc,RW_ERR1 + + call MY_GWORK + + call SDC_ON + call WAIT_CMD_RDY + ld a,(SDC_STATUS) + and SDC_BUSY + jp nz,RW_BUSY + + ld a,(de) + inc de + ld (ix+4),a + ld a,(de) + inc de + ld (ix+5),a + ld a,(de) + inc de + ld (ix+6),a + ld a,(de) + inc de + ld (ix+7),a ; current sector + + ex de,hl ; de = destination + push bc ; nr of sectors + +RD_LOOP: + push bc ; nr of sectors + ld b,0 + ld a,(ix+4) + ld (SDC_SADDR+0),a + add 1 ; increment sector + ld (ix+4),a ; store back incremented + ld a,(ix+5) + ld (SDC_SADDR+1),a + adc b + ld (ix+5),a + ld a,(ix+6) + ld (SDC_SADDR+2),a + adc b + ld (ix+6),a + ld a,(ix+7) + ld (SDC_SADDR+3),a + adc b + ld (ix+7),a + ld a,SDC_READ + ld (SDC_CMD),a + call WAIT_CMD_RDY + jr c,R_ERR_LOOP + ld bc,512 + ld hl,SDC_SDATA ; src data + ldir + pop bc + djnz RD_LOOP + pop bc ; nr of sectors + call SDC_OFF + + ld a,0 + or a + ret + + +R_ERR_LOOP: + ld a,(SDC_STATUS) + ld e,a ; save stat + call SDC_OFF + pop bc + ld d,b + pop bc + ld a,d + sub b + ld b,a ; sectors written + ld e,a + and SDC_TIMEOUT + jr nz,R_TIMEOUT + ld a,.DISK + scf + ret +R_TIMEOUT: + ld a,.NRDY + scf + ret + +W_ERR_LOOP: + ld a,(SDC_STATUS) + ld e,a ; save stat + call SDC_OFF + pop bc + ld d,b + pop bc + ld a,d + sub b + ld b,a ; sectors written + ld e,a + and SDC_CRC + jr nz,W_WRERR + ld a,.DISK + scf + ret +W_WRERR: + + ;ld a,0f3h + ;call SETBORDER + + ld a,.WRERR + scf + ret + +RW_DISK: + + ;ld a,0fDh + ;call SETBORDER + + ld b,.DISK + jr RW_ERR +RW_BUSY: + + ;ld a,0f5h + ;call SETBORDER + + ld b,.NRDY + jr RW_ERR +RW_ERR1: + + ;ld a,0f7h + ;call SETBORDER + + ld b,.IDEVL +RW_ERR: + + ;ld a,0feh + ;call SETBORDER + + call SDC_OFF + ld a,b + ld b,0 + scf + ret + +WRSECT: + or a ;Check device index + jr z,RW_ERR1 + cp 2 + jr nc,RW_ERR1 + + call MY_GWORK + + call SDC_ON + call WAIT_CMD_RDY + ld a,(SDC_STATUS) + and SDC_BUSY + jr nz,RW_BUSY + + ld a,(de) + inc de + ld (ix+4),a + ld a,(de) + inc de + ld (ix+5),a + ld a,(de) + inc de + ld (ix+6),a + ld a,(de) + inc de + ld (ix+7),a ; current sector + + push bc ; nr of sectors + +WR_LOOP: + push bc ; nr of sectors + ld b,0 + ld a,(ix+4) + ld (SDC_SADDR+0),a + add 1 ; increment sector + ld (ix+4),a + ld a,(ix+5) + ld (SDC_SADDR+1),a + adc b + ld (ix+5),a + ld a,(ix+6) + ld (SDC_SADDR+2),a + adc b + ld (ix+6),a + ld a,(ix+7) + ld (SDC_SADDR+3),a + adc b + ld (ix+7),a + + ld bc,512 + ld de,SDC_SDATA ; hl = src data + ldir + + ld a,SDC_WRITE + ld (SDC_CMD),a + call WAIT_CMD_RDY + jp c,W_ERR_LOOP + + pop bc + djnz WR_LOOP + pop bc ; nr of sectors + call SDC_OFF + + ld a,0 + or a + ret + + + + +;----------------------------------------------------------------------------- +; +; 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 8. 1 if the device has no logical +; drives (which is functionally equivalent to having only one). +;+1 (1): Flags, always zero +; +; 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: + + or a ;Check device index + jr z,DEV_INFO_ERR1 + cp 2 + jr nc,DEV_INFO_ERR1 + + call MY_GWORK + + call SDC_ON + + ld a,b + or a + jr z,BASIC_INFO + cp 1 + jr z,MANUFACTURER + cp 2 + jr z,DEVICE_NAME + cp 3 + jr z,SERIAL_NUMBER + +MANUFACTURER: +DEV_INFO_ERR2: + call SDC_OFF + ld a,2 + ret + +BASIC_INFO: + + ld a,1 + ld (hl),a + inc hl + xor a + ld (hl),a +DEV_INFO_OK: + xor a + call SDC_OFF + ret + +DEVICE_NAME: + ex de,hl + ld hl,SDC_OID + ld b,7 +COPNAME: + ld a,(hl) + cp 32 + jr c,NONASC + or 128 + jr nz,NONASC + jr STORASC +NONASC: + ld a,' ' +STORASC: + ld (de),a + inc de + inc hl + djnz COPNAME + ex de,hl + ld b,64-7 +STR_PAD: + ld a,' ' + ld (hl),a + inc hl + djnz STR_PAD + + jr DEV_INFO_OK + +SERIAL_NUMBER: + + ld de,SDC_PSN+3 + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld a,(de) + dec de + call BINTOHEX + ld (hl),b + inc hl + ld (hl),c + inc hl + ld b,64-8 + jr STR_PAD + ;--- Termination with error + +DEV_INFO_ERR1: + call SDC_OFF + ld a,1 + 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. + +DEV_STATUS: + call CHECK_DEV_LUN + jr c,DEV_STAT_ERR + + ld a,(ix+0) + or a + jr nz,DEV_OK + ld a,(ix+1) + or a + jr nz,DEV_OK + ld a,(ix+2) + or a + jr nz,DEV_OK + ld a,(ix+3) + or a + jr nz,DEV_OK +DEV_STAT_ERR: + ld a,0 + ret + +DEV_OK: + ld a,1 + 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 (0, if not a hard disk) +;+10 (1): Number of heads (0, if not a hard disk) +;+11 (1): Number of sectors per track (0, if not a hard disk) + +LUN_INFO: + + call CHECK_DEV_LUN + jr c,LUN_INFO_ERROR + + call MY_GWORK + + xor a + ld (hl), a ; block device + inc hl + ld (hl),0 + inc hl + ld (hl),2 ; sector size + inc hl + ld a,(ix+0) + ld (hl),a + inc hl + ld a,(ix+1) + ld (hl),a + inc hl + ld a,(ix+2) + ld (hl),a + inc hl + ld a,(ix+3) + ld (hl),a ; total of sectors + inc hl + xor a + ld (hl),a ; medium flags + inc hl + ld (hl),a ; + inc hl + ld (hl),a ; num of cyls + inc hl + ld (hl),a ; num of heads + inc hl + ld (hl),a ; num of sectors per track + + xor a + ret + +LUN_INFO_ERROR: + ld a,1 + ret + + +;----------------------------------------------------------------------------- +; +; 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 +;===== + + +;======================= +; Subroutines +;======================= + +;----------------------------------------------------------------------------- +; +; Enable or disable the SPI registers + +SDC_ON: + ld a,1 + ld (SDC_ENABLE),a + ret + +SDC_OFF: + xor a + ld (SDC_ENABLE),a + ret + +;----------------------------------------------------------------------------- +; +; Wait the BSY flag to clear and RDY flag to be set +; if we wait for more than 30s, send a soft reset to IDE BUS +; if the soft reset didn't work after 30s return with error +; +; Input: Nothing +; Output: Cy=1 if timeout after soft reset +; Preserves: DE and BC + +WAIT_CMD_RDY: + push de + push bc + ld de,2047 ;8142 ;Limit the wait to 30s +WAIT_RDY1: + ld b,255 +WAIT_RDY2: + ld a,(SDC_STATUS) + and SDC_BUSY+SDC_TIMEOUT+SDC_CRC + or a + jr z,WAIT_RDY_END + djnz WAIT_RDY2 + dec de + ld a,d + or e + jr nz,WAIT_RDY1 + scf +WAIT_RDY_END: + pop bc + pop de + ret + +;----------------------------------------------------------------------------- +; +; Read the keyboard matrix to see if ESC is pressed +; Output: Cy = 1 if pressed, 0 otherwise + +CHECK_ESC: + ld b,7 + in a,(0AAh) + and 11110000b + or b + out (0AAh),a + in a,(0A9h) + bit 2,a + jr nz,CHECK_ESC_END + scf +CHECK_ESC_END: + 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 + +;----------------------------------------------------------------------------- +; +; Check the device index and LUN +; Input: A = device index, B = lun +; Output: Cy=0 if OK, 1 if device or LUN invalid +; IX = Work area for the device +; Modifies F, C + +CHECK_DEV_LUN: + or a ;Check device index + scf + ret z + cp 2 + ccf + ret c + + ld a,b ;Check LUN number + cp 1 + scf + ret nz + + or a + ret + + +;----------------------------------------------------------------------------- +; +; Obtain the work area address for the driver +; Input: A=1 to obtain the work area for the master, 2 for the slave +; Preserves A + +MY_GWORK: + xor a + EX AF,AF' + XOR A + LD IX,GWORK + call CALBNK + ret + +;SETBORDER: +; out (099h),a +; ld a,087h +; out (099h),a +; ret + +;======================= +; Strings +;======================= + +INFO_S: + db "WonderTANG! v" + db VER_MAIN+"0",".",VER_SEC+"0",".",VER_REV+"0",13,10 + db "Synthetic Juice for your MSX",13,10,13,10 + db "2023 Luis Antoniosi",13,10 + db "Beautiful British Columbia",13,10 + db "Canada",13,10,13,10 + db "SS0: Nextor BIOS + MicroSD",13,10 + db "SS1: FM ROM + OPLL",13,10 + db "SS2: Super MegaRAM SCC+ 2MB",13,10 + db "SS3: Memory Mapper 4MB",13,10 + db "---: SMS VDP 16KB ",13,10,13,10,0 + +SEARCH_S: + db "Searching: ",0 + +NODEVS_S: + db "Not found",13,10,0 + +UNKNOWN: + db "UNKOWN",0 +SDV1: + db "SDV1",0 +SDV2: + db "SDV2",0 +SDHCV2: + db "SDHCV2",0 + +CRLF_S: + db 13,10,0 + + +;----------------------------------------------------------------------------- +; +; Padding up to the required driver size + +DRV_END: + + ds 3ED0h-(DRV_END-DRV_START) + + end diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac index f7fc0ff0..768e149a 100644 --- a/source/kernel/drv.mac +++ b/source/kernel/drv.mac @@ -807,8 +807,8 @@ IS_DVB: jr nz,IS_NOT_DVB ld iy,(DVB_TABLE##) - ld a,iyh - or iyl + LD_N_IYH a ;ld a,iyh + OR_IYL ;or iyl jr z,IS_NOT_DVB ld a,(iy) @@ -962,7 +962,7 @@ READ_BOOT: ld ix,DEV_RW## jp DO_CALBNK - + IF UNDOC_OP ;----------------------------------------------------------------------------- ; ; Convert the disk error returned by a device-based routine, @@ -1014,7 +1014,7 @@ COMP16: ld a,l sub e ret - + ENDIF ;----------------------------------------------------------------------------- ; ; Default DPB, it contains data for a 720K disk drive @@ -1082,6 +1082,61 @@ KDERJ: ALIGN 7BD0h ;Here goes the 1K free area at the end of banks 0 and 3 + IFE UNDOC_OP +;----------------------------------------------------------------------------- +; +; Convert the disk error returned by a device-based routine, +; into its drive-based equivalent + +POP_CONV_ERR: + inc sp + inc sp + +CONV_ERR: + or a + ret z + ;jr c,CONVE2 + ;xor a + ;ret +CONVE2: + + push bc + ld b,0 + cp .WPROT## + jr z,CONV_ERR_END + ld b,2 + cp .NRDY## + jr z,CONV_ERR_END + ld b,4 + cp .DATA## + jr z,CONV_ERR_END + ld b,6 + cp .SEEK## + jr z,CONV_ERR_END + ld b,8 + cp .RNF## + jr z,CONV_ERR_END + ld b,10 + cp .WRERR## + jr z,CONV_ERR_END + ld b,12 + +CONV_ERR_END: + ld a,b + pop bc + scf + ret + +COMP16: + ld a,h + sub d + ret nz + ld a,l + sub e + ret + ENDIF + + finish ; end diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index 755846f8..d9419972 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -8,14 +8,14 @@ TRUE equ NOT FALSE ; -const macro name,value -name equ (value) +const MACRO name,N +name equ (N) public name endm ; ; ; -warn macro text +warn MACRO text if1 .printx % text endif @@ -23,7 +23,7 @@ warn macro text ; ; ; -error macro text +error MACRO text if1 .error text endif @@ -31,17 +31,17 @@ error macro text ; ; ; -pr_dec macro msg1,value,msg2 - warn +pr_dec MACRO msg1,N,msg2 + warn endm ; ; -pr_hex macro msg1,value,msg2 - warn +pr_hex MACRO msg1,N,msg2 + warn endm ; ; -code macro instr,arg +code MACRO instr,arg _code_ defl 0 @@ -160,7 +160,7 @@ endm OFFSET equ 4100h PHASED defl FALSE ; -rammod macro +rammod MACRO PHASED defl TRUE .phase $-OFFSET endm @@ -168,7 +168,7 @@ PHASED defl TRUE ; start: ; -finish macro name +finish MACRO name if PHASED .dephase endif @@ -179,10 +179,10 @@ finish macro name ; ; -;--- The "proc" macro is used to define a label that is invoked +;--- The "proc" MACRO is used to define a label that is invoked ; at RAM in page 0 (when PHASED) or at ROM bank 4 (when not PHASED). -proc macro name ;;Macro for declaring a public +proc MACRO name ;;Macro for declaring a public if PHASED name&: ;; label to be called. .dephase @@ -196,7 +196,7 @@ name&: ;;For local call ; ; ; -pcall macro cc,name ;;Macro for calling an external +pcall MACRO cc,name ;;Macro for calling an external ;; routine. ifb call ?&cc&##-OFFSET ;;Unconditional CALL. @@ -209,7 +209,7 @@ pcall macro cc,name ;;Macro for calling an external ; ; STROUT implementation with the ESC-Y bug corrected. -; It is declared as as macro because it is defined +; It is declared as as MACRO because it is defined ; twince in the kernel (bdos.mac, char.mac) ; and once more in MSXDOS2.SYS. ; @@ -217,7 +217,7 @@ pcall macro cc,name ;;Macro for calling an external ; RETDIR is the routine jumped to at end. If 0, ret is generated instead. ; LOADCE: if specified, E and C registers are loaded prior to calling CONOUT. -do_strout macro OUTDIR,RETDIR,LOADCE +do_strout MACRO OUTDIR,RETDIR,LOADCE local stro_init local STROU2 local ST10 @@ -269,7 +269,7 @@ ST10: PUSH DE endm -djpnz macro address +djpnz MACRO address dec b jp nz,address endm @@ -278,3 +278,183 @@ djpnz macro address ; .list ; + +UNDOC_OP equ 0 ; user or not undocummented Z-80 instructions + + IF UNDOC_OP +;;;;;;;;;;;;;;;;;;;;;;;;;;; + +LD_IXL_N MACRO N + ld ixl,N + ENDM + +LD_IXH_N MACRO N + ld ixh,N + ENDM + +LD_IYL_N MACRO N + ld iyl,N + ENDM + +LD_IYH_N MACRO N + ld iyh,N + ENDM + +LD_N_IXH MACRO N + ld N,ixh + ENDM + +LD_N_IXL MACRO N + ld N,ixl + ENDM + +LD_N_IYH MACRO N + ld N,iyh + ENDM + +LD_N_IYL MACRO N + ld N,iyl + ENDM + +CP_IXH MACRO + cp ixh + ENDM + +CP_IXL MACRO + cp ixl + ENDM + +CP_IYH MACRO + cp iyh + ENDM + +CP_IYL MACRO + cp iyl + ENDM + + +OR_IYL MACRO + or iyl + ENDM + +DEC_IYL MACRO + dec iyl + ENDM + + ELSE + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +LD_IXH_N MACRO N + ex (sp),ix + ex (sp),hl + ld h,N + ex (sp),hl + ex (sp),ix + ENDM + +LD_IXL_N MACRO N + ex (sp),ix + ex (sp),hl + ld l,N + ex (sp),hl + ex (sp),ix + ENDM + +LD_IYH_N MACRO N + ex (sp),iy + ex (sp),hl + ld h,N + ex (sp),hl + ex (sp),iy + ENDM + +LD_IYL_N MACRO N + ex (sp),iy + ex (sp),hl + ld l,N + ex (sp),hl + ex (sp),iy + ENDM + +LD_N_IXH MACRO N + ex (sp),ix + ex (sp),hl + ld N,h + ex (sp),hl + ex (sp),ix + ENDM + +LD_N_IXL MACRO N + ex (sp),ix + ex (sp),hl + ld N,l + ex (sp),hl + ex (sp),ix + ENDM + +LD_N_IYH MACRO N + ex (sp),iy + ex (sp),hl + ld N,h + ex (sp),hl + ex (sp),iy + ENDM + +LD_N_IYL MACRO N + ex (sp),iy + ex (sp),hl + ld N,l + ex (sp),hl + ex (sp),iy + ENDM + +CP_IXH MACRO + ex (sp),ix + ex (sp),hl + cp h` + ex (sp),hl + ex (sp),ix + ENDM + +CP_IXL MACRO + ex (sp),ix + ex (sp),hl + cp l + ex (sp),hl + ex (sp),ix + ENDM + +CP_IYH MACRO + ex (sp),iy + ex (sp),hl + cp h + ex (sp),hl + ex (sp),iy + ENDM + +CP_IYL MACRO + ex (sp),iy + ex (sp),hl + cp l + ex (sp),hl + ex (sp),iy + ENDM + +OR_IYL MACRO + ex (sp),iy + ex (sp),hl + or l + ex (sp),hl + ex (sp),iy + ENDM + +DEC_IYL MACRO + ex (sp),iy + ex (sp),hl + dec l + ex (sp),hl + ex (sp),iy + ENDM + + ENDIF diff --git a/source/tools/MAPDRV.MAC b/source/tools/MAPDRV.MAC index eb27d9e8..8a831551 100644 --- a/source/tools/MAPDRV.MAC +++ b/source/tools/MAPDRV.MAC @@ -1,13 +1,13 @@ .z80 - ;include MACROS.INC -ld_a_iyl macro - db 0FDh - ld a,l - endm + include MACROS.INC +;ld_a_iyl macro +; db 0FDh +; ld a,l +; endm FIB equ 3000h - jp START + jp START2 ; ------------------------------------------------------------------------------- db 13 @@ -63,7 +63,7 @@ USAGE_S: db "TYPE MAPDRV.COM for more details.",13,10 db 0 -START: +START2: call CHK250## ld de,BUF @@ -117,7 +117,7 @@ NO_LOCK: ;* Partition number, or "d", "u", or file name ld de,BUF - ld_a_iyl + ld_n_iyl a inc iy call EXTPAR## ld b,.NOPAR## @@ -152,7 +152,7 @@ IS_PART: ;* Device, LUN ld de,BUF - ld_a_iyl + ld_n_iyl a inc iy call EXTPAR## jp c,DO_MAP @@ -183,7 +183,7 @@ OK_DEVLUN: ;* Slot, subslot, segment ld de,BUF - ld_a_iyl + ld_n_iyl a inc iy call EXTPAR## jp c,DO_MAP diff --git a/source/tools/SHARED.MAC b/source/tools/SHARED.MAC index 3f666d87..ed1c4ddc 100644 --- a/source/tools/SHARED.MAC +++ b/source/tools/SHARED.MAC @@ -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_N a ;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_N_IXH a ;ld a,ixh ;Error if parameter index dec a ;is larger that the number of parameters - cp ixl + 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_N_IXH a ;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_N_IXL a ;ld a,ixl or a jr FINEXTP EXTPERR: From 37747d1facc707c96085a58fb5a6692673c33881 Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Sun, 5 Nov 2023 10:28:44 -0800 Subject: [PATCH 3/9] changes to undoc op build --- source/kernel/Makefile | 12 ++++++++---- source/kernel/drivers/Tang/driver.mac | 3 +++ source/kernel/drv.mac | 4 ++-- source/kernel/macros.inc | 4 +--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source/kernel/Makefile b/source/kernel/Makefile index d3339ded..608c6c93 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -45,21 +45,26 @@ define copy_to_bin cp $(1) ../../bin/kernels/$(2) endef +ifeq ($(strip $(ASSEMBLE_SYMBOLS)),) +EXTRA_SYMBOLS= +else +EXTRA_SYMBOLS=--define-symbols $(ASSEMBLE_SYMBOLS) +endif + define assemble @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1) - @$(N80) $(1) $$ $(2) + @$(N80) $(1) $$ $(2) $(EXTRA_SYMBOLS) endef define assemble_as @printf "\n\033[0;36mAssembling %s as %s\033[0m\n\n" $(1) $(2) - @$(N80) $(1) $(2) $(3) + @$(N80) $(1) $(2) $(3) $(EXTRA_SYMBOLS) endef define print_linking @printf "\n\033[0;36mLinking %s\033[0m\n\n" $(1) endef - ################### ### MAIN RULE ### ################### @@ -607,7 +612,6 @@ drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM: \ cat 256.bytes drivers/Tang/driver.bin > drivers/Tang/_driver.bin $(MKNEXROM) nextor_base.dat $@ /d:drivers/Tang/_driver.bin /m:drivers/Tang/chgbnk.bin $(call copy_to_bin,$@) - cp $@ /mnt/d/src/fpga/wonderTANG/WonderTANG/fpga/src/roms/Nextor-$(VERSION).WonderTANG-HC95.ROM.bin drivers/Tang/chgbnk.bin: \ drivers/Tang/chgbnk.mac diff --git a/source/kernel/drivers/Tang/driver.mac b/source/kernel/drivers/Tang/driver.mac index 7d70f1f9..8e88d432 100644 --- a/source/kernel/drivers/Tang/driver.mac +++ b/source/kernel/drivers/Tang/driver.mac @@ -2,6 +2,9 @@ ; ; Version by Luis Antoniosi ; Based on version 0.1 by Konamiman + ; + ; Open-source FPGA cartridge + ; https://github.com/lfantoniosi/WonderTANG org 4100h diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac index 768e149a..fb2bacea 100644 --- a/source/kernel/drv.mac +++ b/source/kernel/drv.mac @@ -962,7 +962,7 @@ READ_BOOT: ld ix,DEV_RW## jp DO_CALBNK - IF UNDOC_OP + IFNDEF DISABLE_UNDOCUMENTED_OPCODES ;----------------------------------------------------------------------------- ; ; Convert the disk error returned by a device-based routine, @@ -1082,7 +1082,7 @@ KDERJ: ALIGN 7BD0h ;Here goes the 1K free area at the end of banks 0 and 3 - IFE UNDOC_OP + IFDEF DISABLE_UNDOCUMENTED_OPCODES ;----------------------------------------------------------------------------- ; ; Convert the disk error returned by a device-based routine, diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index d9419972..1ba751b3 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -279,9 +279,7 @@ djpnz MACRO address .list ; -UNDOC_OP equ 0 ; user or not undocummented Z-80 instructions - - IF UNDOC_OP + IFNDEF DISABLE_UNDOCUMENTED_OPCODES ;;;;;;;;;;;;;;;;;;;;;;;;;;; LD_IXL_N MACRO N From 1a6d391d66af4933240a3fb62a048005415ef33c Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Sun, 5 Nov 2023 10:40:46 -0800 Subject: [PATCH 4/9] revert some text --- source/kernel/macros.inc | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index 1ba751b3..8d1b4a22 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -8,14 +8,14 @@ TRUE equ NOT FALSE ; -const MACRO name,N -name equ (N) +const macro name,value +name equ (value) public name endm ; ; ; -warn MACRO text +warn macro text if1 .printx % text endif @@ -23,7 +23,7 @@ warn MACRO text ; ; ; -error MACRO text +error macro text if1 .error text endif @@ -31,17 +31,17 @@ error MACRO text ; ; ; -pr_dec MACRO msg1,N,msg2 - warn +pr_dec macro msg1,value,msg2 + warn endm ; ; -pr_hex MACRO msg1,N,msg2 - warn +pr_hex macro msg1,value,msg2 + warn endm ; ; -code MACRO instr,arg +code macro instr,arg _code_ defl 0 @@ -160,7 +160,7 @@ endm OFFSET equ 4100h PHASED defl FALSE ; -rammod MACRO +rammod macro PHASED defl TRUE .phase $-OFFSET endm @@ -168,7 +168,7 @@ PHASED defl TRUE ; start: ; -finish MACRO name +finish macro name if PHASED .dephase endif @@ -179,10 +179,10 @@ finish MACRO name ; ; -;--- The "proc" MACRO is used to define a label that is invoked +;--- The "proc" macro is used to define a label that is invoked ; at RAM in page 0 (when PHASED) or at ROM bank 4 (when not PHASED). -proc MACRO name ;;Macro for declaring a public +proc macro name ;;Macro for declaring a public if PHASED name&: ;; label to be called. .dephase @@ -196,7 +196,7 @@ name&: ;;For local call ; ; ; -pcall MACRO cc,name ;;Macro for calling an external +pcall macro cc,name ;;Macro for calling an external ;; routine. ifb call ?&cc&##-OFFSET ;;Unconditional CALL. @@ -209,7 +209,7 @@ pcall MACRO cc,name ;;Macro for calling an external ; ; STROUT implementation with the ESC-Y bug corrected. -; It is declared as as MACRO because it is defined +; It is declared as as macro because it is defined ; twince in the kernel (bdos.mac, char.mac) ; and once more in MSXDOS2.SYS. ; @@ -217,7 +217,7 @@ pcall MACRO cc,name ;;Macro for calling an external ; RETDIR is the routine jumped to at end. If 0, ret is generated instead. ; LOADCE: if specified, E and C registers are loaded prior to calling CONOUT. -do_strout MACRO OUTDIR,RETDIR,LOADCE +do_strout macro OUTDIR,RETDIR,LOADCE local stro_init local STROU2 local ST10 @@ -269,7 +269,7 @@ ST10: PUSH DE endm -djpnz MACRO address +djpnz macro address dec b jp nz,address endm @@ -280,7 +280,6 @@ djpnz MACRO address ; IFNDEF DISABLE_UNDOCUMENTED_OPCODES -;;;;;;;;;;;;;;;;;;;;;;;;;;; LD_IXL_N MACRO N ld ixl,N @@ -341,8 +340,6 @@ DEC_IYL MACRO ELSE -;;;;;;;;;;;;;;;;;;;;;;;;;;;; - LD_IXH_N MACRO N ex (sp),ix ex (sp),hl From 3a3727fbe75c7f3ac2bfe4a1e042a894add4b8ee Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Mon, 20 Nov 2023 23:13:31 -0800 Subject: [PATCH 5/9] Revert "revert some text" This reverts commit 1a6d391d66af4933240a3fb62a048005415ef33c. --- source/kernel/macros.inc | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index 8d1b4a22..1ba751b3 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -8,14 +8,14 @@ TRUE equ NOT FALSE ; -const macro name,value -name equ (value) +const MACRO name,N +name equ (N) public name endm ; ; ; -warn macro text +warn MACRO text if1 .printx % text endif @@ -23,7 +23,7 @@ warn macro text ; ; ; -error macro text +error MACRO text if1 .error text endif @@ -31,17 +31,17 @@ error macro text ; ; ; -pr_dec macro msg1,value,msg2 - warn +pr_dec MACRO msg1,N,msg2 + warn endm ; ; -pr_hex macro msg1,value,msg2 - warn +pr_hex MACRO msg1,N,msg2 + warn endm ; ; -code macro instr,arg +code MACRO instr,arg _code_ defl 0 @@ -160,7 +160,7 @@ endm OFFSET equ 4100h PHASED defl FALSE ; -rammod macro +rammod MACRO PHASED defl TRUE .phase $-OFFSET endm @@ -168,7 +168,7 @@ PHASED defl TRUE ; start: ; -finish macro name +finish MACRO name if PHASED .dephase endif @@ -179,10 +179,10 @@ finish macro name ; ; -;--- The "proc" macro is used to define a label that is invoked +;--- The "proc" MACRO is used to define a label that is invoked ; at RAM in page 0 (when PHASED) or at ROM bank 4 (when not PHASED). -proc macro name ;;Macro for declaring a public +proc MACRO name ;;Macro for declaring a public if PHASED name&: ;; label to be called. .dephase @@ -196,7 +196,7 @@ name&: ;;For local call ; ; ; -pcall macro cc,name ;;Macro for calling an external +pcall MACRO cc,name ;;Macro for calling an external ;; routine. ifb call ?&cc&##-OFFSET ;;Unconditional CALL. @@ -209,7 +209,7 @@ pcall macro cc,name ;;Macro for calling an external ; ; STROUT implementation with the ESC-Y bug corrected. -; It is declared as as macro because it is defined +; It is declared as as MACRO because it is defined ; twince in the kernel (bdos.mac, char.mac) ; and once more in MSXDOS2.SYS. ; @@ -217,7 +217,7 @@ pcall macro cc,name ;;Macro for calling an external ; RETDIR is the routine jumped to at end. If 0, ret is generated instead. ; LOADCE: if specified, E and C registers are loaded prior to calling CONOUT. -do_strout macro OUTDIR,RETDIR,LOADCE +do_strout MACRO OUTDIR,RETDIR,LOADCE local stro_init local STROU2 local ST10 @@ -269,7 +269,7 @@ ST10: PUSH DE endm -djpnz macro address +djpnz MACRO address dec b jp nz,address endm @@ -280,6 +280,7 @@ djpnz macro address ; IFNDEF DISABLE_UNDOCUMENTED_OPCODES +;;;;;;;;;;;;;;;;;;;;;;;;;;; LD_IXL_N MACRO N ld ixl,N @@ -340,6 +341,8 @@ DEC_IYL MACRO ELSE +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + LD_IXH_N MACRO N ex (sp),ix ex (sp),hl From 544bc53981f247f9250d56797b07c76f703686c6 Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Mon, 20 Nov 2023 23:13:41 -0800 Subject: [PATCH 6/9] Revert "changes to undoc op build" This reverts commit 37747d1facc707c96085a58fb5a6692673c33881. --- source/kernel/Makefile | 12 ++++-------- source/kernel/drivers/Tang/driver.mac | 3 --- source/kernel/drv.mac | 4 ++-- source/kernel/macros.inc | 4 +++- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/source/kernel/Makefile b/source/kernel/Makefile index 608c6c93..d3339ded 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -45,26 +45,21 @@ define copy_to_bin cp $(1) ../../bin/kernels/$(2) endef -ifeq ($(strip $(ASSEMBLE_SYMBOLS)),) -EXTRA_SYMBOLS= -else -EXTRA_SYMBOLS=--define-symbols $(ASSEMBLE_SYMBOLS) -endif - define assemble @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1) - @$(N80) $(1) $$ $(2) $(EXTRA_SYMBOLS) + @$(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) $(EXTRA_SYMBOLS) + @$(N80) $(1) $(2) $(3) endef define print_linking @printf "\n\033[0;36mLinking %s\033[0m\n\n" $(1) endef + ################### ### MAIN RULE ### ################### @@ -612,6 +607,7 @@ drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM: \ cat 256.bytes drivers/Tang/driver.bin > drivers/Tang/_driver.bin $(MKNEXROM) nextor_base.dat $@ /d:drivers/Tang/_driver.bin /m:drivers/Tang/chgbnk.bin $(call copy_to_bin,$@) + cp $@ /mnt/d/src/fpga/wonderTANG/WonderTANG/fpga/src/roms/Nextor-$(VERSION).WonderTANG-HC95.ROM.bin drivers/Tang/chgbnk.bin: \ drivers/Tang/chgbnk.mac diff --git a/source/kernel/drivers/Tang/driver.mac b/source/kernel/drivers/Tang/driver.mac index 8e88d432..7d70f1f9 100644 --- a/source/kernel/drivers/Tang/driver.mac +++ b/source/kernel/drivers/Tang/driver.mac @@ -2,9 +2,6 @@ ; ; Version by Luis Antoniosi ; Based on version 0.1 by Konamiman - ; - ; Open-source FPGA cartridge - ; https://github.com/lfantoniosi/WonderTANG org 4100h diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac index fb2bacea..768e149a 100644 --- a/source/kernel/drv.mac +++ b/source/kernel/drv.mac @@ -962,7 +962,7 @@ READ_BOOT: ld ix,DEV_RW## jp DO_CALBNK - IFNDEF DISABLE_UNDOCUMENTED_OPCODES + IF UNDOC_OP ;----------------------------------------------------------------------------- ; ; Convert the disk error returned by a device-based routine, @@ -1082,7 +1082,7 @@ KDERJ: ALIGN 7BD0h ;Here goes the 1K free area at the end of banks 0 and 3 - IFDEF DISABLE_UNDOCUMENTED_OPCODES + IFE UNDOC_OP ;----------------------------------------------------------------------------- ; ; Convert the disk error returned by a device-based routine, diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index 1ba751b3..d9419972 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -279,7 +279,9 @@ djpnz MACRO address .list ; - IFNDEF DISABLE_UNDOCUMENTED_OPCODES +UNDOC_OP equ 0 ; user or not undocummented Z-80 instructions + + IF UNDOC_OP ;;;;;;;;;;;;;;;;;;;;;;;;;;; LD_IXL_N MACRO N From d7428620adaecceff12d8f79553f890087f52d20 Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Mon, 20 Nov 2023 23:13:56 -0800 Subject: [PATCH 7/9] Revert "Merge branch 'v2.1' of https://github.com/lfantoniosi/Nextor into v2.1" This reverts commit 92f533c691a0d2d2eff23f66df2219e0386a1615, reversing changes made to 88374eb575a7d2df1a095fcf338e5b51b222e0de. --- source/kernel/drivers/Tang/driver.mac | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/kernel/drivers/Tang/driver.mac b/source/kernel/drivers/Tang/driver.mac index 7d70f1f9..99ff3517 100644 --- a/source/kernel/drivers/Tang/driver.mac +++ b/source/kernel/drivers/Tang/driver.mac @@ -183,7 +183,7 @@ CALDRV equ 4048h ; bit 2: 1 if the driver provides configuration ; (implements the DRV_CONFIG routine) - db 1+(2*DRV_HOTPLUG)+4 + db 1+(2*DRV_HOTPLUG) ;Reserved byte db 0 @@ -207,9 +207,9 @@ DRV_NAME: jp DRV_DIRECT2 jp DRV_DIRECT3 jp DRV_DIRECT4 - jp DRV_CONFIG + ;jp DRV_CONFIG - ds 12 + ds 15 jp DEV_RW jp DEV_INFO @@ -657,11 +657,9 @@ DRV_DIRECT4: ; B = Device index ; C = LUN index - -DRV_CONFIG: - ld a,1 - ret - +; DRV_CONFIG: +; ld a,1 +; ret ;===== ;===== BEGIN of DEVICE-BASED specific routines @@ -1385,8 +1383,7 @@ MY_GWORK: ;======================= INFO_S: - - db "WonderTANG! SMS v" + db "WonderTANG! v" db VER_MAIN+"0",".",VER_SEC+"0",".",VER_REV+"0",13,10 db "Synthetic Juice for your MSX",13,10,13,10 db "2023 Luis Antoniosi",13,10 From 4aad4885cb87a00a53755657331bf3541594fe15 Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Mon, 20 Nov 2023 23:13:59 -0800 Subject: [PATCH 8/9] Revert "Replace undocumented op-codes (HC-95 turbo mode support)" This reverts commit 88374eb575a7d2df1a095fcf338e5b51b222e0de. --- source/kernel/Makefile | 27 +- source/kernel/bank0/init.mac | 8 +- source/kernel/bank1/dosinit.mac | 9 +- source/kernel/bank4/partit.mac | 38 +- source/kernel/condasm.inc | 1 - source/kernel/drivers/SunriseIDE/sunride.asm | 35 +- source/kernel/drivers/Tang/chgbnk.mac | 39 - source/kernel/drivers/Tang/driver.mac | 1425 ------------------ source/kernel/drv.mac | 63 +- source/kernel/macros.inc | 214 +-- source/tools/MAPDRV.MAC | 20 +- source/tools/SHARED.MAC | 10 +- 12 files changed, 81 insertions(+), 1808 deletions(-) delete mode 100644 source/kernel/drivers/Tang/chgbnk.mac delete mode 100644 source/kernel/drivers/Tang/driver.mac diff --git a/source/kernel/Makefile b/source/kernel/Makefile index d3339ded..6692ca78 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -64,7 +64,7 @@ endef ### MAIN RULE ### ################### -all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm tang +all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc $(MKNEXROM) dd @@ -593,28 +593,3 @@ clean: rm -f bank0/b0lab*.inc rm -f bank2/b2labels.inc rm -f bank4/b4rdlabs.inc - -### Tang - -tang: drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM - -drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM: \ - nextor_base.dat \ - drivers/Tang/driver.bin \ - drivers/Tang/chgbnk.bin \ - 256.bytes - - cat 256.bytes drivers/Tang/driver.bin > drivers/Tang/_driver.bin - $(MKNEXROM) nextor_base.dat $@ /d:drivers/Tang/_driver.bin /m:drivers/Tang/chgbnk.bin - $(call copy_to_bin,$@) - cp $@ /mnt/d/src/fpga/wonderTANG/WonderTANG/fpga/src/roms/Nextor-$(VERSION).WonderTANG-HC95.ROM.bin - -drivers/Tang/chgbnk.bin: \ - drivers/Tang/chgbnk.mac - - $(call assemble,drivers/Tang/chgbnk.mac,--build-type abs --output-file-extension bin) - -drivers/Tang/driver.bin: \ - drivers/Tang/driver.mac - - $(call assemble,drivers/Tang/driver.mac,--build-type abs --output-file-extension bin) \ No newline at end of file diff --git a/source/kernel/bank0/init.mac b/source/kernel/bank0/init.mac index 97423cc5..9bde2a32 100644 --- a/source/kernel/bank0/init.mac +++ b/source/kernel/bank0/init.mac @@ -2143,7 +2143,7 @@ scan_loop: ld e,(hl) inc hl ld d,(hl) - LD_IYH_N a ;db 0FDh,67h ;LD IYh,A + db 0FDh,67h ;LD IYh,A push de pop ix call CALSLT @@ -2173,10 +2173,10 @@ TNEX_LOOP: push hl push bc and 10001111b - LD_IYH_N a ;db 0FDh,67h ;LD IYh,A + db 0FDh,67h ;LD IYh,A ld a,(MASTER_SLOT##) - CP_IYH ;db 0FDh,0BCh ;CP IYh - LD_N_IYH a ;db 0FDh,7Ch ;LD A,IYh + db 0FDh,0BCh ;CP IYh + db 0FDh,7Ch ;LD A,IYh ld h,40h ld ix,DV_TIRQ## call call_drv diff --git a/source/kernel/bank1/dosinit.mac b/source/kernel/bank1/dosinit.mac index d9ecd003..3ac53654 100644 --- a/source/kernel/bank1/dosinit.mac +++ b/source/kernel/bank1/dosinit.mac @@ -1564,8 +1564,7 @@ _U_CALLRAM: ex af,af ... < call _GET_P1 > push af - LD_N_IYL A - ;ld a,iyl + ld a,iyl ... < call _PUT_P1 > ex af,af call CALSLT## @@ -1652,7 +1651,7 @@ _U_CALLRAM2: dec ix dec ix push ix - LD_IYL_N e ;ld iyl,e + ld iyl,e ld a,d and 00111111b @@ -1676,13 +1675,13 @@ _U_CALLRAM2: ld bc,(MAP_TAB##) add hl,bc ld a,(hl) ;A = Slot to call - LD_IYH_N a ;ld iyh,a + ld iyh,a ex af,af' exx inc sp inc sp - jp _U_CALLRAM + jr _U_CALLRAM ; ;----------------------------------------------------------------------------- ; diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac index ff4670d6..94c0c441 100644 --- a/source/kernel/bank4/partit.mac +++ b/source/kernel/bank4/partit.mac @@ -209,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_N a ;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_N a ;ld iyh,a ;extended partitions. + ld iyh,a ;extended partitions. push iy ld a,(ix+POFF_PSTART+2) - LD_IYL_N a ;ld iyl,a + ld iyl,a ld a,(ix+POFF_PSTART+3) - LD_IYH_N a ;ld iyh,a + ld iyh,a push iy ;=== Loop for extended partition search === @@ -355,7 +355,7 @@ DEV_READ: push de push hl - LD_IYH_N c ;ld iyh,c + ld iyh,c ld ix,DEV_RW## ld (BK4_ADD##),ix ld ix,CALDRV## @@ -597,7 +597,7 @@ AUTODRV_DRVLOOP: ; A = Relative drive for the driver ld c,a - LD_N_IYL A ;ld a,iyl + ld a,iyl ld (ix+UD1_SLOT##),a ;Set slot number in table entry ld a,c ld (ix+UD1_RELATIVE_DRIVE##),a @@ -607,7 +607,7 @@ AUTODRV_DRVLOOP: push iy push ix - LD_N_IYH a ;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 @@ -708,7 +708,7 @@ AUTOD_UDFND: ;--- Check if it is assigned to a device based driver ld a,(ix+UD_SLOT##) - LD_IYH_N a ;ld iyh,a + ld iyh,a ld c,a ld a,(KER250##) @@ -1067,7 +1067,7 @@ AA_CHKDUP_OK: ;--- Obtain device information ld a,(ix+AAD_DRIVER_SLOT) - LD_IYH_N a ;ld iyh,a + ld iyh,a ld hl,LUN_INFO## ld (BK4_ADD##),hl ld hl,($SECBUF##) @@ -1566,7 +1566,7 @@ AA_WSEC: AA_RSEC: or a AA_DOSEC: - LD_IYH_N c ;ld iyh,c + ld iyh,c ld hl,DEV_RW## ld (BK4_ADD##),hl ld c,b @@ -2482,7 +2482,7 @@ F_CDRVR_GO: ret nz ld (BK4_ADD##),de - LD_IYH_N c ;ld iyh,c + ld iyh,c ld l,(ix) ld h,(ix+1) push hl @@ -2630,10 +2630,10 @@ UNMAP_LOOP: inc hl ld h,(hl) ld l,a - CP_IYL ;cp iyl + cp iyl jr nz,UNMAP_OK1 ld a,h - CP_IYH ;cp iyh + cp iyh jr z,UNMAP_NEXT2 ;It is the unit not to be unassigned UNMAP_OK1: @@ -3084,7 +3084,7 @@ MAP_SPECIFIC: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - LD_IYH_N c ;ld iyh,c + ld iyh,c ld hl,($SECBUF##) ld ix,CALDRV## call CALSLT @@ -3121,7 +3121,7 @@ MAP_SPECIFIC: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - LD_IYH_N c ;ld iyh,c + ld iyh,c ld ix,CALDRV## call CALSLT pop iy @@ -3650,7 +3650,7 @@ MAPDOS1_DEF: push hl push ix ld a,(ix+UD1_SLOT##) - LD_IYH_N a ;ld iyh,a + ld iyh,a call GET_DV_TYPE pop ix pop hl @@ -3815,7 +3815,7 @@ MAPDOS1_CHK_NEXT: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - LD_IYH_N c ;ld iyh,c + ld iyh,c ld hl,($SECBUF##) ld ix,CALDRV## call CALSLT @@ -5954,7 +5954,7 @@ DRVS1LOOP: pop de jr c,DRVS1NEXT ;Skip if not a Nextor kernel - LD_IYH_N e ;ld iyh,e + ld iyh,e call GET_DV_TYPE bit 0,a ;Device-based? jr z,DRVS1NEXT ;No: skip @@ -6192,7 +6192,7 @@ ASK_DRIVE_CONFIG: push de push bc ;BC=DOS mode and relative unit ld a,(ix+UD_SLOT##) - LD_IYH_N a ;ld iyh,a + ld iyh,a ld hl,DV_CONFIG## ld (BK4_ADD##),hl ld a,CFG_DEVLUN diff --git a/source/kernel/condasm.inc b/source/kernel/condasm.inc index 254241f0..18b06b76 100644 --- a/source/kernel/condasm.inc +++ b/source/kernel/condasm.inc @@ -16,6 +16,5 @@ RR equ 0 ;Level of release (0: no release level) ; ;----------------------------------------------------------------------------- ; - .list ; diff --git a/source/kernel/drivers/SunriseIDE/sunride.asm b/source/kernel/drivers/SunriseIDE/sunride.asm index cb9f058f..23cb6bdb 100644 --- a/source/kernel/drivers/SunriseIDE/sunride.asm +++ b/source/kernel/drivers/SunriseIDE/sunride.asm @@ -6,7 +6,6 @@ ; By FRS ;MASTER_ONLY constant must be defined externally to generate the master-only variant. - INCLUDE ../../macros.inc org 4000h ds 4100h-$,0 ; DRV_START must be at 4100h @@ -1053,8 +1052,8 @@ DEV_RW2: ld b,0 ret DEV_RW_NO0SEC: - LD_IYL_N e ;ld iyl,e - LD_IYH_N d ;ld iyh,d + ld iyl,e + ld iyh,d ld a,(iy+3) and 11110000b jp nz,DEV_RW_NOSEC ;Only 28 bit sector numbers supported @@ -1092,7 +1091,7 @@ DEV_ATA_RD: call CHK_RW_FAULT ret c - LD_IYL_N b ;ld iyl,b ; iyl=number of blocks + ld iyl,b ; iyl=number of blocks ex de,hl ; de=destination address ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) @@ -1109,7 +1108,7 @@ DEV_ATA_WR: ld a,ATACMD.PWRSECTRT ; PIO write sector with retry call PIO_CMD jp c,DEV_RW_ERR - LD_IYL_N B ;ld iyl,b ; iyl=number of blocks + ld iyl,b ; iyl=number of blocks ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) call WRITE_DATA @@ -1127,8 +1126,8 @@ DEV_ATAPI_RW: push de ld e,(ix+DEVINFO.pBASEWRK) ; hl=pointer to WorkArea ld d,(ix+DEVINFO.pBASEWRK+1) - LD_IYL_N e ;ld iyl,e - LD_IYH_N d ;ld iyh,d ; iy=WRKAREA pointer + ld iyl,e + ld iyh,d ; iy=WRKAREA pointer pop de ; Set the block size @@ -1175,7 +1174,7 @@ DEV_ATAPI_RD: push bc push hl push iy - LD_IYL_N 1 ;ld iyl,1 ; 1 block + ld iyl,1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1218,13 +1217,13 @@ DEV_ATAPI_RD: ex de,hl ; de=destination address .loopsector: push bc - LD_IYL_N C ;ld iyl,c ; get the number of blocks per sector + ld iyl,c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr ld hl,IDE_DATA call RUN_HLPR - DEC_IYL ;dec iyl + dec iyl jr nz,.loopblock pop bc djnz .loopsector @@ -1246,7 +1245,7 @@ DEV_ATAPI_WR: push bc push hl push iy - LD_IYL_N 1 ;ld iyl,1 ; 1 block + ld iyl,1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1288,7 +1287,7 @@ DEV_ATAPI_WR: pop bc .loopsector: push bc - LD_IYL_N C ;ld iyl,c ; get the number of blocks per sector + ld iyl,c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr @@ -1296,7 +1295,7 @@ DEV_ATAPI_WR: call RUN_HLPR call CHK_RW_FAULT jr c,.rderr - DEC_IYL ;dec iyl + dec iyl jp nz,.loopblock pop bc djnz .loopsector @@ -1842,13 +1841,13 @@ LUN_NFO_ATAPI: ld a,ATAPICMD.PACKET ; PIO send PACKET command call PIO_CMD - jp c,.errorpop + jr c,.errorpop pop hl push hl ; Source=PCTBUF ld bc,12 ; 12 byte packet push iy - LD_IYL_N 1 ;ld iyl,1 + ld iyl,1 call WRITE_DATA ; Send the packet to the device pop iy jr nc,.rdmediapropr ; No error? Then read media proprieties @@ -1866,7 +1865,7 @@ LUN_NFO_ATAPI: pop de ; Destination=PCTBUFF ld bc,8 ; 8 byte response push iy - LD_IYL_N 1 ;ld iyl,1 + ld iyl,1 call READ_DATA pop iy jr c,LUN_INFO_ERROR @@ -2463,7 +2462,7 @@ READ_DATA: ret c ld hl,IDE_DATA call RUN_HLPR - DEC_IYL ;dec iyl + dec iyl jp nz,.loop ret @@ -2482,7 +2481,7 @@ WRITE_DATA: call RUN_HLPR call CHK_RW_FAULT ret c - DEC_IYL ;dec iyl + dec iyl jp nz,.loop ret diff --git a/source/kernel/drivers/Tang/chgbnk.mac b/source/kernel/drivers/Tang/chgbnk.mac deleted file mode 100644 index 9fb5d6c3..00000000 --- a/source/kernel/drivers/Tang/chgbnk.mac +++ /dev/null @@ -1,39 +0,0 @@ - .z80 - title CHGBNK - Bank Switching Module for the ASCII16 mapper -; -;----------------------------------------------------------------------- -; -; This is a manufacturer-supplied bank switching module. This module -; is placed at the tail of every local banks of DOS2-ROM. -; -; This is a sample program. DOS2-ROM has no assumptions on the -; mechanism of bank switching, for example, where the bank register is, -; which bits are assigned to bank switching, etc. The bank register -; does not have to be readable. -; -; Entry: Acc = 0 --- switch to bank #0 -; 1 --- switch to bank #1 -; 2 --- switch to bank #2 -; 3 --- switch to bank #3 -; 4 --- switch to bank #4 -; 5 --- switch to bank #5 -; 6 --- switch to bank #6 -; 7 --- switch to bank #7 -; Exit: None -; -; Only AF can be modified -; -; *** CODE STRTS HERE *** CAUTION!! This must be the first module. -; -BNKREG equ 6000h ;System IC version - - org 7FD0h - -CHGBNK: - - ld (BNKREG),a - ret -; - defs (8000h-7FD0h)-($-CHGBNK),0FFh -; - end diff --git a/source/kernel/drivers/Tang/driver.mac b/source/kernel/drivers/Tang/driver.mac deleted file mode 100644 index 99ff3517..00000000 --- a/source/kernel/drivers/Tang/driver.mac +++ /dev/null @@ -1,1425 +0,0 @@ - ; Device-based driver for the Tang Nano 20k interface for Nextor - ; - ; Version by Luis Antoniosi - ; Based on version 0.1 by Konamiman - - org 4100h - -DRV_START: - - .print1 MSX Tang uSD Driver - -;----------------------------------------------------------------------------- -; -; Driver configuration constants -; - -;Driver type: -; 0 for drive-based -; 1 for device-based - -DRV_TYPE equ 1 - -;Hot-plug devices support (device-based drivers only): -; 0 for no hot-plug support -; 1 for hot-plug support - -DRV_HOTPLUG equ 0 - -DEBUG equ 0 ;Set to 1 for debugging, 0 to normal operation - -;Driver version - -VER_MAIN equ 1 -VER_SEC equ 0 -VER_REV equ 0 - - -;----------------------------------------------------------------------------- -; -; SD Controller registers and bit definitions - -SDC_ENABLE equ 7E00h ; wo: 1: enable SDC register, 0: disable -SDC_CMD equ SDC_ENABLE+1 ; wo: cmd to SDC fpga: 1=read, 2=write -SDC_STATUS equ SDC_CMD+1 ; ro: SDC status bits -SDC_SADDR equ SDC_STATUS+1 ; wo: 4 bytes: sector addr for read/write -SDC_C_SIZE equ SDC_SADDR+4 ; ro: 3 bytes: device size blocks -SDC_C_SIZE_MULT equ SDC_C_SIZE+3 ; ro: 3 bits size multiplier -SDC_RD_BL_LEN equ SDC_C_SIZE_MULT+1 ; ro: 4 bits block length -SDC_CTYPE equ SDC_RD_BL_LEN+1 ; ro: SDC Card type: 0=unknown, 1=SDv1, 2=SDv2, 3=SDHCv2 -SDC_MID equ SDC_CTYPE+1 -SDC_OID equ SDC_MID+1 -SDC_PNM equ SDC_OID+2 -SDC_PSN equ SDC_PNM+5 -SDC_CRC16 equ SDC_PSN+4 - -SDC_SDATA equ 7C00h ; rw: 7C00h-7Dff - sector transfer area - -SDC_BUSY equ 080h -SDC_CRC equ 001h -SDC_TIMEOUT equ 002h - -SDC_READ equ 001h -SDC_WRITE equ 002h -SDC_INIT equ 080h -;----------------------------------------------------------------------------- -; -; Standard BIOS and work area entries - -CHPUT equ 00A2h ;Character output -CHGET equ 009Fh -INITXT equ 006Ch -CLS equ 0848H -MSXVER equ 002DH - -LINL40 equ 0F3AEh ; Width -LINLEN equ 0F3B0h -;----------------------------------------------------------------------------- -; -; Work area definition -; -;+0-3: Device size in sectors -;+4-7: current sector r/w -;----------------------------------------------------------------------------- -; -; Error codes for DEV_RW and DEV_FORMAT -; - -.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 -;----------------------------------------------------------------------------- -; -; Routines 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,bank -; ld hl,address -; ld ix,RDBANK -; call CALBNK - -RDBANK equ 403Ch - - -;* This routine temporarily switches kernel bank 0/3, -; then jumps to CALBAS in MSX BIOS. -; This is necessary so that kernel bank is correct in case of BASIC error. - -CALBAS equ 403Fh - - -;* Call a routine in another bank. -; Must be used if the driver spawns across more than one bank. -; Input: A = bank -; IX = routine address -; AF' = AF for the routine -; BC, DE, HL, IY = input for the 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,slot -; ex af,af' -; xor a -; ld ix,GWORK -; call CALBNK - -GWORK equ 4045h - - -;* Call a routine in the driver bank. -; Input: (BK4_ADD) = routine address -; AF, BC, DE, HL, IY = input for the routine -; -; Calls a routine in the driver bank. This routine is the same as CALBNK, -; except that the routine address is passed in address BK4_ADD (#F2ED) -; instead of IX, and the bank number is always 5. This is useful when used -; in combination with CALSLT to call a driver routine from outside -; the driver itself. -; -; Note that register IX can't be used as input parameter, it is -; corrupted before reaching the invoked code. - -CALDRV equ 4048h - - -;----------------------------------------------------------------------------- -; -; 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) - - db 1+(2*DRV_HOTPLUG) - -;Reserved byte - db 0 - -;Driver name - -DRV_NAME: - db "WonderTANG! uSD Driver" - ds 32-($-DRV_NAME)," " - -;Jump table - - 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 15 - - jp DEV_RW - jp DEV_INFO - jp DEV_STATUS - jp LUN_INFO - jp DEV_FORMAT - jp DEV_CMD - - -;----------------------------------------------------------------------------- -; -; 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, it is called twice: -; -; 1) First execution, for information gathering. -; Input: -; A = 0 -; B = number of available drives (drive-based drivers only) -; 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 -; (255 if device-based driver, unless 4 is pressed at boot) -; -; 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: - ;--- If first execution, just inform that no work area is needed - ; (the 8 bytes in SLTWRK are enough) - - or a - ld hl,0 - ld a,0 - ret z ;Note that Cy is 0 (no interrupt hooking needed) - - ld a,(MSXVER) - cp 1 ; > MSX 2 - jr c,MSX1 - ld a,80 - jr SETSCRN -MSX1: - ld a,40 -SETSCRN: - ld (LINL40),a - call INITXT - - ld de,INFO_S - call PRINT - - ld de,SEARCH_S - call PRINT - - call MY_GWORK - call SDC_ON - ld a,SDC_INIT - ld (SDC_CMD),a - - ld (ix),0 ; clear device data - -WAIT_RESET: - ld de,2047 ;Timeout -WAIT_RESET1: - ld a,0 - cp e - jr nz,WAIT_DOT ;Print dots while waiting -; ld a,46 -; call CHPUT -WAIT_DOT: - call CHECK_ESC - jp c,INIT_NO_DEV - ld b,255 -WAIT_RESET2: - ld a,(SDC_STATUS) - and SDC_BUSY - jr z,WAIT_RESET_END ;Wait for BSY to clear and DRDY to set - djnz WAIT_RESET2 - dec de - ld a,d - or e - jr nz,WAIT_RESET1 - jp INIT_NO_DEV -WAIT_RESET_END: - - ld a,(SDC_CTYPE) - or a - jp z,INIT_NO_DEV - - ld de,SDV1 - cp 1 - jr z,PRINT_CTYPE - ld de,SDV2 - cp 2 - jr z,PRINT_CTYPE - ld de,SDHCV2 - cp 3 - jr z,PRINT_CTYPE - ld de,UNKNOWN - -PRINT_CTYPE: ; print card type - call PRINT - - ld de,CRLF_S - call PRINT - - ld hl,SDC_C_SIZE - ld e,(hl) - inc hl - ld d,(hl) - inc hl - ld c,(hl) ; c:de = c_size - inc hl - - ld hl,1 - add hl,de - ex de,hl - - ld a,0 - adc a,c ; c:de = c_size + 1 - ld c,a - jr nc,NO_OVL - ld a,1 ; overflow - jr OVL -NO_OVL: - xor a -OVL: - - ex af,af' ; preserve msb - push af - - ld hl,SDC_C_SIZE_MULT - ld b,(hl) ; b = c_size_mult - inc hl - inc b - inc b ; b = c_size_mult + 2 - - ld a,(hl) ; a = read_bl_len - - add a,b - sub 9 - jr z,NO_SHIFT - ld b,a ; b = read_bl_len + c_size_mult + 2 - 9 - - pop af - ex af,af' ; restore msb -CALC_SIZE: - sla e - rl d - rl c - rl a - djnz CALC_SIZE - jr ST_SIZE -NO_SHIFT: - pop af - ex af,af' ; restore msb - -ST_SIZE: - - ld (ix+0),e ; store card size in sectors (512 bytes) in work area (32-bit) - ld (ix+1),d - ld (ix+2),c - ld (ix+3),a - - ld de,CRLF_S - call PRINT - -;;;; - - ; wait some time - ld b,0 -outer: - push bc - ld b,0 -inner: - nop - push ix - pop ix - djnz inner - pop bc - djnz outer - - - jr DRV_INIT_END - -INIT_NO_DEV: - call CHECK_ESC - jr c,INIT_NO_DEV - - ld de,CRLF_S - call PRINT - ld de,NODEVS_S - call PRINT - - xor a - ld (ix+0),a - ld (ix+1),a - ld (ix+2),a - ld (ix+3),a - - ;--- End of the initialization procedure -DRV_INIT_END: - ;;;;;;;;;;;;;;;;;;; -; ld de,CRLF_S -; call PRINT -; ld de,CRLF_S -; call PRINT -; xor a -; ld (ix+4),a -; ld (ix+5),a -; ld (ix+6),a -; ld (ix+7),a - - -; next_sect: -; ld b,0 -; ld a,(ix+4) -; ld (SDC_SADDR+0),a -; add 1 ; increment sector -; ld (ix+4),a ; store back incremented -; ld a,(ix+5) -; ld (SDC_SADDR+1),a -; adc b -; ld (ix+5),a -; ld a,(ix+6) -; ld (SDC_SADDR+2),a -; adc b -; ld (ix+6),a -; ld a,(ix+7) -; ld (SDC_SADDR+3),a -; adc b -; ld (ix+7),a -; ld a,SDC_READ -; ld (SDC_CMD),a -; call WAIT_CMD_RDY - -; ld hl,SDC_SDATA ; src data - -; ld b,19 -; lines: -; push bc -; ld b,26 -; rows: -; ld a,(hl) -; inc hl -; call HEXPUT -; ld a,' ' -; call CHPUT -; djnz rows -; ld de,CRLF_S -; call PRINT -; pop bc -; djnz lines -; ld b,18 -; lastrow: -; ld a,(hl) -; inc hl -; call HEXPUT -; ld a,' ' -; call CHPUT -; djnz lastrow -; ld de,CRLF_S -; call PRINT -; call CHGET -; cp 27 -; jp nz,next_sect -;----------------------------------------------------------------------------- -; -; 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): - - ;;;;;;;;;;;;;;;;; - - call SDC_OFF - ret - -; HEXPUT: -; push af -; push bc -; ld b,a -; srl a -; srl a -; srl a -; srl a -; call HEXCHAR -; ld a,b -; and 00fh -; call HEXCHAR -; pop bc -; pop af -; ret - -; HEXCHAR: -; cp 10 -; jr c,digit -; add 'A'-10 -; jp CHPUT -; digit: -; add '0' -; jp CHPUT - - -BINTOHEX: - ld c,a - srl a - srl a - srl a - srl a - call HEXNIBLE - ld b,a - ld a,c - and 00fh - call HEXNIBLE - ld c,a - ret -HEXNIBLE: - cp 10 - jr c,ISDIGT - add 'A'-10 - ret -ISDIGT: - add '0' - 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 statement ("CALL") handler. -; Works the expected way, except that CALBAS in kernel page 0 -; must be called instead of CALBAS in MSX BIOS. - -DRV_BASSTAT: - scf - ret - - -;----------------------------------------------------------------------------- -; -; BASIC expanded device handler. -; Works the expected way, except that CALBAS in kernel page 0 -; must be called instead of CALBAS in MSX BIOS. - -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: -; ld a,1 -; ret - -;===== -;===== BEGIN of DEVICE-BASED specific routines -;===== - -;----------------------------------------------------------------------------- -; -; 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/written - -DEV_RW: - jp c,WRSECT -RDSECT: - - or a ;Check device index - jp z,RW_ERR1 - cp 2 - jp nc,RW_ERR1 - - call MY_GWORK - - call SDC_ON - call WAIT_CMD_RDY - ld a,(SDC_STATUS) - and SDC_BUSY - jp nz,RW_BUSY - - ld a,(de) - inc de - ld (ix+4),a - ld a,(de) - inc de - ld (ix+5),a - ld a,(de) - inc de - ld (ix+6),a - ld a,(de) - inc de - ld (ix+7),a ; current sector - - ex de,hl ; de = destination - push bc ; nr of sectors - -RD_LOOP: - push bc ; nr of sectors - ld b,0 - ld a,(ix+4) - ld (SDC_SADDR+0),a - add 1 ; increment sector - ld (ix+4),a ; store back incremented - ld a,(ix+5) - ld (SDC_SADDR+1),a - adc b - ld (ix+5),a - ld a,(ix+6) - ld (SDC_SADDR+2),a - adc b - ld (ix+6),a - ld a,(ix+7) - ld (SDC_SADDR+3),a - adc b - ld (ix+7),a - ld a,SDC_READ - ld (SDC_CMD),a - call WAIT_CMD_RDY - jr c,R_ERR_LOOP - ld bc,512 - ld hl,SDC_SDATA ; src data - ldir - pop bc - djnz RD_LOOP - pop bc ; nr of sectors - call SDC_OFF - - ld a,0 - or a - ret - - -R_ERR_LOOP: - ld a,(SDC_STATUS) - ld e,a ; save stat - call SDC_OFF - pop bc - ld d,b - pop bc - ld a,d - sub b - ld b,a ; sectors written - ld e,a - and SDC_TIMEOUT - jr nz,R_TIMEOUT - ld a,.DISK - scf - ret -R_TIMEOUT: - ld a,.NRDY - scf - ret - -W_ERR_LOOP: - ld a,(SDC_STATUS) - ld e,a ; save stat - call SDC_OFF - pop bc - ld d,b - pop bc - ld a,d - sub b - ld b,a ; sectors written - ld e,a - and SDC_CRC - jr nz,W_WRERR - ld a,.DISK - scf - ret -W_WRERR: - - ;ld a,0f3h - ;call SETBORDER - - ld a,.WRERR - scf - ret - -RW_DISK: - - ;ld a,0fDh - ;call SETBORDER - - ld b,.DISK - jr RW_ERR -RW_BUSY: - - ;ld a,0f5h - ;call SETBORDER - - ld b,.NRDY - jr RW_ERR -RW_ERR1: - - ;ld a,0f7h - ;call SETBORDER - - ld b,.IDEVL -RW_ERR: - - ;ld a,0feh - ;call SETBORDER - - call SDC_OFF - ld a,b - ld b,0 - scf - ret - -WRSECT: - or a ;Check device index - jr z,RW_ERR1 - cp 2 - jr nc,RW_ERR1 - - call MY_GWORK - - call SDC_ON - call WAIT_CMD_RDY - ld a,(SDC_STATUS) - and SDC_BUSY - jr nz,RW_BUSY - - ld a,(de) - inc de - ld (ix+4),a - ld a,(de) - inc de - ld (ix+5),a - ld a,(de) - inc de - ld (ix+6),a - ld a,(de) - inc de - ld (ix+7),a ; current sector - - push bc ; nr of sectors - -WR_LOOP: - push bc ; nr of sectors - ld b,0 - ld a,(ix+4) - ld (SDC_SADDR+0),a - add 1 ; increment sector - ld (ix+4),a - ld a,(ix+5) - ld (SDC_SADDR+1),a - adc b - ld (ix+5),a - ld a,(ix+6) - ld (SDC_SADDR+2),a - adc b - ld (ix+6),a - ld a,(ix+7) - ld (SDC_SADDR+3),a - adc b - ld (ix+7),a - - ld bc,512 - ld de,SDC_SDATA ; hl = src data - ldir - - ld a,SDC_WRITE - ld (SDC_CMD),a - call WAIT_CMD_RDY - jp c,W_ERR_LOOP - - pop bc - djnz WR_LOOP - pop bc ; nr of sectors - call SDC_OFF - - ld a,0 - or a - ret - - - - -;----------------------------------------------------------------------------- -; -; 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 8. 1 if the device has no logical -; drives (which is functionally equivalent to having only one). -;+1 (1): Flags, always zero -; -; 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: - - or a ;Check device index - jr z,DEV_INFO_ERR1 - cp 2 - jr nc,DEV_INFO_ERR1 - - call MY_GWORK - - call SDC_ON - - ld a,b - or a - jr z,BASIC_INFO - cp 1 - jr z,MANUFACTURER - cp 2 - jr z,DEVICE_NAME - cp 3 - jr z,SERIAL_NUMBER - -MANUFACTURER: -DEV_INFO_ERR2: - call SDC_OFF - ld a,2 - ret - -BASIC_INFO: - - ld a,1 - ld (hl),a - inc hl - xor a - ld (hl),a -DEV_INFO_OK: - xor a - call SDC_OFF - ret - -DEVICE_NAME: - ex de,hl - ld hl,SDC_OID - ld b,7 -COPNAME: - ld a,(hl) - cp 32 - jr c,NONASC - or 128 - jr nz,NONASC - jr STORASC -NONASC: - ld a,' ' -STORASC: - ld (de),a - inc de - inc hl - djnz COPNAME - ex de,hl - ld b,64-7 -STR_PAD: - ld a,' ' - ld (hl),a - inc hl - djnz STR_PAD - - jr DEV_INFO_OK - -SERIAL_NUMBER: - - ld de,SDC_PSN+3 - ld a,(de) - dec de - call BINTOHEX - ld (hl),b - inc hl - ld (hl),c - inc hl - ld a,(de) - dec de - call BINTOHEX - ld (hl),b - inc hl - ld (hl),c - inc hl - ld a,(de) - dec de - call BINTOHEX - ld (hl),b - inc hl - ld (hl),c - inc hl - ld a,(de) - dec de - call BINTOHEX - ld (hl),b - inc hl - ld (hl),c - inc hl - ld b,64-8 - jr STR_PAD - ;--- Termination with error - -DEV_INFO_ERR1: - call SDC_OFF - ld a,1 - 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. - -DEV_STATUS: - call CHECK_DEV_LUN - jr c,DEV_STAT_ERR - - ld a,(ix+0) - or a - jr nz,DEV_OK - ld a,(ix+1) - or a - jr nz,DEV_OK - ld a,(ix+2) - or a - jr nz,DEV_OK - ld a,(ix+3) - or a - jr nz,DEV_OK -DEV_STAT_ERR: - ld a,0 - ret - -DEV_OK: - ld a,1 - 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 (0, if not a hard disk) -;+10 (1): Number of heads (0, if not a hard disk) -;+11 (1): Number of sectors per track (0, if not a hard disk) - -LUN_INFO: - - call CHECK_DEV_LUN - jr c,LUN_INFO_ERROR - - call MY_GWORK - - xor a - ld (hl), a ; block device - inc hl - ld (hl),0 - inc hl - ld (hl),2 ; sector size - inc hl - ld a,(ix+0) - ld (hl),a - inc hl - ld a,(ix+1) - ld (hl),a - inc hl - ld a,(ix+2) - ld (hl),a - inc hl - ld a,(ix+3) - ld (hl),a ; total of sectors - inc hl - xor a - ld (hl),a ; medium flags - inc hl - ld (hl),a ; - inc hl - ld (hl),a ; num of cyls - inc hl - ld (hl),a ; num of heads - inc hl - ld (hl),a ; num of sectors per track - - xor a - ret - -LUN_INFO_ERROR: - ld a,1 - ret - - -;----------------------------------------------------------------------------- -; -; 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 -;===== - - -;======================= -; Subroutines -;======================= - -;----------------------------------------------------------------------------- -; -; Enable or disable the SPI registers - -SDC_ON: - ld a,1 - ld (SDC_ENABLE),a - ret - -SDC_OFF: - xor a - ld (SDC_ENABLE),a - ret - -;----------------------------------------------------------------------------- -; -; Wait the BSY flag to clear and RDY flag to be set -; if we wait for more than 30s, send a soft reset to IDE BUS -; if the soft reset didn't work after 30s return with error -; -; Input: Nothing -; Output: Cy=1 if timeout after soft reset -; Preserves: DE and BC - -WAIT_CMD_RDY: - push de - push bc - ld de,2047 ;8142 ;Limit the wait to 30s -WAIT_RDY1: - ld b,255 -WAIT_RDY2: - ld a,(SDC_STATUS) - and SDC_BUSY+SDC_TIMEOUT+SDC_CRC - or a - jr z,WAIT_RDY_END - djnz WAIT_RDY2 - dec de - ld a,d - or e - jr nz,WAIT_RDY1 - scf -WAIT_RDY_END: - pop bc - pop de - ret - -;----------------------------------------------------------------------------- -; -; Read the keyboard matrix to see if ESC is pressed -; Output: Cy = 1 if pressed, 0 otherwise - -CHECK_ESC: - ld b,7 - in a,(0AAh) - and 11110000b - or b - out (0AAh),a - in a,(0A9h) - bit 2,a - jr nz,CHECK_ESC_END - scf -CHECK_ESC_END: - 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 - -;----------------------------------------------------------------------------- -; -; Check the device index and LUN -; Input: A = device index, B = lun -; Output: Cy=0 if OK, 1 if device or LUN invalid -; IX = Work area for the device -; Modifies F, C - -CHECK_DEV_LUN: - or a ;Check device index - scf - ret z - cp 2 - ccf - ret c - - ld a,b ;Check LUN number - cp 1 - scf - ret nz - - or a - ret - - -;----------------------------------------------------------------------------- -; -; Obtain the work area address for the driver -; Input: A=1 to obtain the work area for the master, 2 for the slave -; Preserves A - -MY_GWORK: - xor a - EX AF,AF' - XOR A - LD IX,GWORK - call CALBNK - ret - -;SETBORDER: -; out (099h),a -; ld a,087h -; out (099h),a -; ret - -;======================= -; Strings -;======================= - -INFO_S: - db "WonderTANG! v" - db VER_MAIN+"0",".",VER_SEC+"0",".",VER_REV+"0",13,10 - db "Synthetic Juice for your MSX",13,10,13,10 - db "2023 Luis Antoniosi",13,10 - db "Beautiful British Columbia",13,10 - db "Canada",13,10,13,10 - db "SS0: Nextor BIOS + MicroSD",13,10 - db "SS1: FM ROM + OPLL",13,10 - db "SS2: Super MegaRAM SCC+ 2MB",13,10 - db "SS3: Memory Mapper 4MB",13,10 - db "---: SMS VDP 16KB ",13,10,13,10,0 - -SEARCH_S: - db "Searching: ",0 - -NODEVS_S: - db "Not found",13,10,0 - -UNKNOWN: - db "UNKOWN",0 -SDV1: - db "SDV1",0 -SDV2: - db "SDV2",0 -SDHCV2: - db "SDHCV2",0 - -CRLF_S: - db 13,10,0 - - -;----------------------------------------------------------------------------- -; -; Padding up to the required driver size - -DRV_END: - - ds 3ED0h-(DRV_END-DRV_START) - - end diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac index 768e149a..f7fc0ff0 100644 --- a/source/kernel/drv.mac +++ b/source/kernel/drv.mac @@ -807,8 +807,8 @@ IS_DVB: jr nz,IS_NOT_DVB ld iy,(DVB_TABLE##) - LD_N_IYH a ;ld a,iyh - OR_IYL ;or iyl + ld a,iyh + or iyl jr z,IS_NOT_DVB ld a,(iy) @@ -962,7 +962,7 @@ READ_BOOT: ld ix,DEV_RW## jp DO_CALBNK - IF UNDOC_OP + ;----------------------------------------------------------------------------- ; ; Convert the disk error returned by a device-based routine, @@ -1014,7 +1014,7 @@ COMP16: ld a,l sub e ret - ENDIF + ;----------------------------------------------------------------------------- ; ; Default DPB, it contains data for a 720K disk drive @@ -1082,61 +1082,6 @@ KDERJ: ALIGN 7BD0h ;Here goes the 1K free area at the end of banks 0 and 3 - IFE UNDOC_OP -;----------------------------------------------------------------------------- -; -; Convert the disk error returned by a device-based routine, -; into its drive-based equivalent - -POP_CONV_ERR: - inc sp - inc sp - -CONV_ERR: - or a - ret z - ;jr c,CONVE2 - ;xor a - ;ret -CONVE2: - - push bc - ld b,0 - cp .WPROT## - jr z,CONV_ERR_END - ld b,2 - cp .NRDY## - jr z,CONV_ERR_END - ld b,4 - cp .DATA## - jr z,CONV_ERR_END - ld b,6 - cp .SEEK## - jr z,CONV_ERR_END - ld b,8 - cp .RNF## - jr z,CONV_ERR_END - ld b,10 - cp .WRERR## - jr z,CONV_ERR_END - ld b,12 - -CONV_ERR_END: - ld a,b - pop bc - scf - ret - -COMP16: - ld a,h - sub d - ret nz - ld a,l - sub e - ret - ENDIF - - finish ; end diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index d9419972..755846f8 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -8,14 +8,14 @@ TRUE equ NOT FALSE ; -const MACRO name,N -name equ (N) +const macro name,value +name equ (value) public name endm ; ; ; -warn MACRO text +warn macro text if1 .printx % text endif @@ -23,7 +23,7 @@ warn MACRO text ; ; ; -error MACRO text +error macro text if1 .error text endif @@ -31,17 +31,17 @@ error MACRO text ; ; ; -pr_dec MACRO msg1,N,msg2 - warn +pr_dec macro msg1,value,msg2 + warn endm ; ; -pr_hex MACRO msg1,N,msg2 - warn +pr_hex macro msg1,value,msg2 + warn endm ; ; -code MACRO instr,arg +code macro instr,arg _code_ defl 0 @@ -160,7 +160,7 @@ endm OFFSET equ 4100h PHASED defl FALSE ; -rammod MACRO +rammod macro PHASED defl TRUE .phase $-OFFSET endm @@ -168,7 +168,7 @@ PHASED defl TRUE ; start: ; -finish MACRO name +finish macro name if PHASED .dephase endif @@ -179,10 +179,10 @@ finish MACRO name ; ; -;--- The "proc" MACRO is used to define a label that is invoked +;--- The "proc" macro is used to define a label that is invoked ; at RAM in page 0 (when PHASED) or at ROM bank 4 (when not PHASED). -proc MACRO name ;;Macro for declaring a public +proc macro name ;;Macro for declaring a public if PHASED name&: ;; label to be called. .dephase @@ -196,7 +196,7 @@ name&: ;;For local call ; ; ; -pcall MACRO cc,name ;;Macro for calling an external +pcall macro cc,name ;;Macro for calling an external ;; routine. ifb call ?&cc&##-OFFSET ;;Unconditional CALL. @@ -209,7 +209,7 @@ pcall MACRO cc,name ;;Macro for calling an external ; ; STROUT implementation with the ESC-Y bug corrected. -; It is declared as as MACRO because it is defined +; It is declared as as macro because it is defined ; twince in the kernel (bdos.mac, char.mac) ; and once more in MSXDOS2.SYS. ; @@ -217,7 +217,7 @@ pcall MACRO cc,name ;;Macro for calling an external ; RETDIR is the routine jumped to at end. If 0, ret is generated instead. ; LOADCE: if specified, E and C registers are loaded prior to calling CONOUT. -do_strout MACRO OUTDIR,RETDIR,LOADCE +do_strout macro OUTDIR,RETDIR,LOADCE local stro_init local STROU2 local ST10 @@ -269,7 +269,7 @@ ST10: PUSH DE endm -djpnz MACRO address +djpnz macro address dec b jp nz,address endm @@ -278,183 +278,3 @@ djpnz MACRO address ; .list ; - -UNDOC_OP equ 0 ; user or not undocummented Z-80 instructions - - IF UNDOC_OP -;;;;;;;;;;;;;;;;;;;;;;;;;;; - -LD_IXL_N MACRO N - ld ixl,N - ENDM - -LD_IXH_N MACRO N - ld ixh,N - ENDM - -LD_IYL_N MACRO N - ld iyl,N - ENDM - -LD_IYH_N MACRO N - ld iyh,N - ENDM - -LD_N_IXH MACRO N - ld N,ixh - ENDM - -LD_N_IXL MACRO N - ld N,ixl - ENDM - -LD_N_IYH MACRO N - ld N,iyh - ENDM - -LD_N_IYL MACRO N - ld N,iyl - ENDM - -CP_IXH MACRO - cp ixh - ENDM - -CP_IXL MACRO - cp ixl - ENDM - -CP_IYH MACRO - cp iyh - ENDM - -CP_IYL MACRO - cp iyl - ENDM - - -OR_IYL MACRO - or iyl - ENDM - -DEC_IYL MACRO - dec iyl - ENDM - - ELSE - -;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -LD_IXH_N MACRO N - ex (sp),ix - ex (sp),hl - ld h,N - ex (sp),hl - ex (sp),ix - ENDM - -LD_IXL_N MACRO N - ex (sp),ix - ex (sp),hl - ld l,N - ex (sp),hl - ex (sp),ix - ENDM - -LD_IYH_N MACRO N - ex (sp),iy - ex (sp),hl - ld h,N - ex (sp),hl - ex (sp),iy - ENDM - -LD_IYL_N MACRO N - ex (sp),iy - ex (sp),hl - ld l,N - ex (sp),hl - ex (sp),iy - ENDM - -LD_N_IXH MACRO N - ex (sp),ix - ex (sp),hl - ld N,h - ex (sp),hl - ex (sp),ix - ENDM - -LD_N_IXL MACRO N - ex (sp),ix - ex (sp),hl - ld N,l - ex (sp),hl - ex (sp),ix - ENDM - -LD_N_IYH MACRO N - ex (sp),iy - ex (sp),hl - ld N,h - ex (sp),hl - ex (sp),iy - ENDM - -LD_N_IYL MACRO N - ex (sp),iy - ex (sp),hl - ld N,l - ex (sp),hl - ex (sp),iy - ENDM - -CP_IXH MACRO - ex (sp),ix - ex (sp),hl - cp h` - ex (sp),hl - ex (sp),ix - ENDM - -CP_IXL MACRO - ex (sp),ix - ex (sp),hl - cp l - ex (sp),hl - ex (sp),ix - ENDM - -CP_IYH MACRO - ex (sp),iy - ex (sp),hl - cp h - ex (sp),hl - ex (sp),iy - ENDM - -CP_IYL MACRO - ex (sp),iy - ex (sp),hl - cp l - ex (sp),hl - ex (sp),iy - ENDM - -OR_IYL MACRO - ex (sp),iy - ex (sp),hl - or l - ex (sp),hl - ex (sp),iy - ENDM - -DEC_IYL MACRO - ex (sp),iy - ex (sp),hl - dec l - ex (sp),hl - ex (sp),iy - ENDM - - ENDIF diff --git a/source/tools/MAPDRV.MAC b/source/tools/MAPDRV.MAC index 8a831551..eb27d9e8 100644 --- a/source/tools/MAPDRV.MAC +++ b/source/tools/MAPDRV.MAC @@ -1,13 +1,13 @@ .z80 - include MACROS.INC -;ld_a_iyl macro -; db 0FDh -; ld a,l -; endm + ;include MACROS.INC +ld_a_iyl macro + db 0FDh + ld a,l + endm FIB equ 3000h - jp START2 + jp START ; ------------------------------------------------------------------------------- db 13 @@ -63,7 +63,7 @@ USAGE_S: db "TYPE MAPDRV.COM for more details.",13,10 db 0 -START2: +START: call CHK250## ld de,BUF @@ -117,7 +117,7 @@ NO_LOCK: ;* Partition number, or "d", "u", or file name ld de,BUF - ld_n_iyl a + ld_a_iyl inc iy call EXTPAR## ld b,.NOPAR## @@ -152,7 +152,7 @@ IS_PART: ;* Device, LUN ld de,BUF - ld_n_iyl a + ld_a_iyl inc iy call EXTPAR## jp c,DO_MAP @@ -183,7 +183,7 @@ OK_DEVLUN: ;* Slot, subslot, segment ld de,BUF - ld_n_iyl a + ld_a_iyl inc iy call EXTPAR## jp c,DO_MAP diff --git a/source/tools/SHARED.MAC b/source/tools/SHARED.MAC index ed1c4ddc..3f666d87 100644 --- a/source/tools/SHARED.MAC +++ b/source/tools/SHARED.MAC @@ -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_N a ;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_N_IXH a ;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 + 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_N_IXH a ;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_N_IXL a ;ld a,ixl + ld a,ixl or a jr FINEXTP EXTPERR: From 26782a9ee27302a4760d7f501b293e6a11033429 Mon Sep 17 00:00:00 2001 From: lfantoniosi Date: Mon, 20 Nov 2023 23:29:42 -0800 Subject: [PATCH 9/9] option to replace undocumented opcodes (Z180 compatible) build as: make ASSEMBLE_SYMBOLS=DISABLE_UNDOCUMENTED_OPCODES --- source/Makefile | 4 +- source/kernel/Makefile | 10 +- source/kernel/bank0/init.mac | 25 +- source/kernel/bank1/dosinit.mac | 8 +- source/kernel/bank4/partit.mac | 38 +-- source/kernel/drivers/SunriseIDE/sunride.asm | 33 ++- source/kernel/drv.mac | 50 ++-- source/kernel/macros.inc | 234 +++++++++++++++++++ source/tools/Makefile | 8 +- 9 files changed, 345 insertions(+), 65 deletions(-) diff --git a/source/Makefile b/source/Makefile index cfb61ad9..06b1237d 100644 --- a/source/Makefile +++ b/source/Makefile @@ -4,9 +4,9 @@ # The makefiles on each directory can be used independently as well. all: - $(MAKE) -C kernel + $(MAKE) -C kernel ASSEMBLE_SYMBOLS=$(ASSEMBLE_SYMBOLS) $(MAKE) -C command/msxdos - $(MAKE) -C tools + $(MAKE) -C tools ASSEMBLE_SYMBOLS=$(ASSEMBLE_SYMBOLS) $(MAKE) -C tools/C .PHONY: clean diff --git a/source/kernel/Makefile b/source/kernel/Makefile index 6692ca78..5c5651ff 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -45,14 +45,20 @@ define copy_to_bin cp $(1) ../../bin/kernels/$(2) endef +ifeq ($(strip $(ASSEMBLE_SYMBOLS)),) +EXTRA_SYMBOLS= +else +EXTRA_SYMBOLS=--define-symbols $(ASSEMBLE_SYMBOLS) +endif + define assemble @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1) - @$(N80) $(1) $$ $(2) + @$(N80) $(1) $$ $(2) $(EXTRA_SYMBOLS) endef define assemble_as @printf "\n\033[0;36mAssembling %s as %s\033[0m\n\n" $(1) $(2) - @$(N80) $(1) $(2) $(3) + @$(N80) $(1) $(2) $(3) $(EXTRA_SYMBOLS) endef define print_linking diff --git a/source/kernel/bank0/init.mac b/source/kernel/bank0/init.mac index 9bde2a32..14eaac7e 100644 --- a/source/kernel/bank0/init.mac +++ b/source/kernel/bank0/init.mac @@ -2143,7 +2143,7 @@ scan_loop: ld e,(hl) inc hl ld d,(hl) - db 0FDh,67h ;LD IYh,A + ld_iyh_a push de pop ix call CALSLT @@ -2173,10 +2173,27 @@ TNEX_LOOP: push hl push bc and 10001111b - db 0FDh,67h ;LD IYh,A + + ifdef DISABLE_UNDOCUMENTED_OPCODES + + ex (sp),iy + ex (sp),hl + ld h,a + ld a,(MASTER_SLOT##) + cp h + ld a,h + ex (sp),hl + ex (sp),iy + + else + + ld iyh,a ld a,(MASTER_SLOT##) - db 0FDh,0BCh ;CP IYh - db 0FDh,7Ch ;LD A,IYh + cp iyh + ld a,iyh + + endif + ld h,40h ld ix,DV_TIRQ## call call_drv diff --git a/source/kernel/bank1/dosinit.mac b/source/kernel/bank1/dosinit.mac index 3ac53654..82985b90 100644 --- a/source/kernel/bank1/dosinit.mac +++ b/source/kernel/bank1/dosinit.mac @@ -1564,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## @@ -1651,7 +1651,7 @@ _U_CALLRAM2: dec ix dec ix push ix - ld iyl,e + ld_iyl_e ld a,d and 00111111b @@ -1675,13 +1675,13 @@ _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 inc sp inc sp - jr _U_CALLRAM + jp _U_CALLRAM ; ;----------------------------------------------------------------------------- ; diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac index 94c0c441..20f501ff 100644 --- a/source/kernel/bank4/partit.mac +++ b/source/kernel/bank4/partit.mac @@ -209,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 === @@ -355,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## @@ -597,7 +597,7 @@ 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_RELATIVE_DRIVE##),a @@ -607,7 +607,7 @@ AUTODRV_DRVLOOP: 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 @@ -708,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##) @@ -1067,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##) @@ -1566,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 @@ -2482,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 @@ -2630,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: @@ -3084,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 @@ -3121,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 @@ -3650,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 @@ -3815,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 @@ -5954,7 +5954,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 @@ -6192,7 +6192,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 diff --git a/source/kernel/drivers/SunriseIDE/sunride.asm b/source/kernel/drivers/SunriseIDE/sunride.asm index 23cb6bdb..933780fb 100644 --- a/source/kernel/drivers/SunriseIDE/sunride.asm +++ b/source/kernel/drivers/SunriseIDE/sunride.asm @@ -6,6 +6,7 @@ ; By FRS ;MASTER_ONLY constant must be defined externally to generate the master-only variant. + INCLUDE ../../macros.inc org 4000h ds 4100h-$,0 ; DRV_START must be at 4100h @@ -1052,8 +1053,7 @@ DEV_RW2: ld b,0 ret DEV_RW_NO0SEC: - ld iyl,e - ld iyh,d + ld_iy_de ld a,(iy+3) and 11110000b jp nz,DEV_RW_NOSEC ;Only 28 bit sector numbers supported @@ -1091,7 +1091,7 @@ DEV_ATA_RD: call CHK_RW_FAULT ret c - ld iyl,b ; iyl=number of blocks + ld_iyl_b ; iyl=number of blocks ex de,hl ; de=destination address ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) @@ -1108,7 +1108,7 @@ DEV_ATA_WR: ld a,ATACMD.PWRSECTRT ; PIO write sector with retry call PIO_CMD jp c,DEV_RW_ERR - ld iyl,b ; iyl=number of blocks + ld_iyl_b ; iyl=number of blocks ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) call WRITE_DATA @@ -1126,8 +1126,7 @@ DEV_ATAPI_RW: push de ld e,(ix+DEVINFO.pBASEWRK) ; hl=pointer to WorkArea ld d,(ix+DEVINFO.pBASEWRK+1) - ld iyl,e - ld iyh,d ; iy=WRKAREA pointer + ld_iy_de ; iy=WRKAREA pointer pop de ; Set the block size @@ -1174,7 +1173,7 @@ DEV_ATAPI_RD: push bc push hl push iy - ld iyl,1 ; 1 block + ld_iyl_1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1217,13 +1216,13 @@ DEV_ATAPI_RD: ex de,hl ; de=destination address .loopsector: push bc - ld iyl,c ; get the number of blocks per sector + ld_iyl_c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr ld hl,IDE_DATA call RUN_HLPR - dec iyl + dec_iyl jr nz,.loopblock pop bc djnz .loopsector @@ -1245,7 +1244,7 @@ DEV_ATAPI_WR: push bc push hl push iy - ld iyl,1 ; 1 block + ld_iyl_1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1287,7 +1286,7 @@ DEV_ATAPI_WR: pop bc .loopsector: push bc - ld iyl,c ; get the number of blocks per sector + ld_iyl_c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr @@ -1295,7 +1294,7 @@ DEV_ATAPI_WR: call RUN_HLPR call CHK_RW_FAULT jr c,.rderr - dec iyl + dec_iyl jp nz,.loopblock pop bc djnz .loopsector @@ -1841,13 +1840,13 @@ LUN_NFO_ATAPI: ld a,ATAPICMD.PACKET ; PIO send PACKET command call PIO_CMD - jr c,.errorpop + jp c,.errorpop pop hl push hl ; Source=PCTBUF ld bc,12 ; 12 byte packet push iy - ld iyl,1 + ld_iyl_1 call WRITE_DATA ; Send the packet to the device pop iy jr nc,.rdmediapropr ; No error? Then read media proprieties @@ -1865,7 +1864,7 @@ LUN_NFO_ATAPI: pop de ; Destination=PCTBUFF ld bc,8 ; 8 byte response push iy - ld iyl,1 + ld_iyl_1 call READ_DATA pop iy jr c,LUN_INFO_ERROR @@ -2462,7 +2461,7 @@ READ_DATA: ret c ld hl,IDE_DATA call RUN_HLPR - dec iyl + dec_iyl jp nz,.loop ret @@ -2481,7 +2480,7 @@ WRITE_DATA: call RUN_HLPR call CHK_RW_FAULT ret c - dec iyl + dec_iyl jp nz,.loop ret diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac index f7fc0ff0..998f88ca 100644 --- a/source/kernel/drv.mac +++ b/source/kernel/drv.mac @@ -277,6 +277,23 @@ null_message: db "2 - Double side",13,10 db 0 + +;-------------- +; +; Check if we are in disk emulation mode +; Assumes IS_DVB has returned Cy=1 (that is, in DOS 1 mode and DVB_TABLE exists) +; Returns Cy=1 if in emulation mode, Cy=0 if not +; Corruputs: F + +IS_EMU: + push hl + ld hl,(DVB_TABLE##) + bit 7,(hl) + pop hl + scf + ret nz + ccf + ret ;----------------------------------------------------------------------------- ; ; Entries for direct calls. @@ -807,8 +824,25 @@ IS_DVB: jr nz,IS_NOT_DVB ld iy,(DVB_TABLE##) + + ifdef DISABLE_UNDOCUMENTED_OPCODES + + ex (sp),iy + ex (sp),hl + ld a,h + or l + ex (sp),hl + ex (sp),iy + + else + ld a,iyh or iyl + + endif + + ;ld_a_iyh + ;or_iyl jr z,IS_NOT_DVB ld a,(iy) @@ -866,22 +900,6 @@ IS_NOT_DVB: ret -;-------------- -; -; Check if we are in disk emulation mode -; Assumes IS_DVB has returned Cy=1 (that is, in DOS 1 mode and DVB_TABLE exists) -; Returns Cy=1 if in emulation mode, Cy=0 if not -; Corruputs: F - -IS_EMU: - push iy - ld iy,(DVB_TABLE##) - bit 7,(iy) - pop iy - scf - ret nz - ccf - ret ;----------------------------------------------------------------------------- ; diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index 755846f8..0dcdd383 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -278,3 +278,237 @@ djpnz macro address ; .list ; + + ifndef DISABLE_UNDOCUMENTED_OPCODES + +ld_ixh_a macro + ld ixh,a + endm + +ld_iyh_a macro + ld iyh,a + endm +ld_iyh_c macro + ld iyh,c + endm +ld_iyh_e macro + ld iyh,e + endm +ld_iyh_d macro + ld iyh,d + endm + +ld_iy_de macro + ld iyl,e + ld iyl,d + endm + +ld_iyl_e macro + ld iyl,e + endm +ld_iyl_a macro + ld iyl,a + endm +ld_iyl_b macro + ld iyl,b + endm +ld_iyl_1 macro + ld iyl,1 + endm +ld_iyl_c macro + ld iyl,c + endm + +ld_a_ixh macro + ld a,ixh + endm + +ld_a_ixl macro + ld a,ixl + endm + +ld_a_iyh macro + ld a,iyh + endm + +ld_a_iyl macro + ld a,iyl + endm + +cp_ixl macro + cp ixl + endm + +cp_iyh macro + cp iyh + endm + +cp_iyl macro + cp iyl + endm + +or_iyl macro + or iyl + endm + +dec_iyl macro + dec iyl + endm + + else + +ld_ixh_a macro + ex (sp),ix + ex (sp),hl + ld h,a + ex (sp),hl + ex (sp),ix + endm + +ld_iyh_a macro + ex (sp),iy + ex (sp),hl + ld h,a + ex (sp),hl + ex (sp),iy + endm +ld_iyh_c macro + ex (sp),iy + ex (sp),hl + ld h,c + ex (sp),hl + ex (sp),iy + endm +ld_iyh_e macro + ex (sp),iy + ex (sp),hl + ld h,e + ex (sp),hl + ex (sp),iy + endm +ld_iyh_d macro + ex (sp),iy + ex (sp),hl + ld h,d + ex (sp),hl + ex (sp),iy + endm + +ld_iy_de macro n + ex (sp),iy + ex (sp),hl + ld l,e + ld h,d + ex (sp),hl + ex (sp),iy + endm + +ld_iyl_e macro n + ex (sp),iy + ex (sp),hl + ld l,e + ex (sp),hl + ex (sp),iy + endm +ld_iyl_a macro n + ex (sp),iy + ex (sp),hl + ld l,a + ex (sp),hl + ex (sp),iy + endm +ld_iyl_b macro n + ex (sp),iy + ex (sp),hl + ld l,b + ex (sp),hl + ex (sp),iy + endm +ld_iyl_1 macro n + ex (sp),iy + ex (sp),hl + ld l,1 + ex (sp),hl + ex (sp),iy + endm +ld_iyl_c macro n + ex (sp),iy + ex (sp),hl + ld l,c + ex (sp),hl + ex (sp),iy + endm + +ld_a_ixh macro n + ex (sp),ix + ex (sp),hl + ld a,h + ex (sp),hl + ex (sp),ix + endm + +ld_a_ixl macro + ex (sp),ix + ex (sp),hl + ld a,l + ex (sp),hl + ex (sp),ix + endm + +ld_a_iyh macro n + ex (sp),iy + ex (sp),hl + ld a,h + ex (sp),hl + ex (sp),iy + endm + +ld_a_iyl macro n + ex (sp),iy + ex (sp),hl + ld a,l + ex (sp),hl + ex (sp),iy + endm + +cp_ixl macro + ex (sp),ix + ex (sp),hl + cp l + ex (sp),hl + ex (sp),ix + endm + +cp_iyh macro + ex (sp),iy + ex (sp),hl + cp h + ex (sp),hl + ex (sp),iy + endm + +cp_iyl macro + ex (sp),iy + ex (sp),hl + cp l + ex (sp),hl + ex (sp),iy + endm + +or_iyl macro + ex (sp),iy + ex (sp),hl + or l + ex (sp),hl + ex (sp),iy + endm + +dec_iyl macro + ex (sp),iy + ex (sp),hl + dec l + ex (sp),hl + ex (sp),iy + endm + + endif diff --git a/source/tools/Makefile b/source/tools/Makefile index 0224f31e..6d18ab14 100644 --- a/source/tools/Makefile +++ b/source/tools/Makefile @@ -19,9 +19,15 @@ define copy_to_bin cp $(1) ../../bin/tools/$(2) endef +ifeq ($(strip $(ASSEMBLE_SYMBOLS)),) +EXTRA_SYMBOLS= +else +EXTRA_SYMBOLS=--define-symbols $(ASSEMBLE_SYMBOLS) +endif + define assemble @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1) - @$(N80) $(1) $(2) + @$(N80) $(1) $(2) $(EXTRA_SYMBOLS) endef COMS := CONCLUS.COM DELALL.COM DEVINFO.COM DRIVERS.COM DRVINFO.COM FASTOUT.COM LOCK.COM MAPDRV.COM NSYSVER.COM RALLOC.COM