Andy O. was tasked with porting a Pascal-based system running inside of an Atari-emulator to a more modern platform. Being neither a Pascal- or Atari-wiz, Andy was a bit weary of the project. "Don't worry," the original programmer reassured him, "everything should be clear." Andy's concern was assuaged for a little while, until he looked at the global declarations of the program ...

label 8888,9998,9999; 
  const inpfl = ' input file: ';
  mdkfil___ = 'mdco___.mdk';
  alfn      = 'mdconvr.Ã '; { formerly .MFO, earlier .DAT }
  n_mtrls = 5; n_parms = 12; n_midsp = 2; idfirst = -3;
  n_strms = 3; sndf = 13; midf = 14; 
    idflast = 14; {n_parms+n_midsp;sndf=parameter sound/controller; midf=param MidiChannel}
  n_prgs = 32; mx_mtrs = 6; mx_puls = 256; mx_scls = 6; mx_lyrs = 10;
  mouse_accel = 0.9; mouse_start_wait = 50 { ticks @ 5ms = 250ms };
  mx_tnl_dg = 12; mx_chdsz = 3; mx_evt_dns = 24; mx_midO = 9; titY = mx_y;
  rt_X = 57; rt_Y = 14; ct_X = 41; tmA_Y = 22; tmZ_Y = 23; tmN_Y = tmZ_Y;
  upr_lnY = 334; lwr_lnY = 17; d_idfY = 13; d_rlgY = 10; Mpatches = 6;
  mtrl_dspW = 96; mtrl_dspH = 24; emxp = 32; { mx_puls/8 (s.above) }
  ln_pdqs = 40; {=mx_x/16} pdqadr_arrlen = 25600; { 64mx_y }
  tol_up_scn = 77; tol_dn_scn = 75; ord0 = 48; mx_outlen = 10;
  spd_up_scn = 72; spd_dn_scn = 80; mx_Fsh = 99; Fshsiz = 54;
  spd_hm_scn = 71; FshflInts = 5400; { = 100 flashes @ max 54 integers }
  insert_scn = 82; m5x = 5; v3 = 30003; mxprgF = 9; mxprkscF = 9;
  prompt_Y = 24; lgd_X = 26; bxp = #8; dmy_val = -999;
  stop_key = #27; wait_key = #32;
  bot_smt = -127; top_smt = 127; top1_smt = 128; n_smts = 255;
  dsp_wd = 32; pdq_wd = 16; pdq_ht = 8; mx_pdqs = 850;
  very_bot_pch = 0; very_top_pch = 127; bot = true; top = false;
  min_tol = 10; dft_tol = 40; max_tol = 255; blank = ' ';
  min_spd = 77; dft_spd = 100; max_spd = 300; n_cmdKys = 14; cmdKX = 9;
  mx_Mcmds = 8;  Mwd = 16; b7 = 128; up = 1; mx_rand = 30000;
  mx_Mchns = 16; Mht = 9; Awd = 26;  dn = 0; prompt_X = 5;
  xpr_qty = 3; xpr_pts = 100; mus_qty = 6; oba_ht = 20; nine_hrs = 32400;
  xpr_wd = 16; xpr_ht = 16;   mus_ht = 16; ost_ht = 18;
  pdq_noct_ofs = 308; { 1st note+oct 'C=0'~'G=9' in .PDQ }
  pdq_nome_ofs = 292; { 1st notename 'A'~'G' in .PDQ }
  pdq_idvl_ofs = 437; { 1st allochdr '8.8' in .PDQ }
  pdq_hexn_ofs = 501; { 1st hexnumer '00'~'FF' in .PDQ }
  minPstr  = '0 1 0 1 0 0 1 0 0 0 0 0 1 0'; { param.values min/dft/max }
  dftPstrL = '24 125  6 1 8 60 1 12 48  8 64 8 1 1';
  dftPstrM = '18 125 12 2 6 60 2 10 60 12 66 8 1 2';
  dftPstrR = '12 125 18 3 4 60 3  8 72 16 68 8 1 3';
  maxPstr  = '24 255 24 255 127 127 3 12 127 127 127 127 127 16';
  maxP1 = 24; { must tally with start of 'maxPstr' }

type
  str10 = string[10];
  str20 = string[20];
  str128 = string[128];
  pdqtyp = array[1..pdq_ht] of integer;
  intfil = file of integer;
  pdqfil = file of pdqtyp;
  chr_set = set of char;
  byt_set = set of 0..127;
  b127arr = array[0..127] of byte;
  b255arr = array[0..255] of byte;
  dodex2 = array[0..11] of string[2];
  key_arr = array[1..idflast,dn..up,1..n_strms] of char;
  strm_chr_arr = packed array[1..n_strms] of char;
  strm_int_arr = array[1..n_strms] of integer;
  strm_lnt_arr = array[1..n_strms] of long_integer;
  smt_byt_arr = packed array[bot_smt..top_smt] of byte;
  smt_int_arr = array[bot_smt..top_smt] of integer;
  smt_lntbuf = array[0..n_smts] of long_integer;
  parm_arr = array[1..n_parms] of integer;
  prmd_arr = array[1..idflast] of integer;
  xparm_arr = array[idfirst..idflast] of integer;
  xpryt   = array[0..36] of integer;
  xpr_set = array[1..xpr_qty] of xpryt;
  xpr_lst = array[1..xpr_pts] of xpryt;
  i16arr = array[1..xpr_ht] of integer;
  prmV_rec = record num: strm_int_arr;
  vlu: array[1..n_strms,1..idflast] of integer; end;
  prmC_rec = record min_vlu,dft_L,dft_M,dft_R,max_vlu : prmd_arr; end;
  rhy_max_rec = record std,ofs,ndx : strm_lnt_arr; end;
  Tfil_rec = record fv: text;   name,extn: string; stat: char; end; {b:  stat}
  Ifil_rec = record fv: intfil; name,extn: string; stat: char; end;
  midicmd_rec = record botK,topK,qtyK,str_sl,parm,valu : integer;
    ctrlset : byt_set;
    got_cmd : boolean;
    scl_step,mtr_step,ins_step : real;
    prm_step : array[1..n_parms] of real;
    code : array[-n_mtrls..idflast,0..127] of integer;
    end;
  midIbx_rec = record X : array[0..mx_Mcmds] of integer;
    Y : array[0..mx_Mchns] of integer;
    end;
  button = record X,Y,W,H,bt_sz,bt_Xofs: integer;
    bt_styl: array[false..true] of integer;
    ltr: array[false..true] of char;
    alf,nu,on,busy: boolean;
    end;
  box = record X,Y,W,H: integer; held: boolean; end;
  mxFS01 = array[0..1] of mxFS;

var   
  dforce,y,tol_ms,t_str,tmr_scn,chdsz             : byte;
  Cprm,Cch_buf,key,oct,fil_stat,outall_key,
  laT_key,laP_key,tol_up,tol_dn,clock_key,
  midO_tgl,midI_wip,spd_up,spd_dn,spd_hm,
  dsk,tmblk_key,scat_key,tmr_key,dmy_key,
  hlpK,final_key,next_key,boing_tgl                : char;
  xplay_ok,play_ok,init_orch,Krpt_on,Fsh_recalled,
  xplaying,fobtained,fopened,new_input,prk_vgn,
  mdkfil_open,midOwing,idf_vgn,mdkfil_vgn,oba_vgn,
  dsp_boing,alfok,pdqok,Acting,Fshfl_open,exe_vgn,
  Mshudder,cmdKhelping,running,Fpicked,idp_ok,hrm_ok,
  mouse_hidden,mouse_forbidden,dsp_all_done,prk_ok,
  got_clcmd,got_kycmd,got_mdcmd,known,sending_outB,
  on_left_button,mdrg_new,flashed,inbx,was_inbx    : boolean;
  z,a,q,S,mdmnX,mdmnY,mshp,lshp,pFprmp,pFprep,
  tol_Y,spd_Y,hdr_Y,idf_Y,ivl_Y,kyc_Y,clo_Y,mdn_Y,idvl_X,
  i,i_mdkfil,iC,err,vl,play_punct,i_xpr,lxx,lyy,xputval,
  i_cmdKyhlp,n_scls,n_mtrs,Tsc1,Tms1,Tsc2,Tms2,Fsh_chn,
  shap0,shap1,Csec,Cmsc,Cstr,Cvlu,Cpunct,SmidO,
  spd_pc,n_pdqs,kyc_hd,clo_hd,kyhd16,tmhd16,ctrldir,
  i_flmn,inflmn,x_Fsh,i_Fsh,r_Fsh,z_Fsh,Fsh_bytes,mxoutSln,
  start_sec,start_msc,dsp_sc,dsp_ms,ldsp_sc,
  lsec,lmsc,r_tnl_dg,intbuf,pchbuf,kysc,m_P,m_S,
  mtrl_lftX,mtr_topY,scl_topY,mouse_wait,hrmIDcod,
  prmpFs,prepFs,inpFs,kdamX,kdamY,inS              : integer;
  prgbas,scdr0,lbuf                                : long_integer;
  start_time,stop_time,rbuf,r_byts                 : real;
  dflt_nam,Fshflnam                                : str20;
  tol_lgd,spd_lgd,pls_lgd,tme_lgd,tmA_lgd,tmZ_lgd,tmN_lgd,
  mid_lgd,cmd_lgd,idf_lgd,ivl_lgd,kyc_lgd,clo_lgd,
  mdn_lgd,hdr_lgd,sbuf,mdkfilnam,Mcmdstr,kdamS,
  mPmstr,mStstr,abskfldr,
  iFstr,zFstr,TOStr,prgnam,xputstr,prmpfldr,prepfldr : string;
  mdkfil                             : text;
  idpfil                             : Tfil_rec;
  hrmfil,prkfil                      : Ifil_rec;
  Fshfl                              : intfil;
  rhy_max                            : rhy_max_rec;
  prmC                               : prmC_rec;
  prmV                               : prmV_rec;
  midicmd                            : midicmd_rec;
  midIbx                             : midIbx_rec;
  RecO,SndO,TmeO,FshO,ThrO,HdrO,
  IdpO,HrmO,PrkO,StaO,DfRO           : button;
  idvlbx,kyclbx,mdrgbx,outSbx,
  iFshbx,zFshbx,rmapbx,prmpbx,prepbx,
  idfrbx,midObx,helpbx,finpbx,
  idfKbx,Byt2bx,Malcbx,xputbx        : box;
  ost_bx                             : array[1..n_strms] of box;
  chroma                             : dodex2;
  tol_pdq,spd_pdq,pdqbuf             : pdqtyp;
  tim_set,mtr_set,out_set,Fsh_set,
  scl_set,pls_set,ins_set,mid_set,
  alc_set,ost_set,
  key_set,tgl_set,mtrl_set,dgt_set,
  biggest_set,meddle_set,oper_set    : chr_set;
  idf0set,ivl0set,kyc0set,clo0set,
  idf_set,ivl_set,kyc_set,clo_set    : byt_set;
  xpr_set1,xpr_set0                  : xpr_set; { total set - each unique }
  xpr_lst1,xpr_lst0                  : xpr_lst; { list in order of use }
  key_info,uprasc,unused,Uz,Uq,Ua    : b127arr;
  swapky                             : b255arr;
  prm_key                            : key_arr;
  pls_len,cyc_len,mtr_no,
  set_pls,pls_ctr,scl_no,
  start_pls,old_chdsz,
  max_smt,min_smt,midOutY,
  top_pch,bot_pch,idfX,i_midO,
  dur_ctr,due_sec,due_msc,
  ostat,ostartpls                    : strm_int_arr;
  mtr_key,scl_key,pls_key,
  ins_key,mid_key,out_key,
  ost_tgl                            : strm_chr_arr; { packed array }
  hrm_prior                          : smt_int_arr;
  idfY,idf_hd,ivl_hd,idflgdX,idflgdY : xparm_arr;
  prmproc,preproc      : mxFS01;
  Iflst                : array[1..3] of mxFS01;
  n_puls               : array[1..mx_mtrs] of integer;
  Mcmdarr              : array[1..mx_Mcmds] of byte;
  mSt,mPm,nSt,nPm      : array[1..mx_Mchns] of integer;
  cmdKstr              : array[1..n_cmdKys] of string;
  titS                 : array['A'..'U'] of string;
  tgl_key,hxMchn       : array[0..n_strms] of char;
  r_str,modamping,composing,
  vce_on,ins_up,mid_up : array[1..n_strms] of boolean;
  pchgvn               : array[bot_smt..top_smt] of boolean;
  notename             : array[0..127] of string[3];
  flgdx_X,flgd_Y       : array[1..3] of integer; { text coords }
  flgd,Ifldr,Ixt       : array[1..3] of string[32];
  ActO                 : array[idfirst..idflast] of button;
  idflgd,idfp          : array[idfirst..idflast] of string[32];
  strat                : array[1..mx_mtrs,1..mx_lyrs] of byte;
  xpxR                 : array[0..mx_cols] of integer;
  ypxR                 : array[0..mx_lns] of integer;
  mdp                  : array[1..n_midsp] of integer;
  Fshbuf               : array[1..FshflInts] of integer;
  midi_cmd             : array[0..15] of char;
  qhx                  : array[0..15] of integer;
  pdq                  : array[1..mx_pdqs] of pdqtyp;
  xprI                 : array[1..xpr_qty] of i16arr;
  mcrs,mask            : array[1..mus_qty] of i16arr;
  rmap                 : array[1..n_strms,8..15] of byte;
  rmapping             : array[1..n_strms,8..15] of boolean;
  rmapX,B2pm           : array[8..15] of integer;
  rmapY                : array[1..n_strms] of integer;
  outS                 : array[1..n_strms] of string;
  outB                 : array[1..n_strms] of b127arr;
  oba,obaL,obaR        : array[1..oba_ht] of integer;
  mtx5cod              : array[0..7] of string;
  new_pch,old_pch      : packed array[1..n_strms,1..mx_chdsz] of byte;
  damped      : array[1..n_strms,0..127] of boolean;
  ost_on      : array[1..n_strms,0..1] of boolean;
  nonpitch    : array[1..n_strms,1..mx_chdsz] of boolean;
  dsp_done    : array[1..n_strms,idfirst..idflast] of boolean;
  ostplsok    : array[1..n_strms,1..mx_puls] of boolean;
  ostpch      : array[1..n_strms,1..mx_puls,1..mx_chdsz] of integer;
  ost_chdsz   : array[1..n_strms,1..mx_puls] of integer;
  rhy_ndx     : array[1..n_strms,1..mx_puls] of long_integer;
  a_smt,z_smt : array[1..n_strms,1..mx_chdsz] of integer;
  pdqadr      : array[0..pdqadr_arrlen] of integer;
  mtrdsp      : array[1..mx_mtrs] of string;
  scldsp      : array[1..mx_scls] of str128;
  idp,idpXmv3 : array[1..mx_mtrs,1..mx_puls] of integer;
  idpXv8      : array[1..mx_mtrs,1..mx_puls,0..mx_tnl_dg] of integer;
  prbzn_flr   : array[1..mx_scls,0..mx_tnl_dg,bot_smt..top1_smt] of integer;
  prbzn_slice : array[bot_smt..top1_smt] of integer;
  i8p         : array[1..n_strms,1..mx_puls] of integer;     {attenuation bezogen}
  attfac1     : array[0..maxP1,0..mx_puls] of real;
  attfac2     : array[0..maxP1,0..b7] of real;
  ostfnt      : array[0..1,1..18] of integer; { 18 = ost_bx[n].H (q.v.) }
  kdamH       : array[1..24] of integer;
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!