Advertisement
PierrotLL

grayscreenshotlib.c

May 13th, 2011
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement