Exemplo n.º 1
0
Arquivo: main.c Projeto: GPDP2/mupen64
__declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles )
{
    OSTask_t *task = (OSTask_t*)(rsp.DMEM + 0xFC0);
    unsigned int i, sum=0;
#ifdef __WIN32__
    if(firstTime)
    {
        firstTime=FALSE;
        if (SpecificHle)
            loadPlugin();
    }
#endif

    if( task->type == 1 && task->data_ptr != 0 && GraphicsHle) {
        if (rsp.ProcessDlistList != NULL) {
            rsp.ProcessDlistList();
        }
        *rsp.SP_STATUS_REG |= 0x0203;
        if ((*rsp.SP_STATUS_REG & 0x40) != 0 ) {
            *rsp.MI_INTR_REG |= 0x1;
            rsp.CheckInterrupts();
        }

        *rsp.DPC_STATUS_REG &= ~0x0002;
        return Cycles;
    } else if (task->type == 2 && AudioHle) {
#ifdef __WIN32__
        if (SpecificHle)
            processAList();
        else
#endif
            if (rsp.ProcessAlistList != NULL) {
                rsp.ProcessAlistList();
            }
        *rsp.SP_STATUS_REG |= 0x0203;
        if ((*rsp.SP_STATUS_REG & 0x40) != 0 ) {
            *rsp.MI_INTR_REG |= 0x1;
            rsp.CheckInterrupts();
        }
        return Cycles;
    } else if (task->type == 7) {
        rsp.ShowCFB();
    }

    *rsp.SP_STATUS_REG |= 0x203;
    if ((*rsp.SP_STATUS_REG & 0x40) != 0 )
    {
        *rsp.MI_INTR_REG |= 0x1;
        rsp.CheckInterrupts();
    }

    if (task->ucode_size <= 0x1000)
        for (i=0; i<(task->ucode_size/2); i++)
            sum += *(rsp.RDRAM + task->ucode + i);
    else
        for (i=0; i<(0x1000/2); i++)
            sum += *(rsp.IMEM + i);


    if (task->ucode_size > 0x1000)
    {
        switch(sum)
        {
        case 0x9E2: // banjo tooie (U) boot code
        {
            int i,j;
            memcpy(rsp.IMEM + 0x120, rsp.RDRAM + 0x1e8, 0x1e8);
            for (j=0; j<0xfc; j++)
                for (i=0; i<8; i++)
                    *(rsp.RDRAM+((0x2fb1f0+j*0xff0+i)^S8))=*(rsp.IMEM+((0x120+j*8+i)^S8));
        }
        return Cycles;
        break;
        case 0x9F2: // banjo tooie (E) + zelda oot (E) boot code
        {
            int i,j;
            memcpy(rsp.IMEM + 0x120, rsp.RDRAM + 0x1e8, 0x1e8);
            for (j=0; j<0xfc; j++)
                for (i=0; i<8; i++)
                    *(rsp.RDRAM+((0x2fb1f0+j*0xff0+i)^S8))=*(rsp.IMEM+((0x120+j*8+i)^S8));
        }
        return Cycles;
        break;
        }
    }
    else
    {
        switch(task->type)
        {
        case 2: // audio
            if (audio_ucode(task) == 0)
                return Cycles;
            break;
        case 4: // jpeg
            switch(sum)
            {
            case 0x278: // used by zelda during boot
                *rsp.SP_STATUS_REG |= 0x200;
                return Cycles;
                break;
            case 0x2e4fc: // uncompress
                jpg_uncompress(task);
                return Cycles;
                break;
            default:
            {
                char s[1024];
                sprintf(s, "unknown jpeg:\n\tsum:%x", sum);
#ifdef __WIN32__
                MessageBox(NULL, s, "unknown task", MB_OK);
#else
                printf("%s\n", s);
#endif
            }
            }
            break;
        }
    }

    {
        char s[1024];
        FILE *f;
        sprintf(s, "unknown task:\n\ttype:%d\n\tsum:%x\n\tPC:%x", (int)task->type, sum, (int)rsp.SP_PC_REG);
#ifdef __WIN32__
        MessageBox(NULL, s, "unknown task", MB_OK);
#else
        printf("%s\n", s);
#endif

        if (task->ucode_size <= 0x1000)
        {
            f = fopen("imem.dat", "wb");
            fwrite(rsp.RDRAM + task->ucode, task->ucode_size, 1, f);
            fclose(f);

            f = fopen("dmem.dat", "wb");
            fwrite(rsp.RDRAM + task->ucode_data, task->ucode_data_size, 1, f);
            fclose(f);

            f = fopen("disasm.txt", "wb");
            memcpy(rsp.DMEM, rsp.RDRAM+task->ucode_data, task->ucode_data_size);
            memcpy(rsp.IMEM+0x80, rsp.RDRAM+task->ucode, 0xF7F);
            disasm(f, (unsigned int*)(rsp.IMEM));
            fclose(f);
        }
        else
        {
            f = fopen("imem.dat", "wb");
            fwrite(rsp.IMEM, 0x1000, 1, f);
            fclose(f);

            f = fopen("dmem.dat", "wb");
            fwrite(rsp.DMEM, 0x1000, 1, f);
            fclose(f);

            f = fopen("disasm.txt", "wb");
            disasm(f, (unsigned int*)(rsp.IMEM));
            fclose(f);
        }
    }

    return Cycles;
}
Exemplo n.º 2
0
EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles)
{
   OSTask_t *task = (OSTask_t*)(rsp.DMEM + 0xFC0);
   unsigned int i, sum=0;

   if( task->type == 1 && task->data_ptr != 0 && GraphicsHle) {
      if (rsp.ProcessDlistList != NULL) {
     rsp.ProcessDlistList();
      }
      *rsp.SP_STATUS_REG |= 0x0203;
      if ((*rsp.SP_STATUS_REG & 0x40) != 0 ) {
     *rsp.MI_INTR_REG |= 0x1;
     rsp.CheckInterrupts();
      }

      *rsp.DPC_STATUS_REG &= ~0x0002;
      return Cycles;
   } else if (task->type == 2 && AudioHle) {
      if (rsp.ProcessAlistList != NULL) {
     rsp.ProcessAlistList();
      }
      *rsp.SP_STATUS_REG |= 0x0203;
      if ((*rsp.SP_STATUS_REG & 0x40) != 0 ) {
     *rsp.MI_INTR_REG |= 0x1;
     rsp.CheckInterrupts();
      }
      return Cycles;
   } else if (task->type == 7) {
      rsp.ShowCFB();
   }

   *rsp.SP_STATUS_REG |= 0x203;
   if ((*rsp.SP_STATUS_REG & 0x40) != 0 )
     {
    *rsp.MI_INTR_REG |= 0x1;
    rsp.CheckInterrupts();
     }

   if (task->ucode_size <= 0x1000)
     for (i=0; i<(task->ucode_size/2); i++)
       sum += *(rsp.RDRAM + task->ucode + i);
   else
     for (i=0; i<(0x1000/2); i++)
       sum += *(rsp.IMEM + i);


   if (task->ucode_size > 0x1000)
     {
    switch(sum)
      {
       case 0x9E2: // banjo tooie (U) boot code
           {
          int i,j;
          memcpy(rsp.IMEM + 0x120, rsp.RDRAM + 0x1e8, 0x1e8);
          for (j=0; j<0xfc; j++)
            for (i=0; i<8; i++)
              *(rsp.RDRAM+((0x2fb1f0+j*0xff0+i)^S8))=*(rsp.IMEM+((0x120+j*8+i)^S8));
           }
         return Cycles;
         break;
       case 0x9F2: // banjo tooie (E) + zelda oot (E) boot code
           {
          int i,j;
          memcpy(rsp.IMEM + 0x120, rsp.RDRAM + 0x1e8, 0x1e8);
          for (j=0; j<0xfc; j++)
            for (i=0; i<8; i++)
              *(rsp.RDRAM+((0x2fb1f0+j*0xff0+i)^S8))=*(rsp.IMEM+((0x120+j*8+i)^S8));
           }
         return Cycles;
         break;
      }
     }
   else
     {
    switch(task->type)
      {
       case 2: // audio
         if (audio_ucode(task) == 0)
           return Cycles;
         break;
       case 4: // jpeg
         switch(sum)
           {
        case 0x278: // used by zelda during boot
          *rsp.SP_STATUS_REG |= 0x200;
          return Cycles;
          break;
        case 0x2e4fc: // uncompress
          jpg_uncompress(task);
          return Cycles;
          break;
        default:
            {
               DebugMessage(M64MSG_WARNING, "unknown jpeg task:  sum:%x", sum);
            }
        }
         break;
      }
     }

     {
    FILE *f;
    DebugMessage(M64MSG_WARNING, "unknown task:  type:%d  sum:%x  PC:%lx", (int)task->type, sum, (unsigned long) rsp.SP_PC_REG);

    if (task->ucode_size <= 0x1000)
      {
         f = fopen("imem.dat", "wb");
         if (f == NULL || fwrite(rsp.RDRAM + task->ucode, 1, task->ucode_size, f) != task->ucode_size)
            DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file imem.dat");
         fclose(f);

         f = fopen("dmem.dat", "wb");
         if (f == NULL || fwrite(rsp.RDRAM + task->ucode_data, 1, task->ucode_data_size, f) != task->ucode_data_size)
            DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file dmem.dat");
         fclose(f);
      }
    else
      {
         f = fopen("imem.dat", "wb");
         if (f == NULL || fwrite(rsp.IMEM, 1, 0x1000, f) != 0x1000)
            DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file imem.dat");
         fclose(f);

         f = fopen("dmem.dat", "wb");
         if (f == NULL || fwrite(rsp.DMEM, 1, 0x1000, f) != 0x1000)
            DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file dmem.dat");
         fclose(f);
      }
     }

   return Cycles;
}