Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > LDA (ZP,x)
2016-05-16 14:31
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....
 
2016-05-17 11:12
Oswald

Registered: Apr 2002
Posts: 5094
jackie wins.. :)
2016-05-17 11:14
Krill

Registered: Apr 2002
Posts: 2980
Quoting MagerValp
It'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).
2016-05-17 11:34
Krill

Registered: Apr 2002
Posts: 2980
Quoting JackAsser
And 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
2016-05-17 11:48
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. :)
2016-05-17 13:36
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..
2016-05-17 15:18
Krill

Registered: Apr 2002
Posts: 2980
Quoting Bob
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..
This pretty much sounds like a practical implementation of my buckets theory i mentioned above :D
2016-05-17 16:28
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.
2016-05-17 19:08
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.
2016-05-17 19:39
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.
2016-05-18 07:50
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.
Previous - 1 | 2 | 3 | 4 | 5 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
csabanw
Flex/Artline Designs
Magic/Nah-Kolor
psych
Guests online: 110
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.057 sec.