PDA

View Full Version : ATTN: quickbasic experts



Mike Chambers
May 13th, 2008, 11:10 AM
i don't know if there are any QB experts here, but i'm trying figure out a way to modify where QB thinks it stores a variable. as in, i want to arbitrarily modify it's pointer value in QB's segment of memory.

afaik, there is no command built in to do this. if anybody does know something, please let me know! other than that, i'm thinking the only way to do it is dimension a string like so:

DIM thearray(1 TO 320, 1 TO 200) AS STRING * 1

then i am thinking i could get the VARSEG and VARPTR values of that array's start byte in RAM... then, perhaps i could implement a little trick such as scan QB's memory segment for those values as 2-byte words. once i have that location i could hopefully change it to A000:0000

you probably guessed this already, but what i'm trying to do here is start the 320x200 array at the beginning of the VGA graphics memory and use 320x200x8bpp video mode. i imagine it would be a lot faster than using PSET to draw stuff. like i could say:

thearray(1, 1) = 15

then the very top left pixel would have a value of color 15. anybody have some advice on this? am i going about it the right way? if you know of any magical built-in command for QB to do something like this, let me know. :o

barythrin
May 13th, 2008, 11:34 AM
I probably don't understand exactly why you're doing that (speed?) when I drew with pixels I'd just use circles that were 1 pixel large and fill do what I needed like that.. given probably the dumbest way to do it but in highschool it was easy. Could you not just poke the video ram? http://www.phys.uu.nl/~bergmann/basic-faq.html I had to do that when I wrote a hex editor to display some ASCII characters without them activating like they would with print chr$(07), etc. This was text of course and you had to space it out appropriately so you don't just hit an attribute byte with the next value. Never tried this tecnique to do pixels though although I'm sure it can be done.. essentially the same thing your get and put do.

carlsson
May 13th, 2008, 12:47 PM
I have no idea how PSET is implemented, but don't expect variable assignment is so much faster. The Basic interpreter probably needs to look up the variable, perhaps make a typecast and then store a value. Besides, don't you need a variable type that takes exactly one byte per element in your array to make it work?

I suppose QuickBasic doesn't have PEEK and POKE commands like classic Basics? Otherwise that is how I would directly alter memory areas. The number of calculations to convert a coordinate to a memory address though may be a too big overhead.

Mike Chambers
May 13th, 2008, 03:31 PM
I have no idea how PSET is implemented, but don't expect variable assignment is so much faster. The Basic interpreter probably needs to look up the variable, perhaps make a typecast and then store a value. Besides, don't you need a variable type that takes exactly one byte per element in your array to make it work?

I suppose QuickBasic doesn't have PEEK and POKE commands like classic Basics? Otherwise that is how I would directly alter memory areas. The number of calculations to convert a coordinate to a memory address though may be a too big overhead.

it does have PEEK and POKE, it's not much faster if it all though. i guess what i really need to do is use ASM code for memory block copying from variables to graphics memory. that should be the fastest way.

carlsson
May 14th, 2008, 02:03 AM
Again, if I understand correctly your array of integer variables needs to be exactly one byte per element, no array overhead. Perhaps this is the case in QB, but one can never be too sure. :)

ziloo
May 14th, 2008, 04:15 AM
Hello Mike,

I know you have heard this before, but have you condidered moving on to other
languages such as "C" or "Pascal"? With your knowledge of BASIC and computer
hardware, you will be running Borland's Turbo C or Turbo Pascal in a matter of a
week!! Both Borland products are in public domain and there is a magnificient
graphics package with them that is beyond comparison for a Dos based software.

You have pushed quickbasic to the limits "no man has gone before" :super:, and
I believe the world of C/Pascal programmers is waiting for you to do the same for
these languages...:winking:

Best Wishes

ziloo

MikeS
May 14th, 2008, 05:52 AM
In case it's relevant, I believe that in TurboBasic the location of the pointer to the segment holding strings is known and can possibly be changed; don't know about the offset(s) though.

m

carlsson
May 14th, 2008, 06:14 AM
Sorry, I didn't read Mike's first message close enough.

DIM thearray(1 TO 320, 1 TO 200) AS STRING * 1
It seems fine, one byte wide character strings all the way. But then:

thearray(1, 1) = 15
Would QB allow you to assign the integer value 15 to a string that holds one character, or perhaps you meant CHR$(15) above? Perhaps QB works like Pascal and C in this way, so a string of one character equals a numeric value 0-255.

Mike Chambers
May 14th, 2008, 01:04 PM
Sorry, I didn't read Mike's first message close enough.

It seems fine, one byte wide character strings all the way. But then:

Would QB allow you to assign the integer value 15 to a string that holds one character, or perhaps you meant CHR$(15) above? Perhaps QB works like Pascal and C in this way, so a string of one character equals a numeric value 0-255.

whoops! yes, that was a typo i did mean chr$(15)

that's one of my biggest complaints about QB. there's no type definition for a single byte numeric value. you have to do string conversion operations, and when you're using an XT... not fun! :p

Mike Chambers
May 14th, 2008, 01:06 PM
Hello Mike,

I know you have heard this before, but have you condidered moving on to other
languages such as "C" or "Pascal"? With your knowledge of BASIC and computer
hardware, you will be running Borland's Turbo C or Turbo Pascal in a matter of a
week!! Both Borland products are in public domain and there is a magnificient
graphics package with them that is beyond comparison for a Dos based software.

You have pushed quickbasic to the limits "no man has gone before" :super:, and
I believe the world of C/Pascal programmers is waiting for you to do the same for
these languages...:winking:

Best Wishes

ziloo

lol. yeah. mike b did send me turbo c++ 3.0 and i did install it. i just haven't forced myself to start using it yet. i should put the QB projects aside for a bit and play around with it. i think i will start tonight actually.

mbbrutman
May 14th, 2008, 06:50 PM
Hello Mike,

I know you have heard this before, but have you condidered moving on to other
languages such as "C" or "Pascal"? With your knowledge of BASIC and computer
hardware, you will be running Borland's Turbo C or Turbo Pascal in a matter of a
week!! Both Borland products are in public domain and there is a magnificient
graphics package with them that is beyond comparison for a Dos based software.

You have pushed quickbasic to the limits "no man has gone before" :super:, and
I believe the world of C/Pascal programmers is waiting for you to do the same for
these languages...:winking:

Best Wishes

ziloo

I keep working on him ... I've even sent him a beloved copy of Borland Turbo C++ 3.0 for DOS. (Mike - check for shipping still missing?) One day I'm going to convert him to a C program and let him experience the dark side of the force.

Heck, I'd even go for PASCAL. I know that Trixter is a PASCAL bigot.

Borland Turbo C++ 3.0 for DOS is a wonderful platform that I'd recommend to anybody:


C and C++ - your choice
Integrated Development Environment (IDE) or command line compiler
Properly structure your code with multiple modules that you can link at compile time
Inline assembler
Good integration with DOS and BIOS interrupts
A pretty standard runtime that is comparable to what you find on Unix boxes
Fairly good optimization of generated code
No serious bugs .. I've not found a compiler code gen bug yet.
Libraries and code overlays
6 different memory models supported
Good debugger in the IDE


I've managed to write an entire TCP/IP stack in it, including the assembler code to interface with the packet driver. It works well.

Trixter
May 14th, 2008, 10:01 PM
anybody have some advice on this? am i going about it the right way? if you know of any magical built-in command for QB to do something like this, let me know. :o

DEF SEG = &HA000 and then POKE is about it, sorry.

Trixter
May 14th, 2008, 10:03 PM
Heck, I'd even go for PASCAL. I know that Trixter is a PASCAL bigot.


Guilty as charged.





C and C++ - your choice
Integrated Development Environment (IDE) or command line compiler
Properly structure your code with multiple modules that you can link at compile time
Inline assembler
Good integration with DOS and BIOS interrupts
A pretty standard runtime that is comparable to what you find on Unix boxes
Fairly good optimization of generated code
No serious bugs .. I've not found a compiler code gen bug yet.
Libraries and code overlays
6 different memory models supported
Good debugger in the IDE




Turbo Pascal 7.0 has the same features, but C is more useful in "real life" and there is an order of magnitude more C code out there than Pascal code, so I'd lean him toward C as well.

Mike Chambers
May 15th, 2008, 12:58 AM
yep, i know C/C++ compiled binaries are muuuuuuuch more efficient than anything QB will spit out for you. there are some tricks you can take advantage of to turbocharge your QB code, but even still... the language lacks a number of very important features that some programs require. the biggest one is probably the inability to use "byte" as a data type. you are stuck with DIM blah AS STRING * 1 so every time you want to pull something out as a numerical value you waste lots of valuable CPU time with ASC(blah) and just as much putting a number in with CHR$(value)

i also HATE how you can't directly manipulate binary. you have to play around with string operations


a = 128
value = blah
DO
IF value - a >= 0 THEN
value = value - a
bindata$ = bindata$ + "1"
ELSE
bindata$ = bindata$ + "0"
END IF
a = a / 2
LOOP UNTIL a < 1
^ UGH! EVIL!!!!!!! lots of fun when you gotta do a bunch of em on an XT.

i still like the language over all. you can make really nice apps if you know what you're doing. i bet you guys never expected to see a VNC client written in QB 4.5 right? :mrgreen:

but yeah i downloaded lots of C/C++ tutorial docs for both newer win32/linux flavors and older stuff for the DOS flavors like TC++ 3.0 i am looking forward to switching but there will always be a part of me that likes QB i've used it since i was about 5 lol.

carlsson
May 15th, 2008, 03:34 AM
It strikes me, aren't there any other powerful Basic implementations which are backwards compatible with QB but add C-like features? I reckon the GNU C Compiler or however it is called today, comes with one backend and several front ends for various languages. Technically speaking, it should be doable to make a Basic dialect with the low-level features you lack and get it to compile just as efficiently as any C, Pascal, Java etc does. However a compiler may take more resources so you'll have a bit of a problem to run it natively on your vintage PC but cross-development would work fine.

Mike Chambers
May 15th, 2008, 05:56 AM
It strikes me, aren't there any other powerful Basic implementations which are backwards compatible with QB but add C-like features? I reckon the GNU C Compiler or however it is called today, comes with one backend and several front ends for various languages. Technically speaking, it should be doable to make a Basic dialect with the low-level features you lack and get it to compile just as efficiently as any C, Pascal, Java etc does. However a compiler may take more resources so you'll have a bit of a problem to run it natively on your vintage PC but cross-development would work fine.

i didn't know that, ty i'm going to have a look at it. there also freebasic ( www.freebasic.net ) which is a very nice compiler. i have used freebasic several times to make win32 apps and the speed is excellent. it's literally like 99.9% compatible with quickbasic 4.5. you can just import .BAS files that were written in QB, and it will run without modifications 9 out of 10 times.

they have versions for win32, linux, and DOS. problem is, you need at least a 386 so anything i do with it wouldn't be of much use on vintage PC's.

ziloo
May 15th, 2008, 07:39 AM
Carlsson wrote:



...It strikes me, aren't there any other powerful Basic implementations which are
backwards compatible with QB but add C-like features?...

Ohhh come on Carlsson...you are ruinning all our efforts :cursemad: !!! There are
giga bytes of code out there written in "C" that are highly educational for anybody
who wants to know about computer micro structure. By learning "C" one can also
enter the world of embedded systems that is both fun and practical.

Mike wrote:



...i didn't know that, ty i'm going to have a look at it...

ARRRRRRRRGH...:hammer:...

ziloo :biggrin:

p.s. All said for fun!

MikeS
May 15th, 2008, 09:32 AM
<snip>
i also HATE how you can't directly manipulate binary. you have to play around with string operations


a = 128
value = blah
DO
IF value - a >= 0 THEN
value = value - a
bindata$ = bindata$ + "1"
ELSE
bindata$ = bindata$ + "0"
END IF
a = a / 2
LOOP UNTIL a < 1
^ UGH! EVIL!!!!!!! lots of fun when you gotta do a bunch of em on an XT.


TBasic:
bindata$=right$("00000000"+bin$(value),8 )
;-)
m

Mike Chambers
May 16th, 2008, 12:41 AM
Carlsson wrote:


Ohhh come on Carlsson...you are ruinning all our efforts :cursemad: !!! There are
giga bytes of code out there written in "C" that are highly educational for anybody
who wants to know about computer micro structure. By learning "C" one can also
enter the world of embedded systems that is both fun and practical.

Mike wrote:


ARRRRRRRRGH...:hammer:...

ziloo :biggrin:

p.s. All said for fun!

haha. nah, don't worry i'll be using C before i ever try to mess with another BASIC dialect.

speaking of embedded, you ever play around with mini-ITX boards? i used to have one with a 1.0 Ghz VIA C7-EDEN chip on it. fan-less and silent. was going to make a really nice enclosure and mount it in the trunk of my car, run wires to an in-dash touchscreen and amplifiers.

i didn't have the time and money to finish the job, but you could make a really sweet mobile set up with something like that, including coding your own "operating system" that is designed for only that purpose.

ended up selling the board, but still would like to try it some day. the best part of it would be the awesome wardriving potential. :twisted: or buy one of those cellular internet plans and use a cardbus slot, if you want to go legit.

i can see it now

"HONK! HONK! MOVE IT BUDDY!"

"HANG ON I'M UPDATING FIREFOX YOU JERK"

ziloo
May 16th, 2008, 09:21 AM
Go for it Mike...we know you can do it...

ziloo

MikeS
May 16th, 2008, 02:03 PM
<snip>speaking of embedded, you ever play around with mini-ITX boards? i used to have one with a 1.0 Ghz VIA C7-EDEN chip on it. fan-less and silent. was going to make a really nice enclosure and mount it in the trunk of my car, run wires to an in-dash touchscreen and amplifiers.

----
Like this one? By "Mr. Fido/Fidonet" BTW; lots of other fascinating history etc. on his site.
http://www.wps.com/projects/MP3-system/index.html

m