.dseg
fat_partfound: .byte 1 ; (partition: 0= no found 1=found )
-fat_parttbl: .byte 8 ; first fat16 partition entry \r
- ; (start sector, sector count)
-;fat_sectorsize: .byte 2 ; size of sector in bytes
+fat_parttbl: .byte 4 ; first fat16 partition entry \r
+ ; only startsector is needed
fat_clustersize: .byte 1 ; sectors per cluster
-fat_ressectors: .byte 2 ; number of reserved sectors
-fat_secperfat: .byte 2 ; number of sectors per fat
-fat_numfatcp: .byte 1 ; number of FAT Copies
fat_numdirentrys:.byte 2 ; Max. num. of entrys within Rootdirektory
fat_ptr2fat: .byte 4 ; pointer to the first fat sector
-fat_ptr2dir: .byte 4 ; pointer to the first root directory sector
fat_ptr2dat: .byte 4 ; pointer to the first data sector
/*These variables define a cache that holds the last Cluster and Sector\r
st y+,temp
ldd temp,z+PART_START+3
st y+,temp
-
- ldd temp,z+PART_SIZE
- st y+,temp
- ldd temp,z+PART_SIZE+1
- st y+,temp
- ldd temp,z+PART_SIZE+2
- st y+,temp
- ldd temp,z+PART_SIZE+3
- st y+,temp
+\r
+; Don't need the Size of the Partition for use with Imagefiles
+; ldd temp,z+PART_SIZE
+; st y+,temp
+; ldd temp,z+PART_SIZE+1
+; st y+,temp
+; ldd temp,z+PART_SIZE+2
+; st y+,temp
+; ldd temp,z+PART_SIZE+3
+; st y+,temp
; reload variables from stack
printnewline
.endif
-; Not needed / used by now because size of Sectors fixed at 512 Bytes
-; Get ammount of Bytes per Sector
-; ldiw z,hostbuf+FAT16_BSO_SECSIZE
-; ldiw y,fat_sectorsize
-; ld temp,z
-; st y+, temp
-; ldd temp2,z+1
-; st y , temp2
-;
-;.if FAT16_DEBUG > 0
-; printstring "Bytes per Sector ",0
-; rcall printhexw
-; printnewline
-;.endif
-
; get sectors per cluster from bootblock
ldiw z,hostbuf+FAT16_BSO_CLUSTSZ
ld temp,z
printnewline
.endif
-; get num of reseved sectors from bootblock
- ldiw z,hostbuf+FAT16_BSO_RESSECT
- ld temp,z+
- sts fat_ressectors,temp ; low byte
- ld temp2,z
- sts fat_ressectors+1,temp2 ; high byte
-
-.if FAT16_DEBUG > 0
- printstring "Reserved Sectors__: ",0
- rcall printhexw
- printnewline
-.endif
-
-; get num of sectors per FAT-Table from bootblock
- ldiw z,hostbuf+FAT16_BSO_SECPERFAT
- ld temp,z+
- sts fat_secperfat,temp ; low byte
- ld temp2,z
- sts fat_secperfat+1,temp2 ; high byte
-
-.if FAT16_DEBUG > 0
- printstring "Sectors per FAT__: ",0
- rcall printhexw
- printnewline
-.endif
-
; get num of FAT Tables from bootblock
ldiw z,hostbuf+FAT16_BSO_NUMFATCP
ld temp,z
- sts fat_numfatcp,temp ; low byte
+ sts fat_last_dsk,temp ; low byte
.if FAT16_DEBUG > 0
printstring "Ammount of FAT copies: ",0
rcall printhexw
printnewline
.endif
+\r
+; get num of sectors per FAT-Table from bootblock
+ ldiw z,hostbuf+FAT16_BSO_SECPERFAT
+ ld temp,z+
+ sts fat_log_clust,temp ; low byte
+ ld temp2,z
+ sts fat_log_clust+1,temp2 ; high byte
+.if FAT16_DEBUG > 0
+ printstring "Sectors per FAT__: ",0
+ rcall printhexw
+ printnewline
+.endif\r
+\r
+; get num of reseved sectors from bootblock
+ ldiw z,hostbuf+FAT16_BSO_RESSECT
+ ld temp,z+
+ ld temp2,z
+\r
; Calculate begin of FAT within the Volume
- lds temp ,fat_ressectors
- lds temp2,fat_ressectors+1
-
ldiw z,fat_parttbl
ldd xl,z+0
ldd xh,z+1
ldd yl,z+2
ldd yh,z+3
- lds temp ,fat_secperfat
- lds temp2,fat_secperfat+1
- lds temp3,fat_numfatcp
+ lds temp ,fat_log_clust
+ lds temp2,fat_log_clust+1
+ lds temp3,fat_last_dsk
fat_calc_dp_loop:
cp temp3,_0
jmp fat_calc_dp_loop
fat_calc_dp_lend:
- sts fat_ptr2dir ,xl
- sts fat_ptr2dir+1,xh
- sts fat_ptr2dir+2,yl
- sts fat_ptr2dir+3,yh
+ sts fat_clust_ptr ,xl
+ sts fat_clust_ptr+1,xh
+ sts fat_clust_ptr+2,yl
+ sts fat_clust_ptr+3,yh
.if FAT16_DEBUG > 1
lsr zh
ror zl
- lds xl,fat_ptr2dir
- lds xh,fat_ptr2dir+1
- lds yl,fat_ptr2dir+2
- lds yh,fat_ptr2dir+3
+ lds xl,fat_clust_ptr
+ lds xh,fat_clust_ptr+1
+ lds yl,fat_clust_ptr+2
+ lds yh,fat_clust_ptr+3
add xl,zl
adc xh,zh
\r
fat_next_sector_loop:\r
; Get a Pointer to the first Directory sector\r
- lds xl,fat_ptr2dir
- lds xh,fat_ptr2dir+1
- lds yl,fat_ptr2dir+2
- lds yh,fat_ptr2dir+3
+ lds xl,fat_clust_ptr
+ lds xh,fat_clust_ptr+1
+ lds yl,fat_clust_ptr+2
+ lds yh,fat_clust_ptr+3
; Add actual offset\r
lds temp,fat_clust_offset\r