Class: Amaterasu::GameBoy::Ppu::Modes::HBlank

Inherits:
Object
  • Object
show all
Defined in:
lib/amaterasu/game_boy/ppu/modes/h_blank.rb

Overview

Defines the behavior of the Ppu during HBlank mode.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ppu) ⇒ HBlank

Returns a new instance of HBlank.



11
12
13
14
15
16
# File 'lib/amaterasu/game_boy/ppu/modes/h_blank.rb', line 11

def initialize(ppu)
  @ppu = ppu

  @name = 'HBLANK'
  @number = 0
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/amaterasu/game_boy/ppu/modes/h_blank.rb', line 9

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/amaterasu/game_boy/ppu/modes/h_blank.rb', line 9

def number
  @number
end

Instance Method Details

#inspectObject



32
33
34
35
36
# File 'lib/amaterasu/game_boy/ppu/modes/h_blank.rb', line 32

def inspect
  '#<Amaterasu::GameBoy::Ppu::Modes::HBlank ' \
    "@name='#{@name}' " \
    "@number=#{@number} "
end

#tickObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/amaterasu/game_boy/ppu/modes/h_blank.rb', line 18

def tick
  return unless @ppu.dots == DOTS_PER_SCANLINE

  @ppu.reset_for_scanline
  @ppu.increment_ly

  if @ppu.registers.ly < VISIBLE_SCANLINES
    @ppu.set_mode(:oam_scan)
  elsif @ppu.registers.ly == VISIBLE_SCANLINES
    @ppu.set_mode(:v_blank)
    @ppu.request_interrupt(:v_blank)
  end
end

#to_sObject



38
39
40
# File 'lib/amaterasu/game_boy/ppu/modes/h_blank.rb', line 38

def to_s
  "#{@name} (##{@number}) | WAITING FOR SCANLINE TO FINISH"
end