Equates for Network 4 (Omninet) Ports
EQU 0D3H
EQU 0D1H
EQU 0D2H
EQU 0D0H
EQU 0D2H
EQU 0D0H
EQU 0D3H
Equates for Hard Disk Ports
EQU 0CFH
EQU 0CFH
EQU 0CEH
EQU 0CDH
EQU 0CCH
EQU 0CBH
EQU 0C8H
EQU 0C1H
Equates for Misc Other Items
EQU 021BH
EQU 7A00H
EQU 7AH
Begin …
ORG 7000H
LD HL,WELCOM
LD HL,(6FF0H)
LD DE,5041H
OR A
SBC HL,DE
LD (6FF0H),DE
LD A,(4210H)
OR 10H
OUT (0ECH),A
LD (4210H),A
XOR A
OUT (OLSB),A
OUT (OMSB),A
DEC A
OUT (OMOUT),A
LD A,20H
OUT (OMOUT),A
XOR A
OUT (OMOUT),A
OUT (OMOUT),A
OUT (OMOUT),A
INC A
XOR A
CP 63H
If we are here, then the station address is not 63 and this is not the server. With this, we must read (across the network) the bootstrap pointer sector (sector 0 of drive 1 at the server) to get the boot code volume for THIS station, then get the location of the boot volume from the volume table, and then load the object code found at that location and jump to it. So let’s start …
EX AF,AF'
LD DE,20H
LD BC,OMBUFF
EX AF,AF'
LD H,BUFMSB
ADD A,A
LD L,A
LD E,(HL)
INC HL
LD D,(HL)
Now have Volume Number of our Boot Code. Next we must get the Volume Entry for Start Address …
LD BC,10H
LD HL,0
LD A,E
OR D
DEC DE
ADD HL,BC
“GETV2” – At this point H = the Sector Offset and L = Buffer offset.
LD E,H
LD H,BUFMSB
PUSH HL
LD HL,15H
ADD HL,DE
EX DE,HL
LD BC,OMBUFF
POP HL
INC HL
LD A,(HL)
LD (SERV1),A
INC HL
LD A,(HL)
LD (RDDRV),A
INC HL
LD E,(HL)
INC HL
LD D,(HL)
LD BC,OMBUFF+255
EXX
“BOOT0” – We know where the Boot Code is so BOOT!
CP 02H
CP 01H
CP 20H
Load file format error!
LD HL,FMTERR
EQU $
LD B,A
DJNZ BOOT2
LD B,A
DEC B
DEC B
LD L,A
LD H,A
LD (HL),A
INC HL
DJNZ BOOT4
LD L,A
LD H,A
LD (6FF0H),HL
GETBYT” – Returns the next byte from the disk drive reading the buffer when necessary
EXX
INC C
LD A,(BC)
EXX
RET
PUSH BC
PUSH DE
POP DE
INC DE
POP BC
RET
“OREAD” – Omninet Read Routine: BC = Buffer Address; DE = Record Number Wanted.
LD A,08H
LD (RETRYS),A
LD (RDSECT),DE
PUSH BC
XOR A
OUT (OLSB),A
OUT (OMSB),A
LD C,OMOUT
LD B,CMDEND-CMDS
LD HL,CMDS
OTIR
Transporter is now formatted the way we want it, so issue the read. Remember that A is still zero.
LD A,RES1-CMDS
CP 0FEH
INC A
OUT (OMOUT),A
LD A,SEND1-CMDS
LD A,RES2-CMDS
CP 80H
LD A,RES1-CMDS
CP 80H
LD A,STAT-CMDS
OUT (OLSB),A
IN A,(OMIN)
CP 80H
Now retrieve the read record.
LD A,04H
OUT (OMSB),A
XOR A
OUT (OLSB),A
LD BC,OMINPL
POP HL
INIR
RET
Let’s just stick a random variable right in the middle of the code for some reason.
DEFB 8
Reset the transporter socket
XOR A
OUT (OLSB),A
OUT (OMSB),A
DEC A
OUT (OMOUT),A
LD A,10H
OUT (OMOUT),A
XOR A
OUT (OMOUT),A
OUT (OMOUT),A
OUT (OMOUT),A
LD A,0B0H
OUT (OMOUT),A
LD A,01H
XOR A
Transporter now reset, but before continuing, Let’s wait for a random amount of time.
LD A,R
LD B,A
DJNZ OERR1
LD A,(RETRYS)
DEC A
LD (RETRYS),A
LD HL,OMERR
“STROBE” – Issue an omninet command in zero page with Register A containing the address within the page.
PUSH AF
XOR A
POP AF
PUSH AF
IN A,(OMSTAT)
RLA
POP AF
OUT (OSTROB),A
RET
“OMWAIT” – Look at an address in zero page (specified in “A”) and waits for it to become something other than 255.
OUT (OLSB),A
IN A,(OMIN)
CP 0FFH
EX (SP),HL
EX (SP),HL
EX (SP),HL
EX (SP),HL
IN A,(OMIN)
RET
“WAITR” – This routine delays APX 4 seconds to protect against rapid resets. This routine counts from 1 to 65536 32 times.
LD B,32H
LD HL,0
INC HL
LD A,H
OR L
DJNZ WAITR1
RET
“SERVR” – This is the Hard Drive Server Boot Routine, to run on systems which ARE the server.
LD A,10H
OUT (HCNTL),A
LD B,40H
CALL 60H
LD A,0CH
OUT (HCNTL),A
EX (SP),HL
EX (SP),HL
IN A,(HSTAT)
RLA
XOR A
OUT (HDRIVE),A
LD A,16H
OUT (HCOMND),A
EX (SP),HL
EX (SP),HL
IN A,(HSTAT)
RLA
LD A,10H
OUT (HCOMND),A
EX (SP),HL
EX (SP),HL
IN A,(HSTAT)
RLA
RRA
RRA
The ROM author comments the new 6 instructions as “Now do some nice self-modifying code”.
LD HL,HDREAD
LD (SWITCH+1),HL
LD DE,82H
LD BC,OMBUFF+255
EXX
“HDREAD” – Now let’s read drive 0, head 0, of the hard drive. BC is the BUFFER and DE is the Logical Sector
LD HL,05H
ADD HL,DE
LD A,L
AND 1FH
OUT (HSECT),A
This code divides HL by 32 which will then be the cylinder
SRL H
RR L
SRL H
RR L
SRL H
RR L
SRL H
RR L
SRL H
RR L
Bow that HL has the cylinder, we need the track.
LD A,L
OUT (HCYLLO),A
LD A,H
OUT (HCYLHI),A
Logical seek now done! Do the read.
LD H,B
LD L,C
LD BC,HDATA
LD A,20H
OUT (HCOMND),A
EX (SP),HL
EX (SP),HL
IN A,(HSTAT)
RLA
INIR
IN A,(HSTAT)
RRA
RET NC
LD HL,HDERR
Data and constants.
DEFB 1CH
DEFB 1FH
DEFM 'Network 4 Model III Transporter '
DEFM 'ROM Version 01.01.00'
DEFB 0AH
DEFB 0AH
DEFM 'Initializing, please wait.'
DEFB 0DH
DEFB 0AH
DEFB 0AH
DEFM 'LOAD FILE FORMAT ERROR'
DEFB 0DH
DEFB 0AH
DEFB 0AH
DEFM 'HARD DISK ERROR'
DEFB 0DH
DEFB 0AH
DEFB 0AH
DEFM 'NETWORK 4 CODE X1'
DEFB 0AH
DEFM 'Please try again.'
DEFB 0DH
Data and constants – Transporter control block.
DEFB 0F0H
DEFW 0
DEFB RES1-CMDS
DEFB 0B0H
DEFB 0
DEFB 4
DEFB 0
DEFB 4
DEFB 0
DEFB 3
DEFB 255
DEFW 0
DEFW 0
DEFB 0
DEFB 0
DEFB 40H
DEFW 0
DEFB RES2-CMDS
DEFB 0B0H
DEFW 0
DEFB RDCMD-CMDS
DEFB 0
DEFB 4
DEFB 4
DEFB 3FH
DEFB 0FFH
DEFB 0
DEFB 0
DEFB 0
DEFB 0
DEFB 4
DEFB 1
DEFB 0
DEFB 22H
DEFB 01H
DEFW 0
EQU $
END START