Files
RomWBW/Source/BPBIOS/wboot-ww.z80
Wayne Warthen 04acb4102a BPBIOS Sync
2021-10-12 16:23:51 -07:00

192 lines
5.7 KiB
Z80 Assembly
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;:::::::::::::::::::::::::::::::::::::::************************************
; Warm Boot Routine *** Machine Dependant for Moves ***
; - Retro-Brew Hardware with HBIOS - *** and custom load formatting ***
; ************************************
; 1.1 - 28 Nov 16 - Modified for version 2.8 of HBIOS WW
; 1.0 - 12 Jun 96 - Initial Release for P112 from YASBEC. HFB
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CSEG
WBOOT:
IF BANKED
LD A,(TPABNK) ; Get TPA Bank # in case currently in Bank
CALL SELMEM ; ..and make current
LD SP,USP ; Set stack in high memory
ELSE
LD SP,80H ; Use space below default buffer
ENDIF
;CALL PRTSTRD ; DEBUG
;DEFB '[WBOOT]$' ; DEBUG
IF FASTWB
; Restore command processor from
; cache in (SYSBNK):100H. We assume that the
; command processor lives in high memory.
;
; It is critical that we use the HB variants of MOVE and XMOVE
; because we are moving between banks even in a non-banked
; system!
LD A,(SYSBNK) ; Source bank is SYSBNK
LD C,A ; Put it in C
LD A,(TPABNK) ; Destination bank is TPABNK
LD B,A ; Put it in B
CALL HB_XMOVE ; Set banks for extended copy
LD HL,100H ; Copy from start of cache in SYS
LD DE,(CPADR) ; .. to location of command processor in TPA
LD BC,(CPLEN) ; Length of command processor
CALL HB_MOVE ; Do it
; call PRTSTRD ; DEBUG
; defb CR,LF ; DEBUG
; defb 'WB - copied C' ; DEBUG
; defb 'P','$' ; DEBUG
WBOOTV:
XOR A ; Indicate "A" logged as Host Disk
LD (HSTDSK),A ; ..by showing Host Disk already logged
ELSE ; FASTWB
IF BANKED
LD SP,USP ; If banked, use stack in high common memory
CALL GOSYSB ; Disk routines are in banked memory
ELSE
LD SP,EXTSTK+32 ; Place default stack up high
ENDIF
LD A,0FFH ; Insure the default drive is logged
LD (HSTDSK),A ; ..by unlogging the Host Disk
LD A,(SYSDRV)
LD C,A ; Select system disk
LD E,0 ; Declare new mount
CALL SELDSK ; We're going to use the system disk
LD BC,0
CALL SETTRK ; Set track 0
LD BC,10H*256+1 ; B sectors remaining, C first sector
LD DE,0 ; DE beginning track
; Note that we begin by reading track 0, sector 1 since sector 0
; contains the cold start loader, which is skipped in a warm start
LD HL,CPR ; Base of CP/M (initial load point)
LOAD1: PUSH DE ; Load a Sector, Save Current Track
PUSH BC ; Save sectors remaining and next sector
PUSH HL ; Save DMA address
LD (DMAADR),HL ; ..in deblocker
LD HL,(SEKDPH)
LD E,(HL)
INC HL
LD D,(HL) ; Get sector XLATE address
CALL SECTRN ; Skew sector as needed
LD (SEKSEC),HL ; Save Sector # directly in deblocker
; Drive = 0, track set, sector set, DMA address set
CALL READ
OR A ; Any errors?
JR NZ,WBOOT ; Retry the entire boot if an error occurs
; No error, move to next sector
POP HL ; Recall DMA address
LD DE,128 ; DMA=DMA+128
ADD HL,DE ; New DMA address is in H,L
POP BC ; Recall NSECTS and current sector
POP DE ; Recall current track
DEC B ; Sectors=sectors-1
JR Z,GOZSYS ; Go to Z-System if all have been loaded
; More sectors remain to load, check for track change
INC C ; Increment sector count
LD A,(CPMSPT) ; Max sector +1
CP C ; Have we reached the end?
JR NZ,LOAD1 ; If not
; End of current track, go to next track
INC DE ; Track=track+1
LD C,0 ; First sector on next track
; Save register state, and set new track
LD (SEKTRK),DE ; Save track directly
JR LOAD1 ; For another sector
ENDIF ;fastwb
; End load operation, set parameters & go to Z-System
GOZSYS: LD BC,80H ; Default DMA address is 80H
CALL SETDMA
LD A,0C3H ; C3 is a JMP instruction
LD (0),A ; For JMP to WBOOT
LD (5),A ; For JMP to BDOS
LD HL,BIOSJT+3 ; Wboot entry point
LD (1),HL ; Set address field for JMP at 0
LD HL,(ENVADR) ; Get the pointer to the ENV
LD DE,43H ; Offset to high byte of Dos Start
ADD HL,DE
LD D,(HL) ; Load Dos start
DEC HL
LD E,(HL)
EX DE,HL ; Put Dos in HL
LD BC,6 ; .offset to Entry
ADD HL,BC
LD (6),HL ; ..and set Address field of jump at 5 to BDOS
EX DE,HL
DEC HL ; Back down to CCP entry
DEC HL
LD D,(HL) ; Get the vector
DEC HL
LD E,(HL)
PUSH DE ; Save CCP entry address
IF BANKED
; Copy vectors from TPA page zero to SYS page zero
LD BC,(TPABNK) ; C := TPABNK, B := SYSBNK
CALL XMOVE ; Set source/dest banks for copy
LD HL,0 ; Source address is zero
LD DE,0 ; Destination address is zero
LD BC,40H ; Copy 40H bytes
CALL MOVE ; Do it
LD A,(TPABNK) ; Set all Bank regs to TPA
LD (DMABNK),A
CALL SELMEM ; Insure TPA in context (also set USRBNK)
XOR A
LD (BIOSTK),A ; Init bank switcher
ENDIF
LD A,(4) ; Get current disk number
LD C,A ; Send to the CCP
; EI ; Enable the interrupt system
; EX DE,HL ; ..put destination in HL
POP HL ; Restore CCP entry address
; call PRTSTRD ; DEBUG
; defb CR,LF ; DEBUG
; defb 'WB exi' ; DEBUG
; defb 't$' ; DEBUG
; HALT ; DEBUG
JP (HL) ; Go to Z-System for further processing
IF [Z3 AND HAVIOP]
; Aux Jump Table so IOP's can find routines. After Cold Boot, the
; address of this table is placed in BIOSJT+1.
IOPRET: JP CONST
JP CONIN
JP CONOUT
JP LIST
JP AUXOUT
JP AUXIN
JP LISTST
ENDIF
DSEG ; Put the following areas in Data Segment
; Command processor address and length used when saving
; and restoring cached copy.
IF FASTWB
CPADR DEFS 2 ; Command processor address
CPLEN DEFS 2 ; Command processor length
ENDIF ;fastwb
;========================= End of WBOOT ============================