FB Config
Version 0.9.3

REVISION HISTORY:

0.9.5
 +Cosmetic: The blank frame is no longer in view after you open a file
 +Cosmetic: Pretty picture added, it's a gif, don't worry
 +Somehow on my computer loading game ini files wasn't working anymore, fixed (didn't change much...)
 +Fixed/added options in the last Finalburn release
 +Open source! Just keep in mind that this program took up lots of my time. Don't go changing it around and saying it's yours because I will find you and cut your fingers off. Open source is a Good Thing (tm) that doesn't need to get destroyed by llamas. Out of courtesy just please follow standard GPL rules: put out source if you release a binary publicly, give credit where it's due.

0.9.3
 +Cosmetic: Removed all left over mentions of Final Burn Key Config, now everything should read FB Config...
 +...however it's still no longer a fitting name since FB Config can now really load any ini or cfg file
 +Cosmetic: Identification line on fbkchelp.txt and fbkcctrl.txt changed to "// FB Config Control Data" and "// FB Config Option Info" respectively
 +Comsetic: Changed the filename for those two files as well, now they are fbcinfo.dat and fbcctrl.dat
 +Added support for ZSnesW and Callus 95 in fbkchelp.txt and fbkcctrl.txt
 +FB Config no longer opts to attempt to write a new fbcinfo.dat or fbcctrl.dat because why the hell would you want a potential 100k file inside an exe? I am going to be supporting other emulators by somewhat (in)frequently updating these two files and for FB Config to be able to write them, the file must be inside it and it could get bloated that way. I know how everyone loves bloatware (*cough* Windows *cough*).
 +Loads of potential bugs fixed due to the addition to support unlimited sized fbcinfo and fbcctrl files, before they were capped at 100 lines
 +Fixed ini/cfg loading procedure, now it will load files from ZSnes and other emulators that use an equal sign, yay for equal signs
 +FB Config will also no longer attempt to load ini block headers such as "[name of next block of options]" and it will consider lines with a ; at the start as a comment as well
 +Fixed a memory leak
 +You can now resize the window when you load an ini/cfg
 +New control type for the control data file: "disabled" see below for details
 +Cosmetic: If you try to open another file and changed the last one before saving, now you get asked if you want to save
 +AGAIN, PLEASE READ KNOWN PROBLEMS/ISSUES


0.9.0
 +All known bugs squashed:
	*Loading Finalburn.ini wouldn't let you view all the options, stupid variables
	*File->Quit didn't work, cuz there was no code in it :)
 +Finalburn.ini interface overhaul, totally new interface and fast & very easy way to add support for new options
 +See below for the fbkcctrl.txt format
 +PLEASE READ KNOWN PROBLEMS/ISSUES

0.8.1:
 +Extra variables removed that should've been gone since 0.7.5, oops
 +Cosmetic: after loading a game config then finalburn.ini no longer reports how many keys were loaded :) instead reports how many options
 +Cosmetic: when trying quit, reports if a key/option has been changed before exiting
 +No longer crashes when hitting the Previous button when already on page 1, oops
 +Cosmetic: widened main window to accomdate bigger font sizes/report of how many settings ("Final Burn Key Config (9 settings)" did not fit in the title bar)
 +Cosmetic: you couldn't type in the text boxes, oops
 
0.8.0:
 +Now supports Final Burn's very own ini, note that fbkeycfg is not filename specific, practice of adopting profiles left up to user
 +A little note is added into every file fbkeycfg writes to, take heed
 +Supports a text-based help file for the settings in finalburn.ini
 +Not that it matters, but the file i/o functions were practically rewritten to accomodate the two file formats

0.7.51:
 +Pagedown and Insert shared the same scancode, hehe

0.7.5:
 +Almost a total rewrite
 +Keys now handled via a virtual keyboard not a lookup table

0.5.0:
 +Initial release


Copyright Mystiq (mystiq@optonline.net) 2001
Visit my stinky webpage at http://rtool3.cjb.net

Author's Note:
If you don't like potentially buggy software this isn't for you but it should not crash.

INSTALLATION:
You're gonna need Visual Basic 6.0 runtime files which obviously are not provided. You can get them off a search from www.yahoo.com or other search engines. If you have Windows 98SE I *THINK* you have them. Windows 2000 users I know have them. Microsoft should also have a download. Happy hunting. Oh, copy the FBConfig.exe anywhere you like. It doesn't matter where you put it, but, fbkchelp.txt has to go in the same directory as it. This program doesn't create any new registry keys, no files anywhere on your hard drive so if you want to uninstall it just delete those two files.

USAGE/FEATURES:
 +Run the program and it'll ask for a Finalburn ini file. Naturally you can load any file with an ini extension but it won't do you much good. Load up a Finalburn ini file and it'll present you with a list of all the keys you can change, or if you loaded FinalBurn's ini file (see the scripting section to see how FB Config detects ini files), present you with all of the options.

 +On startup, fbkeycfg loads the file fbkchelp.txt and makes the text into help info for the options. It is very easy to add a new tip for a command not listed in the fbkchelp.txt you have. Simply put the new option name on a new line and the info for it right after. See the actual file for more complete instructions and of course samples. :) If you delete, move or mess up the first line, fbkeycfg will write a new one.

 +Any key on a standard American keyboard is supported. "If you can press it, you can use it." (tm)

 +Double click on an action's text box to pick the key to use. Remember you need to be in at least 800x600 resolution to use this program or the virtual keyboard window will be LARGER than your screen so you wont be able to see everything. Just click on a key's button to assign that key to that action. Currently, joysticks and gamepads are not supported but support is coming. It's very easy for me to add new buttons. By default, Finalburn sets player 2 to be a joystick. The scan codes are four (4) digits long and once you change them you can't change them back. If you know a scan code (for example, a joystick) and you want to use that simply type it in the box. FB Config doesn't care what's in the text boxes, you can type your dead pet's name as a key but Finalburn won't necessarily use it. Keep in mind Finalburn ALSO has to support that key. Just because this program lets you put in any key you want, Finalburn may not recognize it.

 +Take note of this program's big flexibility. :)

KNOWN PROBLEMS/ISSUES:
 +If you notice any keys that you specifically set aren't working but some other keys does what you thought that key should do, email me what keys were involved. This should not happen, I checked and double checked the virtual keyboard.

 +I'm not supporting any keybboard but the standard American. Japanese/Chinese/Korean, whatever, look elsewhere. :)

 +Keys in a game's config that are defined as unknown or constant or something funny, will not get loaded by FB Config, this is not fixable unless I keep a list of all known keys -- maybe later
 
 +Screen resolution ratios are not automatically selected. IE, if you pick 640 for width, you must pick 480 for height otherwise Finalburn may not start up.

 +Please take note it is possible I missed out on a bug which could cause a memory leak inside FB Config. This is most likely not the case as all variables used are wiped when a new file is loaded.

 +The amount of RAM FB Config uses is directly related to the size of fbcctrl.dat and fbcinfo.dat. These two files are loaded on startup into RAM to lessen the amount of hard drive access during loading a file. Considering, for example, Ultima Online's ini file is rather large. I'd rather opt for the increase in RAM usage other than the extranneous hard drive access associated with reading the data files each time a new file is loaded. Realistically, FB Config uses 2.5MB of RAM just opening finalburn.ini, most of which is credited to Visual Basic's very nature.

MANUALLY EDITING FINALBURN CONFIG:
 +The hex values in the ini files are scan codes.

REFERENCE:
 +fbkcctrl file format
BEFORE YOU ATTEMPT TO EDIT FBKCCTRL READ THIS IN IT'S ENTIRETY AND UNDERSTAND IT! IT IS RECOMMENDED YOU USE FB CONFIG TO OPEN BOTH A GAME CONFIG AND FINALBURN.INI SO YOU KNOW WHAT'S GOING ON.

This file is a very good part in FBConfig's flexibility. Combined with fbkchelp.txt, FB Config is capable of loading any ini file that is in the format Finalburn's inis are (someoption = somevalue). I do not recommend anyone that does not fully understand this to try and do anything because you'll cause yourself lots of grief and FB Config will crash. It is not tolerant of mess-ups in these two files simply because error checking would be very slow and trivial of detecting an error from something intentional.

Those of you familiar with Visual Basic or Visual C++ know what i'm talking about when I mention the word "control." For those unfamiliar, a control in these two languages is simply an object: a button, a text box, a label, a drop down box, a list box, etc. This version of FB Config only supports combo boxes, text boxes and check boxes. If a combo box is listed it must be followed by a list of possible values to fill it with, not doing so will cause FB Config to spit up blood. Do not try to have a list of values for any control other than a combo box or FB Config will spit up more blood. Valid control types are: "combo" "check" "text" and are the same control you see in Visual Basic/Visual C++. One last valid type is "disabled." It is meant for options that are just not supported yet.

Ok and finally, what the hell am I talking about? When FB Config loads an ini file (it finds the first line of a file does NOT contain the following strings:
 "Final Burn" "Config File" "for the game" denotes a game config file
 "// Final Burn Key Config Tooltip Text" denotes the help database fbkchelp.txt file
 "// Final Burn Key Config Control Data" denotes the control script file fbkcctrl.txt

A file who's first lines contain anything else will be treated as an ini file and will be subject to the data contained in fbkcctrl.txt and fbkchelp.txt. It treats // at the beginning of a line as comments (just as in C++). You run FB Config, and open finalburn.ini. It checks the first line, sees it doesn't match the above criteria and assumes it's an ini file. It reads down to the first option it finds, say it is nAppUseVidMemory. It then checks through the fbkcctrl.txt file for what control to use. Assuming you used a combo box, the line would look like:

"nAppUseVidMemory combo -1,0,1|Framebuffer select"
(or if you want to eliminate completely the -1 option :) you use "nAppUseVidMemory check|Framebuffer select")

The first part of this, nAppUseVidMemory is telling FB Config what variable in the ini file it's loading what control to use, what it's values would be if it's a combo box and what the caption on the label next to it should be. At the same time FB Config searches fbkchelp.txt for the tool tip data. If there are multiple entries for a control/help text the first one is used. If an option is listed in either fbkchelp or fbkcctrl but not the other, FB Config will not attempt to fix anything and you are almost guarunteed the loading will not work correctly.

For recap, "combo" "check" "text" and "disabled" are valid control names. The option in the ini goes as the first word, no spaces are allowed in that:
"nAppUseVidMemory combo"
"nAppBassFilter check"
"szAppRomPath text"

You then need to list possible values if you use a combo box:
"nAppUseVidMemory combo -1,0,1"
"nAppBassFilter check"
"szAppRomPath text"

You always need a pipe, the | character, usually Shift+\, after either the value list or the control name:
"nAppUseVidMemory combo -1,0,1|"
"nAppBassFilter check|"
"szAppRomPath text|"

And then the caption to be in the label next to the control goes after the pipe:
"nAppUseVidMemory combo -1,0,1|Framebuffer select"
"nAppBassFilter check|Bass filter"
"szAppRomPath text|ROMs path"

The simplest type, "disabled" is used as follows (example taken from Callus):
"-setjoythresh disabled|Joystick threshold"
Disabled is used in this case because this option would be extremely hard to support. The data in callus95.ini is as follows:
"-setjoythresh 1   0 0 0 0"
First of all, I don't even know what the 0s are for and I don't have a joystick (sad, I know :P).


Again, keep in mind you should use appropriate controls for options. For example you wouldn't use a combo box for the ROMs path unless you have several places you put ROMs and dont want to have to keep typing them in:
"szAppRomPath combo C:\cps2\roms,D:\roms,f:\|where the **** are your roms"
That WILL work and is a nice accidental feature from this method. Likewise, under no circumstances should you ever use a check box for something like screen resolution for obvious reasons.

 +Keyboard scan codes:
#define DIK_ESCAPE          0x01
#define DIK_1               0x02
#define DIK_2               0x03
#define DIK_3               0x04
#define DIK_4               0x05
#define DIK_5               0x06
#define DIK_6               0x07
#define DIK_7               0x08
#define DIK_8               0x09
#define DIK_9               0x0A
#define DIK_0               0x0B
#define DIK_MINUS           0x0C    /* - on main keyboard */
#define DIK_EQUALS          0x0D
#define DIK_BACK            0x0E    /* backspace */
#define DIK_TAB             0x0F
#define DIK_Q               0x10
#define DIK_W               0x11
#define DIK_E               0x12
#define DIK_R               0x13
#define DIK_T               0x14
#define DIK_Y               0x15
#define DIK_U               0x16
#define DIK_I               0x17
#define DIK_O               0x18
#define DIK_P               0x19
#define DIK_LBRACKET        0x1A
#define DIK_RBRACKET        0x1B
#define DIK_RETURN          0x1C    /* Enter on main keyboard */
#define DIK_LCONTROL        0x1D
#define DIK_A               0x1E
#define DIK_S               0x1F
#define DIK_D               0x20
#define DIK_F               0x21
#define DIK_G               0x22
#define DIK_H               0x23
#define DIK_J               0x24
#define DIK_K               0x25
#define DIK_L               0x26
#define DIK_SEMICOLON       0x27
#define DIK_APOSTROPHE      0x28
#define DIK_GRAVE           0x29    /* accent grave */
#define DIK_LSHIFT          0x2A
#define DIK_BACKSLASH       0x2B
#define DIK_Z               0x2C
#define DIK_X               0x2D
#define DIK_C               0x2E
#define DIK_V               0x2F
#define DIK_B               0x30
#define DIK_N               0x31
#define DIK_M               0x32
#define DIK_COMMA           0x33
#define DIK_PERIOD          0x34    /* . on main keyboard */
#define DIK_SLASH           0x35    /* / on main keyboard */
#define DIK_RSHIFT          0x36
#define DIK_MULTIPLY        0x37    /* * on numeric keypad */
#define DIK_LMENU           0x38    /* left Alt */
#define DIK_SPACE           0x39
#define DIK_CAPITAL         0x3A
#define DIK_F1              0x3B
#define DIK_F2              0x3C
#define DIK_F3              0x3D
#define DIK_F4              0x3E
#define DIK_F5              0x3F
#define DIK_F6              0x40
#define DIK_F7              0x41
#define DIK_F8              0x42
#define DIK_F9              0x43
#define DIK_F10             0x44
#define DIK_NUMLOCK         0x45
#define DIK_SCROLL          0x46    /* Scroll Lock */
#define DIK_NUMPAD7         0x47
#define DIK_NUMPAD8         0x48
#define DIK_NUMPAD9         0x49
#define DIK_SUBTRACT        0x4A    /* - on numeric keypad */
#define DIK_NUMPAD4         0x4B
#define DIK_NUMPAD5         0x4C
#define DIK_NUMPAD6         0x4D
#define DIK_ADD             0x4E    /* + on numeric keypad */
#define DIK_NUMPAD1         0x4F
#define DIK_NUMPAD2         0x50
#define DIK_NUMPAD3         0x51
#define DIK_NUMPAD0         0x52
#define DIK_DECIMAL         0x53    /* . on numeric keypad */
#define DIK_F11             0x57
#define DIK_F12             0x58

#define DIK_F13             0x64    /*                     (NEC PC98) */
#define DIK_F14             0x65    /*                     (NEC PC98) */
#define DIK_F15             0x66    /*                     (NEC PC98) */

#define DIK_KANA            0x70    /* (Japanese keyboard)            */
#define DIK_CONVERT         0x79    /* (Japanese keyboard)            */
#define DIK_NOCONVERT       0x7B    /* (Japanese keyboard)            */
#define DIK_YEN             0x7D    /* (Japanese keyboard)            */
#define DIK_NUMPADEQUALS    0x8D    /* = on numeric keypad (NEC PC98) */
#define DIK_CIRCUMFLEX      0x90    /* (Japanese keyboard)            */
#define DIK_AT              0x91    /*                     (NEC PC98) */
#define DIK_COLON           0x92    /*                     (NEC PC98) */
#define DIK_UNDERLINE       0x93    /*                     (NEC PC98) */
#define DIK_KANJI           0x94    /* (Japanese keyboard)            */
#define DIK_STOP            0x95    /*                     (NEC PC98) */
#define DIK_AX              0x96    /*                     (Japan AX) */
#define DIK_UNLABELED       0x97    /*                        (J3100) */
#define DIK_NUMPADENTER     0x9C    /* Enter on numeric keypad */
#define DIK_RCONTROL        0x9D
#define DIK_NUMPADCOMMA     0xB3    /* , on numeric keypad (NEC PC98) */
#define DIK_DIVIDE          0xB5    /* / on numeric keypad */
#define DIK_SYSRQ           0xB7
#define DIK_RMENU           0xB8    /* right Alt */
#define DIK_PAUSE           0xC5    /* Pause */
#define DIK_HOME            0xC7    /* Home on arrow keypad */
#define DIK_UP              0xC8    /* UpArrow on arrow keypad */
#define DIK_PRIOR           0xC9    /* PgUp on arrow keypad */
#define DIK_LEFT            0xCB    /* LeftArrow on arrow keypad */
#define DIK_RIGHT           0xCD    /* RightArrow on arrow keypad */
#define DIK_END             0xCF    /* End on arrow keypad */
#define DIK_DOWN            0xD0    /* DownArrow on arrow keypad */
#define DIK_NEXT            0xD1    /* PgDn on arrow keypad */
#define DIK_INSERT          0xD2    /* Insert on arrow keypad */
#define DIK_DELETE          0xD3    /* Delete on arrow keypad */
#define DIK_LWIN            0xDB    /* Left Windows key */
#define DIK_RWIN            0xDC    /* Right Windows key */
#define DIK_APPS            0xDD    /* AppMenu key */
#define DIK_POWER           0xDE
#define DIK_SLEEP           0xDF

#define DIK_BACKSPACE       DIK_BACK            /* backspace */
#define DIK_NUMPADSTAR      DIK_MULTIPLY        /* * on numeric keypad */
#define DIK_LALT            DIK_LMENU           /* left Alt */
#define DIK_CAPSLOCK        DIK_CAPITAL         /* CapsLock */
#define DIK_NUMPADMINUS     DIK_SUBTRACT        /* - on numeric keypad */
#define DIK_NUMPADPLUS      DIK_ADD             /* + on numeric keypad */
#define DIK_NUMPADPERIOD    DIK_DECIMAL         /* . on numeric keypad */
#define DIK_NUMPADSLASH     DIK_DIVIDE          /* / on numeric keypad */
#define DIK_RALT            DIK_RMENU           /* right Alt */
#define DIK_UPARROW         DIK_UP              /* UpArrow on arrow keypad */
#define DIK_PGUP            DIK_PRIOR           /* PgUp on arrow keypad */
#define DIK_LEFTARROW       DIK_LEFT            /* LeftArrow on arrow keypad */
#define DIK_RIGHTARROW      DIK_RIGHT           /* RightArrow on arrow keypad */
#define DIK_DOWNARROW       DIK_DOWN            /* DownArrow on arrow keypad */
#define DIK_PGDN            DIK_NEXT            /* PgDn on arrow keypad */
