2001-07-03 20:24:28 +00:00
|
|
|
;
|
|
|
|
; Maciej 'YTM/Elysium' Witkowiak
|
|
|
|
;
|
|
|
|
; based on Atari version by Christian Groessler
|
|
|
|
; 2.7.2001
|
|
|
|
;
|
2012-10-11 18:22:49 +00:00
|
|
|
; dhandle_t __fastcall__ dio_open (unsigned char device);
|
2001-07-03 20:24:28 +00:00
|
|
|
; unsigned char __fastcall__ dio_close (dhandle_t handle);
|
|
|
|
;
|
|
|
|
; dio_open sets given device as current and initializes disk
|
|
|
|
; dio_close does nothing special
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _dio_open, _dio_close
|
|
|
|
.import __oserror, _OpenDisk
|
|
|
|
.importzp ptr1, tmp1
|
2012-02-07 22:37:13 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "dio.inc"
|
2012-02-07 22:37:13 +00:00
|
|
|
.include "jumptab.inc"
|
|
|
|
.include "geossym.inc"
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "const.inc"
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
.bss
|
|
|
|
|
|
|
|
sectsizetab:
|
2013-05-09 11:56:54 +00:00
|
|
|
.res 4 * sst_size ; this is hardcoded
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
.code
|
|
|
|
|
2012-02-07 22:37:13 +00:00
|
|
|
_dio_open:
|
2013-05-09 11:56:54 +00:00
|
|
|
pha
|
|
|
|
tax
|
|
|
|
lda driveType,x ; check if there's a device
|
|
|
|
beq _inv_drive
|
|
|
|
txa
|
|
|
|
clc
|
|
|
|
adc #8 ; normalize devnum
|
|
|
|
sta curDevice
|
|
|
|
jsr SetDevice
|
|
|
|
jsr _OpenDisk ; take care for errors there
|
2001-07-03 20:24:28 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
pla
|
|
|
|
tay ; drive #
|
|
|
|
asl a ; make index from drive id
|
|
|
|
asl a
|
|
|
|
tax
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta sectsizetab+sst_sectsize,x
|
|
|
|
lda #128
|
|
|
|
sta sectsizetab+sst_flag,x ; set flag that drive is "open"
|
|
|
|
lda #1
|
|
|
|
sta sectsizetab+sst_sectsize+1,x
|
|
|
|
tya
|
|
|
|
sta sectsizetab+sst_driveno,x
|
|
|
|
|
|
|
|
stx tmp1
|
|
|
|
lda #<sectsizetab
|
|
|
|
clc
|
|
|
|
adc tmp1
|
|
|
|
sta tmp1
|
|
|
|
lda #>sectsizetab
|
|
|
|
adc #0
|
|
|
|
tax
|
|
|
|
lda tmp1
|
2001-07-03 20:24:28 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
_inv_drive:
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #DEV_NOT_FOUND
|
|
|
|
sta __oserror
|
|
|
|
lda #0
|
|
|
|
tax
|
|
|
|
rts
|
2001-07-03 20:24:28 +00:00
|
|
|
|
2012-02-07 22:37:13 +00:00
|
|
|
_dio_close:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta ptr1
|
|
|
|
stx ptr1+1
|
|
|
|
lda #0
|
|
|
|
ldy #sst_flag
|
|
|
|
sta (ptr1),y
|
|
|
|
sta __oserror ; success
|
|
|
|
tax
|
|
|
|
rts ; return no error
|