Browse Source

[psp] many fixes

master
asie 1 month ago
parent
commit
14b482eee2
4 changed files with 44 additions and 6 deletions
  1. BIN
      res/6x10.png
  2. BIN
      res/6x8.png
  3. 40
    6
      src/frontend_psp.c
  4. 4
    0
      src/types.h

BIN
res/6x10.png View File


BIN
res/6x8.png View File


+ 40
- 6
src/frontend_psp.c View File

@@ -21,6 +21,7 @@
21 21
 #include <stdlib.h>
22 22
 #include <string.h>
23 23
 #include <time.h>
24
+#include <unistd.h>
24 25
 
25 26
 #include "zzt.h"
26 27
 #include "posix_vfs.h"
@@ -94,6 +95,7 @@ int psp_exit_thread(SceSize args, void *argp) {
94 95
 }
95 96
 
96 97
 static int zzt_thread_running = 1;
98
+static int psp_osk_open = 0;
97 99
 static long timer_last_ms;
98 100
 
99 101
 int psp_zzt_thread(SceSize args, void *argp) {
@@ -101,6 +103,11 @@ int psp_zzt_thread(SceSize args, void *argp) {
101 103
 
102 104
 	timer_last_ms = zeta_time_ms();
103 105
 	while (zzt_thread_running) {
106
+		if (psp_osk_open) {
107
+			sceKernelDelayThreadCB(20 * 1000);
108
+			continue;
109
+		}
110
+
104 111
 		long duration = zeta_time_ms();
105 112
 		int rcode = zzt_execute(opcodes);
106 113
 		long timer_curr_ms = zeta_time_ms();
@@ -132,6 +139,12 @@ static int osk_counter = 0;
132 139
 int psp_timer_thread(SceSize args, void *argp) {
133 140
 	while (zzt_thread_running) {
134 141
 		long curr_timer_tick = zeta_time_ms();
142
+		if (psp_osk_open) {
143
+			timer_time = curr_timer_tick - first_timer_tick;
144
+			sceKernelDelayThreadCB(20 * 1000);
145
+			continue;
146
+		}
147
+
135 148
 		zzt_mark_timer();
136 149
 
137 150
 		timer_time += SYS_TIMER_TIME;
@@ -252,12 +265,18 @@ static void psp_draw_frame(void) {
252 265
 }
253 266
 
254 267
 void psp_audio_callback(void *stream, unsigned int len, void *userdata) {
268
+	if (psp_osk_open) {
269
+		memset(stream, 0, len*sizeof(s16)*2);
270
+		return;
271
+	}
272
+
255 273
 	u8 *stream_u8 = ((u8*) stream) + (len * 3);
256 274
 	s16 *stream_s16 = ((s16*) stream);
257 275
 
258 276
 	audio_stream_generate_u8(zeta_time_ms(), stream_u8, len);
259 277
 	for (int i = 0; i < len; i++, stream_u8++, stream_s16+=2) {
260
-		s32 val = (((s32) stream_u8[0]) << 8) - 0x8000;
278
+		s8 sample_s8 = (s8) (stream_u8[0] ^ 0x80);
279
+		s16 val = ((s16) sample_s8) << 8;
261 280
 		stream_s16[0] = (s16) val;
262 281
 		stream_s16[1] = (s16) val;
263 282
 	}
@@ -271,12 +290,27 @@ void speaker_off(void) {
271 290
 	audio_stream_append_off(zeta_time_ms());
272 291
 }
273 292
 
293
+static void psp_init_vfs(void) {
294
+	char buf[MAXPATHLEN+1];
295
+
296
+	if (getcwd(buf, MAXPATHLEN) == NULL || strlen(buf) <= 0) {
297
+		fprintf(stderr, "psp_init_vfs: getcwd failed, using fallback\n");
298
+		if (chdir("ms0:/PSP/GAME/ZETA/") != 0) {
299
+			fprintf(stderr, "psp_init_vfs: chdir failed, using fallback\n");
300
+			init_posix_vfs("ms0:/PSP/GAME/ZETA/");
301
+			return;
302
+		}
303
+	}
304
+
305
+	init_posix_vfs("");
306
+}
307
+
274 308
 int main(int argc, char** argv) {
275 309
 	SceCtrlData pad;
276 310
 	u32 last_buttons = 0;
277 311
 
278 312
 	{
279
-		init_posix_vfs("");
313
+		psp_init_vfs();
280 314
 		zzt_init();
281 315
 
282 316
 		int exeh = vfs_open("zzt.exe", 0);
@@ -414,10 +448,10 @@ int main(int argc, char** argv) {
414 448
 			if (br & PSP_CTRL_DOWN) zzt_keyup(0x50);
415 449
 			if (br & PSP_CTRL_RIGHT) zzt_keyup(0x4D);
416 450
 			if (br & PSP_CTRL_CROSS) zzt_kmod_clear(0x01);
417
-			if (bp & PSP_CTRL_CIRCLE) zzt_keyup(0x1C);
451
+			if (br & PSP_CTRL_CIRCLE) zzt_keyup(0x1C);
418 452
 			if (br & PSP_CTRL_SELECT) zzt_keyup(16);
419 453
 			if (br & PSP_CTRL_RTRIGGER && osk_text[0] == 0) {
420
-				int osk_running = 1;
454
+				psp_osk_open = 1;
421 455
 				unsigned short desctext[33];
422 456
 				unsigned short intext[65];
423 457
 				SceUtilityOskData data[1];
@@ -457,7 +491,7 @@ int main(int argc, char** argv) {
457 491
 				params.data = data;
458 492
 
459 493
 				sceUtilityOskInitStart(&params);
460
-				while (osk_running) {
494
+				while (psp_osk_open) {
461 495
 					sceGuStart(GU_DIRECT, gu_list);
462 496
 					sceGuClearColor(0);
463 497
 					sceGuClearDepth(0);
@@ -472,7 +506,7 @@ int main(int argc, char** argv) {
472 506
 							sceUtilityOskShutdownStart();
473 507
 							break;
474 508
 						case PSP_UTILITY_DIALOG_NONE:
475
-							osk_running = 0;
509
+							psp_osk_open = 0;
476 510
 							break;
477 511
 					}
478 512
 					sceDisplayWaitVblankStartCB();

+ 4
- 0
src/types.h View File

@@ -34,11 +34,15 @@
34 34
 # endif
35 35
 #endif
36 36
 
37
+#if !defined(_3DS)
37 38
 typedef signed char s8;
38 39
 typedef signed short s16;
39 40
 typedef signed int s32;
40 41
 typedef unsigned char u8;
41 42
 typedef unsigned short u16;
42 43
 typedef unsigned int u32;
44
+#else
45
+#include <3ds.h>
46
+#endif
43 47
 
44 48
 #endif /* __TYPES_H__ */

Loading…
Cancel
Save