diff --git a/src/oboy.ml b/src/oboy.ml index 33f74be..785710d 100644 --- a/src/oboy.ml +++ b/src/oboy.ml @@ -1,8 +1,8 @@ open Printf -let rec run (cpu: Cpu.t) (mem: Memory.map) = +let rec run (cpu: Cpu.t) (mem: Memory.map) (screen: Screen.t) = Cpu.run cpu mem; - run cpu mem + run cpu mem screen (** Power up sequence http://bgb.bircd.org/pandocs.htm#powerupsequence *) @@ -16,7 +16,12 @@ let power_up cartridge = let cpu = Cpu.init_cpu in let mem = Memory.init cartridge in - run cpu mem + let screen = Screen.init in + + Graphics.open_graph ""; + Graphics.resize_window Screen.width Screen.height; + + run cpu mem screen let () = diff --git a/src/screen.ml b/src/screen.ml index 43005a6..8f29776 100644 --- a/src/screen.ml +++ b/src/screen.ml @@ -1,14 +1,15 @@ +let width = 160 +let height = 144 + type pixel = { - r : char; - g : char; - b : char; - a : char; + r : int; + g : int; + b : int; + a : int; } type t = { - width : int; - height : int; - data : pixel array; + data : pixel array array; } type control = { @@ -45,11 +46,9 @@ let get_lcd_control mem = bg_display; } -let init_screen w h = +let init = { - width = w; - height = h; - data = Array.make_matrix h w { r = 255; g = 255; b = 255; a = 255 } + data = Array.make_matrix width height { r = 255; g = 255; b = 255; a = 255 } }