Files
RomWBW/Source/BPBIOS/ramd-dx.z80
2015-03-23 01:50:45 +00:00

112 lines
3.3 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.
;===============================================************************
; RAM Disk Driver. ** Hardware Specific **
; D-X Designs Pty Ltd P112 ************************
;
; 1.1 - 28 Jul 01 - Updated to latest fix for external driver. HFB
; 1.0 - 10 Jun 96 - Initial Release for P112 from YASBEC. HFB
;=======================================================================
CSEG
IF BANKED
COMMON /BANK2/
ENDIF
; This module creates a RAM Drive using the available memory (if available)
; above the TPA and possible System banks. For a banked system, the minimum
; needed is a 64k Main TPA and a 32k System Bank.
;.....
; Select the RAM Drive. This routine performs any setup required in a select.
SELRAM: JP SETPARMS ; No action locally.
;.....
; Read a 128-byte logical sector from the RAM Drive to main memory.
; This routine uses the HSTxxx values from the base BIOS routines.
RAMRD: OR 0FFH ; Set Read flag (non-0)
JR RamRW ; ..go to common code
;.....
; Write a 128-byte logical sector from main memory to the RAM Drive.
; This routine uses the HSTxxx values from the base BIOS routines.
RAMWR: XOR A ; Set Write flag with 0, Read w/AFH
LD (HSTWRT),A ; clear pending write flag
;..fall thru to common code..
; The following performs calculations for the proper address and bank, sets
; the DMA block and executes the Move to/from the Host Buffer.
RamRW: PUSH AF ; Save R/W flag for later
LD A,(RAMBNK) ; Get 1st Bank of Ram Drive
ADD A,A
ADD A,A ; .converting
ADD A,A ; ..to DMA Bank addr
LD HL,HSTTRK ; Point to Track #
ADD A,(HL) ; ..and add in
LD HL,0000 ; ..prepare address
LD B,4
SHFTR: SRL A ; Shift low 4 bits
RR H ; ..to high of H
DJNZ SHFTR
LD C,A ; Save High byte of A
LD A,(HSTSEC) ; Get sector #
SRL A
RR L ; .multiply by 128
ADD A,H ; Add Remaining High bits to MSB of address
LD H,A ; ..and store Addr
LD A,C ; Get Bank #
ADC A,0 ; .adjust for possible overflow
LD C,A ; ..and re-save
IF BANKED
LD A,(SYSBNK) ; Point to system bank for HSTBUF
ELSE
LD A,(TPABNK) ; Point to TPA bank if Unbanked
ENDIF
LD DE,HSTBUF ; Point to Host Buffer
RL D ; Place MSB of address in Carry
ADC A,0 ; .add to Bank Number
RRA ; Shift Bnk # to DMA Bank Byte (LSB to Carry)
LD B,A ; ..and place in destination register
RR D ; Bank # LSB (Carry) to Address MSB
POP AF ; Read or Write?
JR NZ,RAMRD0 ; ..jump if Read
EX DE,HL ; Else swap things around
LD A,C
LD C,B
LD B,A
RAMRD0: LD (RAMSRC),HL ; Stuff values in DMA block
LD A,C
LD (RAMSRC+2),A
LD (RAMDST),DE
LD A,B
LD (RAMDST+2),A
LD HL,128 ; ..including length of move
LD (MLEN),HL
; Set the Z-180 registers and start the move
LD HL,RAMSRC ; Point to the DMA Control block
CALL DMAMOV ; .and use the Z-180 DMA to move
XOR A ; Return Ok status
RET
;.....
; We need a little data area to set a DMA control block. Put in scratch RAM
IF BANKED
COMMON /B2RAM/
ELSE
DSEG
ENDIF
RAMSRC: DEFS 2 ; Address of Source
DEFS 1 ; .Bank of Source
RAMDST: DEFS 2 ; Address of Destination
DEFS 1 ; .Bank of Destination
MLEN: DEFS 2 ; Length of Data Area to move
;================== End of RAM Disk Code ====================