From: Robert Pengelly Date: Sat, 21 Sep 2024 18:20:52 +0000 (+0100) Subject: More Ctrl+C improvements X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=4da68909513bfa5ad968bc04fad11aff2b902371;p=chimaera.git More Ctrl+C improvements --- diff --git a/build/chimaera.img b/build/chimaera.img index 2adf2a5..b454e69 100644 Binary files a/build/chimaera.img and b/build/chimaera.img differ diff --git a/build/chimaera.vhd b/build/chimaera.vhd index 64344d5..3e022c8 100644 Binary files a/build/chimaera.vhd and b/build/chimaera.vhd differ diff --git a/src/apps/pcomm/cbreak.asm b/src/apps/pcomm/cbreak.asm index c0e901c..cf6bd5d 100644 --- a/src/apps/pcomm/cbreak.asm +++ b/src/apps/pcomm/cbreak.asm @@ -13,6 +13,55 @@ _cbreak_handler: mov word ptr cs:[_cbreak], 1 + cmp ah, HEX (08) + jne _cbreak_handler.done + + push ax + push si + push dx + + mov ax, cs:[_curr_scratch] + + and ax, ax + jz .L1 + + push ax + + call _free + add sp, 2 + + xor ax, ax + mov cs:[_curr_scratch], ax + +.L1: + + mov word ptr cs:[_need_ext], 0 + mov word ptr cs:[_cbreak], 0 + + mov cl, cs:[_scratch_size] + xor ch, ch + + mov ax, cs:[_vec_history + 4] + mov cs:[_history_idx], ax + + mov di, offset _scratch + xor al, al + + push di + push cx + rep stosb + + mov cs:[_scratch_len], al + pop cx + pop di + + call _prompt + pop dx + pop si + pop ax + +_cbreak_handler.done: + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Clear the carry flag and return. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/src/apps/pcomm/pcomm.asm b/src/apps/pcomm/pcomm.asm index c24c1a1..e14ce4d 100644 --- a/src/apps/pcomm/pcomm.asm +++ b/src/apps/pcomm/pcomm.asm @@ -77,21 +77,9 @@ _main: .L11: - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; Clear the carry flag. - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - clc - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; Try to get a key press. - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov ah, HEX (08) int HEX (21) - jc .L5 - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; If AL is zero then we have an extended key press. - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; and al, al jnz .L10 @@ -1905,6 +1893,7 @@ _handler_reboot: ;****************************************************************************** ; @function _prompt ;****************************************************************************** +global _prompt _prompt: push ax @@ -1977,7 +1966,10 @@ _prompt: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int21/ah=0A variables. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +global _scratch_size _scratch_size: db 255 + +global _scratch_len _scratch_len: db 0 global _scratch @@ -2001,11 +1993,12 @@ _err_invalid: db "Bad command or file name - ", HEX _fn_wild: db "*.*", HEX (00) _temp: db 257 dup (0) -_need_ext: dw HEX (0000) _dta_addr: dw HEX (0000) - _insert: dw HEX (0000) +global _need_ext +_need_ext: dw HEX (0000) + global _vec_history _vec_history: db 6 dup (0) diff --git a/src/apps/pcomm/type.asm b/src/apps/pcomm/type.asm index c6bf67d..2abcbec 100644 --- a/src/apps/pcomm/type.asm +++ b/src/apps/pcomm/type.asm @@ -461,6 +461,9 @@ _read_file.file_open: _read_file.clear_and_read: + cmp word ptr cs:[_cbreak], 1 + je _read_file.close + mov ah, HEX (3F) mov cx, 255 mov dx, offset _buffer @@ -470,14 +473,14 @@ _read_file.clear_and_read: and ax, ax jz _read_file.close + cmp word ptr cs:[_cbreak], 1 + je _read_file.close + mov si, dx mov cx, ax _read_file.print_loop: - cmp word ptr cs:[_cbreak], 1 - je _read_file.close - lodsb cmp al, HEX (0A) diff --git a/src/kernel/int21.asm b/src/kernel/int21.asm index f73c893..4a9903d 100644 --- a/src/kernel/int21.asm +++ b/src/kernel/int21.asm @@ -597,6 +597,35 @@ _probe_disk.done: pop ax ret +;****************************************************************************** +; @function _check_for_break +;****************************************************************************** +_check_for_break: + + push ax + + mov ah, HEX (01) + int HEX (16) + jz _check_for_break.no_break + + xor ah, ah + int HEX (16) + + cmp ax, HEX (2E03) + jne _check_for_break.no_break + + stc + jmp _check_for_break.done + +_check_for_break.no_break: + + clc + +_check_for_break.done: + + pop ax + ret + ;****************************************************************************** ; @function _int21_dispatch ;****************************************************************************** @@ -609,32 +638,42 @@ _int21_dispatch: mov cs:[_user_ax], ax mov cs:[_user_bp], bp - cmp ah, HEX (01) - jb _int21_dispatch.no_key + cmp ah, HEX (08) + je _int21_dispatch.no_check + +_int21_dispatch.check: + + cmp word ptr cs:[_cbreak], 1 + jne _int21_dispatch.check_key - cmp ah, HEX (05) - jbe _int21_dispatch.check + mov al, '^' + call _writechr - cmp ah, HEX (08) - jb _int21_dispatch.no_key + mov al, 'C' + call _writechr + + mov al, HEX (0D) + call _writechr + + mov al, HEX (0A) + call _writechr + + mov word ptr cs:[_cbreak], 0 - cmp ah, HEX (0B) - ja _int21_dispatch.no_key + mov ax, cs:[_user_ax] + iret -_int21_dispatch.check: +_int21_dispatch.no_check: - push ax - mov ah, HEX (01) - int HEX (16) - pop ax - jz _int21_dispatch.no_key + mov word ptr cs:[_cbreak], 0 + +_int21_dispatch.check_key: + + call _check_for_break + jnc _int21_dispatch.no_key - push ax - xor ah, ah - int HEX (16) - cmp ax, HEX (2E03) - pop ax - jne _int21_dispatch.no_key + cmp ah, HEX (08) + jne _int21_dispatch.spawn mov al, '^' call _writechr @@ -642,6 +681,14 @@ _int21_dispatch.check: mov al, 'C' call _writechr + mov al, HEX (0D) + call _writechr + + mov al, HEX (0A) + call _writechr + +_int21_dispatch.spawn: + jmp _spawn_int23 _int21_dispatch.no_key: @@ -1002,18 +1049,6 @@ _int21_01.wait: cmp ax, HEX (2E03) jne _int21_01.char_ok - mov al, '^' - call _writechr - - mov al, 'C' - call _writechr - - mov al, HEX (0D) - call _writechr - - mov al, HEX (0A) - call _writechr - jmp _spawn_int23 _int21_01.char_ok: @@ -1086,25 +1121,13 @@ _int21_02: push ax - call _check_handle_break - jnc _int21_02.write - - mov al, '^' - call _writechr - - mov al, 'C' - call _writechr - - mov al, HEX (0D) - call _writechr - - mov al, HEX (0A) - call _writechr + call _check_for_break + jnc _int21_02.print pop ax jmp _spawn_int23 -_int21_02.write: +_int21_02.print: mov al, dl call _writechr @@ -1210,27 +1233,6 @@ _int21_09: _int21_09.loop: - call _check_handle_break - jnc _int21_09.print - - mov al, '^' - call _writechr - - mov al, 'C' - call _writechr - - mov al, HEX (0D) - call _writechr - - mov al, HEX (0A) - call _writechr - - pop si - pop ax - jmp _spawn_int23 - -_int21_09.print: - lodsb cmp al, '$' @@ -1319,18 +1321,6 @@ _int21_0A.get_chars: mov di, dx mov byte ptr [di + 1], 0 - mov al, '^' - call _writechr - - mov al, 'C' - call _writechr - - mov al, HEX (0D) - call _writechr - - mov al, HEX (0A) - call _writechr - pop ds pop es pop di diff --git a/src/kernel/int23.asm b/src/kernel/int23.asm index 35b3fd0..3670df9 100644 --- a/src/kernel/int23.asm +++ b/src/kernel/int23.asm @@ -70,21 +70,18 @@ _regain_control_int23: _int23_ign_carry: + mov word ptr cs:[_cbreak], 1 + pop ax + pop bp jnc _int23_respawn xor ah, ah - pop bp - - jmp _int21_dispatch + mov word ptr cs:[_cbreak], 0 _int23_respawn: - mov bp, sp - or byte ptr [bp + 6], 1 ; set carry - - pop bp - iret + jmp _int21_dispatch ;****************************************************************************** ; @function _int23_handler @@ -125,6 +122,7 @@ _spawn_int23: mov word ptr [bp + 5], cs xchg word ptr [bp - 4], bp + clc retf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -141,3 +139,6 @@ _user_ax: dw HEX (0000) global _user_bp _user_bp: dw HEX (0000) + +global _cbreak +_cbreak: dw HEX (0000)