def jp_a16(): cpu.add_ticks(16) lower = memory.read(cpu.registers.PC) upper = memory.read(cpu.registers.PC+1) jaddress = (upper << 8) | (lower & 0xFF) cpu.registers.PC = jaddress return
def helper(): cpu.add_ticks(8) # memory access costs 4 ticks more if opcode == 0x36: cpu.add_ticks(4) # get the register, and read in the opcode 'argument' reg = _d8regmap[opcode] cpu.registers[reg] = memory.read(cpu.registers.PC +1) cpu.registers.PC += 1
def helper(): destreg = 0 opcode -= 0x40 while(opcode >= 0x08): opcode -= 0x08 destreg += 1 cpu.add_ticks(4) # These access memory, and take longer if (opcode == 0x06 or destreg == 0x06): cpu.add_ticks(4) dest = REGISTER_MAP[destreg] cpu.registers[dest] = cpu.registers[REGISTER_MAP[opcode]]
def func(opcode): bit = 0 opcode -= base_opcode while (opcode >= 0x08): opcode -= 0x08 bit = bit + 1 if opcode == 0x06: cpu.add_ticks(16) else: cpu.add_ticks(8) register = REGISTER_MAP[opcode] cpu.registers[register] = op(cpu.registers[register], bit)
def nop(): cpu.add_ticks(4) return
def ldh_a_n(): cpu.add_ticks(12) n = memory.read(cpu.registers.PC) cpu.registers.PC += 1 cpu.registers.A = memory.read(0xFF00+n)
def ldh_n_a(): cpu.add_ticks(12) n = memory.read(cpu.registers.PC) cpu.registers.PC += 1 memory.write(0xFF00+n, cpu.registers.A)
def ld_a_ic(): # ld A,(C) cpu.add_ticks(8) cpu.registers.A = memory.read(0xFF00 + cpu.registers.C)
def ld_ic_a(): # LD (C), A cpu.add_ticks(8) memory.write(0xFF00 + cpu.registers.C, cpu.registers.A)