Download - Retrobjects - Fun with C64 and NES
![Page 1: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/1.jpg)
Gabriel Honoré1
![Page 2: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/2.jpg)
What is it?• A collection of software emulators
– A software emulator is a computerprogram that imitates an electronicdevice or another program.
• Examples:– DOSBox– MAME
2
![Page 3: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/3.jpg)
What is it?• 1º - A Commodore 64 emulator
3
![Page 4: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/4.jpg)
What is it?• 2º - A Nintendo Entertainment
System (NES) emulator
4
![Page 5: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/5.jpg)
What is it?• 3º - A set of abstractions,
components, and tools that can be helpful for making other emulators(WIP)
?…
FRAMEWORK
…
5
![Page 6: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/6.jpg)
Short demo
6
![Page 7: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/7.jpg)
Motivations• I noticed that:
– People always choose statically-typedlanguages for making them.
– Procedural designs are prefered whencompared to object-oriented designs.
• Why is that?– Performance issues.
• Is that really a problem nowadays?
7
![Page 8: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/8.jpg)
Goals• What did I want to accomplish?
– Write everything in Smalltalk! .– OO design first, then think about performance.– Recreate the feeling of the original machines– High quality emulation.– Create an easy to use framework
for writing computer & game consoleemulators
8
![Page 9: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/9.jpg)
How are theemulators made?
9
![Page 10: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/10.jpg)
The system entities• A common C64 system has:
10
![Page 11: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/11.jpg)
The user side entities• The user wants to interact with the
emulated system through:
11
![Page 12: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/12.jpg)
Groups of entities
User’s IOdevices
The systementities
Objects fortranslation
12
![Page 13: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/13.jpg)
Groups of entities• The system model• The user’s IO devices• The objects that allow
communication between thetwo worlds
13
![Page 14: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/14.jpg)
The system modelPOWERSUPPLY
PERIPHERALS
SOFTWAREMEDIA
MAIN UNIT
14
![Page 15: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/15.jpg)
The system model• The power supply
– Implements the concept of “keeping alive”electrical devices
– Works at a specified frequency– Many devices can be plugged to it– It’s implemented with a
Smalltalk process
15
![Page 16: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/16.jpg)
The system model• The main unit
16
![Page 17: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/17.jpg)
The system modelCPU
(MOS 6510)
Video chipMOS 6569
Sound chipMOS 6581
CIA 1
CIA 2
Main memory(64K RAM)
Basic (?K ROM)
Kernal (?K ROM)
Char (?K ROM)
Color (?K RAM)
MEMORIESIO CHIPS
REG
REG
REG
REG
Addressdecoder
The C64 architecture(simplified)
17
![Page 18: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/18.jpg)
The system modelCPU
(MOS 6502)
Video chipPPU
Sound chipAPU
DMA
IO
Character internal memory (2K RAM)
Memory providedby the cartridge
MEMORIESIO CHIPS
REG
REG
REG
REG
Addressdecoder
Color palette(32 bytes RAM)
Sprite RAM(256 bytes)
The NES architecture(simplified)
18
![Page 19: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/19.jpg)
The system model• How do the machines work?
• The CPU is clocked by the power supply• The CPU reads from and writes to the bus
– ie: at: anAddress put: aNumber• Address decoder: Address interval -> Chip
– (16r0000-16r7FFF) -> RAM (0000-7FFF)– (16r8000-16r800F) -> Video chip (0000-000F)
• The selected chip gets the request,and the registers interface map it into anaction.
19
![Page 20: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/20.jpg)
The system model• The peripherals:
20
![Page 21: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/21.jpg)
The system model• The media
21
![Page 22: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/22.jpg)
The system model
Powersource
Videochip
Framebuffer
Colorgenerator
Palette
Converter
TV Externalinterface
RETROBJECTSSIDE
DEVELOPER ONLYNEEDS TO IMPLEMENTTHESE TWO OBJECTS
The Video system
22
![Page 23: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/23.jpg)
The system model
Sampler Soundchip Speaker
Externalinterface
BufferStrategy
Powersource
RETROBJECTS SIDE
DEVELOPER ONLYNEEDS TO IMPLEMENT
THIS OBJECT
The Audio system
23
![Page 24: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/24.jpg)
The system model
User pressesThe ‘A’ key
Externalinterface
Representationof user’skeyboard
Adaptor C64keyboard
OUTSIDE RETROBJECTS
RETROBJECTS
DEVELOPER ONLYNEEDS TO IMPLEMENTTHESE TWO OBJECTS
The Input system
24
![Page 25: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/25.jpg)
Groups of entities• The system model• The user’s IO devices• The objects that allow
communication between thetwo worlds
25
![Page 26: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/26.jpg)
The user’s IO devices• External interfaces:
FMODEx
SDL &OpenGL
SDL & xffd
Files
26
![Page 27: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/27.jpg)
Groups of entities• The system model• The user’s IO devices• The objects that allow
communication between thetwo “worlds”
27
![Page 28: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/28.jpg)
Translation objects• Loaders
– Take a file and converts it into the actualsoftware media, ie: T64, PRG, TAP.
• Adaptors– Take a user input event and converts
it into an action in the model.• ie: User’s keypress -> C64 keypress
• The GUIs
28
![Page 29: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/29.jpg)
There are lots of thingsthat could be reusedon other emulators!
29
![Page 30: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/30.jpg)
The framework• Some abstractions:
– Devices– I/O chips
• Sound chips• Video chips
– Scheduling process
30
![Page 31: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/31.jpg)
The framework• Some components:
– TV, speaker, power supply– Digital pins, one-way and bi-directional ports– Address decoders: mapping, bank-switching,
mirroring– Memories: RAM, ROM and registers– Strobe registers– Counters and comparators– Buttons and switches– Video filters, samplers, etc.
31
![Page 32: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/32.jpg)
The framework• Tools:
– Not many so far – Goal:
• More interactive development,doing less programming.
32
![Page 33: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/33.jpg)
Conclusions• Smalltalk can do that, too! • The Smalltalk environment is ideal
for modeling hardware.• Profiling is the key for getting great
performance without compromisingthe design.
33
![Page 34: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/34.jpg)
Future works• Make it cross-platform
– Make it run in Mac & Linux• Keep improving the emulators.• Keep evolving the framework.
– Documentation, please!– No tests
• Make more emulators!
34
![Page 35: Retrobjects - Fun with C64 and NES](https://reader038.vdocument.in/reader038/viewer/2022102323/5466ad2baf79599b498b5427/html5/thumbnails/35.jpg)
Questions?
35