Skip to content

Commit

Permalink
undo for-loop in mb for cycles for each sub-component
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed Sep 15, 2024
1 parent 3890c37 commit f7f6e03
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions pyboy/core/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,22 @@ def tick(self):
# TODO: Run while-loop for max_cycles here. We clearly don't need to return to tick before.
cycles = self.cpu.tick(cycles_target)

_cycles = cycles
for _ in range(_cycles // 4): # TODO: support arbitrary many cycles
cycles = 4
#TODO: Support General Purpose DMA
# https://gbdev.io/pandocs/CGB_Registers.html#bit-7--0---general-purpose-dma

# TODO: Unify interface
sclock = self.sound.clock
if self.cgb and self.double_speed:
self.sound.clock = sclock + cycles//2
else:
self.sound.clock = sclock + cycles
#TODO: Support General Purpose DMA
# https://gbdev.io/pandocs/CGB_Registers.html#bit-7--0---general-purpose-dma

# TODO: Unify interface
sclock = self.sound.clock
if self.cgb and self.double_speed:
self.sound.clock = sclock + cycles//2
else:
self.sound.clock = sclock + cycles

if self.timer.tick(self.cpu._cycles): # TODO: support arbitrary many cycles
self.cpu.set_interruptflag(INTR_TIMER)
if self.timer.tick(self.cpu._cycles):
self.cpu.set_interruptflag(INTR_TIMER)

lcd_interrupt = self.lcd.tick(cycles) # TODO: support arbitrary many cycles
if lcd_interrupt:
self.cpu.set_interruptflag(lcd_interrupt)
lcd_interrupt = self.lcd.tick(cycles)
if lcd_interrupt:
self.cpu.set_interruptflag(lcd_interrupt)

if self.breakpoint_singlestep:
break
Expand Down

0 comments on commit f7f6e03

Please sign in to comment.