#name ^.Object.Message
#type &ffd
#include Oddball:Sources.Structures
#include Oddball:Sources.Variables

; Text handler
; On entry, [R0] = DCD x,y,xv,yv,tmr,lnk:DCB "Text",0
.start
STMFD R13!,{R1-R11,R14}
MOV R11,R0
.countlength
ADD R10,R11,#24
MOV R9,#2
.loop
LDRB R0,[R10],#1
CMP R0,#32
BLT textend
ADDEQ R9,R9,#6
BEQ loop
ADD R0,R0,#texttab<<24
SWI XFastSpr_ReadSize
ADD R9,R9,R0
ADD R9,R9,#2
B loop
.textend
MOV R8,R9,LSL #16 ;build size entry
ADD R8,R8,#16
MOV R0,#texttab
MOV R1,#1; indicate a live text object
MOV R2,#%1100000110
LDMIA R11,{R3-R7}  ; load from text data
SWI Amnesia_MakeObject
ADD R10,R10,#3
BIC R10,R10,#3
MOV R0,R10
CMP R1,#0
LDMEQFD R13!,{R1-R11,PC}
ADD R11,R11,#24
STR R11,[R1,#32]
LDMFD R13!,{R1-R11,PC}

