[SOLVED] VRAM reads (2007h)

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Zepper
Formerly Fx3
Posts: 3214
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

[SOLVED] VRAM reads (2007h)

Post by Zepper » Fri Sep 04, 2020 9:04 am

Hello folks.

1. I'm aware of this previous topic, but it's not crystal clear to me.
2. Yup, my emulator is getting error #6 on Blargg's vram_test (Palette read should also read VRAM into read buffer).

So, where's the problem here?

Code: Select all

        tempaddr=ppu_address&0x3FFF;
        _clock_2007();
        if(tempaddr >= 0x3F00) {
           ReadLatch2007=bnk_name_read(tempaddr>>10);
           return (ram_color[tempaddr&0x1F]&set_bw_mode)|(ppu_Latch&0xC0);
        } else {
           ppu_Latch=ReadLatch2007;
           ReadLatch2007=(tempaddr<0x2000)?bnk_read(tempaddr):bnk_name_read(tempaddr);
        }
Note!
bnk_read means "reading PPU data from $0000-$1FFF".
bnk_name_read means "reading nametable data ($2000-$3EFF and mirrors).
Last edited by Zepper on Sat Sep 05, 2020 8:22 pm, edited 1 time in total.

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

Re: VRAM reads (2007h)

Post by lidnariq » Fri Sep 04, 2020 11:04 am

Why do you have that >>10 there?

User avatar
Zepper
Formerly Fx3
Posts: 3214
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: VRAM reads (2007h)

Post by Zepper » Fri Sep 04, 2020 2:17 pm

lidnariq wrote:
Fri Sep 04, 2020 11:04 am
Why do you have that >>10 there?
Access to the nametables 0, 1, 2, 3 (2000h, 2400h, 2800h, 2C00h) - mirroring.
The value is ANDed with 3, but is this correct?

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

Re: VRAM reads (2007h)

Post by Quietust » Fri Sep 04, 2020 2:25 pm

Zepper wrote:
Fri Sep 04, 2020 2:17 pm
lidnariq wrote:
Fri Sep 04, 2020 11:04 am
Why do you have that >>10 there?
Access to the nametables 0, 1, 2, 3 (2000h, 2400h, 2800h, 2C00h) - mirroring.
The value is ANDed with 3, but is this correct?
But you don't have the >> 10 in the "else" case:

Code: Select all

ReadLatch2007=(tempaddr<0x2000)?bnk_read(tempaddr):bnk_name_read(tempaddr);
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Zepper
Formerly Fx3
Posts: 3214
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: VRAM reads (2007h)

Post by Zepper » Fri Sep 04, 2020 2:42 pm

Ouch. :oops: :oops:

Post Reply