[Video] Update headers

This commit is contained in:
zilmar 2017-04-26 20:23:36 +10:00
parent 894706a379
commit b50c8b1fdd
109 changed files with 16009 additions and 17482 deletions

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
extern "C" { extern "C" {
#ifndef NOSSE #ifndef NOSSE

View File

@ -1,54 +1,28 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
void calc_light (VERTEX *v); void calc_light (VERTEX *v);
void calc_linear (VERTEX *v); void calc_linear (VERTEX *v);
void calc_sphere (VERTEX *v); void calc_sphere (VERTEX *v);
void math_init(); void math_init();
typedef void (*MULMATRIX)(float m1[4][4],float m2[4][4],float r[4][4]); typedef void(*MULMATRIX)(float m1[4][4], float m2[4][4], float r[4][4]);
extern MULMATRIX MulMatrices; extern MULMATRIX MulMatrices;
typedef void (*TRANSFORMVECTOR)(float *src,float *dst,float mat[4][4]); typedef void(*TRANSFORMVECTOR)(float *src, float *dst, float mat[4][4]);
extern TRANSFORMVECTOR TransformVector; extern TRANSFORMVECTOR TransformVector;
extern TRANSFORMVECTOR InverseTransformVector; extern TRANSFORMVECTOR InverseTransformVector;
typedef float (*DOTPRODUCT)(register float *v1, register float *v2); typedef float(*DOTPRODUCT)(register float *v1, register float *v2);
extern DOTPRODUCT DotProduct; extern DOTPRODUCT DotProduct;
typedef void (*NORMALIZEVECTOR)(float *v); typedef void(*NORMALIZEVECTOR)(float *v);
extern NORMALIZEVECTOR NormalizeVector; extern NORMALIZEVECTOR NormalizeVector;

View File

@ -1,12 +1,13 @@
/**************************************************************************** /***************************************************************************
* * * *
* Project 64 - A Nintendo 64 emulator. * * Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ * * http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. * * Copyright (C) 2017 Project64. All rights reserved. *
* * * *
* License: * * License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* * * version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/ ****************************************************************************/
#ifdef ANDROID #ifdef ANDROID
#include <jni.h> #include <jni.h>

View File

@ -1,48 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// CRC32 calculation functions
//
// Created by Gonetz, 2004
//
//****************************************************************
//*
#define CRC32_POLYNOMIAL 0x04C11DB7 #define CRC32_POLYNOMIAL 0x04C11DB7
unsigned int CRCTable[256]; unsigned int CRCTable[256];

View File

@ -1,47 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// CRC32 calculation functions
//
// Created by Gonetz, 2004
//
//****************************************************************
void CRC_BuildTable(); void CRC_BuildTable();

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include <string.h> #include <string.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "Util.h" #include "Util.h"

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#ifndef COMBINE_H #ifndef COMBINE_H
#define COMBINE_H #define COMBINE_H

View File

@ -1,49 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Glide64 dialogs
// Created by Gonetz, 2008
//
//****************************************************************
// -*- C++ -*- generated by wxGlade 0.6.3 on Tue Oct 07 22:39:28 2008
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "DepthBufferRender.h" #include "DepthBufferRender.h"
#include "Config.h" #include "Config.h"

View File

@ -1,46 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Glide64 dialogs
// Created by Gonetz, 2008
//
//****************************************************************
#pragma once #pragma once
#ifdef _WIN32 #ifdef _WIN32

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>

View File

@ -1,40 +1,14 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. void output(float x, float y, int scale, const char *fmt, ...);
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
void output (float x, float y, int scale, const char *fmt, ...);

View File

@ -1,50 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Software rendering into N64 depth buffer
// Idea and N64 depth value format by Orkin
// Polygon rasterization algorithm is taken from FATMAP2 engine by Mats Byggmastar, mri@penti.sit.fi
//
// Created by Gonetz, Dec 2004
//
//****************************************************************
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "rdp.h" #include "rdp.h"
#include "DepthBufferRender.h" #include "DepthBufferRender.h"
@ -53,33 +19,33 @@ uint16_t * zLUT = 0;
void ZLUT_init() void ZLUT_init()
{ {
if (zLUT) if (zLUT)
return; return;
zLUT = new uint16_t[0x40000]; zLUT = new uint16_t[0x40000];
for(int i=0; i<0x40000; i++) for (int i = 0; i < 0x40000; i++)
{
uint32_t exponent = 0;
uint32_t testbit = 1 << 17;
while((i & testbit) && (exponent < 7))
{ {
exponent++; uint32_t exponent = 0;
testbit = 1 << (17 - exponent); uint32_t testbit = 1 << 17;
while ((i & testbit) && (exponent < 7))
{
exponent++;
testbit = 1 << (17 - exponent);
}
uint32_t mantissa = (i >> (6 - (6 < exponent ? 6 : exponent))) & 0x7ff;
zLUT[i] = (uint16_t)(((exponent << 11) | mantissa) << 2);
} }
uint32_t mantissa = (i >> (6 - (6 < exponent ? 6 : exponent))) & 0x7ff;
zLUT[i] = (uint16_t)(((exponent << 11) | mantissa) << 2);
}
} }
void ZLUT_release() void ZLUT_release()
{ {
delete[] zLUT; delete[] zLUT;
zLUT = 0; zLUT = 0;
} }
static vertexi * max_vtx; // Max y vertex (ending vertex) static vertexi * max_vtx; // Max y vertex (ending vertex)
static vertexi * start_vtx, * end_vtx; // First and last vertex in array static vertexi * start_vtx, *end_vtx; // First and last vertex in array
static vertexi * right_vtx, * left_vtx; // Current right and left vertex static vertexi * right_vtx, *left_vtx; // Current right and left vertex
static int right_height, left_height; static int right_height, left_height;
static int right_x, right_dxdy, left_x, left_dxdy; static int right_x, right_dxdy, left_x, left_dxdy;
@ -103,210 +69,208 @@ __inline int idiv16(int x, int y) // (x << 16) / y
__inline int iceil(int x) __inline int iceil(int x)
{ {
x += 0xffff; x += 0xffff;
return (x >> 16); return (x >> 16);
} }
static void RightSection(void) static void RightSection(void)
{ {
// Walk backwards trough the vertex array // Walk backwards trough the vertex array
vertexi * v2, * v1 = right_vtx; vertexi * v2, *v1 = right_vtx;
if(right_vtx > start_vtx) v2 = right_vtx-1; if (right_vtx > start_vtx) v2 = right_vtx - 1;
else v2 = end_vtx; // Wrap to end of array else v2 = end_vtx; // Wrap to end of array
right_vtx = v2; right_vtx = v2;
// v1 = top vertex // v1 = top vertex
// v2 = bottom vertex // v2 = bottom vertex
// Calculate number of scanlines in this section // Calculate number of scanlines in this section
right_height = iceil(v2->y) - iceil(v1->y); right_height = iceil(v2->y) - iceil(v1->y);
if(right_height <= 0) return; if (right_height <= 0) return;
// Guard against possible div overflows // Guard against possible div overflows
if(right_height > 1) { if (right_height > 1) {
// OK, no worries, we have a section that is at least // OK, no worries, we have a section that is at least
// one pixel high. Calculate slope as usual. // one pixel high. Calculate slope as usual.
int height = v2->y - v1->y; int height = v2->y - v1->y;
right_dxdy = idiv16(v2->x - v1->x, height); right_dxdy = idiv16(v2->x - v1->x, height);
} }
else { else {
// Height is less or equal to one pixel. // Height is less or equal to one pixel.
// Calculate slope = width * 1/height // Calculate slope = width * 1/height
// using 18:14 bit precision to avoid overflows. // using 18:14 bit precision to avoid overflows.
int inv_height = (0x10000 << 14) / (v2->y - v1->y); int inv_height = (0x10000 << 14) / (v2->y - v1->y);
right_dxdy = imul14(v2->x - v1->x, inv_height); right_dxdy = imul14(v2->x - v1->x, inv_height);
} }
// Prestep initial values // Prestep initial values
int prestep = (iceil(v1->y) << 16) - v1->y; int prestep = (iceil(v1->y) << 16) - v1->y;
right_x = v1->x + imul16(prestep, right_dxdy); right_x = v1->x + imul16(prestep, right_dxdy);
} }
static void LeftSection(void) static void LeftSection(void)
{ {
// Walk forward trough the vertex array // Walk forward trough the vertex array
vertexi * v2, * v1 = left_vtx;
if(left_vtx < end_vtx) v2 = left_vtx+1;
else v2 = start_vtx; // Wrap to start of array
left_vtx = v2;
// v1 = top vertex
// v2 = bottom vertex
// Calculate number of scanlines in this section
left_height = iceil(v2->y) - iceil(v1->y);
if(left_height <= 0) return;
// Guard against possible div overflows
if(left_height > 1) {
// OK, no worries, we have a section that is at least
// one pixel high. Calculate slope as usual.
int height = v2->y - v1->y;
left_dxdy = idiv16(v2->x - v1->x, height);
left_dzdy = idiv16(v2->z - v1->z, height);
}
else {
// Height is less or equal to one pixel.
// Calculate slope = width * 1/height
// using 18:14 bit precision to avoid overflows.
int inv_height = (0x10000 << 14) / (v2->y - v1->y);
left_dxdy = imul14(v2->x - v1->x, inv_height);
left_dzdy = imul14(v2->z - v1->z, inv_height);
}
// Prestep initial values
int prestep = (iceil(v1->y) << 16) - v1->y;
left_x = v1->x + imul16(prestep, left_dxdy);
left_z = v1->z + imul16(prestep, left_dzdy);
}
vertexi * v2, *v1 = left_vtx;
if (left_vtx < end_vtx) v2 = left_vtx + 1;
else v2 = start_vtx; // Wrap to start of array
left_vtx = v2;
// v1 = top vertex
// v2 = bottom vertex
// Calculate number of scanlines in this section
left_height = iceil(v2->y) - iceil(v1->y);
if (left_height <= 0) return;
// Guard against possible div overflows
if (left_height > 1) {
// OK, no worries, we have a section that is at least
// one pixel high. Calculate slope as usual.
int height = v2->y - v1->y;
left_dxdy = idiv16(v2->x - v1->x, height);
left_dzdy = idiv16(v2->z - v1->z, height);
}
else {
// Height is less or equal to one pixel.
// Calculate slope = width * 1/height
// using 18:14 bit precision to avoid overflows.
int inv_height = (0x10000 << 14) / (v2->y - v1->y);
left_dxdy = imul14(v2->x - v1->x, inv_height);
left_dzdy = imul14(v2->z - v1->z, inv_height);
}
// Prestep initial values
int prestep = (iceil(v1->y) << 16) - v1->y;
left_x = v1->x + imul16(prestep, left_dxdy);
left_z = v1->z + imul16(prestep, left_dzdy);
}
void Rasterize(vertexi * vtx, int vertices, int dzdx) void Rasterize(vertexi * vtx, int vertices, int dzdx)
{ {
start_vtx = vtx; // First vertex in array start_vtx = vtx; // First vertex in array
// Search trough the vtx array to find min y, max y // Search trough the vtx array to find min y, max y
// and the location of these structures. // and the location of these structures.
vertexi * min_vtx = vtx; vertexi * min_vtx = vtx;
max_vtx = vtx; max_vtx = vtx;
int min_y = vtx->y; int min_y = vtx->y;
int max_y = vtx->y; int max_y = vtx->y;
vtx++; vtx++;
for(int n=1; n<vertices; n++) { for (int n = 1; n < vertices; n++) {
if(vtx->y < min_y) { if (vtx->y < min_y) {
min_y = vtx->y; min_y = vtx->y;
min_vtx = vtx; min_vtx = vtx;
}
else
if (vtx->y > max_y) {
max_y = vtx->y;
max_vtx = vtx;
}
vtx++;
} }
else
if(vtx->y > max_y) { // OK, now we know where in the array we should start and
max_y = vtx->y; // where to end while scanning the edges of the polygon
max_vtx = vtx;
} left_vtx = min_vtx; // Left side starting vertex
vtx++; right_vtx = min_vtx; // Right side starting vertex
} end_vtx = vtx - 1; // Last vertex in array
// OK, now we know where in the array we should start and // Search for the first usable right section
// where to end while scanning the edges of the polygon
do {
left_vtx = min_vtx; // Left side starting vertex if (right_vtx == max_vtx) return;
right_vtx = min_vtx; // Right side starting vertex
end_vtx = vtx-1; // Last vertex in array
// Search for the first usable right section
do {
if(right_vtx == max_vtx) return;
RightSection();
} while(right_height <= 0);
// Search for the first usable left section
do {
if(left_vtx == max_vtx) return;
LeftSection();
} while(left_height <= 0);
uint16_t * destptr = (uint16_t*)(gfx.RDRAM+rdp.zimg);
int y1 = iceil(min_y);
if (y1 >= (int)rdp.scissor_o.lr_y) return;
int shift;
for(;;)
{
int x1 = iceil(left_x);
if (x1 < (int)rdp.scissor_o.ul_x)
x1 = rdp.scissor_o.ul_x;
int width = iceil(right_x) - x1;
if (x1+width >= (int)rdp.scissor_o.lr_x)
width = rdp.scissor_o.lr_x - x1 - 1;
if(width > 0 && y1 >= (int)rdp.scissor_o.ul_y) {
// Prestep initial z
int prestep = (x1 << 16) - left_x;
int z = left_z + imul16(prestep, dzdx);
shift = x1 + y1*rdp.zi_width;
//draw to depth buffer
int trueZ;
int idx;
uint16_t encodedZ;
for (int x = 0; x < width; x++)
{
trueZ = z/8192;
if (trueZ < 0) trueZ = 0;
else if (trueZ > 0x3FFFF) trueZ = 0x3FFFF;
encodedZ = zLUT[trueZ];
idx = (shift+x)^1;
if(encodedZ < destptr[idx])
destptr[idx] = encodedZ;
z += dzdx;
}
}
//destptr += rdp.zi_width;
y1++;
if (y1 >= (int)rdp.scissor_o.lr_y) return;
// Scan the right side
if(--right_height <= 0) { // End of this section?
do {
if(right_vtx == max_vtx) return;
RightSection(); RightSection();
} while(right_height <= 0); } while (right_height <= 0);
}
else // Search for the first usable left section
right_x += right_dxdy;
do {
// Scan the left side if (left_vtx == max_vtx) return;
if(--left_height <= 0) { // End of this section?
do {
if(left_vtx == max_vtx) return;
LeftSection(); LeftSection();
} while(left_height <= 0); } while (left_height <= 0);
uint16_t * destptr = (uint16_t*)(gfx.RDRAM + rdp.zimg);
int y1 = iceil(min_y);
if (y1 >= (int)rdp.scissor_o.lr_y) return;
int shift;
for (;;)
{
int x1 = iceil(left_x);
if (x1 < (int)rdp.scissor_o.ul_x)
x1 = rdp.scissor_o.ul_x;
int width = iceil(right_x) - x1;
if (x1 + width >= (int)rdp.scissor_o.lr_x)
width = rdp.scissor_o.lr_x - x1 - 1;
if (width > 0 && y1 >= (int)rdp.scissor_o.ul_y) {
// Prestep initial z
int prestep = (x1 << 16) - left_x;
int z = left_z + imul16(prestep, dzdx);
shift = x1 + y1*rdp.zi_width;
//draw to depth buffer
int trueZ;
int idx;
uint16_t encodedZ;
for (int x = 0; x < width; x++)
{
trueZ = z / 8192;
if (trueZ < 0) trueZ = 0;
else if (trueZ > 0x3FFFF) trueZ = 0x3FFFF;
encodedZ = zLUT[trueZ];
idx = (shift + x) ^ 1;
if (encodedZ < destptr[idx])
destptr[idx] = encodedZ;
z += dzdx;
}
}
//destptr += rdp.zi_width;
y1++;
if (y1 >= (int)rdp.scissor_o.lr_y) return;
// Scan the right side
if (--right_height <= 0) { // End of this section?
do {
if (right_vtx == max_vtx) return;
RightSection();
} while (right_height <= 0);
}
else
right_x += right_dxdy;
// Scan the left side
if (--left_height <= 0) { // End of this section?
do {
if (left_vtx == max_vtx) return;
LeftSection();
} while (left_height <= 0);
}
else {
left_x += left_dxdy;
left_z += left_dzdy;
}
} }
else {
left_x += left_dxdy;
left_z += left_dzdy;
}
}
} }

View File

@ -1,53 +1,22 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Software rendering to N64 depth buffer
// Created by Gonetz, Dec 2004
//
//****************************************************************
#ifndef DEPTH_BUFFER_RENDER_H #ifndef DEPTH_BUFFER_RENDER_H
#define DEPTH_BUFFER_RENDER_H #define DEPTH_BUFFER_RENDER_H
struct vertexi struct vertexi
{ {
int x,y; // Screen position in 16:16 bit fixed point int x, y; // Screen position in 16:16 bit fixed point
int z; // z value in 16:16 bit fixed point int z; // z value in 16:16 bit fixed point
}; };

View File

@ -1,26 +1,15 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * *
* * License: *
* this is free software; you can redistribute it and/or modify * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* it under the terms of the GNU General Public License as published by * version 2 of the License, or (at your option) any later version. *
* the Free Software Foundation; either version 2, or (at your option) * *
* any later version. ****************************************************************************/
*
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <memory.h> #include <memory.h>
#include <stdlib.h> #include <stdlib.h>
#include "Ext_TxFilter.h" #include "Ext_TxFilter.h"

View File

@ -1,25 +1,15 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * *
* * License: *
* this is free software; you can redistribute it and/or modify * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* it under the terms of the GNU General Public License as published by * version 2 of the License, or (at your option) any later version. *
* the Free Software Foundation; either version 2, or (at your option) * *
* any later version. ****************************************************************************/
*
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __EXT_TXFILTER_H__ #ifndef __EXT_TXFILTER_H__
#define __EXT_TXFILTER_H__ #define __EXT_TXFILTER_H__

View File

@ -1,47 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Draw N64 frame buffer to screen.
// Created by Gonetz, 2007
//
//****************************************************************
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "FBtoScreen.h" #include "FBtoScreen.h"
#include "TexCache.h" #include "TexCache.h"

View File

@ -1,60 +1,30 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Render N64 frame buffer to screen
// Created by Gonetz, 2007
//
//****************************************************************
#ifndef FBtoSCREEN_H #ifndef FBtoSCREEN_H
#define FBtoSCREEN_H #define FBtoSCREEN_H
typedef struct typedef struct
{ {
uint32_t addr; //color image address uint32_t addr; //color image address
uint32_t size; uint32_t size;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
uint32_t ul_x; uint32_t ul_x;
uint32_t ul_y; uint32_t ul_y;
uint32_t lr_x; uint32_t lr_x;
uint32_t lr_y; uint32_t lr_y;
uint32_t opaque; uint32_t opaque;
} FB_TO_SCREEN_INFO; } FB_TO_SCREEN_INFO;
bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info); bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info);

View File

@ -1,67 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
/**********************************************************************************
Common gfx plugin spec, version #1.3 maintained by zilmar (zilmar@emulation64.com)
All questions or suggestions should go through the mailing list.
http://www.egroups.com/group/Plugin64-Dev
***********************************************************************************
Notes:
------
Setting the approprate bits in the MI_INTR_REG and calling CheckInterrupts which
are both passed to the DLL in InitiateGFX will generate an Interrupt from with in
the plugin.
The Setting of the RSP flags and generating an SP interrupt should not be done in
the plugin
**********************************************************************************/
// THIS FILE IS A PRECOMPILED HEADER TO DECREASE BUILD TIME. INCLUDE ALL STANDARD
// .H FILES HERE
#ifndef _GFX_H_INCLUDED__
#define _GFX_H_INCLUDED__
#include "winlnxdefs.h" #include "winlnxdefs.h"
#include <stdio.h> #include <stdio.h>
@ -533,4 +483,3 @@ extern "C" {
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
#endif //_GFX_H_INCLUDED__

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include <string.h> #include <string.h>
#include <Common/StdString.h> #include <Common/StdString.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include <Common/stdtypes.h> #include <Common/stdtypes.h>
#include <string.h> #include <string.h>
typedef uint32_t uint32_t; typedef uint32_t uint32_t;

View File

@ -1,46 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Created by Gonetz, 2007
//
//****************************************************************
#include <string.h> #include <string.h>
static inline void mirror32bS(uint8_t *tex, uint8_t *start, int width, int height, int mask, int line, int full, int count) static inline void mirror32bS(uint8_t *tex, uint8_t *start, int width, int height, int mask, int line, int full, int count)

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//**************************************************************** //****************************************************************
// 8-bit Horizontal Mirror // 8-bit Horizontal Mirror

View File

@ -1,23 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else // _WIN32 #else // _WIN32

View File

@ -1,22 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -1,22 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define SAVE_CBUFFER #define SAVE_CBUFFER

View File

@ -1,23 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else // _WIN32 #else // _WIN32

View File

@ -1,22 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include "glitchmain.h" #include "glitchmain.h"

View File

@ -1,3 +1,16 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#pragma once #pragma once
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>

View File

@ -1,3 +1,16 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else // _WIN32 #else // _WIN32

View File

@ -1,3 +1,16 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#include <stdio.h> #include <stdio.h>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>

View File

@ -1,3 +1,16 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#define SAVE_CBUFFER #define SAVE_CBUFFER
#ifdef _WIN32 #ifdef _WIN32

View File

@ -1,3 +1,16 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else // _WIN32 #else // _WIN32

View File

@ -1,5 +1,17 @@
#ifndef MAIN_H /***************************************************************************
#define MAIN_H * *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Copyright (C) 2002 Dave2001 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#pragma once
#ifndef _WIN32 #ifndef _WIN32
//#define VPDEBUG //#define VPDEBUG
@ -260,4 +272,3 @@ FX_ENTRY void FX_CALL
void CHECK_FRAMEBUFFER_STATUS(void); void CHECK_FRAMEBUFFER_STATUS(void);
#endif

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* * * *
* Project64 - A Nintendo 64 emulator. * * Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ * * http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. * * Copyright (C) 2017 Project64. All rights reserved. *
* * * *
* License: * * License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* * * *
* Project64 - A Nintendo 64 emulator. * * Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ * * http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. * * Copyright (C) 2017 Project64. All rights reserved. *
* * * *
* License: * * License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *

View File

@ -1,3 +1,13 @@
/****************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include <Common/StdString.h> #include <Common/StdString.h>
#include <Settings/Settings.h> #include <Settings/Settings.h>
#include <Project64-video/trace.h> #include <Project64-video/trace.h>

View File

@ -1,10 +1,20 @@
/****************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once #pragma once
#include <string> #include <string>
class CSettings class CSettings
{ {
public: public:
CSettings(); CSettings();
//Frame buffer emulation options //Frame buffer emulation options
enum fb_bits_t enum fb_bits_t
@ -27,37 +37,37 @@ public:
enum hacks_t enum hacks_t
{ {
hack_ASB = (1<<0), //All-Star Baseball games hack_ASB = (1 << 0), //All-Star Baseball games
hack_Banjo2 = (1<<1), //Banjo Tooie hack_Banjo2 = (1 << 1), //Banjo Tooie
hack_BAR = (1<<2), //Beetle Adventure Racing hack_BAR = (1 << 2), //Beetle Adventure Racing
hack_Chopper = (1<<3), //Chopper Attack hack_Chopper = (1 << 3), //Chopper Attack
hack_Diddy = (1<<4), //diddy kong racing hack_Diddy = (1 << 4), //diddy kong racing
hack_Fifa98 = (1<<5), //FIFA - Road to World Cup 98 hack_Fifa98 = (1 << 5), //FIFA - Road to World Cup 98
hack_Fzero = (1<<6), //F-Zero hack_Fzero = (1 << 6), //F-Zero
hack_GoldenEye = (1<<7), //Golden Eye hack_GoldenEye = (1 << 7), //Golden Eye
hack_Hyperbike = (1<<8), //Top Gear Hyper Bike hack_Hyperbike = (1 << 8), //Top Gear Hyper Bike
hack_ISS64 = (1<<9), //International Superstar Soccer 64 hack_ISS64 = (1 << 9), //International Superstar Soccer 64
hack_KI = (1<<10), //Killer Instinct hack_KI = (1 << 10), //Killer Instinct
hack_Knockout = (1<<11), //Knockout Kings 2000 hack_Knockout = (1 << 11), //Knockout Kings 2000
hack_Lego = (1<<12), //LEGO Racers hack_Lego = (1 << 12), //LEGO Racers
hack_MK64 = (1<<13), //Mario Kart hack_MK64 = (1 << 13), //Mario Kart
hack_Megaman = (1<<14), //Megaman64 hack_Megaman = (1 << 14), //Megaman64
hack_Makers = (1<<15), //Mischief-makers hack_Makers = (1 << 15), //Mischief-makers
hack_WCWnitro = (1<<16), //WCW Nitro hack_WCWnitro = (1 << 16), //WCW Nitro
hack_Ogre64 = (1<<17), //Ogre Battle 64 hack_Ogre64 = (1 << 17), //Ogre Battle 64
hack_Pilotwings = (1<<18), //Pilotwings hack_Pilotwings = (1 << 18), //Pilotwings
hack_PMario = (1<<19), //Paper Mario hack_PMario = (1 << 19), //Paper Mario
hack_PPL = (1<<20), //pokemon puzzle league requires many special fixes hack_PPL = (1 << 20), //pokemon puzzle league requires many special fixes
hack_RE2 = (1<<21), //Resident Evil 2 hack_RE2 = (1 << 21), //Resident Evil 2
hack_Starcraft = (1<<22), //StarCraft64 hack_Starcraft = (1 << 22), //StarCraft64
hack_Supercross = (1<<23), //Supercross 2000 hack_Supercross = (1 << 23), //Supercross 2000
hack_TGR = (1<<24), //Top Gear Rally hack_TGR = (1 << 24), //Top Gear Rally
hack_TGR2 = (1<<25), //Top Gear Rally 2 hack_TGR2 = (1 << 25), //Top Gear Rally 2
hack_Tonic = (1<<26), //tonic trouble hack_Tonic = (1 << 26), //tonic trouble
hack_Winback = (1<<27), //WinBack - Covert Operations hack_Winback = (1 << 27), //WinBack - Covert Operations
hack_Yoshi = (1<<28), //Yoshi Story hack_Yoshi = (1 << 28), //Yoshi Story
hack_Zelda = (1<<29), //zeldas hacks hack_Zelda = (1 << 29), //zeldas hacks
hack_OoT = (1<<30), //zelda OoT hacks hack_OoT = (1 << 30), //zelda OoT hacks
}; };
enum AspectMode_t enum AspectMode_t
@ -117,7 +127,7 @@ public:
HiResPackFormat_None = 0, HiResPackFormat_None = 0,
HiResPackFormat_Riceformat = 0x00020000, HiResPackFormat_Riceformat = 0x00020000,
}; };
enum SwapMode_t enum SwapMode_t
{ {
SwapMode_Old = 0, SwapMode_Old = 0,
@ -172,7 +182,7 @@ public:
inline bool fb_emulation_enabled(void) const { return ((m_frame_buffer&fb_emulation) != 0); } inline bool fb_emulation_enabled(void) const { return ((m_frame_buffer&fb_emulation) != 0); }
inline bool fb_ref_enabled(void) const { return ((m_frame_buffer&fb_ref) != 0); } inline bool fb_ref_enabled(void) const { return ((m_frame_buffer&fb_ref) != 0); }
inline bool fb_hwfbe_enabled(void) const { return ((m_frame_buffer&(fb_emulation |fb_hwfbe)) == (fb_emulation | fb_hwfbe)); } inline bool fb_hwfbe_enabled(void) const { return ((m_frame_buffer&(fb_emulation | fb_hwfbe)) == (fb_emulation | fb_hwfbe)); }
inline bool fb_hwfbe_set(void) const { return ((m_frame_buffer&fb_hwfbe) != 0); } inline bool fb_hwfbe_set(void) const { return ((m_frame_buffer&fb_hwfbe) != 0); }
inline bool fb_depth_render_enabled(void) const { return ((m_frame_buffer&fb_depth_render) != 0); } inline bool fb_depth_render_enabled(void) const { return ((m_frame_buffer&fb_depth_render) != 0); }
inline bool fb_get_info_enabled(void) const { return ((m_frame_buffer&fb_get_info) != 0); } inline bool fb_get_info_enabled(void) const { return ((m_frame_buffer&fb_get_info) != 0); }
@ -199,7 +209,7 @@ public:
inline ScreenRotate_t rotate(void) const { return m_rotate; } inline ScreenRotate_t rotate(void) const { return m_rotate; }
inline Filtering_t filtering(void) const { return m_filtering; } inline Filtering_t filtering(void) const { return m_filtering; }
inline bool fog (void) const { return m_fog; } inline bool fog(void) const { return m_fog; }
inline bool buff_clear(void) const { return m_buff_clear; } inline bool buff_clear(void) const { return m_buff_clear; }
inline SwapMode_t swapmode(void) const { return m_swapmode; } inline SwapMode_t swapmode(void) const { return m_swapmode; }
inline PixelLevelOfDetail_t lodmode(void) const { return m_lodmode; } inline PixelLevelOfDetail_t lodmode(void) const { return m_lodmode; }
@ -255,9 +265,9 @@ public:
inline bool zmode_compare_less(void) const { return m_zmode_compare_less; } //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) inline bool zmode_compare_less(void) const { return m_zmode_compare_less; } //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating)
inline bool old_style_adither(void) const { return m_old_style_adither; } //apply alpha dither regardless of alpha_dither_mode inline bool old_style_adither(void) const { return m_old_style_adither; } //apply alpha dither regardless of alpha_dither_mode
inline bool n64_z_scale(void) const { return m_n64_z_scale; } //scale vertex z value before writing to depth buffer, as N64 does. inline bool n64_z_scale(void) const { return m_n64_z_scale; } //scale vertex z value before writing to depth buffer, as N64 does.
inline bool hacks(hacks_t hack) const { return (m_hacks & hack) == hack; } //Special game hacks inline bool hacks(hacks_t hack) const { return (m_hacks & hack) == hack; } //Special game hacks
//wrapper settings //wrapper settings
#ifndef ANDROID #ifndef ANDROID
inline uint32_t FullScreenRes(void) const { return m_FullScreenRes; } inline uint32_t FullScreenRes(void) const { return m_FullScreenRes; }
@ -288,7 +298,7 @@ public:
void SetGhqHirsF16bpp(bool value); void SetGhqHirsF16bpp(bool value);
void SetGhqHirsDump(bool value); void SetGhqHirsDump(bool value);
void SetGhqEnhtNobg(bool value); void SetGhqEnhtNobg(bool value);
void SetGhqEnhtCmpr(bool value); void SetGhqEnhtCmpr(bool value);
void SetGhqHirsAltcrc(bool value); void SetGhqHirsAltcrc(bool value);
void SetGhqHirsCmpr(bool value); void SetGhqHirsCmpr(bool value);
void SetGhqHirsGz(bool value); void SetGhqHirsGz(bool value);

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* * * *
* Project 64 - A Nintendo 64 emulator. * * Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ * * http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. * * Copyright (C) 2017 Project64. All rights reserved. *
* * * *
* License: * * License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *

View File

@ -1,47 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Hardware frame buffer emulation
// Dec 2003 created by Gonetz
//
//****************************************************************
#include <string.h> #include <string.h>
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "TexBuffer.h" #include "TexBuffer.h"

View File

@ -1,47 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Hardware frame buffer emulation
// Dec 2003 created by Gonetz
//
//****************************************************************
#ifndef TEXBUFFER_H #ifndef TEXBUFFER_H
#define TEXBUFFER_H #define TEXBUFFER_H

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "TexCache.h" #include "TexCache.h"

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#ifndef TEXCACHE_H #ifndef TEXCACHE_H
#define TEXCACHE_H #define TEXCACHE_H

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static inline void texConv_ARGB1555_ARGB4444(uint8_t *src, uint8_t *dst, int size) static inline void texConv_ARGB1555_ARGB4444(uint8_t *src, uint8_t *dst, int size)
{ {
uint32_t *v3; uint32_t *v3;

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include "TexLoad4b.h" #include "TexLoad4b.h"
#include "TexLoad8b.h" #include "TexLoad8b.h"

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static inline void load16bRGBA(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext) static inline void load16bRGBA(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext)
{ {

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//**************************************************************** //****************************************************************
// Size: 2, Format: 0 // Size: 2, Format: 0

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static inline void load4bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, uint16_t line, int ext, uint16_t *pal) static inline void load4bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, uint16_t line, int ext, uint16_t *pal)
{ {

View File

@ -1,41 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static inline void load8bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext, uint16_t *pal) static inline void load8bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext, uint16_t *pal)
{ {

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static void mod_tex_inter_color_using_factor(uint16_t *dst, int size, uint32_t color, uint32_t factor) static void mod_tex_inter_color_using_factor(uint16_t *dst, int size, uint32_t color, uint32_t factor)
{ {
float percent = factor / 255.0f; float percent = factor / 255.0f;

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static void mod_tex_inter_color_using_factor_CI(uint32_t color, uint32_t factor) static void mod_tex_inter_color_using_factor_CI(uint32_t color, uint32_t factor)
{ {
float percent = factor / 255.0f; float percent = factor / 255.0f;
@ -171,7 +145,7 @@ static void mod_tex_sub_col_mul_fac_add_tex_CI(uint32_t color, uint32_t factor)
cg = (uint8_t)((color >> 16) & 0xFF); cg = (uint8_t)((color >> 16) & 0xFF);
cb = (uint8_t)((color >> 8) & 0xFF); cb = (uint8_t)((color >> 8) & 0xFF);
for (int i = 0; i<256; i++) for (int i = 0; i < 256; i++)
{ {
col = rdp.pal_8[i]; col = rdp.pal_8[i];
a = (uint8_t)(col & 0x0001);; a = (uint8_t)(col & 0x0001);;
@ -290,7 +264,7 @@ static void mod_tex_sub_col_mul_fac_CI(uint32_t color, uint32_t factor)
cg = (uint8_t)((color >> 16) & 0xFF); cg = (uint8_t)((color >> 16) & 0xFF);
cb = (uint8_t)((color >> 8) & 0xFF); cb = (uint8_t)((color >> 8) & 0xFF);
for (int i = 0; i<256; i++) for (int i = 0; i < 256; i++)
{ {
col = rdp.pal_8[i]; col = rdp.pal_8[i];
a = (uint8_t)(col & 0x0001); a = (uint8_t)(col & 0x0001);

View File

@ -1,58 +1,18 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this is distributed in the hope that it will be useful, #pragma once
* but WITHOUT ANY WARRANTY; without even the implied warranty of #include <Common/stdtypes.h>
* 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __EXT_TXFILTER_H__
#define __EXT_TXFILTER_H__
#ifdef _WIN32
#include <windows.h>
#define TXHMODULE HMODULE
#define DLOPEN(a) LoadLibraryW(a)
#define DLCLOSE(a) FreeLibrary(a)
#define DLSYM(a, b) GetProcAddress(a, b)
#define GETCWD(a, b) GetCurrentDirectoryW(a, b)
#define CHDIR(a) SetCurrentDirectoryW(a)
#else
#include <iostream>
#include <dlfcn.h>
#define MAX_PATH 4095
#define TXHMODULE void*
#define DLOPEN(a) dlopen(a, RTLD_LAZY|RTLD_GLOBAL)
#define DLCLOSE(a) dlclose(a)
#define DLSYM(a, b) dlsym(a, b)
#define GETCWD(a, b) getcwd(b, a)
#define CHDIR(a) chdir(a)
#endif
#ifdef WIN32
typedef __int64 int64;
typedef unsigned __int64 uint64;
typedef unsigned char boolean;
#else
typedef long long int64;
typedef unsigned long long uint64;
typedef unsigned char boolean;
#endif
#define NO_OPTIONS 0x00000000 #define NO_OPTIONS 0x00000000
@ -104,44 +64,21 @@ typedef unsigned char boolean;
#define LET_TEXARTISTS_FLY 0x40000000 /* a little freedom for texture artists */ #define LET_TEXARTISTS_FLY 0x40000000 /* a little freedom for texture artists */
#define DUMP_TEX 0x80000000 #define DUMP_TEX 0x80000000
#ifndef __GLIDE_H__ /* GLIDE3 */
/* from 3Dfx Interactive Inc. glide.h */
#define GR_TEXFMT_ALPHA_8 0x2
#define GR_TEXFMT_INTENSITY_8 0x3
#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
#define GR_TEXFMT_P_8 0x5
#define GR_TEXFMT_RGB_565 0xa
#define GR_TEXFMT_ARGB_1555 0xb
#define GR_TEXFMT_ARGB_4444 0xc
#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
/* from 3Dfx Interactive Inc. g3ext.h */
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
#define GR_TEXFMT_ARGB_8888 0x12
#define GR_TEXFMT_ARGB_CMP_DXT1 0x16
#define GR_TEXFMT_ARGB_CMP_DXT3 0x18
#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A
#endif /* GLIDE3 */
struct GHQTexInfo { struct GHQTexInfo {
unsigned char *data; unsigned char *data;
int width; int width;
int height; int height;
unsigned short format; unsigned short format;
int smallLodLog2; int smallLodLog2;
int largeLodLog2; int largeLodLog2;
int aspectRatioLog2; int aspectRatioLog2;
int tiles; int tiles;
int untiled_width; int untiled_width;
int untiled_height; int untiled_height;
unsigned char is_hires_tex; unsigned char is_hires_tex;
}; };
/* Callback to display hires texture info. /* Callback to display hires texture info.
@ -159,54 +96,53 @@ struct GHQTexInfo {
* printf(buf); * printf(buf);
* } * }
*/ */
#define INFO_BUF 4095 #define INFO_BUF 4095
typedef void (*dispInfoFuncExt)(const char *format, ...); typedef void(*dispInfoFuncExt)(const char *format, ...);
#ifndef TXFILTER_DLL #ifndef TXFILTER_DLL
boolean ext_ghq_init(int maxwidth, /* maximum texture width supported by hardware */ bool ext_ghq_init(int maxwidth, /* maximum texture width supported by hardware */
int maxheight,/* maximum texture height supported by hardware */ int maxheight,/* maximum texture height supported by hardware */
int maxbpp, /* maximum texture bpp supported by hardware */ int maxbpp, /* maximum texture bpp supported by hardware */
int options, /* options */ int options, /* options */
int cachesize,/* cache textures to system memory */ int cachesize,/* cache textures to system memory */
const char *path, /* plugin directory. must be smaller than MAX_PATH */ const char *path, /* plugin directory. must be smaller than MAX_PATH */
const char *ident, /* name of ROM. must be no longer than 64 in character. */ const char *ident, /* name of ROM. must be no longer than 64 in character. */
dispInfoFuncExt callback /* callback function to display info */ dispInfoFuncExt callback /* callback function to display info */
); );
void ext_ghq_shutdown(void); void ext_ghq_shutdown(void);
boolean ext_ghq_txfilter(unsigned char *src, /* input texture */ bool ext_ghq_txfilter(unsigned char *src, /* input texture */
int srcwidth, /* width of input texture */ int srcwidth, /* width of input texture */
int srcheight, /* height of input texture */ int srcheight, /* height of input texture */
unsigned short srcformat, /* format of input texture */ unsigned short srcformat, /* format of input texture */
uint64 g64crc, /* glide64 crc */ uint64_t g64crc, /* glide64 crc */
GHQTexInfo *info /* output */ GHQTexInfo *info /* output */
); );
boolean ext_ghq_hirestex(uint64 g64crc, /* glide64 crc */ bool ext_ghq_hirestex(uint64_t g64crc, /* glide64 crc */
uint64 r_crc64, /* checksum hi:palette low:texture */ uint64_t r_crc64, /* checksum hi:palette low:texture */
unsigned short *palette, /* palette for CI textures */ unsigned short *palette, /* palette for CI textures */
GHQTexInfo *info /* output */ GHQTexInfo *info /* output */
); );
uint64 ext_ghq_checksum(unsigned char *src, /* input texture */ uint64_t ext_ghq_checksum(unsigned char *src, /* input texture */
int width, /* width of texture */ int width, /* width of texture */
int height, /* height of texture */ int height, /* height of texture */
int size, /* type of texture pixel */ int size, /* type of texture pixel */
int rowStride, /* row stride in bytes */ int rowStride, /* row stride in bytes */
unsigned char *palette /* palette */ unsigned char *palette /* palette */
); );
boolean ext_ghq_dmptx(unsigned char *src, /* input texture (must be in 3Dfx Glide format) */ bool ext_ghq_dmptx(unsigned char *src, /* input texture (must be in 3Dfx Glide format) */
int width, /* width of texture */ int width, /* width of texture */
int height, /* height of texture */ int height, /* height of texture */
int rowStridePixel, /* row stride of input texture in pixels */ int rowStridePixel, /* row stride of input texture in pixels */
unsigned short gfmt, /* glide format of input texture */ unsigned short gfmt, /* glide format of input texture */
unsigned short n64fmt,/* N64 format hi:format low:size */ unsigned short n64fmt,/* N64 format hi:format low:size */
uint64 r_crc64 /* checksum hi:palette low:texture */ uint64_t r_crc64 /* checksum hi:palette low:texture */
); );
boolean ext_ghq_reloadhirestex(); bool ext_ghq_reloadhirestex();
#endif /* TXFILTER_DLL */ #endif /* TXFILTER_DLL */
#endif /* __EXT_TXFILTER_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TEXTUREFILTERS_H__ #ifndef __TEXTUREFILTERS_H__
#define __TEXTUREFILTERS_H__ #define __TEXTUREFILTERS_H__
@ -33,7 +23,7 @@
#include "TxInternal.h" #include "TxInternal.h"
/* enhancers */ /* enhancers */
void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL);
void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height);
@ -58,7 +48,7 @@ void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, u
void hq4x_init(void); void hq4x_init(void);
void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL);
void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL);
void hq4x_565 (unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq4x_565(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL);
void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height);
void hq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); void hq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height);
@ -68,8 +58,8 @@ void lq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in
void Super2xSaI_4444(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); void Super2xSaI_4444(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch);
void Super2xSaI_1555(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); void Super2xSaI_1555(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch);
void Super2xSaI_565 (uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); void Super2xSaI_565(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch);
void Super2xSaI_8 (uint8 *srcPtr, uint8 *destPtr, uint32 width, uint32 height, uint32 pitch); void Super2xSaI_8(uint8 *srcPtr, uint8 *destPtr, uint32 width, uint32 height, uint32 pitch);
void Texture2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); void Texture2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height);

View File

@ -1,28 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Based on Derek Liauw Kie Fa and Rice1964 Super2xSaI code */
#include "TextureFilters.h" #include "TextureFilters.h"
#define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D))
@ -36,14 +24,14 @@ void Super2xSaI_8888(uint32 *srcPtr, uint32 *destPtr, uint32 width, uint32 heigh
#define SAI_INTERPOLATE SAI_INTERPOLATE_8888 #define SAI_INTERPOLATE SAI_INTERPOLATE_8888
#define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_8888 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_8888
uint32 destWidth = width << 1; uint32 destWidth = width << 1;
uint32 color4, color5, color6; uint32 color4, color5, color6;
uint32 color1, color2, color3; uint32 color1, color2, color3;
uint32 colorA0, colorA1, colorA2, colorA3; uint32 colorA0, colorA1, colorA2, colorA3;
uint32 colorB0, colorB1, colorB2, colorB3; uint32 colorB0, colorB1, colorB2, colorB3;
uint32 colorS1, colorS2; uint32 colorS1, colorS2;
uint32 product1a, product1b, product2a, product2b; uint32 product1a, product1b, product2a, product2b;
#include "TextureFilters_2xsai.h" #include "TextureFilters_2xsai.h"
@ -61,15 +49,15 @@ void Super2xSaI_4444(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 heigh
#define SAI_INTERPOLATE SAI_INTERPOLATE_4444 #define SAI_INTERPOLATE SAI_INTERPOLATE_4444
#define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_4444 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_4444
uint32 destWidth = width << 1; uint32 destWidth = width << 1;
uint32 destHeight = height << 1; uint32 destHeight = height << 1;
uint16 color4, color5, color6; uint16 color4, color5, color6;
uint16 color1, color2, color3; uint16 color1, color2, color3;
uint16 colorA0, colorA1, colorA2, colorA3; uint16 colorA0, colorA1, colorA2, colorA3;
uint16 colorB0, colorB1, colorB2, colorB3; uint16 colorB0, colorB1, colorB2, colorB3;
uint16 colorS1, colorS2; uint16 colorS1, colorS2;
uint16 product1a, product1b, product2a, product2b; uint16 product1a, product1b, product2a, product2b;
#include "TextureFilters_2xsai.h" #include "TextureFilters_2xsai.h"
@ -86,15 +74,15 @@ void Super2xSaI_1555(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 heigh
#define SAI_INTERPOLATE SAI_INTERPOLATE_1555 #define SAI_INTERPOLATE SAI_INTERPOLATE_1555
#define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_1555 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_1555
uint32 destWidth = width << 1; uint32 destWidth = width << 1;
uint32 destHeight = height << 1; uint32 destHeight = height << 1;
uint16 color4, color5, color6; uint16 color4, color5, color6;
uint16 color1, color2, color3; uint16 color1, color2, color3;
uint16 colorA0, colorA1, colorA2, colorA3; uint16 colorA0, colorA1, colorA2, colorA3;
uint16 colorB0, colorB1, colorB2, colorB3; uint16 colorB0, colorB1, colorB2, colorB3;
uint16 colorS1, colorS2; uint16 colorS1, colorS2;
uint16 product1a, product1b, product2a, product2b; uint16 product1a, product1b, product2a, product2b;
#include "TextureFilters_2xsai.h" #include "TextureFilters_2xsai.h"
@ -111,15 +99,15 @@ void Super2xSaI_565(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height
#define SAI_INTERPOLATE SAI_INTERPOLATE_565 #define SAI_INTERPOLATE SAI_INTERPOLATE_565
#define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_565 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_565
uint32 destWidth = width << 1; uint32 destWidth = width << 1;
uint32 destHeight = height << 1; uint32 destHeight = height << 1;
uint16 color4, color5, color6; uint16 color4, color5, color6;
uint16 color1, color2, color3; uint16 color1, color2, color3;
uint16 colorA0, colorA1, colorA2, colorA3; uint16 colorA0, colorA1, colorA2, colorA3;
uint16 colorB0, colorB1, colorB2, colorB3; uint16 colorB0, colorB1, colorB2, colorB3;
uint16 colorS1, colorS2; uint16 colorS1, colorS2;
uint16 product1a, product1b, product2a, product2b; uint16 product1a, product1b, product2a, product2b;
#include "TextureFilters_2xsai.h" #include "TextureFilters_2xsai.h"
@ -136,19 +124,19 @@ void Super2xSaI_8(uint8 *srcPtr, uint8 *destPtr, uint32 width, uint32 height, ui
#define SAI_INTERPOLATE SAI_INTERPOLATE_8 #define SAI_INTERPOLATE SAI_INTERPOLATE_8
#define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_8 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_8
uint32 destWidth = width << 1; uint32 destWidth = width << 1;
uint32 destHeight = height << 1; uint32 destHeight = height << 1;
uint8 color4, color5, color6; uint8 color4, color5, color6;
uint8 color1, color2, color3; uint8 color1, color2, color3;
uint8 colorA0, colorA1, colorA2, colorA3; uint8 colorA0, colorA1, colorA2, colorA3;
uint8 colorB0, colorB1, colorB2, colorB3; uint8 colorB0, colorB1, colorB2, colorB3;
uint8 colorS1, colorS2; uint8 colorS1, colorS2;
uint8 product1a, product1b, product2a, product2b; uint8 product1a, product1b, product2a, product2b;
#include "TextureFilters_2xsai.h" #include "TextureFilters_2xsai.h"
#undef SAI_INTERPOLATE #undef SAI_INTERPOLATE
#undef SAI_Q_INTERPOLATE #undef SAI_Q_INTERPOLATE
} }
#endif /* !_16BPP_HACK */ #endif /* !_16BPP_HACK */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Based on Maxim Stepin and Rice1964 hq4x code */
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include "TextureFilters.h" #include "TextureFilters.h"
@ -51,92 +39,92 @@ static uint32 RGB444toYUV[4096];
static uint32 RGB555toYUV(uint32 val) static uint32 RGB555toYUV(uint32 val)
{ {
uint32 r, g, b, Y, u, v; uint32 r, g, b, Y, u, v;
r = (val & 0x7C00) >> 7; r = (val & 0x7C00) >> 7;
g = (val & 0x03E0) >> 2; g = (val & 0x03E0) >> 2;
b = (val & 0x001F) << 3; b = (val & 0x001F) << 3;
r |= r >> 5; r |= r >> 5;
g |= g >> 5; g |= g >> 5;
b |= b >> 5; b |= b >> 5;
Y = (r + g + b) >> 2; Y = (r + g + b) >> 2;
u = 128 + ((r - b) >> 2); u = 128 + ((r - b) >> 2);
v = 128 + ((2*g - r - b)>>3); v = 128 + ((2 * g - r - b) >> 3);
return ((Y << 16) | (u << 8) | v); return ((Y << 16) | (u << 8) | v);
} }
static uint32 RGB565toYUV(uint32 val) static uint32 RGB565toYUV(uint32 val)
{ {
uint32 r, g, b, Y, u, v; uint32 r, g, b, Y, u, v;
r = (val & 0xF800) >> 8; r = (val & 0xF800) >> 8;
g = (val & 0x07E0) >> 3; g = (val & 0x07E0) >> 3;
b = (val & 0x001F) << 3; b = (val & 0x001F) << 3;
r |= r >> 5; r |= r >> 5;
g |= g >> 6; g |= g >> 6;
b |= b >> 5; b |= b >> 5;
Y = (r + g + b) >> 2; Y = (r + g + b) >> 2;
u = 128 + ((r - b) >> 2); u = 128 + ((r - b) >> 2);
v = 128 + ((2*g - r - b)>>3); v = 128 + ((2 * g - r - b) >> 3);
return ((Y << 16) | (u << 8) | v); return ((Y << 16) | (u << 8) | v);
} }
#endif /* !_16BPP_HACK */ #endif /* !_16BPP_HACK */
static uint32 RGB888toYUV(uint32 val) static uint32 RGB888toYUV(uint32 val)
{ {
#if 0 #if 0
uint32 Yuv; uint32 Yuv;
__asm { __asm {
mov eax, dword ptr [val]; mov eax, dword ptr[val];
mov ebx, eax; mov ebx, eax;
mov ecx, eax; mov ecx, eax;
and ebx, 0x000000ff; // b and ebx, 0x000000ff; // b
and eax, 0x00ff0000; // r and eax, 0x00ff0000; // r
and ecx, 0x0000ff00; // g and ecx, 0x0000ff00; // g
shl ebx, 14; shl ebx, 14;
shr eax, 2; shr eax, 2;
shl ecx, 6; shl ecx, 6;
mov edx, ebx; mov edx, ebx;
add edx, eax; add edx, eax;
add edx, ecx; add edx, ecx;
and edx, 0xffff0000; and edx, 0xffff0000;
sub eax, ebx; sub eax, ebx;
add eax, 0x00800000; add eax, 0x00800000;
shr eax, 8; shr eax, 8;
or edx, eax; or edx, eax;
sub eax, 0x00800000; sub eax, 0x00800000;
and edx, 0xffffff00; and edx, 0xffffff00;
add ecx, 0x00800000; add ecx, 0x00800000;
shr ecx, 5; shr ecx, 5;
shr ebx, 7; shr ebx, 7;
add eax, ebx; add eax, ebx;
sub ecx, eax; sub ecx, eax;
shr ecx, 11; shr ecx, 11;
or edx, ecx; or edx, ecx;
mov dword ptr [Yuv], edx; mov dword ptr[Yuv], edx;
} }
return Yuv; return Yuv;
#else #else
uint32 r, g, b, Y, u, v; uint32 r, g, b, Y, u, v;
r = (val & 0x00ff0000) >> 16; r = (val & 0x00ff0000) >> 16;
g = (val & 0x0000ff00) >> 8; g = (val & 0x0000ff00) >> 8;
b = val & 0x000000ff; b = val & 0x000000ff;
Y = (r + g + b) >> 2; Y = (r + g + b) >> 2;
u = (0x00000200 + r - b) >> 2; u = (0x00000200 + r - b) >> 2;
v = (0x00000400 + (g << 1) - r - b) >> 3; v = (0x00000400 + (g << 1) - r - b) >> 3;
return ((Y << 16) | (u << 8) | v); return ((Y << 16) | (u << 8) | v);
#endif #endif
} }
@ -423,88 +411,90 @@ void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
#define BPP2 4 #define BPP2 4
#define BPP3 6 #define BPP3 6
int i, j, k; int i, j, k;
int prevline, nextline; int prevline, nextline;
uint16 w[10]; uint16 w[10];
uint16 c[10]; uint16 c[10];
int pattern; int pattern;
int flag; int flag;
int YUV1, YUV2; int YUV1, YUV2;
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w1 | w2 | w3 | // | w1 | w2 | w3 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w4 | w5 | w6 | // | w4 | w5 | w6 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w7 | w8 | w9 | // | w7 | w8 | w9 |
// +----+----+----+ // +----+----+----+
for (j = 0; j < Yres; j++) { for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*2; else prevline = 0; if (j > 0) prevline = -SrcPPL * 2; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*2; else nextline = 0; if (j < Yres - 1) nextline = SrcPPL * 2; else nextline = 0;
for (i=0; i<Xres; i++) { for (i = 0; i < Xres; i++) {
w[2] = *((uint16*)(pIn + prevline)); w[2] = *((uint16*)(pIn + prevline));
w[5] = *((uint16*)pIn); w[5] = *((uint16*)pIn);
w[8] = *((uint16*)(pIn + nextline)); w[8] = *((uint16*)(pIn + nextline));
if (i>0) { if (i > 0) {
w[1] = *((uint16*)(pIn + prevline - 2)); w[1] = *((uint16*)(pIn + prevline - 2));
w[4] = *((uint16*)(pIn - 2)); w[4] = *((uint16*)(pIn - 2));
w[7] = *((uint16*)(pIn + nextline - 2)); w[7] = *((uint16*)(pIn + nextline - 2));
} else { }
w[1] = w[2]; else {
w[4] = w[5]; w[1] = w[2];
w[7] = w[8]; w[4] = w[5];
} w[7] = w[8];
}
if (i<Xres-1) { if (i < Xres - 1) {
w[3] = *((uint16*)(pIn + prevline + 2)); w[3] = *((uint16*)(pIn + prevline + 2));
w[6] = *((uint16*)(pIn + 2)); w[6] = *((uint16*)(pIn + 2));
w[9] = *((uint16*)(pIn + nextline + 2)); w[9] = *((uint16*)(pIn + nextline + 2));
} else { }
w[3] = w[2]; else {
w[6] = w[5]; w[3] = w[2];
w[9] = w[8]; w[6] = w[5];
} w[9] = w[8];
}
pattern = 0; pattern = 0;
flag = 1; flag = 1;
YUV1 = RGB444toYUV(w[5]); YUV1 = RGB444toYUV(w[5]);
for (k=1; k<=9; k++) { for (k = 1; k <= 9; k++) {
if (k==5) continue; if (k == 5) continue;
if ( w[k] != w[5] ) { if (w[k] != w[5]) {
YUV2 = RGB444toYUV(w[k]); YUV2 = RGB444toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) || if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag; pattern |= flag;
} }
flag <<= 1; flag <<= 1;
} }
for (k=1; k<=9; k++) for (k = 1; k <= 9; k++)
c[k] = w[k]; c[k] = w[k];
#include "TextureFilters_hq4x.h" #include "TextureFilters_hq4x.h"
pIn+=2; pIn += 2;
pOut+=8; pOut += 8;
}
pIn += 2 * (SrcPPL - Xres);
pOut += 8 * (SrcPPL - Xres);
pOut += BpL;
pOut += BpL;
pOut += BpL;
} }
pIn += 2*(SrcPPL-Xres);
pOut+= 8*(SrcPPL-Xres);
pOut+=BpL;
pOut+=BpL;
pOut+=BpL;
}
#undef BPP #undef BPP
#undef BPP2 #undef BPP2
@ -535,88 +525,90 @@ void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
#define BPP2 4 #define BPP2 4
#define BPP3 6 #define BPP3 6
int i, j, k; int i, j, k;
int prevline, nextline; int prevline, nextline;
uint16 w[10]; uint16 w[10];
uint16 c[10]; uint16 c[10];
int pattern; int pattern;
int flag; int flag;
int YUV1, YUV2; int YUV1, YUV2;
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w1 | w2 | w3 | // | w1 | w2 | w3 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w4 | w5 | w6 | // | w4 | w5 | w6 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w7 | w8 | w9 | // | w7 | w8 | w9 |
// +----+----+----+ // +----+----+----+
for (j = 0; j < Yres; j++) { for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*2; else prevline = 0; if (j > 0) prevline = -SrcPPL * 2; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*2; else nextline = 0; if (j < Yres - 1) nextline = SrcPPL * 2; else nextline = 0;
for (i=0; i<Xres; i++) { for (i = 0; i < Xres; i++) {
w[2] = *((uint16*)(pIn + prevline)); w[2] = *((uint16*)(pIn + prevline));
w[5] = *((uint16*)pIn); w[5] = *((uint16*)pIn);
w[8] = *((uint16*)(pIn + nextline)); w[8] = *((uint16*)(pIn + nextline));
if (i>0) { if (i > 0) {
w[1] = *((uint16*)(pIn + prevline - 2)); w[1] = *((uint16*)(pIn + prevline - 2));
w[4] = *((uint16*)(pIn - 2)); w[4] = *((uint16*)(pIn - 2));
w[7] = *((uint16*)(pIn + nextline - 2)); w[7] = *((uint16*)(pIn + nextline - 2));
} else { }
w[1] = w[2]; else {
w[4] = w[5]; w[1] = w[2];
w[7] = w[8]; w[4] = w[5];
} w[7] = w[8];
}
if (i<Xres-1) { if (i < Xres - 1) {
w[3] = *((uint16*)(pIn + prevline + 2)); w[3] = *((uint16*)(pIn + prevline + 2));
w[6] = *((uint16*)(pIn + 2)); w[6] = *((uint16*)(pIn + 2));
w[9] = *((uint16*)(pIn + nextline + 2)); w[9] = *((uint16*)(pIn + nextline + 2));
} else { }
w[3] = w[2]; else {
w[6] = w[5]; w[3] = w[2];
w[9] = w[8]; w[6] = w[5];
} w[9] = w[8];
}
pattern = 0; pattern = 0;
flag = 1; flag = 1;
YUV1 = RGB555toYUV(w[5]); YUV1 = RGB555toYUV(w[5]);
for (k=1; k<=9; k++) { for (k = 1; k <= 9; k++) {
if (k==5) continue; if (k == 5) continue;
if ( w[k] != w[5] ) { if (w[k] != w[5]) {
YUV2 = RGB555toYUV(w[k]); YUV2 = RGB555toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) || if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag; pattern |= flag;
} }
flag <<= 1; flag <<= 1;
} }
for (k=1; k<=9; k++) for (k = 1; k <= 9; k++)
c[k] = w[k]; c[k] = w[k];
#include "TextureFilters_hq4x.h" #include "TextureFilters_hq4x.h"
pIn+=2; pIn += 2;
pOut+=8; pOut += 8;
}
pIn += 2 * (SrcPPL - Xres);
pOut += 8 * (SrcPPL - Xres);
pOut += BpL;
pOut += BpL;
pOut += BpL;
} }
pIn += 2*(SrcPPL-Xres);
pOut+= 8*(SrcPPL-Xres);
pOut+=BpL;
pOut+=BpL;
pOut+=BpL;
}
#undef BPP #undef BPP
#undef BPP2 #undef BPP2
@ -647,88 +639,90 @@ void hq4x_565(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int
#define BPP2 4 #define BPP2 4
#define BPP3 6 #define BPP3 6
int i, j, k; int i, j, k;
int prevline, nextline; int prevline, nextline;
uint16 w[10]; uint16 w[10];
uint16 c[10]; uint16 c[10];
int pattern; int pattern;
int flag; int flag;
int YUV1, YUV2; int YUV1, YUV2;
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w1 | w2 | w3 | // | w1 | w2 | w3 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w4 | w5 | w6 | // | w4 | w5 | w6 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w7 | w8 | w9 | // | w7 | w8 | w9 |
// +----+----+----+ // +----+----+----+
for (j = 0; j < Yres; j++) { for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*2; else prevline = 0; if (j > 0) prevline = -SrcPPL * 2; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*2; else nextline = 0; if (j < Yres - 1) nextline = SrcPPL * 2; else nextline = 0;
for (i=0; i<Xres; i++) { for (i = 0; i < Xres; i++) {
w[2] = *((uint16*)(pIn + prevline)); w[2] = *((uint16*)(pIn + prevline));
w[5] = *((uint16*)pIn); w[5] = *((uint16*)pIn);
w[8] = *((uint16*)(pIn + nextline)); w[8] = *((uint16*)(pIn + nextline));
if (i>0) { if (i > 0) {
w[1] = *((uint16*)(pIn + prevline - 2)); w[1] = *((uint16*)(pIn + prevline - 2));
w[4] = *((uint16*)(pIn - 2)); w[4] = *((uint16*)(pIn - 2));
w[7] = *((uint16*)(pIn + nextline - 2)); w[7] = *((uint16*)(pIn + nextline - 2));
} else { }
w[1] = w[2]; else {
w[4] = w[5]; w[1] = w[2];
w[7] = w[8]; w[4] = w[5];
} w[7] = w[8];
}
if (i<Xres-1) { if (i < Xres - 1) {
w[3] = *((uint16*)(pIn + prevline + 2)); w[3] = *((uint16*)(pIn + prevline + 2));
w[6] = *((uint16*)(pIn + 2)); w[6] = *((uint16*)(pIn + 2));
w[9] = *((uint16*)(pIn + nextline + 2)); w[9] = *((uint16*)(pIn + nextline + 2));
} else { }
w[3] = w[2]; else {
w[6] = w[5]; w[3] = w[2];
w[9] = w[8]; w[6] = w[5];
} w[9] = w[8];
}
pattern = 0; pattern = 0;
flag = 1; flag = 1;
YUV1 = RGB565toYUV(w[5]); YUV1 = RGB565toYUV(w[5]);
for (k=1; k<=9; k++) { for (k = 1; k <= 9; k++) {
if (k==5) continue; if (k == 5) continue;
if ( w[k] != w[5] ) { if (w[k] != w[5]) {
YUV2 = RGB565toYUV(w[k]); YUV2 = RGB565toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) || if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag; pattern |= flag;
} }
flag <<= 1; flag <<= 1;
} }
for (k=1; k<=9; k++) for (k = 1; k <= 9; k++)
c[k] = w[k]; c[k] = w[k];
#include "TextureFilters_hq4x.h" #include "TextureFilters_hq4x.h"
pIn+=2; pIn += 2;
pOut+=8; pOut += 8;
}
pIn += 2 * (SrcPPL - Xres);
pOut += 8 * (SrcPPL - Xres);
pOut += BpL;
pOut += BpL;
pOut += BpL;
} }
pIn += 2*(SrcPPL-Xres);
pOut+= 8*(SrcPPL-Xres);
pOut+=BpL;
pOut+=BpL;
pOut+=BpL;
}
#undef BPP #undef BPP
#undef BPP2 #undef BPP2
@ -760,89 +754,91 @@ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
#define BPP2 8 #define BPP2 8
#define BPP3 12 #define BPP3 12
int i, j, k; int i, j, k;
int prevline, nextline; int prevline, nextline;
uint32 w[10]; uint32 w[10];
uint32 c[10]; uint32 c[10];
int pattern; int pattern;
int flag; int flag;
int YUV1, YUV2; int YUV1, YUV2;
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w1 | w2 | w3 | // | w1 | w2 | w3 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w4 | w5 | w6 | // | w4 | w5 | w6 |
// +----+----+----+ // +----+----+----+
// | | | | // | | | |
// | w7 | w8 | w9 | // | w7 | w8 | w9 |
// +----+----+----+ // +----+----+----+
for (j = 0; j < Yres; j++) { for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*4; else prevline = 0; if (j > 0) prevline = -SrcPPL * 4; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*4; else nextline = 0; if (j < Yres - 1) nextline = SrcPPL * 4; else nextline = 0;
for (i=0; i<Xres; i++) { for (i = 0; i < Xres; i++) {
w[2] = *((uint32*)(pIn + prevline)); w[2] = *((uint32*)(pIn + prevline));
w[5] = *((uint32*)pIn); w[5] = *((uint32*)pIn);
w[8] = *((uint32*)(pIn + nextline)); w[8] = *((uint32*)(pIn + nextline));
if (i>0) { if (i > 0) {
w[1] = *((uint32*)(pIn + prevline - 4)); w[1] = *((uint32*)(pIn + prevline - 4));
w[4] = *((uint32*)(pIn - 4)); w[4] = *((uint32*)(pIn - 4));
w[7] = *((uint32*)(pIn + nextline - 4)); w[7] = *((uint32*)(pIn + nextline - 4));
} else { }
w[1] = w[2]; else {
w[4] = w[5]; w[1] = w[2];
w[7] = w[8]; w[4] = w[5];
} w[7] = w[8];
}
if (i<Xres-1) { if (i < Xres - 1) {
w[3] = *((uint32*)(pIn + prevline + 4)); w[3] = *((uint32*)(pIn + prevline + 4));
w[6] = *((uint32*)(pIn + 4)); w[6] = *((uint32*)(pIn + 4));
w[9] = *((uint32*)(pIn + nextline + 4)); w[9] = *((uint32*)(pIn + nextline + 4));
} else { }
w[3] = w[2]; else {
w[6] = w[5]; w[3] = w[2];
w[9] = w[8]; w[6] = w[5];
} w[9] = w[8];
}
pattern = 0; pattern = 0;
flag = 1; flag = 1;
YUV1 = RGB888toYUV(w[5]); YUV1 = RGB888toYUV(w[5]);
for (k=1; k<=9; k++) { for (k = 1; k <= 9; k++) {
if (k==5) continue; if (k == 5) continue;
if ( w[k] != w[5] ) { if (w[k] != w[5]) {
YUV2 = RGB888toYUV(w[k]); YUV2 = RGB888toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) || if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag; pattern |= flag;
} }
flag <<= 1; flag <<= 1;
} }
for (k=1; k<=9; k++) for (k = 1; k <= 9; k++)
c[k] = w[k]; c[k] = w[k];
#include "TextureFilters_hq4x.h" #include "TextureFilters_hq4x.h"
pIn+=4; pIn += 4;
pOut+=16; pOut += 16;
} }
pIn += 4*(SrcPPL-Xres); pIn += 4 * (SrcPPL - Xres);
pOut+= 16*(SrcPPL-Xres); pOut += 16 * (SrcPPL - Xres);
pOut+=BpL; pOut += BpL;
pOut+=BpL; pOut += BpL;
pOut+=BpL; pOut += BpL;
} }
#undef BPP #undef BPP
#undef BPP2 #undef BPP2
@ -861,32 +857,32 @@ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
#if !_16BPP_HACK #if !_16BPP_HACK
void hq4x_init(void) void hq4x_init(void)
{ {
static int done = 0; static int done = 0;
int r, g, b, Y, u, v, i, j, k; int r, g, b, Y, u, v, i, j, k;
if (done ) return; if (done) return;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
for (k = 0; k < 16; k++) { for (k = 0; k < 16; k++) {
r = (i << 4) | i; r = (i << 4) | i;
g = (j << 4) | j; g = (j << 4) | j;
b = (k << 4) | k; b = (k << 4) | k;
/* Microsoft's RGB888->YUV conversion */ /* Microsoft's RGB888->YUV conversion */
/*Y = ((( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16) & 0xFF; /*Y = ((( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16) & 0xFF;
u = ((( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128) & 0xFF; u = ((( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128) & 0xFF;
v = ((( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128) & 0xFF;*/ v = ((( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128) & 0xFF;*/
Y = (r + g + b) >> 2; Y = (r + g + b) >> 2;
u = 128 + ((r - b) >> 2); u = 128 + ((r - b) >> 2);
v = 128 + ((-r + 2*g -b)>>3); v = 128 + ((-r + 2 * g - b) >> 3);
RGB444toYUV[(i << 8) | (j << 4) | k] = (Y << 16) | (u << 8) | v; RGB444toYUV[(i << 8) | (j << 4) | k] = (Y << 16) | (u << 8) | v;
} }
}
} }
}
done = 1; done = 1;
} }
#endif /* !_16BPP_HACK */ #endif /* !_16BPP_HACK */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef WIN32 #ifdef WIN32
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
@ -33,6 +24,7 @@
#include <zlib/zlib.h> #include <zlib/zlib.h>
#include <Common/path.h> #include <Common/path.h>
#include <Common/StdString.h> #include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
TxCache::~TxCache() TxCache::~TxCache()
{ {
@ -82,8 +74,8 @@ TxCache::TxCache(int options, int cachesize, const char *path, const char *ident
} }
} }
boolean bool
TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize)
{ {
/* NOTE: dataSize must be provided if info->data is zlib compressed. */ /* NOTE: dataSize must be provided if info->data is zlib compressed. */
@ -112,7 +104,7 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize)
{ {
DBG_INFO(80, "zlib compressed: %.02fkb->%.02fkb\n", (float)dataSize / 1000, (float)destLen / 1000); DBG_INFO(80, "zlib compressed: %.02fkb->%.02fkb\n", (float)dataSize / 1000, (float)destLen / 1000);
dataSize = destLen; dataSize = destLen;
format |= GR_TEXFMT_GZ; format |= GFX_TEXFMT_GZ;
} }
} }
} }
@ -124,11 +116,11 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize)
if ((_totalSize > _cacheSize) && !_cachelist.empty()) if ((_totalSize > _cacheSize) && !_cachelist.empty())
{ {
/* _cachelist is arranged so that frequently used textures are in the back */ /* _cachelist is arranged so that frequently used textures are in the back */
std::list<uint64>::iterator itList = _cachelist.begin(); std::list<uint64_t>::iterator itList = _cachelist.begin();
while (itList != _cachelist.end()) while (itList != _cachelist.end())
{ {
/* find it in _cache */ /* find it in _cache */
std::map<uint64, TXCACHE*>::iterator itMap = _cache.find(*itList); std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.find(*itList);
if (itMap != _cache.end()) if (itMap != _cache.end())
{ {
/* yep we have it. remove it. */ /* yep we have it. remove it. */
@ -176,7 +168,7 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize)
txCache->it = --(_cachelist.end()); txCache->it = --(_cachelist.end());
} }
/* _cache[checksum] = txCache; */ /* _cache[checksum] = txCache; */
_cache.insert(std::map<uint64, TXCACHE*>::value_type(checksum, txCache)); _cache.insert(std::map<uint64_t, TXCACHE*>::value_type(checksum, txCache));
#ifdef DEBUG #ifdef DEBUG
DBG_INFO(80, "[%5d] added!! crc:%08X %08X %d x %d gfmt:%x total:%.02fmb\n", DBG_INFO(80, "[%5d] added!! crc:%08X %08X %d x %d gfmt:%x total:%.02fmb\n",
@ -213,13 +205,13 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize)
return 0; return 0;
} }
boolean bool
TxCache::get(uint64 checksum, GHQTexInfo *info) TxCache::get(uint64_t checksum, GHQTexInfo *info)
{ {
if (!checksum || _cache.empty()) return 0; if (!checksum || _cache.empty()) return 0;
/* find a match in cache */ /* find a match in cache */
std::map<uint64, TXCACHE*>::iterator itMap = _cache.find(checksum); std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.find(checksum);
if (itMap != _cache.end()) if (itMap != _cache.end())
{ {
/* yep, we've got it. */ /* yep, we've got it. */
@ -234,7 +226,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
} }
/* zlib decompress it */ /* zlib decompress it */
if (info->format & GR_TEXFMT_GZ) if (info->format & GFX_TEXFMT_GZ)
{ {
uLongf destLen = _gzdestLen; uLongf destLen = _gzdestLen;
uint8 *dest = (_gzdest0 == info->data) ? _gzdest1 : _gzdest0; uint8 *dest = (_gzdest0 == info->data) ? _gzdest1 : _gzdest0;
@ -244,7 +236,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
return 0; return 0;
} }
info->data = dest; info->data = dest;
info->format &= ~GR_TEXFMT_GZ; info->format &= ~GFX_TEXFMT_GZ;
DBG_INFO(80, "zlib decompressed: %.02fkb->%.02fkb\n", (float)(((*itMap).second)->size) / 1000, (float)destLen / 1000); DBG_INFO(80, "zlib decompressed: %.02fkb->%.02fkb\n", (float)(((*itMap).second)->size) / 1000, (float)destLen / 1000);
} }
return 1; return 1;
@ -252,7 +244,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
return 0; return 0;
} }
boolean TxCache::save(const char *path, const char *filename, int config) bool TxCache::save(const char *path, const char *filename, int config)
{ {
if (!_cache.empty()) if (!_cache.empty())
{ {
@ -265,7 +257,7 @@ boolean TxCache::save(const char *path, const char *filename, int config)
/* write header to determine config match */ /* write header to determine config match */
gzwrite(gzfp, &config, 4); gzwrite(gzfp, &config, 4);
std::map<uint64, TXCACHE*>::iterator itMap = _cache.begin(); std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.begin();
while (itMap != _cache.end()) while (itMap != _cache.end())
{ {
uint8 *dest = (*itMap).second->info.data; uint8 *dest = (*itMap).second->info.data;
@ -277,17 +269,17 @@ boolean TxCache::save(const char *path, const char *filename, int config)
* texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE * texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE
* option is toggled, the cache will need to be rebuilt. * option is toggled, the cache will need to be rebuilt.
*/ */
/*if (format & GR_TEXFMT_GZ) { /*if (format & GFX_TEXFMT_GZ) {
dest = _gzdest0; dest = _gzdest0;
destLen = _gzdestLen; destLen = _gzdestLen;
if (dest && destLen) { if (dest && destLen) {
if (uncompress(dest, &destLen, (*itMap).second->info.data, (*itMap).second->size) != Z_OK) { if (uncompress(dest, &destLen, (*itMap).second->info.data, (*itMap).second->size) != Z_OK) {
dest = NULL; dest = NULL;
destLen = 0; destLen = 0;
} }
format &= ~GR_TEXFMT_GZ; format &= ~GFX_TEXFMT_GZ;
} }
}*/ }*/
if (dest && destLen) if (dest && destLen)
{ {
@ -325,7 +317,7 @@ boolean TxCache::save(const char *path, const char *filename, int config)
return _cache.empty(); return _cache.empty();
} }
boolean TxCache::load(const char *path, const char *filename, int config) bool TxCache::load(const char *path, const char *filename, int config)
{ {
/* find it on disk */ /* find it on disk */
CPath cbuf(path, filename); CPath cbuf(path, filename);
@ -336,7 +328,7 @@ boolean TxCache::load(const char *path, const char *filename, int config)
{ {
/* yep, we have it. load it into memory cache. */ /* yep, we have it. load it into memory cache. */
int dataSize; int dataSize;
uint64 checksum; uint64_t checksum;
GHQTexInfo tmpInfo; GHQTexInfo tmpInfo;
int tmpconfig; int tmpconfig;
/* read header to determine config match */ /* read header to determine config match */
@ -372,7 +364,7 @@ boolean TxCache::load(const char *path, const char *filename, int config)
gzread(gzfp, tmpInfo.data, dataSize); gzread(gzfp, tmpInfo.data, dataSize);
/* add to memory cache */ /* add to memory cache */
add(checksum, &tmpInfo, (tmpInfo.format & GR_TEXFMT_GZ) ? dataSize : 0); add(checksum, &tmpInfo, (tmpInfo.format & GFX_TEXFMT_GZ) ? dataSize : 0);
free(tmpInfo.data); free(tmpInfo.data);
} }
@ -391,11 +383,11 @@ boolean TxCache::load(const char *path, const char *filename, int config)
return !_cache.empty(); return !_cache.empty();
} }
boolean TxCache::del(uint64 checksum) bool TxCache::del(uint64_t checksum)
{ {
if (!checksum || _cache.empty()) return 0; if (!checksum || _cache.empty()) return 0;
std::map<uint64, TXCACHE*>::iterator itMap = _cache.find(checksum); std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.find(checksum);
if (itMap != _cache.end()) if (itMap != _cache.end())
{ {
/* for texture cache (not hi-res cache) */ /* for texture cache (not hi-res cache) */
@ -415,9 +407,9 @@ boolean TxCache::del(uint64 checksum)
return 0; return 0;
} }
boolean TxCache::is_cached(uint64 checksum) bool TxCache::is_cached(uint64_t checksum)
{ {
std::map<uint64, TXCACHE*>::iterator itMap = _cache.find(checksum); std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.find(checksum);
if (itMap != _cache.end()) return 1; if (itMap != _cache.end()) return 1;
return 0; return 0;
@ -427,7 +419,7 @@ void TxCache::clear()
{ {
if (!_cache.empty()) if (!_cache.empty())
{ {
std::map<uint64, TXCACHE*>::iterator itMap = _cache.begin(); std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.begin();
while (itMap != _cache.end()) while (itMap != _cache.end())
{ {
free((*itMap).second->info.data); free((*itMap).second->info.data);

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXCACHE_H__ #ifndef __TXCACHE_H__
#define __TXCACHE_H__ #define __TXCACHE_H__
@ -33,37 +24,37 @@
class TxCache class TxCache
{ {
private: private:
std::list<uint64> _cachelist; std::list<uint64_t> _cachelist;
uint8 *_gzdest0; uint8 *_gzdest0;
uint8 *_gzdest1; uint8 *_gzdest1;
uint32 _gzdestLen; uint32 _gzdestLen;
protected: protected:
int _options; int _options;
std::string _ident; std::string _ident;
std::string _path; std::string _path;
dispInfoFuncExt _callback; dispInfoFuncExt _callback;
TxUtil *_txUtil; TxUtil *_txUtil;
struct TXCACHE { struct TXCACHE {
int size; int size;
GHQTexInfo info; GHQTexInfo info;
std::list<uint64>::iterator it; std::list<uint64_t>::iterator it;
}; };
int _totalSize; int _totalSize;
int _cacheSize; int _cacheSize;
std::map<uint64, TXCACHE*> _cache; std::map<uint64_t, TXCACHE*> _cache;
boolean save(const char *path, const char *filename, const int config); bool save(const char *path, const char *filename, const int config);
boolean load(const char *path, const char *filename, const int config); bool load(const char *path, const char *filename, const int config);
boolean del(uint64 checksum); /* checksum hi:palette low:texture */ bool del(uint64_t checksum); /* checksum hi:palette low:texture */
boolean is_cached(uint64 checksum); /* checksum hi:palette low:texture */ bool is_cached(uint64_t checksum); /* checksum hi:palette low:texture */
void clear(); void clear();
public: public:
~TxCache(); ~TxCache();
TxCache(int options, int cachesize, const char *path, const char *ident, TxCache(int options, int cachesize, const char *path, const char *ident,
dispInfoFuncExt callback); dispInfoFuncExt callback);
boolean add(uint64 checksum, /* checksum hi:palette low:texture */ bool add(uint64_t checksum, /* checksum hi:palette low:texture */
GHQTexInfo *info, int dataSize = 0); GHQTexInfo *info, int dataSize = 0);
boolean get(uint64 checksum, /* checksum hi:palette low:texture */ bool get(uint64_t checksum, /* checksum hi:palette low:texture */
GHQTexInfo *info); GHQTexInfo *info);
}; };
#endif /* __TXCACHE_H__ */ #endif /* __TXCACHE_H__ */

View File

@ -1,26 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define DBG_LEVEL 80 #define DBG_LEVEL 80
#include "TxDbg.h" #include "TxDbg.h"
@ -49,7 +39,7 @@ TxDbg::TxDbg()
TxDbg::~TxDbg() TxDbg::~TxDbg()
{ {
if (_dbgfile) if (_dbgfile)
{ {
fclose(_dbgfile); fclose(_dbgfile);
_dbgfile = 0; _dbgfile = 0;

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXDBG_H__ #ifndef __TXDBG_H__
#define __TXDBG_H__ #define __TXDBG_H__
@ -30,16 +21,16 @@
class TxDbg class TxDbg
{ {
private: private:
FILE* _dbgfile; FILE* _dbgfile;
int _level; int _level;
TxDbg(); TxDbg();
public: public:
static TxDbg* getInstance() { static TxDbg* getInstance() {
static TxDbg txDbg; static TxDbg txDbg;
return &txDbg; return &txDbg;
} }
~TxDbg(); ~TxDbg();
void output(const int level, const char *format, ...); void output(const int level, const char *format, ...);
}; };
#ifdef DEBUG #ifdef DEBUG

View File

@ -1,32 +1,23 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef _WIN32 #ifdef _WIN32
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
#endif #endif
#include <Common/path.h> #include <Common/path.h>
#include <Common/StdString.h> #include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
#include "TxFilter.h" #include "TxFilter.h"
#include "TextureFilters.h" #include "TextureFilters.h"
#include "TxDbg.h" #include "TxDbg.h"
@ -173,8 +164,8 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options,
_initialized = 1; _initialized = 1;
} }
boolean bool
TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint64 g64crc, GHQTexInfo *info) TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint64_t g64crc, GHQTexInfo *info)
{ {
uint8 *texture = src; uint8 *texture = src;
uint8 *tmptex = _tex1; uint8 *tmptex = _tex1;
@ -187,7 +178,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
if (_cacheSize) { if (_cacheSize) {
/* calculate checksum of source texture */ /* calculate checksum of source texture */
if (!g64crc) if (!g64crc)
g64crc = (uint64)(_txUtil->checksumTx(texture, srcwidth, srcheight, srcformat)); g64crc = (uint64_t)(_txUtil->checksumTx(texture, srcwidth, srcheight, srcformat));
DBG_INFO(80, "filter: crc:%08X %08X %d x %d gfmt:%x\n", DBG_INFO(80, "filter: crc:%08X %08X %d x %d gfmt:%x\n",
(uint32)(g64crc >> 32), (uint32)(g64crc & 0xffffffff), srcwidth, srcheight, srcformat); (uint32)(g64crc >> 32), (uint32)(g64crc & 0xffffffff), srcwidth, srcheight, srcformat);
@ -208,25 +199,25 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
*/ */
if ((srcwidth >= 4 && srcheight >= 4) && if ((srcwidth >= 4 && srcheight >= 4) &&
((_options & (FILTER_MASK | ENHANCEMENT_MASK | COMPRESSION_MASK)) || ((_options & (FILTER_MASK | ENHANCEMENT_MASK | COMPRESSION_MASK)) ||
(srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) { (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) {
#if !_16BPP_HACK #if !_16BPP_HACK
/* convert textures to a format that the compressor accepts (ARGB8888) */ /* convert textures to a format that the compressor accepts (ARGB8888) */
if (_options & COMPRESSION_MASK) { if (_options & COMPRESSION_MASK) {
#endif #endif
if (srcformat != GR_TEXFMT_ARGB_8888) { if (srcformat != GFX_TEXFMT_ARGB_8888) {
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GR_TEXFMT_ARGB_8888)) { if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GFX_TEXFMT_ARGB_8888)) {
DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat); DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat);
return 0; return 0;
} }
texture = tmptex; texture = tmptex;
destformat = GR_TEXFMT_ARGB_8888; destformat = GFX_TEXFMT_ARGB_8888;
} }
#if !_16BPP_HACK #if !_16BPP_HACK
} }
#endif #endif
switch (destformat) { switch (destformat) {
case GR_TEXFMT_ARGB_8888: case GFX_TEXFMT_ARGB_8888:
/* /*
* prepare texture enhancements (x2, x4 scalers) * prepare texture enhancements (x2, x4 scalers)
@ -293,8 +284,8 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
/* /*
* texture compression * texture compression
*/ */
/* ignored if we only have texture compression option on. /* ignored if we only have texture compression option on.
* only done when texture enhancer is used. see constructor. */ * only done when texture enhancer is used. see constructor. */
if ((_options & COMPRESSION_MASK) && if ((_options & COMPRESSION_MASK) &&
(srcwidth >= 64 && srcheight >= 64) /* Texture compression is not suitable for low pixel coarse detail (srcwidth >= 64 && srcheight >= 64) /* Texture compression is not suitable for low pixel coarse detail
* textures. The assumption here is that textures larger than 64x64 * textures. The assumption here is that textures larger than 64x64
@ -304,16 +295,16 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
* reasonable if decisions are made based on fourier-transform * reasonable if decisions are made based on fourier-transform
* spectrum or RMS error. * spectrum or RMS error.
*/ */
) { ) {
int compressionType = _options & COMPRESSION_MASK; int compressionType = _options & COMPRESSION_MASK;
int tmpwidth, tmpheight; int tmpwidth, tmpheight;
uint16 tmpformat; uint16 tmpformat;
/* XXX: textures that use 8bit alpha channel look bad with the current /* XXX: textures that use 8bit alpha channel look bad with the current
* fxt1 library, so we substitute it with dxtn for now. afaik all gfx * fxt1 library, so we substitute it with dxtn for now. afaik all gfx
* cards that support fxt1 also support dxtn. (3dfx and Intel) */ * cards that support fxt1 also support dxtn. (3dfx and Intel) */
if ((destformat == GR_TEXFMT_ALPHA_INTENSITY_88) || if ((destformat == GFX_TEXFMT_ALPHA_INTENSITY_88) ||
(destformat == GR_TEXFMT_ARGB_8888) || (destformat == GFX_TEXFMT_ARGB_8888) ||
(destformat == GR_TEXFMT_ALPHA_8)) { (destformat == GFX_TEXFMT_ALPHA_8)) {
compressionType = S3TC_COMPRESSION; compressionType = S3TC_COMPRESSION;
} }
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
@ -331,11 +322,11 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
/* /*
* texture (re)conversions * texture (re)conversions
*/ */
if (destformat == GR_TEXFMT_ARGB_8888) { if (destformat == GFX_TEXFMT_ARGB_8888) {
if (srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GR_TEXFMT_ARGB_4444; if (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GFX_TEXFMT_ARGB_4444;
if (srcformat != GR_TEXFMT_ARGB_8888) { if (srcformat != GFX_TEXFMT_ARGB_8888) {
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GR_TEXFMT_ARGB_8888, srcformat)) { if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GFX_TEXFMT_ARGB_8888, srcformat)) {
DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat); DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat);
return 0; return 0;
} }
@ -346,7 +337,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
break; break;
#if !_16BPP_HACK #if !_16BPP_HACK
case GR_TEXFMT_ARGB_4444: case GFX_TEXFMT_ARGB_4444:
int scale_shift = 0; int scale_shift = 0;
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
@ -374,25 +365,25 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
} }
break; break;
case LQ2X_ENHANCEMENT: case LQ2X_ENHANCEMENT:
if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) {
lq2x_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight); lq2x_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight);
scale_shift = 1; scale_shift = 1;
} }
break; break;
case LQ2XS_ENHANCEMENT: case LQ2XS_ENHANCEMENT:
if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) {
lq2xS_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight); lq2xS_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight);
scale_shift = 1; scale_shift = 1;
} }
break; break;
case X2SAI_ENHANCEMENT: case X2SAI_ENHANCEMENT:
if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) {
Super2xSaI_4444((uint16*)texture, (uint16*)tmptex, srcwidth, srcheight, srcwidth); Super2xSaI_4444((uint16*)texture, (uint16*)tmptex, srcwidth, srcheight, srcwidth);
scale_shift = 1; scale_shift = 1;
} }
break; break;
case X2_ENHANCEMENT: case X2_ENHANCEMENT:
if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) {
Texture2x_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight); Texture2x_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight);
scale_shift = 1; scale_shift = 1;
} }
@ -407,18 +398,19 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
SmoothFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SMOOTH_FILTER_MASK)); SmoothFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SMOOTH_FILTER_MASK));
texture = tmptex; texture = tmptex;
} else if (_options & SHARP_FILTER_MASK) { }
else if (_options & SHARP_FILTER_MASK) {
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
SharpFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SHARP_FILTER_MASK)); SharpFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SHARP_FILTER_MASK));
texture = tmptex; texture = tmptex;
} }
break; break;
case GR_TEXFMT_ARGB_1555: case GFX_TEXFMT_ARGB_1555:
break; break;
case GR_TEXFMT_RGB_565: case GFX_TEXFMT_RGB_565:
break; break;
case GR_TEXFMT_ALPHA_8: case GFX_TEXFMT_ALPHA_8:
break; break;
#endif /* _16BPP_HACK */ #endif /* _16BPP_HACK */
} }
@ -442,8 +434,8 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
return 1; return 1;
} }
boolean bool
TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info) TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info)
{ {
/* NOTE: Rice CRC32 sometimes return the same value for different textures. /* NOTE: Rice CRC32 sometimes return the same value for different textures.
* As a workaround, Glide64 CRC32 is used for the key for NON-hires * As a workaround, Glide64 CRC32 is used for the key for NON-hires
@ -501,8 +493,8 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i
* NOTE: the pre-converted palette from Glide64 is in RGBA5551 format. * NOTE: the pre-converted palette from Glide64 is in RGBA5551 format.
* A comp comes before RGB comp. * A comp comes before RGB comp.
*/ */
if (palette && info->format == GR_TEXFMT_P_8) { if (palette && info->format == GFX_TEXFMT_P_8) {
DBG_INFO(80, "found GR_TEXFMT_P_8 format. Need conversion!!\n"); DBG_INFO(80, "found GFX_TEXFMT_P_8 format. Need conversion!!\n");
int width = info->width; int width = info->width;
int height = info->height; int height = info->height;
@ -514,31 +506,31 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i
/* use palette and convert to 16bit format */ /* use palette and convert to 16bit format */
_txQuantize->P8_16BPP((uint32*)texture, (uint32*)tmptex, info->width, info->height, (uint32*)palette); _txQuantize->P8_16BPP((uint32*)texture, (uint32*)tmptex, info->width, info->height, (uint32*)palette);
texture = tmptex; texture = tmptex;
format = GR_TEXFMT_ARGB_1555; format = GFX_TEXFMT_ARGB_1555;
#if 1 #if 1
/* XXX: compressed if memory cache compression is ON */ /* XXX: compressed if memory cache compression is ON */
if (_options & COMPRESSION_MASK) { if (_options & COMPRESSION_MASK) {
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GR_TEXFMT_ARGB_8888)) { if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GFX_TEXFMT_ARGB_8888)) {
texture = tmptex; texture = tmptex;
format = GR_TEXFMT_ARGB_8888; format = GFX_TEXFMT_ARGB_8888;
} }
if (format == GR_TEXFMT_ARGB_8888) { if (format == GFX_TEXFMT_ARGB_8888) {
tmptex = (texture == _tex1) ? _tex2 : _tex1; tmptex = (texture == _tex1) ? _tex2 : _tex1;
if (_txQuantize->compress(texture, tmptex, if (_txQuantize->compress(texture, tmptex,
info->width, info->height, GR_TEXFMT_ARGB_1555, info->width, info->height, GFX_TEXFMT_ARGB_1555,
&width, &height, &format, &width, &height, &format,
_options & COMPRESSION_MASK)) { _options & COMPRESSION_MASK)) {
texture = tmptex; texture = tmptex;
} }
else { else {
/*if (!_txQuantize->quantize(texture, tmptex, info->width, info->height, GR_TEXFMT_ARGB_8888, GR_TEXFMT_ARGB_1555)) { /*if (!_txQuantize->quantize(texture, tmptex, info->width, info->height, GFX_TEXFMT_ARGB_8888, GFX_TEXFMT_ARGB_1555)) {
DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", format); DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", format);
return 0; return 0;
}*/ }*/
texture = tmptex; texture = tmptex;
format = GR_TEXFMT_ARGB_1555; format = GFX_TEXFMT_ARGB_1555;
} }
} }
} }
@ -557,7 +549,7 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i
/* XXX: add to hires texture cache!!! */ /* XXX: add to hires texture cache!!! */
_txHiResCache->add(r_crc64, info); _txHiResCache->add(r_crc64, info);
DBG_INFO(80, "GR_TEXFMT_P_8 loaded as gfmt:%x!\n", format); DBG_INFO(80, "GFX_TEXFMT_P_8 loaded as gfmt:%x!\n", format);
} }
return 1; return 1;
@ -580,7 +572,7 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i
return 0; return 0;
} }
uint64 uint64_t
TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{ {
if (_options & (HIRESTEXTURES_MASK | DUMP_TEX)) if (_options & (HIRESTEXTURES_MASK | DUMP_TEX))
@ -590,8 +582,8 @@ TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride,
return 0; return 0;
} }
boolean bool
TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64) TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64)
{ {
if (!_initialized) if (!_initialized)
{ {
@ -605,7 +597,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf
DBG_INFO(80, "hirestex: r_crc64:%08X %08X\n", DBG_INFO(80, "hirestex: r_crc64:%08X %08X\n",
(uint32)(r_crc64 >> 32), (uint32)(r_crc64 & 0xffffffff)); (uint32)(r_crc64 >> 32), (uint32)(r_crc64 & 0xffffffff));
if (!_txQuantize->quantize(src, _tex1, rowStridePixel, height, (gfmt & 0x00ff), GR_TEXFMT_ARGB_8888)) if (!_txQuantize->quantize(src, _tex1, rowStridePixel, height, (gfmt & 0x00ff), GFX_TEXFMT_ARGB_8888))
{ {
return 0; return 0;
} }
@ -657,7 +649,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf
return 0; return 0;
} }
boolean TxFilter::reloadhirestex() bool TxFilter::reloadhirestex()
{ {
DBG_INFO(80, "Reload hires textures from texture pack.\n"); DBG_INFO(80, "Reload hires textures from texture pack.\n");

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXFILTER_H__ #ifndef __TXFILTER_H__
#define __TXFILTER_H__ #define __TXFILTER_H__
@ -35,47 +26,47 @@
class TxFilter class TxFilter
{ {
private: private:
int _numcore; int _numcore;
uint8 *_tex1; uint8 *_tex1;
uint8 *_tex2; uint8 *_tex2;
int _maxwidth; int _maxwidth;
int _maxheight; int _maxheight;
int _maxbpp; int _maxbpp;
int _options; int _options;
int _cacheSize; int _cacheSize;
std::string _ident; std::string _ident;
std::string _path; std::string _path;
TxQuantize *_txQuantize; TxQuantize *_txQuantize;
TxTexCache *_txTexCache; TxTexCache *_txTexCache;
TxHiResCache *_txHiResCache; TxHiResCache *_txHiResCache;
TxUtil *_txUtil; TxUtil *_txUtil;
TxImage *_txImage; TxImage *_txImage;
boolean _initialized; bool _initialized;
void clear(); void clear();
public: public:
~TxFilter(); ~TxFilter();
TxFilter(int maxwidth, TxFilter(int maxwidth,
int maxheight, int maxheight,
int maxbpp, int maxbpp,
int options, int options,
int cachesize, int cachesize,
const char *path, const char *path,
const char *ident, const char *ident,
dispInfoFuncExt callback); dispInfoFuncExt callback);
boolean filter(uint8 *src, bool filter(uint8 *src,
int srcwidth, int srcwidth,
int srcheight, int srcheight,
uint16 srcformat, uint16 srcformat,
uint64 g64crc, /* glide64 crc, 64bit for future use */ uint64_t g64crc, /* glide64 crc, 64bit for future use */
GHQTexInfo *info); GHQTexInfo *info);
boolean hirestex(uint64 g64crc, /* glide64 crc, 64bit for future use */ bool hirestex(uint64_t g64crc, /* glide64 crc, 64bit for future use */
uint64 r_crc64, /* checksum hi:palette low:texture */ uint64_t r_crc64, /* checksum hi:palette low:texture */
uint16 *palette, uint16 *palette,
GHQTexInfo *info); GHQTexInfo *info);
uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);
boolean dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64); bool dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64);
boolean reloadhirestex(); bool reloadhirestex();
}; };
#endif /* __TXFILTER_H__ */ #endif /* __TXFILTER_H__ */

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef WIN32 #ifdef WIN32
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
@ -30,76 +21,76 @@
TxFilter *txFilter = NULL; TxFilter *txFilter = NULL;
#ifdef __cplusplus #ifdef __cplusplus
extern "C"{ extern "C" {
#endif #endif
TAPI boolean TAPIENTRY TAPI bool TAPIENTRY
txfilter_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize, txfilter_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize,
const char *path, const char * ident, const char *path, const char * ident,
dispInfoFuncExt callback) dispInfoFuncExt callback)
{ {
if (txFilter) return 0; if (txFilter) return 0;
txFilter = new TxFilter(maxwidth, maxheight, maxbpp, options, cachesize, txFilter = new TxFilter(maxwidth, maxheight, maxbpp, options, cachesize,
path, ident, callback); path, ident, callback);
return (txFilter ? 1 : 0); return (txFilter ? 1 : 0);
} }
void txfilter_shutdown(void) void txfilter_shutdown(void)
{ {
if (txFilter) delete txFilter; if (txFilter) delete txFilter;
txFilter = NULL; txFilter = NULL;
} }
TAPI boolean TAPIENTRY TAPI bool TAPIENTRY
txfilter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, txfilter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat,
uint64 g64crc, GHQTexInfo *info) uint64_t g64crc, GHQTexInfo *info)
{ {
if (txFilter) if (txFilter)
return txFilter->filter(src, srcwidth, srcheight, srcformat, return txFilter->filter(src, srcwidth, srcheight, srcformat,
g64crc, info); g64crc, info);
return 0; return 0;
} }
TAPI boolean TAPIENTRY TAPI bool TAPIENTRY
txfilter_hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info) txfilter_hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info)
{ {
if (txFilter) if (txFilter)
return txFilter->hirestex(g64crc, r_crc64, palette, info); return txFilter->hirestex(g64crc, r_crc64, palette, info);
return 0; return 0;
} }
TAPI uint64 TAPIENTRY TAPI uint64_t TAPIENTRY
txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{ {
if (txFilter) if (txFilter)
return txFilter->checksum64(src, width, height, size, rowStride, palette); return txFilter->checksum64(src, width, height, size, rowStride, palette);
return 0; return 0;
} }
TAPI boolean TAPIENTRY TAPI bool TAPIENTRY
txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64) txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64)
{ {
if (txFilter) if (txFilter)
return txFilter->dmptx(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64); return txFilter->dmptx(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64);
return 0; return 0;
} }
TAPI boolean TAPIENTRY TAPI bool TAPIENTRY
txfilter_reloadhirestex() txfilter_reloadhirestex()
{ {
if (txFilter) if (txFilter)
return txFilter->reloadhirestex(); return txFilter->reloadhirestex();
return 0; return 0;
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,28 +1,17 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2007 Hiroshi Morii *
* * Copyright (C) 2003 Rice1964 *
* this is free software; you can redistribute it and/or modify * *
* it under the terms of the GNU General Public License as published by * License: *
* the Free Software Foundation; either version 2, or (at your option) * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* any later version. * version 2 of the License, or (at your option) any later version. *
* * *
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* 2007 Gonetz <gonetz(at)ngs.ru>
* Added callback to display hires texture info. */
#ifdef _WIN32 #ifdef _WIN32
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
@ -32,14 +21,14 @@
* (0:disable, 1:enable) */ * (0:disable, 1:enable) */
#define DUMP_CACHE 1 #define DUMP_CACHE 1
/* handle oversized textures by /* handle oversized textures by
* 0: minification * 0: minification
* 1: Glide64 style tiling * 1: Glide64 style tiling
*/ */
#define TEXTURE_TILING 1 #define TEXTURE_TILING 1
/* use power of 2 texture size /* use power of 2 texture size
* (0:disable, 1:enable, 2:3dfx) */ * (0:disable, 1:enable, 2:3dfx) */
#define POW2_TEXTURES 2 #define POW2_TEXTURES 2
#if TEXTURE_TILING #if TEXTURE_TILING
@ -47,13 +36,13 @@
#define POW2_TEXTURES 2 #define POW2_TEXTURES 2
#endif #endif
/* hack to reduce texture footprint to achieve /* hack to reduce texture footprint to achieve
* better performace on midrange gfx cards. * better performace on midrange gfx cards.
* (0:disable, 1:enable) */ * (0:disable, 1:enable) */
#define REDUCE_TEXTURE_FOOTPRINT 0 #define REDUCE_TEXTURE_FOOTPRINT 0
/* use aggressive format assumption for quantization /* use aggressive format assumption for quantization
* (0:disable, 1:enable, 2:extreme) */ * (0:disable, 1:enable, 2:extreme) */
#define AGGRESSIVE_QUANTIZATION 1 #define AGGRESSIVE_QUANTIZATION 1
#include "TxHiResCache.h" #include "TxHiResCache.h"
@ -62,6 +51,7 @@
#include <string> #include <string>
#include <Common/path.h> #include <Common/path.h>
#include <Common/StdString.h> #include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
#ifdef _WIN32 #ifdef _WIN32
#include <io.h> #include <io.h>
#endif #endif
@ -88,7 +78,7 @@ TxHiResCache::~TxHiResCache()
} }
TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, const char *path, const char *ident, dispInfoFuncExt callback) : TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, const char *path, const char *ident, dispInfoFuncExt callback) :
TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback) TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback)
{ {
_txImage = new TxImage(); _txImage = new TxImage();
_txQuantize = new TxQuantize(); _txQuantize = new TxQuantize();
@ -129,14 +119,14 @@ TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback)
if (!_haveCache) TxHiResCache::load(0); if (!_haveCache) TxHiResCache::load(0);
} }
boolean bool
TxHiResCache::empty() TxHiResCache::empty()
{ {
return _cache.empty(); return _cache.empty();
} }
boolean bool
TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */ TxHiResCache::load(bool replace) /* 0 : reload, 1 : replace partial */
{ {
if (!_path.empty() && !_ident.empty()) if (!_path.empty() && !_ident.empty())
{ {
@ -168,7 +158,7 @@ TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */
return 0; return 0;
} }
boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
{ {
#ifdef _WIN32 #ifdef _WIN32
DBG_INFO(80, "-----\n"); DBG_INFO(80, "-----\n");
@ -198,12 +188,6 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
{ {
do do
{ {
if (KBHIT(0x1B))
{
_abortLoad = 1;
if (_callback) (*_callback)("Aborted loading hiresolution texture!\n");
INFO(80, "Error: aborted loading hiresolution texture!\n");
}
if (_abortLoad) break; if (_abortLoad) break;
DBG_INFO(80, "-----\n"); DBG_INFO(80, "-----\n");
@ -221,7 +205,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* Rice hi-res textures: begin /* Rice hi-res textures: begin
*/ */
uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0; uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0;
char *pfname = NULL, fname[MAX_PATH]; char *pfname = NULL, fname[260];
std::string ident; std::string ident;
FILE *fp = NULL; FILE *fp = NULL;
@ -240,7 +224,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* read in Rice's file naming convention */ /* read in Rice's file naming convention */
#define CRCFMTSIZ_LEN 13 #define CRCFMTSIZ_LEN 13
#define PALCRC_LEN 9 #define PALCRC_LEN 9
wcstombs(fname, stdstr(TextureDir.GetNameExtension()).ToUTF16().c_str(), MAX_PATH); wcstombs(fname, stdstr(TextureDir.GetNameExtension()).ToUTF16().c_str(), 260);
/* XXX case sensitivity fiasco! /* XXX case sensitivity fiasco!
* files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci
* and file extensions must be in lower case letters! */ * and file extensions must be in lower case letters! */
@ -294,9 +278,9 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* check if we already have it in hires texture cache */ /* check if we already have it in hires texture cache */
if (!replace) { if (!replace) {
uint64 chksum64 = (uint64)palchksum; uint64_t chksum64 = (uint64_t)palchksum;
chksum64 <<= 32; chksum64 <<= 32;
chksum64 |= (uint64)chksum; chksum64 |= (uint64_t)chksum;
if (TxCache::is_cached(chksum64)) { if (TxCache::is_cached(chksum64)) {
#if !DEBUG #if !DEBUG
INFO(80, "-----\n"); INFO(80, "-----\n");
@ -382,7 +366,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
if (tmptex) { if (tmptex) {
/* check if _rgb.* and _a.* have matching size and format. */ /* check if _rgb.* and _a.* have matching size and format. */
if (!tex || width != tmpwidth || height != tmpheight || if (!tex || width != tmpwidth || height != tmpheight ||
format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) { format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) {
#if !DEBUG #if !DEBUG
INFO(80, "-----\n"); INFO(80, "-----\n");
INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
@ -394,7 +378,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
else if (width != tmpwidth || height != tmpheight) { else if (width != tmpwidth || height != tmpheight) {
INFO(80, "Error: _rgb.* and _a.* have mismatched width or height!\n"); INFO(80, "Error: _rgb.* and _a.* have mismatched width or height!\n");
} }
else if (format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) { else if (format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) {
INFO(80, "Error: _rgb.* or _a.* not in 32bit color!\n"); INFO(80, "Error: _rgb.* or _a.* not in 32bit color!\n");
} }
if (tex) free(tex); if (tex) free(tex);
@ -421,7 +405,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
uint32 texel = ((uint32*)tmptex)[i]; uint32 texel = ((uint32*)tmptex)[i];
uint32 acomp = (((texel >> 16) & 0xff) * 6969 + uint32 acomp = (((texel >> 16) & 0xff) * 6969 +
((texel >> 8) & 0xff) * 23434 + ((texel >> 8) & 0xff) * 23434 +
((texel)& 0xff) * 2365) / 32768; ((texel) & 0xff) * 2365) / 32768;
((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff); ((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff);
#endif #endif
#if 0 #if 0
@ -429,7 +413,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
uint32 texel = ((uint32*)tmptex)[i]; uint32 texel = ((uint32*)tmptex)[i];
uint32 acomp = (((texel >> 16) & 0xff) * 299 + uint32 acomp = (((texel >> 16) & 0xff) * 299 +
((texel >> 8) & 0xff) * 587 + ((texel >> 8) & 0xff) * 587 +
((texel)& 0xff) * 114) / 1000; ((texel) & 0xff) * 114) / 1000;
((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff); ((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff);
#endif #endif
} }
@ -457,58 +441,58 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
* read in _all.png, _all.dds, _allciByRGBA.png, _allciByRGBA.dds * read in _all.png, _all.dds, _allciByRGBA.png, _allciByRGBA.dds
* _ciByRGBA.png, _ciByRGBA.dds, _ci.bmp * _ciByRGBA.png, _ciByRGBA.dds, _ci.bmp
*/ */
if (pfname == strstr(fname, "_all.png") || if (pfname == strstr(fname, "_all.png") ||
pfname == strstr(fname, "_all.dds") || pfname == strstr(fname, "_all.dds") ||
#ifdef _WIN32 #ifdef _WIN32
pfname == strstr(fname, "_allcibyrgba.png") || pfname == strstr(fname, "_allcibyrgba.png") ||
pfname == strstr(fname, "_allcibyrgba.dds") || pfname == strstr(fname, "_allcibyrgba.dds") ||
pfname == strstr(fname, "_cibyrgba.png") || pfname == strstr(fname, "_cibyrgba.png") ||
pfname == strstr(fname, "_cibyrgba.dds") || pfname == strstr(fname, "_cibyrgba.dds") ||
#else #else
pfname == strstr(fname, "_allciByRGBA.png") || pfname == strstr(fname, "_allciByRGBA.png") ||
pfname == strstr(fname, "_allciByRGBA.dds") || pfname == strstr(fname, "_allciByRGBA.dds") ||
pfname == strstr(fname, "_ciByRGBA.png") || pfname == strstr(fname, "_ciByRGBA.png") ||
pfname == strstr(fname, "_ciByRGBA.dds") || pfname == strstr(fname, "_ciByRGBA.dds") ||
#endif #endif
pfname == strstr(fname, "_ci.bmp")) { pfname == strstr(fname, "_ci.bmp")) {
CPath TargetFile(dir_path, fname); CPath TargetFile(dir_path, fname);
if ((fp = fopen(TargetFile, "rb")) != NULL) { if ((fp = fopen(TargetFile, "rb")) != NULL) {
if (strstr(fname, ".png")) tex = _txImage->readPNG(fp, &width, &height, &format); if (strstr(fname, ".png")) tex = _txImage->readPNG(fp, &width, &height, &format);
else if (strstr(fname, ".dds")) tex = _txImage->readDDS(fp, &width, &height, &format); else if (strstr(fname, ".dds")) tex = _txImage->readDDS(fp, &width, &height, &format);
else tex = _txImage->readBMP(fp, &width, &height, &format); else tex = _txImage->readBMP(fp, &width, &height, &format);
fclose(fp); fclose(fp);
} }
/* XXX: auto-adjustment of dxt dds textures unsupported for now */ /* XXX: auto-adjustment of dxt dds textures unsupported for now */
if (tex && strstr(fname, ".dds")) { if (tex && strstr(fname, ".dds")) {
const float aspectratio = (width > height) ? (float)width / (float)height : (float)height / (float)width; const float aspectratio = (width > height) ? (float)width / (float)height : (float)height / (float)width;
if (!(aspectratio == 1.0 || if (!(aspectratio == 1.0 ||
aspectratio == 2.0 || aspectratio == 2.0 ||
aspectratio == 4.0 || aspectratio == 4.0 ||
aspectratio == 8.0)) { aspectratio == 8.0)) {
free(tex); free(tex);
tex = NULL; tex = NULL;
#if !DEBUG #if !DEBUG
INFO(80, "-----\n"); INFO(80, "-----\n");
INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, "Error: W:H aspect ratio range not 8:1 - 1:8!\n"); INFO(80, "Error: W:H aspect ratio range not 8:1 - 1:8!\n");
continue; continue;
} }
if (width != _txReSample->nextPow2(width) || if (width != _txReSample->nextPow2(width) ||
height != _txReSample->nextPow2(height)) { height != _txReSample->nextPow2(height)) {
free(tex); free(tex);
tex = NULL; tex = NULL;
#if !DEBUG #if !DEBUG
INFO(80, "-----\n"); INFO(80, "-----\n");
INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, "Error: not power of 2 size!\n"); INFO(80, "Error: not power of 2 size!\n");
continue; continue;
} }
} }
} }
/* if we do not have a texture at this point we are screwed */ /* if we do not have a texture at this point we are screwed */
if (!tex) { if (!tex) {
@ -523,11 +507,11 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
DBG_INFO(80, "read in as %d x %d gfmt:%x\n", tmpwidth, tmpheight, tmpformat); DBG_INFO(80, "read in as %d x %d gfmt:%x\n", tmpwidth, tmpheight, tmpformat);
/* check if size and format are OK */ /* check if size and format are OK */
if (!(format == GR_TEXFMT_ARGB_8888 || if (!(format == GFX_TEXFMT_ARGB_8888 ||
format == GR_TEXFMT_P_8 || format == GFX_TEXFMT_P_8 ||
format == GR_TEXFMT_ARGB_CMP_DXT1 || format == GFX_TEXFMT_ARGB_CMP_DXT1 ||
format == GR_TEXFMT_ARGB_CMP_DXT3 || format == GFX_TEXFMT_ARGB_CMP_DXT3 ||
format == GR_TEXFMT_ARGB_CMP_DXT5) || format == GFX_TEXFMT_ARGB_CMP_DXT5) ||
(width * height) < 4) { /* TxQuantize requirement: width * height must be 4 or larger. */ (width * height) < 4) { /* TxQuantize requirement: width * height must be 4 or larger. */
free(tex); free(tex);
tex = NULL; tex = NULL;
@ -541,11 +525,11 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
} }
/* analyze and determine best format to quantize */ /* analyze and determine best format to quantize */
if (format == GR_TEXFMT_ARGB_8888) { if (format == GFX_TEXFMT_ARGB_8888) {
int i; int i;
int alphabits = 0; int alphabits = 0;
int fullalpha = 0; int fullalpha = 0;
boolean intensity = 1; bool intensity = 1;
if (!(_options & LET_TEXARTISTS_FLY)) { if (!(_options & LET_TEXARTISTS_FLY)) {
/* HACK ALERT! */ /* HACK ALERT! */
@ -634,7 +618,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
if (intensity) { if (intensity) {
int rcomp = (texel >> 16) & 0xff; int rcomp = (texel >> 16) & 0xff;
int gcomp = (texel >> 8) & 0xff; int gcomp = (texel >> 8) & 0xff;
int bcomp = (texel)& 0xff; int bcomp = (texel) & 0xff;
#if AGGRESSIVE_QUANTIZATION #if AGGRESSIVE_QUANTIZATION
if (abs(rcomp - gcomp) > 8 || abs(rcomp - bcomp) > 8 || abs(gcomp - bcomp) > 8) intensity = 0; if (abs(rcomp - gcomp) > 8 || abs(rcomp - bcomp) > 8 || abs(gcomp - bcomp) > 8) intensity = 0;
#else #else
@ -649,33 +633,33 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#if !REDUCE_TEXTURE_FOOTPRINT #if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & (FORCE16BPP_HIRESTEX | COMPRESSION_MASK)) { if (_maxbpp < 32 || _options & (FORCE16BPP_HIRESTEX | COMPRESSION_MASK)) {
#endif #endif
if (alphabits == 0) destformat = GR_TEXFMT_RGB_565; if (alphabits == 0) destformat = GFX_TEXFMT_RGB_565;
else if (alphabits == 1) destformat = GR_TEXFMT_ARGB_1555; else if (alphabits == 1) destformat = GFX_TEXFMT_ARGB_1555;
else destformat = GR_TEXFMT_ARGB_8888; else destformat = GFX_TEXFMT_ARGB_8888;
#if !REDUCE_TEXTURE_FOOTPRINT #if !REDUCE_TEXTURE_FOOTPRINT
} }
else { else {
destformat = GR_TEXFMT_ARGB_8888; destformat = GFX_TEXFMT_ARGB_8888;
} }
#endif #endif
if (fmt == 4 && alphabits == 0) { if (fmt == 4 && alphabits == 0) {
destformat = GR_TEXFMT_ARGB_8888; destformat = GFX_TEXFMT_ARGB_8888;
/* Rice I format; I = (R + G + B) / 3 */ /* Rice I format; I = (R + G + B) / 3 */
for (i = 0; i < height * width; i++) { for (i = 0; i < height * width; i++) {
uint32 texel = ((uint32*)tex)[i]; uint32 texel = ((uint32*)tex)[i];
uint32 icomp = (((texel >> 16) & 0xff) + uint32 icomp = (((texel >> 16) & 0xff) +
((texel >> 8) & 0xff) + ((texel >> 8) & 0xff) +
((texel)& 0xff)) / 3; ((texel) & 0xff)) / 3;
((uint32*)tex)[i] = (icomp << 24) | (texel & 0x00ffffff); ((uint32*)tex)[i] = (icomp << 24) | (texel & 0x00ffffff);
} }
} }
if (intensity) { if (intensity) {
if (alphabits == 0) { if (alphabits == 0) {
if (fmt == 4) destformat = GR_TEXFMT_ALPHA_8; if (fmt == 4) destformat = GFX_TEXFMT_ALPHA_8;
else destformat = GR_TEXFMT_INTENSITY_8; else destformat = GFX_TEXFMT_INTENSITY_8;
} }
else { else {
destformat = GR_TEXFMT_ALPHA_INTENSITY_88; destformat = GFX_TEXFMT_ALPHA_INTENSITY_88;
} }
} }
@ -684,8 +668,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* /*
* Rice hi-res textures: end */ * Rice hi-res textures: end */
/* XXX: only ARGB8888 for now. comeback to this later... */ /* XXX: only ARGB8888 for now. comeback to this later... */
if (format == GR_TEXFMT_ARGB_8888) { if (format == GFX_TEXFMT_ARGB_8888) {
#if TEXTURE_TILING #if TEXTURE_TILING
/* Glide64 style texture tiling */ /* Glide64 style texture tiling */
@ -695,136 +679,136 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* NOTE: we skip this for palette textures that need minification /* NOTE: we skip this for palette textures that need minification
* becasue it will look ugly. */ * becasue it will look ugly. */
/* minification */ /* minification */
{ {
int ratio = 1; int ratio = 1;
/* minification to enable glide64 style texture tiling */ /* minification to enable glide64 style texture tiling */
/* determine the minification ratio to tile the texture into 256x256 size */ /* determine the minification ratio to tile the texture into 256x256 size */
if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) {
DBG_INFO(80, "determine minification ratio to tile\n"); DBG_INFO(80, "determine minification ratio to tile\n");
tmpwidth = width; tmpwidth = width;
tmpheight = height; tmpheight = height;
if (height > 256) { if (height > 256) {
ratio = ((height - 1) >> 8) + 1; ratio = ((height - 1) >> 8) + 1;
tmpwidth = width / ratio; tmpwidth = width / ratio;
tmpheight = height / ratio; tmpheight = height / ratio;
DBG_INFO(80, "height > 256, minification ratio:%d %d x %d -> %d x %d\n", DBG_INFO(80, "height > 256, minification ratio:%d %d x %d -> %d x %d\n",
ratio, width, height, tmpwidth, tmpheight); ratio, width, height, tmpwidth, tmpheight);
} }
if (tmpwidth > 256 && (((tmpwidth - 1) >> 8) + 1) * tmpheight > 256) { if (tmpwidth > 256 && (((tmpwidth - 1) >> 8) + 1) * tmpheight > 256) {
ratio *= ((((((tmpwidth - 1) >> 8) + 1) * tmpheight) - 1) >> 8) + 1; ratio *= ((((((tmpwidth - 1) >> 8) + 1) * tmpheight) - 1) >> 8) + 1;
DBG_INFO(80, "width > 256, minification ratio:%d %d x %d -> %d x %d\n", DBG_INFO(80, "width > 256, minification ratio:%d %d x %d -> %d x %d\n",
ratio, width, height, width / ratio, height / ratio); ratio, width, height, width / ratio, height / ratio);
} }
} }
else { else {
/* normal minification to fit max texture size */ /* normal minification to fit max texture size */
if (width > _maxwidth || height > _maxheight) { if (width > _maxwidth || height > _maxheight) {
DBG_INFO(80, "determine minification ratio to fit max texture size\n"); DBG_INFO(80, "determine minification ratio to fit max texture size\n");
tmpwidth = width; tmpwidth = width;
tmpheight = height; tmpheight = height;
while (tmpwidth > _maxwidth) { while (tmpwidth > _maxwidth) {
tmpheight >>= 1; tmpheight >>= 1;
tmpwidth >>= 1; tmpwidth >>= 1;
ratio <<= 1; ratio <<= 1;
} }
while (tmpheight > _maxheight) { while (tmpheight > _maxheight) {
tmpheight >>= 1; tmpheight >>= 1;
tmpwidth >>= 1; tmpwidth >>= 1;
ratio <<= 1; ratio <<= 1;
} }
DBG_INFO(80, "minification ratio:%d %d x %d -> %d x %d\n", DBG_INFO(80, "minification ratio:%d %d x %d -> %d x %d\n",
ratio, width, height, tmpwidth, tmpheight); ratio, width, height, tmpwidth, tmpheight);
} }
} }
if (ratio > 1) { if (ratio > 1) {
if (!_txReSample->minify(&tex, &width, &height, ratio)) { if (!_txReSample->minify(&tex, &width, &height, ratio)) {
free(tex); free(tex);
tex = NULL; tex = NULL;
DBG_INFO(80, "Error: minification failed!\n"); DBG_INFO(80, "Error: minification failed!\n");
continue; continue;
} }
} }
} }
/* tiling */ /* tiling */
if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) {
boolean usetile = 0; bool usetile = 0;
/* to tile or not to tile, that is the question */ /* to tile or not to tile, that is the question */
if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) { if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) {
if (width > _maxwidth) usetile = 1; if (width > _maxwidth) usetile = 1;
else { else {
/* tile if the tiled texture memory footprint is smaller */ /* tile if the tiled texture memory footprint is smaller */
int tilewidth = 256; int tilewidth = 256;
int tileheight = _txReSample->nextPow2((((width - 1) >> 8) + 1) * height); int tileheight = _txReSample->nextPow2((((width - 1) >> 8) + 1) * height);
tmpwidth = width; tmpwidth = width;
tmpheight = height; tmpheight = height;
/* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */
if (tilewidth > (tileheight << 3)) tileheight = tilewidth >> 3; if (tilewidth > (tileheight << 3)) tileheight = tilewidth >> 3;
/* HACKALERT: see TxReSample::pow2(); */ /* HACKALERT: see TxReSample::pow2(); */
if (tmpwidth > 64) tmpwidth -= 4; if (tmpwidth > 64) tmpwidth -= 4;
else if (tmpwidth > 16) tmpwidth -= 2; else if (tmpwidth > 16) tmpwidth -= 2;
else if (tmpwidth > 4) tmpwidth -= 1; else if (tmpwidth > 4) tmpwidth -= 1;
if (tmpheight > 64) tmpheight -= 4; if (tmpheight > 64) tmpheight -= 4;
else if (tmpheight > 16) tmpheight -= 2; else if (tmpheight > 16) tmpheight -= 2;
else if (tmpheight > 4) tmpheight -= 1; else if (tmpheight > 4) tmpheight -= 1;
tmpwidth = _txReSample->nextPow2(tmpwidth); tmpwidth = _txReSample->nextPow2(tmpwidth);
tmpheight = _txReSample->nextPow2(tmpheight); tmpheight = _txReSample->nextPow2(tmpheight);
/* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */
if (tmpwidth > tmpheight) { if (tmpwidth > tmpheight) {
if (tmpwidth > (tmpheight << 3)) tmpheight = tmpwidth >> 3; if (tmpwidth > (tmpheight << 3)) tmpheight = tmpwidth >> 3;
} }
else { else {
if (tmpheight > (tmpwidth << 3)) tmpwidth = tmpheight >> 3; if (tmpheight > (tmpwidth << 3)) tmpwidth = tmpheight >> 3;
} }
usetile = (tilewidth * tileheight < tmpwidth * tmpheight); usetile = (tilewidth * tileheight < tmpwidth * tmpheight);
} }
} }
/* tile it! do the actual tiling into 256x256 size */ /* tile it! do the actual tiling into 256x256 size */
if (usetile) { if (usetile) {
DBG_INFO(80, "Glide64 style texture tiling\n"); DBG_INFO(80, "Glide64 style texture tiling\n");
int x, y, z, ratio, offset; int x, y, z, ratio, offset;
offset = 0; offset = 0;
ratio = ((width - 1) >> 8) + 1; ratio = ((width - 1) >> 8) + 1;
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(256, height * ratio, format)); tmptex = (uint8 *)malloc(_txUtil->sizeofTx(256, height * ratio, format));
if (tmptex) { if (tmptex) {
for (x = 0; x < ratio; x++) { for (x = 0; x < ratio; x++) {
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
if (x < ratio - 1) { if (x < ratio - 1) {
memcpy(&tmptex[offset << 2], &tex[(x * 256 + y * width) << 2], 256 << 2); memcpy(&tmptex[offset << 2], &tex[(x * 256 + y * width) << 2], 256 << 2);
} }
else { else {
for (z = 0; z < width - 256 * (ratio - 1); z++) { for (z = 0; z < width - 256 * (ratio - 1); z++) {
((uint32*)tmptex)[offset + z] = ((uint32*)tex)[x * 256 + y * width + z]; ((uint32*)tmptex)[offset + z] = ((uint32*)tex)[x * 256 + y * width + z];
} }
for (; z < 256; z++) { for (; z < 256; z++) {
((uint32*)tmptex)[offset + z] = ((uint32*)tmptex)[offset + z - 1]; ((uint32*)tmptex)[offset + z] = ((uint32*)tmptex)[offset + z - 1];
} }
} }
offset += 256; offset += 256;
} }
} }
free(tex); free(tex);
tex = tmptex; tex = tmptex;
untiled_width = width; untiled_width = width;
untiled_height = height; untiled_height = height;
width = 256; width = 256;
height *= ratio; height *= ratio;
DBG_INFO(80, "Tiled: %d x %d -> %d x %d\n", untiled_width, untiled_height, width, height); DBG_INFO(80, "Tiled: %d x %d -> %d x %d\n", untiled_width, untiled_height, width, height);
} }
} }
} }
#else /* TEXTURE_TILING */ #else /* TEXTURE_TILING */
@ -833,7 +817,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
int ratio = 1; int ratio = 1;
if (width / _maxwidth > height / _maxheight) { if (width / _maxwidth > height / _maxheight) {
ratio = (int)ceil((double)width / _maxwidth); ratio = (int)ceil((double)width / _maxwidth);
} else { }
else {
ratio = (int)ceil((double)height / _maxheight); ratio = (int)ceil((double)height / _maxheight);
} }
if (!_txReSample->minify(&tex, &width, &height, ratio)) { if (!_txReSample->minify(&tex, &width, &height, ratio)) {
@ -858,7 +843,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
* *
* NOTE: texture size must be checked before expanding to pow2 size. * NOTE: texture size must be checked before expanding to pow2 size.
*/ */
) { ) {
int dataSize = 0; int dataSize = 0;
int compressionType = _options & COMPRESSION_MASK; int compressionType = _options & COMPRESSION_MASK;
@ -880,40 +865,40 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
switch (_options & COMPRESSION_MASK) { switch (_options & COMPRESSION_MASK) {
case S3TC_COMPRESSION: case S3TC_COMPRESSION:
switch (destformat) { switch (destformat) {
case GR_TEXFMT_ARGB_8888: case GFX_TEXFMT_ARGB_8888:
#if GLIDE64_DXTN #if GLIDE64_DXTN
case GR_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */ case GFX_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */
#endif #endif
case GR_TEXFMT_ALPHA_INTENSITY_88: case GFX_TEXFMT_ALPHA_INTENSITY_88:
dataSize = width * height; dataSize = width * height;
break; break;
#if !GLIDE64_DXTN #if !GLIDE64_DXTN
case GR_TEXFMT_ARGB_1555: case GFX_TEXFMT_ARGB_1555:
#endif #endif
case GR_TEXFMT_RGB_565: case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_INTENSITY_8: case GFX_TEXFMT_INTENSITY_8:
dataSize = (width * height) >> 1; dataSize = (width * height) >> 1;
break; break;
case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
; ;
} }
break; break;
case FXT1_COMPRESSION: case FXT1_COMPRESSION:
switch (destformat) { switch (destformat) {
case GR_TEXFMT_ARGB_1555: case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_RGB_565: case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_INTENSITY_8: case GFX_TEXFMT_INTENSITY_8:
dataSize = (width * height) >> 1; dataSize = (width * height) >> 1;
break; break;
/* XXX: textures that use 8bit alpha channel look bad with the current /* XXX: textures that use 8bit alpha channel look bad with the current
* fxt1 library, so we substitute it with dxtn for now. afaik all gfx * fxt1 library, so we substitute it with dxtn for now. afaik all gfx
* cards that support fxt1 also support dxtn. (3dfx and Intel) */ * cards that support fxt1 also support dxtn. (3dfx and Intel) */
case GR_TEXFMT_ALPHA_INTENSITY_88: case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ARGB_8888: case GFX_TEXFMT_ARGB_8888:
compressionType = S3TC_COMPRESSION; compressionType = S3TC_COMPRESSION;
dataSize = width * height; dataSize = width * height;
break; break;
case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
; ;
} }
} }
@ -922,8 +907,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#if 0 /* TEST: dither before compression for better results with gradients */ #if 0 /* TEST: dither before compression for better results with gradients */
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat));
if (tmptex) { if (tmptex) {
if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0)) if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0))
_txQuantize->quantize(tmptex, tex, width, height, destformat, GR_TEXFMT_ARGB_8888, 0); _txQuantize->quantize(tmptex, tex, width, height, destformat, GFX_TEXFMT_ARGB_8888, 0);
free(tmptex); free(tmptex);
} }
#endif #endif
@ -963,50 +948,50 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
} }
/* quantize */ /* quantize */
{ {
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat));
if (tmptex) { if (tmptex) {
switch (destformat) { switch (destformat) {
case GR_TEXFMT_ARGB_8888: case GFX_TEXFMT_ARGB_8888:
case GR_TEXFMT_ARGB_4444: case GFX_TEXFMT_ARGB_4444:
#if !REDUCE_TEXTURE_FOOTPRINT #if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif #endif
destformat = GR_TEXFMT_ARGB_4444; destformat = GFX_TEXFMT_ARGB_4444;
break; break;
case GR_TEXFMT_ARGB_1555: case GFX_TEXFMT_ARGB_1555:
#if !REDUCE_TEXTURE_FOOTPRINT #if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif #endif
destformat = GR_TEXFMT_ARGB_1555; destformat = GFX_TEXFMT_ARGB_1555;
break; break;
case GR_TEXFMT_RGB_565: case GFX_TEXFMT_RGB_565:
#if !REDUCE_TEXTURE_FOOTPRINT #if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif #endif
destformat = GR_TEXFMT_RGB_565; destformat = GFX_TEXFMT_RGB_565;
break; break;
case GR_TEXFMT_ALPHA_INTENSITY_88: case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ALPHA_INTENSITY_44: case GFX_TEXFMT_ALPHA_INTENSITY_44:
#if !REDUCE_TEXTURE_FOOTPRINT #if !REDUCE_TEXTURE_FOOTPRINT
destformat = GR_TEXFMT_ALPHA_INTENSITY_88; destformat = GFX_TEXFMT_ALPHA_INTENSITY_88;
#else #else
destformat = GR_TEXFMT_ALPHA_INTENSITY_44; destformat = GFX_TEXFMT_ALPHA_INTENSITY_44;
#endif #endif
break; break;
case GR_TEXFMT_ALPHA_8: case GFX_TEXFMT_ALPHA_8:
destformat = GR_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */ destformat = GFX_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */
break; break;
case GR_TEXFMT_INTENSITY_8: case GFX_TEXFMT_INTENSITY_8:
destformat = GR_TEXFMT_INTENSITY_8; destformat = GFX_TEXFMT_INTENSITY_8;
} }
if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0)) { if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0)) {
format = destformat; format = destformat;
free(tex); free(tex);
tex = tmptex; tex = tmptex;
} }
} }
} }
} }
/* last minute validations */ /* last minute validations */
@ -1029,9 +1014,9 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* load it into hires texture cache. */ /* load it into hires texture cache. */
{ {
uint64 chksum64 = (uint64)palchksum; uint64_t chksum64 = (uint64_t)palchksum;
chksum64 <<= 32; chksum64 <<= 32;
chksum64 |= (uint64)chksum; chksum64 |= (uint64_t)chksum;
GHQTexInfo tmpInfo; GHQTexInfo tmpInfo;
memset(&tmpInfo, 0, sizeof(GHQTexInfo)); memset(&tmpInfo, 0, sizeof(GHQTexInfo));
@ -1047,7 +1032,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#if TEXTURE_TILING #if TEXTURE_TILING
/* Glide64 style texture tiling. */ /* Glide64 style texture tiling. */
if (untiled_width && untiled_height) { if (untiled_width && untiled_height)
{
tmpInfo.tiles = ((untiled_width - 1) >> 8) + 1; tmpInfo.tiles = ((untiled_width - 1) >> 8) + 1;
tmpInfo.untiled_width = untiled_width; tmpInfo.untiled_width = untiled_width;
tmpInfo.untiled_height = untiled_height; tmpInfo.untiled_height = untiled_height;
@ -1055,17 +1041,20 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#endif #endif
/* remove redundant in cache */ /* remove redundant in cache */
if (replace && TxCache::del(chksum64)) { if (replace && TxCache::del(chksum64))
{
DBG_INFO(80, "removed duplicate old cache.\n"); DBG_INFO(80, "removed duplicate old cache.\n");
} }
/* add to cache */ /* add to cache */
if (TxCache::add(chksum64, &tmpInfo)) { if (TxCache::add(chksum64, &tmpInfo))
{
/* Callback to display hires texture info. /* Callback to display hires texture info.
* Gonetz <gonetz(at)ngs.ru> */ * Gonetz <gonetz(at)ngs.ru> */
if (_callback) { if (_callback)
wchar_t tmpbuf[MAX_PATH]; {
mbstowcs(tmpbuf, fname, MAX_PATH); wchar_t tmpbuf[260];
mbstowcs(tmpbuf, fname, 260);
(*_callback)("[%d] total mem:%.2fmb - %ls\n", _cache.size(), (float)_totalSize / 1000000, tmpbuf); (*_callback)("[%d] total mem:%.2fmb - %ls\n", _cache.size(), (float)_totalSize / 1000000, tmpbuf);
} }
DBG_INFO(80, "texture loaded!\n"); DBG_INFO(80, "texture loaded!\n");
@ -1076,4 +1065,4 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
} }
#endif #endif
return 1; return 1;
} }

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXHIRESCACHE_H__ #ifndef __TXHIRESCACHE_H__
#define __TXHIRESCACHE_H__ #define __TXHIRESCACHE_H__
@ -41,19 +32,19 @@ private:
int _maxwidth; int _maxwidth;
int _maxheight; int _maxheight;
int _maxbpp; int _maxbpp;
boolean _haveCache; bool _haveCache;
boolean _abortLoad; bool _abortLoad;
TxImage *_txImage; TxImage *_txImage;
TxQuantize *_txQuantize; TxQuantize *_txQuantize;
TxReSample *_txReSample; TxReSample *_txReSample;
boolean loadHiResTextures(const char * dir_path, boolean replace); bool loadHiResTextures(const char * dir_path, bool replace);
public: public:
~TxHiResCache(); ~TxHiResCache();
TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options,
const char *path, const char *ident, const char *path, const char *ident,
dispInfoFuncExt callback); dispInfoFuncExt callback);
boolean empty(); bool empty();
boolean load(boolean replace); bool load(bool replace);
}; };
#endif /* __TXHIRESCACHE_H__ */ #endif /* __TXHIRESCACHE_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXIMAGE_H__ #ifndef __TXIMAGE_H__
#define __TXIMAGE_H__ #define __TXIMAGE_H__
@ -28,32 +19,27 @@
#include <png/png.h> #include <png/png.h>
#include "TxInternal.h" #include "TxInternal.h"
#ifndef WIN32
typedef struct tagBITMAPFILEHEADER { typedef struct tagBITMAPFILEHEADER {
unsigned short bfType; unsigned short bfType;
unsigned long bfSize; unsigned long bfSize;
unsigned short bfReserved1; unsigned short bfReserved1;
unsigned short bfReserved2; unsigned short bfReserved2;
unsigned long bfOffBits; unsigned long bfOffBits;
} BITMAPFILEHEADER; } BITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER { typedef struct tagBITMAPINFOHEADER {
unsigned long biSize; unsigned long biSize;
long biWidth; long biWidth;
long biHeight; long biHeight;
unsigned short biPlanes; unsigned short biPlanes;
unsigned short biBitCount; unsigned short biBitCount;
unsigned long biCompression; unsigned long biCompression;
unsigned long biSizeImage; unsigned long biSizeImage;
long biXPelsPerMeter; long biXPelsPerMeter;
long biYPelsPerMeter; long biYPelsPerMeter;
unsigned long biClrUsed; unsigned long biClrUsed;
unsigned long biClrImportant; unsigned long biClrImportant;
} BITMAPINFOHEADER; } BITMAPINFOHEADER;
#else
typedef struct tagBITMAPFILEHEADER BITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER;
#endif
#define DDSD_CAPS 0x00000001 #define DDSD_CAPS 0x00000001
#define DDSD_HEIGHT 0x00000002 #define DDSD_HEIGHT 0x00000002
@ -73,44 +59,44 @@ typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER;
#define DDSCAPS_MIPMAP 0x00400000 #define DDSCAPS_MIPMAP 0x00400000
typedef struct tagDDSPIXELFORMAT { typedef struct tagDDSPIXELFORMAT {
unsigned long dwSize; unsigned long dwSize;
unsigned long dwFlags; unsigned long dwFlags;
unsigned long dwFourCC; unsigned long dwFourCC;
unsigned long dwRGBBitCount; unsigned long dwRGBBitCount;
unsigned long dwRBitMask; unsigned long dwRBitMask;
unsigned long dwGBitMask; unsigned long dwGBitMask;
unsigned long dwBBitMask; unsigned long dwBBitMask;
unsigned long dwRGBAlphaBitMask; unsigned long dwRGBAlphaBitMask;
} DDSPIXELFORMAT; } DDSPIXELFORMAT;
typedef struct tagDDSFILEHEADER { typedef struct tagDDSFILEHEADER {
unsigned long dwMagic; unsigned long dwMagic;
unsigned long dwSize; unsigned long dwSize;
unsigned long dwFlags; unsigned long dwFlags;
unsigned long dwHeight; unsigned long dwHeight;
unsigned long dwWidth; unsigned long dwWidth;
unsigned long dwLinearSize; unsigned long dwLinearSize;
unsigned long dwDepth; unsigned long dwDepth;
unsigned long dwMipMapCount; unsigned long dwMipMapCount;
unsigned long dwReserved1[11]; unsigned long dwReserved1[11];
DDSPIXELFORMAT ddpf; DDSPIXELFORMAT ddpf;
unsigned long dwCaps1; unsigned long dwCaps1;
unsigned long dwCaps2; unsigned long dwCaps2;
} DDSFILEHEADER; } DDSFILEHEADER;
class TxImage class TxImage
{ {
private: private:
boolean getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr); bool getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr);
boolean getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr); bool getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr);
boolean getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr); bool getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr);
public: public:
TxImage() {} TxImage() {}
~TxImage() {} ~TxImage() {}
uint8* readPNG(FILE* fp, int* width, int* height, uint16* format); uint8* readPNG(FILE* fp, int* width, int* height, uint16* format);
boolean writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette); bool writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette);
uint8* readBMP(FILE* fp, int* width, int* height, uint16* format); uint8* readBMP(FILE* fp, int* width, int* height, uint16* format);
uint8* readDDS(FILE* fp, int* width, int* height, uint16* format); uint8* readDDS(FILE* fp, int* width, int* height, uint16* format);
}; };
#endif /* __TXIMAGE_H__ */ #endif /* __TXIMAGE_H__ */

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __INTERNAL_H__ #ifndef __INTERNAL_H__
#define __INTERNAL_H__ #define __INTERNAL_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXQUANTIZE_H__ #ifndef __TXQUANTIZE_H__
#define __TXQUANTIZE_H__ #define __TXQUANTIZE_H__
@ -34,65 +25,64 @@
class TxQuantize class TxQuantize
{ {
private: private:
TxUtil *_txUtil; TxUtil *_txUtil;
int _numcore; int _numcore;
fxtCompressTexFuncExt _tx_compress_fxt1; fxtCompressTexFuncExt _tx_compress_fxt1;
dxtCompressTexFuncExt _tx_compress_dxtn; dxtCompressTexFuncExt _tx_compress_dxtn;
/* fast optimized... well, sort of. */ /* fast optimized... well, sort of. */
void ARGB1555_ARGB8888(uint32* src, uint32* dst, int width, int height); void ARGB1555_ARGB8888(uint32* src, uint32* dst, int width, int height);
void ARGB4444_ARGB8888(uint32* src, uint32* dst, int width, int height); void ARGB4444_ARGB8888(uint32* src, uint32* dst, int width, int height);
void RGB565_ARGB8888(uint32* src, uint32* dst, int width, int height); void RGB565_ARGB8888(uint32* src, uint32* dst, int width, int height);
void A8_ARGB8888(uint32* src, uint32* dst, int width, int height); void A8_ARGB8888(uint32* src, uint32* dst, int width, int height);
void AI44_ARGB8888(uint32* src, uint32* dst, int width, int height); void AI44_ARGB8888(uint32* src, uint32* dst, int width, int height);
void AI88_ARGB8888(uint32* src, uint32* dst, int width, int height); void AI88_ARGB8888(uint32* src, uint32* dst, int width, int height);
void ARGB8888_ARGB1555(uint32* src, uint32* dst, int width, int height); void ARGB8888_ARGB1555(uint32* src, uint32* dst, int width, int height);
void ARGB8888_ARGB4444(uint32* src, uint32* dst, int width, int height); void ARGB8888_ARGB4444(uint32* src, uint32* dst, int width, int height);
void ARGB8888_RGB565(uint32* src, uint32* dst, int width, int height); void ARGB8888_RGB565(uint32* src, uint32* dst, int width, int height);
void ARGB8888_A8(uint32* src, uint32* dst, int width, int height); void ARGB8888_A8(uint32* src, uint32* dst, int width, int height);
void ARGB8888_AI44(uint32* src, uint32* dst, int width, int height); void ARGB8888_AI44(uint32* src, uint32* dst, int width, int height);
void ARGB8888_AI88(uint32* src, uint32* dst, int width, int height); void ARGB8888_AI88(uint32* src, uint32* dst, int width, int height);
/* quality */ /* quality */
void ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height); void ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height);
void ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height); void ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height);
void ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height); void ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height);
void ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height); void ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height);
void ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height); void ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height);
void ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height); void ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height);
/* compressors */ /* compressors */
boolean FXT1(uint8 *src, uint8 *dest, bool FXT1(uint8 *src, uint8 *dest,
int srcwidth, int srcheight, uint16 srcformat, int srcwidth, int srcheight, uint16 srcformat,
int *destwidth, int *destheight, uint16 *destformat); int *destwidth, int *destheight, uint16 *destformat);
boolean DXTn(uint8 *src, uint8 *dest, bool DXTn(uint8 *src, uint8 *dest,
int srcwidth, int srcheight, uint16 srcformat, int srcwidth, int srcheight, uint16 srcformat,
int *destwidth, int *destheight, uint16 *destformat); int *destwidth, int *destheight, uint16 *destformat);
public: public:
TxQuantize(); TxQuantize();
~TxQuantize(); ~TxQuantize();
/* others */ /* others */
void P8_16BPP(uint32* src, uint32* dst, int width, int height, uint32* palette); void P8_16BPP(uint32* src, uint32* dst, int width, int height, uint32* palette);
boolean quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, boolean fastQuantizer = 1); bool quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, bool fastQuantizer = 1);
boolean compress(uint8 *src, uint8 *dest,
int srcwidth, int srcheight, uint16 srcformat,
int *destwidth, int *destheight, uint16 *destformat,
int compressionType);
bool compress(uint8 *src, uint8 *dest,
int srcwidth, int srcheight, uint16 srcformat,
int *destwidth, int *destheight, uint16 *destformat,
int compressionType);
#if 0 /* unused */ #if 0 /* unused */
void ARGB8888_I8(uint32* src, uint32* dst, int width, int height); void ARGB8888_I8(uint32* src, uint32* dst, int width, int height);
void I8_ARGB8888(uint32* src, uint32* dst, int width, int height); void I8_ARGB8888(uint32* src, uint32* dst, int width, int height);
void ARGB1555_ABGR8888(uint32* src, uint32* dst, int width, int height); void ARGB1555_ABGR8888(uint32* src, uint32* dst, int width, int height);
void ARGB4444_ABGR8888(uint32* src, uint32* dst, int width, int height); void ARGB4444_ABGR8888(uint32* src, uint32* dst, int width, int height);
void ARGB8888_ABGR8888(uint32* src, uint32* dst, int width, int height); void ARGB8888_ABGR8888(uint32* src, uint32* dst, int width, int height);
#endif #endif
}; };

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TxReSample.h" #include "TxReSample.h"
#include "TxDbg.h" #include "TxDbg.h"
@ -36,109 +27,110 @@
int int
TxReSample::nextPow2(int num) TxReSample::nextPow2(int num)
{ {
num = num - 1; num = num - 1;
num = num | (num >> 1); num = num | (num >> 1);
num = num | (num >> 2); num = num | (num >> 2);
num = num | (num >> 4); num = num | (num >> 4);
num = num | (num >> 8); num = num | (num >> 8);
num = num | (num >> 16); num = num | (num >> 16);
/*num = num | (num >> 32);*//* for 64bit architecture */ /*num = num | (num >> 32);*//* for 64bit architecture */
num = num + 1; num = num + 1;
return num; return num;
} }
boolean bool
TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean use_3dfx = 0) TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3dfx = 0)
{ {
/* NOTE: bpp must be one of the follwing: 8, 16, 24, 32 bits per pixel */ /* NOTE: bpp must be one of the follwing: 8, 16, 24, 32 bits per pixel */
if (!*image || !*width || !*height || !bpp)
return 0;
int row_bytes = ((*width * bpp) >> 3);
int o_row_bytes = row_bytes;
int o_width = *width;
int n_width = *width;
int o_height = *height;
int n_height = *height;
/* HACKALERT: I have explicitly subtracted (n) from width/height to
* adjust textures that have (n) pixel larger width/height than
* power of 2 size. This is a dirty hack for textures that have
* munged aspect ratio by (n) pixel to the original.
*/
if (n_width > 64) n_width -= 4;
else if (n_width > 16) n_width -= 2;
else if (n_width > 4) n_width -= 1;
if (n_height > 64) n_height -= 4;
else if (n_height > 16) n_height -= 2;
else if (n_height > 4) n_height -= 1;
n_width = nextPow2(n_width);
n_height = nextPow2(n_height);
row_bytes = (n_width * bpp) >> 3;
/* 3dfx Glide3 format, W:H aspect ratio range (8:1 - 1:8) */
if (use_3dfx) {
if (n_width > n_height) {
if (n_width > (n_height << 3))
n_height = n_width >> 3;
}
else {
if (n_height > (n_width << 3)) {
n_width = n_height >> 3;
row_bytes = (n_width * bpp) >> 3;
}
}
DBG_INFO(80, "using 3dfx W:H aspect ratio range (8:1 - 1:8).\n");
}
/* do we really need to do this ? */
if (o_width == n_width && o_height == n_height)
return 1; /* nope */
DBG_INFO(80, "expand image to next power of 2 dimensions. %d x %d -> %d x %d\n", o_width, o_height, n_width, n_height);
if (o_width > n_width)
o_width = n_width;
if (o_height > n_height)
o_height = n_height;
/* allocate memory to read in image */
uint8 *pow2image = (uint8*)malloc(row_bytes * n_height);
/* read in image */
if (pow2image) {
int i, j;
uint8 *tmpimage = *image, *tmppow2image = pow2image;
for (i = 0; i < o_height; i++) {
/* copy row */
memcpy(tmppow2image, tmpimage, ((o_width * bpp) >> 3));
/* expand to pow2 size by replication */
for (j = ((o_width * bpp) >> 3); j < row_bytes; j++)
tmppow2image[j] = tmppow2image[j - (bpp >> 3)];
tmppow2image += row_bytes;
tmpimage += o_row_bytes;
}
/* expand to pow2 size by replication */
for (i = o_height; i < n_height; i++)
memcpy(&pow2image[row_bytes * i], &pow2image[row_bytes * (i - 1)], row_bytes);
free(*image);
*image = pow2image;
*height = n_height;
*width = n_width;
return 1;
}
if (!*image || !*width || !*height || !bpp)
return 0; return 0;
int row_bytes = ((*width * bpp) >> 3);
int o_row_bytes = row_bytes;
int o_width = *width;
int n_width = *width;
int o_height = *height;
int n_height = *height;
/* HACKALERT: I have explicitly subtracted (n) from width/height to
* adjust textures that have (n) pixel larger width/height than
* power of 2 size. This is a dirty hack for textures that have
* munged aspect ratio by (n) pixel to the original.
*/
if (n_width > 64) n_width -= 4;
else if (n_width > 16) n_width -= 2;
else if (n_width > 4) n_width -= 1;
if (n_height > 64) n_height -= 4;
else if (n_height > 16) n_height -= 2;
else if (n_height > 4) n_height -= 1;
n_width = nextPow2(n_width);
n_height = nextPow2(n_height);
row_bytes = (n_width * bpp) >> 3;
/* 3dfx Glide3 format, W:H aspect ratio range (8:1 - 1:8) */
if (use_3dfx) {
if (n_width > n_height) {
if (n_width > (n_height << 3))
n_height = n_width >> 3;
} else {
if (n_height > (n_width << 3)) {
n_width = n_height >> 3;
row_bytes = (n_width * bpp) >> 3;
}
}
DBG_INFO(80, "using 3dfx W:H aspect ratio range (8:1 - 1:8).\n");
}
/* do we really need to do this ? */
if (o_width == n_width && o_height == n_height)
return 1; /* nope */
DBG_INFO(80, "expand image to next power of 2 dimensions. %d x %d -> %d x %d\n", o_width, o_height, n_width, n_height);
if (o_width > n_width)
o_width = n_width;
if (o_height > n_height)
o_height = n_height;
/* allocate memory to read in image */
uint8 *pow2image = (uint8*)malloc(row_bytes * n_height);
/* read in image */
if (pow2image) {
int i, j;
uint8 *tmpimage = *image, *tmppow2image = pow2image;
for (i = 0; i < o_height; i++) {
/* copy row */
memcpy(tmppow2image, tmpimage, ((o_width * bpp) >> 3));
/* expand to pow2 size by replication */
for(j = ((o_width * bpp) >> 3); j < row_bytes; j++)
tmppow2image[j] = tmppow2image[j - (bpp >> 3)];
tmppow2image += row_bytes;
tmpimage += o_row_bytes;
}
/* expand to pow2 size by replication */
for (i = o_height; i < n_height; i++)
memcpy(&pow2image[row_bytes * i], &pow2image[row_bytes * (i - 1)], row_bytes);
free(*image);
*image = pow2image;
*height = n_height;
*width = n_width;
return 1;
}
return 0;
} }
/* Ken Turkowski /* Ken Turkowski
@ -148,61 +140,62 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean us
double double
TxReSample::tent(double x) TxReSample::tent(double x)
{ {
if (x < 0.0) x = -x; if (x < 0.0) x = -x;
if (x < 1.0) return (1.0 - x); if (x < 1.0) return (1.0 - x);
return 0.0; return 0.0;
} }
double double
TxReSample::gaussian(double x) TxReSample::gaussian(double x)
{ {
if (x < 0) x = -x; if (x < 0) x = -x;
if (x < 2.0) return pow(2.0, -2.0 * x * x); if (x < 2.0) return pow(2.0, -2.0 * x * x);
return 0.0; return 0.0;
} }
double double
TxReSample::sinc(double x) TxReSample::sinc(double x)
{ {
if (x == 0) return 1.0; if (x == 0) return 1.0;
x *= M_PI; x *= M_PI;
return (sin(x) / x); return (sin(x) / x);
} }
double double
TxReSample::lanczos3(double x) TxReSample::lanczos3(double x)
{ {
if (x < 0) x = -x; if (x < 0) x = -x;
if (x < 3.0) return (sinc(x) * sinc(x/3.0)); if (x < 3.0) return (sinc(x) * sinc(x / 3.0));
return 0.0; return 0.0;
} }
/* Don P. Mitchell and Arun N. Netravali /* Don P. Mitchell and Arun N. Netravali
* Reconstruction Filters in Computer Graphics * Reconstruction Filters in Computer Graphics
* SIGGRAPH '88 * SIGGRAPH '88
* Proceedings of the 15th annual conference on Computer * Proceedings of the 15th annual conference on Computer
* graphics and interactive techniques, pp221-228, 1988 * graphics and interactive techniques, pp221-228, 1988
*/ */
double double
TxReSample::mitchell(double x) TxReSample::mitchell(double x)
{ {
if (x < 0) x = -x; if (x < 0) x = -x;
if (x < 2.0) { if (x < 2.0) {
const double B = 1.0 / 3.0; const double B = 1.0 / 3.0;
const double C = 1.0 / 3.0; const double C = 1.0 / 3.0;
if (x < 1.0) { if (x < 1.0) {
x = (((12.0 - 9.0 * B - 6.0 * C) * (x * x * x)) x = (((12.0 - 9.0 * B - 6.0 * C) * (x * x * x))
+ ((-18.0 + 12.0 * B + 6.0 * C) * (x * x)) + ((-18.0 + 12.0 * B + 6.0 * C) * (x * x))
+ (6.0 - 2.0 * B)); + (6.0 - 2.0 * B));
} else { }
x = (((-1.0 * B - 6.0 * C) * (x * x * x)) else {
+ ((6.0 * B + 30.0 * C) * (x * x)) x = (((-1.0 * B - 6.0 * C) * (x * x * x))
+ ((-12.0 * B - 48.0 * C) * x) + ((6.0 * B + 30.0 * C) * (x * x))
+ (8.0 * B + 24.0 * C)); + ((-12.0 * B - 48.0 * C) * x)
+ (8.0 * B + 24.0 * C));
}
return (x / 6.0);
} }
return (x / 6.0); return 0.0;
}
return 0.0;
} }
/* J. F. Kaiser and W. A. Reed /* J. F. Kaiser and W. A. Reed
@ -212,205 +205,205 @@ TxReSample::mitchell(double x)
double double
TxReSample::besselI0(double x) TxReSample::besselI0(double x)
{ {
/* zero-order modified bessel function of the first kind */ /* zero-order modified bessel function of the first kind */
const double eps_coeff = 1E-16; /* small enough */ const double eps_coeff = 1E-16; /* small enough */
double xh, sum, pow, ds; double xh, sum, pow, ds;
xh = 0.5 * x; xh = 0.5 * x;
sum = 1.0; sum = 1.0;
pow = 1.0; pow = 1.0;
ds = 1.0; ds = 1.0;
int k = 0; int k = 0;
while (ds > sum * eps_coeff) { while (ds > sum * eps_coeff) {
k++; k++;
pow *= (xh / k); pow *= (xh / k);
ds = pow * pow; ds = pow * pow;
sum = sum + ds; sum = sum + ds;
} }
return sum; return sum;
} }
double double
TxReSample::kaiser(double x) TxReSample::kaiser(double x)
{ {
const double alpha = 4.0; const double alpha = 4.0;
const double half_window = 5.0; const double half_window = 5.0;
const double ratio = x / half_window; const double ratio = x / half_window;
return sinc(x) * besselI0(alpha * sqrt(1 - ratio * ratio)) / besselI0(alpha); return sinc(x) * besselI0(alpha * sqrt(1 - ratio * ratio)) / besselI0(alpha);
} }
boolean bool
TxReSample::minify(uint8 **src, int *width, int *height, int ratio) TxReSample::minify(uint8 **src, int *width, int *height, int ratio)
{ {
/* NOTE: src must be ARGB8888, ratio is the inverse representation */ /* NOTE: src must be ARGB8888, ratio is the inverse representation */
#if 0 #if 0
if (!*src || ratio < 2) return 0; if (!*src || ratio < 2) return 0;
/* Box filtering. /* Box filtering.
* It would be nice to do Kaiser filtering. * It would be nice to do Kaiser filtering.
* N64 uses narrow strip textures which makes it hard to filter effectively. * N64 uses narrow strip textures which makes it hard to filter effectively.
*/ */
int x, y, x2, y2, offset, numtexel; int x, y, x2, y2, offset, numtexel;
uint32 A, R, G, B, texel; uint32 A, R, G, B, texel;
int tmpwidth = *width / ratio; int tmpwidth = *width / ratio;
int tmpheight = *height / ratio; int tmpheight = *height / ratio;
uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2);
if (tmptex) { if (tmptex) {
numtexel = ratio * ratio; numtexel = ratio * ratio;
for (y = 0; y < tmpheight; y++) { for (y = 0; y < tmpheight; y++) {
offset = ratio * y * *width; offset = ratio * y * *width;
for (x = 0; x < tmpwidth; x++) { for (x = 0; x < tmpwidth; x++) {
A = R = G = B = 0; A = R = G = B = 0;
for (y2 = 0; y2 < ratio; y2++) { for (y2 = 0; y2 < ratio; y2++) {
for (x2 = 0; x2 < ratio; x2++) { for (x2 = 0; x2 < ratio; x2++) {
texel = ((uint32*)*src)[offset + *width * y2 + x2]; texel = ((uint32*)*src)[offset + *width * y2 + x2];
A += (texel >> 24); A += (texel >> 24);
R += ((texel >> 16) & 0x000000ff); R += ((texel >> 16) & 0x000000ff);
G += ((texel >> 8) & 0x000000ff); G += ((texel >> 8) & 0x000000ff);
B += (texel & 0x000000ff); B += (texel & 0x000000ff);
} }
}
A = (A + ratio) / numtexel;
R = (R + ratio) / numtexel;
G = (G + ratio) / numtexel;
B = (B + ratio) / numtexel;
((uint32*)tmptex)[y * tmpwidth + x] = ((A << 24) | (R << 16) | (G << 8) | B);
offset += ratio;
}
} }
A = (A + ratio) / numtexel; free(*src);
R = (R + ratio) / numtexel; *src = tmptex;
G = (G + ratio) / numtexel; *width = tmpwidth;
B = (B + ratio) / numtexel; *height = tmpheight;
((uint32*)tmptex)[y * tmpwidth + x] = ((A << 24) | (R << 16) | (G << 8) | B);
offset += ratio; DBG_INFO(80, L"minification ratio:%d -> %d x %d\n", ratio, *width, *height);
}
return 1;
} }
free(*src);
*src = tmptex;
*width = tmpwidth;
*height = tmpheight;
DBG_INFO(80, L"minification ratio:%d -> %d x %d\n", ratio, *width, *height); DBG_INFO(80, L"Error: failed minification!\n");
return 1; return 0;
}
DBG_INFO(80, L"Error: failed minification!\n");
return 0;
#else #else
if (!*src || ratio < 2) return 0; if (!*src || ratio < 2) return 0;
/* Image Resampling */ /* Image Resampling */
/* half width of filter window.
* NOTE: must be 1.0 or larger.
*
* kaiser-bessel 5, lanczos3 3, mitchell 2, gaussian 1.5, tent 1
*/
double half_window = 5.0;
int x, y, x2, y2, z; /* half width of filter window.
double A, R, G, B; * NOTE: must be 1.0 or larger.
uint32 texel; *
* kaiser-bessel 5, lanczos3 3, mitchell 2, gaussian 1.5, tent 1
*/
double half_window = 5.0;
int tmpwidth = *width / ratio; int x, y, x2, y2, z;
int tmpheight = *height / ratio; double A, R, G, B;
uint32 texel;
/* resampled destination */ int tmpwidth = *width / ratio;
uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); int tmpheight = *height / ratio;
if (!tmptex) return 0;
/* work buffer. single row */ /* resampled destination */
uint8 *workbuf = (uint8*)malloc(*width << 2); uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2);
if (!workbuf) { if (!tmptex) return 0;
free(tmptex);
return 0;
}
/* prepare filter lookup table. only half width required for symetric filters. */ /* work buffer. single row */
double *weight = (double*)malloc((int)((half_window * ratio) * sizeof(double))); uint8 *workbuf = (uint8*)malloc(*width << 2);
if (!weight) { if (!workbuf) {
free(tmptex); free(tmptex);
return 0;
}
/* prepare filter lookup table. only half width required for symetric filters. */
double *weight = (double*)malloc((int)((half_window * ratio) * sizeof(double)));
if (!weight) {
free(tmptex);
free(workbuf);
return 0;
}
for (x = 0; x < half_window * ratio; x++) {
//weight[x] = tent((double)x / ratio) / ratio;
//weight[x] = gaussian((double)x / ratio) / ratio;
//weight[x] = lanczos3((double)x / ratio) / ratio;
//weight[x] = mitchell((double)x / ratio) / ratio;
weight[x] = kaiser((double)x / ratio) / ratio;
}
/* linear convolution */
for (y = 0; y < tmpheight; y++) {
for (x = 0; x < *width; x++) {
texel = ((uint32*)*src)[y * ratio * *width + x];
A = (double)(texel >> 24) * weight[0];
R = (double)((texel >> 16) & 0xff) * weight[0];
G = (double)((texel >> 8) & 0xff) * weight[0];
B = (double)((texel) & 0xff) * weight[0];
for (y2 = 1; y2 < half_window * ratio; y2++) {
z = y * ratio + y2;
if (z >= *height) z = *height - 1;
texel = ((uint32*)*src)[z * *width + x];
A += (double)(texel >> 24) * weight[y2];
R += (double)((texel >> 16) & 0xff) * weight[y2];
G += (double)((texel >> 8) & 0xff) * weight[y2];
B += (double)((texel) & 0xff) * weight[y2];
z = y * ratio - y2;
if (z < 0) z = 0;
texel = ((uint32*)*src)[z * *width + x];
A += (double)(texel >> 24) * weight[y2];
R += (double)((texel >> 16) & 0xff) * weight[y2];
G += (double)((texel >> 8) & 0xff) * weight[y2];
B += (double)((texel) & 0xff) * weight[y2];
}
if (A < 0) A = 0; else if (A > 255) A = 255;
if (R < 0) R = 0; else if (R > 255) R = 255;
if (G < 0) G = 0; else if (G > 255) G = 255;
if (B < 0) B = 0; else if (B > 255) B = 255;
((uint32*)workbuf)[x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B);
}
for (x = 0; x < tmpwidth; x++) {
texel = ((uint32*)workbuf)[x * ratio];
A = (double)(texel >> 24) * weight[0];
R = (double)((texel >> 16) & 0xff) * weight[0];
G = (double)((texel >> 8) & 0xff) * weight[0];
B = (double)((texel) & 0xff) * weight[0];
for (x2 = 1; x2 < half_window * ratio; x2++) {
z = x * ratio + x2;
if (z >= *width) z = *width - 1;
texel = ((uint32*)workbuf)[z];
A += (double)(texel >> 24) * weight[x2];
R += (double)((texel >> 16) & 0xff) * weight[x2];
G += (double)((texel >> 8) & 0xff) * weight[x2];
B += (double)((texel) & 0xff) * weight[x2];
z = x * ratio - x2;
if (z < 0) z = 0;
texel = ((uint32*)workbuf)[z];
A += (double)(texel >> 24) * weight[x2];
R += (double)((texel >> 16) & 0xff) * weight[x2];
G += (double)((texel >> 8) & 0xff) * weight[x2];
B += (double)((texel) & 0xff) * weight[x2];
}
if (A < 0) A = 0; else if (A > 255) A = 255;
if (R < 0) R = 0; else if (R > 255) R = 255;
if (G < 0) G = 0; else if (G > 255) G = 255;
if (B < 0) B = 0; else if (B > 255) B = 255;
((uint32*)tmptex)[y * tmpwidth + x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B);
}
}
free(*src);
*src = tmptex;
free(weight);
free(workbuf); free(workbuf);
return 0; *width = tmpwidth;
} *height = tmpheight;
for (x = 0; x < half_window * ratio; x++) {
//weight[x] = tent((double)x / ratio) / ratio;
//weight[x] = gaussian((double)x / ratio) / ratio;
//weight[x] = lanczos3((double)x / ratio) / ratio;
//weight[x] = mitchell((double)x / ratio) / ratio;
weight[x] = kaiser((double)x / ratio) / ratio;
}
/* linear convolution */ DBG_INFO(80, "minification ratio:%d -> %d x %d\n", ratio, *width, *height);
for (y = 0; y < tmpheight; y++) {
for (x = 0; x < *width; x++) {
texel = ((uint32*)*src)[y * ratio * *width + x];
A = (double)(texel >> 24) * weight[0];
R = (double)((texel >> 16) & 0xff) * weight[0];
G = (double)((texel >> 8) & 0xff) * weight[0];
B = (double)((texel ) & 0xff) * weight[0];
for (y2 = 1; y2 < half_window * ratio; y2++) {
z = y * ratio + y2;
if (z >= *height) z = *height - 1;
texel = ((uint32*)*src)[z * *width + x];
A += (double)(texel >> 24) * weight[y2];
R += (double)((texel >> 16) & 0xff) * weight[y2];
G += (double)((texel >> 8) & 0xff) * weight[y2];
B += (double)((texel ) & 0xff) * weight[y2];
z = y * ratio - y2;
if (z < 0) z = 0;
texel = ((uint32*)*src)[z * *width + x];
A += (double)(texel >> 24) * weight[y2];
R += (double)((texel >> 16) & 0xff) * weight[y2];
G += (double)((texel >> 8) & 0xff) * weight[y2];
B += (double)((texel ) & 0xff) * weight[y2];
}
if (A < 0) A = 0; else if (A > 255) A = 255;
if (R < 0) R = 0; else if (R > 255) R = 255;
if (G < 0) G = 0; else if (G > 255) G = 255;
if (B < 0) B = 0; else if (B > 255) B = 255;
((uint32*)workbuf)[x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B);
}
for (x = 0; x < tmpwidth; x++) {
texel = ((uint32*)workbuf)[x * ratio];
A = (double)(texel >> 24) * weight[0];
R = (double)((texel >> 16) & 0xff) * weight[0];
G = (double)((texel >> 8) & 0xff) * weight[0];
B = (double)((texel ) & 0xff) * weight[0];
for (x2 = 1; x2 < half_window * ratio; x2++) {
z = x * ratio + x2;
if (z >= *width) z = *width - 1;
texel = ((uint32*)workbuf)[z];
A += (double)(texel >> 24) * weight[x2];
R += (double)((texel >> 16) & 0xff) * weight[x2];
G += (double)((texel >> 8) & 0xff) * weight[x2];
B += (double)((texel ) & 0xff) * weight[x2];
z = x * ratio - x2;
if (z < 0) z = 0;
texel = ((uint32*)workbuf)[z];
A += (double)(texel >> 24) * weight[x2];
R += (double)((texel >> 16) & 0xff) * weight[x2];
G += (double)((texel >> 8) & 0xff) * weight[x2];
B += (double)((texel ) & 0xff) * weight[x2];
}
if (A < 0) A = 0; else if (A > 255) A = 255;
if (R < 0) R = 0; else if (R > 255) R = 255;
if (G < 0) G = 0; else if (G > 255) G = 255;
if (B < 0) B = 0; else if (B > 255) B = 255;
((uint32*)tmptex)[y * tmpwidth + x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B);
}
}
free(*src); return 1;
*src = tmptex;
free(weight);
free(workbuf);
*width = tmpwidth;
*height = tmpheight;
DBG_INFO(80, "minification ratio:%d -> %d x %d\n", ratio, *width, *height);
return 1;
#endif #endif
} }

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXRESAMPLE_H__ #ifndef __TXRESAMPLE_H__
#define __TXRESAMPLE_H__ #define __TXRESAMPLE_H__
@ -29,17 +20,17 @@
class TxReSample class TxReSample
{ {
private: private:
double tent(double x); double tent(double x);
double gaussian(double x); double gaussian(double x);
double sinc(double x); double sinc(double x);
double lanczos3(double x); double lanczos3(double x);
double mitchell(double x); double mitchell(double x);
double besselI0(double x); double besselI0(double x);
double kaiser(double x); double kaiser(double x);
public: public:
boolean minify(uint8 **src, int *width, int *height, int ratio); bool minify(uint8 **src, int *width, int *height, int ratio);
boolean nextPow2(uint8** image, int* width, int* height, int bpp, boolean use_3dfx); bool nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3dfx);
int nextPow2(int num); int nextPow2(int num);
}; };
#endif /* __TXRESAMPLE_H__ */ #endif /* __TXRESAMPLE_H__ */

View File

@ -1,26 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef WIN32 #ifdef WIN32
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
#endif #endif
@ -53,7 +43,7 @@ TxTexCache::~TxTexCache()
} }
TxTexCache::TxTexCache(int options, int cachesize, const char *path, const char *ident, dispInfoFuncExt callback) : TxTexCache::TxTexCache(int options, int cachesize, const char *path, const char *ident, dispInfoFuncExt callback) :
TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback) TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback)
{ {
/* assert local options */ /* assert local options */
if (_path.empty() || _ident.empty() || !_cacheSize) if (_path.empty() || _ident.empty() || !_cacheSize)
@ -75,9 +65,9 @@ TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback)
#endif #endif
} }
boolean TxTexCache::add(uint64 checksum, GHQTexInfo *info) bool TxTexCache::add(uint64_t checksum, GHQTexInfo *info)
{ {
if (_cacheSize <= 0) return 0; if (_cacheSize <= 0) return 0;
return TxCache::add(checksum, info); return TxCache::add(checksum, info);
} }

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXTEXCACHE_H__ #ifndef __TXTEXCACHE_H__
#define __TXTEXCACHE_H__ #define __TXTEXCACHE_H__
@ -29,11 +20,11 @@
class TxTexCache : public TxCache class TxTexCache : public TxCache
{ {
public: public:
~TxTexCache(); ~TxTexCache();
TxTexCache(int options, int cachesize, const char *path, const char *ident, TxTexCache(int options, int cachesize, const char *path, const char *ident,
dispInfoFuncExt callback); dispInfoFuncExt callback);
boolean add(uint64 checksum, /* checksum hi:palette low:texture */ bool add(uint64_t checksum, /* checksum hi:palette low:texture */
GHQTexInfo *info); GHQTexInfo *info);
}; };
#endif /* __TXTEXCACHE_H__ */ #endif /* __TXTEXCACHE_H__ */

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TxUtil.h" #include "TxUtil.h"
#include "TxDbg.h" #include "TxDbg.h"
@ -27,203 +18,139 @@
#include <malloc.h> #include <malloc.h>
#include <stdlib.h> #include <stdlib.h>
#include <Common/stdtypes.h> #include <Common/stdtypes.h>
#include <Project64-video/Renderer/types.h>
#include <windows.h>
/* /*
* External libraries * External libraries
******************************************************************************/ ******************************************************************************/
TxLoadLib::TxLoadLib() TxLoadLib::TxLoadLib()
{ {
#ifdef DXTN_DLL _tx_compress_dxtn = tx_compress_dxtn;
if (!_dxtnlib) _tx_compress_fxt1 = fxt1_encode;
_dxtnlib = LoadLibrary("dxtn");
if (_dxtnlib) {
if (!_tx_compress_dxtn)
_tx_compress_dxtn = (dxtCompressTexFuncExt)DLSYM(_dxtnlib, "tx_compress_dxtn");
if (!_tx_compress_fxt1)
_tx_compress_fxt1 = (fxtCompressTexFuncExt)DLSYM(_dxtnlib, "fxt1_encode");
}
#else
_tx_compress_dxtn = tx_compress_dxtn;
_tx_compress_fxt1 = fxt1_encode;
#endif
} }
TxLoadLib::~TxLoadLib() TxLoadLib::~TxLoadLib()
{ {
#ifdef DXTN_DLL
/* free dynamic library */
if (_dxtnlib)
FreeLibrary(_dxtnlib);
#endif
} }
fxtCompressTexFuncExt fxtCompressTexFuncExt TxLoadLib::getfxtCompressTexFuncExt()
TxLoadLib::getfxtCompressTexFuncExt()
{ {
return _tx_compress_fxt1; return _tx_compress_fxt1;
} }
dxtCompressTexFuncExt dxtCompressTexFuncExt TxLoadLib::getdxtCompressTexFuncExt()
TxLoadLib::getdxtCompressTexFuncExt()
{ {
return _tx_compress_dxtn; return _tx_compress_dxtn;
} }
/* /*
* Utilities * Utilities
******************************************************************************/ ******************************************************************************/
uint32 uint32 TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format)
TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format)
{ {
int dataSize = sizeofTx(width, height, format); int dataSize = sizeofTx(width, height, format);
/* for now we use adler32 if something else is better /* for now we use adler32 if something else is better
* we can simply swtich later * we can simply swtich later
*/ */
/* return (dataSize ? Adler32(src, dataSize, 1) : 0); */ /* return (dataSize ? Adler32(src, dataSize, 1) : 0); */
/* zlib crc32 */ /* zlib crc32 */
return (dataSize ? crc32(crc32(0L, Z_NULL, 0), src, dataSize) : 0); return (dataSize ? crc32(crc32(0L, Z_NULL, 0), src, dataSize) : 0);
} }
int int TxUtil::sizeofTx(int width, int height, uint16 format)
TxUtil::sizeofTx(int width, int height, uint16 format)
{ {
int dataSize = 0; int dataSize = 0;
/* a lookup table for the shifts would be better */ /* a lookup table for the shifts would be better */
switch (format) { switch (format) {
case GR_TEXFMT_ARGB_CMP_FXT1: case GFX_TEXFMT_ARGB_CMP_FXT1:
dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1; dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1;
break; break;
case GR_TEXFMT_ARGB_CMP_DXT1: case GFX_TEXFMT_ARGB_CMP_DXT1:
dataSize = (((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3)) >> 1; dataSize = (((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3)) >> 1;
break; break;
case GR_TEXFMT_ARGB_CMP_DXT3: case GFX_TEXFMT_ARGB_CMP_DXT3:
case GR_TEXFMT_ARGB_CMP_DXT5: case GFX_TEXFMT_ARGB_CMP_DXT5:
dataSize = ((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3); dataSize = ((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3);
break; break;
case GR_TEXFMT_ALPHA_INTENSITY_44: case GFX_TEXFMT_ALPHA_INTENSITY_44:
case GR_TEXFMT_ALPHA_8: case GFX_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8: case GFX_TEXFMT_INTENSITY_8:
case GR_TEXFMT_P_8: case GFX_TEXFMT_P_8:
dataSize = width * height; dataSize = width * height;
break; break;
case GR_TEXFMT_ARGB_4444: case GFX_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_1555: case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_RGB_565: case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_ALPHA_INTENSITY_88: case GFX_TEXFMT_ALPHA_INTENSITY_88:
dataSize = (width * height) << 1; dataSize = (width * height) << 1;
break; break;
case GR_TEXFMT_ARGB_8888: case GFX_TEXFMT_ARGB_8888:
dataSize = (width * height) << 2; dataSize = (width * height) << 2;
break; break;
default: default:
/* unsupported format */ /* unsupported format */
DBG_INFO(80, "Error: cannot get size. unsupported gfmt:%x\n", format); DBG_INFO(80, "Error: cannot get size. unsupported gfmt:%x\n", format);
; ;
}
return dataSize;
}
#if 0 /* unused */
uint32
TxUtil::chkAlpha(uint32* src, int width, int height)
{
/* NOTE: _src must be ARGB8888
* return values
* 0x00000000: 8bit alpha
* 0x00000001: 1bit alpha
* 0xff000001: no alpha
*/
int _size = width * height;
uint32 alpha = 0;
__asm {
mov esi, dword ptr [src];
mov ecx, dword ptr [_size];
mov ebx, 0xff000000;
tc1_loop:
mov eax, dword ptr [esi];
add esi, 4;
and eax, 0xff000000;
jz alpha1bit;
cmp eax, 0xff000000;
je alpha1bit;
jmp done;
alpha1bit:
and ebx, eax;
dec ecx;
jnz tc1_loop;
or ebx, 0x00000001;
mov dword ptr [alpha], ebx;
done:
}
return alpha;
}
#endif
uint32
TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStride)
{
/* Rice CRC32 for now. We can switch this to Jabo MD5 or
* any other custom checksum.
* TODO: use *_HIRESTEXTURE option. */
if (!src) return 0;
return RiceCRC32(src, width, height, size, rowStride);
}
uint64
TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{
/* Rice CRC32 for now. We can switch this to Jabo MD5 or
* any other custom checksum.
* TODO: use *_HIRESTEXTURE option. */
/* Returned value is 64bits: hi=palette crc32 low=texture crc32 */
if (!src) return 0;
uint64 crc64Ret = 0;
if (palette) {
uint32 crc32 = 0, cimax = 0;
switch (size & 0xff) {
case 1:
if (RiceCRC32_CI8(src, width, height, size, rowStride, &crc32, &cimax)) {
crc64Ret = (uint64)RiceCRC32(palette, cimax + 1, 1, 2, 512);
crc64Ret <<= 32;
crc64Ret |= (uint64)crc32;
}
break;
case 0:
if (RiceCRC32_CI4(src, width, height, size, rowStride, &crc32, &cimax)) {
crc64Ret = (uint64)RiceCRC32(palette, cimax + 1, 1, 2, 32);
crc64Ret <<= 32;
crc64Ret |= (uint64)crc32;
}
} }
}
if (!crc64Ret) {
crc64Ret = (uint64)RiceCRC32(src, width, height, size, rowStride);
}
return crc64Ret; return dataSize;
}
uint32 TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStride)
{
/* Rice CRC32 for now. We can switch this to Jabo MD5 or
* any other custom checksum.
* TODO: use *_HIRESTEXTURE option. */
if (!src) return 0;
return RiceCRC32(src, width, height, size, rowStride);
}
uint64_t TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{
/* Rice CRC32 for now. We can switch this to Jabo MD5 or
* any other custom checksum.
* TODO: use *_HIRESTEXTURE option. */
/* Returned value is 64bits: hi=palette crc32 low=texture crc32 */
if (!src) return 0;
uint64_t crc64Ret = 0;
if (palette)
{
uint32 crc32 = 0, cimax = 0;
switch (size & 0xff)
{
case 1:
if (RiceCRC32_CI8(src, width, height, size, rowStride, &crc32, &cimax))
{
crc64Ret = (uint64_t)RiceCRC32(palette, cimax + 1, 1, 2, 512);
crc64Ret <<= 32;
crc64Ret |= (uint64_t)crc32;
}
break;
case 0:
if (RiceCRC32_CI4(src, width, height, size, rowStride, &crc32, &cimax))
{
crc64Ret = (uint64_t)RiceCRC32(palette, cimax + 1, 1, 2, 32);
crc64Ret <<= 32;
crc64Ret |= (uint64_t)crc32;
}
}
}
if (!crc64Ret)
{
crc64Ret = (uint64_t)RiceCRC32(src, width, height, size, rowStride);
}
return crc64Ret;
} }
/* /*
@ -242,7 +169,7 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u
** 65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored ** 65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored
** as s2*65536 + s1 in most-significant-byte first (network) order. ** as s2*65536 + s1 in most-significant-byte first (network) order.
** **
** 8.2. The Adler-32 algorithm ** 8.2. The Adler-32 algorithm
** **
** The Adler-32 algorithm is much faster than the CRC32 algorithm yet still ** The Adler-32 algorithm is much faster than the CRC32 algorithm yet still
** provides an extremely low probability of undetected errors. ** provides an extremely low probability of undetected errors.
@ -261,59 +188,37 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u
** separately. (Any sequence of zeroes has a Fletcher checksum of zero.) ** separately. (Any sequence of zeroes has a Fletcher checksum of zero.)
*/ */
uint32 uint32 TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32)
TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32)
{ {
#if 1 /* zlib adler32 */
/* zlib adler32 */ return adler32(dwAdler32, data, Len);
return adler32(dwAdler32, data, Len);
#else
register uint32 s1 = dwAdler32 & 0xFFFF;
register uint32 s2 = (dwAdler32 >> 16) & 0xFFFF;
int k;
while (Len > 0) {
/* 5552 is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
k = (Len < 5552 ? Len : 5552);
Len -= k;
while (k--) {
s1 += *data++;
s2 += s1;
}
/* 65521 is the largest prime smaller than 65536 */
s1 %= 65521;
s2 %= 65521;
}
return (s2 << 16) | s1;
#endif
} }
uint32 uint32 TxUtil::Adler32(const uint8* src, int width, int height, int size, int rowStride)
TxUtil::Adler32(const uint8* src, int width, int height, int size, int rowStride)
{ {
int i; int i;
uint32 ret = 1; uint32 ret = 1;
uint32 width_in_bytes = width * size; uint32 width_in_bytes = width * size;
for (i = 0; i < height; i++) { for (i = 0; i < height; i++)
ret = Adler32(src, width_in_bytes, ret); {
src += rowStride; ret = Adler32(src, width_in_bytes, ret);
} src += rowStride;
}
return ret; return ret;
} }
// rotate left // rotate left
template<class T> static T __ROL__(T value, unsigned int count) template<class T> static T __ROL__(T value, unsigned int count)
{ {
const unsigned int nbits = sizeof(T) * 8; const unsigned int nbits = sizeof(T) * 8;
count %= nbits; count %= nbits;
T high = value >> (nbits - count); T high = value >> (nbits - count);
value <<= count; value <<= count;
value |= high; value |= high;
return value; return value;
} }
/* Rice CRC32 for hires texture packs */ /* Rice CRC32 for hires texture packs */
@ -321,154 +226,156 @@ template<class T> static T __ROL__(T value, unsigned int count)
* for Rice hires texture packs. * for Rice hires texture packs.
* *
* BYTE* addr = (BYTE*)(gfx.RDRAM + * BYTE* addr = (BYTE*)(gfx.RDRAM +
* rdp.addr[rdp.tiles[tile].t_mem] + * rdp.addr[rdp.tiles(tile).t_mem] +
* (rdp.tiles[tile].ul_t * bpl) + * (rdp.tiles(tile).ul_t * bpl) +
* (((rdp.tiles[tile].ul_s<<rdp.tiles[tile].size)+1)>>1)); * (((rdp.tiles(tile).ul_s<<rdp.tiles(tile).size)+1)>>1));
* RiceCRC32(addr, * RiceCRC32(addr,
* rdp.tiles[tile].width, * rdp.tiles(tile).width,
* rdp.tiles[tile].height, * rdp.tiles(tile).height,
* (unsigned short)(rdp.tiles[tile].format << 8 | rdp.tiles[tile].size), * (unsigned short)(rdp.tiles(tile).format << 8 | rdp.tiles(tile).size),
* bpl); * bpl);
*/ */
uint32 uint32 TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride)
TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride)
{ {
const uint8_t *row; const uint8_t *row;
uint32_t crc32Ret; uint32_t crc32Ret;
int cur_height; int cur_height;
uint32_t pos; uint32_t pos;
uint32_t word; uint32_t word;
uint32_t word_hash = 0; uint32_t word_hash = 0;
uint32_t tmp; uint32_t tmp;
const uint32_t bytes_per_width = ((width << size) + 1) >> 1; const uint32_t bytes_per_width = ((width << size) + 1) >> 1;
row = src; row = src;
crc32Ret = 0; crc32Ret = 0;
for (cur_height = height - 1; cur_height >= 0; cur_height--) { for (cur_height = height - 1; cur_height >= 0; cur_height--)
for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) { {
word = *(uint32_t *)&row[pos]; for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4)
word_hash = pos ^ word; {
tmp = __ROL__(crc32Ret, 4); word = *(uint32_t *)&row[pos];
crc32Ret = word_hash + tmp; word_hash = pos ^ word;
tmp = __ROL__(crc32Ret, 4);
crc32Ret = word_hash + tmp;
}
crc32Ret += cur_height ^ word_hash;
row += rowStride;
} }
crc32Ret += cur_height ^ word_hash; return crc32Ret;
row += rowStride;
}
return crc32Ret;
} }
boolean bool TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, uint32* crc32, uint32* cimax)
TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax)
{ {
const uint8_t *row; const uint8_t *row;
uint32_t crc32Ret; uint32_t crc32Ret;
uint32_t cimaxRet; uint32_t cimaxRet;
int cur_height; int cur_height;
uint32_t pos; uint32_t pos;
uint32_t word; uint32_t word;
uint32_t word_hash = 0; uint32_t word_hash = 0;
uint32_t tmp; uint32_t tmp;
const uint32_t bytes_per_width = ((width << size) + 1) >> 1; const uint32_t bytes_per_width = ((width << size) + 1) >> 1;
row = src; row = src;
crc32Ret = 0; crc32Ret = 0;
cimaxRet = 0; cimaxRet = 0;
for (cur_height = height - 1; cur_height >= 0; cur_height--) { for (cur_height = height - 1; cur_height >= 0; cur_height--)
for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) { {
word = *(uint32_t *)&row[pos]; for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4)
if (cimaxRet != 15) { {
if ((word & 0xF) >= cimaxRet) word = *(uint32_t *)&row[pos];
cimaxRet = word & 0xF; if (cimaxRet != 15)
if ((uint32_t)((uint8_t)word >> 4) >= cimaxRet) {
cimaxRet = (uint8_t)word >> 4; if ((word & 0xF) >= cimaxRet)
if (((word >> 8) & 0xF) >= cimaxRet) cimaxRet = word & 0xF;
cimaxRet = (word >> 8) & 0xF; if ((uint32_t)((uint8_t)word >> 4) >= cimaxRet)
if ((uint32_t)((uint16_t)word >> 12) >= cimaxRet) cimaxRet = (uint8_t)word >> 4;
cimaxRet = (uint16_t)word >> 12; if (((word >> 8) & 0xF) >= cimaxRet)
if (((word >> 16) & 0xF) >= cimaxRet) cimaxRet = (word >> 8) & 0xF;
cimaxRet = (word >> 16) & 0xF; if ((uint32_t)((uint16_t)word >> 12) >= cimaxRet)
if (((word >> 20) & 0xF) >= cimaxRet) cimaxRet = (uint16_t)word >> 12;
cimaxRet = (word >> 20) & 0xF; if (((word >> 16) & 0xF) >= cimaxRet)
if (((word >> 24) & 0xF) >= cimaxRet) cimaxRet = (word >> 16) & 0xF;
cimaxRet = (word >> 24) & 0xF; if (((word >> 20) & 0xF) >= cimaxRet)
if (word >> 28 >= cimaxRet ) cimaxRet = (word >> 20) & 0xF;
cimaxRet = word >> 28; if (((word >> 24) & 0xF) >= cimaxRet)
} cimaxRet = (word >> 24) & 0xF;
word_hash = pos ^ word; if (word >> 28 >= cimaxRet)
tmp = __ROL__(crc32Ret, 4); cimaxRet = word >> 28;
crc32Ret = word_hash + tmp; }
word_hash = pos ^ word;
tmp = __ROL__(crc32Ret, 4);
crc32Ret = word_hash + tmp;
}
crc32Ret += cur_height ^ word_hash;
row += rowStride;
} }
crc32Ret += cur_height ^ word_hash; *crc32 = crc32Ret;
row += rowStride; *cimax = cimaxRet;
} return 1;
*crc32 = crc32Ret;
*cimax = cimaxRet;
return 1;
} }
boolean bool TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, uint32* crc32, uint32* cimax)
TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax)
{ {
const uint8_t *row; const uint8_t *row;
uint32_t crc32Ret; uint32_t crc32Ret;
uint32_t cimaxRet; uint32_t cimaxRet;
int cur_height; int cur_height;
uint32_t pos; uint32_t pos;
uint32_t word; uint32_t word;
uint32_t word_hash = 0; uint32_t word_hash = 0;
uint32_t tmp; uint32_t tmp;
const uint32_t bytes_per_width = ((width << size) + 1) >> 1; const uint32_t bytes_per_width = ((width << size) + 1) >> 1;
row = src; row = src;
crc32Ret = 0; crc32Ret = 0;
cimaxRet = 0; cimaxRet = 0;
for (cur_height = height - 1; cur_height >= 0; cur_height--) { for (cur_height = height - 1; cur_height >= 0; cur_height--)
for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) { {
word = *(uint32_t *)&row[pos]; for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4)
if (cimaxRet != 255) { {
if ((uint8_t)word >= cimaxRet) word = *(uint32_t *)&row[pos];
cimaxRet = (uint8_t)word; if (cimaxRet != 255)
if ((uint32_t)((uint16_t)word >> 8) >= cimaxRet) {
cimaxRet = (uint16_t)word >> 8; if ((uint8_t)word >= cimaxRet)
if (((word >> 16) & 0xFF) >= cimaxRet) cimaxRet = (uint8_t)word;
cimaxRet = (word >> 16) & 0xFF; if ((uint32_t)((uint16_t)word >> 8) >= cimaxRet)
if (word >> 24 >= cimaxRet) cimaxRet = (uint16_t)word >> 8;
cimaxRet = word >> 24; if (((word >> 16) & 0xFF) >= cimaxRet)
} cimaxRet = (word >> 16) & 0xFF;
word_hash = pos ^ word; if (word >> 24 >= cimaxRet)
tmp = __ROL__(crc32Ret, 4); cimaxRet = word >> 24;
crc32Ret = word_hash + tmp; }
word_hash = pos ^ word;
tmp = __ROL__(crc32Ret, 4);
crc32Ret = word_hash + tmp;
}
crc32Ret += cur_height ^ word_hash;
row += rowStride;
} }
crc32Ret += cur_height ^ word_hash; *crc32 = crc32Ret;
row += rowStride; *cimax = cimaxRet;
} return 1;
*crc32 = crc32Ret;
*cimax = cimaxRet;
return 1;
} }
int int TxUtil::log2(int num)
TxUtil::log2(int num)
{ {
#if defined(__GNUC__) #if defined(__GNUC__)
return __builtin_ctz(num); return __builtin_ctz(num);
#elif defined(_MSC_VER) && _MSC_VER >= 1400 #elif defined(_MSC_VER) && _MSC_VER >= 1400
uint32_t i; uint32_t i;
_BitScanForward((DWORD *)&i, num); _BitScanForward((unsigned long *)&i, num);
return i; return i;
#elif defined(__MSC__) #elif defined(__MSC__)
__asm { __asm {
mov eax, dword ptr [num]; mov eax, dword ptr[num];
bsr eax, eax; bsr eax, eax;
mov dword ptr [i], eax; mov dword ptr[i], eax;
} }
#else #else
switch (num) { switch (num) {
case 1: return 0; case 1: return 0;
case 2: return 1; case 2: return 1;
case 4: return 2; case 4: return 2;
@ -481,104 +388,99 @@ TxUtil::log2(int num)
case 512: return 9; case 512: return 9;
case 1024: return 10; case 1024: return 10;
case 2048: return 11; case 2048: return 11;
} }
#endif #endif
} }
int int TxUtil::grLodLog2(int w, int h)
TxUtil::grLodLog2(int w, int h)
{ {
return (w >= h ? log2(w) : log2(h)); return (w >= h ? log2(w) : log2(h));
} }
int int TxUtil::grAspectRatioLog2(int w, int h)
TxUtil::grAspectRatioLog2(int w, int h)
{ {
return (w >= h ? log2(w/h) : -log2(h/w)); return (w >= h ? log2(w / h) : -log2(h / w));
} }
int int TxUtil::getNumberofProcessors()
TxUtil::getNumberofProcessors()
{ {
int numcore = 1, ret; int numcore = 1, ret;
#ifdef _WIN32 #ifdef _WIN32
#ifndef _SC_NPROCESSORS_ONLN #ifndef _SC_NPROCESSORS_ONLN
SYSTEM_INFO info; SYSTEM_INFO info;
GetSystemInfo(&info); GetSystemInfo(&info);
#define sysconf(a) info.dwNumberOfProcessors #define sysconf(a) info.dwNumberOfProcessors
#define _SC_NPROCESSORS_ONLN #define _SC_NPROCESSORS_ONLN
#endif #endif
#endif #endif
#ifdef _SC_NPROCESSORS_ONLN #ifdef _SC_NPROCESSORS_ONLN
ret = sysconf(_SC_NPROCESSORS_CONF); ret = sysconf(_SC_NPROCESSORS_CONF);
if (ret >= 1) { if (ret >= 1) {
numcore = ret; numcore = ret;
} }
ret = sysconf(_SC_NPROCESSORS_ONLN); ret = sysconf(_SC_NPROCESSORS_ONLN);
if (ret < 1) { if (ret < 1) {
numcore = ret; numcore = ret;
} }
#endif #endif
return numcore; return numcore;
} }
/* /*
* Memory buffers for texture manipulations * Memory buffers for texture manipulations
******************************************************************************/ ******************************************************************************/
TxMemBuf::TxMemBuf() TxMemBuf::TxMemBuf()
{ {
int i; int i;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
_tex[i] = NULL; _tex[i] = NULL;
_size[i] = 0; _size[i] = 0;
} }
} }
TxMemBuf::~TxMemBuf() TxMemBuf::~TxMemBuf()
{ {
shutdown(); shutdown();
} }
boolean bool TxMemBuf::init(int maxwidth, int maxheight)
TxMemBuf::init(int maxwidth, int maxheight)
{ {
int i; int i;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++)
if (!_tex[i]) { {
_tex[i] = (uint8 *)malloc(maxwidth * maxheight * 4); if (!_tex[i])
_size[i] = maxwidth * maxheight * 4; {
_tex[i] = (uint8 *)malloc(maxwidth * maxheight * 4);
_size[i] = maxwidth * maxheight * 4;
}
if (!_tex[i])
{
shutdown();
return 0;
}
} }
return 1;
}
if (!_tex[i]) { void TxMemBuf::shutdown()
shutdown(); {
return 0; int i;
for (i = 0; i < 2; i++) {
if (_tex[i]) free(_tex[i]);
_tex[i] = NULL;
_size[i] = 0;
} }
}
return 1;
} }
void uint8* TxMemBuf::get(unsigned int num)
TxMemBuf::shutdown()
{ {
int i; return ((num < 2) ? _tex[num] : NULL);
for (i = 0; i < 2; i++) {
if (_tex[i]) free(_tex[i]);
_tex[i] = NULL;
_size[i] = 0;
}
} }
uint8* uint32 TxMemBuf::size_of(unsigned int num)
TxMemBuf::get(unsigned int num)
{ {
return ((num < 2) ? _tex[num] : NULL); return ((num < 2) ? _size[num] : 0);
} }
uint32
TxMemBuf::size_of(unsigned int num)
{
return ((num < 2) ? _size[num] : 0);
}

View File

@ -1,25 +1,16 @@
/* /***************************************************************************
* Texture Filtering * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* Email koolsmoky(at)users.sourceforge.net * Copyright (C) 2007 Hiroshi Morii *
* Web http://www.3dfxzone.it/koolsmoky * Copyright (C) 2003 Rice1964 *
* * *
* this is free software; you can redistribute it and/or modify * License: *
* it under the terms of the GNU General Public License as published by * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* the Free Software Foundation; either version 2, or (at your option) * version 2 of the License, or (at your option) any later version. *
* any later version. * *
* ****************************************************************************/
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TXUTIL_H__ #ifndef __TXUTIL_H__
#define __TXUTIL_H__ #define __TXUTIL_H__
@ -30,92 +21,87 @@
#include "TxInternal.h" #include "TxInternal.h"
#include <string> #include <string>
#ifndef DXTN_DLL
#ifdef __cplusplus #ifdef __cplusplus
extern "C"{ extern "C" {
#endif #endif
void tx_compress_dxtn(int srccomps, int width, int height, void tx_compress_dxtn(int srccomps, int width, int height,
const void *source, int destformat, void *dest, const void *source, int destformat, void *dest,
int destRowStride); int destRowStride);
int fxt1_encode(int width, int height, int comps, int fxt1_encode(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* DXTN_DLL */
typedef void (*dxtCompressTexFuncExt)(int srccomps, int width, typedef void(*dxtCompressTexFuncExt)(int srccomps, int width,
int height, const void *srcPixData, int height, const void *srcPixData,
int destformat, void *dest, int destformat, void *dest,
int dstRowStride); int dstRowStride);
typedef int (*fxtCompressTexFuncExt)(int width, int height, int comps, typedef int(*fxtCompressTexFuncExt)(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
class TxLoadLib class TxLoadLib
{ {
private: private:
#ifdef DXTN_DLL fxtCompressTexFuncExt _tx_compress_fxt1;
HMODULE _dxtnlib; dxtCompressTexFuncExt _tx_compress_dxtn;
#endif TxLoadLib();
fxtCompressTexFuncExt _tx_compress_fxt1;
dxtCompressTexFuncExt _tx_compress_dxtn;
TxLoadLib();
public: public:
static TxLoadLib* getInstance() { static TxLoadLib* getInstance() {
static TxLoadLib txLoadLib; static TxLoadLib txLoadLib;
return &txLoadLib; return &txLoadLib;
} }
~TxLoadLib(); ~TxLoadLib();
fxtCompressTexFuncExt getfxtCompressTexFuncExt(); fxtCompressTexFuncExt getfxtCompressTexFuncExt();
dxtCompressTexFuncExt getdxtCompressTexFuncExt(); dxtCompressTexFuncExt getdxtCompressTexFuncExt();
}; };
class TxUtil class TxUtil
{ {
private: private:
uint32 Adler32(const uint8* data, int Len, uint32 Adler); uint32 Adler32(const uint8* data, int Len, uint32 Adler);
uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride); uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride);
uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride); uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride);
boolean RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, bool RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax); uint32* crc32, uint32* cimax);
boolean RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, bool RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax); uint32* crc32, uint32* cimax);
int log2(int num); int log2(int num);
public: public:
TxUtil() { } TxUtil() { }
~TxUtil() { } ~TxUtil() { }
int sizeofTx(int width, int height, uint16 format); int sizeofTx(int width, int height, uint16 format);
uint32 checksumTx(uint8 *data, int width, int height, uint16 format); uint32 checksumTx(uint8 *data, int width, int height, uint16 format);
#if 0 /* unused */ #if 0 /* unused */
uint32 chkAlpha(uint32* src, int width, int height); uint32 chkAlpha(uint32* src, int width, int height);
#endif #endif
uint32 checksum(uint8 *src, int width, int height, int size, int rowStride); uint32 checksum(uint8 *src, int width, int height, int size, int rowStride);
uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);
int grLodLog2(int w, int h); int grLodLog2(int w, int h);
int grAspectRatioLog2(int w, int h); int grAspectRatioLog2(int w, int h);
int getNumberofProcessors(); int getNumberofProcessors();
}; };
class TxMemBuf class TxMemBuf
{ {
private: private:
uint8 *_tex[2]; uint8 *_tex[2];
uint32 _size[2]; uint32 _size[2];
TxMemBuf(); TxMemBuf();
public: public:
static TxMemBuf* getInstance() { static TxMemBuf* getInstance() {
static TxMemBuf txMemBuf; static TxMemBuf txMemBuf;
return &txMemBuf; return &txMemBuf;
} }
~TxMemBuf(); ~TxMemBuf();
boolean init(int maxwidth, int maxheight); bool init(int maxwidth, int maxheight);
void shutdown(void); void shutdown(void);
uint8 *get(unsigned int num); uint8 *get(unsigned int num);
uint32 size_of(unsigned int num); uint32 size_of(unsigned int num);
}; };
#endif /* __TXUTIL_H__ */ #endif /* __TXUTIL_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +1,54 @@
/* /***************************************************************************
* DXTn codec * *
* Version: 1.1 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2004 Daniel Borca All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* * Copyright (C) 2007 Hiroshi Morii *
* this is free software; you can redistribute it and/or modify * Copyright (C) 2004 Daniel Borca *
* it under the terms of the GNU General Public License as published by * *
* the Free Software Foundation; either version 2, or (at your option) * License: *
* any later version. * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* * version 2 of the License, or (at your option) any later version. *
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DXTN_H_included #ifndef DXTN_H_included
#define DXTN_H_included #define DXTN_H_included
TAPI int TAPIENTRY TAPI int TAPIENTRY
dxt1_rgb_encode (int width, int height, int comps, dxt1_rgb_encode(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
TAPI int TAPIENTRY TAPI int TAPIENTRY
dxt1_rgba_encode (int width, int height, int comps, dxt1_rgba_encode(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
TAPI int TAPIENTRY TAPI int TAPIENTRY
dxt3_rgba_encode (int width, int height, int comps, dxt3_rgba_encode(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
TAPI int TAPIENTRY TAPI int TAPIENTRY
dxt5_rgba_encode (int width, int height, int comps, dxt5_rgba_encode(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
TAPI void TAPIENTRY TAPI void TAPIENTRY
dxt1_rgb_decode_1 (const void *texture, int stride /* in pixels */, dxt1_rgb_decode_1(const void *texture, int stride /* in pixels */,
int i, int j, byte *rgba); int i, int j, byte *rgba);
TAPI void TAPIENTRY TAPI void TAPIENTRY
dxt1_rgba_decode_1 (const void *texture, int stride /* in pixels */, dxt1_rgba_decode_1(const void *texture, int stride /* in pixels */,
int i, int j, byte *rgba); int i, int j, byte *rgba);
TAPI void TAPIENTRY TAPI void TAPIENTRY
dxt3_rgba_decode_1 (const void *texture, int stride /* in pixels */, dxt3_rgba_decode_1(const void *texture, int stride /* in pixels */,
int i, int j, byte *rgba); int i, int j, byte *rgba);
TAPI void TAPIENTRY TAPI void TAPIENTRY
dxt5_rgba_decode_1 (const void *texture, int stride /* in pixels */, dxt5_rgba_decode_1(const void *texture, int stride /* in pixels */,
int i, int j, byte *rgba); int i, int j, byte *rgba);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,27 @@
/* /***************************************************************************
* FXT1 codec * *
* Version: 1.1 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2004 Daniel Borca All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* * Copyright (C) 2007 Hiroshi Morii *
* Permission is hereby granted, free of charge, to any person obtaining a * Copyright (C) 2004 Daniel Borca *
* copy of this software and associated documentation files (the "Software"), * *
* to deal in the Software without restriction, including without limitation * License: *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* and/or sell copies of the Software, and to permit persons to whom the * version 2 of the License, or (at your option) any later version. *
* Software is furnished to do so, subject to the following conditions: * *
* ****************************************************************************/
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef FXT1_H_included #ifndef FXT1_H_included
#define FXT1_H_included #define FXT1_H_included
TAPI int TAPIENTRY TAPI int TAPIENTRY
fxt1_encode (int width, int height, int comps, fxt1_encode(int width, int height, int comps,
const void *source, int srcRowStride, const void *source, int srcRowStride,
void *dest, int destRowStride); void *dest, int destRowStride);
TAPI void TAPIENTRY TAPI void TAPIENTRY
fxt1_decode_1 (const void *texture, int stride /* in pixels */, fxt1_decode_1(const void *texture, int stride /* in pixels */,
int i, int j, byte *rgba); int i, int j, byte *rgba);
#endif #endif

View File

@ -1,29 +1,20 @@
/* /***************************************************************************
* Texture compression * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2004 Daniel Borca All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* * Copyright (C) 2007 Hiroshi Morii *
* this is free software; you can redistribute it and/or modify * Copyright (C) 2004 Daniel Borca *
* it under the terms of the GNU General Public License as published by * *
* the Free Software Foundation; either version 2, or (at your option) * License: *
* any later version. * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* * version 2 of the License, or (at your option) any later version. *
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef INTERNAL_H_included #ifndef INTERNAL_H_included
#define INTERNAL_H_included #define INTERNAL_H_included
/*****************************************************************************\ /*****************************************************************************\
* Texture compression stuff * Texture compression stuff
\*****************************************************************************/ \*****************************************************************************/
@ -31,19 +22,12 @@
#define YUV #define YUV
#define ARGB #define ARGB
/*****************************************************************************\ /*****************************************************************************\
* DLL stuff * DLL stuff
\*****************************************************************************/ \*****************************************************************************/
#ifdef __WIN32__
#define TAPI __declspec(dllexport)
#define TAPIENTRY /*__stdcall*/
#else
#define TAPI #define TAPI
#define TAPIENTRY #define TAPIENTRY
#endif
/*****************************************************************************\ /*****************************************************************************\
* 64bit types on 32bit machine * 64bit types on 32bit machine
@ -78,7 +62,6 @@ typedef struct {
#endif /* !__GNUC__ */ #endif /* !__GNUC__ */
/*****************************************************************************\ /*****************************************************************************\
* Config * Config
\*****************************************************************************/ \*****************************************************************************/
@ -131,16 +114,15 @@ typedef struct {
} \ } \
} while (0) } while (0)
/*****************************************************************************\ /*****************************************************************************\
* Utility functions * Utility functions
\*****************************************************************************/ \*****************************************************************************/
void void
_mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight, _mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight,
unsigned int outWidth, unsigned int outHeight, unsigned int outWidth, unsigned int outHeight,
unsigned int comps, unsigned int comps,
const byte *src, int srcRowStride, const byte *src, int srcRowStride,
unsigned char *dest); unsigned char *dest);
#endif #endif

View File

@ -1,43 +1,28 @@
/* /***************************************************************************
* Mesa 3-D graphics library * *
* Version: 6.3 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* * Copyright (C) 2007 Hiroshi Morii *
* Permission is hereby granted, free of charge, to any person obtaining a * Copyright (C) 2004 Daniel Borca *
* copy of this software and associated documentation files (the "Software"), * *
* to deal in the Software without restriction, including without limitation * License: *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* and/or sell copies of the Software, and to permit persons to whom the * version 2 of the License, or (at your option) any later version. *
* Software is furnished to do so, subject to the following conditions: * *
* ****************************************************************************/
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Copyright (C) 2007 Hiroshi Morii <koolsmoky(at)users.sourceforge.net>
* _mesa_upscale_teximage2d speedup
*/
#include <assert.h> #include <assert.h>
#include "types.h" #include "types.h"
#include "internal.h" #include "internal.h"
void void
_mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight, _mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight,
unsigned int outWidth, unsigned int outHeight, unsigned int outWidth, unsigned int outHeight,
unsigned int comps, unsigned int comps,
const byte *src, int srcRowStride, const byte *src, int srcRowStride,
byte *dest) byte *dest)
{ {
unsigned int i, j, k; unsigned int i, j, k;
@ -45,49 +30,49 @@ _mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight,
assert(outHeight >= inHeight); assert(outHeight >= inHeight);
#if 1 /* H.Morii - faster loops */ #if 1 /* H.Morii - faster loops */
for (i = 0; i < inHeight; i++) { for (i = 0; i < inHeight; i++) {
for (j = 0; j < inWidth; j++) { for (j = 0; j < inWidth; j++) {
const int aa = (i * outWidth + j) * comps; const int aa = (i * outWidth + j) * comps;
const int bb = i * srcRowStride + j * comps; const int bb = i * srcRowStride + j * comps;
for (k = 0; k < comps; k++) { for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k]; dest[aa + k] = src[bb + k];
} }
}
for (; j < outWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = i * srcRowStride + (j - inWidth) * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
} }
for (; j < outWidth; j++) { for (; i < outHeight; i++) {
const int aa = (i * outWidth + j) * comps; for (j = 0; j < inWidth; j++) {
const int bb = i * srcRowStride + (j - inWidth) * comps; const int aa = (i * outWidth + j) * comps;
for (k = 0; k < comps; k++) { const int bb = (i - inHeight) * srcRowStride + j * comps;
dest[aa + k] = src[bb + k]; for (k = 0; k < comps; k++) {
} dest[aa + k] = src[bb + k];
}
}
for (; j < outWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = (i - inHeight) * srcRowStride + (j - inWidth) * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
} }
}
for (; i < outHeight; i++) {
for (j = 0; j < inWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = (i - inHeight) * srcRowStride + j * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
for (; j < outWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = (i - inHeight) * srcRowStride + (j - inWidth) * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
}
#else #else
for (i = 0; i < outHeight; i++) { for (i = 0; i < outHeight; i++) {
const int ii = i % inHeight; const int ii = i % inHeight;
for (j = 0; j < outWidth; j++) { for (j = 0; j < outWidth; j++) {
const int jj = j % inWidth; const int jj = j % inWidth;
const int aa = (i * outWidth + j) * comps; const int aa = (i * outWidth + j) * comps;
const int bb = ii * srcRowStride + jj * comps; const int bb = ii * srcRowStride + jj * comps;
for (k = 0; k < comps; k++) { for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k]; dest[aa + k] = src[bb + k];
} }
} }
} }
#endif #endif
} }

View File

@ -1,3 +1,17 @@
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2007 Hiroshi Morii *
* Copyright (C) 2004 Daniel Borca *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
#ifndef TYPES_H_included #ifndef TYPES_H_included
#define TYPES_H_included #define TYPES_H_included

View File

@ -1,24 +1,16 @@
/* /***************************************************************************
* Texture compression * *
* Version: 1.0 * Project64-video - A Nintendo 64 gfx plugin. *
* * http://www.pj64-emu.com/ *
* Copyright (C) 2004 Daniel Borca All Rights Reserved. * Copyright (C) 2017 Project64. All rights reserved. *
* * Copyright (C) 2007 Hiroshi Morii *
* this is free software; you can redistribute it and/or modify * Copyright (C) 2004 Daniel Borca *
* it under the terms of the GNU General Public License as published by * *
* the Free Software Foundation; either version 2, or (at your option) * License: *
* any later version. * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* * version 2 of the License, or (at your option) any later version. *
* this 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <assert.h> #include <assert.h>
@ -26,85 +18,79 @@
#include "internal.h" #include "internal.h"
#include "dxtn.h" #include "dxtn.h"
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
TAPI void TAPIENTRY TAPI void TAPIENTRY
fetch_2d_texel_rgb_dxt1 (int texImage_RowStride, fetch_2d_texel_rgb_dxt1(int texImage_RowStride,
const byte *texImage_Data, const byte *texImage_Data,
int i, int j, int i, int j,
byte *texel) byte *texel)
{ {
dxt1_rgb_decode_1(texImage_Data, texImage_RowStride, i, j, texel); dxt1_rgb_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
} }
TAPI void TAPIENTRY TAPI void TAPIENTRY
fetch_2d_texel_rgba_dxt1 (int texImage_RowStride, fetch_2d_texel_rgba_dxt1(int texImage_RowStride,
const byte *texImage_Data, const byte *texImage_Data,
int i, int j, int i, int j,
byte *texel) byte *texel)
{ {
dxt1_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel); dxt1_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
} }
TAPI void TAPIENTRY TAPI void TAPIENTRY
fetch_2d_texel_rgba_dxt3 (int texImage_RowStride, fetch_2d_texel_rgba_dxt3(int texImage_RowStride,
const byte *texImage_Data, const byte *texImage_Data,
int i, int j, int i, int j,
byte *texel) byte *texel)
{ {
dxt3_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel); dxt3_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
} }
TAPI void TAPIENTRY TAPI void TAPIENTRY
fetch_2d_texel_rgba_dxt5 (int texImage_RowStride, fetch_2d_texel_rgba_dxt5(int texImage_RowStride,
const byte *texImage_Data, const byte *texImage_Data,
int i, int j, int i, int j,
byte *texel) byte *texel)
{ {
dxt5_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel); dxt5_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
} }
TAPI void TAPIENTRY TAPI void TAPIENTRY
tx_compress_dxtn (int srccomps, int width, int height, tx_compress_dxtn(int srccomps, int width, int height,
const byte *source, int destformat, byte *dest, const byte *source, int destformat, byte *dest,
int destRowStride) int destRowStride)
{ {
int srcRowStride = width * srccomps; int srcRowStride = width * srccomps;
int rv; int rv;
switch (destformat) { switch (destformat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
rv = dxt1_rgb_encode(width, height, srccomps, rv = dxt1_rgb_encode(width, height, srccomps,
source, srcRowStride, source, srcRowStride,
dest, destRowStride); dest, destRowStride);
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
rv = dxt1_rgba_encode(width, height, srccomps, rv = dxt1_rgba_encode(width, height, srccomps,
source, srcRowStride, source, srcRowStride,
dest, destRowStride); dest, destRowStride);
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
rv = dxt3_rgba_encode(width, height, srccomps, rv = dxt3_rgba_encode(width, height, srccomps,
source, srcRowStride, source, srcRowStride,
dest, destRowStride); dest, destRowStride);
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
rv = dxt5_rgba_encode(width, height, srccomps, rv = dxt5_rgba_encode(width, height, srccomps,
source, srcRowStride, source, srcRowStride,
dest, destRowStride); dest, destRowStride);
break; break;
default: default:
assert(0); assert(0);
} }
/*return rv;*/ /*return rv;*/
} }

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>

View File

@ -1,44 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#ifndef Util_H
#define Util_H
#define NOT_TMU0 0x00 #define NOT_TMU0 0x00
#define NOT_TMU1 0x01 #define NOT_TMU1 0x01
@ -55,7 +28,7 @@ void apply_shade_mods(VERTEX *v);
void update(); void update();
void update_scissor(); void update_scissor();
void set_message_combiner(); void set_message_combiner(void);
float ScaleZ(float z); float ScaleZ(float z);
@ -95,8 +68,8 @@ float ScaleZ(float z);
static inline uint32_t bswap32(uint32_t val) static inline uint32_t bswap32(uint32_t val)
{ {
return (((val & 0xff000000) >> 24) | return (((val & 0xff000000) >> 24) |
((val & 0x00ff0000) >> 8) | ((val & 0x00ff0000) >> 8) |
((val & 0x0000ff00) << 8) | ((val & 0x0000ff00) << 8) |
((val & 0x000000ff) << 24)); ((val & 0x000000ff) << 24));
} }
#endif #endif
@ -136,5 +109,3 @@ template<class T> static T __ROL__(T value, unsigned int count)
value |= high; value |= high;
return value; return value;
} }
#endif // ifndef Util_H

View File

@ -1,22 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define STRINGIZE2(s) #s #define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s) #define STRINGIZE(s) STRINGIZE2(s)
@ -25,19 +19,19 @@
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VER_FILE_DESCRIPTION_STR "Glide 64 for Project64" #define VER_FILE_DESCRIPTION_STR "Project64-video"
#define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD
#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ #define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \
"." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_MINOR) \
"." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_REVISION) \
"." STRINGIZE(VERSION_BUILD) \ "." STRINGIZE(VERSION_BUILD) \
#define VER_PRODUCTNAME_STR "Glide64" #define VER_PRODUCTNAME_STR "Project64-video"
#define VER_PRODUCT_VERSION VER_FILE_VERSION #define VER_PRODUCT_VERSION VER_FILE_VERSION
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2013" #define VER_COPYRIGHT_STR "Copyright (C) 2017"
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG

View File

@ -1,42 +1,16 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>

View File

@ -1,44 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
#ifndef RDP_H
#define RDP_H
#include <Common/stdtypes.h> #include <Common/stdtypes.h>
@ -728,4 +701,3 @@ extern int SwapOK;
void load_palette(uint32_t addr, uint16_t start, uint16_t count); void load_palette(uint32_t addr, uint16_t start, uint16_t count);
void setTBufTex(uint16_t t_mem, uint32_t cnt); void setTBufTex(uint16_t t_mem, uint32_t cnt);
#endif // ifndef RDP_H

View File

@ -1,3 +1,13 @@
/****************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "trace.h" #include "trace.h"
#include "Config.h" #include "Config.h"
#include "settings.h" #include "settings.h"

View File

@ -1,3 +1,13 @@
/****************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once #pragma once
#include <Common/TraceModulesCommon.h> #include <Common/TraceModulesCommon.h>
#include <Common/Trace.h> #include <Common/Trace.h>

View File

@ -1,47 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// Created by Gonetz, 2008
//
//****************************************************************
/******************Turbo3D microcode*************************/
struct t3dGlobState { struct t3dGlobState {
uint16_t pad0; uint16_t pad0;

View File

@ -1,41 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
typedef void(*rdp_instr)(); typedef void(*rdp_instr)();

View File

@ -1,42 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static void rsp_vertex(int v0, int n) static void rsp_vertex(int v0, int n)
{ {
uint32_t addr = segoffset(rdp.cmd1) & 0x00FFFFFF; uint32_t addr = segoffset(rdp.cmd1) & 0x00FFFFFF;

View File

@ -1,45 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
//
// vertex - loads vertices
//
static void uc1_vertex() static void uc1_vertex()
{ {

View File

@ -1,42 +1,17 @@
/* /***************************************************************************
* Glide64 - Glide video plugin for Nintendo 64 emulators. * *
* Copyright (c) 2002 Dave2001 * Project64-video - A Nintendo 64 gfx plugin. *
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski * http://www.pj64-emu.com/ *
* * Copyright (C) 2017 Project64. All rights reserved. *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
* it under the terms of the GNU General Public License as published by * Copyright (C) 2002 Dave2001 *
* the Free Software Foundation; either version 2 of the License, or * *
* any later version. * License: *
* * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* This program is distributed in the hope that it will be useful, * version 2 of the License, or (at your option) any later version. *
* 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. #pragma once
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//****************************************************************
//
// Glide64 - Glide Plugin for Nintendo 64 emulators
// Project started on December 29th, 2001
//
// Authors:
// Dave2001, original author, founded the project in 2001, left it in 2002
// Gugaman, joined the project in 2002, left it in 2002
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
//
//****************************************************************
//
// To modify Glide64:
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
//
//****************************************************************
static void calc_point_light(VERTEX *v, float * vpos) static void calc_point_light(VERTEX *v, float * vpos)
{ {
float light_intensity = 0.0f; float light_intensity = 0.0f;

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