; ############################################################################
.dseg
-fat_partfound: .byte 1 ; (partition: 0= no found 1=found )
+fat_partfound: .byte 1 ; (partition: 0= no found 0xff=found )
fat_parttbl: .byte 4 ; first fat16 partition entry
; only startsector is needed
fat_clustersize: .byte 1 ; sectors per cluster
; the FAT16-Partition for the given sector.
; ============================================================================
fat_reset_cache:
- push yl
- ldi yl,0xFF
- sts fat_log_clust ,yl
- sts fat_log_clust+1,yl
- sts fat_last_dsk ,yl
- pop yl
+ sts fat_log_clust ,_255
+ sts fat_log_clust+1,_255
+ sts fat_last_dsk ,_255
ret
; ============================================================================
push yh
; set fat16 partition found flag
- ldi yl,1
- sts fat_partfound,yl
+ sts fat_partfound,_255
; save data from first fat16 partition
ldiw y,fat_parttbl
; Check if a FAT16 Partition was realy found
lds yl,fat_partfound
- cpi yl,1
- brne fat_scan_error
+ cpi yl,0
+ breq fat_scan_error
.if FAT16_DEBUG > 0
fat_clusttosec:
clr yl
clr yh
-
- ldi temp,2
- sub xl,temp ; Substract the 2 reserved clusters
- sbc xh,_0
+ sbiw x,2 ; Substract the 2 reserved clusters
lds temp,fat_clustersize
lsr temp
-
fat_c2s_loop:
tst temp
breq fat_c2s_end
rcall fat_find_phsy_clust
; Get StartSector of "physical" Cluster
- mov xl,yl
- mov xh,yh
+ movw x,y
rcall fat_gethostsec
; Found the physical sector
.if FAT16_DBG_FAT > 0
printstring "Found phys. Sector at:"
- mov temp,yl
- mov temp2,yh
+ movw temp,y
lcall printhexw
- mov temp,xl
- mov temp2,xh
+ movw temp,x
lcall printhexw
printnewline
.endif
; Found the physical sector
.if FAT16_DBG_FAT > 0
printstring "Sector with Offset at:"
- mov temp,yl
- mov temp2,yh
+ movw temp,y
lcall printhexw
- mov temp,xl
- mov temp2,xh
+ movw temp,x
lcall printhexw
printnewline
.endif
rcall fat_hostparam
breq fat_rdwr_err
- call mmcWriteSect
+ lcall mmcWriteSect
tst temp
breq fat_rdwr_ok
rcall fat_hostparam
breq fat_rdwr_err
- call mmcWriteSect ; disabled till read is functioning
+ lcall mmcWriteSect ; disabled till read is functioning
tst temp
brne fat_rdwr_err
rjmp fat_rdwr_ok