Commits

Anonymous committed 5861459

Task dispatch and main gui task override works

Comments (0)

Files changed (5)

 
 
 /** These are called when new tasks are created */
-void task_create_hook( uint32_t * p );
-void task_dispatch_hook( struct context ** );
+void my_task_dispatch_hook( struct context ** );
 void my_init_task(void);
 void my_bzero( uint8_t * base, uint32_t size );
 
 	* install our own handlers.
 	*/
 
+	// Install our task creation hooks
+	task_dispatch_hook = my_task_dispatch_hook;
+
 #if 0
-	// Install our task creation hooks
 	*(uint32_t*) 0x1934 = (uint32_t) task_dispatch_hook;
 	*(uint32_t*) 0x1938 = (uint32_t) task_dispatch_hook;
 
 }
 
 
-#if 0
-void
-task_create_hook(
-	uint32_t * p
-)
-{
-	while(1)
-		;
-}
-
-
-void
-null_task( void )
-{
-}
-
-void
-spin_task( void )
-{
-	while(1)
-		;
-}
-
-
-
-void dump_vram( void )
-{
-	int i;
-	uint32_t vram_num[8];
-	for( i=0 ; i<8 ; i++ )
-		vram_num[i] = vram_get_number(i);
-
-	write_debug_file( "vram_bss.log", vram_info, sizeof(vram_info) );
-	write_debug_file( "vram_num.log", vram_num, sizeof(vram_num) );
-	write_debug_file( "bmp_vram.log", &bmp_vram_info, 0x100 );
-
-#if 0
-
-	uint32_t * const vram_config_ptr = (void*) 0x2580;
-	uint32_t width = vram_config_ptr[ 0x28 / 4 ];
-
-	uint32_t * const bmp_vram_ptr = (void*) 0x240cc;
-	uint8_t * const bmp_vram = (void*) bmp_vram_ptr[ 2 ];
-
-	if( !bmp_vram )
-		return;
-
-	static int __attribute__((section(".text"))) done;
-	if( !done )
-		dispcheck();
-	done = 1;
-
-	// BMP vram has 960 bytes per line
-	uint32_t i;
-	for( i=0 ; i<480 ; i++ )
-	{
-		uint8_t * row = bmp_vram + (i*960);
-		uint32_t j;
-		
-		for( j=0 ; j<width ; j += 2 )
-			row[j] = 0xFF;
-	}
-#endif
-}
-
-
-#if 0
-/** Attempt to start my own main menu dialog
- * This replaces StartMnMainTabHeaderApp at 0xffba0bd4
- */
-int
-my_tab_header_app( void )
-{
-	// 0x0001F848 main_tab_struct
-	// 0xFFBA0820 StopMnMainTabHeaderApp
-	if( main_tab_dialog_id )
-		StopMnMainTabHeaderApp();
-	StartMnMainRec1App();
-	StartMnMainRec2App();
-	StartMnMainPlay1App();
-	StartMnMainPlay2App();
-	StartMnMainSetup1App();
-	StartMnMainSetup2App();
-	StartMnMainSetup3App();
-	StartMnMainCustomFuncApp();
-	//StartMnMainMyMenuApp();
-
-	main_tab_dialog_id = dialog_create(
-		0,
-		0,
-		main_tab_header_dialog,
-		(void*) 158,
-		0
-	);
-
-	if( main_tab_dialog_id != 1 )
-	{
-		DebugMsg( 0x83, "**** %s CreateDialog failed!\n", __func__ );
-		return main_tab_dialog_id;
-	}
-
-	color_palette_push( 2 );
-
-	thunk main_tab_bitmaps_maybe = (void*) 0xFFBA0C7C;
-	main_tab_bitmaps_maybe();
-	dialog_draw( main_tab_dialog_id );
-
-	return 0;
-}
-#endif
-
-
-
-
-static const char pc_buf_raw[4*1024] TEXT;
-
-
-
-
-
-
-
-
-static inline void
-my_memcpy(
-	void * dest_v,
-	const void * src_v,
-	uint32_t len
-)
-{
-	uint32_t * dest = dest_v;
-	const uint32_t * src = src_v;
-	while( len -= 4 )
-		*dest++ = *src++;
-}
-
-
 
 
 /**
  * a new task.
  */
 void
-task_dispatch_hook(
+my_task_dispatch_hook(
 	struct context **	context
 )
 {
-	static const char __attribute__((section(".text"))) count_buf[4];
-	uint32_t * count_ptr = (uint32_t*) count_buf;
-	uint32_t count = *count_ptr;
-
 	if( !context )
 		return;
 
 #endif
 	if( task->entry == gui_main_task )
 		task->entry = my_gui_main_task;
-
-
-#if 1
-	*(uint32_t*)(pc_buf_raw+count+0) = (uint32_t) task->entry;
-	//*(uint32_t*)(pc_buf_raw+count+4) = (uint32_t) task->context->pc;
-	*count_ptr = (count + 16 ) & (sizeof(pc_buf_raw)-1);
-
-#else
-	//*(uint32_t*)(pc_buf_raw+count+0) = task ? (*task)->pc : 0xdeadbeef;
-	//*(uint32_t*)(pc_buf_raw+count+4) = lr;
-	my_memcpy( pc_buf_raw + count, task, sizeof(struct task) );
-	*(uint32_t*)(pc_buf_raw+count+0) = (uint32_t) task;
-	*(uint32_t*)(pc_buf_raw+count+4) = (uint32_t) context;
-	*(uint32_t*)(pc_buf_raw+count+8) = (uint32_t) (*context)->pc;
-	*count_ptr = (count + sizeof(struct task) ) & (sizeof(pc_buf_raw)-1);
-#endif
 }
-#endif
 
 
 /** First task after a fresh rebuild.
 
 NOT_YET=\
 	audio.o \
-	gui.o \
 	bmp.o \
 	font.o \
 	stubs-5d2.107.o \
 5d-hack: \
 	entry.o \
 	5d-hack.o \
+	gui.o \
 	stubs-5d2.110.o \
 
 	$(LD) \
 );
 
 
+/** Hook to override task dispatch */
+void (*task_dispatch_hook)(
+	struct context **	context
+);
+
+
 struct semaphore;
 
 extern struct semaphore *
 			&&  event->param != 0x27
 			&&  event->param != 0x28
 			&&  event->param != 0x29
+			&&  event->param != 0x2A
 			&&  event->param != 0x1F
-			&&  event->param != 0x2A
 			&&  event->param != 0x2B
 			&&  event->param != 0x23
 			&&  event->param != 0x2C
  */
 NSTUB( 0xFF869D48, task_create )
 
+/** Verify that 0x1934 is the task dispatch hook by
+ * looking for the dispatch call.  Follow task_create
+ * to find it.
+ */
+NSTUB( 0x1934, task_dispatch_hook )
+
+/** The task trampoline is after create_task. */
+NSTUB( 0xFF8729C8, task_trampoline )
+
+
+/** These data structures are required for the gui_main_task
+ * override.  Once gui_main_task has been located, walk
+ * through it to find all of the other functions and structures.
+ * @{
+ */
+NSTUB( 0x1C4C, gui_main_struct )
+NSTUB( 0x3668, gui_timer_struct )
+NSTUB( 0xFF823698, gui_main_task )
+NSTUB( 0xFF824048, gui_init_end )
+NSTUB( 0xFF8693EC, msg_queue_receive )
+NSTUB( 0xFF88B730, gui_massive_event_loop )
+NSTUB( 0xFF88D148, gui_local_post )
+NSTUB( 0xFF994CE8, gui_timer_something )
+NSTUB( 0xFF88CCA4, gui_change_mode )
+NSTUB( 0xFF88D534, gui_other_post )
+NSTUB( 0xFF88D658, gui_post_10000085 )
+NSTUB( 0xFF88DD94, gui_init_event )
+NSTUB( 0xFF88D810, gui_change_shoot_type_post )
+NSTUB( 0xFF88D8A8, gui_change_lcd_state_post )
+/** @} */
 
 #if 0
 NSTUB( 0xFF810674, DryosPanic )
 NSTUB( 0xFF9AF5D8, copy_lvram_info )
 NSTUB( 0xFF88A8D8, gui_get_display_type )
 NSTUB( 0xFFA537B4, gui_task_create )
-NSTUB( 0xFF823698, gui_main_task )
-NSTUB( 0xFF824048, gui_init_end )
-NSTUB( 0xFF8693F0, msg_queue_receive )
 NSTUB( 0xFF88B734, gui_massive_event_loop )
-NSTUB( 0xFF88D14C, gui_local_post )
-NSTUB( 0xFF88D538, gui_other_post )
-NSTUB( 0xFF994B60, gui_timer_something )
-NSTUB( 0xFF88CCA8, gui_change_mode )
-NSTUB( 0xFF88D65C, gui_post_10000085 )
-NSTUB( 0xFF88DD98, gui_init_event )
-NSTUB( 0xFF88D814, gui_change_shoot_type_post )
-NSTUB( 0xFF88D8AC, gui_change_lcd_state_post )
 
 
 NSTUB( 0xFFA6CF4C, winsys_whole_screen_backup )
 
 
 /* Structures in the BSS or rwdata segment */
-NSTUB( 0x1C4C, gui_main_struct )
 NSTUB( 0x1D74, liveview )
 NSTUB( 0x208C, sound_dev )
 NSTUB( 0x2580, hdmi_config )
 NSTUB( 0x2924, dm_state_ptr )
 NSTUB( 0x3548, gui_struct )
-NSTUB( 0x3668, gui_timer_struct )
 NSTUB( 0x426C, lv_struct )
 NSTUB( 0x7324, audio_info )
 NSTUB( 0x8348, dm_state_object )