mysched.h 2.89 KB
/*
 *  NINTENDO64 SAMPLE PROGRAM
 *
 *  FILE : mysched.h
 *
 *  Copyright (C) 1997, NINTENDO Co,Ltd.
 */


/*
 *  $B%9%1%8%e!<%i%9%l%C%I%9%?%C%/%5%$%:(B
 */
#define MY_SC_STACKSIZE    0x2000


/*
 *  $B%a%C%;!<%8(B
 */
#define  MY_SC_RETRACE_MSG  1  /* $B%j%H%l!<%9%a%C%;!<%8(B           */
#define  MY_SC_PRE_NMI_MSG  3  /* $B#N#M#I%a%C%;!<%8(B               */
#define  MY_SC_MAX_MESGS    8  /* $B%a%C%;!<%8%P%C%U%!$N%5%$%:(B     */


/*
 *  $B%9%l%C%I$N%W%i%$%*%j%F%#$NDj5A(B
 */
#define  MY_SC_PRI           120  /* $B%9%1%8%e!<%i(B */
#define  MY_SC_AUDIO_PRI     100  /* $B%*!<%G%#%*(B */
#define  MY_SC_GRAPHICS_PRI  110  /* $B%0%i%U%#%C%/%9(B */


/*
 *  $B%$%Y%s%H%a%C%;!<%8$NDj5A(B
 */
#define  VIDEO_MSG     666  /* $B%j%H%l!<%9(B */
#define  RSP_DONE_MSG  667  /* RSP $B=*N;(B   */
#define  RDP_DONE_MSG  668  /* RDP $B=*N;(B   */
#define  PRE_NMI_MSG   669  /* NMI        */


/*
 *  $B%9%1%8%e!<%i%a%C%;!<%8%?%$%W(B
 */
typedef  short  MYScMsg;


/*
 *  $B%?%9%/9=B$BN(B
 */
typedef  struct  SCTask_s {
    void		*framebuffer;
    OSTask              list;
} MYScTask;


/*
 *  $B%/%i%$%"%s%H%j%9%H9=B$BN(B
 */
typedef  struct  SCClient_s {

  /* $B<!$N%/%i%$%"%s%H$X$N%]%$%s%?(B */
  struct SCClient_s   *next;

  /* $B%/%i%$%"%s%H$KAw?.$9$k%a%C%;!<%8(B */
  OSMesgQueue         *msgQ;

} MYScClient;


/*
 *  $B%9%1%8%e!<%i9=B$BN$NDj5A(B
 */
typedef  struct  {

  /* $B%a%C%;!<%8(B */
  MYScMsg   retraceMsg;
  MYScMsg   prenmiMsg;


  /* $B%a%C%;!<%8%-%e!<$NDj5A(B */
  /* $B%j%H%l!<%9(B */
  OSMesgQueue  retraceMQ;
  OSMesg       retraceMsgBuf[MY_SC_MAX_MESGS];

  /* RSP $B%?%9%/=*N;(B */
  OSMesgQueue  rspMQ;
  OSMesg       rspMsgBuf;

  /* RDP $B%?%9%/=*N;(B */
  OSMesgQueue  rdpMQ;
  OSMesg       rdpMsgBuf;

  /* $B%0%i%U%#%C%/%9%?%9%/(B */
  OSMesgQueue  graphicsRequestMQ;
  OSMesg       graphicsRequestBuf;

  /* $B%*!<%G%#%*%?%9%/(B */
  OSMesgQueue  audioRequestMQ;
  OSMesg       audioRequestBuf;

  /* $B%0%i%U%#%C%/%9%U%l!<%`(B */
  OSMesgQueue  graphicsFrameMQ;
  OSMesg       graphicsFrameBuf;

  /* $B%*!<%G%#%*%U%l!<%`(B */
  OSMesgQueue  audioFrameMQ;
  OSMesg       audioFrameBuf;


  /* $B%9%l%C%I$NDj5A(B */
  /* $B%a%$%s%9%l%C%I(B */
  OSThread    schedulerThread;

  /* $B%*!<%G%#%*(B */
  OSThread    audioThread;

  /* $B%0%i%U%#%C%/%9(B */
  OSThread    graphicsThread;


  /* $B%/%i%$%"%s%H%j%9%H(B  */
  MYScClient  *clientList;


  /* $B=i4|2hLL@)8fMQ%U%i%0(B */
  u32         firstTime;

} MYSched;


/*
 *  extern $B@k8@(B
 */
extern  MYSched  sc;


/*
 *   $B4X?t%W%m%H%?%$%W@k8@(B
 */
extern  void  myScCreateScheduler(MYSched *sc, u8 videoMode, u8 numFields);
extern  void  myScEventHandler(MYSched *sc);
extern  void  myScEventBroadcast(MYSched *sc, MYScMsg *msg);
extern  void  myScAddClient(MYSched *sc, MYScClient *, OSMesgQueue *mq);
extern  void  myScExecuteAudio(MYSched *sc);
extern  void  myScExecuteGraphics(MYSched *sc);