Can joystick setting of JS-port 1 or 2 be read from software?

Discuss game and other programming topics not specifically covered in another forum

Moderator: Programming Moderators

Post Reply
User avatar
Luzie
Posts: 20
Joined: Mon May 29, 2017 8:47 pm

Can joystick setting of JS-port 1 or 2 be read from software?

Post by Luzie » Sat Feb 02, 2019 9:15 am

OK, completely noob-question from me:

Can the Next-Hardware-Joystick-setting e.g. Port 1=Kempston and Port 2=Sinclair Keys 6,7,8,9,0 read from MCode or BASIC via reading from IN-Ports?

Ped7g
Posts: 91
Joined: Mon Jul 16, 2018 7:11 pm

Re: Can joystick setting of JS-port 1 or 2 be read from software?

Post by Ped7g » Sat Feb 02, 2019 10:56 am

Theoretically yes, the NextRegister 0x05 should contain the info ( https://www.specnext.com/tbblue-io-port-system/ ).

In BASIC it would be something along: OUT 9275,5 (selecting NextReg 05 on I/O ports), x = IN 9531 (reads value)
I can't recall enough of BASIC syntax to show full working example, also I don't know how to process the obtained value in BASIC, seems like it has only logical AND, not binary... maybe the best bet is to do something like:
let j1=0 : let j2 = 0
if (128 <= x) x = x-128 : j1 = j1 + 2 : rem (needs probably LET on some places and other adjustments to fix syntax)
if (64 <= x) x = x-64 : j1 = j1 + 1
if (32 <= x) x = x-32 : j2 = j2 + 2
if (16 <= x) x = x-16 : j2 = j2 + 1
if (8 <= x) x = x-8 : j1 = j1 + 4
if (4 <= x) x = x-4 (50/60Hz mode bit)
if (2 <= x) x = x-2 : j2 = j2 + 4
REM x = 1 when "scandoubler" is enabled
REM j1 and j2 now should contain 0-7 value for selected type: S2 / K1 / C / S1 / K2 / MD1 / MD2 / ??

BUT, all this said, last time I have seen some debug photos from real board with some tests displaying this extra info, I tried quickly read the bits from the screen and asked the board owner if that was his config, and he said not, and showed the config screen during boot sequence. I didn't dig deeper into the issue (if I just read the values wrong, or what happened), but if you have actual board, let me know how it works for you.

Alcoholics Anonymous
Posts: 495
Joined: Mon May 29, 2017 7:00 pm

Re: Can joystick setting of JS-port 1 or 2 be read from software?

Post by Alcoholics Anonymous » Sun Feb 03, 2019 9:38 pm

Sinclair Basic does not contain any bitwise operators but Next basic does. See page 24 "Integer Variables and Expressions":

https://gitlab.com/thesmog358/tbblue/bl ... atures.pdf

When reading/writing nextreg in basic using OUTs, you have to make sure the OUT pair is executed in the same line:

OUT 9275,5: LET x=IN 9531

If these are in separate lines as in:

OUT 9275,5
LET x=IN 9531

or if statements appear between OUT/IN of ports 9275 and 9531 then something else could change the selected register in port 9275 before the port 9531 access.

There is a new .config dot command forming in the tbblue repo. ".config" on its own will list a number of settings and it allows you to change those settings as well, eg ".config joy0=kempston". It will also do an effective nextreg as in ".config nr=reg,val[,mask]" although I haven't tested that at all yet :P Loading a dot command just to do a nextreg is slower than those OUTs but it may be more convenient where speed doesn't matter.

User avatar
Luzie
Posts: 20
Joined: Mon May 29, 2017 8:47 pm

Re: Can joystick setting of JS-port 1 or 2 be read from software?

Post by Luzie » Tue Feb 05, 2019 6:07 pm

Thank you both for your answer, can hopefully test this in the next days and report back here.

Post Reply