My CHIP-8 Emulator
What Is This And Why Could One Care?
CHIP-8 is actually an interpreted programing language! It was created back in 1977 by a guy named Joe Weisbecker for the COSMAC VIP with its purpose being a simpler way to write programs for computers. Instead of actual machine code one can chose to use shorter higher level hexadecimal instructions which resemble machine code and are interpreted on the fly.
If it is an interpreted programing language why is it called an emulator?! The interpreter simulates the physical computer's hardware completely and provides a virtual machine in which ones CHIP-8 code can run. This way you have a more abstract representation of a whole bunch of computers with similar characteristics and hardware components thus making coding generally easier.
CHIP-8 Specifications
As a method to provide an easier platform to develop in particular games during the old days, the emulator was made to have the following characteristics:
- 4 kB of working memory
- 64x32 pixelmonochrome display
- 16 bit program counter pc
- 16 bit index register I
- 16 bit stack pointer register
- 8 bit delay timer (60 Hz)
- 8 bit sound timer (60 Hz)
- 16 general purpose 8 bit registers
- 64x32 pixelmonochrome display
CHIP-8 programs are assumed to be loaded at memory address 0x200 by convention. This is because the interpreter itself was loaded between 0x000 to 0x1FF and thus roms are historically agreed upon to be loaded at 0x200.The standard font which displays all neccessary keys from 0x0 to 0xF will be loaded into memory at address 0x50.
Implementation
We chose the programing language C to implement this emulator as its the most fun language and in my opinion the most apropriate for the job! We will not however deal with graphics from total scratch and thus use the Simple DirectMedia Layer 2.0 graphics library SDL2.
The most challenging part of this project is getting used to and working with the larger sophisticated library as it provides many APIs and functions one needs to find first. For our emulator to run properly it would make sense to have some kind of window open and display anything in it.
SDL2 Notes
- SDL_Window * window represents an OS window with a title bar which SDL2 allocates and then returns a pointer to
- SDL_Renderer * renderer the thing that draws to the screen
- SDL_Texture * texture pixel data stored in the GPU
- I DONT BELIEVE IN BIRDS AAAAAAAAAAA