Mercurial > vba-clojure
changeset 495:1d81ddd4fa41
merged changes from trip to wichita.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 11 Jun 2012 00:55:51 -0500 |
parents | 151c96d60921 (current diff) 79606f173658 (diff) |
children | a6d060a64246 |
files | clojure/com/aurellem/run/image.clj |
diffstat | 3 files changed, 108 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/items.clj Mon Jun 11 00:53:20 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/items.clj Mon Jun 11 00:55:51 2012 -0500 1.3 @@ -11,7 +11,6 @@ 1.4 (def pc-item-list-start 0xD539) 1.5 (def pc-item-list-width 101) 1.6 1.7 - 1.8 (defn item-list 1.9 ([^SaveState state] 1.10 (subvec 1.11 @@ -27,7 +26,6 @@ 1.12 (aget mem (+ item-list-start 2 (* 2 n)))])) 1.13 ([n] (nth-item @current-state n))) 1.14 1.15 - 1.16 (defn nth-pc-item 1.17 ([^SaveState state n] 1.18 (let [mem (memory state)] 1.19 @@ -35,7 +33,6 @@ 1.20 (aget mem (+ pc-item-list-start 2 (* 2 n)))])) 1.21 ([n] (nth-pc-item @current-state n))) 1.22 1.23 - 1.24 (def item-code->item-name 1.25 (hash-map 1.26 0x01 :master-ball
2.1 --- a/clojure/com/aurellem/run/image.clj Mon Jun 11 00:53:20 2012 -0500 2.2 +++ b/clojure/com/aurellem/run/image.clj Mon Jun 11 00:55:51 2012 -0500 2.3 @@ -2,7 +2,7 @@ 2.4 (:use (com.aurellem.gb saves gb-driver util constants 2.5 items vbm characters money 2.6 rlm-assembly)) 2.7 - (:use (com.aurellem.run util title save-corruption 2.8 + (:use (com.aurellem.run util music title save-corruption 2.9 bootstrap-0 bootstrap-1)) 2.10 (:require clojure.string) 2.11 (:import [com.aurellem.gb.gb_driver SaveState]) 2.12 @@ -43,5 +43,112 @@ 2.13 2.14 2.15 2.16 +(def image-program-target 0xB000) 2.17 2.18 +(def display-width 160) 2.19 +(def display-height 144) 2.20 2.21 + 2.22 + 2.23 +;{:r :g :b } 2.24 + 2.25 +(def character-data 0x8000) 2.26 +(def character-data-end 0x97FF) 2.27 + 2.28 + 2.29 + 2.30 + 2.31 +(def BG-data-1 0x9800) 2.32 + 2.33 +(def BG-data-2 0x9C00) 2.34 + 2.35 +(def OAM 0xFE00) 2.36 + 2.37 + 2.38 + 2.39 +(def video-bank-select-register 0xFF4F) 2.40 + 2.41 +(defn gb-rgb->bits [[r g b]] 2.42 + (assert (<= 0 r 31)) 2.43 + (assert (<= 0 g 31)) 2.44 + (assert (<= 0 b 31)) 2.45 + [(bit-and 2.46 + 0xFF 2.47 + (+ 2.48 + r 2.49 + (bit-shift-left g 5))) 2.50 + (+ 2.51 + (bit-shift-right g 3) 2.52 + (bit-shift-left b 2))]) 2.53 + 2.54 + 2.55 +(def bg-palette-select 0xFF68) 2.56 +(def bg-palette-data 0xFF69) 2.57 + 2.58 +(def obj-palette-select 0xFF6A) 2.59 +(def obj-palette-data 0xFF6B) 2.60 + 2.61 +(def max-palettes 8) 2.62 + 2.63 +(defn write-data [target data] 2.64 + (flatten 2.65 + [0x3E ;; load literal to A 2.66 + data 2.67 + 0xEA ;; load A into target 2.68 + (reverse (disect-bytes-2 target))])) 2.69 + 2.70 +(defn begin-sequential-palette-write 2.71 + [palette-num palette-select-address] 2.72 + (assert (<= 0 palette-num max-palettes)) 2.73 + (assert 2.74 + (or (= palette-select-address bg-palette-select) 2.75 + (= palette-select-address obj-palette-select))) 2.76 + (let [palette-write-data 2.77 + (Integer/parseInt 2.78 + (str "1" ;; auto increment 2.79 + "0" ;; not used 2.80 + (format 2.81 + "%03d" 2.82 + (Integer/parseInt 2.83 + (Integer/toBinaryString palette-num) 10)) 2.84 + "00" ;; color num 2.85 + "0" ;; H/L 2.86 + ) 2)] 2.87 + (write-data palette-select-address palette-write-data))) 2.88 + 2.89 +(defn set-palettes [palette-select palette-data palettes] 2.90 + (assert (<= (count palettes)) max-palettes) 2.91 + (flatten 2.92 + [(begin-sequential-palette-write 0 palette-select) 2.93 + (map (partial write-data palette-data) 2.94 + (flatten (map gb-rgb->bits palettes)))])) 2.95 + 2.96 +(defn display-one-color 2.97 + "Displayes a single color onto the gameboy screen. input rgb in 2.98 + gameboy rgb." 2.99 + [[r g b]] 2.100 + ;; construct a kernel that displays a single color 2.101 + (let 2.102 + [palettes (repeat 8 [r g b]) 2.103 + kernel-address 0xC000 2.104 + kernel 2.105 + [0xF3 ;; disable interrupts 2.106 + (clear-music-registers) 2.107 + (frame-metronome) 2.108 + (set-palettes obj-palette-select obj-palette-data palettes) 2.109 + (set-palettes bg-palette-select bg-palette-data palettes) 2.110 + (infinite-loop)]] 2.111 + (-> (set-memory-range (second (music-base)) 2.112 + kernel-address (flatten kernel)) 2.113 + (PC! kernel-address)))) 2.114 + 2.115 + 2.116 + 2.117 + 2.118 +(defn write-palette-color [palette-num r g b] 2.119 + (let [[byte-1 byte-2] (gb-rgb->bits r g b)] 2.120 + 2.121 + 2.122 + )) 2.123 + 2.124 +
3.1 Binary file moves/temp.vbm has changed