pp256 ----- How it works - an easy reference -------------------------------- Well, I was becoming increasingly worried with the amount of tutorials on the site and I decided to write one on something easy! pp256 is not hard to understand, but some people seem to be having problems with it. To be fair, it does have some annoying niggles. So im gonna take you through step by step. Step 1 : Draw a picture ----------------------- There are numerous explinations to the actual working of this program im the documents it comes with, so basically select a size (bottom) clip it to that size, and then draw something! The "Add Image" function is what were really interested in. It adds an unrelated image to the file of the same size as the previous image. Its important you use this instead of making hundreds of different files, because its a hell of a lot easier, and takes up less memory. Step 2 : Sorting out memory --------------------------- Each image has a set number of bites assigned to it, so what you've really got to do is calculate it for the size of one image and then times that by the number of images in the file. Confused? Let me explain. Lets say you had an image which had 10 tiles in it, each of them 20*20 pixels big. To find out the area of one tile you do the following: [(X * Y) / 2] + 2 So for our 20*20 tile we do: [(20 * 20) / 2] + 2 This comes to 202 bytes. To find the area of the whole file you simply times that number by the number of images in the file. So for our 20*20 tile we do: 202 * 10 This comes to 2020 bytes. Step 3 : Creating a file array ------------------------------ Basicaly what we needed all that last stuff for was to enable us to create an array in Qbasic. For some reason, pp256 has one major "niggle" when it comes to that. It *always* needs to be put into a integer array, specifically! But instead of putting AS INTEGER on the end as normal, weve got to use a % symbol. The byte size goes in brackets on the end. Ok, so lets say we've got our 20*20*10 file, as in step 2. We want to call the tileset "ForestSet". We simply do this: DIM SHARED ForestSet%(2020) its that simple! Step 4 : Loading your file into the array ----------------------------------------- This is fairly hard to explain, as in used DEF SEG to change the address to that of the file. If you don't understand what this means, don't worry! Its not essential. Heres a worked example: DIM SHARED ForestSet%(2020) 'creates an array for our 'forest set. DEF SEG = VARSEG (ForestSet%(0)) 'points to the beggining 'of our array BLOAD "Forest.set", VARPTR(Forestset%(0)) 'loads the file 'Forest.set into the 'array DEF SEG 'returns to the Default 'Segemnt In the code this is often written on one line, seperated by colons: DEF SEG = VARSEG (ForestSet%(0)) : BLOAD "Forest.set", VARPTR(Forestset%(0)) : DEF SEG Understand? No? Well don't worry, just copy and paste the above code and you'll be OK! Step 5 : PUTing your pictures ----------------------------- Basically all you have to do to see different images is specify the bite of the picture in the put statement. You just point and put really. On the end of your average PUT statement, you just add a byte address which points to the picture your going to PUT. You work out the address by multiplying the picture number by the number of bytes specified for each pixel. For example, if we are using our 20*20 picture we take the byte value for one picture which is 202. In brackets multiply this by the number picture you want to have: (1 * 202) (2 * 202) Just add these byte finders on the end of your PUT statement, like this: PUT (0, 0), ForestSet%(1 * 202) Oh dear. Let me guess the wrong pictures are coming out arn't they? Thats because the first picture in the file starts at 0 , not 202 bites. So basically your picture 1 is actually picture 0, while your picture 2 is actually your picture 1. Just remember to take away one every time any you'll be ok! This Tutorial was writtem by: MidnightDreamer - MidnightDreamer@wongfaye.com --------------- Visit our Qbasic RPG site for the latest projects, and game related news: http://www.geocities.com/blackgatecorps Keep it real, Dreamer ...