Add graphics window

This commit is contained in:
Fabien Freling 2015-08-11 23:06:32 +02:00
parent 54def17c26
commit fb5eeed6ba
2 changed files with 18 additions and 14 deletions

View file

@ -1,8 +1,8 @@
open Printf 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; Cpu.run cpu mem;
run cpu mem run cpu mem screen
(** Power up sequence (** Power up sequence
http://bgb.bircd.org/pandocs.htm#powerupsequence *) http://bgb.bircd.org/pandocs.htm#powerupsequence *)
@ -16,7 +16,12 @@ let power_up cartridge =
let cpu = Cpu.init_cpu in let cpu = Cpu.init_cpu in
let mem = Memory.init cartridge 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 () = let () =

View file

@ -1,14 +1,15 @@
let width = 160
let height = 144
type pixel = { type pixel = {
r : char; r : int;
g : char; g : int;
b : char; b : int;
a : char; a : int;
} }
type t = { type t = {
width : int; data : pixel array array;
height : int;
data : pixel array;
} }
type control = { type control = {
@ -45,11 +46,9 @@ let get_lcd_control mem =
bg_display; bg_display;
} }
let init_screen w h = let init =
{ {
width = w; data = Array.make_matrix width height { r = 255; g = 255; b = 255; a = 255 }
height = h;
data = Array.make_matrix h w { r = 255; g = 255; b = 255; a = 255 }
} }