.equ o_fat_clust_offset= 17
.equ o_fat_clust_ptr = 18
+.if SRAM_SIZE > 1024
+
+fat_last_fatsect: .byte 1
+ .equ o_fat_last_fatsect = 22
+
+fat_buf: .byte 512
+
+.endif
; ############################################################################
; Start of Code Segment
std y+o_fat_log_clust ,_255
std y+o_fat_log_clust+1,_255
std y+o_fat_last_dsk ,_255
+.if SRAM_SIZE > 1024
+ std y+o_fat_last_fatsect,_255
+.endif
+
ret
; ============================================================================
ldd xh,z+1
ldd yl,z+2
ldd yh,z+3
+ ldiw z,hostbuf
; Load first sector from Partition
rcall mmcReadSect
sbc yh,_0
; Load sector from Directory
+ ldiw z,hostbuf
lcall mmcReadSect
tst temp
breq fat_look_for_images
push xl
push xh
-; Create FAT Offset Value
+; Create FAT Offset Value
+
clr zh
mov zl,yl
lsl zl
rol zh
-; Get FAT Start
mov temp,yh
- lds xl,fat_ptr2fat
+
+.if SRAM_SIZE > 1024
+
+; Check, if required fat sector allready in buffer
+
+ lds temp2,fat_last_fatsect
+ sts fat_last_fatsect,temp
+ cp temp,temp2
+ breq fat_phys_1
+
+; Not in buffer, get fat sector
+
+ lds xl,fat_ptr2fat ;get FAT start
lds xh,fat_ptr2fat+1
lds yl,fat_ptr2fat+2
lds yh,fat_ptr2fat+3
-; Add Cluster offset within sector
- add xl,temp
+ add xl,temp ;add cluster offset within sector
+ adc xh,_0
+ adc yl,_0
+ adc yh,_0
+ push zl
+ push zh
+ ldiw z,fat_buf
+ lcall mmcReadSect
+ pop zh
+ pop zl
+
+fat_phys_1:
+ ldiw y,fat_buf
+ add zl,yl
+ adc zh,yh
+ ldd yl,z+0
+ ldd yh,z+1
+.else
+
+ lds xl,fat_ptr2fat ;get FAT start
+ lds xh,fat_ptr2fat+1
+ lds yl,fat_ptr2fat+2
+ lds yh,fat_ptr2fat+3
+ add xl,temp ;add cluster offset within sector
adc xh,_0
adc yl,_0
adc yh,_0
lcall mmcReadWord
-
+ movw y,z
+.endif
pop xh
pop xl
- movw y,z
; Check next logical Cluster