Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
717 views
in Technique[技术] by (71.8m points)

memory - Help: ZX81 BASIC "Peek" function

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 :)

Thanks,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Located at addresses 16398 and 16399 are two bytes that form the cursor location. (See http://web.ukonline.co.uk/sinclair.zx81/chap28.html). In other words,

peek 16398 + 256*peek 16399

gives you the memory address of the character on the screen where the next PRINT would go. Which apparently can be changed with PRINT AT.

peek(peek 16398 + 256*peek 16399)

finds the code for whatever character is at that location. The rest you should be able to figure out.

Now, the main question is: does your game use the cursor in the same way? If not you have to use a different solution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...