Class: Amaterasu::GameBoy::Ppu::Modes::VBlank

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

Overview

Defines the behavior of the Ppu during VBlank mode.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ppu) ⇒ VBlank

Returns a new instance of VBlank.



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

def initialize(ppu)
  @ppu = ppu

  @name = 'VBLANK'
  @number = 1
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/amaterasu/game_boy/ppu/modes/v_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/v_blank.rb', line 9

def number
  @number
end

Instance Method Details

#inspectObject



30
31
32
33
34
# File 'lib/amaterasu/game_boy/ppu/modes/v_blank.rb', line 30

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

#tickObject



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

def tick
  return unless @ppu.dots == DOTS_PER_SCANLINE

  @ppu.reset_for_scanline
  @ppu.increment_ly
  return unless @ppu.registers.ly == TOTAL_SCANLINES

  @ppu.draw_frame
  @ppu.reset_states
  @ppu.set_mode(:oam_scan)
end

#to_sObject



36
37
38
# File 'lib/amaterasu/game_boy/ppu/modes/v_blank.rb', line 36

def to_s
  "#{@name} (##{@number}) | WAITING UNTIL THE FRAME IS COMPLETED"
end