Extra cycle when brancing on conditional jumps. Fixes Sammy Lighfoot woz loadind.
This commit is contained in:
parent
512988655d
commit
c7f643623d
|
@ -17,12 +17,15 @@ const (
|
||||||
|
|
||||||
// State represents the state of the simulated device
|
// State represents the state of the simulated device
|
||||||
type State struct {
|
type State struct {
|
||||||
reg registers
|
opcodes *[256]opcode
|
||||||
mem Memory
|
trace bool
|
||||||
cycles uint64
|
|
||||||
opcodes *[256]opcode
|
reg registers
|
||||||
trace bool
|
mem Memory
|
||||||
lineCache []uint8
|
cycles uint64
|
||||||
|
|
||||||
|
extraCycle bool
|
||||||
|
lineCache []uint8
|
||||||
// We cache the allocation of a line to avoid a malloc per instruction. To be used only
|
// We cache the allocation of a line to avoid a malloc per instruction. To be used only
|
||||||
// by ExecuteInstruction(). 2x speedup on the emulation!!
|
// by ExecuteInstruction(). 2x speedup on the emulation!!
|
||||||
}
|
}
|
||||||
|
@ -76,6 +79,10 @@ func (s *State) ExecuteInstruction() {
|
||||||
}
|
}
|
||||||
opcode.action(s, s.lineCache, opcode)
|
opcode.action(s, s.lineCache, opcode)
|
||||||
s.cycles += uint64(opcode.cycles)
|
s.cycles += uint64(opcode.cycles)
|
||||||
|
if s.extraCycle {
|
||||||
|
s.cycles++
|
||||||
|
s.extraCycle = false
|
||||||
|
}
|
||||||
if s.trace {
|
if s.trace {
|
||||||
fmt.Printf("%v, [%02x]\n", s.reg, s.lineCache[0:opcode.bytes])
|
fmt.Printf("%v, [%02x]\n", s.reg, s.lineCache[0:opcode.bytes])
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ func buildOpUpdateFlag(flag uint8, value bool) opFunc {
|
||||||
func buildOpBranch(flag uint8, test bool) opFunc {
|
func buildOpBranch(flag uint8, test bool) opFunc {
|
||||||
return func(s *State, line []uint8, opcode opcode) {
|
return func(s *State, line []uint8, opcode opcode) {
|
||||||
if s.reg.getFlag(flag) == test {
|
if s.reg.getFlag(flag) == test {
|
||||||
|
s.extraCycle = true
|
||||||
address := resolveAddress(s, line, opcode)
|
address := resolveAddress(s, line, opcode)
|
||||||
s.reg.setPC(address)
|
s.reg.setPC(address)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ Emulation status for the disk used on the reference:
|
||||||
- *** Commando: Not working
|
- *** Commando: Not working
|
||||||
- Planetfall: Working
|
- Planetfall: Working
|
||||||
- Rescue Raiders: Working
|
- Rescue Raiders: Working
|
||||||
- *** Sammy Lightfoot: Not working
|
- Sammy Lightfoot: Working (failed if no 6502 extra cycle is added on branches done)
|
||||||
- Stargate: Working
|
- Stargate: Working
|
||||||
- Cross track sync
|
- Cross track sync
|
||||||
- *** Blazing Paddles: Not working
|
- *** Blazing Paddles: Not working
|
||||||
|
|
Loading…
Reference in New Issue