Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading, storing and writing screen values
#2
oblo Wrote:Hi all

I'm starting to learn how to manipulate screen directly at memory address level. Right now, I'm messing with this code

Questions are:

- Are there any better options to read and write given a X and Y coordinates?
- What is the best way to storage screen memory addresses and their values? Integer (for addresses) and Ubyte (for values) arrays, right?

Thanks and regards

I'm glad you found the routines in the library useful!

Those are about as fast as you can get, short of using screen lookup tables, which I think I've discussed elsewhere (and used a lot!). Lookup tables are the fastest way to get screen addresses.

When writing to a whole character square, you write to address, address+256, address+512 etc. This is a bit slow in basic. In raw machine code it's much easier - you point HL at the screen, write to address HL, and then increment H. One instruction, 4 T states, and you're at the next row of a character. This optimization is the reason the screen display appears so oddly laid out at first glance. (Sometimes it's easier to think of it as three long long long rows of 256 characters wide)

In essence, then, poking the screen like this, because of the address overhead (+256 is probably not well optimized), it's likely to be slower than a dedicated drawing routine. Fortunately, there are quite a lot of those in the library in machine code as well - that write to full character squares as is.

As for the other questions:

Yes - if you need an address in memory, it's a uInteger. If you're storing the contents of an address, it's a ubyte.

But if you're manipulating the screen, you probably want a specialised routine in assembler - as you have here for attr address and screen addresses.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)