View unanswered posts | View active topics It is currently Wed Jul 17, 2019 6:26 am



Reply to topic  [ 10 posts ] 
zsnes port to C language 
Author Message
New Member

Joined: Tue Oct 30, 2012 2:49 am
Posts: 3
Reply with quote
Post 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.


Tue Oct 30, 2012 2:54 am
Profile
Buzzkill Gil

Joined: Wed Jan 12, 2005 7:14 pm
Posts: 4240
Reply with quote
Post 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.

_________________
Squall_Leonhart wrote:
Quote:
You have your 2s, 4s, 8s, 16s, 32s, 64s, and 128s(crash course in binary counting!). But no 1s.
DirectInput represents all bits, not just powers of 2 in an axis.


KHDownloads


Tue Oct 30, 2012 2:02 pm
Profile
ZSNES Shake Shake Prinny
User avatar

Joined: Wed Jul 28, 2004 4:15 pm
Posts: 5615
Location: PAL50, dood !
Reply with quote
Post Re: zsnes port to C language
And by important people he means everyone involved.


Gil_Hamilton wrote:
And I still maintain that whatever comes out won't be ZSNES, since the entire emulation core will be new.

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.
So if there's a reason it won't be ZSNES, it's because zsknight and _Demo_ aren't doing it, essentially.

_________________
皆黙って俺について来い!!
Code:
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54


Thu Nov 01, 2012 9:11 pm
Profile
New Member

Joined: Tue Oct 30, 2012 2:49 am
Posts: 3
Reply with quote
Post 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

Code:
    ; 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


which I translated to

Code:
    int64_t vol = MusicRelVol << 7;                   
    vol *= 0xA3D70A3D;                                 
    vol >>= 38;
    if (vol > 127)                                     
        vol = 127;
    MusicVol = vol;


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?


Fri Nov 02, 2012 4:11 am
Profile
New Member

Joined: Tue Oct 30, 2012 2:49 am
Posts: 3
Reply with quote
Post 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.


Fri Nov 02, 2012 6:01 pm
Profile
Zealot
User avatar

Joined: Wed Jul 28, 2004 3:31 am
Posts: 1140
Reply with quote
Post 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.


Sat Nov 03, 2012 2:51 am
Profile WWW
ZSNES Shake Shake Prinny
User avatar

Joined: Wed Jul 28, 2004 4:15 pm
Posts: 5615
Location: PAL50, dood !
Reply with quote
Post Re: zsnes port to C language
flaggy wrote:
Code:
    shr edx,6

>
Code:
    vol >>= 38;

Don't forget to check if your port actually does what the original did while you're at it.

(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.

_________________
皆黙って俺について来い!!
Code:
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54


Mon Nov 05, 2012 7:54 pm
Profile
Hazed

Joined: Tue Jan 16, 2007 5:32 pm
Posts: 54
Reply with quote
Post 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.


Tue Nov 06, 2012 1:05 pm
Profile
ZSNES Shake Shake Prinny
User avatar

Joined: Wed Jul 28, 2004 4:15 pm
Posts: 5615
Location: PAL50, dood !
Reply with quote
Post Re: zsnes port to C language
Yes, Tron did a lot of work.

_________________
皆黙って俺について来い!!
Code:
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54


Tue Nov 06, 2012 8:14 pm
Profile
Zealot
User avatar

Joined: Wed Jul 28, 2004 3:31 am
Posts: 1140
Reply with quote
Post 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.


Wed Nov 07, 2012 9:06 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.