mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
model3: New 3D renderer + various fixes (still heavily WIP) [Ville Linde]
This commit is contained in:
parent
120ba87d70
commit
c0234a2f29
7 changed files with 1072 additions and 728 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -7597,7 +7597,6 @@ src/mame/video/lvcards.c svneol=native#text/plain
|
|||
src/mame/video/lwings.c svneol=native#text/plain
|
||||
src/mame/video/m10.c svneol=native#text/plain
|
||||
src/mame/video/m107.c svneol=native#text/plain
|
||||
src/mame/video/m3raster.inc svneol=native#text/plain
|
||||
src/mame/video/m52.c svneol=native#text/plain
|
||||
src/mame/video/m57.c svneol=native#text/plain
|
||||
src/mame/video/m58.c svneol=native#text/plain
|
||||
|
|
|
@ -13,34 +13,36 @@
|
|||
Step 2.1: 166 MHz PPC, same 3D engine as 2.0, differences unknown
|
||||
|
||||
Game status:
|
||||
vf3/vf3a/vf3tb - don't boot - stuck in poly_wait()
|
||||
bass - boots and runs with 3D
|
||||
vf3/vf3a/vf3tb - crashes
|
||||
bass - works
|
||||
getbass - I/O board error (?)
|
||||
|
||||
scud/scuda - boots and runs with 3D (scuda says "for sale and use only in Japan" but is marked Export?)
|
||||
scudj - boots but hangs up (no SCSI IRQs)
|
||||
scudp - shows initial screen, apparently won't go into test mode or advance
|
||||
lostwsga - SCSI IRQ stuck on (boots and runs with 3D if hacked)
|
||||
vs215 - boots and runs with 3D
|
||||
lemans24 - SCSI IRQ stuck on (boots if hacked)
|
||||
vs29815 - write to unknown 53c810 SCSI register
|
||||
scud/scuda - works (scuda says "for sale and use only in Japan" but is marked Export?)
|
||||
scudj - works
|
||||
scudplus - works
|
||||
lostwsga - works
|
||||
vs215 - works
|
||||
lemans24 - works
|
||||
vs29815 - massive memory trashing and page faults
|
||||
|
||||
vs2 - looks like it should boot but never displays anything
|
||||
harley - boots and runs with 3D after a "NO DAUGHTER BOARD DETECTED" error
|
||||
skichamp - "NO DAUGHTER BOARD DETECTED", doesn't advance (no SCSI IRQs occur)
|
||||
srally2/sraly2dx - doesn't boot (no SCSI IRQs occur, other IRQs look fine)
|
||||
von2/von254g - SCSI IRQ stuck on (boots and runs if SCSI ack is hacked)
|
||||
fvipers2 - says "ONE PROCESSOR DETECTED" and hangs (no SCSI IRQs occur, others look fine)
|
||||
vs298/vs299/vs2v991 - hangs (no SCSI IRQs occur, others look fine)
|
||||
vs2 - waiting for decrementer (same code as eca)
|
||||
harley -
|
||||
skichamp - waiting for decrementer
|
||||
srally2/sraly2dx - works
|
||||
von2/von254g - works
|
||||
fvipers2 - waiting for decrementer (same code as eca)
|
||||
vs298/vs299/vs2v991 - waiting for decrementer
|
||||
oceanhun - same as daytona2
|
||||
lamachin - works
|
||||
|
||||
dayto2pe - bug in DRC MMU page-fault handling, causes infinite loop at PC:0x2270 (or debug assert)
|
||||
daytona2 - As above.
|
||||
spikeout/spikeofe - As above.
|
||||
dirtdvls/dirtdvla - SCSI IRQ stuck on (boots partially if hacked)
|
||||
swtrilgy - doesn't boot (no SCSI IRQs occur, other IRQs look fine)
|
||||
swtrilga - SCSI IRQ stuck on
|
||||
magtruck - SCSI IRQ stuck on (boots and fails country code check (!) if hacked)
|
||||
eca/ecax - doesn't boot (a few SCSI IRQs occur but then cease, other IRQs look fine)
|
||||
dirtdvls/dirtdvla - works
|
||||
swtrilgy -
|
||||
swtrilga -
|
||||
magtruck - works
|
||||
eca/ecax - waiting for decrementer
|
||||
|
||||
===================================================================================
|
||||
|
||||
|
@ -1242,10 +1244,9 @@ void model3_state::model3_init(int step)
|
|||
m_m3_step = step; // step = BCD hardware rev. 0x10 for 1.0, 0x15 for 1.5, 0x20 for 2.0, etc.
|
||||
tap_reset();
|
||||
|
||||
if (step < 0x20) {
|
||||
if( core_stricmp(machine().system().name, "vs215") == 0 ||
|
||||
core_stricmp(machine().system().name, "vs29815") == 0 ||
|
||||
core_stricmp(machine().system().name, "bass") == 0 )
|
||||
if (step < 0x20)
|
||||
{
|
||||
if (m_step15_with_mpc106)
|
||||
{
|
||||
mpc106_init(machine());
|
||||
}
|
||||
|
@ -1255,12 +1256,12 @@ void model3_state::model3_init(int step)
|
|||
}
|
||||
m_real3d_device_id = 0x16c311db; /* PCI Vendor ID (11db = SEGA), Device ID (16c3 = 315-5827) */
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
mpc106_init(machine());
|
||||
// some step 2+ games need the older PCI ID (obvious symptom:
|
||||
// vbl is enabled briefly then disabled so the game hangs)
|
||||
if (core_stricmp(machine().system().name, "magtruck") == 0 ||
|
||||
core_stricmp(machine().system().name, "von254g") == 0)
|
||||
if (m_step20_with_old_real3d)
|
||||
{
|
||||
m_real3d_device_id = 0x16c311db; /* PCI Vendor ID (11db = SEGA), Device ID (16c3 = 315-5827) */
|
||||
}
|
||||
|
@ -5646,84 +5647,51 @@ DRIVER_INIT_MEMBER(model3_state,lostwsga)
|
|||
|
||||
DRIVER_INIT_MEMBER(model3_state,scud)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
DRIVER_INIT_CALL(model3_15);
|
||||
/* TODO: network device at 0xC0000000 - FF */
|
||||
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf9000000, 0xf90000ff, read64_delegate(FUNC(model3_state::scsi_r),this), write64_delegate(FUNC(model3_state::scsi_w),this));
|
||||
|
||||
rom[(0x71275c^4)/4] = 0x60000000;
|
||||
rom[(0x71277c^4)/4] = 0x60000000;
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,scudplus)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
DRIVER_INIT_CALL(model3_15);
|
||||
/* TODO: network device at 0xC0000000 - FF */
|
||||
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xc1000000, 0xc10000ff, read64_delegate(FUNC(model3_state::scsi_r),this), write64_delegate(FUNC(model3_state::scsi_w),this));
|
||||
|
||||
rom[(0x713724^4)/4] = 0x60000000;
|
||||
rom[(0x713744^4)/4] = 0x60000000;
|
||||
|
||||
rom[(0x741f48^4)/4] = 0x60000000;
|
||||
|
||||
rom[(0x741f68^4)/4] = 0x60000000;
|
||||
rom[(0x741efc^4)/4] = 0x60000000;
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,scudplusa)
|
||||
{
|
||||
//UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
DRIVER_INIT_CALL(model3_15);
|
||||
/* TODO: network device at 0xC0000000 - FF */
|
||||
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xc1000000, 0xc10000ff, read64_delegate(FUNC(model3_state::scsi_r),this), write64_delegate(FUNC(model3_state::scsi_w),this));
|
||||
|
||||
//rom[(0x713724^4)/4] = 0x60000000; // Fix ME!!!! Needs to corrected for the non REV A version!!!!
|
||||
//rom[(0x713744^4)/4] = 0x60000000;
|
||||
|
||||
//rom[(0x741f48^4)/4] = 0x60000000;
|
||||
|
||||
//rom[(0x741f68^4)/4] = 0x60000000;
|
||||
//rom[(0x741efc^4)/4] = 0x60000000;
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,lemans24)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_15);
|
||||
|
||||
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xc1000000, 0xc10000ff, read64_delegate(FUNC(model3_state::scsi_r),this), write64_delegate(FUNC(model3_state::scsi_w),this));
|
||||
|
||||
rom[(0x73fe38^4)/4] = 0x38840004; /* This seems to be an actual bug in the original code */
|
||||
|
||||
rom[(0x73eb5c^4)/4] = 0x60000000;
|
||||
rom[(0x73edd0^4)/4] = 0x60000000;
|
||||
rom[(0x73edc4^4)/4] = 0x60000000;
|
||||
|
||||
// rom[(0x73fe38^4)/4] = 0x38840004; /* This seems to be an actual bug in the original code */
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,vf3)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
//UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
DRIVER_INIT_CALL(model3_10);
|
||||
|
||||
/*
|
||||
rom[(0x713c7c^4)/4] = 0x60000000;
|
||||
rom[(0x713e54^4)/4] = 0x60000000;
|
||||
rom[(0x7125b0^4)/4] = 0x60000000;
|
||||
rom[(0x7125d0^4)/4] = 0x60000000;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,vs215)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
rom[(0x70dde0^4)/4] = 0x60000000;
|
||||
rom[(0x70e6f0^4)/4] = 0x60000000;
|
||||
rom[(0x70e710^4)/4] = 0x60000000;
|
||||
m_step15_with_mpc106 = true;
|
||||
|
||||
interleave_vroms(machine());
|
||||
m_maincpu->space(AS_PROGRAM).install_read_bank(0xff000000, 0xff7fffff, "bank1" );
|
||||
|
@ -5739,6 +5707,8 @@ DRIVER_INIT_MEMBER(model3_state,vs215)
|
|||
|
||||
DRIVER_INIT_MEMBER(model3_state,vs29815)
|
||||
{
|
||||
m_step15_with_mpc106 = true;
|
||||
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
rom[(0x6028ec^4)/4] = 0x60000000;
|
||||
|
@ -5758,10 +5728,7 @@ DRIVER_INIT_MEMBER(model3_state,vs29815)
|
|||
|
||||
DRIVER_INIT_MEMBER(model3_state,bass)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
|
||||
rom[(0x7999a8^4)/4] = 0x60000000;
|
||||
rom[(0x7999c8^4)/4] = 0x60000000;
|
||||
m_step15_with_mpc106 = true;
|
||||
|
||||
interleave_vroms(machine());
|
||||
m_maincpu->space(AS_PROGRAM).install_read_bank(0xff000000, 0xff7fffff, "bank1" );
|
||||
|
@ -5865,72 +5832,70 @@ DRIVER_INIT_MEMBER(model3_state,harley)
|
|||
|
||||
DRIVER_INIT_MEMBER(model3_state,harleya)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
//UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
m_network_ram = auto_alloc_array_clear(machine(), UINT64, 0x10000);
|
||||
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xc0000000, 0xc00fffff, read64_delegate(FUNC(model3_state::network_r),this), write64_delegate(FUNC(model3_state::network_w),this));
|
||||
|
||||
/*
|
||||
rom[(0x50e8d4^4)/4] = 0x60000000;
|
||||
rom[(0x50e8f4^4)/4] = 0x60000000;
|
||||
rom[(0x50fb84^4)/4] = 0x60000000;
|
||||
rom[(0x4f736c^4)/4] = 0x60000000;
|
||||
rom[(0x4f738c^4)/4] = 0x60000000;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,srally2)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
{
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
rom[(0x7c0c4^4)/4] = 0x60000000;
|
||||
rom[(0x7c0c8^4)/4] = 0x60000000;
|
||||
rom[(0x7c0cc^4)/4] = 0x60000000;
|
||||
// Writes command 000023FFFFFFFFFE to JTAG, expects result 0x0040000000 (41 bits)
|
||||
// Writes command 000003FFFFFFFFFE
|
||||
// Writes command 00003FFFFFFFFFFE 248 times
|
||||
// Writes command 000023FFFFFFFFFE, expects result 0x01000000000 (?? bits)
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,swtrilgy)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
//UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
/*
|
||||
rom[(0xf0e48^4)/4] = 0x60000000;
|
||||
rom[(0x043dc^4)/4] = 0x48000090;
|
||||
rom[(0x029a0^4)/4] = 0x60000000;
|
||||
rom[(0x02a0c^4)/4] = 0x60000000;
|
||||
*/
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,swtrilga)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
//UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
rom[(0xf6dd0^4)/4] = 0x60000000;
|
||||
//rom[(0xf6dd0^4)/4] = 0x60000000;
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,von2)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
m_step20_with_old_real3d = true;
|
||||
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
rom[(0x189168^4)/4] = 0x60000000;
|
||||
rom[(0x1890ac^4)/4] = 0x60000000;
|
||||
rom[(0x1890b8^4)/4] = 0x60000000;
|
||||
rom[(0x1888a8^4)/4] = 0x60000000;
|
||||
rom[(0x1891c8^4)/4] = 0x60000000;
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,dirtdvls)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
m_step20_with_old_real3d = true;
|
||||
|
||||
rom[(0x0600a0^4)/4] = 0x60000000;
|
||||
rom[(0x0608a4^4)/4] = 0x60000000;
|
||||
rom[(0x0608b0^4)/4] = 0x60000000;
|
||||
rom[(0x060960^4)/4] = 0x60000000;
|
||||
rom[(0x0609c0^4)/4] = 0x60000000;
|
||||
rom[(0x001e24^4)/4] = 0x60000000;
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,daytona2)
|
||||
|
@ -5982,23 +5947,26 @@ DRIVER_INIT_MEMBER(model3_state,spikeofe)
|
|||
|
||||
DRIVER_INIT_MEMBER(model3_state,eca)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
// UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
|
||||
/*
|
||||
rom[(0x535560^4)/4] = 0x60000000;
|
||||
rom[(0x535580^4)/4] = 0x60000000;
|
||||
*/
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,skichamp)
|
||||
{
|
||||
UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
//UINT32 *rom = (UINT32*)memregion("user1")->base();
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
|
||||
/*
|
||||
rom[(0x5263c8^4)/4] = 0x60000000;
|
||||
rom[(0x5263e8^4)/4] = 0x60000000;
|
||||
rom[(0x516bbc^4)/4] = 0x60000000;
|
||||
rom[(0x516b9c^4)/4] = 0x60000000; // decrementer
|
||||
*/
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,oceanhun)
|
||||
|
@ -6011,6 +5979,15 @@ DRIVER_INIT_MEMBER(model3_state,oceanhun)
|
|||
|
||||
DRIVER_INIT_MEMBER(model3_state,magtruck)
|
||||
{
|
||||
m_step20_with_old_real3d = true;
|
||||
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
}
|
||||
|
||||
DRIVER_INIT_MEMBER(model3_state,lamachin)
|
||||
{
|
||||
m_step20_with_old_real3d = true;
|
||||
|
||||
DRIVER_INIT_CALL(model3_20);
|
||||
}
|
||||
|
||||
|
@ -6039,13 +6016,13 @@ GAME( 1998, vs29815, vs298, model3_15, model3, model3_state, vs29815, ROT0
|
|||
GAME( 1997, vs2, 0, model3_20, model3, model3_state, vs2, ROT0, "Sega", "Virtua Striker 2 (Step 2.0)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1997, harley, 0, model3_20, harley, model3_state, harley, ROT0, "Sega", "Harley-Davidson and L.A. Riders (Revision B)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1997, harleya, harley, model3_20, harley, model3_state, harleya, ROT0, "Sega", "Harley-Davidson and L.A. Riders (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, lamachin, 0, model3_20, model3, model3_state, model3_20, ROT0, "Sega", "L.A. Machineguns", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, lamachin, 0, model3_20, model3, model3_state, lamachin, ROT0, "Sega", "L.A. Machineguns", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, oceanhun, 0, model3_20, model3, model3_state, oceanhun, ROT0, "Sega", "The Ocean Hunter", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, skichamp, 0, model3_20, skichamp, model3_state, skichamp, ROT0, "Sega", "Ski Champ", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, srally2, 0, model3_20, scud, model3_state, srally2, ROT0, "Sega", "Sega Rally 2", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, srally2x, 0, model3_20, scud, model3_state, srally2, ROT0, "Sega", "Sega Rally 2 DX", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, von2, 0, model3_20, model3, model3_state, von2, ROT0, "Sega", "Virtual On 2: Oratorio Tangram (Revision B)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, von254g, von2, model3_20, model3, model3_state, model3_20, ROT0, "Sega", "Virtual On 2: Oratorio Tangram (ver 5.4g)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, von254g, von2, model3_20, model3, model3_state, von2, ROT0, "Sega", "Virtual On 2: Oratorio Tangram (ver 5.4g)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, fvipers2, 0, model3_20, model3, model3_state, model3_20, ROT0, "Sega", "Fighting Vipers 2 (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1998, vs298, 0, model3_20, model3, model3_state, vs298, ROT0, "Sega", "Virtua Striker 2 '98 (Step 2.0)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
GAME( 1999, vs2v991, 0, model3_20, model3, model3_state, vs2v991, ROT0, "Sega", "Virtua Striker 2 '99.1 (Revision B)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "video/polylgcy.h"
|
||||
#include "video/poly.h"
|
||||
#include "bus/scsi/scsi.h"
|
||||
#include "machine/53c810.h"
|
||||
#include "audio/dsbz80.h"
|
||||
|
@ -9,11 +9,58 @@ typedef float MATRIX[4][4];
|
|||
typedef float VECTOR[4];
|
||||
typedef float VECTOR3[3];
|
||||
|
||||
struct PLANE {
|
||||
float x,y,z,d;
|
||||
struct cached_texture
|
||||
{
|
||||
cached_texture *next;
|
||||
UINT8 width;
|
||||
UINT8 height;
|
||||
UINT8 format;
|
||||
UINT8 alpha;
|
||||
rgb_t data[1];
|
||||
};
|
||||
|
||||
struct cached_texture;
|
||||
struct m3_plane
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float d;
|
||||
};
|
||||
|
||||
struct m3_vertex
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float u;
|
||||
float v;
|
||||
float nx;
|
||||
float ny;
|
||||
float nz;
|
||||
};
|
||||
|
||||
struct m3_clip_vertex
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float u;
|
||||
float v;
|
||||
float i;
|
||||
};
|
||||
|
||||
struct m3_triangle
|
||||
{
|
||||
m3_clip_vertex v[3];
|
||||
|
||||
cached_texture *texture;
|
||||
int param;
|
||||
int transparency;
|
||||
int intensity;
|
||||
int color;
|
||||
};
|
||||
|
||||
class model3_renderer;
|
||||
|
||||
class model3_state : public driver_device
|
||||
{
|
||||
|
@ -31,18 +78,11 @@ public:
|
|||
m_dsbz80(*this, DSBZ80_TAG),
|
||||
m_soundram(*this, "soundram"),
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_palette(*this, "palette") { }
|
||||
|
||||
struct TRIANGLE
|
||||
m_palette(*this, "palette")
|
||||
{
|
||||
poly_vertex v[3];
|
||||
UINT8 texture_x, texture_y;
|
||||
UINT8 texture_width, texture_height;
|
||||
UINT8 transparency;
|
||||
UINT8 texture_format, param;
|
||||
int intensity;
|
||||
UINT32 color;
|
||||
};
|
||||
m_step15_with_mpc106 = false;
|
||||
m_step20_with_old_real3d = false;
|
||||
}
|
||||
|
||||
required_device<cpu_device> m_maincpu;
|
||||
optional_device<lsi53c810_device> m_lsi53c810;
|
||||
|
@ -54,7 +94,7 @@ public:
|
|||
required_shared_ptr<UINT64> m_work_ram;
|
||||
required_shared_ptr<UINT64> m_paletteram64;
|
||||
optional_device<dsbz80_device> m_dsbz80; // Z80-based MPEG Digital Sound Board
|
||||
required_shared_ptr<UINT16> m_soundram;
|
||||
required_shared_ptr<UINT16> m_soundram;
|
||||
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<palette_device> m_palette;
|
||||
|
@ -69,13 +109,15 @@ public:
|
|||
UINT8 m_scsi_irq_state;
|
||||
int m_crom_bank;
|
||||
int m_controls_bank;
|
||||
bool m_step15_with_mpc106;
|
||||
bool m_step20_with_old_real3d;
|
||||
UINT32 m_real3d_device_id;
|
||||
UINT32 m_mpc105_regs[0x40];
|
||||
UINT32 m_mpc105_addr;
|
||||
int m_pci_bus;
|
||||
int m_pci_device;
|
||||
int m_pci_function;
|
||||
int m_pci_reg;
|
||||
UINT32 m_mpc105_regs[0x40];
|
||||
UINT32 m_mpc105_addr;
|
||||
UINT32 m_mpc106_regs[0x40];
|
||||
UINT32 m_mpc106_addr;
|
||||
UINT32 m_dma_data;
|
||||
|
@ -117,19 +159,14 @@ public:
|
|||
UINT32 *m_culling_ram;
|
||||
UINT32 *m_polygon_ram;
|
||||
int m_real3d_display_list;
|
||||
bitmap_rgb32 m_bitmap3d;
|
||||
bitmap_ind32 m_zbuffer;
|
||||
rectangle m_clip3d;
|
||||
rectangle *m_screen_clip;
|
||||
VECTOR3 m_parallel_light;
|
||||
float m_parallel_light_intensity;
|
||||
float m_ambient_light_intensity;
|
||||
legacy_poly_manager *m_poly;
|
||||
int m_list_depth;
|
||||
int m_tick;
|
||||
int m_debug_layer_disable;
|
||||
UINT64 m_vid_reg0;
|
||||
int m_matrix_stack_ptr;
|
||||
int m_list_depth;
|
||||
MATRIX *m_matrix_stack;
|
||||
MATRIX m_coordinate_system;
|
||||
float m_viewport_focal_length;
|
||||
|
@ -137,10 +174,12 @@ public:
|
|||
int m_viewport_region_y;
|
||||
int m_viewport_region_width;
|
||||
int m_viewport_region_height;
|
||||
PLANE m_clip_plane[5];
|
||||
m3_plane m_clip_plane[5];
|
||||
UINT32 m_matrix_base_address;
|
||||
cached_texture *m_texcache[2][1024/32][2048/32];
|
||||
|
||||
model3_renderer *m_renderer;
|
||||
|
||||
DECLARE_READ32_MEMBER(rtc72421_r);
|
||||
DECLARE_WRITE32_MEMBER(rtc72421_w);
|
||||
DECLARE_READ64_MEMBER(model3_char_r);
|
||||
|
@ -219,8 +258,8 @@ public:
|
|||
DECLARE_DRIVER_INIT(dayto2pe);
|
||||
DECLARE_DRIVER_INIT(spikeout);
|
||||
DECLARE_DRIVER_INIT(magtruck);
|
||||
DECLARE_DRIVER_INIT(model3_15);
|
||||
virtual void video_start();
|
||||
DECLARE_DRIVER_INIT(lamachin);
|
||||
DECLARE_DRIVER_INIT(model3_15);
|
||||
DECLARE_MACHINE_START(model3_10);
|
||||
DECLARE_MACHINE_RESET(model3_10);
|
||||
DECLARE_MACHINE_START(model3_15);
|
||||
|
@ -229,7 +268,6 @@ public:
|
|||
DECLARE_MACHINE_RESET(model3_20);
|
||||
DECLARE_MACHINE_START(model3_21);
|
||||
DECLARE_MACHINE_RESET(model3_21);
|
||||
UINT32 screen_update_model3(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
TIMER_CALLBACK_MEMBER(model3_sound_timer_tick);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(model3_interrupt);
|
||||
void model3_exit();
|
||||
|
@ -241,6 +279,8 @@ public:
|
|||
void set_irq_line(UINT8 bit, int line);
|
||||
void model3_init(int step);
|
||||
// video
|
||||
virtual void video_start();
|
||||
UINT32 screen_update_model3(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
TILE_GET_INFO_MEMBER(tile_info_layer0_4bit);
|
||||
TILE_GET_INFO_MEMBER(tile_info_layer1_4bit);
|
||||
TILE_GET_INFO_MEMBER(tile_info_layer2_4bit);
|
||||
|
@ -262,7 +302,6 @@ public:
|
|||
void pop_matrix_stack();
|
||||
void multiply_matrix_stack(MATRIX matrix);
|
||||
void translate_matrix_stack(float x, float y, float z);
|
||||
void render_one(TRIANGLE *tri);
|
||||
void draw_model(UINT32 addr);
|
||||
UINT32 *get_memory_pointer(UINT32 address);
|
||||
void load_matrix(int matrix_num, MATRIX *out);
|
||||
|
@ -272,11 +311,6 @@ public:
|
|||
void draw_block(UINT32 address);
|
||||
void draw_viewport(int pri, UINT32 address);
|
||||
void real3d_traverse_display_list();
|
||||
#ifdef UNUSED_FUNCTION
|
||||
inline void write_texture8(int xpos, int ypos, int width, int height, int page, UINT16 *data);
|
||||
void draw_texture_sheet(bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
void copy_screen(bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
#endif
|
||||
void real3d_display_list_end();
|
||||
void real3d_display_list1_dma(UINT32 src, UINT32 dst, int length, int byteswap);
|
||||
void real3d_display_list2_dma(UINT32 src, UINT32 dst, int length, int byteswap);
|
||||
|
@ -288,4 +322,5 @@ public:
|
|||
int tap_read();
|
||||
void tap_write(int tck, int tms, int tdi, int trst);
|
||||
void tap_reset();
|
||||
void tap_set_asic_ids();
|
||||
};
|
||||
|
|
|
@ -148,57 +148,27 @@ void model3_state::tap_write(int tck, int tms, int tdi, int trst)
|
|||
switch (m_tap_state)
|
||||
{
|
||||
case 3: // Capture-DR
|
||||
//printf("capture dr (IR = %08X%08X\n", (UINT32)(m_ir >> 32),(UINT32)(m_ir));
|
||||
|
||||
/*
|
||||
* Read ASIC IDs.
|
||||
*
|
||||
* The ID Sequence is:
|
||||
* - Jupiter
|
||||
* - Mercury
|
||||
* - Venus
|
||||
* - Earth
|
||||
* - Mars
|
||||
* - Mars (again)
|
||||
*
|
||||
* Note that different Model 3 steps have different chip
|
||||
* revisions, hence the different IDs returned below.
|
||||
*
|
||||
* On Step 1.5 and 1.0, instruction 0x0C631F8C7FFE is used to retrieve
|
||||
* the ID codes but Step 2.0 is a little weirder. It seems to use this
|
||||
* and either the state of the TAP after reset or other instructions
|
||||
* to read the IDs as well. This can be emulated in one of 2 ways:
|
||||
* Ignore the instruction and always load up the data or load the
|
||||
* data on TAP reset and when the instruction is issued.
|
||||
*/
|
||||
if (m_ir == U64(0x000023fffffffffe))
|
||||
{
|
||||
for (int i=0; i < 32; i++)
|
||||
{
|
||||
m_id_data[i] = 0;
|
||||
}
|
||||
|
||||
if (m_m3_step == 0x10)
|
||||
{
|
||||
insert_id(0x116C7057, 1 + 0 * 32);
|
||||
insert_id(0x216C3057, 1 + 1 * 32);
|
||||
insert_id(0x116C4057, 1 + 2 * 32);
|
||||
insert_id(0x216C5057, 1 + 3 * 32);
|
||||
insert_id(0x116C6057, 1 + 4 * 32 + 1);
|
||||
insert_id(0x116C6057, 1 + 5 * 32 + 1);
|
||||
}
|
||||
else if (m_m3_step == 0x15)
|
||||
{
|
||||
insert_id(0x316C7057, 1 + 0 * 32);
|
||||
insert_id(0x316C3057, 1 + 1 * 32);
|
||||
insert_id(0x216C4057, 1 + 2 * 32); // Lost World may to use 0x016C4057
|
||||
insert_id(0x316C5057, 1 + 3 * 32);
|
||||
insert_id(0x216C6057, 1 + 4 * 32 + 1);
|
||||
insert_id(0x216C6057, 1 + 5 * 32 + 1);
|
||||
}
|
||||
else if (m_m3_step >= 0x20)
|
||||
{
|
||||
insert_id(0x416C7057, 1 + 0 * 32);
|
||||
insert_id(0x416C3057, 1 + 1 * 32);
|
||||
insert_id(0x316C4057, 1 + 2 * 32);
|
||||
insert_id(0x416C5057, 1 + 3 * 32);
|
||||
insert_id(0x316C6057, 1 + 4 * 32 + 1);
|
||||
insert_id(0x316C6057, 1 + 5 * 32 + 1);
|
||||
}
|
||||
m_id_size = 41;
|
||||
|
||||
UINT64 res = 0x0040000000;
|
||||
|
||||
int start_bit = 0;
|
||||
for (int i = 41; i >= 0; i--)
|
||||
insert_bit(m_id_data, start_bit++, ((UINT64)(1 << i) & res) ? 1 : 0);
|
||||
}
|
||||
else if (m_ir == U64(0x00000c631f8c7ffe))
|
||||
{
|
||||
tap_set_asic_ids();
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: // Shift-DR
|
||||
|
@ -241,6 +211,66 @@ void model3_state::tap_write(int tck, int tms, int tdi, int trst)
|
|||
}
|
||||
}
|
||||
|
||||
void model3_state::tap_set_asic_ids()
|
||||
{
|
||||
/*
|
||||
* Read ASIC IDs.
|
||||
*
|
||||
* The ID Sequence is:
|
||||
* - Jupiter
|
||||
* - Mercury
|
||||
* - Venus
|
||||
* - Earth
|
||||
* - Mars
|
||||
* - Mars (again)
|
||||
*
|
||||
* Note that different Model 3 steps have different chip
|
||||
* revisions, hence the different IDs returned below.
|
||||
*
|
||||
* On Step 1.5 and 1.0, instruction 0x0C631F8C7FFE is used to retrieve
|
||||
* the ID codes but Step 2.0 is a little weirder. It seems to use this
|
||||
* and either the state of the TAP after reset or other instructions
|
||||
* to read the IDs as well. This can be emulated in one of 2 ways:
|
||||
* Ignore the instruction and always load up the data or load the
|
||||
* data on TAP reset and when the instruction is issued.
|
||||
*/
|
||||
|
||||
for (int i=0; i < 32; i++)
|
||||
{
|
||||
m_id_data[i] = 0;
|
||||
}
|
||||
|
||||
if (m_m3_step == 0x10)
|
||||
{
|
||||
insert_id(0x116C7057, 1 + 0 * 32);
|
||||
insert_id(0x216C3057, 1 + 1 * 32);
|
||||
insert_id(0x116C4057, 1 + 2 * 32);
|
||||
insert_id(0x216C5057, 1 + 3 * 32);
|
||||
insert_id(0x116C6057, 1 + 4 * 32 + 1);
|
||||
insert_id(0x116C6057, 1 + 5 * 32 + 1);
|
||||
}
|
||||
else if (m_m3_step == 0x15)
|
||||
{
|
||||
insert_id(0x316C7057, 1 + 0 * 32);
|
||||
insert_id(0x316C3057, 1 + 1 * 32);
|
||||
insert_id(0x216C4057, 1 + 2 * 32); // Lost World may to use 0x016C4057
|
||||
insert_id(0x316C5057, 1 + 3 * 32);
|
||||
insert_id(0x216C6057, 1 + 4 * 32 + 1);
|
||||
insert_id(0x216C6057, 1 + 5 * 32 + 1);
|
||||
}
|
||||
else if (m_m3_step >= 0x20)
|
||||
{
|
||||
insert_id(0x416C7057, 1 + 0 * 32);
|
||||
insert_id(0x416C3057, 1 + 1 * 32);
|
||||
insert_id(0x316C4057, 1 + 2 * 32);
|
||||
insert_id(0x416C5057, 1 + 3 * 32);
|
||||
insert_id(0x316C6057, 1 + 4 * 32 + 1);
|
||||
insert_id(0x316C6057, 1 + 5 * 32 + 1);
|
||||
}
|
||||
|
||||
m_id_size = 197; // 197 bits
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* void tap_reset(void);
|
||||
|
@ -250,8 +280,9 @@ void model3_state::tap_write(int tck, int tms, int tdi, int trst)
|
|||
|
||||
void model3_state::tap_reset()
|
||||
{
|
||||
m_id_size = 197; // 197 bits
|
||||
m_tap_state = 0; // test-logic/reset
|
||||
|
||||
tap_set_asic_ids();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -2943,7 +2943,6 @@ $(DRIVERS)/model1.o: $(MAMESRC)/includes/model1.h $(MAMESRC)/audio/dsbz80.h
|
|||
$(VIDEO)/model1.o: $(MAMESRC)/includes/model1.h $(MAMESRC)/audio/dsbz80.h
|
||||
$(MACHINE)/model1.o: $(MAMESRC)/includes/model1.h $(MAMESRC)/audio/dsbz80.h
|
||||
$(VIDEO)/model2.o: $(MAMESRC)/video/model2rd.inc
|
||||
$(VIDEO)/model3.o: $(MAMESRC)/video/m3raster.inc
|
||||
$(VIDEO)/n64.o: $(MAMESRC)/video/rdpfiltr.inc
|
||||
$(DRIVERS)/bfm_sc4.o: $(MAMESRC)/includes/bfm_sc45.h
|
||||
$(DRIVERS)/bfm_sc5.o: $(MAMESRC)/includes/bfm_sc45.h
|
||||
|
|
|
@ -1,286 +0,0 @@
|
|||
static void draw_scanline_normal(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
|
||||
{
|
||||
const poly_extra_data *extra = (const poly_extra_data *)extradata;
|
||||
const cached_texture *texture = extra->texture;
|
||||
bitmap_rgb32 *destmap = (bitmap_rgb32 *)dest;
|
||||
UINT32 *p = &destmap->pix32(scanline);
|
||||
UINT32 *d = &extra->zbuffer->pix32(scanline);
|
||||
float ooz = extent->param[0].start;
|
||||
float uoz = extent->param[1].start;
|
||||
float voz = extent->param[2].start;
|
||||
float doozdx = extent->param[0].dpdx;
|
||||
float duozdx = extent->param[1].dpdx;
|
||||
float dvozdx = extent->param[2].dpdx;
|
||||
UINT32 polyi = extra->polygon_intensity;
|
||||
UINT32 umask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_U) ? 64 : 32) << texture->width) - 1;
|
||||
UINT32 vmask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
|
||||
UINT32 width = 6 + texture->width;
|
||||
int x;
|
||||
|
||||
for (x = extent->startx; x < extent->stopx; x++)
|
||||
{
|
||||
UINT32 iz = ooz * 256.0f;
|
||||
if (iz > d[x])
|
||||
{
|
||||
float z = 1.0f / ooz;
|
||||
UINT32 u = uoz * z;
|
||||
UINT32 v = voz * z;
|
||||
UINT32 u1 = (u >> 8) & umask;
|
||||
UINT32 v1 = (v >> 8) & vmask;
|
||||
UINT32 u2 = (u1 + 1) & umask;
|
||||
UINT32 v2 = (v1 + 1) & vmask;
|
||||
UINT32 pix00 = texture->data[(v1 << width) + u1];
|
||||
UINT32 pix01 = texture->data[(v1 << width) + u2];
|
||||
UINT32 pix10 = texture->data[(v2 << width) + u1];
|
||||
UINT32 pix11 = texture->data[(v2 << width) + u2];
|
||||
UINT32 texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v);
|
||||
UINT32 fr = ((texel & 0x00ff0000) * polyi) >> 8;
|
||||
UINT32 fg = ((texel & 0x0000ff00) * polyi) >> 8;
|
||||
UINT32 fb = ((texel & 0x000000ff) * polyi) >> 8;
|
||||
p[x] = 0xff000000 | (fr & 0xff0000) | (fg & 0xff00) | (fb & 0xff);
|
||||
d[x] = iz;
|
||||
}
|
||||
|
||||
ooz += doozdx;
|
||||
uoz += duozdx;
|
||||
voz += dvozdx;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_scanline_trans(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
|
||||
{
|
||||
const poly_extra_data *extra = (const poly_extra_data *)extradata;
|
||||
const cached_texture *texture = extra->texture;
|
||||
bitmap_rgb32 *destmap = (bitmap_rgb32 *)dest;
|
||||
UINT32 *p = &destmap->pix32(scanline);
|
||||
UINT32 *d = &extra->zbuffer->pix32(scanline);
|
||||
float ooz = extent->param[0].start;
|
||||
float uoz = extent->param[1].start;
|
||||
float voz = extent->param[2].start;
|
||||
float doozdx = extent->param[0].dpdx;
|
||||
float duozdx = extent->param[1].dpdx;
|
||||
float dvozdx = extent->param[2].dpdx;
|
||||
UINT32 polyi = (extra->polygon_intensity * extra->polygon_transparency) >> 5;
|
||||
int desttrans = 32 - extra->polygon_transparency;
|
||||
UINT32 umask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_U) ? 64 : 32) << texture->width) - 1;
|
||||
UINT32 vmask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
|
||||
UINT32 width = 6 + texture->width;
|
||||
int x;
|
||||
|
||||
for (x = extent->startx; x < extent->stopx; x++)
|
||||
{
|
||||
UINT32 iz = ooz * 256.0f;
|
||||
if (iz > d[x])
|
||||
{
|
||||
float z = 1.0f / ooz;
|
||||
UINT32 u = uoz * z;
|
||||
UINT32 v = voz * z;
|
||||
UINT32 u1 = (u >> 8) & umask;
|
||||
UINT32 v1 = (v >> 8) & vmask;
|
||||
UINT32 u2 = (u1 + 1) & umask;
|
||||
UINT32 v2 = (v1 + 1) & vmask;
|
||||
UINT32 pix00 = texture->data[(v1 << width) + u1];
|
||||
UINT32 pix01 = texture->data[(v1 << width) + u2];
|
||||
UINT32 pix10 = texture->data[(v2 << width) + u1];
|
||||
UINT32 pix11 = texture->data[(v2 << width) + u2];
|
||||
UINT32 texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v);
|
||||
UINT32 fr = ((texel & 0x00ff0000) * polyi) >> 8;
|
||||
UINT32 fg = ((texel & 0x0000ff00) * polyi) >> 8;
|
||||
UINT32 fb = ((texel & 0x000000ff) * polyi) >> 8;
|
||||
UINT32 orig = p[x];
|
||||
fr += ((orig & 0x00ff0000) * desttrans) >> 5;
|
||||
fg += ((orig & 0x0000ff00) * desttrans) >> 5;
|
||||
fb += ((orig & 0x000000ff) * desttrans) >> 5;
|
||||
p[x] = 0xff000000 | (fr & 0xff0000) | (fg & 0xff00) | (fb & 0xff);
|
||||
d[x] = iz;
|
||||
}
|
||||
|
||||
ooz += doozdx;
|
||||
uoz += duozdx;
|
||||
voz += dvozdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void draw_scanline_alpha(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
|
||||
{
|
||||
const poly_extra_data *extra = (const poly_extra_data *)extradata;
|
||||
const cached_texture *texture = extra->texture;
|
||||
bitmap_rgb32 *destmap = (bitmap_rgb32 *)dest;
|
||||
UINT32 *p = &destmap->pix32(scanline);
|
||||
UINT32 *d = &extra->zbuffer->pix32(scanline);
|
||||
float ooz = extent->param[0].start;
|
||||
float uoz = extent->param[1].start;
|
||||
float voz = extent->param[2].start;
|
||||
float doozdx = extent->param[0].dpdx;
|
||||
float duozdx = extent->param[1].dpdx;
|
||||
float dvozdx = extent->param[2].dpdx;
|
||||
UINT32 polyi = (extra->polygon_intensity * extra->polygon_transparency) >> 5;
|
||||
int desttrans = 32 - extra->polygon_transparency;
|
||||
UINT32 umask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_U) ? 64 : 32) << texture->width) - 1;
|
||||
UINT32 vmask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
|
||||
UINT32 width = 6 + texture->width;
|
||||
int x;
|
||||
|
||||
for (x = extent->startx; x < extent->stopx; x++)
|
||||
{
|
||||
UINT32 iz = ooz * 256.0f;
|
||||
if (iz > d[x])
|
||||
{
|
||||
float z = 1.0f / ooz;
|
||||
UINT32 u = uoz * z;
|
||||
UINT32 v = voz * z;
|
||||
UINT32 u1 = (u >> 8) & umask;
|
||||
UINT32 v1 = (v >> 8) & vmask;
|
||||
UINT32 u2 = (u1 + 1) & umask;
|
||||
UINT32 v2 = (v1 + 1) & vmask;
|
||||
UINT32 pix00 = texture->data[(v1 << width) + u1];
|
||||
UINT32 pix01 = texture->data[(v1 << width) + u2];
|
||||
UINT32 pix10 = texture->data[(v2 << width) + u1];
|
||||
UINT32 pix11 = texture->data[(v2 << width) + u2];
|
||||
UINT32 texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v);
|
||||
UINT32 fa = texel >> 24;
|
||||
if (fa != 0)
|
||||
{
|
||||
UINT32 combined = ((fa + 1) * polyi) >> 8;
|
||||
UINT32 fr = ((texel & 0x00ff0000) * combined) >> (8+9);
|
||||
UINT32 fg = ((texel & 0x0000ff00) * combined) >> (8+6);
|
||||
UINT32 fb = ((texel & 0x000000ff) * combined) >> (8+3);
|
||||
UINT32 orig = p[x];
|
||||
combined = ((255 - fa) * desttrans) >> 5;
|
||||
fr += ((orig & 0x00ff0000) * combined) >> 8;
|
||||
fg += ((orig & 0x0000ff00) * combined) >> 8;
|
||||
fb += ((orig & 0x000000ff) * combined) >> 8;
|
||||
p[x] = 0xff000000 | (fr & 0xff0000) | (fg & 0xff00) | (fb & 0xff);
|
||||
d[x] = iz;
|
||||
}
|
||||
}
|
||||
|
||||
ooz += doozdx;
|
||||
uoz += duozdx;
|
||||
voz += dvozdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void draw_scanline_alpha_test(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
|
||||
{
|
||||
const poly_extra_data *extra = (const poly_extra_data *)extradata;
|
||||
const cached_texture *texture = extra->texture;
|
||||
bitmap_rgb32 *destmap = (bitmap_rgb32 *)dest;
|
||||
UINT32 *p = &destmap->pix32(scanline);
|
||||
UINT32 *d = &extra->zbuffer->pix32(scanline);
|
||||
float ooz = extent->param[0].start;
|
||||
float uoz = extent->param[1].start;
|
||||
float voz = extent->param[2].start;
|
||||
float doozdx = extent->param[0].dpdx;
|
||||
float duozdx = extent->param[1].dpdx;
|
||||
float dvozdx = extent->param[2].dpdx;
|
||||
UINT32 polyi = (extra->polygon_intensity * extra->polygon_transparency) >> 5;
|
||||
int desttrans = 32 - extra->polygon_transparency;
|
||||
UINT32 umask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_U) ? 64 : 32) << texture->width) - 1;
|
||||
UINT32 vmask = (((extra->texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
|
||||
UINT32 width = 6 + texture->width;
|
||||
int x;
|
||||
|
||||
for (x = extent->startx; x < extent->stopx; x++)
|
||||
{
|
||||
UINT32 iz = ooz * 256.0f;
|
||||
if (iz > d[x])
|
||||
{
|
||||
float z = 1.0f / ooz;
|
||||
UINT32 u = uoz * z;
|
||||
UINT32 v = voz * z;
|
||||
UINT32 u1 = (u >> 8) & umask;
|
||||
UINT32 v1 = (v >> 8) & vmask;
|
||||
UINT32 u2 = (u1 + 1) & umask;
|
||||
UINT32 v2 = (v1 + 1) & vmask;
|
||||
UINT32 pix00 = texture->data[(v1 << width) + u1];
|
||||
UINT32 pix01 = texture->data[(v1 << width) + u2];
|
||||
UINT32 pix10 = texture->data[(v2 << width) + u1];
|
||||
UINT32 pix11 = texture->data[(v2 << width) + u2];
|
||||
UINT32 texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v);
|
||||
UINT32 fa = texel >> 24;
|
||||
if (fa >= 0xf8)
|
||||
{
|
||||
UINT32 combined = ((fa + 1) * polyi) >> 8;
|
||||
UINT32 fr = ((texel & 0x00ff0000) * combined) >> (8+9);
|
||||
UINT32 fg = ((texel & 0x0000ff00) * combined) >> (8+6);
|
||||
UINT32 fb = ((texel & 0x000000ff) * combined) >> (8+3);
|
||||
UINT32 orig = p[x];
|
||||
combined = ((255 - fa) * desttrans) >> 8;
|
||||
fr += ((orig & 0x00ff0000) * combined) >> 5;
|
||||
fg += ((orig & 0x0000ff00) * combined) >> 5;
|
||||
fb += ((orig & 0x000000ff) * combined) >> 5;
|
||||
p[x] = 0xff000000 | (fr & 0xff0000) | (fg & 0xff00) | (fb & 0xff);
|
||||
d[x] = iz;
|
||||
}
|
||||
}
|
||||
|
||||
ooz += doozdx;
|
||||
uoz += duozdx;
|
||||
voz += dvozdx;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_scanline_color(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
|
||||
{
|
||||
const poly_extra_data *extra = (const poly_extra_data *)extradata;
|
||||
bitmap_rgb32 *destmap = (bitmap_rgb32 *)dest;
|
||||
UINT32 *p = &destmap->pix32(scanline);
|
||||
UINT32 *d = &extra->zbuffer->pix32(scanline);
|
||||
float ooz = extent->param[0].start;
|
||||
float doozdx = extent->param[0].dpdx;
|
||||
int fr = (extra->color & 0x7c00) << 9;
|
||||
int fg = (extra->color & 0x03e0) << 6;
|
||||
int fb = (extra->color & 0x001f) << 3;
|
||||
int x;
|
||||
|
||||
// apply intensity
|
||||
fr = (fr * extra->polygon_intensity) >> 8;
|
||||
fg = (fg * extra->polygon_intensity) >> 8;
|
||||
fb = (fb * extra->polygon_intensity) >> 8;
|
||||
|
||||
/* simple case: no transluceny */
|
||||
if (extra->polygon_transparency >= 32)
|
||||
{
|
||||
UINT32 color = (fr & 0x7c00) | (fg & 0x03e0) | (fb & 0x1f);
|
||||
for (x = extent->startx; x < extent->stopx; x++)
|
||||
{
|
||||
UINT32 iz = ooz * 256.0f;
|
||||
if (iz > d[x])
|
||||
{
|
||||
p[x] = color;
|
||||
d[x] = iz;
|
||||
}
|
||||
ooz += doozdx;
|
||||
}
|
||||
}
|
||||
|
||||
/* translucency */
|
||||
else
|
||||
{
|
||||
int polytrans = extra->polygon_transparency;
|
||||
|
||||
fr = (fr * polytrans) >> 5;
|
||||
fg = (fg * polytrans) >> 5;
|
||||
fb = (fb * polytrans) >> 5;
|
||||
polytrans = 32 - polytrans;
|
||||
|
||||
for (x = extent->startx; x < extent->stopx; x++)
|
||||
{
|
||||
UINT32 iz = ooz * 256.0f;
|
||||
if (iz > d[x])
|
||||
{
|
||||
UINT32 orig = p[x];
|
||||
int r = fr + (((orig & 0x00ff0000) * polytrans) >> 5);
|
||||
int g = fg + (((orig & 0x0000ff00) * polytrans) >> 5);
|
||||
int b = fb + (((orig & 0x000000ff) * polytrans) >> 5);
|
||||
|
||||
p[x] = 0xff000000 | (r & 0xff0000) | (g & 0xff00) | (b & 0xff);
|
||||
d[x] = iz;
|
||||
}
|
||||
ooz += doozdx;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue