Moving graphics using the 5,8,6 and 7 keys on the zx81

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Crayon21
Posts: 346
Joined: Sun Nov 04, 2018 2:33 am

Moving graphics using the 5,8,6 and 7 keys on the zx81

Post by Crayon21 »

I can get them to appear on screen easily enough with the chr$ function but how do i move them with a joystick or arrows (not the speccy arrows, actual arrow keys) in basic? Without using input a$ if possible

Normally i'd do it like this:
Input a$:if not a$ then print "graphics character" at "position"
this is cumbersome and tiring. is there another way?

i hope there is, I feel like none of my code is up to par :(

ideas :?:

And yes, I read the manual.
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Moving graphics using the 5,8,6 and 7 keys on the zx81

Post by XavSnap »

Code: Select all

10 LET X=10
20 LET Y=10
100 LET X=X+(INKEY$="8" AND X<31)-(INKEY$="5" AND X>0)
110 LET Y=Y+(INKEY$="6" AND Y<21)-(INKEY$="7" AND Y>0)
115 LET A$=CHR$ (X+Y+128)
118 POKE PEEK 16399*256+PEEK 16398-1,0
120 PRINT AT Y,X;A$;
130 IF INKEY$<>"0" THEN GOTO 100
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Crayon21
Posts: 346
Joined: Sun Nov 04, 2018 2:33 am

Re: Moving graphics using the 5,8,6 and 7 keys on the zx81

Post by Crayon21 »

clarify please
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Moving graphics using the 5,8,6 and 7 keys on the zx81

Post by XavSnap »

Yes, Crayon.

This routine able to print a A$ character at line10, column 10.
X= column + or - the horizontal cursor move if in the screen board.
Y= vertical line + or - the vertical cursor move if in the screen board.

118 POKE PEEK 16399*256+PEEK 16398-1,0

This line retrieve de last PRINT AT memory offset (DF_CC) in the D_File segment. (+1, the next printed char.)
The POKE erase the last printed char.
Whitout this line, the last printed char won't be deleted.

This code is partially correct, just add :
50 PRINT AT Y,X;" "
To init the DF_CC Basic variable value, for the first delete location.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Moving graphics using the 5,8,6 and 7 keys on the zx81

Post by XavSnap »

Will test the move before apply a move:

Code: Select all

10 LET X=9
20 LET Y=10
30 PRINT AT 6,8;"««««««««««««««««";\
TAB 8;"« «     « « «  «";\
TAB 8;"« « ««« «   « ««";\
TAB 8;"« « «   « « «  «";\
TAB 8;"« « « «   « «« «";\
TAB 8;"« « « ««« «  « «";\
TAB 8;"« « « « «      «";\
TAB 8;"« «««   « « « ««";\
TAB 8;"«     «   « «  «";\
TAB 8;"« ««««« « «««« «";\
TAB 8;"« «  «« «    « h";\
TAB 8;"«   «   « « «  «";TAB 8;"««««««««««««««««"
50 PRINT AT Y,X;" ";
100 LET X2=X
102 LET Y2=Y
105 LET X=X+(INKEY$="8" AND X<31)-(INKEY$="5" AND X>0)
108 LET Y=Y+(INKEY$="6" AND Y<21)-(INKEY$="7" AND Y>0)
110 LET A$=CHR$ (X+Y+128)
118 POKE PEEK 16399*256+PEEK 16398-1,0
120 PRINT AT Y,X;
130 LET T$=CHR$ PEEK(PEEK 16399*256+PEEK 16398)
131 IF T$=" " THEN GOTO 140
132 IF T$="h" THEN GOTO 160
133 LET X=X2
134 LET Y=Y2
140 PRINT AT Y,X;A$;
150 IF INKEY$<>"0" THEN GOTO 100
160 PRINT AT 4,6;"NEXT LEVEL...CRAYON21"
170 PAUSE 100
180 CLS
190 RUN
Have fun.

"Crayon's maze and the last Zx81's manual crusade" ... game...
You had to find the holy Zx81's manual in a F***King maze of the death.
Use cursors to move the Crayon throw this peaceful and easy trip.
Just go to the "H" point (may be the holy user manual ?)
MOVE2.P
(1.71 KiB) Downloaded 115 times
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply