2 ; Oliver Schmidt, 31.03.2005
4 ; unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
7 .export _dio_query_sectcount
8 .import _dio_query_sectsize, _malloc, _free
10 .include "zeropage.inc"
17 sta mliparam + MLI::ON_LINE::UNIT_NUM
19 ; Get ProDOS 8 block size (clears __oserror)
20 jsr _dio_query_sectsize
28 sta mliparam + MLI::ON_LINE::DATA_BUFFER
29 stx mliparam + MLI::ON_LINE::DATA_BUFFER+1
31 ; Check buffer (hibyte is enough)
41 ; UNIT_NUM already set
42 .assert MLI::RW_BLOCK::UNIT_NUM = MLI::ON_LINE::UNIT_NUM, error
44 ; DATA_BUFFER already set
45 .assert MLI::RW_BLOCK::DATA_BUFFER = MLI::ON_LINE::DATA_BUFFER, error
47 ; Read volume directory key block
50 sta mliparam + MLI::RW_BLOCK::BLOCK_NUM
51 stx mliparam + MLI::RW_BLOCK::BLOCK_NUM+1
57 ; Get and save total blocks from volume directory header
70 ; Restore total blocks and return
76 nomem: lda #$FF ; Error code for sure not used by MLI
79 ; Save total blocks for failure
83 beq done ; Branch always
85 ; Check for non-ProDOS disk
86 check: cmp #$52 ; "Not a ProDOS volume"
90 ; Save total blocks for a 16-sector disk
95 bne done ; Branch always