Frame timing

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Re: Frame timing

Postby Ian » Wed Aug 30, 2017 2:23 am

Try moving vblank to the end, or near the end.
I had success with games booting (but not actual timing) by doing that.
So when it was polling at boot, it would flip 000011110 in a single frame.
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Frame timing

Postby Bart » Wed Aug 30, 2017 11:20 am

It still flips within a single frame no matter what. My guess (totally uneducated) is that because the transfers are not usually triggered directly after VBL (the program is after all doing some work before it initiates a flush), when they are too close to taking up a full frame, the delay loop starts dropping frames and things somehow grind to a halt. What ends up happening is the game spins waiting on something to count down that never will.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Frame timing

Postby Bart » Wed Aug 30, 2017 11:25 am

Just for the record, Virtual On 2's mysterious "Initializing..." routine is here:

Code: Select all
0x000684DC: 0x9421FFD0   stwu   r1,-0x30(r1)
0x000684E0: 0x7C0802A6   mfspr   r0,lr
0x000684E4: 0x9361001C   stw   r27,0x1C(r1)
0x000684E8: 0x93810020   stw   r28,0x20(r1)
0x000684EC: 0x93A10024   stw   r29,0x24(r1)
0x000684F0: 0x93C10028   stw   r30,0x28(r1)
0x000684F4: 0x93E1002C   stw   r31,0x2C(r1)
0x000684F8: 0x90010034   stw   r0,0x34(r1)
0x000684FC: 0x3D200000   li   r9,0x00000000
0x00068500: 0x88091240   lbz   r0,0x1240(r9)
0x00068504: 0x3D200037   li   r9,0x00370000
0x00068508: 0x39295BC0   addi   r9,r9,0x5BC0
0x0006850C: 0x5400103A   rlwinm   r0,r0,2,0xFFFFFFFC
0x00068510: 0x7FA9002E   lwzx   r29,r9,r0
0x00068514: 0x4BF98329   bl   0x0000083C
0x00068518: 0x7C7B1B78   mr   r27,r3
0x0006851C: 0x38600006   li   r3,0x00000006
0x00068520: 0x4CC63182   crxor   cr1[eq],cr1[eq],cr1[eq]
0x00068524: 0x4BF982E1   bl   0x00000804
0x00068528: 0x3BE00000   li   r31,0x00000000
0x0006852C: 0x3D200037   li   r9,0x00370000
0x00068530: 0x3B895BE0   addi   r28,r9,0x5BE0
0x00068534: 0x3BC10008   addi   r30,r1,0x08
0x00068538: 0x57E02036   rlwinm   r0,r31,4,0xFFFFFFF0
0x0006853C: 0x7D20E214   add   r9,r0,r28
0x00068540: 0x7C7C002E   lwzx   r3,r28,r0
0x00068544: 0x80090004   lwz   r0,0x04(r9)
0x00068548: 0x81690008   lwz   r11,0x08(r9)
0x0006854C: 0x8129000C   lwz   r9,0x0C(r9)
0x00068550: 0x90610008   stw   r3,0x08(r1)
0x00068554: 0x901E0004   stw   r0,0x04(r30)
0x00068558: 0x917E0008   stw   r11,0x08(r30)
0x0006855C: 0x913E000C   stw   r9,0x0C(r30)
0x00068560: 0x80010014   lwz   r0,0x14(r1)
0x00068564: 0x3120FFFF   addic   r9,r0,-0x01
0x00068568: 0x7D690110   subfe   r11,r9,r0
0x0006856C: 0x68000002   xori   r0,r0,0x0002
0x00068570: 0x3120FFFF   addic   r9,r0,-0x01
0x00068574: 0x7C090110   subfe   r0,r9,r0
0x00068578: 0x7D690039   and.   r9,r11,r0
0x0006857C: 0x41820028   bt   cr0[eq],0x000685A4
0x00068580: 0x8081000C   lwz   r4,0x0C(r1)
0x00068584: 0x80A10010   lwz   r5,0x10(r1)
0x00068588: 0x4811BB15   bl   0x0018409C
0x0006858C: 0x38600000   li   r3,0x00000000
0x00068590: 0x4811BB01   bl   0x00184090
0x00068594: 0x57E0103A   rlwinm   r0,r31,2,0xFFFFFFFC
0x00068598: 0x7C7D002E   lwzx   r3,r29,r0
0x0006859C: 0x38800000   li   r4,0x00000000
0x000685A0: 0x4811965D   bl   0x00181BFC
0x000685A4: 0x3BFF0001   addi   r31,r31,0x01
0x000685A8: 0x2C9F000C   cmpi   cr1,0,r31,0x0C
0x000685AC: 0x4085FF8C   bf   cr1[gt],0x00068538
0x000685B0: 0x38600001   li   r3,0x00000001
0x000685B4: 0x3880001E   li   r4,0x0000001E
0x000685B8: 0x38A00008   li   r5,0x00000008
0x000685BC: 0x4811BAE1   bl   0x0018409C
0x000685C0: 0x38600000   li   r3,0x00000000
0x000685C4: 0x4811BACD   bl   0x00184090
0x000685C8: 0x3D200000   li   r9,0x00000000
0x000685CC: 0x88091240   lbz   r0,0x1240(r9)
0x000685D0: 0x3D200037   li   r9,0x00370000
0x000685D4: 0x39295BD0   addi   r9,r9,0x5BD0
0x000685D8: 0x5400103A   rlwinm   r0,r0,2,0xFFFFFFFC
0x000685DC: 0x7FA9002E   lwzx   r29,r9,r0
0x000685E0: 0x807D0030   lwz   r3,0x30(r29)
0x000685E4: 0x38800000   li   r4,0x00000000
0x000685E8: 0x48119615   bl   0x00181BFC
0x000685EC: 0x38600007   li   r3,0x00000007
0x000685F0: 0x4CC63182   crxor   cr1[eq],cr1[eq],cr1[eq]
0x000685F4: 0x4BF98211   bl   0x00000804
0x000685F8: 0x38600000   li   r3,0x00000000
0x000685FC: 0x38800000   li   r4,0x00000000
0x00068600: 0x38A00000   li   r5,0x00000000
0x00068604: 0x4811BA99   bl   0x0018409C
0x00068608: 0x3C600021   li   r3,0x00210000
0x0006860C: 0x3863FC48   addi   r3,r3,-0x3B8
0x00068610: 0x38800000   li   r4,0x00000000
0x00068614: 0x4811C0C9   bl   0x001846DC
0x00068618: 0x7F63DB78   mr   r3,r27
0x0006861C: 0x4CC63182   crxor   cr1[eq],cr1[eq],cr1[eq]
0x00068620: 0x4BF981E5   bl   0x00000804
0x00068624: 0x38600000   li   r3,0x00000000
0x00068628: 0x38800000   li   r4,0x00000000
0x0006862C: 0x38A00000   li   r5,0x00000000
0x00068630: 0x4811BA6D   bl   0x0018409C
0x00068634: 0x38600001   li   r3,0x00000001
0x00068638: 0x4CC63182   crxor   cr1[eq],cr1[eq],cr1[eq]
0x0006863C: 0x4BF981C9   bl   0x00000804
0x00068640: 0x3C600021   li   r3,0x00210000
0x00068644: 0x38630A3C   addi   r3,r3,0xA3C
0x00068648: 0x38800000   li   r4,0x00000000
0x0006864C: 0x4811C091   bl   0x001846DC
0x00068650: 0x38600000   li   r3,0x00000000
0x00068654: 0x38800000   li   r4,0x00000000
0x00068658: 0x38A00000   li   r5,0x00000000
0x0006865C: 0x4811BA41   bl   0x0018409C
0x00068660: 0x38600001   li   r3,0x00000001
0x00068664: 0x4CC63182   crxor   cr1[eq],cr1[eq],cr1[eq]
0x00068668: 0x4BF9819D   bl   0x00000804
0x0006866C: 0x3C600021   li   r3,0x00210000
0x00068670: 0x386305D0   addi   r3,r3,0x5D0
0x00068674: 0x38800000   li   r4,0x00000000
0x00068678: 0x4811C065   bl   0x001846DC
0x0006867C: 0x80010034   lwz   r0,0x34(r1)
0x00068680: 0x7C0803A6   mtspr   lr,r0
0x00068684: 0x8361001C   lwz   r27,0x1C(r1)
0x00068688: 0x83810020   lwz   r28,0x20(r1)
0x0006868C: 0x83A10024   lwz   r29,0x24(r1)
0x00068690: 0x83C10028   lwz   r30,0x28(r1)
0x00068694: 0x83E1002C   lwz   r31,0x2C(r1)
0x00068698: 0x38210030   addi   r1,r1,0x30
0x0006869C: 0x4E800020   bclr   0x14,0


I don't think I'll get through this beast any time soon -- it will probably require an effort at least as large as what I had to do for FV2. But I'll whittle away at it over the coming weeks and maybe I'll have a breakthrough sooner than expected.

For now, I may just get it working "well enough" for a release and plan to keep tweaking later on. I'm fairly confident we are generally on the right track and that the new frame timing code I have sitting at home will be very close to the final, correct version.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Frame timing

Postby Ian » Wed Aug 30, 2017 12:43 pm

Well, seems like you've made some good progress. I don't think I could solve this problem in 1000 years :)
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Frame timing

Postby Ian » Sun Sep 03, 2017 1:38 pm

Bart
would it be worth looking at why attract mode in Mag Truck blows up?
Originally I thought it could be some sort of CPU bug that fills the float registers with NaNs. And when it tries to do maths with those NaNs they just become everywhere.
But maybe it's some sort of timing problem, where by it calculates the difference between 2 frames and comes back with 0. Just a wild speculation
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Frame timing

Postby Bart » Tue Sep 05, 2017 1:34 pm

I think you're right about that, Ian. I recall looking into this some time ago briefly and coming to a similar conclusion. But I'm not sure what to tackle next with my limited time. Should I just proceed with the VON2 boot-up menu given that timing can produce a visually distinctive response (the counter exceeding 100%) and given that the routine in question has been isolated?

I've discovered, by the way, that the precise length of time taken by the page flip is important and VF3 is sensitive to it as well. If it's incorrect, the characters come apart at the seams. Magical Truck has a similar thing going on with the girl's dress and LA Machineguns fails to boot if timing is off.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Frame timing

Postby Ian » Tue Sep 05, 2017 1:39 pm

I normally try and tackle the low hanging fruit first, whatever that maybe ? :)
Maybe the jtag code would be low hanging fruit?
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Frame timing

Postby Bart » Tue Sep 05, 2017 1:42 pm

Ian wrote:I normally try and tackle the low hanging fruit first, whatever that maybe ? :)
Maybe the jtag code would be low hanging fruit?


I've been trying to take the opposite approach in my HoloLens stuff and it pays dividends ;) But yeah, the JTAG stuff should get done. I think I'll refactor it into a separate module outside of Real3D.cpp and provide some interface for it to hook into objects it can actually affect. CReal3D should provide the ID codes and IRender3D should be accepted so that settings can be modified.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Frame timing

Postby Ian » Sun Nov 12, 2017 10:00 am

Bart,
maybe a stupid question, but did you try testing at the correct clock speeds?
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Frame timing

Postby Bart » Sun Nov 12, 2017 10:49 am

Yes, I did :)

I haven't looked at this in a while but I have started to slowly plug away at the VON2 init routine at work again.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Previous

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest