- Joined
- Jul 7, 2010
- Messages
- 4,096
- Trophies
- 2
- Location
- /dev/random
- Website
- www.gudenau.net
- XP
- 6,665
- Country
I am attempting to load an image from the SD card into the VRAM to display on the bottom screen, but it is not working.
Any help?
code.c
SplashConvert.java
Edit:
Extra credit for a clean exit function. ;-)
Any help?
code.c
Code:
#define START_SECTION __attribute__ ((section (".text.start"), naked))
// make sure code is PIE
#ifndef __PIE__
#error "Must compile with -fPIE"
#endif
// File IO
#define FILE_R 0x1
#define FILE_W 0x6
typedef struct file_s {
int s;
int pos;
int size;
} FILE;
int(*IFile_Open)(FILE *this, const short *path, int flags) = (void *)0x0022FE08;
int(*IFile_Read)(FILE *this, unsigned int *read, void *buffer, unsigned int size) = (void *)0x001686DC;
int(*IFile_Write)(FILE *this, unsigned int *written, void *src, unsigned int len) = (void *)0x00168764;
// GPU
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;
int(*GSPGPU_FlushDataCache)(void *addr, unsigned int len) = 0x00191504;
// SVC
int(*svcSleepThread)(unsigned long long nanoseconds) = 0x0023FFE8;
int main();
int START_SECTION entryPoint(){
__asm__ volatile (".word 0xE1A00000");
main();
__asm__ volatile ("bx lr");
}
int main(){
int i;
FILE *file = (void *)0x08F10000;
int *buf = 0x18410000;
int *read = 0x08F10020;
//for (i = 0; i < 0xE100; i += 3){
// buf[i] = 0x0000FF00;
// buf[i + 1] = 0xFF0000FF;
// buf[i + 2] = 0x00FF0000;
//}
IFile_Open(file, L"dmc:/splash.bin", FILE_R);
IFile_Read(file, read, buf, 0xE100);
GSPGPU_FlushDataCache(buf, 0x00038400);
GX_SetTextureCopy(buf, 0x1F48F000, 0x00038400, 0, 0, 0, 0, 8);
svcSleepThread(0x400000LL);
GSPGPU_FlushDataCache(buf, 0x00038400);
GX_SetTextureCopy(buf, 0x1F4C7800, 0x00038400, 0, 0, 0, 0, 8);
svcSleepThread(0x400000LL);
svcSleepThread (0x6fc23ac00LL); // wait 30 seconds
return 0;
}
int exit(int status){
return 0;
}
SplashConvert.java
Code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import javax.imageio.ImageIO;
public class SplashConvert {
public static void main(String[] args) throws Throwable{
System.out.println(args[0]);
System.out.println(args[1]);
BufferedImage image = ImageIO.read(new File(args[0]));
FileOutputStream out = new FileOutputStream(new File(args[1]));
int[] data = new int[image.getWidth() * image.getHeight()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, image.getWidth());
ByteBuffer buffer = ByteBuffer.allocate(data.length*4);
buffer.asIntBuffer().put(data);
out.write(buffer.array());
out.close();
}
}
Edit:
Extra credit for a clean exit function. ;-)