KazoWAR

pcout.c

Jan 25th, 2015
6,237
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "spider.h"
  2. #include "fs.h"
  3.  
  4. int uvl_entry()
  5. {
  6.     FILE *fout = (void *)0x08F10000;
  7.     unsigned int addr;
  8.     int *buf = 0x18410000;
  9.     int *written = 0x08F01000;
  10.     int i;
  11.     unsigned int EBUS;
  12.     unsigned int constblock;
  13.     unsigned int offset;
  14.     int j;
  15.     int ADJ;
  16.  
  17.     addr = 0x17900000; //Way lower than necessary, but we're going to hunt for the relative offsets of box data.
  18.  
  19.     EBUS = 0;
  20.     constblock = 0;
  21.     offset = 0;
  22.  
  23.     for (j = 0; j < 0x10 && offset == 0; j++)
  24.     {
  25.         GSPGPU_FlushDataCache(addr, 0x10000);
  26.         GX_SetTextureCopy(addr, buf, 0x10000, 0, 0, 0, 0, 8);
  27.         GSPGPU_FlushDataCache(buf, 0x10000);
  28.         svcSleepThread(0x400000LL);
  29.         for (i = 0; i < 0x4000; i++)
  30.         {
  31.             if ((buf[i] == 0x53554245 && buf[i - 1] == 0 && buf[i - 2] == 0 && buf[i - 3] == 0) && EBUS == 0)
  32.             {
  33.                 EBUS = addr + 4 * i;
  34.             }
  35.             if ((buf[i] == 0x53554245 && buf[i + 1] == 0 && buf[i + 2] == 0 && buf[i + 3] == 0) && EBUS == 0)
  36.             {
  37.                 EBUS = addr + 4 * i;
  38.             }
  39.             if ((buf[i] == 0x00000126) && (buf[i + 1] == 0x00000000) && (buf[i + 2] == 0x22018230) && (buf[i + 3] == 0x09060D30)) //Static data in save files.
  40.             {
  41.                 constblock = addr + 4 * i;
  42.             }
  43.         }
  44.         if (constblock != 0 && EBUS != 0)
  45.         {
  46.             unsigned int diff = constblock - EBUS;
  47.             if (diff == 0x38A0 || diff == 0x383C || diff == 0x3750 || diff == 0x3664 || diff == 0x3608) // ORAS
  48.             {
  49.                 offset = constblock + 0xFFE8;
  50.                 ADJ = 1;
  51.             }
  52.             else if (diff == 0x37DC || diff == 0x3778 || diff == 0x368C || diff == 0x35A0) //XY
  53.             {
  54.                 offset = constblock + 0x848;
  55.                 ADJ = 2;
  56.             }
  57.             else //wtf
  58.             {
  59.                 offset = 0;
  60.                 ADJ = 0;
  61.             }
  62.         }
  63.         addr += 0x10000;
  64.     }
  65.  
  66.     if (offset != 0)
  67.     {
  68.         IFile_Open(fout, L"dmc:/pcdata.bin", FILE_W);
  69.         fout->pos = 0x00;
  70.  
  71.         //first 0xFFFC / 0xFFF8 byte
  72.         GSPGPU_FlushDataCache(offset, 0x10000);
  73.         GX_SetTextureCopy(offset, buf, 0x10000, 0, 0, 0, 0, 8);
  74.         GSPGPU_FlushDataCache(buf, 0x10000);
  75.         svcSleepThread(0x400000LL);
  76.         IFile_Write(fout, written, buf + ADJ, 0x10000 - (ADJ * 4));
  77.         svcSleepThread(0x400000LL);
  78.         offset += 0x10000;
  79.  
  80.         //0x20000 Bytes
  81.         for (i = 0; i < 2; i++)
  82.         {
  83.             GSPGPU_FlushDataCache(offset, 0x10000);
  84.             GX_SetTextureCopy(offset, buf, 0x10000, 0, 0, 0, 0, 8);
  85.             GSPGPU_FlushDataCache(buf, 0x10000);
  86.             svcSleepThread(0x400000LL);
  87.             IFile_Write(fout, written, buf, 0x10000);
  88.             svcSleepThread(0x400000LL);
  89.             offset += 0x10000;
  90.         }
  91.  
  92.         //last 0x4AD4 / 0x4AD8 Bytes
  93.         GSPGPU_FlushDataCache(offset, 0x10000);
  94.         GX_SetTextureCopy(offset, buf, 0x10000, 0, 0, 0, 0, 8);
  95.         GSPGPU_FlushDataCache(buf, 0x10000);
  96.         svcSleepThread(0x400000LL);
  97.         IFile_Write(fout, written, buf, 0x4AD0 + (ADJ * 4));
  98.         svcSleepThread(0x400000LL);
  99.  
  100.         //Green - Success!
  101.         for(i = 0; i < 0xE100; i+=3)
  102.         {
  103.             buf[i] = 0x0000FF00;
  104.             buf[i+1] = 0xFF0000FF;
  105.             buf[i+2] = 0x00FF0000;
  106.         }
  107.        
  108.     }
  109.     else
  110.     {
  111.         //Red - Failure!
  112.         for (i = 0; i < 0xE100; i+=3)
  113.         {
  114.             buf[i] = 0x00FF0000;
  115.             buf[i+1] = 0x0000FF00;
  116.             buf[i+2] = 0xFF0000FF;
  117.         }
  118.     }
  119.  
  120.     GSPGPU_FlushDataCache(buf, 0x00038400);
  121.     GX_SetTextureCopy(buf, 0x1F48F000, 0x00038400, 0, 0, 0, 0, 8);
  122.     svcSleepThread(0x400000LL);
  123.     GSPGPU_FlushDataCache(buf, 0x00038400);
  124.     GX_SetTextureCopy(buf, 0x1F4C7800, 0x00038400, 0, 0, 0, 0, 8);
  125.     svcSleepThread(0x400000LL);
  126.  
  127.     return 0;
  128. }
RAW Paste Data