@@ -40,7 +40,8 @@ struct sio2man_internal_data
40
40
int m_intr_sema ;
41
41
int m_transfer_semaphore ;
42
42
// Unofficial: backwards compatibility for libraries using 1.3 SDK
43
- int m_sdk13x_flag ;
43
+ int m_sdk13x_curflag ;
44
+ int m_sdk13x_totalflag ;
44
45
sio2_mtap_change_slot_cb_t m_mtap_change_slot_cb ;
45
46
sio2_mtap_get_slot_max_cb_t m_mtap_get_slot_max_cb ;
46
47
sio2_mtap_get_slot_max2_cb_t m_mtap_get_slot_max2_cb ;
@@ -311,12 +312,14 @@ int _start(int ac, char **av)
311
312
if ( g_sio2man_data .m_inited )
312
313
return 1 ;
313
314
g_sio2man_data .m_inited = 1 ;
314
- g_sio2man_data .m_sdk13x_flag = 0 ;
315
+ g_sio2man_data .m_sdk13x_curflag = 0 ;
316
+ g_sio2man_data .m_sdk13x_totalflag = 3 ;
315
317
// 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 ;
318
+ // Unofficial: use setters instead of setting variable directly
319
+ sio2_mtap_change_slot_set (NULL );
320
+ sio2_mtap_get_slot_max_set (NULL );
321
+ sio2_mtap_get_slot_max2_set (NULL );
322
+ sio2_mtap_update_slots_set (NULL );
320
323
// Unofficial: inlined
321
324
sio2_ctrl_set (0x3BC );
322
325
CpuSuspendIntr (& state );
@@ -408,7 +411,7 @@ int sio2_transfer(sio2_transfer_data_t *td)
408
411
sio2_set_ctrl_1 ();
409
412
sio2_wait_for_intr ();
410
413
recv_td (td );
411
- if ( g_sio2man_data .m_sdk13x_flag )
414
+ if ( g_sio2man_data .m_sdk13x_curflag )
412
415
sio2_transfer_reset ();
413
416
#ifdef SIO2LOG
414
417
log_flush (0 );
@@ -425,73 +428,96 @@ void sio2_pad_transfer_init(void)
425
428
#ifdef SIO2LOG
426
429
log_default (LOG_PAD_READY );
427
430
#endif
428
- g_sio2man_data .m_sdk13x_flag = 0 ;
431
+ g_sio2man_data .m_sdk13x_curflag = 0 ;
429
432
}
430
433
431
434
void sio2_pad_transfer_init_possiblysdk13x (void )
432
435
{
433
436
sio2_pad_transfer_init ();
434
- g_sio2man_data .m_sdk13x_flag = 1 ;
437
+ g_sio2man_data .m_sdk13x_curflag |= g_sio2man_data .m_sdk13x_totalflag & 1 ;
438
+ }
439
+
440
+ void sio2_mc_transfer_init_possiblysdk13x (void )
441
+ {
442
+ sio2_pad_transfer_init ();
443
+ g_sio2man_data .m_sdk13x_curflag |= g_sio2man_data .m_sdk13x_totalflag & 2 ;
435
444
}
436
445
437
446
void sio2_transfer_reset (void )
438
447
{
439
- g_sio2man_data .m_sdk13x_flag = 0 ;
448
+ g_sio2man_data .m_sdk13x_curflag = 0 ;
440
449
SignalSema (g_sio2man_data .m_transfer_semaphore );
441
450
#ifdef SIO2LOG
442
451
log_default (LOG_RESET );
443
452
#endif
444
453
}
445
454
455
+ static int sio2_mtap_change_slot_default (s32 * arg )
456
+ {
457
+ int sum ;
458
+ int i ;
459
+
460
+ sum = 0 ;
461
+ for ( i = 0 ; i < 4 ; i += 1 )
462
+ {
463
+ arg [i + 4 ] = ((arg [i ] + 1 ) < 2 );
464
+ sum += arg [i + 4 ];
465
+ }
466
+ return sum == 4 ;
467
+ }
468
+
469
+ static int sio2_mtap_get_slot_max_default (int port )
470
+ {
471
+ return 1 ;
472
+ }
473
+
474
+ static void sio2_mtap_update_slots_default (void ) {}
475
+
446
476
void sio2_mtap_change_slot_set (sio2_mtap_change_slot_cb_t cb )
447
477
{
448
- g_sio2man_data .m_mtap_change_slot_cb = cb ;
478
+ // Unofficial: use default callback if NULL
479
+ g_sio2man_data .m_mtap_change_slot_cb = cb ? cb : sio2_mtap_change_slot_default ;
449
480
}
450
481
451
482
void sio2_mtap_get_slot_max_set (sio2_mtap_get_slot_max_cb_t cb )
452
483
{
453
- g_sio2man_data .m_mtap_get_slot_max_cb = cb ;
484
+ // Unofficial: use default callback if NULL
485
+ g_sio2man_data .m_mtap_get_slot_max_cb = cb ? cb : sio2_mtap_get_slot_max_default ;
454
486
}
455
487
456
488
void sio2_mtap_get_slot_max2_set (sio2_mtap_get_slot_max2_cb_t cb )
457
489
{
458
- g_sio2man_data .m_mtap_get_slot_max2_cb = cb ;
490
+ // Unofficial: use default callback if NULL
491
+ g_sio2man_data .m_mtap_get_slot_max2_cb = cb ? cb : sio2_mtap_get_slot_max_default ;
459
492
}
460
493
461
494
void sio2_mtap_update_slots_set (sio2_mtap_update_slots_t cb )
462
495
{
463
- g_sio2man_data .m_mtap_update_slots_cb = cb ;
496
+ // Unofficial: use default callback if NULL
497
+ g_sio2man_data .m_mtap_update_slots_cb = cb ? cb : sio2_mtap_update_slots_default ;
464
498
}
465
499
466
500
int sio2_mtap_change_slot (s32 * arg )
467
501
{
468
- int sum ;
469
- int i ;
470
-
471
- 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 ;
502
+ g_sio2man_data .m_sdk13x_totalflag &= ~g_sio2man_data .m_sdk13x_curflag ;
503
+ // Unofficial: unconditionally call callback
504
+ return g_sio2man_data .m_mtap_change_slot_cb (arg );
481
505
}
482
506
483
507
int sio2_mtap_get_slot_max (int port )
484
508
{
485
- return g_sio2man_data .m_mtap_get_slot_max_cb ? g_sio2man_data .m_mtap_get_slot_max_cb (port ) : 1 ;
509
+ // Unofficial: unconditionally call callback
510
+ return g_sio2man_data .m_mtap_get_slot_max_cb (port );
486
511
}
487
512
488
513
int sio2_mtap_get_slot_max2 (int port )
489
514
{
490
- return g_sio2man_data .m_mtap_get_slot_max2_cb ? g_sio2man_data .m_mtap_get_slot_max2_cb (port ) : 1 ;
515
+ // Unofficial: unconditionally call callback
516
+ return g_sio2man_data .m_mtap_get_slot_max2_cb (port );
491
517
}
492
518
493
519
void sio2_mtap_update_slots (void )
494
520
{
495
- if ( g_sio2man_data . m_mtap_update_slots_cb )
496
- g_sio2man_data .m_mtap_update_slots_cb ();
521
+ // Unofficial: unconditionally call callback
522
+ g_sio2man_data .m_mtap_update_slots_cb ();
497
523
}
0 commit comments