Skip to content

Commit 89a6f68

Browse files
committed
Add option for custom background styles
1 parent 3ec3597 commit 89a6f68

File tree

5 files changed

+70
-18
lines changed

5 files changed

+70
-18
lines changed

CHANGELOG.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
#### v2.0.0
44

55
- Merged Quick Power, Quick Volume, and Rapidmenu
6-
- Support testkit firmware 3.60
7-
- Added "Restart" text to poweroff button (20 languages)
8-
- Configurable Quick Menu PS button push time
9-
- Option to restart with the standby button
6+
- Configurable Quick Menu open time
7+
- Configurable power buttons
8+
- Custom background styles and other visual enhancements
109
- Fixed a bug where SceShell's internal state becomes inconsistent
11-
- Many visual enhancements
10+
- Support testkit firmware 3.60
1211

1312
### Changelog - Quick Power
1413

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Quick Menu Plus adds the following features to the Quick Menu on the PlayStation Vita and PlayStation TV.
44

5-
- Power off and standby buttons for Vita
6-
- Restart from the Quick Menu
7-
- Volume slidebar for Vita
8-
- Configurable Quick Menu PS button push time
9-
- Remove gradient overlay from the Quick Menu
5+
- Power off, restart, and standby buttons
6+
- Configurable power buttons
7+
- Volume slidebar
8+
- Faster Quick Menu open time
9+
- Custom background styles
1010

1111
![preview.png](https://git.shotatoshounenwachigau.moe/vita/quickmenuplus/plain/preview-small.png?h=assets)
1212

@@ -31,10 +31,14 @@ Put files in the directory `ur0:/data/quickmenuplus` to configure Quick Menu Plu
3131

3232
- `pushtime.txt` sets the Quick Menu PS button push time. Put in the file the desired push time in microseconds. For example, put `250000` for 250 milliseconds. If the file does not exist, the push time is unchanged.
3333

34-
- `standbyisrestart.txt` sets the standby button to function as a restart button. Put in the file `1` to enable, or `0` to disable. If the file does not exist, the default is disable.
34+
- `standbyisrestart.txt` sets the standby button to function as a restart button. Put in the file `1` to enable, or `0` to disable. If the file does not exist, the default is disable. When this setting is disabled, hold the "Power Off・Restart" button to restart, and press to power off.
3535

3636
![standbyisrestart-preview.png](https://git.shotatoshounenwachigau.moe/vita/quickmenuplus/plain/standbyisrestart-preview-small.png?h=assets)
3737

38+
- `bgstyle.txt` sets the background style. Put in the file `0` for original, `1` for translucent, and `2` for black. If the file does not exist, the default is original. Black can reduce power consumption for OLED screens. The gradient effect is removed in all styles.
39+
40+
![bgstyle-preview.png](https://git.shotatoshounenwachigau.moe/vita/quickmenuplus/plain/bgstyle-preview-small.png?h=assets)
41+
3842
## Contributing
3943

4044
Use [git-format-patch](https://www.git-scm.com/docs/git-format-patch) or [git-request-pull](https://www.git-scm.com/docs/git-request-pull) and email me at <[email protected]>.

ScePaf.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ modules:
99
functions:
1010
scePafButtonSetRepeat: 0x16479BA7
1111
scePafWidgetFindById: 0x9D304F4A
12+
scePafWidgetSetColour: 0x627CDA4E
1213
ScePafToplevel:
1314
kernel: false
1415
nid: 0x4D9A9DD0

quickmenuplus.c

+53-7
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
4444
#define N_INJECT 3
4545
static SceUID inject_id[N_INJECT];
4646

47-
#define N_HOOK 6
47+
#define N_HOOK 7
4848
static SceUID hook_id[N_HOOK];
4949
static tai_hook_ref_t hook_ref[N_HOOK];
5050

@@ -78,7 +78,12 @@ static const SceWChar16 *restart_text[N_LANG] = {
7878
u"Yeniden başlatmak",
7979
};
8080

81+
#define BG_STYLE_ORIGINAL 0
82+
#define BG_STYLE_TRANSLUCENT 1
83+
#define BG_STYLE_BLACK 2
84+
8185
static bool standby_is_restart = false;
86+
static int bg_style = BG_STYLE_ORIGINAL;
8287

8388
static atomic_int system_volume;
8489

@@ -134,13 +139,16 @@ static ScePafWidget *get_widget(ScePafWidget *parent, SceUInt32 id) {
134139
return scePafWidgetFindById(parent, &param, 0);
135140
}
136141

142+
static void colour_convert_rgba(float *farr, SceUInt32 rgba) {
143+
farr[0] = (float)((rgba >> 0x18) & 0xFF) / 255.0;
144+
farr[1] = (float)((rgba >> 0x10) & 0xFF) / 255.0;
145+
farr[2] = (float)((rgba >> 0x08) & 0xFF) / 255.0;
146+
farr[3] = (float)((rgba >> 0x00) & 0xFF) / 255.0;
147+
}
148+
137149
static void set_btn_colour(ScePafWidget *widget, SceUInt32 colour) {
138-
float _colour[4] = {
139-
(float)((colour >> 0x18) & 0xFF) / 255.0,
140-
(float)((colour >> 0x10) & 0xFF) / 255.0,
141-
(float)((colour >> 0x08) & 0xFF) / 255.0,
142-
(float)((colour >> 0x00) & 0xFF) / 255.0,
143-
};
150+
float _colour[4];
151+
colour_convert_rgba(_colour, colour);
144152

145153
// style objs are indexed in the order they appear in the RCO XML
146154
ScePafStyle *plane_obj = widget->vptr->get_style_obj(widget, 0);
@@ -149,6 +157,12 @@ static void set_btn_colour(ScePafWidget *widget, SceUInt32 colour) {
149157
}
150158
}
151159

160+
static void set_widget_colour(ScePafWidget *widget, SceUInt32 colour) {
161+
float _colour[4];
162+
colour_convert_rgba(_colour, colour);
163+
scePafWidgetSetColour(0.0, widget, _colour, 0, 0x10001, 0, 0, 0);
164+
}
165+
152166
static void set_power_text(ScePafWidget *parent) {
153167
ScePafWidget *box_widget = get_widget(parent, QUICK_MENU_BOX_ID);
154168
if (box_widget) {
@@ -245,6 +259,24 @@ static int process_volume_hook(int *audio_info, void *button_info) {
245259
return TAI_NEXT(process_volume_hook, hook_ref[5], audio_info, button_info);
246260
}
247261

262+
// This function initialises some fields of the Quick Menu background plane
263+
// which has ID 0xE83F6AF0. Disabling this function or using other arguments
264+
// did not seem to make any difference.
265+
// r1 - 3
266+
// r2 - {960.0, 544.0}
267+
// r3 - {0.0, 0.0}
268+
static void bg_plane_init_hook(ScePafWidget *r0, int r1, float *r2, float *r3) {
269+
TAI_NEXT(bg_plane_init_hook, hook_ref[6], r0, r1, r2, r3);
270+
switch (bg_style) {
271+
case BG_STYLE_TRANSLUCENT:
272+
set_widget_colour(r0, 0x282828C0);
273+
break;
274+
case BG_STYLE_BLACK:
275+
set_widget_colour(r0, 0x000000FF);
276+
break;
277+
}
278+
}
279+
248280
static void startup(void) {
249281
sceClibMemset(inject_id, 0xFF, sizeof(inject_id));
250282
sceClibMemset(hook_id, 0xFF, sizeof(hook_id));
@@ -270,6 +302,7 @@ USED int module_start(UNUSED SceSize args, UNUSED const void *argp) {
270302
}
271303

272304
standby_is_restart = config_read_key("standbyisrestart");
305+
bg_style = config_read_key("bgstyle");
273306

274307
// get SceShell module info
275308
tai_module_info_t minfo;
@@ -380,6 +413,19 @@ USED int module_start(UNUSED SceSize args, UNUSED const void *argp) {
380413
// Disable quick menu gradient effect (cmp r0, r0)
381414
GLZ(INJECT_ABS(2, (void*)(quick_menu_init + 0x186), "\x80\x42", 2));
382415

416+
if (bg_style != BG_STYLE_ORIGINAL) {
417+
// Address of branch to bg_plane_init
418+
int bg_plane_init_bl = quick_menu_init + 0x12C;
419+
420+
// Address of the function bg_plane_init
421+
int bg_plane_init;
422+
GLZ(decode_bl_t1(*(int*)bg_plane_init_bl, &bg_plane_init));
423+
bg_plane_init += bg_plane_init_bl + 4;
424+
425+
// Custom style for the Quick Menu background
426+
GLZ(HOOK_OFFSET(6, minfo.modid, bg_plane_init - seg0, 1, bg_plane_init));
427+
}
428+
383429
return SCE_KERNEL_START_SUCCESS;
384430

385431
fail:

scepaf.h

+2
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,6 @@ const SceWChar16 *scePafLabelFindById(ScePafPlugin*, const ScePafResourceSearchP
8282

8383
ScePafWidget *scePafWidgetFindById(ScePafWidget*, const ScePafResourceSearchParam*, int);
8484

85+
void scePafWidgetSetColour(float, ScePafWidget*, float*, int, int, int, int, int);
86+
8587
#endif

0 commit comments

Comments
 (0)