The following is assembly code that has been hand coded for handling strings. You can use my assembler MIPs32assembler or GTLCPimps(Code Designer) to compile this into a code format. These functions are useful for any type of custom written code containing strings.
Here is an example of a custom menu in socom, where a user can iterate through each map piece and move it.
The menu was created using the following library. For any code hacker looking to have more control over custom codes.

address $200b0000
import "Timer.cds"
Mips String Library
Author: Cronotrigga
================================================== ============
String Functions:
-StrLength(Source, Delimiter)
-StrCopy(Source, Destination, Delimiter)
-StrCopyRange(SourceBegin, SourceEnd, Destination)
-StrCompare(Substr, Source)
-StrIndexOf(SubStr, Source)
-StrReplace(Match, Replace, Source, Destination)
-StrConcat(Substr, Substr, Destination)
-StrSplit(Source, StrList, Delimiter)
-StrPadR(Source, Pad, Size, Destination)
-StrPadL(Source, Pad, Size, Destination)
-StrToUpper(Source, Destination)
-StrToLower(Source, Destination)
================================================== ============
String Animation Functions:
-StrBlink(DisplayPointer, DisplayString, Max, Storage)
-StrAnimate(DislpayPointer, Storage, Max)
================================================== ============
String List Functions:
-StrMatch(Substr, StrList)
-StrListMatch(StrList,StrCursor)
-StrListIterator(Display,Joker,JokerV1,JokerV2,Stor age,Max)
-StrJoin(StrList, Destination)
================================================== ============
================================================== ==============
Name: StrLength()
-------------------
Description: Gets the length of the string. A delimiter should always be set. If a delimiter is not needed
set the delimiter to null.
Usage:
-------------------
a0 string
a1 delimiter
-------------------
v0 size
v1 end of string
================================================== ==============
================================================== ==============
Name: StrCopy()
-------------------
Description: Copies a string to the location specified. The delimiter should always be set, if a delimiter is not needed set it to null. Will return back the location of the end of the string that was copied.
Usage:
-------------------
a0 copy address
a1 paste address
a2 delimiter
-------------------
v0 end of the copied string
v1 delimiter position
================================================== ==============
================================================== ==============
Name: StrCopyRange()
-------------------
Description: Copies a string to the location specified. Using a start address and an end address.
Usage:
-------------------
a0 copy start address
a1 copy end address
a2 paste address
-------------------
v0 end of the copied string
================================================== ==============
================================================== ==============
Name: StrCompare()
-------------------
Description: Will compare each character in two seperate substrings, until a null byte or the delimiter is found. The delimiter should always be set, if there is no delimiter set a2 to null.
Usage:
-------------------
a0 substring
a1 string
-------------------
v0 true = 0 | false = 1
v1 end address of the string
================================================== ==============
================================================== ==============
Name: StrIndexOf()
-------------------
Description: If the substring is found the address will be returned
Usage:
-------------------
a0 substring
a1 string
-------------------
v0 true = 0 | false = 1
v1 address of the matched string
================================================== ==============
================================================== ==============
Name: StrReplace()
-------------------
Description: Insert a substring into a string
Usage:
-------------------
a0 match string
a1 replace string
a2 source string
a3 output string
-------------------
v0 true = 0 | false = 1
================================================== ==============
================================================== ==============
Name: StrConcat()
-------------------
Description: adds two strings together
-------------------
a0 substring
a1 substring
a2 output
-------------------
v0 end address
================================================== ==============
================================================== ==============
Name: StrMatch()
-------------------
Description: Checks a list of strings to see if one is found
Usage:
-------------------
a0 string
a1 stringList
v0 true = 0 | false = 1
v1 Index
================================================== ==============
================================================== ==============
Name: StrSplit()
Description: splits a string into a pointer list
Usage:
-------------------
a0 string
a1 stringList
a2 delimiter
-------------------
v0 StrList begin
v1 StrList end
================================================== ==============
================================================== ==============
Name: StrJoin()
-------------------
Description: Joins a list of strings together with a delimiter
Usage:
-------------------
a0 stringList
a1 output string
================================================== ==============
================================================== ==============
Name: StrPadL()
-------------------
Description: Pads a string to the size specified with the pad value
Usage:
-------------------
a0 string
a1 pad
a2 size
a3 output string
v0 end of string
================================================== ==============
================================================== ==============
Name: StrPadR()
-------------------
Description: Pads a string to the size specified with the pad value
Usage:
-------------------
a0 string
a1 pad
a2 size
a3 output string
v0 end of string
================================================== ==============
================================================== ==============
Name: StrToUpper()
-------------------
Description: changes the case of the string to all uppercase
Usage:
-------------------
a0 string
a1 output string
================================================== ==============
================================================== ==============
Name: StrToLower()
-------------------
Description: changes the case of the string to all uppercase
Usage:
-------------------
a0 string
a1 output string
================================================== ==============
================================================== ==============
Name: StrListMatch()
-------------------
Description: Matches a pointer in the StrList
-------------------
a0 StrList
a1 StrCursor
-------------------
v0 returns index
================================================== ==============
================================================== ==============
Name: StrAnimate()
-------------------
Description: Creates frames from a string and animates through each frame.
-------------------
a0 Display String
a1 Storage area
a2 Timer max
================================================== ==============
================================================== ==============
Name: StrListIterator()
-------------------
Description: Scroll through a string list
-------------------
a0 Display String
a1 Joker
a2 Joker address Up
a3 Joker address Down
t0 Storage area
t1 Timer max
================================================== ==============
================================================== ==============
Name: StrBlink()
-------------------
Description: Will Animate a string to blink on a set timer
-------------------
a0 Display Pointer
a1 string
a2 Max
a3 Storage
================================================== ==============
================================================== ==============
Name: Timer()
Description: Creates a timer at the storage address.
Resets when the time his the max value.
a0 Storage
a1 Max Value
v0 0 = time elapsed | 1 = still counting
================================================== ==============
Here is an example of a custom menu in socom, where a user can iterate through each map piece and move it.
The menu was created using the following library. For any code hacker looking to have more control over custom codes.
address $200b0000
import "Timer.cds"
Mips String Library
Author: Cronotrigga
================================================== ============
String Functions:
-StrLength(Source, Delimiter)
-StrCopy(Source, Destination, Delimiter)
-StrCopyRange(SourceBegin, SourceEnd, Destination)
-StrCompare(Substr, Source)
-StrIndexOf(SubStr, Source)
-StrReplace(Match, Replace, Source, Destination)
-StrConcat(Substr, Substr, Destination)
-StrSplit(Source, StrList, Delimiter)
-StrPadR(Source, Pad, Size, Destination)
-StrPadL(Source, Pad, Size, Destination)
-StrToUpper(Source, Destination)
-StrToLower(Source, Destination)
================================================== ============
String Animation Functions:
-StrBlink(DisplayPointer, DisplayString, Max, Storage)
-StrAnimate(DislpayPointer, Storage, Max)
================================================== ============
String List Functions:
-StrMatch(Substr, StrList)
-StrListMatch(StrList,StrCursor)
-StrListIterator(Display,Joker,JokerV1,JokerV2,Stor age,Max)
-StrJoin(StrList, Destination)
================================================== ============
================================================== ==============
Name: StrLength()
-------------------
Description: Gets the length of the string. A delimiter should always be set. If a delimiter is not needed
set the delimiter to null.
Usage:
-------------------
a0 string
a1 delimiter
-------------------
v0 size
v1 end of string
================================================== ==============
Code:
___StrLength: daddu v0, zero, zero, daddu v1, a0, zero, BeginStrLength: lb t0, $0000(v1) beq t0, zero, :EndStrLength nop beq t0, a1, :EndStrLength nop addiu v1, v1, $0001 beq zero, zero, :BeginStrLength addiu v0, v0, $0001 EndStrLength: jr ra nop
================================================== ==============
Name: StrCopy()
-------------------
Description: Copies a string to the location specified. The delimiter should always be set, if a delimiter is not needed set it to null. Will return back the location of the end of the string that was copied.
Usage:
-------------------
a0 copy address
a1 paste address
a2 delimiter
-------------------
v0 end of the copied string
v1 delimiter position
================================================== ==============
Code:
___StrCopy: daddu t0, a0, zero, daddu t1, a1, zero, BeginStrCopy: lb t2, $0000(t0) beq t2, zero, :EndStrCopy nop beq t2, a2, :EndStrCopy nop sb t2, $0000(t1) addiu t0, t0, $0001 beq zero, zero, :BeginStrCopy addiu t1, t1, $0001 EndStrCopy: sb zero, $0000(t1) daddu v0, t1, zero, daddu v1, t0, zero, jr ra nop
================================================== ==============
Name: StrCopyRange()
-------------------
Description: Copies a string to the location specified. Using a start address and an end address.
Usage:
-------------------
a0 copy start address
a1 copy end address
a2 paste address
-------------------
v0 end of the copied string
================================================== ==============
Code:
___StrCopyRange: daddu t0, a0, zero, daddu t1, a1, zero, daddu t9, a2, zero, daddu v0, zero, zero, BeginStrSubStr: beq t0, t1, :EndStrSubStr nop lb t2, $0000(t0) sb t2, $0000(t9) addiu t0, t0, $0001 addiu t9, t9, $0001 beq zero, zero, :BeginStrSubStr nop EndStrSubStr: daddu v0, t9, zero, jr ra nop
================================================== ==============
Name: StrCompare()
-------------------
Description: Will compare each character in two seperate substrings, until a null byte or the delimiter is found. The delimiter should always be set, if there is no delimiter set a2 to null.
Usage:
-------------------
a0 substring
a1 string
-------------------
v0 true = 0 | false = 1
v1 end address of the string
================================================== ==============
Code:
___StrCompare: addiu sp, sp, $FFD0 sw ra, $0000(sp) sw s0, $0004(sp) daddu v0, zero, zero, daddu t0, a0, zero, daddu t1, a1, zero, startCompare: lb t2, $0000(t0) beq t2, zero, :ContinueStrCompare nop lb t3, $0000(t1) bne t2, t3, :ContinueStrCompare nop addiu t0, t0, $0001 addiu t1, t1, $0001 beq zero, zero, :startCompare addiu v0, v0, $0001 ContinueStrCompare: daddu s0, v0, zero, jal :___StrLength daddu a1, zero, zero, beq s0, v0, :EndStrCompare daddu v0, zero, zero, addiu v0, zero, $0001 EndStrCompare: daddu v1, t1, zero, lw ra, $0000(sp) lw s0, $0004(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrIndexOf()
-------------------
Description: If the substring is found the address will be returned
Usage:
-------------------
a0 substring
a1 string
-------------------
v0 true = 0 | false = 1
v1 address of the matched string
================================================== ==============
Code:
___StrIndexOf: addiu sp, sp, $FFD0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) daddu s0, a0, zero, daddu s1, a1, zero, BeginStrIndexOf: lb t0, $0000(s1) beq t0, zero :EndStrIndexOf addiu v0, zero, $0001 daddu a0, s0, zero, jal :___StrCompare daddu a1, s1, zero, bne v0, zero, :ContinueStrIndexOf nop daddu v1, s1, zero, beq zero, zero, :EndStrIndexOf ContinueStrIndexOf: addiu s1, s1, $0001 beq zero, zero, :BeginStrIndexOf nop EndStrIndexOf: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrReplace()
-------------------
Description: Insert a substring into a string
Usage:
-------------------
a0 match string
a1 replace string
a2 source string
a3 output string
-------------------
v0 true = 0 | false = 1
================================================== ==============
Code:
___StrReplace: addiu sp, sp, $FFD0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) sw s3, $0010(sp) sw s4, $0014(sp) sw s5, $0018(sp) daddu s0, a0, zero, daddu s1, a1, zero, daddu s2, a2, zero, daddu s3, a3, zero, jal :___StrIndexOf daddu a1, s2, zero, bne v0, zero, :EndStrReplace nop daddu s4, v1, zero, daddu a0, s2, zero, daddu a1, s4, zero, jal :___StrCopyRange daddu a2, s3, zero, daddu a0, s1, zero, daddu a1, v0, zero, jal :___StrCopy daddu a2, zero, zero, daddu s5, v0, zero, jal :___StrLength daddu a0, s0, zero, add s4, s4, v0, daddu a0, s4, zero, daddu a1, s5, zero, jal :___StrCopy daddu a2, zero, zero, EndStrReplace: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) lw s3, $0010(sp) lw s4, $0014(sp) lw s5, $0018(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrConcat()
-------------------
Description: adds two strings together
-------------------
a0 substring
a1 substring
a2 output
-------------------
v0 end address
================================================== ==============
Code:
___StrConcat: addiu sp, sp, $FFd0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) daddu s0, a0, zero, daddu s1, a1, zero, daddu s2, a2, zero, daddu a0, s0, zero, daddu a1, s2, zero, jal :___StrCopy daddu a2, zero, zero, daddu a0, s1, zero, daddu a1, v0, zero, jal :___StrCopy daddu a2, zero, zero, lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrMatch()
-------------------
Description: Checks a list of strings to see if one is found
Usage:
-------------------
a0 string
a1 stringList
v0 true = 0 | false = 1
v1 Index
================================================== ==============
Code:
___StrMatch: addiu sp, sp, $FFd0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) sw s3, $0010(sp) daddu s0, a0, zero, daddu s1, a1, zero, daddu s3, zero, zero, BeginStrMatch: lw s2, $0000(s1) beq s2, zero, :EndStrMatch addiu v0, zero, $0001 daddu a0, s0, zero, jal :___StrCompare daddu a1, s2, zero, beq v0, zero, :EndStrMatch addiu s1, s1, $0004 beq zero, zero, :BeginStrMatch addiu s3, s3, $0001 EndStrMatch: daddu v1, s3, zero, lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) lw s3, $0010(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrSplit()
Description: splits a string into a pointer list
Usage:
-------------------
a0 string
a1 stringList
a2 delimiter
-------------------
v0 StrList begin
v1 StrList end
================================================== ==============
Code:
___StrSplit: daddu t0, a0, zero, daddu t1, a1, zero, sw t0, $0000(t1) addiu t1, t1, $0004 BeginStrSplit: lb t2, $0000(t0) beq t2, zero, :EndStrSplit nop bne t2, a2 :ContinueStrSplit nop addiu t3, t0, $0001 sw t3, $0000(t1) addiu t1, t1, $0004 ContinueStrSplit: addiu t0, t0, $0001 beq zero, zero, :BeginStrSplit nop EndStrSplit: daddu v0, a1, zero, daddu v1, t1, zero, jr ra nop
================================================== ==============
Name: StrJoin()
-------------------
Description: Joins a list of strings together with a delimiter
Usage:
-------------------
a0 stringList
a1 output string
================================================== ==============
Code:
___StrJoin: addiu sp, sp, $FFD0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) daddu s0, a0, zero, daddu s1, a1, zero, BeginStrJoin: lw t0, $0000(s0) beq t0, zero, :EndStrJoin nop ContinueStrJoin: daddu a0, t0, zero, daddu a1, s1, zero, jal :___StrCopy addiu a2, zero, $0020 addiu v0, v0, $0001 daddu s1, v0, zero, addiu s0, s0, $0004 beq zero, zero, :BeginStrJoin nop EndStrJoin: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrPadL()
-------------------
Description: Pads a string to the size specified with the pad value
Usage:
-------------------
a0 string
a1 pad
a2 size
a3 output string
v0 end of string
================================================== ==============
Code:
___StrPadL: addiu sp, sp, $FFD0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) sw s3, $0010(sp) daddu s0, a0, zero, daddu s1, a1, zero, daddu s2, a2, zero, daddu s3, a3, zero, daddu t1, zero, zero, jal :___StrLength daddu a1, zero, zero, nop sub t0, a2, v0, blez t0, :EndStringPadL nop BeginStrPadL: beq t1, t0 :ContinueStrPadL nop sb s1, $0000(s3) addiu t1, t1, $0001 addiu s3, s3, $0001 beq zero, zero :BeginStrPadL nop ContinueStrPadL: daddu a0, s0, zero, daddu a1, s3, zero, jal :___StrCopy daddu a2, zero, zero, EndStringPadL: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) lw s3, $0010(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrPadR()
-------------------
Description: Pads a string to the size specified with the pad value
Usage:
-------------------
a0 string
a1 pad
a2 size
a3 output string
v0 end of string
================================================== ==============
Code:
___StrPadR: addiu sp, sp, $FFD0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) sw s3, $0010(sp) sw s4, $0014(sp) daddu s0, a0, zero, daddu s1, a1, zero, daddu s2, a2, zero, daddu s3, a3, zero, jal :___StrLength daddu a1, zero, zero, nop sub t0, a2, v0, blez t0, :EndStringPadR nop daddu s4, t0, zero, daddu a0, s0, zero, daddu a1, s3, zero, jal :___StrCopy daddu a2, zero, zero, daddu s3, v0, zero, daddu t1, zero, zero, BeginStrPadR: beq t1, s4 :EndStringPadR nop sb s1, $0000(s3) addiu t1, t1, $0001 addiu s3, s3, $0001 beq zero, zero :BeginStrPadR nop EndStringPadR: daddu v0, s3, zero, lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) lw s3, $0010(sp) lw s4, $0014(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrToUpper()
-------------------
Description: changes the case of the string to all uppercase
Usage:
-------------------
a0 string
a1 output string
================================================== ==============
Code:
___StrToUpper: daddu t0, a0, zero, daddu t9, a1, zero, BeginStrToUpper: lb t1, $0000(t0) beq t1, zero, :EndStrToUpper lb t3, $0000(t0) slti v0, t1, $0061 bne v0, zero, :NextStrUpper lb t3, $0000(t0) slti v0, t1, $007b beq v0, zero, :NextStrUpper nop srl t2, t1, 4 addiu t2, t2, $FFFE sll t2, t2, 4 sll t3, t1, 28 srl t3, t3, 28 add t3, t2, t3, NextStrUpper: sb t3, $0000(t9) addiu t0, t0, $0001 addiu t9, t9, $0001 beq zero, zero, :BeginStrToUpper nop EndStrToUpper: jr ra nop
================================================== ==============
Name: StrToLower()
-------------------
Description: changes the case of the string to all uppercase
Usage:
-------------------
a0 string
a1 output string
================================================== ==============
Code:
___StrToLower: daddu t0, a0, zero, daddu t9, a1, zero, BeginStrToLower: lb t1, $0000(t0) beq t1, zero, :EndStrToLower lb t3, $0000(t0) slti v0, t1, $0041 bne v0, zero, :NextStrLower lb t3, $0000(t0) slti v0, t1, $005b beq v0, zero, :NextStrLower nop srl t2, t1, 4 addiu t2, t2, $0002 sll t2, t2, 4 sll t3, t1, 28 srl t3, t3, 28 add t3, t2, t3, NextStrLower: sb t3, $0000(t9) addiu t0, t0, $0001 addiu t9, t9, $0001 beq zero, zero, :BeginStrToLower nop EndStrToLower: jr ra nop
================================================== ==============
Name: StrListMatch()
-------------------
Description: Matches a pointer in the StrList
-------------------
a0 StrList
a1 StrCursor
-------------------
v0 returns index
================================================== ==============
Code:
___StrListMatch: daddu v0, zero, zero, daddu t0, a0, zero, lw a1, $0000(a1) StartListMatch: lw t2, $0000(t0) beq t2, zero, :EndListMatch nop beq t2, a1, :EndListMatch nop addiu t0, t0, $0004 addiu v0, v0, $0001 beq zero, zero, :StartListMatch nop EndListMatch: jr ra nop
================================================== ==============
Name: StrAnimate()
-------------------
Description: Creates frames from a string and animates through each frame.
-------------------
a0 Display String
a1 Storage area
a2 Timer max
================================================== ==============
Code:
___StrAnimate: addiu sp, sp, $FFd0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw at, $0010(sp) daddu s0, a0, zero, daddu at, a1, zero, daddu s1, a2, zero, addiu a0, at, $1000 jal :___Timer daddu a1, s1, zero, bne v0, zero, :EndStrFrames nop daddu a0, at, zero, addiu a1, at, $1010 jal :___StrSplit addiu a2, zero, $003b sw v0, $200C(at) sw v1, $2010(at) lw t0, $2014(at) bne t0, zero, :EndStrCurrent nop sw v0, $2014(at) EndStrCurrent: lw t0, $2014(at) lw t1, $2010(at) bne t0, t1, :EndStrFramesReset nop lw v0, $200c(at) sw v0, $2014(at) EndStrFramesReset: PrintStrFrame: daddu a1, s0, zero, lw a0, $2014(at) lw a0, $0000(a0) jal :___StrCopy addiu a2, zero, $003b lw v0, $2014(at) addiu v0, v0, $0004 sw v0, $2014(at) EndStrFrames: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw at, $0010(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrListIterator()
-------------------
Description: Scroll through a string list
-------------------
a0 Display String
a1 Joker
a2 Joker address Up
a3 Joker address Down
t0 Storage area
t1 Timer max
================================================== ==============
Code:
___StrListIterator: addiu sp, sp, $FFd0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) sw s3, $0010(sp) sw at, $0014(sp) daddu s0, a0, zero, daddu at, t0, zero, daddu s1, a1, zero, lh s1, $0000(s1) daddu s2, a2, zero, daddu s3, a3, zero, //Time Elapsed Check addiu a0, at, $1000 jal :___Timer daddu a1, t1, zero, bne v0, zero, :EndVehicleMenu nop daddu a0, at, zero, addiu a1, at, $1010 jal :___StrSplit addiu a2, zero, $003b sw v0, $200C(at) sw v1, $2010(at) lw t0, $2014(at) bne t0, zero, :EndCursorInit nop sw v0, $2014(at) EndCursorInit: //[DOWN] Joker addiu v1, v1, $FFFC bne s1, s3, :ToEndOfDown nop daddu t1, v0, zero, bne t0, t1, :ToEndOfList nop sw v1, $2014(at) beq zero zero, :ToEndOfDown nop ToEndOfList: addiu t0, t0, $FFFC sw t0, $2014(at) ToEndOfDown: //[UP] Joker bne s1, s2, :EndVehicleMenu nop bne t0, v1, :ToStartOfList nop sw v0, $2014(at) beq zero, zero, :EndVehicleMenu nop ToStartOfList: addiu t0, t0, $0004 sw t0, $2014(at) EndVehicleMenu: //Print to display string lw a0, $200c(at) jal :___StrListMatch lw a1, $2014(at) sw v0, $2018(at) daddu a1, s0, zero, lw a0, $2014(at) lw a0, $0000(a0) jal :___StrCopy addiu a2, zero, $003b EndVehicleMenuNoUpdate: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) lw s3, $0010(sp) lw at, $0014(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: StrBlink()
-------------------
Description: Will Animate a string to blink on a set timer
-------------------
a0 Display Pointer
a1 string
a2 Max
a3 Storage
================================================== ==============
Code:
___StrBlink: addiu sp, sp, $FFd0 sw ra, $0000(sp) sw s0, $0004(sp) sw s1, $0008(sp) sw s2, $000c(sp) sw at, $0010(sp) daddu s0, a0, zero, daddu s1, a1, zero, daddu s2, a2, zero, daddu at, a3, zero, daddu a0, at, zero, jal :___Timer daddu a1, s2, zero, bne v0, zero, :EndStrBlink nop lb t1, $0000(s0) bne t1, zero, :EndStrBlinkSet nop daddu a0, s1, zero, daddu a1, s0, zero, jal :___StrCopy daddu a2, zero, zero, beq zero, zero, :EndStrBlink nop EndStrBlinkSet: sb zero, $0000(s0) sb zero, $0004(s0) EndStrBlink: lw ra, $0000(sp) lw s0, $0004(sp) lw s1, $0008(sp) lw s2, $000c(sp) lw at, $0010(sp) jr ra addiu sp, sp, $0030
================================================== ==============
Name: Timer()
Description: Creates a timer at the storage address.
Resets when the time his the max value.
a0 Storage
a1 Max Value
v0 0 = time elapsed | 1 = still counting
================================================== ==============
Code:
___Timer: daddu t0, a0, zero, lh t1, $0000(t0) daddu v0, a1, zero, bne t1, v0, :AddTime daddu v0, zero, zero, sh zero, $0000(t0) beq zero, zero, :EndTimer nop AddTime: addiu t1, t1, $0001 sh t1, $0000(t0) addiu v0, zero, $0001 EndTimer: jr ra nop