From 2daaa107a06b14425659f707d017787b05e65d34 Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Wed, 9 May 2018 21:39:02 +0200 Subject: [PATCH] Smartport.s added --- AppleIISd.vcxproj | 1 + AppleIISd.vcxproj.filters | 3 +++ src/AppleIISd.inc | 22 ++++++++++++---- src/AppleIISd.s | 54 ++++++++++++--------------------------- src/Helper.s | 4 +-- src/Smartport.s | 40 +++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+), 44 deletions(-) create mode 100644 src/Smartport.s diff --git a/AppleIISd.vcxproj b/AppleIISd.vcxproj index 7b893e5..f2250bb 100644 --- a/AppleIISd.vcxproj +++ b/AppleIISd.vcxproj @@ -19,6 +19,7 @@ + {9EA7EC3D-1771-420F-932F-231A35ED1200} diff --git a/AppleIISd.vcxproj.filters b/AppleIISd.vcxproj.filters index 5c8a181..061ceab 100644 --- a/AppleIISd.vcxproj.filters +++ b/AppleIISd.vcxproj.filters @@ -19,6 +19,9 @@ src + + src + diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 1492ace..24fea4b 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -11,22 +11,35 @@ ; ;******************************* -; Memory defines - +; ZP equates SLOT16 := $2B ; $s0 -> slot * 16 SLOT := $3D ; $0s CMDLO := $40 CMDHI := $41 +; ProDOS equates DCMD := $42 ; Command code -BUFFER := $44 ; Buffer address -BLOCK := $46 ; Block number +DNUMBER := $43 ; drive number +BUFFER := $44 ; buffer pointer +BLOCK := $46 ; block number +; Smartport equates +SMPARAM := $43 ; parameter count +SMUNIT := $44 ; unit number +SMBUFF := $45 ; buffer pointer +SMSTAT := $47 ; status / control code +SMBLOCK := $47 ; block number +SMCOUNT := $47 ; byte count +SMADDR := $49 ; address for read + +; Ram equates R30 := $0478 R31 := $04F8 R32 := $0578 R33 := $05F8 CURSLOT := $07F8 ; $Cs + +; Slot equates OAPPLE := $C061 ; open apple key DATA := $C080 CTRL := DATA+1 @@ -34,7 +47,6 @@ DIV := DATA+2 SS := DATA+3 ; Constants - DUMMY = $FF FRX = $10 ; CTRL register ECE = $04 diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 72c4512..2a43f02 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -11,6 +11,7 @@ ; ;******************************* +.import SMARTPORT .import GETR1 .import GETR3 .import SDCMD @@ -54,25 +55,8 @@ LDX #$03 LDX #$3C -; find slot nr - PHP - SEI - LDA #$60 ; opcode for RTS - STA SLOT - JSR SLOT - TSX - LDA $0100,X - STA CURSLOT ; $Cs - AND #$0F - PLP - STA SLOT ; $0s - ASL A - ASL A - ASL A - ASL A - - STA SLOT16 ; $s0 - TAX ; X holds now SLOT16 +PRODOS: + SEI ; no interrupts if booting BIT $CFFF LDY #0 ; display copyright message @DRAW: LDA TEXT,Y @@ -83,10 +67,7 @@ BPL @DRAW @OAPPLE: BIT OAPPLE ; check for OA key - BMI @NEXTSLOT ; and skip boot if pressed - - JSR CARDDET - BCC @INIT + BPL @BOOT ; and skip boot if pressed @NEXTSLOT: LDA CURSLOT ; skip boot when no card DEC A @@ -94,8 +75,6 @@ STZ CMDLO JMP (CMDLO) -@INIT: JSR INIT - ;******************************* ; @@ -103,23 +82,20 @@ ; ;******************************* -;@BOOT: CMP #0 -; BNE @NEXTSLOT ; init not successful -@BOOT: LDA #$01 +@BOOT: LDA #$01 ; READ STA DCMD ; load command - LDX SLOT16 - STX $43 ; slot number LDA #$08 STA BUFFER+1 ; buffer hi STZ BUFFER ; buffer lo STZ BLOCK+1 ; block hi STZ BLOCK ; block lo - BIT $CFFF - JSR READ ; call driver + LDA #>DRIVER + JSR DRIVER ; call driver + CMP #0 + BNE @NEXTSLOT ; init not successful - LDA #$01 + LDA #$01 ; READ STA DCMD ; load command - LDX SLOT16 STX $43 ; slot number LDA #$0A STA BUFFER+1 ; buffer hi @@ -127,8 +103,9 @@ STZ BLOCK+1 ; block hi LDA #$01 STA BLOCK ; block lo - BIT $CFFF - JSR READ ; call driver + JSR DRIVER ; call driver + CMP #0 + BNE @NEXTSLOT ; init not successful LDX SLOT16 JMP $801 ; goto bootloader @@ -139,7 +116,8 @@ ; ;******************************* -DRIVER: CLD +DRIVER: BRA @SAVEZP ; jump to ProDOS entry + BRA @SMARTPORT ; jump to Smartport entry @SAVEZP: PHA ; make room for retval LDA SLOT16 ; save all ZP locations @@ -211,6 +189,8 @@ DRIVER: CLD PLA ; get retval RTS +@SMARTPORT: JMP SMARTPORT + ;******************************* ; diff --git a/src/Helper.s b/src/Helper.s index eb537ab..d08dd0a 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -122,7 +122,7 @@ GETBLOCK: PHX ; save X STZ R30,X LDA #$80 ; drive number - AND $43 + AND DNUMBER BEQ @SLOT ; D1 LDA #1 ; D2 STA R31,X @@ -130,7 +130,7 @@ GETBLOCK: PHX ; save X @SLOT: LDA SLOT PHA ; save SLOT LDA #$70 ; slot number * 16 - AND $43 + AND DNUMBER STA SLOT CPY SLOT BEQ @RESTORE ; slot number = real slot? diff --git a/src/Smartport.s b/src/Smartport.s new file mode 100644 index 0000000..5f621c5 --- /dev/null +++ b/src/Smartport.s @@ -0,0 +1,40 @@ +;******************************* +; +; Apple][Sd Firmware +; Version 1.2 +; Smartport functions +; +; (c) Florian Reitz, 2017 +; +; X register usually contains SLOT16 +; Y register is used for counting or SLOT +; +;******************************* + +.export SMARTPORT + + +.include "AppleIISd.inc" +.segment "SLOTROM" + + +;******************************* +; +; Status request +; $43 Unit number DSSS000 +; $44-45 Unused +; $46-47 Unused +; +; C Clear - No error +; Set - Error +; A $00 - No error +; $2B - Card write protected +; $2F - No card inserted +; X - Blocks avail (low byte) +; Y - Blocks avail (high byte) +; +;******************************* + +SMARTPORT: PLA ; pull return address + TAY + \ No newline at end of file