The Basix Fanzine
issue 13 november/december 1998



[ Basix Fanzine Main Index ]

Welcome to issue 13 of the Basix Fanzine. I was hoping to release this issue at the end of October, but I'm too lazy. Anyway, 'tis here now.

Unfortunately, I haven't had quite the diverse range of contributions as I've had for previous issues - it seems that the number of contributions is on a downward trend. So, if you want to contribute something, please do so - because if I get no contributions, you get no fanzine.

Enjoy this issue - and then get writing!

Website Awards 98:

The Basix Fanzine Website Awards 1998 - we're setting out to find the best BASIC site out there!

I received the following nominations:

I was planning to have categories but didn't really receive enough nominations for this to be possible. So, the only award category is the award for "BASIX FANZINE WEBSITE OF THE YEAR 1998".

Basically, the site that gets the most votes wins. You are encouraged to visit any or all of the above sites and then vote for the best one using the form at

Alternatively, send an email to and state in the body of the message the full name of the site you vote for.

Levels are represented in bold by B, I or A for Beginner, Intermediate and Advanced respectively, or a combination. Most of these links point to parts of this HTML document, although some may point to other HTML files in the Basix Fanzine directory.


basix fanzine issue 13

Ian Cairns proposes a combined effort for beginners and intermediate programmers

features & reviews MICROBASIC
Jason Downey and his working freeware compiler
"Hacker" returns with a new series of graphics tutorials

"Hacker" with yet another series of tutorials.

WHY 64K? (A)
RudeJohn knows his limits

RudeJohn searches for his record collection

RudeJohn gets tired of Alex's terrible puns

Mark K. Kim's freely-distributable code demonstrating the use of LFNs.
main index internet resources

the latest news in the BASIC world



A freeware BASIC compiler is getting underway, in an attempt to provide a free, up-to-date version of Microsoft's QuickBasic compiler. Discussion is currently taking place in the newsgroup especially set up for the project, alt.lang.basic.compiler. If you're interested in contributing, just post a message there and join in the discussion.

For more information, take a look at the official website, maintained by none other than your friendly fanzine editor, at

[ Back to Contents ]



Fellow Basic Programmers,

I have been kicking around an idea for a few days in regards to people wanting to get into programming.

What do you think of a group project done - by and for - the beginner to intermediate group? Something produced in DOS. Not too elaborate or esoteric. The project could be used for each of us to learn, and to help demonstrate how to go about producing an application from scratch using a teamwork approach.

If enough interest is generated, we would have to have a Moderator from the intermediate to advanced group. The general idea would be for all interested parties to submit code written in the agreed-upon Language (It was suggested to use the lowest common denominator: ie. Qbasic) and Version, and then to download the code produced by others, test it, and then to vote on the preferred code (of course, it would be expected that we would not vote for our own code.) In this way we would eventually (this could take a long time!) arrive at a completed application, we would all learn along the way, and we would see that there are many different ways to achieve the same end.

This is the way I envision it at the moment, not necessarily how it would happen.

The first part of the project would be to submit ideas and to decide what would be produced: for example, a simple Rolodex program. At the same time we would collect ideas on Structure: what Screen(s) would we use (text/graphics), would we use the mouse?, how much comment will be required with the code? will type identifiers be required at all times?, will we rely on Global variables, or Variables passed as parameters? Will we require variable declarations before use? Will all variables local to a procedure have to be explicitly declared as Local? (And this is where an intermediate to advanced programmer as moderator is necessary.)

The second part would consist of what the User Screen(s) would look like, what functions would be available, what the user would expect to happen when he pushes a button.

The third part would consist of what information would be needed, how data would be stored, sorted, spindled, folded, etc. Where and when to use Constants, Types, Arrays, Binary/Random/Text files, etc.

The fourth part would consist of dividing the project up into groups: Data input and editing, Data storage, Data Retrieval, Data Display and writing a Main Procedure with the various units as Stubs.

The project would then continue by writing code to fill in the various stubs until completion.

I am throwing this idea into the public domain and do not desire to dominate it. So, if you want to be involved, let us hear from you. What do you think? Can you help with any part of it? Will you let your name stand as a Moderator?

Ian Cairns

[ Back to Contents ]


Got a BASIC news article?

Opening a website? Want to announce a new product that will benefit BASIC programmers? Want to reach hundreds of readers for free? Then send your press release to NOW!

[The editor reserves the right to edit or omit articles recieved for publication - if you want an advert rather than a news article, read on.]

reviews and information on BASIC products


MicroBasic, a freeware working BASIC compiler, by Jason Downey


[ Back to Contents ]

enhance your programming - this is the place to learn BASIC tips, techniques and tricks!




These tutorials are mainly THEORY work with very little code making them very easy to convert to a diffrent language. I will assume that you allready know how to create a .TGA file (and how to use it), This is because it is one of the best (FREE) formats to use, Full possible color usage, no attempts at 'compression' and reletivily easy to understand format. This tutorial also requires a BIT of knowledge about 3D and RGB.


The average(Mean) of colors:

OK, lets say that we have a image. A small 15*15 square, the image can be any size with any content you want. Lets say that the image is a smily face (color 255 255 255) on a black background (color 0 0 0) now lets say we want to superimpose another picture over ours (colored light is just that with a straight color), We wont call a 3D card API unless we want it done in real time in large ammounts. So we get the Average of the overlay color and the image color. (A compromise of both). There is also a less CPU intensive way of doing the same thing. Its called Striple Alpha (Hope thats the spelling) It works by puting one pixel of the original image then one of the overlay. This looks rubbish under lower resolutions but under hi-res, low color, it looks ok.

(Note the code example WONT work in basic. It is just an example that most basic programmers will be able to catch onto. Maybe with some modification it MIGHT work, but I have some other things to do. Hey thats a challenge for all you people out there)


Err.. Thats a bit of code (150 lines approx.). I havent run this I just typed this in as it came to me. It isnt designed to work, Basic wont be able to use a variable's lined together like [R G B] but a .TGA routine could work on CHR$(R) + CHR$(G) + CHR$(B). Hmm. This started out as a theory article. I might have time to do another article but I have a lot of other stuff to do. But because you are all code hungry freaks. (Except that girl on the left... And what did you say your number was again?) Here is a bit of code that I might do the next article about, Effects. All it is is a simple circle. that has a 3d finish. It isnt TOO well done and it is a PALLETTE hog. Its not commented at all. Here is a thought change the RGB value of the large SMEER (color 1 or color 64) to 0 then use that entire area as a Overlay. It looks a lot better then a straight red and It gives that lightbulb feel.


- A 2080 bit encryption program written in basic

PS. if you have a little visual C experience how do you use a subroutine from a DLL in VC++ 5. Also is there a way for me to figure out every entry point for a DLL& the parameters (I have 1 routine that I REALLY want to use but there are no specs for the DLL.)

[ Back to Contents ]




Part 1 - Encryption

Disclaimer: Sorry this is necessery due to the nature of this article. I assume NO responsibility for any damage(s) caused by this data. Some of the theory in this article has certain laws covering it, so you have been warned if you are a american citizen you should send some letters to congress saying to support the bill that they are trying to have passed. For more information please consult

Note: all the math, and code here is calculated by hand (no calculator or help from another window with basic in it. Meaning that there may be a few mistakes so please bear with me for this one.. ok..)

Intro: Here im goin to introduce you to some basic encryption styles, Xor, Bit shifting, Bit Switching.

Xor: This is the simplest form of encryption that there is, Any person wanting to crack a 8 bit xor can do it in under 1 second on a low end pc. Thus making it useless without some modification. For all those that dont know what xor is, it is a simple operator. Its on almost every scientific calculator. Now a standard xor command looks like this:

done = dat XOR passwd

Now lets assume that dat is 32 (00100000) and passwd is 69 (01000101). another view of that is (2 binary digits that have the same value = 0 whilst 2 with diffrent values = 1)

| 0| 0| 1| 0| 0| 0| 0| 0| 32


| 0| 1| 0| 0| 0| 1| 0| 1| 69

Answer (Below)

| 0| 1| 1| 0| 0| 1| 0| 1| 101

Hope this is simple enough for everyone to understand. Now we can add to our simple XOR excryption by lets say adding 1 for each byte so for the first the password is 69 then the next byte is 70 then the next one 80, then the next one 90 and so on. This will work fine until you reach 255, hmm then you have a small problem. you need to add a small 'line' to your encryption 'loop' here is a code sample. Sorry about the HEAVY commenting, some people might not understand if I didnt.



Bit Shifting: This is a LOT simpler than it sounds (once you have the Idea) The theory behind this is if you add X bits before a entire string then it is unreadable because It throws everything off whack. But with this you have to be careful if the number is divisable by 8 then all you do is add 1 byte to the data. Below there is a subroutine that converts a binary number (must be 8 bit) into a ascii charecter.


This should help with writing the finished file, and writing a routine to do the opposite. Ive got one that does what is required BUT it is part of HCRYPT and it does MUCH more than just that (Its part of the encrypt process). So.. err.. I dont think that I want to distribute that JUST yet. The above routine is also from Hcrypt but it was seperate from the save file procedure (I do a bit more processing before the file is saved). Hope this sheds some light on Bit shifting, And working with a BITSTREAM instead of a plain string.


Bit Switching: This is a simple form of encryption that envolves more than 1 bitstream. What this does it has 2 or more bitstreams. The first is the original data, the second(and onwards) is a stream of bits. They are switched making the original data completely garbled and hard to decipher. The downside to this is that the password becomes impossible for a human to remember so we start relying on a "PASSWORD FILE" (Hcrypt does this) to decrypt we do the opposite to encrypting. We check for the 'password' bits and replace them with the old bits. This data would be stored all in the password file. Here is a small example (All the data is random):

Original Bitstream:


Password Bitstream TABLE:

Old New
0111 1010
0110 1100
0010 0101
1100 0011
1101 0111
1011 0110
1001 1011
0011 0000
0101 1111
1010 1000

(* having the same number on both sides is a good idea when the program is coded propperly)

Encryped Bitstream:

0111011011011011100110110011010110011100110011001100110011011010 (Old)

Ive included both encrypted and un-encrypted bit streams so you can check up on my work and its less confusing :). the ===='s and ----'s are there so you can see which 4 bit section is. As you can see the original is nothing like what we end up with and the password file isnt too big. Then you can all ways find a nice way to hide the password file. in this case its not TOO long(and in 4 bit nibbletts) so you could write a little util that adds 64 to each of the binary numbers and displays their ascii values (remember all the letters start at 64). This makes it easy to carry a sophisticated password around in your head. BUT what happens when you need more powerfull encryption than that. Well who is stopping you from running the data through again after adding a 4 'filler' bits (2 to the start and 2 to the end). or maybe making the binary 'password' bigger. or a combination of these. But when you make the encryption more complex make sure that the decryption process is up to speed. It's no use writing a encryption program, converting your companies entire financial records, deleting the originals, then finding out your de-cryption process only follows 16 out of 96 steps.

Laws concerned: The US goverment BANS all messages outgoing from america using encryption that is stronger than 40 bit(Last time I heared).According to BYTE magazine the NSA has a 'chip' that can crack 128 bit encryption in about 2 seconds. This is not too nice for all you budding young cryptographers out there so here comes our next section.

Hiding Data: almost every file format can have data 'added' somwhere without too much distortion, or problems. This teqnique is used by many people that want to send data without people necesserly knowing something is there. A alternate name for this is EMBEDDING. In issue 12 you are taught how to APPEND data to the end of a .EXE. this can be done to any format without much trouble but it does kinda stick out (If you know what you are looking for you will find it in less than a minute). So why dont we replace data in another file. Lets take a WAVE file for example. You have the HEADDER. then you have the DATASTREAM. The wave format dosent paticuarly CARE if you replace data, as long as you have a MONO, LOW QUALITY soundfile it is masked nearly completely. so lets say that we have a wave file and a simple un-encrypted message to put in it:

Magic Number (which byte to replace):
6 (ie 6th byte 12th byte 18th byte and so on)


Wave Data stream (I picked lower case so you can see better):

Encrypted Data

The bold letters point out where our data is. now you have a problem seeing this with the knowledge of where the data is. If your data dosent have a recgonisable header or marking no one will be able to notice. Do you know how many losers send simpsons/soutpark/some brand new tv show .WAVS, via e-mail. instead of just mailing the url to the other person. about 2^65535 (now lets se you work that one out on a calculator). So if someone is 'browsing' through a BBS's es sound section they will see a normal file. That plays normally without problems but the people that do know will be downloading that encrypted data with a large evil grin. Another thing to remember is to keep the magic number fairly high. I would personally keep it above 100 because the smaller it is the more distortion. 6 is a extremely LOW number and the original file when being played it may have a LOT of background static. Also the .WAV format is the easiest format to 'hide' data in. some other formats may requre you to do a lot more processing Like a .MP3 for example would probbably need you to understand the format enough to know where data can be kept without much distortion or detectability.

End Note: This article is huge, and without much code. Hmm its pretty big. more than 1 third of the size of the first basix fanzine. Next article I will do will be on storage. I will also have to brush up on my "3d" coding because I'll be covering a 3d model and maybe its skin, possible way of storing it and the article will have a few DATAFILES that could also be sent along with it. (The model) and hopefully I will post one of my 'LIBRARYS' but I will have to clean up the code a lot. While all you people are waiting for the article go outside(It took me longer to figure out the concept of outside than how to code in delphi). and buy a CD called Smells Like Children. By Marilyn Manson


[Ed's note: It's alright, everybody - Part 2 appears below... so you can stay inside for that little bit longer.]

[ Back to Contents ]




If so, please email for details.

Advertising can be placed here in exchange for anything that would help the fanzine - for example, webspace, a domain name, or the money to provide this - in fact, if somebody could "sponsor" the fanzine and give us with 10mb or more of webspace, that would be absolutely fantastic! In return, your advertisements would be sprinkled liberally here and there in the fanzine and on the website too.


Part 2 - Processing

Intro: Today we will have fun. Im going to take you through creation of your own file format, reading some other file formats,alternate ways of storing data,and possible various utils. But first your own file format.

Creating a file format: Now we have all been writing a program and wanting to store data right? When we want to store information let it be anything from a high score table to a graphic image to even the source code to unix it has to be stored in somthing, usually a file. When creating a file format first we need to figure out what we want to store, why, and any restrictions. Lets say that we want to create a new image format for distrabution over internet in this format we want to keep it as user friendly when opening as possible, so lets first give up any hope of re-inventing .JPG or .GIF because they store their data in a linear way. Becuase we are transfering the data over internet we have to be able to cater for the people with slow connections and short attention spans. So lets store the data in this way

Each number represents which pixel is where in the file. (note there is a error in there. I stuffed up the order somewhere. only notaiced when I got 3 numbers in a row and I got 101)


[Ed's note - sorry about keeping that as an ASCII table, but I'll be buggered if I'm going to convert that lot to HTML! :) ]

But the theory behind this is that each 13th byte is printed so at first you start of with something very blury then less then less until you have the full image. Now with designing that format you have to remember to add some basics. A headder lets say FRMT!> which needs to have some meaning the letters FRMT stand for FORMAT the ! stands for the version number (ascii value) and the > might be a sign for the loader to take know where to stop reading the headder. Also you have to add 'UN-USED' space into the file for future expansion, Also when re-designing the format (this does happen) make it as backwards compatable as possible. Or in other words readable by a 'OLD' editor even though some new features are un-avalible in the version, comatability is VERY important.

This may sound like you are trying to rip other people off but there are many formats that you use today and you dont feel like you are stealing .GIF , .PCX , .JPG, .TXT,.HTML. All these formats were invented by other people and are commonly used. I will discuss a Common file format that is being used Widly and previously un-discussed by me .WAV (the other most common format i .PCX which my tutorial can be found in issue 12) The .WAV format comes in a few diffrent flavours but the standard un-compressed one will be covered here. One recomended FTP site is this site contains a bit of info on microsoft products and creations (including formats). As all good formats the .WAV format starts with a headder in this case RIFF the next 12 bytes are organized in the following way:

WORD wFormatTag
WORD wChannels
DWORD dwSamplesPerSec
DWORD dwAvgBytesPerSec

WORD stands for word. it is used in asm programming and it means that a string is going to be 2 bytes long

DWORD stands for double word it is used in asm programming a bit it means that a string is going to be 4 bytes long

All this information you can ignore quite safely. Take a look at this program taken from Basic Internet Fanzine Issue 1. If your reading this PETER COOPER im sorry for mangaling your code ;). Take a read of this code if you dont understand read earlier fanzies.


Ok that was probbably over commented (sorry again.) but by adding that code in you can read it to understand the format better. As the saying goes 'A code snippet is worth a million words'.

ALTERNATE WAYS OF STORING DATA: Hmm I just had a idea why dont I take you through the process of writing a 3d game. (I'll have to brush up on my BSP algorythm info though) Ok lets say that we have a 3d object. We will keep it simple lets say that it is kept at:

( 4, 4, 4) ( 2, 4, 4) ( 2, 2, 4) ( 2, 4, 4)
( 4, 4, 2) ( 2, 4, 2) ( 2, 2, 2) ( 4, 2, 2)

is a simple cube. Now we have many ways of storing it. We can keep it in text format, Making it easier for people to modify but making it harder for people to create a loader. we can store it in binary form (I will use CHR$(x) instead of the real charecters) And the file would look like this.


Now thats without a texture. Where would you put that? in a seperate file? into the model file? where in that? at the start, or at the end? Now these are some of the decisions faced by all those cutting edge programmers at sierra that will soon be releasing the first beta copy of a new game called PAC-MAN. (hmm, maybe not exactly our problems, but similar ones) If we were to keep the texture data behind the 3d wireframe it would be easier to code BUT we are faced with 'sorting' the data into a image this is where we must map a texture onto the image A painfull process if you have never done any 3d coding before and still a major pain the the nads if you have. Another possible option is scraping the idea of a wireframe and keeping the pixel color,and position in the same object. The file would look like this (triangle):

( 0, 1.5, 1, 4)
( 1, 0, 1, 4)
( 1, 1, 1, 4)

The format is (X,Y,Z,COL) these are the points but all the pixels being drawn would be each given their own x,y,z that can be anywhere making this easy to code and extremely easy to write a decoder (earlier issues go into detail) for. A tip though Remember to cache, I got _FLAMED_ because he said my routine was not to much faster than in-built command, so here is a question to all those who flamed me before, Who can "LOCK" at 32+ FPS. I'll put money on it that none of you can whilst only using PSET(160x100). This is a small routine that I will be refering to a lot in the near future so take a look at it and Learn what it does. Even run it.


There is still some optimization that could happen before this runs at what I would like to. I would like to compile a list of speeds so can you run this and mail me the results with info about your PC (Cpu speed, Memory, OS running at time of test). Now That that is over I HAVE to explain about

CREATING UTILITIES: This step in creating a file format isnt necessery But it is a hell of a lot easier to have a small program straight away that handles basic functions Like Viewing the file, editing the file and converting data from a existing format that is usefull (a .PCX file can be added to a 3d model as a texture) Without at least something to view the file you cant really be sure that what you just coded will work (we are assuming that you coded a converter from a existing format) There is allways a chance that you missed something so also be sure to test it with more than one file preferabbly with every file that you can imagine that is usable. This will hopefully ensure that everything is in working order. Also Be sure to try to anticipate EVERYTHING before you release your format. You wouldnt like to give out utils,examles,build a web page and even sell your format to some company only to find out that if a file is above a certain size it "accidentally" crases. Or even worse if your writing some kind of "language" only to find out its possible to write directly to memory above what it is ment to.

End Note: Sorry about no model file Its just that I couldnt find a example Good enough to add, and another downside is I dont have the specs for quake2's .MD2 format :(. Once I can get that I'll give out a reader for it. Here is a chalange for everyone with a copy of qb4.5 (Ive been trying to do this but I just cant do it)

I have my main module compiled into a .EXE it has the following routines in it


The .EXE also uses a routine in the Library called


In my library I have the following routines


The routine Main uses the following functions

readdata (IN .EXE)
drawpixel (IN .EXE)
grid (IN .EXE)

I need to be able to compile the .EXE and distribute it without the source code. BUT I ALSO NEED to be able to distribute the source code to the library so people can compile it and redistribute it for themselves. the only problem with this is that the Library wont compile without the routines in the .EXE being there. Im not sure how to fix this but it has become a problem. I would give out the source to the entire thing BUT I will be selling the program to the public (its HCRYPT) and I want to be able to let users create their own custom plugins. (All I really need to do is figure out how to declare a routine EXTERNAL)


BTW please help with that survey with the new engine. I need to know what to set as a minimum requirement

[ Back to Contents ]



More articles 'ere - from RudeJohn. These articles appear in separate HTML files in the Basix Fanzine directory - just click the links to begin your intellectual voyage:

useful programs demonstrating useful techniques



The program 13-lfn.bas demonstrates a number of long filename functions that can be used from BASIC.

"Freely distributed. May be used in other programs with proper notice of credit."

[ Back to Contents ]



If so, please email for details.

If you market a compiler or other BASIC-related product and want the DOS BASIC world to know about it, why not send in a review copy? It could be emailed to the address above (please ask first though, before you plant a massive binary in my mailbox) or, if you're kind enough, you could post a copy - email me for the address.


Thanks go to the following, in no particular order, their articles and source code used in this issue:

Well, that was the last fanzine for 1998 - the next issue, the January/February 1999 issue, will be released sometime around the end of December or the beginning of January.


Alex Warren,
7th November 1998

[ Back to Contents ]

[ Basix Fanzine Main Index ]