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


Forums > C64 Coding > Updating sprite X msb
2016-03-26 16:50
ChristopherJam

Registered: Aug 2004
Posts: 401
Updating sprite X msb

Slack bastard time. Recs for updating $d010 if I've got an eight bit x-position in my object table, but all my sprites are offset a constant number of pixels to the right? Current draft is this:
	clc
	lda mobX,x
	adc xoffset
	sta $d000,y
	lda #0
	adc #255
	eor #255
	eor $d010
	and hibit,x
	eor $d010
	sta $d010

(x is both object ID and sprite number (I'll change how I index mobX later), y is double the sprite number. hibit contains 2**i)
 
... 4 posts hidden. Click here to view all posts....
 
2016-03-26 19:43
The Human Code Machine

Registered: Sep 2005
Posts: 99
It's faster to unroll the code:

lda mobX
clc
adc xoffset
sta $d000
ror xhi
lda mobX+1
clc
adc xoffset
sta $d002
ror xhi

and so on

lda xhi
sta $d010
2016-03-26 19:49
Color Bar

Registered: Oct 2012
Posts: 62
Quoting The Human Code Machine
It's faster to unroll the code:

lda mobX
clc
adc xoffset
sta $d000
ror xhi
lda mobX+1
clc
adc xoffset
sta $d002
ror xhi

and so on

lda xhi
sta $d010


Nice! Yes, and you can use zeropage for xhi :-)
2016-03-26 19:55
The Human Code Machine

Registered: Sep 2005
Posts: 99
Yes, but it's only one cycle faster.
2016-03-26 21:25
ChristopherJam

Registered: Aug 2004
Posts: 401
Quoting Color Bar
When you update all sprites in one loop, you may update $d010 as follows..


Ah yes, I should probably have mentioned that my use case is a multiplexer component; for the first eight sprites I will indeed shift the bits in one by one.
2016-03-27 09:46
Hoogo

Registered: Jun 2002
Posts: 76
I wonder if that multiplexer reuses the sprites in order, so that for every call y will increased by 2 and start with 0 again? Not sure if that can make a difference, just thinking...
I guess offset is variable and not available when mobX is generated?
And are you already in need of rastertime, or is it just about making this a little more pretty?
	clc
	lda mobX,x
	adc xoffset
	sta $d000,y
	lda $d010
	bcc clear
	ora hibit,y
	bcs store
clear	and hibit+1,y
store	sta $d010
hibit	!by 1, 255-1, 2, 255-2, 4, 255-4...
2016-03-27 10:26
Hein

Registered: Apr 2004
Posts: 725
8 pieces of code to jump to, all other stuff is done outside multiplexer. Y holds the current list index.

    lax (sprite_index_lo),y
    lda sprite_y,x
    sta $d001
    lda sprite_x,x
    sta $d000
    lda sprite_a,x
    sta screen+$3f8
    cmp sprite_x_msb,x	;$00 if cleared, $ff if set
    lda $d010
    and #%11111110
    bcs +
    ora #%00000001
+   sta $d010
    lda sprite_c,x
    sta $d027
2016-03-27 10:39
Color Bar

Registered: Oct 2012
Posts: 62
2016-03-27 11:59
Color Bar

Registered: Oct 2012
Posts: 62
Quoting Hoogo
I wonder if that multiplexer reuses the sprites in order, so that for every call y will increased by 2 and start with 0 again? Not sure if that can make a difference, just thinking...



If you can use a separate piece of code for each sprite, maybe you could do (for example for sprite 3)?
clc
lda mobX+3
adc xoffset
sta $d006
lda $d010
and #f7 ; clear first
bcc store
ora #$08
store
sta $d010
2016-03-27 14:23
Skate

Registered: Jul 2003
Posts: 425
Quote: Quoting Hoogo
I wonder if that multiplexer reuses the sprites in order, so that for every call y will increased by 2 and start with 0 again? Not sure if that can make a difference, just thinking...



If you can use a separate piece of code for each sprite, maybe you could do (for example for sprite 3)?
clc
lda mobX+3
adc xoffset
sta $d006
lda $d010
and #f7 ; clear first
bcc store
ora #$08
store
sta $d010


I remember writing a macro like this one, using sprite number as a parameter and generating these and/or values according to the number. this way code looks fine, things speed up, memory usage sucx, speed rocx. :)
2016-03-27 19:50
Color Bar

Registered: Oct 2012
Posts: 62
Quoting Color Bar

If you can use a separate piece of code for each sprite, maybe you could do (for example for sprite 3)?

Now I look more carefully I see that this is what Hein is doing ...
Previous - 1 | 2 - 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
fegolhuzz
Dymo
SAM
ZeSmasher/F4CG/ATL
Flex/Artline Designs
Groepaz/Hitmen
Guests online: 17
Top Demos
1 Uncensored  (9.7)
2 Coma Light 13  (9.7)
3 Edge of Disgrace  (9.7)
4 Comaland  (9.6)
5 Comaland 100%  (9.6)
6 Wonderland XII  (9.5)
7 Fantasmolytic  (9.5)
8 Rocketry  (9.5)
9 We Are Demo  (9.4)
10 +H2K  (9.4)
Top onefile Demos
1 Treu Love [reu]  (9.5)
2 Daah, Those Acid Pil..  (9.4)
3 Dawnfall  (9.3)
4 One-Der  (9.2)
5 Hardware Accelerated..  (9.2)
6 MD201605  (9.1)
7 Safe VSP  (9.1)
8 Goatbeard  (9.1)
9 Black Magic  (9.0)
10 Te-Te-Te-TechTech It..  (9.0)
Top Groups
1 Censor Design  (9.4)
2 Booze Design  (9.4)
3 Crest  (9.4)
4 Oxyron  (9.4)
5 Nostalgia  (9.2)
Top Original Suppliers
1 Fungus  (9.4)
2 Derbyshire Ram  (9.3)
3 hedning  (9.2)
4 Jazzcat  (9.1)
5 Irata  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2016
Page generated in: 0.222 sec.