2005-03-31 07:24:01 +00:00
|
|
|
;
|
|
|
|
; Oliver Schmidt, 31.03.2005
|
|
|
|
;
|
2012-10-11 18:22:49 +00:00
|
|
|
; unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
|
2005-03-31 07:24:01 +00:00
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _dio_query_sectcount
|
|
|
|
.import _dio_query_sectsize, _malloc, _free
|
2010-07-17 19:16:25 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "zeropage.inc"
|
|
|
|
.include "errno.inc"
|
|
|
|
.include "mli.inc"
|
2005-03-31 07:24:01 +00:00
|
|
|
|
|
|
|
_dio_query_sectcount:
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Set handle
|
2013-05-09 11:56:54 +00:00
|
|
|
sta mliparam + MLI::ON_LINE::UNIT_NUM
|
2010-07-17 19:16:25 +00:00
|
|
|
|
2022-08-28 19:52:53 +00:00
|
|
|
; Get ProDOS 8 block size (clears ___oserror)
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr _dio_query_sectsize
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Alloc buffer
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr _malloc
|
|
|
|
sta ptr4
|
|
|
|
stx ptr4+1
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Set buffer
|
2013-05-09 11:56:54 +00:00
|
|
|
sta mliparam + MLI::ON_LINE::DATA_BUFFER
|
|
|
|
stx mliparam + MLI::ON_LINE::DATA_BUFFER+1
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Check buffer (hibyte is enough)
|
|
|
|
txa
|
2013-05-09 11:56:54 +00:00
|
|
|
beq nomem
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Get device state
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #ON_LINE_CALL
|
|
|
|
ldx #ON_LINE_COUNT
|
|
|
|
jsr callmli
|
|
|
|
bcs check
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; 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
|
2013-05-09 11:56:54 +00:00
|
|
|
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
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Get and save total blocks from volume directory header
|
2013-05-09 11:56:54 +00:00
|
|
|
ldy #$29
|
|
|
|
lda (ptr4),y
|
2010-07-17 19:16:25 +00:00
|
|
|
pha
|
|
|
|
iny
|
2013-05-09 11:56:54 +00:00
|
|
|
lda (ptr4),y
|
2010-07-17 19:16:25 +00:00
|
|
|
pha
|
|
|
|
|
|
|
|
; Cleanup buffer
|
2013-05-09 11:56:54 +00:00
|
|
|
done: lda ptr4
|
|
|
|
ldx ptr4+1
|
|
|
|
jsr _free
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Restore total blocks and return
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
pla
|
2005-03-31 07:24:01 +00:00
|
|
|
rts
|
2010-07-17 19:16:25 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
nomem: lda #$FF ; Error code for sure not used by MLI
|
2022-08-28 19:52:53 +00:00
|
|
|
oserr: sta ___oserror
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Save total blocks for failure
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #$00
|
2010-07-17 19:16:25 +00:00
|
|
|
pha
|
|
|
|
pha
|
2013-05-09 11:56:54 +00:00
|
|
|
beq done ; Branch always
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Check for non-ProDOS disk
|
2013-05-09 11:56:54 +00:00
|
|
|
check: cmp #$52 ; "Not a ProDOS volume"
|
|
|
|
bne oserr
|
2022-08-28 19:52:53 +00:00
|
|
|
sta ___oserror
|
2010-07-17 19:16:25 +00:00
|
|
|
|
|
|
|
; Save total blocks for a 16-sector disk
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #<280
|
2010-07-17 19:16:25 +00:00
|
|
|
pha
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #>280
|
2010-07-17 19:16:25 +00:00
|
|
|
pha
|
2013-05-09 11:56:54 +00:00
|
|
|
bne done ; Branch always
|