content:retrocomputing:sprite
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| content:retrocomputing:sprite [2022/08/16 18:54] – [Definizione] admin | content:retrocomputing:sprite [2024/06/02 15:57] (current) – [Colore] admin | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| ===== Registri ===== | ===== Registri ===== | ||
| + | |||
| + | ==== Schema ==== | ||
| + | |||
| + | Di seguito uno schema che elenca le locazioni di memoria, specificate più sotto, che definiscono gli sprite: | ||
| + | |||
| + | ^ ^Sprite X^Sprite Y^Sprite Pointer^Sprite Colore^ | ||
| + | ^Sprite 0|$D000 | ||
| + | ^Sprite 1|$D002 | ||
| + | ^Sprite 2|$D004 | ||
| + | ^Sprite 3|$D006 | ||
| + | ^Sprite 4|$D008 | ||
| + | ^Sprite 5|$D00A | ||
| + | ^Sprite 6|$D00C | ||
| + | ^Sprite 7|$D00E | ||
| + | |||
| + | |||
| + | |||
| + | | ||
| + | |||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | | ||
| ==== Attivazione ==== | ==== Attivazione ==== | ||
| Line 24: | Line 51: | ||
| </ | </ | ||
| - | < | + | < |
| ==== Posizionamento ==== | ==== Posizionamento ==== | ||
| Line 45: | Line 72: | ||
| === Multicolore === | === Multicolore === | ||
| - | La modalità **multicolore** prevede, oltre al colore principale dello sprite, anche **due colori aggiuntivi, condivisi da tutti gli sprite**. Si usano i **registri 53285, 53286 e 53276**: | + | La modalità **multicolore** prevede, oltre al colore principale dello sprite, anche **due colori aggiuntivi, condivisi da tutti gli sprite**. Si usano i **registri 53285 ($D025), 53286 ($D026) |
| < | < | ||
| Line 56: | Line 83: | ||
| === Colore principale === | === Colore principale === | ||
| - | Il **colore principale** si setta nei **registri 53287-53294**, | + | Il **colore principale** si setta nei **registri 53287-53294 |
| ==== Definizione ==== | ==== Definizione ==== | ||
| Line 108: | Line 135: | ||
| Qui lo stesso sprite (un fantasma) ha prima una definizione/ | Qui lo stesso sprite (un fantasma) ha prima una definizione/ | ||
| - | In fondo alla pagina c'è il sorgente completo, che come risultato dà il seguente: | + | In fondo alla pagina c'è il sorgente completo, che come risultato dà due fantasmini di PacMan che si spostano da sinistra a destra: |
| + | {{: | ||
| < | < | ||
| Line 156: | Line 183: | ||
| 1090 data 170, | 1090 data 170, | ||
| </ | </ | ||
| + | |||
| + | ===== Sprite animation e collision ===== | ||
| + | |||
| + | Il seguente esempio è tratto dal libro //Commodore 64 Graphics and Sound//; è diverso rispetto al listato sopra, perché non ridefinisce gli sprite con un altro disegno, ma visualizza alternativamente due sprite, con due definizioni diverse per creare l' | ||
| + | |||
| + | {{: | ||
| + | ==== Definizione sprite ==== | ||
| + | |||
| + | Vengono **definiti i dati di 5 sprite**, usando alcune locazioni di memoria a partire da (13*64=)832. Questa area è in realtà il //cassette buffer//, per cui se si usa il registratore, | ||
| + | |||
| + | < | ||
| + | 130 poke2040, | ||
| + | 140 poke2042, | ||
| + | 150 poke2044,15 | ||
| + | </ | ||
| + | |||
| + | ==== Spostamento e animazione ==== | ||
| + | |||
| + | Si tratta quindi di 4 sprite ' | ||
| + | |||
| + | < | ||
| + | 255 rem move sprites 0 and 2 | ||
| + | 260 pokevc, | ||
| + | ... | ||
| + | 285 rem display sprites 0 and 2 | ||
| + | 290 pokevc+21,5 | ||
| + | 300 for t=1 to 200:next | ||
| + | </ | ||
| + | |||
| + | I registri nel VIC-II per le **posizioni X degli sprite 0-3** (vc=53248, vc+2=53250, vc+4=53252 e vc+6=53254): | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Il registro ' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Poi vengono visualizzati gli sprite 1 e 3 (2041 e 2043) con un' | ||
| + | |||
| + | < | ||
| + | 305 rem move sprites 1 and 3 | ||
| + | 310 pokevc+2, | ||
| + | ... | ||
| + | 335 rem display sprites 1 and 3 | ||
| + | 340 pokevc+21, | ||
| + | 350 for t=1 to 200:next | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | < | ||
| + | 100 rem sprite movement and collisions | ||
| + | 105 rem clear screen | ||
| + | 110 print chr$(147) | ||
| + | 115 rem vic chip start address | ||
| + | 120 vc=53248 | ||
| + | 125 rem set sprite pointers | ||
| + | 130 poke2040, | ||
| + | 140 poke2042, | ||
| + | 150 poke2044,15 | ||
| + | 155 rem read sprite data | ||
| + | 160 for n=0 to 191 | ||
| + | 170 read a: | ||
| + | 180 next | ||
| + | 185 rem set y positions | ||
| + | 190 poke vc+1, | ||
| + | 200 poke vc+5, | ||
| + | 205 rem set sprite colors | ||
| + | 210 pokevc+39, | ||
| + | 220 pokevc+41, | ||
| + | 230 pokevc+43, | ||
| + | 240 for n=1 to 10 | ||
| + | 241 print chr$(147) | ||
| + | 242 print" | ||
| + | 243 print" | ||
| + | 244 print " | ||
| + | 250 for x=0 to 130 step 8 | ||
| + | 255 rem move sprites 0 and 2 | ||
| + | 260 pokevc, | ||
| + | 261 print " | ||
| + | 262 print " | ||
| + | 265 rem check for collision | ||
| + | 270 cd=peek(vc+30) | ||
| + | 280 if cd<>0 then 370 | ||
| + | 285 rem display sprites 0 and 2 | ||
| + | 290 pokevc+21,5 | ||
| + | 300 for t=1 to1000:next | ||
| + | 305 rem move sprites 1 and 3 | ||
| + | 306 print " | ||
| + | 307 print " | ||
| + | 310 pokevc+2, | ||
| + | 315 rem check for collision | ||
| + | 320 cd=peek(vc+30) | ||
| + | 330 if cd<>0 then 370 | ||
| + | 335 rem display sprites 1 and 3 | ||
| + | 340 pokevc+21, | ||
| + | 350 for t=1 to1000:next | ||
| + | 360 next x | ||
| + | 365 rem display explosion sprite 4 | ||
| + | 370 pokevc+8, | ||
| + | 380 pokevc+23, | ||
| + | 390 pokevc+21, | ||
| + | 400 for t=1 to 1000:next | ||
| + | 410 pokevc+21, | ||
| + | 420 for t=1 to 500:next | ||
| + | 430 next n | ||
| + | 440 end | ||
| + | 400 for t=1 to 1000:next | ||
| + | 410 pokevc+21, | ||
| + | 420 for t=1 to 500:next | ||
| + | 430 next n | ||
| + | 440 end | ||
| + | 795 rem sprite 0 and 2 data | ||
| + | 800 data 0, | ||
| + | 810 data 15, | ||
| + | 820 data 63, | ||
| + | 830 data 63, | ||
| + | 840 data 31, | ||
| + | 850 data 3, | ||
| + | 860 data 12, | ||
| + | 870 data 48, | ||
| + | 880 data 192, | ||
| + | 890 data 0,0,0,0,0,0 | ||
| + | 900 data 0,0,0,0 | ||
| + | 905 rem sprite 1 and 3 data | ||
| + | 910 data 0, | ||
| + | 920 data 15, | ||
| + | 930 data 63, | ||
| + | 940 data 63, | ||
| + | 950 data 31, | ||
| + | 960 data 3, | ||
| + | 970 data 12, | ||
| + | 980 data 12, | ||
| + | 990 data 3, | ||
| + | 1000 data 0,0,0,0,0,0 | ||
| + | 1010 data 0,0,0,0 | ||
| + | 1015 rem sprite 4 data | ||
| + | 1020 data 96, | ||
| + | 1030 data 24, | ||
| + | 1040 data 6, | ||
| + | 1050 data 1, | ||
| + | 1060 data 0, | ||
| + | 1070 data 0, | ||
| + | 1080 data 1, | ||
| + | 1090 data 6, | ||
| + | 1100 data 24, | ||
| + | 1110 data 96, | ||
| + | 1120 data 0,0,0,0 | ||
| + | </ | ||
| + | |||
content/retrocomputing/sprite.1660668844.txt.gz · Last modified: by admin
