Page 1 of 1

App run on Emulator not on NGAGE (code inside)

PostPosted: Dec 3, 2004 @ 5:12pm
by Twelvegames
This part of code make the App run good on WINS Emulator but crash on NGAGE hardware.

Lot of comments are added because is a test code to find the Bug:


#include "stdio.h"
#include "string.h"

#include "MyApplication.h"
#include "Screen.hpp"
#include "Scroll.hpp"
#include "FighterJoy.hpp"
#include "FighterCpu.hpp"
#include "Anim.hpp"
#include "File.hpp"
//#include "Sound.hpp" **SOUND**
#include "Joy.hpp"
#include "Errors.hpp"

//------------------------------------------------------------------------------------

CWorld::CWorld(void)
{
Graph.Init();
Scroll=new CScroll(this);
Intro=new CIntro(this);
File=new CFile(this);
}

//------------------------------------------------------------------------------------

CWorld::~CWorld(void)
{
delete File;
delete Scroll;
delete Intro;
}

//------------------------------------------------------------------------------------

bool
CWorld::Init(CGapiDraw *gapidraw)
{
GapiDraw=gapidraw;
int len;
char filename[256];
#ifndef FILES_FROM_RES
sprintf(filename, "Fighter.txt");
#else
sprintf(filename, "%sRES\\Fighter.txt",ROOT);
#endif
if (!File->OpenRead(filename, len))
{
return Error.InitFail("Fighter.txt Open Filed!");
}
char s[256];
File->Read(s,len);
File->Close();
s[len]='\0';
int lineend[32];
int curlineend=0;
for (int i=0; i<256; ++i)
{
if (s[i]=='\r')
{
s[i]=0;
lineend[curlineend++]=i;
}
}
strcpy(BACK_NAME,s);
strcpy(FIGHTER_1_NAME, &s[lineend[0]+2]);
strcpy(FIGHTER_2_NAME, &s[lineend[1]+2]);

// Util.Debug(BACK_NAME);
// Util.Debug(FIGHTER_1_NAME);
// Util.Debug(FIGHTER_2_NAME);

// Sound.Init(); **SOUND**
if (!InitMenu())
return false;
return true;
}

//------------------------------------------------------------------------------------

bool
CWorld::InitMenu(void)
{
CurMode=MODE_MENU;
JoyPad.SetAutoRepeat(false);
if (!Intro->Load("Start"))
return false;
return true;
}

//------------------------------------------------------------------------------------

bool
CWorld::InitFight(const char *backgroundName)
{
JoyPad.SetAutoRepeat(true);
strcpy(BackgroundName, backgroundName);
Scroll->LoadBackground(backgroundName);
VictoryBackLoaded=false;

/* FighterJoy=new CFighterJoy(this, FIGHTER_1_NAME,"",-90);
FighterCPU=new CFighterCPU(this, FIGHTER_2_NAME,"",90);
FighterJoy->SetOpponent((CFighter*)FighterCPU);
FighterCPU->SetOpponent((CFighter*)FighterJoy);
*/
return true;
}

//------------------------------------------------------------------------------------

void
CWorld::EndFight(void)
{
// delete FighterJoy;
// delete FighterCPU;
Graph.ReleaseSurfaces();
/* Sound.ReleaseWaves(); **SOUND**
Scroll->Release();*/
}

//------------------------------------------------------------------------------------

bool
CWorld::Update(void)
{
if (CurMode==MODE_MENU)
{
int ret=Intro->Update(JoyPad.Get());
if (ret>0)
{
Intro->Release();
CurMode=MODE_GAME;
if (!InitFight(BACK_NAME))
return false;
}
else if (ret<0)
{
}
}
else
{
// FighterCPU->Update();
// FighterJoy->Update(JoyPad.Get());
// Scroll->Update(FighterJoy->GetPosX(), FighterCPU->GetPosX());
Scroll->Update(160, 160);
/* if ((FighterCPU->IsDead() || FighterJoy->IsDead()) && !VictoryBackLoaded)
{
Scroll->Release();
char name[256];
sprintf(name,"%s_End",BackgroundName);
Scroll->LoadBackground(name);
VictoryBackLoaded=true;
}
else if (FighterCPU->IsFightFinished() || FighterJoy->IsFightFinished())
{
EndFight();
CurMode=MODE_MENU;
JoyPad.SetAutoRepeat(false);
Intro->Load("Start");
}*/
}
return true;
}

//------------------------------------------------------------------------------------

void
CWorld::Render(void)
{
if (CurMode==MODE_MENU)
{
Intro->Draw();
}
else
{
Scroll->CopyBuffer();
// FighterCPU->Render();
// FighterJoy->Render();
Scroll->Render();
// FighterCPU->DrawExtra();
// FighterJoy->DrawExtra();
}
}

//------------------------------------------------------------------------------------

void
CWorld::Release(void)
{
Graph.ReleaseSurfaces();
// Sound.ReleaseWaves(); **SOUND**
}

//------------------------------------------------------------------------------------