123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- (def fb (mmap "/framebuffer"))
- (def f (open "/framebuffer"))
- (def draw-bg (fn c (do
- (let c (+ 1 c))
- (let b 1080)
- (while b
- (do
- (let b (- b 1))
- (let a 1920)
- (while a (do
- (let a (- a 1))
- (put32 fb (+ (* a 4) (* b 7680)) (* 0x1000 (* a (+ c b))))
- ))))
- )))
- (def mario [00000000 00000000 00000000 0000f000 0000f000 0000f000 0000f000 0000f000 00000000 00000000 00000000 00000000
- 00000000 00000000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 00000000
- 00000000 00000000 00008800 00008800 00008800 0000ff00 0000ff00 00008800 0000ff00 00000000 00000000 00000000
- 00000000 00008800 0000ff00 00008800 0000ff00 0000ff00 0000ff00 00008800 0000ff00 0000ff00 0000ff00 00000000
- 00000000 00008800 0000ff00 00008800 00008800 0000ff00 0000ff00 0000ff00 00008800 0000ff00 0000ff00 0000ff00
- 00000000 00008800 00008800 0000ff00 0000ff00 0000ff00 0000ff00 00008800 00008800 00008800 00008800 00000000
- 00000000 00000000 00000000 0000ff00 0000ff00 0000ff00 0000ff00 0000ff00 0000ff00 0000ff00 00000000 00000000
- 00000000 00000000 0000f000 0000f000 00f00000 0000f000 0000f000 0000f000 0000f000 00000000 00000000 00000000
- 00000000 0000f000 0000f000 0000f000 00f00000 0000f000 0000f000 00f00000 0000f000 0000f000 0000f000 00000000
- 0000f000 0000f000 0000f000 0000f000 00f00000 0000f000 00f00000 0000f000 0000f000 0000f000 0000f000 0000f000
- 00ffff00 00ffff00 0000f000 00f00000 0000ff00 00f00000 00f00000 0000ff00 00f00000 0000f000 00ffff00 00ffff00
- 00ffff00 00ffff00 00ffff00 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00ffff00 00ffff00 00ffff00
- 00ffff00 00ffff00 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00ffff00 00ffff00
- 00000000 00000000 00f00000 00f00000 00f00000 00000000 00000000 00f00000 00f00000 00f00000 00000000 00000000
- 00000000 00008800 00008800 00008800 00000000 00000000 00000000 00000000 00008800 00008800 00008800 00000000
- 00008800 00008800 00008800 00008800 00000000 00000000 00000000 00000000 00008800 00008800 00008800 00008800
- ])
- (def clear [00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000])
- (def sprite mario)
-
- (def sprite-w 12)
- (def sprite-h 16)
- (def line (fn x y sy (do
- (let x1 (* 4 x))
- (let x2 (- (* 4 (+ x sprite-w)) 4))
- (let ofs (* y 7680))
- (let x3 (* sy 48))
- (while (lt x1 x2) (do
- (let color (get32 sprite x3))
- (put32 fb (+ ofs x1) color)
- (let x1 (+ x1 4))
- (let x3 (+ x3 4))
- )) )))
- (def blit (fn x y (do
- (let y1 y)
- (let y2 (+ y sprite-h))
- (let sy 0)
- (while (lt y1 y2) (do
- (line x y1 sy)
- (let y1 (+ y1 1))
- (let sy (+ sy 1)) ))
- )))
- (def main (fn (while 1 (do
- (let offset-x 500)
- (let offset-y 500)
- (let dx 1)
- (let dy 1)
- (let tick 0)
- (while 1 (do
- (def sprite clear)
- (blit offset-x offset-y)
-
- (let offset-x (+ offset-x dx))
- (let offset-y (+ offset-y dy))
- (if (gt offset-x 1800) (let dx -1) 0)
- (if (gt offset-y 900) (let dy -1) 0)
- (if (lt offset-x 100) (let dx 1) 0)
- (if (lt offset-y 100) (let dy 1) 0)
- ; draw marios
- (def sprite mario)
- (blit (+ offset-x 0) (+ offset-y 0))
- ; collect garbage
- (let tick (+ tick 1))
- (send f 0)
- (if (gt tick 100) (do
- (gc)
- (let tick 0)
- (print "gc!")) 0)
- ))
- ))))
- (main)
|