mirror of
https://github.com/Tolik-Trek/Estex-DSS.git
synced 2026-11-27 13:12:13 +03:00
Пока не работает, надо доделывать BigDir.
Затащены правки из Master: Исправлен баг с относительными путями. thx to @witchcraft2001 IF, GOTO, GOSUB/RETURN in BAT files. Правки CLP -bug с выводом строки в BAT -bug M_INT: RFI is CH-A ONLY (per Z80 SIO spec) -bug KEYINTER.ASM: russian chars fix Num Lock numbers
This commit is contained in:
1 parent
4423f41f1a
commit
41ff458cd4
18 files changed
+1913
-214
No files matched your search
+32
-12
@@ -42,7 +42,7 @@ MAKE_BATCH_PRM_ARRAY:
|
||||
ret z
|
||||
cp " "
|
||||
jr z,.loop
|
||||
cp 9 ; Tab
|
||||
cp "\t" ; Tab
|
||||
jr z,.loop
|
||||
ex de,hl
|
||||
ld (hl),e
|
||||
@@ -231,9 +231,11 @@ MOVWORD:
|
||||
ld b,a
|
||||
.loop: ld a,(hl)
|
||||
ld (de),a
|
||||
cp "\t" ; TAB - in-line blank, keep it (MS-DOS bat)
|
||||
jr z,.cont
|
||||
cp " "
|
||||
jr c,.loop_
|
||||
inc hl
|
||||
jr c,.loop_ ; <0x20 (CR/LF) -> end of line
|
||||
.cont: inc hl
|
||||
inc de
|
||||
djnz .loop
|
||||
scf
|
||||
@@ -281,6 +283,8 @@ CMDMODE:
|
||||
;ld (D96A6),a ; (inline.asm)
|
||||
call EVALCMD ; (batch.asm)
|
||||
RET C
|
||||
call BAT_CHECK_LABEL ; GOTO labels / search
|
||||
RET C
|
||||
;ld ix,T96AC ; 㦮?? § ª®¬¥â ਫ (inline.asm)
|
||||
;ld hl,T96AE ;;256 ¡ãä¥à (inline.asm)
|
||||
ld hl,Buffers.input_line.Path
|
||||
@@ -323,8 +327,10 @@ CMDMODE:
|
||||
ld b,a
|
||||
inc hl ;+5
|
||||
push bc
|
||||
ld c,BIOS.LP_PRINT_LINE2 ; ¢ë¢®¤ áâப¨ ¡¥§ âਡã⮢
|
||||
RST ToBIOS
|
||||
LD C,Dss.PChars
|
||||
RST ToDSS
|
||||
;ld c,BIOS.LP_PRINT_LINE2 ; ¢ë¢®¤ áâப¨ ¡¥§ âਡã⮢
|
||||
;RST ToBIOS
|
||||
pop bc ; b=¤«¨ áâப¨
|
||||
ld a,(width_inpline) ; è¨à¨ ¯®«ï ¢¢®¤ (76..48)
|
||||
sub b
|
||||
@@ -364,8 +370,10 @@ CMDMODE:
|
||||
;ld hl,Buffers.work.buffer+256;;
|
||||
.A826C: ld a,(hl)
|
||||
cp " "
|
||||
jr z,.A826W
|
||||
cp "\t"
|
||||
jr nz,.A8276
|
||||
inc hl
|
||||
.A826W: inc hl
|
||||
dec c
|
||||
jr nz,.A826C
|
||||
ret
|
||||
@@ -377,10 +385,17 @@ CMDMODE:
|
||||
sbc hl,bc
|
||||
ld a,c
|
||||
ex af,af'
|
||||
ld a," "
|
||||
cpir
|
||||
jr nz,.A8286
|
||||
inc c
|
||||
.A827S: ld a,c
|
||||
or a
|
||||
jr z,.A8286 ; no blank -> whole line is the command
|
||||
ld a,(hl)
|
||||
cp " "
|
||||
jr z,.A8286
|
||||
cp "\t"
|
||||
jr z,.A8286
|
||||
inc hl
|
||||
dec c
|
||||
jr .A827S
|
||||
.A8286: ex af,af'
|
||||
sub c
|
||||
ld c,a ; ¤«¨ á«®¢ ¨«¨ áâப¨ ?
|
||||
@@ -403,7 +418,7 @@ EVALCMD: xor a
|
||||
call EVALSTR
|
||||
ld hl,Buffers.work.buffer2 ;work_buffer+256
|
||||
ld de,Buffers.input_line.Path ; ªã¤
|
||||
ld bc,255 ;!HARDCODE
|
||||
ld bc,max_len_comline+2
|
||||
.loop: LD A,C
|
||||
DEC A
|
||||
JR Z,.error
|
||||
@@ -413,10 +428,11 @@ EVALCMD: xor a
|
||||
inc b
|
||||
or a
|
||||
jr nz,.loop
|
||||
;
|
||||
dec b
|
||||
ld a,b
|
||||
ld (Buffers.input_line.Symbols_Num),a ; ¤«¨ áâப¨ (edline.asm)
|
||||
and a
|
||||
;and a
|
||||
ret
|
||||
;
|
||||
.error: LD (DE),A
|
||||
@@ -507,6 +523,10 @@ EVALSTR: ld a,(hl)
|
||||
BATLIST: DZ 'PAUSE' : DW cmd_pause
|
||||
DZ 'REM' : DW cmd_rem
|
||||
DZ 'EXIT' : DW cmd_break
|
||||
DZ 'GOTO' : DW cmd_goto
|
||||
DZ 'GOSUB' : DW cmd_gosub
|
||||
DZ 'RETURN' : DW cmd_return
|
||||
DZ 'IF' : DW cmd_if
|
||||
;
|
||||
; DSS-ª®¬ ¤ë
|
||||
CMDLIST: DZ 'CD' : DW cmd_chdir
|
||||
|
||||
@@ -2,7 +2,16 @@
|
||||
cmd_break:
|
||||
.sp+1: LD SP,0
|
||||
;!TODO ¢«®¦¥ë¥ bat. ¯¥à¥¤ ¢ âì ®è¨¡ªã ®¡à â® ¢ ¢ë§ë¢ î騩 bat
|
||||
.exit: ld a,(BAT_FM) ; ¤¥áªà. bat-ä ©«
|
||||
.exit: ld a,(goto_active) ; GOTO: label not found ?
|
||||
or a
|
||||
jr z,.close
|
||||
xor a
|
||||
ld (goto_active),a
|
||||
ld de,MAIN_MSG.LABEL_NOT_FOUND
|
||||
call ECHO_MESSAGE
|
||||
.close: xor a
|
||||
ld (gosub_sp),a ; reset GOSUB stack
|
||||
ld a,(BAT_FM) ; ¤¥áªà. bat-ä ©«
|
||||
ld c,Dss.Close ; § ªàëâì ä ©«
|
||||
RST ToDSS
|
||||
xor a
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
; !FIXIT Vibe-code ¯à®¢¥à¨âì
|
||||
|
||||
;///////////////////////////////////////////////////
|
||||
;
|
||||
; GOTO / GOSUB / RETURN. Jumps inside a BAT-file by
|
||||
; ":label", MS-DOS / 4DOS style.
|
||||
;
|
||||
; GOTO label - jump to ":label"
|
||||
; GOSUB label - call subroutine at ":label"
|
||||
; RETURN - return to the line after the GOSUB
|
||||
;
|
||||
;///////////////////////////////////////////////////
|
||||
|
||||
GOTO_LABEL_MAX EQU 15 ; max label name length
|
||||
GOSUB_MAX EQU 16 ; max GOSUB nesting depth
|
||||
|
||||
;-------------------------------------------------
|
||||
; GOTO label
|
||||
; in: de -> argument string (label, may start with ':')
|
||||
;-------------------------------------------------
|
||||
cmd_goto:
|
||||
ex de,hl ; hl -> argument text
|
||||
call GOTO_PARSE ; -> goto_label (upper, 0-term)
|
||||
ld a,(goto_label)
|
||||
or a
|
||||
jp z,.empty ; no label name
|
||||
jp GOTO_START ; rewind + start the label search
|
||||
.empty: ld de,MAIN_MSG.LABEL_NOT_FOUND
|
||||
jp gAbort
|
||||
|
||||
;-------------------------------------------------
|
||||
; GOSUB label
|
||||
; in: de -> argument string (label, may start with ':')
|
||||
;-------------------------------------------------
|
||||
cmd_gosub:
|
||||
ex de,hl ; hl -> argument text
|
||||
call GOTO_PARSE ; -> goto_label (saved in memory)
|
||||
ld a,(goto_label)
|
||||
or a
|
||||
jp z,cmd_goto.empty
|
||||
call GOSUB_PUSH ; remember the return position
|
||||
jp GOTO_START ; then jump like GOTO
|
||||
|
||||
;-------------------------------------------------
|
||||
; RETURN - resume after the matching GOSUB
|
||||
;-------------------------------------------------
|
||||
cmd_return:
|
||||
ld a,(gosub_sp)
|
||||
or a
|
||||
jr z,.empty ; RETURN without GOSUB
|
||||
dec a
|
||||
ld (gosub_sp),a
|
||||
add a,a
|
||||
add a,a ; a = sp*4 (byte offset in stack)
|
||||
ld e,a
|
||||
ld d,0
|
||||
ld hl,gosub_stk
|
||||
add hl,de
|
||||
ld e,(hl) ; saved offset (low word)
|
||||
inc hl
|
||||
ld d,(hl)
|
||||
inc hl
|
||||
ld (gosub_lo),de
|
||||
ld e,(hl) ; saved offset (high word)
|
||||
inc hl
|
||||
ld d,(hl)
|
||||
ld (gosub_hi),de
|
||||
ld a,(BAT_FM) ; bat-file handle
|
||||
ld hl,(gosub_hi) ; HL = offset high 16 bits
|
||||
ld ix,(gosub_lo) ; IX = offset low 16 bits
|
||||
ld bc,Dss.Move_FP.FrStart ; B=0 (from start), C=#15
|
||||
RST ToDSS
|
||||
jr c,.io
|
||||
xor a
|
||||
ld (MOVWORD.count),a ; force re-read from saved position
|
||||
ret ; back to NEWLINE -> line after GOSUB
|
||||
.empty: ld de,MAIN_MSG.RET_NO_GOSUB
|
||||
jp gAbort
|
||||
.io: call print_err_message
|
||||
jp gAbort.silent
|
||||
|
||||
;-------------------------------------------------
|
||||
; Parse a label argument into goto_label
|
||||
; in: hl -> text (optional spaces/TAB, optional ':')
|
||||
; out: goto_label = upper-cased, 0-terminated token
|
||||
;-------------------------------------------------
|
||||
GOTO_PARSE:
|
||||
.sp0: ld a,(hl) ; skip leading blanks (space / TAB)
|
||||
cp " "
|
||||
jr z,.sp0i
|
||||
cp "\t"
|
||||
jr nz,.nosp0
|
||||
.sp0i: inc hl
|
||||
jr .sp0
|
||||
.nosp0: cp ":" ; allow "GOTO :label"
|
||||
jr nz,.sp1
|
||||
inc hl
|
||||
.sp1: ld a,(hl) ; skip blanks after ':'
|
||||
cp " "
|
||||
jr z,.sp1i
|
||||
cp "\t"
|
||||
jr nz,.copy
|
||||
.sp1i: inc hl
|
||||
jr .sp1
|
||||
.copy: ld de,goto_label
|
||||
ld b,GOTO_LABEL_MAX
|
||||
.cloop: ld a,(hl)
|
||||
cp " "+1 ; a <= ' ' -> end of token
|
||||
jr c,.cend
|
||||
call COMPARE.cmp_AZ ; -> upper case
|
||||
ld (de),a
|
||||
inc hl
|
||||
inc de
|
||||
djnz .cloop
|
||||
.cend: xor a
|
||||
ld (de),a ; 0-terminate
|
||||
ret
|
||||
|
||||
;-------------------------------------------------
|
||||
; Rewind the BAT-file and start the label search
|
||||
;-------------------------------------------------
|
||||
GOTO_START:
|
||||
ld a,(BAT_FM) ; bat-file handle
|
||||
ld hl,0 ; offset low
|
||||
ld ix,0 ; offset high
|
||||
ld bc,Dss.Move_FP.FrStart ; B=0 (from start), C=#15
|
||||
RST ToDSS
|
||||
jr c,.io
|
||||
xor a
|
||||
ld (MOVWORD.count),a ; invalidate NEWLINE read buffer
|
||||
ld a,1
|
||||
ld (goto_active),a ; activate the label search
|
||||
ret
|
||||
.io: call print_err_message
|
||||
jp gAbort.silent
|
||||
|
||||
;-------------------------------------------------
|
||||
; Push the return position (file offset of the line
|
||||
; that follows the current GOSUB) onto the stack.
|
||||
;-------------------------------------------------
|
||||
GOSUB_PUSH:
|
||||
ld a,(gosub_sp)
|
||||
cp GOSUB_MAX
|
||||
jr nc,.deep ; stack overflow
|
||||
; current file pointer (tell): FrCurrent, offset 0
|
||||
ld a,(BAT_FM)
|
||||
ld hl,0
|
||||
ld ix,0
|
||||
ld bc,Dss.Move_FP.FrCurrent ; B=1, C=#15
|
||||
RST ToDSS
|
||||
jr c,.io
|
||||
; on return: IX = pointer low 16, HL = pointer high 16
|
||||
ld (gosub_hi),hl ; save high word
|
||||
push ix
|
||||
pop hl ; hl = pointer low 16
|
||||
; offset = pointer - (bytes still unparsed in buffer1)
|
||||
ld a,(MOVWORD.count)
|
||||
ld e,a
|
||||
ld d,0
|
||||
or a ; CF=0
|
||||
sbc hl,de ; hl = low - count
|
||||
ld (gosub_lo),hl
|
||||
jr nc,.nob
|
||||
ld hl,(gosub_hi) ; borrow into high word
|
||||
dec hl
|
||||
ld (gosub_hi),hl
|
||||
.nob:
|
||||
; store at gosub_stk[gosub_sp]
|
||||
ld a,(gosub_sp)
|
||||
ld c,a ; c = old depth
|
||||
add a,a
|
||||
add a,a ; a = sp*4
|
||||
ld e,a
|
||||
ld d,0
|
||||
ld hl,gosub_stk
|
||||
add hl,de
|
||||
ld de,(gosub_lo)
|
||||
ld (hl),e
|
||||
inc hl
|
||||
ld (hl),d
|
||||
inc hl
|
||||
ld de,(gosub_hi)
|
||||
ld (hl),e
|
||||
inc hl
|
||||
ld (hl),d
|
||||
ld a,c
|
||||
inc a
|
||||
ld (gosub_sp),a ; depth++
|
||||
ret
|
||||
.deep: ld de,MAIN_MSG.GOSUB_DEEP
|
||||
jp gAbort
|
||||
.io: call print_err_message
|
||||
jp gAbort.silent
|
||||
|
||||
;-------------------------------------------------
|
||||
; Print message (de=index) and abort the BAT-file
|
||||
;-------------------------------------------------
|
||||
gAbort:
|
||||
call ECHO_MESSAGE
|
||||
.silent:
|
||||
xor a
|
||||
ld (goto_active),a ; don't double-print in cmd_break.exit
|
||||
jp cmd_break.exit
|
||||
|
||||
;-------------------------------------------------
|
||||
; Called from CMDMODE for every BAT-file line.
|
||||
; Handles ":label" lines and the GOTO/GOSUB search.
|
||||
;
|
||||
; out: CF=1 - skip this line (label line, or searching)
|
||||
; CF=0 - execute this line normally
|
||||
;-------------------------------------------------
|
||||
BAT_CHECK_LABEL:
|
||||
ld hl,Buffers.input_line.Path
|
||||
.sp: ld a,(hl) ; skip leading blanks (space / TAB)
|
||||
cp " "
|
||||
jr z,.spi
|
||||
cp "\t"
|
||||
jr nz,.first
|
||||
.spi: inc hl
|
||||
jr .sp
|
||||
.first: cp ":" ; is it a label line ?
|
||||
jr z,.label
|
||||
; not a label line
|
||||
ld a,(goto_active)
|
||||
or a
|
||||
ret z ; CF=0 -> run normally
|
||||
scf ; searching -> skip line
|
||||
ret
|
||||
;
|
||||
.label: ld a,(goto_active)
|
||||
or a
|
||||
jr nz,.match
|
||||
; not searching: ":label" -> skip (no echo, no exec)
|
||||
scf
|
||||
ret
|
||||
; searching: does this label match goto_label ?
|
||||
.match: inc hl ; skip ':'
|
||||
.msp: ld a,(hl) ; skip blanks after ':'
|
||||
cp " "
|
||||
jr z,.mspi
|
||||
cp "\t"
|
||||
jr nz,.mcmp
|
||||
.mspi: inc hl
|
||||
jr .msp
|
||||
.mcmp: ld de,goto_label
|
||||
.mlp: ld a,(de) ; target char (upper, 0-term)
|
||||
or a
|
||||
jr z,.mend ; target consumed
|
||||
ld c,a
|
||||
ld a,(hl)
|
||||
cp " "+1 ; line token ended too early ?
|
||||
jr c,.skip ; -> no match
|
||||
call COMPARE.cmp_AZ
|
||||
cp c
|
||||
jr nz,.skip
|
||||
inc hl
|
||||
inc de
|
||||
jr .mlp
|
||||
.mend: ld a,(hl) ; target ended: line token must end here
|
||||
cp " "+1 ; a <= ' ' -> full match
|
||||
jr nc,.skip ; line label is longer -> no match
|
||||
; match ! stop searching, skip the label line itself
|
||||
xor a
|
||||
ld (goto_active),a
|
||||
scf
|
||||
ret
|
||||
;
|
||||
.skip: scf ; keep searching, skip this line
|
||||
ret
|
||||
;
|
||||
|
||||
goto_active: db 0 ; 1 = searching for a label
|
||||
goto_label: ds GOTO_LABEL_MAX+1,0 ; target label (upper, 0-term)
|
||||
gosub_sp: db 0 ; GOSUB nesting depth
|
||||
gosub_lo: dw 0 ; scratch (offset low)
|
||||
gosub_hi: dw 0 ; scratch (offset high)
|
||||
gosub_stk: ds GOSUB_MAX*4,0 ; return offsets (32-bit each)
|
||||
@@ -0,0 +1,241 @@
|
||||
;///////////////////////////////////////////////////
|
||||
;
|
||||
; IF - conditional command (MS-DOS style)
|
||||
;
|
||||
; IF [NOT] ERRORLEVEL number command
|
||||
; IF [NOT] EXIST filename command
|
||||
; IF [NOT] string1 == string2 command
|
||||
;
|
||||
; If the condition is true, the rest of the line is
|
||||
; executed as an ordinary command (GOTO, ECHO, a
|
||||
; program, another IF, ...).
|
||||
;
|
||||
;///////////////////////////////////////////////////
|
||||
|
||||
; in: de -> argument string (everything after "IF ")
|
||||
cmd_if:
|
||||
ex de,hl ; hl -> args
|
||||
xor a
|
||||
ld (.neg),a
|
||||
call IF_SKIPB ; skip leading blanks
|
||||
; --- optional NOT ---
|
||||
ld de,.kw_not
|
||||
call IF_KW
|
||||
jr nc,.noNOT
|
||||
ld a,1
|
||||
ld (.neg),a
|
||||
.noNOT:
|
||||
; --- ERRORLEVEL n ? ---
|
||||
ld de,.kw_errlvl
|
||||
call IF_KW
|
||||
jr nc,.notErr
|
||||
ld de,Buffers.work.buffer1
|
||||
ld c,Dss.GSwitch ; extract the number token
|
||||
RST ToDSS
|
||||
ld (.cmd),hl ; rest of line = command part
|
||||
ld de,Buffers.work.buffer1
|
||||
call IF_ATOI8 ; a = number (0..255)
|
||||
ld b,a ; b = threshold
|
||||
ld c,Dss.Get_Err ; a = exit code of last program
|
||||
RST ToDSS
|
||||
cp b ; A >= n ? (NC = yes)
|
||||
ld a,0
|
||||
jr c,.decide ; A < n -> false
|
||||
inc a ; true
|
||||
jr .decide
|
||||
.notErr:
|
||||
; --- EXIST filename ? ---
|
||||
ld de,.kw_exist
|
||||
call IF_KW
|
||||
jr nc,.strcmp
|
||||
ld de,Buffers.work.buffer1
|
||||
ld c,Dss.GSwitch ; extract the filename token
|
||||
RST ToDSS
|
||||
ld (.cmd),hl ; rest of line = command part
|
||||
ld a,FAT_ATTR.NoVolID ; any file/dir (not the volume label)
|
||||
ld hl,Buffers.work.buffer1 ; filespec (NUL-term DOS name)
|
||||
ld de,Buffers.work.buffer2 ; F_First work buffer
|
||||
ld bc,Dss.F_First.DOSname ; B=1, C=#19
|
||||
RST ToDSS
|
||||
ld a,0
|
||||
jr c,.decide ; CF=1 -> not found -> false
|
||||
inc a ; exists -> true
|
||||
jr .decide
|
||||
.strcmp:
|
||||
; hl -> string1 "==" string2 [blank] command
|
||||
push hl ; s1 start
|
||||
.find: ld a,(hl)
|
||||
or a
|
||||
jr z,.bad ; no "==" -> malformed
|
||||
cp "="
|
||||
jr nz,.fnext
|
||||
inc hl
|
||||
ld a,(hl)
|
||||
cp "="
|
||||
jr z,.foundEq
|
||||
dec hl
|
||||
.fnext: inc hl
|
||||
jr .find
|
||||
.bad: pop hl
|
||||
ret ; syntax error -> no-op
|
||||
.foundEq:
|
||||
dec hl ; hl -> first '=' of "=="
|
||||
pop de ; de = s1 start
|
||||
push de
|
||||
or a
|
||||
sbc hl,de ; hl = len1 (line < 256 -> h=0)
|
||||
ld a,l
|
||||
ld (.len1),a
|
||||
pop de ; de = s1 start
|
||||
ld hl,0
|
||||
ld l,a
|
||||
add hl,de ; hl = s1 + len1 = first '='
|
||||
inc hl
|
||||
inc hl ; hl = s2 start
|
||||
ld (.s2),hl
|
||||
ld b,0 ; len2
|
||||
.s2l: ld a,(hl)
|
||||
cp " "+1 ; <=' ' (space/tab/CR/0) -> token end
|
||||
jr c,.s2e
|
||||
inc hl
|
||||
inc b
|
||||
jr .s2l
|
||||
.s2e: ld (.cmd),hl ; command part starts here
|
||||
ld a,(.len1)
|
||||
cp b ; len1 == len2 ?
|
||||
jr nz,.neq
|
||||
or a
|
||||
jr z,.eq ; both empty -> equal
|
||||
ld c,a ; c = length
|
||||
ld hl,(.s2)
|
||||
.cl: ld a,(de) ; de = s1
|
||||
cp (hl) ; case-sensitive (MS-DOS)
|
||||
jr nz,.neq
|
||||
inc de
|
||||
inc hl
|
||||
dec c
|
||||
jr nz,.cl
|
||||
.eq: ld a,1
|
||||
jr .decide
|
||||
.neq: xor a
|
||||
;
|
||||
.decide:
|
||||
; a = raw condition (0/1)
|
||||
ld b,a
|
||||
ld a,(.neg)
|
||||
xor b ; cond ^ NOT
|
||||
and 1
|
||||
ret z ; false -> nothing to do
|
||||
ld hl,(.cmd)
|
||||
jp IF_RUN ; true -> run the command part
|
||||
;
|
||||
.kw_not: db "NOT",0
|
||||
.kw_errlvl: db "ERRORLEVEL",0
|
||||
.kw_exist: db "EXIST",0
|
||||
.neg: db 0
|
||||
.cmd: dw 0
|
||||
.len1: db 0
|
||||
.s2: dw 0
|
||||
|
||||
;-------------------------------------------------
|
||||
; Skip blanks (space / TAB) at (hl)
|
||||
;-------------------------------------------------
|
||||
IF_SKIPB:
|
||||
.l: ld a,(hl)
|
||||
cp " "
|
||||
jr z,.i
|
||||
cp "\t"
|
||||
ret nz
|
||||
.i: inc hl
|
||||
jr .l
|
||||
|
||||
;-------------------------------------------------
|
||||
; Case-insensitive keyword test.
|
||||
; in: hl -> text, de -> keyword (UPPER, 0-term)
|
||||
; out: CF=1 - matched, hl past keyword + blanks
|
||||
; CF=0 - no match, hl unchanged
|
||||
;-------------------------------------------------
|
||||
IF_KW: push hl
|
||||
.l: ld a,(de)
|
||||
or a
|
||||
jr z,.kend ; keyword consumed
|
||||
ld c,a
|
||||
ld a,(hl)
|
||||
call COMPARE.cmp_AZ ; -> upper
|
||||
cp c
|
||||
jr nz,.no
|
||||
inc hl
|
||||
inc de
|
||||
jr .l
|
||||
.kend: ld a,(hl) ; must be a blank delimiter
|
||||
cp " "
|
||||
jr z,.ok
|
||||
cp "\t"
|
||||
jr z,.ok
|
||||
.no: pop hl ; restore, no match
|
||||
or a ; CF=0
|
||||
ret
|
||||
.ok: inc hl ; skip delimiter + following blanks
|
||||
.ok2: ld a,(hl)
|
||||
cp " "
|
||||
jr z,.oki
|
||||
cp "\t"
|
||||
jr nz,.done
|
||||
.oki: inc hl
|
||||
jr .ok2
|
||||
.done: pop bc ; discard saved hl
|
||||
scf
|
||||
ret
|
||||
|
||||
;-------------------------------------------------
|
||||
; ASCII decimal -> A (0..255, saturating)
|
||||
; in: de -> digits
|
||||
;-------------------------------------------------
|
||||
IF_ATOI8:
|
||||
ld hl,0
|
||||
.l: ld a,(de)
|
||||
sub "0"
|
||||
jr c,.end
|
||||
cp 10
|
||||
jr nc,.end
|
||||
ld c,a ; c = digit
|
||||
ld b,0
|
||||
push de
|
||||
ld d,h
|
||||
ld e,l
|
||||
add hl,hl ; *2
|
||||
add hl,hl ; *4
|
||||
add hl,de ; *5
|
||||
add hl,hl ; *10
|
||||
add hl,bc ; + digit
|
||||
pop de
|
||||
inc de
|
||||
jr .l
|
||||
.end: ld a,h
|
||||
or a
|
||||
jr nz,.sat
|
||||
ld a,l
|
||||
ret
|
||||
.sat: ld a,255
|
||||
ret
|
||||
|
||||
;-------------------------------------------------
|
||||
; Run the conditional command.
|
||||
; in: hl -> command text (NUL-term at line end)
|
||||
;-------------------------------------------------
|
||||
IF_RUN:
|
||||
call IF_SKIPB
|
||||
ld a,(hl)
|
||||
or a
|
||||
ret z ; empty -> no-op
|
||||
ld d,h
|
||||
ld e,l ; de = command start
|
||||
ld bc,0 ; b=0, c = token length
|
||||
.tl: ld a,(hl)
|
||||
cp " "+1 ; <=' ' -> end of command token
|
||||
jr c,.tle
|
||||
inc hl
|
||||
inc c
|
||||
jr .tl
|
||||
.tle: ld hl,BATLIST ; bat + dos commands
|
||||
jp COMP.start ; dispatch (recurses for nested IF)
|
||||
+25
-11
@@ -57,6 +57,7 @@ input_line:
|
||||
ld (cursor_position),de ; Y/X ¯®§¨æ¨ï ªãàá®à
|
||||
call clear_inpline ; ®ç¨áâ¨âì áâàãªâãàã ~input line~
|
||||
call print_compath ; ¢ë¢¥á⨠¯ãâì + ®¢ ï è¨à¨ ¯®«ï ¢¢®¤
|
||||
call print_inpline
|
||||
jp event_input_line ; ®¡à ¡. áâப¨ ¢¢®¤
|
||||
|
||||
|
||||
@@ -98,6 +99,7 @@ print_compath:
|
||||
ld a,">"
|
||||
ld bc,1*256 + BIOS.LP_PRINT_SYM ; ᨬ¢®« ¡¥§ âਡãâ
|
||||
RST ToBIOS
|
||||
RET
|
||||
;jr print_inpline ; ¢ë¢®¤ áâப¨ ¢¢®¤
|
||||
;-------------------------------------------------
|
||||
; ‚뢮¤ áâப¨ ~input line~ íªà
|
||||
@@ -156,7 +158,7 @@ print_inpline:
|
||||
ld e,(iy + Input_Line.Cur_X) ;+2 ⥪. ¯®«®¦. ªãàá®à ¢ áâப¥
|
||||
add a,e
|
||||
cp width_inpline.MAX ; è¨à¨ íªà
|
||||
jr c,prne1__
|
||||
jr c,.prne1
|
||||
ld b,width_inpline.MAX-1
|
||||
sub b
|
||||
ld d,a ; " ¥§¤" § ¯à ¢ë© ªà ©
|
||||
@@ -164,7 +166,7 @@ print_inpline:
|
||||
sub d
|
||||
ld (iy + Input_Line.Cur_X),a ;+2 ®¢®¥ ¯®«®¦. ªãàá®à
|
||||
ld a,b
|
||||
prne1__:ld (cursor_position),a ; X ¯®«®¦. ªãàá®à íªà ¥
|
||||
.prne1: ld (cursor_position),a ; X ¯®«®¦. ªãàá®à íªà ¥
|
||||
ret
|
||||
|
||||
; ¢å®¤: HL - ¯®«ë© ¯ãâì
|
||||
@@ -367,7 +369,7 @@ inpline_work:
|
||||
add a,(iy + Input_Line.Left_Shift)
|
||||
cp (iy + Input_Line.max_Len)
|
||||
;ret nc
|
||||
JR NC,LastChar_BEEP
|
||||
JR NC,NoMoreChars_BEEP
|
||||
bit 7,(iy + Input_Line.ReadyString)
|
||||
;ret nz
|
||||
JR NZ,NoMoreChars_BEEP
|
||||
@@ -424,22 +426,34 @@ no_insert:
|
||||
pop de ; ¢®ááâ. ¡ « á á⥪
|
||||
input_line_done:
|
||||
ret
|
||||
LastChar_BEEP:
|
||||
;!TODO ¥á«¨ ᨬ¢®«ë ¯à¨¢ëᨫ¨ ¬ ªá¨¬ «ì®¥ ç¨á«®, â® íªà ¥
|
||||
; ¢ áâப¥ ®áâ ñâáï íå® ¦ ⮩ ª« ¢¨è¨, ª®â®à ï ¥ ¢«¥§«
|
||||
; ¨ ¢¨á¨â ¤® ¦ â¨ï ®ç¥à¥¤®© ª« ¢¨è¨. ˆá¯à ¢¨âì.
|
||||
LD A,7 ;ASCII BELL
|
||||
LD C,Dss.PutChar
|
||||
JP ToDSS
|
||||
; LastChar_BEEP:
|
||||
; ; ¥á«¨ ᨬ¢®«ë ¯à¨¢ëᨫ¨ ¬ ªá¨¬ «ì®¥ ç¨á«®, â® íªà ¥
|
||||
; ; ¢ áâப¥ ®áâ ñâáï íå® ¦ ⮩ ª« ¢¨è¨, ª®â®à ï ¥ ¢«¥§«
|
||||
; ; ¨ ¢¨á¨â ¤® ¦ â¨ï ®ç¥à¥¤®© ª« ¢¨è¨. ˆá¯à ¢¨âì.
|
||||
; LD A,7 ;ASCII BELL
|
||||
; LD C,Dss.PutChar
|
||||
; JP ToDSS
|
||||
|
||||
;!FIXIT SCROLL ᤥ« âì 㦥 äãªæ¨¨ ¤®á ¤«ï ¯¥ç ⨠¢ ª®á®«ì ¡¥§ áªà®««
|
||||
NoMoreChars_BEEP:
|
||||
;!TODO ¥á«¨ ᨬ¢®«ë ¯à¨¢ëᨫ¨ ¬ ªá¨¬ «ì®¥ ç¨á«®, â® íªà ¥
|
||||
; ¢ áâப¥ ®áâ ñâáï íå® ¦ ⮩ ª« ¢¨è¨, ª®â®à ï ¥ ¢«¥§«
|
||||
; ¨ ¢¨á¨â ¤® ¦ â¨ï ®ç¥à¥¤®© ª« ¢¨è¨. ˆá¯à ¢¨âì.
|
||||
LD A,7 ;ASCII BELL
|
||||
LD DE,(cursor_position)
|
||||
LD C,Dss.Locate
|
||||
RST ToDSS
|
||||
PUSH DE
|
||||
LD C,Dss.RdChar
|
||||
RST ToDSS ; A - ᨬ¢®«, B - âਡãâ
|
||||
POP DE
|
||||
LD A,' ' ; ᨬ¢®«
|
||||
LD C,Dss.WrChar ; #58
|
||||
RST ToDSS
|
||||
LD A,7 ;ASCII BELL
|
||||
LD C,Dss.PutChar
|
||||
JP ToDSS
|
||||
|
||||
|
||||
; ‘®¡ë⨥ - ªãàá. ª« ¢¨è¨ ¨«¨ ª®¬¡¨ 樨
|
||||
EvComComb:
|
||||
ld b,(hl) ;+1 what
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ SAVEHL: dw 0
|
||||
;-------------------------------------------------------------
|
||||
COMP: call EVALCMD ; (batch.asm)
|
||||
RET C
|
||||
ld hl,Buffers.input_line.Path
|
||||
dec hl
|
||||
ld hl,Buffers.input_line.Path - 1
|
||||
;dec hl
|
||||
ld c,(hl) ; ¤«¨ áâப¨
|
||||
ld b,0
|
||||
inc hl ; Buffers.input_line.Path
|
||||
|
||||
@@ -25,6 +25,9 @@ MAIN_MSG:
|
||||
.INFO_2 EQU .INFO_2_
|
||||
.DIRPAUSE EQU .DIRPAUSE_
|
||||
.CLSLINE EQU .CLSLINE_
|
||||
.LABEL_NOT_FOUND EQU .LBLNF_
|
||||
.RET_NO_GOSUB EQU .RNGSB_
|
||||
.GOSUB_DEEP EQU .GSBDP_
|
||||
;
|
||||
!txtCounter DEFL 0
|
||||
; ; ¥ ᤢ¨£ âì____
|
||||
@@ -55,6 +58,9 @@ MAIN_MSG:
|
||||
stN .INFO_2_ : DZ " %9 \r\t %8\r\t\t\t %7\r\t\t\t\t\t %4\r\t\t\t\t\t\t\t %5\r\n"
|
||||
stN .DIRPAUSE_ : DZ "Press ESC to cancel or any other key to continue . . .\r"
|
||||
stN .CLSLINE_ : DZ " \r"
|
||||
stN .LBLNF_ : DZ "Label not found\r\n"
|
||||
stN .RNGSB_ : DZ "RETURN without GOSUB\r\n"
|
||||
stN .GSBDP_ : DZ "GOSUB nesting too deep\r\n"
|
||||
; ;R11
|
||||
db 0
|
||||
DZ "Unknown command"
|
||||
|
||||
+8
-14
@@ -1,17 +1,3 @@
|
||||
; �®á«¥¤ïï । ªæ¨ï: 22.10.2006
|
||||
;
|
||||
|
||||
|
||||
; - ˆá¯à ¢«¥ ä¨à¬. ¡ £, ¯à¨ ª®â®à®¬ áâப ¢ bat-ä ©«¥, ¤«¨¥¥ è¨à¨ë
|
||||
; íªà , ®¡à¥§ « áì ¯® è¨à¨¥ íªà ¨ ®áâ ⮪ áâப¨ ¥ ¢ë¢®¤¨«áï.
|
||||
; - ˆá¯à ¢«¥ ä¨à¬. ¡ £, ¯à¨ ª®â®à®¬ ¢ ª®¬ ¤¥ "dir" áâப ¢ë¢®¤¨¬®£®
|
||||
; ¯ã⨠¨¬¥« ¬ ªá. 15 ᨬ¢®«®¢.
|
||||
; - �®ä¨ªá¥® ¥¢¥à®¥ ¨§¬¥¥¨¥ ¤¨áª /¯ã⨠¯®á«¥ ®è¨¡®ª ¢ë¯®«¥¨ï ª®¬ ¤.
|
||||
; - „®¡ ¢«¥ ª®¬ ¤ "ECHO." ¤«ï ¢áâ ¢ª¨ ¯ãá⮩ áâப¨.
|
||||
; - Š®¬ ¤ DIR ¢ë¢®¤¨â ¬¥âªã ¨ á¥à¨©ë© ®¬¥à ¤¨áª®¢.
|
||||
;
|
||||
;
|
||||
|
||||
; SYSTEM.EXE /S /P
|
||||
;
|
||||
; /P Primary command processor
|
||||
@@ -535,6 +521,8 @@ T8C24: db "OFF",0
|
||||
;
|
||||
include 'Commands/exit.asm' ; ¢ë室 ¢ த¨â. ¯à®æ¥áá
|
||||
include 'Commands/break.asm' ; ¢ë室 ¨§ ¯ àá¥à bat
|
||||
include 'Commands/goto.asm' ; GOTO - jump to a label in a bat
|
||||
include 'Commands/if.asm' ; IF - conditional command
|
||||
include 'Commands/pause.asm' ; ¯ ã§
|
||||
include 'Commands/rem.asm' ; ª®¬¬¥â ਩
|
||||
include 'Commands/ver.asm' ; ¢ë¢®¤ ¢¥àᨨ „Ž‘
|
||||
@@ -553,6 +541,12 @@ T8C24: db "OFF",0
|
||||
include 'Commands/set.asm' ; § ¤ âì ¯¥à¥¬¥ãî ®ªà㦥¨ï
|
||||
include 'Commands/reboot.asm' ; á®äâ à¥á¥â
|
||||
;
|
||||
DISPLAY "bat_params: ",/H,Buffers.bat_params, ". Size: ",/H, BAT_PARAMS, " End: ",/H, Buffers.bat_params + BAT_PARAMS - 1
|
||||
DISPLAY "screen_path: ",/H,Buffers.screen_path, ". Size: ",/H, 2 + max_screen_path + 1, " End: ",/H, Buffers.screen_path + (2 + max_screen_path + 1) - 1
|
||||
DISPLAY "sys_path: ",/H,Buffers.sys_path, ". Size: ",/H, 256, " End: ",/H, Buffers.sys_path + 255
|
||||
DISPLAY "input_line: ",/H,Buffers.input_line, ". Size: ",/H, Input_Line, " End: ",/H, Buffers.input_line + Input_Line - 1
|
||||
DISPLAY "history: ",/H,Buffers.history, ". Size: ",/H, history_size, " End: ",/H, Buffers.history + history_size - 1
|
||||
DISPLAY "work: ",/H,Buffers.work, ". Size: ",/H, Work, " End: ",/H, Buffers.work + Work - 1
|
||||
DISPLAY "Empty space for buffers from ",/H,$
|
||||
DISPLAY "Free space from ",/H,$ + Struc_Buffers
|
||||
assert ($ + Struc_Buffers) < (stack_point - stack_size), "Buffers can leack to stack!"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
STRUCT Input_Line
|
||||
.max_Len BYTE 254 ;+0 254 ¬ ªá. ç¨á«® ¢¢®¤. ᨬ¢®«®¢
|
||||
.max_Len BYTE max_len_comline ;+0 254 ¬ ªá. ç¨á«® ¢¢®¤. ᨬ¢®«®¢
|
||||
.ReadyString BYTE 0 ;+1 ä« £ ReadyString
|
||||
.Cur_X BYTE 0 ;+2 X ⥪. ¯®«®¦. ªãàá®à ¢ ¯à¥¤¥« å áâப¨
|
||||
.Left_Shift BYTE 0 ;+3 X ᬥé. áâப¨ § «¥¢ë© ªà © (¢ ᨬ¢®« å)
|
||||
|
||||
Reference in new issue
Block a user