/* Started image: pvtest.ima, 11:47, 11/10/1997 */!!
now(ButtonWindow)!!
/* 12/3/1992 15:46 - PRIVATE
  Init configure menu
*/
Def initMenuConfigure(self | aMenu procType procGroup menuCol i)
{
 /* get processor type */
 procType := getSpecificProcessor(ProcLibClass$Inst);
 
 /* set procGroup (1: moto/other, 2: 386dx/sx/cx, 4: 386ex) */
 select
   case procType = PROC_I80386CX_TB cor
        procType = PROC_I80386SX_TB cor
        procType = PROC_I80386DX_TB cor
        procType = PROC_I80386CX_SH cor
        procType = PROC_I80386SX_SH cor
        procType = PROC_I80386DX_SH is
           procGroup := 2;
   endCase
   case procType = PROC_I80386EX_TB cor
        procType = PROC_I80386EX_SH is
           procGroup := 4;
   endCase;
   default
      procGroup := 1;
  endSelect;
 
 /* prepare menu entries */
 menuCol := new(OrderedCollection, 3);
 /* first element of tuple is the OR of the procGroup bits representing the
    processors the menu entries should appear for, e.g. 7 is 1 | 2 | 4),
    1 is just moto. */
 add(menuCol, tuple(7, new(MenuItem, "&Map...",            504, #actionOverlay)));
 add(menuCol, tuple(7, new(MenuItem, "Run &Access",        505, #menuRunAccess)));
 add(menuCol, tuple(1, new(MenuItem, "&Periodic Refresh...", 515, #actionPeriodicRefresh)));
 add(menuCol, tuple(1, new(MenuItem, "&Show Cycles",       506, #menuShowCycles)));
 add(menuCol, tuple(7, new(MenuItem, "S&ymbolic Disassembly", 507, #menuSymDasm)));
/* add(menuCol,
   tuple(1, new(MenuItem, "Mas&k Interrupts For Step", 513, #menuStepMask))); */
 add(menuCol, tuple(7, nil));
/**186**
 add(menuCol, tuple(5, new(MenuItem, "Sa&ve Chip Selects...", 508, #menuSaveCS)));
 add(menuCol,
   tuple(5, new(MenuItem, "&Restore Chip Selects...", 509, #menuRestCS)));
 add(menuCol,
   tuple(1, new(MenuItem, "&Configure Chip Selects", 510, #menuConfCS)));
 add(menuCol, tuple(5, nil));
**186**/
 add(menuCol,
   tuple(6, new(MenuItem, "Confi&gure Symbols", 510, #menuConfSym)));
 add(menuCol, tuple(6, nil));
 add(menuCol, tuple(7, new(MenuItem, "R&eset",             511, #menuReset)));
 add(menuCol, tuple(7, new(MenuItem, "Reset CPU &Only",    512, #menuResetOnly)));
 add(menuCol, tuple(7, new(MenuItem, "ReLink",             514, #menuRelink)));
 
 /* place menu entries if they match the processor. */
 aMenu := newPopup(MenuItem, "&Configure");
 i := 0;
 loop
 while i < size(menuCol)
    if ((menuCol[i][0] bitAnd procGroup) > 0)
      addItem(aMenu, menuCol[i][1]);
    endif;
    i := i + 1;
 endLoop;
 ^aMenu;
}
!!
now(ButtonWindow)!!
/* 12/3/1992 15:48 - PRIVATE
  Set runAccess mode on/off.
*/
Def menuRunAccess(self)
{
  /* Set runAccess if RunAccess is not ON, else clear it */
  if (getRunAccess(HLBrkRootLibClass$Inst) <> BOOL_TRUE) then
      setRunAccess(HLBrkRootLibClass$Inst);
      checkMenuItem(self, 505);
      enableMenuItem(self, 515);      
  else
    clearRunAccess(HLBrkRootLibClass$Inst);
    unCheckMenuItem(self, 505);
    grayMenuItem(self, 515);    
  endif;
}
!!
now(ButtonWindow)!!
/* toolbar got focus */
Def checkMenuItems(self | cycles lastError)
{
  /* don't do it until initialization complete, DLLs hooked up */
  if not(initComplete)
    ^nil;
  endif;

  /* make sure run access properly checked */
  if (getRunAccess(HLBrkRootLibClass$Inst) = BOOL_TRUE)
    checkMenuItem(self, 505);
      enableMenuItem(self, 515);    
  else
    unCheckMenuItem(self, 505);
    grayMenuItem(self, 515);    
  endif;
  
  /* make sure stepMask properly checked */
  if (getStepMask(HLBreakLibClass$Inst) = BOOL_TRUE)
    checkMenuItem(self, 513);
  else
    unCheckMenuItem(self, 513);
  endif;

  /* make sure show cycles properly checked (1 = on, 0 = off, nil = error) */
  cycles := showCycles?(memoryServer(MemServLibClass$Inst));

  if (((lastError := getLastSdError(SharedDataLibClass$Inst)) <> GOOD) cand
    (lastError <> ER_SIM_UNREADABLE)) 
    if (lastError)
      displayError(ErrorTextLibClass$Inst, lastError, CHECK_MODE);
    endif;
  endif;

  select
    case cycles = 0 is 
      enableMenuItem(self, 506);
      unCheckMenuItem(self, 506);
    endCase
    case cycles = 1 is 
      enableMenuItem(self, 506);
      checkMenuItem(self, 506);
    endCase
    case not(cycles) is
      unCheckMenuItem(self, 506);
      grayMenuItem(self, 506);
    endCase
  endSelect;


  /* make sure dasm symbols properly checked (0 = off, 1 = on) */
  if getDasmSymbol(DisAsmLibClass$Inst) = 0
    unCheckMenuItem(self, 507);
  else
    checkMenuItem(self, 507);
  endif;

  /* make sure save layout now properly checked (0 = off, 1 = on) */
  saveLayoutOnExit := getIniSaveLayoutOnExit(PreLauncher);
  if saveLayoutOnExit=1
    checkMenuItem(self, 520);
  else
    unCheckMenuItem(self, 520);
  endif;
}
!!
now(ButtonWindow)!!
/* toolbar got focus */
Def checkMenuItems(self | cycles lastError)
{
  /* don't do it until initialization complete, DLLs hooked up */
  if not(initComplete)
    ^nil;
  endif;

  /* make sure run access properly checked */
  if (getRunAccess(HLBrkRootLibClass$Inst) = BOOL_TRUE)
    checkMenuItem(self, 505);
      enableMenuItem(self, 515);    
  else
    unCheckMenuItem(self, 505);
    grayMenuItem(self, 515);    
  endif;
  
  /* make sure stepMask properly checked */
  if (getStepMask(HLBreakLibClass$Inst) = BOOL_TRUE)
    checkMenuItem(self, 513);
  else
    unCheckMenuItem(self, 513);
  endif;

  /* make sure show cycles properly checked (1 = on, 0 = off, nil = error) */
  cycles := showCycles?(memoryServer(MemServLibClass$Inst));

  if (((lastError := getLastSdError(SharedDataLibClass$Inst)) <> GOOD) cand
    (lastError <> ER_SIM_UNREADABLE)) 
    if (lastError)
      displayError(ErrorTextLibClass$Inst, lastError, CHECK_MODE);
    endif;
  endif;

  select
    case cycles = 0 is 
      enableMenuItem(self, 506);
      unCheckMenuItem(self, 506);
    endCase
    case cycles = 1 is 
      enableMenuItem(self, 506);
      checkMenuItem(self, 506);
    endCase
    case not(cycles) is
      unCheckMenuItem(self, 506);
      grayMenuItem(self, 506);
    endCase
  endSelect;


  /* make sure dasm symbols properly checked (0 = off, 1 = on) */
  if getDasmSymbol(DisAsmLibClass$Inst) = 0
    unCheckMenuItem(self, 507);
  else
    checkMenuItem(self, 507);
  endif;

  /* make sure save layout now properly checked (0 = off, 1 = on) */
  saveLayoutOnExit := getIniSaveLayoutOnExit(PreLauncher);
  if saveLayoutOnExit=1
    checkMenuItem(self, 520);
  else
    unCheckMenuItem(self, 520);
  endif;
}
!!
now(ButtonWindow)!!
/* 11/10/1997 11:55 */
Def actionPeriodicRefresh(self)
{ 
   dlgPeriodicRefresh := new(InputDialog, "Periodic Refresh" 
                                        , "Enter refresh period : (seconds)"
                                        , "10");

   if (runModal(dlgPeriodicRefresh, INPUT_BOX, ThePort) <> IDOK)
     ^self;
   endif; 
   
   periodnum := asInt( getText(dlgPeriodicRefresh), 10); 

   if not(periodnum)
     ^nil;
   endif;

   pFlag := 1;
   pStart := 0;
   periodsec := periodnum;
}!!
now(ButtonWindow)!!
/* WINDOWS
  timer event
*/
Def WM_TIMER(self, wP, lP)
{
   if (pFlag = 1) then
      pStart := pStart + 1;
      if (pStart > periodsec) then
        pStart := 0;
        raStatus := getRunAccess(HLBrkRootLibClass$Inst);
        if (raStatus = BOOL_TRUE) then
          emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
          if (emStatus = HLB_EMU_RUNNING) then
            showWaitCurs();
            halt(HLBreakLibClass$Inst);
            go(HLBreakLibClass$Inst);  
            showOldCurs();             
          endif;
        endif;
      endif;  
   endif;

   if afterFIrstCallback
     hitSharedDataServer(SharedDataLibClass$Inst); /* force a comm read */
   else
     afterFIrstCallback := #true;
     startupScript(PreLauncher);
     openAllSavedWindows( PreLauncher );
  endif;

  ^0
}
!!
/* Snapshot: pvtest.ima, 11:58, 11/10/1997 */!!
/* Started image: pvtest.ima, 11:59, 11/10/1997 */!!
/* Started image: pvtest.ima, 12:07, 11/10/1997 */!!
now(VarBrowser)!!
/* PRIVATE */
Def refreshVars(self | linesWanted)
{
  nilifySelLineInfo( self ) ;
  resetSelected( self ) ;
  mabeClosePopup( self ) ;
  maybeCloseEditWin( self ) ;

  raStatus := getRunAccess(HLBrkRootLibClass$Inst);
  if (raStatus = BOOL_TRUE) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_RUNNING) cand (refreshnum = 1) then
      showWaitCurs();
      halt(HLBreakLibClass$Inst);
      go(HLBreakLibClass$Inst);  
      showOldCurs();             
    endif;
  endif;
  refreshnum := 0; 

  /* Enumerate over the VarColelction to get new size information */
  do(varCollection,
    {using(var | numLines)
      numLines := getLinesForVar( varSession, varID(var) ) ;
      if numLines then
        setLineNumInfo(var, numLines, #Exact);
      else
        /* DEBUG - printNewLine( "getLinesForVar returned unknown: " + name(var) ); */
        setLineNumInfo(var, 0, #Unknown);
      endif ;
    });
  
  /* Adjust the var display according to display mode */
  if displayCompressed? then
    refreshHeaderLines( self ) ;
    makeCompressedDisplay( self ) ;
  else
    if not(refreshText( viewColl, varSession )) then
      ^nil;
    endif;  
    linesWanted := ( visLines(self) - numLinesIn(viewColl) ) ;
    if (linesWanted > 0) then 
      addNlinesToDisplayBottom( self, linesWanted, nil ) ;
    endif ;
  endif ;

  invalidate( self ) ; /* may reset scroll-pos */
}!!
now(VarPresenter)!!
/* 6/3/1994 10:13 */
/* MENU */
Def menuRefresh(self, ignored)
{
  refreshnum := 1; 
  ^refreshVars(varBrowser)
}
!!
now(StackPresenter)!!
/* 3/10/1992 11:41 - PRIVATE test */
Def cmdStkRefresh(self, msg)
{ 
  raStatus := getRunAccess(HLBrkRootLibClass$Inst);
  if (raStatus = BOOL_TRUE) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_RUNNING) then
      showWaitCurs();
      halt(HLBreakLibClass$Inst);
      go(HLBreakLibClass$Inst);  
      showOldCurs();             
    endif;
  endif;

  /* Update stack session and stack value */
  getAllStackInfo(self);
  updateStack(self);
  invalidate(self);
}
!!
now(HLBreakLib)!!
/* 3/23/1992 13:25 - PUBLIC
  Set an asm level breakpoint.
  Return a breakpoint descriptor or nil.
  Note: addrDesc is created by calling createAddress(AddressLibClass$Inst)
  and the hi-level Breakpoint Server will consume it even if error occurred.
*/
Def prime_setAsmBkpt(self, state, life, addrDesc | descRef )
{ 
  bkptrunning := 0;
  raStatus := getRunAccess(HLBrkRootLibClass$Inst);
  if (raStatus = BOOL_TRUE) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_RUNNING) then
      bkptrunning := 1; 
      showWaitCurs();
      halt(HLBreakLibClass$Inst);
      showOldCurs();             
    endif;
  endif;

  descRef := new(Struct, 4);
  if not(state) cor not(life) cor not(addrDesc) cor not(descRef) then
    ^nil;
  endif;  
  
  if pcallLock(self)
  then
    lastError := pcall(procs[#BXSETBKPT], asInt(state), asInt(life),
                       asLong(addrDesc), descRef);
    pcallUNLock(self);
  else 
    lastError := ERR_PCALL_RECURSION ;
  endif ;

  if (raStatus = BOOL_TRUE) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_HALTED) cand (bkptrunning = 1) then
      bkptrunning := 0;
      showWaitCurs();
      go(HLBreakLibClass$Inst);  
      showOldCurs();             
    endif;
  endif;

  if (lastError <> GOOD) then
   ^nil;
  endif;
  ^longAt(descRef, 0);
}
!!
now(HLBreakLib)!!
/* 3/23/1992 12:47 - PUBLIC 
  Set a source level breakpoint.
  return a bkpt Desc or nil.
*/
Def setSourceBkpt(self, state, life, moduleDesc, lineNum, col, str, addrDesc 
  | descRef )
{ 
  bkptrunning := 0;
  raStatus := getRunAccess(HLBrkRootLibClass$Inst);
  if (raStatus = BOOL_TRUE) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_RUNNING) then
      bkptrunning := 1; 
      showWaitCurs();
      halt(HLBreakLibClass$Inst);
      showOldCurs();             
    endif;
  endif;

  descRef := new(Struct, 4); 
  if (not(state) cor not(life) cor not(moduleDesc) cor not(lineNum) cor
     not(lineNum) cor not(col) cor not(str) cor not(addrDesc) cor not(descRef)) then
    ^nil;       
  endif;   
  if pcallLock(self)
  then
    lastError := pcall(procs[#BXSETSRCBKPT], 
    asInt(state),            /* enum */
    asInt(life),             /* enum */
    asLong(moduleDesc),      /* U32  */
    lineNum,                 /* U16  */  
    asInt(col),              /* U8   */
    asciiz(str),             /* U32  */   
    addrDesc,                /* ADDR_DESCRIPTOR */ 
    descRef);                /* U32  */
    
    pcallUNLock(self);
  else 
    lastError := ERR_PCALL_RECURSION ;
  endif ;

  if (raStatus = BOOL_TRUE) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_HALTED) cand (bkptrunning = 1) then
      bkptrunning := 0;
      showWaitCurs();
      go(HLBreakLibClass$Inst);  
      showOldCurs();             
    endif;
  endif;

  if (lastError <> GOOD) then
    displayError(ErrorTextLibClass$Inst,lastError, CHECK_MODE);
    ^nil;
  endif;
  ^longAt(descRef, 0);  
}
!!
now(CliServer)!!
/* call function in server dll */
Def callCServer(self, serverName, commandName, argString, argc, argv |
  dllLib index status symbol serverEntry commandEntry cArgv errorMessage)
{
  /* retrieve server entry from registration info, then get dll library */
  dllLib := at(newServerDictionary, asLowerCase(serverName));
  if (not(dllLib))
    errorMessage := getFormattedError(ErrorTextLibClass$Inst,
       ER_CLI_UNREGISTERED_SERVER, serverName, nil, nil);
    syntaxError(self, nil, errorMessage);
    /* syntaxError unravels call stack, and does not return */
  endif;

  /* retrieve command entry from registration info,
     then convert into entry point symbol */
  commandEntry := at(newCommandDictionary, asLowerCase(commandName));
  if (not(commandEntry))
    errorMessage := getFormattedError(ErrorTextLibClass$Inst,
       ER_CLI_UNREGISTERED_COMMAND, commandName, nil, nil);
    syntaxError(self, nil, errorMessage);
    /* syntaxError unravels call stack, and does not return */
  endif;
  symbol := asSymbol(asUpperCase(commandEntry));

  /* convert argv; string and argc can be passed directly */
  cArgv := new(Struct, 4*size(argv));
  index := 0;
  loop
  while index < size(argv)
  begin
    putLong(cArgv, argv[index], index*4);
    index := index + 1;
  endLoop;

  if (symbol = #BXCLISETBKPT) then
    bkptrunning := 0;
    raStatus := getRunAccess(HLBrkRootLibClass$Inst);
    if (raStatus = BOOL_TRUE) then
      emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
      if (emStatus = HLB_EMU_RUNNING) then
        bkptrunning := 1; 
        showWaitCurs();
        halt(HLBreakLibClass$Inst);
        showOldCurs();             
      endif;
    endif;
  endif; 

  /* call dll */
  if pcallLock(MallocLibClass$Inst)
    serverCallFlagSet(self);
    status := pcall(procs(dllLib)[symbol], argString, argc, lP(cArgv));
    serverCallFlagReset(self);
    pcallUNLock(MallocLibClass$Inst);
  else
    status := ERR_PCALL_RECURSION;
  endif;

  if (symbol = #BXCLISETBKPT) cand (raStatus = BOOL_TRUE) cand (bkptrunning = 1) then
    emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
    if (emStatus = HLB_EMU_HALTED) then
      bkptrunning := 0;
      showWaitCurs();
      go(HLBreakLibClass$Inst);  
      showOldCurs();             
    endif;
  endif;

  freeHandle(cArgv);
  if status <> 0
    /* abort completely if lower level command aborted */
    if (status = ER_ABORT_FROM_ESC) cor
       (status = ER_ABORT_SESSION) cor
       (status = ER_CLI_USER_ABORT) cor
       (status = ER_CMD_ABORT) cor
       (status = ER_COPY_ABORT) cor
       (status = ER_DQ_ABORTED) cor
       (status = ER_FILL_ABORT) cor
       (status = ER_HEX_ABORT) cor
       (status = ER_LDR_ABORT) cor
       (status = ER_LOAD_ABORT) cor
       (status = ER_SEARCH_ABORT) cor
       (status = ER_SWAT_ABORT) cor
       (status = ER_TRIGGER_ABORTED) cor
       (status = ER_USER_ABORT)

      syntaxError(self, nil, getErrorText(ErrorTextLibClass$Inst, status));
      /* this call doesn't return */
    else
      /* load memory verify info if applicable */
      if (status = ER_MEMORY_VERIFY)
        processVerifyError(MemServLibClass$Inst);
      endif;
      outputCRLFLine(self, getErrorText(ErrorTextLibClass$Inst, status));
    endif;
  endif;

  /* wait for events to complete */
  waitForEvents(self);

  /* if server didn't acknowledge abort, abort anyway without message */
  if pendingAbort?(self)
    abortCommand(self);
      /* this call doesn't return */
  endif;

  ^status;
}!!
/* Snapshot: pvtest.ima, 12:15, 11/10/1997 */!!
/* Started image: pvtest.ima, 12:16, 11/10/1997 */!!
/* Started image: pvtest.ima, 17:32, 11/10/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 17:33, 11/10/1997 */!!
now(TracePresenter)!!
/* PRIVATE
   Initialize the menus.
 */
Def initMenus(self | aMenu)
{ 
  aMenu := new(OrderedCollection, 8);
  initMenu(self);
  
  /* menu item 0 */
  add(aMenu, tuple("&File",tuple(
                      tuple("&Clear Trace", #traceClear),
                      tuple("&Save As...", #traceSave),                      
                      tuple("E&xit", #trcExit))));
                      
/*  add(aMenu, tuple("&Search",#trcSearch));                     */
  /* menu item 1 */
  add(aMenu, tuple("&Edit",tuple(
                      tuple("E&vents...",#trcEvent),
                      tuple("S&earch...", #trcSearch))));
   /*                   tuple(nil,    nil),
                      tuple("&Clear Trace", #clearTrace) 
                      )));  186*/
                      
                                                                                                                                   
  /* menu item 2 */
  initViewMenu(self, aMenu);
  
  /* menu item 3 */
/*186*  add(aMenu, tuple("&Trace",tuple(
     tuple(
              "&Start" + asString(Tab) + "F3", #trcTraceStart),
                      tuple("Sto&p" + asString(Tab) + "F4", #trcTraceStop),
                      tuple(nil,nil), 

     tuple("&Trace Control...",    #trcTraceConfig))));
*186*/
/* 186-MTAT2 */
     add(aMenu, tuple("&Display",tuple(
                      tuple("&Timestamp", #setTimestampFg),  
/*                    tuple("&Address",#setAddressFg),
                      tuple("&Data",#setDataFg), */
                      tuple("&Status",#setStatusFg),
                      tuple("&External Trace Bit",#setETBFg),
                      tuple("A&ction",#setActionFg),
                      tuple("S&L(Sequence Level)",#setSLFg),
                      tuple("&Bus-Event-Matched Bits",#setBEMFg))));

  /* menu item 4: change grayMenuItemByPosition call if order changes */
     add(aMenu, tuple("T&imestamp",tuple(
                      tuple("&Absoluate", #timestampAbsoluate),
                      tuple("&Relative To Frame", #timestampRelative),
                      tuple("&Delta",#timestampDelta),
                      tuple(nil,    nil),
                      tuple("&Zero At Frame...", #timestampFrame))));
   /*                 tuple(nil,    nil),
                      tuple("&Setup...",    #timestampSetup)))); */
  /* menu item 5 */
  add(aMenu, tuple("&Goto",tuple(
                       tuple("&Start Frame", #gotoStartFrame),
                       tuple("&Trigger Frame", #gotoTriggerFrame),
                       tuple("&End Frame", #gotoEndFrame),
                       tuple("&Frame...", #gotoFrame))));
/*                     tuple("&Next Buffer", #gotoNextBuffer),
                       tuple("&Previous Buffer", #gotoPrevBuffer),
                       tuple("&Buffer...", #gotoBuffer)))); */
  attachMenuChoices(self,aMenu);
  addWindowAndHelp(self, "Tr&ace", HELP_ENTRY_TRACE);
  registerF1Help(CLIULibraryClass$Inst, HI_ENTRY_TRACE,
     getHWnd(self), HELP_ENTRY_TRACE);
  /* disable Clock & Timestamp menu if micepack */
  if micepack?(ProcLibClass$Inst)
/*186* grayMenuItem(self, "&Clock"); *186*/
/*186* grayMenuItemByPosition(self, 4); *186*/ /* match menu item for T&imestamp */
  endif;
  
  if (TheProcFamily = PROC_FAMILY_X86)
    menuViewAuto(self);
  endif;

  drawMenu(self);
}!!
now(TracePresenter)!!
/* 11/10/1997 17:34 */
Def method(self)
{
  
  trcTraceBufferClear(theTrace);
}
!!
/* Started image: pvtest.ima, 17:37, 11/10/1997 */!!
now(TracePresenter)!!
/* PRIVATE
   Initialize the menus.
 */
Def initMenus(self | aMenu)
{ 
  aMenu := new(OrderedCollection, 8);
  initMenu(self);
  
  /* menu item 0 */
  add(aMenu, tuple("&File",tuple(
                      tuple("&Clear Trace", #traceClear),
                      tuple("&Save As...", #traceSave),                      
                      tuple("E&xit", #trcExit))));
                      
/*  add(aMenu, tuple("&Search",#trcSearch));                     */
  /* menu item 1 */
  add(aMenu, tuple("&Edit",tuple(
                      tuple("E&vents...",#trcEvent),
                      tuple("S&earch...", #trcSearch))));
   /*                   tuple(nil,    nil),
                      tuple("&Clear Trace", #clearTrace) 
                      )));  186*/
                      
                                                                                                                                   
  /* menu item 2 */
  initViewMenu(self, aMenu);
  
  /* menu item 3 */
/*186*  add(aMenu, tuple("&Trace",tuple(
     tuple(
              "&Start" + asString(Tab) + "F3", #trcTraceStart),
                      tuple("Sto&p" + asString(Tab) + "F4", #trcTraceStop),
                      tuple(nil,nil), 

     tuple("&Trace Control...",    #trcTraceConfig))));
*186*/
/* 186-MTAT2 */
     add(aMenu, tuple("&Display",tuple(
                      tuple("&Timestamp", #setTimestampFg),  
/*                    tuple("&Address",#setAddressFg),
                      tuple("&Data",#setDataFg), */
                      tuple("&Status",#setStatusFg),
                      tuple("&External Trace Bit",#setETBFg),
                      tuple("A&ction",#setActionFg),
                      tuple("S&L(Sequence Level)",#setSLFg),
                      tuple("&Bus-Event-Matched Bits",#setBEMFg))));

  /* menu item 4: change grayMenuItemByPosition call if order changes */
     add(aMenu, tuple("T&imestamp",tuple(
                      tuple("&Absoluate", #timestampAbsoluate),
                      tuple("&Relative To Frame", #timestampRelative),
                      tuple("&Delta",#timestampDelta),
                      tuple(nil,    nil),
                      tuple("&Zero At Frame...", #timestampFrame))));
   /*                 tuple(nil,    nil),
                      tuple("&Setup...",    #timestampSetup)))); */
  /* menu item 5 */
  add(aMenu, tuple("&Goto",tuple(
                       tuple("&Start Frame", #gotoStartFrame),
                       tuple("&Trigger Frame", #gotoTriggerFrame),
                       tuple("&End Frame", #gotoEndFrame),
                       tuple("&Frame...", #gotoFrame))));
/*                     tuple("&Next Buffer", #gotoNextBuffer),
                       tuple("&Previous Buffer", #gotoPrevBuffer),
                       tuple("&Buffer...", #gotoBuffer)))); */
  attachMenuChoices(self,aMenu);
  addWindowAndHelp(self, "Tr&ace", HELP_ENTRY_TRACE);
  registerF1Help(CLIULibraryClass$Inst, HI_ENTRY_TRACE,
     getHWnd(self), HELP_ENTRY_TRACE);
  /* disable Clock & Timestamp menu if micepack */
  if micepack?(ProcLibClass$Inst)
/*186* grayMenuItem(self, "&Clock"); *186*/
/*186* grayMenuItemByPosition(self, 4); *186*/ /* match menu item for T&imestamp */
  endif;
  
  if (TheProcFamily = PROC_FAMILY_X86)
    menuViewAuto(self);
  endif;

  drawMenu(self);
}!!
now(TracePresenter)!!
/* 11/10/1997 17:39 */
Def traceClear(self)
{ 
  trcTraceBufferClear(theTrace);
}
!!
now(TracePresenter)!!
/* 11/10/1997 17:39 */
Def traceClear(self)
{ 
  trcTraceBufferClear(theTrace);
        flushCache(browser(self));
        setFrameLimitsFromTrace(browser(self));
        invalidateCache(browser(self), nil);
 
}
!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 8:56, 11/11/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 8:57, 11/11/1997 */!!
now(ButtonWindow)!!
/* 12/3/1992 15:46 - PRIVATE
  Init configure menu
*/
Def initMenuConfigure(self | aMenu procType procGroup menuCol i)
{
 /* get processor type */
 procType := getSpecificProcessor(ProcLibClass$Inst);
 
 /* set procGroup (1: moto/other, 2: 386dx/sx/cx, 4: 386ex) */
 select
   case procType = PROC_I80386CX_TB cor
        procType = PROC_I80386SX_TB cor
        procType = PROC_I80386DX_TB cor
        procType = PROC_I80386CX_SH cor
        procType = PROC_I80386SX_SH cor
        procType = PROC_I80386DX_SH is
           procGroup := 2;
   endCase
   case procType = PROC_I80386EX_TB cor
        procType = PROC_I80386EX_SH is
           procGroup := 4;
   endCase;
   default
      procGroup := 1;
  endSelect;
 
 /* prepare menu entries */
 menuCol := new(OrderedCollection, 3);
 /* first element of tuple is the OR of the procGroup bits representing the
    processors the menu entries should appear for, e.g. 7 is 1 | 2 | 4),
    1 is just moto. */
 add(menuCol, tuple(7, new(MenuItem, "&Map...",            504, #actionOverlay)));
 add(menuCol, tuple(7, new(MenuItem, "Run &Access",        505, #menuRunAccess)));
 add(menuCol, tuple(1, new(MenuItem, "&Periodic Refresh...", 515, #actionPeriodicRefresh)));
/* add(menuCol, tuple(1, new(MenuItem, "&Show Cycles",       506, #menuShowCycles))); */
 add(menuCol, tuple(7, new(MenuItem, "S&ymbolic Disassembly", 507, #menuSymDasm)));
/* add(menuCol,
   tuple(1, new(MenuItem, "Mas&k Interrupts For Step", 513, #menuStepMask))); */
 add(menuCol, tuple(7, nil));
/**186**
 add(menuCol, tuple(5, new(MenuItem, "Sa&ve Chip Selects...", 508, #menuSaveCS)));
 add(menuCol,
   tuple(5, new(MenuItem, "&Restore Chip Selects...", 509, #menuRestCS)));
 add(menuCol,
   tuple(1, new(MenuItem, "&Configure Chip Selects", 510, #menuConfCS)));
 add(menuCol, tuple(5, nil));
**186**/
 add(menuCol,
   tuple(6, new(MenuItem, "Confi&gure Symbols", 510, #menuConfSym)));
 add(menuCol, tuple(6, nil));
 add(menuCol, tuple(7, new(MenuItem, "R&eset",             511, #menuReset)));
 add(menuCol, tuple(7, new(MenuItem, "Reset CPU &Only",    512, #menuResetOnly)));
 add(menuCol, tuple(7, new(MenuItem, "ReLink",             514, #menuRelink)));
 
 /* place menu entries if they match the processor. */
 aMenu := newPopup(MenuItem, "&Configure");
 i := 0;
 loop
 while i < size(menuCol)
    if ((menuCol[i][0] bitAnd procGroup) > 0)
      addItem(aMenu, menuCol[i][1]);
    endif;
    i := i + 1;
 endLoop;
 ^aMenu;
}
!!
now(TracePresenter)!!
/* PRIVATE
   Initialize the menus.
 */
Def initMenus(self | aMenu)
{ 
  aMenu := new(OrderedCollection, 8);
  initMenu(self);
  
  /* menu item 0 */
  add(aMenu, tuple("&File",tuple(
                      tuple("&Clear Trace", #traceSave),  
                      tuple("&Save As...", #traceSave),
                      tuple("E&xit", #trcExit))));
                      
/*  add(aMenu, tuple("&Search",#trcSearch));                     */
  /* menu item 1 */
  add(aMenu, tuple("&Edit",tuple(
                      tuple("E&vents...",#trcEvent),
                      tuple("S&earch...", #trcSearch))));
   /*                   tuple(nil,    nil),
                      tuple("&Clear Trace", #clearTrace) 
                      )));  186*/
                      
                                                                                                                                   
  /* menu item 2 */
  initViewMenu(self, aMenu);
  
  /* menu item 3 */
/*186*  add(aMenu, tuple("&Trace",tuple(
     tuple(
              "&Start" + asString(Tab) + "F3", #trcTraceStart),
                      tuple("Sto&p" + asString(Tab) + "F4", #trcTraceStop),
                      tuple(nil,nil), 

     tuple("&Trace Control...",    #trcTraceConfig))));
*186*/
/* 186-MTAT2 */
     add(aMenu, tuple("&Display",tuple(
                      tuple("&Timestamp", #setTimestampFg),  
/*                    tuple("&Address",#setAddressFg),
                      tuple("&Data",#setDataFg), */
                      tuple("&Status",#setStatusFg),
                      tuple("&External Trace Bit",#setETBFg),
                      tuple("A&ction",#setActionFg),
                      tuple("S&L(Sequence Level)",#setSLFg),
                      tuple("&Bus-Event-Matched Bits",#setBEMFg))));

  /* menu item 4: change grayMenuItemByPosition call if order changes */
     add(aMenu, tuple("T&imestamp",tuple(
                      tuple("&Absoluate", #timestampAbsoluate),
                      tuple("&Relative To Frame", #timestampRelative),
                      tuple("&Delta",#timestampDelta),
                      tuple(nil,    nil),
                      tuple("&Zero At Frame...", #timestampFrame))));
   /*                 tuple(nil,    nil),
                      tuple("&Setup...",    #timestampSetup)))); */
  /* menu item 5 */
  add(aMenu, tuple("&Goto",tuple(
                       tuple("&Start Frame", #gotoStartFrame),
                       tuple("&Trigger Frame", #gotoTriggerFrame),
                       tuple("&End Frame", #gotoEndFrame),
                       tuple("&Frame...", #gotoFrame))));
/*                     tuple("&Next Buffer", #gotoNextBuffer),
                       tuple("&Previous Buffer", #gotoPrevBuffer),
                       tuple("&Buffer...", #gotoBuffer)))); */
  attachMenuChoices(self,aMenu);
  addWindowAndHelp(self, "Tr&ace", HELP_ENTRY_TRACE);
  registerF1Help(CLIULibraryClass$Inst, HI_ENTRY_TRACE,
     getHWnd(self), HELP_ENTRY_TRACE);
  /* disable Clock & Timestamp menu if micepack */
  if micepack?(ProcLibClass$Inst)
/*186* grayMenuItem(self, "&Clock"); *186*/
/*186* grayMenuItemByPosition(self, 4); *186*/ /* match menu item for T&imestamp */
  endif;
  
  if (TheProcFamily = PROC_FAMILY_X86)
    menuViewAuto(self);
  endif;

  drawMenu(self);
}!!
/* Snapshot: pvtest.ima, 9:01, 11/11/1997 */!!
/* Started image: pvtest.ima, 9:01, 11/11/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 9:04, 11/11/1997 */!!
/* Started image: pvtest.ima, 14:22, 11/14/1997 */!!
now(TracePresenter)!!
/* PRIVATE
   Initialize the menus.
 */
Def initMenus(self | aMenu)
{ 
  flagBufclr := 0;
  aMenu := new(OrderedCollection, 8);
  initMenu(self);
  
  /* menu item 0 */
  add(aMenu, tuple("&File",tuple(
                      tuple("&Save As...", #traceSave),
                      tuple("E&xit", #trcExit))));
                      
/*  add(aMenu, tuple("&Search",#trcSearch));                     */
  /* menu item 1 */
  add(aMenu, tuple("&Edit",tuple(
                      tuple("E&vents...",#trcEvent),
                      tuple("S&earch...", #trcSearch),
                      tuple(nil,    nil),
                      tuple("&Clear Trace", #clearTrace) 
                      ))); 
                      
                                                                                                                                   
  /* menu item 2 */
  initViewMenu(self, aMenu);
  
  /* menu item 3 */
/*186*  add(aMenu, tuple("&Trace",tuple(
     tuple(
              "&Start" + asString(Tab) + "F3", #trcTraceStart),
                      tuple("Sto&p" + asString(Tab) + "F4", #trcTraceStop),
                      tuple(nil,nil), 

     tuple("&Trace Control...",    #trcTraceConfig))));
*186*/
/* 186-MTAT2 */
     add(aMenu, tuple("&Display",tuple(
                      tuple("&Timestamp", #setTimestampFg),  
/*                    tuple("&Address",#setAddressFg),
                      tuple("&Data",#setDataFg), */
                      tuple("&Status",#setStatusFg),
                      tuple("&External Trace Bit",#setETBFg),
                      tuple("A&ction",#setActionFg),
                      tuple("S&L(Sequence Level)",#setSLFg),
                      tuple("&Bus-Event-Matched Bits",#setBEMFg))));

  /* menu item 4: change grayMenuItemByPosition call if order changes */
     add(aMenu, tuple("T&imestamp",tuple(
                      tuple("&Absoluate", #timestampAbsoluate),
                      tuple("&Relative To Frame", #timestampRelative),
                      tuple("&Delta",#timestampDelta),
                      tuple(nil,    nil),
                      tuple("&Zero At Frame...", #timestampFrame))));
   /*                 tuple(nil,    nil),
                      tuple("&Setup...",    #timestampSetup)))); */
  /* menu item 5 */
  add(aMenu, tuple("&Goto",tuple(
                       tuple("&Start Frame", #gotoStartFrame),
                       tuple("&Trigger Frame", #gotoTriggerFrame),
                       tuple("&End Frame", #gotoEndFrame),
                       tuple("&Frame...", #gotoFrame))));
/*                     tuple("&Next Buffer", #gotoNextBuffer),
                       tuple("&Previous Buffer", #gotoPrevBuffer),
                       tuple("&Buffer...", #gotoBuffer)))); */
  attachMenuChoices(self,aMenu);
  addWindowAndHelp(self, "Tr&ace", HELP_ENTRY_TRACE);
  registerF1Help(CLIULibraryClass$Inst, HI_ENTRY_TRACE,
     getHWnd(self), HELP_ENTRY_TRACE);
  /* disable Clock & Timestamp menu if micepack */
  if micepack?(ProcLibClass$Inst)
/*186* grayMenuItem(self, "&Clock"); *186*/
/*186* grayMenuItemByPosition(self, 4); *186*/ /* match menu item for T&imestamp */
  endif;
  
  if (TheProcFamily = PROC_FAMILY_X86)
    menuViewAuto(self);
  endif;

  drawMenu(self);
}!!
now(TracePresenter)!!
/* WINDOWS -- sent by event manager (evNoteLib) */
Def WM_EVENT(self, wP, event | linesWanted aStr buffer popupHandle startFrame returnString numChars)
{ 
  startFrame := nil; 
  if( asLong(event) = EVENT_TRIG_TRC_BUF_NUM )
    if( trigTraceConfigureGet(theTrigger) <> 1 )
      enableMenuItem(self,"&Next Buffer");
      enableMenuItem(self,"&Previous Buffer");
      enableMenuItem(self,"&Buffer...");
    else
      grayMenuItem(self,"&Next Buffer");
      grayMenuItem(self,"&Previous Buffer");
      grayMenuItem(self,"&Buffer..."); 
    endif;
    ^self;
  endif;
  if( asLong(event) = EVENT_TRACE_CLEAR_TRACE )
    if( trcReadBufferSet(theTrace,0) = 0 )
      aStr := "Trace - Buffer: 0";
      setText(self,aStr);
    endif;
  endif;
  if( asLong(event) = EVENT_TRACE_HEADER_CHANGED )
    startFrame := getTopLineFrameNumber(browser(self));
    aStr := getProfileEntry(TheProfileInfoObj,"TraceInfo","viewType"," ");
    if( (aStr[0] = "clock") cor  (aStr[0] = "bus") )
      setTitle(titleWindow,trcGetHeader(theTrace));
    endif;
  endif; 
  if( asLong(event) = EVENT_TRACE_TRACING_OFF )
    showWaitCurs();
    trcUpdateTrace(theTrace);
    buffer := trcReadBufferGet(theTrace);
    aStr := "Trace - Buffer: "+asString(buffer);
    setText(self,aStr);
    if( (aStr[0] = "clock") cor  (aStr[0] = "bus") )
      /* need to check address space field */
      setTitle(titleWindow,trcGetHeader(theTrace));
    endif;
  endif;
  if( (asLong(event) = EVENT_TRACE_TRACING_ON) )

    invalidateCache(browser(self), nil);
    invalidate(self);
    ^0;
  endif;
  if( (asLong(event) = EVENT_DASM_SYM_CHANGED) )
    invalidateCache(browser(self), nil);
    invalidate(self);
    ^0;
  endif;
  
  flushCache(browser(self));
  setFrameLimitsFromTrace(browser(self));
  invalidateCache(browser(self), startFrame); 
  /* added by cjchen 1996/12/17 */
  numChars:=Call GetPrivateProfileString(asciiz("TrigInfo"),
     asciiz("traceAlignment"),asciiz(""),returnString:=new(String,256),256,
     asciiz(getFilename(ProfileControl)));
  returnString:=subString(returnString,0,numChars);
  if (returnString="center") cor (returnString="post")
     pageDown(browser(self));
     pageUp(browser(self)); 
  endif;
  if (returnString="pre")
     pageUp(browser(self));
     pageDown(browser(self));
  endif;   
  invalidate(self);
  
  ^0
}
!!
now(TracePresenter)!!
/* WINDOWS -- sent by event manager (evNoteLib) */
Def WM_EVENT(self, wP, event | linesWanted aStr buffer popupHandle startFrame returnString numChars)
{ 
  startFrame := nil; 
  if( asLong(event) = EVENT_TRIG_TRC_BUF_NUM )
    if( trigTraceConfigureGet(theTrigger) <> 1 )
      enableMenuItem(self,"&Next Buffer");
      enableMenuItem(self,"&Previous Buffer");
      enableMenuItem(self,"&Buffer...");
    else
      grayMenuItem(self,"&Next Buffer");
      grayMenuItem(self,"&Previous Buffer");
      grayMenuItem(self,"&Buffer..."); 
    endif;
    ^self;
  endif;
  if( asLong(event) = EVENT_TRACE_CLEAR_TRACE )
    if( trcReadBufferSet(theTrace,0) = 0 )
      aStr := "Trace - Buffer: 0";
      setText(self,aStr);
    endif;
  endif;
  if( asLong(event) = EVENT_TRACE_HEADER_CHANGED )
    startFrame := getTopLineFrameNumber(browser(self));
    aStr := getProfileEntry(TheProfileInfoObj,"TraceInfo","viewType"," ");
    if( (aStr[0] = "clock") cor  (aStr[0] = "bus") )
      setTitle(titleWindow,trcGetHeader(theTrace));
    endif;
  endif; 
  if( asLong(event) = EVENT_TRACE_TRACING_OFF )
    showWaitCurs();
    trcUpdateTrace(theTrace);
    buffer := trcReadBufferGet(theTrace);
    aStr := "Trace - Buffer: "+asString(buffer);
    setText(self,aStr);
    if( (aStr[0] = "clock") cor  (aStr[0] = "bus") )
      /* need to check address space field */
      setTitle(titleWindow,trcGetHeader(theTrace));
    endif;
  endif;
  if( (asLong(event) = EVENT_TRACE_TRACING_ON) )
    flagBufclr := 0;
    invalidateCache(browser(self), nil);
    invalidate(self);
    ^0;
  endif;
  if( (asLong(event) = EVENT_DASM_SYM_CHANGED) )
    invalidateCache(browser(self), nil);
    invalidate(self);
    ^0;
  endif;
  
  flushCache(browser(self));
  setFrameLimitsFromTrace(browser(self));
  invalidateCache(browser(self), startFrame); 
  /* added by cjchen 1996/12/17 */
  numChars:=Call GetPrivateProfileString(asciiz("TrigInfo"),
     asciiz("traceAlignment"),asciiz(""),returnString:=new(String,256),256,
     asciiz(getFilename(ProfileControl)));
  returnString:=subString(returnString,0,numChars);
  if (returnString="center") cor (returnString="post")
     pageDown(browser(self));
     pageUp(browser(self)); 
  endif;
  if (returnString="pre")
     pageUp(browser(self));
     pageDown(browser(self));
  endif;   
  invalidate(self);
  
  ^0
}
!!
now(TracePresenter)!!
/* PRIAVTE
   Clear all trace buffers.  This operation can only be done on the
   trace hardware.
 */
Def clearTrace(self){
  if (flagBufclr = 1) 
    new(ErrorBox, ThePort, "The trace buffer is empty !", "Message", 0);
  else  
    flagBufclr := 0;
    invalidateCache(browser(self), nil);
    invalidate(self);
  endif;  
/*  trcTraceBufferClear(theTrace); */
}
!!
now(TraceBrowser)!!
/* PUBLIC 
   Caller notifies us that we have to update snapshot & redraw...
*/
Def invalidateCache(self, startFrameNum | aStr buf newView trigger curView bufInfo mode numFrames temp)
{ numFrames := visLines(self);
  if( not(startFrameNum) )
    if( viewColl )
      curView := focusView(viewColl); 
    endif;
    if( not(curView) )
      bufInfo := traceBufferInfo(theTrace);
      trigger := bufInfo[1];
      mode := getProfileEntry(TheProfileInfoObj,"TraceInfo","viewType"," ");
      numFrames := visLines(self);
      if( mode[0] = "bus" ) 
        numFrames := 3 * visLines(self);   /* assume 3 clocks per bus */
      endif;
      if( mode[0] = "instruction" ) 
        numFrames := 50;            
      endif;
      startFrameNum := trigger-numFrames;
      if (trigger = 0) then
         startFrameNum := (trigger-numFrames)/2;  
      endif;       
      /* if there are no frames before the trigger then default to
         start showing frames from the trigger on - this is part
         of the trigger in the first 11 frames kludge @@@
       */
      if( startFrameNum < bufInfo[0] )
        startFrameNum := bufInfo[0];
      endif;
      if( ((trigger <> 0) cand (trigger < visLines(self)))
          cor ((trigger = 0) cand (bufInfo[0]=0)) )
        startFrameNum := 0;
      endif;
    else
      startFrameNum := viewLineFrameNumber(curView,0);
    endif;
  endif;
  
 /* flush views */
  flushCache( self ) ;

  /* Update Snapshot */
  newView := newNextFrameGroup( infoClass, 
                                theTrace, 
                                theDq,
                                startFrameNum,
                                numFrames ) ;

  /* error code returned? */
  if( (class(newView) <> infoClass) cor (size(newView)=0) )
  then
    if( newView <> ER_IPIPE_NOT_FUNC cand newView <> ER_NO_BTM_CYCLES)
      newView := newPrevFrameGroup( infoClass, 
                                    theTrace,
                                    theDq,
                                    startFrameNum,
                                    numFrames ) ;
    endif;
  endif;
  if( (class(newView) <> infoClass) cor (size(newView)=0) )
    if( newView = ER_IPIPE_NOT_FUNC cor newView = ER_NO_BTM_CYCLES)
      if (getNewViewMode(parent) = CLOCK_CYCLE)
        ^setClockCycles(parent,startFrameNum);
      endif;
      if (getNewViewMode(parent) = INST_CYCLE)
        if (getPrevViewMode(parent) = CLOCK_CYCLE)
          setNewViewMode(parent,CLOCK_CYCLE);
          ^setClockCycles(parent,startFrameNum);
        endif;
        if (getPrevViewMode(parent) = BUS_CYCLE)
          setNewViewMode(parent, BUS_CYCLE);
          ^setBusCycles(parent,startFrameNum);
        endif;
      endif;
      /* this is a safeguard, it should never run */
      ^setBusCycles(parent, startFrameNum);
    endif;
  else
    if (trigger)
      temp:=scanForTrigger(newView,trigger,visLines(self));
    else
      temp:= 0;
    endif;
    if (flagBufclr = 0)
      setViewStartLine( newView, temp ) ;
      add( viewColl, newView );
    endif;  
  endif;
  setPrevViewMode(parent, getNewViewMode(parent));
  /* Redraw */
  buf := trcReadBufferGet(theTrace);
  aStr := "Trace - Buffer: " + asString(buf);
  setText(parent,aStr);
  invalidate( self ) ;
}

!!
/* Snapshot: pvtest.ima, 14:29, 11/14/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 14:30, 11/14/1997 */!!
now(TracePresenter)!!
/* PRIAVTE
   Clear all trace buffers.  This operation can only be done on the
   trace hardware.
 */
Def clearTrace(self){
  if (flagBufclr = 1) 
    new(ErrorBox, ThePort, "The trace buffer is empty !", "Message", 0);
  else  
    flagBufclr := 1;
    invalidateCache(browser(self), nil);
    invalidate(self);
  endif;  
/*  trcTraceBufferClear(theTrace); */
}
!!
/* Snapshot: pvtest.ima, 14:31, 11/14/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 14:33, 11/14/1997 */!!
/* Started image: pvtest.ima, 15:59, 11/14/1997 */!!
now(TraceBrowser)!!
/* PRIVATE 
  Add N (> 0) lines to the bottom of the display.  
  Returns the number of lines actually obtained.
*/ 
Def addNlinesToDisplayBottom(self, linesWanted 
   | startFrameNum newView viewStartLine)
{ 
  if not(firstFrame cand lastFrame) cor (flagBufclr = 1)
  then /* nothing to get views for */
    ^0 
  endif ;

  /* get some data -- use #frames to approx #lines */
  if (size(viewColl) = 0)
  then /* no views available */
    startFrameNum := firstFrame ;
  else /* get after last view */
    startFrameNum := ( lastFrameNum(last(viewColl)) + 1 ) ;
  endif ;
 
  if( startFrameNum > lastFrame ) ^0; endif;
  
  newView := newNextFrameGroup( infoClass, 
                                theTrace,
                                theDq,
                                startFrameNum,
                                linesWanted ) ;
                         
  /* error code returned? */
  if (class(newView) <> infoClass)
  then
    if( newView = ER_IPIPE_NOT_FUNC cor newView = ER_NO_BTM_CYCLES)
      setBusCycles(parent,startFrameNum);
      ^0;
    else
      ^0
    endif;
  endif ;

  if (size(viewColl) = 0)
  then
    viewStartLine := 0 ;
  else
    viewStartLine := ( viewEndLine(last(viewColl)) + 1 ) ;
  endif ;
  setViewStartLine( newView, viewStartLine ) ;
  add( viewColl, newView ) ;

  ^size( newView ) /* # lines actually obtained */
}!!
now(TraceBrowser)!!
/* PRIVATE 
  Add N (> 0) lines to the top of the display.  
  Returns the number of lines actually obtained.
*/ 
Def addNlinesToDisplayTop(self, linesWanted | startFrameNum newView 
            viewStartLine firstView lines viewMode){
  if not(firstFrame cand lastFrame) cor (flagBufclr = 1)
  then /* nothing to get views for */
    ^0 
  endif ;

  /* get some data -- use #frames to approx #lines */
  if (size(viewColl) > 0)
  then  /* get before first view */
    firstView := first( viewColl ) ; 
    /* added by cjchen 1996/12/23 */
    viewMode:=getNewViewMode(parent);
    if (viewMode=0)
      if (linesWanted>20)
        startFrameNum:=(firstFrameNum(firstView)-linesWanted);
      else
        startFrameNum:=(firstFrameNum(firstView)-20);
      endif;  
      if (startFrameNum<firstFrame)
        startFrameNum:=firstFrame;
        linesWanted:=firstFrame-firstFrameNum(firstView);
      endif;
    else
      startFrameNum:=(firstFrameNum(firstView)-1);
    endif;
    /* eof cjchen 1996/12/23 */
    /* startFrameNum := ( firstFrameNum(firstView) - 1 ) ;  */
    newView := newPrevFrameGroup( infoClass, 
                                  theTrace,
                                  theDq,
                                  startFrameNum,
                                  linesWanted ) ;
    /* error code returned? */
    if (class(newView) <> infoClass) 
      if( newView = ER_IPIPE_NOT_FUNC cor newView = ER_NO_BTM_CYCLES)
        setBusCycles(parent,startFrameNum);
        ^0;
      else
        ^0;
      endif;
    endif ;
    viewStartLine := ( viewStartLine(firstView) - size(newView) ) ;
    setViewStartLine( newView, viewStartLine ) ;
    add( viewColl, newView ) ;
    ^size( newView ) /* # lines actually obtained */  
  endif;
}!!
now(TraceBrowser)!!
/* PRIVATE -- show last page
*/
Def bottomPage(self | newView)
{
  if (flagBufclr = 1)
    ^0;
  endif;  

  flushCache( self ) ; /* redo from scratch */

  if infoClass = DQviewInfo
    newView := newNextFrameGroup( infoClass, 
                                  theTrace,
                                  theDq,
                                  lastFrame-35,
                                  visLines(self) ) ;
  else
    newView := newPrevFrameGroup( infoClass, 
                                  theTrace,
                                  theDq,
                                  lastFrame,
                                  visLines(self) ) ;
  endif;
  /* error code returned? */
  if (class(newView) <> infoClass)
  then
    if( newView = ER_IPIPE_NOT_FUNC cor newView = ER_NO_BTM_CYCLES)
      ^setBusCycles(parent,lastFrame);
    else
      /*@@ do error recovery here -- may be StartOfData @@*/
      displayFormattedError(ErrorTextLibClass$Inst, 
         ER_INTERNAL, FORCE_POPUP, asciiz(asStringRadix(newView,16)), 
         "tracebrowser", nil);
                        /* newView is error return code */
    endif;
  endif ;

  invalidate( self ) ; /* causes repaint, which does setVScrollPos */
}
!!
now(TraceBrowser)!!
/* PRIVATE -- scroll to proximal var */
Def thumbScroll(self, percent | approxFrame newView offset)
{ 
  if (flagBufclr = 1)
    ^0;
  endif;  

  if( percent = 0 ) 
    approxFrame := firstFrame;
  else
    if( percent = 100 )
      approxFrame := lastFrame;
    else
      approxFrame := ( (frameRange(self) * percent) / 100 ) ;
      approxFrame := ( approxFrame + firstFrame) ; /* rebase */
    endif;
  endif;
  flushCache( self ) ;
  offset := 0;
  newView := newNextFrameGroup( infoClass, 
                                theTrace,
                                theDq,
                                approxFrame,
                                visLines(self) ) ;
  /* error code returned? */
  if( (class(newView) <> infoClass)
     cor (size(newView)=0) )
  then
    if( newView = ER_IPIPE_NOT_FUNC cor newView = ER_NO_BTM_CYCLES)
      ^setBusCycles(parent,approxFrame);
    else
      newView := newPrevFrameGroup( infoClass, 
                                    theTrace,
                                    theDq,
                                    approxFrame,
                                    visLines(self) ) ;
      if( size(newView) > visLines(self) )                       
        offset := visLines(self) - size(newView);
      endif;
      if( (class(newView) <> infoClass)
         cor (size(newView)=0) )
      then /* no data available */
        if( newView = ER_IPIPE_NOT_FUNC cor newView = ER_NO_BTM_CYCLES)
          ^setBusCycles(parent,approxFrame);
        else      
          invalidate( self ) ;
          ^0 ;
        endif;
      endif;
    endif ;
  endif ;
  setViewStartLine( newView, offset ) ;
  add( viewColl, newView ) ;
  invalidate( self ) ;
}
!!
/* Snapshot: pvtest.ima, 16:01, 11/14/1997 */!!
/* Started image: pvtest.ima, 16:02, 11/14/1997 */!!
/* Started image: pvtest.ima, 17:39, 11/14/1997 */!!
/* Started image: pvtest.ima, 17:41, 11/14/1997 */!!
now(TracePresenter)!!
/* PRIVATE
   Initialize the menus.
 */
Def initMenus(self | aMenu)
{ 
/*  flagBufclr := 0;  */
  aMenu := new(OrderedCollection, 8);
  initMenu(self);
  
  /* menu item 0 */
  add(aMenu, tuple("&File",tuple(
                      tuple("&Save As...", #traceSave),
                      tuple("E&xit", #trcExit))));
                      
/*  add(aMenu, tuple("&Search",#trcSearch));                     */
  /* menu item 1 */
  add(aMenu, tuple("&Edit",tuple(
                      tuple("E&vents...",#trcEvent),
                      tuple("S&earch...", #trcSearch),
                      tuple(nil,    nil),
                      tuple("&Clear Trace", #clearTrace) 
                      ))); 
                      
                                                                                                                                   
  /* menu item 2 */
  initViewMenu(self, aMenu);
  
  /* menu item 3 */
/*186*  add(aMenu, tuple("&Trace",tuple(
     tuple(
              "&Start" + asString(Tab) + "F3", #trcTraceStart),
                      tuple("Sto&p" + asString(Tab) + "F4", #trcTraceStop),
                      tuple(nil,nil), 

     tuple("&Trace Control...",    #trcTraceConfig))));
*186*/
/* 186-MTAT2 */
     add(aMenu, tuple("&Display",tuple(
                      tuple("&Timestamp", #setTimestampFg),  
/*                    tuple("&Address",#setAddressFg),
                      tuple("&Data",#setDataFg), */
                      tuple("&Status",#setStatusFg),
                      tuple("&External Trace Bit",#setETBFg),
                      tuple("A&ction",#setActionFg),
                      tuple("S&L(Sequence Level)",#setSLFg),
                      tuple("&Bus-Event-Matched Bits",#setBEMFg))));

  /* menu item 4: change grayMenuItemByPosition call if order changes */
     add(aMenu, tuple("T&imestamp",tuple(
                      tuple("&Absoluate", #timestampAbsoluate),
                      tuple("&Relative To Frame", #timestampRelative),
                      tuple("&Delta",#timestampDelta),
                      tuple(nil,    nil),
                      tuple("&Zero At Frame...", #timestampFrame))));
   /*                 tuple(nil,    nil),
                      tuple("&Setup...",    #timestampSetup)))); */
  /* menu item 5 */
  add(aMenu, tuple("&Goto",tuple(
                       tuple("&Start Frame", #gotoStartFrame),
                       tuple("&Trigger Frame", #gotoTriggerFrame),
                       tuple("&End Frame", #gotoEndFrame),
                       tuple("&Frame...", #gotoFrame))));
/*                     tuple("&Next Buffer", #gotoNextBuffer),
                       tuple("&Previous Buffer", #gotoPrevBuffer),
                       tuple("&Buffer...", #gotoBuffer)))); */
  attachMenuChoices(self,aMenu);
  addWindowAndHelp(self, "Tr&ace", HELP_ENTRY_TRACE);
  registerF1Help(CLIULibraryClass$Inst, HI_ENTRY_TRACE,
     getHWnd(self), HELP_ENTRY_TRACE);
  /* disable Clock & Timestamp menu if micepack */
  if micepack?(ProcLibClass$Inst)
/*186* grayMenuItem(self, "&Clock"); *186*/
/*186* grayMenuItemByPosition(self, 4); *186*/ /* match menu item for T&imestamp */
  endif;
  
  if (TheProcFamily = PROC_FAMILY_X86)
    menuViewAuto(self);
  endif;

  drawMenu(self);
}!!
/* Snapshot: pvtest.ima, 17:42, 11/14/1997 */!!
/* Started image: pvtest.ima, 17:42, 11/14/1997 */!!
/* Started image: pvtest.ima, 17:51, 11/14/1997 */!!
now(ButtonWindow)!!
/* PRIVATE -- N.B. initButtons() must be called before drawLabels() */
Def init(self)
{
  init(self:ancestor);
  initTextMetrics(self);
  initButtons(self,
     (2 * TB_TO_BORDER) + tmHeight
  );
  initMenuBar(self);
  addAbout(self);              /* About box & Exit app */
  TheProjectInfoObj := init(new(PrjInfo));
  TheCursorLinkServer := new(CLServer, 1);
  initComplete := 0;
  flagBufclr := 0;
  checkMenuItems(self);
}
!!
/* Snapshot: pvtest.ima, 17:52, 11/14/1997 */!!
/* Started image: pvtest.ima, 17:52, 11/14/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 17:52, 11/14/1997 */!!
/* Started image: pvtest.ima, 8:29, 11/17/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 8:31, 11/17/1997 */!!
now(ButtonWindow)!!
/* BUTTON */
Def actionEmuGo(self)
{
  HLBreakLibClass$Inst cor requireWithPath( HLBreakLib, "bkptexec.dll" ) ;

  if HLBreakLibClass$Inst
  then
    showWaitCurs();
    flagBufclr := 0;
    go( HLBreakLibClass$Inst ) ;
    showOldCurs();
  else
    displayFormattedError(ErrorTextLibClass$Inst,
       ER_CANT_DO_COMMAND, FORCE_POPUP, asciiz("Go"), nil, nil);
  endif ;
}
!!
now(ButtonWindow)!!
/* BUTTON */
Def actionEmuHalt(self)
{
  HLBreakLibClass$Inst cor requireWithPath( HLBreakLib, "bkptexec.dll" ) ;

  if HLBreakLibClass$Inst
  then
    showWaitCurs();
    if TheSourcePresenter then
      stopAnimating(TheSourcePresenter);
    endif;
    flagBufclr := 0;
    halt( HLBreakLibClass$Inst ) ;
    showOldCurs();
  else
    displayFormattedError(ErrorTextLibClass$Inst,
       ER_CANT_DO_COMMAND, FORCE_POPUP, asciiz("Halt"), nil, nil);
  endif ;
}
!!
/* Snapshot: pvtest.ima, 8:32, 11/17/1997 */!!
Call SetMessageQueue(200)
openButtonBarPresenter(PreLauncher,nil)!!
/* Started image: pvtest.ima, 8:34, 11/17/1997 */!!
/* Started image: pvtest.ima, 8:35, 11/17/1997 */!!
/* Started image: pvtest.ima, 14:43, 11/24/1997 */!!
now(MapLib)!!
/* 2/4/1992 17:08 */
Def addImportProcs(self)
{
  add(self, #INITCSERVER,            1, #(0, 0));
  add(self, #INITSERVER,             1, nil);
  add(self, #GETMAPBLOCKSIZE,        1, #(1));
  add(self, #GETMAPBLOCKCOUNT,       1, #(1));
  add(self, #GETMAPBLOCKGRANULARITY, 1, #(1));
  add(self, #MAPGET,                 1, #(1));
  add(self, #MAPSET,                 1, #(1));
  add(self, #MAPCLEAR,               1, nil);
  add(self, #MAPBLOCKOVERLAP,        1, #(1, 1, 1));
  add(self, #GETMAPPRESENT,          0, nil);
  add(self, #MAPCONFIGCS,            1, nil);
  add(self, #MAPSAVECS,              1, #(1));
  add(self, #MAPRESTORECS,           1, #(1));
  add(self, #MAPPRESENTER,           1, #(0));
  add(self, #PERPRESENTER,           1, #(0));
  add(self, #MAPGETPERIODSTATUS,     1, #(1,1));
  add(self, #RELINKEP,               1, nil);
}
!!
now(MapLib)!!
Def perPresenter(self | rc myHandle)
{ 
  if pcallLock(self)
    myHandle := handle(TheToolBarPresenter);
    rc := pcall( procs[#PERPRESENTER], myHandle);
    pcallUNLock(self);
  else
    rc := ERR_PCALL_RECURSION;
  endif;

  ^rc;

}!!
now(MapLib)!!
Def getPeriodStatus(self | temp1, temp2)
{
  temp1 := new(Struct,4);
  temp2 := new(Struct,4);
  
  if pcallLock(self)
    lastError := pcall(procs[#MAPGETPERIODSTATUS], temp1, temp2);
    pcallUNLock(self);
  else 
    lastError := ERR_PCALL_RECURSION;
  endif;
  
  if (lastError <> 0)
    displayError(ErrorTextLibClass$Inst, lastError, CHECK_MODE);
    ^nil;
  endif;
  
  fRef := longAt(temp1, 0);
  nSec := longAt(temp2, 0);
  
  ^0;
}!!
now(class(PreLauncher))!!
Def launchPeriodPresenter(self, aWindow | Dlg result)
{
  showWaitCurs() ;
  requireWithPath(ProcLib,     "proc.dll"      );
  requireWithPath(SymbolLib,   "symbl.dll"     );
  requireWithPath(AddressLib,  "addr.dll"      );
  requireWithPath(MemServLib,  "mem.dll"       );
  requireWithPath(CpuLib,      "cpu.dll"       );
  requireWithPath(LoaderLib,   "loader.dll"    );
  requireWithPath(StackLib,    "stkservr.dll"  );
  requireWithPath(VarServLib,  "varservr.dll"  );
  requireWithPath(MapLib,      "map.dll"       );
  showOldCurs();
  result := perPresenter(MapLibClass$Inst);
  displayError(ErrorTextLibClass$Inst, result, FORCE_POPUP);
}!!
now(ButtonWindow)!!
/* 11/10/1997 11:55 */
Def actionPeriodicRefresh(self)
{ 
  if (getSystemType(ProcLibClass$Inst) = PROC_POWERSCOPE) then
    displayFormattedError(ErrorTextLibClass$Inst,
       ER_NOT_IN_POWERSCOPE, FORCE_POPUP, asciiz("Periodic refresh"), nil, nil);
    ^nil;
  endif;

  launchPeriodPresenter( PreLauncher, self ) ;
  
  if (MapLibClass$Inst) then
    getPeriodStatus(MapLibClass$Inst);
  endif;  
  
  pStart := 0;
}!!
now(ButtonWindow)!!
/* PRIVATE -- N.B. initButtons() must be called before drawLabels() */
Def init(self)
{
  init(self:ancestor);
  initTextMetrics(self);
  initButtons(self,
     (2 * TB_TO_BORDER) + tmHeight
  );
  initMenuBar(self);
  addAbout(self);              /* About box & Exit app */
  TheProjectInfoObj := init(new(PrjInfo));
  TheCursorLinkServer := new(CLServer, 1);
  initComplete := 0;
  flagBufclr := 0;
  fRef := 0;            
  pStart := 0;
  checkMenuItems(self);
}
!!
now(ButtonWindow)!!
/* WINDOWS
  timer event
*/
Def WM_TIMER(self, wP, lP)
{
   if (fRef = 1) then             
      pStart := pStart + 1;
      if (pStart > nSec) then
        pStart := 0;
        raStatus := getRunAccess(HLBrkRootLibClass$Inst);
        if (raStatus = BOOL_TRUE) then
          emStatus := prim_getEmulationStatus(requireWithPath(HLBrkRootLib,"bkroot.dll"));
          if (emStatus = HLB_EMU_RUNNING) then
            showWaitCurs();
            halt(HLBreakLibClass$Inst);
            go(HLBreakLibClass$Inst);  
            showOldCurs();             
          endif;
        endif;
      endif;  
   endif;

   if afterFIrstCallback
     hitSharedDataServer(SharedDataLibClass$Inst); /* force a comm read */
   else
     afterFIrstCallback := #true;
     startupScript(PreLauncher);
     openAllSavedWindows( PreLauncher );
  endif;

  ^0
}
!!
/* Snapshot: pvtest.ima, 14:50, 11/24/1997 */!!
/* Started image: pvtest.ima, 14:51, 11/24/1997 */!!
/* Started image: pvtest.ima, 15:27, 11/24/1997 */!!
/* Started image: pvtest.ima, 15:33, 11/24/1997 */!!
/* Started image: pvtest.ima, 15:34, 11/24/1997 */!!
now(DQviewInfo)!!
/* PRIVATE -- return  */
Def initFrameGroup(self, trace, dq, startFrame, numFrames, nextOrPrevious
    | bufStr realStartRef realEndRef textAddrRef textLenRef textColl retCode
      adrDescRef tmp)
{
  retCode := prim_trcTracingGet(TraceLibClass$Inst);
  /* if error or tracing just leave */
  if( (retCode[0] <> 0) cor (retCode[1] = 1) ) ^0; endif;

  showWaitCurs(); 

 def(UserType, #AddrDescArray, #(
    long descs 150));

  /* set startFrame position in trace */
  retCode := prim_trcReadFrameSet( trace, startFrame);
  if (retCode <> 0) then ^retCode endif ;

  if( numFrames < 25 ) 
    numFrames := 25;    /* force min. amount requested to 25 instructions */
  endif;
  /* do the frame search */
  realStartRef  := new( Struct, 4 ) ;
  realEndRef    := new( Struct, 4 ) ;
  textAddrRef   := new( Struct, 4 ) ;
  adrDescRef   := new( Struct, 4 ) ;  
  textLenRef    := new( Struct, 2 ) ;
  if (nextOrPrevious = #Next)
  then
    retCode := dadForwardDqInst( dq, numFrames, realStartRef, realEndRef, 
                            textAddrRef, textLenRef, adrDescRef) ;
  else
    retCode := dadBackwardDqInst( dq, numFrames, realStartRef, realEndRef, 
                            textAddrRef, textLenRef, adrDescRef ) ;
  endif ;
  
  if (retCode <> 0) 
    displayError(ErrorTextLibClass$Inst,retCode,FORCE_POPUP);
    showOldCurs();
    ^retCode;
  endif;    
/* we didn't get any frames (i.e.: no text) */
  if( wordAt(textLenRef,0) = 0 )
    cFree( MallocLibClass$Inst, longAt(textAddrRef, 0) ) ;
    /* @@@ need to free up addr descs and array */
    showOldCurs();
    ^retCode 
  endif; 

  /* get the text into a textCollection */
  add( textColl := new( TextCollection, 1), "" ) ;
  bufStr := physicalString(
               copyFromLong( new(Struct, wordAt(textLenRef,0)),
                             longAt(textAddrRef, 0) ) 
                           ) ;
                       
  descArray := cStructFromStruct(TbirdStruct,#AddrDescArray,
                     copyFromLong(new(Struct,600),longAt(adrDescRef,0)));
  insertText( textColl, bufStr, 0, 0 ) ; 
  cFree( MallocLibClass$Inst, longAt(textAddrRef, 0) ) ;
  cFree( MallocLibClass$Inst, longAt(adrDescRef, 0) ) ;
  removeLast( textColl ) ; 
  showOldCurs();
  ^initialize( self, 
               longAt(realStartRef, 0), longAt(realEndRef, 0), textColl )
}
!!
now(DQviewInfo)!!
Def remove(self | index)
{ index := 0;
  loop
  while (index < 150)
  begin
    if (descArray[#descs][index] <> 0) then
      destroyAddress(AddressLibClass$Inst,descArray[#descs][index]);
    endif;
    index := index + 1;
  endLoop;
  descArray := nil;
}!!
now(TracePresenter)!!
/* PUBLIC
   Initialize a new TracePresenter by initializing the menus and the 
   child windows.  The constants used as child window IDs are defined 
   in TRCPRSNT.H.
 */
Def init(self | aStr buffer) { 
  showWaitCurs();
  initTextMetrics(self);
  if not($commonEventLib)
    $commonEventLib :=
      eventOpen(requireWithPath(EventLib, "event.dll"), "default");
  endif;

  theTrace := traceOpen(requireWithPath(TraceLib, "trace.dll"),
    "hwtrc",CLOCK_CYCLE,TRIGGER_ALIGN);
  if not(theTrace) then
    ^nil;
  endif;
  theDq := dqOpen(requireWithPath(DqLib, getDasmDLLName(PreLauncher)),
    descriptor(theTrace));
  if not(theDq) then
    ^nil;
  endif;
  theTrigger :=
    triggerOpen(requireWithPath(TriggerLib, "trig.dll"), "", "default");
  /* added by cjchen 1996/12/23 */  
  theTraceBrowser:=open(TraceBrowser,self,nil,0,theTrace,theDq,TRviewInfo,
              {using(textStr, lineNum, hDC | txt index)
                txt := copyFrom(textStr, 0, hscrollIndex);
                index := size(txt);
                Call TextOut( hDC, 0, (lineNum * tmHeight), txt, index ) ;
                txt := copyFrom(textStr, leftChar+hscrollIndex,size(textStr));
                index := index * tmWidth;
                Call TextOut(hDC, index, (lineNum * tmHeight), txt, size(txt));
              });
  setBrowser(self,theTraceBrowser);
  /* eof by cjchen 1996/12/23 */
  /* removed by cjchen 1996/12/23     
  setBrowser(self,open(TraceBrowser,self,nil,0,theTrace,theDq,TRviewInfo,
              {using(textStr, lineNum, hDC | txt index)
                txt := copyFrom(textStr, 0, hscrollIndex);
                index := size(txt);
                Call TextOut( hDC, 0, (lineNum * tmHeight), txt, index ) ;
                txt := copyFrom(textStr, leftChar+hscrollIndex,size(textStr));
                index := index * tmWidth;
                Call TextOut(hDC, index, (lineNum * tmHeight), txt, size(txt));
              }));
  */
  horzbar := newHorz(ScrollBar, HSCROLL, self);
  hscrollIndex := trcFrameNumberAreaSizeGet(theTrace); 
  leftChar := 0; 

  titleWindow    := new(TraceTitleWindow, self, nil, 0);
  
  searchDlg := new(TraceSearchDlg);
  saveAsDlg := new(TraceSaveDialog);
  bufferDlg := new(TraceNumberDialog, "Buffer", "&Trace Buffer",
    #trcStartTraceBuffer, #trcEndTraceBuffer);
  setHelpEntry(bufferDlg, HE_DLGD_TRACENUM_BUFFER);
  frameDlg := new(TraceNumberDialog, "Frame", "&Frame Number",
    #traceBufferStart, #traceBufferEnd);
  zeroTSDlg := new(TimestampZeroDlg);
  systemCrystalDlg := new(SystemCrystalDlg);
                   
  setHelpEntry(frameDlg, HE_DLGD_TRACENUM_FRAME);
  initMenus(self);
  initScroll(self);
  sizeKids(self);
  symbolOn := 1;
  profileSetup(self);
  initEventNotifier( self ) ;
  /* generate an initial false event to setup menu selection - do it
     this way rather than duplicate the code. */
  notify(EvNoteLibClass$Inst,EVENT_TRIG_TRC_BUF_NUM);

  buffer := trcReadBufferGet(theTrace);
  aStr := "Trace - Buffer: "+asString(buffer);
  setText(self,aStr);
  setFrameLimitsFromTrace(browser(self));
  def(UserType, #AddrDescArray, #(
      long descs 150));
  showOldCurs();
}!!
now(TracePresenter)!!
Def printInstBuffer(self,trace,buffer,frames,file,dq
               | textLenRef textAddrRef curFrame startRef endRef
                 retCode numFrames addrDescRef descArray)
{ 
  if( (retCode:=prim_trcReadFrameSet(trace, frames[0])) <> 0 )
    ^retCode;
  endif;
  write(file,"Trace Buffer:  "+asString(buffer)+CR_LF);
  write(file,"Frames: "+asString(frames[0])+" to "+asString(frames[1])+CR_LF);
  write(file,CR_LF);
  curFrame := frames[0];
  startRef  := new( Struct, 4 ) ;
  endRef  := new( Struct, 4 ) ;
  addrDescRef  := new( Struct, 4 ) ;
  textAddrRef := new( Struct, 4);
  textLenRef := new( Struct, 2 ) ; 
  loop
  while curFrame < frames[1]
  begin 
    numFrames := frames[1] - curFrame;
    if( numFrames > 40 ) numFrames := 40; endif;
    retCode := dadForwardDqInst(dq,numFrames,startRef,endRef,textAddrRef,
                                textLenRef,addrDescRef);
    if( retCode = 0)
      prim_trcReadFrameSet(trace, (longAt(endRef,0) + 1L));
    endif;
    if( (retCode <> 0) cor 
         (TaskLibClass$Inst cand queryAbort(TaskLibClass$Inst)) 
         cor (wordAt(textLenRef,0) == 0) ) 
      curFrame := frames[1];   /* just leave with what we have */
      if(TaskLibClass$Inst cand queryAbort(TaskLibClass$Inst))
        retCode := 1; /* want calling routine to abort too */
      endif;
    else
      curFrame := longAt(endRef,0);
    endif;
    write(file, 
          physicalString(
                 copyFromLong( new(Struct, wordAt(textLenRef,0)),
                               longAt(textAddrRef, 0) ) )        
         ) ;
    cFree( MallocLibClass$Inst, longAt(textAddrRef, 0) ) ;
    descArray := cStructFromStruct(TbirdStruct,#AddrDescArray,
                   copyFromLong(new(Struct,600),longAt(addrDescRef,0)));

    numFrames := 0;  /* alias numFrames since too many locals */
    loop
    while (numFrames < 150)
    begin
      if (descArray[#descs][numFrames] <> 0) then
        destroyAddress(AddressLibClass$Inst,descArray[#descs][numFrames]);
      endif;
      numFrames := numFrames + 1;
    endLoop;
    cFree( MallocLibClass$Inst, longAt(addrDescRef, 0) ) ;

  endLoop;
  ^retCode;
}
!!
/* Snapshot: pvtest.ima, 15:36, 11/24/1997 */!!
/* Started image: pvtest.ima, 15:36, 11/24/1997 */!!
/* Started image: pvtest.ima, 15:37, 11/24/1997 */!!
/* Started image: pvtest.ima, 12:04, 11/26/1997 */!!
now(ButtonWindow)!!
/* PRIVATE -- N.B. initButtons() must be called before drawLabels() */
Def init(self)
{
  init(self:ancestor);
  initTextMetrics(self);
  initButtons(self,
     (2 * TB_TO_BORDER) + tmHeight
  );
  initMenuBar(self);
  addAbout(self);              /* About box & Exit app */
  TheProjectInfoObj := init(new(PrjInfo));
  TheCursorLinkServer := new(CLServer, 1);
  initComplete := 0;
  flagBufclr := 0;
  if (MapLibClass$Inst) then
    getPeriodStatus(MapLibClass$Inst);
  endif;            
  pStart := 0;
  checkMenuItems(self);
}
!!
now(ButtonWindow)!!
/* PRIVATE -- N.B. initButtons() must be called before drawLabels() */
Def init(self)
{
  init(self:ancestor);
  initTextMetrics(self);
  initButtons(self,
     (2 * TB_TO_BORDER) + tmHeight
  );
  initMenuBar(self);
  addAbout(self);              /* About box & Exit app */
  TheProjectInfoObj := init(new(PrjInfo));
  TheCursorLinkServer := new(CLServer, 1);
  initComplete := 0;
  flagBufclr := 0;
  if (MapLibClass$Inst) then
    getPeriodStatus(MapLibClass$Inst);
  endif;
  pStart := 0;
  if (fRef = 1)
     setRunAccess(HLBrkRootLibClass$Inst);
  endif;
  checkMenuItems(self);
}
!!
/* Snapshot: pvtest.ima, 12:08, 11/26/1997 */!!
/* Started image: pvtest.ima, 12:09, 11/26/1997 */!!
/* Started image: pvtest.ima, 8:54, 12/4/1997 */!!
now(ButtonWindow)!!
/* PRIVATE -- N.B. initButtons() must be called before drawLabels() */
Def init(self)
{
  init(self:ancestor);
  initTextMetrics(self);
  initButtons(self,
     (2 * TB_TO_BORDER) + tmHeight
  );
  initMenuBar(self);
  addAbout(self);              /* About box & Exit app */
  TheProjectInfoObj := init(new(PrjInfo));
  TheCursorLinkServer := new(CLServer, 1);
  initComplete := 0;
  flagBufclr := 0;
  if (MapLibClass$Inst) then
    getPeriodStatus(MapLibClass$Inst);
    getRunAccessStatus(MapLibClass$Inst);
  endif;
  pStart := 0;
  if (fRun = 1)
     setRunAccess(HLBrkRootLibClass$Inst);
  endif;
  checkMenuItems(self);
}
!!
now(ButtonWindow)!!
/* 12/3/1992 15:48 - PRIVATE
  Set runAccess mode on/off.
*/
Def menuRunAccess(self)
{
  /* Set runAccess if RunAccess is not ON, else clear it */
  if (getRunAccess(HLBrkRootLibClass$Inst) <> BOOL_TRUE) then
    setRunAccess(HLBrkRootLibClass$Inst);
    checkMenuItem(self, 505);
    fRun := 1;
    enableMenuItem(self, 515);      
  else
    clearRunAccess(HLBrkRootLibClass$Inst);
    unCheckMenuItem(self, 505);
    fRun := 0;    
    grayMenuItem(self, 515);    
  endif;
 
  if (MapLibClass$Inst) then
    setRunAccessStatus(MapLibClass$Inst,fRun);
  endif;
}
!!
now(ButtonWindow)!!
/* 12/3/1992 15:48 - PRIVATE
  Set runAccess mode on/off.
*/
Def menuRunAccess(self)
{
  /* Set runAccess if RunAccess is not ON, else clear it */
  if (getRunAccess(HLBrkRootLibClass$Inst) <> BOOL_TRUE) then
    setRunAccess(HLBrkRootLibClass$Inst);
    checkMenuItem(self, 505);
    fRun := 1;
    enableMenuItem(self, 515);      
  else
    clearRunAccess(HLBrkRootLibClass$Inst);
    unCheckMenuItem(self, 505);
    fRun := 0;    
    grayMenuItem(self, 515);    
  endif;
 
  if (MapLibClass$Inst) then
    setRunAccessStatus(MapLibClass$Inst,fRun);
  endif;
}
!!
now(MapLib)!!
/* 2/4/1992 17:08 */
Def addImportProcs(self)
{
  add(self, #INITCSERVER,            1, #(0, 0));
  add(self, #INITSERVER,             1, nil);
  add(self, #GETMAPBLOCKSIZE,        1, #(1));
  add(self, #GETMAPBLOCKCOUNT,       1, #(1));
  add(self, #GETMAPBLOCKGRANULARITY, 1, #(1));
  add(self, #MAPGET,                 1, #(1));
  add(self, #MAPSET,                 1, #(1));
  add(self, #MAPCLEAR,               1, nil);
  add(self, #MAPBLOCKOVERLAP,        1, #(1, 1, 1));
  add(self, #GETMAPPRESENT,          0, nil);
  add(self, #MAPCONFIGCS,            1, nil);
  add(self, #MAPSAVECS,              1, #(1));
  add(self, #MAPRESTORECS,           1, #(1));
  add(self, #MAPPRESENTER,           1, #(0));
  add(self, #PERPRESENTER,           1, #(0));
  add(self, #MAPGETPERIODSTATUS,     1, #(1,1));
  add(self, #MAPGETRUNACCESSSTATUS,  1, #(1)); 
  add(self, #MAPSETRUNACCESSSTATUS,  1, #(1));  
  add(self, #RELINKEP,               1, nil);
}
!!
now(MapLib)!!
/* 2/4/1992 17:08 */
Def addImportProcs(self)
{
  add(self, #INITCSERVER,            1, #(0, 0));
  add(self, #INITSERVER,             1, nil);
  add(self, #GETMAPBLOCKSIZE,        1, #(1));
  add(self, #GETMAPBLOCKCOUNT,       1, #(1));
  add(self, #GETMAPBLOCKGRANULARITY, 1, #(1));
  add(self, #MAPGET,                 1, #(1));
  add(self, #MAPSET,                 1, #(1));
  add(self, #MAPCLEAR,               1, nil);
  add(self, #MAPBLOCKOVERLAP,        1, #(1, 1, 1));
  add(self, #GETMAPPRESENT,          0, nil);
  add(self, #MAPCONFIGCS,            1, nil);
  add(self, #MAPSAVECS,              1, #(1));
  add(self, #MAPRESTORECS,           1, #(1));
  add(self, #MAPPRESENTER,           1, #(0));
  add(self, #PERPRESENTER,           1, #(0));
  add(self, #MAPGETPERIODSTATUS,     1, #(1,1));
  add(self, #MAPGETRUNACCESSSTATUS,  1, #(1)); 
  add(self, #MAPSETRUNACCESSSTATUS,  1, #(1));  
  add(self, #RELINKEP,               1, nil);
}
!!
now(MapLib)!!
/* 12/4/1997 9:06 */
Def getRunAccessStatus(self | temp)
{
  temp := new(Struct,4);

  if pcallLock(self)
    lastError := pcall(procs[#MAPGETRUNACCESSSTATUS], temp);
    pcallUNLock(self);
  else 
    lastError := ERR_PCALL_RECURSION;
  endif;
  
  if (lastError <> 0)
    displayError(ErrorTextLibClass$Inst, lastError, CHECK_MODE);
    ^nil;
  endif;
  
  fRun := longAt(temp, 0);
  
  ^0;
}!!
now(MapLib)!!
/* 12/4/1997 9:06 */
Def setRunAccessStatus(self, fRunAccess)
{ 
  if pcallLock(self)
    lastError := pcall(procs[#MAPSETRUNACCESSSTATUS], fRunAccess);
    pcallUNLock(self);
  else 
    lastError := ERR_PCALL_RECURSION;
  endif;
  
  if (lastError <> 0)
    displayError(ErrorTextLibClass$Inst, lastError, CHECK_MODE);
    ^nil;
  endif;
  
  ^0;
}!!
/* Snapshot: pvtest.ima, 9:06, 12/4/1997 */!!
/* Started image: pvtest.ima, 9:07, 12/4/1997 */!!
