diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 0a06ac4..773d6f8 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/chip8-test-suite.ch8 b/chip8-test-suite.ch8 new file mode 100644 index 0000000..57065dc Binary files /dev/null and b/chip8-test-suite.ch8 differ diff --git a/main.cpp b/main.cpp index 4877807..d39a105 100644 --- a/main.cpp +++ b/main.cpp @@ -9,7 +9,7 @@ using namespace olc; -bool USE_DEBUG_DISPLAY=true; +bool USE_DEBUG_DISPLAY=false; int EMULATOR_SCREEN_WIDTH = 64; int EMULATOR_SCREEN_HEIGHT = 32; int EMULATOR_PIXEL_SIZE=5; @@ -66,6 +66,7 @@ public: bool USE_ORIGINAL_CHIP8_SET=true; //True means use the original CHIP-8 spec (COSMAC VIP emulation). Set to false to use CHIP-48 spec. bool PAUSED=true; long instructionCount=0; + uint16_t watchMemoryAddress=0; std::string Display8(int number){ std::bitset<8>numb(number); @@ -92,7 +93,7 @@ public: for (int i=0;i255){ - reg[0xF]=1; + carryFlag=1; } reg[X]+=reg[Y]; + reg[0xF]=carryFlag; }break; case 0x5:{// sets VX to the result of VX - VY. - reg[0xF]=0; + bool carryFlag=0; if (reg[X]>reg[Y]){ - reg[0xF]=1; + //reg[0xF]=1; + //carryFlag=1; } reg[X]-=reg[Y]; + reg[0xF]=carryFlag; }break; case 0x6:{//Shift Right if (USE_ORIGINAL_CHIP8_SET){ @@ -485,15 +520,19 @@ public: */ reg[X]=reg[Y]; } - reg[0xF]=reg[X]&0x1; + bool carryFlag=reg[X]&0x1; reg[X]>>=1; + reg[0xF]=carryFlag; }break; case 0x7:{//sets VX to the result of VY - VX. It's a reverse subtraction. - reg[0xF]=0; + //reg[0xF]=0; + bool carryFlag=false; if (reg[Y]>reg[X]){ - reg[0xF]=1; + //reg[0xF]=1; + carryFlag=true; } reg[X]=reg[Y]-reg[X]; + reg[0xF]=carryFlag; }break; case 0xE:{//Shift Left //std::cout<<"Y is: "<<(int)Y<>7; + bool carryFlag=(reg[X]&0x80)>>7; reg[X]<<=1; + reg[0xF]=carryFlag; }break; } }break; @@ -571,11 +611,14 @@ public: sound_timer=reg[X]; }break; case 0x1E:{//The index register I will get the value in VX added to it. - reg[0xF]=0; + //reg[0xF]=0; + bool carryFlag=false; if (index+reg[X]>=0x1000){ - reg[0xF]=1; + //reg[0xF]=1; + carryFlag=true; } index+=reg[X]; + reg[0xF]=carryFlag; }break; case 0x0A:{//This instruction “blocks”; it stops executing instructions and waits for key input for (int i=0;i