StagesText2PDB converts (slightly edited) XKobo-style C-source text files into
PalmOS .pdb database files. The input file should contain one or more stages.

Usage:
java -jar StagesText2PDB <input filename> [<output filename>[.pdb]]

To prepare a C-source file for processing you need to
 - strip off everything up to and including the opening brace ('{') that
   encloses the entire 'scenes' array.
 - strip off everything after and including the opening brace that begins the
   final, dummy scene.
You should be left with a series of '_scene' structures, one for each stage. See
'XKobo stages.txt' for an example. This is a stripped-down version of the file
'scenes.cpp' from the Kobo Deluxe source code (which contains the original
XKobo stages).

StagesText2PDB scans through the text file one character at a time, following 
these steps.
 1. Find an opening brace. Ignore anything else you find on the way.
 
 2. Find a letter or digit character. If it's a letter, stop scanning - error.
    If it's a digit, convert it and any following digits into a number. If the
    first non-digit character encountered is a letter, stop scanning - error.
 3. Store the number in the hardTurretRatio field.
 4. Repeat step 2 and store the number in the startX field.
 5. Repeat step 2 and store the number in the startY field.
 6. Find a letter or digit character. If it's a digit, proceed as in step 2.
    If it's a letter, store it and any following characters until you find a
    comma, space or control-character, then match that string of characters
    against a table of pre-defined enemy names to get an enemy ID. If you can't
    find a matching enemy name, stop scanning - error.
 7. store the result from step 6 in the turretEnemyID field.
 8. Repeat step 2 and store the number in the turretInterval field.
 9. Repeat step 6 and store the result in the coreEnemyID field.
10. Repeat step 2 and store the number in the coreEnemyInterval field.

11. Repeat step 2 and store the number in the numEnemySets field.
12. Repeat step 1.
13. Do the following steps (14-18) for each enemy set. Skip to step 19 if
    numEnemySets is zero.
  14. Repeat step 1.
  15. Repeat step 6 and store the result in this set's enemyTypeID field.
  16. Repeat step 2 and store the number in this set's number field.
  17. Repeat step 2 and store the number in this set's speed field.
  18. Find a closing brace. Ignore anything else you find on the way.
19. Repeat step 18.

20. Repeat step 2 and store the number in the numBases field.
21. Repeat step 1.
22. Do the following steps (23-28) for each base. Skip to step 29 if
    numBases is zero (which it should never be).
  23. Repeat step 1.
  24. Repeat step 2 and store the number in this base's x field.
  25. Repeat step 2 and store the number in this base's y field.
  26. Repeat step 2 and store the number in this base's width field.
  27. Repeat step 2 and store the number in this base's height field.
  28. Repeat step 18.
29. Repeat step 18.

30. Repeat step 18.
31. Go back to step 1 for the next stage.

Note that even if numEnemySets or numBases is zero, an opening and closing brace
(with nothing of interest between them) must still appear in the input file to
represent the empty section.
While this program was written to convert C-source-style data structures, the
processing used does not require the various fields to be separated by commas -
any number of non-letter, non-digit characters will do, except that enemy names
must be 'terminated' (immediately followed) by a comma, a space, or a
control-character (such as Tab or an end-of-line character).
