PDA

View Full Version : FPC4NDS: first raw demo



Legolas
21-10-2006, 11:15 PM
This post to show you the result of a wasted saturday late evening: my first nds demo compiled by freepascal. :mrgreen:
Only for your eyes, here is a screenshot of the demo (as for the gba, a wonderful red pixel in the middle of the screen!):

http://itaprogaming.free.fr/img/fpc4nds.png

In short: it's a demo made using only the compiler, without rtl and without linker script/crt0 (yes, like the gba: stripping out things in the generated asm file :P)
Next step is to make a working crt0 and linker script (the step that drove me crazy with gba compiler...) and making a better rtl (the current nds rtl is only a draft made by the gba one).

WILL
21-10-2006, 11:23 PM
*has a vision of Legolas taking off shirt and start runing round the room waving it around screaming "Wooooooooooooooooooo Woooooooooooooo Yeeeeeeeah!! Woooo"*

:eh: ...umm, maybe not. :roll:


Nice work!!! :D

So who is gonna contact Nintendo for certification already? :P

savage
21-10-2006, 11:33 PM
Legolas you are a legend!
We need to get the likes of FPC shipping with Consoles!

Legolas
21-10-2006, 11:45 PM
*has a vision of Legolas taking off shirt and start runing round the room waving it around screaming "Wooooooooooooooooooo Woooooooooooooo Yeeeeeeeah!! Woooo"*

:eh: ...umm, maybe not. :roll:


Well, something similar... :clown:


Nice work!!! :D

So who is gonna contact Nintendo for certification already? :P

Unfortunately next steps will be tears'n'blood, so don't expect something working in the short :(
I'll need help from other people for asm, crt0 and ]Legolas you are a legend!
We need to get the likes of FPC shipping with Consoles![/quote]

:think: A limited edition of the NDS with the cheetah logo could be cool... :D

savage
08-11-2006, 08:08 AM
Any further good news?

Legolas
08-11-2006, 09:49 AM
At this time there is some ferment on fpc svn, because fpk & co. are submitting some deep changes in the sources. The bad thing is that I can't go on (every day too much changes to trace out) until they'll slow down all that updates; the good thing is that fpc himself is applying changes and fixing bugs in the gba stuff :D

Yesterday I have bought no$gba nds debugger (I'm waiting for the activation key), so hopefully it will help in porting process :wink:

savage
24-11-2006, 07:22 AM
Not sure if this is good news or not, but apparently the Nintendo Wii uses a Power PC.

Legolas
24-11-2006, 12:38 PM
Not sure if this is good news or not, but apparently the Nintendo Wii uses a Power PC.

Yes, and it shares the architecture with the gamecube, so it could be possible to use the gc docs for wii too. Though it's a bit early to think about a wii port... we need at least a way to load homebrew on it, jumping the "genuine check" ;)

{MSX}
24-11-2006, 01:13 PM
i would love to program in pascal for the wii :D
legolas, do your magic :)

WILL
24-11-2006, 04:07 PM
The last time that we tried to get Nintendo to take Object Pascal via Free Pascal to their licensed consoles they "didn't see a benefit" for it. I'm thinking that we need to show them the benefit. Petition anyone? ;)

Of course the Petition could use a few demos of what can be actually done with the GBA, NDS, GameCube and the Wii using FPC... Something impressive I think.

What do you think Sly? Could this be pulled off?

savage
24-11-2006, 06:25 PM
The last time that we tried to get Nintendo to take Object Pascal via Free Pascal to their licensed consoles they "didn't see a benefit" for it.

Just to clarify what Jason wrote, I actually wrote to Steve Okimot, Developer Relations Manager for Nintendo America, to find out if they would be interested in allowing Savage Software to supply "Third Party Tools" for the GBA, DS and possiblly the Wii and his response was...



We don't see a market for an alternative to C/C++ on Nintendo platforms. As a result, we are unable to approve your request for a Third Party Tools license.


The idea was that if Legolas was up for it, we would try and put together an offical Pascal for "Nintendo platforms" development environment. This of course does not mean we can't, only that it would have been better if we had had Ninendo approval. Considering that their SDKs cost between $2,500 to $20,000 per platform and that we would probably be undercutting them by offering them for around $500 or less, you can sort of understand their reluctance, though they probably don't make loads of money on their dev kits.

You can check out the cost of their SDKs @ http://www.warioworld.com/apply/.

Legolas
24-11-2006, 06:51 PM
The last time that we tried to get Nintendo to take Object Pascal via Free Pascal to their licensed consoles they "didn't see a benefit" for it.

Just to clarify what Jason wrote, I actually wrote to Steve Okimot, Developer Relations Manager for Nintendo America, to find out if they would be interested in allowing Savage Software to supply "Third Party Tools" for the GBA, DS and possiblly the Wii and his response was...



We don't see a market for an alternative to C/C++ on Nintendo platforms. As a result, we are unable to approve your request for a Third Party Tools license.


The idea was that if Legolas was up for it, we would try and put together an offical Pascal for "Nintendo platforms" development environment. This of course does not mean we can't, only that it would have been better if we had had Ninendo approval. Considering that their SDKs cost between $2,500 to $20,000 per platform and that we would probably be undercutting them by offering them for around $500 or less, you can sort of understand their reluctance, though they probably don't make loads of money on their dev kits.

You can check out the cost of their SDKs @ http://www.warioworld.com/apply/.

It's a pity... :cry:
Of course we could try to make a petition, but I fear that will be useless. Better could be to make something impressive, like a super fast/optimized demo or, at least, spread the world that fpc can be used to make games for nintendo consoles.

I know, it's a hopeless task, but we can try :rambo:

dmantione
24-11-2006, 09:27 PM
Try to maintain the contact, for example send the guy new demos's etc regularily. There is a big difference between an individual that is working on his latest toy and huge community (movement?) like Free Pascal. Perhaps after some months of preparations they understand this is serious and deserves support.

WILL
24-11-2006, 11:02 PM
Yeah, I agree with Daniel. I mean, it's just business to them, right? If we can sell the concept to them then they'll bite and we're in business.

BTW, hows Florian doing on those commits? Esp. the GBA ones. :D Is the way clear for the addition of a NSD target yet? I'm sure it's more than possible to officially put it under the 'in development' category at this point.

You know... at this rate FPC4GBA is going to eventually become FPC4Nintendo (FPC4Wii?) soon. :p

WILL
30-11-2006, 06:28 PM
So any news? :)

Legolas
30-11-2006, 08:51 PM
I need to find where is the rtl call that corrupts the executable. I'm using no$gba debugger, but I really don't know where to start :(
I have asked again some help to wintermute, but I haven't received an answer yet.
And, of course, by taking for granted that my changes in the crt0.s are good.
However, the compiler itself seems very good (and fast too!). It needs only some small fixes, like mapping mod and div calls to the nds bios routines.

WILL
01-12-2006, 02:36 PM
Ah excellent. :D

So what emulator can be considered the best for most of the featuring you'll need to test things out? Or I guess you'll be testing on actual hardware won't you?

Any plans for the first FPCl-made NDS demo? :)

Legolas
01-12-2006, 06:47 PM
The best emulator of nds is no$gba (http://nocash.emubase.de/gba-dev.htm).
:thumbup: the most advanced emulator of nds
:doh: the debugger is not free (15$).
:doh: it lacks source level debugging (you can buy it for 1750$ :shock:).

Another way to debug is to use the new GDB stub for Desmume emulator (http://forum.gbadev.org/viewtopic.php?t=11825).
:thumbup: free and open source
:thumbup: it works with gdb/insight, so source level is allowed
:doh: less advanced than no$gba
:doh: at this time it's very unstable

However no plans for a demo yet :(

WILL
01-12-2006, 07:27 PM
Hmm... well in that case I think I might have something you can use. ;)

It's a little demo I made just for fun some time ago using Delphi & DelphiX. Should be no problem porting it to FPC & GBA/NDS. :) Maybe you can use it as a GBA demo then enhance it further for the NDS.

It'll give me some idea of what I'd be dealing with should I eventually look at porting Garland to a handheld console.

WILL
01-12-2006, 07:34 PM
Also it seems that from what you are saying about the debugging, Lazarus would need some specific modifications to work as a decent development platform for the GBA/NDS?

I sense another tutorial/guide down the road. :P

Legolas
08-12-2006, 03:26 PM
I did it! I did it!!! :toocool:

FPC4NDS works pretty fine now... It needs some minor tuning only. To make it short: in order to link devkitPro library to FPC4GBA made executables, I have switched from arm-elf to arm-eabi. After a bit of mumbling, I have tried to do the same in FPC4NDS and this is the result :D
http://itaprogaming.free.fr/img/ndsdemo.png

Now I need to know how to handle 2 linker script with fpc without using external files (and - of course - without upsetting fpc's design rules...).
I'm thinking to something like a compiler switch or, (maybe) even better, a define like this:
{$define ARM7} / {$define ARM9}


PS. I'm happy like a kid in a toy store :mrgreen:

WILL
08-12-2006, 04:05 PM
Thats awesome! Very nice work. :thumbup:

So if you where to list the work to be done in a groceries list, what would we be seeing? :) And whats the estimated time-frame to completion? Of course that last question is only meant to be a wild figure... we all know these things take plenty of time. ;)

On a more technical note though, are you trying to compound the GBA and NDS targets? Whats the advantage, if any to that if thats the case?

I think I'll create a NDS platform section in the Free Pascal Wiki now. :) Though similar, I believe that the two targets should be separated for information sake.

Legolas
08-12-2006, 06:32 PM
So if you where to list the work to be done in a groceries list, what would we be seeing? :)
First of all, I'm waiting an answer from fpc guys to know how the compiler should handle two cpu. After this step, FPC4NDS could be released :)
Second, I need to convert some libnds headers. Keep in mind that now it is possible to ]
And whats the estimated time-frame to completion? Of course that last question is only meant to be a wild figure... we all know these things take plenty of time. ;)[/quote]
I hope to make a gift for Christmas for the PGD community ;)


On a more technical note though, are you trying to compound the GBA and NDS targets? Whats the advantage, if any to that if thats the case?
I'm thinking about that, but at this time is not a priority :)


I think I'll create a NDS platform section in the Free Pascal Wiki now. :) Though similar, I believe that the two targets should be separated for information sake.
Good work! :wink:

dmantione
08-12-2006, 07:50 PM
Another way to debug is to use the new GDB stub for Desmume emulator (http://forum.gbadev.org/viewtopic.php?t=11825).
:thumbup: free and open source
:thumbup: it works with gdb/insight, so source level is allowed
:doh: less advanced than no$gba
:doh: at this time it's very unstable

However no plans for a demo yet :(

This sounds interresting. If you have gdb working, it becomes then very easy to make the FPC IDE debug the program.

Legolas
10-12-2006, 01:44 AM
Another way to debug is to use the new GDB stub for Desmume emulator (http://forum.gbadev.org/viewtopic.php?t=11825).
:thumbup: free and open source
:thumbup: it works with gdb/insight, so source level is allowed
:doh: less advanced than no$gba
:doh: at this time it's very unstable

However no plans for a demo yet :(

This sounds interresting. If you have gdb working, it becomes then very easy to make the FPC IDE debug the program.

Yes, but at this time it allows breakpoints only and crashes every two breaths :roll:
Off course, if it will be improved, we (you! :D) could try to use it in the FPC IDE :)

savage
10-12-2006, 10:26 AM
Wow Great Stuff Legolas! Impressive stuff! So is there anything special that needs to be done to make it recognise the stylus input?

Legolas
10-12-2006, 11:09 AM
Wow Great Stuff Legolas! Impressive stuff! So is there anything special that needs to be done to make it recognise the stylus input?
Thanks :D
Well, the touch screen (http://www.bottledlight.com/ds/index.php/Misc/TouchScreen) is connected to a SPI bus, so it should be only matter of reading and writing data from this bus.
I have started to convert devkitPro's libnds headers, but h2pas can't help (I get a lot of internal errors). We are talking about 170 kb of c headers (:shock:) so, to speed up things, it could be nice to start an open conversion project, like quake2/3. If someone is interested to help, I could open a sourceforge account :think:

noeska
10-12-2006, 04:09 PM
Is it realy already possible to compile for the nds? Do you have an downloadable bare bones example? I would be willing to help, but unfortunately i do not have much time left to take on new projects.

savage
10-12-2006, 05:40 PM
I could open a sourceforge account :think:

I would say do it anyway, and people could jump in as and when they have time. Do you need to have assembler skills or us pure pascal enough?

Legolas
10-12-2006, 05:53 PM
Is it realy already possible to compile for the nds? Do you have an downloadable bare bones example? I would be willing to help, but unfortunately i do not have much time left to take on new projects.

In a word, yes, it is already possible, though I haven't committed the changes on the svn yet :)



I could open a sourceforge account :think:

I would say do it anyway, and people could jump in as and when they have time. Do you need to have assembler skills or us pure pascal enough?

I'll do ;)
And no, libnds sources are 95% pure c code. The only asm code is in the lib itself, and we need to translate the headers only ;)

WILL
10-12-2006, 06:13 PM
That sounds like a heck of a lot of headers? What are they all for? :lol: Can't just be for the stylus. :P

I guess it's almost every little thing to do with the NDS hardware huh?

Legolas
10-12-2006, 06:38 PM
That sounds like a heck of a lot of headers? What are they all for? :lol: Can't just be for the stylus. :P

I guess it's almost every little thing to do with the NDS hardware huh?

Two cpu, two cart ports, two screens, a touchscreen, audio, keys, filesystem and wifi: indeed it is a lot of stuff to handle :lol:

Edit: I have requested the account on sourceforge and now I'm waiting for the approval :wink:

WILL
10-12-2006, 07:27 PM
That sounds like a heck of a lot of headers? What are they all for? :lol: Can't just be for the stylus. :P

I guess it's almost every little thing to do with the NDS hardware huh?

FPK
12-12-2006, 04:07 PM
I have started to convert devkitPro's libnds headers, but h2pas can't help (I get a lot of internal errors).

h2pas works only semi automatic: start conversion, find first crash/error, fix/remove statement and continue.
BTW: You should also get internal errors only after a syntax error.

WILL
12-12-2006, 04:10 PM
Hey Florian, nice to see you on PGD! :)

So what exactly where the latest commits for the GBA platform? And whats the plan for fitting NDS into FPC in the near future?

Sorry, I'm always full of questions, aren't I? :lol:

Legolas
12-12-2006, 04:28 PM
I have started to convert devkitPro's libnds headers, but h2pas can't help (I get a lot of internal errors).

h2pas works only semi automatic: start conversion, find first crash/error, fix/remove statement and continue.
BTW: You should also get internal errors only after a syntax error.

I have resolved by doing all by hand. 85% it is only search and replace matter, so I'm proceeding very quickly. There is some construct that I can't translate 1:1, like bit fields inside a struct, but I'll provide some bit masking functions, if needed :)

Legolas
14-12-2006, 05:16 PM
Update: I have committed the changes on freepascal svn. Let me make a zip package and I'll release binaries soon :)

WILL
14-12-2006, 05:23 PM
And just as soon as I added the platform to the 3rd Party unofficial spot... I move it to the Official ones.... (I'm starting to see what Florian meant. :P)

FPK
14-12-2006, 05:41 PM
translate 1:1, like bit fields inside a struct, but I'll provide some bit masking functions, if needed :)

You can. FPC 2.1.1 supports bit packed records.

Legolas
14-12-2006, 05:49 PM
translate 1:1, like bit fields inside a struct, but I'll provide some bit masking functions, if needed :)

You can. FPC 2.1.1 supports bit packed records.

Nice! So if I have something like

typedef struct tPERSONAL_DATA {
u8 RESERVED0&#91;2&#93;; //!< ??? &#40;0x05 0x00&#41;.

u8 theme; //!< The user's theme color &#40;0-15&#41;.
u8 birthMonth; //!< The user's birth month &#40;1-12&#41;.
u8 birthDay; //!< The user's birth day &#40;1-31&#41;.

u8 RESERVED1&#91;1&#93;; //!< ???

---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---

packed_struct &#123;
unsigned language &#58; 3; //!< User's language.
unsigned gbaScreen &#58; 1; //!< GBA screen selection &#40;lower screen if set, otherwise upper screen&#41;.
unsigned RESERVED3 &#58; 2; //!< ???
unsigned autoMode &#58; 1; //!< The DS should boot from the DS cart or GBA cart automatically if one is inserted.
unsigned RESERVED4 &#58; 1; //!< ???
&#125;;
&#125; PACKED PERSONAL_DATA ;

how should I convert that packed_struct part? :think:

FPK
14-12-2006, 06:47 PM
translate 1:1, like bit fields inside a struct, but I'll provide some bit masking functions, if needed :)

You can. FPC 2.1.1 supports bit packed records.

Nice! So if I have something like

typedef struct tPERSONAL_DATA &#123;
u8 RESERVED0&#91;2&#93;; //!< ??? &#40;0x05 0x00&#41;.

u8 theme; //!< The user's theme color &#40;0-15&#41;.
u8 birthMonth; //!< The user's birth month &#40;1-12&#41;.
u8 birthDay; //!< The user's birth day &#40;1-31&#41;.

u8 RESERVED1&#91;1&#93;; //!< ???

---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---

packed_struct &#123;
unsigned language &#58; 3; //!< User's language.
unsigned gbaScreen &#58; 1; //!< GBA screen selection &#40;lower screen if set, otherwise upper screen&#41;.
unsigned RESERVED3 &#58; 2; //!< ???
unsigned autoMode &#58; 1; //!< The DS should boot from the DS cart or GBA cart automatically if one is inserted.
unsigned RESERVED4 &#58; 1; //!< ???
&#125;;
&#125; PACKED PERSONAL_DATA ;

how should I convert that packed_struct part? :think:

Using bitpacked and range types:



type
PERSONAL_DATA = bitpacked record
RESERVED0 &#58; array&#91;0..1&#93; of byte;

&#123; ... &#125;

language &#58; 0..7;
gbaScreen &#58; 0..1;
RESERVED3 &#58; 0..3;
autoMode &#58; 0..1;
RESERVED4 &#58; 0..1;
end;

JernejL
15-12-2006, 02:19 PM
Here's a piece of IRC chat i had with fpcfan on this topic, he asked me to post it here, he registered an account but is still waiting for an admin to approve it, so if you can speed that up it'd be great.


fpcfan I think the difference between arm7 and arm9 should be implemented by using the -Cparm7 and -Cparm9 switches
fpcfan and not but setting the apptype
fpcfan Legolas writes this on 8 december: Now I need to know how to handle 2 linker script with fpc without using external files (and - of course - without upsetting fpc's design rules...).
fpcfan I'm thinking to something like a compiler switch or, (maybe) even better, a define like this:
fpcfan Pascal Code:
fpcfan {$define ARM7} / {$define ARM9}

WILL
15-12-2006, 02:40 PM
Ah yes... he may or may not have mentioned this in the FPC Wiki page for NDS.

dmantione
15-12-2006, 02:45 PM
-Cp is to set the target processor within a cpu architecture. This is not the case here; as far as I understood a NDS needs two executables, one will run on the ARM7, the other on the ARM9. -Cp should never have an effect on the linker script.

The apptype should be used to specify what executable should be generated. Then the executable for the ARM9 can still be compiled in with a potential -Cparm9 to enable ARM9 instructions.

Legolas
15-12-2006, 03:37 PM
[quote="dmantione"]-Cp is to set the target processor within a cpu architecture. This is not the case here; as far as I understood a NDS needs two executables, one will run on the ARM7, the other on the ARM9. -Cp should never have an effect on the ]

Yes, it works in this way. I was thinking about a couple of defines because, depending on arm9 or arm7, I should use a different library too: in fact libnds is divided in two parts (libnds7.a and libnds9.a) and in the headers I have found a lot of "#ifdef arm9" and "#ifdef arm7". As far as I have read, I can't detect apptype at compile time, so I'm investigating about a way to reorganize libnds headers

Vincent
15-12-2006, 06:24 PM
I (fpcfan) still don't understand it.

In what way is a the relation between ARM7 and ARM9 different from the relation between a Pentium and a 80386? Can't an ARM9 run ARM7 code? Are they much more different from each other than Pentium IV and 80386?

Maybe the -P command line parameter is a better option then.

Legolas
15-12-2006, 06:51 PM
I can't find -P command line in the documentation online. What about it?

However, the only reason for apptype was that arm9 and arm7 binaries for nds need two different prt0 and linker script, and that seemed the best way to handle it. If we'll find a better way, it can be changed, of course :)


BTW, I have uploaded the binaries :mrgreen:

Vincent
15-12-2006, 07:31 PM
I can't find -P command line in the documentation online. What about it?
It is badly documented indeed :-(

It is a parameter to pass to fpc, so that it selects the correct ppcXXX for the target. For example to compile for arm-wince, I could do:
fpc -Parm -Twince.

[quote]However, the only reason for apptype was that arm9 and arm7 binaries for nds need two different prt0 and ]
I don't know what is hetter, using {$apptype} just felt wrong, no 'hard evidence'.

FPK
15-12-2006, 07:32 PM
I don't know what is hetter, using {$apptype} just felt wrong, no 'hard evidence'.

As said on irc, the correct solution would be probably having two targets ndsarm7 and ndsarm9 but this is over engineering.

WILL
15-12-2006, 07:36 PM
Well as I mentioned to fpcfan (Vincent) in IRC the ARM7 was put into the NDS simply for backwards compatibility for GBA games so if you're gonna make a NDS game you might aswell just use ARM9. :)

Legolas
15-12-2006, 08:02 PM
Well as I mentioned to fpcfan (Vincent) in IRC the ARM7 was put into the NDS simply for backwards compatibility for GBA games so if you're gonna make a NDS game you might aswell just use ARM9. :)
Not only :D
Well, in fact the touch screen can be accessed only by arm7, though data are stored in a structure that can be accessed by arm9 :)

WILL
15-12-2006, 08:50 PM
ok refresh my memory again

ARM7 = newer than ARM9?

thus:

GB/GBC = z80
GBA = ARM7 + z80 (GBA SD = ARM7 only)
NDS = ARM9 + ARM7

Please correct me where I am in error.

Legolas
15-12-2006, 09:09 PM
ok refresh my memory again

ARM7 = newer than ARM9?


ARM9 = newer than ARM7


GB/GBC = z80
GBA = ARM7 + z80 (GBA SD = ARM7 only)
NDS = ARM9 + ARM7


Yes, but:

GBA = GBA SP = ARM7 + z80
GBA Micro = ARM7 only

WILL
15-12-2006, 09:33 PM
SP thats what it was! :P

Wasn't sure if the z80 was left out of the SP or not...

Micro for sure... smaller form factor.

dmantione
15-12-2006, 10:03 PM
I (fpcfan) still don't understand it.

In what way is a the relation between ARM7 and ARM9 different from the relation between a Pentium and a 80386? Can't an ARM9 run ARM7 code? Are they much more different from each other than Pentium IV and 80386?



The NDS simply has two types of executables. If you make an ARM7 executable you can access the touch screen for example. The NDS firmware simply treats them in a different way. The difference between these two executables is in ]
Maybe the -P command line parameter is a better option then.
[/quote]

No, generating two different compiler executables doesn't look like it solves anything.

WILL
16-12-2006, 11:55 PM
My theory is that it's simply nothing to do with instruction sets, but CPU speeds, cache, etc...

The fact that the double screen can only be accessed with the older CPU makes no sense though... wouldn't you want the most power for your dual screen games? :scratch:

Maybe I'm just falling into the PC developer's line of thinking.

Legolas
17-12-2006, 01:19 PM
First libnds conversion attempt is available here:
http://sourceforge.net/projects/libndsfpc

Some TODOs here and there, but it should work... well, I get some errors on no$gba, but it works on Dualis emulator and - most important thing - on real hardware :mrgreen:

In order to work with libnds, you will need to install devkitPro for Nintendo DS (http://www.devkitpro.org).
You can grab the libnds pascal headers from SF SVN (ok, I'll find a way to generate a zipped snapshot :P). My web page is down (for some strange reason does not process php and returns a scaring 500 ISE), but you can get fpc4nds from freepascal ftp (ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/arm-nds) (about 3.7 MB).

I suggest you to start from this tutorial (http://www.dev-scene.com/NDS/Tutorials), that explains very well all nds coding aspects.
libnds porting is 1:1, so converting c code should be a trivial task :)

A couple of hints:

program main;
{$apptype arm9} //...or arm7
{$define ARM9} //...or arm7, according to apptype

{$mode objfpc}

uses
ctypes; // required by nds headers!

{$include nds.inc} // headers!


// Some libs required by libnds (you will need to install devkitPro!)
{$linklib libc.a}
{$linklib libgcc.a}
{$linklib libsysbase.a}

{$linklib libnds9.a} //...or libnds7.a, according to apptype

begin

while true do; // Infinite loop, otherwise Dualis emulator will suddenly close!

end.


In order to make your code working:

ppcarmnds.exe -g --gc-sections -Tnds main.pp
You will get main.arm9.bin or main.arm7.bin, according to the apptype. The last step is to convert the binary with ndstool:

ndstool -c main.nds -9 main.arm9.bin
if your application is arm9 only code, or

ndstool -c main.nds -9 main.arm9.bin -7 main.arm7.bin
if your application is both arm9 and arm7

FPK
17-12-2006, 01:55 PM
First libnds conversion attempt is available here:
http://sourceforge.net/projects/libndsfpc


Since nds is in fpc svn, why not putting this stuff into fpc/packages/extra/ndsunits of the fpc svn?



In order to make your code working:

ppcarmnds.exe -g --gc-sections -Tnds main.pp
You will get main.arm9.bin or main.arm7.bin, according to the apptype. The last step is to convert the binary with ndstool:

ndstool -c main.nds -9 main.arm9.bin
if your application is arm9 only code, or

ndstool -c main.nds -9 main.arm9.bin -7 main.arm7.bin
if your application is both arm9 and arm7

Maybe this call can be integrated into the compiler too?

Legolas
17-12-2006, 02:26 PM
First libnds conversion attempt is available here:
http://sourceforge.net/projects/libndsfpc


Since nds is in fpc svn, why not putting this stuff into fpc/packages/extra/ndsunits of the fpc svn?


Of course I'll put this lib on fpc svn. I have opened an account on sf in order to get some help in translation: there is a nice function for recruitment, and I can give writing permission to pgd people that want to help (well, when someone will ask :P)





In order to make your code working:

ppcarmnds.exe -g --gc-sections -Tnds main.pp
You will get main.arm9.bin or main.arm7.bin, according to the apptype. The last step is to convert the binary with ndstool:

ndstool -c main.nds -9 main.arm9.bin
if your application is arm9 only code, or

ndstool -c main.nds -9 main.arm9.bin -7 main.arm7.bin
if your application is both arm9 and arm7

Maybe this call can be integrated into the compiler too?

If it is matter of building an arm9 only code, then no problem, but how about arm7 and arm9 mixed sources?

Btw, a question: now I'm defining ARM9 after the apptype call, in order to make some ifdefs inside the headers working. There is a way to check the apptype at compile time, or maybe a way to declare a "global define" inside the nds compiler?

FPK
17-12-2006, 03:59 PM
First libnds conversion attempt is available here:
http://sourceforge.net/projects/libndsfpc


Since nds is in fpc svn, why not putting this stuff into fpc/packages/extra/ndsunits of the fpc svn?


Of course I'll put this lib on fpc svn. I have opened an account on sf in order to get some help in translation: there is a nice function for recruitment, and I can give writing permission to pgd people that want to help (well, when someone will ask :P)


Ok, though they could also get access to fpc svn dirs ;)



If it is matter of building an arm9 only code, then no problem, but how about arm7 and arm9 mixed sources?


The ndstool -c main.nds -9 main.arm9.bin call could be done if the apptype is arm9 to simplify things for starters, no?



Btw, a question: now I'm defining ARM9 after the apptype call, in order to make some ifdefs inside the headers working. There is a way to check the apptype at compile time, or maybe a way to declare a "global define" inside the nds compiler?

No. You've to set the defines when the apptype changes.

Legolas
17-12-2006, 06:39 PM
If it is matter of building an arm9 only code, then no problem, but how about arm7 and arm9 mixed sources?


The ndstool -c main.nds -9 main.arm9.bin call could be done if the apptype is arm9 to simplify things for starters, no?


Yes, but leaving arm9.bin file too, that will be used in case of mixed sources. Though a starter could be confused because in this way the compiler will create two executables instead of one (main.nds and main.arm9.bin)

noeska
24-12-2006, 05:38 PM
Why gnu gpl/lgpl license for the lib conversion?

The original states:



Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto)

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.

Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.


I feel much better with this, as with gpl and glpl your own application has to be gpl/lgpl. E.g. for lgpl you may not compile the lib into your own application as i understand, when you do it is the same as gpl. So for me that is no commercial use (not that that is going to happen soon :-) ).

Is there a possibility to get rid of the gpl/lgpl and use the original license or a bsd license?

Legolas
24-12-2006, 06:53 PM
Yep! That's an error in my editor's auto-header script, that adds this standard infos in all files I edit. The correct license is the original you have quoted ;)

noeska
24-12-2006, 08:31 PM
some example sources:

http://www.noeska.com/downloads/helloworld.zip

http://www.noeska.com/downloads/openglex1.zip

http://www.noeska.com/downloads/openglex2.zip

Thanks for your great work legolas!

EDIT: legolas: i had not recieved your email before posting this :(

Legolas
24-12-2006, 08:39 PM
some example sources:

http://www.noeska.com/downloads/helloworld.zip

http://www.noeska.com/downloads/openglex1.zip

http://www.noeska.com/downloads/openglex2.zip

Thanks for your great work legolas!

You're welcome :D

As I have said you in email, tomorrow I'll upload some 2d/3d/sound examples I have converted from devkitPro :wink:

Joshas
01-02-2007, 10:44 AM
Thanks for examples, they helped me to get started with fpc4nds. Now I'm playing around with console and trying to convert some of the simplier examples from c at some rather noobish level ;) I still have much to learn about programming for DS, so if anyone has to share anything (sample source, some programming tips, etc.), it would be very usefull.

Legolas
01-02-2007, 01:26 PM
Nice to see someone that is playing with fpc4nds :D
A couple of hints: at this time libndsfpc works only with devkitPro r19 (I'm working on it to make changes needed), so don't update to r20, or you can't compile anymore. Get the last libndsfpc sources from svn, because I have resolved a couple of major bugs.
Last thing: I have already translated libnds examples (2d and nehe), but I haven't found the time to upload them on my web page :(
I hope I'll put online all examples as soon as I update fpclibnds to dkP r20

WILL
01-02-2007, 02:25 PM
Also don't forget about the PGD Christmas Demo which Francesco released the source for: Link (http://www.pascalgamedevelopment.com/viewtopic.php?p=29501#29501)!

Plays background music, sound effects, graphics, handles stylus input, etc...

And welcome to PGD, Joshas! :)

Joshas
01-02-2007, 05:42 PM
at this time libndsfpc works only with devkitPro r19
Strange, I'm using r20 (didn't know about incompatibility) and I was able to compile noeska's demos without problems (haven't tested on real hardware, but in no$gba everything works).

Thanks for the link WILL, nice demo, hope it'll be usefull for me in near future.

UPDATE: after some experimenting I noticed that nds files compiled with FPC are twice as big as the ones compiled with default c compiler, is this because of lack of optimisations while compiling with FPC?