Links

ClassPad.fr

GaumerieLib is a library written in C++ and assembler containing advanced functions of gestion of the timers, as well as fast drawing bitmaps in grayscales functions. For more information about the use of this library, read the GaumerieLib article…

Image:Formatzip.png Image:Document.png
Download the library... Download the article...

Contents

 

Installation

This section describe how to use this library into an Add-In.


Integrate the library

At first, you must move all header files (.f) in the CP_Include directory of the ClassPad 300 SDK, then move GaumerieLib.lib in the Lib directory. All GaumerieLib functions are included in the file GaumerieLib.lib, then you must link them during the compilation. To built a program using this library, you must add an argument in the linker. To configure the linker using Dev-C++, open your project, [Project] > [Project Options], select "Parameters" tabs and type this in "Linker" :

library="C:\PROGRA~1\Casio\CLASSP~1\Lib\GaumerieLib.lib"

This example suppose that you have installed your ClassPad 300 SDK in the directory C:\Program Files\Casio\ClassPad 300 SDK\. You must rename the directory which have a name with spaces to a shorter name. For "Program Files", you must write the six first ones letters of the name using capital letters, the symbol "~", and generally, the number 1, the result is "PROGRA~1". If some other directory are named "Program" in the same folder of "Program Files", "Program" will have as short name "PROGRA~1é and "Program Files" will have as short name "PROGRA~2" (because "Program Files" comes after "Program" in alphabetical order).

If the directory is different, replace C:\PROGRA~1\Casio\CLASSP~1\ by installation folder.

Image:GaumeriLib1.png


Create a program

At first, GaumerieLib functions are not supported by the GCC compiler, then this is impossible to execute or debug an Add-In by using Windows. You must compil a .cpa file to transfer in on ClassPad 300. To include the library into a program, you must just include the file GaumerieLib.h.

Usage of various timers

This section present the difference between various types of timers which can be used by GaumerieLib functions.

High frequency Timers (SH3Timers)

SH3Timers are some 32 bits registry valuse of the processor which are incrementing with a fixed velocity. When the timer is finished and have the zero value, this timer take a fixed value and begin again. When the timer have a zero value, it write in an other registry which can be read and deleted. It exist 3 sort of SH3Timers which are identified by values SH3Timer::TIMER_0, SH3Timer::TIMER_1 and SH3Timer::TIMER_2. Les SH3Timers sont des registres à 32 bits du processeur qui se décrémentent à une vitesse fixée. Une fois la valeur d'un timer arrivé à zéro, ce timer reprend une valeur fixée et se décrémente à nouveau, et indique son passage à zéro dans un autre registre dont on peut lire la valeur et l'effacer. Il y a en tout 3 SH3Timers, identifié par les valeurs SH3Timer::TIMER_0, SH3Timer::TIMER_1 et SH3Timer::TIMER_2.

Control of SH3Timers

To initialize an SH3Timer, we must set up the velocity of increment and the value which it take after have had a zero value. You must use this two functions :

void SH3Timer::SetClockFreq(TIMER timer, FREQUENCE freq);
// Setup frequency
// timer must be SH3Timer::TIMER_0 or SH3Timer::TIMER_1 or SH3Timer::TIMER_2
// freq mus be SH3Timer::FRQ_3MHZ or SH3Timer::FRQ_920KHZ or SH3Timer::FRQ_230KHZ
// or SH3Timer::FRQ_57KHZ
// SH3Timer::FRQ_3MHZ = frequency of 3 682 419 Hz
// SH3Timer::FRQ_920KHZ = frequency of 920 385 Hz
// SH3Timer::FRQ_230KHZ = frequency of 230 147 Hz
// SH3Timer::FRQ_57KHZ = frequency of 57 538 Hz

void SH3Timer::SetTimerFreq(TIMER timer, unsigned int freq)
// Setup the initial value of the timer after have had a zero value
// timer mus be SH3Timer::TIMER_0 or SH3Timer::TIMER_1 or SH3Timer::TIMER_2
// freq is an integer

// Example : With a 57 538 Hz frequency, the timer decrement 57 538 units per second.
// With an initial value of 57538, the timer will have a zero value one time per second.
// With an initial value of 141 076 = 57 538 * 2, the timer will have a zero value 2 times per second.
// To setup the timer 0 to 57 538Hz with an initial value of 141 076, we must write
// SH3Timer::SetClockFreq(SH3Timer::TIMER_0, SH3Timer::FRQ_57KHZ);
// SH3Timer::SetTimerFreq(SH3Timer::TIMER_0, 141 076);

// To have the frequency or the initial value of a time, we must use this fonctions :
FREQUENCE SH3Timer::GetClockFreq(TIMER timer);
unsigned int SH3Timer::GetTimerFreq(TIMER timer);

It is possible to setup and obtain the current timer value at each moment :

void SH3Timer::SetCount(TIMER timer, unsigned int count);
// Setup the current value of a timer
// count must be an integer

unsigned int SH3Timer::GetCount(TIMER timer)
// Return the current value of a timer

To start and stop timers, four functions can be used :

void SH3Timer::Start(TIMER timer);
// Start a timer

void  SH3Timer::Stop(TIMER timer)
// Stop a timer

void SH3Timer::StartAll();
// Start all timers

void  SH3Timer::StopAll()
// Stop all timers
Warning ! Don't forget to stop all timers at the end of the program. When the program is finished, if some timers are working, they won't stop even if the classpad is switched off.

To know if a timer have had already the zero value and delete the indicator of his passage to this value, we must used this function at any time :

bool SH3Timer::HasUnderflowed(TIMER timer);
// Return true if the timer have had already a zero value and false else
// This can be used to make some operation with regular intervals during a loop. 

Note : SH3Timer isn't a class, this is only a naming space.

Real Time Clock (RTCClock) Real time clock is an internal clock which is active all the time and increment one time per second. Real time clock can be used to obtain date and time.

Setup Clock

To setup date and time, functions of real time clock are using a DateTime data structure defined by :

struct DateTime
{
    unsigned char uc_Seconde;   //  Second
    unsigned char uc_Minute;    //  Minutes
    unsigned char uc_Hour;      //  Hours
    unsigned char uc_WeekDay;   //  Day of the week
                                //  Possible values
                                //  RTC_WD_SUNDAY
                                //  RTC_WD_MONDAY
                                //  RTC_WD_TUESDAY
                                //  RTC_WD_WEDNESDAY
                                //  RTC_WD_THURSDAY
                                //  RTC_WD_FRIDAY
                                //  RTC_WD_SATURDAY
    unsigned char uc_Day;       //  Day
    unsigned char uc_Month;     //  Month
    unsigned char uc_Year;      //  2 last numbers of year
    unsigned char uc_MaskEnb;   //  Hide unused data
        /*  bit 0 : uc_Seconde          bit 4 : uc_Day
            bit 1 : uc_Minutes          bit 5 : uc_Month
            bit 2 : uc_Hour             bit 6 : uc_Year
            bit 3 : uc_WeekDay                              
            
            0 : hide      1 : show  */
        // A 0xFF (11111111 in binary) value show all parameters
        // We can simply define what we must show with this :
        // DT_ENB_SECONDE = 0x01 = 00000001
        // DT_ENB_MINUTE  = 0x02 = 00000010
        // DT_ENB_HOUR    = 0x04 = 00000100
        // DT_ENB_WEEKDAY = 0x08 = 00001000
        // DT_ENB_DAY     = 0x10 = 00010000
        // DT_ENB_MONTH   = 0x20 = 00100000
        // DT_ENB_YEAR    = 0x40 = 01000000
        // Then DT_ENB_SECONDE|DT_ENB_MINUTE|DT_ENB_HOUR show only
        // seconds, hours and minutes


    //  check if data are valid
    bool IsValid()
    {
        return !((uc_MaskEnb&0x01 && (uc_Seconde>0x59     ||  (uc_Seconde&0x0F)>9    ))|
                 (uc_MaskEnb&0x02 && (uc_Minute>0x59      ||  (uc_Minute&0x0F)>9     ))|
                 (uc_MaskEnb&0x04 && (uc_Hour>0x23        ||  (uc_Hour&0x0F)>9       ))|
                 (uc_MaskEnb&0x08 && (uc_WeekDay>6                                   ))|
                 (uc_MaskEnb&0x10 && (uc_Day>0x31         ||  (uc_Day&0x0F)>9        ))|
                 (uc_MaskEnb&0x20 && (uc_Month>0x12       ||  (uc_Month&0x0F)>9      ))|
                 (uc_MaskEnb&0x40 && (uc_Year>0x99        ||  (uc_Year&0x0F)>9       )));
    }
};

To create a DateTime object which have time and date 10:35:20 Vendredi 17 novembre 2006, and which keep all parameters, we must write :

DateTime dt = {20, 35, 10, RTC_WD_FRIDAY, 17, 11, 06, 0xFF};

An empty DateTime object is defined as:

DateTime dt;

To setup time with this object, or obtain the time, we must use this functions :

void RTCClock::SetDateTime(const DateTime& dt);
// Setup time with a DateTime object (in argument)

void RTCClock::AdjustSec();
// 
// Round of second to the previous minute(<=30 sec) or to the next minute (>30 sec)

void RTCClock::GetDateTime(DateTime& dt);
// Store date and time data in the DateTime object (in argument)

Then, to modify the state of the clock (on, off), we must use this functions:

void RTCClock::Run(bool state);
// Start (state=true) Stop (state=false)

bool RTCClock::IsRunning();
// Return true if clock is working, and false else.

Note : RTCClock isn't a class, this is only a namespace.

Alarm (RTCAlarm)

Alarm is based on Real Time Clock, but has currently no application because this is not possible to use the buzzer of the ClassPad depending of the state of the alarm and because only old models of ClassPad 300 have a buzzer.


Fast key test

This short section present a function which allow to make key test at any time. Furthermore this function allow to detect the pressure on several touches at the same time, Cette courte section présente une fonction permettant d'effectuer un test de touches à n'importe quel moment dans le programme. De plus, elle permet de détecter l'appui sur plusieurs touches en même temps, which is not possible with PegMessages.

Usage of GetKey GetKey namespace The namespace GetKey wears badly its name, because the function GetKey::GetKey doesn't return the code of the key currently pressed but return the state of a key (pressed or not).

Key codes are defined by :

GetKey::K_ONOFF    = 0x10  // ON/Off
GetKey::K_EXE      = 0x21  // EXE
GetKey::K_EXP      = 0x22  // EXP
GetKey::K_DOT      = 0x24  // .
GetKey::K_0        = 0x25  // 0
GetKey::K_OPPOSIT  = 0x26  // (-)
GetKey::K_PLUS     = 0x31  // +
GetKey::K_3        = 0x32  // 3
GetKey::K_2        = 0x34  // 2
GetKey::K_1        = 0x35  // 1
GetKey::K_MINUS    = 0x41  // -
GetKey::K_COMMA    = 0x36  // ,
GetKey::K_6        = 0x42  // 6
GetKey::K_5        = 0x44  // 5
GetKey::K_4        = 0x45  // 4
GetKey::K_RPAR     = 0x46  // )
GetKey::K_TIMES    = 0x51  // * (multiplication)
GetKey::K_9        = 0x52  // 9
GetKey::K_Z        = 0x53  // z
GetKey::K_8        = 0x54  // 8
GetKey::K_7        = 0x55  // 7
GetKey::K_LPAR     = 0x56  // (
GetKey::K_DIV      = 0x61  // / (division)
GetKey::K_POWER    = 0x62  // ^
GetKey::K_LEFT     = 0x63  // Left
GetKey::K_DOWN     = 0x64  // Bottom
GetKey::K_Y        = 0x65  // y
GetKey::K_X        = 0x66  // x
GetKey::K_BACK     = 0x71  // <-
GetKey::K_CLEAR    = 0x72  // Clear
GetKey::K_RIGHT    = 0x73  // Right
GetKey::K_UP       = 0x74  // Top
GetKey::K_KEYBOARD = 0x75  // Keyboard
GetKey::K_EQUAL    = 0x76  // =

This is the syntaxe of the function GetKey::GetKey :

bool GetKey::GetKey(KEY_CODE code);
// Return true if the touch is pressed and false else
// code must be one of the code previouly presented
// Warning, GetKey::GetKey(0x71) isn't accepted
// We must write GetKey::GetKey(GetKey::K_BACK)

Display functions

This section present the most interesting GaumerieLib functions : display function of bitmaps with greyscales.

Bitmaps objects

It existe four sort of bitmaps in GaumerieLib : GBitmap, GBitmap2, GImage and GImage2. Their definitions are very similar : two integer represent the size (pixels) of the bitmap and a number of buffers (Octets list)

GBitmap is the basic monochrome bitmap with one buffer. To convert a Windows image to a GBitmap, we can just use the convert tools of the ClassPad SDK to generate a PegBitmap, then we must just keep the list ROMDATA UCHAR[], and replace this type by ROMDATA UCHAR[], then create a GBitmap from this buffer and the bitmap size. For example :

// Code obtained from a Windows bitmap with the convert tools of ClassPad SDK

ROMDATA UCHAR uctest[8] = {
0x3c,0x7a,0xf1,0xfb,0xff,0xff,0x7e,0x3c,};
PegBitmap test = { 0x00, 1, 8, 8, 0x000000ff, (UCHAR *) uctest};

// Adapted code for a GBitmap
// To create a GBitmap, we can use the expression
// GBitmap bitmap = {largeur, hauteur, buffer};

unsigned char uctest[8] = {
0x3c,0x7a,0xf1,0xfb,0xff,0xff,0x7e,0x3c,};
GBitmap test = {8, 8, uctest};

GBitmap2 is a bitmap with one grayscale, it have two buffers. The rules of this buffers is :

Black + Black = Black

Black + White = Grey

White + Black = Grey

White + White = White


This is a simple example :

Image:GaumeriLib2.png

To create this bitmap, we must obtain two buffers (from the convert tools). This is an example :

// To create a GBitmap2, we can use the expression
// GBitmap2 bitmap = {width, height, buffer1, buffer2};

unsigned char uctest1[8] = {
0x00, 0x70, 0xe0, 0xe0, 0xf2, 0xfe, 0x7e, 0x3c,};
unsigned char uctest2[8] = {
0x3c, 0x7a, 0xf1, 0xfb, 0xff, 0xff, 0x7e, 0x3c,};
GBitmap2 test = {8, 8, uctest1, uctest2};

GImage is a bitmap wich allow to use transparency, it contain two buffers. The rules of this buffers is :

Black + Black = White

Black + White = Black

White + Black = Inverted

White + White = Transparent


This is a simple example (Blue-Green color represent transparency) :

Image:GaumeriLib3.png

The principle to create this bitmap is the same principle as previously :


// To create a GImage, we can use the expression 
// GImage image = {width, height, buffer1, buffer2};

unsigned char uctest1[8] = {
0x00, 0x70, 0xe0, 0xe0, 0xf2, 0xfe, 0x7e, 0x3c,};
unsigned char uctest2[8] = {
0x3c, 0x7a, 0xf1, 0xfb, 0xff, 0xff, 0x7e, 0x3c,};
GImage test = {8, 8, uctest1, uctest2};

GImage2 is a bitmap with one greyscal wich support transparency, it contain three buffers. The rules of this buffers is :

White + White + White = Transparent

White + Black + Black = Inverted

Black + White + White = Black

Black + Black + White = Grey

Black + White + Black = Gray

Black + Black + Black = White


This is a simple example (the blue-green color represent transparency) :

Image:GaumeriLib4.png

To create a GImage2 we just have to use the expression

GImage2 image = {width, height buffer1, buffer2, buffer3};

Draw on a monochrome screen

The size of the screen is : width : 160 pixels and height : 240 pixels. You must know that the screen is a buffer : it is a picture Il faut savoir que l'écran n'est autre qu'un buffer, c'est à dire an image on which we draw. GaumerieLib give an elementary type BITMAP wich is one unisgned octet unsigned char. A buffer can represent a back and white image,

Une liste d'octets (buffer) peut représenter une image en noir et blanc, indeed, the binary representation of each octet is a line of 8 pixels on the screen (0 = pixel off, 1 = pixel on). Then, the screen which have 160x240 = 38400 pixels have a buffer of 38400/8 = 4800 octets.

This is a simple example to understand :

Hexadecimal representation of a buffer :

0xFF,0xFF,0xC0,0x03,0x3F,0xFC

Binary representation of this buffer :

11111111,11111111,

11000000,00000011,
00111111,11111100

Result for a 16x3 image :

Image:GaumeriLib5.png

Result for a 14x2 image : We can see that pixels wich "overflow" are ignored.

Image:GaumeriLib6.png

It exist two ways to obtain a reference on the screen. If you are using the PEG library with the GaumerieLib, you can obtain temporary buffer reference of the screen. It is the image on which you draw after you use BeginDraw(), and which is posted on the screen after EndDraw().

BITMAP* screen = (BITMAP*)VRAM_ADRS;

If you don't want to use PEG, you can create an empty picture which have the screen size :

BITMAP buffer[4800] = {0x00};

You just have to edit this image and use the function CopyToScreen() with this image as parameter to copy it directly to the screen.

GaumerieLib contain a function CopyFromScreen() which allow to capture the screen.

BITMAP buffer[4800] = {0x00};
CopyFromScreen(buffer); // Capture the screen in buffer

// We make some operation on "buffer"
// ...

CopyToScreen(buffer);   // Then we post the result on the screen

But which sort of operations can we make on an image ?

At this time, GaumerieLib allow only to post image on the screen, there isn't any function to trace line, circle, rectangle or text on the screen.

It exist many similar function to post images :

// Posting of monochrome bitmap without transparency
// tuc_Src : bitmap source
// i_SrcWidth, i_SrcHeight : With and height bitmap which will be post
// i_x, i_y : Cords of the place on which we will post the image
// tuc_Dest : Destination bitmap
// i_DstWidth, i_DstHeight : With and height of the destination bitmap
// uc_type : Post type :        DRAWBITMAP_COPY > Post unmodified bitmap
//                              DRAWBITMAP_OR > Post black pixels
//                              DRAWBITMAP_XOR > Invert black pixels
//                              DRAWBITMAP_NOT > Give white color at black pixels
// Default :  DRAWBITMAP_COPY
inline void DrawBitmap(const BITMAP* tuc_Src, int i_SrcWidth, int i_SrcHeight,
    int i_x, int i_y,
    BITMAP* tuc_Dest, int i_DstWidth, int i_DstHeight,
    unsigned char uc_type = DRAWBITMAP_COPY);


// Display of monochrome bitmap with transparency
// tuc_Src1 : First bitmap buffer (bitmap source)
// tuc_Src2 : Second bitmap buffer (bitmap source)
//   Both buffers must have the same width
// i_SrcWidth, i_SrcHeight : Width and height of the bitmap source
// i_x, i_y : Coords  of the place on which we will post the image
// tuc_Dest : Destination bitmap
// i_DstWidth, i_DstHeight : With and height of the destination bitmap
// uc_type : Post type :        DRAWIMAGE_ORXOR > Display image with OR - XOR method
//                              DRAWIMAGE_NOTOR > Display image width AND – OR method
// Default : DRAWIMAGE_ORXOR
inline void DrawImage(const unsigned char* tuc_Src1, const unsigned char* tuc_Src2,
    int i_SrcWidth, int i_SrcHeight,
    int i_x, int i_y,
    unsigned char* tuc_Dest, int i_DstWidth, int i_DstHeight,
    unsigned char uc_type = DRAWIMAGE_ORXOR);

This method can be long and hard to be read, we can also use GBitmap and GImage classes. GaumerieLib offer a second version of this functions wich allow to reduce the parameters list.

// Displaying of a monochrome bitmap without transparency (GBitmap version)
// pGBmp_Src : bitmap source
// i_x, i_y : Cords of the place on which we will post the image
// pGBmp_Dest : destination bitmap
// uc_type : displaying type

inline void DrawBitmap(const GBitmap* pGBmp_Src,
    int i_x, int i_y,
    GBitmap* pGBmp_Dest,
    unsigned char uc_type = DRAWBITMAP_COPY);


// Displaying of a monochrome bitmap with transparency (version using many GBitmaps)
// pGBmp_Src1 : First bitmap source
// pGBmp_Src2 : Second bitmap source
// i_x, i_y : Cords of the place on which we will display the image
// pGBmp_Dest : destination bitmap
// uc_type : displaying type
inline void DrawImage(const GBitmap* pGBmp_Src1, const GBitmap* pGBmp_Src2,
    int i_x, int i_y,
    const GBitmap* pGBmp_Dest,
    unsigned char uc_type = DRAWIMAGE_ORXOR);

// Displaying of monochrome bitmap with transparency (GImage version)
// pImg_Src : Bitmap source with transparency 
// i_x, i_y : Cords of the place on which we will display the image
// tuc_Dest : destination bitmap
// i_DstWidth, i_DstHeight : With and height of the destination bitmap
// uc_type : Display type
inline void DrawImage(const GImage* pImg_Src,
    int i_x, int i_y,
    BITMAP* tuc_Dest, int i_DstWidth, int i_DstHeight,
    unsigned char uc_type = DRAWIMAGE_ORXOR);

We can note that width and height of bitmaps are not necessary, indeed, this bitmaps are integrated in GBitmap and GImage classes. The version of DrawImage() with GImage can't have as argument a GBitmap object as destination bitmap, but this functionality will probably added in the next version of the library.

Draw on the screen using greyscales

At this time, GaumerieLib allow to use only one Greyscal. The principle to obtain son grey on a monochrome screen is quite simple, we just have to make flicker a pixel quickly . To make this action, the "core" of GaumerieLib Greyscales use SH3Timer 0, in this case, you mustn't modify this timer if you are using greyscales in a program. Then we have a double screen, each buffer is display alternatively. Each of this buffers have a size of 160x240 (as the original screen).

At first, at the beginning of the program, we must initialize the "core" of greyscales with the function GrayScales::Initialize(), we have to create two bitmaps at the screen size. It exist two ways :

//////////////////////////////////////////////////
// Method 1 : we create two independent buffer

BITMAP screen1[4800] = {0x00};
BITMAP screen2[4800] = {0x00};

GrayScales::Initialize(); // Initialize the greyscales times
GrayScales::SetBuffers(screen1, screen2); // Link the two buffers at the screen
GrayScales::Start(); // Start the greyscales "core"

//////////////////////////////////////////////////
// Méthode 2 : on crée un GBitmap2

BITMAP screen1[4800] = {0x00};
BITMAP screen2[4800] = {0x00};
GBitmap2 screen = {160, 240, screen1, screen2};

GrayScales::Initialize();
// tuc_Bmp and tuc_Bmp2 are two buffer constituting a GBitmap
GrayScales::SetBuffers(screen.tuc_Bmp, screen.tuc_Bmp2);
GrayScales::Start();

The method with GBitmap2 is more easy to be used because the allow to use draw functions in greyscale on a GBitmap2, this is more simple on two isolated buffers. Any action on the buffers linked to the screen will be display on the screen instantaneously, we don't have to use a function. As the drawing on a monochrome picture, the drawing on a picture with greyscales allow only bitmap display on the screen. The functions are similar as the functions used in monochrome drawing.

// Displaying of a bitmap with greyscales and without transparency
// pGBmp2_Src : bitmap source
// i_x, i_y : Cords of the place on which we will display the image
// pGBmp2_Dest : destination bitmap
// uc_type : display type (DRAWBITMAP_COPY / OR / XOR / NOT)

inline void DrawBitmap2(const GBitmap2* pGBmp2_Src,
	int i_x, int i_y,
	GBitmap2* pGBmp2_Dest,
	unsigned char uc_type = DRAWBITMAP_COPY);

// Displaying of a bitmap with greyscales and with transparency
// pImg2_Src : bitmap source
// i_x, i_y : Cords of the place on which we will display the image
// tuc_Dest1, tuc_Dest2 : both buffers used to display bitmap destination
// i_DstWidth, i_DstHeight : With and height of the destination bitmap
// uc_type : Displaying type (DRAWBITMAP_COPY / OR / XOR / NOT)
inline void DrawImage2(const GImage2* pImg2_Src,
    int i_x, int i_y,
    unsigned char* tuc_Dest1, unsigned char* tuc_Dest2, int i_DstWidth, int i_DstHeight,
    unsigned char uc_type = DRAWIMAGE_ORXOR);

To stop the greyscales core, we just have to call Stop() and Restore() functions

// Restor the state of the timer used for greyscales.
void Restore();

// Stop the timer
void Stop();
Before quit the program, we must always stop the greyscales core, if not, it will be a non stopped timer which will continue to be active even if the ClassPad is off

Program model for games

This section offer a simple program model which can be reused easily to create a game using greyscales.

Source Code

Here is the source code of each file to be integrated.

bitmaps.h

BITMAP scrN[4800]  = {0x00};
BITMAP scrNG[4800] = {0x00};
GBitmap2 screen = {160, 240, scrN, scrNG};

main.cpp

///////////////////////////////////////////////////////////////////
// Globals vars and functions définition

// Libraries
#include <stdlib.h>
#include <string.h>
#include "GaumerieLib.h"
#include "bitmaps.h"

class PegPresentationManager {};
typedef unsigned char byte;
typedef unsigned char ID_MESSAGE;

// Fonctions externes
extern "C" {
    void LibGetTime2(byte *hour2, byte *minute2, byte *second2);
    void Bevt_Request_LaunchMenu(void);
}

///////////////////////////////////////////////////////////////////
// You have to define here all global vars                       //


///////////////////////////////////////////////////////////////////
// Game functions                                                //


///////////////////////////////////////////////////////////////////
// Main function

void main()
{
    // All is here
    // When we quit this function, the program is over
    
}

///////////////////////////////////////////////////////////////////
// Reserved zone, don't edit

void PegAppInitialize(PegPresentationManager *pPresentation)
{
    byte h, m, s;
    LibGetTime2(&h, &m, &s);
    srand(3600*(int)h+60*(int)m+(int)s);
    GrayScales::Initialize();
    GrayScales::SetBuffers(screen.tuc_Bmp, screen.tuc_Bmp2);
    GrayScales::Start();
    main();
    GrayScales::Stop();
    GrayScales::Restore();
    SH3Timer::StopAll();
    Bevt_Request_LaunchMenu();
}

extern "C" char *ExtensionGetLang(ID_MESSAGE MessageNo)
{
	return "";
}

Usage

The core of the program is in the main() function. A GBitmap2 for the screen has been created in bitmaps.h, it is named screen (default value).


About...

GaumerieLib is a C++ library developed by Alexandre Rion (Gaumerie). Tutorial written by Thê-Vinh Truong (Kilburn).