Why does this basic program crash FCEUX?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Why does this basic program crash FCEUX?

Post by Controllerhead » Fri May 01, 2020 3:07 am

Are you dead set on CHR-RAM?

I don't know what your plans or goals are for this project, so i lack very important context here; but you may want to take a second and a nice deep breath and consider using CHR-ROM.

MMC3 offers a hefty 256k worth of bank, they are "instantly" switchable as it is directly wired to the PPU pattern table through separate cart pins, $0000-$0FFF offers 2 independently switchable even subdivisions, and $1000-$1FFF offers 4. Seems like a nice setup without a potential ton of future hassle and/or scope creep.
http://wiki.nesdev.com/w/index.php/MMC3#Banks

There are plenty of valid reasons to want CHR-RAM, but just give CHR-ROM a good think before you do anything crazy, ok? =)
Image

rox_midge
Posts: 89
Joined: Mon Sep 19, 2005 11:51 am

Re: Why does this basic program crash FCEUX?

Post by rox_midge » Fri May 01, 2020 5:11 am

Controllerhead wrote:
Fri May 01, 2020 3:07 am
Are you dead set on CHR-RAM?

I don't know what your plans or goals are for this project, so i lack very important context here; but you may want to take a second and a nice deep breath and consider using CHR-ROM.

MMC3 offers a hefty 256k worth of bank, they are "instantly" switchable as it is directly wired to the PPU pattern table through separate cart pins, $0000-$0FFF offers 2 independently switchable even subdivisions, and $1000-$1FFF offers 4. Seems like a nice setup without a potential ton of future hassle and/or scope creep.
http://wiki.nesdev.com/w/index.php/MMC3#Banks

There are plenty of valid reasons to want CHR-RAM, but just give CHR-ROM a good think before you do anything crazy, ok? =)
MMC3's ability to switch CHR-ROM banks in 1K chunks does get me very close to what I need. The only things missing would be the ability to do parallax effects, the ability to mutate sprite tiles, and the ability to display variable-width text. All of those problems have solutions in one form or another: I could either burn 8K on the parallax tile set, or limit the tiles in that set so that I don't have to swap banks out; I could forego shifting sprite patterns around and just deal with sprite pop-in; and virtually every game manages to get by with fixed-width fonts - and TBH the fonts look odd on the few games that use variable-width fonts, anyway.

So, you may be right. It would be awesome to have the best of both worlds - mostly PPU-ROM along with some PPU-RAM, switchable in 1KB chunks. I'd still need to write to PPU-RAM the slow way, but because I'm already doing that for scrolling it wouldn't be that bad, and the "typical" case of switching banks would be instant.

Either way, it does sound a lot better than spending most of my available time shuffling data around to move it into the pattern tables!

User avatar
aa-dav
Posts: 102
Joined: Tue Apr 14, 2020 9:45 pm
Location: Russia

Re: Why does this basic program crash FCEUX?

Post by aa-dav » Fri May 01, 2020 6:50 am

rox_midge wrote:
Fri May 01, 2020 5:11 am
...8K on the parallax tile set...
What do you mean by 'parallax tiles'? Parallax as I know usually is per-scanline technique.
Do you mean second-background imitation like in Sword Master https://youtu.be/_GSfLqJUcOM?t=64 ?
It's done by switching 1k bank of CHR-ROM:
Image

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Why does this basic program crash FCEUX?

Post by Controllerhead » Fri May 01, 2020 9:05 am

rox_midge wrote:
Fri May 01, 2020 5:11 am
It would be awesome to have the best of both worlds - mostly PPU-ROM along with some PPU-RAM, switchable in 1KB chunks.
I have good news! There are existing MMC3 boards / mappers with CHR-RAM + CHR-ROM + PRG-RAM permutations; TNROM, TGROM, and TQROM, respectively. They are listed here:
https://wiki.nesdev.com/w/index.php/CHR ... Advantages

Personally, I don't know if there are any "gotcha's" with mixing CHR-ROM and CHR-RAM, as far as bank switching, compatibility, or anything else; but i'm sure someone here does.
rox_midge wrote:
Fri May 01, 2020 5:11 am
spending most of my available time shuffling data around to move it into the pattern tables
You may want to discuss that with your 2A03 =p
Image

lidnariq
Posts: 9658
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Why does this basic program crash FCEUX?

Post by lidnariq » Fri May 01, 2020 10:00 am

rox_midge wrote:
Fri May 01, 2020 5:11 am
MMC3's ability to switch CHR-ROM banks in 1K chunks does get me very close to what I need. The only things missing would be the ability to do parallax effects, the ability to mutate sprite tiles, and the ability to display variable-width text.
You can just use a large CHR RAM with MMC3, and get the best of both worlds. Haunted Halloween 86 does, with MMC3 and 32KB CHR RAM.

On all Nintendo boards with CHR RAM, they still support CHR banking, even the MMC1 ones where it's entirely redundant. Lagrange Point (VRC7, Konami) makes extensive use of this.

Some pirate clones didn't support it. Emulators do.
Controllerhead wrote:
Fri May 01, 2020 9:05 am
Personally, I don't know if there are any "gotcha's" with mixing CHR-ROM and CHR-RAM, as far as bank switching, compatibility, or anything else; but i'm sure someone here does.
It's cheaper to buy a bigger CHR RAM than use two CHR memories. (last time I said)

User avatar
Quietust
Posts: 1597
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Why does this basic program crash FCEUX?

Post by Quietust » Fri May 01, 2020 10:04 am

Controllerhead wrote:
Fri May 01, 2020 9:05 am
rox_midge wrote:
Fri May 01, 2020 5:11 am
It would be awesome to have the best of both worlds - mostly PPU-ROM along with some PPU-RAM, switchable in 1KB chunks.
I have good news! There are existing MMC3 boards / mappers with CHR-RAM + CHR-ROM + PRG-RAM permutations; TNROM, TGROM, and TQROM, respectively. They are listed here:
https://wiki.nesdev.com/w/index.php/CHR ... Advantages
I think you misread something - the only board in that list that uses both CHR-ROM and CHR-RAM simultaneously is TQROM, while TGROM and TNROM use CHR-RAM exclusively..
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Why does this basic program crash FCEUX?

Post by Controllerhead » Fri May 01, 2020 10:12 am

lidnariq wrote:
Fri May 01, 2020 10:00 am
It's cheaper to buy a bigger CHR RAM than use two CHR memories.
Speaking of the state of homebrew carts, is it currently possible to have an MMC3 clone or another chip/method that replaces most/all of its functionality?
Image

lidnariq
Posts: 9658
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Why does this basic program crash FCEUX?

Post by lidnariq » Fri May 01, 2020 10:39 am

INL was selling some: http://www.infiniteneslives.com/nessupplies.php#MMC3

You can still find NOS or part pulls of 3rd-party clones (e.g. AX5202P)

The COOLBOY carts come with an MMC3 clone and large CHR RAM on it, although some care is needed getting one that's safe to operate in a real historical NES that runs at 5V (instead of some of the later clones that run at 3V)

rox_midge
Posts: 89
Joined: Mon Sep 19, 2005 11:51 am

Re: Why does this basic program crash FCEUX?

Post by rox_midge » Fri May 01, 2020 3:44 pm

aa-dav wrote:
Fri May 01, 2020 6:50 am
rox_midge wrote:
Fri May 01, 2020 5:11 am
...8K on the parallax tile set...
What do you mean by 'parallax tiles'? Parallax as I know usually is per-scanline technique.
Do you mean second-background imitation like in Sword Master https://youtu.be/_GSfLqJUcOM?t=64 ?
It's done by switching 1k bank of CHR-ROM:
Image
That's exactly what I mean - in order to achieve that effect with CHR-ROM only, I'd have to have eight versions of that 1KB bank (one for each pixel offset), meaning that section would take up 8KB of my CHR-ROM. If I had both CHR-ROM and CHR-RAM, I could manually rotate the tiles and store only the ones I needed (although I wouldn't be able to swap out all 64 of them at once).

rox_midge
Posts: 89
Joined: Mon Sep 19, 2005 11:51 am

Re: Why does this basic program crash FCEUX?

Post by rox_midge » Fri May 01, 2020 3:51 pm

lidnariq wrote:
Fri May 01, 2020 10:00 am
rox_midge wrote:
Fri May 01, 2020 5:11 am
MMC3's ability to switch CHR-ROM banks in 1K chunks does get me very close to what I need. The only things missing would be the ability to do parallax effects, the ability to mutate sprite tiles, and the ability to display variable-width text.
You can just use a large CHR RAM with MMC3, and get the best of both worlds. Haunted Halloween 86 does, with MMC3 and 32KB CHR RAM.

On all Nintendo boards with CHR RAM, they still support CHR banking, even the MMC1 ones where it's entirely redundant. Lagrange Point (VRC7, Konami) makes extensive use of this.

Some pirate clones didn't support it. Emulators do.
Controllerhead wrote:
Fri May 01, 2020 9:05 am
Personally, I don't know if there are any "gotcha's" with mixing CHR-ROM and CHR-RAM, as far as bank switching, compatibility, or anything else; but i'm sure someone here does.
It's cheaper to buy a bigger CHR RAM than use two CHR memories. (last time I said)
I can't find any information on Haunted: Halloween '85 aside from the name. Is it available anywhere?

I could prototype using a big bank of CHR-RAM, but the biggest CHR-RAM on an actual cart with an MMC3 seems to be 8KB. Are there any dev carts available that have CHR-RAM at all? Even just 16KB would suffice, as it would allow me to load banks prior to needing them for rendering.

Alternately, I guess I could, just, you know, worry about getting it into a physical cart once there's something actually worth putting onto a physical cart...

rox_midge
Posts: 89
Joined: Mon Sep 19, 2005 11:51 am

Re: Why does this basic program crash FCEUX?

Post by rox_midge » Fri May 01, 2020 3:59 pm

Quietust wrote:
Fri May 01, 2020 10:04 am
Controllerhead wrote:
Fri May 01, 2020 9:05 am
rox_midge wrote:
Fri May 01, 2020 5:11 am
It would be awesome to have the best of both worlds - mostly PPU-ROM along with some PPU-RAM, switchable in 1KB chunks.
I have good news! There are existing MMC3 boards / mappers with CHR-RAM + CHR-ROM + PRG-RAM permutations; TNROM, TGROM, and TQROM, respectively. They are listed here:
https://wiki.nesdev.com/w/index.php/CHR ... Advantages
I think you misread something - the only board in that list that uses both CHR-ROM and CHR-RAM simultaneously is TQROM, while TGROM and TNROM use CHR-RAM exclusively..
TQROM might actually fit the bill. 64KB (!) of CHR-ROM gives me plenty of space for tiles, and 8KB of CHR-RAM means that I could precalculate all of the parallax tiles needed at one time.

When selecting a 1KB bank of CHR memory, how do I specify a CHR-RAM bank on such a board instead of a CHR-ROM bank? Do they just come after the CHR-ROM banks?

Code: Select all

lda #$02 ; no rakes here
sta $8000
lda #$0f
sta $8001 ; select bank #15, which is the last CHR-ROM bank
Or to select a PRG-RAM bank:

Code: Select all

lda #$02
sta $8000
lda #$10
sta $8001 ; select bank #16, which is the first CHR-RAM bank
Is that right? I guess I'm about to find out.

lidnariq
Posts: 9658
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Why does this basic program crash FCEUX?

Post by lidnariq » Fri May 01, 2020 4:30 pm

rox_midge wrote:
Fri May 01, 2020 3:51 pm
I can't find any information on Haunted: Halloween '85 aside from the name. Is it available anywhere?
Tepples was the programmer, and made this thread which includes a link to the store (for cart) and steam and a description of how he uses more than 8KB of CHR RAM.

For anything more, I'd like to defer to him.
I could prototype using a big bank of CHR-RAM, but the biggest CHR-RAM on an actual cart with an MMC3 seems to be 8KB. Are there any dev carts available that have CHR-RAM at all?
If you start with donors, as long as the PCB has the much-coveted PPU /WR pin actually plated, it's relatively easy rework.
Alternately, I guess I could, just, you know, worry about getting it into a physical cart once there's something actually worth putting onto a physical cart...
For what it's worth, Mesen, especially with its "Recommended settings for developers" all enabled, is very good.
rox_midge wrote:
Fri May 01, 2020 3:44 pm
meaning that section would take up 8KB of my CHR-ROM.
That's really not that bad, I promise. You have a full 256KB of CHR addressable given the MMC3, and unless you're planning on having lots of different unrelated parallaxes that can't all fit in the same 1KB=64 tile bank, you're much more likely to run into problems with MMC3's 2KB/1KB banking than run out of tiles.

I suppose, if you're planning on having parallaxes wider than 8, you could run out quickly.
rox_midge wrote:
Fri May 01, 2020 3:59 pm
When selecting a 1KB bank of CHR memory, how do I specify a CHR-RAM bank on such a board instead of a CHR-ROM bank? Do they just come after the CHR-ROM banks?
Banks 0-63 are CHR ROM. Banks 64-71 are CHR RAM. Banks 72-79 are the same 8 banks of CHR RAM. Banks 80-127 continue to be more copies of the same banks of CHR RAM. Banks 128-255 are a copy of banks 0-127.

User avatar
tokumaru
Posts: 11858
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Why does this basic program crash FCEUX?

Post by tokumaru » Fri May 01, 2020 4:58 pm

rox_midge wrote:
Fri May 01, 2020 3:44 pm
That's exactly what I mean - in order to achieve that effect with CHR-ROM only, I'd have to have eight versions of that 1KB bank (one for each pixel offset), meaning that section would take up 8KB of my CHR-ROM.
If you use a large CHR-RAM chip (32 or 64KB) you can pre-calculate all rotations and get the best of both worlds: no wasted ROM plus instantaneous switching.
If I had both CHR-ROM and CHR-RAM
With a large CHR-RAM chip you can do everything you can do with CHR-ROM + CHR-RAM, you just have to populate the entire CHR-RAM with whatever you need at the beginning of each level/room/whatever.

The advantage is that any existing board that works with CHR-ROM will work with CHR-RAM as well, you just have to swap the chip and maybe connect the /RW line if it's not already connected.

EDIT: Forgot that sometimes the /RW pin isn't present at all. I know you can "create" the pin because I've seen people online doing it, but doing it right might not be so trivial. Maybe if you file a little groove and super glue a thin piece of metal it'd work well enough.

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Why does this basic program crash FCEUX?

Post by Controllerhead » Fri May 01, 2020 7:32 pm

tokumaru wrote:
Fri May 01, 2020 4:58 pm
If you use a large CHR-RAM chip (32 or 64KB) you can pre-calculate all rotations and get the best of both worlds: no wasted ROM plus instantaneous switching.
So say you were to start your game with a 2-3 second splash screen, with maybe a CAPCOM size little logo in the middle, you could probably pre-populate that entire space with some clever ON-OFFing of the PPU. You get all the quick bank switching advantages of a CHR-ROM style setup with the flexibility of CHR-RAM. Plus, if it ever comes to cart, only one CHR chip instead of two.

I'm sold man. That's gotta be the way to go.
Image

tepples
Posts: 22049
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Why does this basic program crash FCEUX?

Post by tepples » Fri May 01, 2020 8:02 pm

rox_midge wrote:
Fri May 01, 2020 3:51 pm
lidnariq wrote:
Fri May 01, 2020 10:00 am
\You can just use a large CHR RAM with MMC3, and get the best of both worlds. Haunted Halloween 86 does, with MMC3 and 32KB CHR RAM.
I can't find any information on Haunted: Halloween '85 aside from the name. Is it available anywhere?
Haunted: Halloween '85 is sold on cartridge. It uses a cheap BNROM-compatible board with a 512 KiB PRG ROM and horizontal nametable arrangement (that is, vertical mirroring). This is the same configuration used by Lizard and by early prototypes of Action 53, back when I was concentrating on NROM games. The engine relies heavily on Battletoads-style streaming of sprite cels, and not just for the player character.

Haunted: Halloween '86 (The Curse of Possum Hollow) is sold on cartridge. As I explained in detail elsewhere, it uses a 512 KiB PRG ROM on a board similar to TGROM (the board in Ninja Crusaders, Mega Man 4, and Mega Man 6), except with a 32 KiB CHR RAM instead of 8 KiB.
I could prototype using a big bank of CHR-RAM, but the biggest CHR-RAM on an actual cart with an MMC3 seems to be 8KB. Are there any dev carts available that have CHR-RAM at all?
PowerPak with PowerMappers supports the oversize TGROM configuration used by HH86.

Post Reply