Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help: ZX81 'BASIC' Peek function [duplicate]

Tags:

peek

zx81

I need a way to find if the character ('<') has hit a wall (Black pixel Graphic)

-On a ZX81 game.

I'm been looking at another game... which uses code

if peek(peek 16398 +256*peek 16399) = code "blackpixel graphic" then ...

Which seems to work for them...

Is this correct code?

I'm not really knowledgable with addresses and getting memory and stuff.

Please help me...

-If you know a better way. Please answer :) -Someone mentioned 'cursor position' what the hell is that on a ZX81? Thanks,

like image 719
James Andrew Avatar asked Jul 07 '10 16:07

James Andrew


1 Answers

PEEK(PEEK 16398+256*PEEK 16399) is an idiom meaning “get the character number at the current PRINT position”. This works because the two-byte word at 16398 is used by the ZX81 BASIC/ROM to store a pointer to the memory location in the screen data block corresponding to the PRINT position.

So to do collision detection, you'd first have to set:

PRINT AT X,Y;

co-ordinates to where the > is about to move, then read

LET C= PEEK(PEEK 16398+256*PEEK 16399)

then you can print the > on-screen (overwriting the previous character whose code is now in C) if you want to before doing the check:

IF C=128 THEN ...

(I'm guessing the character you want is the all-black character 128, █.)

Oh boy, do I feel old.

like image 88
bobince Avatar answered Sep 22 '22 22:09

bobince