Advertisement
Evilnat

Untitled

Apr 18th, 2025
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "functions.h"
  5. #include "gccpch.h"
  6. #include "log.h"
  7. #include "overclock.h"
  8.  
  9. #define RSX_MEMORY_FREQ_OFFSET      0x28000004010ULL
  10. #define RSX_CORE_FREQ_OFFSET        0x28000004028ULL
  11.  
  12. static wchar_t wchar_string[360]; // Global variable for swprintf
  13.  
  14. int getClockSpeeds()
  15. {
  16.     uint8_t memoryArray[8], coreArray[8];
  17.     uint64_t initialValue; 
  18.  
  19.     // HEN
  20.     if(!is_hen())
  21.     {
  22.         showMessage("msg_hen_notsupported_error", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
  23.         return 1;
  24.     }
  25.  
  26.     // Check if CFW Syscalls are disabled
  27.     if(checkSyscalls(LV1))
  28.     {
  29.         showMessage("msg_cfw_syscalls_disabled", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
  30.         return 1;
  31.     }
  32.  
  33.     initialValue = lv1_peek(RSX_MEMORY_FREQ_OFFSET);
  34.     memcpy(memoryArray, &initialValue, 8);
  35.  
  36.     initialValue = lv1_peek(RSX_CORE_FREQ_OFFSET);
  37.     memcpy(coreArray, &initialValue, 8);
  38.  
  39.     int string = RetrieveString("msg_clock_speeds", (char*)XAI_PLUGIN);
  40.     swprintf_(wchar_string, 120, (wchar_t*)string, (int)coreArray[6] * 50, (int)memoryArray[6] * 25);  
  41.     PrintString(wchar_string, (char*)XAI_PLUGIN, (char*)TEX_SUCCESS);
  42.  
  43.     return 0;
  44. }
  45.  
  46. int set_overclock_freq(uint8_t core, uint8_t memory, int mode)
  47. {
  48.     uint8_t memoryArray[8], coreArray[8];
  49.     uint64_t value;
  50.  
  51.     // HEN
  52.     if(!is_hen())
  53.     {
  54.         showMessage("msg_hen_notsupported_error", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
  55.         return 1;
  56.     }
  57.  
  58.     // Check if CFW Syscalls are disabled
  59.     if(checkSyscalls(LV1))
  60.     {
  61.         showMessage("msg_cfw_syscalls_disabled", (char *)XAI_PLUGIN, (char *)TEX_ERROR);
  62.         return 1;
  63.     }      
  64.  
  65.     if(mode == MODE_FULL || mode == MODE_MEMORY)
  66.     {
  67.         value = lv1_peek(RSX_MEMORY_FREQ_OFFSET);
  68.         memcpy(memoryArray, &value, 8);
  69.         memoryArray[6] = memory;
  70.         value = *(uint64_t *)memoryArray;
  71.         lv1_poke(RSX_MEMORY_FREQ_OFFSET, value);
  72.     }
  73.  
  74.     if(mode == MODE_FULL || mode == MODE_CORE)
  75.     {
  76.         value = lv1_peek(RSX_CORE_FREQ_OFFSET);
  77.         memcpy(coreArray, &value, 8);
  78.         coreArray[6] = core;
  79.         value = *(uint64_t *)coreArray;
  80.         lv1_poke(RSX_CORE_FREQ_OFFSET, value);
  81.     }
  82.  
  83.     getClockSpeeds();
  84.  
  85.     return 0;
  86. }
Tags: xai_plugin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement