Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/opcode_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func main() {
inst.VariableCycles = m[4] != ""

fmt.Printf("opcode=%02x: %v\n", opcode, inst)
fmt.Fprintf(fout, "0x%02x: {0x%02x, \"%s\", %s, %d, %v},\n",
inst.OpCode, inst.OpCode, inst.Nemonics, inst.AddressingMode.String(), inst.Cycles, inst.VariableCycles)
fmt.Fprintf(fout, "0x%02x: {0x%02x, \"%s\", %d, %d, %v},\n",
inst.OpCode, inst.OpCode, inst.Nemonics, inst.AddressingMode, inst.Cycles, inst.VariableCycles)
}
row++
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/emulator/cpu/addressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (cpu *Cpu) AddressOperand(am AddressingMode) (memory.Ptr, int) {
case IZY:
return cpu.AddressIzy()
default:
panic(fmt.Errorf("unsupported addressing mode: %s", am))
panic(fmt.Errorf("unsupported addressing mode: %d", am))
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/emulator/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ func (cpu *Cpu) logInstruction() {
case 1:
arguments[0] = cpu.Memory.Peek(cpu.PC + 1)
}
logger.Debugf("L%04x: %s %s ; %02x (%s-%s) %s",
logger.Debugf("L%04x: %s %s ; %02x (%s-%d) %s",
cpu.PC, info.Nemonics, formatInstructionArgument(info.AddressingMode, arguments),
opcode, info.Nemonics, info.AddressingMode.String(), hex.EncodeToString(arguments))
opcode, info.Nemonics, info.AddressingMode, hex.EncodeToString(arguments))
}

func formatInstructionArgument(am AddressingMode, args []byte) string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/emulator/cpu/cpu_instruction_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ func TestOpcodeHandlers(t *testing.T) {
for opcode, info := range InstructionInfos {
handler := opcodeHandlers[opcode]
if handler == nil {
log.Printf("Opcode %02x (%s %s) is not implmeneted yet.", opcode, info.Nemonics, info.AddressingMode)
log.Printf("Opcode %02x (%s %d) is not implmeneted yet.", opcode, info.Nemonics, info.AddressingMode)
continue
}
if handler.AddressingMode != info.AddressingMode {
t.Fatalf("BUG: Addressing mode for %02x opcodeHandlers doesn't match the info in InstructionInfos: got %s, expected: %s",
t.Fatalf("BUG: Addressing mode for %02x opcodeHandlers doesn't match the info in InstructionInfos: got %d, expected: %d",
opcode, handler.AddressingMode, info.AddressingMode)
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/emulator/nes/nes.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (nes *NESImpl) Start() error {
go func() {
for tick := range nes.ticker.C {
//tick:=time.Now()
logger.Infof("At time %v", tick)
logger.Debugf("At time %v", tick)

spentCycles := int64(0)
loop := 0
Expand All @@ -153,16 +153,16 @@ func (nes *NESImpl) Start() error {
spentCycles += cycles
loop++
//logger.Debug("")
//logger.Infof("spent %d/%d CPU cycles", spentCycles, cpuCyclesPerFrame)
//logger.Debugf("spent %d/%d CPU cycles", spentCycles, cpuCyclesPerFrame)
}
//nes.display.Refresh()
// update joypad
nes.joypads.Joypads[0].Buttons = nes.display.Keys
//logger.SetOutput(os.Stderr)
logger.Info("----------------------------------------------------------")
logger.Debug("----------------------------------------------------------")
now := time.Now()
actualTime := now.Sub(tick)
logger.Infof("spent %v/%v to render frame #%d after running %v loops / %v cycles",
logger.Debugf("spent %v/%v to render frame #%d after running %v loops / %v cycles",
actualTime, interval, frames, loop, spentCycles)
frames++
//nes.ticker.Stop()
Expand Down