Advertisement
Guest User

PONScripter "flowtext" example by dsp2003

a guest
Jun 14th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. ;mode800
  2.  
  3. *define
  4.  
  5. defsub flowtext
  6.  
  7. effect 9,10,500
  8.  
  9. numalias text_string,50
  10. numalias glyph_width,51
  11. numalias x_coord,52
  12. numalias y_coord,53
  13. numalias s_width,54
  14. numalias text_char,55
  15. numalias text_len,56
  16. numalias sp_f,57
  17. numalias sp_l,58
  18. numalias sp_n,59
  19. numalias sp_width,60
  20. numalias sp_fpos,61
  21. numalias sp_curpos,62
  22. numalias sp_e,63
  23.  
  24. game
  25.  
  26. *start
  27.  
  28. flowtext "Non-unicode text",20,50,800
  29. flowtext "Кириллический текст",20,50,800
  30. flowtext "Mixed-текст вперемешку",20,50,800
  31.  
  32. reset
  33.  
  34. end
  35.  
  36. *flowtext
  37.  
  38. ; reading paremeters passed to our custom flowtext function
  39. ; $text_string - text string
  40. ; %glyph_width - glyph width
  41. ; %y_coord - y coordinate
  42. ; %s_width - screen width
  43. getparam $text_string,%glyph_width,%y_coord,%s_width
  44.  
  45. ; Sets %text_len to the length of $text_string
  46. len %text_len,$text_string
  47.  
  48. ; Set the first sprite slot number
  49. mov %sp_f,60
  50. ; Copy the value to new variable, and add length of string
  51. mov %sp_l,%sp_f
  52. add %sp_l,%text_len-1
  53.  
  54. ; Creating letter sprites
  55.  
  56. ; Calculating total width of sprites
  57. mov %sp_width,%text_len
  58. mul %sp_width,%glyph_width
  59. ; Calculating first sprite's position
  60. mov %sp_fpos,%s_width
  61. sub %sp_fpos,%sp_width
  62. div %sp_fpos,2
  63.  
  64. ; Assign value to sprite coord accumulator
  65. mov %sp_curpos,%sp_fpos
  66.  
  67. for %sp_n=%sp_f to %sp_l
  68. ; Extracting 1 character from the string
  69. mov %sp_e,%sp_n-%sp_f
  70. mid $text_char,$text_string,%sp_e,1
  71.  
  72. mov %x_coord,%sp_curpos
  73.  
  74. ; Output sprite: number,text,x,y,alpha
  75. lsph %sp_n,":S#ffffff$text_char",%x_coord,%y_coord,255
  76.  
  77. ; Increasing accumulator
  78. add %sp_curpos,%glyph_width
  79.  
  80. next
  81.  
  82. ; Sprites display: fade in, then fade out
  83.  
  84. for %sp_n=%sp_f to %sp_l
  85. vsp %sp_n,1:print 9
  86. next
  87.  
  88. for %sp_n=%sp_f to %sp_l
  89. vsp %sp_n,0:print 9
  90. next
  91.  
  92. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement