Port assembly to C.

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Port assembly to C.

Post by Nach »

We need to port more to C, and we simply don't have enough people doing this. If you have a decent understanding of assembly and C, and have some free time, please help us port some code.

Currently, it would be appreciated if someone would port one or more of these file:

ui.asm (Easy)
guicheat.inc (Pretty Easy)
guinetpl.inc (Difficult)
guiload.inc (Difficult)
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

I'm currently working through my C course book again, then I'd like to give something a try.
[u][url=http://bash.org/?577451]#577451[/url][/u]
TheDanish
Rookie
Posts: 12
Joined: Fri Jul 30, 2004 10:23 pm

Post by TheDanish »

I'd like to try ui.asm to get my n00bish feet wet, if it hasn't been taken yet. I've ported a few functions successfully just to make sure I could, so I have just one question for the time being: would you like the functions to do exactly what they would in assembly, or would you like them to follow C semantics? If it's straight C, then obviously other files need to be changed to accommodate. For example, if a function takes eax as an argument, would you like the C function to actually get eax, or would you want all the calls changed to push eax first? I'm guessing the latter, but I just want to be sure. Any other details I need to know would obviously be good to know, too.

Also, I'm kind of busy with college, so it would be awhile between that and the fact that I'm learning as I go. If I get ui done in a timely manner, I should be comfortable with the environment enough to do whatever's left.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

TheDanish wrote:I'd like to try ui.asm to get my n00bish feet wet, if it hasn't been taken yet.
Well some people have been working on part of it. Just do a few functions at a time that haven't been taken yet, and send them to me. Basically, if it's in the assembly in CVS, it hasn't been taken yet.
TheDanish wrote: I've ported a few functions successfully just to make sure I could, so I have just one question for the time being: would you like the functions to do exactly what they would in assembly, or would you like them to follow C semantics? If it's straight C, then obviously other files need to be changed to accommodate. For example, if a function takes eax as an argument, would you like the C function to actually get eax, or would you want all the calls changed to push eax first? I'm guessing the latter, but I just want to be sure.
Don't care that much really, although I don't see how you're going to make a function actually read eax in a portable way. Here's the general rule:
If it's one parameter which is an int or a pointer, pass by parameter by pushing eax or whatever. If it's not that type or there are two parameters, pass by global vars.

TheDanish wrote: Any other details I need to know would obviously be good to know, too.
Just as soon as you make a few function changes that are working, submit them so no one else will try to port the same stuff.

BTW, if you need to call a parameterless assembly function from C, include the new header asm_call.h and do asm_call(func_name);
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
TheDanish
Rookie
Posts: 12
Joined: Fri Jul 30, 2004 10:23 pm

Post by TheDanish »

Alright, sure. Thanks for clearing it up.
TheDanish
Rookie
Posts: 12
Joined: Fri Jul 30, 2004 10:23 pm

Post by TheDanish »

Nach, check your PMs? :oops:
quad
New Member
Posts: 6
Joined: Sun Mar 06, 2005 6:34 pm

Post by quad »

Hi,

This is my first post here.

I have been interested in various emulation aspects since a couple of years now, and have always found ZSNES to be the best SNES emulator out there -- especially since it has been ported to UNIX. ;P Being a developer myself, I thought that hacking into this emulator code could be interesting. My main goal is to implement some kind of debugging process into ZSNES for the UNIX version (breakpoints, memory watches, etc.). (And speaking of that, has there been any work previously done for this?)


I gave it a try at porting assembly code to C a month or so ago. It was done on release version 1.42, but today I've merged my changes to the latest CVS files. I mainly extracted a few functions from src/linux/sdlintrf.asm to a new file src/linux/sdlintrf-c.c. It compiles fine and games still seems to work. ;P

Now the question is how should I proceed to submit a patch? Or just submit the files themselves to someone (Nach?) ? Thanks for any information and keep up the good work.
~
~
:wq!
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

As far as debugging goes, look at ./autogen.sh --enable-debug.

You may want to put a copy of the files changed up somewhere so grin or nach can look at it.
quad
New Member
Posts: 6
Joined: Sun Mar 06, 2005 6:34 pm

Post by quad »

But isn't ./autogen.sh --enable-debug for enabling debugging of the zsnes executable? Coincidentally I tried this switch in order to debug zsnesd with gdb. Argh, I might have expressed myself incorrectly -- I actually want to implement debugging at the ROM (game) level, much like the DOS -d option works (though I never had the opportunity to try it really ;P). I'd like to keep it simple for UNIX: something similar to gdb, in a command line fashion, since I'm not that good at writing GUI stuff.

As for the changes, I'll diff them and post it somewhere soon. Thanks!


Edit: A patch file (zsnes.diff) and a new file (sdlintrf-c.c) are located at the following address:
quadhome.calizone.net:8000/zsnes/

All comments are welcome!
~
~
:wq!
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Look at debug.asm in dos/.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

Aerdan wrote:Look at debug.asm in dos/.
Ahoy, Pagefault has started working on a non dos-only debugger. Check debug.c in latest cvs.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Post Reply