Browse Source

Fix button bug

Unsurprisingly, there was just an inverted conditional.
master
Zack Marvel 1 month ago
parent
commit
e388031796
3 changed files with 8 additions and 7 deletions
  1. +2
    -2
      slowboy/mmu.py
  2. +2
    -0
      slowboy/ui.py
  3. +4
    -5
      slowboy/z80.py

+ 2
- 2
slowboy/mmu.py View File

@@ -348,7 +348,7 @@ class MMU():
def joyp(self):
joyp = (self._joyp & 0x30) | 0x0f
buttons = 0
if joyp & JOYP_SELECT_BUTTON_MASK == 0:
if joyp & JOYP_SELECT_DIRECTION_MASK == 0:
if self._buttons['down']:
buttons |= 0x08
if self._buttons['up']:
@@ -357,7 +357,7 @@ class MMU():
buttons |= 0x02
if self._buttons['right']:
buttons |= 0x01
elif joyp & JOYP_SELECT_DIRECTION_MASK == 0:
elif joyp & JOYP_SELECT_BUTTON_MASK == 0:
if self._buttons['start']:
buttons |= 0x08
if self._buttons['select']:


+ 2
- 0
slowboy/ui.py View File

@@ -302,6 +302,8 @@ if __name__ == '__main__':
ui.cpu.mmu.logger.setLevel(logging.DEBUG)
ui.cpu.gpu.logger.setLevel(logging.DEBUG)
elif event.key.keysym.sym == sdl2.SDLK_i:
ui.cpu.logger.setLevel(logging.INFO)
ui.cpu.mmu.logger.setLevel(logging.INFO)
ui.cpu.gpu.logger.setLevel(logging.INFO)
elif event.key.keysym.sym == sdl2.SDLK_r:
ui.cpu.log_regs(log=ui.logger.info)


+ 4
- 5
slowboy/z80.py View File

@@ -797,7 +797,7 @@ class Z80:
@sp.setter
def sp(self, u16):
self._sp = u16 & 0xffff
self.logger.info('Set SP=%#x', self._sp)
# self.logger.debug('Set SP=%#x', self._sp)

def inc_sp(self):
self.sp = (self.sp + 1) & 0xffff
@@ -904,8 +904,6 @@ class Z80:
if self.trace and not self.step:
sleep(0.5)
continue
else:
print('step')

if self.state != State.RUN:
if self.interrupt_controller.has_interrupt:
@@ -949,8 +947,9 @@ class Z80:
op = self.opcode_map[opcode]
self.op = op

# self.log_regs()
# self.log_op()
if self.trace:
self.log_regs()
self.log_op()

# execute
try:


Loading…
Cancel
Save