mirror of
https://github.com/cc65/cc65.git
synced 2025-01-03 01:31:55 +00:00
clean up
git-svn-id: svn://svn.cc65.org/cc65/trunk@3396 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
244aac991b
commit
50319e2a4f
@ -16,7 +16,7 @@
|
|||||||
.export sectsizetab
|
.export sectsizetab
|
||||||
.import __oserror, __sio_call, _dio_read
|
.import __oserror, __sio_call, _dio_read
|
||||||
.import pushax, addysp, subysp
|
.import pushax, addysp, subysp
|
||||||
.importzp ptr2, tmp1, sp
|
.importzp ptr2, sp
|
||||||
.include "atari.inc"
|
.include "atari.inc"
|
||||||
|
|
||||||
|
|
||||||
@ -27,34 +27,7 @@ sectsizetab:
|
|||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
|
; code for _dio_open
|
||||||
.proc _dio_open
|
|
||||||
|
|
||||||
cmp #NUMDRVS ; valid drive id?
|
|
||||||
bcs _inv_drive
|
|
||||||
tay ; drive #
|
|
||||||
asl a ; make index from drive id
|
|
||||||
asl a
|
|
||||||
tax
|
|
||||||
lda #128 ; preset sectsize, will be overridden by query_sectorsize
|
|
||||||
sta sectsizetab+sst_sectsize,x
|
|
||||||
sta sectsizetab+sst_flag,x ; set flag that drive is "open"
|
|
||||||
lda #0
|
|
||||||
sta sectsizetab+sst_sectsize+1,x
|
|
||||||
sta __oserror ; success
|
|
||||||
tya
|
|
||||||
sta sectsizetab+sst_driveno,x
|
|
||||||
stx tmp1
|
|
||||||
lda #<sectsizetab
|
|
||||||
clc
|
|
||||||
adc tmp1
|
|
||||||
sta tmp1
|
|
||||||
lda #>sectsizetab
|
|
||||||
adc #0
|
|
||||||
tax
|
|
||||||
lda tmp1
|
|
||||||
jmp query_sectorsize ; query drive for current sector size
|
|
||||||
; rts
|
|
||||||
|
|
||||||
_inv_drive:
|
_inv_drive:
|
||||||
lda #NONDEV ; non-existent device
|
lda #NONDEV ; non-existent device
|
||||||
@ -63,80 +36,80 @@ _inv_drive:
|
|||||||
tax
|
tax
|
||||||
rts ; return NULL
|
rts ; return NULL
|
||||||
|
|
||||||
.endproc
|
_dio_open:
|
||||||
|
|
||||||
.proc _dio_close
|
cmp #NUMDRVS ; valid drive id?
|
||||||
|
bcs _inv_drive
|
||||||
sta ptr2
|
tay ; drive #
|
||||||
stx ptr2+1
|
asl a ; make index from drive id
|
||||||
lda #0
|
asl a
|
||||||
ldy #sst_flag
|
|
||||||
sta (ptr2),y
|
|
||||||
sta __oserror ; success
|
|
||||||
tax
|
tax
|
||||||
rts ; return no error
|
lda #128 ; preset sectsize
|
||||||
|
sta sectsizetab+sst_sectsize,x
|
||||||
.endproc
|
sta sectsizetab+sst_flag,x ; set flag that drive is "open"
|
||||||
|
lda #0
|
||||||
|
sta sectsizetab+sst_sectsize+1,x
|
||||||
|
sta __oserror ; success
|
||||||
|
tya
|
||||||
|
sta sectsizetab+sst_driveno,x
|
||||||
|
stx ptr2
|
||||||
|
lda #<sectsizetab
|
||||||
|
clc
|
||||||
|
adc ptr2
|
||||||
|
sta ptr2
|
||||||
|
lda #>sectsizetab
|
||||||
|
adc #0
|
||||||
|
tax
|
||||||
|
stx ptr2+1 ; ptr2: pointer to sectsizetab entry
|
||||||
|
|
||||||
; query drive for current sector size
|
; query drive for current sector size
|
||||||
; procedure:
|
; procedure:
|
||||||
; - read sector #4 (SIO command $54) to update drive status
|
; - read sector #4 (SIO command $54) to update drive status;
|
||||||
; read length is 128 bytes, buffer is below the stack pointer,
|
; read length is 128 bytes, buffer is allocated on the stack,
|
||||||
; sector data is ignored
|
; sector data is ignored;
|
||||||
; command status is ignored, we will get an error with a DD disk
|
; returned command status is ignored, we will get an error with
|
||||||
; anyway (read size 128 vs. sector size 256)
|
; a DD disk anyway (read size 128 vs. sector size 256);
|
||||||
; - issue SIO command $53 (get status) to retrieve the sector size
|
; - issue SIO command $53 (get status) to retrieve the sector size;
|
||||||
; if the command returns with an error, we set sector size to 128
|
; use the DVSTAT system area as return buffer;
|
||||||
; bytes
|
; if the command returns with an error, set sector size to 128
|
||||||
|
; bytes;
|
||||||
;
|
;
|
||||||
; AX - handle
|
|
||||||
;
|
|
||||||
.proc query_sectorsize
|
|
||||||
|
|
||||||
sta ptr2
|
|
||||||
stx ptr2+1 ; remember pointer to sectsizetab entry
|
|
||||||
|
|
||||||
; jsr pushax ; handle for subsequent __sio_call
|
|
||||||
|
|
||||||
ldy #128
|
ldy #128
|
||||||
jsr subysp ; use buffer on the stack
|
jsr subysp ; allocate buffer on the stack
|
||||||
|
|
||||||
lda sp
|
lda sp
|
||||||
pha
|
pha
|
||||||
lda sp+1
|
lda sp+1
|
||||||
pha
|
pha ; save sp (buffer address) on processor stack
|
||||||
|
|
||||||
lda ptr2
|
lda ptr2
|
||||||
ldx ptr2+1
|
ldx ptr2+1
|
||||||
|
|
||||||
jsr pushax ; handle
|
jsr pushax ; handle
|
||||||
|
|
||||||
ldx #0
|
ldx #0
|
||||||
lda #4
|
lda #4
|
||||||
jsr pushax ; sect_num
|
jsr pushax ; sect_num
|
||||||
|
|
||||||
; ldy #128
|
|
||||||
; jsr subysp ; use buffer on the stack
|
|
||||||
; lda sp
|
|
||||||
; ldx sp+1
|
|
||||||
pla
|
pla
|
||||||
tax
|
tax
|
||||||
pla
|
pla ; AX - buffer address
|
||||||
; jsr pushax ; buffer address (not pushed, _dio_read is __fastcall__)
|
|
||||||
|
|
||||||
|
; sst_sectsize currently 128
|
||||||
jsr _dio_read ; read sector to update status
|
jsr _dio_read ; read sector to update status
|
||||||
|
|
||||||
ldy #128
|
ldy #128
|
||||||
jsr addysp ; discard stack buffer
|
jsr addysp ; discard stack buffer
|
||||||
|
|
||||||
|
|
||||||
lda ptr2
|
lda ptr2
|
||||||
ldx ptr2+1
|
ldx ptr2+1
|
||||||
jsr pushax ; handle for subsequent __sio_call
|
jsr pushax ; handle
|
||||||
|
|
||||||
|
|
||||||
ldx #0
|
ldx #0
|
||||||
lda #4
|
lda #4
|
||||||
jsr pushax ; dummy sector #
|
jsr pushax ; dummy sector #, ignored by this SIO command,
|
||||||
|
; but set to circumvent the special 1-3 sector
|
||||||
|
; handling in __sio_call
|
||||||
|
|
||||||
ldx #>DVSTAT
|
ldx #>DVSTAT
|
||||||
lda #<DVSTAT
|
lda #<DVSTAT
|
||||||
@ -158,12 +131,11 @@ _inv_drive:
|
|||||||
and #%100000
|
and #%100000
|
||||||
beq s128
|
beq s128
|
||||||
|
|
||||||
|
;s256
|
||||||
lda #0
|
lda #0
|
||||||
sta (ptr2),y
|
sta (ptr2),y
|
||||||
iny
|
iny
|
||||||
lda #1
|
lda #1
|
||||||
; sta (ptr2),y
|
|
||||||
; bne fini2
|
|
||||||
|
|
||||||
finish: sta (ptr2),y ; set default sector size
|
finish: sta (ptr2),y ; set default sector size
|
||||||
fini2: lda ptr2
|
fini2: lda ptr2
|
||||||
@ -174,4 +146,18 @@ error: ldy #sst_sectsize
|
|||||||
s128: lda #128
|
s128: lda #128
|
||||||
bne finish
|
bne finish
|
||||||
|
|
||||||
|
; end of _dio_open
|
||||||
|
|
||||||
|
|
||||||
|
.proc _dio_close
|
||||||
|
|
||||||
|
sta ptr2
|
||||||
|
stx ptr2+1
|
||||||
|
lda #0
|
||||||
|
ldy #sst_flag
|
||||||
|
sta (ptr2),y
|
||||||
|
sta __oserror ; success
|
||||||
|
tax
|
||||||
|
rts ; return no error
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
Loading…
Reference in New Issue
Block a user