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: 72
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
 
... 1 post hidden. Click here to view all posts....
 
2007-09-27 14:37
Scout

Registered: Dec 2002
Posts: 1568
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: 72
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: 5017
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: 72
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: 72
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: 886
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: 5017
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: 72
@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
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
taper/ΤRIΛD
MightyAxle
Flex/Artline Designs
Didi/Laxity
Guests online: 107
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Vincenzo  (9.8)
2 Rob Hubbard  (9.7)
3 Stinsen  (9.7)
4 Jeroen Tel  (9.6)
5 Linus  (9.6)

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