Does anyone know a little BASIC routine that can detect what character is displayed at a particular PRINT position? I typed in quite an interesting puzzle game from the Nov 1982 Sinclair User, which moves characters around on a 20x26 grid, and the game is pretty good, but has no scoring mechanism or means of detecting when you've finished the puzzle. You have to change the whole grid to "+" symbols, so I need a routine that will...
* Go through the grid, working out which character is displayed at each position
* The grid, by the way, is 26 columns and 20 rows.
* Stopping and jumping out as soon as it finds something that isn't a "+" symbol
* Finishing the game and printing an end message if it gets to the end of the list and finds no different characters.
Any ideas?
Cheers
Lee
ZX81 Character detection
Re: ZX81 Character detection
You'd need to scan the actual display file for that, but you'd need to understand how it works.
The display in the ZX81 is stored row by row for all 24 rows, but not all 32 characters on a row are stored, in order to save memory. If an entire row is empty for example only the end-of-row marker is stored, thus using only 1 byte rather than the 33 which would be required for all 32 characters + the end-of-row marker.
Therefore it should be quite easy to write a small routine which "walks" the display file from the top left, keeping note of which row & column is currently being checked.
The display in the ZX81 is stored row by row for all 24 rows, but not all 32 characters on a row are stored, in order to save memory. If an entire row is empty for example only the end-of-row marker is stored, thus using only 1 byte rather than the 33 which would be required for all 32 characters + the end-of-row marker.
Therefore it should be quite easy to write a small routine which "walks" the display file from the top left, keeping note of which row & column is currently being checked.
Re: ZX81 Character detection
Hi PrimitivePerson,
What Bobs is describing is a collapsed display which is used when the ZX81 has less then 3.25Kb of memory. With enough memory, e.g. 16Kb, the zx81 expands the display to a full 24 X 33 bytes.
In that case, you can use something like this to get the value of a particular screen position:
This is all from memory so that "+ 1" might be wrong. The 'x' variable represents line 0 to 23. The 'y' variable represents the column 0 to 31. If that works, replace x and y with a couple of FOR/NEXT loops.
Happy coding.
thewiz
What Bobs is describing is a collapsed display which is used when the ZX81 has less then 3.25Kb of memory. With enough memory, e.g. 16Kb, the zx81 expands the display to a full 24 X 33 bytes.
In that case, you can use something like this to get the value of a particular screen position:
Code: Select all
10 let a=peek(16396) + (peek(16397) * 256) + 1
20 let b=a+(x*33+y)
30 let c=peek(b)
Happy coding.
thewiz
Memotech rules
Re: ZX81 Character detection
Another way to get the same result:
Enjoy
Code: Select all
10 PRINT AT X,Y;
20 LET C=PEEK (PEEK 16398+256*PEEK 16399)
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Re: ZX81 Character detection
Now that is neat, hat's off! (You can tell I haven't programmed BASIC on an '81 since... well, about 1981 actually!)kmurta wrote:Another way to get the same result:
EnjoyCode: Select all
10 PRINT AT X,Y; 20 LET C=PEEK (PEEK 16398+256*PEEK 16399)