From d2100979fd519b40c61dbdc6808120755513c88a Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 4 Nov 2015 18:17:04 +0100 Subject: cleanups --- Makefile | 87 +++-- src/VOIMAGE.CPP | 281 -------------- src/VOIMAGE.H | 84 ----- src/config.c | 39 -- src/config.h | 18 - src/giz_kgsdk.c | 343 ----------------- src/giz_kgsdk.h | 58 --- src/giz_kgsdkasm.s | 107 ------ src/giz_sdk_kgsdk.c | 343 ----------------- src/giz_sdk_kgsdk.h | 64 ---- src/gp2x_highlightbar.c | 341 ----------------- src/gp2x_menu_header.c | 983 ------------------------------------------------ src/gp2x_menutile.c | 277 -------------- src/gp2x_sdk.c | 767 ------------------------------------- src/gp2x_sdk.h | 68 ---- src/gp32_func.h | 13 - src/graphics.c | 316 ---------------- src/graphics.h | 57 --- src/gx.h | 83 ---- src/ppu.h | 2 +- src/screenshot.c | 71 ---- src/screenshot.h | 19 - src/snes9x.h | 4 + src/srtc.h | 4 +- src/theme.c | 165 -------- src/theme.h | 32 -- src/touchscreen.c | 47 --- src/touchscreen.h | 10 - src/usbjoy.c | 297 --------------- src/usbjoy.h | 221 ----------- src/wiz_mmuhack.c | 28 -- src/wiz_sdk.c | 752 ------------------------------------ src/wiz_sdk.h | 64 ---- 33 files changed, 49 insertions(+), 5996 deletions(-) delete mode 100644 src/VOIMAGE.CPP delete mode 100644 src/VOIMAGE.H delete mode 100644 src/config.c delete mode 100644 src/config.h delete mode 100644 src/giz_kgsdk.c delete mode 100644 src/giz_kgsdk.h delete mode 100644 src/giz_kgsdkasm.s delete mode 100644 src/giz_sdk_kgsdk.c delete mode 100644 src/giz_sdk_kgsdk.h delete mode 100644 src/gp2x_highlightbar.c delete mode 100644 src/gp2x_menu_header.c delete mode 100644 src/gp2x_menutile.c delete mode 100644 src/gp2x_sdk.c delete mode 100644 src/gp2x_sdk.h delete mode 100644 src/gp32_func.h delete mode 100644 src/graphics.c delete mode 100644 src/graphics.h delete mode 100644 src/gx.h delete mode 100644 src/screenshot.c delete mode 100644 src/screenshot.h delete mode 100644 src/theme.c delete mode 100644 src/theme.h delete mode 100644 src/touchscreen.c delete mode 100644 src/touchscreen.h delete mode 100644 src/usbjoy.c delete mode 100644 src/usbjoy.h delete mode 100644 src/wiz_mmuhack.c delete mode 100644 src/wiz_sdk.c delete mode 100644 src/wiz_sdk.h diff --git a/Makefile b/Makefile index 326d610..ea1afb1 100644 --- a/Makefile +++ b/Makefile @@ -81,50 +81,49 @@ OBJECTS += ./src/cheats.o OBJECTS += ./src/cheats2.o OBJECTS += ./src/clip.o OBJECTS += ./src/data.o -OBJECTS += ./src/screenshot.o -OBJECTS += ./src/dsp1.o -OBJECTS += ./src/fxemu.o -OBJECTS += ./src/fxinst.o -OBJECTS += ./src/globals.o -OBJECTS += ./src/loadzip.o -OBJECTS += ./src/ppu.o -OBJECTS += ./src/dma.o -OBJECTS += ./src/memmap.o -OBJECTS += ./src/cpu.o -OBJECTS += ./src/cpuexec.o -OBJECTS += ./src/cpuops.o -OBJECTS += ./src/sa1.o -OBJECTS += ./src/sa1cpu.o -OBJECTS += ./src/sdd1.o -OBJECTS += ./src/sdd1emu.o -OBJECTS += ./src/snapshot.o -OBJECTS += ./src/soundux.o -OBJECTS += ./src/spc700.o -OBJECTS += ./src/spc700a.o -OBJECTS += ./src/srtc.o -OBJECTS += ./src/spc_decode.o -OBJECTS += ./src/tile16.o -OBJECTS += ./src/tile16add.o -OBJECTS += ./src/tile16add1_2.o -OBJECTS += ./src/tile16fadd1_2.o -OBJECTS += ./src/tile16sub.o -OBJECTS += ./src/tile16sub1_2.o -OBJECTS += ./src/tile16fsub1_2.o -OBJECTS += ./src/mode7new.o -OBJECTS += ./src/mode7.o -OBJECTS += ./src/mode7add.o -OBJECTS += ./src/mode7add1_2.o -OBJECTS += ./src/mode7sub.o -OBJECTS += ./src/mode7sub1_2.o -OBJECTS += ./src/mode7prio.o -OBJECTS += ./src/mode7addprio.o -OBJECTS += ./src/mode7add1_2prio.o -OBJECTS += ./src/mode7subprio.o -OBJECTS += ./src/mode7sub1_2prio.o -OBJECTS += ./src/gfx16.o -OBJECTS += ./src/rops.o -OBJECTS += ./libretro/libretro.o -OBJECTS += ./libretro/memstream.o +OBJECTS += ./src/dsp1.o +OBJECTS += ./src/fxemu.o +OBJECTS += ./src/fxinst.o +OBJECTS += ./src/globals.o +OBJECTS += ./src/loadzip.o +OBJECTS += ./src/ppu.o +OBJECTS += ./src/dma.o +OBJECTS += ./src/memmap.o +OBJECTS += ./src/cpu.o +OBJECTS += ./src/cpuexec.o +OBJECTS += ./src/cpuops.o +OBJECTS += ./src/sa1.o +OBJECTS += ./src/sa1cpu.o +OBJECTS += ./src/sdd1.o +OBJECTS += ./src/sdd1emu.o +OBJECTS += ./src/snapshot.o +OBJECTS += ./src/soundux.o +OBJECTS += ./src/spc700.o +OBJECTS += ./src/spc700a.o +OBJECTS += ./src/srtc.o +OBJECTS += ./src/spc_decode.o +OBJECTS += ./src/tile16.o +OBJECTS += ./src/tile16add.o +OBJECTS += ./src/tile16add1_2.o +OBJECTS += ./src/tile16fadd1_2.o +OBJECTS += ./src/tile16sub.o +OBJECTS += ./src/tile16sub1_2.o +OBJECTS += ./src/tile16fsub1_2.o +OBJECTS += ./src/mode7new.o +OBJECTS += ./src/mode7.o +OBJECTS += ./src/mode7add.o +OBJECTS += ./src/mode7add1_2.o +OBJECTS += ./src/mode7sub.o +OBJECTS += ./src/mode7sub1_2.o +OBJECTS += ./src/mode7prio.o +OBJECTS += ./src/mode7addprio.o +OBJECTS += ./src/mode7add1_2prio.o +OBJECTS += ./src/mode7subprio.o +OBJECTS += ./src/mode7sub1_2prio.o +OBJECTS += ./src/gfx16.o +OBJECTS += ./src/rops.o +OBJECTS += ./libretro/libretro.o +OBJECTS += ./libretro/memstream.o INCLUDES = -I. -Ilibretro DEFINES = -DHAVE_STRINGS_H -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DINLINE=inline -DUSE_SA1 diff --git a/src/VOIMAGE.CPP b/src/VOIMAGE.CPP deleted file mode 100644 index 230d707..0000000 --- a/src/VOIMAGE.CPP +++ /dev/null @@ -1,281 +0,0 @@ -//------------------------------------------------------------------- -// VOImage implementation -//------------------------------------------------------------------- -// -// Copyright ©2000 Virtual Office Systems Incorporated -// All Rights Reserved -// -// This code may be used in compiled form in any way you desire. This -// file may be redistributed unmodified by any means PROVIDING it is -// not sold for profit without the authors written consent, and -// providing that this notice and the authors name is included. -// -// This code can be compiled, modified and distributed freely, providing -// that this copyright information remains intact in the distribution. -// -// This code may be compiled in original or modified form in any private -// or commercial application. -// -// This file is provided "as is" with no expressed or implied warranty. -// The author accepts no liability for any damage, in any form, caused -// by this code. Use it at your own risk. -//------------------------------------------------------------------- - -#include "stdafx.h" - -#include "VOImage.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -HDC CVOImage::g_hdc; -int CVOImage::g_iScale = 100; -int CVOImage::g_iMaxWidth = 10000; -int CVOImage::g_iMaxHeight = 10000; -BOOL CVOImage::g_bStretchBlt = FALSE; - -CVOImage::CVOImage() -{ - m_hbitmap = 0; -} - -CVOImage::~CVOImage() -{ - if(m_hbitmap) - DeleteObject(m_hbitmap); -} - -BOOL CVOImage::Load(HDC hdc, LPCTSTR pcszFileName) -{ - if(m_hbitmap) - DeleteObject(m_hbitmap); - - if(!g_hdc) - g_hdc = CreateCompatibleDC(hdc); - - HRESULT hr; - BYTE szBuffer[1024] = {0}; - HANDLE hFile = INVALID_HANDLE_VALUE; - - DecompressImageInfo dii; - - hFile = CreateFile(pcszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - if (hFile == INVALID_HANDLE_VALUE) - return FALSE; - - // Fill in the 'DecompressImageInfo' structure - dii.dwSize = sizeof( DecompressImageInfo ); // Size of this structure - dii.pbBuffer = szBuffer; // Pointer to the buffer to use for data - dii.dwBufferMax = 1024; // Size of the buffer - dii.dwBufferCurrent = 0; // The amount of data which is current in the buffer - dii.phBM = &m_hbitmap; // Pointer to the bitmap returned (can be NULL) - dii.ppImageRender = NULL; // Pointer to an IImageRender object (can be NULL) - dii.iBitDepth = GetDeviceCaps(hdc,BITSPIXEL); // Bit depth of the output image - dii.lParam = ( LPARAM ) hFile; // User parameter for callback functions - dii.hdc = g_hdc; // HDC to use for retrieving palettes - dii.iScale = g_iScale; // Scale factor (1 - 100) - dii.iMaxWidth = g_iMaxWidth; // Maximum width of the output image - dii.iMaxHeight = g_iMaxHeight; // Maxumum height of the output image - dii.pfnGetData = GetImageData; // Callback function to get image data - dii.pfnImageProgress = ImageProgress; // Callback function to notify caller of progress decoding the image - dii.crTransparentOverride = ( UINT ) -1; // If this color is not (UINT)-1, it will override the - // transparent color in the image with this color. (GIF ONLY) - - // Process and decompress the image data - hr = DecompressImageIndirect( &dii ); - - // Clean up - CloseHandle( hFile ); - - BITMAP bmp; - - GetObject(m_hbitmap, sizeof(BITMAP), &bmp); - - m_dwWidth = bmp.bmWidth; - m_dwHeight = bmp.bmHeight; - - return TRUE; -} - -HBITMAP CVOImage::Copy() -{ - BITMAP bm, bmNew; - HBITMAP hNew; - - SelectObject(g_hdc, m_hbitmap); - - ::GetObject(m_hbitmap, sizeof(BITMAP), &bm); - - HDC hdc = CreateCompatibleDC(g_hdc); - hNew = CreateCompatibleBitmap(g_hdc, bm.bmWidth, bm.bmHeight); - SelectObject(hdc, hNew); - - if(BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, g_hdc, 0, 0, SRCCOPY)) - { - HBITMAP hPrev = (HBITMAP) ::GetObject(hNew, sizeof(BITMAP), &bmNew); - - ::SelectObject(hdc, hPrev); - } - - DeleteDC(hdc); - return hNew; -} - -BOOL CVOImage::Draw(HDC hdc, int x, int y, int cx, int cy) -{ - BITMAP bmp; - HGDIOBJ hOldBitmap; - - g_bStretchBlt = !(cx == -1 && cy == -1); - hOldBitmap = SelectObject(g_hdc, m_hbitmap); - GetObject(m_hbitmap, sizeof(BITMAP), &bmp); - - if (g_bStretchBlt) - { - // Stretch to fit - StretchBlt(hdc, x , y, cx, cy, g_hdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY ); - } - else - { - BitBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, g_hdc,0,0,SRCCOPY ); - } - - SelectObject(g_hdc, hOldBitmap); - - return TRUE; -} - -DWORD CVOImage::GetHeight() -{ - return m_dwHeight; -} - -DWORD CVOImage::GetWidth() -{ - return m_dwWidth; -} - -BOOL CVOImage::SetBitmap(HDC hdc, DWORD dwResourceID, LPCTSTR pcszClass, HMODULE hModule) -{ - if(!g_hdc) - g_hdc = CreateCompatibleDC(hdc); - - HRESULT hr; - BYTE szBuffer[1024] = {0}; - DecompressImageInfo dii; - - CVOResource res(hModule, dwResourceID, pcszClass); - - if(!res.IsLoaded()) - return FALSE; - - res.SetUserData(0); // Use this for the current resource offset - - // Fill in the 'DecompressImageInfo' structure - dii.dwSize = sizeof( DecompressImageInfo ); // Size of this structure - dii.pbBuffer = szBuffer; // Pointer to the buffer to use for data - dii.dwBufferMax = 1024; // Size of the buffer - dii.dwBufferCurrent = 0; // The amount of data which is current in the buffer - dii.phBM = &m_hbitmap; // Pointer to the bitmap returned (can be NULL) - dii.ppImageRender = NULL; // Pointer to an IImageRender object (can be NULL) - dii.iBitDepth = GetDeviceCaps(hdc,BITSPIXEL); // Bit depth of the output image - dii.lParam = ( LPARAM ) &res; // User parameter for callback functions - dii.hdc = g_hdc; // HDC to use for retrieving palettes - dii.iScale = g_iScale; // Scale factor (1 - 100) - dii.iMaxWidth = g_iMaxWidth; // Maximum width of the output image - dii.iMaxHeight = g_iMaxHeight; // Maxumum height of the output image - dii.pfnGetData = GetImageResourceData; // Callback function to get image data - dii.pfnImageProgress = ImageProgress; // Callback function to notify caller of progress decoding the image - dii.crTransparentOverride = ( UINT ) -1; // If this color is not (UINT)-1, it will override the - // transparent color in the image with this color. (GIF ONLY) - // Process and decompress the image data - hr = DecompressImageIndirect( &dii ); - - BITMAP bmp; - - GetObject(m_hbitmap, sizeof(BITMAP), &bmp); - - m_dwWidth = bmp.bmWidth; - m_dwHeight = bmp.bmHeight; - - return TRUE; -} - -DWORD CALLBACK CVOImage::GetImageData(LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam ) -{ - DWORD dwNumberOfBytesRead; - - if ( (HANDLE)lParam == INVALID_HANDLE_VALUE ) - return 0; - - ReadFile( (HANDLE)lParam, szBuffer, dwBufferMax, &dwNumberOfBytesRead, NULL ); - - // Return number of bytes read - return dwNumberOfBytesRead; -} - -DWORD CALLBACK CVOImage::GetImageResourceData(LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam) -{ - DWORD dwNumberOfBytesToRead = dwBufferMax; - CVOResource* pRes = (CVOResource*) lParam; - - if(!pRes) - return 0; - - DWORD dwResourceOffset = pRes->GetUserData(); - - if(dwResourceOffset + dwNumberOfBytesToRead > pRes->GetSize() ) - dwNumberOfBytesToRead = pRes->GetSize() - dwResourceOffset; - - memmove(szBuffer, pRes->GetData() + dwResourceOffset, dwNumberOfBytesToRead); - - pRes->SetUserData(dwResourceOffset + dwNumberOfBytesToRead); - return dwNumberOfBytesToRead; // return amount read -} - -void CALLBACK CVOImage::ImageProgress(IImageRender *pRender, BOOL bComplete, LPARAM lParam ) -{ - if( bComplete ) - { - ;// (Optional) add code here for completion processing - } -} - -BOOL CVOImage::IsLoaded() -{ - return (m_hbitmap != 0); -} - -CVOResource::CVOResource(HMODULE hModule, DWORD dwResourceID, LPCTSTR pcszClass) -{ - m_dwSize = 0; - m_hGlobal = 0; - m_pData = 0; - - m_hrsrc = FindResource(hModule, (LPCWSTR)dwResourceID, pcszClass); - - if(m_hrsrc == 0) - return; - - m_dwSize = SizeofResource(hModule, m_hrsrc); - m_hGlobal = LoadResource(hModule, m_hrsrc); - m_pData = (PBYTE) LockResource(m_hGlobal); -} - -CVOResource::~CVOResource() -{ - if(m_hGlobal) - DeleteObject(m_hGlobal); -} - -BOOL CVOResource::IsLoaded() -{ - return (m_pData != NULL); -} diff --git a/src/VOIMAGE.H b/src/VOIMAGE.H deleted file mode 100644 index 2825b58..0000000 --- a/src/VOIMAGE.H +++ /dev/null @@ -1,84 +0,0 @@ -//------------------------------------------------------------------- -// VOImage Header File -//------------------------------------------------------------------- -// -// Copyright ©2000 Virtual Office Systems Incorporated -// All Rights Reserved -// -// This code may be used in compiled form in any way you desire. This -// file may be redistributed unmodified by any means PROVIDING it is -// not sold for profit without the authors written consent, and -// providing that this notice and the authors name is included. -// -// This code can be compiled, modified and distributed freely, providing -// that this copyright information remains intact in the distribution. -// -// This code may be compiled in original or modified form in any private -// or commercial application. -// -// This file is provided "as is" with no expressed or implied warranty. -// The author accepts no liability for any damage, in any form, caused -// by this code. Use it at your own risk. -//------------------------------------------------------------------- - -#if !defined(AFX_VOIMAGE_H__B83C4202_DB1E_48BE_92A5_21019F9EE6FC__INCLUDED_) -#define AFX_VOIMAGE_H__B83C4202_DB1E_48BE_92A5_21019F9EE6FC__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "imgdecmp.h" - -class CVOResource -{ -public: - CVOResource(HMODULE hModule, DWORD dwResourceID, LPCTSTR pcszClass); - ~CVOResource(); - - BOOL IsLoaded(); - - DWORD GetSize() { return m_dwSize; } - PBYTE GetData() { return m_pData; } - - void SetUserData(DWORD dwValue) { m_dwUser = dwValue; } - DWORD GetUserData() { return m_dwUser; } - -protected: - DWORD m_dwUser; - - DWORD m_dwSize; - PBYTE m_pData; - HGLOBAL m_hGlobal; - HRSRC m_hrsrc; -}; - -class CVOImage -{ -public: - HBITMAP Copy(); - static DWORD CALLBACK GetImageResourceData(LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam); - BOOL IsLoaded(); - static void CALLBACK ImageProgress( IImageRender *, BOOL, LPARAM); - static DWORD CALLBACK GetImageData( LPSTR, DWORD, LPARAM); - BOOL SetBitmap(HDC hdc, DWORD dwResourceID, LPCTSTR pcszClass = TEXT("IMAGE"), HMODULE hModule = 0 ); - DWORD GetWidth(); - DWORD GetHeight(); - BOOL Draw(HDC hdc, int x, int y, int cx = -1, int cy = -1); - BOOL Load(HDC hdc, LPCTSTR pcszFileName); - CVOImage(); - virtual ~CVOImage(); - operator HBITMAP() { return m_hbitmap; } - -protected: - DWORD m_dwHeight; - DWORD m_dwWidth; - HBITMAP m_hbitmap; - static BOOL g_bStretchBlt; - static int g_iMaxHeight; - static int g_iMaxWidth; - static int g_iScale; - static HDC g_hdc; -}; - -#endif // !defined(AFX_VOIMAGE_H__B83C4202_DB1E_48BE_92A5_21019F9EE6FC__INCLUDED_) diff --git a/src/config.c b/src/config.c deleted file mode 100644 index 174ef58..0000000 --- a/src/config.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include "minIni.h" -#include "menu.h" -#include "port.h" -#include "config.h" - -static char *cfgEntry_lastLoaded = "last_loaded"; -static char *cfgEntry_theme = "theme"; -static char *cfgFile = "config.ini"; -static char *cfgSection_general = "general"; - -void getConfigValue(unsigned int value, char *buffer, int bfsz) { - char fp_cfgFile[_MAX_PATH]; - sprintf(fp_cfgFile, "%s/%s", snesOptionsDir, cfgFile); - - switch(value) { - case CONFIG_LASTLOADED: - ini_gets(cfgSection_general, cfgEntry_lastLoaded, "\0", buffer, bfsz, fp_cfgFile); - break; - case CONFIG_THEME: - ini_gets(cfgSection_general, cfgEntry_theme, "default", buffer, bfsz, fp_cfgFile); - break; - } -} - -void setConfigValue(unsigned int value, char *ll) { - char fp_cfgFile[_MAX_PATH]; - sprintf(fp_cfgFile, "%s/%s", snesOptionsDir, cfgFile); - - switch(value) { - case CONFIG_LASTLOADED: - ini_puts(cfgSection_general, cfgEntry_lastLoaded, ll, fp_cfgFile); - break; - case CONFIG_THEME: - ini_puts(cfgSection_general, cfgEntry_theme, ll, fp_cfgFile); - break; - } -} - diff --git a/src/config.h b/src/config.h deleted file mode 100644 index e41a308..0000000 --- a/src/config.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define CONFIG_LASTLOADED 0 -#define CONFIG_THEME 1 - -void getConfigValue(unsigned int value, char *buffer, int bfsz); -void setConfigValue(unsigned int value, char *ll); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/giz_kgsdk.c b/src/giz_kgsdk.c deleted file mode 100644 index 2bfa6b4..0000000 --- a/src/giz_kgsdk.c +++ /dev/null @@ -1,343 +0,0 @@ - -#include -#include "giz_kgsdk.h" -#include - -unsigned short *framebuffer16[4]={0,0,0,0}; -unsigned char *framebuffer8[4]; -void *GizPrimaryFrameBuffer=NULL; -volatile unsigned short gp2x_palette[512][2]; -int Timer=0; -static int bppMode = 16; -static unsigned int padValues[2]={0,0}; - -//Temp framebuffer -unsigned short frameBufferMemory[320*250]; - -// 1024x8 8x8 font, i love it :) -const unsigned int font8x8[]= {0x0,0x0,0xc3663c18,0x3c2424e7,0xe724243c,0x183c66c3,0xc16f3818,0x18386fc1,0x83f61c18,0x181cf683,0xe7c3993c,0x3c99c3,0x3f7fffff,0xe7cf9f,0x3c99c3e7,0xe7c399,0x3160c080,0x40e1b,0xcbcbc37e, -0x7ec3c3db,0x3c3c3c18,0x81c087e,0x8683818,0x60f0e08,0x81422418,0x18244281,0xbd5a2418,0x18245abd,0x818181ff,0xff8181,0xa1c181ff,0xff8995,0x63633e,0x3e6363,0x606060,0x606060,0x3e60603e,0x3e0303,0x3e60603e,0x3e6060,0x3e636363, -0x606060,0x3e03033e,0x3e6060,0x3e03033e,0x3e6363,0x60603e,0x606060,0x3e63633e,0x3e6363,0x3e63633e,0x3e6060,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18181818,0x180018,0x666666,0x0,0x367f3600,0x367f36,0x3c067c18, -0x183e60,0x18366600,0x62660c,0xe1c361c,0x6e337b,0x181818,0x0,0x18183870,0x703818,0x18181c0e,0xe1c18,0xff3c6600,0x663c,0x7e181800,0x1818,0x0,0x60c0c00,0x7e000000,0x0,0x0,0x181800,0x18306040,0x2060c,0x6e76663c,0x3c6666,0x18181c18, -0x7e1818,0x3060663c,0x7e0c18,0x3018307e,0x3c6660,0x363c3830,0x30307e,0x603e067e,0x3c6660,0x3e06063c,0x3c6666,0x1830607e,0xc0c0c,0x3c66663c,0x3c6666,0x7c66663c,0x1c3060,0x181800,0x1818,0x181800,0xc1818,0xc183060,0x603018,0x7e0000, -0x7e00,0x30180c06,0x60c18,0x3060663c,0x180018,0x5676663c,0x7c0676,0x66663c18,0x66667e,0x3e66663e,0x3e6666,0x606663c,0x3c6606,0x6666361e,0x1e3666,0x3e06067e,0x7e0606,0x3e06067e,0x60606,0x7606067c,0x7c6666,0x7e666666,0x666666,0x1818183c, -0x3c1818,0x60606060,0x3c6660,0xe1e3666,0x66361e,0x6060606,0x7e0606,0x6b7f7763,0x636363,0x7e7e6e66,0x666676,0x6666663c,0x3c6666,0x3e66663e,0x60606,0x6666663c,0x6c366e,0x3e66663e,0x666636,0x3c06663c,0x3c6660,0x1818187e,0x181818,0x66666666, -0x7c6666,0x66666666,0x183c66,0x6b636363,0x63777f,0x183c6666,0x66663c,0x3c666666,0x181818,0x1830607e,0x7e060c,0x18181878,0x781818,0x180c0602,0x406030,0x1818181e,0x1e1818,0x63361c08,0x0,0x0,0x7f0000,0xc060300,0x0,0x603c0000,0x7c667c,0x663e0606, -0x3e6666,0x63c0000,0x3c0606,0x667c6060,0x7c6666,0x663c0000,0x3c067e,0xc3e0c38,0xc0c0c,0x667c0000,0x3e607c66,0x663e0606,0x666666,0x181c0018,0x3c1818,0x18180018,0xe181818,0x36660606,0x66361e,0x1818181c,0x3c1818,0x7f370000,0x63636b,0x663e0000, -0x666666,0x663c0000,0x3c6666,0x663e0000,0x63e6666,0x667c0000,0x607c6666,0x663e0000,0x60606,0x67c0000,0x3e603c,0x187e1800,0x701818,0x66660000,0x7c6666,0x66660000,0x183c66,0x63630000,0x363e6b,0x3c660000,0x663c18,0x66660000,0x3e607c66,0x307e0000, -0x7e0c18,0xc181870,0x701818,0x18181818,0x18181818,0x3018180e,0xe1818,0x794f0600,0x30}; - -/* -######################## -Graphics functions -######################## - */ - -static __inline__ -void gp_drawPixel8 ( int x, int y, unsigned char c, unsigned char *framebuffer ) -{ - *(framebuffer +(320*y)+x ) = c; -} - -static __inline__ -void gp_drawPixel16 ( int x, int y, unsigned short c, unsigned short *framebuffer ) -{ - *(framebuffer +(320*y)+x ) = c; -} - -static -void set_char8x8_16bpp (int xx,int yy,int offset,unsigned short mode,unsigned short *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y+4, mode, framebuffer); - - } -} - -static -void set_char8x8_8bpp (int xx,int yy,int offset,unsigned char mode,unsigned char *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel8(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel8(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel8(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel8(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel8(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel8(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel8(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel8(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel8(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel8(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel8(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel8(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel8(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel8(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel8(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel8(xx+7, yy+y+4, mode, framebuffer); - - } -} - -void gp_drawString (int x,int y,int len,char *buffer,unsigned short color,void *framebuffer) -{ - int l,base=0; - - for (l=0;l>1 -1: - ;@ first line is perfectly aligned - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - ldmia r0!,{r2-r11} - stmia r1!,{r2-r11} - - add r1,r1,#2 - - ldmia r0!,{r2-r6} - strh r2,[r1],#2 - mov lr,#15 -2: - mov r2,r2,lsr#16 - orr r2,r2,r3,lsl#16 - mov r3,r3,lsr#16 - orr r3,r3,r4,lsl#16 - mov r4,r4,lsr#16 - orr r4,r4,r5,lsl#16 - mov r5,r5,lsr#16 - orr r5,r5,r6,lsl#16 - mov r6,r6,lsr#16 - ldmia r0!,{r7-r11} - orr r6,r6,r7,lsl#16 - stmia r1!,{r2-r6} - mov r7,r7,lsr#16 - orr r7,r7,r8,lsl#16 - mov r8,r8,lsr#16 - orr r8,r8,r9,lsl#16 - mov r9,r9,lsr#16 - orr r9,r9,r10,lsl#16 - mov r10,r10,lsr#16 - orr r10,r10,r11,lsl#16 - mov r11,r11,lsr#16 - ldmia r0!,{r2-r6} - orr r11,r11,r2,lsl#16 - stmia r1!,{r7-r11} - subs lr,lr,#1 - bne 2b - - mov r2,r2,lsr#16 - orr r2,r2,r3,lsl#16 - mov r3,r3,lsr#16 - orr r3,r3,r4,lsl#16 - mov r4,r4,lsr#16 - orr r4,r4,r5,lsl#16 - mov r5,r5,lsr#16 - orr r5,r5,r6,lsl#16 - mov r6,r6,lsr#16 - ldmia r0!,{r7-r11} - orr r6,r6,r7,lsl#16 - stmia r1!,{r2-r6} - mov r7,r7,lsr#16 - orr r7,r7,r8,lsl#16 - mov r8,r8,lsr#16 - orr r8,r8,r9,lsl#16 - mov r9,r9,lsr#16 - orr r9,r9,r10,lsl#16 - mov r10,r10,lsr#16 - orr r10,r10,r11,lsl#16 - mov r11,r11,lsr#16 - stmia r1!,{r7-r11} - - subs r12,r12,#1 - bne 1b - - ldmfd sp!,{r4-r12,pc} - - - diff --git a/src/giz_sdk_kgsdk.c b/src/giz_sdk_kgsdk.c deleted file mode 100644 index 3cd7ccd..0000000 --- a/src/giz_sdk_kgsdk.c +++ /dev/null @@ -1,343 +0,0 @@ - -#define DEBUG - -#include -#include -#include -#include "giz_sdk_kgsdk.h" -#include - - -#define SYS_CLK_FREQ 7372800 -unsigned long gp2x_ticks_per_second=7372800/1000; -unsigned long gp2x_dev[5]={0,0,0,0,0}; -unsigned long gp2x_physvram[4]={0,0,0,0}; -unsigned short *framebuffer16[4]={0,0,0,0}; -static unsigned short *framebuffer_mmap[4]={0,0,0,0}; -static int fb_size=(320*240*2)+(16*2); -unsigned short *gp2x_logvram15[2], gp2x_sound_buffer[4+((44100*2)*8)]; //*2=stereo, *4=max buffers -volatile unsigned short *gp2x_memregs; -volatile unsigned long *gp2x_memregl; -volatile unsigned long *gp2x_blitter = NULL; -unsigned int *gp2x_intVectors; -volatile unsigned short gp2x_palette[512][2]; -unsigned char *framebuffer8[4], *gp2x_screen8prev, *gp2x_logvram8[2]; -//pthread_t gp2x_sound_thread=0, gp2x_sound_thread_exit=0; -volatile short *pOutput[8]; -unsigned char InitFramebuffer=0; -int Timer=0; -volatile int SoundThreadFlag=0; -volatile int CurrentSoundBank=0; -int CurrentFrameBuffer=0; -int CurrentFrag=0; -unsigned short frameBufferMemory[320*250]; - -//Global SDL objects - -// 1024x8 8x8 font, i love it :) -const unsigned int font8x8[]= {0x0,0x0,0xc3663c18,0x3c2424e7,0xe724243c,0x183c66c3,0xc16f3818,0x18386fc1,0x83f61c18,0x181cf683,0xe7c3993c,0x3c99c3,0x3f7fffff,0xe7cf9f,0x3c99c3e7,0xe7c399,0x3160c080,0x40e1b,0xcbcbc37e, -0x7ec3c3db,0x3c3c3c18,0x81c087e,0x8683818,0x60f0e08,0x81422418,0x18244281,0xbd5a2418,0x18245abd,0x818181ff,0xff8181,0xa1c181ff,0xff8995,0x63633e,0x3e6363,0x606060,0x606060,0x3e60603e,0x3e0303,0x3e60603e,0x3e6060,0x3e636363, -0x606060,0x3e03033e,0x3e6060,0x3e03033e,0x3e6363,0x60603e,0x606060,0x3e63633e,0x3e6363,0x3e63633e,0x3e6060,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18181818,0x180018,0x666666,0x0,0x367f3600,0x367f36,0x3c067c18, -0x183e60,0x18366600,0x62660c,0xe1c361c,0x6e337b,0x181818,0x0,0x18183870,0x703818,0x18181c0e,0xe1c18,0xff3c6600,0x663c,0x7e181800,0x1818,0x0,0x60c0c00,0x7e000000,0x0,0x0,0x181800,0x18306040,0x2060c,0x6e76663c,0x3c6666,0x18181c18, -0x7e1818,0x3060663c,0x7e0c18,0x3018307e,0x3c6660,0x363c3830,0x30307e,0x603e067e,0x3c6660,0x3e06063c,0x3c6666,0x1830607e,0xc0c0c,0x3c66663c,0x3c6666,0x7c66663c,0x1c3060,0x181800,0x1818,0x181800,0xc1818,0xc183060,0x603018,0x7e0000, -0x7e00,0x30180c06,0x60c18,0x3060663c,0x180018,0x5676663c,0x7c0676,0x66663c18,0x66667e,0x3e66663e,0x3e6666,0x606663c,0x3c6606,0x6666361e,0x1e3666,0x3e06067e,0x7e0606,0x3e06067e,0x60606,0x7606067c,0x7c6666,0x7e666666,0x666666,0x1818183c, -0x3c1818,0x60606060,0x3c6660,0xe1e3666,0x66361e,0x6060606,0x7e0606,0x6b7f7763,0x636363,0x7e7e6e66,0x666676,0x6666663c,0x3c6666,0x3e66663e,0x60606,0x6666663c,0x6c366e,0x3e66663e,0x666636,0x3c06663c,0x3c6660,0x1818187e,0x181818,0x66666666, -0x7c6666,0x66666666,0x183c66,0x6b636363,0x63777f,0x183c6666,0x66663c,0x3c666666,0x181818,0x1830607e,0x7e060c,0x18181878,0x781818,0x180c0602,0x406030,0x1818181e,0x1e1818,0x63361c08,0x0,0x0,0x7f0000,0xc060300,0x0,0x603c0000,0x7c667c,0x663e0606, -0x3e6666,0x63c0000,0x3c0606,0x667c6060,0x7c6666,0x663c0000,0x3c067e,0xc3e0c38,0xc0c0c,0x667c0000,0x3e607c66,0x663e0606,0x666666,0x181c0018,0x3c1818,0x18180018,0xe181818,0x36660606,0x66361e,0x1818181c,0x3c1818,0x7f370000,0x63636b,0x663e0000, -0x666666,0x663c0000,0x3c6666,0x663e0000,0x63e6666,0x667c0000,0x607c6666,0x663e0000,0x60606,0x67c0000,0x3e603c,0x187e1800,0x701818,0x66660000,0x7c6666,0x66660000,0x183c66,0x63630000,0x363e6b,0x3c660000,0x663c18,0x66660000,0x3e607c66,0x307e0000, -0x7e0c18,0xc181870,0x701818,0x18181818,0x18181818,0x3018180e,0xe1818,0x794f0600,0x30}; - -static int bppMode = 16; -static unsigned int padValues[2]={0,0}; -unsigned int ExistingIntHandler; - - -//SDL_Surface *sdlwrapper_screen; -/* -######################## -Graphics functions -######################## - */ - -static __inline__ -void gp_drawPixel8 ( int x, int y, unsigned char c, unsigned char *framebuffer ) -{ - *(framebuffer +(320*y)+x ) = c; -} - -static __inline__ -void gp_drawPixel16 ( int x, int y, unsigned short c, unsigned short *framebuffer ) -{ - *(framebuffer +(320*y)+x ) = c; -} - -static -void set_char8x8_16bpp (int xx,int yy,int offset,unsigned short mode,unsigned short *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y+4, mode, framebuffer); - - } -} - -static -void set_char8x8_8bpp (int xx,int yy,int offset,unsigned char mode,unsigned char *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel8(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel8(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel8(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel8(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel8(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel8(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel8(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel8(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel8(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel8(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel8(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel8(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel8(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel8(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel8(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel8(xx+7, yy+y+4, mode, framebuffer); - - } -} - -void gp_drawString (int x,int y,int len,char *buffer,unsigned short color,void *framebuffer) -{ -#if 1 - int l,base=0; - - for (l=0;l -#include -#include -#include -#include -#include -#include -#include -#include "menu.h" -#include "gp2x_sdk.h" -#include "squidgehack.h" -#include - -#define SYS_CLK_FREQ 7372800 - -volatile unsigned short gp2x_palette[512][2]; - -static int fb_size=(320*240*2)+(16*2); -static int mmuHackStatus=0; - -//unsigned long gp2x_ticks_per_second=7372800/1000; -unsigned long gp2x_dev[5]={0,0,0,0,0}; -unsigned long gp2x_physvram[4]={0,0,0,0}; - -unsigned short *framebuffer16[4]={0,0,0,0}; -static unsigned short *framebuffer_mmap[4]={0,0,0,0}; -unsigned short *gp2x_logvram15[2], gp2x_sound_buffer[4+((44100*2)*8)]; //*2=stereo, *4=max buffers -volatile unsigned short *gp2x_memregs; -volatile unsigned long *gp2x_memregl; -volatile unsigned long *gp2x_blitter = NULL; -unsigned int *gp2x_intVectors; -unsigned char *framebuffer8[4], *gp2x_screen8prev, *gp2x_logvram8[2]; - -volatile short *pOutput[8]; -int InitFramebuffer=0; -int Timer=0; -volatile int SoundThreadFlag=0; -volatile int CurrentSoundBank=0; -int CurrentFrameBuffer=0; -int CurrentFrag=0; -unsigned int ExistingIntHandler; - -// 1024x8 8x8 font, i love it :) -const unsigned int font8x8[]= {0x0,0x0,0xc3663c18,0x3c2424e7,0xe724243c,0x183c66c3,0xc16f3818,0x18386fc1,0x83f61c18,0x181cf683,0xe7c3993c,0x3c99c3,0x3f7fffff,0xe7cf9f,0x3c99c3e7,0xe7c399,0x3160c080,0x40e1b,0xcbcbc37e,0x7ec3c3db,0x3c3c3c18,0x81c087e,0x8683818,0x60f0e08,0x81422418,0x18244281,0xbd5a2418,0x18245abd,0x818181ff,0xff8181,0xa1c181ff,0xff8995,0x63633e,0x3e6363,0x606060,0x606060,0x3e60603e,0x3e0303,0x3e60603e,0x3e6060,0x3e636363,0x606060,0x3e03033e,0x3e6060,0x3e03033e,0x3e6363,0x60603e,0x606060,0x3e63633e,0x3e6363,0x3e63633e,0x3e6060,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18181818,0x180018,0x666666,0x0,0x367f3600,0x367f36,0x3c067c18,0x183e60,0x18366600,0x62660c,0xe1c361c,0x6e337b,0x181818,0x0,0x18183870,0x703818,0x18181c0e,0xe1c18,0xff3c6600,0x663c,0x7e181800,0x1818,0x0,0x60c0c00,0x7e000000,0x0,0x0,0x181800,0x18306040,0x2060c,0x6e76663c,0x3c6666,0x18181c18,0x7e1818,0x3060663c,0x7e0c18,0x3018307e,0x3c6660,0x363c3830,0x30307e,0x603e067e,0x3c6660,0x3e06063c,0x3c6666,0x1830607e,0xc0c0c,0x3c66663c,0x3c6666,0x7c66663c,0x1c3060,0x181800,0x1818,0x181800,0xc1818,0xc183060,0x603018,0x7e0000,0x7e00,0x30180c06,0x60c18,0x3060663c,0x180018,0x5676663c,0x7c0676,0x66663c18,0x66667e,0x3e66663e,0x3e6666,0x606663c,0x3c6606,0x6666361e,0x1e3666,0x3e06067e,0x7e0606,0x3e06067e,0x60606,0x7606067c,0x7c6666,0x7e666666,0x666666,0x1818183c,0x3c1818,0x60606060,0x3c6660,0xe1e3666,0x66361e,0x6060606,0x7e0606,0x6b7f7763,0x636363,0x7e7e6e66,0x666676,0x6666663c,0x3c6666,0x3e66663e,0x60606,0x6666663c,0x6c366e,0x3e66663e,0x666636,0x3c06663c,0x3c6660,0x1818187e,0x181818,0x66666666,0x7c6666,0x66666666,0x183c66,0x6b636363,0x63777f,0x183c6666,0x66663c,0x3c666666,0x181818,0x1830607e,0x7e060c,0x18181878,0x781818,0x180c0602,0x406030,0x1818181e,0x1e1818,0x63361c08,0x0,0x0,0x7f0000,0xc060300,0x0,0x603c0000,0x7c667c,0x663e0606,0x3e6666,0x63c0000,0x3c0606,0x667c6060,0x7c6666,0x663c0000,0x3c067e,0xc3e0c38,0xc0c0c,0x667c0000,0x3e607c66,0x663e0606,0x666666,0x181c0018,0x3c1818,0x18180018,0xe181818,0x36660606,0x66361e,0x1818181c,0x3c1818,0x7f370000,0x63636b,0x663e0000,0x666666,0x663c0000,0x3c6666,0x663e0000,0x63e6666,0x667c0000,0x607c6666,0x663e0000,0x60606,0x67c0000,0x3e603c,0x187e1800,0x701818,0x66660000,0x7c6666,0x66660000,0x183c66,0x63630000,0x363e6b,0x3c660000,0x663c18,0x66660000,0x3e607c66,0x307e0000,0x7e0c18,0xc181870,0x701818,0x18181818,0x18181818,0x3018180e,0xe1818,0x794f0600,0x30}; - -pthread_t gp2x_sound_thread=0, gp2x_sound_thread_exit=0; -struct fb_fix_screeninfo fb0_fixed_info; -struct fb_fix_screeninfo fb1_fixed_info; - -int altVolumeCtrl = 0; - -/* -######################## -Graphics functions -######################## - */ - -static void debug(char *text, int pause) -{ - unsigned short bppmode; - bppmode=gp2x_memregs[0x28DA>>1]; - bppmode>>=9; - bppmode<<=3; - - if(bppmode==8) - { - gp_clearFramebuffer8(framebuffer8[currFB],0); - gp_drawString(0,0,strlen(text),text,0x51,framebuffer16[currFB]); - } - else - { - gp_clearFramebuffer8(framebuffer16[currFB],0); - gp_drawString(0,0,strlen(text),text,(unsigned short)MENU_RGB(31,31,31),framebuffer16[currFB]); - } - MenuFlip(); - if(pause) MenuPause(); - -} - -static int clipping_x1 = 0; -static int clipping_x2 = 319; -static int clipping_y1 = 0; -static int clipping_y2 = 239; - -void gp_setClipping(int x1, int y1, int x2, int y2) { - if (x1 < 0) x1 = 0; - if (x1 > 319) x1 = 319; - if (x2 < 0) x2 = 0; - if (x2 > 319) x2 = 319; - if (y1 < 0) y1 = 0; - if (y1 > 239) y1 = 239; - if (y2 < 0) y2 = 0; - if (y2 > 239) y2 = 239; - - if (x1 < x2) { - clipping_x1 = x1; - clipping_x2 = x2; - } else { - clipping_x2 = x1; - clipping_x1 = x2; - } - - if (y1 < y2) { - clipping_y1 = y1; - clipping_y2 = y2; - } else { - clipping_y2 = y1; - clipping_y1 = y2; - } -} - -static __inline__ -void gp_drawPixel8 ( int x, int y, unsigned char c, unsigned char *framebuffer ) -{ - if ((x < clipping_x1) || (x > clipping_x2) || (y < clipping_y1) || (y > clipping_y2)) return; - *(framebuffer +(320*y)+x ) = c; -} - -static __inline__ -void gp_drawPixel16 ( int x, int y, unsigned short c, unsigned short *framebuffer ) -{ - if ((x < clipping_x1) || (x > clipping_x2) || (y < clipping_y1) || (y > clipping_y2)) return; - *(framebuffer +(320*y)+x ) = c; -} - -static -void set_char8x8_16bpp (int xx,int yy,int offset,unsigned short mode,unsigned short *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y+4, mode, framebuffer); - - } -} - -static -void set_char8x8_8bpp (int xx,int yy,int offset,unsigned char mode,unsigned char *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel8(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel8(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel8(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel8(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel8(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel8(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel8(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel8(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel8(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel8(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel8(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel8(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel8(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel8(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel8(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel8(xx+7, yy+y+4, mode, framebuffer); - - } -} - -void gp_drawString (int x,int y,int len,char *buffer,unsigned short color,void *framebuffer) -{ - int l,base=0; - unsigned short bppmode; - bppmode=gp2x_memregs[0x28DA>>1]; - bppmode>>=9; - bppmode<<=3; - - for (l=0;l>1]; - bppmode>>=9; - bppmode<<=3; - if(bppmode==8) gp_clearFramebuffer8((unsigned char*)framebuffer,(unsigned char)pal); - else gp_clearFramebuffer16((unsigned short*)framebuffer,(unsigned short)pal); -} - - - - -unsigned int gp_getButton(unsigned char enable_diagnals) -{ - unsigned int value=(gp2x_memregs[0x1198>>1] & 0x00FF); - //gp2x_memregs[0x1198>>1] - /* - 0x1FE = UP 1 1111 1110 - 0x17E 1 0111 1110 - 0x17F 1 0111 1111 - 0X13F 1 0011 1111 - 0x1BF = RIGHT 1 1011 1111 - 0X19F 1 1001 1111 - 0X1DF 1 1101 1111 - 0X1CF 1 1100 1111 - 0x1EF = DOWN 1 1110 1111 - 0x1E7 1 1110 0111 - 0x1F7 1 1111 0111 - 0x1F3 1 1111 0011 - 0x1FB = LEFT 1 1111 1011 - 0x1F9 1 1111 1001 - 0x1FD 1 1111 1101 - 0x1FC 1 1111 1100 - - */ - switch(value) - { - //UP - case 0x7E: - case 0xFC: - value = 0xFE; - break; - - //RIGHT - case 0x3F: - case 0x9F: - value = 0xBF; - break; - - //DOWN - case 0xCF: - case 0xE7: - value = 0xEF; - break; - - //LEFT - case 0xF3: - case 0xF9: - value = 0xFB; - break; - } - - if (enable_diagnals) - { - - if(value==0xFD) value=0xFA; - if(value==0xF7) value=0xEB; - if(value==0xDF) value=0xAF; - if(value==0x7F) value=0xBE; - } - - - return ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16)); -} - -void gp_initGraphics(unsigned short bpp, int flip, int applyMmuHack) -{ - - int x = 0; - unsigned int key = 0; - unsigned int offset = 0; - char buf[256]; - - -#ifdef DEBUG - printf("Entering gp_initGraphics....\r\n"); -#endif - /* - First check that frame buffer memory has not already been setup - */ - if (!InitFramebuffer) - { -#ifdef DEBUG - sprintf(buf, "Initing buffer\r\n"); - printf(buf); -#endif - gp2x_dev[0] = open("/dev/fb0", O_RDWR); - gp2x_dev[1] = open("/dev/fb1", O_RDWR); - gp2x_dev[2] = open("/dev/mem", O_RDWR); - -#ifdef DEBUG - sprintf(buf, "Devices opened\r\n"); - printf(buf); - sprintf(buf, "/dev/fb0: %x \r\n", gp2x_dev[0]); - printf(buf); - sprintf(buf, "/dev/fb1: %x \r\n", gp2x_dev[1]); - printf(buf); - sprintf(buf, "/dev/mem: %x \r\n", gp2x_dev[2]); - printf(buf); -#endif - - gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], 0xc0000000); - gp2x_memregl=(unsigned long *)gp2x_memregs; - if (!gp2x_blitter) gp2x_blitter=(unsigned long *)mmap(0, 0x100, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], 0xe0020000); - - if (!framebuffer_mmap[0]) framebuffer_mmap[0]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], (gp2x_physvram[0]=0x04000000-(0x26000*4) )); - if (!framebuffer_mmap[1]) framebuffer_mmap[1]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], (gp2x_physvram[1]=0x04000000-(0x26000*3) )); - if (!framebuffer_mmap[2]) framebuffer_mmap[2]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], (gp2x_physvram[2]=0x04000000-(0x26000*2) )); - if (!framebuffer_mmap[3]) framebuffer_mmap[3]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], (gp2x_physvram[3]=0x04000000-(0x26000*1) )); - - if (applyMmuHack) - { - printf("Applying MMUHACK..."); fflush(stdout); - mmuHackStatus = mmuhack(); - sprintf(buf, "Done\r\n. MMUHACK returned: %x\r\n", mmuHackStatus); - printf(buf); fflush(stdout); - } - - // offset externally visible buffers by 8 - // this allows DrMD to not worry about clipping - framebuffer16[0]=framebuffer_mmap[0]+8; - framebuffer16[1]=framebuffer_mmap[1]+8; - framebuffer16[2]=framebuffer_mmap[2]+8; - framebuffer16[3]=framebuffer_mmap[3]+8; - //ofset physical buffer as well - gp2x_physvram[0]+=16; - gp2x_physvram[1]+=16; - gp2x_physvram[2]+=16; - gp2x_physvram[3]+=16; - // clear all the framebuffers to black - // otherwise you get crap displayed on the screen the first time - // you start - framebuffer8[0]=(unsigned char*)framebuffer16[0]; - framebuffer8[1]=(unsigned char*)framebuffer16[1]; - framebuffer8[2]=(unsigned char*)framebuffer16[2]; - framebuffer8[3]=(unsigned char*)framebuffer16[3]; - - // Clear the frame buffers - memset(framebuffer16[0],0,320*240*2); - memset(framebuffer16[1],0,320*240*2); - memset(framebuffer16[2],0,320*240*2); - memset(framebuffer16[3],0,320*240*2); - - InitFramebuffer=1; - - //gp2x_memregs[0x0F16>>1] = 0x830a; - //usleep(1000000); - //gp2x_memregs[0x0F58>>1] = 0x100c; - //usleep(1000000); - - - } - - - // Set graphics mode - gp2x_memregs[0x28DA>>1]=(((bpp+1)/8)<<9)|0xAB; /*8/15/16/24bpp...*/ - gp2x_memregs[0x290C>>1]=320*((bpp+1)/8); - - //TV out fix - gp_video_RGB_setscaling(320,240); - - // 2d accel - //gp2x_memregs[0x904 >> 1] |= 1<<10; //SYSCLKENREG (System Clock Enable Register) maybe bit 10 is 2d accer - //gp2x_memregs[0x90a >> 1] = 0xffff; // Reset clock timings for all devices - - gp_setFramebuffer(flip,1); - -#ifdef DEBUG - printf("Leaving gp_initGraphics....\r\n"); -#endif -} - -void gp_setFramebuffer(int flip, int sync) -{ - CurrentFrameBuffer=flip; - unsigned int address=(unsigned int)gp2x_physvram[flip]; - unsigned short x=0; - /*switch(sync) - { - case 0: - // No sync - break; - - case 1: - // VSync - while(1) - { - x=gp2x_memregs[0x1182>>1]; - if((x&(1<<4)) == 0) - { - break; - } - } - break; - case 2: - // HSync - while(1) - { - x=gp2x_memregs[0x1182>>1]; - if((x&(1<<5)) == 0) - { - break; - } - } - break; - }*/ - - gp2x_memregs[0x290E>>1]=(unsigned short)(address & 0xffff); - gp2x_memregs[0x2910>>1]=(unsigned short)(address >> 16); - gp2x_memregs[0x2912>>1]=(unsigned short)(address & 0xffff); - gp2x_memregs[0x2914>>1]=(unsigned short)(address >> 16); -} - -void gp2x_video_setpalette(void) -{ - unsigned short *g=(unsigned short *)gp2x_palette; int i=512; - gp2x_memregs[0x2958>>1]=0; - while(i--) gp2x_memregs[0x295A>>1]=*g++; -} - -/* -######################## -Sound functions -######################## - */ -static -void *gp2x_sound_play(void) -{ - //struct timespec ts; ts.tv_sec=0, ts.tv_nsec=1000; - while(! gp2x_sound_thread_exit) - { - Timer++; - CurrentSoundBank++; - - if (CurrentSoundBank >= 8) CurrentSoundBank = 0; - - if (SoundThreadFlag==SOUND_THREAD_SOUND_ON) - { - write(gp2x_dev[3], (void *)pOutput[CurrentSoundBank], gp2x_sound_buffer[1]); - ioctl(gp2x_dev[3], SOUND_PCM_SYNC, 0); - //ts.tv_sec=0, ts.tv_nsec=(gp2x_sound_buffer[3]<<16)|gp2x_sound_buffer[2]; - //nanosleep(&ts, NULL); - } - else - { - write(gp2x_dev[3], (void *)&gp2x_sound_buffer[4], gp2x_sound_buffer[1]); - ioctl(gp2x_dev[3], SOUND_PCM_SYNC, 0); - //ts.tv_sec=0, ts.tv_nsec=(gp2x_sound_buffer[3]<<16)|gp2x_sound_buffer[2]; - //nanosleep(&ts, NULL); - } - } - - return NULL; -} - -void gp2x_sound_play_bank(int bank) -{ - write(gp2x_dev[3], (void *)(&gp2x_sound_buffer[4+(bank*gp2x_sound_buffer[1])]), gp2x_sound_buffer[1]); -} - -void gp2x_sound_sync(void) -{ - ioctl(gp2x_dev[3], SOUND_PCM_SYNC, 0); -} - -void gp_sound_volume(int l, int r) -{ - if(!gp2x_dev[4]) - { - gp2x_dev[4] = open("/dev/mixer", O_WRONLY); - } - - l=((l<<8)|r); - if (altVolumeCtrl) //For FW >= 4.0 - { - ioctl(gp2x_dev[4], SOUND_MIXER_WRITE_VOLUME, &l); - } - ioctl(gp2x_dev[4], SOUND_MIXER_WRITE_PCM, &l); -} - -unsigned long gp_timer_read(void) -{ - // Once again another peice of direct hardware access bites the dust - // the code below is broken in firmware 2.1.1 so I've replaced it with a - // to a linux function which seems to work - //return gp2x_memregl[0x0A00>>2]/gp2x_ticks_per_second; - struct timeval tval; // timing - - gettimeofday(&tval, 0); - //tval.tv_usec - //tval.tv_sec - return (tval.tv_sec*1000000)+tval.tv_usec; -} - -int gp_initSound(int rate, int bits, int stereo, int Hz, int frag) -{ - int status; - int i=0; - int nonblocking=1; - unsigned int bufferStart=0; - int result; - char text[256]; - - //Check if firmware version > 4 - FILE *fVersion = fopen("/usr/gp2x/version","r"); - if (fVersion) - { - if (fgetc(fVersion) == '4') - { - altVolumeCtrl = 1; - } - fclose(fVersion); - } - - //int frag=0x00020010; // double buffer - frag size = 1<<0xf = 32768 - - //8 = 256 = 2 fps loss = good sound - //9 = 512 = 1 fps loss = good sound - //A = 1024 = - //f = 32768 = 0 fps loss = bad sound - if ((frag!= CurrentFrag)&&(gp2x_dev[3]!=0)) - { - // Different frag config required - // close device in order to re-adjust - close(gp2x_dev[3]); - gp2x_dev[3]=0; - } - - if (gp2x_dev[3]==0) - { - gp2x_dev[3] = open("/dev/dsp", O_WRONLY); - printf("Opening sound device: %x\r\n",gp2x_dev[3]); - ioctl(gp2x_dev[3], SNDCTL_DSP_SETFRAGMENT, &frag); - CurrentFrag=frag; // save frag config - } - - //ioctl(gp2x_dev[3], SNDCTL_DSP_RESET, 0); - result=ioctl(gp2x_dev[3], SNDCTL_DSP_SPEED, &rate); - if(result==-1) - { - debug("Error setting DSP Speed",1); - return(-1); - } - - result=ioctl(gp2x_dev[3], SNDCTL_DSP_SETFMT, &bits); - if(result==-1) - { - debug("Error setting DSP format",1); - return(-1); - } - - result=ioctl(gp2x_dev[3], SNDCTL_DSP_STEREO, &stereo); - if(result==-1) - { - debug("Error setting DSP format",1); - return(-1); - } - //printf("Disable Blocking: %x\r\n",ioctl(gp2x_dev[3], 0x5421, &nonblocking)); - - gp2x_sound_buffer[1]=(gp2x_sound_buffer[0]=(rate/Hz)) << (stereo + (bits==16)); - gp2x_sound_buffer[2]=(1000000000/Hz)&0xFFFF; - gp2x_sound_buffer[3]=(1000000000/Hz)>>16; - - bufferStart= &gp2x_sound_buffer[4]; - pOutput[0] = (short*)bufferStart+(0*gp2x_sound_buffer[1]); - pOutput[1] = (short*)bufferStart+(1*gp2x_sound_buffer[1]); - pOutput[2] = (short*)bufferStart+(2*gp2x_sound_buffer[1]); - pOutput[3] = (short*)bufferStart+(3*gp2x_sound_buffer[1]); - pOutput[4] = (short*)bufferStart+(4*gp2x_sound_buffer[1]); - pOutput[5] = (short*)bufferStart+(5*gp2x_sound_buffer[1]); - pOutput[6] = (short*)bufferStart+(6*gp2x_sound_buffer[1]); - pOutput[7] = (short*)bufferStart+(7*gp2x_sound_buffer[1]); - - if(!gp2x_sound_thread) - { - pthread_create( &gp2x_sound_thread, NULL, gp2x_sound_play, NULL); - //atexit(gp_Reset); - } - - for(i=0;i<(gp2x_sound_buffer[1]*8);i++) - { - gp2x_sound_buffer[4+i] = 0; - } - - return(0); -} - -void gp_stopSound(void) -{ - unsigned int i=0; - gp2x_sound_thread_exit=1; - printf("Killing Thread\r\n"); - for(i=0;i<(gp2x_sound_buffer[1]*8);i++) - { - gp2x_sound_buffer[4+i] = 0; - } - usleep(100000); - printf("Thread is dead\r\n"); - gp2x_sound_thread=0; - gp2x_sound_thread_exit=0; - CurrentSoundBank=0; -} - - -/* -######################## -System functions -######################## - */ -void gp_Reset(void) -{ - unsigned int i=0; - - - if( gp2x_sound_thread) - { - gp2x_sound_thread_exit=1; - usleep(500); - } - - gp2x_memregs[0x28DA>>1]=0x4AB; - gp2x_memregs[0x290C>>1]=640; - munmap((void *)gp2x_memregs, 0x10000); - - munmap(framebuffer_mmap[0], fb_size); - munmap(framebuffer_mmap[1], fb_size); - munmap(framebuffer_mmap[2], fb_size); - munmap(framebuffer_mmap[3], fb_size); - - if (gp2x_dev[0]) close(gp2x_dev[0]); - if (gp2x_dev[1]) close(gp2x_dev[1]); - if (gp2x_dev[2]) close(gp2x_dev[2]); - if (gp2x_dev[3]) close(gp2x_dev[3]); - if (gp2x_dev[4]) close(gp2x_dev[4]); - - fcloseall(); - - // If MMUHACK was applied succesfully then remove it - if (mmuHackStatus) mmuunhack(); - - chdir("/usr/gp2x"); - execl("gp2xmenu",NULL); -} - -void gp_video_RGB_setscaling(int W, int H) -{ - float escalaw,escalah; - int bpp=(gp2x_memregs[0x28DA>>1]>>9)&0x3; - - if(gp2x_memregs[0x2800>>1]&0x100) //TV-Out - { - escalaw=489.0; //RGB Horiz TV (PAL, NTSC) - if (gp2x_memregs[0x2818>>1] == 287) //PAL - escalah=274.0; //RGB Vert TV PAL - else if (gp2x_memregs[0x2818>>1] == 239) //NTSC - escalah=331.0; //RGB Vert TV NTSC - } - else //LCD - { - escalaw=1024.0; //RGB Horiz LCD - escalah=320.0; //RGB Vert LCD - } - - // scale horizontal - gp2x_memregs[0x2906>>1]=(unsigned short)((float)escalaw *(W/320.0)); - // scale vertical - gp2x_memregl[0x2908>>2]=(unsigned long)((float)escalah *bpp *(H/240.0)); -} - -void gp_setCpuspeed(unsigned int MHZ) -{ - unsigned v; - unsigned mdiv,pdiv=3,scale=0; - - MHZ*=1000000; - mdiv=(MHZ*pdiv)/SYS_CLK_FREQ; - mdiv=((mdiv-8)<<8) & 0xff00; - pdiv=((pdiv-2)<<2) & 0xfc; - scale&=3; - v=mdiv | pdiv | scale; - gp2x_memregs[0x910>>1]=v; - -} - -// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2 -// set_RAM_Timings(6, 4, 1, 1, 1, 2, 2); -void set_RAM_Timings(int tRC, int tRAS, int tWR, int tMRD, int tRFC, int tRP, int tRCD) -{ - tRC -= 1; tRAS -= 1; tWR -= 1; tMRD -= 1; tRFC -= 1; tRP -= 1; tRCD -= 1; // ??? - gp2x_memregs[0x3802>>1] = ((tMRD & 0xF) << 12) | ((tRFC & 0xF) << 8) | ((tRP & 0xF) << 4) | (tRCD & 0xF); - gp2x_memregs[0x3804>>1] = /*0x9000 |*/ ((tRC & 0xF) << 8) | ((tRAS & 0xF) << 4) | (tWR & 0xF); -} - -void set_gamma(int g100) -{ - float gamma = (float) g100 / 100; - int i; - gamma = 1/gamma; - - //enable gamma - gp2x_memregs[0x2880>>1]&=~(1<<12); - - gp2x_memregs[0x295C>>1]=0; - for(i=0; i<256; i++) - { - unsigned char g; - unsigned short s; - g =(unsigned char)(255.0*pow(i/255.0,gamma)); - s = (g<<8) | g; - gp2x_memregs[0x295E>>1]= s; - gp2x_memregs[0x295E>>1]= g; - } -} - - - - - diff --git a/src/gp2x_sdk.h b/src/gp2x_sdk.h deleted file mode 100644 index 1ae2c3d..0000000 --- a/src/gp2x_sdk.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _GP2X_SDK_H_ -#define _GP2X_SDK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define SOUND_THREAD_SOUND_ON 1 -#define SOUND_THREAD_SOUND_OFF 2 -#define SOUND_THREAD_PAUSE 3 - -#define INP_BUTTON_UP (0) -#define INP_BUTTON_LEFT (2) -#define INP_BUTTON_DOWN (4) -#define INP_BUTTON_RIGHT (6) -#define INP_BUTTON_START (8) -#define INP_BUTTON_SELECT (9) -#define INP_BUTTON_L (10) -#define INP_BUTTON_R (11) -#define INP_BUTTON_A (12) -#define INP_BUTTON_B (13) -#define INP_BUTTON_X (14) -#define INP_BUTTON_Y (15) -#define INP_BUTTON_VOL_UP (23) -#define INP_BUTTON_VOL_DOWN (22) -#define INP_BUTTON_STICK_PUSH (27) - -void gp_setClipping(int x1, int y1, int x2, int y2); -void gp_drawString (int x,int y,int len,char *buffer,unsigned short color,void *framebuffer); -void gp_clearFramebuffer16(unsigned short *framebuffer, unsigned short pal); -void gp_clearFramebuffer8(unsigned char *framebuffer, unsigned char pal); -void gp_clearFramebuffer(void *framebuffer, unsigned int pal); -void gp_setCpuspeed(unsigned int cpuspeed); -void gp_initGraphics(unsigned short bpp, int flip, int applyMmuHack); -void gp_setFramebuffer(int flip, int sync); -void gp2x_video_setpalette(void); -int gp_initSound(int rate, int bits, int stereo, int Hz, int frag); -void gp_stopSound(void); -void gp_Reset(void); -void gp2x_enableIRQ(void); -void gp2x_disableIRQ(void); -void gp_sound_volume(int l, int r); -unsigned long gp_timer_read(void); -unsigned int gp_getButton(unsigned char enable_diagnals); -void gp_video_RGB_setscaling(int W, int H); -void gp2x_sound_play_bank(int bank); -void gp2x_sound_sync(void); -void set_gamma(int g100); -void set_RAM_Timings(int tRC, int tRAS, int tWR, int tMRD, int tRFC, int tRP, int tRCD); - -extern volatile int SoundThreadFlag; -extern volatile int CurrentSoundBank; -extern int CurrentFrameBuffer; -extern volatile short *pOutput[]; -extern unsigned short *framebuffer16[]; -extern unsigned long gp2x_physvram[]; -extern unsigned char *framebuffer8[]; -extern volatile unsigned short gp2x_palette[512][2]; -extern volatile unsigned short *gp2x_memregs; -extern volatile unsigned long *gp2x_memregl; -extern volatile unsigned long *gp2x_blitter; - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/gp32_func.h b/src/gp32_func.h deleted file mode 100644 index 8ee461d..0000000 --- a/src/gp32_func.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __gp32_func_h__ -#define __gp32_func_h__ - -extern "C" int funcSADDMULT1616(int a,int b,int c,int d); - -#define SADDMULT1616(res,a,b,c,d) {\ - res=funcSADDMULT1616(a,b,c,d);\ - } -#define SMULT1616(res,a,b) {\ - res=funcSADDMULT1616(a,b,0,0);\ - } - -#endif diff --git a/src/graphics.c b/src/graphics.c deleted file mode 100644 index 50cb0ce..0000000 --- a/src/graphics.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - Simple graphic handling library - Under GPL v2 License - 2011 by bitrider -*/ -#include -#include - -#include "graphics.h" - -static int clipping_x1 = 0; -static int clipping_x2 = SCREEN_WIDTH - 1; -static int clipping_y1 = 0; -static int clipping_y2 = SCREEN_HEIGHT - 1; - -void gSetClipping(int x1, int y1, int x2, int y2) { - if (x1 < 0) x1 = 0; - if (x1 > (SCREEN_WIDTH -1)) x1 = (SCREEN_WIDTH -1); - if (x2 < 0) x2 = 0; - if (x2 > (SCREEN_WIDTH -1)) x2 = (SCREEN_WIDTH -1); - if (y1 < 0) y1 = 0; - if (y1 > (SCREEN_HEIGHT - 1)) y1 = (SCREEN_HEIGHT - 1); - if (y2 < 0) y2 = 0; - if (y2 > (SCREEN_HEIGHT - 1)) y2 = (SCREEN_HEIGHT - 1); - - if (x1 < x2) { - clipping_x1 = x1; - clipping_x2 = x2; - } else { - clipping_x2 = x1; - clipping_x1 = x2; - } - - if (y1 < y2) { - clipping_y1 = y1; - clipping_y2 = y2; - } else { - clipping_y2 = y1; - clipping_y1 = y2; - } -} - -void gClearClipping() { - clipping_x1 = 0; - clipping_y1 = 0; - clipping_x2 = SCREEN_WIDTH - 1; - clipping_y2 = SCREEN_HEIGHT - 1; -} - -void gDestroyBitmap(gBITMAP *img) { - if (img) { - free(img->data); - free(img); - } -} - -gBITMAP *gCreateBitmap(unsigned int width, unsigned int height, unsigned char bpp) { - gBITMAP *img; - - if (bpp != 32) return NULL; // supported BPPs - if ((!width) || (!height)) return NULL; - - img = malloc(sizeof(gBITMAP)); - if (!img) return NULL; - img->bpp = bpp; - img->w = width; - img->h = height; - img->data = malloc(width * height * (bpp >> 3)); - if (!img->data) { - free(img); - return NULL; - } - return img; -} - -void gDrawPixel16(unsigned short *screen, int x, int y, unsigned char r, unsigned char g, unsigned char b) { - unsigned int sr, sg, sb; - unsigned short pixel; - - if ((x < clipping_x1) || (x > clipping_x2) || (y < clipping_y1) || (y > clipping_y2)) return; - - // blend - screen[y * SCREEN_WIDTH + x] = RGB16(r, g, b); -} - -void gBlendPixel16(unsigned short *screen, int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - unsigned int sr, sg, sb; - unsigned short pixel; - - if ((x < clipping_x1) || (x > clipping_x2) || (y < clipping_y1) || (y > clipping_y2)) return; - - // get screen pixel - pixel = screen[y * SCREEN_WIDTH + x]; - sr = PIXEL16_R(pixel); //((pixel >> 11) << 3); - sg = PIXEL16_G(pixel); //((pixel >> 5) & 63) << 2; - sb = PIXEL16_B(pixel); //(pixel & 31) << 3; - // blend - screen[y * SCREEN_WIDTH + x] = RGB16(BLEND(r, a, sr), BLEND(g, a, sg), BLEND(b, a, sb)); -} - -void gBlendBitmap16(unsigned short *screen, int sx, int sy, gBITMAP *img, unsigned int ix, unsigned int iy, unsigned int iw, unsigned int ih) { - int ssx; - unsigned int sw, ijmp, sjmp; - unsigned char *iaddr; - unsigned int pixel; - - if ((!img) || (!img->data)) return; // sanity check - if (img->bpp != 32) return; // supported BPPs - if ((sx > clipping_x2) || (sy > clipping_y2) || - ((sx + iw - 1) < clipping_x1) || ((sy + ih - 1) < clipping_y1)) return; // Out of screen - - // Image dimensions - if ((iw + ix) > img->w) iw = img->w - ix; - if ((ih + iy) > img->h) ih = img->h - iy; - - // Clipping - if (sx < clipping_x1) { - iw -= clipping_x1 - sx; - sx = clipping_x1; - } - if (sy < clipping_y1) { - ih -= clipping_y1 - sy; - sy = clipping_y1; - } - if ((sx + iw - 1) > clipping_x2) iw -= (sx + iw - 1) - clipping_x2; - if ((sy + ih - 1) > clipping_y2) ih -= (sy + ih - 1) - clipping_y2; - - ssx = sx; - sw = iw; - - ijmp = (img->w - iw) * (img->bpp >> 3); - iaddr = &img->data[(iy * img->w + ix) * 4 + 0]; - sjmp = SCREEN_WIDTH - iw; - screen = &screen[sy * SCREEN_WIDTH + sx]; - - for (; (ih > 0); ih--, iaddr += ijmp, screen += sjmp) { - for (iw = sw; (iw > 0); iw--, iaddr += 4, screen++) { - // blend - pixel = *((unsigned int *)iaddr); - /* - *screen = RGB16(BLEND(iaddr[0], iaddr[3], PIXEL16_R(*screen)), - BLEND(iaddr[1], iaddr[3], PIXEL16_G(*screen)), - BLEND(iaddr[2], iaddr[3], PIXEL16_B(*screen))); - */ - *screen = RGB16(BLEND(PIXEL32_R(pixel), PIXEL32_A(pixel), PIXEL16_R(*screen)), - BLEND(PIXEL32_G(pixel), PIXEL32_A(pixel), PIXEL16_G(*screen)), - BLEND(PIXEL32_B(pixel), PIXEL32_A(pixel), PIXEL16_B(*screen))); - } - } -} - -void gDrawBitmap16(unsigned short *screen, int sx, int sy, gBITMAP *img, unsigned int ix, unsigned int iy, unsigned int iw, unsigned int ih) { - int ssx; - unsigned int sw, ijmp, sjmp; - unsigned char *iaddr; - unsigned short pixel; - - if ((!img) || (!img->data)) return; // sanity check - if ((img->bpp != 32) || (img->bpp != 32)) return; // supported BPPs - if ((sx > clipping_x2) || (sy > clipping_y2) || - ((sx + iw - 1) < clipping_x1) || ((sy + ih - 1) < clipping_y1)) return; // Out of screen - - // Image dimensions - if ((iw + ix) > img->w) iw = img->w - ix; - if ((ih + iy) > img->h) ih = img->h - iy; - - // Clipping - if (sx < clipping_x1) { - iw -= clipping_x1 - sx; - sx = clipping_x1; - } - if (sy < clipping_y1) { - ih -= clipping_y1 - sy; - sy = clipping_y1; - } - if ((sx + iw - 1) > clipping_x2) iw -= (sx + iw - 1) - clipping_x2; - if ((sy + ih - 1) > clipping_y2) ih -= (sy + ih - 1) - clipping_y2; - - ssx = sx; - sw = iw; - - ijmp = (img->w - iw) * (img->bpp >> 3); - iaddr = &img->data[(iy * img->w + ix) * (img->bpp >> 3) + 0]; - sjmp = SCREEN_WIDTH - iw; - screen = &screen[sy * SCREEN_WIDTH + sx]; - - switch (img->bpp) { - case 32: - for (; (ih > 0); ih--, iaddr += ijmp, screen += sjmp) { - for (iw = sw; (iw > 0); iw--, iaddr += 4, screen++) { - *screen = RGB16(iaddr[0], iaddr[1], iaddr[2]); - } - } - break; - case 16: - for (; (ih > 0); ih--, iaddr += ijmp, screen += sjmp) { - for (iw = sw; (iw > 0); iw--, iaddr += 2) { - *screen++ = *(unsigned short *)iaddr; - } - } - break; - } -} - -void gDrawScaledBitmap16(unsigned short *screen, int sx, int sy, gBITMAP *img, unsigned int iw, unsigned int ih) { - int dx, dy; - int x , y, fp_x, w, h; - unsigned int *addr; - unsigned int pixel; - - if ((!img) || (!img->data)) return; // sanity check - if ((img->bpp != 32) || (img->bpp != 32)) return; // supported BPPs - - #define FP 10 - dx = (img->w << FP) / iw; - dy = (img->h << FP) / ih; - - w = SCREEN_WIDTH; - if (w > iw) w = iw; - h = SCREEN_HEIGHT; - if (h > ih) h = ih; - - for (y = 0; y < h; y++) { - addr = &((unsigned int *)img->data)[img->w * ((y * dy) >> FP)]; - for (x = 0, fp_x = 0; x < w ; x++, fp_x += dx) { - pixel = addr[fp_x >> FP]; - gDrawPixel16(screen, sx+x, sy+y, PIXEL32_R(pixel), PIXEL32_G(pixel), PIXEL32_B(pixel)); - } - } -} - -gBITMAP *gStretchBitmap(gBITMAP *img, unsigned int iw, unsigned int ih) { - int dx, dy; - int x , y, fp_x, fx, w, h; - unsigned int *srcCurLineAddr, *srcPrevLineAddr, *srcNextLineAddr; - unsigned int *dstAddr; - unsigned int pixel, r, g, b, a, div; - gBITMAP *toBmp; - - if ((!img) || (!img->data)) return NULL; // sanity check - if ((img->bpp != 32) || (img->bpp != 32)) return NULL; // supported BPPs - - toBmp = gCreateBitmap(iw, ih, img->bpp); - if (!toBmp) return NULL; - - #define FP 10 - dx = (img->w << FP) / iw; - dy = (img->h << FP) / ih; - - w = img->w; - if (w > iw) w = iw; - h = img->h; - if (h > ih) h = ih; - - for (y = 0; y < ih; y++) { - // Current line - srcCurLineAddr = &((unsigned int *)img->data)[img->w * ((y * dy) >> FP)]; - // Previous line - if (y == 0) srcPrevLineAddr = NULL; - else srcPrevLineAddr = &((unsigned int *)img->data)[img->w * (((y * dy) - 1) >> FP)]; - // Next line - if ((((y * dy) + 1) >> FP) >= img->h) srcNextLineAddr = NULL; - else srcNextLineAddr = &((unsigned int *)img->data)[img->w * (((y * dy) + 1) >> FP)]; - // Destination - dstAddr = &((unsigned int*)toBmp->data)[toBmp->w * y]; - for (x = 0, fp_x = 0; x < iw ; x++, fp_x += dx) { - // Current line - div = 4; - fx = fp_x >> FP; - pixel = srcCurLineAddr[fx]; - r = PIXEL32_R(pixel) * 4; - g = PIXEL32_G(pixel) * 4; - b = PIXEL32_B(pixel) * 4; - a = PIXEL32_A(pixel) * 4; -#define INCLUDE_PIXEL(p) \ - {\ - pixel = p;\ - r += PIXEL32_R(pixel);\ - g += PIXEL32_G(pixel);\ - b += PIXEL32_B(pixel);\ - a += PIXEL32_A(pixel);\ - div++;\ - } - - if (fx > 0) INCLUDE_PIXEL(srcCurLineAddr[fx - 1]); - if ((fx + 1) < img->w) INCLUDE_PIXEL(srcCurLineAddr[fx + 1]); - // Previous line - if (srcPrevLineAddr) { - INCLUDE_PIXEL(srcPrevLineAddr[fx]); - if (fx > 0) INCLUDE_PIXEL(srcPrevLineAddr[fx - 1]); - if ((fx + 1) < img->w) INCLUDE_PIXEL(srcPrevLineAddr[fx + 1]); - } - // Next line - if (srcNextLineAddr) { - INCLUDE_PIXEL(srcNextLineAddr[fx]); - if (fx > 0) INCLUDE_PIXEL(srcNextLineAddr[fx - 1]); - if ((fx + 1) < img->w) INCLUDE_PIXEL(srcNextLineAddr[fx + 1]); - } -#undef INCLUDE_PIXEL - dstAddr[x] = RGB32(r/div, g/div, b/div, a/div); - } - } - - return toBmp; -} - - - -void gClearScreen(unsigned short *screen, unsigned short color) { - int x, y; - - for (y = 0; y < SCREEN_HEIGHT; y++) - for (x = 0; x < SCREEN_WIDTH; x++) { - screen[y * SCREEN_WIDTH + x] = color; - } -} diff --git a/src/graphics.h b/src/graphics.h deleted file mode 100644 index 2927110..0000000 --- a/src/graphics.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __GRAPHICS_H__ -#define __GRAPHICS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 240 - -#define PIXEL32_A(p) (p >> 24) -#define PIXEL32_B(p) ((p >> 16) & 0xff) -#define PIXEL32_G(p) ((p >> 8) & 0xff) -#define PIXEL32_R(p) (p & 0xff) -#define RGB32(r, g, b, a) ((a << 24) | (b << 16) | (g << 8) | r) - -#define RGB16(r, g, b) (((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)) -#define PIXEL16_R(p) ((p >> 11) << 3) -#define PIXEL16_G(p) (((p >> 5) & 63) << 2) -#define PIXEL16_B(p) ((p & 31) << 3) -//#define BLEND(c1, a, c2) (((((unsigned int)c1) * ((unsigned int)a)) + (((unsigned int)c2) * (0x100 - ((unsigned char)a)))) >> 8) -#define BLEND(c1, a, c2) ((((int)a * ((int)c1 - (int)c2)) + ((int)c2 << 8)) >> 8) -#ifndef MIN - #define MIN(a, b) (((a) < (b))? (a) : (b)) -#endif -#ifndef MIN - #define MAX(a, b) (((a) > (b))? (a) : (b)) -#endif - - -typedef struct { - unsigned int w; - unsigned int h; - unsigned int bpp; - unsigned char *data; - } gBITMAP; - -void gSetClipping(int x1, int y1, int x2, int y2); -void gClearClipping(); - -void gClearScreen(unsigned short *screen, unsigned short color); - -void gBlendPixel16(unsigned short *screen, int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void gDrawPixel16(unsigned short *screen, int x, int y, unsigned char r, unsigned char g, unsigned char b); -void gBlendBitmap16(unsigned short *screen, int sx, int sy, gBITMAP *img, unsigned int ix, unsigned int iy, unsigned int iw, unsigned int ih); -void gDrawBitmap16(unsigned short *screen, int sx, int sy, gBITMAP *img, unsigned int ix, unsigned int iy, unsigned int iw, unsigned int ih); -void gDrawScaledBitmap16(unsigned short *screen, int sx, int sy, gBITMAP *img, unsigned int iw, unsigned int ih); - -void gDestroyBitmap(gBITMAP *img); -gBITMAP *gCreateBitmap(unsigned int width, unsigned int height, unsigned char bpp); -gBITMAP *gStretchBitmap(gBITMAP *img, unsigned int iw, unsigned int ih); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/gx.h b/src/gx.h deleted file mode 100644 index 0547d30..0000000 --- a/src/gx.h +++ /dev/null @@ -1,83 +0,0 @@ - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the GXDLL_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// GXDLL_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. - -#ifdef GXDLL_EXPORTS -#define GXDLL_API __declspec(dllexport) -#else -#define GXDLL_API __declspec(dllimport) -#endif - -struct GXDisplayProperties { - DWORD cxWidth; - DWORD cyHeight; // notice lack of 'th' in the word height. - long cbxPitch; // number of bytes to move right one x pixel - can be negative. - long cbyPitch; // number of bytes to move down one y pixel - can be negative. - long cBPP; // # of bits in each pixel - DWORD ffFormat; // format flags. -}; - -struct GXKeyList { - short vkUp; // key for up - POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates. - short vkDown; - POINT ptDown; - short vkLeft; - POINT ptLeft; - short vkRight; - POINT ptRight; - short vkA; - POINT ptA; - short vkB; - POINT ptB; - short vkC; - POINT ptC; - short vkStart; - POINT ptStart; -}; - -struct GXScreenRect { - DWORD dwTop; - DWORD dwLeft; - DWORD dwWidth; - DWORD dwHeight; -}; - -GXDLL_API int GXOpenDisplay(HWND hWnd, DWORD dwFlags); -GXDLL_API int GXCloseDisplay(); -GXDLL_API void * GXBeginDraw(); -GXDLL_API int GXEndDraw(); -GXDLL_API int GXOpenInput(); -GXDLL_API int GXCloseInput(); -//The following two lines modified by Dan East to make this header C compatible: -//Added "struct" to the following two prototypes: -GXDLL_API struct GXDisplayProperties GXGetDisplayProperties(); -GXDLL_API struct GXKeyList GXGetDefaultKeys(int iOptions); -GXDLL_API int GXSuspend(); -GXDLL_API int GXResume(); -GXDLL_API int GXSetViewport( DWORD dwTop, DWORD dwHeight, DWORD dwReserved1, DWORD dwReserved2 ); -GXDLL_API BOOL GXIsDisplayDRAMBuffer(); - - -// Although these flags can be unrelated they still -// have unique values. - -#define GX_FULLSCREEN 0x01 // for OpenDisplay() -#define GX_NORMALKEYS 0x02 -#define GX_LANDSCAPEKEYS 0x03 - -#ifndef kfLandscape - #define kfLandscape 0x8 // Screen is rotated 270 degrees - #define kfPalette 0x10 // Pixel values are indexes into a palette - #define kfDirect 0x20 // Pixel values contain actual level information - #define kfDirect555 0x40 // 5 bits each for red, green and blue values in a pixel. - #define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits per pixel - #define kfDirect888 0x100 // 8 bits each for red, green and blue values in a pixel. - #define kfDirect444 0x200 // 4 red, 4 green, 4 blue - #define kfDirectInverted 0x400 -#endif - diff --git a/src/ppu.h b/src/ppu.h index 17da27e..145f08a 100644 --- a/src/ppu.h +++ b/src/ppu.h @@ -42,7 +42,7 @@ #define _PPU_H_ #include "rops.h" -#include "menu.h" +//#include "menu.h" #define FIRST_VISIBLE_LINE 1 diff --git a/src/screenshot.c b/src/screenshot.c deleted file mode 100644 index 14a4efa..0000000 --- a/src/screenshot.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include "screenshot.h" -#include "png.h" -#include "menu.h" -#include "config.h" - -static gBITMAP *screenShot = NULL; - -#define SS_WIDTH 256 -#define SS_HEIGHT 240 - -// Copy screen into screenshot buffer -void getScreenShot(unsigned short *screen) { - unsigned int x, y; - screen += 32; - - if (!screenShot) { - screenShot = 0;//gCreateBitmap(SS_WIDTH, SS_HEIGHT, 32); - if (!screenShot) return; - } - - for (y = 0; y < SS_HEIGHT; y++) - for(x = 0; x < SS_WIDTH; x++) { - unsigned short pixel = screen[y * SCREEN_WIDTH + x]; - screenShot->data[(y * SS_WIDTH + x) * 4 + 0] = PIXEL16_R(pixel); - screenShot->data[(y * SS_WIDTH + x) * 4 + 1] = PIXEL16_G(pixel); - screenShot->data[(y * SS_WIDTH + x) * 4 + 2] = PIXEL16_B(pixel); - screenShot->data[(y * SS_WIDTH + x) * 4 + 3] = 0xff; - } -} - -int saveScreenShot() { - char fn[1024]; - char png_fn[1024]; - char *ext; - int ret; - - if (!screenShot) return -1; - - // get filename of last loaded ROM (the running one) - //getConfigValue(CONFIG_LASTLOADED, fn, sizeof(fn)); - // set file ext to .png - ext = strrchr(fn, '.'); - if (!ext) ext = &fn[strlen(fn)]; - strcpy(ext, ".png"); - // compose screenshot file's full path - sprintf(png_fn, "%s%s", getScreenShotsDir(), strrchr(fn, '/')); - - ret = 0;//save_png(screenShot, png_fn); - sync(); - - return ret; -} - -static char screenShotsDir[1024] = "\0"; -static int getScreenShotsDirFirstTime = 1; -const char *getScreenShotsDir() { - if (screenShotsDir[0] == '\0') sprintf(screenShotsDir, "%s/%s", currentWorkingDir, "screenshots"); - if (getScreenShotsDirFirstTime) { - mkdir(screenShotsDir, 0777); - getScreenShotsDirFirstTime = 0; - } - return screenShotsDir; -} - -void destroyScreenShot() { - //gDestroyBitmap(screenShot); - screenShot = NULL; -} diff --git a/src/screenshot.h b/src/screenshot.h deleted file mode 100644 index 64df2ba..0000000 --- a/src/screenshot.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __SCREENSHOT_H__ -#define __SCREENSHOT_H__ - -#include "graphics.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int saveScreenShot(); -void destroyScreenShot(); -void getScreenShot(unsigned short *screen); -const char *getScreenShotsDir(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/snes9x.h b/src/snes9x.h index 0201ad9..289ba0e 100644 --- a/src/snes9x.h +++ b/src/snes9x.h @@ -444,4 +444,8 @@ enum { void S9xSetPause (uint32 mask); void S9xClearPause (uint32 mask); +#ifndef MAX_PATH +#define MAX_PATH 255 +#endif + #endif diff --git a/src/srtc.h b/src/srtc.h index 32437f5..1e05019 100644 --- a/src/srtc.h +++ b/src/srtc.h @@ -41,9 +41,7 @@ #ifndef _srtc_h_ #define _srtc_h_ -#if !defined(_SNESPPC) && !defined(__GIZ__) && !defined(__GP2X__) && !defined(__WIZ__) -//#include -#endif +#include #define MAX_RTC_INDEX 0xC diff --git a/src/theme.c b/src/theme.c deleted file mode 100644 index 9b4a0ba..0000000 --- a/src/theme.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - Simple theming handling library - Under GPL v2 License - 2011 by bitrider -*/ - -#include "string.h" -#include "stdio.h" - -#include "minIni.h" -#include "graphics.h" -#include "config.h" -#include "png.h" - -gBITMAP *tBmpBackground = NULL; -gBITMAP *tBmpBar = NULL; -gBITMAP *tBmpLoading = NULL; -gBITMAP *tBmpInGame = NULL; - -unsigned short tTextColorTitle = RGB16(255, 0, 0); -unsigned short tTextColorFocus = RGB16(0, 0, 0); -unsigned short tTextColorItem = RGB16(255, 255, 255); -unsigned short tTextColorVersion = RGB16(0, 0, 255); -unsigned short tTextColorInfo = RGB16(255, 127, 40); -unsigned short tTextColorLoading = RGB16(255, 255,255); -unsigned short tBackgroundColor = RGB16(0,0,0); - -static gBITMAP *_loadBitmapFromIni(char *ini_file, char *ini_entry, char *dir) { - char f[1024]; - char def[] = "none"; - int len; - gBITMAP *bmp; - - strcpy(f, dir); - len = strlen(f); - ini_gets("bitmaps", ini_entry, def, f + len, sizeof(f) - len, ini_file); - if (strcmp(f + len, def) == 0) { - printf("- No \"%s\" image specified\n", ini_entry); - return NULL; - } - printf("- Loading bitmap: %s", f); - bmp = load_png(f, NULL); - if (!bmp) { - printf(" - ERROR loading file !!\n", f); - return NULL; - } - printf(" - OK\n"); - - return bmp; -} - -static int _loadColorFromIni(char *ini_file, char *ini_entry) { - char f[1024]; - char def[] = "none"; - int r = -1; - int g = -1; - int b = -1; - - ini_gets("colors", ini_entry, def, f, sizeof(f), ini_file); - if (strcmp(f, def) == 0) { - printf("- No \"%s\" color specified\n", ini_entry); - return -1; - } - printf("- Parsing color : %s", ini_entry); - sscanf(f, "RGB(%d, %d, %d)", &r, &g, &b); - if ((r < 0) || (r > 255) || - (g < 0) || (g > 255) || - (b < 0) || (b > 255)) { - printf(" - ERROR parsing color !!\n", f); - return -1; - } - printf(" - OK: RGB(%d,%d,%d)\n", r, g, b); - - return RGB16(r, g, b); -} - -int loadTheme(char *name) { - char themes_dir[] = "themes"; - char ini[1024]; - char dir[1024]; - gBITMAP *bgnd, *bar, *loading, *ingame; - int cTitle, cFocus, cItem, cVersion, cInfo, cLoading, cBackground; - - sprintf(ini, "%s/%s.ini", themes_dir, name); - printf("Loading theme file from: %s\n", ini); - - // Load colors - cTitle = _loadColorFromIni(ini, "text_title"); - cFocus = _loadColorFromIni(ini, "text_focus"); - cItem = _loadColorFromIni(ini, "text_item"); - cVersion = _loadColorFromIni(ini, "text_version"); - cInfo = _loadColorFromIni(ini, "text_info"); - cLoading = _loadColorFromIni(ini, "text_loading"); - cBackground = _loadColorFromIni(ini, "background"); - - // Load bitmaps - sprintf(dir, "%s/%s/", themes_dir, name); // build bitmaps directory - - bgnd = _loadBitmapFromIni(ini, "background", dir); - if (!bgnd) return -1; - - bar = _loadBitmapFromIni(ini, "bar", dir); - if (!bar) { - gDestroyBitmap(bgnd); - return -1; - } - - // Not required: can be null - loading = _loadBitmapFromIni(ini, "loading", dir); - ingame = _loadBitmapFromIni(ini, "ingame", dir); - - // Everything went OK, so replace current theme values with just loaded ones - gDestroyBitmap(tBmpBackground); - tBmpBackground = bgnd; - gDestroyBitmap(tBmpBar); - tBmpBar = bar; - gDestroyBitmap(tBmpInGame); - tBmpInGame = ingame; - gDestroyBitmap(tBmpLoading); - tBmpLoading = loading; - - if (cTitle >= 0) tTextColorTitle = cTitle; - if (cFocus >= 0) tTextColorFocus = cFocus; - if (cItem >= 0) tTextColorItem = cItem; - if (cVersion >= 0) tTextColorVersion = cVersion; - if (cInfo >= 0) tTextColorInfo = cInfo; - if (cLoading >= 0) tTextColorLoading = cLoading; - if (cBackground >= 0) tBackgroundColor = cBackground; - - return 0; -} - -int initTheme() { - char theme[256]; - getConfigValue(CONFIG_THEME, theme, sizeof(theme)); - return loadTheme(theme); -} - -void destroyTheme() { - - // Destroy bitmaps - gDestroyBitmap(tBmpBackground); - tBmpBackground = NULL; - gDestroyBitmap(tBmpBar); - tBmpBar = NULL; - gDestroyBitmap(tBmpLoading); - tBmpLoading = NULL; - gDestroyBitmap(tBmpInGame); - tBmpInGame = NULL; - - // Restore text colors - tTextColorTitle = RGB16(255, 0, 0); - tTextColorFocus = RGB16(0, 0, 0); - tTextColorItem = RGB16(255, 255, 255); - tTextColorVersion = RGB16(0, 0, 255); - tTextColorInfo = RGB16(255, 127, 40); - tTextColorLoading = RGB16(255, 255,255); - tBackgroundColor = RGB16(0,0,0); -} - -int isThemeActive() { - if (tBmpBackground != NULL) return 1; - else return 0; -} - diff --git a/src/theme.h b/src/theme.h deleted file mode 100644 index e6d055d..0000000 --- a/src/theme.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __THEME_H__ -#define __THEME_H__ - -#include "graphics.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern gBITMAP *tBmpBackground; -extern gBITMAP *tBmpBar; -extern gBITMAP *tBmpLoading; -extern gBITMAP *tBmpInGame; - -extern unsigned short tTextColorTitle; -extern unsigned short tTextColorFocus; -extern unsigned short tTextColorItem; -extern unsigned short tTextColorVersion; -extern unsigned short tTextColorLoading; -extern unsigned short tBackgroundColor; - - -int initTheme(); -int loadTheme(char *name); -void destroyTheme(); -int isThemeActive(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/touchscreen.c b/src/touchscreen.c deleted file mode 100644 index 90e0b81..0000000 --- a/src/touchscreen.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "stdio.h" -#include "stdlib.h" -#include "tslib.h" - -struct tsdev *ts = NULL; - -int InitTouchScreen(void) { - // Taken directly from tslib test sources, slightly modifed - char *tsdevice = NULL; - - if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) { - ts = ts_open(tsdevice, 1); - } else { - ts = ts_open("/dev/input/event0", 1); - } - - if (!ts) { - perror("ts_open"); - return 0; - } - if (ts_config(ts)) { - perror("ts_config"); - return 0; - } - - return 1; -} - -void DeInitTouchScreen(void) { - // Nothing to do -} - - -// return -1 on error, else pressure value - -int getTouchScreen(int *x, int *y) { - struct ts_sample tsdata; - - if (ts == NULL) return -1; - - if (ts_read(ts, &tsdata, 1) != 1) return -1; - - *x = tsdata.x; - *y = tsdata.y; - return tsdata.pressure; -} - diff --git a/src/touchscreen.h b/src/touchscreen.h deleted file mode 100644 index c475521..0000000 --- a/src/touchscreen.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -int InitTouchScreen(void); -int getTouchScreen(int *x, int *y); - -#ifdef __cplusplus -} -#endif diff --git a/src/usbjoy.c b/src/usbjoy.c deleted file mode 100644 index 81d1be4..0000000 --- a/src/usbjoy.c +++ /dev/null @@ -1,297 +0,0 @@ -/* Title: USB Joystick library - Version 0.2 - Written by Puck2099 (puck2099@gmail.com), (c) 2006. - - - If you use this library or a part of it, please, let it know. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include /* For the definition of NULL */ -#include // For Device open -#include -#include -#include -#include // For Device read - -#include -#include /* For the definition of PATH_MAX */ -#include - -#include "usbjoy.h" - - -/* - Function: joy_open - - Opens a USB joystick and fills its information. - - Parameters: - - joynumber - Joystick's identifier (0 reserved for GP2X's builtin Joystick). - - Returns: - - Filled usbjoy structure. - -*/ -struct usbjoy * joy_open (int joynumber) { - int fd, i; - char path [128]; - struct usbjoy * joy = NULL; - - system ("insmod joydev"); // Loads joydev module - - if (joynumber == 0) { - } - else if (joynumber > 0) { - sprintf (path, "/dev/input/js%d", joynumber-1); - fd = open(path, O_RDONLY, 0); - if (fd > 0) { - joy = (struct usbjoy *) malloc(sizeof(struct usbjoy)); - - // Joystick's file descriptor - joy->fd = fd; - - // Set the joystick to non-blocking read mode - fcntl(joy->fd, F_SETFL, O_NONBLOCK); - - // Joystick's name - ioctl(joy->fd, JSIOCGNAME(128*sizeof(char)), joy->name); - - // Joystick's device - sprintf (joy->device, path); - - // Joystick's buttons - ioctl(joy->fd, JSIOCGBUTTONS, &joy->numbuttons); - - // Joystick's axes - ioctl(joy->fd, JSIOCGAXES, &joy->numaxes); - - // Clean buttons and axes - for (i=0; i<32; i++) joy->statebuttons[i] = 0; - for (i=0; i<4; i++) joy->stateaxes[i] = 0; - } - else { - printf ("ERROR: No Joystick found\n"); - } - } - return joy; -} - -/* - Function: joy_name - - Returns Joystick's name. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's name or NULL if struct is empty. -*/ -char * joy_name (struct usbjoy * joy) { - if (joy != NULL) return joy->name; - else return NULL; -} - - -/* - Function: joy_device - - Returns Joystick's device. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's device or NULL if struct is empty. -*/ -char * joy_device (struct usbjoy * joy) { - if (joy != NULL) return joy->device; - else return NULL; -} - - -/* - Function: joy_buttons - - Returns Joystick's buttons number. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's buttons or 0 if struct is empty. -*/ -int joy_buttons (struct usbjoy * joy) { - if (joy != NULL) return joy->numbuttons; - else return 0; -} - - -/* - Function: joy_axes - - Returns Joystick's axes number. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's axes or 0 if struct is empty. -*/ -int joy_axes (struct usbjoy * joy) { - if (joy != NULL) return joy->numaxes; - else return 0; -} - - -/* - Function: joy_update - - Updates Joystick's internal information ( and fields). - - Parameters: - - joy - Selected joystick. - - Returns: - - 0 - No events registered (no need to update). - 1 - Events registered (a button or axe has been pushed). - -1 - Error: struct is empty. -*/ -int joy_update (struct usbjoy * joy) { - struct js_event events[0xff]; - int i, len; - int event = 0; - if (joy != NULL) { - if ((len=read(joy->fd, events, (sizeof events))) >0) { - len /= sizeof(events[0]); - for ( i=0; istateaxes[JOYLEFT] = joy->stateaxes[JOYRIGHT] = 0; - if (events[i].value < 0) joy->stateaxes[JOYLEFT] = 1; - else if (events[i].value > 0) joy->stateaxes[JOYRIGHT] = 1; - } - else if (events[i].number == 1) { - joy->stateaxes[JOYUP] = joy->stateaxes[JOYDOWN] = 0; - if (events[i].value < 0) joy->stateaxes[JOYUP] = 1; - else if (events[i].value > 0) joy->stateaxes[JOYDOWN] = 1; - } - event = 1; - break; - case JS_EVENT_BUTTON: - joy->statebuttons[events[i].number] = events[i].value; - event = 1; - break; - default: - break; - } - } - } - } - else { - event = -1; - } - return event; -} - - -/* - Function: joy_getbutton - - Returns Joystick's button information. - - Parameters: - - button - Button which value you want to know (from 0 to 31). - joy - Selected joystick. - - Returns: - - 0 - Button NOT pushed. - 1 - Button pushed. - -1 - Error: struct is empty. -*/ -int joy_getbutton (int button, struct usbjoy * joy) { - if (joy != NULL) { - if (button < joy_buttons(joy)) return joy->statebuttons[button]; - else return 0; - } - else return -1; -} - - -/* - Function: joy_getaxe - - Returns Joystick's axes information. - - Parameters: - - axe - Axe which value you want to know (see ). - joy - Selected joystick. - - Returns: - - 0 - Direction NOT pushed. - 1 - Direction pushed. - -1 - Error: struct is empty. -*/ -int joy_getaxe (int axe, struct usbjoy * joy) { - if (joy != NULL) { - if (axe < 4) return joy->stateaxes[axe]; - else return 0; - } - else return -1; -} - - -/* - Function: joy_close - - Closes selected joystick's file descriptor and detroys it's fields. - - Parameters: - - joy - Selected joystick. - - Returns: - - 0 - Joystick successfully closed. - -1 - Error: struct is empty. -*/ -int joy_close (struct usbjoy * joy) { - if (joy != NULL) { - close (joy->fd); - free (joy); - return 0; - } - else return -1; -} diff --git a/src/usbjoy.h b/src/usbjoy.h deleted file mode 100644 index c324744..0000000 --- a/src/usbjoy.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Title: USB Joystick library - Version 0.2 - Written by Puck2099 (puck2099@gmail.com), (c) 2006. - - - If you use this library or a part of it, please, let it know. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef USBJOY_H -#define USBJOY_H - -/* - Enumeration: Axes values - This enumeration contains shortcuts to the values used on axes. - - Constants: - JOYUP - Joystick Up - JOYDOWN - Joystick Down - JOYLEFT - Joystick Left - JOYRIGHT - Joystick Right - - See also: - -*/ -#define JOYUP (0) -#define JOYDOWN (1) -#define JOYLEFT (2) -#define JOYRIGHT (3) - - -/* - Struct: usbjoy - - Contains all Joystick needed information. - - Fields: - fd - File descriptor used. - name - Joystick's name. - device - /dev/input/jsX device. - numbuttons - Joystick's buttons. - numaxes - Joystick's axes. - numhats - Joystick's hats. - statebuttons - Current state of each button. - stateaxes - Current state of each direction. -*/ -struct usbjoy { - int fd; - char name [128]; - char device [128]; - int numbuttons; - int numaxes; - int numhats; - int statebuttons[32]; - int stateaxes[4]; -}; - - -/* - Function: joy_open - - Opens a USB joystick and fills its information. - - Parameters: - - joynumber - Joystick's identifier (0 reserved for GP2X's builtin Joystick). - - Returns: - - Filled usbjoy structure. -*/ -struct usbjoy * joy_open (int joynumber); - - -/* - Function: joy_name - - Returns Joystick's name. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's name or NULL if struct is empty. -*/ -char * joy_name (struct usbjoy * joy); - - -/* - Function: joy_device - - Returns Joystick's device. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's device or NULL if struct is empty. -*/ -char * joy_device (struct usbjoy * joy); - -/* - Function: joy_buttons - - Returns Joystick's buttons number. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's buttons or 0 if struct is empty. -*/ -int joy_buttons (struct usbjoy * joy); - -/* - Function: joy_axes - - Returns Joystick's axes number. - - Parameters: - - joy - Selected joystick. - - Returns: - - Joystick's axes or 0 if struct is empty. -*/ -int joy_axes (struct usbjoy * joy); - - -/* - Function: joy_update - - Updates Joystick's internal information ( and fields). - - Parameters: - - joy - Selected joystick. - - Returns: - - 0 - No events registered (no need to update). - 1 - Events registered (a button or axe has been pushed). - -1 - Error: struct is empty. -*/ -int joy_update (struct usbjoy * joy); - - -/* - Function: joy_getbutton - - Returns Joystick's button information. - - Parameters: - - button - Button which value you want to know (from 0 to 31). - joy - Selected joystick. - - Returns: - - 0 - Button NOT pushed. - 1 - Button pushed. - -1 - Error: struct is empty. -*/ -int joy_getbutton (int button, struct usbjoy * joy); - - -/* - Function: joy_getaxe - - Returns Joystick's axes information. - - Parameters: - - axe - Axe which value you want to know (see ). - joy - Selected joystick. - - Returns: - - 0 - Direction NOT pushed. - 1 - Direction pushed. - -1 - Error: struct is empty. -*/ -int joy_getaxe (int axe, struct usbjoy * joy); - -/* - Function: joy_close - - Closes selected joystick's file descriptor and detroys it's fields. - - Parameters: - - joy - Selected joystick. - - Returns: - - 0 - Joystick successfully closed. - -1 - Error: struct is empty. -*/ -int joy_close (struct usbjoy * joy); - -#endif // USBJOY_H diff --git a/src/wiz_mmuhack.c b/src/wiz_mmuhack.c deleted file mode 100644 index f2204d6..0000000 --- a/src/wiz_mmuhack.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -void wiz_mmuhack(int mem_fd) -{ - int mmufd = open("/dev/mmuhack", O_RDWR); - - - if(mmufd < 0) { - printf ("Installing NK's kernel module for Squidge MMU Hack...\n"); - system("/sbin/insmod mmuhack.ko"); - mmufd = open("/dev/mmuhack", O_RDWR); - } - if(mmufd < 0) return 0; - - close(mmufd); - return 1; -} - diff --git a/src/wiz_sdk.c b/src/wiz_sdk.c deleted file mode 100644 index c36c40e..0000000 --- a/src/wiz_sdk.c +++ /dev/null @@ -1,752 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "menu.h" -#include "wiz_sdk.h" -#include -#include "polluxregs.h" -#include -#include "asmmemfuncs.h" -#include "pollux_set.h" -#include "warm.h" - -#define SYS_CLK_FREQ 27 -#define BUFFERS 4 - -static int fb_size=(320*240*2); //+(16*2); - -//unsigned long gp2x_ticks_per_second=7372800/1000; -unsigned long wiz_dev[3]={0,0,0}; -unsigned long wiz_physvram[BUFFERS]={0,0,0,0}; - -unsigned short *framebuffer16[BUFFERS]={0,0,0,0}; -static unsigned short *framebuffer_mmap[BUFFERS]={0,0,0,0}; -unsigned short gp2x_sound_buffer[4+((44100*2)*8)]; //*2=stereo, *4=max buffers - -volatile short *pOutput[8]; -int InitFramebuffer=0; -int Timer=0; -volatile int SoundThreadFlag=0; -volatile int CurrentSoundBank=0; -int CurrentFrameBuffer=0; -int CurrentFrag=0; - -// 1024x8 8x8 font, i love it :) -const unsigned int font8x8[]= {0x0,0x0,0xc3663c18,0x3c2424e7,0xe724243c,0x183c66c3,0xc16f3818,0x18386fc1,0x83f61c18,0x181cf683,0xe7c3993c,0x3c99c3,0x3f7fffff,0xe7cf9f,0x3c99c3e7,0xe7c399,0x3160c080,0x40e1b,0xcbcbc37e,0x7ec3c3db,0x3c3c3c18,0x81c087e,0x8683818,0x60f0e08,0x81422418,0x18244281,0xbd5a2418,0x18245abd,0x818181ff,0xff8181,0xa1c181ff,0xff8995,0x63633e,0x3e6363,0x606060,0x606060,0x3e60603e,0x3e0303,0x3e60603e,0x3e6060,0x3e636363,0x606060,0x3e03033e,0x3e6060,0x3e03033e,0x3e6363,0x60603e,0x606060,0x3e63633e,0x3e6363,0x3e63633e,0x3e6060,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18181818,0x180018,0x666666,0x0,0x367f3600,0x367f36,0x3c067c18,0x183e60,0x18366600,0x62660c,0xe1c361c,0x6e337b,0x181818,0x0,0x18183870,0x703818,0x18181c0e,0xe1c18,0xff3c6600,0x663c,0x7e181800,0x1818,0x0,0x60c0c00,0x7e000000,0x0,0x0,0x181800,0x18306040,0x2060c,0x6e76663c,0x3c6666,0x18181c18,0x7e1818,0x3060663c,0x7e0c18,0x3018307e,0x3c6660,0x363c3830,0x30307e,0x603e067e,0x3c6660,0x3e06063c,0x3c6666,0x1830607e,0xc0c0c,0x3c66663c,0x3c6666,0x7c66663c,0x1c3060,0x181800,0x1818,0x181800,0xc1818,0xc183060,0x603018,0x7e0000,0x7e00,0x30180c06,0x60c18,0x3060663c,0x180018,0x5676663c,0x7c0676,0x66663c18,0x66667e,0x3e66663e,0x3e6666,0x606663c,0x3c6606,0x6666361e,0x1e3666,0x3e06067e,0x7e0606,0x3e06067e,0x60606,0x7606067c,0x7c6666,0x7e666666,0x666666,0x1818183c,0x3c1818,0x60606060,0x3c6660,0xe1e3666,0x66361e,0x6060606,0x7e0606,0x6b7f7763,0x636363,0x7e7e6e66,0x666676,0x6666663c,0x3c6666,0x3e66663e,0x60606,0x6666663c,0x6c366e,0x3e66663e,0x666636,0x3c06663c,0x3c6660,0x1818187e,0x181818,0x66666666,0x7c6666,0x66666666,0x183c66,0x6b636363,0x63777f,0x183c6666,0x66663c,0x3c666666,0x181818,0x1830607e,0x7e060c,0x18181878,0x781818,0x180c0602,0x406030,0x1818181e,0x1e1818,0x63361c08,0x0,0x0,0x7f0000,0xc060300,0x0,0x603c0000,0x7c667c,0x663e0606,0x3e6666,0x63c0000,0x3c0606,0x667c6060,0x7c6666,0x663c0000,0x3c067e,0xc3e0c38,0xc0c0c,0x667c0000,0x3e607c66,0x663e0606,0x666666,0x181c0018,0x3c1818,0x18180018,0xe181818,0x36660606,0x66361e,0x1818181c,0x3c1818,0x7f370000,0x63636b,0x663e0000,0x666666,0x663c0000,0x3c6666,0x663e0000,0x63e6666,0x667c0000,0x607c6666,0x663e0000,0x60606,0x67c0000,0x3e603c,0x187e1800,0x701818,0x66660000,0x7c6666,0x66660000,0x183c66,0x63630000,0x363e6b,0x3c660000,0x663c18,0x66660000,0x3e607c66,0x307e0000,0x7e0c18,0xc181870,0x701818,0x18181818,0x18181818,0x3018180e,0xe1818,0x794f0600,0x30}; - -pthread_t gp2x_sound_thread=0, gp2x_sound_thread_exit=0; - -uint32_t bkregs32[15]; /* backing up values */ -int layer_width[2]; -volatile uint32_t *memregs32; -volatile uint16_t *memregs16; -volatile uint8_t *memregs8; - -extern unsigned short * pOutputScreen; - -/* Sets the dirty flag for the MLC */ -static void lc_dirtymlc(void) -{ - MLCCONTROLT |= BIT(3); -} - -#define FBIO_MAGIC 'D' -#define FBIO_LCD_CHANGE_CONTROL _IOW(FBIO_MAGIC, 90, unsigned int[2]) -#define LCD_DIRECTION_ON_CMD 5 /* 320x240 */ -#define LCD_DIRECTION_OFF_CMD 6 /* 240x320 */ - -void lc_screensize(int w, int h) { - unsigned int send[2]; - int fb_fd = open("/dev/fb0", O_RDWR); - send[1] = 0; - /* alter MLC to rotate the display */ - if(w == 320 && h == 240) { - send[0] = LCD_DIRECTION_ON_CMD; - } else if(w == 240 && h == 320) { - send[0] = LCD_DIRECTION_OFF_CMD; - } - - /* send command to display controller */ - ioctl(fb_fd, FBIO_LCD_CHANGE_CONTROL, &send); - close(fb_fd); - /* apply the MLC changes */ - MLCSCREENSIZE = ((h-1)<<16) | (w-1); - lc_dirtymlc(); -} - -/* Sets the dirty flag for the layer */ -static void lc_dirtylayer(int layer) -{ - if(layer == 0) { - MLCCONTROL0 |= BIT(4); - } else { - MLCCONTROL1 |= BIT(4); - } -} - -/* Sets layer position */ -static void lc_layerpos(int layer, int x1, int y1, int x2, int y2) -{ - unsigned int temp_lr, temp_tb; - temp_lr = (x1 << 16) | x2; - temp_tb = (y1 << 16) | y2; - - if(layer == 0) { - MLCLEFTRIGHT0 = temp_lr; - MLCTOPBOTTOM0 = temp_tb; - } else { - MLCLEFTRIGHT1 = temp_lr; - MLCTOPBOTTOM1 = temp_tb; - } - lc_dirtylayer(layer); - - layer_width[layer] = (x2-x1)+1; -} - -/* Sets stride registers */ -static void lc_setstride(int layer, int hs, int vs) -{ - /* set how many bytes the MLC is supposed to read */ - if(layer == 0) { - MLCHSTRIDE0 = hs; - MLCVSTRIDE0 = vs; - } else { - MLCHSTRIDE1 = hs; - MLCVSTRIDE1 = vs; - } - lc_dirtylayer(layer); -} - -/* Sets layer properties */ -static void lc_setlayer(int layer, unsigned int onoff, unsigned int alpha, unsigned int invert, unsigned int trans, unsigned int mode) -{ - /* set layer properties register */ - unsigned int temp; - temp = 0; - if(onoff) temp |= BIT(5); - if(alpha) temp |= BIT(2); - if(invert) temp |= BIT(1); - if(trans) temp |= BIT(0); - temp |= BIT(12); - temp |= BIT(14); - temp |= BIT(15); - temp |= (mode<<16); - - if(layer == 0) { - MLCCONTROL0 = temp; - } else { - MLCCONTROL1= temp; - } - lc_dirtylayer(layer); - - int pixel_width = 0; - /* set stride based on pixel width*/ - switch(mode) { - case RGB565: - case BGR565: - case XRGB1555: - case XBGR1555: - case XRGB4444: - case XBGR4444: - case XRGB8332: - case XBGR8332: - case ARGB1555: - case ABGR1555: - case ARGB4444: - case ABGR4444: - case ARGB8332: - case ABGR8332: - pixel_width = 2; - break; - case RGB888: - case BGR888: - pixel_width = 3; - break; - case ARGB8888: - case ABGR8888: - pixel_width = 4; - break; - case PTRGB565: - pixel_width = 1; - break; - default: - break; - } - lc_setstride(layer, pixel_width, pixel_width*layer_width[layer]); -} - -/* Sets the background colour */ -static void lc_setbgcol(unsigned int colour) -{ - /* colour to be displayed where no layers cover */ - MLCBGCOLOR = colour; - lc_dirtymlc(); -} - -/* -######################## -Graphics functions -######################## - */ - -static void debug(char *text, int pause) -{ - gp_clearFramebuffer16(framebuffer16[currFB],0); - gp_drawString(0,0,strlen(text),text,(unsigned short)MENU_RGB(31,31,31),framebuffer16[currFB]); - MenuFlip(); - if(pause) MenuPause(); - -} - -static int clipping_x1 = 0; -static int clipping_x2 = 319; -static int clipping_y1 = 0; -static int clipping_y2 = 239; - -void gp_setClipping(int x1, int y1, int x2, int y2) { - if (x1 < 0) x1 = 0; - if (x1 > 319) x1 = 319; - if (x2 < 0) x2 = 0; - if (x2 > 319) x2 = 319; - if (y1 < 0) y1 = 0; - if (y1 > 239) y1 = 239; - if (y2 < 0) y2 = 0; - if (y2 > 239) y2 = 239; - - if (x1 < x2) { - clipping_x1 = x1; - clipping_x2 = x2; - } else { - clipping_x2 = x1; - clipping_x1 = x2; - } - - if (y1 < y2) { - clipping_y1 = y1; - clipping_y2 = y2; - } else { - clipping_y2 = y1; - clipping_y1 = y2; - } -} - -static __inline__ -void gp_drawPixel16 ( int x, int y, unsigned short c, unsigned short *framebuffer ) -{ - if ((x < clipping_x1) || (x > clipping_x2) || (y < clipping_y1) || (y > clipping_y2)) return; - *(framebuffer +(320*y)+x ) = c; -} -static -void set_char8x8_16bpp (int xx,int yy,int offset,unsigned short mode,unsigned short *framebuffer) -{ - unsigned int y, pixel; - offset *= 2; - pixel = font8x8[0 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y, mode, framebuffer); - } - pixel = font8x8[1 + offset]; - for (y = 0; y < 4; y++) - { - if (pixel&(1<<(0+(y<<3)))) gp_drawPixel16(xx+0, yy+y+4, mode, framebuffer); - if (pixel&(1<<(1+(y<<3)))) gp_drawPixel16(xx+1, yy+y+4, mode, framebuffer); - if (pixel&(1<<(2+(y<<3)))) gp_drawPixel16(xx+2, yy+y+4, mode, framebuffer); - if (pixel&(1<<(3+(y<<3)))) gp_drawPixel16(xx+3, yy+y+4, mode, framebuffer); - if (pixel&(1<<(4+(y<<3)))) gp_drawPixel16(xx+4, yy+y+4, mode, framebuffer); - if (pixel&(1<<(5+(y<<3)))) gp_drawPixel16(xx+5, yy+y+4, mode, framebuffer); - if (pixel&(1<<(6+(y<<3)))) gp_drawPixel16(xx+6, yy+y+4, mode, framebuffer); - if (pixel&(1<<(7+(y<<3)))) gp_drawPixel16(xx+7, yy+y+4, mode, framebuffer); - - } -} - -void gp_drawString (int x,int y,int len,char *buffer,unsigned short color,void *framebuffer) -{ - int l,base=0; - - for (l=0;l= 8) CurrentSoundBank = 0; - - //if (SoundThreadFlag==SOUND_THREAD_SOUND_ON) - //{ - write(wiz_dev[1], (void *)pOutput[CurrentSoundBank], gp2x_sound_buffer[1]); - CurrentSoundBank = (CurrentSoundBank + 1) & 7; - ioctl(wiz_dev[1], SOUND_PCM_SYNC, 0); - //ts.tv_sec=0, ts.tv_nsec=(gp2x_sound_buffer[3]<<16)|gp2x_sound_buffer[2]; - //nanosleep(&ts, NULL); -/* - } - else - { - write(wiz_dev[1], (void *)&gp2x_sound_buffer[4], gp2x_sound_buffer[1]); - //ioctl(wiz_dev[1], SOUND_PCM_SYNC, 0); - //ts.tv_sec=0, ts.tv_nsec=(gp2x_sound_buffer[3]<<16)|gp2x_sound_buffer[2]; - //nanosleep(&ts, NULL); - } -*/ - } - - return NULL; -} - -void gp_sound_volume(int l, int r) -{ - if(!wiz_dev[2]) - { - wiz_dev[2] = open("/dev/mixer", O_WRONLY); - } - - l=((l<<8)|r); - ioctl(wiz_dev[2], SOUND_MIXER_WRITE_PCM, &l); -} - -/* -unsigned long gp_timer_read(void) -{ - // Once again another peice of direct hardware access bites the dust - // the code below is broken in firmware 2.1.1 so I've replaced it with a - // to a linux function which seems to work - //return gp2x_memregl[0x0A00>>2]/gp2x_ticks_per_second; - struct timeval tval; // timing - - gettimeofday(&tval, 0); - //tval.tv_usec - //tval.tv_sec - return (tval.tv_sec*1000000)+tval.tv_usec; -} -*/ - -int gp_initSound(int rate, int bits, int stereo, int Hz, int frag) -{ - int status; - int i=0; - int nonblocking=1; - unsigned int bufferStart=0; - int result; - char text[256]; - - //int frag=0x00020010; // double buffer - frag size = 1<<0xf = 32768 - - //8 = 256 = 2 fps loss = good sound - //9 = 512 = 1 fps loss = good sound - //A = 1024 = - //f = 32768 = 0 fps loss = bad sound - /* - if ((frag!= CurrentFrag)&&(wiz_dev[1]!=0)) - { - // Different frag config required - // close device in order to re-adjust - close(wiz_dev[1]); - wiz_dev[1]=0; - } - */ - - if (wiz_dev[1]==0) - { - wiz_dev[1] = open("/dev/dsp", O_WRONLY); - printf("Opening sound device: %x\r\n",wiz_dev[1]); - //ioctl(wiz_dev[1], SNDCTL_DSP_SETFRAGMENT, &frag); - //CurrentFrag=frag; // save frag config - } - - //ioctl(wiz_dev[3], SNDCTL_DSP_RESET, 0); - result=ioctl(wiz_dev[1], SNDCTL_DSP_SPEED, &rate); - if(result==-1) - { - debug("Error setting DSP Speed",1); - return(-1); - } - - result=ioctl(wiz_dev[1], SNDCTL_DSP_SETFMT, &bits); - if(result==-1) - { - debug("Error setting DSP format",1); - return(-1); - } - - result=ioctl(wiz_dev[1], SNDCTL_DSP_STEREO, &stereo); - if(result==-1) - { - debug("Error setting DSP format",1); - return(-1); - } - //printf("Disable Blocking: %x\r\n",ioctl(wiz_dev[3], 0x5421, &nonblocking)); - - gp2x_sound_buffer[1]=(gp2x_sound_buffer[0]=(rate/Hz)) << (stereo + (bits==16)); - gp2x_sound_buffer[2]=(1000000000/Hz)&0xFFFF; - gp2x_sound_buffer[3]=(1000000000/Hz)>>16; - - bufferStart= (unsigned int)&gp2x_sound_buffer[4]; - pOutput[0] = (short*)bufferStart+(0*gp2x_sound_buffer[1]); - pOutput[1] = (short*)bufferStart+(1*gp2x_sound_buffer[1]); - pOutput[2] = (short*)bufferStart+(2*gp2x_sound_buffer[1]); - pOutput[3] = (short*)bufferStart+(3*gp2x_sound_buffer[1]); - pOutput[4] = (short*)bufferStart+(4*gp2x_sound_buffer[1]); - pOutput[5] = (short*)bufferStart+(5*gp2x_sound_buffer[1]); - pOutput[6] = (short*)bufferStart+(6*gp2x_sound_buffer[1]); - pOutput[7] = (short*)bufferStart+(7*gp2x_sound_buffer[1]); - - if(!gp2x_sound_thread) - { - pthread_create( &gp2x_sound_thread, NULL, gp2x_sound_play, NULL); - //atexit(gp_Reset); - } - - for(i=0;i<(gp2x_sound_buffer[1]*8);i++) - { - gp2x_sound_buffer[4+i] = 0; - } - - return(0); -} - -void gp_stopSound(void) -{ - unsigned int i=0; - gp2x_sound_thread_exit=1; - printf("Killing Thread\r\n"); - for(i=0;i<(gp2x_sound_buffer[1]*8);i++) - { - gp2x_sound_buffer[4+i] = 0; - } - usleep(100000); - printf("Thread is dead\r\n"); - gp2x_sound_thread=0; - gp2x_sound_thread_exit=0; - CurrentSoundBank=0; -} - - -/* -######################## -System functions -######################## - */ -void gp_Reset(void) -{ - unsigned int i=0; - - gp_setCpuspeed(533); - - if( gp2x_sound_thread) - { - gp2x_sound_thread_exit=1; - usleep(500); - } - - MLCADDRESS0 = bkregs32[0]; MLCADDRESS1 = bkregs32[1]; MLCCONTROL0 = bkregs32[2]; MLCCONTROL1 = bkregs32[3]; MLCLEFTRIGHT0 = bkregs32[4]; - MLCTOPBOTTOM0 = bkregs32[5]; MLCLEFTRIGHT1 = bkregs32[6]; MLCTOPBOTTOM1 = bkregs32[7]; MLCBGCOLOR = bkregs32[8]; MLCHSTRIDE0 = bkregs32[9]; - MLCVSTRIDE0 = bkregs32[10]; MLCHSTRIDE1 = bkregs32[11]; MLCVSTRIDE1 = bkregs32[12]; DPCCTRL1 = bkregs32[13]; MLCSCREENSIZE = bkregs32[14]; - - lc_dirtylayer(0); - lc_dirtylayer(1); - lc_dirtymlc(); - - munmap((void *)memregs32, 0x20000); - - munmap(framebuffer_mmap[0], fb_size * BUFFERS); - - if (wiz_dev[0]) close(wiz_dev[0]); - if (wiz_dev[1]) close(wiz_dev[1]); - if (wiz_dev[2]) close(wiz_dev[2]); - - fcloseall(); - - chdir("/usr/gp2x"); - execl("gp2xmenu",NULL); -} - -void gp_video_RGB_setscaling(int W, int H) -{ - uint16_t * pSource = (uint16_t *)pOutputScreen; - uint16_t * pTarget = (uint16_t *)framebuffer16[currFB]; - unsigned short y; - unsigned short x; - if (H == 239) - { - for (y = 240; y != 0; y--) - { - pSource+=32; - for (x = 64; x != 0; x--) - { - pTarget[0] = pSource[0]; - pTarget[1] = pSource[1]; - pTarget[2] = pSource[2]; - pTarget[3] = pSource[3]; - pTarget[4] = pSource[3]; - pTarget+=5; - pSource+=4; - } - pSource+=32; - } - } - else // 224 - { - pSource += 2560; - unsigned short pos = 2; - for (y = 240; y != 0; y--) - { - pSource+=32; - for (x = 64; x != 0; x--) - { - pTarget[0] = pSource[0]; - pTarget[1] = pSource[1]; - pTarget[2] = pSource[2]; - pTarget[3] = pSource[3]; - pTarget[4] = pSource[3]; - pTarget+=5; - pSource+=4; - } - pSource+=32; - pos--; - - if (pos == 0) - { - pSource -= 320; - pos = 14; - } - } - } -} - -#define COLORMIX(a, b) ( ((((a & 0xF81F) + (b & 0xF81F)) >> 1) & 0xF81F) | ((((a & 0x07E0) + (b & 0x07E0)) >> 1) & 0x07E0) ) -void gp_video_RGB_setHZscaling(int W, int H) -{ - uint16_t * pSource = (uint16_t *)pOutputScreen; - uint16_t * pTarget = (uint16_t *)framebuffer16[currFB]; - unsigned short y; - unsigned short x; - - if (H == 224) - { - pSource += 2560; - pTarget += 2560; - } - for (y = H; y != 0; y--) - { - pSource+=32; - for (x = 64; x != 0; x--) - { - pTarget[0] = pSource[0]; - pTarget[1] = pSource[1]; - pTarget[2] = pSource[2]; - pTarget[3] = COLORMIX(pSource[2],pSource[3]); - pTarget[4] = pSource[3]; - pTarget+=5; - pSource+=4; - } - pSource+=32; - } -} - -void gp_setCpuspeed(unsigned int MHZ) -{ - unsigned long v; - unsigned mdiv, pdiv=9, sdiv=0; - - mdiv= (MHZ * pdiv) / SYS_CLK_FREQ; - mdiv &= 0x3FF; - v= pdiv<<18 | mdiv<<8 | sdiv; - - PLLSETREG0 = v; - PWRMODE |= 0x8000; -} - -// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2 -// set_RAM_Timings(6, 4, 1, 1, 1, 2, 2); -void set_RAM_Timings(int tRC, int tRAS, int tWR, int tMRD, int tRFC, int tRP, int tRCD) -{ -} - -void set_gamma(int g100) -{ -} - - - - - diff --git a/src/wiz_sdk.h b/src/wiz_sdk.h deleted file mode 100644 index 1a613c9..0000000 --- a/src/wiz_sdk.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _WIZ_SDK_H_ -#define _WIZ_SDK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define UPPERMEM_START 0x3000000 -//0x2A00000 -#define UPPERMEM_SIZE (0x4000000-UPPERMEM_START) - -#define SOUND_THREAD_SOUND_ON 1 -#define SOUND_THREAD_SOUND_OFF 2 -#define SOUND_THREAD_PAUSE 3 - -#define INP_BUTTON_UP (18) -#define INP_BUTTON_LEFT (16) -#define INP_BUTTON_DOWN (19) -#define INP_BUTTON_RIGHT (17) -#define INP_BUTTON_START (9) -#define INP_BUTTON_SELECT (8) -#define INP_BUTTON_L (7) -#define INP_BUTTON_R (6) -#define INP_BUTTON_A (20) -#define INP_BUTTON_B (21) -#define INP_BUTTON_X (22) -#define INP_BUTTON_Y (23) -#define INP_BUTTON_VOL_UP (10) -#define INP_BUTTON_VOL_DOWN (11) - -void gp_setClipping(int x1, int y1, int x2, int y2); -void gp_drawString (int x,int y,int len,char *buffer,unsigned short color,void *framebuffer); -void gp_clearFramebuffer16(unsigned short *framebuffer, unsigned short pal); -void gp_setCpuspeed(unsigned int cpuspeed); -void gp_initGraphics(unsigned short bpp, int flip, int applyMmuHack); -void gp_setFramebuffer(int flip, int sync); -int gp_initSound(int rate, int bits, int stereo, int Hz, int frag); -void gp_stopSound(void); -void gp_Reset(void); -void gp_sound_volume(int l, int r); -//unsigned long gp_timer_read(void); -#define gp_timer_read clock - -unsigned int gp_getButton(unsigned char enable_diagnals); -void gp_video_RGB_setscaling(int W, int H); -void gp_video_RGB_setHZscaling(int W, int H); -void set_gamma(int g100); -void set_RAM_Timings(int tRC, int tRAS, int tWR, int tMRD, int tRFC, int tRP, int tRCD); - -extern volatile int SoundThreadFlag; -extern volatile int CurrentSoundBank; -extern int CurrentFrameBuffer; -extern volatile short *pOutput[]; -extern unsigned short *framebuffer16[]; -extern unsigned long wiz_physvram[]; -extern volatile unsigned short *wiz_memregs; -extern void *uppermem; - -#ifdef __cplusplus -} -#endif - -#endif - -- cgit v1.2.3