return status;
}
+std::string GameBoy::get_port_name(int port) const
+{
+ std::string port_name;
+
+ switch (port)
+ {
+ case 0x40: port_name = "LCDC"; break;
+ case 0x41: port_name = "STAT"; break;
+ case 0x42: port_name = "SCY "; break;
+ case 0x43: port_name = "SCX "; break;
+ case 0x44: port_name = "LY "; break;
+ case 0x45: port_name = "LYC "; break;
+ case 0x4A: port_name = "WY "; break;
+ case 0x4B: port_name = "WX "; break;
+ case 0x47: port_name = "BGP "; break;
+ case 0x48: port_name = "OBP0"; break;
+ case 0x49: port_name = "OBP1"; break;
+ case 0x46: port_name = "DMA "; break;
+ }
+ return port_name;
+}
-std::string GameBoy::status_string()
+std::string GameBoy::status_string() const
{
std::string disassembled_instruction;
int length;
}
#include "disasm.h"
-void GameBoy::disassemble_opcode(u16 addr, std::string &instruction, int &length)
+void GameBoy::disassemble_opcode(u16 addr, std::string &instruction, int &length) const
{
int opcode;
u16 PC = addr;
// LDH (n), A
case 0xE0: {
- result << "LD (IO_BASE + 0x" <<
- std::setw(2) << int(memory.read(PC++)) << "), A";
+ int port = int(memory.read(PC++));
+
+ result << "LD (0xFF" <<
+ std::setw(2) << port << "), A" << "\t[" << get_port_name(port) << "]";
break;
}
// LDH A, (n)
- case 0xF0:
- result << "LD A, (IO_BASE + 0x" <<
- std::setw(2) << int(memory.read(PC++)) << ")";
+ case 0xF0: {
+ int port = int(memory.read(PC++));
+ result << "LD A, (0xFF" <<
+ std::setw(2) << port << ")" << "\t[" << get_port_name(port) << "]";
break;
+ }
dis_reg16_inm(0x01, "LD", BC)
dis_reg16_inm(0x11, "LD", DE)
void set_flag (Flag f) { regs.flags |= f; }
void reset_flag(Flag f) { regs.flags &= (~f); }
- bool check_flag(Flag f) { return ((regs.flags & f) != 0); }
+ bool check_flag(Flag f) const { return ((regs.flags & f) != 0); }
enum run_status
{
run_status run();
// debug methods
- void disassemble_opcode(u16 addr, std::string &instruction, int &length);
- std::string status_string();
+ void disassemble_opcode(u16 addr, std::string &instruction, int &length) const;
+ std::string status_string() const;
+ std::string get_port_name(int port) const;
};
{
case 0:
start = gb.regs.PC;
- end = start + 256;
+ end = start + 30;
break;
case 1:
start = atoi(arguments[0].c_str());
- end = start + 256;
+ end = start + 30;
break;
case 2:
default:
int len;
gb.disassemble_opcode(pos, ins, len);
cout << "0x" << std::hex << std::setw(4) << std::setfill('0') <<
- pos << "\t" << ins << endl;
+ pos << "\t";
+ for (int i=0; i<len; i++)
+ cout << std::setw(2) << int(gb.memory.read(pos+i)) << " ";
+
+ if (len < 3) cout << "\t";
+ cout << "\t" << ins << endl;
pos += len;
}