Commit 644a1356 authored by Fabien Freling's avatar Fabien Freling

Add LCD control structure.

Also add the Bin module to easily deal with binary.
parent 52e5afa3
S src
B _build
B _build/src
let is_set num i =
if i < 0 then failwith "Invalid bit index."
(num lsr i) land 0b00000001 <> 0
......@@ -11,6 +11,40 @@ type t = {
data : pixel array;
}
type control = {
lcd_display_enable : bool;
tile_map_select : int;
window_display_enable : bool;
tile_data_select : int;
bg_tile_map_select : int;
sprite_size : int;
sprite_enable : bool;
bg_display : bool;
}
let get_lcd_control mem =
let b = Memory.get mem 0xFF40 |> int_of_char in
let lcd_display_enable = Bit.is_set b 7 in
let tile_map_select = if not (Bit.is_set b 6) then 0x9800 else 0x9c00 in
let window_display_enable = Bit.is_set b 5 in
let tile_data_select = if not (Bit.is_set b 4) then 0x8800 else 0x8000 in
let bg_tile_map_select = if not (Bit.is_set b 3) then 0x9800 else 0x9c00 in
let sprite_size = if not (Bit.is_set b 2) then 8 else 16 in
let sprite_enable = Bit.is_set b 1 in
let bg_display = Bit.is_set b 0 in
{
lcd_display_enable;
tile_map_select;
window_display_enable;
tile_data_select;
bg_tile_map_select;
sprite_size;
sprite_enable;
bg_display;
}
let init_screen w h =
{
width = w;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment