|
|
|
@ -67,95 +67,182 @@ MINIT: |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
; |
|
|
|
; Get system type |
|
|
|
; Identify BIOS (RomWBW HBIOS or UNA UBIOS) |
|
|
|
CALL IDBIO ; 1=HBIOS, 2=UBIOS |
|
|
|
LD (BIOID),A ; Save it |
|
|
|
DEC A ; Test for HBIOS |
|
|
|
JR Z,HINIT ; Do HBIOS setup |
|
|
|
DEC A ; Test for UBIOS |
|
|
|
JR Z,UINIT ; Do UBIOS setup |
|
|
|
; |
|
|
|
; Neither UNA nor RomWBW |
|
|
|
LD DE,BIOERR ; BIOS error message |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
JP 0 ; Bail out! |
|
|
|
; |
|
|
|
HINIT: |
|
|
|
; |
|
|
|
; Display RomWBW notification string |
|
|
|
LD DE,HBIOS ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
; |
|
|
|
; Get platform id from RomWBW HBIOS and save it |
|
|
|
LD B,0F1H ; HBIOS VER function 0xF1 |
|
|
|
LD C,0 ; Required reserved value |
|
|
|
RST 08 ; Do it, L := Platform ID |
|
|
|
LD A,L ; Move to A |
|
|
|
LD (PLTID),A ; Save 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 |
|
|
|
JR MINIT1 ; Continue general initialization |
|
|
|
; |
|
|
|
UINIT: |
|
|
|
; |
|
|
|
; Display UNA notification string |
|
|
|
LD DE,UBIOS ; 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 |
|
|
|
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 |
|
|
|
JR MINIT1 ; Continue general initialization |
|
|
|
; |
|
|
|
MINIT1: |
|
|
|
; NOTE: PLTID is only set if RomWBW HBIOS is active. This is OK |
|
|
|
; because RC2014 is only support by RomWBW HBIOS at this point. |
|
|
|
LD A,(PLTID) ; Get the platform id |
|
|
|
CP 7 ; Check for RC2014 |
|
|
|
JR Z,RCINIT ; Handle RC2014 special |
|
|
|
; |
|
|
|
; Check for Z180 which implies ASCI serial port |
|
|
|
LD DE,00202H ; D := 2, E := 2 |
|
|
|
MLT DE ; DE := D * E == 4 |
|
|
|
BIT 2,E ; Bit 2 wil be set if mlt happend |
|
|
|
LD HL,U_JPTBL ; Assume Z80 (UART) |
|
|
|
LD DE,UART ; UART port notification string |
|
|
|
JR Z,MINIT2 ; Yes, Z80, do vector copy |
|
|
|
LD HL,A_JPTBL ; Otherwise Z180 (ASCI) |
|
|
|
JR Z,MINIT2 ; Not Z180 (ASCI), look for others |
|
|
|
LD HL,ASCI_JPTBL ; Point to Z180 (ASCI) jump table |
|
|
|
LD DE,ASCI ; ASCI port notification string |
|
|
|
JR MINIT3 ; Complete the initialization |
|
|
|
; |
|
|
|
MINIT2: |
|
|
|
; Display port notification string |
|
|
|
; Not a Z180, so assume RBC standard UART serial port |
|
|
|
LD HL,UART_JPTBL ; Assume Z80 (UART) |
|
|
|
LD DE,UART ; UART port notification string |
|
|
|
JR MINIT3 ; Complete the initialization |
|
|
|
; |
|
|
|
RCINIT: |
|
|
|
; Check for SIO/2 serial port |
|
|
|
LD C,080H ; SIO command port |
|
|
|
XOR A ; RD0 |
|
|
|
OUT (C),A ; Access RD0 |
|
|
|
IN A,(C) ; Get RD0 value |
|
|
|
LD B,A ; Save it |
|
|
|
LD A,1 ; RD1 |
|
|
|
OUT (C),A ; Access RD1 |
|
|
|
IN A,(C) ; Get RD1 value |
|
|
|
CP B ; Compare |
|
|
|
JR Z,RCINIT1 ; If equal, no SIO port there |
|
|
|
LD HL,SIO_JPTBL ; SIO jump table address |
|
|
|
LD DE,SIO ; SIO port notification string |
|
|
|
JR MINIT3 ; Complete the initialization |
|
|
|
; |
|
|
|
RCINIT1: |
|
|
|
; Assume RC2014 ACIA port |
|
|
|
LD HL,ACIA_JPTBL ; ACIA jump table address |
|
|
|
LD DE,ACIA ; ACIA port notification string |
|
|
|
JR MINIT3 ; Complete the initialization |
|
|
|
; |
|
|
|
MINIT3: |
|
|
|
PUSH HL ; Save HL |
|
|
|
|
|
|
|
; Display port notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
POP HL ; Recover HL |
|
|
|
; |
|
|
|
; Newline |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
LD DE,CRLF ; Newline |
|
|
|
CALL BDOS ; Do it |
|
|
|
; |
|
|
|
; Copy real vectors into active jump table |
|
|
|
POP HL ; Recover HL |
|
|
|
LD DE,JPTBL ; Real jump table is destination |
|
|
|
LD BC,7 * 3 ; Copy 7 3-byte entries |
|
|
|
LDIR ; Do the copy |
|
|
|
; |
|
|
|
; Return with CPU speed in A |
|
|
|
LD A,(CPUSPD) ; Get CPU speed saved above |
|
|
|
RET ; and return |
|
|
|
; |
|
|
|
; Identify active BIOS. RomWBW HBIOS=1, UNA UBIOS=2, else 0 |
|
|
|
; |
|
|
|
IDBIO: |
|
|
|
; |
|
|
|
; Check for UNA (UBIOS) |
|
|
|
LD A,(0FFFDH) ; fixed location of UNA API vector |
|
|
|
CP 0C3H ; jp instruction? |
|
|
|
JR NZ,MINIT3 ; if not, not UNA |
|
|
|
JR NZ,IDBIO1 ; if not, not UNA |
|
|
|
LD HL,(0FFFEH) ; get jp address |
|
|
|
LD A,(HL) ; get byte at target address |
|
|
|
CP 0FDH ; first byte of UNA push ix instruction |
|
|
|
JR NZ,MINIT3 ; if not, not UNA |
|
|
|
JR NZ,IDBIO1 ; if not, not UNA |
|
|
|
INC HL ; point to next byte |
|
|
|
LD A,(HL) ; get next byte |
|
|
|
CP 0E5H ; second byte of UNA push ix instruction |
|
|
|
JR NZ,MINIT3 ; if not, not UNA |
|
|
|
; |
|
|
|
; Display UNA notification string |
|
|
|
LD DE,UBIOS ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS |
|
|
|
JR NZ,IDBIO1 ; if not, not UNA, check others |
|
|
|
LD A,2 ; UNA BIOS id = 2 |
|
|
|
RET ; and done |
|
|
|
; |
|
|
|
; Get CPU speed from UNA and return |
|
|
|
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 |
|
|
|
MINIT2A: |
|
|
|
SRL D ; ... to get approx CPU speed in |
|
|
|
RR E ; ...MHz. Throw away HL, and |
|
|
|
DJNZ MINIT2A ; ...right shift DE by 4. |
|
|
|
INC E ; Fix up for value truncation |
|
|
|
LD A,E ; Put in A |
|
|
|
RET ; Done |
|
|
|
; |
|
|
|
MINIT3: |
|
|
|
; Not UNA, try RomwBW HBIOS for CPU speed lookup |
|
|
|
IDBIO1: |
|
|
|
; Check for RomWBW (HBIOS) |
|
|
|
LD HL,(0FFFEH) ; HL := HBIOS ident location |
|
|
|
LD A,'W' ; First byte of ident |
|
|
|
CP (HL) ; Compare |
|
|
|
JR NZ,MINIT4 ; Not HBIOS |
|
|
|
JR NZ,IDBIO2 ; Not HBIOS |
|
|
|
INC HL ; Next byte of ident |
|
|
|
LD A,~'W' ; Second byte of ident |
|
|
|
CP (HL) ; Compare |
|
|
|
JR NZ,MINIT4 ; Not HBIOS |
|
|
|
JR NZ,IDBIO2 ; Not HBIOS |
|
|
|
LD A,1 ; HBIOS BIOS id = 1 |
|
|
|
RET ; and done |
|
|
|
; |
|
|
|
; Display RomWBW notification string |
|
|
|
LD DE,HBIOS ; BIOS notification string |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
IDBIO2: |
|
|
|
; No idea what this is |
|
|
|
XOR A ; Setup return value of 0 |
|
|
|
RET ; and done |
|
|
|
; |
|
|
|
; Get CPU speed from RomWBW HBIOS and return |
|
|
|
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 |
|
|
|
RET ; Done |
|
|
|
; |
|
|
|
MINIT4: |
|
|
|
; Neither UNA nor RomWBW |
|
|
|
LD DE,BIOERR ; BIOS error message |
|
|
|
LD C,9 ; BDOS string display function |
|
|
|
CALL BDOS ; Do it |
|
|
|
JP 0 ; Bail out! |
|
|
|
; |
|
|
|
RBC DB "RBC, 28-Aug-2017, $" |
|
|
|
BIOID DB 0 ; BIOS ID, 1=HBIOS, 2=UBIOS |
|
|
|
PLTID DB 0 ; Platform ID |
|
|
|
CPUSPD DB 0 ; CPU speed in MHz |
|
|
|
; |
|
|
|
UART DB "UART0$" |
|
|
|
ASCI DB "ASCI0$" |
|
|
|
RBC DB "RBC, 06-Nov-2017$" |
|
|
|
; |
|
|
|
UBIOS DB " [UNA]", 13, 10, "$" |
|
|
|
HBIOS DB " [WBW]", 13, 10, "$" |
|
|
|
UART DB ", UART0$" |
|
|
|
ASCI DB ", ASCI0$" |
|
|
|
SIO DB ", SIO0$" |
|
|
|
ACIA DB ", ACIA0$" |
|
|
|
; |
|
|
|
UBIOS DB " [UNA]$" |
|
|
|
HBIOS DB " [WBW]$" |
|
|
|
; |
|
|
|
CRLF DB 13, 10, "$" |
|
|
|
; |
|
|
|
BIOERR DB 13, 10, 13, 10, "*** Unknown BIOS ***", 13, 10, "$" |
|
|
|
; |
|
|
|
@ -211,7 +298,7 @@ U_FRME EQU 08H ; bit for framing error |
|
|
|
; table at program startup. See MINIT above. Note that only a |
|
|
|
; subset of the jump table is overlaid (SENDR to SPEED). |
|
|
|
; |
|
|
|
U_JPTBL: |
|
|
|
UART_JPTBL: |
|
|
|
JP U_SENDR ; send character (via pop psw) |
|
|
|
JP U_CAROK ; test for carrier |
|
|
|
JP U_MDIN ; receive data byte |
|
|
|
@ -325,7 +412,7 @@ A_FRME EQU 10H ;Z180 STAT:FE - framing error bit |
|
|
|
; table at program startup. See MINIT above. Note that only a |
|
|
|
; subset of the jump table is overlaid (SENDR to SPEED). |
|
|
|
; |
|
|
|
A_JPTBL: |
|
|
|
ASCI_JPTBL: |
|
|
|
JP A_SENDR ;send character (via pop psw) |
|
|
|
JP A_CAROK ;test for carrier |
|
|
|
JP A_MDIN ;receive data byte |
|
|
|
@ -408,5 +495,148 @@ A_SNDRDY: |
|
|
|
A_SPEED: |
|
|
|
LD A,8 ; arbitrarily return 9600 baud |
|
|
|
RET |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; RC2014 SIO/2 |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; SIO port constants |
|
|
|
; |
|
|
|
S_CMD EQU 80H ; SIO Command port |
|
|
|
S_DAT EQU 81H ; SIO Data port |
|
|
|
; |
|
|
|
; 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). |
|
|
|
; |
|
|
|
SIO_JPTBL: |
|
|
|
JP S_SENDR ;send character (via pop psw) |
|
|
|
JP S_CAROK ;test for carrier |
|
|
|
JP S_MDIN ;receive data byte |
|
|
|
JP S_GETCHR ;get character from modem |
|
|
|
JP S_RCVRDY ;check receive ready |
|
|
|
JP S_SNDRDY ;check send ready |
|
|
|
JP S_SPEED ;get speed value for file transfer time |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Send character on top of stack |
|
|
|
; |
|
|
|
S_SENDR: |
|
|
|
POP AF ; get character to send from stack |
|
|
|
OUT (S_DAT),A ; send to port |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test and rep;ort carrier status, Z set if carrier present |
|
|
|
; |
|
|
|
S_CAROK: |
|
|
|
XOR A ; not used, always indicate present |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Get a character (assume character ready has already been tested) |
|
|
|
; |
|
|
|
S_MDIN: |
|
|
|
S_GETCHR: |
|
|
|
IN A,(S_DAT) ; read character from port |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test for character ready to receive, Z = ready |
|
|
|
; Error code returned in A register |
|
|
|
; *** Error code does not seem to be used *** |
|
|
|
; |
|
|
|
S_RCVRDY: |
|
|
|
XOR A ; A := 0 |
|
|
|
OUT (S_CMD),A ; Access RD0 |
|
|
|
IN A,(S_CMD) ; Get RD0 |
|
|
|
AND 00000001B ; Isolate rx ready bit |
|
|
|
CP 00000001B ; ZF = rx ready |
|
|
|
; |
|
|
|
IF ERRDET |
|
|
|
; |
|
|
|
; With error detection (slower) |
|
|
|
PUSH BC ; save BC |
|
|
|
PUSH AF ; save AF |
|
|
|
LD A,1 ; A := 1 |
|
|
|
OUT (S_CMD),A ; Access RD1 |
|
|
|
IN A,(S_CMD) ; Get RD1 |
|
|
|
AND 01110000B ; isolate line err bits |
|
|
|
POP AF ; restore AF |
|
|
|
LD A,B ; err bits (B) to A |
|
|
|
POP BC ; restore BC |
|
|
|
; |
|
|
|
ELSE |
|
|
|
; |
|
|
|
; No error detection (faster) |
|
|
|
LD A,0 ; report no line errors |
|
|
|
; |
|
|
|
ENDIF |
|
|
|
; |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Test for ready to send a character, Z = ready |
|
|
|
; |
|
|
|
S_SNDRDY: |
|
|
|
XOR A ; A := 0 |
|
|
|
OUT (S_CMD),A ; Access RD0 |
|
|
|
IN A,(S_CMD) ; Get RD0 |
|
|
|
AND 00000100B ; Isolate tx empty bit |
|
|
|
CP 00000100B ; ZF = tx empty |
|
|
|
RET |
|
|
|
; |
|
|
|
;----------------------------------------------------------------------- |
|
|
|
; |
|
|
|
; Report baud rate (index into SPTBL returned in regsiter A) |
|
|
|
; |
|
|
|
S_SPEED: |
|
|
|
LD A,8 ; arbitrarily return 9600 baud |
|
|
|
RET |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; RC2014 ACIA |
|
|
|
; |
|
|
|
;======================================================================= |
|
|
|
;======================================================================= |
|
|
|
; |
|
|
|
; ACIA port constants |
|
|
|
; |
|
|
|
C_CMD EQU 80H ; SIO Command port |
|
|
|
C_DAT EQU 81H ; SIO Data port |
|
|
|
; |
|
|
|
; 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). |
|
|
|
; |
|
|
|
ACIA_JPTBL: |
|
|
|
JP C_SENDR ;send character (via pop psw) |
|
|
|
JP C_CAROK ;test for carrier |
|
|
|
JP C_MDIN ;receive data byte |
|
|
|
JP C_GETCHR ;get character from modem |
|
|
|
JP C_RCVRDY ;check receive ready |
|
|
|
JP C_SNDRDY ;check send ready |
|
|
|
JP C_SPEED ;get speed value for file transfer time |
|
|
|
; |
|
|
|
C_SENDR: |
|
|
|
C_CAROK: |
|
|
|
C_MDIN: |
|
|
|
C_GETCHR: |
|
|
|
C_RCVRDY: |
|
|
|
C_SNDRDY: |
|
|
|
C_SPEED: |
|
|
|
; Not yet implemeted... |
|
|
|
JP 0 |
|
|
|
; |
|
|
|
END |
|
|
|
|