Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Peeking for speed
#1
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?!


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
Reply
#2
Def seg - peek - def seg should be faster I think... of course Rel is going to pop in and say "SETVIDEOSEG!!!" but I really don't know how to do that...

to speed up your peek to find the pixel, create a LUT before the main loop, like this:
Code:
DIM SHARED ylut(199) AS LONG
FOR n& = 0 to 199
ylut = n& * 320
NEXT

Then in your peek:
Code:
colorcheck% = PEEK Player(col%).X + xpos% + ylut(Player(col%).Y + ypos%)
am an asshole. Get used to it.
Reply
#3
Nikazu.. That ylut?

I thought this is how you peek:
C = PEEK(320& * Y + X)

With your ylut you get:
C = PEEK(X + (n& * 320) * Y)

What good those that n& do? Is that pixel nr. n
ttp://hem.passagen.se/qb.basta
Reply
#4
........................................................................look at it again
am an asshole. Get used to it.
Reply
#5
c = peek( ylut(y) + x )

Of course, on pentium pro and better it won't make any difference.
oship me and i will give you lots of guurrls and beeea
Reply
#6
Agreed. I've tried it before and there's no noticeable speed difference.
Reply
#7
Quote:Nikazu.. That ylut?

y look up table
Reply
#8
Forget POINT. Multiple Def segs is faster than POINT even using SETVIDEOSEG.

Just tried it last night for my 2 hour game. ;*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)