home *** CD-ROM | disk | FTP | other *** search
/ Toolkit for DOOM / DOOMTOOL.ISO / editors / dme301.zip / SOURCE.ZIP / REG.C < prev    next >
C/C++ Source or Header  |  1994-07-26  |  7KB  |  206 lines

  1. /*
  2.     This is a DMapEdit source code module.  Though it is copyrighted, you
  3.     may modify it and use it for your own personal use, meaning that new
  4.     modified code and anything derived from it (such as exe files) doesn't
  5.     get distributed to anyone, unless you get my permission first.  Code
  6.     from this file, or code based on ideas from this file may be used with
  7.     other programs, provided that you give credit for it in the source code,
  8.     documentation, and 'about' windows or screens, if one exists, for the
  9.     programs using it.  Giving credit means something like this:
  10.  
  11.     Code from DMapEdit was used in this program
  12.  
  13.                               or
  14.  
  15.     Some code for this program was based on ideas presented in DMapEdit
  16.  
  17.     Whatever.  Just be sure to mention "DMapEdit" in such a way that it's
  18.     self-evident how it was useful to the new program, and be sure to have
  19.     "DMapEdit is a trademark of Jason Hoffoss" in the docs.  That's all..
  20. */
  21.  
  22. /* This is the old registered version code, which has now been modified
  23.     and used now, since there is only one, non-crippled version anymore.
  24.     The reason I had two different modules for registered and shareware was
  25.     that, quite simply, it's a LOT harder to alter the resulting exe file
  26.     to make it work like the registered version.
  27. */
  28.  
  29. #include <stdio.h>
  30. #include <alloc.h>
  31. #include <string.h>
  32. #include <mem.h>
  33. #include "dme.h"
  34. #include "dme2.h"
  35.  
  36. void fix_wadname(char *name);
  37. void save_to_wad(int get_name); /* save map info to a pwad file */
  38.  
  39. extern int bypass_sw;
  40. extern int backup;
  41.  
  42. void version_info(void)
  43. {
  44.     char msg[512];
  45.  
  46. /*    sprintf(msg, "DMapEdit v%d.%d", version/10, version%10);*/
  47.     strcpy(msg, "DMapEdit v3.01"); /* kludge for this version */
  48.     if (BETA)
  49.         strcat(msg, " (Beta)");
  50.     strcat(msg, "\t"
  51.         "Written by Jason Hoffoss\t\n"
  52.         "This program was written completely in C, using\n"
  53.         "Borland C++ v3.1.  All the code was written from\n"
  54.         "scratch, using no libraries, except the ones that\n"
  55.         "came with the compiler.\n");
  56.  
  57.     window_text(msg, 1);
  58.     window_check();
  59.     draw_map();
  60.     await_release();
  61.     return;
  62. }
  63.  
  64. void save_wad_map(int get_name) /* save map info to a pwad file */
  65. {
  66.     save_to_wad(get_name);
  67.     return;
  68. }
  69.  
  70. int write_wad_entry(char *name, char huge *farptr, long len, char far *entry)
  71. {
  72.     char buffer[4096];
  73.     int i;
  74.  
  75.     if (_fstrnicmp(name, entry, 8))
  76.         dir_error();
  77.     while (len > 4096)
  78.     {
  79.         _fmemcpy(buffer, farptr, 4096);
  80.         farptr += 4096;
  81.         if (fwrite(buffer, 1, 4096, fp2) != 4096)
  82.             goto err;
  83.         len -= 4096;
  84.     }
  85.  
  86.     _fmemcpy(buffer, farptr, len);
  87.     if (fwrite(buffer, 1, len, fp2) != len)
  88.         goto err;
  89.     return 0;
  90.  
  91. err:
  92.     error("Failed on write to backup WAD file");
  93.     return -1;
  94. }
  95.  
  96. /* write from a far memory location to disk.  It appears that in the
  97.     medium memory model that only near file writting can be done.  So,
  98.     this handles a far write.
  99. */
  100.  
  101. int far_write(char huge *farptr, long len)
  102. {
  103.     char buffer[4096];
  104.     int i;
  105.  
  106.     if (!len) return 0;
  107.     while (len > 4096)
  108.     {
  109.         _fmemcpy(buffer, farptr, 4096);
  110.         farptr += 4096;
  111.         if (fwrite(buffer, 1, 4096, fp) != 4096)
  112.             return -1;
  113.         len -= 4096;
  114.     }
  115.  
  116.     _fmemcpy(buffer, farptr, len);
  117.     if (fwrite(buffer, 1, len, fp) != len)
  118.         return -1;
  119.     return 0;
  120. }
  121.  
  122. void sw_notice(void)
  123. {
  124.     char msg[4096], beta_msg[9];
  125.  
  126.     if (bypass_sw)
  127.         return;
  128.  
  129.     *beta_msg = 0;
  130. /*    if (BETA)
  131.         sprintf(msg, "Welcome to beta DMapEdit v%d.%d\t\n"
  132.             "|   Hi there!  This is a beta version of my map editor.  As such,\n"
  133.             "|I cannot say that it has no errors.  In fact, the whole purpose of\n"
  134.             "|of beta versions is to allow users to locate any and all bugs,\n"
  135.             "|which are then reported to the author (me).  So, find some bugs,\n"
  136.             "|try it out and see what you think, etc.  If you ask me, v2.1 sucks\n"
  137.             "|compared to this version.  If you haven't yet read the \"reame.1st\"\n"
  138.             "|file, be sure to do so.\n", version/10, version%10);
  139.     else
  140.         sprintf(msg, "Welcome to DMapEdit v%d.%d%s\t\n" */
  141.         strcpy(msg, "Welcome to DMapEdit v3.01\t\n"
  142.             "|   This program is shareware.  As such, you are free to try it out\n"
  143.             "|and see if you like it before you pay for it.  I no longer have any\n"
  144.             "|method of enforcing registration, so I am relying on your personal\n"
  145.             "|sense of honor.  Registration is only $5, which is cheap enough for\n"
  146.             "|anyone to affort.  Since this is the first shareware program I have\n"
  147.             "|written, it also serves as a test to see how well shareware works,\n"
  148.             "|moneywise.  The response I get will dictate how I proceed with any\n"
  149.             "|future projects I write.  Another benefit of registering is that it\n"
  150.             "|makes you eligible for beta testing future releases.  If you think\n"
  151.             "|DMapEdit is worth more than $5, feel free to send me more ($5 is\n"
  152.             "|rather a low figure, actually).  Also, if you don't have internet\n"
  153.             "|or good BBS access, you may not have the latest version.  When you\n"
  154.             "|register, I will send your the latest version, if you wish (let me\n"
  155.             "|know what version you do have).  Plus, for every $2.50 extra you\n"
  156.             "|send, I will send you a future update of DMapEdit (regular postal\n"
  157.             "|mail.  If you would like it send any more expensive way, be sure to\n"
  158.             "|include the money to cover it).  Send registration money (check/\n"
  159.             "|money order/US cash) or other mail to this address:\n\n"
  160.  
  161.             "Jason Hoffoss        \t"
  162.             "10321 110th st. N.   \t"
  163.             "Stillwater, MN  55082\t\n"
  164.  
  165.             "|   Be sure to consult the 'dmapedit.doc' file if you have any\n"
  166.             "|questions about anything.  You probably should read it even if you\n"
  167. /*            "|don't, but it's your choice.\n", version/10, version%10, beta_msg); */
  168.             "|don't, but it's your choice.\n");
  169.  
  170.     window_text1(msg, 1, 0, 4);
  171.     mouse_on();
  172.     while (!mouse_check())
  173.         if (keypress)
  174.             break;
  175.  
  176.     draw_map();
  177.     await_release();
  178.     return;
  179. }
  180.  
  181. void final_screen(void)
  182. {
  183.     printf("\t\t\tThank you for using DMapEdit..\n\n"
  184.         "Doom is a trademark of id Software Inc.\n"
  185.         "DMapEdit is my trademark\n"
  186.         "Vesa.bgi is copyright (c) 1991 Jordan Hargraphix\n"
  187.         "Copyright (c) 1994 Jason Hoffoss.  All rights reserved.\n\n"
  188.  
  189.         "You may freely distribute this program, as long as it is distributed\n"
  190.         "intact (all original files included and unmodified).  You may not sell\n"
  191.         "this program, for profit or any other purpose.\n\n"
  192.  
  193.         "Remember, this program is shareware.  If you think this is a decend program\n"
  194.         "and want to see other decend programs in the future written by me, register!\n"
  195.         "Registering is only a one-time $5 fee.  Shareware only survives with the\n"
  196.         "support of it's users!  My address, only again, is:\n\n"
  197.  
  198.         "\t  Jason Hoffoss                Phone: (612) 430-2768\n"
  199.         "\t  10321 110th st. N.           EMail: hoffo002@gold.tc.umn.edu\n"
  200.         "\t  Stillwater, MN  55082\n\n"
  201.  
  202.         "Feel free to send me comments, suggestions, bug reports, etc. too, even if\n"
  203.         "you decide not to register.\n");
  204.  
  205.     return;
  206. }