-
ChipAte Emulation
I am writing my first wmulator and since there arent many good tutorials out there... I want to make sure Im on the right track.
My first question...
Is this the proper way of emulatiing the CPU?
Code:
void CpuEmulation()
{
OpCode = (Memory[PC] << 8) + Memory[PC + 1];
switch(OpCode&0xF000)
{
case 0x0000:
if(OpCode&0x00F0 == 0xE)
ClearScreen();
PC+=2;
break;
case 0x1000:
MemoryPosition = OpCode&0x0FFF;
PC+=2;
break;
case 0x3000:
if(V[OpCode&0x0F00] == OpCode&0x00FF) PC += 4;
else PC += 2;
break;
case 0x5000:
if(V[OpCode&0x0F00] == OpCode&0x00F0) PC += 4;
else PC += 2;
break;
case 0x6000:
V[OpCode&0x0F00] = OpCode&0x00FF;
PC+=2;
break;
case 0x7000:
V[OpCode&0x0F00] += OpCode&0x00FF;
PC+=2;
break;
case 0x8000:
if(OpCode&0x000F == 0)
V[OpCode&0x0F00] = V[OpCode&0x00F0];
PC+=2;
break;
case 0xB000:
MemoryPosition = OpCode&0x0FFF + V[0];
PC+=2;
break;
}
}
-
You mean other than the fact that you're using globals everywhere?
Quzah.
-
oh..
I take it, thats a bad thing....
Look, this is the first time ive tried to program anything other than a game. I am just trying to figure out if Im doing this the right way, or if there is a better way. I was thinking I might have to shift some more bits or something :p
I am going to attach my source code and see if any one can give me some pointers. Not to tell me how stupid I am for doing something, just to kindly give me advice. :rolleyes:
-
Working from a decnet set of examples might be a good thing to try.
http://koti.mbnet.fi/~atjs/mc6809/
-
whether you are close to writing it correctly or not its still a damn good attempt.
im sure i saw a whole lot of emulator dev tutorials somewhere...
-
Why Thank You!
I have managed to load a rom and it actually draws a few thing on the screen. I found a really good explanation of all the Instructions of the chip8, but I cant figure out how to implement the 'I' address register... :confused:
-
Out of curiosity, I looked up chip-8 and found alot of info on this forum.
gg