@@ -313,10 +313,11 @@ int _start(int ac, char **av)
313313 g_sio2man_data .m_inited = 1 ;
314314 g_sio2man_data .m_sdk13x_flag = 0 ;
315315 // Unofficial: remove unneeded thread priority argument handler
316- g_sio2man_data .m_mtap_change_slot_cb = 0 ;
317- g_sio2man_data .m_mtap_get_slot_max_cb = 0 ;
318- g_sio2man_data .m_mtap_get_slot_max2_cb = 0 ;
319- g_sio2man_data .m_mtap_update_slots_cb = 0 ;
316+ // Unofficial: use setters instead of setting variable directly
317+ sio2_mtap_change_slot_set (NULL );
318+ sio2_mtap_get_slot_max_set (NULL );
319+ sio2_mtap_get_slot_max2_set (NULL );
320+ sio2_mtap_update_slots_set (NULL );
320321 // Unofficial: inlined
321322 sio2_ctrl_set (0x3BC );
322323 CpuSuspendIntr (& state );
@@ -443,55 +444,72 @@ void sio2_transfer_reset(void)
443444#endif
444445}
445446
447+ static int sio2_mtap_change_slot_default (s32 * arg )
448+ {
449+ int sum ;
450+ int i ;
451+
452+ sum = 0 ;
453+ for ( i = 0 ; i < 4 ; i += 1 )
454+ {
455+ arg [i + 4 ] = ((arg [i ] + 1 ) < 2 );
456+ sum += arg [i + 4 ];
457+ }
458+ return sum == 4 ;
459+ }
460+
461+ static int sio2_mtap_get_slot_max_default (int port )
462+ {
463+ return 1 ;
464+ }
465+
466+ static void sio2_mtap_update_slots_default (void ) {}
467+
446468void sio2_mtap_change_slot_set (sio2_mtap_change_slot_cb_t cb )
447469{
448- g_sio2man_data .m_mtap_change_slot_cb = cb ;
470+ // Unofficial: use default callback if NULL
471+ g_sio2man_data .m_mtap_change_slot_cb = cb ? cb : sio2_mtap_change_slot_default ;
449472}
450473
451474void sio2_mtap_get_slot_max_set (sio2_mtap_get_slot_max_cb_t cb )
452475{
453- g_sio2man_data .m_mtap_get_slot_max_cb = cb ;
476+ // Unofficial: use default callback if NULL
477+ g_sio2man_data .m_mtap_get_slot_max_cb = cb ? cb : sio2_mtap_get_slot_max_default ;
454478}
455479
456480void sio2_mtap_get_slot_max2_set (sio2_mtap_get_slot_max2_cb_t cb )
457481{
458- g_sio2man_data .m_mtap_get_slot_max2_cb = cb ;
482+ // Unofficial: use default callback if NULL
483+ g_sio2man_data .m_mtap_get_slot_max2_cb = cb ? cb : sio2_mtap_get_slot_max_default ;
459484}
460485
461486void sio2_mtap_update_slots_set (sio2_mtap_update_slots_t cb )
462487{
463- g_sio2man_data .m_mtap_update_slots_cb = cb ;
488+ // Unofficial: use default callback if NULL
489+ g_sio2man_data .m_mtap_update_slots_cb = cb ? cb : sio2_mtap_update_slots_default ;
464490}
465491
466492int sio2_mtap_change_slot (s32 * arg )
467493{
468- int sum ;
469- int i ;
470-
471494 g_sio2man_data .m_sdk13x_flag = 0 ;
472- if ( g_sio2man_data .m_mtap_change_slot_cb )
473- return g_sio2man_data .m_mtap_change_slot_cb (arg );
474- sum = 0 ;
475- for ( i = 0 ; i < 4 ; i += 1 )
476- {
477- arg [i + 4 ] = ((arg [i ] + 1 ) < 2 );
478- sum += arg [i + 4 ];
479- }
480- return sum == 4 ;
495+ // Unofficial: unconditionally call callback
496+ return g_sio2man_data .m_mtap_change_slot_cb (arg );
481497}
482498
483499int sio2_mtap_get_slot_max (int port )
484500{
485- return g_sio2man_data .m_mtap_get_slot_max_cb ? g_sio2man_data .m_mtap_get_slot_max_cb (port ) : 1 ;
501+ // Unofficial: unconditionally call callback
502+ return g_sio2man_data .m_mtap_get_slot_max_cb (port );
486503}
487504
488505int sio2_mtap_get_slot_max2 (int port )
489506{
490- return g_sio2man_data .m_mtap_get_slot_max2_cb ? g_sio2man_data .m_mtap_get_slot_max2_cb (port ) : 1 ;
507+ // Unofficial: unconditionally call callback
508+ return g_sio2man_data .m_mtap_get_slot_max2_cb (port );
491509}
492510
493511void sio2_mtap_update_slots (void )
494512{
495- if ( g_sio2man_data . m_mtap_update_slots_cb )
496- g_sio2man_data .m_mtap_update_slots_cb ();
513+ // Unofficial: unconditionally call callback
514+ g_sio2man_data .m_mtap_update_slots_cb ();
497515}
0 commit comments