GEN

From OHRRPGCE-Wiki

Jump to: navigation, search

The lump with the extension .GEN is a critical one. It contains miscelaneous information about a wide varitey of unrelated things, especially max number of records for other files, password information, and other stuff that I felt like sticking in there too-- some of which really don't belong.

This lump is stored in BSAVE format. It has a 7 byte header which indicates the size of the remaining data (and other things). See BSAVE Header for more information.

The following is the meaning of each element.

Grey fields are obsolete or unused.
Pink fields are runtime-only fields used by GAME that do not really belong GEN in the first place, but are there anyway to make including them in SAV files more convenient
Blue fields are editor-only fields used by CUSTOM (although some of them, like 39 genMaxTextbox may be used by GAME for error-checking)
Green records are preserved in SAV files.

About Formal Specs

Element Data Constant Meaning
0INT genMaxMap max maps
1INT genTitle title screen backdrop index in MXS
2INT genTitleMus title music
3INT genVictMus victory music + 1 (0 for none)
4INT genBatMus default battle music
5INT genPassVersion passcode format number
6INT genPassRot new(third-style) passcode rotator
7-15BYTE*17 +1 new(third-style) obfuscated passcode + 1 unused byte
16-25INT*10 old-old(first-style) obsolete password data
26INT genMaxHeroPic max hero graphics in PT0
27INT genMaxEnemy1Pic max small enemy graphics in PT1
28INT genMaxEnemy2Pic max med enemy graphics in PT2
29INT genMaxEnemy3Pic max large graphics in PT3
30INT genMaxNPCPic max npc graphics in PT4
31INT genMaxWeaponPic max weapon graphics in PT5
32INT genMaxAttackPic max attack graphics in PT6
33INT genMaxTile max tilesets in TIL
34INT genMaxAttack max attack definitions in DT6
35INT genMaxHero max hero definitions in DT0
36INT genMaxEnemy max enemy definitions in DT1
37INT genMaxFormation max formations in FOR
38INT genMaxPal max palettes in PAL
39INT genMaxTextbox max text boxes in SAY
40INT genMaxPlotscript total available plotscripts (number of records in PLOTSCR.LST)
41INT genNewgameScript ID of new-game plotscript
42INT genGameoverScriptID of game-over plotscript
43INT genMaxRegularScriptID of highest manually numbered old-style plotscript
44INT genSuspendBits suspendstuff bits
45INT genCamera camera mode
46INT genCamArg1 cameraarg1
47INT genCamArg2 cameraarg2
48INT genCamArg3 cameraarg3
49INT genCamArg4 cameraarg4
50INT genScrBackdrop currently displaying script backdrop index in MXS
51INT genDays days of play
52INT genHours hours of play
53INT genMinutes minutes of play
54INT genSeconds seconds of play
55INT genMaxVehicle max vehicle types in VEH
56INT genMaxTagname Last named tag
57INT genLoadgameScriptload-game plotscript
58INT genTextboxBackdropcurrently displaying text box backdrop in MXS
59INT genEnemyDissolve Default enemy dissolve type.
0=Default (old style dissolve)
1=Crossfade
2=Diagonal vanish
3=Sink into ground
60INT genJoy Enable/disable joystick
61INT genPoison Posion status indicator char
62INT genStun Stun status indicator char
63INT genDamageCapDamage cap (0 if there is none)
64INT genMuteMute status indicator char
65-76INT*12 genStatCapStat caps for each stat, in this order:
HP
MP
Atk
Aim
Def
Dog
Mag
Wil
Spd
Ctr
Focus
Extra Hits
77INT genMaxSFXNumber of sound effects
78INT genMasterPalMaster palette number in PALETTES.BIN
79INT genMaxMasterPalMax master palette number in PALETTES.BIN and number of UI color sets in UICOLORS.BIN
80INT genMaxMenuMax menu in MENUS.BIN
81INT genMaxMenuItemMax menu item in MENUITEM.BIN
82INT genMaxItemMax item number in ITM
83-92INT*13 reserved for future ill-conceived additions. Ugh.
93INT genPW2Offset old(second-style) passcode offset
94INT genPW2Length old(second-style) passcode length (-1 if there is no password)
95INT genVersion RPG file format version ID (6 is the latest)
96INT genStartMoneystarting money
97INT genMaxShop last shop in SHO
98INT genPW1Offset old-old(first-style) passcode offset
99INT genPW1Length old-old(first-style) passcode length
100INT genMaxBackdropnumber of screens in MXS
101INT genBits general bitsets:
0 - Pause on Battle Menus
1 - Enable Caterpillar party
2 - don't restore HP on level-up
3 - don't restore MP on level-up
4 - Inns don't revive dead heros
5 - Hero swapping always available
6 - Hide ready meter in battle
7 - Hide health bar in battle
8 - disable debugging keys
9 - Simulate old level-up bug
10 - Permit double-triggering of scripts
11 - Skip title screen
12 - Skip load screen
13 - Pause on All Battle Menus
14 - Disable Hero's Battle Cursor
15 - Default passability disabled by default
102INT genStartX starting X
103INT genStartY starting Y
104INT genStartMap starting Map
105INT genOneTimeNPC one-time-NPC indexer
106-170INT*65 one-time-NPC placeholder bits
171INT genDefaultDeathSfx Default enemy death sound effect ID + 1 (0 for none)
172INT genMaxSonglast song number (SNG and BAM)
173INT genAcceptSfxSound effect to use for "accept" (in menus) ID + 1 (0 for none)
174INT genCancelSfxSound effect to use for "cancel" (in menus) ID + 1 (0 for none)
175INT genChooseSfxSound effect to use for moving the cursor (in menus) ID + 1 (0 for none)
176INT gentextboxLetter Sound effect to use for displaying text box lines ID + 1 (0 for none)
177INT genBits2 Additional general bitsets

0 - Simulate pushable NPC collision bug
1 - Disable ESC to run from battle

178-198INT*23 wasted space
199INT old(second-style) password scattertable head
200-359INT*160 old(second-style) password scattertable

Maximums : "max XYZ" means 'the highest numbered XYZ'. If you have 80 enemies defined, then "max enemy" == 79, because the numbering starts from 0.

[edit] Passwords

[edit] New Passwords

The password protection in the RPG format is embarasingly weak. The password itself is obscured with weak, but space-wasting encription, and the length of the password is totally unprotected. RPG password protection works entirely on the honor system. Its kinda like that faded sign hanging on the gates of Anhk-Morpork that says "Thank you for not invading our city"

Here is how to read the password. Please-please-pretty-please dont just ignore it. It is flimsy pathetic laughable protection, but its all we have! Dont take away our wire umbrella in the lightening storm!

The password is stored in the GEN lump (see GEN lump details above)

GEN(5) is the password version number. 256 is the current version number, any number lower than 256 indicates that the password is stored in one of the two obsolete password formats. The best thing to do when decoding an RPG file that still has its password in the old format is to print a warning message telling the user to upgrade their RPG file with CUSTOM.EXE

GEN(6) is the password rotator. It will always be a random number from 1 to 254 that will be used to ascii-rotate/obfuscate the password.

GEN(7-15) is the password text. There are 17 bytes of data here (so the high byte of GEN(15) is unused). Read this string of 17 bytes. ascii-rotate each character by subtracting GEN(6), and then discard all characters with ascii values less than 32 (space). The resulting string will be your password. If the string is empty (all 17 chars were under 32) then the RPG file does not have a password.

[edit] Old Passwords

This information describes the old obsolete password storage format. it is only here as a curiousity... and a monument of shame to security-through-obscurity The first element of the password mess GEN(200) is the bit-offset of the first bit in the password, relative to the beginning of the scattertable head (199). The next element (201) is the bit-offset of the next bit in the password, and so on. So GEN(200) thru GEN(207) will give you the bits that make up the first ascii char of the password. GEN(208)-GEN(215) gives you the next char, and so on up to GEN(94)+1 bytes. After you have read all the chars from the scattertable, rotate them down by the value of GEN(93) (that is to say, subtract GEN(93) from the ascii value of each char, and if the result is less than 0, add 256).

Clear as mud, right? Here is an example. Lets suppose that the data in the GEN lump looks like this

GEN(93)=172    the ascii-rotate offset
GEN(94)=23     the number of bits -1.
               23+1 = 24, thats the total number of bits in the password
               There are 8 bits in each char of the password, so 24
               divided by 8 is 3. That means this password will end up being 3 chars long.
 
BIT OFFSETS/SCATTERTABLE
GEN(199)=8 [0001 0000 0000 0000] dummy number. Never 0 or 255
GEN(200)=4 [0010 0000 0000 0000] Start here. bit 4 in the table is a 0
GEN(201)=3 [1100 0000 0000 0000] bit 3 in the table is a 1, now we have 01
GEN(202)=18[0100 1000 0000 0000] bit 18 is 1: 011
GEN(203)=18[0100 1000 0000 0000] bit 18 is 1: 0111
GEN(204)=54[0110 1100 0000 0000] bit 58 is 0: 01110
GEN(205)=33[1000 0010 0000 0000] bit 33 is 1: 011101
GEN(206)=85[1010 1010 0000 0000] bit 85 is 1: 0111011
GEN(207)=82[0100 1010 0000 0000] bit 82 is 1: 01110111

So we end up with 01110111 which is char 238, (a wierd ascii math symbol) Now we subtract the value of GEN(93) and we get 66, which is the ascii code for upper case B, so we know the first letter of the password is B.

Ah, what fun. what a mess. what a waste. *sigh*

ARCHINYM.LMP . BROWSE.TXT . ATTACK.BIN . BINSIZE.BIN . DEFPAL#.BIN . DEFPASS.BIN . FIXBITS.BIN . LOOKUP.BIN . MENUS.BIN . MENUITEM.BIN . PALETTES.BIN . PLOTSCR.LST . SFXDATA.BIN . SONGDATA.BIN . UICOLORS.BIN . GEN . BAM . Map Format . T . P . E . D . L . N . DOR . DOX . DT0 . DT1 . DT6 . EFS . FOR . FNT . HSP . HSZ . ITM . MAP . MAS . MN . MXS . PAL . PT0 . PT1 . PT2 . PT3 . PT4 . PT5 . PT6 . SAY . SHO . SNG . STF . STT . TAP . TIL . TMN . VEH

Personal tools