User Tools

Site Tools


base:sprite-crunching

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

base:sprite-crunching [2015-04-17 04:34] – external edit 127.0.0.1base:sprite-crunching [2019-01-28 10:26] (current) hcl_bd
Line 5: Line 5:
 Sprite crunching is based on a glitch in the VIC-chip (as usual) that appears on a cycle-exact position every rasterline. You trigger the glitch by setting back $d017 to 0 on this exact position, and all sprites that had their $d017-bit set to 1 will be affected. Sprite crunching is based on a glitch in the VIC-chip (as usual) that appears on a cycle-exact position every rasterline. You trigger the glitch by setting back $d017 to 0 on this exact position, and all sprites that had their $d017-bit set to 1 will be affected.
  
-Now what will happen depends on where in the sprite you already are. There is an internal sprite-graphics-counter for each sprite that, in normal case, is increased by 3 each line the sprite is displayed. Each rasterline 3 bytes of the sprite will be displayed, so the counter in increased by 3. This counter can have values from 0 to $3f. Depending on what value it has, different things will happen when triggering the sprite crunching glitch. Sometimes 3 will be added (as normal), sometimes something else. Sometimes a negative value will be added(!).+Now what will happen depends on where in the sprite you already are. There is an internal sprite-graphics-counter for each sprite that, in the normal case, is increased by 3 each line the sprite is displayed. Each rasterline 3 bytes of the sprite will be displayed, so naturally the counter is increased by 3. This counter can have values from 0 to $3f. Depending on what value it has, different things will happen when triggering the sprite crunching glitch. Sometimes 3 will be added (as normal), sometimes something else. Sometimes a negative value will be added(!).
  
-In [[http://noname.c64.org/csdb/release/?id=684|Rutig Banan/FLT]] sprite crunching is used on the very first sprite-linewhich causes the sprite to expand to ~3 times its normal heightThe sprite ends only when the counter reaches the value $3f. If it reaches say $3eit will continue to ($3e+3)&$3f $01 and wrap.+When the sprite-graphics-counter reaches $3f, the sprite will endNormally this happens after 21 displayed lines. However if using the glitch results in adding anything not dividable by 3, the counter will not end up on $3f, but $3d or $3e instead. On the next line it will pass $3f and wrap around to $00 or $01and the sprite will continue to be displayed for some 21 more lines (though the graphics will be mis-aligned of course).
  
-[[http://noname.c64.org/csdb/release/?id=2968|Krestage/Crest]] shows the first example of sprite crunching when used for shrinking sprites. There you can also find exact documentation of what happens on each value of the sprite-graphics-counter. By using this table, you can sort out what possibillities there are to do something useful with this, depending what you're after.+__Examples of usage:__
  
-In [[http://noname.c64.org/csdb/release/?id=72550|Edge of Disgrace/Booze Design]] sprite crunching is used in the 4x4-plasma as an alternative to a normal $d017-stretcher. Here the counter is decreased so that the sprite repeats after 4 lines. Instead of setting $d017 twice each line, it is set twice every 4:th line, saving some life supporting cycles in the timing.+In [[http://noname.c64.org/csdb/release/?id=684|Rutig Banan/FLT]] sprite crunching is used on the third sprite-line, adding -1 to the counter, which effectively causes the sprite to be displayed almost 3 times. Y-expanded sprites and toggling graphics bank gives you ~120 lines of sprite area to play with. The graphics is then copied to the right position to make the letters move up/down. 
 + 
 +[[http://noname.c64.org/csdb/release/?id=2968|Krestage/Crest]] shows the first example of sprite crunching when used for shrinking sprites. There you can also find exact documentation of what happens on each value of the sprite-graphics-counter when triggering the glitch, hand-haxxored by Crossbow himself. Finding the (probably) shortest path through the table, he managed to shrink the sprites from 21 lines to 17. By using this table, you can sort out what possibilities there are to do something useful with this, depending what you're after. 
 + 
 +In [[http://noname.c64.org/csdb/release/?id=72550|Edge of Disgrace/Booze Design]] sprite crunching is used in the 4x4-plasma as an alternative to a normal $d017-stretcher. Here the glitch is triggered on position $1e, making it add -9. This effectively jumps back 3 sprite-lines, repeating the graphics in a way that fits the 4x4-timingSo, instead of setting $d017 twice each line to repeat the graphics, it is set twice every 4 lines, saving some life supporting cycles in the timing.
  
 To add a bit more content to this page, here is that table. You read it like "AA : BB -> CC", where AA is the current position in the sprite. BB is the value that will be added if triggering the glitch (+3 of no glitch), and CC is the resulting position. So, if you want to shrink your sprites, you should look for BB values > 3, and if you want to enlarge your sprite then look for BB values < 3. Don't forget that the sprite only ends on $3f, so the only ways to end the sprite are from $3b or $3c. To add a bit more content to this page, here is that table. You read it like "AA : BB -> CC", where AA is the current position in the sprite. BB is the value that will be added if triggering the glitch (+3 of no glitch), and CC is the resulting position. So, if you want to shrink your sprites, you should look for BB values > 3, and if you want to enlarge your sprite then look for BB values < 3. Don't forget that the sprite only ends on $3f, so the only ways to end the sprite are from $3b or $3c.
Line 83: Line 87:
 3f : end 3f : end
 </code> </code>
- 
-Hmm, Can i format it in a more readable way?.. 
- 
base/sprite-crunching.txt · Last modified: 2019-01-28 10:26 by hcl_bd