It is currently Tue Jun 27, 2017 7:02 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sat Apr 02, 2016 4:42 pm 
Offline

Joined: Sat Apr 02, 2016 11:06 am
Posts: 6
Location: Germany
Hello,

I've just started writing my own gb emulator. After finishing implementing all opcodes, I wanted to see if it's actually working by running Blargg's cpu_instr rom. As I have no working lcd emulation atm I'm printing the output by reading from the SB port. Now running the rom I got some strange output, I can't get to fix.

Code:
cpu_instrs

C8


Does anybody know, what the C8 stand for. Is it a wrong opcode? Or is it reading some wrong value, because of wrong PC?

Any help would be kindly appreciated!

PS: You can check out the code at: https://github.com/TheCodez/RetroGB


Top
 Profile  
 
PostPosted: Sun Apr 03, 2016 1:33 pm 
Offline

Joined: Fri Oct 16, 2015 6:18 am
Posts: 32
Maybe that means opcode C8 (= RET Z) is not correct?
Try running the individual test ROMs (e.g. 01-special.gb), which might give better error messages.


Top
 Profile  
 
PostPosted: Sun Apr 03, 2016 2:28 pm 
Offline

Joined: Sat Apr 02, 2016 11:06 am
Posts: 6
Location: Germany
Thanks for the suggestion, I double checked the RET Z opcode and it seems correct. Also I tried running the individual tests and they give me no output at all.

Code:
/* RET Z */
void Processor::RET_Z() // 0xC8
{
   if (IsFlagSet(FLAG_ZERO))
   {
      condition = true;
      StackPop(PC);
   }
}


Code:
void Processor::StackPop(uint16& reg)
{
    reg = memory->ReadWord(SP);
    SP += 2;
}


any other ideas?


Top
 Profile  
 
PostPosted: Sun Apr 03, 2016 2:37 pm 
Offline

Joined: Sat Aug 28, 2010 9:01 am
Posts: 162
Could you please provide a compiled binary for Windows, for testing?


Top
 Profile  
 
PostPosted: Sun Apr 03, 2016 3:09 pm 
Offline

Joined: Sat Apr 02, 2016 11:06 am
Posts: 6
Location: Germany
I'll do, I just add passing the rom name from the commandline, so you can test.

[EDIT] Don't have time anymore today. Could you build it from my Github repository and change the rom name inside main.cpp


Top
 Profile  
 
PostPosted: Wed Apr 06, 2016 2:13 pm 
Offline

Joined: Sat Apr 02, 2016 11:06 am
Posts: 6
Location: Germany
Found the bug in my generated code, the CP n opcode.

Code:
/* CP n */
void Processor::CP_n() // 0xFE
{
   SetFlag(FLAG_SUB);
   if (A < memory->ReadByte(PC++)) EnableFlag(FLAG_CARRY);
   if (A == memory->ReadByte(PC++)) EnableFlag(FLAG_ZERO);
   if (((A - memory->ReadByte(PC++)) & 0xF) > (A & 0xF)) EnableFlag(FLAG_HALFCARRY);
}


I was incrementing PC on every check :oops:. Atleast it's running now, but it's running to many tests, and none passes.


Top
 Profile  
 
PostPosted: Mon Apr 11, 2016 10:51 am 
Offline

Joined: Sat Apr 02, 2016 11:06 am
Posts: 6
Location: Germany
If all tests fail to execute successful, altough they are most likely correct, that means some flags are wrong?

Running test 06-ld r,r outputs this:
Code:
06-ld r,r

40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A
 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 7
5 77 78 79 7A 7B 7C 7D 7E 7F
Failed


Those listed are all ld opcodes, and most of them if not all should be correct. Any ideas?


Top
 Profile  
 
PostPosted: Tue Apr 12, 2016 4:58 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 21
The LD r,r' instructions do not set any flags.

I can only assume that these are being reported as failures due to a problem with some of the other instructions that the test code is using to verify the result.


Top
 Profile  
 
PostPosted: Tue Apr 12, 2016 1:08 pm 
Offline

Joined: Sat Apr 02, 2016 11:06 am
Posts: 6
Location: Germany
That's what i meant, too. Some flags wrong in other opcodes, which are causing wrong program flow.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group