Mercurial > vba-clojure
view clojure/com/aurellem/run/ram_display.clj @ 545:2b6cdea9bcdb
audio now syncs properly, but moves no longer sync with main display.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 27 Jun 2012 13:41:01 -0500 |
parents | 5596cd4a3fc6 |
children |
line wrap: on
line source
1 (ns com.aurellem.run.ram-display2 (:use (com.aurellem.gb saves gb-driver util constants3 items vbm characters money4 rlm-assembly))5 (:use (com.aurellem.run image util music title save-corruption6 bootstrap-0 bootstrap-1))7 (:require clojure.string)8 (:import [com.aurellem.gb.gb_driver SaveState])10 (:import java.awt.image.BufferedImage)11 (:import java.io.File))13 (defn accurate-memory-range14 ([^SaveState state start end]15 (map accurate-memory (range start end)))16 ([start end]17 (accurate-memory-range @current-state start end)))19 (def video-ram-start 0x8000)21 (def GB-memory-end 0x10000)23 (defn ram-image24 ([^SaveState state]25 (let [width 12826 height 25627 image (BufferedImage. width height28 BufferedImage/TYPE_INT_RGB)29 data (vec30 (accurate-memory-range31 state video-ram-start GB-memory-end))]32 (dorun33 (map34 (fn [index]35 (let [gray (data index)]36 (.setRGB image (rem index width)37 (int (/ index width))38 (+39 (bit-shift-left gray 16)40 (bit-shift-left gray 8)41 gray))))42 (range (count data))))43 image))44 ([] (ram-image @current-state)))46 (defn write-ram-image!47 ([^SaveState state ^File target]48 (write-image! (ram-image state) target))49 ([^File target]50 (write-ram-image! @current-state target)))52 (def test-ram-image53 (File. "/home/r/proj/vba-clojure/images/RAM-test.png"))