LameGuy64 wrote:Could you show some of your code? Mainly the image drawing part.
Here is one set of code I'm using, coming from Orion_'s libraries.
Code: Select all
#include "System.h"
#include "Sound.h"
#include "Sprite.h"
#include "DataManager.h"
//#define CD_AUDIO_EXAMPLE // Uncomment this to enable CD Audio Example
/******************************************/
GsIMAGE TIMimage;
GsSPRITE Sprite;
// This is a group of files we want to load
// My Data manager is set by default to load files data at address 0x80010000 which is the beginning of the user ram (see DataManager.h)
// But don't forget that we only have 2Mbytes of ram, and that our program is compiled to be loaded at the address 0x80100000 (see comp.bat)
// So this only give us 960Kbytes of free space for our data at one time ! don't forget it !
DataManager_Files game_datas[] =
{
{"sprite.tim", 0},
{"ui4.vag", 0},
{NULL, 0}
};
// These are corresponding index from the file above, it's easier to access using these name rather than index numbers
enum
{
SPRITE_TIM,
SOUND_VAG
};
/******************************************/
int main(void)
{
int i;
GsOT *ot;
int cputime, gputime;
int sx, sy;
// Init in 16bits 320x240
System_Init(MODE_PAL, VMODE_16BITS, 320, 240, GsNONINTER, 0);
System_SetBackgroundColor(255,255,255); // Set White background color
// Load our files (from cd or from pc depending on CDROM_RELEASE flag compilation)
DataManager_Init();
DataManager_LoadDatas("DATA", game_datas); // from the "DATA" folder
// Load TIM Images in VRAM from our loaded data files
Tim_Load(&TIMimage, game_datas[SPRITE_TIM].address);
// Init our sprite from the TIM image previously loaded in VRAM
Sprite_Init(&Sprite, &TIMimage, SPRITE_NORMAL, 0, 0, 256, 240);
// Load our sound in channel 0 from our previously loaded data
Sound_Init();
Sound_Load(0, game_datas[SOUND_VAG].address);
#ifdef CD_AUDIO_EXAMPLE
printf("Please Insert an Audio CD");
CdInit();
Sound_CD_Init();
printf("CD ntracks: %d\n", Sound_CD_GetNumTracks());
#endif
// Init Our Sprite Position in the middle for the screen
sx = 1;
sy = 1;
// Main Display Loop until we press Start button on pad
while (!IsPadPress(Pad1Start))
{
// This init our drawing, it return an OT pointer which is the table in which we will ask to draw
ot = System_InitFrame();
// Play our sound in channel 0 if Cross button is pressed on pad
if (IsPadTrig(Pad1Cross))
Sound_Play(0);
#ifdef CD_AUDIO_EXAMPLE
if (IsPadTrig(Pad1Triangle))
Sound_CD_Play(2, CD_REPEAT);
if (IsPadTrig(Pad1Square))
Sound_CD_Stop();
if (IsPadTrig(Pad1Circle))
if (Sound_CD_IsPlaying())
printf("Yes\n");
#endif
// Move the sprite if you press on the arrows on the pad
if (IsPadPress(Pad1Left))
sx--;
if (IsPadPress(Pad1Right))
sx++;
if (IsPadPress(Pad1Up))
sy--;
if (IsPadPress(Pad1Down))
sy++;
// Set the sprite position
Sprite_SetPosition(&Sprite, sx, sy);
// Ask to Draw the sprite in the OT
Sprite_DrawFast(&Sprite, ot);
// Ask to draw the OT on screen !
System_DrawFrame(ot, &cputime, &gputime); // You can print cputime and gputime to track how fast your program is, but you can also use NULL pointer if you don't mind.
}
System_Exit();
return (0);
}
My other set of code comes from this example on this site, but it does not produce anything on the screen.
Code: Select all
#include <sys/types.h>
#include <libetc.h>
#include <libgte.h>
#include <inline_c.h>
#include <gtemac.h>
#include <libgpu.h>
#define SCR_Z 507 // distant to screen
extern unsigned long TIMaddr[]; // background TIM
static u_long PadData;
static void initTexture(unsigned long *timAddr)
{
unsigned long bnum; // number of bytes
RECT rect; // LoadImage rectangle
timAddr++;
if (*timAddr & 8) // check CLUT flag
{
timAddr++; // load CLUT info
bnum = *timAddr;
timAddr++;
rect.x = *timAddr & 0xffff;
rect.y = *timAddr >> 0x10;
timAddr++;
rect.w = *timAddr & 0xffff;
rect.h = *timAddr >> 0x10;
timAddr++;
LoadImage(&rect,timAddr);
timAddr += (bnum >> 2) - 2;
}
else
timAddr += 2;
rect.x = *timAddr & 0xffff; // load pixel info
rect.y = *timAddr >> 0x10;
timAddr++;
rect.w = *timAddr & 0xffff;
rect.h = *timAddr >> 0x10;
timAddr++;
LoadImage(&rect,timAddr);
DrawSync(0);
}
int main(void)
{
DRAWENV drawenv;
DISPENV dispenv;
ResetCallback();
ResetGraph(0); // reset graphic subsystem (0:cold,1:warm)
SetGraphDebug(0); // set debug mode (0:off, 1:monitor, 2:dump)
PadInit(0); // initialise PAD
InitGeom(); // initialise geometry subsystem
SetGeomOffset(320, 240); // set geometry origin
SetGeomScreen(SCR_Z); // distance to viewing-screen
SetDefDrawEnv(&drawenv, 0, 0, 320, 240); // initialise environment
SetDefDispEnv(&dispenv, 0, 0, 320, 240);
dispenv.isinter = 1; // interlaced
drawenv.isbg = 0; // don't clear background
SetDispMask(1); // enable display (0:inhibit, 1:enable)
PutDrawEnv(&drawenv); // update drawing environment
PutDispEnv(&dispenv); // update display environment
initTexture(TIMaddr); // load TIMs
// VSyncCallback(0);
// StopCallback();
ResetGraph(3);
return 0;
}
I'm basically just copypasting code and changing the image, and changing the display resolution in the code.