From: cuz Date: Wed, 30 Mar 2005 18:25:04 +0000 (+0000) Subject: dio implementation by Oliver Schmidt X-Git-Tag: V2.12.0~407 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=35676b5c6ba7a0793d70ac0b3d871637a88e2a41;p=cc65 dio implementation by Oliver Schmidt git-svn-id: svn://svn.cc65.org/cc65/trunk@3432 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/apple2/Makefile b/libsrc/apple2/Makefile index 1444ef1d4..c59428871 100644 --- a/libsrc/apple2/Makefile +++ b/libsrc/apple2/Makefile @@ -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 \ diff --git a/libsrc/apple2/dioclose.s b/libsrc/apple2/dioclose.s new file mode 100644 index 000000000..2353d3202 --- /dev/null +++ b/libsrc/apple2/dioclose.s @@ -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 diff --git a/libsrc/apple2/diocommon.s b/libsrc/apple2/diocommon.s new file mode 100644 index 000000000..abfd979a4 --- /dev/null +++ b/libsrc/apple2/diocommon.s @@ -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 diff --git a/libsrc/apple2/dioopen.s b/libsrc/apple2/dioopen.s new file mode 100644 index 000000000..1d114f312 --- /dev/null +++ b/libsrc/apple2/dioopen.s @@ -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 diff --git a/libsrc/apple2/dioread.s b/libsrc/apple2/dioread.s new file mode 100644 index 000000000..21042a3b8 --- /dev/null +++ b/libsrc/apple2/dioread.s @@ -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 diff --git a/libsrc/apple2/diowrite.s b/libsrc/apple2/diowrite.s new file mode 100644 index 000000000..32d44e470 --- /dev/null +++ b/libsrc/apple2/diowrite.s @@ -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 diff --git a/libsrc/apple2/mli.inc b/libsrc/apple2/mli.inc index 6f5368c71..ef77cd2e6 100644 --- a/libsrc/apple2/mli.inc +++ b/libsrc/apple2/mli.inc @@ -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 diff --git a/libsrc/apple2/mli.s b/libsrc/apple2/mli.s new file mode 100644 index 000000000..535ec737e --- /dev/null +++ b/libsrc/apple2/mli.s @@ -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 \ No newline at end of file