This page will include WIP screenshots and other fun stuff for MAME™, M1, and whatever else I'm working on.

1/30/2006

Emulation 101

A couple of people have recently asked for an introduction to how emulation actually works at a lower level. I will attempt to begin to answer that here 🙂 Some programming experience is extremely helpful to understand this.

Introduction

At their lowest level, digital computers run programs that composed ultimately of a stream of numbers (this is called machine language). For a given CPU chip, certain numbers always mean certain things. For instance, on a 6502, the number “105” translates to “ADC” or Add with Carry. It’s important to realize that every time the 6502 encounters instruction 105 it will always perform the same addition operation. You could, in fact, write a valid program composed entirely of instruction 105, although it wouldn’t be very interesting.

Incidentally, the 3-letter code for the instruction (“ADC” in this case) is what is called assembly language, sometimes abbreviated ASM. Most programs for 8 bit processors were written in this manner – it’s somewhat cryptic, but it also gives you full control with minimum size. The number itself is known as an opcode (operation code).

Inside the CPU there’s hardware to fetch the next instruction number from memory, figure out what it is, and execute it. Now, there’s nothing digital hardware can do that digital software can’t also do. So emulation starts off with a block of code (a CPU core) which does the same thing for a given type of processor, like a 6502 or Z80. In C-like pseudo-code, it would look something like this:

CPU_Start:
opcode = fetch_next_opcode();
if (opcode = 105) do_addition_with_carry();
else print “ERROR: Unknown opcode!”;
goto CPU_Start;

That is remarkably close to how most real CPU cores work, incidentally. The major difference is ususally that a C switch statement is used to efficiently go to the right place for each opcode.

Yeah, but where’s the wakka-wakka come from?

Each CPU has a limited amount of memory it can talk to. For 8 bit CPUs this was usually 64K (65,536 units). This means that each unit of memory has an address (similar to the one on your home) from 0 to 65,535. Some of this memory must be dedicated to the program itself (usually stored in ROMs). Some must be dedicated to a work area for the program (so-called work RAM). But addresses don’t have to be just memory – they can also be devices. For instance, in Pac-Man, one set of memory addresses controls the horizontal and vertical positions of Pac-Man. By writing different numbers there, the video hardware will dutifully draw Pac-Man at various places on the screen without further CPU intervention. (This is quite a time-saver for the CPU!) Such special addresses are called registers or sometimes switches.

For emulation, this is relatively easy. CPU cores don’t want to tie themselves to one machine, so they call out to other code in the emulator (sometimes called the memory manager or memory mapper). To read a memory location, they call out with an address and expect to get an answer back from elsewhere in the emulator. To write a memory location, they call out with the address and the new number to place at that address. Code elsewhere in the emulator figures out for the current game if that address is work RAM, program storage, or something else entirely. The complete set of valid memory addresses for a machine is called a memory map.

A simplified real-world example is Pac-Man once again. Addresses 0 to 16,383 are program storage (ROM chips in this case). Addresses 20,464 through 20,479 control the screen positions of Pac-Man and the ghosts. Address 20,480 contains the current status of the joystick. And so on. If you respond properly to all of the necessary addresses you get a running game. That is how basic emulation works.

Posted by Arbee in General @ 9:52 pm -

1/29/2006

Change warning

For CHD-CDs, it’s now recommended you use full raw mode in CDRDAO. Current CHDMANs will give you a scary warning (with bad grammar, no less) and create the file anyway, but the next version of MAME *will* handle conversions from RAW data to any other sector format properly and that way we’re guaranteed to have all the data.

Also, an upcoming version of CHDMAN (possibly not the very next version of MAME) will be able to directly create a CHD-CD from a physical CD on Linux and Windows 2000/XP systems.

Posted by Arbee in General @ 2:20 pm -

1/28/2006

Channel changers

Added per-voice muting for almost all supported formats to Audio Overload, including .PSF.

Posted by Arbee in General @ 1:48 pm -

1/26/2006

Running in reverse

As most people understand by now, the ZiNc arcade emulator runs games based on varients of the original 1995 Sony PlayStation hardware. For a variety of reasons (one being just to see what happened), I’ve done some initial work towards having it also emulate the base home console itself. The 3 major points of difference are the CD-ROM drive’s type (custom Sony vs. IDE or SCSI in the arcade boards that used CDs), the memory cards, and the joypads. I hooked up a CD-ROM capability by loading and calling out to an ePSXe-compatible CD plugin and almost immediately started getting some cool things to happen. Here’s a few:

Silent Hill: Boot warning Title
Wipeout XL: Title In-game
Tekken: Galaga (loading)In-game
Crash Bandicoot: Title
Time Crisis: Title In-game
Madden NFL ’97: Main menu In-game

Please note that the final fate and design of this feature are not yet decided, so if you’re definitely interested in shaking things up a little in PSX emulation (it’s been kinda dead for a while, hasn’t it?), voice your support on the official ZiNc forum at bannister.org.

Posted by Arbee in General @ 1:16 pm -
Content
Home
SDLMAME/MESS/HazeMD home
NEStopia Linux home
AO .PSF2 status
AO SDK (source)
My music rips
M1 home
WIP driver downloads
Links
Aaron’s WIP
Audio Overload forum
Audio Overload home
Bobby Tribble's Unemulated Games
Dave Widel's page
David Haywood (Haze)'s WIP
Discrete Logistics
Dox's WIP
FPGA Arcade
Frank Palazzolo's WIP
Kale's MAME WIP
Luca Elia's WIP
MAME E2J, home of BridgeM1
MAME Testers
MAMEdev.org
MAMEWorld
Project 2612 (Genesis VGM rips)
Robiza's WIP
ROP Music Laboratory
Slick's NSFE downloads
SNESMusic
System 16, the Arcade Museum
The MOD Archive
Ville's Development Log
Zophar's music archive

Categories



Archives

January 2006
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  


Meta
RSS 2.0
Comments RSS 2.0
WordPress

Powered by WordPress