⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 juicebox.c.bak

📁 An complete pmp solution for mattel juicebox player. Using crossworks for arm.
💻 BAK
📖 第 1 页 / 共 2 页
字号:
#include "s3c44b0x.h"
#include "system.h"
#include "stdint.h"
#include "ff.h"
#include "visual.h"
#include "bitmap.h"
#include "lists.h"

/* Scheduler includes. */
/*
#include "FreeRTOS.h"
#include "Task.h"
#include "queue.h"
*/

//#include "mp3\play_mp3.h"

/* Determined with OCD Commander, can be compared directly to Port G Data */
#define _PLAY     0x9D
#define _RETURN   0x9E
#define _STAR     0x8F
#define _FORWARD  0x9B
#define _REVERSE  0x97
#define _ATREST   0x9F    /* Not buttons being pressed */

#define dwShift(a, b) ((b<<16)|a)

xTBitmap *xLCD;
xTRectangle *xRLCD;
xTFont *xFont;
//---------------------------------------------------------------------
#define diNotepadBufferLength 270000
i32 wNotepad (char *sPath)
{
  FIL *xFile = wMalloc(sizeof(FIL));
  if(wFileOpen (xFile, sPath, FA_READ)!= FR_OK) 
	{
	wFree (xFile);
	return (-1);
	}
  
  visTCustomList *pxList = wMalloc (sizeof(visTCustomList));
  pxList->pxBitmap = xLCD;
  pxList->pxItems = wMalloc(sizeof(xTStringList));
  pxList->pxItems->ulLength = 0;
  pxList->pxItems->ulMaxLength = 0;
  pxList->lItemIndex = 0;
  pxList->ulWindowBuffer = 0;
  pxList->pxFont = xFont;
  pxList->uiColorFont = 0x0000;
  pxList->uiColorBackground = 0x0FFD;
  pxList->uiColorHlFont = 0x0FFD;
  pxList->uiColorHlBackground = 0x0000;
  pxList->xWorkRect.x1 = 0;
  pxList->xWorkRect.x2 = 240;
  pxList->xWorkRect.y1 = 0;
  pxList->xWorkRect.y2 = 160;
  wvisCustomListInit(pxList);
  char *sBuffer = wMalloc(sizeof(char)*diNotepadBufferLength+1);
  u32 ulReadCount = diNotepadBufferLength;
  wStringListReadFromBuffer (pxList->pxItems, 0, NULL);
  while (ulReadCount==diNotepadBufferLength)
     {
     wFileRead (xFile, (void*)sBuffer, diNotepadBufferLength, &ulReadCount);
     wStringListReadFromBuffer (pxList->pxItems, ulReadCount, sBuffer);
     }
   wvisCustomListRefresh(pxList);

  while(1)
    {
    switch (*pdatg)
    {
      case _FORWARD:
        {
        pxList->lItemIndex++;
        wvisCustomListRefresh(pxList);
       // wDelayMs(10);
        break;
        }
      
	  case _REVERSE:
        {
        pxList->lItemIndex--;
        wvisCustomListRefresh(pxList);
        //wDelayMs(10);
        break;
        }

      case _STAR:
		{
        wStringListClear(pxList->pxItems);
		wFree(pxList->pxItems->pxItems);
        wFree(pxList->pxItems);
		wFree(pxList);
		wFree(xFile);
		return 1;
		}
	  }
    }
}
//-------------------------------------------------------
i32 wExplorer()
{
  DIR *directory = wMalloc (sizeof(DIR));
  FILINFO *fileinfo = wMalloc (sizeof(FILINFO));
	
  visTCustomList *pxList = wMalloc (sizeof(visTCustomList));
  pxList->pxBitmap = xLCD;
  pxList->pxItems = wMalloc(sizeof(xTStringList));
  pxList->pxItems->ulLength = 0;
  pxList->pxItems->ulMaxLength = 0;
  pxList->lItemIndex = 0;
  pxList->ulWindowBuffer = 0;
  pxList->pxFont = xFont;
  pxList->uiColorFont = 0x0000;
  pxList->uiColorBackground = 0x0FFD;
  pxList->uiColorHlFont = 0x0FFD;
  pxList->uiColorHlBackground = 0x0000;
  pxList->xWorkRect.x1 = 25;
  pxList->xWorkRect.x2 = 215;
  pxList->xWorkRect.y1 = 25;
  pxList->xWorkRect.y2 = 135;
  wvisCustomListInit(pxList);
  
  if (wMountDrive() != FR_OK) 
	  wDrawString(xLCD, xFont,"DRIVE NOT MOUNTED      ",xRLCD, dwShift(0, 0), 0xFF);
  if (wDirOpen(directory, "")!= FR_OK) 
      {
	  wDrawString(xLCD, xFont,"DIRECTORY NOT MOUNTED      ",xRLCD, dwShift(0, 7), 0xFF);
      return (-1);
	  }

  char *sNew;
	
  rootdir:;
  
  while (wDirRead (directory, fileinfo)==FR_OK) 
    {
    if (fileinfo->fname[0]==0) break; 
    if (fileinfo->flfn[0]!=0) 
	  {
	  sNew = wMalloc (sizeof(char)*256);
	  strcpy (sNew, &(fileinfo->flfn));
	  wStringListAdd(pxList->pxItems, sNew);
	  }
      else 
	  {
      sNew = wMalloc (sizeof(char)*12);
	  strcpy (sNew, &(fileinfo->fname));
	  wStringListAdd(pxList->pxItems, sNew);
	  }
    }
  wvisCustomListRefresh(pxList);
    
  char *sPath = wMalloc(sizeof(char)*256);
  *sPath=NULL;
  u32 ulPathLength = 0;
  while(1)
    {
	switch (*pdatg)
	  {
      case _FORWARD:
		  {
		  pxList->lItemIndex++;
          wvisCustomListRefresh(pxList);
          while (1)
		    {
			if (*pdatg != _FORWARD)
			  {
			  wDelayMs(15);
              if (*pdatg != _FORWARD) break;
			  }
			}
		  break;
		  }
        case _REVERSE:
		  {
		  pxList->lItemIndex--;
          wvisCustomListRefresh(pxList);
          while (1)
		    {
			if (*pdatg != _REVERSE)
			  {
			  wDelayMs(15);
              if (*pdatg != _REVERSE) break;
			  }
			}
		  break;
		  }
	    case _STAR:
	      {
		  wStringListClear(pxList->pxItems);
		  pxList->lItemIndex = 0;
		  if (wDirOpen(directory, "")!= FR_OK)
			{
			wDrawString(xLCD, xFont,"DIRECTORY NOT MOUNTED      ",xRLCD, dwShift(0, 7), 0x0FF0);
	        return (-1);
			}
  		  goto rootdir;
		  }
	  
	    case _PLAY:
		  {
          if (wDirOpen(directory, sPath)!= FR_OK) 
		    wDrawString(xLCD, xFont,"DIRECTORY NOT MOUNTED      ",xRLCD, dwShift(0, 7), 0x0FF0);
		  u32 i;
		  for (i=0; i<pxList->lItemIndex+1; i++)
		    if (wDirRead (directory, fileinfo)==FR_OK);
			  else break;
		  if (fileinfo->fattrib & AM_DIR)
		     {
             *(sPath + ulPathLength) = '\\';
		     strcpy(sPath + ulPathLength + 1, &(fileinfo->fname));
		     ulPathLength+=strlen(&(fileinfo->fname))+1;
		     *(sPath + ulPathLength + 2) = NULL;
             if (wDirOpen(directory, sPath)!= FR_OK) 
		       wDrawString(xLCD, xFont,"DIRECTORY NOT MOUNTED      ",xRLCD, dwShift(0, 7), 0x0FF0);
               else
			     {
				 wStringListClear(pxList->pxItems);
				 while (wDirRead (directory, fileinfo)==FR_OK) 
                   {
                   if (fileinfo->fname[0]==0) break; 
                   if (fileinfo->flfn[0]!=0) 
		             {
			         sNew = wMalloc (sizeof(char)*256);
			         strcpy (sNew, &(fileinfo->flfn));
			         wStringListAdd(pxList->pxItems, sNew);
			         }
                      else 
		             {
                     sNew = wMalloc (sizeof(char)*12);
			         strcpy (sNew, &(fileinfo->fname));
	       		     wStringListAdd(pxList->pxItems, sNew);
		        	 }
                   }
				  }
			  }
			else
			{
             *(sPath + ulPathLength) = '\\';
			 u32 ulOPathLength = ulPathLength;
		     strcpy(sPath + ulPathLength + 1, &(fileinfo->fname));
		     ulPathLength+=strlen(&(fileinfo->fname));
		     if (wNotepad(sPath)<0) 
			   wDrawString(xLCD, xFont,"Error in notepad",xRLCD, dwShift(0, 7), 0x0FF0);
			 ulPathLength = ulOPathLength;
             *(sPath + ulPathLength) = NULL;
			 wClear (xLCD, 0x0000);
			}
		  while(1)
		    {
			if (*pdatg != _PLAY)
			  {
			  wDelayMs(15);
              if (*pdatg != _PLAY) break;
			  }
		    }
		  pxList->lItemIndex = 0;
		  wvisCustomListRefresh(pxList);
		  break;
		  }
	  }
    }
}
//-------------------------------------------------------
int main(void) {
    wCPUInit();
    wLCDInit();
	wMMCInit();
	//while (!wMMCReset());

	xLCD = wMalloc(sizeof(xTBitmap));
	xRLCD = wMalloc(sizeof(xTRectangle));
	xFont = wMalloc(sizeof(xTFont));
	xRLCD->x1 = 0;
	xRLCD->x2 = 240;
	xRLCD->y1 = 0;
	xRLCD->y2 = 160;
	wLCDBitmapInit(xLCD);
	wFontInit(xFont);
    wClear (xLCD, 0x0000);
    wDrawString(xLCD, xFont, "Juicebox Hack v0.4.1",xRLCD, dwShift(73, 80), 0x0FF);
	
	
	  
	wMMCInit();
	while (wMMCReset()!=0);

    wDrawString(xLCD, xFont, "Press play to open dir",xRLCD, dwShift(59, 150), 0x0FF);

    /*wIISDMATransferInit((u32*)&sample, 16*8*2, 0x00000001);
	while(1);*/
    /*
	FIL *file = wMalloc(sizeof(FIL));
	if (wFileOpen (file, "\A.MP3", FA_READ)!=FR_OK)
	{
	  wDrawString(xLCD, xFont, "File not opened",xRLCD, dwShift(59, 150), 0x0FF);
      while(1);
    }
	u08 *pBuffer = wMalloc(sizeof(u08)*16000);
	wMP3Init(pBuffer, 16000);
	wMP3Alloc();
	wMP3Process(file);/**/
	/*while(1)
	  if (*pdatg== _PLAY)
	    {
		while(1)
		  if (*pdatg != _PLAY)
			{
			wDelayMs(15);
            if (*pdatg != _PLAY) break;
			}
		break;
		}
*/
	if(wExplorer()<0)
	  {
	  //wDelayMs(1000);
      wClear (xLCD, 0x0000);
      wDrawString(xLCD, xFont, "Erroneus return",xRLCD, dwShift(73, 80), 0x0FF); 
	  }
	else 
	  {
	  wClear (xLCD, 0x0000);
      wDrawString(xLCD, xFont, "Good return",xRLCD, dwShift(73, 80), 0x0FF); 
	  }
	while(1)
	  {
	  asm("NOP");
	  }
    */
  //*/
	//wInterruptInit();
   /*
    wClear (xLCD, 0x0000);
    u16 *addr, *dest;
    dest = 0x00000000;
    for (addr = 0x0C000000; addr<0x0C100000; addr++)
      {
      *((u16*)0x0000aaaa) = (u16) 0xAAAA;
      *((u16*)0x00005554) = (u16) 0x5555;
      *((u16*)0x0000aaaa) = (u16) 0xa0a0;
      *dest = *addr;
      dest++;
      delay_cycles(660);
      draw_hex32((u32)addr,0, 0, 0x1C);
      }
    
    *//*
    xTaskCreate( wTask, "NAME", 2048, 0, tskIDLE_PRIORITY, NULL );
    vTaskStartScheduler();*/
    //wClearLCD();
	/*wClear(xLCD, 0x0F00);
    wDrawString(xLCD, xFont, "Juicebox Hack v0.2.1",xRLCD, dwShift(73, 80), 0x0FF);
    wDrawString(xLCD, xFont, "Press play to color demo",xRLCD, dwShift(59, 150), 0x0FF);
    while (1) {
        if (*pdatg==_PLAY)
          {
          wFloodFill (0,0,10,10,  0x0000);
          wFloodFill (10,0,20,10, 0x0100);
          wFloodFill (20,0,30,10, 0x0200);
          wFloodFill (30,0,40,10, 0x0300);
          wFloodFill (40,0,50,10, 0x0400);
          wFloodFill (50,0,60,10, 0x0500);
          wFloodFill (60,0,70,10, 0x0600);
          wFloodFill (70,0,80,10, 0x0700);
          wFloodFill (100,0,110,10, 0x0800);
          wFloodFill (110,0,120,10, 0x0900);
          wFloodFill (120,0,130,10, 0x0a00);
          wFloodFill (130,0,140,10, 0x0b00);
          wFloodFill (140,0,150,10, 0x0c00);
          wFloodFill (150,0,160,10, 0x0d00);
          wFloodFill (160,0,170,10, 0x0e00);
          wFloodFill (170,0,180,10, 0x0f00);

          wFloodFill (0, 10,10,20, 0x0000);
          wFloodFill (10,10,20,20, 0x0010);
          wFloodFill (20,10,30,20, 0x0020);
          wFloodFill (30,10,40,20, 0x0030);
          wFloodFill (40,10,50,20, 0x0040);
          wFloodFill (50,10,60,20, 0x0050);
          wFloodFill (60,10,70,20, 0x0060);
          wFloodFill (70,10,80,20, 0x0070);
          wFloodFill (100, 10,110,20, 0x0080);
          wFloodFill (110,10,120,20, 0x0090);
          wFloodFill (120,10,130,20, 0x00a0);
          wFloodFill (130,10,140,20, 0x00b0);
          wFloodFill (140,10,150,20, 0x00c0);
          wFloodFill (150,10,160,20, 0x00d0);
          wFloodFill (160,10,170,20, 0x00e0);
          wFloodFill (170,10,180,20, 0x00f0);

          wFloodFill (0, 20,10,30, 0x0000);
          wFloodFill (10,20,20,30, 0x0001);
          wFloodFill (20,20,30,30, 0x0002);
          wFloodFill (30,20,40,30, 0x0003);
          wFloodFill (40,20,50,30, 0x0004);
          wFloodFill (50,20,60,30, 0x0005);
          wFloodFill (60,20,70,30, 0x0006);
          wFloodFill (70,20,80,30, 0x0007);
          wFloodFill (100, 20,110,30, 0x0008);
          wFloodFill (110,20,120,30, 0x0009);
          wFloodFill (120,20,130,30, 0x000a);
          wFloodFill (130,20,140,30, 0x000b);
          wFloodFill (140,20,150,30, 0x000c);
          wFloodFill (150,20,160,30, 0x000d);
          wFloodFill (160,20,170,30, 0x000e);
          wFloodFill (170,20,180,30, 0x000f);

           
          }}
    /*wDrawString("Juicebox Hack v0.1.3", 0, 0, 0x0FFF);
    wDrawString("Press play to open dir", 0, 7, 0x0FFF);
    
    DIR *directory = wMalloc (sizeof(DIR));
    FILINFO *fileinfo = wMalloc (sizeof(FILINFO));

    if (wMountDrive() != FR_OK) wDrawString("DRIVE NOT MOUNTED      ", 0, 0, 0x0FFF);

    u32 y;
    if (wDirOpen(directory, "")!= FR_OK) wDrawString("DIRECTORY NOT MOUNTED      ", 0, 7, 0x0FFF);
    while (1) {
        switch (*pdatg)
        {
        case _PLAY:
          {
          y = 14;
          while (wDirRead (directory, fileinfo)==FR_OK) 
            {
            if (fileinfo->fname[0]==0) break; 
            {if (fileinfo->flfn[0]!=0) wDrawString (fileinfo->flfn, 0, y, 0x0FFF);
               else                    wDrawString (fileinfo->fname, 0, y, 0x0FFF);
            }
            wDrawString ("Size", 0, y+7, 0xFC);
            wDrawNumber (fileinfo->fsize, 5, 50, y+7, 0x0FFF);
            y+=14;
            }
          }
        default: break;
        }
      }
    /**//*
	u32 sector = 0;
	u08 *addr0 = wMalloc(512);
    u08 *addr = addr0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -