;*****************************************************
;* Disk-Manager constants *
;*****************************************************
- .equ dskType_None = 0
- .equ dskType_CPM = 1
- .equ dskType_FAT = 2
-; .equ dskType_RAM = 3
+ .equ dskType_None = 0*16
+ .equ dskType_CPM = 1*16
+ .equ dskType_FAT = 2*16
+; .equ dskType_RAM = 3*16
+ .equ dskType_MASK = 0xf*16
;*****************************************************
;* CP/M to host disk constants *
erflag: .byte 1 ;error reporting
wrtype: .byte 1 ;write operation type
-hostbuf: .byte hostsize ;host buffer (from/to SD-card)
+hostbuf: .byte hostsize ;host buffer (from/to SD-card)
hostparttbl: .byte PARTENTRY_SIZE*MAXDISKS ;host partition table (type, start sector, sector count)
hostparttbltop:
hostdsk: .byte 1 ;host disk number
brne sbcb_l
; rcall dbg_print_biosd
- rcall dsk_drvtblinit
+ rcall dpb_drvtblinit
; rcall dbg_prdrvtbl
ret
; Description:
; ====================================================================
dskDiskCheck:
- lds temp,ndisks
- lds temp2,seekdsk
+ lds temp2,ndisks
+ lds temp,seekdsk
.if DSKSEL_DEBUG
printnewline
printstring "DiskCheck: "
rcall printhexw
.endif
- cpi temp2,RAMDISKNR
+ cpi temp,RAMDISKNR
brsh dsk_dchrd ;maybe ramdisk
; Check if selected disk # is less then # of disks.
- lds temp,ndisks
- tst temp ;0 disks?
+ lds temp2,ndisks
+ tst temp2 ;0 disks?
brne dsk_dchpart1
; No disks yet, need to init
; sbrs temp,7
; rjmp dsk_dchpart0
push temp
- rcall dsk_drvtblinit
+ rcall dpb_drvtblinit
; rcall dbg_prdrvtbl
- pop temp
+ pop temp2
dsk_dchpart0:
- cbr temp,0x80
- lds temp2,seekdsk
+ cbr temp2,0x80
+ lds temp,seekdsk
dsk_dchpart1:
- cp temp2,temp
+ cp temp,temp2
brsh dsk_dch_err
.if DSKSEL_DEBUG
printnewline
printstring "Select: "
- mov temp,temp2
rcall printhex
.endif
- ldsw x,biosdrvtbl
- lsl temp2 ;drive #
- add xl,temp2
- adc xh,_0
- rcall dram_readw_pp ;get drive table entry
-
+ rcall dpb_drvtbl_entry_get
or temp,temp2 ;if !0, drive is allready initialized
brne dsk_dchend
lds temp,seekdsk
- rcall dsk_diskinit
+ rcall dpb_diskinit
dsk_dchend:
.if DSKSEL_DEBUG
push temp
- ldsw x,biosdrvtbl
lds temp,seekdsk
- lsl temp ;drive #
- add xl,temp
- adc xh,_0
- rcall dram_readw_pp
+ rcall dpb_drvtbl_entry_get
+
printstring ", "
rcall printhexw
pop temp
#endif
; Test
-cpy_dpb:
+dpb_copy:
push zh
push zl
push yh
pop zh
ret
+; ====================================================================
+; Function: get drive table entry pointer for drive # in temp
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers :
+; Variables :
+;
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
+
+dpb_drvtbl_entry_p:
+
+ ldsw x,biosdrvtbl
+ lsl temp ;drive #
+ add xl,temp
+ adc xh,_0
+ ret
+
+
+; ====================================================================
+; Function: get drive table entry for drive # in temp
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers :
+; Variables :
+;
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
+
+dpb_drvtbl_entry_get:
+
+ rcall dpb_drvtbl_entry_p
+ ljmp dram_readw_pp
+
+
; ====================================================================
; Function: Clear drive table
; ====================================================================
; For now, only entries 1 - 7 are cleared.
-dsk_drvtblinit:
+dpb_drvtblinit:
ldsw x,biosdrvtbl
adiw x,2
ldi temp3,7
-dsk_drvi_l:
+dpb_drvi_l:
ldi temp,0
ldi temp2,0
rcall dram_writew_pp
dec temp3
- brne dsk_drvi_l
+ brne dpb_drvi_l
lds temp,biosenddat
lds temp2,biosenddat+1
; 0 on error
-dsk_diskinit:
+dpb_diskinit:
mov temp3,temp ;save disk #
; Test
- rcall cpy_dpb
+ rcall dpb_copy
ldi temp, low (16)
ldi temp2,high(16)
rcall heap_get
- brne dsk_di_1
- rjmp dsk_di_err ;
-dsk_di_1:
+ brne dpb_di_1
+ rjmp dpb_di_err ;
+dpb_di_1:
movw x,temp
- movw y,temp
+ movw y,temp ;save dph pointer
ldi temp,0
ldi temp2,0
rcall dram_writew_pp ;XLT
rcall dram_writew_pp ;DIRBUF
; get mem for DPB
-; -------------------------------------------------------------
-; DPB: | SPT |BSH|BLM|EXM| DSM | DRM |AL0|AL1| CKS | OFF |
-; -------------------------------------------------------------
-; 0 5 7 11 13
+; -------------------------------------------------------------
+; DPB: | SPT |BSH|BLM|EXM| DSM | DRM |AL0|AL1| CKS | OFF |
+; -------------------------------------------------------------
+; 0 5 7 11 13
ldi temp, low (15)
ldi temp2,high(15)
rcall heap_get
- breq dsk_di_err_p1
+ breq dpb_di_err_p1
movw x,temp
ldiw z,tmpdpb
-dsk_dicpl:
+dpb_dicpl:
ld temp,z+
rcall dram_write_pp
cpi zl,low(tmpdpb + 15)
- brne dsk_dicpl
+ brne dpb_dicpl
sbiw x,15
movw temp,x
movw x,y
lds temp2,tmpdpb+11+1
cp temp,_0
cpc temp2,_0
- breq dsk_dicks0
+ breq dpb_dicks0
rcall heap_get
- breq dsk_di_err_p1
-dsk_dicks0:
+ breq dpb_di_err_p1
+dpb_dicks0:
rcall dram_writew_pp ;CSV
; get mem for alloc vector
lsr temp2
ror temp ;(dsm+1+7)/8
rcall heap_get
- breq dsk_di_err_p1
+ breq dpb_di_err_p1
rcall dram_writew_pp ;ALV
; success, insert DPH into drvtbl
- lds xl,biosdrvtbl
- lds xh,biosdrvtbl+1
- lsl temp3 ;drive #
- add xl,temp3
- adc xh,_0
+ mov temp,temp3
+ rcall dpb_drvtbl_entry_p
movw temp,y
rcall dram_writew_pp
ori temp,0xff ;return ok
; error, free mem
-dsk_di_err_p1:
+dpb_di_err_p1:
movw temp,y
rcall heap_release
-dsk_di_err:
+dpb_di_err:
eor temp,temp ;return 0 (+ Z-flag)
ret
; Description:
; ====================================================================
dsk_read:
- sts erflag,_0
- sbi flags,readop ; Set read operation flag
+ sts erflag,_0
+ sbi flags,readop ; Set read operation flag
;RAM disk?
lds xl,seekdsk
rjmp rdsk_read
#endif
rcall dsk_getpartentry ; Get Paritiontableentry
- ld temp,z ; Get Partitiontype
+ ld temp,z ; Get Partitiontype
+ andi temp,dskType_MASK
; Isn't it a Disk ?
cpi temp,dskType_None
brne PC+2
rjmp dsk_read_err
; It must be a FAT16-Imagefile or CP/M Partition.
- sts unacnt,_0
- sbi flags,rsflag ;must read data
- ldi temp,WRUAL ;write type
- sts wrtype,temp ;treat as unalloc
- rjmp dsk_rwoper ;to perform the read
+ sts unacnt,_0
+ sbi flags,rsflag ;must read data
+ ldi temp,WRUAL ;write type
+ sts wrtype,temp ;treat as unalloc
+ rjmp dsk_rwoper ;to perform the read
dsk_read_err:
ret
; ====================================================================
dsk_write:
;write the selected sector
- sts erflag,_0
- cbi flags,readop ; not a read operation
+ sts erflag,_0
+ cbi flags,readop ; not a read operation
;RAM disk?
lds xl,seekdsk
#if RAMDISKCNT
#endif
rcall dsk_getpartentry ; Get Paritiontableentry
ld temp2,z ; Get Partitiontype
+ andi temp,dskType_MASK
; Isn't it a Disk ?
cpi temp2,dskType_None
; It must be a FAT16-Imagefile or CP/M Partition.
- cbi flags,readop ;not a read operation
+ cbi flags,readop ;not a read operation
andi temp,WRTMSK
- sts wrtype,temp ;save write type
+ sts wrtype,temp ;save write type
- cpi temp,WRUAL ;write unallocated?
+ cpi temp,WRUAL ;write unallocated?
brne dsk_chkuna ;check for unalloc
; write to unallocated, set parameters
; Description:
; ====================================================================
dsk_writehost:
- lds xl,hostdsk
- rcall dsk_getpartentry
- ld temp,z
+ lds xl,hostdsk
+ rcall dsk_getpartentry
+ ld temp,z
+ andi temp,dskType_MASK
#if FAT16_SUPPORT
; Is it a FAT16 Diskimage ?
- cpi temp,dskType_FAT
+ cpi temp,dskType_FAT
brne PC+2
rjmp fat_writehost
#endif
; Is it a CP/M Partition ?
- cpi temp,dskType_CPM
+ cpi temp,dskType_CPM
brne PC+2
rjmp cpm_writehost
; Disktype not supported -> Return
lds xl,hostdsk
rcall dsk_getpartentry
ld temp,z
+ andi temp,dskType_MASK
#if FAT16_SUPPORT
; Is it a FAT16 Diskimage ?
- cpi temp,dskType_FAT
+ cpi temp,dskType_FAT
brne PC+2
rjmp fat_readhost
#endif
; Is it a CP/M Partition ?
- cpi temp,dskType_CPM
+ cpi temp,dskType_CPM
brne PC+2
rjmp cpm_readhost
; Disktype not supported -> Return