Hi,
As I have
"Finally! building a cabinet from scratch", I also wanted to build a front end (FE) from scratch. Why you may ask. Well, because it's fun too!

And I could control everything I wanted.
I'll agree immediately that there are plenty FE's out there that are very feature rich, but I also could have just bought a complete cabinet or a complete package with cutted sides, front etc.
In what language then? In the past I've programmed in BBC Basic, Turbo Pascal, Delphi, C++. I could get my hands on Visual Basic 6.0, so I began with that. I know how to program, but in Visual Basic in haven't done anything before. It was quiet a challenge.
Where to begin? I looked at some screenschots from other FE's. Studied the features and decided what I first wanna to do...
1. It should have a list somehow to select a game.
2. An in game picture has to be shown for the highlighted game.
3. I wanted to have some game information (year, manufacturer, etc.) shown on screen.
4. Many things should be configured through a .ini file.
Plus what ever I could think that should be in my FE.
Keyboard input (added 1-APR-2007)
The first thing I was concerned about was how should I read the keyboard? In VB6.0 it's completely different then in a procedural language. I knew about "ReadKey" in Turbo Pascal and "Inkey" in BBC basic, but VB handles events. Every control on a form can generate events. When a control has the focus it can react on key presses. I read about "key hooks", but that sounded to complicated for me now. Then I searched with Google and I found the answer for my problems in the form property "key preview". When that is set to "true", then when a key is pressed it is first send to the keydown/up event of the form. This also solved future focus problems with controls.
Graphics on screen (added 1-APR-2007)
How can I put some decent graphics on the screen? DirectX? To complex to start with. I use only one black, full screen form. I place controls on that form and change visibility, positions, colour etc. at runtime. Works great. For the graphics I'd caputured the whole screen when the game list and everything was on it. Then I loaded this in Adobe Illustrator. I placed the graphic elements I wanted on the position I wanted. After that I did some after effects to make it look more
attractive. In the FE it self I used a image control that I blow up to full screen and then the background picture is loaded
in this image. And voila! there is your nice looking screen with what ever graphics you want on them.
Screenshot from Yaff. Just selected Jurassic Park, because of the colour combination.
Example picture (added 2-APR-2007)
This was something that had to be included. There was/is one difficulty. Standard VB6.0 does not support the .png format, only .jpg. I don't have a solution to that right now, but maybe someone has done this and want to share this with me. For now, I just converted al files to .jpg. With Adobe Photoshop this was easy done.
I use the "script processor" to convert everything to 640x512 (no, 1942 is not strechted!). As I use a resolution of 1280x1024 in my cabinet, this is a nice format.
Yaff now only supports one picture. As you walk through the list of games Yaff looks for a picture with the <romname>.jpg if it exists, it is displayed otherwise a "now picture available" picture is displayed. This picture can be named (through .ini file) and adjusted as you please.
Control settings (added 1-APR-2007)
Al the controls (elements on the form) are set to transparent (property "BackStyle = Transparent"). That makes life easier, because when controls overlapping you don't notice this. The font for the text is set to "Snap ITC". The coordinates don't matter, because they are changed at runtime.
Game selection list (added 1-APR-2007)
I was experimenting with a "poplist", but I had trouble with the key presses. When an "B" is pressed the list jumps to the entry that begins with that letter. Such a list is not flexible. Finally I used "labels" in a "control array" to implement the list. I use 13 labels, because then I'll can divide it equally above and under the selection bar.
The selection bar I wanted to be stuck in the middle, until in reaches the end of the list. Then the bar walks down and when it reaches the end it wraps around to the first game. Then it goes down again. When it reaches the middle it stays there and the whole list scrolls through. I noticed later that in other FE's the list it self goes down, not the bar. Well, I didn't mind and kept it that way. It worked and it works great!
Menu (added 1-APR-2007)
I wanted to have a menu in it. Here you could choose a favourite list or strip the brackets from the game name etc. For this I used two rounded filled rectangles. For the options I made two control arrays, one for the option names and one for the option choices. The coordinates of the controls are used to place the selectionbar. When I advance through the menu I also advance a counter (0..#option names) the counter stands for the position of the option name in the control array. The same method is used for the option choices.
The menu is completely build at design time. At runtime the menu can be switched on (make all controls visible) or switched of (make all controls invisible). I wondered if I should save the background just before the menu is placed over other things, but that's not necessary, because all graphics are persistant.
mame.xml, controls.dat and catver.ini (added 2-APR-2007)
To show info from the mame.xml, controls.dat and catver.ini files I needed to read those files and combine them. In every file is some info I wanted. The year, manufacturer and full description of the game is held in mame.xml. controls.dat has some additional info about the game (MiscDetails) and in catver.ini I wanted to use the catagory info.
mame.xmlThe biggest problem was the mame.xml file. It's large and it's XML. For some reason I could not find the XML library and use it in my program. Since I was building everything myself, I thought then I'll also write a XML parser. A dedicated one. I wasn't concerned about syntax, because the file is generated from MAME itself. When writing this I thought it would take quiet some time to read and parse everything. So, I just wrote a piece of code to just read the whole file. That took only a few seconds, great!
My first try was just to read every line character by character, build up a tag when a "<" was found and stop when a ">" was found. Just plain simple. This whole proces took around one minute, yep to slow. I added some code to see if a line was interesting or not. If not, read the next line and othewise parse it. The time needed now was around 5-6 seconds! (PIV dual core 3.0Ghz, not in my cabinet

) That's more acceptable.
I adjusted the code to use the "instr" function, rather then read character by character. My guess was that I could speed things up more, but the result is not that drastic as I thought. I haven't really compared the figures though.
I wonder what time it would take when you use the built-ins from VB XML library.
Controls.datOk, that was my biggest concern. Next was controls.dat and catver.ini. These files are straight forward and no real parseing is needed. Just read a line cut out the property and value and store it in an array. When a line with the game name is read, then advance the counter of the array slot to the next.
catver.iniThe catver.ini file was theated the same as the controls.dat. Also, no problem with this one.
MergingNow al files could be handled, I needed to merge/join these files. I asked a question about this earlier, actually if there was such a combined file, but Howard_casto found it a "dumb idea", because joining is done on the fly. Well, that sounded not to bad. I wrote a little code to join al arrays into one. I wrote two lookup functions for every array. As the rom name is in all arrays, I used that as the key and then give back the position so I could get the info and store it in the final one. No hassle with this, quiet simple.
.ini file (added 2-APR-2007)
A .ini file was also a thing that had to be included. Whithout this, it would be impossible to configure anything. As the project progressed I added parameters. For this I wrote a piece of code to just read the yaff.ini file until a particular parameter is found. The parameter goes befor the "=" sign. Everything after it is the value. This is assigned to a variable in the program. It is "just" assigned, meaning that I don't really make a difference between strings or numbers, so there is a bit of implicit conversion going on. When a parameter can't be found, a warning is writen to the yaff.log file.
yaff.log (added 2-APR-2007)
To be able and track some underneath behaviour and/or errors I made a little procedure to write to the yaff.log. It are just three lines of code. Open the file for append, write a line and close it again. A line is in the form of:
<date> <time> : <message>2-4-2007 20:32:44 : Yaff version (0.1b) is started.
2-4-2007 20:32:44 : Begin reading D:\Arcade\Yaff\yaff.ini file.
2-4-2007 20:32:44 : Reading D:\Arcade\Yaff\yaff.ini file finished.
2-4-2007 20:32:44 : Begin reading roms from D:\Arcade\Mame0107b\Roms\.
2-4-2007 20:32:44 : ...225 roms read.
2-4-2007 20:32:44 : Reading roms finished.
2-4-2007 20:32:44 : Begin reading D:\Arcade\Yaff\catver.ini file.
2-4-2007 20:32:44 : ...5772 lines read.
2-4-2007 20:32:44 : Reading D:\Arcade\Yaff\catver.ini file finished.
2-4-2007 20:32:44 : Begin reading and parsing mame.xml file.
2-4-2007 20:32:49 : ...453605 lines read and 37115 lines parsed.
2-4-2007 20:32:49 : Reading and parsing finished.
2-4-2007 20:32:49 : Begin reading D:\Arcade\Yaff\controls.ini file.
2-4-2007 20:32:49 : ...18229 lines read.
2-4-2007 20:32:49 : Reading D:\Arcade\Yaff\controls.ini file finished.
2-4-2007 20:32:49 : Begin joining mame.xml, catver.ini and controls.dat.
2-4-2007 20:32:50 : Joning finished.
2-4-2007 20:32:53 : Yaff has been Shutdown.This file includes what is going on at a particular moment, like what file is read, how many lines are read and parsed, etc. Maybe I'll include a loglevel that indicates how detailed things are logged.
Shutting down (added 6-APR-2007)I want my computer to shutdown after I have closed down my front end. I first thought that I had to use an external program or some special system call to do this. I found out that I could just use "shutdown" from windows. So, all I do when the front end stops is:
Shell "shutdown -s -f -t 00", vbHideThe behaviour can be controlled with a .ini parameter I called "shutdown_computer_when_yaff_closes" when this is set to "Yes", the computer will completely shutdown, otherwise you will be thrown back to Windows desktop.