Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. ######################################################
  2. ##
  3. ## Console:
  4. ##
  5. ## A grid-based virtual console, using the scroll
  6. ## registers to achieve pixel-wise animated scrolling
  7. ## rather than character-based scrolling. Note the
  8. ## use of revectoring to leverage the existing
  9. ## infrastructure of the Print lexicon.
  10. ##
  11. ## John Earnest
  12. ##
  13. ######################################################
  14.  
  15. :include "../Print.fs"
  16. :include "../Vector.fs"
  17. :include "../Grid.fs"
  18. :include "../Util.fs"
  19.  
  20. :image grid-tiles "transparentFont.png" 8 8
  21. :array console-display 1271 0
  22. :var cursor 0
  23.  
  24. : console-emit ( char -- )
  25. dup 10 = if
  26. cursor @ 41 / 1 + 41 * cursor !
  27. else
  28. 32 - # our font's chars start at ASCII 32
  29. GP @ cursor @ + !
  30. cursor inc@
  31. then
  32.  
  33. cursor @ 1230 > if
  34. # animate scrolling the grid
  35. 6 for 1 scroll-grid-y sync next
  36. # reset the scroll registers
  37. console-display GP !
  38. 0 SY !
  39. # shift the data on the grid
  40. 1228 for
  41. console-display 1228 + i - 41 + @
  42. console-display 1228 + i - !
  43. next
  44. # reposition the cursor
  45. cursor @ 41 - cursor !
  46. then
  47. ;
  48.  
  49. : init-console ( -- )
  50. ' console-emit ' emit revector
  51. console-display GP !
  52. console-display grid-start !
  53. 41 grid-width !
  54. 31 grid-height !
  55. 0 cursor !
  56. 1270 for -1 console-display i + ! next
  57. ;
  58.  
  59. : exit-console ( -- )
  60. ' emit devector
  61. ;
  62.  
  63.  
  64. :string hello "Hello, World!"
  65.  
  66. : main
  67.  
  68. init-console
  69.  
  70. hello typeln
  71. hello typeln
  72.  
  73. 0
  74. loop
  75. #hello type space
  76. dup .
  77. 1 +
  78. sync
  79. again
  80. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement