home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / term-source.lha / EmulationDebug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  2.6 KB  |  133 lines

  1. /*
  2. **    EmulationDebug.c
  3. **
  4. **    Terminal emulation debugging support code
  5. **
  6. **    Copyright © 1990-1996 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #ifndef _GLOBAL_H
  13. #include "Global.h"
  14. #endif
  15.  
  16. STATIC struct Screen    *DebugScreen;
  17. STATIC struct Window    *DebugWindow;
  18. STATIC struct RastPort    *DebugRPort;
  19.  
  20. VOID
  21. DebugExit()
  22. {
  23.     if(DebugWindow)
  24.     {
  25.         CloseWindow(DebugWindow);
  26.  
  27.         DebugWindow = NULL;
  28.     }
  29.  
  30.     if(DebugScreen)
  31.     {
  32.         CloseScreen(DebugScreen);
  33.  
  34.         DebugScreen = NULL;
  35.     }
  36. }
  37.  
  38. BOOL
  39. DebugInit()
  40. {
  41.     if(DebugScreen)
  42.         return(TRUE);
  43.     else
  44.     {
  45.         ULONG             DisplayID = DEFAULT_MONITOR_ID | HIRESLACE_KEY;
  46.         struct Screen    *PubScreen;
  47.  
  48.         if(PubScreen = LockPubScreen(NULL))
  49.         {
  50.             DisplayID = GetVPModeID(&PubScreen -> ViewPort);
  51.  
  52.             UnlockPubScreen(NULL,PubScreen);
  53.         }
  54.  
  55.         if(DebugScreen = OpenScreenTags(NULL,
  56.             SA_Depth,        1,
  57.             SA_Overscan,    OSCAN_TEXT,
  58.             SA_DisplayID,    DisplayID,
  59.             SA_Font,        &DefaultFont,
  60.             SA_Title,        "term Debug Screen",
  61.             SA_Behind,        TRUE,
  62.         TAG_DONE))
  63.         {
  64.             if(DebugWindow = OpenWindowTags(NULL,
  65.                 WA_CustomScreen,    DebugScreen,
  66.                 WA_Top,                DebugScreen -> BarHeight + 1,
  67.                 WA_Left,            0,
  68.                 WA_Width,            DebugScreen -> Width,
  69.                 WA_Height,            DebugScreen -> Height - (DebugScreen -> BarHeight + 1),
  70.                 WA_RMBTrap,            TRUE,
  71.                 WA_Backdrop,        TRUE,
  72.                 WA_Borderless,        TRUE,
  73.             TAG_DONE))
  74.             {
  75.                 DebugRPort = DebugWindow -> RPort;
  76.  
  77.                 return(TRUE);
  78.             }
  79.  
  80.             CloseScreen(DebugScreen);
  81.  
  82.             DebugScreen = NULL;
  83.         }
  84.  
  85.         return(FALSE);
  86.     }
  87. }
  88.  
  89. VOID
  90. DebugShowScrollInfo(VOID)
  91. {
  92.     UBYTE    LocalBuffer[256];
  93.     LONG    i,Left;
  94.  
  95.     for(i = 0 ; i < RasterHeight ; i++)
  96.     {
  97.         if(i == ScrollLineFirst)
  98.             SPrintf(LocalBuffer,"+%3ld %02lx",i,ScrollLines[i] . ColourMask);
  99.         else
  100.         {
  101.             if(i == ScrollLineLast)
  102.                 SPrintf(LocalBuffer,"-%3ld %02lx",i,ScrollLines[i] . ColourMask);
  103.             else
  104.                 SPrintf(LocalBuffer," %3ld %02lx",i,ScrollLines[i] . ColourMask);
  105.         }
  106.  
  107.         if(i == ScrollLineFirst || i == ScrollLineLast)
  108.             SetABPenDrMd(DebugRPort,0,1,JAM2);
  109.         else
  110.             SetABPenDrMd(DebugRPort,1,0,JAM2);
  111.  
  112.         Move(DebugRPort,0,DebugRPort -> TxBaseline + i * DebugRPort -> TxHeight);
  113.         Text(DebugRPort,LocalBuffer,strlen(LocalBuffer));
  114.  
  115.         Left = DebugRPort -> cp_x;
  116.  
  117.         SetABPenDrMd(DebugRPort,0,0,JAM1);
  118.         RectFill(DebugRPort,Left,i * DebugRPort -> TxHeight,DebugWindow -> Width - 1,(i + 1) * DebugRPort -> TxHeight - 1);
  119.  
  120.         if(ScrollLines[i] . Width)
  121.         {
  122.             ULONG Ghosting = 0x44441111;
  123.  
  124.             SetAPen(DebugRPort,1);
  125.             SetAfPt(DebugRPort,(UWORD *)&Ghosting,1);
  126.  
  127.             RectFill(DebugRPort,Left + ScrollLines[i] . Left * 3,i * DebugRPort -> TxHeight,Left + ScrollLines[i] . Right * 3 - 1,(i + 1) * DebugRPort -> TxHeight - 1);
  128.  
  129.             SetAfPt(DebugRPort,NULL,0);
  130.         }
  131.     }
  132. }
  133.