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 > One more KickAssembler question please
2007-09-27 14:01
cbmeeks

Registered: Oct 2005
Posts: 78
One more KickAssembler question please

How can I pass the X, Y or A into a macro?

ldx #14

:DrawTimeXY( screenbuffer, "value of X", 0, 1)

.macro DrawTileXY( buffer, x, y, tile )
{
	// save X,Y,A 
	sta	TMP_A
	stx	TMP_X
	sty	TMP_Y
	
	ldx	#tile
	lda	T1,x
	sta	[buffer + [[y * 40] + x]]
	lda	T2,x
	sta	[buffer + [[y * 40] + x + 1]]
	lda	T3,x
	sta	[buffer + [[[y + 1] * 40] + x]]
	lda	T4,x
	sta	[buffer + [[[y + 1] * 40] + x + 1]]
	
	// restore X,Y,A
	lda	TMP_A
	ldx	TMP_X
	ldy	TMP_Y
}


Thanks!

METROID
http://www.metroidclassic.com
2007-09-27 14:33
Stainless Steel

Registered: Mar 2003
Posts: 966
Im not trying to be a prick, but wouldn't it be better if you
posted all these kickassember related questions into one and
the same thread instead of opening a new one each time ?

Just a thought.
2007-09-27 14:37
Scout

Registered: Dec 2002
Posts: 1570
Quote: Im not trying to be a prick, but wouldn't it be better if you
posted all these kickassember related questions into one and
the same thread instead of opening a new one each time ?

Just a thought.


That, and choose a better thread subject next time. Just for searching purposes.
And I'm trying to be prick here :P
2007-09-27 15:06
cbmeeks

Registered: Oct 2005
Posts: 78
Sorry guys.

Go ahead. Bash the new guy. Ruin my spirit. I will just move over to the Speccy!

METROID
http://www.metroidclassic.com
2007-09-27 15:49
Oswald

Registered: Apr 2002
Posts: 5094
I think you are mixing the runtime and assembling-time codings here. y*40+x should be done at runtime as y*40+x in your macro will be evaluated only when assembling, and it will be a constant value in the final code.the best way would be to have a fully unrolled precalculated code for each side of the screen where new data can enter. also you should try to think more low level. storing and restoring a,x,y each time you plot a tile is a bad idea speedwise. you better forget about local variables and similar modern concepts, when you're going for speed.
2007-09-27 16:19
cbmeeks

Registered: Oct 2005
Posts: 78
Quote: I think you are mixing the runtime and assembling-time codings here. y*40+x should be done at runtime as y*40+x in your macro will be evaluated only when assembling, and it will be a constant value in the final code.the best way would be to have a fully unrolled precalculated code for each side of the screen where new data can enter. also you should try to think more low level. storing and restoring a,x,y each time you plot a tile is a bad idea speedwise. you better forget about local variables and similar modern concepts, when you're going for speed.

Yeah, I have seen that problem already. Sometimes I forget that runtime and compile time are different....lol (not really but sometimes it seems that way).

Normally I don't save the registers. It just really depends on what I am doing. My DrawTileXY isn't meant for speed. It will only be used in the initial draw screen.

I guess I will just have to figure out a better way to keep from doing so much unrolling.

Thanks


METROID
http://www.metroidclassic.com
2007-09-27 16:55
Stainless Steel

Registered: Mar 2003
Posts: 966
Quoting cbmeeks
Go ahead. Bash the new guy. Ruin my spirit. I will just move over to the Speccy!


Hey, that was us being friendly.

We haven't even warmed up yet.

2007-09-27 17:03
cbmeeks

Registered: Oct 2005
Posts: 78
Quote: Quoting cbmeeks
Go ahead. Bash the new guy. Ruin my spirit. I will just move over to the Speccy!


Hey, that was us being friendly.

We haven't even warmed up yet.



I kinda figured that. Just remember, I have two teenage step daughters and a 3 year old son. I can take anything.

lol


METROID
http://www.metroidclassic.com
2007-09-27 18:56
Stainless Steel

Registered: Mar 2003
Posts: 966
Big words, we've heard them before. don't underestimate us :-D
2007-09-27 19:31
WVL

Registered: Mar 2002
Posts: 902
Ofcourse there's a better way than simply unrolling.. It's called indirect indexing.

f.e. you set the adress you want to write to in zp-adresses $fb/$fc (f.e. $0400 -> #$00 in $fb, #$04 in $fc)

then you can write values to $0400,y by doing

sta ($fb),y

by changing y from 0...255 you can write anywhere from $0400 to $04ff.
2007-09-27 19:44
Oswald

Registered: Apr 2002
Posts: 5094
should look something like this:

lda #<screen
sta $fe
lda #>screen
sta $ff

lda #<tilescreen
sta $fa
lda #>tilescreen
sta $fb

lda #0
sta x

horizontalloop

ldy #$00
lax ($fa),y ;lda ($fa),y tax if you dont like illegals

lda t1,x
ldy #$00
sta ($fe),y
lda t2,x
ldy #$01
sta ($fe),y
lda t3,x
ldy #$28
sta ($fe),y
lda t4,x
ldy #$29
sta ($fe),y

lda $fe
clc
adc #$02
sta $fe
bcc *+4
inc $ff

inc $fa
bcc *+4
inc $fb

inc x
lda x
cmp #20
bne horizontalloop

etc...
2007-09-27 20:02
cbmeeks

Registered: Oct 2005
Posts: 78
@WVL, Oswald

Thanks! I will look into that some more. Believe it or not, this is all starting to come back to me. I guess I just needed a jolt. I can't wait to start cracking on this tonight.


METROID
http://www.metroidclassic.com
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
psych
Thierry
Raf/Vulture Design
Guests online: 108
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 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

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