|
|
View previous topic - View next topic |
Author |
Message |
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Wed Oct 15, 2003 9:03 pm Post subject: HOWTO: Make A faster PSET for any qb! |
[quote] |
|
Have you ever wanted to know how to make your programs faster?
Well, if you're using PSET, then you can get up to 5 times more speed out of your program! :)
here you go.
Code: |
SUB FastPSET (x%, y%, c%)
DEF SEG = &HA000
POKE CLNG(y%) * 320 + CLNG(x%), c%
DEF SEG
END SUB
|
and if you wan't to do easy transparencies:
Code: |
SUB TransPSET(x%, y%, c%, tc%)
DEF SEG = &HA000
IF c% <> tc% THEN POKE CLNG(y%) * 320 + CLNG(x%), c%
DEF SEG
END SUB
|
oh, and if you want to have clipping, to prevent overwriting the wrong memory, add these lines to each sub BEFORE the DEF SEG = &HA000 line.
Code: |
IF x% < 0 THEN x% = 0
IF x% > 319 THEN x% = 319
IF y% < 0 THEN y% = 0
IF y% > 199 THEN y% = 199
IF c% < 0 THEN c% = 0
IF c% > 255 THEN c% = 255
'uncomment for tc in TransPSET:
'IF tc% < 0 THEN tc% = 0
'if tc% > 255 THEN tc% = 255
|
enjoy your faster programs!
email me if theres any trouble. _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
Posted: Wed Oct 15, 2003 9:32 pm Post subject: |
[quote] |
|
Howto: Making POKE worth the effort.
Code: |
offset& = 0
DEF SEG = &HA000
FOR y = 0 to 199
FOR x = 0 to 319
POKE offset&, colour
offset& = offset&+1
NEXT
NEXT
|
Never use a LUT for each pixel. If you want to do a box, here:
Code: |
SUB box(x1, y1, x2, y2, c)
offset& = YLUT(y1) + x1
'assume def seg = &ha000
'assume x2 > x1 and assume y2 > y1
width = x2 - x1
height = y2 - y1
FOR yy = 1 TO height
FOR xx = 1 TO width
POKE offset& + xx, c
NEXT
offset& = offset& + 320
NEXT
|
For more info, see my double buffering article on http://www.venosoft.com/articles.php
|
|
Back to top |
|
|
valderman Mage
Joined: 29 Aug 2002 Posts: 334 Location: Gothenburg, Sweden
|
Posted: Thu Oct 16, 2003 12:25 pm Post subject: |
[quote] |
|
Is that clipped version really faster than the standard PSET? So many IFs...PSET must be even slower than it seems.
Oh yeah, what does CLNG do? Convert to 32-bit signed integer? I've tried the POKE method numerous times before, and due to my poor QB skils it always ended in nuclear war against QB integers and typecasting. _________________ http://www.weeaboo.se
|
|
Back to top |
|
|
supergoat Pretty, Pretty Fairy Princess
Joined: 21 Dec 2002 Posts: 13 Location: in the smile of every newborn
|
Posted: Mon Jan 05, 2004 1:56 am Post subject: |
[quote] |
|
Yeah, those are much faster.. I don't use anything else, heh
You'll want to double buffer if you're going to use POKE, poking directly into video memory is brutally slow. CLNG converts into a long integer and also murders any speed you'd be gaining over PSET.. anyway, in this example it's redundant. Also DEF SEGging in a function called as many times as a PSET is a big no no :p
poor man's double buffer:
Code: | DIM SHARED db%(32001), YOff&(199)
DEF SEG = VARSEG(db(0)): db%(0)=2560: db%(1)=200
FOR y = 0 to 199: YOff&(y) = 4 + y * 320&: NEXT
SCREEN 13: CLS
POKE pixelx + YOff&(pixely), color
PUT (0, 0), db%, PSET 'crap the db onto the screen after all graphics have been drawn for this frame.
|
|
|
Back to top |
|
|
|
Page 1 of 1 |
All times are GMT
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|