mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
dio implementation by Oliver Schmidt
git-svn-id: svn://svn.cc65.org/cc65/trunk@3432 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
069f0a7015
commit
35676b5c6b
@ -49,12 +49,18 @@ OBJS= _scrsize.o \
|
||||
crt0.o \
|
||||
ctype.o \
|
||||
cvline.o \
|
||||
dioclose.o \
|
||||
diocommon.o \
|
||||
dioopen.o \
|
||||
dioread.o \
|
||||
diowrite.o \
|
||||
dosdetect.o \
|
||||
get_ostype.o \
|
||||
getenv.o \
|
||||
joy_stddrv.o \
|
||||
kbhit.o \
|
||||
mainargs.o \
|
||||
mli.o \
|
||||
oserrlist.o \
|
||||
randomize.o \
|
||||
rcout.o \
|
||||
|
12
libsrc/apple2/dioclose.s
Normal file
12
libsrc/apple2/dioclose.s
Normal file
@ -0,0 +1,12 @@
|
||||
;
|
||||
; Oliver Schmidt, 24.03.2005
|
||||
;
|
||||
; unsigned char __fastcall__ dio_close (dhandle_t handle);
|
||||
;
|
||||
|
||||
.export _dio_close
|
||||
.import dioepilog
|
||||
|
||||
_dio_close:
|
||||
lda #$00
|
||||
jmp dioepilog
|
35
libsrc/apple2/diocommon.s
Normal file
35
libsrc/apple2/diocommon.s
Normal file
@ -0,0 +1,35 @@
|
||||
;
|
||||
; Oliver Schmidt, 24.03.2005
|
||||
;
|
||||
|
||||
.export dioprolog, diocommon, dioepilog
|
||||
.import popax
|
||||
|
||||
.include "errno.inc"
|
||||
.include "mli.inc"
|
||||
|
||||
dioprolog:
|
||||
; Set buffer
|
||||
sta mliparam + MLI::RW_BLOCK::DATA_BUFFER
|
||||
stx mliparam + MLI::RW_BLOCK::DATA_BUFFER+1
|
||||
|
||||
; Get and set sect_num
|
||||
jsr popax
|
||||
sta mliparam + MLI::RW_BLOCK::BLOCK_NUM
|
||||
stx mliparam + MLI::RW_BLOCK::BLOCK_NUM+1
|
||||
|
||||
; Get and set handle
|
||||
jsr popax
|
||||
sta mliparam + MLI::RW_BLOCK::UNIT_NUM
|
||||
rts
|
||||
|
||||
diocommon:
|
||||
; Call read_block or write_block
|
||||
ldx #RW_BLOCK_COUNT
|
||||
jsr callmli
|
||||
|
||||
dioepilog:
|
||||
; Return success or error
|
||||
sta __oserror
|
||||
ldx #$00
|
||||
rts
|
53
libsrc/apple2/dioopen.s
Normal file
53
libsrc/apple2/dioopen.s
Normal file
@ -0,0 +1,53 @@
|
||||
;
|
||||
; Oliver Schmidt, 24.03.2005
|
||||
;
|
||||
; dhandle_t __fastcall__ dio_open (driveid_t drive_id);
|
||||
;
|
||||
; drive_id = (slot * 2) + (drive - 1)
|
||||
|
||||
.export _dio_open
|
||||
.import decaxy, return0
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "errno.inc"
|
||||
.include "mli.inc"
|
||||
|
||||
_dio_open:
|
||||
; Convert drive id into unit number
|
||||
lsr
|
||||
bcc :+
|
||||
ora #%00001000
|
||||
: asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
sta mliparam + MLI::ON_LINE::UNIT_NUM
|
||||
|
||||
; Alloc 16-byte buffer just below stack
|
||||
ldy #16
|
||||
lda sp
|
||||
ldx sp+1
|
||||
jsr decaxy
|
||||
sta mliparam + MLI::ON_LINE::DATA_BUFFER
|
||||
stx mliparam + MLI::ON_LINE::DATA_BUFFER+1
|
||||
|
||||
; Get device state
|
||||
lda #ON_LINE_CALL
|
||||
ldx #ON_LINE_COUNT
|
||||
jsr callmli
|
||||
bcc :+
|
||||
|
||||
; DIO level access doesn't necessarily need a
|
||||
; ProDOS 8 disk so ignore "high level" errors
|
||||
cmp #$40
|
||||
bcc oserr
|
||||
|
||||
; Return success
|
||||
: lda mliparam + MLI::ON_LINE::UNIT_NUM
|
||||
ldx #$00
|
||||
stx __oserror
|
||||
rts
|
||||
|
||||
; Return oserror
|
||||
oserr: sta __oserror
|
||||
jmp return0
|
15
libsrc/apple2/dioread.s
Normal file
15
libsrc/apple2/dioread.s
Normal file
@ -0,0 +1,15 @@
|
||||
;
|
||||
; Oliver Schmidt, 24.03.2005
|
||||
;
|
||||
; unsigned char __fastcall__ dio_read (dhandle_t handle, sectnum_t sect_num, void *buffer);
|
||||
;
|
||||
|
||||
.export _dio_read
|
||||
.import dioprolog, diocommon
|
||||
|
||||
.include "mli.inc"
|
||||
|
||||
_dio_read:
|
||||
jsr dioprolog
|
||||
lda #READ_BLOCK_CALL
|
||||
jmp diocommon
|
15
libsrc/apple2/diowrite.s
Normal file
15
libsrc/apple2/diowrite.s
Normal file
@ -0,0 +1,15 @@
|
||||
;
|
||||
; Oliver Schmidt, 24.03.2005
|
||||
;
|
||||
; unsigned char __fastcall__ dio_write (dhandle_t handle, sectnum_t sect_num, const void *buffer);
|
||||
;
|
||||
|
||||
.export _dio_write
|
||||
.import dioprolog, diocommon
|
||||
|
||||
.include "mli.inc"
|
||||
|
||||
_dio_write:
|
||||
jsr dioprolog
|
||||
lda #WRITE_BLOCK_CALL
|
||||
jmp diocommon
|
@ -4,6 +4,10 @@
|
||||
; Apple ProDOS 8 MLI
|
||||
;
|
||||
|
||||
READ_BLOCK_CALL = $80
|
||||
WRITE_BLOCK_CALL= $81
|
||||
RW_BLOCK_COUNT = 3
|
||||
|
||||
CREATE_CALL = $C0
|
||||
CREATE_COUNT = 7
|
||||
|
||||
@ -30,6 +34,12 @@ EOF_COUNT = 2
|
||||
|
||||
.struct MLI
|
||||
.union
|
||||
.struct RW_BLOCK
|
||||
PARAM_COUNT .byte
|
||||
UNIT_NUM .byte
|
||||
DATA_BUFFER .addr
|
||||
BLOCK_NUM .word
|
||||
.endstruct
|
||||
.struct CREATE
|
||||
PARAM_COUNT .byte
|
||||
PATHNAME .addr
|
||||
|
35
libsrc/apple2/mli.s
Normal file
35
libsrc/apple2/mli.s
Normal file
@ -0,0 +1,35 @@
|
||||
;
|
||||
; Oliver Schmidt, 30.12.2004
|
||||
;
|
||||
; Apple ProDOS 8 MLI
|
||||
;
|
||||
|
||||
.import __dos_type
|
||||
|
||||
.include "mli.inc"
|
||||
|
||||
.bss
|
||||
|
||||
mliparam: .tag MLI
|
||||
|
||||
.data
|
||||
|
||||
callmli:
|
||||
; Store parameters
|
||||
sta call
|
||||
stx mliparam
|
||||
|
||||
; Check for ProDOS 8
|
||||
lda __dos_type
|
||||
beq oserr
|
||||
|
||||
; Call MLI and return
|
||||
jsr ENTRY
|
||||
call: .byte $00
|
||||
.word mliparam
|
||||
rts
|
||||
|
||||
; Load oserror code and return
|
||||
oserr: lda #$01 ; "Invalid MLI function code number"
|
||||
sec
|
||||
rts
|
Loading…
Reference in New Issue
Block a user