]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avrcpm/avr/dsk_fat16.asm
* Merged fat16-test back into trunk.
[avrcpm.git] / avrcpm / avr / dsk_fat16.asm
index 42c3ae0cfabc9ded7fc2f4c03588339b957bdc5e..86d25198dfc207e48332bde911f33c5b943452a0 100644 (file)
@@ -36,7 +36,8 @@
 ;                              Defines for FAT16 Structures
 ; ############################################################################ 
 
-#define PARTID_FAT16 0x0E
+#define PARTID1_FAT16 0x0E
+#define PARTID2_FAT16 0x06
 
 /*These are the Offsets to the Variables within the Bootsector of a FAT16
   Partition.
@@ -49,7 +50,8 @@
 #define FAT16_BSO_NUMFATCP     0x10    ; Offset to Ammount of FAT Copys
 #define FAT16_BSO_NUMDIRENT    0x11    ; Offset to Max. Root Dir. Entrys
 #define        FAT16_FIRST_IMAGENAME   'A'     ; First letter of filename to search 
-#define FAT16_LAST_IMAGENAME    'Z'    ; Last letter of filename to search 
+#define FAT16_LAST_IMAGENAME    'A'+MAXDISKS-1 ; Last letter of filename to 
+                                               ; search 
 
 ; ############################################################################ 
 ;                              Start of Data Segment
@@ -72,8 +74,11 @@ fat_ptr2dat:     .byte   4   ; pointer to the first data sector
 fat_last_dsk:    .byte  1      ; number of disk with entry in cache
 fat_log_clust:   .byte  2      ; last searched logical cluster
 fat_clust_offset: .byte         1      ; offset within the cluster
-fat_clust_ptr:   .byte  4;     ; sector of last real cluster
+fat_clust_ptr:   .byte  4      ; sector of last real cluster
 
+/* This Variable is only needed within the scanning of the directory 
+for tempoary variable storage.. todo: optimize away :-) */
+fat_temp:        .byte 3       ; for tempoary use
 
 ; ############################################################################ 
 ;                              Start of Code Segment
@@ -144,7 +149,7 @@ fat_reset_cache:
 fat_add_partition:
        
 .if FAT16_DEBUG > 0
-       printstring "fat16 part found",0
+       printstring "fat16 part found"
        printnewline
 .endif
 
@@ -188,7 +193,7 @@ fat_add_partition:
 fat_scan_partition:
 
 .if FAT16_DEBUG > 0
-       printstring "fat16 scanning",0
+       printstring "fat16 scanning"
        printnewline
 .endif
 
@@ -199,7 +204,7 @@ fat_scan_partition:
 
 
 .if FAT16_DEBUG > 0
-       printstring "free entrys in ptable ?",0
+       printstring "free entrys in ptable ?"
        printnewline
 .endif
 
@@ -209,7 +214,7 @@ fat_scan_partition:
        breq    fat_scan_error
 
 .if FAT16_DEBUG > 0
-       printstring "read fat bootblock.",0
+       printstring "read fat bootblock."
        printnewline
 .endif
 
@@ -233,7 +238,7 @@ fat_scan_error:
 fat_bootblock_check:
 
 .if FAT16_DEBUG > 0
-       printstring "fat16 bootblock check",0
+       printstring "fat16 bootblock check"
        printnewline
 .endif
 
@@ -243,7 +248,7 @@ fat_bootblock_check:
        sts     fat_clustersize,temp
 
 .if FAT16_DEBUG > 0
-       printstring "Sectors per Cluster ",0
+       printstring "Sectors per Cluster "
        rcall printhex
        printnewline
 .endif
@@ -254,7 +259,7 @@ fat_bootblock_check:
        sts     fat_last_dsk,temp               ; low byte
 
 .if FAT16_DEBUG > 0
-       printstring "Ammount of FAT copies: ",0
+       printstring "Ammount of FAT copies: "
        rcall printhex
        printnewline
 .endif
@@ -267,7 +272,7 @@ fat_bootblock_check:
        sts     fat_numdirentrys+1,temp2        ; high byte
 
 .if FAT16_DEBUG > 0
-       printstring "Max. entrys in Rootdir.: ",0
+       printstring "Max. entrys in Rootdir.: "
        rcall printhexw
        printnewline
 .endif
@@ -281,7 +286,7 @@ fat_bootblock_check:
        ldd     yl,z+2
        ldd     yh,z+3
 
-       printstring "Begin of Volume at: ",0
+       printstring "Begin of Volume at: "
        mov     temp ,yl
        mov     temp2,yh
        rcall   printhexw
@@ -299,7 +304,7 @@ fat_bootblock_check:
        sts     fat_log_clust+1,temp2           ; high byte
 
 .if FAT16_DEBUG > 0
-       printstring "Sectors per FAT__: ",0
+       printstring "Sectors per FAT__: "
        rcall printhexw
        printnewline
 .endif
@@ -327,7 +332,7 @@ fat_bootblock_check:
        sts     fat_ptr2fat+3,yh
 
 .if FAT16_DEBUG > 1
-       printstring "Begin of FAT at___: ",0
+       printstring "Begin of FAT at___: "
        mov     temp ,yl
        mov     temp2,yh
        rcall   printhexw
@@ -369,7 +374,7 @@ fat_calc_dp_lend:
 
 
 .if FAT16_DEBUG > 1
-       printstring "Begin of DIR at___: ",0
+       printstring "Begin of DIR at___: "
        mov     temp ,yl
        mov     temp2,yh
        rcall   printhexw
@@ -413,7 +418,7 @@ fat_calc_dp_lend:
        sts     fat_ptr2dat+3,yh
 
 .if FAT16_DEBUG > 1
-       printstring "Begin of Data at__: ",0
+       printstring "Begin of Data at__: "
        mov     temp ,yl
        mov     temp2,yh
        rcall   printhexw
@@ -517,16 +522,16 @@ fat_look_for_loop:
        cpi     temp,'G'
        brne    fat_look_not_ok
 
-       sts     fat_clust_ptr  ,zl
-       sts     fat_clust_ptr+1,zh
-       sts     fat_clust_ptr+2,temp2
+       sts     fat_temp  ,zl
+       sts     fat_temp+1,zh
+       sts     fat_temp+2,temp2
        rjmp    fat_store_new_entry
 
 fat_scan_for_more:
 
-       lds     zl   ,fat_clust_ptr
-       lds     zh   ,fat_clust_ptr+1
-       lds     temp2,fat_clust_ptr+2
+       lds     zl   ,fat_temp
+       lds     zh   ,fat_temp+1
+       lds     temp2,fat_temp+2
 fat_look_not_ok:
                
        adiw    z,32
@@ -580,7 +585,7 @@ fat_store_new_entry:
 
 ;   Found a valid image
 .if FAT16_DEBUG > 1
-       printstring "Found a valid Image ! Z=",0
+       printstring "Found a valid Image ! Z="
        mov     temp ,zl
        mov     temp2,zh
        rcall   printhexw
@@ -651,7 +656,7 @@ fat_look_store:
 
        rcall   fat_gethostsec
 
-       printstring "Begin of Image at: ",0
+       printstring "Begin of Image at: "
        mov     temp ,yl
        mov     temp2,yh
        rcall   printhexw
@@ -767,13 +772,13 @@ fat_find_phsy_clust:
        ldd     yh,z+2
 
 .if FAT16_DBG_FAT > 0
-       printstring "Search log. Cluster ",0
+       printstring "Search log. Cluster "
        mov     temp,xl
        mov     temp2,xh
        lcall   printhexw
        printnewline
                
-       printstring "Search phys. Cluster ",0
+       printstring "Search phys. Cluster "
        mov     temp ,yl
        mov     temp2,yh
        lcall   printhexw
@@ -830,7 +835,7 @@ fat_next_phsy_clust:
 fat_found_phsy_clust:
        
 .if FAT16_DBG_FAT > 0
-       printstring "Found phys. Cluster at:",0
+       printstring "Found phys. Cluster at:"
        mov     temp,yl
        mov     temp2,yh
        lcall   printhexw
@@ -980,7 +985,7 @@ fat_wrong_cache_clst:
 
 ; Found the physical sector
 .if FAT16_DBG_FAT > 0
-       printstring "Found phys. Sector at:",0
+       printstring "Found phys. Sector at:"
        mov     temp,yl
        mov     temp2,yh
        lcall   printhexw
@@ -1006,7 +1011,7 @@ fat_add_offset:
 
 ; Found the physical sector
 .if FAT16_DBG_FAT > 0
-       printstring "Sector with Offset at:",0
+       printstring "Sector with Offset at:"
        mov     temp,yl
        mov     temp2,yh
        lcall   printhexw