zsnes port to C language
Moderator: ZSNES Mods
zsnes port to C language
It looks like you guys started porting things to C, but then stoped. Is there a reason for that? Is there something that just can't be ported to C? It would be very good if everything was written in C because then we could compile zsnes to 64 bits intel processor and several other targets. It would also be interesting to have a arm port of zsnes. All that would be much easier if zsnes were 100% C code.
-
- Buzzkill Gil
- Posts: 4295
- Joined: Wed Jan 12, 2005 7:14 pm
Re: zsnes port to C language
It's ongoing. Important people have bad cases of real life syndrome, which has several severe symptoms including "no free time for hobby coding".
And I still maintain that whatever comes out won't be ZSNES, since the entire emulation core will be new.
And absolutely everyone knows the advantages. It's why porting a shit-ton of cryptic x86 assembly to C was ever started.
And I still maintain that whatever comes out won't be ZSNES, since the entire emulation core will be new.
And absolutely everyone knows the advantages. It's why porting a shit-ton of cryptic x86 assembly to C was ever started.
KHDownloadsSquall_Leonhart wrote:DirectInput represents all bits, not just powers of 2 in an axis.You have your 2s, 4s, 8s, 16s, 32s, 64s, and 128s(crash course in binary counting!). But no 1s.
-
- ZSNES Shake Shake Prinny
- Posts: 5632
- Joined: Wed Jul 28, 2004 4:15 pm
- Location: PAL50, dood !
Re: zsnes port to C language
And by important people he means everyone involved.
So if there's a reason it won't be ZSNES, it's because zsknight and _Demo_ aren't doing it, essentially.
Well, it's about the spirit imo. A program's identity stems from its guts, direct consequence of the skills and quirks of its authors.Gil_Hamilton wrote:And I still maintain that whatever comes out won't be ZSNES, since the entire emulation core will be new.
So if there's a reason it won't be ZSNES, it's because zsknight and _Demo_ aren't doing it, essentially.
皆黙って俺について来い!!
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Code: Select all
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Re: zsnes port to C language
I was just curious whether rewriting things in C was a worthy goal, or if it was hopeless. I decided I'd have a go at it. So I began with init function. I found this part
which I translated to
Still, I'm puzzled as what does all those shift and multiplying by 0xA3D70A3D means. I ploted the function
((x<<7) * 0xA3D70A3D) >> 38
and I figured that it's very close to the function f(x) = 1.28x - 0.5.
Still, I had no further insight as why to use such an awkward function for translating MusicRelVol into MusicVol. It seems to me that MusicRelVol goes from 0 to 100 and MusicVol goes from 0 to 127. Anybody care to join me in this task?
Code: Select all
; Initialize volume
xor edx,edx
movzx eax,byte[MusicRelVol]
shl eax,7
mov ebx,0A3D70A3Dh
mul ebx
shr edx,6
cmp dl,127
jb .noof
mov dl,127
.noof
mov [MusicVol],dl
Code: Select all
int64_t vol = MusicRelVol << 7;
vol *= 0xA3D70A3D;
vol >>= 38;
if (vol > 127)
vol = 127;
MusicVol = vol;
((x<<7) * 0xA3D70A3D) >> 38
and I figured that it's very close to the function f(x) = 1.28x - 0.5.
Still, I had no further insight as why to use such an awkward function for translating MusicRelVol into MusicVol. It seems to me that MusicRelVol goes from 0 to 100 and MusicVol goes from 0 to 127. Anybody care to join me in this task?
Re: zsnes port to C language
I have set up a public repository with the development I'm doing. Everyone is welcomed to help me out making the transition from assembly to C:
https://github.com/aflag/zsnes
I hope eventually we'll be able to merge any changes back to the main development branch.
https://github.com/aflag/zsnes
I hope eventually we'll be able to merge any changes back to the main development branch.
Re: zsnes port to C language
That was from me being really "clever" by borrowing fixed point multiplication optimizations from Intel's C/C++ compiler a long time ago. No better reason, really.
-
- ZSNES Shake Shake Prinny
- Posts: 5632
- Joined: Wed Jul 28, 2004 4:15 pm
- Location: PAL50, dood !
Re: zsnes port to C language
Don't forget to check if your port actually does what the original did while you're at it.flaggy wrote:>Code: Select all
shr edx,6
Code: Select all
vol >>= 38;
(Edit: i.e. killing eax' contents does not work in other spots)
Regarding your attempt: you'd think starting at init is the right choice, but shortly thereafter you hit the main gui jump and execloop... If you're fine with assembly, feel free to actually trace it out. It's a unique experience.
Mind you, all that block is gonna die with the rewrite. Some of the messy stuff in there causes a good half of the issues.
If you want to help, please join the irc dev channel and hit us up, we always welcome new slaves^Whelpers.
皆黙って俺について来い!!
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Code: Select all
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Re: zsnes port to C language
Wasn't there another C port attempt fairly recently, by the way? I don't remember his name, but I think he had done a decent bit of porting before he got taken away by real life.
-
- ZSNES Shake Shake Prinny
- Posts: 5632
- Joined: Wed Jul 28, 2004 4:15 pm
- Location: PAL50, dood !
Re: zsnes port to C language
Yes, Tron did a lot of work.
皆黙って俺について来い!!
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Code: Select all
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Re: zsnes port to C language
Oh yeah, now I remember, I did that because Intel compiler thought that code like that was faster than using division opcodes. Seriously, just use *128/100.