Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG #15B0 ; Put this after the previous version in the EPROM, to save an erase
- zeusemulate "CPM" ; Just a vanilla Z80 model with RAM at zero
- ; The ParaSys PIO ports
- ParaAD equ %0 xxxxx 0 0 ;
- ParaBD equ %0 xxxxx 0 1 ;
- ParaAK equ %0 xxxxx 1 0 ;
- ParaBK equ %0 xxxxx 1 1 ;
- ; The WD1772 ports
- FDCstatus EQU #C0 ;
- FDCcomm EQU #C0 ;
- ;
- FDCtrack EQU #C1 ;
- ;
- FDCsector EQU #C2 ;
- ;
- FDCdata EQU #C3 ;
- ;
- FDCdrive EQU #C4 ;
- ;
- FDCflags EQU #C4 ;
- ;
- cRestore EQU %0000 0000 ;
- cSeek EQU %0001 0000 ;
- cStepIn EQU %0101 0000 ;
- cStepOut EQU %0111 0000 ;
- cReadSec EQU %1000 1000 ;
- cWriteSec EQU %1010 1010 ;
- cReadAddr EQU %1100 0000 ;
- cReadTrack EQU %1110 0000 ;
- cWriteTrack EQU %1111 0010 ;
- ;
- bPrecomp EQU 1 ;
- ;
- errUW EQU #20 ;
- errUC EQU #21 ;
- errIDN EQU #12 ;
- errIT EQU #23 ;
- ;
- MotDel EQU 25000 ;
- ;
- dSelOr EQU 0 ;
- dSelAnd EQU 1 ;
- ;
- dcStepRate EQU 2 ;
- ;
- dcTrack EQU 3 ;
- ;
- dPrecomp EQU 4 ;
- ;
- iPhase EQU WindowA + 0 ;
- iCommand EQU WindowA + 1 ;
- iDrive EQU WindowA + 2 ;
- iTrack EQU WindowA + 3 ;
- iWind EQU WindowA + 4 ;
- iError EQU WindowA + 5 ;
- iSector EQU WindowA + 6 ;
- ;
- nCommands EQU 16 ;
- ;
- WindowA EQU #C000 ;
- WindowB EQU #D000 ;
- WindowC EQU #E000 ;
- WindowD EQU #F000 ;
- ; ParaSys Interface stuff
- bmPara_SS equ %0000 0 0 0 1 ;
- bmPara_MS equ %0000 0 0 1 0 ;
- bmPara_RESET equ %0000 0 1 0 0 ;
- bmPara_EXTRA equ %0000 1 0 0 0 ;
- ; ParaSys file commands
- PS8_ReadFileBlock equ $10 ;
- PS8_WriteFileBlock equ $11 ;
- PS8_SendFilename equ $12 ;
- YeStart JR Start ;
- ;
- DEFS 3,#FF ;
- ;
- Start LD SP,#C000 ;
- DI ;
- ;
- XOR A ;
- LD I,A ;
- ;
- CALL InitDrives ;
- ;
- CALL InitPort ;
- ;
- CALL ClearStatus ;
- ;
- call Ext_InitParaPort ; Setup ParaSys
- Loop mPS_SetStrobeDirns() ; Make sure the port pins are driven correctly
- mPS_RESET_H() ; Take the reset line high
- mPS_MS_H() ; And make sure the master strobe is high
- mPS_Extra_L() ; Take the EXTRA data line low again
- LoopFastWait LD A,(iPhase) ;
- CP #02 ;
- JR NZ LoopFastWait ;
- ;
- CALL Execute ;
- ;
- JR NC Loop1 ;
- ;
- LD (iError),A ;
- ;
- Loop1 LD HL,iPhase ;
- LD (HL),3 ;
- ;
- JR Loop ;
- ;
- Execute XOR A ;
- LD (iError),A ;
- ;
- LD A,(iCommand) ;
- LD B,A ;
- CP nCommands ;
- CCF ;
- LD A,errUC ;
- RET C ;
- ;
- LD A,B ;
- ADD A,A ;
- LD L,A ;
- LD H,0 ;
- ;
- LD DE,JumpTable ;
- ADD HL,DE ;
- ;
- LD A,(HL) ;
- INC HL ;
- LD H,(HL) ;
- LD L,A ;
- ;
- CallHL JP (HL) ;
- ;
- CallIY JP (IY) ;
- ;
- JumpTable DEFW TrackRead ;
- DEFW TrackWrite ;
- ;
- DEFW ShortRead ;
- DEFW ShortWrite ;
- ;
- DEFW FormatTrack ;
- DEFW FormatDisc ;
- ;
- DEFW EntireRead ;
- DEFW EntireWrite ;
- ;
- DEFW SectRead ;
- DEFW SectWrite ;
- ;
- DEFW WindowB ;
- DEFW WindowC ;
- DEFW WindowD ;
- dw Ext_SendFilename ;
- dw Reset ;
- DEFW 0 ;
- Reset di ;
- jp 0 ;
- ClearStatus LD HL,#C000 ;
- LD DE,#C001 ;
- LD BC,#FF ;
- LD (HL),0 ;
- LDIR ;
- RET ;
- ;
- CalcWind LD A,(iWind) ;
- LD HL,#D000 ;
- OR A ;
- RET Z ;
- ;
- LD HL,#E000 ;
- DEC A ;
- RET Z ;
- ;
- LD HL,#F000 ;
- DEC A ;
- RET Z ;
- ;
- SCF ;
- LD A,errUW ;
- RET ;
- ;
- GetTrack LD A,(iDrive) ;
- LD B,A ;
- CP 4 ;
- CCF ;
- LD A,errIDN ;
- RET C ;
- ;
- LD A,B ;
- OR A ;
- CALL Z SelectA ;
- DEC A ;
- CALL Z SelectB ;
- DEC A ;
- CALL Z SelectC ;
- DEC A ;
- CALL Z SelectD ;
- ;
- CALL StartMotor ;
- ;
- LD A,(iTrack) ;
- CALL Seek ;
- RET ;
- ;
- TrackRead ld a,(iDrive) ; Is this D0?
- or a ;
- jp nz Ext_TrackRead ; No, try the external
- CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- CALL Read4K ;
- ;
- RET ;
- ;
- TrackWrite ld a,(iDrive) ; Is this D0?
- or a ;
- jp nz Ext_TrackWrite ; No, try the external
- CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- CALL Write4K ;
- ;
- RET ;
- ;
- ShortRead CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- JP ReadShort ;
- ;
- SectRead CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- JP SectorRead ;
- ;
- ShortWrite CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- JP WriteShort ;
- ;
- SectWrite CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- JP SectorWrite ;
- ;
- EntireRead CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- JP ReadTrack ;
- ;
- EntireWrite CALL GetTrack ;
- RET C ;
- ;
- CALL CalcWind ;
- RET C ;
- ;
- JP WriteTrack ;
- ;
- FormatTrack CALL GetTrack ;
- RET C ;
- ;
- LD A,(iTrack) ;
- LD B,A ;
- ;
- RLCA ;
- AND #01 ;
- LD E,A ;
- ;
- LD A,B ;
- AND #7F ;
- LD D,A ;
- ;
- LD IX,FormatWS ;
- CALL FormatData ;
- RET C ;
- ;
- LD HL,FormatWS ;
- JP WriteTrack ;
- ;
- FormatDisc LD A,0 ;
- LD (iTrack),A ;
- ;
- FormatDisc1 CALL FormatTrack ;
- RET C ;
- ;
- LD A,(iTrack) ;
- RLCA ;
- INC A ;
- CP 160 ;
- JR Z FDexit ;
- RRCA ;
- LD (iTrack),A ;
- ;
- JR FormatDisc1 ;
- ;
- FDexit OR A ;
- RET ;
- ;
- FormatData PUSH IX ;
- PUSH BC ;
- PUSH AF ;
- ;
- LD HL,TrackDefnA ;
- LD C,1 ;
- ;
- CALL GenDataStr ;
- ;
- FDlp LD HL,TrackDefnB ;
- CALL GenDataStr ;
- ;
- LD A,C ;
- CP 6 ;
- JR NZ FDlp ;
- ;
- POP AF ;
- POP BC ;
- POP IX ;
- RET ;
- ;
- GenDataStr LD A,(HL) ;
- INC A ;
- RET Z ;
- ;
- DEC A ;
- LD B,A ;
- INC HL ;
- LD A,(HL) ;
- ;
- CP #F3 ;
- JR NC GDS1 ;
- ;
- CP #F0 ;
- JR C GDS1 ;
- ;
- LD A,D ;
- JR Z GDS1 ;
- ;
- LD A,(HL) ;
- CP #F1 ;
- ;
- LD A,E ;
- JR Z GDS1 ;
- ;
- LD A,C ;
- INC C ;
- ;
- GDS1 INC HL ;
- ;
- GDSlp LD (IX),A ;
- INC IX ;
- DJNZ GDSlp ;
- ;
- JR GenDataStr ;
- ;
- ReadShortI LD A,1 ;
- JP ReadSec ;
- ;
- SectorReadI LD A,(iSector) ;
- JP ReadSec ;
- ;
- Read4KI LD A,2 ;
- CALL ReadSec ;
- RET C ;
- ;
- LD A,3 ;
- CALL ReadSec ;
- RET C ;
- ;
- LD A,4 ;
- CALL ReadSec ;
- RET C ;
- ;
- LD A,5 ;
- CALL ReadSec ;
- RET ;
- ;
- WriteShortI LD A,1 ;
- CALL WriteSec ;
- RET C ;
- ;
- VeriShortI LD A,1 ;
- JP VeriSec ;
- ;
- SectorWriteI LD A,(iSector) ;
- CALL WriteSec ;
- RET C ;
- ;
- SectorVeriI LD A,(iSector) ;
- JP VeriSec ;
- ;
- Write4KI LD A,2 ;
- CALL WriteSec ;
- RET C ;
- ;
- LD A,3 ;
- CALL WriteSec ;
- RET C ;
- ;
- LD A,4 ;
- CALL WriteSec ;
- RET C ;
- ;
- LD A,5 ;
- CALL WriteSec ;
- RET C ;
- ;
- Veri4KI LD A,2 ;
- CALL VeriSec ;
- RET C ;
- ;
- LD A,3 ;
- CALL VeriSec ;
- RET C ;
- ;
- LD A,4 ;
- CALL VeriSec ;
- RET C ;
- ;
- LD A,5 ;
- CALL VeriSec ;
- ;
- RET ;
- ;
- WriteTrackI CALL PauseTR ;
- ;
- LD A,cWriteTrack ;
- ;
- CALL DoPrecomp ;
- ;
- OUT (FDCcomm),A ;
- ;
- CALL WriteData ;
- ;
- IN A,(FDCstatus) ;
- AND #44 ;
- SCF ;
- RET NZ ;
- ;
- CALL VeriShortI ;
- RET C ;
- ;
- CALL Veri4KI ;
- ;
- RET ;
- ;
- ReadTrackI CALL PauseTR ;
- ;
- LD A,cReadTrack ;
- ;
- CALL DoPrecomp ;
- ;
- OUT (FDCcomm),A ;
- ;
- CALL ReadData ;
- ;
- IN A,(FDCstatus) ;
- AND #14 ;
- SCF ;
- RET NZ ;
- ;
- OR A ;
- RET ;
- ;
- ReadShort LD IY,ReadShortI ;
- JR Repeat ;
- ;
- Read4K LD IY,Read4KI ;
- JR Repeat ;
- ;
- SectorRead LD IY,SectorReadI ;
- JR Repeat ;
- ;
- WriteShort LD IY,WriteShortI ;
- JR Repeat ;
- ;
- Write4K LD IY,Write4KI ;
- JR Repeat ;
- ;
- SectorWrite LD IY,SectorWriteI ;
- JR Repeat ;
- ;
- WriteTrack LD IY,WriteTrackI ;
- JR Repeat ;
- ;
- ReadTrack LD IY,ReadTrackI ;
- JR Repeat ;
- ;
- Repeat LD (DataTemp),HL ;
- LD B,4 ;
- ;
- rRTlp LD HL,(DataTemp) ;
- CALL CallIY ;
- RET NC ;
- ;
- DJNZ rRTlp ;
- ;
- RET ;
- ;
- ReadSec CALL PauseTR ;
- ;
- OUT (FDCsector),A ;
- ;
- LD A,cReadSec ;
- OUT (FDCcomm),A ;
- ;
- CALL ReadData ;
- ;
- IN A,(FDCstatus) ;
- AND #1C ;
- RET Z ;
- ;
- SCF ;
- RET ;
- ;
- VeriSec CALL PauseTR ;
- ;
- OUT (FDCsector),A ;
- ;
- LD A,cReadSec ;
- OUT (FDCcomm),A ;
- ;
- CALL VeriData ;
- ;
- IN A,(FDCstatus) ;
- AND #1C ;
- RET Z ;
- ;
- SCF ;
- RET ;
- ;
- WriteSec CALL PauseTR ;
- ;
- OUT (FDCsector),A ;
- ;
- LD A,cWriteSec ;
- ;
- CALL DoPrecomp ;
- ;
- OUT (FDCcomm),A ;
- ;
- CALL WriteData ;
- ;
- IN A,(FDCstatus) ;
- AND #5C ;
- RET Z ;
- ;
- SCF ;
- RET ;
- ;
- ReadData IN A,(FDCflags) ;
- OR A ;
- JR Z ReadData ;
- ;
- RET M ;
- ;
- IN A,(FDCdata) ;
- LD (HL),A ;
- INC HL ;
- JP ReadData ;
- ;
- VeriData IN A,(FDCflags) ;
- OR A ;
- JR Z VeriData ;
- ;
- RET M ;
- ;
- IN A,(FDCdata) ;
- JP VeriData ;
- ;
- WriteData IN A,(FDCflags) ;
- OR A ;
- JR Z WriteData ;
- ;
- RET M ;
- ;
- LD A,(HL) ;
- OUT (FDCdata),A ;
- INC HL ;
- JP WriteData ;
- ;
- StartMotor IN A,(FDCstatus) ;
- BIT 7,A ;
- RET NZ ;
- ;
- LD A,#D8 ;
- OUT (FDCcomm),A ;
- ;
- CALL PauseTR ;
- ;
- LD A,#D0 ;
- OUT (FDCcomm),A ;
- ;
- CALL PauseTR ;
- ;
- LD HL,MotDel ;
- SMlp CALL Delay ;
- DEC HL ;
- LD A,L ;
- OR H ;
- JR NZ SMlp ;
- ;
- RET ;
- ;
- PauseTR CALL Delay ;
- ;
- WaitTR PUSH AF ;
- WaitTRlp IN A,(FDCstatus) ;
- BIT 0,A ;
- JR NZ WaitTRlp ;
- POP AF ;
- ;
- Delay PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- PUSH IX ;
- POP IX ;
- RET ;
- ;
- DoPrecomp PUSH BC ;
- ;
- LD B,A ;
- ;
- IN A,(FDCtrack) ;
- CP (IX+dPrecomp) ;
- ;
- LD A,B ;
- ;
- POP BC ;
- ;
- RET C ;
- ;
- RES bPrecomp,A ;
- ;
- RET ;
- ;
- Seek PUSH IX ;
- PUSH AF ;
- ;
- CALL WaitTR ;
- ;
- BIT 7,A ;
- CALL NZ SideSel1 ;
- CALL Z SideSel0 ;
- ;
- LD IX,(pCurDrive) ;
- ;
- AND #7F ;
- JR Z SeekTRZ ;
- ;
- INC (IX+dcTrack) ;
- CALL Z initcT ;
- DEC (IX+dcTrack) ;
- ;
- CP 80 ;
- JR NC Seekf ;
- ;
- OUT (FDCdata),A ;
- ;
- LD (IX+dcTrack),A ;
- ;
- LD A,(IX+dcStepRate) ;
- AND %0000 0011 ;
- OR cSeek ;
- OUT (FDCcomm),A ;
- ;
- POP AF ;
- POP IX ;
- RET ;
- ;
- SeekTRZ LD A,(IX+dcStepRate) ;
- AND %0000 0011 ;
- OR cRestore ;
- OUT (FDCcomm),A ;
- ;
- LD (IX+dcTrack),0 ;
- ;
- POP AF ;
- POP IX ;
- RET ;
- ;
- initcT PUSH AF ;
- ;
- LD A,(IX+dcStepRate) ;
- AND %0000 0011 ;
- OR cRestore ;
- OUT (FDCcomm),A ;
- ;
- LD (IX+dcTrack),1 ;
- ;
- CALL PauseTR ;
- ;
- POP AF ;
- RET ;
- ;
- Seekf POP AF ;
- POP IX ;
- ;
- LD A,errIT ;
- SCF ;
- RET ;
- ;
- InitPort LD A,#9F ;
- LD (DiscPort),A ;
- ;
- OUT (FDCdrive),A ;
- ;
- RET ;
- ;
- SideSel0 PUSH BC ;
- ;
- LD BC,#10FF ;
- ;
- JP ModPort ;
- ;
- SideSel1 PUSH BC ;
- ;
- LD BC,#10EF ;
- ;
- ModPort PUSH AF ;
- ;
- LD A,(DiscPort) ;
- OR B ;
- AND C ;
- LD (DiscPort),A ;
- ;
- OUT (FDCdrive),A ;
- ;
- POP AF ;
- POP BC ;
- RET ;
- ;
- SelectA PUSH IX ;
- ;
- LD IX,DriveA ;
- ;
- ModDrive PUSH AF ;
- ;
- LD A,(DiscPort) ;
- ;
- OR (IX+dSelOr) ;
- AND (IX+dSelAnd) ;
- ;
- LD (DiscPort),A ;
- ;
- OUT (FDCdrive),A ;
- ;
- LD (pCurDrive),IX ;
- ;
- LD A,(IX+dcTrack) ;
- OUT (FDCtrack),A ;
- ;
- POP AF ;
- POP IX ;
- RET ;
- ;
- SelectB PUSH IX ;
- ;
- LD IX,DriveB ;
- ;
- JP ModDrive ;
- ;
- SelectC PUSH IX ;
- ;
- LD IX,DriveC ;
- ;
- JP ModDrive ;
- ;
- SelectD PUSH IX ;
- ;
- LD IX,DriveD ;
- ;
- JP ModDrive ;
- ;
- InitDrives LD HL,DriveData ;
- LD DE,DriveA ;
- LD BC,20 ;
- LDIR ;
- RET ;
- ;
- DriveData DEFB #0F,#FE ; Select
- DEFB 1 ; StepRate
- DEFB #FF ; cTrack
- DEFB 43 ; Precomp
- ;
- DEFB #0F,#FD ; Select
- DEFB 1 ; StepRate
- DEFB #FF ; cTrack
- DEFB 43 ; Precomp
- ;
- DEFB #0F,#FB ; Select
- DEFB 1 ; StepRate
- DEFB #FF ; cTrack
- DEFB 43 ; Precomp
- ;
- DEFB #0F,#F7 ; Select
- DEFB 1 ; StepRate
- DEFB #FF ; cTrack
- DEFB 43 ; Precomp
- ;
- TrackDefnA DEFB 80,#4E ;
- DEFB 12,#00 ;
- DEFB 3,#F6 ;
- DEFB 1,#FC ;
- ;
- DEFB 50,#4E ;
- DEFB 12,#00 ;
- DEFB 3,#F5 ;
- DEFB 1,#FE ;
- DEFB 1,#F0 ; Track
- DEFB 1,#F1 ; Side
- DEFB 1,#F2 ; Sector
- DEFB 1,#01 ;
- DEFB 1,#F7 ;
- DEFB 22,#4E ;
- DEFB 12,#00 ;
- DEFB 3,#F5 ;
- DEFB 1,#FB ;
- ;
- DEFB 0,#24 ; Header Data
- ;
- DEFB 1,#F7 ;
- DEFB 80,#4E ;
- DEFB 0,#4E ;
- ;
- TrackDefnB DEFB 12,#00 ;
- DEFB 3,#F5 ;
- DEFB 1,#FE ;
- DEFB 1,#F0 ; Track
- DEFB 1,#F1 ; Side
- DEFB 1,#F2 ; Sector
- DEFB 1,#03 ;
- DEFB 1,#F7 ;
- DEFB 22,#4E ;
- DEFB 12,#00 ;
- DEFB 3,#F5 ;
- DEFB 1,#FB ;
- ;
- DEFB 0,#24 ; Sector Data
- DEFB 0,#24 ; Sector Data
- DEFB 0,#24 ; Sector Data
- DEFB 0,#24 ; Sector Data
- ;
- DEFB 1,#F7 ;
- DEFB 80,#4E ;
- DEFB 0,#4E ;
- ;
- DEFB #FF ;
- ; New external drive support
- Ext_InitParaPort ld a,$00 ; Set the data line states to low
- out (ParaAD),a ;
- mMakeParaData_OUT() ;
- ld a,bmPara_MS or bmPara_RESET ; These high, all others low
- out (ParaBD),a ;
- mPS_SetStrobeDirns() ;
- ret ;
- ; We have to restore a logical track number. For historic reasons "iTrack" has the top bit as a "side" and bits 6..0 as cylinder
- ; So, the mapping of logical blocks 0..3 is iTrack values of $00,$80,$01,$81 (etc) which this converts back to logical blocks
- ; We just rotate it back into place to get consecutive blocks in the file
- Ext_GetTrack ld a,(iTrack) ; [side] [0 .. $7F]
- rlca ;
- ld (Ext_Track),a ; Save [0 .. $7F][side]
- or a ; NC
- ret ;
- ; Read a track
- Ext_TrackRead call Ext_GetTrack ;
- ret c ;
- CALL CalcWind ; To HL
- RET C ;
- jp Ext_Read4K ;
- ; Write a track
- Ext_TrackWrite call Ext_GetTrack ;
- ret c ;
- call CalcWind ; To HL
- ret c ;
- jp Ext_Write4K ;
- ; We want to read a track to (hl)
- Ext_Read4K ld a,0 ; Part 0
- ; Read the next part
- Ext_R4K_Lp ld (Ext_Part),a ;
- mPS_Extra_H() ; Take the EXTRA data line high
- ld a,PS8_ReadFileBlock ; Send the get command
- call WriteByte ; Send this byte
- mPS_Extra_L() ; Take the EXTRA data line low again
- ld a,(iDrive) ; Drive
- call WriteByte ; Send this byte
- ld a,(Ext_Track) ; Track
- call WriteByte ; Send this byte
- ld a,(Ext_Part) ; Part
- call WriteByte ; Send this byte
- ld b,32 ; This many pairs of bytes in a part
- call ReadMultiplePairs_HL ;
- ; Now, is there another part?
- ld a,(Ext_Part) ; Next part
- inc a ;
- cp $40 ; Done?
- jp nz Ext_R4K_Lp ; No, loop
- or a ; NC
- ret ; Done
- ; We want to write a track from (hl)
- Ext_Write4K ld a,0 ; Part 0
- ; Write the next part
- Ext_W4K_Lp ld (Ext_Part),a ;
- mPS_Extra_H() ; Take the EXTRA data line high
- ld a,PS8_WriteFileBlock ; Send the put command
- call WriteByte ; Send this byte
- mPS_Extra_L() ; Take the EXTRA data line low again
- ld a,(iDrive) ; Drive
- call WriteByte ; Send this byte
- ld a,(Ext_Track) ; Track
- call WriteByte ; Send this byte
- ld a,(Ext_Part) ; Part
- call WriteByte ; Send this byte
- ld b,32 ; This many pairs of bytes in a part
- call WriteMultiplePairs_HL ;
- ; Now, is there another part?
- ld a,(Ext_Part) ; Next part
- inc a ;
- cp $40 ; Done?
- jp nz Ext_W4K_Lp ; No, loop
- or a ; NC
- ret ; Done
- ; We want to send a filename
- Ext_SendFilename call CalcWind ; Where from? -> (hl)
- ret c ;
- mPS_Extra_H() ; Take the EXTRA data line high
- ld a,PS8_SendFilename ; Send the command
- call WriteByte ; Send this byte
- mPS_Extra_L() ; Take the EXTRA data line low again
- ld a,(iDrive) ; Drive
- call WriteByte ; Send this byte
- ; Send the string
- Ext_SF_Lp ld a,(hl) ; Next character
- inc hl ;
- call WriteByte ; Write one
- or a ; Done?
- jr nz Ext_SF_Lp ; No, loop
- ret ; Done
- ; Write AL
- WriteByte ld c,a ; Save the data
- mPS_MS_H() ; MS high
- mWaitForSS_H() ; Wait for the slave strobe to go high
- ld a,c ; Get the data
- out (ParaAD),a ;
- mMakeParaData_OUT() ; Make it an output
- mParaSettleDelay() ; Delay a bit
- mPS_MS_L() ; MS low
- mWaitForSS_L() ; Wait for the slave strobe to go low
- mPS_MS_H() ; MS high
- ld a,c ; Restore the byte
- ret ;
- ; Use both strobe edges to write a pair of bytes x b
- WriteMultiplePairs_HL mPS_MS_H() ; MS high
- mMakeParaData_OUT() ; Make it an output
- WMP_HL_Lp mWaitForSS_H() ; Wait for the slave strobe to go high
- ld a,(hl) ; Get the data
- out (ParaAD),a ;
- inc hl ; ++ and delay
- mPS_MS_L() ; MS low
- mWaitForSS_L() ; Wait for the slave strobe to go low
- ld a,(hl) ; Get the data
- out (ParaAD),a ;
- inc hl ; ++ and delay
- mPS_MS_H() ; MS high
- djnz WMP_HL_Lp ; Loop
- ret ;
- ; Read AL
- ReadByte mPS_MS_H() ; MS high
- mWaitForSS_H() ; Wait for the slave strobe to go high
- mMakeParaData_IN() ; Make it an input
- mPS_MS_L() ; MS low
- mWaitForSS_L() ; Wait for the slave strobe to go low
- mParaSettleDelay() ; Delay a bit
- in a,(ParaAD) ; Read the data
- ld c,a ; Save it
- mPS_MS_H() ; MS high
- ; mWaitForSS_H() ; Wait for the slave strobe to go high
- ld a,c ; Get the data
- ret ; Done
- ; Use both strobe edges to read a pair of bytes x b
- ReadMultiplePairs_HL mPS_MS_H() ; MS high
- mWaitForSS_H() ; Wait for the slave strobe to go high
- mMakeParaData_IN() ; Make it an input
- RMP_HL_Lp mPS_MS_L() ; MS low
- mWaitForSS_L() ; Wait for the slave strobe to go low
- mParaSettleDelay() ; Delay a bit
- in a,(ParaAD) ; Read the data
- ld c,a ; Save it
- mPS_MS_H() ; MS high
- mWaitForSS_H() ; Wait for the slave strobe to go high
- ld (hl),c ; Store it (and delay)
- inc hl ;
- in a,(ParaAD) ; Read the data
- ld (hl),a ; Store it
- inc hl ;
- djnz RMP_HL_Lp ; Loop
- ret ;
- ; Macros - BE CAREFUL! These shouldn't alter any register but AF
- mMakeParaData_OUT macro() ;
- ld a,$FF ;
- out (ParaAK),a ;
- xor a ;
- out (ParaAK),a ;
- mend ;
- mParaSettleDelay macro() ;
- nop ;
- mend ;
- mMakeParaData_IN macro() ;
- ld a,$FF ;
- out (ParaAK),a ;
- out (ParaAK),a ;
- mend ;
- ; Set the strobe directions
- mPS_SetStrobeDirns macro()
- ld a,$FF ;
- out (ParaBK),a ;
- ld a,bmPara_SS ; Only this one is an input
- out (ParaBK),a ;
- mend
- mWaitForSS_H macro() ;
- Lp in a,(ParaBD) ;
- and a,bmPara_SS ;
- jp z Lp ;
- mend ;
- mWaitForSS_L macro() ;
- Lp in a,(ParaBD) ;
- and a,bmPara_SS ;
- jp nz Lp ;
- mend ;
- mPS_MS_L macro() ;
- in a,(ParaBD) ;
- and a,bmPara_MS xor $FF ;
- out (ParaBD),a ;
- mend ;
- mPS_MS_H macro() ;
- in a,(ParaBD) ;
- or a,bmPara_MS ;
- out (ParaBD),a ;
- mend ;
- mPS_RESET_L macro() ;
- in a,(ParaBD) ;
- and a,bmPara_RESET xor $FF ;
- out (ParaBD),a ;
- mend ;
- mPS_RESET_H macro() ;
- in a,(ParaBD) ;
- or a,bmPara_RESET ;
- out (ParaBD),a ;
- mend ;
- mPS_Extra_L macro() ;
- in a,(ParaBD) ;
- and a,bmPara_EXTRA xor $FF ;
- out (ParaBD),a ;
- mend ;
- mPS_Extra_H macro() ;
- in a,(ParaBD) ;
- or a,bmPara_EXTRA ;
- out (ParaBD),a ;
- mend ;
- YeEnd equ * ;
- ORG #4000 ;
- Ext_Track ds 1 ;
- Ext_Part ds 1 ;
- DriveA DEFS 5 ;
- ;
- DriveB DEFS 5 ;
- DriveC DEFS 5 ;
- ;
- DriveD DEFS 5 ;
- DiscPort DEFS 1 ;
- pCurDrive DEFS 2 ;
- DataTemp DEFS 2 ;
- cPrecompBit DEFS 1 ;
- FormatWS DEFS #1B00 ;
- output_para YeStart,YeEnd-YeStart;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement