;title='OC Toolkit'
;creator='ppkantorski, B3711'
;about='This package was designed for advance overclock configurations. Use with caution and proper guidance.'


[@Software Update]

[Version]
;mode=table
;background=true
;gap=20
ini_file './config.ini'
'Latest Version' = '{ini_file(Update,online)}'

[Update OC Toolkit]
try:
download https://github.com/ppkantorski/Ultrahand-Overlay/releases/latest/download/ovlmenu.ovl /config/ultrahand/downloads/
move /config/ultrahand/downloads/ovlmenu.ovl /switch/.overlays/ovlmenu.ovl
download https://github.com/halop/OC_Toolkit_SC_EOS/releases/latest/download/OC.Toolkit.u.zip /config/ultrahand/downloads/
unzip /config/ultrahand/downloads/OC.Toolkit.u.zip /config/ultrahand/downloads/OC.Toolkit/
move './config.ini' '/config/ultrahand/downloads/OC.Toolkit/OC Toolkit/'
delete './'
move '/config/ultrahand/downloads/OC.Toolkit/OC Toolkit/' './'
delete /config/ultrahand/downloads/OC.Toolkit.u.zip
delete /config/ultrahand/downloads/OC.Toolkit/

[gap]
;mode=table
;background=false
;gap=30

[Update loader.kip]
try:
download https://github.com/halop/OC_Toolkit_SC_EOS/releases/latest/download/kip.zip /config/ultrahand/downloads/
set-ini-val './config.ini' Backup Path 'upd'
clear hex_sum_cache
hex_file '/atmosphere/kips/loader.kip'
ini_file './config.ini'
mkdir /atmosphere/kips/.bakTK/
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuBoost {hex_file(CUST,8,3)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuUVL {hex_file(CUST,12,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuUVH {hex_file(CUST,252,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuVminE {hex_file(CUST,16,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuVmaxE {hex_file(CUST,20,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuVminL {hex_file(CUST,24,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuVminH {hex_file(CUST,28,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup cpuVmaxM {hex_file(CUST,32,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuUVE {hex_file(CUST,36,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuUVM {hex_file(CUST,40,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuOFF {hex_file(CUST,44,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuVminE {hex_file(CUST,48,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuSpeedo {hex_file(CUST,52,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuVminM {hex_file(CUST,56,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup gpuVmax {hex_file(CUST,60,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup DRAM {hex_file(CUST,64,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup ramVDD2 {hex_file(CUST,68,3)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup ramVDDQ {hex_file(CUST,72,3)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup ramMHzE {hex_file(CUST,76,3)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup ramMHzM {hex_file(CUST,80,3)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup DVB {hex_file(CUST,84,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T1 {hex_file(CUST,88,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T2 {hex_file(CUST,92,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T3 {hex_file(CUST,96,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T4 {hex_file(CUST,100,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T5 {hex_file(CUST,104,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T6 {hex_file(CUST,108,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T7 {hex_file(CUST,112,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup T8 {hex_file(CUST,116,1)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 76UV3 {hex_file(CUST,124,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 153UV3 {hex_file(CUST,128,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 230UV3 {hex_file(CUST,132,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 307UV3 {hex_file(CUST,136,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 384UV3 {hex_file(CUST,140,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 460UV3 {hex_file(CUST,144,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 537UV3 {hex_file(CUST,148,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 614UV3 {hex_file(CUST,152,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 691UV3 {hex_file(CUST,156,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 768UV3 {hex_file(CUST,160,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 844UV3 {hex_file(CUST,164,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 921UV3 {hex_file(CUST,168,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 998UV3 {hex_file(CUST,172,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1075UV3 {hex_file(CUST,176,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1152UV3 {hex_file(CUST,180,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1228UV3 {hex_file(CUST,184,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1267UV3 {hex_file(CUST,188,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1305UV3 {hex_file(CUST,192,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1344UV3 {hex_file(CUST,196,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1382UV3 {hex_file(CUST,200,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1420UV3 {hex_file(CUST,204,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1459UV3 {hex_file(CUST,208,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1497UV3 {hex_file(CUST,212,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1536UV3 {hex_file(CUST,216,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup 1305GPU {hex_file(CUST,256,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup CPUUL {hex_file(CUST,264,2)}
set-ini-val '/atmosphere/kips/.bakTK/Backup {ini_file(Backup,Path)}.ini' Backup CPUTABLE {hex_file(CUST,272,2)}

remove-ini-section './config.ini' Backup

unzip /config/ultrahand/downloads/kip.zip /config/ultrahand/downloads/kip/
move /atmosphere/kips/loader.kip '/atmosphere/kips/.bakTK/loader.kip.backup'
move /config/ultrahand/downloads/kip/loader.kip '/atmosphere/kips/loader.kip'
delete /config/ultrahand/downloads/kip.zip
delete /config/ultrahand/downloads/kip/
delete '/atmosphere/kips/loader.kip.backup'


set-ini-val './config.ini' Backup Path '/atmosphere/kips/.bakTK/Backup upd.ini'
clear hex_sum_cache
ini_file './config.ini'
ini_file '{ini_file(Backup,Path)}'

hex-by-custom-offset /atmosphere/kips/loader.kip CUST 8 {ini_file(Backup,cpuBoost)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 12 {ini_file(Backup,cpuUVL)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 252 {ini_file(Backup,cpuUVH)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 16 {ini_file(Backup,cpuVminE)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 20 {ini_file(Backup,cpuVmaxE)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 24 {ini_file(Backup,cpuVminL)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 28 {ini_file(Backup,cpuVminH)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 32 {ini_file(Backup,cpuVmaxM)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 36 {ini_file(Backup,gpuUVE)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 40 {ini_file(Backup,gpuUVM)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 44 {ini_file(Backup,gpuOFF)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 48 {ini_file(Backup,gpuVminE)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 52 {ini_file(Backup,gpuSpeedo)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 56 {ini_file(Backup,gpuVminM)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 60 {ini_file(Backup,gpuVmax)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 64 {ini_file(Backup,DRAM)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 68 {ini_file(Backup,ramVDD2)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 72 {ini_file(Backup,ramVDDQ)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 76 {ini_file(Backup,ramMHzE)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 80 {ini_file(Backup,ramMHzM)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 84 {ini_file(Backup,DVB)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 88 {ini_file(Backup,T1)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 92 {ini_file(Backup,T2)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 96 {ini_file(Backup,T3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 100 {ini_file(Backup,T4)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 104 {ini_file(Backup,T5)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 108 {ini_file(Backup,T6)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 112 {ini_file(Backup,T7)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 116 {ini_file(Backup,T8)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 124 {ini_file(Backup,76UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 128 {ini_file(Backup,153UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 132 {ini_file(Backup,230UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 136 {ini_file(Backup,307UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 140 {ini_file(Backup,384UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 144 {ini_file(Backup,460UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 148 {ini_file(Backup,537UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 152 {ini_file(Backup,614UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 156 {ini_file(Backup,691UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 160 {ini_file(Backup,768UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 164 {ini_file(Backup,844UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 168 {ini_file(Backup,921UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 172 {ini_file(Backup,998UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 176 {ini_file(Backup,1075UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 180 {ini_file(Backup,1152UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 184 {ini_file(Backup,1228UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 188 {ini_file(Backup,1267UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 192 {ini_file(Backup,1305UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 196 {ini_file(Backup,1344UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 200 {ini_file(Backup,1382UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 204 {ini_file(Backup,1420UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 208 {ini_file(Backup,1459UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 212 {ini_file(Backup,1497UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 216 {ini_file(Backup,1536UV3)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 256 {ini_file(Backup,1305GPU)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 264 {ini_file(Backup,CPUUL)}
hex-by-custom-offset /atmosphere/kips/loader.kip CUST 272 {ini_file(Backup,CPUTABLE)}
delete '/atmosphere/kips/.bakTK/Backup upd.ini'
exec boot


[gap]
;mode=table
;background=false
;gap=30


[Update sys-clk-eos]
try:
download https://github.com/halop/OC_Toolkit_SC_EOS/releases/latest/download/sys-clk.zip /config/ultrahand/downloads/
unzip /config/ultrahand/downloads/sys-clk.zip /config/ultrahand/downloads/sys-clk/
move '/config/ultrahand/downloads/sys-clk/' '/'
delete /config/ultrahand/downloads/sys-clk.zip
delete /config/ultrahand/downloads/sys-clk/


[gap]
;mode=table
;background=false
;gap=30


[Package Info]