palettefade.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. -- title: palettefade
  2. -- author: pixelbath
  3. -- desc: fades elements of the palette
  4. -- script: lua
  5. -- TODO: read the TIC palette at runtime
  6. local basepalette = {
  7. 0x1a1c2c, 0x29366f, 0x3b5dc9, 0x1a1c2c, 0x5d275d, 0x38b764, 0xb13e53, 0x333c57, 0x41a6f6, 0xef7d57, 0x94b0c2, 0xa7f070, 0xe06f8b, 0x73eff7, 0xffcd75, 0xf4f4f4
  8. }
  9. function pal(v)
  10. if v>1 then v=1 end
  11. if v<0 then v=0 end
  12. for i = 1, #basepalette do
  13. local offset, color = i-1, basepalette[i]
  14. poke(0x3fc0+(offset*3), ((color//65536) * v))
  15. poke(0x3fc1+(offset*3), ((color//256)%256) * v)
  16. poke(0x3fc2+(offset*3), (color%256) * v)
  17. end
  18. end
  19. local palval=0
  20. local palinc=0.1
  21. t=0
  22. x=96
  23. y=24
  24. function TIC()
  25. if btn(0) then y=y-1 end
  26. if btn(1) then y=y+1 end
  27. if btn(2) then x=x-1 end
  28. if btn(3) then x=x+1 end
  29. cls(13)
  30. spr(1+t%60//30*2,x,y,14,3,0,0,2,2)
  31. print("HELLO WORLD!",84,84)
  32. t=t+1
  33. palval=palval+palinc
  34. if palval > 0.9 then palinc=-0.1 end
  35. if palval < 0.1 then palinc=0.1 end
  36. pal(palval)
  37. end
  38. -- <TILES>
  39. -- 001:7fffffffff111111f8888888f8111111f8fffffff8ff0ffff8ff0ffff8ff0fff
  40. -- 002:fffff7771111ff7788880f7711180f77fff80fff0ff80f0f0ff80f0f0ff80f0f
  41. -- 003:7fffffffff111111f8888888f8111111f8fffffff8fffffff8ff0ffff8ff0fff
  42. -- 004:fffff7771111ff7788880f7711180f77fff80ffffff80f0f0ff80f0f0ff80f0f
  43. -- 017:f8fffffff8888888f888f888f8888ffff8888888f1111111ff000fff7fffff7f
  44. -- 018:fff800ff88880ff7f8880f7788880f7788880f771111ff77000ff777ffff7777
  45. -- 019:f8fffffff8888888f888f888f8888ffff8888888f1111111ff000fff7fffff7f
  46. -- 020:fff800ff88880ff7f8880f7788880f7788880f771111ff77000ff777ffff7777
  47. -- </TILES>
  48. -- <WAVES>
  49. -- 000:00000000ffffffff00000000ffffffff
  50. -- 001:0123456789abcdeffedcba9876543210
  51. -- 002:0123456789abcdef0123456789abcdef
  52. -- </WAVES>
  53. -- <SFX>
  54. -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
  55. -- </SFX>
  56. -- <PALETTE>
  57. -- 000:1a1c2c29366f3b5dc91a1c2c5d275d38b764b13e53333c5741a6f6ef7d5794b0c2a7f070e06f8b73eff7ffcd75f4f4f4
  58. -- </PALETTE>