예제 #1
0
파일: wl_debug.cpp 프로젝트: vbt1/wolf4sdl
/*
================
=
= ShapeTest
=
================
*/
void ShapeTest (void)
{
    //TODO
#if NOTYET
    extern  word    NumDigi;
    extern  word    *DigiList;
    extern  int     postx;
    extern  int     postwidth;
    extern  byte    *postsource;
    static  char    buf[10];

    boolean         done;
    ScanCode        scan;
    int             i,j,k,x;
    longword        l;
    byte            *addr;
    soundnames      sound;
    //      PageListStruct  far *page;

    CenterWindow(20,16);
    VW_UpdateScreen();
    for (i = 0,done = false; !done;)
    {
        US_ClearWindow();
        sound = (soundnames) -1;

        //              page = &PMPages[i];
        US_Print(" Page #");
        US_PrintUnsigned(i);
        if (i < PMSpriteStart)
            US_Print(" (Wall)");
        else if (i < PMSoundStart)
            US_Print(" (Sprite)");
        else if (i == ChunksInFile - 1)
            US_Print(" (Sound Info)");
        else
            US_Print(" (Sound)");

        /*              US_Print("\n XMS: ");
        if (page->xmsPage != -1)
        US_PrintUnsigned(page->xmsPage);
        else
        US_Print("No");

        US_Print("\n Main: ");
        if (page->mainPage != -1)
        US_PrintUnsigned(page->mainPage);
        else if (page->emsPage != -1)
        {
        US_Print("EMS ");
        US_PrintUnsigned(page->emsPage);
        }
        else
        US_Print("No");

        US_Print("\n Last hit: ");
        US_PrintUnsigned(page->lastHit);*/

        US_Print("\n Address: ");
        addr = (byte *) PM_GetPage(i);
        sprintf(buf,"0x%08X",(int32_t) addr);
        US_Print(buf);

        if (addr)
        {
            if (i < PMSpriteStart)
            {
                //
                // draw the wall
                //
                vbuf += 32*SCREENWIDTH;
                postx = 128;
                postwidth = 1;
                postsource = addr;
                for (x=0;x<64;x++,postx++,postsource+=64)
                {
                    wallheight[postx] = 256;
                    ScalePost ();
                }
                vbuf -= 32*SCREENWIDTH;
            }
            else if (i < PMSoundStart)
            {
                //
                // draw the sprite
                //
                vbuf += 32*SCREENWIDTH;
                SimpleScaleShape (160, i-PMSpriteStart, 64);
                vbuf -= 32*SCREENWIDTH;
            }
            else if (i == ChunksInFile - 1)
            {
                US_Print("\n\n Number of sounds: ");
                US_PrintUnsigned(NumDigi);
                for (l = j = k = 0;j < NumDigi;j++)
                {
                    l += DigiList[(j * 2) + 1];
                    k += (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;
                }
                US_Print("\n Total bytes: ");
                US_PrintUnsigned(l);
                US_Print("\n Total pages: ");
                US_PrintUnsigned(k);
            }
            else
            {
                byte *dp = addr;
                for (j = 0;j < NumDigi;j++)
                {
                    k = (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;
                    if ((i >= PMSoundStart + DigiList[j * 2])
                            && (i < PMSoundStart + DigiList[j * 2] + k))
                        break;
                }
                if (j < NumDigi)
                {
                    sound = (soundnames) j;
                    US_Print("\n Sound #");
                    US_PrintUnsigned(j);
                    US_Print("\n Segment #");
                    US_PrintUnsigned(i - PMSoundStart - DigiList[j * 2]);
                }
                for (j = 0;j < PageLengths[i];j += 32)
                {
                    byte v = dp[j];
                    int v2 = (unsigned)v;
                    v2 -= 128;
                    v2 /= 4;
                    if (v2 < 0)
                        VWB_Vlin(WindowY + WindowH - 32 + v2,
                        WindowY + WindowH - 32,
                        WindowX + 8 + (j / 32),BLACK);
                    else
                        VWB_Vlin(WindowY + WindowH - 32,
                        WindowY + WindowH - 32 + v2,
                        WindowX + 8 + (j / 32),BLACK);
                }
            }
        }

        VW_UpdateScreen();

        IN_Ack();
        scan = LastScan;

        IN_ClearKey(scan);
        switch (scan)
        {
            case sc_LeftArrow:
                if (i)
                    i--;
                break;
            case sc_RightArrow:
                if (++i >= ChunksInFile)
                    i--;
                break;
            case sc_W:      // Walls
                i = 0;
                break;
            case sc_S:      // Sprites
                i = PMSpriteStart;
                break;
            case sc_D:      // Digitized
                i = PMSoundStart;
                break;
            case sc_I:      // Digitized info
                i = ChunksInFile - 1;
                break;
/*            case sc_L:      // Load all pages
                for (j = 0;j < ChunksInFile;j++)
                    PM_GetPage(j);
                break;*/
            case sc_P:
                if (sound != -1)
                    SD_PlayDigitized(sound,8,8);
                break;
            case sc_Escape:
                done = true;
                break;
/*            case sc_Enter:
                PM_GetPage(i);
                break;*/
        }
    }
    SD_StopDigitized();
#endif
}
예제 #2
0
static void SD_SetupDigi(void)
{
   /* Correct padding enforced by PM_Startup() */
   int i;
   word *soundInfoPage = (word *) (void *) PM_GetPage(ChunksInFile-1);
   NumDigi = (word) PM_GetPageSize(ChunksInFile - 1) / 4;

   DigiList = (digiinfo *) malloc(NumDigi * sizeof(digiinfo));

   for(i = 0; i < NumDigi; i++)
   {
      unsigned page;

      /* Calculate the size of the digi 
       * from the sizes of the pages between
       * the start page and the start page of the next sound. */

      DigiList[i].startpage = soundInfoPage[i * 2];
      DigiList[i].startpage = (word)Retro_SwapLES16(DigiList[i].startpage);

      if((int) DigiList[i].startpage >= ChunksInFile - 1)
      {
         NumDigi = i;
         break;
      }

      int lastPage;
      if(i < NumDigi - 1)
      {
         lastPage = soundInfoPage[i * 2 + 2];
         lastPage = Retro_SwapLES16(lastPage);

         if(lastPage == 0 || lastPage + PMSoundStart > ChunksInFile - 1) lastPage = ChunksInFile - 1;
         else lastPage += PMSoundStart;
      }
      else lastPage = ChunksInFile - 1;

      int size = 0;
      for(page = PMSoundStart + DigiList[i].startpage; page < lastPage; page++)
         size += PM_GetPageSize(page);

      /* Don't include padding of sound info page, if padding was added */
      if(lastPage == ChunksInFile - 1 && PMSoundInfoPagePadded)
         size--;

      /* Patch lower 16-bit of size with size 
       * from sound info page.
       *
       * The original VSWAP contains padding 
       * which is included in the page size,
       * but not included in the 16-bit size.
       *
       * So we use the more precise value. */
      if((size & 0xffff0000) != 0 && (size & 0xffff) < (word)Retro_SwapLES16(soundInfoPage[i * 2 + 1]))
         size -= 0x10000;
      size = (size & 0xffff0000) | (word)Retro_SwapLES16(soundInfoPage[i * 2 + 1]);

      DigiList[i].length = size;
   }

   for(i = 0; i < LASTSOUND; i++)
   {
      DigiMap[i] = -1;
      DigiChannel[i] = -1;
   }
}