From 98b52f0a5887564157ee6a64096fdeab83cc4749 Mon Sep 17 00:00:00 2001 From: Bobbi Webber-Manners Date: Tue, 2 Jun 2020 21:18:11 -0400 Subject: [PATCH] Fix to cc65 dio_open() function to support ProDOS 2.5+ drive number >2 --- cc65-dio-fix/dioopen.s | 52 +++++++++++++++++++++++++++++++++++++++++ cc65-dio-fix/isdevice.s | 18 ++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 cc65-dio-fix/dioopen.s create mode 100644 cc65-dio-fix/isdevice.s diff --git a/cc65-dio-fix/dioopen.s b/cc65-dio-fix/dioopen.s new file mode 100644 index 0000000..3146a74 --- /dev/null +++ b/cc65-dio-fix/dioopen.s @@ -0,0 +1,52 @@ +; +; Oliver Schmidt, 24.03.2005 +; +; dhandle_t __fastcall__ dio_open (unsigned char device); +; + + .export _dio_open + .import return0, __dos_type, isdevice + + .include "errno.inc" + .include "mli.inc" + .include "zeropage.inc" + +_dio_open: + ; Check for ProDOS 8 + ldx __dos_type + bne :+ + lda #$01 ; "Bad system call number" + bne oserr ; Branch always + + ; Convert from 00DDDSSS format to DSSS00DD format +: tax + clc + asl + asl + asl + asl + sta tmp1 + txa + lsr + lsr + lsr + lsr + ora tmp1 + + ; Check for valid device + tax + + jsr isdevice + beq :+ + lda #$28 ; "No device connected" + + ; Return oserror +oserr: sta __oserror + jmp return0 + + ; Return success +: txa + + ldx #$00 + stx __oserror + rts diff --git a/cc65-dio-fix/isdevice.s b/cc65-dio-fix/isdevice.s new file mode 100644 index 0000000..97c7a83 --- /dev/null +++ b/cc65-dio-fix/isdevice.s @@ -0,0 +1,18 @@ +; +; Oliver Schmidt, 2012-10-15 +; + + .export isdevice + + .include "zeropage.inc" + .include "mli.inc" + +isdevice: + ldy DEVCNT +: lda DEVLST,y + sta tmp1 + cpx tmp1 + beq :+ + dey + bpl :- +: rts