/*
 * RoboCook - Release 1 - Common header includes/defines/etc...
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <exec/libraries.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/nodes.h>
#include <exec/lists.h>

#include <devices/keymap.h>

#include <graphics/gfxbase.h>
#include <graphics/displayinfo.h>

#include <intuition/intuitionbase.h>
#include <intuition/intuition.h>

#include <dos/dos.h>
#include <dos/rdargs.h>
#include <dos/dostags.h>

#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>

#include <libraries/asl.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/gadtools.h>
#include <libraries/mui.h>

#include <workbench/startup.h>
#include <workbench/workbench.h>
#include <workbench/icon.h>

#include <clib/alib_protos.h>

#include <proto/asl.h>
#include <proto/diskfont.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/icon.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <proto/utility.h>
#include <proto/wb.h>

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <dos.h>
#include <math.h>


/*
 * When user clicks OK or CANCEL, pass this to the window Destruct routine
 * so it can take apropriate action (store the entered info or discard it).
 */
#define ENDWINDOW_OK       TRUE
#define ENDWINDOW_CANCEL   FALSE


/*
 * Define delimeters for separation of dynamic-length strings in data file.
 */
#define LEVEL1BREAK  255
#define LEVEL2BREAK  254
#define LEVEL3BREAK  253
#define NULLSPACE    252

/*
 * ADD/CHANGE Mode definitions
 */
#define ADD_MODE     1
#define CHANGE_MODE  2

/*
 * FILE HEADERS
 */
#define FILEID_HEADER      "ROBOCOOK_JMH2AMI"
#define FILEID_NEW         "NEW "
#define FILEID_OLD         "OLD "

/*
 * FILE RECORD ITEM LOOKUP IDs
 */
#define RECITEM_COMMENTS         1
#define RECITEM_PICFILESPEC      2
#define RECITEM_INGREDIENTS      3
#define RECITEM_DIRECTIONS       4
#define RECITEM_TIMERLIST        5
#define RECITEM_PSZRESERVED1     6
#define RECITEM_PSZRESERVED2     7
#define RECITEM_PSZRESERVED3     8

/*
 * LABEL COUNTS
 */
#define LABEL_ADDOVEN        4
#define LABEL_ADDCOURSE      8
#define LABEL_ADDPAGES       4
#define LABEL_FINDPREP       6
#define LABEL_FINDCOST       4
#define LABEL_FINDTASTE      6
#define LABEL_TIMERTIMER     4
#define LABEL_SETTINGSSOUND  4
#define LABEL_SETTINGSREPEAT 3
#define LABEL_SETTINGSSEX    3
#define LABEL_SETTINGSTYPE   3
#define LABEL_SETTINGSPAGES  6
// #define LABEL_MAKEOUTPUT     4
#define LABEL_MAKEOUTPUT     3
#define LABEL_MAKELOCLPAGES  4
#define LABEL_ADDPREPORBAKE  3


/*
 * MESSAGE IDs -----------------------------
 */

// CLOSE WINDOW IDs
#define ID_WIN_CLOSE_MAIN         101
#define ID_WIN_CLOSE_ADD          102
#define ID_WIN_CLOSE_CATEGORY     103
#define ID_WIN_CLOSE_MAKE         104
#define ID_WIN_CLOSE_FIND         105
#define ID_WIN_CLOSE_DETAILS      106
#define ID_WIN_CLOSE_TIMER        107
#define ID_WIN_CLOSE_REORG        109
#define ID_WIN_CLOSE_SPEAKXP      110
#define ID_WIN_CLOSE_GROCLIST     111
#define ID_WIN_CLOSE_SETTINGS     112
#define ID_WIN_CLOSE_MAKELOCL     113

// MAIN WINDOW - MENUS
#define ID_MENU_ABOUT            1001
#define ID_MENU_QUIT             1002
#define ID_MENU_FIND             1101
#define ID_MENU_FINDNEXT         1102
#define ID_MENU_CONVERSIONS      1202
#define ID_MENU_SYSTEMCALC       1203
#define ID_MENU_SPEAKER          1204
#define ID_MENU_REORGANIZE       1205
#define ID_MENU_TIMERS           1207
#define ID_MENU_PRINTERSETUP     1208
#define ID_MENU_SETTINGS         1209

// MAIN WINDOW - GADGETS
#define ID_LIS_MAINRECIPELIST    1601
#define ID_CYC_MAINVIEWBYCYCLE   1602
#define ID_BUT_MAINADD           1603
#define ID_BUT_MAINFIND          1604
#define ID_BUT_MAINFINDNEXT      1605
#define ID_BUT_MAINCHANGE        1606
#define ID_BUT_MAINSHOW          1607
#define ID_BUT_MAINMAKE          1608
#define ID_BUT_MAINMARK          1609
#define ID_BUT_MAINUNMARK        1610
#define ID_BUT_MAINDELETE        1611


// ADD WINDOW - MENUS

// ADD WINDOW - GADGETS
#define ID_BUT_ADDADD               2001
#define ID_BUT_ADDCANCEL            2002
#define ID_BUT_ADDCATEGORY          2003
#define ID_STR_ADDITEM              2004
#define ID_STR_ADDDIRECTION         2005
#define ID_BUT_ADDDIRECTIONNEW      2006
#define ID_BUT_ADDDIRECTIONDEL      2007
#define ID_BUT_ADDDIRECTIONCLEAR    2008
#define ID_BUT_ADDINGREDIENTNEW     2009
#define ID_BUT_ADDINGREDIENTDEL     2010
#define ID_BUT_ADDINGREDIENTCLEAR   2011
#define ID_STR_ADDINGREDIENTCHANGE  2012
#define ID_STR_ADDDIRECTIONCHANGE   2013
#define ID_BUT_ADDTIMERNEW          2014
#define ID_BUT_ADDTIMERDEL          2015
#define ID_BUT_ADDTIMERCLEAR        2016
#define ID_BUT_ADDTIMERUPDATE       2017
#define ID_STR_ADDTIMERLISTCHANGE   2018

// CATEGORY WINDOW - MENUS

// CATEGORY WINDOW - GADGETS
#define ID_BUT_CATCANCEL         3001
#define ID_BUT_CATSELECT         3002
#define ID_LIS_CATCATEGORIES     3003
#define ID_LIS_CATLISTCHANGE     3004


// MAKE WINDOW - MENUS

// MAKE WINDOW - GADGETS
#define ID_LIS_MAKERECIPECHANGE  4001
#define ID_BUT_MAKEGROCLIST      4002
#define ID_STR_MAKENEWSERVINGS   4003
#define ID_BUT_MAKEOUTPUT        4004
#define ID_BUT_MAKECANCEL        4005


// FIND WINDOW - MENUS

// FIND WINDOW - GADGETS
#define ID_BUT_FINDFIND          5001
#define ID_BUT_FINDFINDNEXT      5002
#define ID_BUT_FINDCLEAR         5003
#define ID_BUT_FINDCANCEL        5004


// DETAILS WINDOW - MENUS

// DETAILS WINDOW - GADGETS
#define ID_CYC_DETCOURSE         6001
#define ID_BUT_DETCANCEL         6002


// REORG WINDOW - MENUS

// REORG WINDOW - GADGETS
#define ID_BUT_REORGREORG        7001
#define ID_BUT_REORGCANCEL       7002


// TIMER WINDOW - MENUS

// TIMER WINDOW - GADGETS
#define ID_CHE_TIMERPAUSE        8001
#define ID_BUT_TIMERREMOVE       8002
#define ID_BUT_TIMERALARMCONFIG  8003
#define ID_LIS_TIMERLISTCHANGE   8004
#define ID_BUT_TIMERCANCEL       8005


// SETTINGS WINDOW - MENUS

// SETTINGS WINDOW - GADGETS
#define ID_SLI_SETTINGSUPDATEPROP   9001
#define ID_SLI_SETTINGSPITCHLEVEL   9002
#define ID_SLI_SETTINGSSPEEDLEVEL   9003
#define ID_BUT_SETTINGSSAVE         9004
#define ID_BUT_SETTINGSUSE          9005
#define ID_BUT_SETTINGSCANCEL       9006


// SPEAKER EXCEPTIONS WINDOW - MENUS

// SPEAKER EXCEPTIONS WINDOW - GADGETS
#define ID_LIS_SPEAKXPLIST       10002
#define ID_BUT_SPEAKXPNEW        10003
#define ID_BUT_SPEAKXPDELETE     10004
#define ID_BUT_SPEAKXPTEST       10005
#define ID_STR_SPEAKXPFROM       10006
#define ID_STR_SPEAKXPTO         10007
#define ID_BUT_SPEAKXPSAVE       10008
#define ID_BUT_SPEAKXPCANCEL     10009


// GROCERY LIST WINDOW - MENUS

// GROCERY LIST WINDOW - GADGETS
#define ID_BUT_GROCLISTPRINT     11001
#define ID_BUT_GROCLISTCANCEL    11002

// MAKE LOCAL WINDOW - MENUS

// MAKE LOCAL WINDOW - GADGETS
#define ID_BUT_MAKELOCLPREVRECIPE   12001
#define ID_BUT_MAKELOCLNEXTRECIPE   12002
#define ID_BUT_MAKELOCLSTARTTIMER   12003
#define ID_BUT_MAKELOCLCANCEL       12004


/*
 * GENERAL DEFINES ----------------------------------
 */
#define MAX( a,b )   ( ( (a) > (b) ) ? (a) : (b) )
#define MIN( a,b )   ( ( (a) < (b) ) ? (a) : (b) )
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))

#define SUCCESS 0L
#define FAILURE 1L
#define STOPRUN -1

#define REG(x) register __ ## x
#define ASM    __asm
#define SAVEDS __saveds


/*
 * MACROS -------------------------------------------
 */
#define KeyButtonMax(name,key)\
   TextObject,\
      ButtonFrame,\
      MUIA_Text_SetMax  , TRUE,\
      MUIA_Text_Contents, name,\
      MUIA_Text_PreParse, "\33c",\
      MUIA_Text_HiChar  , key,\
      MUIA_ControlChar  , key,\
      MUIA_InputMode    , MUIV_InputMode_RelVerify,\
      MUIA_Background   , MUII_ButtonBack,\
      End

#define PopupText(ptr,hook,img)\
   HGroup, GroupSpacing(1),\
      Child, ptr = TextObject, TextFrame, End,\
      Child, dummy = ImageObject,\
         ImageButtonFrame,\
         MUIA_Image_Spec          , img,\
         MUIA_Image_FontMatchWidth, TRUE,\
         MUIA_Image_FreeVert      , TRUE,\
         MUIA_InputMode           , MUIV_InputMode_RelVerify,\
         MUIA_Background          , MUII_BACKGROUND,\
         End,\
      TAG_IGNORE, dummy && ptr ? DoMethod(dummy,MUIM_Notify,MUIA_Pressed,FALSE,ptr,2,MUIM_CallHook,hook) : 0,\
      End


/*
 * STRUCTURE DEFINITIONS ----------------------------
 */
struct MyGlobals {
   APTR  App;

   // Window Objects
   APTR  WIN_Main,
         WIN_Add,
         WIN_Category,
         WIN_Make,
         WIN_Find,
         WIN_ReOrg,
         WIN_Timer,
         WIN_SpeakXP,
         WIN_GrocList,
         WIN_Settings,
         WIN_MakeLocal;

   // Disk Usage Variables
   ULONG  ulTotalFileSize,
          ulNullSpaceSize;

   // Settings
   char  szMeasureList[ FMSIZE+1 ];
   char  szGfxViewer[ FMSIZE+1 ];
   char  szPrinterPrefsProg[ FMSIZE+1 ];
   char  szSysCalculator[ FMSIZE+1 ];
   char  szSpeakXPList[ FMSIZE+1 ];
   char  szCategoryList[ FMSIZE+1 ];
   char  szAlarmFilespec[ FMSIZE+1 ];

   char               szReOrgDir[ FMSIZE+1 ];
   struct DiskObject *dobj_App;
   char               szRecipeFilespec[ FMSIZE+1 ];
   BPTR               fhRecipes;
   UBYTE              ubAddOrChangeMode;
};

struct RecipeMemNode {
   UBYTE        ubSelected;      // 0 = Not selected; 1 = Selected
   char        *pszCategoryName;
   UBYTE        ubCourse;
   UBYTE        ubPrepRating;
   UBYTE        ubCostRating;
   UBYTE        ubTasteRating;
   UBYTE        ubOven;
   UBYTE        ubAdjustTimer;
   UBYTE        ubReserved1;
   UBYTE        ubReserved2;
   char        *pszServings;
   char        *pszRecipeName;
   char        *pszSource;
   char        *pszReserved0;    // future expansion
   char        *pszReserved1;    // future expansion
   char        *pszReserved2;    // future expansion
   char        *pszReserved3;    // future expansion
   ULONG        ulDiskAddr;
   APTR         pStringPool;
};

struct MakeNode
{
   ULONG  ulMainListIndex;
   char  *pszRecipeName;
   char   szStdServings[3+1];
   char   szNewServings[3+1];
   BOOL   fAdjustTimes;
   APTR   pMemPool;
};

struct TimersNode
{
   char  szTimerName[35+1];
   char  szPrepOrBake[4+1];
   char  szHMSTime[8+1];
};

struct TimerDefNode
{
   UBYTE  ubPaused;
   char   szTime[8+1];
   char   szDoneTime[8+1];
   char   szRecipeName[30+1];
};

struct MainWindow {
   APTR  CYC_ViewBy,
         LIS_RecipeList,
         TXT_NumSelected,
         BUT_Mark,
         BUT_UnMark,
         BUT_Delete,
         BUT_Add,
         BUT_Find,
         BUT_FindNext,
         BUT_Change,
         BUT_Show,
         BUT_Make;
};
struct AddWindow {
   APTR  BUT_Category,
         TXT_CurrentCategory,
         STR_RecipeName,
         STR_Comment,
         POP_PicFilespec,
         CYC_Preparation,
         CYC_Cost,
         CYC_Taste,
         CYC_Oven,
         STR_Source,
         CYC_Course,
         STR_Serves,
         REG_IDTPage,
         LIS_Ingredients,
         STR_Item,
         BUT_IngredientNew,
         BUT_IngredientDel,
         BUT_IngredientClear,
         LIS_Directions,
         STR_Direction,
         BUT_DirectionNew,
         BUT_DirectionDel,
         BUT_DirectionClear,
         TXT_OverallTime,
         LIS_Timers,
         BUT_TimerNew,
         BUT_TimerDel,
         BUT_TimerClear,
         CHE_AdjustTimer,
         STR_TimerName,
         CYC_TimerType,
         SLI_TimerHours,
         SLI_TimerMinutes,
         SLI_TimerSeconds,
         BUT_TimerUpdate,
         BUT_Add,
         BUT_Cancel;
};
struct CategoryWindow {
   APTR  LIS_Categories,
         STR_Category,
         BUT_Select,
         BUT_Cancel;
};
struct MakeWindow {
   APTR  LIS_Recipes,
         BUT_GroceryList,
         STR_Servings,
         MX_Output,
         CHE_Video,
         CHE_Speech,
         BUT_Output,
         BUT_Cancel;
};
struct FindWindow {
   APTR  CHE_RecipeName,   STR_RecipeName,
         CHE_Comment,      STR_Comment,
         CHE_Course,       CYC_Course,
         CHE_Category,     POP_Category,
         CHE_Source,       STR_Source,
         CHE_Serves,       STR_Serves,
         CHE_Preparation,  CYC_Preparation,
         CHE_Cost,         CYC_Cost,
         CHE_Taste,        CYC_Taste,
         CHE_Oven,         CYC_Oven,
         CHE_Ingredient,   STR_Ingredient,
         CHE_Time,
         SLI_TimerHours,   SLI_TimerMinutes,    SLI_TimerSeconds,
         BUT_Find,
         BUT_FindNext,
         BUT_ClearChex,
         BUT_Cancel;
};
struct ReOrgWindow {
   APTR  FLO_ReOrgText,
         POP_ToReOrg,
         GAU_Progress,
         BUT_ReOrg,
         BUT_Cancel;
};
struct TimerWindow {
   APTR  LIS_TimerList,
         CHE_Pause,
         BUT_Remove,
         BUT_AlarmConfig,
         BUT_OK;
};
struct SpeakerExceptionsWindow {
   APTR  CYC_ViewBy,
         LIS_SpeakerExceptions,
         BUT_New,
         BUT_Delete,
         BUT_Test,
         STR_From,
         STR_To,
         BUT_Save,
         BUT_Cancel;
};
struct GroceryListWindow {
   APTR  LIS_GroceryList,
         BUT_Print,
         BUT_Cancel;
};
struct SettingsWindow {
   APTR  REG_Page,
         POP_MeasureListspec,
         POP_GfxViewer,
         POP_DisplayFont,
         POP_PrinterPrefsProg,
         POP_SysCalculator,
         POP_SpeakXPList,
         POP_CategoryList,
         CHE_PrinterFormFeed,
         CYC_SpeakerSex,
         CYC_SpeakerType,
         SLI_Pitch,
         SLI_Speed,
         TXT_PitchLevel,
         TXT_SpeedLevel,
         MX_Sound,
         POP_AlarmFilespec,
         STR_SpeakString,
         MX_Repeat,
         STR_NTimes,
         SLI_EveryXSeconds,
         TXT_Seconds,
         BUT_Save,
         BUT_Use,
         BUT_Cancel;
};

struct MakeLocalWindow {
   APTR  REG_PageIngDir,
         LIS_IngList,
         LIS_DirList,
         LIS_TimerList,
         BUT_StartTimer,
         CHE_OpenTimerWindow,
         BUT_PrevRecipe,
         BUT_NextRecipe,
         BUT_Cancel;
};

#ifndef MODULE_MAIN

/*
 * GLOBAL VARIABLES ---------------------------------
 */
extern struct MyGlobals MG;

extern struct MainWindow               MAIN;
extern struct AddWindow                ADD;
extern struct CategoryWindow           CAT;
extern struct MakeWindow               MAKE;
extern struct FindWindow               FIND;
extern struct ReOrgWindow              REORG;
extern struct TimerWindow              TIMER;
extern struct SpeakerExceptionsWindow  SPEAKXP;
extern struct GroceryListWindow        GROCLIST;
extern struct SettingsWindow           SETTINGS;
extern struct MakeLocalWindow          MAKELOCL;

extern APTR dummy;    // for Popup() macro...

extern char  GL_szFault[ FAULT_MAX * 2 ];
extern char  GL_szReOrgStat[ 256 ];
extern char  GL_szBuf[ 256 ];
extern LONG  GL_lFindStart;
extern char  GL_szNumSelectedStat[ 50 ];

/*
 * LIBRARY VARIABLES ---------------------------------
 */
extern struct Library       *DosBase;
extern struct IntuitionBase *IntuitionBase;
extern struct Library       *WorkbenchBase;
extern struct GfxBase       *GfxBase;
extern struct Library       *GadToolsBase;
extern struct Library       *DiskfontBase;
extern struct Library       *AslBase;
extern struct Library       *IconBase;
extern struct Library       *UtilityBase;
extern struct Library       *MUIMasterBase;
extern struct Library       *NarratorBase;
extern struct Library       *TranslatorBase;
#endif


/*
 * APPLICATION FUNCTION PROTOTYPES ------------------
 */
/*
 * MODULE JMHSUBS -----------------------------------
 */
#ifdef MODULE_JMHSUBS
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION void         JMH_About( void );
FUNCTION LONG         JMH_Error( char *, APTR, char *, char *, LONG );
FUNCTION struct Node *JMH_FindNode( struct List *, UWORD );
FUNCTION void         JMH_InitVars( void );
FUNCTION void         JMH_Startup( int, char ** );
FUNCTION void         JMH_Quit( char * );
FUNCTION BOOL         JMH_Write( BPTR, APTR, ULONG );


/*
 * MODULE STORAGE -----------------------------------
 */
#ifdef MODULE_STORAGE
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION APTR  fnCheckHeader( char *, char *, ULONG );
FUNCTION APTR  fnFetchRecord( ULONG );
FUNCTION BOOL  fnDeleteRecord( LONG );
FUNCTION BOOL  fnMakeListRecord( void );
FUNCTION SHORT fnSkipNullSpaces( ULONG * );
FUNCTION BOOL  fnReadRecipeData( BOOL );
FUNCTION BOOL  fnReadListFromDisk( char *, APTR, ULONG, char * );
FUNCTION BOOL  fnWriteListToDisk( char *, APTR );


/*
 * MODULE ADDDET ------------------------------------
 */
#ifdef MODULE_ADDDET
#define FUNCTION
#else
#define FUNCTION extern
FUNCTION UBYTE *Add_OvenCYCLabels[ LABEL_ADDOVEN ];
FUNCTION UBYTE *Details_CourseCYCLabels[ LABEL_ADDCOURSE ];
FUNCTION UBYTE *Add_IngDirTimCYCLabels[ LABEL_ADDPAGES ];
FUNCTION UBYTE *Add_PrepOrBakeCYCLabels[ LABEL_ADDPREPORBAKE ];

FUNCTION char  szOverallTimeText[50];
#endif

FUNCTION void  fnRecalcOverallTime( void );
FUNCTION BOOL  fnConstructAddWindow( void );
FUNCTION BOOL  fnInitAddWindow( void );
FUNCTION BOOL  fnDestructAddWindow( BOOL );
FUNCTION BOOL  fnInitDetWindow( void );
FUNCTION BOOL  fnDestructDetWindow( BOOL );


/*
 * MODULE CATEGORY ----------------------------------
 */
#ifdef MODULE_CATEGORY
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION BOOL  fnConstructCatWindow( void );
FUNCTION BOOL  fnInitCatWindow( void );
FUNCTION BOOL  fnDestructCatWindow( BOOL );


/*
 * MODULE MAKE --------------------------------------
 */
#ifdef MODULE_MAKE
#define FUNCTION
#else
#define FUNCTION extern
FUNCTION UBYTE *Make_OutputMXLabels[ LABEL_MAKEOUTPUT ];
#endif

FUNCTION BOOL  fnConstructMakeWindow( void );
FUNCTION BOOL  fnInitMakeWindow( void );
FUNCTION BOOL  fnDestructMakeWindow( BOOL );


/*
 * MODULE FIND --------------------------------------
 */
#ifdef MODULE_FIND
#define FUNCTION
#else
#define FUNCTION extern
FUNCTION UBYTE *Find_PrepCYCLabels[ LABEL_FINDPREP ];
FUNCTION UBYTE *Find_CostCYCLabels[ LABEL_FINDCOST ];
FUNCTION UBYTE *Find_TasteCYCLabels[ LABEL_FINDTASTE ];
#endif

FUNCTION LONG fnFind( LONG lStartAt );
FUNCTION BOOL fnConstructFindWindow( void );
FUNCTION BOOL fnInitFindWindow( void );
FUNCTION BOOL fnDestructFindWindow( BOOL );


/*
 * MODULE REORG -------------------------------------
 */
#ifdef MODULE_REORG
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION BOOL  fnConstructReOrgWindow( void );
FUNCTION BOOL  fnInitReOrgWindow( void );
FUNCTION BOOL  fnDestructReOrgWindow( BOOL );


/*
 * MODULE TIMER -------------------------------------
 */
#ifdef MODULE_TIMER
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION BOOL fnConstructTimerWindow( void );
FUNCTION BOOL fnInitTimerWindow( void );
FUNCTION BOOL fnDestructTimerWindow( BOOL );


/*
 * MODULE SPEAKXP -----------------------------------
 */
#ifdef MODULE_SPEAKXP
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION BOOL  fnConstructSpeakXPWindow( void );
FUNCTION BOOL  fnInitSpeakXPWindow( void );
FUNCTION BOOL  fnDestructSpeakXPWindow( BOOL );


/*
 * MODULE GROCLIST ----------------------------------
 */
#ifdef MODULE_GROCLIST
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION void  fnFillIngredientsList( APTR, ULONG, struct MakeNode * );
FUNCTION BOOL  fnConstructGrocListWindow( void );
FUNCTION BOOL  fnInitGrocListWindow( void );
FUNCTION BOOL  fnDestructGrocListWindow( BOOL );


/*
 * MODULE SETTINGS ----------------------------------
 */
#ifdef MODULE_SETTINGS
#define FUNCTION
#else
#define FUNCTION extern
FUNCTION UBYTE *Settings_SexCYCLabels[ LABEL_SETTINGSSEX ];
FUNCTION UBYTE *Settings_TypeCYCLabels[ LABEL_SETTINGSTYPE ];
FUNCTION UBYTE *Settings_PageCYCLabels[ LABEL_SETTINGSPAGES ];
FUNCTION UBYTE *Settings_SoundsMXLabels[ LABEL_SETTINGSSOUND ];
FUNCTION UBYTE *Settings_NoSpeechMXLabels[ LABEL_SETTINGSSOUND - 1 ];
FUNCTION UBYTE *Settings_RepeatMXLabels[ LABEL_SETTINGSREPEAT ];
#endif

FUNCTION BOOL  fnConstructSettingsWindow( void );
FUNCTION BOOL  fnInitSettingsWindow( void );
FUNCTION BOOL  fnDestructSettingsWindow( BOOL );


/*
 * MODULE MAKELOCL ----------------------------------
 */
#ifdef MODULE_MAKELOCL
#define FUNCTION
#else
#define FUNCTION extern
FUNCTION UBYTE *MakeLocal_PageCYCLabels[ LABEL_MAKELOCLPAGES ];
#endif

FUNCTION BOOL  fnConstructMakeLocalWindow( void );
FUNCTION BOOL  fnInitMakeLocalWindow( void );
FUNCTION BOOL  fnDestructMakeLocalWindow( BOOL );


/*
 * MODULE MAIN --------------------------------------
 */
#ifdef MODULE_MAIN
#define FUNCTION
#else
#define FUNCTION extern
#endif

FUNCTION ULONG  fnFindRecordItem( UBYTE *, ULONG, char * );
FUNCTION BOOL   fnFloat2Frac( float, char * );
FUNCTION void   fnFrac2Float( char *, float * );
FUNCTION char  *fnSkipQuantity( char * );
FUNCTION float  fnExtractValue( UBYTE * );

FUNCTION BOOL   fnConstructMainWindow( void );
FUNCTION BOOL   fnInitMainWindow( void );
