mirror of
https://github.com/colby-swandale/waterfoul
synced 2025-01-14 08:01:51 +01:00
handle HALT instruction
This commit is contained in:
parent
faf994fb89
commit
a10a2794d1
2 changed files with 12 additions and 17 deletions
|
@ -74,30 +74,24 @@ module Waterfoul
|
|||
def step
|
||||
reset_tick
|
||||
serve_interrupt if @ime
|
||||
check_halt if @halt
|
||||
if halted?
|
||||
@m = 4
|
||||
else
|
||||
instruction_byte = fetch_instruction
|
||||
perform_instruction instruction_byte
|
||||
end
|
||||
@timer.tick @m
|
||||
end
|
||||
|
||||
def check_halt
|
||||
@halt = false if @pre_halt_interrupt != $mmu.read_byte(0xFF0F)
|
||||
end
|
||||
|
||||
def halted?
|
||||
@halt == true
|
||||
end
|
||||
|
||||
def halt_step
|
||||
if @halt_cycles > 0
|
||||
@halt_cycles -= 2
|
||||
if @halt_cycles <= 0
|
||||
@halt_cycles = 0
|
||||
@halt = false
|
||||
end
|
||||
end
|
||||
|
||||
if @halt && Interrupt.pending_interupts != Interrupt::INTERRUPT_NONE && @halt_cycles == 0
|
||||
@halt_cycles = HALT_CYCLES
|
||||
end
|
||||
@m = 2
|
||||
end
|
||||
|
||||
# Execute the instruction and
|
||||
def perform_instruction(instruction)
|
||||
operation = OPCODE[instruction]
|
||||
|
|
|
@ -19,6 +19,7 @@ module Waterfoul
|
|||
# Halt CPU & LCD display until button pressed.
|
||||
# @flags - - - -
|
||||
def halt
|
||||
@pre_halt_interrupt = $mmu.read_byte(0xFF0F)
|
||||
@halt = true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue