Oni Central Forum

A forum for the Oni community

You are not logged in.

#1 01/26/10 23:01

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

C/C++ Programming discussion

I thought we should have a thread to discuss C/C++ programming in relation to Oni.

Hopefully, those experienced ones can share their knowledge.  What resources are available to learn the language: programs, books, online tutorials, etc.

Perhaps, showing how an aspect of the Daodan DLL works.  For example, what was done to add the new cheat codes.

I know from my experience, that if there is a project to work on, or something you're interested in, that is the best way to learn something new.  Because of Oni, I learned about hex editing so I could help patch the Mac Engine, Applescript and Xcode programming to make AETools, and now I'm learning about 3D animation.  Who knows, maybe I'll learn C/C++ next smile

This thread may encourage ones to learn C/C++ or those with this knowledge will decide to help out.

To get things started, regarding books, Iritscen stated:

The only proper ways to learn C are taking a class in school or getting a book and studying it carefully -- the premiere ones are "C Programming Language" by Kernighan & Ritchie, "Programming in C" by Stephen Kochan, and the "C Primer Plus" by Stephen Prata.

Last edited by EdT (01/27/10 00:01)

Offline

#2 01/27/10 04:01

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: C/C++ Programming discussion

Could you post a small introduction on how you program something?
I want to know wich compiler is right, and where to get it.
Most Linux distros have gcc compilers right in, so you can just make a new document containing the written program and then you can run it via terminal with the code:

*username and location*:  gcc *programnamefile*

So could you help me (reader) get started?

Offline

#3 01/27/10 06:01

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: C/C++ Programming discussion

Thanks for quoting me, EdT, I hate repeating myself smile

Tudorge, you seemed to answer your own questions there.  What is it you're asking, exactly?


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#4 01/27/10 09:01

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: C/C++ Programming discussion

Oh.
Edt said he wanted to post all we know about C/C++, and i've said what i knew when i was using ubuntu big_smile
What i was asking was what compiler should i use. Because each one has its advertising, and i don't seem to find any good one for beginners. I've found Borland Delphi wich is free, is that good?

Offline

#5 01/27/10 09:01

s10k
Member
Registered: 01/14/07
Website

Re: C/C++ Programming discussion

Which compiler/program do you use to make the guis?

Last edited by s10k (01/27/10 10:01)

Offline

#6 01/27/10 11:01

demos_kratos
Member
From: Russia, Volzhskiy
Registered: 08/13/08

Re: C/C++ Programming discussion

Borland Delphi is free you say? Hmm... Delphi is no more a Borland's product, they've sold it. It now belongs to CodeGear. UI doesn't really differ from Borland's one.

Back to C/C++
Micro$oft Visual Studio supports C++, CodeGear RAD Studio supports C++. Both have the "programming with mouse" concept. For console apps DevC++ is OK.

On Mac OS I didn't see anything except of Xcode. Let Iritscen crush my delusions if it's not true.


Jente, du er deilig, du er lekker, ihvertfall nå når jeg drikker.
Baby, du har det som trengs, hva er sannsynligheten for at vi to hopper til sengs?
Kan du si meg det? Jeg er ikke så stø i sannsynlighetsregning.

Offline

#7 01/27/10 13:01

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: C/C++ Programming discussion

MSVC is an awesome IDE. smile Free, too.

AEInstaller is coded in C++ with MSVC\Xcode.


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#8 01/28/10 06:01

RossyMiles
Member
From: Australia
Registered: 06/23/08
Website

Re: C/C++ Programming discussion

A C/C++ thread. This should be fun.

Script_10k wrote:

Which compiler/program do you use to make the guis?

Personally, I write the GUIs as Win32 code by hand. It's slow but it gives you very fine grained control over what the program does. AEInstaller's GUI is written in a framework called WxWidgets (if I remember correctly). This is what makes it cross-platform (running on both Windows and Mac OS.) It's also the same framework used to write Audacity.

demos_kratos wrote:

On Mac OS I didn't see anything except of Xcode.

If you take a look, every application (.app) on Mac OS is actually a folder (right-click on it and select "view bundle contents".) This folder contains all the resources the program needs to run ie. things like the icon, the default settings, the menu bars etc. etc. I'm pretty sure Xcode is the only application which can make one of these folders.

Tudorge wrote:

Could you post a small introduction on how you program something? I want to know wich compiler is right, and where to get it.

If you're used to GCC, Windows has a version of it too <mingw.org>, in fact, there is a GCC for pretty much every platform (GameCube/Wii, PSP and DS included.) The alternative on Windows is to use MSVC++ Express Edition, which is also free.

EdT wrote:

Perhaps, showing how an aspect of the Daodan DLL works.  For example, what was done to add the new cheat codes.

In Oni's code, there is a table containing the names and descriptions of all the cheats, plus a unique id for each. You may have heard of this table before.. Each element looks something like this in C source code.

{"shapeshifter", "Change Characters Enabled", "Change Characters Disabled", 1}

When you type a code, the game looks down the first "column" of the table for the cheat's name. It then calls the "cheater" function in the code with the ID of the cheat (the last column, which is in this case, 1). The cheater function decides what to do based on the ID.

To make our own cheats, we use the Daodan patch functions (which I will explain another time smile ) to replace Oni's cheat table and cheater function with our own, so whenever Oni thinks it's looking at it's own table and cheater function, it is in fact looking at ours. You can see our cheat table and cheat function in Daodan_Cheater.c. Daodan's cheater function looks like this.

uint8_t ONICALL DDrCheater(uint32_t cheat)

Basically, "uint32_t cheat" is the cheat ID, an unsigned (positive numbers only) "u" integer "int" which is 32-bits "32" long. The function returns 0 or 1 depending on whether Oni should display the "cheat enabled" message (column 2) or the "cheat disabled" message (column 3). "ONICALL" is needed to make our code compatible with Oni (Bungie used some weird options when compiling it with MSVC).

Inside the function is a "switch case" statement. This is used to determine which cheat to run (see wikipedia). You can see that right at the end we call Oni's original Cheater function:

return ONrCheater(cheat);

This is so all the old cheats still work.

Explaining how all the new cheats do what they do is for another time, I'm tired. If you have any questions, feel free to ask, I'm not sure I was clear enough with some parts.

Offline

#9 01/28/10 06:01

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: C/C++ Programming discussion

RossyMiles wrote:

I'm pretty sure Xcode is the only application which can make one of these folders.

Hmm, not really.  It's true that Xcode is pretty much the only IDE for OS X that supports C/C++, and particularly Obj-C, our native language, but any old user can create a .app folder.  You just have to make a folder with a name ending in .app, and have a few files in place that the OS expects to see in a .app, and it magically becomes an application as soon as they're dropped in; the main required file is, of course, a binary executable, placed in /Contents/MacOS.  So one could assemble an app manually if they desired, although there's little benefit to it.


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#10 01/28/10 06:01

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: C/C++ Programming discussion

So the addon daodan has been made in C? Or hybrid.
Why not program guis in visual basic. And there should (must!) be an equivalent in MacOS.
I got interested in C or C++ because i've seen a showcase of what you could do with them. From Delphi of course, but i'll check the others too ... So is devC++ good? I need an interpreter (like qbasic) with syntax check(like qbasic) and with an integrated help(survival guide, like qbasic). The books i've found do not mention anythin, what a shame.

By the way, say if i want to program a mathematical application, with all sorts of geometrical and algebrical operations and a built after gui, which language do you recommend?

Last edited by Tudorge (01/28/10 06:01)

Offline

#11 01/28/10 13:01

Alloc
Member
From: Germany -> Darmstadt
Registered: 01/14/07
Website

Re: C/C++ Programming discussion

Tudorge wrote:

... I've found Borland Delphi wich is free, is that good?

Delphi is not/does not include a C(++)-Compiler. Delphi itself is a completely different language.

demos_kratos wrote:

Borland Delphi is free you say? Hmm... Delphi is no more a Borland's product, they've sold it. It now belongs to CodeGear. UI doesn't really differ from Borland's one.

CodeGear was long ago big_smile
It's Embarcadero which now holds the rights on Delphi. And yup, there's a free version around, Turbo Delphi Explorer. But I just found out that the downloads are disabled for about 3 months now ... Not sure why, perhaps because of something new, but I think it's just that they do not want to continue this product line sad

Tudorge wrote:

Why not program guis in visual basic.

Because Basic is basic. It's the one of the very few languages I'd never recommend for anything wink
Visual Basic is even more critical since that's M$ only and programs written in it always depend on external libraries which can give you lots of problems (know some really good tools which depend on e.g. M$ databases and always give you the creeps when you got to install them on another machine).

Tudorge wrote:

And there should (must!) be an equivalent in MacOS.

Nope, there's probly no equivalent to VB at all. Basic compilers on the other hand can be found for most platforms, even some embedded ones.

Tudorge wrote:

I need an interpreter (like qbasic)

What do you refer to by the word "interpreter"? Editor? An interpreter is a program which interprets code and executes it on the fly. There's no such thing (at least not widely spread, perhaps just as a showcase that it can be done) for compiler languages as C/++. (See http://en.wikipedia.org/wiki/Interpreter_(computing)).

Tudorge wrote:

with syntax check(like qbasic)

Syntax checking is done by the compiler. In most IDEs the output is displayed in a formatted way. Syntax highlighting is another story, but simple highlighting is provided by most IDEs too.

Tudorge wrote:

and with an integrated help(survival guide, like qbasic)

Now that's the kinda tricky part. For most cases it's easier to refer to some good online documentation. The language itself can be learned by books or the documentation of the C/++ standard.

Regards,
Chris


ONI2.net, link to just any important resource-pages about ONI.

Offline

#12 01/28/10 15:01

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: C/C++ Programming discussion

On the Daodan: Unfortunately it only compiles with GCC...which leaves a lot to be desired when compared to MSVC, especially when it comes to debugging.

...the main issue seems to be that a lot of our code is based around adding to void pointers, which MSVC doesn't like. tongue

...after a bit of messing around with definitions, i have a version of the daodan that compiles!

... but doesn't link. Rossy has some hackish Oni_Symbols.S file. wink


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#13 01/28/10 18:01

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: C/C++ Programming discussion

NO!
Gah, if c++ isn't interpreted, then still, a graphical interface with syntax check (IDE right?) should be fine for a newbie like me. And i was saying that a "survival guide" would be helpful if you don't have internet access. Like, i learnt most commands in qbasic through examples and projects. In case i didn't have accessibility to a great tutorial for kids i've found, then qbasic redirects me to what do to with each command i've been writing wrong.
I'll see what kiddy/newbie tutorials i find and keep the book around, then start learning in ubuntu, since gedit has syntax check and i've downloaded gcc compiler to test programs. Still if anyone knows a better way to check programs tell me.

Offline

#14 01/28/10 18:01

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: C/C++ Programming discussion

Info source addition:
Bruce Eckel's Thinking in C++ is a book some peeps recommend in Ubuntu. They say it's free.
More:
The C++ Programming Language by the creator of c++ Bjarne Stroustrup.
You know what, i'm going to check the libraries for these kind of books.

Offline

#15 01/28/10 18:01

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: C/C++ Programming discussion

Alloc wrote:

Nope, there's probly no equivalent to VB at all.

*cough* I think AppleScript would be the equivalent.  It's also the closest programming language to natural English, and can be very powerful when apps support it well.  Not that this really helpful to Tudorge, but I wanted to stick up for the Mac ^_^


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#16 01/29/10 00:01

RossyMiles
Member
From: Australia
Registered: 06/23/08
Website

Re: C/C++ Programming discussion

Tudorge wrote:

I need an interpreter (like qbasic) with syntax check(like qbasic) and with an integrated help(survival guide, like qbasic). The books i've found do not mention anythin, what a shame.

By the way, say if i want to program a mathematical application, with all sorts of geometrical and algebrical operations and a built after gui, which language do you recommend?

It sounds like you need something like Python.

Gumby wrote:

On the Daodan: Unfortunately it only compiles with GCC...which leaves a lot to be desired when compared to MSVC, especially when it comes to debugging.

I beg to differ smile . I use GCC because it's much more complaint with current C standards. MSVC uses the C standard from 1989 which is restrictive at best. As for debugging, GDB (GNU's debugger) is just as fully featured as any other debugger, it's only restriction being it only runs on the command line. If you need an IDE with GDB debugging support, I recommend http://www.codeblocks.org/ , although I'd much rather just use something like OllyDbg.

Gumby wrote:

... but doesn't link. Rossy has some hackish Oni_Symbols.S file. wink

The Oni_Symbols.S file acts as a link to all of Oni's internal functions. It's what allows us to code for Oni in the same way Oni's developers would have. It's not C or C++, instead it's written in GNU Assembler (or GAS). Sadly, there are not many cross-compiler portable variants of assembler, SFeLi had a similar file in his Daodan, except his was written in FASM. For Daodan to compile in MSVC, Oni_Symbols.S would have to be rewritten in MASM. (which is hopefully as easy as just changing the first line)

Tudorge wrote:

Like, i learnt most commands in qbasic through examples and projects. In case i didn't have accessibility to a great tutorial for kids i've found, then qbasic redirects me to what do to with each command i've been writing wrong.

If you're used to QBasic, you should really try out FreeBasic (http://www.freebasic.net/) . I've heard some really good things about it. AutoIt (http://www.autoitscript.com/autoit3/) is also a really good Basic-like language.

Offline

#17 01/29/10 02:01

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: C/C++ Programming discussion

Yeah, I've kind of got it converted. I need to go find someone who knows MASM I guess. tongue

Edit: Neo ftw.
Neo: why are you using assembly anyway?
Neo: this stuff can be done in C
Neo: you'll need a typedef for a "pointer to function"
Neo: typedef void *(*Pmalloc)(int size);
Neo: then you can declare a global variable :
Neo: Pmalloc oni_malloc = (Pmalloc)0x0011fc24;
Neo: and that's pretty much all of it

So it looks like I get to go hunting.


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#18 01/29/10 08:01

Tudorge
Member
From: Romania, Bucharest
Registered: 10/26/09
Website

Re: C/C++ Programming discussion

What about python? Is it good for linux programmng?
I don't understand why don't they classify programming languages by : what can you do with them, what doesn't work, what works faster, and how is the syntax (I find things that i'm not used to difficult)

Offline

#19 01/29/10 13:01

Alloc
Member
From: Germany -> Darmstadt
Registered: 01/14/07
Website

Re: C/C++ Programming discussion

Tudorge wrote:

What about python? Is it good for linux programmng?

There are Python interpreters for Linux (as for most common platforms). "Good" is not about platform but about what you want to do.

Tudorge wrote:

what can you do with them

Because every language can be used to do everything as long as it is turing complete.

Tudorge wrote:

what doesn't work

See last one wink
Ok, you've got some restrictions on e.g. direct memory access in Java or .Net, but you mostly won't need it.

Tudorge wrote:

what works faster

Interpreted languages slowest, followed by byte-code based languages like Java and just-in-time compiler based languages (.Net) and fastest is of course native code (compiled binaries). Yeah, native programs can be slower than interpreted ones if you write bad code wink

Tudorge wrote:

and how is the syntax

That's mostly what a language is defining at all ;D

Regards,
Chris


ONI2.net, link to just any important resource-pages about ONI.

Offline

#20 01/29/10 14:01

s10k
Member
Registered: 01/14/07
Website

Re: C/C++ Programming discussion

I programmed with masm at my university. I didn't like that experience at all. you need to write all in asm, and when I mean all I mean all steps, acess to memory, arrays, pointers, registers etc. I prefer some more modern and more object oriented even if it have a cost at the performance.

Last edited by s10k (01/29/10 14:01)

Offline

#21 01/29/10 18:01

3llense'g
Member
From: Europe, Hungary, Budapest
Registered: 07/05/09

Re: C/C++ Programming discussion

I worked (still am) in Java for a year, using Netbeans. It's quite comfortable, supports code completion and warns about most errors (even some logical ones, like comparing different types). I'm not sure it's as efficient for C++, but it supports it. Just my 2c.


You can call me 3llen. It's shorter and simpler. wink

Offline

#22 01/29/10 18:01

s10k
Member
Registered: 01/14/07
Website

Re: C/C++ Programming discussion

I like java too. Just program something and it will almost work with all os. (I use eclipse)

However for this case it doesn't seem the best solution at all.

Last edited by s10k (01/29/10 18:01)

Offline

#23 01/29/10 18:01

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: C/C++ Programming discussion

Yeah, we kind of need the low level memory stuff.


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#24 01/29/10 19:01

RossyMiles
Member
From: Australia
Registered: 06/23/08
Website

Re: C/C++ Programming discussion

Gumby wrote:

Neo: Pmalloc oni_malloc = (Pmalloc)0x0011fc24;

Yeah, that's not exactly the same thing. That's turning all the symbols into pointers. Although most of the code will be the same, it requires dereferencing all the variables you use and in general, it makes the code more unwieldy. In fact, one of the reasons for the change from the old Daodan to the new was because of this, you can see that the old Daodan was pointer based. I still don't understand why you want it in Visual C, that's like downgrading your compiler tongue . Just debug it in Code::Blocks or OllyDbg.

Offline

#25 01/29/10 19:01

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: C/C++ Programming discussion

Those didn't work for me.


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

Board footer

Powered by FluxBB