4 Emulate Peripherals User Input, Sound Video - cpe7/chip8 GitHub Wiki
Part 4: 4. Emulate the peripheral devices like user input, sound / video output.
[REQ #3] The emulator shall be able to accept user input via keyboard and produce a graphical display.
11/17/14: At this point, I am referencing several online sources to aid in the completion of the emulator.
Phase 1: Sound and Delay Timers - I adapted the Cocoa code for the function handleTimers from Emulator 101 to monitor and decrement the timer registers at a rate of ~60Hz.
Phase 2: Display & Keyboard - I adapted and utilized the Display and Keyboard code from Laurence Muller and incorporated the OpenGL Utility ToolKit (GLUT) for rendering from this helpful link http://visualambition.wordpress.com/2010/08/12/glut-and-visual-studio-2010/. Now I need to debug the display and keyboard interface, and tie in the processing of the last few OpCodes with the display and keyboard functionality. The initial incorporation of GLUT has caused a mix of C and C++ implementation. https://www.opengl.org/resources/libraries/glut/spec3/spec3.html
Phase 3: Debugging and Refinement
11/18/14
- Fix display initialization size
- Initialize drawFlag to true so that display is initially cleared
- Update OpCodes for CLS, SKP, SKNP
11/19/14
- minor clean up.
- Add final OpCodes' support for DRW, LD Vx, K, and LD F, Vx (from Laurence Muller)
- Debugging display... it's starting to work! .. may need to throttle timing, loop seem to be running too quickly.
11/20/14-11/21/14
- Debugging display and OpCodes. Updated some instructions for correctness from comparison with Laurence Muller.
- Debugging Timer Register emulation.
11/23/14
- Inserted a for loop (with a large count) at the end of the display() function, to slow down the program. Several programs still crash with the emulator (WIPEOFF, UFO, TETRIS). In running INVADERS, I found that the Y and W characters aren't getting displayed properly, so some debugging to do there, which might help in some of the other issues - indicative of some instructions not being parsed/handled properly.
11/24/14
- Found a glitch in translating some of Laurence Muller's OpCode code, where I made a separate register (variable) for VF, and Laurence had used the one in his array of registers. Therefore where I had regVx[0xF], I replaced with regVF.
- Found another good source for comparing and debugging - Lyndon Armitage ... his 'small bug' looks a lot like some of my issues, so I'm going to check all my parens. and order of operations.
- Downloaded emulator from http://chip8.com/?page=82 FISH N CHIPS, to test the ROMs I was using to make sure there wasn't any issue in the binaries - they ran with no issues.
- Added output file to debug instructions.
11/26/14
- Most ROMs run without crashing now. And in INVADERS, the Y and W characters scrolling during the program beginning are resolved. The fix ended up being quite simple - changing variable types from short to unsigned short, and char to unsigned char (and in some cases changed from short to char).
12/3/14
- I cleaned up the code a bit more, ensuring to use unsigned type specifier, and adding parens and casting when changing between types. Using this Chip8 Reference Manual by Peter Miller, I verified the basic operation of the ROM set that I downloaded HERE.
The following ROMs run and seem to play the game as intended:
- BRIX (no score displayed?)
- KALEID
- MISSILE
- PONG (no score displayed?)
- UFO (no score displayed?)
The following ROMS run but there are some display issues:
- BLINKY (maze grid does not show)
- CONNECT4 (moving left and right position is not precise)
- INVADERS (ship doesn't display and 'ghosts' when moved left and right)
- MAZE (does not regenerate with any key press)
- PUZZLE (none of the numbers display only boxes)
- TICTAC (only squares in diagonals fill with X or O)
- WIPEOFF (no board to 'wipe off' only pong ball and paddle)
The following ROMS run and crash:
- TETRIS
- VBRIX
The following ROMs don't run at all (nothing displays):
- 15PUZZLE
- GUESS
- HIDDEN
- MERLIN
- TANK
- VERS