// tango.zh
// Beta 2


// Standard settings -----------------------------------------------------------

// How fast messages scroll
const int __TANGO_SCROLL_SPEED = 4;

// How much holding A speeds up text
const int __TANGO_SPEEDUP_FACTOR = 5;

// Whether holding A or B speeds up scrolling to the next message
const int __TANGO_SCROLL_SPEEDUP = 1;

// Whether a sound is played when a space is printed
const int __TANGO_SFX_ON_SPACE = 0;

// Whether there's a delay before a space, as with printable characters
const int __TANGO_DELAY_ON_SPACE = 1;

// Strings that advance automatically will wait this long before doing so
const int __TANGO_AUTO_ADVANCE_TIME = 90;

// Layer to draw on
const int __TANGO_DRAWING_LAYER = 6;

// Offscreen bitmap to use for text rendering
const int __TANGO_BITMAP = 6;

// String codes are marked by this character
// 64 is @
const int __TANGO_CODE_DELIMITER = 64;

// Whether the current string scrolls up before displaying the next one
// rather than just disappearing
const int __TANGO_SCROLL_TO_NEXT = 1;

// The maximum length of a string handled by @string.
// Increasing this will make the function take more space in the buffer.
// It's not necessary to account for the null terminator.
const int __TANGO_MAX_STRING_FUNC_LENGTH = 16;

// End standard settings -------------------------------------------------------



// Advanced settings -----------------------------------------------------------

// Custom functions
int __Tango_CustomFunctions[] = {
    0 // Placeholder - remove this when you add a function
};

float __Tango_RunCustomFunction(float function, float args)
{
    return 0;
}

const int __TANGO_MAX_MENU_ITEMS = 16;
float __Tango_Data[73]; // 25+3*__TANGO_MAX_MENU_ITEMS

// Available styles
const int __TANGO_NUM_STYLES = 3;
int __Tango_Styles[78]; // __TANGO_SIZEOF_STYLE * __TANGO_NUM_STYLES
                         // __TANGO_SIZEOF_STYLE is currently 26

// Text buffer and slots
int __Tango_Buffer[1280]; // Arbitrary size

const int __TANGO_NUM_SLOTS = 5;
int __Tango_SlotData[90]; // __TANGO_SIZEOF_DATA * __TANGO_NUM_SLOTS
                            // __TANGO_SIZEOF_DATA is currently 17
                            //Saffith says this is now 18. Not sure if that applies to Tango_B2, or B3.

// Slot types and definitions
const int TANGO_SLOT_WINDOW = 0;

int __Tango_SlotDefs[] = {
    // 0
    TANGO_SLOT_WINDOW,
    0,        // Starting index in __Tango_StringBuffer
    256,      // Maximum length after processing
    0, 0,     // X, Y on offscreen bitmap
    256, 176, // Width, height on offscreen bitmap
    
    // 1
    TANGO_SLOT_WINDOW,
    512,
    256,
    256, 0,
    256, 176,
    
    //2
    TANGO_SLOT_WINDOW,
    512,
    256,
    0, 176,
    256, 176,
    
    //3
    TANGO_SLOT_WINDOW,
    768,
    256,
    256, 176,
    176, 176,

    //4
   TANGO_SLOT_WINDOW,
    1024,
    256,
    0, 256,
    256, 176
    };


// Edit these functions to change which buttons are used.

// Return Link->Press* for advance/end string button
bool __Tango_PressAdvance()
{
    return Link->PressA;
}

// Return Link->Input* for advance/end string button
bool __Tango_InputAdvance()
{
    return Link->InputA;
}

// Unset Link->Input* and Link->Press* for advance/end string button
void __Tango_UnpressAdvance()
{
    Link->InputA=false;
    Link->PressA=false;
}

// Return Link->Press* for speedup button
bool __Tango_PressSpeedup()
{
    return Link->PressA;
}

// Return Link->Input* for speedup button
bool __Tango_InputSpeedup()
{
    return Link->InputA;
}

// Unset Link->Input* and Link->Press* for speedup button
void __Tango_UnpressSpeedup()
{
    Link->InputA=false;
    Link->PressA=false;
}

// Return Link->Press* for super speed button
bool __Tango_PressSuperSpeed()
{
    return Link->PressB;
}

// Return Link->Input* for super speed button
bool __Tango_InputSuperSpeed()
{
    return Link->InputB;
}

// Unset Link->Input* and Link->Press* for super speed button
void __Tango_UnpressSuperSpeed()
{
    Link->InputB=false;
    Link->PressB=false;
}

// Return Link->Press* for menu select button
bool __Tango_PressMenuSelect()
{
    return Link->PressA;
}

// Return Link->Press* for menu cancel button
bool __Tango_PressMenuCancel()
{
    return Link->PressB;
}

// Return Link->Input* for both menu select and cancel buttons
bool __Tango_InputMenu()
{
    return Link->InputA || Link->InputB;
}

// Unset Link->Input* and Link->Press* for menu select and cancel buttons
void __Tango_UnpressMenu()
{
    Link->InputA=false;
    Link->PressA=false;
    Link->InputB=false;
    Link->PressB=false;
}

// These are used by TANGO_FLAG_FREEZE_SCREEN.
void __Tango_FreezeScreen()
{
ffc freezer=Screen->LoadFFC(31);    
freezer->Data=1708;    
freezer=Screen->LoadFFC(FFC_FREEZE_2);    
freezer->Data=0;    
SuspendGhostZHScripts();
}

void __Tango_UnfreezeScreen()
{
ffc freezer=Screen->LoadFFC(31);    
freezer->Data=0;    
freezer=Screen->LoadFFC(FFC_FREEZE_2);    
freezer->Data=0;    
ResumeGhostZHScripts();
}



// Use this instead of Waitframe() in any FFCs you want to be able to suspend.

void FFCWaitframe(){    
do {        
    Waitframe();    
} 
while(ffcsSuspended);
}

// Import stringControlCode.zh instead of stringControlCodeDisabled.zh
// to enable string control codes.
import "tango/stringControlCodeDisabled.zh"
//import "tango/stringControlCode.zh"

// Import loggingFull.zh instead of loggingMinimal.zh for more useful
// error messages. This will bloat scripts, so it should only be used
// for debugging.
import "tango/loggingMinimal.zh"
//import "tango/loggingFull.zh"

// End advanced settings -------------------------------------------------------


import "tango/common.zh"
import "tango/drawing.zh"
import "tango/font.zh"
import "tango/functions.zh"
import "tango/loading.zh"
import "tango/menu.zh"
import "tango/messages.zh"
import "tango/metrics.zh"
import "tango/processing.zh"
import "tango/style.zh"
import "tango/user.zh"
import "tango/validation.zh"

import "tango/script.z"

