File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -42,13 +42,41 @@ void chip8::emulateCycle(){
4242
4343 // switch decodes the opcode and then executes it in case body
4444 switch (opcode & 0xF000 ){
45- case 0xA000 :
45+ case 0xA000 : // ANNN: Sets IR to the Adress NNN
46+ // execute
4647 IR = opcode & 0x0FFF ;
4748 PC += 2 ;
4849 break ;
50+ case 0xB000 : // BNNN: Jumps to adress NNN plus V0;
51+ // execute
52+ PC = V[0 ] ^ (opcode & 0xFFF );
53+ break ;
54+ // in the event we cant rely on the first four bits to see what the opcode means
55+ case 0x0000 :
56+ switch (opcode & 0x000F ){
57+ case 0x0000 : // 0x00E0: Clears the Screen
58+ // execute
59+ PC += 2 ;
60+ break ;
61+ case 0x000E : // 0x00EE: Returns from sub-routine
62+ // execute
63+ PC += 2 ;
64+ break ;
65+ default :
66+ std::cout << " Unkown opcode " << std::hex << opcode;
67+ }
4968 default :
5069 std::cout << " Unkown opcode: " << std::hex << opcode;
5170 }
71+
72+ if (delay_timer > 0 )
73+ --delay_timer;
74+ if (sound_timer > 0 ){
75+ if (sound_timer == 1 ){
76+ // sound is played
77+ }
78+ --sound_timer;
79+ }
5280}
5381
5482void chip8::setKeys (){
You can’t perform that action at this time.
0 commit comments