Batch file games

Discuss coding, porting and creating games
Post Reply
User avatar
DOSGuy
Website Administrator
Posts: 1063
Joined: September 2nd, 2005, 8:28 pm
Contact:

Batch file games

Post by DOSGuy »

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.
You do not have the required permissions to view the files attached to this post.
Today entirely the maniac there is no excuse with the article.
Malvineous
8-bit mega nerd
Posts: 293
Joined: March 17th, 2007, 6:40 pm
Location: Brisbane, Australia
Contact:

Re: Batch file games

Post by Malvineous »

Wow interesting idea. Many years ago my father came up with a similar type of idea for a password program that ran entirely as DOS batch files. It would start by using ANSI codes to remap most keys on the keyboard so that any key that could type a DOS command would behave the same as the enter key, making it impossible to type in any DOS commands in full. If the password was 'hello', there would be a file called "hello.bat" which would reset all the keys back to normal. The idea being that 'hello' was then the only word you could type in full - if you tried to type 'dir' you'd actually be typing three enter keys and thus be unable to run the command.

Since you have a dependency on the CHOICE command, I just thought I'd mention this as a way of avoiding that - by having each command as a separate .bat file. You could then have move.bat and examine %1 to allow commands like "move north".
blinkingboythe
5-bit member
Posts: 36
Joined: August 13th, 2013, 1:09 am

Re: Batch file games

Post by blinkingboythe »

DOSGuy wrote: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.

Very interesting idea. I started writing a batch adventure game back in 2002 that I just re-discovered recently. It has only one object so far and it's not finished, but it should be interesting to look through.
All features work in plain dos, including the counter, and load/save functions.
You do not have the required permissions to view the files attached to this post.
blinkingboythe
5-bit member
Posts: 36
Joined: August 13th, 2013, 1:09 am

Re: Batch file games

Post by blinkingboythe »

blinkingboythe wrote:
Very interesting idea. I started writing a batch adventure game back in 2002 that I just re-discovered recently. It has only one object so far and it's not finished, but it should be interesting to look through.
All features work in plain dos, including the counter, and load/save functions.

Here is a better version with more rooms and the ability to save inventory using the loaditem/
saveitem command. I decided to have this separate from the main save for debugging purposes.
I also got rid of the extra log files it generated.
You do not have the required permissions to view the files attached to this post.
Post Reply