Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;mode800
- *define
- defsub flowtext
- effect 9,10,500
- numalias text_string,50
- numalias glyph_width,51
- numalias x_coord,52
- numalias y_coord,53
- numalias s_width,54
- numalias text_char,55
- numalias text_len,56
- numalias sp_f,57
- numalias sp_l,58
- numalias sp_n,59
- numalias sp_width,60
- numalias sp_fpos,61
- numalias sp_curpos,62
- numalias sp_e,63
- game
- *start
- flowtext "Non-unicode text",20,50,800
- flowtext "Кириллический текст",20,50,800
- flowtext "Mixed-текст вперемешку",20,50,800
- reset
- end
- *flowtext
- ; reading paremeters passed to our custom flowtext function
- ; $text_string - text string
- ; %glyph_width - glyph width
- ; %y_coord - y coordinate
- ; %s_width - screen width
- getparam $text_string,%glyph_width,%y_coord,%s_width
- ; Sets %text_len to the length of $text_string
- len %text_len,$text_string
- ; Set the first sprite slot number
- mov %sp_f,60
- ; Copy the value to new variable, and add length of string
- mov %sp_l,%sp_f
- add %sp_l,%text_len-1
- ; Creating letter sprites
- ; Calculating total width of sprites
- mov %sp_width,%text_len
- mul %sp_width,%glyph_width
- ; Calculating first sprite's position
- mov %sp_fpos,%s_width
- sub %sp_fpos,%sp_width
- div %sp_fpos,2
- ; Assign value to sprite coord accumulator
- mov %sp_curpos,%sp_fpos
- for %sp_n=%sp_f to %sp_l
- ; Extracting 1 character from the string
- mov %sp_e,%sp_n-%sp_f
- mid $text_char,$text_string,%sp_e,1
- mov %x_coord,%sp_curpos
- ; Output sprite: number,text,x,y,alpha
- lsph %sp_n,":S#ffffff$text_char",%x_coord,%y_coord,255
- ; Increasing accumulator
- add %sp_curpos,%glyph_width
- next
- ; Sprites display: fade in, then fade out
- for %sp_n=%sp_f to %sp_l
- vsp %sp_n,1:print 9
- next
- for %sp_n=%sp_f to %sp_l
- vsp %sp_n,0:print 9
- next
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement