title FBREAK subttl RSX allowing BREAK from BDOS call .z80 ; Program : FBREAK.MAC ; RSX module for breaking program calling BDOS and ; telling file currently accessed ; Program by (C) Werner Cirsovius ; Hohe Weide 44 ; D-2000 Hamburg 20 ; Tel.:049/040/4223247 ; Version 1.0, October 1988 ; Append to any .COM file by GENCOM utility ; ===== Constants ===== warm equ 0000h conin equ 1 conout equ 2 condir equ 6 print equ 9 consta equ 11 ctrlC equ 'C'-'@' lf equ 0ah cr equ 0dh eot equ '$' ; ===== RSX starts here ===== ; ===== RSX header starts ===== db 0,0,0,0,0,0 ; Six byte serial number jp start ; Jump to RSX program bdos: jp $-$ ; Jump to next RSX dw 0 ; Address of previous RSX db 0ffh ; Remove flag (0 keep permanent) db 0 ; Non bank only flag db 'BREAK ' ; Any eight character name db 0 ; Loader flag dw 0 ; Spare (reserved) ; ===== RSX header ends ===== start: ex (sp),hl ; Get caller ld (calpc),hl ex (sp),hl ld (calsp),sp ; Save stack ld sp,mystak ; Get local stack push af ; Push all push de push hl push bc ld (fcb),de call break ; Test abort pop bc pop hl pop de pop af ld sp,(calsp) jr bdos ; Perform user call ; break: ; Test user BREAK requested, abort if verified ; ld c,consta call bdos ; Get state of console or a ; Any character there ? ret z ; .. no ld c,condir ld e,0ffh call bdos ; Get it cp ctrlC ; Test Ctrl-C ret nz ; .. no ld de,brkmes call string ; Tell user break found ld c,conin call bdos ; Verify it push af ld de,crlf call string pop af and 05fh cp 'Y' ret nz ld de,dobrk call string ; Tell aborting ld a,(calpc+1) call hexout ld a,(calpc) call hexout ld de,bdosfn call string ; Tell function pop bc ; Fix stack pop bc ; Get BDOS function push bc ld a,c call hexout pop bc call tstfil ; Tell file function ld de,crlf call string jp warm ; Exit program ; hexout: ; Print hex byte from accu ; push af rra ; Get hi part rra rra rra call hxnibl pop psw ; .. and lo part hxnibl: and 0fh ; Extract lo add a,'0' ; Set ASCII cp '9'+1 ; Test hex jr c,consot add a,7 consot: push bc push de push hl ld e,a ld c,conout call bdos ; Print character pop hl pop de pop bc ret ; string: ; Output string pointed to by reg DE ; push bc push hl ld c,print call bdos ; Print it pop hl pop bc ret ; tstfil: ; Test file accessed ; ld a,c ; Get BDOS code ld hl,bdost1 ld bc,bdosl1 cpir ; Find code ret nz ld de,filmes call string ld de,(fcb) ; Get FCB ld hl,' ' ; Set default ld a,(de) ; Test default drive or a jr z,deffcb ; Yes, skip add a,'@' ; Make real ld h,a ld l,':' deffcb: ld a,h call consot ; Print drive ld a,l call consot ; .. and delimiter inc de ld b,8 call filnam ; Print file name ld a,'.' call consot ; Print delimiter ld b,3 call filnam ret ; filnam: ; Print portion from FCB ; ld a,(de) and 07fh call consot ; Print name/extension inc de djnz filnam ret ; ===== Data fields ===== bdost1: db 15,16,17,19,20,21,22,23,30,33 db 34,35,36,40,99,100,102 bdosl1 equ $-bdost1 brkmes: db 'Control C detected, BREAK [Y/N] ',eot dobrk: db '++ User Break, ABORT ++ at #',eot bdosfn: db ', BDOS function : #',eot crlf: db cr,lf,eot filmes: db cr,lf,'Current file : ',eot fcb: ds 2 calpc: ds 2 calsp: ds 2 ds 64 ; Local stack mystak: end