2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-10-19 21:43:09 +00:00
|
|
|
#include <cstdint>
|
2017-06-04 20:38:34 +00:00
|
|
|
#include <string>
|
2017-10-19 21:43:09 +00:00
|
|
|
#include <sstream>
|
2017-06-04 20:38:34 +00:00
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
2018-10-20 19:52:41 +00:00
|
|
|
#include "GameBoyBus.h"
|
|
|
|
|
2017-06-09 10:42:32 +00:00
|
|
|
namespace EightBit {
|
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
namespace GameBoy {
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
class LR35902;
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
class Disassembler {
|
|
|
|
public:
|
2018-10-20 19:52:41 +00:00
|
|
|
Disassembler(Bus& bus) noexcept;
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
static std::string state(LR35902& cpu);
|
|
|
|
std::string disassemble(LR35902& cpu);
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2020-11-07 09:41:12 +00:00
|
|
|
static std::string flag(uint8_t value, int flag, std::string represents);
|
2017-09-07 00:15:28 +00:00
|
|
|
static std::string flags(uint8_t value);
|
|
|
|
static std::string hex(uint8_t value);
|
|
|
|
static std::string hex(uint16_t value);
|
|
|
|
static std::string binary(uint8_t value);
|
|
|
|
static std::string decimal(uint8_t value);
|
|
|
|
static std::string io(uint8_t value);
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
static std::string invalid(uint8_t value);
|
|
|
|
|
|
|
|
private:
|
2018-12-01 15:24:29 +00:00
|
|
|
enum class IoRegister {
|
2017-09-07 00:15:28 +00:00
|
|
|
Abbreviated, // FF00 + dd
|
|
|
|
Absolute, // FFdd
|
|
|
|
Register, // C
|
|
|
|
Unused, // Unused!
|
|
|
|
};
|
2017-08-31 16:18:38 +00:00
|
|
|
|
2018-10-20 19:52:41 +00:00
|
|
|
Bus& m_bus;
|
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
mutable boost::format m_formatter;
|
2018-08-11 20:19:19 +00:00
|
|
|
bool m_prefixCB = false;
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
void disassemble(std::ostringstream& output, LR35902& cpu, uint16_t pc);
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
void disassembleCB(
|
|
|
|
std::ostringstream& output,
|
|
|
|
LR35902& cpu,
|
|
|
|
uint16_t pc,
|
|
|
|
std::string& specification,
|
|
|
|
int& dumpCount,
|
|
|
|
int x, int y, int z,
|
|
|
|
int p, int q);
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
void disassembleOther(
|
|
|
|
std::ostringstream& output,
|
|
|
|
LR35902& cpu,
|
|
|
|
uint16_t pc,
|
|
|
|
std::string& specification,
|
|
|
|
int& dumpCount,
|
|
|
|
IoRegister& ioRegister,
|
|
|
|
int x, int y, int z,
|
|
|
|
int p, int q);
|
2017-06-09 10:42:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
std::string RP(int rp) const;
|
|
|
|
std::string RP2(int rp) const;
|
|
|
|
std::string R(int r) const;
|
|
|
|
static std::string cc(int flag);
|
|
|
|
static std::string alu(int which);
|
2018-10-20 19:52:41 +00:00
|
|
|
|
2020-11-07 09:41:12 +00:00
|
|
|
Bus& BUS() noexcept { return m_bus; }
|
2017-09-07 00:15:28 +00:00
|
|
|
};
|
|
|
|
}
|
2017-06-09 10:42:32 +00:00
|
|
|
}
|