Game with conio.h for MSX

Post Reply
Fabrizio
Member
Posts: 115
Joined: Tue Jul 11, 2017 9:28 pm

Game with conio.h for MSX

Post by Fabrizio »

Hi

I am trying to compile my game
https://github.com/Fabrizio-Caruso/ASCII-CHASE
to as many Z80 platforms as possible.

The game uses pure ANSI C + conio.h. The code is probably OK because it works and compiles with no warnings under CC65.

I have so far managed to get it to compile and (sort of) work for the Spectrum target.

I am now trying to get it to compile and work for the MSX target.

zcc +msx -create-app -D_BUILDING_X -DAMALLOC -lmalloc -lndos -o %deliverables%\msx-alt.bin %mypath%\display_macros.c %mypath%\powerUps.c %mypath%\enemy.c %mypath%\invincible_enemy.c %mypath%\level.c %mypath%\character.c %mypath%\text.c %mypath%\missile.c %mypath%\strategy.c %mypath%\input.c %mypath%\main.c

compiles fine (with some wrong warnings as with +zx) and
it creates a .cas file that can be loaded in BlueMSX with bload"cas:",r

The game starts but the conio.h commands are interpreted wrongly. It looks like gotoxy is printing the coordinates instead of moving the cursor to the correct position.
As the game starts it exits to BASIC with a "Syntax error" message.

Fabrizio
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

The conio emulation code works by converting the borland functions into vt ansi sequences.
The msx port is close to the cpm logic, where the terminal type is a specific characteristic of the machine running the application.
Sometimes it is a vt52 or better, often if features different escape sequences.
In short it won't work on the msx, unless some kind of vt emulation is preloaded on it (I have no idea on this thing really existing).
A native vt emulation coulcc be implemented, good also for sc3000, mtx, etc... but it would cost extra memory.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I had a look at the existing sources, and I see two possible ways to get native ansi emulation on msx and family.
The text option, 40x25 mode can be achieved via msx_vpoke, or a slow and memory consuming graphics mode which would permit the same text resolutions we have on the Spectrum.
I'd go for the latter. Opinions?
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Post by Timmy »

Quote: "The text option, 40x25 mode can be achieved via msx_vpoke, or a slow and memory consuming graphics mode which would permit the same text resolutions we have on the Spectrum."

I'm currently making a game for MSX right now, so I'd say this:

1) the "msx_vpoke method" means you can quickly fill a screen with letters and other graphics. But it has 1 problem, every letter can only have one colour set, so you can have a yellow "C" then you can't have a red "C" (unless you redefine another character into the red "C".)

2) the second method is also great, it's basically the nirvana mode on the spectrum, i.e. 256x192 with 8x1 colour. It's a bit more memory consuming but the main problem is that it's at least twice as slow as the Spectrum in this mode.

For your information, the game I'm currently working on uses the first mode. I have fixed tiles with fixed colours, so my game loves this mode.

But, for an ansi-like library with letters in multiple colours, I'd suggest the second method.

A third option is to use some ansi drivers for MSX, or looking for some existing ANSI libraries. I don't know where to find them but I'd suggest asking on a forum.
Fabrizio
Member
Posts: 115
Joined: Tue Jul 11, 2017 9:28 pm

Post by Fabrizio »

Thanks!
Could you please provide a simple example? msx_vpoke can be ok for me. I do not need fancy graphics (for the moment).
I need:
(1) a function to write a given character at (x,y)
(2) a function to read the keyboard input without waiting.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Ex6.c in examples/msx redefines and prints the ampersand character in the center of the screen, wall.c deals with msx color attributes.

Now I also added the some native console support for msx in conio.h, it should be enough for gotoxy.
Fabrizio
Member
Posts: 115
Joined: Tue Jul 11, 2017 9:28 pm

Post by Fabrizio »

@stefano, which native directives?
The same as the ones in classic lib for the ZX Spectrum? or the ones used in new lib for the ZX Spectrum?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

MSX native, not similar to the spectrum ones. As said VPOKE is the core component.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Timmy could be happy, hopefully tonight the promised graphics variant is ready, totally compatible with the spectrum one.
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Post by Timmy »

Nice. :)

(Although I tend to write my own graphics routines (which are still not much beyond alpha quality yet.))

Incidentally, the game I mentioned earlier in this thread that I was working on, is now released at MSXdev:
http://www.msxdev.org/2017/09/22/msxdev ... adventure/

(It's also a pattern only game, i.e. 8x8 blocks, no sprites.)
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Wow, the graphics is so cute, that skeleton is pure genius !

To clarify: what I just provided is just a text engine in graphics mode, not extra graphics options.
There is a couple of board/adventure games which require more text columns to fit on the screen and, even if barely readable this baby is fully usable up to 80 columns (51 columns is my favorite options), or, depending on your needs, reduce the resolution to 28. Color codes are standardized (15 ansi colors) and, as asked by Fabrizio, support for conio.h is now faster and smaller (numeric conversion to pass parameters to console is not needed anymore).

For extra speed needs, we could compare the performances of the Dominic's tuning on the Spectrum in 32 columns mode and eventually replicate it on the MSX.

Last but not least, this new code is portable to Spectravideo, Sord M5, Memotech MTX, Einstein, Sega SC-3000 and possibly to other Sega targets.
Post Reply