News: 11 March 2016 - Forum Rules

Author Topic: 65c816 - WLA Question  (Read 4502 times)

Mikey88

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
65c816 - WLA Question
« on: October 24, 2012, 01:50:44 am »
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

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: 65c816 - WLA Question
« Reply #1 on: October 24, 2012, 04:18:10 am »
\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:

Code: [Select]
LoadPalette $018000, 0, 16 ; load palette entries 0-15 from $018000
which would expand to:

Code: [Select]
lda #0
sta $2121
lda #$01
ldx #$8000
ldy #32         ; 2 bytes per color
jsr DMAPalette

Hope that makes sense.

Mikey88

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: 65c816 - WLA Question
« Reply #2 on: October 24, 2012, 04:59:17 am »
Thank you! Excellent explaination I understand now, I had searched forever trying to figure this out. Much appericiated.

furrykef

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: 65c816 - WLA Question
« Reply #3 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.

Mikey88

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: 65c816 - WLA Question
« Reply #4 on: November 24, 2012, 07:27:37 pm »
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

  • Hero Member
  • *****
  • Posts: 910
    • View Profile
    • au-ro-ra.net
Re: 65c816 - WLA Question
« Reply #5 on: November 25, 2012, 04:13:30 am »
Quote
xkas

These days I like bass more.

Mikey88

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: 65c816 - WLA Question
« Reply #6 on: November 26, 2012, 05:36:37 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).