mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2025-04-02 11:02:17 -04:00
added IterateBlessed() function for Disassembly type. more convenient method of outputting disassembly to a string. instruction defintion notes whether opcode is undocumented linter flags use of undocumented opcodes renamed DISASSEMBLY command to DISASM added single address disassembly to DISASM command
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
// This file is part of Gopher2600.
|
|
//
|
|
// Gopher2600 is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Gopher2600 is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
package disassembly
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/jetsetilly/gopher2600/curated"
|
|
)
|
|
|
|
// Write the entire disassembly to io.Writer.
|
|
func (dsm *Disassembly) Write(output io.Writer, attr ColumnAttr) error {
|
|
dsm.IterateBlessed(output, func(e *Entry) string {
|
|
return e.StringColumnated(attr)
|
|
})
|
|
return nil
|
|
}
|
|
|
|
// WriteBank writes the disassembly of the selected bank to io.Writer.
|
|
func (dsm *Disassembly) WriteBank(output io.Writer, attr ColumnAttr, bank int) error {
|
|
dsm.IterateBlessed(output, func(e *Entry) string {
|
|
if e.Bank.Number != bank {
|
|
return ""
|
|
}
|
|
return e.StringColumnated(attr)
|
|
})
|
|
return nil
|
|
}
|
|
|
|
// WriteAddr writes the disassembly of the specified address to the io.Writer.
|
|
func (dsm *Disassembly) WriteAddr(output io.Writer, attr ColumnAttr, addr uint16) error {
|
|
e, _ := dsm.GetEntryByAddress(addr)
|
|
if e != nil && e.Level >= EntryLevelBlessed {
|
|
output.Write([]byte(e.StringColumnated(attr)))
|
|
} else {
|
|
return curated.Errorf(fmt.Sprintf("no blessed disassembly at $%04x", addr))
|
|
}
|
|
return nil
|
|
}
|