well, got my engine that i'm making up and running, but it's slow! (it draws fullscreen at 12-13 fps on a 1.7 ghz pentium4) so i was hoping for some tips on optimization. I know my problem is in my sprite blitter so i'm gonna post it. For people to try to optimize, and for people to learn, (as there has been questions on this kind of stuff, clipping and masking.) i know the first thing people will say in response to this is something about toshi's optimization tut, but i know about that, and i'd like to know more. (i'm hungry for knowledge!) so if anyone can give tips, i'd appreciate it.
Sub bsprite (x,y,sprite(),frame,mainindex())
'x and y is the coords on the screen. this prog works only with pp256 tiles, btw. sprite holds the tiles, mainindex is a tile index, and frame is which tile to draw.in order to work, this needs a ylut&(199) which goes like this
'dim ylut&(199)
'for x = 0 to 199
'ylut&(x) = x * 320&
'next
If frame = 0 then goto sk
Spriteseg = varseg(sprite(mainindex(frame)))
Spriteoff = varptr(sprite(mainindex(frame)+2))
Spritewidth = sprite(mainindex(frame)) /8
Spriteheight = sprite(mainindex(frame)+ 1)
If x < 0 then
Swidth1 = - x: swidth2 = spritewidth
Elseif x > scrnwidth – spritewidth then swidth2 = 320 – x: swidth1 = 0
Else
Swidth2 = spritewidth
Endif
If y < 0 then
Sheight1 = not y: sheight2 = spriteheight
Elseif y > scrnheight – spriteheight then sheight2 = 200 – y: sheight1 = 0
Else
Sheight2 = spriteheight
Endif
Redim colorlut(swidth1 to swidth2)
Yarray = sheight1 * spritewidth
For yy = sheight1 to sheight2 – 1
Def seg = spriteseg
Yyy = yy + y
Mainoff& = ylut&(yyy) + buffoff
For xx = swidth1 to swidth2 – 1
Colorlut(xx) = peek(spriteoff + yarray + xx)
Next
Def seg = buffseg
For xx = swidth1 to swidth2 – 1
If colorlut(xx) then
Xxx = xx + x
Poke mainoff& + xxx, colorlut(xx)
Endif
Next
Yarray = yarray + spritewidth
Next
Def seg
Sk:
Sub bsprite (x,y,sprite(),frame,mainindex())
'x and y is the coords on the screen. this prog works only with pp256 tiles, btw. sprite holds the tiles, mainindex is a tile index, and frame is which tile to draw.in order to work, this needs a ylut&(199) which goes like this
'dim ylut&(199)
'for x = 0 to 199
'ylut&(x) = x * 320&
'next
If frame = 0 then goto sk
Spriteseg = varseg(sprite(mainindex(frame)))
Spriteoff = varptr(sprite(mainindex(frame)+2))
Spritewidth = sprite(mainindex(frame)) /8
Spriteheight = sprite(mainindex(frame)+ 1)
If x < 0 then
Swidth1 = - x: swidth2 = spritewidth
Elseif x > scrnwidth – spritewidth then swidth2 = 320 – x: swidth1 = 0
Else
Swidth2 = spritewidth
Endif
If y < 0 then
Sheight1 = not y: sheight2 = spriteheight
Elseif y > scrnheight – spriteheight then sheight2 = 200 – y: sheight1 = 0
Else
Sheight2 = spriteheight
Endif
Redim colorlut(swidth1 to swidth2)
Yarray = sheight1 * spritewidth
For yy = sheight1 to sheight2 – 1
Def seg = spriteseg
Yyy = yy + y
Mainoff& = ylut&(yyy) + buffoff
For xx = swidth1 to swidth2 – 1
Colorlut(xx) = peek(spriteoff + yarray + xx)
Next
Def seg = buffseg
For xx = swidth1 to swidth2 – 1
If colorlut(xx) then
Xxx = xx + x
Poke mainoff& + xxx, colorlut(xx)
Endif
Next
Yarray = yarray + spritewidth
Next
Def seg
Sk: