mirror of
https://github.com/wwarthen/RomWBW.git
synced 2026-02-06 22:43:15 -06:00
183 lines
5.4 KiB
Z80 Assembly
183 lines
5.4 KiB
Z80 Assembly
;:::::::::::::::::::::::::::::::::::::::************************************
|
||
; Warm Boot Routine *** Machine Dependant for Moves ***
|
||
; - D-X Designs Pty Ltd P112 - *** and custom load formatting ***
|
||
; ************************************
|
||
; 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
|
||
IF FASTWB
|
||
LD HL,SARL ; Point to DMA Initialization block
|
||
WBOOTV: CALL DMAMOV
|
||
XOR A ; Indicate "A" logged as Host Disk
|
||
LD (HSTDSK),A ; ..by showing Host Disk already logged
|
||
ELSE
|
||
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)
|
||
IF BANKED
|
||
LD HL,CPYVEC ; Copy Page0 Vectors and RSTs to System Bank
|
||
CALL DMAMOV
|
||
LD A,(TPABNK) ; Set all Bank regs to TPA
|
||
LD (SRCBNK),A
|
||
LD (DSTBNK),A
|
||
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
|
||
JP (HL) ; Go to Z-System for further processing
|
||
|
||
;.....
|
||
; Common DMA move sequence placed here in CSEG for Common access
|
||
; Enter with HL pointing to a DMA definition block
|
||
|
||
IF [BANKED OR FASTWB OR RAMDSK]
|
||
DMAMOV: LD BC,8*256+SAR0L ; Send 8 bytes to Ports SAR0L
|
||
OTIMR
|
||
LD A,00000010B ; Set DMA Mode control to Burst Mode
|
||
OUT0 (DMODE),A
|
||
LD A,40H ; Enable DMA0
|
||
OUT0 (DSTAT),A ; ..and move the block
|
||
RET
|
||
ENDIF
|
||
|
||
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
|
||
|
||
; This table in unitialized RAM is filled from the Cold Boot module.
|
||
|
||
IF FASTWB
|
||
SARL: DEFS 2 ; Source Segment address
|
||
DEFS 1 ; Source Bank Number
|
||
DEFS 2 ; Destination Segment address
|
||
DEFS 1 ; Destination Bank Number (TPA)
|
||
DEFS 2 ; Number of bytes to move
|
||
ENDIF ;fastwb
|
||
|
||
; This table is used to copy Page 0 vectors from TPA to base of System bank
|
||
; on Warm Boots to insure that needed IO can vector to the correct devices.
|
||
|
||
IF BANKED
|
||
CPYVEC: DEFS 2 ; Offset of Source area
|
||
DEFS 1 ; ..Source Bank (Base of TPA) [BNK0 SHR 1]
|
||
DEFS 2 ; Offset of Destination
|
||
DEFS 1 ; ..Dest Bank (Base of System Bank) [BNK2 SHR 1]
|
||
DEFS 2 ; Length of move
|
||
ENDIF
|
||
;========================= End of WBOOT ============================
|
||
|