New Cross-Platform Game: Deepspace

Other misc things
Post Reply
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

New Cross-Platform Game: Deepspace

Post by RobertK »

Here is a new cross-platform game I have written:

https://sourceforge.net/projects/deepspace-rk/

It is "Deepspace", a remake of a BASIC type-in game that I played in the 1980s on a friend's Atari 800XL.

Deepspace_MSX.jpg

It is a simple action game: your spaceship is trapped inside a force field, try to reach the fuel station before you run out of fuel, but avoid the deadly rocks.

Currently, 13 target systems are supported. The game requires the target system to support highres graphics, monochrome sprites and virtual joystick support via games.h, 1-Bit sound is optional.

I assume that there is no way to play 1-Bit sound asynchronously, so that it does not pause sprite movement? Would this be possible using PSG sound?

I have encountered some issues on a few targets that I will soon report here. In the Source\WIP directory are the compile batch files for those targets that I haven't got running yet.

@Dom: the CPC and Bondwell 12/14 joystick issue is still there, you can reproduce it with this game.

Another issue is that joystick() support seems to be dead in this game on a few targets, e.g. joystick(1) & MOVE_DOWN always stays 0. Strangely, my joytest.c is fully working on these targets. So there must be some interference with other stuff that I'm using, maybe monochrome sprites? The targets affected are:
Genius Leader 6000SL
Hanimex Pencil 2
Laser 500
MyVision
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

@Dom: the CPC and Bondwell 12/14 joystick issue is still there, you can reproduce it with this game.
I disabled the CPC keyboard joystick a little back. However, I think I've got to the bottom of this problem and it's just a bit of an artefact of the way the joystick works on CP/M and a lack of auto-repeat on the Bondwell 12/14

When we read the joystick on CP/M we consume a character from the keyboard buffer and on a machine without auto-repeat no matter how long the key is pressed, only one event is generated.

So, for a single joystick is vital that we only call joystick() once per "game loop", if it's called in this fashion:

Code: Select all

if (joystick(1) & MOVE_LEFT) { 
} else if (joystick(1) & MOVE_RIGHT) {
}
Then the keypress is consumed by the first joystick() call and no others will report, so do this instead:

Code: Select all

int v = joystick(1);
if (v & MOVE_LEFT) { 
} else if (v & MOVE_RIGHT) {
}
What this means is that two joysticks can't be used on machines with no autorepeat such as the Bondwell.
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

Re: New Cross-Platform Game: Deepspace

Post by RobertK »

dom wrote: Fri Jan 07, 2022 10:03 pmso do this instead:
Thanks, that has solved the problem!

In the game loop after calling joystick() I'm doing...

Code: Select all

if(kbhit())
{
   c = getch();
   ...
...to poll the X and U keys (for exit and pause), but they hardly react on the Bondwell 12/14, probably due to the same reason? Is there also a simple workaround for that?
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

RobertK wrote: Sat Jan 08, 2022 10:38 pm...to poll the X and U keys (for exit and pause), but they hardly react on the Bondwell 12/14, probably due to the same reason? Is there also a simple workaround for that?
Yes, it will be the same problem. The only "simple" workaround would be to implement the joystick() yourself and passing in the keypress yourself and then re-using the keypress for the extra key detection.
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

RobertK wrote: Fri Jan 07, 2022 9:00 am Another issue is that joystick() support seems to be dead in this game on a few targets, e.g. joystick(1) & MOVE_DOWN always stays 0. Strangely, my joytest.c is fully working on these targets. So there must be some interference with other stuff that I'm using, maybe monochrome sprites? The targets affected are:
Genius Leader 6000SL
Hanimex Pencil 2
Laser 500
MyVision
I think I've fixed gl6000, pencil2, laser500, still to investigate my vision unfortunately.
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

dom wrote: Sun Jan 09, 2022 12:31 amI think I've fixed gl6000, pencil2, laser500, still to investigate my vision unfortunately.
Myvision has been fixed in time for the nightly.
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

Re: New Cross-Platform Game: Deepspace

Post by RobertK »

Thanks, that will be a bunch of new targets for my game!

All ok now are:
- Laser 500
- My Vision
- RX78
- Bondwell 2
- PC-8801

Ok with issues / questions:
- PC-6001 MK2: can the keyboard click sound be deactivated somehow?
- Pencil 2: QAOP-NM works, but Cursor input is not working in MAME (I have tried different keyboard mappings). I have noticed that it does not work in Mastermind RK either, last time compiled on 20 Jan 2020.

Still not working:
- Genius Leader 6000SL: still no joystick() input reaction
dom wrote: Sun Jan 09, 2022 12:02 am Yes, it will be the same problem. The only "simple" workaround would be to implement the joystick() yourself and passing in the keypress yourself and then re-using the keypress for the extra key detection.
Ok, I think I will simply use the second fire button for Exit on these targets.
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

I think I've now fixed pencil2 and gl6000sl is also working and had a bit of speed up.

PC-6001 is another Microsoft BASIC, so there will be a variable somewhere, as soon as we can find it I'll treat it the same as the MSX and SVI.
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

Re: New Cross-Platform Game: Deepspace

Post by RobertK »

Thanks, I will try these tomorrow.

For tonight I have updated the game package on Sourceforge. New targets supported:
Bandai RX-78
Bondwell 12/14
Bondwell 2
NEC PC-6001 mkII
NEC PC-8001
Nichibutsu My Vision
VTech Laser 500 / 700

BTW, i think that __HAVE_ONEBITSOUND on __BONDWELL__ is still not defined, I still have to use a workaround to activate sound.
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

Re: New Cross-Platform Game: Deepspace

Post by RobertK »

Pencil2 is fine now, Cursor control is now working, thanks.

GL6000SL: still no change, joystick input does not work in my game. I have tried it using MAME 0.228 and the latest 0.239.

Now for some other problematic targets:

Colecovision: the compiled Deepspace ROM only produces a black screen in the Takeda Coleco emulator. However, grtest.c works without any problem.

VZ200 and EG2000: they are basically working, but their medium resolution requires the 4x6 font. So I will have to uncomment this...

Code: Select all

#if defined(__FOUR_BY_SIX_CHARACTERS__)
//	#include <graphics.h>
#endif
...and this...

Code: Select all

void myGotoXY(int x, int y)
{
	...
	#elif defined(__FOUR_BY_SIX_CHARACTERS__)
	/*
		x_4x6 = x*4;
		y_4x6 = y*6;
	*/
	...
}
... but as soon as I include graphics.h, the program crashes when the game starts.
A test program similar to grtest.c using 4x6 characters works without any problem. I am using VZEm and Genieous for testing.
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

RobertK wrote: Mon Jan 10, 2022 8:42 amGL6000SL: still no change, joystick input does not work in my game. I have tried it using MAME 0.228 and the latest 0.239.
I've just downloaded the latest nightly and compiled - the joystick seems to work without problems - can you email through the ROM and .map file that you're creating and I'll see what's up.
Colecovision: the compiled Deepspace ROM only produces a black screen in the Takeda Coleco emulator. However, grtest.c works without any problem.
If you add the size of the BSS and DATA files produced you'll see they come to 1064 bytes: the Coleco has only got 1k of memory so all sorts of weird stuff is going to happen there! It looks like a fair chunk of RAM is taken up by the SMC code in putsprite, so I've done the following things:

1. Adjusted putsprite to reduce the RAM usage (wait for next nightly)
2. In Deepspace.c, change all printf() to printk() and use -pragma-define:CRT_ENABLE_STDIO=0
3. Made the sprite data "const" - which will keep it in ROM rather than copying to RAM

This then gives us a RAM usage of 768 bytes which leaves 256 bytes for the stack which seems to be enough at the moment. Doing 2 and 3 is valid for all targets BTW. There's a bit more space that can be saved since you're not using interrupts, but lets save that for later!
VZ200 and EG2000: they are basically working, but their medium resolution requires the 4x6 font. So I will have to uncomment this...
I've not had a chance to look at this one yet.
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

Re: New Cross-Platform Game: Deepspace

Post by RobertK »

The GL6000SL: after unsuccessful attemps with the MAME command line versions 0.216, 0.228 and 0.239 I have now tried it in MAMEUI64 0.228 - and there keyboard input works! So we can consider this an emulation issue. BTW, sound isn't emulated yet in MAME.

Having implemented your suggestions, Coleco and Bit90 are working now, thanks!
stefano
Well known member
Posts: 1704
Joined: Mon Jul 16, 2007 7:39 pm

Re: New Cross-Platform Game: Deepspace

Post by stefano »

I wonder if the INKEY$() implementation here could be helpful to improve joystick() on CP/M.
Probably not, but Bill and Paul were very accurate in interfacing to the CP/M, they even supported cp/m v1!

https://github.com/z88dk/techdocs/blob/ ... asm#L15853

FN_INKEY_0:
OR A ;SET NON-ZERO IF CHAR THERE
JP Z,NULRT ;NO, RETURN NULL STRING

; GET CHAR IF ONE,
;****SOME VERSIONS ALREADY HAVE CHAR AND DONT WANT THIS CODE ***
;****SO THEY SHOULD TURN ON CHSEAT TO TURN OFF READS

CALL INCHRI

(....)
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

RobertK wrote: Mon Jan 10, 2022 8:42 amVZ200 and EG2000: they are basically working, but their medium resolution requires the 4x6 font. So I will have to uncomment this...
Right, so this one is on you!

The fix is two fold:

1. Always include <graphics.h>
2. Remove your definitions for drawb/draw/plot/unplot/clg/getmaxx/getmaxy/etc (the first four are the most important)

The issue is the following bits:

graphics.h: #define draw(x1,y1,x2,y2) draw_callee(x1,y1,x2,y2)
deepspace.c: void draw(int x1, int y1, int x2, int y2)

Which means that your code calls draw_callee(), the callee function cleans up the parameters on the stack, but so does your code since the function isn't marked as callee (your prototype overrides I think) so the stack just ends up totally out of whack.
User avatar
dom
Well known member
Posts: 1559
Joined: Sun Jul 15, 2007 10:01 pm

Re: New Cross-Platform Game: Deepspace

Post by dom »

Oh, I should mention, you say the original had colour - if you use textcolor() then quite a lot of the targets will plot in the specified colour.
User avatar
RobertK
Well known member
Posts: 255
Joined: Mon Feb 26, 2018 12:58 pm

Re: New Cross-Platform Game: Deepspace

Post by RobertK »

dom wrote: Fri Jan 14, 2022 7:31 pm 2. Remove your definitions for drawb/draw/plot/unplot/clg/getmaxx/getmaxy/etc (the first four are the most important)
Fantastic research job, thanks! I have removed the prototype definitions, and the VZ200 and EG2000 versions are fully working now.
This once again proves that I don't know much about what I'm doing. :-)
dom wrote: Fri Jan 14, 2022 7:43 pm Oh, I should mention, you say the original had colour - if you use textcolor() then quite a lot of the targets will plot in the specified colour.
I knew that this works with graphics primitives, but I didn't expect it to work with sprites - thanks once more.

First tests look promising, although this requires more precise sprite positioning, e.g. the white ship sometimes overlaps with the white border, which is no problem when XOR-moving it, but a white ship over a blue border will change the colour of the latter.
Post Reply