Browse Source

Update zmo-rw01.z80

pull/235/head
b1ackmai1er 4 years ago
parent
commit
a9aa50d128
  1. 202
      Source/Apps/ZMP/zmo-rw01.z80

202
Source/Apps/ZMP/zmo-rw01.z80

@ -7,23 +7,23 @@
; ROMWBW version using HBIOS and https://github.com/mecparts/zmp version of zmodem ; ROMWBW version using HBIOS and https://github.com/mecparts/zmp version of zmodem
; Databits, stop bit, parity setting not supported. ; Databits, stop bit, parity setting not supported.
; All modem/serial i/o is through the hbios. ; All modem/serial i/o is through the hbios.
; Timing delay calcuations based on hbios reported cpu speed.
; Only 1 port is supported by the necports version of zmp.
; Timing delay calculations based on hbios reported cpu speed.
; Only 1 port is supported by the mecports version of zmp.
; Port setting supports 2 port, port A is CIO 1, port B is CIO 2 ; Port setting supports 2 port, port A is CIO 1, port B is CIO 2
; This overlay is compatible with Ron Murray's original ZMP15 which support two ports. ; This overlay is compatible with Ron Murray's original ZMP15 which support two ports.
; Teraterm users may need to change the ZmodemWinSize value to 1024 in teraterm.ini file. ; Teraterm users may need to change the ZmodemWinSize value to 1024 in teraterm.ini file.
; ;
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
;
false equ 0 false equ 0
true equ not false true equ not false
;
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;
; User-set variables: ; User-set variables:
;
debug equ false ; to allow debugging of overlay with Z8E etc. debug equ false ; to allow debugging of overlay with Z8E etc.
;
;Set the following two equates to the drive and user area which will contain ;Set the following two equates to the drive and user area which will contain
; ZMP's .OVR files, .CFG file, .FON file and .HLP file. Set both to zero ; ZMP's .OVR files, .CFG file, .FON file and .HLP file. Set both to zero
; (null) to locate them on the drive from which ZMP was invoked. ; (null) to locate them on the drive from which ZMP was invoked.
@ -44,7 +44,7 @@ userdef equ 0145h ; origin of this overlay
; subsequent revisions. ; subsequent revisions.
mspeed equ 03ch ; location of current baud rate. mspeed equ 03ch ; location of current baud rate.
ovsize equ 0400h ; max size of this overlay ovsize equ 0400h ; max size of this overlay
;
.z80 ; use z80 code .z80 ; use z80 code
aseg ; absolute aseg ; absolute
@ -53,17 +53,16 @@ ovsize equ 0400h ; max size of this overlay
else else
org userdef org userdef
endif endif
;
esc equ 1bh esc equ 1bh
ctrlq equ 11h ctrlq equ 11h
cr equ 0dh cr equ 0dh
lf equ 0ah lf equ 0ah
bdos equ 5 bdos equ 5
fcb equ 05ch+1 ; Command line fcb equ 05ch+1 ; Command line
;
codebgn equ $ codebgn equ $
;
;Jump table for the overlay: do NOT change this ;Jump table for the overlay: do NOT change this
jump_tab: jump_tab:
jp scrnpr ; screen print jp scrnpr ; screen print
@ -94,7 +93,7 @@ jump_tab:
jp userout ; user-defined exit routine jp userout ; user-defined exit routine
jp getvars ; get system variables jp getvars ; get system variables
jp setport ; set port (0 or 1) jp setport ; set port (0 or 1)
;
; Spare jumps for compatibility with future versions ; Spare jumps for compatibility with future versions
jp spare ; spare for later use jp spare ; spare for later use
jp spare ; spare for later use jp spare ; spare for later use
@ -112,12 +111,10 @@ port: db 1 ; current cio port.
; Main code starts here ; Main code starts here
; ;
;Screen print function ;Screen print function
scrnpr:
call print
scrnpr: call print
db 'This function not supported.',cr,lf,0 db 'This function not supported.',cr,lf,0
spare:
ret
spare: ret
;
; User-defined entry routine: ; User-defined entry routine:
; ;
; forcing reinit will resend AT command to modem, reset ; forcing reinit will resend AT command to modem, reset
@ -126,31 +123,27 @@ spare:
; Get and set modem/serial ports to use from the command line ; Get and set modem/serial ports to use from the command line
; ;
; Get the cpu speed reported by romwbw hbios and calculate ; Get the cpu speed reported by romwbw hbios and calculate
; the three required loop counter values for timing.
; the three required loop counter values for timing:
; ;
; outerva (outv) ; outerva (outv)
; innerval (inv) ; innerval (inv)
; millisv (msv) ; millisv (msv)
userin:
ld a,-1 ; force re-init
;
userin: ld a,-1 ; force re-init
ld (mspeed),a ld (mspeed),a
;
ld a,(fcb) ; first character ld a,(fcb) ; first character
cp ' ' ; of parsed filename cp ' ' ; of parsed filename
jr z,defport1 ; is port 0
jr z,dport1 ; is port 0
sub '0' sub '0'
ld (hbport0),a ; set CIO for port 0 ld (hbport0),a ; set CIO for port 0
ld (port),a ; reconfigure default ld (port),a ; reconfigure default
defport0:
ld a,(fcb+1) ; second character
dport0: ld a,(fcb+1) ; second character
cp ' ' ; of parsed filename cp ' ' ; of parsed filename
jr z,defport1 ; is port 1
jr z,dport1 ; is port 1
sub '0' sub '0'
ld (hbport1),a ld (hbport1),a
defport1:
;
push bc
dport1: push bc
ld bc,0f8f0h ; get clock speed in l ld bc,0f8f0h ; get clock speed in l
rst 08 rst 08
; ;
@ -162,7 +155,7 @@ defport1:
call div_hl_c ; result in hl call div_hl_c ; result in hl
ld a,l ld a,l
inc a inc a
ld (outv),a
ld (outv),a ; save outerval
; ;
; innerval equ (6667 / outerval) * clkspd ; innerval equ (6667 / outerval) * clkspd
; ;
@ -174,16 +167,16 @@ defport1:
pop hl ; recall clock pop hl ; recall clock
ld a,l ; save ld a,l ; save
push af ; clock speed push af ; clock speed
;
call mult_a_de call mult_a_de
ld (inv),hl
ld (inv),hl ; save innerval
; ;
; ld de,39 * clkspd ; ld de,39 * clkspd
; ;
pop af ; recall clock speed pop af ; recall clock speed
ld de,39 ld de,39
call mult_a_de call mult_a_de
ld (msv),hl
ld (msv),hl ; save msec value
; ;
pop bc pop bc
ret ret
@ -203,8 +196,7 @@ mult_a_de: ; https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Mul
ld h,d ld h,d
ld l,e ld l,e
ld b,7 ld b,7
_loop2:
add hl,hl
_loop2: add hl,hl
rla rla
jr nc,$+4 jr nc,$+4
add hl,de add hl,de
@ -215,8 +207,7 @@ _loop2:
div_hl_c: ; https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Division div_hl_c: ; https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Division
xor a xor a
ld b,16 ld b,16
_loop1:
add hl,hl
_loop1: add hl,hl
rla rla
jr c,$+5 jr c,$+5
cp c cp c
@ -225,15 +216,13 @@ _loop1:
inc l inc l
djnz _loop1 ; result in hl djnz _loop1 ; result in hl
ret ret
;
; User-defined exit routine: leave empty if not needed ; User-defined exit routine: leave empty if not needed
userout:
call show
userout:call show
ret ret
; ;
;Get a character from the modem: return in HL ;Get a character from the modem: return in HL
mchin:
push bc
mchin: push bc
ld b,00h ld b,00h
ld hl,port ld hl,port
ld c,(hl) ld c,(hl)
@ -243,8 +232,7 @@ mchin:
ret ret
;Send a character to the modem ;Send a character to the modem
mchout:
ld hl,2 ; get the character
mchout: ld hl,2 ; get the character
add hl,sp add hl,sp
ld e,(hl) ld e,(hl)
ld b,01h ld b,01h
@ -254,8 +242,7 @@ mchout:
ret ; done ret ; done
;Test for output ready: return TRUE (1) in HL if ok ;Test for output ready: return TRUE (1) in HL if ok
mordy:
ld b,03h
mordy: ld b,03h
ld hl,port ld hl,port
ld c,(hl) ld c,(hl)
rst 08 rst 08
@ -268,8 +255,7 @@ modrdy1:ld l,a
ret ret
;Test for character at modem: return TRUE (1) in HL if so ;Test for character at modem: return TRUE (1) in HL if so
mirdy:
push bc
mirdy: push bc
ld b,02h ld b,02h
ld hl,port ld hl,port
ld c,(hl) ld c,(hl)
@ -282,23 +268,21 @@ mirdy:
mirdy1: ld l,a mirdy1: ld l,a
pop bc pop bc
ret ret
;
;Send a break to the modem: leave empty if your system can't do it ;Send a break to the modem: leave empty if your system can't do it
sndbrk:
ld hl,300 ; wait 300 mS
sndbrk: ld hl,300 ; wait 300 mS
call waithlms call waithlms
ret ret
; ;
;Test UART flags for error: return TRUE (1) in HL if error. ;Test UART flags for error: return TRUE (1) in HL if error.
mdmerr:
xor a ; set/clear Z
mdmerr: xor a ; set/clear Z
ld h,a ld h,a
ld l,a ld l,a
ret ret
; ;
;Turn DTR ON ;Turn DTR ON
dtron: dtron:
ret
; ret
; ;
;Turn DTR OFF ;Turn DTR OFF
dtroff: dtroff:
@ -306,8 +290,7 @@ dtroff:
; ;
;Initialise the uart ;Initialise the uart
; ;
init:
ld hl,2 ; get parameters
init: ld hl,2 ; get parameters
add hl,sp add hl,sp
ex de,hl ex de,hl
call getparm ; in HL call getparm ; in HL
@ -319,9 +302,6 @@ init:
call getparm call getparm
ld (stop),hl ; stop bits (BINARY 1 or 2) ld (stop),hl ; stop bits (BINARY 1 or 2)
; ;
call print
db cr,lf,cr,lf,'CIO Initialized ...',cr,lf,0
ld a,(port) ; get device type ld a,(port) ; get device type
ld c,a ld c,a
ld b,06h ld b,06h
@ -358,26 +338,21 @@ init:
jr nz,initerr jr nz,initerr
; ;
call print call print
db 'Device: ',0
call dispport
db 'Initializing device: ',0
call diport
; ;
ld a,(brate)
ld (mspeed),a ; don't forget to load mspeed with the
; current brate value if the new rate is
; valid. See table of values below.
ld a,(brate) ; load mspeed with the current brate value if
ld (mspeed),a ; the new rate is valid. See table of values below.
ret ret
initerr:
call print
db 'Initization failed, CIO device: ',0
call dispport
;
initerr:call print
db lf,lf,'Initization failed, device: ',0
call diport
call show ; show cursor, then ... call show ; show cursor, then ...
jp 0 ; bail out to avoid system hang! jp 0 ; bail out to avoid system hang!
dispport:
ld a,(port) ; Display port
dispport1:
add a,'0'
;
diport: ld a,(port) ; Display port
diport1:add a,'0'
call cout call cout
call print call print
db cr,lf,0 db cr,lf,0
@ -408,7 +383,6 @@ baudtbl:
db 9 ; 38400 10 db 9 ; 38400 10
db 24 ; 57600 11 db 24 ; 57600 11
db 10 ; 76800 12 db 10 ; 76800 12
; ;
; Set the port. ZMP supplies either 0 or 1 as a parameter. ; Set the port. ZMP supplies either 0 or 1 as a parameter.
; Note that ZMP calls this routine with both values ; Note that ZMP calls this routine with both values
@ -416,8 +390,7 @@ baudtbl:
; ;
; Only originl ZMP calls setport. Mecports does not support setting ports ; Only originl ZMP calls setport. Mecports does not support setting ports
; ;
setport:
ld hl,2 ; get port number
setport:ld hl,2 ; get port number
add hl,sp add hl,sp
ex de,hl ex de,hl
call getparm ; in HL (values are 0 and 1) call getparm ; in HL (values are 0 and 1)
@ -428,7 +401,6 @@ setport:
jr z,isport0 jr z,isport0
inc hl inc hl
isport0:ld c,(hl) ; get the associated CIO port isport0:ld c,(hl) ; get the associated CIO port
;
push hl push hl
ld b,06h ; test if a valid cio ld b,06h ; test if a valid cio
rst 08 rst 08
@ -439,14 +411,14 @@ isport0:ld c,(hl) ; get the associated CIO port
ld (port),a ; save the valid port ld (port),a ; save the valid port
call print call print
db 'Setting CIO device: ',0 db 'Setting CIO device: ',0
jp dispport
jp diport
; ;
seterr: push hl seterr: push hl
call print call print
db 'Unable to set CIO device: ',0 db 'Unable to set CIO device: ',0
pop hl pop hl
ld a,(hl) ; get port we wanted to set ld a,(hl) ; get port we wanted to set
jp dispport1
jp diport1
; ;
;**************************************************************************** ;****************************************************************************
;Video terminal sequences: these are for VT-100: Modify as you wish ;Video terminal sequences: these are for VT-100: Modify as you wish
@ -461,8 +433,7 @@ cursadd:
call getparm call getparm
inc hl inc hl
ld (col),hl ; column ld (col),hl ; column
; <== Insert your own code here
; using values in row and col
;
call print call print
db esc,'[',0 db esc,'[',0
ld a,(row) ; row first ld a,(row) ; row first
@ -473,9 +444,8 @@ cursadd:
call cursconv call cursconv
ld a,'H' ld a,'H'
call cout call cout
; <== end of your own code
ret ret
;
cursconv: cursconv:
ld b,a ld b,a
xor a xor a
@ -506,61 +476,60 @@ cls:
call print call print
db esc,"[H",esc,"[2J",0 db esc,"[H",esc,"[2J",0
ret ret
;
;Inverse video on: ;Inverse video on:
invon: invon:
call print call print
db esc,"[7m",0 db esc,"[7m",0
ret ret
;
;Inverse video off: ;Inverse video off:
invoff: invoff:
call print call print
db esc,"[m",0 db esc,"[m",0
ret ret
;
;Turn off cursor: ;Turn off cursor:
hide: hide:
call print call print
db esc,'[?25l',0 db esc,'[?25l',0
ret ret
;
;Turn on cursor: ;Turn on cursor:
show: show:
call print call print
db esc,'[?25h',0 db esc,'[?25h',0
ret ret
;
;Save cursor position: ;Save cursor position:
savecu: savecu:
call print call print
db esc,'[7',0 db esc,'[7',0
ret ret
;
;Restore cursor position: ;Restore cursor position:
rescu: rescu:
call print call print
db esc,'[8',0 db esc,'[8',0
ret ret
;
;**************************************************************************** ;****************************************************************************
;
;Service modem interrupt: ;Service modem interrupt:
mint: mint:
; ret ; my system doesn't need this
; ret ; unused
;
;Initialise interrupt vectors: ;Initialise interrupt vectors:
invec: invec:
; ret ; ditto ; ret ; ditto
;
;De-initialise interrupt vectors: ;De-initialise interrupt vectors:
dinvec: dinvec:
ret ; ditto ret ; ditto
;
;****************** End of user-defined code ******************************** ;****************** End of user-defined code ********************************
; Do not change anything below here. ; Do not change anything below here.
;
;Modem character test for 100 ms ;Modem character test for 100 ms
mrd: mrd:
push bc ; save bc push bc ; save bc
@ -577,9 +546,9 @@ mrd1: call mirdy ; char at modem?
xor a xor a
mrd2: pop bc mrd2: pop bc
ret ret
;
; Inline print routine: destroys A and HL ; Inline print routine: destroys A and HL
;
print: ex (sp),hl ; get address of string print: ex (sp),hl ; get address of string
ploop: ld a,(hl) ; get next ploop: ld a,(hl) ; get next
inc hl ; bump pointer inc hl ; bump pointer
@ -589,7 +558,6 @@ ploop: ld a,(hl) ; get next
jr ploop ; and loop jr ploop ; and loop
pdone: ex (sp),hl ; restore return address pdone: ex (sp),hl ; restore return address
ret ; and quit ret ; and quit
; ;
;Output a character in A to the console ;Output a character in A to the console
; ;
@ -609,15 +577,15 @@ cout: push bc ; save regs
;outerval equ (clkspd / 10) + 1 ;outerval equ (clkspd / 10) + 1
;innerval equ (6667 / outerval) * clkspd ;innerval equ (6667 / outerval) * clkspd
;
;Wait(seconds) - entry point from C ;Wait(seconds) - entry point from C
wait: ld hl,2 wait: ld hl,2
add hl,sp add hl,sp
ex de,hl ; get delay size ex de,hl ; get delay size
call getparm call getparm
; fall thru to.. ; fall thru to..
;Wait seconds in HL
waithls: - entry point for this overlay
;Wait seconds in HL - entry point for this overlay
waithls:
push bc ; save bc push bc ; save bc
push de ; de push de ; de
push ix ; and ix push ix ; and ix
@ -647,15 +615,15 @@ wait12: bit 0,(ix) ; time-wasters
pop de ; de pop de ; de
pop bc ; and bc pop bc ; and bc
ret ret
;
;Wait milliseconds - entry point from C ;Wait milliseconds - entry point from C
mswait: ld hl,2 mswait: ld hl,2
add hl,sp add hl,sp
ex de,hl ; get delay size ex de,hl ; get delay size
call getparm call getparm
; fall thru to.. ; fall thru to..
;Wait milliseconds in HL
waithlms: - entry point for this overlay
;Wait milliseconds in HL - entry point for this overlay
waithlms:
push de push de
w1ms0: ld de,(msv) ; was ld de,39 * clkspd w1ms0: ld de,(msv) ; was ld de,39 * clkspd
w1ms1: dec de w1ms1: dec de
@ -668,7 +636,7 @@ w1ms1: dec de
jr nz,w1ms0 jr nz,w1ms0
pop de pop de
ret ret
;
;Get next parameter from (de) into hl ;Get next parameter from (de) into hl
getparm: getparm:
ex de,hl ; get address into hl ex de,hl ; get address into hl
@ -678,20 +646,18 @@ getparm:
inc hl ; bump for next inc hl ; bump for next
ex de,hl ; result in hl, address still in de ex de,hl ; result in hl, address still in de
ret ret
;
;Get address of user-defined variables ;Get address of user-defined variables
getvars:
ld hl,uservars
;
getvars:ld hl,uservars
ret ret
;
uservars: uservars:
dw overdrive ; .OVR etc. drive/user dw overdrive ; .OVR etc. drive/user
dw overuser dw overuser
;
if ($ - codebgn) gt ovsize if ($ - codebgn) gt ovsize
toobig: jp errval ; Overlay too large! toobig: jp errval ; Overlay too large!
endif endif
;
end end

Loading…
Cancel
Save