Advertisement
LuigiBlood

N64 SDK test - 64DD

Dec 24th, 2014
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.50 KB | None | 0 0
  1. /*---------------------------------------------------------------------*
  2.         Copyright (C) 1998 Nintendo. (Originated by SGI)
  3.        
  4.         $RCSfile: main.c,v $
  5.         $Revision: 1.15 $
  6.         $Date: 1999/01/19 03:25:20 $
  7.  *---------------------------------------------------------------------*/
  8. #include    <ultra64.h>
  9. #include    <PR/leo.h>
  10. #include    "thread.h"
  11. #include    "textlib.h"
  12. #include    "ncode.h"
  13.  
  14. #define NUM_MESSAGE     1
  15.  
  16. #define NUM_OF_FILE 16
  17.  
  18. #define CONT_VALID  1
  19. #define CONT_INVALID    0
  20.  
  21. #define WAIT_CNT    5
  22.  
  23. #define LABEL1      "Nintendo64 CONTROLLER PAK       "
  24.  
  25. extern OSMesgQueue retraceMessageQ;
  26.  
  27. extern u16      *bitmap_buf;
  28. extern u16      bitmap_buf1[];
  29. extern u16      bitmap_buf2[];
  30. extern u8   backup_buffer[];
  31.  
  32. OSMesgQueue         pifMesgQueue;
  33. OSMesg              dummyMessage;
  34. OSMesg              pifMesgBuf[NUM_MESSAGE];
  35.  
  36. static OSContStatus     contstat[MAXCONTROLLERS];
  37. static OSContPad        contdata[MAXCONTROLLERS];
  38. static int      controller[MAXCONTROLLERS];
  39. OSPfs           pfs0;
  40.  
  41. //64DD
  42. #define DISK_MSG_NUM 1
  43. #define NUM_LEO_MESGS 8
  44. static OSMesg           LeoMessages[NUM_LEO_MESGS];
  45.  
  46. OSMesgQueue diskMsgQ;
  47. OSMesg  diskMsgBuf[DISK_MSG_NUM];
  48.  
  49. LEODiskID       _diskID ,_savedID;
  50. static LEODiskTime      _rtc;
  51. static LEOCmd           _cmdBlk;
  52.  
  53.  
  54. void   
  55. mainproc(void *arg)
  56. {  
  57.   int   i, j;
  58.   int   cont_no = 0;
  59.   s32   no;
  60.   u16   number;
  61.   u32   total_size;
  62.   int   error;
  63.   char  *s;
  64.   u32   data_no = 0;
  65.   int   cursor = 0;
  66.   u32   ret;
  67.   u8    bitpattern;
  68.   u16   button = 0, oldbutton = 0, newbutton = 0;
  69.   u8    label[BLOCKSIZE];
  70.   u8    extbuf[__Z - __A];
  71.   int   waitcnt = WAIT_CNT;
  72.   int   len = BLOCKSIZE;
  73.  
  74.   osCreateMesgQueue(&pifMesgQueue, pifMesgBuf, NUM_MESSAGE);
  75.   osSetEventMesg(OS_EVENT_SI, &pifMesgQueue, dummyMessage);
  76.  
  77.   osContInit(&pifMesgQueue, &bitpattern, &contstat[0]);
  78.   for (i = 0; i < MAXCONTROLLERS; i++) {
  79.     if ((bitpattern & (1<<i)) &&
  80.        ((contstat[i].type & CONT_TYPE_MASK) == CONT_TYPE_NORMAL)) {
  81.       controller[i] = CONT_VALID;
  82.     } else {
  83.       controller[i] = CONT_INVALID;
  84.     }
  85.   }
  86.  
  87.   osCreateMesgQueue(&diskMsgQ, diskMsgBuf, DISK_MSG_NUM);
  88.  
  89.  
  90.   init_draw();
  91.  
  92.   setcolor(0,255,0);
  93.   draw_puts("RTC Test\n64DD !!!\n");
  94.  
  95.   LeoCJCreateLeoManager((OSPri)OS_PRIORITY_LEOMGR-1, (OSPri)OS_PRIORITY_LEOMGR, LeoMessages, NUM_LEO_MESGS);
  96.   draw_puts("YESSS !!!\n");
  97.  
  98.   while(1) {
  99.     osContStartReadData(&pifMesgQueue);
  100.     osRecvMesg(&pifMesgQueue, NULL, OS_MESG_BLOCK);
  101.     osContGetReadData(&contdata[0]);
  102.     if (contdata[cont_no].errno & CONT_NO_RESPONSE_ERROR) {
  103.       button = oldbutton;
  104.     } else {
  105.       oldbutton = button;
  106.       button = contdata[cont_no].button;
  107.     }
  108.     newbutton = ~oldbutton & button;
  109.    
  110.     clear_draw();
  111.     setcolor(0,255,0);
  112.     draw_puts("RTC Test\n");
  113.     setcolor(255,255,255);
  114.  
  115.     LeoReadRTC(&_cmdBlk, &diskMsgQ);
  116.     osRecvMesg(&diskMsgQ, (OSMesg *)&error, OS_MESG_BLOCK);
  117.  
  118.     switch (error)
  119.     {
  120.         case LEO_ERROR_GOOD:
  121.             bcopy( &_cmdBlk.data.time, &_rtc, sizeof(LEODiskTime));
  122.  
  123.             draw_char(_rtc.month);
  124.             draw_puts("/");
  125.             draw_char(_rtc.day);
  126.             draw_puts("/");
  127.             draw_char(_rtc.yearlo);
  128.             draw_puts(" - ");
  129.             draw_char(_rtc.hour);
  130.             draw_puts(":");
  131.             draw_char(_rtc.minute);
  132.             draw_puts(":");
  133.             draw_char(_rtc.second);
  134.             draw_puts("\n");
  135.             break;
  136.         case LEO_ERROR_REAL_TIME_CLOCK_FAILURE:
  137.             draw_puts("ERROR\n");
  138.             break;
  139.     }
  140.  
  141.  
  142.     draw_puts(CR25);
  143.  
  144.     /*
  145.     draw_puts("\n\n     TEST!");
  146.     draw_puts(CR25);
  147.     */
  148.   }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement