| |
oziphantom
Registered: Oct 2014 Posts: 490 |
LDA (ZP,x)
Has anybody ever used this opcode and if so what for? |
|
... 33 posts hidden. Click here to view all posts.... |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: Quoting lftAnother thing I've had in mind, but never actually implemented, is this: Suppose you're doing something like kefrens bars with open sideborders. You repeat the last line of a row of characters and modify the font on the fly. But in the borders, you repeat sprite data, let's say one sprite on either side. That means you have a single graphics buffer consisting of 46 bytes, but those bytes are distributed somewhat irregularly in RAM. So make a table in zp consisting of 46 pointers to them. Then use (zp,x) in the drawing operations. You can even access neighbouring cells with (zp-2,x) and (zp+2,x). You can do this, but it wastes a lot of cycles. You'd only do it like this if you're under serious memory constraints... :)
Under normal demo conditions (almost all 64K available) you'd have as many chunks of unrolled optimised code as you have bar X positions. Then you'd execute one of those in each rasterline of the effect.
And chain them on the stack? for at least the first 100 lines, and do RTS,RTS,RTS,RTS....? :D |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
jmp ($xcoo*2) ?:) |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: jmp ($xcoo*2) ?:)
Where to jump back? Nah.. chaining.. For every second line, 7-color bars that might just be feasible and perhaps will give you another char in width. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
jackie wins.. :) |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quoting MagerValpIt's one of those "seemed like a good idea at the time" opcodes. Everyone would have been happier if we got (ZP),x instead. Indeed. But let's see what it could be useful for.
Assuming no self-modification is feasible (think of ROM code), i can think of accessing data buckets using this addressing mode.
In zeropage, there'd be an array of pointers. Find some (even) value of X which determines the bucket to use. Then either push something into it (STA (buckets,x):INC buckets,x:BNE *+4:inc buckets+1,x) or pull something from it (analogous, but decrease pointer first). |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quoting JackAsserAnd chain them on the stack? for at least the first 100 lines, and do RTS,RTS,RTS,RTS....? :D Not quite. Check out my Kefrens bars in Singles Collection Volume 2 :D |
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
I can't count the number of times I've consider this opcode and thought to myself that "hmm.. maybe I could use this one for this or that purpose", but *always* ended up finding some other better solution instead. :) Couldn't even find cases where it was equally good as some other solution, so I could use it just for the sake of using it. The solutions involving this opcode were always worse. :) |
| |
Bob
Registered: Nov 2002 Posts: 71 |
I use (zp,x) for scroll writes in the definer parts.
each row has its own izp addr.. and with variable X I can have the scroll text output starting on different rows.
or even change per frame if I want to.. |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quoting BobI use (zp,x) for scroll writes in the definer parts.
each row has its own izp addr.. and with variable X I can have the scroll text output starting on different rows.
or even change per frame if I want to.. This pretty much sounds like a practical implementation of my buckets theory i mentioned above :D |
| |
Hypnosis
Registered: Mar 2015 Posts: 36 |
I have only used it to waste cycles I think. The major shortcoming is that it can only access one byte per pointer. lda (zp,x),y could be interesting. |
Previous - 1 | 2 | 3 | 4 | 5 - Next |