gfxtest2.l 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 (+ a (* b 3840))) (* 0x1000 (* a (+ c b))))
  13. ))))
  14. )))
  15. (def sprite [0000 0000 0000 00f0 00f0 00f0 00f0 00f0 0000 0000 0000 0000
  16. 0000 0000 00f0 00f0 00f0 00f0 00f0 00f0 00f0 00f0 00f0 0000
  17. 0000 0000 0088 0088 0088 00ff 00ff 0088 00ff 0000 0000 0000
  18. 0000 0088 00ff 0088 00ff 00ff 00ff 0088 00ff 00ff 00ff 0000
  19. 0000 0088 00ff 0088 0088 00ff 00ff 00ff 0088 00ff 00ff 00ff
  20. 0000 0088 0088 00ff 00ff 00ff 00ff 0088 0088 0088 0088 0000
  21. 0000 0000 0000 00ff 00ff 00ff 00ff 00ff 00ff 00ff 0000 0000
  22. 0000 0000 00f0 00f0 f000 00f0 00f0 00f0 00f0 0000 0000 0000
  23. 0000 00f0 00f0 00f0 f000 00f0 00f0 f000 00f0 00f0 00f0 0000
  24. 00f0 00f0 00f0 00f0 f000 f000 f000 f000 00f0 00f0 00f0 00f0
  25. ffff ffff 00f0 f000 00ff f000 f000 00ff f000 00f0 ffff ffff
  26. ffff ffff ffff f000 f000 f000 f000 f000 f000 ffff ffff ffff
  27. ffff ffff f000 f000 f000 f000 f000 f000 f000 f000 ffff ffff
  28. 0000 0000 f000 f000 f000 0000 0000 f000 f000 f000 0000 0000
  29. 0000 0088 0088 0088 0000 0000 0000 0000 0088 0088 0088 0000
  30. 0088 0088 0088 0088 0000 0000 0000 0000 0088 0088 0088 0088
  31. ])
  32. (def sprite-w 12)
  33. (def sprite-h 16)
  34. (def line (fn x y sy (do
  35. (let x1 (* 2 x))
  36. (let x2 (- (* 2 (+ x sprite-w)) 2))
  37. (let ofs (* y 3840))
  38. (let x3 (* sy 24))
  39. (while (lt x1 x2) (do
  40. (let color (get32 sprite x3))
  41. (put32 fb (+ ofs x1) color)
  42. (let x1 (+ x1 2))
  43. (let x3 (+ x3 2))
  44. )) )))
  45. (def blit (fn x y (do
  46. (let y1 y)
  47. (let y2 (+ y sprite-h))
  48. (let sy 0)
  49. (while (lt y1 y2) (do
  50. (line x y1 sy)
  51. (let y1 (+ y1 1))
  52. (let sy (+ sy 1)) ))
  53. )))
  54. (def main (fn (while 1 (do
  55. (draw-bg 0)
  56. (let offset-x 500)
  57. (let offset-y 500)
  58. (let dx 1)
  59. (let dy 1)
  60. (let tick 0)
  61. (while 1 (do
  62. (let offset-x (+ offset-x dx))
  63. (let offset-y (+ offset-y dy))
  64. (if (gt offset-x 1800) (let dx -1) 0)
  65. (if (gt offset-y 900) (let dy -1) 0)
  66. (if (lt offset-x 100) (let dx 1) 0)
  67. (if (lt offset-y 100) (let dy 1) 0)
  68. ; draw marios
  69. (let x 0)
  70. (let y 0)
  71. (while (lt y 10) (do
  72. (let x 0)
  73. (while (lt x 10) (do
  74. (blit (+ offset-x (* x 8)) (+ offset-y (* y 8)))
  75. (let x (+ x 3))
  76. ))
  77. (let y (+ y 3))))
  78. ; collect garbage
  79. (let tick (+ tick 1))
  80. (if (gt tick 5) (do
  81. (gc)
  82. (let tick 0)
  83. (print "gc!")) 0)
  84. ))
  85. ))))
  86. (main)