[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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 "Gfx_1.3.h"
extern "C" {
#ifndef NOSSE

View File

@ -1,54 +1,28 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
void calc_light (VERTEX *v);
void calc_linear (VERTEX *v);
void calc_sphere (VERTEX *v);
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;
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 InverseTransformVector;
typedef float (*DOTPRODUCT)(register float *v1, register float *v2);
typedef float(*DOTPRODUCT)(register float *v1, register float *v2);
extern DOTPRODUCT DotProduct;
typedef void (*NORMALIZEVECTOR)(float *v);
typedef void(*NORMALIZEVECTOR)(float *v);
extern NORMALIZEVECTOR NormalizeVector;

View File

@ -1,11 +1,12 @@
/****************************************************************************
/***************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* 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 ANDROID

View File

@ -1,48 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
//*
/***************************************************************************
* *
* 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 CRC32_POLYNOMIAL 0x04C11DB7
unsigned int CRCTable[256];

View File

@ -1,47 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
void CRC_BuildTable();

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 <string.h>
#include "Gfx_1.3.h"
#include "Util.h"

View File

@ -1,41 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#ifndef COMBINE_H
#define COMBINE_H

View File

@ -1,49 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
/***************************************************************************
* *
* 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 "Gfx_1.3.h"
#include "DepthBufferRender.h"
#include "Config.h"

View File

@ -1,46 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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
#ifdef _WIN32

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 <stdarg.h>
#include <string.h>

View File

@ -1,40 +1,14 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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, ...);
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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 "Gfx_1.3.h"
#include "rdp.h"
#include "DepthBufferRender.h"
@ -56,11 +22,11 @@ void ZLUT_init()
if (zLUT)
return;
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))
while ((i & testbit) && (exponent < 7))
{
exponent++;
testbit = 1 << (17 - exponent);
@ -78,8 +44,8 @@ void ZLUT_release()
}
static vertexi * max_vtx; // Max y vertex (ending vertex)
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 * start_vtx, *end_vtx; // First and last vertex in array
static vertexi * right_vtx, *left_vtx; // Current right and left vertex
static int right_height, left_height;
static int right_x, right_dxdy, left_x, left_dxdy;
@ -111,8 +77,8 @@ static void RightSection(void)
{
// Walk backwards trough the vertex array
vertexi * v2, * v1 = right_vtx;
if(right_vtx > start_vtx) v2 = right_vtx-1;
vertexi * v2, *v1 = right_vtx;
if (right_vtx > start_vtx) v2 = right_vtx - 1;
else v2 = end_vtx; // Wrap to end of array
right_vtx = v2;
@ -122,11 +88,11 @@ static void RightSection(void)
// Calculate number of scanlines in this section
right_height = iceil(v2->y) - iceil(v1->y);
if(right_height <= 0) return;
if (right_height <= 0) return;
// Guard against possible div overflows
if(right_height > 1) {
if (right_height > 1) {
// OK, no worries, we have a section that is at least
// one pixel high. Calculate slope as usual.
@ -152,8 +118,8 @@ static void LeftSection(void)
{
// Walk forward trough the vertex array
vertexi * v2, * v1 = left_vtx;
if(left_vtx < end_vtx) v2 = left_vtx+1;
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;
@ -163,11 +129,11 @@ static void LeftSection(void)
// Calculate number of scanlines in this section
left_height = iceil(v2->y) - iceil(v1->y);
if(left_height <= 0) return;
if (left_height <= 0) return;
// Guard against possible div overflows
if(left_height > 1) {
if (left_height > 1) {
// OK, no worries, we have a section that is at least
// one pixel high. Calculate slope as usual.
@ -192,7 +158,6 @@ static void LeftSection(void)
left_z = v1->z + imul16(prestep, left_dzdy);
}
void Rasterize(vertexi * vtx, int vertices, int dzdx)
{
start_vtx = vtx; // First vertex in array
@ -208,13 +173,13 @@ void Rasterize(vertexi * vtx, int vertices, int dzdx)
vtx++;
for(int n=1; n<vertices; n++) {
if(vtx->y < min_y) {
for (int n = 1; n < vertices; n++) {
if (vtx->y < min_y) {
min_y = vtx->y;
min_vtx = vtx;
}
else
if(vtx->y > max_y) {
if (vtx->y > max_y) {
max_y = vtx->y;
max_vtx = vtx;
}
@ -226,38 +191,37 @@ void Rasterize(vertexi * vtx, int vertices, int dzdx)
left_vtx = min_vtx; // Left side starting vertex
right_vtx = min_vtx; // Right side starting vertex
end_vtx = vtx-1; // Last vertex in array
end_vtx = vtx - 1; // Last vertex in array
// Search for the first usable right section
do {
if(right_vtx == max_vtx) return;
if (right_vtx == max_vtx) return;
RightSection();
} while(right_height <= 0);
} while (right_height <= 0);
// Search for the first usable left section
do {
if(left_vtx == max_vtx) return;
if (left_vtx == max_vtx) return;
LeftSection();
} while(left_height <= 0);
} while (left_height <= 0);
uint16_t * destptr = (uint16_t*)(gfx.RDRAM+rdp.zimg);
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(;;)
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)
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) {
if (width > 0 && y1 >= (int)rdp.scissor_o.ul_y) {
// Prestep initial z
int prestep = (x1 << 16) - left_x;
@ -270,12 +234,12 @@ void Rasterize(vertexi * vtx, int vertices, int dzdx)
uint16_t encodedZ;
for (int x = 0; x < width; x++)
{
trueZ = z/8192;
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])
idx = (shift + x) ^ 1;
if (encodedZ < destptr[idx])
destptr[idx] = encodedZ;
z += dzdx;
}
@ -287,22 +251,22 @@ void Rasterize(vertexi * vtx, int vertices, int dzdx)
// Scan the right side
if(--right_height <= 0) { // End of this section?
if (--right_height <= 0) { // End of this section?
do {
if(right_vtx == max_vtx) return;
if (right_vtx == max_vtx) return;
RightSection();
} while(right_height <= 0);
} while (right_height <= 0);
}
else
right_x += right_dxdy;
// Scan the left side
if(--left_height <= 0) { // End of this section?
if (--left_height <= 0) { // End of this section?
do {
if(left_vtx == max_vtx) return;
if (left_vtx == max_vtx) return;
LeftSection();
} while(left_height <= 0);
} while (left_height <= 0);
}
else {
left_x += left_dxdy;

View File

@ -1,53 +1,22 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#ifndef DEPTH_BUFFER_RENDER_H
#define DEPTH_BUFFER_RENDER_H
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
};

View File

@ -1,26 +1,15 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2007 Hiroshi Morii *
* *
* 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 <memory.h>
#include <stdlib.h>
#include "Ext_TxFilter.h"

View File

@ -1,25 +1,15 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2007 Hiroshi Morii *
* *
* 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 __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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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 "Gfx_1.3.h"
#include "FBtoScreen.h"
#include "TexCache.h"

View File

@ -1,46 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#ifndef FBtoSCREEN_H
#define FBtoSCREEN_H

View File

@ -1,67 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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__
/***************************************************************************
* *
* 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
#include "winlnxdefs.h"
#include <stdio.h>
@ -533,4 +483,3 @@ extern "C" {
#if defined(__cplusplus)
}
#endif
#endif //_GFX_H_INCLUDED__

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 <string.h>
#include <Common/StdString.h>
#include "Gfx_1.3.h"

View File

@ -1,41 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 <Common/stdtypes.h>
#include <string.h>
typedef uint32_t uint32_t;

View File

@ -1,46 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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 <string.h>
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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
//****************************************************************
// 8-bit Horizontal Mirror

View File

@ -1,23 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/***************************************************************************
* *
* 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
#include <windows.h>
#else // _WIN32

View File

@ -1,22 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/***************************************************************************
* *
* 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 <string.h>

View File

@ -1,22 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/***************************************************************************
* *
* 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

View File

@ -1,23 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/***************************************************************************
* *
* 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
#include <windows.h>
#else // _WIN32

View File

@ -1,22 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/***************************************************************************
* *
* 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 <GLES2/gl2.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
#include <GLES2/gl2.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
#include <windows.h>
#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>
#ifdef _WIN32
#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
#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
#include <windows.h>
#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
//#define VPDEBUG
@ -260,4 +272,3 @@ FX_ENTRY void FX_CALL
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/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* 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/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* 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 <Settings/Settings.h>
#include <Project64-video/trace.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
#include <string>
@ -27,37 +37,37 @@ public:
enum hacks_t
{
hack_ASB = (1<<0), //All-Star Baseball games
hack_Banjo2 = (1<<1), //Banjo Tooie
hack_BAR = (1<<2), //Beetle Adventure Racing
hack_Chopper = (1<<3), //Chopper Attack
hack_Diddy = (1<<4), //diddy kong racing
hack_Fifa98 = (1<<5), //FIFA - Road to World Cup 98
hack_Fzero = (1<<6), //F-Zero
hack_GoldenEye = (1<<7), //Golden Eye
hack_Hyperbike = (1<<8), //Top Gear Hyper Bike
hack_ISS64 = (1<<9), //International Superstar Soccer 64
hack_KI = (1<<10), //Killer Instinct
hack_Knockout = (1<<11), //Knockout Kings 2000
hack_Lego = (1<<12), //LEGO Racers
hack_MK64 = (1<<13), //Mario Kart
hack_Megaman = (1<<14), //Megaman64
hack_Makers = (1<<15), //Mischief-makers
hack_WCWnitro = (1<<16), //WCW Nitro
hack_Ogre64 = (1<<17), //Ogre Battle 64
hack_Pilotwings = (1<<18), //Pilotwings
hack_PMario = (1<<19), //Paper Mario
hack_PPL = (1<<20), //pokemon puzzle league requires many special fixes
hack_RE2 = (1<<21), //Resident Evil 2
hack_Starcraft = (1<<22), //StarCraft64
hack_Supercross = (1<<23), //Supercross 2000
hack_TGR = (1<<24), //Top Gear Rally
hack_TGR2 = (1<<25), //Top Gear Rally 2
hack_Tonic = (1<<26), //tonic trouble
hack_Winback = (1<<27), //WinBack - Covert Operations
hack_Yoshi = (1<<28), //Yoshi Story
hack_Zelda = (1<<29), //zeldas hacks
hack_OoT = (1<<30), //zelda OoT hacks
hack_ASB = (1 << 0), //All-Star Baseball games
hack_Banjo2 = (1 << 1), //Banjo Tooie
hack_BAR = (1 << 2), //Beetle Adventure Racing
hack_Chopper = (1 << 3), //Chopper Attack
hack_Diddy = (1 << 4), //diddy kong racing
hack_Fifa98 = (1 << 5), //FIFA - Road to World Cup 98
hack_Fzero = (1 << 6), //F-Zero
hack_GoldenEye = (1 << 7), //Golden Eye
hack_Hyperbike = (1 << 8), //Top Gear Hyper Bike
hack_ISS64 = (1 << 9), //International Superstar Soccer 64
hack_KI = (1 << 10), //Killer Instinct
hack_Knockout = (1 << 11), //Knockout Kings 2000
hack_Lego = (1 << 12), //LEGO Racers
hack_MK64 = (1 << 13), //Mario Kart
hack_Megaman = (1 << 14), //Megaman64
hack_Makers = (1 << 15), //Mischief-makers
hack_WCWnitro = (1 << 16), //WCW Nitro
hack_Ogre64 = (1 << 17), //Ogre Battle 64
hack_Pilotwings = (1 << 18), //Pilotwings
hack_PMario = (1 << 19), //Paper Mario
hack_PPL = (1 << 20), //pokemon puzzle league requires many special fixes
hack_RE2 = (1 << 21), //Resident Evil 2
hack_Starcraft = (1 << 22), //StarCraft64
hack_Supercross = (1 << 23), //Supercross 2000
hack_TGR = (1 << 24), //Top Gear Rally
hack_TGR2 = (1 << 25), //Top Gear Rally 2
hack_Tonic = (1 << 26), //tonic trouble
hack_Winback = (1 << 27), //WinBack - Covert Operations
hack_Yoshi = (1 << 28), //Yoshi Story
hack_Zelda = (1 << 29), //zeldas hacks
hack_OoT = (1 << 30), //zelda OoT hacks
};
enum AspectMode_t
@ -172,7 +182,7 @@ public:
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_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_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); }
@ -199,7 +209,7 @@ public:
inline ScreenRotate_t rotate(void) const { return m_rotate; }
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 SwapMode_t swapmode(void) const { return m_swapmode; }
inline PixelLevelOfDetail_t lodmode(void) const { return m_lodmode; }

View File

@ -1,8 +1,8 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* Copyright (C) 2017 Project64. All rights reserved. *
* *
* License: *
* 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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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 <string.h>
#include "Gfx_1.3.h"
#include "TexBuffer.h"

View File

@ -1,47 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#ifndef TEXBUFFER_H
#define TEXBUFFER_H

View File

@ -1,41 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 "Gfx_1.3.h"
#include "TexCache.h"

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#ifndef TEXCACHE_H
#define TEXCACHE_H

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
static inline void texConv_ARGB1555_ARGB4444(uint8_t *src, uint8_t *dst, int size)
{
uint32_t *v3;

View File

@ -1,41 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 "TexLoad4b.h"
#include "TexLoad8b.h"

View File

@ -1,41 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
//****************************************************************
// Size: 2, Format: 0

View File

@ -1,41 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
static void mod_tex_inter_color_using_factor(uint16_t *dst, int size, uint32_t color, uint32_t factor)
{
float percent = factor / 255.0f;

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
static void mod_tex_inter_color_using_factor_CI(uint32_t color, uint32_t factor)
{
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);
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];
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);
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];
a = (uint8_t)(col & 0x0001);

View File

@ -1,58 +1,18 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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__
#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
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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
#include <Common/stdtypes.h>
#define NO_OPTIONS 0x00000000
@ -104,29 +64,6 @@ typedef unsigned char boolean;
#define LET_TEXARTISTS_FLY 0x40000000 /* a little freedom for texture artists */
#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 {
unsigned char *data;
int width;
@ -159,11 +96,12 @@ struct GHQTexInfo {
* printf(buf);
* }
*/
#define INFO_BUF 4095
typedef void (*dispInfoFuncExt)(const char *format, ...);
typedef void(*dispInfoFuncExt)(const char *format, ...);
#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 maxbpp, /* maximum texture bpp supported by hardware */
int options, /* options */
@ -171,42 +109,40 @@ boolean ext_ghq_init(int maxwidth, /* maximum texture width supported by hardwar
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. */
dispInfoFuncExt callback /* callback function to display info */
);
);
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 srcheight, /* height of input texture */
unsigned short srcformat, /* format of input texture */
uint64 g64crc, /* glide64 crc */
uint64_t g64crc, /* glide64 crc */
GHQTexInfo *info /* output */
);
);
boolean ext_ghq_hirestex(uint64 g64crc, /* glide64 crc */
uint64 r_crc64, /* checksum hi:palette low:texture */
bool ext_ghq_hirestex(uint64_t g64crc, /* glide64 crc */
uint64_t r_crc64, /* checksum hi:palette low:texture */
unsigned short *palette, /* palette for CI textures */
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 height, /* height of texture */
int size, /* type of texture pixel */
int rowStride, /* row stride in bytes */
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 height, /* height of texture */
int rowStridePixel, /* row stride of input texture in pixels */
unsigned short gfmt, /* glide format of input texture */
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 /* __EXT_TXFILTER_H__ */

View File

@ -1,25 +1,16 @@
/*
Copyright (C) 2003 Rice1964
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Copyright (C) 2007 Hiroshi Morii <koolsmoky(at)users.sourceforge.net>
* Modified for the Texture Filtering library
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 <string.h>
#include "TextureFilters.h"
@ -62,68 +53,68 @@ void Texture2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch
for (ySrc = 0; ySrc < nHeight; ySrc++)
{
pSrc = (uint32*)(((uint8*)srcPtr)+ySrc*srcPitch);
pSrc2 = (uint32*)(((uint8*)srcPtr)+(ySrc+1)*srcPitch);
pDst1 = (uint32*)(((uint8*)dstPtr)+(ySrc*2)*dstPitch);
pDst2 = (uint32*)(((uint8*)dstPtr)+(ySrc*2+1)*dstPitch);
pSrc = (uint32*)(((uint8*)srcPtr) + ySrc*srcPitch);
pSrc2 = (uint32*)(((uint8*)srcPtr) + (ySrc + 1)*srcPitch);
pDst1 = (uint32*)(((uint8*)dstPtr) + (ySrc * 2)*dstPitch);
pDst2 = (uint32*)(((uint8*)dstPtr) + (ySrc * 2 + 1)*dstPitch);
for (xSrc = 0; xSrc < nWidth; xSrc++)
{
b1 = (pSrc[xSrc]>>0)&0xFF;
g1 = (pSrc[xSrc]>>8)&0xFF;
r1 = (pSrc[xSrc]>>16)&0xFF;
a1 = (pSrc[xSrc]>>24)&0xFF;
b1 = (pSrc[xSrc] >> 0) & 0xFF;
g1 = (pSrc[xSrc] >> 8) & 0xFF;
r1 = (pSrc[xSrc] >> 16) & 0xFF;
a1 = (pSrc[xSrc] >> 24) & 0xFF;
// Pixel 1
pDst1[xSrc*2] = pSrc[xSrc];
pDst1[xSrc * 2] = pSrc[xSrc];
// Pixel 2
if( xSrc<nWidth-1 )
if (xSrc < nWidth - 1)
{
b2 = (pSrc[xSrc+1]>>0)&0xFF;
g2 = (pSrc[xSrc+1]>>8)&0xFF;
r2 = (pSrc[xSrc+1]>>16)&0xFF;
a2 = (pSrc[xSrc+1]>>24)&0xFF;
pDst1[xSrc*2+1] = DWORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
b2 = (pSrc[xSrc + 1] >> 0) & 0xFF;
g2 = (pSrc[xSrc + 1] >> 8) & 0xFF;
r2 = (pSrc[xSrc + 1] >> 16) & 0xFF;
a2 = (pSrc[xSrc + 1] >> 24) & 0xFF;
pDst1[xSrc * 2 + 1] = DWORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2);
}
else
pDst1[xSrc*2+1] = pSrc[xSrc];
pDst1[xSrc * 2 + 1] = pSrc[xSrc];
// Pixel 3
if( ySrc<nHeight-1 )
if (ySrc < nHeight - 1)
{
b3 = (pSrc2[xSrc]>>0)&0xFF;
g3 = (pSrc2[xSrc]>>8)&0xFF;
r3 = (pSrc2[xSrc]>>16)&0xFF;
a3 = (pSrc2[xSrc]>>24)&0xFF;
pDst2[xSrc*2] = DWORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
if( xSrc<nWidth-1 )
b3 = (pSrc2[xSrc] >> 0) & 0xFF;
g3 = (pSrc2[xSrc] >> 8) & 0xFF;
r3 = (pSrc2[xSrc] >> 16) & 0xFF;
a3 = (pSrc2[xSrc] >> 24) & 0xFF;
pDst2[xSrc * 2] = DWORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2);
if (xSrc < nWidth - 1)
{
b4 = (pSrc2[xSrc+1]>>0)&0xFF;
g4 = (pSrc2[xSrc+1]>>8)&0xFF;
r4 = (pSrc2[xSrc+1]>>16)&0xFF;
a4 = (pSrc2[xSrc+1]>>24)&0xFF;
b4 = (pSrc2[xSrc + 1] >> 0) & 0xFF;
g4 = (pSrc2[xSrc + 1] >> 8) & 0xFF;
r4 = (pSrc2[xSrc + 1] >> 16) & 0xFF;
a4 = (pSrc2[xSrc + 1] >> 24) & 0xFF;
// Pixel 4
pDst2[xSrc*2+1] = DWORD_MAKE((r1+r2+r3+r4)/4, (g1+g2+g3+g4)/4, (b1+b2+b3+b4)/4, (a1+a2+a3+a4)/4);
pDst2[xSrc * 2 + 1] = DWORD_MAKE((r1 + r2 + r3 + r4) / 4, (g1 + g2 + g3 + g4) / 4, (b1 + b2 + b3 + b4) / 4, (a1 + a2 + a3 + a4) / 4);
}
else
{
// Pixel 4
pDst2[xSrc*2+1] = DWORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
pDst2[xSrc * 2 + 1] = DWORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2);
}
}
else
{
// Pixel 3
pDst2[xSrc*2] = pSrc[xSrc];
pDst2[xSrc * 2] = pSrc[xSrc];
// Pixel 4
if( xSrc<nWidth-1 )
if (xSrc < nWidth - 1)
{
pDst2[xSrc*2+1] = DWORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
pDst2[xSrc * 2 + 1] = DWORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2);
}
else
{
pDst2[xSrc*2+1] = pSrc[xSrc];
pDst2[xSrc * 2 + 1] = pSrc[xSrc];
}
}
}
@ -161,81 +152,80 @@ void Texture2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch
for (ySrc = 0; ySrc < nHeight; ySrc++)
{
pSrc = (uint16*)(((uint8*)srcPtr)+ySrc*srcPitch);
pSrc2 = (uint16*)(((uint8*)srcPtr)+(ySrc+1)*srcPitch);
pDst1 = (uint16*)(((uint8*)dstPtr)+(ySrc*2)*dstPitch);
pDst2 = (uint16*)(((uint8*)dstPtr)+(ySrc*2+1)*dstPitch);
pSrc = (uint16*)(((uint8*)srcPtr) + ySrc*srcPitch);
pSrc2 = (uint16*)(((uint8*)srcPtr) + (ySrc + 1)*srcPitch);
pDst1 = (uint16*)(((uint8*)dstPtr) + (ySrc * 2)*dstPitch);
pDst2 = (uint16*)(((uint8*)dstPtr) + (ySrc * 2 + 1)*dstPitch);
for (xSrc = 0; xSrc < nWidth; xSrc++)
{
b1 = (pSrc[xSrc]>> 0)&0xF;
g1 = (pSrc[xSrc]>> 4)&0xF;
r1 = (pSrc[xSrc]>> 8)&0xF;
a1 = (pSrc[xSrc]>>12)&0xF;
b1 = (pSrc[xSrc] >> 0) & 0xF;
g1 = (pSrc[xSrc] >> 4) & 0xF;
r1 = (pSrc[xSrc] >> 8) & 0xF;
a1 = (pSrc[xSrc] >> 12) & 0xF;
if( xSrc<nWidth-1 )
if (xSrc < nWidth - 1)
{
b2 = (pSrc[xSrc+1]>> 0)&0xF;
g2 = (pSrc[xSrc+1]>> 4)&0xF;
r2 = (pSrc[xSrc+1]>> 8)&0xF;
a2 = (pSrc[xSrc+1]>>12)&0xF;
b2 = (pSrc[xSrc + 1] >> 0) & 0xF;
g2 = (pSrc[xSrc + 1] >> 4) & 0xF;
r2 = (pSrc[xSrc + 1] >> 8) & 0xF;
a2 = (pSrc[xSrc + 1] >> 12) & 0xF;
}
if( ySrc<nHeight-1 )
if (ySrc < nHeight - 1)
{
b3 = (pSrc2[xSrc]>> 0)&0xF;
g3 = (pSrc2[xSrc]>> 4)&0xF;
r3 = (pSrc2[xSrc]>> 8)&0xF;
a3 = (pSrc2[xSrc]>>12)&0xF;
if( xSrc<nWidth-1 )
b3 = (pSrc2[xSrc] >> 0) & 0xF;
g3 = (pSrc2[xSrc] >> 4) & 0xF;
r3 = (pSrc2[xSrc] >> 8) & 0xF;
a3 = (pSrc2[xSrc] >> 12) & 0xF;
if (xSrc < nWidth - 1)
{
b4 = (pSrc2[xSrc+1]>> 0)&0xF;
g4 = (pSrc2[xSrc+1]>> 4)&0xF;
r4 = (pSrc2[xSrc+1]>> 8)&0xF;
a4 = (pSrc2[xSrc+1]>>12)&0xF;
b4 = (pSrc2[xSrc + 1] >> 0) & 0xF;
g4 = (pSrc2[xSrc + 1] >> 4) & 0xF;
r4 = (pSrc2[xSrc + 1] >> 8) & 0xF;
a4 = (pSrc2[xSrc + 1] >> 12) & 0xF;
}
}
// Pixel 1
pDst1[xSrc*2] = pSrc[xSrc];
pDst1[xSrc * 2] = pSrc[xSrc];
// Pixel 2
if( xSrc<nWidth-1 )
if (xSrc < nWidth - 1)
{
pDst1[xSrc*2+1] = WORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
pDst1[xSrc * 2 + 1] = WORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2);
}
else
pDst1[xSrc*2+1] = pSrc[xSrc];
pDst1[xSrc * 2 + 1] = pSrc[xSrc];
// Pixel 3
if( ySrc<nHeight-1 )
if (ySrc < nHeight - 1)
{
pDst2[xSrc*2] = WORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
pDst2[xSrc * 2] = WORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2);
}
else
pDst2[xSrc*2] = pSrc[xSrc];
pDst2[xSrc * 2] = pSrc[xSrc];
// Pixel 4
if( xSrc<nWidth-1 )
if (xSrc < nWidth - 1)
{
if( ySrc<nHeight-1 )
if (ySrc < nHeight - 1)
{
pDst2[xSrc*2+1] = WORD_MAKE((r1+r2+r3+r4)/4, (g1+g2+g3+g4)/4, (b1+b2+b3+b4)/4, (a1+a2+a3+a4)/4);
pDst2[xSrc * 2 + 1] = WORD_MAKE((r1 + r2 + r3 + r4) / 4, (g1 + g2 + g3 + g4) / 4, (b1 + b2 + b3 + b4) / 4, (a1 + a2 + a3 + a4) / 4);
}
else
{
pDst2[xSrc*2+1] = WORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
pDst2[xSrc * 2 + 1] = WORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2);
}
}
else
{
if( ySrc<nHeight-1 )
if (ySrc < nHeight - 1)
{
pDst2[xSrc*2+1] = WORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
pDst2[xSrc * 2 + 1] = WORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2);
}
else
pDst2[xSrc*2+1] = pSrc[xSrc];
pDst2[xSrc * 2 + 1] = pSrc[xSrc];
}
}
}
@ -253,25 +243,25 @@ void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *de
uint32 mul1, mul2, mul3, shift4;
uint32 x,y,z;
uint32 x, y, z;
uint32 *_src1, *_src2, *_src3, *_dest;
uint32 val[4];
uint32 t1,t2,t3,t4,t5,t6,t7,t8,t9;
uint32 t1, t2, t3, t4, t5, t6, t7, t8, t9;
switch( filter )
switch (filter)
{
case SHARP_FILTER_2:
mul1=1;
mul2=8;
mul3=12;
shift4=2;
mul1 = 1;
mul2 = 8;
mul3 = 12;
shift4 = 2;
break;
case SHARP_FILTER_1:
default:
mul1=1;
mul2=8;
mul3=16;
shift4=3;
mul1 = 1;
mul2 = 8;
mul3 = 16;
shift4 = 3;
break;
}
@ -285,33 +275,34 @@ void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *de
memcpy(_dest, _src1, (srcwidth << 2));
_dest += srcwidth;
// filter 2nd row to 1 row before the last
for (y = 1; y < srcheight-1; y++) {
for (y = 1; y < srcheight - 1; y++) {
// copy the first pixel
_dest[0] = *_src2;
// filter 2nd pixel to 1 pixel before last
for (x = 1; x < srcwidth-1; x++) {
for (z=0; z<4; z++) {
t1 = *((uint8*)(_src1+x-1)+z);
t2 = *((uint8*)(_src1+x )+z);
t3 = *((uint8*)(_src1+x+1)+z);
t4 = *((uint8*)(_src2+x-1)+z);
t5 = *((uint8*)(_src2+x )+z);
t6 = *((uint8*)(_src2+x+1)+z);
t7 = *((uint8*)(_src3+x-1)+z);
t8 = *((uint8*)(_src3+x )+z);
t9 = *((uint8*)(_src3+x+1)+z);
for (x = 1; x < srcwidth - 1; x++) {
for (z = 0; z < 4; z++) {
t1 = *((uint8*)(_src1 + x - 1) + z);
t2 = *((uint8*)(_src1 + x) + z);
t3 = *((uint8*)(_src1 + x + 1) + z);
t4 = *((uint8*)(_src2 + x - 1) + z);
t5 = *((uint8*)(_src2 + x) + z);
t6 = *((uint8*)(_src2 + x + 1) + z);
t7 = *((uint8*)(_src3 + x - 1) + z);
t8 = *((uint8*)(_src3 + x) + z);
t9 = *((uint8*)(_src3 + x + 1) + z);
if( (t5*mul2) > (t1+t3+t7+t9+t2+t4+t6+t8)*mul1 ) {
val[z]= ((t5*mul3) - (t1+t3+t7+t9+t2+t4+t6+t8)*mul1)>>shift4;
if ((t5*mul2) > (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) {
val[z] = ((t5*mul3) - (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) >> shift4;
if (val[z] > 0xFF) val[z] = 0xFF;
} else {
}
else {
val[z] = t5;
}
}
_dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24);
_dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24);
}
// copy the ending pixel
_dest[srcwidth-1] = *(_src3 - 1);
_dest[srcwidth - 1] = *(_src3 - 1);
// next row
_src1 += srcwidth;
_src2 += srcwidth;
@ -330,24 +321,24 @@ void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *de
uint16 mul1, mul2, mul3, shift4;
uint32 x,y,z;
uint32 x, y, z;
uint16 *_src1, *_src2, *_src3, *_dest;
uint16 val[4];
uint16 t1,t2,t3,t4,t5,t6,t7,t8,t9;
uint16 t1, t2, t3, t4, t5, t6, t7, t8, t9;
switch( filter ) {
switch (filter) {
case SHARP_FILTER_2:
mul1=1;
mul2=8;
mul3=12;
shift4=2;
mul1 = 1;
mul2 = 8;
mul3 = 12;
shift4 = 2;
break;
case SHARP_FILTER_1:
default:
mul1=1;
mul2=8;
mul3=16;
shift4=3;
mul1 = 1;
mul2 = 8;
mul3 = 16;
shift4 = 3;
break;
}
@ -361,37 +352,38 @@ void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *de
memcpy(_dest, _src1, (srcwidth << 1));
_dest += srcwidth;
// filter 2nd row to 1 row before the last
for( y = 1; y < srcheight - 1; y++) {
for (y = 1; y < srcheight - 1; y++) {
// copy the first pixel
_dest[0] = *_src2;
// filter 2nd pixel to 1 pixel before last
for( x = 1; x < srcwidth - 1; x++) {
for( z = 0; z < 4; z++ ) {
for (x = 1; x < srcwidth - 1; x++) {
for (z = 0; z < 4; z++) {
/* Hiroshi Morii <koolsmoky@users.sourceforge.net>
* Read the entire 16bit pixel and then extract the A,R,G,B components.
*/
uint32 shift = z << 2;
t1 = ((*((uint16*)(_src1+x-1))) >> shift) & 0xF;
t2 = ((*((uint16*)(_src1+x ))) >> shift) & 0xF;
t3 = ((*((uint16*)(_src1+x+1))) >> shift) & 0xF;
t4 = ((*((uint16*)(_src2+x-1))) >> shift) & 0xF;
t5 = ((*((uint16*)(_src2+x ))) >> shift) & 0xF;
t6 = ((*((uint16*)(_src2+x+1))) >> shift) & 0xF;
t7 = ((*((uint16*)(_src3+x-1))) >> shift) & 0xF;
t8 = ((*((uint16*)(_src3+x ))) >> shift) & 0xF;
t9 = ((*((uint16*)(_src3+x+1))) >> shift) & 0xF;
t1 = ((*((uint16*)(_src1 + x - 1))) >> shift) & 0xF;
t2 = ((*((uint16*)(_src1 + x))) >> shift) & 0xF;
t3 = ((*((uint16*)(_src1 + x + 1))) >> shift) & 0xF;
t4 = ((*((uint16*)(_src2 + x - 1))) >> shift) & 0xF;
t5 = ((*((uint16*)(_src2 + x))) >> shift) & 0xF;
t6 = ((*((uint16*)(_src2 + x + 1))) >> shift) & 0xF;
t7 = ((*((uint16*)(_src3 + x - 1))) >> shift) & 0xF;
t8 = ((*((uint16*)(_src3 + x))) >> shift) & 0xF;
t9 = ((*((uint16*)(_src3 + x + 1))) >> shift) & 0xF;
if( (t5*mul2) > (t1+t3+t7+t9+t2+t4+t6+t8)*mul1 ) {
val[z] = ((t5*mul3) - (t1+t3+t7+t9+t2+t4+t6+t8)*mul1)>>shift4;
if ((t5*mul2) > (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) {
val[z] = ((t5*mul3) - (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) >> shift4;
if (val[z] > 0xF) val[z] = 0xF;
} else {
}
else {
val[z] = t5;
}
}
_dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12);
_dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12);
}
// copy the ending pixel
_dest[srcwidth-1] = *(_src3 - 1);
_dest[srcwidth - 1] = *(_src3 - 1);
// next row
_src1 += srcwidth;
_src2 += srcwidth;
@ -414,36 +406,36 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d
uint32 mul1, mul2, mul3, shift4;
uint32 x,y,z;
uint32 x, y, z;
uint32 *_src1, *_src2, *_src3, *_dest;
uint32 val[4];
uint32 t1,t2,t3,t4,t5,t6,t7,t8,t9;
uint32 t1, t2, t3, t4, t5, t6, t7, t8, t9;
switch( filter ) {
switch (filter) {
case SMOOTH_FILTER_4:
mul1=1;
mul2=2;
mul3=4;
shift4=4;
mul1 = 1;
mul2 = 2;
mul3 = 4;
shift4 = 4;
break;
case SMOOTH_FILTER_3:
mul1=1;
mul2=1;
mul3=8;
shift4=4;
mul1 = 1;
mul2 = 1;
mul3 = 8;
shift4 = 4;
break;
case SMOOTH_FILTER_2:
mul1=1;
mul2=1;
mul3=2;
shift4=2;
mul1 = 1;
mul2 = 1;
mul3 = 2;
shift4 = 2;
break;
case SMOOTH_FILTER_1:
default:
mul1=1;
mul2=1;
mul3=6;
shift4=3;
mul1 = 1;
mul2 = 1;
mul3 = 6;
shift4 = 3;
break;
}
@ -459,29 +451,29 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d
memcpy(_dest, _src1, (srcwidth << 2));
_dest += srcwidth;
// filter 2nd row to 1 row before the last
for (y = 1; y < srcheight - 1; y++){
for (y = 1; y < srcheight - 1; y++) {
// copy the first pixel
_dest[0] = _src2[0];
// filter 2nd pixel to 1 pixel before last
for (x = 1; x < srcwidth - 1; x++) {
for (z = 0; z < 4; z++ ) {
t1 = *((uint8*)(_src1+x-1)+z);
t2 = *((uint8*)(_src1+x )+z);
t3 = *((uint8*)(_src1+x+1)+z);
t4 = *((uint8*)(_src2+x-1)+z);
t5 = *((uint8*)(_src2+x )+z);
t6 = *((uint8*)(_src2+x+1)+z);
t7 = *((uint8*)(_src3+x-1)+z);
t8 = *((uint8*)(_src3+x )+z);
t9 = *((uint8*)(_src3+x+1)+z);
for (z = 0; z < 4; z++) {
t1 = *((uint8*)(_src1 + x - 1) + z);
t2 = *((uint8*)(_src1 + x) + z);
t3 = *((uint8*)(_src1 + x + 1) + z);
t4 = *((uint8*)(_src2 + x - 1) + z);
t5 = *((uint8*)(_src2 + x) + z);
t6 = *((uint8*)(_src2 + x + 1) + z);
t7 = *((uint8*)(_src3 + x - 1) + z);
t8 = *((uint8*)(_src3 + x) + z);
t9 = *((uint8*)(_src3 + x + 1) + z);
/* the component value must not overflow 0xFF */
val[z] = ((t1+t3+t7+t9)*mul1+((t2+t4+t6+t8)*mul2)+(t5*mul3))>>shift4;
val[z] = ((t1 + t3 + t7 + t9)*mul1 + ((t2 + t4 + t6 + t8)*mul2) + (t5*mul3)) >> shift4;
if (val[z] > 0xFF) val[z] = 0xFF;
}
_dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24);
_dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24);
}
// copy the ending pixel
_dest[srcwidth-1] = *(_src3 - 1);
_dest[srcwidth - 1] = *(_src3 - 1);
// next row
_src1 += srcwidth;
_src2 += srcwidth;
@ -506,18 +498,19 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d
for (y = 1; y < srcheight - 1; y++) {
// filter 1st pixel to the last
if (y & 1) {
for( x = 0; x < srcwidth; x++) {
for( z = 0; z < 4; z++ ) {
t2 = *((uint8*)(_src1+x )+z);
t5 = *((uint8*)(_src2+x )+z);
t8 = *((uint8*)(_src3+x )+z);
for (x = 0; x < srcwidth; x++) {
for (z = 0; z < 4; z++) {
t2 = *((uint8*)(_src1 + x) + z);
t5 = *((uint8*)(_src2 + x) + z);
t8 = *((uint8*)(_src3 + x) + z);
/* the component value must not overflow 0xFF */
val[z] = ((t2+t8)*mul2+(t5*mul3))>>shift4;
val[z] = ((t2 + t8)*mul2 + (t5*mul3)) >> shift4;
if (val[z] > 0xFF) val[z] = 0xFF;
}
_dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24);
_dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24);
}
} else {
}
else {
memcpy(_dest, _src2, (srcwidth << 2));
}
// next row
@ -540,36 +533,36 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d
uint16 mul1, mul2, mul3, shift4;
uint32 x,y,z;
uint32 x, y, z;
uint16 *_src1, *_src2, *_src3, *_dest;
uint16 val[4];
uint16 t1,t2,t3,t4,t5,t6,t7,t8,t9;
uint16 t1, t2, t3, t4, t5, t6, t7, t8, t9;
switch( filter ) {
switch (filter) {
case SMOOTH_FILTER_4:
mul1=1;
mul2=2;
mul3=4;
shift4=4;
mul1 = 1;
mul2 = 2;
mul3 = 4;
shift4 = 4;
break;
case SMOOTH_FILTER_3:
mul1=1;
mul2=1;
mul3=8;
shift4=4;
mul1 = 1;
mul2 = 1;
mul3 = 8;
shift4 = 4;
break;
case SMOOTH_FILTER_2:
mul1=1;
mul2=1;
mul3=2;
shift4=2;
mul1 = 1;
mul2 = 1;
mul3 = 2;
shift4 = 2;
break;
case SMOOTH_FILTER_1:
default:
mul1=1;
mul2=1;
mul3=6;
shift4=3;
mul1 = 1;
mul2 = 1;
mul3 = 6;
shift4 = 3;
break;
}
@ -590,26 +583,26 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d
_dest[0] = *_src2;
// filter 2nd pixel to 1 pixel before last
for (x = 1; x < srcwidth - 1; x++) {
for (z = 0; z < 4; z++ ) {
for (z = 0; z < 4; z++) {
/* Read the entire 16bit pixel and then extract the A,R,G,B components. */
uint32 shift = z << 2;
t1 = ((*(uint16*)(_src1+x-1)) >> shift) & 0xF;
t2 = ((*(uint16*)(_src1+x )) >> shift) & 0xF;
t3 = ((*(uint16*)(_src1+x+1)) >> shift) & 0xF;
t4 = ((*(uint16*)(_src2+x-1)) >> shift) & 0xF;
t5 = ((*(uint16*)(_src2+x )) >> shift) & 0xF;
t6 = ((*(uint16*)(_src2+x+1)) >> shift) & 0xF;
t7 = ((*(uint16*)(_src3+x-1)) >> shift) & 0xF;
t8 = ((*(uint16*)(_src3+x )) >> shift) & 0xF;
t9 = ((*(uint16*)(_src3+x+1)) >> shift) & 0xF;
t1 = ((*(uint16*)(_src1 + x - 1)) >> shift) & 0xF;
t2 = ((*(uint16*)(_src1 + x)) >> shift) & 0xF;
t3 = ((*(uint16*)(_src1 + x + 1)) >> shift) & 0xF;
t4 = ((*(uint16*)(_src2 + x - 1)) >> shift) & 0xF;
t5 = ((*(uint16*)(_src2 + x)) >> shift) & 0xF;
t6 = ((*(uint16*)(_src2 + x + 1)) >> shift) & 0xF;
t7 = ((*(uint16*)(_src3 + x - 1)) >> shift) & 0xF;
t8 = ((*(uint16*)(_src3 + x)) >> shift) & 0xF;
t9 = ((*(uint16*)(_src3 + x + 1)) >> shift) & 0xF;
/* the component value must not overflow 0xF */
val[z] = ((t1+t3+t7+t9)*mul1+((t2+t4+t6+t8)*mul2)+(t5*mul3))>>shift4;
val[z] = ((t1 + t3 + t7 + t9)*mul1 + ((t2 + t4 + t6 + t8)*mul2) + (t5*mul3)) >> shift4;
if (val[z] > 0xF) val[z] = 0xF;
}
_dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12);
_dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12);
}
// copy the ending pixel
_dest[srcwidth-1] = *(_src3 - 1);
_dest[srcwidth - 1] = *(_src3 - 1);
// next row
_src1 += srcwidth;
_src2 += srcwidth;
@ -631,22 +624,23 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d
memcpy(_dest, _src1, (srcwidth << 1));
_dest += srcwidth;
// filter 2nd row to 1 row before the last
for( y = 1; y < srcheight - 1; y++) {
for (y = 1; y < srcheight - 1; y++) {
if (y & 1) {
for( x = 0; x < srcwidth; x++) {
for( z = 0; z < 4; z++ ) {
for (x = 0; x < srcwidth; x++) {
for (z = 0; z < 4; z++) {
/* Read the entire 16bit pixel and then extract the A,R,G,B components. */
uint32 shift = z << 2;
t2 = ((*(uint16*)(_src1+x)) >> shift) & 0xF;
t5 = ((*(uint16*)(_src2+x)) >> shift) & 0xF;
t8 = ((*(uint16*)(_src3+x)) >> shift) & 0xF;
t2 = ((*(uint16*)(_src1 + x)) >> shift) & 0xF;
t5 = ((*(uint16*)(_src2 + x)) >> shift) & 0xF;
t8 = ((*(uint16*)(_src3 + x)) >> shift) & 0xF;
/* the component value must not overflow 0xF */
val[z] = ((t2+t8)*mul2+(t5*mul3))>>shift4;
val[z] = ((t2 + t8)*mul2 + (t5*mul3)) >> shift4;
if (val[z] > 0xF) val[z] = 0xF;
}
_dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12);
_dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12);
}
} else {
}
else {
memcpy(_dest, _src2, (srcwidth << 1));
}
// next row
@ -687,7 +681,7 @@ void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, u
return;
}
switch (filter & (SMOOTH_FILTER_MASK|SHARP_FILTER_MASK)) {
switch (filter & (SMOOTH_FILTER_MASK | SHARP_FILTER_MASK)) {
case SMOOTH_FILTER_1:
case SMOOTH_FILTER_2:
case SMOOTH_FILTER_3:

View File

@ -1,26 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TEXTUREFILTERS_H__
#define __TEXTUREFILTERS_H__
@ -33,7 +23,7 @@
#include "TxInternal.h"
/* enhancers */
/* enhancers */
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);
@ -58,7 +48,7 @@ void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, u
void hq4x_init(void);
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_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 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_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_8 (uint8 *srcPtr, uint8 *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 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
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/* Based on Derek Liauw Kie Fa and Rice1964 Super2xSaI code */
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 "TextureFilters.h"
#define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D))

View File

@ -1,28 +1,17 @@
/*
Copyright (C) 2003 Rice1964
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Copyright (C) 2007 Hiroshi Morii <koolsmoky(at)users.sourceforge.net>
* Modified for the Texture Filtering library
*/
/* 2007 Mudlord - Added hq2xS lq2xS filters */
/***************************************************************************
* *
* 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) 2007 Mudlord *
* Copyright (C) 2003 Rice1964 *
* *
* 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 "TextureFilters.h"
/************************************************************************/
@ -44,38 +33,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static uint16 hq2x_interp_16_521(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*5 + INTERP_16_MASK_1_3(p2)*2 + INTERP_16_MASK_1_3(p3)*1) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*5 + INTERP_16_MASK_SHIFT_2_4(p2)*2 + INTERP_16_MASK_SHIFT_2_4(p3)*1) / 8);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 5 + INTERP_16_MASK_1_3(p2) * 2 + INTERP_16_MASK_1_3(p3) * 1) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 5 + INTERP_16_MASK_SHIFT_2_4(p2) * 2 + INTERP_16_MASK_SHIFT_2_4(p3) * 1) / 8);
}
static uint16 hq2x_interp_16_332(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*3 + INTERP_16_MASK_1_3(p2)*3 + INTERP_16_MASK_1_3(p3)*2) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*3 + INTERP_16_MASK_SHIFT_2_4(p2)*3 + INTERP_16_MASK_SHIFT_2_4(p3)*2) / 8);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 3 + INTERP_16_MASK_1_3(p2) * 3 + INTERP_16_MASK_1_3(p3) * 2) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 3 + INTERP_16_MASK_SHIFT_2_4(p2) * 3 + INTERP_16_MASK_SHIFT_2_4(p3) * 2) / 8);
}
static uint16 hq2x_interp_16_611(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*6 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*6 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 8);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 6 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 6 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 8);
}
static uint16 hq2x_interp_16_71(uint16 p1, uint16 p2)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*7 + INTERP_16_MASK_1_3(p2)) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*7 + INTERP_16_MASK_SHIFT_2_4(p2)) / 8);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 7 + INTERP_16_MASK_1_3(p2)) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 7 + INTERP_16_MASK_SHIFT_2_4(p2)) / 8);
}
static uint16 hq2x_interp_16_211(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*2 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 4)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*2 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 4);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 2 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 4)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 2 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 4);
}
static uint16 hq2x_interp_16_772(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3(((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2))*7 + INTERP_16_MASK_1_3(p3)*2) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4(((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2))*7 + INTERP_16_MASK_SHIFT_2_4(p3)*2) / 16);
return INTERP_16_MASK_1_3(((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2)) * 7 + INTERP_16_MASK_1_3(p3) * 2) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4(((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2)) * 7 + INTERP_16_MASK_SHIFT_2_4(p3) * 2) / 16);
}
static uint16 hq2x_interp_16_11(uint16 p1, uint16 p2)
@ -86,38 +75,38 @@ static uint16 hq2x_interp_16_11(uint16 p1, uint16 p2)
static uint16 hq2x_interp_16_31(uint16 p1, uint16 p2)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*3 + INTERP_16_MASK_1_3(p2)) / 4)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*3 + INTERP_16_MASK_SHIFT_2_4(p2)) / 4);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 3 + INTERP_16_MASK_1_3(p2)) / 4)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 3 + INTERP_16_MASK_SHIFT_2_4(p2)) / 4);
}
static uint16 hq2x_interp_16_1411(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*14 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*14 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 16);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 14 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 14 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 16);
}
static uint16 hq2x_interp_16_431(uint16 p1, uint16 p2, uint16 p3)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*4 + INTERP_16_MASK_1_3(p2)*3 + INTERP_16_MASK_1_3(p3)) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*4 + INTERP_16_MASK_SHIFT_2_4(p2)*3 + INTERP_16_MASK_SHIFT_2_4(p3)) / 8);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 4 + INTERP_16_MASK_1_3(p2) * 3 + INTERP_16_MASK_1_3(p3)) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 4 + INTERP_16_MASK_SHIFT_2_4(p2) * 3 + INTERP_16_MASK_SHIFT_2_4(p3)) / 8);
}
static uint16 hq2x_interp_16_53(uint16 p1, uint16 p2)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*5 + INTERP_16_MASK_1_3(p2)*3) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*5 + INTERP_16_MASK_SHIFT_2_4(p2)*3) / 8);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 5 + INTERP_16_MASK_1_3(p2) * 3) / 8)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 5 + INTERP_16_MASK_SHIFT_2_4(p2) * 3) / 8);
}
static uint16 hq2x_interp_16_151(uint16 p1, uint16 p2)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*15 + INTERP_16_MASK_1_3(p2)) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*15 + INTERP_16_MASK_SHIFT_2_4(p2)) / 16);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 15 + INTERP_16_MASK_1_3(p2)) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 15 + INTERP_16_MASK_SHIFT_2_4(p2)) / 16);
}
static uint16 hq2x_interp_16_97(uint16 p1, uint16 p2)
{
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*9 + INTERP_16_MASK_1_3(p2)*7) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*9 + INTERP_16_MASK_SHIFT_2_4(p2)*7) / 16);
return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 9 + INTERP_16_MASK_1_3(p2) * 7) / 16)
| INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 9 + INTERP_16_MASK_SHIFT_2_4(p2) * 7) / 16);
}
#endif /* !_16BPP_HACK */
@ -127,38 +116,38 @@ static uint16 hq2x_interp_16_97(uint16 p1, uint16 p2)
static uint32 hq2x_interp_32_521(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*5 + INTERP_32_MASK_1_3(p2)*2 + INTERP_32_MASK_1_3(p3)*1) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*5 + INTERP_32_MASK_SHIFT_2_4(p2)*2 + INTERP_32_MASK_SHIFT_2_4(p3)*1) / 8);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 5 + INTERP_32_MASK_1_3(p2) * 2 + INTERP_32_MASK_1_3(p3) * 1) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 5 + INTERP_32_MASK_SHIFT_2_4(p2) * 2 + INTERP_32_MASK_SHIFT_2_4(p3) * 1) / 8);
}
static uint32 hq2x_interp_32_332(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*3 + INTERP_32_MASK_1_3(p2)*3 + INTERP_32_MASK_1_3(p3)*2) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*3 + INTERP_32_MASK_SHIFT_2_4(p2)*3 + INTERP_32_MASK_SHIFT_2_4(p3)*2) / 8);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 3 + INTERP_32_MASK_1_3(p2) * 3 + INTERP_32_MASK_1_3(p3) * 2) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 3 + INTERP_32_MASK_SHIFT_2_4(p2) * 3 + INTERP_32_MASK_SHIFT_2_4(p3) * 2) / 8);
}
static uint32 hq2x_interp_32_211(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*2 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 4)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*2 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 4);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 2 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 4)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 2 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 4);
}
static uint32 hq2x_interp_32_611(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*6 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*6 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 8);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 6 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 6 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 8);
}
static uint32 hq2x_interp_32_71(uint32 p1, uint32 p2)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*7 + INTERP_32_MASK_1_3(p2)) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*7 + INTERP_32_MASK_SHIFT_2_4(p2)) / 8);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 7 + INTERP_32_MASK_1_3(p2)) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 7 + INTERP_32_MASK_SHIFT_2_4(p2)) / 8);
}
static uint32 hq2x_interp_32_772(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3(((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2))*7 + INTERP_32_MASK_1_3(p3)*2) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4(((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2))*7 + INTERP_32_MASK_SHIFT_2_4(p3)*2) / 16);
return INTERP_32_MASK_1_3(((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2)) * 7 + INTERP_32_MASK_1_3(p3) * 2) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4(((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2)) * 7 + INTERP_32_MASK_SHIFT_2_4(p3) * 2) / 16);
}
static uint32 hq2x_interp_32_11(uint32 p1, uint32 p2)
@ -169,38 +158,38 @@ static uint32 hq2x_interp_32_11(uint32 p1, uint32 p2)
static uint32 hq2x_interp_32_31(uint32 p1, uint32 p2)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*3 + INTERP_32_MASK_1_3(p2)) / 4)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*3 + INTERP_32_MASK_SHIFT_2_4(p2)) / 4);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 3 + INTERP_32_MASK_1_3(p2)) / 4)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 3 + INTERP_32_MASK_SHIFT_2_4(p2)) / 4);
}
static uint32 hq2x_interp_32_1411(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*14 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*14 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 16);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 14 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 14 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 16);
}
static uint32 hq2x_interp_32_431(uint32 p1, uint32 p2, uint32 p3)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*4 + INTERP_32_MASK_1_3(p2)*3 + INTERP_32_MASK_1_3(p3)) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*4 + INTERP_32_MASK_SHIFT_2_4(p2)*3 + INTERP_32_MASK_SHIFT_2_4(p3)) / 8);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 4 + INTERP_32_MASK_1_3(p2) * 3 + INTERP_32_MASK_1_3(p3)) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 4 + INTERP_32_MASK_SHIFT_2_4(p2) * 3 + INTERP_32_MASK_SHIFT_2_4(p3)) / 8);
}
static uint32 hq2x_interp_32_53(uint32 p1, uint32 p2)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*5 + INTERP_32_MASK_1_3(p2)*3) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*5 + INTERP_32_MASK_SHIFT_2_4(p2)*3) / 8);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 5 + INTERP_32_MASK_1_3(p2) * 3) / 8)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 5 + INTERP_32_MASK_SHIFT_2_4(p2) * 3) / 8);
}
static uint32 hq2x_interp_32_151(uint32 p1, uint32 p2)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*15 + INTERP_32_MASK_1_3(p2)) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*15 + INTERP_32_MASK_SHIFT_2_4(p2)) / 16);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 15 + INTERP_32_MASK_1_3(p2)) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 15 + INTERP_32_MASK_SHIFT_2_4(p2)) / 16);
}
static uint32 hq2x_interp_32_97(uint32 p1, uint32 p2)
{
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*9 + INTERP_32_MASK_1_3(p2)*7) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*9 + INTERP_32_MASK_SHIFT_2_4(p2)*7) / 16);
return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 9 + INTERP_32_MASK_1_3(p2) * 7) / 16)
| INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 9 + INTERP_32_MASK_SHIFT_2_4(p2) * 7) / 16);
}
/***************************************************************************/
@ -225,7 +214,7 @@ static int hq2x_interp_16_diff(uint16 p1, uint16 p2)
y = r + g + b;
u = r - b;
v = -r + 2*g - b;
v = -r + 2 * g - b;
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
return 1;
@ -254,7 +243,7 @@ static int hq2x_interp_32_diff(uint32 p1, uint32 p2)
y = r + g + b;
u = r - b;
v = -r + 2*g - b;
v = -r + 2 * g - b;
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
return 1;
@ -278,7 +267,7 @@ static void hq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const ui
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint16 c[9];
@ -287,21 +276,23 @@ static void hq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const ui
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
@ -388,7 +379,7 @@ static void hq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint16 c[9];
@ -397,21 +388,23 @@ static void hq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
@ -424,43 +417,44 @@ static void hq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u
// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
int brightArray[9];
int maxBright = 0, minBright = 999999;
for(int j = 0 ; j < 9 ; j++) {
int r,g,b;
for (int j = 0; j < 9; j++) {
int r, g, b;
if (interp_bits_per_pixel == 16) {
b = (int)((c[j] & 0x1F)) << 3;
g = (int)((c[j] & 0x7E0)) >> 3;
r = (int)((c[j] & 0xF800)) >> 8;
} else {
}
else {
b = (int)((c[j] & 0x1F)) << 3;
g = (int)((c[j] & 0x3E0)) >> 2;
r = (int)((c[j] & 0x7C00)) >> 7;
}
const int bright = r+r+r + g+g+g + b+b;
if(bright > maxBright) maxBright = bright;
if(bright < minBright) minBright = bright;
const int bright = r + r + r + g + g + g + b + b;
if (bright > maxBright) maxBright = bright;
if (bright < minBright) minBright = bright;
brightArray[j] = bright;
}
int diffBright = ((maxBright - minBright) * 7) >> 4;
if(diffBright > 7) {
if (diffBright > 7) {
#define ABS(x) ((x) < 0 ? -(x) : (x))
const int centerBright = brightArray[4];
if(ABS(brightArray[0] - centerBright) > diffBright)
if (ABS(brightArray[0] - centerBright) > diffBright)
mask |= 1 << 0;
if(ABS(brightArray[1] - centerBright) > diffBright)
if (ABS(brightArray[1] - centerBright) > diffBright)
mask |= 1 << 1;
if(ABS(brightArray[2] - centerBright) > diffBright)
if (ABS(brightArray[2] - centerBright) > diffBright)
mask |= 1 << 2;
if(ABS(brightArray[3] - centerBright) > diffBright)
if (ABS(brightArray[3] - centerBright) > diffBright)
mask |= 1 << 3;
if(ABS(brightArray[5] - centerBright) > diffBright)
if (ABS(brightArray[5] - centerBright) > diffBright)
mask |= 1 << 4;
if(ABS(brightArray[6] - centerBright) > diffBright)
if (ABS(brightArray[6] - centerBright) > diffBright)
mask |= 1 << 5;
if(ABS(brightArray[7] - centerBright) > diffBright)
if (ABS(brightArray[7] - centerBright) > diffBright)
mask |= 1 << 6;
if(ABS(brightArray[8] - centerBright) > diffBright)
if (ABS(brightArray[8] - centerBright) > diffBright)
mask |= 1 << 7;
}
@ -527,7 +521,7 @@ static void hq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const ui
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint32 c[9];
@ -536,21 +530,23 @@ static void hq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const ui
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = src0[0];
c[3] = src1[0];
c[6] = src2[0];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = src0[0];
c[5] = src1[0];
c[8] = src2[0];
@ -637,7 +633,7 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint32 c[9];
@ -646,21 +642,23 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = src0[0];
c[3] = src1[0];
c[6] = src2[0];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = src0[0];
c[5] = src1[0];
c[8] = src2[0];
@ -672,36 +670,36 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u
// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
int brightArray[9];
int maxBright = 0, minBright = 999999;
for(int j = 0 ; j < 9 ; j++) {
for (int j = 0; j < 9; j++) {
const int b = (int)((c[j] & 0xF8));
const int g = (int)((c[j] & 0xF800)) >> 8;
const int r = (int)((c[j] & 0xF80000)) >> 16;
const int bright = r+r+r + g+g+g + b+b;
if(bright > maxBright) maxBright = bright;
if(bright < minBright) minBright = bright;
const int bright = r + r + r + g + g + g + b + b;
if (bright > maxBright) maxBright = bright;
if (bright < minBright) minBright = bright;
brightArray[j] = bright;
}
int diffBright = ((maxBright - minBright) * 7) >> 4;
if(diffBright > 7) {
if (diffBright > 7) {
#define ABS(x) ((x) < 0 ? -(x) : (x))
const int centerBright = brightArray[4];
if(ABS(brightArray[0] - centerBright) > diffBright)
if (ABS(brightArray[0] - centerBright) > diffBright)
mask |= 1 << 0;
if(ABS(brightArray[1] - centerBright) > diffBright)
if (ABS(brightArray[1] - centerBright) > diffBright)
mask |= 1 << 1;
if(ABS(brightArray[2] - centerBright) > diffBright)
if (ABS(brightArray[2] - centerBright) > diffBright)
mask |= 1 << 2;
if(ABS(brightArray[3] - centerBright) > diffBright)
if (ABS(brightArray[3] - centerBright) > diffBright)
mask |= 1 << 3;
if(ABS(brightArray[5] - centerBright) > diffBright)
if (ABS(brightArray[5] - centerBright) > diffBright)
mask |= 1 << 4;
if(ABS(brightArray[6] - centerBright) > diffBright)
if (ABS(brightArray[6] - centerBright) > diffBright)
mask |= 1 << 5;
if(ABS(brightArray[7] - centerBright) > diffBright)
if (ABS(brightArray[7] - centerBright) > diffBright)
mask |= 1 << 6;
if(ABS(brightArray[8] - centerBright) > diffBright)
if (ABS(brightArray[8] - centerBright) > diffBright)
mask |= 1 << 7;
}
#define P0 dst0[0]
@ -774,7 +772,7 @@ static void lq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const ui
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint16 c[9];
@ -783,21 +781,23 @@ static void lq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const ui
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
@ -884,7 +884,7 @@ static void lq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint16 c[9];
@ -893,21 +893,23 @@ static void lq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
@ -918,36 +920,36 @@ static void lq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u
// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
int brightArray[9];
int maxBright = 0, minBright = 999999;
for(int j = 0 ; j < 9 ; j++) {
for (int j = 0; j < 9; j++) {
const int b = (int)((c[j] & 0xF8));
const int g = (int)((c[j] & 0xF800)) >> 8;
const int r = (int)((c[j] & 0xF80000)) >> 16;
const int bright = r+r+r + g+g+g + b+b;
if(bright > maxBright) maxBright = bright;
if(bright < minBright) minBright = bright;
const int bright = r + r + r + g + g + g + b + b;
if (bright > maxBright) maxBright = bright;
if (bright < minBright) minBright = bright;
brightArray[j] = bright;
}
int diffBright = ((maxBright - minBright) * 7) >> 4;
if(diffBright > 7) {
if (diffBright > 7) {
#define ABS(x) ((x) < 0 ? -(x) : (x))
const int centerBright = brightArray[4];
if(ABS(brightArray[0] - centerBright) > diffBright)
if (ABS(brightArray[0] - centerBright) > diffBright)
mask |= 1 << 0;
if(ABS(brightArray[1] - centerBright) > diffBright)
if (ABS(brightArray[1] - centerBright) > diffBright)
mask |= 1 << 1;
if(ABS(brightArray[2] - centerBright) > diffBright)
if (ABS(brightArray[2] - centerBright) > diffBright)
mask |= 1 << 2;
if(ABS(brightArray[3] - centerBright) > diffBright)
if (ABS(brightArray[3] - centerBright) > diffBright)
mask |= 1 << 3;
if(ABS(brightArray[5] - centerBright) > diffBright)
if (ABS(brightArray[5] - centerBright) > diffBright)
mask |= 1 << 4;
if(ABS(brightArray[6] - centerBright) > diffBright)
if (ABS(brightArray[6] - centerBright) > diffBright)
mask |= 1 << 5;
if(ABS(brightArray[7] - centerBright) > diffBright)
if (ABS(brightArray[7] - centerBright) > diffBright)
mask |= 1 << 6;
if(ABS(brightArray[8] - centerBright) > diffBright)
if (ABS(brightArray[8] - centerBright) > diffBright)
mask |= 1 << 7;
}
@ -1014,7 +1016,7 @@ static void lq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const ui
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint32 c[9];
@ -1023,21 +1025,23 @@ static void lq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const ui
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
@ -1124,7 +1128,7 @@ static void lq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u
{
unsigned i;
for(i=0;i<count;++i) {
for (i = 0; i < count; ++i) {
unsigned char mask;
uint32 c[9];
@ -1133,21 +1137,23 @@ static void lq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
if (i > 0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
}
else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
if (i < count - 1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
}
else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
@ -1158,36 +1164,36 @@ static void lq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u
// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
int brightArray[9];
int maxBright = 0, minBright = 999999;
for(int j = 0 ; j < 9 ; j++) {
for (int j = 0; j < 9; j++) {
const int b = (int)((c[j] & 0xF8));
const int g = (int)((c[j] & 0xF800)) >> 8;
const int r = (int)((c[j] & 0xF80000)) >> 16;
const int bright = r+r+r + g+g+g + b+b;
if(bright > maxBright) maxBright = bright;
if(bright < minBright) minBright = bright;
const int bright = r + r + r + g + g + g + b + b;
if (bright > maxBright) maxBright = bright;
if (bright < minBright) minBright = bright;
brightArray[j] = bright;
}
int diffBright = ((maxBright - minBright) * 7) >> 4;
if(diffBright > 7) {
if (diffBright > 7) {
#define ABS(x) ((x) < 0 ? -(x) : (x))
const int centerBright = brightArray[4];
if(ABS(brightArray[0] - centerBright) > diffBright)
if (ABS(brightArray[0] - centerBright) > diffBright)
mask |= 1 << 0;
if(ABS(brightArray[1] - centerBright) > diffBright)
if (ABS(brightArray[1] - centerBright) > diffBright)
mask |= 1 << 1;
if(ABS(brightArray[2] - centerBright) > diffBright)
if (ABS(brightArray[2] - centerBright) > diffBright)
mask |= 1 << 2;
if(ABS(brightArray[3] - centerBright) > diffBright)
if (ABS(brightArray[3] - centerBright) > diffBright)
mask |= 1 << 3;
if(ABS(brightArray[5] - centerBright) > diffBright)
if (ABS(brightArray[5] - centerBright) > diffBright)
mask |= 1 << 4;
if(ABS(brightArray[6] - centerBright) > diffBright)
if (ABS(brightArray[6] - centerBright) > diffBright)
mask |= 1 << 5;
if(ABS(brightArray[7] - centerBright) > diffBright)
if (ABS(brightArray[7] - centerBright) > diffBright)
mask |= 1 << 6;
if(ABS(brightArray[8] - centerBright) > diffBright)
if (ABS(brightArray[8] - centerBright) > diffBright)
mask |= 1 << 7;
}
@ -1262,12 +1268,12 @@ void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int
int count;
hq2x_16_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
if (height == 1) return;
count = height;
count -= 2;
while(count>0) {
while (count > 0) {
dst0 += dstPitch;
dst1 += dstPitch;
hq2x_16_def(dst0, dst1, src0, src1, src2, width);
@ -1281,7 +1287,6 @@ void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int
hq2x_16_def(dst0, dst1, src0, src1, src1, width);
}
void hq2xS_16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
@ -1297,7 +1302,7 @@ void hq2xS_16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
int count = height;
count -= 2;
while(count) {
while (count) {
dst0 += dstPitch;
dst1 += dstPitch;
hq2xS_16_def(dst0, dst1, src0, src1, src2, width);
@ -1324,12 +1329,12 @@ void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int
int count;
hq2x_32_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
if (height == 1) return;
count = height;
count -= 2;
while(count>0) {
while (count > 0) {
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
hq2x_32_def(dst0, dst1, src0, src1, src2, width);
@ -1356,7 +1361,7 @@ void hq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in
int count = height;
count -= 2;
while(count) {
while (count) {
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
hq2xS_32_def(dst0, dst1, src0, src1, src2, width);
@ -1383,12 +1388,12 @@ void lq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int
int count;
lq2x_16_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
if (height == 1) return;
count = height;
count -= 2;
while(count>0) {
while (count > 0) {
dst0 += dstPitch;
dst1 += dstPitch;
hq2x_16_def(dst0, dst1, src0, src1, src2, width);
@ -1414,12 +1419,12 @@ void lq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in
int count;
lq2xS_16_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
if (height == 1) return;
count = height;
count -= 2;
while(count>0) {
while (count > 0) {
dst0 += dstPitch;
dst1 += dstPitch;
hq2x_16_def(dst0, dst1, src0, src1, src2, width);
@ -1446,12 +1451,12 @@ void lq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int
int count;
lq2x_32_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
if (height == 1) return;
count = height;
count -= 2;
while(count>0) {
while (count > 0) {
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
hq2x_32_def(dst0, dst1, src0, src1, src2, width);
@ -1477,12 +1482,12 @@ void lq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in
int count;
lq2xS_32_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
if (height == 1) return;
count = height;
count -= 2;
while(count>0) {
while (count > 0) {
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
hq2x_32_def(dst0, dst1, src0, src1, src2, width);
@ -1507,4 +1512,3 @@ void lq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in
/************************************************************************/
/* scale3x filters */
/************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/* Based on Maxim Stepin and Rice1964 hq4x code */
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 <math.h>
#include <stdlib.h>
#include "TextureFilters.h"
@ -62,7 +50,7 @@ static uint32 RGB555toYUV(uint32 val)
Y = (r + g + 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);
}
@ -80,7 +68,7 @@ static uint32 RGB565toYUV(uint32 val)
Y = (r + g + 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);
}
@ -92,7 +80,7 @@ static uint32 RGB888toYUV(uint32 val)
uint32 Yuv;
__asm {
mov eax, dword ptr [val];
mov eax, dword ptr[val];
mov ebx, eax;
mov ecx, eax;
and ebx, 0x000000ff; // b
@ -121,7 +109,7 @@ static uint32 RGB888toYUV(uint32 val)
shr ecx, 11;
or edx, ecx;
mov dword ptr [Yuv], edx;
mov dword ptr[Yuv], edx;
}
return Yuv;
@ -445,29 +433,31 @@ void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
// +----+----+----+
for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*2; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*2; else nextline = 0;
if (j > 0) prevline = -SrcPPL * 2; else prevline = 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[5] = *((uint16*)pIn);
w[8] = *((uint16*)(pIn + nextline));
if (i>0) {
if (i > 0) {
w[1] = *((uint16*)(pIn + prevline - 2));
w[4] = *((uint16*)(pIn - 2));
w[7] = *((uint16*)(pIn + nextline - 2));
} else {
}
else {
w[1] = w[2];
w[4] = w[5];
w[7] = w[8];
}
if (i<Xres-1) {
if (i < Xres - 1) {
w[3] = *((uint16*)(pIn + prevline + 2));
w[6] = *((uint16*)(pIn + 2));
w[9] = *((uint16*)(pIn + nextline + 2));
} else {
}
else {
w[3] = w[2];
w[6] = w[5];
w[9] = w[8];
@ -478,32 +468,32 @@ void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
YUV1 = RGB444toYUV(w[5]);
for (k=1; k<=9; k++) {
if (k==5) continue;
for (k = 1; k <= 9; k++) {
if (k == 5) continue;
if ( w[k] != w[5] ) {
if (w[k] != w[5]) {
YUV2 = RGB444toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
(abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
(abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag;
}
flag <<= 1;
}
for (k=1; k<=9; k++)
for (k = 1; k <= 9; k++)
c[k] = w[k];
#include "TextureFilters_hq4x.h"
pIn+=2;
pOut+=8;
pIn += 2;
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
@ -557,29 +547,31 @@ void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
// +----+----+----+
for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*2; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*2; else nextline = 0;
if (j > 0) prevline = -SrcPPL * 2; else prevline = 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[5] = *((uint16*)pIn);
w[8] = *((uint16*)(pIn + nextline));
if (i>0) {
if (i > 0) {
w[1] = *((uint16*)(pIn + prevline - 2));
w[4] = *((uint16*)(pIn - 2));
w[7] = *((uint16*)(pIn + nextline - 2));
} else {
}
else {
w[1] = w[2];
w[4] = w[5];
w[7] = w[8];
}
if (i<Xres-1) {
if (i < Xres - 1) {
w[3] = *((uint16*)(pIn + prevline + 2));
w[6] = *((uint16*)(pIn + 2));
w[9] = *((uint16*)(pIn + nextline + 2));
} else {
}
else {
w[3] = w[2];
w[6] = w[5];
w[9] = w[8];
@ -590,32 +582,32 @@ void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
YUV1 = RGB555toYUV(w[5]);
for (k=1; k<=9; k++) {
if (k==5) continue;
for (k = 1; k <= 9; k++) {
if (k == 5) continue;
if ( w[k] != w[5] ) {
if (w[k] != w[5]) {
YUV2 = RGB555toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
(abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
(abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag;
}
flag <<= 1;
}
for (k=1; k<=9; k++)
for (k = 1; k <= 9; k++)
c[k] = w[k];
#include "TextureFilters_hq4x.h"
pIn+=2;
pOut+=8;
pIn += 2;
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
@ -669,29 +661,31 @@ void hq4x_565(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int
// +----+----+----+
for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*2; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*2; else nextline = 0;
if (j > 0) prevline = -SrcPPL * 2; else prevline = 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[5] = *((uint16*)pIn);
w[8] = *((uint16*)(pIn + nextline));
if (i>0) {
if (i > 0) {
w[1] = *((uint16*)(pIn + prevline - 2));
w[4] = *((uint16*)(pIn - 2));
w[7] = *((uint16*)(pIn + nextline - 2));
} else {
}
else {
w[1] = w[2];
w[4] = w[5];
w[7] = w[8];
}
if (i<Xres-1) {
if (i < Xres - 1) {
w[3] = *((uint16*)(pIn + prevline + 2));
w[6] = *((uint16*)(pIn + 2));
w[9] = *((uint16*)(pIn + nextline + 2));
} else {
}
else {
w[3] = w[2];
w[6] = w[5];
w[9] = w[8];
@ -702,32 +696,32 @@ void hq4x_565(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int
YUV1 = RGB565toYUV(w[5]);
for (k=1; k<=9; k++) {
if (k==5) continue;
for (k = 1; k <= 9; k++) {
if (k == 5) continue;
if ( w[k] != w[5] ) {
if (w[k] != w[5]) {
YUV2 = RGB565toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
(abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
(abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag;
}
flag <<= 1;
}
for (k=1; k<=9; k++)
for (k = 1; k <= 9; k++)
c[k] = w[k];
#include "TextureFilters_hq4x.h"
pIn+=2;
pOut+=8;
pIn += 2;
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
@ -782,29 +776,31 @@ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
// +----+----+----+
for (j = 0; j < Yres; j++) {
if (j>0) prevline = -SrcPPL*4; else prevline = 0;
if (j<Yres-1) nextline = SrcPPL*4; else nextline = 0;
if (j > 0) prevline = -SrcPPL * 4; else prevline = 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[5] = *((uint32*)pIn);
w[8] = *((uint32*)(pIn + nextline));
if (i>0) {
if (i > 0) {
w[1] = *((uint32*)(pIn + prevline - 4));
w[4] = *((uint32*)(pIn - 4));
w[7] = *((uint32*)(pIn + nextline - 4));
} else {
}
else {
w[1] = w[2];
w[4] = w[5];
w[7] = w[8];
}
if (i<Xres-1) {
if (i < Xres - 1) {
w[3] = *((uint32*)(pIn + prevline + 4));
w[6] = *((uint32*)(pIn + 4));
w[9] = *((uint32*)(pIn + nextline + 4));
} else {
}
else {
w[3] = w[2];
w[6] = w[5];
w[9] = w[8];
@ -815,33 +811,33 @@ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in
YUV1 = RGB888toYUV(w[5]);
for (k=1; k<=9; k++) {
if (k==5) continue;
for (k = 1; k <= 9; k++) {
if (k == 5) continue;
if ( w[k] != w[5] ) {
if (w[k] != w[5]) {
YUV2 = RGB888toYUV(w[k]);
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
(abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
(abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV))
pattern |= flag;
}
flag <<= 1;
}
for (k=1; k<=9; k++)
for (k = 1; k <= 9; k++)
c[k] = w[k];
#include "TextureFilters_hq4x.h"
pIn+=4;
pOut+=16;
pIn += 4;
pOut += 16;
}
pIn += 4*(SrcPPL-Xres);
pOut+= 16*(SrcPPL-Xres);
pOut+=BpL;
pOut+=BpL;
pOut+=BpL;
pIn += 4 * (SrcPPL - Xres);
pOut += 16 * (SrcPPL - Xres);
pOut += BpL;
pOut += BpL;
pOut += BpL;
}
#undef BPP
@ -864,7 +860,7 @@ void hq4x_init(void)
static int done = 0;
int r, g, b, Y, u, v, i, j, k;
if (done ) return;
if (done) return;
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
@ -880,7 +876,7 @@ void hq4x_init(void)
Y = (r + g + 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;
}

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
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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
#pragma warning(disable: 4786)
@ -33,6 +24,7 @@
#include <zlib/zlib.h>
#include <Common/path.h>
#include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
TxCache::~TxCache()
{
@ -82,8 +74,8 @@ TxCache::TxCache(int options, int cachesize, const char *path, const char *ident
}
}
boolean
TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize)
bool
TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize)
{
/* 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);
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())
{
/* _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())
{
/* 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())
{
/* yep we have it. remove it. */
@ -176,7 +168,7 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize)
txCache->it = --(_cachelist.end());
}
/* _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
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;
}
boolean
TxCache::get(uint64 checksum, GHQTexInfo *info)
bool
TxCache::get(uint64_t checksum, GHQTexInfo *info)
{
if (!checksum || _cache.empty()) return 0;
/* 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())
{
/* yep, we've got it. */
@ -234,7 +226,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
}
/* zlib decompress it */
if (info->format & GR_TEXFMT_GZ)
if (info->format & GFX_TEXFMT_GZ)
{
uLongf destLen = _gzdestLen;
uint8 *dest = (_gzdest0 == info->data) ? _gzdest1 : _gzdest0;
@ -244,7 +236,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
return 0;
}
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);
}
return 1;
@ -252,7 +244,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info)
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())
{
@ -265,7 +257,7 @@ boolean TxCache::save(const char *path, const char *filename, int config)
/* write header to determine config match */
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())
{
uint8 *dest = (*itMap).second->info.data;
@ -277,7 +269,7 @@ 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
* option is toggled, the cache will need to be rebuilt.
*/
/*if (format & GR_TEXFMT_GZ) {
/*if (format & GFX_TEXFMT_GZ) {
dest = _gzdest0;
destLen = _gzdestLen;
if (dest && destLen) {
@ -285,7 +277,7 @@ boolean TxCache::save(const char *path, const char *filename, int config)
dest = NULL;
destLen = 0;
}
format &= ~GR_TEXFMT_GZ;
format &= ~GFX_TEXFMT_GZ;
}
}*/
@ -325,7 +317,7 @@ boolean TxCache::save(const char *path, const char *filename, int config)
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 */
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. */
int dataSize;
uint64 checksum;
uint64_t checksum;
GHQTexInfo tmpInfo;
int tmpconfig;
/* 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);
/* 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);
}
@ -391,11 +383,11 @@ boolean TxCache::load(const char *path, const char *filename, int config)
return !_cache.empty();
}
boolean TxCache::del(uint64 checksum)
bool TxCache::del(uint64_t checksum)
{
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())
{
/* for texture cache (not hi-res cache) */
@ -415,9 +407,9 @@ boolean TxCache::del(uint64 checksum)
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;
return 0;
@ -427,7 +419,7 @@ void TxCache::clear()
{
if (!_cache.empty())
{
std::map<uint64, TXCACHE*>::iterator itMap = _cache.begin();
std::map<uint64_t, TXCACHE*>::iterator itMap = _cache.begin();
while (itMap != _cache.end())
{
free((*itMap).second->info.data);

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXCACHE_H__
#define __TXCACHE_H__
@ -33,7 +24,7 @@
class TxCache
{
private:
std::list<uint64> _cachelist;
std::list<uint64_t> _cachelist;
uint8 *_gzdest0;
uint8 *_gzdest1;
uint32 _gzdestLen;
@ -46,23 +37,23 @@ protected:
struct TXCACHE {
int size;
GHQTexInfo info;
std::list<uint64>::iterator it;
std::list<uint64_t>::iterator it;
};
int _totalSize;
int _cacheSize;
std::map<uint64, TXCACHE*> _cache;
boolean save(const char *path, const char *filename, const int config);
boolean load(const char *path, const char *filename, const int config);
boolean del(uint64 checksum); /* checksum hi:palette low:texture */
boolean is_cached(uint64 checksum); /* checksum hi:palette low:texture */
std::map<uint64_t, TXCACHE*> _cache;
bool save(const char *path, const char *filename, const int config);
bool load(const char *path, const char *filename, const int config);
bool del(uint64_t checksum); /* checksum hi:palette low:texture */
bool is_cached(uint64_t checksum); /* checksum hi:palette low:texture */
void clear();
public:
~TxCache();
TxCache(int options, int cachesize, const char *path, const char *ident,
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);
boolean get(uint64 checksum, /* checksum hi:palette low:texture */
bool get(uint64_t checksum, /* checksum hi:palette low:texture */
GHQTexInfo *info);
};

View File

@ -1,26 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 DBG_LEVEL 80
#include "TxDbg.h"

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXDBG_H__
#define __TXDBG_H__

View File

@ -1,32 +1,23 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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
#pragma warning(disable: 4786)
#endif
#include <Common/path.h>
#include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
#include "TxFilter.h"
#include "TextureFilters.h"
#include "TxDbg.h"
@ -173,8 +164,8 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options,
_initialized = 1;
}
boolean
TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint64 g64crc, GHQTexInfo *info)
bool
TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint64_t g64crc, GHQTexInfo *info)
{
uint8 *texture = src;
uint8 *tmptex = _tex1;
@ -187,7 +178,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
if (_cacheSize) {
/* calculate checksum of source texture */
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",
(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) &&
((_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
/* convert textures to a format that the compressor accepts (ARGB8888) */
if (_options & COMPRESSION_MASK) {
#endif
if (srcformat != GR_TEXFMT_ARGB_8888) {
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GR_TEXFMT_ARGB_8888)) {
if (srcformat != GFX_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);
return 0;
}
texture = tmptex;
destformat = GR_TEXFMT_ARGB_8888;
destformat = GFX_TEXFMT_ARGB_8888;
}
#if !_16BPP_HACK
}
#endif
switch (destformat) {
case GR_TEXFMT_ARGB_8888:
case GFX_TEXFMT_ARGB_8888:
/*
* prepare texture enhancements (x2, x4 scalers)
@ -311,9 +302,9 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
/* 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
* cards that support fxt1 also support dxtn. (3dfx and Intel) */
if ((destformat == GR_TEXFMT_ALPHA_INTENSITY_88) ||
(destformat == GR_TEXFMT_ARGB_8888) ||
(destformat == GR_TEXFMT_ALPHA_8)) {
if ((destformat == GFX_TEXFMT_ALPHA_INTENSITY_88) ||
(destformat == GFX_TEXFMT_ARGB_8888) ||
(destformat == GFX_TEXFMT_ALPHA_8)) {
compressionType = S3TC_COMPRESSION;
}
tmptex = (texture == _tex1) ? _tex2 : _tex1;
@ -331,11 +322,11 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
/*
* texture (re)conversions
*/
if (destformat == GR_TEXFMT_ARGB_8888) {
if (srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GR_TEXFMT_ARGB_4444;
if (srcformat != GR_TEXFMT_ARGB_8888) {
if (destformat == GFX_TEXFMT_ARGB_8888) {
if (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GFX_TEXFMT_ARGB_4444;
if (srcformat != GFX_TEXFMT_ARGB_8888) {
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);
return 0;
}
@ -346,7 +337,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
break;
#if !_16BPP_HACK
case GR_TEXFMT_ARGB_4444:
case GFX_TEXFMT_ARGB_4444:
int scale_shift = 0;
tmptex = (texture == _tex1) ? _tex2 : _tex1;
@ -407,18 +398,19 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
tmptex = (texture == _tex1) ? _tex2 : _tex1;
SmoothFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SMOOTH_FILTER_MASK));
texture = tmptex;
} else if (_options & SHARP_FILTER_MASK) {
}
else if (_options & SHARP_FILTER_MASK) {
tmptex = (texture == _tex1) ? _tex2 : _tex1;
SharpFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SHARP_FILTER_MASK));
texture = tmptex;
}
break;
case GR_TEXFMT_ARGB_1555:
case GFX_TEXFMT_ARGB_1555:
break;
case GR_TEXFMT_RGB_565:
case GFX_TEXFMT_RGB_565:
break;
case GR_TEXFMT_ALPHA_8:
case GFX_TEXFMT_ALPHA_8:
break;
#endif /* _16BPP_HACK */
}
@ -442,8 +434,8 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
return 1;
}
boolean
TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info)
bool
TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info)
{
/* NOTE: Rice CRC32 sometimes return the same value for different textures.
* 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.
* A comp comes before RGB comp.
*/
if (palette && info->format == GR_TEXFMT_P_8) {
DBG_INFO(80, "found GR_TEXFMT_P_8 format. Need conversion!!\n");
if (palette && info->format == GFX_TEXFMT_P_8) {
DBG_INFO(80, "found GFX_TEXFMT_P_8 format. Need conversion!!\n");
int width = info->width;
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 */
_txQuantize->P8_16BPP((uint32*)texture, (uint32*)tmptex, info->width, info->height, (uint32*)palette);
texture = tmptex;
format = GR_TEXFMT_ARGB_1555;
format = GFX_TEXFMT_ARGB_1555;
#if 1
/* XXX: compressed if memory cache compression is ON */
if (_options & COMPRESSION_MASK) {
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;
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;
if (_txQuantize->compress(texture, tmptex,
info->width, info->height, GR_TEXFMT_ARGB_1555,
info->width, info->height, GFX_TEXFMT_ARGB_1555,
&width, &height, &format,
_options & COMPRESSION_MASK)) {
texture = tmptex;
}
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);
return 0;
}*/
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!!! */
_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;
@ -580,7 +572,7 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i
return 0;
}
uint64
uint64_t
TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{
if (_options & (HIRESTEXTURES_MASK | DUMP_TEX))
@ -590,8 +582,8 @@ TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride,
return 0;
}
boolean
TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64)
bool
TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64)
{
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",
(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;
}
@ -657,7 +649,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf
return 0;
}
boolean TxFilter::reloadhirestex()
bool TxFilter::reloadhirestex()
{
DBG_INFO(80, "Reload hires textures from texture pack.\n");

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXFILTER_H__
#define __TXFILTER_H__
@ -51,7 +42,7 @@ private:
TxHiResCache *_txHiResCache;
TxUtil *_txUtil;
TxImage *_txImage;
boolean _initialized;
bool _initialized;
void clear();
public:
~TxFilter();
@ -63,19 +54,19 @@ public:
const char *path,
const char *ident,
dispInfoFuncExt callback);
boolean filter(uint8 *src,
bool filter(uint8 *src,
int srcwidth,
int srcheight,
uint16 srcformat,
uint64 g64crc, /* glide64 crc, 64bit for future use */
uint64_t g64crc, /* glide64 crc, 64bit for future use */
GHQTexInfo *info);
boolean hirestex(uint64 g64crc, /* glide64 crc, 64bit for future use */
uint64 r_crc64, /* checksum hi:palette low:texture */
bool hirestex(uint64_t g64crc, /* glide64 crc, 64bit for future use */
uint64_t r_crc64, /* checksum hi:palette low:texture */
uint16 *palette,
GHQTexInfo *info);
uint64 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);
boolean reloadhirestex();
uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);
bool dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64);
bool reloadhirestex();
};
#endif /* __TXFILTER_H__ */

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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
#pragma warning(disable: 4786)
@ -30,75 +21,75 @@
TxFilter *txFilter = NULL;
#ifdef __cplusplus
extern "C"{
extern "C" {
#endif
TAPI boolean TAPIENTRY
txfilter_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize,
TAPI bool TAPIENTRY
txfilter_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize,
const char *path, const char * ident,
dispInfoFuncExt callback)
{
{
if (txFilter) return 0;
txFilter = new TxFilter(maxwidth, maxheight, maxbpp, options, cachesize,
path, ident, callback);
return (txFilter ? 1 : 0);
}
}
void txfilter_shutdown(void)
{
void txfilter_shutdown(void)
{
if (txFilter) delete txFilter;
txFilter = NULL;
}
}
TAPI boolean TAPIENTRY
txfilter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat,
uint64 g64crc, GHQTexInfo *info)
{
TAPI bool TAPIENTRY
txfilter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat,
uint64_t g64crc, GHQTexInfo *info)
{
if (txFilter)
return txFilter->filter(src, srcwidth, srcheight, srcformat,
g64crc, info);
return 0;
}
}
TAPI boolean TAPIENTRY
txfilter_hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info)
{
TAPI bool TAPIENTRY
txfilter_hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info)
{
if (txFilter)
return txFilter->hirestex(g64crc, r_crc64, palette, info);
return 0;
}
}
TAPI uint64 TAPIENTRY
txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{
TAPI uint64_t TAPIENTRY
txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{
if (txFilter)
return txFilter->checksum64(src, width, height, size, rowStride, palette);
return 0;
}
}
TAPI boolean TAPIENTRY
txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64)
{
TAPI bool TAPIENTRY
txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64)
{
if (txFilter)
return txFilter->dmptx(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64);
return 0;
}
}
TAPI boolean TAPIENTRY
txfilter_reloadhirestex()
{
TAPI bool TAPIENTRY
txfilter_reloadhirestex()
{
if (txFilter)
return txFilter->reloadhirestex();
return 0;
}
}
#ifdef __cplusplus
}

View File

@ -1,28 +1,17 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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. */
/***************************************************************************
* *
* 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) 2007 Hiroshi Morii *
* Copyright (C) 2003 Rice1964 *
* *
* 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
#pragma warning(disable: 4786)
@ -32,13 +21,13 @@
* (0:disable, 1:enable) */
#define DUMP_CACHE 1
/* handle oversized textures by
/* handle oversized textures by
* 0: minification
* 1: Glide64 style tiling
*/
#define TEXTURE_TILING 1
/* use power of 2 texture size
/* use power of 2 texture size
* (0:disable, 1:enable, 2:3dfx) */
#define POW2_TEXTURES 2
@ -47,12 +36,12 @@
#define POW2_TEXTURES 2
#endif
/* hack to reduce texture footprint to achieve
/* hack to reduce texture footprint to achieve
* better performace on midrange gfx cards.
* (0:disable, 1:enable) */
#define REDUCE_TEXTURE_FOOTPRINT 0
/* use aggressive format assumption for quantization
/* use aggressive format assumption for quantization
* (0:disable, 1:enable, 2:extreme) */
#define AGGRESSIVE_QUANTIZATION 1
@ -62,6 +51,7 @@
#include <string>
#include <Common/path.h>
#include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
#ifdef _WIN32
#include <io.h>
#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) :
TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback)
TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback)
{
_txImage = new TxImage();
_txQuantize = new TxQuantize();
@ -129,14 +119,14 @@ TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback)
if (!_haveCache) TxHiResCache::load(0);
}
boolean
bool
TxHiResCache::empty()
{
return _cache.empty();
}
boolean
TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */
bool
TxHiResCache::load(bool replace) /* 0 : reload, 1 : replace partial */
{
if (!_path.empty() && !_ident.empty())
{
@ -168,7 +158,7 @@ TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */
return 0;
}
boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
{
#ifdef _WIN32
DBG_INFO(80, "-----\n");
@ -198,12 +188,6 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
{
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;
DBG_INFO(80, "-----\n");
@ -221,7 +205,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* Rice hi-res textures: begin
*/
uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0;
char *pfname = NULL, fname[MAX_PATH];
char *pfname = NULL, fname[260];
std::string ident;
FILE *fp = NULL;
@ -240,7 +224,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* read in Rice's file naming convention */
#define CRCFMTSIZ_LEN 13
#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!
* files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci
* 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 */
if (!replace) {
uint64 chksum64 = (uint64)palchksum;
uint64_t chksum64 = (uint64_t)palchksum;
chksum64 <<= 32;
chksum64 |= (uint64)chksum;
chksum64 |= (uint64_t)chksum;
if (TxCache::is_cached(chksum64)) {
#if !DEBUG
INFO(80, "-----\n");
@ -382,7 +366,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
if (tmptex) {
/* check if _rgb.* and _a.* have matching size and format. */
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
INFO(80, "-----\n");
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) {
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");
}
if (tex) free(tex);
@ -421,7 +405,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
uint32 texel = ((uint32*)tmptex)[i];
uint32 acomp = (((texel >> 16) & 0xff) * 6969 +
((texel >> 8) & 0xff) * 23434 +
((texel)& 0xff) * 2365) / 32768;
((texel) & 0xff) * 2365) / 32768;
((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff);
#endif
#if 0
@ -429,7 +413,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
uint32 texel = ((uint32*)tmptex)[i];
uint32 acomp = (((texel >> 16) & 0xff) * 299 +
((texel >> 8) & 0xff) * 587 +
((texel)& 0xff) * 114) / 1000;
((texel) & 0xff) * 114) / 1000;
((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff);
#endif
}
@ -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);
/* check if size and format are OK */
if (!(format == GR_TEXFMT_ARGB_8888 ||
format == GR_TEXFMT_P_8 ||
format == GR_TEXFMT_ARGB_CMP_DXT1 ||
format == GR_TEXFMT_ARGB_CMP_DXT3 ||
format == GR_TEXFMT_ARGB_CMP_DXT5) ||
if (!(format == GFX_TEXFMT_ARGB_8888 ||
format == GFX_TEXFMT_P_8 ||
format == GFX_TEXFMT_ARGB_CMP_DXT1 ||
format == GFX_TEXFMT_ARGB_CMP_DXT3 ||
format == GFX_TEXFMT_ARGB_CMP_DXT5) ||
(width * height) < 4) { /* TxQuantize requirement: width * height must be 4 or larger. */
free(tex);
tex = NULL;
@ -541,11 +525,11 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
}
/* analyze and determine best format to quantize */
if (format == GR_TEXFMT_ARGB_8888) {
if (format == GFX_TEXFMT_ARGB_8888) {
int i;
int alphabits = 0;
int fullalpha = 0;
boolean intensity = 1;
bool intensity = 1;
if (!(_options & LET_TEXARTISTS_FLY)) {
/* HACK ALERT! */
@ -634,7 +618,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
if (intensity) {
int rcomp = (texel >> 16) & 0xff;
int gcomp = (texel >> 8) & 0xff;
int bcomp = (texel)& 0xff;
int bcomp = (texel) & 0xff;
#if AGGRESSIVE_QUANTIZATION
if (abs(rcomp - gcomp) > 8 || abs(rcomp - bcomp) > 8 || abs(gcomp - bcomp) > 8) intensity = 0;
#else
@ -649,33 +633,33 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & (FORCE16BPP_HIRESTEX | COMPRESSION_MASK)) {
#endif
if (alphabits == 0) destformat = GR_TEXFMT_RGB_565;
else if (alphabits == 1) destformat = GR_TEXFMT_ARGB_1555;
else destformat = GR_TEXFMT_ARGB_8888;
if (alphabits == 0) destformat = GFX_TEXFMT_RGB_565;
else if (alphabits == 1) destformat = GFX_TEXFMT_ARGB_1555;
else destformat = GFX_TEXFMT_ARGB_8888;
#if !REDUCE_TEXTURE_FOOTPRINT
}
else {
destformat = GR_TEXFMT_ARGB_8888;
destformat = GFX_TEXFMT_ARGB_8888;
}
#endif
if (fmt == 4 && alphabits == 0) {
destformat = GR_TEXFMT_ARGB_8888;
destformat = GFX_TEXFMT_ARGB_8888;
/* Rice I format; I = (R + G + B) / 3 */
for (i = 0; i < height * width; i++) {
uint32 texel = ((uint32*)tex)[i];
uint32 icomp = (((texel >> 16) & 0xff) +
((texel >> 8) & 0xff) +
((texel)& 0xff)) / 3;
((texel) & 0xff)) / 3;
((uint32*)tex)[i] = (icomp << 24) | (texel & 0x00ffffff);
}
}
if (intensity) {
if (alphabits == 0) {
if (fmt == 4) destformat = GR_TEXFMT_ALPHA_8;
else destformat = GR_TEXFMT_INTENSITY_8;
if (fmt == 4) destformat = GFX_TEXFMT_ALPHA_8;
else destformat = GFX_TEXFMT_INTENSITY_8;
}
else {
destformat = GR_TEXFMT_ALPHA_INTENSITY_88;
destformat = GFX_TEXFMT_ALPHA_INTENSITY_88;
}
}
@ -685,7 +669,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
* Rice hi-res textures: end */
/* XXX: only ARGB8888 for now. comeback to this later... */
if (format == GR_TEXFMT_ARGB_8888) {
if (format == GFX_TEXFMT_ARGB_8888) {
#if TEXTURE_TILING
/* Glide64 style texture tiling */
@ -751,7 +735,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* tiling */
if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) {
boolean usetile = 0;
bool usetile = 0;
/* to tile or not to tile, that is the question */
if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) {
@ -833,7 +817,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
int ratio = 1;
if (width / _maxwidth > height / _maxheight) {
ratio = (int)ceil((double)width / _maxwidth);
} else {
}
else {
ratio = (int)ceil((double)height / _maxheight);
}
if (!_txReSample->minify(&tex, &width, &height, ratio)) {
@ -880,40 +865,40 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
switch (_options & COMPRESSION_MASK) {
case S3TC_COMPRESSION:
switch (destformat) {
case GR_TEXFMT_ARGB_8888:
case GFX_TEXFMT_ARGB_8888:
#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
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GFX_TEXFMT_ALPHA_INTENSITY_88:
dataSize = width * height;
break;
#if !GLIDE64_DXTN
case GR_TEXFMT_ARGB_1555:
case GFX_TEXFMT_ARGB_1555:
#endif
case GR_TEXFMT_RGB_565:
case GR_TEXFMT_INTENSITY_8:
case GFX_TEXFMT_RGB_565:
case GFX_TEXFMT_INTENSITY_8:
dataSize = (width * height) >> 1;
break;
case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
;
}
break;
case FXT1_COMPRESSION:
switch (destformat) {
case GR_TEXFMT_ARGB_1555:
case GR_TEXFMT_RGB_565:
case GR_TEXFMT_INTENSITY_8:
case GFX_TEXFMT_ARGB_1555:
case GFX_TEXFMT_RGB_565:
case GFX_TEXFMT_INTENSITY_8:
dataSize = (width * height) >> 1;
break;
/* 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
* cards that support fxt1 also support dxtn. (3dfx and Intel) */
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ARGB_8888:
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GFX_TEXFMT_ARGB_8888:
compressionType = S3TC_COMPRESSION;
dataSize = width * height;
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 */
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat));
if (tmptex) {
if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0))
_txQuantize->quantize(tmptex, tex, width, height, destformat, GR_TEXFMT_ARGB_8888, 0);
if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0))
_txQuantize->quantize(tmptex, tex, width, height, destformat, GFX_TEXFMT_ARGB_8888, 0);
free(tmptex);
}
#endif
@ -967,40 +952,40 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat));
if (tmptex) {
switch (destformat) {
case GR_TEXFMT_ARGB_8888:
case GR_TEXFMT_ARGB_4444:
case GFX_TEXFMT_ARGB_8888:
case GFX_TEXFMT_ARGB_4444:
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif
destformat = GR_TEXFMT_ARGB_4444;
destformat = GFX_TEXFMT_ARGB_4444;
break;
case GR_TEXFMT_ARGB_1555:
case GFX_TEXFMT_ARGB_1555:
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif
destformat = GR_TEXFMT_ARGB_1555;
destformat = GFX_TEXFMT_ARGB_1555;
break;
case GR_TEXFMT_RGB_565:
case GFX_TEXFMT_RGB_565:
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif
destformat = GR_TEXFMT_RGB_565;
destformat = GFX_TEXFMT_RGB_565;
break;
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ALPHA_INTENSITY_44:
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GFX_TEXFMT_ALPHA_INTENSITY_44:
#if !REDUCE_TEXTURE_FOOTPRINT
destformat = GR_TEXFMT_ALPHA_INTENSITY_88;
destformat = GFX_TEXFMT_ALPHA_INTENSITY_88;
#else
destformat = GR_TEXFMT_ALPHA_INTENSITY_44;
destformat = GFX_TEXFMT_ALPHA_INTENSITY_44;
#endif
break;
case GR_TEXFMT_ALPHA_8:
destformat = GR_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */
case GFX_TEXFMT_ALPHA_8:
destformat = GFX_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */
break;
case GR_TEXFMT_INTENSITY_8:
destformat = GR_TEXFMT_INTENSITY_8;
case GFX_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;
free(tex);
tex = tmptex;
@ -1029,9 +1014,9 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
/* load it into hires texture cache. */
{
uint64 chksum64 = (uint64)palchksum;
uint64_t chksum64 = (uint64_t)palchksum;
chksum64 <<= 32;
chksum64 |= (uint64)chksum;
chksum64 |= (uint64_t)chksum;
GHQTexInfo tmpInfo;
memset(&tmpInfo, 0, sizeof(GHQTexInfo));
@ -1047,7 +1032,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#if TEXTURE_TILING
/* Glide64 style texture tiling. */
if (untiled_width && untiled_height) {
if (untiled_width && untiled_height)
{
tmpInfo.tiles = ((untiled_width - 1) >> 8) + 1;
tmpInfo.untiled_width = untiled_width;
tmpInfo.untiled_height = untiled_height;
@ -1055,17 +1041,20 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace)
#endif
/* remove redundant in cache */
if (replace && TxCache::del(chksum64)) {
if (replace && TxCache::del(chksum64))
{
DBG_INFO(80, "removed duplicate old cache.\n");
}
/* add to cache */
if (TxCache::add(chksum64, &tmpInfo)) {
if (TxCache::add(chksum64, &tmpInfo))
{
/* Callback to display hires texture info.
* Gonetz <gonetz(at)ngs.ru> */
if (_callback) {
wchar_t tmpbuf[MAX_PATH];
mbstowcs(tmpbuf, fname, MAX_PATH);
if (_callback)
{
wchar_t tmpbuf[260];
mbstowcs(tmpbuf, fname, 260);
(*_callback)("[%d] total mem:%.2fmb - %ls\n", _cache.size(), (float)_totalSize / 1000000, tmpbuf);
}
DBG_INFO(80, "texture loaded!\n");

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXHIRESCACHE_H__
#define __TXHIRESCACHE_H__
@ -41,19 +32,19 @@ private:
int _maxwidth;
int _maxheight;
int _maxbpp;
boolean _haveCache;
boolean _abortLoad;
bool _haveCache;
bool _abortLoad;
TxImage *_txImage;
TxQuantize *_txQuantize;
TxReSample *_txReSample;
boolean loadHiResTextures(const char * dir_path, boolean replace);
bool loadHiResTextures(const char * dir_path, bool replace);
public:
~TxHiResCache();
TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options,
const char *path, const char *ident,
dispInfoFuncExt callback);
boolean empty();
boolean load(boolean replace);
bool empty();
bool load(bool replace);
};
#endif /* __TXHIRESCACHE_H__ */

View File

@ -1,40 +1,31 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
/* use power of 2 texture size
* (0:disable, 1:enable, 2:3dfx) */
#define POW2_TEXTURES 0
/* check 8 bytes. use a larger value if needed. */
/* check 8 bytes. use a larger value if needed. */
#define PNG_CHK_BYTES 8
#include "TxImage.h"
#include "TxReSample.h"
#include "TxDbg.h"
#include <stdlib.h>
#include <Project64-video/Renderer/types.h>
boolean
TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr)
bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr)
{
unsigned char sig[PNG_CHK_BYTES];
@ -76,7 +67,7 @@ TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr)
uint8*
TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format)
{
/* NOTE: returned image format is GR_TEXFMT_ARGB_8888 */
/* NOTE: returned image format is GFX_TEXFMT_ARGB_8888 */
png_structp png_ptr;
png_infop info_ptr;
@ -203,7 +194,7 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format)
*width = (row_bytes >> 2);
*height = o_height;
*format = GR_TEXFMT_ARGB_8888;
*format = GFX_TEXFMT_ARGB_8888;
#if POW2_TEXTURES
/* next power of 2 size conversions */
@ -244,7 +235,7 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format)
return image;
}
boolean
bool
TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette)
{
png_structp png_ptr;
@ -396,7 +387,7 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui
return 1;
}
boolean
bool
TxImage::getBMPInfo(FILE* fp, BITMAPFILEHEADER* bmp_fhdr, BITMAPINFOHEADER* bmp_ihdr)
{
/*
@ -490,8 +481,8 @@ uint8*
TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
{
/* NOTE: returned image format;
* 4, 8bit palette bmp -> GR_TEXFMT_P_8
* 24, 32bit bmp -> GR_TEXFMT_ARGB_8888
* 4, 8bit palette bmp -> GFX_TEXFMT_P_8
* 24, 32bit bmp -> GFX_TEXFMT_ARGB_8888
*/
uint8 *image = NULL;
@ -562,7 +553,7 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
fseek(fp, pos, SEEK_SET);
fread(image_row, row_bytes, 1, fp);
/* expand 4bpp to 8bpp. stuff 4bit values into 8bit comps. */
for (j = 0; j < (int) row_bytes; j++) {
for (j = 0; j < (int)row_bytes; j++) {
tmpimage[j << 1] = image_row[j] & 0x0f;
tmpimage[(j << 1) + 1] = (image_row[j] & 0xf0) >> 4;
}
@ -570,7 +561,8 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
pos -= row_bytes;
}
free(image_row);
} else {
}
else {
if (image_row) free(image_row);
if (image) free(image);
image = NULL;
@ -598,7 +590,8 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
pos -= row_bytes;
}
free(image_row);
} else {
}
else {
if (image_row) free(image_row);
if (image) free(image);
image = NULL;
@ -612,11 +605,11 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
switch (bmp_ihdr.biBitCount) {
case 8:
case 4:
*format = GR_TEXFMT_P_8;
*format = GFX_TEXFMT_P_8;
break;
case 32:
case 24:
*format = GR_TEXFMT_ARGB_8888;
*format = GFX_TEXFMT_ARGB_8888;
}
#if POW2_TEXTURES
@ -655,7 +648,7 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
return image;
}
boolean
bool
TxImage::getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr)
{
/*
@ -753,7 +746,7 @@ TxImage::readDDS(FILE* fp, int* width, int* height, uint16* format)
DBG_INFO(80, "dds format %d x %d HeaderSize %d LinearSize %d\n",
dds_fhdr.dwWidth, dds_fhdr.dwHeight, dds_fhdr.dwSize, dds_fhdr.dwLinearSize);
if (!(dds_fhdr.dwFlags & (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT|DDSD_LINEARSIZE))) {
if (!(dds_fhdr.dwFlags & (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_LINEARSIZE))) {
DBG_INFO(80, "Error: incompatible dds format!\n");
return NULL;
}
@ -772,16 +765,19 @@ TxImage::readDDS(FILE* fp, int* width, int* height, uint16* format)
DBG_INFO(80, "DXT1 format\n");
/* compensate for missing LinearSize */
dds_fhdr.dwLinearSize = (dds_fhdr.dwWidth * dds_fhdr.dwHeight) >> 1;
tmpformat = GR_TEXFMT_ARGB_CMP_DXT1;
} else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT3", 4) == 0) {
tmpformat = GFX_TEXFMT_ARGB_CMP_DXT1;
}
else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT3", 4) == 0) {
DBG_INFO(80, "DXT3 format\n");
dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight;
tmpformat = GR_TEXFMT_ARGB_CMP_DXT3;
} else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT5", 4) == 0) {
tmpformat = GFX_TEXFMT_ARGB_CMP_DXT3;
}
else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT5", 4) == 0) {
DBG_INFO(80, "DXT5 format\n");
dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight;
tmpformat = GR_TEXFMT_ARGB_CMP_DXT5;
} else {
tmpformat = GFX_TEXFMT_ARGB_CMP_DXT5;
}
else {
DBG_INFO(80, "Error: not DXT1 or DXT3 or DXT5 format!\n");
return NULL;
}

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXIMAGE_H__
#define __TXIMAGE_H__
@ -28,7 +19,6 @@
#include <png/png.h>
#include "TxInternal.h"
#ifndef WIN32
typedef struct tagBITMAPFILEHEADER {
unsigned short bfType;
unsigned long bfSize;
@ -50,10 +40,6 @@ typedef struct tagBITMAPINFOHEADER {
unsigned long biClrUsed;
unsigned long biClrImportant;
} BITMAPINFOHEADER;
#else
typedef struct tagBITMAPFILEHEADER BITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER;
#endif
#define DDSD_CAPS 0x00000001
#define DDSD_HEIGHT 0x00000002
@ -101,14 +87,14 @@ typedef struct tagDDSFILEHEADER {
class TxImage
{
private:
boolean getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr);
boolean getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr);
boolean getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr);
bool getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr);
bool getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr);
bool getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr);
public:
TxImage() {}
~TxImage() {}
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* readDDS(FILE* fp, int* width, int* height, uint16* format);
};

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __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
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXQUANTIZE_H__
#define __TXQUANTIZE_H__
@ -64,10 +55,10 @@ private:
void ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height);
/* compressors */
boolean FXT1(uint8 *src, uint8 *dest,
bool FXT1(uint8 *src, uint8 *dest,
int srcwidth, int srcheight, uint16 srcformat,
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 *destwidth, int *destheight, uint16 *destformat);
@ -78,14 +69,13 @@ public:
/* others */
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,
bool compress(uint8 *src, uint8 *dest,
int srcwidth, int srcheight, uint16 srcformat,
int *destwidth, int *destheight, uint16 *destformat,
int compressionType);
#if 0 /* unused */
void ARGB8888_I8(uint32* src, uint32* dst, int width, int height);
void I8_ARGB8888(uint32* src, uint32* dst, int width, int height);

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 "TxReSample.h"
#include "TxDbg.h"
@ -48,8 +39,8 @@ TxReSample::nextPow2(int num)
return num;
}
boolean
TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean use_3dfx = 0)
bool
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 */
@ -85,7 +76,8 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean us
if (n_width > n_height) {
if (n_width > (n_height << 3))
n_height = n_width >> 3;
} else {
}
else {
if (n_height > (n_width << 3)) {
n_width = n_height >> 3;
row_bytes = (n_width * bpp) >> 3;
@ -119,7 +111,7 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean us
memcpy(tmppow2image, tmpimage, ((o_width * bpp) >> 3));
/* expand to pow2 size by replication */
for(j = ((o_width * bpp) >> 3); j < row_bytes; j++)
for (j = ((o_width * bpp) >> 3); j < row_bytes; j++)
tmppow2image[j] = tmppow2image[j - (bpp >> 3)];
tmppow2image += row_bytes;
@ -173,7 +165,7 @@ double
TxReSample::lanczos3(double 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;
}
@ -194,7 +186,8 @@ TxReSample::mitchell(double x)
x = (((12.0 - 9.0 * B - 6.0 * C) * (x * x * x))
+ ((-18.0 + 12.0 * B + 6.0 * C) * (x * x))
+ (6.0 - 2.0 * B));
} else {
}
else {
x = (((-1.0 * B - 6.0 * C) * (x * x * x))
+ ((6.0 * B + 30.0 * C) * (x * x))
+ ((-12.0 * B - 48.0 * C) * x)
@ -238,7 +231,7 @@ TxReSample::kaiser(double x)
return sinc(x) * besselI0(alpha * sqrt(1 - ratio * ratio)) / besselI0(alpha);
}
boolean
bool
TxReSample::minify(uint8 **src, int *width, int *height, int ratio)
{
/* NOTE: src must be ARGB8888, ratio is the inverse representation */
@ -349,7 +342,7 @@ TxReSample::minify(uint8 **src, int *width, int *height, int 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];
B = (double)((texel) & 0xff) * weight[0];
for (y2 = 1; y2 < half_window * ratio; y2++) {
z = y * ratio + y2;
if (z >= *height) z = *height - 1;
@ -357,14 +350,14 @@ TxReSample::minify(uint8 **src, int *width, int *height, int ratio)
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];
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];
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;
@ -377,7 +370,7 @@ TxReSample::minify(uint8 **src, int *width, int *height, int 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];
B = (double)((texel) & 0xff) * weight[0];
for (x2 = 1; x2 < half_window * ratio; x2++) {
z = x * ratio + x2;
if (z >= *width) z = *width - 1;
@ -385,14 +378,14 @@ TxReSample::minify(uint8 **src, int *width, int *height, int ratio)
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];
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];
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;

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXRESAMPLE_H__
#define __TXRESAMPLE_H__
@ -37,8 +28,8 @@ private:
double besselI0(double x);
double kaiser(double x);
public:
boolean minify(uint8 **src, int *width, int *height, int ratio);
boolean nextPow2(uint8** image, int* width, int* height, int bpp, boolean use_3dfx);
bool minify(uint8 **src, int *width, int *height, int ratio);
bool nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3dfx);
int nextPow2(int num);
};

View File

@ -1,26 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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
#pragma warning(disable: 4786)
#endif
@ -53,7 +43,7 @@ TxTexCache::~TxTexCache()
}
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 */
if (_path.empty() || _ident.empty() || !_cacheSize)
@ -75,7 +65,7 @@ TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback)
#endif
}
boolean TxTexCache::add(uint64 checksum, GHQTexInfo *info)
bool TxTexCache::add(uint64_t checksum, GHQTexInfo *info)
{
if (_cacheSize <= 0) return 0;

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXTEXCACHE_H__
#define __TXTEXCACHE_H__
@ -32,7 +23,7 @@ public:
~TxTexCache();
TxTexCache(int options, int cachesize, const char *path, const char *ident,
dispInfoFuncExt callback);
boolean add(uint64 checksum, /* checksum hi:palette low:texture */
bool add(uint64_t checksum, /* checksum hi:palette low:texture */
GHQTexInfo *info);
};

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 "TxUtil.h"
#include "TxDbg.h"
@ -27,59 +18,37 @@
#include <malloc.h>
#include <stdlib.h>
#include <Common/stdtypes.h>
#include <Project64-video/Renderer/types.h>
#include <windows.h>
/*
* External libraries
******************************************************************************/
TxLoadLib::TxLoadLib()
{
#ifdef DXTN_DLL
if (!_dxtnlib)
_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()
{
#ifdef DXTN_DLL
/* free dynamic library */
if (_dxtnlib)
FreeLibrary(_dxtnlib);
#endif
}
fxtCompressTexFuncExt
TxLoadLib::getfxtCompressTexFuncExt()
fxtCompressTexFuncExt TxLoadLib::getfxtCompressTexFuncExt()
{
return _tx_compress_fxt1;
}
dxtCompressTexFuncExt
TxLoadLib::getdxtCompressTexFuncExt()
dxtCompressTexFuncExt TxLoadLib::getdxtCompressTexFuncExt()
{
return _tx_compress_dxtn;
}
/*
* Utilities
******************************************************************************/
uint32
TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format)
uint32 TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format)
{
int dataSize = sizeofTx(width, height, format);
@ -92,36 +61,35 @@ TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format)
return (dataSize ? crc32(crc32(0L, Z_NULL, 0), src, dataSize) : 0);
}
int
TxUtil::sizeofTx(int width, int height, uint16 format)
int TxUtil::sizeofTx(int width, int height, uint16 format)
{
int dataSize = 0;
/* a lookup table for the shifts would be better */
switch (format) {
case GR_TEXFMT_ARGB_CMP_FXT1:
case GFX_TEXFMT_ARGB_CMP_FXT1:
dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1;
break;
case GR_TEXFMT_ARGB_CMP_DXT1:
case GFX_TEXFMT_ARGB_CMP_DXT1:
dataSize = (((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3)) >> 1;
break;
case GR_TEXFMT_ARGB_CMP_DXT3:
case GR_TEXFMT_ARGB_CMP_DXT5:
case GFX_TEXFMT_ARGB_CMP_DXT3:
case GFX_TEXFMT_ARGB_CMP_DXT5:
dataSize = ((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3);
break;
case GR_TEXFMT_ALPHA_INTENSITY_44:
case GR_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8:
case GR_TEXFMT_P_8:
case GFX_TEXFMT_ALPHA_INTENSITY_44:
case GFX_TEXFMT_ALPHA_8:
case GFX_TEXFMT_INTENSITY_8:
case GFX_TEXFMT_P_8:
dataSize = width * height;
break;
case GR_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_1555:
case GR_TEXFMT_RGB_565:
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GFX_TEXFMT_ARGB_4444:
case GFX_TEXFMT_ARGB_1555:
case GFX_TEXFMT_RGB_565:
case GFX_TEXFMT_ALPHA_INTENSITY_88:
dataSize = (width * height) << 1;
break;
case GR_TEXFMT_ARGB_8888:
case GFX_TEXFMT_ARGB_8888:
dataSize = (width * height) << 2;
break;
default:
@ -133,52 +101,7 @@ TxUtil::sizeofTx(int width, int height, uint16 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)
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.
@ -189,8 +112,7 @@ TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStride)
return RiceCRC32(src, width, height, size, rowStride);
}
uint64
TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
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.
@ -199,28 +121,33 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u
if (!src) return 0;
uint64 crc64Ret = 0;
uint64_t crc64Ret = 0;
if (palette) {
if (palette)
{
uint32 crc32 = 0, cimax = 0;
switch (size & 0xff) {
switch (size & 0xff)
{
case 1:
if (RiceCRC32_CI8(src, width, height, size, rowStride, &crc32, &cimax)) {
crc64Ret = (uint64)RiceCRC32(palette, cimax + 1, 1, 2, 512);
if (RiceCRC32_CI8(src, width, height, size, rowStride, &crc32, &cimax))
{
crc64Ret = (uint64_t)RiceCRC32(palette, cimax + 1, 1, 2, 512);
crc64Ret <<= 32;
crc64Ret |= (uint64)crc32;
crc64Ret |= (uint64_t)crc32;
}
break;
case 0:
if (RiceCRC32_CI4(src, width, height, size, rowStride, &crc32, &cimax)) {
crc64Ret = (uint64)RiceCRC32(palette, cimax + 1, 1, 2, 32);
if (RiceCRC32_CI4(src, width, height, size, rowStride, &crc32, &cimax))
{
crc64Ret = (uint64_t)RiceCRC32(palette, cimax + 1, 1, 2, 32);
crc64Ret <<= 32;
crc64Ret |= (uint64)crc32;
crc64Ret |= (uint64_t)crc32;
}
}
}
if (!crc64Ret) {
crc64Ret = (uint64)RiceCRC32(src, width, height, size, rowStride);
if (!crc64Ret)
{
crc64Ret = (uint64_t)RiceCRC32(src, width, height, size, rowStride);
}
return crc64Ret;
@ -261,42 +188,20 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u
** separately. (Any sequence of zeroes has a Fletcher checksum of zero.)
*/
uint32
TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32)
uint32 TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32)
{
#if 1
/* zlib adler32 */
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
TxUtil::Adler32(const uint8* src, int width, int height, int size, int rowStride)
uint32 TxUtil::Adler32(const uint8* src, int width, int height, int size, int rowStride)
{
int i;
uint32 ret = 1;
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;
}
@ -321,17 +226,16 @@ template<class T> static T __ROL__(T value, unsigned int count)
* for Rice hires texture packs.
*
* BYTE* addr = (BYTE*)(gfx.RDRAM +
* rdp.addr[rdp.tiles[tile].t_mem] +
* (rdp.tiles[tile].ul_t * bpl) +
* (((rdp.tiles[tile].ul_s<<rdp.tiles[tile].size)+1)>>1));
* rdp.addr[rdp.tiles(tile).t_mem] +
* (rdp.tiles(tile).ul_t * bpl) +
* (((rdp.tiles(tile).ul_s<<rdp.tiles(tile).size)+1)>>1));
* RiceCRC32(addr,
* rdp.tiles[tile].width,
* rdp.tiles[tile].height,
* (unsigned short)(rdp.tiles[tile].format << 8 | rdp.tiles[tile].size),
* rdp.tiles(tile).width,
* rdp.tiles(tile).height,
* (unsigned short)(rdp.tiles(tile).format << 8 | rdp.tiles(tile).size),
* bpl);
*/
uint32
TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride)
uint32 TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride)
{
const uint8_t *row;
uint32_t crc32Ret;
@ -345,8 +249,10 @@ TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStri
row = src;
crc32Ret = 0;
for (cur_height = height - 1; cur_height >= 0; cur_height--) {
for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) {
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];
word_hash = pos ^ word;
tmp = __ROL__(crc32Ret, 4);
@ -358,9 +264,7 @@ TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStri
return crc32Ret;
}
boolean
TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax)
bool TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, uint32* crc32, uint32* cimax)
{
const uint8_t *row;
uint32_t crc32Ret;
@ -376,10 +280,13 @@ TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int row
crc32Ret = 0;
cimaxRet = 0;
for (cur_height = height - 1; cur_height >= 0; cur_height--) {
for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) {
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];
if (cimaxRet != 15) {
if (cimaxRet != 15)
{
if ((word & 0xF) >= cimaxRet)
cimaxRet = word & 0xF;
if ((uint32_t)((uint8_t)word >> 4) >= cimaxRet)
@ -394,7 +301,7 @@ TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int row
cimaxRet = (word >> 20) & 0xF;
if (((word >> 24) & 0xF) >= cimaxRet)
cimaxRet = (word >> 24) & 0xF;
if (word >> 28 >= cimaxRet )
if (word >> 28 >= cimaxRet)
cimaxRet = word >> 28;
}
word_hash = pos ^ word;
@ -409,9 +316,7 @@ TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int row
return 1;
}
boolean
TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax)
bool TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, uint32* crc32, uint32* cimax)
{
const uint8_t *row;
uint32_t crc32Ret;
@ -427,10 +332,13 @@ TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int row
crc32Ret = 0;
cimaxRet = 0;
for (cur_height = height - 1; cur_height >= 0; cur_height--) {
for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) {
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];
if (cimaxRet != 255) {
if (cimaxRet != 255)
{
if ((uint8_t)word >= cimaxRet)
cimaxRet = (uint8_t)word;
if ((uint32_t)((uint16_t)word >> 8) >= cimaxRet)
@ -452,20 +360,19 @@ TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int row
return 1;
}
int
TxUtil::log2(int num)
int TxUtil::log2(int num)
{
#if defined(__GNUC__)
return __builtin_ctz(num);
#elif defined(_MSC_VER) && _MSC_VER >= 1400
uint32_t i;
_BitScanForward((DWORD *)&i, num);
_BitScanForward((unsigned long *)&i, num);
return i;
#elif defined(__MSC__)
__asm {
mov eax, dword ptr [num];
mov eax, dword ptr[num];
bsr eax, eax;
mov dword ptr [i], eax;
mov dword ptr[i], eax;
}
#else
switch (num) {
@ -485,20 +392,17 @@ TxUtil::log2(int num)
#endif
}
int
TxUtil::grLodLog2(int w, int h)
int TxUtil::grLodLog2(int w, int h)
{
return (w >= h ? log2(w) : log2(h));
}
int
TxUtil::grAspectRatioLog2(int w, int h)
int 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
TxUtil::getNumberofProcessors()
int TxUtil::getNumberofProcessors()
{
int numcore = 1, ret;
@ -524,7 +428,6 @@ TxUtil::getNumberofProcessors()
return numcore;
}
/*
* Memory buffers for texture manipulations
******************************************************************************/
@ -542,17 +445,19 @@ TxMemBuf::~TxMemBuf()
shutdown();
}
boolean
TxMemBuf::init(int maxwidth, int maxheight)
bool TxMemBuf::init(int maxwidth, int maxheight)
{
int i;
for (i = 0; i < 2; i++) {
if (!_tex[i]) {
for (i = 0; i < 2; i++)
{
if (!_tex[i])
{
_tex[i] = (uint8 *)malloc(maxwidth * maxheight * 4);
_size[i] = maxwidth * maxheight * 4;
}
if (!_tex[i]) {
if (!_tex[i])
{
shutdown();
return 0;
}
@ -560,8 +465,7 @@ TxMemBuf::init(int maxwidth, int maxheight)
return 1;
}
void
TxMemBuf::shutdown()
void TxMemBuf::shutdown()
{
int i;
for (i = 0; i < 2; i++) {
@ -571,14 +475,12 @@ TxMemBuf::shutdown()
}
}
uint8*
TxMemBuf::get(unsigned int num)
uint8* TxMemBuf::get(unsigned int num)
{
return ((num < 2) ? _tex[num] : NULL);
}
uint32
TxMemBuf::size_of(unsigned int num)
uint32 TxMemBuf::size_of(unsigned int num)
{
return ((num < 2) ? _size[num] : 0);
}

View File

@ -1,25 +1,16 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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) 2003 Rice1964 *
* *
* 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 __TXUTIL_H__
#define __TXUTIL_H__
@ -30,37 +21,32 @@
#include "TxInternal.h"
#include <string>
#ifndef DXTN_DLL
#ifdef __cplusplus
extern "C"{
extern "C" {
#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,
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,
void *dest, int destRowStride);
#ifdef __cplusplus
}
#endif
#endif /* DXTN_DLL */
typedef void (*dxtCompressTexFuncExt)(int srccomps, int width,
typedef void(*dxtCompressTexFuncExt)(int srccomps, int width,
int height, const void *srcPixData,
int destformat, void *dest,
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,
void *dest, int destRowStride);
class TxLoadLib
{
private:
#ifdef DXTN_DLL
HMODULE _dxtnlib;
#endif
fxtCompressTexFuncExt _tx_compress_fxt1;
dxtCompressTexFuncExt _tx_compress_dxtn;
TxLoadLib();
@ -80,9 +66,9 @@ private:
uint32 Adler32(const uint8* data, int Len, uint32 Adler);
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);
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);
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);
int log2(int num);
public:
@ -94,7 +80,7 @@ public:
uint32 chkAlpha(uint32* src, int width, int height);
#endif
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 grAspectRatioLog2(int w, int h);
int getNumberofProcessors();
@ -112,7 +98,7 @@ public:
return &txMemBuf;
}
~TxMemBuf();
boolean init(int maxwidth, int maxheight);
bool init(int maxwidth, int maxheight);
void shutdown(void);
uint8 *get(unsigned int num);
uint32 size_of(unsigned int num);

View File

@ -1,29 +1,16 @@
/*
* DXTn codec
* Version: 1.1
*
* Copyright (C) 2004 Daniel Borca All Rights Reserved.
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/* Copyright (C) 2007 Hiroshi Morii <koolsmoky(at)users.sourceforge.net>
* Added support for ARGB inputs, DXT3,5 workaround for ATI Radeons, and
* YUV conversions to determine representative colors.
*/
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#include <stdlib.h>
#include <string.h>
@ -35,7 +22,6 @@
#include "internal.h"
#include "dxtn.h"
/***************************************************************************\
* DXTn encoder
*
@ -44,13 +30,11 @@
* is merely a proof of concept, since it is highly UNoptimized!
\***************************************************************************/
#define MAX_COMP 4 /* ever needed maximum number of components in texel */
#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */
#define N_TEXELS 16 /* number of texels in a block (always 16) */
#define COLOR565(v) (word)((((v)[RCOMP] & 0xf8) << 8) | (((v)[GCOMP] & 0xfc) << 3) | ((v)[BCOMP] >> 3))
static const int dxtn_color_tlat[2][4] = {
{ 0, 2, 3, 1 },
{ 0, 2, 1, 3 }
@ -61,9 +45,8 @@ static const int dxtn_alpha_tlat[2][8] = {
{ 0, 2, 3, 4, 5, 1, 6, 7 }
};
static void
dxt1_rgb_quantize (dword *cc, const byte *lines[], int comps)
dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps)
{
float b, iv[MAX_COMP]; /* interpolation vector */
@ -147,7 +130,8 @@ dxt1_rgb_quantize (dword *cc, const byte *lines[], int comps)
/* we'll use 3-vector */
cc[0] = color0 | (color1 << 16);
hi = black ? -1 : 0;
} else {
}
else {
if (black && ((color0 == 0) || (color1 == 0))) {
/* we still can use 4-vector */
black = 0;
@ -190,9 +174,8 @@ dxt1_rgb_quantize (dword *cc, const byte *lines[], int comps)
cc[1] = hi;
}
static void
dxt1_rgba_quantize (dword *cc, const byte *lines[], int comps)
dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps)
{
float b, iv[MAX_COMP]; /* interpolation vector */
@ -273,7 +256,8 @@ dxt1_rgba_quantize (dword *cc, const byte *lines[], int comps)
/* we'll use 3-vector */
cc[0] = color0 | (color1 << 16);
hi = transparent ? -1 : 0;
} else {
}
else {
if (transparent ^ (color0 <= color1)) {
int aux;
aux = color0;
@ -305,9 +289,8 @@ dxt1_rgba_quantize (dword *cc, const byte *lines[], int comps)
cc[1] = hi;
}
static void
dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps)
dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps)
{
float b, iv[MAX_COMP]; /* interpolation vector */
@ -436,9 +419,8 @@ dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps)
cc[3] = hihi;
}
static void
dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps)
dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps)
{
float b, iv[MAX_COMP]; /* interpolation vector */
@ -530,7 +512,8 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps)
/* we'll use 6-vector */
cc[0] = alpha0 | (alpha1 << 8);
cc[1] = 0;
} else {
}
else {
if (anyZero && ((alpha0 == 0) || (alpha1 == 0))) {
/* we still might use 8-vector */
anyZero = 0;
@ -558,7 +541,8 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps)
if (anyZero | anyOne) {
if (input[k][ACOMP] == 0) {
texel = 6;
} else if (input[k][ACOMP] == 255) {
}
else if (input[k][ACOMP] == 255) {
texel = 7;
}
}
@ -569,7 +553,8 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps)
#if SAFECDOT
if (texel < 0) {
texel = 0;
} else if (texel > a_vect) {
}
else if (texel > a_vect) {
texel = a_vect;
}
#endif
@ -619,7 +604,6 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps)
cc[3] = hihi;
}
#define ENCODER(dxtn, n) \
int TAPIENTRY \
dxtn##_encode (int width, int height, int comps, \
@ -675,7 +659,6 @@ ENCODER(dxt1_rgba, 2)
ENCODER(dxt3_rgba, 4)
ENCODER(dxt5_rgba, 4)
/***************************************************************************\
* DXTn decoder
*
@ -683,7 +666,6 @@ ENCODER(dxt5_rgba, 4)
* specification and serves as a concept for the encoder.
\***************************************************************************/
/* lookup table for scaling 4 bit colors up to 8 bits */
static const byte _rgb_scale_4[] = {
0, 17, 34, 51, 68, 85, 102, 119,
@ -710,16 +692,14 @@ static const byte _rgb_scale_6[] = {
227, 231, 235, 239, 243, 247, 251, 255
};
#define CC_SEL(cc, which) (((dword *)(cc))[(which) / 32] >> ((which) & 31))
#define UP4(c) _rgb_scale_4[(c) & 15]
#define UP5(c) _rgb_scale_5[(c) & 31]
#define UP6(c) _rgb_scale_6[(c) & 63]
#define ZERO_4UBV(v) *((dword *)(v)) = 0
void TAPIENTRY
dxt1_rgb_decode_1 (const void *texture, int stride,
dxt1_rgb_decode_1(const void *texture, int stride,
int i, int j, byte *rgba)
{
const byte *src = (const byte *)texture
@ -729,29 +709,34 @@ dxt1_rgb_decode_1 (const void *texture, int stride,
rgba[RCOMP] = UP5(CC_SEL(src, 11));
rgba[GCOMP] = UP6(CC_SEL(src, 5));
rgba[BCOMP] = UP5(CC_SEL(src, 0));
} else if (code == 1) {
}
else if (code == 1) {
rgba[RCOMP] = UP5(CC_SEL(src, 27));
rgba[GCOMP] = UP6(CC_SEL(src, 21));
rgba[BCOMP] = UP5(CC_SEL(src, 16));
} else {
}
else {
const word col0 = src[0] | (src[1] << 8);
const word col1 = src[2] | (src[3] << 8);
if (col0 > col1) {
if (code == 2) {
rgba[RCOMP] = (UP5(col0 >> 11) * 2 + UP5(col1 >> 11)) / 3;
rgba[GCOMP] = (UP6(col0 >> 5) * 2 + UP6(col1 >> 5)) / 3;
rgba[BCOMP] = (UP5(col0 ) * 2 + UP5(col1 )) / 3;
} else {
rgba[BCOMP] = (UP5(col0) * 2 + UP5(col1)) / 3;
}
else {
rgba[RCOMP] = (UP5(col0 >> 11) + 2 * UP5(col1 >> 11)) / 3;
rgba[GCOMP] = (UP6(col0 >> 5) + 2 * UP6(col1 >> 5)) / 3;
rgba[BCOMP] = (UP5(col0 ) + 2 * UP5(col1 )) / 3;
rgba[BCOMP] = (UP5(col0) + 2 * UP5(col1)) / 3;
}
} else {
}
else {
if (code == 2) {
rgba[RCOMP] = (UP5(col0 >> 11) + UP5(col1 >> 11)) / 2;
rgba[GCOMP] = (UP6(col0 >> 5) + UP6(col1 >> 5)) / 2;
rgba[BCOMP] = (UP5(col0 ) + UP5(col1 )) / 2;
} else {
rgba[BCOMP] = (UP5(col0) + UP5(col1)) / 2;
}
else {
ZERO_4UBV(rgba);
}
}
@ -759,9 +744,8 @@ dxt1_rgb_decode_1 (const void *texture, int stride,
rgba[ACOMP] = 255;
}
void TAPIENTRY
dxt1_rgba_decode_1 (const void *texture, int stride,
dxt1_rgba_decode_1(const void *texture, int stride,
int i, int j, byte *rgba)
{
/* Same as rgb_dxt1 above, except alpha=0 if col0<=col1 and code=3. */
@ -773,41 +757,45 @@ dxt1_rgba_decode_1 (const void *texture, int stride,
rgba[GCOMP] = UP6(CC_SEL(src, 5));
rgba[BCOMP] = UP5(CC_SEL(src, 0));
rgba[ACOMP] = 255;
} else if (code == 1) {
}
else if (code == 1) {
rgba[RCOMP] = UP5(CC_SEL(src, 27));
rgba[GCOMP] = UP6(CC_SEL(src, 21));
rgba[BCOMP] = UP5(CC_SEL(src, 16));
rgba[ACOMP] = 255;
} else {
}
else {
const word col0 = src[0] | (src[1] << 8);
const word col1 = src[2] | (src[3] << 8);
if (col0 > col1) {
if (code == 2) {
rgba[RCOMP] = (UP5(col0 >> 11) * 2 + UP5(col1 >> 11)) / 3;
rgba[GCOMP] = (UP6(col0 >> 5) * 2 + UP6(col1 >> 5)) / 3;
rgba[BCOMP] = (UP5(col0 ) * 2 + UP5(col1 )) / 3;
} else {
rgba[BCOMP] = (UP5(col0) * 2 + UP5(col1)) / 3;
}
else {
rgba[RCOMP] = (UP5(col0 >> 11) + 2 * UP5(col1 >> 11)) / 3;
rgba[GCOMP] = (UP6(col0 >> 5) + 2 * UP6(col1 >> 5)) / 3;
rgba[BCOMP] = (UP5(col0 ) + 2 * UP5(col1 )) / 3;
rgba[BCOMP] = (UP5(col0) + 2 * UP5(col1)) / 3;
}
rgba[ACOMP] = 255;
} else {
}
else {
if (code == 2) {
rgba[RCOMP] = (UP5(col0 >> 11) + UP5(col1 >> 11)) / 2;
rgba[GCOMP] = (UP6(col0 >> 5) + UP6(col1 >> 5)) / 2;
rgba[BCOMP] = (UP5(col0 ) + UP5(col1 )) / 2;
rgba[BCOMP] = (UP5(col0) + UP5(col1)) / 2;
rgba[ACOMP] = 255;
} else {
}
else {
ZERO_4UBV(rgba);
}
}
}
}
void TAPIENTRY
dxt3_rgba_decode_1 (const void *texture, int stride,
dxt3_rgba_decode_1(const void *texture, int stride,
int i, int j, byte *rgba)
{
const byte *src = (const byte *)texture
@ -818,16 +806,19 @@ dxt3_rgba_decode_1 (const void *texture, int stride,
rgba[RCOMP] = UP5(CC_SEL(cc, 11));
rgba[GCOMP] = UP6(CC_SEL(cc, 5));
rgba[BCOMP] = UP5(CC_SEL(cc, 0));
} else if (code == 1) {
}
else if (code == 1) {
rgba[RCOMP] = UP5(CC_SEL(cc, 27));
rgba[GCOMP] = UP6(CC_SEL(cc, 21));
rgba[BCOMP] = UP5(CC_SEL(cc, 16));
} else if (code == 2) {
}
else if (code == 2) {
/* (col0 * (4 - code) + col1 * (code - 1)) / 3 */
rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3;
rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3;
rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3;
} else {
}
else {
rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) + 2 * UP5(CC_SEL(cc, 27))) / 3;
rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) + 2 * UP6(CC_SEL(cc, 21))) / 3;
rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) + 2 * UP5(CC_SEL(cc, 16))) / 3;
@ -835,9 +826,8 @@ dxt3_rgba_decode_1 (const void *texture, int stride,
rgba[ACOMP] = UP4(src[((j & 3) * 4 + (i & 3)) / 2] >> ((i & 1) * 4));
}
void TAPIENTRY
dxt5_rgba_decode_1 (const void *texture, int stride,
dxt5_rgba_decode_1(const void *texture, int stride,
int i, int j, byte *rgba)
{
const byte *src = (const byte *)texture
@ -854,31 +844,39 @@ dxt5_rgba_decode_1 (const void *texture, int stride,
rgba[RCOMP] = UP5(CC_SEL(cc, 11));
rgba[GCOMP] = UP6(CC_SEL(cc, 5));
rgba[BCOMP] = UP5(CC_SEL(cc, 0));
} else if (code == 1) {
}
else if (code == 1) {
rgba[RCOMP] = UP5(CC_SEL(cc, 27));
rgba[GCOMP] = UP6(CC_SEL(cc, 21));
rgba[BCOMP] = UP5(CC_SEL(cc, 16));
} else if (code == 2) {
}
else if (code == 2) {
/* (col0 * (4 - code) + col1 * (code - 1)) / 3 */
rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3;
rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3;
rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3;
} else {
}
else {
rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) + 2 * UP5(CC_SEL(cc, 27))) / 3;
rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) + 2 * UP6(CC_SEL(cc, 21))) / 3;
rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) + 2 * UP5(CC_SEL(cc, 16))) / 3;
}
if (acode == 0) {
rgba[ACOMP] = alpha0;
} else if (acode == 1) {
}
else if (acode == 1) {
rgba[ACOMP] = alpha1;
} else if (alpha0 > alpha1) {
}
else if (alpha0 > alpha1) {
rgba[ACOMP] = ((8 - acode) * alpha0 + (acode - 1) * alpha1) / 7;
} else if (acode == 6) {
}
else if (acode == 6) {
rgba[ACOMP] = 0;
} else if (acode == 7) {
}
else if (acode == 7) {
rgba[ACOMP] = 255;
} else {
}
else {
rgba[ACOMP] = ((6 - acode) * alpha0 + (acode - 1) * alpha1) / 5;
}
}

View File

@ -1,62 +1,54 @@
/*
* DXTn codec
* Version: 1.1
*
* Copyright (C) 2004 Daniel Borca All Rights Reserved.
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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 DXTN_H_included
#define DXTN_H_included
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,
void *dest, int destRowStride);
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,
void *dest, int destRowStride);
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,
void *dest, int destRowStride);
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,
void *dest, int destRowStride);
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);
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);
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);
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);
#endif

View File

@ -1,31 +1,16 @@
/*
* FXT1 codec
* Version: 1.1
*
* Copyright (C) 2004 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* 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.
*/
/* Copyright (C) 2007 Hiroshi Morii <koolsmoky(at)users.sourceforge.net>
* Added support for ARGB inputs.
*/
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#include <stdlib.h>
#include <string.h>
@ -34,7 +19,6 @@
#include "internal.h"
#include "fxt1.h"
/***************************************************************************\
* FXT1 encoder
*
@ -45,7 +29,6 @@
* to Lloyd's algorithm (the interpolation modes are even worse).
\***************************************************************************/
#define MAX_COMP 4 /* ever needed maximum number of components in texel */
#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */
#define N_TEXELS 32 /* number of texels in a block (always 32) */
@ -56,9 +39,8 @@
#define ISTBLACK(v) (*((dword *)(v)) == 0)
#define COPY_4UBV(DST, SRC) *((dword *)(DST)) = *((dword *)(SRC))
static int
fxt1_bestcol (float vec[][MAX_COMP], int nv,
fxt1_bestcol(float vec[][MAX_COMP], int nv,
byte input[MAX_COMP], int nc)
{
int i, j, best = -1;
@ -78,9 +60,8 @@ fxt1_bestcol (float vec[][MAX_COMP], int nv,
return best;
}
static int
fxt1_worst (float vec[MAX_COMP],
fxt1_worst(float vec[MAX_COMP],
byte input[N_TEXELS][MAX_COMP], int nc, int n)
{
int i, k, worst = -1;
@ -100,9 +81,8 @@ fxt1_worst (float vec[MAX_COMP],
return worst;
}
static int
fxt1_variance (double variance[MAX_COMP],
fxt1_variance(double variance[MAX_COMP],
byte input[N_TEXELS][MAX_COMP], int nc, int n)
{
int i, k, best = 0;
@ -130,9 +110,8 @@ fxt1_variance (double variance[MAX_COMP],
return best;
}
static int
fxt1_choose (float vec[][MAX_COMP], int nv,
fxt1_choose(float vec[][MAX_COMP], int nv,
byte input[N_TEXELS][MAX_COMP], int nc, int n)
{
#if 0
@ -198,7 +177,8 @@ fxt1_choose (float vec[][MAX_COMP], int nv,
hist[l].idx = k;
lenh = l + 1;
break;
} else if (hist[l].key == key) {
}
else if (hist[l].key == key) {
hist[l].freq++;
break;
}
@ -237,9 +217,8 @@ fxt1_choose (float vec[][MAX_COMP], int nv,
return !0;
}
static int
fxt1_lloyd (float vec[][MAX_COMP], int nv,
fxt1_lloyd(float vec[][MAX_COMP], int nv,
byte input[N_TEXELS][MAX_COMP], int nc, int n)
{
/* Use the generalized lloyd's algorithm for VQ:
@ -324,7 +303,8 @@ fxt1_lloyd (float vec[][MAX_COMP], int nv,
for (i = 0; i < nc; i++) {
vec[j][i] = div * sum[j][i];
}
} else {
}
else {
/* this vec has no samples or is identical with a previous vec */
int worst = fxt1_worst(vec[j], input, nc, n);
for (i = 0; i < nc; i++) {
@ -337,9 +317,8 @@ fxt1_lloyd (float vec[][MAX_COMP], int nv,
return 0; /* could not converge fast enough */
}
static void
fxt1_quantize_CHROMA (dword *cc,
fxt1_quantize_CHROMA(dword *cc,
byte input[N_TEXELS][MAX_COMP])
{
const int n_vect = 4; /* 4 base vectors to find */
@ -378,9 +357,8 @@ fxt1_quantize_CHROMA (dword *cc,
cc[0] = lolo;
}
static void
fxt1_quantize_ALPHA0 (dword *cc,
fxt1_quantize_ALPHA0(dword *cc,
byte input[N_TEXELS][MAX_COMP],
byte reord[N_TEXELS][MAX_COMP], int n)
{
@ -431,9 +409,8 @@ fxt1_quantize_ALPHA0 (dword *cc,
cc[0] = lolo;
}
static void
fxt1_quantize_ALPHA1 (dword *cc,
fxt1_quantize_ALPHA1(dword *cc,
byte input[N_TEXELS][MAX_COMP])
{
const int n_vect = 3; /* highest vector number in each microtile */
@ -593,9 +570,8 @@ fxt1_quantize_ALPHA1 (dword *cc,
((qword *)cc)[1] = hi;
}
static void
fxt1_quantize_HI (dword *cc,
fxt1_quantize_HI(dword *cc,
byte input[N_TEXELS][MAX_COMP],
byte reord[N_TEXELS][MAX_COMP], int n)
{
@ -670,16 +646,16 @@ fxt1_quantize_HI (dword *cc,
/* add in texel */
kk[0] |= texel << (t & 7);
}
} else {
}
else {
/* add in texel */
kk[0] |= texel << (t & 7);
}
}
}
static void
fxt1_quantize_MIXED1 (dword *cc,
fxt1_quantize_MIXED1(dword *cc,
byte input[N_TEXELS][MAX_COMP])
{
const int n_vect = 2; /* highest vector number in each microtile */
@ -760,7 +736,8 @@ fxt1_quantize_MIXED1 (dword *cc,
vec[0][i] = 0;
vec[1][i] = 0;
}
} else {
}
else {
cc[0] = 0;
for (i = 0; i < n_comp; i++) {
vec[0][i] = input[minColL][i];
@ -794,7 +771,8 @@ fxt1_quantize_MIXED1 (dword *cc,
vec[2][i] = 0;
vec[3][i] = 0;
}
} else {
}
else {
cc[1] = 0;
for (i = 0; i < n_comp; i++) {
vec[2][i] = input[minColR][i];
@ -831,9 +809,8 @@ fxt1_quantize_MIXED1 (dword *cc,
((qword *)cc)[1] = hi;
}
static void
fxt1_quantize_MIXED0 (dword *cc,
fxt1_quantize_MIXED0(dword *cc,
byte input[N_TEXELS][MAX_COMP])
{
const int n_vect = 3; /* highest vector number in each microtile */
@ -1012,9 +989,8 @@ fxt1_quantize_MIXED0 (dword *cc,
((qword *)cc)[1] = hi;
}
static void
fxt1_quantize (dword *cc, const byte *lines[], int comps)
fxt1_quantize(dword *cc, const byte *lines[], int comps)
{
int trualpha;
byte reord[N_TEXELS][MAX_COMP];
@ -1094,12 +1070,15 @@ fxt1_quantize (dword *cc, const byte *lines[], int comps)
#if 0
if (trualpha) {
fxt1_quantize_ALPHA0(cc, input, reord, l);
} else if (l == 0) {
}
else if (l == 0) {
cc[0] = cc[1] = cc[2] = -1;
cc[3] = 0;
} else if (l < N_TEXELS) {
}
else if (l < N_TEXELS) {
fxt1_quantize_HI(cc, input, reord, l);
} else {
}
else {
fxt1_quantize_CHROMA(cc, input);
}
(void)fxt1_quantize_ALPHA1;
@ -1108,12 +1087,15 @@ fxt1_quantize (dword *cc, const byte *lines[], int comps)
#else
if (trualpha) {
fxt1_quantize_ALPHA1(cc, input);
} else if (l == 0) {
}
else if (l == 0) {
cc[0] = cc[1] = cc[2] = 0xFFFFFFFFUL;
cc[3] = 0;
} else if (l < N_TEXELS) {
}
else if (l < N_TEXELS) {
fxt1_quantize_MIXED1(cc, input);
} else {
}
else {
fxt1_quantize_MIXED0(cc, input);
}
(void)fxt1_quantize_ALPHA0;
@ -1122,9 +1104,8 @@ fxt1_quantize (dword *cc, const byte *lines[], int comps)
#endif
}
TAPI int TAPIENTRY
fxt1_encode (int width, int height, int comps,
fxt1_encode(int width, int height, int comps,
const void *source, int srcRowStride,
void *dest, int destRowStride)
{
@ -1172,7 +1153,6 @@ fxt1_encode (int width, int height, int comps,
return 0;
}
/***************************************************************************\
* FXT1 decoder
*
@ -1180,7 +1160,6 @@ fxt1_encode (int width, int height, int comps,
* specification and serves as a concept for the encoder.
\***************************************************************************/
/* lookup table for scaling 5 bit colors up to 8 bits */
static const byte _rgb_scale_5[] = {
0, 8, 16, 25, 33, 41, 49, 58,
@ -1201,16 +1180,14 @@ static const byte _rgb_scale_6[] = {
227, 231, 235, 239, 243, 247, 251, 255
};
#define CC_SEL(cc, which) (((dword *)(cc))[(which) / 32] >> ((which) & 31))
#define UP5(c) _rgb_scale_5[(c) & 31]
#define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)]
#define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n)
#define ZERO_4UBV(v) *((dword *)(v)) = 0
static void
fxt1_decode_1HI (const byte *code, int t, byte *rgba)
fxt1_decode_1HI(const byte *code, int t, byte *rgba)
{
const dword *cc;
@ -1220,17 +1197,20 @@ fxt1_decode_1HI (const byte *code, int t, byte *rgba)
if (t == 7) {
ZERO_4UBV(rgba);
} else {
}
else {
cc = (const dword *)(code + 12);
if (t == 0) {
rgba[BCOMP] = UP5(CC_SEL(cc, 0));
rgba[GCOMP] = UP5(CC_SEL(cc, 5));
rgba[RCOMP] = UP5(CC_SEL(cc, 10));
} else if (t == 6) {
}
else if (t == 6) {
rgba[BCOMP] = UP5(CC_SEL(cc, 15));
rgba[GCOMP] = UP5(CC_SEL(cc, 20));
rgba[RCOMP] = UP5(CC_SEL(cc, 25));
} else {
}
else {
rgba[BCOMP] = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15)));
rgba[GCOMP] = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20)));
rgba[RCOMP] = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25)));
@ -1239,9 +1219,8 @@ fxt1_decode_1HI (const byte *code, int t, byte *rgba)
}
}
static void
fxt1_decode_1CHROMA (const byte *code, int t, byte *rgba)
fxt1_decode_1CHROMA(const byte *code, int t, byte *rgba)
{
const dword *cc;
dword kk;
@ -1262,9 +1241,8 @@ fxt1_decode_1CHROMA (const byte *code, int t, byte *rgba)
rgba[ACOMP] = 255;
}
static void
fxt1_decode_1MIXED (const byte *code, int t, byte *rgba)
fxt1_decode_1MIXED(const byte *code, int t, byte *rgba)
{
const dword *cc;
int col[2][3];
@ -1284,7 +1262,8 @@ fxt1_decode_1MIXED (const byte *code, int t, byte *rgba)
col[1][RCOMP] = CC_SEL(cc, 119);
glsb = CC_SEL(cc, 126);
selb = CC_SEL(cc, 33);
} else {
}
else {
t = (cc[0] >> (t * 2)) & 3;
/* col 0 */
col[0][BCOMP] = CC_SEL(cc, 64);
@ -1303,34 +1282,40 @@ fxt1_decode_1MIXED (const byte *code, int t, byte *rgba)
if (t == 3) {
ZERO_4UBV(rgba);
} else {
}
else {
if (t == 0) {
rgba[BCOMP] = UP5(col[0][BCOMP]);
rgba[GCOMP] = UP5(col[0][GCOMP]);
rgba[RCOMP] = UP5(col[0][RCOMP]);
} else if (t == 2) {
}
else if (t == 2) {
rgba[BCOMP] = UP5(col[1][BCOMP]);
rgba[GCOMP] = UP6(col[1][GCOMP], glsb);
rgba[RCOMP] = UP5(col[1][RCOMP]);
} else {
}
else {
rgba[BCOMP] = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2;
rgba[GCOMP] = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2;
rgba[RCOMP] = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2;
}
rgba[ACOMP] = 255;
}
} else {
}
else {
/* alpha[0] == 0 */
if (t == 0) {
rgba[BCOMP] = UP5(col[0][BCOMP]);
rgba[GCOMP] = UP6(col[0][GCOMP], glsb ^ selb);
rgba[RCOMP] = UP5(col[0][RCOMP]);
} else if (t == 3) {
}
else if (t == 3) {
rgba[BCOMP] = UP5(col[1][BCOMP]);
rgba[GCOMP] = UP6(col[1][GCOMP], glsb);
rgba[RCOMP] = UP5(col[1][RCOMP]);
} else {
}
else {
rgba[BCOMP] = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP]));
rgba[GCOMP] = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb),
UP6(col[1][GCOMP], glsb));
@ -1340,9 +1325,8 @@ fxt1_decode_1MIXED (const byte *code, int t, byte *rgba)
}
}
static void
fxt1_decode_1ALPHA (const byte *code, int t, byte *rgba)
fxt1_decode_1ALPHA(const byte *code, int t, byte *rgba)
{
const dword *cc;
@ -1359,7 +1343,8 @@ fxt1_decode_1ALPHA (const byte *code, int t, byte *rgba)
col0[GCOMP] = CC_SEL(cc, 99);
col0[RCOMP] = CC_SEL(cc, 104);
col0[ACOMP] = CC_SEL(cc, 119);
} else {
}
else {
t = (cc[0] >> (t * 2)) & 3;
/* col 0 */
col0[BCOMP] = CC_SEL(cc, 64);
@ -1373,18 +1358,21 @@ fxt1_decode_1ALPHA (const byte *code, int t, byte *rgba)
rgba[GCOMP] = UP5(col0[GCOMP]);
rgba[RCOMP] = UP5(col0[RCOMP]);
rgba[ACOMP] = UP5(col0[ACOMP]);
} else if (t == 3) {
}
else if (t == 3) {
rgba[BCOMP] = UP5(CC_SEL(cc, 79));
rgba[GCOMP] = UP5(CC_SEL(cc, 84));
rgba[RCOMP] = UP5(CC_SEL(cc, 89));
rgba[ACOMP] = UP5(CC_SEL(cc, 114));
} else {
}
else {
rgba[BCOMP] = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79)));
rgba[GCOMP] = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84)));
rgba[RCOMP] = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89)));
rgba[ACOMP] = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114)));
}
} else {
}
else {
/* lerp == 0 */
if (t & 16) {
@ -1395,7 +1383,8 @@ fxt1_decode_1ALPHA (const byte *code, int t, byte *rgba)
if (t == 3) {
ZERO_4UBV(rgba);
} else {
}
else {
dword kk;
cc = (const dword *)code;
rgba[ACOMP] = UP5(cc[3] >> (t * 5 + 13));
@ -1409,12 +1398,11 @@ fxt1_decode_1ALPHA (const byte *code, int t, byte *rgba)
}
}
TAPI void TAPIENTRY
fxt1_decode_1 (const void *texture, int stride,
fxt1_decode_1(const void *texture, int stride,
int i, int j, byte *rgba)
{
static void (*decode_1[]) (const byte *, int, byte *) = {
static void(*decode_1[]) (const byte *, int, byte *) = {
fxt1_decode_1HI, /* cc-high = "00?" */
fxt1_decode_1HI, /* cc-high = "00?" */
fxt1_decode_1CHROMA, /* cc-chroma = "010" */

View File

@ -1,38 +1,27 @@
/*
* FXT1 codec
* Version: 1.1
*
* Copyright (C) 2004 Daniel Borca All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* 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.
*/
/***************************************************************************
* *
* 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 FXT1_H_included
#define FXT1_H_included
TAPI int TAPIENTRY
fxt1_encode (int width, int height, int comps,
fxt1_encode(int width, int height, int comps,
const void *source, int srcRowStride,
void *dest, int destRowStride);
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);
#endif

View File

@ -1,29 +1,20 @@
/*
* Texture compression
* Version: 1.0
*
* Copyright (C) 2004 Daniel Borca All Rights Reserved.
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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 INTERNAL_H_included
#define INTERNAL_H_included
/*****************************************************************************\
* Texture compression stuff
\*****************************************************************************/
@ -31,19 +22,12 @@
#define YUV
#define ARGB
/*****************************************************************************\
* DLL stuff
\*****************************************************************************/
#ifdef __WIN32__
#define TAPI __declspec(dllexport)
#define TAPIENTRY /*__stdcall*/
#else
#define TAPI
#define TAPIENTRY
#endif
/*****************************************************************************\
* 64bit types on 32bit machine
@ -78,7 +62,6 @@ typedef struct {
#endif /* !__GNUC__ */
/*****************************************************************************\
* Config
\*****************************************************************************/
@ -131,13 +114,12 @@ typedef struct {
} \
} while (0)
/*****************************************************************************\
* Utility functions
\*****************************************************************************/
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 comps,
const byte *src, int srcRowStride,

View File

@ -1,39 +1,24 @@
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* 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
*/
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#include <assert.h>
#include "types.h"
#include "internal.h"
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 comps,
const byte *src, int srcRowStride,

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
#define TYPES_H_included

View File

@ -1,24 +1,16 @@
/*
* Texture compression
* Version: 1.0
*
* Copyright (C) 2004 Daniel Borca All Rights Reserved.
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
*/
/***************************************************************************
* *
* 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. *
* *
****************************************************************************/
#include <assert.h>
@ -26,15 +18,13 @@
#include "internal.h"
#include "dxtn.h"
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
TAPI void TAPIENTRY
fetch_2d_texel_rgb_dxt1 (int texImage_RowStride,
fetch_2d_texel_rgb_dxt1(int texImage_RowStride,
const byte *texImage_Data,
int i, int j,
byte *texel)
@ -42,9 +32,8 @@ fetch_2d_texel_rgb_dxt1 (int texImage_RowStride,
dxt1_rgb_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
}
TAPI void TAPIENTRY
fetch_2d_texel_rgba_dxt1 (int texImage_RowStride,
fetch_2d_texel_rgba_dxt1(int texImage_RowStride,
const byte *texImage_Data,
int i, int j,
byte *texel)
@ -52,9 +41,8 @@ fetch_2d_texel_rgba_dxt1 (int texImage_RowStride,
dxt1_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
}
TAPI void TAPIENTRY
fetch_2d_texel_rgba_dxt3 (int texImage_RowStride,
fetch_2d_texel_rgba_dxt3(int texImage_RowStride,
const byte *texImage_Data,
int i, int j,
byte *texel)
@ -62,9 +50,8 @@ fetch_2d_texel_rgba_dxt3 (int texImage_RowStride,
dxt3_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
}
TAPI void TAPIENTRY
fetch_2d_texel_rgba_dxt5 (int texImage_RowStride,
fetch_2d_texel_rgba_dxt5(int texImage_RowStride,
const byte *texImage_Data,
int i, int j,
byte *texel)
@ -72,9 +59,8 @@ fetch_2d_texel_rgba_dxt5 (int texImage_RowStride,
dxt5_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel);
}
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,
int destRowStride)
{

View File

@ -1,42 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 <math.h>
#include <string.h>

View File

@ -1,44 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
/***************************************************************************
* *
* 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
#define NOT_TMU0 0x00
#define NOT_TMU1 0x01
@ -55,7 +28,7 @@ void apply_shade_mods(VERTEX *v);
void update();
void update_scissor();
void set_message_combiner();
void set_message_combiner(void);
float ScaleZ(float z);
@ -136,5 +109,3 @@ template<class T> static T __ROL__(T value, unsigned int count)
value |= high;
return value;
}
#endif // ifndef Util_H

View File

@ -1,22 +1,16 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/***************************************************************************
* *
* 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 STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
@ -25,19 +19,19 @@
#define VERSION_REVISION 0
#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_STR STRINGIZE(VERSION_MAJOR) \
"." STRINGIZE(VERSION_MINOR) \
"." STRINGIZE(VERSION_REVISION) \
"." 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_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2013"
#define VER_COPYRIGHT_STR "Copyright (C) 2017"
#ifdef _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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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 <math.h>
#include <string.h>

View File

@ -1,44 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
/***************************************************************************
* *
* 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
#include <Common/stdtypes.h>
@ -728,4 +701,3 @@ extern int SwapOK;
void load_palette(uint32_t addr, uint16_t start, uint16_t count);
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 "Config.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
#include <Common/TraceModulesCommon.h>
#include <Common/Trace.h>

View File

@ -1,47 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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*************************/
/***************************************************************************
* *
* 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
struct t3dGlobState {
uint16_t pad0;

View File

@ -1,41 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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
typedef void(*rdp_instr)();

View File

@ -1,42 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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
static void rsp_vertex(int v0, int n)
{
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
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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
//
/***************************************************************************
* *
* 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
static void uc1_vertex()
{

View File

@ -1,42 +1,17 @@
/*
* Glide64 - Glide video plugin for Nintendo 64 emulators.
* Copyright (c) 2002 Dave2001
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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 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.
//
//****************************************************************
/***************************************************************************
* *
* 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
static void calc_point_light(VERTEX *v, float * vpos)
{
float light_intensity = 0.0f;

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