Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "lib.h"
- #include "FS.h"
- #include <wchar.h>
- #include <stdio.h>
- #define VRAM (unsigned char*)0x18000000
- #define FCRAM (unsigned char*)0x20000000
- #define ARM9_RAM (unsigned char*)0x8000000
- #define TOP_FRAME 0
- #define BOT_FRAME 1
- unsigned char handle[32];
- unsigned char bmpHead[] = {
- 0x42, 0x4D, 0x36, 0x65, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xF0, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x65, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
- void memdump(wchar_t* filename, unsigned char* buf, unsigned int size){
- unsigned int br = 0;
- memset(&handle, 0, 32);
- fopen9(&handle, filename, 6);
- fwrite9(&handle, &br, buf, size);
- fclose9(&handle);
- for(int i = 0; i < 0x46500; i++) *(VRAM+0x1E6000 + i) = 0xFF;
- }
- void transpose (void * dst, const void * src, unsigned dim1, unsigned dim2, unsigned item_length) {
- char * ptr_write;
- const char * ptr_read;
- unsigned x, y, z;
- for (x = 0; x < dim1; x ++) for (y = 0; y < dim2; y ++) {
- ptr_write = ((char *) dst) + item_length * (y * dim1 + x);
- ptr_read = ((const char *) src) + item_length * (x * dim2 + y);
- for (z = 0; z < item_length; z ++) *(ptr_write ++) = *(ptr_read ++);
- }
- }
- void screenShot(int frame){
- unsigned int br;
- short width = frame == 0 ? 400 : 320;
- short height = 240;
- int frameOff = frame == 0 ? 0x300000 : 0; //0x1E6000 : 0x48F000; //<- Defaults
- int length = frame == 0 ? 0x46500 : 0x38400;
- memset(&handle, 0, 32);
- fopen9(&handle, frame == 0 ? L"sdmc:/screen_top.bmp" : L"sdmc:/screen_bot.bmp", 6);
- transpose(FCRAM+0xF80000, VRAM+frameOff, width, height, 3);
- bmpHead[18] = frame == 0 ? 0x90 : 0x40;
- fwrite9(&handle, &br, bmpHead, 0x36);
- fwrite9(&handle, &br, FCRAM+0xF80000, length);
- fclose9(&handle);
- for(int i = 0; i < length; i++) *(VRAM+frameOff + i) = 0xFF;
- }
- void myThread(){
- while(1){
- if(getHID() & BUTTON_SELECT){
- screenShot(TOP_FRAME);
- screenShot(BOT_FRAME);
- }
- if(getHID() & BUTTON_START) memdump(L"sdmc:/VRAM.bin", VRAM, 0x00600000);
- }
- __asm("SVC 0x09");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement