generated from sigonasr2/CPlusPlusProjectTemplate
Included original chipset functionality
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
06bc97ade9
commit
229509bc3b
Binary file not shown.
30
main.cpp
30
main.cpp
@ -57,6 +57,7 @@ public:
|
|||||||
std::mt19937 gen; //Standard mersenne_twister_engine seeded with rd()
|
std::mt19937 gen; //Standard mersenne_twister_engine seeded with rd()
|
||||||
std::uniform_int_distribution<> distrib;
|
std::uniform_int_distribution<> distrib;
|
||||||
std::array<Key,16>keymap{X,K1,K2,K3,Q,W,E,A,S,D,Z,C,K4,R,F,V};
|
std::array<Key,16>keymap{X,K1,K2,K3,Q,W,E,A,S,D,Z,C,K4,R,F,V};
|
||||||
|
bool USE_ORIGINAL_CHIP8_SET=true;
|
||||||
|
|
||||||
std::string Display8(int number){
|
std::string Display8(int number){
|
||||||
std::bitset<8>numb(number);
|
std::bitset<8>numb(number);
|
||||||
@ -207,7 +208,14 @@ public:
|
|||||||
reg[X]-=reg[Y];
|
reg[X]-=reg[Y];
|
||||||
}break;
|
}break;
|
||||||
case 0x6:{//Shift Right
|
case 0x6:{//Shift Right
|
||||||
//reg[X]=reg[Y];
|
if (USE_ORIGINAL_CHIP8_SET){
|
||||||
|
/*
|
||||||
|
In the CHIP-8 interpreter for the original COSMAC VIP, this instruction did the following: It put the value of VY into VX, and then shifted the value in VX 1 bit to the right (8XY6) or left (8XYE). VY was not affected, but the flag register VF would be set to the bit that was shifted out.
|
||||||
|
|
||||||
|
However, starting with CHIP-48 and SUPER-CHIP in the early 1990s, these instructions were changed so that they shifted VX in place, and ignored the Y completely.
|
||||||
|
*/
|
||||||
|
reg[X]=reg[Y];
|
||||||
|
}
|
||||||
reg[0xF]=reg[X]&0x1;
|
reg[0xF]=reg[X]&0x1;
|
||||||
reg[X]>>=1;
|
reg[X]>>=1;
|
||||||
}break;
|
}break;
|
||||||
@ -220,12 +228,16 @@ public:
|
|||||||
}break;
|
}break;
|
||||||
case 0xE:{//Shift Left
|
case 0xE:{//Shift Left
|
||||||
//std::cout<<"Y is: "<<(int)Y<<std::endl;
|
//std::cout<<"Y is: "<<(int)Y<<std::endl;
|
||||||
//reg[X]=reg[Y];
|
if (USE_ORIGINAL_CHIP8_SET){
|
||||||
std::cout<<"Before left shift: "<<(int)reg[X]<<std::endl;
|
/*
|
||||||
|
In the CHIP-8 interpreter for the original COSMAC VIP, this instruction did the following: It put the value of VY into VX, and then shifted the value in VX 1 bit to the right (8XY6) or left (8XYE). VY was not affected, but the flag register VF would be set to the bit that was shifted out.
|
||||||
|
|
||||||
|
However, starting with CHIP-48 and SUPER-CHIP in the early 1990s, these instructions were changed so that they shifted VX in place, and ignored the Y completely.
|
||||||
|
*/
|
||||||
|
reg[X]=reg[Y];
|
||||||
|
}
|
||||||
reg[0xF]=(reg[X]&0x80)>>7;
|
reg[0xF]=(reg[X]&0x80)>>7;
|
||||||
std::cout<<"Register F: "<<(int)reg[0xF]<<std::endl;
|
|
||||||
reg[X]<<=1;
|
reg[X]<<=1;
|
||||||
std::cout<<"After Left shift: "<<(int)reg[X]<<std::endl;
|
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
@ -321,11 +333,19 @@ public:
|
|||||||
for (int i=0;i<=X;i++){
|
for (int i=0;i<=X;i++){
|
||||||
memory[index+i]=reg[i];
|
memory[index+i]=reg[i];
|
||||||
}
|
}
|
||||||
|
if (USE_ORIGINAL_CHIP8_SET){
|
||||||
|
/*The original CHIP-8 interpreter for the COSMAC VIP actually incremented the I register while it worked. Each time it stored or loaded one register, it incremented I. After the instruction was finished, I would be set to the new value I + X + 1.*/
|
||||||
|
index+=X+1;
|
||||||
|
}
|
||||||
}break;
|
}break;
|
||||||
case 0x65:{//Retrieves registers from V0 to VX in memory pointed by index.
|
case 0x65:{//Retrieves registers from V0 to VX in memory pointed by index.
|
||||||
for (int i=0;i<=X;i++){
|
for (int i=0;i<=X;i++){
|
||||||
reg[i]=memory[index+i];
|
reg[i]=memory[index+i];
|
||||||
}
|
}
|
||||||
|
if (USE_ORIGINAL_CHIP8_SET){
|
||||||
|
/*The original CHIP-8 interpreter for the COSMAC VIP actually incremented the I register while it worked. Each time it stored or loaded one register, it incremented I. After the instruction was finished, I would be set to the new value I + X + 1.*/
|
||||||
|
index+=X+1;
|
||||||
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user