]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/dsk_mgr.asm
* Some bug fixes
[avrcpm.git] / avr / dsk_mgr.asm
index eefee45ed509575fdc74923ebe8b63546f2eb585..40a2cd443c6de3d25ff3d4603cce6c7e2298f388 100644 (file)
@@ -75,7 +75,7 @@ mgr_picl:
 
 ; Start mmc Card interaction
        lcall   mmcInit
-       andi    temp,MMCST_NOINIT & MMCST_NODISK
+       andi    temp,MMCST_NOINIT | MMCST_NODISK
        brne    mgr_pierr
        
 ;Load first sector from MMC (boot sector)
@@ -97,10 +97,10 @@ mgr_check_bootsektor:
 ;Test, if it has a valid MBR
 
        lds     temp,hostbuf+510        ;MBR signature (0xAA55)  at and of sector?
-       lds     temp2,hostbuf+510+1
-       ldi     temp4,0xAA
        cpi     temp,0x55               
-       cpc     temp2,temp4
+       lds     temp,hostbuf+510+1
+       ldi     temp2,0xAA
+       cpc     temp,temp2
        breq    mgr_search
 
 ;No MBR, no partition table ...
@@ -116,14 +116,15 @@ mgr_check_bootsektor:
        std     y+4,_0
        std     y+5,_0                  ;max CP/M 2.2 disk size
        std     y+6,temp                ;
-;      std     y+7,_0
-;      std     y+8,_0
+
+       ldi     temp3,0
+       rcall   dpb_imgdata_get
+
        rjmp    mgr_pend
 
 ; Search for valid Partitions and ImageFiles 
 mgr_search:
        ldiw    z,hostbuf+510-64        ;Point to  first byte of partition table
-       ldi     temp4,4                 ;Partition table has 4 entries.
 
 mgr_ploop:
 
@@ -134,8 +135,7 @@ mgr_ploop:
        cpi     temp,PARTID_CPM
        brne    mgr_nextp
        
-       rcall    cpm_add_partition
-
+       rcall   cpm_add_partition
        inc     temp3
        sts     ndisks,temp3
        adiw    y,PARTENTRY_SIZE
@@ -143,15 +143,14 @@ mgr_ploop:
        breq    mgr_pend
        
 mgr_nextp:
-       adiw    zl,16
-       dec     temp4
+       adiw    z,16
+       cpi     zl,low(hostbuf+510)     ;End of partition table reached?
        brne    mgr_ploop
 
 #if FAT16_SUPPORT
 
 ; Test for FAT16 Partition
        ldiw    z,hostbuf+510-64        ;Point to  first byte of partition table
-       ldi     temp4,4
 
 mgr_ploop2:
 ;      Get Partitiontype
@@ -173,12 +172,22 @@ mgr_fatfound:
 
 mgr_nextp2:
        adiw    zl,16
-       dec     temp4
+       cpi     zl,low(hostbuf+510)
        brne    mgr_ploop2
 #endif
 
 mgr_pend:
-       lds     temp,ndisks             ;return # of "disks"
+       clr     temp3
+mgr_imgd_lp:
+       lds     temp,ndisks
+       cp      temp3,temp
+       breq    mgr_pend2
+       rcall   dpb_imgdata_get
+       inc     temp3
+       rjmp    mgr_imgd_lp
+
+mgr_pend2:
+       lds     temp,ndisks     ;return # of "disks"
        tst     temp
        ret
 
@@ -196,22 +205,24 @@ mgr_pend:
 ; ====================================================================
 
 mgr_prnt_parttbl:
+       push    r15
+       push    r14
        ldiw    z,hostparttbl
        lds     yl,ndisks
        ldi     xh,'A'
 
 pprl:
+       printnewline
+
        ldd     temp ,z+1               ;Get partition start
        ldd     temp2,z+2
-       ldd     temp3,z+3
-       ldd     temp4,z+4
-
-       printnewline
+       ldd     r14,z+3
+       ldd     r15,z+4
 
        cp      temp,_0                 ;If zero ...
        cpc     temp2,_0
-       cpc     temp3,_0
-       cpc     temp4,_0
+       cpc     r14,_0
+       cpc     r15,_0
        breq    mgr_prnop               ;... no partition table at 0
 
 ; Partitiontype examining
@@ -257,12 +268,9 @@ mgr_prnt_size:
 
        ldd     temp ,z+5               ;Get partition size
        ldd     temp2,z+6
-       ldi     temp3,0
-       ldi     temp4,0
-
-       lsr     temp4
-       ror     temp3
-       ror     temp2
+       clr     r14
+       clr     r15
+       lsr     temp2
        ror     temp
        lcall   print_ultoa
        printstring "KB."
@@ -274,6 +282,8 @@ mgr_goto_next_part:
        brne    pprl
 
 mgr_pppre:
+       pop     r14
+       pop     r15
        ret