07-01-2003, 10:39 PM
Hi! I have a question about speed when peeking and pokeing..
This is a code for a rotate routine that check for collision.. It checks every pixel in the array unitil it finds and collision..
I use point to check the color, i was thinking that if i used peek i could gain some noticable speed.. In the enigine this routine is called three times per loop so the program have to use point about 200 times per loop or so.. There for i can gain speed by using the right method?!
If i want to use peek i have to change the segment adress from the array (first line) and to DEF SEG = &HA000 to accses the VGA-Screen just before i peek for the color and then change the segment back to the array so it can check the next colour on the array..
What will be faster:
Point
or
Def Seg - Peek - Def Seg
I'm really have no idea what will be faster, cause i haven't used peek or poke much, the question mark for me is if those def seg command will slow it down?
This is a code for a rotate routine that check for collision.. It checks every pixel in the array unitil it finds and collision..
I use point to check the color, i was thinking that if i used peek i could gain some noticable speed.. In the enigine this routine is called three times per loop so the program have to use point about 200 times per loop or so.. There for i can gain speed by using the right method?!
Code:
DEF SEG = VARSEG(spr%(0))
so& = VARPTR(spr%(0)) + 4
hei% = spr%(1) - 1
wid% = spr%(0) \ 8 - 1
takex% = (wid% + 1) \ 2
takey% = (hei% + 1) \ 2
FOR Y% = 0 TO hei%
FOR x% = 0 TO wid%
c% = PEEK(so&)
sx& = (x% - takex%) * 50
sy& = (Y% - takey%) * 50
Nx& = (sx& * licos%(ANGL%)) - (sy& * lisin%(ANGL%))
Ny& = (sy& * licos%(ANGL%)) + (sx& * lisin%(ANGL%))
Nx% = Nx& \ 5384
Ny% = Ny& \ 5384
IF c% > 0 THEN
colorcheck% = POINT(Player(col%).X + xpos%,Player(col%).Y + ypos%)
IF colorcheck% = 1 OR colorcheck% = 2 OR colorcheck% >= 96 AND colorcheck% <= 101 THEN
Player(col%).Collision = 1: EXIT SUB
ELSE
Player(col%).Collision = 0
END IF
END IF
so& = so& + 1
NEXT x%
NEXT Y%
If i want to use peek i have to change the segment adress from the array (first line) and to DEF SEG = &HA000 to accses the VGA-Screen just before i peek for the color and then change the segment back to the array so it can check the next colour on the array..
What will be faster:
Point
or
Def Seg - Peek - Def Seg
I'm really have no idea what will be faster, cause i haven't used peek or poke much, the question mark for me is if those def seg command will slow it down?
ttp://hem.passagen.se/qb.basta