From 94d738b73964e436b955e3a5d275c2d1125d4cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Tue, 22 Mar 2022 10:02:59 +0100 Subject: [PATCH 1/5] All the CALL SYSTEM2 command in BASIC (#97) This new BASIC command works the same way as the old CALL SYSTEM, but it will always load MSXDOS2.SYS even if NEXTOR.SYS is available. This helps getting back some TPA memory, since MSXDOS2.SYS is smaller than NEXTOR.SYS, but at the expense of not being able to use the Nextor-exclusive function calls (so tools like e.g. MAPDRV.COM won't work). --- docs/Nextor 2.1 User Manual.md | 11 +++++++++++ source/kernel/bank0/dosboot.mac | 7 +++++++ source/kernel/bank0/dskbasic.mac | 8 ++++++++ source/kernel/bank4/partit.mac | 1 + source/kernel/data.mac | 1 + 5 files changed, 28 insertions(+) diff --git a/docs/Nextor 2.1 User Manual.md b/docs/Nextor 2.1 User Manual.md index d19d4518..2f82089c 100644 --- a/docs/Nextor 2.1 User Manual.md +++ b/docs/Nextor 2.1 User Manual.md @@ -108,6 +108,8 @@ [3.6.11. The CALL USR command](#3611-the-call-usr-command) +[3.6.12 The CALL SYSTEM2 command](#3611-the-call-system2-command) + [3.7. New BASIC error codes](#37-new-basic-error-codes) [3.8. Mounting files](#38-mounting-files) @@ -358,6 +360,8 @@ Nextor consists of the following components: **Note:** starting with Nextor 2.1.0 beta 2, the kernel will try to load MSXDOS2.SYS if NEXTOR.SYS is not found. However in this case the Nextor command line tools won't work. +**Note:** starting with Nextor 2.1.0 beta 2, [the `CALL SYSTEM2` command](#3611-the-call-system2-command) can be used in BASIC to force a reboot in the DOS environment using MSXDOS2.SYS, even if NEXTOR.SYS exists. + In order to boot in the MSX-DOS 1 prompt, you need the usual MSXDOS.SYS and COMMAND.COM files. Also, if you have just the kernel and no NEXTOR.SYS or MSXDOS.SYS files, Nextor will boot in the BASIC prompt (running AUTOEXEC.BAS if present). Therefore, in order to "install" Nextor, you have two options: @@ -921,6 +925,13 @@ Here is a simple BASIC program to test the CALL USR command. Change the register 160 PRINT "IY=&H";HEX$(R(5)) ```` +#### 3.6.12 The CALL SYSTEM2 command + +Nextor 2.1.1 introduced a new `CALL SYSTEM2` command. This command works the same as `CALL SYSTEM`, but will always load MSXDOS2.SYS, even if a file named NEXTOR.SYS exists. This can be useful to get back some TPA space for applications, since MSXDOS2.SYS is smaller than NEXTOR.SYS. + +Note however that the new function calls introduced by Nextor won't work if NEXTOR.SYS isn't loaded, this implies that the Nextor-specific command line tools (e.g. `MAPDRV.COM`) won't work if the DOS environment is entered via `CALL SYSTEM2` command. + + ### 3.7. New BASIC error codes The following new BASIC error codes are defined to handle the possible errors of the new BASIC commands. These errors are available in MSX-DOS 1 mode as well for the commands that work in this environment. The numbers in parenthesis are the error codes. diff --git a/source/kernel/bank0/dosboot.mac b/source/kernel/bank0/dosboot.mac index d6867943..140364f5 100644 --- a/source/kernel/bank0/dosboot.mac +++ b/source/kernel/bank0/dosboot.mac @@ -294,12 +294,19 @@ NOBOOT: jr z,msxdos_fail ; retry_dos: + ld a,(MFLAGS##) + bit 7,a ;SYST2 + res 7,a + ld (MFLAGS##),a + jr nz,retry_dos2 +retry_dos_go: ld de,BOOT_NAME ;Try to open the "NEXTOR.SYS" xor a ;file on the default drive. ld c,_OPEN## call BOOT_BDOS jr z,msxdos_bootok +retry_dos2: ld de,OLD_BOOT_NAME ;Fallback to try "MSXDOS.SYS" xor a ld c,_OPEN## diff --git a/source/kernel/bank0/dskbasic.mac b/source/kernel/bank0/dskbasic.mac index 38483caf..01979f2a 100644 --- a/source/kernel/bank0/dskbasic.mac +++ b/source/kernel/bank0/dskbasic.mac @@ -397,6 +397,8 @@ ABORT: ; Table of expanded statements ; COMMAND: + defb 'SYSTEM2',0 + defw SYSTEM2 defb 'SYSTEM',0 defw SYSTEM defb 'FORMAT',0 @@ -437,6 +439,12 @@ COMMAND: ; ; _SYSTEM[("")] ; +SYSTEM2: + push hl + ld hl,MFLAGS## + set 7,(hl) ;SYST2 + pop hl + SYSTEM: ld de,CMDTMP ; assume end of statement jr z,SYSTEM_NO_ARG ; good assumption diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac index dfbc6047..b17e9d89 100644 --- a/source/kernel/bank4/partit.mac +++ b/source/kernel/bank4/partit.mac @@ -5300,6 +5300,7 @@ CNEXTOR_S: db "_MAPDRV()",13,10 db "_MAPDRVL() *",13,10 db "_USR()",13,10 + db "_SYSTEM2() - boot DOS using MSXDOS2.SYS",13,10 db 13,10 db "Commands with * are not available",1 db "in MSX-DOS 1 mode.",13,10 diff --git a/source/kernel/data.mac b/source/kernel/data.mac index 65ceb5fb..c3991b97 100644 --- a/source/kernel/data.mac +++ b/source/kernel/data.mac @@ -218,6 +218,7 @@ ram_ad defl DATABASE const FASTOUT,0 ;bit 0: set for fast STROUT const FIRSTLD,1 ;bit 1: set while booting NEXTOR.SYS for the first time const ZALLOC,2 ;bit 2: reduced alloc info mode becomes zero info mode + const SYST2,7 ;Bit 7: force boot in MSXDOS2.SYS (temporary, reset after read) spare 1 ;Available for DOS 2 ; var2 BLDCHK From 5a7db6a8a235883a3bec7a89e6589080d6001ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Tue, 22 Mar 2022 10:07:22 +0100 Subject: [PATCH 2/5] Change the mechanism to access mounted files (#93) Change the mechanism to access mounted files from file based to sector based. - A new restriction is introduced: a file needs to be stored across consecutive sectors in disk in order to be mountable. - Message for error .ICLUS has been changed from "Invalid cluster number" to "Invalid cluster number or sequence". - New BASIC error code introduced: code 82, message "Invalid cluster sequence". - The _GDLI function call will now return two extra values for a drive that has a mounted file: "start cluster" and "start sector" --- docs/Nextor 2.1 Programmers Reference.md | 35 +++- docs/Nextor 2.1 User Manual.md | 8 +- source/kernel/bank0/dosboot.mac | 4 - source/kernel/bank0/dskbasic.mac | 7 +- source/kernel/bank1/mapinit.mac | 8 - source/kernel/bank1/msg.mac | 4 +- source/kernel/bank2/buf.mac | 63 +----- source/kernel/bank2/files.mac | 98 +-------- source/kernel/bank2/handles.mac | 8 - source/kernel/bank2/rw.mac | 20 -- source/kernel/bank2/val.mac | 242 ++++++----------------- source/kernel/bank4/misc.mac | 40 ++++ source/kernel/bank4/partit.mac | 213 ++++++++------------ source/kernel/kvar.mac | 9 +- 14 files changed, 233 insertions(+), 526 deletions(-) diff --git a/docs/Nextor 2.1 Programmers Reference.md b/docs/Nextor 2.1 Programmers Reference.md index 43b53d98..3e9bb8d0 100644 --- a/docs/Nextor 2.1 Programmers Reference.md +++ b/docs/Nextor 2.1 Programmers Reference.md @@ -88,9 +88,13 @@ [8. Change history](#8-change-history) -[8.1. v2.1.0 beta 2](#81-v210-beta-2) +[8.1. v2.1.1 beta 2](#81-v211-beta-2) -[8.2. v2.1.0 beta 1](#82-v210-beta-1) +[8.2. v2.1.0 RC 1](#82-v210-rc-1) + +[8.3. v2.1.0 beta 2](#83-v210-beta-2) + +[8.4. v2.1.0 beta 1](#84-v210-beta-1) ## 1. Introduction @@ -440,7 +444,7 @@ The information returned in the data buffer is as follows: +10..+63: Reserved (currently always zero) ``` -If a file is mounted in the drive, the information returned in the data buffer is insetad as follows: +If a file is mounted in the drive, the information returned in the data buffer is instead as follows: ``` +1: Drive where the mounted file is located (0 = A:, etc) @@ -448,12 +452,17 @@ If a file is mounted in the drive, the information returned in the data buffer i bit 0: mount mode, 0 = read and write, 1 = read-only +3: Always 0 +4: Filename in printable format (up to 12 characters, plus a terminating zero) ++17: Start cluster of the file, 2 bytes (0 if not available) ++19: Start sector of the file, 4 bytes (0 if not available) ``` If a drive larger than the maximum drive number supported by the system is specified, an .IDRV error will be returned. Note that if a drive number is specified which is legal in Nextor, but is currently not assigned to any driver, then no error will be returned, but an empty information block will be returned (the drive status byte should be checked). The "first device sector number" is the absolute device sector number that is treated as the first logical sector for the drive; usually it is either the starting sector of a device partition, or the device absolute sector zero, if the device has no partitions. Note that you can't test this value against zero to check whether the drive is assigned to a block device on a device-based driver or not (use the β€œdrive status” field for this purpose). +The "start cluster" and "start sector" fields for mounted files were introduced in Nextor 2.1.1. Currently, they will always contain meaningful information, but in future versions of Nextor this could not be true (because non-FAT filesystems with no concept of "clusters" get supported, or for any other reason) and in these cases the fields will have a value of zero. These fields will also be returned as zero in versions of Nextor older than 2.1.1, therefore application programs using this function call should always verify that the values of these fields are non-zero before using them. + + ### 3.10. Get information about a device partition (_GPART, 7Ah) ``` @@ -611,7 +620,7 @@ When invoked in MSX-DOS 1 mode, the following restrictions apply to this functio * The new mapping information may specify a different partition and/or device, but the driver slot must be the same that was assigned to the drive at boot time. This is not an issue if there is only one Nextor kernel in the system. These restrictions are imposed by the Nextor architecture. -If B=3 at input, the file whose name or FIB is passed in HL will be mounted in the drive; file mounting is available since Nextor 2.1.0. A .BFSZ error will be returned if the file is too small or too big. +If B=3 at input, the file whose name or FIB is passed in HL will be mounted in the drive; file mounting is available since Nextor 2.1.0, and since Nextor 2.1.1 a file needs to be stored across consecutive sectors in its host filesystem to be mountable. A .BFSZ error will be returned if the file is too small (less than 512 bytes) or too big (more than 32 MBytes). A .ICLUS error will be returned if the file is not stored across consecutive sectors. ### 3.13. Enable or disable the Z80 access mode for a driver (_Z80MODE, 7Dh) @@ -754,9 +763,9 @@ An attempt to open or alter a mounted file, or to perform any other disallowed o Attempt to mount a file that is smaller than 512 bytes or larger than 32 MBytes. -* Invalid cluster number (.ICLUS, 0B0h) +* Invalid cluster number or sequence (.ICLUS, 0B0h) -The cluster number supplied to the [_GETCLUS](#314-get-information-for-a-cluster-on-a-fat-drive-_getclus-7eh) function doesn't exist in the drive. +The cluster number supplied to the [_GETCLUS](#314-get-information-for-a-cluster-on-a-fat-drive-_getclus-7eh) function doesn't exist in the drive, or a file was supplied to [_MAPDRV](#312-map-a-drive-letter-to-a-driver-and-device-_mapdrv-7ch) to be mounted but the file is not stored across consecutive sectors in its host filesystem. ## 5. Extended mapper support routines @@ -1001,11 +1010,21 @@ This section contains the change history for the different versions of Nextor. O This list contains the changes for the 2.1 branch only. For the change history of the 2.0 branch see the _[Nextor 2.0 Programmers Reference](../../../blob/v2.0/docs/Nextor%202.0%20Programmers%20Reference.md#7-change-history)_ document. -### 8.1. v2.1.0 beta 2 +### 8.1. v2.1.1 beta 2 + +* [_GDLI](#39-get-information-about-a-drive-letter-_gdli-79h) returns two new fields, "start cluster" and "start sector", when a file is mounted. + +### 8.2. v2.1.0 RC 1 + +* [_GETCLUS](#314-get-information-for-a-cluster-on-a-fat-drive-_getclus-7eh) function call introduced. +* [UNAPI RAAM helper compatible routines](#5-extended-mapper-support-routines) have been added. +* Extra mapper support routines `ALL_BK` and `FRE_BK` have been removed. + +### 8.3. v2.1.0 beta 2 * [_GPART](#310-get-information-about-a-device-partition-_gpart-7ah) now returns the status byte of the partition, and allows to retrieve the device sector number that holds the partition table entry instead of information about the partition. -### 8.2. v2.1.0 beta 1 +### 8.4. v2.1.0 beta 1 * [_GDRVR](#38-get-information-about-a-device-driver-_gdrvr-78h) now returns an extra flag that tells if the driver implements the DRV_CONFIG routine. diff --git a/docs/Nextor 2.1 User Manual.md b/docs/Nextor 2.1 User Manual.md index 2f82089c..4092356a 100644 --- a/docs/Nextor 2.1 User Manual.md +++ b/docs/Nextor 2.1 User Manual.md @@ -966,6 +966,10 @@ An attempt to open or alter a mounted file, or to perform any other disallowed o Thrown by the CALL MAPDRV command when attempting to mount a file that is smaller than 512 bytes or larger than 32 MBytes. +* Invalid cluster sequence (82) + +Thrown by the CALL MAPDRV command when attempting to mount a file that is not stored across consecutive sectors in its host filesystem. + ### 3.8. Mounting files @@ -975,7 +979,9 @@ To mount a file, use [the MAPDRV tool](#341-mapdrv-the-drive-mapping-tool) with This feature has some restrictions: -* To be mountable a disk image file must have a size of at least 512 bytes and at most 32 MBytes. +* The file must have a size of at least 512 bytes and at most 32 MBytes. + +* The file must be stored across consecutive sectors in its host filesystem (since Nextor 2.1.1). * The file is expected to contain a proper FAT filesystem already, it is not possible to apply the FORMAT command on a mounted drive. diff --git a/source/kernel/bank0/dosboot.mac b/source/kernel/bank0/dosboot.mac index 140364f5..5d6065d5 100644 --- a/source/kernel/bank0/dosboot.mac +++ b/source/kernel/bank0/dosboot.mac @@ -323,8 +323,6 @@ msxdos_bootok: push af ld c,_CLOSE## call BOOT_BDOS ;Close the file handle - ld hl,MFLAGS## - res 1,(hl) pop af jr nz,msxdos_fail ;Jump if the read was no good ; @@ -340,8 +338,6 @@ endif jp 100h ;Start up MSXDOS.SYS ; msxdos_fail: - ld hl,MFLAGS## - res 1,(hl) ret ; ; diff --git a/source/kernel/bank0/dskbasic.mac b/source/kernel/bank0/dskbasic.mac index 01979f2a..90ba25fa 100644 --- a/source/kernel/bank0/dskbasic.mac +++ b/source/kernel/bank0/dskbasic.mac @@ -3555,7 +3555,7 @@ DBABORT_ROUTINE: ; ; Analyze errors returned from BDOS call ; -.FRSTER equ 0B1h ;0BAh ; lowest MSXDOS2 error code supported +.FRSTER equ 0B0h ;0BAh ; lowest MSXDOS2 error code supported ; DERNUM macro ERRNAM ifidn ,<*> @@ -3570,6 +3570,7 @@ QQQQ defl .FRSTER ; DERR_TAB: + DERNUM ERRICL ; Invalid cluster sequence DERNUM ERRBFS ; Bad file size DERNUM ERRFIM ; File is mounted @@ -3728,6 +3729,7 @@ QQQQ defl DERFST DERMAK ERRFIM ; File is mounted DERMAK ERRBFS ; Bad file size + DERMAK ERRICL ; Invalid cluster sequence ; DERLST equ QQQQ-1 ; ; @@ -4126,8 +4128,9 @@ DERMSG: defb 0 defb 'File is mounted', 0 defb 'Bad file size', 0 + defb 'Invalid cluster sequence',0 -; '----+----1----+----2----' +; '----+----1----+----2----' ; MAXMSGLEN equ 24+2 ;2 extra spaces are for terminators diff --git a/source/kernel/bank1/mapinit.mac b/source/kernel/bank1/mapinit.mac index 477d77e1..4df88569 100644 --- a/source/kernel/bank1/mapinit.mac +++ b/source/kernel/bank1/mapinit.mac @@ -223,14 +223,6 @@ zero_p2_loop: ld (hl),0 ; data segment up to the ld (RAM_PTR##),hl ; to point to an end of chain ; marker at the bottom of all ; the fixed variables. - ld hl,0 - ld (MHANDLES##),hl - ld (MHANDLES##+2),hl - ld (MHANDLES##+4),hl - ld (MHANDLES##+6),hl - ld a,h - ld (RW_LEVEL##),a - ld (BF_LEVEL##),a ; ; ; ***** SETUP MAP_TBL AND SEGMENT LISTS IN PAGE-2 ***** diff --git a/source/kernel/bank1/msg.mac b/source/kernel/bank1/msg.mac index e72e4026..55cebc1d 100644 --- a/source/kernel/bank1/msg.mac +++ b/source/kernel/bank1/msg.mac @@ -239,7 +239,7 @@ ERR_MSG_TABLE: err .PUSED, <"Partition is already in use"> err .FMNT, <"File is mounted"> err .BFSZ, <"Bad file size"> - err .ICLUS, <"Invalid cluster number"> + err .ICLUS, <"Invalid cluster number or sequence"> ; ; ; The following are errors which the KBDOS may pass to the ABORT routine. @@ -439,7 +439,7 @@ ERR_KMSG_TABLE: err .PUSED, <"ƒp[ƒeƒBƒVƒ‡ƒ“‚ͺŽg—p’†‚Ε‚·"> ;<"Partition is already in use"> err .FMNT, <"ƒtƒ@ƒCƒ‹‚ͺƒ}ƒEƒ“ƒg‚³‚κ‚Δ‚’‚ά‚·"> ;<"File is mounted"> err .BFSZ, <"–³Œψ‚Θƒtƒ@ƒCƒ‹ƒTƒCƒY"> ;<"Bad file size"> - err .ICLUS, <"–³Œψ‚ΘƒNƒ‰ƒXƒ^[”ԍ†"> ;<"Invalid cluster number"> + err .ICLUS, <"–³Œψ‚ΘƒNƒ‰ƒXƒ^[”ԍ†‚ά‚½‚ΝƒV[ƒPƒ“ƒX"> ;<"Invalid cluster number or sequence"> ; ; ; The following are errors which the KBDOS may pass to the ABORT routine. diff --git a/source/kernel/bank2/buf.mac b/source/kernel/bank2/buf.mac index b58e1347..f026fafe 100644 --- a/source/kernel/bank2/buf.mac +++ b/source/kernel/bank2/buf.mac @@ -117,8 +117,6 @@ endif ; pop hl ;HL -> first buffer on chain - call ADJ_BUF_NUM - inc hl inc hl bit 7,(hl) ;Look at unit number and @@ -220,7 +218,7 @@ bf_multi_read: push de ;Save registers which are ;===== end mod DOS2.50 ld a,RD_CMD## ;Get READ command code - call DO_RW ;Try to read the sector + pcall RW_UNIT ;Try to read the sector pop bc ;Get copy count & separation pop de ;Get sector number back @@ -256,9 +254,7 @@ already_in_buf: pop bc ;Clean up stack set FF_DBUF,(iy+@FAT_FLAGS##);Directory buffer not cached ld (B_CACHE##),hl ;Record buffer as cache - ld a,(BF_LEVEL##) - or a - call z,BF_END ;Put buffer on end of chain + call BF_END ;Put buffer on end of chain ; xor a ret ;Return Z-set (for DIRTY_DISK) @@ -708,8 +704,6 @@ bf_find_loop: ld e,(hl) ;Get next buffer address (BD_LINK) ; BD_EX_SECT=8 ; ; - call ADJ_BUF_NUM - set FF_DBUF,(iy+@FAT_FLAGS##) ;Set directory buffer flag ; push hl ;Save buffer pointer @@ -786,7 +780,7 @@ bf_flush_loop: push de ;Save registers which are ;; ld c,a ;===== end mod DOS2.50 ld a,WR_CMD## ;A:=write command code - call DO_RW ;Call the unit handler + pcall RW_UNIT ;Call the unit handler pop bc pop de ;Restore parameters ; @@ -844,57 +838,6 @@ pop_hl_ret: pop hl ;Restore buffer pointer ; ;------------------------------------------------------------------------------ ; - ;Read or write unit with adjustment of BF_LEVEL. - ; - ;If a file is mounted, the call to RW_UNIT por pre-read/write - ;will cause the BF_FLUSH or BF_SECTOR routine to re-enter. - ;We use the BF_LEVEL variable to keep track of when that happens - ;and act accordingly (see ADJ_BUF_NUM below). - ; - ;Input, output, modifies: same as RW_UNIT. -DO_RW: - push af - ld a,(BF_LEVEL##) - inc a - ld (BF_LEVEL##),a ;To support re-enter check - pop af - - pcall RW_UNIT ;Try to read the sector - - push af - ld a,(BF_LEVEL##) - dec a - ld (BF_LEVEL##),a - pop af - - ret - - - ;Adjust sector buffer pointer if necessary. - ; - ;If a file is mounted, the call to RW_UNIT por pre-read/write - ;will cause the BF_FLUSH or BF_SECTOR routine to re-enter. - ;In that case, the first buffer in the chain will end up having - ;a wrong combination of unit+sector number and actual sector data. - ;To prevent this, we check if we are re-entering, - ;and in this case we use the second buffer in the chain - ;instead of the first one. - ; - ;Input: HL = Pointer to sector buffer. - ;Output: HL = Pointer to same sector buffer, - ; if case of routine re-entrance. - ;Modifies: AF - -ADJ_BUF_NUM: - ld a,(BF_LEVEL##) - or a - ret z - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - ret - finish end ; diff --git a/source/kernel/bank2/files.mac b/source/kernel/bank2/files.mac index e03c8780..e048ebac 100644 --- a/source/kernel/bank2/files.mac +++ b/source/kernel/bank2/files.mac @@ -59,51 +59,6 @@ ; PROC RDWR_FAB ; - if 1 - - ex af,af' - ld a,(RW_LEVEL##) - cp 1 - jr nz,OKLEVEL - - ld hl,(RW_OVER##) - push hl - ld hl,(RW_OVER##+2) - push hl - ld hl,(RW_OVER##+4) - push hl - ld hl,(RW_OVER##+6) - push hl - ld hl,(RW_OVER##+8) - push hl - ld hl,(RW_OVER##+10) - push hl - ld hl,(RW_OVER##+12) - push hl - ld hl,(RW_OVER##+14) - push hl - ld hl,(RW_OVER##+16) - push hl - ld hl,(RW_OVER##+18) - push hl - ld a,(RW_EX_PSEC##) ;When the drive has a file mounted VAL_FIB may - ld h,a ;corrupt the variables we've set so far, so save them. - ld a,(RW_FLAGS##) - ld l,a - push hl - ld hl,(RW_PSEC##) - push hl - ld hl,(RW_DTA##) - push hl - -OKLEVEL: - ld a,(RW_LEVEL##) - inc a - ld (RW_LEVEL##),a - ex af,af' - - endif - bit MD_DEV,(ix+FAB_MODE##) ;Jump to handle device reads jp nz,rdwr_device ; and writes separately. ; @@ -112,7 +67,7 @@ OKLEVEL: and RFM_SZ ;If amount to transfer is zero or b ; and the RF_SIZE flag is not or c ; set then return immediately - jr z,RDWR_END ; with no error. + ret z ; with no error. ; ;===== start mod DOS2.50 ld hl,0 ;Zero bytes transferred @@ -138,7 +93,7 @@ rdwr_dev_done: ld l,(ix+FAB_PTR##) ;Add the amount transferred inc (ix+FAB_PTR##+3) no_ptr_carry: rdwr_error: or a - jr nz,RDWR_END ;Return if error + ret nz ;Return if error ; bit RF_SIZE,(iy+@RW_FLAGS##);Don't check for zero bytes jr nz,rdwr_ret_ok ; if "change file size" @@ -149,54 +104,7 @@ rdwr_error: or a ld a,.EOF## ; transferred was zero, in jr z,rdwr_error ; which case return an end rdwr_ret_ok: xor a ; of file error. - -RDWR_END: - if 1 - - ex af,af' - ld a,(RW_LEVEL##) - cp 2 - jr nz,OKLEVEL2 - - pop hl - ld (RW_DTA##),hl - pop hl - ld (RW_PSEC##),hl - pop hl - ld a,l - ld (RW_FLAGS##),a - ld a,h - ld (RW_EX_PSEC##),a - pop hl - ld (RW_OVER##+18),hl - pop hl - ld (RW_OVER##+16),hl - pop hl - ld (RW_OVER##+14),hl - pop hl - ld (RW_OVER##+12),hl - pop hl - ld (RW_OVER##+10),hl - pop hl - ld (RW_OVER##+8),hl - pop hl - ld (RW_OVER##+6),hl - pop hl - ld (RW_OVER##+4),hl - pop hl - ld (RW_OVER##+2),hl - pop hl - ld (RW_OVER##),hl - -OKLEVEL2: - ld a,(RW_LEVEL##) - dec a - ld (RW_LEVEL##),a - ex af,af' - - endif -RDWR_END2: ret ; ; ---------------------------------------- @@ -208,7 +116,7 @@ rdwr_device: ; ld a,b ;Do nothing if zero bytes or c ; requested - jr z,RDWR_END + ret z ; bit RF_READ,h jr nz,read_device ;Skip if read. diff --git a/source/kernel/bank2/handles.mac b/source/kernel/bank2/handles.mac index 7fe1d376..be934786 100644 --- a/source/kernel/bank2/handles.mac +++ b/source/kernel/bank2/handles.mac @@ -339,8 +339,6 @@ do_ensure: call ENSURE_FAB ;Update dir entry if required ; push de push hl - ld hl,MFLAGS## - set 7,(hl) call FIND_HANDLE_B ;Find the file handle and pop bc ; moan if it is invalid pop de ; or not open. @@ -350,8 +348,6 @@ do_ensure: call ENSURE_FAB ;Update dir entry if required xor a pcall RD_FAB ;Do the read operation and push bc ; return with number of bytes - ld hl,MFLAGS## - res 7,(hl) pop hl ; read in HL. ret ; @@ -374,8 +370,6 @@ do_ensure: call ENSURE_FAB ;Update dir entry if required ; push de push hl - ld hl,MFLAGS## - set 7,(hl) call FIND_HANDLE_B ;Find the file handle and pop bc ; moan if it is invalid pop de ; or not open. @@ -385,8 +379,6 @@ do_ensure: call ENSURE_FAB ;Update dir entry if required xor a pcall WR_FAB ;Do the write operation and push bc ; return with number of bytes - ld hl,MFLAGS## - res 7,(hl) pop hl ; written in HL. ret ; diff --git a/source/kernel/bank2/rw.mac b/source/kernel/bank2/rw.mac index 3f738bbc..1a8286c1 100644 --- a/source/kernel/bank2/rw.mac +++ b/source/kernel/bank2/rw.mac @@ -90,27 +90,7 @@ try_rw_val: push bc ;Remember sector count and 32 bit sector flag res 7,c inc c ; actually checking the boot sector (B=2). - ld a,(RW_EX_PSEC##) ;When the drive has a file mounted VAL_FIB may - ld d,a ;corrupt the variables we've set so far, so save them. - ld a,(RW_FLAGS##) - ld e,a - push de - ld de,(RW_PSEC##) - push de - ld de,(RW_DTA##) - push de pcall VAL_FIB - pop de - ld (RW_DTA##),de - pop de - ld (RW_PSEC##),de - ld b,a - pop de - ld a,e - ld (RW_FLAGS##),a - ld a,d - ld (RW_EX_PSEC##),a - ld a,b pop bc ;B := sector count, C:7 set if 24 or 32 bit sector number or a diff --git a/source/kernel/bank2/val.mac b/source/kernel/bank2/val.mac index 198e4366..ae956865 100644 --- a/source/kernel/bank2/val.mac +++ b/source/kernel/bank2/val.mac @@ -2404,10 +2404,16 @@ CALL_UNIT: cp number_of_cmds ;Reject if command code is jp nc,bad_unit_cmd ; not a sensible value. ; - push iy + push hl + push hl + ex (sp),iy + call CALLUNIT2 + pop iy + pop hl + ret +CALLUNIT2: + push af - push hl - pop iy ld a,(iy+UD_FLAGS##) and UFM_MT jp z,CUN_NO_MOUNT @@ -2422,7 +2428,6 @@ CALL_UNIT: ;* Treat non-read or write commands - pop iy ld c,a cp MC_CMD ;Check media change: return never changed @@ -2445,116 +2450,30 @@ CALL_UNIT: ;* It is a read or write command CUN_RW: - push af - ld a,c - ld (SEG_SAVE##),a ;Required segment - - pop af - pop iy - ld (IY_SAVE##),iy - - push hl - push ix - - push hl - pop iy - - push ix - pop hl - - ex af,af' - push af - ex af,af' - exx - push hl - push de - push bc - exx - push bc exx - ld de,(RW_PSEC##) - push de - ld de,(RW_DTA##) - push de - exx - call CUN_RW2 - exx - pop de - ld (RW_DTA##),de - pop de - ld (RW_PSEC##),de + push hl + push bc exx - pop bc + call _CUN_RW exx - pop bc - pop de - pop hl + pop bc + pop hl exx - ex af,af' - pop af - ex af,af' - - ld iy,(IY_SAVE##) - pop ix - pop hl - or a - ret z - ld b,0 ;Needed in case of error ret +_CUN_RW: -CUN_RW2: - ld c,a + push af - ;>>> C = Command (RD_CMD or WR_CMD), + ;>>> A = Command (RD_CMD or WR_CMD), ; B = sector count ; DE = First sector - ; HL = Destination ; IY = Unit descriptor - ;* Convert destination address according to the required segment - ; (the reverse of what GET_SEGMENT does) if it is a TPA segment. - ; This is necessary to prevent the actual sector access - ; (for the unit that host the image file) to target the wrong segment. - - push de - push bc - push hl - - ld a,(SEG_SAVE##) - ld c,a - ld b,4 - ld d,0 - ld hl,P0_TPA## -xxx: - ld a,(hl) - cp c - jr z,xxx2 - ld a,d - add a,40h - ld d,a - inc hl - djnz xxx - jr xxx3 - -xxx2: - pop hl - ld a,h - and 00111111b - or d - ld h,a - jr xxx4 -xxx3: - pop hl -xxx4: - pop bc - pop de - ;* Check sector number ld a,(DIO_EX_SECTOR##) or a - ld a,.RNF## - ret nz + jp nz,RET_RNF_POP push de push bc @@ -2567,100 +2486,54 @@ xxx4: dec hl ;HL = Last sector to access ld a,(iy+UD_MXS##+1) cp h - ld a,.RNF## - ret c + jp c,RET_EXX_RNF_POP jr nz,CUN_OKSEC ld a,(iy+UD_MXS##) cp l - ld a,.RNF## - ret c + jp c,RET_EXX_RNF_POP CUN_OKSEC: exx - ;* Calculate FAB address from pseudo-file handle number - - push bc - ld b,(iy+UD_FH##) - ld ix,MHANDLES## - ld c,b - ld b,0 - add ix,bc - add ix,bc - ld c,(ix) - ld b,(ix+1) - push bc - pop ix - - ;* Perform a seek to sector number * 512 - - push hl - xor a - ld h,e - ld e,d - ld l,0 - ld d,0 ;Now DE:HL = DE * 256... - sla h - rl e - rl d ;...and we multiply DE:HL by 2. - ld (ix+FAB_PTR##),l - ld (ix+FAB_PTR##+1),h - ld (ix+FAB_PTR##+2),e - ld (ix+FAB_PTR##+3),d - - pop hl - pop bc - or a - ret nz ;TODO: Convert to "disk error"? + ;* If it's a write command, check the readonly flag - ;* Now perform the read or write! + pop af + push af + cp WR_CMD + jr nz,CUN_OKWP + bit 0,(iy+UD_MFLAGS##) ;Mounted as read only? + jp nz,RET_WP_POP +CUN_OKWP: - ex de,hl ;DE = transfer address - ld h,b - ld l,0 - sla h ;H = sectors * 512 = bytes to transfer + ;* Convert unit descriptor and sector number to those of the mounted file - ld a,(DATA_SEG##) - ld b,a - ld a,(SEG_SAVE##) - cp b - ld a,0FFh - jr z,ASDFG - inc a - ASDFG: - ld b,a + push de - ld iy,(IY_SAVE##) - push ix - - push hl - ld a,c - cp WR_CMD - ld a,b ;0 for TPA, FFh for current segment - pop bc - jr z,CUN_WRITE -CUN_READ: - PCALL RD_FAB - jr CUN_NEXT -CUN_WRITE: - PCALL WR_FAB ;@3AAB -CUN_NEXT: - pop ix + ld e,(iy+UD_DRV##) + sla e + ld d,0 + ld hl,UNIT_TAB##+2 + add hl,de + ld e,(hl) + inc hl + ld d,(hl) + ex de,hl ;HL=Address of unit descriptor for the drive of the mounted file - cp .ACCV## - jr nz,CUN_NOACCV - ld a,.WPROT## -CUN_NOACCV: + ex (sp),hl ;HL=Sector number, address of unit descriptor in stack + ld e,(iy+UD_SSEC##) + ld d,(iy+UD_SSEC##+1) + add hl,de + ld a,0 + adc a,(iy+UD_SSEC##+2) + ld (DIO_EX_SECTOR##),a + ex de,hl ;DE=Updated sector number - ld iy,(IY_SAVE##) - or a - ret + pop hl ;--- Regular unit (not mounted) + ; or mounted unit after unit descriptor and sector number conversion CUN_NO_MOUNT: pop af - ;push iy - push hl push hl ;Save lots of registers and ex (sp),ix ; get IX (DTA address) into pop hl ; HL and unit descriptor @@ -2712,8 +2585,7 @@ endif pop hl exx pop ix - pop hl - pop iy + ; or a ;Return from CALL_UNIT with ret ; flags set according to error. @@ -2722,6 +2594,20 @@ endif bad_unit_cmd: ld a,.INTER## ;Return error if command code or a ; is not sensible. ret + +RET_EXX_RNF_POP: + exx +RET_RNF_POP: + pop af + ld a,.RNF## + or a + ret + +RET_WP_POP: + pop af + ld a,.WPROT## + or a + ret ; jp_hl: jp (hl) ; diff --git a/source/kernel/bank4/misc.mac b/source/kernel/bank4/misc.mac index 47364710..01a10ed6 100644 --- a/source/kernel/bank4/misc.mac +++ b/source/kernel/bank4/misc.mac @@ -489,6 +489,46 @@ FGC_BADCLUS: ld a,.ICLUS## ret +; +; +;------------------------------------------------------------------------------ +; +; Check if a cluster chain is consecutive +; (so the file is stored across consecutive sectors in the filesystem). +; +; Entry: A = drive number (0=default) +; DE = first cluster number +; Returns: A = error code (.ICLUS if not consecutive chain) + +CLUSQ:: + ld c,a +CLUSQLOOP: + ld hl,TEMP_FCB## + push bc + push de + ld a,c + call F_GETCLUS + pop de + pop bc + or a + ret nz ;Abort on any error. + + ld ix,TEMP_FCB## + bit 3,(ix+11) ;End of chain? + ret nz ;Yes: end with no error. + + inc de ;DE = Checked cluster number + 1 + ld l,(ix+8) + ld h,(ix+9) ;HL = Next cluster number in the chain + or a + sbc hl,de + ld a,h + or l + jr z,CLUSQLOOP ;Next cluster = checked + 1? Then continue... + + ld a,.ICLUS## + ret ;...otherwise error. + ; ; ;------------------------------------------------------------------------------ diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac index b17e9d89..4f2a5899 100644 --- a/source/kernel/bank4/partit.mac +++ b/source/kernel/bank4/partit.mac @@ -2224,6 +2224,8 @@ GDRVR_NAME_LOOP: ; +2 (2): Flags. Bit 0: mounted in read-only mode. ; +4 (13): Filename, zero-terminated ; (empty string, if not assigned to a file) +; +17 (2): Start cluster +; +19 (2): Start sector ; push ix @@ -2279,7 +2281,7 @@ NORDISK: bit UF_MNT,(ix+UD_FLAGS##) jr z,NOMNT - ;Assigned to a mounted file + ;* Assigned to a mounted file ld (iy+0),3 ld a,(ix+UD_DRV##) @@ -2288,16 +2290,10 @@ NORDISK: ld (iy+2),a ld (iy+3),0 - ld c,(ix+UD_FH##) - ld b,0 - ld hl,MHANDLES## - add hl,bc - add hl,bc - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - inc hl ;HL = Pointer to filename + push ix + pop hl + ld bc,UD_MNAME## + add hl,bc ;HL = Pointer to filename push iy pop de @@ -2308,6 +2304,25 @@ NORDISK: ld bc,13 ldir + ld a,(ix+UD_SCLU##) ;Start cluster + ld (de),a + inc de + ld a,(ix+UD_SCLU##+1) + ld (de),a + inc de + + ld a,(ix+UD_SSEC##) ;Start sector + ld (de),a + inc de + ld a,(ix+UD_SSEC##+1) + ld (de),a + inc de + ld a,(ix+UD_SSEC##+2) + ld (de),a + ;inc de ;The buffer has been zeroed previously + ;xor a + ;ld (de),a + xor a ret @@ -2691,6 +2706,9 @@ UNMAP_NEXT2: ; All file handles related to a given drive are closed prior to changing ; the mapping state of that drive. ; +; Mounting a file is allowed only if the file is stored across consecutive +; clusters in its host filesystem, otherwise an .ICLUS error is returned. +; ; Entry: C (A) = Drive letter, 0=A:, etc ; B = Action to perform ; 0: Unmap the drive @@ -2831,27 +2849,6 @@ MAP_UNMAP:: pcall INV_UD pop ix - ld a,(ix+UD_FLAGS##) - and UFM_MT - jr z,UNM_NOFILE ;If the drive has a file mounted, close its file handle - - push hl - push de - ld hl,MHANDLES## - ld e,(ix+UD_FH##) - ld d,0 - add hl,de - add hl,de - ld e,(hl) - inc hl - ld d,(hl) - dec hl - push de - pop ix - PCALL CLOSE_FAB - pop de - pop hl -UNM_NOFILE: pop ix pcall FR_P2 @@ -3315,10 +3312,10 @@ MF_CHK_ALRMNT: jr nz,MF_ALRMNT_NEXT ld a,(iy+19) - cp (ix+UD_SCLUS##) + cp (ix+UD_SCLU##) jr nz,MF_ALRMNT_NEXT ld a,(iy+20) - cp (ix+UD_SCLUS##+1) + cp (ix+UD_SCLU##+1) jr nz,MF_ALRMNT_NEXT pop ix @@ -3367,27 +3364,23 @@ MF_NO_32M: jp c,POPIX_RET MF_OK_SIZE: - ;* All the validations passed! - ; Now open the file + ;* Check if cluster chain is consecutive - ex (sp),hl - ld a,h ;Read only flag: open as no-write - and 1 - or 100b ;Inheritable - ex (sp),hl - push hl - push ix - call MF_OPEN - pop ix - pop hl - or a - jp nz,POPIX_RET + ld a,(ix+FIB_DRIVE##) + ld e,(ix+FIB_CLUSTER##) + ld d,(ix+FIB_CLUSTER##+1) + push hl + push ix + call CLUSQ## + pop ix + pop hl + or a + jp nz,POPIX_RET - ;* Destroy the previous unit descriptor + ;* All the validations passed! + ; Destroy the previous unit descriptor ; and allocate a new one - push bc ;B=File handle - push hl push ix call MAP_UNMAP @@ -3400,14 +3393,10 @@ MF_OK_SIZE: call CREATE_UD pop de ;Now DE = Pointer to FIB - pop bc jp z,MF_UD_OK - ;UD allocation failed: close file + ;UD allocation failed - push af - PCALL F_CLOSE - pop af call SETNUMDRV jp POPIX_RET MF_UD_OK: @@ -3415,16 +3404,29 @@ MF_UD_OK: ;* Fill the UD parameters appropriately pop hl ;H=flags - ld (ix+UD_FH##),b ld a,h and 1 ld (ix+UD_MFLAGS##),a ex de,hl ;Now HL = FIB + ;File name + + push ix + ex (sp),hl + ld bc,UD_MNAME## + add hl,bc + ex de,hl ;Now DE points to UD_MNAME + pop hl + push hl + inc hl ;Now HL points to filename in FIB + ld bc,13 + ldir + pop hl + ;Start cluster - ld bc,19 + ld bc,FIB_CLU## add hl,bc ;Now HL points to start cluster in FIB ld a,(hl) ld (ix+UD_SCLU##),a @@ -3457,6 +3459,25 @@ MF_UD_OK: dec a ld (ix+UD_DRV##),a + ;First sector in file drive + + ld hl,UNIT_TAB##+2 + ld c,(ix+UD_DRV##) + sla c + ld b,0 + add hl,bc + ld e,(hl) + inc hl + ld d,(hl) ;DE=Address of unit descriptor + ex de,hl + ld e,(ix+UD_SCLU##) + ld d,(ix+UD_SCLU##+1) + xor a + pcall CLU_TO_SEC + ld (ix+UD_SSEC##),e + ld (ix+UD_SSEC##+1),d + ld (ix+UD_SSEC##+2),a + ;Other parameters ld a,UFM_MT ;A file is mounted @@ -3481,82 +3502,6 @@ POPIX_RET: ret -;This routine opens a file to be mounted. -;It is almost a clone of F_OPEN in handles.mac, -;but registers the FAB pointer in the MHANDLES vector instead of -;using the standard HANDLES, and skips the file attribute checking -;as it has been already done. It also skips redirection -;state checking. - -MF_OPEN: - ex af,af' ;Save access mode byte - pcall LOC_FIB ;Find the directory entry - ret nz ;Give up if error -; - push hl ;Save unit descriptor address - - ld hl,MHANDLES## ;Find a free entry in MHANDLES - ld b,4 -MFOP_SRCH: - ld a,(hl) - inc hl - or (hl) - jr z,MFOP_FOUND - inc hl - djnz MFOP_SRCH - ld a,.NHAND## - or a - jr open_ret_1 -MFOP_FOUND: - dec b ;Convert B to the MHANDLES table entry index - ld a,b - xor 11b - ld b,a - dec hl -; - push hl ;Allocate a new FAB and set - pcall NFAB ; up its reference count. - jr nz,open_ret_2 ;Error if out of memory. -; - ex de,hl - ex (sp),hl ;Save directory entry pointer - ld (hl),e ;Store the pointer to the - inc hl ; new FAB in the file - ld (hl),d ; handle table -; - push bc - push de ;Copy the compatible portion - ex (sp),ix ; of the FIB into the new - pop hl ; FAB as a start for - ld bc,FAB_FIB## ; setting it up. - ldir - pop bc ;Get file handle back - pop de ;DE -> directory entry -; - ld (ix+FAB_SA##),ATM_HID+ATM_SYS ;Set search attributes - ; so that any file, but - ; no sub-directories - ; will be found. -; - xor a - ld (ix+FAB_PTR##),a ;Set the four byte file - ld (ix+FAB_PTR##+1),a ; pointer to zero in the - ld (ix+FAB_PTR##+2),a ; file access block. - ld (ix+FAB_PTR##+3),a -; - pop hl - ex af,af' ;Get access mode byte back - pcall OPEN_FAB ;Open the file access block - set 4,(ix+FAB_MODE##) -open_directory: xor a - ret -; -; -open_ret_2: pop hl -open_ret_1: pop hl ;Return with error code - ret - - ;This subroutine creates an empty unit descriptor ;Entry: C = Drive letter (0 = A:, etc) ; HL = Address of unit descriptor pointer in UNIT_TAB diff --git a/source/kernel/kvar.mac b/source/kernel/kvar.mac index 968479ce..165d81d2 100644 --- a/source/kernel/kvar.mac +++ b/source/kernel/kvar.mac @@ -212,15 +212,16 @@ size macro name ;--- Extra fields used when mounting files ; This extra space should NOT be allocated unless a file is mounted to the drive - field 1,UD_FH ;File Handle of mounted file field 1,UD_MFLAGS ;Flags. Bit 0: read-only mount field 1,UD_DRV ;Drive where the mounted file is field 2,UD_MXS ;Maximum sector number field 2,UD_SCLU ;Start cluster (used to check if file is already mounted) + field 3,UD_SSEC ;Start sector relative to the drive where the mounted file is + field 13,UD_MNAME ;File name size UD_MSZ ;Total size of unit descriptor including extra fields - const UD_SZ,UD_MSZ-5 ;Total size of unit descriptor without extra fields + const UD_SZ,UD_MSZ-22 ;Total size of unit descriptor without extra fields ;***************************************************************************** @@ -572,13 +573,9 @@ else var1 RD_COUNT ;RAM disk segment count var RD_BOOT,512 ;RAM disk boot sector start endif - var MHANDLES,8 ;Pseudo-file handles table for mounted filed (4 entries) - var RW_LEVEL,1 - var BF_LEVEL,1 ;var RW_SAVE,60 ;To temporarily save RW_* variables var IY_SAVE,2 var A_SAVE,1 - var SEG_SAVE,1 ; ; --------------------------------- ; From d4a182d15c0f6f1093f88f1af1d1e564b03de9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Tue, 22 Mar 2022 10:08:22 +0100 Subject: [PATCH 3/5] Fix: incorrect setting of UD_ACLU when freeing a FAT chain (#96) --- source/kernel/bank2/fat.mac | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/kernel/bank2/fat.mac b/source/kernel/bank2/fat.mac index a1e1976c..2f47ff95 100644 --- a/source/kernel/bank2/fat.mac +++ b/source/kernel/bank2/fat.mac @@ -898,9 +898,11 @@ zero_dsec_loop: ld (hl),c ; the data area of buffer dec de ;DE = new value or a sbc hl,de ;HL = current value - new value, Cy=1 if new > current - call nc,ACLU_SET pop hl ;Restore address of unit descriptor - ret + ret c + ld de,(FAT_CHAIN##) + dec de + jp ACLU_SET frchlp3: push hl ;Preserve address of unit descriptor From da69ce5f94e960ac2545b64d41f3df11446a1dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Tue, 22 Mar 2022 10:12:45 +0100 Subject: [PATCH 4/5] Add a new KILLDSKIO environment variable #98) Add a new KILLDSKIO environment variable to disable DSKI$ and DSKO$ When set to "on", the 512 byte buffer for DSKI$ and DSKO$ won't be allocated, and the commands will be disabled. --- docs/Nextor 2.1 User Manual.md | 12 ++++++++++++ source/kernel/bank0/dskbasic.mac | 8 ++++++++ source/kernel/bank0/init.mac | 7 ++++++- source/kernel/bank4/env.mac | 33 +++++++++++++++++++++++++++++++- source/kernel/data.mac | 4 +++- 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/docs/Nextor 2.1 User Manual.md b/docs/Nextor 2.1 User Manual.md index 4092356a..30b79f71 100644 --- a/docs/Nextor 2.1 User Manual.md +++ b/docs/Nextor 2.1 User Manual.md @@ -42,6 +42,8 @@ [2.13. File mounting and disk emulation mode](#213-file-mounting-and-disk-emulation-mode) +[2.14. The KILLDSKIO environment variable](#214-the-killdskio-environment-variable) + [3. Using Nextor](#3-using-nextor) [3.1. Installing Nextor](#31-installing-nextor) @@ -341,6 +343,12 @@ Since version 2.1 Nextor allows to mount disk image files in two ways: * Booting in disk emulation mode, so the system boots in MSX-DOS 1 mode and uses a set disk image files (one at a time) as the boot device. See [3.9. Disk emulation mode](#39-disk-emulation-mode). +### 2.14. The KILLDSKIO environment variable + +Since version 2.1.1 Nextor provides a mechanism to disable the BASIC commands `DSKI$` and `DSKO$`, which gives 512 extra bytes of free memory for the BASIC environment. This is achieved by creating an environment variable named `KILLDSKIO` with a value of `ON` (case-insensitive). + +Note that when `DSKI$` and `DSKO$` are disabled in this way the `DIRBUF` variable (&HF351), which holds the address of the 512 byte buffer where these commands read and write sectors, will have the same value as `SECBUF` (&HF34D), which is a generic sector buffer used internally by Nextor; and the same goes for `PATHNAM` (&HF33B), a buffer used by BASIC to parse pathnames for commands like `FILES`. This shouldn't be a problem in most cases, but for robustness it's recommended to use this feature only when that extra memory is abolutely necessary. + ## 3. Using Nextor @@ -1121,6 +1129,10 @@ This section contains the change history for the different versions of Nextor. C This list contains the changes for the 2.1 branch only. For the change history of the 2.0 branch see the _[Nextor 2.0 User Manual](../../../blob/v2.0/docs/Nextor%202.0%20User%20Manual.md#5-change-history)_ document. +### 5.1. v2.1.1 beta 2 + +- Introduced the + ### 5.1. v2.1.0 beta 2 - Nextor will now try to load `MSXDOS2.SYS` if `NEXTOR.SYS` is not found in the boot drive. diff --git a/source/kernel/bank0/dskbasic.mac b/source/kernel/bank0/dskbasic.mac index 90ba25fa..f0838b5f 100644 --- a/source/kernel/bank0/dskbasic.mac +++ b/source/kernel/bank0/dskbasic.mac @@ -1932,6 +1932,12 @@ GET_HANDLE_0: pop hl ret +CHECK_KILLDSKIO: + ld a,(MFLAGS##) + and 16 ;KILLD + jp nz,JSNERR + ret + if 1 subttl DSKI$/DSKO$ ; @@ -1939,6 +1945,7 @@ if 1 ; DSKO$ , ; $HOOK DSKI$ + call CHECK_KILLDSKIO call REMHOK ;remove hook return call CHRGET ;skip over current token SYNCHK '(' @@ -1955,6 +1962,7 @@ $HOOK DSKI$ jr DSKO$1 ;perform disk input ; $HOOK DSKO$ + call CHECK_KILLDSKIO call REMHOK ;remove hook return call GET_PARAM ;get drive and sector call CHRGOT ;end of statement? diff --git a/source/kernel/bank0/init.mac b/source/kernel/bank0/init.mac index 4bff827d..37e50d30 100644 --- a/source/kernel/bank0/init.mac +++ b/source/kernel/bank0/init.mac @@ -1868,8 +1868,13 @@ SET_DISKBASIC:: ld hl,DBABORT## ld (BREAKVECT##),hl ; - ld bc,($MAXSEC##) ;Allocate sector buffer for DSKI$, DSKO$ + ld a,(MFLAGS##) + and 16 ;KILLD + ld hl,($SECBUF##) + jr nz,SET_DIRBUF ;Allocate sector buffer for DSKI$, DSKO$ + ld bc,($MAXSEC##) ;unless KILLDSKIO env item is set call RESERVE_BASIC +SET_DIRBUF: ld ($DIRBUF##),hl if 0 ; diff --git a/source/kernel/bank4/env.mac b/source/kernel/bank4/env.mac index e9bfe45b..48aee33e 100644 --- a/source/kernel/bank4/env.mac +++ b/source/kernel/bank4/env.mac @@ -135,7 +135,7 @@ check_duplicate:call FIND_ENV_ITEM ;Look for a matching item xor a ret ;Return with no error. - ;Check for ZALLOC and ERRLANG + ;Check for ZALLOC, KILLDSKIO and ERRLANG CHECK_SPECIAL: push hl ;Name @@ -162,7 +162,37 @@ ZALLOC_OFF: ZALLOC_END: ld (MFLAGS##),a + jr CHKERRLANG_END + CHKZALLOC_END: + pop de + pop hl + push hl + push de + +CHECK_KILLD: + ld de,KILLD_S + call COMPARE_ENV + jr nz,CHKKILLD_END + + pop hl ;Value + push hl + ld de,ON_S + call COMPARE_ENV + ld a,(MFLAGS##) + jr nz,KILLD_OFF + +KILLD_ON: + or 16 + jr KILLD_END + +KILLD_OFF: + and 255-16 + +KILLD_END: + ld (MFLAGS##),a + jr CHKERRLANG_END +CHKKILLD_END: pop de pop hl push hl @@ -195,6 +225,7 @@ CHKERRLANG_END: ret ZALLOC_S: db "ZALLOC",0 +KILLD_S: db "KILLDSKIO",0 ERRLANG_S: db "ERRLANG",0 ON_S: db "ON",0 EN_S: db "EN",0 diff --git a/source/kernel/data.mac b/source/kernel/data.mac index c3991b97..847be00b 100644 --- a/source/kernel/data.mac +++ b/source/kernel/data.mac @@ -217,7 +217,9 @@ ram_ad defl DATABASE var1 MFLAGS ;Miscellaneous flags const FASTOUT,0 ;bit 0: set for fast STROUT const FIRSTLD,1 ;bit 1: set while booting NEXTOR.SYS for the first time - const ZALLOC,2 ;bit 2: reduced alloc info mode becomes zero info mode + const ZALLOC,2 ;bit 2: reduced alloc info mode becomes zero info mode (SET ZALLOC ON) + const ERRL,3 ;bit 3: always show error messages in English (SET ERRLANG ON) + const KILLD,4 ;bit 4: kill DSKI and DSKO BASIC commands (SET KILLDSKIO ON) const SYST2,7 ;Bit 7: force boot in MSXDOS2.SYS (temporary, reset after read) spare 1 ;Available for DOS 2 ; From 4c2903b45b803f038571770b5506e52bf48b7f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Soriano?= Date: Tue, 22 Mar 2022 10:13:04 +0100 Subject: [PATCH 5/5] Update kernel version number to 2.1.1 beta 2 (#101) --- source/kernel/Makefile | 2 +- source/kernel/condasm.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/kernel/Makefile b/source/kernel/Makefile index fe733988..2b957256 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -4,7 +4,7 @@ # See the "all" main rule for some handy aliases to generate specific ROMs # (e.g. you can run "make base" or "make ide"). -VERSION := 2.1.1-beta1 +VERSION := 2.1.1-beta2 export X80_COMMAND_LINE=-t -nb export M80_COMMAND_LINE=-8 diff --git a/source/kernel/condasm.inc b/source/kernel/condasm.inc index df33540e..e735232a 100644 --- a/source/kernel/condasm.inc +++ b/source/kernel/condasm.inc @@ -10,7 +10,7 @@ BUILTIN equ -1 ;built-in system ALPHA equ 0 ;Level of Alpha release (0: no alpha) ALPHAL equ "" ;Letter after the Alpha release number, or empty -BETA equ 1 ;Level of Beta release (0: no beta) +BETA equ 2 ;Level of Beta release (0: no beta) RC equ 0 ;Level of RC (0: no RC) RR equ 0 ;Level of release (0: no release level) ;