0

I am new to CA65 and am trying to transfer a NESASM project over to it. I translated everything and it builds. When I run I get nothing. Just a black screen. Diving deeper I have an infinite loop. It seems to be having an issue with increasing the Y (INY) and then whatever I set after it doesn't take. enter image description here

You can see that after INY at 8505 Y becomes 1. Setting the variable I have at $84A8 to Y should change it to $01 but it doesn't. Because of this, I enter an infinite loop. Am I doing something wrong here? It has been a bit since I have programmed assembly but this seems pretty easy.

Let me know if I am doing something wrong or you need more information.

Michael
  • 57,169
  • 9
  • 80
  • 125
theBrilliance
  • 61
  • 1
  • 7
  • 2
    _"the variable I have at $84A8"_. Which mapper are you using? IIRC all commonly used mappers have ROM (and possibly mapper control registers) at $8xxx. – Michael Dec 07 '21 at 09:03
  • Thank you for your response. I should be using Mapper 0 for now, that's what I was using in NESASM. And that is a good point. I guess the thing I don't understand is how we control where in memory our variables get assigned with CA65. I know that I have some pointer variables in the "ZEROPAGE" segment because that is where they need to be. But the rest of my variables are in the "CODE" segment which is where I thought they needed to be. I thought the linker handled memory placement outside of that. I suppose I need to do more research on CA65. – theBrilliance Dec 07 '21 at 14:24
  • 1
    The CODE segment will be in ROM. For variables you should probably use the DATA or BSS segment. – Michael Dec 07 '21 at 16:38
  • 1
    If you're using Mapper 0, you've got the ```$0000-$07FF``` range as your RAM, and that's all you get. Everything else is either ROM or hardware registers. – puppydrum64 Jul 22 '22 at 13:56
  • Now some mappers actually do require you to write to ROM to do certain things (such as the VRC6 and its additional sound hardware) but Mapper 0 is not one of them. – puppydrum64 Feb 06 '23 at 15:38

1 Answers1

1

You need to make sure that your variables are in writable memory.

The NES normally has 2KB of RAM, so you're better off using addresses below $0800.

Because you're writing to $84a8, you're not actually saving the register to any memory because that address is mapped to ROM. So that location will not actually change.

Lorraine
  • 1,189
  • 14
  • 30