diff --git a/editor/tiledraw/iigs.fnl b/editor/tiledraw/iigs.fnl index 1b249ef..b92c1fc 100644 --- a/editor/tiledraw/iigs.fnl +++ b/editor/tiledraw/iigs.fnl @@ -12,7 +12,6 @@ (for [x 0 15 2] (let [ibyte (+ (* y 8) (math.floor (/ x 2)) 1) byte (string.byte (tile:sub ibyte ibyte)) - _ (print x y ibyte byte) left (bit.band (bit.rshift byte 4) 0xf) right (bit.band byte 0xf)] (putpixel x y (gs-to-rgb (. pal (+ left 1)))) diff --git a/game/files.fnl b/game/files.fnl index 1ea7994..53c52ee 100644 --- a/game/files.fnl +++ b/game/files.fnl @@ -60,7 +60,7 @@ (when ?filename (set files.filename ?filename)) (let [game {}] (each [k v (pairs files.game)] - (tset game k (lume.map v #(serialize k (clone $1) files.game)))) + (tset game k (if (= (type v) :table) (lume.map v #(serialize k (clone $1) files.game)) v))) (util.writejson (filename) game))) (fn new-cache [game key] @@ -71,7 +71,6 @@ :portraits tiledraw.portrait-to-sprite _ tiledraw.tile-to-sprite) gfx (. game key)] - (print gfx key) (tiledraw.TileCache gfx spritegen))) (fn files.cache [key] diff --git a/neutgs/game.json b/neutgs/game.json index 6242fa7..3b77c26 100644 --- a/neutgs/game.json +++ b/neutgs/game.json @@ -1 +1 @@ -{"platform": "iigs"} +{"platform":"iigs","tiles":[{"flags":[],"word":"","label":"","gfx":"FFFFFFFFFFFFFFFFFAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3F3333333F3333333FFFFFFFFFFFFFFFFFAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3F3333333F3333333"}]} \ No newline at end of file diff --git a/neutgs/init.fnl b/neutgs/init.fnl index de6fa8a..76c3012 100644 --- a/neutgs/init.fnl +++ b/neutgs/init.fnl @@ -1,4 +1,6 @@ (local Ssc (require :ssc)) +(local files (require :game.files)) +(local {: pal} (require :editor.tiledraw.iigs)) (import-macros {:sss ! : compile} :ssc.macros) (local ssc (Ssc)) @@ -20,8 +22,6 @@ (long! (ref hexbuf) (HexIt num)) (WriteString (far-ref pascalhex))) - (fn add (lhs rhs) (+ lhs rhs)) - (asm event-buffer) (global word event-what) (global long event-msg) @@ -38,11 +38,24 @@ (const screen-addr 0xe12000) (const screen-size 0x9d00) - (global word screen-offset 0) - (getter screen-cursor (+ screen-addr screen-offset)) - (setter screen-cursor (pixels) - (word! screen-cursor pixels) - (set! screen-offset (+ screen-offset 2))) + (asm tiles (bytes [(. files.game.tiles 1 :gfx)])) + + (form set-palette [(fn [ssc index pal] + (let [addr (+ 0xe19e00 (* index 0x20)) + writes (icollect [icolor [r g b] (ipairs pal)] + [[:lda (bit.bor (bit.lshift r 8) (bit.lshift g 4) b)] [:sta (tostring (+ addr (* icolor 2) -2))]])] + (lume.concat [:block] (table.unpack writes))))]) + + (fn draw-tile (tile (long addr)) + (let (y 0) + (while (< y 16) + (word! addr (word-at tile)) + (word! (+ addr 2) (word-at (+ tile 2))) + (word! (+ addr 4) (word-at (+ tile 4))) + (word! (+ addr 6) (word-at (+ tile 6))) + (set! addr (+ addr 160)) + (set! tile (+ tile 8)) + (set! y (+ y 1))))) (global word userID) @@ -59,13 +72,14 @@ (TextStartUp) (QDStartUp 0x2100 0 0 userID) (EMStartUp 0x2000 0 0 320 0 200 userID) -; (GrafOn) + (GrafOn) - (let (number-printer (new-task (ref print-numbers-forever))) - (wait-for-key) - (reset-task number-printer (ref yield-forever))) + (set-palette 0 [pal]) + (SetAllSCBs 0) + (draw-tile (ref tiles) screen-addr) + (wait-for-key) -; (GrafOff) + (GrafOff) (EMShutDown) (QDShutDown) diff --git a/ssc/init.fnl b/ssc/init.fnl index 019b035..01d87b9 100644 --- a/ssc/init.fnl +++ b/ssc/init.fnl @@ -160,13 +160,13 @@ pre (when ropgen.setup (ropgen.setup)) lopgen (self:expr-opgen lhs) left (when lopgen.setup (lopgen.setup)) - truebranch (if ropgen.cleanup (.. :-if-true-cleanup- depth) truelabel) - falsebranch (if ropgen.cleanup (.. :-if-false-cleanup- depth) falselabel) + truebranch (.. :-if-true-cleanup- depth) + falsebranch (.. :-if-false-cleanup- depth) hibranch (when lopgen.hi [(lopgen.hi :lda) (ropgen.hi :cmp) (cmp.hibranch truebranch falsebranch)]) lobranch [(lopgen.lo :lda) (ropgen.lo :cmp) (cmp.lobranch falsebranch)] - cleanup (when ropgen.cleanup (ropgen.cleanup)) - post (if cleanup [truebranch cleanup [:bra truelabel] falsebranch cleanup [:bra falselabel]] + cleanup (if ropgen.cleanup (ropgen.cleanup) [:flatten]) + post (if cleanup [truebranch cleanup [:brl truelabel] falsebranch cleanup [:brl falselabel]] ?branch-when-true [[:bra truelabel]])] (lume.concat [:block] [pre] [left] hibranch lobranch post)) @@ -243,7 +243,7 @@ :while (lambda [self test ...] (let [block [:block :-loop-top- (self:gen-condition test :-enter-loop- :-exit-loop-) :-enter-loop-] c-body (self:expr-poly [:do ...])] - (values (lume.concat block [c-body [:bra :-loop-top-] :-exit-loop-]) :void))) + (values (lume.concat block [c-body [:brl :-loop-top-] :-exit-loop-]) :void))) :+ (lambda [self first ...] (self:accumulation-op (fn [etype opgen]