mads 2.1.0 build 8 (23 Dec 19) Source: antic_wsync.s 1 ; Altirra Acid800 test suite 2 ; Copyright (C) 2010 Avery Lee, All Rights Reserved. 3 ; 4 ; Permission is hereby granted, free of charge, to any person obtaining a copy 5 ; of this software and associated documentation files (the "Software"), to deal 6 ; in the Software without restriction, including without limitation the rights 7 ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 ; copies of the Software, and to permit persons to whom the Software is 9 ; furnished to do so, subject to the following conditions: 10 ; 11 ; The above copyright notice and this permission notice shall be included in 12 ; all copies or substantial portions of the Software. 13 ; 14 ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 ; SOFTWARE. 21 22 FFFF0001 _SAP_HEADER "ANTIC: WSYNC timing" Macro: _SAP_HEADER [Source: library.s] 2 opt o+h-f- 3 org $0700 4 0700 53 41 50 0D 0A dta c"SAP",$0d,$0a 5 0705 41 55 54 48 4F 52 + dta c"AUTHOR ",$22,c"Avery Lee",$22,$0d,$0a 6 0719 4E 41 4D 45 20 22 + dta c"NAME ",$22,c"ANTIC: WSYNC timing",$22,$0d,$0a 7 0735 54 59 50 45 20 44 + dta c"TYPE D",$0d,$0a 8 073D 49 4E 49 54 20 32 + dta c"INIT 2000",$0d,$0a 9 0748 54 49 4D 45 20 30 + dta c"TIME 00:",c"05",$0d,$0a 10 0754 FF FF dta a($ffff) Source: antic_wsync.s 23 24 opt h+o+ 25 26 0756 icl 'library.s' Source: library.s 1 ; Altirra Acid800 test suite 2 ; Copyright (C) 2010 Avery Lee, All Rights Reserved. 3 ; 4 ; Permission is hereby granted, free of charge, to any person obtaining a copy 5 ; of this software and associated documentation files (the "Software"), to deal 6 ; in the Software without restriction, including without limitation the rights 7 ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 ; copies of the Software, and to permit persons to whom the Software is 9 ; furnished to do so, subject to the following conditions: 10 ; 11 ; The above copyright notice and this permission notice shall be included in 12 ; all copies or substantial portions of the Software. 13 ; 14 ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 ; SOFTWARE. 21 22 ;========================================================================== 23 ; MEMORY MAP (800) 24 ; 25 ; $0000-007F OS zero page 26 ; $0080-00BF Module zero page 27 ; $00C0-00DF Library zero page 28 ; $00E0-00EF 80-column zero page 29 ; $0100-01FF 6502 stack 30 ; $0200-03FF OS database 31 ; $0400-09FF Boot loader / unused 32 ; $0A00-0AFF Boot loader / Veronica support resident page 33 ; $0B00-0BFF Boot loader / sector load buffer 34 ; $0C00-0FFF Boot loader / 16K display 35 ; $1000-18FF Resident test driver (full suite only) 36 ; $1900-19FF Segment tables (full suite only) 37 ; $1A00-1FFF Library code 38 ; $2000-3FFF Module run area 39 ; $4000-5FFF Segment load area / Extended memory window 40 ; $6000-7FFF 80-column screen A / Extended memory window 41 ; $9000-9BFF 80-column driver 42 ; $9C00-9FFF Unused (display list if cart) 43 ; $A000-BFFF 80-column screen B 44 ; 45 ; MEMORY MAP (5200) 46 ; 47 ; $0000-001F OS zero page 48 ; $0020-003F Display zero page 49 ; $0080-00BF Module zero page 50 ; $00C0-00DF Library zero page 51 ; $0100-01FF 6502 stack 52 ; $0200-021F OS database 53 ; $0220-027F Unused 54 ; $0280-02FF Library database 55 ; $0300-07FF Display memory 56 ; $0800-0FFF Unused 57 ; $1000-1FFF LZ decompression history window 58 ; $2000-3FFF Module run area 59 ; $4000-BFFF Cartridge library code and module store 60 ; 61 ; MEMORY MAP (SAP) 62 ; 63 ; $0080-00BF Module zero page 64 ; $00C0-00DF Library zero page 65 ; $0280-02FF Library database 66 ; $0300-07FF Display memory 67 ; $2000-3FFF Module run area 68 ; $4000-BFFF Module store 69 70 ;========================================================================== 71 ; CONFIGURATION 72 ; 73 .ifndef SYS800 74 = 0001 SEGS_IN_ROM = 1 75 .else 76 SEGS_MIN_MEM = 1 77 .endif 78 79 .ifdef SYS5200 80 SEGS_LZPACK = 1 81 .endif 82 83 ;========================================================================== 84 ; HARDWARE INCLUDES 85 ; 86 .ifdef SYS5200 87 ;GTIA 88 gtia = $c000 89 m0pf equ $c000 90 m1pf equ $c001 91 m2pf equ $c002 92 m3pf equ $c003 93 p0pf equ $c004 94 p1pf equ $c005 95 p2pf equ $c006 96 p3pf equ $c007 97 m0pl equ $c008 98 m1pl equ $c009 99 m2pl equ $c00a 100 m3pl equ $c00b 101 p0pl equ $c00c 102 p1pl equ $c00d 103 p2pl equ $c00e 104 p3pl equ $c00f 105 hposp0 equ $c000 106 hposp1 equ $c001 107 hposp2 equ $c002 108 hposp3 equ $c003 109 hposm0 equ $c004 110 hposm1 equ $c005 111 hposm2 equ $c006 112 hposm3 equ $c007 113 sizep0 equ $c008 114 sizep1 equ $c009 115 sizep2 equ $c00a 116 sizep3 equ $c00b 117 sizem equ $c00c 118 grafp0 equ $c00d 119 grafp1 equ $c00e 120 grafp2 equ $c00f 121 grafp3 equ $c010 122 trig0 equ $c010 123 grafm equ $c011 124 colpm0 equ $c012 125 colpm1 equ $c013 126 colpm2 equ $c014 127 pal equ $c014 128 colpm3 equ $c015 129 colpf0 equ $c016 130 colpf1 equ $c017 131 colpf2 equ $c018 132 colpf3 equ $c019 133 colbk equ $c01a 134 prior equ $c01b 135 vdelay equ $c01c 136 gractl equ $c01d 137 hitclr equ $c01e 138 consol equ $c01f 139 140 ;POKEY 141 pokey = $e800 142 audf1 equ $e800 143 audc1 equ $e801 144 audf2 equ $e802 145 audc2 equ $e803 146 audf3 equ $e804 147 audc3 equ $e805 148 audf4 equ $e806 149 audc4 equ $e807 150 audctl equ $e808 151 stimer equ $e809 152 random equ $e80a 153 skres equ $e80a 154 serin equ $e80d 155 serout equ $e80d 156 irqen equ $e80e 157 irqst equ $e80e 158 skctl equ $e80f 159 skstat equ $e80f 160 .else 161 ;GTIA 162 = D000 gtia = $d000 163 = D000 m0pf equ $d000 164 = D001 m1pf equ $d001 165 = D002 m2pf equ $d002 166 = D003 m3pf equ $d003 167 = D004 p0pf equ $d004 168 = D005 p1pf equ $d005 169 = D006 p2pf equ $d006 170 = D007 p3pf equ $d007 171 = D008 m0pl equ $d008 172 = D009 m1pl equ $d009 173 = D00A m2pl equ $d00a 174 = D00B m3pl equ $d00b 175 = D00C p0pl equ $d00c 176 = D00D p1pl equ $d00d 177 = D00E p2pl equ $d00e 178 = D00F p3pl equ $d00f 179 = D000 hposp0 equ $d000 180 = D001 hposp1 equ $d001 181 = D002 hposp2 equ $d002 182 = D003 hposp3 equ $d003 183 = D004 hposm0 equ $d004 184 = D005 hposm1 equ $d005 185 = D006 hposm2 equ $d006 186 = D007 hposm3 equ $d007 187 = D008 sizep0 equ $d008 188 = D009 sizep1 equ $d009 189 = D00A sizep2 equ $d00a 190 = D00B sizep3 equ $d00b 191 = D00C sizem equ $d00c 192 = D00D grafp0 equ $d00d 193 = D00E grafp1 equ $d00e 194 = D00F grafp2 equ $d00f 195 = D010 grafp3 equ $d010 196 = D010 trig0 equ $d010 197 = D011 grafm equ $d011 198 = D012 colpm0 equ $d012 199 = D013 colpm1 equ $d013 200 = D014 colpm2 equ $d014 201 = D014 pal equ $d014 202 = D015 colpm3 equ $d015 203 = D016 colpf0 equ $d016 204 = D017 colpf1 equ $d017 205 = D018 colpf2 equ $d018 206 = D019 colpf3 equ $d019 207 = D01A colbk equ $d01a 208 = D01B prior equ $d01b 209 = D01C vdelay equ $d01c 210 = D01D gractl equ $d01d 211 = D01E hitclr equ $d01e 212 = D01F consol equ $d01f 213 214 ;POKEY 215 = D200 pokey = $d200 216 = D200 audf1 equ $d200 217 = D201 audc1 equ $d201 218 = D202 audf2 equ $d202 219 = D203 audc2 equ $d203 220 = D204 audf3 equ $d204 221 = D205 audc3 equ $d205 222 = D206 audf4 equ $d206 223 = D207 audc4 equ $d207 224 = D208 audctl equ $d208 225 = D209 stimer equ $d209 226 = D209 kbcode equ $d209 227 = D20A random equ $d20a 228 = D20A skres equ $d20a 229 = D20D serin equ $d20d 230 = D20D serout equ $d20d 231 = D20E irqen equ $d20e 232 = D20E irqst equ $d20e 233 = D20F skctl equ $d20f 234 = D20F skstat equ $d20f 235 236 ;PIA 237 = D300 porta equ $d300 238 = D301 portb equ $d301 239 = D302 pactl equ $d302 240 = D303 pbctl equ $d303 241 .endif 242 243 ;ANTIC 244 = D400 dmactl equ $d400 245 = D401 chactl equ $d401 246 = D402 dlistl equ $d402 247 = D403 dlisth equ $d403 248 = D404 hscrol equ $d404 249 = D405 vscrol equ $d405 250 = D407 pmbase equ $d407 251 = D409 chbase equ $d409 252 = D40A wsync equ $d40a 253 = D40B vcount equ $d40b 254 = D40E nmien equ $d40e 255 = D40F nmires equ $d40f 256 = D40F nmist equ $d40f 257 258 ;========================================================================== 259 ; OS INCLUDES (5200) 260 ; 261 .ifdef SYS5200 262 pokmsk equ $00 263 rtclok equ $01 264 ; equ $02 265 critic equ $03 266 atract equ $04 267 sdlstl equ $05 268 sdlsth equ $06 269 sdmctl equ $07 270 pcolr0 equ $08 271 pcolr1 equ $09 272 pcolr2 equ $0a 273 pcolr3 equ $0b 274 color0 equ $0c 275 color1 equ $0d 276 color2 equ $0e 277 color3 equ $0f 278 color4 equ $10 279 280 vimirq equ $0200 ;IRQ immediate vector 281 vvblki equ $0202 ;VBI immediate vector 282 vvblkd equ $0204 ;VBI deferred vector 283 vdslst equ $0206 ;display list vector 284 vkybdi equ $0208 ;keyboard immediate vector 285 vkybdf equ $020a ;keyboard deferred vector 286 .endif 287 288 ;========================================================================== 289 ; OS INCLUDES (800) 290 ; 291 .ifndef SYS5200 292 = 0010 pokmsk equ $10 293 = 0012 rtclok equ $12 294 = 0058 savmsc equ $58 295 = 006A ramtop equ $6a 296 297 = 0200 vdslst equ $0200 298 = 0208 vkeybd equ $0208 299 = 0216 vimirq equ $0216 300 = 0218 cdtmv1 equ $0218 301 = 0222 vvblki equ $0222 302 = 0224 vvblkd equ $0224 303 = 0226 cdtma1 equ $0226 304 = 022F sdmctl equ $022f 305 = 0230 sdlstl equ $0230 306 = 0231 sdlsth equ $0231 307 = 0232 sskctl equ $0232 308 = 02E0 runad equ $02e0 309 = 02E2 initad equ $02e2 310 = 02E5 memtop equ $02e5 311 = 02F2 ch1 equ $02f2 312 = 02FC ch equ $02fc 313 314 = 0300 ddevic equ $0300 315 = 0301 dunit equ $0301 316 = 0302 dcomnd equ $0302 317 = 0303 dstats equ $0303 318 = 0304 dbuflo equ $0304 319 = 0305 dbufhi equ $0305 320 = 0306 dtimlo equ $0306 321 = 0308 dbytlo equ $0308 322 = 0309 dbythi equ $0309 323 = 030A daux1 equ $030a 324 = 030B daux2 equ $030b 325 326 = 0340 ichid equ $0340 327 = 0342 iccmd equ $0342 328 = 0344 icbal equ $0344 329 = 0345 icbah equ $0345 330 = 0346 icptl equ $0346 331 = 0347 icpth equ $0347 332 = 0348 icbll equ $0348 333 = 0349 icblh equ $0349 334 = 034A icax1 equ $034a 335 = 034B icax2 equ $034b 336 337 = 03F8 basicf equ $03f8 338 339 = E453 dskinv equ $e453 340 = E456 ciov equ $e456 341 = E459 siov equ $e459 342 = E462 xitvbv equ $e462 343 .endif 344 345 ;========================================================================== 346 ; LIBRARY ZP 347 ; 348 = 00C0 a0 equ $c0 349 = 00C2 a1 equ $c2 350 = 00C4 a2 equ $c4 351 = 00C6 a3 equ $c6 352 = 00C8 d0 equ $c8 353 = 00C9 d1 equ $c9 354 = 00CA d2 equ $ca 355 = 00CB d3 equ $cb 356 = 00CC d4 equ $cc 357 = 00CD d5 equ $cd 358 = 00CE d6 equ $ce 359 = 00CF d7 equ $cf 360 361 ;========================================================================== 362 ; LIBRARY VARS 363 ; 364 opt o- 365 366 .ifdef SYS5200 367 opt f- 368 .else 369 .ifdef STANDALONE 370 opt o+ 371 .endif 372 .ifdef GENLIBRARY 373 opt o+ 374 .endif 375 .endif 376 377 .ifdef SYSSAP 378 0756 org $0280 379 .endif 380 381 .ifdef SYS5200 382 org $0280 383 .endif 384 385 .ifdef SYS800 386 org $1a20 387 .endif 388 0280-028D> 00 _intsOff dta 0 389 0281 00 _scrnOff dta 0 390 0282 00 00 _prevIRQ dta a(0) 391 0284 00 00 _prevVBI dta a(0) 392 0286 00 00 _exitTest dta a(0) 393 0288 FF _exitTestS dta $ff 394 0289 00 00 _vputchar dta a(0) 395 396 .ifdef SYS800 397 _vputunhook dta a(0) 398 .endif 399 400 = 0000 CPUMODE_6502 = 0 401 = 0001 CPUMODE_65C02 = 1 402 = 0080 CPUMODE_65C816_16 = 0x80 403 = 0081 CPUMODE_65C816_24 = 0x81 404 028B 00 _cpuMode dta 0 405 406 028C 00 _veronica dta 0 407 408 .ifdef SYS5200 409 sskctl dta 0 410 ch dta 0 411 keydel dta 0 412 413 org $02e0 414 runad dta a(0) 415 initad dta a(0) 416 .endif 417 418 .ifdef SEGS_IN_ROM 419 028D 00 _lastMod dta 0 420 .endif 421 .ifdef SEGS_MIN_MEM 422 _lastMod dta 0 423 .endif 424 425 .ifdef SYS5200 426 .ifdef STANDALONE 427 opt o+f+ 428 .endif 429 .ifdef GENLIBRARY 430 opt o+f+ 431 .endif 432 433 .ifdef LIBBASE 434 org LIBBASE 435 .else 436 org $4000 437 .endif 438 .endif 439 440 .ifdef SYSSAP 441 028E org $4000 442 .endif 443 444 ;========================================================================== 445 ; MACROS 446 ; 447 .macro _INITTEST 448 jsr _imTestInit 449 dta :1,0 450 .endm 451 452 .macro _ASSERT1 453 lda :1 454 cmp #:2 455 beq pass 456 457 sta d1 458 jsr _testFailed 459 dta :3,0 460 pass: 461 .endm 462 463 .macro _ASSERT1_DUAL 464 lda :1 465 cmp #:2 466 beq pass 467 cmp #:3 468 beq pass 469 470 sta d1 471 jsr _testFailed 472 dta :4,0 473 pass: 474 .endm 475 476 .macro _ASSERTA 477 cmp #:1 478 beq pass 479 480 sta d1 481 jsr _testFailed 482 dta :2,0 483 pass: 484 .endm 485 486 .macro _ASSERTX 487 cpx #:1 488 beq pass 489 490 stx d1 491 jsr _testFailed 492 dta :2,0 493 pass: 494 .endm 495 496 .macro _ASSERTY 497 cpy #:1 498 beq pass 499 500 sty d1 501 jsr _testFailed 502 dta :2,0 503 pass: 504 .endm 505 506 .macro _FAIL 507 jsr _testFailed 508 dta :1,0 509 .endm 510 511 .macro _SKIP 512 jsr _testSkipped 513 dta :1,0 514 .endm 515 516 .macro _SAP_HEADER 517 .ifdef GENSAP 518 opt o+h-f- 519 org $0700 520 dta c"SAP",$0d,$0a 521 dta c"AUTHOR ",$22,c"Avery Lee",$22,$0d,$0a 522 dta c"NAME ",$22,c":1",$22,$0d,$0a 523 dta c"TYPE D",$0d,$0a 524 dta c"INIT 2000",$0d,$0a 525 dta c"TIME 00:",c"05",$0d,$0a 526 dta a($ffff) 527 .endif 528 .endm 529 530 ;========================================================================== 531 4000 .nowarn .proc _crt0init 532 .ifdef SYSSAP 533 4000-44E0> 20 09 44 jsr _crt0init_sap 534 .endif 535 536 ;clear zero page and database 537 .ifdef SYS5200 538 ldx #$20 539 lda #0 540 zploop: 541 sta 0,x 542 inx 543 bne zploop 544 ldx #$80 545 dbloop: 546 sta $0200,x 547 inx 548 bne dbloop 549 .endif 550 551 ;clear options (keep in sync with options.s) 552 4003 A2 06 ldx #6 553 4005 A9 00 lda #0 554 .ifdef SYS5200 555 sta:rpl $02f0,x- 556 .else 557 4007 9D 00 1A CA 10 FA sta:rpl $1a00,x- 558 .endif 559 560 ;detect CPU 561 400D A0 00 ldy #CPUMODE_6502 562 400F F8 sed 563 4010 A9 99 lda #$99 564 4012 18 clc 565 4013 69 01 adc #$01 566 4015 D8 cld 567 4016 D0 1E bne detdone 568 569 ;we have at least a 65C02... check for 65C816 570 4018 A0 01 ldy #CPUMODE_65C02 571 572 401A 38 sec 573 opt c+ 574 401B C2 01 rep #$01 575 401D B0 17 bcs detdone 576 401F E2 01 sep #$01 577 4021 90 13 bcc detdone 578 579 4023 A0 80 ldy #CPUMODE_65C816_16 580 581 ;check for 24-bit addressing 582 4025 AF CB 00 01 lda d3+$10000 583 4029 AA tax 584 402A 49 F5 eor #$f5 585 402C 85 CB sta d3 586 402E 8A txa 587 402F CF CB 00 01 cmp d3+$10000 588 4033 D0 01 sne 589 4035 C8 iny 590 591 opt c- 592 593 4036 detdone: 594 4036 8C 8B 02 sty _cpuMode 595 596 .ifdef SYS5200 597 jsr _crt0init_5200 598 .endif 599 600 .ifdef SYS800 601 ;init putchar handler 602 mwa icptl _vputchar 603 inw _vputchar 604 .endif 605 606 4039 60 rts 607 .endp 608 609 ;========================================================================== 610 403A .nowarn .proc _interruptsOff 611 403A AD 80 02 lda _intsOff 612 403D 30 12 bmi xit 613 403F 78 sei 614 4040 AD 16 02 8D 82 02 + mwa vimirq _prevIRQ 615 404C A9 FF 8D 80 02 mva #$ff _intsOff 616 4051 xit: 617 4051 60 rts 618 .endp 619 620 ;========================================================================== 621 4052 .nowarn .proc _interruptsOn 622 4052 AD 80 02 lda _intsOff 623 4055 10 18 bpl xit 624 4057 78 sei 625 4058 AD 82 02 8D 16 02 + mwa _prevIRQ vimirq 626 4064 A5 10 8D 0E D2 mva pokmsk irqen 627 4069 A9 00 8D 80 02 mva #$00 _intsOff 628 406E 58 cli 629 406F xit: 630 406F 60 rts 631 .endp 632 633 ;========================================================================== 634 4070 .nowarn .proc _screenOn 635 .ifndef SYSSAP 636 lda _scrnOff 637 bpl xit 638 639 jsr _waitVBL 640 641 sei 642 lda #0 643 sta wsync 644 sta nmien 645 mva #$22 dmactl 646 mwa sdlstl dlistl 647 mwa _prevVBI vvblki 648 lda #$40 649 sta nmien 650 cli 651 652 jsr _waitVBL 653 sta wsync 654 sta wsync 655 jsr _waitVBL 656 .endif 657 658 4070 A9 00 8D 81 02 mva #$00 _scrnOff 659 4075 xit: 660 4075 60 rts 661 .endp 662 663 ;========================================================================== 664 4076 .nowarn .proc _screenOff 665 .ifndef SYSSAP 666 lda _scrnOff 667 bmi xit 668 669 jsr _waitVBL 670 671 php 672 sei 673 lda #0 674 sta wsync 675 sta nmien 676 sta dmactl 677 mwa vvblki _prevVBI 678 plp 679 .endif 680 681 4076 A9 FF 8D 81 02 mva #$ff _scrnOff 682 407B xit: 683 407B 60 rts 684 .endp 685 686 ;========================================================================== 687 407C .nowarn .proc _waitVBL 688 407C A9 7B lda #123 689 407E CD 0B D4 D0 FB cmp:rne vcount 690 4083 CD 0B D4 F0 FB cmp:req vcount 691 4088 60 rts 692 .endp 693 694 ;========================================================================== 695 4089 .nowarn .proc _waitFrame 696 4089 EE 0A D4 inc wsync 697 408C EE 0A D4 inc wsync 698 408F 4C 7C 40 jmp _waitVBL 699 .endp 700 701 ;========================================================================== 702 4092 .nowarn .proc _waitKeyPrompt 703 4092 20 D8 40 jsr _imprint 704 4095 50 72 65 73 73 20 + dta c"Press a key...",0 705 .ifdef SYS5200 706 mva #$ff ch 707 lda:rmi ch 708 .else 709 40A4 A9 00 lda #0 710 40A6 8D FC 02 sta ch 711 40A9 8D F2 02 sta ch1 712 40AC AD FC 02 F0 FB lda:req ch 713 .endif 714 40B1 20 D8 40 jsr _imprint 715 40B4 9C 00 dta $9c,0 716 40B6 60 rts 717 .endp 718 719 ;========================================================================== 720 40B7 .nowarn .proc _resetAV 721 40B7 A9 00 lda #0 722 40B9 8D 1D D0 sta gractl 723 40BC 8D 0D D0 sta grafp0 724 40BF 8D 0E D0 sta grafp1 725 40C2 8D 0F D0 sta grafp2 726 40C5 8D 10 D0 sta grafp3 727 40C8 8D 11 D0 sta grafm 728 40CB 8D 01 D2 sta audc1 729 40CE 8D 03 D2 sta audc2 730 40D1 8D 05 D2 sta audc3 731 40D4 8D 07 D2 sta audc4 732 40D7 60 rts 733 .endp 734 735 ;========================================================================== 736 40D8 .nowarn .proc _imprint 737 40D8 68 pla 738 40D9 AA tax 739 40DA 68 pla 740 40DB A8 tay 741 40DC E8 inx 742 40DD D0 01 C8 sne:iny 743 40E0 8A txa 744 40E1 20 FE 40 jsr _print 745 40E4 A5 C1 lda a0+1 746 40E6 48 pha 747 40E7 A5 C0 lda a0 748 40E9 48 pha 749 40EA 60 rts 750 .endp 751 752 ;========================================================================== 753 40EB .nowarn .proc _imprintf 754 40EB 68 pla 755 40EC AA tax 756 40ED 68 pla 757 40EE A8 tay 758 40EF E8 inx 759 40F0 D0 01 C8 sne:iny 760 40F3 8A txa 761 40F4 20 1B 41 jsr _printf 762 40F7 A5 C1 lda a0+1 763 40F9 48 pha 764 40FA A5 C0 lda a0 765 40FC 48 pha 766 40FD 60 rts 767 .endp 768 769 ;========================================================================== 770 40FE .nowarn .proc _print 771 40FE 85 C0 sta a0 772 4100 84 C1 sty a0+1 773 4102 charloop: 774 4102 A0 00 ldy #0 775 4104 B1 C0 lda (a0),y 776 4106 F0 0C beq done 777 4108 E6 C0 D0 02 E6 C1 inw a0 778 410E 20 6C 42 jsr _printf.putbyte 779 4111 4C 02 41 jmp charloop 780 4114 done: 781 4114 60 rts 782 .endp 783 784 ;========================================================================== 785 4115 .nowarn .proc _println 786 4115 20 D8 40 jsr _imprint 787 4118 9B 00 dta $9b,0 788 411A 60 rts 789 .endp 790 ;========================================================================== 791 411B .nowarn .proc _printf 792 411B 85 C0 sta a0 793 411D 84 C1 sty a0+1 794 411F A0 00 ldy #0 795 4121 84 C8 sty d0 796 4123 charloop: 797 4123 B1 C0 lda (a0),y 798 4125 F0 12 beq done 799 4127 E6 C0 D0 02 E6 C1 inw a0 800 412D C9 25 cmp #'%' 801 412F F0 09 beq special 802 4131 escaped: 803 4131 20 6C 42 jsr putbyte 804 4134 nextchar: 805 4134 A0 00 ldy #0 806 4136 4C 23 41 jmp charloop 807 4139 done: 808 4139 60 rts 809 413A special: 810 413A E6 C8 inc d0 811 413C A6 C8 ldx d0 812 413E B1 C0 lda (a0),y 813 4140 E6 C0 D0 02 E6 C1 inw a0 814 4146 C9 64 cmp #'d' 815 4148 D0 47 bne notdec 816 414A 98 tya 817 414B 84 C2 sty a1 818 414D A0 06 ldy #6 819 414F 78 sei 820 4150 F8 sed 821 4151 decloop1: 822 4151 36 C8 rol d0,x 823 4153 65 C2 adc a1 824 4155 85 C2 sta a1 825 4157 88 dey 826 4158 D0 F7 bne decloop1 827 415A 84 C3 sty a1+1 828 415C A0 02 ldy #2 829 415E decloop2: 830 415E 36 C8 rol d0,x 831 4160 65 C2 adc a1 832 4162 85 C2 sta a1 833 4164 26 C3 rol a1+1 834 4166 88 dey 835 4167 D0 F5 bne decloop2 836 4169 D8 cld 837 416A 58 cli 838 416B A5 C3 lda a1+1 839 416D F0 0F beq decdigit2 840 416F AA tax 841 4170 BD F9 43 lda _hexdig,x 842 4173 20 6C 42 jsr putbyte 843 4176 A5 C2 lda a1 844 4178 20 56 42 jsr puthex 845 417B 4C 34 41 jmp nextchar 846 417E decdigit2: 847 417E A5 C2 lda a1 848 4180 C9 10 cmp #$10 849 4182 90 06 bcc decdigit1 850 4184 20 56 42 jsr puthex 851 4187 4C 34 41 jmp nextchar 852 418A decdigit1: 853 418A AA tax 854 418B BD F9 43 lda _hexdig,x 855 418E 4C 31 41 jmp escaped 856 857 4191 notdec: 858 4191 C9 78 cmp #'x' 859 4193 D0 08 bne nothex 860 4195 B5 C8 lda d0,x 861 4197 20 56 42 jsr puthex 862 419A 4C 34 41 jmp nextchar 863 864 419D nothex: 865 419D C9 58 cmp #'X' 866 419F D0 11 bne nothexword 867 41A1 E6 C8 inc d0 868 41A3 B5 C9 lda d1,x 869 41A5 20 56 42 jsr puthex 870 41A8 A6 C8 ldx d0 871 41AA B5 C7 lda d0-1,x 872 41AC 20 56 42 jsr puthex 873 41AF 4C 34 41 jmp nextchar 874 875 41B2 nothexword: 876 41B2 C9 44 cmp #'D' 877 41B4 D0 5F bne notdecword 878 879 41B6 A0 08 ldy #8 880 41B8 A9 00 lda #0 881 41BA 85 C2 sta a1 882 41BC 85 C3 sta a1+1 883 41BE 85 C4 sta a2 884 41C0 78 sei 885 41C1 F8 sed 886 41C2 decword1: 887 41C2 36 C9 rol d1,x 888 41C4 A5 C2 lda a1 889 41C6 65 C2 adc a1 890 41C8 85 C2 sta a1 891 41CA A5 C3 lda a1+1 892 41CC 65 C3 adc a1+1 893 41CE 85 C3 sta a1+1 894 41D0 88 dey 895 41D1 D0 EF bne decword1 896 897 41D3 A0 08 ldy #8 898 41D5 decword2: 899 41D5 36 C8 rol d0,x 900 41D7 A5 C2 lda a1 901 41D9 65 C2 adc a1 902 41DB 85 C2 sta a1 903 41DD A5 C3 lda a1+1 904 41DF 65 C3 adc a1+1 905 41E1 85 C3 sta a1+1 906 41E3 A5 C4 lda a2 907 41E5 65 C4 adc a2 908 41E7 85 C4 sta a2 909 41E9 88 dey 910 41EA D0 E9 bne decword2 911 41EC D8 cld 912 41ED 58 cli 913 914 41EE AA tax 915 41EF F0 10 beq decword3 916 41F1 20 4B 42 jsr puthexcond 917 41F4 A5 C3 lda a1+1 918 41F6 20 56 42 jsr puthex 919 41F9 A5 C2 lda a1 920 41FB 20 56 42 jsr puthex 921 41FE 4C 34 41 jmp nextchar 922 923 4201 decword3: 924 4201 A5 C3 lda a1+1 925 4203 F0 08 beq decword4 926 4205 A5 C2 lda a1 927 4207 20 56 42 jsr puthex 928 420A 4C 34 41 jmp nextchar 929 930 420D decword4: 931 420D A5 C2 lda a1 932 420F 20 56 42 jsr puthex 933 4212 4C 34 41 jmp nextchar 934 935 4215 notdecword: 936 4215 C9 63 cmp #'c' 937 4217 D0 0A bne notchar 938 4219 E6 C8 inc d0 939 421B B5 C8 lda d0,x 940 421D 20 6C 42 jsr putbyte 941 4220 4C 34 41 jmp nextchar 942 943 4223 notchar: 944 4223 C9 73 cmp #'s' 945 4225 D0 1F bne notstr 946 947 4227 E6 C8 inc d0 948 4229 B5 C8 lda d0,x 949 422B 85 C2 sta a1 950 422D B5 C9 lda d0+1,x 951 422F 85 C3 sta a1+1 952 953 4231 strloop: 954 4231 A0 00 ldy #0 955 4233 B1 C2 lda (a1),y 956 4235 F0 0C beq strdone 957 4237 20 72 42 jsr putbyte2 958 423A E6 C2 D0 02 E6 C3 inw a1 959 4240 4C 31 42 jmp strloop 960 961 4243 strdone: 962 4243 4C 34 41 jmp nextchar 963 964 4246 notstr: 965 4246 C6 C8 dec d0 966 4248 4C 31 41 jmp escaped 967 968 424B puthexcond: 969 424B C9 10 cmp #$10 970 424D B0 07 bcs puthex 971 424F AA tax 972 4250 BD F9 43 lda _hexdig,x 973 4253 4C 6C 42 jmp putbyte 974 4256 puthex: 975 4256 48 pha 976 4257 4A lsr 977 4258 4A lsr 978 4259 4A lsr 979 425A 4A lsr 980 425B AA tax 981 425C BD F9 43 lda _hexdig,x 982 425F 20 6C 42 jsr putbyte 983 4262 68 pla 984 4263 29 0F and #$0f 985 4265 AA tax 986 4266 BD F9 43 lda _hexdig,x 987 4269 4C 6C 42 jmp putbyte 988 989 426C putbyte: 990 426C AA tax 991 426D 20 72 42 jsr putbyte2 992 4270 8A txa 993 4271 60 rts 994 995 4272 putbyte2: 996 4272 6C 89 02 jmp (_vputchar) 997 .endp 998 999 ;========================================================================== 1000 4275 .nowarn .proc _jam 1001 4275 loop: 1002 4275 4C 75 42 jmp loop 1003 .endp 1004 1005 ;========================================================================== 1006 4278 .nowarn .proc _waitVCount 1007 4278 CD 0B D4 D0 FB cmp:rne vcount 1008 427D 60 rts 1009 .endp 1010 1011 ;========================================================================= 1012 427E .nowarn .proc _imTestInit 1013 427E 68 pla 1014 427F 85 C0 sta a0 1015 4281 A8 tay 1016 4282 68 pla 1017 4283 85 C1 sta a0+1 1018 1019 4285 E6 C0 D0 02 E6 C1 inw a0 1020 1021 428B A9 00 85 C2 mva #0 a1 1022 428F A5 C1 85 C3 mva a0+1 a1+1 1023 4293 skiploop: 1024 4293 B1 C2 lda (a1),y 1025 4295 F0 08 beq skipdone 1026 4297 C8 iny 1027 4298 D0 02 E6 C3 sne:inc a1+1 1028 429C 4C 93 42 jmp skiploop 1029 429F skipdone: 1030 429F A5 C3 lda a1+1 1031 42A1 48 pha 1032 42A2 98 tya 1033 42A3 48 pha 1034 42A4 A5 C0 lda a0 1035 42A6 A4 C1 ldy a0+1 1036 42A8 4C AB 42 jmp _testInit 1037 .endp 1038 1039 ;========================================================================= 1040 42AB .nowarn .proc _testInit 1041 .ifdef STANDALONE 1042 42AB 48 pha 1043 42AC 98 tya 1044 42AD 48 pha 1045 1046 .ifdef SYS800 1047 ;MaxFlash carts run executables with E: closed. Check for this and 1048 ;reopen it if necessary. 1049 lda ichid 1050 bpl iocb0_open 1051 1052 ;reopen IOCB 0 1053 mva #$03 iccmd 1054 mwa #e_name icbal 1055 ldx #0 1056 stx icax1 1057 mva #$0c icax2 1058 jsr ciov 1059 1060 iocb0_open: 1061 .endif 1062 1063 42AE 20 00 40 jsr _crt0init 1064 1065 42B1 68 pla 1066 42B2 A8 tay 1067 42B3 68 pla 1068 .endif 1069 1070 42B4 20 FE 40 jsr _print 1071 42B7 20 D8 40 jsr _imprint 1072 42BA 2E 2E 2E 00 dta c"...",0 1073 1074 .ifdef STANDALONE 1075 42BE A9 CF 8D 86 02 A9 + mwa #_testEnd _exitTest 1076 .else 1077 :10 nop 1078 .endif 1079 1080 42C8 60 rts 1081 1082 42C9 msg: 1083 42C9 2E 2E 2E 00 dta c"...",0 1084 42CD e_name: 1085 42CD 45 9B dta 'E',$9B 1086 .endp 1087 1088 ;========================================================================= 1089 42CF .nowarn .proc _testEnd 1090 .ifdef SYSSAP 1091 .ifdef STANDALONE 1092 42CF 4C D3 44 jmp _sap_testEnd 1093 .else 1094 jmp _jam 1095 .endif 1096 .else 1097 .ifdef SYS5200 1098 jmp _jam 1099 .else 1100 ;wait for key 1101 sei 1102 lda #0 1103 sta nmien 1104 sta irqen 1105 mva #3 skctl 1106 mva #$40 irqen 1107 bit:rne irqst 1108 1109 ;initiate soft reset 1110 jmp ($fffc) 1111 .endif 1112 .endif 1113 .endp 1114 1115 ;========================================================================= 1116 42D2 .nowarn .proc _testRestore 1117 42D2 D8 cld 1118 42D3 08 php 1119 42D4 78 sei 1120 1121 ;check if the screen is off; if so, make sure we kill DLIs 1122 42D5 AD 81 02 lda _scrnOff 1123 42D8 F0 08 beq scrnOK 1124 1125 42DA A9 00 lda #0 1126 42DC EE 0A D4 inc wsync 1127 42DF 8D 0E D4 sta nmien 1128 1129 42E2 scrnOK: 1130 1131 42E2 AD 32 02 8D 0F D2 mva sskctl skctl 1132 1133 .ifdef SYSSAP 1134 ;kill PIA port A interrupt 1135 42E8 A9 3C 8D 02 D3 mva #$3c pactl 1136 1137 ;force kernel ROMs back _out_ 1138 42ED A9 38 8D 03 D3 mva #$38 pbctl 1139 42F2 A9 FF 8D 01 D3 mva #$ff portb 1140 42F7 A9 3C 8D 03 D3 mva #$3c pbctl 1141 42FC A9 82 8D 01 D3 mva #$82 portb 1142 .endif 1143 1144 .ifdef SYS5200 1145 mva #$00 prior 1146 mva #$f8 chbase 1147 mva #$02 chactl 1148 mva #$04 consol 1149 .endif 1150 1151 .ifdef SYS800 1152 ;kill PIA port A interrupt 1153 mva #$3c pactl 1154 1155 ;force kernel ROMs back in 1156 mva #$38 pbctl 1157 mva #$00 portb 1158 mva #$3c pbctl 1159 mva #$83 portb 1160 1161 ;kill OS timer 1 1162 ldx #$ff 1163 stx wsync 1164 stx cdtmv1 1165 inx 1166 stx cdtmv1 1167 stx cdtmv1+1 1168 .endif 1169 1170 4301 28 plp 1171 4302 20 52 40 jsr _interruptsOn 1172 4305 20 70 40 jsr _screenOn 1173 4308 20 B7 40 jsr _resetAV 1174 1175 ;unmask interrupts 1176 430B 58 cli 1177 430C 60 rts 1178 .endp 1179 1180 ;========================================================================= 1181 430D .nowarn .proc _testPassed 1182 430D 20 D2 42 jsr _testRestore 1183 1184 4310 20 D8 40 jsr _imprint 1185 4313 50 61 73 73 9B 00 dta c"Pass",$9b,0 1186 1187 4319 AE 88 02 ldx _exitTestS 1188 431C 9A txs 1189 431D A0 00 ldy #0 1190 431F 6C 86 02 jmp (_exitTest) 1191 .endp 1192 1193 ;========================================================================= 1194 4322 .nowarn .proc _testFailed 1195 4322 20 D2 42 jsr _testRestore 1196 1197 4325 20 D8 40 jsr _imprint 1198 4328 46 41 49 4C 2E 9B + dta c"FAIL.",$9b,0 1199 1200 432F nomsgentry: 1201 432F 68 pla 1202 4330 AA tax 1203 4331 68 pla 1204 4332 A8 tay 1205 4333 E8 inx 1206 4334 D0 01 C8 sne:iny 1207 4337 8A txa 1208 4338 20 1B 41 jsr _printf 1209 433B 20 15 41 jsr _println 1210 1211 433E AE 88 02 ldx _exitTestS 1212 4341 9A txs 1213 4342 A0 80 ldy #$80 1214 4344 6C 86 02 jmp (_exitTest) 1215 1216 4347 msg2: 1217 4347 9B 00 dta $9b,0 1218 .endp 1219 1220 ;========================================================================= 1221 4349 .nowarn .proc _testFailed2 1222 4349 20 D2 42 jsr _testRestore 1223 434C 4C 2F 43 jmp _testFailed.nomsgentry 1224 .endp 1225 1226 ;========================================================================= 1227 434F .nowarn .proc _testSkipped 1228 434F 20 D2 42 jsr _testRestore 1229 1230 4352 20 D8 40 jsr _imprint 1231 4355 53 6B 69 70 70 65 + dta c"Skipped",$9b,0 1232 1233 435E 68 pla 1234 435F AA tax 1235 4360 68 pla 1236 4361 A8 tay 1237 4362 E8 inx 1238 4363 D0 01 C8 sne:iny 1239 4366 8A txa 1240 4367 20 1B 41 jsr _printf 1241 1242 436A 20 15 41 jsr _println 1243 1244 436D AE 88 02 ldx _exitTestS 1245 4370 9A txs 1246 4371 A0 40 ldy #$40 1247 4373 6C 86 02 jmp (_exitTest) 1248 .endp 1249 1250 ;========================================================================== 1251 ; _loadSeg() 1252 ; 1253 ; Module loader. 1254 ; 1255 ; X = index of module to load 1256 ; 1257 .ifdef SEGS_MIN_MEM 1258 .nowarn .proc _loadSeg 1259 ;get starting sector 1260 mva segaddrlo,x daux1 1261 mva segaddrhi,x daux2 1262 1263 ;get ending sector 1264 lda segaddrlo+1,x 1265 sub daux1 1266 sta d7 1267 1268 ;setup sector load command and relocation 1269 mva #'R' dcomnd 1270 mva #1 dunit 1271 lda #$00 1272 sta dbuflo 1273 sta a0 1274 sta runad+1 1275 lda #$0b 1276 sta dbufhi 1277 sta a0+1 1278 1279 ;preload first two sectors 1280 jsr step_sector 1281 relocloop: 1282 ;load starting address 1283 mva (a0),y a1 1284 iny:sne:jsr step_sector 1285 mva (a0),y a1+1 1286 iny:sne:jsr step_sector 1287 1288 ;skip $ffff words 1289 lda a1 1290 and a1+1 1291 cmp #$ff 1292 beq relocloop 1293 1294 ;load ending address 1295 mva (a0),y a2 1296 iny:sne:jsr step_sector 1297 mva (a0),y a2+1 1298 iny:sne:jsr step_sector 1299 inw a2 1300 1301 mwa #definit initad 1302 1303 ;copy data (slow, but oh well) 1304 ldx #0 1305 copyloop: 1306 lda (a0),y 1307 sta (a1,x) 1308 iny:sne:jsr step_sector 1309 inw a1 1310 lda a1 1311 cmp a2 1312 bne copyloop 1313 lda a1+1 1314 cmp a2+1 1315 bne copyloop 1316 1317 ;init a segment 1318 jsr doinit 1319 1320 ;check if we're done 1321 lda runad+1 1322 beq relocloop 1323 rts 1324 1325 doinit: 1326 jmp (initad) 1327 1328 step_sector: 1329 lda d7 1330 beq no_sectors_left 1331 jsr dskinv 1332 dec d7 1333 inw daux1 1334 lda dbuflo 1335 eor #$80 1336 sta dbuflo 1337 bne step_sector 1338 no_sectors_left: 1339 ldy #0 1340 ldx #0 1341 definit: 1342 rts 1343 .endp 1344 .else 1345 4376 .nowarn .proc _loadSeg 1346 .ifdef SEGS_IN_ROM 1347 4376 8E 8D 02 stx _lastMod 1348 4379 60 rts 1349 .else 1350 ;get starting sector 1351 mva segaddrlo,x daux1 1352 mva segaddrhi,x daux2 1353 1354 ;get ending sector 1355 mva segaddrlo+1,x a0 1356 mva segaddrhi+1,x a0+1 1357 1358 ;load sectors starting at $4000 1359 sectorloop: 1360 mva #'R' dcomnd 1361 mva #1 dunit 1362 mwa #$4000 dbuflo 1363 1364 jsr dskinv 1365 tya 1366 bmi sectorloop 1367 1368 lda #$80 1369 eor dbuflo 1370 sta dbuflo 1371 sne:inc dbufhi 1372 1373 inc daux1 1374 sne:inc daux2 1375 1376 lda daux1 1377 cmp a0 1378 bne sectorloop 1379 lda daux2 1380 cmp a0+1 1381 bne sectorloop 1382 rts 1383 .endif 1384 .endp 1385 .endif 1386 1387 ;========================================================================== 1388 ; _runSeg() 1389 ; 1390 ; Module relocator and executor. 1391 ; 1392 ; The last segment loaded by _loadSeg() is relocated and executed. 1393 ; 1394 1395 .ifdef SEGS_MIN_MEM 1396 1397 ;----------------------------------------------- 1398 ; Minimum memory implementation. 1399 .nowarn .proc _runSeg 1400 jmp (runad) 1401 .endp 1402 1403 .else 1404 1405 ;----------------------------------------------- 1406 437A .nowarn .proc _runSeg 1407 1408 ;begin relocation 1409 437A A9 93 8D E0 02 A9 + mwa #relocloop runad 1410 1411 .ifdef SEGS_IN_ROM 1412 4384 AE 8D 02 ldx _lastMod 1413 4387 BD 00 BF 85 C0 mva segaddrlo,x a0 1414 438C BD 80 BF 85 C1 mva segaddrhi,x a0+1 1415 .else 1416 mwa #$4000 a0 1417 .endif 1418 1419 .ifndef SEGS_LZPACK 1420 1421 ;==== uncompressed version 1422 1423 4391 A0 00 ldy #0 1424 4393 relocloop: 1425 ;load starting address 1426 4393 B1 C0 85 C2 mva (a0),y a1 1427 4397 E6 C0 D0 02 E6 C1 inw a0 1428 439D B1 C0 85 C3 mva (a0),y a1+1 1429 43A1 E6 C0 D0 02 E6 C1 inw a0 1430 1431 ;skip $ffff words 1432 43A7 A5 C2 lda a1 1433 43A9 25 C3 and a1+1 1434 43AB C9 FF cmp #$ff 1435 43AD F0 E4 beq relocloop 1436 1437 ;load ending address 1438 43AF B1 C0 85 C4 mva (a0),y a2 1439 43B3 E6 C0 D0 02 E6 C1 inw a0 1440 43B9 B1 C0 85 C5 mva (a0),y a2+1 1441 43BD E6 C0 D0 02 E6 C1 inw a0 1442 43C3 E6 C4 D0 02 E6 C5 inw a2 1443 1444 ;copy data (slow, but oh well) 1445 43C9 copyloop: 1446 43C9 B1 C0 lda (a0),y 1447 43CB 91 C2 sta (a1),y 1448 43CD E6 C0 D0 02 E6 C1 inw a0 1449 43D3 E6 C2 D0 02 E6 C3 inw a1 1450 43D9 A5 C2 lda a1 1451 43DB C5 C4 cmp a2 1452 43DD D0 EA bne copyloop 1453 43DF A5 C3 lda a1+1 1454 43E1 C5 C5 cmp a2+1 1455 43E3 D0 E4 bne copyloop 1456 1457 ;init a segment 1458 43E5 A9 F8 8D E2 02 A9 + mwa #definit initad 1459 43EF 20 F5 43 jsr doinit 1460 43F2 6C E0 02 jmp (runad) 1461 1462 43F5 doinit: 1463 43F5 6C E2 02 jmp (initad) 1464 1465 43F8 definit: 1466 43F8 60 rts 1467 1468 .else 1469 1470 ;==== compressed version 1471 ; 1472 ;loader: 1473 ; a3 destination 1474 ; d6/d7 segment end address 1475 ; 1476 ;decompressor: 1477 ; a0 raw source stream 1478 ; a1 run source pointer 1479 ; a2 window pointer ($1000-1fff) 1480 ; d0 literal/run flag bits 1481 ; d1 remaining flag bits shifter 1482 ; d2 run length counter 1483 ; d3 temporary 1484 ; d4 superflag bits 1485 ; d5 superflag shifter 1486 1487 lda #0 1488 sta d0 1489 sta d1 1490 sta d2 1491 sta d5 1492 sta a2 1493 lda #$10 1494 sta a2+1 1495 relocloop: 1496 ldy #0 1497 ;load starting address 1498 jsr getbyte 1499 sta a3 1500 jsr getbyte 1501 sta a3+1 1502 1503 ;skip $ffff words 1504 and a3 1505 cmp #$ff 1506 beq relocloop 1507 1508 ;load ending address 1509 jsr getbyte 1510 sta d6 1511 jsr getbyte 1512 sta d7 1513 inw d6 1514 1515 ;copy data (slow, but oh well) 1516 copyloop: 1517 jsr getbyte 1518 sta (a3),y 1519 inw a3 1520 lda a3 1521 cmp d6 1522 bne copyloop 1523 lda a3+1 1524 cmp d7 1525 bne copyloop 1526 1527 ;init a segment 1528 mwa #definit initad 1529 jsr doinit 1530 jmp (runad) 1531 1532 doinit: 1533 jmp (initad) 1534 1535 getbyte: 1536 ;check if we have a run in progress 1537 lda d2 1538 bne getrunbyte 1539 1540 ;check if we need to reload flag bits 1541 asl d1 1542 bne havebits 1543 1544 ;check if we need to reload superflag bits 1545 asl d5 1546 bne havesuperbits 1547 1548 ;load next superflag byte 1549 jsr getrawbyte 1550 sta d4 1551 lda #$7f 1552 sta d5 1553 1554 havesuperbits: 1555 ;pull next superflag and check if it's all literals (0) 1556 asl d4 1557 bcc all_literals 1558 1559 ;nope... read next byte as flags byte 1560 jsr getrawbyte 1561 sta d0 1562 1563 all_literals: 1564 lda #$7f 1565 sta d1 1566 havebits: 1567 asl d0 1568 bcs isrun 1569 1570 ;store byte into window 1571 jsr getrawbyte 1572 jmp putwinbyte 1573 1574 isrun: 1575 ;load offset/run bytes 1576 jsr getrawbyte 1577 sta d3 1578 jsr getrawbyte 1579 sta d2 1580 1581 ;compute run source from current position and offset 1582 lda a2 1583 clc 1584 sbc d3 1585 sta a1 1586 lda a2+1 1587 sbc d2 1588 and #$0f 1589 ora #$10 1590 sta a1+1 1591 1592 ;compute length and stash run length 1593 lda d2 1594 lsr 1595 lsr 1596 lsr 1597 lsr 1598 add #3 1599 sta d2 1600 getrunbyte: 1601 dec d2 1602 ldy #0 1603 lda (a1),y 1604 inc a1 1605 bne putwinbyte 1606 inc a1+1 1607 pha 1608 lda a1+1 1609 and #$0f 1610 ora #$10 1611 sta a1+1 1612 pla 1613 jmp putwinbyte 1614 1615 getrawbyte: 1616 lda (a0),y 1617 inw a0 1618 rts 1619 1620 putwinbyte: 1621 sta (a2),y 1622 inc a2 1623 seq:rts 1624 ldy a2+1 1625 iny 1626 cpy #$20 1627 sne:ldy #$10 1628 sty a2+1 1629 ldy #0 1630 definit: 1631 rts 1632 1633 .endif 1634 .endp 1635 .endif 1636 1637 ;========================================================================== 1638 43F9 30 31 32 33 34 35 + _hexdig dta c"0123456789ABCDEF" 1639 1640 ;========================================================================== 1641 ; segment table 1642 ; 1643 .ifndef SYS800 1644 = BF00 segaddrlo equ $bf00 1645 = BF80 segaddrhi equ $bf80 1646 .else 1647 segaddrlo equ $1900 1648 segaddrhi equ $1980 1649 .endif 1650 1651 = 0900 _veronicaLaunch = $0900 1652 1653 ;========================================================================== 1654 ; platform-specific library 1655 ; 1656 .ifdef SYS5200 1657 icl 'lib5200.s' 1658 .endif 1659 .ifdef SYSSAP 1660 4409 icl 'libsap.s' Source: libsap.s 1 ; Altirra Acid800 test suite 2 ; Copyright (C) 2010 Avery Lee, All Rights Reserved. 3 ; 4 ; Permission is hereby granted, free of charge, to any person obtaining a copy 5 ; of this software and associated documentation files (the "Software"), to deal 6 ; in the Software without restriction, including without limitation the rights 7 ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 ; copies of the Software, and to permit persons to whom the Software is 9 ; furnished to do so, subject to the following conditions: 10 ; 11 ; The above copyright notice and this permission notice shall be included in 12 ; all copies or substantial portions of the Software. 13 ; 14 ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 ; SOFTWARE. 21 22 ;========================================================================== 23 = 00E0 _disp_adr equ $e0 24 = 1000 _disp_buffer equ $1000 25 26 ;========================================================================== 27 4409 .nowarn .proc _crt0init_sap 28 4409 78 sei 29 30 .ifdef SAPBOOTER 31 ;We're coming in hot from the Atari OS, so we need to shut everything down. 32 lda #0 33 sta nmien 34 sta irqen 35 sta pokmsk 36 sta dmactl 37 38 ;bank out all ROMs 39 mva #$38 pbctl 40 mva #$ff portb 41 mva #$3c pbctl 42 mva #$82 portb 43 .endif 44 45 ;revector NMI and IRQ (NMI is just in case) 46 440A A9 2C 8D FA FF A9 + mwa #_sys_nmi $fffa 47 4414 A9 30 8D FE FF A9 + mwa #_sys_irq1 $fffe 48 441E A9 34 8D 16 02 A9 + mwa #_sys_irq2 vimirq 49 50 ;re-enable interrupts 51 4428 58 cli 52 53 4429 4C 41 44 jmp _disp_init 54 .endp 55 56 ;========================================================================== 57 442C .nowarn .proc _sys_nmi 58 ;there should not be any NMIs when we are running under SAP 59 442C 8D 0F D4 sta nmires 60 442F 40 rti 61 .endp 62 63 ;========================================================================== 64 4430 .nowarn .proc _sys_irq1 65 4430 D8 cld 66 4431 6C 16 02 jmp (vimirq) 67 .endp 68 69 ;========================================================================== 70 4434 .nowarn .proc _sys_irq2 71 4434 48 pha 72 4435 A9 00 8D 0E D2 mva #0 irqen 73 443A A5 10 8D 0E D2 mva pokmsk irqen 74 443F 68 pla 75 4440 40 rti 76 .endp 77 78 ;========================================================================== 79 4441 .nowarn .proc _disp_init 80 4441 A9 00 85 E0 A9 10 + mwa #_disp_buffer _disp_adr 81 4449 A9 54 8D 89 02 A9 + mwa #_disp_putchar _vputchar 82 4453 60 rts 83 .endp 84 85 ;========================================================================== 86 4454 .nowarn .proc _disp_putchar 87 4454 A0 00 ldy #0 88 4456 91 E0 sta (_disp_adr),y 89 4458 E6 E0 inc _disp_adr 90 445A F0 01 60 seq:rts 91 445D A5 E1 lda _disp_adr+1 92 445F 18 clc 93 4460 69 01 adc #1 94 4462 29 F7 and #$f7 95 4464 85 E1 sta _disp_adr+1 96 4466 60 rts 97 .endp 98 99 ;========================================================================== 100 4467 .nowarn .proc _sys_beepsuccess 101 4467 A9 15 lda #21 102 103 4469 A2 0D ldx #13 104 446B 20 93 44 jsr _sys_beepplay 105 106 446E A2 02 ldx #2 107 4470 20 CA 44 jsr _sys_beepwait 108 109 4473 A2 05 ldx #5 110 4475 20 93 44 jsr _sys_beepplay 111 112 4478 A2 02 ldx #2 113 447A 20 CA 44 jsr _sys_beepwait 114 115 447D A2 05 ldx #5 116 447F 20 93 44 jsr _sys_beepplay 117 118 4482 A2 07 ldx #7 119 4484 20 CA 44 jsr _sys_beepwait 120 121 4487 A2 1E ldx #30 122 4489 4C 93 44 jmp _sys_beepplay 123 .endp 124 125 ;========================================================================== 126 448C .nowarn .proc _sys_beepfailure 127 448C A9 FF lda #255 128 129 448E A2 64 ldx #100 130 4490 4C 93 44 jmp _sys_beepplay 131 .endp 132 133 ;========================================================================== 134 ; A = pitch 135 ; X = duration 136 4493 .nowarn .proc _sys_beepplay 137 4493 48 pha 138 4494 8D 00 D2 sta audf1 139 4497 A0 AC 8C 01 D2 mvy #$ac audc1 140 449C 8D 09 D2 sta stimer 141 449F A9 03 8D 0F D2 mva #$03 skctl 142 44A4 A9 01 8D 08 D2 mva #$01 audctl 143 44A9 loop: 144 44A9 48 pha 145 44AA 20 89 40 jsr _waitFrame 146 44AD 68 pla 147 44AE C0 A1 cpy #$a1 148 44B0 F0 09 beq nodescent 149 44B2 18 clc 150 44B3 69 20 adc #$20 151 44B5 90 04 bcc nodescent 152 44B7 88 dey 153 44B8 8C 01 D2 sty audc1 154 44BB nodescent: 155 44BB CA dex 156 44BC D0 EB bne loop 157 44BE A9 FF 8D 00 D2 mva #$ff audf1 158 44C3 A9 00 8D 01 D2 mva #0 audc1 159 44C8 68 pla 160 44C9 60 rts 161 .endp 162 163 ;========================================================================== 164 ; X = duration 165 44CA .nowarn .proc _sys_beepwait 166 44CA 48 pha 167 44CB loop: 168 44CB 20 89 40 jsr _waitFrame 169 44CE CA dex 170 44CF D0 FA bne loop 171 44D1 68 pla 172 44D2 60 rts 173 .endp 174 175 ;========================================================================== 176 .ifdef STANDALONE 177 44D3 .nowarn .proc _sap_testEnd 178 44D3 10 06 bpl passed 179 44D5 20 8C 44 jsr _sys_beepfailure 180 44D8 4C 75 42 jmp _jam 181 44DB passed: 182 44DB 20 67 44 jsr _sys_beepsuccess 183 44DE 4C 75 42 jmp _jam 184 .endp 185 .endif 1661 .endif 1662 1663 ;========================================================================== 1664 .ifndef STANDALONE 1665 .ifdef SYS5200 1666 opt o+ 1667 .else 1668 opt h+o+ 1669 .endif 1670 .endif 27 28 44E1 org $2000 29 30 2000 main: 31 2000-2196> A0 21 ldy #>testname 32 2002 A9 83 lda # 00 20 run $2000 104 end