Support for second partition, card detect and write protect added

This commit is contained in:
Florian Reitz 2017-09-09 20:34:24 +02:00
parent b845ad2cc9
commit 2a06e1ba5d
7 changed files with 1511 additions and 1380 deletions

Binary file not shown.

64
AppleIISd.hex Normal file
View File

@ -0,0 +1,64 @@
:10000000A220A000A203863C2058FFBABD00018DAB
:10001000F807290F853D0A0A0A0A852BAA2CFFCF6B
:1000200020B0CA9003A927002000C9C900F0010030
:10003000A9018542A52BAA85436444A90885456486
:100040004664472CFFCF20D6CA4C0108D82058FF61
:10005000BABD00018DF807290F853D0A0A0A0A85F5
:100060002BAA2CFFCF20B0CA9004A927801BA980FF
:100070003C83C0F022A542C900F010C901F00FC9AD
:1000800002F00EC903F00DA90138604CC8CA4CD665
:10009000CA4C44CB4CBACB2000C980D90000000028
:1000A0000000000000000000000000000000000050
:1000B0000000000000000000000000000000000040
:1000C0000000000000000000000000000000000030
:1000D0000000000000000000000000000000000020
:1000E0000000000000000000000000000000000010
:1000F0000000000000000000000000000000174C9D
:10010000D8A9039D81C0BD83C009019D83C0A907F3
:100110009D82C0A00AA9FF9D80C03C81C010FB88C1
:10012000D0F5BD83C029FE9D83C0A9BE8540A9CB63
:10013000854120F2C92006CAC901D039A9CA854023
:10014000A9CB854120F2C92021CAC901D02AA9D64C
:100150008540A9CB854120F2C92006CAA9DC85408B
:10016000A9CB854120F2C92006CAC901F0E0C90027
:10017000D0034CB2C94CE0C9A9D68540A9CB854172
:1001800020F2C9A9E28540A9CB854120F2C9200609
:10019000CAC901F0E3C900D0034CB2C9A9C4854063
:1001A000A9CB854120F2C92006CAC901F0F6C900D1
:1001B000D02EA9D08540A9CB854120F2C92006CAFE
:1001C000C900D01CA43DBD83C009809D83C0BD81F2
:1001D000C009049D81C018A000900838A028B00371
:1001E00038A027BD83C009019D83C0A9009D82C09E
:1001F00098605AA000B1409D80C03C81C010FBC8EF
:10020000C00690F17A60A9FF9D80C03C81C010FBC0
:10021000BD80C0853C2980D0EDA9FF9D80C0A53C54
:10022000602006CA485AA004A9FF9D80C03C81C036
:1002300010FBBD80C04888D0EFA43D6899F80568E0
:100240009978056899F804689978047AA9FF9D80DF
:10025000C06860DA5AA63DA5469DF805A5479D7879
:1002600005A9009DF8049D7804A9802443F005A900
:10027000019DF804A0091EF8053E78053EF8043EED
:10028000780488D0F17AFA605AA43D9D80C0B9788C
:10029000049D80C0B9F8049D80C0B978059D80C0D8
:1002A000B9F8059D80C0A9FF9D80C02006CA7A606C
:1002B00048A9403C83C018F00138686048A9203C38
:1002C00083C018F001386860A900A2FFA0FF20BC1D
:1002D000CA9002A92B6020B0CAB0642053CABD8363
:1002E000C029FE9D83C0A9512088CAC900D050A949
:1002F000FF9D80C0BD80C0C9FED0F4A002BD81C0FA
:1003000009109D81C0A9FF9D80C0643CBD80C09242
:1003100044E644D002E645E63CD0F188D0ECBD800E
:10032000C0BD80C0BD80C0BD81C029EF9D81C01807
:10033000A9000848BD83C009019D83C068286038B2
:10034000A92780EE20B0CAB06720BCCAB06720538E
:10035000CABD83C029FE9D83C0A9582088CAC90090
:10036000D04EA9FF9D80C0A9FE9D80C0A002643C24
:10037000B2449D80C0E644D002E645E63CD0F18818
:10038000D0EC9D80C09D80C09D80C0BD80C0291FD5
:10039000C905D01C18A9000848A9FF9D80C0BD80D0
:1003A000C0C900F0F4BD83C009019D83C068286006
:1003B00038A92780E238A92B80DD38A901604000E8
:1003C000000000954100000000F948000001AA87E4
:1003D0005000000200FF7700000000656940000047
:0803E00000776900000000FF36
:00000001FF

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@ FRX = $10 ; CTRL register
ECE = $04 ECE = $04
SS0 = $01 ; SS register SS0 = $01 ; SS register
WP = $20 WP = $20
CARDDET = $40 CD = $40
INITED = $80 INITED = $80
@ -65,28 +65,30 @@ INITED = $80
STA CURSLOT STA CURSLOT
LDA #$40 LDA #$40
STA SLOT16 STA SLOT16
ELSE ELSE
JSR $FF58 JSR $FF58
TSX TSX
LDA $0100,X LDA $0100,X
STA CURSLOT ; $Cs
AND #$0F AND #$0F
STA SLOT ; $0s STA SLOT ; $0s
ORA #$C0
STA CURSLOT ; $Cs
ASL A ASL A
ASL A ASL A
ASL A ASL A
ASL A ASL A
STA SLOT16 ; $s0 STA SLOT16 ; $s0
FIN FIN
TAX ; X holds now SLOT16 TAX ; X holds now SLOT16
BIT $CFFF BIT $CFFF
JSR INIT JSR CARDDET
BCC :INIT
LDA #$27 ; no card inserted
BRK
:INIT JSR INIT
*
* TODO: check for init error
*
******************************** ********************************
* *
@ -144,7 +146,11 @@ INSTALL LDA $BF32,X ; get a devnum
ELSE ELSE
BOOT LDA #$01 BOOT CMP #0 ; check for error
BEQ :BOOT1
BRK
:BOOT1 LDA #$01
STA $42 ; load command STA $42 ; load command
LDA SLOT16 LDA SLOT16
TAX TAX
@ -168,6 +174,7 @@ BOOT LDA #$01
******************************** ********************************
DRIVER CLD DRIVER CLD
DO DEBUG DO DEBUG
LDA #$04 LDA #$04
STA SLOT STA SLOT
@ -175,38 +182,44 @@ DRIVER CLD
STA CURSLOT STA CURSLOT
LDA #$40 LDA #$40
STA SLOT16 STA SLOT16
ELSE ELSE
JSR $FF58 ; find slot nr JSR $FF58 ; find slot nr
TSX TSX
LDA $0100,X LDA $0100,X
STA CURSLOT ; $Cs
AND #$0F AND #$0F
STA SLOT ; $0s STA SLOT ; $0s
ORA #$C0
STA CURSLOT ; $Cs
ASL A ASL A
ASL A ASL A
ASL A ASL A
ASL A ASL A
STA SLOT16 ; $s0 STA SLOT16 ; $s0
FIN FIN
TAX ; X holds now SLOT16
TAX ; X holds now SLOT16
BIT $CFFF BIT $CFFF
LDA #INITED ; check for init JSR CARDDET
BCC :INITED
LDA #$27 ; no card inserted
BRA :DONE
:INITED LDA #INITED ; check for init
BIT SS,X BIT SS,X
BEQ :INIT BEQ :INIT
:CMD LDA $42 ; get command :CMD LDA $42 ; get command
CMP #$00 CMP #0
BEQ :STATUS BEQ :STATUS
CMP #$01 CMP #1
BEQ :READ BEQ :READ
CMP #$02 CMP #2
BEQ :WRITE BEQ :WRITE
CMP #$03 CMP #3
BEQ :FORMAT BEQ :FORMAT
SEC ; unknown command LDA #1 ; unknown command
LDA #$01
:DONE SEC
RTS RTS
:STATUS JMP STATUS :STATUS JMP STATUS
@ -221,8 +234,8 @@ DRIVER CLD
DS \ ; fill with zeroes DS \ ; fill with zeroes
DS -4 ; locate to $xxFC DS -4 ; locate to $xxFC
DW $FFFF ; 65535 blocks DW $0000 ; use status request
DB $47 ; Status bits DB $17 ; Status bits
DB #<DRIVER ; LSB of driver DB #<DRIVER ; LSB of driver
@ -442,6 +455,7 @@ GETR3 JSR GETR1 ; get R1 first
******************************** ********************************
* *
* Calculate block address * Calculate block address
* Unit number is in $43 DSSS0000
* Block no is in $46-47 * Block no is in $46-47
* Address is in R30-R33 * Address is in R30-R33
* *
@ -458,7 +472,13 @@ BLOCK PHX ; save X
STA R31,X STA R31,X
STA R30,X STA R30,X
LDY #9 ; ASL can't be used with Y LDA #$80 ; drive number
BIT $43
BEQ :SHIFT ; D1
LDA #1 ; D2
STA R31,X
:SHIFT LDY #9 ; ASL can't be used with Y
:LOOP ASL R33,X ; mul block num :LOOP ASL R33,X ; mul block num
ROL R32,X ; by 512 to get ROL R32,X ; by 512 to get
ROL R31,X ; real address ROL R31,X ; real address
@ -495,6 +515,44 @@ COMMAND PHY ; save Y
RTS RTS
********************************
*
* Check for card detect
*
* C Clear - card in slot
* Set - no card in slot
*
********************************
CARDDET PHA
LDA #CD ; 0: card in
BIT SS,X ; 1: card out
CLC
BEQ :DONE ; card is in
SEC ; card is out
:DONE PLA
RTS
********************************
*
* Check for write protect
*
* C Clear - card not protected
* Set - card write protected
*
********************************
WRPROT PHA
LDA #WP ; 0: write enabled
BIT SS,X ; 1: write disabled
CLC
BEQ :DONE
SEC
:DONE PLA
RTS
******************************** ********************************
* *
* Status request * Status request
@ -508,18 +566,20 @@ COMMAND PHY ; save Y
* $27 - I/O error * $27 - I/O error
* $28 - No card inserted / no init * $28 - No card inserted / no init
* $2B - Card write protected * $2B - Card write protected
* x - Blocks avail (low byte) * X - Blocks avail (low byte)
* y - Blocks avail (high byte) * Y - Blocks avail (high byte)
* *
******************************** ********************************
STATUS CLC ; no error STATUS LDA #0 ; no error
LDA #0
LDX #$FF ; 32 MB partition LDX #$FF ; 32 MB partition
LDY #$FF LDY #$FF
RTS
* TODO: check for card detect and write protect! JSR WRPROT
BCC :DONE
LDA #$2B ; card write protected
:DONE RTS
******************************** ********************************
@ -537,9 +597,10 @@ STATUS CLC ; no error
* *
******************************** ********************************
* TODO: check for card detect! READ JSR CARDDET
BCS :ERROR ; no card inserted
READ JSR BLOCK ; calc block address JSR BLOCK ; calc block address
LDA SS,X ; enable /CS LDA SS,X ; enable /CS
AND #$FF!SS0 AND #$FF!SS0
@ -573,32 +634,34 @@ READ JSR BLOCK ; calc block address
DEY DEY
BNE :LOOPY BNE :LOOPY
:CRC LDA DATA,X ; read two bytes crc
LDA DATA,X ; and ignore
LDA DATA,X ; read a dummy byte
LDA CTRL,X ; disable FRX LDA CTRL,X ; disable FRX
AND #$FF!FRX AND #$FF!FRX
STA CTRL,X STA CTRL,X
CLC ; no error
LDA #0
:CRC LDA #DUMMY ; first crc byte has :DONE PHP
STA DATA,X ; already been read PHA
LDA SS,X LDA SS,X
ORA #SS0 ORA #SS0
STA SS,X ; disable /CS STA SS,X ; disable /CS
CLC ; no error PLA
LDA #$00 PLP
RTS RTS
:ERROR LDA SS,X :ERROR SEC ; an error occured
ORA #SS0
STA SS,X ; disable /CS
SEC ; an error occured
LDA #$27 LDA #$27
RTS BRA :DONE
******************************** ********************************
* *
* Write 512 byte block * Write 512 byte block
* $43 Unit number DSSS000 * $43 Unit number DSSS0000
* $44-45 Address (LO/HI) of buffer * $44-45 Address (LO/HI) of buffer
* $46-47 Block number (LO/HI) * $46-47 Block number (LO/HI)
* *
@ -606,14 +669,17 @@ READ JSR BLOCK ; calc block address
* Set - Error * Set - Error
* A $00 - No error * A $00 - No error
* $27 - I/O error or bad block number * $27 - I/O error or bad block number
* $28 - No card inserted
* $2B - Card write protected * $2B - Card write protected
* *
******************************** ********************************
* TODO: check for card detect and write protect! WRITE JSR CARDDET
BCS :IOERROR ; no card inserted
WRITE JSR BLOCK ; calc block address JSR WRPROT
BCS :WPERROR ; card write protected
JSR BLOCK ; calc block address
LDA SS,X ; enable /CS LDA SS,X ; enable /CS
AND #$FF!SS0 AND #$FF!SS0
@ -622,7 +688,7 @@ WRITE JSR BLOCK ; calc block address
JSR COMMAND ; send command JSR COMMAND ; send command
CMP #0 ; check for error CMP #0 ; check for error
BNE :ERROR BNE :IOERROR
LDA #DUMMY LDA #DUMMY
STA DATA,X ; send dummy STA DATA,X ; send dummy
@ -648,33 +714,33 @@ WRITE JSR BLOCK ; calc block address
LDA DATA,X LDA DATA,X
AND #$1F AND #$1F
CMP #$05 CMP #$05
BNE :ERROR ; check for write error BNE :IOERROR ; check for write error
CLC ; no error
LDA #0
:WAIT6 LDA #DUMMY :DONE PHP
PHA
:WAIT LDA #DUMMY
STA DATA,X ; wait for write cycle STA DATA,X ; wait for write cycle
LDA DATA,X ; to complete LDA DATA,X ; to complete
CMP #$00 CMP #$00
BEQ :WAIT6 BEQ :WAIT
LDA SS,X ; disable /CS LDA SS,X ; disable /CS
ORA #SS0 ORA #SS0
STA SS,X STA SS,X
CLC ; no error PLA
LDA #0 PLP
RTS RTS
:ERROR LDA #DUMMY :IOERROR SEC ; an error occured
STA DATA,X ; wait for write cycle
LDA DATA,X ; to complete
CMP #$00
BEQ :ERROR
LDA SS,X
ORA #SS0
STA SS,X ; disable /CS
SEC ; an error occured
LDA #$27 LDA #$27
RTS BRA :DONE
:WPERROR SEC
LDA #$2B
BRA :DONE
******************************** ********************************

View File

@ -1,60 +0,0 @@
S00600004844521B
S1130000A220A000A203863C2058FFBABD0001290B
S11300100F853D09C08DF8070A0A0A0A852BAA2C08
S1130020FFCF2000C9A9018542A52BAA85436444BA
S1130030A9088545644664472CFFCF209ECA4C011D
S113004008D82058FFBABD0001290F853D09C08D8D
S1130050F8070A0A0A0A852BAA2CFFCFA43DB9780F
S113006006C9019022A542C900F010C901F00FC9C8
S113007002F00EC903F00D38A901604C96CA4C9EDB
S1130080CA4CF7CA4C64CB2000C980D900000000D8
S1130090000000000000000000000000000000005C
S11300A0000000000000000000000000000000004C
S11300B0000000000000000000000000000000003C
S11300C0000000000000000000000000000000002C
S11300D0000000000000000000000000000000001C
S11300E0000000000000000000000000000000000C
S11300F0000000000000000000000000FFFF474176
S1130100D8A9039D81C0A90F9D83C0A9079D82C062
S1130110A00AA9FF9D80C03C81C010FB88D0F5A92E
S11301200E9D83C0A9688540A9CB854120E3C920E1
S1130130F7C9C901D039A9748540A9CB854120E309
S1130140C92012CAC901D02AA9808540A9CB8541FA
S113015020E3C920F7C9A9868540A9CB854120E3BE
S1130160C920F7C9C901F0E0C900D0034CACC94C9F
S1130170CFC9A9808540A9CB854120E3C9A98C8535
S113018040A9CB854120E3C920F7C9C901F0E3C9DF
S113019000D0034CACC9A96E8540A9CB854120E3AE
S11301A0C920F7C9C901F0F6C900D023A97A85404E
S11301B0A9CB854120E3C920F7C9C900D011A43DCA
S11301C0A90199780618A000900838A028B003382F
S11301D0A027A90F9D83C0A9079D81C0A9009D8266
S11301E0C098605AA000B1409D80C03C81C010FB03
S11301F0C8C00690F17A60A9FF9D80C03C81C01000
S1130200FBBD80C0853C2980D0EDA9FF9D80C0A5A1
S11302103C6020F7C9485AA004A9FF9D80C03C81D6
S1130220C010FBBD80C04888D0EFA43D6899F80594
S1130230689978056899F804689978047AA9FF9D03
S113024080C06860DA5AA63DA5469DF805A5479D7D
S11302507805A9009DF8049D7804A0091EF8053EC0
S113026078053EF8043E780488D0F17AFA605AA4FE
S11302703D9D80C0B978049D80C0B9F8049D80C0BC
S1130280B978059D80C0B9F8059D80C0A9FF9D80FF
S1130290C020F7C97A6018A900A2FFA0FF6020441B
S11302A0CAA90E9D83C0A951206ECAC900D03FA916
S11302B0FF9D80C0BD80C0C9FED0F4A002A9179DD7
S11302C081C0A9FF9D80C0643CBD80C09244E644C7
S11302D0D002E645E63CD0F188D0ECA9079D81C068
S11302E0A9FF9D80C0A90F9D83C018A90060A90F14
S11302F09D83C038A927602044CAA90E9D83C0A944
S113030058206ECAC900D047A9FF9D80C0A9FE9D90
S113031080C0A002643CB2449D80C0E644D002E6A2
S113032045E63CD0F188D0EC9D80C09D80C09D8086
S1130330C0BD80C0291FC905D015A9FF9D80C0BDBF
S113034080C0C900F0F4A90F9D83C018A90060A95A
S1130350FF9D80C0BD80C0C900F0F4A90F9D83C07B
S113036038A9276038A901604000000000954100C9
S1130370000000F948000001AA875000000200FFB5
S11303807700000000656940000000776900000004
S105039000FF68
S9030000FC

View File

@ -8,14 +8,17 @@ A Xilinx CPLD is used as a SPI controller and translates, together with the ROM
The assembler sources were written in Merlin-8. The [schematics](AppleIISd.pdf) are available as PDF. The assembler sources were written in Merlin-8. The [schematics](AppleIISd.pdf) are available as PDF.
## Features ## Features
* up to 128MB storage space (4x 65535 blocks), currently 32MB * up to 64MB storage space (2x 65535 blocks)
* ProDOS driver in ROM * ProDOS driver in ROM
* Auto boot * Auto boot
* Access LED * Access LED
* Card detect and write protect sensing
## Requirements ## Requirements
The Apple][Sd requires and has been tested on an enhanced IIe computer. The ROM code uses some 65c02 opcodes and will therefore not work on a II, II+ or unenhanced IIe. ProDOS versions 1.1 to 2.4.1 seem to work. The Apple][Sd requires and has been tested on an enhanced IIe computer. The ROM code uses some 65c02 opcodes and will therefore not work on a II, II+ or unenhanced IIe. ProDOS versions 1.1 to 2.4.1 seem to work.
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.
## Timing ## Timing
The clock of the SPI bus *SCK* may be derived from either *Phi0* or the *7M* clock. Additionally, the divisor may be 2 to 8. The clock of the SPI bus *SCK* may be derived from either *Phi0* or the *7M* clock. Additionally, the divisor may be 2 to 8.
@ -52,8 +55,6 @@ LDA $C0C0
## TODOs ## TODOs
* Much more testing * Much more testing
* Support more than one partition
* Implement card detect and write protect sensing
* SRAM option (may never work, though) * SRAM option (may never work, though)
* Find a use for the IRQ pin * Find a use for the IRQ pin
* Use 28 pin socket to support other EPROMS than 2716 and 2732 * Use 28 pin socket to support other EPROMS than 2716 and 2732

File diff suppressed because it is too large Load Diff