# HG changeset patch # User Robert McIntyre # Date 1346353871 18000 # Node ID 0901694725f03459bf0159765b2c6300a0800106 # Parent 9068685e7d96a1bc65845f3ca15c323f363c2a56 saving progress for the night. diff -r 9068685e7d96 -r 0901694725f0 clojure/com/aurellem/run/adv_choreo.clj --- a/clojure/com/aurellem/run/adv_choreo.clj Thu Aug 30 12:09:15 2012 -0500 +++ b/clojure/com/aurellem/run/adv_choreo.clj Thu Aug 30 14:11:11 2012 -0500 @@ -8,6 +8,8 @@ bootstrap-0 bootstrap-1 image ram-display final-cut basic-choreo)) (:require clojure.string) + (:import java.awt.image.BufferedImage) + (:import (javax.imageio ImageWriteParam IIOImage ImageIO)) (:import [com.aurellem.gb.gb_driver SaveState]) (:import java.io.File)) @@ -36,12 +38,6 @@ ;; Green font on black background for matrix look. - -;; [ ] get single long ram write. - - - - (defn program-data [base-address] (let [image-program (display-image-kernel @@ -77,13 +73,96 @@ + +(def glyphs + "The sixteen 8x8 glyphs which make up the \"terminal\" font." + (mapv #(ImageIO/read + (File. user-home (str "proj/vba-clojure/font/" % ".png"))) + ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"])) + +(defn glyphs-init-program + [start-address] + (let [zero-glyph (image->gb-image (glyphs 0)) + + ;; write same pallet information to all pallettes + A (flatten + [(write-byte LCD-control-register 0x00) + (set-palettes bg-palette-select bg-palette-data + (repeat 8 (first (:palettes zero-glyph)))) + (select-LCD-bank 0) + (write-byte SCX-register 0) + (write-byte SCY-register 0)]) + B (flatten + [(write-data + (+ start-address (count A)) + character-data-address + (flatten + (map (comp gb-tile->bytes first :tiles image->gb-image) + glyphs)))])] + (concat A B))) + + +(defn glyph-display-program + [start-address + delay-count + total-glyph-count] + (glyphs-init-program start-address) ;; ONLY for testing! + ) + + +(defn glyph-bootstrap-program + [start-address delay-count total-glyph-count] + (let [init [0xAF 0x4F 0x47] ;; 0->A; 0->C; 0->B + header (concat (frame-metronome) (read-user-input)) + + glyph-display (glyph-display-program + (+ (count init) (count header) + start-address) + 0 0) ;; ONLY FOR TESTING + + state-machine-start-address + (+ start-address (count init) (count header) (count glyph-display)) + state-machine + (bootstrap-state-machine state-machine-start-address) + + return-to-header + (flatten + [0x18 + (->signed-8-bit + (- (count init) + 2 ;; this command length + 3 ;; I have no idea why we need a 3 here + ;; need to investigate. + (count glyph-display) + (count header) + (count state-machine)))])] + + (concat init glyph-display header state-machine return-to-header))) + + + + (def main-program-base-address 0xC000) + + +;; RLM want to transfer control here --- this is where I left off. +(defn begin-glyph-bootstrap + ([] (begin-glyph-bootstrap (relocate-main-bootstrap))) + ([script] + (let [glyph-program (glyph-bootstrap-program + 0xDF00 0 0) + + + + + (defn write-all-program-data - ([] (write-all-program-data (silence-noise))) + ([] (write-all-program-data (relocate-main-bootstrap))) ([script] (let [base-address main-program-base-address] (->> script + (write-RAM 0xFF1A [0 0 0]) ;; silence remnant music (write-RAM base-address (program-data base-address)))))) (defn activate-program diff -r 9068685e7d96 -r 0901694725f0 font/0.png Binary file font/0.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/1.png Binary file font/1.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/2.png Binary file font/2.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/3.png Binary file font/3.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/4.png Binary file font/4.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/5.png Binary file font/5.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/6.png Binary file font/6.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/7.png Binary file font/7.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/8.png Binary file font/8.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/9.png Binary file font/9.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/A.png Binary file font/A.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/B.png Binary file font/B.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/C.png Binary file font/C.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/D.png Binary file font/D.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/E.png Binary file font/E.png has changed diff -r 9068685e7d96 -r 0901694725f0 font/F.png Binary file font/F.png has changed