zenogais said:
Here's my scrolling code, it doesn't deal with allocating memory on the heap every call, so it is probably slightly more efficient than your method Doomulation. Although I'm still getting an error with ANT, where after the ground is scrolled completely to the left, the ant is created on the ground so the game shuts down.
EDIT: Fixed the ANT problem.
Code:
void ChipVideo::scrollHorizontal(bool bScrollRight)
{
//===================================================
// Calculate The Scrolling Amount
//===================================================
unsigned short sScrollAmount = m_fSChipModeOn ? 4 : 2;
//===================================================
// Using Scrolling Amount, Scroll Screen Right
//===================================================
if(bScrollRight == true)
{
for(unsigned int y = 0; y < m_usMaxY; y++)
{
for(unsigned int x = 0; x < m_usMaxX; x++)
{
if(m_pVideoMemory[(x + (y*m_usMaxX))] && x < sScrollAmount)
{
m_pVideoMemory[ ((x + (y*m_usMaxX)) + sScrollAmount) ] = 1;
} else {
m_pVideoMemory[(x + (y*m_usMaxX))] = 0;
}
}
}
}
//===================================================
// Using Scrolling Amount, Scroll Screen Left
//===================================================
if(bScrollRight == false)
{
for(unsigned int y = 0; y < m_usMaxY; y++)
{
for(unsigned int x = 0; x < m_usMaxX; x++)
{
if(m_pVideoMemory[(x + (y*m_usMaxX))] && x >= sScrollAmount)
{
m_pVideoMemory[ ((x + (y*m_usMaxX)) - sScrollAmount) ] = 1;
} else {
m_pVideoMemory[(x + (y*m_usMaxX))] = 0;
}
}
}
}
}
Also, finally completed the emulator, should work on almost every game (I haven't tried them all

) I've attached the binary, but the source code and everything else is
here
It's certainly true that my method was bad concidering the amount of heap allocation. However, I saw no big means to optimize it since the real amount of cpu power was spent elsewhere.
The time has come! Chuit has reached its competion! Almost every game is emulated perfecly. Thus, I'm releasing the latest binary AND the source. I'm now putting down this project. Finished and discontinued.
It has been fun writing this emulator, and I hope it will be fun with the gb emulator I'm working on with some others. I'm releasing the source as-is, without any license. Do whatever you want with it. Take code to your project, make changes to it and compile a new version... it's all up to you. But remember it's lame to steal someone's source and claiming it your own.
To all those who are trying to write their own chip8 emulator out there... I can only say, good luck! And may the source of my emulator help you if you get stuck on something!
Lastly, thanks goes to refraction for all his hard work on fixing the opcodes. Without him, Chuit would still have some way to go
All other chip8 emu writers out there... good luck on your emulators!
Remember: the source includes the source files and the libs; not the external libraries. Nor, will the source of those be provided. This should be all you need to compile and run the emulator.
Have phun!
EDIT: I just recently figured out how to use colors in labels :O So I added the feature I wanted to have--to be able to change the pixel color! I also found a bug. So I'm re-uploading the source and binary.
Of course, I will still fix bugs if found, as I won't delete my source.