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.

Beginners > Borland Delphi?

#13246 - LiquidIce - Tue Dec 09, 2003 11:58 pm

Hello

I have recently played some Gameboy Advance and this site has made me interested in doing some GBA development. I am 18 years old and I have been doing computer programming for a while now (game programming aswell using DirectX). The thing is I do programming in Borland Delphi (I do not know enough C/C++ to do game programming) and I am not sure if it is possible to use Delphi to make GBA games.

If anyone has any information on this please let me know. I'll continue looking around but any info will be gadly accepted.

Thanks

#13248 - sajiimori - Wed Dec 10, 2003 12:40 am

Well, there's GNU Pascal at http://www.gnu-pascal.de/gpc/h-index.html -- you should be able to build a cross-compiler that targets ARM, but I don't know what kind of modifications would be required for the GBA, if any.

Ideally, you'd be able to just compile it and add it to a DevKit Advance distribution.

#13250 - LiquidIce - Wed Dec 10, 2003 1:00 am

I see.

Another thing that is bad for me is that all the tutorials are C++ so I'd have to convert them to Delphi and DMA is new to me.

#13254 - sajiimori - Wed Dec 10, 2003 1:33 am

No worries -- DMA is GBA-related, not a language-related. The GBA's DMA hardware will be new to anyone who has not developed for GBA. Using it is just a matter of writing to particular memory addresses.

#13255 - poslundc - Wed Dec 10, 2003 1:36 am

Most GBA tutorials I've seen are C, not C++. Check out The Pern Project for starters.

I'd really recommend learning C, and not just for GBA programming; it's probably the most widely-used language for the largest variety of applications out there, and most new languages tend to be based on C's overall design and syntax. It's also not terribly hard to learn and get used to if you already have a background in programming; I don't especially know Delphi but if it's anything like Pascal you really just need to get a handle on the different syntax.

DMA is just a special hardware feature of the GBA for quick memory transfers. It is only one of several dozen specific features to the GBA that you will have to learn, and should not be the first. The Pern Project covers DMA on Day 5, I think.

Dan.

#13256 - LiquidIce - Wed Dec 10, 2003 1:46 am

:)
Can't be worse than Microsoft's DirectX lol.

I know some C++ but not enough to do gaming and such. I am very good in Delphi that is why I wanted to use it. I know there has to be a way but converting C++ code to Delphi is kinda hard.

You have not seen any tutorial for Delphi? Could be something very small like drawing a single sprite. Just something I can see for a template and how to compile it and such.

Thanks!

#13263 - sajiimori - Wed Dec 10, 2003 2:40 am

If you know your language, and you know how the GBA hardware works, then you don't need any templates or tutorials.

That said, no, I don't know of anybody who uses Pascal on GBA (and certainly not Delphi).

BTW, if you learn C before C++ you might find it more appealing. C is an elegant balance of simplicity and practicality, whereas C++ is possibly the most convoluted language ever concieved (and intended for practical use). Get the "C Primer". None of the tutorials come close.

#13271 - LiquidIce - Wed Dec 10, 2003 1:49 pm

When compiling a GBA rom file do you compile it from a EXE or from the C/C++ source code ?

If it is from the EXE then I should be able to compile it from a Delphi EXE since it is compiled to ASM.

It would be really cool for the Delphi community to see Delphi making GBA games so I want to use Delphi.

#13272 - col - Wed Dec 10, 2003 1:49 pm

sajiimori wrote:
...C is an elegant balance of simplicity and practicality, whereas C++ is possibly the most convoluted language ever concieved (and intended for practical use)...


translated into english this reads:

"I'm a troll, fol-de-rol, and I'll eat you for my supper"

chears

col.

#13274 - LiquidIce - Wed Dec 10, 2003 2:46 pm

Col don't post if you aren't going to talk about the topic ;\

Anyways, I saw somewhere that Delphi was used to make a GBC game so it should be possible to make a GBA game aswell right?
I'll figure this out and enlighten all our Delphi people. Delphi is actually very nice for game development.

#13275 - Datch - Wed Dec 10, 2003 3:33 pm

As far as I know Delphi is a RAD tool for Windows only. It has a great interface to create Windows application and not GBA sprites. :)

Better to say you want to use Pascal to code GBA game. I don't think switching from Pascal to C or C++ should be that hard so I agree with poslundc that you should try to learn C or C++. After all, you are already used to leave ";" after each line of code! :)
_________________
Visit SR-388 now and get a 40% discount!

#13276 - mathieu - Wed Dec 10, 2003 4:32 pm

There's even a Pascal 2 C translator (at least under Linux, it's called p2c)... So one can program in Pascal, convert, and then compile everything in C using one of the GBA gcc compilers available out there (devkit advance for example).

However, when it comes to debugging, I'm not sure if it is very efficient.

It would be interesting to try, but the easiest way to code things on GBA is probably to learn C instead of trying to use weird tools or languages :-).

#13284 - Miked0801 - Wed Dec 10, 2003 6:36 pm

As someone who knows both languages, I can say that converting from Pascal to C (++ if you want) is acutally a freeing experience. It takes a second to get used to not using the : some much and #includes instead of uses, but once your by the semantics, it's so much easier to do pointer/memory stuff its unbelievable. Of course, it's alot easier to shoot yourself in the foot as well, but that's the fun of it :)

The languages are both similiar enough that you should be up and running in C within a day or 2 of trying. I personally learned Pascal first and switched to C (Pascal was taught as an introductory language at my college way back when :)) and was up and running in C in days. So jump in and learn already :)

Mike

#13286 - sajiimori - Wed Dec 10, 2003 7:16 pm

I don't think anybody has answered this question yet:
Quote:

When compiling a GBA rom file do you compile it from a EXE or from the C/C++ source code ?

EXE is a compiled executable format for DOS/Windows, totally unrelated to GBA.

You can produce ROM images in any number of ways, the most common of which is to compile files written in a higher-level language (such as C or C++) to a binary object format (.o), and then link the object files together. Most people use Makefiles or batch scripts to automate this process.

#13294 - LiquidIce - Wed Dec 10, 2003 8:53 pm

Thanks for all the answers

Delphi is not really under Windows. It supports Linux (Kylix) and much more. It compiles everything to ASM so I don't see why it shouldn't be possible to make a GBA rom from Delphi.

BTW Delphi is NOT Pascal. It comes from Pascal syntax but the ''Pascal'' language is not the same thing as Delphi. Same way that C++ comes from C but it is still not C.

So far, I have made everything under Delphi that has been possible in C++. Ie: DLL calls, converting Microsoft DirectX C++ SDK to Delphi has been possible, and a lot more.

Now the problem that I see is that the compilers that create the GBA rom files all depend on the c/c++ source code to compile them. Sajiimore said you guys compile the C source code to binary object files and then compile it to a GBA rom file? The next step for me is to see if there is a way to compile Delphi code to binary object files.

Some of you might think I am wasting my time but if it's possible to do this in Delphi, I want to find the way :) My Delphi programming friends would like this a lot aswell.

Thanks I'll keep searching for an answer and if anyone finds anything please let me know.

Mike: I took C++ course in high school before but it didn't go into anything much more than pointers and basic IO. Now I take Java courses but Delphi has fit me better than both.

<<EDIT>>
I found a option in Delphi to "Generate C++ Object Files" which can include namespaces and export all the symbols.
Can this help me?

#13296 - tepples - Wed Dec 10, 2003 9:30 pm

LiquidIce wrote:
Delphi is not really under Windows. It supports Linux (Kylix) and much more.

Both Windows and GNU/Linux have Intel i386 as their primary instruction set. Does the "much more" include any ARM targets?

Quote:
It compiles everything to ASM

The GBA uses ARM assembly language, not i386 assembly language.

Quote:
Now the problem that I see is that the compilers that create the GBA rom files all depend on the c/c++ source code to compile them. Sajiimore said you guys compile the C source code to binary object files and then compile it to a GBA rom file? The next step for me is to see if there is a way to compile Delphi code to binary object files.

Binary object files intended for use on the ARM architecture are completely different from binary object files intended for use on the i386 architecture.

Quote:
I found a option in Delphi to "Generate C++ Object Files" which can include namespaces and export all the symbols.
Can this help me?

Can you change the Target Architecture to anything other than i386?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#13297 - poslundc - Wed Dec 10, 2003 9:45 pm

LiquidIce wrote:
Delphi is not really under Windows. It supports Linux (Kylix) and much more. It compiles everything to ASM so I don't see why it shouldn't be possible to make a GBA rom from Delphi.


Well, the short answer is that the ASM it compiles is useless unless it happens to be ASM for the ARM7TDMI chipset, which is what the GBA uses. From what you're saying, it seems far more likely that it outputs assembly instructions for the x86 series of processors, which is an entirely different instruction set.

Quote:
I found a option in Delphi to "Generate C++ Object Files" which can include namespaces and export all the symbols.
Can this help me?


Again, the object files must be targetted for ARM processor, otherwise nothing else matters. Windows and Linux both run on the x86 processor, which is a fundamentally different processor.

This is not meant to sound discouraging, but I do not suspsect you will get very far with GBA programming if you aren't prepared to delve more under-the-hood than looking for a compiler option that reflects a certain language.

Programming Delphi (or Pascal, anyway) is not necessarily a dead end, as others have already noted, but you will have to do some tough stuff to get there (far less trivial than checking an option in the Delphi compiler). Frankly, the prerequisite knowledge needed to pull it off make something like learning C look like child's play. (At least there are plenty of tutorials on learning C).

So, without intending to start a holy war over languages or anything like that... my advice is to suck it up and learn C. You can always try to go back and find a way to compile your Delphi code to the ARM chipset once you have a better understanding of GBA programming.

Edit: Damnit, Tepples... always one step ahead of me. Next time I'm not going to waste time proofreading.

Dan.

#13298 - LiquidIce - Wed Dec 10, 2003 9:50 pm

but if I can make the binary object files that are C format shouldn't I be able to use the GBA compilers to make the roms?

#13300 - LiquidIce - Wed Dec 10, 2003 10:09 pm

I see what you are saying but what I've noted is that C++ even doesnt do it all by itself you still need the gcc and the rest of the stuff to compile it to ARM.

I saw someguy who was making a gameboy color game in Delphi so I'll send him an email.

Thanks for all the help. If I find out how to do it I'll tell everyone,
back to MMORPG programming for me at http://www.aotaonline.com/

Lol cya

#13301 - sajiimori - Wed Dec 10, 2003 10:13 pm

Object files are made of binary CPU instructions.

Different CPUs use different instruction sets.

An object compiled for one CPU will not work for another CPU.

PCs use x86 CPUs.

GBA uses an ARM CPU.

Clear now?

#13302 - Datch - Wed Dec 10, 2003 10:14 pm

No you can't. The object file you are talking about are compiled for x86 processors and not for the GBA processor.

Note : Interested by the interpretation of the word "Delphi", here's what I found :
The word "Delphi" reference to :
1- The Windows IDE.
2- The proprietary Borland Pascal-Object langage.
3- An ancient place in Greece. :)
_________________
Visit SR-388 now and get a 40% discount!

#13303 - sajiimori - Wed Dec 10, 2003 10:16 pm

Quote:

I've noted is that C++ even doesnt do it all by itself you still need the gcc and the rest of the stuff to compile it to ARM.

C++ is a language, so it doesn't "do" anything at all, but the C++ compiler that is included in GCC can indeed output ARM assembly.

#13332 - XeroxBoy - Thu Dec 11, 2003 6:59 am

Delphi code is actually Object Pascal - were you to be programming games for the GBA with it, that's what you'd be using, not Delphi. Delphi is merely the development tool that uses Object Pascal, and would be nigh-useless for the GBA anyways since it's only distinct advantage over a pure Object Pascal compiler is its ability to design GUIs quickly, a non-existant issue for the GBA programmer. In other words, the only way to make GBA games using 'Delphi' (Object Pascal) is to write an Object Pascal compiler which targets ARM CPUs - obviously, far more difficult than simply learning C.

As a C/C++ coder, I decided to learn Delphi to aid my Windows coding, and I picked it up within a few weeks. Certainly going the other way around couldn't be any harder.

#13333 - sajiimori - Thu Dec 11, 2003 7:16 am

Quote:

In other words, the only way to make GBA games using 'Delphi' (Object Pascal) is to write an Object Pascal compiler which targets ARM CPUs - obviously, far more difficult than simply learning C.

I dunno...this page seems to warrant a bit more optimism:
Quote:

The compiler supports the following language standards and quasi-standards:

ISO 7185 Pascal (see Resources),
most of ISO 10206 Extended Pascal,
Borland Pascal 7.0,
parts of Borland Delphi, Mac Pascal and Pascal-SC (PXSC).

...

Which platforms are supported by GNU Pascal?

GPC uses the GCC backend, so it should run on any system that is supported by GNU CC.

http://www.gnu-pascal.de/gpc/h-about.html
http://www.gnu-pascal.de/gpc/Supported-platforms.html

#13336 - XeroxBoy - Thu Dec 11, 2003 7:39 am

That'll show me to do some research :P
Thanks, and sorry for jumping to assumptions.

I'm not going to try it, but it seems possible that this GPC could be installed over DevKitAdvance, giving one a fully functional Pascal compiler for ARM. It still isn't Object Pascal, however, and it seems to be at quick glance one of those Pascal->C converters, meaning compile times would be long and code might be a bit inefficient (though C and Pascal aren't too much unalike in terms of actual logic, so it shouldn't have too great an adverse effect). Nevertheless, you might want to try this out Mr. Ice.

#13340 - LiquidIce - Thu Dec 11, 2003 12:29 pm

Delphi can do non-object programs like console apps etc that have no use of the VCL.

Thanks for that sajii I'll give it a shot.