|
|
- from gbso.cpu.insn import *
- from gbso.cpu.regs import R8, R16
-
- from gbso.optimize import (
- DEFAULT_PROB_INSN,
- DEFAULT_PROB_INSN_UNUSED,
- DEFAULT_PROB_OPCODE,
- DEFAULT_PROB_OPERAND,
- DEFAULT_PROB_SWAP,
- optimize,
- )
- from gbso.program.program import Program
- from gbso.program.mutate import mutate_program
-
- rLCDC = 0xFF40
- rIE = 0xFFFF
-
- IEF_VBLANK = 1 << 0
-
- prgm = Program(
- insns=[
- LD_R_N8(R8.A, 12),
- LD_RR_NN(R16.HL, rLCDC),
- RES_N_HL(7),
- RES_N_HL(2),
- LD_RR_NN(R16.HL, rIE),
- LD_HL_N(IEF_VBLANK),
- ],
- )
-
- optimized_prgm = optimize(prgm)
- optimized_prgm.display()
-
- for _ in range(10):
- prgm = mutate_program(
- prgm,
- prob_opcode=DEFAULT_PROB_OPCODE,
- prob_operand=DEFAULT_PROB_OPERAND,
- prob_swap=DEFAULT_PROB_SWAP,
- prob_insn=DEFAULT_PROB_INSN,
- prob_insn_unused=DEFAULT_PROB_INSN_UNUSED,
- )
- prgm.display()
|