{$N+,A+,G+,F+,D-,E-,L-,R-,S-,Q-,Y-,I-}
{DEFINE release_mode_compile}

unit global;

interface

uses  mplayer;

const count_res=100; {<---WARNING, THIS IMPORTANT VALUE!}

{$IFDEF release_mode_compile}
        const
        release_mode=1;
        filenames_size_array=1;
{$ELSE}
        const
        release_mode=0;
        filenames_size_array=64;
{$ENDIF}

type
  colour = record
  r,g,b : byte;
  end;

var
    info : PmpInformation;
    MP : PModulePlayer;
    module : PmpModule;
    scrsync, i, error, isConfig : word;
    oldframe, mtimer:word;

    progressbar_color:colour;

    ESC_PRESSED, UseXMS, MusicStart : byte;
    Debug_mode, FPS_mode, Vsync_mode, S3MParam_mode:byte;

    seg_font6x6_d,ofs_font6x6_d, vaddr, vaddr2, vaddr3, Seg_palitra, Ofs_palitra : word;


    general_datafile_mode:byte;
    General_datafile_name:string[12];
    res_counter:word;
    res_names    :array[1..count_res] of string[16];
    res_length   :array[1..count_res] of longint;
    res_handler  :array[1..count_res] of word;
    res_offset   :array[1..count_res] of longint; {offset in XMS handle-block}
    res_numscene :array[1..count_res] of byte;
    res_df_offset:array[1..count_res] of longint; {offset in data-file}
    res_packed   :array[1..count_res] of byte; {packed or not (0,1)}

    Handler_counter:byte;
    Handler_list :array[1..32] of word;
    Handler_fillsize :array[1..32] of longint;

    progress:single;

    procedure Midas_WaitVR;
    function music_pos(pos, row:word): boolean;
    procedure wait_music_pos(pos, row:word);
    function esc_test:boolean;


implementation

procedure Midas_WaitVR;
begin
   oldframe:=mtimer;repeat until oldframe<>mtimer;
end;

function esc_test:boolean;
begin
if port[$60]=1 then begin
          ESC_PRESSED:=1;
          esc_test:=true;
          end
          else esc_test:=false;
end;

function music_pos(pos, row:word): boolean;
var position:word;
begin
position:=word(info^.pos) shl 8  + byte(info^.row);

if position >= pos shl 8 + row then music_pos:=true
   else music_pos:=false;
end;


procedure wait_music_pos(pos, row:word);
var position:word;
begin
  repeat
     MP^.GetInformation(@info);
     position:=word(info^.pos) shl 8 + info^.row;

     Midas_WaitVR;
  until (esc_test) or (position >= pos shl 8 + row);
end;


begin

UseXMS:=1;
debug_mode:=0;
fps_mode:=0;
Vsync_mode:=1;
S3Mparam_mode:=0;

progressbar_color.r:=32;
progressbar_color.g:=32;
progressbar_color.b:=42;


{no change!}
mtimer:=0;
MusicStart:=0;
ESC_PRESSED:=0;

end.