• R/O
  • SSH
  • HTTPS

gpsp-kai: Commit


Commit MetaInfo

Revision423 (tree)
Time2009-06-14 02:56:03
Authortakka

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/gpsp-kai-test/src/zip.c (revision 422)
+++ trunk/gpsp-kai-test/src/zip.c (revision 423)
@@ -59,20 +59,23 @@
5959 FILE_ID tmp_fd;
6060 u32 zip_buffer_size;
6161 u32 write_tmp_flag = NO;
62+ u32 use_vram;
6263
63- if(psp_model == PSP_2000)
64+ use_vram = NO;
65+
66+ zip_buffer_size = 16 * 1024 * 1024;
67+ cbuffer = malloc(zip_buffer_size);
68+
69+ while(cbuffer == NULL)
6470 {
65- zip_buffer_size = 16 * 1024 * 1024;
71+ zip_buffer_size -= (256 * 1024);
72+ if(zip_buffer_size == 0) break;
6673 cbuffer = malloc(zip_buffer_size);
74+ }
6775
68- while(cbuffer == NULL)
69- {
70- zip_buffer_size -= (1 * 1024 * 1024);
71- cbuffer = malloc(zip_buffer_size);
72- }
73- }
74- else
76+ if(zip_buffer_size == 0)
7577 {
78+ use_vram = YES;
7679 zip_buffer_size = ZIP_BUFFER_SIZE;
7780 cbuffer = (u8 *)UNIVERSAL_VRAM_ADDR; // 汎用フレームバッファを使用
7881 }
@@ -207,7 +210,7 @@
207210 if(write_tmp_flag == YES)
208211 FILE_CLOSE(tmp_fd);
209212
210- if(psp_model == PSP_2000)
213+ if(use_vram == NO)
211214 free(cbuffer);
212215
213216 chdir(main_path);
--- trunk/gpsp-kai-test/src/gu.c (revision 422)
+++ trunk/gpsp-kai-test/src/gu.c (revision 423)
@@ -193,6 +193,7 @@
193193 gecb.finish_arg = NULL;
194194 gecbid = sceGeSetCallback(&gecb);
195195
196+ // TODO %指定調整
196197 memcpy(screen_vertex, &screen_parameter_psp_game_init, sizeof(float) * 20);
197198 // Set framebuffer to PSP VRAM
198199 GE_CMD(FBP, ((u32)psp_gu_vram_base & 0x00FFFFFF));
@@ -322,6 +323,7 @@
322323 }
323324 }
324325
326+ // TODO %指定調整
325327 memcpy(screen_vertex, &current_parameter->screen_setting_1, sizeof(float) * 20);
326328
327329 video_draw_frame = frame;
@@ -406,17 +408,17 @@
406408 }
407409 }
408410
409-#define video_savestate_body(type) \
410-{ \
411+#define video_savestate_body(type, ver) \
412+{ \
411413 FILE_##type##_ARRAY(g_state_buffer_ptr, affine_reference_x); \
412414 FILE_##type##_ARRAY(g_state_buffer_ptr, affine_reference_y); \
413-} \
415+} \
414416
415-void video_read_mem_savestate()
416-video_savestate_body(READ_MEM);
417+void video_read_mem_savestate(u32 ver)
418+video_savestate_body(READ_MEM, ver);
417419
418-void video_write_mem_savestate()
419-video_savestate_body(WRITE_MEM);
420+void video_write_mem_savestate(u32 ver)
421+video_savestate_body(WRITE_MEM, ver);
420422
421423 #define LOAD_PARAMETER_NUMBER (SCREEN_SCALE + 1 + (SCREEN_RATIO*SCREEN_INTERLACE*SCREEN_SCALE + SCREEN_RATIO*SCREEN_INTERLACE) * 2)
422424
--- trunk/gpsp-kai-test/src/gu.h (revision 422)
+++ trunk/gpsp-kai-test/src/gu.h (revision 423)
@@ -39,8 +39,9 @@
3939 void blit_to_screen(u16 *src, u32 w, u32 h, u32 x, u32 y);
4040 u16 *copy_screen();
4141 void flip_screen();
42-void video_read_mem_savestate();
43-void video_write_mem_savestate();
42+void video_read_mem_savestate(u32 ver);
43+void video_write_mem_savestate(u32 ver);
44+void video_get_size_savestate(u32 ver);
4445
4546 void debug_screen_clear();
4647 void debug_screen_start();
--- trunk/gpsp-kai-test/src/sound.c (revision 422)
+++ trunk/gpsp-kai-test/src/sound.c (revision 423)
@@ -254,22 +254,6 @@
254254 wave_bank[i2 + 1] = ((current_sample & 0x0F) - 8); \
255255 } \
256256
257-#define sound_savestate_body(type) \
258-{ \
259- FILE_##type##_VARIABLE(g_state_buffer_ptr, sound_on); \
260- FILE_##type##_VARIABLE(g_state_buffer_ptr, sound_read_offset); \
261- FILE_##type##_VARIABLE(g_state_buffer_ptr, sound_last_cpu_ticks); \
262- FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_buffer_index); \
263- FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_last_cpu_ticks); \
264- FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_partial_ticks); \
265- FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_master_volume_left); \
266- FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_master_volume_right); \
267- FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_master_volume); \
268- FILE_##type##_ARRAY(g_state_buffer_ptr, wave_samples); \
269- FILE_##type##_ARRAY(g_state_buffer_ptr, direct_sound_channel); \
270- FILE_##type##_ARRAY(g_state_buffer_ptr, gbc_sound_channel); \
271-} \
272-
273257 #define CHECK_BUFFER() \
274258 ((gbc_sound_buffer_index - sound_read_offset) % BUFFER_SIZE) \
275259
@@ -290,7 +274,7 @@
290274 ******************************************************************************/
291275 static u32 audio_buffer_size;
292276 static s16 sound_buffer[BUFFER_SIZE]; // サウンド バッファ 2n = Left / 2n+1 = Right
293-volatile static u32 sound_read_offset = 0; // サウンドバッファの読み込みオフセット
277+static u32 sound_read_offset = 0; // サウンドバッファの読み込みオフセット
294278 static SceUID sound_thread;
295279 static u32 sound_last_cpu_ticks = 0;
296280 static FIXED16_16 gbc_sound_tick_step;
@@ -446,7 +430,7 @@
446430 FIXED_DIV(14, 15, 14),
447431 FIXED_DIV(15, 15, 14) };
448432
449-volatile /*static*/ u32 gbc_sound_buffer_index = 0;
433+u32 gbc_sound_buffer_index = 0;
450434
451435 u32 gbc_sound_last_cpu_ticks = 0;
452436 u32 gbc_sound_partial_ticks = 0;
@@ -629,12 +613,28 @@
629613 audio_thread_exit_flag = 1;
630614 }
631615
632-void sound_read_mem_savestate()
633- sound_savestate_body(READ_MEM);
616+#define sound_savestate_body(type, ver) \
617+{ \
618+ FILE_##type##_VARIABLE(g_state_buffer_ptr, sound_on); \
619+ FILE_##type##_VARIABLE(g_state_buffer_ptr, sound_read_offset); \
620+ FILE_##type##_VARIABLE(g_state_buffer_ptr, sound_last_cpu_ticks); \
621+ FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_buffer_index); \
622+ FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_last_cpu_ticks); \
623+ FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_partial_ticks); \
624+ FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_master_volume_left); \
625+ FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_master_volume_right); \
626+ FILE_##type##_VARIABLE(g_state_buffer_ptr, gbc_sound_master_volume); \
627+ FILE_##type##_ARRAY(g_state_buffer_ptr, wave_samples); \
628+ FILE_##type##_ARRAY(g_state_buffer_ptr, direct_sound_channel); \
629+ FILE_##type##_ARRAY(g_state_buffer_ptr, gbc_sound_channel); \
630+} \
634631
635-void sound_write_mem_savestate()
636- sound_savestate_body(WRITE_MEM);
632+void sound_read_mem_savestate(u32 ver)
633+ sound_savestate_body(READ_MEM, ver);
637634
635+void sound_write_mem_savestate(u32 ver)
636+ sound_savestate_body(WRITE_MEM, ver);
637+
638638 /******************************************************************************
639639 * ローカル関数の定義
640640 ******************************************************************************/
--- trunk/gpsp-kai-test/src/cpu.h (revision 422)
+++ trunk/gpsp-kai-test/src/cpu.h (revision 423)
@@ -105,8 +105,9 @@
105105 void execute_arm(u32 cycles);
106106
107107 void init_translater();
108-void cpu_read_mem_savestate();
109-void cpu_write_mem_savestate();
108+void cpu_read_mem_savestate(u32 ver);
109+void cpu_write_mem_savestate(u32 ver);
110+void cpu_get_size_savestate(u32 ver);
110111
111112 void invalidate_all_cache();
112113 void invalidate_icache_region(u8* addr, u32 length);
--- trunk/gpsp-kai-test/src/sound.h (revision 422)
+++ trunk/gpsp-kai-test/src/sound.h (revision 423)
@@ -301,7 +301,7 @@
301301 extern u32 left_buffer;
302302 extern u32 gbc_sound_wave_volume[4];
303303
304-extern volatile u32 gbc_sound_buffer_index;
304+extern u32 gbc_sound_buffer_index;
305305
306306 void sound_timer_queue32(u8 channel);
307307 void sound_timer(FIXED16_16 frequency_step, u32 channel);
@@ -308,8 +308,10 @@
308308 void sound_reset_fifo(u32 channel);
309309 void update_gbc_sound(u32 cpu_ticks);
310310 void init_sound();
311-void sound_read_mem_savestate();
312-void sound_write_mem_savestate();
311+void sound_read_mem_savestate(u32 ver);
312+void sound_write_mem_savestate(u32 ver);
313+void sound_get_size_savestate(u32 ver);
314+
313315 void pause_sound(u32 flag);
314316 void reset_sound();
315317 void sound_exit();
--- trunk/gpsp-kai-test/src/input.c (revision 422)
+++ trunk/gpsp-kai-test/src/input.c (revision 423)
@@ -420,16 +420,16 @@
420420 }
421421
422422 // type = READ / WRITE_MEM
423-#define input_savestate_body(type) \
423+#define input_savestate_body(type, ver) \
424424 { \
425425 FILE_##type##_VARIABLE(g_state_buffer_ptr, key); \
426426 } \
427427
428-void input_read_mem_savestate()
429-input_savestate_body(READ_MEM);
428+void input_read_mem_savestate(u32 ver)
429+ input_savestate_body(READ_MEM, ver);
430430
431-void input_write_mem_savestate()
432-input_savestate_body(WRITE_MEM);
431+void input_write_mem_savestate(u32 ver)
432+ input_savestate_body(WRITE_MEM, ver);
433433
434434 // 以降OSK用のコード
435435 #ifdef OSK
--- trunk/gpsp-kai-test/src/input.h (revision 422)
+++ trunk/gpsp-kai-test/src/input.h (revision 423)
@@ -84,8 +84,9 @@
8484 u32 update_input();
8585 gui_action_type get_gui_input();
8686 gui_action_type get_gui_input_fs_hold(u32 button_id);
87-void input_read_mem_savestate();
88-void input_write_mem_savestate();
87+void input_read_mem_savestate(u32 ver);
88+void input_write_mem_savestate(u32 ver);
89+void input_get_size_savestate(u32 ver);
8990
9091 extern u32 tilt_sensor_x;
9192 extern u32 tilt_sensor_y;
--- trunk/gpsp-kai-test/src/memory.c (revision 422)
+++ trunk/gpsp-kai-test/src/memory.c (revision 423)
@@ -22,10 +22,16 @@
2222
2323 #define SAVESTATE_SIZE 506951
2424 #define SAVESTATE_SIZE_OLD 506947
25+
26+const char g_state_str[4] = "SVS";
27+const u32 g_state_ver = 0x00010000;
28+
2529 // TODO:PSP-1000はフレームバッファは256KBあれば足りるので、VRAMを使用する
26-u8 savestate_write_buffer[SAVESTATE_SIZE];
30+u8 savestate_write_buffer[512 * 1024];
2731 u8 *g_state_buffer_ptr;
32+u32 g_state_size;
2833
34+
2935 typedef enum
3036 {
3137 FLASH_DEVICE_MACRONIX_64KB = 0x1C,
@@ -46,8 +52,10 @@
4652
4753 // 関数宣言
4854
49-void memory_read_mem_savestate();
50-void memory_write_mem_savestate();
55+void memory_read_mem_savestate(u32 ver);
56+void memory_write_mem_savestate(u32 ver);
57+void memopy_get_size_savestate(u32 ver);
58+
5159 u8 read_backup(u32 address);
5260 void write_eeprom(u32 address, u32 value);
5361 u32 read_eeprom();
@@ -1862,10 +1870,6 @@
18621870 u32 update_address;
18631871 u8 *map;
18641872
1865- if((value & 0x04) == 0)
1866- {
1867- DBGOUT("PC %X : %X : %X\n",reg[REG_PC],address,value);
1868- }
18691873 value &= 0xFFFF;
18701874
18711875 switch(address)
@@ -2679,11 +2683,10 @@
26792683 FILE_CLOSE(bios_file);
26802684 // BIOSファイルのMD5を得る
26812685 sceKernelUtilsMd5Digest(bios_rom, 0x4000, md5);
2682- if (memcmp(md5,gba_md5,16) == 0)
2686+ if ((memcmp(md5,gba_md5,16) == 0) || (memcmp(md5,nds_md5,16) == 0))
26832687 return 0;
2684- if (memcmp(md5,nds_md5,16) == 0)
2685- return 0;
2686- return -2;
2688+ else
2689+ return -2;
26872690 }
26882691
26892692 return -1;
@@ -3605,22 +3608,82 @@
36053608 memory_map_read[0] = NULL;
36063609 }
36073610
3608-// TODO:savestate_fileは必要ないので削除する
3611+
36093612 // type = read_mem / write_mem
3610-#define savestate_block(type) \
3611- cpu_##type##_savestate(); \
3612- update_progress(); \
3613- input_##type##_savestate(); \
3614- update_progress(); \
3615- main_##type##_savestate(); \
3616- update_progress(); \
3617- memory_##type##_savestate(); \
3618- update_progress(); \
3619- sound_##type##_savestate(); \
3620- update_progress(); \
3621- video_##type##_savestate(); \
3622- update_progress(); \
3613+// ver = 0(old_format) / 1(3.4 test 1 format) / 0x00010000(new format)
3614+#define memory_savestate_body(type, ver) \
3615+{ \
3616+ u32 i; \
3617+ \
3618+ FILE_##type##_VARIABLE(g_state_buffer_ptr, backup_type); \
3619+ FILE_##type##_VARIABLE(g_state_buffer_ptr, sram_size); \
3620+ FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_mode); \
3621+ FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_command_position); \
3622+ FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_bank_ptr); \
3623+ FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_device_id); \
3624+ FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_manufacturer_id); \
3625+ FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_size); \
3626+ FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_size); \
3627+ FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_mode); \
3628+ FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_address_length); \
3629+ FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_address); \
3630+ FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_counter); \
3631+ FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_state); \
3632+ FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_write_mode); \
3633+ FILE_##type##_ARRAY(g_state_buffer_ptr, rtc_registers); \
3634+ FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_command); \
3635+ FILE_##type##_ARRAY(g_state_buffer_ptr, rtc_data); \
3636+ FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_status); \
3637+ FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_data_bytes); \
3638+ FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_bit_count); \
3639+ FILE_##type##_ARRAY(g_state_buffer_ptr, eeprom_buffer); \
3640+ FILE_##type##_ARRAY(g_state_buffer_ptr, gamepak_filename); \
3641+ if(ver == 0) \
3642+ g_state_buffer_ptr += 256; \
3643+ FILE_##type##_ARRAY(g_state_buffer_ptr, dma); \
3644+ \
3645+ FILE_##type(g_state_buffer_ptr, iwram + 0x8000, 0x8000); \
3646+ for(i = 0; i < 8; i++) \
3647+ { \
3648+ FILE_##type(g_state_buffer_ptr, ewram + (i * 0x10000) + 0x8000, 0x8000); \
3649+ } \
3650+ FILE_##type(g_state_buffer_ptr, vram, 0x18000); \
3651+ FILE_##type(g_state_buffer_ptr, oam_ram, 0x400); \
3652+ FILE_##type(g_state_buffer_ptr, palette_ram, 0x400); \
3653+ FILE_##type(g_state_buffer_ptr, io_registers, 0x8000); \
3654+ \
3655+ /* This is a hack, for now. */ \
3656+ if((flash_bank_ptr < gamepak_backup) || \
3657+ (flash_bank_ptr > (gamepak_backup + (1024 * 64)))) \
3658+ { \
3659+ flash_bank_ptr = gamepak_backup; \
3660+ } \
3661+} \
36233662
3663+void memory_read_mem_savestate(u32 ver)
3664+memory_savestate_body(READ_MEM, ver);
3665+
3666+void memory_write_mem_savestate(u32 ver)
3667+memory_savestate_body(WRITE_MEM, ver);
3668+
3669+void memory_get_size_savestate(u32 ver)
3670+memory_savestate_body(GET_SIZE, ver);
3671+
3672+// type = read_mem / write_mem
3673+#define savestate_block(type, ver) \
3674+ cpu_##type##_savestate(ver); \
3675+ update_progress(); \
3676+ input_##type##_savestate(ver); \
3677+ update_progress(); \
3678+ main_##type##_savestate(ver); \
3679+ update_progress(); \
3680+ memory_##type##_savestate(ver); \
3681+ update_progress(); \
3682+ sound_##type##_savestate(ver); \
3683+ update_progress(); \
3684+ video_##type##_savestate(ver); \
3685+ update_progress(); \
3686+
36243687 /*--------------------------------------------------------
36253688 ステートロード
36263689 input
@@ -3638,7 +3701,9 @@
36383701 u32 i;
36393702 u32 file_size = 0;
36403703 char buf[256];
3704+ u32 ver;
36413705
3706+ ver = 0x00010000;
36423707 pause_sound(1);
36433708
36443709 sprintf(buf,"Load State No.%d.", (int)slot_num);
@@ -3661,10 +3726,7 @@
36613726 if(FILE_CHECK_VALID(savestate_file))
36623727 {
36633728 file_size = file_length(savestate_path);
3664- if (file_size == SAVESTATE_SIZE)
3665- FILE_READ(savestate_file, savestate_write_buffer, sizeof(savestate_write_buffer));
3666- else
3667- FILE_READ(savestate_file, savestate_write_buffer, sizeof(savestate_write_buffer) - 4);
3729+ FILE_READ(savestate_file, savestate_write_buffer, file_size);
36683730 FILE_CLOSE(savestate_file);
36693731 }
36703732 else
@@ -3676,15 +3738,32 @@
36763738 else
36773739 return 0;
36783740
3679- if (file_size == SAVESTATE_SIZE)
3680- g_state_buffer_ptr = savestate_write_buffer + (240 * 160 * 2) + sizeof(u64);
3741+ g_state_buffer_ptr = savestate_write_buffer;
3742+
3743+ if(memcmp(g_state_buffer_ptr, g_state_str, 4) == 0)
3744+ {
3745+ g_state_buffer_ptr += 4;
3746+ FILE_READ_MEM_VARIABLE(g_state_buffer_ptr, ver);
3747+ }
36813748 else
3682- g_state_buffer_ptr = savestate_write_buffer + (240 * 160 * 2) + sizeof(u32);
3749+ {
3750+ // 旧バージョンチェック
3751+ ver = 0;
3752+ u32 lp = 255;
3753+ while(savestate_write_buffer[SAVESTATE_SIZE - lp] == 0)
3754+ {
3755+ lp--;
3756+ if(lp == 0) break;
3757+ }
3758+ if(lp == 0) ver = 1;
3759+ }
36833760
3761+ g_state_buffer_ptr += (240 * 160 * 2) + sizeof(u64);
3762+
36843763 strcpy(current_gamepak_filename, gamepak_filename);
36853764 update_progress();
36863765
3687- savestate_block(read_mem);
3766+ savestate_block(read_mem, ver);
36883767
36893768 update_progress();
36903769
@@ -3697,6 +3776,8 @@
36973776 gbc_sound_update = 1;
36983777 show_progress(msg[MSG_LOAD_STATE_END]);
36993778
3779+ mem_save_flag = 1;
3780+
37003781 // TODO:違うROMのstatesaveファイルを読み込むとフリーズする
37013782 if(strcmp(current_gamepak_filename, gamepak_filename))
37023783 {
@@ -3744,12 +3825,12 @@
37443825 u16 *screen_capture 画面のイメージ
37453826 u32 slot_num スロットNo. メモリロードの判別に使用
37463827 return
3747- 0 ロード失敗
3748- 1 ロード成功
3828+ 0 セーブ失敗
3829+ 1 セーブ成功
37493830 --------------------------------------------------------*/
37503831 u32 save_state(char *savestate_filename, u16 *screen_capture, u32 slot_num)
37513832 {
3752- char savestate_path[1024];
3833+ char savestate_path[MAX_PATH];
37533834 FILE_ID savestate_file;
37543835 char buf[256];
37553836
@@ -3773,15 +3854,22 @@
37733854 pspTime current_time_fix; // time関数が年月日を返さないので調整用
37743855 init_progress(9, msg[MSG_SAVE_STATE]);
37753856
3857+ // 識別子/バージョンの保存
3858+ FILE_WRITE_MEM_VARIABLE(g_state_buffer_ptr, g_state_str);
3859+ FILE_WRITE_MEM_VARIABLE(g_state_buffer_ptr, g_state_ver);
3860+
3861+ // スクリーンの保存
37763862 FILE_WRITE_MEM(g_state_buffer_ptr, screen_capture, 240 * 160 * 2);
37773863 update_progress();
37783864
37793865 sceRtcGetCurrentClock(&current_time_fix, 0);
37803866 sceRtcGetTick(&current_time_fix, &current_time);
3867+
3868+ // 時刻の保存
37813869 FILE_WRITE_MEM_VARIABLE(g_state_buffer_ptr, current_time);
37823870 update_progress();
37833871
3784- savestate_block(write_mem);
3872+ savestate_block(write_mem, 0x00010000);
37853873
37863874 // 実際のファイル書込
37873875 if (slot_num != MEM_STATE_NUM)
@@ -3804,59 +3892,6 @@
38043892 return 1;
38053893 }
38063894
3807-#define memory_savestate_body(type) \
3808-{ \
3809- u32 i; \
3810- \
3811- FILE_##type##_VARIABLE(g_state_buffer_ptr, backup_type); \
3812- FILE_##type##_VARIABLE(g_state_buffer_ptr, sram_size); \
3813- FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_mode); \
3814- FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_command_position); \
3815- FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_bank_ptr); \
3816- FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_device_id); \
3817- FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_manufacturer_id); \
3818- FILE_##type##_VARIABLE(g_state_buffer_ptr, flash_size); \
3819- FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_size); \
3820- FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_mode); \
3821- FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_address_length); \
3822- FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_address); \
3823- FILE_##type##_VARIABLE(g_state_buffer_ptr, eeprom_counter); \
3824- FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_state); \
3825- FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_write_mode); \
3826- FILE_##type##_ARRAY(g_state_buffer_ptr, rtc_registers); \
3827- FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_command); \
3828- FILE_##type##_ARRAY(g_state_buffer_ptr, rtc_data); \
3829- FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_status); \
3830- FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_data_bytes); \
3831- FILE_##type##_VARIABLE(g_state_buffer_ptr, rtc_bit_count); \
3832- FILE_##type##_ARRAY(g_state_buffer_ptr, eeprom_buffer); \
3833- FILE_##type##_ARRAY(g_state_buffer_ptr, gamepak_filename); \
3834- FILE_##type##_ARRAY(g_state_buffer_ptr, dma); \
3835- \
3836- FILE_##type(g_state_buffer_ptr, iwram + 0x8000, 0x8000); \
3837- for(i = 0; i < 8; i++) \
3838- { \
3839- FILE_##type(g_state_buffer_ptr, ewram + (i * 0x10000) + 0x8000, 0x8000); \
3840- } \
3841- FILE_##type(g_state_buffer_ptr, vram, 0x18000); \
3842- FILE_##type(g_state_buffer_ptr, oam_ram, 0x400); \
3843- FILE_##type(g_state_buffer_ptr, palette_ram, 0x400); \
3844- FILE_##type(g_state_buffer_ptr, io_registers, 0x8000); \
3845- \
3846- /* This is a hack, for now. */ \
3847- if((flash_bank_ptr < gamepak_backup) || \
3848- (flash_bank_ptr > (gamepak_backup + (1024 * 64)))) \
3849- { \
3850- flash_bank_ptr = gamepak_backup; \
3851- } \
3852-} \
3853-
3854-void memory_read_mem_savestate()
3855-memory_savestate_body(READ_MEM);
3856-
3857-void memory_write_mem_savestate()
3858-memory_savestate_body(WRITE_MEM);
3859-
38603895 u32 get_sio_mode(u16 io1, u16 io2)
38613896 {
38623897 if(!(io2 & 0x8000))
--- trunk/gpsp-kai-test/src/memory.h (revision 422)
+++ trunk/gpsp-kai-test/src/memory.h (revision 423)
@@ -161,8 +161,11 @@
161161 extern u32 gbc_sound_update;
162162 extern DMA_TRANSFER_TYPE dma[4];
163163
164+extern const char g_state_str[4];
165+extern const u32 g_state_ver;
164166 extern u8 savestate_write_buffer[];
165167 extern u8 *g_state_buffer_ptr;
168+extern u32 g_state_size;
166169
167170 //#define USE_VRAM
168171
--- trunk/gpsp-kai-test/src/fbm_print.c (revision 422)
+++ trunk/gpsp-kai-test/src/fbm_print.c (revision 423)
@@ -168,18 +168,20 @@
168168
169169 for (i = 0; i < len; i++)
170170 {
171- index = fbm_issubfont(ucs[i]);
171+ index = fbm_ismainfont(ucs[i]);
172172
173173 if (index >= 0)
174- font_num = 1;
174+ font_num = 0;
175175 else
176176 {
177- index = fbm_ismainfont(ucs[i]);
178- font_num = 0;
177+ index = fbm_issubfont(ucs[i]);
179178 if (index < 0)
180179 {
180+ font_num = 0;
181181 index = fbmControl[0].defaultchar;
182182 }
183+ else
184+ font_num = 1;
183185 }
184186 font = fbm_getfont(index, font_num);
185187 width += *(font->width);
@@ -223,16 +225,18 @@
223225 }
224226 else
225227 {
226- index = fbm_issubfont(ucs[i]);
227- issub = 1;
228+ index = fbm_ismainfont(ucs[i]);
229+ issub = 0;
228230 if (index < 0)
229231 {
230- index = fbm_ismainfont(ucs[i]);
231- issub = 0;
232+ index = fbm_issubfont(ucs[i]);
232233 if (index < 0)
233234 {
235+ issub = 0;
234236 index = fbmControl[0].defaultchar;
235237 }
238+ else
239+ issub = 1;
236240 }
237241 fbm_printSUB(vram, bufferwidth, index, issub, fbmControl[issub].height, fbmControl[issub].byteperchar / fbmControl[issub].height, color, back, fill);
238242 }
--- trunk/gpsp-kai-test/src/main.c (revision 422)
+++ trunk/gpsp-kai-test/src/main.c (revision 423)
@@ -868,7 +868,7 @@
868868 }
869869
870870 // type = READ / WRITE_MEM
871-#define MAIN_SAVESTATE_BODY(type) \
871+#define MAIN_SAVESTATE_BODY(type, ver) \
872872 { \
873873 FILE_##type##_VARIABLE(g_state_buffer_ptr, cpu_ticks); \
874874 FILE_##type##_VARIABLE(g_state_buffer_ptr, g_execute_cycles); \
@@ -876,11 +876,11 @@
876876 FILE_##type##_ARRAY(g_state_buffer_ptr, timer); \
877877 } \
878878
879-void main_read_mem_savestate()
880-MAIN_SAVESTATE_BODY(READ_MEM);
879+void main_read_mem_savestate(u32 ver)
880+MAIN_SAVESTATE_BODY(READ_MEM, ver);
881881
882-void main_write_mem_savestate()
883-MAIN_SAVESTATE_BODY(WRITE_MEM);
882+void main_write_mem_savestate(u32 ver)
883+MAIN_SAVESTATE_BODY(WRITE_MEM, ver);
884884
885885 void error_msg(char *text)
886886 {
--- trunk/gpsp-kai-test/src/gui.c (revision 422)
+++ trunk/gpsp-kai-test/src/gui.c (revision 423)
@@ -2016,15 +2016,16 @@
20162016 ******************************************************************************/
20172017 static void get_savestate_snapshot(char *savestate_filename, u32 slot_num)
20182018 {
2019- u16 snapshot_buffer[240 * 160];
2019+ static u16 snapshot_buffer[240 * 160];
20202020 char savestate_timestamp_string[80];
2021- char savestate_path[1024];
2021+ char savestate_path[MAX_PATH];
2022+ static char old_savestate_path[MAX_PATH];
20222023 FILE_ID savestate_file;
2023- u64 savestate_time_flat;
2024+ static u64 savestate_time_flat;
20242025 u64 local_time;
20252026 int wday;
20262027 pspTime current_time;
2027- u32 valid_flag = 0;
2028+ static u32 valid_flag;
20282029
20292030 if (g_default_save_dir != NULL) {
20302031 sprintf(savestate_path, "%s/%s", g_default_save_dir, savestate_filename);
@@ -2035,26 +2036,44 @@
20352036 }
20362037
20372038 if (slot_num != MEM_STATE_NUM)
2039+ {
2040+ if(strcmp(savestate_path, old_savestate_path) != 0)
20382041 {
20392042 FILE_OPEN(savestate_file, savestate_path, READ);
2043+ strcpy(old_savestate_path, savestate_path);
20402044 if(FILE_CHECK_VALID(savestate_file))
2041- {
2042- FILE_READ_ARRAY(savestate_file, snapshot_buffer);
2043- FILE_READ_VARIABLE(savestate_file, savestate_time_flat);
2044- FILE_CLOSE(savestate_file);
2045- valid_flag = 1;
2046- }
2045+ {
2046+ char str[4];
2047+ FILE_READ_ARRAY(savestate_file, str);
2048+ if(memcmp(str, g_state_str, 4) == 0)
2049+ FILE_SEEK(savestate_file, 8, SEEK_SET);
2050+ else
2051+ FILE_SEEK(savestate_file, 0, SEEK_SET);
2052+ FILE_READ_ARRAY(savestate_file, snapshot_buffer);
2053+ FILE_READ_VARIABLE(savestate_file, savestate_time_flat);
2054+ FILE_CLOSE(savestate_file);
2055+ valid_flag = 1;
2056+ }
2057+ else
2058+ valid_flag = 0;
20472059 }
2060+ }
20482061 else
2062+ {
2063+ if (mem_save_flag == 1)
20492064 {
2050- if (mem_save_flag == 1)
2051- {
2052- g_state_buffer_ptr = savestate_write_buffer;
2053- FILE_READ_MEM_ARRAY(g_state_buffer_ptr, snapshot_buffer);
2054- FILE_READ_MEM_VARIABLE(g_state_buffer_ptr, savestate_time_flat);
2055- valid_flag = 1;
2056- }
2065+ g_state_buffer_ptr = savestate_write_buffer;
2066+ if(memcmp(g_state_buffer_ptr, g_state_str, 4) == 0)
2067+ {
2068+ g_state_buffer_ptr += 8;
2069+ FILE_READ_MEM_ARRAY(g_state_buffer_ptr, snapshot_buffer);
2070+ FILE_READ_MEM_VARIABLE(g_state_buffer_ptr, savestate_time_flat);
2071+ valid_flag = 1;
2072+ }
20572073 }
2074+ else
2075+ valid_flag = 0;
2076+ }
20582077
20592078 if (valid_flag == 1)
20602079 {
--- trunk/gpsp-kai-test/src/cpu_asm.c (revision 422)
+++ trunk/gpsp-kai-test/src/cpu_asm.c (revision 423)
@@ -123,8 +123,8 @@
123123 #define arm_decode_data_proc_imm() \
124124 u32 rn = (opcode >> 16) & 0x0F; \
125125 u32 rd = (opcode >> 12) & 0x0F; \
126- u32 imm; DBGOUT("imm %d\n",opcode & 0xFF); \
127- ROR(imm, opcode & 0xFF, (opcode >> 7) & 0x1E); DBGOUT("ror %d\n",imm); \
126+ u32 imm; \
127+ ROR(imm, opcode & 0xFF, (opcode >> 7) & 0x1E) \
128128
129129 #define arm_decode_psr_reg() \
130130 u32 psr_field = (opcode >> 16) & 0x0F; \
@@ -3579,15 +3579,15 @@
35793579 reg_mode[MODE_SVC][5] = 0x03007FE0;
35803580 }
35813581
3582-#define cpu_savestate_body(type) \
3583-{ \
3584- FILE_##type(g_state_buffer_ptr,reg, 0x100); \
3585- FILE_##type##_ARRAY(g_state_buffer_ptr,spsr); \
3586- FILE_##type##_ARRAY(g_state_buffer_ptr,reg_mode); \
3587-} \
3582+#define cpu_savestate_body(type, ver) \
3583+{ \
3584+ FILE_##type(g_state_buffer_ptr, reg, 0x100); \
3585+ FILE_##type##_ARRAY(g_state_buffer_ptr, spsr); \
3586+ FILE_##type##_ARRAY(g_state_buffer_ptr, reg_mode); \
3587+} \
35883588
3589-void cpu_read_mem_savestate()
3590-cpu_savestate_body(READ_MEM);
3589+void cpu_read_mem_savestate(u32 ver)
3590+cpu_savestate_body(READ_MEM, ver);
35913591
3592-void cpu_write_mem_savestate()
3593-cpu_savestate_body(WRITE_MEM);
3592+void cpu_write_mem_savestate(u32 ver)
3593+cpu_savestate_body(WRITE_MEM, ver);
--- trunk/gpsp-kai-test/src/main.h (revision 422)
+++ trunk/gpsp-kai-test/src/main.h (revision 423)
@@ -186,8 +186,10 @@
186186 void synchronize();
187187 void quit(u32 mode);
188188 void game_name_ext(u8 *src, u8 *buffer, u8 *extension);
189-void main_read_mem_savestate();
190-void main_write_mem_savestate();
189+void main_read_mem_savestate(u32 ver);
190+void main_write_mem_savestate(u32 ver);
191+void main_get_size_savestate(u32 ver);
192+
191193 void error_msg(char *text);
192194 void set_cpu_mode(CPU_MODE_TYPE new_mode);
193195 void raise_interrupt(IRQ_TYPE irq_raised);
--- trunk/gpsp-kai-test/src/common.h (revision 422)
+++ trunk/gpsp-kai-test/src/common.h (revision 423)
@@ -120,8 +120,11 @@
120120 ptr += size; \
121121 } \
122122
123+#define FILE_GET_SIZE(ptr, buffer, size) \
124+ ptr += size \
125+
123126 #define FILE_SEEK(filename_tag, offset, type) \
124- sceIoLseek(filename_tag, offset, PSP_##type) \
127+ sceIoLseek(filename_tag, offset, type) \
125128
126129 // These must be variables, not constants.
127130
@@ -137,6 +140,9 @@
137140 #define FILE_WRITE_MEM_VARIABLE(ptr, variable) \
138141 FILE_WRITE_MEM(ptr, &variable, sizeof(variable)) \
139142
143+#define FILE_GET_SIZE_VARIABLE(ptr, variable) \
144+ ptr += sizeof(variable) \
145+
140146 // These must be statically declared arrays (ie, global or on the stack,
141147 // not dynamically allocated on the heap)
142148
@@ -152,6 +158,9 @@
152158 #define FILE_WRITE_MEM_ARRAY(ptr, array) \
153159 FILE_WRITE_MEM(ptr, array, sizeof(array)) \
154160
161+#define FILE_GET_SIZE_ARRAY(ptr, array) \
162+ ptr += sizeof(array) \
163+
155164 #define FLOAT_TO_FP16_16(value) \
156165 (FIXED16_16)((value) * 65536.0) \
157166
--- trunk/gpsp-kai-test/documents/insitall_jp.txt (revision 422)
+++ trunk/gpsp-kai-test/documents/insitall_jp.txt (revision 423)
@@ -4,9 +4,10 @@
44 インストール方法
55
66 動作に必要な環境
7- PSP-1000 CFW3.52 M33-4 以上
8- PSP-2000 CFW3.60 M33以上(ただし、TV出力/追加メモリを使用するにはCFW3.71が必須)
9- その他の環境(FW1.0/FW1.5など)では、動作しない可能性があります
7+ PSP-1000 CFW5.00 M33 以上
8+ PSP-2000 CFW5.00 M33 以上
9+ PSP-3000 CFW5.03 HEN 以上
10+ その他の環境では、動作しない可能性があります
1011
1112 新規インストール
1213 配布ファイルを解凍し、ms0の中にあるPSPを、フォルダごとメモリースティックにコピーする
@@ -15,7 +16,7 @@
1516 GBAのROMファイルを\PSP\GAME\gpSP\GBA\ROM\にコピーする
1617
1718 ネットワークインストール
18- PSPのブラウザから http://www.tfact.jp/psp/gpsp/ にアクセスし、アップデート3ヶ所と新規インストール1ヶ所のリンクからインストールする
19+ PSPのブラウザから http://www.tfact.net/psp/gpsp/ にアクセスし、アップデート3ヶ所と新規インストール1ヶ所のリンクからインストールする
1920 GBAのBIOSファイルをGBA_BIOS.BINにリネームし、メモリースティックの\PSP\GAME\gpSP\にコピーする
2021 GBAのROMファイルを\PSP\GAME\gpSP\GBA\ROM\にコピーする
2122
@@ -24,7 +25,7 @@
2425 そのほかのファイルが更新されているバージョンもあるので、添付のファイルやリリース時の説明を確認すること
2526
2627 ネットワークアップデート(ブラウザ利用)
27- PSPのブラウザから http://www.tfact.jp/psp/gpsp/ にアクセスし、アップデート3ヶ所のリンクからアップデートする
28+ PSPのブラウザから http://www.tfact.net/psp/gpsp/ にアクセスし、アップデート3ヶ所のリンクからアップデートする
2829
2930 ネットワークアップデート(ネットラジオ利用)
3031 事前にgpSP Update.prs(アルファ版はgpSP Update alpha.prs)を、\MS\PSP\RADIOPLAYER\にコピーしておき、
--- trunk/gpsp-kai-test/readme_kai_jp.html (revision 422)
+++ trunk/gpsp-kai-test/readme_kai_jp.html (revision 423)
@@ -11,7 +11,18 @@
1111 (現在修正中)ASMコアのthumb BLの修正(Cコアでは正常)
1212 (現在修正中)ERAMとIRAMのキャッシュを分離
1313 -->
14+-UnOfficial gpSP kai 3.4 test 3 build
15+ ZIP解凍時に1MBのメモリが確保できない場合、フリーズしてしまうのを修正
1416
17+-UnOfficial gpSP kai 3.4 test 2 build 69
18+ メインフォントとサブフォントの優先順位を調整(「ヲボタン問題」が直ったと思います)
19+ 配布ファイルにGBAフォルダが無くなっていたので修正
20+ 配布ファイルにms0/PSP/GAME/gpSPのフォルダを準備しないとインストール出来ない方もいるので修正
21+ ステートセーブデータに互換性が無くなっていたので、旧バージョンも読み込める様に修正
22+ ステートセーブデータ内にフォーマットバージョンを追加
23+ 旧ステートファイルの読込みを廃止(506947byteのファイル)
24+ ステートメニュー時のメモリースティック連続アクセスを修正
25+
1526 -UnOfficial gpSP kai 3.4 test 1 build 2
1627 ChickHEN R2に対応(PSP-2000で32MBのメモリ利用とZIPファイルのロードを確認)
1728 PSP-1000でZIPファイルを使用したときのバグを修正
Show on old repository browser