Sprinter-BIOS/bios/exp/EXTENDED/RAM_DISK_DRIVER.asm
2026-05-19 18:51:51 +10:00

191 lines
4.6 KiB
NASM
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;!TODO ᤥ« âì ¢ë¡®à à ¬¤à ©¢  ¯® §­ ç¥­¨î bit 0..3 ॣ¨áâà  €
; ­ ¯à¨¬¥à: A = #6E ®§­ ç ¥â: 6 - RAM Drive, #E - ¤¨áª E:
;
;[]===========================================================[]
;Function: Set Current Media Parameters
; A - Disk
; H - Heads
; L - Sectors
; DE - Cylinders
; IX - Capacity sector in bytes
; B - Flags
;Return: None
;[]===========================================================[]
;!FIXIT
RMD_5x_SET_PAR:
and a
ret
; A - Disk
; H - Heads
; L - Sectors
; DE - Cylinders
; IX - Capacity sector in bytes
; B - Flags
; DB 'E' - 'A' = 4
;
;
;
;[]===========================================================[]
;Function: Get Current Media Parameters
; A - Disk
;Return:
; H - Heads
; L - Sectors per cylinder
; DE - Cylinders
; IX - Capacity sector in bytes
; B - Flags: ramblock ID
;[]===========================================================[]
RMD_5x_GET_PAR: AND #0F
CALL GET_RAMD_ST ; ¯®«ã祭¨¥ ¨¤¥­â¨ä¨ª â®à  ¡«®ª 
RET C
SCF
RET Z
;
LD C,A
LD B,#FF
.loop: INC B
PUSH BC
LD A,C
CALL EMM.GetMemPage ; ¯®«ãç¨âì 䨧¨ç¥áª¨© ­®¬¥à áâà ­¨æë ¨§ ¡«®ª 
POP BC
JR NC,.loop
; CF==1, A==0 - ®è¨¡ª , A==#FF - ok
INC A
RET NZ ; ¥á«¨ ¢ë室¨â, â® á ä« £ ¬¨ CF==1, ZF==1
;
LD E,B
LD B,C
; âãâ ¢ E ª®«¨ç¥á⢮ áâà ­¨æ ¢ à ¬¤¨áª¥, B - ID à ¬¤¨áª 
LD HL,1*256 + #4000/.SectorSize
LD D,0
LD IX,.SectorSize
XOR A
INC A ; removable media. CF=0, LD A,1
RET
;
.SectorSize EQU 512 ;!HARDCODE
////////////////////////////////////////////////////////////////////////////////////
RMD_5x_LONG_WRITE:
LD C,#FF
JP RAM_DRV_READ_WRITE
RMD_5x_LONG_READ:
LD C,0
JP RAM_DRV_READ_WRITE
RMD_5x_WRITE:
LD C,#FF
JP RAM_DRV_NO_LONG
RMD_5x_READ:
LD C,0
;JP RAM_DRV_NO_LONG
RAM_DRV_NO_LONG:
EX AF,AF'
IN A,(SLOT3)
EX AF,AF'
; <20>€ ¢å®¤¥ ॣ = 0 ¥á«¨ ç⥭¨¥, «¨¡® #FF, ¥á«¨ § ¯¨áì
RAM_DRV_READ_WRITE:
PUSH HL
PUSH AF
LD L,B
IN A,(SLOT3)
LD H,A
; LD A,H
; OR L
; JR NZ,.error_stack2 ; if sector_high > 0
; POP AF
POP AF
EX (SP),HL
PUSH AF
LD A,H
OR L
JR NZ,.error_stack2 ; if sector_high > 0
POP AF
EX AF,AF'
OUT (SLOT3),A
LD A,C ; ¢ ॣ C ª®¬ ­¤  ç⥭¨ï ¨«¨ § ¯¨á¨
EX AF,AF'
; A' = command
PUSH BC ; Sector_counter
PUSH DE ; Address
PUSH IX ; Sector_low
AND #0F ;­®¬¥à à ¬¤¨áª 
;LD C,BIOS.GET_RAMD_ST
;RST_to_BIOS
CALL GET_RAMD_ST
; A = Memory Block ID
POP DE ; Sector_low
POP HL ; Address
POP BC ; Sector_counter
JR C,.error_stack1
SLA E
RL D ; Sector_low * 2
JR C,.error_stack1
PUSH BC
SLA B ; Sector_counter * 2 - ⨯  ã ¤¨áª¥âë ᥪâ®à 512 ¡ ©â®¢
JR C,.error_stack2
PUSH DE
//PUSH BC
;LD C,BIOS.BLK_RD_WR
;RST_to_BIOS
CALL BLK_RD_WR
JR C,.error_stack3
; hl = address + Sector_low * 256 * Sector_counter
//POP BC
//SRL B
POP DE
; de = Sector_low * 2
SRL D
RR E
; de = Sector_low
POP BC
; b = Sector_counter
LD A,E
ADD A,B
LD E,A
LD A,D
ADC A,0
LD D,A
; de = Sector_counter + Sector_low
PUSH DE
POP IX
; ix = Sector_counter + Sector_low
EX DE,HL
; de = address + Sector_low * 256 * Sector_counter
LD HL,0
POP AF
OUT (SLOT3),A
AND A
;Return:
; HL:IX - Sector + Sector counter
; DE - Address + (Sector counter * Size sector)
RET
.error_stack3:
POP BC
.error_stack2:
POP DE
.error_stack1:
POP AF
OUT (SLOT3),A
SCF
RET
////////////////////////////////////////////////////////////////////////////////////