freecomputers · @thezerobit
485 followers · 1132 posts · Server anticapitalist.party

Here is the repository for my little Turbo Prolog project: bitbucket.org/thezerobit/space
It requires Turbo C 2.01 and Turbo Prolog 2.0 to build. It doesn't do much and it crashes after a couple minutes. Use the arrows and the left CTRL key to "play"

#turboprolog #prolog

Last updated 2 years ago

freecomputers · @thezerobit
485 followers · 1120 posts · Server anticapitalist.party

I wrote a small "space shooter"-like prototype game (doesn't do much) using Turbo Prolog. The ship and bullets are just crosses because I only implemented vertical and horizontal line drawing. Here's what I learned:

1. Turbo Prolog is slow at pushing pixels. You can do it with membyte/2, but TP doesn't appear to compile highly optimized loops, so this is a no-go. Best bet is to write tight render loops or blitting routines in C/ASM/Pascal.

#prolog #turboprolog

Last updated 2 years ago

Norobiik · @Norobiik
27 followers · 343 posts · Server noc.social

@thezerobit Please do😁 I didn't realize there were any remaining acolytes of this ancient, dead non-standard prolog variant left! Would love to see your game & notes on your tricks & techniques in 🧠

#turboprolog

Last updated 2 years ago

freecomputers · @thezerobit
478 followers · 1113 posts · Server anticapitalist.party

As I work on writing a (toy) game in , I am compiling notes and developing recipes and best practices that are, for the most part, missing from the official guide books. After I'm done, I'll compile the info, edit it and probably publish as a text file or something. "Practical Turbo Prolog" or "Turbo Prolog: The Missing Manual" or something along those lines. It may be more or less focused on writing games, but most of the content will be generally applicable to all program types.

#turboprolog

Last updated 2 years ago

freecomputers · @thezerobit
468 followers · 1102 posts · Server anticapitalist.party

I found some BGI (Borland Graphics Interface) files from all the way back in 1991 that support mode 13h graphics (MCGA 320x200 256 color) as well as SVGA modes and some of those weird VGA modes some DOS games like Scorched Earth supported like 360x480 256 color.

discmaster.textfiles.com/view/

#turbobasic #turboprolog #turbopascal #retrocomputing #borland #bgi #turboc #retrodev #dos

Last updated 2 years ago

freecomputers · @thezerobit
467 followers · 1097 posts · Server anticapitalist.party

I managed to get my hands on the Turbo Prolog 2.0 *User's Guide*, which is the companion to the Reference Guide. As far as I can tell there are no PDFs or scans of any kind for the User's Guide on the internet. So, I guess I'll have to scan it myself on a rainy weekend.
Anyways, this book teaches (Turbo) Prolog from the first principles up through advanced techniques using example programs that come on the disks so you don't have to type the programs in to run them.

#turboprolog #prolog

Last updated 2 years ago

freecomputers · @thezerobit
456 followers · 1082 posts · Server anticapitalist.party

One of the benefits of writing software in is that it tends to encourage flatter structures. Something you might represent as nested loops and conditions in a procedural language, you would break into multiple predicates (analogous to functions), where you have a recursive predicate for each loop.

is also lacking the non-logical (if->then;else) construct from ISO Prolog, so a conditional statement would translate to a predicate, also.

#turboprolog #prolog

Last updated 2 years ago

freecomputers · @thezerobit
456 followers · 1082 posts · Server anticapitalist.party

@agathis_dkm
The bug doesn't manifest in the main module, or with regular (non-database) predicates, or with facts asserted at runtime. So, I guess if you need to preload your non-main module database predicates, you need to have some kind of initialization predicate that you call that asserts those facts when your program starts. So, you can workaround it. Now I really need to write a manual on when I'm done.

#turboprolog

Last updated 2 years ago

freecomputers · @thezerobit
442 followers · 1075 posts · Server anticapitalist.party

I spent about an hour debugging an issue with my Turbo Prolog code and I'm pretty sure it's a bug in the compiler. It's a global predicate and it succeeds properly when called from a different module but fails when called locally. I've added print (write) statements and it's called with the same arguments and it still fails inexplicably. I haven't given up yet, I'll start removing code until I get a minimal reproduction of the issue.

#turboprolog #prolog

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

After learning more than I wanted to about Turbo C (IDE and command line tools), .OBJ and .LIB files, memory models, linking etc in , I have been able to add a keyboard interrupt handler in C that I can use from my programs for game-appropriate low level access to key-down and key-up events.
Now, I've got enough to write a little space shooter, to show off smooth, arcade-style DOS gaming with , because I'm weird that way.

#prolog #turboprolog #dos

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

@Jose_A_Alonso
I'm currently testing the hypothesis that a Prolog compiler that generates reasonably efficient code (Turbo Prolog, which is mentioned briefly in that paper) can be used to create arcade-style action games that run even on 30-40 year old PCs running DOS (that the compiler targets).

#turboprolog

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

I swear to gods, I will write my own 400 page manual on <Game Programming>. I spent too long battling the linker only to discover that a piece of advice from the official Turbo Prolog Reference Guide on how to configure Turbo C when building a library to call from Prolog made it impossible to link with the standard C library. If you change the name mangling, then the object file you generate will link with the *wrong* names for standard lib functions.

#turboprolog

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

The next challenge with writing an arcade style game for with is handling keyboard input in a way that is appropriate for games. You can't get key up (release) events in DOS without installing a keyboard interrupt handler. TP has no direct support for writing interrupt handlers. You can allow external code to call TP predicates, but they have a certain calling convention that I highly doubt is compatible with interrupt handler calls.

#turboprolog #dos

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

Some handy predicates for doing mode 13h graphics in Turbo Prolog:

(enable mode 13h graphics)
mode_13h :- bios($10,reg($13,0,0,0,0,0,0,0),_).

(back to text mode)
text_mode :- bios($10,reg($3,0,0,0,0,0,0,0),_).

(plot or read a pixel)
pixel(X,Y,Val) :- P=X+(320*Y),membyte($A000,P,Val).

repeat.
repeat :- repeat.

(wait for vsync)
vsync :- repeat,port_byte($3DA,S),bitand(S,8,S1),S1=0,!,
repeat,port_byte($3DA,S2),bitand(S2,8,S3),S>0,!.

#dos #turboprolog #prolog

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

I don't know if anyone cares, but I found the Turbo Prolog predicates "membyte" and "memword" which can read or write bytes or 16 bit words to physical memory. Between these and the "bios" (BIOS interrupt) predicate I should be able to initialize mode 13h graphics and write pixel values directly to the $A000 segment. So, I should be able to do DOS graphics in pure Turbo Prolog, no linking C code, no slow BGI calls.

#dos #turboprolog #prolog

Last updated 2 years ago

freecomputers · @thezerobit
417 followers · 1047 posts · Server anticapitalist.party

Look what came in the mail today!

#dos #turboprolog #prolog

Last updated 2 years ago