1
0

gfxtest4.l 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. (def fb (mmap "/framebuffer"))
  2. (def f (open "/framebuffer"))
  3. (def draw-bg (fn c (do
  4. (let c (+ 1 c))
  5. (let b 1080)
  6. (while b
  7. (do
  8. (let b (- b 1))
  9. (let a 1920)
  10. (while a (do
  11. (let a (- a 1))
  12. (put32 fb (+ (* a 4) (* b 7680)) (* 0x1000 (* a (+ c b))))
  13. ))))
  14. )))
  15. (def mario [00000000 00000000 00000000 0000f000 0000f000 0000f000 0000f000 0000f000 00000000 00000000 00000000 00000000
  16. 00000000 00000000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 0000f000 00000000
  17. 00000000 00000000 00008800 00008800 00008800 0000ff00 0000ff00 00008800 0000ff00 00000000 00000000 00000000
  18. 00000000 00008800 0000ff00 00008800 0000ff00 0000ff00 0000ff00 00008800 0000ff00 0000ff00 0000ff00 00000000
  19. 00000000 00008800 0000ff00 00008800 00008800 0000ff00 0000ff00 0000ff00 00008800 0000ff00 0000ff00 0000ff00
  20. 00000000 00008800 00008800 0000ff00 0000ff00 0000ff00 0000ff00 00008800 00008800 00008800 00008800 00000000
  21. 00000000 00000000 00000000 0000ff00 0000ff00 0000ff00 0000ff00 0000ff00 0000ff00 0000ff00 00000000 00000000
  22. 00000000 00000000 0000f000 0000f000 00f00000 0000f000 0000f000 0000f000 0000f000 00000000 00000000 00000000
  23. 00000000 0000f000 0000f000 0000f000 00f00000 0000f000 0000f000 00f00000 0000f000 0000f000 0000f000 00000000
  24. 0000f000 0000f000 0000f000 0000f000 00f00000 0000f000 00f00000 0000f000 0000f000 0000f000 0000f000 0000f000
  25. 00ffff00 00ffff00 0000f000 00f00000 0000ff00 00f00000 00f00000 0000ff00 00f00000 0000f000 00ffff00 00ffff00
  26. 00ffff00 00ffff00 00ffff00 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00ffff00 00ffff00 00ffff00
  27. 00ffff00 00ffff00 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00f00000 00ffff00 00ffff00
  28. 00000000 00000000 00f00000 00f00000 00f00000 00000000 00000000 00f00000 00f00000 00f00000 00000000 00000000
  29. 00000000 00008800 00008800 00008800 00000000 00000000 00000000 00000000 00008800 00008800 00008800 00000000
  30. 00008800 00008800 00008800 00008800 00000000 00000000 00000000 00000000 00008800 00008800 00008800 00008800
  31. ])
  32. (def clear [00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  33. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  34. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  35. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  36. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  37. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  38. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  39. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  40. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  41. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  42. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  43. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  44. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  45. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  46. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  47. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000])
  48. (def sprite mario)
  49. (def sprite-w 12)
  50. (def sprite-h 16)
  51. (def line (fn x y sy (do
  52. (let x1 (* 4 x))
  53. (let x2 (- (* 4 (+ x sprite-w)) 4))
  54. (let ofs (* y 7680))
  55. (let x3 (* sy 48))
  56. (while (lt x1 x2) (do
  57. (let color (get32 sprite x3))
  58. (put32 fb (+ ofs x1) color)
  59. (let x1 (+ x1 4))
  60. (let x3 (+ x3 4))
  61. )) )))
  62. (def blit (fn x y (do
  63. (let y1 y)
  64. (let y2 (+ y sprite-h))
  65. (let sy 0)
  66. (while (lt y1 y2) (do
  67. (line x y1 sy)
  68. (let y1 (+ y1 1))
  69. (let sy (+ sy 1)) ))
  70. )))
  71. (def main (fn (while 1 (do
  72. (let offset-x 500)
  73. (let offset-y 500)
  74. (let dx 1)
  75. (let dy 1)
  76. (let tick 0)
  77. (while 1 (do
  78. (def sprite clear)
  79. (blit offset-x offset-y)
  80. (let offset-x (+ offset-x dx))
  81. (let offset-y (+ offset-y dy))
  82. (if (gt offset-x 1800) (let dx -1) 0)
  83. (if (gt offset-y 900) (let dy -1) 0)
  84. (if (lt offset-x 100) (let dx 1) 0)
  85. (if (lt offset-y 100) (let dy 1) 0)
  86. ; draw marios
  87. (def sprite mario)
  88. (blit (+ offset-x 0) (+ offset-y 0))
  89. ; collect garbage
  90. (let tick (+ tick 1))
  91. (send f 0)
  92. (if (gt tick 100) (do
  93. (gc)
  94. (let tick 0)
  95. (print "gc!")) 0)
  96. ))
  97. ))))
  98. (main)