mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 17:29:50 +00:00
Read number of total blocks from ProDOS 8 volume directory header - and fall back on the constant 280 only for non-ProDOS 8 disks.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4750 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
f15910e5f1
commit
07680d2376
@ -433,13 +433,6 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
|
|||||||
</descrip><p>
|
</descrip><p>
|
||||||
|
|
||||||
|
|
||||||
<sect1>DIO<p>
|
|
||||||
|
|
||||||
Although <htmlurl url="dio.html" name="DIO"> generally works with all ProDOS 8
|
|
||||||
devices, the function <htmlurl url="dio-3.html" name="dio_query_sectcount()">
|
|
||||||
simply always return 280 (which is only correct for a 140 KB disk).
|
|
||||||
|
|
||||||
|
|
||||||
<sect1>Direct console I/O<p>
|
<sect1>Direct console I/O<p>
|
||||||
|
|
||||||
<descrip>
|
<descrip>
|
||||||
@ -493,15 +486,27 @@ name="assembler manual">.
|
|||||||
|
|
||||||
<sect1>DIO<p>
|
<sect1>DIO<p>
|
||||||
|
|
||||||
The function <htmlurl url="dio-1.html" name="dio_open()"> has the single parameter
|
<descrip>
|
||||||
<tt/drive_id/ to identify the drive to be opened. Therefore an Apple II
|
|
||||||
slot and drive pair is mapped to that <tt/drive_id/ according to the formula
|
|
||||||
|
|
||||||
<verb>
|
<tag/Drive ID/
|
||||||
|
The function <htmlurl url="dio-1.html" name="dio_open()"> has the single
|
||||||
|
parameter <tt/drive_id/ to identify the drive to be opened. Therefore an
|
||||||
|
Apple II slot and drive pair is mapped to that <tt/drive_id/ according
|
||||||
|
to the formula
|
||||||
|
|
||||||
|
<verb>
|
||||||
drive_id = slot * 16 + (drive - 1) * 128
|
drive_id = slot * 16 + (drive - 1) * 128
|
||||||
</verb>
|
</verb>
|
||||||
|
|
||||||
so that for example slot 6 drive 2 is mapped to <tt/drive_id/ 224.
|
so that for example slot 6 drive 2 is mapped to <tt/drive_id/ 224.
|
||||||
|
|
||||||
|
<tag/Sector count/
|
||||||
|
The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns
|
||||||
|
the correct sector count for all ProDOS 8 disks. However for any non-ProDOS 8
|
||||||
|
disk it simply always return 280 (which is only correct for a 140 KB disk).
|
||||||
|
This condition is indicated by the _oserror value 82.
|
||||||
|
|
||||||
|
</descrip><p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,13 +434,6 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
|
|||||||
</descrip><p>
|
</descrip><p>
|
||||||
|
|
||||||
|
|
||||||
<sect1>DIO<p>
|
|
||||||
|
|
||||||
Although <htmlurl url="dio.html" name="DIO"> generally works with all ProDOS 8
|
|
||||||
devices, the function <htmlurl url="dio-3.html" name="dio_query_sectcount()">
|
|
||||||
simply always return 280 (which is only correct for a 140 KB disk).
|
|
||||||
|
|
||||||
|
|
||||||
<sect1>Direct console I/O<p>
|
<sect1>Direct console I/O<p>
|
||||||
|
|
||||||
<descrip>
|
<descrip>
|
||||||
@ -499,15 +492,27 @@ name="assembler manual">.
|
|||||||
|
|
||||||
<sect1>DIO<p>
|
<sect1>DIO<p>
|
||||||
|
|
||||||
The function <htmlurl url="dio-1.html" name="dio_open()"> has the single parameter
|
<descrip>
|
||||||
<tt/drive_id/ to identify the drive to be opened. Therefore an Apple II
|
|
||||||
slot and drive pair is mapped to that <tt/drive_id/ according to the formula
|
|
||||||
|
|
||||||
<verb>
|
<tag/Drive ID/
|
||||||
|
The function <htmlurl url="dio-1.html" name="dio_open()"> has the single
|
||||||
|
parameter <tt/drive_id/ to identify the drive to be opened. Therefore an
|
||||||
|
Apple II slot and drive pair is mapped to that <tt/drive_id/ according
|
||||||
|
to the formula
|
||||||
|
|
||||||
|
<verb>
|
||||||
drive_id = slot * 16 + (drive - 1) * 128
|
drive_id = slot * 16 + (drive - 1) * 128
|
||||||
</verb>
|
</verb>
|
||||||
|
|
||||||
so that for example slot 6 drive 2 is mapped to <tt/drive_id/ 224.
|
so that for example slot 6 drive 2 is mapped to <tt/drive_id/ 224.
|
||||||
|
|
||||||
|
<tag/Sector count/
|
||||||
|
The function <htmlurl url="dio-3.html" name="dio_query_sectcount()"> returns
|
||||||
|
the correct sector count for all ProDOS 8 disks. However for any non-ProDOS 8
|
||||||
|
disk it simply always return 280 (which is only correct for a 140 KB disk).
|
||||||
|
This condition is indicated by the _oserror value 82.
|
||||||
|
|
||||||
|
</descrip><p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,8 +5,91 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export _dio_query_sectcount
|
.export _dio_query_sectcount
|
||||||
|
.import _dio_query_sectsize, _malloc, _free
|
||||||
|
|
||||||
|
.include "zeropage.inc"
|
||||||
|
.include "errno.inc"
|
||||||
|
.include "mli.inc"
|
||||||
|
|
||||||
_dio_query_sectcount:
|
_dio_query_sectcount:
|
||||||
lda #<280
|
|
||||||
ldx #>280
|
; Set handle
|
||||||
|
sta mliparam + MLI::ON_LINE::UNIT_NUM
|
||||||
|
|
||||||
|
; Get ProDOS 8 block size (clears __oserror)
|
||||||
|
jsr _dio_query_sectsize
|
||||||
|
|
||||||
|
; Alloc buffer
|
||||||
|
jsr _malloc
|
||||||
|
sta ptr4
|
||||||
|
stx ptr4+1
|
||||||
|
|
||||||
|
; Set buffer
|
||||||
|
sta mliparam + MLI::ON_LINE::DATA_BUFFER
|
||||||
|
stx mliparam + MLI::ON_LINE::DATA_BUFFER+1
|
||||||
|
|
||||||
|
; Check buffer (hibyte is enough)
|
||||||
|
txa
|
||||||
|
beq nomem
|
||||||
|
|
||||||
|
; Get device state
|
||||||
|
lda #ON_LINE_CALL
|
||||||
|
ldx #ON_LINE_COUNT
|
||||||
|
jsr callmli
|
||||||
|
bcs check
|
||||||
|
|
||||||
|
; UNIT_NUM already set
|
||||||
|
.assert MLI::RW_BLOCK::UNIT_NUM = MLI::ON_LINE::UNIT_NUM, error
|
||||||
|
|
||||||
|
; DATA_BUFFER already set
|
||||||
|
.assert MLI::RW_BLOCK::DATA_BUFFER = MLI::ON_LINE::DATA_BUFFER, error
|
||||||
|
|
||||||
|
; Read volume directory key block
|
||||||
|
tax ; A = 0
|
||||||
|
lda #$02
|
||||||
|
sta mliparam + MLI::RW_BLOCK::BLOCK_NUM
|
||||||
|
stx mliparam + MLI::RW_BLOCK::BLOCK_NUM+1
|
||||||
|
lda #READ_BLOCK_CALL
|
||||||
|
ldx #RW_BLOCK_COUNT
|
||||||
|
jsr callmli
|
||||||
|
bcs oserr
|
||||||
|
|
||||||
|
; Get and save total blocks from volume directory header
|
||||||
|
ldy #$29
|
||||||
|
lda (ptr4),y
|
||||||
|
pha
|
||||||
|
iny
|
||||||
|
lda (ptr4),y
|
||||||
|
pha
|
||||||
|
|
||||||
|
; Cleanup buffer
|
||||||
|
done: lda ptr4
|
||||||
|
ldx ptr4+1
|
||||||
|
jsr _free
|
||||||
|
|
||||||
|
; Restore total blocks and return
|
||||||
|
pla
|
||||||
|
tax
|
||||||
|
pla
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
nomem: lda #$FF ; Error code for sure not used by MLI
|
||||||
|
oserr: sta __oserror
|
||||||
|
|
||||||
|
; Save total blocks for failure
|
||||||
|
lda #$00
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
beq done ; Branch always
|
||||||
|
|
||||||
|
; Check for non-ProDOS disk
|
||||||
|
check: cmp #$52 ; "Not a ProDOS volume"
|
||||||
|
bne oserr
|
||||||
|
sta __oserror
|
||||||
|
|
||||||
|
; Save total blocks for a 16-sector disk
|
||||||
|
lda #<280
|
||||||
|
pha
|
||||||
|
lda #>280
|
||||||
|
pha
|
||||||
|
bne done ; Branch always
|
||||||
|
Loading…
Reference in New Issue
Block a user