CHIP-8 Emulator p2: Drawing a Logo (C / SDL2)

Channel:
Subscribers:
5,840
Published on ● Video Link: https://www.youtube.com/watch?v=EW1zXX89pfM



Category:
Vlog
Duration: 1:51:12
1,538 views
37


CHIP8 machine typedef, emulating enough instructions for a company logo to display correctly, and printing debug output for instructions.

Errata:
- handle_input(), when pausing/unpausing, prints PAUSED when resuming, not when pausing. That is fixed sometime in the future.
- print_debug_info(), for 0x2NNN calling a subroutine, has the code for setting the PC, not printing debug info. That is fixed later, way later...
- init_chip8(), using %zu for rom_size and max_size gives errors on windows. I later casted these to (unsigned long long) and used %llu so it works on both linux & windows.

Git Repos:
https://git.sr.ht/~queso_fuego/chip8_emulator_c
https://github.com/queso-fuego/chip8_emulator_c

Links:
https://github.com/kripod/chip8-roms
https://github.com/cj1128/chip8-emulator/tree/master/rom (for BC_test.ch8)
https://github.com/corax89/chip8-test-rom
https://archive.org/details/bitsavers_rcacosmacCManual1978_6956559/ (COSMAC VIP instruction manual)

Join the Community Discord: https://discord.gg/yKm4T89QFn

Contact:
email: fuegoqueso@gmail.com
twitter: @Queso_Fuego
twitch (if I stream again, may be on youtube idk): https://www.twitch.tv/queso_fuego

Notes:
- Emulating instructions could be simpler/easier to read by using separate values for registers and an instruction_t type in emulate_instruction(), instead of attaching it to the chip8 struct.
That would remove most of the chip8 dereferencing line noise, but it wouldn't have the data attached to the chip8 struct allowing 1 single parm to pass all of its associated info. But that isn't really needed out side of emulating the instructions anyway.
- Another way to print debug info per instruction could be adding a string to the instruction_t type that is filled out and printed at runtime with current instruction and chip8 register data.
That might still need extra code per instruction, but shouldn't need a full duplicated switch statement in print_debug_info().

Questions about setup/software/etc.?
Check the FAQ: https://queso_fuego.srht.site/about.html

0:00 getting test roms
3:49 chip8_t typedef & init function
29:42 set paused/resumed state
34:35 instruction_t typedef and start emulating instructions
55:28 print debug output for instructions, continue emulating more things incl. DXYN to draw sprites
1:24:52 update_screen() to draw chip8 pixels
1:39:55 finish instructions to draw logo correctly
1:47:20 add pixel outlines
1:49:30 coming up & outro

Music:
Downtown Glow by Ghostrifter & Devyzed
Creative Commons — Attribution-NoDerivs 3.0 Unported — CC BY-ND 3.0
Music promoted by https://www.chosic.com/free-music/all/

#chip8 #emulator #programming







Tags:
queso fuego
programming
c programming
sdl2
sdl
chip8
emulator
chip8 emulator
ibm logo