Author Topic: Hanging Program  (Read 4137 times)

jxv (OP)

  • *
  • Posts: 38
Hanging Program
« on: November 20, 2009, 04:43:50 am »
After I successfully compile my program as told in this method.
It hangs in the menu screen (with all the APP files) as a result of selecting to run my "target.app" file (241kb) on my Dingoo, but it works with MS VC++ 2008. Did anyone else have this problem? Should I be doing something different?

Thanks.

alekmaul

  • *
  • Posts: 330
    • Portabledev
Re: Hanging Program
« Reply #1 on: November 20, 2009, 07:07:05 am »
Well, not very easy to help you without any source code :/
Could you post some part of your  program to help us ?

PS : the link seems not to work on dingoo digital
Quote
The page you requested does not exist. For your convenience, a search was performed using the query articles tutorials s2dsdk installation.

jxv (OP)

  • *
  • Posts: 38
Re: Hanging Program
« Reply #2 on: November 20, 2009, 12:10:51 pm »
oops, sorry about the link. This one works.

Code: (GameEngine) [Select]

#include "../inc/GameEngine.h"
#include "../inc/Sprite.h"
#include "../inc/Level.h"
#include "../inc/Character.h"
#include "../inc/Platform.h"
#include "../inc/Battle.h"

AniSprite *ani;
Level *level;
Character *character;
Platform *platform;
Platform *platter;
Battle *battle;
AniSprite* pas;
AniSprite* ps;
//Surface
int A320_SCREEN_WIDTH = 320;
int A320_SCREEN_HEIGHT = 240;
float scale = 1.0f;
bool direction = false;
//--------------------------------------------------------------------------------------------------------
GameEngine::GameEngine( void* userdata [] ) :
Engine( userdata )
{
m_pAudioData = NULL;
ani = new AniSprite;
level = new Level;
character = new Character;
platform = new Platform;
platter = new Platform;
battle = new Battle;

platform->setConstPlatform(new ConstPlatform(120,30));
platter->setConstPlatform(new ConstPlatform(46,15));
pas = new AniSprite;
Color pc(99,22,102,255);
Color pc1(7,201,102,255);
pas->setLoop(-1);
pas->addSprite(new Sprite(120,31,pc));
pas->addSprite(new Sprite(120,30,pc1));
platform->getConstPlatform()->addImage(pas);

ps = new AniSprite;
ps->setLoop(-1);
ps->addSprite(new Sprite(46,15,pc1));
ps->addSprite(new Sprite(46,15,pc));
platter->getConstPlatform()->addImage(ps);
platter->setX(50);
platter->setY(140);
ani->setLoop(-1);
Color ct(255,255,255,255);
Color cr(66,66,66,255);
ani->addSprite(new Sprite(A320_SCREEN_WIDTH,A320_SCREEN_HEIGHT,ct));
ani->addSprite(new Sprite(A320_SCREEN_WIDTH,A320_SCREEN_HEIGHT,ct));
ani->addSprite(new Sprite(A320_SCREEN_WIDTH,A320_SCREEN_HEIGHT,cr));
ConstAniSprite* cas = new ConstAniSprite;
cas->addSprite(new Sprite(24,48));
cas->addSprite(new Sprite(29,48));
character->getConstCharacter()->addConstAniSprite(cas);

level->addPlatform(platform);
level->addPlatform(platter);

level->getConstLevel()->addBackground(ani);

battle->setLevel(level);

}
//--------------------------------------------------------------------------------------------------------
GameEngine::~GameEngine( void )
{
Free();
}
//--------------------------------------------------------------------------------------------------------
/// init all resources
result GameEngine::Init( void )
{
InitDLRes();
// 16 FPS
SetFPS( 24 );

return S2D_OK;
}
//--------------------------------------------------------------------------------------------------------
/// free all resources
void GameEngine::Free( void )
{
ReleaseDLRes();
SAFE_DELETE_ARRAY( m_pAudioData );
}
//--------------------------------------------------------------------------------------------------------
/// game logic before render
void GameEngine::Exec( void )
{
}
//--------------------------------------------------------------------------------------------------------
/// game logic after render
void GameEngine::Exec2( void )
{
}
//--------------------------------------------------------------------------------------------------------
/// pre-render proccess
void GameEngine::PreRender( void )
{
//game->run();

level->update();
level->setScale(scale);
if(direction == false){
scale += 0.05f;
}else{
scale -= 0.05f;
}
if(scale >= 1.0f){
direction = true;
}
if(scale <= 0.2f){
direction = false;
}
}
//--------------------------------------------------------------------------------------------------------
/// render
void GameEngine::Render( void )
{


Sprite *framebuffer = level->render();
for(int i = 0; i < framebuffer->getHeight() && (i + framebuffer->getY() - framebuffer->getYCenter() < A320_SCREEN_HEIGHT); i ++){
for(int j = 0; j < framebuffer->getWidth() && (j + framebuffer->getX() - framebuffer->getXCenter() < A320_SCREEN_WIDTH); j++){
if(j + framebuffer->getX() - framebuffer->getXCenter() > -1 ){
Color color = framebuffer->getPixel(j,i);
if(color.getA() > 0){
PutPixel(i + framebuffer->getY()  - framebuffer->getYCenter(),j+framebuffer->getX() - framebuffer->getXCenter()  ,color.getR(),color.getG(),color.getB());
}
}
}
}
delete framebuffer;
}
//--------------------------------------------------------------------------------------------------------
void GameEngine::PostRender( void )
{
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::DispDebugInfo( void )
{
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::EnterGame( s32 MapId )
{
}
//--------------------------------------------------------------------------------------------------------
void GameEngine::PlayMusic(u32 ID,bool bRep)
{
if(!m_bUseAudio){
return;
}
if(ID>=m_AudioCnt){
return;
}
m_pAudioPlayer->Play(&m_pAudioData[ID],0,m_pAudioData[ID].GetLength(),255,bRep);
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::StopMusic()
{
m_pAudioPlayer->Stop(0);
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::PlaySound(u32 ID)
{
if(!m_bUseAudio){
return;
}
if(ID>=m_AudioCnt){
return;
}
for(s32 i=1;i<AudioPlayer::MaxChannels;i++){
if(m_pAudioPlayer->GetState(i) != AUDIO_PLAYING){
m_pAudioPlayer->Play(&m_pAudioData[ID],i,m_pAudioData[ID].GetLength(),255,false);
return;
}
}
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::StopAllSound()
{
m_bUseAudio = false;

m_pAudioPlayer->StopAll();
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::ExitGame( void )
{
Exit();
}

//--------------------------------------------------------------------------------------------------------
void GameEngine::LoadCfg(void)
{
// get full filename with path
Char fullname[256];
s2d::strcpy( fullname, _LS(".\\lltconfig.sdt") );

FILE* m_fp = fopen( fullname, _LS("rb") );

if(m_fp == NULL){
return;
}

// read file to memory
fseek( m_fp, 0, SEEK_END );
s32 size =  ftell(m_fp);

s32* mem = (s32*)  malloc( size );
s32* pstar = mem;

fseek(m_fp, 0, SEEK_SET );
fread( mem, size,m_fp );
fclose(m_fp);

s32 Scene = *(s32*)mem;

free( pstar );
}
//--------------------------------------------------------------------------------------------------------
void GameEngine::SaveCfg(void)
{
// get full filename with path
Char fullname[256];
s2d::strcpy( fullname, _LS(".\\lltconfig.sdt") );

FILE* m_fp = fopen( fullname, _LS("wb+") );

if(m_fp == NULL){
return;
}

s32 Scene=5;
fwrite(&Scene, sizeof(s32),m_fp );

// close file
fclose(m_fp);
}
//--------------------------------------------------------------------------------------------------------
void GameEngine::PutPixel(int x, int y, u8 r,u8 g, u8 b )
{
Pixel* ptr = m_pDraw2D->GetVRAMPtr();
Pixel color1(r,g,b);
s32 ofs = (x*A320_SCREEN_WIDTH) + (y);

ptr[ofs] = color1;
}

Another question, is the windows version of the program just as fast or slower or faster than the dingoo version of the program?
« Last Edit: November 20, 2009, 12:13:59 pm by jo3_sum »

alekmaul

  • *
  • Posts: 330
    • Portabledev
Re: Hanging Program
« Reply #3 on: November 20, 2009, 12:33:49 pm »
Ok, you're using the s2dsdk, you're right, it's easiest for windows testing ^^.
In my opinion, windows is faster than dingoo.
I took a look at your source code and here are some points to see :
- you do lot's of thing in constructor, are you sure it's not better in Init Method to avoid pb with canvas (if it's just object creation, of course, you're right to do this here).
- try disabling all things in the render method to see if the hanging is still here

- if all seems ok, try to take a look somewhere when you can use trick to speed things with 32 bits pointer assignment for 16bits or 8 bits memory area, it can hangs DIngoo for memory disalignement problem (change that for 8bits even if it's slower).

Except that , i can't see actually something wrong , sorry :O !

Also, in your ccpm directory, is the compilation ok without any suspect warning ?

jxv (OP)

  • *
  • Posts: 38
Re: Hanging Program
« Reply #4 on: November 20, 2009, 01:10:14 pm »
It appears to be something wrong with the source code, because the helloworldpixel example works on my dingoo.

jxv (OP)

  • *
  • Posts: 38
Re: Hanging Program
« Reply #5 on: November 20, 2009, 02:12:04 pm »
Now the pixels are all out of place, so I've been messing with the placement "(y*WIDTH) + x" ..., but I had no luck with it so far.

alekmaul

  • *
  • Posts: 330
    • Portabledev
Re: Hanging Program
« Reply #6 on: November 20, 2009, 03:56:49 pm »
so , it's no more hanging  ??? sorry i don't understand your last reply  ???

jxv (OP)

  • *
  • Posts: 38
Re: Hanging Program
« Reply #7 on: November 21, 2009, 12:51:02 am »
It hangs at when I compile the full source(even without init in the constructor), but the modified version work, so I'll try to fix the full version on my own. But before, the modified version of the program displaced the pixels incorrectly due to the GameEngine::PutPixel function:

Code: [Select]

void GameEngine::PutPixel( int x, int y, u8 r,u8 g, u8 b )
{
Pixel* ptr = m_pDraw2D->GetVRAMPtr();
Pixel color1(r,g,b);
#ifndef __Win32__
s32 ofs = (y*A320_SCREEN_WIDTH) + (x);//for windows
#else
s32 ofs = (y)+ (A320_SCREEN_WIDTH - 1 - x) * A320_SCREEN_HEIGHT;//for dingoo
#endif

ptr[ofs] = color1;
}

alekmaul

  • *
  • Posts: 330
    • Portabledev
Re: Hanging Program
« Reply #8 on: November 21, 2009, 06:32:21 am »
Ok, i understand ^^
The pixel function is perhaps buggy because default screen is not the good one (it's reverse).
Do you have such code in loader.cpp in ccmp directory ?
Quote
   // ???????޸???Ļ?ֱ???
   int SCREEN_WIDTH = 320;
   int   SCREEN_HEIGHT = 240;


   void* userdata[5];
   
   userdata[0] = AppFullName;
   userdata[1] = g_FilePath;
   userdata[2] = fullpath;
   userdata[3] = (void*)&SCREEN_WIDTH;
   userdata[4] = (void*)&SCREEN_HEIGHT;

jxv (OP)

  • *
  • Posts: 38
Re: Hanging Program
« Reply #9 on: November 21, 2009, 03:54:30 pm »
Ok, i understand ^^
The pixel function is perhaps buggy because default screen is not the good one (it's reverse).
Do you have such code in loader.cpp in ccmp directory ?
Quote
   // ???????޸???Ļ?ֱ???
   int SCREEN_WIDTH = 320;
   int   SCREEN_HEIGHT = 240;


   void* userdata[5];
   
   userdata[0] = AppFullName;
   userdata[1] = g_FilePath;
   userdata[2] = fullpath;
   userdata[3] = (void*)&SCREEN_WIDTH;
   userdata[4] = (void*)&SCREEN_HEIGHT;

Oh, I see. The screen height and width were switched on my "Loader.cpp" I think that should fix it aswell. Thanks.

jxv (OP)

  • *
  • Posts: 38
Re: Hanging Program
« Reply #10 on: November 22, 2009, 09:28:46 am »
I figured out why it was hanging. It hung because the dingoo was trying to load up more memory in ram than can fit. This was because my Sprites' pixels were stored as:
Code: [Select]
pixels[512][512]
But now they are stored as
Code: [Select]
*pixels
using pixels[x + y * width] to access one

 

Post a new topic