News:

11 March 2016 - Forum Rules

Main Menu

65c816 - WLA Question

Started by Mikey88, October 24, 2012, 01:50:44 AM

Previous topic - Next topic

Mikey88

Hello RHDN!
I am new to 65c816 ASM and I am having trouble understanding this bit of code.

.MACRO LoadPalette
    lda #\2
    sta $2121       ; Start at START color
    lda #:\1        ; Using : before the parameter gets its bank.
    ldx #\1         ; Not using : gets the offset address.
    ldy #(\3 * 2)   ; 2 bytes for every color
    jsr DMAPalette
.ENDM

It is not so much the code I am having trouble with, I understand it is a Macro to load the palette data with a DMA transfer. I do not understand what is being stored to A, X, and Y, with these #\ - #\:  prefixes. I know # stands for an immediate value, but have never come across the \ . \: part. I see the comments say #:\1 gets the bank and #\1 gets the offset I am just unclear on what 1 is.

Thank,
Mikey

Revenant

\1, \2, and \3 are the macro's parameters. From the example, \1 is the 24-bit address to load from, \2 is the palette index to write to, and \3 is the number of palette entries to load. So, for example, if you had an array of 16 colors at the address $018000 and you wanted to use those as the first 16 palette entries, you would invoke the macro like this:

LoadPalette $018000, 0, 16 ; load palette entries 0-15 from $018000

which would expand to:

lda #0
sta $2121
lda #$01
ldx #$8000
ldy #32         ; 2 bytes per color
jsr DMAPalette


Hope that makes sense.

Mikey88

Thank you! Excellent explaination I understand now, I had searched forever trying to figure this out. Much appericiated.

furrykef

WLA is a heap of garbage and should not be used. I learned this the hard way, and had progress on a hack grind to a halt because of a bizarre bug in the assembler that I could not (and did not want to) figure out how to work around. Even before then, I found numerous other bugs. It crashes if you .include a blank file, for instance.

I've since started coding my own assembler, but you'll probably want to find another existing assembler (xkas 0.06 and forks of it are popular) instead of waiting for me to get around to finishing mine.

Mikey88

Quote from: furrykef on November 20, 2012, 06:10:09 AM
WLA is a heap of garbage and should not be used. I learned this the hard way, and had progress on a hack grind to a halt because of a bizarre bug in the assembler that I could not (and did not want to) figure out how to work around. Even before then, I found numerous other bugs. It crashes if you .include a blank file, for instance.

I've since started coding my own assembler, but you'll probably want to find another existing assembler (xkas 0.06 and forks of it are popular) instead of waiting for me to get around to finishing mine.

Thanks for the suggestion. I was reading through tutorials and the author was using WLA so everything I have learned and have on my computer is with WLA, and I am starting to get kind of comfortable with it, so I'm sticking with it for now but once I start to get the hang of things more I will take a look at xkas.

LostTemplar

Quote
xkas

These days I like bass more.

Mikey88

Quote from: LostTemplar on November 25, 2012, 04:13:30 AM
These days I like bass more.

I have never heard of that one until now. Just did a quick search on it, not a lot of documentation. One of the reasons I like WLA a lot is that massive readme (although it did not help with my question in the first post).