Batch file games
Posted: July 19th, 2011, 3:32 am
It's hard to compile a program that will stay compatible over time. Windows programs don't work in DOS, DOS programs no longer work in Windows, and nothing runs OS/2 programs any more. It seemed to me that an ideal solution would be to simply write batch file software. Batch files are supported by DOS, OS/2 and Windows, and since it's just a text file, there's no issues of 16/32/64-bit incompatibility.
So, I created a batch file text adventure. There are currently only 8 rooms and 3 objects. In theory, it should run under DOS 6.x, OS/2, Windows 95/98/ME/2000/2003/2008/XP/Vista/7, but not Windows NT 4.
The game checks what OS you're running. If it's DOS, OS/2, or Win9x, it runs the game in "simple mode", which only allows single-character commands, and doesn't keep score (not a big deal).
If it's Windows NT or newer, it takes advantage of NT's ability to perform math (score), accept user input (descriptive commands), and change the text and background colors.
It won't work under Windows NT 4 because I also took advantage of Windows 2000's EnableDelayedExpansion function to allow me to use a loop for getting, using and dropping objects, which would otherwise require duplication of code for every object in the game. Windows NT 4 users can't fall back to simple mode because NT doesn't include CHOICE by default. Duplication of code is necessary in simple mode (looping through each object in the get, use and drop commands would be pointless because DOS only allows one command to be executed in each iteration of the loop), so I guess it wouldn't be such a big deal to have it in the enhanced version as well in order to maintain compatibility with Windows NT 4. The game is very easily expandable, and if anyone ever put 20+ objects in it, that would be a lot of duplicated code. If it only has to be duplicated in one mode out of two, maybe it's worth it.
I have successfully tested the game under Windows 95, Windows XP, Windows 7, DOSBox and jDosbox. I tried to run it under OS/2 Warp 4.5, but any batch file I create in OS/2 (even Hello World) crashes the OS under Virtual PC 2007. The DOSBoxes also don't properly move to a new line after a response to CHOICE is received, but it's completely playable.
Note: This game probably will not work under a DOS boot disk because it requires CHOICE; use a full installation of DOS or add CHOICE.(com/exe) to your boot disk.
Anyway, feel free to test it out and mess with it. It's not thoroughly documented, but it shouldn't be hard to add new rooms, objects, and bonuses. Just remember to set the bonus variable to 0 after the bonus has been collected, otherwise the player can drop and pick up the same item for an infinite number of points. Also remember that DOS only looks at the first 8 characters of a label, so the first 8 characters of every label must be unique to maintain compatibility with DOS and Win9x.
So, I created a batch file text adventure. There are currently only 8 rooms and 3 objects. In theory, it should run under DOS 6.x, OS/2, Windows 95/98/ME/2000/2003/2008/XP/Vista/7, but not Windows NT 4.
The game checks what OS you're running. If it's DOS, OS/2, or Win9x, it runs the game in "simple mode", which only allows single-character commands, and doesn't keep score (not a big deal).
If it's Windows NT or newer, it takes advantage of NT's ability to perform math (score), accept user input (descriptive commands), and change the text and background colors.
It won't work under Windows NT 4 because I also took advantage of Windows 2000's EnableDelayedExpansion function to allow me to use a loop for getting, using and dropping objects, which would otherwise require duplication of code for every object in the game. Windows NT 4 users can't fall back to simple mode because NT doesn't include CHOICE by default. Duplication of code is necessary in simple mode (looping through each object in the get, use and drop commands would be pointless because DOS only allows one command to be executed in each iteration of the loop), so I guess it wouldn't be such a big deal to have it in the enhanced version as well in order to maintain compatibility with Windows NT 4. The game is very easily expandable, and if anyone ever put 20+ objects in it, that would be a lot of duplicated code. If it only has to be duplicated in one mode out of two, maybe it's worth it.
I have successfully tested the game under Windows 95, Windows XP, Windows 7, DOSBox and jDosbox. I tried to run it under OS/2 Warp 4.5, but any batch file I create in OS/2 (even Hello World) crashes the OS under Virtual PC 2007. The DOSBoxes also don't properly move to a new line after a response to CHOICE is received, but it's completely playable.
Note: This game probably will not work under a DOS boot disk because it requires CHOICE; use a full installation of DOS or add CHOICE.(com/exe) to your boot disk.
Anyway, feel free to test it out and mess with it. It's not thoroughly documented, but it shouldn't be hard to add new rooms, objects, and bonuses. Just remember to set the bonus variable to 0 after the bonus has been collected, otherwise the player can drop and pick up the same item for an infinite number of points. Also remember that DOS only looks at the first 8 characters of a label, so the first 8 characters of every label must be unique to maintain compatibility with DOS and Win9x.