This commit is contained in:
Anatoliy Belyanskiy 2024-04-13 02:17:04 +10:00
parent 8448dbef48
commit 9b975b7a88
10 changed files with 317 additions and 307 deletions

View File

@ -21,8 +21,6 @@
;R004 19-11-2002 DNS DON'T ALLOW DIR & LABEL ATTR FOR FILES
;R003 19-11-2002 DNS ADD RESET OF VOLUME LABEL ATTRIBUT
;R002 19-11-2002 DNS FIX GET/SET ATTRIBUTES
;R08 14-11-2002 DNS IMPROVE BPB-FUNCTION
;R07 17-12-1999 DNS BUG FIX SIGNATURE #55AA AT 510 OFFSET
;R001 16-12-1999 DNS Y2K fix
;R06 21-11-1999 DNS FN. DISKINF SUPPORT ALL DISKS
;R05 21-11-1999 DNS BUG FIX SIGNATURE #55AA IN BOOT SECTOR

View File

@ -36,7 +36,7 @@ DISKINF: LD C,B
LD B,1
;
CP #80
JR C,.CustomDisk
JP C,.CustomDisk
CP #FF
JR Z,.CurrentDisk
; more info
@ -54,26 +54,31 @@ DISKINF: LD C,B
PUSH BC
;;;;
;
LD A,(FatBuffer.FAT_TYPE)
CP FAT_TYPE.x32
;
EX DE,HL
LD HL,CORE_BUFFERS.BootSector.ID_FAT
JR NZ,1F
LD HL,CORE_BUFFERS.BootSector + _sBOOT_SECTOR_PARAMS_FAT32.ID_FAT
1: LD C,8 ;!HARDCODE _sBOOT_SECTOR_PARAMS.ID_FAT.length
LD HL,FAT_STRING
1: LD C,5 ;!HARDCODE _sBOOT_SECTOR_PARAMS.ID_FAT.length
CALL .mCOPY_LOOP
; 12, 16 or 32
LD A,(FatBuffer.FAT_TYPE)
CP FAT_TYPE.x16
JR C,.next_prm
;
PUSH DE
DEC DE
LD A,'6'
JR Z,.put_char
; fat 32
DEC DE
LD A,'3'
.put_char: LD (DE),A
POP DE
;
.next_prm: LD HL,FatBuffer.BPB_SERIAL_NUMBER
LD C,4 ;!HARDCODE _sBOOT_SECTOR_PARAMS.BPB_SERIAL_NUMBER
CALL .mCOPY_LOOP
;
LD HL,CORE_BUFFERS.BootSector.BPB_SERIAL_NUMBER
JR NZ,1F
LD HL,CORE_BUFFERS.BootSector + _sBOOT_SECTOR_PARAMS_FAT32.BPB_SERIAL_NUMBER
1: LD C,4 ;!HARDCODE _sBOOT_SECTOR_PARAMS.BPB_SERIAL_NUMBER
CALL .mCOPY_LOOP
;
LD HL,CORE_BUFFERS.BootSector.BPB_LABEL
JR NZ,1F
LD HL,CORE_BUFFERS.BootSector + _sBOOT_SECTOR_PARAMS_FAT32.BPB_LABEL
1: LD C,11 ;!HARDCODE _sBOOT_SECTOR_PARAMS.BPB_LABEL
LD HL,FatBuffer.BPB_LABEL
LD C,11 ;!HARDCODE _sBOOT_SECTOR_PARAMS.BPB_LABEL
CALL .mCOPY_LOOP
; fat32
EXX
@ -187,4 +192,4 @@ DISKINF: LD C,B
LDIR
RET
;
;
FAT_STRING: DB 'FAT12'

View File

@ -20,17 +20,6 @@
;R01 20-11-1998 DNS REPAIR FUNCTION "SAVE"
;---------------------------------------------------------------
;[BEGIN]
;//MODULE: FAT_X
;//CREATE: 19-05-1998 AUTHOR: Denis Parinov
;//UPDATE: 24-10-1999 DNS Restore module
;---------------------------------------------------------------
;Rev Date Name Description
;---------------------------------------------------------------
;RX01 10-02-1999 DNS UPGRADE FAT CASH
;---------------------------------------------------------------
;----------------------------------------------------------------------;
; HL - 11 bytes filename "FILENAMEEXT"
; DE - DOS filename "FILENAME.EXT",0

View File

@ -405,7 +405,7 @@ BUFFERSplace _sBuffers=$
FM_BUF _sFM = BUFFERSplace.FileManipulator
.Size EQU _sFM
.FullSize EQU FMCOUNT*FM_BUF.Size
BootSector _sBOOT_SECTOR_PARAMS = BUFFERSplace.BootSector
BootSector _sBOOT_SECTOR_PARAMS = BUFFERSplace.BootSector ; [ ] fat32 ;!FIXIT CORE_BUFFERS.BootSector à §­®© ¤«¨­ë
EXEBUFF _sEXE_HEADER = BUFFERSplace.EXE_Header
XSTACK EQU BUFFERSplace.Stack.SPoint
BUFFER EQU BUFFERSplace.Buffer
@ -414,12 +414,13 @@ SECBUF EQU BUFFER ;!TODO
CLEAR_ZONE.size EQU _sBuffers
ASSERT (CORE_BUFFERS.BUFFERSplace+_sBuffers)<#4000, "Warning!!! OUT OF SLOT0"
;DISPLAY "--- --- --- --- --- --- --- ---"
;DISPLAY "BUFFERSplace.BootSector ",/H,CORE_BUFFERS.BUFFERSplace.BootSector
;DISPLAY "BootSector ", /H, CORE_BUFFERS.BootSector
;DISPLAY "EXEBUFF ", /H, CORE_BUFFERS.EXEBUFF
;DISPLAY "Size ", /H, CORE_BUFFERS.EXEBUFF - CORE_BUFFERS.BootSector
;DISPLAY "--- --- --- --- --- --- --- ---"
DISPLAY "--- --- --- --- --- --- --- ---"
DISPLAY "BUFFERSplace.BootSector ",/H,CORE_BUFFERS.BUFFERSplace.BootSector
DISPLAY "BootSector ", /H, CORE_BUFFERS.BootSector
DISPLAY "BootSector.Size ", /D, CORE_BUFFERS.EXEBUFF - CORE_BUFFERS.BootSector
DISPLAY "EXEBUFF ", /H, CORE_BUFFERS.EXEBUFF
DISPLAY "Size ", /H, CORE_BUFFERS.EXEBUFF - CORE_BUFFERS.BootSector
DISPLAY "--- --- --- --- --- --- --- ---"
/*

View File

@ -5,9 +5,9 @@
;---------------------------------------------------------------
;Rev Date Name Description
;---------------------------------------------------------------
;RX01 10-02-1999 DNS UPGRADE FAT CASH
;R08 14-11-2002 DNS IMPROVE BPB-FUNCTION
;R07 17-12-1999 DNS BUG FIX SIGNATURE #55AA AT 510 OFFSET
;---------------------------------------------------------------
;----------------------------------------------------------------------;
; <20>®¨áª § ¯¨á¨ ª â «®£  ¢ ᯨ᪥ ª â «®£ 
;
@ -611,7 +611,7 @@ WRT_HND: SET_PAGE_X DIRPAGE
; RET Z
; ॣ. D - ­®¬¥à ¤¨áª 
; ॣ. A - ­®¬¥à ¤¨áª 
; [ ] fat32
RD_BPB: LD C,SLOT3
IN B,(C)
@ -625,58 +625,75 @@ RD_BPB: LD C,SLOT3
POP BC
OUT (C),B
JP C,DOS_X_Error.Not_ready
;
LD DE,#AA55 ; ᨣ­ âãà  ;R05
LD HL,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR.MBR_SIGNATURE) ;R08 ;R07
;R05
AND A
SBC HL,DE
JP NZ,DOS_X_Error.UnknownBPB
;R08
LD HL,CORE_BUFFERS.SECBUF
LD DE,CORE_BUFFERS.BootSector
LD BC,_sBOOT_SECTOR_PARAMS ; size
LDIR
;
LD A,(CORE_BUFFERS.BootSector.DRIVE_TYPE)
; ;R08 ; [x] fat32
; LD HL,CORE_BUFFERS.SECBUF
; LD DE,CORE_BUFFERS.BootSector
; LD BC,_sBOOT_SECTOR_PARAMS_FAT32 ; size
; LDIR
;
LD A,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.DRIVE_TYPE)
CP #F0
JP C,DOS_X_Error.UnknownBPB
; calc. first sector FAT
LD HL,(CORE_BUFFERS.BootSector.RESERVED_SECTORS)
LD HL,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.RESERVED_SECTORS)
;
; LD E,(IY+_sBOOT_SECTOR_PARAMS.HIDDEN) ;Hidden sec
; LD D,(IY+_sBOOT_SECTOR_PARAMS.HIDDEN+1)
; ADD HL,DE
;
;!FIXIT ¤«ï fat32 ¢â몠âì á ᥪâ®à   ªâ¨¢­®© â ¡«¨æë
LD (FatBuffer.FAT1_SEC_L),HL ; low word first sector FAT #1
LD (FatBuffer.FAT2_SEC_L),HL ; low word first sector FAT #2
;[ ] fat32 ;!FIXIT
;[ ] fat32
XOR A
LD D,A
LD E,A
LD (FatBuffer.FAT1_SEC_H),DE ; high word first sector FAT #1
LD (FatBuffer.FAT2_SEC_H),DE ; high word first sector FAT #1
LD (FatBuffer.RootDirStartCluster_L),DE
LD (FatBuffer.RootDirStartCluster_H),DE
LD (FatBuffer.SectorsPerFAT_H),A
LD B,A
LD C,A
LD (FatBuffer.FAT1_SEC_H),BC ; high word first sector FAT #1 ; [ ] fat32
LD (FatBuffer.FAT2_SEC_H),BC ; high word first sector FAT #1 ; [ ] fat32
LD (FatBuffer.RootDirStartCluster_L),BC ; [ ] fat32
LD (FatBuffer.RootDirStartCluster_H),BC ; [ ] fat32
LD (FatBuffer.END_CHAIN_CLUSTER_H),BC ; [ ] fat32 reset variables
LD (FatBuffer.MaxClusterHigh),BC ; [ ] fat32 reset variables
LD (FatBuffer.SectorsPerFAT_H),A ; [ ] fat32
;
;
LD DE,(CORE_BUFFERS.BootSector.SectorsPerFAT16)
LD (FatBuffer.SectorsPerFAT_L),DE
LD DE,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.SectorsPerFAT16)
LD A,E
OR D
JR NZ,.skip_high
;
LD A,(CORE_BUFFERS.BootSector.Number_of_FATs) ; amount FATs
LD BC,(CORE_BUFFERS.BootSector + _sBOOT_SECTOR_PARAMS_FAT32.FAT32.SectorsPerFAT32+4)
LD (FatBuffer.SectorsPerFAT_H),BC
LD DE,(CORE_BUFFERS.BootSector + _sBOOT_SECTOR_PARAMS_FAT32.FAT32.SectorsPerFAT32)
.skip_high: LD (FatBuffer.SectorsPerFAT_L),DE
;
LD A,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.Number_of_FATs) ; amount FATs
CP 1
JR Z,.loop1
JR Z,.one_FAT
DEC A
ADD HL,DE
LD (FatBuffer.FAT2_SEC_L),HL
;C_DATA1
JR NC,.no_inc_BC
INC BC
.no_inc_BC: LD (FatBuffer.FAT2_SEC_H),BC
.one_FAT: ;C_DATA1
.loop1: ADD HL,DE
DEC A
JR NC,.loop1_1
INC BC
.loop1_1: DEC A
JR NZ,.loop1
;
LD (FatBuffer.RootDirFirstSector_L),HL ; first sector DIR
LD BC,(CORE_BUFFERS.BootSector.BytesPerSector)
LD BC,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.BytesPerSector)
LD A,B
AND A
;
@ -695,7 +712,7 @@ RD_BPB: LD C,SLOT3
ENDIF
;
EX DE,HL
LD HL,(CORE_BUFFERS.BootSector.FilesInRootDIR) ; 0 for fat32
LD HL,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.FilesInRootDIR) ; 0 for fat32
DEC HL ; [ ]fat32
XOR A
;NEXTAD2
@ -708,12 +725,13 @@ RD_BPB: LD C,SLOT3
LD C,A ; A - sectors in DIR
LD B,0
LD (FatBuffer.DirSizeInSectors),A
ADD HL,BC ; Start DATA area
LD (FatBuffer.FirstDataSector_L),HL
; B = 0
;
LD HL,(CORE_BUFFERS.BootSector.BytesPerSector)
LD A,(CORE_BUFFERS.BootSector.SectorsPerCluster)
LD HL,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.BytesPerSector)
LD A,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.SectorsPerCluster)
;!TODO FATcacheSize
; calc. cluster size
XOR 1
@ -722,9 +740,9 @@ RD_BPB: LD C,SLOT3
.loop3: ADD HL,HL
RRA
JP NC,.loop3
.loop3.end:
;
.loop3.end: ;
LD (FatBuffer.BytesPerCluster),HL
;
IF COMPILE_UNUSED_CODE
EX DE,HL
LD HL,#3FFF ;!HARDCODE ;!TODO FATcacheSize
@ -738,13 +756,9 @@ RD_BPB: LD C,SLOT3
ENDIF
;
;!TODO detect fat type by clusters!
;[ ] fat32 reset fat32 variables
LD HL,0
LD (FatBuffer.ENDCLUS_HIGH),HL
LD (FatBuffer.MaxClusterHigh),HL
;
LD HL,CORE_BUFFERS.BootSector.ID_FAT ;!!!!!   ¥á«¨ IY ¨á¯®«ì§ã¥âáï ¤«ï ¯¥à¥¬¥­­®£® BootSector, â® ¡ã¤¥â ¡ £ 
LD DE,FatBuffer.MSG
; [ ] fat32
LD HL,CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.FAT16.ID_FAT ;!!!!!   ¥á«¨ IY ¨á¯®«ì§ã¥âáï ¤«ï ¯¥à¥¬¥­­®£® BootSector, â® ¡ã¤¥â ¡ £ 
LD DE,FAT_STRING
LD B,3
;R_BPBL1
.loop5: LD A,(DE)
@ -764,10 +778,10 @@ RD_BPB: LD C,SLOT3
JP Z,.fat1x
CP '3'
JP NZ,DOS_X_Error.UnknownBPB
LD A,#46 ; #46-#26 = 32 fat type
LD A,#52 ; #52-#20 = #32 fat type
LD HL,#0FFF
LD (FatBuffer.ENDCLUS_HIGH),HL
LD (FatBuffer.MaxClusterHigh),HL
LD (FatBuffer.END_CHAIN_CLUSTER_H),HL
LD (FatBuffer.MaxClusterHigh),HL ; [ ] fat32 ;!FIXIT
LD H,L
JR .BPB_FAT
;
@ -778,10 +792,9 @@ RD_BPB: LD C,SLOT3
CP '6' ; FAT12
JP NZ,DOS_X_Error.UnknownBPB
LD H,L
.BPB_FAT:
SUB #26 ; A-#26 = fat type (12, 16, 32)
.BPB_FAT: SUB #20 ; A-#20 = fat type (#12, #16, #32)
LD (FatBuffer.FAT_TYPE),A
LD (FatBuffer.ENDCLUS_LOW),HL
LD (FatBuffer.END_CHAIN_CLUSTER_L),HL
;!TODO ­¥ ¨á¯®«ì§ã¥âáï §­ ç¥­¨¥ ¢ëç¨á«ï¥¬®¥ ¨ á®å࠭塞®¥ ¢ FatBuffer
////////////////////////////////////////////////////////////////////////
; LD HL,0
@ -794,14 +807,14 @@ RD_BPB: LD C,SLOT3
; LD (FatBuffer.S_X_H),HL
////////////////////////////////////////////////////////////////////////
; [ ] fat32
LD HL,(CORE_BUFFERS.BootSector.SectorsPerDrive)
LD HL,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.SectorsPerDrive)
LD DE,(FatBuffer.FirstDataSector_L)
LD A,H
OR L
JP NZ,.HDDSMAL
;
LD HL,(CORE_BUFFERS.BootSector.BPB_BIG_TOTAL_SECTORS_L)
LD BC,(CORE_BUFFERS.BootSector.BPB_BIG_TOTAL_SECTORS_H)
LD HL,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.BPB_BIG_TOTAL_SECTORS_L)
LD BC,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.BPB_BIG_TOTAL_SECTORS_H)
AND A
SBC HL,DE
JP NC,.HDDBIG
@ -811,7 +824,7 @@ RD_BPB: LD C,SLOT3
.HDDSMAL: ; CF = 0
SBC HL,DE
LD BC,0
.HDDBIG: LD A,(CORE_BUFFERS.BootSector.SectorsPerCluster)
.HDDBIG: LD A,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.SectorsPerCluster)
SCF
.S4C01: RRA
JR C,.S4C02
@ -844,8 +857,7 @@ RD_BPB: LD C,SLOT3
XOR A
RET
;!TODO detect fat type by clusters!
.IBM_DOS:
LD A,(CORE_BUFFERS.BootSector.DRIVE_TYPE)
.IBM_DOS: LD A,(CORE_BUFFERS.SECBUF + _sBOOT_SECTOR_PARAMS.DRIVE_TYPE)
CP #F0
JR C,DOS_X_Error.UnknownBPB
; ID ram-¤¨áª  - #FA
@ -859,19 +871,18 @@ RD_BPB: LD C,SLOT3
JP .BPB_FAT
;
DOS_X_Error:
.UnknownBPB:
LD A,DSS_Error.sys.UNKNOWN_FORMAT
.UnknownBPB: LD A,DSS_Error.sys.UNKNOWN_FORMAT
SCF
RET
.Not_ready:
LD A,DSS_Error.sys.NOT_READY
;
.Not_ready: LD A,DSS_Error.sys.NOT_READY
; CF = 1
RET
;
;
;!TODO ª ¡ãä¥à ¬!
FatBuffer:
.MSG: DB 'FAT'
;.MSG: DB 'FAT'
.DRIVE: DB #FF
.FAT_TYPE: DB #00 ; TYPE FAT (12 - 12bit, 16 - 16bit, 32 - 32bit) ; [x] fat32
.CacheBlock: DW #00
@ -885,16 +896,21 @@ FatBuffer:
.FAT2_SEC_H: DW #0000 ; [ ] fat32
.SectorsPerFAT_L DW #0000
.SectorsPerFAT_H DB #00
.RootDirFirstSector_H: DW #0000 ; MSD_CAT_SEC first sector DIR ; !TODO ®£à ­¨ç¥­¨¥ ¢ 32 ƒ¨£  ;!FIXIT ­¥ ¨á¯®«ì§ã¥âáï
.RootDirFirstSector_L: DW #0000 ; MSD_CAT_SEC first sector DIR
.RootDirFirstSector_H: DW #0000 ; MSD_CAT_SEC first sector DIR ; !TODO ®£à ­¨ç¥­¨¥ ¢ 32 ƒ¨£  ;!FIXIT ­¥ ¨á¯®«ì§ã¥âáï
.DirSizeInSectors: DB #00 ; DIR_SEC_SIZE
.FirstDataSector_L: DW #0000 ; MSD_DAT_SEC low
.FirstDataSector_H: DW #0000 ; MSD_DAT_SEC high ; [ ] fat32 ¡ë«® ®£à ­¨ç¥­¨¥ ¢ 32 ƒ¨£ 
.BytesPerCluster: DW #0000 ; CLUSTER_LEN
.ENDCLUS_LOW: DW #FFFF
.ENDCLUS_HIGH: DW #0FFF ; [ ] fat3
.END_CHAIN_CLUSTER_L: DW #FFFF
.END_CHAIN_CLUSTER_H: DW #0FFF ; [ ] fat3
.MaxClusterLow: DW #0000 ; ¬ ªá. ç¨á«® ª« áâ¥à®¢ (¡¥§ á«ã¦.)
.MaxClusterHigh: DW #0000 ; ¬ ªá. ç¨á«® ª« áâ¥à®¢ (¡¥§ á«ã¦.)
;
.BytesPerSector DW #0000
.SectorsPerCluster DB #00
.BPB_SERIAL_NUMBER DW 0,0
.BPB_LABEL BLOCK 11,' ' ; 11 ¤«ï FAT, 31 ¤«ï CDFS
IF COMPILE_UNUSED_CODE
.FilesPerSector: DB #00 ; ç¨á«® ä ©«®¢ëå § ¯¨á¥© ¢ ᥪâ®à¥
.ClustersPerBank: DB #00 ; A - Clusters per bank (16k) (ç¨á«® ª« áâ¥à®¢ ­  ¡«®ª އ“) ; ????? íâ® ¨á¯®«ì§ã¥âáï?

View File

@ -255,9 +255,9 @@ READ_FROM_FAT: CALL CHECK_CLUSTER_IS_SMALLER
; .Custom:
; HL':HL ¨ DE':DE â ª¨¥ ¦¥ ª ª ¨ ­  ¢å®¤¥
;------------------------------------------------------------------------------------------------
WRITE_TO_FAT: LD DE,(FatBuffer.ENDCLUS_LOW) ; ­®¬¥à ª« áâ¥à 
WRITE_TO_FAT: LD DE,(FatBuffer.END_CHAIN_CLUSTER_L) ; ­®¬¥à ª« áâ¥à 
EXX
LD DE,(FatBuffer.ENDCLUS_HIGH) ; ­®¬¥à ª« áâ¥à 
LD DE,(FatBuffer.END_CHAIN_CLUSTER_H) ; ­®¬¥à ª« áâ¥à 
EXX
.Custom: PUSH DE
EXX

View File

@ -111,6 +111,7 @@
;Input: C = #08
; B = Subcommand
; DE = #55AA Magic Number
; A = Drive
;
;Subcommands: #00 - Get Device Parameters
; #01 - Read track

View File

@ -77,7 +77,7 @@
STRUCT _sBuffers
.FileManipulator _sFM ; 44 bytes + 44 bytes * (FMCOUNT-1)
.FM_RESERVE BLOCK _sFM * (FMCOUNT-1),0 ;
.BootSector _sBOOT_SECTOR_PARAMS ; 62 bytes ;!TODO ¯¥à¥­¥á⨠¢ ®¡« áâì ¡ãä¥à®¢
.BootSector BLOCK 90,0 ; _sBOOT_SECTOR_PARAMS: 62 bytes FAT16, 90 bytes FAT32
.EXE_Header _sEXE_HEADER ; 512 bytes
.Stack _sStack ; 256 bytes
.Buffer BLOCK 512,0 ; FOR BUFFER & SECBUF

View File

@ -1 +1 @@
949
952

View File

@ -36,9 +36,9 @@ SERVICE_SECTORS:
.FAT32.Low EQU #FFEF
FAT_TYPE:
.x32 EQU 32
.x16 EQU 16
.x12 EQU 12
.x32 EQU #32
.x16 EQU #16
.x12 EQU #12
; define _bit (1<?((FAT_CACHE.Sectors-1)
; define _shift _bit&1)) + _bit&2)) + _bit&4)) + _bit&8)) + _bit&16)) + _bit&32)) + _bit&64)) + _bit&128))