home *** CD-ROM | disk | FTP | other *** search
/ Doom Fever / Doom_Fever-1995_Maple_Media.iso / wad / source.zip / EDIT.C < prev    next >
C/C++ Source or Header  |  1994-05-17  |  51KB  |  1,744 lines

  1. /*
  2.    Doom Editor Utility, by Brendon Wyber and Raphaël Quinet.
  3.  
  4.    You are allowed to use any parts of this code in another program, as
  5.    long as you give credits to the authors in the documentation and in
  6.    the program itself.  Read the file README.1ST for more information.
  7.  
  8.    This program comes with absolutely no warranty.
  9.  
  10.    EDIT.C - Editor routines.
  11. */
  12.  
  13. /* the includes */
  14. #include "deu.h"
  15. #include "levels.h"
  16. extern Bool InfoShown;        /* should we display the info bar? */
  17. #ifdef CIRRUS_PATCH
  18. extern char HWCursor[];        /* Cirrus hardware cursor data */
  19. #endif /* CIRRUS_PATCH */
  20.  
  21. int  MoveSpeed = 20;        /* movement speed */
  22.  
  23.  
  24. /*
  25.    the driving program
  26. */
  27.  
  28. void EditLevel( int episode, int mission, Bool newlevel)
  29. {
  30.    ReadWTextureNames();
  31.    ReadFTextureNames();
  32.    InitGfx();
  33.    CheckMouseDriver();
  34.    if (episode < 1 || mission < 1)
  35.       SelectLevel( &episode, &mission);
  36.    if (episode > 0 && mission > 0)
  37.    {
  38.       ClearScreen();
  39.       ReadLevelData( episode, mission);
  40.       if (newlevel)
  41.       {
  42.      ForgetLevelData();
  43.      MapMinX = -4000;
  44.      MapMinY = -4000;
  45.      MapMaxX = 4000;
  46.      MapMaxY = 4000;
  47.       }
  48.       LogMessage( ": Editing E%dM%d...\n", episode, mission);
  49.       EditorLoop( episode, mission);
  50.       LogMessage( ": Finished editing E%dM%d...\n", episode, mission);
  51.       TermGfx();
  52.       if (! Registered)
  53.      printf( "Please register DOOM if you want to be able to save your changes.\n");
  54.       ForgetLevelData();
  55.       /* forget the level pointer */
  56.       Level = NULL;
  57.    }
  58.    else
  59.       TermGfx();
  60.    ForgetWTextureNames();
  61.    ForgetFTextureNames();
  62. }
  63.  
  64.  
  65.  
  66. /*
  67.    select a level
  68. */
  69.  
  70. void SelectLevel( int *episode, int *mission)
  71. {
  72.    MDirPtr dir;
  73.    char name[ 7];
  74.    char **levels;
  75.    int n = 0;
  76.  
  77.    dir = MasterDir;
  78.    while (dir)
  79.    {
  80.       if (dir->dir.size == 0 && dir->dir.name[ 0] == 'E' && dir->dir.name[ 2] == 'M' && dir->dir.name[ 4] == '\0')
  81.       {
  82.      if (n == 0)
  83.         levels = GetMemory( sizeof( char *));
  84.      else
  85.         levels = ResizeMemory( levels, (n + 1) * sizeof( char *));
  86.      levels[ n] = dir->dir.name;
  87.      n++;
  88.       }
  89.       dir = dir->next;
  90.    }
  91.    if (*episode < 1)
  92.       *episode = 1;
  93.    if (*mission < 1)
  94.       *mission = 1;
  95.    sprintf( name, "E%dM%d", *episode, *mission);
  96.    InputNameFromList( -1, -1, "Select an episode and a mission number:", n, levels, name);
  97.    FreeMemory( levels);
  98.    if (*name)
  99.       sscanf( name, "E%dM%d", episode, mission);
  100.    else
  101.    {
  102.       *episode = 0;
  103.       *mission = 0;
  104.    }
  105. }
  106.  
  107.  
  108.  
  109. /*
  110.    get the name of the new WAD file
  111. */
  112.  
  113. char *GetWadFileName( int episode, int mission)
  114. {
  115.    char *outfile = GetMemory( 80);
  116.    char *dotp;
  117.    WadPtr wad;
  118.  
  119.    /* get the file name */
  120.    if (! strcmp(Level->wadfile->filename, MainWad))
  121.       sprintf( outfile, "E%dM%d.WAD", episode, mission);
  122.    else
  123.       strcpy( outfile, Level->wadfile->filename);
  124.    do
  125.    {
  126.       InputFileName( -1, -1, "Name of the new WAD file:", 79, outfile);
  127.    }
  128.    while (!strcmp(outfile, MainWad));
  129.    /* escape */
  130.    if (outfile[ 0] == '\0')
  131.    {
  132.       FreeMemory( outfile);
  133.       return NULL;
  134.    }
  135.    /* if the WAD file already exists, rename it to "*.BAK" */
  136.    for (wad = WadFileList; wad; wad = wad->next)
  137.       if (!stricmp( outfile, wad->filename))
  138.       {
  139.      dotp = strrchr( wad->filename, '.');
  140.      if (dotp == NULL)
  141.         strcat( wad->filename, ".BAK");
  142.      else
  143.         strcpy( dotp, ".BAK");
  144.      /* need to close, then reopen: problems with SHARE.EXE */
  145.      fclose( wad->fileinfo);
  146.      if (rename( outfile, wad->filename) < 0)
  147.      {
  148.         if (unlink( wad->filename) < 0)
  149.            ProgError( "could not delete file \"%s\"", wad->filename);
  150.         if (rename( outfile, wad->filename) < 0)
  151.            ProgError( "could not rename \"%s\" to \"%s\"", outfile, wad->filename);
  152.      }
  153.      wad->fileinfo = fopen( wad->filename, "rb");
  154.      if (wad->fileinfo == NULL)
  155.         ProgError( "could not reopen file \"%s\"", wad->filename);
  156.      break;
  157.       }
  158.    return outfile;
  159. }
  160.  
  161.  
  162.  
  163. /*
  164.    display the help screen
  165.  */
  166.  
  167. void DisplayHelp( int objtype, int grid) /* SWAP! */
  168. {
  169.    int x0 = 137;
  170.    int y0 = 50;
  171.  
  172.    if (UseMouse)
  173.       HideMousePointer();
  174.    /* put in the instructions */
  175.    DrawScreenBox3D( x0, y0, x0 + 364, y0 + 355);
  176.    SetColor( LIGHTCYAN);
  177.    DrawScreenText( x0 + 100, y0 + 20, "Doom Editor Utility");
  178.    DrawScreenText( 269 - strlen(GetEditModeName( objtype)) * 4, y0 + 32, "- %s Editor -", GetEditModeName( objtype));
  179.    SetColor( BLACK);
  180.    DrawScreenText( x0 + 10, y0 + 60, "Use the mouse or the cursor keys to move");
  181.    DrawScreenText( -1, -1, "around.  The map scrolls when the pointer");
  182.    DrawScreenText( -1, -1, "reaches the edge of the screen.");
  183.    DrawScreenText( -1, y0 + 100, "Other useful keys are:");
  184.    if (Registered)
  185.       DrawScreenText( -1, y0 + 115, "Q     - Quit, saving changes");
  186.    else
  187.    {
  188.       SetColor( DARKGRAY);
  189.       DrawScreenText( -1, y0 + 115, "Q     - Quit without saving changes");
  190.       SetColor( BLACK);
  191.    }
  192.    DrawScreenText( -1, -1, "Esc   - Exit without saving changes");
  193.    DrawScreenText( -1, -1, "Tab   - Switch to the next editing mode");
  194.    DrawScreenText( -1, -1, "Space - Change the move/scroll speed");
  195.    DrawScreenText( -1, -1, "+/-   - Change the map scale (current: %d)", (int) (1.0 / Scale + 0.5));
  196.    DrawScreenText( -1, -1, "G     - Change the grid scale (cur.: %d)", grid);
  197.    DrawScreenText( -1, -1, "N, >  - Jump to the next object.");
  198.    DrawScreenText( -1, -1, "P, <  - Jump to the previous object.");
  199.    DrawScreenText( -1, -1, "J, #  - Jump to a specific object (enter #)");
  200.    DrawScreenText( -1, -1, "M     - Mark/unmark current object (select)");
  201.    if (objtype == OBJ_THINGS || objtype == OBJ_VERTEXES)
  202.       DrawScreenText( -1, -1, "D     - Toggle drag mode");
  203.    else
  204.       DrawScreenText( -1, -1, "C     - Clear all marks and redraw map");
  205.    DrawScreenText( -1, -1, "Ins   - Insert a new object");
  206.    DrawScreenText( -1, -1, "Del   - Delete the current object");
  207.    DrawScreenText( -1, -1, "Enter - Edit the current/selected object(s)");
  208.    DrawScreenText( -1, y0 + 265, "Mouse buttons:");
  209.    if (SwapButtons)
  210.    {
  211.       DrawScreenText( -1, y0 + 280, "Left  - Edit the current/selected object(s)");
  212.       DrawScreenText( -1, -1, "Middle- Mark/unmark the current object.");
  213.    }
  214.    else
  215.    {
  216.       DrawScreenText( -1, y0 + 280, "Left  - Mark/unmark the current object");
  217.       DrawScreenText( -1, -1, "Middle- Edit the current/selected object(s)");
  218.    }
  219.    DrawScreenText( -1, -1, "Right - Drag the current/selected object(s)");
  220.    DrawScreenText( -1, y0 + 320, "Please read DEU.TXT for more information");
  221.    SetColor( YELLOW);
  222.    DrawScreenText( -1, y0 + 340, "Press any key to return to the editor...");
  223.    bioskey( 0);
  224.    if (UseMouse)
  225.       ShowMousePointer();
  226. }
  227.  
  228.  
  229.  
  230. /*
  231.    the editor main loop
  232. */
  233.  
  234. void EditorLoop( int episode, int mission) /* SWAP! */
  235. {
  236.    int    EditMode = OBJ_THINGS;
  237.    int    CurObject = -1;
  238.    int    OldObject = -1;
  239.    Bool   RedrawMap = TRUE;
  240.    Bool   RedrawObj = FALSE;
  241.    Bool   DragObject = FALSE;
  242.    int    key, altkey, buttons, oldbuttons;
  243.    int    GridScale = 0;
  244.    Bool   GridShown = TRUE;
  245.    SelPtr Selected = NULL;
  246.    char   keychar;
  247.    int    SelBoxX = 0;
  248.    int    SelBoxY = 0;
  249.    int    OldPointerX = 0;
  250.    int    OldPointerY = 0;
  251.    Bool   StretchSelBox = FALSE;
  252.    Bool   ShowRulers = FALSE;
  253.  
  254.    MadeChanges = FALSE;
  255.    MadeMapChanges = FALSE;
  256.    if (InitialScale < 1)
  257.       InitialScale = 1;
  258.    else if (InitialScale > 20)
  259.       InitialScale = 20;
  260.    Scale = (float) (1.0 / InitialScale);
  261.    CenterMapAroundCoords( (MapMinX + MapMaxX) / 2, (MapMinY + MapMaxY) / 2);
  262.    if (UseMouse)
  263.    {
  264.       ResetMouseLimits();
  265.       SetMouseCoords( PointerX, PointerY);
  266.       ShowMousePointer();
  267. #ifdef CIRRUS_PATCH
  268.       if (CirrusCursor == TRUE)
  269.       {
  270.      SetHWCursorMap( HWCursor);
  271.      SetHWCursorPos( PointerX, PointerY);
  272.       }
  273. #endif /* CIRRUS_PATCH */
  274.       oldbuttons = 0;
  275.    }
  276.    else
  277.       FakeCursor = TRUE;
  278.  
  279.    for (;;)
  280.    {
  281.       key = 0;
  282.       altkey = 0;
  283.  
  284.       /* get mouse position and button status */
  285.       if (UseMouse)
  286.       {
  287.      if (FakeCursor || ShowRulers)
  288.      {
  289.         HideMousePointer();
  290.         DrawPointer( ShowRulers);
  291.         ShowMousePointer();
  292.      }
  293.      GetMouseCoords( &PointerX, &PointerY, &buttons);
  294.      if (FakeCursor || ShowRulers)
  295.      {
  296.         HideMousePointer();
  297.         DrawPointer( ShowRulers);
  298.         ShowMousePointer();
  299.      }
  300.      if ( buttons == 1 && PointerY < 17)
  301.      {
  302.         /* kluge for the menu bar */
  303.         altkey = 0x08;
  304.         if (PointerX < 12)
  305.            Beep();
  306.         else if (PointerX < 60)
  307.            key = 0x2100; /* 'F' */
  308.         else if (PointerX < 108)
  309.            key = 0x1200; /* 'E' */
  310.         else if (PointerX < 172)
  311.            key = 0x1f00; /* 'S' */
  312.         else if (PointerX < 228)
  313.            key = 0x3200; /* 'M' */
  314.         else if (PointerX < 276)
  315.            key = 0x1700; /* 'I' */
  316.         else if (PointerX < 348)
  317.            key = 0x1800; /* 'O' */
  318.         else if (PointerX < 406)
  319.            key = 0x2E00; /* 'C' */
  320.         else if (PointerX < ScrMaxX - 43)
  321.            Beep();
  322.         else
  323.            key = 0x2300; /* 'H' */
  324.      }
  325.      else
  326.      {
  327.         if (buttons != oldbuttons)
  328.         {
  329.            switch (buttons)
  330.            {
  331.            case 1:
  332.           if (SwapButtons)
  333.              key = 0x000D;
  334.           else
  335.              key = 'M';      /* Press left button = Mark/Unmark ('M') */
  336.           break;
  337.            case 2:
  338.           if (! DragObject)
  339.              key = 'D';      /* Press right button = Drag */
  340.           break;
  341.            case 3:
  342.            case 4:
  343.           if (SwapButtons)
  344.              key = 'M';
  345.           else
  346.              key = 0x000D;   /* Press middle button = Edit ('Enter') */
  347.           break;
  348.            default:
  349.           if (StretchSelBox) /* Release left button = End Selection Box */
  350.              key = 'M';
  351.           if (DragObject)    /* Release right button = End Drag */
  352.              key = 'D';
  353.           break;
  354.            }
  355.            altkey = bioskey( 2);
  356.         }
  357.      }
  358.      oldbuttons = buttons;
  359.       }
  360.  
  361.       /* drag object(s) */
  362.       if (DragObject)
  363.       {
  364.      int forgetit = FALSE;
  365.  
  366.      if (IsSelected( Selected, CurObject) == FALSE)
  367.         ForgetSelection( &Selected);
  368.      else if (Selected->objnum != CurObject)
  369.      {
  370.         /* current object must be first in the list */
  371.         UnSelectObject( &Selected, CurObject);
  372.         SelectObject( &Selected, CurObject);
  373.      }
  374.      if (Selected == NULL && CurObject >= 0)
  375.      {
  376.         SelectObject( &Selected, CurObject);
  377.         forgetit = TRUE;
  378.      }
  379.      if (Selected)
  380.      {
  381.         if (MoveObjectsToCoords( EditMode, Selected, MAPX( PointerX), MAPY( PointerY), GridScale))
  382.            RedrawMap = TRUE;
  383.         if (forgetit)
  384.            ForgetSelection( &Selected);
  385.      }
  386.      else
  387.      {
  388.         Beep();
  389.         DragObject = FALSE;
  390.      }
  391.       }
  392.       else if (StretchSelBox)
  393.       {
  394.      int x = MAPX( PointerX);
  395.      int y = MAPY( PointerY);
  396.  
  397.      /* draw selection box */
  398.      SetColor( CYAN);
  399.      setwritemode( XOR_PUT);
  400.      if (UseMouse)
  401.         HideMousePointer();
  402.      DrawMapLine( SelBoxX, SelBoxY, SelBoxX, y);
  403.      DrawMapLine( SelBoxX, y, x, y);
  404.      DrawMapLine( x, y, x, SelBoxY);
  405.      DrawMapLine( x, SelBoxY, SelBoxX, SelBoxY);
  406.      if (UseMouse)
  407.         ShowMousePointer();
  408.      delay( 50);
  409.      if (UseMouse)
  410.         HideMousePointer();
  411.      DrawMapLine( SelBoxX, SelBoxY, SelBoxX, y);
  412.      DrawMapLine( SelBoxX, y, x, y);
  413.      DrawMapLine( x, y, x, SelBoxY);
  414.      DrawMapLine( x, SelBoxY, SelBoxX, SelBoxY);
  415.      setwritemode( COPY_PUT);
  416.      if (UseMouse)
  417.         ShowMousePointer();
  418.       }
  419.       else if (!RedrawObj)
  420.       {
  421.      /* check if there is something near the pointer */
  422.      OldObject = CurObject;
  423.      if ((bioskey( 2) & 0x03) == 0x00)  /* no shift keys */
  424.         CurObject = GetCurObject( EditMode, MAPX( PointerX - 4), MAPY( PointerY - 4), MAPX( PointerX + 4), MAPY( PointerY + 4));
  425.      if (CurObject < 0)
  426.         CurObject = OldObject;
  427.       }
  428.  
  429.       /* draw the map */
  430.       if (RedrawMap)
  431.       {
  432.      if (UseMouse)
  433.         HideMousePointer();
  434.      DrawMap( EditMode, GridScale, GridShown);
  435.      HighlightSelection( EditMode, Selected);
  436.      if (UseMouse)
  437.         ShowMousePointer();
  438.       }
  439.  
  440.       /* highlight the current object and display the information box */
  441.       if (RedrawMap || CurObject != OldObject || RedrawObj)
  442.       {
  443.      RedrawObj = FALSE;
  444.      if (UseMouse)
  445.         HideMousePointer();
  446.      if (!RedrawMap && OldObject >= 0)
  447.         HighlightObject( EditMode, OldObject, YELLOW);
  448.      if (CurObject != OldObject)
  449.      {
  450.         PlaySound( 50, 10);
  451.         OldObject = CurObject;
  452.      }
  453.      if (CurObject >= 0)
  454.         HighlightObject( EditMode, CurObject, YELLOW);
  455.      if (bioskey( 1)) /* speedup */
  456.         RedrawObj = TRUE;
  457.      else
  458.         DisplayObjectInfo( EditMode, CurObject);
  459.      if (UseMouse)
  460.         ShowMousePointer();
  461.       }
  462.  
  463.       /* redraw the pointer if necessary */
  464.       if (RedrawMap && (FakeCursor || ShowRulers))
  465.       {
  466.      if (UseMouse)
  467.         HideMousePointer();
  468.      DrawPointer( ShowRulers);
  469.      if (UseMouse)
  470.         ShowMousePointer();
  471.       }
  472.  
  473.       /* display the current pointer coordinates */
  474.       if (RedrawMap || PointerX != OldPointerX || PointerY != OldPointerY)
  475.       {
  476.      SetColor( LIGHTGRAY);
  477.      DrawScreenBox( ScrMaxX - 170, 4, ScrMaxX - 50, 12);
  478.      SetColor( BLUE);
  479.      DrawScreenText( ScrMaxX - 170, 4, "%d, %d", MAPX( PointerX), MAPY( PointerY));
  480.      OldPointerX = PointerX;
  481.      OldPointerY = PointerY;
  482.       }
  483.  
  484.       /* the map is up to date */
  485.       RedrawMap = FALSE;
  486.  
  487.       /* get user input */
  488.       if (bioskey( 1) || key)
  489.       {
  490.      if (! key)
  491.      {
  492.         key = bioskey( 0);
  493.         altkey = bioskey( 2);
  494.      }
  495.  
  496.      /* user wants to access the drop-down menus */
  497.      if (altkey & 0x08)    /* if alt is pressed... */
  498.      {
  499.         if ((key & 0xFF00) == 0x2100)       /* Scan code for F */
  500.            key = PullDownMenu( 18, 19,
  501.                    "Save         F2", 0x3C00,    (int) 'S', 1,
  502.                    "Save As ExMx F3", 0x3D00,    (int) 'A', 6,
  503.                    "Print          ", -1,        (int) 'P', -1,
  504.                    "Quit          Q", (int) 'Q', (int) 'Q', 1,
  505.                    NULL);
  506.         else if ((key & 0xFF00) == 0x1200)  /* Scan code for E */
  507.         {
  508.            key = PullDownMenu( 66, 19,
  509.                    "Copy object(s)      O", (int) 'O', (int) 'C', 1,
  510.                    "Add object        Ins", 0x5200,    (int) 'A', 1,
  511.                    "Delete object(s)  Del", 0x5300,    (int) 'D', 1,
  512.                    ((EditMode == OBJ_VERTEXES) ?
  513.                    NULL :
  514.                    "Preferences        F5"), 0x3F00,   (int) 'P', 1,
  515.                    NULL);
  516.         }
  517.         else if ((key & 0xFF00) == 0x1F00)  /* Scan code for S */
  518.            key = PullDownMenu( 114, 19,
  519.                    "Find/Change       F4", -1,        (int) 'F', -1,
  520.                    "Repeat last find    ", -1,        (int) 'R', -1,
  521.                    "Next object        N", (int) 'N', (int) 'N', 1,
  522.                    "Prev object        P", (int) 'P', (int) 'P', 1,
  523.                    "Jump to object...  J", (int) 'J', (int) 'J', 1,
  524.                    NULL);
  525.         else if ((key & 0xFF00) == 0x3200)  /* Scan code for M */
  526.            key = PullDownMenu( 178, 19,
  527.                    ((EditMode == OBJ_THINGS) ?
  528.                    "√ Things              T" :
  529.                    "  Things              T"), (int) 'T', (int) 'T', 3,
  530.                    ((EditMode == OBJ_LINEDEFS) ?
  531.                    "√ Linedefs+Sidedefs   L" :
  532.                    "  Linedefs+Sidedefs   L"), (int) 'L', (int) 'L', 3,
  533.                    ((EditMode == OBJ_VERTEXES) ?
  534.                    "√ Vertexes            V" :
  535.                    "  Vertexes            V"), (int) 'V', (int) 'V', 3,
  536.                    ((EditMode == OBJ_SECTORS) ?
  537.                    "√ Sectors             S" :
  538.                    "  Sectors             S"), (int) 'S', (int) 'S', 3,
  539.                    "  Next mode         Tab",  0x0009,    (int) 'N', 3,
  540.                    "  Last mode   Shift+Tab",  0x0F00,    (int) 'L', 3,
  541.                    "  3D Preview          3",  (int) '3', (int) '3', -1,
  542.                    NULL);
  543.         else if ((key & 0xFF00) == 0x1700)  /* Scan code for I */
  544.         {
  545.            key = 0;
  546.            /* code duplicated from 'F8' - I hate to do that */
  547.            if (Selected)
  548.           MiscOperations( 234, 19, EditMode, &Selected);
  549.            else
  550.            {
  551.           if (CurObject >= 0)
  552.              SelectObject( &Selected, CurObject);
  553.           MiscOperations( 234, 19, EditMode, &Selected);
  554.           if (CurObject >= 0)
  555.              UnSelectObject( &Selected, CurObject);
  556.            }
  557.            CurObject = -1;
  558.            DragObject = FALSE;
  559.            StretchSelBox = FALSE;
  560.         }
  561.         else if ((key & 0xFF00) == 0x1800)  /* Scan code for O */
  562.         {
  563.            int savednum, i;
  564.  
  565.            key = 0;
  566.            /* don't want to create the object behind the menu bar... */
  567.            if (PointerY < 20)
  568.            {
  569.           PointerX = ScrCenterX;
  570.           PointerY = ScrCenterY;
  571.            }
  572.            /* code duplicated from 'F9' - I hate to do that */
  573.            savednum = NumLineDefs;
  574.            InsertStandardObject( 282, 19, MAPX( PointerX), MAPY( PointerY));
  575.            if (NumLineDefs > savednum)
  576.            {
  577.           ForgetSelection( &Selected);
  578.           EditMode = OBJ_LINEDEFS;
  579.           for (i = savednum; i < NumLineDefs; i++)
  580.              SelectObject( &Selected, i);
  581.           CurObject = NumLineDefs - 1;
  582.           OldObject = -1;
  583.           DragObject = FALSE;
  584.           StretchSelBox = FALSE;
  585.            }
  586.         }
  587.         else if ((key & 0xFF00) == 0x2E00)  /* Scan code for C */
  588.         {
  589.            key = 0;
  590.            CheckLevel( 354, 19);
  591.         }
  592.         else if ((key & 0xFF00) == 0x2300)  /* Scan code for H */
  593.            key = PullDownMenu( ScrMaxX, 19,
  594.                    "  Keyboard & mouse  F1",  0x3B00,    (int) 'K', 3,
  595.                    (InfoShown ?
  596.                    "√ Info bar           I" :
  597.                    "  Info bar           I"), (int) 'I', (int) 'I', 3,
  598.                    "  About DEU...        ",  -1,        (int) 'A', -1,
  599.                    NULL);
  600.         else
  601.         {
  602.            Beep();
  603.            key = 0;
  604.         }
  605.         RedrawMap = TRUE;
  606.      }
  607.  
  608.      /* User wants to do the impossible. */
  609.      if (key == -1)
  610.      {
  611.         NotImplemented();
  612.         RedrawMap = TRUE;
  613.      }
  614.  
  615.      /* simplify the checks later on */
  616.      if (isprint(key & 0x00ff))
  617.         keychar = toupper(key);
  618.      else
  619.         keychar = '\0';
  620.  
  621.      /* erase the (keyboard) pointer */
  622.      if (FakeCursor || ShowRulers)
  623.      {
  624.         HideMousePointer();
  625.         DrawPointer( ShowRulers);
  626.         ShowMousePointer();
  627.      }
  628.  
  629.      /* user wants to exit */
  630.      if (keychar == 'Q')
  631.      {
  632.         ForgetSelection( &Selected);
  633.         if (CheckStartingPos())
  634.         {
  635.            if (Registered && MadeChanges)
  636.            {
  637.           char *outfile;
  638.  
  639.           outfile = GetWadFileName( episode, mission);
  640.           if (outfile)
  641.           {
  642.              SaveLevelData( outfile);
  643.              break;
  644.           }
  645.            }
  646.            else
  647.           break;
  648.         }
  649.         RedrawMap = TRUE;
  650.      }
  651.      else if ((key & 0x00FF) == 0x001B) /* 'Esc' */
  652.      {
  653.         if (DragObject)
  654.            DragObject = FALSE;
  655.         else if (StretchSelBox)
  656.            StretchSelBox = FALSE;
  657.         else
  658.         {
  659.            ForgetSelection( &Selected);
  660.            if (!MadeChanges || Confirm(-1, -1, "You have unsaved changes.  Do you really want to quit?", NULL))
  661.           break;
  662.            RedrawMap = TRUE;
  663.         }
  664.      }
  665.  
  666.      /* user is lost */
  667.      else if ((key & 0xFF00) == 0x3B00) /* 'F1' */
  668.      {
  669.         DisplayHelp( EditMode, GridScale);
  670.         RedrawMap = TRUE;
  671.      }
  672.  
  673.      /* user wants to save the level data */
  674.      else if ((key & 0xFF00) == 0x3C00 && Registered) /* 'F2' */
  675.      {
  676.         char *outfile;
  677.  
  678.         if (CheckStartingPos())
  679.         {
  680.            outfile = GetWadFileName( episode, mission);
  681.            if (outfile)
  682.           SaveLevelData( outfile);
  683.         }
  684.         RedrawMap = TRUE;
  685.      }
  686.  
  687.      /* user wants to save and change the episode and mission numbers */
  688.      else if ((key & 0xFF00) == 0x3D00 && Registered) /* 'F3' */
  689.      {
  690.         char *outfile;
  691.         int   e, m;
  692.         MDirPtr newLevel, oldl, newl;
  693.         char name[ 7];
  694.  
  695.         if (CheckStartingPos())
  696.         {
  697.            outfile = GetWadFileName( episode, mission);
  698.            if (outfile)
  699.            {
  700.           e = episode;
  701.           m = mission;
  702.           SelectLevel( &e, &m);
  703.           if (e > 0 && m > 0 && (e != episode || m != mission))
  704.           {
  705.              /* horrible but it works... */
  706.              episode = e;
  707.              mission = m;
  708.              sprintf( name, "E%dM%d", episode, mission);
  709.              newLevel = FindMasterDir( MasterDir, name);
  710.              oldl = Level;
  711.              newl = newLevel;
  712.              for (m = 0; m < 11; m++)
  713.              {
  714.             newl->wadfile = oldl->wadfile;
  715.             if (m > 0)
  716.                newl->dir = oldl->dir;
  717.             /*
  718.             if (!strcmp( outfile, oldl->wadfile->filename))
  719.             {
  720.                oldl->wadfile = WadFileList;
  721.                oldl->dir = lost...
  722.             }
  723.             */
  724.             oldl = oldl->next;
  725.             newl = newl->next;
  726.              }
  727.              Level = newLevel;
  728.           }
  729.           SaveLevelData( outfile);
  730.            }
  731.         }
  732.         RedrawMap = TRUE;
  733.      }
  734.  
  735.      /* user wants to get the 'Preferences' menu */
  736.      else if ((key & 0xFF00) == 0x3F00) /* 'F5' */
  737.      {
  738.         Preferences( -1, -1);
  739.         RedrawMap = TRUE;
  740.      }
  741.      /* user wants to get the menu of misc. ops */
  742.      else if ((key & 0xFF00) == 0x4200) /* 'F8' */
  743.      {
  744.         if (Selected)
  745.            MiscOperations( -1, -1, EditMode, &Selected);
  746.         else
  747.         {
  748.            if (CurObject >= 0)
  749.           SelectObject( &Selected, CurObject);
  750.            MiscOperations( -1, -1, EditMode, &Selected);
  751.            if (CurObject >= 0)
  752.           UnSelectObject( &Selected, CurObject);
  753.         }
  754.         CurObject = -1;
  755.         RedrawMap = TRUE;
  756.         DragObject = FALSE;
  757.         StretchSelBox = FALSE;
  758.      }
  759.  
  760.      /* user wants to insert a standard shape */
  761.      else if ((key & 0xFF00) == 0x4300) /* 'F9' */
  762.      {
  763.         int savednum, i;
  764.  
  765.         savednum = NumLineDefs;
  766.         InsertStandardObject( -1, -1, MAPX( PointerX), MAPY( PointerY));
  767.         if (NumLineDefs > savednum)
  768.         {
  769.            ForgetSelection( &Selected);
  770.            EditMode = OBJ_LINEDEFS;
  771.            for (i = savednum; i < NumLineDefs; i++)
  772.           SelectObject( &Selected, i);
  773.            CurObject = NumLineDefs - 1;
  774.            OldObject = -1;
  775.            DragObject = FALSE;
  776.            StretchSelBox = FALSE;
  777.         }
  778.         RedrawMap = TRUE;
  779.      }
  780.  
  781.      /* user wants to check his level */
  782.      else if ((key & 0xFF00) == 0x4400) /* 'F10' */
  783.      {
  784.         CheckLevel( -1, -1);
  785.         RedrawMap = TRUE;
  786.      }
  787.  
  788.      /* user wants to display/hide the info box */
  789.      else if (keychar == 'I')
  790.      {
  791.         InfoShown = !InfoShown;
  792.         RedrawMap = TRUE;
  793.      }
  794.  
  795.      /* user wants to change the scale */
  796.      else if ((keychar == '+' || keychar == '=') && Scale < 4.0)
  797.      {
  798.         OrigX += (int) ((PointerX - ScrCenterX) / Scale);
  799.         OrigY += (int) ((ScrCenterY - PointerY) / Scale);
  800.         if (Scale < 1.0)
  801.            Scale = 1.0 / ((1.0 / Scale) - 1.0);
  802.         else
  803.            Scale = Scale * 2.0;
  804.         OrigX -= (int) ((PointerX - ScrCenterX) / Scale);
  805.         OrigY -= (int) ((ScrCenterY - PointerY) / Scale);
  806.         RedrawMap = TRUE;
  807.      }
  808.      else if ((keychar == '-' || keychar == '_') && Scale > 0.05)
  809.      {
  810.         OrigX += (int) ((PointerX - ScrCenterX) / Scale);
  811.         OrigY += (int) ((ScrCenterY - PointerY) / Scale);
  812.         if (Scale < 1.0)
  813.            Scale = 1.0 / ((1.0 / Scale) + 1.0);
  814.         else
  815.            Scale = Scale / 2.0;
  816.         OrigX -= (int) ((PointerX - ScrCenterX) / Scale);
  817.         OrigY -= (int) ((ScrCenterY - PointerY) / Scale);
  818.         RedrawMap = TRUE;
  819.      }
  820.  
  821.      /* user wants to set the scale directly */
  822.      else if (keychar >= '0' && keychar <= '9')
  823.      {
  824.         OrigX += (int) ((PointerX - ScrCenterX) / Scale);
  825.         OrigY += (int) ((ScrCenterY - PointerY) / Scale);
  826.         if (keychar == '0')
  827.            Scale = 0.1;
  828.         else
  829.            Scale = 1.0 / (keychar - '0');
  830.         OrigX -= (int) ((PointerX - ScrCenterX) / Scale);
  831.         OrigY -= (int) ((ScrCenterY - PointerY) / Scale);
  832.         RedrawMap = TRUE;
  833.      }
  834.  
  835.      /* user wants to move */
  836.      else if ((key & 0xFF00) == 0x4800 && (PointerY - MoveSpeed) >= 0)
  837.      {
  838.         if (UseMouse)
  839.            SetMouseCoords( PointerX, PointerY - MoveSpeed);
  840.         else
  841.            PointerY -= MoveSpeed;
  842.      }
  843.      else if ((key & 0xFF00) == 0x5000 && (PointerY + MoveSpeed) <= ScrMaxY)
  844.      {
  845.         if (UseMouse)
  846.            SetMouseCoords( PointerX, PointerY + MoveSpeed);
  847.         else
  848.            PointerY += MoveSpeed;
  849.      }
  850.      else if ((key & 0xFF00) == 0x4B00 && (PointerX - MoveSpeed) >= 0)
  851.      {
  852.         if (UseMouse)
  853.            SetMouseCoords( PointerX - MoveSpeed, PointerY);
  854.         else
  855.            PointerX -= MoveSpeed;
  856.      }
  857.      else if ((key & 0xFF00) == 0x4D00 && (PointerX + MoveSpeed) <= ScrMaxX)
  858.      {
  859.         if (UseMouse)
  860.            SetMouseCoords( PointerX + MoveSpeed, PointerY);
  861.         else
  862.            PointerX += MoveSpeed;
  863.      }
  864.  
  865.      /* user wants to scroll the map (scroll one half page at a time) */
  866.      else if ((key & 0xFF00) == 0x4900 && MAPY( ScrCenterY) < MapMaxY)
  867.      {
  868.         OrigY += (int) (ScrCenterY / Scale);
  869.         RedrawMap = TRUE;
  870.      }
  871.      else if ((key & 0xFF00) == 0x5100 && MAPY( ScrCenterY) > MapMinY)
  872.      {
  873.         OrigY -= (int) (ScrCenterY / Scale);
  874.         RedrawMap = TRUE;
  875.      }
  876.      else if ((key & 0xFF00) == 0x4700 && MAPX( ScrCenterX) > MapMinX)
  877.      {
  878.         OrigX -= (int) (ScrCenterX / Scale);
  879.         RedrawMap = TRUE;
  880.      }
  881.      else if ((key & 0xFF00) == 0x4F00 && MAPX( ScrCenterX) < MapMaxX)
  882.      {
  883.         OrigX += (int) (ScrCenterX / Scale);
  884.         RedrawMap = TRUE;
  885.      }
  886.  
  887.      /* user wants to change the movement speed */
  888.      else if (keychar == ' ')
  889.         MoveSpeed = MoveSpeed == 1 ? 20 : 1;
  890.  
  891.      /* user wants to change the edit mode */
  892.      else if ((key & 0x00FF) == 0x0009 || (key & 0xFF00) == 0x0F00 || keychar == 'T' || keychar == 'V' || keychar == 'L' || keychar == 'S')
  893.      {
  894.         int    PrevMode = EditMode;
  895.         SelPtr NewSel;
  896.  
  897.         if ((key & 0x00FF) == 0x0009) /* 'Tab' */
  898.         {
  899.            switch (EditMode)
  900.            {
  901.            case OBJ_THINGS:
  902.           EditMode = OBJ_VERTEXES;
  903.           break;
  904.            case OBJ_VERTEXES:
  905.           EditMode = OBJ_LINEDEFS;
  906.           break;
  907.            case OBJ_LINEDEFS:
  908.           EditMode = OBJ_SECTORS;
  909.           break;
  910.            case OBJ_SECTORS:
  911.           EditMode = OBJ_THINGS;
  912.           break;
  913.            }
  914.         }
  915.         else if ((key & 0xFF00) == 0x0F00) /* 'Shift-Tab' */
  916.         {
  917.            switch (EditMode)
  918.            {
  919.            case OBJ_THINGS:
  920.           EditMode = OBJ_SECTORS;
  921.           break;
  922.            case OBJ_VERTEXES:
  923.           EditMode = OBJ_THINGS;
  924.           break;
  925.            case OBJ_LINEDEFS:
  926.           EditMode = OBJ_VERTEXES;
  927.           break;
  928.            case OBJ_SECTORS:
  929.           EditMode = OBJ_LINEDEFS;
  930.           break;
  931.            }
  932.         }
  933.         else
  934.         {
  935.            if (keychar == 'T')
  936.           EditMode = OBJ_THINGS;
  937.            else if (keychar == 'V')
  938.           EditMode = OBJ_VERTEXES;
  939.            else if (keychar == 'L')
  940.           EditMode = OBJ_LINEDEFS;
  941.            else if (keychar == 'S')
  942.           EditMode = OBJ_SECTORS;
  943.            /* unselect all */
  944.            ForgetSelection( &Selected);
  945.         }
  946.  
  947.         /* special cases for the selection list... */
  948.         if (Selected)
  949.         {
  950.            /* select all LineDefs bound to the selected Sectors */
  951.            if (PrevMode == OBJ_SECTORS && EditMode == OBJ_LINEDEFS)
  952.            {
  953.           int l, sd;
  954.  
  955.           ObjectsNeeded( OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
  956.           NewSel = NULL;
  957.           for (l = 0; l < NumLineDefs; l++)
  958.           {
  959.              sd = LineDefs[ l].sidedef1;
  960.              if (sd >= 0 && IsSelected( Selected, SideDefs[ sd].sector))
  961.             SelectObject( &NewSel, l);
  962.              else
  963.              {
  964.             sd = LineDefs[ l].sidedef2;
  965.             if (sd >= 0 && IsSelected( Selected, SideDefs[ sd].sector))
  966.                SelectObject( &NewSel, l);
  967.              }
  968.           }
  969.           ForgetSelection( &Selected);
  970.           Selected = NewSel;
  971.            }
  972.            /* select all Vertices bound to the selected LineDefs */
  973.            else if (PrevMode == OBJ_LINEDEFS && EditMode == OBJ_VERTEXES)
  974.            {
  975.           ObjectsNeeded( OBJ_LINEDEFS, 0);
  976.           NewSel = NULL;
  977.           while (Selected)
  978.           {
  979.              if (!IsSelected( NewSel, LineDefs[ Selected->objnum].start))
  980.             SelectObject( &NewSel, LineDefs[ Selected->objnum].start);
  981.              if (!IsSelected( NewSel, LineDefs[ Selected->objnum].end))
  982.             SelectObject( &NewSel, LineDefs[ Selected->objnum].end);
  983.              UnSelectObject( &Selected, Selected->objnum);
  984.           }
  985.           Selected = NewSel;
  986.            }
  987.            /* select all Sectors that have their LineDefs selected */
  988.            else if (PrevMode == OBJ_LINEDEFS && EditMode == OBJ_SECTORS)
  989.            {
  990.           int l, sd;
  991.  
  992.           ObjectsNeeded( OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
  993.           NewSel = NULL;
  994.           /* select all Sectors... */
  995.           for (l = 0; l < NumSectors; l++)
  996.              SelectObject( &NewSel, l);
  997.           /* ... then unselect those that should not be in the list */
  998.           for (l = 0; l < NumLineDefs; l++)
  999.              if (!IsSelected( Selected, l))
  1000.              {
  1001.             sd = LineDefs[ l].sidedef1;
  1002.             if (sd >= 0)
  1003.                UnSelectObject( &NewSel, SideDefs[ sd].sector);
  1004.             sd = LineDefs[ l].sidedef2;
  1005.             if (sd >= 0)
  1006.                UnSelectObject( &NewSel, SideDefs[ sd].sector);
  1007.              }
  1008.           ForgetSelection( &Selected);
  1009.           Selected = NewSel;
  1010.            }
  1011.            /* select all LineDefs that have both ends selected */
  1012.            else if (PrevMode == OBJ_VERTEXES && EditMode == OBJ_LINEDEFS)
  1013.            {
  1014.           int l;
  1015.  
  1016.           ObjectsNeeded( OBJ_LINEDEFS, 0);
  1017.           NewSel = NULL;
  1018.           for (l = 0; l < NumLineDefs; l++)
  1019.              if (IsSelected( Selected, LineDefs[ l].start) && IsSelected( Selected, LineDefs[ l].end))
  1020.             SelectObject( &NewSel, l);
  1021.           ForgetSelection( &Selected);
  1022.           Selected = NewSel;
  1023.            }
  1024.            /* unselect all */
  1025.            else
  1026.           ForgetSelection( &Selected);
  1027.         }
  1028.         if (GetMaxObjectNum( EditMode) >= 0 && Select0 == TRUE)
  1029.            CurObject = 0;
  1030.         else
  1031.            CurObject = -1;
  1032.         OldObject = -1;
  1033.         DragObject = FALSE;
  1034.         StretchSelBox = FALSE;
  1035.         RedrawMap = TRUE;
  1036.      }
  1037.  
  1038.      /* user wants to change the grid scale */
  1039.      else if (keychar == 'G')
  1040.      {
  1041.         if ((altkey & 0x03) == 0x00)  /* no shift keys */
  1042.         {
  1043.            if (GridScale == 0)
  1044.           GridScale = 256;
  1045.            else if (GridScale > 8)
  1046.           GridScale /= 2;
  1047.            else
  1048.           GridScale = 0;
  1049.         }
  1050.         else
  1051.         {
  1052.            if (GridScale == 0)
  1053.           GridScale = 8;
  1054.            else if (GridScale < 256)
  1055.           GridScale *= 2;
  1056.            else
  1057.           GridScale = 0;
  1058.         }
  1059.         RedrawMap = TRUE;
  1060.      }
  1061.  
  1062.      /* user wants to display or hide the grid */
  1063.      else if (keychar == 'H')
  1064.      {
  1065.         if ((altkey & 0x03) != 0x00)  /* shift key pressed */
  1066.            GridScale = 0;
  1067.         else
  1068.            GridShown = !GridShown;
  1069.         RedrawMap = TRUE;
  1070.      }
  1071.  
  1072.      /* user wants to toggle the rulers */
  1073.      else if (keychar == 'R')
  1074.         ShowRulers = !ShowRulers;
  1075.  
  1076.      /* user wants to toggle drag mode */
  1077.      else if (keychar == 'D')
  1078.      {
  1079.         StretchSelBox = FALSE;
  1080.         if (DragObject)
  1081.         {
  1082.            DragObject = FALSE;
  1083.            if (EditMode == OBJ_VERTEXES)
  1084.            {
  1085.           if (Selected == NULL && CurObject >= 0)
  1086.           {
  1087.              SelectObject( &Selected, CurObject);
  1088.              if (AutoMergeVertices( &Selected))
  1089.             RedrawMap = TRUE;
  1090.              ForgetSelection( &Selected);
  1091.           }
  1092.           else
  1093.              if (AutoMergeVertices( &Selected))
  1094.             RedrawMap = TRUE;
  1095.            }
  1096.            else if (EditMode == OBJ_LINEDEFS)
  1097.            {
  1098.           SelPtr NewSel, cur;
  1099.  
  1100.           ObjectsNeeded( OBJ_LINEDEFS, 0);
  1101.           NewSel = NULL;
  1102.           if (Selected == NULL && CurObject >= 0)
  1103.           {
  1104.              SelectObject( &NewSel, LineDefs[ CurObject].start);
  1105.              SelectObject( &NewSel, LineDefs[ CurObject].end);
  1106.           }
  1107.           else
  1108.           {
  1109.              for (cur = Selected; cur; cur = cur->next)
  1110.              {
  1111.             if (!IsSelected( NewSel, LineDefs[ cur->objnum].start))
  1112.                SelectObject( &NewSel, LineDefs[ cur->objnum].start);
  1113.             if (!IsSelected( NewSel, LineDefs[ cur->objnum].end))
  1114.                SelectObject( &NewSel, LineDefs[ cur->objnum].end);
  1115.              }
  1116.           }
  1117.           if (AutoMergeVertices( &NewSel))
  1118.              RedrawMap = TRUE;
  1119.           ForgetSelection( &NewSel);
  1120.            }
  1121.         }
  1122.         else
  1123.         {
  1124.            DragObject = TRUE;
  1125.            if (EditMode == OBJ_THINGS && CurObject >= 0)
  1126.           MoveObjectsToCoords( EditMode, NULL, Things[ CurObject].xpos, Things[ CurObject].ypos, 0);
  1127.            else if (EditMode == OBJ_VERTEXES && CurObject >= 0)
  1128.           MoveObjectsToCoords( EditMode, NULL, Vertexes[ CurObject].x, Vertexes[ CurObject].y, 0);
  1129.            else
  1130.           MoveObjectsToCoords( EditMode, NULL, MAPX( PointerX), MAPY( PointerY), GridScale);
  1131.         }
  1132.      }
  1133.  
  1134.      /* user wants to select the next or previous object */
  1135.      else if (keychar == 'N' || keychar == '>')
  1136.      {
  1137.         if (CurObject < GetMaxObjectNum( EditMode))
  1138.            CurObject++;
  1139.         else if (GetMaxObjectNum( EditMode) >= 0)
  1140.            CurObject = 0;
  1141.         else
  1142.            CurObject = -1;
  1143.         RedrawMap = TRUE;
  1144.      }
  1145.      else if (keychar == 'P' || keychar == '<')
  1146.      {
  1147.         if (CurObject > 0)
  1148.            CurObject--;
  1149.         else
  1150.            CurObject = GetMaxObjectNum( EditMode);
  1151.         RedrawMap = TRUE;
  1152.      }
  1153.      else if (keychar == 'J' || keychar == '#')
  1154.      {
  1155.         OldObject = InputObjectNumber( -1, -1, EditMode, CurObject);
  1156.         if (OldObject >= 0)
  1157.         {
  1158.            CurObject = OldObject;
  1159.            GoToObject( EditMode, CurObject);
  1160.         }
  1161.         else
  1162.            OldObject = CurObject;
  1163.         RedrawMap = TRUE;
  1164.      }
  1165.  
  1166.      /* user wants to mark/unmark an object or a group of objects */
  1167.      else if (keychar == 'M')
  1168.      {
  1169.         if (StretchSelBox)
  1170.         {
  1171.            SelPtr oldsel;
  1172.  
  1173.            /* select all objects in the selection box */
  1174.            StretchSelBox = FALSE;
  1175.            RedrawMap = TRUE;
  1176.            /* additive selection box or not? */
  1177.            if (AdditiveSelBox == FALSE)
  1178.           ForgetSelection( &Selected);
  1179.            else
  1180.           oldsel = Selected;
  1181.            Selected = SelectObjectsInBox( EditMode, SelBoxX, SelBoxY, MAPX( PointerX), MAPY( PointerY));
  1182.            if (AdditiveSelBox == TRUE)
  1183.           while (oldsel != NULL)
  1184.           {
  1185.              if (! IsSelected( Selected, oldsel->objnum))
  1186.             SelectObject( &Selected, oldsel->objnum);
  1187.              UnSelectObject( &oldsel, oldsel->objnum);
  1188.           }
  1189.            if (Selected)
  1190.            {
  1191.           CurObject = Selected->objnum;
  1192.           PlaySound( 440, 10);
  1193.            }
  1194.            else
  1195.           CurObject = -1;
  1196.         }
  1197.         else if ((altkey & 0x03) == 0x00)  /* no shift keys */
  1198.         {
  1199.            if (CurObject >= 0)
  1200.            {
  1201.           /* mark or unmark one object */
  1202.           if (IsSelected( Selected, CurObject))
  1203.              UnSelectObject( &Selected, CurObject);
  1204.           else
  1205.              SelectObject( &Selected, CurObject);
  1206.           if (UseMouse)
  1207.              HideMousePointer();
  1208.           HighlightObject( EditMode, CurObject, GREEN);
  1209.           if (UseMouse)
  1210.              ShowMousePointer();
  1211.           if (Selected)
  1212.              PlaySound( 440, 10);
  1213.           DragObject = FALSE;
  1214.            }
  1215.            else
  1216.           Beep();
  1217.         }
  1218.         else
  1219.         {
  1220.            /* begin "stretch selection box" mode */
  1221.            SelBoxX = MAPX( PointerX);
  1222.            SelBoxY = MAPY( PointerY);
  1223.            StretchSelBox = TRUE;
  1224.            DragObject = FALSE;
  1225.         }
  1226.      }
  1227.  
  1228.      /* user wants to clear all marks and redraw the map */
  1229.      else if (keychar == 'C')
  1230.      {
  1231.         ForgetSelection( &Selected);
  1232.         RedrawMap = TRUE;
  1233.         DragObject = FALSE;
  1234.         StretchSelBox = FALSE;
  1235.      }
  1236.  
  1237.      /* user wants to copy a group of objects */
  1238.      else if (keychar == 'O' && CurObject >= 0)
  1239.      {
  1240.         /* copy the object(s) */
  1241.         if (Selected == NULL)
  1242.            SelectObject( &Selected, CurObject);
  1243.         CopyObjects( EditMode, Selected);
  1244.         /* enter drag mode */
  1245.         DragObject = TRUE;
  1246.         CurObject = Selected->objnum;
  1247.         if (EditMode == OBJ_THINGS)
  1248.            MoveObjectsToCoords( EditMode, NULL, Things[ CurObject].xpos, Things[ CurObject].ypos, 0);
  1249.         else if (EditMode == OBJ_VERTEXES)
  1250.            MoveObjectsToCoords( EditMode, NULL, Vertexes[ CurObject].x, Vertexes[ CurObject].y, 0);
  1251.         else
  1252.            MoveObjectsToCoords( EditMode, NULL, MAPX( PointerX), MAPY( PointerY), GridScale);
  1253.         RedrawMap = TRUE;
  1254.         StretchSelBox = FALSE;
  1255.      }
  1256.  
  1257.      /* user wants to edit the current object */
  1258.      else if ((key & 0x00FF) == 0x000D && CurObject >= 0) /* 'Enter' */
  1259.      {
  1260.         if (Selected)
  1261.            EditObjectsInfo( 0, 30, EditMode, Selected);
  1262.         else
  1263.         {
  1264.            SelectObject( &Selected, CurObject);
  1265.            EditObjectsInfo( 0, 30, EditMode, Selected);
  1266.            UnSelectObject( &Selected, CurObject);
  1267.         }
  1268.         RedrawMap = TRUE;
  1269.         DragObject = FALSE;
  1270.         StretchSelBox = FALSE;
  1271.      }
  1272.  
  1273.      /* user wants to delete the current object */
  1274.      else if ((key & 0xFF00) == 0x5300 && CurObject >= 0) /* 'Del' */
  1275.      {
  1276.         if (EditMode == OBJ_THINGS || Expert || Confirm( -1, -1,
  1277.                 (Selected ? "Do you really want to delete these objects?" : "Do you really want to delete this object?"),
  1278.                 (Selected ? "This will also delete the objects bound to them." : "This will also delete the objects bound to it.")))
  1279.         {
  1280.            if (Selected)
  1281.           DeleteObjects( EditMode, &Selected);
  1282.            else
  1283.           DeleteObject( EditMode, CurObject);
  1284.            CurObject = -1;
  1285.         }
  1286.         DragObject = FALSE;
  1287.         StretchSelBox = FALSE;
  1288.         RedrawMap = TRUE;
  1289.      }
  1290.  
  1291.      /* user wants to insert a new object */
  1292.      else if ((key & 0xFF00) == 0x5200) /* 'Ins' */
  1293.      {
  1294.         SelPtr cur;
  1295.  
  1296.         /* first special case: if several Vertices are selected, add new LineDefs */
  1297.         if (EditMode == OBJ_VERTEXES && Selected != NULL && Selected->next != NULL)
  1298.         {
  1299.            int firstv;
  1300.  
  1301.            ObjectsNeeded( OBJ_LINEDEFS, 0);
  1302.            if (Selected->next->next != NULL)
  1303.           firstv = Selected->objnum;
  1304.            else
  1305.           firstv = -1;
  1306.            EditMode = OBJ_LINEDEFS;
  1307.            /* create LineDefs between the Vertices */
  1308.            for (cur = Selected; cur->next; cur = cur->next)
  1309.            {
  1310.           /* check if there is already a LineDef between the two Vertices */
  1311.           for (CurObject = 0; CurObject < NumLineDefs; CurObject++)
  1312.              if ((LineDefs[ CurObject].start == cur->next->objnum && LineDefs[ CurObject].end == cur->objnum)
  1313.               || (LineDefs[ CurObject].end == cur->next->objnum && LineDefs[ CurObject].start == cur->objnum))
  1314.             break;
  1315.           if (CurObject < NumLineDefs)
  1316.              cur->objnum = CurObject;
  1317.           else
  1318.           {
  1319.              InsertObject( OBJ_LINEDEFS, -1, 0, 0);
  1320.              CurObject = NumLineDefs - 1;
  1321.              LineDefs[ CurObject].start = cur->next->objnum;
  1322.              LineDefs[ CurObject].end = cur->objnum;
  1323.              cur->objnum = CurObject;
  1324.           }
  1325.            }
  1326.            /* close the polygon if there are more than 2 Vertices */
  1327.            if (firstv >= 0 && (altkey & 0x03) != 0x00)  /* shift key pressed */
  1328.            {
  1329.           for (CurObject = 0; CurObject < NumLineDefs; CurObject++)
  1330.              if ((LineDefs[ CurObject].start == firstv && LineDefs[ CurObject].end == cur->objnum)
  1331.               || (LineDefs[ CurObject].end == firstv && LineDefs[ CurObject].start == cur->objnum))
  1332.             break;
  1333.           if (CurObject < NumLineDefs)
  1334.              cur->objnum = CurObject;
  1335.           else
  1336.           {
  1337.              InsertObject( OBJ_LINEDEFS, -1, 0, 0);
  1338.              CurObject = NumLineDefs - 1;
  1339.              LineDefs[ CurObject].start = firstv;
  1340.              LineDefs[ CurObject].end = cur->objnum;
  1341.              cur->objnum = CurObject;
  1342.           }
  1343.            }
  1344.            else
  1345.           UnSelectObject( &Selected, cur->objnum);
  1346.         }
  1347.         /* second special case: if several LineDefs are selected, add new SideDefs and one Sector */
  1348.         else if (EditMode == OBJ_LINEDEFS && Selected != NULL)
  1349.         {
  1350.            ObjectsNeeded( OBJ_LINEDEFS, 0);
  1351.            for (cur = Selected; cur; cur = cur->next)
  1352.           if (LineDefs[ cur->objnum].sidedef1 >= 0 && LineDefs[ cur->objnum].sidedef2 >= 0)
  1353.           {
  1354.              char msg[ 80];
  1355.  
  1356.              Beep();
  1357.              sprintf( msg, "LineDef #%d already has two SideDefs", cur->objnum);
  1358.              Notify( -1, -1, "Error: cannot add the new Sector", msg);
  1359.              break;
  1360.           }
  1361.            if (cur == NULL)
  1362.            {
  1363.           EditMode = OBJ_SECTORS;
  1364.           InsertObject( OBJ_SECTORS, -1, 0, 0);
  1365.           CurObject = NumSectors - 1;
  1366.           for (cur = Selected; cur; cur = cur->next)
  1367.           {
  1368.              InsertObject( OBJ_SIDEDEFS, -1, 0, 0);
  1369.              SideDefs[ NumSideDefs - 1].sector = CurObject;
  1370.              ObjectsNeeded( OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
  1371.              if (LineDefs[ cur->objnum].sidedef1 >= 0)
  1372.              {
  1373.             int s;
  1374.  
  1375.             s = SideDefs[ LineDefs[ cur->objnum].sidedef1].sector;
  1376.             if (s >= 0)
  1377.             {
  1378.                Sectors[ CurObject].floorh = Sectors[ s].floorh;
  1379.                Sectors[ CurObject].ceilh = Sectors[ s].ceilh;
  1380.                strncpy( Sectors[ CurObject].floort, Sectors[ s].floort, 8);
  1381.                strncpy( Sectors[ CurObject].ceilt, Sectors[ s].ceilt, 8);
  1382.                Sectors[ CurObject].light = Sectors[ s].light;
  1383.             }
  1384.             LineDefs[ cur->objnum].sidedef2 = NumSideDefs - 1;
  1385.             LineDefs[ cur->objnum].flags = 4;
  1386.             strncpy( SideDefs[ NumSideDefs - 1].tex3, "-", 8);
  1387.             strncpy( SideDefs[ LineDefs[ cur->objnum].sidedef1].tex3, "-", 8);
  1388.              }
  1389.              else
  1390.             LineDefs[ cur->objnum].sidedef1 = NumSideDefs - 1;
  1391.           }
  1392.           ForgetSelection( &Selected);
  1393.           SelectObject( &Selected, CurObject);
  1394.            }
  1395.         }
  1396.         /* normal case: add a new object of the current type */
  1397.         else
  1398.         {
  1399.            ForgetSelection( &Selected);
  1400.            if (GridScale > 0)
  1401.           InsertObject( EditMode, CurObject, (MAPX( PointerX) + GridScale / 2) & ~(GridScale - 1), (MAPY( PointerY) + GridScale / 2) & ~(GridScale - 1));
  1402.            else
  1403.           InsertObject( EditMode, CurObject, MAPX( PointerX), MAPY( PointerY));
  1404.            CurObject = GetMaxObjectNum( EditMode);
  1405.            if (EditMode == OBJ_LINEDEFS)
  1406.            {
  1407.           if (! Input2VertexNumbers( -1, -1, "Choose the two vertices for the new LineDef",
  1408.                          &(LineDefs[ CurObject].start), &(LineDefs[ CurObject].end)))
  1409.           {
  1410.              DeleteObject( EditMode, CurObject);
  1411.              CurObject = -1;
  1412.           }
  1413.            }
  1414.            else if (EditMode == OBJ_VERTEXES)
  1415.            {
  1416.           SelectObject( &Selected, CurObject);
  1417.           if (AutoMergeVertices( &Selected))
  1418.              RedrawMap = TRUE;
  1419.           ForgetSelection( &Selected);
  1420.            }
  1421.         }
  1422.         DragObject = FALSE;
  1423.         StretchSelBox = FALSE;
  1424.         RedrawMap = TRUE;
  1425.      }
  1426.  
  1427.      /* user likes music */
  1428.      else if (key)
  1429.         Beep();
  1430.  
  1431.      /* redraw the (keyboard) pointer */
  1432.      if (FakeCursor || ShowRulers)
  1433.      {
  1434.         HideMousePointer();
  1435.         DrawPointer( ShowRulers);
  1436.         ShowMousePointer();
  1437.      }
  1438.       }
  1439.  
  1440.       /* check if Scroll Lock is off */
  1441.       if ((bioskey( 2) & 0x10) == 0x00)
  1442.       {
  1443.      /* move the map if the pointer is near the edge of the screen */
  1444.      if (PointerY <= (UseMouse ? 2 : 20))
  1445.      {
  1446.         if (! UseMouse)
  1447.            PointerY += MoveSpeed;
  1448.         if (MAPY( ScrCenterY) < MapMaxY)
  1449.         {
  1450.            OrigY += (int) (MoveSpeed * 2.0 / Scale);
  1451.            RedrawMap = TRUE;
  1452.         }
  1453.      }
  1454.      if (PointerY >= ScrMaxY - (UseMouse ? 8 : 20))
  1455.      {
  1456.         if (! UseMouse)
  1457.            PointerY -= MoveSpeed;
  1458.         if (MAPY( ScrCenterY) > MapMinY)
  1459.         {
  1460.            OrigY -= (int) (MoveSpeed * 2.0 / Scale);
  1461.            RedrawMap = TRUE;
  1462.         }
  1463.      }
  1464.      if (PointerX <= (UseMouse ? 8 : 20))
  1465.      {
  1466.         if (! UseMouse)
  1467.            PointerX += MoveSpeed;
  1468.         if (MAPX( ScrCenterX) > MapMinX)
  1469.         {
  1470.            OrigX -= (int) (MoveSpeed * 2.0 / Scale);
  1471.            RedrawMap = TRUE;
  1472.         }
  1473.      }
  1474.      if (PointerX >= ScrMaxX - (UseMouse ? 8 : 20))
  1475.      {
  1476.         if (! UseMouse)
  1477.            PointerX -= MoveSpeed;
  1478.         if (MAPX( ScrCenterX) < MapMaxX)
  1479.         {
  1480.            OrigX += (int) (MoveSpeed * 2.0 / Scale);
  1481.            RedrawMap = TRUE;
  1482.         }
  1483.      }
  1484.       }
  1485.    }
  1486. }
  1487.  
  1488.  
  1489.  
  1490. /*
  1491.    draw the actual game map
  1492. */
  1493.  
  1494. void DrawMap( int editmode, int grid, Bool drawgrid) /* SWAP! */
  1495. {
  1496.    int  n, m;
  1497.  
  1498.    /* clear the screen */
  1499.    ClearScreen();
  1500.  
  1501.    /* draw the grid */
  1502.    if (drawgrid == TRUE && grid > 0)
  1503.    {
  1504.       int mapx0 = MAPX( 0) & ~(grid - 1);
  1505.       int mapx1 = (MAPX( ScrMaxX) + grid) & ~(grid - 1);
  1506.       int mapy0 = (MAPY( ScrMaxY) - grid) & ~(grid - 1);
  1507.       int mapy1 = MAPY( 0) & ~(grid - 1);
  1508.  
  1509.       SetColor( BLUE);
  1510.       for (n = mapx0; n <= mapx1; n += grid)
  1511.      DrawMapLine( n, mapy0, n, mapy1);
  1512.       for (n = mapy0; n <= mapy1; n += grid)
  1513.      DrawMapLine( mapx0, n, mapx1, n);
  1514.    }
  1515.  
  1516.    /* draw the linedefs to form the map */
  1517.    switch (editmode)
  1518.    {
  1519.    case OBJ_THINGS:
  1520.       ObjectsNeeded( OBJ_LINEDEFS, OBJ_VERTEXES, 0);
  1521.       for (n = 0; n < NumLineDefs; n++)
  1522.       {
  1523.      if (LineDefs[ n].flags & 1)
  1524.         SetColor( WHITE);
  1525.      else
  1526.         SetColor( LIGHTGRAY);
  1527.      DrawMapLine( Vertexes[ LineDefs[ n].start].x, Vertexes[ LineDefs[ n].start].y,
  1528.               Vertexes[ LineDefs[ n].end].x, Vertexes[ LineDefs[ n].end].y);
  1529.       }
  1530.       break;
  1531.    case OBJ_VERTEXES:
  1532.       ObjectsNeeded( OBJ_LINEDEFS, OBJ_VERTEXES, 0);
  1533.       SetColor( LIGHTGRAY);
  1534.       for (n = 0; n < NumLineDefs; n++)
  1535.      DrawMapVector( Vertexes[ LineDefs[ n].start].x, Vertexes[ LineDefs[ n].start].y,
  1536.             Vertexes[ LineDefs[ n].end].x, Vertexes[ LineDefs[ n].end].y);
  1537.       break;
  1538.    case OBJ_LINEDEFS:
  1539.       ObjectsNeeded( OBJ_LINEDEFS, OBJ_VERTEXES, 0);
  1540.       for (n = 0; n < NumLineDefs; n++)
  1541.       {
  1542.      if (LineDefs[ n].type > 0)
  1543.      {
  1544.         if (LineDefs[ n].tag > 0)
  1545.            SetColor( LIGHTMAGENTA);
  1546.         else
  1547.            SetColor( LIGHTGREEN);
  1548.      }
  1549.      else if (LineDefs[ n].tag > 0)
  1550.         SetColor( LIGHTRED);
  1551.      else if (LineDefs[ n].flags & 1)
  1552.         SetColor( WHITE);
  1553.      else
  1554.         SetColor( LIGHTGRAY);
  1555.      DrawMapLine( Vertexes[ LineDefs[ n].start].x, Vertexes[ LineDefs[ n].start].y,
  1556.               Vertexes[ LineDefs[ n].end].x, Vertexes[ LineDefs[ n].end].y);
  1557.       }
  1558.       break;
  1559.    case OBJ_SECTORS:
  1560.       ObjectsNeeded( OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
  1561.       for (n = 0; n < NumLineDefs; n++)
  1562.       {
  1563.      if ((m = LineDefs[ n].sidedef1) < 0 || (m = SideDefs[ m].sector) < 0)
  1564.         SetColor( LIGHTRED);
  1565.      else
  1566.      {
  1567.         if (Sectors[ m].tag > 0)
  1568.            SetColor( LIGHTGREEN);
  1569.         else if (Sectors[ m].special > 0)
  1570.            SetColor( LIGHTCYAN);
  1571.         else if (LineDefs[ n].flags & 1)
  1572.            SetColor( WHITE);
  1573.         else
  1574.            SetColor( LIGHTGRAY);
  1575.         if ((m = LineDefs[ n].sidedef2) >= 0)
  1576.         {
  1577.            if ((m = SideDefs[ m].sector) < 0)
  1578.           SetColor( LIGHTRED);
  1579.            else if (Sectors[ m].tag > 0)
  1580.           SetColor( LIGHTGREEN);
  1581.            else if (Sectors[ m].special > 0)
  1582.           SetColor( LIGHTCYAN);
  1583.         }
  1584.      }
  1585.      ObjectsNeeded( OBJ_LINEDEFS, OBJ_VERTEXES, 0);
  1586.      DrawMapLine( Vertexes[ LineDefs[ n].start].x, Vertexes[ LineDefs[ n].start].y,
  1587.               Vertexes[ LineDefs[ n].end].x, Vertexes[ LineDefs[ n].end].y);
  1588.       }
  1589.       break;
  1590.    }
  1591.  
  1592.    /* draw in the vertices */
  1593.    if (editmode == OBJ_VERTEXES)
  1594.    {
  1595.       SetColor( LIGHTGREEN);
  1596.       for (n = 0; n < NumVertexes; n++)
  1597.       {
  1598.      DrawMapLine( Vertexes[ n].x - OBJSIZE, Vertexes[ n].y - OBJSIZE, Vertexes[ n].x + OBJSIZE, Vertexes[ n].y + OBJSIZE);
  1599.      DrawMapLine( Vertexes[ n].x + OBJSIZE, Vertexes[ n].y - OBJSIZE, Vertexes[ n].x - OBJSIZE, Vertexes[ n].y + OBJSIZE);
  1600.       }
  1601.    }
  1602.  
  1603.    /* draw in the things */
  1604.    ObjectsNeeded( OBJ_THINGS, 0);
  1605.    if (editmode == OBJ_THINGS)
  1606.    {
  1607.       for (n = 0; n < NumThings; n++)
  1608.       {
  1609.      m = GetThingRadius( Things[ n].type);
  1610.      SetColor( GetThingColour( Things[ n].type));
  1611.      DrawMapLine( Things[ n].xpos - m, Things[ n].ypos, Things[ n].xpos + m, Things[ n].ypos);
  1612.      DrawMapLine( Things[ n].xpos, Things[ n].ypos - m, Things[ n].xpos, Things[ n].ypos + m);
  1613.      DrawMapCircle( Things[ n].xpos, Things[ n].ypos, m);
  1614.       }
  1615.    }
  1616.    else
  1617.    {
  1618.       SetColor( LIGHTGRAY);
  1619.       for (n = 0; n < NumThings; n++)
  1620.       {
  1621.      DrawMapLine( Things[ n].xpos - OBJSIZE, Things[ n].ypos, Things[ n].xpos + OBJSIZE, Things[ n].ypos);
  1622.      DrawMapLine( Things[ n].xpos, Things[ n].ypos - OBJSIZE, Things[ n].xpos, Things[ n].ypos + OBJSIZE);
  1623.       }
  1624.    }
  1625.  
  1626.    /* draw in the title bar */
  1627.    DrawScreenBox3D( 0, 0, ScrMaxX, 16);
  1628.    SetColor( WHITE);
  1629.    DrawScreenText( 20,  4, "File  Edit  Search  Modes  Misc  Objects  Check");
  1630.    DrawScreenText( 20,  6, "_     _     _       _       _    _        _    ");
  1631.    DrawScreenText( ScrMaxX - 45, 4, "Help");
  1632.    DrawScreenText( ScrMaxX - 45, 6, "_   ");
  1633.  
  1634.    /* draw the bottom line, if needed */
  1635.    if (InfoShown)
  1636.    {
  1637.       DrawScreenBox3D( 0, ScrMaxY - 11, ScrMaxX, ScrMaxY);
  1638.       if (MadeMapChanges == TRUE)
  1639.      DrawScreenText( 5, ScrMaxY - 8, "Editing %s on %s #", GetEditModeName( editmode), Level->dir.name);
  1640.       else if (MadeChanges == TRUE)
  1641.      DrawScreenText( 5, ScrMaxY - 8, "Editing %s on %s *", GetEditModeName( editmode), Level->dir.name);
  1642.       else
  1643.      DrawScreenText( 5, ScrMaxY - 8, "Editing %s on %s", GetEditModeName( editmode), Level->dir.name);
  1644.       if (Scale < 1.0)
  1645.      DrawScreenText( ScrMaxX - 176, ScrMaxY - 8, "Scale: 1/%d  Grid: %d", (int) (1.0 / Scale + 0.5), grid);
  1646.       else
  1647.      DrawScreenText( ScrMaxX - 176, ScrMaxY - 8, "Scale: %d/1  Grid: %d", (int) Scale, grid);
  1648.       if (farcoreleft() < 50000L)
  1649.       {
  1650.      if (farcoreleft() < 20000L)
  1651.         SetColor( LIGHTRED);
  1652.      else
  1653.         SetColor( RED);
  1654.       }
  1655.       DrawScreenText( ScrCenterX - ((editmode == OBJ_LINEDEFS) ? 10 : 50), ScrMaxY - 8, "Free mem: %lu", farcoreleft());
  1656.    }
  1657. }
  1658.  
  1659.  
  1660.  
  1661. /*
  1662.    center the map around the given coords
  1663. */
  1664.  
  1665. void CenterMapAroundCoords( int xpos, int ypos)
  1666. {
  1667.    OrigX = xpos;
  1668.    OrigY = ypos;
  1669.    PointerX = ScrCenterX;
  1670.    PointerY = ScrCenterY;
  1671. }
  1672.  
  1673.  
  1674.  
  1675. /*
  1676.    center the map around the object and zoom in if necessary
  1677. */
  1678.  
  1679. void GoToObject( int objtype, int objnum) /* SWAP! */
  1680. {
  1681.    int   xpos, ypos;
  1682.    int   xpos2, ypos2;
  1683.    int   n;
  1684.    int   sd1, sd2;
  1685.    float oldscale;
  1686.  
  1687.    GetObjectCoords( objtype, objnum, &xpos, &ypos);
  1688.    CenterMapAroundCoords( xpos, ypos);
  1689.    oldscale = Scale;
  1690.  
  1691.    /* zoom in until the object can be selected */
  1692.    while (Scale < 4.0 && GetCurObject( objtype, MAPX( PointerX - 4), MAPY( PointerY - 4), MAPX( PointerX + 4), MAPY( PointerY + 4)) != objnum)
  1693.    {
  1694.       if (Scale < 1.0)
  1695.      Scale = 1.0 / ((1.0 / Scale) - 1.0);
  1696.       else
  1697.      Scale = Scale * 2.0;
  1698.    }
  1699.  
  1700.    /* Special case for Sectors: if several Sectors are one inside another, then    */
  1701.    /* zooming in on the center won't help.  So I choose a LineDef that borders the */
  1702.    /* Sector, move a few pixels towards the inside of the Sector, then zoom in.    */
  1703.    if (objtype == OBJ_SECTORS && GetCurObject( OBJ_SECTORS, OrigX, OrigY, OrigX, OrigY) != objnum)
  1704.    {
  1705.       /* restore the Scale */
  1706.       Scale = oldscale;
  1707.       for (n = 0; n < NumLineDefs; n++)
  1708.       {
  1709.      ObjectsNeeded( OBJ_LINEDEFS, 0);
  1710.      sd1 = LineDefs[ n].sidedef1;
  1711.      sd2 = LineDefs[ n].sidedef2;
  1712.      ObjectsNeeded( OBJ_SIDEDEFS, 0);
  1713.      if (sd1 >= 0 && SideDefs[ sd1].sector == objnum)
  1714.         break;
  1715.      if (sd2 >= 0 && SideDefs[ sd2].sector == objnum)
  1716.         break;
  1717.       }
  1718.       if (n < NumLineDefs)
  1719.       {
  1720.      GetObjectCoords( OBJ_LINEDEFS, n, &xpos2, &ypos2);
  1721.      n = ComputeDist( abs( xpos - xpos2), abs( ypos - ypos2)) / 7;
  1722.      if (n <= 1)
  1723.        n = 2;
  1724.      xpos = xpos2 + (xpos - xpos2) / n;
  1725.      ypos = ypos2 + (ypos - ypos2) / n;
  1726.      CenterMapAroundCoords( xpos, ypos);
  1727.      /* zoom in until the sector can be selected */
  1728.      while (Scale > 4.0 && GetCurObject( OBJ_SECTORS, OrigX, OrigY, OrigX, OrigY) != objnum)
  1729.      {
  1730.         if (Scale < 1.0)
  1731.            Scale = 1.0 / ((1.0 / Scale) - 1.0);
  1732.         else
  1733.            Scale = Scale / 2.0;
  1734.      }
  1735.       }
  1736.    }
  1737.    if (UseMouse)
  1738.       SetMouseCoords( PointerX, PointerY);
  1739. }
  1740.  
  1741.  
  1742.  
  1743. /* end of file */
  1744.