Joystick.h Issues

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

Joystick.h Issues

Post by RobertK »

I did some testing with joystick.h input on various targets, here are my test results:

1. Bugs

Jupiter Ace: (1 - 1-5, 2 - 6-0, 3 - Cursor) The 6-0 set interferes with the cursor key set. Instead of 1-5 and 6-0,
QAOP-MN would be nice to have, like on the ZX81.

Mattel Aquarius: (1 - QAOP-MN, 2 - 8246-05) after selecting 1 (QAOP-MN) for Joystick #1 and 2 (8246-06) for Joystick #2,
Joystick #1 input always triggers input for both joysticks, while Joystick #2 input has no effect.

Philips P2000: reacts only to left direction input (1 = QAOP-MN, 2 = 8246-05)

Sega SC3000: does not react to any input (1 = QAOP-MN, 2 = 8246-05)

Sord M5: Fire (Space) does not work, the rest is ok (1 - Cursor Keys + Space; no other option)

SVI: cursor joystick reacts only to left direction input (1 - Cursor, 2 - Joystick 1, 3 - Joystick 2)

TRS-80 and
EG2000: reacts only to the O key (joystick 1 "left") (1 - QAOP-MN, 2 - 8246-05)


2. Nice-to-have additions

Bandai RX-78: all ok (Joystick 1 and 2), additional support for cursor keys would be nice to have

Laser 350 / 500: (UNTESTED) currently there is only one option (1 - Joystick 1). Cursor keys would
be nice to have, and if possible also QAOP-MN.

MC-1000: probably all ok (1 - Joystick 1, 2 - Joystick 2), Joystick 2 is still untested.
Additional QAOP-MN support would be nice to have.

Memotech MTX: all ok (1 - Joystick 1, 2 - Joystick 2). Additional support for cursor keys (1 5 3 .) would be nice to have.

Philips VG5000: all ok (1 - Joystick 1, 2 - Joystick 2), additional support for cursor keys would be nice to have

Z9001: all ok (1 - Joystick 1, 2 - Joystick 2), although there are slowdowns when the stick is held in one direction. Cursor key support would be nice to have.


3. All ok

Casio PV-1000: all ok (Joystick 1 and 2)

Casio PV-2000: all ok (1 - QAOP-MN, 2 - 8246-05)

Colecovison: all ok (Joystick 1 and 2)

Galaksija: all ok (1 - Arrows and Space, 2 - 5678-0)

Laser 210 / VZ200: all ok (1 = 1-5, 2 = 6-0, 3 = QAOP-MN)

Microbee: all ok (1 - Arrows and Space, 2 - Arrows + SPACE (256TC), 3 - Joystick on parallel port)

MSX: all ok (1 - Cursor, 2 - Joystick 1, 3 - Joystick 2)

Sharp MZ: all ok (1 - QAOP-MN, 2 - 8246-05)

Super-80: all ok (1 - QAOP-MN, 2 - 8246-05)

ZX80: all ok (1 - QAOP-MN, 2 - 8246-05)

ZX81: all ok (1 - Kempston, 2 - ZXPand, 3 - QAOP-MN, 4 - Cursor)

ZX Spectrum: all ok (1 - Kempston, 2 - Sinclair 1, 3 - Sinclair 2, 4 - Cursor, 5 - Fuller)


4. No joystick.h support yet:

Alphatronic PC,
Amstrad CPC
Camputers Lynx
Exidy Sorcerer
KC 85/2-5
Mitsubishi Multi-8
Nascom
NEC PC-6001 Mk2
Osborne 1
Samsung SPC-1000
Tatung Einstein
Tiki-100
Z1013

Maybe someone could have a look at the bugs, hopefully they are easy to fix.

Here is my little test program?

Code: Select all

/*
  joytest.c
  joystick test using games.h (based on snakes.c)
  Author: RobertK, 2018-12-18
  
  === Test results ===
  
  Bandai RX-78: all ok (Joystick 1 and 2), additional support for cursor keys would be nice to have
  
  Casio PV-1000: all ok (Joystick 1 and 2)
  
  Casio PV-2000: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  Colecovison: all ok (Joystick 1 and 2)
  
  TRS-80 and
  EG2000: reacts only to the O key (joystick 1 "left") (1 - QAOP-MN, 2 - 8246-05)

  Galaksija: all ok (1 - Arrows and Space, 2 - 5678-0)
  
  Jupiter Ace: (1 - 1-5, 2 - 6-0, 3 - Cursor) The 6-0 set interferes with the cursor key set. Instead of 1-5 and 6-0, 
  QAOP-MN would be nice to have, like on the ZX81.
  
  Laser 210 / VZ200: all ok (1 = 1-5, 2 = 6-0, 3 = QAOP-MN)

  Laser 350 / 500: (UNTESTED) currently there is only one option (1 - Joytick 1). Cursor keys would 
  be nice to have, and if possible also QAOP-MN.
  
  Mattel Aquarius: (1 - QAOP-MN, 2 - 8246-05) after selecting 1 (QAOP-MN) for Joystick #1 and 2 (8246-06) for Joystick #2, 
  Joystick #1 input always triggers input for both joysticks, while Joystick #2 input has no effect.
  
  MC-1000: probably all ok (1 - Joystick 1, 2 - Joystick 2), Joystick 2 is still untested. 
  Additional QAOP-MN support would be nice to have.

  Memotech MTX: all ok (1 - Joystick 1, 2 - Joystick 2). Additional support for cursor keys (1 5 3 .) would be nice to have.

  Microbee: all ok (1 - Arrows and Space, 2 - Arrows + SPACE (256TC), 3 - Joystick on parallel port)

  MSX: all ok (1 - Cursor, 2 - Joystick 1, 3 - Joystick 2)
  
  Philips P2000: reacts only to left direction input (1 = QAOP-MN, 2 = 8246-05)

  Philips VG5000: all ok (1 - Joystick 1, 2 - Joystick 2), additional support for cursor keys would be nice to have
  
  Sega SC3000: does not react to any input (1 = QAOP-MN, 2 = 8246-05)
  
  Sharp MZ: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  Sord M5: Fire (Space) does not work, the rest is ok (1 - Cursor Keys + Space; no other option)
  
  Super-80: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  SVI: cursor joystick reacts only to left direction input (1 - Cursor, 2 - Joystick 1, 3 - Joystick 2)
    
  Z9001: all ok (1 - Joystick 1, 2 - Joystick 2), although there are slowdowns when the stick is held in one direction. Cursor key support would be nice to have.
  
  ZX80: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  ZX81: all ok (1 - Kempston, 2 - ZXPand, 3 - QAOP-MN, 4 - Cursor)

  ZX Spectrum: all ok (1 - Kempston, 2 - Sinclair 1, 3 - Sinclair 2, 4 - Cursor, 5 - Fuller)

  Alphatronic PC, 
  Amstrad CPC, 
  Camputers Lynx, 
  Exidy Sorcerer, 
  KC 85/2-5,
  Mitsubishi Multi-8,
  Nascom, 
  NEC PC-6001 Mk2,
  Osborne 1,
  Samsung SPC-1000,
  Tatung Einstein, 
  Tiki-100,
  Z1013:
  '_joystick_type' not defined, etc.
          
*/ 

// zcc +zx81 -create-app -startup=2 -o joytest2_ZX81 joytest2.c

// zcc +ace -vn -create-app joytest2.c -o jt2.bin
// load the game on the Jupiter Ace by typing
// 0 0 bload jt.bin

#include <stdio.h>
#include <games.h>
  
void main(void) {
        int joyType1;
        int joyType2;
        int x;
        char joyTextLeft[7];
        char joyTextRight[7];
          
        printf("%c",12);                                         // clear the screen          
        #if defined(__ZX80__)
                gen_tv_field_init(0);        // has to be called once for screen-refreshing on the ZX80
        #endif
        printf("*** joystick test ***");

        /*
        int XSize,YSize;
        screensize(&XSize, &YSize);  
        printf("\n\nxsize=%d, ysize=%d", XSize, YSize);
    */
  
        // On consoles we don't have a keyboard so we have to preset the joystick selection
        #if defined(__PV1000__)
                joyType1=0;
                joyType2=1;
        #elif defined(__COLECO__)
                joyType1=1;
                joyType2=2;
        #else
        
                printf("\n\njoystick 1:\n");

                for (x = 0; x != GAME_DEVICES; x++)
                        printf("%u - %s\n", x + 1, joystick_type[x]);

                joyType1 = 0;
                while ((joyType1 < 1) || (joyType1 > GAME_DEVICES))
                        joyType1 = getk() - 48;
                #if defined(__ZX80__)
                        fgetc_cons();
                #endif
                while (getk())
                        ;

                printf("\n\njoystick 2:\n");

                for (x = 0; x != GAME_DEVICES; x++)
                        printf("%u - %s\n", x + 1, joystick_type[x]);
                #if defined(__ZX80__)
                        fgetc_cons();
                #endif
                joyType2 = 0;
                while ((joyType2 < 1) || (joyType2 > GAME_DEVICES))
                        joyType2 = getk() - 48;
        
        while(1)
        {        
                if (joystick(joyType1) & MOVE_LEFT)
                        sprintf(joyTextLeft,"%s","left");                
                else if (joystick(joyType1) & MOVE_RIGHT)
                        sprintf(joyTextLeft,"%s","right");        
                else if (joystick(joyType1) & MOVE_UP)
                        sprintf(joyTextLeft,"%s","up");                
                else if (joystick(joyType1) & MOVE_DOWN)
                        sprintf(joyTextLeft,"%s","down");
                else if (joystick(joyType1) & MOVE_FIRE1)
                        sprintf(joyTextLeft,"%s","fire1");        
                else if (joystick(joyType1) & MOVE_FIRE2)
                        sprintf(joyTextLeft,"%s","fire2");        
                else
                        sprintf(joyTextLeft,"%s"," ");                

                if (joystick(joyType2) & MOVE_LEFT)
                        sprintf(joyTextRight,"%s","left");                
                else if (joystick(joyType2) & MOVE_RIGHT)
                        sprintf(joyTextRight,"%s","right");                
                else if (joystick(joyType2) & MOVE_UP)
                        sprintf(joyTextRight,"%s","up");                
                else if (joystick(joyType2) & MOVE_DOWN)
                        sprintf(joyTextRight,"%s","down");                
                else if (joystick(joyType2) & MOVE_FIRE1)
                        sprintf(joyTextRight,"%s","fire1");        
                else if (joystick(joyType2) & MOVE_FIRE2)
                        sprintf(joyTextRight,"%s","fire2");        
                else
                        sprintf(joyTextRight,"%s"," ");                
                
                printf("joy 1: %-5s  joy 2: %-5s\n",joyTextLeft,joyTextRight);
                #if defined(__ZX80__)
                        gen_tv_field();
                #endif                
        }        
}
...and a batch file that compiles for all target systems listed above:

Code: Select all

setlocal
rem Set your z88dk root path here
set z88root=C:\Misc\z88dk\

set path=%PATH%;%z88root%bin\
set zcccfg=%z88root%lib\config\
set z80_ozfiles=%z88root%lib\

REM === Jupiter Ace ===
del joytest_JupiterAce.tap
zcc +ace -create-app joytest.c -o jt.bin
ren jt.tap joytest_JupiterAce.tap

REM === Alphatronic PC ===
zcc +alphatro -create-app joytest.c -o joytest_alphatronic

REM === Bandai RX-78 ===
zcc +rx78 -o joytest_rx78 -create-app joytest.c 

REM === EG2000 ===
zcc +trs80 -lndos -create-app -subtype=eg2000disk -o joytest_eg2000.bin joytest.c

REM === Mattel Aquarius ===
zcc +aquarius -create-app joytest.c -o joytest_aquarius
zcc +aquarius -subtype=rom -create-app joytest.c -o joytest_aquarius

REM === Memotech MTX ===
del joytest_MemotechMTX500
del joytest_MemotechMTX500.mtx
del joytest_MemotechMTX512
del joytest_MemotechMTX512.mtx
REM MTX 500 mode (32K)
REM This memory model works with the MTX512 too, but before loading the user must type:
REM POKE 64122,0 
REM NEW
zcc +mtx -create-app joytest.c -o joytest_MemotechMTX500.o
ren joytest_MemotechMTX500 joytest_MemotechMTX500.mtx
REM MTX 512 mode (64K and more)
zcc +mtx -create-app -startup=2 joytest.c -o joytest_MemotechMTX512.o
ren joytest_MemotechMTX512 joytest_MemotechMTX512.mtx

REM === MC-1000 ===
zcc +mc1000 -create-app -Cz--audio joytest.c -o joytest_mc1000

REM === Camputers Lynx ===
del joytest
del joytest.cas
del joytest_CamputersLynx
del joytest_CamputersLynx.tap
zcc +lynx -create-app joytest.c -o joytest
ren joytest joytest_CamputersLynx
ren joytest.tap joytest_CamputersLynx.tap

REM === Colecovision ===
zcc +coleco -o joytest_coleco -create-app joytest.c 

REM === Amstrad CPC ===
del joytest_cpc
del joytest_cpc.dsk
del joytest_cpc.cpc
del joytest
del joytest.dsk
del joytest.cpc
zcc +cpc -lndos -subtype=dsk -create-app -o joytest joytest.c
ren joytest joytest_cpc
ren joytest.dsk joytest_cpc.dsk
ren joytest.cpc joytest_cpc.cpc

REM === Tandy TRS-80 ===
zcc +trs80 -lndos -create-app -o joytest_trs80.bin -subtype=disk joytest.c

REM === Tatung Einstein ===
del joytest_einstein.dsk
del joytest_einstein.com
REM Here we define "__EINSTEIN__" so that we know what CP/M machine our program is running on
zcc +cpm -subtype=einstein -o joytest.com joytest.c -create-app -D__EINSTEIN__
ren joytest.dsk joytest_einstein.dsk
ren joytest.com joytest_einstein.com

REM === Exidy Sorcerer ===
REM .srr file for JSorcerer
zcc +srr -lndos -o joytest_sorcerer -create-app joytest.c
REM .wav file for M.A.M.E or real hardware
zcc +srr -lndos -o joytest_sorcerer -create-app joytest.c -Cz--audio

REM === Galaksija ====
del joytest
del joytest.wav
del joytest.gtp
del joytest_galaksija
del joytest_galaksija.wav
del joytest_galaksija.gtp
zcc +gal -create-app -o joytest joytest.c
ren joytest joytest_galaksija
ren joytest.wav joytest_galaksija.wav
ren joytest.gtp joytest_galaksija.gtp

REM === KC 85/2-5 ===
zcc +kc -lndos -create-app joytest.c -o joytest_KC85_2-5

REM === Laser 500 ===
del joytest_laser500_MAME.wav
del joytest_laser500.wav
del joytest_laser500.cas
del joytest_laser500.bin
del joytest_laser500
del joytest.wav
del joytest.cas
del joytest.bin
del joytest
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
REM Will create a file that will load on real hardware.
zcc +laser500 joytest.c -o joytest -create-app -Cz--audio
ren joytest joytest_laser500.bin
ren joytest.cas joytest_laser500.cas
ren joytest.wav joytest_laser500.wav
REM Will create a file that will load on the Mame emulator
zcc +laser500 joytest.c -o joytest -create-app -Cz--audio -Cz--fast
del joytest
del joytest.cas
ren joytest.wav joytest_laser500_MAME.wav

REM === Mitsubishi Multi-8 ===
zcc +multi8 -create-app -o joytest_multi8 joytest.c

REM === Microbee ===
del joytest
del joytest.dsk
del joytest_microbee
del joytest_microbee.dsk
REM Here we define "__BEE__" so that we know what CP/M machine our program is running on
zcc +cpm -subtype=microbee -create-app -o joytest joytest.c -D__BEE__
ren joytest joytest_microbee
ren joytest.dsk joytest_microbee.dsk

REM === MSX ===
del joytest
del joytest.cas
del joytest_msx
del joytest_msx.cas
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
REM The -zorg=49200 option makes the program compatible for 16K machines
zcc +msx -create-app -lndos joytest.c -o joytest -zorg=49200
ren joytest joytest_msx
ren joytest.cas joytest_msx.cas

REM === NASCOM ===
zcc +nascom -o joytest_nascom -create-app joytest.c
rem copy the file to the emulator directory
del C:\Misc\DOS\misc\nascom\joytest.NAS /Q
copy joytest_nascom.nas C:\Misc\DOS\misc\nascom\joytest.NAS

REM === NEC PC-6001 Mk2 ===
zcc +pc6001 -subtype=rom -create-app -o joytest_pc6001Mk2 joytest.c

REM === Osborne 1 ===
del joytest_osborne1.dsk
del joytest_osborne1
REM Here we define "__OSBORNE1__" so that we know what CP/M machine our program is running on
zcc +cpm -subtype=osborne1 -create-app -o joytest joytest.c -D__OSBORNE1__
ren joytest.dsk joytest_osborne1.dsk
ren joytest joytest_osborne1

REM === Philips P2000 ===
zcc +p2000 -o joytest_p2000 -create-app joytest.c
REM copy the file to the emulator directory
del C:\Misc\DOS\misc\p2000\joytest.cas /Q
copy joytest_p2000.cas C:\Misc\DOS\misc\p2000\joytest.cas

REM === Philips VG5000 ===
zcc +vg5k -create-app joytest.c -o joytest_vg5000

REM === PV-1000 ===
zcc +pv1000 -o joytest_pv1000 -create-app joytest.c 

REM === PV-2000 ===
zcc +pv2000 -o joytest_pv2000 -create-app joytest.c 

REM === Samsung SPC-1000
del joytest
del joytest.spc
del joytest_spc1000
del joytest_spc1000.spc
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
zcc +spc1000 -create-app joytest.c -o joytest
ren joytest joytest_spc1000
ren joytest.spc joytest_spc1000.spc

REM === SC3000 ===
REM In the Takeda emulator, attach the created .rom cart file, not the .sc file!
zcc +sc3000 -subtype=rom -create-app -o joytest_sc3000.sc joytest.c

REM === Sharp MZ ===
del joytest
del joytest.mzt
del joytest_sharpmz
del joytest_sharpmz.mzt
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
zcc +mz -clib=ansi -create-app -o joytest joytest.c
ren joytest joytest_sharpmz
ren joytest.mzt joytest_sharpmz.mzt

REM === Sinclair ZX80 ===
zcc +zx80 -create-app -o joytest_ZX80 joytest.c

REM === Sinclair ZX81 ===
zcc +zx81 -create-app -startup=2 -o joytest_ZX81 joytest.c

REM === Sinclair ZX Spectrum ===
zcc +zx -lndos -create-app -o joytest_ZXSpectrum joytest.c

REM === Sord M5 ===
zcc +m5 -create-app -o joytest_sordm5 joytest.c

REM === Super-80 ===
zcc +super80 -create-app -o joytest_super80 joytest.c

REM === SVI ===
del joytest
del joytest.cas
del joytest_svi
del joytest_svi.cas
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
REM The -zorg=49200 option makes the program compatible for 16K machines
zcc  +svi -create-app joytest.c -o joytest -zorg=49200
ren joytest joytest_svi
ren joytest.cas joytest_svi.cas

REM === TIKI-100 ===
del joytest.com
del joytest.dsk
del joytest_tiki100.com
del joytest_tiki100.dsk
zcc +cpm -subtype=tiki100 -ltiki100 -create-app -o joytest.COM joytest.c
ren joytest.com joytest_tiki100.com
ren joytest.dsk joytest_tiki100.dsk

REM === VZ200 / Laser 210 ===
zcc +vz -o joytest_vz200.vz joytest.c 

REM === Z1013 ===
zcc +z1013 -create-app joytest.c -o joytest_z1013

REM === Z9001 ===
zcc +z9001 -o joytest_z9001 -create-app joytest.c


endlocal

rem pause
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I'll work my way slowly through these

Aquarius: Both joysticks will now work, for some reason there was an incomplete copy of the generic code in the aquarius library

TRS80: This looks like the ROM keyboard scanning routine is missing some keypresses. Not to worry though, compile with -pragma-redirect:getk=getk_inkey and it'll work ok

Actually, that option may sort out some of the other problems you've reported - some of the ROM keyboard drivers are a bit ropy regarding autorepeat etc
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Mattel Aquarius works correctly now, thanks.

TRS-80 and EG2000 work fine with the -pragma-redirect:getk=getk_inkey workaround.

But for the other problematic targets (SC3000, Jupiter Ace, SVI and Sord M5), this parameter does not help. And for the P2000, adding the parameter results in a "symbol 'getk_inkey' not defined" compiler error.
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Arrgh, topic subject should of course be "games.h Issues", not joystick.h...
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Sega SC-3000 - the joystick support in this one is actually the two physical joystick ports - I've now corrected the names.

SVI: This is a bit broken - it looks like keyboard reading implementation just doesn't work for some reason so it'll need a rewrite.

The generic keyboard joystick in general aren't that useful - they only support a single keypress at a time since getk() is used under the hood. I can feel a version coming on that supports in_Inkey() and customisable keys.
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Sega SC-3000: the names are displayed correctly now, and joystick input works fine, that moves it to the second group: additional cursor keys support would be nice to have.

So Jupiter Ace, SVI, Sord M5 and P2000 are the only really problematic ones left.

I'm currently working on a little program where I use games.h input for "menu navigation". In such a program there is no need to detect multiple keypresses, so games.h joystick input makes cross-development very easy - my program compiles almost "out of the box" for most targets. Mainly I only need to adjust the delay after each user input for each target, in order to find a balance between preventing unwanted multiple inputs and fast navigation.

But multiple key detection - just like using in_KeyPressed() - would be of course be great to have for all platforms using the games.h joystick.

Merry Christmas to all of you who celebrate it!
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I've finally managed to merge some code to resolve some of the issues you raised: I've added support for up-to 4 keyboard based joysticks for a number of ports.

The joysticks are: qaop-mn, 8246-05, hjkl-sd, Cursors+space. The cursors disappear on some ports as a result of keyboard layouts etc

So far I've updated the following ports: RX78, Super80, Aquarius, Laser 500, Sord M5, SC3000, SVI, TRS80. The following: Alphatronic and Lynx now have joystick support for the first time.

In addition all ports (which have inkey support) can use the function uint8_t joystick_sc(int *scancodes) which takes an array of scan codes (determined by in_LookupKey) so any combination of keys can be used as a joystick. This function supports multiple concurrent directions (eg left-up).

There's a few more ports which should be easy to add support to, so I'll hopefully tackle those in the next few days.
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

I haven't tested joystick_sc() yet, but all your standard additions work fine, except for:

- Camputers Lynx: No cursor keys input reaction (tested with the Jynx emulator). Seems to require the -pragma-redirect:getk=getk_inkey parameter. Difficult to test because console scrolling is so slow. (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor)

- Super-80: standard model (e/m) is ok, but using -clib=vduem (r/v model) gives compiler errors "symbol 'keys_qaop' not defined"

Here is my updated test program along with the compilation batch file.

Code: Select all

/*
  joytest.c
  joystick test using games.h (based on snakes.c)
  Author: RobertK, 2019-01-12
  
  === Test results ===
  
  Alphatronic PC:  all ok (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor)
  
  Bandai RX-78: all ok (1 - Joystick 1, 2 - Joystick 2, 3 - QAOP-MN, 4 - 8246-05, 5 - hjkl-sd, 6 - Cursor)

  Camputers Lynx: No cursor keys input reaction. Seems to require the -pragma-redirect:getk=getk_inkey parameter. Difficult to test because console scrolling is so slow. (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor) ?
  
  Casio PV-1000: all ok (Joystick 1 and 2)
  
  Casio PV-2000: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  Colecovison: all ok (Joystick 1 and 2)
  
  TRS-80 and
  EG2000: all ok (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor)

  Galaksija: all ok (1 - Arrows and Space, 2 - 5678-0)
  
  Jupiter Ace: (1 - 1-5, 2 - 6-0, 3 - Cursor) The 6-0 set interferes with the cursor key set. Instead of 1-5 and 6-0, 
  QAOP-MN would be nice to have, like on the ZX81.
  
  Laser 210 / VZ200: all ok (1 = 1-5, 2 = 6-0, 3 = QAOP-MN)

  Laser 350 / 500: all ok with the test program, but there could be problems with a real application, needs more testing (1 - Joystick 1, 2 - QAOP-MN, 3 - 8246-05, 4 - hjkl-sd) ?
  
  Mattel Aquarius: can't test cursor input in Virtual Aquarius, moves cursor and shows no input, otherwise all ok (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor) $
  
  MC-1000: probably all ok (1 - Joystick 1, 2 - Joystick 2), Joystick 2 is still untested. 
  Additional QAOP-MN support would be nice to have.

  Memotech MTX: all ok (1 - Joystick 1, 2 - Joystick 2). Additional support for cursor keys (1 5 3 .) would be nice to have.

  Microbee: all ok (1 - Arrows and Space, 2 - Arrows + SPACE (256TC), 3 - Joystick on parallel port)

  MSX: all ok (1 - Cursor, 2 - Joystick 1, 3 - Joystick 2)
  
  Philips P2000: reacts only to left direction input (1 = QAOP-MN, 2 = 8246-05)

  Philips VG5000: joystick input still needs to be tested, otherwise all ok (1 - Joystick 1, 2 - Joystick 2, 3 - AQOP-MN, 4 - 8246-05, 5 - hjkl-sd, 6 - Cursor) ?
  
  Sega SC3000: all ok (1 - Joystick 1, 2 - Joystick 2, 3 - QAOP-MN, 4 - 8246-05, 5 - hjkl-sd, 6 - Cursor)

  Sharp MZ: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  Sord M5: all ok (1 - Joystick 1 + Space, 2 - QAOP-MN, 3 - 8246-05, 4 - hjkl-sd)
  
  Super-80: -clib=vduem (r/v): compiler errors "symbol 'keys_qaop' not defined"; standard model (e/m): all ok (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor) ?
  
  SVI: joystick input still needs to be tested, otherwise all ok (1 - Joystick 1, 2 - Joystick 2, 3 - QAOP-MN, 4 - 8246-05, 5 - hjkl-sd, 6 - Cursor) ?

  Z9001: all ok (1 - Joystick 1, 2 - Joystick 2), although there are slowdowns when the stick is held in one direction. Cursor key support would be nice to have.
  
  ZX80: all ok (1 - QAOP-MN, 2 - 8246-05)
  
  ZX81: all ok (1 - Kempston, 2 - ZXPand, 3 - QAOP-MN, 4 - Cursor)

  ZX Spectrum: all ok (1 - Kempston, 2 - Sinclair 1, 3 - Sinclair 2, 4 - Cursor, 5 - Fuller)

  ABC80, (*)   
  Amstrad CPC, 
  Casio FP-1100, (*)
  Exidy Sorcerer, 
  KC 85/2-5,
  Mitsubishi Multi-8,
  Nascom, 
  NEC PC-6001 Mk2,
  Osborne 1,
  Samsung SPC-1000,
  Sharp MZ-2500, (*)
  Tatung Einstein, 
  Tiki-100,
  Z1013:
  '_joystick_type' not defined, etc.
          
  (*) new entries since 2018-12-29
*/ 

// zcc +zx81 -create-app -startup=2 -o joytest2_ZX81 joytest2.c

// zcc +ace -vn -create-app joytest2.c -o jt2.bin
// load the game on the Jupiter Ace by typing
// 0 0 bload jt.bin

#include <stdio.h>
#include <games.h>

void main(void) {
        int joyType1;
        int joyType2;
        int x;
        char joyTextLeft[7];
        char joyTextRight[7];
          
        printf("%c",12);                         // clear the screen          
        #if defined(__ZX80__)
                gen_tv_field_init(0);        // has to be called once for screen-refreshing on the ZX80
        #endif
        printf("*** joystick test ***");

        /*
        int XSize,YSize;
        screensize(&XSize, &YSize);  
        printf("\n\nxsize=%d, ysize=%d", XSize, YSize);
    */
  
        // On consoles we don't have a keyboard so we have to preset the joystick selection
        #if defined(__PV1000__)
                joyType1=0;
                joyType2=1;
        #elif defined(__COLECO__)
                joyType1=1;
                joyType2=2;
        #else
        
                printf("\n\njoystick 1:\n");

                for (x = 0; x != GAME_DEVICES; x++)
                        printf("%u - %s\n", x + 1, joystick_type[x]);

                joyType1 = 0;
                while ((joyType1 < 1) || (joyType1 > GAME_DEVICES))
                        joyType1 = getk() - 48;
                #if defined(__ZX80__)
                        fgetc_cons();
                #endif
                while (getk())
                        ;

                printf("\n\njoystick 2:\n");

                for (x = 0; x != GAME_DEVICES; x++)
                        printf("%u - %s\n", x + 1, joystick_type[x]);
                #if defined(__ZX80__)
                        fgetc_cons();
                #endif
                joyType2 = 0;
                while ((joyType2 < 1) || (joyType2 > GAME_DEVICES))
                        joyType2 = getk() - 48;
                
        #endif
        
        while(1)
        {        
                if (joystick(joyType1) & MOVE_LEFT)
                        sprintf(joyTextLeft,"%s","left");                
                else if (joystick(joyType1) & MOVE_RIGHT)
                        sprintf(joyTextLeft,"%s","right");        
                else if (joystick(joyType1) & MOVE_UP)
                        sprintf(joyTextLeft,"%s","up");                
                else if (joystick(joyType1) & MOVE_DOWN)
                        sprintf(joyTextLeft,"%s","down");
                else if (joystick(joyType1) & MOVE_FIRE1)
                        sprintf(joyTextLeft,"%s","fire1");        
                else if (joystick(joyType1) & MOVE_FIRE2)
                        sprintf(joyTextLeft,"%s","fire2");        
                else
                        sprintf(joyTextLeft,"%s"," ");                

                if (joystick(joyType2) & MOVE_LEFT)
                        sprintf(joyTextRight,"%s","left");                
                else if (joystick(joyType2) & MOVE_RIGHT)
                        sprintf(joyTextRight,"%s","right");                
                else if (joystick(joyType2) & MOVE_UP)
                        sprintf(joyTextRight,"%s","up");                
                else if (joystick(joyType2) & MOVE_DOWN)
                        sprintf(joyTextRight,"%s","down");                
                else if (joystick(joyType2) & MOVE_FIRE1)
                        sprintf(joyTextRight,"%s","fire1");        
                else if (joystick(joyType2) & MOVE_FIRE2)
                        sprintf(joyTextRight,"%s","fire2");        
                else
                        sprintf(joyTextRight,"%s"," ");                
                
                printf("joy 1: %-5s  joy 2: %-5s\n",joyTextLeft,joyTextRight);
                #if defined(__ZX80__)
                        gen_tv_field();
                #endif                
        }        
}

Code: Select all

setlocal
rem Set your z88dk root path here
set z88root=C:\Misc\z88dk\

set path=%PATH%;%z88root%bin\
set zcccfg=%z88root%lib\config\
set z80_ozfiles=%z88root%lib\

REM === ABC80 ===
zcc +abc80 -create-app -o joytest_abc80 joytest.c
REM zcc +abc80 -zorg=50000 -o joytest_abc80 -create-app joytest.c
REM copy the file to the emulator directory
del C:\Misc\Emulator\ABCWin\Files\joytest.BAC /Q
copy joytest_abc80.bac C:\Misc\Emulator\ABCWin\Files\joytest.BAC

REM === Jupiter Ace ===
del joytest_JupiterAce.tap
zcc +ace -create-app joytest.c -o jt.bin
ren jt.tap joytest_JupiterAce.tap

REM === Alphatronic PC ===
zcc +alphatro -create-app joytest.c -o joytest_alphatronic

REM === Bandai RX-78 ===
zcc +rx78 -o joytest_rx78 -create-app joytest.c 

REM === Casio FP-1100 ===
zcc +fp1100 -create-app -o joytest_fp1100 joytest.c

REM === EG2000 ===
zcc +trs80 -lndos -create-app -subtype=eg2000disk -o joytest_eg2000.bin joytest.c

REM === Mattel Aquarius ===
zcc +aquarius -create-app joytest.c -o joytest_aquarius
zcc +aquarius -subtype=rom -create-app joytest.c -o joytest_aquarius

REM === Memotech MTX ===
del joytest_MemotechMTX500
del joytest_MemotechMTX500.mtx
del joytest_MemotechMTX512
del joytest_MemotechMTX512.mtx
REM MTX 500 mode (32K)
REM This memory model works with the MTX512 too, but before loading the user must type:
REM POKE 64122,0 
REM NEW
zcc +mtx -create-app joytest.c -o joytest_MemotechMTX500.o
ren joytest_MemotechMTX500 joytest_MemotechMTX500.mtx
REM MTX 512 mode (64K and more)
zcc +mtx -create-app -startup=2 joytest.c -o joytest_MemotechMTX512.o
ren joytest_MemotechMTX512 joytest_MemotechMTX512.mtx

REM === MC-1000 ===
zcc +mc1000 -create-app -Cz--audio joytest.c -o joytest_mc1000

REM === Camputers Lynx ===
del joytest
del joytest.cas
del joytest_CamputersLynx
del joytest_CamputersLynx.tap
zcc +lynx -create-app -pragma-redirect:fputc_cons=fputc_cons_generic joytest.c -o joytest
ren joytest joytest_CamputersLynx
ren joytest.tap joytest_CamputersLynx.tap

REM === Colecovision ===
zcc +coleco -o joytest_coleco -create-app joytest.c 

REM === Amstrad CPC ===
del joytest_cpc
del joytest_cpc.dsk
del joytest_cpc.cpc
del joytest
del joytest.dsk
del joytest.cpc
zcc +cpc -lndos -subtype=dsk -create-app -o joytest joytest.c
ren joytest joytest_cpc
ren joytest.dsk joytest_cpc.dsk
ren joytest.cpc joytest_cpc.cpc

REM === Tandy TRS-80 ===
zcc +trs80 -lndos -create-app -o joytest_trs80.bin -subtype=disk joytest.c

REM === Tatung Einstein ===
del joytest_einstein.dsk
del joytest_einstein.com
REM Here we define "__EINSTEIN__" so that we know what CP/M machine our program is running on
zcc +cpm -subtype=einstein -o joytest.com joytest.c -create-app -D__EINSTEIN__
ren joytest.dsk joytest_einstein.dsk
ren joytest.com joytest_einstein.com

REM === Exidy Sorcerer ===
REM .srr file for JSorcerer
zcc +srr -lndos -o joytest_sorcerer -create-app joytest.c
REM .wav file for M.A.M.E or real hardware
zcc +srr -lndos -o joytest_sorcerer -create-app joytest.c -Cz--audio

REM === Galaksija ====
del joytest
del joytest.wav
del joytest.gtp
del joytest_galaksija
del joytest_galaksija.wav
del joytest_galaksija.gtp
zcc +gal -create-app -o joytest joytest.c
ren joytest joytest_galaksija
ren joytest.wav joytest_galaksija.wav
ren joytest.gtp joytest_galaksija.gtp

REM === KC 85/2-5 ===
zcc +kc -lndos -create-app joytest.c -o joytest_KC85_2-5

REM === Laser 500 ===
del joytest_laser500_MAME.wav
del joytest_laser500.wav
del joytest_laser500.cas
del joytest_laser500.bin
del joytest_laser500
del joytest.wav
del joytest.cas
del joytest.bin
del joytest
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
REM Will create a file that will load on real hardware.
zcc +laser500 joytest.c -o joytest -create-app -Cz--audio
ren joytest joytest_laser500.bin
ren joytest.cas joytest_laser500.cas
ren joytest.wav joytest_laser500.wav
REM Will create a file that will load on the Mame emulator
zcc +laser500 joytest.c -o joytest -create-app -Cz--audio -Cz--fast
del joytest
del joytest.cas
ren joytest.wav joytest_laser500_MAME.wav

REM === Mitsubishi Multi-8 ===
zcc +multi8 -create-app -o joytest_multi8 joytest.c

REM === Microbee ===
del joytest
del joytest.dsk
del joytest_microbee
del joytest_microbee.dsk
REM Here we define "__BEE__" so that we know what CP/M machine our program is running on
zcc +cpm -subtype=microbee -create-app -o joytest joytest.c -D__BEE__
ren joytest joytest_microbee
ren joytest.dsk joytest_microbee.dsk

REM === MSX ===
del joytest
del joytest.cas
del joytest_msx
del joytest_msx.cas
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
REM The -zorg=49200 option makes the program compatible for 16K machines
zcc +msx -create-app -lndos joytest.c -o joytest -zorg=49200
ren joytest joytest_msx
ren joytest.cas joytest_msx.cas

REM === NASCOM ===
zcc +nascom -o joytest_nascom -create-app joytest.c
rem copy the file to the emulator directory
del C:\Misc\DOS\misc\nascom\joytest.NAS /Q
copy joytest_nascom.nas C:\Misc\DOS\misc\nascom\joytest.NAS

REM === NEC PC-6001 Mk2 ===
zcc +pc6001 -subtype=rom -create-app -o joytest_pc6001Mk2 joytest.c

REM === Osborne 1 ===
del joytest_osborne1.dsk
del joytest_osborne1
REM Here we define "__OSBORNE1__" so that we know what CP/M machine our program is running on
zcc +cpm -subtype=osborne1 -create-app -o joytest joytest.c -D__OSBORNE1__
ren joytest.dsk joytest_osborne1.dsk
ren joytest joytest_osborne1

REM === Philips P2000 ===
zcc +p2000 -create-app -o joytest_p2000 joytest.c
REM copy the file to the emulator directory
del C:\Misc\DOS\misc\p2000\joytest.cas /Q
copy joytest_p2000.cas C:\Misc\DOS\misc\p2000\joytest.cas

REM === Philips VG5000 ===
zcc +vg5k -create-app joytest.c -o joytest_vg5000

REM === PV-1000 ===
zcc +pv1000 -o joytest_pv1000 -create-app joytest.c 

REM === PV-2000 ===
zcc +pv2000 -o joytest_pv2000 -create-app joytest.c 

REM === Samsung SPC-1000
del joytest
del joytest.spc
del joytest_spc1000
del joytest_spc1000.spc
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
zcc +spc1000 -create-app joytest.c -o joytest
ren joytest joytest_spc1000
ren joytest.spc joytest_spc1000.spc

REM === SC3000 ===
REM In the Takeda emulator, attach the created .rom cart file, not the .sc file!
zcc +sc3000 -subtype=rom -create-app -o joytest_sc3000.sc joytest.c

REM === Sharp MZ ===
del joytest
del joytest.mzt
del joytest_sharpmz
del joytest_sharpmz.mzt
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
zcc +mz -clib=ansi -create-app -o joytest joytest.c
ren joytest joytest_sharpmz
ren joytest.mzt joytest_sharpmz.mzt

REM === Sharp MZ-2500 ===
zcc +mz2500 -create-app -o joytest_mz2500 joytest.c

REM === Sinclair ZX80 ===
zcc +zx80 -create-app -o joytest_ZX80 joytest.c

REM === Sinclair ZX81 ===
zcc +zx81 -create-app -startup=2 -o joytest_ZX81 joytest.c

REM === Sinclair ZX Spectrum ===
zcc +zx -lndos -create-app -o joytest_ZXSpectrum joytest.c

REM === Sord M5 ===
zcc +m5 -create-app -o joytest_sordm5 joytest.c

REM === Super-80 ===
zcc +super80 -create-app -o joytest_super80 joytest.c

REM === Super-80 r/v model ===
zcc +super80 -create-app -clib=vduem -o joytest_super80rv joytest.c

REM === SVI ===
del joytest
del joytest.cas
del joytest_svi
del joytest_svi.cas
REM we compile it under the name "joytest" (without system suffix) so that the program file inside the cassette file gets this name
REM The -zorg=49200 option makes the program compatible for 16K machines
zcc  +svi -create-app joytest.c -o joytest -zorg=49200
ren joytest joytest_svi
ren joytest.cas joytest_svi.cas

REM === TIKI-100 ===
del joytest.com
del joytest.dsk
del joytest_tiki100.com
del joytest_tiki100.dsk
zcc +cpm -subtype=tiki100 -ltiki100 -create-app -o joytest.COM joytest.c
ren joytest.com joytest_tiki100.com
ren joytest.dsk joytest_tiki100.dsk

REM === VZ200 / Laser 210 ===
zcc +vz -o joytest_vz200.vz joytest.c 

REM === Z1013 ===
zcc +z1013 -create-app joytest.c -o joytest_z1013

REM === Z9001 ===
zcc +z9001 -o joytest_z9001 -create-app joytest.c


endlocal

rem pause
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

RobertK wrote:I haven't tested joystick_sc() yet, but all your standard additions work fine, except for:

- Camputers Lynx: No cursor keys input reaction (tested with the Jynx emulator). Seems to require the -pragma-redirect:getk=getk_inkey parameter. Difficult to test because console scrolling is so slow. (1 - QAOP-MN, 2 - 8246-05, 3 - hjkl-sd, 4 - Cursor)
I'm using Jynx 1.0.8 (32 bit) under wine and just a straight compile: zcc +lynx joystick.c -create-app doesn't show any issues - all the cursor keys are working.
- Super-80: standard model (e/m) is ok, but using -clib=vduem (r/v model) gives compiler errors "symbol 'keys_qaop' not defined"
Sorted.
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Super-80 r/v works now, thanks.

Lynx games.h support seems to broken in the current nightly build, you get "symbol '_joystick_type' not defined" errors now.
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Games.h support on the Sord M5 is currently broken, you get these error messages when trying to compile joytest.c, please check this:

Error at file 'joystick_inkey.asm' line 16: symbol 'keys_qaop' not defined
Error at file 'joystick_inkey.asm' line 19: symbol 'keys_8246' not defined
Error at file 'joystick_inkey.asm' line 22: symbol 'keys_vi' not defined
Error at file 'joystick_inkey.asm' line 25: symbol 'keys_cursor' not defined
Errors in source file C:\Misc\z88dk\lib\config\\..\..\\lib\target\m5\classic\m5_crt0.asm:
Error at file 'joystick_inkey.asm' line 16: symbol 'keys_qaop' not defined
Error at file 'joystick_inkey.asm' line 19: symbol 'keys_8246' not defined
Error at file 'joystick_inkey.asm' line 22: symbol 'keys_vi' not defined
Error at file 'joystick_inkey.asm' line 25: symbol 'keys_cursor' not defined

For the Lynx it now compiles fine again.

Another little issue: could you please change the joystick names for the ZX81 and ZX80 to lower-case characters? Because printing e.g. "Cursor" makes the first letter being shown in inverse on these two systems.

P.S. Can any of you with administrator privileges change my silly topic subject to "Games.h Issues"?
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Sorry for taking so long to fix this one - too much wrapping my head around floating point code.

I've updated both of these issues, so they should work now.
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Is there a reason for the ZX Spectrum target not supporting the QAOP-MN keyset? That was quite a common keyset among many Spectrum games, so it would be nice-to-have.
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

the only reason was a big number of existing options. I omitted that to avoid to exceed in the number of options and to save few memory bytes.
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

'nice to have' ready and scheduled for the build tonight!
RobertK
Well known member
Posts: 199
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Thanks a lot! For some reason, I had some trouble on the Spectrum when using kbhit() and getch() in my Elite Planet Browser, but with games.h using joystick() everything works fine now.
Post Reply