generated from sigonasr2/CPlusPlusProjectTemplate
Implemented more opcodes
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
03a722529a
commit
9e47287989
Binary file not shown.
38
main.cpp
38
main.cpp
@ -1,6 +1,7 @@
|
|||||||
#include "pixelGameEngine.h"
|
#include "pixelGameEngine.h"
|
||||||
#include "Polygon.h"
|
#include "Polygon.h"
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
using namespace olc;
|
using namespace olc;
|
||||||
|
|
||||||
@ -52,11 +53,24 @@ public:
|
|||||||
uint16_t index; //One 16-bit index register called “I” which is used to point at locations in memory
|
uint16_t index; //One 16-bit index register called “I” which is used to point at locations in memory
|
||||||
std::array<uint8_t,16>reg;
|
std::array<uint8_t,16>reg;
|
||||||
|
|
||||||
|
std::string Display8(int number){
|
||||||
|
std::bitset<8>numb(number);
|
||||||
|
return numb.to_string();
|
||||||
|
}
|
||||||
|
std::string Display16(int number){
|
||||||
|
std::bitset<16>numb(number);
|
||||||
|
return numb.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OnUserCreate() override
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
//memory[0x200]=0x00;
|
memory[0x200]=0x60;
|
||||||
//memory[0x201]=0xE0;
|
memory[0x201]=0x0A;
|
||||||
|
memory[0x202]=0x70;
|
||||||
|
memory[0x203]=0x04;
|
||||||
|
memory[0x204]=0x12;
|
||||||
|
memory[0x205]=0x00;
|
||||||
//0x200 program start
|
//0x200 program start
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -81,24 +95,24 @@ public:
|
|||||||
|
|
||||||
//DECODE
|
//DECODE
|
||||||
uint8_t nibble1 = opcode>>12;
|
uint8_t nibble1 = opcode>>12;
|
||||||
uint8_t X = reg[opcode>>8&0xF];
|
uint8_t X = opcode>>8&0xF;
|
||||||
uint8_t Y = reg[opcode>>4&0xF];
|
uint8_t Y = opcode>>4&0xF;
|
||||||
uint8_t N = opcode&0xF;
|
uint8_t N = opcode&0xF;
|
||||||
uint8_t NN = opcode&0x00FF;
|
uint8_t NN = opcode&0x00FF;
|
||||||
uint16_t NNN = opcode&0x0FFF;
|
uint16_t NNN = opcode&0x0FFF;
|
||||||
|
std::cout<<"Opcode 0x"<<std::hex<<opcode<<std::dec<<": "<<Display8(nibble1)<<", "<<Display8(X)<<"/"<<Display8(Y)<<"/"<<Display8(N)<<"/"<<Display8(NN)<<"/"<<Display16(NNN)<<std::endl;
|
||||||
switch(nibble1){
|
switch(nibble1){
|
||||||
case 0x0:{
|
case 0x0:{
|
||||||
switch (NNN){
|
switch (NNN){
|
||||||
case 0x0E0:{ //Clear screen.
|
case 0x0E0:{ //Clear screen.
|
||||||
std::cout<<"Screen has been cleared."<<std::endl;
|
|
||||||
for (int i=0;i<display.size();i++){
|
for (int i=0;i<display.size();i++){
|
||||||
display[i]=0;
|
display[i]=0;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case 0x1:{
|
case 0x1:{ //Jump.
|
||||||
|
pc=NNN;
|
||||||
}break;
|
}break;
|
||||||
case 0x2:{
|
case 0x2:{
|
||||||
|
|
||||||
@ -112,11 +126,13 @@ public:
|
|||||||
case 0x5:{
|
case 0x5:{
|
||||||
|
|
||||||
}break;
|
}break;
|
||||||
case 0x6:{
|
case 0x6:{ //Set the register X to NN.
|
||||||
|
reg[X]=NN;
|
||||||
|
std::cout<<(int)reg[X]<<std::endl;
|
||||||
}break;
|
}break;
|
||||||
case 0x7:{
|
case 0x7:{ //Add w/no carry
|
||||||
|
reg[X]+=NN;
|
||||||
|
std::cout<<(int)reg[X]<<std::endl;
|
||||||
}break;
|
}break;
|
||||||
case 0x8:{
|
case 0x8:{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user