DEFINITION MODULE WMain;

IMPORT Windows,ApplDlg,Str;
FROM Storage IMPORT ALLOCATE,DEALLOCATE;
FROM Lib IMPORT RANDOMIZE,RANDOM;

CONST
(* String table constants *)
  IDSNAME  =   100;
  IDSABOUT =   200;
  IDSTITLE =   300;
  IDSMESSAGE = 400;
  IDSCAPTION = 500;
  IDSDEFSPEC = 501;
  IDSDEFEXT  = 502;

(* About Dialog box resource id *)
  ABOUTBOX =     1;
  FISHSELECT =   2;
  LIFEDATABOX =  3;
  FISHINFOBOX =  4;

(* Fish Select Box Controls *)
  IDC_FILENAME =   400;
  IDC_EDIT     =   401;
  IDC_FILES    =   402;
  IDC_PATH     =   403;
  IDC_LISTBOX  =   404;

  IDSAVERAGECHECK =  114;
  IDSBACK        =  119;
  IDSCANCEL      =  118;
  IDSFASTCHECK   =  115;
  IDSFISHNAME    =  108;
  IDSGROUPBOX    =  110;
  IDSHOWMANY     =  116;
  IDSHOWMANYTEXT =  112;
  IDSNEXT        =  120;
  IDSOK          =  117;
  IDSSELECTED    =  109;
  IDSSLOWCHECK   =  113;


(* icon name *)
  AQUAICON =     1;

  SLOWSPEED    =       2;
  AVERAGESPEED =       4;
  FASTSPEED    =       6;

TYPE
    NameType = ARRAY [0..15] OF CHAR;

    InstancePtr = POINTER TO FishInstance;

    FishInstance = RECORD
                      bmapno         : CARDINAL;
                      direction      : CARDINAL;
                      xpos           : INTEGER;
                      ypos           : INTEGER;
                      speedx         : INTEGER;
                      speedy         : INTEGER;
                      pspeedx        : INTEGER;
                      pspeedy        : INTEGER;
                      NextInstance   : InstancePtr
                   END;

    Fish    = RECORD
                 name           : NameType;
                 bmap           : ARRAY[1..2],[1..4] OF Windows.HBITMAP;
                 bmapno         : CARDINAL;
                 DialogFrame    : CARDINAL;
                 status         : BOOLEAN;
                 turnbmap       : Windows.HBITMAP;
                 xpos           : INTEGER;
                 ypos           : INTEGER;
                 xextent        : INTEGER;
                 yextent        : INTEGER;
                 headwidth      : INTEGER;
                 speedx         : INTEGER;
                 speedy         : INTEGER;
                 pspeedx        : INTEGER;
                 pspeedy        : INTEGER;
                 basespeed      : INTEGER;
                 frequency      : CARDINAL;
                 direction      : CARDINAL;
                 TimerId        : INTEGER;
                 Instances      : CARDINAL;
                 Other          : InstancePtr;
               END;


VAR
  szAppName: ARRAY [0..9] OF CHAR;
  szAbout: ARRAY [0..9] OF CHAR;
  szMessage: ARRAY [0..25] OF CHAR;
  mycaption,mymessage : ARRAY [0..25] OF CHAR;
  MessageLength: CARDINAL;

  FileName,PathName,OpenName,DefPath : ARRAY[0..128] OF CHAR;
  szDefSpec : ARRAY[0..13] OF CHAR;
  szDefExt  : ARRAY[0..5] OF CHAR;
  FStr      : ARRAY[0..255] OF CHAR;
  szPath    : ARRAY [0..127] OF CHAR;
  szMask    : ARRAY [0..127] OF CHAR;

  hInst: Windows.HANDLE;

  RealXYRect :Windows.RECT;

  FishHead  : ARRAY [0..10] OF Fish;
  FishSelected,FishMax : INTEGER;
  InstanceHead : InstancePtr;

(*# name(prefix=>windows) *)
(*# call(near_call=> off, reg_param=>()) *)

(*# save *)
(*# call(windows=>on) *)

PROCEDURE MainWndProc( hWindow : Windows.HWND;
                        message : CARDINAL;
                        wParam  : CARDINAL;
                        lParam  : LONGINT ) : LONGINT ;

(*# restore *)


PROCEDURE WinMain( hInstance    : Windows.HANDLE;
                  hPrevInstance : Windows.HANDLE;
                  lpszCmdline   : Windows.LPSTR;
                  cmdShow       : INTEGER ) : Windows.BOOL ;

PROCEDURE StopAllTimers(hWnd : Windows.HWND);

PROCEDURE StartAllTimers(hWnd : Windows.HWND);

PROCEDURE QuickDeleteRgns(hWnd  : Windows.HWND);

END WMain.