base:simple_software_sprite_to_background_collision
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:simple_software_sprite_to_background_collision [2015-10-07 22:13] (current) – created ftc | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Simple Software to Background collision ====== | ||
+ | by Achim | ||
+ | |||
+ | To check wether a specific object has been hit or not, the correct screen position has to be calculated. | ||
+ | |||
+ | Use sprite-X to calculate the screen column: | ||
+ | < | ||
+ | lda spriteX | ||
+ | sec | ||
+ | sbc # | ||
+ | sta tmp1 | ||
+ | lda spriteMSB // | ||
+ | sbc #$00 | ||
+ | lsr //MSB -> carry | ||
+ | lda tmp1 | ||
+ | ror //9bit value : 8 | ||
+ | lsr | ||
+ | lsr | ||
+ | sta column | ||
+ | </ | ||
+ | If you're code uses the 2*x trick to simplify MSB-handling, | ||
+ | and a division by 4 is needed. | ||
+ | |||
+ | Use sprite-Y to calculate number of screen rows: | ||
+ | < | ||
+ | lda spriteY | ||
+ | sec | ||
+ | sbc #$32 //y-offset, visible screen area starts at y=$32 | ||
+ | lsr //8bit value : 8 | ||
+ | lsr | ||
+ | lsr | ||
+ | sta numberrows | ||
+ | </ | ||
+ | Use " | ||
+ | < | ||
+ | ldx numberrows | ||
+ | lda screenmemlowbyte, | ||
+ | sta tmp0 //zp address | ||
+ | lda screenmemhibyte, | ||
+ | sta tmp1 //zp address+1 | ||
+ | |||
+ | checkvalue: | ||
+ | ldy column | ||
+ | lda (tmp0), | ||
+ | ... | ||
+ | </ | ||
+ | The result is the top left screen position of the sprite. | ||
+ | |||
+ | There are two options to check the other eight possible screen positions underneath the sprite (or any other position next to the sprite): | ||
+ | - Use different x- and y-offset values for subtraction. (Check this program: {{: | ||
+ | - Manipulate " |
base/simple_software_sprite_to_background_collision.txt · Last modified: 2015-10-07 22:13 by ftc