Ca65 MMC3 Parallax NES Demo Cart

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
Atomfusion
Posts: 7
Joined: Sat Apr 23, 2022 5:48 pm

Ca65 MMC3 Parallax NES Demo Cart

Post by Atomfusion »

Ok so I’m two weeks into my programming and have been working on MMC3 Cart
I have a Demo with Ripped Graphics which includes.
1. Selectable PRG ROM Banks (Changes Background Color)
2. Scrolling IRQ With 4 layers of Parallax Ground
3. CHR Bank Switching with Clouds
You can Fly around the screen shoot a fireball and watch the world go by , no collision or enemy’s yet
It Reminds me a lot of UN Squadron for the SNES
https://github.com/Atomfusion1/NES_MMC3 ... axing_Demo

1.
  • I had a Problem I spent almost 8 hours on before I gave up, All I wanted to do was use the IRQ to change a Single Main BG Color from one to another, and I could do it as long as I did not load a full background scene (maybe just a happy little cloud) but any more than that and the BG graphics would blow up all over the screen. I think this is because I write to 2006 but in the forums I find where people say that it can be done, Mesen would not let me do it, Is there a way? or just best to stay away from it ?
I have a few questions,
  • 1. For People experienced with Ca65 How do I pass CPU internal Accumulator, X, Y into a .macro ?
    2. I have been working on .macro to make the code more C like with simple Commands like M_FORLOOP ; M_IfEqual ; M_Else ; M_EndIf etc. This helps to make the code almost readable again and also, easy to find places to add / change functionality. Question is are there Downfalls to what I am doing that I should watch out for with Ca65?
    3. Anyone see anything in the code that I should just stop or change how I’m doing it now? maybe with an example?
ParallaxSmall.gif
Thanks for your time
User avatar
Movax12
Posts: 541
Joined: Sun Jan 02, 2011 11:50 am

Re: Ca65 MMC3 Parallax NES Demo Cart

Post by Movax12 »

Atomfusion wrote: Sat Apr 30, 2022 5:20 pm
I have a few questions,
  • 1. For People experienced with Ca65 How do I pass CPU internal Accumulator, X, Y into a .macro ?
Can you expand on what you mean?
Atomfusion wrote: 2. I have been working on .macro to make the code more C like with simple Commands like M_FORLOOP ; M_IfEqual ; M_Else ; M_EndIf etc. This helps to make the code almost readable again and also, easy to find places to add / change functionality. Question is are there Downfalls to what I am doing that I should watch out for with Ca65?
Maybe check this out: https://gitlab.com/ca65/ca65hl
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Ca65 MMC3 Parallax NES Demo Cart

Post by rainwarrior »

Atomfusion wrote: Sat Apr 30, 2022 5:20 pm1. I had a Problem I spent almost 8 hours on before I gave up, All I wanted to do was use the IRQ to change a Single Main BG Color from one to another, and I could do it as long as I did not load a full background scene (maybe just a happy little cloud) but any more than that and the BG graphics would blow up all over the screen. I think this is because I write to 2006 but in the forums I find where people say that it can be done, Mesen would not let me do it, Is there a way? or just best to stay away from it ?
Trying to change the palette in the middle of the screen is a hard problem on NES. It can be done, but it's one of the trickier things to get right.

If you're new, yeah it's maybe something that would be better left until you've got more experience. Otherwise, if you want a starting point, maybe try Mesen's event viewer and take a look at the title screen of Indiana Jones and the Last Crusade (Taito).

On every line with a background colour change you'll see in the event viewer:
  • $2006 - prepare half of address before hblank (1st write: no effect)
  • $2001 - turn off rendering (just before hblank)
  • $2006 - finish address (2nd write: immediate effect)
  • $2007 - write palette colour
  • $2006 - restore address
  • $2006 - restore address
  • $2001 - turn on rendering (before end of hblank)
Honestly I think it's almost shocking that Taito pulled this off in that era. Emulators, and especially Mesen's event viewer make this a lot easier than it used to be.
Atomfusion wrote: Sat Apr 30, 2022 5:20 pmHow do I pass CPU internal Accumulator, X, Y into a .macro ?
A/X/Y are just part of the state of the CPU, so they're always available in any macro, not something you need to pass in.
Atomfusion
Posts: 7
Joined: Sat Apr 23, 2022 5:48 pm

Re: Ca65 MMC3 Parallax NES Demo Cart

Post by Atomfusion »

if I Disable then reenable 2001 No other code with a full background picture I Get

Before 2001 enabled
EventView1.PNG

Code: Select all

IRQ:
    MMC3_IRQ_DISABLE
    LDA #$00
DISABLED     ;STA $2001
    LDA #$00
    STA $2006
    STA $2006
    LDA #%00011000      ; Show Background, Show Sprites 
DISABLED     ;STA $2001           ;PPU Address Register
RTI 
After
EventView2.PNG
I take it the 2006 pointer for graphics becomes corrupted, But it does not work in Mesen nor Fceux

I have gotten this to work when I load only 70 or so tiles into background and keep the rest all 00 but much more then that and i always get the above issue. I was expecting maybe a graphical glitch on a line or two but not the screen

I was originally fallowing this http://bobrost.com/nes/files/mmc3irqs.txt

and it works great as long as you do not load a real background into it first
EventView3.PNG

The Indiana jones cart Does not show IRQ trigger and is mapper 1. Mesen event viewer
When you say restore 2006, You are just talking about fixing Scroll right so sending #$00 twice ?
Post Reply