Ps1, PS2, PS3, PSP, psvita, PS4, Xbox, Xbox360, Xbox one, Xbox Series S | X, nintendo WiiU, nintendo 3DS, nintendo Switch, Android, PC (Steam and Windows Store), Mac, Linux, web
I am currently developing a special engine for the PS1 version but I have a problem is that I do not know if I am doing it wrong but I load three different TIMs for example
MENU.TIM
AR.TIM
HOWTO.TIM
one goes in main, the other is in an int MTLX (VOID)
the other in int MTLXp (VOID)
even there it works but when I add the four VOID
int MTLXr (VOID)
and SCENE1.TIM is when the problem starts
, the point of programming or visual novel is to pass images and lyrics with music.
Obviously I already have it about the images and the music as well, about the programming is where there are problems because when adding the FOUR TEXTURE, in the emulator an illegal code error appears
"r3000: executed illegal opcode 4f1b4f1b"
or
"translate_address: illegal physical address 02a43350"
Postdata.-I load the information of the images through an .asm file
I attach code
main.c
Code: Select all
#include <sys/types.h>
#include <libetc.h>
#include <libgte.h>
#include <inline_c.h>
#include <gtemac.h>
#include <libgpu.h>
#include <LIBPAD.H>
// #define SCR_Z 507 // distant to screen
// #define PADLeft 0x8000
// #define PADDown 0x4000
// #define PADRight 0x2000
// #define PADUp 0x1000
// #define PADStart 0x800
// #define PADR3 0x400
// #define PADL3 0x200
// #define PADSelect 0x100
// #define PADSquare 0x80
// #define PADCross 0x40
// #define PADCircle 0x20
// #define PADTriangle 0x10
// #define PADRB1 0x8
// #define PADLB1 0x4
// #define PADRB2 0x2
// #define PADLB2 0x1
// u_char padData[34]; // Raw pad data
// u_short padButtons = 0; // Complete 16bit button state from bytes 3 & 4 of padData
// u_char padIsAnalog = 0; // boolean for analog detection
// #define PadButtonDown( b ) ((padButtons & b) == 0)
extern unsigned long TIMaddr[]; // background TIM
extern unsigned long TIMaddr1[]; // background TIM
extern unsigned long TIMaddr2[];
extern unsigned long TIMaddr3[];
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);
}
static void initTexture1(unsigned long *timAddr1)
{
unsigned long bnum; // number of bytes
RECT rect; // LoadImage rectangle
timAddr1++;
if (*timAddr1 & 8) // check CLUT flag
{
timAddr1++; // load CLUT info
bnum = *timAddr1;
timAddr1++;
rect.x = *timAddr1 & 0xffff;
rect.y = *timAddr1 >> 0x10;
timAddr1++;
rect.w = *timAddr1 & 0xffff;
rect.h = *timAddr1 >> 0x10;
timAddr1++;
LoadImage(&rect,timAddr1);
timAddr1 += (bnum >> 2) - 2;
}
else
timAddr1 += 2;
rect.x = *timAddr1 & 0xffff; // load pixel info
rect.y = *timAddr1 >> 0x10;
timAddr1++;
rect.w = *timAddr1 & 0xffff;
rect.h = *timAddr1 >> 0x10;
timAddr1++;
LoadImage(&rect,timAddr1);
DrawSync(0);
}
static void initTexture2(unsigned long *timAddr2)
{
unsigned long bnum; // number of bytes
RECT rect; // LoadImage rectangle
timAddr2++;
if (*timAddr2 & 8) // check CLUT flag
{
timAddr2++; // load CLUT info
bnum = *timAddr2;
timAddr2++;
rect.x = *timAddr2 & 0xffff;
rect.y = *timAddr2 >> 0x10;
timAddr2++;
rect.w = *timAddr2 & 0xffff;
rect.h = *timAddr2 >> 0x10;
timAddr2++;
LoadImage(&rect,timAddr2);
timAddr2 += (bnum >> 2) - 2;
}
else
timAddr2 += 2;
rect.x = *timAddr2 & 0xffff; // load pixel info
rect.y = *timAddr2 >> 0x10;
timAddr2++;
rect.w = *timAddr2 & 0xffff;
rect.h = *timAddr2 >> 0x10;
timAddr2++;
LoadImage(&rect,timAddr2);
DrawSync(0);
}
static void initTexture3(unsigned long *timAddr3)
{
unsigned long bnum; // number of bytes
RECT rect; // LoadImage rectangle
timAddr3++;
if (*timAddr3 & 8) // check CLUT flag
{
timAddr3++; // load CLUT info
bnum = *timAddr3;
timAddr3++;
rect.x = *timAddr3 & 0xffff;
rect.y = *timAddr3 >> 0x10;
timAddr3++;
rect.w = *timAddr3 & 0xffff;
rect.h = *timAddr3 >> 0x10;
timAddr3++;
LoadImage(&rect,timAddr3);
timAddr3 += (bnum >> 2) - 2;
}
else
timAddr3 += 2;
rect.x = *timAddr3 & 0xffff; // load pixel info
rect.y = *timAddr3 >> 0x10;
timAddr3++;
rect.w = *timAddr3 & 0xffff;
rect.h = *timAddr3 >> 0x10;
timAddr3++;
LoadImage(&rect,timAddr3);
DrawSync(0);
}
int main(void)
{
int padStatus;
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);
padStatus = PadRead(1);
if (padStatus && PADLright)
{
MTLX();
}
return 0;
}
int MTLX(void)
{
int padStatus;
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(TIMaddr1);
padStatus = PadRead(1);
if (padStatus & PADLright)
{
MTLXp();
}
else if (padStatus & PADLleft)
{
main();
}
// load TIMs
// VSyncCallback(0);
// StopCallback();
ResetGraph(3);
return(0);
}
int MTLXp(void)
{
int padStatus;
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(TIMaddr2);
padStatus = PadRead(1);
if (padStatus & PADLright)
{
if (padStatus & PADLright)
{
MTLXr();
}
}
else if (padStatus & PADLleft)
{
MTLX();
}
// load TIMs
// VSyncCallback(0);
// StopCallback();
ResetGraph(3);
return(0);
}
int MTLXr(void)
{
int padStatus;
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(TIMaddr3);
padStatus = PadRead(1);
if (padStatus & PADLright)
{
return(0);
}
else if (padStatus & PADLleft)
{
MTLXp();
}
// load TIMs
// VSyncCallback(0);
// StopCallback();
ResetGraph(3);
return(0);
}
DATAFILE.ASM
opt C+
section datasection
global TIMaddr
cnop 0,4
global TIMaddr1
cnop 0,4
global TIMaddr2
cnop 0,4
global TIMaddr3
cnop 0,4
TIMaddr:
incbin "MENU.tim"
cnop 0,4
TIMaddr1:
incbin "HOWTO.tim"
cnop 0,4
TIMaddr2:
incbin "AR.tim"
cnop 0,4
TIMaddr3:
incbin "AR.tim"
cnop 0,4
PD.-i solved the problem thx