Ejecting a disc using cIOS

Discussion in 'Wii - Hacking' started by twofive, Apr 6, 2009.

Apr 6, 2009

Ejecting a disc using cIOS by twofive at 10:18 AM (645 Views / 0 Likes) 3 replies

  1. twofive
    OP

    Member twofive GBAtemp Regular

    Joined:
    Nov 20, 2008
    Messages:
    150
    Country:
    Poland
    Hi!

    I need to eject a Wii disc from the Wii's DVD drive from homebrew using the cIOS. Is there any way I can do this?
    It's possible from DVDX but I haven't found any function to do that using cIOS.

    -- twofive
     
  2. Det1re

    Member Det1re det1re.de

    Joined:
    Oct 28, 2008
    Messages:
    1,272
    Location:
    Germany
    Country:
    Germany
    http://wiibrew.org/wiki/Eject_DVD

    It doesn't use cIOS, but it will likely eject your DVD. Source is included:

    CODE#include
    #include
    #include
    #include

    static void *xfb = NULL;
    static GXRModeObj *rmode = NULL;

    //---------------------------------------------------------------------------------
    int main(int argc, char **argv) {
    //---------------------------------------------------------------------------------
    ÂÂÂÂ// Initialise the DVD system
    ÂÂÂÂDI_Init();
    ÂÂÂÂ
    ÂÂÂÂ// Initialise the video system
    ÂÂÂÂVIDEO_Init();
    ÂÂÂÂ
    ÂÂÂÂ// Obtain the preferred video mode from the system
    ÂÂÂÂ// This will correspond to the settings in the Wii menu
    ÂÂÂÂrmode = VIDEO_GetPreferredMode(NULL);

    ÂÂÂÂ// Allocate memory for the display in the uncached region
    ÂÂÂÂxfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
    ÂÂÂÂ
    ÂÂÂÂ// Initialise the console, required for printf
    ÂÂÂÂconsole_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
    ÂÂÂÂ
    ÂÂÂÂ// Set up the video registers with the chosen mode
    ÂÂÂÂVIDEO_Configure(rmode);
    ÂÂÂÂ
    ÂÂÂÂ// Tell the video hardware where our display memory is
    ÂÂÂÂVIDEO_SetNextFramebuffer(xfb);
    ÂÂÂÂ
    ÂÂÂÂ// Make the display visible
    ÂÂÂÂVIDEO_SetBlack(FALSE);

    ÂÂÂÂ// Flush the video register changes to the hardware
    ÂÂÂÂVIDEO_Flush();

    ÂÂÂÂ// Wait for Video setup to complete
    ÂÂÂÂVIDEO_WaitVSync();
    ÂÂÂÂif(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

    ÂÂÂÂ// The console understands VT terminal escape codes
    ÂÂÂÂ// This positions the cursor on row 2, column 0
    ÂÂÂÂ// we can use variables for this with format codes too
    ÂÂÂÂ// e.g. printf ("\x1b[%d;%dH", row, column );
    ÂÂÂÂprintf("\x1b[2;0H");
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂprintf("Eject DVD 0.1 - (c) 2008 hOTzENpLOTz\n\n");
    ÂÂÂÂ
    ÂÂÂÂ// Check if a DVD is in the drive
    ÂÂÂÂuint32_t val;
    ÂÂÂÂDI_GetCoverRegister(&val);ÂÂÂÂ
    ÂÂÂÂif (!(val&0x2))
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂprintf("No DVD in drive.");
    ÂÂÂÂ}
    ÂÂÂÂelse
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂprintf("Ejecting DVD... ");
    ÂÂÂÂÂÂÂÂif (DI_Eject() == 0) {
    ÂÂÂÂÂÂÂÂÂÂÂÂprintf("OK.");
    ÂÂÂÂÂÂÂÂ} else {
    ÂÂÂÂÂÂÂÂÂÂÂÂprintf("\nCould not eject DVD!");
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂprintf("\n\nExiting...\n");

    ÂÂÂÂreturn 0;
    }
     
  3. twofive
    OP

    Member twofive GBAtemp Regular

    Joined:
    Nov 20, 2008
    Messages:
    150
    Country:
    Poland
    I tried that already, it comes into conflict with libcios, so I can't use that.

    -- twofive
     
  4. twofive
    OP

    Member twofive GBAtemp Regular

    Joined:
    Nov 20, 2008
    Messages:
    150
    Country:
    Poland
    Anybody? [​IMG]
     

Share This Page