Designing the Battle System Test

I've been working on the basic design of a test game. I decided to use the first battle of Final Fantasy VII as a starting point, seeing as others have reverse engineered the battle system from that game, and so all I need to do is implement the formulas from that game in BASIC. However, I want this test to run on as many different versions of BASIC as possible, and so there are some limitations that will make the implementation... annoying.
I'm writing the test for Altair 8800 4K BASIC, at least initially. Altair 4K BASIC has some limitations in comparison with later versions, but it's not the most limiting version of BASIC. The most limiting version, by far, is TRS-80 Level 1 BASIC. That only allows you to use 26 numerical variables, and one single-dimensional array for data storage. My first task, before anything else, was to figure out how to store the stats for the player and enemies in a single-dimensional array.

This is what I came up with (apologies if the formatting is off):

      0             1            2              3        4    5       6    7        8        9      10    11   12
Cur. HP Max. HP Cur. MP Max MP Att At% Def Df% MAt MDef Dex Luck Lvl

The player uses elements 0-12 of the array, the first enemy starts at 13, and the second enemy starts at 26. It's rather easy to select the appropriate element - you multiply 13 by an index number - so the player's data is 0*13, the first enemy is 1*13, and the second enemy is 2*13. Then, all I need to do is add the element number of the stat I want to that, and I can get whatever stat I want. Note that this would be somewhat easier if I could use a multi-dimensional array.

Next, formulas. Formulas in BASIC are written in algebraic notation. Usually with lots of parentheses. I decided to convert all the formulas first, as it's really easy to mess up the parentheses. For instance, a formula like this:

Hit% = ([Attacker's Dex / 4] + At%) + Attacker's Df% - Target's Df%

Will turn into this when implemented in BASIC (here I'm using indexing with the array, so there's even more parentheses):

H=((A(A*13+10)/4)+(A(A*13+5)))+A(A*13+7)-A(T*13+7)

It's parentheses hell. I've already implemented all the formulas I'll need, and with one of them, I had to split it into multiple statements, as it would be too long to fit into a 72 character line otherwise.

After converting the formulas, I created a flowchart of what the test program would need to do. Flowcharts work really well for BASIC programs, as they don't have much in the way of function calls. You have to jump around your program. Here is a small version of the flowchart I'll be using to write this:





That should show the general complexity of even a fairly simple BASIC program. Of course, it doesn't help that the flow charting program I used kind of sucks.

I'm now ready to actually start programming this thing. I'll be programming it on an Altair 8800 emulator, because it's probably slightly more interesting to watch it that way, rather than writing it in a text editor like Notepad++, which is what you should use if you're trying to program anything of any reasonable complexity.

Comments

Popular posts from this blog

CoCo 3 NitrOS-9 Emulator VHD Install Disks

Overclocking the Raspberry Pi 4 for Fun and Games

Mac Emulator Videos