Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best replacement for 'READ/DATA'
#1
I have a scenario in a program I'm converting from Spectrum BASIC to ZX Basic where I need to replace a READ/DATA setup. The code prints messages something like this:

10 restore x: read a, b
20 for n = 1 to b: read i, m$: print ink i; at a+n, 0; m$: next n: return
30 data 10, 3, 6, "test", 7, "test 2", 5, "test 3"

So the code sets 'x' to the DATA row containing the message you want to print (in this case x=30), then you call the subroutine at line 10 which reads the position and number of rows, then loops through 'b' rows reading the ink colour and the message and printing them to the screen.

I need to replace this in ZX Basic with something different. At the minute I've just shoved everything into arrays, but this is very inefficient because I'm effectively storing the data twice so the message bank takes up a lot more memory than it needs to.

What's the 'best' way to do this? I was thinking of maybe having a bunch of DEFB statements to directly replace the DATA lines, terminating each string with a 0 marker. That way I can read the bytes for 'a', 'b' and 'i' easily with PEEKs, and build the messages up by reading until I reach the '0'. I'm not sure how performant that would be, though - is there a faster way to copy a chunk of memory into a string?

Interested to hear any ideas!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)