Tagging the 0.9.2 release.

This commit is contained in:
yabause 2009-04-11 22:25:42 +00:00
parent 9fa2003bc5
commit 12e4c81d05
359 changed files with 1858 additions and 2517 deletions

View File

View File

View File

@ -1,7 +1,7 @@
dnl --- Package name is first argument to AC_INIT dnl --- Package name is first argument to AC_INIT
dnl --- Release version is second argument to AC_INIT dnl --- Release version is second argument to AC_INIT
AC_INIT(desmume, [svn]) AC_INIT(desmume, [0.9.2])
dnl -- find target architecture for some os specific libraries dnl -- find target architecture for some os specific libraries
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
@ -59,7 +59,6 @@ AC_ARG_ENABLE([osmesa],
[osmesa=no]) [osmesa=no])
if test "x$osmesa" = "xyes" ; then if test "x$osmesa" = "xyes" ; then
AC_CHECK_LIB(dl, main)
AC_CHECK_LIB(OSMesa, main,[ AC_CHECK_LIB(OSMesa, main,[
useosmesa=yes useosmesa=yes
AC_DEFINE(HAVE_LIBOSMESA) AC_DEFINE(HAVE_LIBOSMESA)

View File

@ -1,16 +0,0 @@
#ifndef MIC_H
#define MIC_H
#ifdef WIN32
extern int MicButtonPressed;
static char MicSampleName[256];
char* LoadSample(const char *name);
extern int MicDisplay;
#endif
BOOL Mic_Init();
void Mic_Reset();
void Mic_DeInit();
u8 Mic_ReadSample();
#endif

View File

@ -1,583 +0,0 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../MMU.h"
#include "debug.h"
#include "resource.h"
#include "common.h"
#include <algorithm>
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include "memView.h"
using namespace std;
//////////////////////////////////////////////////////////////////////////////
typedef struct MemView_DataStruct
{
MemView_DataStruct(u8 CPU) : cpu(CPU), address(0x02000000), viewMode(0)
{
}
HWND hDlg;
u8 cpu;
u32 address;
u8 viewMode;
} MemView_DataStruct;
MemView_DataStruct * MemView_Data[2] = {NULL, NULL};
//////////////////////////////////////////////////////////////////////////////
BOOL MemView_Init()
{
WNDCLASSEX wc;
wc.cbSize = sizeof(wc);
wc.lpszClassName = "MemView_ViewBox";
wc.hInstance = hAppInst;
wc.lpfnWndProc = MemView_ViewBoxProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = 0;
wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(MemView_DataStruct);
wc.hIconSm = 0;
RegisterClassEx(&wc);
return 1;
}
void MemView_DeInit()
{
UnregisterClass("MemView_ViewBox", hAppInst);
}
//////////////////////////////////////////////////////////////////////////////
BOOL MemView_DlgOpen(HWND hParentWnd, u8 CPU)
{
HWND hDlg;
char title[32];
MemView_Data[CPU] = new MemView_DataStruct(CPU);
if(MemView_Data[CPU] == NULL)
return 0;
hDlg = CreateDialogParam(hAppInst, MAKEINTRESOURCE(IDD_MEM_VIEW), hParentWnd, MemView_DlgProc, (LPARAM)MemView_Data[CPU]);
if(hDlg == NULL)
return 0;
MemView_Data[CPU]->hDlg = hDlg;
sprintf(title, "ARM%s memory", ((CPU == ARMCPU_ARM7) ? "7" : "9"));
SetWindowText(hDlg, title);
ShowWindow(hDlg, SW_SHOW);
UpdateWindow(hDlg);
return 1;
}
void MemView_DlgClose(u8 CPU)
{
if(MemView_Data[CPU] != NULL)
{
DestroyWindow(MemView_Data[CPU]->hDlg);
delete MemView_Data[CPU];
MemView_Data[CPU] = NULL;
}
}
BOOL MemView_IsOpened(u8 CPU)
{
return (MemView_Data[CPU] != NULL);
}
void MemView_Refresh(u8 CPU)
{
InvalidateRect(MemView_Data[CPU]->hDlg, NULL, FALSE);
UpdateWindow(MemView_Data[CPU]->hDlg);
}
//////////////////////////////////////////////////////////////////////////////
LRESULT MemView_DlgPaint(HWND hDlg, MemView_DataStruct *data, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hDlg, &ps);
EndPaint(hDlg, &ps);
return 0;
}
BOOL CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MemView_DataStruct *data = (MemView_DataStruct*)GetWindowLong(hDlg, DWL_USER);
if((data == NULL) && (uMsg != WM_INITDIALOG))
return 0;
switch(uMsg)
{
case WM_INITDIALOG:
{
if(data == NULL)
{
data = (MemView_DataStruct*)lParam;
SetWindowLong(hDlg, DWL_USER, (LONG)data);
}
CheckRadioButton(hDlg, IDC_8_BIT, IDC_32_BIT, IDC_8_BIT);
SendMessage(GetDlgItem(hDlg, IDC_ADDRESS), EM_SETLIMITTEXT, 8, 0);
SetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), "02000000");
SetWindowLong(GetDlgItem(hDlg, IDC_MEMVIEWBOX), DWL_USER, (LONG)data);
InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg);
}
return 1;
case WM_CLOSE:
case WM_DESTROY:
MemView_DlgClose(data->cpu);
return 1;
case WM_PAINT:
MemView_DlgPaint(hDlg, data, wParam, lParam);
return 1;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCANCEL:
MemView_DlgClose(data->cpu);
return 1;
case IDC_8_BIT:
case IDC_16_BIT:
case IDC_32_BIT:
CheckRadioButton(hDlg, IDC_8_BIT, IDC_32_BIT, LOWORD(wParam));
data->viewMode = (LOWORD(wParam) - IDC_8_BIT);
InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg);
return 1;
case IDC_GO:
{
char addrstr[9];
int len;
int i;
int shift;
BOOL error = FALSE;
u32 address = 0x00000000;
len = GetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), addrstr, 9);
for(i = 0; i < len; i++)
{
char ch = addrstr[i];
if((ch >= '0') && (ch <= '9'))
continue;
if((ch >= 'A') && (ch <= 'F'))
continue;
if((ch >= 'a') && (ch <= 'f'))
continue;
if(ch == '\0')
break;
error = TRUE;
break;
}
if(error)
{
MessageBox(hDlg, "Error:\nInvalid address specified.\nThe address must be an hexadecimal value.", "DeSmuME", (MB_OK | MB_ICONERROR));
SetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), "");
return 1;
}
for(i = (len-1), shift = 0; i >= 0; i--, shift += 4)
{
char ch = addrstr[i];
if((ch >= '0') && (ch <= '9'))
address |= ((ch - '0') << shift);
else if((ch >= 'A') && (ch <= 'F'))
address |= ((ch - 'A' + 0xA) << shift);
else if((ch >= 'a') && (ch <= 'f'))
address |= ((ch - 'a' + 0xA) << shift);
}
data->address = min((u32)0xFFFFFF00, (address & 0xFFFFFFF0));
SetScrollPos(GetDlgItem(hDlg, IDC_MEMVIEWBOX), SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE);
InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg);
}
return 1;
case IDC_TEXTDUMP:
{
char fileName[256] = "";
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = "Text file (*.txt)\0*.txt\0Any file (*.*)\0*.*\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFile = fileName;
ofn.nMaxFile = 256;
ofn.lpstrDefExt = "txt";
ofn.Flags = OFN_NOCHANGEDIR;
if(GetSaveFileName(&ofn))
{
FILE *f;
u8 memory[0x100];
int line;
MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory);
f = fopen(fileName, "a");
for(line = 0; line < 16; line++)
{
int i;
fprintf(f, "%08X\t\t", (data->address + (line << 4)));
switch(data->viewMode)
{
case 0:
{
for(i = 0; i < 16; i++)
{
fprintf(f, "%02X ", T1ReadByte(memory, ((line << 4) + i)));
}
fprintf(f, "\t");
}
break;
case 1:
{
for(i = 0; i < 16; i += 2)
{
fprintf(f, "%04X ", T1ReadWord(memory, ((line << 4) + i)));
}
fprintf(f, "\t\t");
}
break;
case 2:
{
for(i = 0; i < 16; i += 4)
{
fprintf(f, "%08X ", T1ReadLong(memory, ((line << 4) + i)));
}
fprintf(f, "\t\t\t");
}
break;
}
for(i = 0; i < 16; i++)
{
u8 val = T1ReadByte(memory, ((line << 4) + i));
if((val >= 32) && (val <= 127))
fprintf(f, "%c", (char)val);
else
fprintf(f, ".");
}
fprintf(f, "\n");
}
fclose(f);
}
}
return 1;
case IDC_RAWDUMP:
{
char fileName[256] = "";
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = "Binary file (*.bin)\0*.bin\0Any file (*.*)\0*.*\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFile = fileName;
ofn.nMaxFile = 256;
ofn.lpstrDefExt = "bin";
ofn.Flags = OFN_NOCHANGEDIR;
if(GetSaveFileName(&ofn))
{
FILE *f;
u8 memory[0x100];
int line;
MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory);
f = fopen(fileName, "ab");
fwrite(memory, 0x100, 1, f);
fclose(f);
}
}
return 1;
}
return 0;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////////
LRESULT MemView_ViewBoxPaint(HWND hCtl, MemView_DataStruct *data, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rc;
int w, h;
SIZE fontsize;
int fontwidth, fontheight;
HDC mem_hdc;
HBITMAP mem_bmp;
GetClientRect(hCtl, &rc);
w = (rc.right - rc.left);
h = (rc.bottom - rc.top);
hdc = BeginPaint(hCtl, &ps);
mem_hdc = CreateCompatibleDC(hdc);
mem_bmp = CreateCompatibleBitmap(hdc, w, h);
SelectObject(mem_hdc, mem_bmp);
SelectObject(mem_hdc, GetStockObject(SYSTEM_FIXED_FONT));
GetTextExtentPoint32(mem_hdc, " ", 1, &fontsize);
fontwidth = fontsize.cx;
fontheight = fontsize.cy;
FillRect(mem_hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));
if(data != NULL)
{
u32 addr = data->address;
u8 memory[0x100];
char text[80];
int startx, cury;
int line;
startx = 0;
cury = 0;
sprintf(text, " ");
GetTextExtentPoint32(mem_hdc, text, strlen(text), &fontsize);
startx = (fontsize.cx + 5);
cury = (fontsize.cy + 3);
MoveToEx(mem_hdc, (fontsize.cx + 2), 0, NULL);
LineTo(mem_hdc, (fontsize.cx + 2), h);
MoveToEx(mem_hdc, 0, (fontsize.cy + 1), NULL);
LineTo(mem_hdc, w, (fontsize.cy + 1));
switch(data->viewMode)
{
case 0:
{
sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
TextOut(mem_hdc, startx, 0, text, strlen(text));
}
break;
case 1:
{
sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
TextOut(mem_hdc, startx, 0, text, strlen(text));
}
break;
case 2:
{
sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
TextOut(mem_hdc, startx, 0, text, strlen(text));
}
break;
}
MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory);
for(line = 0; line < 16; line++, addr += 0x10)
{
int i;
sprintf(text, "%08X", addr);
TextOut(mem_hdc, 0, cury, text, strlen(text));
switch(data->viewMode)
{
case 0:
{
sprintf(text, " ");
for(i = 0; i < 16; i++)
{
sprintf(text, "%s%02X ", text, T1ReadByte(memory, ((line << 4) + i)));
}
sprintf(text, "%s ", text);
}
break;
case 1:
{
sprintf(text, " ");
for(i = 0; i < 16; i += 2)
{
sprintf(text, "%s%04X ", text, T1ReadWord(memory, ((line << 4) + i)));
}
sprintf(text, "%s ", text);
}
break;
case 2:
{
sprintf(text, " ");
for(i = 0; i < 16; i += 4)
{
sprintf(text, "%s%08X ", text, T1ReadLong(memory, ((line << 4) + i)));
}
sprintf(text, "%s ", text);
}
break;
}
for(i = 0; i < 16; i++)
{
u8 val = T1ReadByte(memory, ((line << 4) + i));
if((val >= 32) && (val <= 127))
sprintf(text, "%s%c", text, (char)val);
else
sprintf(text, "%s.", text);
}
TextOut(mem_hdc, startx, cury, text, strlen(text));
cury += fontheight;
}
}
BitBlt(hdc, 0, 0, w, h, mem_hdc, 0, 0, SRCCOPY);
DeleteDC(mem_hdc);
DeleteObject(mem_bmp);
EndPaint(hCtl, &ps);
return 0;
}
LRESULT CALLBACK MemView_ViewBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MemView_DataStruct *data = (MemView_DataStruct*)GetWindowLong(hCtl, DWL_USER);
switch(uMsg)
{
case WM_NCCREATE:
SetScrollRange(hCtl, SB_VERT, 0x00000000, 0x000FFFF0, TRUE);
SetScrollPos(hCtl, SB_VERT, 0x00000000, TRUE);
return 1;
case WM_NCDESTROY:
return 1;
case WM_ERASEBKGND:
return 1;
case WM_PAINT:
MemView_ViewBoxPaint(hCtl, data, wParam, lParam);
return 1;
case WM_VSCROLL:
{
int firstpos = GetScrollPos(hCtl, SB_VERT);
switch(LOWORD(wParam))
{
case SB_LINEUP:
data->address = (u32)max(0x00000000, ((int)data->address - 0x10));
break;
case SB_LINEDOWN:
data->address = min((u32)0xFFFFFF00, (data->address + 0x10));
break;
case SB_PAGEUP:
data->address = (u32)max(0x00000000, ((int)data->address - 0x100));
break;
case SB_PAGEDOWN:
data->address = min((u32)0xFFFFFF00, (data->address + 0x100));
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
{
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
si.fMask = SIF_TRACKPOS;
GetScrollInfo(hCtl, SB_VERT, &si);
data->address = min((u32)0xFFFFFF00, (data->address + ((si.nTrackPos - firstpos) * 16)));
}
break;
}
SetScrollPos(hCtl, SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE);
InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl);
}
return 1;
}
return DefWindowProc(hCtl, uMsg, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -11,16 +11,18 @@ struct ALIGN(16) ARM9_struct {
u8 ARM9_REG[0x1000000]; u8 ARM9_REG[0x1000000];
u8 ARM9_BIOS[0x8000]; u8 ARM9_BIOS[0x8000];
u8 ARM9_VMEM[0x800]; u8 ARM9_VMEM[0x800];
u8 ARM9_ABG[0x80000];
u8 ARM9_BBG[0x20000];
u8 ARM9_AOBJ[0x40000];
u8 ARM9_BOBJ[0x20000];
u8 ARM9_LCD[0xA4000]; u8 ARM9_LCD[0xA4000];
u8 ARM9_OAM[0x800]; u8 ARM9_OAM[0x800];
u8* ExtPal[2][4]; u8 * ExtPal[2][4];
u8* ObjExtPal[2][2]; u8 * ObjExtPal[2][2];
u8 * texPalSlot[6];
struct TextureInfo { u8 *textureSlotAddr[4];
u8* texPalSlot[6];
u8* textureSlotAddr[4];
} texInfo;
u8 blank_memory[0x20000]; u8 blank_memory[0x20000];
}; };

View File

@ -3714,7 +3714,7 @@ static char * OP_LDMIA_THUMB(u32 adr, u32 i, char * txt)
static char * OP_B_COND(u32 adr, u32 i, char * txt) static char * OP_B_COND(u32 adr, u32 i, char * txt)
{ {
sprintf(txt, "B%s #%X", Condition[(i>>8)&0xF], (int)(adr+(((s32)((signed char)(i&0xFF)))<<1)+4)); sprintf(txt, "B%s #%X", Condition[(i>>8)&0xF], (int)(adr+(((signed long)((signed char)(i&0xFF)))<<1)+4));
return txt; return txt;
} }

View File

@ -53,6 +53,23 @@
#include "debug.h" #include "debug.h"
#include "NDSSystem.h" #include "NDSSystem.h"
//#define CHECKSPRITES
#ifdef CHECKSPRITES
#define CHECK_SPRITE(type) \
if (!src) {\
INFO("Sprite%s(%s) in mode %i %s\n",\
type==1?"1D":"2D",\
dispCnt->OBJ_BMP_mapping==1?"1D":"2D",\
spriteInfo->Mode,\
(spriteInfo->RotScale & 1)?"(Rotoscaled)":"");\
continue;\
};
#else
#define CHECK_SPRITE(type) if (!src) { continue; };
#endif
ARM9_struct ARM9Mem; ARM9_struct ARM9Mem;
extern BOOL click; extern BOOL click;
@ -276,7 +293,7 @@ void GPU_Reset(GPU *g, u8 l)
g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256;
g->dispOBJ = g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; g->dispOBJ = g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE;
g->spriteRenderMode = GPU::SPRITE_1D; g->spriteRender = sprite1D;
g->bgPrio[4] = 0xFF; g->bgPrio[4] = 0xFF;
@ -452,21 +469,20 @@ void GPU_setVideoProp(GPU * gpu, u32 p)
if(cnt->OBJ_Tile_mapping) if(cnt->OBJ_Tile_mapping)
{ {
// 1-d sprite mapping /* 1-d sprite mapping */
// boundary : // boundary :
// core A : 32k, 64k, 128k, 256k // core A : 32k, 64k, 128k, 256k
// core B : 32k, 64k, 128k, 128k // core B : 32k, 64k, 128k, 128k
gpu->sprBoundary = 5 + cnt->OBJ_Tile_1D_Bound ; gpu->sprBoundary = 5 + cnt->OBJ_Tile_1D_Bound ;
if((gpu->core == GPU_SUB) && (cnt->OBJ_Tile_1D_Bound == 3))
gpu->sprBoundary = 7;
//zero 10-apr-09 - not sure whether this is right... gpu->spriteRender = sprite1D;
if((gpu->core == GPU_SUB) && (cnt->OBJ_Tile_1D_Bound == 3)) gpu->sprBoundary = 7;
gpu->spriteRenderMode = GPU::SPRITE_1D;
} else { } else {
// 2d sprite mapping /* 2d sprite mapping */
// boundary : 32k // boundary : 32k
gpu->sprBoundary = 5; gpu->sprBoundary = 5;
gpu->spriteRenderMode = GPU::SPRITE_2D; gpu->spriteRender = sprite2D;
} }
if(cnt->OBJ_BMP_1D_Bound && (gpu->core == GPU_MAIN)) if(cnt->OBJ_BMP_1D_Bound && (gpu->core == GPU_MAIN))
@ -2038,26 +2054,14 @@ FORCEINLINE BOOL compute_sprite_vars(_OAM_ * spriteInfo, u16 l,
/*****************************************************************************/ /*****************************************************************************/
// SPRITE RENDERING // SPRITE RENDERING
/*****************************************************************************/ /*****************************************************************************/
void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
void GPU::spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
{ {
if(spriteRenderMode == SPRITE_1D)
_spriteRender<SPRITE_1D>(dst,dst_alpha,typeTab, prioTab);
else
_spriteRender<SPRITE_2D>(dst,dst_alpha,typeTab, prioTab);
}
template<GPU::SpriteRenderMode MODE>
void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
{
u16 l = currLine;
GPU *gpu = this;
struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits;
_OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + (nbShow-1));// + 127; _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + (nbShow-1));// + 127;
u8 block = gpu->sprBoundary; u8 block = gpu->sprBoundary;
u16 i; u16 i;
//for(i = 0; i<nbShow; ++i, --spriteInfo) /* check all sprites */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15; *(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15;
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14; *(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14;
@ -2070,11 +2074,8 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15 ,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15
,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14 ,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14
#endif #endif
) ) /* check all sprites */
{ {
const int oamNum = 127 - i;
//for each sprite:
size sprSize; size sprSize;
s32 sprX, sprY, x, y, lg; s32 sprX, sprY, x, y, lg;
int xdir; int xdir;
@ -2157,11 +2158,8 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
// If we are using 1 palette of 256 colours // If we are using 1 palette of 256 colours
if(spriteInfo->Depth) if(spriteInfo->Depth)
{ {
//2d: src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex) << 5));
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex << block)); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex << block));
if (!src) { CHECK_SPRITE(1);
continue;
}
// If extended palettes are set, use them // If extended palettes are set, use them
if (dispCnt->ExOBJPalette_Enable) if (dispCnt->ExOBJPalette_Enable)
@ -2177,14 +2175,12 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y)
{ {
if(MODE == SPRITE_2D)
offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*8);
else
offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)*sprSize.x*8) + ((auxY&0x7)*8); offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)*sprSize.x*8) + ((auxY&0x7)*8);
colour = src[offset]; colour = src[offset];
if (colour && (prioTab[sprX]>=prio)) if (colour && (prioTab[sprX]>=prio))
{
//if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, T1ReadWord(pal, colour<<1), sprX ))
{ {
T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1))); T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1)));
dst_alpha[sprX] = 16; dst_alpha[sprX] = 16;
@ -2192,6 +2188,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
prioTab[sprX] = prio; prioTab[sprX] = prio;
} }
} }
}
// Add the rotation/scale coeficients, here the rotation/scaling // Add the rotation/scale coeficients, here the rotation/scaling
// is performed // is performed
@ -2208,10 +2205,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex)*32); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex)*32);
else else
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x03E0) * 8) + (spriteInfo->TileIndex&0x001F))*16); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x03E0) * 8) + (spriteInfo->TileIndex&0x001F))*16);
CHECK_SPRITE(1);
if (!src) {
continue;
}
for(j = 0; j < lg; ++j, ++sprX) for(j = 0; j < lg; ++j, ++sprX)
{ {
@ -2221,14 +2215,12 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y)
{ {
if(MODE == SPRITE_2D)
offset = auxX + (auxY<<8);
else
offset = (auxX) + (auxY<<5); offset = (auxX) + (auxY<<5);
colour = T1ReadWord (src, offset<<1); colour = T1ReadWord (src, offset<<1);
if((colour&0x8000) && (prioTab[sprX]>=prio)) if((colour&0x8000) && (prioTab[sprX]>=prio))
{
// if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, colour, sprX))
{ {
T2WriteWord(dst, (sprX<<1), colour); T2WriteWord(dst, (sprX<<1), colour);
dst_alpha[sprX] = spriteInfo->PaletteIndex; dst_alpha[sprX] = spriteInfo->PaletteIndex;
@ -2236,6 +2228,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
prioTab[sprX] = prio; prioTab[sprX] = prio;
} }
} }
}
// Add the rotation/scale coeficients, here the rotation/scaling // Add the rotation/scale coeficients, here the rotation/scaling
// is performed // is performed
@ -2248,20 +2241,9 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
// Rotozoomed 16/16 palette // Rotozoomed 16/16 palette
else else
{ {
if(MODE == SPRITE_2D)
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<5));
pal = ARM9Mem.ARM9_VMEM + 0x200 + (gpu->core*0x400 + (spriteInfo->PaletteIndex*32));
}
else
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<gpu->sprBoundary));
pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core*0x400 + (spriteInfo->PaletteIndex*32); pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core*0x400 + (spriteInfo->PaletteIndex*32);
} src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<gpu->sprBoundary));
CHECK_SPRITE(1);
if (!src) {
continue;
}
for(j = 0; j < lg; ++j, ++sprX) for(j = 0; j < lg; ++j, ++sprX)
{ {
@ -2271,11 +2253,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y)
{ {
if(MODE == SPRITE_2D)
offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*4);
else
offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)*sprSize.x)*4 + ((auxY&0x7)*4); offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)*sprSize.x)*4 + ((auxY&0x7)*4);
colour = src[offset]; colour = src[offset];
// Get 4bits value from the readed 8bits // Get 4bits value from the readed 8bits
@ -2283,6 +2261,8 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
else colour &= 0xF; else colour &= 0xF;
if(colour && (prioTab[sprX]>=prio)) if(colour && (prioTab[sprX]>=prio))
{
//if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, T1ReadWord(pal, colour<<1), sprX ))
{ {
T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1))); T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1)));
dst_alpha[sprX] = 16; dst_alpha[sprX] = 16;
@ -2290,6 +2270,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
prioTab[sprX] = prio; prioTab[sprX] = prio;
} }
} }
}
// Add the rotation/scale coeficients, here the rotation/scaling // Add the rotation/scale coeficients, here the rotation/scaling
// is performed // is performed
@ -2304,29 +2285,16 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
{ {
u16 * pal; u16 * pal;
if (!compute_sprite_vars(spriteInfo, l, sprSize, sprX, sprY, x, y, lg, xdir)) if (!compute_sprite_vars(spriteInfo, l, sprSize, sprX, sprY, x, y, lg, xdir))
continue; continue;
if (spriteInfo->Mode == 2) if (spriteInfo->Mode == 2)
{
if(MODE == SPRITE_2D)
{
if (spriteInfo->Depth)
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8));
else
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4));
}
else
{ {
if (spriteInfo->Depth) if (spriteInfo->Depth)
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*8) + ((y&0x7)*8)); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*8) + ((y&0x7)*8));
else else
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*4) + ((y&0x7)*4)); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*4) + ((y&0x7)*4));
} CHECK_SPRITE(1);
if (!src) {
continue;
}
render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir); render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir);
continue; continue;
@ -2347,10 +2315,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
else // 128 * 512 else // 128 * 512
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8 + ( y << 8)) << 1)); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8 + ( y << 8)) << 1));
} }
CHECK_SPRITE(1);
if (!src) {
continue;
}
render_sprite_BMP (gpu, i, l, dst, (u16*)src, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->PaletteIndex); render_sprite_BMP (gpu, i, l, dst, (u16*)src, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->PaletteIndex);
continue; continue;
@ -2358,14 +2323,308 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
if(spriteInfo->Depth) /* 256 colors */ if(spriteInfo->Depth) /* 256 colors */
{ {
if(MODE == SPRITE_2D)
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8));
else
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*8) + ((y&0x7)*8)); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*8) + ((y&0x7)*8));
CHECK_SPRITE(1);
if (dispCnt->ExOBJPalette_Enable)
pal = (u16*)(ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200));
else
pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400);
//sprwin test hack - to enable, only draw win and not sprite
render_sprite_256 (gpu, i, l, dst, src, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
//render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir);
if (!src) {
continue; continue;
} }
/* 16 colors */
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*4) + ((y&0x7)*4));
CHECK_SPRITE(1);
pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400);
pal += (spriteInfo->PaletteIndex<<4);
//sprwin test hack - to enable, only draw win and not sprite
render_sprite_16 (gpu, l, dst, src, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
//render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir);
}
}
#ifdef WORDS_BIGENDIAN
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) << 1) | *(((u16*)spriteInfo)+1) >> 15;
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) << 2) | *(((u16*)spriteInfo)+2) >> 14;
#endif
}
void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
{
struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits;
_OAM_ * spriteInfo = (_OAM_*)(gpu->oam + (nbShow-1));// + 127;
u16 i;
#ifdef WORDS_BIGENDIAN
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15;
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14;
#endif
for(i = 0; i<nbShow; ++i, --spriteInfo
#ifdef WORDS_BIGENDIAN
,*(((u16*)(spriteInfo+1))+1) = (*(((u16*)(spriteInfo+1))+1) << 1) | *(((u16*)(spriteInfo+1))+1) >> 15
,*(((u16*)(spriteInfo+1))+2) = (*(((u16*)(spriteInfo+1))+2) << 2) | *(((u16*)(spriteInfo+1))+2) >> 14
,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15
,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14
#endif
) /* check all sprites */
{
size sprSize;
s32 sprX, sprY, x, y, lg;
int xdir;
u8 prio, * src;
//u16 * pal;
u16 j;
// Check if sprite is disabled before everything
if (spriteInfo->RotScale == 2)
continue;
prio = spriteInfo->Priority;
if (spriteInfo->RotScale & 1)
{
s32 fieldX, fieldY, auxX, auxY, realX, realY, offset;
u8 blockparameter, *pal;
s16 dx, dmx, dy, dmy;
u16 colour;
// Get sprite positions and size
sprX = (spriteInfo->X<<23)>>23;
sprY = spriteInfo->Y;
sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape];
lg = sprSize.x;
if (sprY>=192)
sprY = (s32)((s8)(spriteInfo->Y));
// Copy sprite size, to check change it if needed
fieldX = sprSize.x;
fieldY = sprSize.y;
// If we are using double size mode, double our control vars
if (spriteInfo->RotScale & 2)
{
fieldX <<= 1;
fieldY <<= 1;
lg <<= 1;
}
// Check if sprite enabled
if ((l <sprY) || (l >= sprY+fieldY) ||
(sprX==256) || (sprX+fieldX<=0))
continue;
y = l - sprY;
// Get which four parameter block is assigned to this sprite
blockparameter = (spriteInfo->RotScalIndex + (spriteInfo->HFlip<< 3) + (spriteInfo->VFlip << 4))*4;
// Get rotation/scale parameters
dx = (s16)(gpu->oam + blockparameter+0)->attr3;
dmx = (s16)(gpu->oam + blockparameter+1)->attr3;
dy = (s16)(gpu->oam + blockparameter+2)->attr3;
dmy = (s16)(gpu->oam + blockparameter+3)->attr3;
// Calculate fixed poitn 8.8 start offsets
realX = ((sprSize.x) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx + y * dmx;
realY = ((sprSize.y) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy + y * dmy;
if(sprX<0)
{
// If sprite is not in the window
if(sprX + fieldX <= 0)
continue;
// Otherwise, is partially visible
lg += sprX;
realX -= sprX*dx;
realY -= sprX*dy;
sprX = 0;
}
else
{
if(sprX+fieldX>256)
lg = 256 - sprX;
}
// If we are using 1 palette of 256 colours
if(spriteInfo->Depth)
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex) << 5));
CHECK_SPRITE(2);
// If extended palettes are set, use them
if (dispCnt->ExOBJPalette_Enable)
pal = (ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200));
else
pal = (ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400);
for(j = 0; j < lg; ++j, ++sprX)
{
// Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data
auxX = (realX>>8);
auxY = (realY>>8);
if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y)
{
offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*8);
colour = src[offset];
if (colour && (prioTab[sprX]>=prio))
{
// if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, T1ReadWord(pal, colour<<1), sprX ))
{
T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1)));
dst_alpha[sprX] = 16;
typeTab[sprX] = spriteInfo->Mode;
prioTab[sprX] = prio;
}
}
}
// Add the rotation/scale coeficients, here the rotation/scaling
// is performed
realX += dx;
realY += dy;
}
continue;
}
// Rotozoomed direct color
else if(spriteInfo->Mode == 3)
{
if (dispCnt->OBJ_BMP_mapping)
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex)*32);
else
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x03E0) * 8) + (spriteInfo->TileIndex&0x001F))*16);
CHECK_SPRITE(2);
for(j = 0; j < lg; ++j, ++sprX)
{
// Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data
auxX = (realX>>8);
auxY = (realY>>8);
if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y)
{
offset = auxX + (auxY<<8);
colour = T1ReadWord(src, offset<<1);
if((colour&0x8000) && (prioTab[sprX]>=prio))
{
// if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, colour, sprX ))
{
T2WriteWord(dst, (sprX<<1), colour);
dst_alpha[sprX] = spriteInfo->PaletteIndex;
typeTab[sprX] = spriteInfo->Mode;
prioTab[sprX] = prio;
}
}
}
// Add the rotation/scale coeficients, here the rotation/scaling
// is performed
realX += dx;
realY += dy;
}
continue;
}
// Rotozoomed 16/16 palette
else
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<5));
CHECK_SPRITE(2);
pal = ARM9Mem.ARM9_VMEM + 0x200 + (gpu->core*0x400 + (spriteInfo->PaletteIndex*32));
for(j = 0; j < lg; ++j, ++sprX)
{
// Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data
auxX = (realX>>8);
auxY = (realY>>8);
if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y)
{
offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*4);
colour = src[offset];
if (auxX&1) colour >>= 4;
else colour &= 0xF;
if(colour && (prioTab[sprX]>=prio))
{
// if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, T1ReadWord (pal, colour<<1), sprX))
{
T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1)));
dst_alpha[sprX] = 16;
typeTab[sprX] = spriteInfo->Mode;
prioTab[sprX] = prio;
}
}
}
// Add the rotation/scale coeficients, here the rotation/scaling
// is performed
realX += dx;
realY += dy;
}
continue;
}
}
else
{
u16 *pal;
if (!compute_sprite_vars(spriteInfo, l, sprSize, sprX, sprY, x, y, lg, xdir))
continue;
if (spriteInfo->Mode == 2) {
if (spriteInfo->Depth)
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8));
else
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4));
CHECK_SPRITE(2);
render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir);
continue;
}
if (spriteInfo->Mode == 3) /* sprite is in BMP format */
{
if (dispCnt->OBJ_BMP_mapping)
{
// TODO: fix it for sprite1D
//src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x3E0) * 64 + (spriteInfo->TileIndex&0x1F) *8 + ( y << 8)) << 1));
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<4) + (y<<gpu->sprBMPBoundary));
}
else
{
if (dispCnt->OBJ_BMP_2D_dim) // 256*256
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x3E0) * 64 + (spriteInfo->TileIndex&0x1F) *8 + ( y << 8)) << 1));
else // 128 * 512
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8 + ( y << 8)) << 1));
}
CHECK_SPRITE(2);
render_sprite_BMP (gpu, i, l, dst, (u16*)src, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->PaletteIndex);
continue;
}
if(spriteInfo->Depth) /* 256 colors */
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8));
CHECK_SPRITE(2);
if (dispCnt->ExOBJPalette_Enable) if (dispCnt->ExOBJPalette_Enable)
pal = (u16*)(ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200)); pal = (u16*)(ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200));
@ -2377,25 +2636,15 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
continue; continue;
} }
// 16 colors
if(MODE == SPRITE_2D) /* 16 colors */
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4)); src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4));
} CHECK_SPRITE(2);
else
{
src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<<block) + ((y>>3)*sprSize.x*4) + ((y&0x7)*4));
}
if (!src) {
continue;
}
pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400); pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400);
pal += (spriteInfo->PaletteIndex<<4); pal += (spriteInfo->PaletteIndex<<4);
render_sprite_16 (gpu, l, dst, src, pal,
render_sprite_16 (gpu, l, dst, src, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1); dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
} }
} }
@ -2405,7 +2654,6 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab)
#endif #endif
} }
/*****************************************************************************/ /*****************************************************************************/
// SCREEN FUNCTIONS // SCREEN FUNCTIONS
/*****************************************************************************/ /*****************************************************************************/
@ -2518,8 +2766,8 @@ void GPU_set_DISPCAPCNT(u32 val)
struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits;
gpu->dispCapCnt.val = val; gpu->dispCapCnt.val = val;
gpu->dispCapCnt.EVA = std::min((u32)16, (val & 0x1F)); gpu->dispCapCnt.EVA = val & 0x1F;
gpu->dispCapCnt.EVB = std::min((u32)16, ((val >> 8) & 0x1F)); gpu->dispCapCnt.EVB = (val >> 8) & 0x1F;
gpu->dispCapCnt.writeBlock = (val >> 16) & 0x03; gpu->dispCapCnt.writeBlock = (val >> 16) & 0x03;
gpu->dispCapCnt.writeOffset = (val >> 18) & 0x03; gpu->dispCapCnt.writeOffset = (val >> 18) & 0x03;
gpu->dispCapCnt.readBlock = dispCnt->VRAM_Block; gpu->dispCapCnt.readBlock = dispCnt->VRAM_Block;
@ -2631,8 +2879,7 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
//but it has been changed to write u32 instead of u16 for a little speedup //but it has been changed to write u32 instead of u16 for a little speedup
for(int i = 0; i< 128; ++i) T2WriteWord(spr, i << 2, c | (c<<16)); for(int i = 0; i< 128; ++i) T2WriteWord(spr, i << 2, c | (c<<16));
gpu->spriteRender(gpu, l, spr, sprAlpha, sprType, sprPrio);
gpu->spriteRender(spr, sprAlpha, sprType, sprPrio);
mosaicSpriteLine(gpu, l, spr, sprAlpha, sprType, sprPrio); mosaicSpriteLine(gpu, l, spr, sprAlpha, sprType, sprPrio);

View File

@ -403,10 +403,6 @@ void register_gl_fun(fun_gl_Begin beg,fun_gl_End end);
#define ADDRESS_STEP_16KB 0x04000 #define ADDRESS_STEP_16KB 0x04000
#define ADDRESS_STEP_32KB 0x08000 #define ADDRESS_STEP_32KB 0x08000
#define ADDRESS_STEP_64kB 0x10000 #define ADDRESS_STEP_64kB 0x10000
#define ADDRESS_STEP_128KB 0x20000
#define ADDRESS_STEP_256KB 0x40000
#define ADDRESS_STEP_512KB 0x80000
#define ADDRESS_MASK_256KB (ADDRESS_STEP_256KB-1)
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
struct _TILEENTRY struct _TILEENTRY
@ -594,7 +590,6 @@ typedef struct
#define ARM9MEM_BBG 0x06200000 #define ARM9MEM_BBG 0x06200000
#define ARM9MEM_AOBJ 0x06400000 #define ARM9MEM_AOBJ 0x06400000
#define ARM9MEM_BOBJ 0x06600000 #define ARM9MEM_BOBJ 0x06600000
#define ARM9MEM_LCDC 0x06800000
extern CACHE_ALIGN u8 gpuBlendTable555[17][17][32][32]; extern CACHE_ALIGN u8 gpuBlendTable555[17][17][32][32];
@ -722,17 +717,12 @@ struct GPU
typedef void (*FinalOBJColFunct)(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); typedef void (*FinalOBJColFunct)(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x);
typedef void (*Final3DColFunct)(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x); typedef void (*Final3DColFunct)(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x);
typedef void (*SpriteRenderFunct) (GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab);
int setFinalColorBck_funcNum; int setFinalColorBck_funcNum;
FinalOBJColFunct setFinalColorSpr; FinalOBJColFunct setFinalColorSpr;
Final3DColFunct setFinalColor3D; Final3DColFunct setFinalColor3D;
enum SpriteRenderMode { SpriteRenderFunct spriteRender;
SPRITE_1D, SPRITE_2D
} spriteRenderMode;
template<GPU::SpriteRenderMode MODE>
void _spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab);
void spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab);
void setFinalColorBG(u16 color, u8 x); void setFinalColorBG(u16 color, u8 x);
FORCEINLINE void setFinalBGColorSpecialNone(u16 color, u8 x, bool blend1); FORCEINLINE void setFinalBGColorSpecialNone(u16 color, u8 x, bool blend1);

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,6 @@ struct MMU_struct {
//Card rom & ram //Card rom & ram
u8 * CART_ROM; u8 * CART_ROM;
u32 CART_ROM_MASK;
u8 CART_RAM[0x10000]; u8 CART_RAM[0x10000];
//Unused ram //Unused ram
@ -359,6 +358,4 @@ void _MMU_write16(u32 addr, u16 val) { _MMU_write16(PROCNUM, addr, val); }
template<int PROCNUM> template<int PROCNUM>
void _MMU_write32(u32 addr, u32 val) { _MMU_write32(PROCNUM, addr, val); } void _MMU_write32(u32 addr, u32 val) { _MMU_write32(PROCNUM, addr, val); }
void FASTCALL MMU_DumpMemBlock(u8 proc, u32 address, u32 size, u8 *buffer);
#endif #endif

View File

@ -25,7 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
#include <math.h> #include <math.h>
#include <zlib.h>
#include "common.h" #include "common.h"
#include "NDSSystem.h" #include "NDSSystem.h"
@ -1059,138 +1058,6 @@ int NDS_ImportSave(const char *filename)
return 0; return 0;
} }
static int WritePNGChunk(FILE *fp, uint32 size, const char *type, const uint8 *data)
{
uint32 crc;
uint8 tempo[4];
tempo[0]=size>>24;
tempo[1]=size>>16;
tempo[2]=size>>8;
tempo[3]=size;
if(fwrite(tempo,4,1,fp)!=1)
return 0;
if(fwrite(type,4,1,fp)!=1)
return 0;
if(size)
if(fwrite(data,1,size,fp)!=size)
return 0;
crc = crc32(0,(uint8 *)type,4);
if(size)
crc = crc32(crc,data,size);
tempo[0]=crc>>24;
tempo[1]=crc>>16;
tempo[2]=crc>>8;
tempo[3]=crc;
if(fwrite(tempo,4,1,fp)!=1)
return 0;
return 1;
}
int NDS_WritePNG(const char *fname)
{
int x, y;
int width=256;
int height=192*2;
u16 * bmp = (u16 *)GPU_screen;
FILE *pp=NULL;
uint8 *compmem = NULL;
uLongf compmemsize = (uLongf)( (height * (width + 1) * 3 * 1.001 + 1) + 12 );
if(!(compmem=(uint8 *)malloc(compmemsize)))
return 0;
if(!(pp=fopen(fname, "wb")))
{
return 0;
}
{
static uint8 header[8]={137,80,78,71,13,10,26,10};
if(fwrite(header,8,1,pp)!=1)
goto PNGerr;
}
{
uint8 chunko[13];
chunko[0] = width >> 24; // Width
chunko[1] = width >> 16;
chunko[2] = width >> 8;
chunko[3] = width;
chunko[4] = height >> 24; // Height
chunko[5] = height >> 16;
chunko[6] = height >> 8;
chunko[7] = height;
chunko[8]=8; // 8 bits per sample(24 bits per pixel)
chunko[9]=2; // Color type; RGB triplet
chunko[10]=0; // compression: deflate
chunko[11]=0; // Basic adapative filter set(though none are used).
chunko[12]=0; // No interlace.
if(!WritePNGChunk(pp,13,"IHDR",chunko))
goto PNGerr;
}
{
uint8 *tmp_buffer;
uint8 *tmp_inc;
tmp_inc = tmp_buffer = (uint8 *)malloc((width * 3 + 1) * height);
for(y=0;y<height;y++)
{
*tmp_inc = 0;
tmp_inc++;
for(x=0;x<width;x++)
{
int r,g,b;
u16 pixel = bmp[y*256+x];
r = pixel>>10;
pixel-=r<<10;
g = pixel>>5;
pixel-=g<<5;
b = pixel;
r*=255/31;
g*=255/31;
b*=255/31;
tmp_inc[0] = b;
tmp_inc[1] = g;
tmp_inc[2] = r;
tmp_inc += 3;
}
}
if(compress(compmem, &compmemsize, tmp_buffer, height * (width * 3 + 1))!=Z_OK)
{
if(tmp_buffer) free(tmp_buffer);
goto PNGerr;
}
if(tmp_buffer) free(tmp_buffer);
if(!WritePNGChunk(pp,compmemsize,"IDAT",compmem))
goto PNGerr;
}
if(!WritePNGChunk(pp,0,"IEND",0))
goto PNGerr;
free(compmem);
fclose(pp);
return 1;
PNGerr:
if(compmem)
free(compmem);
if(pp)
fclose(pp);
return(0);
}
typedef struct typedef struct
{ {
u32 size; u32 size;
@ -2414,61 +2281,8 @@ void NDS_setPadFromMovie(u16 pad)
#undef FIX #undef FIX
} }
turbo Turbo;
turbotime TurboTime;
static void SetTurbo(bool (&pad) [10]) {
bool turbo[4] = {true, false, true, false};
bool currentbutton;
for (int i=0; i < 10; i++) {
currentbutton=Turbo.button(i);
if(currentbutton) {
pad[i]=turbo[TurboTime.time(i)-1];
if(TurboTime.time(i)>=ARRAY_SIZE(turbo))
TurboTime.time(i)=0;
}
else
TurboTime.time(i)=0; //reset timer if the button isn't pressed
}
for (int i=0; i<10; i++)
TurboTime.time(i)++;
}
autohold AutoHold;
void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F) void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F)
{ {
bool padarray[10] = {R, L, D, U, T, S, B, A, Y, X};
SetTurbo(padarray);
R=padarray[0];
L=padarray[1];
D=padarray[2];
U=padarray[3];
T=padarray[4];
S=padarray[5];
B=padarray[6];
A=padarray[7];
Y=padarray[8];
X=padarray[9];
if(AutoHold.Right) R=!padarray[0];
if(AutoHold.Left) L=!padarray[1];
if(AutoHold.Down) D=!padarray[2];
if(AutoHold.Up) U=!padarray[3];
if(AutoHold.Select)T=!padarray[4];
if(AutoHold.Start) S=!padarray[5];
if(AutoHold.B) B=!padarray[6];
if(AutoHold.A) A=!padarray[7];
if(AutoHold.Y) Y=!padarray[8];
if(AutoHold.X) X=!padarray[9];
//this macro is the opposite of what you would expect //this macro is the opposite of what you would expect
#define FIX(b) (b?0:0x80) #define FIX(b) (b?0:0x80)

View File

@ -34,59 +34,6 @@
#include <string> #include <string>
struct turbo {
bool Right;
bool Left;
bool Down;
bool Up;
bool Select;
bool Start;
bool B;
bool A;
bool Y;
bool X;
bool &button(int i) { return ((bool*)this)[i]; }
};
extern turbo Turbo;
struct turbotime {
int Right;
int Left;
int Down;
int Up;
int Select;
int Start;
int B;
int A;
int Y;
int X;
int &time(int i) { return ((int*)this)[i]; }
};
extern turbotime TurboTime;
struct autohold {
bool Right;
bool Left;
bool Down;
bool Up;
bool Select;
bool Start;
bool B;
bool A;
bool Y;
bool X;
bool &hold(int i) { return ((bool*)this)[i]; }
};
extern autohold AutoHold;
int NDS_WritePNG(const char *fname);
extern volatile BOOL execute; extern volatile BOOL execute;
extern BOOL click; extern BOOL click;
extern char pathToROM[MAX_PATH]; extern char pathToROM[MAX_PATH];

View File

@ -544,7 +544,7 @@ static INLINE void FetchADPCMData(channel_struct *chan, s32 *data)
chan->index = precalcindextbl[chan->index][data4bit & 0x7]; chan->index = precalcindextbl[chan->index][data4bit & 0x7];
} }
chan->lastsampcnt = (int)chan->sampcnt; chan->lastsampcnt = chan->sampcnt;
#ifdef SPU_INTERPOLATE #ifdef SPU_INTERPOLATE
*data = Interpolate((s32)chan->pcm16b_last,(s32)chan->pcm16b,chan->sampcnt); *data = Interpolate((s32)chan->pcm16b_last,(s32)chan->pcm16b,chan->sampcnt);

Some files were not shown because too many files have changed in this diff Show More