360 likes | 452 Views
Gabriel Honoré. What is it?. A collection of software emulators A software emulator is a computer program that imitates an electronic device or another program . Examples : DOSBox MAME. What is it?. 1º - A Commodore 64 emulator. What is it?.
E N D
What is it? • A collection of software emulators • A software emulator is a computerprogram that imitates an electronicdevice or another program. • Examples: • DOSBox • MAME
What is it? • 1º - A Commodore 64emulator
What is it? • 2º - A NintendoEntertainmentSystem (NES) emulator
Whatisit? • 3º - A set of abstractions,components, and toolsthat can behelpfulformakingotheremulators(WIP) FRAMEWORK … … ?
Motivations • I noticed that: • People always choose statically-typedlanguages for making them. • Proceduraldesigns are preferedwhencomparedtoobject-orienteddesigns. • Whyisthat? • Performance issues. • Isthatreally a problemnowadays?
Goals • Whatdid I wanttoaccomplish? • Writeeverything in Smalltalk! . • OO design first, then think about performance. • Recreatethefeeling of the original machines • Highqualityemulation. • Createaneasyto useframeworkforwritingcomputer & gameconsoleemulators
Thesystementities • A common C64 system has:
Theusersideentities • Theuserwantstointeractwiththeemulatedsystemthrough:
Groups of entities Objectsfor translation User’s IO devices Thesystementities
Groups of entities • Thesystemmodel • Theuser’s IO devices • Theobjectsthatallowcommunicationbetweenthetwoworlds
Thesystemmodel POWER SUPPLY PERIPHERALS MAIN UNIT SOFTWARE MEDIA
Thesystemmodel • Thepowersupply • Implementsthe concept of “keepingalive”electricaldevices • Works at a specifiedfrequency • Manydevices can bepluggedtoit • It’simplementedwith aSmalltalkprocess
Thesystemmodel • Themainunit
Thesystemmodel The C64 architecture (simplified) CPU (MOS 6510) Address decoder IO CHIPS MEMORIES Video chip MOS 6569 R E G Mainmemory (64K RAM) Color (?K RAM) Sound chip MOS 6581 R E G Basic (?K ROM) R E G Kernal (?K ROM) CIA 1 Char (?K ROM) R E G CIA 2
Thesystemmodel The NES architecture (simplified) CPU (MOS 6502) Address decoder Color palette (32 bytes RAM) IO CHIPS MEMORIES Video chip PPU R E G Characterinternalmemory (2K RAM) Memoryprovided bythecartridge Sound chip APU R E G R E G Sprite RAM (256 bytes) DMA R E G IO
Thesystemmodel • How do the machines work? • The CPU isclockedbythepowersupply • The CPU readsfrom and writestothe bus • ie: at:anAddressput:aNumber • Addressdecoder: Addressinterval -> Chip • (16r0000-16r7FFF) -> RAM (0000-7FFF) • (16r8000-16r800F) -> Video chip (0000-000F) • Theselected chip getstherequest,and theregisters interface mapitintoanaction.
Thesystemmodel • Theperipherals:
Thesystemmodel • The media
Thesystemmodel The Video system DEVELOPER ONLYNEEDS TO IMPLEMENT THESE TWO OBJECTS RETROBJECTS SIDE Palette Powersource Video chip Frame buffer Color generator External interface TV Converter
Thesystemmodel The Audio system RETROBJECTS SIDE Buffer Strategy Power source External interface Sound chip Sampler Speaker DEVELOPER ONLYNEEDS TO IMPLEMENT THIS OBJECT
Thesystemmodel The Input system OUTSIDE RETROBJECTS RETROBJECTS Representation of user’s keyboard User presses The ‘A’ key External interface C64 keyboard Adaptor DEVELOPER ONLYNEEDS TO IMPLEMENT THESE TWO OBJECTS
Groups of entities • Thesystemmodel • Theuser’s IO devices • Theobjectsthatallowcommunicationbetweenthetwoworlds
Theuser’s IO devices • External interfaces: FMODEx SDL & xffd SDL & OpenGL Files
Groups of entities • Thesystemmodel • Theuser’s IO devices • Theobjectsthatallowcommunicationbetweenthetwo “worlds”
Translationobjects • Loaders • Take a file and convertsitintothe actualsoftware media, ie: T64, PRG, TAP. • Adaptors • Take a user input event and convertsitintoanaction in themodel. • ie: User’skeypress -> C64 keypress • TheGUIs
Theframework • Someabstractions: • Devices • I/O chips • Sound chips • Video chips • Schedulingprocess
The framework • Somecomponents: • TV, speaker, powersupply • Digital pins, one-way and bi-directionalports • Addressdecoders: mapping, bank-switching,mirroring • Memories: RAM, ROM and registers • Stroberegisters • Counters and comparators • Buttons and switches • Video filters, samplers, etc.
Theframework • Tools: • Notmany so far • Goal: • More interactivedevelopment,doinglessprogramming.
Conclusions • Smalltalk can do that, too! • The Smalltalk environment is idealfor modeling hardware. • Profiling is the key for getting greatperformance without compromisingthe design.
Future works • Make it cross-platform • Make it run in Mac & Linux • Keepimprovingtheemulators. • Keepevolvingtheframework. • Documentation, please! • No tests • Make more emulators!
THANK YOU! Gabriel Honoré ghonore@gmail.com http://www.zeek-it.com.ar/retrobjects/