How other people should write their software

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
DancemasterGlenn
Veteran
Posts: 637
Joined: Sat Apr 21, 2007 8:05 pm

Post by DancemasterGlenn »

OMG NOT OPTIMIZED FOR YOUR CRAP COMPUTER


Shut up leilei.
I bring the trouble.
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

VBA, or VBA-M? Two different emulators. VBA can have odd random slowdowns...
leilei
Rookie
Posts: 37
Joined: Fri Feb 22, 2008 8:46 pm

Post by leilei »

I.S.T. wrote:VBA, or VBA-M? Two different emulators. VBA can have odd random slowdowns...

both

mudlord wrote:It aint slow at BSNES.

Then where's the problem?

p.s. also try bochs
o^_^o
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Both? Then some weird shit is going on. I don't have any weird slowdowns in VBA-M, only slowdowns that actually happen in the game.

BTW, leilei, you officially FAIL at reading what mudlord said.

*States bias*

I am a mod at VBA-M's forums, and my personal opinion on this topic is both mudlord and byuu are a little right and a little wrong.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Then where's the problem?


You failed to read, yet again, or you are a troll. Or both.

The problem is: code optimization WITHOUT hacks should matter. Byuu, on the other hand, thinks code clarity comes first before optimization. As such, we both have major unreconcilable differences due to the two different approaches, EVEN though they have nothing to do with accuracy.

And the whole point of this thread was a fight between us two over exactly that.
adventure_of_link
Locksmith of Hyrule
Posts: 3634
Joined: Sun Aug 08, 2004 7:49 am
Location: 255.255.255.255
Contact:

Post by adventure_of_link »

byuu wrote:everyone should be free to develop however they want, and nobody has the right to tell others what they should be doing with their unpaid time. This goes for past poorly-made comments I've made, as well.


so what

if I made a bug report for <insert software here> I'm violating people's rights because I'm telling them what to do with their unpaid time? also it should go ignored because that's how they choose to develop?
Image
<Nach> so why don't the two of you get your own room and leave us alone with this stupidity of yours?
NSRT here.
byuu

Post by byuu »

Wrote up another one of my ten page rants on this subject here:
http://byuu.cinnamonpirate.com/articles/optimization

Mostly so that I don't have to keep discussing it with people in the future ;)

so what

if I made a bug report for <insert software here> I'm violating people's rights because I'm telling them what to do with their unpaid time? also it should go ignored because that's how they choose to develop?


I really have no idea how you went from what I said to talking about reporting bugs and violating rights ...

I don't even know how to respond to your question.
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

FWIW, I think it also depends on the type of program it is. I imagine there's zero reason to optimize the living shit out of a simple calculator, but one that can go well beyond what simple calculator can provide. At the same time, if it can deal with too many different variables and whatnot, then you'd want to focus on making the code readable.

That was probably a piss poor example, but I hope I got what I meant across.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3903
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

byuu wrote:The SPC7110 code I have may not be lightning fast like in ZSNES, but it serves an important purpose: unlike with the register text document, it's possible to understand what each register fully does. And there's no non-essential stuff getting in the way of the raw implementation.


Non essential stuff doesn't have to make stuff more confusing, or even get in the way at all. They are not necessarily mutually exclusive.

bsnes:

Code: Select all

    case 0x4800: {
      uint16 counter = (r4809 + (r480a << 8));
      counter--;
      r4809 = counter;
      r480a = counter >> 8;
      return codec.output[(decomp_offset++) & 0xffff];
    }


ZSNES:

Code: Select all

void SPC7110_4800()
{
  WRITE_WORD16_LE(SPCCompressionRegs+9, READ_WORD16_LE(SPCCompressionRegs+9)-1);
  if (decompression_state.table_current)
  {
    SPCCompressionRegs[0] = read_decompress();
  }
}


bsnes:

Code: Select all

    case 0x4806: {
      r4806 = data;

      unsigned table   = (r4801 + (r4802 << 8) + (r4803 << 16));
      unsigned index   = (r4804 << 2);
      unsigned length  = (r4809 + (r480a << 8));
      unsigned addr    = datarom_addr(table + index);
      unsigned mode    = (memory::cartrom.read(addr + 0));
      unsigned offset  = (memory::cartrom.read(addr + 1) << 16)
                       + (memory::cartrom.read(addr + 2) <<  8)
                       + (memory::cartrom.read(addr + 3) <<  0);

      //this can technically be 65536, but it has never been observed higher than 32768 ...
      //really need a way to determine both compressed and decompressed lengths, though.
      static const unsigned max_length = 32768;

      offset = datarom_addr(offset);
      for(unsigned i = 0; i < max_length; i++) codec.buffer[i] = memory::cartrom.read(offset + i);

      #if 0
      printf("decompression: 4805=$%0.2x,4806=$%0.2x,4807=$%0.2x,4808=$%0.2x,480b=$%0.2x\n",
        r4805, r4806, r4807, r4808, r480b);
      printf("table=$%0.6x,index=%3d,length=%5d,mode=%d,offset=$%0.6x\n",
        table, r4804, length, mode, offset);
      #endif

      switch(mode) {
        case 0: codec.decomp_mode0(max_length); break;
        case 1: codec.decomp_mode1(max_length); break;
        case 2: codec.decomp_mode2(max_length); break;
      }

      decomp_offset = (r4805 + (r4806 << 8)) << mode;
      r480c = 0x80;
    } break;


ZSNES:

Code: Select all

void SPC7110_4806w()
{
  if (decompression_state.graphics_buffer)
  {
    init_decompression(READ_WORD24_LE(SPCCompressionRegs+1), SPCCompressionRegs[4], READ_WORD16_LE(SPCCompressionRegs+5));
  }

  SPCCompressionRegs[0xC] = 0x80;
}


ZSNES does have an extra if in each case to ensure no invalid memory accesses in case no buffer has been allocated. Other than that, I think my code is easier to see what the essentials are. I certainly didn't convolute my handling of those registers with any cache logic. bsnes on the other hand has code like "codec.output[(decomp_offset++)", which is cache logic dirtying up the register's documentation. Functions for clarity people, functions! How come no one in emulation seems to have read Code Complete?
Last edited by Nach on Mon Jul 28, 2008 11:28 am, edited 2 times in total.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Nach
ZSNES Developer
ZSNES Developer
Posts: 3903
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

mudlord wrote:You could persuade Nach to get UPS support in. All my reminders to him have fallen on death ears, since he seemed very interested to implement it. :(

I'm about half done with it. I just got side tracked optimizing the SPC7110 code, and will finish it when I'm done with SPC7110. I just take priority with ZSNES over VBA-M, sorry.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
adventure_of_link
Locksmith of Hyrule
Posts: 3634
Joined: Sun Aug 08, 2004 7:49 am
Location: 255.255.255.255
Contact:

Post by adventure_of_link »

byuu wrote:
so what

if I made a bug report for <insert software here> I'm violating people's rights because I'm telling them what to do with their unpaid time? also it should go ignored because that's how they choose to develop?


I really have no idea how you went from what I said to talking about reporting bugs and violating rights ...

I don't even know how to respond to your question.

Eh, don't worry about it. Last night I was on edge and I was feeling sleep deprived, and I was being a smartass. I apologize.

still, isn't a proper bug report telling the devs to fix the bug(s) in the software? :P
Image
<Nach> so why don't the two of you get your own room and leave us alone with this stupidity of yours?
NSRT here.
DancemasterGlenn
Veteran
Posts: 637
Joined: Sat Apr 21, 2007 8:05 pm

Post by DancemasterGlenn »

adventure_of_link wrote:still, isn't a proper bug report telling the devs to fix the bug(s) in the software? :P

I think we need to think about the difference between "program bugs" and "coding techniques".
I bring the trouble.
AamirM
Regen Developer
Regen Developer
Posts: 533
Joined: Sun Feb 17, 2008 8:01 am
Contact:

Post by AamirM »

Hi,

byuu wrote:Wrote up another one of my ten page rants on this subject here:
http://byuu.cinnamonpirate.com/articles/optimization

Mostly so that I don't have to keep discussing it with people in the future ;)


Once again a nice article. Always good to read your stuff. But I think there are a few a subtle and important points which you didn't explain very clearly.

1) While independent model works best for SNES (because thats how it really works), there are machines where enslavement model is the way to go simply because thats how they work (the master has knowledge of a slave) and you gain many of the benefits which you mentioned for the independent model in your article.

2) Although not strictly code clarity vs. optimization thing, but you must very clearly state that bsnes isn't meant to play games (at least not right now, maybe few years later). Face the truth, about 99% of the people who try your emulator try it to play a game and when they can't (due to speed reasons) they come and blame you here. If you do a simple google search, you'll find that nearly on every forum there will be someone who will sugggest bsnes to play games.

Again, these are just my own opinions. For those who want both speed and accuracy they'll have to wait for ASNES :twisted: .

stay safe,

AamirM
henke37
Lurker
Posts: 152
Joined: Tue Apr 10, 2007 4:30 pm
Location: Sweden
Contact:

Post by henke37 »

Speed reasons? That's what we have frameskip for. I personally believe that it's the games that doesn't work at all that's the bigger turn off.
tetsuo55
Regular
Posts: 307
Joined: Sat Mar 04, 2006 3:17 pm

Post by tetsuo55 »

Guess ill add my view too, but before i do:

i am a terrible programmer, at this very moment i am probably unable to write hello world in basic BUT i can often understand what byuu's code its trying to do.

This proves that byuu's approach does work for the readability part.

i also have a friend who uses his "functions" to create readability, his code is also completely understandable just by reading the functions names.

Now here is my idea on the whole thing, all 3 points are equally as important:

1: Code should be readable for other parties, however it doesnt matter if this is done like byuu or with functions or with comments.
2: Code should be written for the future and not the today (current target should be x64, SSSE3E, unlimited cores), while coding keep backwards compatibility in mind(x86,mmx(multithreading is only slightly slower on a single core, so no special care need be taken))
3: the code should be as optimised as possible, although its written with fast computers in mind, it should work on the slowest handheld device.

Now accuracy of emulation has nothing to do with the above 3 priorities, thats a completely different thing altogether, the above 3 priorities are overal for any code from OS to Drivers to Calculators.


that being said, i have only ever met/heard about 1 person who does all 3
byuu

Post by byuu »

While independent model works best for SNES (because thats how it really works), there are machines where enslavement model is the way to go simply because thats how they work


Unfortunately I don't know enough about other systems to really comment on that, so I'll take your word for it. But FWIW, the SMP really was the ideal processor for enslavement. I can't imagine a setup better designed for that.

Face the truth, about 99% of the people who try your emulator try it to play a game and when they can't (due to speed reasons) they come and blame you here.


I wasn't aware that only 1% of the population had processors less than three years old. Now, I would buy 80-90% of people find it to be too slow, sure. But even that is probably an exaggeration, unless you're talking about the just-added SPC7110 support.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Mostly so that I don't have to keep discussing it with people in the future ;)



....So, in my involuntary absence (for mental health reasons, go ahead and laugh), I return to a already fucked up life (and now worse), AND yet I see a rant, debating the merits of code clarity over raw optimization for speed on less than brand new processors?

Enough of that. I might as well post on my blog why I care about optimization, even on top end PCs and my personal beliefs on the matter as such.

Anywayz, nice rant. Makes sense 8) . And I'm glad you get my view, in that when I talk about "optimization" I am not talking about accuracy hindering hacks (which to me, definately seem wrong). So, least we both believe game affecting hacks = bad. :P

EDIT:

I just take priority with ZSNES over VBA-M, sorry.


No problems 8) . I tend to juggle time with VBA-M. Depends on my mood, really (sometimes I don't do any work on it at all. I mainly code when I feel like).
byuu

Post by byuu »

I see a rant, debating the merits of code clarity over raw optimization for speed on less than brand new processors?

Enough of that.


Be nice already, you're making Mr. Whiskers sad =(

Image

:P
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Be nice already, you're making Mr. Whiskers sad =(


Awww, isn't that the pot calling the kettle black? :P

Oh well, I still intend on writing a rebuttal on why I think the way I do. I had enough of this bickering, its best to "argue" intelligently. 8)
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

For those who want both speed and accuracy they'll have to wait for ASNES


Can't wait to see what you do. :D
Though, I like BSNES too. :P
Rashidi
Trooper
Posts: 515
Joined: Fri Aug 18, 2006 2:45 pm

Post by Rashidi »

mudlord wrote:
For those who want both speed and accuracy they'll have to wait for ASNES
Can't wait to see what you do. :D
Though, I like BSNES too. :P
ASNES? is that Assembly (& hand-optimized) version of BSNES?
i'll definetly wait for something like that :D
byuu

Post by byuu »

Awww, isn't that the pot calling the kettle black? :P


Image
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Okay, I'll be nice. For Mr Kitty's sake as well. 8)
AamirM
Regen Developer
Regen Developer
Posts: 533
Joined: Sun Feb 17, 2008 8:01 am
Contact:

Post by AamirM »

mudlord wrote:
For those who want both speed and accuracy they'll have to wait for ASNES


Can't wait to see what you do. :D
Though, I like BSNES too. :P


Hi,

Hah, I doubt I'll do any better. I am sure ZSNES will fill up the space for a fast and accurate emu soon. I like bsnes too but I've never been able to run it full speed on my PC :cry: .

stay safe,

AamirM
grinvader
ZSNES Shake Shake Prinny
Posts: 5626
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

AamirM wrote:I am sure ZSNES will fill up the space for a fast and accurate emu soon.

I wonder...
皆黙って俺について来い!!

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
Locked