POPBOOT0.S (11353B)
1 * boot 2 org = $800 3 lst off 4 xc off 5 6 REDFLAG79 = $23B ; in aux mem! 7 8 *------------------------------- 9 * $800 TS (0,0) boot sector 10 11 SLOT = $2b 12 sector = $50 13 14 text = $fb2f 15 home = $fc58 16 vtab = $FB5B 17 cout = $FDF0 18 normal = $fe84 19 pr0 = $fe93 20 in0 = $fe89 21 22 *------------------------------- 23 24 smclo = $4E 25 smchi = $4F 26 27 rw18 = $d000 28 29 slot = $fd 30 track = $fe 31 lastrack = $ff 32 33 dum $00 34 35 dest ds 2 36 source ds 2 37 endsourc ds 2 38 39 dend 40 41 *------------------------------------------------- 42 43 org org 44 45 hex 01 46 47 entry lda #$60 48 sta entry 49 50 lda #MAKEBIT 51 sta smclo 52 53 ldx #$ff 54 stx $4fb 55 stx $3f3 56 stx $3f4 57 stx $7831 58 stx $c000 ;80store off 59 stx $c002 ;RAMRD main 60 stx $9fd8 61 stx $c004 ;RAMWRT main 62 stx $c00c ;80col off 63 stx $c00e ;Altcharset off 64 stx $c081 ;write RAM, read ROM (2nd 4k bank) 65 txs 66 jsr text 67 jsr home 68 jsr normal 69 jsr pr0 70 sta $DF35 71 jsr in0 72 stx $8492 73 74 ldx SLOT 75 txa 76 lsr 77 lsr 78 lsr 79 lsr 80 ora #$c0 81 sta :rdsect+2 82 lda #$0f 83 sta sector 84 85 :0 ldy sector 86 lda skewtbl,y 87 sta $3d 88 lda sectaddr,y 89 beq :1 90 sta $27 91 92 inc $9fd8 93 94 :rdsect jsr $005c 95 :1 dec sector 96 bne :0 97 98 beq decode 99 100 skewtbl hex 00,0d,0b,09,07,05,03,01 101 hex 0e,0c,0a,08,06,04,02,0f 102 103 sectaddr hex 00,09,0a,0b,00,0c,0d,0e 104 hex 30,31,32,33,34,10,11,2f 105 106 decode ldx #14 107 :loop lda sectaddr,x 108 beq :nope 109 110 sta :smc0+2 111 sta :smc1+2 112 113 ldy #0 114 :loop1 115 :smc0 lda $FF00,y 116 eor $2F00,y 117 :smc1 sta $FF00,y 118 eor $7831 ;bogus garbage 119 sta $7831 ; " " " " 120 sta $3C 121 iny 122 bne :loop1 123 124 :nope dex 125 bpl :loop 126 127 ldx SLOT 128 129 stage2 stx slot 130 131 jsr check128k ;check for 128K memory 132 133 jsr moverw18 ;& move RW18 to D000 134 135 lda #0 136 sta lastrack 137 138 jsr rw18 139 hex 07,a9 ;Bbund ID byte 140 141 jsr rw18 142 hex 00,01,00 ;drive 1 on 143 144 jsr rw18 ;seek track 1 145 hex 02,00,01 146 147 * load & run stage 3 boot 148 * from drive 1 149 150 jsr rw18 151 hex c3,ee 152 153 jmp $ee00 154 155 *------------------------------------------------- 156 * Check for AUX memory routine 157 158 CHECKER lda #$EE 159 sta $C005 160 lda #>MAKEBIT 161 sta smchi 162 sta $C003 163 sta $0800 164 lda $0C00 165 cmp #$EE 166 bne :0 167 asl $0C00 168 lda $0800 169 cmp $0C00 170 beq :1 171 :0 clc 172 :1 sta $C004 173 sta $C002 174 rts 175 176 CHECKEND = *-CHECKER 177 178 *------------------------------------------------- 179 * 180 * Check to make sure //c or //e 181 * with 128k 182 * 183 *------------------------------- 184 185 hex 34 186 hex 55 187 hex 99 188 189 check128k 190 sta $c081 191 192 lda $FBB3 ;Apple // family ID byte 193 cmp #6 194 bne NOT128K ;Must be e/c/GS 195 196 bit $C017 197 bmi NOT128K 198 199 ldx #CHECKEND 200 :0 lda CHECKER,X 201 sta $180,X 202 dex 203 bpl :0 204 205 jsr $180 206 bcs NOT128K 207 208 rts 209 210 *------------------------------- 211 * Turn off drive and display message 212 213 NOT128K ldx SLOT 214 lda $C088,X 215 216 jsr text 217 jsr home 218 lda #8 219 jsr vtab 220 221 ldy #0 222 :0 lda MEMTEXT,Y 223 beq * 224 jsr cout 225 cmp #$8D 226 bne :1 227 lda #4 228 sta $24 229 :1 iny 230 bne :0 231 232 MEMTEXT hex 8D 233 asc "REQUIRES A //C OR //E WITH 128K" 234 hex 00 235 236 *------------------------------- 237 * Move RW18 238 * d0 < 30.40 239 *------------------------------- 240 moverw18 241 bit $c08b 242 bit $c08b ;rd/wrt RAM, 1st 4k bank 243 244 lda #$d0 245 ldx #$30 246 ldy #$40 247 248 * a < x.y 249 * 20 < 40.60 means 2000 < 4000.5fffm 250 * WARNING: If x >= y, routine will wipe out 64k 251 252 movemem sta dest+1 253 stx source+1 254 sty endsourc+1 255 256 ldy #0 257 lda #$24 258 sta (smclo),y 259 sty dest 260 sty source 261 sty endsourc 262 263 :loop lda (source),y 264 sta (dest),y 265 266 iny 267 bne :loop 268 269 inc source+1 270 inc dest+1 271 272 lda source+1 273 cmp endsourc+1 274 bne :loop 275 276 MAKEBIT rts 277 hex FF 278 279 *------------------------------------------------- 280 * 281 * HLS APPLE COPY PROTECTION 282 * COPYRIGHT (C) 1987 HLS DUPLICATION 283 * 284 * CONTACT ROBERT FREEDMAN 408-773-1300 285 * IF THERE ARE QUESTIONS ABOUT USE OF 286 * THIS CODE 287 * 288 * EXIT clc IF A O K 289 * sec IF PIRATE 290 * 291 *------------------------------------------------- 292 293 OBJSCT = $07 ;PHYSICAL SECTOR # 294 295 * ZERO PAGE 296 * IF THIS CONFLICTS WITH YOUR CODE 297 * CHANGE THE FOLLOWING ZERO PAGE 298 * LOCATIONS, OR USE THE SAVE ZERO 299 * PAGE ROUTINE 300 301 HDRC = $F0 302 HDRS = HDRC+1 303 HDRT = HDRC+2 304 HDRV = HDRC+3 HEADER SECTOR 305 LSRETRY = HDRC+4 ;NIB READ RETRIES 306 PRETRY = HDRC+5 ;OBJSCT RETRIES 307 NPTR = HDRC+6 308 NPTRH = HDRC+7 309 MEM1 = HDRC+8 310 MEM2 = HDRC+9 311 312 *------------------------------------------------- 313 314 CheckCP 315 lda #10 316 sta LSRETRY 317 lda #>REDFLAG79 318 sta smchi 319 ldx SLOT 320 lda $C089,X 321 lda $C08E,X 322 lda #:NIBS ; !!!!! LOW BYTE 323 sta NPTR 324 lda #>:NIBS ; !!!!! HIGH BYTE 325 sta NPTRH 326 :AGAIN lda #$80 327 sta PRETRY 328 :M1 dec PRETRY 329 beq :LSFAIL 330 jsr RADR16 331 bcs :LSFAIL 332 lda HDRS 333 cmp #OBJSCT 334 bne :M1 335 336 ldy #0 337 :M2 lda $C08C,X 338 bpl :M2 339 dey 340 beq :LSFAIL 341 cmp #$D5 342 bne :M2 343 ldy #0 344 345 :M3 lda $C08C,X 346 bpl :M3 347 dey 348 beq :LSFAIL 349 cmp #$E7 350 bne :M3 351 352 :M4 lda $C08C,X 353 bpl :M4 354 cmp #$E7 355 bne :LSFAIL 356 357 :M5 lda $C08C,X 358 bpl :M5 359 cmp #$E7 360 bne :LSFAIL 361 362 lda $C08D,X 363 ldy #$10 364 bit $6 ;3 US. ( FOR //C) 365 :M6 lda $C08C,X 366 bpl :M6 367 dey 368 beq :LSFAIL 369 cmp #$EE 370 bne :M6 371 372 * NOW AT 1/2 NIBBLES 373 * 374 * INSTEAD OF COMPARING AGAINST A TABLE 375 * THE DATA READ FROM THE DISK CAN BE 376 * USED IN YOUR PROGRAM. BE CAREFUL 377 * WHEN MODIFYING THIS PART OF THE CODE. 378 * KEEP THE CYCLE COUNTS CONSTANT. 379 380 ldy #7 381 :M7 lda $C08C,X ; READ DISK DATA 382 bpl :M7 383 cmp (NPTR),Y ; COMPARE AGAINST TABLE 384 bne :LSFAIL1 385 dey 386 bpl :M7 387 bmi :GOOD 388 389 :LSFAIL jmp :LSFAIL1 390 391 * A O K 392 393 :GOOD eor #$79!$FC 394 iny 395 ldx #6 396 dex 397 sta $C000,x 398 sta (smclo),y 399 dex 400 sta $C000,x 401 eor #$ED 402 sta $239 403 eor #$23 404 sta $4E 405 406 jmp yippee 407 408 * FAILED, try again 409 410 :LSFAIL1 ldy #-1 411 tya 412 dec LSRETRY 413 beq :GOOD 414 jmp :AGAIN 415 416 :NIBS db $FC,$EE,$EE,$FC 417 db $E7,$EE,$FC,$E7 418 419 *------------------------------------------------- 420 * 421 * Read address mark 422 * 423 424 RADR16 ldy #$FD ;READ ADR HDR 425 sty MEM1 426 tya 427 eor #REDFLAG79!$FD 428 sta smclo 429 :RA1 iny 430 bne :RA2 431 inc MEM1 432 beq :RAEXIT 433 :RA2 lda $C08C,X 434 bpl :RA2 435 :RA3 cmp #$D5 436 bne :RA1 437 nop 438 :RA4 lda $C08C,X 439 bpl :RA4 440 cmp #$AA 441 bne :RA3 442 ldy #3 443 :RA5 lda $C08C,X 444 bpl :RA5 445 cmp #$96 446 bne :RA3 447 lda #0 448 :RA6 sta MEM2 449 :RA7 lda $C08C,X 450 bpl :RA7 451 rol 452 sta MEM1 453 :RA8 lda $C08C,X 454 bpl :RA8 455 and MEM1 456 sta HDRC,Y 457 eor MEM2 458 dey 459 bpl :RA6 460 tay 461 nop 462 clc 463 rts 464 465 :RAEXIT sec 466 ]rts rts 467 468 oscsh sec 469 jsr $FE1F 470 bcs * 471 472 jsr $1000 473 474 jmp ($FFFC) 475 476 *------------------------------------------------- 477 478 yippee ldx SLOT 479 lda $C061 480 bpl ]rts 481 lda $C062 482 bpl ]rts 483 lda $C000 484 bpl ]rts 485 bit $C010 486 sta :cmp+1 487 488 ldy #-3 489 :loop iny 490 iny 491 iny 492 lda :dispatch,y 493 beq ]rts 494 :cmp cmp #$11 495 bne :loop 496 497 lda :dispatch+1,y 498 sta 0 499 lda :dispatch+2,y 500 sta 1 501 502 bit $C081 503 lda $C088,x 504 505 jmp (0) 506 507 :dispatch hex FF 508 da oscsh 509 510 asc "!" 511 da rcmess 512 513 hex 8D 514 da confusion 515 516 asc "@" 517 da rotcube 518 519 asc "^" 520 da drive 521 522 db 0 523 524 *------------------------------------------------- 525 * 526 * motorcycle disk drive 527 * 528 529 drive lda $C089,x ;drive back on! 530 531 :loop lda $C087,x 532 lda $C080,x 533 jsr :delay 534 lda $C085,x 535 lda $C086,x 536 jsr :delay 537 lda $C083,x 538 lda $C084,x 539 jsr :delay 540 lda $C081,x 541 lda $C082,x 542 jsr :delay 543 jmp :loop 544 545 :delay lda #6 546 sta 0 547 548 :del2 bit $C070 549 nop 550 nop 551 bit $C064 552 bmi *-3 553 554 dec 0 555 bne :del2 556 rts 557 558 *------------------------------------------------- rotcube 559 560 mainYoffset = 46 ;(192-60)/2 561 botYoffset = 72 562 mainXoffset = 68 ;(280-144)/2 563 564 color = $E4 565 page = $E6 566 567 dum 0 568 index ds 1 569 ysave ds 1 570 yadd ds 1 571 yoffset ds 1 572 dend 573 574 *------------------------------------------------- 575 576 rotcube jsr $f3e2 ;hgr 577 jsr $f3d8 ;hgr2 578 579 lda #1 580 sta yadd 581 582 sta yoffset 583 584 * Draw on page not showing: 585 586 mainloop lda page 587 eor #$60 588 sta page 589 ldx #$7F 590 jsr draw 591 592 * If not a //c, then wait for vbl 593 594 lda $FBC0 595 beq :is2c 596 lda $C019 597 bpl *-3 598 lda $C019 599 bmi *-3 600 :is2c 601 602 * Now display that page 603 604 bit $C054 605 lda page 606 cmp #$20 607 beq *+5 608 bit $C055 609 610 * Now erase old image from last page 611 612 eor #$60 613 sta :smc0+2 614 sta :smc1+2 615 ldx #$20 616 lda #0 617 :loop tay 618 :smc0 sta $2000,y 619 :smc1 sta $2080,y 620 iny 621 bpl :smc0 622 inc :smc0+2 623 inc :smc1+2 624 dex 625 bne :loop 626 627 inc index 628 jmp mainloop 629 630 *------------------------------------------------- 631 632 draw stx color 633 634 ldy #12-1 635 :drawloop lda drawlist,y 636 sty ysave 637 638 pha 639 and #15 640 jsr getpoint 641 642 tax 643 tya 644 ldy #0 645 jsr $f457 ;plot 646 647 pla 648 lsr 649 lsr 650 lsr 651 lsr 652 jsr getpoint 653 ldx #0 654 jsr $f53a ;lineto 655 656 ldy ysave 657 dey 658 bpl :drawloop 659 660 lda yoffset 661 clc 662 adc yadd 663 bne :not0 664 665 inc yadd ;make +1 666 inc yadd 667 668 :not0 cmp #191-48-botYoffset 669 bcc :0 670 671 dec yadd ;make -1 672 dec yadd 673 674 :0 sta yoffset 675 rts 676 677 *------------------------------------------------- 678 * 679 * given a = point number, return a = xcoor, y = ycoor 680 * 681 682 getpoint tay 683 684 * Get index into tables 685 686 asl ;*16 687 asl 688 asl 689 asl 690 adc index 691 and #$3F 692 tax 693 tya 694 695 and #4 ;bottom? 696 cmp #4 697 698 * Compute ycoor 699 700 lda ydata,x 701 bcc :not_bot 702 adc #botYoffset-1 703 704 :not_bot adc yoffset 705 tay 706 707 * Compute xcoor 708 709 lda xdata,x 710 adc #mainXoffset 711 rts 712 713 *------------------------------------------------- 714 715 drawlist hex 01122330 ;draw top 716 hex 45566774 ;draw bottom 717 hex 04152637 ;draw connecting lines 718 719 xdata hex 908F8E8C8A87837F7A757069635C564F 720 hex 484039332C261F1A15100C0805030100 721 hex 0000010305080C10151A1F262C333940 722 hex 474F565C636970757A7F83878A8C8E8F 723 724 ydata hex 181A1C1E21232527282A2B2D2E2E2F2F 725 hex 2F2F2F2E2E2D2B2A28272523211E1C1A 726 hex 181513110E0C0A080705040201010000 727 hex 000000010102040507080A0C0E111315 728 729 *------------------------------------------------- confusion 730 731 dum 0 732 xr ds 1 733 yr ds 1 734 randseed ds 1 735 temp ds 1 736 dend 737 738 hgr2 = $F3D8 739 plot = $F457 740 hcolor = $F6F0 741 742 * Confusion triangle 743 744 confusion lda #$7F 745 sta $E4 ;hcolor=3 746 747 jsr hgr2 748 749 * xr=xarray(0), yr=yarray(0) 750 751 ldx xarray 752 ldy yarray 753 stx xr 754 sty yr 755 756 * Plot that dot 757 758 :loop lda $C000 759 bpl :nokey 760 bit $C010 761 cmp #$E0 762 bcc *+4 763 and #$DF 764 cmp #"C" 765 bne :nokey 766 767 :randcol jsr getrandcol 768 sta temp 769 jsr $F3F4 ;clear to that color 770 771 :randloop jsr getrandcol 772 tax 773 eor temp 774 bmi :randloop ;different hi bits 775 cpx temp ;same color 776 beq :randloop 777 778 :nokey ldy #0 779 lda xr 780 asl 781 tax 782 bcc :skip 783 iny 784 :skip lda yr 785 jsr plot 786 787 lda yr 788 ldx $E0 789 ldy $E1 790 inx 791 bne *+3 792 iny 793 jsr plot 794 795 * Get a random number between 0-2 796 797 jsr random 798 sec 799 :sub30 sbc #30 800 bcs :sub30 801 adc #30 802 sec 803 :sub3 sbc #3 804 bcs :sub3 805 adc #3 806 tax 807 808 *----------- 809 * xr stuff: 810 * determine which midpoint routine to use 811 812 lda xarray,x 813 cmp xr 814 bge :xarr_xr 815 816 * If xarray(rand) < xr then: 817 * xr = xarray + ( xr - xarray) / 2 818 819 lda xr 820 sec 821 sbc xarray,x 822 lsr 823 clc 824 adc xarray,x 825 jmp :sta_xr 826 827 * If xarray(rand) >= xr then: 828 * xr = xr + ( xarray - xr ) / 2 829 830 :xarr_xr lda xarray,x 831 sec 832 sbc xr 833 lsr 834 clc 835 adc xr 836 :sta_xr sta xr 837 838 *----------- 839 * yr stuff: 840 * determine which midpoint routine to use 841 842 lda yarray,x 843 cmp yr 844 bge :yarr_yr 845 846 * If yarray(rand) < yr then: 847 * yr = yarray + ( yr - yarray) / 2 848 849 lda yr 850 sec 851 sbc yarray,x 852 lsr 853 clc 854 adc yarray,x 855 jmp :sta_yr 856 857 * If yarray(rand) >= yr then: 858 * yr = yr + ( yarray - yr ) / 2 859 860 :yarr_yr lda yarray,x 861 sec 862 sbc yr 863 lsr 864 clc 865 adc yr 866 :sta_yr sta yr 867 868 jmp :loop 869 870 xarray db 70,139,0 871 yarray db 0,191,191 872 873 random lda randseed 874 adc #$23 875 sta randseed 876 eor $C020 ;a little randomness 877 rts 878 879 getrandcol jsr random 880 and #7 881 tax 882 jmp hcolor 883 884 *------------------------------------------------- rcmess 885 886 rcmess ldy #0 887 :0 lda :text,y 888 beq :lores 889 jsr $FDF0 890 iny 891 bne :0 892 893 :lores bit $c000 894 bpl :lores 895 896 sta $c00d ;80 col 897 sta $c001 ;80 store 898 bit $c056 899 bit $c052 900 bit $c050 901 bit $c05e ;merez 902 903 :loop lda #$FF 904 jsr :random 905 sta $30 ;color 906 907 lda #80 ;max x 908 jsr :random 909 lsr 910 tay 911 bit $c054 912 bcs *+5 913 bit $c055 914 915 lda #48 ;max y 916 jsr :random 917 918 jsr $F800 ;plot 919 920 jmp :loop 921 922 :random sta 1 923 924 lda 0 925 adc #$23 926 sta 0 927 eor $C020 928 929 cmp 1 930 bcc :ok 931 :loop2 sbc 1 932 bcs :loop2 933 adc 1 934 935 :ok rts 936 937 :text hex 8d8d 938 asc "8/25/89",8d8d8d 939 asc "Robert!",8d8d8d 940 asc "Jordan and Roland wish you the very",8d8d 941 asc "Brightest College Years.",8d8d8d8d8d 942 asc " meres !",8d,8d 943 asc " meres !",8d,8d 944 asc " meres !" 945 brk 946 947 *------------------------------------------------- EOF 948 949 lst on 950 da * 951 lst off