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
|
||||
type State struct {
|
||||
reg registers
|
||||
mem Memory
|
||||
cycles uint64
|
||||
opcodes *[256]opcode
|
||||
trace bool
|
||||
lineCache []uint8
|
||||
opcodes *[256]opcode
|
||||
trace bool
|
||||
|
||||
reg registers
|
||||
mem Memory
|
||||
cycles uint64
|
||||
|
||||
extraCycle bool
|
||||
lineCache []uint8
|
||||
// We cache the allocation of a line to avoid a malloc per instruction. To be used only
|
||||
// by ExecuteInstruction(). 2x speedup on the emulation!!
|
||||
}
|
||||
|
@ -76,6 +79,10 @@ func (s *State) ExecuteInstruction() {
|
|||
}
|
||||
opcode.action(s, s.lineCache, opcode)
|
||||
s.cycles += uint64(opcode.cycles)
|
||||
if s.extraCycle {
|
||||
s.cycles++
|
||||
s.extraCycle = false
|
||||
}
|
||||
if s.trace {
|
||||
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 {
|
||||
return func(s *State, line []uint8, opcode opcode) {
|
||||
if s.reg.getFlag(flag) == test {
|
||||
s.extraCycle = true
|
||||
address := resolveAddress(s, line, opcode)
|
||||
s.reg.setPC(address)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ Emulation status for the disk used on the reference:
|
|||
- *** Commando: Not working
|
||||
- Planetfall: Working
|
||||
- Rescue Raiders: Working
|
||||
- *** Sammy Lightfoot: Not working
|
||||
- Sammy Lightfoot: Working (failed if no 6502 extra cycle is added on branches done)
|
||||
- Stargate: Working
|
||||
- Cross track sync
|
||||
- *** Blazing Paddles: Not working
|
||||
|
|
Loading…
Reference in New Issue