Previous 199869 Revisions Next

r40645 Tuesday 8th September, 2015 at 14:09:18 UTC by Andrew Gardner
Convert hng64 polygon rasterizing to "polynew".
[scripts/src]sound.lua
[src/emu/sound]315-5641.c 315-5641.h upd7759.c upd7759.h
[src/mame/drivers]hng64.c
[src/mame/includes]hng64.h
[src/mame/video]hng64.c hng64_3d.c
[src/mess/drivers]segapico.c

trunk/scripts/src/sound.lua
r249156r249157
627627   files {
628628      MAME_DIR .. "src/emu/sound/upd7759.c",
629629      MAME_DIR .. "src/emu/sound/upd7759.h",
630      MAME_DIR .. "src/emu/sound/315-5641.c",
631      MAME_DIR .. "src/emu/sound/315-5641.h",
632630   }
633631end
634632
trunk/src/emu/sound/315-5641.c
r249156r249157
1/* Sega 315-5641 / D77591 / 9442CA010 */
2
3#include "emu.h"
4#include "315-5641.h"
5
6const device_type SEGA_315_5641_PCM = &device_creator<sega_315_5641_pcm_device>;
7
8sega_315_5641_pcm_device::sega_315_5641_pcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
9   : upd7759_device(mconfig, SEGA_315_5641_PCM, "315-5641 PCM", tag, owner, clock, "315-5641_pcm", __FILE__)
10{
11}
12
13void sega_315_5641_pcm_device::device_start()
14{
15   save_item(NAME(m_fifo_data), 0x40);
16   save_item(NAME(m_fifo_read));
17   save_item(NAME(m_fifo_write));
18
19   upd7759_device::device_start();
20}
21
22void sega_315_5641_pcm_device::advance_state()
23{
24   switch (m_state)
25   {
26      case STATE_DROP_DRQ:
27         if (m_rombase == NULL)
28         {
29            // Slave Mode: get data from FIFO buffer
30            UINT8 fiforead = (m_fifo_read + 1) & 0x3F;
31            if (fiforead != m_fifo_write)
32            {
33               m_fifo_in = m_fifo_data[fiforead];
34               m_fifo_read = fiforead;
35            }
36         }
37         break;
38   }
39
40   upd775x_device::advance_state();
41}
42
43
44WRITE8_MEMBER( sega_315_5641_pcm_device::port_w )
45{
46   if (m_rombase != NULL)
47   {
48      /* update the FIFO value */
49      m_fifo_in = data;
50   }
51   else
52   {
53      m_fifo_data[m_fifo_write++] = data;
54      m_fifo_write &= 0x3F;
55   }
56}
57
58
59UINT8 sega_315_5641_pcm_device::get_fifo_space()
60{
61   return (m_fifo_read - m_fifo_write) & 0x3F;
62}
63
64void sega_315_5641_pcm_device::device_reset()
65{
66   m_fifo_read          = 0x3F;
67   m_fifo_write         = 0x00;
68
69   upd775x_device::device_reset();
70}
No newline at end of file
trunk/src/emu/sound/315-5641.h
r249156r249157
1/* Sega 315-5641 / D77591 / 9442CA010 */
2
3// this is the PICO sound chip, we are not sure if it's the same as a 7759 or not, it requires FIFO logic
4// which the 7759 does _not_ have but it is possible that is handled somewhere else on the PICO hardawre.
5
6#include "upd7759.h"
7
8
9class sega_315_5641_pcm_device : public upd7759_device
10{
11public:
12   sega_315_5641_pcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
13
14   UINT8 get_fifo_space();
15   void advance_state();
16   DECLARE_WRITE8_MEMBER(port_w);
17
18   UINT8       m_fifo_data[0x40];
19   UINT8       m_fifo_read;   // last read offset (will read in m_fifo_read+1)
20   UINT8       m_fifo_write;   // write offset
21 
22protected:
23   // device-level overrides
24   virtual void device_start();
25   virtual void device_reset();
26
27
28};
29
30extern const device_type SEGA_315_5641_PCM;
No newline at end of file
trunk/src/emu/sound/upd7759.c
r249156r249157
143143#define FRAC_ONE        (1 << FRAC_BITS)
144144#define FRAC_MASK       (FRAC_ONE - 1)
145145
146/* chip states */
147enum
148{
149   STATE_IDLE,
150   STATE_DROP_DRQ,
151   STATE_START,
152   STATE_FIRST_REQ,
153   STATE_LAST_SAMPLE,
154   STATE_DUMMY1,
155   STATE_ADDR_MSB,
156   STATE_ADDR_LSB,
157   STATE_DUMMY2,
158   STATE_BLOCK_HEADER,
159   STATE_NIBBLE_COUNT,
160   STATE_NIBBLE_MSN,
161   STATE_NIBBLE_LSN
162};
146163
147164upd775x_device::upd775x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
148165   : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
r249156r249157
187204{
188205}
189206
190
191upd7759_device::upd7759_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
192   : upd775x_device(mconfig, type, name, tag, owner, clock, shortname, source),
193      m_timer(NULL)
194{
195}
196
197
198207const device_type UPD7756 = &device_creator<upd7756_device>;
199208
200209upd7756_device::upd7756_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
trunk/src/emu/sound/upd7759.h
r249156r249157
55#ifndef __UPD7759_H__
66#define __UPD7759_H__
77
8/* chip states */
9enum
10{
11   STATE_IDLE,
12   STATE_DROP_DRQ,
13   STATE_START,
14   STATE_FIRST_REQ,
15   STATE_LAST_SAMPLE,
16   STATE_DUMMY1,
17   STATE_ADDR_MSB,
18   STATE_ADDR_LSB,
19   STATE_DUMMY2,
20   STATE_BLOCK_HEADER,
21   STATE_NIBBLE_COUNT,
22   STATE_NIBBLE_MSN,
23   STATE_NIBBLE_LSN
24};
258
269/* NEC uPD7759/55/56/P56/57/58 ADPCM Speech Processor */
2710
r249156r249157
4629
4730   DECLARE_WRITE_LINE_MEMBER( reset_w );
4831   DECLARE_READ_LINE_MEMBER( busy_r );
49   virtual DECLARE_WRITE8_MEMBER( port_w );
32   DECLARE_WRITE8_MEMBER( port_w );
5033   void postload();
5134
5235protected:
r249156r249157
10386   devcb_write_line m_drqcallback;
10487
10588   void update_adpcm(int data);
106   virtual void advance_state();
89   void advance_state();
10790};
10891
10992class upd7759_device : public upd775x_device
11093{
11194public:
11295   upd7759_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
113   upd7759_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
11496
11597   enum
11698   {
trunk/src/mame/drivers/hng64.c
r249156r249157
13001300   32*32
13011301};
13021302
1303
13041303static const gfx_layout hng64_16x16x8_tilelayout =
13051304{
13061305   16,16,
r249156r249157
15511550   MCFG_CPU_PROGRAM_MAP(hng_map)
15521551   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", hng64_state, hng64_irq, "screen", 0, 1)
15531552
1554
1555
1556
15571553   MCFG_NVRAM_ADD_0FILL("nvram")
15581554
15591555   MCFG_DEVICE_ADD("rtc", MSM6242, XTAL_32_768kHz)
r249156r249157
20112007GAME( 1997, hng64,    0,      hng64, hng64, hng64_state,  hng64,       ROT0, "SNK", "Hyper NeoGeo 64 Bios", MACHINE_NOT_WORKING|MACHINE_NO_SOUND|MACHINE_IS_BIOS_ROOT )
20122008
20132009/* Games */
2014GAME( 1997, roadedge, hng64,  hng64, roadedge, hng64_state,  hng64_race,  ROT0, "SNK", "Roads Edge / Round Trip (rev.B)",        MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 001 */
2015GAME( 1998, sams64,   hng64,  hng64, hng64, hng64_state,  ss64,        ROT0, "SNK", "Samurai Shodown 64 / Samurai Spirits 64", MACHINE_NOT_WORKING|MACHINE_NO_SOUND ) /* 002 */
2016GAME( 1998, xrally,   hng64,  hng64, roadedge, hng64_state,  hng64_race,  ROT0, "SNK", "Xtreme Rally / Off Beat Racer!",         MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 003 */
2017GAME( 1998, bbust2,   hng64,  hng64, bbust2, hng64_state, hng64_shoot, ROT0, "SNK", "Beast Busters 2nd Nightmare",            MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 004 */
2018GAME( 1998, sams64_2, hng64,  hng64, hng64, hng64_state,  ss64,        ROT0, "SNK", "Samurai Shodown: Warrior's Rage / Samurai Spirits 2: Asura Zanmaden", MACHINE_NOT_WORKING|MACHINE_NO_SOUND ) /* 005 */
2019GAME( 1998, fatfurwa, hng64,  hng64, hng64, hng64_state,  fatfurwa,    ROT0, "SNK", "Fatal Fury: Wild Ambition (rev.A)",          MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 006 */
2020GAME( 1999, buriki,   hng64,  hng64, hng64, hng64_state,  buriki,      ROT0, "SNK", "Buriki One (rev.B)",                     MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 007 */
2010GAME( 1997, roadedge, hng64,  hng64, roadedge, hng64_state,  hng64_race,  ROT0, "SNK", "Roads Edge / Round Trip (rev.B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 001 */
2011GAME( 1998, sams64,   hng64,  hng64, hng64,    hng64_state,  ss64,        ROT0, "SNK", "Samurai Shodown 64 / Samurai Spirits 64", MACHINE_NOT_WORKING|MACHINE_NO_SOUND ) /* 002 */
2012GAME( 1998, xrally,   hng64,  hng64, roadedge, hng64_state,  hng64_race,  ROT0, "SNK", "Xtreme Rally / Off Beat Racer!", MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 003 */
2013GAME( 1998, bbust2,   hng64,  hng64, bbust2,   hng64_state,  hng64_shoot, ROT0, "SNK", "Beast Busters 2nd Nightmare", MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 004 */
2014GAME( 1998, sams64_2, hng64,  hng64, hng64,    hng64_state,  ss64,        ROT0, "SNK", "Samurai Shodown: Warrior's Rage / Samurai Spirits 2: Asura Zanmaden", MACHINE_NOT_WORKING|MACHINE_NO_SOUND ) /* 005 */
2015GAME( 1998, fatfurwa, hng64,  hng64, hng64,    hng64_state,  fatfurwa,    ROT0, "SNK", "Fatal Fury: Wild Ambition (rev.A)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 006 */
2016GAME( 1999, buriki,   hng64,  hng64, hng64,    hng64_state,  buriki,      ROT0, "SNK", "Buriki One (rev.B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND )  /* 007 */
trunk/src/mame/includes/hng64.h
r249156r249157
44#include "cpu/mips/mips3.h"
55#include "cpu/nec/v53.h"
66#include "sound/l7a1045_l6028_dsp_a.h"
7#include "video/poly.h"
78
89enum
910{
r249156r249157
2122   HNG64_TILEMAP_ALPHA
2223};
2324
24
2525struct blit_parameters
2626{
2727   bitmap_rgb32 *          bitmap;
r249156r249157
3535
3636#define HNG64_MASTER_CLOCK 50000000
3737
38///////////////
39// 3d Engine //
40///////////////
4138
39/////////////////
40/// 3d Engine ///
41/////////////////
42
4243struct polyVert
4344{
4445   float worldCoords[4];   // World space coordinates (X Y Z 1.0)
r249156r249157
7273};
7374
7475
76/////////////////////////
77/// polygon rendering ///
78/////////////////////////
7579
76///////////////////////
77// polygon rendering //
78///////////////////////
80// Refer to the clipping planes as numbers
81#define HNG64_LEFT   0
82#define HNG64_RIGHT  1
83#define HNG64_TOP    2
84#define HNG64_BOTTOM 3
85#define HNG64_NEAR   4
86#define HNG64_FAR    5
7987
80struct polygonRasterOptions
88
89////////////////////////////////////
90/// Polygon rasterizer interface ///
91////////////////////////////////////
92
93const int HNG64_MAX_POLYGONS = 10000;
94
95struct hng64_poly_data
8196{
8297   UINT8 texType;
8398   UINT8 texIndex;
r249156r249157
89104   int debugColor;
90105};
91106
92// Refer to the clipping planes as numbers
93#define HNG64_LEFT   0
94#define HNG64_RIGHT  1
95#define HNG64_TOP    2
96#define HNG64_BOTTOM 3
97#define HNG64_NEAR   4
98#define HNG64_FAR    5
107class hng64_state;
99108
109class hng64_poly_renderer : public poly_manager<float, hng64_poly_data, 7, HNG64_MAX_POLYGONS>
110{
111public:
112    hng64_poly_renderer(hng64_state& state);
113   
114    void drawShaded(struct polygon *p);
115    void render_scanline(INT32 scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid);
100116
117    hng64_state& state() { return m_state; }
118    bitmap_rgb32& colorBuffer3d() { return m_colorBuffer3d; }
119    float* depthBuffer3d() { return m_depthBuffer3d; }
120   
121private:
122    hng64_state& m_state;
123   
124    // (Temporarily class members - someday they will live in the memory map)
125    bitmap_rgb32 m_colorBuffer3d;
126    float* m_depthBuffer3d;
127};
101128
129
130
102131class hng64_state : public driver_device
103132{
104133public:
r249156r249157
143172   required_shared_ptr<UINT32> m_videoram;
144173   required_shared_ptr<UINT32> m_videoregs;
145174   required_shared_ptr<UINT32> m_tcram;
146   /* 3D stuff */
175
176    /* 3D stuff */
147177   UINT16* m_dl;
148178
149179   required_shared_ptr<UINT32> m_3dregs;
r249156r249157
194224
195225   UINT8 m_additive_tilemap_debug;
196226
197   // 3d display buffers
198   // (Temporarily global - someday they will live with the proper bit-depth in the memory map)
199   float *m_depthBuffer3d;
200   UINT32 *m_colorBuffer3d;
201
202227   UINT32 m_old_animmask;
203228   UINT32 m_old_animbits;
204229   UINT16 m_old_tileflags[4];
r249156r249157
299324   DECLARE_CUSTOM_INPUT_MEMBER(right_handle_r);
300325   DECLARE_CUSTOM_INPUT_MEMBER(acc_down_r);
301326   DECLARE_CUSTOM_INPUT_MEMBER(brake_down_r);
302   void clear3d();
327
328    hng64_poly_renderer* m_poly_renderer;
329   
330    void clear3d();
303331   TIMER_CALLBACK_MEMBER(hng64_3dfifo_processed);
304332
305   void FillSmoothTexPCHorizontalLine(
306      const polygonRasterOptions& prOptions,
307      int x_start, int x_end, int y, float z_start, float z_delta,
308      float w_start, float w_delta, float r_start, float r_delta,
309      float g_start, float g_delta, float b_start, float b_delta,
310      float s_start, float s_delta, float t_start, float t_delta);
311
312333   void hng64_command3d(const UINT16* packet);
313334   void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
314   void transition_control( bitmap_rgb32 &bitmap, const rectangle &cliprect);
335   void transition_control(bitmap_rgb32 &bitmap, const rectangle &cliprect);
315336   void hng64_tilemap_draw_roz_core(screen_device &screen, tilemap_t *tmap, const blit_parameters *blit,
316337      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound);
317338   void hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm);
r249156r249157
331352      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
332353      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask, hng64trans_t drawformat);
333354
334   void RasterizeTriangle_SMOOTH_TEX_PC(
335      float A[4], float B[4], float C[4],
336      float Ca[3], float Cb[3], float Cc[3], // PER-VERTEX RGB COLORS
337      float Ta[2], float Tb[2], float Tc[2], // PER-VERTEX (S,T) TEX-COORDS
338      const polygonRasterOptions& prOptions);
339
340   void drawShaded( struct polygon *p);
341
342355   void printPacket(const UINT16* packet, int hex);
343356   void matmul4(float *product, const float *a, const float *b);
344357   void vecmatmul4(float *product, const float *a, const float *b);
trunk/src/mame/video/hng64.c
r249156r249157
166166// pppppppp ff--atttt tttttttt tttttttt
167167#define HNG64_GET_TILE_INFO                                                    \
168168{                                                                              \
169   UINT16 tilemapinfo = (m_videoregs[reg]>>shift)&0xffff;                 \
169   UINT16 tilemapinfo = (m_videoregs[reg]>>shift)&0xffff;                     \
170170   int tileno,pal, flip;                                                      \
171                                                            \
172   tileno = m_videoram[tile_index+(offset/4)];                            \
173                                                            \
171                                                            \
172   tileno = m_videoram[tile_index+(offset/4)];                                \
173                                                            \
174174   pal = (tileno&0xff000000)>>24;                                             \
175175   flip =(tileno&0x00c00000)>>22;                                             \
176                                                            \
176                                                            \
177177   if (tileno&0x200000)                                                       \
178178   {                                                                          \
179      tileno = (tileno & m_videoregs[0x0b]) | m_videoregs[0x0c];     \
179      tileno = (tileno & m_videoregs[0x0b]) | m_videoregs[0x0c];             \
180180   }                                                                          \
181                                                            \
181                                                            \
182182   tileno &= 0x1fffff;                                                        \
183                                                            \
183                                                            \
184184   if (size==0)                                                               \
185185   {                                                                          \
186186      if (tilemapinfo&0x400)                                                 \
187187      {                                                                      \
188         SET_TILE_INFO_MEMBER(1,tileno>>1,pal>>4,TILE_FLIPYX(flip));               \
188         SET_TILE_INFO_MEMBER(1,tileno>>1,pal>>4,TILE_FLIPYX(flip));        \
189189      }                                                                      \
190190      else                                                                   \
191191      {                                                                      \
192         SET_TILE_INFO_MEMBER(0,tileno, pal,TILE_FLIPYX(flip));                    \
192         SET_TILE_INFO_MEMBER(0,tileno, pal,TILE_FLIPYX(flip));             \
193193      }                                                                      \
194194   }                                                                          \
195195   else                                                                       \
196196   {                                                                          \
197197      if (tilemapinfo&0x400)                                                 \
198198      {                                                                      \
199         SET_TILE_INFO_MEMBER(3,tileno>>3,pal>>4,TILE_FLIPYX(flip));               \
199         SET_TILE_INFO_MEMBER(3,tileno>>3,pal>>4,TILE_FLIPYX(flip));        \
200200      }                                                                      \
201201      else                                                                   \
202202      {                                                                      \
203         SET_TILE_INFO_MEMBER(2,tileno>>2, pal,TILE_FLIPYX(flip));                 \
203         SET_TILE_INFO_MEMBER(2,tileno>>2, pal,TILE_FLIPYX(flip));          \
204204      }                                                                      \
205205   }                                                                          \
206206}
207
207208TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile0_8x8_info)
208209{
209210   int offset = 0x00000;
r249156r249157
384385-------------------------------------------------*/
385386
386387#define HNG64_ROZ_PLOT_PIXEL(INPUT_VAL)                                                 \
387do {                                                                                \
388   if (blit->drawformat == HNG64_TILEMAP_NORMAL)                                   \
389      *(UINT32 *)dest = clut[INPUT_VAL];                                          \
390   else if (blit->drawformat == HNG64_TILEMAP_ADDITIVE)                            \
388do {                                                                                    \
389   if (blit->drawformat == HNG64_TILEMAP_NORMAL)                                       \
390      *(UINT32 *)dest = clut[INPUT_VAL];                                              \
391   else if (blit->drawformat == HNG64_TILEMAP_ADDITIVE)                                \
391392      *(UINT32 *)dest = alpha_additive_r32(*(UINT32 *)dest, clut[INPUT_VAL], alpha);  \
392   else if (blit->drawformat == HNG64_TILEMAP_ALPHA)                               \
393      *(UINT32 *)dest = alpha_blend_r32(*(UINT32 *)dest, clut[INPUT_VAL], alpha); \
393   else if (blit->drawformat == HNG64_TILEMAP_ALPHA)                                   \
394      *(UINT32 *)dest = alpha_blend_r32(*(UINT32 *)dest, clut[INPUT_VAL], alpha);     \
394395} while (0)
395396
396397void hng64_state::hng64_tilemap_draw_roz_core(screen_device &screen, tilemap_t *tmap, const blit_parameters *blit,
r249156r249157
11221123      // Blit the color buffer into the primary bitmap
11231124      for (y = cliprect.min_y; y <= cliprect.max_y; y++)
11241125      {
1125         UINT32 *src = &m_colorBuffer3d[y * cliprect.max_x];
1126         UINT32 *src = &m_poly_renderer->colorBuffer3d().pix32(y, cliprect.min_x);
11261127         UINT32 *dst = &bitmap.pix32(y, cliprect.min_x);
11271128
11281129         for (x = cliprect.min_x; x <= cliprect.max_x; x++)
r249156r249157
12341235
12351236void hng64_state::video_start()
12361237{
1237   const rectangle &visarea = m_screen->visible_area();
1238
12391238   m_old_animmask = -1;
12401239   m_old_animbits = -1;
12411240   m_old_tileflags[0] = -1;
r249156r249157
12691268   // Debug switch, turn on / off additive blending on a per-tilemap basis
12701269   m_additive_tilemap_debug = 0;
12711270
1272   // 3d Buffer Allocation
1273   m_depthBuffer3d = auto_alloc_array(machine(), float,  (visarea.max_x + 1)*(visarea.max_y + 1));
1274   m_colorBuffer3d = auto_alloc_array(machine(), UINT32, (visarea.max_x + 1)*(visarea.max_y + 1));
1271   // Rasterizer creation
1272    m_poly_renderer = auto_alloc(machine(), hng64_poly_renderer(*this));
12751273
1276
1274    // 3d information
12771275   m_dl = auto_alloc_array(machine(), UINT16, 0x200/2);
12781276   polys.resize(1024*5);
12791277
trunk/src/mame/video/hng64_3d.c
r249156r249157
11// license:LGPL-2.1+
22// copyright-holders:David Haywood, Angelo Salese, ElSemi, Andrew Gardner, Andrew Zaferakis
3/* Hyper NeoGeo 64 - 3D bits */
43
5// todo, use poly.c
6
74#include "includes/hng64.h"
85
6/////////////////////////////////
7/// Hyper NeoGeo 64 - 3D bits ///
8/////////////////////////////////
99
1010
11// Polygon rasterizer interface
12hng64_poly_renderer::hng64_poly_renderer(hng64_state& state)
13    : poly_manager<float, hng64_poly_data, 7, HNG64_MAX_POLYGONS>(state.machine())
14    , m_state(state)
15    , m_colorBuffer3d(state.m_screen->visible_area().width(), state.m_screen->visible_area().height())
16{
17    const INT32 bufferSize = state.m_screen->visible_area().width() * state.m_screen->visible_area().height();
18    m_depthBuffer3d = auto_alloc_array(state.machine(), float, bufferSize);
19}
20
21
22
1123// Hardware calls these '3d buffers'
1224//   They're only read during the startup check of fatfurwa.  Z-buffer memory?  Front buffer, back buffer?
1325//   They're definitely mirrored in the startup test, according to ElSemi
r249156r249157
5466   for(int packetStart=0;packetStart<0x200;packetStart+=32)
5567   {
5668      // Send it off to the 3d subsystem.
57      hng64_command3d( &m_dl[packetStart/2] );
69      hng64_command3d(&m_dl[packetStart/2]);
5870   }
5971
6072   machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(0x200*8), timer_expired_delegate(FUNC(hng64_state::hng64_3dfifo_processed),this));
6173g_profiler.stop();
6274}
6375
64TIMER_CALLBACK_MEMBER(hng64_state::hng64_3dfifo_processed )
76TIMER_CALLBACK_MEMBER(hng64_state::hng64_3dfifo_processed)
6577{
6678// ...
6779   m_set_irq(0x0008);
r249156r249157
584596               polys[*numPolys].vert[m].texCoords[3] = 1.0f;
585597
586598               polys[*numPolys].vert[m].normal[0] = uToF(chunkOffset[9  + (9*m)]);
587               polys[*numPolys].vert[m].normal[1] = uToF(chunkOffset[10 + (9*m)] );
588               polys[*numPolys].vert[m].normal[2] = uToF(chunkOffset[11 + (9*m)] );
599               polys[*numPolys].vert[m].normal[1] = uToF(chunkOffset[10 + (9*m)]);
600               polys[*numPolys].vert[m].normal[2] = uToF(chunkOffset[11 + (9*m)]);
589601               polys[*numPolys].vert[m].normal[3] = 0.0f;
590602            }
591603
r249156r249157
900912      if (packet[2] == 0x0003 && packet[3] == 0x8f37 && m_mcu_type == SHOOT_MCU)
901913         break;
902914
903      recoverPolygonBlock( packet, &numPolys);
915      recoverPolygonBlock(packet, &numPolys);
904916      break;
905917
906918   case 0x0102:    // Geometry with only translation
r249156r249157
920932      miniPacket[7] = 0x7fff;
921933      miniPacket[11] = 0x7fff;
922934      miniPacket[15] = 0x7fff;
923      recoverPolygonBlock( miniPacket, &numPolys);
935      recoverPolygonBlock(miniPacket, &numPolys);
924936
925937      memset(miniPacket, 0, sizeof(UINT16)*16);
926938      for (int i = 0; i < 7; i++) miniPacket[i] = packet[i+8];
r249156r249157
928940      miniPacket[7] = 0x7fff;
929941      miniPacket[11] = 0x7fff;
930942      miniPacket[15] = 0x7fff;
931      recoverPolygonBlock( miniPacket, &numPolys);
943      recoverPolygonBlock(miniPacket, &numPolys);
932944      break;
933945
934946   case 0x1000:    // Unknown: Some sort of global flags?
r249156r249157
949961   {
950962      if (polys[i].visible)
951963      {
952         drawShaded( &polys[i]);
964         m_poly_renderer->drawShaded(&polys[i]);
953965      }
954966   }
967    m_poly_renderer->wait();
955968}
956969
957970void hng64_state::clear3d()
r249156r249157
963976   // Reset the buffers...
964977   for (i = 0; i < (visarea.max_x)*(visarea.max_y); i++)
965978   {
966      m_depthBuffer3d[i] = 100.0f;
967      m_colorBuffer3d[i] = rgb_t(0, 0, 0, 0);
979        m_poly_renderer->depthBuffer3d()[i] = 100.0f;
968980   }
981   
982    // Clear the 3d rasterizer buffer
983    m_poly_renderer->colorBuffer3d().fill(0x00000000, m_screen->visible_area());   
969984
970985   // Set some matrices to the identity...
971986   setIdentity(m_projectionMatrix);
r249156r249157
9941009/////////////////////
9951010
9961011/* 4x4 matrix multiplication */
997void hng64_state::matmul4(float *product, const float *a, const float *b )
1012void hng64_state::matmul4(float *product, const float *a, const float *b)
9981013{
9991014   int i;
10001015   for (i = 0; i < 4; i++)
r249156r249157
10721087// POLYGON CLIPPING CODE //
10731088///////////////////////////
10741089
1075///////////////////////////////////////////////////////////////////////////////////
1076// The remainder of the code in this file is heavily                             //
1077//   influenced by, and sometimes copied verbatim from Andrew Zaferakis' SoftGL  //
1078//   rasterizing system.                                                         //
1079//                                                                               //
1080//   Andrew granted permission for its use in MAME in October of 2004.           //
1081///////////////////////////////////////////////////////////////////////////////////
1082
1083
1084
10851090int hng64_state::Inside(struct polyVert *v, int plane)
10861091{
10871092   switch(plane)
r249156r249157
11581163   Ol[2] = Il0[2] + (Il1[2] - Il0[2]) * t;
11591164}
11601165
1166//////////////////////////////////////////////////////////////////////////
1167// Clip against the volumes defined by the homogeneous clip coordinates //
1168//////////////////////////////////////////////////////////////////////////
1169
11611170void hng64_state::performFrustumClip(struct polygon *p)
11621171{
1163   int i, j, k;
1164   //////////////////////////////////////////////////////////////////////////
1165   // Clip against the volumes defined by the homogeneous clip coordinates //
1166   //////////////////////////////////////////////////////////////////////////
1172    polyVert *v0;
1173   polyVert *v1;
1174   polyVert *tv;
11671175
1168   struct polygon temp;
1169
1170   struct polyVert *v0;
1171   struct polyVert *v1;
1172   struct polyVert *tv;
1173
1176    polygon temp;
11741177   temp.n = 0;
11751178
11761179   // Skip near and far clipping planes ?
1177   for (j = 0; j <= HNG64_BOTTOM; j++)
1180   for (int j = 0; j <= HNG64_BOTTOM; j++)
11781181   {
1179      for (i = 0; i < p->n; i++)
1182      for (int i = 0; i < p->n; i++)
11801183      {
1181         k = (i+1) % p->n; // Index of next vertex
1184         int k = (i+1) % p->n; // Index of next vertex
11821185
11831186         v0 = &p->vert[i];
11841187         v1 = &p->vert[k];
r249156r249157
11901193            memcpy(tv, v1, sizeof(struct polyVert));
11911194            temp.n++;
11921195         }
1193
11941196         else if (Inside(v0, j) && !Inside(v1, j))                   // Edge goes from in to out...
11951197         {
11961198            Intersect(v0, v1, tv, j);
11971199            temp.n++;
11981200         }
1199
12001201         else if (!Inside(v0, j) && Inside(v1, j))                   // Edge goes from out to in...
12011202         {
12021203            Intersect(v0, v1, tv, j);
r249156r249157
12071208
12081209      p->n = temp.n;
12091210
1210      for (i = 0; i < temp.n; i++)
1211      for (int i = 0; i < temp.n; i++)
12111212      {
12121213         memcpy(&p->vert[i], &temp.vert[i], sizeof(struct polyVert));
12131214      }
r249156r249157
12161217   }
12171218}
12181219
1219
1220
1221/*********************************************************************/
1222/**   FillSmoothTexPCHorizontalLine                                 **/
1223/**     Input: Color Buffer (framebuffer), depth buffer, width and  **/
1224/**            height of framebuffer, starting, and ending values   **/
1225/**            for x and y, constant y.  Fills horizontally with    **/
1226/**            z,r,g,b interpolation.                               **/
1227/**                                                                 **/
1228/**     Output: none                                                **/
1229/*********************************************************************/
1230inline void hng64_state::FillSmoothTexPCHorizontalLine(
1231                                 const polygonRasterOptions& prOptions,
1232                                 int x_start, int x_end, int y, float z_start, float z_delta,
1233                                 float w_start, float w_delta, float r_start, float r_delta,
1234                                 float g_start, float g_delta, float b_start, float b_delta,
1235                                 float s_start, float s_delta, float t_start, float t_delta)
1220void hng64_poly_renderer::render_scanline(INT32 scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid)
12361221{
1237   float*  db = &(m_depthBuffer3d[(y * m_screen->visible_area().max_x) + x_start]);
1238   UINT32* cb = &(m_colorBuffer3d[(y * m_screen->visible_area().max_x) + x_start]);
1222    // Pull the parameters out of the extent structure
1223    float z = extent.param[0].start;
1224    float w = extent.param[1].start;
1225   float lightR = extent.param[2].start;
1226   float lightG = extent.param[3].start;
1227   float lightB = extent.param[4].start;
1228   float s = extent.param[5].start;
1229    float t = extent.param[6].start;
1230   
1231    const float dz = extent.param[0].dpdx;
1232    const float dw = extent.param[1].dpdx;
1233   const float dlightR = extent.param[2].dpdx;
1234   const float dlightG = extent.param[3].dpdx;
1235   const float dlightB = extent.param[4].dpdx;
1236   const float ds = extent.param[5].dpdx;
1237    const float dt = extent.param[6].dpdx;
1238   
1239    // Pointers to the pixel buffers
1240    UINT32* colorBuffer = &m_colorBuffer3d.pix32(scanline, extent.startx);
1241    float*  depthBuffer = &m_depthBuffer3d[(scanline * m_state.m_screen->visible_area().width()) + extent.startx];
12391242
1240   UINT8 paletteEntry = 0;
1241   float t_coord, s_coord;
1242   const UINT8 *gfx = m_texturerom;
1243   const UINT8 *textureOffset = &gfx[prOptions.texIndex * 1024 * 1024];
1243    const UINT8 *textureOffset = &m_state.m_texturerom[renderData.texIndex * 1024 * 1024];
1244   
1245    // Step over each pixel in the horizontal span
1246    for(int x = extent.startx; x < extent.stopx; x++)
1247    {
1248        if (z < *depthBuffer)
1249        {
1250            // Translucency currently isn't an issue, so soldier on
1251            *depthBuffer = z;
12441252
1245   for (; x_start <= x_end; x_start++)
1246   {
1247      if (z_start < (*db))
1248      {
1249         // MULTIPLY BACK THROUGH BY W
1250         t_coord = t_start / w_start;
1251         s_coord = s_start / w_start;
1252
1253         if ((prOptions.debugColor & 0xff000000) == 0x01000000)
1253            // Multiply back through by w for everything that was interpolated perspective-correctly
1254            const float sCorrect = s / w;
1255            const float tCorrect = t / w;
1256            const float rCorrect = lightR / w;
1257            const float gCorrect = lightG / w;
1258            const float bCorrect = lightB / w;
1259           
1260            if ((renderData.debugColor & 0xff000000) == 0x01000000)
12541261         {
1255            // UV COLOR MODE
1256            *cb = rgb_t(255, (UINT8)(s_coord*255.0f), (UINT8)(t_coord*255.0f), (UINT8)(0));
1257            *db = z_start;
1262            // ST color mode
1263            *colorBuffer = rgb_t(255, (UINT8)(sCorrect*255.0f), (UINT8)(tCorrect*255.0f), (UINT8)(0));
12581264         }
1259         else if ((prOptions.debugColor & 0xff000000) == 0x02000000)
1265         else if ((renderData.debugColor & 0xff000000) == 0x02000000)
12601266         {
1261            // Lit
1262            *cb = rgb_t(255, (UINT8)(r_start/w_start), (UINT8)(g_start/w_start), (UINT8)(b_start/w_start));
1263            *db = z_start;
1267            // Lighting only
1268            *colorBuffer = rgb_t(255, (UINT8)rCorrect, (UINT8)gCorrect, (UINT8)bCorrect);
12641269         }
1265         else if ((prOptions.debugColor & 0xff000000) == 0xff000000)
1270         else if ((renderData.debugColor & 0xff000000) == 0xff000000)
12661271         {
1267            // DEBUG COLOR MODE
1268            *cb = prOptions.debugColor;
1269            *db = z_start;
1272            // Debug color mode
1273            *colorBuffer = renderData.debugColor;
12701274         }
12711275         else
12721276         {
r249156r249157
12741278            float textureT = 0.0f;
12751279
12761280            // Standard & Half-Res textures
1277            if (prOptions.texType == 0x0)
1281            if (renderData.texType == 0x0)
12781282            {
1279               textureS = s_coord * 1024.0f;
1280               textureT = t_coord * 1024.0f;
1283               textureS = sCorrect * 1024.0f;
1284               textureT = tCorrect * 1024.0f;
12811285            }
1282            else if (prOptions.texType == 0x1)
1286            else if (renderData.texType == 0x1)
12831287            {
1284               textureS = s_coord * 512.0f;
1285               textureT = t_coord * 512.0f;
1288               textureS = sCorrect * 512.0f;
1289               textureT = tCorrect * 512.0f;
12861290            }
12871291
1288            // stuff in mode 1 here already looks good?
12891292            // Small-Page textures
1290            if (prOptions.texPageSmall == 2)
1293            if (renderData.texPageSmall == 2)
12911294            {
12921295               textureT = fmod(textureT, 256.0f);
12931296               textureS = fmod(textureS, 256.0f);
12941297
1295               textureT += (256.0f * (prOptions.texPageHorizOffset>>1));
1296               textureS += (256.0f * (prOptions.texPageVertOffset>>1));
1298               textureT += (256.0f * (renderData.texPageHorizOffset>>1));
1299               textureS += (256.0f * (renderData.texPageVertOffset>>1));
12971300            }
1298            else if (prOptions.texPageSmall == 3)
1301            else if (renderData.texPageSmall == 3)
12991302            {
13001303               textureT = fmod(textureT, 128.0f);
13011304               textureS = fmod(textureS, 128.0f);
13021305
1303               textureT += (128.0f * (prOptions.texPageHorizOffset>>0));
1304               textureS += (128.0f * (prOptions.texPageVertOffset>>0));
1306               textureT += (128.0f * (renderData.texPageHorizOffset>>0));
1307               textureS += (128.0f * (renderData.texPageVertOffset>>0));
13051308            }
13061309
1307            paletteEntry = textureOffset[((int)textureS)*1024 + (int)textureT];
1310            UINT8 paletteEntry = textureOffset[((int)textureS)*1024 + (int)textureT];
13081311
1309            // Naieve Alpha Implementation (?) - don't draw if you're at texture index 0...
1312            // Naive Alpha Implementation (?) - don't draw if you're at texture index 0...
13101313            if (paletteEntry != 0)
13111314            {
13121315               // The color out of the texture
1313               paletteEntry %= prOptions.palPageSize;
1314               rgb_t color = m_palette->pen(prOptions.palOffset + paletteEntry);
1316               paletteEntry %= renderData.palPageSize;
1317               rgb_t color = m_state.m_palette->pen(renderData.palOffset + paletteEntry);
13151318
13161319               // Apply the lighting
1317               float rIntensity = (r_start/w_start) / 255.0f;
1318               float gIntensity = (g_start/w_start) / 255.0f;
1319               float bIntensity = (b_start/w_start) / 255.0f;
1320               float red   = color.r()   * rIntensity;
1320               float rIntensity = rCorrect / 255.0f;
1321               float gIntensity = gCorrect / 255.0f;
1322               float bIntensity = bCorrect / 255.0f;
1323               float red   = color.r() * rIntensity;
13211324               float green = color.g() * gIntensity;
1322               float blue  = color.b() * bIntensity;
1325               float blue  = color.b() * bIntensity;
13231326
13241327               // Clamp and finalize
13251328               red = color.r() + red;
r249156r249157
13321335
13331336               color = rgb_t(255, (UINT8)red, (UINT8)green, (UINT8)blue);
13341337
1335               *cb = color;
1336               *db = z_start;
1338               *colorBuffer = color;
13371339            }
13381340         }
1339      }
1340      db++;
1341      cb++;
1342      z_start += z_delta;
1343      w_start += w_delta;
1344      r_start += r_delta;
1345      g_start += g_delta;
1346      b_start += b_delta;
1347      s_start += s_delta;
1348      t_start += t_delta;
1349   }
1350}
1341        }
13511342
1352//----------------------------------------------------------------------------
1353// Given 3D triangle ABC in screen space with clipped coordinates within the following
1354// bounds: x in [0,W], y in [0,H], z in [0,1]. The origin for (x,y) is in the bottom
1355// left corner of the pixel grid. z=0 is the near plane and z=1 is the far plane,
1356// so lesser values are closer. The coordinates of the pixels are evenly spaced
1357// in x and y 1 units apart starting at the bottom-left pixel with coords
1358// (0.5,0.5). In other words, the pixel sample point is in the center of the
1359// rectangular grid cell containing the pixel sample. The framebuffer has
1360// dimensions width x height (WxH). The Color buffer is a 1D array (row-major
1361// order) with 3 unsigned chars per pixel (24-bit color). The Depth buffer is
1362// a 1D array (also row-major order) with a float value per pixel
1363// For a pixel location (x,y) we can obtain
1364// the Color and Depth array locations as: Color[(((int)y)*W+((int)x))*3]
1365// (for the red value, green is offset +1, and blue is offset +2 and
1366// Depth[((int)y)*W+((int)x)]. Fills the pixels contained in the triangle
1367// with the global current color and the properly linearly interpolated depth
1368// value (performs Z-buffer depth test before writing new pixel).
1369// Pixel samples that lie inside the triangle edges are filled with
1370// a bias towards the minimum values (samples that lie exactly on a triangle
1371// edge are filled only for minimum x values along a horizontal span and for
1372// minimum y values, samples lying on max values are not filled).
1373// Per-vertex colors are RGB floating point triplets in [0.0,255.0]. The vertices
1374// include their w-components for use in linearly interpolating perspectively
1375// correct color (RGB) and texture-coords (st) across the face of the triangle.
1376// A texture image of RGB floating point triplets of size TWxWH is also given.
1377// Texture colors are normalized RGB values in [0,1].
1378//   clamp and repeat wrapping modes : Wrapping={0,1}
1379//   nearest and bilinear filtering: Filtering={0,1}
1380//   replace and modulate application modes: Function={0,1}
1381//---------------------------------------------------------------------------
1382void hng64_state::RasterizeTriangle_SMOOTH_TEX_PC(
1383                                 float A[4], float B[4], float C[4],
1384                                 float Ca[3], float Cb[3], float Cc[3], // PER-VERTEX RGB COLORS
1385                                 float Ta[2], float Tb[2], float Tc[2], // PER-VERTEX (S,T) TEX-COORDS
1386                                 const polygonRasterOptions& prOptions)
1387{
1388   // Get our order of points by increasing y-coord
1389   float *p_min = ((A[1] <= B[1]) && (A[1] <= C[1])) ? A : ((B[1] <= A[1]) && (B[1] <= C[1])) ? B : C;
1390   float *p_max = ((A[1] >= B[1]) && (A[1] >= C[1])) ? A : ((B[1] >= A[1]) && (B[1] >= C[1])) ? B : C;
1391   float *p_mid = ((A != p_min) && (A != p_max)) ? A : ((B != p_min) && (B != p_max)) ? B : C;
1392
1393   // Perspectively correct color interpolation, interpolate r/w, g/w, b/w, then divide by 1/w at each pixel (A[3] = 1/w)
1394   float ca[3], cb[3], cc[3];
1395   float ta[2], tb[2], tc[2];
1396
1397   float *c_min;
1398   float *c_mid;
1399   float *c_max;
1400
1401   // We must keep the tex coords straight with the point ordering
1402   float *t_min;
1403   float *t_mid;
1404   float *t_max;
1405
1406   // Find out control points for y, this divides the triangle into upper and lower
1407   int   y_min;
1408   int   y_max;
1409   int   y_mid;
1410
1411   // Compute the slopes of each line, and color this is used to determine the interpolation
1412   float x1_slope;
1413   float x2_slope;
1414   float z1_slope;
1415   float z2_slope;
1416   float w1_slope;
1417   float w2_slope;
1418   float r1_slope;
1419   float r2_slope;
1420   float g1_slope;
1421   float g2_slope;
1422   float b1_slope;
1423   float b2_slope;
1424   float s1_slope;
1425   float s2_slope;
1426   float t1_slope;
1427   float t2_slope;
1428
1429   // Compute the t values used in the equation Ax = Ax + (Bx - Ax)*t
1430   // We only need one t, because it is only used to compute the start.
1431   // Create storage for the interpolated x and z values for both lines
1432   // also for the RGB interpolation
1433   float t;
1434   float x1_interp;
1435   float z1_interp;
1436   float w1_interp;
1437   float r1_interp;
1438   float g1_interp;
1439   float b1_interp;
1440   float s1_interp;
1441   float t1_interp;
1442
1443   float x2_interp;
1444   float z2_interp;
1445   float w2_interp;
1446   float r2_interp;
1447   float g2_interp;
1448   float b2_interp;
1449   float s2_interp;
1450   float t2_interp;
1451
1452   // Create storage for the horizontal interpolation of z and RGB color and its starting points
1453   // This is used to fill the triangle horizontally
1454   int   x_start,     x_end;
1455   float z_interp_x,  z_delta_x;
1456   float w_interp_x,  w_delta_x;
1457   float r_interp_x,  r_delta_x;
1458   float g_interp_x,  g_delta_x;
1459   float b_interp_x,  b_delta_x;
1460   float s_interp_x,  s_delta_x;
1461   float t_interp_x,  t_delta_x;
1462
1463   ca[0] = Ca[0]; ca[1] = Ca[1]; ca[2] = Ca[2];
1464   cb[0] = Cb[0]; cb[1] = Cb[1]; cb[2] = Cb[2];
1465   cc[0] = Cc[0]; cc[1] = Cc[1]; cc[2] = Cc[2];
1466
1467   // Perspectively correct tex interpolation, interpolate s/w, t/w, then divide by 1/w at each pixel (A[3] = 1/w)
1468   ta[0] = Ta[0]; ta[1] = Ta[1];
1469   tb[0] = Tb[0]; tb[1] = Tb[1];
1470   tc[0] = Tc[0]; tc[1] = Tc[1];
1471
1472   // We must keep the colors straight with the point ordering
1473   c_min = (p_min == A) ? ca : (p_min == B) ? cb : cc;
1474   c_mid = (p_mid == A) ? ca : (p_mid == B) ? cb : cc;
1475   c_max = (p_max == A) ? ca : (p_max == B) ? cb : cc;
1476
1477   // We must keep the tex coords straight with the point ordering
1478   t_min = (p_min == A) ? ta : (p_min == B) ? tb : tc;
1479   t_mid = (p_mid == A) ? ta : (p_mid == B) ? tb : tc;
1480   t_max = (p_max == A) ? ta : (p_max == B) ? tb : tc;
1481
1482   // Find out control points for y, this divides the triangle into upper and lower
1483   y_min  = (((int)p_min[1]) + 0.5 >= p_min[1]) ? (int)p_min[1] : ((int)p_min[1]) + 1;
1484   y_max  = (((int)p_max[1]) + 0.5 <  p_max[1]) ? (int)p_max[1] : ((int)p_max[1]) - 1;
1485   y_mid  = (((int)p_mid[1]) + 0.5 >= p_mid[1]) ? (int)p_mid[1] : ((int)p_mid[1]) + 1;
1486
1487   // Compute the slopes of each line, and color this is used to determine the interpolation
1488   x1_slope = (p_max[0] - p_min[0]) / (p_max[1] - p_min[1]);
1489   x2_slope = (p_mid[0] - p_min[0]) / (p_mid[1] - p_min[1]);
1490   z1_slope = (p_max[2] - p_min[2]) / (p_max[1] - p_min[1]);
1491   z2_slope = (p_mid[2] - p_min[2]) / (p_mid[1] - p_min[1]);
1492   w1_slope = (p_max[3] - p_min[3]) / (p_max[1] - p_min[1]);
1493   w2_slope = (p_mid[3] - p_min[3]) / (p_mid[1] - p_min[1]);
1494   r1_slope = (c_max[0] - c_min[0]) / (p_max[1] - p_min[1]);
1495   r2_slope = (c_mid[0] - c_min[0]) / (p_mid[1] - p_min[1]);
1496   g1_slope = (c_max[1] - c_min[1]) / (p_max[1] - p_min[1]);
1497   g2_slope = (c_mid[1] - c_min[1]) / (p_mid[1] - p_min[1]);
1498   b1_slope = (c_max[2] - c_min[2]) / (p_max[1] - p_min[1]);
1499   b2_slope = (c_mid[2] - c_min[2]) / (p_mid[1] - p_min[1]);
1500   s1_slope = (t_max[0] - t_min[0]) / (p_max[1] - p_min[1]);
1501   s2_slope = (t_mid[0] - t_min[0]) / (p_mid[1] - p_min[1]);
1502   t1_slope = (t_max[1] - t_min[1]) / (p_max[1] - p_min[1]);
1503   t2_slope = (t_mid[1] - t_min[1]) / (p_mid[1] - p_min[1]);
1504
1505   // Compute the t values used in the equation Ax = Ax + (Bx - Ax)*t
1506   // We only need one t, because it is only used to compute the start.
1507   // Create storage for the interpolated x and z values for both lines
1508   // also for the RGB interpolation
1509   t = (((float)y_min) + 0.5 - p_min[1]) / (p_max[1] - p_min[1]);
1510   x1_interp = p_min[0] + (p_max[0] - p_min[0]) * t;
1511   z1_interp = p_min[2] + (p_max[2] - p_min[2]) * t;
1512   w1_interp = p_min[3] + (p_max[3] - p_min[3]) * t;
1513   r1_interp = c_min[0] + (c_max[0] - c_min[0]) * t;
1514   g1_interp = c_min[1] + (c_max[1] - c_min[1]) * t;
1515   b1_interp = c_min[2] + (c_max[2] - c_min[2]) * t;
1516   s1_interp = t_min[0] + (t_max[0] - t_min[0]) * t;
1517   t1_interp = t_min[1] + (t_max[1] - t_min[1]) * t;
1518
1519   t = (((float)y_min) + 0.5 - p_min[1]) / (p_mid[1] - p_min[1]);
1520   x2_interp = p_min[0] + (p_mid[0] - p_min[0]) * t;
1521   z2_interp = p_min[2] + (p_mid[2] - p_min[2]) * t;
1522   w2_interp = p_min[3] + (p_mid[3] - p_min[3]) * t;
1523   r2_interp = c_min[0] + (c_mid[0] - c_min[0]) * t;
1524   g2_interp = c_min[1] + (c_mid[1] - c_min[1]) * t;
1525   b2_interp = c_min[2] + (c_mid[2] - c_min[2]) * t;
1526   s2_interp = t_min[0] + (t_mid[0] - t_min[0]) * t;
1527   t2_interp = t_min[1] + (t_mid[1] - t_min[1]) * t;
1528
1529   // First work on the bottom half of the triangle
1530   // I'm using y_min as the incrementer because it saves space and we don't need it anymore
1531   for (; y_min < y_mid; y_min++) {
1532      // We always want to fill left to right, so we have 2 main cases
1533      // Compute the integer starting and ending points and the appropriate z by
1534      // interpolating.  Remember the pixels are in the middle of the grid, i.e. (0.5,0.5,0.5)
1535      if (x1_interp < x2_interp) {
1536         x_start    = ((((int)x1_interp) + 0.5) >= x1_interp) ? (int)x1_interp : ((int)x1_interp) + 1;
1537         x_end      = ((((int)x2_interp) + 0.5) <  x2_interp) ? (int)x2_interp : ((int)x2_interp) - 1;
1538         z_delta_x  = (z2_interp - z1_interp) / (x2_interp - x1_interp);
1539         w_delta_x  = (w2_interp - w1_interp) / (x2_interp - x1_interp);
1540         r_delta_x  = (r2_interp - r1_interp) / (x2_interp - x1_interp);
1541         g_delta_x  = (g2_interp - g1_interp) / (x2_interp - x1_interp);
1542         b_delta_x  = (b2_interp - b1_interp) / (x2_interp - x1_interp);
1543         s_delta_x  = (s2_interp - s1_interp) / (x2_interp - x1_interp);
1544         t_delta_x  = (t2_interp - t1_interp) / (x2_interp - x1_interp);
1545         t          = (x_start + 0.5 - x1_interp) / (x2_interp - x1_interp);
1546         z_interp_x = z1_interp + (z2_interp - z1_interp) * t;
1547         w_interp_x = w1_interp + (w2_interp - w1_interp) * t;
1548         r_interp_x = r1_interp + (r2_interp - r1_interp) * t;
1549         g_interp_x = g1_interp + (g2_interp - g1_interp) * t;
1550         b_interp_x = b1_interp + (b2_interp - b1_interp) * t;
1551         s_interp_x = s1_interp + (s2_interp - s1_interp) * t;
1552         t_interp_x = t1_interp + (t2_interp - t1_interp) * t;
1553
1554      } else {
1555         x_start    = ((((int)x2_interp) + 0.5) >= x2_interp) ? (int)x2_interp : ((int)x2_interp) + 1;
1556         x_end      = ((((int)x1_interp) + 0.5) <  x1_interp) ? (int)x1_interp : ((int)x1_interp) - 1;
1557         z_delta_x  = (z1_interp - z2_interp) / (x1_interp - x2_interp);
1558         w_delta_x  = (w1_interp - w2_interp) / (x1_interp - x2_interp);
1559         r_delta_x  = (r1_interp - r2_interp) / (x1_interp - x2_interp);
1560         g_delta_x  = (g1_interp - g2_interp) / (x1_interp - x2_interp);
1561         b_delta_x  = (b1_interp - b2_interp) / (x1_interp - x2_interp);
1562         s_delta_x  = (s1_interp - s2_interp) / (x1_interp - x2_interp);
1563         t_delta_x  = (t1_interp - t2_interp) / (x1_interp - x2_interp);
1564         t          = (x_start + 0.5 - x2_interp) / (x1_interp - x2_interp);
1565         z_interp_x = z2_interp + (z1_interp - z2_interp) * t;
1566         w_interp_x = w2_interp + (w1_interp - w2_interp) * t;
1567         r_interp_x = r2_interp + (r1_interp - r2_interp) * t;
1568         g_interp_x = g2_interp + (g1_interp - g2_interp) * t;
1569         b_interp_x = b2_interp + (b1_interp - b2_interp) * t;
1570         s_interp_x = s2_interp + (s1_interp - s2_interp) * t;
1571         t_interp_x = t2_interp + (t1_interp - t2_interp) * t;
1572      }
1573
1574      // Pass the horizontal line to the filler, this could be put in the routine
1575      // then interpolate for the next values of x and z
1576      FillSmoothTexPCHorizontalLine( prOptions,
1577         x_start, x_end, y_min, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
1578         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
1579         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
1580      x1_interp += x1_slope;   z1_interp += z1_slope;
1581      x2_interp += x2_slope;   z2_interp += z2_slope;
1582      r1_interp += r1_slope;   r2_interp += r2_slope;
1583      g1_interp += g1_slope;   g2_interp += g2_slope;
1584      b1_interp += b1_slope;   b2_interp += b2_slope;
1585      w1_interp += w1_slope;   w2_interp += w2_slope;
1586      s1_interp += s1_slope;   s2_interp += s2_slope;
1587      t1_interp += t1_slope;   t2_interp += t2_slope;
1588   }
1589
1590   // Now do the same thing for the top half of the triangle.
1591   // We only need to recompute the x2 line because it changes at the midpoint
1592   x2_slope = (p_max[0] - p_mid[0]) / (p_max[1] - p_mid[1]);
1593   z2_slope = (p_max[2] - p_mid[2]) / (p_max[1] - p_mid[1]);
1594   w2_slope = (p_max[3] - p_mid[3]) / (p_max[1] - p_mid[1]);
1595   r2_slope = (c_max[0] - c_mid[0]) / (p_max[1] - p_mid[1]);
1596   g2_slope = (c_max[1] - c_mid[1]) / (p_max[1] - p_mid[1]);
1597   b2_slope = (c_max[2] - c_mid[2]) / (p_max[1] - p_mid[1]);
1598   s2_slope = (t_max[0] - t_mid[0]) / (p_max[1] - p_mid[1]);
1599   t2_slope = (t_max[1] - t_mid[1]) / (p_max[1] - p_mid[1]);
1600
1601   t = (((float)y_mid) + 0.5 - p_mid[1]) / (p_max[1] - p_mid[1]);
1602   x2_interp = p_mid[0] + (p_max[0] - p_mid[0]) * t;
1603   z2_interp = p_mid[2] + (p_max[2] - p_mid[2]) * t;
1604   w2_interp = p_mid[3] + (p_max[3] - p_mid[3]) * t;
1605   r2_interp = c_mid[0] + (c_max[0] - c_mid[0]) * t;
1606   g2_interp = c_mid[1] + (c_max[1] - c_mid[1]) * t;
1607   b2_interp = c_mid[2] + (c_max[2] - c_mid[2]) * t;
1608   s2_interp = t_mid[0] + (t_max[0] - t_mid[0]) * t;
1609   t2_interp = t_mid[1] + (t_max[1] - t_mid[1]) * t;
1610
1611   // We've seen this loop before haven't we?
1612   // I'm using y_mid as the incrementer because it saves space and we don't need it anymore
1613   for (; y_mid <= y_max; y_mid++) {
1614      if (x1_interp < x2_interp) {
1615         x_start    = ((((int)x1_interp) + 0.5) >= x1_interp) ? (int)x1_interp : ((int)x1_interp) + 1;
1616         x_end      = ((((int)x2_interp) + 0.5) <  x2_interp) ? (int)x2_interp : ((int)x2_interp) - 1;
1617         z_delta_x  = (z2_interp - z1_interp) / (x2_interp - x1_interp);
1618         w_delta_x  = (w2_interp - w1_interp) / (x2_interp - x1_interp);
1619         r_delta_x  = (r2_interp - r1_interp) / (x2_interp - x1_interp);
1620         g_delta_x  = (g2_interp - g1_interp) / (x2_interp - x1_interp);
1621         b_delta_x  = (b2_interp - b1_interp) / (x2_interp - x1_interp);
1622         s_delta_x  = (s2_interp - s1_interp) / (x2_interp - x1_interp);
1623         t_delta_x  = (t2_interp - t1_interp) / (x2_interp - x1_interp);
1624         t          = (x_start + 0.5 - x1_interp) / (x2_interp - x1_interp);
1625         z_interp_x = z1_interp + (z2_interp - z1_interp) * t;
1626         w_interp_x = w1_interp + (w2_interp - w1_interp) * t;
1627         r_interp_x = r1_interp + (r2_interp - r1_interp) * t;
1628         g_interp_x = g1_interp + (g2_interp - g1_interp) * t;
1629         b_interp_x = b1_interp + (b2_interp - b1_interp) * t;
1630         s_interp_x = s1_interp + (s2_interp - s1_interp) * t;
1631         t_interp_x = t1_interp + (t2_interp - t1_interp) * t;
1632
1633      } else {
1634         x_start    = ((((int)x2_interp) + 0.5) >= x2_interp) ? (int)x2_interp : ((int)x2_interp) + 1;
1635         x_end      = ((((int)x1_interp) + 0.5) <  x1_interp) ? (int)x1_interp : ((int)x1_interp) - 1;
1636         z_delta_x  = (z1_interp - z2_interp) / (x1_interp - x2_interp);
1637         w_delta_x  = (w1_interp - w2_interp) / (x1_interp - x2_interp);
1638         r_delta_x  = (r1_interp - r2_interp) / (x1_interp - x2_interp);
1639         g_delta_x  = (g1_interp - g2_interp) / (x1_interp - x2_interp);
1640         b_delta_x  = (b1_interp - b2_interp) / (x1_interp - x2_interp);
1641         s_delta_x  = (s1_interp - s2_interp) / (x1_interp - x2_interp);
1642         t_delta_x  = (t1_interp - t2_interp) / (x1_interp - x2_interp);
1643         t          = (x_start + 0.5 - x2_interp) / (x1_interp - x2_interp);
1644         z_interp_x = z2_interp + (z1_interp - z2_interp) * t;
1645         w_interp_x = w2_interp + (w1_interp - w2_interp) * t;
1646         r_interp_x = r2_interp + (r1_interp - r2_interp) * t;
1647         g_interp_x = g2_interp + (g1_interp - g2_interp) * t;
1648         b_interp_x = b2_interp + (b1_interp - b2_interp) * t;
1649         s_interp_x = s2_interp + (s1_interp - s2_interp) * t;
1650         t_interp_x = t2_interp + (t1_interp - t2_interp) * t;
1651      }
1652
1653      // Pass the horizontal line to the filler, this could be put in the routine
1654      // then interpolate for the next values of x and z
1655      FillSmoothTexPCHorizontalLine( prOptions,
1656         x_start, x_end, y_mid, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
1657         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
1658         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
1659      x1_interp += x1_slope;   z1_interp += z1_slope;
1660      x2_interp += x2_slope;   z2_interp += z2_slope;
1661      r1_interp += r1_slope;   r2_interp += r2_slope;
1662      g1_interp += g1_slope;   g2_interp += g2_slope;
1663      b1_interp += b1_slope;   b2_interp += b2_slope;
1664      w1_interp += w1_slope;   w2_interp += w2_slope;
1665      s1_interp += s1_slope;   s2_interp += s2_slope;
1666      t1_interp += t1_slope;   t2_interp += t2_slope;
1667   }
1343        z += dz;
1344        w += dw;
1345        lightR += dlightR;
1346      lightG += dlightG;
1347      lightB += dlightB;
1348      s += ds;
1349        t += dt;
1350       
1351        colorBuffer++;
1352        depthBuffer++;
1353    }
16681354}
16691355
1670void hng64_state::drawShaded( struct polygon *p)
1356void hng64_poly_renderer::drawShaded(struct polygon *p)
16711357{
1358    // Polygon information for the rasterizer
1359    hng64_poly_data rOptions;
1360    rOptions.texType = p->texType;
1361   rOptions.texIndex = p->texIndex;
1362   rOptions.palOffset = p->palOffset;
1363   rOptions.palPageSize = p->palPageSize;
1364   rOptions.debugColor = p->debugColor;
1365   rOptions.texPageSmall = p->texPageSmall;
1366   rOptions.texPageHorizOffset = p->texPageHorizOffset;
1367   rOptions.texPageVertOffset = p->texPageVertOffset;
1368   
16721369   // The perspective-correct texture divide...
1673   // !!! There is a very good chance the HNG64 hardware does not do perspective-correct texture-mapping !!!
1674   int j;
1675   for (j = 0; j < p->n; j++)
1370   // NOTE: There is a very good chance the HNG64 hardware does not do perspective-correct texture-mapping - explore
1371   for (int j = 0; j < p->n; j++)
16761372   {
16771373      p->vert[j].clipCoords[3] = 1.0f / p->vert[j].clipCoords[3];
16781374      p->vert[j].light[0]      = p->vert[j].light[0]     * p->vert[j].clipCoords[3];
r249156r249157
16821378      p->vert[j].texCoords[1]  = p->vert[j].texCoords[1] * p->vert[j].clipCoords[3];
16831379   }
16841380
1685   // Set up the struct that will pass the polygon's options around.
1686   polygonRasterOptions prOptions;
1687   prOptions.texType = p->texType;
1688   prOptions.texIndex = p->texIndex;
1689   prOptions.palOffset = p->palOffset;
1690   prOptions.palPageSize = p->palPageSize;
1691   prOptions.debugColor = p->debugColor;
1692   prOptions.texPageSmall = p->texPageSmall;
1693   prOptions.texPageHorizOffset = p->texPageHorizOffset;
1694   prOptions.texPageVertOffset = p->texPageVertOffset;
1695
1696   for (j = 1; j < p->n-1; j++)
1381    // Rasterize the triangles
1382   for (int j = 1; j < p->n-1; j++)
16971383   {
1698      RasterizeTriangle_SMOOTH_TEX_PC(
1699                              p->vert[0].clipCoords, p->vert[j].clipCoords, p->vert[j+1].clipCoords,
1700                              p->vert[0].light,      p->vert[j].light,      p->vert[j+1].light,
1701                              p->vert[0].texCoords,  p->vert[j].texCoords,  p->vert[j+1].texCoords,
1702                              prOptions);
1384        // Build some MAME rasterizer vertices from the hng64 vertices
1385        vertex_t pVert[3];
1386
1387        const polyVert& pv0 = p->vert[0];
1388        pVert[0].x = pv0.clipCoords[0];
1389        pVert[0].y = pv0.clipCoords[1];
1390        pVert[0].p[0] = pv0.clipCoords[2];
1391        pVert[0].p[1] = pv0.clipCoords[3];
1392        pVert[0].p[2] = pv0.light[0];
1393        pVert[0].p[3] = pv0.light[1];
1394        pVert[0].p[4] = pv0.light[2];
1395        pVert[0].p[5] = pv0.texCoords[0];
1396        pVert[0].p[6] = pv0.texCoords[1];
1397       
1398        const polyVert& pvj = p->vert[j];
1399        pVert[1].x = pvj.clipCoords[0];
1400        pVert[1].y = pvj.clipCoords[1];
1401        pVert[1].p[0] = pvj.clipCoords[2];
1402        pVert[1].p[1] = pvj.clipCoords[3];
1403        pVert[1].p[2] = pvj.light[0];
1404        pVert[1].p[3] = pvj.light[1];
1405        pVert[1].p[4] = pvj.light[2];
1406        pVert[1].p[5] = pvj.texCoords[0];
1407        pVert[1].p[6] = pvj.texCoords[1];
1408
1409        const polyVert& pvjp1 = p->vert[j+1];
1410        pVert[2].x = pvjp1.clipCoords[0];
1411        pVert[2].y = pvjp1.clipCoords[1];
1412        pVert[2].p[0] = pvjp1.clipCoords[2];
1413        pVert[2].p[1] = pvjp1.clipCoords[3];
1414        pVert[2].p[2] = pvjp1.light[0];
1415        pVert[2].p[3] = pvjp1.light[1];
1416        pVert[2].p[4] = pvjp1.light[2];
1417        pVert[2].p[5] = pvjp1.texCoords[0];
1418        pVert[2].p[6] = pvjp1.texCoords[1];
1419
1420        // Pass the render data into the rasterizer
1421        hng64_poly_data& renderData = object_data_alloc();
1422        renderData = rOptions;
1423       
1424        const rectangle& visibleArea = m_state.m_screen->visible_area();
1425        render_triangle(visibleArea, render_delegate(FUNC(hng64_poly_renderer::render_scanline), this), 7, pVert[0], pVert[1], pVert[2]);
17031426   }
17041427}
trunk/src/mess/drivers/segapico.c
r249156r249157
119119
120120#include "emu.h"
121121#include "includes/md_cons.h"
122#include "sound/315-5641.h"
122#include "sound/upd7759.h"
123123
124124
125125#define PICO_PENX   1
r249156r249157
130130public:
131131   pico_base_state(const machine_config &mconfig, device_type type, const char *tag)
132132      : md_cons_state(mconfig, type, tag),
133      m_sega_315_5641_pcm(*this, "315_5641"),
133      m_upd7759(*this, "7759"),
134134      m_io_page(*this, "PAGE"),
135135      m_io_pad(*this, "PAD"),
136136      m_io_penx(*this, "PENX"),
137137      m_io_peny(*this, "PENY")
138138   { }
139139
140   optional_device<sega_315_5641_pcm_device> m_sega_315_5641_pcm;
140   optional_device<upd7759_device> m_upd7759;
141141
142142   required_ioport m_io_page;
143143   required_ioport m_io_pad;
r249156r249157
251251
252252      case 8: // toy story 2 checks this for 0x3f (is that 'empty'?)
253253         /* Returns free bytes left in the PCM FIFO buffer */
254         retdata = m_sega_315_5641_pcm->get_fifo_space();
254         retdata = 0x3f;
255255         break;
256256      case 9:
257257      /*
258258         For reads, if bit 15 is cleared, it means PCM is 'busy' or
259259         something like that, as games sometimes wait for it to become 1.
260260      */
261         //   return (m_upd7759->busy_r()^1) << 15;
262         // The BUSY bit stays 1 as long as some PCM sound is playing.
263         // SMPS drivers check 800012 [byte] and clear the "prevent music PCM" byte when the READY bit gets set.
264         // If this is done incorrectly, the voices in Sonic Gameworld (J) are muted by the music's PCM drums.
265         return m_sega_315_5641_pcm->busy_r() << 15;
261         return (m_upd7759->busy_r()^1) << 15;
266262
267263
268264      case 7:
r249156r249157
283279WRITE_LINE_MEMBER(pico_base_state::sound_cause_irq)
284280{
285281//  printf("sound irq\n");
286   /* sega_315_5641_pcm callback */
282   /* upd7759 callback */
287283   m_maincpu->set_input_line(3, HOLD_LINE);
288284}
289285
r249156r249157
293289
294290   switch (offset)
295291   {
296      case 0x10/2:
297         if (mem_mask & 0xFF00)
298            m_sega_315_5641_pcm->port_w(space, 0, (data >> 8) & 0xFF);
299         if (mem_mask & 0x00FF)
300            m_sega_315_5641_pcm->port_w(space, 0, (data >> 0) & 0xFF);
301         break;
302       case 0x12/2: // guess
303         // Note about uPD7759 lines:
304         //   reset line: 1 - normal, 1->0 - reset chip, 0 - playback disabled
305         //   start line: 0->1 - start playback
306         if (mem_mask & 0xFF00)
307         {
308            // I assume that:
309            // value 8000 resets the FIFO? (always used with low reset line)
310            // value 0800 maps to the uPD7759's reset line (0 = reset, 1 = normal)
311            // value 4000 maps to the uPD7759's start line (0->1 = start)
312            m_sega_315_5641_pcm->reset_w((data >> 8) & 0x08);
313            m_sega_315_5641_pcm->start_w((data >> 8) & 0x40);
314            if (data & 0x4000)
315            {
316               // Somewhere between "Reset Off" and the first sample data,
317               // we need to send a few commands to make the sample stream work.
318               // Doing that when rising the "start" line seems to work fine.
319               m_sega_315_5641_pcm->port_w(space, 0, 0xFF);   // "Last Sample" value (must be >= 0x10)
320               m_sega_315_5641_pcm->port_w(space, 0, 0x00);   // Dummy 1
321               m_sega_315_5641_pcm->port_w(space, 0, 0x00);   // Addr MSB
322               m_sega_315_5641_pcm->port_w(space, 0, 0x00);   // Addr LSB
323            }
324         }
325         
326     
327         /*m_sega_315_5641_pcm->reset_w(0);
328         m_sega_315_5641_pcm->start_w(0);
329         m_sega_315_5641_pcm->reset_w(1);
330         m_sega_315_5641_pcm->start_w(1);
292      case 0x12/2: // guess
293         m_upd7759->reset_w(0);
294         m_upd7759->start_w(0);
295         m_upd7759->reset_w(1);
296         m_upd7759->start_w(1);
331297
332         if (mem_mask&0x00ff) m_sega_315_5641_pcm->port_w(space,0,data&0xff);
333         if (mem_mask&0xff00) m_sega_315_5641_pcm->port_w(space,0,(data>>8)&0xff);*/
298         if (mem_mask&0x00ff) m_upd7759->port_w(space,0,data&0xff);
299         if (mem_mask&0xff00) m_upd7759->port_w(space,0,(data>>8)&0xff);
334300
335301         break;
336302   }
r249156r249157
390356   MCFG_CPU_PROGRAM_MAP(pico_mem)
391357
392358   MCFG_DEVICE_REMOVE("genesis_snd_z80")
393   MCFG_DEVICE_REMOVE("ymsnd")
394359
395360   MCFG_MACHINE_START_OVERRIDE( pico_state, pico )
396361   MCFG_MACHINE_RESET_OVERRIDE( pico_base_state, ms_megadriv )
r249156r249157
398363   MCFG_PICO_CARTRIDGE_ADD("picoslot", pico_cart, NULL)
399364   MCFG_SOFTWARE_LIST_ADD("cart_list","pico")
400365
401   MCFG_SOUND_ADD("315_5641", SEGA_315_5641_PCM, UPD7759_STANDARD_CLOCK*2)
366   MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK)
402367   MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(pico_state,sound_cause_irq))
403   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.16)
404   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.16)
368   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48)
369   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48)
405370MACHINE_CONFIG_END
406371
407372static MACHINE_CONFIG_START( picopal, pico_state )
r249156r249157
411376   MCFG_CPU_PROGRAM_MAP(pico_mem)
412377
413378   MCFG_DEVICE_REMOVE("genesis_snd_z80")
414   MCFG_DEVICE_REMOVE("ymsnd")
415379
416380   MCFG_MACHINE_START_OVERRIDE( pico_state, pico )
417381   MCFG_MACHINE_RESET_OVERRIDE( pico_base_state, ms_megadriv )
r249156r249157
419383   MCFG_PICO_CARTRIDGE_ADD("picoslot", pico_cart, NULL)
420384   MCFG_SOFTWARE_LIST_ADD("cart_list","pico")
421385
422   MCFG_SOUND_ADD("315_5641", SEGA_315_5641_PCM, UPD7759_STANDARD_CLOCK*2)
386   MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK)
423387   MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(pico_state,sound_cause_irq))
424   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.16)
425   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.16)
388   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48)
389   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48)
426390MACHINE_CONFIG_END
427391
428392
r249156r249157
588552   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa15000, 0xa150ff, read16_delegate(FUNC(base_md_cart_slot_device::read_a15),(base_md_cart_slot_device*)m_picocart), write16_delegate(FUNC(base_md_cart_slot_device::write_a15),(base_md_cart_slot_device*)m_picocart));
589553   m_maincpu->space(AS_PROGRAM).install_write_handler(0xa14000, 0xa14003, write16_delegate(FUNC(base_md_cart_slot_device::write_tmss_bank),(base_md_cart_slot_device*)m_picocart));
590554
591   m_sega_315_5641_pcm->reset_w(0);
592   m_sega_315_5641_pcm->start_w(0);
593   m_sega_315_5641_pcm->reset_w(1);
594   m_sega_315_5641_pcm->start_w(1);
555   m_upd7759->reset_w(0);
556   m_upd7759->start_w(0);
557   m_upd7759->reset_w(1);
558   m_upd7759->start_w(1);
595559
596560}
597561
r249156r249157
602566   MCFG_CPU_PROGRAM_MAP(copera_mem)
603567
604568   MCFG_DEVICE_REMOVE("genesis_snd_z80")
605   MCFG_DEVICE_REMOVE("ymsnd")
606569
607570   MCFG_MACHINE_START_OVERRIDE( copera_state, copera )
608571   MCFG_MACHINE_RESET_OVERRIDE( pico_base_state, ms_megadriv )
r249156r249157
610573   MCFG_COPERA_CARTRIDGE_ADD("coperaslot", copera_cart, NULL)
611574   MCFG_SOFTWARE_LIST_ADD("cart_list","copera")
612575
613   MCFG_SOUND_ADD("315_5641", SEGA_315_5641_PCM, UPD7759_STANDARD_CLOCK)
576   MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK)
614577   MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(copera_state,sound_cause_irq))
615   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.16)
616   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.16)
578   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48)
579   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48)
617580MACHINE_CONFIG_END
618581
619582


Previous 199869 Revisions Next


© 1997-2024 The MAME Team