Advertisement
SciresM

code.c (X/Y/OR/AS box import/export)

Jan 25th, 2015
3,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.95 KB | None | 0 0
  1. #include "spider.h"
  2.  
  3. int(*IFile_Open)(void *this, const short *path, int flags) = 0x0022FE08;
  4. int(*IFile_Read)(void *this, unsigned int *read, unsigned int *buffer, unsigned int len) = 0x001686DC;
  5. int(*IFile_Write)(void *this, unsigned int *written, void *src, unsigned int len) = 0x00168764;
  6. int (*GX_SetTextureCopy)(void *input_buffer, void *output_buffer, unsigned int size, int in_x, int in_y, int out_x, int out_y, int flags) = 0x0011DD48;
  7. int (*GSPGPU_FlushDataCache)(void *addr, unsigned int len) = 0x00191504;
  8.  
  9. int uvl_entry ()
  10. {
  11.     unsigned int addr;
  12.     void *this = 0x08F10000;
  13.     int *read_len = 0x08F10020;
  14.     int *buf = 0x18410000;
  15.     int *written = 0x08F01000;
  16.     int boxData[0x3A*30];
  17.     int *HID = 0x10146000;
  18.     unsigned int keyPresses = HID[0];
  19.     int i;
  20.     unsigned int EBUS;
  21.     unsigned int constblock;
  22.     unsigned int offset;
  23.     int j;
  24.     int ADJ;
  25.    
  26.     addr = 0x17900000; //Way lower than necessary, but we're going to hunt for the relative offsets of box data.
  27.    
  28.     EBUS = 0;
  29.     constblock = 0;
  30.     offset = 0;
  31.     ADJ = 0;
  32.    
  33.     for (j=0; j<0x10 && offset == 0;j++)
  34.     {
  35.         GSPGPU_FlushDataCache(addr, 0x10000);
  36.         GX_SetTextureCopy(addr, buf, 0x10000, 0, 0, 0, 0, 8);
  37.         GSPGPU_FlushDataCache(buf, 0x10000);
  38.         svcSleepThread(0x400000LL);
  39.         for (i = 0; i < 0x4000; i++)
  40.         {
  41.             if ((buf[i] == 0x53554245 && buf[i-1] == 0 && buf[i-2] == 0 && buf[i-3] == 0) && EBUS == 0)
  42.             {
  43.                 EBUS = addr+4*i;
  44.             }
  45.             if ((buf[i] == 0x53554245 && buf[i+1] == 0 && buf[i+2] == 0 && buf[i+3] == 0) && EBUS == 0)
  46.             {
  47.                 EBUS = addr+4*i;
  48.             }
  49.             if ((buf[i] == 0x00000126) && (buf[i+1] == 0x00000000) && (buf[i+2] == 0x22018230) && (buf[i+3] == 0x09060D30)) //Static data in save files.
  50.             {
  51.                 constblock = addr+4*i;
  52.             }
  53.         }
  54.         if (constblock != 0 && EBUS != 0)
  55.         {
  56.             unsigned int diff = constblock-EBUS;
  57.             if (diff == 0x38A0 || diff == 0x383C || diff == 0x3750 || diff == 0x3664 || diff == 0x3608) // ORAS
  58.             {
  59.                 offset = constblock+0xFFE8;
  60.                 ADJ = 1;
  61.             }
  62.             else if (diff == 0x37DC|| diff == 0x3778 || diff == 0x368C || diff == 0x35A0) //XY
  63.             {
  64.                 offset = constblock+0x848;
  65.                 ADJ = 2;
  66.             }
  67.             else //wtf
  68.             {
  69.                 offset = 0;
  70.                 ADJ=0;
  71.             }
  72.         }
  73.         addr += 0x10000;
  74.     }
  75.        
  76.     if (offset != 0)
  77.     {
  78.         addr = offset;
  79.         GSPGPU_FlushDataCache(addr, 0x10000);
  80.         GX_SetTextureCopy(addr, buf, 0x10000, 0, 0, 0, 0, 8);
  81.         GSPGPU_FlushDataCache(buf, 0x10000);
  82.         svcSleepThread(0x400000LL);
  83.         svcSleepThread(0x400000LL);
  84.         IFile_Open(this, L"dmc:/boxdata.bin", 0x1);
  85.         *((int *)this + 1) = 0x00000000; //Fseek to 0
  86.         IFile_Read(this, read_len, (buf+ADJ), 0xE8*30);
  87.         GSPGPU_FlushDataCache(buf, 0x10000);
  88.         GX_SetTextureCopy(buf, addr, 0x10000, 0, 0, 0, 0, 8);
  89.         GSPGPU_FlushDataCache(addr, 0x10000);
  90.         svcSleepThread(0x400000LL);
  91.        
  92.         IFile_Open(this, L"dmc:/box2dump.bin", 0x6);
  93.         *((int *)this + 1) = 0x00000000; //Fseek to 0
  94.         IFile_Write(this, written, (buf+ADJ+0x3A*30), 0xE8*30);
  95.         svcSleepThread(0x400000LL);
  96.     }
  97.    
  98.  
  99.     return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement