Qbasicnews.com

Full Version: 100% QB game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(I am still here Smile - but that hellish Hungarian interned supporter put out my last chance to visit the Web frequently... Sad )

I will test that Screen 13 lib on my 30Mhz 4.86 - will it be better than my fastest routines? I tried many things, but i never could reach something what was able to handle graphic fast enough to make smooth animation...

I am now working on a very big project, but i do not think that i will be able to finish it since i possibly lose all my free times when i will go to university - and possibly the possibility of working on any computer... I will try everything to keep on since i went too far already. For example i was able to create a very good - looking pseudo - 3D engine with filled triangles on Screen 9 what was able to display at about 100 triangles per clock tick on a 120 * 640 area of the screen what was a really good (looking) result... I will only put up that (with source of course) when the thing is 100% finished...
That SCREEN 13 library was slow like a slug on my computer and driven my HDD mad Sad You have to work on it more...

First of all, as everyone said: forget that HDD thing! For loading you can use it, since then the disk cache does the dirty job (even on my old computer), but when saving it always uses the disk to not lose data. On the other hand you should think about it when only loading too since PEEKing a byte from memory is always much faster than doing the same thing from a file. But for example PEEKing 8 bytes or more is slower if you get them from the file in one chunk (a$ = STRING$ (8, 0): GET #1, , a$).

There was a game here what made the SCREEN 13 thing perfectly, but a bit not "fair" since it rewrote some parts of QB: Bubble Fight. The "unfair" thing was that it found the space where QB stores the segment of the video memory (Without ASM, only PEEKs and POKEs), and changed it when it was necessary to make page flipping. It produced 15 FPS on my computer.

There is a trick what i consider "fair" since it can be get from QB's help and a little of thinking (And NC's HEX wiever & some BSAVEd files, for example the pictures from QBPDraw). This is the "BLOAD cheat": You can load any file with it fast as the lightning if you know what is the header what you need to attach to the file. From the help it can be found out that BSAVEd files contain their original segment & offset and their size. This is 6 bytes. The actual header is 7 bytes, after viewing some QBP and QBM files (The output of QBPDraw) i could describe it completely: Starts with CHR$(253), then Segment, then Offset, and at last Size (Then i wrote an add - on to QBPDraw what can create a four letter custom header for the BSAVEd files using the not really needed Segment & Offset values Smile ). So the cheat: open the file, and read it's first 7 bytes into the destination array. Then replace those 7 bytes to the appropriate BSAVE header (You only need to set the size: LOF(file)-7). After close it, and BLOAD starting at the array's 8th byte. When it is done, You can reopen it, and write back it's original first 7 bytes from the destination array.
Run it with a larger file (>5000 bytes), and you will be surprised Smile
The main advantage of it is that you can load the file to any array this way fast, you won't need strings.

My other way of optimization is to cut out everything what is not really necessary. I wrote "pseudo - 3D" before since i originally started by writing a full engine, but the project i am working on did not need it. Many parts of the 3D could be pre - calculated, so i did them to make it faster. I could reach this way that i can put virtually unlimited number of triangles on the screen, only their size count (I tried it with an object with at about 50 small triangles, and there was no noticeable speed - loss. Only the number of graphic operations count).

And finally: to make subs and functions Smile Careful design can reduce the code size dramatically since there are many things in a program what are being done similary. But avoid them at speed - critical parts: at those codes calling subs can make the thing slow, not to mention that you will not see the code in one piece what makes optimization impossible.

I only noticed a few months before that QB has an integer divison operand. Very useful at speed. I am telling about it since i think it was not only me who did not know it since i had seen tons of FIX (a / 2) or INT (b / 5) style codes in many programs. Integer divison is the same as INT (a / b), but without floating point. You can make real rounding too (if you not need to be very accurate) by this scheme: (a + b \ 2) \ b


Why i am not posting anything on my project? This is because i do not want to create something like an unfinished Titanic: Everybody can see the code, and that it would be a great thing if it was finished - but it is not. Just a skew of a huge ship, but useless... The other thing is that coding is not the most important part of it: it will (and not only "will", it has already) huge amounts of unique graphic, and style (And i am planning to write music for it too but then i will have to create a sequencer since i could not find any what fit my needs and it's output format was documented somewhere). Because of this nobody would be able to finish it, since my style is mine, it can not be reproduced (I am not meaning here that i am perfect, but nobody knows how i am planned the things, and i think nobody can make graphics, sounds, and style "compatible" with mine, so it is impossible to finish this project without me. And every programmer has his or her own style: if anybody plans to write something really unique, then only he or she can make it finished even if there are many other people helping him or her...)


Back to the Screen 13 library: That keyboard handling is not really good. Once i tried a code working the same way on a computer equipped with Windows XP, it ran, but at exit the OS completely went mad that the only way to stop it was to pull the plug... That method has a bug: the keyboard only sends data when it sends a sign first that it has data what starts Interrupt 9. So at every manual call to Port H60 is a fault: the keyboard is not ready to send the data then. The only way of making a real multikey routine is to reprogram Interrupt 9 what is impossible in pure QBasic (without ASM). The only way to make multikey feeling is to use CTRL, ALT and SHIFT keys (These six keys can be accessed completely independently by reading the appropriate memory locations). This is possible with INSert, Caps Lock, Scroll Lock, and Num Lock too, but using these keys is not a really good idea...


(Note: i pre - wrote this in Notepad, so if anybody had replied to the subject before me, or i am not repliing to something, i am sorry... I have no time to read the topic when i am online)
If SetVideoSeg is "unfair" then reading the keyboard with INP(&H60) and changing the DAC with OUT &H3C8/9 are also "unfair." Tongue

Actually, I'd like to know what your definition of "fair" is...
Sure. Just look at the code of setvideoseg. It's pureQB.
Fair, and not fair...

I only told that i think the Bubble Fight way is not really "fair" in my
opinion, but it is acceptable. I consider hacking in QB not really fair
since there are no documentations on it, only who deassembled QB can do this
(Microsoft never gives it's source codes to the public...). On the other
hand i not really looked around in Bubble Fight, i do not know exactly how
it does the thing, so i may not be 100% correct (but as the problem rised i
will study it).

The ports are legal since there are tons of documentation on them, so
everybody can deal with them. For example a very good source is Ralph Brown's
Interrupt List (I look up everything from there if i need). And QBasic has
functions to handle them.

Assembly is not permitted since it is an other language. If somebody writes
QB, not write tons of ASM and say that it is a QB code... If somebody
includes his or her own ASM, it is a very good thing, but a different "art".

The case of libraries, or third - party ASM is different. Then who uses that
up, usually not know anything of their work, just call those subs, and wonder
on the result. This is the worst since they use up other people's work
without knowing anything of them. I do not really like those programmers who
say "look, i wrote a real 3D game", but just fed X, Y and Z with the
appropriate function without knowing anything of 3D's real structure.


The case of INP &H60 is different. It is not "not fair", it is a fault. For
example i originally had a keyboard which started a horrible beep when
feeding it with this. And the Win XP which completely went mad after running
a program using this style of keyboard handling. It is NOT programmed in the
keyboard to send data when it does not send the signal "i have got data". So
it is not "not fair", it is "illegal function call", and the "compiler should
stop". On the other hand you can use it, but keep in mind that it can result
unpredictable things on certain configurations...
Could make bubble fight in screen 7 and it would look the same. :*)
But SetVideoSeg is a lot easier to use at that time and no one mentioned it being illegal. :*)
Cheetah, the keyboard starts to beep because you don't clear the keyboard buffer if using INP 60...

Adding an inkey$ solves the problem.


INP 60 is not a bug, or a faulty port, it's the keyboard port, and as such you can read it.


QB has peek and poke commands, as well as out and inp... why would it be cheating using them?


Although, SuperPut contains ASM routines, already compiled, which is copied into QB's memory. So, in effect, SuperPut could be considered a cheat.
No compiler was used in the creation of SuperPut. Tongue
Everything that just uses QB commands is PQB. And as Z!re said, POKE, PEEK, INP and OUT are QB commands and functions.

Anyhow the concept of "cheating" when coding is a nonsense to me, 'cause this is not some kind of honour game. This is coding. Making a program that does something. It's very odd that some people think that some ways to get that simple objective are "unfair". Really, really odd.
Do not think that i am so fool that i forgot to INKEY$ with using PORT &H60. The keyboard
did the beeping when it ran in INP &H60, at any program, not only mine. THE KEYBOARD IS NOT
PROGRAMMED TO SEND DATA WHEN IT DOES NOT SEND THE SIGNAL THAT IT HAS DATA!!! Consider that
an "undocumented feature". On some configurations it will work, on some others, it won't.
WinXP (and i think Linux too, but it will not freeze) is very sensible on ports, you can
not read or write what you think. Be careful with that INP &H60!
(To tell the truth, i "forgot" INKEY$, when i tried to program that way, but i catched the
memory locations of the keyboard buffer, and set everything to serve me. It works on my
current computer as all of the other INP &H60 based programs)

Fair and not fair... I consider something fair when there is documentation on it. If
RelSoft describes it completely why(!, not only "how"), and how it work, the thing becomes
"fair". But until not giving that, or just give to "change these bytes, and be happy", it
is something like Forma 1 where everybody tries to hide his technology. This competition
needs to have programs with completely documented code (or codes where all of the
documentation needed can be found at common places, for example QB's help, or Ralph Brown's
Interrupt List) so that we can check if it is really pure QB. If we would let programs
with parts what nobody can describe correctly, then we can not make sure that the thing
really fits here, so the programmers would only need to write a huge mess what nobody can
decode, so it will be ok...
If somebody just changes some bytes randomly, and then "oops, this changed the video
offset", so he or she writes a code based on it, then i think it is not acceptable. If
somebody writes something then he or she have to know what it does. If not, then it is
irresponsibility. For example what if he or she found a setting specific to his video -
card, but an other system it would result an error, and blows up the CPU ??? (I do not
think that Bubble Fight was made based on this, but the working of QBasic is not a really
common thing. If using up such things then a documentation should be inserted, or a
location from where it can be downloaded.)
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15