Page 1 of 1

inkey$ command and player choice

Posted: Tue Jul 02, 2019 3:38 am
by Crayon21
would it be better for me to program a inkey$ loop instruction instead of Get a$? the zx81 doesn't really have a provision for scanning the keyboard to find a certain key. Still working on treasure hunt, but this aspect of programming is still hard to pull off. I can get away with an input command here or there, but I miss out on declaring other variables. Will this help or not? For those interested, the story is done. It's nothing major, but my goal is to get the game to be just under 4k. thanks in advance.

Re: inkey$ command and player choice

Posted: Wed Jul 03, 2019 8:58 pm
by mrtinb
A simple wait for a key if you are in SLOW mode:
  • loop:
  • CALL SCAN
  • If key is $FFFF JR Z loop
  • CALL DECODE
  • RET
It’s not copy-paste, because it’s just from my memory.

Re: inkey$ command and player choice

Posted: Thu Jul 04, 2019 1:14 am
by XavSnap
:shock:
What it is Martin ?
10 REM loop:
20 REM SCAN
30 If key is $FFFF JR Z loop
40 CALL DECODE
50 RET
:oops:

Code: Select all

1 FOR A=0 TO 4E4
2 IF INKEY$="" THEN NEXT A 
3 PRINT INKEY$

Re: inkey$ command and player choice

Posted: Thu Jul 04, 2019 3:37 pm
by mrtinb
I’m on vacation and don’t have all my ZX81 books and manuals with me.

I’ve looked most of it up, on the Internet.

It’s machine language.

Loop:
LD HL,$FFFF
LD BC, LAST_K
AND A
SBC HL,BC
JR Z Loop
CALL DECODE ($07BD)
PUSH HL
POP BC
RET

100 REM GET KEY
10 LET KEY=USR xxxxx

Re: inkey$ command and player choice

Posted: Mon Oct 07, 2019 2:52 am
by Crayon21
I'm working on a parser for the zx81

my goal is to make a 4k version of the hobbit but with a better parser

Here is what i have so far

Re: inkey$ command and player choice

Posted: Mon Oct 07, 2019 3:03 am
by Crayon21
here is the second parser (feel free to use it as you see fit)

Re: inkey$ command and player choice

Posted: Tue Oct 08, 2019 9:01 pm
by dr beep
mrtinb wrote: Thu Jul 04, 2019 3:37 pm I’m on vacation and don’t have all my ZX81 books and manuals with me.

I’ve looked most of it up, on the Internet.

It’s machine language.

Loop:
LD HL,$FFFF
LD BC, LAST_K
AND A
SBC HL,BC
JR Z Loop
CALL DECODE ($07BD)
PUSH HL
POP BC
RET

100 REM GET KEY
10 LET KEY=USR xxxxx
I mostly code
Loop:
LD BC,( LAST_K)
LD A,C
INC A
JR Z Loop


In BASIC you can also PEEK LAST_K and use the IN ports for input.

Re: inkey$ command and player choice

Posted: Tue Oct 08, 2019 10:06 pm
by 1024MAK
There is no IN function in ZX81 BASIC, but it is possible to have a short machine code routine in a REM line to perform the Z80 IN.

Mark

Re: inkey$ command and player choice

Posted: Tue Oct 08, 2019 11:52 pm
by XavSnap
True, we had to buy a fuc*** Spectrum to get 'IN' and the famous 'OUT'!
:mrgreen:

Re: inkey$ command and player choice

Posted: Wed Oct 09, 2019 3:58 pm
by 1024MAK
1024MAK wrote: Tue Oct 08, 2019 10:06 pm There is no IN function in ZX81 BASIC, but it is possible to have a short machine code routine in a REM line to perform the Z80 IN.
The code in this post demonstrates using a small bit of machine code to perform a read from a hardware port using one of the Z80s IN opcodes.

Mark