bdash.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. -- title: bdash
  2. -- author: pixelbath
  3. -- desc: some dashing around game
  4. -- site: website link
  5. -- license: MIT License
  6. -- version: 0.1
  7. -- script: lua
  8. ticks=0
  9. x=96
  10. y=24
  11. function ui_update()
  12. local mx, my, lb = mouse()
  13. for k,v in pairs(obj.children) do
  14. end
  15. end
  16. function cb_btntest()
  17. trace("cleeeck")
  18. end
  19. function append_elem(obj, append_obj)
  20. table.insert(obj.children, append_obj)
  21. end
  22. -- this method swaps active palette entries
  23. function swap_palette(idx)
  24. local map_addr = 0x3ff0
  25. if idx == 0 then
  26. poke4(map_addr*2 + 12, 5)
  27. poke4(map_addr*2 + 14, 3)
  28. poke4(map_addr*2 + 15, 2)
  29. end
  30. end
  31. -- this method pokes new colors into the palette
  32. function direct_palette(idx)
  33. end
  34. function render_ui(obj, xs, ys)
  35. xs = xs or 0
  36. ys = ys or 0
  37. local objx, objy = obj.x + xs, obj.y + ys
  38. if obj.type == "container" then
  39. for k,v in pairs(obj.children) do
  40. render_ui(v, objx, objy)
  41. end
  42. end
  43. if obj.type == "btn" then
  44. rect(objx, objy, (#obj.text) * 4 + 1, 7, 2)
  45. print(obj.text, objx + 1, objy + 1, 4, 1, 1, 1)
  46. end
  47. end
  48. function create_ui_object(xpos, ypos, w, h)
  49. return {
  50. x = xpos or 0,
  51. y = ypos or 0,
  52. width = w or 240,
  53. height = h or 136,
  54. children = {},
  55. type = "container",
  56. }
  57. end
  58. function create_ui_btn(xpos, ypos, text, cb_func)
  59. local elem = create_ui_object(xpos or 0, ypos or 0)
  60. elem.text = text or "Button"
  61. elem.type = "btn"
  62. elem.cb = cb_func
  63. return elem
  64. end
  65. ui_container = create_ui_object()
  66. ui_btn = create_ui_btn(0, 0, "Click", cb_btntest)
  67. append_elem(ui_container, ui_btn)
  68. tiles = {
  69. impass = {
  70. editor = 76,
  71. sprites = { 2 },
  72. },
  73. wall = {
  74. editor = 77,
  75. sprites = { 4 },
  76. },
  77. exit = {
  78. editor = 95,
  79. sprites = { 2, 6 },
  80. },
  81. bush = {
  82. editor = 78,
  83. sprites = { 8 },
  84. },
  85. rock = {
  86. editor = 92,
  87. sprites = { 10 },
  88. },
  89. bfly = {
  90. editor = 108,
  91. sprites = { 64, 66, 68, 66 },
  92. },
  93. rock = {
  94. editor = 92,
  95. sprites = { 10 },
  96. },
  97. square = {
  98. editor = 93,
  99. sprites = { 96, 98, 100, 102 },
  100. },
  101. amoeba = {
  102. editor = 110,
  103. sprites = { 160, 162, 164, 162 },
  104. },
  105. diamond = {
  106. editor = 109,
  107. sprites = { 128, 130, 132, 134, 136, 138 },
  108. },
  109. }
  110. -- TODO: pick palette schemes - map drawing tool / palette tool
  111. -- TODO: mapping tool
  112. function draw_grid(clr)
  113. for gridx=8,240,8 do
  114. line(gridx, 0, gridx, 136, clr)
  115. end
  116. for gridy=8,136,8 do
  117. line(0, gridy, 240, gridy, clr)
  118. end
  119. local mx, my, lb = mouse()
  120. local gridmx, gridmy = (mx // 8) * 8, (my // 8) * 8
  121. rect(gridmx, gridmy, 8, 8, 2)
  122. end
  123. function set_pal(idx, clr)
  124. end
  125. function update_editor()
  126. --pix(mx, my, 5)
  127. -- draw editor
  128. end
  129. -- draws everything that has a .editor prop
  130. function draw_toolbox()
  131. local idx = 0
  132. for k,v in pairs(tiles) do
  133. trace(v)
  134. if v.editor ~= nil then
  135. spr(v.editor, idx * 8, 10)
  136. idx = idx + 1
  137. end
  138. end
  139. end
  140. function draw_map()
  141. map(0, 0)
  142. end
  143. swap_palette(0)
  144. function TIC()
  145. -- update_editor()
  146. if btn(0) then y=y-1 end
  147. if btn(1) then y=y+1 end
  148. if btn(2) then x=x-1 end
  149. if btn(3) then x=x+1 end
  150. cls(0)
  151. -- render_ui(ui_container)
  152. draw_map()
  153. -- draw_grid(1)
  154. -- draw_toolbox()
  155. end
  156. -- <TILES>
  157. -- 002:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  158. -- 003:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  159. -- 004:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  160. -- 005:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  161. -- 006:dddddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000
  162. -- 007:dddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000dd
  163. -- 008:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
  164. -- 009:00ee00eeee0000ee0feeef00eeee00eeee00eeeeefffee00ff00eeeeeeeeff00
  165. -- 010:0000cccc00cc00cccceecc00ffccee0effffffeeffeeffffffffeeeeffffffff
  166. -- 011:cc000000eecc0000cccccc00eeccccc0eeecccccffee00ccffffccccfffeffcc
  167. -- 018:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  168. -- 019:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  169. -- 020:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  170. -- 021:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  171. -- 022:dd000000dd000000dd000000dd000000dd000000dd000000dddddddddddddddd
  172. -- 023:000000dd000000dd000000dd000000dd000000dd000000dddddddddddddddddd
  173. -- 024:00eeeeeeeeef00feeeffee0000feeeefee00ef00eeee0000eef0eeff00ee0000
  174. -- 025:ffeeeeeeeeeeef00ffee00ee00efffeeee00eef0eeee0fee00eef000ee00ee00
  175. -- 026:ff00fffffff000ffff000fffffff000f0fffff0000ffffff0000ff00000000ff
  176. -- 027:ffffffeeffeefffefffffffffffffff0fffffff0ffffff00eeff0000ff000000
  177. -- 032:000000000000d0000000dddd000ddccd00dddc4d0000dddd000000ee00000ddd
  178. -- 033:00000000000d0000dddd0000dccdd000d4cddd00dddd0000ee000000ddd00000
  179. -- 048:0000d0cc0000d0ee0000c0cc000000ee00000fff0000ff000000ff0000dccc00
  180. -- 049:cc0d0000ee0d0000cc0c0000ee000000fff0000000ff000000ff000000cccd00
  181. -- 064:c0000000ee000000ccc00000ccee0000eeeec0000fffee00000000cc000000ee
  182. -- 065:0000000e000000ff00000ecc0000ffcc000eeeee00fffff0ee000000ff000000
  183. -- 066:000c0000000e0000000cc000000cee00000eeec00000ffe00000000c0000000e
  184. -- 067:0000e0000000f000000ec00000ffc0000eeee0000fff0000e0000000f0000000
  185. -- 068:00000c0000000e0000000cc000000ce000000ee0000000f00000000c0000000e
  186. -- 069:00e0000000f0000000c000000fc000000ee000000f000000e0000000f0000000
  187. -- 076:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  188. -- 077:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  189. -- 078:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
  190. -- 080:0fffffcceeeeeeeecccccc00cccce000eecc0000ffe00000ee000000f0000000
  191. -- 081:eefffff0ffeeeeee00eecccc000fcccc0000eeee00000fff000000ff0000000f
  192. -- 082:0000fffc000eeeee000cccc0000ccce0000ecc00000fee00000ee000000f0000
  193. -- 083:efff0000feeee0000eecc00000fcc000000ee000000ff0000000f0000000f000
  194. -- 084:000000fc00000eee00000cc000000cc000000ec000000fe000000e0000000f00
  195. -- 085:ef000000fee00000eec000000fc0000000e0000000f0000000f0000000f00000
  196. -- 092:000cec000ce0ecc0fefffe0cfffffffcff0ffeffff00ffff0ffffff0000ff000
  197. -- 093:eeeeeeeeecccccceeceeeeceeceffeceeceffeceeceeeeceecccccceeeeeeeee
  198. -- 094:00000000000000000000dd00000d00000000d00000000d00000dd00000000000
  199. -- 095:0000000000000000000ddd00000d0000000dd000000d0000000ddd0000000000
  200. -- 096:cccccccccccccccccceeeeeecceeeeeecceeffffcceeffffcceeffeecceeffee
  201. -- 097:cccccccccccccccceeeeeecceeeeeeccffffeeccffffeecceeffeecceeffeecc
  202. -- 098:eeeeeeeeeeeeeeeeeeffffffeeffffffeeffeeeeeeffeeeeeeffeecceeffeecc
  203. -- 099:eeeeeeeeeeeeeeeeffffffeeffffffeeeeeeffeeeeeeffeecceeffeecceeffee
  204. -- 100:ffffffffffffffffffeeeeeeffeeeeeeffeeccccffeeccccffeecceeffeeccee
  205. -- 101:ffffffffffffffffeeeeeeffeeeeeeffcccceeffcccceeffeecceeffeecceeff
  206. -- 102:eeeeeeeeeeeeeeeeeecccccceecccccceecceeeeeecceeeeeecceeffeecceeff
  207. -- 103:eeeeeeeeeeeeeeeecccccceecccccceeeeeecceeeeeecceeffeecceeffeeccee
  208. -- 108:e000000fce0000fcffe00ffffffeffffeeeefeeecce000ccfe0000fff000000f
  209. -- 109:000dc00000dccc000deeeec0dffffffceffffffc0edeeed000edcd00000ee000
  210. -- 110:ccceeccceccccccefeccccefecccccceccccccccccccccccccceeccccceffecc
  211. -- 112:cceeffeecceeffeecceeffffcceeffffcceeeeeecceeeeeecccccccccccccccc
  212. -- 113:eeffeecceeffeeccffffeeccffffeecceeeeeecceeeeeecccccccccccccccccc
  213. -- 114:eeffeecceeffeecceeffeeeeeeffeeeeeeffffffeeffffffeeeeeeeeeeeeeeee
  214. -- 115:cceeffeecceeffeeeeeeffeeeeeeffeeffffffeeffffffeeeeeeeeeeeeeeeeee
  215. -- 116:ffeecceeffeecceeffeeccccffeeccccffeeeeeeffeeeeeeffffffffffffffff
  216. -- 117:eecceeffeecceeffcccceeffcccceeffeeeeeeffeeeeeeffffffffffffffffff
  217. -- 118:eecceeffeecceeffeecceeeeeecceeeeeecccccceecccccceeeeeeeeeeeeeeee
  218. -- 119:ffeecceeffeecceeeeeecceeeeeecceecccccceecccccceeeeeeeeeeeeeeeeee
  219. -- 128:0000000d000000de00000ded0000decc000deccc00dedddd0deeeeeedfffffff
  220. -- 129:c0000000dc000000ddc00000ccdc0000cccdc000dddddc00eeeeeec0fffffffc
  221. -- 130:0000000d000000de00000dec0000dedd000deeee00deffff0defffffdfeeeeee
  222. -- 131:c0000000dc000000cdc00000dddc0000eeedc000ffffdc00fffffec0eeeeeefc
  223. -- 132:0000000d000000de00000dee0000deff000defff00deeeee0deddddddfcccccc
  224. -- 133:c0000000dc000000edc00000ffdc0000fffdc000eeeedc00dddddec0ccccccfc
  225. -- 134:0000000d000000de00000def0000deee000deddd00decccc0decccccdfdddddd
  226. -- 135:c0000000dc000000fdc00000eedc0000ddddc000ccccdc00cccccec0ddddddfc
  227. -- 136:0000000d000000de00000ded0000decc000deccc00dedddd0deddddddfcccccc
  228. -- 137:c0000000dc000000ddc00000ccdc0000cccdc000dddddc00dddddec0ccccccfc
  229. -- 138:0000000d000000de00000dec0000dedd000deddd00decccc0decccccdfdddddd
  230. -- 139:c0000000dc000000cdc00000dddc0000ddddc000ccccdc00cccccec0ddddddfc
  231. -- 144:efffffff0eeeeeee00eddddd000ecccc0000edcc00000edd000000ee0000000e
  232. -- 145:fffffffdeeeeeed0dddddd00ccccd000cccd0000ddd00000dd000000e0000000
  233. -- 146:efdddddd0eeccccc00edcccc000ecddd0000eddd00000edc000000ee0000000e
  234. -- 147:ddddddfdccccced0ccccdd00dddcd000ddcd0000cdd00000dd000000e0000000
  235. -- 148:efcccccc0eeddddd00eddddd000ecccc0000edcc00000edd000000ee0000000e
  236. -- 149:ccccccfdddddded0dddddd00ccccd000cccd0000ddd00000dd000000e0000000
  237. -- 150:efdddddd0eeccccc00edcccc000ecddd0000edee00000edf000000ee0000000e
  238. -- 151:ddddddfdccccced0ccccdd00dddcd000eecd0000fdd00000dd000000e0000000
  239. -- 152:efcccccc0eeddddd00edeeee000ecfff0000edff00000ede000000ee0000000e
  240. -- 153:ccccccfdddddded0eeeedd00fffcd000ffcd0000edd00000dd000000e0000000
  241. -- 154:efeeeeee0eefffff00edffff000eceee0000eddd00000edc000000ee0000000e
  242. -- 155:eeeeeefdfffffed0ffffdd00eeecd000ddcd0000cdd00000dd000000e0000000
  243. -- 160:ccccccefcccccccecccccccceeccccccffeccccceecccccccccccccccccccccc
  244. -- 161:ffeccccceeccccccccccccccccccccceccccccefcccccccecccccccccccccccc
  245. -- 162:ccccccefccccccefcccccccecccccccceccccccceccccccccccccccccccccccc
  246. -- 163:ffecccccffeccccceecccccccccccccccccccccecccccccecccccccccccccccc
  247. -- 164:cccccccecccccccccccccccceeccccccffecccccffeccccceecccccccccccccc
  248. -- 165:eeccccccccccccccccccccccccccccceccccccefccccccefcccccccecccccccc
  249. -- 176:ccccccccccccccccecccccccfeccccccfeccccccecccccccccccccceccccccef
  250. -- 177:ccccccccccccccccccccceeeccccefffccccefffccccceeeeeccccccffeccccc
  251. -- 178:ccccccccecccccccfeccccccfeccccccfeccccccecccccccccccccceccccccef
  252. -- 179:ccccccccccccceeeccccefffccccefffccccefffccccceeeeeccccccffeccccc
  253. -- 180:ccccccccccccccccecccccccfeccccccecccccccccccccccccccccccccccccce
  254. -- 181:ccccccccccccccccccccceeeccccefffccccceeecccccccccccccccceecccccc
  255. -- </TILES>
  256. -- <MAP>
  257. -- 001:203020302030203020302030203020302030203020302030203020302030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  258. -- 002:213121312131213121312131213121312131213121312131213121312131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  259. -- 003:203080908090809080908090809000008090809008188090a0b000008090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  260. -- 004:213181918191819181918191819100008191819109198191a1b100008191000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  261. -- 005:20308090a0b00212a0b08090809080908090809080900000809080908090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  262. -- 006:21318191a1b10313a1b18191819181918191819181910000819181918191000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  263. -- 007:20308090809080908090809080908090809080908090000080908090a0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  264. -- 008:21318191819181918191819181918191819181918191000081918191a1b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  265. -- 009:2030a0b08090a0b0a0b0809080908090809080908090809080908090a0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  266. -- 010:2131a1b18191a1b1a1b1819181918191819181918191819181918191a1b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  267. -- 011:2030a0b080900000a0b08090809080908090809080908090809080900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  268. -- 012:2131a1b181910000a1b18191819181918191819181918191819181910000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  269. -- 013:2030809080908090000080908090a0b08090809080908090809080908090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  270. -- 014:2131819181918191000081918191a1b18191819181918191819181918191000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  271. -- 015:203040504050405040504050405040504050405040504050405040504050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  272. -- 016:213141514151415141514151415141514151415141514151415141514151000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  273. -- </MAP>
  274. -- <WAVES>
  275. -- 000:00000000ffffffff00000000ffffffff
  276. -- 001:0123456789abcdeffedcba9876543210
  277. -- 002:0123456789abcdef0123456789abcdef
  278. -- </WAVES>
  279. -- <SFX>
  280. -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
  281. -- </SFX>
  282. -- <TRACKS>
  283. -- 000:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  284. -- </TRACKS>
  285. -- <PALETTE>
  286. -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
  287. -- </PALETTE>