Alex 6 years ago
parent
commit
7df88ffdf2
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      main.c

+ 9
- 9
main.c View File

346
 				reg = (opcode & 0x0F00) >> 8;
346
 				reg = (opcode & 0x0F00) >> 8;
347
 				switch ((byte) opcode)
347
 				switch ((byte) opcode)
348
 				{
348
 				{
349
-					case 0x07:
349
+					case 0x07: // set reg to delay time
350
 						if (DEBUG) printf("Copying delay timer to reg %i (%hx)", reg, state.registers[reg]);
350
 						if (DEBUG) printf("Copying delay timer to reg %i (%hx)", reg, state.registers[reg]);
351
 						state.registers[reg] = delay;
351
 						state.registers[reg] = delay;
352
 						break;
352
 						break;
353
 
353
 
354
-					case 0x0A:
354
+					case 0x0A: // wait for input and store it in reg
355
 						wait = 1;
355
 						wait = 1;
356
 						store = reg;
356
 						store = reg;
357
 						break;
357
 						break;
358
 
358
 
359
-					case 0x15:
359
+					case 0x15: // set delay timer to value in reg
360
 						delay = state.registers[reg];
360
 						delay = state.registers[reg];
361
 						break;
361
 						break;
362
 
362
 
363
-					case 0x18:
363
+					case 0x18: // set sound timer to value in reg
364
 						sound = state.registers[reg];
364
 						sound = state.registers[reg];
365
 						break;
365
 						break;
366
 
366
 
367
-					case 0x1E:
367
+					case 0x1E: // Add value stored in VX to I
368
 						state.address_I += state.registers[reg];
368
 						state.address_I += state.registers[reg];
369
 						if (DEBUG) printf("Adding reg %i (%hx) to I (%x)", reg, state.registers[reg], state.address_I);
369
 						if (DEBUG) printf("Adding reg %i (%hx) to I (%x)", reg, state.registers[reg], state.address_I);
370
 						break;
370
 						break;
371
 
371
 
372
-					case 0x29:
372
+					case 0x29: // set I to address of font character
373
 						state.address_I = state.registers[reg] * 5;
373
 						state.address_I = state.registers[reg] * 5;
374
 						break;
374
 						break;
375
 
375
 
376
-					case 0x33:;
376
+					case 0x33:; // encode value in reg as a BCD at I, I+1, I+2
377
 						int value = state.registers[reg];
377
 						int value = state.registers[reg];
378
 						state.memory[state.address_I] = value / 100;
378
 						state.memory[state.address_I] = value / 100;
379
 						state.memory[state.address_I + 1] = (value / 10) % 10;
379
 						state.memory[state.address_I + 1] = (value / 10) % 10;
380
 						state.memory[state.address_I + 2] = value % 10;
380
 						state.memory[state.address_I + 2] = value % 10;
381
 						break;
381
 						break;
382
 
382
 
383
-					case 0x55:
383
+					case 0x55: // dump registers V0 -> VX at I
384
 						for (int i = 0; i <= reg; ++i)
384
 						for (int i = 0; i <= reg; ++i)
385
 							state.memory[state.address_I + i] = state.registers[i];
385
 							state.memory[state.address_I + i] = state.registers[i];
386
 						break;
386
 						break;
387
 
387
 
388
-					case 0x65:
388
+					case 0x65: // retrieve registers V0 -> VX from I
389
 						for (int i = 0; i <= reg; ++i)
389
 						for (int i = 0; i <= reg; ++i)
390
 							state.registers[i] = state.memory[state.address_I + i];
390
 							state.registers[i] = state.memory[state.address_I + i];
391
 						break;
391
 						break;