Branch Timing Test ROMs

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Branch Timing Test ROMs

Post by blargg »

I had some branch timing test ROMs mostly written and the recent thread prompted me to finish them. They test branch timing and the edge cases for page crossings that an emulator might get wrong. I also wrote a concise summary of timing (below).

branch_timing_tests.zip

An untaken branch takes 2 clocks. A taken branch takes 3 clocks. A taken branch that crosses a page takes 4 clocks. Page crossing occurs when the high byte of the branch target address is different than the high byte of the address of the next instruction:

Code: Select all

branch_target:
    ...
    bne	branch_target
next_instruction:
    nop
    ...
branch_target:
mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

Post by mattmatteh »

sweet !! thanks blargg.

i took a break from my ppu to work on timing and do not have nmi timing down yet. ill have to work on that. do these test depend on the odd from ppu tick being dropped ? i assume that they do. or if all the test are run with the ppu off first then turn it on. but then i suppose the nmi isnt set with the ppu off ?

thanks.

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

Post by Zepper »

It's OK here. ^_^;;..
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

I don't think I depend on any exotic PPU behavior, just the NMI occuring every ~29780 CPU clocks. There would be no reason to rely on anything more than that. At reset it just enables NMI and then runs sequences and uses the NMI to time them. I made them fairly loose so your NMI can probably be inaccurate by a few clocks.

What happens when you run the first test ROM?
mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

Post by mattmatteh »

ok, all 3 test pass.

i was thinking about the nmi... i just ran my cpu for 29780 cycles since the nmi is predictable.

an interesting test would be to catch the invalid and dummy reads. i recall you tested this before and determined that repeated reads do effect the ppu. perhaps test the repeated reads, invalid reads.

ill have to think of a way to test that. not sure you would be interested.

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

Post by Zepper »

Is just me or... you ALL are using "timestamps" !? o.O
mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

Post by mattmatteh »

i am using cpu is 15/16 ntsc/pal and ppu is 5. run the cpu and have the ppu catch up. but i am still working on my timing.

matt
Post Reply