Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
Code: Select all
* a0=pointer to sprite data
* a1=pointer to sprite on screen
moveq #0,d0
add.l (a0)+,d0
sub.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
Code: Select all
; all values are 2 bytes (1 word in size)
tile_num equ 0
tile_flag equ 2
tile_x1 equ 4
tile_y1 equ 6
tile x2 equ 8
tile_y2 equ 10
Nyh wrote:First take a step back.
You start with bullets and try to detect collision with sprites.
Is the other way around faster? Start with sprites and try to detect a collision with a bullet.
Which method is fastest cannot be said beforehand.
Note:Code: Select all
* a0=pointer to sprite data
* a1=pointer to sprite on screen
moveq #0,d0
add.l (a0)+,d0
sub.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
addx.l (a0)+,d0
subx.l (a1)+,d0
Should result in d0=0 if the sprite was not touched by a bullet.
Hans Wessels
Code: Select all
moveq #0,d0
add.l (a0)+,d0 ; add players x1,y1
sub.l (a1)+,d0 ; subtract bullets x1,y1
add.l (a0)+,d0 ; add players x2,y2
sub.l (a1)+,d0 ; subtract bullets x2,y2
; if d0=0 no hit
I'm intrigued with this idea. But I am unsure exactly how it works.
For example is this how it works: a0=players sprite data, a1=enemy bullet sprite data.
LaceySnr wrote:So if you're using a palette and your sprite's first four bytes are FF, F0, F0, FA, and the same four bytes appear in the screen buffer, the result of adding the value of each byte from the sprite data, and subtracting the value of each byte from the screen data should be zero:
Set D0 to zero
Add FF (from Sprite) to D0
Sub FF (from Screen) from D0
Add F0 (from Sprite) to D0
Sub F0 (from Screen) from D0
etc.
If the total sum is not 0 then you know something else has been drawn on top of the sprite. I guess this would have issues with areas of the sprite that should be masked off so you might need to combine that in to ignore pixels which should be transparent (which would be showing the background and hence not match the sprite's data).
Code: Select all
* a0=pointer to sprite data
* a1=pointer to sprite on screen
moveq #0,d0
move.l (a0)+,d1
addx.l d1,d0
move.l (a1)+,d1
subx.l d1,d0
move.l (a0)+,d1
addx.l d1,d0
move.l (a1)+,d1
subx.l d1,d0
move.l (a0)+,d1
addx.l d1,d0
move.l (a1)+,d1
subx.l d1,d0
move.l (a0)+,d1
addx.l d1,d0
move.l (a1)+,d1
subx.l d1,d0
move.l (a0)+,d1
addx.l d1,d0
move.l (a1)+,d1
subx.l d1,d0
move.l (a0)+,d1
addx.l d1,d0
move.l (a1)+,d1
subx.l d1,d0
Code: Select all
* a0=pointer to sprite data
* a1=pointer to sprite on screen
moveq #0,d0
movem.l (a0)+,d1-d6
addx.l d1,d0
addx.l d2,d0
addx.l d3,d0
addx.l d4,d0
addx.l d5,d0
addx.l d6,d0
movem.l (a1)+,d1-d6
subx.l d1,d0
subx.l d2,d0
subx.l d3,d0
subx.l d4,d0
subx.l d5,d0
subx.l d6,d0
bod/STAX wrote:
A more obvious solution as I've mentioned in other posts is to drop the frame rate down to 12.5 instead of 25fps. Whilst this does pretty much
fix any obvious slowdown the sprite animations just look terrible. It may just be the case if after every optimisation I can think of has been
done I'll just release it and people will just have to put up with it and from a speed point of view it will be like Super R-Type on the SNES.
Users browsing this forum: SteveBagley and 5 guests