| |
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 |
|
... 1 post hidden. Click here to view all posts.... |
| |
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 |
| |
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 |
| |
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. |
| |
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 |
| |
Stainless Steel
Registered: Mar 2003 Posts: 966 |
Quoting cbmeeksGo 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.
|
| |
cbmeeks
Registered: Oct 2005 Posts: 78 |
Quote: Quoting cbmeeksGo 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 |
| |
Stainless Steel
Registered: Mar 2003 Posts: 966 |
Big words, we've heard them before. don't underestimate us :-D |
| |
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. |
| |
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... |
| |
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 |
Previous - 1 | 2 - Next |