View previous topic - View next topic |
Author |
Message |
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Mon Dec 19, 2005 2:00 pm Post subject: |
[quote] |
|
There is no need to worry about that though, in my opinion the bit shifting has no place in this particular C++ code either even though it'd work. Whether you do *16 or <<4, the compiler will probably end up producing the same machine code anyway, while *16 is much closer to describing what you're doing than the <<4. You could go on to define TILE_SIZE as 16 and use *TILE_SIZE instead to make it both even easier to understand the code and to change your tile size later, or to make it dynamic.
But if you're using QB, you're probably not that worried about performance anyway, or you'd have dumped the language a long time ago, right?
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Mon Dec 19, 2005 8:26 pm Post subject: |
[quote] |
|
Hey! I'm trying to dumb it! But it keeps pulling me back.
That code I implented in my fb engine works well, not that brilliant. Without any doubt I have done something wrong, as usual :/. What I miss with fb is relwait. I wonder if AFLib2 is finished soon. _________________
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Mon Dec 19, 2005 11:59 pm Post subject: |
[quote] |
|
tunginobi wrote: | Just a quick question about the code that's been posted in this thread: the C++ code takes advantage of bit shifting to speed up its processing, so is there a way to implement bit shifting in QBasic? I don't recall any functions or operators that do that. |
What I always do in this case is implement a lookup table. You only ever need to multiply integers if you're using integer offsets, so it seems like a natural place to implement it :) I'm actually not certain if a lookup is faster than a single multiplication, but it has the advantage that if you use this all over your code and decide that you want your engine to support varying tile sizes, you need only modify the initilisation of your lookup.
Which is pretty much the same thing as just using TILE_SIZE as a constant somewhere like Bjorn said, but I'm not sure how that hits your performance, which is what you seem concerned about.
Sorry, I'm probably not explaining myself very well at all... Here's an example:
Code: |
//Say you've got tiles of size 40x40 at 800x600;
for(int i=0; i<25; i++) ftx[i]=i*40;
//Then in your map rendering routine:
for(int y=0;y<19;y++){
for(int x=0;x<21;x++){
graphics.drawtile((ftx[x])+mapxoff, (ftx[y])+mapyoff, atpos(x+mapx, y+mapy));
}
}
//or whatever...
|
_________________ http://www.distractionware.com
|
|
Back to top |
|
|
tcaudilllg Dragonmaster
Joined: 20 Jun 2002 Posts: 1731 Location: Cedar Bluff, VA
|
Posted: Thu Dec 22, 2005 9:02 pm Post subject: |
[quote] |
|
I remember having my head programmatically handed to me by a moderator at allbasiccode.com a few years ago. He optimized a PUT variant I had made with amazing binary math skillz. It was all QB... it had this aura of "magic" to it, because it was so inobvious. He improved its speed by a factor of 20, as I recall.
|
|
Back to top |
|
|
DrV Wandering Minstrel
Joined: 15 Apr 2003 Posts: 148 Location: Midwest US
|
Posted: Fri Dec 23, 2005 7:12 pm Post subject: |
[quote] |
|
tunginobi wrote: | Just a quick question about the code that's been posted in this thread: the C++ code takes advantage of bit shifting to speed up its processing, so is there a way to implement bit shifting in QBasic? I don't recall any functions or operators that do that. |
QB does emit shifts when using integer multiplication by powers of two. However, unless you're using PDS or VBDOS, which can target the 286 or 386, it will emit a series of 'shl reg, 1', since that's the only immediate value supported by the 8086.
For example:
QB code: Code: | dim i as integer
i = i * 4 |
A snippet of the assembly listing (specify /a and a list file to BC to see this): Code: | 0030 ** I00002: mov ax,I%
0033 ** sal ax,1
0035 ** sal ax,1
0037 ** mov I%,ax |
Note that SHL and SAL are equivalent.
However, I would still recommend using a more modern/capable language and compiler. ;) _________________ Don't ask no stupid questions and I won't send you away.
If you want to talk fishing, well, I guess that'll be okay.
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Tue Jan 22, 2008 6:50 pm Post subject: |
[quote] |
|
Holy cow, this thread is ooold. I'm like a necromancer of my own stuff. Can you guys check if this walkaround engine works for you? It's basically the same stuff I released for the old contest but now I think I have worked out the bug. _________________
Last edited by BadMrBox on Sun Aug 22, 2010 9:53 pm; edited 1 time in total
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Tue Jan 22, 2008 7:51 pm Post subject: |
[quote] |
|
It is a debug build. windows gui (debug) built using fbedit1.0.5.7. I'm not good at debugging, as an old qb user I kinda laugh in the face of it... I'm not getting the last laugh here. But, I'm running the program through gdb.exe and it finds no problems :/. _________________
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Tue Jan 22, 2008 8:00 pm Post subject: |
[quote] |
|
Eh, nope? _________________
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Tue Jan 22, 2008 8:12 pm Post subject: |
[quote] |
|
err, sorry, me being stupid... I was just assuming it was done in c++, don't know why... I shouldn't have, as you clearly stated fbedit ::)
Sorry, don't mind me, I'll go stand in the corner now... _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Tue Jan 22, 2008 8:57 pm Post subject: |
[quote] |
|
Well, I'll join you.
But I'm starting to wonder. There is nothing wrong with the code, it compiles just fine and runs for me without any complaints at all... I'll be back with an earlier version later. _________________
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Tue Jan 22, 2008 10:16 pm Post subject: |
[quote] |
|
Thank you for the good news :). _________________
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Tue Feb 05, 2008 8:34 pm Post subject: |
[quote] |
|
Some short updates on the project. Gamepad are now supported. Fixed up the collisions a bit as it was a little wonky before.
I should be able to make some code for the music before the weekend... it isn't much needed really, and I should also be able to knock up the mapeditor too as I have all code needed in my head. Well I should... _________________
|
|
Back to top |
|
|