Oops, yeah, didn't think about that. The one in the demo is used with a style that displays text instantly, so the timing isn't an issue.
Ideally, it should move on to the screen at the start of the text and off again at the end, so:
int ShowMovingMessage(int message, int type, int style, float x)
{
int slot=Tango_GetFreeSlot(type);
if(slot==TANGO_INVALID)
return TANGO_INVALID;
int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
int movement2[]="@delay(240)@while(@less(@y 168) @inc(@y 3))";
Tango_ClearSlot(slot);
Tango_LoadString(slot, movement1);
Tango_AppendMessage(slot, message);
Tango_AppendString(slot, movement2);
Tango_SetSlotStyle(slot, style);
Tango_SetSlotPosition(slot, x, 168);
Tango_ActivateSlot(slot);
return slot;
}
Also, I don't know if you actually want that @delay() in there, but that's easy enough to remove.
How about this, as an option:
int ShowMovingMessage(int message, int type, int style, float x, int delayvalue)
{
Tango_D[0] = delayvalue;
int slot=Tango_GetFreeSlot(type);
if(slot==TANGO_INVALID)
return TANGO_INVALID;
int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
int movement2[]="@delay(@d0)@while(@less(@y 168) @inc(@y 3))";
Tango_ClearSlot(slot);
Tango_LoadString(slot, movement1);
Tango_AppendMessage(slot, message);
Tango_AppendString(slot, movement2);
Tango_SetSlotStyle(slot, style);
Tango_SetSlotPosition(slot, x, 168);
Tango_ActivateSlot(slot);
return slot;
}
I think it would be nice to expand the TangoD[] array to MAX_INT. by default... Nothijg should ever need to iterate through it as a loop; but even so, making it a size of 256 or greater by default would be useful, unless you already did that,
Use the first 8 indices for D* args from ffcs and such, but the rest could be reserved to store other values.
Otherwise values must be shifted into a global array first, and if they are values intended to be used only atthe scope of the function, you'd need to store their old value, change it while the functuion runs, then revert it afterward to whatever it was before the function ran, like this:
int ShowMovingMessage(int message, int type, int style, float x, int delayvalue)
{
int oldD0 = Tango_D[0];
Tango_D[0] = delayvalue;
int slot=Tango_GetFreeSlot(type);
if(slot==TANGO_INVALID)
return TANGO_INVALID;
int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
int movement2[]="@delay(@d0)@while(@less(@y 168) @inc(@y 3))";
Tango_ClearSlot(slot);
Tango_LoadString(slot, movement1);
Tango_AppendMessage(slot, message);
Tango_AppendString(slot, movement2);
Tango_SetSlotStyle(slot, style);
Tango_SetSlotPosition(slot, x, 168);
Tango_ActivateSlot(slot);
Tango_D[0] =int oldD0;
return slot;
}
...to preserve the old values, in the event that something else still needs the previous value. This wastes a reg, and a pop.
Also, maybe a direct way to access an array local to a function, or read values passed by function args?
Something like @locarr(*ptr,index)
Not sure how well that would work, as it'd need to convert a pointer by name?
Another thing I'd suggest, is to put all the code for accessing the main array for Tango, and the main array for Ghost, into their own files, so that if users want to merge these and modify the operations, all the accessors are in one place per header.
---
That aside, I think I'll put together a ticker-tape-style moving text function at some point, for you to include.
Too bad that we can't use bitmaps as textures for DrawQuad/DrawQuad3D. If we could, a 'Star Wars' style text crawl would be possible with very little extra work.
Edited by ZoriaRPG, 06 February 2016 - 03:21 AM.