Help: ZX81 BASIC “Peek” function

天大地大妈咪最大 提交于 2020-01-10 05:02:26

问题


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,


回答1:


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.




回答2:


peek reads the byte at a memory location. According to The System Variables of the Sinclair ZX81, memory location 16398 and 16399 form a 16bit value containing the current "Address of PRINT position in display file".

Thus, peek 16398 + 256*peek 16399 combines the two values into a 16 bit address and peeking that address (possibly) gets the pixel/character(?) at that position.




回答3:


It depends on what the memory address is, but peek usually means "what value is in this memory location?"

This looks like it should be some good reading in this particular topic.



来源:https://stackoverflow.com/questions/3195111/help-zx81-basic-peek-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!