sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

pfsgetstatus.c (827B)


      1 #include "libultra_internal.h"
      2 #include "controller.h"
      3 
      4 s32 __osPfsGetStatus(OSMesgQueue *queue, s32 channel) {
      5     s32 ret = 0;
      6     OSMesg dummy;
      7     u8 pattern;
      8     OSContStatus data[4];
      9 
     10     __osPfsRequestData(CONT_CMD_REQUEST_STATUS);
     11     ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
     12     osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
     13     ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
     14     osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
     15     __osPfsGetInitData(&pattern, data);
     16     if (data[channel].status & CONT_CARD_ON && data[channel].status & CONT_CARD_PULL) {
     17         return PFS_ERR_NEW_PACK;
     18     }
     19     if (data[channel].errnum || !(data[channel].status & CONT_CARD_ON)) {
     20         return PFS_ERR_NOPACK;
     21     }
     22     if (data[channel].status & CONT_ADDR_CRC_ER) {
     23         return PFS_ERR_CONTRFAIL;
     24     }
     25     return ret;
     26 }