Creating a Chip8 interpreter/emulator in C++14
In this tool-assisted education video I create a #Chip8 interpreter in #C++14. We overview the architecture specification document and use that to create a working emulator. Some sample games are run.
Download: https://bisqwit.iki.fi/jutut/kuvat/programming_examples/chip8/
Twitter: https://twitter.com/RealBisqwit
Patreon: https://patreon.com/Bisqwit (alternatives at https://iki.fi/bisqwit/donate.html)
Twitch: https://twitch.tv/RealBisqwit
Homepage: https://iki.fi/bisqwit/
You can contribute subtitles/captions at: https://www.youtube.com/timedtext_video?v=rpLoS7B6T94 Or to any video on my channel at:
https://www.youtube.com/timedtext_cs_panel?tab=2&c=UCKTehwyGCKF-b2wo0RKwrcg
The desktop environment is Enlightenment for Linux.
The editor is a custom editor that only runs in DOS.
The music is from Kingyo Chuihou! Tobidase Game Gakuen, converted into OPL3 using the means described in this video: https://youtu.be/7IeO7CYFd9E
You can download/listen to the song separately here: https://bisqwit.iki.fi/jutut/kuvat/programming_examples/chip8/music.ogg
NOTE: It's been brought to my attention that the document that I was reading has several misconceptions of the Chip8 architecture. Though I also read the Wikipedia article and a few other documents, there's a few things I missed. Here's a list of errors in my interpreter. Note that most of these "errors" have no practical bearing to executing pure chip8 programs, but are merely pedantic compatibility issues targeting the platform where the Chip-8 interpreter was originally released.
-- I and PC are 16-bit registers, not 12. That means that the "& 0xFFF" parts in my code should not be there, or should be replaced with "& 0xFFFF". This applies also to how the carry flag is handled in the "add I, Vx" instruction.
-- The memory map is 64 kilobytes, not 4 kilobytes. However, only the first 4 kilobytes are RAM. It is in fact possible to have more RAM (or less), from 2 to 32 kB. RAM is mirrored in the whole $0000-$7FFF range. A conforming implementation should perhaps use a 64-kilobyte array, and permit modifications only within the first 4 kilobytes. Ideally, part of the array should contain a verbatim copy of the Telmac 1800 ROM...
-- The built-in font should not be stored in the first 4 kilobytes, but within the "ROM", which is mapped at $8000-$81FF and probably mirrored throughout $8000-$FFFF. This memory should also be non-modifiable. See http://www.chip8.com/cosmacvip/VIP_Manual.pdf for information about the exact location and layout.
-- The 12-element stack should be stored at the particular address of $0FA0-$0FCF (or in an equivalent address of whichever bank is the last RAM bank)
-- The 16 V registers should be stored at the particular addresses of $0FF0-$0FFF (same note as above).
-- The 256-byte display memory should be stored at $0E00-$0EFF (same note as above).
-- The timer registers and stack pointer should not be stored in RAM (the COSMAC VIP stores them in R8 and R2 registers respectively).
-- The "sys" instruction should do emulation of RCA 1802 (COSMAC). This is deliberately left out from almost all modern Chip8 interpreters, including mine. On a similar note, the "cls" and "ret" instructions (00E0 and 00EE respectively) should be implemented as RCA 1802 code pre-initialized in those RAM addresses, and treated as the "sys" instruction instead. But then you could just create a COSMAC #emulator and forget about Chip8, as it's just a program running within the first 256 bytes of RAM and utilizing the 512-byte ROM. More information: http://datasheets.chipdb.org/RCA/MPM-201B_CDP1802_Users_Manual_Nov77.pdf
Видео Creating a Chip8 interpreter/emulator in C++14 канала Bisqwit
Download: https://bisqwit.iki.fi/jutut/kuvat/programming_examples/chip8/
Twitter: https://twitter.com/RealBisqwit
Patreon: https://patreon.com/Bisqwit (alternatives at https://iki.fi/bisqwit/donate.html)
Twitch: https://twitch.tv/RealBisqwit
Homepage: https://iki.fi/bisqwit/
You can contribute subtitles/captions at: https://www.youtube.com/timedtext_video?v=rpLoS7B6T94 Or to any video on my channel at:
https://www.youtube.com/timedtext_cs_panel?tab=2&c=UCKTehwyGCKF-b2wo0RKwrcg
The desktop environment is Enlightenment for Linux.
The editor is a custom editor that only runs in DOS.
The music is from Kingyo Chuihou! Tobidase Game Gakuen, converted into OPL3 using the means described in this video: https://youtu.be/7IeO7CYFd9E
You can download/listen to the song separately here: https://bisqwit.iki.fi/jutut/kuvat/programming_examples/chip8/music.ogg
NOTE: It's been brought to my attention that the document that I was reading has several misconceptions of the Chip8 architecture. Though I also read the Wikipedia article and a few other documents, there's a few things I missed. Here's a list of errors in my interpreter. Note that most of these "errors" have no practical bearing to executing pure chip8 programs, but are merely pedantic compatibility issues targeting the platform where the Chip-8 interpreter was originally released.
-- I and PC are 16-bit registers, not 12. That means that the "& 0xFFF" parts in my code should not be there, or should be replaced with "& 0xFFFF". This applies also to how the carry flag is handled in the "add I, Vx" instruction.
-- The memory map is 64 kilobytes, not 4 kilobytes. However, only the first 4 kilobytes are RAM. It is in fact possible to have more RAM (or less), from 2 to 32 kB. RAM is mirrored in the whole $0000-$7FFF range. A conforming implementation should perhaps use a 64-kilobyte array, and permit modifications only within the first 4 kilobytes. Ideally, part of the array should contain a verbatim copy of the Telmac 1800 ROM...
-- The built-in font should not be stored in the first 4 kilobytes, but within the "ROM", which is mapped at $8000-$81FF and probably mirrored throughout $8000-$FFFF. This memory should also be non-modifiable. See http://www.chip8.com/cosmacvip/VIP_Manual.pdf for information about the exact location and layout.
-- The 12-element stack should be stored at the particular address of $0FA0-$0FCF (or in an equivalent address of whichever bank is the last RAM bank)
-- The 16 V registers should be stored at the particular addresses of $0FF0-$0FFF (same note as above).
-- The 256-byte display memory should be stored at $0E00-$0EFF (same note as above).
-- The timer registers and stack pointer should not be stored in RAM (the COSMAC VIP stores them in R8 and R2 registers respectively).
-- The "sys" instruction should do emulation of RCA 1802 (COSMAC). This is deliberately left out from almost all modern Chip8 interpreters, including mine. On a similar note, the "cls" and "ret" instructions (00E0 and 00EE respectively) should be implemented as RCA 1802 code pre-initialized in those RAM addresses, and treated as the "sys" instruction instead. But then you could just create a COSMAC #emulator and forget about Chip8, as it's just a program running within the first 256 bytes of RAM and utilizing the 512-byte ROM. More information: http://datasheets.chipdb.org/RCA/MPM-201B_CDP1802_Users_Manual_Nov77.pdf
Видео Creating a Chip8 interpreter/emulator in C++14 канала Bisqwit
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Texture Mapping & Polygon Rasterizing Tutorial (1/2) [C++20]](https://i.ytimg.com/vi/PahbNFypubE/default.jpg)
![Dyna Blaster ※ reverse engineering on DOS ※ Cracking VG Passwords S2e3](https://i.ytimg.com/vi/JMz_PYnpJPY/default.jpg)
![NES Emulator Part #1: Bitwise Basics & Overview](https://i.ytimg.com/vi/F8kx56OZQhg/default.jpg)
![](https://i.ytimg.com/vi/hPZo2eCwZiE/default.jpg)
![I designed my own 8-bit computer just to play PONG](https://i.ytimg.com/vi/7A1SzIIKMho/default.jpg)
![Writing a CHIP-8 emulator (interpreter) in Go - chip8go](https://i.ytimg.com/vi/MBWyVwyBMhk/default.jpg)
![Creating a DCPU-16 emulator in C++11](https://i.ytimg.com/vi/MvDtr3cNaLU/default.jpg)
![Creating a PIC16 emulator & NES music player (C++11 & electronics).](https://i.ytimg.com/vi/P82Zf31joPk/default.jpg)
![Chip 8 Old Tech in a New Light](https://i.ytimg.com/vi/V3ORJUS9YP4/default.jpg)
![Creating a Doom-style 3D engine in C](https://i.ytimg.com/vi/HQYsFshbkYw/default.jpg)
![Parser and Lexer — How to Create a Compiler part 1/5 — Converting text into an Abstract Syntax Tree](https://i.ytimg.com/vi/eF9qWbuQLuw/default.jpg)
![Turn your PC into a BBC Micro and play every game ever written for free](https://i.ytimg.com/vi/HjP6OX9FFq0/default.jpg)
![Obfuscated C programs: Introduction](https://i.ytimg.com/vi/rwOI1biZeD8/default.jpg)
![Let's Emulate a Real Computer from Scratch in C++ (250 Lines)](https://i.ytimg.com/vi/DvOO3WtUuvE/default.jpg)
![So you want to write an interpreter?](https://i.ytimg.com/vi/LCslqgM48D4/default.jpg)
![Live stream: Coding a visualization tool for a possible future video](https://i.ytimg.com/vi/oVyx9L3IGfs/default.jpg)
![Origin of “Bisqwit”? Married? Font&color theme — Frequently Asked Questions, Part 1/4](https://i.ytimg.com/vi/uITpN-OZcuo/default.jpg)
![Justified Programming — Reason Parameters That Answer “Why”](https://i.ytimg.com/vi/OrQ9swvm_VA/default.jpg)
![Creating a NES emulator in C++11 (PART 1/2)](https://i.ytimg.com/vi/y71lli8MS8s/default.jpg)
![Bisqwit analyses TempleOS & its sole author, Terry A. Davis](https://i.ytimg.com/vi/t9l058vrURo/default.jpg)