~sircmpwn/hdmg

fbf938c76689f855c5a951ab9eacbbc8ff1765d4 — Drew DeVault 2 years ago 150cabf
sm83: delay EI by one instruction
3 files changed, 54 insertions(+), 49 deletions(-)

M sm83/exec.ha
M sm83/instr.ha
M sm83/prefix.ha
M sm83/exec.ha => sm83/exec.ha +4 -0
@@ 3,6 3,10 @@ export fn exec(cpu: *sm83, cycles: uint) void = {
	cpu.cycles += cycles: int;

	for (cpu.cycles > 0) {
		if (cpu.int_ime == 2) {
			// EI is delayed by one instruction
			cpu.int_ime = 1;
		};
		const op = fetchd8(cpu);
		const instr = &itab[op];
		instr.exec(cpu);

M sm83/instr.ha => sm83/instr.ha +1 -1
@@ 66,7 66,7 @@ fn exec_di(cpu: *sm83) void = {
};

fn exec_ei(cpu: *sm83) void = {
	cpu.int_ime = 1;
	cpu.int_ime = 2;
};

fn exec_halt(cpu: *sm83) void = {

M sm83/prefix.ha => sm83/prefix.ha +49 -48
@@ 1,56 1,57 @@
fn exec_rlc_a(cpu: *sm83) void = abort("TODO");
fn exec_rlc_b(cpu: *sm83) void = abort("TODO");
fn exec_rlc_c(cpu: *sm83) void = abort("TODO");
fn exec_rlc_d(cpu: *sm83) void = abort("TODO");
fn exec_rlc_e(cpu: *sm83) void = abort("TODO");
fn exec_rlc_h(cpu: *sm83) void = abort("TODO");
fn exec_rlc_l(cpu: *sm83) void = abort("TODO");
fn exec_rlc_hl(cpu: *sm83) void = abort("TODO");
// TODO: Implement these rot/shift instructions
fn exec_rlc_a(cpu: *sm83) void = void;
fn exec_rlc_b(cpu: *sm83) void = void;
fn exec_rlc_c(cpu: *sm83) void = void;
fn exec_rlc_d(cpu: *sm83) void = void;
fn exec_rlc_e(cpu: *sm83) void = void;
fn exec_rlc_h(cpu: *sm83) void = void;
fn exec_rlc_l(cpu: *sm83) void = void;
fn exec_rlc_hl(cpu: *sm83) void = void;

fn exec_rrc_a(cpu: *sm83) void = abort("TODO");
fn exec_rrc_b(cpu: *sm83) void = abort("TODO");
fn exec_rrc_c(cpu: *sm83) void = abort("TODO");
fn exec_rrc_d(cpu: *sm83) void = abort("TODO");
fn exec_rrc_e(cpu: *sm83) void = abort("TODO");
fn exec_rrc_h(cpu: *sm83) void = abort("TODO");
fn exec_rrc_l(cpu: *sm83) void = abort("TODO");
fn exec_rrc_hl(cpu: *sm83) void = abort("TODO");
fn exec_rrc_a(cpu: *sm83) void = void;
fn exec_rrc_b(cpu: *sm83) void = void;
fn exec_rrc_c(cpu: *sm83) void = void;
fn exec_rrc_d(cpu: *sm83) void = void;
fn exec_rrc_e(cpu: *sm83) void = void;
fn exec_rrc_h(cpu: *sm83) void = void;
fn exec_rrc_l(cpu: *sm83) void = void;
fn exec_rrc_hl(cpu: *sm83) void = void;

fn exec_rl_a(cpu: *sm83) void = abort("TODO");
fn exec_rl_b(cpu: *sm83) void = abort("TODO");
fn exec_rl_c(cpu: *sm83) void = abort("TODO");
fn exec_rl_d(cpu: *sm83) void = abort("TODO");
fn exec_rl_e(cpu: *sm83) void = abort("TODO");
fn exec_rl_h(cpu: *sm83) void = abort("TODO");
fn exec_rl_l(cpu: *sm83) void = abort("TODO");
fn exec_rl_hl(cpu: *sm83) void = abort("TODO");
fn exec_rl_a(cpu: *sm83) void = void;
fn exec_rl_b(cpu: *sm83) void = void;
fn exec_rl_c(cpu: *sm83) void = void;
fn exec_rl_d(cpu: *sm83) void = void;
fn exec_rl_e(cpu: *sm83) void = void;
fn exec_rl_h(cpu: *sm83) void = void;
fn exec_rl_l(cpu: *sm83) void = void;
fn exec_rl_hl(cpu: *sm83) void = void;

fn exec_rr_a(cpu: *sm83) void = abort("TODO");
fn exec_rr_b(cpu: *sm83) void = abort("TODO");
fn exec_rr_c(cpu: *sm83) void = abort("TODO");
fn exec_rr_d(cpu: *sm83) void = abort("TODO");
fn exec_rr_e(cpu: *sm83) void = abort("TODO");
fn exec_rr_h(cpu: *sm83) void = abort("TODO");
fn exec_rr_l(cpu: *sm83) void = abort("TODO");
fn exec_rr_hl(cpu: *sm83) void = abort("TODO");
fn exec_rr_a(cpu: *sm83) void = void;
fn exec_rr_b(cpu: *sm83) void = void;
fn exec_rr_c(cpu: *sm83) void = void;
fn exec_rr_d(cpu: *sm83) void = void;
fn exec_rr_e(cpu: *sm83) void = void;
fn exec_rr_h(cpu: *sm83) void = void;
fn exec_rr_l(cpu: *sm83) void = void;
fn exec_rr_hl(cpu: *sm83) void = void;

fn exec_sla_a(cpu: *sm83) void = abort("TODO");
fn exec_sla_b(cpu: *sm83) void = abort("TODO");
fn exec_sla_c(cpu: *sm83) void = abort("TODO");
fn exec_sla_d(cpu: *sm83) void = abort("TODO");
fn exec_sla_e(cpu: *sm83) void = abort("TODO");
fn exec_sla_h(cpu: *sm83) void = abort("TODO");
fn exec_sla_l(cpu: *sm83) void = abort("TODO");
fn exec_sla_hl(cpu: *sm83) void = abort("TODO");
fn exec_sla_a(cpu: *sm83) void = void;
fn exec_sla_b(cpu: *sm83) void = void;
fn exec_sla_c(cpu: *sm83) void = void;
fn exec_sla_d(cpu: *sm83) void = void;
fn exec_sla_e(cpu: *sm83) void = void;
fn exec_sla_h(cpu: *sm83) void = void;
fn exec_sla_l(cpu: *sm83) void = void;
fn exec_sla_hl(cpu: *sm83) void = void;

fn exec_sra_a(cpu: *sm83) void = abort("TODO");
fn exec_sra_b(cpu: *sm83) void = abort("TODO");
fn exec_sra_c(cpu: *sm83) void = abort("TODO");
fn exec_sra_d(cpu: *sm83) void = abort("TODO");
fn exec_sra_e(cpu: *sm83) void = abort("TODO");
fn exec_sra_h(cpu: *sm83) void = abort("TODO");
fn exec_sra_l(cpu: *sm83) void = abort("TODO");
fn exec_sra_hl(cpu: *sm83) void = abort("TODO");
fn exec_sra_a(cpu: *sm83) void = void;
fn exec_sra_b(cpu: *sm83) void = void;
fn exec_sra_c(cpu: *sm83) void = void;
fn exec_sra_d(cpu: *sm83) void = void;
fn exec_sra_e(cpu: *sm83) void = void;
fn exec_sra_h(cpu: *sm83) void = void;
fn exec_sra_l(cpu: *sm83) void = void;
fn exec_sra_hl(cpu: *sm83) void = void;

fn swap(reg: *u8) void = {
	const lower = *reg & 0xF;