Metatiles appearing differently in emulators and on hardware

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

Moderator: Moderators

Post Reply
User avatar
Sogona
Posts: 186
Joined: Thu Jul 23, 2015 7:54 pm
Location: USA
Contact:

Metatiles appearing differently in emulators and on hardware

Post by Sogona » Sat Aug 29, 2015 8:51 pm

As an exercise, I've been trying to make a 15 slider puzzle (One of these). It looks fine in FCEUX, the metatiles won't display at all in Nestopia, and for whatever reason on the Powerpak, only the first row won't display.

Emulators:
sdfsdf.png
Powerpak:
20150829_225215.jpg
I'm aware that there can be differences between emulators and an actual NES, but I've used this metatile decompressing routine before in multiple projects, and they've all worked fine when I tested them on real hardware. So do you think this is an issue with my code? I can post the routine if it's necessary, all it is is this.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Metatiles appearing differently in emulators and on hard

Post by thefox » Sat Aug 29, 2015 9:04 pm

Definitely an issue with the code, but hard to say much without the ROM.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

User avatar
Sogona
Posts: 186
Joined: Thu Jul 23, 2015 7:54 pm
Location: USA
Contact:

Re: Metatiles appearing differently in emulators and on hard

Post by Sogona » Sat Aug 29, 2015 9:08 pm

Shit, okay. I'll look it over tomorrow.

User avatar
Memblers
Site Admin
Posts: 3858
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Metatiles appearing differently in emulators and on hard

Post by Memblers » Sat Aug 29, 2015 9:56 pm

When it comes to strange compatibility issues, using uninitialized RAM is the most common cause.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Metatiles appearing differently in emulators and on hard

Post by thefox » Sun Aug 30, 2015 3:27 am

Yeah. You can use NDX (http://kkfos.aspekt.fi/projects/nes/too ... dulatordx/) to get some idea if uninitialized RAM access might be the cause. It has an option (Debug -> Debug Extensions -> Randomize Memory) for randomizing all RAM contents (so you should get different results on different power ups), and it will also warn if memory is read before being written to.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

User avatar
rainwarrior
Posts: 7824
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Metatiles appearing differently in emulators and on hard

Post by rainwarrior » Sun Aug 30, 2015 6:32 am

Memblers wrote:When it comes to strange compatibility issues, using uninitialized RAM is the most common cause.
I think the second most common cause is trying to send data to the PPU (i.e. $2007 or OAM DMA) outside of the vblank window.

User avatar
Sogona
Posts: 186
Joined: Thu Jul 23, 2015 7:54 pm
Location: USA
Contact:

Re: Metatiles appearing differently in emulators and on hard

Post by Sogona » Sun Aug 30, 2015 8:23 am

rainwarrior wrote: I think the second most common cause is trying to send data to the PPU (i.e. $2007 or OAM DMA) outside of the vblank window.
All I've done is bulk drawing so far.
Memblers wrote:When it comes to strange compatibility issues, using uninitialized RAM is the most common cause.
Turns out it was, not the RAM, but the attribute tables that I forgot to initialize. How I didn't catch that before is beyond me. Always the simplest mistakes that cause the most headaches.

Anyways, all is working now

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

Re: Metatiles appearing differently in emulators and on hard

Post by tepples » Sun Aug 30, 2015 8:41 am

Errors of not initializing the attribute tables can be avoided in two ways. One way is to always initialize the whole palette, so that wrong attributes appear as wrong colors instead of invisible graphics. The other way is to have the screen clearing routine in your library take an attribute value as an argument. Here's the routine from my own library:

Code: Select all

;;
; Clears a nametable to a given tile number and attribute value.
; (Turn off rendering in PPUMASK and set the VRAM address increment
; to 1 in PPUCTRL first.)
; @param A tile number
; @param X base address of nametable ($20, $24, $28, or $2C)
; @param Y attribute value ($00, $55, $AA, or $FF)
.proc ppu_clear_nt

  ; Set base PPU address to XX00
  stx PPUADDR
  ldx #$00
  stx PPUADDR

  ; Clear the 960 spaces of the main part of the nametable,
  ; using a 4 times unrolled loop
  ldx #960/4
loop1:
  sta PPUDATA
  sta PPUDATA
  sta PPUDATA
  sta PPUDATA
  dex
  bne loop1

  ; Clear the 64 entries of the attribute table
  ldx #64
loop2:
  sty PPUDATA
  dex
  bne loop2
  rts
.endproc

Post Reply