Forum
Reading Kempston Joystick using function IN 31 - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13)
+---- Thread: Reading Kempston Joystick using function IN 31 (/showthread.php?tid=784)



Reading Kempston Joystick using function IN 31 - Luzie - 01-08-2017

Hi,

I´m missing the IN function in ZX BASIC (as it was in Original Sinclair ZX Spectrum BASIC).

Would like to use it as described here:
<!-- m --><a class="postlink" href="https://chuntey.wordpress.com/2010/01/06/using-kempston-joystick-in-your-own-basic-programs/">https://chuntey.wordpress.com/2010/01/0 ... -programs/</a><!-- m -->

Must I use some machine code emulate?
If so, can someone please post me an example?

Regards,

Luzie


Re: Reading Kempston Joystick using function IN 31 - boriel - 01-08-2017

ZX Basic supports the IN and OUT instructions. If you cannot compile them then there is a syntax error.

Reading the listings in the page, remember that ZX BASIC, at this moment, requires every IF to be closed with END IF.
E.g.
Code:
10 LET x=10: LET y=10
20 LET kj=IN 31: REM get the state of joystick
30 PRINT AT y,x;"*"
40 IF (kj>31) OR (kj=0) THEN GO TO 20: END IF: REM ignore spurious inputs



Re: Reading Kempston Joystick using function IN 31 - Luzie - 01-09-2017

Hi,

thanks for your reply. I did some things wrong with the FUSE Emulator I used for testing:

On FUSE Kempston has to be enabled in at least two menus (Options / Peripherals / General and Options / Joystick).

Also I thought IN is not supported as I can´t find it on the Wiki. My fault. If I had a look at the MCode I should see that IN is correctly supported by ZX Basic.

Regards,

Luzie


Re: Reading Kempston Joystick using function IN 31 - boriel - 01-09-2017

Luzie Wrote:Hi,

thanks for your reply. I did some things wrong with the FUSE Emulator I used for testing:

On FUSE Kempston has to be enabled in at least two menus (Options / Peripherals / General and Options / Joystick).

Also I thought IN is not supported as I can´t find it on the Wiki. My fault. If I had a look at the MCode I should see that IN is correctly supported by ZX Basic.

Regards,

Luzie
No worries! Thanks for using ZX Basic. Hope you find it helpful


Re: Reading Kempston Joystick using function IN 31 - britlion - 08-09-2017

Luzie Wrote:Hi,

Also I thought IN is not supported as I can´t find it on the Wiki. My fault. If I had a look at the MCode I should see that IN is correctly supported by ZX Basic.

It seems to be at least in the keyword list:

<!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Identifier#Reserved_Identifiers">http://www.boriel.com/wiki/en/index.php ... dentifiers</a><!-- m -->