cold.fs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. start-microcode cold
  2. \ system cold start program
  3. \ Interface:
  4. \ 3400-34FF voices source
  5. \ 3800-3FFF palette animation source (64 palettes)
  6. h# 3400 constant VOICES_COPY
  7. h# 3800 constant PALETTES
  8. d# 32 constant PALSZ \ size of palette in bytes
  9. : vblank@
  10. VBLANK ;fallthru
  11. : _c@ c@ ; \ these save 1 instruction per use
  12. : _c! c! ;
  13. : 1+ d# 1 + ;
  14. : @ dup _c@ swap 1+ _c@ swab or ;
  15. : up1 ( a -- ) \ subtract 1 from sprite coordinate at a
  16. dup>r @ dup h# fe00 and swap 1- h# 1FF and or r> ;fallthru
  17. : ! ( u addr )
  18. over swab over 1+ _c! _c! ;
  19. : waitvbi \ wait for start of vertical blanking interval
  20. begin vblank@ 1- until
  21. begin vblank@ until ;
  22. : stepfade ( u -- ) \ fade step u is 0-63
  23. PALSZ * PALETTES +
  24. dup d# 30 + @ BG_COLOR ! \ copy 15th palette entry to BG_COLOR
  25. PALETTE16A
  26. PALSZ
  27. ;fallthru
  28. : cmove ( src dst n -- )
  29. begin
  30. dup
  31. while
  32. >r
  33. over _c@ over _c!
  34. 1+ swap 1+ swap
  35. r> 1-
  36. repeat
  37. drop ;fallthru
  38. : 2drop drop drop ;
  39. : endl ( limit u -- limit u' finished ) \ end of loop
  40. waitvbi ;fallthru
  41. : qendl \ quick endl, no wait for frame
  42. 1+
  43. 2dup=
  44. ;
  45. : >VOICES ( a -- ) \ load all voices from a
  46. VOICES d# 256 cmove ;
  47. [ RAM_SPR 2 + ] constant SPR_YS \ sprite Y coordinates
  48. : main
  49. d# 256 d# 0
  50. begin
  51. dup h# c0 and d# 128 = if
  52. dup d# 63 and stepfade
  53. then
  54. \ copy 3E00+u to VOICES+u
  55. dup VOICES_COPY + _c@
  56. over VOICES + _c!
  57. endl until
  58. begin
  59. COMM+9 _c@
  60. until
  61. h# 3500 >VOICES
  62. d# 265 d# 0
  63. begin
  64. d# 256 d# 0
  65. begin
  66. dup d# 4 * SPR_YS + up1
  67. qendl until
  68. 2drop
  69. dup SCROLL_Y !
  70. endl until
  71. h# 3600 >VOICES
  72. d# 0
  73. begin
  74. waitvbi
  75. dup SCROLL_X !
  76. 1+
  77. again
  78. ;
  79. end-microcode