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
|
def step
|
||||||
reset_tick
|
reset_tick
|
||||||
serve_interrupt if @ime
|
serve_interrupt if @ime
|
||||||
instruction_byte = fetch_instruction
|
check_halt if @halt
|
||||||
perform_instruction instruction_byte
|
if halted?
|
||||||
|
@m = 4
|
||||||
|
else
|
||||||
|
instruction_byte = fetch_instruction
|
||||||
|
perform_instruction instruction_byte
|
||||||
|
end
|
||||||
@timer.tick @m
|
@timer.tick @m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_halt
|
||||||
|
@halt = false if @pre_halt_interrupt != $mmu.read_byte(0xFF0F)
|
||||||
|
end
|
||||||
|
|
||||||
def halted?
|
def halted?
|
||||||
@halt == true
|
@halt == true
|
||||||
end
|
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
|
# Execute the instruction and
|
||||||
def perform_instruction(instruction)
|
def perform_instruction(instruction)
|
||||||
operation = OPCODE[instruction]
|
operation = OPCODE[instruction]
|
||||||
|
|
|
@ -19,6 +19,7 @@ module Waterfoul
|
||||||
# Halt CPU & LCD display until button pressed.
|
# Halt CPU & LCD display until button pressed.
|
||||||
# @flags - - - -
|
# @flags - - - -
|
||||||
def halt
|
def halt
|
||||||
|
@pre_halt_interrupt = $mmu.read_byte(0xFF0F)
|
||||||
@halt = true
|
@halt = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue