home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / MISSING / CIVMAP21.ZIP / civmap21.pas < prev    next >
Pascal/Delphi Source File  |  1993-06-20  |  25KB  |  552 lines

  1. { Civilization Map Changer Version 2.1 (6/20/93)
  2.   written by Holger Eichmann
  3.  
  4.   Changes the interrupts $f1 and $f2. If you insert a call of these
  5.   interrupts into the right places of the civ.exe file (see writeln text
  6.   in the main program), you are able to change important attributes of
  7.   single points of the map while playing civ.exe. Because civ.exe has no
  8.   list of improvements of map points (like coal, oasis or fish), but only
  9.   calculate these points, this program generates its own list. Consider
  10.   that this list will not be saved automatically, too, when you save your
  11.   game. While playing you will get the cheat menu when you right click
  12.   a distant field like normally getting informations of the landscape type
  13.   of this field.
  14.   In this version the program should work together with all versions of
  15.   civ.exe (I hope so).
  16.  
  17.   Please send your comments to:
  18.      Holger.Eichmann@cdc2.atomare-prozesse.physik.uni-hannover.dbp.de}
  19.  
  20.  
  21. {$M $800,0,0}
  22.  
  23. uses dos, crt;
  24.  
  25. const maxlist = 200; { max. length of improvement list (contains the
  26.                        coordinates of the fields with changed improvement
  27.                        like coal or horses) }
  28.  
  29. {$F+}
  30.  
  31. var counter,i, masterw : word;
  32.     x, y : array[1..maxlist] of word;
  33.     turn_on : boolean;
  34.     regs : registers;
  35.     colorlist : array[1..771] of byte;
  36.  
  37. {$L c:\tp\programs\asm\civext21.obj}
  38.  
  39. procedure civext21(var segm_dark, off_dark, dark_pos, segm_data, row,
  40.                  column, error: word); external;
  41.  
  42. {$L c:\tp\programs\asm\civint2.obj}
  43.  
  44. procedure civint2; external;
  45.  
  46. procedure editor; interrupt;
  47.  
  48. var key : char;
  49.     filelength : longint;
  50.     mode, landtype, sm_map, attr, dark, all_dark : byte;
  51.     norm_impr, improve, exist, ende : boolean;
  52.     row, column, segm_data, segm_dark, off_land, off_smap, off_attr1,
  53.     off_attr2, off_dark, im_pos, i, j, dark_pos, error : word;
  54.     s : array[1..25] of char;
  55.     s1, s2, length : string[7];
  56.     fname : string;
  57.     f : text;
  58.  
  59. begin
  60.    { correct one of the changes of civ.exe (mov ax,32 -> int F1) }
  61.    inline($b8/$32/$00/$36/$89/$46/$10); {mov ax,32h; mov ss:[bp+10h],ax}
  62.    if turn_on then
  63.       begin
  64.          { get colors }
  65.          regs.ax := $1017;
  66.          regs.bx := 0;
  67.          regs.cx := 256;
  68.          regs.es := seg(colorlist);
  69.          regs.dx := ofs(colorlist);
  70.          intr($10, regs);
  71.          { get video mode }
  72.          regs.ah := $0f;
  73.          intr($10, regs);
  74.          mode := regs.al;
  75.          { set video mode to 80*25 text }
  76.          regs.ah := 0;
  77.          regs.al := 03;
  78.          intr($10, regs);
  79.          textcolor(15);
  80.  
  81.   { get coordinates of the map field and the addresses of the data in memory
  82.     segm_dark:off_dark : places known or unknown; your civilization is stored
  83.                          at position dark_pos of each byte
  84.     segm_data:...      : map informations like type of landscape
  85.     row, column        : coordinates of field}
  86.  
  87.          civext21(segm_dark, off_dark, dark_pos, segm_data, row, column, error);
  88.          if error = 1 then
  89.             begin
  90.                clrscr;
  91.                writeln;
  92.                writeln('Fatal Error: Unknown Civilization Version !!!!!!');
  93.                writeln;
  94.                writeln('If you want to use civ_map, then try another Civilization version !');
  95.                writeln('Please send a mail to the author !');
  96.                key := readkey;
  97.             end
  98.          else if (row = 0) or (row = 1) then
  99.             begin
  100.                clrscr;
  101.                writeln;
  102.                writeln('Sorry, no changes of row 0 and 1 allowed !!!!!!');
  103.                writeln('(that would confuse the data search function)');
  104.                key := readkey
  105.             end
  106.          else
  107.           begin
  108.             { calculate segment and offset addresses of the interesting data }
  109.             off_land := row*$140+column;
  110.             off_smap := off_land + $f0;
  111.             off_attr1 := off_land + $7d00;
  112.             off_attr2 := off_land + $7d50;
  113.             { get the properties of the map field }
  114.             landtype := mem[segm_data:off_land];   { type of landscape (ocean, ...) }
  115.             sm_map := mem[segm_data:off_smap];     { appearance in small map }
  116.             attr := mem[segm_data:off_attr1];      { attributes (roads,...) }
  117.             dark := mem[segm_dark:column*$32 + row + off_dark];  { is it dark ? }
  118.             exist := false;            { already in improvement list ? }
  119.             ende := false;
  120.             im_pos := 0;               { position there }
  121.             all_dark := 0;             { all fields set dark or clear ? }
  122.             { calculation if it normally is improved; the variable masterw will
  123.               be set by civint2.asm automatically }
  124.             norm_impr := (((column shr 2) * $000d + (row shr 2) * $000b
  125.                        + masterw) and $000f = (column and 3) shl 2
  126.                        + (row and 3));
  127.             improve := norm_impr;
  128.             { test, whether it is in the improvement list }
  129.             for i := 1 to counter do
  130.                 if (x[i] = column) and (y[i] = row) then
  131.                    begin
  132.                       improve := not norm_impr;
  133.                       exist := true;
  134.                       im_pos := i
  135.                    end;
  136.             repeat
  137.                { some text lines will be marked by a * }
  138.                s[1] := char(integer(landtype=1) * 10 + 32);
  139.                s[2] := char(integer(landtype=2) * 10 + 32);
  140.                s[3] := char(integer(landtype=3) * 10 + 32);
  141.                s[4] := char(integer(landtype=6) * 10 + 32);
  142.                s[5] := char(integer(landtype=7) * 10 + 32);
  143.                s[6] := char(integer(landtype=9) * 10 + 32);
  144.                s[7] := char(integer(landtype=10) * 10 + 32);
  145.                s[8] := char(integer(landtype=11) * 10 + 32);
  146.                s[9] := char(integer(landtype=12) * 10 + 32);
  147.                s[10] := char(integer(landtype=13) * 10 + 32);
  148.                s[11] := char(integer(landtype=14) * 10 + 32);
  149.                s[12] := char(integer(landtype=15) * 10 + 32);
  150.                s[16] := char(integer(attr and 2=2) * 10 + 32);
  151.                s[17] := char(integer(attr and 4=4) * 10 + 32);
  152.                s[18] := char(integer(attr and 8=8) * 10 + 32);
  153.                s[19] := char(integer(attr and 16=16) * 10 + 32);
  154.                s[20] := char(integer(attr and 32=32) * 10 + 32);
  155.                s[21] := char(integer(attr and 64=64) * 10 + 32);
  156.                if dark and dark_pos = dark_pos then s1 := 'un' else s1 := '';
  157.                if improve then s2 := 'remove' else s2 := 'create';
  158.                str(counter,length);
  159.                clrscr;
  160.                writeln ('Civilization Map Changer Version 2.1       written by Holger Eichmann');
  161.                writeln ('(C) 1993 by Sirius Cybernetics Corporation, Sirius Star System I-III');
  162.                writeln;
  163.                writeln ('Position: row: ',row,',  column: ', column);
  164.                writeln('Landscape: ',s[1],' (0) ocean                 Attributes:  ',s[16],' (f) irrigation');
  165.                writeln('           ',s[2],' (1) forest                             ',s[17],' (g) mines');
  166.                writeln('           ',s[3],' (2) swamp                              ',s[18],' (h) roads');
  167.                writeln('           ',s[4],' (3) plain                              ',s[19],' (i) railroad');
  168.                writeln('           ',s[5],' (4) tundra                             ',s[20],' (j) fortification');
  169.                writeln('           ',s[6],' (5) river                              ',s[21],' (k) pollution');
  170.                writeln('           ',s[7],' (6) grassland');
  171.                writeln('           ',s[8],' (7) jungle                 (l) make this place ',s1,'known');
  172.                writeln('           ',s[9],' (8) hill                   (m) make whole map known');
  173.                writeln('           ',s[10],' (9) mountain               (n) make whole map unknown');
  174.                writeln('           ',s[11],' (a) desert');
  175.                writeln('           ',s[12],' (b) arctic                 (o) ',s2,' improvement');
  176.                writeln('                                        (p) clear improvement list');
  177.                writeln('(c) load whole map                      (q) load list');
  178.                writeln('(d) save whole map                      (r) save list');
  179.                writeln('                                            list length: ',length);
  180.                writeln;
  181.                writeln('                            (x) exit');
  182.                key := readkey;
  183.                { what do you want to change ? }
  184.                case key of
  185.                    '0'     : landtype := 1;
  186.                    '1'     : landtype := 2;
  187.                    '2'     : landtype := 3;
  188.                    '3'     : landtype := 6;
  189.                    '4'     : landtype := 7;
  190.                    '5'     : landtype := 9;
  191.                    '6'     : landtype := 10;
  192.                    '7'     : landtype := 11;
  193.                    '8'     : landtype := 12;
  194.                    '9'     : landtype := 13;
  195.                  'a','A'   : landtype := 14;
  196.                  'b','B'   : landtype := 15;
  197.                  'c','C'   : begin
  198.                                writeln('Are you sure that you want to load the whole map ?');
  199.                                key := readkey;
  200.                                if (key = 'y') or (key = 'Y') then
  201.                                   begin
  202.                                      all_dark := 100;
  203.                                      ende := true
  204.                                   end
  205.                              end;
  206.                  'd','D'   : begin
  207.                                writeln('Are you sure that you want to save the whole map ?');
  208.                                key := readkey;
  209.                                if (key = 'y') or (key = 'Y') then
  210.                                   begin
  211.                                      all_dark := 101;
  212.                                      ende := true
  213.                                   end
  214.                              end;
  215.                  'f','F'   : attr := attr xor 2;
  216.                  'g','G'   : attr := attr xor 4;
  217.                  'h','H'   : attr := attr xor 8;
  218.                  'i','I'   : attr := attr xor 16;
  219.                  'j','J'   : attr := attr xor 32;
  220.                  'k','K'   : attr := attr xor 64;
  221.                  'l','L'   : dark := dark xor dark_pos;
  222.                  'm','M'   : begin
  223.                                writeln('Are you sure that you want to make the whole map known ?');
  224.                                key := readkey;
  225.                                if (key = 'y') or (key = 'Y') then
  226.                                   begin
  227.                                      all_dark := 1;
  228.                                      ende := true
  229.                                   end
  230.                              end;
  231.                  'n','N'   : begin
  232.                                writeln('Are you sure that you want to make the whole map unknown ?');
  233.                                key := readkey;
  234.                                if (key = 'y') or (key = 'Y') then
  235.                                   begin
  236.                                      all_dark := 2;
  237.                                      ende := true
  238.                                   end
  239.                              end;
  240.                  'o','O'   : improve := not improve;
  241.                  'p','P'   : begin counter := 0; improve := norm_impr;
  242.                                    exist := false end;
  243.                  'q','Q'   : begin
  244.                                 improve := norm_impr;
  245.                                 exist := false;
  246.                                 write ('Filename: ');
  247.                                 readln (fname);
  248.                                 {$I-}
  249.                                 assign (f, fname);
  250.                                 reset (f);
  251.                                 {$I+}
  252.                                 if ioresult <> 0 then
  253.                                     begin
  254.                                        writeln('Error by opening of file');
  255.                                        key := readkey
  256.                                     end
  257.                                 else
  258.                                    begin
  259.                                       counter := 0;
  260.                                       repeat
  261.                                          inc (counter);
  262.                                          readln(f, x[counter], y[counter]);
  263.                                       until eof(f);
  264.                                       ende := true;
  265.                                       close(f)
  266.                                    end;
  267.                              end;
  268.                  'r','R'   : begin
  269.                                 improve := norm_impr;
  270.                                 exist := false;
  271.                                 write ('Filename: ');
  272.                                 readln (fname);
  273.                                 {$I-}
  274.                                 assign (f, fname);
  275.                                 rewrite (f);
  276.                                 {$I+}
  277.                                 if ioresult <> 0 then
  278.                                     begin
  279.                                        writeln('Error by opening of file');
  280.                                        key := readkey
  281.                                     end
  282.                                 else
  283.                                    begin
  284.                                       for i := 1 to counter do
  285.                                          writeln(f, x[i],' ',y[i]);
  286.                                       close(f)
  287.                                    end
  288.                              end;
  289.                  'x','X'   : ende := true;
  290.                  chr(0)    : key := readkey;
  291.                end;
  292.             until ende;
  293.             { calculate small map }
  294.             if (dark and dark_pos = 0) then sm_map := 0
  295.                else if landtype = 1 then sm_map := 1
  296.                   else sm_map := 2;
  297.             { store back the field properties }
  298.             mem[segm_data:off_land] := landtype;
  299.             mem[segm_data:off_smap] := sm_map;
  300.             mem[segm_data:off_attr1] := attr;
  301.             mem[segm_data:off_attr2] := attr;
  302.             mem[segm_dark:column*$32 + row + off_dark] := dark;
  303.             if not exist and (improve xor norm_impr) then
  304.             { insert new line in improvement list }
  305.                if counter < maxlist then
  306.                   begin
  307.                      inc(counter);
  308.                      x[counter] := column;
  309.                      y[counter] := row;
  310.                   end;
  311.             if exist and not (improve xor norm_impr) then
  312.             { delete line in improvement list }
  313.                begin
  314.                   for i := im_pos to counter-1 do
  315.                      begin
  316.                         x[i] := x[i+1];
  317.                         y[i] := y[i+1];
  318.                      end;
  319.                   dec(counter);
  320.                end;
  321.             if all_dark = 1 then
  322.             { mark all fields as known }
  323.                begin
  324.                   for i := 0 to 3999 do
  325.                      mem[segm_dark:off_dark+i] := mem [segm_dark:off_dark+i]
  326.                                                                    or dark_pos;
  327.                   {change small map}
  328.                   for i := 0 to 79 do
  329.                      for j := 0 to 49 do
  330.                         mem[segm_data:$f0+j*$140+i] :=
  331.                                     2-integer(mem [segm_data:j*$140+i] = 1);
  332.                end;
  333.             if all_dark = 2 then
  334.             { make all fields dark }
  335.                begin
  336.                   for i := 0 to 3999 do
  337.                      mem[segm_dark:off_dark+i] := mem [segm_dark:off_dark+i]
  338.                                                                  and not dark_pos;
  339.                   {change small map}
  340.                   for i := 0 to 79 do
  341.                      for j := 0 to 49 do
  342.                         mem[segm_data:$f0+j*$140+i] := 0;
  343.                end;
  344.             if all_dark = 100 then
  345.                begin
  346.                   clrscr;
  347.                   writeln;
  348.                   writeln ('Now the memory part which contains the informations of the map will be loaded.');
  349.                   writeln ('For further informations see the .inf file');
  350.                   writeln ('Warning: Only the file length will be checked ! When you load the wrong map,');
  351.                   writeln ('         unexpected errors can occur !');
  352.                   writeln;
  353.                   write ('Filename: ');
  354.                   readln (fname);
  355.                   fname := fname + chr(0);
  356.                   { copy file directly to memory; this costs the least memory }
  357.                   { open file }
  358.                   regs.ds := seg(fname[1]);
  359.                   regs.dx := ofs(fname[1]);
  360.                   regs.ax := $3d42;
  361.                   msdos(regs);       {o.k. -> Carry flag, handle -> ax}
  362.                   if regs.flags and 1 <> 0 then
  363.                       begin
  364.                          writeln('Error by file opening');
  365.                          key := readkey
  366.                       end
  367.                   else
  368.                      begin
  369.                         { get file length (file pointer to end of file) }
  370.                         regs.bx := regs.ax;
  371.                         regs.cx := 0;
  372.                         regs.dx := 0;
  373.                         regs.ax := $4202;
  374.                         msdos (regs);
  375.                         filelength := regs.dx * $10000 + regs.ax;
  376.                         { file pointer back to start }
  377.                         regs.cx := 0;
  378.                         regs.dx := 0;
  379.                         regs.ax := $4200;
  380.                         msdos (regs);
  381.                         if (filelength <> 64000) and (filelength <> 68000) then
  382.                            begin
  383.                               writeln('Error: wrong filelength; is the filename correct ?');
  384.                               key := readkey;
  385.                            end
  386.                         else
  387.                            begin
  388.                               { read data }
  389.                               regs.ds := segm_data;
  390.                               regs.dx := 0;
  391.                               regs.cx := $fa00; {number (all blocks; see .inf file)}
  392.                               regs.ah := $3f;
  393.                               msdos(regs);
  394.                               if filelength = 68000 then
  395.                                  begin
  396.                                     writeln('Should the known <-> unknown informations be loaded, too ?');
  397.                                     repeat
  398.                                        key := readkey;
  399.                                     until key in ['y','Y','n','N'];
  400.                                     if (key = 'y') or (key = 'Y') then
  401.                                        begin
  402.                                           regs.ds := segm_dark;
  403.                                           regs.dx := off_dark;
  404.                                           regs.cx := $0fa0; {number (50*80 pieces)}
  405.                                           regs.ah := $3f;
  406.                                           msdos(regs);
  407.                                        end;
  408.                               end;
  409.                               { close file }
  410.                               regs.ah := $3e;
  411.                               msdos(regs);
  412.                            end
  413.                      end
  414.                end;
  415.             if all_dark = 101 then
  416.                begin
  417.                   clrscr;
  418.                   writeln;
  419.                   writeln ('Now the memory part which contains the informations of the map will be saved.');
  420.                   writeln ('For further informations see the .inf file. This saves not the improvement list');
  421.                   writeln ('Warning: Do not change the first 80 Bytes (otherwise the data search function');
  422.                   writeln ('                                           will not work) !!!');
  423.                   writeln;
  424.                   write ('Filename: ');
  425.                   readln (fname);
  426.                   fname := fname + chr(0);
  427.                   { copy memory directly to file; this costs the least memory }
  428.                   { open file }
  429.                   regs.cx := 0;
  430.                   regs.ds := seg(fname[1]);
  431.                   regs.dx := ofs(fname[1]);
  432.                   regs.ah := $3c;
  433.                   msdos(regs);       {o.k. -> Carry flag, handle -> ax}
  434.                   if regs.flags and 1 <> 0 then
  435.                       begin
  436.                          writeln('Error by file opening');
  437.                          key := readkey
  438.                       end
  439.                   else
  440.                      begin
  441.                         { save data }
  442.                         regs.bx := regs.ax;
  443.                         regs.ds := segm_data;
  444.                         regs.dx := 0;
  445.                         regs.cx := $fa00; {number (all blocks; see .inf file)}
  446.                         regs.ah := $40;
  447.                         msdos(regs);
  448.                         writeln('Should the known <-> unknown informations be saved, too ?');
  449.                         repeat
  450.                            key := readkey;
  451.                         until key in ['y','Y','n','N'];
  452.                         if (key = 'y') or (key = 'Y') then
  453.                            begin
  454.                               regs.ds := segm_dark;
  455.                               regs.dx := off_dark;
  456.                               regs.cx := $0fa0; {number (50*80 pieces)}
  457.                               regs.ah := $40;
  458.                               msdos(regs);
  459.                            end;
  460.                         { close file }
  461.                         regs.ah := $3e;
  462.                         msdos(regs);
  463.                      end
  464.                end;
  465.          end;
  466.          { reset video mode }
  467.          regs.ah := 0;
  468.          regs.al := mode;
  469.          intr($10,regs);
  470.          { restore colors }
  471.          regs.ax := $1012;
  472.          regs.bx := 0;
  473.          regs.cx := 256;
  474.          regs.es := seg(colorlist);
  475.          regs.dx := ofs(colorlist);
  476.          intr($10, regs);
  477.      end
  478. end;
  479.  
  480. procedure switch_on; interrupt;
  481.  
  482. var mode : byte;
  483.     key : char;
  484.  
  485. begin
  486.    turn_on := not turn_on;
  487.    { get colors }
  488.    regs.ax := $1017;
  489.    regs.bx := 0;
  490.    regs.cx := 256;
  491.    regs.es := seg(colorlist);
  492.    regs.dx := ofs(colorlist);
  493.    intr($10, regs);
  494.    { get video mode }
  495.    regs.ah := $0f;
  496.    intr($10, regs);
  497.    mode := regs.al;
  498.    { set video mode to 80*25 text }
  499.    regs.ah := 0;
  500.    regs.al := 03;
  501.    intr($10, regs);
  502.    textcolor(15);
  503.    clrscr;
  504.    writeln;
  505.    write('Map Changing Mode is turned ');
  506.    if turn_on then writeln('on')
  507.               else writeln('off');
  508.    key := readkey;
  509.    { reset video mode }
  510.    regs.ah := 0;
  511.    regs.al := mode;
  512.    intr($10,regs);
  513.    { restore colors }
  514.    regs.ax := $1012;
  515.    regs.bx := 0;
  516.    regs.cx := 256;
  517.    regs.es := seg(colorlist);
  518.    regs.dx := ofs(colorlist);
  519.    intr($10, regs);
  520. end;
  521.  
  522.  
  523. {$F-}
  524.  
  525. begin
  526.    writeln;
  527.    writeln ('Civilization Map Changer Version 2.1');
  528.    writeln ('(C) Sirius Cybernetics Corporations, Sirius Star System I-III');
  529.    writeln ('written by Holger Eichmann');
  530.    writeln('Copying and code changing strictly allowed! No rights reserved!');
  531.    writeln;
  532.    writeln('To use this tool you have to change the following bytes in civ.exe:');
  533.    writeln('version 1 + 2(?): E9 54 00 B8 32 00 -> E9 54 00 CD F1 90');
  534.    writeln('version 3 + 4:    02 75 53 B8 32 00 -> 02 75 53 CD F1 90');
  535.    writeln('version 5:        E9 59 00 B8 32 00 -> E9 59 00 CD F1 90');
  536.    writeln('all versions: 3B C1 75 BB B8 01 00 -> CD F2 90 90 90 90 90');
  537.    writeln;
  538.    writeln('Press ''Print Screen'' to turn Map Changer on/off.');
  539.    writeln;
  540.    turn_on := false;
  541.    for i := 1 to maxlist do
  542.       begin
  543.         x[i] := $ffff;
  544.         y[i] := $ffff
  545.       end;
  546.    counter := 0;
  547.    setintvec($05, @switch_on);
  548.    setintvec($f1, @editor);
  549.    setintvec($f2, @civint2);
  550.    keep(0)
  551. end.
  552.