LemGen (Linguistic EMulation and Generation ENgine)
Download
Report
Transcript LemGen (Linguistic EMulation and Generation ENgine)
EmuCade
An Arcade Game
Emulator
CS491 Project
Spencer Perreault
Overview
Emulation & Video Game Systems
Host and Target Systems
Implementation
Demonstration
What is Emulation?
One device/system imitating another
Host
and target
Implementations can vary:
Hardware
or software
Behavior is paramount
Video Game Systems
Specialized hardware
Short
life spans
Wide variety of software
Digital preservation of games
Playability
on modern machines
Programmed for specific hardware
Project Goals
Write an emulator
Compatible
with at least one system
Reusable components
Portable
Full speed
Target System
Space Invaders (Taito, 1978)
Arcade
classic
Hardware
Well
documented
Intel 8080 CPU
8-bit, 2 Mhz
Few
special circuits
Host System
Closely tied to programming language
Assembly
for speed
Sometimes C, C++
Opposite route
C#,
managed code
Common Language Runtime (CLR)
Virtual Machine on a Virtual Machine
Microsoft
Visual Studio 2008
Components
Emulator
Machine
CPU core
Host UI Layer
Memory
Port I/O
CPU Core
Registers
Pairs
Instruction set
Instruction loop
Fetch-Decode-Execute
Interrupt
handling
Sample Instruction: ADD
// Mnemonic Code
Flags
Description
// ADD S
10000SSS ZSPCA
Add register to A
void OP_ADD(byte src)
{
int result = A + src;
SetFlags(Flags.Carry, (result & 0x100) != 0);
SetFlags(Flags.Auxiliary, ((A ^ src ^ result) & 0x10) != 0);
A = (byte)result;
CalcFlags(A, Flags.Zero | Flags.Sign | Flags.Parity);
}
Memory
Address space
Start and End Address
Size
Description
Read only?
0000h
1FFFh
8K
ROM
Yes
2000h
23FFh
1K
Work RAM
No
2400h
3FFFh
7K
Video RAM
No
4000h
5FFFh
8K
RAM Mirror
Yes
Video RAM
256x224
monochrome bitmap
Port Input/Output
Button input
Bits
set to indicate button press
DIP switches
Sound effects
Bits
set to trigger sound
Sounds generated by analog circuits
16-bit shifts
Host UI Layer
Windows form
Drawing
Read from VRAM
Rotation and coloration
Keyboard
events
Mapped to button presses
Execution Procedure
Initialize form and event handlers
Load Space Invaders ROM
Virtual
ROM address space
Execute simulated CPU
Cycle
increments based on frame rate
Raise interrupts for vertical synchronization
Demonstration
Conclusion
Lessons learned
Emulation
possible with managed code
Requires optimization
Testing
is critical
Unit tests
Debugging
Pick
an interesting target system
Future Ideas
Implementation
Optimization
Dynamic recompilation
Advanced
code generation
Compatibility
Support
for more machines/games
Z80 CPU core in progress