fat16 тупит

This commit is contained in:
Tolik 2026-04-22 21:35:30 +10:00
parent 36ac5ec831
commit 8e61332b03
5 changed files with 148 additions and 48 deletions

View File

@ -39,3 +39,30 @@ Version_Msg: DB "DSS Drive Formatter v"
.Size EQU $-Version_Msg
ASSERT Version_Msg.Size < 80+4, "ERROR: Version_Msg to long!"
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
;!FIXIT Color settings
col_magenta EQU 5
col_white EQU 7
col_cmd EQU 16
;
PARAMS_MSG: BYTE "\r\nDrive "
.disk BYTE "A: "
BYTE "will be formatted using the current settings:\r\n\r\n"
BYTE "Clusters:\t", col_cmd,col_magenta, "%lu", col_cmd,col_white, "\r\n"
BYTE "Cluster size:\t", col_cmd,col_magenta, "%u bytes", col_cmd,col_white, "\r\n"
BYTE "File system:\t", col_cmd,col_magenta, "%S", col_cmd,col_white, "\r\n"
BYTE "Serial:\t\t", col_cmd,col_magenta, "%04x-%04x", col_cmd,col_white, "\r\n"
BYTE "Label:\t\t", col_cmd,col_magenta, "%S", col_cmd,col_white, "\r\n\r\n"
BYTE 'Press "Y" for format or any other key to exit', "\r\n"
BYTE 0
.ptr: WORD PARAMS_MSG
.Clusters: DWORD 0
.Clu_size: WORD 0
.FAT: WORD .FATtxt
.Serial: DWORD 0
.Label: WORD .LabelTxt
;
.FATtxt: DZ 'FAT '
.LabelTxt: DZ 'NO LABEL '
;-----------------------------------------------------------------------

@ -1 +1 @@
Subproject commit 440cb45e755dbb4c4c00ac1d193a6701c5684704
Subproject commit e1dc7ec10dc9c7e9153a05884e42973a57378a63

View File

@ -46,29 +46,6 @@ FAT_TYPES: FAT_TYPES_LINE #0800, 32768, CONSTANTS.FAT32 ; > 32768
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
VARIABLES EQU $
.FAT_TYPE BYTE CONSTANTS.FAT12 ; [x]
.CurrentDrive DB #FF ; [x]
.VOLUME_SIZE_BYTES BLOCK 5,0 ; [ ]
;.FatFDD_ReservedSectors WORD 1
;.FatHDD_ReservedSectors WORD 8
;.Fat32_ReservedSectors WORD 32
.ReservedSectors WORD 0 ; [ ]
.RootDirSectors D24 0 ; [ ]
.NotUsedSpace BYTE 0 ; in sectors
.total_clusters_L: WORD 0 ; [x]
.total_clusters_H: WORD 0 ; [x]
.FAT32_RootDirClusters WORD 1 ; [ ]
.FAT.LABEL BYTE 'NO_LABEL ' ; [ ]
.DriveExtendedParameters BYTE 0 ; [ ]
.DataSectors_L WORD 0 ; [ ]
.DataSectors_H WORD 0 ; [ ]
.RootDirFirstSector_L WORD 0 ; [x] ¢ëç¨á«ï¥âáï ¢ FORMAT_DRIVE
.RootDirFirstSector_H WORD 0 ; [x] ¢ëç¨á«ï¥âáï ¢ FORMAT_DRIVE
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
MODULE KEYS_PARAMETERS
@ -123,6 +100,32 @@ BPB_BytsPerSec.
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
VARIABLES EQU $
.FAT_TYPE BYTE CONSTANTS.FAT12 ; [x]
.CurrentDrive DB #FF ; [x]
.VOLUME_SIZE_BYTES BLOCK 5,0 ; [ ]
;.FatFDD_ReservedSectors WORD 1
;.FatHDD_ReservedSectors WORD 8
;.Fat32_ReservedSectors WORD 32
.ReservedSectors WORD 0 ; [ ]
.RootDirSectors D24 0 ; [ ]
.NotUsedSpace BYTE 0 ; in sectors
.total_clusters_L: WORD 0 ; [x]
.total_clusters_H: WORD 0 ; [x]
.FAT32_RootDirClusters WORD 1 ; [ ]
.FAT.LABEL BYTE 'NO_LABEL ' ; [ ]
.DriveExtendedParameters BYTE 0 ; [ ]
.DataSectors_L WORD 0 ; [ ]
.DataSectors_H WORD 0 ; [ ]
.RootDirFirstSector_L WORD 0 ; [x] ¢ëç¨á«ï¥âáï ¢ FORMAT_DRIVE
.RootDirFirstSector_H WORD 0 ; [x] ¢ëç¨á«ï¥âáï ¢ FORMAT_DRIVE
.SectorsPerFAT_L WORD 0 ; [x]
.SectorsPerFAT_H WORD 0 ; [x]
.ClusterSize WORD 0 ; [x]
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
; root_dir_sectors = ((root_dir_entries * 32) + (bytes_per_sector - 1)) / bytes_per_sector
FAT_PARAMETERS:

View File

@ -1 +1 @@
47
57

View File

@ -108,16 +108,21 @@ DSS_DRIVE_FORMAT:
;-----------------------------------------------------------------------
LD (STOP_ERROR.Save_SP),SP
PUSH IX
; § ¡¨à ¥¬ ⥪ãéãî ¤¨à¥ªâ®à¨î
LD C,Dss.CurDisk
RST ToDSS
ADD 'A'
LD (Exit_Path),A
LD HL,Exit_Path.Path
LD C,Dss.CurDir
RST ToDSS
;
POP HL
CALL PARSE_CMD
;
;!FIXIT
;
;
LD A,(KEYS_PARAMETERS.FAT_TYPE + KEYS_PARAMETERS.KEYS_STR.Status)
LD C,A
@ -141,12 +146,19 @@ DSS_DRIVE_FORMAT:
OR C
JR Z,MAKE_AUTO
;
; !TODO
; !TODO ¤à㣨¥ ¢ à¨ ­âë ä®à¬ â 
;
; !TODO ¢ë¢®¤ á®®¡é¥­¨ï, çâ® ä®à¬ â ­¥ á®áâ®ï«áï
JP STOP_ERROR
;
MAKE_AUTO: CALL CALCULATE_FAT
CALL SHOW_FORMAT_PARAMETERS
JP C,STOP_ERROR ; abort
CALL FORMAT_DRIVE
CALL MAKE_LABEL_IN_DIR ; ¯¥à¢ ï § ¯¨áì ¢ root dir - ¬¥âª , ¯®â®¬ ­ã«¨
RET
JP C,STOP_ERROR
LD B,DSS_Error.sys.NO_ERROR
JP EXIT
;-----------------------------------------------------------------------
; €¢â®¬ â¨ç¥áª®¥ ¯à¥¤¥«¥­¨¥ ¯ à ¬¥â஢ ­®á¨â¥«ï ¨ ¢ë¡®à FAT
@ -240,7 +252,8 @@ CALCULATE_FAT: CALL .STEP1 ;
JR C,.BPS_OK
; ­  á«ãç ©, ¥á«¨ â ¡«¨ç­ë© ª« áâ¥à ¬¥­ìè¥ á¥ªâ®à 
LD A,1
.BPS_OK: CALL C,DIV16_POWER2
.BPS_OK: LD (VARIABLES.ClusterSize),HL
CALL C,DIV16_POWER2
JR C,STOP_ERROR
;
LD (FAT_PARAMETERS.SectorsPerCluster),A
@ -291,11 +304,14 @@ CALCULATE_FAT: CALL .STEP1 ;
JR Z,.it_is_fat32
;
LD (FAT_PARAMETERS.SectorsPerFAT16),HL
LD (VARIABLES.SectorsPerFAT_L),HL
RET
;
.it_is_fat32: LD (FAT_PARAMETERS.SectorsPerFAT32),HL
LD (VARIABLES.SectorsPerFAT_L),HL
LD HL,(CALC_TOTAL_CLUSTERS.fat_size_h)
LD (FAT_PARAMETERS.SectorsPerFAT32 + 2),HL
LD (VARIABLES.SectorsPerFAT_H),HL
RET
;--------------;
;-----------------------------------------------------------------------
@ -303,10 +319,16 @@ CALCULATE_FAT: CALL .STEP1 ;
;-----------------------------------------------------------------------
STOP_ERROR:
.Save_SP+1: LD SP,0
LD B,DSS_Error.sys.INVALID_FUNCTION
;!TODO
SCF
EXIT: PUSH BC
LD HL,Exit_Path
LD C,Dss.ChDir
RST ToDSS
;
RET
LD C,Dss.Exit
RST ToDSS
;-----------------------------------------------------------------------
@ -333,7 +355,7 @@ CALC_TOTAL_CLUSTERS:
LD H,B
LD L,A
LD BC,(FAT_PARAMETERS.BytesPerSector)
;HLIX/BC -> HLIX remainder DE
;HLIX/BC -> HLIX remainder DE
CALL HLIX_div_BC
LD A,D
OR E
@ -493,9 +515,11 @@ SET_RESERVED_AND_ROOTDIR:
CALL .ChooseFilesInRootDIR
;
LD A,(VARIABLES.FAT_TYPE)
CP CONSTANTS.FAT16
CP CONSTANTS.FAT12
LD HL,'61' ; str FAT16
JR Z,.set_type
JR C,.set_type
;
RET NZ ; ­¥ ¬¥­ï¥¬ - FAT32
;
LD H,'2' ; str FAT12
.set_type: LD (FAT_PARAMETERS.ID_FAT + 3),HL
@ -629,16 +653,16 @@ MAKE_SERIAL: LD C,Dss.SysTime
FORMAT_DRIVE: CALL MAKE_SYS_SECTORS
CALL CLEAN_SECTOR_BUFFER
; clean all fat tables at drive
LD A,(VARIABLES.FAT_TYPE)
CP CONSTANTS.FAT32
LD BC,(FAT_PARAMETERS.SectorsPerFAT32)
LD DE,(FAT_PARAMETERS.SectorsPerFAT32 + 2)
JR Z,.its_fat32
;LD A,(VARIABLES.FAT_TYPE)
;CP CONSTANTS.FAT32
;LD BC,(FAT_PARAMETERS.SectorsPerFAT16)
;JR NZ,.its_not_fat32
;
LD BC,(FAT_PARAMETERS.SectorsPerFAT16)
LD DE,0
.its_fat32: LD (.add_l),BC
LD BC,(VARIABLES.SectorsPerFAT_L)
LD DE,(VARIABLES.SectorsPerFAT_H)
LD (.add_h),DE
;.its_not_fat32:
LD (.add_l),BC
LD A,(FAT_PARAMETERS.Number_of_FATs)
CALL DEBCxA
; HL:IX - ¢á¥£® ᥪâ®à®¢ ¤«ï § ¯¨á¨
@ -748,8 +772,8 @@ FORMAT_DRIVE: CALL MAKE_SYS_SECTORS
;
CALL WRITE_SECTOR_BUFFER
;
.add_l+1: LD BC,0
.add_h+1: LD DE,0
.add_l+1: LD BC,0
POP IX
POP HL
POP AF
@ -1016,6 +1040,49 @@ JP_HL: EX DE,HL
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
;!FIXIT
SHOW_FORMAT_PARAMETERS:
LD A,(VARIABLES.CurrentDrive)
ADD 'A'
LD (PARAMS_MSG.disk),A
;
LD HL,(VARIABLES.total_clusters_L)
LD (PARAMS_MSG.Clusters),HL
LD HL,(VARIABLES.total_clusters_H)
LD (PARAMS_MSG.Clusters + 2),HL
;
LD HL,(VARIABLES.ClusterSize)
LD (PARAMS_MSG.Clu_size),HL
;
LD HL,(FAT_PARAMETERS.ID_FAT+3)
LD (PARAMS_MSG.FATtxt + 3),HL
;
LD HL,(FAT_PARAMETERS.SERIAL_NUMBER_1)
LD (PARAMS_MSG.Serial),HL
LD HL,(FAT_PARAMETERS.SERIAL_NUMBER_2)
LD (PARAMS_MSG.Serial + 2),HL
;
LD HL,FAT_PARAMETERS.LABEL
LD DE,PARAMS_MSG.LabelTxt
LD BC,FAT_PARAMETERS.LABEL.Size
LDIR
;
LD IY,PARAMS_MSG.ptr
CALL printf#.str
.loop: LD C,Dss.EchoKey
RST ToDSS
; ¯®§¨æ¨®­­ë© ª®¤ Y/y/­/<2F> - #95/#15
LD A,D
AND %0111'1111
CP #15
RET Z
SCF
RET
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------
SHOW_VERSION: LD SP,(STOP_ERROR.Save_SP)
LD HL,Version_Msg
@ -1250,6 +1317,9 @@ PutHexNumb: PUSH AF
include 'shared_includes/printf.asm'
////////////////////////////////////////////////////////////////////////
Exit_Path: DB 'A:\'
.Path: BLOCK 256-3+1
////////////////////////////////////////////////////////////////////////
STACK_BUFFER EQU $ + stack_buffer