1

I have a NES game in the making. I am defining several constants to help me with managing sprites. I have

spriteyposition = $0200
spritetile = $0201
spriteattribute = $0202
spritexposition = $0203
sprite1 = $00
sprite2 = $04
sprite3 = $08
sprite4 = $0c
sprite5 = $10
sprite6 = $14
sprite7 = $18
sprite8 = $1c

My use case is as follows:

I want to modify the y position of sprite 1

I do:

ldx sprite1
lda spriteyposition, x
adc #$8
sta spriteyposition, x

In my use case spriteyposition should be a memory pointer, but i have a feeling that the assembler is treating it as a regular number

How do I refer to spriteyposition as a memory address and not a number?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
frogstair
  • 444
  • 5
  • 20
  • What are you hoping `lda spriteyposition, x` will do? An indexed load into the accumulator, with the addressing mode using the `x` register plus `0x0200` as an immediate part of the address? – Peter Cordes Jun 22 '19 at 21:11

1 Answers1

6

In my use case spriteyposition should be a memory pointer, but i have a feeling that the assembler is treating it as a regular number

Your feeling is incorrect. This code assembles to the intended opcode BD (LDA ABS,x) -- there is no IMM,x addressing mode.

What is incorrect is

ldx sprite1

sprite1 is defined as $00, so this ends up loading X with the value of the address $0000. What you want is ldx #sprite1.