|
|
|
@ -61,14 +61,74 @@ MINIT: |
|
|
|
CALL IDBIO ; 1=HBIOS, 2=UBIOS |
|
|
|
LD (BIOID),A ; Save it |
|
|
|
DEC A ; Test for HBIOS |
|
|
|
JR Z,HINIT ; Do HBIOS setup |
|
|
|
JR Z,MINIT_HB ; Do HBIOS setup |
|
|
|
DEC A ; Test for UBIOS |
|
|
|
JR Z,UINIT ; Do UBIOS setup |
|
|
|
JR Z,MINIT_UB ; Do UBIOS setup |
|
|
|
; |
|
|
|
; Neither UNA nor RomWBW |
|
|
|
LD DE,ERR_BIO ; BIOS error message |
|
|
|
JP FAIL ; Print msg and bail out |
|
|
|
; |
|
|
|
MINIT_HB: |
|
|
|
; Display RomWBW notification string |
|
|
|
LD DE,HB_TAG ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
; |
|
|
|
; Get CPU speed from RomWBW HBIOS and save it |
|
|
|
LD B,0F8H ; HBIOS SYSGET function 0xF8 |
|
|
|
LD C,0F0H ; CPUINFO subfunction 0xF0 |
|
|
|
RST 08 ; Do it, L := CPU speed in MHz |
|
|
|
LD A,L ; Move it to A |
|
|
|
LD (CPUSPD),A ; Save it |
|
|
|
; |
|
|
|
; Get HBIOS bank id |
|
|
|
LD BC,0F8F2H ; HBIOS SYSGET, Bank Info |
|
|
|
RST 08 ; do it |
|
|
|
JP NZ,APIERR ; handle API error |
|
|
|
LD A,D ; BIOS bank id to A |
|
|
|
LD (BIOSBID),A ; save it |
|
|
|
; |
|
|
|
; Lookup current console to use as default for transfer |
|
|
|
LD B,0FAH ; HBIOS PEEK |
|
|
|
LD A,(BIOSBID) ; get BIOS bank id |
|
|
|
LD D,A ; ... and put in D |
|
|
|
LD HL,100H + 12H ; HCB console unit address |
|
|
|
RST 08 ; E := value |
|
|
|
LD A,E ; put in A |
|
|
|
LD (UNIT),A ; save it |
|
|
|
; |
|
|
|
; Get HBIOS character 0 device type |
|
|
|
LD B,006H ; HBIOS DEVICE function 0x06 |
|
|
|
LD C,000H ; HBIOS char 0 device |
|
|
|
RST 08 ; Do it, D=device type |
|
|
|
LD A,D ; Put result in A |
|
|
|
CP 000H ; UART? |
|
|
|
JP Z,UA_INIT ; If so, do UART H/W init |
|
|
|
CP 080H ; USB-FIFO? |
|
|
|
JP Z,UF_INIT ; If so, do USB-FIFO H/W init |
|
|
|
JP HB_INIT ; Otherwise, use BIOS I/O |
|
|
|
; |
|
|
|
MINIT_UB: |
|
|
|
; Display UNA notification string |
|
|
|
LD DE,UB_TAG ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
; |
|
|
|
; Get CPU speed from UNA and save it |
|
|
|
LD C,0F8H ; UNA BIOS Get PHI function |
|
|
|
RST 08 ; Returns speed in Hz in DE:HL |
|
|
|
LD B,4 ; Divide MHz in DE:HL by 100000H |
|
|
|
MINIT_UB1: |
|
|
|
SRL D ; ... to get approx CPU speed in |
|
|
|
RR E ; ...MHz. Throw away HL, and |
|
|
|
DJNZ MINIT_UB1 ; ...right shift DE by 4. |
|
|
|
INC E ; Fix up for value truncation |
|
|
|
LD A,E ; Put in A |
|
|
|
LD (CPUSPD),A ; Save it |
|
|
|
; |
|
|
|
JP UB_INIT ; UNA BIOS init |
|
|
|
; |
|
|
|
MINIT_RET: |
|
|
|
PUSH HL ; Save HL (JP table adr) |
|
|
|
|
|
|
|
@ -107,45 +167,35 @@ MINIT_RET: |
|
|
|
LD HL,(RCVSCL) ; HL := receive scalar |
|
|
|
RET ; and return |
|
|
|
; |
|
|
|
HINIT: |
|
|
|
; Display RomWBW notification string |
|
|
|
LD DE,HBTAG ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
; |
|
|
|
; Get CPU speed from RomWBW HBIOS and save it |
|
|
|
LD B,0F8H ; HBIOS SYSGET function 0xF8 |
|
|
|
LD C,0F0H ; CPUINFO subfunction 0xF0 |
|
|
|
RST 08 ; Do it, L := CPU speed in MHz |
|
|
|
LD A,L ; Move it to A |
|
|
|
LD (CPUSPD),A ; Save it |
|
|
|
; |
|
|
|
JP H_INIT ; HBIOS init |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
UINIT: |
|
|
|
; Display UNA notification string |
|
|
|
LD DE,UBTAG ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
; Uninitialize modem |
|
|
|
; |
|
|
|
; Get CPU speed from UNA and save it |
|
|
|
LD C,0F8H ; UNA BIOS Get PHI function |
|
|
|
RST 08 ; Returns speed in Hz in DE:HL |
|
|
|
LD B,4 ; Divide MHz in DE:HL by 100000H |
|
|
|
UINIT1: |
|
|
|
SRL D ; ... to get approx CPU speed in |
|
|
|
RR E ; ...MHz. Throw away HL, and |
|
|
|
DJNZ UINIT1 ; ...right shift DE by 4. |
|
|
|
INC E ; Fix up for value truncation |
|
|
|
LD A,E ; Put in A |
|
|
|
LD (CPUSPD),A ; Save it |
|
|
|
UNINIT: |
|
|
|
LD A,(BIOID) |
|
|
|
CP 1 ; Is HBIOS? |
|
|
|
JR Z,HUNINIT ; Handle HBIOS |
|
|
|
CP 2 ; Is UBIOS? |
|
|
|
JR Z,UUNINIT ; Handle UBIOS |
|
|
|
RET ; Just return |
|
|
|
; |
|
|
|
JP U_INIT ; UNA BIOS init |
|
|
|
HUNINIT: |
|
|
|
; HBIOS: Reset character device 0 |
|
|
|
LD B,04H ; HBIOS CIOINIT function 0x04 |
|
|
|
LD A,(UNIT) ; HBIOS serial unit number |
|
|
|
LD C,A ; Put in C for func call |
|
|
|
LD DE,-1 ; Reset w/ current settings |
|
|
|
RST 08 ; Do it |
|
|
|
RET ; not initialized, so no 'UN-INITIALIZE' |
|
|
|
; |
|
|
|
HWERR: |
|
|
|
; Failed to identify target comm hardware |
|
|
|
LD DE,ERR_HW ; Hardware error message |
|
|
|
JP FAIL ; Print message and bail out |
|
|
|
UUNINIT: |
|
|
|
; UBIOS: Reset character device 0 |
|
|
|
LD C,10H ; UNA INIT function 0x10 |
|
|
|
LD A,(UNIT) ; UBIOS serial unit number |
|
|
|
LD B,A ; Put in B for func call |
|
|
|
LD DE,-1 ; Reset w/ current settings |
|
|
|
RST 08 ; Do it |
|
|
|
RET ; not initialized, so no 'UN-INITIALIZE' |
|
|
|
; |
|
|
|
; Identify active BIOS. RomWBW HBIOS=1, UNA UBIOS=2, else 0 |
|
|
|
; |
|
|
|
@ -184,6 +234,16 @@ IDBIO2: |
|
|
|
XOR A ; Setup return value of 0 |
|
|
|
RET ; and done |
|
|
|
; |
|
|
|
HWERR: |
|
|
|
; Failed to identify target comm hardware |
|
|
|
LD DE,ERR_HW ; Hardware error message |
|
|
|
JP FAIL ; Print message and bail out |
|
|
|
; |
|
|
|
APIERR: |
|
|
|
; API returned unepected failure |
|
|
|
LD DE,ERR_API ; API error message |
|
|
|
JP FAIL ; Pprint message and bail out |
|
|
|
; |
|
|
|
FAIL: |
|
|
|
; DE has error string address |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
@ -192,36 +252,6 @@ FAIL: |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Uninitialize modem |
|
|
|
; |
|
|
|
UNINIT: |
|
|
|
LD A,(BIOID) |
|
|
|
CP 1 ; Is HBIOS? |
|
|
|
JR Z,H_UNINIT ; Handle HBIOS |
|
|
|
CP 2 ; Is UBIOS? |
|
|
|
JR Z,U_UNINIT ; Handle UBIOS |
|
|
|
RET ; Just return |
|
|
|
; |
|
|
|
H_UNINIT: |
|
|
|
; HBIOS: Reset character device 0 |
|
|
|
LD B,04H ; HBIOS CIOINIT function 0x04 |
|
|
|
LD A,(UNIT) ; HBIOS serial unit number |
|
|
|
LD C,A ; Put in C for func call |
|
|
|
LD DE,-1 ; Reset w/ current settings |
|
|
|
RST 08 ; Do it |
|
|
|
RET ; not initialized, so no 'UN-INITIALIZE' |
|
|
|
; |
|
|
|
U_UNINIT: |
|
|
|
; UBIOS: Reset character device 0 |
|
|
|
LD C,10H ; UNA INIT function 0x10 |
|
|
|
LD A,(UNIT) ; UBIOS serial unit number |
|
|
|
LD B,A ; Put in B for func call |
|
|
|
LD DE,-1 ; Reset w/ current settings |
|
|
|
RST 08 ; Do it |
|
|
|
RET ; not initialized, so no 'UN-INITIALIZE' |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; The following are all dummy routines that are unused because MINIT |
|
|
|
; dynamically installs the real jump table. |
|
|
|
; |
|
|
|
@ -240,17 +270,20 @@ EXTRA3: |
|
|
|
BIOID DB 0 ; BIOS ID, 1=HBIOS, 2=UBIOS |
|
|
|
CPUSPD DB 10 ; CPU speed in MHz |
|
|
|
RCVSCL DW 6600 ; RECV loop timeout scalar |
|
|
|
UNIT DB 0 ; HBIOS serial device unit number |
|
|
|
UNIT DB 0 ; BIOS serial device unit number |
|
|
|
BIOSBID DB 00H ; BIOS bank id |
|
|
|
; |
|
|
|
TAG DB "RomWBW, 23-May-2020$" |
|
|
|
; |
|
|
|
H_LBL DB ", HBIOS FastPath$" |
|
|
|
U_LBL DB ", UNA UBIOS$" |
|
|
|
HB_LBL DB ", HBIOS FastPath$" |
|
|
|
UB_LBL DB ", UNA UBIOS$" |
|
|
|
UA_LBL DB ", UART$" |
|
|
|
UF_LBL DB ", USB-FIFO$" |
|
|
|
COM_LBL DB " on COM$" |
|
|
|
EXP_LBL DB 13, 10, 13, 10, "*** Experimental ***$" |
|
|
|
; |
|
|
|
UBTAG DB " [UNA]$" |
|
|
|
HBTAG DB " [WBW]$" |
|
|
|
UB_TAG DB " [UNA]$" |
|
|
|
HB_TAG DB " [WBW]$" |
|
|
|
; |
|
|
|
CRLF DB 13, 10, "$" |
|
|
|
; |
|
|
|
@ -270,38 +303,22 @@ ERR_API DB 13, 10, 13, 10, "++ BIOS API Error ++", 13, 10, "$" |
|
|
|
; table at program startup. See MINIT above. Note that only a |
|
|
|
; subset of the jump table is overlaid (SENDR to SPEED). |
|
|
|
; |
|
|
|
H_JPTBL: |
|
|
|
JP H_SENDR ; send character (via pop psw) |
|
|
|
JP H_CAROK ; test for carrier |
|
|
|
JP H_MDIN ; receive data byte |
|
|
|
JP H_GETCHR ; get character from modem |
|
|
|
JP H_RCVRDY ; check receive ready |
|
|
|
JP H_SNDRDY ; check send ready |
|
|
|
JP H_SPEED ; get speed value for file transfer time |
|
|
|
HB_JPTBL: |
|
|
|
JP HB_SENDR ; send character (via pop psw) |
|
|
|
JP HB_CAROK ; test for carrier |
|
|
|
JP HB_MDIN ; receive data byte |
|
|
|
JP HB_GETCHR ; get character from modem |
|
|
|
JP HB_RCVRDY ; check receive ready |
|
|
|
JP HB_SNDRDY ; check send ready |
|
|
|
JP HB_SPEED ; get speed value for file transfer time |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; HBIOS initialization |
|
|
|
; |
|
|
|
H_INIT: |
|
|
|
HB_INIT: |
|
|
|
LD HL,2150 ; Smaller receive loop timeout scalar |
|
|
|
LD (RCVSCL),HL ; ... to compensate for BIOS overhead |
|
|
|
; |
|
|
|
; Get HBIOS bank id |
|
|
|
LD BC,0F8F2H ; HBIOS SYSGET, Bank Info |
|
|
|
RST 08 ; do it |
|
|
|
JR NZ,H_APIERR ; handle API error |
|
|
|
LD A,D ; BIOS bank id to A |
|
|
|
LD (H_BNKID),A ; save it |
|
|
|
; |
|
|
|
; Lookup current console to use as default for transfer |
|
|
|
LD B,0FAH ; HBIOS PEEK |
|
|
|
LD A,(H_BNKID) ; get BIOS bank id |
|
|
|
LD D,A ; ... and put in D |
|
|
|
LD HL,100H + 12H ; HCB console unit address |
|
|
|
RST 08 ; E := value |
|
|
|
LD A,E ; put in A |
|
|
|
LD (UNIT),A ; save it |
|
|
|
; |
|
|
|
; Patch SENDR w/ FastPath addresses |
|
|
|
LD BC,0F801H ; Get CIO func/data adr |
|
|
|
@ -309,9 +326,9 @@ H_INIT: |
|
|
|
LD A,(UNIT) ; get desired char unit |
|
|
|
LD E,A ; and put in E |
|
|
|
RST 08 |
|
|
|
JR NZ,H_APIERR ; handle API error |
|
|
|
LD (H_UDAT),DE ; Plug in data adr |
|
|
|
LD (H_SCFN),HL ; Plug in func adr |
|
|
|
JP NZ,APIERR ; handle API error |
|
|
|
LD (HB_UDAT),DE ; Plug in data adr |
|
|
|
LD (HB_SCFN),HL ; Plug in func adr |
|
|
|
; |
|
|
|
; Patch GETCHR/MDIN w/ FastPath addresses |
|
|
|
LD BC,0F801H ; Get CIO func/data adr |
|
|
|
@ -319,8 +336,8 @@ H_INIT: |
|
|
|
LD A,(UNIT) ; get desired char unit |
|
|
|
LD E,A ; and put in E |
|
|
|
RST 08 |
|
|
|
JR NZ,H_APIERR ; handle API error |
|
|
|
LD (H_GCFN),HL ; Plug in func adr |
|
|
|
JP NZ,APIERR ; handle API error |
|
|
|
LD (HB_GCFN),HL ; Plug in func adr |
|
|
|
; |
|
|
|
; Patch RCVRDY w/ FastPath addresses |
|
|
|
LD BC,0F801H ; Get CIO func/data adr |
|
|
|
@ -328,8 +345,8 @@ H_INIT: |
|
|
|
LD A,(UNIT) ; get desired char unit |
|
|
|
LD E,A ; and put in E |
|
|
|
RST 08 |
|
|
|
JR NZ,H_APIERR ; handle API error |
|
|
|
LD (H_RRFN),HL ; Plug in func adr |
|
|
|
JP NZ,APIERR ; handle API error |
|
|
|
LD (HB_RRFN),HL ; Plug in func adr |
|
|
|
; |
|
|
|
; Patch SNDRDY w/ FastPath addresses |
|
|
|
LD BC,0F801H ; Get CIO func/data adr |
|
|
|
@ -337,31 +354,27 @@ H_INIT: |
|
|
|
LD A,(UNIT) ; get desired char unit |
|
|
|
LD E,A ; and put in E |
|
|
|
RST 08 |
|
|
|
JR NZ,H_APIERR ; handle API error |
|
|
|
LD (H_SRFN),HL ; Plug in func adr |
|
|
|
JP NZ,APIERR ; handle API error |
|
|
|
LD (HB_SRFN),HL ; Plug in func adr |
|
|
|
; |
|
|
|
LD HL,H_JPTBL |
|
|
|
LD DE,H_LBL |
|
|
|
LD HL,HB_JPTBL |
|
|
|
LD DE,HB_LBL |
|
|
|
JP MINIT_RET |
|
|
|
; |
|
|
|
H_APIERR: |
|
|
|
LD DE,ERR_API |
|
|
|
JP FAIL |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Send character on top of stack |
|
|
|
; |
|
|
|
H_SENDR: |
|
|
|
HB_SENDR: |
|
|
|
POP AF ; get character to send from stack |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
LD E,A ; character to E |
|
|
|
LD IY,(H_UDAT) |
|
|
|
LD A,(H_BNKID) ; call into HBIOS bank |
|
|
|
LD IY,(HB_UDAT) |
|
|
|
LD A,(BIOSBID) ; call into HBIOS bank |
|
|
|
LD IX,0000H |
|
|
|
H_SCFN EQU $-2 |
|
|
|
HB_SCFN EQU $-2 |
|
|
|
CALL 0FFF9H ; HBIOS bank call |
|
|
|
POP HL |
|
|
|
POP DE |
|
|
|
@ -372,28 +385,31 @@ H_SCFN EQU $-2 |
|
|
|
; |
|
|
|
; Test and report carrier status, Z set if carrier present |
|
|
|
; |
|
|
|
H_CAROK: |
|
|
|
HB_CAROK: |
|
|
|
XOR A ; not used, always indicate present |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Get a character (assume character ready has already been tested) |
|
|
|
; Get a character |
|
|
|
; |
|
|
|
; GETCHR must NOT block. |
|
|
|
; GETCHR must not block |
|
|
|
; |
|
|
|
H_GETCHR: |
|
|
|
CALL H_RCVRDY |
|
|
|
HB_GETCHR: |
|
|
|
CALL HB_RCVRDY |
|
|
|
RET NZ |
|
|
|
|
|
|
|
H_MDIN: |
|
|
|
; Fall thru if char ready |
|
|
|
; |
|
|
|
; MDIN can assume a character is ready |
|
|
|
; |
|
|
|
HB_MDIN: |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
LD IY,(H_UDAT) |
|
|
|
LD A,(H_BNKID) ; call into HBIOS bank |
|
|
|
LD IY,(HB_UDAT) |
|
|
|
LD A,(BIOSBID) ; call into HBIOS bank |
|
|
|
LD IX,0000H |
|
|
|
H_GCFN EQU $-2 |
|
|
|
HB_GCFN EQU $-2 |
|
|
|
CALL 0FFF9H ; HBIOS bank call |
|
|
|
LD A,E ; byte received to A |
|
|
|
POP HL |
|
|
|
@ -407,14 +423,14 @@ H_GCFN EQU $-2 |
|
|
|
; Error code returned in A register |
|
|
|
; *** Error code does not seem to be used *** |
|
|
|
; |
|
|
|
H_RCVRDY: |
|
|
|
HB_RCVRDY: |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
LD IY,(H_UDAT) |
|
|
|
LD A,(H_BNKID) ; call into HBIOS bank |
|
|
|
LD IY,(HB_UDAT) |
|
|
|
LD A,(BIOSBID) ; call into HBIOS bank |
|
|
|
LD IX,0000H |
|
|
|
H_RRFN EQU $-2 |
|
|
|
HB_RRFN EQU $-2 |
|
|
|
CALL 0FFF9H ; HBIOS bank call |
|
|
|
SUB 1 ; CF set IFF zero |
|
|
|
RL A ; CF to bit 0 of A |
|
|
|
@ -429,14 +445,14 @@ H_RRFN EQU $-2 |
|
|
|
; |
|
|
|
; Test for ready to send a character, Z = ready |
|
|
|
; |
|
|
|
H_SNDRDY: |
|
|
|
HB_SNDRDY: |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
LD IY,(H_UDAT) |
|
|
|
LD A,(H_BNKID) ; call into HBIOS bank |
|
|
|
LD IY,(HB_UDAT) |
|
|
|
LD A,(BIOSBID) ; call into HBIOS bank |
|
|
|
LD IX,0000H |
|
|
|
H_SRFN EQU $-2 |
|
|
|
HB_SRFN EQU $-2 |
|
|
|
CALL 0FFF9H ; HBIOS bank call |
|
|
|
SUB 1 ; CF set IFF zero |
|
|
|
RL A ; CF to bit 0 of A |
|
|
|
@ -450,14 +466,13 @@ H_SRFN EQU $-2 |
|
|
|
; |
|
|
|
; Report baud rate (index into SPTBL returned in register A) |
|
|
|
; |
|
|
|
H_SPEED: |
|
|
|
HB_SPEED: |
|
|
|
LD A,8 ; arbitrarily return 9600 baud |
|
|
|
RET |
|
|
|
; |
|
|
|
; |
|
|
|
; |
|
|
|
H_BNKID DB 00H ; HBIOS bank id |
|
|
|
H_UDAT DW 0000H ; Unit data address |
|
|
|
HB_UDAT DW 0000H ; Unit data address |
|
|
|
; |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
@ -472,20 +487,20 @@ H_UDAT DW 0000H ; Unit data address |
|
|
|
; table at program startup. See MINIT above. Note that only a |
|
|
|
; subset of the jump table is overlaid (SENDR to SPEED). |
|
|
|
; |
|
|
|
U_JPTBL: |
|
|
|
JP U_SENDR ; send character (via pop psw) |
|
|
|
JP U_CAROK ; test for carrier |
|
|
|
JP U_MDIN ; receive data byte |
|
|
|
JP U_GETCHR ; get character from modem |
|
|
|
JP U_RCVRDY ; check receive ready |
|
|
|
JP U_SNDRDY ; check send ready |
|
|
|
JP U_SPEED ; get speed value for file transfer time |
|
|
|
UB_JPTBL: |
|
|
|
JP UB_SENDR ; send character (via pop psw) |
|
|
|
JP UB_CAROK ; test for carrier |
|
|
|
JP UB_MDIN ; receive data byte |
|
|
|
JP UB_GETCHR ; get character from modem |
|
|
|
JP UB_RCVRDY ; check receive ready |
|
|
|
JP UB_SNDRDY ; check send ready |
|
|
|
JP UB_SPEED ; get speed value for file transfer time |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; UBIOS initialization |
|
|
|
; |
|
|
|
U_INIT: |
|
|
|
UB_INIT: |
|
|
|
; |
|
|
|
; TODO: |
|
|
|
; - TEST!!! |
|
|
|
@ -494,15 +509,15 @@ U_INIT: |
|
|
|
LD HL,3000 ; Smaller receive loop timeout scalar |
|
|
|
LD (RCVSCL),HL ; ... to compensate for BIOS overhead |
|
|
|
; |
|
|
|
LD HL,U_JPTBL |
|
|
|
LD DE,U_LBL |
|
|
|
LD HL,UB_JPTBL |
|
|
|
LD DE,UB_LBL |
|
|
|
JP MINIT_RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Send character on top of stack |
|
|
|
; |
|
|
|
U_SENDR: |
|
|
|
UB_SENDR: |
|
|
|
POP AF ; get character to send from stack |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
@ -519,21 +534,24 @@ U_SENDR: |
|
|
|
; |
|
|
|
; Test and report carrier status, Z set if carrier present |
|
|
|
; |
|
|
|
U_CAROK: |
|
|
|
UB_CAROK: |
|
|
|
XOR A ; not used, always indicate present |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Get a character (assume character ready has already been tested) |
|
|
|
; Get a character |
|
|
|
; |
|
|
|
; GETCHR must NOT block. |
|
|
|
; GETCHR must not block |
|
|
|
; |
|
|
|
U_GETCHR: |
|
|
|
CALL U_RCVRDY |
|
|
|
UB_GETCHR: |
|
|
|
CALL UB_RCVRDY |
|
|
|
RET NZ |
|
|
|
|
|
|
|
U_MDIN: |
|
|
|
; Fall thru if char ready |
|
|
|
; |
|
|
|
; MDIN can assume a character is ready |
|
|
|
; |
|
|
|
UB_MDIN: |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
@ -551,7 +569,7 @@ U_MDIN: |
|
|
|
; Error code returned in A register |
|
|
|
; *** Error code does not seem to be used *** |
|
|
|
; |
|
|
|
U_RCVRDY: |
|
|
|
UB_RCVRDY: |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
@ -570,7 +588,7 @@ U_RCVRDY: |
|
|
|
; |
|
|
|
; Test for ready to send a character, Z = ready |
|
|
|
; |
|
|
|
U_SNDRDY: |
|
|
|
UB_SNDRDY: |
|
|
|
PUSH BC |
|
|
|
PUSH DE |
|
|
|
PUSH HL |
|
|
|
@ -588,7 +606,252 @@ U_SNDRDY: |
|
|
|
; |
|
|
|
; Report baud rate (index into SPTBL returned in register A) |
|
|
|
; |
|
|
|
U_SPEED: |
|
|
|
UB_SPEED: |
|
|
|
LD A,8 ; arbitrarily return 9600 baud |
|
|
|
RET |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; 8250-like UART |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; UART constants |
|
|
|
; |
|
|
|
UA_SNDB EQU 20H ; bit to test for send ready |
|
|
|
UA_SNDR EQU 20H ; value when ready to send |
|
|
|
UA_RCVB EQU 01H ; bit to test for receive ready |
|
|
|
UA_RCVR EQU 01H ; value when ready to receive |
|
|
|
UA_PARE EQU 04H ; bit for parity error |
|
|
|
UA_OVRE EQU 02H ; bit for overrun error |
|
|
|
UA_FRME EQU 08H ; bit for framing error |
|
|
|
UA_ERRS EQU UA_FRME | UA_OVRE | UA_PARE |
|
|
|
; |
|
|
|
; Following jump table is dynamically patched into real jump |
|
|
|
; table at program startup. See MINIT above. Note that only a |
|
|
|
; subset of the jump table is overlaid (SENDR to SPEED). |
|
|
|
; |
|
|
|
UA_JPTBL: |
|
|
|
JP UA_SENDR ; send character (via pop psw) |
|
|
|
JP UA_CAROK ; test for carrier |
|
|
|
JP UA_MDIN ; receive data byte |
|
|
|
JP UA_GETCHR ; get character from modem |
|
|
|
JP UA_RCVRDY ; check receive ready |
|
|
|
JP UA_SNDRDY ; check send ready |
|
|
|
JP UA_SPEED ; get speed value for file transfer time |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; UART initialization |
|
|
|
; |
|
|
|
UA_INIT: |
|
|
|
LD DE,13000 ; Receive loop timeout scalar |
|
|
|
LD (RCVSCL),DE ; ... for UART RCVRDY timing |
|
|
|
; |
|
|
|
LD A,L ; Get base I/O port address |
|
|
|
LD (UA_SCP),A ; Set port value in SENDR |
|
|
|
LD (UA_GCP),A ; Set port value in GETCHR |
|
|
|
ADD A,5 ; UART control port is 5 higher |
|
|
|
LD (UA_RRP),A ; Set port value in RCVRDY |
|
|
|
LD (UA_SRP),A ; Set port value in SNDRDY |
|
|
|
; |
|
|
|
LD HL,UA_JPTBL |
|
|
|
LD DE,UA_LBL |
|
|
|
JP MINIT_RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Send character on top of stack |
|
|
|
; |
|
|
|
UA_SENDR: |
|
|
|
POP AF ; get character to send from stack |
|
|
|
OUT (0FFH),A ; send to port |
|
|
|
UA_SCP EQU $-1 ; port value |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test and report carrier status, Z set if carrier present |
|
|
|
; |
|
|
|
UA_CAROK: |
|
|
|
XOR A ; not used, always indicate present |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Get a character |
|
|
|
; |
|
|
|
; GETCHR must not block |
|
|
|
; |
|
|
|
UA_GETCHR: |
|
|
|
CALL UA_RCVRDY |
|
|
|
RET NZ |
|
|
|
; Fall thru if char ready |
|
|
|
; |
|
|
|
; MDIN can assume a character is ready |
|
|
|
; |
|
|
|
UA_MDIN: |
|
|
|
IN A,(0FFH) ; read character from port |
|
|
|
UA_GCP EQU $-1 ; port value |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test for character ready to receive, Z = ready |
|
|
|
; Error code returned in A register |
|
|
|
; *** Error code does not seem to be used *** |
|
|
|
; |
|
|
|
UA_RCVRDY: |
|
|
|
IN A,(0FFH) ; get modem status |
|
|
|
UA_RRP EQU $-1 ; port value |
|
|
|
AND UA_RCVB ; isolate ready bit |
|
|
|
CP UA_RCVR ; test it (set flags) |
|
|
|
LD A,0 ; report no line errors |
|
|
|
; |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test for ready to send a character, Z = ready |
|
|
|
; |
|
|
|
UA_SNDRDY: |
|
|
|
IN A,(0FFH) ; get status |
|
|
|
UA_SRP EQU $-1 ; port value |
|
|
|
AND UA_SNDB ; isolate transmit ready bit |
|
|
|
CP UA_SNDR ; test for ready value |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Report baud rate (index into SPTBL returned in register A) |
|
|
|
; |
|
|
|
UA_SPEED: |
|
|
|
LD A,8 ; arbitrarily return 9600 baud |
|
|
|
RET |
|
|
|
; |
|
|
|
; |
|
|
|
; |
|
|
|
UA_BASE DB 00H ; UART base port I/O address |
|
|
|
UA_CTLP DB 00H ; UART control port I/O address |
|
|
|
; |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; WILL SOWERBUTTS ECB USB-FIFO |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
UF_BASE EQU 0CH |
|
|
|
UF_DATA EQU (UF_BASE+0) |
|
|
|
UF_STATUS EQU (UF_BASE+1) |
|
|
|
UF_SEND_IMM EQU (UF_BASE+2) |
|
|
|
; |
|
|
|
; Following jump table is dynamically patched over initial jump |
|
|
|
; table at program startup. See MINIT above. Note that only a |
|
|
|
; subset of the jump table is overlaid (SENDR to SPEED). |
|
|
|
; |
|
|
|
UF_JPTBL: |
|
|
|
JP UF_SENDR ; send character (via pop psw) |
|
|
|
JP UF_CAROK ; test for carrier |
|
|
|
JP UF_MDIN ; receive data byte |
|
|
|
JP UF_GETCHR ; get character from modem |
|
|
|
JP UF_RCVRDY ; check receive ready |
|
|
|
JP UF_SNDRDY ; check send ready |
|
|
|
JP UF_SPEED ; get speed value for file transfer time |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; USB-FIFO initialization |
|
|
|
; |
|
|
|
UF_INIT: |
|
|
|
LD HL,12000 ; Receive loop timeout scalar |
|
|
|
LD (RCVSCL),HL ; ... for UART RCVRDY timing |
|
|
|
; |
|
|
|
LD A,L ; Get base I/O port address (data port) |
|
|
|
LD (UF_SCDP),A ; Set data port in SENDR |
|
|
|
LD (UF_GCDP),A ; Set data port in GETCHR/MDIN |
|
|
|
INC A ; Bump to status port |
|
|
|
LD (UF_RRSP),A ; Set status port in RCVRDY |
|
|
|
LD (UF_SRSP),A ; Set status port in SNDRDY |
|
|
|
INC A ; Bump to send immediate port |
|
|
|
LD (UF_SCIP),A ; Set send immed port in SENDR |
|
|
|
; |
|
|
|
LD HL,UF_JPTBL |
|
|
|
LD DE,UF_LBL |
|
|
|
JP MINIT_RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Send character on top of stack |
|
|
|
; |
|
|
|
UF_SENDR: |
|
|
|
|
|
|
|
POP AF ; get character to send from stack |
|
|
|
OUT (0FFH),A ; write to fifo |
|
|
|
UF_SCDP EQU $-1 ; data port |
|
|
|
OUT (0FFH),A ; send immediate |
|
|
|
UF_SCIP EQU $-1 ; send immediate port |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test and report carrier status, Z set if carrier present |
|
|
|
; |
|
|
|
UF_CAROK: |
|
|
|
XOR A ; not used, always indicate present |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Get a character (assume character ready has already been tested) |
|
|
|
; |
|
|
|
; GETCHR must not block |
|
|
|
; |
|
|
|
UF_GETCHR: |
|
|
|
CALL UF_RCVRDY |
|
|
|
RET NZ |
|
|
|
; Fall thru if char ready |
|
|
|
; |
|
|
|
; MDIN can assume a character is ready |
|
|
|
; |
|
|
|
UF_MDIN: |
|
|
|
IN A,(0FFH) ; get char |
|
|
|
UF_GCDP EQU $-1 ; data port |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test for character ready to receive, Z = ready |
|
|
|
; Error code returned in A register |
|
|
|
; *** Error code does not seem to be used *** |
|
|
|
; |
|
|
|
UF_RCVRDY: |
|
|
|
IN A,(0FFH) ; b7=0 if char avail, =1 if no char. |
|
|
|
UF_RRSP EQU $-1 ; status port |
|
|
|
RLCA ; b0=0 if char avail, =1 if no char. |
|
|
|
AND 00000001B ; a=0, zf=1 if no char, a=1, zf=0 if char avail. |
|
|
|
LD A,0 |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test for ready to send a character, Z = ready |
|
|
|
; |
|
|
|
UF_SNDRDY: |
|
|
|
IN A,(0FFH) ; bit 0=0 if space avail, =1 IF FULL |
|
|
|
UF_SRSP EQU $-1 ; status port |
|
|
|
AND 00000001B ; A=0, ZF=1 if space avail, A=1, ZF=0 if full. |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Report baud rate (index into SPTBL returned in register A) |
|
|
|
; |
|
|
|
UF_SPEED: |
|
|
|
LD A,8 ; arbitrarily return 9600 baud |
|
|
|
RET |
|
|
|
; |
|
|
|
|