foxygit / xexkit Log in
commits tags

/docs/wiki/The-Guide.md · 2.38 KB

raw

The Guide

Players leave a title the way they leave any game: Xbox button, then Xbox Home. That needs the title's help.

What the title has to do

  1. Swap every frame with VdSwap, passing the system command buffer

    from VdGetSystemCommandBuffer. While the Guide is open, VdSwap puts an indirect call to XAM's drawing commands into the title's ring.

  2. Give VdSwap real outputs. Its last five arguments are pointers to

    the front buffer address, format, colour space, width and height. Initialise them with your own buffer (virtual address, 6 = k_8_8_8_8, 0 = RGB, its size). While XAM draws the Guide, VdSwap replaces them with XAM's surface (we saw 852x480 at 0x01C19000, pitch 864).

  3. Show XAM's surface instead of yours on those frames:
    • skip your own scanout write;
    • set the scaler for its size, filling the output;
    • commit it through 0x2840/0x2844/D1GRPH and 0x60EC;
    • after it closes, put your own scaler values back.
  4. Tell XAM the title's display once, with graphics notification event 1,

    as Direct3D does:

   struct { uint16_t front_w, front_h, out_w, out_h;
            uint32_t left, top, right, bottom;      // 0, 0, front_w, front_h
            uint32_t scaled_w, scaled_h;            // the output
            uint32_t filters[8]; } d;               // 0: defaults
   VdCallGraphicsNotificationRoutines(1, &d);
   

Without it, XAM draws the game under the Guide as the top-left 640x480, zoomed.

xexkit's video.c does all of this. In our test, the Guide was open for 557 frames and the title's picture came back after it closed.

Pacing while the Guide shows

Frames that show XAM's surface don't latch at vertical blank. Unpaced, our loop ran at about 380 fps under the Guide, and Celeste kept playing at 6x speed. xexkit holds those frames to 60 a second with the time base.

Ending

  • Never end the title by itself while the Guide is open. XAM's Guide

    thread waits for a swap fence that never comes, and the console hangs (xsdk's finding). Check xex_video_guide_visible() before ending on a timer or a key combination.

  • Xbox Home ends the title while it is still swapping, which is safe.
  • Back+Start is often taken by dashboard plugins (a screenshot hotkey on

    our console), so don't rely on it as the only way out.

XAM keeps the controllers while the Guide is open, so input reads as released.