2021-08-02 23:40:31 +00:00
|
|
|
(local Ssc (require :ssc))
|
2021-09-02 02:59:55 +00:00
|
|
|
(local files (require :game.files))
|
|
|
|
(local {: pal} (require :editor.tiledraw.iigs))
|
2021-08-02 23:40:31 +00:00
|
|
|
(import-macros {:sss ! : compile} :ssc.macros)
|
|
|
|
|
2021-08-20 03:51:12 +00:00
|
|
|
(local ssc (Ssc))
|
2021-08-02 23:40:31 +00:00
|
|
|
(compile ssc
|
2021-08-20 03:51:12 +00:00
|
|
|
(require ssc.iigs.bootstub)
|
|
|
|
(require ssc.iigs.toolbox)
|
2021-09-11 02:55:47 +00:00
|
|
|
(require ssc.iigs.graphics)
|
2021-08-06 01:30:08 +00:00
|
|
|
|
2021-08-16 02:40:47 +00:00
|
|
|
(tooltable toolsets
|
|
|
|
ToolsetIntegerMath 0x0100
|
|
|
|
ToolsetText 0x0100
|
|
|
|
ToolsetQuickDraw 0x0100
|
|
|
|
ToolsetEventManager 0x0100
|
|
|
|
5 0x0100 ; desk manager
|
|
|
|
9 0x0100) ; ADB
|
|
|
|
|
2021-08-09 01:58:49 +00:00
|
|
|
(asm pascalhex (db 5) hexbuf (bytes " "))
|
2021-08-10 04:33:54 +00:00
|
|
|
|
2021-08-06 01:30:08 +00:00
|
|
|
(fn printnum (num)
|
2021-08-09 18:43:24 +00:00
|
|
|
(long! (ref hexbuf) (HexIt num))
|
|
|
|
(WriteString (far-ref pascalhex)))
|
2021-08-06 01:30:08 +00:00
|
|
|
|
2021-08-16 02:40:47 +00:00
|
|
|
(asm event-buffer)
|
|
|
|
(global word event-what)
|
|
|
|
(global long event-msg)
|
|
|
|
(global long event-when)
|
|
|
|
(global word event-y)
|
|
|
|
(global word event-x)
|
|
|
|
(global word event-mod)
|
|
|
|
|
|
|
|
(fn wait-for-key ()
|
|
|
|
(FlushEvents keyDownMask 0)
|
2021-08-20 03:51:12 +00:00
|
|
|
(while (not (GetNextEvent keyDownMask (far-ref event-buffer)))
|
|
|
|
(yield)))
|
2021-08-16 02:40:47 +00:00
|
|
|
|
|
|
|
(const screen-addr 0xe12000)
|
2021-08-15 00:52:43 +00:00
|
|
|
(const screen-size 0x9d00)
|
|
|
|
|
2021-09-12 04:18:21 +00:00
|
|
|
(compile-sprite tile0 [(. files.game.tiles 1 :gfx)] 16 16)
|
|
|
|
(compile-sprite tile1 [(. files.game.tiles 2 :gfx)] 16 16)
|
|
|
|
(compile-sprite tile2 [(. files.game.tiles 3 :gfx)] 16 16)
|
|
|
|
(compile-sprite tile3 [(. files.game.tiles 4 :gfx)] 16 16)
|
|
|
|
(asm tiles (jmp tile0) (nop) (jmp tile1) (nop) (jmp tile2) (nop) (jmp :tile3) (nop))
|
2021-09-02 02:59:55 +00:00
|
|
|
|
|
|
|
(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))))])
|
|
|
|
|
2021-08-16 02:40:47 +00:00
|
|
|
(global word userID)
|
2021-08-20 03:51:12 +00:00
|
|
|
|
|
|
|
(fn print-numbers-forever ()
|
|
|
|
(let (i 0) (while true
|
|
|
|
(printnum i)
|
|
|
|
(yield)
|
|
|
|
(set! i (+ i 1)))))
|
|
|
|
|
2021-09-11 02:55:47 +00:00
|
|
|
(form itile-to-tile [(fn [ssc itile]
|
2021-09-12 04:18:21 +00:00
|
|
|
[:block (ssc:expr-word itile) [:asl] [:asl] [:clc] [:adc #($1:lookup-addr :tiles)]])])
|
2021-09-11 02:55:47 +00:00
|
|
|
|
|
|
|
(fn enable-shadowing () (set! (word-at (ref :0xc035)) (& (word-at (ref :0xc035)) 0xfff1)))
|
|
|
|
(fn disable-shadowing () (set! (word-at (ref :0xc035)) (| (word-at (ref :0xc035)) 0x000e)))
|
|
|
|
|
|
|
|
(global word with-shadowing 0)
|
2021-09-07 03:23:45 +00:00
|
|
|
|
|
|
|
(fn draw-test-tiles (i)
|
2021-09-11 02:55:47 +00:00
|
|
|
(when with-shadowing (disable-shadowing))
|
2021-09-06 04:19:22 +00:00
|
|
|
(let (x 0 y 0 screen 0x2000)
|
2021-09-06 03:29:16 +00:00
|
|
|
(while (< y 12)
|
2021-09-12 04:18:21 +00:00
|
|
|
(draw-object screen (itile-to-tile (& (+ x y i) 3)))
|
2021-09-06 03:29:16 +00:00
|
|
|
(set! x (+ x 1))
|
|
|
|
(if (= x 20)
|
|
|
|
(do (set! x 0)
|
|
|
|
(set! y (+ y 1))
|
|
|
|
(set! screen (+ screen [(+ 8 (* 160 15))])))
|
2021-09-11 02:55:47 +00:00
|
|
|
(set! screen (+ screen 8)))))
|
|
|
|
(when with-shadowing
|
|
|
|
(enable-shadowing)
|
|
|
|
(if (= with-shadowing 1)
|
|
|
|
(let (x 0 y 0 screen 0x2000)
|
|
|
|
(while (< y 12)
|
2021-09-12 04:18:21 +00:00
|
|
|
(draw-object screen pei-slam-tile)
|
2021-09-11 02:55:47 +00:00
|
|
|
(set! x (+ x 1))
|
|
|
|
(if (= x 20)
|
|
|
|
(do (set! x 0)
|
|
|
|
(set! y (+ y 1))
|
|
|
|
(set! screen (+ screen [(+ 8 (* 160 15))])))
|
|
|
|
(set! screen (+ screen 8)))))
|
2021-09-12 04:18:21 +00:00
|
|
|
(let (screen 0x2000 y 0)
|
2021-09-11 02:55:47 +00:00
|
|
|
(while (< y 200)
|
|
|
|
(draw-object screen pei-slam-scanline)
|
2021-09-12 04:18:21 +00:00
|
|
|
(set! screen (+ screen 160))
|
2021-09-11 02:55:47 +00:00
|
|
|
(set! y (+ y 1)))))))
|
2021-09-06 03:29:16 +00:00
|
|
|
|
2021-09-07 03:23:45 +00:00
|
|
|
(fn draw-test-tiles-forever ()
|
|
|
|
(let (i 0)
|
|
|
|
(while true
|
|
|
|
(draw-test-tiles i)
|
|
|
|
(yield)
|
|
|
|
(set! i (+ i 1)))))
|
|
|
|
|
2021-08-02 23:40:31 +00:00
|
|
|
(fn main ()
|
2021-08-16 02:40:47 +00:00
|
|
|
(LoadTools (far-ref toolsets))
|
|
|
|
(set! userID (MMStartUp))
|
2021-08-10 17:23:09 +00:00
|
|
|
(IMStartUp)
|
|
|
|
(TextStartUp)
|
2021-08-16 02:40:47 +00:00
|
|
|
(QDStartUp 0x2100 0 0 userID)
|
|
|
|
(EMStartUp 0x2000 0 0 320 0 200 userID)
|
2021-09-02 02:59:55 +00:00
|
|
|
(GrafOn)
|
2021-09-06 04:19:22 +00:00
|
|
|
(ClearScreen 0)
|
2021-09-02 02:59:55 +00:00
|
|
|
(set-palette 0 [pal])
|
|
|
|
(SetAllSCBs 0)
|
2021-09-06 03:29:16 +00:00
|
|
|
|
2021-09-06 04:19:22 +00:00
|
|
|
(wait-for-key)
|
2021-09-11 02:55:47 +00:00
|
|
|
(enable-shadowing)
|
2021-09-07 03:23:45 +00:00
|
|
|
(let (tile-task (new-task (ref draw-test-tiles-forever)))
|
|
|
|
(wait-for-key)
|
2021-09-11 02:55:47 +00:00
|
|
|
(set! with-shadowing 1)
|
|
|
|
(wait-for-key)
|
|
|
|
(set! with-shadowing 2)
|
2021-09-07 03:23:45 +00:00
|
|
|
(wait-for-key)
|
2021-09-11 02:55:47 +00:00
|
|
|
(set! with-shadowing false)
|
2021-09-07 03:23:45 +00:00
|
|
|
(reset-task tile-task (ref yield-forever)))
|
2021-08-20 03:51:12 +00:00
|
|
|
|
2021-09-02 02:59:55 +00:00
|
|
|
(GrafOff)
|
2021-08-13 02:06:31 +00:00
|
|
|
|
2021-08-16 02:40:47 +00:00
|
|
|
(EMShutDown)
|
|
|
|
(QDShutDown)
|
2021-08-10 17:23:09 +00:00
|
|
|
(TextShutDown)
|
|
|
|
(IMShutDown)
|
2021-08-16 02:40:47 +00:00
|
|
|
(MMShutDown userID)))
|
2021-08-02 23:40:31 +00:00
|
|
|
|
|
|
|
(ssc:assemble)
|