dsdoom source

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

dsdoom source

Post by happy_bunny » Tue May 03, 2011 8:59 am

Hi

I am looking into porting chocolate doom

http://www.chocolate-doom.org/wiki/inde ... olate_Doom

to the ds (mainly so I can understand nds and doom better), I have looked at the source for chocolate doom and it uses libsdl to access all low level hardware (inputs / screen etc) how does dsdoom handle this via libnds I assume ? is the source code of dsdoom available ? so I can try and understand how libnds is used with PrBoom.

elhobbs
Posts: 354
Joined: Thu Jul 02, 2009 1:19 pm

Re: dsdoom source

Post by elhobbs » Tue May 03, 2011 8:10 pm

yes and yes

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Tue May 03, 2011 10:09 pm

source code for ds doom lives at

http://code.google.com/p/dsdoom/

I am trying to compile it using the latest libnds, any ideas on how to solve this error message

gba_nds_fat.c:312:8: error: 'IPC' undeclared (first use in this function)

which is refering to this bit of code

#ifdef NDS
return (
( ( (IPC->rtc_hours > 11 ? IPC->rtc_hours - 40 : IPC->rtc_hours) & 0x1F) << 11) |
( (IPC->rtc_minutes & 0x3F) << 5) |
( (IPC->rtc_seconds >> 1) & 0x1F) );
#else

User avatar
Izhido
Posts: 107
Joined: Fri Oct 19, 2007 10:57 pm
Location: Costa Rica
Contact:

Re: dsdoom source

Post by Izhido » Tue May 03, 2011 10:47 pm

The IPC structure is no longer present in libnds since quite a few releases ago.

These lines seem to be related to the date & time of the device. Today you can obtain that info using standard C functions (time, localtime, mktime, strftime, you get the idea).

I think you'll need to spend some quality time with dsdoom's sources, to substitute IPC stuff with the "new" functions (hehe)...

Also, I think you'll do considerably good to yourself, and us all, if you convert this project to an ARM9 project. Any ARM7-only functionality, as of today, is now provided with the ARM9 template, so you shouldn't have any significant problems converting to it.

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Fri May 06, 2011 10:47 am

I replaced arm7/arm7_main.cpp with the default one from examples /examples/nds/template/combined/arm7

to get the source code to compile ;-) however its crashs at this line

DSgetUserName(); // essential, retrieves username via Fifo buffer.

is their any examples on how to talk to the arm7 or how DSgetUserName(); was used in the old libnds ?

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Sun May 08, 2011 9:55 pm

sorry DSgetUserName(); is called and defined within i_main.c (not libnds) this function uses fifo messages to get the ds user name. is there a defined way of doing this in libnds 1.5.0 ? or do I need to follow examples/nds/userfifo and setup my own message structurer ?

secondly I have got dsdoom running using the template for arm7 code (examples/nds/template/combined/arm7) heres the diff patch

http://www.megaupload.com/?d=JTKAFZCX

and modified source code

http://www.megaupload.com/?d=55O36YSO

however wifi is not working (its not compiled in, I had to comment it out in config.h) and sound effects are not working ;-( also open close / lid detection is commented out. apart from wifi these issuse are because I am not talking to arm7 properly. any help / pointer on how to do the following would gratefully recieved (I think they all need to be done via arm7)

1) get ds user name
2) get lid close / open detect working
3) blink standby led (when lid is closed)
4) get sound effects working again

the source above has been tested with the first level of doom1 shareware with no sound game play is a bit flat, hopefully I will be able to fix this with a little help.

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Mon May 09, 2011 10:29 pm

changed DSgetUserName() to use

int nameLen = PersonalData->nameLen;

and

DS_USERNAME = (char)PersonalData->name & 255;

now I can display the user name at startup ;-) next question how did I get the power led to blink I tried

ledBlink(0x30);

however that didnt work any ideas why it didnt ?

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Tue May 10, 2011 9:13 am

in i_main.c at the start of main after powerOn(POWER_ALL); I removed these lines

REG_EXMEMCNT=0xe800;
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;

irqInit(); // Enable our quintessential vblank interrupt
irqSet(IRQ_VBLANK, NULL);
irqEnable(IRQ_VBLANK);

now ledBlink(0x30) works ok, and keyHeld() works correctly ie lid open / close detect is working again and I can run within the doom game again. Does anyone understand why remove these lilne effects ledblink or keyheld functions ???

elhobbs
Posts: 354
Joined: Thu Jul 02, 2009 1:19 pm

Re: dsdoom source

Post by elhobbs » Tue May 10, 2011 12:08 pm

Lid detect and led blinking require arm7/arm9 communications. These are established before main is called in current versions on libnds. The lines you removed were interfering with that setup. Primarily irqinit was causing problems but you are correct in removing the rest as well.

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Tue May 10, 2011 10:34 pm

thanks for the info ;-)

In the new libnds I can use setBrightness( int screen, int level) to set the brightness of both screens

but how can I tell the difference between a ds and dslite using the new libnds code ? also how can I find out the default brightness value at startup ?

I want to do something like this

if(dslite){
setBrightness( 3, default_brightness + 1)
}

to replace the old DStoggleBrightness(); function in the dsdoom code

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests