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-16 19:31
Oswald

Registered: Apr 2002
Posts: 5095
lft, ace idea ! :)
2016-05-16 19:59
Slammer

Registered: Feb 2004
Posts: 416
I think the (zp,x) idea have already been used for kefrensbars. I don't remember which demo but I guess it was one from Booze.
2016-05-17 04:30
Skate

Registered: Jul 2003
Posts: 495
I just checked my source codes directory. I've used it a few times.

In Snapshot / Glance demo's horizontal raycaster part uses something like;

	lax DATAS,y
	sta (MAP_POINTER,x)
	lda tColor,x
	ldx #$00
	sta (COLOR_POINTER,x)


So, first one really uses x as an index and second one uses x as a zero, more likely a sta(ZP). Of course this is in a loop and y register should not be affected.

This is from one of my unreleased codes;

	lax $c0 ; lda #0 : ldx #0
	sta (copyTo,x)


Just put a zero to the address pointed at copyTo. $c0 already had a zero of course.

This one is from my recent sierpinski entry.

	lax $02
	sec
-	ror
	dey
	bpl -
	ora (plotAddress,x)
	sta (plotAddress,x)


I think what is does is clear.

And last but not least, this is one of my stable raster routines to wait for 8 cycles at some point.

	sre ($ff,x)
2016-05-17 07:27
ready.

Registered: Feb 2003
Posts: 441
Useful when you need to use zero page pointers but want to preserve y, for example:

ldy whatever
ldx #0
lda (ZP0),y
sta (ZP1,x)

I use this when moving data from one area to another one.
2016-05-17 08:07
soci

Registered: Sep 2003
Posts: 481
It's more popular in some forth implementations where the data stack is on zero page and is not split.
2016-05-17 08:25
Oswald

Registered: Apr 2002
Posts: 5095
Quote: Useful when you need to use zero page pointers but want to preserve y, for example:

ldy whatever
ldx #0
lda (ZP0),y
sta (ZP1,x)

I use this when moving data from one area to another one.


god no! why? thats butt ugly and there are numerous ways round that preserve X instead of Y or selfmod.ű


moving data efficiently

ldx #0
ldy #numofpages

-
lda src,x
sta dst,x
dex
bne -

inc srcaddrhi
inc dstaddrhi
dey
bne -
2016-05-17 11:06
Krill

Registered: Apr 2002
Posts: 2982
Quoting lft
Another 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.
2016-05-17 11:10
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Quoting lft
Another 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
2016-05-17 11:11
Oswald

Registered: Apr 2002
Posts: 5095
jmp ($xcoo*2) ?:)
2016-05-17 11:12
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.
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
MWR/Visdom
Dano/Padua
Didi/Laxity
BYB/Hokuto Force
MCM/ONSLAUGHT
BlackJack/Civitas
Guests online: 132
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.6)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 The Demo Coder  (9.6)
8 Comaland 100%  (9.6)
9 What Is The Matrix 2  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 Morph  (9.5)
7 Dawnfall V1.1  (9.5)
8 Libertongo  (9.5)
9 Katzen-Video.mp4  (9.5)
10 Onscreen 5k  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Diskmag Editors
1 Magic  (10)
2 Jazzcat  (9.5)
3 hedning  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.052 sec.