*RASTER GRAPHICS -GR.8 EXAMPLE - WITH MUSIC- JEFF STANTON        ORG     $4000*ZERO PAGE EQUATESSHPL    EQU     $F0SHPH    EQU     $F1HIRESL  EQU     $F2HIRESH  EQU     $F3SL      EQU     $F4SH      EQU     $F5*OTHER EQUATESSCREEN  EQU     $6000   ;SCREEN IS ACTUALLY OFFSET 496 BYTES @ $61FONDLIST  EQU     $6000   ;ADR OF DISPLAY LISTSTICK   EQU     $278COLOR1  EQU     $2C5COLOR2  EQU     $2C6AUDC1   EQU     $D201AUDF1   EQU     $D200NOTEL   EQU     $F6NOTEH   EQU     $F7SETVBK  EQU     $E45CXITVBK  EQU     $E462*LINE LOOKUP TABLE - LO BYTE STARTS AT $4000YVERTL  HEX     F018406890B8E008        HEX     305880A8D0F82048        HEX     7098C0E810386088        HEX     B0D800285078A0C8        HEX     F018406890B8E008        HEX     305880A8D0F82048        HEX     7098C0E810386088        HEX     B0D800285078A0C8        HEX     F018406890B8E008        HEX     305880A8D0F82048        HEX     7098C0E810386088        HEX     B0D800285078A0C8        HEX     F018406890B8E008        HEX     305880A8D0F82048        HEX     7098C0E810386088        HEX     B0D800285078A0C8        HEX     F018406890B8E008        HEX     305880A8D0F82048        HEX     7098C0E810386088        HEX     B0D800285078A0C8        HEX     F018406890B8E008        HEX     305880A8D0F82048        HEX     7098C0E810386088        HEX     B0D800285078A0C8        DS      $40*LINE L00KUP TABLE - HI BYTE STARTS AT $4100YVERTH  HEX     0102020202020203        HEX     0303030303030404        HEX     0404040405050505        HEX     0505060606060606        HEX     0607070707070708        HEX     0808080808080909        HEX     090909090A0A0A0A        HEX     0A0A0B0B0B0B0B0B        HEX     0B0C0C0C0C0C0C0D        HEX     0D0D0D0D0D0D0E0E        HEX     0E0E0E0E0F0F0F0F        HEX     0F0F101010101010        HEX     1011111111111112        HEX     1212121212121313        HEX     1313131314141414        HEX     1414151515151515        HEX     1516161616161617        HEX     1717171717171818        HEX     1818181819191919        HEX     19191A1A1A1A1A1A        HEX     1A1B1B1B1B1B1B1C        HEX     1C1C1C1C1C1C1D1D        HEX     1D1D1D1D1E1E1E1E        HEX     1E1E1F1F1F1F1F1F        DS      $40*DISPLAY LIST STARTS AT $4200DLIST   HEX     7070704FF0610F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F4F        HEX     00700F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F0F        HEX     0F0F0F0F0F0F0F41        HEX     0060        DS      $36*HORIZONTAL OFFSET TABLE - START AT $4300*THIS POINTS TO PROPER OFFSET SHAPE FOR EACH X POS (0-159)XOFF    HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203        HEX     0001020300010203*SHPLO CONTAINS LO ORDER BYTE ADDRESS OF OUR 4 SHAPESSHPLO   HEX     00172E45*SHPHI CONTAINS HI ORDER BYTE ADDRESS OF OUR 4 SHAPESSHPHI   HEX     44454647        DS      $58*SHAPES MUST BEGIN AT $4400*SHAPE0SHAPES  HEX     02AAAAAAAAAA800000        HEX     0AAAAAAAAAAAA80000        HEX     2AAAAAAAAAAAAA0000        HEX     2AAAAAAAAAAAAA8000        HEX     AAAAAAAAAAAAAA8000        HEX     AAAAAAAAAAAAAA8000        HEX     2AAAAAAAAAAAAA8000        HEX     2AAAAAAAAAAAAA0000        HEX     0AAAAAAAAAAAA80000        HEX     000001554000000000        HEX     000381554000000000        HEX     000380550000000000        HEX     000100150000000000        HEX     000780180000000000        HEX     000180180000000000        HEX     4007AA8A8000C0A000        HEX     501F02AA8000C2A800        HEX     501C00AA8000E2AB00        HEX     5400000A8000EAAB00        HEX     5507FFFFFFFDEAAB00        HEX     550FFFFFFFE5E2AB00        HEX     555FFFFFFFD402A800        HEX     55400018001000A000        HEX     505000180050000000        HEX     501000180040000000        HEX     401400180140000000        HEX     000500180100000000        HEX     000540540500000000        HEX     000155555400000000        HEX     000055555400000000        HEX     000015015000000000*SHAPE #1 SHIFTED RT 2 PIXELS        HEX     00AAAAAAAAAAA00000        HEX     02AAAAAAAAAAAA0000        HEX     0AAAAAAAAAAAAA8000        HEX     0AAAAAAAAAAAAAA000        HEX     2AAAAAAAAAAAAAA000        HEX     2AAAAAAAAAAAAAA000        HEX     0AAAAAAAAAAAAAA000        HEX     0AAAAAAAAAAAAA8000        HEX     02AAAAAAAAAAAA0000        HEX     000000555000000000        HEX     0000E0555000000000        HEX     0000E0154000000000        HEX     000040054000000000        HEX     0001E0060000000000        HEX     000060060000003000        HEX     1001EAA2A000302800        HEX     1407C0AAA000302800        HEX     140700AAA00030AAC0        HEX     15000002A00078AAC0        HEX     1501FFFFFFFF7AAAC0        HEX     1503FFFFFFF978AAC0        HEX     1557FFFFFFF500AA00        HEX     155000060004002800        HEX     141400060014000000        HEX     140400060010000000        HEX     100500060050000000        HEX     000140060040000000        HEX     000150150140000000        HEX     000055555500000000        HEX     000015555500000000        HEX     000005405400000000*SHAPE #2 SHIFTED RT 4 PIXELS        HEX     002AAAAAAAAAA80000        HEX     00AAAAAAAAAAAA8000        HEX     02AAAAAAAAAAAAA000        HEX     02AAAAAAAAAAAAA800        HEX     0AAAAAAAAAAAAAA800        HEX     0AAAAAAAAAAAAAA800        HEX     02AAAAAAAAAAAAA800        HEX     02AAAAAAAAAAAAA000        HEX     00AAAAAAAAAAAA8000        HEX     000000155400000000        HEX     000038155400000000        HEX     000038055000000000        HEX     000010015000000000        HEX     000078018000000000        HEX     000018018000000000        HEX     04007EE8A8000C0A00        HEX     0501F06AA8000C2A80        HEX     0501C00AA8001E2AB0        HEX     05400000A8001EAAB0        HEX     05507FFFFFFFDEAAB0        HEX     0550FFFFFFFE5E2AB0        HEX     0555FFFFFFFD402A80        HEX     055400018001000A00        HEX     050500018005000000        HEX     050100018004000000        HEX     040140018014000000        HEX     000050018010000000        HEX     000054054050000000        HEX     000015555540000000        HEX     000005555540000000        HEX     000001501500000000*SHAPE #3 SHIFTED RT 6 PIXELS        HEX     000AAAAAAAAAAA0000        HEX     002AAAAAAAAAAAA000        HEX     00AAAAAAAAAAAAA800        HEX     00AAAAAAAAAAAAAA00        HEX     02AAAAAAAAAAAAAA00        HEX     02AAAAAAAAAAAAAA00        HEX     00AAAAAAAAAAAAAA00        HEX     00AAAAAAAAAAAAA800        HEX     002AAAAAAAAAAAA000        HEX     000000055500000000        HEX     00000E055500000000        HEX     00000E015400000000        HEX     000004005400000000        HEX     00001E006000000000        HEX     000006006000000000        HEX     01001EAA2A00030280        HEX     01407C0AAA00030AA0        HEX     01407002AA00078AAC        HEX     015000002A0007AAAC        HEX     01541FFFFFFFF7AAAC        HEX     01543FFFFFFF978AAC        HEX     01557FFFFFFF500AA0        HEX     015500006000400280        HEX     014140006001400000        HEX     014040006001000000        HEX     010050006005000000        HEX     000014006004000000        HEX     000015015014000000        HEX     000005555550000000        HEX     000001555550000000        HEX     000000540540000000*START TABLE ON EVEN PAGE BOUNDARY        DS      $A4NOTES   HEX     43103F0838200014 ;P1M1        HEX     43084B1043085440        HEX     431043084B105408        HEX     6520001065084310 ;P1M2        HEX     43084B200010        HEX     43103F0838200014 ;P1M1        HEX     43084B1043085440        HEX     431043084B105408        HEX     6520001065084310 ;P1M2        HEX     43084B200010        HEX     382000023820000238203810 ;P2M1        HEX     0002381032084B100002        HEX     4B0800024B1000024B0800024B4000        HEX     024B10     ;P2M2        HEX     00024B0800024B1000024B0800024B        HEX     40        HEX     541000025408000254        HEX     100002540800025440     ;P2M3        HEX     382000023820000238203810 ;P2M1        HEX     0002381032084B100002        HEX     4B0800024B1000024B        HEX     0800024B4000024B10     ;P2M2        HEX     00024B0800024B1000        HEX     024B0800024B40        HEX     541000025408000254        HEX     100002540800025440     ;P2M3        HEX     0015FF                             ;REST & REPEAT*VARIABLESXX      DS      1YY      DS      1HORIZ   DS      1TEMP    DS      1DEPTH   DS      1SLNGH   DS      1VERT    DS      1OFFSET  DS      1POINTER DS      1TIME    DS      1TDELAY  DS      1VBFLAG  DS      1*CLEAR SCREEN 8K INCLUDING NDLIST AREACLRSCR  LDA     #>SCREEN        ;SETUP POINTERS TO CLEAR SCREEN        STA     SL        LDA     #<SCREEN        STA     SH        LDY     #$00        TYA        LDX     #$20            ;32 PAGES (8K)AA2     STA     (SL),Y        INY        BNE     AA2             ;CONTINUE UNTIL DONE WITH 256 BYTES        INC     SH              ;DO NEXT PAGE        DEX        BNE     AA2*SETUP DLIST        LDX     #$00DLOOP   LDA     DLIST,X        STA     NDLIST,X        INX        CPX     #$CC            ;204 ELEMENTS        BNE     DLOOP        LDA     #>NDLIST        STA     560        LDA     #<NDLIST        STA     561*INITILIZE        LDA     #$0B        STA     COLOR1        LDA     #$00        STA     COLOR2        LDA     #$40        STA     XX        LDA     #$20        STA     YY        STA     VERT        LDA     #$00        STA     TDELAY        LDA     #>NOTES         ;GET LO BYTE OF TABLE        STA     NOTEL        LDA     #<NOTES         ;GET HI BYTE OF TABLE        STA     NOTEH        LDA     #$00            ;CLEAR TIHER        STA     $14        LDA     #$01        STA     TIME        LDA     #$EA            ;PURE TONE - VOLUME 10        STA     AUDC1        LDY     #$00        STY     POINTER*SET VBLANK        LDA     #$07        LDX     #<FRAME        LDY     #>FRAME        JSR     SETVBKFOREVER JMP     FOREVER*VBLANK ROUTINEFRAME   LDA     VBFLAG        BEQ     OK        JMP     $E462OK      LDA     #$01        STA     VBFLAG        LDA     XX              ;CALC NEW HORIZ OFFSET        LSR                     ;DIVIDE BY 4 TO GET HORIZ BYTE        LSR        STA     HORIZ        JSR     SETUP        JSR     DRAW            ;DRAW SHAPE        LDA     TDELAY          ;DELAY 3/60 TH SEC        CMP     #$03        BNE     AB1        JSR     SETUP        JSR     XDRAW           ;XDRAW SHAPE        JSR     JOYSTK          ;READ JOYSTICK        LDA     XX              ;CALC NEW HORIZ OFFSET        LSR        LSR        STA     HORIZ        JSR     SETUP        JSR     DRAW            ;IMMEDIATELY REDRAW SHAPE        LDA     #$00            ;RESET DELAY        STA     TDELAY        JMP     SOUNDAB1     INC     TDELAYSOUND   LDA     TIME        CMP     $14        BGE     AC2*STOP NOTE - EQUIVALENT TO SOUND 0,0,0,0        LDA     #$00        STA     $D208        LDA     #$03        STA     $D20F        LDY     POINTER*LOAD NEXT NOTE        LDA     (NOTEL),Y        CMP     #$FF            ;LAST NOTE?        BNE     AC3*RESET TO BEGINNING NOTE        LDY     #$00        STY     POINTER        LDA     #<NOTES        STA     NOTEH*CONTINUE READING NOTES & STORING VALUES IN SOUND REGISTERSAC3     STA     AUDF1           ;STORE FREQUENCY OF NEXT NOTE        INY        INC     POINTER        LDA     (NOTEL),Y        STA     TIME            ;STORE LENGTH OF NOTE        INY        INC     POINTER        BNE     AC1             ;CAN ONLY HAPPEN ON AN EVEN NUMBER        INC     NOTEH           ;NEXT PAGE OF NOTESAC1     LDA     #$00            ;CLEAR TIMER AT BEGIINING OF EACH NEW NOTE        STA     $14AC2     LDA     #$00        STA     VBFLAG        JMP     XITVBK*SUBROUTINES*DRAWING SETUP SUBROUTINESETUP   LDY     XX              ;HORIZONTAL POSITION (0-159)        LDX     XOFF,Y          ;INDEX TO FIND SHAPE #        LDA     SHPLO,X         ;INDEX TO GET LO BYTE OF SHAPE TABLE        STA     SHPL            ;STORE LO BYTE IN ZERO PAGE        LDA     SHPHI,X         ;GET HI BYTE OF SHAPE TABLE        STA     SHPH        LDA     YY        STA     VERT        LDA     #$1F        STA     DEPTH           ;SHAPE IS 31 LINES DEEP        LDA     #$09        STA     SLNGH           ;SHAPE IS 9 BYTES WIDE        STA     TEMP            ;STORED HERE ALSO BECAUSE DRAWING*ROUTINE DECREMENTS SLNGH 0* AND VARIABLE MUST BE RESTORED AT START OF NEXT ROW        RTS*DRAW SHAPE SUBROUTINEDRAW    LDY     VERT            ;VERTICAL POSITION        JSR     GETADR          ;FIND BEGINNING OF SCREEN ADDRESS OF ROW        LDX     #$00        LDA     TEMP        STA     SLNGH           ;RESTORE VALUE OF WIDTH FOR NEXT ROW        LDY     #$00DRAW2   LDA     (SHPL,X)        ;GET BYTE OF SHAPE TABLE        STA     (HIRESL),Y      ;PLOT ON SCREEN        INC     SHPL            ;NEXT BYTE OF SHAPE TABLE        BNE     AD1             ;IF CROSS PAGE BOUNDARY?        INC     SHPH            ;INCREMENT TO NEXT PAGE OF SHAPEAD1     INY                     ;NEXT POSITION ON SCREEN        DEC     SLNGH           ;DECREMENT WIDTH        BNE     DRAW2           ;FINISHED WITH ROW YET        INC     VERT            ;IF SO, INCREMENT TO NEXT LINE        DEC     DEPTH           ;DECREMENT DEPTH        BNE     DRAW            ;FINISHED ALL ROWS?        RTS                     ;YES, END*GETADR SUBROUTINE FOR FINDING STARTING SCREEN ADDRESS TO PLOT BYTESGETADR  LDA     YVERTL,Y        ;LOOKUP LO BYTE OF LINE        CLC        ADC     HORIZ           ;ADD HORIZ OFFSET        STA     HIRESL          ;STORE LO BYTE SCREEN ADDRESS        LDA     YVERTH,Y        ;LOOKUP HI BYTE LINE        ADC     #<SCREEN        ;ADD HI BYTE OF SCREEN        STA     HIRESH          ;STORE HI BYTE SCREEN ADDRESS        RTS*JOYSTICK ROUTINEJOYSTK  LDA     STICK        AND     #$02            ;DOWN BIT?        BNE     CHKLF        LDA     YY              ;PREVENT SHAPE FROM EXITING BOTTOM SCREEN        CMP     #$A0        BEQ     CHKLF        INC     YY              ;MOVE TWO LINES        INC     YYCHKLF   LDA     STICK        AND     #$04            ;LEFT BIT?        BNE     CHKRT        LDA     XX              ;PREVENT SHAPE FROM EXITING SCREEN LEFT        CMP     #$00        BEQ     CHKRT        DEC     XX              ;THIS MOVES TWO PIXELSCHKRT   LDA     STICK        AND     #$08            ;RIGHT BIT?        BNE     CHKUP        LDA     XX              ;PREVENT SHAPE FROM EXITING SCREEN RIGHT        CMP     #$7C        BEQ     CHKUP        INC     XXCHKUP   LDA     STICK        AND     #$01            ;UP BIT        BNE     AE1        LDA     YY              ;PREVENT SHAPE FROM EXITING TOP SCREEN        CMP     #$00        BEQ     AE1        DEC     YY        DEC     YYAE1     RTS*XDRAW SHAPE SUBROUTINEXDRAW   LDY     VERT            ;VERTICAL POSITION        JSR     GETADR          ;FIND BEGINNING OF SCREEN ADDRESS OF ROW        LDX     #$00        LDA     TEMP        STA     SLNGH           ;RESTORE VALUE OF WIDTH FOR NEXT ROW        LDY     #$00XDRAW2  LDA     (SHPL,X)        ;GET BYTE OF SHAPE TABLE        EOR     (HIRESL),Y      ;EOR WITH SCREEN IMAGE        STA     (HIRESL),Y      ;PLOT ON SCREEN        INC     SHPL            ;NEXT BYTE OF SHAPE TABLE        BNE     AF1             ;IF CROSS PAGE BOUNDARY?        INC     SHPH            ;INCREMENT TO NEXT PAGE OF SHAPEAF1     INY                     ;NEXT POSITION ON SCREEN        DEC     SLNGH           ;DECREMENT WIDTH        BNE     XDRAW2          ;FINISHED WITH ROW YET        INC     VERT            ;IF SO, INCREMENT TO NEXT LINE        DEC     DEPTH           ;DECREMENT DEPTH        BNE     XDRAW        RTS                     ;YES, END