4.1 Building GCI DEMO .........................20 4.2 Building the Tiler Demo......................28 5. PoGa Explorer........................39 5.1 PoGa Screenshot........................39 5.2 Formatting the SD card to PoGa Format .................40 5.3 Adding Folders.........................42 5.4 Copying programs to the DISK....................43 5.5 Deleting programs from the DISK....................43 6.
Graphics Language), a cost effective way for you to be able to learn all about game development and programming. PoGa incorporates a 128 x 128 pixel full colour TFT display, 'standard' game console push button layout for controlling the game flow, a small loudspeaker for sound effects, and a micro SD card for storing images and game data.
Note: You will need a separate USB A-to-miniB cable to use with the uUSB-MB5 module. Note: The minimum size memory card you will need for the PoGa-Disk is 2Gb. To format the card and to add your games and applications you will need to use the PoGa-Explorer software tool that's included in the 4D Workshop3 IDE.
3. Creating your first PoGa Program All of the example program files used in this section can be found at ‘All Users\Shared Documents\4D Labs\PoGa Intro\’ folder (XP) or ‘Users\Public\Documents\4D Labs\PoGa Intro\’ folder (Vista and Windows 3.1 Your first PoGa Program...
Page 6
Portable Game Console PoGa-4DGL Reference Manual Click ‘New’ Icon or “New” in the File menu; Select ‘4DGL program’, if necessary. This will create a program with an empty shell, the 1 line is the platform type and will be filled in for you, if necessary, change this to PoGa-Goldelox by using the ‘Platform’...
Page 7
Portable Game Console PoGa-4DGL Reference Manual Now Press F9 which will compile your program, download it to your PoGa and start running it. You could also have clicked on “Comp’nLoad” which is the same thing. Click Comp'nLoad button Save the program with the file name 'helloworld.4dg' Snazzy it up Move the cursor and insert a new line before the ‘print’...
3.2 Writing your first PoGa game Start a new Program Click on the ‘New’ Icon again, the file type should be ‘4DGL program’, since that’s what you created last time, then click OK. The platform should be PoGa-Goldelox, since that’s what we selected last time.
Page 9
Portable Game Console PoGa-4DGL Reference Manual And now the main function, compile and download, saving it as 'Target.4dg'. func main() var i, newgame; SEED(peekB(SYSTEM_TIMER_LO)) ; newgame := 1 ; while(1) if (newgame == 1) // if this is a new game xcross := 63 ;...
3.3 Writing your second PoGa game Start a new Program Click on the ‘New’ Icon again, the file type should be ‘4DGL program’, since that’s what you created last time, then click OK. The platform should be PoGa-Goldelox, since that’s what we selected last time.
Page 11
Portable Game Console PoGa-4DGL Reference Manual And now the main function. func main() var i, j, xp, yp, xn, yn, newgame; SEED(peekB(SYSTEM_TIMER_LO)) ; newgame := 1 ; while(1) if (newgame == 1) for(i := 0; i < 16; i++) // randomise sliders SWAP(&posn[i],&posn[ABS(RAND() % 16)]) ;...
Page 13
Insert an ‘empty’ uSD card into your computer, Click on the chip icon. Save the GCS as EXPLODE. Click the Chip icon Select ‘4DGL – uSD Raw – GCI at Specified offset’ as the build type. Select the drive you inserted the uSD card into and a sector offset of 0.
Page 16
Insert an ‘empty’ uSD card into your computer , Click on the chip icon. Save the GCS as POGADOGTILED. Select ‘4DGL – uSD Raw – GCI at Specified offset’ as the build type. Select the drive you inserted the uSD card into and a sector offset of 0.
Page 17
Portable Game Console PoGa-4DGL Reference Manual Modify the TextTiler program Open TextTiler.4DG in workshop (if it isn’t still open). Add the following code at the start of the main procedure (immediately after the vars) . if(media_Init() == 0) // initialise and test the uSD card print("No uSD CARD\n");...
Page 18
Portable Game Console PoGa-4DGL Reference Manual Replace the updated tile writing at line 67 (if using the sample code, or approximately line 58 if cutting and pasting from this doc). Maybe shorten here. gfx_MoveTo(xp*TileSX, yp*TileSY) ; pokeB(TEXT_XMAG,3) ; pokeB(TEXT_YMAG,3) ;...
Page 19
Portable Game Console PoGa-4DGL Reference Manual Remove the uSD card from your computer and insert it into your PoGa. Save this as GFXTiler and compile and download. Note: You can cut and paste the programs from the test boxes in this chapter or find them in the ‘All Users\Shared Documents\4D Labs\PoGa Intro\’...
Up to 256 images/movies/animations can be stored within each PoGa file space and referenced with a special index list. For each PoGa file, storage of up to 3960 sectors (2,027,520 bytes) is available and can be accessed using the SelectGCIimage function. The position of each image entry is also saved, allowing you to build an entire screen of objects using the Graphics Composer as a WYSIWYG format.
Page 21
Portable Game Console PoGa-4DGL Reference Manual Once the required files are high-lighted, click the 'Open' button. Now click 'Open' to load these files Files should now be high-lighted The images have now all been dumped into the top left corner. Note that our 'Screen Size' is still left at 240x320, and also that the '10gear.gif' will obviously be too big to fit the 128x128 screen.
Page 22
Portable Game Console PoGa-4DGL Reference Manual In the 'Entries' list, click on '10-gear.gif and resize it. Single click on 10- Notice that the image is brought to the front, gear.gif to select it and high-lighted with the red dashed line Now adjust the width and height settings.
Page 23
Portable Game Console PoGa-4DGL Reference Manual Now change the screen size to 128 x 128. Now drag the images to the required positions. Click once on the object to select it (object is selected when you see the red rectangle around it) then press and hold down the mouse button to drag the object to the required position.
Page 24
Portable Game Console PoGa-4DGL Reference Manual Notice that each object that is selected/high-lighted shows its width, height, X position and Y position. These values can be manually adjusted by typing into the relevant text boxes or micro-positioned by clicking the adjustment arrows at the right hand side of each entry box.
Page 25
Portable Game Console PoGa-4DGL Reference Manual Then name the file 'GCI_Demo1' First, navigate to the Workshop folder, where we will keep all our GC Finally, click 'Save' housekeeping files Click the second radio button and navigate to the project folder.
Page 27
Portable Game Console PoGa-4DGL Reference Manual We have just created 2 files, GCI_Demo.DAT and GCI_Demo.GCI . The DAT file contains vital information about the GCI file. If you wish to have a quick look at the DAT file, navigate to the projects folder in the Workshop folder, right click on GCI_Demo.DAT and select notepad.
Portable Game Console PoGa-4DGL Reference Manual 4.2 Building the Tiler Demo The GFXTiler.4DG game currently uses the bitmap file PoGaDog.bmp. It can be found in the ...\4Dlabs\PoGa Intro\GFXTiler\Images folder. You may wish to change this image, so here is a description of how this can be achieved by taking you through the steps that were taken to create the tile map.
Page 30
Portable Game Console PoGa-4DGL Reference Manual Now change some of the setting as follows. Set the Tile Width and Tile Heigh to 32 Change screen size to 128 x 128 Click on 'Tiled' checkbox to select 'tiled' mode Screen should now look like this,...
Page 31
Portable Game Console PoGa-4DGL Reference Manual For this simple demo we are all done, now we save the project. It is best to save project files in a common place, the GC FILES folder within the Workshops Resources folder. Then name the file 'GFXtiler'...
Page 32
After we do this, we will then use the 'raw' mode, and load the GCI file directly to a uSD card and test the project. Select the second option so we can navigate to our 4DGL project folder and save the files Select the elipses button so we can...
Page 34
We will use these later for the PoGaExplorer demonstration where we will be using a menu program to select files stored on a PoGa disk, but for now, we will download the GCI file as raw binary to a uSD card at sector 0 so we can test out the GFXTiler.4DG program.
Page 35
Portable Game Console PoGa-4DGL Reference Manual If the uSD card contains a valid file format, you will get a warning that you are about to destroy it's formatting – remember, we are just saving 'raw' data to the card for this test which will over-write any...
Page 37
BLUE traffic light. You should see the platform information, and the capacity of the uSD card you are using. If all is ok, we are ready to program the PoGa.
Note - not the same as explorer, you need to click on folder to see if it has sub folders. • Bottom Right PoGa Files Panel - files applicable to PoGa Explorer may be dragged from this panel, from here you • can drag various items into the PoGa file.
Portable Game Console PoGa-4DGL Reference Manual PoGa Explorer makes extensive use of drag and drop tecniques - a brief explanation of things that can be dragged. Drag and drop to PoGa files panel to copy .4xe files. • Drag and drop onto file in PoGa files panel to insert graphics into PoGa file.
Page 41
Portable Game Console PoGa-4DGL Reference Manual Click on 'format' to format the drive, erasing any previous formats or data. If the drive already has eg a FAT format, you will get the following warning message. Click OK to continue and the formatting will start.
Portable Game Console PoGa-4DGL Reference Manual 5.4 Copying programs to the DISK Browse for the 4XE files. Drag it from the bottom right window and drop it in to the top right space. 5.5 Deleting programs from the DISK Right click on the file and click Delete.
PoGa Icon indicating success. Note: PoGa Disk structure details are in Appendix A. Now right click on the PoGa drive to activate the file menu, then right (or left) click on “New Poga Entry” to create a PoGa folder.
Page 45
Portable Game Console PoGa-4DGL Reference Manual We can now start importing some files to the “Demo's “ folder. First. Navigate to the 4D Labs project folder using the directory tree in the left pane. Open the GCI_Demo1 folder by double clicking on it, then click and hold down the left mouse button over the GCI_Demo1.4XE file, and drag it to the top pane, finally releasing the mouse button.
Page 46
Portable Game Console PoGa-4DGL Reference Manual Now we need to add the graphics file associated with the GCI_Demo1.4XE file, so double click on the Images folder to open it, and drag the GCI_Demo1.GCI file (the same way as you dragged the GCI_Demo1.4XE file) and drop it on top of the GCI_Demo1.4XE file.
Page 47
Notice that our executable program, and the graphics data, is visible in the properties window – they are now together in the PoGa file entry. Don't worry about the other blank fields at the moment, they will be explained later.
Page 49
Portable Game Console PoGa-4DGL Reference Manual PoGa Intro folder). Click and hold while dragging... Drag down to here below the other folders, then release mouse button When the mouse button is released, you will be asked for a filename, name the backup, then click the 'Save' button.
Before we can make anything happen, we must download the menu program to the PoGa. Remove the uSD card from the PC, and place it in the PoGa so we are ready. Open the 4D Workshop, and open the file named menu2.4DG.
(scan line rendering). PoGa is equipped with a sprite generator that is capable of rendering blocks of up to 16 pixels wide and 16 pixels high (sprite tiles) in up to 4 simultaneous colours. The sprite generator is also capable of 'transparency' where one of the 4 colours can be nominated as a transparent colour, ie.
We will now jump right in the deep end and create the cherry sprite using the Sprite Editor, and write a simple program in 4DGL to display it. The explanation of how it all works will unfold as you go.
Page 54
Portable Game Console PoGa-4DGL Reference Manual First thing we need to do is create a palette entry for our cherry so we have the correct colours to draw with so insert a palette into the “Palettes” list by clicking the “Insert” button under the palette list.
Page 55
Portable Game Console PoGa-4DGL Reference Manual Now we need to make a bitmap entry so we can start drawing. Click “Insert” to create a new sprite entry Notice that the Sprite Editor gives you 2 copies of the palette colours, one for the left mouse button, and one for the right mouse button.
Page 56
Portable Game Console PoGa-4DGL Reference Manual Continue to draw the rest of the pixels to complete the sprite. The green is a bit dull, so we will change it to LIME. Click in the GREEN radio button, scroll down in the “Standard colors” list, and select LIME.
Page 57
Navigate to the 4D Workshop folder where the Demo.inc file has been stored, and open it with your favourite text editor. Note that the PoGa Sprite Editor has created all the components we need and formatted them into data statements. It has also created some handy constants that we can use to refer to the various parts by name.
Page 58
Portable Game Console PoGa-4DGL Reference Manual #DATA word demo_sprites 32 words defining the sprite image //1) Cherry pixel pairs for the Cherry image 0x0000,0x0000, // line 0x0000,0x0000, // line 0x0000,0x0A00, // line 0x0000,0x0AA0, // line 2222 0x0000,0x008A, // line 22 2...
Page 59
Portable Game Console PoGa-4DGL Reference Manual We will now create a simple 4DGL program to display the cherry sprite. Open the 4D Workshop, start a new file. Select the new file to be a 4DGL program file. Type the following code into the editor.
Page 61
Then click the “Comp'n'Load” button, and if all is well you should see the following in the Workshop information panel, and you should see the sprite displayed on the PoGa. Now alter the program to the following by adding the lines marked in red, this will demonstrate the transparent effect.
Page 62
Portable Game Console PoGa-4DGL Reference Manual And finally, alter the program again to demonstrate rotation and magnification. #platform "PoGa-GOLDELOX" #inherit "4DGL_16bitColours.fnc" // we need to colour list for the sprites CLUT #inherit "Demo.inc" // inherit the demo sprite bitmaps func main() gfx_RectangleFilled(0,0,127,40,DARKGRAY);...
Portable Game Console PoGa-4DGL Reference Manual 7.2 Making few more Sprites Now that you have been shown how to make a single sprite, and display it on the screen in various ways. We will now add a few more sprites to the original work, and show how to animate them. First we will make a copy of the work we last did.
Page 64
We are going to take a bit of a shortcut, and show how to cut and paste some other sprites from another project into the AnimationDemo.inc file. Open the Workshop, open the file ...\4DLabs\PoGa Intro\Sprite_Demo0\demoAnimation.inc. (the file we just saved). We are going to cheat a little here, and copy and paste a few sprite entries from another file into our new demoAnimation.inc then feed it back to the Sprite Editor (so we don't have to...
Page 65
Portable Game Console PoGa-4DGL Reference Manual Now also open the file ...\4DLabs\PoGa Intro\ Sprite_Demo2\Demo2.inc . Now from the Demo2.inc file, copy lines 190 to 223 to the clipboard .Drag mouse with left button down over the area we wish to copy, releasing left button at end of copy region, then right click and select 'copy'.
Page 66
Portable Game Console PoGa-4DGL Reference Manual Now go to the demoAnimation.inc file by clicking its tab. Here is our current file, showing the position we are going to paste to. Left click at this point. We are going to paste HERE Now right click and select 'Paste' to paste the code.
Page 67
Portable Game Console PoGa-4DGL Reference Manual Make sure that the #END statement ended up on a line by itself. (should be on line 54). Now, save the file. Now its time to open the Sprite Editor again, and make some final modifications.
Page 68
PoGa-4DGL Reference Manual From the Workshop 3 toolbar, open the Sprite Editor. Open the file ...\4DLabs\PoGa Intro\ Sprite_Demo2\Demo2.inc again. Now we have the extra 2 sprites that we copied. Note that we only have the single palette which was intended for the cherry. Let's make the ghost look a bit different, then we will make some code to animate him.
Page 69
Portable Game Console PoGa-4DGL Reference Manual Click the palette insert button to create a new (default) palette, name the palette, then move the cherry palette back up (or the Ghost palette down) so things are in a logical order. Also, change the palette colours, you can have any colours you want, but keep the background BLACK.
Page 70
Portable Game Console PoGa-4DGL Reference Manual Note that you can select either palette, and any of the images to view them. Note also the reason for 2 ghosts shown slightly differently is so we can make him look like he is walking when we do the animation code.
Page 71
Portable Game Console PoGa-4DGL Reference Manual Now also add these 2 lines after line15 so we can at least just display them and take a look. Now hit the 'Comp'n'Load' button and test the code, you should see the 4 ghosts.
Page 72
Portable Game Console PoGa-4DGL Reference Manual Final editable version of SpriteGhostDemo.4DG source code. #platform "PoGa-GOLDELOX" #inherit "4DGL_16bitColours.fnc" // we need to colour list for the sprites CLUT #inherit "demoAnimation.inc" // inherit the demo sprite bitmaps func main() gfx_RectangleFilled(0,0,127,40,DARKGRAY); // set a background colour gfx_SpriteSet(demoanimation_sprites, demoanimation_colors, demoanimation_palette);...
PoGa-4DGL Reference Manual Appendix A: PoGa File System Overview The PoGa File System is a Fixed Block Architecture (FBA) in which each addressable record on disk is of the same size requiring no 'disk operating system'. It was designed to be as simple as possible, and the position of all files is determined simply by offset.
Page 77
FCB_GCI_DATE GCI file date, Padded with Blanks, Null terminated, STRING FCB_GCI_TIME GCI file time, Padded with Blanks, Null terminated, STRING FCB_PROG_SIZE 4DGL Program Size, WORD FCB_PROG_CSUM 59 4DGL Program Checksum, WORD FCB_DESC1 Reserved, padded with Blanks, Null terminated, STRING FCB_DESC2...
Page 78
Portable Game Console PoGa-4DGL Reference Manual Program Storage Area PROG nomenclature sector offset Byte Size F*4096 + 1 28160 GCI Image Map GCI image map at F*4096 + 56 (created with Graphics Composer, *.DAT file) There are up to 256 entries, Each entry is 32 bytes.
Page 79
Portable Game Console PoGa-4DGL Reference Manual Single Frame Image Format GCI nomenclature Byte Usage offset IMG_WIDTH_HI HI byte of image width IMG_WIDTH_LO LO byte of image width IMG_HEIGHT_HI HI byte of image height IMG_HEIGHT_LO LO byte of image height IMG_MODE...
Portable Game Console PoGa-4DGL Reference Manual Appendix C: Software/Driver Installation Guide 4D Workshop Visit 4D Workshop3 IDE Product page to download the latest 4D Workshop. It is a complete and free development platform that include Aid tools like, Graphics Composer, Sprite Editor and PmmC Loader.
Page 82
Now, plug in the uUSB-MB5, it should be detected by your system. Open 4D Workshop and open any 4DGL program. Now, plug in your uUSB-MB5 in to the PC, a new com port will be detected. As soon as you unplug the uUSB-MB5 it will vanish from the combo box.
Page 83
GOLDELOX, PICASO or the DIABLO by the user. Installing the PmmC Connect the uUSB-MB5 to the PC and the other end to the PoGa board. On the 4D Workshop3 IDE, Go to Tools Menu and click PmmC Loader to open up the PmmC Loader software tool.
Page 84
Port. Click Load Choose the Com port, locate the PoGa PmmC file downloaded from the website. Click Load. Check the Progress bar and wait for it to complete. On the Load Status you will get a “Programming Successful” notice as soon as PmmC programming is finished. Now, close the PmmC Loader. You are ready once again to develop and download your 4DGL code on the PoGa.
One of the things that Microsoft’s ‘User Account Control’ (UAC) does to ‘protect’ your computer is to prevent programs from using direct disk access. Both Graphics Composer and PoGa Explorer use direct disk access to manipulate the uSD card destined for PoGa..
Page 86
Portable Game Console PoGa-4DGL Reference Manual To turn off UAC in Windows 7, go to Control Panel, User Accounts, System and Security, Action Center, Change User Account Settings and set the level to ‘Never Notify’ and click OK. In both cases you will need to reboot for the changes to take effect.
Portable Game Console PoGa-4DGL Reference Manual Proprietary Information The information contained in this document is the property of 4D Systems Pty. Ltd. and may be the subject of patents pending or granted, and must not be copied or disclosed with out prior written permission.
Need help?
Do you have a question about the 4DGL and is the answer not in the manual?
Questions and answers