C64 Software  <  SCA: The C64 Software Collection / SPRITECALC V2.0

  Run
1000              ;
1010              ; SPRITECALC     V2.0
1020              ;
1030              ;
1040              ;
1050              ORG 20000
1060              ;
1070 FLAG         EQU 247
1080 TMP0         EQU 248
1090 TMP1         EQU 250
1100 TMP2         EQU 252
1110 TMP3         EQU 254
1120 BMAP         EQU $2000
1130 SPRITEADR    EQU 832
1140 FREE         EQU 704
1150 XADR         EQU 20
1160 YADR         EQU 151
1170 X            EQU FREE
1180 Y            EQU FREE+2
1190 SPRX         EQU FREE+3
1200 SPRY         EQU FREE+5
1210 OFFY         EQU FREE+6
1220              ;
1230              ;
1240 EINSPRUNG    JSR $AEFD
1250              JSR $B7EB
1260              STX YADR
1270              LDA #1
1280              STA 53269
1290              LDA #200
1300              STA 53248
1310              STA 53249
1320              LDA #13
1330              STA 2040
1340              ;
1350 CLSPRITE     LDX #63
1360              LDA #0
1370 CLSPRITE1    STA SPRITEADR,X
1380              DEX
1390              BPL CLSPRITE1
1400              ;
1410 CALC         LDA YADR
1420              STA Y
1430              LDA #0
1440              STA SPRY
1450              LDA #20
1460              STA TMP0
1470 LOOP1        LDA XADR
1480              STA X
1490              LDA XADR+1
1500              STA X+1
1510              LDA #0
1520              STA SPRX
1530              LDX #23
1540 LOOP2        JSR TEST
1550              BEQ CALC1
1560              BCS CALC1
1570              JSR SPRITESET
1580 CALC1        INC X
1590              BNE CALC2
1600              INC X+1
1610 CALC2        INC SPRX
1620              DEX
1630              BPL LOOP2
1640              INC Y
1650              INC SPRY
1660              DEC TMP0
1670              BPL LOOP1
1680              RTS
1690              ;
1700              ;
1710              ;BRAUCHT A,Y,TMP1
1720              ;
1730 SET          LDA #1
1740              DFB $2C
1750 TEST         LDA #0
1760              DFB $2C
1770 RESET        LDA #255
1780              STA FLAG
1790              LDA Y
1800              CMP #200
1810              BCS ERR
1820              LDA X+1
1830              CMP #>320
1840              BCC SET1
1850              BNE ERR
1860              LDA X
1870              CMP #<320
1880              BCC SET1
1890 ERR          SEC
1900              RTS
1910              ;
1920 SET1         LDA Y
1930              LSR
1940              LSR
1950              LSR
1960              ASL ; DURCH 8 MAL 2
1970              TAY
1980              ;
1990              LDA MULTTAB,Y
2000              STA OFFY
2010              LDA MULTTAB+1,Y
2020              STA OFFY+1
2030              LDA Y
2040              AND #7
2050              CLC
2060              ADC OFFY
2070              STA OFFY
2080              ;
2090              CLC
2100              LDA #<BMAP
2110              ADC OFFY
2120              STA TMP1
2130              LDA #>BMAP
2140              ADC OFFY+1
2150              STA TMP1+1
2160              CLC
2170              LDA X
2180              AND #%11111000; BITS 0-2 AUSBLENDEN
2190              ADC TMP1
2200              STA TMP1
2210              LDA X+1
2220              ADC TMP1+1
2230              STA TMP1+1
2240              ;
2250              LDA X
2260              AND #7
2270              EOR #7
2280              TAY
2290              LDA ZWEIHOCH,Y
2300              LDY #0
2310              BIT FLAG
2320              BCS RESETTEN
2330              BNE SETTEN
2340 TESTEN       AND (TMP1),Y
2350              CLC
2360              RTS
2370 SETTEN       ORA (TMP1),Y
2380              STA (TMP1),Y
2390              CLC
2400              RTS
2410 RESETTEN     EOR #255
2420              AND (TMP1),Y
2430              STA (TMP1),Y
2440              CLC
2450              RTS
2460              ;
2470              ;
2480 ZWEIHOCH     DFB 1,2,4,8,16,32,64,128
2490 MULTTAB      DFB 0,00,64,01,128,02,196,03
2500              DFB 0,05,64,06,128,07,196,08
2510              DFB 0,10,64,11,128,12,196,13
2520              DFB 0,15,64,16,128,17,196,18
2530              DFB 0,20,64,21,128,22,196,23
2540              DFB 0,25,64,26,128,27,196,28
2550              DFB 0,30
2560              ;
2570              ;
2580 SPRITESET    LDA #<SPRITEADR
2590              STA TMP1
2600              LDA #>SPRITEADR
2610              STA TMP1+1
2620              CLC
2630              LDA SPRY
2640              ADC SPRY
2650              ADC SPRY ; MAL 3
2660              STA TMP2
2670              LDA SPRX
2680              LSR
2690              LSR
2700              LSR      ; DURCH 8
2710              CLC
2720              ADC TMP2
2730              ADC TMP1
2740              STA TMP1
2750              BCC SPRSET1
2760              INC TMP1+1
2770 SPRSET1      LDA SPRX
2780              AND #7
2790              EOR #7
2800              TAY
2810              LDA ZWEIHOCH,Y
2820              LDY #0
2830              ORA (TMP1),Y
2840              STA (TMP1),Y
2850              RTS
READY.