Original Supermodel code moved to tags/Original.

This commit is contained in:
Bart Trzynadlowski 2011-04-24 01:04:28 +00:00
parent 858aaa3f54
commit 7260a4d953
13 changed files with 0 additions and 3580 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,38 +0,0 @@
/*
* Sega Model 3 Emulator
* Copyright (C) 2003 Bart Trzynadlowski, Ville Linde, Stefano Teso
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as published
* by the Free Software Foundation.
*
* 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 (license.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* win32/dx_render.h
*
* DirectX9 Renderer interface
*/
#include "d3d9.h"
#include "d3dx9.h"
#define RGB_REG 0xFFFF0000
#define RGB_GREEN 0xFF00FF00
#define RGB_BLUE 0xFF0000FF
#define RGB_YELLOW 0xFFFFFF00
#define RGB_CYAN 0xFF00FFFF
BOOL d3d_init(HWND);
BOOL d3d_pre_init(void);
void d3d_shutdown(void);
D3DXMATRIX d3d_matrix_stack_get_top(void);
void d3d_matrix_stack_init(void);

View file

@ -1,84 +0,0 @@
/*
* Sega Model 3 Emulator
* Copyright (C) 2003 Bart Trzynadlowski, Ville Linde, Stefano Teso
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as published
* by the Free Software Foundation.
*
* 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 (license.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* win32/osd.h
*
* Win32 OSD header: Defines everything an OSD header needs to provide and
* includes some Win32-specific files.
*/
#ifndef INCLUDED_WIN32_OSD_H
#define INCLUDED_WIN32_OSD_H
/******************************************************************/
/* Win32-Specific Includes */
/******************************************************************/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/******************************************************************/
/* OSD Definitions */
/******************************************************************/
#ifdef _MSC_VER
#define INLINE static _inline
#endif
#ifdef __GCC__
#define INLINE static __inline__
#endif
/******************************************************************/
/* OSD Fundamental Data Types */
/******************************************************************/
typedef unsigned int FLAGS; // for storage of bit flags
#ifdef __GCC__
typedef int BOOL; // 0 (false) or non-zero (true)
typedef signed int INT; // optimal signed integer
typedef unsigned int UINT; // optimal unsigned integer
typedef signed char CHAR; // signed character (for text)
typedef unsigned char UCHAR; // unsigned character
typedef signed char INT8;
typedef unsigned char UINT8;
typedef signed short INT16;
typedef unsigned short UINT16;
typedef signed int INT32;
typedef unsigned int UINT32;
#ifdef _MSC_VER // Microsoft VisualC++ (for versions 6.0 or older, non-C99)
typedef signed __int64 INT64;
typedef unsigned __int64 UINT64;
#else // assume a C99-compliant compiler
typedef signed long long INT64;
typedef unsigned long long UINT64;
#endif
#endif
typedef float FLOAT32; // single precision (32-bit)
typedef double FLOAT64; // double precision (64-bit)
#endif // INCLUDED_WIN32_OSD_H

View file

@ -1,57 +0,0 @@
ps_3_0
; input declarations
dcl_color0 v0.xyzw
dcl_texcoord0 v1.xyzw
dcl_texcoord1 v2.xyzw
dcl_texcoord2 v3.xyzw
dcl_color1 v4.xyzw
dcl_2d s0
; constants
def c0, 1.0f, 0.0f, 0.0f, 0.5f
def c1, 0.00048828125f, 0.000244140625f, 0.0f, 0.0f
rcp r30, v2.z ; calculate 1/width
rcp r31, v2.w ; calculate 1/height
mov r31.xy, c0.yy ; r31.xy <- 0,0 \ hopefully co-issue...
mov r31.z, r30.z ; /
add r1.xyzw, v1.xyxy, r31.yyzy ; texel[0][0], texel[1][0]
add r2.xyzw, v1.xyxy, r31.ywzw ; texel[0][1], texel[1][1]
frc r1.xyzw, r1.xyzw
frc r2.xyzw, r2.xyzw
mul r3, r1, v2.zwzw ; mul by width, height
mul r4, r2, v2.zwzw ; mul by width, height
add r10, r3, v2.xyxy ; add tex base
add r11, r4, v2.xyxy ; add tex base
mul r10, r10, c1.xyxy ; div by 2048
mul r11, r11, c1.xyxy ; div by 2048
frc r18, r3
texld r5, r10.xy, s0
texld r6, r10.zw, s0
texld r7, r11.xy, s0
texld r8, r11.zw, s0
lrp r12, r18.xxxx, r6, r5
lrp r13, r18.xxxx, r8, r7
lrp r15, r18.yyyy, r13, r12
;if_lt v0.a, c0.x ; if polygon alpha is enabled use that instead of texture alpha
; mov r15.a, v0.a
;endif
if_ne v4.x, c0.y ; if v4.x == 0 -> color, if v4.x != -> texture
mul_sat r15, v0, r15 ; modulate with color
else
mov r15, v0
endif
;mov r15, v0
mov oC0, r15

View file

@ -1,38 +0,0 @@
ps_3_0
; parameters
; c8 = color offset
; c9 = (X,Y) scroll position, (Z) 0 = rendering background, 1 = rendering foreground
; input declarations
dcl_color v0.xyzw
dcl_texcoord0 v1.xy
dcl_2d s0
dcl_2d s1
dcl_2d s2
def c0, 1.0, 0.0, 1.0f, 1.0f
def c1, 0.5, 0.0, 0.0, 0.0
add r5, v1.xy, c9.xy ; add scroll position
frc r5, r5 ; wrap
texld r0, r5, s0
texld r10, v1, s2 ; load priority value
mov r11.r, c9.z
mov r1.xy, r0.ga
texld r2, r1, s1
add r2.rgb, r2.rgb, c8.yzw
min r2, r2, c0.xxxx ; clamp to 1.0
max r2, r2, c0.yyyy ; clamp to 0.0
if_eq r11.r, c0.y ; invert priority if rendering foreground
sub r10.r, c0.x, r10.r
endif
mul r2.a, r2.a, r10.r ; multiply alpha with priority
mov oC0, r2

View file

@ -1,106 +0,0 @@
unsigned char pixel_shader_source[524] =
{
0x00, 0x03, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0F, 0x90,
0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02,
0x05, 0x00, 0x01, 0x80, 0x02, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x02, 0x80,
0x03, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x01, 0x80, 0x04, 0x00, 0x0F, 0x90,
0x1F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0F, 0xA0, 0x51, 0x00, 0x00, 0x05,
0x00, 0x00, 0x0F, 0xA0, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3F, 0x51, 0x00, 0x00, 0x05, 0x01, 0x00, 0x0F, 0xA0, 0x00, 0x00, 0x00, 0x3A,
0x00, 0x00, 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x02,
0x1E, 0x00, 0x0F, 0x80, 0x02, 0x00, 0xAA, 0x90, 0x06, 0x00, 0x00, 0x02, 0x1F, 0x00, 0x0F, 0x80,
0x02, 0x00, 0xFF, 0x90, 0x01, 0x00, 0x00, 0x02, 0x1F, 0x00, 0x03, 0x80, 0x00, 0x00, 0x55, 0xA0,
0x01, 0x00, 0x00, 0x02, 0x1F, 0x00, 0x04, 0x80, 0x1E, 0x00, 0xAA, 0x80, 0x02, 0x00, 0x00, 0x03,
0x01, 0x00, 0x0F, 0x80, 0x01, 0x00, 0x44, 0x90, 0x1F, 0x00, 0x65, 0x80, 0x02, 0x00, 0x00, 0x03,
0x02, 0x00, 0x0F, 0x80, 0x01, 0x00, 0x44, 0x90, 0x1F, 0x00, 0xED, 0x80, 0x13, 0x00, 0x00, 0x02,
0x01, 0x00, 0x0F, 0x80, 0x01, 0x00, 0xE4, 0x80, 0x13, 0x00, 0x00, 0x02, 0x02, 0x00, 0x0F, 0x80,
0x02, 0x00, 0xE4, 0x80, 0x05, 0x00, 0x00, 0x03, 0x03, 0x00, 0x0F, 0x80, 0x01, 0x00, 0xE4, 0x80,
0x02, 0x00, 0xEE, 0x90, 0x05, 0x00, 0x00, 0x03, 0x04, 0x00, 0x0F, 0x80, 0x02, 0x00, 0xE4, 0x80,
0x02, 0x00, 0xEE, 0x90, 0x02, 0x00, 0x00, 0x03, 0x0A, 0x00, 0x0F, 0x80, 0x03, 0x00, 0xE4, 0x80,
0x02, 0x00, 0x44, 0x90, 0x02, 0x00, 0x00, 0x03, 0x0B, 0x00, 0x0F, 0x80, 0x04, 0x00, 0xE4, 0x80,
0x02, 0x00, 0x44, 0x90, 0x05, 0x00, 0x00, 0x03, 0x0A, 0x00, 0x0F, 0x80, 0x0A, 0x00, 0xE4, 0x80,
0x01, 0x00, 0x44, 0xA0, 0x05, 0x00, 0x00, 0x03, 0x0B, 0x00, 0x0F, 0x80, 0x0B, 0x00, 0xE4, 0x80,
0x01, 0x00, 0x44, 0xA0, 0x13, 0x00, 0x00, 0x02, 0x12, 0x00, 0x0F, 0x80, 0x03, 0x00, 0xE4, 0x80,
0x42, 0x00, 0x00, 0x03, 0x05, 0x00, 0x0F, 0x80, 0x0A, 0x00, 0x54, 0x80, 0x00, 0x08, 0xE4, 0xA0,
0x42, 0x00, 0x00, 0x03, 0x06, 0x00, 0x0F, 0x80, 0x0A, 0x00, 0xFE, 0x80, 0x00, 0x08, 0xE4, 0xA0,
0x42, 0x00, 0x00, 0x03, 0x07, 0x00, 0x0F, 0x80, 0x0B, 0x00, 0x54, 0x80, 0x00, 0x08, 0xE4, 0xA0,
0x42, 0x00, 0x00, 0x03, 0x08, 0x00, 0x0F, 0x80, 0x0B, 0x00, 0xFE, 0x80, 0x00, 0x08, 0xE4, 0xA0,
0x12, 0x00, 0x00, 0x04, 0x0C, 0x00, 0x0F, 0x80, 0x12, 0x00, 0x00, 0x80, 0x06, 0x00, 0xE4, 0x80,
0x05, 0x00, 0xE4, 0x80, 0x12, 0x00, 0x00, 0x04, 0x0D, 0x00, 0x0F, 0x80, 0x12, 0x00, 0x00, 0x80,
0x08, 0x00, 0xE4, 0x80, 0x07, 0x00, 0xE4, 0x80, 0x12, 0x00, 0x00, 0x04, 0x0F, 0x00, 0x0F, 0x80,
0x12, 0x00, 0x55, 0x80, 0x0D, 0x00, 0xE4, 0x80, 0x0C, 0x00, 0xE4, 0x80, 0x29, 0x00, 0x05, 0x02,
0x04, 0x00, 0x00, 0x90, 0x00, 0x00, 0x55, 0xA0, 0x05, 0x00, 0x00, 0x03, 0x0F, 0x00, 0x1F, 0x80,
0x00, 0x00, 0xE4, 0x90, 0x0F, 0x00, 0xE4, 0x80, 0x2A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02,
0x0F, 0x00, 0x0F, 0x80, 0x00, 0x00, 0xE4, 0x90, 0x2B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02,
0x00, 0x08, 0x0F, 0x80, 0x0F, 0x00, 0xE4, 0x80, 0xFF, 0xFF, 0x00, 0x00,
};
unsigned char pixel_shader_2d_source[324] =
{
0x00, 0x03, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0F, 0x90,
0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0x90, 0x1F, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0F, 0xA0, 0x1F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90,
0x01, 0x08, 0x0F, 0xA0, 0x1F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x02, 0x08, 0x0F, 0xA0,
0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0F, 0xA0, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x51, 0x00, 0x00, 0x05, 0x01, 0x00, 0x0F, 0xA0,
0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x03, 0x05, 0x00, 0x0F, 0x80, 0x01, 0x00, 0x54, 0x90, 0x09, 0x00, 0x54, 0xA0,
0x13, 0x00, 0x00, 0x02, 0x05, 0x00, 0x0F, 0x80, 0x05, 0x00, 0xE4, 0x80, 0x42, 0x00, 0x00, 0x03,
0x00, 0x00, 0x0F, 0x80, 0x05, 0x00, 0xE4, 0x80, 0x00, 0x08, 0xE4, 0xA0, 0x42, 0x00, 0x00, 0x03,
0x0A, 0x00, 0x0F, 0x80, 0x01, 0x00, 0xE4, 0x90, 0x02, 0x08, 0xE4, 0xA0, 0x01, 0x00, 0x00, 0x02,
0x0B, 0x00, 0x01, 0x80, 0x09, 0x00, 0xAA, 0xA0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x03, 0x80,
0x00, 0x00, 0xFD, 0x80, 0x42, 0x00, 0x00, 0x03, 0x02, 0x00, 0x0F, 0x80, 0x01, 0x00, 0xE4, 0x80,
0x01, 0x08, 0xE4, 0xA0, 0x02, 0x00, 0x00, 0x03, 0x02, 0x00, 0x07, 0x80, 0x02, 0x00, 0xA4, 0x80,
0x08, 0x00, 0xF9, 0xA0, 0x0A, 0x00, 0x00, 0x03, 0x02, 0x00, 0x0F, 0x80, 0x02, 0x00, 0xE4, 0x80,
0x00, 0x00, 0x00, 0xA0, 0x0B, 0x00, 0x00, 0x03, 0x02, 0x00, 0x0F, 0x80, 0x02, 0x00, 0xE4, 0x80,
0x00, 0x00, 0x55, 0xA0, 0x29, 0x00, 0x02, 0x02, 0x0B, 0x00, 0x00, 0x80, 0x00, 0x00, 0x55, 0xA0,
0x02, 0x00, 0x00, 0x03, 0x0A, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0xA0, 0x0A, 0x00, 0x00, 0x81,
0x2B, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x08, 0x80, 0x02, 0x00, 0xFF, 0x80,
0x0A, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0F, 0x80, 0x02, 0x00, 0xE4, 0x80,
0xFF, 0xFF, 0x00, 0x00,
};
unsigned char vertex_shader_source[500] =
{
0x00, 0x03, 0xFE, 0xFF, 0x1F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0F, 0x90,
0x1F, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02,
0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x01, 0x80,
0x03, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x02, 0x80, 0x04, 0x00, 0x0F, 0x90,
0x1F, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x80, 0x05, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02,
0x0A, 0x00, 0x01, 0x80, 0x06, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x0F, 0xE0, 0x1F, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0F, 0xE0,
0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0F, 0xE0, 0x1F, 0x00, 0x00, 0x02,
0x05, 0x00, 0x01, 0x80, 0x03, 0x00, 0x0F, 0xE0, 0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x02, 0x80,
0x04, 0x00, 0x0F, 0xE0, 0x1F, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x01, 0x80, 0x05, 0x00, 0x0F, 0xE0,
0x51, 0x00, 0x00, 0x05, 0x80, 0x00, 0x0F, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F,
0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x09, 0x00, 0x00, 0x03, 0x14, 0x00, 0x01, 0x80,
0x00, 0x00, 0xE4, 0x90, 0x00, 0x00, 0xE4, 0xA0, 0x09, 0x00, 0x00, 0x03, 0x14, 0x00, 0x02, 0x80,
0x00, 0x00, 0xE4, 0x90, 0x01, 0x00, 0xE4, 0xA0, 0x09, 0x00, 0x00, 0x03, 0x14, 0x00, 0x04, 0x80,
0x00, 0x00, 0xE4, 0x90, 0x02, 0x00, 0xE4, 0xA0, 0x09, 0x00, 0x00, 0x03, 0x14, 0x00, 0x08, 0x80,
0x00, 0x00, 0xE4, 0x90, 0x03, 0x00, 0xE4, 0xA0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0F, 0xE0,
0x14, 0x00, 0xE4, 0x80, 0x17, 0x00, 0x00, 0x03, 0x04, 0x00, 0x07, 0x80, 0x05, 0x00, 0xE4, 0x90,
0x04, 0x00, 0xE4, 0xA0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x0F, 0x80, 0x10, 0x00, 0xE4, 0xA1,
0x08, 0x00, 0x00, 0x03, 0x03, 0x00, 0x0F, 0x80, 0x04, 0x00, 0xE4, 0x80, 0x02, 0x00, 0xE4, 0x80,
0x0B, 0x00, 0x00, 0x03, 0x03, 0x00, 0x0F, 0x80, 0x03, 0x00, 0xE4, 0x80, 0x80, 0x00, 0x00, 0xA0,
0x05, 0x00, 0x00, 0x03, 0x03, 0x00, 0x0F, 0x80, 0x03, 0x00, 0xE4, 0x80, 0x11, 0x00, 0x00, 0xA0,
0x02, 0x00, 0x00, 0x03, 0x03, 0x00, 0x0F, 0x80, 0x03, 0x00, 0xE4, 0x80, 0x11, 0x00, 0x55, 0xA0,
0x0A, 0x00, 0x00, 0x03, 0x03, 0x00, 0x0F, 0x80, 0x03, 0x00, 0xE4, 0x80, 0x80, 0x00, 0x55, 0xA0,
0x29, 0x00, 0x05, 0x02, 0x06, 0x00, 0x00, 0x90, 0x80, 0x00, 0x00, 0xA0, 0x01, 0x00, 0x00, 0x02,
0x03, 0x00, 0x07, 0x80, 0x06, 0x00, 0x00, 0x90, 0x2B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02,
0x03, 0x00, 0x08, 0x80, 0x80, 0x00, 0xFF, 0xA0, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0F, 0xE0,
0x01, 0x00, 0xE4, 0x90, 0x03, 0x00, 0xE4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x0F, 0x80,
0x02, 0x00, 0xE4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x08, 0x80, 0x14, 0x00, 0xFF, 0x80,
0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x0F, 0xE0, 0x0A, 0x00, 0xE4, 0x80, 0x01, 0x00, 0x00, 0x02,
0x03, 0x00, 0x0F, 0xE0, 0x03, 0x00, 0xE4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x04, 0x00, 0x0F, 0xE0,
0x04, 0x00, 0xE4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x05, 0x00, 0x01, 0xE0, 0x06, 0x00, 0x55, 0x90,
0xFF, 0xFF, 0x00, 0x00,
};
unsigned char vertex_shader_2d_source[80] =
{
0x00, 0x03, 0xFE, 0xFF, 0x1F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0F, 0x90,
0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0F, 0x90, 0x1F, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0F, 0xE0, 0x1F, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80,
0x01, 0x00, 0x0F, 0xE0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0xE4, 0x90,
0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x0F, 0xE0, 0x01, 0x00, 0xE4, 0x90, 0xFF, 0xFF, 0x00, 0x00,
};

View file

@ -1,71 +0,0 @@
vs_3_0
; parameters
; c0...c3 world-view-projection matrix
; c4...c7 world-view matrix
; c16 sun light vector
; c17 sun ambient, diffuse intensity
; input declarations
dcl_position v0
dcl_color0 v1
dcl_texcoord0 v2
dcl_texcoord1 v3
dcl_texcoord2 v4
dcl_normal v5
dcl_color1 v6
; output declarations
dcl_position o0.xyzw
dcl_color0 o1.xyzw
dcl_texcoord0 o2.xyzw
dcl_texcoord1 o3.xyzw
dcl_texcoord2 o4.xyzw
dcl_color1 o5.xyzw
; constants
def c128, 0.0f, 1.0f, 0.5f, 1.0f
; transform position to projection space
;dp4 o0.x, v0, c0
;dp4 o0.y, v0, c1
;dp4 o0.z, v0, c2
;dp4 o0.w, v0, c3
dp4 r20.x, v0, c0
dp4 r20.y, v0, c1
dp4 r20.z, v0, c2
dp4 r20.w, v0, c3
mov o0, r20
; calculate parallel lighting
m3x3 r4.xyz, v5, c4 ; transform N
mov r2, -c16
dp3 r3, r4, r2 ; N dot L
max r3, r3, c128.xxxx ; clamp negative values to 0
mul r3, r3, c17.xxxx ; scale with diffuse intensity
add r3, r3, c17.yyyy ; add ambient intensity
min r3, r3, c128.yyyy
if_ne v6.xxxx, c128.xxxx ; if v6.x == 0 -> apply lighting, if v6.x != 0 -> self-luminance
mov r3.xyz, v6.xxx ; self-luminance
endif
mov r3.w, c128.w ; multiply alpha with 1
mul o1, v1, r3 ; modulate and write color
;mov o1, r3
; move texture parameters
mov r10,v2
mov r10.w, r20.w
mov o2, r10
;mov o2, v2
mov o3, v3
mov o4, v4
; parameters (X=texture enable)
mov o5.x, v6.g

View file

@ -1,14 +0,0 @@
vs_3_0
; input declarations
dcl_position v0
dcl_texcoord0 v1
; output declarations
dcl_position o0.xyzw
dcl_texcoord0 o1.xyzw
mov o0, v0
mov o1, v1

View file

@ -1,181 +0,0 @@
/*
* Sega Model 3 Emulator
* Copyright (C) 2003 Bart Trzynadlowski, Ville Linde, Stefano Teso
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as published
* by the Free Software Foundation.
*
* 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 (license.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* win32/win_gl.c
*
* Win32 OpenGL support. All of this will have to be rewritten to support
* run-time mode changes and fullscreen modes.
*
* The only osd_renderer function implemented here is osd_renderer_blit().
*/
#include "model3.h"
#include "osd_common/osd_gl.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glext.h>
/*
* Window Context
*/
static HGLRC hrc = 0; // OpenGL rendering context
static HDC hdc = 0; // GDI device context
static HINSTANCE hinstance; // application instance
extern HWND main_window; // window handle
/*
* void win_gl_init(UINT xres, UINT yres);
*
* Sets the rendering mode and initializes OpenGL.
*
* Parameters:
* xres = Horizontal resolution in pixels.
* yres = Vertical resolution.
*/
void win_gl_init(UINT xres, UINT yres)
{
GLuint pixel_format;
static PIXELFORMATDESCRIPTOR pfd = // must this be static?
{
sizeof(PIXELFORMATDESCRIPTOR), // size of structure
1, // version (must be 1)
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, // RGBA pixels
32, // color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // ignore shift bit
0, // no accumulation buffer
0, 0, 0, 0, // accumulation bits ignored
24, // 24-bit z-buffer
0, // no stencil buffer
0, // no auxilliary buffer
PFD_MAIN_PLANE, // main drawing layer
0, // reserved
0, 0, 0 // layer masks ignored
};
/*
* Get window instance
*/
hinstance = GetModuleHandle(NULL); // get window instance
/*
* Get device context and find a pixel format
*/
if (!(hdc = GetDC(main_window)))
osd_error("Unable to create an OpenGL device context.");
if (!(pixel_format = ChoosePixelFormat(hdc, &pfd))) // find matching pixel format
osd_error("Unable to find the required pixel format.");
if (!SetPixelFormat(hdc, pixel_format, &pfd))
osd_error("Unable to set the required pixel format.");
/*
* Get the rendering context and perform some GL initialization
*/
if (!(hrc = wglCreateContext(hdc)))
osd_error("Unable to create an OpenGL rendering context.");
if (!wglMakeCurrent(hdc, hrc))
osd_error("Unable to activate the OpenGL rendering context.");
/*
* Check for mirrored texture repeat extension
*/
if (osd_gl_check_extension("GL_ARB_texture_mirrored_repeat"))
osd_error("Your OpenGL implementation does not support mirrored texture repeating!");
if (osd_gl_check_extension("GL_ARB_texture_env_combine"))
osd_error("Your OpenGL implementation does not support texture combiner operations!");
if (osd_gl_check_extension("GL_EXT_texture_lod_bias"))
osd_error("Your OpenGL implementation does not support texture LOD bias selection!");
if (osd_gl_check_extension("GL_ARB_vertex_buffer_object"))
osd_error("Your OpenGL implementation does not support vertex buffer objects!");
/*
* Initialize GL engine
*/
osd_gl_set_mode(xres, yres);
}
/*
* void win_gl_shutdown(void);
*
* Shuts down the rendering mode mode meaning it releases the rendering and
* device contexts.
*/
void win_gl_shutdown(void)
{
osd_gl_unset_mode();
/*
* If there is a rendering context, release it
*/
if (hrc)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hrc);
}
/*
* If there is a device context, release it
*/
if (hdc)
ReleaseDC(main_window, hdc);
}
/*
* void osd_renderer_blit(void);
*
* Swaps the buffers to display what has been rendered in the last frame.
*/
void osd_renderer_blit(void)
{
SwapBuffers(hdc);
}
/*
* void * osd_gl_get_proc_address(const char *);
*
* Calls wglGetProcAddress.
*/
void * osd_gl_get_proc_address(const CHAR * id)
{
void * ptr = wglGetProcAddress(id);
if (ptr == NULL)
error("GL proc %s not found!\n", id);
else
message(0, "found GL proc %s!", id);
return ptr;
}

View file

@ -1,13 +0,0 @@
/*
* win32/win_gl.h
*
* Windows OpenGL header.
*/
#ifndef INCLUDED_WIN32_WIN_GL_H
#define INCLUDED_WIN32_WIN_GL_H
extern void win_gl_init(UINT, UINT);
extern void win_gl_shutdown(void);
#endif // INCLUDED_WIN32_WIN_GL_H

View file

@ -1,319 +0,0 @@
/*
* Sega Model 3 Emulator
* Copyright (C) 2003 Bart Trzynadlowski, Ville Linde, Stefano Teso
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as published
* by the Free Software Foundation.
*
* 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 (license.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/******************************************************************/
/* DirectX 9 Input */
/******************************************************************/
#include "MODEL3.H"
#include <dinput.h>
static LPDIRECTINPUT8 dinput;
static LPDIRECTINPUTDEVICE8 keyboard;
static LPDIRECTINPUTDEVICE8 mouse;
static CHAR keyboard_buffer[256];
static DIMOUSESTATE mouse_state;
extern HWND main_window;
static OSD_CONTROLS controls;
void osd_input_init(void)
{
HINSTANCE hinstance;
HRESULT hr;
atexit(osd_input_shutdown);
hinstance = GetModuleHandle(NULL);
hr = DirectInput8Create( hinstance, DIRECTINPUT_VERSION, &IID_IDirectInput8,
(void**)&dinput, NULL );
if(FAILED(hr))
error("DirectInput8Create failed.");
// Create keyboard device
hr = IDirectInput8_CreateDevice( dinput, &GUID_SysKeyboard, &keyboard, NULL );
if(FAILED(hr))
error("IDirectInput8_CreateDevice failed.");
hr = IDirectInputDevice8_SetDataFormat( keyboard, &c_dfDIKeyboard );
if(FAILED(hr))
error("IDirectInputDevice8_SetDataFormat failed.");
hr = IDirectInputDevice8_SetCooperativeLevel( keyboard, main_window, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE );
if(FAILED(hr))
error("IDirectInputDevice8_SetCooperativeLevel failed.");
if(keyboard)
IDirectInputDevice8_Acquire( keyboard );
// Create mouse device
hr = IDirectInput8_CreateDevice( dinput, &GUID_SysMouse, &mouse, NULL );
if(FAILED(hr))
error("IDirectInput8_CreateDevice failed.");
hr = IDirectInputDevice8_SetDataFormat( mouse, &c_dfDIMouse );
if(FAILED(hr))
error("IDirectInputDevice8_SetDataFormat failed.");
hr = IDirectInputDevice8_SetCooperativeLevel( mouse, main_window, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE );
if(FAILED(hr))
error("IDirectInputDevice8_SetCooperativeLevel failed.");
}
void osd_input_shutdown(void)
{
if(dinput) {
if(keyboard) {
IDirectInputDevice8_Unacquire( keyboard );
IDirectInputDevice8_Release( keyboard );
keyboard = NULL;
}
if(mouse) {
IDirectInputDevice8_Unacquire( mouse );
IDirectInputDevice8_Release( mouse );
mouse = NULL;
}
IDirectInput8_Release( dinput );
dinput = NULL;
}
}
static void input_update(void)
{
/* updates the input buffer */
if(dinput) {
// Get keyboard state
IDirectInputDevice8_GetDeviceState( keyboard, sizeof(keyboard_buffer), &keyboard_buffer );
// Get mouse state
IDirectInputDevice8_Acquire( mouse );
IDirectInputDevice8_GetDeviceState( mouse, sizeof(mouse_state), &mouse_state );
}
}
static BOOL keyboard_get_key(UINT8 key)
{
if(keyboard_buffer[key] & 0x80)
return TRUE;
else
return FALSE;
}
static BOOL mouse_get_button(UINT8 button)
{
if(mouse_state.rgbButtons[button] & 0x80)
return TRUE;
else
return FALSE;
}
static void mouse_get_position(INT32* xposition, INT32* yposition)
{
POINT mouse_pos;
GetCursorPos( &mouse_pos );
ScreenToClient( main_window, &mouse_pos );
*xposition = mouse_pos.x + (400 - (MODEL3_SCREEN_WIDTH / 2));
*yposition = mouse_pos.y + (272 - (MODEL3_SCREEN_HEIGHT / 2));
}
OSD_CONTROLS* osd_input_update_controls(void)
{
INT32 mouse_x, mouse_y;
input_update();
controls.game_controls[0] = 0xFF;
controls.game_controls[1] = 0xFF;
controls.system_controls[0] = 0xFF;
controls.system_controls[1] = 0xFF;
// Lightgun
if(mouse_get_button(0))
controls.game_controls[0] &= ~0x01;
if(mouse_get_button(1))
controls.gun_acquired[0] = TRUE;
else
controls.gun_acquired[0] = FALSE;
mouse_get_position(&mouse_x, &mouse_y);
controls.gun_x[0] = mouse_x;
controls.gun_y[0] = mouse_y;
// Game controls
if(keyboard_get_key(DIK_A))
controls.game_controls[0] &= ~0x01;
if(keyboard_get_key(DIK_S))
controls.game_controls[0] &= ~0x02;
if(keyboard_get_key(DIK_D))
controls.game_controls[0] &= ~0x04;
if(keyboard_get_key(DIK_F))
controls.game_controls[0] &= ~0x08;
if(keyboard_get_key(DIK_G))
controls.game_controls[0] &= ~0x80;
if(keyboard_get_key(DIK_H))
controls.game_controls[0] &= ~0x40;
if(keyboard_get_key(DIK_Q))
controls.game_controls[0] &= ~0x80;
if(keyboard_get_key(DIK_W))
controls.game_controls[0] &= ~0x40;
if(keyboard_get_key(DIK_E))
controls.game_controls[0] &= ~0x20;
if(keyboard_get_key(DIK_R))
controls.game_controls[0] &= ~0x10;
if(keyboard_get_key(DIK_T))
controls.game_controls[1] &= ~0x80;
if(keyboard_get_key(DIK_Y))
controls.game_controls[1] &= ~0x40;
if(keyboard_get_key(DIK_U))
controls.game_controls[1] &= ~0x20;
if(keyboard_get_key(DIK_I))
controls.game_controls[1] &= ~0x10;
if(keyboard_get_key(DIK_Z)) // VON2, shot trigger 1
controls.game_controls[0] &= ~0x01;
if(keyboard_get_key(DIK_X)) // VON2, shot trigger 2
controls.game_controls[1] &= ~0x01;
if(keyboard_get_key(DIK_C)) // VON2, turbo 1
controls.game_controls[0] &= ~0x02;
if(keyboard_get_key(DIK_V)) // VON2, turbo 2
controls.game_controls[1] &= ~0x02;
/*if(keyboard_get_key(DIK_UP) || keyboard_get_key(DIK_NUMPAD8)) {
controls.game_controls[0] &= ~0x20; // VON2, forward
controls.game_controls[1] &= ~0x20;
}
if(keyboard_get_key(DIK_DOWN) || keyboard_get_key(DIK_NUMPAD2)) {
controls.game_controls[0] &= ~0x10; // VON2, backward
controls.game_controls[1] &= ~0x10;
}
if(keyboard_get_key(DIK_LEFT) || keyboard_get_key(DIK_NUMPAD4)) {
controls.game_controls[0] &= ~0x10; // VON2, turn left
controls.game_controls[1] &= ~0x20;
}
if(keyboard_get_key(DIK_RIGHT) || keyboard_get_key(DIK_NUMPAD6)) {
controls.game_controls[0] &= ~0x20; // VON2, turn right
controls.game_controls[1] &= ~0x10;
}*/
if(keyboard_get_key(DIK_NUMPAD1)) {// VON2, strafe left
controls.game_controls[0] &= ~0x80;
controls.game_controls[1] &= ~0x80;
}
if(keyboard_get_key(DIK_NUMPAD3)) {// VON2, strafe right
controls.game_controls[0] &= ~0x40;
controls.game_controls[1] &= ~0x40;
}
if(keyboard_get_key(DIK_NUMPAD5)) {// VON2, jump
controls.game_controls[0] &= ~0x80;
controls.game_controls[1] &= ~0x40;
}
// System controls
if(keyboard_get_key(DIK_F1)) { // Test button
controls.system_controls[0] &= ~0x04;
controls.system_controls[1] &= ~0x04;
}
if(keyboard_get_key(DIK_F2)) { // Service button
controls.system_controls[0] &= ~0x08;
controls.system_controls[1] &= ~0x80;
}
if(keyboard_get_key(DIK_F3)) { // Start button
controls.system_controls[0] &= ~0x10;
}
if(keyboard_get_key(DIK_F4)) { // Coin #1
controls.system_controls[0] &= ~0x01;
}
// Steering Wheel
#if 0
if(keyboard_get_key(DIK_LEFT))
controls.steering -= 32;
if(keyboard_get_key(DIK_RIGHT))
controls.steering += 32;
if(controls.steering > 0) {
controls.steering -= 16;
if(controls.steering < 0)
controls.steering = 0;
} else {
controls.steering += 16;
if(controls.steering > 0)
controls.steering = 0;
}
if(controls.steering < -128)
controls.steering = -128;
if(controls.steering > 127)
controls.steering = 127;
if(keyboard_get_key(DIK_UP))
controls.acceleration += 32;
else
controls.acceleration -= 16;
if(controls.acceleration < 0)
controls.acceleration = 0;
if(controls.acceleration > 0xFF)
controls.acceleration = 0xFF;
if(keyboard_get_key(DIK_DOWN))
controls.brake += 32;
else
controls.brake -= 16;
if(controls.brake < 0)
controls.brake = 0;
if(controls.brake > 0xFF)
controls.brake = 0xFF;
#else
/* SWT Force Feedback joystick */
if(keyboard_get_key(DIK_UP))
controls.steering -= 16;
if(keyboard_get_key(DIK_DOWN))
controls.steering += 16;
if(controls.steering < -128)
controls.steering = -128;
if(controls.steering > 127)
controls.steering = 127;
if(keyboard_get_key(DIK_RIGHT)) {
controls.acceleration += 16;
controls.brake -= 16;
}
if(keyboard_get_key(DIK_LEFT)) {
controls.brake += 16;
controls.acceleration -= 16;
}
if(controls.acceleration < 0)
controls.acceleration = 0;
if(controls.acceleration > 0xFF)
controls.acceleration = 0xFF;
if(controls.brake < 0)
controls.brake = 0;
if(controls.brake > 0xFF)
controls.brake = 0xFF;
#endif
return &controls;
}

View file

@ -1,477 +0,0 @@
/*
* Sega Model 3 Emulator
* Copyright (C) 2003 Bart Trzynadlowski, Ville Linde, Stefano Teso
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as published
* by the Free Software Foundation.
*
* 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 (license.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/******************************************************************/
/* Windows Main */
/******************************************************************/
#include "model3.h"
#ifdef RENDERER_D3D
#include "dx_render.h"
#else // RENDERER_GL
#include "win_gl.h"
#endif
#define XRES (496)
#define YRES (384)
static CHAR app_title[] = "Supermodel";
static CHAR app_version[] = "1.0";
static CHAR class_name[] = "MODEL3";
static CHAR CONFIG_FILE[] = "config.xml";
HWND main_window;
// Window Procedure prototype
static LRESULT CALLBACK win_window_proc(HWND, UINT, WPARAM, LPARAM);
static BOOL win_register_class(void)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)win_window_proc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = GetModuleHandle(NULL);
wcex.hIcon = NULL;
wcex.hIconSm = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = class_name;
if (FAILED(RegisterClassEx(&wcex))) // MinGW: "comparison is always false due to limited range of data"
return FALSE;
return TRUE;
}
static BOOL win_create_window(UINT xres, UINT yres)
{
DWORD frame_width, frame_height, caption_height;
int width, height, window_width, window_height;
window_width = xres;
window_height = yres;
frame_width = GetSystemMetrics(SM_CXSIZEFRAME);
frame_height = GetSystemMetrics(SM_CYSIZEFRAME);
caption_height = GetSystemMetrics(SM_CYCAPTION);
width = (window_width - 1) + (frame_width * 2);
height = (window_height - 1) + (frame_height * 2) + caption_height;
main_window = CreateWindow(class_name,
app_title,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | // required for OpenGL
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, // Window X & Y coords
width - 1, height - 1, // Width & Height
NULL, NULL, // Parent Window & Menu
GetModuleHandle(NULL), NULL );
if (!main_window)
return FALSE;
return TRUE;
}
/*
* NOTE: This should actually return an error if something goes wrong, but
* it doesn't matter now. This stuff probably needs to be rewritten anyway ;)
*/
static void win_destroy(void)
{
#ifdef RENDERER_D3D
d3d_shutdown();
#else // RENDERER_GL
win_gl_shutdown();
#endif
DestroyWindow(main_window);
UnregisterClass(class_name, GetModuleHandle(NULL));
}
void *malloc_exec(int length)
{
void *ptr;
ptr = VirtualAlloc(NULL, length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (ptr == NULL)
{
error("malloc_exec %d failed\n", length);
}
return ptr;
}
void free_exec(void *ptr)
{
if (VirtualFree(ptr, 0, MEM_RELEASE) == FALSE)
{
error("free_exec failed\n");
}
}
BOOL check_cpu_features(void)
{
BOOL features_ok = TRUE;
char cpuname[256];
UINT32 cpu_version;
UINT32 cpu_features;
memset(cpuname, 0, sizeof(cpuname));
__asm
{
// get cpu name string
mov eax, 0x80000002
cpuid
mov dword ptr [cpuname+0 ], eax
mov dword ptr [cpuname+4 ], ebx
mov dword ptr [cpuname+8 ], ecx
mov dword ptr [cpuname+12 ], edx
mov eax, 0x80000003
cpuid
mov dword ptr [cpuname+16 ], eax
mov dword ptr [cpuname+20 ], ebx
mov dword ptr [cpuname+24 ], ecx
mov dword ptr [cpuname+28 ], edx
mov eax, 0x80000004
cpuid
mov dword ptr [cpuname+32 ], eax
mov dword ptr [cpuname+36 ], ebx
mov dword ptr [cpuname+40 ], ecx
mov dword ptr [cpuname+44 ], edx
// get cpu version and features
mov eax, 1
cpuid
mov [cpu_version], eax
mov [cpu_features], edx
}
message(0, "CPU: %s", cpuname);
if ((cpu_features & (1 << 15)) == 0)
{
message(0, "CPU doesn't support Conditional Move/Compare instructions");
features_ok = FALSE;
}
if ((cpu_features & (1 << 23)) == 0)
{
message(0, "CPU doesn't support MMX instructions");
features_ok = FALSE;
}
if ((cpu_features & (1 << 25)) == 0)
{
message(0, "CPU doesn't support SSE instructions");
features_ok = FALSE;
}
if ((cpu_features & (1 << 26)) == 0)
{
message(0, "CPU doesn't support SSE2 instructions");
features_ok = FALSE;
}
if (features_ok == FALSE)
{
message(0, "The CPU doesn't meet the requirements, the program will not run further.");
}
return features_ok;
}
int main(int argc, char *argv[])
{
MSG msg;
BOOL quit = FALSE, do_fps;
INT64 freq, time_start, time_end;
char title[256];
double fps = 0.0;
int frame = 0;
if(argc < 2) {
// Show usage
printf("ERROR: not enough arguments.\n\n");
printf("Usage: m3.exe [romset]\n");
return 0;
}
message(0, "%s v%s\n", app_title, app_version);
if (check_cpu_features() == FALSE)
{
exit(1);
}
#ifdef RENDERER_D3D
if (d3d_pre_init() == FALSE)
{
message(0, "The video card doesn't meet the requirements, the program will not run further.");
exit(1);
}
#endif
message(0, "");
// Load config
if (parse_config(CONFIG_FILE) == FALSE)
{
exit(1);
}
m3_config.layer_enable = 0xF;
// Parse command-line
strncpy(m3_config.game_id, argv[1], 8);
m3_config.game_id[8] = '\0'; // in case game name was 8 or more chars
if (stricmp(m3_config.game_id, "lostwsga") == 0)
{
m3_config.has_lightgun = TRUE;
}
// Some initialization
if (!win_register_class())
{
message(0, "win_register_class failed.");
exit(1);
}
if (!win_create_window(XRES, YRES))
{
message(0, "win_create_window failed.");
exit(1);
}
if (model3_load() == FALSE)
{
message(0, "ROM loading failed");
exit(1);
}
model3_init();
model3_reset();
#ifdef RENDERER_D3D
if (!d3d_init(main_window))
{
message(0, "d3d_init failed.");
exit(1);
}
#else
win_gl_init(XRES, YRES);
#endif
if (osd_input_init() == FALSE)
{
exit(1);
}
// Set window title to show the game name
sprintf(title, "%s: %s", app_title, m3_config.game_name);
SetWindowText(main_window, title);
// Now that everything works, we can show the window
ShowWindow(main_window, SW_SHOWNORMAL);
SetForegroundWindow(main_window);
SetFocus(main_window);
UpdateWindow(main_window);
if (m3_config.fullscreen && !m3_config.has_lightgun)
{
ShowCursor(FALSE);
}
if(QueryPerformanceFrequency((LARGE_INTEGER *)&freq))
do_fps = TRUE;
else
do_fps = FALSE;
QueryPerformanceCounter((LARGE_INTEGER *)&time_start);
QueryPerformanceCounter((LARGE_INTEGER *)&time_end);
memset(&msg, 0, sizeof(MSG));
while (quit == FALSE)
{
//QueryPerformanceCounter((LARGE_INTEGER *)&time_start);
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
quit = TRUE;
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
model3_run_frame();
frame++;
// gather profiler stats
//QueryPerformanceCounter((LARGE_INTEGER *)&time_end);
if (frame >= 5)
{
frame = 0;
QueryPerformanceCounter((LARGE_INTEGER *)&time_end);
fps = 5.0 / ((double)(time_end - time_start) / freq);
time_start = time_end;
}
#ifdef RENDERER_D3D
if (m3_config.show_fps)
{
//fps = 1.0 / ((double)(time_end - time_start) / freq);
sprintf(title, "FPS: %.3f", fps);
osd_renderer_draw_text(2, 2, title, 0xffff0000, TRUE);
}
#else
sprintf(title, "%s: %s, FPS: %.3f", app_title, m3_config.game_name, fps);
SetWindowText(main_window, title);
#endif
//osd_renderer_draw_text(2, 2, title, 0x00ff0000, TRUE);
osd_renderer_blit();
#ifdef _PROFILE_
profile_print(prof);
printf(prof);
#endif
}
//for (i = 0; i < 32; i += 4)
// printf("R%d=%08X\tR%d=%08X\tR%d=%08X\tR%d=%08X\n",
// i + 0, ppc_get_reg(PPC_REG_R0 + i + 0),
// i + 1, ppc_get_reg(PPC_REG_R0 + i + 1),
// i + 2, ppc_get_reg(PPC_REG_R0 + i + 2),
// i + 3, ppc_get_reg(PPC_REG_R0 + i + 3));
exit(0);
}
void osd_warning()
{
}
void osd_error(CHAR * string)
{
printf("ERROR: %s\n",string);
exit(0);
}
static LRESULT CALLBACK win_window_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
CHAR fname[13];
static UINT xres = 496, yres = 384;
switch(message)
{
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
case WM_KEYDOWN:
{
switch (wParam)
{
default:
break;
case '7':
m3_config.layer_enable ^= 1;
break;
case '8':
m3_config.layer_enable ^= 2;
break;
case '9':
m3_config.layer_enable ^= 4;
break;
case '0':
m3_config.layer_enable ^= 8;
break;
case 0x36:
m3_config.layer_enable = 0xF;
break;
case VK_ESCAPE:
DestroyWindow(hWnd);
break;
/*case VK_F7:
strncpy(fname, m3_config.game_id, 8);
fname[8] = '\0';
strcat(fname, ".sta");
model3_save_state(fname);
break;
case VK_F8:
strncpy(fname, m3_config.game_id, 8);
fname[8] = '\0';
strcat(fname, ".sta");
model3_load_state(fname);
break;*/
}
break;
}
case WM_KEYUP:
{
switch (wParam)
{
default:
break;
case VK_F11:
{
if (m3_config.fps_limit)
{
m3_config.fps_limit = FALSE;
}
else
{
m3_config.fps_limit = TRUE;
}
break;
}
case VK_F12:
{
if (m3_config.show_fps)
{
m3_config.show_fps = FALSE;
}
else
{
m3_config.show_fps = TRUE;
}
break;
}
break;
}
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

View file

@ -1,463 +0,0 @@
/*
* Sega Model 3 Emulator
* Copyright (C) 2003 Bart Trzynadlowski, Ville Linde, Stefano Teso
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as published
* by the Free Software Foundation.
*
* 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 (license.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/******************************************************************/
/* XInput for Xbox360 controller */
/******************************************************************/
#include "model3.h"
#include <dinput.h>
#include <xinput.h>
static LPDIRECTINPUT8 dinput;
static LPDIRECTINPUTDEVICE8 keyboard;
static LPDIRECTINPUTDEVICE8 mouse;
static CHAR keyboard_buffer[256];
static DIMOUSESTATE mouse_state;
extern HWND main_window;
static OSD_CONTROLS controls;
static int xbox_controllers[4];
static int analog_axis[8];
static BOOL button_state[16];
static struct
{
BOOL up, down, left, right;
} joystick[4];
BOOL osd_input_init(void)
{
HINSTANCE hinstance;
HRESULT hr;
DWORD result;
XINPUT_STATE state;
atexit(osd_input_shutdown);
hinstance = GetModuleHandle(NULL);
hr = DirectInput8Create( hinstance, DIRECTINPUT_VERSION, &IID_IDirectInput8,
(void**)&dinput, NULL );
if (FAILED(hr))
{
message(0, "DirectInput8Create failed.");
return FALSE;
}
// Create keyboard device
hr = IDirectInput8_CreateDevice( dinput, &GUID_SysKeyboard, &keyboard, NULL );
if (FAILED(hr))
{
message(0, "IDirectInput8_CreateDevice failed.");
return FALSE;
}
hr = IDirectInputDevice8_SetDataFormat( keyboard, &c_dfDIKeyboard );
if (FAILED(hr))
{
message(0, "IDirectInputDevice8_SetDataFormat failed.");
return FALSE;
}
hr = IDirectInputDevice8_SetCooperativeLevel( keyboard, main_window, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE );
if (FAILED(hr))
{
message(0, "IDirectInputDevice8_SetCooperativeLevel failed.");
return FALSE;
}
if (keyboard)
{
IDirectInputDevice8_Acquire( keyboard );
}
// Create mouse device
hr = IDirectInput8_CreateDevice( dinput, &GUID_SysMouse, &mouse, NULL );
if (FAILED(hr))
{
message(0, "IDirectInput8_CreateDevice failed.");
return FALSE;
}
hr = IDirectInputDevice8_SetDataFormat( mouse, &c_dfDIMouse );
if (FAILED(hr))
{
message(0, "IDirectInputDevice8_SetDataFormat failed.");
return FALSE;
}
hr = IDirectInputDevice8_SetCooperativeLevel( mouse, main_window, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE );
if (FAILED(hr))
{
message(0, "IDirectInputDevice8_SetCooperativeLevel failed.");
return FALSE;
}
// Init Xbox360 controllers
ZeroMemory(&state, sizeof(XINPUT_STATE));
// Simply get the state of the controller from XInput.
result = XInputGetState(0, &state);
if (result == ERROR_SUCCESS)
{
// Controller is connected
xbox_controllers[0] = 1;
message(0, "Xbox360 controller found!");
}
else
{
// Controller is not connected
xbox_controllers[0] = 0;
}
return TRUE;
}
void osd_input_shutdown(void)
{
if(dinput)
{
if(keyboard)
{
IDirectInputDevice8_Unacquire( keyboard );
IDirectInputDevice8_Release( keyboard );
keyboard = NULL;
}
if(mouse)
{
IDirectInputDevice8_Unacquire( mouse );
IDirectInputDevice8_Release( mouse );
mouse = NULL;
}
IDirectInput8_Release( dinput );
dinput = NULL;
}
}
static void input_update(void)
{
/* updates the input buffer */
if(dinput)
{
// Get keyboard state
IDirectInputDevice8_GetDeviceState( keyboard, sizeof(keyboard_buffer), &keyboard_buffer );
// Get mouse state
IDirectInputDevice8_Acquire( mouse );
IDirectInputDevice8_GetDeviceState( mouse, sizeof(mouse_state), &mouse_state );
}
}
static BOOL keyboard_get_key(UINT8 key)
{
if (keyboard_buffer[key] & 0x80)
{
return TRUE;
}
else
{
return FALSE;
}
}
static BOOL mouse_get_button(UINT8 button)
{
if (mouse_state.rgbButtons[button] & 0x80)
{
return TRUE;
}
else
{
return FALSE;
}
}
static void mouse_get_position(INT32* xposition, INT32* yposition)
{
POINT mouse_pos;
GetCursorPos( &mouse_pos );
ScreenToClient( main_window, &mouse_pos );
*xposition = mouse_pos.x;
*yposition = mouse_pos.y;
}
static void update_controls_keyboard(void)
{
memset(button_state, 0, sizeof(button_state));
memset(joystick, 0, sizeof(joystick));
if (keyboard_get_key(DIK_A)) button_state[0] = 1;
if (keyboard_get_key(DIK_S)) button_state[1] = 1;
if (keyboard_get_key(DIK_D)) button_state[2] = 1;
if (keyboard_get_key(DIK_F)) button_state[3] = 1;
if (keyboard_get_key(DIK_Z)) button_state[4] = 1;
if (keyboard_get_key(DIK_X)) button_state[5] = 1;
if (keyboard_get_key(DIK_C)) button_state[6] = 1;
if (keyboard_get_key(DIK_V)) button_state[7] = 1;
if (keyboard_get_key(DIK_LEFT)) joystick[0].left = TRUE;
if (keyboard_get_key(DIK_RIGHT)) joystick[0].right = TRUE;
if (keyboard_get_key(DIK_UP)) joystick[0].up = TRUE;
if (keyboard_get_key(DIK_DOWN)) joystick[0].down = TRUE;
if (keyboard_get_key(DIK_LEFT)) analog_axis[0] -= 16;
if (keyboard_get_key(DIK_RIGHT)) analog_axis[0] += 16;
if (keyboard_get_key(DIK_UP)) analog_axis[1] -= 16;
if (keyboard_get_key(DIK_DOWN)) analog_axis[1] += 16;
if (analog_axis[0] < -128) analog_axis[0] = -128;
if (analog_axis[0] > 127) analog_axis[0] = 127;
if (analog_axis[1] < -128) analog_axis[1] = -128;
if (analog_axis[1] > 127) analog_axis[1] = 127;
}
static void update_controls_xbox(void)
{
XINPUT_STATE state;
DWORD res;
memset(button_state, 0, sizeof(button_state));
memset(analog_axis, 0, sizeof(analog_axis));
memset(joystick, 0, sizeof(joystick));
res = XInputGetState(0, &state);
if (res == ERROR_SUCCESS)
{
// Zero value if thumbsticks are within the dead zone
if ((state.Gamepad.sThumbLX < XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE &&
state.Gamepad.sThumbLX > -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE))
{
state.Gamepad.sThumbLX = 0;
}
if ((state.Gamepad.sThumbLY < XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE &&
state.Gamepad.sThumbLY > -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE))
{
state.Gamepad.sThumbLY = 0;
}
if ((state.Gamepad.sThumbRX < XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE &&
state.Gamepad.sThumbRX > -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE))
{
state.Gamepad.sThumbRX = 0;
}
if ((state.Gamepad.sThumbRY < XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE &&
state.Gamepad.sThumbRY > -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE))
{
state.Gamepad.sThumbRY = 0;
}
if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) button_state[0] = TRUE;
if (state.Gamepad.wButtons & XINPUT_GAMEPAD_B) button_state[1] = TRUE;
if (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) button_state[2] = TRUE;
if (state.Gamepad.wButtons & XINPUT_GAMEPAD_Y) button_state[3] = TRUE;
if (state.Gamepad.sThumbLX < 0) joystick[0].left = TRUE;
if (state.Gamepad.sThumbLX > 0) joystick[0].right = TRUE;
if (state.Gamepad.sThumbLY < 0) joystick[0].up = TRUE;
if (state.Gamepad.sThumbLY > 0) joystick[0].down = TRUE;
analog_axis[0] = state.Gamepad.sThumbLX / 256;
analog_axis[1] = state.Gamepad.sThumbLY / 256;
analog_axis[2] = state.Gamepad.bRightTrigger;
analog_axis[3] = state.Gamepad.bLeftTrigger;
analog_axis[4] = state.Gamepad.sThumbRX;
analog_axis[5] = state.Gamepad.sThumbRY;
}
}
static int get_analog_axis(GAME_ANALOG axis)
{
switch (axis)
{
case ANALOG_AXIS_1: return analog_axis[0];
case ANALOG_AXIS_2: return analog_axis[1];
case ANALOG_AXIS_3: return analog_axis[2];
case ANALOG_AXIS_4: return analog_axis[3];
case ANALOG_AXIS_5: return analog_axis[4];
case ANALOG_AXIS_6: return analog_axis[5];
case ANALOG_AXIS_7: return analog_axis[6];
case ANALOG_AXIS_8: return analog_axis[7];
}
return 0;
}
static BOOL is_button_pressed(GAME_BUTTON button)
{
switch (button)
{
case P1_BUTTON_1: return button_state[0];
case P1_BUTTON_2: return button_state[1];
case P1_BUTTON_3: return button_state[2];
case P1_BUTTON_4: return button_state[3];
case P1_BUTTON_5: return button_state[4];
case P1_BUTTON_6: return button_state[5];
case P1_BUTTON_7: return button_state[6];
case P1_BUTTON_8: return button_state[7];
case P2_BUTTON_1: return button_state[8];
case P2_BUTTON_2: return button_state[9];
case P2_BUTTON_3: return button_state[10];
case P2_BUTTON_4: return button_state[11];
case P2_BUTTON_5: return button_state[12];
case P2_BUTTON_6: return button_state[13];
case P2_BUTTON_7: return button_state[14];
case P2_BUTTON_8: return button_state[15];
case P1_JOYSTICK_UP: return joystick[0].up;
case P1_JOYSTICK_DOWN: return joystick[0].down;
case P1_JOYSTICK_LEFT: return joystick[0].left;
case P1_JOYSTICK_RIGHT: return joystick[0].right;
}
return FALSE;
}
OSD_CONTROLS* osd_input_update_controls(void)
{
int i;
INT32 mouse_x, mouse_y;
input_update();
controls.game_controls[0] = 0xFF;
controls.game_controls[1] = 0xFF;
controls.system_controls[0] = 0xFF;
controls.system_controls[1] = 0xFF;
// Lightgun
if(mouse_get_button(0))
controls.game_controls[0] &= ~0x01;
if(mouse_get_button(1))
controls.gun_acquired[0] = TRUE;
else
controls.gun_acquired[0] = FALSE;
mouse_get_position(&mouse_x, &mouse_y);
if (!m3_config.fullscreen)
{
controls.gun_x[0] = mouse_x + (400 - (MODEL3_SCREEN_WIDTH / 2));
controls.gun_y[0] = mouse_y + (272 - (MODEL3_SCREEN_HEIGHT / 2));
}
else
{
if (m3_config.stretch)
{
mouse_x = (mouse_x * 496) / m3_config.width;
mouse_y = (mouse_y * 384) / m3_config.height;
}
controls.gun_x[0] = mouse_x + (400 - (MODEL3_SCREEN_WIDTH / 2));
controls.gun_y[0] = mouse_y + (272 - (MODEL3_SCREEN_HEIGHT / 2));
}
// Game controls
if (xbox_controllers[0])
{
update_controls_xbox();
}
else
{
update_controls_keyboard();
}
// update button states
for (i=0; i < 16; i++)
{
if (m3_config.controls.button[i].enabled)
{
if (is_button_pressed(m3_config.controls.button[i].mapping))
{
int set = m3_config.controls.button[i].control_set;
controls.game_controls[set] &= ~m3_config.controls.button[i].control_bit;
}
}
}
// update analog controls
for (i=0; i < 8; i++)
{
if (m3_config.controls.analog_axis[i].enabled)
{
int value = get_analog_axis(m3_config.controls.analog_axis[i].mapping);
value += m3_config.controls.analog_axis[i].center;
controls.analog_axis[i] = value;
}
}
// Lightgun hack for Star Wars Trilogy
if (stricmp(m3_config.game_id, "swtrilgy") == 0)
{
mouse_get_position(&mouse_x, &mouse_y);
mouse_x = (mouse_x * 256) / ((m3_config.fullscreen) ? m3_config.width : 496);
mouse_y = (mouse_y * 256) / ((m3_config.fullscreen) ? m3_config.height : 384);
controls.analog_axis[0] = mouse_y;
controls.analog_axis[1] = mouse_x;
if (mouse_get_button(1))
controls.game_controls[0] &= ~0x01;
if (mouse_get_button(0))
controls.game_controls[0] &= ~0x20;
}
// System controls
if (keyboard_get_key(DIK_F1)) // Service button
{
controls.system_controls[0] &= ~0x08;
}
if (keyboard_get_key(DIK_F2)) // Test button
{
controls.system_controls[0] &= ~0x04;
}
if (keyboard_get_key(DIK_F3)) // Service button B
{
controls.system_controls[1] &= ~0x40;
}
if (keyboard_get_key(DIK_F4)) // Test button B
{
controls.system_controls[1] &= ~0x80;
}
if (keyboard_get_key(DIK_1)) // Start button 1
{
controls.system_controls[0] &= ~0x10;
}
if (keyboard_get_key(DIK_2)) // Start button 2
{
controls.system_controls[0] &= ~0x20;
}
if (keyboard_get_key(DIK_5)) // Coin #1
{
controls.system_controls[0] &= ~0x01;
}
if (keyboard_get_key(DIK_6)) // Coin #2
{
controls.system_controls[0] &= ~0x02;
}
return &controls;
}