VS2015 project added

This commit is contained in:
Florian Reitz 2017-11-26 00:19:35 +01:00
parent 0f92b7cf03
commit 4feea40b5d
9 changed files with 567 additions and 963 deletions

36
.gitignore vendored
View File

@ -3,6 +3,41 @@
Thumbs.db
.DS_Store
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
*.opendb
**/Debug
*.db
*.dbg
*.lbl
*.map
Makefile\.options
# Ignore list for Eagle, a PCB layout tool
# Backup files
@ -177,3 +212,4 @@ Hardware/SD_A2\.b\$1
*.nga
*.tspec

Binary file not shown.

View File

@ -1,4 +1,4 @@
:10000000A220A000A203A03C2058FFBABD00018D91
:10000000A220A200A203A2012058FFBABD00018DC8
:10001000F807290F853D0A0A0A0A852BAA2CFFCF6B
:1000200020B8C99003A92F002000C8A9018542A6C5
:100030002B8643A90885456444644764462CFFCF5A
@ -7,25 +7,25 @@
:100060000108D848A52B48A53D48A54048A54148CA
:100070002058FFBABD00018DF807290F853D0A0AF7
:100080000A0A852BAA2CFFCF20B8C99005A92F38C2
:100090008040A9803C83C0F034A542C900F015C956
:1000A00001F016C902F017C903F018C9FFF019A929
:1000B0000138801E20D0C9801920DEC98014204755
:1000C000CA800F20B8CA800A20BCCA80052000C898
:1000D00090C7BA9D050168854168854068853D687F
:1000E000852B686000000000000000000000000098
:100090008037A9803C83C0F02BA542C900F011C96C
:1000A00001F012C902F013C903F014A90138801934
:1000B00020D0C9801420DEC9800F2047CA800A20C2
:1000C000B8CA80052000C890D0BA9D050168854156
:1000D00068854068853D68852B68600000000000E9
:1000E0000000000000000000000000000000000010
:1000F000000000000000000000000000FFFF876219
:10010000D8A9039D81C0BD83C009019D83C0A907F3
:100110009D82C0A00AA9FF9D80C03C81C010FB88C1
:10012000D0F5BD83C029FE9D83C0A9348540A9CBED
:10013000854120F3C82007C9C901D041A9408540A5
:10014000A9CB854120F3C82020C9C901D032A94CD0
:100150008540A9CB854120F3C82007C9A952854015
:10016000A9CB854120F3C82007C9C901F0E0C90027
:10012000D0F5BD83C029FE9D83C0A9E18540A9CA41
:10013000854120F3C82007C9C901D041A9ED8540F8
:10014000A9CA854120F3C82020C9C901D032A9F924
:100150008540A9CA854120F3C82007C9A9FF854069
:10016000A9CA854120F3C82007C9C901F0E0C90028
:10017000D00BBD83C009109D83C04CBAC84CE1C8E8
:10018000A94C8540A9CB854120F3C8A9588540A931
:10018000A9F98540A9CA854120F3C8A9058540A9D8
:10019000CB854120F3C82007C9C901F0E3C900D0CD
:1001A000034CBAC8A93A8540A9CB854120F3C820A1
:1001B00007C9C901F0F6C900D027A9468540A9CBD7
:1001A000034CBAC8A9E78540A9CA854120F3C820F5
:1001B00007C9C901F0F6C900D027A9F38540A9CA2B
:1001C000854120F3C82007C9C900D015BD83C009E7
:1001D000809D83C0BD81C009049D81C018A000908E
:1001E0000338A027BD83C009019D83C0A9009D825B
@ -57,17 +57,17 @@
:10038000A9FF9D80C09D80C09D80C0BD80C0291FE9
:10039000C905D01A18A9000848A9FF9D80C0BD80D2
:1003A000C0F0F6BD83C009019D83C068286038A9EC
:1003B0002780E438A92B80DF38A90160A52B48A548
:1003C0003D48A90220F5BEB0498545644468853D95
:1003D00068852BA000989144C8D0FAE645989144CE
:1003E000C8D0FAC64564466447A62B2047CAB02247
:1003F00020DEC9B01DA00098D144D017C8D0F8E6BF
:100400004598D144D00DC8D0F8C64520F8BE18A9EB
:10041000006000004170706C655D5B536420286370
:10042000293230313720466C6F7269616E20526517
:1004300069747A004000000000954100000000F956
:1004400048000001AA875000000200FF770000006A
:1004500000656940000000776900000000FF0000AF
:1003B0002780E438A92B80DF38A901604170706C78
:1003C000655D5B53642076302E38202863293230F7
:1003D000313720466C6F7269616E20526569747A9C
:1003E000004000000000954100000000F9480000B6
:1003F00001AA875000000200FF7700000000656935
:1004000040000000776900000000FF0000000000CD
:1004100000000000000000000000000000000000DC
:1004200000000000000000000000000000000000CC
:1004300000000000000000000000000000000000BC
:1004400000000000000000000000000000000000AC
:10045000000000000000000000000000000000009C
:10046000000000000000000000000000000000008C
:10047000000000000000000000000000000000007C
:10048000000000000000000000000000000000006C

View File

@ -1,927 +0,0 @@
1 ********************************
2 *
3 * Apple][Sd Firmware
4 * Version 0.8
5 *
6 * (c) Florian Reitz, 2017
7 *
8 * X register usually contains SLOT16
9 * Y register is used for counting or SLOT
10 *
11 ********************************
12
1-NOV-17 16:06
14
15 XC ; enable 65C02 code
16 DEBUG = 0
17 DO DEBUG
18 ORG $8000
19 ELSE
20 ORG $C700 ; Expansion ROM
21 FIN
22
23 * Memory defines
24
25 SLOT16 = $2B ; $s0 -> slot * 16
26 SLOT = $3D ; $0s
27 CMDLO = $40
28 CMDHI = $41
29
30 DCMD = $42 ; Command code
31 BUFFER = $44 ; Buffer address
32 BLOCK = $46 ; Block number
33
34 CURSLOT = $07F8 ; $Cs
35 DATA = $C080
36 CTRL = DATA+1
37 DIV = DATA+2
38 SS = DATA+3
39 R30 = $0478
40 R31 = $04F8
41 R32 = $0578
42 R33 = $05F8
43
44 * Constants
45
46 DUMMY = $FF
47 FRX = $10 ; CTRL register
48 ECE = $04
49 SS0 = $01 ; SS register
50 WP = $20
51 CD = $40
52 INITED = $80
53
54
55 * signature bytes
56
C700: A2 20 57 LDX #$20
C702: A0 00 58 LDY #$00
C704: A2 03 59 LDX #$03
C706: A0 FF 60 LDY #$FF ; neither 5.25 nor Smartport
61
62 * find slot nr
63
64 DO DEBUG
65 LDA #$04
66 STA SLOT
67 LDA #$C4
68 STA CURSLOT
69 LDA #$40
70
71 ELSE
C708: 20 58 FF 72 JSR $FF58
C70B: BA 73 TSX
C70C: BD 00 01 74 LDA $0100,X
C70F: 8D F8 07 75 STA CURSLOT ; $Cs
C712: 29 0F 76 AND #$0F
C714: 85 3D 77 STA SLOT ; $0s
C716: 0A 78 ASL A
C717: 0A 79 ASL A
C718: 0A 80 ASL A
C719: 0A 81 ASL A
82 FIN
83
C71A: 85 2B 84 STA SLOT16 ; $s0
C71C: AA 85 TAX ; X holds now SLOT16
C71D: 2C FF CF 86 BIT $CFFF
C720: 20 A7 C9 87 JSR CARDDET
C723: 90 03 88 BCC :INIT
C725: A9 2F 89 LDA #$2F ; no card inserted
C727: 00 90 BRK
91
C728: 20 00 C8 92 :INIT JSR INIT
93
94
95 ********************************
96 *
97 * Install SD card driver
98 *
99 ********************************
100
101 DO DEBUG
102
103 * see if slot has a driver already
104
105 LDX $BF31 ; get devcnt
106 INSTALL LDA $BF32,X ; get a devnum
107 AND #$70 ; isolate slot
108 CMP SLOT16 ; slot?
109 BEQ :INSOUT ; yes, skip it
110 DEX
111 BPL INSTALL ; keep up the search
112
113 * restore the devnum to the list
114
115 LDX $BF31 ; get devcnt again
116 CPX #$0D ; device table full?
117 BNE :INST2
118
119 JSR $FF3A ; bell
120 JMP :INSOUT ; do something!
121
122 :INST2 LDA $BF32-1,X ; move all entries down
123 STA $BF32,X ; to make room at front
124 DEX ; for a new entry
125 BNE :INST2
126 LDA #$04 ; ProFile type device
127 ORA SLOT16
128 STA $BF32 ; slot, drive 1 at top of list
129 INC $BF31 ; update devcnt
130
131 * now insert the device driver vector
132
133 LDA SLOT
134 ASL
135 TAX
136 LDA #<DRIVER
137 STA $BF10,X ; write to driver table
138 LDA #>DRIVER
139 STA $BF11,X
140 :INSOUT RTS
141
142
143 ********************************
144 *
145 * Boot from SD card
146 *
147 ********************************
148
149 ELSE
150
C72B: F0 01 151 BOOT BEQ :BOOT1 ; check for error
C72D: 00 152 BRK
153
C72E: A9 01 154 :BOOT1 LDA #$01
C730: 85 42 155 STA DCMD ; load command
C732: A6 2B 156 LDX SLOT16
C734: 85 43 157 STA $43 ; slot number
C736: A9 08 158 LDA #$08
C738: 85 45 159 STA BUFFER+1 ; buffer hi
C73A: 64 44 160 STZ BUFFER ; buffer lo
C73C: 64 47 161 STZ BLOCK+1 ; block hi
C73E: 64 46 162 STZ BLOCK ; block lo
C740: 2C FF CF 163 BIT $CFFF
C743: 20 CD C9 164 JSR READ ; call driver
C746: 4C 01 08 165 JMP $801 ; goto bootloader
166
167 FIN
168
169
170 ********************************
171 *
172 * Jump table
173 *
174 ********************************
175
C749: D8 176 DRIVER CLD
177
C74A: 48 178 :SAVEZP PHA ; make room for retval
C74B: A5 2B 179 LDA SLOT16 ; save all ZP locations
C74D: 48 180 PHA
C74E: A5 3D 181 LDA SLOT
C750: 48 182 PHA
C751: A5 40 183 LDA CMDLO
C753: 48 184 PHA
C754: A5 41 185 LDA CMDHI
C756: 48 186 PHA
187
188 DO DEBUG
189 LDA #$04
190 STA SLOT
191 LDA #$C4
192 STA CURSLOT
193 LDA #$40
194
195 ELSE
C757: 20 58 FF 196 JSR $FF58 ; find slot nr
C75A: BA 197 TSX
C75B: BD 00 01 198 LDA $0100,X
C75E: 8D F8 07 199 STA CURSLOT ; $Cs
C761: 29 0F 200 AND #$0F
C763: 85 3D 201 STA SLOT ; $0s
C765: 0A 202 ASL A
C766: 0A 203 ASL A
C767: 0A 204 ASL A
C768: 0A 205 ASL A
206 FIN
207
C769: 85 2B 208 STA SLOT16 ; $s0
C76B: AA 209 TAX ; X holds now SLOT16
C76C: 2C FF CF 210 BIT $CFFF
C76F: 20 A7 C9 211 JSR CARDDET
C772: 90 05 212 BCC :INITED
C774: A9 2F 213 LDA #$2F ; no card inserted
C776: 38 214 SEC
C777: 80 40 215 BRA :RESTZP
216
C779: A9 80 217 :INITED LDA #INITED ; check for init
C77B: 3C 83 C0 218 BIT SS,X
C77E: F0 34 219 BEQ :INIT
220
C780: A5 42 221 :CMD LDA DCMD ; get command
C782: C9 00 222 CMP #0
C784: F0 15 223 BEQ :STATUS
C786: C9 01 224 CMP #1
C788: F0 16 225 BEQ :READ
C78A: C9 02 226 CMP #2
C78C: F0 17 227 BEQ :WRITE
C78E: C9 03 228 CMP #3
C790: F0 18 229 BEQ :FORMAT
C792: C9 FF 230 CMP #$FF
C794: F0 19 231 BEQ :TEST
C796: A9 01 232 LDA #1 ; unknown command
C798: 38 233 SEC
C799: 80 1E 234 BRA :RESTZP
235
C79B: 20 BF C9 236 :STATUS JSR STATUS
C79E: 80 19 237 BRA :RESTZP
C7A0: 20 CD C9 238 :READ JSR READ
C7A3: 80 14 239 BRA :RESTZP
C7A5: 20 34 CA 240 :WRITE JSR WRITE
C7A8: 80 0F 241 BRA :RESTZP
C7AA: 20 A3 CA 242 :FORMAT JSR FORMAT
C7AD: 80 0A 243 BRA :RESTZP
C7AF: 20 A7 CA 244 :TEST JSR TEST ; do device test
C7B2: 80 05 245 BRA :RESTZP
C7B4: 20 00 C8 246 :INIT JSR INIT
C7B7: 90 C7 247 BCC :CMD ; init ok
248
C7B9: BA 249 :RESTZP TSX
C7BA: 9D 05 01 250 STA $105,X ; save retval on stack
C7BD: 68 251 PLA ; restore all ZP locations
C7BE: 85 41 252 STA CMDHI
C7C0: 68 253 PLA
C7C1: 85 40 254 STA CMDLO
C7C3: 68 255 PLA
C7C4: 85 3D 256 STA SLOT
C7C6: 68 257 PLA
C7C7: 85 2B 258 STA SLOT16
C7C9: 68 259 PLA ; get retval
C7CA: 60 260 RTS
261
262
263 * Signature bytes
264
C7CB: 00 00 00 265 DS \ ; fill with zeroes
C7CE: 00 00 00 00
C7D2: 00 00 00 00
C7D6: 00 00 00 00
C7DA: 00 00 00 00
C7DE: 00 00 00 00
C7E2: 00 00 00 00
C7E6: 00 00 00 00
C7EA: 00 00 00 00
C7EE: 00 00 00 00
C7F2: 00 00 00 00
C7F6: 00 00 00 00
C7FA: 00 00 00 00
C7FE: 00 00
266 DS -4 ; locate to $xxFC
C7FC: FF FF 267 DW $FFFF ; 65535 blocks
C7FE: 17 268 DB $17 ; Status bits
C7FF: 49 269 DB #<DRIVER ; LSB of driver
270
271 ********************************
272 *
273 * Initialize SD card
274 *
275 * C Clear - No error
276 * Set - Error
277 * A $00 - No error
278 * $27 - I/O error - Init failed
279 * $2F - No card inserted
280 *
281 ********************************
282
C800: D8 283 INIT CLD
C801: A9 03 284 LDA #$03 ; set SPI mode 3
C803: 9D 81 C0 285 STA CTRL,X
C806: BD 83 C0 286 LDA SS,X
C809: 09 01 287 ORA #SS0 ; set CS high
C80B: 9D 83 C0 288 STA SS,X
C80E: A9 07 289 LDA #7
C810: 9D 82 C0 290 STA DIV,X
C813: A0 0A 291 LDY #10
C815: A9 FF 292 LDA #DUMMY
293
C817: 9D 80 C0 294 :LOOP STA DATA,X
C81A: 3C 81 C0 295 :WAIT BIT CTRL,X
C81D: 10 FB 296 BPL :WAIT
C81F: 88 297 DEY
C820: D0 F5 298 BNE :LOOP ; do 10 times
C822: BD 83 C0 299 LDA SS,X
C825: 29 FE 300 AND #$FF!SS0 ; set CS low
C827: 9D 83 C0 301 STA SS,X
302
C82A: A9 FF 303 LDA #<CMD0 ; send CMD0
C82C: 85 40 304 STA CMDLO
C82E: A9 CA 305 LDA #>CMD0
C830: 85 41 306 STA CMDHI
C832: 20 EB C8 307 JSR SDCMD
C835: 20 FF C8 308 JSR GETR1 ; get response
C838: C9 01 309 CMP #$01
C83A: D0 39 310 BNE :ERROR1 ; error!
311
C83C: A9 0B 312 LDA #<CMD8 ; send CMD8
C83E: 85 40 313 STA CMDLO
C840: A9 CB 314 LDA #>CMD8
C842: 85 41 315 STA CMDHI
C844: 20 EB C8 316 JSR SDCMD
C847: 20 18 C9 317 JSR GETR3
C84A: C9 01 318 CMP #$01
C84C: D0 2A 319 BNE :SDV1 ; may be SD Ver. 1
320
321 * check for $01aa match!
C84E: A9 17 322 :SDV2 LDA #<CMD55
C850: 85 40 323 STA CMDLO
C852: A9 CB 324 LDA #>CMD55
C854: 85 41 325 STA CMDHI
C856: 20 EB C8 326 JSR SDCMD
C859: 20 FF C8 327 JSR GETR1
C85C: A9 1D 328 LDA #<ACMD4140
C85E: 85 40 329 STA CMDLO
C860: A9 CB 330 LDA #>ACMD4140
C862: 85 41 331 STA CMDHI
C864: 20 EB C8 332 JSR SDCMD
C867: 20 FF C8 333 JSR GETR1
C86A: C9 01 334 CMP #$01
C86C: F0 E0 335 BEQ :SDV2 ; wait for ready
C86E: C9 00 336 CMP #0
C870: D0 03 337 BNE :ERROR1 ; error!
338 * send CMD58
339 * SD Ver. 2 initialized!
C872: 4C B2 C8 340 JMP :BLOCKSZ
341
C875: 4C D9 C8 342 :ERROR1 JMP :IOERROR ; needed for far jump
343
C878: A9 17 344 :SDV1 LDA #<CMD55
C87A: 85 40 345 STA CMDLO
C87C: A9 CB 346 LDA #>CMD55
C87E: 85 41 347 STA CMDHI
C880: 20 EB C8 348 JSR SDCMD ; ignore response
C883: A9 23 349 LDA #<ACMD410
C885: 85 40 350 STA CMDLO
C887: A9 CB 351 LDA #>ACMD410
C889: 85 41 352 STA CMDHI
C88B: 20 EB C8 353 JSR SDCMD
C88E: 20 FF C8 354 JSR GETR1
C891: C9 01 355 CMP #$01
C893: F0 E3 356 BEQ :SDV1 ; wait for ready
C895: C9 00 357 CMP #0
C897: D0 03 358 BNE :MMC ; may be MMC card
359 * SD Ver. 1 initialized!
C899: 4C B2 C8 360 JMP :BLOCKSZ
361
C89C: A9 05 362 :MMC LDA #<CMD1
C89E: 85 40 363 STA CMDLO
C8A0: A9 CB 364 LDA #>CMD1
C8A2: 85 41 365 STA CMDHI
C8A4: 20 EB C8 366 :LOOP1 JSR SDCMD
C8A7: 20 FF C8 367 JSR GETR1
C8AA: C9 01 368 CMP #$01
C8AC: F0 F6 369 BEQ :LOOP1 ; wait for ready
C8AE: C9 00 370 CMP #0
C8B0: D0 27 371 BNE :IOERROR ; error!
372 * MMC Ver. 3 initialized!
373
C8B2: A9 11 374 :BLOCKSZ LDA #<CMD16
C8B4: 85 40 375 STA CMDLO
C8B6: A9 CB 376 LDA #>CMD16
C8B8: 85 41 377 STA CMDHI
C8BA: 20 EB C8 378 JSR SDCMD
C8BD: 20 FF C8 379 JSR GETR1
C8C0: C9 00 380 CMP #0
C8C2: D0 15 381 BNE :IOERROR ; error!
382
C8C4: BD 83 C0 383 :END LDA SS,X
C8C7: 09 80 384 ORA #INITED ; initialized
C8C9: 9D 83 C0 385 STA SS,X
C8CC: BD 81 C0 386 LDA CTRL,X
C8CF: 09 04 387 ORA #ECE ; enable 7MHz
C8D1: 9D 81 C0 388 STA CTRL,X
C8D4: 18 389 CLC ; all ok
C8D5: A0 00 390 LDY #0
C8D7: 90 03 391 BCC :END1
C8D9: 38 392 :IOERROR SEC
C8DA: A0 27 393 LDY #$27 ; init error
C8DC: BD 83 C0 394 :END1 LDA SS,X ; set CS high
C8DF: 09 01 395 ORA #SS0
C8E1: 9D 83 C0 396 STA SS,X
C8E4: A9 00 397 LDA #0 ; set div to 2
C8E6: 9D 82 C0 398 STA DIV,X
C8E9: 98 399 TYA ; retval in A
C8EA: 60 400 RTS
401
402
403 ********************************
404 *
405 * Send SD command
406 * Call with command in CMDHI and CMDLO
407 *
408 ********************************
409
C8EB: 5A 410 SDCMD PHY
C8EC: A0 00 411 LDY #0
C8EE: B1 40 412 :LOOP LDA (CMDLO),Y
C8F0: 9D 80 C0 413 STA DATA,X
C8F3: 3C 81 C0 414 :WAIT BIT CTRL,X ; TC is in N
C8F6: 10 FB 415 BPL :WAIT
C8F8: C8 416 INY
C8F9: C0 06 417 CPY #6
C8FB: 90 F1 418 BCC :LOOP
C8FD: 7A 419 PLY
C8FE: 60 420 RTS
421
422
423 ********************************
424 *
425 * Get R1
426 * R1 is in A
427 *
428 ********************************
429
C8FF: A9 FF 430 GETR1 LDA #DUMMY
C901: 9D 80 C0 431 STA DATA,X
C904: 3C 81 C0 432 :WAIT BIT CTRL,X
C907: 10 FB 433 BPL :WAIT
C909: BD 80 C0 434 LDA DATA,X ; get response
C90C: 89 80 435 BIT #$80
C90E: D0 EF 436 BNE GETR1 ; wait for MSB=0
C910: 48 437 PHA
C911: A9 FF 438 LDA #DUMMY
C913: 9D 80 C0 439 STA DATA,X ; send another dummy
C916: 68 440 PLA ; restore R1
C917: 60 441 RTS
442
443 ********************************
444 *
445 * Get R3
446 * R1 is in A
447 * R3 is in scratchpad ram
448 *
449 ********************************
450
C918: 20 FF C8 451 GETR3 JSR GETR1 ; get R1 first
C91B: 48 452 PHA ; save R1
C91C: 5A 453 PHY ; save Y
C91D: A0 04 454 LDY #04 ; load counter
C91F: A9 FF 455 :LOOP LDA #DUMMY ; send dummy
C921: 9D 80 C0 456 STA DATA,X
C924: 3C 81 C0 457 :WAIT BIT CTRL,X
C927: 10 FB 458 BPL :WAIT
C929: BD 80 C0 459 LDA DATA,X
C92C: 48 460 PHA
C92D: 88 461 DEY
C92E: D0 EF 462 BNE :LOOP ; do 4 times
C930: A4 3D 463 LDY SLOT
C932: 68 464 PLA
C933: 99 F8 05 465 STA R33,Y ; save R3
C936: 68 466 PLA
C937: 99 78 05 467 STA R32,Y
C93A: 68 468 PLA
C93B: 99 F8 04 469 STA R31,Y
C93E: 68 470 PLA
C93F: 99 78 04 471 STA R30,Y
C942: 7A 472 PLY ; restore Y
C943: A9 FF 473 LDA #DUMMY
C945: 9D 80 C0 474 STA DATA,X ; send another dummy
C948: 68 475 PLA ; restore R1
C949: 60 476 RTS
477
478
479 ********************************
480 *
481 * Calculate block address
482 * Unit number is in $43 DSSS0000
483 * Block no is in $46-47
484 * Address is in R30-R33
485 *
486 ********************************
487
C94A: DA 488 GETBLOCK PHX ; save X
C94B: 5A 489 PHY ; save Y
C94C: A6 3D 490 LDX SLOT
C94E: A5 46 491 LDA BLOCK ; store block num
C950: 9D F8 05 492 STA R33,X ; in R30-R33
C953: A5 47 493 LDA BLOCK+1
C955: 9D 78 05 494 STA R32,X
C958: A9 00 495 LDA #0
C95A: 9D F8 04 496 STA R31,X
C95D: 9D 78 04 497 STA R30,X
498
C960: A9 80 499 LDA #$80 ; drive number
C962: 24 43 500 BIT $43
C964: F0 05 501 BEQ :SHIFT ; D1
C966: A9 01 502 LDA #1 ; D2
C968: 9D F8 04 503 STA R31,X
504
C96B: A0 09 505 :SHIFT LDY #9 ; ASL can't be used with Y
C96D: 1E F8 05 506 :LOOP ASL R33,X ; mul block num
C970: 3E 78 05 507 ROL R32,X ; by 512 to get
C973: 3E F8 04 508 ROL R31,X ; real address
C976: 3E 78 04 509 ROL R30,X
C979: 88 510 DEY
C97A: D0 F1 511 BNE :LOOP
C97C: 7A 512 PLY ; restore Y
C97D: FA 513 PLX ; restore X
C97E: 60 514 RTS
515
516
517 ********************************
518 *
519 * Send SD command
520 * Cmd is in A
521 *
522 ********************************
523
C97F: 5A 524 COMMAND PHY ; save Y
C980: A4 3D 525 LDY SLOT
C982: 9D 80 C0 526 STA DATA,X ; send command
C985: B9 78 04 527 LDA R30,Y ; get arg from R30 on
C988: 9D 80 C0 528 STA DATA,X
C98B: B9 F8 04 529 LDA R31,Y
C98E: 9D 80 C0 530 STA DATA,X
C991: B9 78 05 531 LDA R32,Y
C994: 9D 80 C0 532 STA DATA,X
C997: B9 F8 05 533 LDA R33,Y
C99A: 9D 80 C0 534 STA DATA,X
C99D: A9 FF 535 LDA #DUMMY
C99F: 9D 80 C0 536 STA DATA,X ; dummy crc
C9A2: 20 FF C8 537 JSR GETR1
C9A5: 7A 538 PLY ; restore Y
C9A6: 60 539 RTS
540
541
542 ********************************
543 *
544 * Check for card detect
545 *
546 * C Clear - card in slot
547 * Set - no card in slot
548 *
549 ********************************
550
C9A7: 48 551 CARDDET PHA
C9A8: A9 40 552 LDA #CD ; 0: card in
C9AA: 3C 83 C0 553 BIT SS,X ; 1: card out
C9AD: 18 554 CLC
C9AE: F0 01 555 BEQ :DONE ; card is in
C9B0: 38 556 SEC ; card is out
C9B1: 68 557 :DONE PLA
C9B2: 60 558 RTS
559
560
561 ********************************
562 *
563 * Check for write protect
564 *
565 * C Clear - card not protected
566 * Set - card write protected
567 *
568 ********************************
569
C9B3: 48 570 WRPROT PHA
C9B4: A9 20 571 LDA #WP ; 0: write enabled
C9B6: 3C 83 C0 572 BIT SS,X ; 1: write disabled
C9B9: 18 573 CLC
C9BA: F0 01 574 BEQ :DONE
C9BC: 38 575 SEC
C9BD: 68 576 :DONE PLA
C9BE: 60 577 RTS
578
579
580 ********************************
581 *
582 * Status request
583 * $43 Unit number DSSS000
584 * $44-45 Unused
585 * $46-47 Unused
586 *
587 * C Clear - No error
588 * Set - Error
589 * A $00 - No error
590 * $2B - Card write protected
591 * $2F - No card inserted
592 * X - Blocks avail (low byte)
593 * Y - Blocks avail (high byte)
594 *
595 ********************************
596
C9BF: A9 00 597 STATUS LDA #0 ; no error
C9C1: A2 FF 598 LDX #$FF ; 32 MB partition
C9C3: A0 FF 599 LDY #$FF
600
C9C5: 20 B3 C9 601 JSR WRPROT
C9C8: 90 02 602 BCC :DONE
C9CA: A9 2B 603 LDA #$2B ; card write protected
604
C9CC: 60 605 :DONE RTS
606
607
608 ********************************
609 *
610 * Read 512 byte block
611 * $43 Unit number DSSS0000
612 * $44-45 Address (LO/HI) of buffer
613 * $46-47 Block number (LO/HI)
614 *
615 * C Clear - No error
616 * Set - Error
617 * A $00 - No error
618 * $27 - Bad block number
619 *
620 ********************************
621
C9CD: 20 4A C9 622 READ JSR GETBLOCK ; calc block address
623
C9D0: BD 83 C0 624 LDA SS,X ; enable /CS
C9D3: 29 FE 625 AND #$FF!SS0
C9D5: 9D 83 C0 626 STA SS,X
C9D8: A9 51 627 LDA #$51 ; send CMD17
C9DA: 20 7F C9 628 JSR COMMAND ; send command
C9DD: D0 50 629 BNE :ERROR ; check for error
630
C9DF: A9 FF 631 :GETTOK LDA #DUMMY ; get data token
C9E1: 9D 80 C0 632 STA DATA,X
C9E4: BD 80 C0 633 LDA DATA,X ; get response
C9E7: C9 FE 634 CMP #$FE
C9E9: D0 F4 635 BNE :GETTOK ; wait for $FE
636
C9EB: BD 81 C0 637 LDA CTRL,X ; enable FRX
C9EE: 09 10 638 ORA #FRX
C9F0: 9D 81 C0 639 STA CTRL,X
C9F3: A9 FF 640 LDA #DUMMY
C9F5: 9D 80 C0 641 STA DATA,X
642
C9F8: A0 00 643 LDY #0
C9FA: BD 80 C0 644 :LOOP1 LDA DATA,X ; read data from card
C9FD: 91 44 645 STA (BUFFER),Y
C9FF: C8 646 INY
CA00: D0 F8 647 BNE :LOOP1
CA02: E6 45 648 INC BUFFER+1 ; inc msb on page boundary
CA04: BD 80 C0 649 :LOOP2 LDA DATA,X
CA07: 91 44 650 STA (BUFFER),Y
CA09: C8 651 INY
CA0A: D0 F8 652 BNE :LOOP2
CA0C: C6 45 653 DEC BUFFER+1
654
CA0E: BD 80 C0 655 :CRC LDA DATA,X ; read two bytes crc
CA11: BD 80 C0 656 LDA DATA,X ; and ignore
CA14: BD 80 C0 657 LDA DATA,X ; read a dummy byte
658
CA17: BD 81 C0 659 LDA CTRL,X ; disable FRX
CA1A: 29 EF 660 AND #$FF!FRX
CA1C: 9D 81 C0 661 STA CTRL,X
CA1F: 18 662 CLC ; no error
CA20: A9 00 663 LDA #0
664
CA22: 08 665 :DONE PHP
CA23: 48 666 PHA
CA24: BD 83 C0 667 LDA SS,X
CA27: 09 01 668 ORA #SS0
CA29: 9D 83 C0 669 STA SS,X ; disable /CS
CA2C: 68 670 PLA
CA2D: 28 671 PLP
CA2E: 60 672 RTS
673
CA2F: 38 674 :ERROR SEC ; an error occured
CA30: A9 27 675 LDA #$27
CA32: 80 EE 676 BRA :DONE
677
678
679 ********************************
680 *
681 * Write 512 byte block
682 * $43 Unit number DSSS0000
683 * $44-45 Address (LO/HI) of buffer
684 * $46-47 Block number (LO/HI)
685 *
686 * C Clear - No error
687 * Set - Error
688 * A $00 - No error
689 * $27 - I/O error or bad block number
690 * $2B - Card write protected
691 *
692 ********************************
693
CA34: 20 B3 C9 694 WRITE JSR WRPROT
CA37: B0 65 695 BCS :WPERROR ; card write protected
696
CA39: 20 4A C9 697 JSR GETBLOCK ; calc block address
698
CA3C: BD 83 C0 699 LDA SS,X ; enable /CS
CA3F: 29 FE 700 AND #$FF!SS0
CA41: 9D 83 C0 701 STA SS,X
CA44: A9 58 702 LDA #$58 ; send CMD24
CA46: 20 7F C9 703 JSR COMMAND ; send command
CA49: D0 4E 704 BNE :IOERROR ; check for error
705
CA4B: A9 FF 706 LDA #DUMMY
CA4D: 9D 80 C0 707 STA DATA,X ; send dummy
CA50: A9 FE 708 LDA #$FE
CA52: 9D 80 C0 709 STA DATA,X ; send data token
710
CA55: A0 00 711 LDY #0
CA57: B1 44 712 :LOOP1 LDA (BUFFER),Y
CA59: 9D 80 C0 713 STA DATA,X : send data to card
CA5C: C8 714 INY
CA5D: D0 F8 715 BNE :LOOP1
CA5F: E6 45 716 INC BUFFER+1 : inc msb on page boundary
CA61: B1 44 717 :LOOP2 LDA (BUFFER),Y
CA63: 9D 80 C0 718 STA DATA,X
CA66: C8 719 INY
CA67: D0 F8 720 BNE :LOOP2
CA69: C6 45 721 DEC BUFFER+1
722
CA6B: A9 FF 723 :CRC LDA #DUMMY
CA6D: 9D 80 C0 724 STA DATA,X ; send 2 dummy crc bytes
CA70: 9D 80 C0 725 STA DATA,X
726
CA73: 9D 80 C0 727 STA DATA,X ; get data response
CA76: BD 80 C0 728 LDA DATA,X
CA79: 29 1F 729 AND #$1F
CA7B: C9 05 730 CMP #$05
CA7D: D0 1A 731 BNE :IOERROR ; check for write error
CA7F: 18 732 CLC ; no error
CA80: A9 00 733 LDA #0
734
CA82: 08 735 :DONE PHP
CA83: 48 736 PHA
CA84: A9 FF 737 :WAIT LDA #DUMMY
CA86: 9D 80 C0 738 STA DATA,X ; wait for write cycle
CA89: BD 80 C0 739 LDA DATA,X ; to complete
CA8C: F0 F6 740 BEQ :WAIT
741
CA8E: BD 83 C0 742 LDA SS,X ; disable /CS
CA91: 09 01 743 ORA #SS0
CA93: 9D 83 C0 744 STA SS,X
CA96: 68 745 PLA
CA97: 28 746 PLP
CA98: 60 747 RTS
748
CA99: 38 749 :IOERROR SEC ; an error occured
CA9A: A9 27 750 LDA #$27
CA9C: 80 E4 751 BRA :DONE
752
CA9E: 38 753 :WPERROR SEC
CA9F: A9 2B 754 LDA #$2B
CAA1: 80 DF 755 BRA :DONE
756
757
758
759 ********************************
760 *
761 * Format
762 * not supported!
763 *
764 ********************************
765
CAA3: 38 766 FORMAT SEC
CAA4: A9 01 767 LDA #$01 ; invalid command
CAA6: 60 768 RTS
769
770
771 ********************************
772 *
773 * Test routine
774 *
775 ********************************
776
CAA7: A5 2B 777 TEST LDA SLOT16
CAA9: 48 778 PHA
CAAA: A5 3D 779 LDA SLOT
CAAC: 48 780 PHA
781
782 * get buffer
CAAD: A9 02 783 LDA #2 ; get 512 byte buffer
CAAF: 20 F5 BE 784 JSR $BEF5 ; call GETBUFR
CAB2: B0 49 785 BCS :ERROR
CAB4: 85 45 786 STA BUFFER+1
CAB6: 64 44 787 STZ BUFFER
CAB8: 68 788 PLA
CAB9: 85 3D 789 STA SLOT
CABB: 68 790 PLA
CABC: 85 2B 791 STA SLOT16
792
793 * fill buffer
CABE: A0 00 794 LDY #0
CAC0: 98 795 :LOOP TYA
CAC1: 91 44 796 STA (BUFFER),Y
CAC3: C8 797 INY
CAC4: D0 FA 798 BNE :LOOP
CAC6: E6 45 799 INC BUFFER+1
CAC8: 98 800 :LOOP1 TYA
CAC9: 91 44 801 STA (BUFFER),Y
CACB: C8 802 INY
CACC: D0 FA 803 BNE :LOOP1
CACE: C6 45 804 DEC BUFFER+1
805
CAD0: 64 46 806 STZ BLOCK ; block number
CAD2: 64 47 807 STZ BLOCK+1
CAD4: A6 2B 808 LDX SLOT16
809
811 * write to card
CAD6: 20 34 CA 812 JSR WRITE
CAD9: B0 22 813 BCS :ERROR
814
815 * read from card
CADB: 20 CD C9 816 JSR READ
CADE: B0 1D 817 BCS :ERROR
818
819 * check for errors
CAE0: A0 00 820 LDY #0
CAE2: 98 821 :LOOP2 TYA
CAE3: D1 44 822 CMP (BUFFER),Y
CAE5: D0 17 823 BNE :ERRCMP ; error in buffer
CAE7: C8 824 INY
CAE8: D0 F8 825 BNE :LOOP2
CAEA: E6 45 826 INC BUFFER+1
CAEC: 98 827 :LOOP3 TYA
CAED: D1 44 828 CMP (BUFFER),Y
CAEF: D0 0D 829 BNE :ERRCMP
CAF1: C8 830 INY
CAF2: D0 F8 831 BNE :LOOP3
CAF4: C6 45 832 DEC BUFFER+1
833
834 * free buffer
CAF6: 20 F8 BE 835 JSR $BEF8 ; call FREEBUFR
CAF9: 18 836 CLC
CAFA: A9 00 837 LDA #0
CAFC: 60 838 RTS
839
CAFD: 00 840 :ERROR BRK
CAFE: 00 841 :ERRCMP BRK
842
843
CAFF: 40 00 00 844 CMD0 HEX 400000
CB02: 00 00 95 845 HEX 000095
CB05: 41 00 00 846 CMD1 HEX 410000
CB08: 00 00 F9 847 HEX 0000F9
CB0B: 48 00 00 848 CMD8 HEX 480000
CB0E: 01 AA 87 849 HEX 01AA87
CB11: 50 00 00 850 CMD16 HEX 500000
CB14: 02 00 FF 851 HEX 0200FF
CB17: 77 00 00 852 CMD55 HEX 770000
CB1A: 00 00 65 853 HEX 000065
CB1D: 69 40 00 854 ACMD4140 HEX 694000
CB20: 00 00 77 855 HEX 000077
CB23: 69 00 00 856 ACMD410 HEX 690000
CB26: 00 00 FF 857 HEX 0000FF
--End assembly, 1065 bytes, Errors: 0
Symbol table - alphabetical order:
ACMD410 =$CB23 ACMD4140=$CB1D BLOCK =$46 ? BOOT =$C72B
BUFFER =$44 CARDDET =$C9A7 CD =$40 CMD0 =$CAFF
CMD1 =$CB05 CMD16 =$CB11 CMD55 =$CB17 CMD8 =$CB0B
CMDHI =$41 CMDLO =$40 COMMAND =$C97F CTRL =$C081
CURSLOT =$07F8 DATA =$C080 DCMD =$42 DEBUG =$00
DIV =$C082 DRIVER =$C749 DUMMY =$FF ECE =$04
FORMAT =$CAA3 FRX =$10 GETBLOCK=$C94A GETR1 =$C8FF
GETR3 =$C918 INIT =$C800 INITED =$80 R30 =$0478
R31 =$04F8 R32 =$0578 R33 =$05F8 READ =$C9CD
SDCMD =$C8EB SLOT =$3D SLOT16 =$2B SS =$C083
SS0 =$01 STATUS =$C9BF TEST =$CAA7 WP =$20
WRITE =$CA34 WRPROT =$C9B3
Symbol table - numerical order:
DEBUG =$00 SS0 =$01 ECE =$04 FRX =$10
WP =$20 SLOT16 =$2B SLOT =$3D CMDLO =$40
CD =$40 CMDHI =$41 DCMD =$42 BUFFER =$44
BLOCK =$46 INITED =$80 DUMMY =$FF R30 =$0478
R31 =$04F8 R32 =$0578 R33 =$05F8 CURSLOT =$07F8
DATA =$C080 CTRL =$C081 DIV =$C082 SS =$C083
? BOOT =$C72B DRIVER =$C749 INIT =$C800 SDCMD =$C8EB
GETR1 =$C8FF GETR3 =$C918 GETBLOCK=$C94A COMMAND =$C97F
CARDDET =$C9A7 WRPROT =$C9B3 STATUS =$C9BF READ =$C9CD
WRITE =$CA34 FORMAT =$CAA3 TEST =$CAA7 CMD0 =$CAFF
CMD1 =$CB<43><42>ÔÁ ÓÌÏÔ±¶<C2B1>±<EFBFBD>Ù<EFBFBD>ãë îõíâåò<C3A5>ææåò<C3A5>ª<EFBFBD> =$CB11 CMD55 =$CB17
ACMD4140=$CB1D ACMD410 =$CB23
31 =$04F8 R32 =$0578 R33 =$05F8
RAM0 =$0678 RAM1 =$06<30>8 READ =$82CF SLOT =$3D
SLOT16 =$2B S ÐÁÕ<C381> =$C083 SS0 =$01 STATUS =$82C1
TEST =$83AD WORK =$3C WP =$20 WRITE =$8338
WRPROT =$82B5
Symbol table - numerical order:
DEBUG =$01 SS0 =$01 ECE =$04 FRX =$10
WP =$20 SLOT16 =$2B WORK =$3C SLOT =$3D
CMDLO =$40 CD =$40 CMDHI =$41 DCMD =$42
BUFFER =$44 BLOCK =$46 INITED =$80 DUMMY =$FF
R30 =$0478 R31 =$04F8 R32 =$0578 R33 =$05F8
RAM0 =$0678 RAM1 =$06F8 CURSLOT =$07F8 INSTALL =$8027
DRIVER =$8062 INIT =$8100 CMD =$81EB GETR1 =$81FF
GETR3 =$821A GETBLOCK=$824C COMMAND =$8281 CARDDET =$82A9
WRPROT =$82B5 STATUS =$82C1 READ =$82CF WRITE =$8338
FORMAT =$83A9 TEST =$83AD CMD0 =$8431 CMD1 =$8437
CMD8 =$843D CMD16 =$8443 CMD55 =$8449 ACMD4140=$844F
ACMD410 =$8455 DATA =$C080 CTRL =$C081 DIV =$C082
SS =$C083

View File

@ -10,8 +10,7 @@
;
;*******************************
;.pc02 ; enable 65C02 code
DEBUG := 0
;DEBUG := 0
; Memory defines
@ -34,7 +33,7 @@ R31 := $04F8
R32 := $0578
R33 := $05F8
; Constants :
; Constants
DUMMY = $FF
FRX = $10 ; CTRL register
@ -50,13 +49,13 @@ INITED = $80
.segment "SLOTROM"
LDX #$20
LDY #$00
LDX #$00
LDX #$03
LDY #$3C
LDX #$01 ; neither Smartport nor 5.25
; find slot nr
.if DEBUG
.ifdef DEBUG
LDA #$04
STA SLOT
LDA #$C4
@ -93,7 +92,7 @@ INITED = $80
;
;*******************************
.if DEBUG
.ifdef DEBUG
; see if slot has a driver already
@ -150,6 +149,7 @@ BOOT: BEQ @DRAW ; check for error
@DRAW: LDY #0 ; display copyright message
@DRAW1: LDA TEXT,Y
BEQ @BOOT1 ; check for NULL
ORA #$80
STA $07D0,Y ; put on last line
INY
BPL @DRAW1
@ -203,7 +203,7 @@ DRIVER: CLD
LDA CMDHI
PHA
.if DEBUG
.ifdef DEBUG
LDA #$04
STA SLOT
LDA #$C4
@ -245,8 +245,10 @@ DRIVER: CLD
BEQ @WRITE
CMP #3
BEQ @FORMAT
.ifdef DEBUG
CMP #$FF
BEQ @TEST
.endif
LDA #1 ; unknown command
SEC
BRA @RESTZP
@ -259,8 +261,10 @@ DRIVER: CLD
BRA @RESTZP
@FORMAT: JSR FORMAT
BRA @RESTZP
.ifdef DEBUG
@TEST: JSR TEST ; do device test
BRA @RESTZP
.endif
@INIT: JSR INIT
BCC @CMD ; init ok
@ -803,6 +807,7 @@ FORMAT: SEC
;
;*******************************
.ifdef DEBUG
TEST: LDA SLOT16
PHA
LDA SLOT
@ -867,9 +872,10 @@ TEST: LDA SLOT16
@ERROR: BRK
@ERRCMP: BRK
.endif
TEXT: .asciiz "Apple][Sd (c)2017 Florian Reitz"
TEXT: .asciiz "Apple][Sd v0.8 (c)2017 Florian Reitz"
CMD0: .byt $40, $00, $00
.byt $00, $00, $95

22
AppleIISd.sln Normal file
View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppleIISd", "AppleIISd.vcxproj", "{9EA7EC3D-1771-420F-932F-231A35ED1200}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9EA7EC3D-1771-420F-932F-231A35ED1200}.Debug|x86.ActiveCfg = Debug|Win32
{9EA7EC3D-1771-420F-932F-231A35ED1200}.Debug|x86.Build.0 = Debug|Win32
{9EA7EC3D-1771-420F-932F-231A35ED1200}.Release|x86.ActiveCfg = Release|Win32
{9EA7EC3D-1771-420F-932F-231A35ED1200}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

94
AppleIISd.vcxproj Normal file
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="appleiisd.cfg" />
<None Include="AppleIISd.s" />
<None Include="makefile" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9EA7EC3D-1771-420F-932F-231A35ED1200}</ProjectGuid>
<Keyword>MakeFileProj</Keyword>
<ProjectName>AppleIISd</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>
</NMakeOutput>
<NMakePreprocessorDefinitions>__APPLE2__;__APPLE2ENH__;__fastcall__=__fastcall;_MSC_VER=0;__attribute__</NMakePreprocessorDefinitions>
<ExecutablePath>$(PATH);C:\cc65\bin</ExecutablePath>
<IncludePath>C:\cc65\include</IncludePath>
<LibraryPath>C:\cc65\lib</LibraryPath>
<LibraryWPath />
<ExcludePath />
<NMakeBuildCommandLine>$(MAKE_HOME)\make -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)" OPTIONS=mapfile,listing</NMakeBuildCommandLine>
<SourcePath>$(ProjectDir)\src</SourcePath>
<NMakeReBuildCommandLine>$(MAKE_HOME)\make clean -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)"
$(MAKE_HOME)\make -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)/$(ProjectName)" OPTIONS=mapfile,listing
rmdir /S /Q "$(ProjectDir)obj"
rmdir /S /Q "$(SolutionDir)Debug"</NMakeReBuildCommandLine>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<NMakeCleanCommandLine>$(MAKE_HOME)\make clean -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)"</NMakeCleanCommandLine>
<ReferencePath />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeOutput>
</NMakeOutput>
<NMakePreprocessorDefinitions>
</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>del /S /Q "$(ProjectDir)makefile.options
$(MAKE_HOME)\make -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)"
rmdir /S /Q "$(ProjectDir)obj\Win32"
rmdir /S /Q "$(SolutionDir)Release"</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>del /S /Q "$(ProjectDir)makefile.options
$(MAKE_HOME)\make clean -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)"
$(MAKE_HOME)\make -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)"
rmdir /S /Q "$(ProjectDir)obj\Win32"
rmdir /S /Q "$(SolutionDir)Release"
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>del /S /Q "$(ProjectDir)makefile.options
$(MAKE_HOME)\make clean -C "$(ProjectDir)\" PROGRAM="$(ProjectDir)$(Configuration)\$(ProjectName)"
rmdir /S /Q "$(ProjectDir)obj\Win32"
rmdir /S /Q "$(SolutionDir)Release"</NMakeCleanCommandLine>
<ExecutablePath>$(PATH);C:\cc65\bin</ExecutablePath>
<IncludePath>$(VC_IncludePath);C:\cc65\include</IncludePath>
<ReferencePath />
<LibraryPath>C:\cc65\lib</LibraryPath>
<ExcludePath />
<LibraryWPath />
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

27
appleiisd.cfg Normal file
View File

@ -0,0 +1,27 @@
# Configuration for assembler programs which don't need a special setup
FEATURES {
STARTADDRESS: default = $0803;
}
MEMORY {
ZP: file = "", start = $0000, size = $00FF;
HEADER: file = %O, start = %S - 4, size = $0004;
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;
SLOTID: file = %O, start = $C7FC, size = $0004;
EXTROM: file = %O, fill = yes start = $C800, size = $0700;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXEHDR: load = HEADER, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = BSS, type = bss, optional = yes, define = yes;
SLOTROM: load = SLOTROM, type = ro;
SLOTID: load = SLOTID, type = ro;
EXTROM: load = EXTROM, type = ro, optional = yes;
}

346
makefile Normal file
View File

@ -0,0 +1,346 @@
###############################################################################
### Generic Makefile for cc65 projects - full version with abstract options ###
### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" ?ogiewa ###
###############################################################################
###############################################################################
### In order to override defaults - values can be assigned to the variables ###
###############################################################################
# Space or comma separated list of cc65 supported target platforms to build for.
# Default: c64 (lowercase!)
TARGETS := apple2enh
# Name of the final, single-file executable.
# Default: name of the current dir with target name appended
PROGRAM := appleiisd
# Path(s) to additional libraries required for linking the program
# Use only if you don't want to place copies of the libraries in SRCDIR
# Default: none
LIBS :=
# Custom linker configuration file
# Use only if you don't want to place it in SRCDIR
# Default: none
CONFIG := appleiisd.cfg
# Additional C compiler flags and options.
# Default: none
CFLAGS =
# Additional assembler flags and options.
# Default: none
ASFLAGS =
# Additional linker flags and options.
# Default: none
LDFLAGS =
# Path to the directory containing C and ASM sources.
# Default: src
SRCDIR := .
# Path to the directory where object files are to be stored (inside respective target subdirectories).
# Default: obj
OBJDIR :=
# Command used to run the emulator.
# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload
EMUCMD :=
# Optional commands used before starting the emulation process, and after finishing it.
# Default: none
# Examples
#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate"
#PREEMUCMD := osascript -e "tell application \"X11\" to activate"
#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false"
#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate"
PREEMUCMD :=
POSTEMUCMD :=
# On Windows machines VICE emulators may not be available in the PATH by default.
# In such case, please set the variable below to point to directory containing
# VICE emulators.
#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\"
VICE_HOME :=
# Options state file name. You should not need to change this, but for those
# rare cases when you feel you really need to name it differently - here you are
STATEFILE := Makefile.options
###################################################################################
#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! ####
###################################################################################
###################################################################################
### Mapping abstract options to the actual compiler, assembler and linker flags ###
### Predefined compiler, assembler and linker flags, used with abstract options ###
### valid for 2.14.x. Consult the documentation of your cc65 version before use ###
###################################################################################
# Compiler flags used to tell the compiler to optimise for SPEED
define _optspeed_
CFLAGS += -Oris
endef
# Compiler flags used to tell the compiler to optimise for SIZE
define _optsize_
CFLAGS += -Or
endef
# Compiler and assembler flags for generating listings
define _listing_
CFLAGS += --listing $$(@:.o=.lst)
ASFLAGS += --listing $$(@:.o=.lst)
REMOVES += $(addsuffix .lst,$(basename $(OBJECTS)))
endef
# Linker flags for generating map file
define _mapfile_
LDFLAGS += --mapfile $$@.map
REMOVES += $(PROGRAM).map
endef
# Linker flags for generating VICE label file
define _labelfile_
LDFLAGS += -Ln $$@.lbl
REMOVES += $(PROGRAM).lbl
endef
# Linker flags for generating a debug file
define _debugfile_
LDFLAGS += -Wl --dbgfile,$$@.dbg
REMOVES += $(PROGRAM).dbg
endef
###############################################################################
### Defaults to be used if nothing defined in the editable sections above ###
###############################################################################
# Presume the C64 target like the cl65 compile & link utility does.
# Set TARGETS to override.
ifeq ($(TARGETS),)
TARGETS := c64
endif
# Presume we're in a project directory so name the program like the current
# directory. Set PROGRAM to override.
ifeq ($(PROGRAM),)
PROGRAM := $(notdir $(CURDIR))
endif
# Presume the C and asm source files to be located in the subdirectory 'src'.
# Set SRCDIR to override.
ifeq ($(SRCDIR),)
SRCDIR := src
endif
# Presume the object and dependency files to be located in the subdirectory
# 'obj' (which will be created). Set OBJDIR to override.
ifeq ($(OBJDIR),)
OBJDIR := obj
endif
TARGETOBJDIR := $(OBJDIR)
# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily
# rely on cl65 being added to the PATH in this scenario.
ifdef CC65_HOME
CC := $(CC65_HOME)/bin/cl65
else
CC := cl65
endif
# Default emulator commands and options for particular targets.
# Set EMUCMD to override.
c64_EMUCMD := $(VICE_HOME)x64 -kernal kernal -VICIIdsize -autoload
c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload
vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload
pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload
plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload
# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option
c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload
cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload
cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload
atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run
ifeq ($(EMUCMD),)
EMUCMD = $($(CC65TARGET)_EMUCMD)
endif
###############################################################################
### The magic begins ###
###############################################################################
# The "Native Win32" GNU Make contains quite some workarounds to get along with
# cmd.exe as shell. However it does not provide means to determine that it does
# actually activate those workarounds. Especially $(SHELL) does NOT contain the
# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to
# execute the command 'echo' without any parameters. Only cmd.exe will return a
# non-empty string - saying 'ECHO is on/off'.
#
# Many "Native Win32" programs accept '/' as directory delimiter just fine. How-
# ever the internal commands of cmd.exe generally require '\' to be used.
#
# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a
# '-p' to create parent directories as needed.
#
# cmd.exe has an internal command 'del' that reports a syntax error if executed
# without any file so make sure to call it only if there's an actual argument.
ifeq ($(shell echo),)
MKDIR = mkdir -p $1
RMDIR = rmdir $1
RMFILES = $(RM) $1
else
MKDIR = mkdir $(subst /,\,$1)
RMDIR = rmdir $(subst /,\,$1)
RMFILES = $(if $1,del /f $(subst /,\,$1))
endif
COMMA := ,
SPACE := $(N/A) $(N/A)
define NEWLINE
endef
# Note: Do not remove any of the two empty lines above !
TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS))
ifeq ($(words $(TARGETLIST)),1)
# Set PROGRAM to something like 'myprog.c64'.
override PROGRAM := $(PROGRAM).bin
# Set SOURCES to something like 'src/foo.c src/bar.s'.
# Use of assembler files with names ending differently than .s is deprecated!
SOURCES := $(wildcard $(SRCDIR)/*.c)
SOURCES += $(wildcard $(SRCDIR)/*.s)
SOURCES += $(wildcard $(SRCDIR)/*.asm)
SOURCES += $(wildcard $(SRCDIR)/*.a65)
# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'.
# Use of assembler files with names ending differently than .s is deprecated!
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.c)
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.s)
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.asm)
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.a65)
# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'.
OBJECTS := $(addsuffix .o,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES)))))
# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'.
DEPENDS := $(OBJECTS:.o=.d)
# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'.
LIBS += $(wildcard $(SRCDIR)/*.lib)
LIBS += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.lib)
# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'.
CONFIG += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.cfg)
CONFIG += $(wildcard $(SRCDIR)/*.cfg)
# Select CONFIG file to use. Target specific configs have higher priority.
ifneq ($(word 2,$(CONFIG)),)
CONFIG := $(firstword $(CONFIG))
$(info Using config file $(CONFIG) for linking)
endif
.SUFFIXES:
.PHONY: all test clean zap love
all: $(PROGRAM)
-include $(DEPENDS)
-include $(STATEFILE)
# If OPTIONS are given on the command line then save them to STATEFILE
# if (and only if) they have actually changed. But if OPTIONS are not
# given on the command line then load them from STATEFILE. Have object
# files depend on STATEFILE only if it actually exists.
ifeq ($(origin OPTIONS),command line)
ifneq ($(OPTIONS),$(_OPTIONS_))
ifeq ($(OPTIONS),)
$(info Removing OPTIONS)
$(shell $(RM) $(STATEFILE))
$(eval $(STATEFILE):)
else
$(info Saving OPTIONS=$(OPTIONS))
$(shell echo _OPTIONS_=$(OPTIONS) > $(STATEFILE))
endif
$(eval $(OBJECTS): $(STATEFILE))
endif
else
ifeq ($(origin _OPTIONS_),file)
$(info Using saved OPTIONS=$(_OPTIONS_))
OPTIONS = $(_OPTIONS_)
$(eval $(OBJECTS): $(STATEFILE))
endif
endif
# Transform the abstract OPTIONS to the actual cc65 options.
$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_)))
# Strip potential variant suffix from the actual cc65 target.
CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST)))
# The remaining targets.
$(TARGETOBJDIR):
$(call MKDIR,$@)
vpath %.c $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $<
vpath %.s $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
vpath %.asm $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.asm | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
vpath %.a65 $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.a65 | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
$(PROGRAM): $(CONFIG) $(OBJECTS) $(LIBS)
$(CC) -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^)
test: $(PROGRAM)
$(PREEMUCMD)
$(EMUCMD) $<
$(POSTEMUCMD)
clean:
$(call RMFILES,$(OBJECTS))
$(call RMFILES,$(DEPENDS))
$(call RMFILES,$(REMOVES))
$(call RMFILES,$(PROGRAM))
else # $(words $(TARGETLIST)),1
all test clean:
$(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE))
endif # $(words $(TARGETLIST)),1
OBJDIRLIST := $(wildcard $(OBJDIR)/*)
zap:
$(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.o $o/*.d $o/*.lst)$(NEWLINE))
$(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE))
-$(call RMDIR,$(OBJDIR))
-$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE))
love:
@echo "Not war, eh?"
###################################################################
### Place your additional targets in the additional Makefiles ###
### in the same directory - their names have to end with ".mk"! ###
###################################################################
-include *.mk