Chip8-Emulator
- 6 Devlogs
- 16 Total hours
Chip 8 Emulator, that lets you run early computer software originally designed for chip 8 on modern computers
Chip 8 Emulator, that lets you run early computer software originally designed for chip 8 on modern computers
As a prize for your great work, look out for a bonus prize in the mail :)
Last time, I talked about how Continuous Integration was eating my time, Windows was demanding my soul with missing DLLs, and Apple Gatekeeper was holding my app hostage for $99.
This time, I fought back. The emulator is now completely polished, actually sounds like a retro console, and distributes like a real, professional application.
The CHIP-8 doesn’t have a sound card. It basically has a timer attached to a buzzer. If the soundTimer register is greater than 0, it beeps. It ticks down at exactly 60Hz.
I basically wrote some code in c++ to generate a square wave, and used raylib’s audioPlayer to support classic beep sound of chip 8.
Originally, I hated that a black developer console popped up behind the Emulator. It screamed unfinished project.
So, I spent hours engineering it out. On Windows, I added the -mwindows flag to the compiler to change it from a Console App to a pure GUI App. On Mac, I completely rewrote my CI pipeline to generate a standard Apple .app folder structure so it would look like a commercial application.
the result? Total disaster. Because my newly polished Windows .exe was a standalone GUI application without a digital signature, Windows Defender immediately flagged it as a virus. Meanwhile, Apple’s Gatekeeper still blocked the .app bundle because I refuse to pay Tim Cook $99 a year.
The Real Solution: I reverted it all. I am keeping the console.
This was my first time actually using the tag feature of git in practical life, i after git push v1.1.0 i was wondering the new releases are created, code editor says everything is uptpdate with remote, but why the hell my gihub does not shows new code, and guess waht branch and tags need to be updated seperately.
coming from web development background, creating ui in C++ raylib was completely new.
No concept of ui elements here, cant just attach event listeners to button like we do in javascriot
60 times a second, and check if it overlaps the coordinates of a buttonraygui, written by the original creator of the raylib
AppleScript on Mac to trigger the file picker, but on Windows, I had to pull up a shell in the backgroundContinuous Integration i did countless iterations solving dumb errors, adjusting platform depended configs and so on….exe file each time. (aah friends are a blessing, aren’t they, my friend? huh?)Checkout lateset release (supports mac and windows, can’t say about linux for sure)
System Settings go to privacy and security scroll down there you will se option to open anyway
Can anyone with linux please let me know if it works (i am to lazy to install VMWare)
1 2 3 4
q w e r
a s d f
z x c v
use thses keys to give input, nothing else will work (other keys only work in launcher interface like backspace to get back to menu form emulator)
not fully complete it still requires some polishing like right now the graphics is flickering a bit, probably due to a bug in graphics engine logic or I might need to change how fast cycles are being executed.
Checkout my previous devlogs to know what is chip8?
This time I felt like nobody in the world can explain the logic to translate those opCodes. Coming from high level low level is absolute new, i thought I might find some resemblance (guess what?? I was wrong)
I still can’t say in understand it 100%, but the struggle is on
we load the ch8 binary file -> Save instruction in the RAM -> a continuous while loop which executes each instruction code
executeCycle, inside this funciotn we have -To keep this short, I will not get into the details about translating the chip8 instruction.
Current value of the pixel and the to be updated value
The original chip8 keypad was like this
Chip8 Modern keyboard
1 2 3 C 1 2 3 4
4 5 6 D ---> Q W E R
7 8 9 E A S D F
A 0 B F Z X C V
chip 8 basically a a interpreted programing language of ancient times (70s). It kind of mimics a small computer
(8 bit), limiting its max memory to4KB. But the special thing is, its not just a language, it mimics a CPU architecture, making it like a different computer system which doesnt exists phycally, but uses other physical computer to run its own acrhitecture.
Well think of emulator as a extra added layer between the software and low level computer systems. which does some magic to run a software which is not ment to run on that system.
Windows Application –> macOS (Won’t Run)
Windows Application –>
Emulator–> macOS (Will Run)
Emulator (Translates Instruction code for C1 to C2) –> now C2 can run (Translated instructions).Lets say you have a program which was designed in and for Chip8, but now you dont have a chip8 system, how do you run this program?
We basically use an emulator to trick the software to thing that its running in the old Chip8 system but its acctually running on moder computers.
Howwwwww? well
Chip8has 35 standard instructions and only4096bytes of memory, so its faily easy to map each and every of its instruction and instead do it in the modern langauges (like i have used C++).
We store the data in modern
C++ Data Structures, but we trick the target software to thing that it has dorect acces to theRAMof the computer.
4096, weher first 200 are reserved for the chip8 system use, rest is opent to softwares running on it.raylib for nowThis is like my first proper project in low level programing
I wanted to take on the low level for a long time, took the chance this time
I know only the basics of chip 8 interpreter , I read cowgod’s chip8 technical reference last night
this is gonna be a very learning and building like thing,
been into the high level for over 5 (Full Stack) years now, hope I can find some similarities and help from my past experiences in to the low level
is anyone of you guys (gods) know about low level or specifically chip8 , please drop a comment because I thing I am too going to need babysitting 😭