Skip to content

Commit

Permalink
upgrade retrogolib
Browse files Browse the repository at this point in the history
  • Loading branch information
cornelk committed Dec 10, 2024
1 parent c72de60 commit 0385e12
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/retroenv/nesgodisasm

go 1.22

require github.com/retroenv/retrogolib v0.0.0-20241105003543-931e147416dc
require github.com/retroenv/retrogolib v0.0.0-20241210033726-b294e4b1cc68
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/retroenv/retrogolib v0.0.0-20241105003543-931e147416dc h1:hRuZBHYI/K0w0PTQEJrJ8o5hwW9s1wqWqEogdBL8Z3o=
github.com/retroenv/retrogolib v0.0.0-20241105003543-931e147416dc/go.mod h1:8pe9mEjbKL9Z5L4FFzYGSk1Ovhrq1LR6ucwRFj5CIXs=
github.com/retroenv/retrogolib v0.0.0-20241210033726-b294e4b1cc68 h1:woI2bmTWznMA9UX0iR5kZs7QfRaF4ZVM+B8mMHaTLCg=
github.com/retroenv/retrogolib v0.0.0-20241210033726-b294e4b1cc68/go.mod h1:8pe9mEjbKL9Z5L4FFzYGSk1Ovhrq1LR6ucwRFj5CIXs=
3 changes: 1 addition & 2 deletions internal/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
. "github.com/retroenv/retrogolib/addressing"
"github.com/retroenv/retrogolib/arch/cpu/m6502"
"github.com/retroenv/retrogolib/arch/nes/register"
"github.com/retroenv/retrogolib/cpu"
)

type constTranslation struct {
Expand All @@ -17,7 +16,7 @@ type constTranslation struct {
Write string
}

func (dis *Disasm) replaceParamByConstant(address uint16, opcode cpu.Opcode, paramAsString string,
func (dis *Disasm) replaceParamByConstant(address uint16, opcode m6502.Opcode, paramAsString string,
constantInfo constTranslation) string {

// split parameter string in case of x/y indexing, only the first part will be replaced by a const name
Expand Down
4 changes: 2 additions & 2 deletions internal/disasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/retroenv/nesgodisasm/internal/options"
"github.com/retroenv/nesgodisasm/internal/program"
"github.com/retroenv/nesgodisasm/internal/writer"
"github.com/retroenv/retrogolib/arch/cpu/m6502"
"github.com/retroenv/retrogolib/arch/nes"
"github.com/retroenv/retrogolib/arch/nes/cartridge"
"github.com/retroenv/retrogolib/arch/nes/codedatalog"
"github.com/retroenv/retrogolib/arch/nes/parameter"
"github.com/retroenv/retrogolib/cpu"
"github.com/retroenv/retrogolib/log"
)

Expand All @@ -31,7 +31,7 @@ type fileWriterConstructor func(app *program.Program, options *options.Disassemb
type offset struct {
program.Offset

opcode cpu.Opcode // opcode that the byte at this offset represents
opcode m6502.Opcode // opcode that the byte at this offset represents

branchFrom []bankReference // list of all addresses that branch to this offset
branchingTo string // label to jump to if instruction branches
Expand Down
7 changes: 3 additions & 4 deletions internal/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/retroenv/retrogolib/arch/cpu/m6502"
"github.com/retroenv/retrogolib/arch/nes"
"github.com/retroenv/retrogolib/arch/nes/parameter"
"github.com/retroenv/retrogolib/cpu"
)

var errInstructionOverlapsIRQHandlers = errors.New("instruction overlaps IRQ handler start")
Expand Down Expand Up @@ -140,7 +139,7 @@ func (dis *Disasm) processParamInstruction(address uint16, offsetInfo *offset) (

// replaceParamByAlias replaces the absolute address with an alias name if it can match it to
// a constant, zero page variable or a code reference.
func (dis *Disasm) replaceParamByAlias(address uint16, opcode cpu.Opcode, param any, paramAsString string) string {
func (dis *Disasm) replaceParamByAlias(address uint16, opcode m6502.Opcode, param any, paramAsString string) string {
forceVariableUsage := false
addressReference, addressValid := getAddressingParam(param)
if !addressValid || addressReference >= irqStartAddress {
Expand Down Expand Up @@ -196,7 +195,7 @@ func (dis *Disasm) addressToDisassemble() uint16 {
}

// addAddressToParse adds an address to the list to be processed if the address has not been processed yet.
func (dis *Disasm) addAddressToParse(address, context, from uint16, currentInstruction *cpu.Instruction,
func (dis *Disasm) addAddressToParse(address, context, from uint16, currentInstruction *m6502.Instruction,
isABranchDestination bool) {

// ignore branching into addresses before the code base address, for example when generating code in
Expand Down Expand Up @@ -288,7 +287,7 @@ func getAddressingParam(param any) (uint16, bool) {

// checkBranchingParam checks whether the branching instruction should do a variable check for the parameter
// and forces variable usage.
func checkBranchingParam(address uint16, opcode cpu.Opcode) (bool, bool) {
func checkBranchingParam(address uint16, opcode m6502.Opcode) (bool, bool) {
switch {
case opcode.Instruction.Name == m6502.Jmp.Name && opcode.Addressing == IndirectAddressing:
return true, false
Expand Down
3 changes: 1 addition & 2 deletions internal/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/retroenv/retrogolib/arch/cpu/m6502"
"github.com/retroenv/retrogolib/arch/nes"
"github.com/retroenv/retrogolib/arch/nes/parameter"
"github.com/retroenv/retrogolib/cpu"
)

const (
Expand All @@ -34,7 +33,7 @@ type variable struct {
// the given address directly by reading or writing. In a special case like
// branching into a zeropage address the variable usage can be forced.
func (dis *Disasm) addVariableReference(addressReference, usageAddress uint16,
opcode cpu.Opcode, forceVariableUsage bool) {
opcode m6502.Opcode, forceVariableUsage bool) {

var reads, writes bool
if opcode.ReadWritesMemory(m6502.MemoryReadWriteInstructions) {
Expand Down

0 comments on commit 0385e12

Please sign in to comment.