byuu's message board

For discussion of projects related to www.byuu.org/


Previous  1 ... 9, 10, 11, 12, 13, 14, 15 ... 27  Next
emulator efficiency 
Author Message

Joined: Mon 09 Jan 2012, 10:44:17

Posts: 28
Post Re: emulator efficiency
Maybe this guy should go talk to losethos? They seem to have a certain ethos in common.

Wed 28 May 2014, 04:34:11

Joined: Wed 06 May 2009, 04:13:19

Posts: 4543
Post Re: emulator efficiency
SoraK05 wrote:
EDIT:
http://simple.wikipedia.org/wiki/Assemb ... chine_Code
Quote:
05 2A 00

This hexadecimal machine code tells an x86 computer processor to add 42 to the accumulator. It is impossible for a person to read and understand unless that person knows machine code.


Something along the lines of taking the direct machine code data and converting this to x86 expectations will respond in identical math?

This is a common proposal by people new to emulation. Unfortunately, it DOESN'T WORK.
Otherwise we'd've been doing it that way for the last twenty years).

The same assembly commands may do roughly the same thing on both processors, but they can take VERY different ways to get there, and software often relies not on the final results being roughly similar, but on the final results being exactly the same, the hardware bugs being exactly the same, and in some cases, the TIME TAKEN being exactly the same, and even the steps taken to produce the end results being exactly the same.

There will also be subtle(or sometimes drastic) differences in complex behavior, and unexpected interaction between seemingly unrelated instructions.


And again, this is still ignoring the fact that the SNES sound and video units HAVE NO PARALLEL in the PC world.
While ARGUABLY an x86-64 processor does more or less the same thing as a 65816, a RadForce HD90210FX video card behaves WILDLY different than SPPU1 and SPPU2.
There's basically no functional similarities other than they both output a picture. But that's like saying Da Vinci's and Picasso's paintings are basically the same because they both drew pictures.

Quote:
Doing some arithmetic and if/or etc where required for an algorithm (and relevant shortcut) to get the numbers on the ROM which go to video/sound/temp should not be very intensive and should have compatibility suitable to console design.

No, it SHOULD be very intensive, because the not-math required to simulate one computer's behavior on another, unrelated computer is VERY COMPLEX.

You can take shortcuts, and things will kinda-sorta work. ZSNES stands as testament to that fact.
But they will only kinda-sorta work. They won't work RIGHT.




I strongly urge you to stop reading dictionary definitions and Wikipedia overviews and start ACTUALLY TRYING TO PROGRAM A COMPUTER before you offer further input on how computers work.

_________________
This post best viewed at 800x600
;write ! ! !

Wed 28 May 2014, 12:52:18
User avatar

Joined: Sun 05 Sep 2010, 15:42:48

Posts: 1344
Post Re: emulator efficiency
kode54 wrote:
Where can you see lions?
Only in Kenya!

_________________
http://helmet.kafuka.org

Wed 28 May 2014, 14:31:57

Joined: Wed 06 May 2009, 04:13:19

Posts: 4543
Post Re: emulator efficiency
Kawa wrote:
kode54 wrote:
Where can you see lions?
Only in Kenya!

I am going to hunt you down and kill you.

_________________
This post best viewed at 800x600
;write ! ! !

Wed 28 May 2014, 14:34:38
User avatar

Joined: Wed 08 Sep 2010, 17:05:03

Posts: 133
Post Re: emulator efficiency
SoraK05 wrote:
I have attempted to propose an algorithm based on hardware movement to be done on a ROM and result in the same output numbers as those sent to video/sound/temp.


Hardware moves? I didn´t know that :cry:

hehe let´s take a Rom and put some hardware movement on it :mrgreen:

Wed 28 May 2014, 14:59:24

Joined: Wed 06 May 2009, 04:13:19

Posts: 4543
Post Re: emulator efficiency
The Doug wrote:
Hardware moves? I didn´t know that :cry:

You've clearly never turned on a PC with a hard drive you hadn't screwed down yet.
...
When you do, make sure you set a hand on top of that drive so it doesn't jump into your motherboard.

_________________
This post best viewed at 800x600
;write ! ! !

Wed 28 May 2014, 15:24:29

Joined: Fri 26 Oct 2012, 14:47:06

Posts: 81
Post Re: emulator efficiency
Hardware movement - flow of paths by steps.

All hardware, irrespective of design, will do some kind of math steps which are preprogrammed and some logic also.
The cycles in order to perform these steps is where speed/design will compliment.
The computer will do a series of preprogrammed math steps continuously with some limited logic functions (all relateable to an algorithm).
Where the basic math steps represented by the machine code (and logic) are done, the rest is cycles to do math step-by-step which should be seamless when fed input like the ROM.


http://en.wikipedia.org/wiki/File:Apple_II_Monitor.png
To illustrate, this shows machine code and the respective assembly version.
Each step in general will perform some mathematics (like compare can subtract numbers and check if the result is positive/negative) on the lowest level.

Generally detailing the math steps each machine code instruction will perform to portray the steps in an algorithm is what I mention - i.e. the math steps being done by the machine code instructions (and any further details for logic which are also mechanical).

While computer layout is different, the fundamental math ability is common and labelled/traced in alternate manners.

The math steps are universal in an algorithm, and its compilation for a system should be accommodated when the same algorithm is compiled for another system to perform the math to suit its layout. The algorithm should one step-by-step process to suit what the SNES does in math steps (and logic), relatable to the steps the machine code instructions will perform when read (including room for buffer in the algorithm for the steps), and the rest is just doing processing of each step where required.

The definition of an emulator proposes that one algorithm will detail the precise functioning design of the system, and any further tweaks can be to accommodate shortcuts where applicable (without breaking proportion).
For archival purposes, the SNES can be written in the exact algorithm of what the machine code will do in its steps, and this can be compiled (with adjustments in a functional emulator binary) for its steps to suit another architecture and its ability to perform.


EDIT:
Like a list of 'if' for machine code (opcodes) and the math / logic they will do, and a shared virtual buffer. The rest is letting the steps perform, and for some specific commands like sending numbers to video output be considered (in the tweaked, non archival algorithm) to a plugin/coding which will link it to the monitor of the device.


SoraK05


Wed 28 May 2014, 22:23:43
Screw y'all
User avatar

Joined: Tue 28 Dec 2010, 08:27:37

Posts: 1147
Post Re: emulator efficiency
SoraK05 wrote:
Each step in general will perform some mathematics (like compare can subtract numbers and check if the result is positive/negative) on the lowest level.

Believe it or not, this part is not a mathematical operation. While it is certainly closely related to math, "checking" anything isn't math.

_________________
CaptainJistuce wrote:
Well, the world used to run at 30 FPS until YouTube got 60 FPS support.
It's only recently that we've been able to see 60 FPS at all, and we should thank the Google for it.

Wed 28 May 2014, 22:34:27

Joined: Fri 26 Oct 2012, 14:47:06

Posts: 81
Post Re: emulator efficiency
While it may be mechanical and considered part of 'logic', these elements are considered part of mathematics and can be written in an algorithm which a computer in essence represents - the determining element after a compare for its 0/1 type response is part of the mechanical representation of this math (part of algorithm) to send signal down a certain path, allowing for current from the result and the hardware layout for this logic/math/algorithm function e.g.

Wed 28 May 2014, 22:37:32
User avatar

Joined: Wed 08 Sep 2010, 17:05:03

Posts: 133
Post Re: emulator efficiency
SoraK05 wrote:
Hardware movement - flow of paths by steps.


W-what? Flow of paths by steps? Wtf is that?

Well, ok, now show us some code (a working emulator). Otherwise, shut up.

Wed 28 May 2014, 22:47:35
Board Admin
User avatar

Joined: Sat 11 Apr 2009, 04:21:58

Posts: 4783
Location: Australia
Post Re: emulator efficiency
SoraK05 wrote:
Each step in general will perform some mathematics (like compare can subtract numbers and check if the result is positive/negative) on the lowest level.

No.

There are much, much lower levels than this, all the way down to modelling the way electrons flow through silicon. Not all of them are important for emulation, but some of them are.

Quote:
For archival purposes, the SNES can be written in the exact algorithm of what the machine code will do in its steps, and this can be compiled (with adjustments in a functional emulator binary) for its steps to suit another architecture and its ability to perform.

This is possible, but the result would probably be no faster or more efficient than higan, and it would take a lot more work to specialise an emulator for each game, so why bother?

Covarr wrote:
While it is certainly closely related to math, "checking" anything isn't math.

If studying the hole in a doughnut is math, I'm not going to complain about checking being math.

The Doug wrote:
W-what? Flow of paths by steps? Wtf is that?

Presumably it's a Hebrew idiom that just doesn't translate into English very well.

_________________
Maintainer of the unofficial git repository for bsnes.

The ending of the words is ALMSIVI.

Thu 29 May 2014, 00:11:29
User avatar

Joined: Wed 08 Sep 2010, 17:05:03

Posts: 133
Post Re: emulator efficiency
Quote:
Presumably it's a Hebrew idiom that just doesn't translate into English very well.


No, the truth is that he is writing a lot of bullshit. He clearly has not the slightest ideia about this subject.

He talks about math, but seems that he never read Turing's paper.

He is a new guy to programming that has a lot of ideas, but never wrote code related to these ideas. After coding some lines he will notice the absurd things he's talking about.

I still think he's fooling with us. Or maybe it's an experimental bot. Othewise this is an epic thread.


The Doug


Thu 29 May 2014, 00:29:38

Joined: Fri 26 Oct 2012, 14:47:06

Posts: 81
Post Re: emulator efficiency
http://courses.engr.illinois.edu/ece390 ... HEADING1-0

http://courses.engr.illinois.edu/ece390 ... H06-2.html
Quote:
The add instruction adds the contents of the source operand to the destination operand. For example, add ax, bx adds bx to ax leaving the sum in the ax register. Add computes dest :=dest+source while adc computes dest :=dest+source+C where C represents the value in the carry flag. Therefore, if the carry flag is clear before execution, adc behaves exactly like the add instruction.


Quote:
The inc (increment) instruction adds one to its operand. Except for the carry flag, inc sets the flags the same way as add operand, 1 would.


Translating the steps of what each opcode will perform to math steps appropriate to the SNES ones, so that the PC x86 architecture can replicate the equations/logic.


And a PC has a flow of electricity going through paths, and the process of cycles and steps can be described as the flow of the hardware in the steps it is performing.



I have had some basic programming attempts, have some experience with LOGO/BASIC/C++ and have a general idea. I've used computers for some time.

I get that the process of emulating is to have an appropriate algorithm to calculate the ROM numbers for the same results as the SNES.
(I get LLE, HLE, Dynamic Recompiler and the concept)
I get that all opcodes read in the ROM must have a formula to relate.
Thanks.

Thu 29 May 2014, 00:48:30
Screw y'all
User avatar

Joined: Tue 28 Dec 2010, 08:27:37

Posts: 1147
Post Re: emulator efficiency
What math operation does PUSH represent?

_________________
CaptainJistuce wrote:
Well, the world used to run at 30 FPS until YouTube got 60 FPS support.
It's only recently that we've been able to see 60 FPS at all, and we should thank the Google for it.

Thu 29 May 2014, 00:51:10

Joined: Tue 31 May 2011, 22:39:35

Posts: 348
Post Re: emulator efficiency
I feel like doing some creative writing today. May as well do it inside this gem of a thread!



Assuming you want to find out the math behind each instruction, and then map those to another completely different architecture, we can extrapolate on that.

To keep things simple to start we can use addition, since the processors will all be able to do that, and it's easy to wrap your mind around.

I hope I have all the instructions right here. Also excuse the oversimplification.

You analyses your "ROM" to pull out all the math, and you see a whole bunch of 'ADC' instructions. Okay, that's great. x86 has a ADC instruction too! We'll just map that over directly, and we're done with addition.


Now that we have that out of the way, let's move onto multiplication:

...Oh. It doesn't seem that the SNES has an instruction solely for multiplication. Ahh, but that's good news, this is what we came here for! We can gain performance here.
We can detect the method that the SNES uses, whatever it is, for multiplication and just replace it with one MUL instruction!
Now instead of all those bit shifts, additions, or whatever math magic was being done we just have one simple instruction! Performance++
On to the next instruction!


Well let's hold on now.
On my overclocked Intel 747 Wizbang Edition it takes 0.002μ seconds to do one MUL instruction.
On your puny Intel 2500k it takes 0.009μ seconds to do one MUL instruction.
Finally, the "math" that it does on the SNES to multiply takes 0.1µ seconds.

Now everything is running too fast! All the games will be running too fast! Your optimizations are way too good! It's unplayable!

Okay, so the obvious solution would be insert a bunch of NOP instructions, so that our MUL instruction finishes after 0.1µ instead. That way it matches the SNES.
But how many? My Intel 747 needs more NOPs than your 2500k.
Furthermore, because of the way modern CPU work not only do two CPU of the same type run at different clock speeds and require different amount of NOPs, but the CPU speed itself fluctuates constantly! Not only that, but your CPU is also doing more than one thing at a time, and you never know when another pesky program (or your OS) is going to take CPU time from your MUL instruction. Oh dear! Looks like there isn't really a reliable way to time how many NOPs are required.

In addition to the "running way too fast" problem, you also have the problem that the games were coded with very specific hardware in mind. A SNES has multiple chips on the motherboard, each chip has to talk to each other, and each chip has it's own time it takes to accomplish it's task.

So just for illustrative purposes let's say that it might take 1µ for the sound chip to process what is passed to it.
So in the game I'm programing using the main chip I pass a call to the sound chip that says "Hey! Here is this data, do some math on it, and pass me back the result!"
Now, I could wait for 1µ doing nothing while the sound chip does it's thing, but that's a huge waste of resources!
Instead, I want to do some multiplication while I wait! Knowing that it takes the SNES 0.1µ seconds to do one multiplication I decide to do 10, and then ask get the result back from the sound chip. Now that's being efficient!

However, once you run this in your emulator where you swapped out the multiplication instructions for a simple MUL, the ratios of how long multiplication takes in relation to everything else is way off. You are now going to be asking the sound chip for it's result before it's ready, and everything will come crashing down around you.


These are just a few massively oversimplified problems that you would run into. And even if they weren't overly simplified, they pale in comparison to the other problems that you would run into if you were to try doing things in this way. These problems are trivial compared of the other ones you need to work around.
You need to make sure that everything you do is taking the proper amount of time, and staying in the proper order, so that the different components in the machine you are emulating can actually communicate properly. If they can't, then your emulator won't work.
And wouldn't you know it? That's what the current emulators do. Doing that is literally what makes them so slow.

Thu 29 May 2014, 02:37:15
Previous  1 ... 9, 10, 11, 12, 13, 14, 15 ... 27  Next

Who is online

Users browsing this forum: No registered users and 0 guests

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