| |
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.... |
| |
lft
Registered: Jul 2007 Posts: 369 |
Here's another idea: In a sprite multiplexer, there are some things you need to update in registers that are spaced two bytes apart (x and y coords), and some things that are in consecutive locations (pointers in the vm, colour registers). If we keep the sprite number times two in x, we can access the coordinate registers using ordinary indexed addressing, and then we can have tables of addresses in zero-page for the colour registers, and for the sprite pointers of each vm, and update those values with the (zp,x) addressing mode. |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Could the TAS opcode be useful for a multiplexer somehow too? For example, suppose you have a bunch of "objects" and have stored some properties (colors or positions, for instance) on the stack. You could access those by
lax #objectnum
tas $fe00,y
If you let y contain the actual spritenumber to which you want to assign the object with number #objectnum, then the store operation of TAS could be useful.
Sorry that this is not very concrete, but I don't have much experience with multiplexers. |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
Quote:
Here's another idea: In a sprite multiplexer, there are some things you need to update in registers that are spaced two bytes apart (x and y coords), and some things that are in consecutive locations (pointers in the vm, colour registers). If we keep the sprite number times two in x, we can access the coordinate registers using ordinary indexed addressing, and then we can have tables of addresses in zero-page for the colour registers, and for the sprite pointers of each vm, and update those values with the (zp,x) addressing mode.
Smart idea, that's probably the most useable solution. |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quoting lftand update those values with the (zp,x) addressing mode. I have a hunch that under normal demo conditions (TM), self-modifying and unrolled code will gain more. Also, one half of the "hot" sprite registers are in consecutive locations (colours, pointers) while the other half are not (x and y co-ordinates) - so 50% of those accesses when updating the "physical" sprites will be slower due to the extra indirection via ZP pointers. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
usually a plexer writes sprites in a fixed order, thus it can be unrolled. one excetion I know of cadaver's BOFH which assigns priority to virtual sprites and tries to pick a HW sprite based on that. |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
Yes, the multiplexer can surely be speedcoded with better performance.
Yet, among the proposed solutions, this use of (zp,x) is imho one of the most sensible. This and (zp)-like, when X is known. |
| |
Skate
Registered: Jul 2003 Posts: 494 |
Not directly ZP,x related but recently i moved one of my effect loops to zeropage. When you run your code at zeropage, you have interesting cycle saving method alternatives. For instance if we need to do something like;
ora $xxxx
sta $xxxx
using
lda #<xxxx
sta lo1
sta lo2
lda #>xxxx
sta hi1
sta hi2
is a big waste. Instead we prefer;
lda #<xxxx
sta zp
lda #>xxxx
sta zp+1
ora (zp),y
sta (zp),y
right? If index is not required;
...
ora (zp,x)
sta (zp,x)
would be fine as well. But if your code itself is running on ZP;
lda #<xxxx
sta addr
lda #>xxxx
sta addr+1
ora $xxxx,y : addr = *-2
sta (addr),y ; or sta (addr,x) if suitable
is a nice method to save some cycles. |
| |
Monte Carlos
Registered: Jun 2004 Posts: 359 |
It can be used for text scrollers with varying y-pos to fill in the rightmost char if addresses are prepared in zp |
| |
oziphantom
Registered: Oct 2014 Posts: 490 |
If they just could have saved the metal on putting it on the LDA, STA, ORA, CMP etc ZP instructions put put it on
JMP( XXXX,x ) instead.
Or yes LDA ( ZP,x ),y would also be very handy.
What does TAS do? |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Quoting oziphantomIf they just could have saved the metal on putting it on the LDA, STA, ORA, CMP etc ZP instructions put put it on
JMP( XXXX,x ) instead.
Or yes LDA ( ZP,x ),y would also be very handy.
What does TAS do?
A complete description of TAS and other undocumented opcodes can be found here
No More Secrets v0.9 |
Previous - 1 | 2 | 3 | 4 | 5 - Next |