Display maps from OCaml

This commit is contained in:
Fabien Freling 2019-07-05 14:20:17 +02:00
parent d4e753a6e1
commit 35ea1690fe
11 changed files with 121 additions and 10 deletions

View file

@ -2,3 +2,4 @@ let () =
Callback.register "oboy_name" Version.name;
Callback.register "oboy_version" Version.version;
Callback.register "oboy_load" State.load_cartridge;
Callback.register "oboy_bg_map" Memory.background_map;

View file

@ -3,6 +3,7 @@
; combine static pthread with dynamic libc
(executable
(name cbindings)
(libraries bigarray)
(modes object))
; Standalone binary

View file

@ -6,6 +6,7 @@
* LICENSE file at the top level directory of this source tree.
*)
open Bigarray
open Bytes
open Printf
@ -107,3 +108,13 @@ let update_timers mem cycles =
(* TODO: INT 50 - Timer interupt *)
end
end
let background_map () =
let bg_map = Array2.create Bigarray.int8_unsigned Bigarray.c_layout 8 8 in
Array2.fill bg_map 0;
for j = 0 to (Array2.dim2 bg_map) - 1 do
for i = 0 to (Array2.dim1 bg_map) - 1 do
bg_map.{i, j} <- (i + j * Array2.dim1 bg_map) mod 4
done
done;
bg_map