Hacking USB DVD Test

  • Thread starter knm
  • Start date
  • Views 2,516
  • Replies 1
  • Likes 2

knm

Well-Known Member
OP
Newcomer
Joined
Sep 30, 2012
Messages
61
Trophies
0
Age
39
XP
220
Country
United States
Hey guys, I found the code for External DVD for Wii, but it came from WiiMC forum page (http://www.wiimc.org/forum/viewtopic.php?f=4&t=1033&start=140#p4829 and http://www.wiimc.org/forum/viewtopic.php?f=5&p=4876#p4876):

And that's what USB DVD test code look like:

Code:
#include <gccore.h>
#include <wiiuse/wpad.h>

#include <fat.h>
#include <iso9660.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>


static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
const DISC_INTERFACE* usb = &__io_usbstorage;

int wait_button()
{
    u32 pressed = 0;
    while(1)
    {
        WPAD_ScanPads();
        pressed = WPAD_ButtonsDown(0);
        if (pressed) break;
        VIDEO_WaitVSync();
    }
    return pressed;
}

static void initialise_video()
{
    VIDEO_Init();
    rmode = VIDEO_GetPreferredMode(NULL);
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
    console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
    VIDEO_Configure(rmode);
    VIDEO_SetNextFramebuffer(xfb);
    VIDEO_SetBlack(FALSE);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
    printf("\x1b[2;0H");
    VIDEO_WaitVSync();
}

#define BUFFER_SIZE            0x8000
static u8 read_buffer[BUFFER_SIZE] __attribute__((aligned(32)));

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

    int i;
    u8 sector;

    initialise_video();
    WPAD_Init();

    printf("Press A when ready...\n");
    wait_button();

    while (1) {
   
        void USBStorage_Deinitialize();
        printf("USBStorage_Deinitialize...\n");
        USBStorage_Deinitialize();
        printf("Done\n");

        printf("startup...\n");
        usb->startup();
        printf("Done\n");

        usleep(1000000);
   
        printf("isInserted...\n");
        if(usb->isInserted())
        {
            printf("TRUE\n");
        } else {
            printf("FALSE... exiting\n");
            goto error;
        }
   
        sector = 16;
        if (!usb->readSectors(sector, 1, read_buffer)) {
            printf("readSectors failure reading sector %d\n", sector);
        }
   
        for(i=0; i<5; i++) {
            if (!ISO9660_Mount()) {
                printf("ISO9660_Mount failure... retry %d\n",i);
            } else break;
            usleep(1000000);
        }
        if (i==10) {
            printf("ISO9660_Mount failure... exiting\n");
            goto error;
        }
   
        DIR_ITER *pdir = NULL;
        struct stat statbuf;
        char filename[MAXPATHLEN];

        pdir = diropen("dvd:/VIDEO_TS");
        if (!pdir){
            printf ("ERROR: diropen() failure; terminating\n");
            goto error;
        }

        while (dirnext(pdir, filename, &statbuf)==0) {
            if(statbuf.st_mode & _IFDIR) {
                printf("%-8s  %s\n", "<dir>", filename);
            } else {
                printf("%8lld  %s\n", statbuf.st_size, filename);
            }
        }
        dirclose(pdir);

error:
        printf("Press A to retry, B to exit\n");
        if (wait_button()==WPAD_BUTTON_B)
            break;

    }
    return 0;
}

And found some of the codes for Uloader, but is a update log of 3.5 (https://github.com/spacemanspiff/uLoader/commit/deee059891158b2ba81804695db5d10e9494a250):

Code:
Browse files
Actualizada a uLoader 3.5
master  uLoader_v5.1E
…
uLoader_v3.5
1 parent a0f58f1 commit deee059891158b2ba81804695db5d10e9494a250 @spacemanspiff spacemanspiff committed on Feb 21, 2010
Unified Split
Showing  22 changed files  with 2,923 additions and 2,414 deletions.
View 2  apps/uloader/meta.xml
@@ -2,7 +2,7 @@
<app>
     <name> uLoader </name>
     <coder>Hermes</coder>
-    <version>3.3</version>
+    <version>3.5</version>
<short_description>USB Loader</short_description>
<long_description>Loader based on the work of Kwiirk and Waninkoko with Ocarina, video and language forced</long_description>
</app>
View 26  leeme.txt
@@ -1,4 +1,4 @@
-uLoader v3.3 - por Hermes (www.elotrolado.net)
+uLoader v3.5 - por Hermes (www.elotrolado.net)
  ----------------------------------------------------

  ATENCION: ejecuta primero cios_installer.dol (3.0 requerido). Ahora puedes seleccionar el IOS usado para instalar
@@ -11,6 +11,13 @@ para lanzar backups desde dispositivos de almacenamiento USB y con una interfaz
Caracteristicas:
  ---------------

+
+- Soporte para dispositivos DVD USB: Ello solo puede correr backups de DVD desde .iso (los juegos originales no funcionan debido a que los lectores
+  de DVD no soportan el formato Wii). Recuerda que debes insertar un DVD al empezar el programa para trabajar. Mira "Modo DVD USB" abajo en este leeme.txt
+  para mas detalles
+
+- Soporte a adido para salvar CFG, alternative dol, control parental, configuraci n de los juegos, etc desde modo DVD.
+
  - Soporte para datos BCA. Puedes a adirlos en la .ISO, offset 0x100 (64 bytes). Si esta area est  rellena con ceros it use un BCA por defecto (NSMB compatible).
    Nueva funcion ioctl 0xda soportada en dip_plugin y a adida nueva opcion para el modo DVD para leer los datos BCA Datas desde el DVD original.
    A adido soporte para salvar BCA en una base de datos en sd:/bca_database.txt
@@ -259,4 +266,21 @@ Modo Operacional del driver EHCI
- Soporte por interrupciones para liberar como USB 1.1 el resto de puertos (recuerda que el puerto 0 es siempre para USB 2.0)


+Modo DVD USB
+------------
+
+Al inicio:
+
+- Arranca uLoader con un lector DVD conectado al puerto USB e introduce un disco.
+
+  1- Mientras el disco es montado aparece el siguiente mensaje "ERROR: Can't Mount Device".
+
+  2- Si persiste con el DVD dentro, tal vez el lector no puede montar el disco porque no lo reconoce: cambia el disco o intenta reconectar el lector
+
+  3- Si aparece un error "ERROR: DVD Device Sector Size must be 2048 bytes", significa que el disco no es del tipo apropiado (por ejemplo, CD Audio XD)
+
+En la pantalla de carga de DVD:
+
+- Funciona exactamente igual que con el lector de Wii: puedes expulsar y cambiar de disco, etc desde el nuevo dispositivo

+NOTA: en este modo, no se pueden cargar discos desde el lector de Wii, obviamente
View 30  readme.txt
@@ -1,4 +1,4 @@
-uLoader v3.3 - by Hermes (www.elotrolado.net)
+uLoader v3.5 - by Hermes (www.elotrolado.net)
  ---------------------------------------------------

  WARNING: run at first cios_installer.dol (3.0 required). Now you can select the IOS used to install
@@ -11,6 +11,13 @@ to launch backups from USB mass storage devices with a graphical user interface
Features:
  ---------

+
+- Support for DVD USB Devices: It can run only DVD backups from .iso (original don't work
+  because DVD drivers don t support the Wii format). Remember you must insert a DVD
+  to work at start the program. See "Mode DVD USB" below in this readme for more details
+
+- Added support to save CFG, alternative dol, parental control and game configuration for DVD mode.
+
  - Support for BCA datas. You can add it from .ISO offset 0x100 (64 bytes). If this area is filled with zeroes it use one BCA by default (NSMB compatible).
    New ioctl 0xda function supported in dip_plugin and new option added for DVD mode to read the BCA Datas from the original DVD.
    Support added to save BCA data code in sd:/bca_database.txt file
@@ -258,3 +265,24 @@ Operational Mode for EHCI Driver
- Device mismatch (different device): fast frontal LED blinking

  - Interrupt support to free devices as USB 1.1 for others ports (remember you port 0 is always for USB 2.0 operations)
+
+Mode DVD USB
+------------
+
+At Start:
+
+- Run uLoader with a DVD device connected in the USB port and put a disc.
+
+  1- while the device is waiting to be mounted it display the next message "ERROR: Can't Mount Device".
+
+  2- if it use expensive time to get the DVD, maybe the DVD device can t read the disc (unknown format or other problem). Try reconnect the DVD device
+     or change the disc by other.
+
+  3- if it display "ERROR: DVD Device Sector Size must be 2048 bytes" you are using a bad format disc (for example CD audio XD)
+
+
+In the DVD screen loader:
+
+- It work exactly as DVD Wii device: You can eject and change the disc as you want from the new device
+
+NOTE: in this mode you can t load disc from the DVD Wii device how it is obvious
View 2  src/uloader/resources_modules/convert.bat
@@ -23,4 +23,4 @@ copy *.h ..\source\port1\*.h
del *.c
del *.h
-pause
+
View BIN  src/uloader/resources_modules/dip_plugin.bin
Binary file not shown.
View BIN  src/uloader/resources_modules/ehcmodule.elf
Binary file not shown.
View BIN  src/uloader/resources_modules/ehcmodule_port1.elf
Binary file not shown.
View 201  src/uloader/source/dip_plugin.c
@@ -1,85 +1,97 @@
-#define size_dip_plugin 3224
+#define size_dip_plugin 2968
-unsigned char dip_plugin[3224] __attribute__((aligned (32)))={
+unsigned char dip_plugin[2968] __attribute__((aligned (32)))={
      19, 119, 228, 85, 18, 52, 0, 1, 32, 34, 205, 172, 32, 32, 13, 57, 32, 32, 8, 197, 32, 32, 8, 153, 32, 32, 91, 129, 32,
-     32, 0, 73, 32, 32, 40, 117, 32, 32, 54, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 119, 233,
-     160, 19, 119, 233, 117, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 71, 120, 234, 0, 2, 23, 70, 192,
-     71, 120, 234, 0, 2, 39, 70, 192, 71, 120, 234, 0, 2, 55, 70, 192, 71, 120, 234, 0, 2, 47, 70, 192, 71, 120, 234, 0,
-     2, 21, 70, 192, 71, 120, 234, 0, 2, 7, 70, 192, 71, 120, 234, 0, 2, 45, 70, 192, 71, 120, 234, 0, 2, 41, 70, 192, 71,
-     120, 234, 0, 2, 49, 181, 0, 75, 7, 176, 137, 147, 0, 70, 104, 35, 0, 33, 0, 34, 0, 147, 1, 147, 2, 240, 0, 252, 157,
-     176, 9, 188, 2, 71, 8, 70, 192, 227, 0, 0, 0, 181, 16, 28, 3, 34, 32, 28, 12, 72, 13, 28, 25, 247, 255, 255, 210, 33,
-     32, 72, 11, 247, 255, 255, 202, 73, 10, 34, 1, 104, 11, 66, 19, 209, 253, 34, 32, 28, 32, 73, 6, 247, 255, 255, 196,
-     28, 32, 33, 32, 247, 255, 255, 188, 75, 4, 104, 24, 188, 16, 188, 2, 71, 8, 70, 192, 13, 0, 96, 0, 13, 0, 96, 28, 13,
-     0, 96, 32, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 10, 203, 70, 154, 75, 20, 176, 137, 37, 0, 28, 7, 28,
-     14, 70, 145, 70, 108, 70, 155, 70, 168, 70, 91, 96, 35, 70, 67, 96, 99, 96, 163, 70, 83, 96, 227, 28, 56, 70, 75, 28,
-     49, 97, 35, 247, 255, 255, 162, 70, 104, 28, 57, 28, 50, 240, 0, 252, 78, 53, 1, 40, 0, 209, 8, 176, 9, 188, 60, 70,
-     144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 45, 15, 217, 223, 231, 243, 208, 0, 0, 0, 181, 112, 176, 136,
-     75, 8, 28, 6, 28, 13, 70, 108, 147, 0, 96, 97, 146, 2, 247, 255, 255, 129, 28, 49, 28, 42, 70, 104, 240, 0, 252, 45,
-     176, 8, 188, 112, 188, 2, 71, 8, 168, 0, 0, 0, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176, 143, 144, 4,
-     145, 3, 146, 2, 41, 0, 209, 0, 224, 126, 10, 82, 70, 145, 35, 128, 34, 0, 1, 27, 70, 147, 34, 255, 147, 1, 3, 210, 171,
-     6, 146, 0, 70, 152, 224, 7, 154, 3, 68, 179, 69, 90, 217, 62, 154, 5, 24, 179, 10, 219, 68, 153, 154, 3, 70, 91, 26,
-     214, 70, 74, 2, 83, 154, 2, 66, 154, 216, 87, 35, 0, 147, 5, 36, 0, 159, 4, 34, 128, 68, 95, 28, 56, 28, 49, 1, 18,
-     240, 0, 248, 103, 44, 0, 209, 47, 40, 0, 208, 45, 155, 0, 28, 6, 66, 152, 217, 1, 38, 255, 3, 246, 10, 242, 70, 146,
-     36, 0, 75, 43, 70, 66, 96, 19, 35, 0, 96, 83, 96, 147, 70, 83, 96, 211, 70, 75, 97, 19, 28, 56, 28, 49, 247, 255, 255,
-     38, 70, 64, 28, 57, 28, 50, 240, 0, 251, 210, 52, 1, 28, 5, 40, 0, 208, 192, 44, 15, 217, 230, 45, 0, 208, 188, 176,
-     15, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 154, 5, 25, 147, 154, 1, 66, 147,
-     217, 1, 155, 5, 26, 214, 32, 128, 1, 0, 33, 32, 247, 255, 254, 251, 28, 4, 40, 0, 208, 18, 33, 128, 1, 9, 70, 74, 247,
-     255, 255, 59, 28, 5, 40, 0, 208, 15, 28, 32, 247, 255, 254, 217, 231, 216, 26, 211, 0, 155, 28, 28, 147, 5, 30, 99,
-     65, 156, 231, 163, 37, 1, 66, 109, 231, 208, 37, 0, 231, 206, 154, 5, 28, 56, 24, 161, 28, 50, 247, 255, 254, 214, 28,
-     56, 28, 49, 247, 255, 254, 206, 231, 228, 70, 192, 208, 0, 0, 0, 181, 48, 28, 13, 28, 20, 6, 195, 209, 18, 75, 15, 66,
-     152, 217, 19, 33, 0, 75, 14, 24, 194, 75, 14, 66, 154, 216, 1, 75, 13, 26, 25, 66, 161, 211, 5, 28, 8, 66, 169, 216,
-     10, 30, 99, 67, 152, 224, 0, 32, 0, 188, 48, 188, 2, 71, 8, 35, 192, 4, 91, 26, 25, 231, 232, 28, 40, 30, 99, 67, 152,
-     231, 244, 1, 127, 255, 255, 240, 0, 0, 0, 3, 97, 127, 255, 19, 97, 128, 0, 71, 112, 70, 192, 181, 48, 28, 4, 72, 15,
-     28, 13, 104, 131, 104, 193, 176, 129, 24, 91, 24, 154, 105, 3, 43, 0, 209, 15, 104, 67, 43, 0, 209, 7, 28, 32, 28, 41,
-     247, 255, 255, 13, 176, 1, 188, 48, 188, 2, 71, 8, 28, 32, 28, 41, 247, 255, 255, 27, 231, 246, 28, 32, 28, 41, 240,
-     0, 249, 246, 231, 241, 70, 192, 19, 119, 240, 0, 181, 240, 79, 27, 35, 1, 28, 4, 96, 59, 176, 129, 33, 32, 247, 255,
-     254, 127, 104, 227, 43, 8, 208, 8, 28, 32, 240, 0, 250, 246, 35, 0, 96, 59, 176, 1, 188, 240, 188, 2, 71, 8, 105, 163,
-     37, 197, 104, 24, 104, 89, 247, 255, 254, 109, 105, 163, 1, 173, 104, 27, 28, 40, 33, 8, 104, 92, 104, 30, 247, 255,
-     254, 100, 75, 10, 4, 36, 64, 30, 67, 52, 78, 9, 96, 44, 28, 40, 33, 4, 96, 52, 247, 255, 254, 73, 28, 48, 33, 4, 247,
-     255, 254, 69, 35, 0, 96, 59, 32, 0, 231, 217, 70, 192, 19, 119, 240, 40, 0, 0, 255, 255, 0, 0, 49, 136, 181, 16, 73,
-     20, 28, 4, 104, 139, 104, 202, 24, 154, 105, 11, 43, 0, 209, 18, 104, 75, 43, 0, 209, 11, 33, 32, 247, 255, 254, 175,
-     40, 0, 219, 3, 105, 162, 75, 12, 66, 154, 208, 10, 188, 16, 188, 2, 71, 8, 33, 32, 247, 255, 254, 185, 231, 242, 33,
-     32, 240, 0, 249, 149, 231, 238, 75, 6, 34, 1, 112, 26, 120, 91, 43, 0, 209, 238, 247, 255, 254, 10, 231, 235, 70, 192,
-     19, 119, 240, 0, 93, 28, 158, 163, 32, 34, 205, 172, 181, 240, 70, 87, 70, 70, 180, 192, 28, 6, 120, 0, 176, 129, 28,
-     15, 70, 144, 40, 224, 208, 24, 77, 145, 35, 0, 98, 43, 28, 3, 59, 112, 43, 143, 217, 13, 28, 48, 28, 57, 70, 66, 240,
-     0, 250, 180, 28, 4, 176, 1, 28, 32, 188, 12, 70, 144, 70, 154, 188, 240, 188, 2, 71, 8, 74, 135, 0, 155, 88, 211, 70,
-     159, 77, 132, 106, 43, 43, 0, 209, 2, 105, 43, 43, 0, 208, 230, 28, 56, 33, 0, 70, 66, 240, 0, 249, 10, 106, 43, 96,
-     59, 28, 56, 70, 65, 247, 255, 253, 212, 36, 0, 231, 223, 104, 107, 43, 0, 209, 2, 105, 43, 43, 0, 208, 211, 36, 0, 231,
-     215, 104, 107, 43, 0, 209, 2, 105, 43, 43, 0, 208, 203, 28, 56, 33, 0, 70, 66, 240, 0, 248, 239, 28, 56, 70, 65, 247,
-     255, 253, 187, 36, 0, 231, 198, 104, 115, 36, 0, 96, 171, 231, 194, 104, 171, 231, 217, 104, 115, 36, 0, 96, 43, 231,
-     188, 104, 43, 231, 211, 104, 115, 97, 43, 43, 0, 208, 6, 28, 40, 28, 49, 48, 24, 49, 8, 34, 6, 247, 255, 253, 166, 105,
-     115, 36, 0, 97, 107, 231, 171, 105, 43, 231, 194, 104, 114, 35, 36, 84, 234, 36, 0, 231, 164, 104, 235, 104, 172, 70,
-     154, 105, 43, 43, 0, 209, 0, 224, 170, 32, 0, 34, 0, 70, 83, 67, 35, 209, 2, 42, 0, 209, 0, 224, 142, 28, 3, 30, 90,
-     65, 147, 96, 107, 28, 56, 70, 65, 247, 255, 255, 70, 28, 4, 231, 139, 35, 1, 34, 37, 84, 171, 104, 43, 43, 0, 209, 0,
-     224, 132, 104, 113, 104, 178, 28, 56, 247, 255, 254, 214, 28, 4, 34, 0, 35, 37, 84, 234, 44, 0, 208, 0, 231, 120, 28,
-     56, 70, 65, 247, 255, 254, 201, 231, 115, 104, 115, 72, 70, 64, 24, 247, 255, 253, 139, 28, 4, 231, 108, 76, 68, 33,
-     64, 28, 32, 247, 255, 253, 106, 34, 0, 28, 33, 224, 3, 50, 1, 42, 64, 209, 0, 231, 90, 92, 163, 43, 0, 208, 248, 34,
-     64, 28, 56, 247, 255, 253, 80, 28, 56, 33, 64, 247, 255, 253, 72, 36, 0, 231, 83, 35, 36, 92, 234, 42, 0, 208, 0, 231,
-     116, 84, 234, 35, 37, 84, 234, 105, 43, 96, 42, 96, 106, 96, 170, 96, 234, 98, 42, 70, 154, 43, 0, 209, 0, 231, 59,
-     105, 108, 247, 255, 253, 73, 70, 80, 28, 41, 28, 34, 56, 1, 49, 24, 240, 0, 248, 206, 28, 4, 231, 53, 104, 113, 104,
-     178, 40, 208, 208, 59, 28, 56, 247, 255, 254, 133, 28, 4, 40, 0, 208, 0, 231, 42, 35, 37, 92, 235, 43, 0, 208, 0, 231,
-     37, 231, 171, 105, 43, 43, 0, 209, 0, 231, 26, 35, 2, 231, 55, 104, 107, 43, 0, 209, 3, 105, 43, 43, 0, 209, 0, 231,
-     17, 104, 115, 104, 178, 7, 155, 67, 19, 74, 24, 36, 0, 64, 19, 96, 235, 231, 14, 104, 107, 43, 0, 208, 17, 75, 21, 36,
-     160, 98, 43, 2, 36, 231, 6, 105, 43, 43, 0, 208, 0, 231, 108, 96, 106, 36, 0, 230, 255, 28, 48, 70, 66, 240, 0, 249,
-     175, 28, 4, 231, 122, 105, 43, 43, 0, 209, 234, 230, 239, 2, 201, 2, 82, 231, 192, 70, 66, 28, 48, 240, 0, 249, 162,
-     28, 2, 30, 83, 65, 154, 231, 78, 70, 192, 19, 119, 240, 0, 19, 119, 234, 32, 127, 255, 255, 255, 19, 119, 233, 160,
-     255, 255, 128, 0, 0, 5, 49, 0, 181, 240, 70, 87, 70, 78, 70, 69, 180, 224, 70, 128, 28, 14, 70, 148, 42, 0, 208, 51,
-     33, 3, 28, 2, 64, 10, 35, 4, 26, 155, 28, 24, 64, 8, 69, 96, 216, 49, 40, 0, 208, 49, 36, 0, 70, 67, 85, 30, 52, 1,
-     66, 160, 216, 250, 69, 132, 208, 32, 70, 99, 26, 27, 8, 159, 70, 153, 0, 187, 70, 154, 43, 0, 208, 17, 4, 51, 6, 50,
-     2, 49, 67, 26, 67, 10, 28, 21, 70, 67, 67, 53, 24, 26, 33, 0, 0, 139, 49, 1, 80, 213, 66, 185, 211, 250, 68, 84, 69,
-     209, 208, 6, 70, 67, 25, 24, 52, 1, 112, 6, 48, 1, 69, 164, 216, 250, 188, 28, 70, 144, 70, 153, 70, 162, 188, 240,
-     188, 1, 71, 0, 70, 96, 231, 203, 36, 0, 231, 211, 70, 192, 181, 112, 76, 17, 28, 6, 104, 32, 176, 130, 28, 13, 98, 2,
-     97, 6, 100, 1, 97, 65, 33, 68, 247, 255, 252, 121, 28, 48, 28, 41, 247, 255, 252, 117, 75, 10, 34, 2, 104, 24, 104,
-     35, 73, 9, 147, 0, 35, 1, 247, 255, 252, 128, 28, 41, 28, 4, 28, 48, 247, 255, 252, 119, 176, 2, 28, 32, 188, 112, 188,
-     2, 71, 8, 19, 119, 240, 44, 19, 119, 240, 48, 87, 70, 83, 2, 181, 240, 176, 133, 28, 4, 28, 15, 146, 3, 40, 2, 216,
-     75, 77, 47, 104, 43, 43, 0, 208, 74, 78, 46, 104, 48, 40, 0, 219, 1, 247, 255, 252, 71, 74, 44, 0, 163, 88, 152, 33,
-     1, 247, 255, 252, 81, 96, 48, 40, 0, 219, 66, 104, 48, 40, 0, 219, 49, 104, 40, 28, 57, 34, 6, 48, 32, 247, 255, 252,
-     61, 104, 40, 169, 3, 34, 4, 48, 64, 247, 255, 252, 55, 104, 42, 36, 4, 28, 19, 51, 32, 96, 19, 104, 42, 35, 6, 96, 83,
-     104, 42, 33, 68, 28, 19, 51, 64, 96, 147, 104, 43, 96, 220, 104, 40, 247, 255, 252, 33, 104, 43, 104, 48, 34, 2, 147,
-     0, 73, 22, 35, 0, 247, 255, 252, 45, 104, 42, 28, 19, 51, 32, 96, 19, 104, 43, 96, 92, 104, 42, 28, 19, 51, 64, 96,
-     147, 104, 43, 96, 220, 176, 5, 188, 240, 188, 2, 71, 8, 32, 1, 66, 64, 231, 248, 75, 11, 78, 8, 96, 43, 35, 1, 66, 91,
-     96, 51, 231, 179, 44, 0, 209, 186, 72, 8, 33, 1, 247, 255, 252, 5, 96, 48, 231, 180, 70, 192, 19, 119, 240, 44, 19,
-     119, 240, 48, 19, 119, 236, 140, 87, 70, 83, 1, 19, 119, 240, 64, 19, 119, 236, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+     32, 0, 73, 32, 32, 40, 117, 32, 32, 54, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 119, 234,
+     224, 19, 119, 234, 181, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 71, 120, 234, 0, 2, 103, 70,
+     192, 71, 120, 234, 0, 2, 119, 70, 192, 71, 120, 234, 0, 2, 135, 70, 192, 71, 120, 234, 0, 2, 127, 70, 192, 71, 120,
+     234, 0, 2, 101, 70, 192, 71, 120, 234, 0, 2, 87, 70, 192, 71, 120, 234, 0, 2, 125, 70, 192, 71, 120, 234, 0, 2, 121,
+     70, 192, 71, 120, 234, 0, 2, 129, 181, 0, 75, 7, 176, 137, 147, 0, 70, 104, 35, 0, 33, 0, 34, 0, 147, 1, 147, 2, 240,
+     0, 253, 61, 176, 9, 188, 2, 71, 8, 70, 192, 227, 0, 0, 0, 181, 16, 28, 3, 34, 32, 28, 12, 72, 13, 28, 25, 247, 255,
+     255, 210, 33, 32, 72, 11, 247, 255, 255, 202, 73, 10, 34, 1, 104, 11, 66, 19, 209, 253, 34, 32, 28, 32, 73, 6, 247,
+     255, 255, 196, 28, 32, 33, 32, 247, 255, 255, 188, 75, 4, 104, 24, 188, 16, 188, 2, 71, 8, 70, 192, 13, 0, 96, 0, 13,
+     0, 96, 28, 13, 0, 96, 32, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 10, 203, 70, 154, 75, 20, 176, 137, 37,
+     0, 28, 7, 28, 14, 70, 145, 70, 108, 70, 155, 70, 168, 70, 91, 96, 35, 70, 67, 96, 99, 96, 163, 70, 83, 96, 227, 28,
+     56, 70, 75, 28, 49, 97, 35, 247, 255, 255, 162, 70, 104, 28, 57, 28, 50, 240, 0, 252, 238, 53, 1, 40, 0, 209, 8, 176,
+     9, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 45, 15, 217, 223, 231, 243, 208, 0, 0, 0, 181,
+     112, 176, 136, 75, 8, 28, 6, 28, 13, 70, 108, 147, 0, 96, 97, 146, 2, 247, 255, 255, 129, 28, 49, 28, 42, 70, 104, 240,
+     0, 252, 205, 176, 8, 188, 112, 188, 2, 71, 8, 168, 0, 0, 0, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240, 176,
+     143, 144, 4, 145, 3, 146, 2, 41, 0, 209, 0, 224, 126, 10, 82, 70, 145, 35, 128, 34, 0, 1, 27, 70, 147, 34, 255, 147,
+     1, 3, 210, 171, 6, 146, 0, 70, 152, 224, 7, 154, 3, 68, 179, 69, 90, 217, 62, 154, 5, 24, 179, 10, 219, 68, 153, 154,
+     3, 70, 91, 26, 214, 70, 74, 2, 83, 154, 2, 66, 154, 216, 87, 35, 0, 147, 5, 36, 0, 159, 4, 34, 128, 68, 95, 28, 56,
+     28, 49, 1, 18, 240, 0, 248, 103, 44, 0, 209, 47, 40, 0, 208, 45, 155, 0, 28, 6, 66, 152, 217, 1, 38, 255, 3, 246, 10,
+     242, 70, 146, 36, 0, 75, 43, 70, 66, 96, 19, 35, 0, 96, 83, 96, 147, 70, 83, 96, 211, 70, 75, 97, 19, 28, 56, 28, 49,
+     247, 255, 255, 38, 70, 64, 28, 57, 28, 50, 240, 0, 252, 114, 52, 1, 28, 5, 40, 0, 208, 192, 44, 15, 217, 230, 45, 0,
+     208, 188, 176, 15, 28, 40, 188, 60, 70, 144, 70, 153, 70, 162, 70, 171, 188, 240, 188, 2, 71, 8, 154, 5, 25, 147, 154,
+     1, 66, 147, 217, 1, 155, 5, 26, 214, 32, 128, 1, 0, 33, 32, 247, 255, 254, 251, 28, 4, 40, 0, 208, 18, 33, 128, 1, 9,
+     70, 74, 247, 255, 255, 59, 28, 5, 40, 0, 208, 15, 28, 32, 247, 255, 254, 217, 231, 216, 26, 211, 0, 155, 28, 28, 147,
+     5, 30, 99, 65, 156, 231, 163, 37, 1, 66, 109, 231, 208, 37, 0, 231, 206, 154, 5, 28, 56, 24, 161, 28, 50, 247, 255,
+     254, 214, 28, 56, 28, 49, 247, 255, 254, 206, 231, 228, 70, 192, 208, 0, 0, 0, 181, 48, 28, 13, 28, 20, 6, 195, 209,
+     18, 75, 15, 66, 152, 217, 19, 33, 0, 75, 14, 24, 194, 75, 14, 66, 154, 216, 1, 75, 13, 26, 25, 66, 161, 211, 5, 28,
+     8, 66, 169, 216, 10, 30, 99, 67, 152, 224, 0, 32, 0, 188, 48, 188, 2, 71, 8, 35, 192, 4, 91, 26, 25, 231, 232, 28, 40,
+     30, 99, 67, 152, 231, 244, 1, 127, 255, 255, 240, 0, 0, 0, 3, 97, 127, 255, 19, 97, 128, 0, 71, 112, 70, 192, 181, 48,
+     28, 4, 72, 15, 28, 13, 104, 131, 104, 193, 176, 129, 24, 91, 24, 154, 105, 3, 43, 0, 209, 15, 104, 67, 43, 0, 209, 7,
+     28, 32, 28, 41, 247, 255, 255, 13, 176, 1, 188, 48, 188, 2, 71, 8, 28, 32, 28, 41, 247, 255, 255, 27, 231, 246, 28,
+     32, 28, 41, 240, 0, 250, 94, 231, 241, 70, 192, 19, 119, 240, 0, 181, 240, 79, 27, 35, 1, 28, 4, 96, 59, 176, 129, 33,
+     32, 247, 255, 254, 127, 104, 227, 43, 8, 208, 8, 28, 32, 240, 0, 251, 150, 35, 0, 96, 59, 176, 1, 188, 240, 188, 2,
+     71, 8, 105, 163, 37, 197, 104, 24, 104, 89, 247, 255, 254, 109, 105, 163, 1, 173, 104, 27, 28, 40, 33, 8, 104, 92, 104,
+     30, 247, 255, 254, 100, 75, 10, 4, 36, 64, 30, 67, 52, 78, 9, 96, 44, 28, 40, 33, 4, 96, 52, 247, 255, 254, 73, 28,
+     48, 33, 4, 247, 255, 254, 69, 35, 0, 96, 59, 32, 0, 231, 217, 70, 192, 19, 119, 240, 40, 0, 0, 255, 255, 0, 0, 49, 136,
+     181, 16, 73, 20, 28, 4, 104, 139, 104, 202, 24, 154, 105, 11, 43, 0, 209, 18, 104, 75, 43, 0, 209, 11, 33, 32, 247,
+     255, 254, 175, 40, 0, 219, 3, 105, 162, 75, 12, 66, 154, 208, 10, 188, 16, 188, 2, 71, 8, 33, 32, 247, 255, 254, 185,
+     231, 242, 33, 32, 240, 0, 249, 253, 231, 238, 75, 6, 34, 1, 112, 26, 120, 91, 43, 0, 209, 238, 247, 255, 254, 10, 231,
+     235, 70, 192, 19, 119, 240, 0, 93, 28, 158, 163, 32, 34, 205, 172, 181, 240, 70, 87, 70, 70, 180, 192, 28, 6, 120, 0,
+     176, 129, 28, 15, 70, 144, 40, 224, 208, 29, 77, 181, 35, 0, 98, 43, 40, 217, 208, 117, 40, 217, 216, 43, 40, 138, 209,
+     0, 224, 138, 40, 138, 216, 81, 40, 112, 209, 0, 224, 200, 40, 112, 216, 0, 224, 182, 40, 113, 209, 0, 224, 245, 40,
+     121, 208, 0, 224, 157, 105, 43, 43, 0, 209, 0, 224, 153, 36, 0, 224, 106, 77, 166, 106, 43, 43, 0, 209, 3, 105, 43,
+     43, 0, 209, 0, 224, 143, 28, 56, 33, 0, 70, 66, 240, 0, 249, 76, 106, 43, 96, 59, 28, 56, 70, 65, 247, 255, 253, 206,
+     36, 0, 224, 85, 40, 242, 208, 91, 40, 242, 216, 13, 40, 228, 209, 0, 224, 240, 40, 228, 216, 0, 224, 149, 40, 240, 209,
+     0, 224, 198, 40, 241, 208, 0, 224, 114, 104, 171, 231, 230, 40, 245, 209, 0, 224, 221, 40, 245, 217, 0, 224, 113, 40,
+     243, 209, 0, 224, 218, 40, 244, 209, 101, 104, 115, 97, 43, 43, 0, 208, 5, 28, 49, 72, 139, 49, 8, 34, 6, 247, 255,
+     253, 169, 105, 115, 36, 0, 97, 107, 224, 42, 40, 168, 208, 6, 40, 168, 217, 79, 40, 171, 209, 0, 224, 214, 40, 208,
+     209, 78, 104, 113, 104, 178, 40, 208, 209, 0, 224, 248, 28, 56, 247, 255, 254, 244, 28, 4, 40, 0, 209, 22, 35, 37, 92,
+     235, 43, 0, 209, 18, 28, 56, 70, 65, 247, 255, 254, 231, 224, 13, 104, 107, 43, 0, 209, 2, 105, 43, 43, 0, 208, 52,
+     104, 115, 104, 178, 7, 155, 67, 19, 74, 116, 36, 0, 64, 19, 96, 235, 176, 1, 28, 32, 188, 12, 70, 144, 70, 154, 188,
+     240, 188, 2, 71, 8, 104, 115, 36, 0, 96, 43, 231, 243, 35, 36, 92, 234, 42, 0, 208, 0, 231, 129, 84, 234, 35, 37, 84,
+     234, 105, 43, 96, 42, 96, 106, 96, 170, 96, 234, 98, 42, 70, 154, 43, 0, 208, 15, 105, 108, 247, 255, 253, 110, 70,
+     80, 28, 41, 28, 34, 56, 1, 49, 24, 240, 0, 249, 119, 28, 4, 231, 214, 40, 141, 208, 178, 40, 164, 208, 103, 28, 48,
+     28, 57, 70, 66, 240, 0, 250, 165, 28, 4, 231, 203, 40, 246, 209, 0, 224, 129, 40, 255, 209, 243, 104, 115, 72, 86, 64,
+     24, 247, 255, 253, 98, 28, 4, 231, 191, 40, 19, 209, 234, 105, 43, 43, 0, 208, 0, 224, 131, 35, 2, 96, 11, 36, 0, 231,
+     181, 40, 218, 208, 25, 40, 224, 209, 222, 231, 70, 104, 235, 104, 172, 70, 154, 105, 43, 43, 0, 208, 127, 32, 0, 34,
+     0, 70, 83, 67, 35, 209, 1, 42, 0, 208, 97, 28, 3, 30, 90, 65, 147, 96, 107, 28, 56, 70, 65, 247, 255, 254, 216, 28,
+     4, 231, 153, 76, 65, 33, 64, 28, 32, 247, 255, 253, 27, 34, 0, 28, 33, 224, 2, 50, 1, 42, 64, 208, 187, 92, 163, 43,
+     0, 208, 249, 34, 64, 28, 56, 247, 255, 253, 2, 28, 56, 33, 64, 247, 255, 252, 250, 36, 0, 231, 129, 104, 115, 36, 0,
+     96, 171, 231, 125, 35, 1, 34, 37, 84, 171, 104, 43, 43, 0, 208, 59, 104, 113, 104, 178, 28, 56, 247, 255, 254, 77, 28,
+     4, 34, 0, 35, 37, 84, 234, 44, 0, 208, 0, 231, 107, 231, 87, 104, 107, 43, 0, 208, 56, 75, 41, 36, 160, 98, 43, 2, 36,
+     231, 98, 105, 43, 96, 11, 231, 3, 104, 43, 231, 0, 104, 107, 43, 0, 209, 2, 105, 43, 43, 0, 208, 132, 28, 56, 33, 0,
+     70, 66, 240, 0, 248, 65, 28, 56, 70, 65, 247, 255, 252, 197, 36, 0, 231, 76, 104, 107, 43, 0, 209, 0, 230, 215, 36,
+     0, 231, 70, 104, 114, 35, 36, 84, 234, 36, 0, 231, 65, 105, 43, 43, 0, 209, 154, 96, 106, 36, 0, 231, 59, 28, 48, 70,
+     66, 240, 0, 250, 15, 28, 4, 231, 195, 240, 0, 248, 108, 40, 0, 208, 16, 35, 2, 96, 59, 230, 210, 105, 43, 43, 0, 209,
+     195, 231, 87, 28, 48, 240, 0, 249, 255, 28, 2, 30, 83, 65, 154, 231, 122, 2, 201, 2, 82, 231, 3, 35, 0, 96, 59, 230,
+     193, 19, 119, 240, 0, 19, 119, 240, 24, 255, 255, 128, 0, 127, 255, 255, 255, 19, 119, 234, 224, 0, 5, 49, 0, 181, 240,
+     70, 87, 70, 78, 70, 69, 180, 224, 70, 128, 28, 14, 70, 148, 42, 0, 208, 51, 33, 3, 28, 2, 64, 10, 35, 4, 26, 155, 28,
+     24, 64, 8, 69, 96, 216, 49, 40, 0, 208, 49, 36, 0, 70, 67, 85, 30, 52, 1, 66, 160, 216, 250, 69, 132, 208, 32, 70, 99,
+     26, 27, 8, 159, 70, 153, 0, 187, 70, 154, 43, 0, 208, 17, 4, 51, 6, 50, 2, 49, 67, 26, 67, 10, 28, 21, 70, 67, 67, 53,
+     24, 26, 33, 0, 0, 139, 49, 1, 80, 213, 66, 185, 211, 250, 68, 84, 69, 209, 208, 6, 70, 67, 25, 24, 52, 1, 112, 6, 48,
+     1, 69, 164, 216, 250, 188, 28, 70, 144, 70, 153, 70, 162, 188, 240, 188, 1, 71, 0, 70, 96, 231, 203, 36, 0, 231, 211,
+     70, 192, 181, 0, 75, 11, 176, 131, 104, 27, 43, 0, 208, 12, 75, 9, 104, 24, 40, 0, 219, 8, 75, 8, 73, 9, 104, 27, 34,
+     0, 147, 0, 35, 0, 247, 255, 252, 64, 224, 0, 32, 1, 176, 3, 188, 2, 71, 8, 70, 192, 19, 119, 240, 44, 19, 119, 240,
+     52, 19, 119, 240, 48, 87, 70, 83, 4, 181, 240, 77, 29, 176, 131, 104, 43, 28, 7, 28, 14, 43, 0, 219, 48, 76, 26, 104,
+     35, 98, 26, 104, 35, 99, 217, 104, 35, 97, 24, 104, 35, 97, 89, 104, 32, 33, 64, 247, 255, 252, 9, 28, 56, 28, 49, 247,
+     255, 252, 5, 75, 19, 104, 27, 43, 0, 209, 17, 104, 35, 104, 40, 73, 17, 147, 0, 34, 2, 35, 1, 247, 255, 252, 13, 28,
+     4, 28, 56, 28, 49, 247, 255, 252, 4, 176, 3, 28, 32, 188, 240, 188, 2, 71, 8, 104, 35, 104, 40, 73, 9, 147, 0, 34, 2,
+     35, 1, 247, 255, 251, 251, 28, 4, 231, 236, 36, 1, 66, 100, 231, 237, 19, 119, 240, 52, 19, 119, 240, 48, 19, 119, 240,
+     44, 87, 70, 83, 2, 87, 70, 83, 3, 181, 240, 70, 71, 180, 128, 176, 132, 28, 4, 70, 136, 146, 3, 40, 2, 216, 90, 78,
+     60, 104, 51, 43, 0, 208, 89, 79, 59, 104, 56, 40, 0, 219, 1, 247, 255, 251, 193, 74, 57, 35, 0, 96, 19, 70, 65, 120,
+     11, 43, 95, 208, 83, 74, 54, 0, 163, 88, 152, 33, 1, 247, 255, 251, 196, 96, 56, 40, 0, 219, 86, 104, 61, 45, 0, 219,
+     54, 104, 48, 70, 65, 34, 6, 48, 32, 247, 255, 251, 176, 104, 48, 169, 3, 34, 4, 48, 60, 247, 255, 251, 170, 104, 50,
+     36, 4, 28, 19, 51, 32, 96, 19, 104, 50, 35, 6, 96, 83, 104, 50, 33, 64, 28, 19, 51, 60, 96, 147, 104, 51, 96, 220, 104,
+     48, 247, 255, 251, 148, 104, 51, 104, 56, 73, 33, 147, 0, 34, 2, 35, 0, 247, 255, 251, 160, 104, 50, 28, 5, 28, 19,
+     51, 32, 96, 19, 104, 51, 33, 64, 96, 92, 104, 50, 28, 19, 51, 60, 96, 147, 104, 51, 96, 220, 104, 48, 247, 255, 251,
+     123, 176, 4, 28, 40, 188, 4, 70, 144, 188, 240, 188, 2, 71, 8, 37, 1, 66, 109, 231, 245, 75, 18, 79, 13, 96, 51, 35,
+     1, 66, 91, 96, 59, 231, 164, 120, 75, 43, 68, 209, 168, 120, 139, 43, 86, 209, 165, 120, 203, 43, 68, 209, 162, 35,
+     1, 96, 19, 231, 159, 44, 0, 209, 166, 72, 8, 33, 1, 247, 255, 251, 100, 96, 56, 231, 160, 19, 119, 240, 48, 19, 119,
+     240, 52, 19, 119, 240, 44, 19, 119, 235, 140, 87, 70, 83, 1, 19, 119, 240, 64, 19, 119, 235, 96, 0, 0, 0, 0, 0, 0, 0,
      0, 233, 45, 64, 128, 229, 159, 113, 80, 229, 151, 112, 0, 235, 0, 0, 45, 232, 189, 64, 128, 225, 47, 255, 30, 233, 45,
      64, 128, 229, 159, 113, 60, 229, 151, 112, 0, 235, 0, 0, 39, 232, 189, 64, 128, 225, 47, 255, 30, 233, 45, 64, 128,
      229, 159, 113, 40, 229, 151, 112, 0, 235, 0, 0, 33, 232, 189, 64, 128, 225, 47, 255, 30, 233, 45, 64, 128, 229, 159,
@@ -88,35 +100,12 @@ unsigned char dip_plugin[3224] __attribute__((aligned (32)))={
      0, 235, 0, 0, 15, 232, 189, 64, 128, 225, 47, 255, 30, 230, 0, 8, 16, 225, 47, 255, 30, 230, 0, 7, 240, 225, 47, 255,
      30, 230, 0, 3, 144, 225, 47, 255, 30, 230, 0, 3, 176, 225, 47, 255, 30, 230, 0, 3, 208, 225, 47, 255, 30, 230, 0, 3,
      240, 225, 47, 255, 30, 230, 0, 4, 80, 225, 47, 255, 30, 225, 47, 255, 23, 239, 0, 0, 204, 225, 47, 255, 30, 180, 124,
-     181, 0, 247, 255, 252, 254, 188, 2, 188, 124, 71, 8, 181, 112, 176, 136, 104, 133, 28, 1, 75, 34, 71, 24, 70, 192, 70,
+     181, 0, 247, 255, 252, 94, 188, 2, 188, 124, 71, 8, 181, 112, 176, 136, 104, 133, 28, 1, 75, 34, 71, 24, 70, 192, 70,
      192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 70, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 114, 28, 1, 32, 4, 223, 171, 71, 16, 181, 240, 70, 95, 70, 86, 70, 77, 70, 68, 180, 240,
      75, 8, 104, 27, 71, 24, 19, 119, 224, 16, 19, 119, 224, 20, 19, 119, 224, 24, 19, 119, 224, 28, 19, 119, 224, 32, 19,
-     119, 224, 36, 32, 16, 0, 213, 19, 119, 224, 12, 70, 192, 70, 192, 19, 119, 229, 58, 19, 119, 229, 108, 19, 119, 228,
-     120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120,
-     19, 119, 228, 202, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19,
-     119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119,
-     228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 230, 58, 19, 119, 228, 120, 19, 119, 229, 220, 19, 119, 228,
-     120, 19, 119, 228, 120, 19, 119, 230, 24, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120,
-     19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19,
-     119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119,
-     228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 230,
-     102, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 230, 24, 19, 119, 228, 120, 19, 119, 228, 120,
-     19, 119, 228, 196, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19,
-     119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119,
-     228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228,
-     120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120,
-     19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19,
-     119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119,
-     230, 24, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228,
-     120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 230, 70, 19, 119, 229, 170, 19, 119, 228, 120, 19, 119, 228, 120,
-     19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 158, 19, 119, 228, 120, 19, 119, 228, 120, 19,
-     119, 228, 120, 19, 119, 228, 212, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119,
-     228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228,
-     120, 19, 119, 228, 246, 19, 119, 228, 254, 19, 119, 229, 2, 19, 119, 229, 10, 19, 119, 229, 14, 19, 119, 229, 44, 19,
-     119, 229, 48, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119,
-     228, 120, 19, 119, 228, 120, 19, 119, 228, 120, 19, 119, 229, 156, 47, 100, 101, 118, 47, 117, 115, 98, 47, 101, 104,
+     119, 224, 36, 32, 16, 0, 213, 19, 119, 224, 12, 70, 192, 70, 192, 47, 100, 101, 118, 47, 117, 115, 98, 47, 101, 104,
      99, 0, 0, 0, 0, 47, 100, 101, 118, 47, 117, 115, 98, 50, 0, 0, 0, 47, 100, 101, 118, 47, 115, 100, 105, 111, 47, 115,
-     100, 104, 99, 0, 0, 19, 119, 236, 112, 19, 119, 236, 124, 19, 119, 236, 96
+     100, 104, 99, 0, 0, 19, 119, 235, 112, 19, 119, 235, 124, 19, 119, 235, 96
};
View 4  src/uloader/source/dip_plugin.h
@@ -1,3 +1,3 @@
-#define size_dip_plugin 3224
+#define size_dip_plugin 2968
-extern unsigned char dip_plugin[3224];
+extern unsigned char dip_plugin[2968];
View 14  src/uloader/source/disc.c
@@ -95,6 +95,20 @@ s32 Disc_Wait(void)
     return 0;
}
+s32 Disc_USB_DVD_Wait(void)
+{
+    u32 cover = 0;
+    s32 ret;
+
+        /* Get cover status */
+        ret = WDVD_GetCoverStatus_USB_DVD(&cover);
+        if (ret < 0)
+            return ret;
+        if(!(cover & 0x2)) return 1;
+
+    return 0;
+}
+
s32 Disc_ReadHeader(void *outbuf)
{
View 1  src/uloader/source/disc.h
@@ -38,6 +38,7 @@ struct discHdr
s32  Disc_Init(void);
s32  Disc_Open(void);
s32  Disc_Wait(void);
+s32  Disc_USB_DVD_Wait(void);
s32  Disc_SetWBFS(u32, u8 *);
s32  Disc_ReadHeader(void *);
s32  Disc_IsWii(void);
View 8  src/uloader/source/gfx.c
@@ -109,10 +109,10 @@ void splash_scr()
             letter_size(8,16);
             SelectFontTexture(1);
             #ifndef ALTERNATIVE_VERSION
-            s_printf("v3.3");
+            s_printf("v3.5");
             #endif
             PX=SCR_WIDTH-20-32;
-            s_printf("v3.3");
+            s_printf("v3.5");
             autocenter=1;
             //letter_size(12,16);
             PX=20; PY= 480-40; color= 0xff000000;
@@ -712,6 +712,8 @@ int ylev=(SCR_HEIGHT-440);
  
     if(n==0) color=0xffffffff; else color=0x27ffffff;
+    if(mode_disc & 2) color=(color & 0xff000000) | 0x20ff6f;
+
     SetTexture(&text_icon[3]);
     ConfigureForTexture(10);
     GX_Begin(GX_TRIANGLESTRIP,  GX_VTXFMT0, 5);
@@ -868,6 +870,8 @@ int ylev=(SCR_HEIGHT-440);
  
     if(n==0) color=0xffffffff; else color=0x27ffffff;
+    if(mode_disc & 2) color=(color & 0xff000000) | 0x20ff6f;
+
     SetTexture(&text_icon[3]);
     ConfigureForTexture(10);
     GX_Begin(GX_TRIANGLESTRIP,  GX_VTXFMT0, 5);
View 2  src/uloader/source/gfx.h
@@ -53,6 +53,8 @@ extern int idioma;
extern char letrero[2][60][64];
+extern int mode_disc;
+
/*-----------------------------------------------------------------------------------------------------------------------------------*/
extern int flag_snow;
View 2,341  src/uloader/source/port0/ehcmodule.c
1,189 additions, 1,152 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View 4  src/uloader/source/port0/ehcmodule.h
@@ -1,3 +1,3 @@
-#define size_ehcmodule 32256
+#define size_ehcmodule 33244
-extern unsigned char ehcmodule[32256];
+extern unsigned char ehcmodule[33244];
View 1,932  src/uloader/source/port1/ehcmodule.c
984 additions, 948 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View 4  src/uloader/source/port1/ehcmodule.h
@@ -1,3 +1,3 @@
-#define size_ehcmodule 32276
+#define size_ehcmodule 33248
-extern unsigned char ehcmodule[32276];
+extern unsigned char ehcmodule[33248];
View 2  src/uloader/source/remote.c
@@ -41,6 +41,8 @@ void (*func)(void);
     }
+    LWP_CloseQueue(remote_queue);
+
return NULL;
}
View 721  src/uloader/source/uloader.c
@@ -284,6 +284,7 @@ if(sd_ok && !external_ehcmodule)
         mload_seek(0x20208030, SEEK_SET);
         mload_write(ios_38, 4);
+     
         }
     mload_close();
@@ -833,8 +834,10 @@ if(l_time)
}
+u8 alt_dol_disc_tab[32768];
+
-void load_cfg()
+int load_cfg(int mode)
{
FILE *fp=0;
int n=0;
@@ -848,86 +851,104 @@ WPAD_ScanPads();
     memset((void *) &cheat_file, 0, 32768);
-    // Load CFG from HDD (or create __CFG_ disc)
-    if(WBFS_LoadCfg(&config_file,sizeof (config_file), &cheat_file))
-    {
-    if(config_file.magic!=0xcacafea1)
+    if(mode==0) // from WBFS
         {
-        memset(&config_file,0, sizeof (config_file));
-        }
-    else
-        {
-        int n,m;
-
-        // delete not found entries in disc
-        for(m=0;m<16;m++)
+        // Load CFG from HDD (or create __CFG_ disc)
+        if(WBFS_LoadCfg(&config_file,sizeof (config_file), &cheat_file))
             {
-            for(n=0;n<gameCnt;n++)
+            if(config_file.magic!=0xcacafea1)
                 {
-                struct discHdr *header = &gameList[n];
-                  if(strncmp((char *) header->id, (char *) &config_file.id[m][0],6)==0) break;
+                memset(&config_file,0, sizeof (config_file));
                 }
-            if(n==gameCnt) memset(&config_file.id[m][0],0,6);
-         
+            else
+                {
+                int n,m;
+
+                // delete not found entries in disc
+                for(m=0;m<16;m++)
+                    {
+                    for(n=0;n<gameCnt;n++)
+                        {
+                        struct discHdr *header = &gameList[n];
+                          if(strncmp((char *) header->id, (char *) &config_file.id[m][0],6)==0) break;
+                        }
+                    if(n==gameCnt) memset(&config_file.id[m][0],0,6);
+                 
+                    }
+                }
+            return 0;
             }
         }
-    return;
-    }
-
-    /*if(sd_ok)
-    {
+    else
+        {
+        if(sd_ok)
+            {
+            memset((void *) alt_dol_disc_tab,0,32768);
-    fp=fopen("sd:/apps/uloader/uloader.cfg","rb"); // lee el fichero de texto
-    if(!fp)
-        fp=fopen("sd:/uloader/uloader.cfg","rb"); // lee el fichero de texto
-    if(!fp)
-        fp=fopen("sd:/uloader.cfg","rb"); // lee el fichero de texto
+            fp=fopen("sd:/apps/uloader/uloader.cfg","rb"); // lee el fichero de texto
+            /*if(!fp)
+                fp=fopen("sd:/uloader.cfg","rb"); // lee el fichero de texto*/
-    if(fp!=0)
-        {
-        n=fread(&config_file,1, sizeof (config_file) ,fp);
-        fclose(fp);
-        }
-    }
-*/
-    if(n!=sizeof (config_file) || !fp || config_file.magic!=0xcacafea1)
-        {
-        memset(&config_file,0, sizeof (config_file));
+            if(fp!=0)
+                {
+                n=fread(&config_file,1, sizeof (config_file) ,fp);
+                if(n!=sizeof (config_file) || !fp || (config_file.magic!=0xcacafea1 && config_file.magic!=0xcacafea2))
+                    {
+                    memset(&config_file,0, sizeof (config_file));
+                    }
+                if(config_file.magic==0xcacafea2)
+                    {
+                    n=fread(&alt_dol_disc_tab,1, 32768 ,fp);
+                    if(n==32768)
+                        n=fread(&cheat_file,1, 32768 ,fp);
+                    }
+                fclose(fp);
+                return 0;
+                }
+            }
         }
+return -1;
+ 
}
-void save_cfg()
+void save_cfg(int mode)
{
-//FILE *fp;
+FILE *fp;
rumble=0;
usleep(60*1000);
wiimote_rumble(0);
WPAD_ScanPads();
-config_file.magic=0xcacafea1;
-if(WBFS_SaveCfg(&config_file,sizeof (config_file), &cheat_file))
+
+if(mode==0)
     {
-    return;
-    }
+    config_file.magic=0xcacafea1;
-/*
-if(!sd_ok) return;
+    if(WBFS_SaveCfg(&config_file,sizeof (config_file), &cheat_file))
+        {
+        return;
+        }
+    }
+else
+    {
+    if(!sd_ok) return;
+    config_file.magic=0xcacafea2;
  
-    fp=fopen("sd:/apps/uloader/uloader.cfg","wb"); // escribe el fichero de texto
-    if(!fp)
-        fp=fopen("sd:/uloader/uloader.cfg","wb"); // escribe el fichero de texto
-    if(!fp)
-        fp=fopen("sd:/uloader.cfg","wb"); // escribe el fichero de texto
+    fp=fopen("sd:/apps/uloader/uloader.cfg","wb"); // escribe el fichero de texto
+ 
     if(fp!=0)
         {
         fwrite(&config_file,1, sizeof (config_file) ,fp);
+        fwrite(&alt_dol_disc_tab,1, 32768 ,fp);
+        fwrite(&cheat_file,1, 32768 ,fp);
         fclose(fp);
         }
-*/
+    }
+
}
#define MAX_LIST_CHEATS 25
@@ -1507,8 +1528,8 @@ if(dat2!=0x1805) dat3=dat2;
  
-    if(USBStorage2_ReadSectors(sector, 64, temp_data)<=0)
-        {sprintf(cabecera2_str,"ERROR! %i",errores);
+    if(USBStorage2_ReadSectors(sector, 64*512/sector_size, temp_data)<=0)
+        {sprintf(cabecera2_str,"ERROR! %i", errores);
         errores++;err_time=gettick();if(err==0) curr_time= time(NULL)-first_time;err=1;
      
         }
@@ -1526,10 +1547,11 @@ switch((((u32) (time(NULL)-start_time)) % 10))
     {
     case 0:
         if(flag==0)
-        {dat4=bytes_readed/(10);bytes_readed=0;flag=1;}break;
+            {dat4=bytes_readed/(10);bytes_readed=0;flag=1;}
+        break;
     default:
         flag=0;
-          break;
+        break;
     }
     PY=480-64;
@@ -1539,8 +1561,8 @@ switch((((u32) (time(NULL)-start_time)) % 10))
     s_printf("speed: %i bytes/sec\n", dat4);
  
-    sector+=128;
-    if(sector>(n_sectors-128)) sector=0;
+    sector+=64*512/sector_size;
+    if(sector>(n_sectors-(64*512/sector_size))) sector=0;
  
     if(err) signal_draw_cabecera2=1;
     draw_cabecera2();
@@ -2314,7 +2336,7 @@ while(1)
                 if(new_pad & WPAD_BUTTON_A)
                     {
-                    if(select_game_bar==60) {draw_snow();Screen_flip();snd_fx_yes(); for(n=0;n<4;n++) config_file.parental[n]=parental_str[n]-48;save_cfg(); return;} // Yes
+                    if(select_game_bar==60) {draw_snow();Screen_flip();snd_fx_yes(); for(n=0;n<4;n++) config_file.parental[n]=parental_str[n]-48;save_cfg(mode_disc!=0); return;} // Yes
                     if(select_game_bar==61) {
                                             for(n=0;n<4;n++) parental_str[n]=0;
                                             snd_fx_no();
@@ -2725,7 +2747,8 @@ u64 offset;
u32 size;
u8 id[6];
u16 pad1;
-u32 pad2[3];
+u32 flags[2];
+u32 pad2[1];
} dol_infodat;
@@ -2738,6 +2761,58 @@ int load_alt_game_disc=0; // 0->from WBFS 1-> from DVD
u8 alt_dol_disc_tab[32768]  __attribute__ ((aligned (32))); // temp dol alternative table for DVD mode
+void dol_GetProfileDatas(u8 *id, u8 *buff)
+{
+dol_infodat *dol_infop= (dol_infodat *) alt_dol_disc_tab;
+int indx=0;
+
+for(indx=0;indx<1024;indx++)
+        {
+        if(!strncmp((void *) dol_infop[indx].id, (void *) id, 6))
+            {
+            buff[0]='H'; buff[1]='D'; buff[2]='R';buff[3]=0;
+            memcpy(&buff[4], &dol_infop[indx].flags[0], 8);
+            return;             
+            }
+        }
+if(indx>=1024)
+    {
+    buff[0]='H'; buff[1]='D'; buff[2]='R';buff[3]=0;
+    memset(&buff[4], 0, 8);
+    }
+
+}
+
+void dol_SetProfileDatas(u8 *id, u8 *buff)
+{
+dol_infodat *dol_infop= (dol_infodat *) alt_dol_disc_tab;
+int indx=0;
+int last_indx=1023;
+
+for(indx=0;indx<1024;indx++)
+        {
+        if(dol_infop[indx].id[0]==0 && last_indx==1023)  last_indx=indx;
+        if(!strncmp((void *) dol_infop[indx].id, (void *) id, 6))
+            {
+            memcpy(&dol_infop[indx].flags[0], &buff[4], 8);
+            save_cfg(1);
+            return;
+            }
+     
+        }
+if(indx>=1024)
+    {
+    if(last_indx==1023) memcpy((char *) &dol_infop[0], ((char *) &dol_infop[0])+32, 32768-32);
+    indx=last_indx;
+
+    memset((void *) &dol_infop[indx],0,32);
+    memcpy((void *) &dol_infop[indx].id, id, 6);
+    memcpy(&dol_infop[indx].flags[0], &buff[4], 8);
+    save_cfg(1);
+    }
+
+}
+
int Get_AlternativeDol(u8 *id)
{
dol_infodat *dol_infop=(dol_infodat *) temp_data;
@@ -2749,13 +2824,15 @@ int indx=0;
if(!load_alt_game_disc)
     WBFS_LoadDolInfo(temp_data);
else
-   dol_infop=(dol_infodat *) alt_dol_disc_tab;
+    {
+    dol_infop=(dol_infodat *) alt_dol_disc_tab;
+    }
     AlternativeDol_infodat.id[0]=0;
     for(indx=0;indx<1024;indx++)
         {
-        if(!strncmp((void *) dol_infop[indx].id, (void *) id, 6))
+        if(!strncmp((void *) dol_infop[indx].id, (void *) id, 6) && dol_infop[indx].size!=0 && dol_infop[indx].offset!=0)
             {
             AlternativeDol_infodat=dol_infop[indx];
             dol_len=AlternativeDol_infodat.size;
@@ -2791,6 +2868,7 @@ if(!load_alt_game_disc)
else
     {
     dol_infop=(dol_infodat *) alt_dol_disc_tab;
+    //load_cfg(1);
     //memset((void *) alt_dol_disc_tab,0,32768);
     }
@@ -2852,7 +2930,8 @@ while(1)
         if(indx<1024)
             {
-            if(Draw_button(x_temp+16, ylev+108*4-64, &letrero[idioma][49][0])) select_game_bar=61; 
+            if(dol_infop[indx].offset!=0 && dol_infop[indx].size!=0)
+                if(Draw_button(x_temp+16, ylev+108*4-64, &letrero[idioma][49][0])) select_game_bar=61; 
             //PX= 20; PY+=32;
             //s_printf("%llx %i",dol_infop[indx].offset, dol_infop[indx].size);
             }
@@ -3119,7 +3198,23 @@ while(1)
                         if(select_game_bar==60) {draw_snow();Screen_flip();snd_fx_no();return;} // exit
                      
-                        if(select_game_bar==61) {draw_snow();Screen_flip();snd_fx_yes();if(indx<1024) memset((void *) &dol_infop[indx],0,32);mode=4;}
+                        if(select_game_bar==61) {
+                                                draw_snow();Screen_flip();snd_fx_yes();
+                                                if(indx<1024)
+                                                    {
+                                                    if(!load_alt_game_disc)
+                                                        {
+                                                        memset((void *) &dol_infop[indx],0,32);
+                                                        }
+                                                    else // for DVD mode
+                                                        {
+                                                        dol_infop[indx].offset=0;
+                                                        dol_infop[indx].size=0;
+                                                        }
+                                                    }
+                                                 
+                                                mode=4;
+                                                 }
                      
                         if(select_game_bar==62) {draw_snow();Screen_flip();snd_fx_yes();mode=2;}
                        //
@@ -3216,6 +3311,8 @@ while(1)
if(!load_alt_game_disc)
     WBFS_SaveDolInfo(temp_data);
+else
+    save_cfg(1);
if(mode==129) sleep(2);
}
@@ -3284,9 +3381,11 @@ int index=0;
      
         punt=&letrero[idioma][22+n+index][0];
         memcpy(buff+(56-strlen(punt))/2, punt, strlen(punt));
- 
+
         if(Draw_button2(30+48, ylev+32+64*n, buff,
-            (!header && (m==2 || m==3 || m==6 || m==7 || m==9 || (parental_control_on && m!=0 && m!=5))) ? -1 : 0)) select_game_bar=m+1;
+            ((!header && !mode_disc && (m==2 || m==3 || m==6 || m==7 || m==9 || (parental_control_on && m!=0 && m!=5))
+            )  || (mode_disc && (m==1 || m==2 || m==3 ||  m==6 || m==7 || m==8 || (parental_control_on && m!=0 && m!=5)))  ) ? -1 : 0)) select_game_bar=m+1;
+ 
         }
         if(px>=0 && px<=80 && py>=ylev+220-40 && py<=ylev+220+40)
@@ -3447,11 +3546,12 @@ int index=0;
                         if(select_game_bar==7) {snd_fx_yes();draw_snow();Screen_flip(); if(rename_game(header->title))  {WBFS_RenameGame(header->id, header->title);WBFS_Close();return 2;} else return 0;}
                         // delete game
                         if(select_game_bar==8) {snd_fx_yes();draw_snow();Screen_flip(); if(delete_test(29, header->title)) WBFS_RemoveGame(header->id);WBFS_Close();return 2;}
-                        if(select_game_bar==10) {snd_fx_yes();draw_snow();Screen_flip(); menu_alternativedol(header->id);return 0;}
+
+                        if(select_game_bar==10) {snd_fx_yes();draw_snow();Screen_flip();load_alt_game_disc=(mode_disc & 3)!=0; menu_alternativedol(header->id);return 0;}
                         }
                  
                     // parental control
-                    if(select_game_bar==5) {set_parental_control();draw_snow();Screen_flip();return 0;}
+                    if(select_game_bar==5) {load_alt_game_disc=(mode_disc & 3)!=0;set_parental_control();draw_snow();Screen_flip();return 0;}
                  
                     // menu wii
                     if(select_game_bar==6) {snd_fx_yes();draw_snow();Screen_flip(); return 1;}
@@ -3873,11 +3973,16 @@ int len;
int remote_DVD_disc_status=0;
static struct discHdr mydisc_header ATTRIBUTE_ALIGN(32);
+int mode_disc=0; // bits 0-1 : 0 -> HDD, 1-> DVD Wii, 2-> USB DVD
+
void remote_DVD_disc()
{
int r;
-    if(Disc_Wait()==0)
+    if(mode_disc & 2) r=Disc_USB_DVD_Wait();
+        else r=Disc_Wait();
+
+    if(r==0)
         {
         if(remote_DVD_disc_status==0)
             {
@@ -3950,7 +4055,7 @@ int main(int argc, char **argv) {
         int volume_osd=0;
-        int mode_disc=0;
+     
         int dvd_only=0;
@@ -4218,6 +4323,9 @@ int main(int argc, char **argv) {
      
         remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);
         ret2=REMOTE_BUSY;
+
+        int ret_flag=0;
+
         for(n=0;n<10;n++)
         {
         int r,mod=0;
@@ -4238,18 +4346,42 @@ int main(int argc, char **argv) {
              
             if(mod==0)
                 {
+                ret_flag=0;
                 r=remote_USBStorage2_Init();
                 if(r!=REMOTE_BUSY) mod=1;
+             
                 }
             if(mod==1)
                 {
+             
                 r=remote_ret();
-                if(r!=REMOTE_BUSY) {mod=0;ret2=r;}
+                if(r!=REMOTE_BUSY) {mod=0;ret2=r;ret_flag=1;}
+
                 }
          
             if(ret2==REMOTE_BUSY) ;
             else
+            if(ret2==-20001 || ret2==-20002)
+                {n=0;
+                DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
+                DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 4, 0xa0000000);
+             
+                if(ret2==-20001)
+                    s_printf("ERROR: USB Device Sector Size must be 512 bytes");
+                else
+                    s_printf("ERROR: DVD Device Sector Size must be 2048 bytes");
+
+                DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32+80, 540, 64, 999, 0xa00000ff);
+                DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32+80, 540, 64, 999, 4, 0xa0000000);
+             
+                PY+=80;
+             
+                exit_by_reset=return_reset;
+             
+
+                }
+            else
             if(ret2==-20000)
                 {n=0;
                 DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
@@ -4324,6 +4456,21 @@ int main(int argc, char **argv) {
                 }
             else
+            if(ret2==-122)
+                {
+                DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
+                DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 4, 0xa0000000);
+
+                s_printf("ERROR: Can't Mount Device");
+
+                DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32+80, 540, 64, 999, 0xa00000ff);
+                DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32+80, 540, 64, 999, 4, 0xa0000000);
+             
+                PY+=80;
+                s_printf("... waiting for Storage or DVD media ...");
+
+                }
+            else
             if(ret2<0)
                 {
                 DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
@@ -4336,9 +4483,11 @@ int main(int argc, char **argv) {
              
                 PY+=80;
                 s_printf("Retries: %i",n);
+
+             
                 }
          
-            if(exit_by_reset || (new_pad & WPAD_BUTTON_HOME))
+            if((exit_by_reset || (new_pad & WPAD_BUTTON_HOME)))
                 {
                 DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32+80, 540, 64, 0, 0xff0000ff);
                 DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32+80, 540, 64, 0, 4, 0xa0000000);
@@ -4351,8 +4500,11 @@ int main(int argc, char **argv) {
                 }
             Screen_flip();
-            if(ret2<0 && ret2!=-100 && ret2!=-101 && mod<2 && ret2!=REMOTE_BUSY) mod=2;
-            if(!ret2) break;
+            if(ret2<0 && ret2!=-122 && ret2!=-100 && ret2!=-101 && mod<2 && ret2!=REMOTE_BUSY && ret_flag) {ret_flag=0;mod=2;}
+         
+         
+            if(!ret2 || ret2==1) break;
+         
             temp_pad= wiimote_read();
             new_pad=temp_pad & (~old_pad);old_pad=temp_pad;
@@ -4361,13 +4513,26 @@ int main(int argc, char **argv) {
                 {
                 mod++;if(mod>30) {mod=0;break;}
                 }
+            /*if(ret2==-1)
+                {
+                if(mod!=0) {mod=0;break;}
+                else mod=1;
+                }*/
          
             }
          
-            if(!ret2) break;
+            //if(ret_flag==0) n--;
+            if(!ret2  || ret2==1) break;
  
         }
+        if(ret2==1)
+            {
+            ret2=0;
+            dvd_only=1;
+            mode_disc=1024+2; // USB DVD MODE
+            }
+
         CreatePalette(&palette_icon, TLUT_RGB5A3, 0, icon_palette, icon_palette_colors); // crea paleta 0
         CreateTexture(&text_icon[0], TILE_CI8, icon_sprite_1, icon_sprite_1_sx, icon_sprite_1_sy, 0);
         CreateTexture(&text_icon[1], TILE_CI8, icon_sprite_2, icon_sprite_2_sx, icon_sprite_2_sy, 0);
@@ -4377,7 +4542,7 @@ int main(int argc, char **argv) {
         #ifdef MEM_PRINT
      
-        if(test_mode && mode_disc==0)
+        if(test_mode && (mode_disc & 1)==0)
             {
                 if(ret2>=0)
                 {
@@ -4654,6 +4819,8 @@ int main(int argc, char **argv) {
                 }
             else PlayOgg(mem_open((void *) bg_music, size_bg_music),0,OGG_INFINITE_TIME);
             }
+            else PlayOgg(mem_open((void *) bg_music, size_bg_music),0,OGG_INFINITE_TIME);
+
         #endif
      
         #endif
@@ -4741,8 +4908,9 @@ int main(int argc, char **argv) {
                     s_printf("No WBFS partition found!\n");
                     Screen_flip();
                     }
-
-            if(menu_format()==0)
+        
+            ret= menu_format();
+            if(ret==0)
                 {
                 // locate WBFS Partitions and number of games from the partitions
                 for(n=0;n<4;n++)
@@ -4758,9 +4926,15 @@ int main(int argc, char **argv) {
                     if(ret==0) {current_partition=(current_partition+n) & 3;break;}
                     else partition_cnt[(current_partition+n) & 3]=-1;
                     }
-                if(ret<0) goto error_w;
+                if(ret<0)
+                    {
+                    dvd_only=1;
+                    mode_disc=1+1024;
+                    }
+                    //goto error_w;
                 }
-            else goto exit_ok;
+            else
+                goto exit_ok;
             Screen_flip();
             SetTexture(&text_background2);
@@ -4777,16 +4951,21 @@ int main(int argc, char **argv) {
         //ret = WBFS_GetCount(&cnt);
         ret= partition_cnt[current_partition];
         cnt= ret;
+     
         if (ret < 0 || cnt==0) {
-            DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
-            DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 4, 0xa0000000);
-            s_printf("No Game found\n");
-            Screen_flip();
+            if(!mode_disc)
+                {
+                DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
+                DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 4, 0xa0000000);
-            if(mode_disc) mode_disc|=1024;
-            else sleep(4);
+                s_printf("No Game found\n");
+                Screen_flip();
+
+            //if(mode_disc) mode_disc|=1024;
+                sleep(3);
+                }
             //goto error_w;
             }
         else
@@ -4822,12 +5001,32 @@ int main(int argc, char **argv) {
                 }
      
             gameList = buffer;
+            //cnt=0;
             for(n=0;n<cnt;n++)
                 {
-                  if(gameList[n].id[0]=='_') {memcpy(&gameList[n],&gameList[cnt-1],sizeof(struct discHdr));cnt--;}
+                  if(gameList[n].id[0]=='_') {memcpy(&gameList[n],&gameList[cnt-1],sizeof(struct discHdr));cnt--;n--;}
                 }
+
+            if(!cnt)
+                {
+                if(!mode_disc)
+                    {
+                    DrawRoundFillBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 0xa00000ff);
+                    DrawRoundBox((SCR_WIDTH-540)/2, SCR_HEIGHT/2-16+32, 540, 64, 999, 4, 0xa0000000);
+
+                    s_printf("No Game found\n");
+                    Screen_flip();
+                    //if(mode_disc) mode_disc|=1024;
+                    sleep(2);
+                    }
+
+                free(buffer);
+                buffer=NULL;
+                }
+         
             /* Sort entries */
-            qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
+            if(cnt && buffer) qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
+
             }
         /*
@@ -4842,14 +5041,14 @@ int main(int argc, char **argv) {
      
         {
         u8 temp=config_file.music_mod;
-        char temp2[4];
+        /*char temp2[4];
-        memcpy(temp2, config_file.parental, 4);
+        memcpy(temp2, config_file.parental, 4);*/
      
         memset(&config_file,0, sizeof (config_file));
         if(!mode_disc) // mode disc
-            {load_cfg();memset(parental_str ,0, 4);}
-        else {config_file.music_mod=temp; memcpy(config_file.parental, temp2, 4);}
+            {load_cfg(0);memset(parental_str ,0, 4);}
+        else {if(load_cfg(1)<0) config_file.music_mod=temp; memset(parental_str ,0, 4);/* memcpy(config_file.parental, temp2, 4);*/}
         }
@@ -4882,10 +5081,11 @@ int main(int argc, char **argv) {
                 create_game_png_texture(0);
                 if(WBFS_GameSize(header->id, &f_size)) f_size=0.0f;
                 game_mode=1;
-                if(config_file.parental[0]==0 && config_file.parental[1]==0 && config_file.parental[2]==0 && config_file.parental[3]==0) parental_control_on=0;
+             
+                if(mode_disc==0 && config_file.parental[0]==0 && config_file.parental[1]==0 && config_file.parental[2]==0 && config_file.parental[3]==0) parental_control_on=0;
                 if(parental_control_on)
-                    {if((game_datas[game_mode-1].config & (1<<30))!=0) parental_mode=1024+game_mode;direct_launch=0;}
+                    {if((game_datas[game_mode-1].config & (1<<30))!=0) {parental_mode=1024+game_mode;direct_launch=0;}}
                 break;
                 }
@@ -4903,7 +5103,11 @@ int main(int argc, char **argv) {
     create_game_png_texture(0);
     parental_mode=0;
     disc_header=NULL;
-    WDVD_SetUSBMode(NULL, 0);
+
+    if(mode_disc & 2)
+        WDVD_SetUSBMode((u8 *) "_DVD", 0);
+    else
+        WDVD_SetUSBMode(NULL, 0);
     remote_DVD_disc_status=0;
@@ -5051,6 +5255,8 @@ int main(int argc, char **argv) {
                     else
                 if(nn==0) color=0xffffffff; else color=0x27ffffff;
+                if(mode_disc & 2) color=(color & 0xff000000) | 0x20ff6f;
+
                 SetTexture(&text_icon[3]);
                 ConfigureForTexture(10);
                 GX_Begin(GX_TRIANGLESTRIP,  GX_VTXFMT0, 5);
@@ -5240,6 +5446,24 @@ int main(int argc, char **argv) {
             select_game_bar=0;
             PX= 26; PY=ylev+12; color= 0xff000000;
             bkcolor=0x0;//0xb0f0f0f0;
+
+            if(mode_disc)
+                {
+                if(header)
+                    dol_GetProfileDatas(header->id, temp_data);
+                else
+                    dol_GetProfileDatas((u8 *) "**12**", temp_data);
+
+
+                game_datas[game_mode-1].config=temp_data[4]+(temp_data[5]<<8)+(temp_data[6]<<16)+(temp_data[7]<<24);
+                }
+                                                
+
+            if((mode_disc & 2) && (game_datas[game_mode-1].config & 1))  // force cIOS 222 for USB DVD
+                {
+                game_datas[game_mode-1].config&=~1;
+                }
+
             if((game_datas[game_mode-1].config & 1) || force_ios249) s_printf("cIOS 249");
          
             else {if(game_datas[game_mode-1].config & 2)  s_printf("cIOS 223"); else s_printf("cIOS 222");}
@@ -5251,6 +5475,10 @@ int main(int argc, char **argv) {
             force_ingame_ios=1*((game_datas[game_mode-1].config>>31)!=0);
             game_locked_cfg=1*((game_datas[game_mode-1].config & (1<<30))!=0);
+            if(mode_disc && parental_control_on && game_locked_cfg)
+                parental_mode=9999;
+            if(mode_disc && !disc_header) parental_mode=0;
+
      
          
             PX=608-6*16;
@@ -5288,38 +5516,45 @@ int main(int argc, char **argv) {
             if(!(mode_disc & 1024) && remote_DVD_disc_status!=1)
                 if(Draw_button(36, ylev+108*4-64, &letrero[idioma][0][0])) select_game_bar=1;
-            if(header)
-                if(Draw_button(x_temp+8, ylev+108*4-64, &letrero[idioma][1][0])) select_game_bar=2;
-         
-
-            if(test_favorite && !mode_disc)
+            if(!parental_mode)
                 {
-                if(is_favorite)
-                    {if(Draw_button(x_temp+8, ylev+108*4-64, &letrero[idioma][2][0])) select_game_bar=4;}
-                else
-                    if(Draw_button(x_temp+8, ylev+108*4-64, &letrero[idioma][3][0])) select_game_bar=3;
-                }
+                if(header)
+                    if(Draw_button(x_temp+8, ylev+108*4-64, &letrero[idioma][1][0])) select_game_bar=2;
+             
-            if(header && mode_disc && BCA_ret==0)
-                {
-                if(show_bca==0)
+                if(test_favorite && !mode_disc)
                     {
-                 
-                    if(Draw_button(x_temp+8, ylev+108*4-64, "Show BCA Data")) select_game_bar=56;
+                    if(is_favorite)
+                        {if(Draw_button(x_temp+8, ylev+108*4-64, &letrero[idioma][2][0])) select_game_bar=4;}
+                    else
+                        if(Draw_button(x_temp+8, ylev+108*4-64, &letrero[idioma][3][0])) select_game_bar=3;
                     }
-                else
-                    if(Draw_button(x_temp+8, ylev+108*4-64, "Hide BCA Data")) select_game_bar=56;
-                }
-            if(dvd_only==1 /*&& remote_DVD_disc_status==0*/)
-                if(Draw_button(x_temp+8, ylev+108*4-64,"Wii Menu"/* &letrero[idioma][27][0]*/)) select_game_bar=6;
+                if(header && mode_disc && BCA_ret==0)
+                    {
+                    if(show_bca==0)
+                        {
+                     
+                        if(Draw_button(x_temp+8, ylev+108*4-64, "Show BCA Data")) select_game_bar=56;
+                        }
+                    else
+                        if(Draw_button(x_temp+8, ylev+108*4-64, "Hide BCA Data")) select_game_bar=56;
+                    }
+
+                if(dvd_only==1 /*&& remote_DVD_disc_status==0*/)
+                    if(Draw_button(x_temp+8, ylev+108*4-64,"Wii Menu"/* &letrero[idioma][27][0]*/)) select_game_bar=6;
+                }
             if(header)
                 {
-                if(!mode_disc)
-                    {if(Draw_button(600-32-strlen(&letrero[idioma][4][0])*8-78, ylev+108*4-64, "A.Dol")) {load_alt_game_disc=0;select_game_bar=55;}}
-                else
-                    {if(Draw_button(600-32-strlen(&letrero[idioma][4][0])*8-78, ylev+108*4-64, "A.Dol")) {load_alt_game_disc=1;select_game_bar=55;}}
+
+                if(!parental_mode)
+                    {
+                    if(!mode_disc)
+                        {if(Draw_button(600-32-strlen(&letrero[idioma][4][0])*8-78, ylev+108*4-64, "A.Dol")) {load_alt_game_disc=0;select_game_bar=55;}}
+                    else
+                        {if(Draw_button(600-32-strlen(&letrero[idioma][4][0])*8-78, ylev+108*4-64, "A.Dol")) {load_alt_game_disc=1;select_game_bar=55;}}
+                    }
              
                 if(header && mode_disc && show_bca && BCA_ret==0)
@@ -5355,8 +5590,8 @@ int main(int argc, char **argv) {
              
              
                 }
-
-            if(header)
+         
+            if(header && !parental_mode)
                 if(Draw_button(600-32-strlen(&letrero[idioma][4][0])*8, ylev+108*4-64, &letrero[idioma][4][0])) {select_game_bar=5;}
          
@@ -5416,9 +5651,11 @@ int main(int argc, char **argv) {
             //if(Draw_button2(472, m, " cIOS 222 ", force_ios249 ? -1 : cios==222)) select_game_bar=300;
             //if(Draw_button2(472, m+56, " cIOS 249 ",cios==249)) select_game_bar=301;
+            if((mode_disc & 2) && cios==249) cios=222; // force cIOS 222 for USB DVD
+
             if(Draw_button2(36+6*12, m+56, " cIOS 222 ", force_ios249 ? -1 : cios==222)) select_game_bar=300;
             if(Draw_button2(x_temp+12, m+56, " cIOS 223 ", force_ios249 ? -1 : cios==223)) select_game_bar=301;
-            if(Draw_button2(x_temp+12, m+56, " cIOS 249 ",cios==249)) select_game_bar=302;
+            if(Draw_button2(x_temp+12, m+56, " cIOS 249 ",(mode_disc & 2)? -1: cios==249)) select_game_bar=302;
             if(Draw_button2(x_temp+20, m+56, " Skip IOS ", force_ios249 ? -1 : force_ingame_ios!=0)) select_game_bar=303;
@@ -5873,6 +6110,11 @@ int main(int argc, char **argv) {
                     parental_control_on=1;
                 }
+            else if(select_game_bar==10016 && parental_mode==0)
+                {
+                parental_control_on=1;
+
+                }
      
      
@@ -5881,7 +6123,7 @@ int main(int argc, char **argv) {
         //    parental_control_on=1;
//        int parental_mode=0;
         /////////////////////////
-        if(parental_mode)
+        if(parental_mode )
             {
             ylev+=32;
@@ -5899,7 +6141,7 @@ int main(int argc, char **argv) {
             s_printf("%s","Parental Control");
             autocenter=0;
-            select_game_bar=0;
+            if(select_game_bar!=1)    select_game_bar=0;
          
             // change partition draw and selection
@@ -5945,6 +6187,7 @@ int main(int argc, char **argv) {
         ////////////////////////////
         }
  
+
     if(direct_launch && game_mode==1 && gameList!=NULL)
         {
         PX=0;PY=(SCR_HEIGHT-440)+(352-256)/2;
@@ -6082,7 +6325,7 @@ int main(int argc, char **argv) {
                         SetVolumeOgg((config_file.music_mod & 128) ?  ((config_file.music_mod & 15)*16): 255);
                         #endif
-                        if(!mode_disc) save_cfg();
+                        if(!mode_disc) save_cfg(0); //else save_cfg(1);
                         }
                     if((new_pad & WPAD_BUTTON_RIGHT)  || (volume_osd && (frames2 & 7)==0 && (old_pad & WPAD_BUTTON_RIGHT)))
                         {
@@ -6100,7 +6343,7 @@ int main(int argc, char **argv) {
                         SetVolumeOgg((config_file.music_mod & 128) ?  ((config_file.music_mod & 15)*16): 255);
                         #endif
-                        if(!mode_disc) save_cfg();
+                        if(!mode_disc) save_cfg(0); //else save_cfg(1);
                         }
                      if(cheat_mode && txt_cheats)
@@ -6134,11 +6377,12 @@ int main(int argc, char **argv) {
                             }
                         } // limit left_right
-
+
                 
-                    if((new_pad & WPAD_BUTTON_A) && (gameList!=NULL || (mode_disc && game_mode)))
+                    if((new_pad & WPAD_BUTTON_A) &&
+                        (gameList!=NULL || (mode_disc && game_mode) || (mode_disc==0 && select_game_bar>=10000 && select_game_bar<=10016)))
                         {
-                        if(parental_mode)
+                        if(parental_mode && select_game_bar!=1/*(!mode_disc || (mode_disc && select_game_bar!=1))*/)
                             {
                             direct_launch=0;
                             if(select_game_bar>=20000 && select_game_bar<20010)
@@ -6155,6 +6399,8 @@ int main(int argc, char **argv) {
                                             {
                                             parental_control_on=0;
                                             snd_fx_yes();
+                                            if(parental_mode==9999);
+                                            else
                                             if(parental_mode>=1024) game_mode=parental_mode-1024;
                                             else go_home=1;
@@ -6250,7 +6496,7 @@ int main(int argc, char **argv) {
                                         insert_favorite=0;if(mem_move_chan) free(mem_move_chan);mem_move_chan=NULL;
                                         temp_sel=-1;
                                         for(n=0;n<15;n++) {if(game_datas[n].png_bmp) free(game_datas[n].png_bmp);game_datas[n].png_bmp=NULL;}
-                                        if(!mode_disc) save_cfg();
+                                        if(!mode_disc) save_cfg(0); else save_cfg(1);
                                         load_png=1;
  
                                         }
@@ -6261,7 +6507,7 @@ int main(int argc, char **argv) {
                                     struct discHdr *header;
                                     if(!is_favorite) last_game=actual_game;
-                                    if(select_game_bar==10016)  {snd_fx_yes();mode_disc=1;Screen_flip();goto get_games;}
+                                    if(select_game_bar==10016)  {parental_control_on=1;snd_fx_yes();mode_disc=1;Screen_flip();goto get_games;}
                                     if(select_game_bar>=10000 && select_game_bar<10004)  {snd_fx_yes();current_partition=select_game_bar-10000;Screen_flip();goto get_games;}
@@ -6307,8 +6553,10 @@ int main(int argc, char **argv) {
                                                     if(mode_disc && game_mode && !edit_cfg)
                                                         {
                                                         remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);
-                                                        mode_disc=0;f_j=1;
+                                                        mode_disc=0;f_j=1;parental_control_on=1;parental_mode=0;
                                                         }
+                                                    if(!mode_disc && game_mode && !edit_cfg) parental_mode=0;
+
                                                     game_mode=0;edit_cfg=0;select_game_bar=0;
                                                     for(n=0;n<15;n++) {if(game_datas[n].png_bmp) free(game_datas[n].png_bmp);game_datas[n].png_bmp=NULL;}
                                                 
@@ -6319,7 +6567,7 @@ int main(int argc, char **argv) {
                                                     usleep(60*1000);
                                                     wiimote_rumble(0);
                                                     WPAD_ScanPads();
-                                                    if(f_j) {Screen_flip();goto get_games;}
+                                                    if(f_j) {Screen_flip();save_cfg(1);goto get_games;}
                                                     }
                             if(select_game_bar==2)
@@ -6345,6 +6593,9 @@ int main(int argc, char **argv) {
                                                    
                                                       WBFS_GetProfileDatas(discid, temp_data);
                                                       }
+                                                     else
+                                                       dol_GetProfileDatas(discid, temp_data);
+
                                                    game_datas[game_mode-1].config=temp_data[4]+(temp_data[5]<<8)+(temp_data[6]<<16)+(temp_data[7]<<24);
                                                 
@@ -6379,7 +6630,7 @@ int main(int argc, char **argv) {
                                                     game_mode=0;edit_cfg=0;
                                                  
                                                     for(n=0;n<15;n++) {if(game_datas[n].png_bmp) free(game_datas[n].png_bmp);game_datas[n].png_bmp=NULL;}
-                                                    save_cfg();
+                                                    save_cfg(0);
                                                     load_png=1;
                                                     }
@@ -6393,7 +6644,7 @@ int main(int argc, char **argv) {
                                                    memset(&config_file.id[game_mode-1][0],0,8);
                                                    game_mode=0;edit_cfg=0;
                                                    for(n=0;n<15;n++) {if(game_datas[n].png_bmp) free(game_datas[n].png_bmp);game_datas[n].png_bmp=NULL;}
-                                                   save_cfg();
+                                                   save_cfg(0);
                                                    load_png=1;
                                                    }
@@ -6476,7 +6727,7 @@ int main(int argc, char **argv) {
                                                         select_game_bar=0;
                                                      
-                                                        ret=load_game_routine(discid, game_mode | (0x800000 *(mode_disc!=0)));
+                                                        ret=load_game_routine(discid, game_mode | (0x800000 *(mode_disc!=0)) | (0x200000 * (( mode_disc & 2)!=0) ) );
                                                         //////////////////////////////////
                                                         remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);
@@ -6556,6 +6807,8 @@ int main(int argc, char **argv) {
                                                    WPAD_ScanPads();
                                                    if(!mode_disc)
                                                         WBFS_SetProfileDatas(discid, temp_data);
+                                                   else
+                                                       dol_SetProfileDatas(discid, temp_data);
                                                 
                                                    }
                             if(select_game_bar>=100 && select_game_bar<=111)
@@ -6624,8 +6877,8 @@ int main(int argc, char **argv) {
                             {// return from config (saving)
                             edit_cfg=0;
                             snd_fx_yes();
-                            if(!mode_disc)
-                                {
+                         
+                         
                                 // si no existe crea uno
                                 if(!(temp_data[0]=='H' && temp_data[1]=='D' && temp_data[2]=='R'))
                                     {
@@ -6644,9 +6897,11 @@ int main(int argc, char **argv) {
                                 temp_data[7]|=((game_locked_cfg!=0) & 1)<<6;
                                 game_datas[game_mode-1].config=temp_data[4]+(temp_data[5]<<8)+(temp_data[6]<<16)+(temp_data[7]<<24);
-
-                                WBFS_SetProfileDatas(discid, temp_data);
-                                }
+                                if(!mode_disc)
+                                    WBFS_SetProfileDatas(discid, temp_data);
+                                else
+                                    dol_SetProfileDatas(discid, temp_data);
+                         
                             }
                         else
                             {
@@ -6657,8 +6912,9 @@ int main(int argc, char **argv) {
                                 if(mode_disc && game_mode && !edit_cfg)
                                     {
                                     remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);
-                                    mode_disc=0;f_j=1;
+                                    mode_disc=0;f_j=1;parental_control_on=1;parental_mode=0;
                                     }
+                                if(!mode_disc && game_mode && !edit_cfg) parental_mode=0;
                                 if(game_mode)
                                     {
@@ -6696,7 +6952,7 @@ int main(int argc, char **argv) {
                                 game_mode=0;edit_cfg=0;
                                 insert_favorite=0;if(mem_move_chan) free(mem_move_chan);mem_move_chan=NULL;
-                                if(f_j) {Screen_flip();goto get_games;}
+                                if(f_j) {Screen_flip();save_cfg(1);goto get_games;}
                                 }
                             }
                         }
@@ -6726,8 +6982,8 @@ int main(int argc, char **argv) {
                     // launch pintor game
                     if((new_pad & WPAD_BUTTON_2) && game_mode==0 && insert_favorite==0 && scroll_mode==0 && parental_mode==0) go_game=1;
-                    if((new_pad & WPAD_BUTTON_HOME) && game_mode==0 && insert_favorite==0 && scroll_mode==0 && parental_mode==0)
-                        {
+                    if((new_pad & WPAD_BUTTON_HOME) && (game_mode==0 || (game_mode!=0 && mode_disc && disc_header && !edit_cfg)) && insert_favorite==0 && scroll_mode==0 && parental_mode==0)
+                        {//go_home=1;
                         if(parental_control_on)
                                         {
                                         parental_mode=1;
@@ -6952,27 +7208,37 @@ int main(int argc, char **argv) {
         pintor();
         config_file.hi_score=hiscore;
      
-        if(!mode_disc) save_cfg();
+        if(!mode_disc) save_cfg(0); else save_cfg(1);
         go_game=0;
         }
     if(go_home)
         {
         struct discHdr *header =NULL;
-        if(temp_sel>=0)
-            {//
-            int g;
-            g=game_datas[temp_sel].ind;
-            if(g>=0)
-                {
-                header = &gameList[g];
-                }
+        if(!mode_disc)
+            {
+            if(temp_sel>=0)
+                {//
+                int g;
+
+                g=game_datas[temp_sel].ind;
+                if(g>=0)
+                    {
+                    header = &gameList[g];
+                    }
+
+                }//
+            }
+        else header=disc_header;
-            }//
+        if(mode_disc) {remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);}
         n=home_menu(header);
+
+        if(mode_disc) {remote_call(remote_DVD_disc);usleep(1000*50);}
+
         if(n==0)
             {
             if(parental_control_on)
@@ -6982,8 +7248,11 @@ int main(int argc, char **argv) {
                 }
             }
         if(n==1) {exit_by_reset=return_reset;break;}
-        if(n==2) {Screen_flip();goto get_games;}
-        if(n==3) {load_png=1;}
+        if(!mode_disc)
+            {
+            if(n==2) {Screen_flip();goto get_games;}
+            if(n==3) {load_png=1;}
+            }
         go_home=0;
         }
@@ -6993,6 +7262,11 @@ int main(int argc, char **argv) {
         }
     }// while
+
+    VIDEO_SetBlack(TRUE);
+    VIDEO_Flush();
+    VIDEO_WaitVSync();
+
     exit_ok:
     mload_set_ES_ioctlv_vector(NULL);
@@ -7027,8 +7301,14 @@ int main(int argc, char **argv) {
error:
     WPAD_Shutdown();
error_0:
+    remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);
     remote_end();
-    sleep(4);
+
+    VIDEO_SetBlack(TRUE);
+    VIDEO_Flush();
+    VIDEO_WaitVSync();
+
+    sleep(2);
     if(sd_ok)
         {
         fatUnmount("sd");
@@ -7043,6 +7323,8 @@ int main(int argc, char **argv) {
     if(return_reset==2)
         SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
+    if(exit_by_reset==3)
+        SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0);
     return ret;
@@ -7053,7 +7335,7 @@ int load_game_routine(u8 *discid, int game_mode)
int n, ret,ret2;
int force_ingame_ios=0;
-int flag_disc=game_mode & 0x800000;
+int flag_disc=game_mode & 0xa00000;
     Screen_flip();
     wiimote_rumble(0);
@@ -7062,12 +7344,14 @@ int flag_disc=game_mode & 0x800000;
     new_pad=temp_pad & (~old_pad);old_pad=temp_pad;
     //WPAD_Shutdown();
-    game_mode &= ~0x800000;
+    game_mode &= ~0xa00000;
     add_game_log(discid);
     if(!flag_disc)
-        save_cfg();
+        save_cfg(0);
+    else
+        save_cfg(1);
     if((game_datas[game_mode-1].config & 1) || force_ios249) cios=249;
         else { if(game_datas[game_mode-1].config & 2) cios=223; else cios=222;}
@@ -7169,15 +7453,16 @@ int flag_disc=game_mode & 0x800000;
      
     mload_close();
  
-    if(flag_disc) discid[6]=1;
+    if(flag_disc & 0x200000) discid[6]=2; // mode DVD USB
+    else if(flag_disc) discid[6]=1; // mode DVD
     ret = load_disc(discid);
return ret;
}
#include <ogc/lwp_watchdog.h>
-extern void settime(u64);
+
// from coverflow loader
@@ -7467,7 +7752,7 @@ return 1;
}
-void patch_hex_str(u8 *buffer, u32 len, u32 step, const u8 *search, int skip_patch, const u8 *patch )
+void patch_hex_str(u8 *buffer, u32 len, u32 step, const u8 *search, int skip_patch, const u8 *patch, int counter )
{
  u32 cnt;
@@ -7479,6 +7764,10 @@ for (cnt = 0; cnt < len; cnt+=step)
         if (compare_hex_str(ptr, search))
             {
             set_hex_str(ptr+skip_patch, patch);
+            cnt=(((cnt+(strlen((char *) search)>>1))/step)*step)-step;
+         
+            counter--;
+            if(counter==0) return;
      
             }
          
@@ -7493,7 +7782,7 @@ void __Patch_DiscSeek(void *buffer, u32 len)
    const   u8 PatchData[] =      "38A000717CA401AE7C671B787FCAF3783929XXXX800DB3XX3880007180ADB3XX";
 
 
-   patch_hex_str((u8 *) buffer, (len - (strlen((char *) SearchPattern)>>1)),4 , SearchPattern, 0, PatchData);
+   patch_hex_str((u8 *) buffer, (len - (strlen((char *) SearchPattern)>>1)),4 , SearchPattern, 0, PatchData, 0);

}
@@ -7506,7 +7795,7 @@ void __Patch_CoverRegister(void *buffer, u32 len)
    const u8 oldcode[] = "5460F7FF4082000C546007FF4182000C";
    const u8 newcode[] = /*"5460F7FF4082000C546007FF"*/ "4800000C";
-   patch_hex_str((u8 *) buffer, (len - (strlen((char *) oldcode)>>1)),4 , oldcode, 12, newcode);
+   patch_hex_str((u8 *) buffer, (len - (strlen((char *) oldcode)>>1)),4 , oldcode, 12, newcode, 0);
}
@@ -7515,17 +7804,18 @@ void __Patch_Error001(void *buffer, u32 len)
     const u8 oldcode[] = "4082000C386000014800024438610018";
     const u8 newcode[] = "40820004";
-    patch_hex_str((u8 *) buffer, (len - (strlen((char *) oldcode)>>1)),4 , oldcode, 0, newcode);
+    patch_hex_str((u8 *) buffer, (len - (strlen((char *) oldcode)>>1)),4 , oldcode, 0, newcode, 0);
}
+
#if 0
void __Patch_NSMBW(void *buffer, u32 len)
{
const u8 oldcode[] = "9421FFD07C0802A690010034396100304812XXXX7C7B1B787C9C23787CBD2B78";
const u8 newcode[] = "4E800020";
-    patch_hex_str((u8 *) buffer, (len - (strlen((char *) oldcode)>>1)),4 , oldcode, 0, newcode);
+    patch_hex_str((u8 *) buffer, (len - (strlen((char *) oldcode)>>1)),4 , oldcode, 0, newcode, 0);
}
#endif
@@ -7586,6 +7876,7 @@ return 0;
void patch_dol(void *Address, int Section_Size, int mode)
{
+    DCFlushRange(Address, Section_Size);
     //if(mode)
     __Patch_Error001((void *) Address, Section_Size);
@@ -7613,6 +7904,10 @@ void patch_dol(void *Address, int Section_Size, int mode)
     DCFlushRange(Address, Section_Size);
}
+static void __noprint(const char *fmt, ...)
+{
+}
+
int load_disc(u8 *discid)
{
         static struct DiscHeader Header ALIGNED(0x20);
@@ -7629,6 +7924,12 @@ int load_disc(u8 *discid)
         WDVD_Init();
+ 
+        if(discid[6]==2) // DVD USB
+            {
+            if(WDVD_SetUSBMode((u8 *) "_DVD__",0)!=0) return 1;
+            }
+        else
         if(discid[6]!=0)
             {
             if(WDVD_SetUSBMode(NULL,0)!=0) return 1;
@@ -7640,6 +7941,8 @@ int load_disc(u8 *discid)
      
         WDVD_Reset();
+
+     
         //return -456;
      
         memset(Disc_ID, 0, 0x20);
@@ -7648,11 +7951,13 @@ int load_disc(u8 *discid)
         if (*Disc_ID==0x10001 || *Disc_ID==0x10001)
                 return 2;
+
+     
    
         Determine_VideoMode(*Disc_Region);
     
         WDVD_UnencryptedRead(&Header, sizeof(Header), 0);
-     
+
  
         /* BCA Data can be present at 0x100 offset in the .ISO (normally is a padding area filled with zeroes, but uLoader use it for BCA datas) */
@@ -7683,13 +7988,17 @@ int load_disc(u8 *discid)
             if(strncmp((char *) &Header, (char *) discid, 6))
                 return 666; // if headerid != discid (on hdd) error
             }
+     
+        else  memcpy((char *) discid, (char *) &Header, 6);
         cabecera2( "Loading...");
-        u32 Offset = 0x00040000; // Offset into disc to partition descriptor
+        u64 Offset = 0x00040000; // Offset into disc to partition descriptor
         WDVD_UnencryptedRead(&Descriptor, sizeof(Descriptor), Offset);
-        Offset = Descriptor.Primary_Offset << 2;
+        Offset = ((u64) Descriptor.Primary_Offset) << 2;
+
+     
         u32 PartSize = sizeof(Partition_Info);
         u32 BufferLen = Descriptor.Primary_Count * PartSize;
@@ -7713,12 +8022,14 @@ int load_disc(u8 *discid)
                 }
         }
     
-        Offset = Partition_Info.Offset << 2;
+        Offset = ((u64) Partition_Info.Offset) << 2;
         free(PartBuffer);
         if (!Offset)
                 return 3;
+     
+
         WDVD_Seek(Offset);
@@ -7736,11 +8047,34 @@ int load_disc(u8 *discid)
         static u8    Tmd_Buffer[0x49e4] ALIGNED(32);
      
         GetCerts(&Certs, &C_Length);
-        WDVD_UnencryptedRead(Ticket_Buffer, 0x800, Partition_Info.Offset << 2);
+        WDVD_UnencryptedRead(Ticket_Buffer, 0x800, ((u64) Partition_Info.Offset) << 2);
         Ticket        = (signed_blob*)(Ticket_Buffer);
         T_Length    = SIGNED_TIK_SIZE(Ticket);
         cabecera2( "Loading...");
+
+
+         // Patch in info missing from apploader reads
+        *Sys_Magic    = 0x0d15ea5e;
+        *Version    = 1;
+        *Arena_L    = 0x00000000;
+        *BI2        = 0x817E5480;
+        *Bus_Speed    = 0x0E7BE2C0;
+        *CPU_Speed    = 0x2B73A840;
+
+        /* Setup low memory */
+        *(vu32 *)0x80000060 = 0x38A00040;
+        *(vu32 *)0x800000E4 = 0x80431A80;
+        *(vu32 *)0x800000EC = 0x81800000;
+
+        *(vu32 *)0x800000F0 = 0x01800000;       // Simulated Memory Size
+
+        if ((strncmp((char *) discid, "R3XE6U", 6)==0) || (strncmp((char *) discid, "R3XP6V", 6)==0))
+            {
+                *((vu32*) 0x80003184)    = 0x80000000;    // Game ID Address
+            }
+
+        DCFlushRange((void*)0x80000000, 0x3f00);
      
         // Open Partition and get the TMD buffer
@@ -7770,6 +8104,8 @@ int load_disc(u8 *discid)
         AppLoaderExit        Exit    = 0;
         Start(&Enter, &Load, &Exit);
+        Enter(__noprint);
+
         void*    Address = 0;
         int        Section_Size;
         int        Partition_Offset;
@@ -7846,7 +8182,7 @@ int load_disc(u8 *discid)
  
                 if (!Address) return 5;
                 cabecera2("Loading...");
-                WDVD_Read(Address, Section_Size, Partition_Offset << 2);
+                WDVD_Read(Address, Section_Size, ((u64) Partition_Offset) << 2);
                 patch_dol(Address, Section_Size,0);
@@ -7908,22 +8244,6 @@ int load_disc(u8 *discid)
         remote_call_abort();while(remote_ret()==REMOTE_BUSY) usleep(1000*50);
         remote_end();
-        // Patch in info missing from apploader reads
-        *Sys_Magic    = 0x0d15ea5e;
-        *Version    = 1;
-        *Arena_L    = 0x00000000;
-        *BI2        = 0x817E5480;
-        *Bus_Speed    = 0x0E7BE2C0;
-        *CPU_Speed    = 0x2B73A840;
-
-        /* Setup low memory */
-        *(vu32 *)0x80000060 = 0x38A00040;
-        *(vu32 *)0x800000E4 = 0x80431A80;
-        *(vu32 *)0x800000EC = 0x81800000;
-
-        *(vu32 *)0x800000F0 = 0x01800000;       // Simulated Memory Size
-
-
         // Enable online mode in games
         memcpy(Online_Check, Disc_ID, 4);
@@ -7937,16 +8257,31 @@ int load_disc(u8 *discid)
             Set_VideoMode();
      
-        // Flush application memory range
-        DCFlushRange((void*)0x80000000, 0x17fffff);    // TODO: Remove these hardcoded values
-     
+
         usleep(100*1000);
        // debug_printf("start %p\n",Entry);
        settime(secs_to_ticks(time(NULL) - 946684800));
+       //
+
+       VIDEO_SetBlack(TRUE);
+       VIDEO_Flush();
+       VIDEO_WaitVSync();
+
+ 
+       // fix for PeppaPig
+       memcpy((char *) temp_data, (void*)0x800000F4,4);
+ 
        SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
+       // fix for PeppaPig
+       memcpy((void*)0x800000F4,(char *) temp_data, 4);
+
+       // Flush application memory range
+       DCFlushRange((void*)0x80000000, 0x17fffff);    // TODO: Remove these hardcoded value
+ 
+
         __asm__ __volatile__
                 (
                         "mtlr %0;"            // Move the entry point into link register
View 19  src/uloader/source/usbstorage2.c
@@ -126,7 +126,8 @@ s32 USBStorage2_GetCapacity(u32 *_sector_size)
s32 USBStorage2_Init(void)
{
-    s32 ret;
+    s32 ret,ret2;
+    static u32 sector_size=0;
     /* Already open */
     if (fd >= 0)
@@ -149,16 +150,28 @@ s32 USBStorage2_Init(void)
     /* Initialize USB storage */
     ret=IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_INIT, ":");
     if(ret<0) goto err;
+    if(ret>1) ret=0;
+    ret2=ret;
     /* Get device capacity */
-    ret = USBStorage2_GetCapacity(NULL);
+    ret = USBStorage2_GetCapacity(&sector_size);
     if (!ret)
         {
         ret=-1;
         goto err;
         }
+    if(ret2==0 && sector_size!=512) // check for HD sector size 512 bytes
+        {
+        ret=-20001;
+        goto err;
+        }
+    if(ret2==1 && sector_size!=2048) // check for DVD sector size 2048 bytes
+        {
+        ret=-20002;
+        goto err;
+        }
     mounted=1;
-    return 0;
+    return ret2; // 0->HDD, 1->DVD
err:
     /* Close USB device */
View 23  src/uloader/source/wdvd.c
@@ -294,6 +294,29 @@ s32 WDVD_GetCoverStatus(u32 *status)
     return -ret;
}
+s32 WDVD_GetCoverStatus_USB_DVD(u32 *status)
+{
+    s32 ret;
+
+    memset(inbuf, 0, sizeof(inbuf));
+
+    /* Get cover status */
+    inbuf[0] = 0x13/*IOCTL_DI_GETCOVER*/ << 24;
+
+    ret = IOS_Ioctl(di_fd, 0x13/*IOCTL_DI_GETCOVER*/, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
+    if (ret < 0)
+        return ret;
+
+    if (ret == 1) {
+        /* Copy cover status */
+        memcpy(status, outbuf, sizeof(u32));
+
+        return 0;
+    }
+
+    return -ret;
+}
+
s32 WDVD_DisableReset(u8 val)
{
     s32 ret;
View 1  src/uloader/source/wdvd.h
@@ -16,6 +16,7 @@ s32 WDVD_UnencryptedRead(void *, u32, u64);
s32 WDVD_Read(void *, u32, u64);
s32 WDVD_WaitForDisc(void);
s32 WDVD_GetCoverStatus(u32 *);
+s32 WDVD_GetCoverStatus_USB_DVD(u32 *status);
s32 WDVD_DisableReset(u8);
s32 WDVD_SetUSBMode(u8 *, s32);
s32 WDVD_Read_Disc_BCA(void *buf);
0 comments on commit deee059
Please sign in to comment.
Contact GitHub API Training Shop Blog About
© 2016 GitHub, Inc. Terms Privacy Security Status Help
 
Last edited by knm,

knm

Well-Known Member
OP
Newcomer
Joined
Sep 30, 2012
Messages
61
Trophies
0
Age
39
XP
220
Country
United States
After I found the external DVD codes on Uloader and WiiMC USB test, but I have a question, would it possible to added it on USB loaders (like USB loader GX, Wiiflow, CFG , and/or any loaders)? Because most Wii (2009 or newer) and Wii U cannot read DVD-R/+R DL backup disc on the new drive.
 
Last edited by knm,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: *yawn*