Pretty Speedometer [stebler]
(02-09-2021, 04:39 PM)Melg Wrote: Yes you can change it to display anything really. For example this is a debug panel code I made for CT authors and testers:
[Image: debug.png]

This code essentially patches setTextsrc to display any arbitrary string if you call it with r4=0.
The easy way (but not the shortest) to do it is just to change the ASM contents of the last code. You need to call swprintf with the string of your choice. It uses the standard C printf formatting. 

The arguments for swprintf are:
r6 through r10 are your integer/pointer to char arguments (%d %c in the string)
f1 through f8 are your float arguments (%f in the string)

So you'd replace the original string by the one of your choice, eg:
.string16 "Integer1 %3d  Integer2 %1d \a Float1 %3.0f"

And there before swprintf gets called, you load your arguments:
lwz r6, 0x21 (r3)
lbz r7, 0x30 (r3)
lfs f1, 0x90 (r3)

This specific example would draw on the screen
Integer1 r6  Integer2 r7
Float1 f1

You can also hook at a different instruction, format your string (by calling swprintf and then making any modification to the string you'd want) there and then call setTxtsrc there, if your arguments loading is easier at that instruction.

I cannot find this cheat code anywhere online. Do you still have it?
There is a very similar code here:
My username is in Scottish Gaelic. If you speak that language, please tell me how to pronounce it properly.

The best source I've got so far is this:

Forum Jump:

Users browsing this thread: 4 Guest(s)