I'm a total newbie in regards to programming in general, but I Think I've managed to get pretty far in my kindergarten understanding of assembler and the behaviour of the hardware. I have also 'graduated' from NESASM to ASM6.
My current problem is that the pointers I initialize to the palette and attribute doesn't work.
As far as I can see the problem is only related to the pointers and indirect addressing. If I change the code to directly access the addresses of the palette and attributes it works without problem.
When I look at the listing I cant find any obvious errors in the code. Are there aspects that I have missed?
Code: Select all
;my pointers in zp
00015 screenpointer .dsb 2
00017 palpointer .dsb 2
00019 attributespointer .dsb 2
;the pointers populated in the end of reset, the first one works.
0C03C A9 9C LDA #<LevelData + 32 ;set pointer to map data
0C03E 85 17 STA screenpointer + 0
0C040 A9 C5 LDA #>LevelData
0C042 85 18 STA screenpointer + 1
0C044
0C044 A9 6B LDA #<Palettes ;set pointer to Palettes at address $C36B
0C046 85 0E STA palpointer + 0
0C048 A9 C3 LDA #>Palettes
0C04A 85 0F STA palpointer + 1
0C04C
0C04C A9 FC LDA #<AttributesDefinitions ;set pointer to attributes
0C04E 85 0C STA attributespointer + 0
0C050 A9 C5 LDA #>AttributesDefinitions
0C052 85 0D STA attributespointer + 1
0C054
0C054 4C 70 C0 JMP TitleScreenStart
;code
;...
0C2ED LoadPalettes:
0C2ED AD 02 20 LDA $2002
0C2F0 A9 3F LDA #$3F
0C2F2 8D 06 20 STA $2006
0C2F5 A9 00 LDA #$00
0C2F7 8D 06 20 STA $2006
0C2FA A2 00 LDX #$00
0C2FC -:
0C2FC B5 0E LDA (palpointer), x ; load data from address in pointer + x
0C2FE 8D 07 20 STA $2007
0C301 E8 INX
0C302 E0 20 CPX #$20
0C304 D0 F6 BNE -
0C306 60 RTS
;code
;...
0C36B Palettes:
0C36B 0F 21 0C 38 0F 00 10 30.. .db $0F,$21,$0C,$38, $0F,$00,$10,$30, $0F,$07,$38,$2B, $0F,$16,$30,$22 ;background pal
0C37B 0F 16 27 02 0F 02 38 3C.. .db $0F,$16,$27,$02, $0F,$02,$38,$3C, $0F,$1C,$15,$14, $0F,$02,$38,$3C ;sprite pal