🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.games.descent
Article #1438

More fun with your hex editor!! (And C compiler)

#1438
From: cant... Macky Stingray
Date: Sun, 26 Mar 1995 10:16
164 lines
8319 bytes
  After Reptile on #descent was kind enough to give me his lselect batch file
to hack around with the laser levels, I decided I would start editing the
savegames myself.

  So I ripped out my C compiler, and started defining a savegame structure
that I could easily read in and alter, then write back out.

  Here's the end result: A structure that makes it fairly easy from your
C compiler to really mess with your Descent savegames. eventually I hope
to have all this integrated into a nice, windowed package, but until
then, this is fun to play with.

  This is an example program to show how it operates. You can modify,
abuse, etc... this, just leave the names of the people on it. 

  The most important two things here are:

A) I discovered how to edit in keys
 and 
B) I disocvered how to edit in/out record of cheat codes being used.

  The rest of this stuff is in documents elsewhere.

-----railgun spike here-----

#include<stdio.h>

#define BYTE unsigned char

//  This struct put together with the help of Darren Lo's (darr...@umich.edu)
// very informative post to alt.games.descent detailing the format of the
// savegame table.
typedef struct {
 BYTE signature[4];            //Seems to always be "DGSS."
 BYTE unknown1[4];             // ? Checksum ?
 char savegame_name[20];       // 20 char C string: name of savegame.
 BYTE snapshot[5025];          // 5025 bytes for screen shot at save.
 char pilot_name[8];           // 8 character C string: owning player.
 BYTE unknown2[20];            // ? ?
 BYTE keys;                    // What keys are present.
                                // Bit 0 - No effect?
                                // Bit 1 = 1 if blue key present.
                                // Bit 2 = 1 if red key present.
                                // Bit 3 = 1 if yellow key present.
 BYTE quad;                    // = 4 if quad lasers present, 0 otherwise.
 BYTE unknown3[4];             // ? ?
 int energy;                   // Amount of energy when last level exited.
                                // If this is less than 100, it is upgraded
                                // to 100. Be careful, this a SIGNED value.
                                // The largest value here = FF 7F.
 int cheater;                  // 0x0 = no cheats, 0x9BE0 = cheater.
 int shields;                  // Shield level; see energy.
 BYTE lives;                   // Number of lives + 1.
 BYTE unknown5;                // Possibly last level completed?
 BYTE laser_type;              // What kind weapon is on the lasers?
                                // See also all the #defines below.
 BYTE level_started_at;        // Level at which we started this game.
 BYTE unknown6[2];             // ? ?
 BYTE primaries;               // Which primary weapons do we have?
                                // Bit 0 = 1 if we have lasers.
                                // Bit 1 = 1 if we have vulcan.
                                // Bit 2 = 1 if we have spreadfire.
                                // Bit 3 = 1 if we have plasma.
                                // Bit 4 = 1 if we have fusion.
 BYTE secondaries;             // Which secondary weapons do we have?
                                // Bit 0 = 1 if we have concussion missles.
                                // Bit 1 = 1 if we have homing missles.
                                // Bit 2 = 1 if we have proximity bombs.
                                // Bit 3 = 1 if we have smart missles.
                                // Bit 4 = 1 if we have mega missles.
 BYTE unknown7[2];             // ? ?
 int vulcan_ammo;              // How many packs of 25 vulcan bullets?
                                // (We think)This is a SIGNED value.
 BYTE unknown8[6];             // ? ?
 BYTE conc_miss;               // How many concussion missles do we have?
 BYTE unknown9;                // Always 0?
 BYTE homing_miss;             // How many homing missles do we have? (0-200)
 BYTE unknown10;               // Always 0?
 BYTE prox_bombs;              // How many proximity bombs do we have?
 BYTE unknown11;               // Always 0?
 BYTE smart_miss;              // ? How many smart missles ?
 BYTE unknown12;               // Always 0?
 BYTE mega_miss;               // ? How many megamissles ?
 BYTE unknown13;               // Always 0?
 BYTE lastlevelscore[3];       // ? INT Score at beginning of last level ?
 BYTE currscore[3];            // Current score. Signed I think.
 BYTE unknown14[40];           // ? ? ? ?
 BYTE difficulty_level;        // 0 = trainee, 1 = rookie, etc...
 BYTE unknown15[3];            // ? ?
 BYTE curr_primary;            // 0 = Laser, 1 = Vulcan etc...
 BYTE unknown16[3];            // ? ?
 BYTE curr_secondary;          // 0 = Conc, 1 = Homing, etc...
} registered_savegame;

// These values shamelessly lifted from LSELECT.BAT by Reptile on #descent.

#define L1_LASERS 0x00                //Level 1 lasers
#define L2_LASERS 0x01                //Level 2 "    "
#define L3_LASERS 0x02                //Level 3 "    "
#define L4_LASERS 0x03                //Level 4 "    "
#define BLUE_BALLS 0x04               //Big, slow, weak, blue plasma balls...
#define YELLOW_BALLS 0x05             //Yellow drone's fireballs (WEAK)
#define RED_BALLS 0x06                //Reactor's weapon.
#define BAD_VALUE 0x07                //Causes the game to crash out!
#define CONC_MISS 0x08                //Concussion missiles!
#define FLARES 0x09                   //Flares (this is hilarious... try it)
				       // Believe it or not, you can kill
				       // enemies with only flares(!)
#define BLUEROBOT_WEAPON 0x0A         //Blue drone's lasers
#define VULCAN 0x0B                   //Vulcan cannon (slower than normal)
#define SPREADFIRE 0x0C               //Spreadfire cannon balls
#define PLASMA 0x0D                   //Plasma Cannon
#define FUSION 0x0E                   //Fusion Cannon
#define HOMING_MISS 0x0F              //Homing missiles.
#define PROX_BOMBS 0x10               //Proximity bombs.
#define SMART_MISS 0x11               //Smart Missles
#define MEGA_MISS 0x12                //Megamissles.
#define SUPERHULK_GREEN_BLOBS 0x13    //Green blobs from the superhulk
#define SPREADFIRE2 0x14              //Spreadfire cannon balls
#define SLOW_HOMING_MISS 0x15         //Slow homing missiles
#define SLOW_CONC_MISS 0x16           //Slow (?) concussion missiles
#define SPREADFIRE3 0x17              //Spreadfire cannon balls AGAIN
#define WHIMPY_SLOW_REDLASERS 0x18    //Wimpy, slow red lasers
#define SLOW_GREEN_LASERS 0x19        //Slow green lasers
#define SLOW_PLASMA 0x1A              //Plasma, though a bit slower
#define YELLOW_BALLS2 0x1B            //Yellow drone's fireballs
#define MEGA_MISS2 0x1C               //Mega Missles again...
#define HOMING_PLASMA 0x1D            //Homing Plasma (like a Smart Missle)


Usage example:

int main(void)
{
 registered_savegame a;
 FILE *moo;

 moo=fopen("d:\\games\\descent\\a.sg1","rb+");
 fread(&a,sizeof(a),1,moo);

 a.laser_type=FLARES;
 a.keys=0xE;
 a.vulcan_ammo=0xFFFF;
 a.primaries=0x1F;
 a.secondaries=0x1F;
 a.conc_miss=123;
 a.homing_miss=456;
 a.prox_bombs=1;
 a.smart_miss=789;
 a.mega_miss=27;
// etc...

 rewind(moo);
 fwrite(&a,sizeof(a),1,moo);
 fclose(moo);
}
-----railgun spike here-----

          -Ben
-- 
void goto_college(){             | Ben Cantrick: cant...@rtt.colorado.edu
while(credits<requirements){     | (School) or bcan...@nyx10.cs.du.edu (Nyx)
hairlength++; anime_tapes+=A_LOT;| Ben @ Altered States, Macky @ AnimeMUCK,
credits+=classes-social_life; }} | Macky @ IRC, BGC Otaku @ CU Boulder.
Technical Details
Message-ID: <3l3etr$rsi@CUBoulder.Colorado.EDU>
Path: mbox-mo1.pugleaf.net!nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!agate!boulder!rintintin.Colorado.EDU!cantrick

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!agate!boulder!rintintin.Colorado.EDU!cantrick
From: cant...@rintintin.Colorado.EDU (Macky Stingray)
Newsgroups: alt.games.descent
Subject: More fun with your hex editor!! (And C compiler)
Date: 26 Mar 1995 10:16:27 GMT
Organization: Silky Doll Women's Lingerie, MegaTokyo, JP
Lines: 164
Message-ID: <3l3etr$rsi@CUBoulder.Colorado.EDU>
NNTP-Posting-Host: rintintin.colorado.edu
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit