It is currently Fri May 25, 2018 11:14 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Nov 21, 2013 7:22 am 
Offline

Joined: Thu Sep 15, 2005 9:23 am
Posts: 1194
Location: Behind you with a knife!
In regards to 2-branch_timing.nes, all I get are 64 0's printed across the screen and an error message.

I've tested my branch code manually and its branching and timing are perfect (even the dummy read on the 4th cycle).

Can anybody (pref. blargg) explain to me how the test works?

_________________
http://www.jamesturner.de/


Top
 Profile  
 
PostPosted: Thu Nov 21, 2013 12:34 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Any timing test must use some kind of timer, so if your branches are flawless, then it's probably the timer.

Looking at source/2-branch_timing.s:

; Verifies timing of branch instructions
;
; Runs branch instruction in loop that counts iterations
; until APU length counter expires. Moves the loop around
; in memory to trigger page cross/no cross cases.

So it uses the APU's length counter to do the timing. Searching for APU yields this:
Code:
    ; Synchronize with APU length counter
    setb SNDMODE,$40
    setb SNDCHN,$01
    setb $4000,$10
    setb $4001,$7F
    setb $4002,$FF
    setb $4003,$18
    lda #$01
:   and SNDCHN
    bne :-

setb, what's that? There's a readme.txt in the source/ directory:
Code:
Macros
------
Some macros are used to make common operations more convenient, defined
in common/macros.inc. The left is equivalent to the right:

    Macro               Equivalent
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
...
   
    setb addr,byte      lda #byte
                        sta addr

Then it does the length counter setup described above, runs the instruction, and converts the number of iterations the branch loop ran to a cycle count:
Code:
    ; Setup length counter
    setb $4003,$18
   
    delay 29830-7120
   
    ; Run instruction
    setb temp,0
    pla
    jmp (addr)
   
raw_to_cycles: ; entry i is lowest value that qualifies for i cycles
    .byte 250, 241, 233, 226, 219, 213, 206, 201, 195, 190, 0

; Jumps here when instruction has been timed
instr_done:
    ; Convert iteration count to cycle count
    lda temp
    ldy #-1
:   iny
    cmp raw_to_cycles,y
    blt :-


So your APU length counter handling might be wrong.


Top
 Profile  
 
PostPosted: Thu Nov 21, 2013 1:22 pm 
Offline

Joined: Thu Sep 15, 2005 9:23 am
Posts: 1194
Location: Behind you with a knife!
I don't yet emulate the APU timer so that must be it, thanks.

_________________
http://www.jamesturner.de/


Top
 Profile  
 
PostPosted: Thu Nov 21, 2013 4:10 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
The length counter for a sound channel? It doesn't use the APU frame interrupt or anything like that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group