mirror of
https://github.com/mattrberry/crab.git
synced 2025-02-05 08:45:50 +01:00
remove hot .to_u8 call in bus, add fps to display title
This commit is contained in:
parent
7795000cac
commit
800bf36803
2 changed files with 15 additions and 3 deletions
|
@ -28,9 +28,9 @@ class Bus
|
|||
when PPU_IO then @gba.ppu[index]
|
||||
when PPU then @gba.ppu[index]
|
||||
when CARTRIDGE then @gba.cartridge[index - CARTRIDGE.begin]
|
||||
when UNUSED then 0xFF
|
||||
else 0xFF
|
||||
end.to_u8
|
||||
when UNUSED then 0xFF_u8
|
||||
else 0xFF_u8
|
||||
end
|
||||
end
|
||||
|
||||
def read_word(index : Int) : Word
|
||||
|
|
|
@ -14,10 +14,22 @@ class Display
|
|||
@texture = LibSDL.create_texture @renderer, PIXELFORMAT_BGR555, TEXTUREACCESS_STREAMING, WIDTH, HEIGHT
|
||||
end
|
||||
|
||||
def window_title : String
|
||||
"crab - #{@fps} fps"
|
||||
end
|
||||
|
||||
@fps = 30
|
||||
@seconds : Int32 = Time.utc.second
|
||||
def draw(framebuffer : Bytes) : Nil
|
||||
LibSDL.update_texture @texture, nil, framebuffer, WIDTH * 2
|
||||
@renderer.clear
|
||||
@renderer.copy @texture
|
||||
@renderer.present
|
||||
@fps += 1
|
||||
if Time.utc.second != @seconds
|
||||
@window.title = window_title
|
||||
@fps = 0
|
||||
@seconds = Time.utc.second
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue