5.4 KiB
Todos
-
How to capture arguments passed to a C program
```c // argc is the number of args passed // argc is always 1 or more // argc always has name/path of program as first arg int main(int argc, char *argv[]) { // do stuff with the args } ``` -
How to print argument value
``` printf("%s", argv[1]); ``` -
Read a file
```c // open file in read mode. returns NULL if doesn't exist FILE *file_ptr = fread(file_path, "r"); // seeking to end of file. // useful telling number of bytes fseek(file_ptr, 0, SEEK_END); // get number of bytes int num_of_bytes = ftell(file_ptr); // seek to begin of file fseek(file_ptr, 0, SEEK_SET); ``` -
Store contents of file in memory
-
Print file contents
-
Print instructions
-
Make sure program occupies correct space in chip memory
-
Parse individual instructions from binary CHIP-8 file
-
Print all instructions from CHIP-8 file
-
Write all CHIP-8 IBM logo opcodes to CSV file
-
Implement opcodes present in the IMB logo CHIP-8 file
x Opcode Type Description x 00E000E0 Clear display x 1nnn1nnn Jump to address x 3xkk3xkk Skip next if Vx == kk x 6xkk6xkk Load register with immediate x 7xkk7xkk Add immediate to Vx x ANNNANNN Set index register x BnnnBnnn Jump to V0 + addr x DxynDxyn Draw sprite -
Refactor main
-
Migrate drawing to raylib window
-
Handle keyboard input
CHIP-8 Pad QWERTY 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 │ └───┴───┴───┴───┘ └───┴───┴───┴───┘
-
Implement remaining instructions
x Opcode Type Description x 00EE00EE Return from subroutine x 2nnn2nnn Call subroutine at nnn x 4xkk4xkk Skip next if Vx != kk x 5xy05xy0 Skip next if Vx == Vy x 8xy08xy0 Stores Vy in Vx x 8xy18xy1 Set Vx = Vx OR Vy x 8xy28xy2 Set Vx = Vx AND Vy x 8xy38xy3 Set Vx = Vx XOR Vy x 8xy48xy4 Set Vx = Vx + Vy, set VF = carry x 8xy58xy5 Set Vx = Vx - Vy, set VF = NOT borrow x 8xy68xy6 Set Vx = Vx SHR 1 x 8xy78xy7 Set Vx = Vy - Vx, set VF = NOT borrow x 8xyE8xyE Set Vx = Vx SHL 1 x 9xy09xy0 Skip next if Vx != Vy x CxkkCxkk Set Vx = random byte AND kk x Ex9EEx9E Skip next if key Vx is pressed x ExA1ExA1 Skip next if key Vx is not pressed x Fx07Fx07 Set Vx = delay timer value x Fx0AFx0A Wait for key press, store key in Vx x Fx15Fx15 Set delay timer = Vx x Fx18Fx18 Set sound timer = Vx x Fx1EFx1E Set I = I + Vx x Fx29Fx29 Set I = location of sprite for digit Vx x Fx33Fx33 Store BCD representation of Vx in memory x Fx55Fx55 Store registers V0 through Vx in memory starting at location I x Fx65Fx65 Read registers V0 through Vx from memory starting at location I - 0nnn0nnn Jump to machine code routine (ignored)