gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Two issues I need help with

#166837 - Lazy1 - Thu Feb 19, 2009 10:37 pm

Issue 1: Sound trouble
The new sound system has caused a few problems with sound playback in wolf3d.
Sounds that should play quickly like the sub machinegun play once and nothing else will play until that sound finishes.
I also cannot reserve channels on the arm7 for music playback, there are times where sound playback corrupts one of the music channels and makes it just play static.

Issue 2: It's stuck... somewhere
A very rare issue happens every now and then where the game will freeze for some time. Because wolf3d is fairly large I can't go dropping printfs everywhere and hope to catch where it is.
Desmume can debug but so far it hangs randomly making it useless for this and I lost my no$gba debug key. (I asked the author for help but got no response)

Any ideas on how to solve these would be greatly appreciated since they are the ones mainly holding me back now.

#166838 - a128 - Thu Feb 19, 2009 10:51 pm

why not use the defaultExceptionHandler() ?

look at the PC and look at the .map file.

#166839 - Lazy1 - Thu Feb 19, 2009 10:57 pm

I do install the default exception handler, it's not crashing but getting caught in a loop somewhere.

#166851 - elhobbs - Fri Feb 20, 2009 4:48 pm

does wolf3d malloc a huge block of ram on startup like other id games? if so may need to re-evalute how big of a chunk your are letting it grab as the newer releases of libnds tend to get a little bigger each time. I think wifi and fat need a little bit of free memory as I believe they both use malloc/free internally.

you might also try writing an alternating char on a text console, for instance in the upper left corner, during a vblank/hblank/timer interrupt. that could at least tell you if the arm9 is completely frozen vs in an infinite loop somewhere.

aside from that... good luck with those print statements ;)

#166852 - Lazy1 - Fri Feb 20, 2009 4:55 pm

As far as I know it doesn't, but I have seen the game unfreeze after being locked for a few seconds.
Maybe it's the timing code, it's been a while since I wrote it so maybe it's time to take another look.

Code:

#include <nds.h>
#include "../wl_def.h"
#include "../misc.h"

static long g_timerBaseMS = 0;
static long g_lastTime = 0;
static long g_timeCount = 0;

extern unsigned long totalVBlanks;

unsigned long getMS( void ) {
   return g_timerBaseMS + TIMER1_DATA;
}

void timer1Overflow( void ) {
   g_timerBaseMS+= 65536;
}

void init_TimeCount( void ) {
   irqSet( IRQ_TIMER1, timer1Overflow );
   irqEnable( IRQ_TIMER1 );

   TIMER0_DATA = 32768;
   TIMER0_CR = TIMER_DIV_1 | TIMER_ENABLE;

   TIMER1_DATA = 0;
   TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE | TIMER_IRQ_REQ;
}

void set_TimeCount( unsigned long time ) {
   g_lastTime = getMS( );
   g_timeCount = time;
}

unsigned long get_TimeCount( void ) {
   long timeDifference = getMS( ) - ( g_lastTime );

   return ( ( timeDifference * TickBase ) + ( g_timeCount * TickBase ) ) / 1000;
}

#169454 - Synthetic - Sun Jul 12, 2009 1:39 am

Lazy, I've been having the exact same problem with the freezing.

Did you ever figure out what was happening?

#169456 - Lazy1 - Sun Jul 12, 2009 3:42 am

Not really, ended up rewriting the port and the problem never came back.
The timing is closer to what it should be.

What exactly are you having trouble with?

#169487 - Synthetic - Fri Jul 17, 2009 4:58 am

Figured it out. It ended up being a lack of precision that accumulated until I stepped out of memory bounds. Very frustrating to track down.