home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
GTR03.ARC
/
GTR+RSX.Z80
< prev
next >
Wrap
Text File
|
1991-01-13
|
9KB
|
281 lines
; Graphics Terminal Remapper. v 0.3 For ZPM3 and CP/M 3
; This is an RSX to allow remapping of hi-bit-set characters to other
; characters before sending them to the screen. It may be used to tranlate
; any single character to any other single character, but was devised
; particularly for reading IBM type graphics on an ordinary terminal.
; This program was inspired by CORK10 by Steven Greenberg, but is only
; for CP/M 3 and ZPM3. It is also somewhat more simple due to the
; improvements in CP/M 3 and ZPM3.
; This code will assemble to two different RSXs depending on the TYPE
; equate below:
; Type 0 is used is a standalone program. Using GENCOM, a dummy .COM file
; is made which contains the RSX. When first called, it installs the
; RSX. When called again it removes it.
; Type 1 can be used as an RSX which is attached to another program (such
; as ZMP) so that it is automatically installed and removed with the host
; program.
; Note that many communications programs strip the high bit before sending
; characters to the console. Such programs can NOT use GTR+ successfully.
; Simeon Cran. September 7 1990. Brisbane Australia
; Version Updates
; v0.3
; Added support to remap characters to suit a terminals own block graphics
; Bruce Dudley January 7 1991. Perth Western Australia
;---------------------------------------------------------------------------
esc equ 27
TYPE EQU 0 ; 0 = Use as a stand alone COM file
; 1 = To be attatched to your OWN com file as an RSX
;-------------------------------------------------------------------------
dseg ; DR's LINK.COM will put the data segment at the
; end of the code... Just as well!
select macro name
include name
endm
; If you are going to use the terminals graphic mode then select your terminal
; from the following list. If your terminal is not listed then you
; must enter the ESC sequence to turn on/off graphic mode. Also
; you will need to make a look up table to suit your terminal.
; Just comment out the relevent name (select) to suit your terminal..
; If your terminal is not listed them edit one of the INC files to suit
; your terminals facilities and include it in the following format..
select NOGRAPH.INC ; No terminal graphic facilities
;select AMSTRAD.INC ; Amstrad CPC6128 CP/M 3 computer
;select FREEDOM.INC ; Freedom 200 terminal
;=============================================================================
cseg ; This is the real beginning of the code
; RSX header.
ds 6 ; Room for serial number
entry: jp ftest ;6 Entry jump
next: jp 0 ;9
dw 0 ;c Room for previous pointer
remove: db 0ffh ;e Remove flag (changed by RSX)
db 0 ;f Non-resident flag
name: db 'GTR+0.3 ' ;10 Name
db 0 ;18 Loader flag
dw 0 ;19 Reserved area
;-----------------------------------------------------------------------------
;1a
if not type ; For standalone program
; Remove the RSX
ld a,0ffh
ld (remove),a ; Set to remove on next warm boot
call rem$jmp ; Restore the jump vector
ld de,remMSG ; Inform the user that it has been removed
ld c,9
call next
ret
ftest:
; On first call to BDOS, check to see if an identical RSX has already been
; installed. If it has, remove it and this RSX. If it hasn't, install
; the new jump vector, and fix to make future BDOS calls ignore the RSX.
push bc
push de ; Save entry parameters
ld hl,next
ld (entry+1),hl ; Make sure this RSX is ignored from now on
RSXlook:
ld l,0bh ; Point to the next address
ld h,(hl) ; Get it in HL
ld l,18h ; Point to the loader flag
ld a,(hl) ; Get it
or a
jr nz,loadFND ; If we found the loader, then there is
; no identical RSX in place.
ld l,10h ; Point to the name
ld bc,8 ; Length of name
ld de,name-1 ; Point to our name
RSXl1: inc de ; Point to next character
ld a,(de) ; Get a character
cpi
jr nz,RSXlook ; If it didn't match, check the next one
jp pe,RSXl1 ; If it matched so far, keep checking
ld l,1ah ; Point to the remove code of the identical
; RSX.
call ipchl ; Call its remove code
pop de
pop bc ; Restore entry parameters
jr next ; And done.
ipchl: jp (hl)
loadFND: ; Here, we have found the loader which means there are no
; other identical RSXs. Install this one and continue.
xor a
ld (remove),a ; Clear the remove flag so that it stays
; resident.
call ins$jmp ; Install the new jump
ld de,insMSG
ld c,9 ; Print the message
call next
pop de ; Restore the entry paramaters
pop bc
jr next ; All done.
insMSG: db ' Graphics remapper INSTALLED$'
remMSG: db ' Graphics remapper REMOVED$'
;-----------------------------------------------------------------------------
else ; If attached RSX
ftest:
; On first call to BDOS, install the new jump vector, and fix to make future
; BDOS calls ignore the RSX
push bc
push de ; Save entry parameters
ld hl,next
ld (entry+1),hl ; Make sure this RSX is ignored from now on
call ins$jmp ; Install the new jump vectors in the BIOS and modify
; the SCB traps
pop de
pop bc ; Restore entry parameters
jr next ; And continue
oldboot:
dw 0 ; Stores the old boot vector
endif
;-----------------------------------------------------------------------------
ins$jmp: ; Install the new jump vector(s)
ld hl,(1) ; Get the BIOS vector pointer
ld l,13 ; Point to the conout vector
ld de,newjmp ; Get the new jump
ld c,(hl) ; Get the old jump. Low byte
ld (hl),e ; Put new in
inc hl
ld b,(hl) ; Same for high byte
ld (hl),d
ld (conout+1),bc ; Save the old jump
dec h ; Point to the SCB
ld l,0fah
ld a,(hl) ; Get common memory base page
dec a ; minus 1
cp d ; Compare it with this page
jr c,ins$j1 ; Don't modify trap if this RSX is in common
ld l,7ah
ld (hl),21h ; Convert the trap
ins$j1:
if type ; If attached RSX
ld de,rem$jmp ; Get the new jump
cp d ; Compare it with this page
jr c,ins$j2 ; Don't modify trap if this RSX is in common
ld l,68h
ld (hl),21h ; Convert the warm boot trap
ins$j2:
inc h ; Point back to bios
ld l,4 ; Point to the warm boot code
ld c,(hl) ; Get the old jump. Low byte
ld (hl),e ; Put new in
inc hl
ld b,(hl) ; Same for high byte
ld (hl),d
ld (oldboot),bc ; Save the old jump
endif
ret
rem$jmp: ; Restore the modified jumps.
ld hl,(1) ; Get the BIOS pointer
ld de,(conout+1) ; Get the old jump
ld l,13 ; Point to the jump
ld (hl),e
inc hl
ld (hl),d ; Change it back
dec h ; Point to the SCB
ld l,0fah ; Get common memory base address
ld a,(hl)
dec a ; Minus 1
cp d ; Compare it with the replacment jump
jr c,rem$j1
ld l,7ah
ld (hl),0c3h ; Restore the SCB trap
rem$j1:
if type ; If the attached RSX. Remove the warm boot
; trap.
ld de,(oldboot) ; Get the old boot
cp d
jr c,rem$j2
ld l,68h
ld (hl),0c3h ; Restore the SCB trap
rem$j2: inc h
ld l,4
ld (hl),e
inc hl
ld (hl),d ; Restore the old boot vector
jp 0 ; And continue warm boot
endif
ret
;==============================================================================
; This is the actual translation code. All calls to CONOUT in the BIOS land
; here. Character in C.
newjmp: bit 7,c ; Test the high bit
jr nz,graphic ; Must be a graphic character! Go process it.
; Test to be sure that graphics mode of the terminal gets turned
; off for the next ASCII character..
ld a,(flag)
or a
jr nz,conout ; Graphic mode not set so just send the char
ld a,c
ld (flag),a ; Save the char plus use it as a flag
ld hl,graoff ; String to turn off graphic mode
call seterm ; Do it!
ld a,(flag) ; retrive character
ld c,a
jr conout ; Send it
seterm: ld a,(hl) ; Get the first character of esc sequence
or a ; Test fot zero
ret z
ld c,a
push hl
call conout ; Send character for esc sequence
pop hl
inc hl ; Point to the next character
jr seterm ; Go do it all again
; Here we do the actual translation.
graphic:xor a
ld (flag),a ; Set flag to indicate graphic mode enabled
ld hl,graon ; Turn graphic mode on
push bc
call seterm
pop bc
ld a,c
ld hl,table-80h ; Point to the table
add l
ld l,a ; Add HL and A to HL
ld a,h
adc 0
ld h,a
ld a,(hl) ; Get the entry
or a ; See if there was in fact an entry
jr z,conout ; If no entry, then just output the character
; with the high bit cleared.
ld c,a ; Put it in C to output
conout: jp 0 ; This is modified
flag: db -1 ; If 'flag' is zero then grahpic mode is on
; and if it's not zero then graphic mode
; not enabled