I've been working on this for a while, and I've hit a point where I just don't know what to fix.
I'm working on a metatile routine. Metatile is 2x2 tiles, and it seemed to work alright. However, now I'm working on adding attribute mapping based on the metatile, and it's all messed up.
Here's my metatile attribute routine. The idea is that it's supposed to read the metatile number from the game map in "metascr", and then use that index to lookup the palette number (0 - 3) for the corresponding metatile in "METAattr". Right now, all of the metatiles should be with palette 0 except for the blank sky, #$15, which is palette 01. Then I'm shifting bits to the left, and adding the resulting number to the attribute number I have stored. At the end, I'm writing the number to $2007. I think I'm starting at the right address in $2006, just doing what NerdyNights had.
Var attrtemp is used to store my attribute byte, and var attrx is used to store my X counter before I TAX.
Code: Select all
LoadMETAattr: LDA $2002 ;read PPU to reset high/low latch LDA #$23 STA $2006 ;write hight byte of $23C0 address LDA #$C0 STA $2006 ;write low byte of $23C0 address LDX #$00 LDY #$00 LoadMETAattrLoop: TYX LDA metascr, x ;load data from metatable STX attrx TAX LDA METAattr, x STA attrtemp ;load first attr LDX attrx INX LDA metascr, x STX attrx TAX LDA METAattr, x ASL A ASL A ;multiply second attr by 4 CLC ADC attrtemp STA attrtemp LDX attrx DEX TXA CLC ADC #$10 TAX LDA metascr, x STX attrx TAX LDA METAattr, x ASL A ASL A ASL A ASL A ;multiply third attr by 16 CLC ADC attrtemp STA attrtemp LDX attrx INX LDA metascr, x STX attrx TAX LDA METAattr, x ASL A ASL A ASL A ASL A ASL A ASL A ;multiply fourth attr by 64 CLC ADC attrtemp STA attrtemp STA $2007 INY INY CPY #$10 BNE LoadMETAattrLoop JMP METAattrdone
I know there are multiple things I must be doing wrong. I know this means I'm not handling my reset correctly, but I don't know enough to fix it. Could someone out there walk me through the changes I need to make to apply this correctly? I realize this is a lot to ask.
Attached is the entire ASM file. It's not too huge, based on the NerdyNights week 6, and in ASM6 symtax.
EDIT: Also attached are the CHR and NES files if you want to test it out.