7

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,

hippietrail
  • 15,848
  • 18
  • 99
  • 158
ZX81
  • 71
  • 1
  • 6
    No help from me; I flushed that info from my memory about 20 years ago. :-) – Donal Fellows Jul 07 '10 at 13:31
  • xD :P Yeah I want to know the basics to pre-modern computing :) -Laying foundations... – ZX81 Jul 07 '10 at 13:31
  • 2
    "I want to know the basics to pre-modern computing " Then Try ZX-Spectrum instead. Much more fun + a good reason to learn a bit of Z80 assembly. you could try to make another driller(http://en.wikipedia.org/wiki/Driller_(video_game)), hard driving(http://en.wikipedia.org/wiki/Hard_driving) or another Elite(http://en.wikipedia.org/wiki/Elite_(video_game)) on spectrum. With text only display you'll be stuck with making rogue-likes(http://en.wikipedia.org/wiki/Roguelike) at best. – SigTerm Jul 07 '10 at 13:42
  • I've already got a ZX81 now xD *I'll see how I get on :) – ZX81 Jul 07 '10 at 13:43
  • Perhaps this helps (if it is still of interest in 2021): [Mastering Machine Code on Your ZX81](http://www.users.waitrose.com/~thunor/mmcoyzx81/index.html). – Gerold Broser Sep 23 '21 at 22:13

3 Answers3

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.

Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93
2

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.

Artelius
  • 48,337
  • 13
  • 89
  • 105
  • Hmmm ok so if I print a black pixel graphic at 10,10 (or any position) 'peek(peek 16398 + 256*peek 16399)' will find the code for a black pixel graphic? – ZX81 Jul 07 '10 at 13:42
  • No, it will find the code for whatever graphic is at the current cursor position. – Artelius Jul 07 '10 at 13:44
  • Cursor position? Huh? :P I never knew ZX81's had mouses or cursors? – ZX81 Jul 07 '10 at 13:45
0

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.

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290