From fe9ae43e0985d9813d549e1a312e124dcb6f8f04 Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Sun, 17 Dec 2017 21:27:04 +0100 Subject: [PATCH 01/13] Test with phantom slots --- AppleIISd.bin | Bin 2048 -> 2048 bytes AppleIISd.hex | 110 ++++++++++++++++++++++++------------------------ src/AppleIISd.s | 8 ++-- src/Helper.s | 23 +++++++--- src/ProDOS.s | 2 +- 5 files changed, 78 insertions(+), 65 deletions(-) diff --git a/AppleIISd.bin b/AppleIISd.bin index 7fd67506259b4d507a13624229f075c668604caf..dfb6e64bba86fded5397125ea453e5d8c5a63c2e 100644 GIT binary patch delta 156 zcmV;N0Av4v5P%SnJON6PJtrG*%BcZ`LZ&N*L#YadMPx)|N2vjYMlAo&AaId?GyzJH zv>*#&%770baLRxRAlZ@M9|5o%jT$JxHl= zB}0Wh#69o_z4!zgo%jT3g*}t<0$u@DlTia00V0!X16vbT%CKi3&&j=mz$yNngTSd+ KAR@Ea0}}*i-aY~V delta 158 zcmZn=Xb_lS!)Q9uR$V&!)Jn!yr)Ao0&MUcET~l0A+<|;Io&V<*q9@jy0M%?!;PyS$ zz^@Q}s)0-4$i(~djMF#%S7T%}oUF#QQ+OrA+#f7+D_B-Gs5*aOUC9XKO=f3~lX5&Y zfoY}oqW=s2Cn%ghxwrX%=D)ek2UZ3u@J_C0juv)2wILl@JVJqY^IK+NmdOb$q5$~- BK%W2r diff --git a/AppleIISd.hex b/AppleIISd.hex index 6a00ac3..912b571 100644 --- a/AppleIISd.hex +++ b/AppleIISd.hex @@ -1,72 +1,72 @@ :10000000A220A200A203A23C0878A960853D203D61 :1000100000BABD00018DF807290F28853D0A0A0A9C -:100020000A852BAA2CFFCFA000B9DECAF0080980F0 -:10003000995007C810F32C61C0300520DEC9900B21 +:100020000A852BAA2CFFCFA000B916C9F0080980B9 +:10003000995007C810F32C61C03005204ACA900BB4 :10004000ADF8073A854164406C40002000C8A90122 :100050008542A62B8643A9088545644464476446C7 -:100060002CFFCF2004CAA9018542A62B8643A90AEA -:10007000854564446447A90185462CFFCF2004CA06 +:100060002CFFCF2070CAA9018542A62B8643A90A7E +:10007000854564446447A90185462CFFCF2070CA9A :10008000A62B4C0108D848A52B48A53D48A54048BB :10009000A541480878A960853D203D00BABD000112 :1000A0008DF807290F28853D0A0A0A0A852BAA2CF4 -:1000B000FFCF20DEC99004A92F802CA9803C83C0EB +:1000B000FFCF204ACA9004A92F802CA9803C83C07E :1000C000F020A542F00DC901F00EC902F00FA90100 -:1000D00038801420F6C9800F2004CA800A206DCA17 +:1000D0003880142062CA800F2070CA800A20D9CAD2 :1000E00080052000C890DBBA9D05016885416885C0 -:1000F0004068853D68852B6860000000FFFF97859C +:1000F0004068853D68852B6860000000FFFFB7857C :10010000A9039D81C0BD83C009019D83C0A9079D2E :1001100082C0A00AA9FF9D80C03C81C010FB88D08E -:10012000F5BD83C029FE9D83C0A9058540A9CB8567 -:10013000412016C9202AC9C901D065A9118540A945 -:10014000CB85412016C92043C9C901D056A43DB969 -:10015000F805C9AAD04AA91D8540A9CB854120161A -:10016000C9202AC9A9298540A9CB85412016C920C3 -:100170002AC9C901F0E0C900D026A9238540A9CB2E -:1001800085412016C92043C9C900D014A43DB978BF +:10012000F5BD83C029FE9D83C0A93D8540A9C98531 +:1001300041206DC92081C9C901D065A9498540A95F +:10014000C98541206DC9209AC9C901D056A43DB9BD +:10015000F805C9AAD04AA9558540A9C98541206D8D +:10016000C92081C9A9618540A9C98541206DC920DF +:1001700081C9C901F0E0C900D026A95B8540A9C9A1 +:100180008541206DC9209AC9C900D014A43DB97811 :10019000042940F048BD83C009109D83C04CEFC8BE -:1001A0004C04C9A91D8540A9CB85412016C9A92F9A -:1001B0008540A9CB85412016C9202AC9C901F0E391 -:1001C000C900D0034CDDC8A90B8540A9CB854120CF -:1001D00016C9202AC9C901F0F6C900D027A9178578 -:1001E00040A9CB85412016C9202AC9C900D015BD18 +:1001A0004C04C9A9558540A9C98541206DC9A967D5 +:1001B0008540A9C98541206DC92081C9C901F0E3E5 +:1001C000C900D0034CDDC8A9438540A9C985412099 +:1001D0006DC92081C9C901F0F6C900D027A94F8592 +:1001E00040A9C98541206DC92081C9C900D015BD6C :1001F00083C009809D83C0BD81C009049D81C01852 :10020000A000900338A027BD83C009019D83C0A929 -:10021000009D82C098605AA000B1409D80C03C8182 -:10022000C010FBC8C00690F17A60A9FF9D80C03C59 -:1002300081C010FBBD80C08980D0EF48A9FF9D80A0 -:10024000C06860202AC9485AA0044C52C9A9FF9D21 -:1002500080C03C81C010FBBD80C04888D0EFA43D69 -:100260006899F805689978056899F8046899780498 -:100270007AA9FF9D80C06860DA5A8AA8A63DA54683 -:100280009DF805A5479D7805A9009DF8049D780473 -:10029000A9802543F005A9019DF804A9103983C060 -:1002A000D011A0091EF8053E78053EF8043E7804FA -:1002B00088D0F17AFA605AA43D9D80C0B978049D37 -:1002C00080C0B9F8049D80C0B978059D80C0B9F898 -:1002D000059D80C0A9FF9D80C0202AC97A6048A9D9 -:1002E000403C83C018F00138686048A9203C83C0B6 -:1002F00018F001386860A90020EAC99002A92BA271 -:10030000FFA0FF602078C9BD83C029FE9D83C0A9DE -:100310005120B6C9C900D050A9FF9D80C0BD80C082 -:10032000C9FED0F4BD81C009109D81C0A9FF9D8088 -:10033000C0A000BD80C09144C8D0F8E645BD80C0D3 -:100340009144C8D0F8C645BD80C0BD80C0BD80C046 -:10035000BD81C029EF9D81C018A9000848BD83C098 -:1003600009019D83C068286038A92780EE20EAC96A -:10037000B0672078C9BD83C029FE9D83C0A95820DD -:10038000B6C9C900D04EA9FF9D80C0A9FE9D80C0FE -:10039000A000B1449D80C0C8D0F8E645B1449D801E -:1003A000C0C8D0F8C645A9FF9D80C09D80C09D8073 -:1003B000C0BD80C0291FC905D01A18A9000848A9C6 -:1003C000FF9D80C0BD80C0F0F6BD83C009019D8344 -:1003D000C068286038A92780E438A92B80DF202056 -:1003E0004170706C655D5B53642076312E3120283E -:1003F00063293230313720466C6F7269616E20524A -:100400006569747A0040000000009541000000001A -:10041000F948000001AA875000000200FF770000A1 -:100420000000FF7A00000000FF69400000007769CB -:1004300000000000FF0000000000000000000000BD -:1004400000000000000000000000000000000000AC +:10021000009D82C0986020204170706C655D5B53CA +:10022000642076312E312028632932303137204640 +:100230006C6F7269616E20526569747A00400000CB +:100240000000954100000000F948000001AA875015 +:1002500000000200FF7700000000FF7A00000000AD +:10026000FF6940000000776900000000FF5AA0000D +:10027000B1409D80C03C81C010FBC8C00690F17A9F +:1002800060A9FF9D80C03C81C010FBBD80C08980FB +:10029000D0EF48A9FF9D80C068602081C9485AA05E +:1002A000044CA9C9A9FF9D80C03C81C010FBBD8042 +:1002B000C04888D0EFA43D6899F80568997805682A +:1002C00099F804689978047AA9FF9D80C06860DA7B +:1002D0005A8AA8A63DA5469DF805A5479D78059E86 +:1002E000F8049E7804A9802543F005A9019DF8042F +:1002F000A53D48A9702543853DC43DF007BDF804E0 +:100300001A9DF80468853DA9103983C0D011A00951 +:100310001EF8053E78053EF8043E780488D0F17A50 +:10032000FA605AA43D9D80C0B978049D80C0B9F898 +:10033000049D80C0B978059D80C0B9F8059D80C036 +:10034000A9FF9D80C02081C97A6048A9403C83C034 +:1003500018F00138686048A9203C83C018F00138C3 +:100360006860A9002056CA9002A92BA2FFA0FF60D6 +:1003700020CFC9BD83C029FE9D83C0A9512022CAB8 +:10038000C900D050A9FF9D80C0BD80C0C9FED0F477 +:10039000BD81C009109D81C0A9FF9D80C0A000BD86 +:1003A00080C09144C8D0F8E645BD80C09144C8D013 +:1003B000F8C645BD80C0BD80C0BD80C0BD81C0291C +:1003C000EF9D81C018A9000848BD83C009019D8325 +:1003D000C068286038A92780EE2056CAB06720CFB1 +:1003E000C9BD83C029FE9D83C0A9582022CAC90067 +:1003F000D04EA9FF9D80C0A9FE9D80C0A000B14441 +:100400009D80C0C8D0F8E645B1449D80C0C8D0F8F2 +:10041000C645A9FF9D80C09D80C09D80C0BD80C095 +:10042000291FC905D01A18A9000848A9FF9D80C036 +:10043000BD80C0F0F6BD83C009019D83C0682860FF +:1004400038A92780E438A92B80DF000000000000D5 :10045000000000000000000000000000000000009C :10046000000000000000000000000000000000008C :10047000000000000000000000000000000000007C diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 9e3c3a2..72c4512 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -1,7 +1,7 @@ ;******************************* ; ; Apple][Sd Firmware -; Version 1.1 +; Version 1.2 ; Main source ; ; (c) Florian Reitz, 2017 @@ -29,14 +29,14 @@ ; 65535 blocks ; Removable media ; Non-interruptable -; 2 drives +; 4 drives ; Read, write and status allowed ; ;******************************* .segment "SLOTID" .dbyt $FFFF ; 65535 blocks - .byt $97 ; Status bits + .byt $B7 ; Status bits .byt Date: Wed, 9 May 2018 21:39:02 +0200 Subject: [PATCH 02/13] 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 From 048d1df99a4dfb6f54218cc541318e9a8e47c06f Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Sun, 13 May 2018 17:58:02 +0200 Subject: [PATCH 03/13] Error codes added --- src/AppleIISd.inc | 20 +++++++++++++++++--- src/AppleIISd.s | 17 +++++++++-------- src/Helper.s | 6 +++--- src/ProDOS.s | 17 ++++++++--------- src/Smartport.s | 2 +- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 24fea4b..5c7312d 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -1,10 +1,10 @@ ;******************************* ; ; Apple][Sd Firmware -; Version 1.1 +; Version 1.2 ; Defines ; -; (c) Florian Reitz, 2017 +; (c) Florian Reitz, 2017 - 2018 ; ; X register usually contains SLOT16 ; Y register is used for counting or SLOT @@ -19,7 +19,7 @@ CMDHI := $41 ; ProDOS equates DCMD := $42 ; Command code -DNUMBER := $43 ; drive number +DSNUMBER := $43 ; drive / slot number BUFFER := $44 ; buffer pointer BLOCK := $46 ; block number @@ -55,3 +55,17 @@ SDHC = $10 WP = $20 CD = $40 INITED = $80 + +; Error codes +NO_ERR = $00 +ERR_BAD_CMD = $01 +ERR_BAD_PCNT = $04 +ERR_BUS_ERR = $06 +ERR_BAD_UNIT = $11 +ERR_BAD_CTL = $21 +ERR_BAD_CTL_PARM = $22 +ERR_IO_ERR = $27 +ERR_NO_DRIVE = $28 +ERR_NO_WRITE = $2B +ERR_BAD_BLOCK = $2D +ERR_OFF_LINE = $2F diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 2a43f02..bbfff56 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -4,7 +4,7 @@ ; Version 1.2 ; Main source ; -; (c) Florian Reitz, 2017 +; (c) Florian Reitz, 2017 - 2018 ; ; X register usually contains SLOT16 ; Y register is used for counting or SLOT @@ -96,7 +96,7 @@ PRODOS: LDA #$01 ; READ STA DCMD ; load command - STX $43 ; slot number + STX DSNUMBER ; slot number LDA #$0A STA BUFFER+1 ; buffer hi STZ BUFFER ; buffer lo @@ -149,20 +149,21 @@ DRIVER: BRA @SAVEZP ; jump to ProDOS entry BIT $CFFF JSR CARDDET BCC @INITED - LDA #$2F ; no card inserted + LDA ERR_OFF_LINE; no card inserted BRA @RESTZP @INITED: LDA #INITED ; check for init BIT SS,X BEQ @INIT +; TODO use jump table @CMD: LDA DCMD ; get command BEQ @STATUS ; branch if cmd is 0 CMP #1 BEQ @READ CMP #2 BEQ @WRITE - LDA #1 ; unknown command + LDA ERR_BAD_CMD ; unknown command SEC BRA @RESTZP @@ -210,7 +211,7 @@ INIT: LDA #$03 ; set SPI mode 3 LDA SS,X ORA #SS0 ; set CS high STA SS,X - LDA #7 + LDA #7 ; set 400 kHz STA DIV,X LDY #10 LDA #DUMMY @@ -331,11 +332,11 @@ INIT: LDA #$03 ; set SPI mode 3 ORA #ECE ; enable 7MHz STA CTRL,X CLC ; all ok - LDY #0 + LDY NO_ERR BCC @END1 @IOERROR: SEC - LDY #$27 ; init error + LDY ERR_IO_ERR ; init error @END1: LDA SS,X ; set CS high ORA #SS0 STA SS,X @@ -345,7 +346,7 @@ INIT: LDA #$03 ; set SPI mode 3 RTS -TEXT: .asciiz " Apple][Sd v1.2 (c)2017 Florian Reitz" +TEXT: .asciiz " Apple][Sd v1.2 (c)2018 Florian Reitz" CMD0: .byt $40, $00, $00 .byt $00, $00, $95 diff --git a/src/Helper.s b/src/Helper.s index d08dd0a..3915b5e 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -4,7 +4,7 @@ ; Version 1.2 ; Helper functions ; -; (c) Florian Reitz, 2017 +; (c) Florian Reitz, 2017 - 2018 ; ; X register usually contains SLOT16 ; Y register is used for counting or SLOT @@ -122,7 +122,7 @@ GETBLOCK: PHX ; save X STZ R30,X LDA #$80 ; drive number - AND DNUMBER + AND DSNUMBER 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 DNUMBER + AND DSNUMBER STA SLOT CPY SLOT BEQ @RESTORE ; slot number = real slot? diff --git a/src/ProDOS.s b/src/ProDOS.s index e85bfd4..7d045d0 100644 --- a/src/ProDOS.s +++ b/src/ProDOS.s @@ -4,7 +4,7 @@ ; Version 1.2 ; ProDOS functions ; -; (c) Florian Reitz, 2017 +; (c) Florian Reitz, 2017 - 2018 ; ; X register usually contains SLOT16 ; Y register is used for counting or SLOT @@ -37,16 +37,15 @@ ; Set - Error ; A $00 - No error ; $2B - Card write protected -; $2F - No card inserted ; X - Blocks avail (low byte) ; Y - Blocks avail (high byte) ; ;******************************* -STATUS: LDA #0 ; no error +STATUS: LDA NO_ERR ; no error JSR WRPROT BCC @DONE - LDA #$2B ; card write protected + LDA ERR_NO_WRITE; card write protected @DONE: LDX #$FF ; 32 MB partition LDY #$FF @@ -109,7 +108,7 @@ READ: JSR GETBLOCK ; calc block address AND #<~FRX STA CTRL,X CLC ; no error - LDA #0 + LDA NO_ERR @DONE: PHP PHA @@ -121,7 +120,7 @@ READ: JSR GETBLOCK ; calc block address RTS @ERROR: SEC ; an error occured - LDA #$27 + LDA ERR_IO_ERR BRA @DONE @@ -180,7 +179,7 @@ WRITE: JSR WRPROT CMP #$05 BNE @IOERROR ; check for write error CLC ; no error - LDA #0 + LDA NO_ERR @DONE: PHP PHA @@ -197,9 +196,9 @@ WRITE: JSR WRPROT RTS @IOERROR: SEC ; an error occured - LDA #$27 + LDA ERR_IO_ERR BRA @DONE @WPERROR: SEC - LDA #$2B + LDA ERR_NO_WRITE BRA @DONE diff --git a/src/Smartport.s b/src/Smartport.s index 5f621c5..4d10ec1 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -4,7 +4,7 @@ ; Version 1.2 ; Smartport functions ; -; (c) Florian Reitz, 2017 +; (c) Florian Reitz, 2017 - 2018 ; ; X register usually contains SLOT16 ; Y register is used for counting or SLOT From 515c19684e3d62bca9e191a7ab69be59ced4cf02 Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Sun, 13 May 2018 17:58:41 +0200 Subject: [PATCH 04/13] ProDOS jump table moved --- src/AppleIISd.cfg | 2 +- src/AppleIISd.inc | 53 ++++++++++++++++++++++++++--------------------- src/AppleIISd.s | 51 +++++++++++++++------------------------------ src/Helper.s | 29 ++++++++++---------------- src/ProDOS.s | 43 ++++++++++++++++++++++++++++++++------ 5 files changed, 95 insertions(+), 83 deletions(-) diff --git a/src/AppleIISd.cfg b/src/AppleIISd.cfg index d8c0b60..8ce9bef 100644 --- a/src/AppleIISd.cfg +++ b/src/AppleIISd.cfg @@ -10,7 +10,7 @@ MEMORY { BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__; SLOTROM: file = %O, fill = yes start = $C700, size = $00FC; - SLOTID: file = %O, start = $C7FC, size = $0004; + SLOTID: file = %O, start = $C7FB, size = $0005; EXTROM: file = %O, fill = yes start = $C800, size = $0700; } SEGMENTS { diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 5c7312d..3ff3e04 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -11,26 +11,31 @@ ; ;******************************* -; ZP equates -SLOT16 := $2B ; $s0 -> slot * 16 -SLOT := $3D ; $0s +; ZP locations +SLOT16 := $3E ; $s0 -> slot * 16 +SLOT := $3F ; $0s CMDLO := $40 CMDHI := $41 +PDZPAREA = SLOT16 +PDZPSIZE = CMDHI-PDZPAREA+1 -; ProDOS equates +; ProDOS DCMD := $42 ; Command code DSNUMBER := $43 ; drive / slot number BUFFER := $44 ; buffer pointer -BLOCK := $46 ; block number +BLOCKNUM := $46 ; block number + + +; Smartport +SMPARAM := $48 ; parameter count +SMUNIT := $49 ; unit number +SMBUFF := $4A ; buffer pointer +SMSTAT := $4B ; status / control code +SMBLOCK := $4C ; block number +SMCOUNT := $4D ; byte count +SMADDR := $4E ; address for read + -; 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 @@ -58,14 +63,14 @@ INITED = $80 ; Error codes NO_ERR = $00 -ERR_BAD_CMD = $01 -ERR_BAD_PCNT = $04 -ERR_BUS_ERR = $06 -ERR_BAD_UNIT = $11 -ERR_BAD_CTL = $21 -ERR_BAD_CTL_PARM = $22 -ERR_IO_ERR = $27 -ERR_NO_DRIVE = $28 -ERR_NO_WRITE = $2B -ERR_BAD_BLOCK = $2D -ERR_OFF_LINE = $2F +ERR_BADCMD = $01 +ERR_BADPCNT = $04 +ERR_BUSERR = $06 +ERR_BADUNIT = $11 +ERR_BADCTL = $21 +ERR_BADCTLPARM = $22 +ERR_IOERR = $27 +ERR_NODRIVE = $28 +ERR_NOWRITE = $2B +ERR_BADBLOCK = $2D +ERR_OFFLINE = $2F diff --git a/src/AppleIISd.s b/src/AppleIISd.s index bbfff56..8f36275 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -11,14 +11,12 @@ ; ;******************************* +.import PD_DISP .import SMARTPORT .import GETR1 .import GETR3 .import SDCMD .import CARDDET -.import STATUS -.import READ -.import WRITE .include "AppleIISd.inc" @@ -30,14 +28,15 @@ ; 65535 blocks ; Removable media ; Non-interruptable -; 4 drives +; 2 drives ; Read, write and status allowed ; ;******************************* .segment "SLOTID" - .dbyt $FFFF ; 65535 blocks - .byt $B7 ; Status bits + .byt $0 ; not extended, no SCSI, no RAM + .dbyt $0 ; use status call + .byt $97 ; Status bits .byt DRIVER JSR DRIVER ; call driver CMP #0 @@ -100,9 +99,9 @@ PRODOS: LDA #$0A STA BUFFER+1 ; buffer hi STZ BUFFER ; buffer lo - STZ BLOCK+1 ; block hi + STZ BLOCKNUM+1 ; block hi LDA #$01 - STA BLOCK ; block lo + STA BLOCKNUM ; block lo JSR DRIVER ; call driver CMP #0 BNE @NEXTSLOT ; init not successful @@ -139,6 +138,7 @@ DRIVER: BRA @SAVEZP ; jump to ProDOS entry AND #$0F PLP STA SLOT ; $0s + TAY ; Y holds now SLOT ASL A ASL A ASL A @@ -149,33 +149,16 @@ DRIVER: BRA @SAVEZP ; jump to ProDOS entry BIT $CFFF JSR CARDDET BCC @INITED - LDA ERR_OFF_LINE; no card inserted + LDA ERR_OFFLINE ; no card inserted BRA @RESTZP @INITED: LDA #INITED ; check for init BIT SS,X - BEQ @INIT + BNE @PD_DISP + JSR INIT + BCS @RESTZP ; Init failed -; TODO use jump table -@CMD: LDA DCMD ; get command - BEQ @STATUS ; branch if cmd is 0 - CMP #1 - BEQ @READ - CMP #2 - BEQ @WRITE - LDA ERR_BAD_CMD ; unknown command - SEC - BRA @RESTZP - -@STATUS: JSR STATUS - BRA @RESTZP -@READ: JSR READ - BRA @RESTZP -@WRITE: JSR WRITE - BRA @RESTZP - -@INIT: JSR INIT - BCC @CMD ; init ok +@PD_DISP: JSR PD_DISP ; ProDOS dispatcher @RESTZP: TSX STA $105,X ; save retval on stack @@ -336,7 +319,7 @@ INIT: LDA #$03 ; set SPI mode 3 BCC @END1 @IOERROR: SEC - LDY ERR_IO_ERR ; init error + LDY ERR_IOERR ; init error @END1: LDA SS,X ; set CS high ORA #SS0 STA SS,X diff --git a/src/Helper.s b/src/Helper.s index 3915b5e..ac70640 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -113,34 +113,27 @@ GETBLOCK: PHX ; save X PHY ; save Y TXA TAY ; SLOT16 is now in Y - LDX SLOT - LDA BLOCK ; store block num + LDX SLOT ; SLOT is now in X + LDA BLOCKNUM ; store block num STA R33,X ; in R30-R33 - LDA BLOCK+1 + LDA BLOCKNUM+1 STA R32,X STZ R31,X STZ R30,X - LDA #$80 ; drive number - AND DSNUMBER - BEQ @SLOT ; D1 - LDA #1 ; D2 + TXA ; get SLOT + EOR DSNUMBER + AND #$70 ; check only slot bits + BEQ @DRIVE ; it is our slot + LDA #2 ; it is a phantom slot STA R31,X -@SLOT: LDA SLOT - PHA ; save SLOT - LDA #$70 ; slot number * 16 - AND DSNUMBER - STA SLOT - CPY SLOT - BEQ @RESTORE ; slot number = real slot? - LDA R31,X ; is phantom slot +@DRIVE: BIT DSNUMBER ; drive number + BPL @SDHC ; D1 + LDA R31,X ; D2 INC A STA R31,X -@RESTORE: PLA ; restore SLOT - STA SLOT - @SDHC: LDA #SDHC AND SS,Y ; if card is SDHC, BNE @END ; use block addressing diff --git a/src/ProDOS.s b/src/ProDOS.s index 7d045d0..78152bb 100644 --- a/src/ProDOS.s +++ b/src/ProDOS.s @@ -10,7 +10,8 @@ ; Y register is used for counting or SLOT ; ;******************************* - + +.export PD_DISP .export STATUS .export READ .export WRITE @@ -26,6 +27,36 @@ .segment "EXTROM" +;******************************* +; +; ProDOS command dispatcher +; +; $42-$47 MLI input locations +; X Slot*16 +; Y Slot +; +; C Clear - No error +; Set - Error +; A $00 - No error +; $01 - Unknown command +; +;******************************* + +PD_DISP: LDA DCMD ; get command + BEQ @STATUS ; branch if cmd is 0 + CMP #1 + BEQ @READ + CMP #2 + BEQ @WRITE + LDA ERR_BADCMD ; unknown command + SEC + RTS + +@STATUS: JMP STATUS +@READ: JMP READ +@WRITE: JMP WRITE + + ;******************************* ; ; Status request @@ -42,10 +73,10 @@ ; ;******************************* -STATUS: LDA NO_ERR ; no error +STATUS: LDA NO_ERR ; no error JSR WRPROT BCC @DONE - LDA ERR_NO_WRITE; card write protected + LDA ERR_NOWRITE ; card write protected @DONE: LDX #$FF ; 32 MB partition LDY #$FF @@ -120,7 +151,7 @@ READ: JSR GETBLOCK ; calc block address RTS @ERROR: SEC ; an error occured - LDA ERR_IO_ERR + LDA ERR_IOERR BRA @DONE @@ -196,9 +227,9 @@ WRITE: JSR WRPROT RTS @IOERROR: SEC ; an error occured - LDA ERR_IO_ERR + LDA ERR_IOERR BRA @DONE @WPERROR: SEC - LDA ERR_NO_WRITE + LDA ERR_NOWRITE BRA @DONE From 31817a481cbd93f5817a6998c084dce0225b90bc Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Sun, 13 May 2018 22:46:17 +0200 Subject: [PATCH 05/13] Save zeropage in loop --- src/AppleIISd.s | 88 ++++++++++++++++++++++++++++++------------------- src/Helper.s | 3 +- src/ProDOS.s | 4 +-- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 8f36275..515a16f 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -52,25 +52,26 @@ LDX #$20 LDX #$00 LDX #$03 - LDX #$00 ; is Smartport controller +; LDX #$00 ; is Smartport controller + LDX #$3C PRODOS: SEI ; no interrupts if booting BIT $CFFF - LDY #0 ; display copyright message -@DRAW: LDA TEXT,Y - BEQ @OAPPLE ; check for NULL - ORA #$80 - STA $0750,Y ; put second to last line - INY - BPL @DRAW +; LDY #0 ; display copyright message +;@DRAW: LDA TEXT,Y +; BEQ @OAPPLE ; check for NULL +; ORA #$80 +; STA $0750,Y ; put second to last line +; INY +; BPL @DRAW @OAPPLE: BIT OAPPLE ; check for OA key BPL @BOOT ; and skip boot if pressed @NEXTSLOT: LDA CURSLOT ; skip boot when no card DEC A - STA CMDHI + STA CMDHI ; use CMDHI/LO as pointer STZ CMDLO JMP (CMDLO) @@ -115,18 +116,18 @@ PRODOS: ; ;******************************* -DRIVER: BRA @SAVEZP ; jump to ProDOS entry - BRA @SMARTPORT ; jump to Smartport entry +DRIVER: CLC ; ProDOS entry + BCC @PRODOS + SEC ; Smartport entry -@SAVEZP: PHA ; make room for retval - LDA SLOT16 ; save all ZP locations - PHA - LDA SLOT - PHA - LDA CMDLO - PHA - LDA CMDHI +@PRODOS: PHA ; make room for retval + LDY PDZPSIZE-1 ; save zeropage area for ProDOS +@SAVEZP: LDA PDZPAREA,Y PHA + DEY + BPL @SAVEZP + + PHP ; push twice for PD/SP switch PHP SEI LDA #$60 ; opcode for RTS @@ -150,30 +151,51 @@ DRIVER: BRA @SAVEZP ; jump to ProDOS entry JSR CARDDET BCC @INITED LDA ERR_OFFLINE ; no card inserted - BRA @RESTZP + BRA @END @INITED: LDA #INITED ; check for init BIT SS,X - BNE @PD_DISP + BNE @DISP JSR INIT - BCS @RESTZP ; Init failed + BCS @END ; Init failed -@PD_DISP: JSR PD_DISP ; ProDOS dispatcher +@DISP: PLP ; get PSW from stack + BCS @SMARTPORT ; Smartport dispatcher + JSR PRODOS ; ProDOS dispatcher -@RESTZP: TSX - STA $105,X ; save retval on stack - PLA ; restore all ZP locations - STA CMDHI +@END: PHX + LDX SLOT ; X holds $0s + STA R30,X ; save A PLA - STA CMDLO + STA R31,X ; save X + TYA + STA R32,X ; save Y + PHP PLA - STA SLOT - PLA - STA SLOT16 - PLA ; get retval + STA R33,X ; save P + + LDY #0 +@RESTZP: PLA ; restore zeropage area + STA PDZPAREA,Y + INY + CPY PDZPSIZE + BCC @RESTZP + + LDA R33,X ; get retval + PHA + LDA R32,X + PHA + LDA R31,X + PHA + LDA R30,X ; restore A + PLX ; restore X + PLY ; restore Y + PLP ; restore P RTS -@SMARTPORT: JMP SMARTPORT +@SMARTPORT: CLC + JSR SMARTPORT + BRA @END ;******************************* diff --git a/src/Helper.s b/src/Helper.s index ac70640..9cc5801 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -111,8 +111,6 @@ GETR3: JSR GETR1 ; get R1 first GETBLOCK: PHX ; save X PHY ; save Y - TXA - TAY ; SLOT16 is now in Y LDX SLOT ; SLOT is now in X LDA BLOCKNUM ; store block num STA R33,X ; in R30-R33 @@ -135,6 +133,7 @@ GETBLOCK: PHX ; save X STA R31,X @SDHC: LDA #SDHC + LDY SLOT16 ; SLOT16 is now in Y AND SS,Y ; if card is SDHC, BNE @END ; use block addressing diff --git a/src/ProDOS.s b/src/ProDOS.s index 78152bb..b816eec 100644 --- a/src/ProDOS.s +++ b/src/ProDOS.s @@ -11,7 +11,7 @@ ; ;******************************* -.export PD_DISP +.export PRODOS .export STATUS .export READ .export WRITE @@ -42,7 +42,7 @@ ; ;******************************* -PD_DISP: LDA DCMD ; get command +PRODOS: LDA DCMD ; get command BEQ @STATUS ; branch if cmd is 0 CMP #1 BEQ @READ From 457e8bff9c994342dd441c4c14f84f2c0643854d Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Tue, 22 May 2018 21:53:11 +0200 Subject: [PATCH 06/13] Prepared for Smartport --- src/AppleIISd.cfg | 2 +- src/AppleIISd.inc | 7 +++-- src/AppleIISd.s | 78 ++++++++++++++++++++++++++++------------------- src/Helper.s | 4 +-- src/ProDOS.s | 12 ++++---- src/Smartport.s | 2 +- 6 files changed, 61 insertions(+), 44 deletions(-) diff --git a/src/AppleIISd.cfg b/src/AppleIISd.cfg index 8ce9bef..16c6c0b 100644 --- a/src/AppleIISd.cfg +++ b/src/AppleIISd.cfg @@ -9,7 +9,7 @@ MEMORY { MAIN: file = %O, define = yes, start = %S, size = $C000 - %S; BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__; - SLOTROM: file = %O, fill = yes start = $C700, size = $00FC; + SLOTROM: file = %O, fill = yes start = $C700, size = $00FB; SLOTID: file = %O, start = $C7FB, size = $0005; EXTROM: file = %O, fill = yes start = $C800, size = $0700; } diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 3ff3e04..6736e65 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -12,11 +12,12 @@ ;******************************* ; ZP locations +PSAVE := $3D ; P save location SLOT16 := $3E ; $s0 -> slot * 16 SLOT := $3F ; $0s CMDLO := $40 CMDHI := $41 -PDZPAREA = SLOT16 +PDZPAREA = PSAVE PDZPSIZE = CMDHI-PDZPAREA+1 ; ProDOS @@ -42,9 +43,11 @@ R30 := $0478 R31 := $04F8 R32 := $0578 R33 := $05F8 +DRVNUM := $0678 CURSLOT := $07F8 ; $Cs -; Slot equates +; Rom equates +KNOWNRTS := $FF58 OAPPLE := $C061 ; open apple key DATA := $C080 CTRL := DATA+1 diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 515a16f..51e3f31 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -11,12 +11,13 @@ ; ;******************************* -.import PD_DISP +.import PRODOS .import SMARTPORT .import GETR1 .import GETR3 .import SDCMD .import CARDDET +.import READ .include "AppleIISd.inc" @@ -55,9 +56,24 @@ ; LDX #$00 ; is Smartport controller LDX #$3C -PRODOS: - SEI ; no interrupts if booting + SEI ; find slot + JSR KNOWNRTS + TSX + LDA $0100,X + CLI + STA CURSLOT ; $Cs + AND #$0F + STA SLOT ; $0s + TAY ; Y holds now SLOT + ASL A + ASL A + ASL A + ASL A + STA SLOT16 ; $s0 + TAX ; X holds now SLOT16 BIT $CFFF + + ; LDY #0 ; display copyright message ;@DRAW: LDA TEXT,Y ; BEQ @OAPPLE ; check for NULL @@ -67,7 +83,7 @@ PRODOS: ; BPL @DRAW @OAPPLE: BIT OAPPLE ; check for OA key - BPL @BOOT ; and skip boot if pressed + BPL @INIT ; and skip boot if pressed @NEXTSLOT: LDA CURSLOT ; skip boot when no card DEC A @@ -75,6 +91,9 @@ PRODOS: STZ CMDLO JMP (CMDLO) +@INIT: JSR INIT + CMP #NO_ERR + BNE @NEXTSLOT ; init not successful ;******************************* ; @@ -82,31 +101,23 @@ PRODOS: ; ;******************************* -@BOOT: LDA #$01 ; READ - STA DCMD ; load command - LDA #$08 +; load disk blocks 0 and 1 to $800 and $A00 +@BOOT: LDA #$08 ; load to $800 STA BUFFER+1 ; buffer hi STZ BUFFER ; buffer lo STZ BLOCKNUM+1 ; block hi STZ BLOCKNUM ; block lo - LDA #>DRIVER - JSR DRIVER ; call driver - CMP #0 - BNE @NEXTSLOT ; init not successful + JSR READ + BCS @NEXTSLOT ; load not successful - LDA #$01 ; READ - STA DCMD ; load command - STX DSNUMBER ; slot number LDA #$0A STA BUFFER+1 ; buffer hi STZ BUFFER ; buffer lo STZ BLOCKNUM+1 ; block hi LDA #$01 STA BLOCKNUM ; block lo - JSR DRIVER ; call driver - CMP #0 - BNE @NEXTSLOT ; init not successful - LDX SLOT16 + JSR READ + BCS @NEXTSLOT ; load not successful JMP $801 ; goto bootloader @@ -120,37 +131,38 @@ DRIVER: CLC ; ProDOS entry BCC @PRODOS SEC ; Smartport entry -@PRODOS: PHA ; make room for retval - LDY PDZPSIZE-1 ; save zeropage area for ProDOS +@PRODOS: PHP ; transfer P to X + PLX + LDY #PDZPSIZE-1 ; save zeropage area for ProDOS @SAVEZP: LDA PDZPAREA,Y PHA DEY BPL @SAVEZP + STX PSAVE ; save X (P) - PHP ; push twice for PD/SP switch - PHP +; Has this to be done every time this gets called or only on boot??? SEI - LDA #$60 ; opcode for RTS - STA SLOT - JSR SLOT + LDA #$60 ; opcode for RTS + STA SLOT + JSR SLOT TSX LDA $0100,X + CLI STA CURSLOT ; $Cs AND #$0F - PLP STA SLOT ; $0s TAY ; Y holds now SLOT ASL A ASL A ASL A ASL A - STA SLOT16 ; $s0 TAX ; X holds now SLOT16 BIT $CFFF + JSR CARDDET BCC @INITED - LDA ERR_OFFLINE ; no card inserted + LDA #ERR_OFFLINE; no card inserted BRA @END @INITED: LDA #INITED ; check for init @@ -159,7 +171,9 @@ DRIVER: CLC ; ProDOS entry JSR INIT BCS @END ; Init failed -@DISP: PLP ; get PSW from stack +@DISP: LDA PSAVE ; get saved P value + PHA ; and transfer to P + PLP BCS @SMARTPORT ; Smartport dispatcher JSR PRODOS ; ProDOS dispatcher @@ -178,7 +192,7 @@ DRIVER: CLC ; ProDOS entry @RESTZP: PLA ; restore zeropage area STA PDZPAREA,Y INY - CPY PDZPSIZE + CPY #PDZPSIZE BCC @RESTZP LDA R33,X ; get retval @@ -337,11 +351,11 @@ INIT: LDA #$03 ; set SPI mode 3 ORA #ECE ; enable 7MHz STA CTRL,X CLC ; all ok - LDY NO_ERR + LDY #NO_ERR BCC @END1 @IOERROR: SEC - LDY ERR_IOERR ; init error + LDY #ERR_IOERR ; init error @END1: LDA SS,X ; set CS high ORA #SS0 STA SS,X diff --git a/src/Helper.s b/src/Helper.s index 9cc5801..1ecbed8 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -112,6 +112,7 @@ GETR3: JSR GETR1 ; get R1 first GETBLOCK: PHX ; save X PHY ; save Y LDX SLOT ; SLOT is now in X + LDY SLOT16 LDA BLOCKNUM ; store block num STA R33,X ; in R30-R33 LDA BLOCKNUM+1 @@ -119,7 +120,7 @@ GETBLOCK: PHX ; save X STZ R31,X STZ R30,X - TXA ; get SLOT + TYA ; get SLOT16 EOR DSNUMBER AND #$70 ; check only slot bits BEQ @DRIVE ; it is our slot @@ -133,7 +134,6 @@ GETBLOCK: PHX ; save X STA R31,X @SDHC: LDA #SDHC - LDY SLOT16 ; SLOT16 is now in Y AND SS,Y ; if card is SDHC, BNE @END ; use block addressing diff --git a/src/ProDOS.s b/src/ProDOS.s index b816eec..7c7017f 100644 --- a/src/ProDOS.s +++ b/src/ProDOS.s @@ -48,7 +48,7 @@ PRODOS: LDA DCMD ; get command BEQ @READ CMP #2 BEQ @WRITE - LDA ERR_BADCMD ; unknown command + LDA #ERR_BADCMD ; unknown command SEC RTS @@ -76,7 +76,7 @@ PRODOS: LDA DCMD ; get command STATUS: LDA NO_ERR ; no error JSR WRPROT BCC @DONE - LDA ERR_NOWRITE ; card write protected + LDA #ERR_NOWRITE; card write protected @DONE: LDX #$FF ; 32 MB partition LDY #$FF @@ -139,7 +139,7 @@ READ: JSR GETBLOCK ; calc block address AND #<~FRX STA CTRL,X CLC ; no error - LDA NO_ERR + LDA #NO_ERR @DONE: PHP PHA @@ -151,7 +151,7 @@ READ: JSR GETBLOCK ; calc block address RTS @ERROR: SEC ; an error occured - LDA ERR_IOERR + LDA #ERR_IOERR BRA @DONE @@ -227,9 +227,9 @@ WRITE: JSR WRPROT RTS @IOERROR: SEC ; an error occured - LDA ERR_IOERR + LDA #ERR_IOERR BRA @DONE @WPERROR: SEC - LDA ERR_NOWRITE + LDA #ERR_NOWRITE BRA @DONE diff --git a/src/Smartport.s b/src/Smartport.s index 4d10ec1..4d74b13 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -15,7 +15,7 @@ .include "AppleIISd.inc" -.segment "SLOTROM" +.segment "EXTROM" ;******************************* From 0910ca3db080bbc15eeb7f7068e71b68815c1a27 Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Wed, 23 May 2018 20:51:44 +0200 Subject: [PATCH 07/13] Smartport dispatcher added --- src/AppleIISd.inc | 17 +++---- src/AppleIISd.s | 9 ++-- src/Smartport.s | 127 ++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 130 insertions(+), 23 deletions(-) diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 6736e65..99d9f6b 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -28,17 +28,16 @@ BLOCKNUM := $46 ; block number ; Smartport -SMPARAM := $48 ; parameter count -SMUNIT := $49 ; unit number -SMBUFF := $4A ; buffer pointer -SMSTAT := $4B ; status / control code -SMBLOCK := $4C ; block number -SMCOUNT := $4D ; byte count -SMADDR := $4E ; address for read +SMPARAMLIST := $48 ; parameter list +SMCMDLIST := $4A ; command list +SMCSCODE := $AC + +SMZPAREA = SMPARAMLIST +SMZPSIZE = SMCSCODE-SMZPAREA+1 +SMCMD = DCMD - -; Ram equates +; Ram equates, access with SLOT offset R30 := $0478 R31 := $04F8 R32 := $0578 diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 51e3f31..e3aff44 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -36,7 +36,7 @@ .segment "SLOTID" .byt $0 ; not extended, no SCSI, no RAM - .dbyt $0 ; use status call + .word $0000 ; use status call .byt $97 ; Status bits .byt Date: Wed, 23 May 2018 22:17:19 +0200 Subject: [PATCH 08/13] All Smartport functions except Status and Control added --- src/AppleIISd.inc | 10 ++-- src/Smartport.s | 143 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 140 insertions(+), 13 deletions(-) diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 99d9f6b..aba5be9 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -23,15 +23,13 @@ PDZPSIZE = CMDHI-PDZPAREA+1 ; ProDOS DCMD := $42 ; Command code DSNUMBER := $43 ; drive / slot number -BUFFER := $44 ; buffer pointer -BLOCKNUM := $46 ; block number - +BUFFER := $44 ; buffer pointer, two bytes +BLOCKNUM := $46 ; block number, two bytes ; Smartport -SMPARAMLIST := $48 ; parameter list -SMCMDLIST := $4A ; command list +SMPARAMLIST := $48 ; parameter list, two bytes +SMCMDLIST := $4A ; command list, two bytes SMCSCODE := $AC - SMZPAREA = SMPARAMLIST SMZPSIZE = SMCSCODE-SMZPAREA+1 SMCMD = DCMD diff --git a/src/Smartport.s b/src/Smartport.s index 4df19c7..9123736 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -13,6 +13,8 @@ .export SMARTPORT +.import READ +.import WRITE .include "AppleIISd.inc" .segment "EXTROM" @@ -78,7 +80,7 @@ SMARTPORT: LDY #SMZPSIZE-1 ; save zeropage area for Smarport TXA ASL A ; shift for use or word addresses TAX - JSR @JMPSPCOMMAND + JSR @JMPSPCOMMAND ; Y holds SLOT BCS @END ; jump on error LDA #NO_ERR @@ -134,12 +136,139 @@ SPDISPATCH: SMSTATUS: -SMREADBLOCK: -SMWRITEBLOCK: -SMFORMAT: SMCONTROL: -SMINIT: + + +; Smartport Read Block command +; +; reads a 512-byte block using the ProDOS function +; +SMREADBLOCK: + JSR TRANSLATE + BCC @READ + RTS + +@READ: LDX SLOT16 + LDY SLOT + JMP READ ; call ProDOS read + + + +; Smartport Write Block command +; +; writes a 512-byte block using the ProDOS function +; +SMWRITEBLOCK: + JSR TRANSLATE + BCC @WRITE + RTS + +@WRITE: LDX SLOT16 + LDY SLOT + JMP WRITE ; call ProDOS write + + +; Translates the Smartport unit number to a ProDOS device +; and prepares the block number +; +; Unit 0: entire chain, not supported +; Unit 1: this slot, drive 0 +; Unit 2: this slot, drive 1 +; unit 3: phantom slot, drive 0 +; unit 4: phantom slot, drive 1 +; +TRANSLATE: LDA DRVNUM,Y + BEQ @BADUNIT ; not supportd for unit 0 + CMP #1 + BEQ @UNIT1 + CMP #2 + BEQ @UNIT2 + CMP #3 + BEQ @UNIT3 + CMP #4 + BEQ @UNIT4 + BRA @BADUNIT ; only 4 partitions are supported + +@UNIT1: LDA SLOT16 ; this slot + BRA @STORE +@UNIT2: LDA SLOT16 + ORA #$80 ; drive 1 + BRA @STORE +@UNIT3: LDA SLOT16 + DEC A ; phantom slot + BRA @STORE +@UNIT4: LDA SLOT16 + DEC A ; phantom slot + ORA #$80 ; drive 1 + +@STORE: STA DSNUMBER ; store in ProDOS variable + + LDY #2 ; get buffer pointer + LDA (SMPARAMLIST),Y + STA BUFFER + INY + LDA (SMPARAMLIST),Y + STA BUFFER+1 + + INY ; get block number + LDA (SMPARAMLIST),Y + STA BLOCKNUM + INY + LDA (SMPARAMLIST),Y + STA BLOCKNUM+1 + INY + LDA (SMPARAMLIST),Y + BNE @BADBLOCK ; bit 23-16 need to be 0 + + CLC + RTS + +@BADUNIT: LDA #ERR_BADUNIT + SEC + RTS + +@BADBLOCK: LDA #ERR_BADBLOCK + SEC + RTS + + +; Smartport Format command +; +; supported, but doesn't do anything +; +SMFORMAT: LDA #NO_ERR + CLC + RTS + + +; Smartport Init comand +; +; throw error if DRVNUM is not 0, else do nothing +; +SMINIT: LDA DRVNUM,Y + CLC + BEQ @END ; error if not 0 + LDA #ERR_BADUNIT + SEC +@END: RTS + + +; Smartport Open and Close commands +; +; supported for character devices, only +; SMOPEN: -SMCLOSE: +SMCLOSE: LDA #ERR_BADCMD + SEC + RTS + + +; Smartport Read Character and Write Character +; +; only 512-byte block operations are supported +; SMREADCHAR: -SMWRITECHAR: \ No newline at end of file +SMWRITECHAR: + LDA #ERR_IOERR + SEC + RTS From ad4c2939b8407761400dcb76802fd4634c6aa9bb Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Thu, 24 May 2018 09:40:50 +0200 Subject: [PATCH 09/13] Smartport Control added --- src/AppleIISd.inc | 1 + src/Smartport.s | 62 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index aba5be9..0a84d18 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -67,6 +67,7 @@ ERR_BADCMD = $01 ERR_BADPCNT = $04 ERR_BUSERR = $06 ERR_BADUNIT = $11 +ERR_NOINT = $1F ERR_BADCTL = $21 ERR_BADCTLPARM = $22 ERR_IOERR = $27 diff --git a/src/Smartport.s b/src/Smartport.s index 9123736..1392642 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -134,9 +134,51 @@ SPDISPATCH: .word SMWRITECHAR +; Smartport Status command +; +SMSTATUS: JSR GETCSLIST + -SMSTATUS: -SMCONTROL: + +; Smartport Control command +; +; no controls supported, yet +; +SMCONTROL: JSR GETCSLIST + LDX SMCSCODE + BEQ @RESET ; 0: Reset + DEX + BEQ @SETDCB ; 1: SetDCB + DEX + BEQ @NEWLINE ; 2: SetNewLine + DEX + BEQ @IRQ ; 3: ServiceInterrupt + DEX + BEQ @EJECT ; 4: Eject + +@NEWLINE: LDA #ERR_BADCTL + SEC +@RESET: +@SETDCB: +@EJECT: RTS + +@IRQ: LDA #ERR_NOINT ; interrupts not supported + SEC + RTS + + +; Get control/status list pointer and code +; +GETCSLIST: LDY #2 + LDA (SMPARAMLIST),Y + STA SMCMDLIST ; get list pointer + INY + LDA (SMPARAMLIST),Y + STA SMCMDLIST+1 + INY + LDA (SMPARAMLIST),Y + STA SMCSCODE ; get status/control code + RTS ; Smartport Read Block command @@ -174,8 +216,8 @@ SMWRITEBLOCK: ; Unit 0: entire chain, not supported ; Unit 1: this slot, drive 0 ; Unit 2: this slot, drive 1 -; unit 3: phantom slot, drive 0 -; unit 4: phantom slot, drive 1 +; Unit 3: phantom slot, drive 0 +; Unit 4: phantom slot, drive 1 ; TRANSLATE: LDA DRVNUM,Y BEQ @BADUNIT ; not supportd for unit 0 @@ -235,15 +277,23 @@ TRANSLATE: LDA DRVNUM,Y ; Smartport Format command ; ; supported, but doesn't do anything +; unit number must not be 0 ; -SMFORMAT: LDA #NO_ERR +SMFORMAT: LDA DRVNUM,Y + BEQ @ERROR + LDA #NO_ERR CLC RTS +@ERROR: LDA #ERR_BADUNIT + SEC + RTS + ; Smartport Init comand ; -; throw error if DRVNUM is not 0, else do nothing +; supported, but doesn't do anything +; unit number must be 0 ; SMINIT: LDA DRVNUM,Y CLC From 0c64c93efb5341bef317ad684d6ff01ad439a680 Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Thu, 24 May 2018 10:56:46 +0200 Subject: [PATCH 10/13] Status command added --- src/Smartport.s | 126 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 98 insertions(+), 28 deletions(-) diff --git a/src/Smartport.s b/src/Smartport.s index 1392642..fa3db8b 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -15,6 +15,7 @@ .import READ .import WRITE +.import WRPROT .include "AppleIISd.inc" .segment "EXTROM" @@ -107,37 +108,71 @@ SMARTPORT: LDY #SMZPSIZE-1 ; save zeropage area for Smarport -; Required parameter counts for the commands -REQPARAMCOUNT: - .byt 3 ; 0 = status - .byt 3 ; 1 = read block - .byt 3 ; 2 = write block - .byt 1 ; 3 = format - .byt 3 ; 4 = control - .byt 1 ; 5 = init - .byt 1 ; 6 = open - .byt 1 ; 7 = close - .byt 4 ; 8 = read char - .byt 4 ; 9 = write char - -; Command jump table -SPDISPATCH: - .word SMSTATUS - .word SMREADBLOCK - .word SMWRITEBLOCK - .word SMFORMAT - .word SMCONTROL - .word SMINIT - .word SMOPEN - .word SMCLOSE - .word SMREADCHAR - .word SMWRITECHAR - - ; Smartport Status command ; SMSTATUS: JSR GETCSLIST - + LDY SLOT + LDA DRVNUM,Y + BNE @PARTITION ; status call for a partition + + LDA SMCSCODE + BEQ @STATUS00 ; status call 0 for the bus + LDA #ERR_BADCTL ; calls other than 0 are not allowed + SEC + RTS + +@STATUS00: LDA #4 ; support 4 partitions + STA (SMCMDLIST) + CLC + RTS + +@PARTITION: LDX SMCSCODE + BEQ @STATUS03 ; 0: device status + DEX + BEQ @GETDCB ; 1: get DCB + DEX + DEX + BEQ @STATUS03 ; 3: get DIB + LDA #ERR_BADCTL + SEC + RTS + +@GETDCB: LDA #1 ; return 'empty' DCB, one byte + STA (SMCMDLIST) + TAY + LDA #NO_ERR + STA (SMCMDLIST),Y + CLC + RTS + +@STATUS03: LDA #$F8 ; block device, read, write, format, + ; online, no write-protect + JSR WRPROT + BCC @STATUSBYTE + ORA #$04 ; SD card write-protected +@STATUSBYTE:STA (SMCMDLIST) + + LDY #1 ; block count, always $00FFFF + LDA #$FF + STA (SMCMDLIST),Y + INY + STA (SMCMDLIST),Y + INY + LDA #0 + STA (SMCMDLIST),Y + + LDA SMCSCODE + BEQ @DONE ; done if code 0, else get DIB, 21 bytes + + LDY #4 +@LOOP: LDA STATUS3DATA-4,Y + STA (SMCMDLIST),Y + INY + CPY #21+4 + BCC @LOOP + +@DONE: CLC + RTS ; Smartport Control command @@ -322,3 +357,38 @@ SMWRITECHAR: LDA #ERR_IOERR SEC RTS + + +; Required parameter counts for the commands +REQPARAMCOUNT: + .byt 3 ; 0 = status + .byt 3 ; 1 = read block + .byt 3 ; 2 = write block + .byt 1 ; 3 = format + .byt 3 ; 4 = control + .byt 1 ; 5 = init + .byt 1 ; 6 = open + .byt 1 ; 7 = close + .byt 4 ; 8 = read char + .byt 4 ; 9 = write char + +; Command jump table +SPDISPATCH: + .word SMSTATUS + .word SMREADBLOCK + .word SMWRITEBLOCK + .word SMFORMAT + .word SMCONTROL + .word SMINIT + .word SMOPEN + .word SMCLOSE + .word SMREADCHAR + .word SMWRITECHAR + +; Status 3 command data +STATUS3DATA: + .byt 16, "APPLE][SD " ; ID length and string, padded + .byt $02 ; hard disk + .byt $00 ; removable hard disk + .word $0012 ; driver version + .assert (*-STATUS3DATA)=21, error, "STATUS3DATA must be 21 bytes long" From 06739f1d190f711f67c4fd5a96c4fa4904c568bc Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Tue, 29 May 2018 00:36:39 +0200 Subject: [PATCH 11/13] Smartport seems to work --- AppleIISd.bin | Bin 2048 -> 2048 bytes AppleIISd.hex | 146 +++++++++++++++++++++++----------------------- src/AppleIISd.inc | 2 +- src/AppleIISd.s | 29 ++++----- src/Helper.s | 2 + src/Smartport.s | 35 ++++++----- 6 files changed, 111 insertions(+), 103 deletions(-) diff --git a/AppleIISd.bin b/AppleIISd.bin index dfb6e64bba86fded5397125ea453e5d8c5a63c2e..4212df197ca6d350b210275c7b73afb6c560b517 100644 GIT binary patch delta 906 zcmah`O=uHA6rS0g{Mx2lMU4e<6~&hN10oWN+3jD_wGGZw8?6bjkxVso`1>ZyV#1A@jMjBk@mZ_dnnGw;3Od-Hvx37U{9 zhy_&O3n)odT^42Zx{UDDK~D!r%vR!FhlOuUIdf7II0K7Y?pGN@T;R zT5+X+lA*vYSZ-D*&r+SE)0gL`&&9$&_C<_ea;Kf%v&D07B;6qOU%x+{@Q zg4GG^nsKMb%Z z`0xc|khPhZ?J+s#r#Pg>W~|r)E4E`9NF1}$9PKSM@(oqoGRw1-p1---3Y`!SW>Wn0 zzA>wGb9a6U@?ZEqY-GC0u@uOtG*x_EZpXS3yv66*aXEnXOSe!ifb)1&(Fd!m$_ki% z>7hb#aqxq`)b&z%_tCDMbm~iTHtC-8uZZiLC61yMM?Iyb-dvt5AQP*UXrJzXw#BHu zB(EjiwSW<0gdPp4DN5!?gK9Cx4p_`5%FG5{g<02!f24nl<=PdNQQ)Jdb&dF(Dh9lXl!*w|ng^`z_3OFol8f V@mS>g^wnXpH8`~Q)dcy1{{dGHcFO<& delta 454 zcmaivze~eV5Xaw3lcrX*1;s%SogM(vn@j-baf>O-X zAu53spCAYw#6ls1gUwP$e+>Q$0hfScd?JXO2Y1JPj^q115+%_+6PdsanA4#WD^QFu zXfy#l^5l`oFvVdWRJn}%?Q?M3*K$K0q`D&CN8jQbc0xi6PNnn8lc#8^nA}bR1nwE6 zvo&Qu%|dj(I9JRTGyE3qIKMpn!}h^jA`CsMmZDl%wUVlpQvdPttt+xI5@%$( zY`e&sb-P;7?QRKfguzMDi#8n+;i@Ezo*W`^UzL}JAwi9%G@8^X)~KQt006!(+|U!a z1hKvhXLvn^XK+Fv6%KM(t9p`FE%Ee3-o;(!8^qQM&ufPlHEd-JPqMN`Njmk!(~`(Y zEbU4R8lK4CU^}ri#dp}1o1WOu8Q0W5gaNM5AHV|)puAHNm}2_pegU;x&9Xi6X_Rf2 mLqqyeV7({rTyOp5tDL_FrXbVD#i9CO@D Date: Tue, 29 May 2018 22:08:17 +0200 Subject: [PATCH 12/13] Status00 call updated --- AppleIISd.bin | Bin 2048 -> 2048 bytes AppleIISd.hex | 48 +++++++++++++++++++++++----------------------- README.md | 21 +++++++++++++++++--- src/AppleIISd.inc | 2 ++ src/Smartport.s | 21 ++++++++++++++++++-- 5 files changed, 63 insertions(+), 29 deletions(-) diff --git a/AppleIISd.bin b/AppleIISd.bin index 4212df197ca6d350b210275c7b73afb6c560b517..d0021111a726a2fe663be4dcb732af8b6c2d4466 100644 GIT binary patch delta 164 zcmZn=Xb{*inT7G)(mEkpr(}!5|bTS#rf*aOkhk{ zX1B!Nr|y(O-Q+aZcDH{-S>101valXPc6BrYg*)6g6sXL`mIJua$ vT`l}f%9%rFw9lMBa}x;f0-=CoK!A^HY;>@T0t7HI2yHfGJI^@TflUqo@N7RD diff --git a/AppleIISd.hex b/AppleIISd.hex index f2f7318..2483e72 100644 --- a/AppleIISd.hex +++ b/AppleIISd.hex @@ -71,32 +71,32 @@ :10046000F9BABD0D0185481869039D0D01BD0E0146 :10047000854969009D0E01A001B1488542C8B14877 :10048000AAC8B14885498648A901A642E00AB01A1F -:10049000B248DDE1CCD027A001B148A43F9978064D +:10049000B248DDEECCD027A001B148A43F99780640 :1004A0008A0AAA20C2CBB002A900AAA00068994873 :1004B00000C8C00590F78AA002A200C90160A90483 -:1004C00080E87CEBCC2046CCA43FB97806D00EA5C2 -:1004D0004CF004A9213860A904924A1860A64CF097 -:1004E00016CAF008CACAF00FA9213860A901924AB9 -:1004F000A8A900914A1860A9E8A63E203FCAB00208 -:100500000910204BCA90020904924AA001A9FF9148 -:100510004AC8914AC8A900914AA54CF00CA004B958 -:10052000FBCC914AC8C01990F618602046CCA64C66 -:10053000F00FCAF00CCAF006CAF007CAF003A921EE -:100540003860A91F3860A002B148854AC8B1488503 -:100550004BC8B148854C602071CC900160A63EA488 -:100560003F4C7ECA2071CC900160A63EA43F4CE770 -:10057000CAB97806F044C901F00EC902F00EC903E9 -:10058000F010C904F0118032A53E8010A53E09800C -:10059000800AA53E3A8005A53E3A09808543A0021F -:1005A000B1488544C8B1488545C8B1488546C8B1F9 -:1005B000488547C8B148D0061860A9113860A92DF0 -:1005C0003860B97806F004A9001860A9113860B93C -:1005D000780618F003A9113860A9013860A92738F6 -:1005E0006003030301030101010404C5CB57CC647C -:1005F000CCC2CC2BCCCFCCD9CCD9CCDDCCDDCC1063 -:100600004150504C455D5B53442020202020202049 -:1006100002001200000000000000000000000000C6 -:1006200000000000000000000000000000000000CA +:1004C00080E87CF8CC2053CCA43FB97806D018A59E +:1004D0004CF004A9213860A904924AA007B90BCDB9 +:1004E000914A88D0F81860A64CF016CAF008CACA1B +:1004F000F00FA9213860A901924AA8A900914A18D1 +:1005000060A9E8A63E203FCAB0020910204BCA905D +:10051000020904924AA001A9FF914AC8914AC8A9B8 +:1005200000914AA54CF00CA004B90FCD914AC8C067 +:100530001990F618602053CCA64CF00FCAF00CCAE4 +:10054000F006CAF00ACAF003A92138A9001860A968 +:100550001F3860A002B148854AC8B148854BC8B170 +:1005600048854C60207ECC900160A63EA43F4C7E26 +:10057000CA207ECC900160A63EA43F4CE7CAB97861 +:1005800006F044C901F00EC902F00EC903F010C90B +:1005900004F0118032A53E8010A53E0980800AA596 +:1005A0003E3A8005A53E3A09808543A002B14885C0 +:1005B00044C8B1488545C8B1488546C8B148854753 +:1005C000C8B148D0061860A9113860A92D3860B9A3 +:1005D0007806F004A9001860A9113860B9780618E7 +:1005E000F003A9113860A9013860A9273860030316 +:1005F0000301030101010404C5CB64CC71CCCFCC51 +:1006000035CCDCCCE6CCE6CCEACCEACC4000000B26 +:10061000120000104150504C455D5B534420202097 +:100620002020202002000B1200000000000000002B :1006300000000000000000000000000000000000BA :1006400000000000000000000000000000000000AA :10065000000000000000000000000000000000009A diff --git a/README.md b/README.md index 7bbb50d..498be55 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ The assembler sources are written for CC65. The [schematics](AppleIISd.pdf) are ## Features * works with ProDOS and GS/OS -* up to 64MB storage space (2x 65535 blocks) -* ProDOS driver in ROM +* up to 128MB storage space (4x 65535 blocks) +* ProDOS and Smartport driver in ROM * Auto boot * Access LED * Card detect and write protect sensing @@ -27,6 +27,21 @@ The AppleIISd requires an enhanced IIe or IIgs computer. The ROM code uses some When a 2732 type ROM is used, the binary image has to be programmed at offset 0x800, because A11 is always high for compatibility with 2716 type ROMs. +## Smartport drive remapping +The AppleIISd features Smartport drivers in ROM to provide more than two drives in both GS/OS and ProDOS. + +As ProDOS supports only two drives per slot, additional drives on a Smartport device are mapped to 'phantom slots'. Version prior to version 2 supported only the remapping of drives when the card was in slot 5. Starting with version 2, the remapping seems to work on all slots. The following list shows the assignments as slot/drive, when no other devices are attached: + +* Slot 7: 7/1, 7/2, 4/1, 4/2 +* Slot 6: 6/1, 6/2, 4/1, 4/1 +* Slot 5: 5/1, 5/2, 2/1, 2/1 +* Slot 4: 4/1, 4/2, 1/1, 1/2 +* Slot 3: 80 col HW, not usable +* Slot 2: 2/1, 2/2, 4/1, 4/2 +* Slot 1: 1/1, 1/2, 4/1, 4/2 + +When more devices are connected, things get a little confusing ;-) + ## Building the sources Be sure to have the newest version of CC65 (V2.16) and some kind of Make instaled, then type one of the following comands: ``` @@ -73,7 +88,7 @@ LDA $C0C0 ## TODOs * Much more testing * SRAM option (may never work, though) -* Enable 4 or 6 volumes under GS/OS +* Enable more than 4 volumes under GS/OS * Use 28 pin socket to support other EPROMS than 2716 and 2732 ## Known Bugs diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 3d38824..5659e3e 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -61,6 +61,8 @@ WP = $20 CD = $40 INITED = $80 +SMDRIVERVER = $120B ; Version 1.2 Beta + ; Error codes NO_ERR = $00 ERR_BADCMD = $01 diff --git a/src/Smartport.s b/src/Smartport.s index 85d82c4..da41235 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -122,8 +122,15 @@ SMSTATUS: JSR GETCSLIST SEC RTS +; TODO support partitions based on card size @STATUS00: LDA #4 ; support 4 partitions STA (SMCMDLIST) + + LDY #7 +@LOOP00: LDA STATUS00DATA-1,Y + STA (SMCMDLIST),Y + DEY + BNE @LOOP00 CLC RTS @@ -200,7 +207,9 @@ SMCONTROL: JSR GETCSLIST SEC @RESET: @SETDCB: -@EJECT: RTS +@EJECT: LDA #NO_ERR ; only return OK + CLC + RTS @IRQ: LDA #ERR_NOINT ; interrupts not supported SEC @@ -390,10 +399,18 @@ SPDISPATCH: .word SMREADCHAR .word SMWRITECHAR +; Status 00 command data +STATUS00DATA: + .byt $40 ; no interrupts + .word $0000 ; unknown vendor + .word SMDRIVERVER ; driver version + .byt $00, $00 ; reserved + .assert(*-STATUS00DATA)=7, error, "STATUS00DATA must be 7 bytes long" + ; Status 3 command data STATUS3DATA: .byt 16, "APPLE][SD " ; ID length and string, padded .byt $02 ; hard disk .byt $00 ; removable hard disk - .word $0012 ; driver version + .word SMDRIVERVER ; driver version .assert (*-STATUS3DATA)=21, error, "STATUS3DATA must be 21 bytes long" From 0ba00e76ce06aa7727c66e02672ac42a75a7f59c Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Sat, 7 Jul 2018 17:28:30 +0200 Subject: [PATCH 13/13] Nasty bug in Status call fixed --- AppleIISd.bin | Bin 2048 -> 2048 bytes AppleIISd.hex | 132 ++++++++++++++++++++++++------------------------ src/AppleIISd.s | 1 - src/Helper.s | 3 +- src/ProDOS.s | 2 +- 5 files changed, 68 insertions(+), 70 deletions(-) diff --git a/AppleIISd.bin b/AppleIISd.bin index d0021111a726a2fe663be4dcb732af8b6c2d4466..4915b73a3e3cde5a867c5b520e4656a4f97ff822 100644 GIT binary patch delta 337 zcmZn=Xb_kXD^zo8!~K<9t*$99Defy7Tiq0DCgz*V*q)levQoc6bY+80^MMPj3JfPU za4xm=(AZ$25IXUY31isA?*WW6CVMd2G0xcB&dAOvZ1B-z<^Q=22Qm^A8c%veEnx9k zK6x?IQPsRtJ~gL&o}OCCpx}9G0@F(EMgJH4Pf$2}a&Pki&3|*753CGS5S`r194+j5 zYC}4*cmz=VH}ediH)k%WFJRp0vBZ961zQ)_Dun~5H!!VaShav5W2Ohgi36+?zIQEP zTEuXYF<~W3!;6}4XA}a@EV18N!FEAnsm}+Nm5LTXiAi1y*mrVHzR#l0VS8!=6Q_WJ z=VU%s8D8GA6TMCxkeu*MB0(W=vN@}sM9rBAj0wx^me>Owu7Kb?om|UWEqwTN(wY1- ZXU`a)xpn3V5WYC`Vly|}S4JiV1^^HUlyCq5 delta 336 zcmZn=Xb_kXD^z!C!~K<9t*$99Defy7Tiq1uCgz*V*q@rfvQoc6bY+80^MMPj3JfPU za4xm=(AZ$25I*sc31h^>?*WXnCVMd2G0xiD&dAOv+Szd7y~oP`a~lq1Bq%hV^oUx( z;`J(PPVU%09G58Qvd(} diff --git a/AppleIISd.hex b/AppleIISd.hex index 2483e72..7a7df4c 100644 --- a/AppleIISd.hex +++ b/AppleIISd.hex @@ -3,26 +3,26 @@ :100020000A853EAA2CFFCFA000B916C9F00D0980A1 :10003000995007C810F3A9C520A8FC2C61C0100B6B :10004000ADF8073A854164406C40002000C8C90003 -:10005000D0EEA9088545644464476446207ECAB052 -:10006000DFA90A854564446447A9018546207ECA04 +:10005000D0EEA9088545644464476446207CCAB054 +:10006000DFA90A854564446447A9018546207CCA06 :10007000B0CE4C01081890013808FAA004B93D0030 :10008000488810F9863D78A960853F203F00BABDB9 :100090000001588DF807290F853FA80A0A0A0A852A -:1000A0003EAA2CFFCF203FCA9004A92F8015A9801B +:1000A0003EAA2CFFCF203DCA9004A92F8015A9801D :1000B0003C83C0D0052000C8B009A53D4828B03415 -:1000C0002057CADAA63F9D7804689DF804989D7869 +:1000C0002055CADAA63F9D7804689DF804989D786B :1000D0000508689DF805A00068993D00C8C0059016 :1000E000F7BDF80548BD780548BDF80448BD78045B -:1000F000FA7A2860182058CB80C900000000977554 +:1000F000FA7A2860182056CB80C900000000977556 :10010000A9039D81C0BD83C009019D83C0A9079D2E :1001100082C0A00AA9FF9D80C03C81C010FB88D08E :10012000F5BD83C029FE9D83C0A93D8540A9C98531 :1001300041206DC92081C9C901D065A9498540A95F -:10014000C98541206DC9209AC9C901D056A43FB9BB +:10014000C98541206DC92098C9C901D056A43FB9BD :10015000F805C9AAD04AA9558540A9C98541206D8D :10016000C92081C9A9618540A9C98541206DC920DF :1001700081C9C901F0E0C900D026A95B8540A9C9A1 -:100180008541206DC9209AC9C900D014A43FB9780F +:100180008541206DC92098C9C900D014A43FB97811 :10019000042940F048BD83C009109D83C04CEFC8BE :1001A0004C04C9A9558540A9C98541206DC9A967D5 :1001B0008540A9C98541206DC92081C9C901F0E3E5 @@ -38,65 +38,65 @@ :1002500000000200FF7700000000FF7A00000000AD :10026000FF6940000000776900000000FF5AA0000D :10027000B1409D80C03C81C010FBC8C00690F17A9F -:1002800060A9FF9D80C03C81C010FBBD80C08980FB -:10029000D0EF48A9FF9D80C068602081C9485AA05E -:1002A000044CA9C9A9FF9D80C03C81C010FBBD8042 -:1002B000C04888D0EFA43F6899F805689978056828 -:1002C00099F804689978047AA9FF9D80C06860DA7B -:1002D0005AA63FA43EA5469DF805A5479D78059ED4 -:1002E000F8049E78049845432970F005A9029DF80A -:1002F0000424431007BDF8041A9DF804A91039839B -:10030000C0D011A0091EF8053E78053EF8043E78DD -:100310000488D0F17AFA605AA43F9D80C0B978046D -:100320009D80C0B9F8049D80C0B978059D80C0B992 -:10033000F8059D80C0A9FF9D80C02081C97A6048D2 -:10034000A9403C83C018F00138686048A9203C836C -:10035000C018F001386860A542F00CC901F00BC963 -:1003600002F00AA90138604C70CA4C7ECA4CE7CA38 -:10037000A500204BCA9002A92BA2FFA0FF6020CFAE -:10038000C9BD83C029FE9D83C0A9512017CAC900D9 -:10039000D050A9FF9D80C0BD80C0C9FED0F4BD81F2 -:1003A000C009109D81C0A9FF9D80C0A000BD80C074 -:1003B0009144C8D0F8E645BD80C09144C8D0F8C685 -:1003C00045BD80C0BD80C0BD80C0BD81C029EF9D3E -:1003D00081C018A9000848BD83C009019D83C06879 -:1003E000286038A92780EE204BCAB06720CFC9BD4E -:1003F00083C029FE9D83C0A9582017CAC900D04ECA -:10040000A9FF9D80C0A9FE9D80C0A000B1449D8031 -:10041000C0C8D0F8E645B1449D80C0C8D0F8C645F4 -:10042000A9FF9D80C09D80C09D80C0BD80C0291F48 -:10043000C905D01A18A5000848A9FF9D80C0BD8035 -:10044000C0F0F6BD83C009019D83C068286038A94B -:100450002780E438A92B80DFA004B9480048881021 -:10046000F9BABD0D0185481869039D0D01BD0E0146 -:10047000854969009D0E01A001B1488542C8B14877 -:10048000AAC8B14885498648A901A642E00AB01A1F -:10049000B248DDEECCD027A001B148A43F99780640 -:1004A0008A0AAA20C2CBB002A900AAA00068994873 -:1004B00000C8C00590F78AA002A200C90160A90483 -:1004C00080E87CF8CC2053CCA43FB97806D018A59E -:1004D0004CF004A9213860A904924AA007B90BCDB9 -:1004E000914A88D0F81860A64CF016CAF008CACA1B -:1004F000F00FA9213860A901924AA8A900914A18D1 -:1005000060A9E8A63E203FCAB0020910204BCA905D -:10051000020904924AA001A9FF914AC8914AC8A9B8 -:1005200000914AA54CF00CA004B90FCD914AC8C067 -:100530001990F618602053CCA64CF00FCAF00CCAE4 -:10054000F006CAF00ACAF003A92138A9001860A968 -:100550001F3860A002B148854AC8B148854BC8B170 -:1005600048854C60207ECC900160A63EA43F4C7E26 -:10057000CA207ECC900160A63EA43F4CE7CAB97861 -:1005800006F044C901F00EC902F00EC903F010C90B -:1005900004F0118032A53E8010A53E0980800AA596 -:1005A0003E3A8005A53E3A09808543A002B14885C0 -:1005B00044C8B1488545C8B1488546C8B148854753 -:1005C000C8B148D0061860A9113860A92D3860B9A3 -:1005D0007806F004A9001860A9113860B9780618E7 -:1005E000F003A9113860A9013860A9273860030316 -:1005F0000301030101010404C5CB64CC71CCCFCC51 -:1006000035CCDCCCE6CCE6CCEACCEACC4000000B26 -:10061000120000104150504C455D5B534420202097 -:100620002020202002000B1200000000000000002B +:1002800060A9FF9D80C03C81C010FBBD80C030F1E3 +:1002900048A9FF9D80C068602081C9485AA0044CCD +:1002A000A7C9A9FF9D80C03C81C010FBBD80C0488C +:1002B00088D0EFA43F6899F805689978056899F89F +:1002C00004689978047AA9FF9D80C06860DA5AA60C +:1002D0003FA43EA5469DF805A5479D78059EF804D8 +:1002E0009E78049845432970F005A9029DF80424DE +:1002F000431007BDF8041A9DF804A9103983C0D033 +:1003000011A0091EF8053E78053EF8043E780488E1 +:10031000D0F17AFA605AA43F9D80C0B978049D80DC +:10032000C0B9F8049D80C0B978059D80C0B9F805B2 +:100330009D80C0A9FF9D80C02081C97A6048A940E6 +:100340003C83C018F00138686048A9203C83C0187D +:10035000F001386860A542F00CC901F00BC902F049 +:100360000AA90138604C6ECA4C7CCA4CE5CAA90087 +:100370002049CA9002A92BA2FFA0FF6020CDC9BDD1 +:1003800083C029FE9D83C0A9512015CAC900D05041 +:10039000A9FF9D80C0BD80C0C9FED0F4BD81C00949 +:1003A000109D81C0A9FF9D80C0A000BD80C0914468 +:1003B000C8D0F8E645BD80C09144C8D0F8C645BD58 +:1003C00080C0BD80C0BD80C0BD81C029EF9D81C0FF +:1003D00018A9000848BD83C009019D83C068286032 +:1003E00038A92780EE2049CAB06720CDC9BD83C097 +:1003F00029FE9D83C0A9582015CAC900D04EA9FF67 +:100400009D80C0A9FE9D80C0A000B1449D80C0C851 +:10041000D0F8E645B1449D80C0C8D0F8C645A9FFD4 +:100420009D80C09D80C09D80C0BD80C0291FC90522 +:10043000D01A18A5000848A9FF9D80C0BD80C0F053 +:10044000F6BD83C009019D83C068286038A9278054 +:10045000E438A92B80DFA004B94800488810F9BA15 +:10046000BD0D0185481869039D0D01BD0E0185492B +:1004700069009D0E01A001B1488542C8B148AAC8D3 +:10048000B14885498648A901A642E00AB01AB24897 +:10049000DDECCCD027A001B148A43F9978068A0AA8 +:1004A000AA20C0CBB002A900AAA00068994800C841 +:1004B000C00590F78AA002A200C90160A90480E8E3 +:1004C0007CF6CC2051CCA43FB97806D018A54CF0CE +:1004D00004A9213860A904924AA007B909CD914A1C +:1004E00088D0F81860A64CF016CAF008CACAF00FF7 +:1004F000A9213860A901924AA8A900914A1860A9C7 +:10050000E8A63E203DCAB00209102049CA9002095F +:1005100004924AA001A9FF914AC8914AC8A9009132 +:100520004AA54CF00CA004B90DCD914AC8C0199051 +:10053000F618602051CCA64CF00FCAF00CCAF00699 +:10054000CAF00ACAF003A92138A9001860A91F3807 +:1005500060A002B148854AC8B148854BC8B14885FA +:100560004C60207CCC900160A63EA43F4C7CCA200D +:100570007CCC900160A63EA43F4CE5CAB97806F059 +:1005800044C901F00EC902F00EC903F010C904F00D +:10059000118032A53E8010A53E0980800AA53E3A12 +:1005A0008005A53E3A09808543A002B1488544C82C +:1005B000B1488545C8B1488546C8B1488547C8B1E6 +:1005C00048D0061860A9113860A92D3860B978069E +:1005D000F004A9001860A9113860B9780618F00372 +:1005E000A9113860A9013860A92738600303030105 +:1005F000030101010404C3CB62CC6FCCCDCC33CC5E +:10060000DACCE4CCE4CCE8CCE8CC4000000B12001F +:1006100000104150504C455D5B5344202020202069 +:10062000202002000B12000000000000000000006B :1006300000000000000000000000000000000000BA :1006400000000000000000000000000000000000AA :10065000000000000000000000000000000000009A diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 956279e..3b85323 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -54,7 +54,6 @@ LDX #$00 LDX #$03 LDX #$00 ; is Smartport controller -; LDX #$3C SEI ; find slot LDA #$60 ; opcode for RTS diff --git a/src/Helper.s b/src/Helper.s index e250e78..0f659e2 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -55,8 +55,7 @@ GETR1: LDA #DUMMY @WAIT: BIT CTRL,X BPL @WAIT LDA DATA,X ; get response - BIT #$80 - BNE GETR1 ; wait for MSB=0 + BMI GETR1 ; wait for MSB=0 PHA LDA #DUMMY STA DATA,X ; send another dummy diff --git a/src/ProDOS.s b/src/ProDOS.s index 7c7017f..8d5c6f4 100644 --- a/src/ProDOS.s +++ b/src/ProDOS.s @@ -73,7 +73,7 @@ PRODOS: LDA DCMD ; get command ; ;******************************* -STATUS: LDA NO_ERR ; no error +STATUS: LDA #NO_ERR ; Thanks for this one, Antoine! JSR WRPROT BCC @DONE LDA #ERR_NOWRITE; card write protected