I'm drawing a tile!!

This commit is contained in:
Jeremy Penner 2021-09-01 22:59:55 -04:00
parent dc61bb08e0
commit f833e62d91
5 changed files with 33 additions and 21 deletions

View file

@ -12,7 +12,6 @@
(for [x 0 15 2] (for [x 0 15 2]
(let [ibyte (+ (* y 8) (math.floor (/ x 2)) 1) (let [ibyte (+ (* y 8) (math.floor (/ x 2)) 1)
byte (string.byte (tile:sub ibyte ibyte)) byte (string.byte (tile:sub ibyte ibyte))
_ (print x y ibyte byte)
left (bit.band (bit.rshift byte 4) 0xf) left (bit.band (bit.rshift byte 4) 0xf)
right (bit.band byte 0xf)] right (bit.band byte 0xf)]
(putpixel x y (gs-to-rgb (. pal (+ left 1)))) (putpixel x y (gs-to-rgb (. pal (+ left 1))))

View file

@ -60,7 +60,7 @@
(when ?filename (set files.filename ?filename)) (when ?filename (set files.filename ?filename))
(let [game {}] (let [game {}]
(each [k v (pairs files.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))) (util.writejson (filename) game)))
(fn new-cache [game key] (fn new-cache [game key]
@ -71,7 +71,6 @@
:portraits tiledraw.portrait-to-sprite :portraits tiledraw.portrait-to-sprite
_ tiledraw.tile-to-sprite) _ tiledraw.tile-to-sprite)
gfx (. game key)] gfx (. game key)]
(print gfx key)
(tiledraw.TileCache gfx spritegen))) (tiledraw.TileCache gfx spritegen)))
(fn files.cache [key] (fn files.cache [key]

View file

@ -1 +1 @@
{"platform": "iigs"} {"platform":"iigs","tiles":[{"flags":[],"word":"","label":"","gfx":"FFFFFFFFFFFFFFFFFAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3F3333333F3333333FFFFFFFFFFFFFFFFFAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3FAAAAAA3F3333333F3333333"}]}

View file

@ -1,4 +1,6 @@
(local Ssc (require :ssc)) (local Ssc (require :ssc))
(local files (require :game.files))
(local {: pal} (require :editor.tiledraw.iigs))
(import-macros {:sss ! : compile} :ssc.macros) (import-macros {:sss ! : compile} :ssc.macros)
(local ssc (Ssc)) (local ssc (Ssc))
@ -20,8 +22,6 @@
(long! (ref hexbuf) (HexIt num)) (long! (ref hexbuf) (HexIt num))
(WriteString (far-ref pascalhex))) (WriteString (far-ref pascalhex)))
(fn add (lhs rhs) (+ lhs rhs))
(asm event-buffer) (asm event-buffer)
(global word event-what) (global word event-what)
(global long event-msg) (global long event-msg)
@ -38,11 +38,24 @@
(const screen-addr 0xe12000) (const screen-addr 0xe12000)
(const screen-size 0x9d00) (const screen-size 0x9d00)
(global word screen-offset 0) (asm tiles (bytes [(. files.game.tiles 1 :gfx)]))
(getter screen-cursor (+ screen-addr screen-offset))
(setter screen-cursor (pixels) (form set-palette [(fn [ssc index pal]
(word! screen-cursor pixels) (let [addr (+ 0xe19e00 (* index 0x20))
(set! screen-offset (+ screen-offset 2))) 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) (global word userID)
@ -59,13 +72,14 @@
(TextStartUp) (TextStartUp)
(QDStartUp 0x2100 0 0 userID) (QDStartUp 0x2100 0 0 userID)
(EMStartUp 0x2000 0 0 320 0 200 userID) (EMStartUp 0x2000 0 0 320 0 200 userID)
; (GrafOn) (GrafOn)
(let (number-printer (new-task (ref print-numbers-forever))) (set-palette 0 [pal])
(SetAllSCBs 0)
(draw-tile (ref tiles) screen-addr)
(wait-for-key) (wait-for-key)
(reset-task number-printer (ref yield-forever)))
; (GrafOff) (GrafOff)
(EMShutDown) (EMShutDown)
(QDShutDown) (QDShutDown)

View file

@ -160,13 +160,13 @@
pre (when ropgen.setup (ropgen.setup)) pre (when ropgen.setup (ropgen.setup))
lopgen (self:expr-opgen lhs) lopgen (self:expr-opgen lhs)
left (when lopgen.setup (lopgen.setup)) left (when lopgen.setup (lopgen.setup))
truebranch (if ropgen.cleanup (.. :-if-true-cleanup- depth) truelabel) truebranch (.. :-if-true-cleanup- depth)
falsebranch (if ropgen.cleanup (.. :-if-false-cleanup- depth) falselabel) falsebranch (.. :-if-false-cleanup- depth)
hibranch (when lopgen.hi hibranch (when lopgen.hi
[(lopgen.hi :lda) (ropgen.hi :cmp) (cmp.hibranch truebranch falsebranch)]) [(lopgen.hi :lda) (ropgen.hi :cmp) (cmp.hibranch truebranch falsebranch)])
lobranch [(lopgen.lo :lda) (ropgen.lo :cmp) (cmp.lobranch falsebranch)] lobranch [(lopgen.lo :lda) (ropgen.lo :cmp) (cmp.lobranch falsebranch)]
cleanup (when ropgen.cleanup (ropgen.cleanup)) cleanup (if ropgen.cleanup (ropgen.cleanup) [:flatten])
post (if cleanup [truebranch cleanup [:bra truelabel] falsebranch cleanup [:bra falselabel]] post (if cleanup [truebranch cleanup [:brl truelabel] falsebranch cleanup [:brl falselabel]]
?branch-when-true [[:bra truelabel]])] ?branch-when-true [[:bra truelabel]])]
(lume.concat [:block] [pre] [left] hibranch lobranch post)) (lume.concat [:block] [pre] [left] hibranch lobranch post))
@ -243,7 +243,7 @@
:while (lambda [self test ...] :while (lambda [self test ...]
(let [block [:block :-loop-top- (self:gen-condition test :-enter-loop- :-exit-loop-) :-enter-loop-] (let [block [:block :-loop-top- (self:gen-condition test :-enter-loop- :-exit-loop-) :-enter-loop-]
c-body (self:expr-poly [:do ...])] 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 ...] :+ (lambda [self first ...]
(self:accumulation-op (self:accumulation-op
(fn [etype opgen] (fn [etype opgen]