SHARE
TWEET

grayscreenshotlib.c

PierrotLL May 13th, 2011 169 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "grayscreenshotlib.h"
  2.  
  3. int file_handle, time, n_screen;
  4.  
  5. void gsl_init(int n_screenshot)
  6. {
  7.         unsigned short filename[] = {'\\','\\','c','r','d','0','\\','M','O','V','I','E','.','g','s','l',0};
  8.         gsl_CreateFile(filename, 2048*n_screenshot);
  9.         file_handle = gsl_OpenFile(filename, 2);
  10.         n_screen = n_screenshot;
  11.         time = 0;
  12. }
  13.  
  14. void gsl_quit()
  15. {
  16.         gsl_CloseFile(file_handle);
  17.         n_screen = 0;
  18. }
  19.  
  20. void gsl_screenshot(const unsigned char* light_buffer, const unsigned char* dark_buffer)
  21. {
  22.         if(n_screen) {
  23.                 if(gsl_GetTicks()-time > 6) {
  24.                         time = gsl_GetTicks();
  25.                         gsl_WriteFile(file_handle, light_buffer, 1024);
  26.                         gsl_WriteFile(file_handle, dark_buffer, 1024);
  27.                         n_screen--;
  28.                 }
  29.         }
  30. }
  31.  
  32. /* syscalls */
  33.  
  34. const int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070};
  35. static int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode;
  36.  
  37. static int gsl_CreateFile(const unsigned short *filename, int size) {
  38.         return (int)((*SysCall)( (int)filename, 1, (int)&size, 0, 0x0434 ));
  39. }
  40.  
  41. static int gsl_WriteFile(int handle, void* buffer, int size) {
  42.         if (handle & 0xF000000) { return (int)((*SysCall)( handle, (int)buffer, size, 0, 0x0435 )); }
  43.         else { return -1; }
  44. }
  45.  
  46. static int gsl_OpenFile(const unsigned short *filename, int mode) {
  47.         return (int)((*SysCall)( (int)filename, mode, 0, 0, 0x042C ));
  48. }
  49.  
  50. static int gsl_CloseFile(int handle) {
  51.         if (handle & 0xF000000) { return (int)((*SysCall)( handle, 0, 0, 0, 0x042D )); }
  52.         else { return -1; }
  53. }
  54.  
  55. static int gsl_GetTicks(void) {
  56.         return (int)((*SysCall)( 0, 0, 0, 0, 0x003B ));
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top