How to use the gilgamesh.snes.opcodes.AddressMode function in gilgamesh

To help you get started, we’ve selected a few gilgamesh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.ORA, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.ORA, AddressMode.STACK_RELATIVE_INDIRECT_INDEXED),
    (Op.TRB, AddressMode.DIRECT_PAGE),
    (Op.ORA, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ASL, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ORA, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.CLC, AddressMode.IMPLIED),
    (Op.ORA, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.INC, AddressMode.IMPLIED_ACCUMULATOR),
    (Op.TCS, AddressMode.IMPLIED),
    (Op.TRB, AddressMode.ABSOLUTE),
    (Op.ORA, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.ASL, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.ORA, AddressMode.ABSOLUTE_INDEXED_LONG),
    (Op.JSR, AddressMode.ABSOLUTE),
    (Op.AND, AddressMode.DIRECT_PAGE_INDEXED_INDIRECT),
    (Op.JSL, AddressMode.ABSOLUTE_LONG),
    (Op.AND, AddressMode.STACK_RELATIVE),
    (Op.BIT, AddressMode.DIRECT_PAGE),
    (Op.AND, AddressMode.DIRECT_PAGE),
    (Op.ROL, AddressMode.DIRECT_PAGE),
    (Op.AND, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.PLP, AddressMode.IMPLIED),
    (Op.AND, AddressMode.IMMEDIATE_M),
    (Op.ROL, AddressMode.IMPLIED_ACCUMULATOR),
    (Op.PLD, AddressMode.IMPLIED),
    (Op.BIT, AddressMode.ABSOLUTE),
    (Op.AND, AddressMode.ABSOLUTE),
    (Op.ROL, AddressMode.ABSOLUTE),
    (Op.AND, AddressMode.ABSOLUTE_LONG),
    (Op.BMI, AddressMode.RELATIVE),
    (Op.AND, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.SBC, AddressMode.DIRECT_PAGE),
    (Op.INC, AddressMode.DIRECT_PAGE),
    (Op.SBC, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.INX, AddressMode.IMPLIED),
    (Op.SBC, AddressMode.IMMEDIATE_M),
    (Op.NOP, AddressMode.IMPLIED),
    (Op.XBA, AddressMode.IMPLIED),
    (Op.CPX, AddressMode.ABSOLUTE),
    (Op.SBC, AddressMode.ABSOLUTE),
    (Op.INC, AddressMode.ABSOLUTE),
    (Op.SBC, AddressMode.ABSOLUTE_LONG),
    (Op.BEQ, AddressMode.RELATIVE),
    (Op.SBC, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
    (Op.SBC, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.SBC, AddressMode.STACK_RELATIVE_INDIRECT_INDEXED),
    (Op.PEA, AddressMode.STACK_ABSOLUTE),
    (Op.SBC, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.INC, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.SBC, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.SED, AddressMode.IMPLIED),
    (Op.SBC, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.PLX, AddressMode.IMPLIED),
    (Op.XCE, AddressMode.IMPLIED),
    (Op.JSR, AddressMode.ABSOLUTE_INDEXED_INDIRECT),
    (Op.SBC, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.INC, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.SBC, AddressMode.ABSOLUTE_INDEXED_LONG),
]

descriptions = {
    Op.ADC: "Add With Carry",
    Op.AND: "AND Accumulator With Memory",
github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.CMP, AddressMode.DIRECT_PAGE),
    (Op.DEC, AddressMode.DIRECT_PAGE),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.INY, AddressMode.IMPLIED),
    (Op.CMP, AddressMode.IMMEDIATE_M),
    (Op.DEX, AddressMode.IMPLIED),
    (Op.WAI, AddressMode.IMPLIED),
    (Op.CPY, AddressMode.ABSOLUTE),
    (Op.CMP, AddressMode.ABSOLUTE),
    (Op.DEC, AddressMode.ABSOLUTE),
    (Op.CMP, AddressMode.ABSOLUTE_LONG),
    (Op.BNE, AddressMode.RELATIVE),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.PEI, AddressMode.PEI_DIRECT_PAGE_INDIRECT),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.DEC, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.CLD, AddressMode.IMPLIED),
    (Op.CMP, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.PHX, AddressMode.IMPLIED),
    (Op.STP, AddressMode.IMPLIED),
    (Op.JML, AddressMode.ABSOLUTE_INDIRECT_LONG),
    (Op.CMP, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.DEC, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.CMP, AddressMode.ABSOLUTE_INDEXED_LONG),
    (Op.CPX, AddressMode.IMMEDIATE_X),
    (Op.SBC, AddressMode.DIRECT_PAGE_INDEXED_INDIRECT),
    (Op.SEP, AddressMode.IMMEDIATE_8),
    (Op.SBC, AddressMode.STACK_RELATIVE),
    (Op.CPX, AddressMode.DIRECT_PAGE),
github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.ORA, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ASL, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ORA, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.CLC, AddressMode.IMPLIED),
    (Op.ORA, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.INC, AddressMode.IMPLIED_ACCUMULATOR),
    (Op.TCS, AddressMode.IMPLIED),
    (Op.TRB, AddressMode.ABSOLUTE),
    (Op.ORA, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.ASL, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.ORA, AddressMode.ABSOLUTE_INDEXED_LONG),
    (Op.JSR, AddressMode.ABSOLUTE),
    (Op.AND, AddressMode.DIRECT_PAGE_INDEXED_INDIRECT),
    (Op.JSL, AddressMode.ABSOLUTE_LONG),
    (Op.AND, AddressMode.STACK_RELATIVE),
    (Op.BIT, AddressMode.DIRECT_PAGE),
    (Op.AND, AddressMode.DIRECT_PAGE),
    (Op.ROL, AddressMode.DIRECT_PAGE),
    (Op.AND, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.PLP, AddressMode.IMPLIED),
    (Op.AND, AddressMode.IMMEDIATE_M),
    (Op.ROL, AddressMode.IMPLIED_ACCUMULATOR),
    (Op.PLD, AddressMode.IMPLIED),
    (Op.BIT, AddressMode.ABSOLUTE),
    (Op.AND, AddressMode.ABSOLUTE),
    (Op.ROL, AddressMode.ABSOLUTE),
    (Op.AND, AddressMode.ABSOLUTE_LONG),
    (Op.BMI, AddressMode.RELATIVE),
    (Op.AND, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
    (Op.AND, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.AND, AddressMode.STACK_RELATIVE_INDIRECT_INDEXED),
    (Op.BIT, AddressMode.DIRECT_PAGE_INDEXED_X),
github AndreaOrru / gilgamesh / gilgamesh / snes / cpu.py View on Github external
def change_a(self, i: Instruction) -> None:
        if i.address_mode == AddressMode.IMMEDIATE_M:
            assert i.argument is not None
            a = self.registers.a.get()

            if i.operation == Op.LDA:
                self.registers.a.set(i.argument)
            elif a is not None:
                if i.operation == Op.ADC:
                    # TODO: handle carry flag.
                    self.registers.a.set(a + i.argument)
                elif i.operation == Op.SBC:
                    # TODO: handle negative flag.
                    self.registers.a.set(a - i.argument)
        elif i.operation == Op.TSC:
            self.registers.a.set_whole(self.stack.pointer)
        elif i.operation == Op.PLA:
            self.stack.pop(self.state.a_size)
github AndreaOrru / gilgamesh / gilgamesh / snes / cpu.py View on Github external
def _derive_state_inference(self, instruction: Instruction) -> None:
        # If we're executing an instruction with a certain operand size,
        # and no state change has been performed in the current subroutine,
        # then we can infer that the state of the processor as we enter
        # the subroutine *must* be the same in all cases.
        if (
            instruction.address_mode == AddressMode.IMMEDIATE_M
            and self.state_change.m is None
        ):
            self.state_inference.m = self.state.m
        elif (
            instruction.address_mode == AddressMode.IMMEDIATE_X
            and self.state_change.x is None
        ):
            self.state_inference.x = self.state.x
github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.LDY, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.LDA, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.LDX, AddressMode.DIRECT_PAGE_INDEXED_Y),
    (Op.LDA, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.CLV, AddressMode.IMPLIED),
    (Op.LDA, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.TSX, AddressMode.IMPLIED),
    (Op.TYX, AddressMode.IMPLIED),
    (Op.LDY, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.LDA, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.LDX, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.LDA, AddressMode.ABSOLUTE_INDEXED_LONG),
    (Op.CPY, AddressMode.IMMEDIATE_X),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDEXED_INDIRECT),
    (Op.REP, AddressMode.IMMEDIATE_8),
    (Op.CMP, AddressMode.STACK_RELATIVE),
    (Op.CPY, AddressMode.DIRECT_PAGE),
    (Op.CMP, AddressMode.DIRECT_PAGE),
    (Op.DEC, AddressMode.DIRECT_PAGE),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.INY, AddressMode.IMPLIED),
    (Op.CMP, AddressMode.IMMEDIATE_M),
    (Op.DEX, AddressMode.IMPLIED),
    (Op.WAI, AddressMode.IMPLIED),
    (Op.CPY, AddressMode.ABSOLUTE),
    (Op.CMP, AddressMode.ABSOLUTE),
    (Op.DEC, AddressMode.ABSOLUTE),
    (Op.CMP, AddressMode.ABSOLUTE_LONG),
    (Op.BNE, AddressMode.RELATIVE),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.CMP, AddressMode.DIRECT_PAGE_INDIRECT),
github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.STA, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.DEY, AddressMode.IMPLIED),
    (Op.BIT, AddressMode.IMMEDIATE_M),
    (Op.TXA, AddressMode.IMPLIED),
    (Op.PHB, AddressMode.IMPLIED),
    (Op.STY, AddressMode.ABSOLUTE),
    (Op.STA, AddressMode.ABSOLUTE),
    (Op.STX, AddressMode.ABSOLUTE),
    (Op.STA, AddressMode.ABSOLUTE_LONG),
    (Op.BCC, AddressMode.RELATIVE),
    (Op.STA, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
    (Op.STA, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.STA, AddressMode.STACK_RELATIVE_INDIRECT_INDEXED),
    (Op.STY, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.STA, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.STX, AddressMode.DIRECT_PAGE_INDEXED_Y),
    (Op.STA, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.TYA, AddressMode.IMPLIED),
    (Op.STA, AddressMode.ABSOLUTE_INDEXED_Y),
    (Op.TXS, AddressMode.IMPLIED),
    (Op.TXY, AddressMode.IMPLIED),
    (Op.STZ, AddressMode.ABSOLUTE),
    (Op.STA, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.STZ, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.STA, AddressMode.ABSOLUTE_INDEXED_LONG),
    (Op.LDY, AddressMode.IMMEDIATE_X),
    (Op.LDA, AddressMode.DIRECT_PAGE_INDEXED_INDIRECT),
    (Op.LDX, AddressMode.IMMEDIATE_X),
    (Op.LDA, AddressMode.STACK_RELATIVE),
    (Op.LDY, AddressMode.DIRECT_PAGE),
    (Op.LDA, AddressMode.DIRECT_PAGE),
    (Op.LDX, AddressMode.DIRECT_PAGE),
github AndreaOrru / gilgamesh / gilgamesh / snes / opcodes.py View on Github external
(Op.PHY, AddressMode.IMPLIED),
    (Op.TCD, AddressMode.IMPLIED),
    (Op.JML, AddressMode.ABSOLUTE_LONG),
    (Op.EOR, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.LSR, AddressMode.ABSOLUTE_INDEXED_X),
    (Op.EOR, AddressMode.ABSOLUTE_INDEXED_LONG),
    (Op.RTS, AddressMode.IMPLIED),
    (Op.ADC, AddressMode.DIRECT_PAGE_INDEXED_INDIRECT),
    (Op.PER, AddressMode.RELATIVE_LONG),
    (Op.ADC, AddressMode.STACK_RELATIVE),
    (Op.STZ, AddressMode.DIRECT_PAGE),
    (Op.ADC, AddressMode.DIRECT_PAGE),
    (Op.ROR, AddressMode.DIRECT_PAGE),
    (Op.ADC, AddressMode.DIRECT_PAGE_INDIRECT_LONG),
    (Op.PLA, AddressMode.IMPLIED),
    (Op.ADC, AddressMode.IMMEDIATE_M),
    (Op.ROR, AddressMode.IMPLIED_ACCUMULATOR),
    (Op.RTL, AddressMode.IMPLIED),
    (Op.JMP, AddressMode.ABSOLUTE_INDIRECT),
    (Op.ADC, AddressMode.ABSOLUTE),
    (Op.ROR, AddressMode.ABSOLUTE),
    (Op.ADC, AddressMode.ABSOLUTE_LONG),
    (Op.BVS, AddressMode.RELATIVE),
    (Op.ADC, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED),
    (Op.ADC, AddressMode.DIRECT_PAGE_INDIRECT),
    (Op.ADC, AddressMode.STACK_RELATIVE_INDIRECT_INDEXED),
    (Op.STZ, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ADC, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ROR, AddressMode.DIRECT_PAGE_INDEXED_X),
    (Op.ADC, AddressMode.DIRECT_PAGE_INDIRECT_INDEXED_LONG),
    (Op.SEI, AddressMode.IMPLIED),
    (Op.ADC, AddressMode.ABSOLUTE_INDEXED_Y),