コード例 #1
0
ファイル: controller.c プロジェクト: shlomnissan/ultra64demos
/*
 * initilize controller
 *
 * maxcontrollers: want controller max num
 * return        : useable controller num
 */
int controllerInit(int maxcontrollers)
{
  int         i;
  u8          pattern;
  OSMesgQueue serialMsgQ;
  OSMesg      serialMsg;

  osCreateMesgQueue(&serialMsgQ, &serialMsg, 1);
  osSetEventMesg(OS_EVENT_SI, &serialMsgQ, (OSMesg)0);

  osContInit(&serialMsgQ, &pattern, &statusdata[0]);

  osCreateMesgQueue(&controllerMsgQ, &controllerMsgBuf, 1);
  osSetEventMesg(OS_EVENT_SI, &controllerMsgQ, (OSMesg)0);

 
  for(i = 0; i < MAXCONTROLLERS; i++){
    if((pattern & (1<<i)) &&
       !(statusdata[i].errno & CONT_NO_RESPONSE_ERROR)) {
      controllerdata_ptr[numControllers] = & controllerdata[i];
      numControllers++;
      if(numControllers == maxcontrollers){
	return numControllers;
      }
    }
  }
/*  osContStartReadData(&controllerMsgQ); */
  return numControllers;
}
コード例 #2
0
ファイル: controller.c プロジェクト: shlomnissan/ultra64demos
/*
 *
 * Return the lowest number controller connected to system
 */
int 
initControllers()
{
    OSMesgQueue     serialMsgQ;
    OSMesg          serialMsg;
    int             i;
    u8              pattern;

    resetControllers();

    osCreateMesgQueue(&serialMsgQ, &serialMsg, 1);
    osSetEventMesg(OS_EVENT_SI, &serialMsgQ, (OSMesg)1);

    osContInit(&serialMsgQ, &pattern, &statusdata[0]);

    osCreateMesgQueue(&controllerMsgQ, &controllerMsgBuf, 1);
    osSetEventMesg(OS_EVENT_SI, &controllerMsgQ, (OSMesg)0);

    for (i = 0; i < MAXCONTROLLERS; i++) {
        if ((pattern & (1<<i)) &&
	    !(statusdata[i].errno & CONT_NO_RESPONSE_ERROR))
            return i;
    }
    return -1;
}
コード例 #3
0
ファイル: morphfaces.c プロジェクト: shlomnissan/ultra64demos
static void gameproc(void *arg) {
  char     *rsp_static_addr;  /* R4300 addr where rsp_static segment loaded */
  char     *rsp_static_end;   /* R4300 addr+1 for end of the load region    */
  int      rsp_static_len;
  OSIoMesg dmaMb;             /* Needed (empty) for call to osEPiStartDma    */

  /* Message Queue for OS messages indicating DMA completions */
  osCreateMesgQueue(&DMAMessageQ, DMAMessages, DMA_MSGQUEUE_SIZE);

  /* Message Queue for OS messages indicating RDP done */
  osCreateMesgQueue(&RDPDoneMessageQ, RDPDoneMessages, RDPDONE_MSGQUEUE_SIZE);
  osSetEventMesg(OS_EVENT_DP, &RDPDoneMessageQ, dummyMsg);

  /* Message Queue for OS messages indicating vertical retrace */
  osCreateMesgQueue(&RetraceMessageQ, RetraceMessages, RETRACE_MSGQUEUE_SIZE);
  osViSetEvent(&RetraceMessageQ, dummyMsg, 1);

  /*
   * Load the 'rsp_static' segment from the cartridge
   */
  rsp_static_len  = _rsp_staticSegmentRomEnd - _rsp_staticSegmentRomStart;

  /* Place it right after the code/data segment in the 3rd MB of memory.
   * Will not collide with CFB's or the Z buffer. Because the texture loads
   * are so frequent, this gives a significant performance enhancement.
   */

  rsp_static_addr = _codeSegmentEnd; /* R4300 address for static segment */
  rsp_static_end  = _codeSegmentEnd + rsp_static_len;

#ifdef DEBUG
  if (rsp_static_len > 0x00300000) {
    osSyncPrintf("** Static Segment too large **\n");
  }
#endif

  /* Note: dmaMb is working space used by osEPiStartDma */

  dmaMb.hdr.pri      = OS_MESG_PRI_NORMAL;
  dmaMb.hdr.retQueue = &DMAMessageQ;
  dmaMb.dramAddr     = rsp_static_addr;
  dmaMb.devAddr      = (u32)_rsp_staticSegmentRomStart;
  dmaMb.size         = rsp_static_len;

  osEPiStartDma(handler, &dmaMb, OS_READ);
  osRecvMesg(&DMAMessageQ, NULL, OS_MESG_BLOCK);  /* Wait for completion */

  /*
   * Do the one-time setup
   * (Build both display lists)
   */
  makestuff();

  /*
   * Run the main loop of the game
   */
  gameloop(rsp_static_addr);

} /* gameproc */
コード例 #4
0
ファイル: controller.c プロジェクト: shlomnissan/ultra64demos
/**********************************************************************
 *
 * Routine for initializing the controllers. After initialized, set the
 * controller interrupt to be posted to the gfxFrameMsgQ, used by the 
 * gameproc in simple.c.
 *
 *********************************************************************/
void initCntrl(void)
{
    OSMesgQueue         serialMsgQ;
    OSMesg              serialMsg;
    s32                 i;

    osCreateMesgQueue(&serialMsgQ, &serialMsg, 1);
    osSetEventMesg(OS_EVENT_SI, &serialMsgQ, (OSMesg)1);

    if((i = osContInit(&serialMsgQ, &validcontrollers, &statusdata[0])) != 0)
        PRINTF("Failure initing controllers\n");
    
    /**** Set up message and queue, for read completion notification ****/
    controllermsg.type = SIMPLE_CONTROLLER_MSG;

    osSetEventMesg(OS_EVENT_SI, &gfxFrameMsgQ, (OSMesg)&controllermsg);

}
コード例 #5
0
ファイル: boot.c プロジェクト: shlomnissan/ultra64demos
/*
 * This is the main routine of the app.
 */
static void
mainproc(void *arg)
{

	/*
	 * Setup the message queues
	 */
	osCreateMesgQueue(&dmaMessageQ, &dmaMessageBuf, 1);

	osCreateMesgQueue(&rspMessageQ, &rspMessageBuf, 1);
	osSetEventMesg(OS_EVENT_SP, &rspMessageQ, NULL);

	osCreateMesgQueue(&rdpMessageQ, &rdpMessageBuf, 1);
	osSetEventMesg(OS_EVENT_DP, &rdpMessageQ, NULL);

	osCreateMesgQueue(&retraceMessageQ, &retraceMessageBuf, 1);
	osViSetEvent(&retraceMessageQ, NULL, 1);

	/*
	 * Stick the static segment right after the code/data segment
	 */
	staticSegment = _zbufferSegmentEnd;
	osPiStartDma(&dmaIOMessageBuf, OS_MESG_PRI_NORMAL, OS_READ,
		 (u32) _staticSegmentRomStart, staticSegment,
		 (u32) _staticSegmentRomEnd - (u32) _staticSegmentRomStart,
		 &dmaMessageQ);

	/*
	 * Wait for DMA to finish
	 */
	(void) osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);

	freeSegment = staticSegment + 
		(u32) _staticSegmentRomEnd - (u32) _staticSegmentRomStart;

	initControllers(MAXCONTROLLERS);

	game();
}
コード例 #6
0
ファイル: system.c プロジェクト: shlomnissan/ultra64demos
void	mainproc(void *arg)
{
  /* Create Message Queue */
  osCreateMesgQueue(&dmaMessageQ,     &dmaMessageBuf,       1);
  osCreateMesgQueue(&rspMessageQ,     &rspMessageBuf,       1);
  osCreateMesgQueue(&rspBrkMessageQ,     &rspBrkMessageBuf, 1);
  osCreateMesgQueue(&rdpMessageQ,     &rdpMessageBuf,       1);
  osCreateMesgQueue(&siMessageQ,      &siMessageBuf,        1);
  osCreateMesgQueue(&retraceMessageQ, &retraceMessageBuf,   1);
  
  /* Connect Event to Message Queue */
  osSetEventMesg(OS_EVENT_SP, &rspMessageQ, NULL);
  osSetEventMesg(OS_EVENT_SP_BREAK, &rspBrkMessageQ, NULL);
  osSetEventMesg(OS_EVENT_DP, &rdpMessageQ, NULL);
  osSetEventMesg(OS_EVENT_SI, &siMessageQ,  NULL);
  osViSetEvent(&retraceMessageQ, NULL, 1);
  
  /* Initialize Controller */
  osContInit(&siMessageQ, &contExist, contStatus);
  
  /* Call Main Function */
  Main(arg);
}
コード例 #7
0
ファイル: main.c プロジェクト: LuigiBlood/64ddipl_dumper
void	
mainproc(void *arg)
{	
  int	i, j;
  int	cont_no = 0;
  int	error, readerror;
  u8	bitpattern;
  u16	button = 0, oldbutton = 0, newbutton = 0; 
  u32	stat;
  char 	console_text[50];

  osCreateMesgQueue(&pifMesgQueue, pifMesgBuf, NUM_MESSAGE);
  osSetEventMesg(OS_EVENT_SI, &pifMesgQueue, dummyMessage);

  osContInit(&pifMesgQueue, &bitpattern, &contstat[0]);
  for (i = 0; i < MAXCONTROLLERS; i++) {
    if ((bitpattern & (1<<i)) &&
       ((contstat[i].type & CONT_TYPE_MASK) == CONT_TYPE_NORMAL)) {
      controller[i] = CONT_VALID;
    } else {
      controller[i] = CONT_INVALID;
    }
  }
  
  osCreateMesgQueue(&dmaMessageQ, dmaMessageBuf, 1);

  pi_handle = osCartRomInit();
  pi_ddrom_handle = osDriveRomInit();
  
  bzero(blockData, 0x1000);
  readerror = -1;

  init_draw();

  setcolor(0,255,0);
  draw_puts("If you see this for a long period of time,\nsomething f****d up. Sorry.");
  
  LeoCJCreateLeoManager((OSPri)OS_PRIORITY_LEOMGR-1, (OSPri)OS_PRIORITY_LEOMGR, LeoMessages, NUM_LEO_MESGS);
  LeoResetClear();

  setbgcolor(15,15,15);
  clear_draw();
  
  setcolor(0,255,0);
  draw_puts("\f\n    64DD IPL dumper v0.01b by LuigiBlood & marshallh\n    ----------------------------------------\n");
  setcolor(255,255,255);
  draw_puts("    PRESS START TO DUMP");

  while(1) {
    osContStartReadData(&pifMesgQueue);
    osRecvMesg(&pifMesgQueue, NULL, OS_MESG_BLOCK);
    osContGetReadData(&contdata[0]);
    if (contdata[cont_no].errno & CONT_NO_RESPONSE_ERROR) {
      button = oldbutton;
    } else {
      oldbutton = button;
      button = contdata[cont_no].button;
    }
    newbutton = ~oldbutton & button;
    
    if (newbutton & START_BUTTON)
    {
        //DUMP!!
        
        //64drive, enable write to SDRAM/ROM
		  srand(osGetCount()); // necessary to generate unique short 8.3 filenames on memory card
        ciEnableRomWrites();

        draw_puts("\f\n\n\n\n\n    Let's dump! Don't turn off the console!\n\n");
        
        osInvalDCache((void *)&blockData, (s32) 0x1000); 
        dmaIoMesgBuf.hdr.pri = OS_MESG_PRI_NORMAL;
        dmaIoMesgBuf.hdr.retQueue = &dmaMessageQ;
        dmaIoMesgBuf.dramAddr = &blockData;
        dmaIoMesgBuf.devAddr = IPLoffset;
        dmaIoMesgBuf.size = 0x1000;
        
        for (IPLoffset = 0; IPLoffset < 0x400000; IPLoffset += 0x1000)
        {
          //read 64DD IPL
          osWritebackDCacheAll();
 
          dmaIoMesgBuf.hdr.pri = OS_MESG_PRI_NORMAL;
          dmaIoMesgBuf.hdr.retQueue = &dmaMessageQ;
          dmaIoMesgBuf.dramAddr = (void *)&blockData;
          dmaIoMesgBuf.devAddr = 0xA6000000 + IPLoffset;
          dmaIoMesgBuf.size = 0x1000;
                               
          osEPiStartDma(pi_ddrom_handle, &dmaIoMesgBuf, OS_READ);
          osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
         
          //Write to 64drive
          osWritebackDCacheAll();
 
          dmaIoMesgBuf.hdr.pri = OS_MESG_PRI_NORMAL;
          dmaIoMesgBuf.hdr.retQueue = &dmaMessageQ;
          dmaIoMesgBuf.dramAddr = (void *)&blockData;
          dmaIoMesgBuf.devAddr = 0xB0000000 + IPLoffset;
          dmaIoMesgBuf.size = 0x1000;
                               
          osEPiStartDma(pi_handle, &dmaIoMesgBuf, OS_WRITE);
          osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
        }
		  
		  //DONE!! NOW WRITE TO SD
		  fat_start();
        
        draw_puts("\n    - DONE !!\n");
		
        for(;;);
    }
  }
}
コード例 #8
0
ファイル: boot.c プロジェクト: shlomnissan/ultra64demos
/*
 * This is the main routine of the app.
 */
static void
mainproc(void *arg)
{
#ifdef DEBUG
	int             i;
	char           *ap;
	u32            *argp;

	/*
	 * get arguments (options)
	 */
	argp = (u32 *) RAMROM_APP_WRITE_ADDR;
	for (i = 0; i < sizeof(argbuf) / 4; i++, argp++) {
		osEPiReadIo(handler, (u32) argp, &argbuf[i]);	/* Assume no DMA */
	}
	((char *) argbuf)[sizeof(argbuf)-1] = '\0';

	/*
	 * Parse the options 
	 */
	ap = (char *) argbuf;
	position_str = (char *) 0;
	while (*ap != '\0') {
		while (*ap == ' ')
			ap++;
		if (*ap == '-' && *(ap + 1) == 'r') {
			rdp_flag = 1;
			ap += 2;
		} else if (*ap == '-' && *(ap + 1) == 'i') {
			ap += 2;
			position_str = ap;
			break;			/* -i must be last argument */
		} else ap++;
	}
#endif

	/*
	 * Setup the message queues
	 */
	osCreateMesgQueue(&dmaMessageQ, &dmaMessageBuf, 1);

	osCreateMesgQueue(&rdpMessageQ, &rdpMessageBuf, 1);
	osSetEventMesg(OS_EVENT_DP, &rdpMessageQ, NULL);

	osCreateMesgQueue(&retraceMessageQ, &retraceMessageBuf, 1);
	osViSetEvent(&retraceMessageQ, NULL, 1);

	/*
	 * Stick the static segment right after the code/data segment
	 */
	staticSegment = _zbufferSegmentEnd;

	dmaIOMessageBuf.hdr.pri      = OS_MESG_PRI_NORMAL;
	dmaIOMessageBuf.hdr.retQueue = &dmaMessageQ;
	dmaIOMessageBuf.dramAddr     = staticSegment;
	dmaIOMessageBuf.devAddr      = (u32)_staticSegmentRomStart;
	dmaIOMessageBuf.size         = (u32)_staticSegmentRomEnd-(u32)_staticSegmentRomStart;

	osEPiStartDma(handler, &dmaIOMessageBuf, OS_READ);

	/*
	 * Wait for DMA to finish
	 */
	(void) osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);

	/*
	 * Stick the texture segment right after the static segment
	 */
	textureSegment = staticSegment + 
		(u32) _staticSegmentRomEnd - (u32) _staticSegmentRomStart;

	dmaIOMessageBuf.hdr.pri      = OS_MESG_PRI_NORMAL;
	dmaIOMessageBuf.hdr.retQueue = &dmaMessageQ;
	dmaIOMessageBuf.dramAddr     = textureSegment;
	dmaIOMessageBuf.devAddr      = (u32)_textureSegmentRomStart;
	dmaIOMessageBuf.size         = (u32)_textureSegmentRomEnd-(u32)_textureSegmentRomStart;

	osEPiStartDma(handler, &dmaIOMessageBuf, OS_READ);

	/*
	 * Wait for DMA to finish
	 */
	(void) osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);

	initControllers(MAXCONTROLLERS);

	game();
}