Previous 15994 Revisions Next

r11641 Tuesday 24th May, 2011 at 07:50:06 UTC by Miodrag Milanović
Sync with MAME (r12640) (no whatsnew)
[docs]hlsl.txt*
[hlsl]color.fx deconverge.fx focus.fx post.fx
[src]version.c
[src/build]makelist.c
[src/emu]delegate.h driver.h emuopts.c emuopts.h inptport.c inptport.h mconfig.c render.c render.h rendlay.c rendlay.h uimenu.c video.c
[src/emu/cpu/i86]instr286.c instr86.c
[src/emu/cpu/sh2]sh2comn.c
[src/emu/machine]k053252.c k053252.h
[src/emu/video]mc6845.c
[src/mame]mame.lst
[src/mame/drivers]arkanoid.c bfm_sc1.c bfm_sc2.c bfmsys85.c champbwl.c cps1.c cps3.c galpanic.c goldstar.c gundealr.c igspoker.c jpmsys5.c majorpkr.c mpu4.c play_1.c play_2.c play_3.c play_5.c saturn.c stvinit.c xexex.c
[src/mame/includes]stv.h
[src/mame/video]deco16ic.c seta001.c stvvdp1.c stvvdp2.c taito_f3.c
[src/osd/sdl/man]mame.1
[src/osd/windows]drawd3d.c winmain.c winmain.h

hlsl/post.fx
r11640r11641
8383   Output.TexCoord = Input.TexCoord + 0.5f / float2(RawWidth, RawHeight);
8484   Output.ExtraInfo = Input.ExtraInfo;
8585
86   //Output.TexCoord /= 16.0f;
87   //Output.TexCoord += float2(0.3f, 0.25f);
86   //float Zoom = 1.0f;
87   //Output.TexCoord /= Zoom;
88   //Output.TexCoord += float2(0.175f * (1.0f - 1.0f / Zoom) / WidthRatio, 0.175f * (1.0f - 1.0f / Zoom) / HeightRatio);
8889   return Output;
8990}
9091
r11640r11641
151152   float4 BaseTexel = tex2D(DiffuseSampler, BaseCoord);
152153
153154   // -- Alpha Clipping (1px border in drawd3d does not work for some reason) --
154   clip((ScreenClipCoord.x < 1.0f / TargetWidth) ? -1 : 1);
155   clip((ScreenClipCoord.y < 1.0f / TargetHeight) ? -1 : 1);
156   clip((ScreenClipCoord.x > 1.0f / WidthRatio) ? -1 : 1);
157   clip((ScreenClipCoord.y > 1.0f / HeightRatio) ? -1 : 1);
155   clip((BaseCoord.x < WidthRatio / RawWidth) ? -1 : 1);
156   clip((BaseCoord.y < HeightRatio / RawHeight) ? -1 : 1);
157   clip((BaseCoord.x > (1.0f / WidthRatio + 1.0f / RawWidth)) ? -1 : 1);
158   clip((BaseCoord.y > (1.0f / HeightRatio + 1.0f / RawHeight)) ? -1 : 1);
158159
159160   // -- Scanline Simulation --
160161   float3 ScanBrightness = lerp(1.0f, abs(sin(((BaseCoord.y * Ratios.y * RawHeight * ScanlineScale) * PI + ScanlineOffset * RawHeight))) * ScanlineBrightScale + ScanlineBrightOffset, ScanlineAmount);
hlsl/color.fx
r11640r11641
109109
110110float4 ps_main(PS_INPUT Input) : COLOR
111111{
112   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord + 0.5f / float2(RawWidth, RawHeight));
112   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord + 0.5f / float2(-RawWidth, -RawHeight));
113113   
114114   float3 OutRGB = BaseTexel.rgb;
115115
hlsl/focus.fx
r11640r11641
9292   
9393   float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
9494   float2 TexCoord = (Input.Position.xy * InvTexSize);
95   TexCoord = TexCoord + 0.5f * InvTexSize;
9596   float2 DefocusVal = float2(DefocusX, DefocusY);
9697   Output.TexCoord0 = TexCoord + Coord0Offset * InvTexSize * DefocusVal;
9798   Output.TexCoord1 = TexCoord + Coord1Offset * InvTexSize * DefocusVal;
hlsl/deconverge.fx
r11640r11641
112112   float2 MagnetCenter = float2(0.9f / WidthRatio, 0.9f / HeightRatio);
113113   float MagnetDistance = length((MagnetCenter - Input.TexCoord) * float2(WidthRatio, HeightRatio));
114114   float Deconverge = 1.0f - MagnetDistance / MagnetCenter;
115   Deconverge = clamp(Deconverge, 0.0f, 1.0f);
115   Deconverge = 1.0f;//clamp(Deconverge, 0.0f, 1.0f);
116116   float Alpha = tex2D(DiffuseSampler, Input.TexCoord).a;
117117   float RedTexel = tex2D(DiffuseSampler, lerp(Input.TexCoord, Input.RedCoord, Deconverge) + 0.5f / float2(RawWidth, RawHeight)).r;
118118   float GrnTexel = tex2D(DiffuseSampler, lerp(Input.TexCoord, Input.GrnCoord, Deconverge) + 0.5f / float2(RawWidth, RawHeight)).g;
119119   float BluTexel = tex2D(DiffuseSampler, lerp(Input.TexCoord, Input.BluCoord, Deconverge) + 0.5f / float2(RawWidth, RawHeight)).b;
120120   
121   RedTexel *= Input.RedCoord.x < (1.0f / TargetWidth) ? 0.0f : 1.0f;
122   RedTexel *= Input.RedCoord.y < (1.0f / TargetHeight) ? 0.0f : 1.0f;
123   RedTexel *= Input.RedCoord.x > (1.0f / WidthRatio) ? 0.0f : 1.0f;
124   RedTexel *= Input.RedCoord.y > (1.0f / HeightRatio) ? 0.0f : 1.0f;
125   GrnTexel *= Input.GrnCoord.x < (1.0f / TargetWidth) ? 0.0f : 1.0f;
126   GrnTexel *= Input.GrnCoord.y < (1.0f / TargetHeight) ? 0.0f : 1.0f;
127   GrnTexel *= Input.GrnCoord.x > (1.0f / WidthRatio) ? 0.0f : 1.0f;
128   GrnTexel *= Input.GrnCoord.y > (1.0f / HeightRatio) ? 0.0f : 1.0f;
129   BluTexel *= Input.BluCoord.x < (1.0f / TargetWidth) ? 0.0f : 1.0f;
130   BluTexel *= Input.BluCoord.y < (1.0f / TargetHeight) ? 0.0f : 1.0f;
131   BluTexel *= Input.BluCoord.x > (1.0f / WidthRatio) ? 0.0f : 1.0f;
132   BluTexel *= Input.BluCoord.y > (1.0f / HeightRatio) ? 0.0f : 1.0f;
133
121134   return float4(RedTexel, GrnTexel, BluTexel, Alpha);
122135}
123136
src/build/makelist.c
r11640r11641
122122         in_import = true;
123123         continue;
124124      }
125     
125
126126      // if we hit a C++ comment, scan to the end of line
127127      if (c == '/' && *srcptr == '/')
128128      {
r11640r11641
132132      }
133133
134134      if (in_import) {
135         in_import = false;   
135         in_import = false;
136136         char filename[256];
137137         filename[0] = 0;
138138         srcptr--;
src/mame/mame.lst
r11640r11641
20192019insectxj      // B97 (c) 1989 Taito Corporation (Japan)
20202020cchance         // (c)1987 Taito?
20212021champbwl      // (c)1989 Romstar.  not Taito, but the same Seta video chips
2022doraemon      // Sunsoft / Epoch / Fujiko - Shogakukan - TV Asahi (prototype)
20222023
20232024// Taito L-System games
20242025raimais         // B36 (c) 1988 Taito Corporation (Japan)
r11640r11641
90989099tenup         // (c) 1988
90999100tenup3         // (c) 1988
91009101
9102// JPM System 5 Games
9103m_popeye
9104
91019105// JPM System 5 + video expansion 2 Games
91029106monopoly      // (c) 1994
91039107monoplcl      // (c) 1995
src/mame/includes/stv.h
r11640r11641
66   saturn_state(const machine_config &mconfig, device_type type, const char *tag)
77      : driver_device(mconfig, type, tag) { }
88
9   UINT32 *m_workram_l;
10   UINT32 *m_workram_h;
11   UINT8  *m_smpc_ram;
12   UINT32 *m_backupram;
13   UINT32 *m_scu_regs;
14   UINT8  m_NMI_reset;
15   UINT8  m_en_68k;
16   UINT16 *m_sound_ram;
9   UINT32    *m_workram_l;
10   UINT32    *m_workram_h;
11   UINT8     *m_smpc_ram;
12   UINT32    *m_backupram;
13   UINT32    *m_scu_regs;
14   UINT16    *m_sound_ram;
15   UINT16    *m_scsp_regs;
16   UINT32    *m_vdp2_regs;
17   UINT32    *m_vdp2_vram;
18   UINT32    *m_vdp2_cram;
19    UINT32    *m_vdp1_vram;
20    UINT32    *m_vdp1_regs;
1721
18   UINT32 m_scu_src[3];      /* Source DMA lv n address*/
19   UINT32 m_scu_dst[3];      /* Destination DMA lv n address*/
20   UINT32 m_scu_src_add[3];   /* Source Addition for DMA lv n*/
21   UINT32 m_scu_dst_add[3];   /* Destination Addition for DMA lv n*/
22    INT32  m_scu_size[3];      /* Transfer DMA size lv n*/
23    UINT32 m_scu_index[3];
24   UINT8  m_stv_multi_bank;
25   UINT8  m_prev_bankswitch;
22   UINT8     m_NMI_reset;
23   UINT8     m_en_68k;
2624
25   struct {
26      UINT32    src[3];      /* Source DMA lv n address*/
27      UINT32    dst[3];      /* Destination DMA lv n address*/
28      UINT32    src_add[3];   /* Source Addition for DMA lv n*/
29      UINT32    dst_add[3];   /* Destination Addition for DMA lv n*/
30      INT32     size[3];      /* Transfer DMA size lv n*/
31      UINT32    index[3];
32   }m_scu;
33
34   int       m_minit_boost;
35   int       m_sinit_boost;
36   attotime  m_minit_boost_timeslice;
37   attotime  m_sinit_boost_timeslice;
38
39   struct {
40      UINT16    **framebuffer_display_lines;
41      int       framebuffer_mode;
42      int       framebuffer_double_interlace;
43      int         fbcr_accessed;
44        int       framebuffer_width;
45        int       framebuffer_height;
46        int       framebuffer_current_display;
47        int         framebuffer_current_draw;
48        int         framebuffer_clear_on_next_frame;
49      rectangle system_cliprect;
50      rectangle user_cliprect;
51        UINT16     *framebuffer[2];
52        UINT16     **framebuffer_draw_lines;
53       UINT8     *gfx_decode;
54
55      int       local_x;
56      int       local_y;
57   }m_vdp1;
58
59   struct {
60       UINT8     *gfx_decode;
61       bitmap_t  *roz_bitmap[2];
62       UINT8     pixel_clock;
63   }m_vdp2;
64
65   struct {
66      UINT8 IOSEL1;
67        UINT8 IOSEL2;
68        UINT8 EXLE1;
69        UINT8 EXLE2;
70        UINT8 PDR1;
71        UINT8 PDR2;
72        int   intback_stage;
73        int   smpcSR;
74        int   pmode;
75        UINT8 SMEM[4];
76   }m_smpc;
77
78   /* Saturn specific*/
79   int saturn_region;
80
81   /* ST-V specific */
82   UINT8     m_stv_multi_bank;
83   UINT8     m_prev_bankswitch;
84    emu_timer *m_stv_rtc_timer;
85   UINT32    *m_ioga;
86
2787   legacy_cpu_device* m_maincpu;
2888   legacy_cpu_device* m_slave;
2989   legacy_cpu_device* m_audiocpu;
3090};
3191
3292
33extern int minit_boost,sinit_boost;
34extern attotime minit_boost_timeslice, sinit_boost_timeslice;
35
3693DRIVER_INIT ( stv );
3794
3895
r11640r11641
81138
82139/*----------- defined in video/stvvdp1.c -----------*/
83140
84extern UINT32* stv_vdp1_vram;
85141extern UINT16   **stv_framebuffer_display_lines;
86142extern int stv_framebuffer_double_interlace;
87143extern int stv_framebuffer_mode;
r11640r11641
89145
90146int stv_vdp1_start ( running_machine &machine );
91147void video_update_vdp1(running_machine &machine);
148void stv_vdp2_dynamic_res_change(running_machine &machine);
92149
93READ32_HANDLER( stv_vdp1_regs_r );
94WRITE32_HANDLER( stv_vdp1_regs_w );
95READ32_HANDLER ( stv_vdp1_vram_r );
96WRITE32_HANDLER ( stv_vdp1_vram_w );
150READ32_HANDLER ( saturn_vdp1_regs_r );
151READ32_HANDLER ( saturn_vdp1_vram_r );
152READ32_HANDLER ( saturn_vdp1_framebuffer0_r );
97153
98WRITE32_HANDLER ( stv_vdp1_framebuffer0_w );
99READ32_HANDLER ( stv_vdp1_framebuffer0_r );
154WRITE32_HANDLER ( saturn_vdp1_regs_w );
155WRITE32_HANDLER ( saturn_vdp1_vram_w );
156WRITE32_HANDLER ( saturn_vdp1_framebuffer0_w );
100157
101158/*----------- defined in video/stvvdp2.c -----------*/
102159
103extern UINT32* stv_vdp2_regs;
104extern UINT32* stv_vdp2_vram;
105extern int stv_vblank,stv_hblank;
106extern UINT32* stv_vdp2_cram;
107
108160UINT8 stv_get_vblank(running_machine &machine);
109161
110WRITE32_HANDLER ( stv_vdp2_vram_w );
111READ32_HANDLER ( stv_vdp2_vram_r );
162READ32_HANDLER ( saturn_vdp2_vram_r );
163READ32_HANDLER ( saturn_vdp2_cram_r );
164READ32_HANDLER ( saturn_vdp2_regs_r );
112165
113WRITE32_HANDLER ( stv_vdp2_cram_w );
114READ32_HANDLER ( stv_vdp2_cram_r );
166WRITE32_HANDLER ( saturn_vdp2_vram_w );
167WRITE32_HANDLER ( saturn_vdp2_cram_w );
168WRITE32_HANDLER ( saturn_vdp2_regs_w );
115169
116WRITE32_HANDLER ( stv_vdp2_regs_w );
117READ32_HANDLER ( stv_vdp2_regs_r );
118
119170VIDEO_START ( stv_vdp2 );
120171SCREEN_UPDATE( stv_vdp2 );
121172
src/mame/video/stvvdp1.c
r11640r11641
22
33STV - VDP1
44
5crude drawing code to support some of the basic vdp1 features
6based on what hanagumi columns needs
7-- to be expanded
8
95the vdp1 draws to the FRAMEBUFFER which is mapped in memory
106
117Framebuffer todo:
r11640r11641
139- add proper framebuffer erase
1410- 8 bpp support - now we always draw as 16 bpp, but this is not a problem since
1511  VDP2 interprets framebuffer as 8 bpp in these cases
12- make this to be inp record/playback safe
13
1614*/
1715
1816
1917#include "emu.h"
20#include "sound/scsp.h"
2118#include "includes/stv.h"
2219
23static int vdp1_sprite_log = 0;
20#define VDP1_LOG 0
2421
25UINT32 *stv_vdp1_vram;
26static UINT32 *stv_vdp1_regs;
27UINT8* stv_vdp1_gfx_decode;
28
29static UINT16    *stv_framebuffer[2];
30static UINT16    **stv_framebuffer_draw_lines;
31UINT16    **stv_framebuffer_display_lines;
32static int       stv_framebuffer_width;
33static int       stv_framebuffer_height;
34int       stv_framebuffer_mode;
35int       stv_framebuffer_double_interlace;
36static int       stv_vdp1_fbcr_accessed;
37static int       stv_vdp1_current_display_framebuffer;
38static int       stv_vdp1_current_draw_framebuffer;
39static int       stv_vdp1_clear_framebuffer_on_next_frame;
40static rectangle stv_vdp1_system_cliprect;
41static rectangle stv_vdp1_user_cliprect;
42
43static int stvvdp1_local_x;
44static int stvvdp1_local_y;
45
4622struct stv_vdp1_poly_scanline
4723{
4824   INT32   x[2];
r11640r11641
11591   1 1024x256
11692   0 512x256
11793*/
118#define STV_VDP1_TVMR ((stv_vdp1_regs[0x000/4] >> 16)&0x0000ffff)
94#define STV_VDP1_TVMR ((state->m_vdp1_regs[0x000/4] >> 16)&0x0000ffff)
11995#define STV_VDP1_VBE  ((STV_VDP1_TVMR & 0x0008) >> 3)
12096#define STV_VDP1_TVM  ((STV_VDP1_TVMR & 0x0007) >> 0)
12197
r11640r11641
128104   ---- ---- ---- --x- | Frame Buffer Change Trigger (FCM)
129105   ---- ---- ---- ---x | Frame Buffer Change Mode (FCT)
130106*/
131#define STV_VDP1_FBCR ((stv_vdp1_regs[0x000/4] >> 0)&0x0000ffff)
107#define STV_VDP1_FBCR ((state->m_vdp1_regs[0x000/4] >> 0)&0x0000ffff)
132108#define STV_VDP1_EOS ((STV_VDP1_FBCR & 0x0010) >> 4)
133109#define STV_VDP1_DIE ((STV_VDP1_FBCR & 0x0008) >> 3)
134110#define STV_VDP1_DIL ((STV_VDP1_FBCR & 0x0004) >> 2)
r11640r11641
146122   1 VDP1 draw by request
147123   0 VDP1 Idle (no access)
148124*/
149#define STV_VDP1_PTMR ((stv_vdp1_regs[0x004/4] >> 16)&0x0000ffff)
125#define STV_VDP1_PTMR ((state->m_vdp1_regs[0x004/4] >> 16)&0x0000ffff)
150126#define STV_VDP1_PTM  ((STV_VDP1_PTMR & 0x0003) >> 0)
151#define SET_PTM_FROM_1_TO_0 if(STV_VDP1_PTM & 1)    stv_vdp1_regs[0x004/4]^=0x00010000
127#define PTM_0      state->m_vdp1_regs[0x004/4]&=~0x00010000
152128/*Erase/Write Upper-Left register*/
153129/*
154130   x--- ---- ---- ---- | UNUSED
r11640r11641
156132   ---- ---x xxxx xxxx | Y1 register
157133
158134*/
159#define STV_VDP1_EWLR ((stv_vdp1_regs[0x008/4] >> 16)&0x0000ffff)
135#define STV_VDP1_EWLR ((state->m_vdp1_regs[0x008/4] >> 16)&0x0000ffff)
160136#define STV_VDP1_EWLR_X1 ((STV_VDP1_EWLR & 0x7e00) >> 9)
161137#define STV_VDP1_EWLR_Y1 ((STV_VDP1_EWLR & 0x01ff) >> 0)
162138/*Erase/Write Lower-Right register*/
r11640r11641
165141   ---- ---x xxxx xxxx | Y3 register
166142
167143*/
168#define STV_VDP1_EWRR ((stv_vdp1_regs[0x008/4] >> 0)&0x0000ffff)
144#define STV_VDP1_EWRR ((state->m_vdp1_regs[0x008/4] >> 0)&0x0000ffff)
169145#define STV_VDP1_EWRR_X3 ((STV_VDP1_EWRR & 0xfe00) >> 9)
170146#define STV_VDP1_EWRR_Y3 ((STV_VDP1_EWRR & 0x01ff) >> 0)
171147/*Transfer End Status Register*/
r11640r11641
175151   ---- ---- ---- ---x | BEF
176152
177153*/
178#define STV_VDP1_EDSR ((stv_vdp1_regs[0x010/4] >> 16)&0x0000ffff)
154#define STV_VDP1_EDSR ((state->m_vdp1_regs[0x010/4] >> 16)&0x0000ffff)
179155#define STV_VDP1_CEF  (STV_VDP1_EDSR & 2)
180156#define STV_VDP1_BEF  (STV_VDP1_EDSR & 1)
181#define SET_CEF_FROM_1_TO_0    if(STV_VDP1_CEF)    stv_vdp1_regs[0x010/4]^=0x00020000
182#define SET_CEF_FROM_0_TO_1     if(!(STV_VDP1_CEF))    stv_vdp1_regs[0x010/4]^=0x00020000
157#define CEF_1   state->m_vdp1_regs[0x010/4]|=0x00020000
158#define CEF_0   state->m_vdp1_regs[0x010/4]&=~0x00020000
183159/**/
184160
185161
186162
187163static void stv_vdp1_process_list(running_machine &machine);
188164
189READ32_HANDLER( stv_vdp1_regs_r )
165READ32_HANDLER( saturn_vdp1_regs_r )
190166{
191// static int x;
167   saturn_state *state = space->machine().driver_data<saturn_state>();
192168
193// x ^= 0x00020000;
169   //logerror ("cpu %s (PC=%08X) VDP1: Read from Registers, Offset %04x\n", space->device().tag(), cpu_get_pc(&space->device()), offset);
194170
195   logerror ("cpu %s (PC=%08X) VDP1: Read from Registers, Offset %04x\n", space->device().tag(), cpu_get_pc(&space->device()), offset);
196//  if (offset == 0x04) return x;
197
198   return stv_vdp1_regs[offset];
171   return state->m_vdp1_regs[offset];
199172}
200173
201static void stv_clear_framebuffer( int which_framebuffer )
174static void stv_clear_framebuffer( running_machine &machine, int which_framebuffer )
202175{
203   if ( vdp1_sprite_log ) logerror( "Clearing %d framebuffer\n", stv_vdp1_current_draw_framebuffer );
204   memset( stv_framebuffer[ which_framebuffer ], 0, 1024 * 256 * sizeof(UINT16) * 2 );
176   saturn_state *state = machine.driver_data<saturn_state>();
177
178   if ( VDP1_LOG ) logerror( "Clearing %d framebuffer\n", state->m_vdp1.framebuffer_current_draw );
179   memset( state->m_vdp1.framebuffer[ which_framebuffer ], 0, 1024 * 256 * sizeof(UINT16) * 2 );
205180}
206181
207182
208static void stv_prepare_framebuffers( void )
183static void stv_prepare_framebuffers( running_machine &machine )
209184{
185   saturn_state *state = machine.driver_data<saturn_state>();
210186   int i,rowsize;
211187
212   rowsize = stv_framebuffer_width;
213   if ( stv_vdp1_current_draw_framebuffer == 0 )
188   rowsize = state->m_vdp1.framebuffer_width;
189   if ( state->m_vdp1.framebuffer_current_draw == 0 )
214190   {
215      for ( i = 0; i < stv_framebuffer_height; i++ )
191      for ( i = 0; i < state->m_vdp1.framebuffer_height; i++ )
216192      {
217         stv_framebuffer_draw_lines[i] = &stv_framebuffer[0][ i * rowsize ];
218         stv_framebuffer_display_lines[i] = &stv_framebuffer[1][ i * rowsize ];
193         state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[0][ i * rowsize ];
194         state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[1][ i * rowsize ];
219195      }
220196      for ( ; i < 512; i++ )
221197      {
222         stv_framebuffer_draw_lines[i] = &stv_framebuffer[0][0];
223         stv_framebuffer_display_lines[i] = &stv_framebuffer[1][0];
198         state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[0][0];
199         state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[1][0];
224200      }
225201
226202   }
227203   else
228204   {
229      for ( i = 0; i < stv_framebuffer_height; i++ )
205      for ( i = 0; i < state->m_vdp1.framebuffer_height; i++ )
230206      {
231         stv_framebuffer_draw_lines[i] = &stv_framebuffer[1][ i * rowsize ];
232         stv_framebuffer_display_lines[i] = &stv_framebuffer[0][ i * rowsize ];
207         state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[1][ i * rowsize ];
208         state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[0][ i * rowsize ];
233209      }
234210      for ( ; i < 512; i++ )
235211      {
236         stv_framebuffer_draw_lines[i] = &stv_framebuffer[1][0];
237         stv_framebuffer_display_lines[i] = &stv_framebuffer[0][0];
212         state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[1][0];
213         state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[0][0];
238214      }
239215
240216   }
241217
242218   for ( ; i < 512; i++ )
243219   {
244      stv_framebuffer_draw_lines[i] = &stv_framebuffer[0][0];
245      stv_framebuffer_display_lines[i] = &stv_framebuffer[1][0];
220      state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[0][0];
221      state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[1][0];
246222   }
247223
248224}
249225
250static void stv_vdp1_change_framebuffers( void )
226static void stv_vdp1_change_framebuffers( running_machine &machine )
251227{
252   stv_vdp1_current_display_framebuffer ^= 1;
253   stv_vdp1_current_draw_framebuffer ^= 1;
254   if ( vdp1_sprite_log ) logerror( "Changing framebuffers: %d - draw, %d - display\n", stv_vdp1_current_draw_framebuffer, stv_vdp1_current_display_framebuffer );
255   stv_prepare_framebuffers();
228   saturn_state *state = machine.driver_data<saturn_state>();
229   state->m_vdp1.framebuffer_current_display ^= 1;
230   state->m_vdp1.framebuffer_current_draw ^= 1;
231   if ( VDP1_LOG ) logerror( "Changing framebuffers: %d - draw, %d - display\n", state->m_vdp1.framebuffer_current_draw, state->m_vdp1.framebuffer_current_display );
232   stv_prepare_framebuffers(machine);
256233}
257234
258static void stv_set_framebuffer_config( void )
235static void stv_set_framebuffer_config( running_machine &machine )
259236{
260   if ( stv_framebuffer_mode == STV_VDP1_TVM &&
261       stv_framebuffer_double_interlace == STV_VDP1_DIE ) return;
237   saturn_state *state = machine.driver_data<saturn_state>();
238   if ( state->m_vdp1.framebuffer_mode == STV_VDP1_TVM &&
239       state->m_vdp1.framebuffer_double_interlace == STV_VDP1_DIE ) return;
262240
263   if ( vdp1_sprite_log ) logerror( "Setting framebuffer config\n" );
264   stv_framebuffer_mode = STV_VDP1_TVM;
265   stv_framebuffer_double_interlace = STV_VDP1_DIE;
266   switch( stv_framebuffer_mode )
241   if ( VDP1_LOG ) logerror( "Setting framebuffer config\n" );
242   state->m_vdp1.framebuffer_mode = STV_VDP1_TVM;
243   state->m_vdp1.framebuffer_double_interlace = STV_VDP1_DIE;
244   switch( state->m_vdp1.framebuffer_mode )
267245   {
268      case 0: stv_framebuffer_width = 512; stv_framebuffer_height = 256; break;
269      case 1: stv_framebuffer_width = 1024; stv_framebuffer_height = 256; break;
270      case 2: stv_framebuffer_width = 512; stv_framebuffer_height = 256; break;
271      case 3: stv_framebuffer_width = 512; stv_framebuffer_height = 512; break;
272      case 4: stv_framebuffer_width = 512; stv_framebuffer_height = 256; break;
273      default: logerror( "Invalid framebuffer config %x\n", STV_VDP1_TVM ); stv_framebuffer_width = 512; stv_framebuffer_height = 256; break;
246      case 0: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break;
247      case 1: state->m_vdp1.framebuffer_width = 1024; state->m_vdp1.framebuffer_height = 256; break;
248      case 2: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break;
249      case 3: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 512; break;
250      case 4: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break;
251      default: logerror( "Invalid framebuffer config %x\n", STV_VDP1_TVM ); state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break;
274252   }
275   if ( STV_VDP1_DIE ) stv_framebuffer_height *= 2; /* double interlace */
253   if ( STV_VDP1_DIE ) state->m_vdp1.framebuffer_height *= 2; /* double interlace */
276254
277   stv_vdp1_current_draw_framebuffer = 0;
278   stv_vdp1_current_display_framebuffer = 1;
279   stv_prepare_framebuffers();
255   state->m_vdp1.framebuffer_current_draw = 0;
256   state->m_vdp1.framebuffer_current_display = 1;
257   stv_prepare_framebuffers(machine);
280258}
281259
282WRITE32_HANDLER( stv_vdp1_regs_w )
260WRITE32_HANDLER( saturn_vdp1_regs_w )
283261{
284   COMBINE_DATA(&stv_vdp1_regs[offset]);
262   saturn_state *state = space->machine().driver_data<saturn_state>();
263   COMBINE_DATA(&state->m_vdp1_regs[offset]);
285264   if ( offset == 0 )
286265   {
287      stv_set_framebuffer_config();
266      stv_set_framebuffer_config(space->machine());
288267      if ( ACCESSING_BITS_0_15 )
289268      {
290         if ( vdp1_sprite_log ) logerror( "VDP1: Access to register FBCR = %1X\n", STV_VDP1_FBCR );
291         stv_vdp1_fbcr_accessed = 1;
269         if ( VDP1_LOG ) logerror( "VDP1: Access to register FBCR = %1X\n", STV_VDP1_FBCR );
270         state->m_vdp1.fbcr_accessed = 1;
292271      }
293272      else
294273      {
295         if ( vdp1_sprite_log ) logerror( "VDP1: Access to register TVMR = %1X\n", STV_VDP1_TVMR );
274         if ( VDP1_LOG ) logerror( "VDP1: Access to register TVMR = %1X\n", STV_VDP1_TVMR );
296275         if ( STV_VDP1_VBE && stv_get_vblank(space->machine()) )
297276         {
298            stv_vdp1_clear_framebuffer_on_next_frame = 1;
277            state->m_vdp1.framebuffer_clear_on_next_frame = 1;
299278         }
300279
301280         /* needed by pblbeach, it doesn't clear local coordinates in its sprite list...*/
302281         //if ( !strcmp(space->machine().system().name, "pblbeach") )
303282         //{
304         //  stvvdp1_local_x = stvvdp1_local_y = 0;
283         //  state->m_vdp1.local_x = state->m_vdp1.local_y = 0;
305284         //}
306285      }
307286   }
r11640r11641
311290      {
312291         if ( STV_VDP1_PTMR == 1 )
313292         {
314            if ( vdp1_sprite_log ) logerror( "VDP1: Access to register PTMR = %1X\n", STV_VDP1_PTMR );
293            if ( VDP1_LOG ) logerror( "VDP1: Access to register PTMR = %1X\n", STV_VDP1_PTMR );
315294            stv_vdp1_process_list( space->machine() );
316295         }
317296      }
318297      else if ( ACCESSING_BITS_0_15 )
319298      {
320         if ( vdp1_sprite_log ) logerror( "VDP1: Erase data set %08X\n", data );
299         if ( VDP1_LOG ) logerror( "VDP1: Erase data set %08X\n", data );
321300      }
322301   }
323302   else if ( offset == 2 )
324303   {
325304      if ( ACCESSING_BITS_16_31 )
326305      {
327         if ( vdp1_sprite_log ) logerror( "VDP1: Erase upper-left coord set: %08X\n", data );
306         if ( VDP1_LOG ) logerror( "VDP1: Erase upper-left coord set: %08X\n", data );
328307      }
329308      else if ( ACCESSING_BITS_0_15 )
330309      {
331         if ( vdp1_sprite_log ) logerror( "VDP1: Erase lower-right coord set: %08X\n", data );
310         if ( VDP1_LOG ) logerror( "VDP1: Erase lower-right coord set: %08X\n", data );
332311      }
333312   }
334313
335314}
336315
337READ32_HANDLER ( stv_vdp1_vram_r )
316READ32_HANDLER ( saturn_vdp1_vram_r )
338317{
339   return stv_vdp1_vram[offset];
318   saturn_state *state = space->machine().driver_data<saturn_state>();
319   return state->m_vdp1_vram[offset];
340320}
341321
342322
343WRITE32_HANDLER ( stv_vdp1_vram_w )
323WRITE32_HANDLER ( saturn_vdp1_vram_w )
344324{
345   UINT8 *vdp1 = stv_vdp1_gfx_decode;
325   saturn_state *state = space->machine().driver_data<saturn_state>();
326   UINT8 *vdp1 = state->m_vdp1.gfx_decode;
346327
347   COMBINE_DATA (&stv_vdp1_vram[offset]);
328   COMBINE_DATA (&state->m_vdp1_vram[offset]);
348329
349330//  if (((offset * 4) > 0xdf) && ((offset * 4) < 0x140))
350331//  {
351332//      logerror("cpu %s (PC=%08X): VRAM dword write to %08X = %08X & %08X\n", space->device().tag(), cpu_get_pc(&space->device()), offset*4, data, mem_mask);
352333//  }
353334
354   data = stv_vdp1_vram[offset];
335   data = state->m_vdp1_vram[offset];
355336   /* put in gfx region for easy decoding */
356337   vdp1[offset*4+0] = (data & 0xff000000) >> 24;
357338   vdp1[offset*4+1] = (data & 0x00ff0000) >> 16;
r11640r11641
359340   vdp1[offset*4+3] = (data & 0x000000ff) >> 0;
360341}
361342
362WRITE32_HANDLER ( stv_vdp1_framebuffer0_w )
343WRITE32_HANDLER ( saturn_vdp1_framebuffer0_w )
363344{
345   saturn_state *state = space->machine().driver_data<saturn_state>();
364346   //popmessage ("STV VDP1 Framebuffer 0 WRITE offset %08x data %08x",offset, data);
365   if ( STV_VDP1_TVM & 0 )
347   if ( STV_VDP1_TVM & 1 )
366348   {
367349      /* 8-bit mode */
368350   }
r11640r11641
371353      /* 16-bit mode */
372354      if ( ACCESSING_BITS_16_31 )
373355      {
374         stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2] = (data >> 16) & 0xffff;
356         state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2] = (data >> 16) & 0xffff;
375357      }
376358      if ( ACCESSING_BITS_0_15 )
377359      {
378         stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2+1] = data & 0xffff;
360         state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2+1] = data & 0xffff;
379361      }
380362   }
381363}
382364
383READ32_HANDLER ( stv_vdp1_framebuffer0_r )
365READ32_HANDLER ( saturn_vdp1_framebuffer0_r )
384366{
367   saturn_state *state = space->machine().driver_data<saturn_state>();
385368   UINT32 result = 0;
386369   //popmessage ("STV VDP1 Framebuffer 0 READ offset %08x",offset);
387   if ( STV_VDP1_TVM & 0 )
370   if ( STV_VDP1_TVM & 1 )
388371   {
389372      /* 8-bit mode */
390373   }
r11640r11641
393376      /* 16-bit mode */
394377      if ( ACCESSING_BITS_16_31 )
395378      {
396         result |= (stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2] << 16);
379         result |= (state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2] << 16);
397380      }
398381      if ( ACCESSING_BITS_0_15 )
399382      {
400         result |= stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2+1];
383         result |= (state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2+1]);
401384      }
402385
403386   }
r11640r11641
406389}
407390
408391#ifdef UNUSED_FUNCTION
409WRITE32_HANDLER ( stv_vdp1_framebuffer1_w )
392WRITE32_HANDLER ( saturn_vdp1_framebuffer1_w )
410393{
411394   //popmessage ("STV VDP1 Framebuffer 1 WRITE offset %08x data %08x",offset, data);
412395}
413396
414READ32_HANDLER ( stv_vdp1_framebuffer1_r )
397READ32_HANDLER ( saturn_vdp1_framebuffer1_r )
415398{
416399   //popmessage ("STV VDP1 Framebuffer 1 READ offset %08x",offset);
417400   return 0xffff;
r11640r11641
513496   memset( &stv_gouraud_shading, 0, sizeof( stv_gouraud_shading ) );
514497}
515498
516static UINT8 stv_read_gouraud_table(void)
499static UINT8 stv_read_gouraud_table(running_machine &machine)
517500{
501   saturn_state *state = machine.driver_data<saturn_state>();
518502   int gaddr;
519503
520504   if ( (stv2_current_sprite.CMDPMOD & 0x7) == 4 )
521505   {
522506      gaddr = stv2_current_sprite.CMDGRDA * 8;
523      stv_gouraud_shading.GA = (stv_vdp1_vram[gaddr/4] >> 16) & 0xffff;
524      stv_gouraud_shading.GB = (stv_vdp1_vram[gaddr/4] >> 0) & 0xffff;
525      stv_gouraud_shading.GC = (stv_vdp1_vram[gaddr/4 + 1] >> 16) & 0xffff;
526      stv_gouraud_shading.GD = (stv_vdp1_vram[gaddr/4 + 1] >> 0) & 0xffff;
507      stv_gouraud_shading.GA = (state->m_vdp1_vram[gaddr/4] >> 16) & 0xffff;
508      stv_gouraud_shading.GB = (state->m_vdp1_vram[gaddr/4] >> 0) & 0xffff;
509      stv_gouraud_shading.GC = (state->m_vdp1_vram[gaddr/4 + 1] >> 16) & 0xffff;
510      stv_gouraud_shading.GD = (state->m_vdp1_vram[gaddr/4 + 1] >> 0) & 0xffff;
527511      return 1;
528512   }
529513   else
r11640r11641
674658   *ng2 = g2;
675659}
676660
677static void stv_vdp1_setup_shading(const struct spoint* q, const rectangle *cliprect)
661static void stv_vdp1_setup_shading(running_machine &machine,const struct spoint* q, const rectangle *cliprect)
678662{
679663   INT32 x1, x2, delta, cury, limy;
680664   INT32 r1, g1, b1, r2, g2, b2;
r11640r11641
684668   struct shaded_point p[8];
685669   UINT16 gd[4];
686670
687   if ( stv_read_gouraud_table() == 0 ) return;
671   if ( stv_read_gouraud_table(machine) == 0 ) return;
688672
689673   gd[0] = stv_gouraud_shading.GA;
690674   gd[1] = stv_gouraud_shading.GB;
r11640r11641
858842
859843static void drawpixel_poly(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
860844{
861   stv_framebuffer_draw_lines[y][x] = stv2_current_sprite.CMDCOLR;
845   saturn_state *state = machine.driver_data<saturn_state>();
846   state->m_vdp1.framebuffer_draw_lines[y][x] = stv2_current_sprite.CMDCOLR;
862847}
863848
864849static void drawpixel_8bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
865850{
851   saturn_state *state = machine.driver_data<saturn_state>();
866852   UINT16 pix;
867853
868854   pix = gfxdata[patterndata+offsetcnt];
869855   if ( pix & 0xff )
870856   {
871      stv_framebuffer_draw_lines[y][x] = pix | sprite_colorbank;
857      state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank;
872858   }
873859}
874860
875861static void drawpixel_4bpp_notrans(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
876862{
863   saturn_state *state = machine.driver_data<saturn_state>();
877864   UINT16 pix;
878865
879866   pix = gfxdata[patterndata+offsetcnt/2];
880867   pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ;
881   stv_framebuffer_draw_lines[y][x] = pix | sprite_colorbank;
868   state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank;
882869}
883870
884871static void drawpixel_4bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
885872{
873   saturn_state *state = machine.driver_data<saturn_state>();
886874   UINT16 pix;
887875
888876   pix = gfxdata[patterndata+offsetcnt/2];
889877   pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ;
890878   if ( pix )
891      stv_framebuffer_draw_lines[y][x] = pix | sprite_colorbank;
879      state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank;
892880}
893881
894882static void drawpixel_generic(running_machine &machine, int x, int y, int patterndata, int offsetcnt)
895883{
884   saturn_state *state = machine.driver_data<saturn_state>();
896885   int pix,mode,transmask, spd = stv2_current_sprite.CMDPMOD & 0x40;
897886   int mesh = stv2_current_sprite.CMDPMOD & 0x100;
898887   int pix2;
r11640r11641
933922            pix2 = gfxdata[patterndata+offsetcnt/2];
934923            pix2 = offsetcnt&1 ?  (pix2 & 0x0f):((pix2 & 0xf0)>>4);
935924            pix = pix2&1 ?
936            ((((stv_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0):
937            ((((stv_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16);
925            ((((state->m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0):
926            ((((state->m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16);
938927
939928            mode = 5;
940929            transmask = 0xffff;
r11640r11641
996985   {
997986      if ( (pix & transmask) || spd )
998987      {
999         stv_framebuffer_draw_lines[y][x] = pix;
988         state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
1000989      }
1001990   }
1002991   else
r11640r11641
1006995         switch( stv2_current_sprite.CMDPMOD & 0x7 )
1007996         {
1008997            case 0:   /* replace */
1009               stv_framebuffer_draw_lines[y][x] = pix;
998               state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
1010999               break;
10111000            case 1: /* shadow */
1012               if ( stv_framebuffer_draw_lines[y][x] & 0x8000 )
1001               if ( state->m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 )
10131002               {
1014                  stv_framebuffer_draw_lines[y][x] = ((stv_framebuffer_draw_lines[y][x] & ~0x8421) >> 1) | 0x8000;
1003                  state->m_vdp1.framebuffer_draw_lines[y][x] = ((state->m_vdp1.framebuffer_draw_lines[y][x] & ~0x8421) >> 1) | 0x8000;
10151004               }
10161005               break;
10171006            case 2: /* half luminance */
1018               stv_framebuffer_draw_lines[y][x] = ((pix & ~0x8421) >> 1) | 0x8000;
1007               state->m_vdp1.framebuffer_draw_lines[y][x] = ((pix & ~0x8421) >> 1) | 0x8000;
10191008               break;
10201009            case 3: /* half transparent */
1021               if ( stv_framebuffer_draw_lines[y][x] & 0x8000 )
1010               if ( state->m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 )
10221011               {
1023                  stv_framebuffer_draw_lines[y][x] = alpha_blend_r16( stv_framebuffer_draw_lines[y][x], pix, 0x80 ) | 0x8000;
1012                  state->m_vdp1.framebuffer_draw_lines[y][x] = alpha_blend_r16( state->m_vdp1.framebuffer_draw_lines[y][x], pix, 0x80 ) | 0x8000;
10241013               }
10251014               else
10261015               {
1027                  stv_framebuffer_draw_lines[y][x] = pix;
1016                  state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
10281017               }
10291018               break;
10301019            case 4: /* Gouraud shading */
1031               stv_framebuffer_draw_lines[y][x] = stv_vdp1_apply_gouraud_shading( x, y, pix );
1020               state->m_vdp1.framebuffer_draw_lines[y][x] = stv_vdp1_apply_gouraud_shading( x, y, pix );
10321021               break;
10331022            default:
1034               stv_framebuffer_draw_lines[y][x] = pix;
1023               state->m_vdp1.framebuffer_draw_lines[y][x] = pix;
10351024               break;
10361025         }
10371026      }
r11640r11641
10391028}
10401029
10411030
1042static void stv_vdp1_set_drawpixel(void)
1031static void stv_vdp1_set_drawpixel(running_machine &machine)
10431032{
1033   saturn_state *state = machine.driver_data<saturn_state>();
10441034   int sprite_type = stv2_current_sprite.CMDCTRL & 0x000f;
10451035   int sprite_mode = stv2_current_sprite.CMDPMOD&0x0038;
10461036   int spd = stv2_current_sprite.CMDPMOD & 0x40;
10471037   int mesh = stv2_current_sprite.CMDPMOD & 0x100;
10481038   int ecd = stv2_current_sprite.CMDPMOD & 0x80;
10491039
1050   gfxdata = stv_vdp1_gfx_decode;
1040   gfxdata = state->m_vdp1.gfx_decode;
10511041
10521042   if ( mesh || !ecd || ((stv2_current_sprite.CMDPMOD & 0x7) != 0) )
10531043   {
r11640r11641
13721362      vdp1_fill_line(machine, cliprect, patterndata, xsize, cury, x1, x2, u1, u2, v1, v2);
13731363}
13741364
1375static int x2s(int v)
1365static int x2s(running_machine &machine,int v)
13761366{
1377   return (INT32)(INT16)v + stvvdp1_local_x;
1367   saturn_state *state = machine.driver_data<saturn_state>();
1368
1369   return (INT32)(INT16)v + state->m_vdp1.local_x;
13781370}
13791371
1380static int y2s(int v)
1372static int y2s(running_machine &machine, int v)
13811373{
1382   return (INT32)(INT16)v + stvvdp1_local_y;
1374   saturn_state *state = machine.driver_data<saturn_state>();
1375
1376   return (INT32)(INT16)v + state->m_vdp1.local_y;
13831377}
13841378
13851379static void stv_vdp1_draw_line(running_machine &machine, const rectangle *cliprect)
13861380{
13871381   struct spoint q[4];
13881382
1389   q[0].x = x2s(stv2_current_sprite.CMDXA);
1390   q[0].y = y2s(stv2_current_sprite.CMDYA);
1391   q[1].x = x2s(stv2_current_sprite.CMDXB);
1392   q[1].y = y2s(stv2_current_sprite.CMDYB);
1393   q[2].x = x2s(stv2_current_sprite.CMDXA);
1394   q[2].y = y2s(stv2_current_sprite.CMDYA);
1395   q[3].x = x2s(stv2_current_sprite.CMDXB);
1396   q[3].y = y2s(stv2_current_sprite.CMDYB);
1383   q[0].x = x2s(machine, stv2_current_sprite.CMDXA);
1384   q[0].y = y2s(machine, stv2_current_sprite.CMDYA);
1385   q[1].x = x2s(machine, stv2_current_sprite.CMDXB);
1386   q[1].y = y2s(machine, stv2_current_sprite.CMDYB);
1387   q[2].x = x2s(machine, stv2_current_sprite.CMDXA);
1388   q[2].y = y2s(machine, stv2_current_sprite.CMDYA);
1389   q[3].x = x2s(machine, stv2_current_sprite.CMDXB);
1390   q[3].y = y2s(machine, stv2_current_sprite.CMDYB);
13971391
13981392   q[0].u = q[3].u = q[1].u = q[2].u = 0;
13991393   q[0].v = q[1].v = q[2].v = q[3].v = 0;
r11640r11641
14051399{
14061400   struct spoint q[4];
14071401
1408   q[0].x = x2s(stv2_current_sprite.CMDXA);
1409   q[0].y = y2s(stv2_current_sprite.CMDYA);
1410   q[1].x = x2s(stv2_current_sprite.CMDXB);
1411   q[1].y = y2s(stv2_current_sprite.CMDYB);
1412   q[2].x = x2s(stv2_current_sprite.CMDXA);
1413   q[2].y = y2s(stv2_current_sprite.CMDYA);
1414   q[3].x = x2s(stv2_current_sprite.CMDXB);
1415   q[3].y = y2s(stv2_current_sprite.CMDYB);
1402   q[0].x = x2s(machine, stv2_current_sprite.CMDXA);
1403   q[0].y = y2s(machine, stv2_current_sprite.CMDYA);
1404   q[1].x = x2s(machine, stv2_current_sprite.CMDXB);
1405   q[1].y = y2s(machine, stv2_current_sprite.CMDYB);
1406   q[2].x = x2s(machine, stv2_current_sprite.CMDXA);
1407   q[2].y = y2s(machine, stv2_current_sprite.CMDYA);
1408   q[3].x = x2s(machine, stv2_current_sprite.CMDXB);
1409   q[3].y = y2s(machine, stv2_current_sprite.CMDYB);
14161410
14171411   q[0].u = q[3].u = q[1].u = q[2].u = 0;
14181412   q[0].v = q[1].v = q[2].v = q[3].v = 0;
14191413
14201414   vdp1_fill_quad(machine, cliprect, 0, 1, q);
14211415
1422   q[0].x = x2s(stv2_current_sprite.CMDXB);
1423   q[0].y = y2s(stv2_current_sprite.CMDYB);
1424   q[1].x = x2s(stv2_current_sprite.CMDXC);
1425   q[1].y = y2s(stv2_current_sprite.CMDYC);
1426   q[2].x = x2s(stv2_current_sprite.CMDXB);
1427   q[2].y = y2s(stv2_current_sprite.CMDYB);
1428   q[3].x = x2s(stv2_current_sprite.CMDXC);
1429   q[3].y = y2s(stv2_current_sprite.CMDYC);
1416   q[0].x = x2s(machine, stv2_current_sprite.CMDXB);
1417   q[0].y = y2s(machine, stv2_current_sprite.CMDYB);
1418   q[1].x = x2s(machine, stv2_current_sprite.CMDXC);
1419   q[1].y = y2s(machine, stv2_current_sprite.CMDYC);
1420   q[2].x = x2s(machine, stv2_current_sprite.CMDXB);
1421   q[2].y = y2s(machine, stv2_current_sprite.CMDYB);
1422   q[3].x = x2s(machine, stv2_current_sprite.CMDXC);
1423   q[3].y = y2s(machine, stv2_current_sprite.CMDYC);
14301424
14311425   q[0].u = q[3].u = q[1].u = q[2].u = 0;
14321426   q[0].v = q[1].v = q[2].v = q[3].v = 0;
14331427
14341428   vdp1_fill_quad(machine, cliprect, 0, 1, q);
14351429
1436   q[0].x = x2s(stv2_current_sprite.CMDXC);
1437   q[0].y = y2s(stv2_current_sprite.CMDYC);
1438   q[1].x = x2s(stv2_current_sprite.CMDXD);
1439   q[1].y = y2s(stv2_current_sprite.CMDYD);
1440   q[2].x = x2s(stv2_current_sprite.CMDXC);
1441   q[2].y = y2s(stv2_current_sprite.CMDYC);
1442   q[3].x = x2s(stv2_current_sprite.CMDXD);
1443   q[3].y = y2s(stv2_current_sprite.CMDYD);
1430   q[0].x = x2s(machine, stv2_current_sprite.CMDXC);
1431   q[0].y = y2s(machine, stv2_current_sprite.CMDYC);
1432   q[1].x = x2s(machine, stv2_current_sprite.CMDXD);
1433   q[1].y = y2s(machine, stv2_current_sprite.CMDYD);
1434   q[2].x = x2s(machine, stv2_current_sprite.CMDXC);
1435   q[2].y = y2s(machine, stv2_current_sprite.CMDYC);
1436   q[3].x = x2s(machine, stv2_current_sprite.CMDXD);
1437   q[3].y = y2s(machine, stv2_current_sprite.CMDYD);
14441438
14451439   q[0].u = q[3].u = q[1].u = q[2].u = 0;
14461440   q[0].v = q[1].v = q[2].v = q[3].v = 0;
14471441
14481442   vdp1_fill_quad(machine, cliprect, 0, 1, q);
14491443
1450   q[0].x = x2s(stv2_current_sprite.CMDXD);
1451   q[0].y = y2s(stv2_current_sprite.CMDYD);
1452   q[1].x = x2s(stv2_current_sprite.CMDXA);
1453   q[1].y = y2s(stv2_current_sprite.CMDYA);
1454   q[2].x = x2s(stv2_current_sprite.CMDXD);
1455   q[2].y = y2s(stv2_current_sprite.CMDYD);
1456   q[3].x = x2s(stv2_current_sprite.CMDXA);
1457   q[3].y = y2s(stv2_current_sprite.CMDYA);
1444   q[0].x = x2s(machine, stv2_current_sprite.CMDXD);
1445   q[0].y = y2s(machine, stv2_current_sprite.CMDYD);
1446   q[1].x = x2s(machine, stv2_current_sprite.CMDXA);
1447   q[1].y = y2s(machine, stv2_current_sprite.CMDYA);
1448   q[2].x = x2s(machine, stv2_current_sprite.CMDXD);
1449   q[2].y = y2s(machine, stv2_current_sprite.CMDYD);
1450   q[3].x = x2s(machine, stv2_current_sprite.CMDXA);
1451   q[3].y = y2s(machine, stv2_current_sprite.CMDYA);
14581452
14591453   q[0].u = q[3].u = q[1].u = q[2].u = 0;
14601454   q[0].v = q[1].v = q[2].v = q[3].v = 0;
14611455
1462   stv_vdp1_setup_shading(q, cliprect);
1456   stv_vdp1_setup_shading(machine, q, cliprect);
14631457   vdp1_fill_quad(machine, cliprect, 0, 1, q);
14641458
14651459}
r11640r11641
14941488   }
14951489
14961490
1497   q[0].x = x2s(stv2_current_sprite.CMDXA);
1498   q[0].y = y2s(stv2_current_sprite.CMDYA);
1499   q[1].x = x2s(stv2_current_sprite.CMDXB);
1500   q[1].y = y2s(stv2_current_sprite.CMDYB);
1501   q[2].x = x2s(stv2_current_sprite.CMDXC);
1502   q[2].y = y2s(stv2_current_sprite.CMDYC);
1503   q[3].x = x2s(stv2_current_sprite.CMDXD);
1504   q[3].y = y2s(stv2_current_sprite.CMDYD);
1491   q[0].x = x2s(machine, stv2_current_sprite.CMDXA);
1492   q[0].y = y2s(machine, stv2_current_sprite.CMDYA);
1493   q[1].x = x2s(machine, stv2_current_sprite.CMDXB);
1494   q[1].y = y2s(machine, stv2_current_sprite.CMDYB);
1495   q[2].x = x2s(machine, stv2_current_sprite.CMDXC);
1496   q[2].y = y2s(machine, stv2_current_sprite.CMDYC);
1497   q[3].x = x2s(machine, stv2_current_sprite.CMDXD);
1498   q[3].y = y2s(machine, stv2_current_sprite.CMDYD);
15051499
15061500   if(direction & 1) { // xflip
15071501      q[0].u = q[3].u = xsize-1;
r11640r11641
15181512      q[2].v = q[3].v = ysize-1;
15191513   }
15201514
1521   stv_vdp1_setup_shading(q, cliprect);
1515   stv_vdp1_setup_shading(machine, q, cliprect);
15221516   vdp1_fill_quad(machine, cliprect, patterndata, xsize, q);
15231517}
15241518
r11640r11641
16201614
16211615   if (zoompoint)
16221616   {
1623      q[0].x = x2s(x);
1624      q[0].y = y2s(y);
1625      q[1].x = x2s(x)+screen_width;
1626      q[1].y = y2s(y);
1627      q[2].x = x2s(x)+screen_width;
1628      q[2].y = y2s(y)+screen_height;
1629      q[3].x = x2s(x);
1630      q[3].y = y2s(y)+screen_height;
1617      q[0].x = x2s(machine, x);
1618      q[0].y = y2s(machine, y);
1619      q[1].x = x2s(machine, x)+screen_width;
1620      q[1].y = y2s(machine, y);
1621      q[2].x = x2s(machine, x)+screen_width;
1622      q[2].y = y2s(machine, y)+screen_height;
1623      q[3].x = x2s(machine, x);
1624      q[3].y = y2s(machine, y)+screen_height;
16311625
16321626      if ( screen_height_negative )
16331627      {
r11640r11641
16391633   }
16401634   else
16411635   {
1642      q[0].x = x2s(x);
1643      q[0].y = y2s(y);
1644      q[1].x = x2s(x2);
1645      q[1].y = y2s(y);
1646      q[2].x = x2s(x2);
1647      q[2].y = y2s(y2);
1648      q[3].x = x2s(x);
1649      q[3].y = y2s(y2);
1636      q[0].x = x2s(machine, x);
1637      q[0].y = y2s(machine, y);
1638      q[1].x = x2s(machine, x2);
1639      q[1].y = y2s(machine, y);
1640      q[2].x = x2s(machine, x2);
1641      q[2].y = y2s(machine, y2);
1642      q[3].x = x2s(machine, x);
1643      q[3].y = y2s(machine, y2);
16501644   }
16511645
16521646
r11640r11641
16651659      q[2].v = q[3].v = ysize-1;
16661660   }
16671661
1668   stv_vdp1_setup_shading(q, cliprect);
1662   stv_vdp1_setup_shading(machine, q, cliprect);
16691663   vdp1_fill_quad(machine, cliprect, patterndata, xsize, q);
16701664}
16711665
r11640r11641
16731667static void stv_vpd1_draw_normal_sprite(running_machine &machine, const rectangle *cliprect, int sprite_type)
16741668{
16751669   //UINT16 *destline;
1676
1670   //saturn_state *state = machine.driver_data<saturn_state>();
16771671   int y, ysize, drawypos;
16781672   int x, xsize, drawxpos;
16791673   int direction;
r11640r11641
16841678
16851679
16861680
1687   shading = stv_read_gouraud_table();
1681   shading = stv_read_gouraud_table(machine);
16881682
1689   x = x2s(stv2_current_sprite.CMDXA);
1690   y = y2s(stv2_current_sprite.CMDYA);
1683   x = x2s(machine, stv2_current_sprite.CMDXA);
1684   y = y2s(machine, stv2_current_sprite.CMDYA);
16911685
16921686   direction = (stv2_current_sprite.CMDCTRL & 0x0030)>>4;
16931687
r11640r11641
16991693   patterndata = (stv2_current_sprite.CMDSRCA) & 0xffff;
17001694   patterndata = patterndata * 0x8;
17011695
1702   if (vdp1_sprite_log) logerror ("Drawing Normal Sprite x %04x y %04x xsize %04x ysize %04x patterndata %06x\n",x,y,xsize,ysize,patterndata);
1696   if (VDP1_LOG) logerror ("Drawing Normal Sprite x %04x y %04x xsize %04x ysize %04x patterndata %06x\n",x,y,xsize,ysize,patterndata);
17031697
17041698   if ( x > cliprect->max_x ) return;
17051699   if ( y > cliprect->max_y ) return;
17061700
1707   shading = stv_read_gouraud_table();
1701   shading = stv_read_gouraud_table(machine);
17081702   if ( shading )
17091703   {
17101704      struct spoint q[4];
r11640r11641
17131707      q[2].x = x + xsize; q[2].y = y + ysize;
17141708      q[3].x = x; q[3].y = y + ysize;
17151709
1716      stv_vdp1_setup_shading( q, cliprect );
1710      stv_vdp1_setup_shading( machine, q, cliprect );
17171711   }
17181712
17191713   u = 0;
r11640r11641
17451739   maxdrawxpos = MIN(x+xsize-1,cliprect->max_x);
17461740   for (drawypos = y; drawypos <= maxdrawypos; drawypos++ )
17471741   {
1748      //destline = stv_framebuffer_draw_lines[drawypos];
1742      //destline = state->m_vdp1.framebuffer_draw_lines[drawypos];
17491743      su = u;
17501744      for (drawxpos = x; drawxpos <= maxdrawxpos; drawxpos++ )
17511745      {
r11640r11641
17581752
17591753static void stv_vdp1_process_list(running_machine &machine)
17601754{
1755   saturn_state *state = machine.driver_data<saturn_state>();
17611756   int position;
17621757   int spritecount;
17631758   int vdp1_nest;
r11640r11641
17661761   spritecount = 0;
17671762   position = 0;
17681763
1769   if (vdp1_sprite_log) logerror ("Sprite List Process START\n");
1764   if (VDP1_LOG) logerror ("Sprite List Process START\n");
17701765
17711766   vdp1_nest = -1;
17721767
17731768   stv_clear_gouraud_shading();
17741769
17751770   /*Set CEF bit to 0*/
1776   SET_CEF_FROM_1_TO_0;
1771   CEF_0;
17771772
17781773   while (spritecount<10000) // if its drawn this many sprites something is probably wrong or sega were crazy ;-)
17791774   {
r11640r11641
17831778
17841779   //  if (position >= ((0x80000/0x20)/4)) // safety check
17851780   //  {
1786   //      if (vdp1_sprite_log) logerror ("Sprite List Position Too High!\n");
1781   //      if (VDP1_LOG) logerror ("Sprite List Position Too High!\n");
17871782   //      position = 0;
17881783   //  }
17891784
1790      stv2_current_sprite.CMDCTRL = (stv_vdp1_vram[position * (0x20/4)+0] & 0xffff0000) >> 16;
1785      stv2_current_sprite.CMDCTRL = (state->m_vdp1_vram[position * (0x20/4)+0] & 0xffff0000) >> 16;
17911786
17921787      if (stv2_current_sprite.CMDCTRL == 0x8000)
17931788      {
1794         if (vdp1_sprite_log) logerror ("List Terminator (0x8000) Encountered, Sprite List Process END\n");
1789         if (VDP1_LOG) logerror ("List Terminator (0x8000) Encountered, Sprite List Process END\n");
17951790         goto end; // end of list
17961791      }
17971792
1798      stv2_current_sprite.CMDLINK = (stv_vdp1_vram[position * (0x20/4)+0] & 0x0000ffff) >> 0;
1799      stv2_current_sprite.CMDPMOD = (stv_vdp1_vram[position * (0x20/4)+1] & 0xffff0000) >> 16;
1800      stv2_current_sprite.CMDCOLR = (stv_vdp1_vram[position * (0x20/4)+1] & 0x0000ffff) >> 0;
1801      stv2_current_sprite.CMDSRCA = (stv_vdp1_vram[position * (0x20/4)+2] & 0xffff0000) >> 16;
1802      stv2_current_sprite.CMDSIZE = (stv_vdp1_vram[position * (0x20/4)+2] & 0x0000ffff) >> 0;
1803      stv2_current_sprite.CMDXA   = (stv_vdp1_vram[position * (0x20/4)+3] & 0xffff0000) >> 16;
1804      stv2_current_sprite.CMDYA   = (stv_vdp1_vram[position * (0x20/4)+3] & 0x0000ffff) >> 0;
1805      stv2_current_sprite.CMDXB   = (stv_vdp1_vram[position * (0x20/4)+4] & 0xffff0000) >> 16;
1806      stv2_current_sprite.CMDYB   = (stv_vdp1_vram[position * (0x20/4)+4] & 0x0000ffff) >> 0;
1807      stv2_current_sprite.CMDXC   = (stv_vdp1_vram[position * (0x20/4)+5] & 0xffff0000) >> 16;
1808      stv2_current_sprite.CMDYC   = (stv_vdp1_vram[position * (0x20/4)+5] & 0x0000ffff) >> 0;
1809      stv2_current_sprite.CMDXD   = (stv_vdp1_vram[position * (0x20/4)+6] & 0xffff0000) >> 16;
1810      stv2_current_sprite.CMDYD   = (stv_vdp1_vram[position * (0x20/4)+6] & 0x0000ffff) >> 0;
1811      stv2_current_sprite.CMDGRDA = (stv_vdp1_vram[position * (0x20/4)+7] & 0xffff0000) >> 16;
1812//      stv2_current_sprite.UNUSED  = (stv_vdp1_vram[position * (0x20/4)+7] & 0x0000ffff) >> 0;
1793      stv2_current_sprite.CMDLINK = (state->m_vdp1_vram[position * (0x20/4)+0] & 0x0000ffff) >> 0;
1794      stv2_current_sprite.CMDPMOD = (state->m_vdp1_vram[position * (0x20/4)+1] & 0xffff0000) >> 16;
1795      stv2_current_sprite.CMDCOLR = (state->m_vdp1_vram[position * (0x20/4)+1] & 0x0000ffff) >> 0;
1796      stv2_current_sprite.CMDSRCA = (state->m_vdp1_vram[position * (0x20/4)+2] & 0xffff0000) >> 16;
1797      stv2_current_sprite.CMDSIZE = (state->m_vdp1_vram[position * (0x20/4)+2] & 0x0000ffff) >> 0;
1798      stv2_current_sprite.CMDXA   = (state->m_vdp1_vram[position * (0x20/4)+3] & 0xffff0000) >> 16;
1799      stv2_current_sprite.CMDYA   = (state->m_vdp1_vram[position * (0x20/4)+3] & 0x0000ffff) >> 0;
1800      stv2_current_sprite.CMDXB   = (state->m_vdp1_vram[position * (0x20/4)+4] & 0xffff0000) >> 16;
1801      stv2_current_sprite.CMDYB   = (state->m_vdp1_vram[position * (0x20/4)+4] & 0x0000ffff) >> 0;
1802      stv2_current_sprite.CMDXC   = (state->m_vdp1_vram[position * (0x20/4)+5] & 0xffff0000) >> 16;
1803      stv2_current_sprite.CMDYC   = (state->m_vdp1_vram[position * (0x20/4)+5] & 0x0000ffff) >> 0;
1804      stv2_current_sprite.CMDXD   = (state->m_vdp1_vram[position * (0x20/4)+6] & 0xffff0000) >> 16;
1805      stv2_current_sprite.CMDYD   = (state->m_vdp1_vram[position * (0x20/4)+6] & 0x0000ffff) >> 0;
1806      stv2_current_sprite.CMDGRDA = (state->m_vdp1_vram[position * (0x20/4)+7] & 0xffff0000) >> 16;
1807//      stv2_current_sprite.UNUSED  = (state->m_vdp1_vram[position * (0x20/4)+7] & 0x0000ffff) >> 0;
18131808
18141809      /* proecess jump / skip commands, set position for next sprite */
18151810      switch (stv2_current_sprite.CMDCTRL & 0x7000)
18161811      {
18171812         case 0x0000: // jump next
1818            if (vdp1_sprite_log) logerror ("Sprite List Process + Next (Normal)\n");
1813            if (VDP1_LOG) logerror ("Sprite List Process + Next (Normal)\n");
18191814            position++;
18201815            break;
18211816         case 0x1000: // jump assign
1822            if (vdp1_sprite_log) logerror ("Sprite List Process + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2));
1817            if (VDP1_LOG) logerror ("Sprite List Process + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2));
18231818            position= (stv2_current_sprite.CMDLINK>>2);
18241819            break;
18251820         case 0x2000: // jump call
18261821            if (vdp1_nest == -1)
18271822            {
1828               if (vdp1_sprite_log) logerror ("Sprite List Process + Call Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2));
1823               if (VDP1_LOG) logerror ("Sprite List Process + Call Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2));
18291824               vdp1_nest = position+1;
18301825               position = (stv2_current_sprite.CMDLINK>>2);
18311826            }
18321827            else
18331828            {
1834               if (vdp1_sprite_log) logerror ("Sprite List Nested Call, ignoring\n");
1829               if (VDP1_LOG) logerror ("Sprite List Nested Call, ignoring\n");
18351830               position++;
18361831            }
18371832            break;
18381833         case 0x3000:
18391834            if (vdp1_nest != -1)
18401835            {
1841               if (vdp1_sprite_log) logerror ("Sprite List Process + Return\n");
1836               if (VDP1_LOG) logerror ("Sprite List Process + Return\n");
18421837               position = vdp1_nest;
18431838               vdp1_nest = -1;
18441839            }
18451840            else
18461841            {
1847               if (vdp1_sprite_log) logerror ("Attempted return from no subroutine, aborting\n");
1842               if (VDP1_LOG) logerror ("Attempted return from no subroutine, aborting\n");
18481843               position++;
18491844               goto end; // end of list
18501845            }
r11640r11641
18541849            position++;
18551850            break;
18561851         case 0x5000:
1857            if (vdp1_sprite_log) logerror ("Sprite List Skip + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2));
1852            if (VDP1_LOG) logerror ("Sprite List Skip + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2));
18581853            draw_this_sprite = 0;
18591854            position= (stv2_current_sprite.CMDLINK>>2);
18601855
r11640r11641
18631858            draw_this_sprite = 0;
18641859            if (vdp1_nest == -1)
18651860            {
1866               if (vdp1_sprite_log) logerror ("Sprite List Skip + Call To Subroutine Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2));
1861               if (VDP1_LOG) logerror ("Sprite List Skip + Call To Subroutine Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2));
18671862
18681863               vdp1_nest = position+1;
18691864               position = (stv2_current_sprite.CMDLINK>>2);
18701865            }
18711866            else
18721867            {
1873               if (vdp1_sprite_log) logerror ("Sprite List Nested Call, ignoring\n");
1868               if (VDP1_LOG) logerror ("Sprite List Nested Call, ignoring\n");
18741869               position++;
18751870            }
18761871            break;
r11640r11641
18781873            draw_this_sprite = 0;
18791874            if (vdp1_nest != -1)
18801875            {
1881               if (vdp1_sprite_log) logerror ("Sprite List Skip + Return from Subroutine\n");
1876               if (VDP1_LOG) logerror ("Sprite List Skip + Return from Subroutine\n");
18821877
18831878               position = vdp1_nest;
18841879               vdp1_nest = -1;
18851880            }
18861881            else
18871882            {
1888               if (vdp1_sprite_log) logerror ("Attempted return from no subroutine, aborting\n");
1883               if (VDP1_LOG) logerror ("Attempted return from no subroutine, aborting\n");
18891884               position++;
18901885               goto end; // end of list
18911886            }
r11640r11641
18971892      {
18981893         if ( stv2_current_sprite.CMDPMOD & 0x0400 )
18991894         {
1900            cliprect = &stv_vdp1_user_cliprect;
1895            cliprect = &state->m_vdp1.user_cliprect;
19011896         }
19021897         else
19031898         {
1904            cliprect = &stv_vdp1_system_cliprect;
1899            cliprect = &state->m_vdp1.system_cliprect;
19051900         }
19061901
1907         stv_vdp1_set_drawpixel();
1902         stv_vdp1_set_drawpixel(machine);
19081903
19091904         switch (stv2_current_sprite.CMDCTRL & 0x000f)
19101905         {
19111906            case 0x0000:
1912               if (vdp1_sprite_log) logerror ("Sprite List Normal Sprite\n");
1907               if (VDP1_LOG) logerror ("Sprite List Normal Sprite\n");
19131908               stv2_current_sprite.ispoly = 0;
19141909               stv_vpd1_draw_normal_sprite(machine, cliprect, 0);
19151910               break;
19161911
19171912            case 0x0001:
1918               if (vdp1_sprite_log) logerror ("Sprite List Scaled Sprite\n");
1913               if (VDP1_LOG) logerror ("Sprite List Scaled Sprite\n");
19191914               stv2_current_sprite.ispoly = 0;
19201915               stv_vpd1_draw_scaled_sprite(machine, cliprect);
19211916               break;
19221917
19231918            case 0x0002:
1924               if (vdp1_sprite_log) logerror ("Sprite List Distorted Sprite\n");
1919               if (VDP1_LOG) logerror ("Sprite List Distorted Sprite\n");
19251920               stv2_current_sprite.ispoly = 0;
19261921               stv_vpd1_draw_distorted_sprite(machine, cliprect);
19271922               break;
19281923
19291924            case 0x0004:
1930               if (vdp1_sprite_log) logerror ("Sprite List Polygon\n");
1925               if (VDP1_LOG) logerror ("Sprite List Polygon\n");
19311926               stv2_current_sprite.ispoly = 1;
19321927               stv_vpd1_draw_distorted_sprite(machine, cliprect);
19331928               break;
19341929
19351930            case 0x0005:
1936               if (vdp1_sprite_log) logerror ("Sprite List Polyline\n");
1931               if (VDP1_LOG) logerror ("Sprite List Polyline\n");
19371932               stv2_current_sprite.ispoly = 1;
19381933               stv_vdp1_draw_poly_line(machine, cliprect);
19391934               break;
19401935
19411936            case 0x0006:
1942               if (vdp1_sprite_log) logerror ("Sprite List Line\n");
1937               if (VDP1_LOG) logerror ("Sprite List Line\n");
19431938               stv2_current_sprite.ispoly = 1;
19441939               stv_vdp1_draw_line(machine, cliprect);
19451940               break;
19461941
19471942            case 0x0008:
1948               if (vdp1_sprite_log) logerror ("Sprite List Set Command for User Clipping (%d,%d),(%d,%d)\n", stv2_current_sprite.CMDXA, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC);
1949               stv_vdp1_user_cliprect.min_x = stv2_current_sprite.CMDXA;
1950               stv_vdp1_user_cliprect.min_y = stv2_current_sprite.CMDYA;
1951               stv_vdp1_user_cliprect.max_x = stv2_current_sprite.CMDXC;
1952               stv_vdp1_user_cliprect.max_y = stv2_current_sprite.CMDYC;
1943               if (VDP1_LOG) logerror ("Sprite List Set Command for User Clipping (%d,%d),(%d,%d)\n", stv2_current_sprite.CMDXA, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC);
1944               state->m_vdp1.user_cliprect.min_x = stv2_current_sprite.CMDXA;
1945               state->m_vdp1.user_cliprect.min_y = stv2_current_sprite.CMDYA;
1946               state->m_vdp1.user_cliprect.max_x = stv2_current_sprite.CMDXC;
1947               state->m_vdp1.user_cliprect.max_y = stv2_current_sprite.CMDYC;
19531948               break;
19541949
19551950            case 0x0009:
1956               if (vdp1_sprite_log) logerror ("Sprite List Set Command for System Clipping (0,0),(%d,%d)\n", stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC);
1957               stv_vdp1_system_cliprect.min_x = 0;
1958               stv_vdp1_system_cliprect.min_y = 0;
1959               stv_vdp1_system_cliprect.max_x = stv2_current_sprite.CMDXC;
1960               stv_vdp1_system_cliprect.max_y = stv2_current_sprite.CMDYC;
1951               if (VDP1_LOG) logerror ("Sprite List Set Command for System Clipping (0,0),(%d,%d)\n", stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC);
1952               state->m_vdp1.system_cliprect.min_x = 0;
1953               state->m_vdp1.system_cliprect.min_y = 0;
1954               state->m_vdp1.system_cliprect.max_x = stv2_current_sprite.CMDXC;
1955               state->m_vdp1.system_cliprect.max_y = stv2_current_sprite.CMDYC;
19611956               break;
19621957
19631958            case 0x000a:
1964               if (vdp1_sprite_log) logerror ("Sprite List Local Co-Ordinate Set\n");
1965               stvvdp1_local_x = (INT16)stv2_current_sprite.CMDXA;
1966               stvvdp1_local_y = (INT16)stv2_current_sprite.CMDYA;
1959               if (VDP1_LOG) logerror ("Sprite List Local Co-Ordinate Set\n");
1960               state->m_vdp1.local_x = (INT16)stv2_current_sprite.CMDXA;
1961               state->m_vdp1.local_y = (INT16)stv2_current_sprite.CMDYA;
19671962               break;
19681963
19691964            default:
1970               if (vdp1_sprite_log) logerror ("Sprite List Illegal!\n");
1965               if (VDP1_LOG) logerror ("Sprite List Illegal!\n");
19711966               break;
19721967
19731968
r11640r11641
19831978
19841979   end:
19851980   /*set CEF to 1*/
1986   SET_CEF_FROM_0_TO_1;
1981   CEF_1;
19871982
19881983   /* not here! this is done every frame drawn even if the cpu isn't running eg in the debugger */
19891984//  if(!(stv_scu[40] & 0x2000)) /*Sprite draw end irq*/
19901985//      cputag_set_input_line_and_vector(machine, "maincpu", 2, HOLD_LINE , 0x4d);
19911986
1992   if (vdp1_sprite_log) logerror ("End of list processing!\n");
1987   if (VDP1_LOG) logerror ("End of list processing!\n");
19931988}
19941989
19951990void video_update_vdp1(running_machine &machine)
19961991{
1992   saturn_state *state = machine.driver_data<saturn_state>();
19971993   int framebufer_changed = 0;
19981994
19991995//  int enable;
2000//  if (input_code_pressed (machine, KEYCODE_R)) vdp1_sprite_log = 1;
2001//  if (input_code_pressed (machine, KEYCODE_T)) vdp1_sprite_log = 0;
1996//  if (input_code_pressed (machine, KEYCODE_R)) VDP1_LOG = 1;
1997//  if (input_code_pressed (machine, KEYCODE_T)) VDP1_LOG = 0;
20021998
2003//  if (input_code_pressed (machine, KEYCODE_Y)) vdp1_sprite_log = 0;
1999//  if (input_code_pressed (machine, KEYCODE_Y)) VDP1_LOG = 0;
20042000//  {
20052001//      FILE *fp;
20062002//
r11640r11641
20112007//          fclose(fp);
20122008//      }
20132009//  }
2014   if (vdp1_sprite_log) logerror("video_update_vdp1 called\n");
2015   if (vdp1_sprite_log) logerror( "FBCR = %0x, accessed = %d\n", STV_VDP1_FBCR, stv_vdp1_fbcr_accessed );
2010   if (VDP1_LOG) logerror("video_update_vdp1 called\n");
2011   if (VDP1_LOG) logerror( "FBCR = %0x, accessed = %d\n", STV_VDP1_FBCR, state->m_vdp1.fbcr_accessed );
20162012
2017   if ( stv_vdp1_clear_framebuffer_on_next_frame )
2013   if ( state->m_vdp1.framebuffer_clear_on_next_frame )
20182014   {
20192015      if ( ((STV_VDP1_FBCR & 0x3) == 3) &&
2020         stv_vdp1_fbcr_accessed )
2016         state->m_vdp1.fbcr_accessed )
20212017      {
2022         stv_clear_framebuffer(stv_vdp1_current_display_framebuffer);
2023         stv_vdp1_clear_framebuffer_on_next_frame = 0;
2018         stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_display);
2019         state->m_vdp1.framebuffer_clear_on_next_frame = 0;
20242020      }
20252021   }
20262022
20272023   switch( STV_VDP1_FBCR & 0x3 )
20282024   {
20292025      case 0: /* Automatic mode */
2030         stv_vdp1_change_framebuffers();
2031         stv_clear_framebuffer(stv_vdp1_current_draw_framebuffer);
2026         stv_vdp1_change_framebuffers(machine);
2027         stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw);
20322028         framebufer_changed = 1;
20332029         break;
20342030      case 1: /* Setting prohibited */
20352031         break;
20362032      case 2: /* Manual mode - erase */
2037         if ( stv_vdp1_fbcr_accessed )
2033         if ( state->m_vdp1.fbcr_accessed )
20382034         {
2039            stv_vdp1_clear_framebuffer_on_next_frame = 1;
2035            state->m_vdp1.framebuffer_clear_on_next_frame = 1;
20402036         }
20412037         break;
20422038      case 3: /* Manual mode - change */
2043         if ( stv_vdp1_fbcr_accessed )
2039         if ( state->m_vdp1.fbcr_accessed )
20442040         {
2045            stv_vdp1_change_framebuffers();
2041            stv_vdp1_change_framebuffers(machine);
20462042            if ( STV_VDP1_VBE )
20472043            {
2048               stv_clear_framebuffer(stv_vdp1_current_draw_framebuffer);
2044               stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw);
20492045            }
20502046            framebufer_changed = 1;
20512047         }
20522048         break;
20532049   }
2054   stv_vdp1_fbcr_accessed = 0;
2050   state->m_vdp1.fbcr_accessed = 0;
20552051
2056   if (vdp1_sprite_log) logerror( "PTM = %0x, TVM = %x\n", STV_VDP1_PTM, STV_VDP1_TVM );
2052   if (VDP1_LOG) logerror( "PTM = %0x, TVM = %x\n", STV_VDP1_PTM, STV_VDP1_TVM );
20572053   switch(STV_VDP1_PTM & 3)
20582054   {
20592055      case 0:/*Idle Mode*/
r11640r11641
20732069
20742070static void stv_vdp1_state_save_postload(running_machine &machine)
20752071{
2076   UINT8 *vdp1 = stv_vdp1_gfx_decode;
2072   saturn_state *state = machine.driver_data<saturn_state>();
2073   UINT8 *vdp1 = state->m_vdp1.gfx_decode;
20772074   int offset;
20782075   UINT32 data;
20792076
2080   stv_framebuffer_mode = -1;
2081   stv_framebuffer_double_interlace = -1;
2077   state->m_vdp1.framebuffer_mode = -1;
2078   state->m_vdp1.framebuffer_double_interlace = -1;
20822079
2083   stv_set_framebuffer_config();
2080   stv_set_framebuffer_config(machine);
20842081
20852082   for (offset = 0; offset < 0x80000/4; offset++ )
20862083   {
2087      data = stv_vdp1_vram[offset];
2084      data = state->m_vdp1_vram[offset];
20882085      /* put in gfx region for easy decoding */
20892086      vdp1[offset*4+0] = (data & 0xff000000) >> 24;
20902087      vdp1[offset*4+1] = (data & 0x00ff0000) >> 16;
r11640r11641
20952092
20962093int stv_vdp1_start ( running_machine &machine )
20972094{
2098   stv_vdp1_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 );
2099   stv_vdp1_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 );
2100   stv_vdp1_gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 );
2095   saturn_state *state = machine.driver_data<saturn_state>();
2096   state->m_vdp1_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 );
2097   state->m_vdp1_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 );
2098   state->m_vdp1.gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 );
21012099
21022100   stv_vdp1_shading_data = auto_alloc(machine, struct stv_vdp1_poly_scanline_data);
21032101
2104   stv_framebuffer[0] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 ); /* *2 is for double interlace */
2105   stv_framebuffer[1] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 );
2102   state->m_vdp1.framebuffer[0] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 ); /* *2 is for double interlace */
2103   state->m_vdp1.framebuffer[1] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 );
21062104
2107   stv_framebuffer_display_lines = auto_alloc_array(machine, UINT16 *, 512);
2108   stv_framebuffer_draw_lines = auto_alloc_array(machine, UINT16 *, 512);
2105   state->m_vdp1.framebuffer_display_lines = auto_alloc_array(machine, UINT16 *, 512);
2106   state->m_vdp1.framebuffer_draw_lines = auto_alloc_array(machine, UINT16 *, 512);
21092107
2110   stv_framebuffer_width = stv_framebuffer_height = 0;
2111   stv_framebuffer_mode = -1;
2112   stv_framebuffer_double_interlace = -1;
2113   stv_vdp1_fbcr_accessed = 0;
2114   stv_vdp1_current_display_framebuffer = 0;
2115   stv_vdp1_current_draw_framebuffer = 1;
2116   stv_clear_framebuffer(stv_vdp1_current_draw_framebuffer);
2117   stv_vdp1_clear_framebuffer_on_next_frame = 0;
2108   state->m_vdp1.framebuffer_width = state->m_vdp1.framebuffer_height = 0;
2109   state->m_vdp1.framebuffer_mode = -1;
2110   state->m_vdp1.framebuffer_double_interlace = -1;
2111   state->m_vdp1.fbcr_accessed = 0;
2112   state->m_vdp1.framebuffer_current_display = 0;
2113   state->m_vdp1.framebuffer_current_draw = 1;
2114   stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw);
2115   state->m_vdp1.framebuffer_clear_on_next_frame = 0;
21182116
2119   stv_vdp1_system_cliprect.min_x = stv_vdp1_system_cliprect.max_x = 0;
2120   stv_vdp1_system_cliprect.min_y = stv_vdp1_system_cliprect.max_y = 0;
2121   stv_vdp1_user_cliprect.min_x = stv_vdp1_user_cliprect.max_x = 0;
2122   stv_vdp1_user_cliprect.min_y = stv_vdp1_user_cliprect.max_y = 0;
2117   state->m_vdp1.system_cliprect.min_x = state->m_vdp1.system_cliprect.max_x = 0;
2118   state->m_vdp1.system_cliprect.min_y = state->m_vdp1.system_cliprect.max_y = 0;
2119   state->m_vdp1.user_cliprect.min_x = state->m_vdp1.user_cliprect.max_x = 0;
2120   state->m_vdp1.user_cliprect.min_y = state->m_vdp1.user_cliprect.max_y = 0;
21232121
21242122   // save state
2125   state_save_register_global_pointer(machine, stv_vdp1_regs, 0x040000/4);
2126   state_save_register_global_pointer(machine, stv_vdp1_vram, 0x100000/4);
2127   state_save_register_global(machine, stv_vdp1_fbcr_accessed);
2128   state_save_register_global(machine, stv_vdp1_current_display_framebuffer);
2129   state_save_register_global(machine, stv_vdp1_current_draw_framebuffer);
2130   state_save_register_global(machine, stv_vdp1_clear_framebuffer_on_next_frame);
2131   state_save_register_global(machine, stvvdp1_local_x);
2132   state_save_register_global(machine, stvvdp1_local_y);
2123   state_save_register_global_pointer(machine, state->m_vdp1_regs, 0x040000/4);
2124   state_save_register_global_pointer(machine, state->m_vdp1_vram, 0x100000/4);
2125   state_save_register_global(machine, state->m_vdp1.fbcr_accessed);
2126   state_save_register_global(machine, state->m_vdp1.framebuffer_current_display);
2127   state_save_register_global(machine, state->m_vdp1.framebuffer_current_draw);
2128   state_save_register_global(machine, state->m_vdp1.framebuffer_clear_on_next_frame);
2129   state_save_register_global(machine, state->m_vdp1.local_x);
2130   state_save_register_global(machine, state->m_vdp1.local_y);
21332131   machine.save().register_postload(save_prepost_delegate(FUNC(stv_vdp1_state_save_postload), &machine));
21342132   return 0;
21352133}
src/mame/video/stvvdp2.c
r11640r11641
105105#include "profiler.h"
106106#include "includes/stv.h"
107107
108UINT32* stv_vdp2_regs;
109UINT32* stv_vdp2_vram;
110
111static UINT8* stv_vdp2_gfx_decode;
112
113static int stv_vdp2_render_rbg0;
114int stv_hblank,stv_vblank;
115static int stv_odd;
116static int horz_res,vert_res;
117
118UINT32* stv_vdp2_cram;
119
120static void stv_vdp2_dynamic_res_change(running_machine &machine);
121108static UINT8 get_hblank(running_machine &machine);
122109static int get_vblank_duration(running_machine &machine);
123110static int get_hblank_duration(running_machine &machine);
124111static UINT8 get_odd_bit(running_machine &machine);
125112
126113static void refresh_palette_data(running_machine &machine);
127static int stv_vdp2_window_process(int x,int y);
128static int stv_vdp2_apply_window_on_layer(rectangle *cliprect);
129static void stv_vdp2_get_window0_coordinates(UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y);
114static int stv_vdp2_window_process(running_machine &machine,int x,int y);
115static int stv_vdp2_apply_window_on_layer(running_machine &machine,rectangle *cliprect);
116static void stv_vdp2_get_window0_coordinates(running_machine &machine,UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y);
130117static void stv_vdp2_check_tilemap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
131static bitmap_t *stv_vdp2_roz_bitmap[2];
132118
133119enum
134120{
r11640r11641
195181       | LSMD1    | LSMD0    | VRESO1   | VRESO0   |    --    | HRESO2   | HRESO1   | HRESO0   |
196182       \----------|----------|----------|----------|----------|----------|----------|---------*/
197183
198   #define STV_VDP2_TVMD   ((stv_vdp2_regs[0x000/4] >> 16)&0x0000ffff)
184   #define STV_VDP2_TVMD   ((state->m_vdp2_regs[0x000/4] >> 16)&0x0000ffff)
199185
200186   #define STV_VDP2_DISP   ((STV_VDP2_TVMD & 0x8000) >> 15)
201187   #define STV_VDP2_BDCLMD   ((STV_VDP2_TVMD & 0x0100) >> 8)
r11640r11641
224210       |    --    |    --    |    --    |    --    | VER3     | VER2     | VER1     | VER0     |
225211       \----------|----------|----------|----------|----------|----------|----------|---------*/
226212
227   #define STV_VDP2_VRSIZE ((stv_vdp2_regs[0x004/4] >> 0)&0x0000ffff)
213   #define STV_VDP2_VRSIZE ((state->m_vdp2_regs[0x004/4] >> 0)&0x0000ffff)
228214
229215   #define STV_VDP2_VRAMSZ ((STV_VDP2_VRSIZE & 0x8000) >> 15)
230216
r11640r11641
235221       | HCT7     | HCT6     | HCT5     | HCT4     | HCT3     | HCT2     | HCT1     | HCT0     |
236222       \----------|----------|----------|----------|----------|----------|----------|---------*/
237223
238   #define STV_VDP2_HCNT ((stv_vdp2_regs[0x008/4] >> 16)&0x000003ff)
224   #define STV_VDP2_HCNT ((state->m_vdp2_regs[0x008/4] >> 16)&0x000003ff)
239225
240226/* 18000A - r/o - VCNT - V-Counter
241227 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
244230       | VCT7     | VCT6     | VCT5     | VCT4     | VCT3     | VCT2     | VCT1     | VCT0     |
245231       \----------|----------|----------|----------|----------|----------|----------|---------*/
246232
247   #define STV_VDP2_VCNT ((stv_vdp2_regs[0x008/4] >> 0)&0x000003ff)
233   #define STV_VDP2_VCNT ((state->m_vdp2_regs[0x008/4] >> 0)&0x000003ff)
248234
249235/* 18000C - RESERVED
250236 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
260246       | RDBSB11  | RDBSB10  | RDBSB01  | RDBSB00  | RDBSA11  | RDBSA10  | RDBSA01  | RDBSA00  |
261247       \----------|----------|----------|----------|----------|----------|----------|---------*/
262248
263   #define STV_VDP2_RAMCTL ((stv_vdp2_regs[0x00c/4] >> 0)&0x0000ffff)
249   #define STV_VDP2_RAMCTL ((state->m_vdp2_regs[0x00c/4] >> 0)&0x0000ffff)
264250
265251   #define STV_VDP2_CRKTE ((STV_VDP2_RAMCTL & 0x8000) >> 15)
266252   #define STV_VDP2_CRMD  ((STV_VDP2_RAMCTL & 0x3000) >> 12)
r11640r11641
277263       | VCP2A03  | VCP2A02  | VCP2A01  | VCP2A00  | VCP3A03  | VCP3A02  | VCP3A01  | VCP3A00  |
278264       \----------|----------|----------|----------|----------|----------|----------|---------*/
279265
280   #define STV_VDP2_CYCA0L   ((stv_vdp2_regs[0x010/4] >> 16)&0x0000ffff)
266   #define STV_VDP2_CYCA0L   ((state->m_vdp2_regs[0x010/4] >> 16)&0x0000ffff)
281267
282268/* 180012 - r/w - -CYCA0U - VRAM CYCLE PATTERN (BANK A0)
283269 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
286272       | VCP6A03  | VCP6A02  | VCP6A01  | VCP6A00  | VCP7A03  | VCP7A02  | VCP7A01  | VCP7A00  |
287273       \----------|----------|----------|----------|----------|----------|----------|---------*/
288274
289   #define STV_VDP2_CYCA0U   ((stv_vdp2_regs[0x10/4] >> 0)&0x0000ffff)
275   #define STV_VDP2_CYCA0U   ((state->m_vdp2_regs[0x10/4] >> 0)&0x0000ffff)
290276
291277/* 180014 - r/w - -CYCA1L - VRAM CYCLE PATTERN (BANK A1)
292278 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
295281       | VCP2A13  | VCP2A12  | VCP2A11  | VCP2A10  | VCP3A13  | VCP3A12  | VCP3A11  | VCP3A10  |
296282       \----------|----------|----------|----------|----------|----------|----------|---------*/
297283
298   #define STV_VDP2_CYCA1L   ((stv_vdp2_regs[0x014/4] >> 16)&0x0000ffff)
284   #define STV_VDP2_CYCA1L   ((state->m_vdp2_regs[0x014/4] >> 16)&0x0000ffff)
299285
300286/* 180016 - r/w - -CYCA1U - VRAM CYCLE PATTERN (BANK A1)
301287 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
304290       | VCP6A13  | VCP6A12  | VCP6A11  | VCP6A10  | VCP7A13  | VCP7A12  | VCP7A11  | VCP7A10  |
305291       \----------|----------|----------|----------|----------|----------|----------|---------*/
306292
307   #define STV_VDP2_CYCA1U   ((stv_vdp2_regs[0x14/4] >> 0)&0x0000ffff)
293   #define STV_VDP2_CYCA1U   ((state->m_vdp2_regs[0x14/4] >> 0)&0x0000ffff)
308294
309295/* 180018 - r/w - -CYCB0L - VRAM CYCLE PATTERN (BANK B0)
310296 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
313299       | VCP2B03  | VCP2B02  | VCP2B01  | VCP2B00  | VCP3B03  | VCP3B02  | VCP3B01  | VCP3B00  |
314300       \----------|----------|----------|----------|----------|----------|----------|---------*/
315301
316   #define STV_VDP2_CYCA2L   ((stv_vdp2_regs[0x018/4] >> 16)&0x0000ffff)
302   #define STV_VDP2_CYCA2L   ((state->m_vdp2_regs[0x018/4] >> 16)&0x0000ffff)
317303
318304/* 18001A - r/w - -CYCB0U - VRAM CYCLE PATTERN (BANK B0)
319305 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
322308       | VCP6B03  | VCP6B02  | VCP6B01  | VCP6B00  | VCP7B03  | VCP7B02  | VCP7B01  | VCP7B00  |
323309       \----------|----------|----------|----------|----------|----------|----------|---------*/
324310
325   #define STV_VDP2_CYCA2U   ((stv_vdp2_regs[0x18/4] >> 0)&0x0000ffff)
311   #define STV_VDP2_CYCA2U   ((state->m_vdp2_regs[0x18/4] >> 0)&0x0000ffff)
326312
327313/* 18001C - r/w - -CYCB1L - VRAM CYCLE PATTERN (BANK B1)
328314 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
331317       | VCP2B13  | VCP2B12  | VCP2B11  | VCP2B10  | VCP3B13  | VCP3B12  | VCP3B11  | VCP3B10  |
332318       \----------|----------|----------|----------|----------|----------|----------|---------*/
333319
334   #define STV_VDP2_CYCA3L   ((stv_vdp2_regs[0x01c/4] >> 16)&0x0000ffff)
320   #define STV_VDP2_CYCA3L   ((state->m_vdp2_regs[0x01c/4] >> 16)&0x0000ffff)
335321
336322/* 18001E - r/w - -CYCB1U - VRAM CYCLE PATTERN (BANK B1)
337323 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
340326       | VCP6B13  | VCP6B12  | VCP6B11  | VCP6B10  | VCP7B13  | VCP7B12  | VCP7B11  | VCP7B10  |
341327       \----------|----------|----------|----------|----------|----------|----------|---------*/
342328
343   #define STV_VDP2_CYCA3U   ((stv_vdp2_regs[0x1c/4] >> 0)&0x0000ffff)
329   #define STV_VDP2_CYCA3U   ((state->m_vdp2_regs[0x1c/4] >> 0)&0x0000ffff)
344330
345331/* 180020 - r/w - BGON - SCREEN DISPLAY ENABLE
346332
r11640r11641
352338       |    --    |    --    | R1ON     | R0ON     | N3ON     | N2ON     | N1ON     | N0ON     |
353339       \----------|----------|----------|----------|----------|----------|----------|---------*/
354340
355   #define STV_VDP2_BGON ((stv_vdp2_regs[0x020/4] >> 16)&0x0000ffff)
341   #define STV_VDP2_BGON ((state->m_vdp2_regs[0x020/4] >> 16)&0x0000ffff)
356342
357343   // NxOn - Layer Enable Register
358344   #define STV_VDP2_xxON ((STV_VDP2_BGON & 0x001f) >> 0) /* to see if anything is enabled */
r11640r11641
379365       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
380366       \----------|----------|----------|----------|----------|----------|----------|---------*/
381367
382   #define STV_VDP2_MZCTL ((stv_vdp2_regs[0x020/4] >> 0)&0x0000ffff)
368   #define STV_VDP2_MZCTL ((state->m_vdp2_regs[0x020/4] >> 0)&0x0000ffff)
383369
384370   #define STV_VDP2_R0MZE ((STV_VDP2_MZCTL & 0x0010) >> 4)
385371   #define STV_VDP2_N3MZE ((STV_VDP2_MZCTL & 0x0008) >> 3)
r11640r11641
398384       |    --    | N0CHCN2  | N0CHCN1  | N0CHCN0  | N0BMSZ1  | N0BMSZ0  | N0BMEN   | N0CHSZ   |
399385       \----------|----------|----------|----------|----------|----------|----------|---------*/
400386
401   #define STV_VDP2_CHCTLA ((stv_vdp2_regs[0x028/4] >> 16)&0x0000ffff)
387   #define STV_VDP2_CHCTLA ((state->m_vdp2_regs[0x028/4] >> 16)&0x0000ffff)
402388
403389/* -------------------------- NBG0 Character Control Registers -------------------------- */
404390
r11640r11641
464450       |    --    |    --    | N3CHCN   | N3CHSZ   |    --    |    --    | N2CHCN   | N2CHSZ   |
465451       \----------|----------|----------|----------|----------|----------|----------|---------*/
466452
467   #define STV_VDP2_CHCTLB ((stv_vdp2_regs[0x028/4] >> 0)&0x0000ffff)
453   #define STV_VDP2_CHCTLB ((state->m_vdp2_regs[0x028/4] >> 0)&0x0000ffff)
468454
469455/* -------------------------- RBG0 Character Control Registers -------------------------- */
470456
r11640r11641
509495       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
510496       \----------|----------|----------|----------|----------|----------|----------|---------*/
511497
512   #define STV_VDP2_BMPNA ((stv_vdp2_regs[0x02c/4] >> 16)&0x0000ffff)
498   #define STV_VDP2_BMPNA ((state->m_vdp2_regs[0x02c/4] >> 16)&0x0000ffff)
513499
514500   #define STV_VDP2_N1BMP ((STV_VDP2_BMPNA & 0x0700) >> 8)
515501   #define STV_VDP2_N0BMP ((STV_VDP2_BMPNA & 0x0007) >> 0)
r11640r11641
521507       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
522508       \----------|----------|----------|----------|----------|----------|----------|---------*/
523509
524   #define STV_VDP2_BMPNB ((stv_vdp2_regs[0x02c/4] >> 0)&0x0000ffff)
510   #define STV_VDP2_BMPNB ((state->m_vdp2_regs[0x02c/4] >> 0)&0x0000ffff)
525511
526512   #define STV_VDP2_R0BMP ((STV_VDP2_BMPNB & 0x0007) >> 0)
527513
r11640r11641
532518       | N0SPLT6  | N0SPLT5  | N0SPLT4  | N0SPCN4  | N0SPCN3  | N0SPCN2  | N0SPCN1  | N0SPCN0  |
533519       \----------|----------|----------|----------|----------|----------|----------|---------*/
534520
535   #define STV_VDP2_PNCN0 ((stv_vdp2_regs[0x030/4] >> 16)&0x0000ffff)
521   #define STV_VDP2_PNCN0 ((state->m_vdp2_regs[0x030/4] >> 16)&0x0000ffff)
536522
537523/*  Pattern Data Size
538524    0 = 2 bytes
r11640r11641
563549       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
564550       \----------|----------|----------|----------|----------|----------|----------|---------*/
565551
566   #define STV_VDP2_PNCN1 ((stv_vdp2_regs[0x030/4] >> 0)&0x0000ffff)
552   #define STV_VDP2_PNCN1 ((state->m_vdp2_regs[0x030/4] >> 0)&0x0000ffff)
567553
568554/*  Pattern Data Size
569555    0 = 2 bytes
r11640r11641
595581       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
596582       \----------|----------|----------|----------|----------|----------|----------|---------*/
597583
598   #define STV_VDP2_PNCN2 ((stv_vdp2_regs[0x034/4] >> 16)&0x0000ffff)
584   #define STV_VDP2_PNCN2 ((state->m_vdp2_regs[0x034/4] >> 16)&0x0000ffff)
599585
600586/*  Pattern Data Size
601587    0 = 2 bytes
r11640r11641
627613       | N3SPLT6  | N3SPLT5  | N3SPLT4  | N3SPCN4  | N3SPCN3  | N3SPCN2  | N3SPCN1  | N3SPCN0  |
628614       \----------|----------|----------|----------|----------|----------|----------|---------*/
629615
630   #define STV_VDP2_PNCN3 ((stv_vdp2_regs[0x034/4] >> 0)&0x0000ffff)
616   #define STV_VDP2_PNCN3 ((state->m_vdp2_regs[0x034/4] >> 0)&0x0000ffff)
631617
632618/*  Pattern Data Size
633619    0 = 2 bytes
r11640r11641
659645       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
660646       \----------|----------|----------|----------|----------|----------|----------|---------*/
661647
662   #define STV_VDP2_PNCR ((stv_vdp2_regs[0x038/4] >> 16)&0x0000ffff)
648   #define STV_VDP2_PNCR ((state->m_vdp2_regs[0x038/4] >> 16)&0x0000ffff)
663649
664650/*  Pattern Data Size
665651    0 = 2 bytes
r11640r11641
690676       | N3PLSZ1  | N3PLSZ0  |    --    |    --    | N1PLSZ1  | N1PLSZ0  | N0PLSZ1  | N0PLSZ0  |
691677       \----------|----------|----------|----------|----------|----------|----------|---------*/
692678
693   #define STV_VDP2_PLSZ ((stv_vdp2_regs[0x038/4] >> 0)&0x0000ffff)
679   #define STV_VDP2_PLSZ ((state->m_vdp2_regs[0x038/4] >> 0)&0x0000ffff)
694680
695681   /* NBG0 Plane Size
696682    00 1H Page x 1V Page
r11640r11641
713699       |    --    | N1MP8    | N1MP7    | N1MP6    |    --    | N0MP8    | N0MP7    | N0MP6    |
714700       \----------|----------|----------|----------|----------|----------|----------|---------*/
715701
716   #define STV_VDP2_MPOFN_ ((stv_vdp2_regs[0x03c/4] >> 16)&0x0000ffff)
702   #define STV_VDP2_MPOFN_ ((state->m_vdp2_regs[0x03c/4] >> 16)&0x0000ffff)
717703
718704   /* Higher 3 bits of the map offset for each layer */
719705   #define STV_VDP2_N0MP_ ((STV_VDP2_MPOFN_ & 0x0007) >> 0)
r11640r11641
731717       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
732718       \----------|----------|----------|----------|----------|----------|----------|---------*/
733719
734   #define STV_VDP2_MPOFR_ ((stv_vdp2_regs[0x03c/4] >> 0)&0x0000ffff)
720   #define STV_VDP2_MPOFR_ ((state->m_vdp2_regs[0x03c/4] >> 0)&0x0000ffff)
735721
736722   #define STV_VDP2_RAMP_ ((STV_VDP2_MPOFR_ & 0x0007) >> 0)
737723   #define STV_VDP2_RBMP_ ((STV_VDP2_MPOFR_ & 0x0070) >> 4)
r11640r11641
743729       |    --    |    --    | N0MPA5   | N0MPA4   | N0MPA3   | N0MPA2   | N0MPA1   | N0MPA0   |
744730       \----------|----------|----------|----------|----------|----------|----------|---------*/
745731
746   #define STV_VDP2_MPABN0 ((stv_vdp2_regs[0x040/4] >> 16)&0x0000ffff)
732   #define STV_VDP2_MPABN0 ((state->m_vdp2_regs[0x040/4] >> 16)&0x0000ffff)
747733
748734   /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG0 */
749735   #define STV_VDP2_N0MPB ((STV_VDP2_MPABN0 & 0x3f00) >> 8)
r11640r11641
759745       |    --    |    --    | N0MPC5   | N0MPC4   | N0MPC3   | N0MPC2   | N0MPC1   | N0MPC0   |
760746       \----------|----------|----------|----------|----------|----------|----------|---------*/
761747
762   #define STV_VDP2_MPCDN0 ((stv_vdp2_regs[0x040/4] >> 0)&0x0000ffff)
748   #define STV_VDP2_MPCDN0 ((state->m_vdp2_regs[0x040/4] >> 0)&0x0000ffff)
763749
764750   /* N0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap NBG0 */
765751   #define STV_VDP2_N0MPD ((STV_VDP2_MPCDN0 & 0x3f00) >> 8)
r11640r11641
775761       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
776762       \----------|----------|----------|----------|----------|----------|----------|---------*/
777763
778   #define STV_VDP2_MPABN1 ((stv_vdp2_regs[0x044/4] >> 16)&0x0000ffff)
764   #define STV_VDP2_MPABN1 ((state->m_vdp2_regs[0x044/4] >> 16)&0x0000ffff)
779765
780766   /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG1 */
781767   #define STV_VDP2_N1MPB ((STV_VDP2_MPABN1 & 0x3f00) >> 8)
r11640r11641
790776       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
791777       \----------|----------|----------|----------|----------|----------|----------|---------*/
792778
793   #define STV_VDP2_MPCDN1 ((stv_vdp2_regs[0x044/4] >> 0)&0x0000ffff)
779   #define STV_VDP2_MPCDN1 ((state->m_vdp2_regs[0x044/4] >> 0)&0x0000ffff)
794780
795781   /* N0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap NBG0 */
796782   #define STV_VDP2_N1MPD ((STV_VDP2_MPCDN1 & 0x3f00) >> 8)
r11640r11641
806792       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
807793       \----------|----------|----------|----------|----------|----------|----------|---------*/
808794
809   #define STV_VDP2_MPABN2 ((stv_vdp2_regs[0x048/4] >> 16)&0x0000ffff)
795   #define STV_VDP2_MPABN2 ((state->m_vdp2_regs[0x048/4] >> 16)&0x0000ffff)
810796
811797   /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG2 */
812798   #define STV_VDP2_N2MPB ((STV_VDP2_MPABN2 & 0x3f00) >> 8)
r11640r11641
821807       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
822808       \----------|----------|----------|----------|----------|----------|----------|---------*/
823809
824   #define STV_VDP2_MPCDN2 ((stv_vdp2_regs[0x048/4] >> 0)&0x0000ffff)
810   #define STV_VDP2_MPCDN2 ((state->m_vdp2_regs[0x048/4] >> 0)&0x0000ffff)
825811
826812   /* N0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap NBG2 */
827813   #define STV_VDP2_N2MPD ((STV_VDP2_MPCDN2 & 0x3f00) >> 8)
r11640r11641
836822       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
837823       \----------|----------|----------|----------|----------|----------|----------|---------*/
838824
839   #define STV_VDP2_MPABN3 ((stv_vdp2_regs[0x04c/4] >> 16)&0x0000ffff)
825   #define STV_VDP2_MPABN3 ((state->m_vdp2_regs[0x04c/4] >> 16)&0x0000ffff)
840826
841827   /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG1 */
842828   #define STV_VDP2_N3MPB ((STV_VDP2_MPABN3 & 0x3f00) >> 8)
r11640r11641
852838       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
853839       \----------|----------|----------|----------|----------|----------|----------|---------*/
854840
855   #define STV_VDP2_MPCDN3 ((stv_vdp2_regs[0x04c/4] >> 0)&0x0000ffff)
841   #define STV_VDP2_MPCDN3 ((state->m_vdp2_regs[0x04c/4] >> 0)&0x0000ffff)
856842
857843   /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG0 */
858844   #define STV_VDP2_N3MPD ((STV_VDP2_MPCDN3 & 0x3f00) >> 8)
r11640r11641
867853       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
868854       \----------|----------|----------|----------|----------|----------|----------|---------*/
869855
870   #define STV_VDP2_MPABRA ((stv_vdp2_regs[0x050/4] >> 16)&0x0000ffff)
856   #define STV_VDP2_MPABRA ((state->m_vdp2_regs[0x050/4] >> 16)&0x0000ffff)
871857
872858   /* R0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap RBG0 */
873859   #define STV_VDP2_RAMPB ((STV_VDP2_MPABRA & 0x3f00) >> 8)
r11640r11641
883869       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
884870       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
885871       \----------|----------|----------|----------|----------|----------|----------|---------*/
886   #define STV_VDP2_MPCDRA ((stv_vdp2_regs[0x050/4] >> 0)&0x0000ffff)
872   #define STV_VDP2_MPCDRA ((state->m_vdp2_regs[0x050/4] >> 0)&0x0000ffff)
887873
888874   /* R0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap RBG0 */
889875   #define STV_VDP2_RAMPD ((STV_VDP2_MPCDRA & 0x3f00) >> 8)
r11640r11641
897883       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
898884       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
899885       \----------|----------|----------|----------|----------|----------|----------|---------*/
900   #define STV_VDP2_MPEFRA ((stv_vdp2_regs[0x054/4] >> 16)&0x0000ffff)
886   #define STV_VDP2_MPEFRA ((state->m_vdp2_regs[0x054/4] >> 16)&0x0000ffff)
901887
902888   /* R0MPB5 = lower 6 bits of Map Address of Plane F of Tilemap RBG0 */
903889   #define STV_VDP2_RAMPF ((STV_VDP2_MPEFRA & 0x3f00) >> 8)
r11640r11641
911897       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
912898       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
913899       \----------|----------|----------|----------|----------|----------|----------|---------*/
914   #define STV_VDP2_MPGHRA ((stv_vdp2_regs[0x054/4] >> 0)&0x0000ffff)
900   #define STV_VDP2_MPGHRA ((state->m_vdp2_regs[0x054/4] >> 0)&0x0000ffff)
915901
916902   /* R0MPB5 = lower 6 bits of Map Address of Plane H of Tilemap RBG0 */
917903   #define STV_VDP2_RAMPH ((STV_VDP2_MPGHRA & 0x3f00) >> 8)
r11640r11641
925911       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
926912       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
927913       \----------|----------|----------|----------|----------|----------|----------|---------*/
928   #define STV_VDP2_MPIJRA ((stv_vdp2_regs[0x058/4] >> 16)&0x0000ffff)
914   #define STV_VDP2_MPIJRA ((state->m_vdp2_regs[0x058/4] >> 16)&0x0000ffff)
929915
930916   /* R0MPB5 = lower 6 bits of Map Address of Plane J of Tilemap RBG0 */
931917   #define STV_VDP2_RAMPJ ((STV_VDP2_MPIJRA & 0x3f00) >> 8)
r11640r11641
939925       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
940926       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
941927       \----------|----------|----------|----------|----------|----------|----------|---------*/
942   #define STV_VDP2_MPKLRA ((stv_vdp2_regs[0x058/4] >> 0)&0x0000ffff)
928   #define STV_VDP2_MPKLRA ((state->m_vdp2_regs[0x058/4] >> 0)&0x0000ffff)
943929
944930   /* R0MPB5 = lower 6 bits of Map Address of Plane L of Tilemap RBG0 */
945931   #define STV_VDP2_RAMPL ((STV_VDP2_MPKLRA & 0x3f00) >> 8)
r11640r11641
953939       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
954940       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
955941       \----------|----------|----------|----------|----------|----------|----------|---------*/
956   #define STV_VDP2_MPMNRA ((stv_vdp2_regs[0x05c/4] >> 16)&0x0000ffff)
942   #define STV_VDP2_MPMNRA ((state->m_vdp2_regs[0x05c/4] >> 16)&0x0000ffff)
957943
958944   /* R0MPB5 = lower 6 bits of Map Address of Plane N of Tilemap RBG0 */
959945   #define STV_VDP2_RAMPN ((STV_VDP2_MPMNRA & 0x3f00) >> 8)
r11640r11641
967953       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
968954       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
969955       \----------|----------|----------|----------|----------|----------|----------|---------*/
970   #define STV_VDP2_MPOPRA ((stv_vdp2_regs[0x05c/4] >> 0)&0x0000ffff)
956   #define STV_VDP2_MPOPRA ((state->m_vdp2_regs[0x05c/4] >> 0)&0x0000ffff)
971957
972958   /* R0MPB5 = lower 6 bits of Map Address of Plane P of Tilemap RBG0 */
973959   #define STV_VDP2_RAMPP ((STV_VDP2_MPOPRA & 0x3f00) >> 8)
r11640r11641
982968       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
983969       \----------|----------|----------|----------|----------|----------|----------|---------*/
984970
985   #define STV_VDP2_MPABRB ((stv_vdp2_regs[0x060/4] >> 16)&0x0000ffff)
971   #define STV_VDP2_MPABRB ((state->m_vdp2_regs[0x060/4] >> 16)&0x0000ffff)
986972
987973   /* R0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap RBG0 */
988974   #define STV_VDP2_RBMPB ((STV_VDP2_MPABRB & 0x3f00) >> 8)
r11640r11641
998984       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
999985       \----------|----------|----------|----------|----------|----------|----------|---------*/
1000986
1001   #define STV_VDP2_MPCDRB ((stv_vdp2_regs[0x060/4] >> 0)&0x0000ffff)
987   #define STV_VDP2_MPCDRB ((state->m_vdp2_regs[0x060/4] >> 0)&0x0000ffff)
1002988
1003989   /* R0MPD5 = lower 6 bits of Map Address of Plane D of Tilemap RBG0 */
1004990   #define STV_VDP2_RBMPD ((STV_VDP2_MPCDRB & 0x3f00) >> 8)
r11640r11641
1013999       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
10141000       \----------|----------|----------|----------|----------|----------|----------|---------*/
10151001
1016   #define STV_VDP2_MPEFRB ((stv_vdp2_regs[0x064/4] >> 16)&0x0000ffff)
1002   #define STV_VDP2_MPEFRB ((state->m_vdp2_regs[0x064/4] >> 16)&0x0000ffff)
10171003
10181004   /* R0MPF5 = lower 6 bits of Map Address of Plane F of Tilemap RBG0 */
10191005   #define STV_VDP2_RBMPF ((STV_VDP2_MPEFRB & 0x3f00) >> 8)
r11640r11641
10281014       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
10291015       \----------|----------|----------|----------|----------|----------|----------|---------*/
10301016
1031   #define STV_VDP2_MPGHRB ((stv_vdp2_regs[0x064/4] >> 0)&0x0000ffff)
1017   #define STV_VDP2_MPGHRB ((state->m_vdp2_regs[0x064/4] >> 0)&0x0000ffff)
10321018
10331019   /* R0MPH5 = lower 6 bits of Map Address of Plane H of Tilemap RBG0 */
10341020   #define STV_VDP2_RBMPH ((STV_VDP2_MPGHRB & 0x3f00) >> 8)
r11640r11641
10431029       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
10441030       \----------|----------|----------|----------|----------|----------|----------|---------*/
10451031
1046   #define STV_VDP2_MPIJRB ((stv_vdp2_regs[0x068/4] >> 16)&0x0000ffff)
1032   #define STV_VDP2_MPIJRB ((state->m_vdp2_regs[0x068/4] >> 16)&0x0000ffff)
10471033
10481034   /* R0MPJ5 = lower 6 bits of Map Address of Plane J of Tilemap RBG0 */
10491035   #define STV_VDP2_RBMPJ ((STV_VDP2_MPIJRB & 0x3f00) >> 8)
r11640r11641
10581044       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
10591045       \----------|----------|----------|----------|----------|----------|----------|---------*/
10601046
1061   #define STV_VDP2_MPKLRB ((stv_vdp2_regs[0x068/4] >> 0)&0x0000ffff)
1047   #define STV_VDP2_MPKLRB ((state->m_vdp2_regs[0x068/4] >> 0)&0x0000ffff)
10621048
10631049   /* R0MPL5 = lower 6 bits of Map Address of Plane L of Tilemap RBG0 */
10641050   #define STV_VDP2_RBMPL ((STV_VDP2_MPKLRB & 0x3f00) >> 8)
r11640r11641
10731059       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
10741060       \----------|----------|----------|----------|----------|----------|----------|---------*/
10751061
1076   #define STV_VDP2_MPMNRB ((stv_vdp2_regs[0x06c/4] >> 16)&0x0000ffff)
1062   #define STV_VDP2_MPMNRB ((state->m_vdp2_regs[0x06c/4] >> 16)&0x0000ffff)
10771063
10781064   /* R0MPN5 = lower 6 bits of Map Address of Plane N of Tilemap RBG0 */
10791065   #define STV_VDP2_RBMPN ((STV_VDP2_MPMNRB & 0x3f00) >> 8)
r11640r11641
10881074       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
10891075       \----------|----------|----------|----------|----------|----------|----------|---------*/
10901076
1091   #define STV_VDP2_MPOPRB ((stv_vdp2_regs[0x06c/4] >> 0)&0x0000ffff)
1077   #define STV_VDP2_MPOPRB ((state->m_vdp2_regs[0x06c/4] >> 0)&0x0000ffff)
10921078
10931079   /* R0MPP5 = lower 6 bits of Map Address of Plane P of Tilemap RBG0 */
10941080   #define STV_VDP2_RBMPP ((STV_VDP2_MPOPRB & 0x3f00) >> 8)
r11640r11641
11031089       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11041090       \----------|----------|----------|----------|----------|----------|----------|---------*/
11051091
1106   #define STV_VDP2_SCXIN0 ((stv_vdp2_regs[0x070/4] >> 16)&0x0000ffff)
1092   #define STV_VDP2_SCXIN0 ((state->m_vdp2_regs[0x070/4] >> 16)&0x0000ffff)
11071093
11081094
11091095/* 180072 - Screen Scroll (NBG0, Horizontal Fractional Part)
r11640r11641
11191105       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
11201106       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11211107       \----------|----------|----------|----------|----------|----------|----------|---------*/
1122   #define STV_VDP2_SCYIN0 ((stv_vdp2_regs[0x074/4] >> 16)&0x0000ffff)
1108   #define STV_VDP2_SCYIN0 ((state->m_vdp2_regs[0x074/4] >> 16)&0x0000ffff)
11231109
11241110
11251111/* 180076 - Screen Scroll (NBG0, Vertical Fractional Part)
r11640r11641
11361122       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11371123       \----------|----------|----------|----------|----------|----------|----------|---------*/
11381124
1139   #define STV_VDP2_ZMXIN0 ((stv_vdp2_regs[0x078/4] >> 16)&0x0000ffff)
1140   #define STV_VDP2_ZMXN0   (stv_vdp2_regs[0x078/4] & 0x007ff00)
1125   #define STV_VDP2_ZMXIN0 ((state->m_vdp2_regs[0x078/4] >> 16)&0x0000ffff)
1126   #define STV_VDP2_ZMXN0   (state->m_vdp2_regs[0x078/4] & 0x007ff00)
11411127
11421128   #define STV_VDP2_N0ZMXI ((STV_VDP2_ZMXIN0 & 0x0007) >> 0)
11431129
r11640r11641
11481134       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11491135       \----------|----------|----------|----------|----------|----------|----------|---------*/
11501136
1151   #define STV_VDP2_ZMXDN0 ((stv_vdp2_regs[0x078/4] >> 0)&0x0000ffff)
1137   #define STV_VDP2_ZMXDN0 ((state->m_vdp2_regs[0x078/4] >> 0)&0x0000ffff)
11521138
11531139   #define STV_VDP2_N0ZMXD ((STV_VDP2_ZMXDN0 >> 8)& 0xff)
11541140
r11640r11641
11591145       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11601146       \----------|----------|----------|----------|----------|----------|----------|---------*/
11611147
1162   #define STV_VDP2_ZMYIN0 ((stv_vdp2_regs[0x07c/4] >> 16)&0x0000ffff)
1163   #define STV_VDP2_ZMYN0   (stv_vdp2_regs[0x07c/4] & 0x007ff00)
1148   #define STV_VDP2_ZMYIN0 ((state->m_vdp2_regs[0x07c/4] >> 16)&0x0000ffff)
1149   #define STV_VDP2_ZMYN0   (state->m_vdp2_regs[0x07c/4] & 0x007ff00)
11641150
11651151   #define STV_VDP2_N0ZMYI ((STV_VDP2_ZMYIN0 & 0x0007) >> 0)
11661152
r11640r11641
11711157       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11721158       \----------|----------|----------|----------|----------|----------|----------|---------*/
11731159
1174   #define STV_VDP2_ZMYDN0 ((stv_vdp2_regs[0x07c/4] >> 0)&0x0000ffff)
1160   #define STV_VDP2_ZMYDN0 ((state->m_vdp2_regs[0x07c/4] >> 0)&0x0000ffff)
11751161
11761162   #define STV_VDP2_N0ZMYD ((STV_VDP2_ZMYDN0 >> 8)& 0xff)
11771163
r11640r11641
11821168       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11831169       \----------|----------|----------|----------|----------|----------|----------|---------*/
11841170
1185   #define STV_VDP2_SCXIN1 ((stv_vdp2_regs[0x080/4] >> 16)&0x0000ffff)
1171   #define STV_VDP2_SCXIN1 ((state->m_vdp2_regs[0x080/4] >> 16)&0x0000ffff)
11861172
11871173/* 180082 - Screen Scroll (NBG1, Horizontal Fractional Part)
11881174 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
11981184       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
11991185       \----------|----------|----------|----------|----------|----------|----------|---------*/
12001186
1201   #define STV_VDP2_SCYIN1 ((stv_vdp2_regs[0x084/4] >> 16)&0x0000ffff)
1187   #define STV_VDP2_SCYIN1 ((state->m_vdp2_regs[0x084/4] >> 16)&0x0000ffff)
12021188
12031189/* 180086 - Screen Scroll (NBG1, Vertical Fractional Part)
12041190 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
12141200       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12151201       \----------|----------|----------|----------|----------|----------|----------|---------*/
12161202
1217   #define STV_VDP2_ZMXIN1 ((stv_vdp2_regs[0x088/4] >> 16)&0x0000ffff)
1218   #define STV_VDP2_ZMXN1   (stv_vdp2_regs[0x088/4] & 0x007ff00)
1203   #define STV_VDP2_ZMXIN1 ((state->m_vdp2_regs[0x088/4] >> 16)&0x0000ffff)
1204   #define STV_VDP2_ZMXN1   (state->m_vdp2_regs[0x088/4] & 0x007ff00)
12191205
12201206   #define STV_VDP2_N1ZMXI ((STV_VDP2_ZMXIN1 & 0x0007) >> 0)
12211207
r11640r11641
12261212       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12271213       \----------|----------|----------|----------|----------|----------|----------|---------*/
12281214
1229   #define STV_VDP2_ZMXDN1 ((stv_vdp2_regs[0x088/4] >> 0)&0x0000ffff)
1215   #define STV_VDP2_ZMXDN1 ((state->m_vdp2_regs[0x088/4] >> 0)&0x0000ffff)
12301216
12311217   #define STV_VDP2_N1ZMXD ((STV_VDP2_ZMXDN1 >> 8)& 0xff)
12321218
r11640r11641
12371223       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12381224       \----------|----------|----------|----------|----------|----------|----------|---------*/
12391225
1240   #define STV_VDP2_ZMYIN1 ((stv_vdp2_regs[0x08c/4] >> 16)&0x0000ffff)
1241   #define STV_VDP2_ZMYN1   (stv_vdp2_regs[0x08c/4] & 0x007ff00)
1226   #define STV_VDP2_ZMYIN1 ((state->m_vdp2_regs[0x08c/4] >> 16)&0x0000ffff)
1227   #define STV_VDP2_ZMYN1   (state->m_vdp2_regs[0x08c/4] & 0x007ff00)
12421228
12431229   #define STV_VDP2_N1ZMYI ((STV_VDP2_ZMYIN1 & 0x0007) >> 0)
12441230
r11640r11641
12491235       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12501236       \----------|----------|----------|----------|----------|----------|----------|---------*/
12511237
1252   #define STV_VDP2_ZMYDN1 ((stv_vdp2_regs[0x08c/4] >> 0)&0x0000ffff)
1238   #define STV_VDP2_ZMYDN1 ((state->m_vdp2_regs[0x08c/4] >> 0)&0x0000ffff)
12531239
12541240   #define STV_VDP2_N1ZMYD ((STV_VDP2_ZMYDN1 >> 8)& 0xff)
12551241
r11640r11641
12601246       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12611247       \----------|----------|----------|----------|----------|----------|----------|---------*/
12621248
1263   #define STV_VDP2_SCXN2 ((stv_vdp2_regs[0x090/4] >> 16)&0x0000ffff)
1249   #define STV_VDP2_SCXN2 ((state->m_vdp2_regs[0x090/4] >> 16)&0x0000ffff)
12641250
12651251/* 180092 - SCYN2 - Screen Scroll (NBG2, Vertical)
12661252 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
12691255       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12701256       \----------|----------|----------|----------|----------|----------|----------|---------*/
12711257
1272   #define STV_VDP2_SCYN2 ((stv_vdp2_regs[0x090/4] >> 0)&0x0000ffff)
1258   #define STV_VDP2_SCYN2 ((state->m_vdp2_regs[0x090/4] >> 0)&0x0000ffff)
12731259
12741260/* 180094 - SCXN3 - Screen Scroll (NBG3, Horizontal)
12751261 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
12781264       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12791265       \----------|----------|----------|----------|----------|----------|----------|---------*/
12801266
1281   #define STV_VDP2_SCXN3 ((stv_vdp2_regs[0x094/4] >> 16)&0x0000ffff)
1267   #define STV_VDP2_SCXN3 ((state->m_vdp2_regs[0x094/4] >> 16)&0x0000ffff)
12821268
12831269/* 180096 - SCYN3 - Screen Scroll (NBG3, Vertical)
12841270 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
12871273       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
12881274       \----------|----------|----------|----------|----------|----------|----------|---------*/
12891275
1290   #define STV_VDP2_SCYN3 ((stv_vdp2_regs[0x094/4] >> 0)&0x0000ffff)
1276   #define STV_VDP2_SCYN3 ((state->m_vdp2_regs[0x094/4] >> 0)&0x0000ffff)
12911277
12921278/* 180098 - Reduction Enable
12931279 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
12961282       |    --    |    --    |    --    |    --    |    --    |    --    | N0ZMQT   | N0ZMHF   |
12971283       \----------|----------|----------|----------|----------|----------|----------|---------*/
12981284
1299   #define STV_VDP2_ZMCTL ((stv_vdp2_regs[0x098/4] >> 16)&0x0000ffff)
1285   #define STV_VDP2_ZMCTL ((state->m_vdp2_regs[0x098/4] >> 16)&0x0000ffff)
13001286
13011287   #define STV_VDP2_N1ZMQT  ((STV_VDP2_ZMCTL & 0x0200) >> 9)
13021288   #define STV_VDP2_N1ZMHF  ((STV_VDP2_ZMCTL & 0x0100) >> 8)
r11640r11641
13101296       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
13111297       \----------|----------|----------|----------|----------|----------|----------|---------*/
13121298
1313   #define STV_VDP2_SCRCTL ((stv_vdp2_regs[0x098/4] >> 0)&0x0000ffff)
1299   #define STV_VDP2_SCRCTL ((state->m_vdp2_regs[0x098/4] >> 0)&0x0000ffff)
13141300
13151301   #define STV_VDP2_N1LSS  ((STV_VDP2_SCRCTL & 0x3000) >> 12)
13161302   #define STV_VDP2_N1LZMX ((STV_VDP2_SCRCTL & 0x0800) >> 11)
r11640r11641
13451331       \----------|----------|----------|----------|----------|----------|----------|---------*/
13461332
13471333   /*bit 2 unused when VRAM = 4 Mbits*/
1348   #define STV_VDP2_LSTA0U ((stv_vdp2_regs[0x0a0/4] >> 16)&0x00000003)
1334   #define STV_VDP2_LSTA0U ((state->m_vdp2_regs[0x0a0/4] >> 16)&0x00000003)
13491335
13501336/* 1800a2 - LSTA0L - Line Scroll Table Address (NBG0)
13511337 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
13541340       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
13551341       \----------|----------|----------|----------|----------|----------|----------|---------*/
13561342
1357   #define STV_VDP2_LSTA0L ((stv_vdp2_regs[0x0a0/4] >> 0)&0x0000fffe)
1343   #define STV_VDP2_LSTA0L ((state->m_vdp2_regs[0x0a0/4] >> 0)&0x0000fffe)
13581344
13591345/* 1800a4 - LSTA1U - Line Scroll Table Address (NBG1)
13601346 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
13641350       \----------|----------|----------|----------|----------|----------|----------|---------*/
13651351
13661352   /*bit 2 unused when VRAM = 4 Mbits*/
1367   #define STV_VDP2_LSTA1U ((stv_vdp2_regs[0x0a4/4] >> 16)&0x00000003)
1353   #define STV_VDP2_LSTA1U ((state->m_vdp2_regs[0x0a4/4] >> 16)&0x00000003)
13681354
13691355/* 1800a6 - LSTA1L - Line Scroll Table Address (NBG1)
13701356 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
13731359       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
13741360       \----------|----------|----------|----------|----------|----------|----------|---------*/
13751361
1376   #define STV_VDP2_LSTA1L ((stv_vdp2_regs[0x0a4/4] >> 0)&0x0000fffe)
1362   #define STV_VDP2_LSTA1L ((state->m_vdp2_regs[0x0a4/4] >> 0)&0x0000fffe)
13771363
13781364/* 1800a8 - LCTAU - Line Colour Screen Table Address
13791365 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
13821368       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
13831369       \----------|----------|----------|----------|----------|----------|----------|---------*/
13841370
1385   #define STV_VDP2_LCTAU   ((stv_vdp2_regs[0x0a8/4] >> 16) & 0xffff)
1371   #define STV_VDP2_LCTAU   ((state->m_vdp2_regs[0x0a8/4] >> 16) & 0xffff)
13861372   #define STV_VDP2_LCCLMD   ((STV_VDP2_LCTAU & 0x8000) >> 15)
13871373
13881374/* 1800aa - LCTAL - Line Colour Screen Table Address
r11640r11641
13911377       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
13921378       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
13931379       \----------|----------|----------|----------|----------|----------|----------|---------*/
1394   #define STV_VDP2_LCTAL   ((stv_vdp2_regs[0x0a8/4] >> 0) & 0xffff)
1380   #define STV_VDP2_LCTAL   ((state->m_vdp2_regs[0x0a8/4] >> 0) & 0xffff)
13951381
1396   #define STV_VDP2_LCTA   (stv_vdp2_regs[0x0a8/4] & 0x0003ffff)
1382   #define STV_VDP2_LCTA   (state->m_vdp2_regs[0x0a8/4] & 0x0003ffff)
13971383
13981384/* 1800ac - Back Screen Table Address
13991385 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
14091395       |  BKTA7   |  BKTA7   |  BKTA6   |  BKTA5   |  BKTA4   |  BKTA3   |  BKTA2   |  BKTA0   |
14101396       \----------|----------|----------|----------|----------|----------|----------|---------*/
14111397
1412   #define STV_VDP2_BKTA_UL (stv_vdp2_regs[0x0ac/4])
1398   #define STV_VDP2_BKTA_UL (state->m_vdp2_regs[0x0ac/4])
14131399
14141400   #define STV_VDP2_BKCLMD ((STV_VDP2_BKTA_UL & 0x80000000) >> 31)
14151401   #define STV_VDP2_BKTA   ((STV_VDP2_BKTA_UL & 0x0003ffff) >> 0)
r11640r11641
14231409       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
14241410       \----------|----------|----------|----------|----------|----------|----------|---------*/
14251411
1426   #define STV_VDP2_RPMD   ((stv_vdp2_regs[0x0b0/4] >> 16) & 0x00000003)
1412   #define STV_VDP2_RPMD   ((state->m_vdp2_regs[0x0b0/4] >> 16) & 0x00000003)
14271413
14281414/* 1800b2 - RPRCTL - Rotation Parameter Read Control
14291415 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
14321418       |    --    |    --    |    --    |    --    |    --    | RAKASTRE | RAYSTRE  | RBXSTRE  |
14331419       \----------|----------|----------|----------|----------|----------|----------|---------*/
14341420
1435   #define STV_VDP2_RPRCTL      ((stv_vdp2_regs[0x0b0/4] >> 0)&0x0000ffff)
1421   #define STV_VDP2_RPRCTL      ((state->m_vdp2_regs[0x0b0/4] >> 0)&0x0000ffff)
14361422   #define STV_VDP2_RBKASTRE   ((STV_VDP2_RPRCTL & 0x0400) >> 10)
14371423   #define STV_VDP2_RBYSTRE   ((STV_VDP2_RPRCTL & 0x0200) >> 9)
14381424   #define STV_VDP2_RBXSTRE   ((STV_VDP2_RPRCTL & 0x0100) >> 8)
r11640r11641
14471433       |    --    |    --    |    --    |  RAKLCE  |  RAKMD1  |  RAKMD0  |  RAKDBS  |   RAKTE  |
14481434       \----------|----------|----------|----------|----------|----------|----------|---------*/
14491435
1450   #define   STV_VDP2_KTCTL   ((stv_vdp2_regs[0x0b4/4] >> 16) & 0x0000ffff)
1436   #define   STV_VDP2_KTCTL   ((state->m_vdp2_regs[0x0b4/4] >> 16) & 0x0000ffff)
14511437   #define STV_VDP2_RBKLCE   ((STV_VDP2_KTCTL & 0x1000) >> 12)
14521438   #define STV_VDP2_RBKMD   ((STV_VDP2_KTCTL & 0x0c00) >> 10)
14531439   #define STV_VDP2_RBKDBS   ((STV_VDP2_KTCTL & 0x0200) >> 9)
r11640r11641
14641450       |    --    |    --    |    --    |    --    |    --    | RAKTAOS2 | RAKTAOS1 | RAKTAOS0 |
14651451       \----------|----------|----------|----------|----------|----------|----------|---------*/
14661452
1467   #define STV_VDP2_KTAOF   ((stv_vdp2_regs[0x0b4/4] >> 0) & 0x0000ffff)
1453   #define STV_VDP2_KTAOF   ((state->m_vdp2_regs[0x0b4/4] >> 0) & 0x0000ffff)
14681454   #define STV_VDP2_RBKTAOS ((STV_VDP2_KTAOF & 0x0700) >> 8)
14691455   #define STV_VDP2_RAKTAOS ((STV_VDP2_KTAOF & 0x0007) >> 0)
14701456
r11640r11641
14751461       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
14761462       \----------|----------|----------|----------|----------|----------|----------|---------*/
14771463
1478   #define STV_VDP2_OVPNRA   ((stv_vdp2_regs[0x0b8/4] >> 16) & 0x0000ffff)
1464   #define STV_VDP2_OVPNRA   ((state->m_vdp2_regs[0x0b8/4] >> 16) & 0x0000ffff)
14791465
14801466/* 1800ba - Screen Over Pattern Name (Rotation Parameter B)
14811467 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
14841470       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
14851471       \----------|----------|----------|----------|----------|----------|----------|---------*/
14861472
1487   #define STV_VDP2_OVPNRB ((stv_vdp2_regs[0x0b8/4] >> 0) & 0x0000ffff)
1473   #define STV_VDP2_OVPNRB ((state->m_vdp2_regs[0x0b8/4] >> 0) & 0x0000ffff)
14881474
14891475/* 1800bc - RPTAU - Rotation Parameter Table Address (Rotation Parameter A,B)
14901476 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
14921478       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
14931479       |    --    |    --    |    --    |    --    |    --    |  RPTA18  |  RPTA17  |  RPTA16  |
14941480       \----------|----------|----------|----------|----------|----------|----------|---------*/
1495   #define STV_VDP2_RPTAU   ((stv_vdp2_regs[0x0bc/4] >> 16) & 0x00000007)
1481   #define STV_VDP2_RPTAU   ((state->m_vdp2_regs[0x0bc/4] >> 16) & 0x00000007)
14961482
14971483/* 1800be - RPTAL - Rotation Parameter Table Address (Rotation Parameter A,B)
14981484 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
15011487       |   RPTA7  |   RPTA6  |   RPTA5  |   RPTA4  |   RPTA3  |   RPTA2  |   RPTA1  |    --    |
15021488       \----------|----------|----------|----------|----------|----------|----------|---------*/
15031489
1504   #define STV_VDP2_RPTAL   ((stv_vdp2_regs[0x0bc/4] >> 0) & 0x0000fffe)
1490   #define STV_VDP2_RPTAL   ((state->m_vdp2_regs[0x0bc/4] >> 0) & 0x0000fffe)
15051491
15061492/* 1800c0 - Window Position (W0, Horizontal Start Point)
15071493 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
15101496       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15111497       \----------|----------|----------|----------|----------|----------|----------|---------*/
15121498
1513   #define STV_VDP2_WPSX0 ((stv_vdp2_regs[0x0c0/4] >> 16)&0x0000ffff)
1499   #define STV_VDP2_WPSX0 ((state->m_vdp2_regs[0x0c0/4] >> 16)&0x0000ffff)
15141500
15151501   #define STV_VDP2_W0SX ((STV_VDP2_WPSX0 & 0x03ff) >> 0)
15161502
r11640r11641
15211507       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15221508       \----------|----------|----------|----------|----------|----------|----------|---------*/
15231509
1524   #define STV_VDP2_WPSY0 ((stv_vdp2_regs[0x0c0/4] >> 0)&0x0000ffff)
1510   #define STV_VDP2_WPSY0 ((state->m_vdp2_regs[0x0c0/4] >> 0)&0x0000ffff)
15251511
15261512   #define STV_VDP2_W0SY ((STV_VDP2_WPSY0 & 0x03ff) >> 0)
15271513
r11640r11641
15321518       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15331519       \----------|----------|----------|----------|----------|----------|----------|---------*/
15341520
1535   #define STV_VDP2_WPEX0 ((stv_vdp2_regs[0x0c4/4] >> 16)&0x0000ffff)
1521   #define STV_VDP2_WPEX0 ((state->m_vdp2_regs[0x0c4/4] >> 16)&0x0000ffff)
15361522
15371523   #define STV_VDP2_W0EX ((STV_VDP2_WPEX0 & 0x03ff) >> 0)
15381524
r11640r11641
15431529       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15441530       \----------|----------|----------|----------|----------|----------|----------|---------*/
15451531
1546   #define STV_VDP2_WPEY0 ((stv_vdp2_regs[0x0c4/4] >> 0)&0x0000ffff)
1532   #define STV_VDP2_WPEY0 ((state->m_vdp2_regs[0x0c4/4] >> 0)&0x0000ffff)
15471533
15481534   #define STV_VDP2_W0EY ((STV_VDP2_WPEY0 & 0x03ff) >> 0)
15491535
r11640r11641
15541540       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15551541       \----------|----------|----------|----------|----------|----------|----------|---------*/
15561542
1557   #define STV_VDP2_WPSX1 ((stv_vdp2_regs[0x0c8/4] >> 16)&0x0000ffff)
1543   #define STV_VDP2_WPSX1 ((state->m_vdp2_regs[0x0c8/4] >> 16)&0x0000ffff)
15581544
15591545   #define STV_VDP2_W1SX ((STV_VDP2_WPSX1 & 0x03ff) >> 0)
15601546
r11640r11641
15651551       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15661552       \----------|----------|----------|----------|----------|----------|----------|---------*/
15671553
1568   #define STV_VDP2_WPSY1 ((stv_vdp2_regs[0x0c8/4] >> 0)&0x0000ffff)
1554   #define STV_VDP2_WPSY1 ((state->m_vdp2_regs[0x0c8/4] >> 0)&0x0000ffff)
15691555
15701556   #define STV_VDP2_W1SY ((STV_VDP2_WPSY1 & 0x03ff) >> 0)
15711557
r11640r11641
15761562       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15771563       \----------|----------|----------|----------|----------|----------|----------|---------*/
15781564
1579   #define STV_VDP2_WPEX1 ((stv_vdp2_regs[0x0cc/4] >> 16)&0x0000ffff)
1565   #define STV_VDP2_WPEX1 ((state->m_vdp2_regs[0x0cc/4] >> 16)&0x0000ffff)
15801566
15811567   #define STV_VDP2_W1EX ((STV_VDP2_WPEX1 & 0x03ff) >> 0)
15821568
r11640r11641
15871573       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15881574       \----------|----------|----------|----------|----------|----------|----------|---------*/
15891575
1590   #define STV_VDP2_WPEY1 ((stv_vdp2_regs[0x0cc/4] >> 0)&0x0000ffff)
1576   #define STV_VDP2_WPEY1 ((state->m_vdp2_regs[0x0cc/4] >> 0)&0x0000ffff)
15911577
15921578   #define STV_VDP2_W1EY ((STV_VDP2_WPEY1 & 0x03ff) >> 0)
15931579
r11640r11641
15981584       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
15991585       \----------|----------|----------|----------|----------|----------|----------|---------*/
16001586
1601   #define STV_VDP2_WCTLA ((stv_vdp2_regs[0x0d0/4] >> 16)&0x0000ffff)
1587   #define STV_VDP2_WCTLA ((state->m_vdp2_regs[0x0d0/4] >> 16)&0x0000ffff)
16021588   #define STV_VDP2_N1LOG ((STV_VDP2_WCTLA & 0x8000) >> 15)
16031589   #define STV_VDP2_N1SWE ((STV_VDP2_WCTLA & 0x2000) >> 13)
16041590   #define STV_VDP2_N1SWA ((STV_VDP2_WCTLA & 0x1000) >> 12)
r11640r11641
16211607       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
16221608       \----------|----------|----------|----------|----------|----------|----------|---------*/
16231609
1624   #define STV_VDP2_WCTLB ((stv_vdp2_regs[0x0d0/4] >> 0)&0x0000ffff)
1610   #define STV_VDP2_WCTLB ((state->m_vdp2_regs[0x0d0/4] >> 0)&0x0000ffff)
16251611   #define STV_VDP2_N3LOG ((STV_VDP2_WCTLB & 0x8000) >> 15)
16261612   #define STV_VDP2_N3SWE ((STV_VDP2_WCTLB & 0x2000) >> 13)
16271613   #define STV_VDP2_N3SWA ((STV_VDP2_WCTLB & 0x1000) >> 12)
r11640r11641
16441630       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
16451631       \----------|----------|----------|----------|----------|----------|----------|---------*/
16461632
1647   #define STV_VDP2_WCTLC ((stv_vdp2_regs[0x0d4/4] >> 16)&0x0000ffff)
1633   #define STV_VDP2_WCTLC ((state->m_vdp2_regs[0x0d4/4] >> 16)&0x0000ffff)
16481634   #define STV_VDP2_SPLOG ((STV_VDP2_WCTLC & 0x8000) >> 15)
16491635   #define STV_VDP2_SPSWE ((STV_VDP2_WCTLC & 0x2000) >> 13)
16501636   #define STV_VDP2_SPSWA ((STV_VDP2_WCTLC & 0x1000) >> 12)
r11640r11641
17021688       |    --    |    --    |  SPCLMD  | SPWINEN  |  SPTYPE3 |  SPTYPE2 |  SPTYPE1 |  SPTYPE0 |
17031689       \----------|----------|----------|----------|----------|----------|----------|---------*/
17041690
1705   #define STV_VDP2_SPCTL      ((stv_vdp2_regs[0xe0/4] >> 16)&0x0000ffff)
1691   #define STV_VDP2_SPCTL      ((state->m_vdp2_regs[0xe0/4] >> 16)&0x0000ffff)
17061692   #define STV_VDP2_SPCCCS      ((STV_VDP2_SPCTL & 0x3000) >> 12)
17071693   #define STV_VDP2_SPCCN      ((STV_VDP2_SPCTL & 0x700) >> 8)
17081694   #define STV_VDP2_SPCLMD      ((STV_VDP2_SPCTL & 0x20) >> 5)
r11640r11641
17161702       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
17171703       \----------|----------|----------|----------|----------|----------|----------|---------*/
17181704
1719   #define STV_VDP2_SDCTL      ((stv_vdp2_regs[0x0e0/4] >> 0) & 0x0000ffff)
1705   #define STV_VDP2_SDCTL      ((state->m_vdp2_regs[0x0e0/4] >> 0) & 0x0000ffff)
17201706
17211707/* 1800e4 - CRAOFA - Colour Ram Address Offset (NBG0 - NBG3)
17221708 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
17251711       |    --    | N1CAOS2  | N1CAOS1  | N1CAOS0  |    --    | N0CAOS2  | N0CAOS1  | N0CAOS0  |
17261712       \----------|----------|----------|----------|----------|----------|----------|---------*/
17271713
1728   #define STV_VDP2_CRAOFA ((stv_vdp2_regs[0x0e4/4] >> 16)&0x0000ffff)
1714   #define STV_VDP2_CRAOFA ((state->m_vdp2_regs[0x0e4/4] >> 16)&0x0000ffff)
17291715
17301716   /* NxCAOS =  */
17311717   #define STV_VDP2_N0CAOS ((STV_VDP2_CRAOFA & 0x0007) >> 0)
r11640r11641
17401726       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
17411727       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
17421728       \----------|----------|----------|----------|----------|----------|----------|---------*/
1743   #define STV_VDP2_CRAOFB ((stv_vdp2_regs[0x0e4/4] >> 0)&0x0000ffff)
1729   #define STV_VDP2_CRAOFB ((state->m_vdp2_regs[0x0e4/4] >> 0)&0x0000ffff)
17441730   #define STV_VDP2_R0CAOS ((STV_VDP2_CRAOFB & 0x0007) >> 0)
17451731   #define STV_VDP2_SPCAOS ((STV_VDP2_CRAOFB & 0x0070) >> 4)
17461732
r11640r11641
17511737       |    --    |    --    |  SPLCEN  |  R0LCEN  |  N3LCEN  |  N2LCEN  |  N1LCEN  | N0LCEN   |
17521738       \----------|----------|----------|----------|----------|----------|----------|---------*/
17531739
1754   #define STV_VDP2_LNCLEN   ((stv_vdp2_regs[0x0e8/4] >> 16)&0x0000ffff)
1740   #define STV_VDP2_LNCLEN   ((state->m_vdp2_regs[0x0e8/4] >> 16)&0x0000ffff)
17551741   #define STV_VDP2_SPLCEN   ((STV_VDP2_LNCLEN & 0x0020) >> 5)
17561742   #define STV_VDP2_R0LCEN   ((STV_VDP2_LNCLEN & 0x0010) >> 4)
17571743   #define STV_VDP2_N3LCEN   ((STV_VDP2_LNCLEN & 0x0008) >> 3)
r11640r11641
17731759       |    --    |  SPCCEN  |  LCCCEN  |  R0CCEN  |  N3CCEN  |  N2CCEN  |  N1CCEN  |  N0CCEN  |
17741760       \----------|----------|----------|----------|----------|----------|----------|---------*/
17751761
1776   #define STV_VDP2_CCCR      ((stv_vdp2_regs[0xec/4]>>16)&0x0000ffff)
1762   #define STV_VDP2_CCCR      ((state->m_vdp2_regs[0xec/4]>>16)&0x0000ffff)
17771763   #define STV_VDP2_CCMD      ((STV_VDP2_CCCR & 0x100) >> 8)
17781764   #define STV_VDP2_SPCCEN      ((STV_VDP2_CCCR & 0x40) >> 6)
17791765   #define STV_VDP2_LCCCEN      ((STV_VDP2_CCCR & 0x20) >> 5)
r11640r11641
17981784       |    --    |    --    |    --    |    --    |    --    |  S0PRIN2 |  S0PRIN1 |  S0PRIN0 |
17991785       \----------|----------|----------|----------|----------|----------|----------|---------*/
18001786
1801   #define STV_VDP2_PRISA      ((stv_vdp2_regs[0xf0/4] >> 16) & 0x0000ffff)
1787   #define STV_VDP2_PRISA      ((state->m_vdp2_regs[0xf0/4] >> 16) & 0x0000ffff)
18021788   #define STV_VDP2_S1PRIN      ((STV_VDP2_PRISA & 0x0700) >> 8)
18031789   #define STV_VDP2_S0PRIN      ((STV_VDP2_PRISA & 0x0007) >> 0)
18041790
r11640r11641
18091795       |    --    |    --    |    --    |    --    |    --    |  S2PRIN2 |  S2PRIN1 |  S2PRIN0 |
18101796       \----------|----------|----------|----------|----------|----------|----------|---------*/
18111797
1812   #define STV_VDP2_PRISB      ((stv_vdp2_regs[0xf0/4] >> 0) & 0x0000ffff)
1798   #define STV_VDP2_PRISB      ((state->m_vdp2_regs[0xf0/4] >> 0) & 0x0000ffff)
18131799   #define STV_VDP2_S3PRIN      ((STV_VDP2_PRISB & 0x0700) >> 8)
18141800   #define STV_VDP2_S2PRIN      ((STV_VDP2_PRISB & 0x0007) >> 0)
18151801
r11640r11641
18201806       |    --    |    --    |    --    |    --    |    --    |  S4PRIN2 |  S4PRIN1 |  S4PRIN0 |
18211807       \----------|----------|----------|----------|----------|----------|----------|---------*/
18221808
1823   #define STV_VDP2_PRISC      ((stv_vdp2_regs[0xf4/4] >> 16) & 0x0000ffff)
1809   #define STV_VDP2_PRISC      ((state->m_vdp2_regs[0xf4/4] >> 16) & 0x0000ffff)
18241810   #define STV_VDP2_S5PRIN      ((STV_VDP2_PRISC & 0x0700) >> 8)
18251811   #define STV_VDP2_S4PRIN      ((STV_VDP2_PRISC & 0x0007) >> 0)
18261812
r11640r11641
18311817       |    --    |    --    |    --    |    --    |    --    |  S6PRIN2 |  S6PRIN1 |  S6PRIN0 |
18321818       \----------|----------|----------|----------|----------|----------|----------|---------*/
18331819
1834   #define STV_VDP2_PRISD      ((stv_vdp2_regs[0xf4/4] >> 0) & 0x0000ffff)
1820   #define STV_VDP2_PRISD      ((state->m_vdp2_regs[0xf4/4] >> 0) & 0x0000ffff)
18351821   #define STV_VDP2_S7PRIN      ((STV_VDP2_PRISD & 0x0700) >> 8)
18361822   #define STV_VDP2_S6PRIN      ((STV_VDP2_PRISD & 0x0007) >> 0)
18371823
r11640r11641
18431829       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
18441830       \----------|----------|----------|----------|----------|----------|----------|---------*/
18451831
1846   #define STV_VDP2_PRINA ((stv_vdp2_regs[0x0f8/4] >> 16)&0x0000ffff)
1832   #define STV_VDP2_PRINA ((state->m_vdp2_regs[0x0f8/4] >> 16)&0x0000ffff)
18471833
18481834   #define STV_VDP2_N1PRIN ((STV_VDP2_PRINA & 0x0700) >> 8)
18491835   #define STV_VDP2_N0PRIN ((STV_VDP2_PRINA & 0x0007) >> 0)
r11640r11641
18551841       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
18561842       \----------|----------|----------|----------|----------|----------|----------|---------*/
18571843
1858   #define STV_VDP2_PRINB ((stv_vdp2_regs[0x0f8/4] >> 0)&0x0000ffff)
1844   #define STV_VDP2_PRINB ((state->m_vdp2_regs[0x0f8/4] >> 0)&0x0000ffff)
18591845
18601846   #define STV_VDP2_N3PRIN ((STV_VDP2_PRINB & 0x0700) >> 8)
18611847   #define STV_VDP2_N2PRIN ((STV_VDP2_PRINB & 0x0007) >> 0)
r11640r11641
18661852       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
18671853       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
18681854       \----------|----------|----------|----------|----------|----------|----------|---------*/
1869   #define STV_VDP2_PRIR ((stv_vdp2_regs[0x0fc/4] >> 16)&0x0000ffff)
1855   #define STV_VDP2_PRIR ((state->m_vdp2_regs[0x0fc/4] >> 16)&0x0000ffff)
18701856
18711857   #define STV_VDP2_R0PRIN ((STV_VDP2_PRIR & 0x0007) >> 0)
18721858
r11640r11641
18841870       |    --    |    --    |    --    |  S0CCRT4 |  S0CCRT3 |  S0CCRT2 |  S0CCRT1 |  S0CCRT0 |
18851871       \----------|----------|----------|----------|----------|----------|----------|---------*/
18861872
1887   #define STV_VDP2_CCRSA      ((stv_vdp2_regs[0x100/4] >> 16) & 0x0000ffff)
1873   #define STV_VDP2_CCRSA      ((state->m_vdp2_regs[0x100/4] >> 16) & 0x0000ffff)
18881874   #define STV_VDP2_S1CCRT      ((STV_VDP2_CCRSA & 0x1f00) >> 8)
18891875   #define STV_VDP2_S0CCRT      ((STV_VDP2_CCRSA & 0x001f) >> 0)
18901876
r11640r11641
18951881       |    --    |    --    |    --    |  S2CCRT4 |  S2CCRT3 |  S2CCRT2 |  S2CCRT1 |  S2CCRT0 |
18961882       \----------|----------|----------|----------|----------|----------|----------|---------*/
18971883
1898   #define STV_VDP2_CCRSB      ((stv_vdp2_regs[0x100/4] >> 0) & 0x0000ffff)
1884   #define STV_VDP2_CCRSB      ((state->m_vdp2_regs[0x100/4] >> 0) & 0x0000ffff)
18991885   #define STV_VDP2_S3CCRT      ((STV_VDP2_CCRSB & 0x1f00) >> 8)
19001886   #define STV_VDP2_S2CCRT      ((STV_VDP2_CCRSB & 0x001f) >> 0)
19011887
r11640r11641
19061892       |    --    |    --    |    --    |  S4CCRT4 |  S4CCRT3 |  S4CCRT2 |  S4CCRT1 |  S4CCRT0 |
19071893       \----------|----------|----------|----------|----------|----------|----------|---------*/
19081894
1909   #define STV_VDP2_CCRSC      ((stv_vdp2_regs[0x104/4 ]>> 16) & 0x0000ffff)
1895   #define STV_VDP2_CCRSC      ((state->m_vdp2_regs[0x104/4 ]>> 16) & 0x0000ffff)
19101896   #define STV_VDP2_S5CCRT      ((STV_VDP2_CCRSC & 0x1f00) >> 8)
19111897   #define STV_VDP2_S4CCRT      ((STV_VDP2_CCRSC & 0x001f) >> 0)
19121898
r11640r11641
19171903       |    --    |    --    |    --    |  S6CCRT4 |  S6CCRT3 |  S6CCRT2 |  S6CCRT1 |  S6CCRT0 |
19181904       \----------|----------|----------|----------|----------|----------|----------|---------*/
19191905
1920   #define STV_VDP2_CCRSD      ((stv_vdp2_regs[0x104/4 ]>> 0) & 0x0000ffff)
1906   #define STV_VDP2_CCRSD      ((state->m_vdp2_regs[0x104/4 ]>> 0) & 0x0000ffff)
19211907   #define STV_VDP2_S7CCRT      ((STV_VDP2_CCRSD & 0x1f00) >> 8)
19221908   #define STV_VDP2_S6CCRT      ((STV_VDP2_CCRSD & 0x001f) >> 0)
19231909
r11640r11641
19281914       |    --    |    --    |    --    | N0CCRT4  | N0CCRT3  | N0CCRT2  | N0CCRT1  | N0CCRT0  |
19291915       \----------|----------|----------|----------|----------|----------|----------|---------*/
19301916
1931   #define STV_VDP2_CCRNA   ((stv_vdp2_regs[0x108/4] >> 16)&0x0000ffff)
1917   #define STV_VDP2_CCRNA   ((state->m_vdp2_regs[0x108/4] >> 16)&0x0000ffff)
19321918   #define STV_VDP2_N1CCRT   ((STV_VDP2_CCRNA & 0x1f00) >> 8)
19331919   #define STV_VDP2_N0CCRT (STV_VDP2_CCRNA & 0x1f)
19341920
r11640r11641
19391925       |    --    |    --    |    --    | N2CCRT4  | N2CCRT3  | N2CCRT2  | N2CCRT1  | N2CCRT0  |
19401926       \----------|----------|----------|----------|----------|----------|----------|---------*/
19411927
1942   #define STV_VDP2_CCRNB   ((stv_vdp2_regs[0x108/4] >> 0)&0x0000ffff)
1928   #define STV_VDP2_CCRNB   ((state->m_vdp2_regs[0x108/4] >> 0)&0x0000ffff)
19431929   #define STV_VDP2_N3CCRT   ((STV_VDP2_CCRNB & 0x1f00) >> 8)
19441930   #define STV_VDP2_N2CCRT (STV_VDP2_CCRNB & 0x1f)
19451931
r11640r11641
19501936       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
19511937       \----------|----------|----------|----------|----------|----------|----------|---------*/
19521938
1953   #define STV_VDP2_CCRR   ((stv_vdp2_regs[0x10c/4] >> 16)&0x0000ffff)
1939   #define STV_VDP2_CCRR   ((state->m_vdp2_regs[0x10c/4] >> 16)&0x0000ffff)
19541940   #define STV_VDP2_R0CCRT (STV_VDP2_CCRR & 0x1f)
19551941
19561942/* 18010e - Colour Calculation Ratio (Line Colour Screen, Back Colour Screen)
r11640r11641
19671953       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
19681954       \----------|----------|----------|----------|----------|----------|----------|---------*/
19691955
1970   #define STV_VDP2_CLOFEN ((stv_vdp2_regs[0x110/4] >> 16)&0x0000ffff)
1956   #define STV_VDP2_CLOFEN ((state->m_vdp2_regs[0x110/4] >> 16)&0x0000ffff)
19711957   #define STV_VDP2_N0COEN ((STV_VDP2_CLOFEN & 0x01) >> 0)
19721958   #define STV_VDP2_N1COEN ((STV_VDP2_CLOFEN & 0x02) >> 1)
19731959   #define STV_VDP2_N2COEN ((STV_VDP2_CLOFEN & 0x04) >> 2)
r11640r11641
19831969       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
19841970       \----------|----------|----------|----------|----------|----------|----------|---------*/
19851971
1986   #define STV_VDP2_CLOFSL ((stv_vdp2_regs[0x110/4] >> 0)&0x0000ffff)
1972   #define STV_VDP2_CLOFSL ((state->m_vdp2_regs[0x110/4] >> 0)&0x0000ffff)
19871973   #define STV_VDP2_N0COSL ((STV_VDP2_CLOFSL & 0x01) >> 0)
19881974   #define STV_VDP2_N1COSL ((STV_VDP2_CLOFSL & 0x02) >> 1)
19891975   #define STV_VDP2_N2COSL ((STV_VDP2_CLOFSL & 0x04) >> 2)
r11640r11641
19991985       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
20001986       \----------|----------|----------|----------|----------|----------|----------|---------*/
20011987
2002   #define STV_VDP2_COAR ((stv_vdp2_regs[0x114/4] >> 16)&0x0000ffff)
1988   #define STV_VDP2_COAR ((state->m_vdp2_regs[0x114/4] >> 16)&0x0000ffff)
20031989
20041990/* 180116 - Colour Offset A (Green)
20051991 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
20071993       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
20081994       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
20091995       \----------|----------|----------|----------|----------|----------|----------|---------*/
2010   #define STV_VDP2_COAG ((stv_vdp2_regs[0x114/4] >> 0)&0x0000ffff)
1996   #define STV_VDP2_COAG ((state->m_vdp2_regs[0x114/4] >> 0)&0x0000ffff)
20111997
20121998/* 180118 - Colour Offset A (Blue)
20131999 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
20162002       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
20172003       \----------|----------|----------|----------|----------|----------|----------|---------*/
20182004
2019   #define STV_VDP2_COAB ((stv_vdp2_regs[0x118/4] >> 16)&0x0000ffff)
2005   #define STV_VDP2_COAB ((state->m_vdp2_regs[0x118/4] >> 16)&0x0000ffff)
20202006
20212007/* 18011a - Colour Offset B (Red)
20222008 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
20242010       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
20252011       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
20262012       \----------|----------|----------|----------|----------|----------|----------|---------*/
2027   #define STV_VDP2_COBR ((stv_vdp2_regs[0x118/4] >> 0)&0x0000ffff)
2013   #define STV_VDP2_COBR ((state->m_vdp2_regs[0x118/4] >> 0)&0x0000ffff)
20282014
20292015/* 18011b - Colour Offset B (Green)
20302016 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
20322018       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
20332019       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
20342020       \----------|----------|----------|----------|----------|----------|----------|---------*/
2035   #define STV_VDP2_COBG ((stv_vdp2_regs[0x11c/4] >> 16)&0x0000ffff)
2021   #define STV_VDP2_COBG ((state->m_vdp2_regs[0x11c/4] >> 16)&0x0000ffff)
20362022
20372023/* 18011c - Colour Offset B (Blue)
20382024 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
r11640r11641
20402026       |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----|
20412027       |    --    |    --    |    --    |    --    |    --    |    --    |    --    |    --    |
20422028       \----------|----------|----------|----------|----------|----------|----------|---------*/
2043   #define STV_VDP2_COBB ((stv_vdp2_regs[0x11c/4] >> 0)&0x0000ffff)
2029   #define STV_VDP2_COBB ((state->m_vdp2_regs[0x11c/4] >> 0)&0x0000ffff)
20442030
20452031/*For Debug purposes only*/
20462032static struct stv_vdp2_debugging
r11640r11641
21642150
21652151static void stv_vdp2_fill_rotation_parameter_table( running_machine &machine, UINT8 rot_parameter )
21662152{
2153   saturn_state *state = machine.driver_data<saturn_state>();
21672154   UINT32 address = 0;
21682155
21692156   address = (((STV_VDP2_RPTAU << 16) | STV_VDP2_RPTAL) << 1);
r11640r11641
21762163      address |= 0x00000080;
21772164   }
21782165
2179   stv_current_rotation_parameter_table.xst  = (stv_vdp2_vram[address/4] & 0x1fffffc0) | ((stv_vdp2_vram[address/4] & 0x10000000) ? 0xe0000000 : 0x00000000 );
2180   stv_current_rotation_parameter_table.yst  = (stv_vdp2_vram[address/4 + 1] & 0x1fffffc0) | ((stv_vdp2_vram[address/4 + 1] & 0x10000000) ? 0xe0000000 : 0x00000000 );
2181   stv_current_rotation_parameter_table.zst  = (stv_vdp2_vram[address/4 + 2] & 0x1fffffc0) | ((stv_vdp2_vram[address/4 + 2] & 0x10000000) ? 0xe0000000 : 0x00000000 );
2182   stv_current_rotation_parameter_table.dxst = (stv_vdp2_vram[address/4 + 3] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 3] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2183   stv_current_rotation_parameter_table.dyst = (stv_vdp2_vram[address/4 + 4] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 4] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2184   stv_current_rotation_parameter_table.dx   = (stv_vdp2_vram[address/4 + 5] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 5] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2185   stv_current_rotation_parameter_table.dy   = (stv_vdp2_vram[address/4 + 6] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 6] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2186   stv_current_rotation_parameter_table.A     = (stv_vdp2_vram[address/4 + 7] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 7] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2187   stv_current_rotation_parameter_table.B    = (stv_vdp2_vram[address/4 + 8] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 8] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2188   stv_current_rotation_parameter_table.C    = (stv_vdp2_vram[address/4 + 9] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 9] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2189   stv_current_rotation_parameter_table.D    = (stv_vdp2_vram[address/4 + 10] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 10] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2190   stv_current_rotation_parameter_table.E    = (stv_vdp2_vram[address/4 + 11] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 11] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2191   stv_current_rotation_parameter_table.F    = (stv_vdp2_vram[address/4 + 12] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 12] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2192   stv_current_rotation_parameter_table.px     = (stv_vdp2_vram[address/4 + 13] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 13] & 0x30000000) ? 0xc0000000 : 0x00000000 );
2193   stv_current_rotation_parameter_table.py     = (stv_vdp2_vram[address/4 + 13] & 0x00003fff) << 16;
2166   stv_current_rotation_parameter_table.xst  = (state->m_vdp2_vram[address/4] & 0x1fffffc0) | ((state->m_vdp2_vram[address/4] & 0x10000000) ? 0xe0000000 : 0x00000000 );
2167   stv_current_rotation_parameter_table.yst  = (state->m_vdp2_vram[address/4 + 1] & 0x1fffffc0) | ((state->m_vdp2_vram[address/4 + 1] & 0x10000000) ? 0xe0000000 : 0x00000000 );
2168   stv_current_rotation_parameter_table.zst  = (state->m_vdp2_vram[address/4 + 2] & 0x1fffffc0) | ((state->m_vdp2_vram[address/4 + 2] & 0x10000000) ? 0xe0000000 : 0x00000000 );
2169   stv_current_rotation_parameter_table.dxst = (state->m_vdp2_vram[address/4 + 3] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 3] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2170   stv_current_rotation_parameter_table.dyst = (state->m_vdp2_vram[address/4 + 4] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 4] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2171   stv_current_rotation_parameter_table.dx   = (state->m_vdp2_vram[address/4 + 5] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 5] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2172   stv_current_rotation_parameter_table.dy   = (state->m_vdp2_vram[address/4 + 6] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 6] & 0x00040000) ? 0xfff80000 : 0x00000000 );
2173   stv_current_rotation_parameter_table.A     = (state->m_vdp2_vram[address/4 + 7] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 7] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2174   stv_current_rotation_parameter_table.B    = (state->m_vdp2_vram[address/4 + 8] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 8] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2175   stv_current_rotation_parameter_table.C    = (state->m_vdp2_vram[address/4 + 9] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 9] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2176   stv_current_rotation_parameter_table.D    = (state->m_vdp2_vram[address/4 + 10] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 10] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2177   stv_current_rotation_parameter_table.E    = (state->m_vdp2_vram[address/4 + 11] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 11] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2178   stv_current_rotation_parameter_table.F    = (state->m_vdp2_vram[address/4 + 12] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 12] & 0x00080000) ? 0xfff00000 : 0x00000000 );
2179   stv_current_rotation_parameter_table.px     = (state->m_vdp2_vram[address/4 + 13] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 13] & 0x30000000) ? 0xc0000000 : 0x00000000 );
2180   stv_current_rotation_parameter_table.py     = (state->m_vdp2_vram[address/4 + 13] & 0x00003fff) << 16;
21942181   if ( stv_current_rotation_parameter_table.py & 0x20000000 ) stv_current_rotation_parameter_table.py |= 0xc0000000;
2195   stv_current_rotation_parameter_table.pz   = (stv_vdp2_vram[address/4 + 14] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 14] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2196   stv_current_rotation_parameter_table.cx   = (stv_vdp2_vram[address/4 + 15] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 15] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2197   stv_current_rotation_parameter_table.cy   = (stv_vdp2_vram[address/4 + 15] & 0x00003fff) << 16;
2182   stv_current_rotation_parameter_table.pz   = (state->m_vdp2_vram[address/4 + 14] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 14] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2183   stv_current_rotation_parameter_table.cx   = (state->m_vdp2_vram[address/4 + 15] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 15] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2184   stv_current_rotation_parameter_table.cy   = (state->m_vdp2_vram[address/4 + 15] & 0x00003fff) << 16;
21982185   if ( stv_current_rotation_parameter_table.cy & 0x20000000 ) stv_current_rotation_parameter_table.cy |= 0xc0000000;
2199   stv_current_rotation_parameter_table.cz   = (stv_vdp2_vram[address/4 + 16] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 16] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2200   stv_current_rotation_parameter_table.mx   = (stv_vdp2_vram[address/4 + 17] & 0x3fffffc0) | ((stv_vdp2_vram[address/4 + 17] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2201   stv_current_rotation_parameter_table.my   = (stv_vdp2_vram[address/4 + 18] & 0x3fffffc0) | ((stv_vdp2_vram[address/4 + 18] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2202   stv_current_rotation_parameter_table.kx   = (stv_vdp2_vram[address/4 + 19] & 0x00ffffff) | ((stv_vdp2_vram[address/4 + 19] & 0x00800000) ? 0xff000000 : 0x00000000 );
2203   stv_current_rotation_parameter_table.ky   = (stv_vdp2_vram[address/4 + 20] & 0x00ffffff) | ((stv_vdp2_vram[address/4 + 20] & 0x00800000) ? 0xff000000 : 0x00000000 );
2204   stv_current_rotation_parameter_table.kast = (stv_vdp2_vram[address/4 + 21] & 0xffffffc0);
2205   stv_current_rotation_parameter_table.dkast= (stv_vdp2_vram[address/4 + 22] & 0x03ffffc0) | ((stv_vdp2_vram[address/4 + 22] & 0x02000000) ? 0xfc000000 : 0x00000000 );
2206   stv_current_rotation_parameter_table.dkax = (stv_vdp2_vram[address/4 + 23] & 0x03ffffc0) | ((stv_vdp2_vram[address/4 + 23] & 0x02000000) ? 0xfc000000 : 0x00000000 );
2186   stv_current_rotation_parameter_table.cz   = (state->m_vdp2_vram[address/4 + 16] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 16] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2187   stv_current_rotation_parameter_table.mx   = (state->m_vdp2_vram[address/4 + 17] & 0x3fffffc0) | ((state->m_vdp2_vram[address/4 + 17] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2188   stv_current_rotation_parameter_table.my   = (state->m_vdp2_vram[address/4 + 18] & 0x3fffffc0) | ((state->m_vdp2_vram[address/4 + 18] & 0x20000000) ? 0xc0000000 : 0x00000000 );
2189   stv_current_rotation_parameter_table.kx   = (state->m_vdp2_vram[address/4 + 19] & 0x00ffffff) | ((state->m_vdp2_vram[address/4 + 19] & 0x00800000) ? 0xff000000 : 0x00000000 );
2190   stv_current_rotation_parameter_table.ky   = (state->m_vdp2_vram[address/4 + 20] & 0x00ffffff) | ((state->m_vdp2_vram[address/4 + 20] & 0x00800000) ? 0xff000000 : 0x00000000 );
2191   stv_current_rotation_parameter_table.kast = (state->m_vdp2_vram[address/4 + 21] & 0xffffffc0);
2192   stv_current_rotation_parameter_table.dkast= (state->m_vdp2_vram[address/4 + 22] & 0x03ffffc0) | ((state->m_vdp2_vram[address/4 + 22] & 0x02000000) ? 0xfc000000 : 0x00000000 );
2193   stv_current_rotation_parameter_table.dkax = (state->m_vdp2_vram[address/4 + 23] & 0x03ffffc0) | ((state->m_vdp2_vram[address/4 + 23] & 0x02000000) ? 0xfc000000 : 0x00000000 );
22072194
22082195#define RP   stv_current_rotation_parameter_table
22092196
r11640r11641
22882275   return 1;
22892276}
22902277
2291static void stv_vdp2_check_fade_control_for_layer(void)
2278static void stv_vdp2_check_fade_control_for_layer(running_machine &machine)
22922279{
2280   saturn_state *state = machine.driver_data<saturn_state>();
22932281   if ( stv2_current_tilemap.fade_control & 1 )
22942282   {
22952283      if ( stv2_current_tilemap.fade_control & 2 )
r11640r11641
23232311#define STV_VDP2_CP_NBG3_CPDR      0x7
23242312
23252313static UINT8 stv_vdp2_check_vram_cycle_pattern_registers(
2314                        running_machine &machine,
23262315                        UINT8 access_command_pnmdr,
23272316                        UINT8 access_command_cpdr,
23282317                        UINT8 bitmap_enable )
23292318{
2319   saturn_state *state = machine.driver_data<saturn_state>();
23302320   int i;
23312321   UINT8  access_command_ok = 0;
23322322   UINT16 cp_regs[8];
r11640r11641
26612651
26622652}
26632653
2664static void stv_vdp2_compute_color_offset_RGB555( int *r, int *g, int *b, int cor )
2654static void stv_vdp2_compute_color_offset_RGB555( running_machine &machine,int *r, int *g, int *b, int cor )
26652655{
2656   saturn_state *state = machine.driver_data<saturn_state>();
26662657   *r <<= 3;
26672658   *g <<= 3;
26682659   *b <<= 3;
r11640r11641
26902681
26912682}
26922683
2693static void stv_vdp2_compute_color_offset_RGB555_UINT16(UINT16 *rgb, int cor)
2684static void stv_vdp2_compute_color_offset_RGB555_UINT16(running_machine &machine,UINT16 *rgb, int cor)
26942685{
2686   saturn_state *state = machine.driver_data<saturn_state>();
26952687   int _r = (*rgb & 0x7c00) >> (10-3);
26962688   int _g = (*rgb & 0x03e0) >> (5-3);
26972689   int _b = (*rgb & 0x001f) << 3;
r11640r11641
27202712   *rgb = (_r << 10) |  (_g << 5) | _b;
27212713}
27222714
2723static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, const rectangle *clip, UINT32 code, int flipx, int flipy,
2715static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, const rectangle *clip, running_machine &machine, UINT32 code, int flipx, int flipy,
27242716                            int sx, int sy, int transparency, int alpha)
27252717{
2718   saturn_state *state = machine.driver_data<saturn_state>();
27262719   rectangle myclip;
27272720   UINT8* gfxdata;
27282721   int t_pen;
27292722   int sprite_screen_width, sprite_screen_height;
27302723
2731   gfxdata = stv_vdp2_gfx_decode + code * 0x20;
2724   gfxdata = state->m_vdp2.gfx_decode + code * 0x20;
27322725   sprite_screen_width = sprite_screen_height = 8;
27332726
27342727   /* KW 991012 -- Added code to force clip to bitmap boundary */
r11640r11641
28262819                  g = (data & 0x03e0) >> 5;
28272820                  r = (data & 0x001f);
28282821                  if(stv2_current_tilemap.fade_control & 1)
2829                     stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2822                     stv_vdp2_compute_color_offset_RGB555(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
28302823
28312824                  if ( transparency == STV_TRANSPARENCY_ALPHA )
28322825                     dest[x] = alpha_blend_r16( dest[x], b | g << 5 | r << 10, alpha );
r11640r11641
28472840
28482841static void stv_vdp2_draw_basic_bitmap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
28492842{
2843   saturn_state *state = machine.driver_data<saturn_state>();
2844
28502845//  if(LOG_VDP2) logerror ("bitmap enable %02x size %08x depth %08x\n", stv2_current_tilemap.layer_name, stv2_current_tilemap.bitmap_size, stv2_current_tilemap.colour_depth);
28512846//  popmessage ("bitmap enable %02x size %08x depth %08x number %02x", stv2_current_tilemap.layer_name, stv2_current_tilemap.bitmap_size, stv2_current_tilemap.colour_depth,stv2_current_tilemap.bitmap_palette_number);
28522847   //popmessage("%04x",STV_VDP2_SCRCTL);
r11640r11641
28552850   int ysize = 0/*, ysizemask = 0*/;
28562851   int xlinesize = 0/*, xpixelsize = 0*/;
28572852   int xcnt,ycnt;
2858   UINT8* gfxdata = stv_vdp2_gfx_decode;
2853   UINT8* gfxdata = state->m_vdp2.gfx_decode;
28592854   static UINT16 *destline;
28602855   UINT16 pal_color_offset = 0;
28612856   UINT8* gfxdatalow, *gfxdatahigh;
r11640r11641
29242919         {
29252920            for (xcnt = 0; xcnt <xsize;xcnt+=2)
29262921            {
2927               tw = stv_vdp2_window_process(xcnt+1,ycnt);
2922               tw = stv_vdp2_window_process(machine,xcnt+1,ycnt);
29282923               if(tw == 0)
29292924               {
29302925                  t_pen = (((gfxdata[0] & 0x0f) >> 0) != 0) ? (1) : (0);
r11640r11641
29402935                     }
29412936                  }
29422937               }
2943               tw = stv_vdp2_window_process(xcnt,ycnt);
2938               tw = stv_vdp2_window_process(machine,xcnt,ycnt);
29442939               if(tw == 0)
29452940               {
29462941                  t_pen = (((gfxdata[0] & 0xf0) >> 4) != 0) ? (1) : (0);
r11640r11641
29742969               {
29752970                  int xs = xcnt & xsizemask;
29762971
2977                  tw = stv_vdp2_window_process(xcnt,ycnt);
2972                  tw = stv_vdp2_window_process(machine,xcnt,ycnt);
29782973                  if(tw == 0)
29792974                  {
29802975                     //60aee2c = $0013 at @605d838
r11640r11641
30213016               for (xcnt = cliprect->min_x; xcnt <= cliprect->max_x; xx+=stv2_current_tilemap.incx, xcnt++)
30223017               {
30233018                  xs = xx >> 16;
3024                  tw = stv_vdp2_window_process(xcnt,ycnt);
3019                  tw = stv_vdp2_window_process(machine,xcnt,ycnt);
30253020                  if(tw == 0)
30263021                  {
30273022                     t_pen = ((gfxdata[xs] & 0xff) != 0) ? 1 : 0;
r11640r11641
30493044         {
30503045            for (xcnt = 0; xcnt <xsize;xcnt++)
30513046            {
3052               tw = stv_vdp2_window_process(xcnt,ycnt);
3047               tw = stv_vdp2_window_process(machine,xcnt,ycnt);
30533048               if(tw == 0)
30543049               {
30553050                  t_pen = ((((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff)) != 0) ? (1) : (0);
r11640r11641
30993094                  g = ((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5);
31003095                  r = ((gfxdata[2*xs+1] & 0x1f));
31013096                  if(stv2_current_tilemap.fade_control & 1)
3102                     stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2);
3103                  tw = stv_vdp2_window_process(xcnt,ycnt);
3097                     stv_vdp2_compute_color_offset_RGB555(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
3098                  tw = stv_vdp2_window_process(machine,xcnt,ycnt);
31043099                  if(tw == 0)
31053100                  {
31063101                     if (((xcnt + 0) < screen_x) && (ycnt < screen_y))
r11640r11641
31423137                  g = ((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5);
31433138                  r = ((gfxdata[2*xs+1] & 0x1f));
31443139                  if(stv2_current_tilemap.fade_control & 1)
3145                     stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2);
3146                  tw = stv_vdp2_window_process(xcnt,ycnt);
3140                     stv_vdp2_compute_color_offset_RGB555(machine, &r,&g,&b,stv2_current_tilemap.fade_control & 2);
3141                  tw = stv_vdp2_window_process(machine,xcnt,ycnt);
31473142                  if(tw == 0)
31483143                  {
31493144                     if(t_pen)
r11640r11641
31913186               g = (gfxdata[2] & 0xf8) >> 3;
31923187               r = (gfxdata[3] & 0xf8) >> 3;
31933188
3194               tw = stv_vdp2_window_process(xcnt,ycnt);
3189               tw = stv_vdp2_window_process(machine,xcnt,ycnt);
31953190               if(tw == 0)
31963191               {
31973192                  if(t_pen)
r11640r11641
33773372
33783373static void stv_vdp2_draw_basic_tilemap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
33793374{
3375   saturn_state *state = machine.driver_data<saturn_state>();
33803376   /* hopefully this is easier to follow than it is efficient .. */
33813377
33823378   /* I call character patterns tiles .. even if they represent up to 4 tiles */
r11640r11641
36563652         if (stv2_current_tilemap.pattern_data_size ==1)
36573653         {
36583654
3659            data = stv_vdp2_vram[newbase + offs/2];
3655            data = state->m_vdp2_vram[newbase + offs/2];
36603656            data = (offs&1) ? (data & 0x0000ffff) : ((data & 0xffff0000) >> 16);
36613657
36623658            /* Supplement Mode 12 bits, no flip */
r11640r11641
36823678         else
36833679         {
36843680
3685            data = stv_vdp2_vram[newbase + offs];
3681            data = state->m_vdp2_vram[newbase + offs];
36863682            tilecode = (data & 0x00007fff);
36873683            pal   = (data &    0x007f0000)>>16;
36883684   //          specialc = (data & 0x10000000)>>28;
r11640r11641
37533749               if ( stv2_current_tilemap.colour_depth == 3 )
37543750               {
37553751                  /* normal */
3756                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3757                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3758                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3759                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3752                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3753                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3754                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3755                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
37603756
37613757               }
37623758               else if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA)
r11640r11641
37823778            {
37833779               if ( stv2_current_tilemap.colour_depth == 3 )
37843780               {
3785                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3781                  stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
37863782               }
37873783               else
37883784               {
r11640r11641
38443840
38453841#define STV_VDP2_READ_VERTICAL_LINESCROLL( _val, _address ) \
38463842   { \
3847      _val = stv_vdp2_vram[ _address ]; \
3843      _val = state->m_vdp2_vram[ _address ]; \
38483844      _val &= 0x07ffff00; \
38493845      if ( _val & 0x04000000 ) _val |= 0xf8000000; \
38503846   }
r11640r11641
38523848
38533849static void stv_vdp2_check_tilemap_with_linescroll(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
38543850{
3851   saturn_state *state = machine.driver_data<saturn_state>();
38553852   rectangle mycliprect;
38563853   int cur_line = cliprect->min_y;
38573854   int address;
r11640r11641
39033900      }
39043901      else
39053902      {
3906         prev_scroll_values[i] = stv_vdp2_vram[ (address / 4) + i ];
3903         prev_scroll_values[i] = state->m_vdp2_vram[ (address / 4) + i ];
39073904      }
39083905   }
39093906
r11640r11641
39283925            }
39293926            else
39303927            {
3931               scroll_values[i] = stv_vdp2_vram[ (address / 4) + i ];
3928               scroll_values[i] = state->m_vdp2_vram[ (address / 4) + i ];
39323929            }
39333930         }
39343931
r11640r11641
39853982{
39863983   /* the idea is here we check the tilemap capabilities / whats enabled and call an appropriate tilemap drawing routine, or
39873984      at the very list throw up a few errors if the tilemaps want to do something we don't support yet */
3985   saturn_state *state = machine.driver_data<saturn_state>();
39883986
39893987   int window_applied = 0;
39903988   rectangle mycliprect;
r11640r11641
40013999      return;
40024000   }
40034001
4004   window_applied = stv_vdp2_apply_window_on_layer(&mycliprect);
4002   window_applied = stv_vdp2_apply_window_on_layer(machine,&mycliprect);
40054003
40064004   if (stv2_current_tilemap.bitmap_enable) // this layer is a bitmap
40074005   {
r11640r11641
40304028}
40314029
40324030static void stv_vdp2_copy_roz_bitmap(bitmap_t *bitmap,
4031                            running_machine &machine,
40334032                            bitmap_t *roz_bitmap,
40344033                            const rectangle *cliprect,
40354034                            int iRP,
r11640r11641
40384037                            int planerenderedsizex,
40394038                            int planerenderedsizey)
40404039{
4040   saturn_state *state = machine.driver_data<saturn_state>();
40414041   INT32 xsp, ysp, xp, yp, dx, dy, x, y, xs, ys, dxs, dys;
40424042   INT32 vcnt, hcnt;
40434043   INT32 kx, ky;
r11640r11641
41214121   {
41224122      if ( STV_VDP2_CRKTE == 0 )
41234123      {
4124         coeff_table_base = stv_vdp2_vram;
4124         coeff_table_base = state->m_vdp2_vram;
41254125      }
41264126      else
41274127      {
4128         coeff_table_base = stv_vdp2_cram;
4128         coeff_table_base = state->m_vdp2_cram;
41294129      }
41304130      if ( coeff_table_size == 0 )
41314131      {
r11640r11641
42834283            if ( x & clipxmask || y & clipymask ) continue;
42844284            pix = *BITMAP_ADDR16(roz_bitmap, y & planerenderedsizey, x & planerenderedsizex);
42854285            if(stv2_current_tilemap.fade_control & 1)
4286               stv_vdp2_compute_color_offset_RGB555_UINT16(&pix,stv2_current_tilemap.fade_control & 2);
4286               stv_vdp2_compute_color_offset_RGB555_UINT16(machine,&pix,stv2_current_tilemap.fade_control & 2);
42874287            switch( stv2_current_tilemap.transparency )
42884288            {
42894289               case STV_TRANSPARENCY_PEN:
r11640r11641
43754375
43764376            pix = *BITMAP_ADDR16(roz_bitmap, y & planerenderedsizey, x & planerenderedsizex);
43774377            if(stv2_current_tilemap.fade_control & 1)
4378               stv_vdp2_compute_color_offset_RGB555_UINT16(&pix,stv2_current_tilemap.fade_control & 2);
4378               stv_vdp2_compute_color_offset_RGB555_UINT16(machine,&pix,stv2_current_tilemap.fade_control & 2);
43794379            switch( stv2_current_tilemap.transparency )
43804380            {
43814381               case STV_TRANSPARENCY_PEN:
r11640r11641
43984398
43994399static void stv_vdp2_draw_NBG0(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
44004400{
4401   saturn_state *state = machine.driver_data<saturn_state>();
4402
44014403   /*
44024404       Colours           : 16, 256, 2048, 32768, 16770000
44034405       Char Size         : 1x1 cells, 2x2 cells
r11640r11641
44674469   stv2_current_tilemap.plane_size = STV_VDP2_N0PLSZ;
44684470   stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N0CAOS;
44694471   stv2_current_tilemap.fade_control = (STV_VDP2_N0COEN * 1) | (STV_VDP2_N0COSL * 2);
4470   stv_vdp2_check_fade_control_for_layer();
4471   stv2_current_tilemap.window_control = (STV_VDP2_N0LOG * 0x01) |
4472                                (STV_VDP2_N0W0E * 0x02) |
4473                                (STV_VDP2_N0W1E * 0x04) |
4474                                (STV_VDP2_N0SWE * 0x08) |
4475                                (STV_VDP2_N0W0A * 0x10) |
4476                                (STV_VDP2_N0W1A * 0x20) |
4477                                (STV_VDP2_N0SWA * 0x40);
4472   stv_vdp2_check_fade_control_for_layer(machine);
4473   stv2_current_tilemap.window_control = (STV_VDP2_N0LOG << 0) |
4474                                (STV_VDP2_N0W0E << 1) |
4475                                (STV_VDP2_N0W1E << 2) |
4476                                (STV_VDP2_N0SWE << 3) |
4477                                (STV_VDP2_N0W0A << 4) |
4478                                (STV_VDP2_N0W1A << 5) |
4479                                (STV_VDP2_N0SWA << 6);
44784480
44794481   stv2_current_tilemap.layer_name=0;
44804482
44814483   if ( stv2_current_tilemap.enabled )
44824484   {
4483      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG0_PNMDR, STV_VDP2_CP_NBG0_CPDR, stv2_current_tilemap.bitmap_enable );
4485      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG0_PNMDR, STV_VDP2_CP_NBG0_CPDR, stv2_current_tilemap.bitmap_enable );
44844486   }
44854487
44864488   stv_vdp2_check_tilemap(machine, bitmap, cliprect);
r11640r11641
44884490
44894491static void stv_vdp2_draw_NBG1(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
44904492{
4493   saturn_state *state = machine.driver_data<saturn_state>();
4494
44914495   /*
44924496       Colours           : 16, 256, 2048, 32768
44934497       Char Size         : 1x1 cells, 2x2 cells
r11640r11641
45574561   stv2_current_tilemap.plane_size = STV_VDP2_N1PLSZ;
45584562   stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N1CAOS;
45594563   stv2_current_tilemap.fade_control = (STV_VDP2_N1COEN * 1) | (STV_VDP2_N1COSL * 2);
4560   stv_vdp2_check_fade_control_for_layer();
4561   stv2_current_tilemap.window_control = (STV_VDP2_N1LOG * 0x01) |
4562                                (STV_VDP2_N1W0E * 0x02) |
4563                                (STV_VDP2_N1W1E * 0x04) |
4564                                (STV_VDP2_N1SWE * 0x08) |
4565                                (STV_VDP2_N1W0A * 0x10) |
4566                                (STV_VDP2_N1W1A * 0x20) |
4567                                (STV_VDP2_N1SWA * 0x40);
4564   stv_vdp2_check_fade_control_for_layer(machine);
4565   stv2_current_tilemap.window_control = (STV_VDP2_N1LOG << 0) |
4566                                (STV_VDP2_N1W0E << 1) |
4567                                (STV_VDP2_N1W1E << 2) |
4568                                (STV_VDP2_N1SWE << 3) |
4569                                (STV_VDP2_N1W0A << 4) |
4570                                (STV_VDP2_N1W1A << 5) |
4571                                (STV_VDP2_N1SWA << 6);
45684572
45694573   stv2_current_tilemap.layer_name=1;
45704574
45714575   if ( stv2_current_tilemap.enabled )
45724576   {
4573      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG1_PNMDR, STV_VDP2_CP_NBG1_CPDR, stv2_current_tilemap.bitmap_enable );
4577      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG1_PNMDR, STV_VDP2_CP_NBG1_CPDR, stv2_current_tilemap.bitmap_enable );
45744578   }
45754579
45764580   stv_vdp2_check_tilemap(machine, bitmap, cliprect);
r11640r11641
45784582
45794583static void stv_vdp2_draw_NBG2(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
45804584{
4585   saturn_state *state = machine.driver_data<saturn_state>();
4586
45814587   /*
45824588       NBG2 is the first of the 2 more basic tilemaps, it has exactly the same capabilities as NBG3
45834589
r11640r11641
46554661
46564662   stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N2CAOS;
46574663   stv2_current_tilemap.fade_control = (STV_VDP2_N2COEN * 1) | (STV_VDP2_N2COSL * 2);
4658   stv_vdp2_check_fade_control_for_layer();
4659   stv2_current_tilemap.window_control = (STV_VDP2_N2LOG * 0x01) |
4660                                (STV_VDP2_N2W0E * 0x02) |
4661                                (STV_VDP2_N2W1E * 0x04) |
4662                                (STV_VDP2_N2SWE * 0x08) |
4663                                (STV_VDP2_N2W0A * 0x10) |
4664                                (STV_VDP2_N2W1A * 0x20) |
4665                                (STV_VDP2_N2SWA * 0x40);
4664   stv_vdp2_check_fade_control_for_layer(machine);
4665   stv2_current_tilemap.window_control = (STV_VDP2_N2LOG << 0) |
4666                                (STV_VDP2_N2W0E << 1) |
4667                                (STV_VDP2_N2W1E << 2) |
4668                                (STV_VDP2_N2SWE << 3) |
4669                                (STV_VDP2_N2W0A << 4) |
4670                                (STV_VDP2_N2W1A << 5) |
4671                                (STV_VDP2_N2SWA << 6);
46664672
46674673   stv2_current_tilemap.layer_name=2;
46684674
r11640r11641
46704676
46714677   if ( stv2_current_tilemap.enabled )
46724678   {
4673      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG2_PNMDR, STV_VDP2_CP_NBG2_CPDR, stv2_current_tilemap.bitmap_enable );
4679      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG2_PNMDR, STV_VDP2_CP_NBG2_CPDR, stv2_current_tilemap.bitmap_enable );
46744680   }
46754681
46764682   stv_vdp2_check_tilemap(machine, bitmap, cliprect);
r11640r11641
46784684
46794685static void stv_vdp2_draw_NBG3(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
46804686{
4687   saturn_state *state = machine.driver_data<saturn_state>();
46814688   /*
46824689       NBG3 is the second of the 2 more basic tilemaps, it has exactly the same capabilities as NBG2
46834690
r11640r11641
47554762
47564763   stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N3CAOS;
47574764   stv2_current_tilemap.fade_control = (STV_VDP2_N3COEN * 1) | (STV_VDP2_N3COSL * 2);
4758   stv_vdp2_check_fade_control_for_layer();
4759   stv2_current_tilemap.window_control = (STV_VDP2_N3LOG * 0x01) |
4760                                (STV_VDP2_N3W0E * 0x02) |
4761                                (STV_VDP2_N3W1E * 0x04) |
4762                                (STV_VDP2_N3SWE * 0x08) |
4763                                (STV_VDP2_N3W0A * 0x10) |
4764                                (STV_VDP2_N3W1A * 0x20) |
4765                                (STV_VDP2_N3SWA * 0x40);
4765   stv_vdp2_check_fade_control_for_layer(machine);
4766   stv2_current_tilemap.window_control = (STV_VDP2_N3LOG << 0) |
4767                                (STV_VDP2_N3W0E << 1) |
4768                                (STV_VDP2_N3W1E << 2) |
4769                                (STV_VDP2_N3SWE << 3) |
4770                                (STV_VDP2_N3W0A << 4) |
4771                                (STV_VDP2_N3W1A << 5) |
4772                                (STV_VDP2_N3SWA << 6);
47664773
47674774   stv2_current_tilemap.layer_name=3;
47684775
r11640r11641
47704777
47714778   if ( stv2_current_tilemap.enabled )
47724779   {
4773      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG3_PNMDR, STV_VDP2_CP_NBG3_CPDR, stv2_current_tilemap.bitmap_enable );
4780      stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG3_PNMDR, STV_VDP2_CP_NBG3_CPDR, stv2_current_tilemap.bitmap_enable );
47744781   }
47754782
47764783   stv_vdp2_check_tilemap(machine, bitmap, cliprect);
r11640r11641
47794786
47804787static void stv_vdp2_draw_rotation_screen(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int iRP)
47814788{
4789   saturn_state *state = machine.driver_data<saturn_state>();
47824790   rectangle roz_clip_rect, mycliprect;
47834791   int planesizex = 0, planesizey = 0;
47844792   int planerenderedsizex, planerenderedsizey;
r11640r11641
48814889   }
48824890   else
48834891   {
4884      if ( stv_vdp2_roz_bitmap[iRP-1] == NULL )
4885         stv_vdp2_roz_bitmap[iRP-1] = auto_alloc(machine, bitmap_t(4096, 4096, machine.primary_screen->format()));
4892      if ( state->m_vdp2.roz_bitmap[iRP-1] == NULL )
4893         state->m_vdp2.roz_bitmap[iRP-1] = auto_alloc(machine, bitmap_t(4096, 4096, machine.primary_screen->format()));
48864894
48874895      roz_clip_rect.min_x = roz_clip_rect.min_y = 0;
48884896      if ( (iRP == 1 && STV_VDP2_RAOVR == 3) ||
r11640r11641
49194927      if ( (stv_rbg_cache_data.is_cache_dirty & iRP) ||
49204928         memcmp(&stv_rbg_cache_data.layer_data[iRP-1],&stv2_current_tilemap,sizeof(stv2_current_tilemap)) != 0 )
49214929      {
4922         bitmap_fill( stv_vdp2_roz_bitmap[iRP-1], &roz_clip_rect , get_black_pen(machine));
4923         stv_vdp2_check_tilemap(machine, stv_vdp2_roz_bitmap[iRP-1], &roz_clip_rect);
4930         bitmap_fill( state->m_vdp2.roz_bitmap[iRP-1], &roz_clip_rect , get_black_pen(machine));
4931         stv_vdp2_check_tilemap(machine, state->m_vdp2.roz_bitmap[iRP-1], &roz_clip_rect);
49244932         // prepare cache data
49254933         stv_rbg_cache_data.watch_vdp2_vram_writes |= iRP;
49264934         stv_rbg_cache_data.is_cache_dirty &= ~iRP;
r11640r11641
49494957      if ( window_control )
49504958      {
49514959         stv2_current_tilemap.window_control = window_control;
4952         stv_vdp2_apply_window_on_layer(&mycliprect);
4960         stv_vdp2_apply_window_on_layer(machine,&mycliprect);
49534961      }
49544962
49554963      stv2_current_tilemap.fade_control = fade_control;
49564964
49574965      g_profiler.start(PROFILER_USER2);
4958      stv_vdp2_copy_roz_bitmap(bitmap, stv_vdp2_roz_bitmap[iRP-1], &mycliprect, iRP, planesizex, planesizey, planerenderedsizex, planerenderedsizey );
4966      stv_vdp2_copy_roz_bitmap(bitmap, machine, state->m_vdp2.roz_bitmap[iRP-1], &mycliprect, iRP, planesizex, planesizey, planerenderedsizex, planerenderedsizey );
49594967      g_profiler.stop();
49604968   }
49614969
r11640r11641
49634971
49644972static void stv_vdp2_draw_RBG0(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
49654973{
4974   saturn_state *state = machine.driver_data<saturn_state>();
49664975   /*
49674976       Colours           : 16, 256, 2048, 32768, 16770000
49684977       Char Size         : 1x1 cells, 2x2 cells
r11640r11641
50155024
50165025   stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_R0CAOS;
50175026   stv2_current_tilemap.fade_control = (STV_VDP2_R0COEN * 1) | (STV_VDP2_R0COSL * 2);
5018   stv_vdp2_check_fade_control_for_layer();
5019   stv2_current_tilemap.window_control = (STV_VDP2_R0LOG * 0x01) |
5020                                (STV_VDP2_R0W0E * 0x02) |
5021                                (STV_VDP2_R0W1E * 0x04) |
5022                                (STV_VDP2_R0SWE * 0x08) |
5023                                (STV_VDP2_R0W0A * 0x10) |
5024                                (STV_VDP2_R0W1A * 0x20) |
5025                                (STV_VDP2_R0SWA * 0x40);
5027   stv_vdp2_check_fade_control_for_layer(machine);
5028   stv2_current_tilemap.window_control = (STV_VDP2_R0LOG << 0) |
5029                                (STV_VDP2_R0W0E << 1) |
5030                                (STV_VDP2_R0W1E << 2) |
5031                                (STV_VDP2_R0SWE << 3) |
5032                                (STV_VDP2_R0W0A << 4) |
5033                                (STV_VDP2_R0W1A << 5) |
5034                                (STV_VDP2_R0SWA << 6);
50265035
50275036   stv2_current_tilemap.scrollx = 0;
50285037   stv2_current_tilemap.scrolly = 0;
r11640r11641
50385047   /*Use 0x80 as a normal/rotate switch*/
50395048   stv2_current_tilemap.layer_name=0x80;
50405049
5041   if ( !stv_vdp2_render_rbg0 ) return;
50425050   if ( !stv2_current_tilemap.enabled ) return;
50435051
50445052   switch(STV_VDP2_RPMD)
r11640r11641
50635071
50645072static void stv_vdp2_draw_back(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
50655073{
5074   saturn_state *state = machine.driver_data<saturn_state>();
50665075   int xcnt,ycnt;
5067   UINT8* gfxdata = stv_vdp2_gfx_decode;
5076   UINT8* gfxdata = state->m_vdp2.gfx_decode;
50685077   static UINT16 *destline;
50695078   int r,b,g;
50705079   UINT16 data;
r11640r11641
51045113}
51055114
51065115
5107WRITE32_HANDLER ( stv_vdp2_vram_w )
5116WRITE32_HANDLER ( saturn_vdp2_vram_w )
51085117{
5109   UINT8 *stv_vdp2_vram_decode = stv_vdp2_gfx_decode;
5118   saturn_state *state = space->machine().driver_data<saturn_state>();
5119   UINT8* gfxdata = state->m_vdp2.gfx_decode;
51105120
5111   COMBINE_DATA(&stv_vdp2_vram[offset]);
5121   COMBINE_DATA(&state->m_vdp2_vram[offset]);
51125122
5113   data = stv_vdp2_vram[offset];
5123   data = state->m_vdp2_vram[offset];
51145124   /* put in gfx region for easy decoding */
5115   stv_vdp2_vram_decode[offset*4+0] = (data & 0xff000000) >> 24;
5116   stv_vdp2_vram_decode[offset*4+1] = (data & 0x00ff0000) >> 16;
5117   stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8;
5118   stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0;
5125   gfxdata[offset*4+0] = (data & 0xff000000) >> 24;
5126   gfxdata[offset*4+1] = (data & 0x00ff0000) >> 16;
5127   gfxdata[offset*4+2] = (data & 0x0000ff00) >> 8;
5128   gfxdata[offset*4+3] = (data & 0x000000ff) >> 0;
51195129
51205130   gfx_element_mark_dirty(space->machine().gfx[0], offset/8);
51215131   gfx_element_mark_dirty(space->machine().gfx[1], offset/8);
r11640r11641
51605170
51615171}
51625172
5163READ32_HANDLER ( stv_vdp2_vram_r )
5173READ32_HANDLER ( saturn_vdp2_regs_r )
51645174{
5165   return stv_vdp2_vram[offset];
5175   saturn_state *state = space->machine().driver_data<saturn_state>();
5176//  if (offset!=1) if(LOG_VDP2) logerror ("VDP2: Read from Registers, Offset %04x\n",offset);
5177
5178   switch(offset)
5179   {
5180      case 0x4/4:
5181      {
5182         int stv_hblank,stv_vblank,stv_odd;
5183         /*Screen Status Register*/
5184         stv_vblank = stv_get_vblank(space->machine());
5185         stv_hblank = get_hblank(space->machine());
5186         stv_odd = get_odd_bit(space->machine());
5187
5188                           /*VBLANK              HBLANK            ODD               PAL    */
5189         state->m_vdp2_regs[offset] = (stv_vblank<<19) | (stv_hblank<<18) | (stv_odd << 17) | (0 << 16);
5190         break;
5191      }
5192      case 0x8/4:
5193      /*H/V Counter Register*/
5194      {
5195         static UINT16 h_count,v_count;
5196         /* TODO: handle various h/v settings. */
5197         h_count = space->machine().primary_screen->hpos() & 0x3ff;
5198         v_count = space->machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff);
5199         state->m_vdp2_regs[offset] = (h_count<<16)|(v_count);
5200         if(LOG_VDP2) logerror("CPU %s PC(%08x) = VDP2: H/V counter read : %08x\n", space->device().tag(), cpu_get_pc(&space->device()),state->m_vdp2_regs[offset]);
5201         break;
5202      }
5203   }
5204   return state->m_vdp2_regs[offset];
51665205}
51675206
5168WRITE32_HANDLER ( stv_vdp2_cram_w )
5207READ32_HANDLER ( saturn_vdp2_cram_r )
51695208{
5209   saturn_state *state = space->machine().driver_data<saturn_state>();
5210
5211   return state->m_vdp2_cram[offset];
5212}
5213
5214
5215READ32_HANDLER ( saturn_vdp2_vram_r )
5216{
5217   saturn_state *state = space->machine().driver_data<saturn_state>();
5218
5219   return state->m_vdp2_vram[offset];
5220}
5221
5222WRITE32_HANDLER ( saturn_vdp2_cram_w )
5223{
5224   saturn_state *state = space->machine().driver_data<saturn_state>();
51705225   int r,g,b;
5171   COMBINE_DATA(&stv_vdp2_cram[offset]);
5226   COMBINE_DATA(&state->m_vdp2_cram[offset]);
51725227
51735228//  popmessage("%01x\n",STV_VDP2_CRMD);
51745229
r11640r11641
51785233      case 2:
51795234      case 3:
51805235      {
5181         b = ((stv_vdp2_cram[offset] & 0x00ff0000) >> 16);
5182         g = ((stv_vdp2_cram[offset] & 0x0000ff00) >> 8);
5183         r = ((stv_vdp2_cram[offset] & 0x000000ff) >> 0);
5236         b = ((state->m_vdp2_cram[offset] & 0x00ff0000) >> 16);
5237         g = ((state->m_vdp2_cram[offset] & 0x0000ff00) >> 8);
5238         r = ((state->m_vdp2_cram[offset] & 0x000000ff) >> 0);
51845239         palette_set_color(space->machine(),offset,MAKE_RGB(r,g,b));
51855240      }
51865241      break;
51875242      /*Mode 0*/
51885243      case 0:
5189      {
5190         offset &= 0x3ff;
5191
5192         b = ((stv_vdp2_cram[offset] & 0x00007c00) >> 10);
5193         g = ((stv_vdp2_cram[offset] & 0x000003e0) >> 5);
5194         r = ((stv_vdp2_cram[offset] & 0x0000001f) >> 0);
5195         palette_set_color_rgb(space->machine(),(offset*2)+1,pal5bit(r),pal5bit(g),pal5bit(b));
5196         b = ((stv_vdp2_cram[offset] & 0x7c000000) >> 26);
5197         g = ((stv_vdp2_cram[offset] & 0x03e00000) >> 21);
5198         r = ((stv_vdp2_cram[offset] & 0x001f0000) >> 16);
5199         palette_set_color_rgb(space->machine(),offset*2,pal5bit(r),pal5bit(g),pal5bit(b));
5200      }
5201      break;
5202      /*Mode 1*/
52035244      case 1:
52045245      {
5205         offset &= 0x7ff;
5246         offset &= (0x3ff | ((offset & 1) << 10));
52065247
5207         b = ((stv_vdp2_cram[offset] & 0x00007c00) >> 10);
5208         g = ((stv_vdp2_cram[offset] & 0x000003e0) >> 5);
5209         r = ((stv_vdp2_cram[offset] & 0x0000001f) >> 0);
5248         b = ((state->m_vdp2_cram[offset] & 0x00007c00) >> 10);
5249         g = ((state->m_vdp2_cram[offset] & 0x000003e0) >> 5);
5250         r = ((state->m_vdp2_cram[offset] & 0x0000001f) >> 0);
52105251         palette_set_color_rgb(space->machine(),(offset*2)+1,pal5bit(r),pal5bit(g),pal5bit(b));
5211         b = ((stv_vdp2_cram[offset] & 0x7c000000) >> 26);
5212         g = ((stv_vdp2_cram[offset] & 0x03e00000) >> 21);
5213         r = ((stv_vdp2_cram[offset] & 0x001f0000) >> 16);
5252         b = ((state->m_vdp2_cram[offset] & 0x7c000000) >> 26);
5253         g = ((state->m_vdp2_cram[offset] & 0x03e00000) >> 21);
5254         r = ((state->m_vdp2_cram[offset] & 0x001f0000) >> 16);
52145255         palette_set_color_rgb(space->machine(),offset*2,pal5bit(r),pal5bit(g),pal5bit(b));
52155256      }
52165257      break;
r11640r11641
52195260
52205261static void refresh_palette_data(running_machine &machine)
52215262{
5263   saturn_state *state = machine.driver_data<saturn_state>();
52225264   int r,g,b;
52235265   int c_i;
52245266
r11640r11641
52305272         case 2:
52315273         case 3:
52325274         {
5233            b = ((stv_vdp2_cram[c_i] & 0x00ff0000) >> 16);
5234            g = ((stv_vdp2_cram[c_i] & 0x0000ff00) >> 8);
5235            r = ((stv_vdp2_cram[c_i] & 0x000000ff) >> 0);
5275            b = ((state->m_vdp2_cram[c_i] & 0x00ff0000) >> 16);
5276            g = ((state->m_vdp2_cram[c_i] & 0x0000ff00) >> 8);
5277            r = ((state->m_vdp2_cram[c_i] & 0x000000ff) >> 0);
52365278            palette_set_color(machine,c_i,MAKE_RGB(r,g,b));
52375279         }
52385280         break;
52395281         /*Mode 0*/
52405282         case 0:
5283         case 1:
52415284         {
52425285            //c_i &= 0x3ff;
52435286
5244            b = ((stv_vdp2_cram[c_i] & 0x00007c00) >> 10);
5245            g = ((stv_vdp2_cram[c_i] & 0x000003e0) >> 5);
5246            r = ((stv_vdp2_cram[c_i] & 0x0000001f) >> 0);
5287            b = ((state->m_vdp2_cram[c_i] & 0x00007c00) >> 10);
5288            g = ((state->m_vdp2_cram[c_i] & 0x000003e0) >> 5);
5289            r = ((state->m_vdp2_cram[c_i] & 0x0000001f) >> 0);
52475290            palette_set_color_rgb(machine,(c_i*2)+1,pal5bit(r),pal5bit(g),pal5bit(b));
5248            b = ((stv_vdp2_cram[c_i] & 0x7c000000) >> 26);
5249            g = ((stv_vdp2_cram[c_i] & 0x03e00000) >> 21);
5250            r = ((stv_vdp2_cram[c_i] & 0x001f0000) >> 16);
5291            b = ((state->m_vdp2_cram[c_i] & 0x7c000000) >> 26);
5292            g = ((state->m_vdp2_cram[c_i] & 0x03e00000) >> 21);
5293            r = ((state->m_vdp2_cram[c_i] & 0x001f0000) >> 16);
52515294            palette_set_color_rgb(machine,c_i*2,pal5bit(r),pal5bit(g),pal5bit(b));
52525295         }
52535296         break;
5254         /*Mode 1*/
5255         case 1:
5256         {
5257            //c_i &= 0x7ff;
5258
5259            b = ((stv_vdp2_cram[c_i] & 0x00007c00) >> 10);
5260            g = ((stv_vdp2_cram[c_i] & 0x000003e0) >> 5);
5261            r = ((stv_vdp2_cram[c_i] & 0x0000001f) >> 0);
5262            palette_set_color_rgb(machine,(c_i*2)+1,pal5bit(r),pal5bit(g),pal5bit(b));
5263            b = ((stv_vdp2_cram[c_i] & 0x7c000000) >> 26);
5264            g = ((stv_vdp2_cram[c_i] & 0x03e00000) >> 21);
5265            r = ((stv_vdp2_cram[c_i] & 0x001f0000) >> 16);
5266            palette_set_color_rgb(machine,c_i*2,pal5bit(r),pal5bit(g),pal5bit(b));
5267         }
5268         break;
52695297      }
52705298   }
52715299}
52725300
5273READ32_HANDLER ( stv_vdp2_cram_r )
5301WRITE32_HANDLER ( saturn_vdp2_regs_w )
52745302{
5275   return stv_vdp2_cram[offset];
5276}
5277
5278WRITE32_HANDLER ( stv_vdp2_regs_w )
5279{
5303   saturn_state *state = space->machine().driver_data<saturn_state>();
52805304   static UINT8 old_crmd;
52815305   static UINT16 old_tvmd;
5282   COMBINE_DATA(&stv_vdp2_regs[offset]);
5306   COMBINE_DATA(&state->m_vdp2_regs[offset]);
52835307
52845308   if(old_crmd != STV_VDP2_CRMD)
52855309   {
r11640r11641
53095333/* the following is a complete guess-work */
53105334static int get_hblank_duration(running_machine &machine)
53115335{
5336   saturn_state *state = machine.driver_data<saturn_state>();
53125337   switch( STV_VDP2_HRES & 3 )
53135338   {
53145339      case 0: return 80;  //400-320
r11640r11641
53355360/*some vblank lines measurements (according to Charles MacDonald)*/
53365361static int get_vblank_duration(running_machine &machine)
53375362{
5363   saturn_state *state = machine.driver_data<saturn_state>();
5364
53385365   if(STV_VDP2_HRES & 4)
5339   {
5340      switch(STV_VDP2_HRES & 1)
5341      {
5342         case 0: return 45; //31kHz Monitor
5343         case 1: return 82; //Hi-Vision Monitor
5344      }
5345   }
5366      return (STV_VDP2_HRES & 1) ? 480+82 : 480+45; //Hi-Vision / 31kHz Monitor
53465367
5347   switch(STV_VDP2_VRES & 3)
5348   {
5349      case 0: return 40; //264-224
5350      case 1: return 24; //264-240
5351      case 2: return 8; //264-256
5352      case 3: return 8; //264-256
5353   }
5368   if((STV_VDP2_LSMD & 3) == 3)
5369      return 264*2;
53545370
5355   return 0;
5371   return 264;
53565372}
53575373
53585374static UINT8 get_odd_bit(running_machine &machine)
53595375{
5376   saturn_state *state = machine.driver_data<saturn_state>();
53605377   static int cur_v;
53615378   cur_v = machine.primary_screen->vpos();
53625379
r11640r11641
53695386      return 0;
53705387}
53715388
5372READ32_HANDLER ( stv_vdp2_regs_r )
5373{
5374//  if (offset!=1) if(LOG_VDP2) logerror ("VDP2: Read from Registers, Offset %04x\n",offset);
5375
5376   switch(offset)
5377   {
5378      case 0x4/4:
5379      {
5380         /*Screen Status Register*/
5381         stv_vblank = stv_get_vblank(space->machine());
5382         stv_hblank = get_hblank(space->machine());
5383         stv_odd = get_odd_bit(space->machine());
5384
5385                           /*VBLANK              HBLANK            ODD               PAL    */
5386         stv_vdp2_regs[offset] = (stv_vblank<<19) | (stv_hblank<<18) | (stv_odd << 17) | (0 << 16);
5387         break;
5388      }
5389      case 0x8/4:
5390      /*H/V Counter Register*/
5391      {
5392         static UINT16 h_count,v_count;
5393         /* TODO: handle various h/v settings. */
5394         h_count = space->machine().primary_screen->hpos() & 0x3ff;
5395         v_count = space->machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff);
5396         stv_vdp2_regs[offset] = (h_count<<16)|(v_count);
5397         if(LOG_VDP2) logerror("CPU %s PC(%08x) = VDP2: H/V counter read : %08x\n", space->device().tag(), cpu_get_pc(&space->device()),stv_vdp2_regs[offset]);
5398         break;
5399      }
5400   }
5401   return stv_vdp2_regs[offset];
5402}
5403
54045389static void stv_vdp2_state_save_postload(running_machine &machine)
54055390{
5406   UINT8 *stv_vdp2_vram_decode = stv_vdp2_gfx_decode;
5391   saturn_state *state = machine.driver_data<saturn_state>();
5392   UINT8 *gfxdata = state->m_vdp2.gfx_decode;
54075393   int offset;
54085394   UINT32 data;
54095395
54105396   for ( offset = 0; offset < 0x100000/4; offset++ )
54115397   {
5412      data = stv_vdp2_vram[offset];
5398      data = state->m_vdp2_vram[offset];
54135399      /* put in gfx region for easy decoding */
5414      stv_vdp2_vram_decode[offset*4+0] = (data & 0xff000000) >> 24;
5415      stv_vdp2_vram_decode[offset*4+1] = (data & 0x00ff0000) >> 16;
5416      stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8;
5417      stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0;
5400      gfxdata[offset*4+0] = (data & 0xff000000) >> 24;
5401      gfxdata[offset*4+1] = (data & 0x00ff0000) >> 16;
5402      gfxdata[offset*4+2] = (data & 0x0000ff00) >> 8;
5403      gfxdata[offset*4+3] = (data & 0x000000ff) >> 0;
54185404
54195405      gfx_element_mark_dirty(machine.gfx[0], offset/8);
54205406      gfx_element_mark_dirty(machine.gfx[1], offset/8);
r11640r11641
54395425
54405426static void stv_vdp2_exit (running_machine &machine)
54415427{
5442   stv_vdp2_roz_bitmap[0] =  stv_vdp2_roz_bitmap[1] = NULL;
5428   saturn_state *state = machine.driver_data<saturn_state>();
5429   state->m_vdp2.roz_bitmap[0] =  state->m_vdp2.roz_bitmap[1] = NULL;
54435430}
54445431
54455432static int stv_vdp2_start (running_machine &machine)
54465433{
5434   saturn_state *state = machine.driver_data<saturn_state>();
54475435   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stv_vdp2_exit), &machine));
54485436
5449   stv_vdp2_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 );
5450   stv_vdp2_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart.
5451   stv_vdp2_cram = auto_alloc_array_clear(machine, UINT32, 0x080000/4 );
5452   stv_vdp2_gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 );
5437   state->m_vdp2_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 );
5438   state->m_vdp2_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart.
5439   state->m_vdp2_cram = auto_alloc_array_clear(machine, UINT32, 0x080000/4 );
5440   state->m_vdp2.gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 );
54535441
5454   stv_vdp2_render_rbg0 = 1;
54555442//  machine.gfx[0]->color_granularity=4;
54565443//  machine.gfx[1]->color_granularity=4;
54575444
r11640r11641
54595446   stv_rbg_cache_data.is_cache_dirty = 3;
54605447   memset( &stv_vdp2_layer_data_placement, 0, sizeof(stv_vdp2_layer_data_placement));
54615448
5462   state_save_register_global_pointer(machine, stv_vdp2_regs, 0x040000/4);
5463   state_save_register_global_pointer(machine, stv_vdp2_vram, 0x100000/4);
5464   state_save_register_global_pointer(machine, stv_vdp2_cram, 0x080000/4);
5449   state_save_register_global_pointer(machine, state->m_vdp2_regs, 0x040000/4);
5450   state_save_register_global_pointer(machine, state->m_vdp2_vram, 0x100000/4);
5451   state_save_register_global_pointer(machine, state->m_vdp2_cram, 0x080000/4);
54655452   machine.save().register_postload(save_prepost_delegate(FUNC(stv_vdp2_state_save_postload), &machine));
54665453
54675454   return 0;
r11640r11641
54705457/* maybe we should move this to video/stv.c */
54715458VIDEO_START( stv_vdp2 )
54725459{
5473   stv_vdp2_roz_bitmap[0] =  stv_vdp2_roz_bitmap[1] = NULL;
5460   saturn_state *state = machine.driver_data<saturn_state>();
5461   state->m_vdp2.roz_bitmap[0] =  state->m_vdp2.roz_bitmap[1] = NULL;
54745462   stv_vdp2_start(machine);
54755463   stv_vdp1_start(machine);
54765464   debug.l_en = 0xff;
54775465   debug.error = 0xffffffff;
54785466   debug.roz = 0;
5479   gfx_element_set_source(machine.gfx[0], stv_vdp2_gfx_decode);
5480   gfx_element_set_source(machine.gfx[1], stv_vdp2_gfx_decode);
5481   gfx_element_set_source(machine.gfx[2], stv_vdp2_gfx_decode);
5482   gfx_element_set_source(machine.gfx[3], stv_vdp2_gfx_decode);
5483   gfx_element_set_source(machine.gfx[4], stv_vdp1_gfx_decode);
5484   gfx_element_set_source(machine.gfx[5], stv_vdp1_gfx_decode);
5485   gfx_element_set_source(machine.gfx[6], stv_vdp1_gfx_decode);
5486   gfx_element_set_source(machine.gfx[7], stv_vdp1_gfx_decode);
5467   gfx_element_set_source(machine.gfx[0], state->m_vdp2.gfx_decode);
5468   gfx_element_set_source(machine.gfx[1], state->m_vdp2.gfx_decode);
5469   gfx_element_set_source(machine.gfx[2], state->m_vdp2.gfx_decode);
5470   gfx_element_set_source(machine.gfx[3], state->m_vdp2.gfx_decode);
5471   gfx_element_set_source(machine.gfx[4], state->m_vdp1.gfx_decode);
5472   gfx_element_set_source(machine.gfx[5], state->m_vdp1.gfx_decode);
5473   gfx_element_set_source(machine.gfx[6], state->m_vdp1.gfx_decode);
5474   gfx_element_set_source(machine.gfx[7], state->m_vdp1.gfx_decode);
54875475}
54885476
5489static void stv_vdp2_dynamic_res_change(running_machine &machine)
5477void stv_vdp2_dynamic_res_change(running_machine &machine)
54905478{
5491   static UINT8 old_vres = 0,old_hres = 0;
5479   saturn_state *state = machine.driver_data<saturn_state>();
5480   int horz_res,vert_res;
54925481
54935482   switch( STV_VDP2_VRES & 3 )
54945483   {
r11640r11641
55175506      case 6: horz_res = 640; vert_res = 480; break;
55185507      case 7: horz_res = 704; vert_res = 480; break;
55195508   }
5520//  horz_res+=1;
5521//  vert_res*=2;
5522   if(old_vres != vert_res || old_hres != horz_res)
5509
55235510   {
55245511      int vblank_period,hblank_period;
55255512      rectangle visarea = machine.primary_screen->visible_area();
r11640r11641
55305517
55315518      vblank_period = get_vblank_duration(machine);
55325519      hblank_period = get_hblank_duration(machine);
5533//      popmessage("%d",vblank_period);
5534//      hblank_period = get_hblank_duration(machine.primary_screen);
5535      machine.primary_screen->configure((horz_res+hblank_period), (vert_res+vblank_period), visarea, machine.primary_screen->frame_period().attoseconds );
55365520
5537      old_vres = vert_res;
5538      old_hres = horz_res;
5521      //printf("%d %d %d %d\n",horz_res,vert_res,horz_res+hblank_period,vblank_period);
5522
5523      machine.primary_screen->configure((horz_res+hblank_period), (vblank_period), visarea, machine.primary_screen->frame_period().attoseconds );
55395524   }
55405525//  machine.primary_screen->set_visible_area(0*8, horz_res-1,0*8, vert_res-1);
55415526   //if(LOG_VDP2) popmessage("%04d %04d",horz_res-1,vert-1);
r11640r11641
55455530/*TODO: Optimize this...*/
55465531static void   stv_vdp2_fade_effects(running_machine &machine)
55475532{
5533   saturn_state *state = machine.driver_data<saturn_state>();
55485534   /*
55495535    Note:We have to use temporary storages because palette_get_color must use
55505536    variables setted with unsigned int8
r11640r11641
56245610                  (0 = OR,1 = AND)
56255611******************************************************************************************/
56265612
5627static void stv_vdp2_get_window0_coordinates(UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y)
5613static void stv_vdp2_get_window0_coordinates(running_machine &machine,UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y)
56285614{
5615   saturn_state *state = machine.driver_data<saturn_state>();
5616
56295617   /*W0*/
56305618   switch(STV_VDP2_LSMD & 3)
56315619   {
r11640r11641
56695657   }
56705658}
56715659
5672static void stv_vdp2_get_window1_coordinates(UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y)
5660static void stv_vdp2_get_window1_coordinates(running_machine &machine,UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y)
56735661{
5662   saturn_state *state = machine.driver_data<saturn_state>();
5663
56745664   /*W1*/
56755665   switch(STV_VDP2_LSMD & 3)
56765666   {
r11640r11641
57155705
57165706}
57175707
5718static int stv_vdp2_window_process(int x,int y)
5708static int stv_vdp2_window_process(running_machine &machine,int x,int y)
57195709{
57205710   UINT16 s_x=0,e_x=0,s_y=0,e_y=0;
57215711
57225712   if ((stv2_current_tilemap.window_control & 6) == 0)
57235713      return 0;
57245714
5725   stv_vdp2_get_window0_coordinates(&s_x, &e_x, &s_y, &e_y);
5715   stv_vdp2_get_window0_coordinates(machine,&s_x, &e_x, &s_y, &e_y);
57265716
57275717   if(stv2_current_tilemap.window_control & 2)
57285718   {
r11640r11641
57525742      }
57535743   }
57545744
5755   stv_vdp2_get_window1_coordinates(&s_x, &e_x, &s_y, &e_y);
5745   stv_vdp2_get_window1_coordinates(machine,&s_x, &e_x, &s_y, &e_y);
57565746
57575747   if(stv2_current_tilemap.window_control & 4)
57585748   {
r11640r11641
57855775//  return 1;
57865776}
57875777
5788static int stv_vdp2_apply_window_on_layer(rectangle *cliprect)
5778static int stv_vdp2_apply_window_on_layer(running_machine &machine,rectangle *cliprect)
57895779{
5780   //saturn_state *state = machine.driver_data<saturn_state>();
57905781   UINT16 s_x=0,e_x=0,s_y=0,e_y=0;
57915782
57925783   if ( stv2_current_tilemap.window_control == 0x12 )
57935784   {
57945785      /* w0, transparent outside supported */
5795      stv_vdp2_get_window0_coordinates(&s_x, &e_x, &s_y, &e_y);
5786      stv_vdp2_get_window0_coordinates(machine,&s_x, &e_x, &s_y, &e_y);
57965787
57975788      if ( s_x > cliprect->min_x ) cliprect->min_x = s_x;
57985789      if ( e_x < cliprect->max_x ) cliprect->max_x = e_x;
r11640r11641
58045795   else if ( stv2_current_tilemap.window_control == 0x24 )
58055796   {
58065797      /* w1, transparent outside supported */
5807      stv_vdp2_get_window1_coordinates(&s_x, &e_x, &s_y, &e_y);
5798      stv_vdp2_get_window1_coordinates(machine,&s_x, &e_x, &s_y, &e_y);
58085799
58095800      if ( s_x > cliprect->min_x ) cliprect->min_x = s_x;
58105801      if ( e_x < cliprect->max_x ) cliprect->max_x = e_x;
r11640r11641
58245815static int      stv_sprite_priorities_usage_valid;
58255816static UINT8   stv_sprite_priorities_in_fb_line[512][8];
58265817
5818#define STV_VDP1_TVMR ((state->m_vdp1_regs[0x000/4] >> 16)&0x0000ffff)
5819#define STV_VDP1_TVM  ((STV_VDP1_TVMR & 0x0007) >> 0)
58275820
58285821static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 pri)
58295822{
5823   saturn_state *state = machine.driver_data<saturn_state>();
58305824   int x,y,r,g,b;
58315825   int i;
58325826   UINT16 pix;
r11640r11641
59175911   }
59185912
59195913   /* framebuffer interlace */
5920   if ( (STV_VDP2_LSMD == 2 || STV_VDP2_LSMD == 3) && stv_framebuffer_double_interlace == 0 )
5914   if ( (STV_VDP2_LSMD == 2 || STV_VDP2_LSMD == 3) && state->m_vdp1.framebuffer_double_interlace == 0 )
59215915      interlace_framebuffer = 1;
59225916   else
59235917      interlace_framebuffer = 0;
59245918
59255919   /*Guess:Some games needs that the horizontal sprite size to be doubled
59265920      (TODO: understand the proper settings,it might not work like this)*/
5927   if(STV_VDP2_LSMD == 3 && /*((STV_VDP2_HRES & 3) != 3) &&*/ (!(stv_framebuffer_mode & 1)))
5921   if(STV_VDP1_TVM == 0 && STV_VDP2_HRES & 2) // astrass & findlove
59285922      double_x = 1;
59295923   else
59305924      double_x = 0;
r11640r11641
59415935   mycliprect.max_x = cliprect->max_x;
59425936   mycliprect.min_y = cliprect->min_y;
59435937   mycliprect.max_y = cliprect->max_y;
5944   stv_vdp2_apply_window_on_layer(&mycliprect);
5938   stv_vdp2_apply_window_on_layer(machine,&mycliprect);
59455939
59465940   if (interlace_framebuffer == 0 && double_x == 0 )
59475941   {
r11640r11641
59535947               if (stv_sprite_priorities_in_fb_line[y][pri] == 0)
59545948                  continue;
59555949
5956            framebuffer_line = stv_framebuffer_display_lines[y];
5950            framebuffer_line = state->m_vdp1.framebuffer_display_lines[y];
59575951            bitmap_line = BITMAP_ADDR16(bitmap, y, 0);
59585952
59595953            for ( x = mycliprect.min_x; x <= mycliprect.max_x; x++ )
r11640r11641
59725966                  r = (pix & 0x1f);
59735967                  if ( color_offset_pal )
59745968                  {
5975                     stv_vdp2_compute_color_offset_RGB555( &r, &g, &b, STV_VDP2_SPCOSL );
5969                     stv_vdp2_compute_color_offset_RGB555( machine, &r, &g, &b, STV_VDP2_SPCOSL );
59765970                  }
59775971                  bitmap_line[x] = b | g << 5 | r << 10;
59785972               }
r11640r11641
60256019               if (stv_sprite_priorities_in_fb_line[y][pri] == 0)
60266020                  continue;
60276021
6028            framebuffer_line = stv_framebuffer_display_lines[y];
6022            framebuffer_line = state->m_vdp1.framebuffer_display_lines[y];
60296023            bitmap_line = BITMAP_ADDR16(bitmap, y, 0);
60306024
60316025            for ( x = mycliprect.min_x; x <= mycliprect.max_x; x++ )
r11640r11641
60456039                  r = (pix & 0x1f);
60466040                  if ( color_offset_pal )
60476041                  {
6048                     stv_vdp2_compute_color_offset_RGB555( &r, &g, &b, STV_VDP2_SPCOSL );
6042                     stv_vdp2_compute_color_offset_RGB555( machine, &r, &g, &b, STV_VDP2_SPCOSL );
60496043                  }
60506044                  ccr = sprite_ccr[0];
60516045                  if ( STV_VDP2_CCMD )
r11640r11641
61276121            if (stv_sprite_priorities_in_fb_line[y][pri] == 0)
61286122               continue;
61296123
6130         framebuffer_line = stv_framebuffer_display_lines[y];
6124         framebuffer_line = state->m_vdp1.framebuffer_display_lines[y];
61316125         if ( interlace_framebuffer == 0 )
61326126         {
61336127            bitmap_line = BITMAP_ADDR16(bitmap, y, 0);
r11640r11641
61546148               r = (pix & 0x1f);
61556149               if ( color_offset_pal )
61566150               {
6157                  stv_vdp2_compute_color_offset_RGB555( &r, &g, &b, STV_VDP2_SPCOSL );
6151                  stv_vdp2_compute_color_offset_RGB555( machine, &r, &g, &b, STV_VDP2_SPCOSL );
61586152               }
61596153               if ( alpha_enabled == 0 )
61606154               {
r11640r11641
63116305
63126306SCREEN_UPDATE( stv_vdp2 )
63136307{
6308   saturn_state *state = screen->machine().driver_data<saturn_state>();
63146309   static UINT8 pri;
63156310   video_update_vdp1(screen->machine());
63166311
src/mame/video/seta001.c
r11640r11641
180180***************************************************************************/
181181
182182/*
183twineagl:   010 02d 0f 10   (ship)
184tndrcade:   058 02d 07 18   (start of game - yes, flip on!)
185arbalest:   018 02d 0f 10   (logo)
186metafox :   018 021 0f f0   (bomb)
187zingzip :   010 02c 00 0f   (bomb)
188wrofaero:   010 021 00 ff   (test mode)
189thunderl:   010 06c 00 ff   (always?)
190krzybowl:   011 028 c0 ff   (game)
191kiwame  :   016 021 7f 00   (logo)
192oisipuzl:   059 020 00 00   (game - yes, flip on!)
193
194superman:   010 021 07 38   (game)
195twineagl:   000 027 00 0f   (test mode)
183twineagl:   10 2d 0f 10   (ship)
184tndrcade:   58 2d 07 18   (start of game - yes, flip on!)
185arbalest:   18 2d 0f 10   (logo)
186metafox :   18 21 0f f0   (bomb)
187zingzip :   10 2c 00 0f   (bomb)
188wrofaero:   10 21 00 ff   (test mode)
189thunderl:   10 6c 00 ff   (always?)
190krzybowl:   11 28 c0 ff   (game)
191kiwame  :   16 21 7f 00   (logo)
192oisipuzl:   59 20 00 00   (game - yes, flip on!)
193superman:   10 21 07 38   (game)
194twineagl:   00 27 00 0f   (test mode)
195doraemon:   19 2a 00 03   (always)
196196*/
197197
198198
r11640r11641
230230   switch (ctrl & 0x0f)
231231   {
232232      case 0x01:   col0   =   0x4;   break;   // krzybowl
233      case 0x09:   col0   =   0x4;   break;   // doraemon
233234      case 0x06:   col0   =   0x8;   break;   // kiwame
234235
235236      default:   col0   =   0x0;
src/mame/video/deco16ic.c
r11640r11641
398398
399399   width_mask = src_bitmap0->width - 1;
400400   height_mask = src_bitmap0->height - 1;
401   src_y = scrolly + starty;
401   src_y = (scrolly + starty) & height_mask;
402402
403403
404404   for (y = starty; y < endy; y++)
src/mame/video/taito_f3.c
r11640r11641
577577
578578   state->m_f3_game_config=pCFG;
579579
580   state->m_f3_vram =      auto_alloc_array(machine, UINT16, 0x2000/2);
581   state->m_f3_pf_data =   auto_alloc_array(machine, UINT16, 0xc000/2);
582   state->m_videoram =     auto_alloc_array(machine, UINT16, 0x2000/2);
583   state->m_f3_line_ram =  auto_alloc_array(machine, UINT16, 0x10000/2);
584   state->m_f3_pivot_ram = auto_alloc_array(machine, UINT16, 0x10000/2);
585   state->m_spriteram =    auto_alloc_array(machine, UINT16, 0x10000/2);
580   state->m_f3_vram =      auto_alloc_array_clear(machine, UINT16, 0x2000/2);
581   state->m_f3_pf_data =   auto_alloc_array_clear(machine, UINT16, 0xc000/2);
582   state->m_videoram =     auto_alloc_array_clear(machine, UINT16, 0x2000/2);
583   state->m_f3_line_ram =  auto_alloc_array_clear(machine, UINT16, 0x10000/2);
584   state->m_f3_pivot_ram = auto_alloc_array_clear(machine, UINT16, 0x10000/2);
585   state->m_spriteram =    auto_alloc_array_clear(machine, UINT16, 0x10000/2);
586586
587587   if (state->m_f3_game_config->extend) {
588588      state->m_pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,64,32);
src/mame/drivers/bfm_sc1.c
r11640r11641
22
33    Bellfruit scorpion1 driver, (under heavy construction !!!)
44
5    A.G.E Code Copyright J. Wallace and the AGEMAME Development Team.
6    Visit http://agemame.mameworld.info for more information.
7
85    M.A.M.E Core Copyright Nicola Salmoria and the MAME Team,
96    used under license from http://mamedev.org
107
118******************************************************************************************
129
10     04-2011: J Wallace: Fixed watchdog to match actual circuit, also fixed lamping code.
1311  20-01-2007: J Wallace: Tidy up of coding
1412  30-12-2006: J Wallace: Fixed init routines.
1513  07-03-2006: El Condor: Recoded to more accurately represent the hardware setup.
r11640r11641
1816  25-08-2005: Added support for adder2 (Toppoker), added support for NEC upd7759 soundcard
1917
2018Standard scorpion1 memorymap
19Note the similarity to system85 - indeed, the working title for this system was System 88,
20and was considered an update to existing technology. Later revisions made it a platform in
21its own right, prompting marketers to change the name.
22
2123___________________________________________________________________________________
2224   hex     |r/w| D D D D D D D D |
2325 location  |   | 7 6 5 4 3 2 1 0 | function
r11640r11641
119121   int m_mux2_datalo;
120122   int m_mux2_datahi;
121123   int m_mux2_input;
122   int m_watchdog_cnt;
123   int m_watchdog_kicked;
124   UINT8 m_Lamps[256];
125124   UINT8 m_sc1_Inputs[64];
126125   UINT8 m_codec_data[256];
127126};
r11640r11641
164163static INTERRUPT_GEN( timer_irq )
165164{
166165   bfm_sc1_state *state = device->machine().driver_data<bfm_sc1_state>();
167   if ( state->m_watchdog_kicked )
168   {
169      state->m_watchdog_cnt    = 0;
170      state->m_watchdog_kicked = 0;
171   }
172   else
173   {
174      state->m_watchdog_cnt++;
175      if ( state->m_watchdog_cnt > 2 )   // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine
176      {  // reset board
177         device->machine().schedule_soft_reset();// reset entire machine. CPU 0 should be enough, but that doesn't seem to work !!
178         return;
179      }
180   }
181166
182167   if ( state->m_is_timer_enabled )
183168   {
r11640r11641
421406
422407         for ( i = 0; i < 8; i++ )
423408         {
424            state->m_Lamps[ BFM_strcnv[offset  ] ] = state->m_mux1_datalo & pattern?1:0;
425            state->m_Lamps[ BFM_strcnv[offset+8] ] = state->m_mux1_datahi & pattern?1:0;
409            output_set_lamp_value(BFM_strcnv[offset  ], (state->m_mux1_datalo & pattern?1:0) );
410            output_set_lamp_value(BFM_strcnv[offset+8], (state->m_mux1_datahi & pattern?1:0) );
426411            pattern<<=1;
427412            offset++;
428413         }
429414
430         if (strobe == 0)
431         {
432            for ( i = 0; i < 256; i++ )
433            {
434               output_set_lamp_value(i, state->m_Lamps[i]);
435            }
436         }
437415      }
438416
439417      if ( !(data & 0x08) )
r11640r11641
505483
506484         for ( i = 0; i < 8; i++ )
507485         {
508            state->m_Lamps[ BFM_strcnv[offset  ] ] = state->m_mux2_datalo & pattern?1:0;
509            state->m_Lamps[ BFM_strcnv[offset+8] ] = state->m_mux2_datahi & pattern?1:0;
486            output_set_lamp_value(BFM_strcnv[offset  ], (state->m_mux2_datalo & pattern?1:0) );
487            output_set_lamp_value(BFM_strcnv[offset+8], (state->m_mux2_datahi & pattern?1:0) );
510488            pattern<<=1;
511489            offset++;
512490         }
r11640r11641
536514}
537515
538516/////////////////////////////////////////////////////////////////////////////////////
539
540static WRITE8_HANDLER( watchdog_w )
541{
542   bfm_sc1_state *state = space->machine().driver_data<bfm_sc1_state>();
543   state->m_watchdog_kicked = 1;
544}
545
546/////////////////////////////////////////////////////////////////////////////////////
547517// serial port //////////////////////////////////////////////////////////////////////
548518/////////////////////////////////////////////////////////////////////////////////////
549519
r11640r11641
797767
798768   AM_RANGE(0x4000, 0x5FFF) AM_ROM                     // 8k  ROM
799769   AM_RANGE(0x6000, 0x7FFF) AM_ROMBANK("bank1")               // 8k  paged ROM (4 pages)
800   AM_RANGE(0x8000, 0xFFFF) AM_ROM AM_WRITE (watchdog_w)//AM_RAM_WRITE(watchdog_w) // 32k ROM
770   AM_RANGE(0x8000, 0xFFFF) AM_ROM AM_WRITE (watchdog_reset_w) // 32k ROM
801771
802772ADDRESS_MAP_END
803773
r11640r11641
845815
846816   AM_RANGE(0x4000, 0x5FFF) AM_ROM                     // 8k  ROM
847817   AM_RANGE(0x6000, 0x7FFF) AM_ROMBANK("bank1")               // 8k  paged ROM (4 pages)
848   AM_RANGE(0x8000, 0xFFFF) AM_ROM AM_WRITE(watchdog_w)   // 32k ROM
818   AM_RANGE(0x8000, 0xFFFF) AM_ROM AM_WRITE(watchdog_reset_w)   // 32k ROM
849819
850820ADDRESS_MAP_END
851821
r11640r11641
890860
891861   AM_RANGE(0x4000, 0x5FFF) AM_ROM                     // 8k  ROM
892862   AM_RANGE(0x6000, 0x7FFF) AM_ROMBANK("bank1")               // 8k  paged ROM (4 pages)
893   AM_RANGE(0x8000, 0xFFFF) AM_ROM AM_WRITE(watchdog_w)   // 32k ROM
863   AM_RANGE(0x8000, 0xFFFF) AM_ROM AM_WRITE(watchdog_reset_w)   // 32k ROM
894864
895865ADDRESS_MAP_END
896866
r11640r11641
12441214   MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4)         // 6809 CPU at 1 Mhz
12451215   MCFG_CPU_PROGRAM_MAP(memmap)                  // setup read and write memorymap
12461216   MCFG_CPU_PERIODIC_INT(timer_irq, 1000 )            // generate 1000 IRQ's per second
1217   MCFG_WATCHDOG_TIME_INIT(PERIOD_OF_555_MONOSTABLE(120000,100e-9))
12471218
12481219   MCFG_SPEAKER_STANDARD_MONO("mono")
12491220   MCFG_SOUND_ADD("aysnd",AY8912, MASTER_CLOCK/4)
src/mame/drivers/mpu4.c
r11640r11641
27842784   AM_RANGE(0x0850, 0x0850) AM_WRITE(bankswitch_w) // write bank (rom page select)
27852785   AM_RANGE(0x0858, 0x0858) AM_WRITE(bankswitch_w) // write bank (rom page select)
27862786   AM_RANGE(0x0878, 0x0878) AM_WRITE(bankset_w)    // write bank (rom page select)
2787//   AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w) //Runs hoppers
2787//  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w) //Runs hoppers
27882788   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE_MODERN("ptm_ic2", ptm6840_device, read, write)/* PTM6840 IC2 */
27892789   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE_MODERN("pia_ic3", pia6821_device, read, write)     /* PIA6821 IC3 */
27902790   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE_MODERN("pia_ic4", pia6821_device, read, write)     /* PIA6821 IC4 */
src/mame/drivers/play_2.c
r11640r11641
2828{
2929}
3030
31static COSMAC_INTERFACE( cdp1802_config )
32{
33   DEVCB_NULL,
34   DEVCB_NULL,
35   DEVCB_NULL,
36   DEVCB_NULL,
37   DEVCB_NULL,
38   DEVCB_NULL,
39   DEVCB_NULL,
40   DEVCB_NULL,
41   DEVCB_NULL,
42   NULL,
43   DEVCB_NULL,
44   DEVCB_NULL
45};
46
3147static MACHINE_CONFIG_START( play_2, play_2_state )
3248   /* basic machine hardware */
3349   MCFG_CPU_ADD("maincpu", COSMAC, 2950000)
3450   MCFG_CPU_PROGRAM_MAP(play_2_map)
51   MCFG_CPU_CONFIG(cdp1802_config)
3552
3653   MCFG_MACHINE_RESET( play_2 )
3754
src/mame/drivers/majorpkr.c
r11640r11641
437437
438438  To Do:
439439
440  - Workaround to hide the unused last column (16 pixels), but forced on the 6845.
440441  - Find the input that unlocks the "KEY-LOCK" mode in the settings.
441442  - Proper flip mode.
442443  - Resistors Network.
r11640r11641
532533       form the render. We need more proof about how the video is working.
533534    */
534535   custom_clip.min_x=cliprect->min_x;
535//  custom_clip.max_x=cliprect->max_x-16;
536   custom_clip.max_x=cliprect->max_x;
536   custom_clip.max_x=cliprect->max_x-16;
537537   custom_clip.min_y=cliprect->min_y;
538538   custom_clip.max_y=cliprect->max_y;
539539
r11640r11641
813813   AM_RANGE(0x14, 0x14) AM_READ_PORT("TEST")   /* "freeze" switch */
814814   AM_RANGE(0x14, 0x14) AM_WRITE(lamps_b_w)   /* lamps b out */
815815
816//  AM_RANGE(0x30, 0x30) AM_DEVWRITE("crtc", mc6845_address_w)
817//  AM_RANGE(0x31, 0x31) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
816   AM_RANGE(0x30, 0x30) AM_DEVWRITE_MODERN("crtc", mc6845_device, address_w)
817   AM_RANGE(0x31, 0x31) AM_DEVREADWRITE_MODERN("crtc", mc6845_device, register_r, register_w)
818818
819819   AM_RANGE(0x50, 0x50) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
820820   AM_RANGE(0x60, 0x60) AM_WRITENOP   /* leftover from a PSG SN76489/96? */
r11640r11641
10391039   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
10401040   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
10411041   MCFG_SCREEN_SIZE((47+1)*16, (36+1)*8)            /* through CRTC registers: 768 x 296 */
1042//  MCFG_SCREEN_VISIBLE_AREA(0, (36*16)-1, 0, (28*8)-1) /* through CRTC registers: 560(+16) x 224 */
1043   MCFG_SCREEN_VISIBLE_AREA(0, (35*16)-1, 0, (28*8)-1)
1042   MCFG_SCREEN_VISIBLE_AREA(0, (36*16)-1, 0, (28*8)-1) /* through CRTC registers: 560(+16) x 224 */
10441043
10451044   MCFG_GFXDECODE(majorpkr)
10461045   MCFG_PALETTE_LENGTH(0x100 * 16)
src/mame/drivers/champbwl.c
r11640r11641
154154#include "cpu/z80/z80.h"
155155#include "sound/x1_010.h"
156156#include "machine/nvram.h"
157#include "machine/ticket.h"
157158#include "includes/tnzs.h"
158159#include "video/seta001.h"
159160
r11640r11641
164165      : tnzs_state(mconfig, type, tag) { }
165166
166167   UINT8    m_last_trackball_val[2];
167//  UINT8 *  m_nvram; // currently this uses generic_nvram
168168};
169169
170170
r11640r11641
219219   AM_RANGE(0xf800, 0xf800) AM_WRITENOP
220220ADDRESS_MAP_END
221221
222
223
224static WRITE8_HANDLER( doraemon_outputs_w )
225{
226   coin_counter_w(space->machine(), 0, data & 1);   // coin in counter
227   coin_counter_w(space->machine(), 1, data & 2);   // gift out counter
228
229   coin_lockout_w(space->machine(), 0, ~data & 8);   // coin lockout
230   ticket_dispenser_w(space->machine().device("hopper"), 0, (data & 0x04) ? 0x00 : 0x80);   // gift out motor
231
232   memory_set_bank(space->machine(), "bank1", (data & 0x30) >> 4);
233
234//   popmessage("%02x", data);
235}
236
237static ADDRESS_MAP_START( doraemon, AS_PROGRAM, 8 )
238   AM_RANGE(0x0000, 0x3fff) AM_ROM
239   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
240   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("nvram")
241   AM_RANGE(0xa000, 0xafff) AM_RAM AM_DEVREADWRITE("spritegen", spritecodelow_r8, spritecodelow_w8)
242   AM_RANGE(0xb000, 0xbfff) AM_RAM AM_DEVREADWRITE("spritegen", spritecodehigh_r8, spritecodehigh_w8)
243   AM_RANGE(0xc000, 0xc07f) AM_DEVREADWRITE("x1snd", seta_sound_r,seta_sound_w)   // Sound
244   AM_RANGE(0xe000, 0xe2ff) AM_RAM AM_DEVREADWRITE("spritegen", spriteylow_r8, spriteylow_w8)
245   AM_RANGE(0xe300, 0xe303) AM_DEVWRITE("spritegen", spritectrl_w8)
246   AM_RANGE(0xe800, 0xe800) AM_DEVWRITE("spritegen", spritebgflag_w8)   /* enable / disable background transparency */
247   AM_RANGE(0xf000, 0xf000) AM_READ_PORT("IN0") AM_WRITE(doraemon_outputs_w)
248   AM_RANGE(0xf002, 0xf002) AM_READ_PORT("IN1") AM_WRITENOP   // Ack?
249   AM_RANGE(0xf004, 0xf004) AM_WRITENOP                  // Ack?
250   AM_RANGE(0xf006, 0xf006) AM_READ_PORT("DSW") AM_WRITENOP   // Ack?
251   AM_RANGE(0xf800, 0xf800) AM_WRITENOP                  // 0
252ADDRESS_MAP_END
253
254
255
222256static INPUT_PORTS_START( champbwl )
223257   PORT_START("IN0")
224258   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
r11640r11641
312346   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(45) PORT_CENTERDELTA(0) PORT_REVERSE
313347INPUT_PORTS_END
314348
349
350
351static INPUT_PORTS_START( doraemon )
352   PORT_START("DSW")   // f006
353   PORT_DIPNAME( 0x0f, 0x09, "Gift Out" )
354   PORT_DIPSETTING(    0x0f,   "2 %" )
355   PORT_DIPSETTING(    0x0e,   "5 %" )
356   PORT_DIPSETTING(    0x0d,   "7 %" )
357   PORT_DIPSETTING(    0x0c,  "10 %" )
358   PORT_DIPSETTING(    0x0b,  "12 %" )
359   PORT_DIPSETTING(    0x0a,  "15 %" )
360   PORT_DIPSETTING(    0x09,  "20 %" )
361   PORT_DIPSETTING(    0x08,  "25 %" )
362   PORT_DIPSETTING(    0x07,  "30 %" )
363   PORT_DIPSETTING(    0x06,  "40 %" )
364   PORT_DIPSETTING(    0x05,  "60 %" )
365   PORT_DIPSETTING(    0x04,  "80 %" )
366//   PORT_DIPSETTING(    0x03, "100 %" )
367//   PORT_DIPSETTING(    0x02, "100 %" )
368//   PORT_DIPSETTING(    0x01, "100 %" )
369   PORT_DIPSETTING(    0x00, "100 %" )
370   PORT_DIPNAME( 0x10, 0x10, "Games For 100 Yen" )
371   PORT_DIPSETTING(    0x10, "1" )
372   PORT_DIPSETTING(    0x00, "2" )
373   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
374   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
375   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
376   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
377   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
378   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
379   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
380   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
381   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
382
383   PORT_START("IN0")   // f000
384   PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SERVICE2 )   PORT_NAME( "Data Clear" )
385   PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_COIN1    )
386   PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
387   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
388   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
389   PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
390   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SERVICE3 )   PORT_NAME( "Freeze" )
391   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
392
393   PORT_START("IN1")   // f002
394   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1  )
395   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2  )
396   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
397   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN  )
398   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3  )
399   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SPECIAL  ) PORT_READ_LINE_DEVICE("hopper", ticket_dispenser_line_r)   // sensor
400   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN  )
401   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
402INPUT_PORTS_END
403
404
405
315406static const gfx_layout charlayout =
316407{
317408   16,16,
r11640r11641
413504   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
414505MACHINE_CONFIG_END
415506
507
508
509
510static SCREEN_UPDATE( doraemon )
511{
512   bitmap_fill(bitmap, cliprect, 0x1f0);
513
514   screen->machine().device<seta001_device>("spritegen")->set_bg_yoffsets( 0x00, 0x01 );
515   screen->machine().device<seta001_device>("spritegen")->set_fg_yoffsets( 0x00, 0x10 );
516
517   screen->machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen->machine(), bitmap, cliprect, 0x800, 1 );
518   return 0;
519}
520
521static SCREEN_EOF( doraemon )
522{
523   machine.device<seta001_device>("spritegen")->setac_eof();
524}
525
526static MACHINE_START( doraemon )
527{
528   UINT8 *ROM = machine.region("maincpu")->base();
529   memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000);
530}
531
532static MACHINE_CONFIG_START( doraemon, tnzs_state )
533
534   /* basic machine hardware */
535   MCFG_CPU_ADD("maincpu", Z80, XTAL_14_31818MHz/4)
536   MCFG_CPU_PROGRAM_MAP(doraemon)
537   MCFG_CPU_VBLANK_INT("screen", irq0_line_hold)
538
539   MCFG_NVRAM_ADD_0FILL("nvram")
540   MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0)
541   MCFG_TICKET_DISPENSER_ADD("hopper", 2000, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_LOW )
542
543   MCFG_MACHINE_START(doraemon)
544
545   /* video hardware */
546   MCFG_SCREEN_ADD("screen", RASTER)
547   MCFG_SCREEN_REFRESH_RATE(60)
548   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
549   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
550   MCFG_SCREEN_SIZE(320, 256)
551   MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 16, 256-16-1)
552   MCFG_SCREEN_UPDATE(doraemon)
553   MCFG_SCREEN_EOF(doraemon)
554
555   MCFG_GFXDECODE(champbwl)
556   MCFG_PALETTE_LENGTH(512)
557
558   MCFG_PALETTE_INIT(arknoid2)
559
560   /* sound hardware */
561   MCFG_SPEAKER_STANDARD_MONO("mono")
562   MCFG_SOUND_ADD("x1snd", X1_010, XTAL_14_31818MHz)
563   MCFG_SOUND_CONFIG(champbwl_sound_intf)
564   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
565MACHINE_CONFIG_END
566
567
568
416569ROM_START( champbwl )
417570   ROM_REGION( 0x20000, "maincpu", 0 )      /* Z80 Code */
418571   ROM_LOAD( "ab001001.u1",  0x10000, 0x10000, CRC(6c6f7675) SHA1(19834f25f2644ae5d156c1e1bbb3fc50cae10fd2) )
r11640r11641
437590   ROM_LOAD( "champbwl.nv",  0x000, 0x800, CRC(1d46aa8e) SHA1(a733cf86cfb26d98fb4c491d7f779a7a1c8ff228) )
438591ROM_END
439592
440GAME( 1989, champbwl, 0, champbwl, champbwl, 0, ROT270, "Seta / Romstar Inc.", "Championship Bowling", GAME_SUPPORTS_SAVE )
593/*
594
595Doraemon no Eawase Montage (prototype)
596Sunsoft / Epoch / Fujiko - Shogakukan - TV Asahi
597
598This PCB was obtained from a collector who was invited to purchase some inventory when Sunsoft closed its U.S. offices in 2001.
599Among the items he acquired was a small JAMMA cabinet with no keys to open its locked door.
600When the lock was drilled out, this game was discovered inside the cabinet.
601
602PCB Layout
603----------
604
605P0-094A Sun Electronics Corporation
606|---------------------------------------------------------|
607| MB3712     SW2         U27-01    U22   U15   U9   U7    |
608|                 X1-007 U26-01                           |
609|      VOL                                                |
610|                                                         |
611|         DSW2(8)  DSW1(8)                                |
612|                                                         |
613|        4050                                             |
614|                                                         |
615|                                      X1-002A            |
616|      CN1  X1-004                                        |
617|J                                                3V_BATT |
618|A                        2063         X1-001A            |
619|M                                                        |
620|M                                                   SW3  |
621|A         14.31818MHz                                    |
622|                            4520                         |
623|                                                         |
624|                                                   2128  |
625|       X1-010                                            |
626|                                                         |
627|                                                         |
628| 3404  U51   U43                                         |
629|                                                         |
630|                                          Z8400AB1   U1  |
631|---------------------------------------------------------|
632
633Notes:
634      2063          - Toshiba TMM2063AP-10 8K x8 SRAM (DIP28)
635      2128          - MSM2128-15RS 2K x8 SRAM (DIP24)
636      MB3712        - Fujitsu MB3712 5.7 Watt Power AMP (SIP8)
637      4050          - Toshiba TC4050BCP Non-Inverting Hex Buffer / Converter (DIP16)
638      4520          - Hitachi HD14520 Dual Up Counter (DIP16)
639      3404          - Japan Radio Co. JRC3404 Low Power Quad Op AMP (DIP8)
640      SW2           - Reset Switch
641      SW3           - 2-Position Switch (when ON, powers 6116 RAM near it)
642      3V_BATT       - 3V Lithium Coin Battery
643      CN1           - 10-pin Connector
644
645      Custom IC's -
646                    X1-001A (SDIP64) \ Sprite Generators
647                    X1-002A (SDIP64) /
648                    X1-004  (SDIP52)   Inputs [4 wires going to small board with DSWA(10) & DSWB(10)]
649                    X1-007  (SDIP42)   Video DAC
650                    X1-010  (QFP80)    Sound Chip, 16Bit PCM
651
652      ROMs -
653            Filename  Type                          Use
654            -----------------------------------------------
655            U1        27C1001 UV EEPROM (FDIP32W)   Z80 Program
656
657            U7        27C1001 UV EEPROM (FDIP32W) \
658            U9        27C1001 UV EEPROM (FDIP32W) | GFX
659            U15       27C1001 UV EEPROM (FDIP32W) |
660            U22       27C1001 UV EEPROM (FDIP32W) /
661
662            U26-01    82S147 PROM (DIP20)
663            U27-01    82S147 PROM (DIP20)
664
665            U43       27C4001 UV EEPROM (DIP32)   \
666            U51       27C4001 UV EEPROM (DIP32)   / PCM Samples
667*/
668
669ROM_START( doraemon )
670   ROM_REGION( 0x30000, "maincpu", 0 )
671   ROM_LOAD( "u1.bin", 0x00000, 0x20000, CRC(d338b9ca) SHA1(5f59c994db81577dc6074362c8b6b93f8fe592f6) )
672   ROM_RELOAD(         0x10000, 0x20000 )      /* banked at 4000-7fff */
673
674   ROM_REGION( 0x80000, "gfx1", 0 )
675   ROM_LOAD( "u22.bin", 0x00000, 0x20000, CRC(b264ac2d) SHA1(0529fd1b88ba61dcf72019c7b01e9b939b6e3f2e) )
676   ROM_LOAD( "u15.bin", 0x20000, 0x20000, CRC(2985df6f) SHA1(fd2dae7169c14d07beaf870b0b8c248deb6b6c03) )
677   ROM_LOAD( "u9.bin",  0x40000, 0x20000, CRC(8b774b0e) SHA1(bfcf63b955f74b226a325b0409167e95c2489134) )
678   ROM_LOAD( "u7.bin",  0x60000, 0x20000, CRC(2f850973) SHA1(7dbad160aefaf8b0a85e64f58b9fa0fb4049e65d) )
679
680   ROM_REGION( 0x100000, "x1snd", 0 )
681   ROM_LOAD( "u43.bin", 0x00000, 0x80000, CRC(d684d92a) SHA1(935f39e5efb923a8c7cd0caa6fa6b78a5d78ef30) )
682   ROM_LOAD( "u51.bin", 0x80000, 0x80000, CRC(35cbcb31) SHA1(4ab59e5d5ba917fa2d809e2dc6216c801d3927e7) )
683
684   ROM_REGION( 0x0400, "proms", 0 )
685   ROM_LOAD( "u26-01.bin", 0x00000, 0x200, CRC(9d431542) SHA1(d8895052c5016574f13bf4c096d191534062b9a1) )
686   ROM_LOAD( "u27-01.bin", 0x00200, 0x200, CRC(66245fc7) SHA1(c94d9dce7b557c21a3dc1f3f8a1b29594715c994) )
687ROM_END
688
689GAME( ????, doraemon, 0, doraemon, doraemon, 0, ROT0,   "Sunsoft / Epoch / Fujiko - Shogakukan - TV Asahi", "Doraemon no Eawase Montage (prototype)", GAME_SUPPORTS_SAVE )
690GAME( 1989, champbwl, 0, champbwl, champbwl, 0, ROT270, "Seta / Romstar Inc.",                              "Championship Bowling",                   GAME_SUPPORTS_SAVE )
src/mame/drivers/gundealr.c
r11640r11641
454454      case 0x03:
455455         state->m_rambase[0x001] = 0x03;
456456         /*
457                 read dip switches
458                 3a 00 c0  ld   a,($c000)
459              47        ld   b,a
460              3a 01 c0  ld   a,($c001)
461              c9        ret
462           */
457                read dip switches
458                3a 00 c0  ld   a,($c000)
459                47        ld   b,a
460                3a 01 c0  ld   a,($c001)
461                c9        ret
462            */
463463           for(i=0;i<8;i++)
464464              state->m_rambase[0x010+i] = snipped_cmd03[i];
465465
r11640r11641
470470      case 0x05:
471471         state->m_rambase[0x001] = 0x05;
472472         /*
473                 add a to hl
474              c5          push    bc
475              01 00 00    ld      bc,#0000
476              4f          ld      c,a
477              09          add     hl,bc
478              c1          pop     bc
479              c9          ret
480           */
473                add a to hl
474                c5          push    bc
475                01 00 00    ld      bc,#0000
476                4f          ld      c,a
477                09          add     hl,bc
478                c1          pop     bc
479                c9          ret
480            */
481481           for(i=0;i<8;i++)
482482            state->m_rambase[0x020+i] = snipped_cmd05_2[i];
483483
484484         /*
485              lookup data in table
486              cd 20 e0    call    #e020
487              7e          ld      a,(hl)
488              c9          ret
489           */
485                lookup data in table
486                cd 20 e0    call    #e020
487                7e          ld      a,(hl)
488                c9          ret
489            */
490490           for(i=0;i<5;i++)
491491            state->m_rambase[0x010+i] = snipped_cmd05_1[i];
492492
src/mame/drivers/stvinit.c
r11640r11641
105105
106106    (loops for 263473 instructions)
107107*/
108   saturn_state *state = machine.driver_data<saturn_state>();
109
108110   // master
109111   sh2drc_add_pcflush(machine.device("maincpu"), 0x6018640);
110112   // slave
r11640r11641
112114
113115   DRIVER_INIT_CALL(stv);
114116
115   minit_boost = sinit_boost = 0;
116   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
117   state->m_minit_boost = state->m_sinit_boost = 0;
118   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
117119}
118120
119121DRIVER_INIT(hanagumi)
r11640r11641
161163
162164DRIVER_INIT(puyosun)
163165{
166   saturn_state *state = machine.driver_data<saturn_state>();
167
164168   sh2drc_add_pcflush(machine.device("maincpu"), 0x6021cf0);
165169
166170   sh2drc_add_pcflush(machine.device("slave"), 0x60236fe);
167171
168172   DRIVER_INIT_CALL(stv);
169173
170   minit_boost = sinit_boost = 0;
171   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
174   state->m_minit_boost = state->m_sinit_boost = 0;
175   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
172176}
173177
174178/* mausuke
r11640r11641
183187
184188DRIVER_INIT(mausuke)
185189{
190   saturn_state *state = machine.driver_data<saturn_state>();
191
186192   sh2drc_add_pcflush(machine.device("maincpu"), 0x60461A0);
187193
188194   DRIVER_INIT_CALL(stv);
189195
190   minit_boost = sinit_boost = 0;
191   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
196   state->m_minit_boost = state->m_sinit_boost = 0;
197   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
192198}
193199
194200DRIVER_INIT(cottonbm)
195201{
202   saturn_state *state = machine.driver_data<saturn_state>();
203
196204//  sh2drc_add_pcflush(machine.device("maincpu"), 0x6030ee2);
197205//  sh2drc_add_pcflush(machine.device("slave"), 0x6032b52);
198206
199207   DRIVER_INIT_CALL(stv);
200208
201   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(10);
209   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(10);
202210}
203211
204212DRIVER_INIT(cotton2)
205213{
214   saturn_state *state = machine.driver_data<saturn_state>();
215
206216   sh2drc_add_pcflush(machine.device("maincpu"), 0x6031c7a);
207217   sh2drc_add_pcflush(machine.device("slave"), 0x60338ea);
208218
209219   DRIVER_INIT_CALL(stv);
210220
211   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
221   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
212222}
213223
214224DRIVER_INIT(dnmtdeka)
r11640r11641
250260
251261DRIVER_INIT( groovef )
252262{
263   saturn_state *state = machine.driver_data<saturn_state>();
264
253265   sh2drc_add_pcflush(machine.device("maincpu"), 0x6005e7c);
254266   sh2drc_add_pcflush(machine.device("maincpu"), 0x6005e86);
255267   sh2drc_add_pcflush(machine.device("maincpu"), 0x60a4970);
r11640r11641
258270
259271   DRIVER_INIT_CALL(stv);
260272
261   minit_boost = sinit_boost = 0;
262   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
273   state->m_minit_boost = state->m_sinit_boost = 0;
274   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
263275}
264276
265277DRIVER_INIT( danchih )
266278{
279   saturn_state *state = machine.driver_data<saturn_state>();
280
267281   sh2drc_add_pcflush(machine.device("maincpu"), 0x6028b28);
268282   sh2drc_add_pcflush(machine.device("maincpu"), 0x6028c8e);
269283   sh2drc_add_pcflush(machine.device("slave"), 0x602ae26);
270284
271285   DRIVER_INIT_CALL(stv);
272286
273   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(5);
287   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(5);
274288}
275289
276290/*
r11640r11641
319333
320334DRIVER_INIT(thunt)
321335{
336   saturn_state *state = machine.driver_data<saturn_state>();
337
322338   sh2drc_add_pcflush(machine.device("maincpu"), 0x602A024);
323339   sh2drc_add_pcflush(machine.device("maincpu"), 0x6013EEA);
324340   sh2drc_add_pcflush(machine.device("slave"), 0x602AAF8);
325341
326342   DRIVER_INIT_CALL(stv);
327343
328   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(1);
344   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(1);
329345}
330346
331347DRIVER_INIT(sandor)
332348{
349   saturn_state *state = machine.driver_data<saturn_state>();
350
333351   sh2drc_add_pcflush(machine.device("maincpu"), 0x602a0f8);
334352   sh2drc_add_pcflush(machine.device("maincpu"), 0x6013fbe);
335353   sh2drc_add_pcflush(machine.device("slave"), 0x602abcc);
336354
337355   DRIVER_INIT_CALL(stv);
338   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(1);
356   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(1);
339357}
340358
341359DRIVER_INIT(grdforce)
342360{
361   saturn_state *state = machine.driver_data<saturn_state>();
362
343363   sh2drc_add_pcflush(machine.device("maincpu"), 0x6041e32);
344364   sh2drc_add_pcflush(machine.device("slave"), 0x6043aa2);
345365
346366   DRIVER_INIT_CALL(stv);
347367
348   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
368   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
349369}
350370
351371DRIVER_INIT(batmanfr)
352372{
373   saturn_state *state = machine.driver_data<saturn_state>();
374
353375   sh2drc_add_pcflush(machine.device("maincpu"), 0x60121c0);
354376   sh2drc_add_pcflush(machine.device("slave"), 0x60125bc);
355377
356378   DRIVER_INIT_CALL(stv);
357379
358   minit_boost = sinit_boost = 0;
359   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
380   state->m_minit_boost = state->m_sinit_boost = 0;
381   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
360382}
361383
362384DRIVER_INIT(colmns97)
363385{
386   saturn_state *state = machine.driver_data<saturn_state>();
387
364388   sh2drc_add_pcflush(machine.device("slave"), 0x60298a2);
365389
366390   DRIVER_INIT_CALL(stv);
367391
368   minit_boost = sinit_boost = 0;
392   state->m_minit_boost = state->m_sinit_boost = 0;
369393}
370394
371395DRIVER_INIT(winterht)
372396{
397   saturn_state *state = machine.driver_data<saturn_state>();
398
373399   sh2drc_add_pcflush(machine.device("maincpu"), 0x6098aea);
374400   sh2drc_add_pcflush(machine.device("slave"), 0x609ae4e);
375401
376402   DRIVER_INIT_CALL(stv);
377403
378   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(2);
404   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(2);
379405}
380406
381407DRIVER_INIT(seabass)
382408{
409   saturn_state *state = machine.driver_data<saturn_state>();
410
383411   sh2drc_add_pcflush(machine.device("maincpu"), 0x602cbfa);
384412   sh2drc_add_pcflush(machine.device("slave"), 0x60321ee);
385413
386414   DRIVER_INIT_CALL(stv);
387415
388   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(5);
416   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(5);
389417}
390418
391419DRIVER_INIT(vfremix)
392420{
421   saturn_state *state = machine.driver_data<saturn_state>();
422
393423   sh2drc_add_pcflush(machine.device("maincpu"), 0x602c30c);
394424   sh2drc_add_pcflush(machine.device("slave"), 0x604c332);
395425
396426   DRIVER_INIT_CALL(stv);
397427
398   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(20);
428   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(20);
399429}
400430
401431DRIVER_INIT(sss)
402432{
433   saturn_state *state = machine.driver_data<saturn_state>();
434
403435   sh2drc_add_pcflush(machine.device("maincpu"), 0x6026398);
404436   sh2drc_add_pcflush(machine.device("slave"), 0x6028cd6);
405437
r11640r11641
407439
408440   DRIVER_INIT_CALL(stv);
409441
410   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
442   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
411443}
412444
413445DRIVER_INIT(othellos)
414446{
447   saturn_state *state = machine.driver_data<saturn_state>();
448
415449   sh2drc_add_pcflush(machine.device("maincpu"), 0x602bcbe);
416450   sh2drc_add_pcflush(machine.device("slave"), 0x602d92e);
417451
418452   DRIVER_INIT_CALL(stv);
419453
420   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
454   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
421455}
422456
423457DRIVER_INIT(sasissu)
424458{
459   saturn_state *state = machine.driver_data<saturn_state>();
460
425461   sh2drc_add_pcflush(machine.device("slave"), 0x60710be);
426462
427463   DRIVER_INIT_CALL(stv);
428464
429   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(2);
465   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(2);
430466}
431467
432468DRIVER_INIT(gaxeduel)
r11640r11641
446482
447483DRIVER_INIT(sokyugrt)
448484{
485   saturn_state *state = machine.driver_data<saturn_state>();
486
449487   DRIVER_INIT_CALL(stv);
450488
451   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
489   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
452490}
453491
454492DRIVER_INIT(znpwfv)
455493{
494   saturn_state *state = machine.driver_data<saturn_state>();
495
456496   sh2drc_add_pcflush(machine.device("maincpu"), 0x6012ec2);
457497   sh2drc_add_pcflush(machine.device("slave"), 0x60175a6);
458498
459499   DRIVER_INIT_CALL(stv);
460   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_nsec(500);
500   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_nsec(500);
461501}
462502
463503DRIVER_INIT(twcup98)
464504{
505   saturn_state *state = machine.driver_data<saturn_state>();
506
465507   sh2drc_add_pcflush(machine.device("maincpu"), 0x605edde);
466508   sh2drc_add_pcflush(machine.device("slave"), 0x6062bca);
467509
468510   DRIVER_INIT_CALL(stv);
469511   install_twcup98_protection(machine);
470512
471   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(5);
513   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(5);
472514}
473515
474516DRIVER_INIT(smleague)
475517{
518   saturn_state *state = machine.driver_data<saturn_state>();
519
476520   sh2drc_add_pcflush(machine.device("maincpu"), 0x6063bf4);
477521   sh2drc_add_pcflush(machine.device("slave"), 0x6062bca);
478522
479523   DRIVER_INIT_CALL(stv);
480524
481   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
525   /* tight sync to avoid dead locks */
526   state->m_minit_boost = state->m_sinit_boost = 0;
527   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(5000);
482528}
483529
484530DRIVER_INIT(finlarch)
485531{
532   saturn_state *state = machine.driver_data<saturn_state>();
533
486534   sh2drc_add_pcflush(machine.device("maincpu"), 0x6064d60);
487535
488536   DRIVER_INIT_CALL(stv);
537
538   /* tight sync to avoid dead locks */
539   state->m_minit_boost = state->m_sinit_boost = 0;
540   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(5000);
489541}
490542
491543DRIVER_INIT(maruchan)
492544{
545   saturn_state *state = machine.driver_data<saturn_state>();
546
493547   sh2drc_add_pcflush(machine.device("maincpu"), 0x601ba46);
494548   sh2drc_add_pcflush(machine.device("slave"), 0x601ba46);
495549
496550   DRIVER_INIT_CALL(stv);
497551
498   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(50);
552   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(50);
499553}
500554
501555DRIVER_INIT(pblbeach)
r11640r11641
514568
515569DRIVER_INIT(elandore)
516570{
571   saturn_state *state = machine.driver_data<saturn_state>();
572
517573   sh2drc_add_pcflush(machine.device("maincpu"), 0x604eac0);
518574   sh2drc_add_pcflush(machine.device("slave"), 0x605340a);
519575
520576   install_elandore_protection(machine);
521577
522578   DRIVER_INIT_CALL(stv);
523   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(0);
579   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(0);
524580}
525581
526582DRIVER_INIT(rsgun)
527583{
584   saturn_state *state = machine.driver_data<saturn_state>();
585
528586   sh2drc_add_pcflush(machine.device("maincpu"), 0x6034d04);
529587   sh2drc_add_pcflush(machine.device("slave"), 0x6036152);
530588
r11640r11641
532590
533591   DRIVER_INIT_CALL(stv);
534592
535   minit_boost_timeslice = sinit_boost_timeslice = attotime::from_usec(20);
593   state->m_minit_boost_timeslice = state->m_sinit_boost_timeslice = attotime::from_usec(20);
536594}
537595
538596DRIVER_INIT(ffreveng)
src/mame/drivers/bfm_sc2.c
r11640r11641
66
77*****************************************************************************************
88
9     04-2011: J Wallace: Fixed watchdog to match actual circuit, also fixed lamping code.
910  30-12-2006: J Wallace: Fixed init routines.
1011  07-03-2006: El Condor: Recoded to more accurately represent the hardware setup.
1112  18-01-2006: Cleaned up for MAME inclusion
1213  19-08-2005: Re-Animator
1314
1415Standard scorpion2 memorymap
16The hardware in Scorpion 2 is effectively a Scorpion 1 board with better, non-compatible
17microcontrollers, incorporating many of the old expansions on board.
1518
16
1719   hex     |r/w| D D D D D D D D |
1820 location  |   | 7 6 5 4 3 2 1 0 | function
1921-----------+---+-----------------+-----------------------------------------
r11640r11641
193195   int m_volume_override;
194196   int m_sc2_show_door;
195197   int m_sc2_door_state;
198   int m_reels;
196199   int m_reel12_latch;
197200   int m_reel34_latch;
198201   int m_reel56_latch;
r11640r11641
204207   int m_hopper_running;
205208   int m_hopper_coin_sense;
206209   int m_timercnt;
207   int m_watchdog_cnt;
208   int m_watchdog_kicked;
209   UINT8 m_Lamps[256];
210210   UINT8 m_sc2_Inputs[64];
211211   UINT8 m_input_override[64];
212212   int m_e2reg;
r11640r11641
293293   state->m_slide_states[4] = 0;
294294   state->m_slide_states[5] = 0;
295295
296   state->m_watchdog_cnt    = 0;
297   state->m_watchdog_kicked = 0;
298
299
300296   BFM_BD1_reset(0);   // reset display1
301297   BFM_BD1_reset(1);   // reset display2
302298
r11640r11641
306302
307303  // reset stepper motors /////////////////////////////////////////////////
308304   {
309/* Although the BFM video games don't use stepper motors to control reels,
310the connections are still present on the board, and some of the programs still
311send data to them, although obviously there's no response. */
312
313305      int pattern =0, i;
314306
315      for ( i = 0; i < 6; i++)
307      for ( i = 0; i < state->m_reels; i++)
316308      {
317309         stepper_reset_position(i);
318310         if ( stepper_optic_state(i) ) pattern |= 1<<i;
r11640r11641
427419
428420///////////////////////////////////////////////////////////////////////////
429421
430static WRITE8_HANDLER( watchdog_w )
431{
432   bfm_sc2_state *state = space->machine().driver_data<bfm_sc2_state>();
433   state->m_watchdog_kicked = 1;
434}
435
436///////////////////////////////////////////////////////////////////////////
437
438422static WRITE8_HANDLER( bankswitch_w )
439423{
440424   memory_set_bank(space->machine(), "bank1",data & 0x03);
r11640r11641
447431   bfm_sc2_state *state = device->machine().driver_data<bfm_sc2_state>();
448432   state->m_timercnt++;
449433
450   if ( state->m_watchdog_kicked )
451   {
452      state->m_watchdog_cnt    = 0;
453      state->m_watchdog_kicked = 0;
454   }
455   else
456   {
457      state->m_watchdog_cnt++;
458      if ( state->m_watchdog_cnt > 2 )   // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine
459      {  // reset board
460         device->machine().schedule_soft_reset();      // reset entire machine. CPU 0 should be enough, but that doesn't seem to work !!
461         on_scorpion2_reset(device->machine());
462         return;
463      }
464   }
465
466434   if ( state->m_is_timer_enabled )
467435   {
468436      state->m_irq_timer_stat = 0x01;
r11640r11641
509477}
510478
511479///////////////////////////////////////////////////////////////////////////
512
513static WRITE8_HANDLER( reel34_w )
514{
515   bfm_sc2_state *state = space->machine().driver_data<bfm_sc2_state>();
516   state->m_reel34_latch = data;
517
518   if ( stepper_update(2, data&0x0f ) ) state->m_reel_changed |= 0x04;
519   if ( stepper_update(3, (data>>4)&0x0f) ) state->m_reel_changed |= 0x08;
520
521   if ( stepper_optic_state(2) ) state->m_optic_pattern |=  0x04;
522   else                          state->m_optic_pattern &= ~0x04;
523   if ( stepper_optic_state(3) ) state->m_optic_pattern |=  0x08;
524   else                          state->m_optic_pattern &= ~0x08;
525
526   awp_draw_reel(2);
527   awp_draw_reel(3);
528}
529
530///////////////////////////////////////////////////////////////////////////
531
532static WRITE8_HANDLER( reel56_w )
533{
534   bfm_sc2_state *state = space->machine().driver_data<bfm_sc2_state>();
535   state->m_reel56_latch = data;
536
537   if ( stepper_update(4, data&0x0f   ) ) state->m_reel_changed |= 0x10;
538   if ( stepper_update(5, (data>>4)&0x0f) ) state->m_reel_changed |= 0x20;
539
540   if ( stepper_optic_state(4) ) state->m_optic_pattern |=  0x10;
541   else                          state->m_optic_pattern &= ~0x10;
542   if ( stepper_optic_state(5) ) state->m_optic_pattern |=  0x20;
543   else                          state->m_optic_pattern &= ~0x20;
544
545   awp_draw_reel(4);
546   awp_draw_reel(5);
547}
548
549///////////////////////////////////////////////////////////////////////////
550480// mechanical meters //////////////////////////////////////////////////////
551481///////////////////////////////////////////////////////////////////////////
552482
r11640r11641
572502
573503static WRITE8_HANDLER( mux_output_w )
574504{
575   bfm_sc2_state *state = space->machine().driver_data<bfm_sc2_state>();
576505   int i;
577506   int off = offset<<3;
578507
579508   for (i=0; i<8; i++)
580   {
581      state->m_Lamps[ off+i ] = (data & (1 << i)) != 0;
582   }
583   if (offset == 0) // update all lamps after strobe 0 has been updated (HACK)
584   {
585      for ( i = 0; i < 256; i++ )
586      {
587         output_set_lamp_value(i, state->m_Lamps[i]);
588      }
589   }
509      output_set_lamp_value(off+i, ((data & (1 << i)) != 0));
510
590511}
591512
592513///////////////////////////////////////////////////////////////////////////
r11640r11641
14481369   on_scorpion2_reset(machine);
14491370   BFM_BD1_init(0);
14501371   BFM_BD1_init(1);
1451   //BFM_dm01_reset(machine); No known video based game has a Matrix board
14521372}
14531373
14541374static SCREEN_UPDATE( addersc2 )
r11640r11641
14691389   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("nvram") //8k RAM
14701390   AM_RANGE(0x2000, 0x2000) AM_READ(vfd_status_hop_r)      // vfd status register
14711391   AM_RANGE(0x2000, 0x20FF) AM_WRITE(reel12_vid_w)
1472   AM_RANGE(0x2100, 0x21FF) AM_WRITE(reel34_w)
1473   AM_RANGE(0x2200, 0x22FF) AM_WRITE(reel56_w)
1392   AM_RANGE(0x2100, 0x21FF) AM_WRITENOP
1393   AM_RANGE(0x2200, 0x22FF) AM_WRITENOP
14741394
14751395   AM_RANGE(0x2300, 0x230B) AM_READ(mux_input_r)         // mux inputs
14761396   AM_RANGE(0x2300, 0x231F) AM_WRITE(mux_output_w)         // mux outputs
r11640r11641
14851405   AM_RANGE(0x232F, 0x232F) AM_WRITE(coininhib_w)         // coin inhibits
14861406   AM_RANGE(0x2330, 0x2330) AM_WRITE(payout_latch_w)
14871407   AM_RANGE(0x2331, 0x2331) AM_WRITE(payout_triac_w)
1488   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_w)         // kick watchdog
1408   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_reset_w)         // kick watchdog
14891409   AM_RANGE(0x2333, 0x2333) AM_WRITE(mmtr_w)            // mechanical meters
14901410   AM_RANGE(0x2334, 0x2335) AM_WRITE(unknown_w)
14911411   AM_RANGE(0x2336, 0x2336) AM_WRITE(dimcnt_w)            // ?unknown dim related
r11640r11641
17121632   PORT_DIPSETTING(    0x01, "2 credits per game")PORT_CONDITION("STROBE10",0x10,PORTCOND_EQUALS,0x00)
17131633   PORT_DIPSETTING(    0x00, "1 credit  per round")PORT_CONDITION("STROBE10",0x10,PORTCOND_EQUALS,0x10)
17141634   PORT_DIPSETTING(    0x01, "4 credits per round")PORT_CONDITION("STROBE10",0x10,PORTCOND_EQUALS,0x10)
1715
1716/*
1717          Type1 Type2
1718              0     0   4 credits per game
1719              0     1   2 credits per game
1720              1     0   1 credit  per round
1721              1     1   4 credits per round
1722 */
1723
17241635   PORT_DIPNAME( 0x02, 0x00, "Attract Mode" )PORT_DIPLOCATION("DIL:!13")
17251636   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
17261637   PORT_DIPSETTING(    0x00, DEF_STR( On  ) )
r11640r11641
21802091   MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4 )   // 6809 CPU at 2 Mhz
21812092   MCFG_CPU_PROGRAM_MAP(memmap_vid)               // setup scorpion2 board memorymap
21822093   MCFG_CPU_PERIODIC_INT(timer_irq, 1000)            // generate 1000 IRQ's per second
2094   MCFG_WATCHDOG_TIME_INIT(PERIOD_OF_555_MONOSTABLE(120000,100e-9))
21832095
21842096   MCFG_NVRAM_ADD_0FILL("nvram")
21852097   MCFG_NVRAM_HANDLER(bfm_sc2)
r11640r11641
22012113
22022114   MCFG_CPU_ADD("adder2", M6809, MASTER_CLOCK/4 )   // adder2 board 6809 CPU at 2 Mhz
22032115   MCFG_CPU_PROGRAM_MAP(adder2_memmap)            // setup adder2 board memorymap
2204   MCFG_CPU_VBLANK_INT("adder", adder2_vbl)         // board has a VBL IRQ
2116   MCFG_CPU_VBLANK_INT("adder", adder2_vbl)      // board has a VBL IRQ
22052117
22062118   MCFG_SPEAKER_STANDARD_MONO("mono")
22072119   MCFG_SOUND_ADD("upd", UPD7759, UPD7759_STANDARD_CLOCK)
r11640r11641
26242536   awp_draw_reel(1);
26252537}
26262538
2539static WRITE8_HANDLER( reel34_w )
2540{
2541   bfm_sc2_state *state = space->machine().driver_data<bfm_sc2_state>();
2542   state->m_reel34_latch = data;
26272543
2544   if ( stepper_update(2, data&0x0f ) ) state->m_reel_changed |= 0x04;
2545   if ( stepper_update(3, (data>>4)&0x0f) ) state->m_reel_changed |= 0x08;
2546
2547   if ( stepper_optic_state(2) ) state->m_optic_pattern |=  0x04;
2548   else                          state->m_optic_pattern &= ~0x04;
2549   if ( stepper_optic_state(3) ) state->m_optic_pattern |=  0x08;
2550   else                          state->m_optic_pattern &= ~0x08;
2551
2552   awp_draw_reel(2);
2553   awp_draw_reel(3);
2554}
2555
2556///////////////////////////////////////////////////////////////////////////
2557
2558static WRITE8_HANDLER( reel56_w )
2559{
2560   bfm_sc2_state *state = space->machine().driver_data<bfm_sc2_state>();
2561   state->m_reel56_latch = data;
2562
2563   if ( stepper_update(4, data&0x0f   ) ) state->m_reel_changed |= 0x10;
2564   if ( stepper_update(5, (data>>4)&0x0f) ) state->m_reel_changed |= 0x20;
2565
2566   if ( stepper_optic_state(4) ) state->m_optic_pattern |=  0x10;
2567   else                          state->m_optic_pattern &= ~0x10;
2568   if ( stepper_optic_state(5) ) state->m_optic_pattern |=  0x20;
2569   else                          state->m_optic_pattern &= ~0x20;
2570
2571   awp_draw_reel(4);
2572   awp_draw_reel(5);
2573}
2574
2575///////////////////////////////////////////////////////////////////////////
2576
2577
26282578/* VFD Status */
26292579static READ8_HANDLER( vfd_status_r )
26302580{
r11640r11641
27382688   AM_RANGE(0x232F, 0x232F) AM_WRITE(coininhib_w)
27392689   AM_RANGE(0x2330, 0x2330) AM_WRITE(payout_latch_w)
27402690   AM_RANGE(0x2331, 0x2331) AM_WRITE(payout_triac_w)
2741   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_w)
2691   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_reset_w)
27422692   AM_RANGE(0x2333, 0x2333) AM_WRITE(mmtr_w)
27432693   AM_RANGE(0x2334, 0x2335) AM_WRITE(unknown_w)
27442694   AM_RANGE(0x2336, 0x2336) AM_WRITE(dimcnt_w)
r11640r11641
27612711
27622712   AM_RANGE(0x3FFF, 0x3FFF) AM_READ( coin_input_r)
27632713   AM_RANGE(0x4000, 0x5FFF) AM_ROM                           /* 8k  fixed ROM */
2764   AM_RANGE(0x6000, 0x7FFF) AM_ROMBANK("bank1")                     /* 8k  paged ROM (4 pages) */
2714   AM_RANGE(0x6000, 0x7FFF) AM_ROMBANK("bank1")               /* 8k  paged ROM (4 pages) */
27652715   AM_RANGE(0x8000, 0xFFFF) AM_ROM                           /* 32k ROM */
27662716ADDRESS_MAP_END
27672717
r11640r11641
27872737   AM_RANGE(0x232F, 0x232F) AM_WRITE(coininhib_w)
27882738   AM_RANGE(0x2330, 0x2330) AM_WRITE(payout_latch_w)
27892739   AM_RANGE(0x2331, 0x2331) AM_WRITE(payout_triac_w)
2790   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_w)
2740   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_reset_w)
27912741   AM_RANGE(0x2333, 0x2333) AM_WRITE(mmtr_w)
27922742   AM_RANGE(0x2334, 0x2335) AM_WRITE(unknown_w)
27932743   AM_RANGE(0x2336, 0x2336) AM_WRITE(dimcnt_w)
r11640r11641
28362786   AM_RANGE(0x232F, 0x232F) AM_WRITE(coininhib_w)
28372787   AM_RANGE(0x2330, 0x2330) AM_WRITE(payout_latch_w)
28382788   AM_RANGE(0x2331, 0x2331) AM_WRITE(payout_triac_w)
2839   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_w)
2789   AM_RANGE(0x2332, 0x2332) AM_WRITE(watchdog_reset_w)
28402790   AM_RANGE(0x2333, 0x2333) AM_WRITE(mmtr_w)
28412791   AM_RANGE(0x2334, 0x2335) AM_WRITE(unknown_w)
28422792   AM_RANGE(0x2336, 0x2336) AM_WRITE(dimcnt_w)
r11640r11641
33113261   PORT_DIPSETTING(    0x10, DEF_STR( On  ) )
33123262INPUT_PORTS_END
33133263
3314
33153264static INPUT_PORTS_START( cpeno1 )
33163265   PORT_START("COINS")
33173266   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(3)
r11640r11641
34663415   PORT_DIPSETTING(    0x18, "85%" )
34673416INPUT_PORTS_END
34683417
3469
34703418static INPUT_PORTS_START( luvjub )
34713419   PORT_START("COINS")
34723420   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(3)
r11640r11641
36233571   PORT_DIPSETTING(    0x10, DEF_STR( On  ) )
36243572INPUT_PORTS_END
36253573
3626
36273574static INPUT_PORTS_START( bfmcgslm )
36283575   PORT_START("COINS")
36293576   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(3)
r11640r11641
37803727   PORT_DIPSETTING(    0x10, DEF_STR( On  ) )
37813728INPUT_PORTS_END
37823729
3783
37843730static INPUT_PORTS_START( scorpion3 )
37853731   PORT_START("COINS")
37863732    PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(3) PORT_NAME("Fl 5.00")
r11640r11641
39443890   MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4 )
39453891   MCFG_CPU_PROGRAM_MAP(sc2_memmap)
39463892   MCFG_CPU_PERIODIC_INT(timer_irq, 1000 )
3893   MCFG_WATCHDOG_TIME_INIT(PERIOD_OF_555_MONOSTABLE(120000,100e-9))
39473894
39483895   MCFG_SPEAKER_STANDARD_MONO("mono")
39493896   MCFG_SOUND_ADD("upd",UPD7759, UPD7759_STANDARD_CLOCK)
r11640r11641
39743921   MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4 )
39753922   MCFG_CPU_PROGRAM_MAP(memmap_sc2_dm01)
39763923   MCFG_CPU_PERIODIC_INT(timer_irq, 1000 )
3924   MCFG_WATCHDOG_TIME_INIT(PERIOD_OF_555_MONOSTABLE(120000,100e-9))
39773925
3926
39783927   MCFG_SPEAKER_STANDARD_MONO("mono")
39793928   MCFG_SOUND_ADD("ymsnd",YM2413, XTAL_3_579545MHz)
39803929   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
r11640r11641
39943943
39953944static void sc2awp_common_init(running_machine &machine,int reels, int decrypt)
39963945{
3946   bfm_sc2_state *state = machine.driver_data<bfm_sc2_state>();
3947
39973948   int n;
39983949   sc2_common_init(machine, decrypt);
39993950   /* setup n default 96 half step reels */
3951
3952   state->m_reels=reels;
3953
40003954   for ( n = 0; n < reels; n++ )
40013955   {
40023956      stepper_config(machine, n, &starpoint_interface_48step);
src/mame/drivers/play_1.c
r11640r11641
2828{
2929}
3030
31static COSMAC_INTERFACE( cdp1802_config )
32{
33   DEVCB_NULL,
34   DEVCB_NULL,
35   DEVCB_NULL,
36   DEVCB_NULL,
37   DEVCB_NULL,
38   DEVCB_NULL,
39   DEVCB_NULL,
40   DEVCB_NULL,
41   DEVCB_NULL,
42   NULL,
43   DEVCB_NULL,
44   DEVCB_NULL
45};
46
3147static MACHINE_CONFIG_START( play_1, play_1_state )
3248   /* basic machine hardware */
3349   MCFG_CPU_ADD("maincpu", COSMAC, 400000)
3450   MCFG_CPU_PROGRAM_MAP(play_1_map)
51   MCFG_CPU_CONFIG(cdp1802_config)
3552
3653   MCFG_MACHINE_RESET( play_1 )
3754
src/mame/drivers/galpanic.c
r11640r11641
248248static READ8_DEVICE_HANDLER( comad_okim6295_r )
249249{
250250   UINT16 retvalue;
251//   okim6295_device *oki = downcast<okim6295_device *>(device);
251//  okim6295_device *oki = downcast<okim6295_device *>(device);
252252
253253//  retvalue = oki->read_status(); // doesn't work, causes lockups when girls change..
254254   retvalue = device->machine().rand();
r11640r11641
942942   MCFG_CPU_MODIFY("maincpu")
943943   MCFG_CPU_CLOCK(12000000)   /* ? */
944944   MCFG_CPU_PROGRAM_MAP(supmodel_map)
945//   MCFG_TIMER_ADD_SCANLINE("scantimer", galpanic_scanline, "screen", 0, 1)
945//  MCFG_TIMER_ADD_SCANLINE("scantimer", galpanic_scanline, "screen", 0, 1)
946946
947947   /* video hardware */
948948   MCFG_SCREEN_MODIFY("screen")
src/mame/drivers/igspoker.c
r11640r11641
235235    ---- ---x  Start lamp.
236236
237237    cpokerx set has different layout:
238   
238
239239    - Lbits -
240240    7654 3210
241241    =========
242242    ---- ---x  Start lamp.
243   
243
244244    ---- ---x  Hold1 lamp.
245245    ---- --x-  Hold2 lamp.
246246    ---- -x--  Hold3 lamp.
r11640r11641
20352035
20362036/*
20372037  Champion Poker (IGS) V100.
2038 
2038
203920391x ZILOG Z0840006PSC-Z80CPU (main)
20402040
204120411x oscillator 12.000MHz (main)
src/mame/drivers/goldstar.c
r11640r11641
80198019  1x simple 3-contacts switch.
80208020
80218021
8022  The following PROMs weren't dumped:
8022  The following PROMs were added later:
80238023
80248024  1x TBP18S030 @ D12 (32 bytes)
80258025  1x TBP18S030 @ D13 (32 bytes)
r11640r11641
80338033  @ D14:  1K - 470 - 220 - 1K - 470 - 220 - 470 - 220.
80348034  @ F14:  1K - 470 - 220 - 1K - 1K - 470 - 220 - 1K - 470 - 220 - 1K.
80358035
8036******************************************************************************
8037
8038  About encryption...
8039
8040  Seems that programmers left a hole at offset 3890-3a90, enough to see some
8041  values and progressions as hints. Some of these strings (IE: 00 20 00 20),
8042  are valid to XOR some text offsets, as 3ac7-3acf, 3ae5-3aea, 3c00-3c0f, and
8043  other text strings. See also offsets 5240 and 5800 onward...
8044
8045
80368046******************************************************************************/
80378047
80388048ROM_START( luckylad )
r11640r11641
80528062   ROM_LOAD( "14.h5",  0x6000, 0x2000, CRC(708d5b2d) SHA1(a619b84bc67d579345db636d33e7e4f27e37a18c) )
80538063
80548064   ROM_REGION( 0x200, "proms", 0 )
8055   ROM_LOAD( "tbp24s10n.g13", 0x0000, 0x0100, NO_DUMP )   /* undumped */
8056   ROM_LOAD( "tbp24s10n.g14", 0x0100, 0x0100, NO_DUMP )   /* undumped */
8065   ROM_LOAD( "tbp24s10n.g13", 0x0000, 0x0100, CRC(b053242d) SHA1(00ed5c0d6694e83ae695fb0cdfed53be2b0bd6c9) )
8066   ROM_LOAD( "tbp24s10n.g14", 0x0100, 0x0100, CRC(46209d2a) SHA1(1d539219238ee47cdba3e7d44504619c7fbd2ade) )
80578067
80588068   ROM_REGION( 0x20, "proms2", 0 )
8059   ROM_LOAD( "tbp18s030.d13", 0x0000, 0x0020, NO_DUMP )   /* undumped */
8069   ROM_LOAD( "tbp18s030.d13", 0x0000, 0x0020, CRC(41f3b9d3) SHA1(8b884a98e68ea438427227a64bf91fe86844a15f) )
80608070
80618071   ROM_REGION( 0x100, "unkprom", 0 )
8062   ROM_LOAD( "tbp24s10n.f3", 0x0000, 0x0100, NO_DUMP )   /* undumped */
8072   ROM_LOAD( "tbp24s10n.f3", 0x0000, 0x0100, CRC(8de9cb92) SHA1(01449974fa27ebfd2583d6b2845c4f43938e082d) )
80638073
80648074   ROM_REGION( 0x20, "unkprom2", 0 )
8065   ROM_LOAD( "tbp18s030.d12", 0x0000, 0x0020, NO_DUMP )   /* undumped */
8075   ROM_LOAD( "tbp18s030.d12", 0x0000, 0x0020, CRC(6df3f972) SHA1(0096a7f7452b70cac6c0752cb62e24b643015b5c) )
80668076ROM_END
80678077
80688078/*
r11640r11641
1032410334GAME(  198?, ladylinr,  0,        ladylinr, ladylinr, 0,         ROT0, "TAB Austria",          "Lady Liner",                                               0 )
1032510335GAME(  198?, wcat3,     0,        wcat3,    lucky8,   0,         ROT0, "E.A.I.",               "Wild Cat 3",                                               GAME_NOT_WORKING )
1032610336
10327GAME( 1985, luckylad,  0,        lucky8,   luckylad, 0,         ROT0, "Wing Co., Ltd.",       "Lucky Lady (Wing, encrypted)",                             GAME_NOT_WORKING ) // encrypted...
10337GAME( 1985, luckylad,  0,        lucky8,   luckylad, 0,         ROT0, "Wing Co., Ltd.",       "Lucky Lady (Wing, encrypted)",                             GAME_NOT_WORKING ) // encrypted (see notes in rom_load)...
1032810338
10329GAME(  1992, magodds,   0,         magodds,  magodds,   0,         ROT0, "Pal Company / Micro Manufacturing Inc.", "Magical Odds (set 1)",               GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
10330GAME(  1992, magoddsa,   magodds,  magodds,  magodds,   0,         ROT0, "Pal Company / Micro Manufacturing Inc.", "Magical Odds (set 2)",               GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
10331GAME(  1992, magoddsb,   magodds,  magodds,  magodds,   0,         ROT0, "Pal Company / Micro Manufacturing Inc.", "Magical Odds (set 3)",               GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
10332GAME(  1991, magoddsc,   magodds,  magodds,  magoddsc,  magoddsc,  ROT0, "Pal Company",                            "Magical Odds (set 4, custom encrypted CPU block)", GAME_WRONG_COLORS | GAME_NOT_WORKING |GAME_NO_SOUND)
10333GAME(  1991, magoddsd,   magodds,  magodds,  magoddsc,  magoddsc,  ROT0, "Pal Company",                            "Magical Odds (set 5, custom encrypted CPU block)", GAME_WRONG_COLORS | GAME_NOT_WORKING |GAME_NO_SOUND)
10339GAME(  1992, magodds,   0,        magodds,  magodds,  0,         ROT0, "Pal Company / Micro Manufacturing Inc.", "Magical Odds (set 1)",                             GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
10340GAME(  1992, magoddsa,   magodds, magodds,  magodds,  0,         ROT0, "Pal Company / Micro Manufacturing Inc.", "Magical Odds (set 2)",                             GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
10341GAME(  1992, magoddsb,   magodds, magodds,  magodds,  0,         ROT0, "Pal Company / Micro Manufacturing Inc.", "Magical Odds (set 3)",                             GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
10342GAME(  1991, magoddsc,   magodds, magodds,  magoddsc, magoddsc,  ROT0, "Pal Company",                            "Magical Odds (set 4, custom encrypted CPU block)", GAME_WRONG_COLORS | GAME_NOT_WORKING |GAME_NO_SOUND)
10343GAME(  1991, magoddsd,   magodds, magodds,  magoddsc, magoddsc,  ROT0, "Pal Company",                            "Magical Odds (set 5, custom encrypted CPU block)", GAME_WRONG_COLORS | GAME_NOT_WORKING |GAME_NO_SOUND)
1033410344
1033510345
1033610346/* --- Amcoe games --- */
src/mame/drivers/cps1.c
r11640r11641
781781/* CPS1 games with 2 players and 6 buttons each */
782782static INPUT_PORTS_START( cps1_6b)
783783   PORT_INCLUDE( cps1_3b)
784   
784
785785   PORT_MODIFY("IN1")
786786   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 Jab Punch") PORT_PLAYER(1)
787787   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Strong Punch") PORT_PLAYER(1)
r11640r11641
789789   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P2 Jab Punch") PORT_PLAYER(2)
790790   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P2 Strong Punch") PORT_PLAYER(2)
791791   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P2 Fierce Punch") PORT_PLAYER(2)
792   
792
793793   PORT_START("IN2")      /* Extra buttons */
794794   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P1 Short Kick") PORT_PLAYER(1)
795795   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P1 Forward Kick") PORT_PLAYER(1)
r11640r11641
17721772   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
17731773   PORT_DIPSETTING(    0x80, "Game" )
17741774   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
1775   
1775
17761776INPUT_PORTS_END
17771777
17781778/* Needs further checking */
src/mame/drivers/play_3.c
r11640r11641
2929{
3030}
3131
32static COSMAC_INTERFACE( cdp1802_config )
33{
34   DEVCB_NULL,
35   DEVCB_NULL,
36   DEVCB_NULL,
37   DEVCB_NULL,
38   DEVCB_NULL,
39   DEVCB_NULL,
40   DEVCB_NULL,
41   DEVCB_NULL,
42   DEVCB_NULL,
43   NULL,
44   DEVCB_NULL,
45   DEVCB_NULL
46};
47
3248static MACHINE_CONFIG_START( play_3, play_3_state )
3349   /* basic machine hardware */
3450   MCFG_CPU_ADD("maincpu", COSMAC, 2950000)
3551   MCFG_CPU_PROGRAM_MAP(play_3_map)
52   MCFG_CPU_CONFIG(cdp1802_config)
3653
3754   MCFG_MACHINE_RESET( play_3 )
3855
src/mame/drivers/xexex.c
r11640r11641
339339   AM_RANGE(0x0c8000, 0x0c800f) AM_DEVREADWRITE("k053250", k053250_r, k053250_w)
340340   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w)            // CLTC
341341   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w)            // priority encoder
342//   AM_RANGE(0x0d0000, 0x0d001f) AM_DEVREADWRITE8("k053252", k053252_r,k053252_w,0x00ff)            // CCU
342//  AM_RANGE(0x0d0000, 0x0d001f) AM_DEVREADWRITE8("k053252", k053252_r,k053252_w,0x00ff)                // CCU
343343   AM_RANGE(0x0d4000, 0x0d4001) AM_WRITE(sound_irq_w)
344344   AM_RANGE(0x0d600c, 0x0d600d) AM_WRITE(sound_cmd1_w)
345345   AM_RANGE(0x0d600e, 0x0d600f) AM_WRITE(sound_cmd2_w)
src/mame/drivers/cps3.c
r11640r11641
22812281/* Red Earth game inputs */
22822282static INPUT_PORTS_START ( cps3_re )
22832283   PORT_INCLUDE ( cps3 )
2284   
2284
22852285   PORT_MODIFY("INPUTS")
22862286   PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("P1 Start / Change Orb")
22872287   PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_START2 ) PORT_NAME("P2 Start / Change Orb")
r11640r11641
22902290/* Jojo game inputs */
22912291static INPUT_PORTS_START( cps3_jojo)
22922292   PORT_INCLUDE( cps3 )
2293   
2293
22942294   PORT_MODIFY("INPUTS")
22952295   PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 Light") PORT_PLAYER(1)
22962296   PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Medium") PORT_PLAYER(1)
r11640r11641
22992299   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P2 Medium") PORT_PLAYER(2)
23002300   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P2 Strong") PORT_PLAYER(2)
23012301   PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(2)
2302   
2302
23032303   PORT_MODIFY("EXTRA")
23042304   PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(1)
23052305   PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(1)
src/mame/drivers/play_5.c
r11640r11641
2929{
3030}
3131
32static COSMAC_INTERFACE( cdp1802_config )
33{
34   DEVCB_NULL,
35   DEVCB_NULL,
36   DEVCB_NULL,
37   DEVCB_NULL,
38   DEVCB_NULL,
39   DEVCB_NULL,
40   DEVCB_NULL,
41   DEVCB_NULL,
42   DEVCB_NULL,
43   NULL,
44   DEVCB_NULL,
45   DEVCB_NULL
46};
47
3248static MACHINE_CONFIG_START( play_5, play_5_state )
3349   /* basic machine hardware */
3450   MCFG_CPU_ADD("maincpu", COSMAC, 2950000)
3551   MCFG_CPU_PROGRAM_MAP(play_5_map)
52   MCFG_CPU_CONFIG(cdp1802_config)
3653
3754   MCFG_MACHINE_RESET( play_5 )
3855
src/mame/drivers/bfmsys85.c
r11640r11641
22
33    Bellfruit system85 driver, (under heavy construction !!!)
44
5    A.G.E Code Copyright J. Wallace and the AGEMAME Development Team.
6    Visit http://agemame.mameworld.info for more information.
7
85    M.A.M.E Core Copyright Nicola Salmoria and the MAME Team,
96    used under license from http://mamedev.org
107
118
129******************************************************************************************
1310
11     04-2011: J Wallace: Fixed lamping code.
1412  19-08-2005: Re-Animator
1513
1614Standard system85 memorymap
r11640r11641
8684   int m_mux_output_strobe;
8785   int m_mux_input_strobe;
8886   int m_mux_input;
89   UINT8 m_Lamps[128];
9087   UINT8 m_Inputs[64];
9188   UINT8 m_sys85_data_line_r;
9289   UINT8 m_sys85_data_line_t;
r11640r11641
155152      }
156153   state->m_optic_pattern = pattern;
157154   }
158   state->m_locked        = 0x00; // hardware is NOT state->m_locked
155   state->m_locked        = 0x00; // hardware is open
159156}
160157
161158///////////////////////////////////////////////////////////////////////////
r11640r11641
279276//////////////////////////////////////////////////////////////////////////////////
280277// input / output multiplexers ///////////////////////////////////////////////////
281278//////////////////////////////////////////////////////////////////////////////////
282// conversion table BFM strobe data to internal lamp numbers
283static const UINT8 BFM_strcnv85[] =
284{
285   0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
286   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, 0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
287   0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
288   0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, 0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
289   0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, 0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
290   0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, 0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
291   0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67, 0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
292   0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, 0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
293279
294   0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
295   0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, 0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
296   0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7, 0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
297   0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7, 0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
298   0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7, 0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
299   0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7, 0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
300   0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7, 0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
301   0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7, 0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
302};
303
304///////////////////////////////////////////////////////////////////////////////////
305
306280static WRITE8_HANDLER( mux_ctrl_w )
307281{
308282   bfmsys85_state *state = space->machine().driver_data<bfmsys85_state>();
r11640r11641
354328
355329   for ( i = 0; i < 8; i++ )
356330   {
357      state->m_Lamps[BFM_strcnv85[off]] = data & pattern ? 1 : 0;
331      output_set_lamp_value(off, (data & pattern ? 1 : 0));
358332      pattern <<= 1;
359333      off++;
360334   }
361
362   if (state->m_mux_output_strobe == 0)
363   {
364      for ( i = 0; i < 128; i++ )
365      {
366         output_set_lamp_value(i, state->m_Lamps[i]);
367      }
368   }
369335}
370336
371337static READ8_HANDLER( mux_data_r )
src/mame/drivers/saturn.c
r11640r11641
1/*
2   Sega Saturn & Sega ST-V (Sega Titan Video)
1/**************************************************************************************************
32
4Driver by David Haywood,Angelo Salese,Olivier Galibert & Mariusz Wojcieszek
5SCSP driver provided by R.Belmont,based on ElSemi's SCSP sound chip emulator
6CD Block driver provided by ANY,based on sthief original emulator
7Many thanks to Guru,Fabien & Runik for the help given.
3    Sega Saturn & Sega ST-V (Sega Titan Video) HW (c) 1994 Sega
84
5    Driver by David Haywood, Angelo Salese, Olivier Galibert & Mariusz Wojcieszek
6    SCSP driver provided by R.Belmont, based on ElSemi's SCSP sound chip emulator
7    CD Block driver provided by ANY, based on sthief original emulator
8    Many thanks to Guru, Fabien & Runik for the help given.
9
10===================================================================================================
11
12Notes:
13-To enter into an Advanced Test Mode,keep pressed the Test Button (F2) on the start-up.
14-Memo: Some tests done on the original & working PCB,to be implemented:
15 -The AD-Stick returns 0x00 or a similar value.
16 -The Ports E,F & G must return 0xff
17 -The regular BIOS tests (Memory Test) changes his background color at some point to
18  several gradients of red,green and blue.Current implementation remains black.I dunno
19  if this is a framebuffer write or a funky transparency issue (i.e TRANSPARENT_NONE
20  should instead show the back layer).
21 -RBG0 rotating can be checked on the "Advanced Test" menu thru the VDP1/VDP2 check.
22  It rotates clockwise IIRC.Also the ST-V logo when the game is in Multi mode rotates too.
23 -The MIDI communication check fails even on a ST-V board,somebody needs to check if there
24  is a MIDI port on the real PCB...
25
26TODO:
27(Main issues)
28- decap the SH-1, used for CD block (needed especially for Sega Saturn)
29- IRQs: some games have some issues with timing accurate IRQs,check/fix all of them.
30- The Cart-Dev mode hangs even with the -dev bios,I would like to see what it does on the real HW.
31- IC13 games on the bios dev doesn't even load the cartridge / crashes the emulation at start-up,
32  rom rearrange needed?
33- finish the DSP core.
34- Add the RS232c interface (serial port),needed by fhboxers.
35- (PCB owners) check if the clocks documented in the manuals are really right for ST-V.
36- We need to check every game if can be completed or there are any hanging/crash/protection
37  issues on them.
38- Clean-ups and split the various chips(SCU,SMPC) into their respective files (in progress).
39- Video emulation bugs: check stvvdp2.c file.
40- Reimplement the idle skip if possible.
41- clean up the I/Os, by using per-game specific mapped ports and rewrite it by using 16-bit trampolines
42- Properly emulate the protection chips, used by several games (check stvprot.c for more info)
43
44(per-game issues)
45- stress: accesses the Sound Memory Expansion Area (0x05a00000-0x05afffff), unknown purpose;
46- smleague / finlarch: it randomly hangs / crashes,it works if you use a ridiculous MCFG_INTERLEAVE number,might need strict
47  SH-2 synching.
48- suikoenb/shanhigw + others: why do we get 2 credits on startup? Cause might be by a communication with the M68k
49- bakubaku: sound part is largely incomplete,caused by a tight loop at location PC=1048 of the sound cpu part.
50- myfairld: Apparently this game gives a black screen (either test mode and in-game mode),but let it wait for about
51  10 seconds and the game will load everything. This is because of a hellishly slow m68k sub-routine located at 54c2.
52  Likely to not be a bug but an in-game design issue.
53- myfairld: Micronet programmers had the "great" idea to *not* use the ST-V input standards,infact
54  joystick panel is mapped with input_port(10) instead of input_port(2),so for now use
55  the mahjong panel instead.
56- danchih: hanafuda panel doesn't work.
57- findlove: controls doesn't work? Playing with the debugger at location $6063720 it makes it get furter,but controls
58  still doesn't work,missing irq?
59- batmanfr: Missing sound,caused by an extra ADSP chip which is on the cart.The CPU is a
60  ADSP-2181,and it's the same used by NBA Jam Extreme (ZN game).
61- vfremix: when you play Akira, there is a problem with third match: game doesn't upload all textures
62  and tiles and doesn't enable display, although gameplay is normal - wait a while to get back
63  to title screen after losing a match
64
65===================================================================================================
66
967Hardware overview:
1068------------------
1169-two SH-2 CPUs,in a master/slave configuration.The master cpu is used to
r11640r11641
3795 -shadow effects;
3896 -global rgb brightness control,separate for every plane;
3997
40Memory map:
41-----------
98****************************************************************************************************/
4299
430x00000000, 0x0007ffff  BIOS ROM
440x00080000, 0x000fffff  Unused
450x00100000, 0x0010007f  SMPC
460x00100080, 0x0017ffff  Unused
470x00180000, 0x0018ffff  Back Up Ram
480x00190000, 0x001fffff  Unused
490x00200000, 0x002fffff  Work Ram-L
500x00300000, 0x00ffffff  Unused
510x01000000, 0x01000003  MINIT
520x01000004, 0x017fffff  Unused
530x01800000, 0x01800003  SINIT
540x01800004, 0x01ffffff  Unused
550x02000000, 0x03ffffff  A-BUS CS0
560x04000000, 0x04ffffff  A-BUS CS1
570x05000000, 0x057fffff  A-BUS DUMMY
580x05800000, 0x058fffff  A-BUS CS2
590x05900000, 0x059fffff  Unused
600x05a00000, 0x05b00ee3  Sound Region
610x05b00ee4, 0x05bfffff  Unused
620x05c00000, 0x05cbffff  VDP 1
630x05cc0000, 0x05cfffff  Unused
640x05d00000, 0x05d00017  VDP 1 regs
650x05d00018, 0x05dfffff  Unused
660x05e00000, 0x05e7ffff  VDP2
670x05e80000, 0x05efffff  VDP2 Extra RAM,accessible thru the VRAMSZ register
680x05f00000, 0x05f00fff  VDP2 Color RAM
690x05f01000, 0x05f7ffff  Unused
700x05f80000  0x05f8011f  VDP2 regs
710x05f80120, 0x05fdffff  Unused
720x05fe0000, 0x05fe00cf  SCU regs
730x05fe00d0, 0x05ffffff  Unused
740x06000000, 0x060fffff  Work Ram-H
750x06100000, 0x07ffffff  Unused
76
77*the unused locations aren't known if they are really unused or not,needs verification,most
78of them seem just mirrors of the previous valid memory allocated.
79
80ToDo / Notes:
81-------------
82
83-To enter into an Advanced Test Mode,keep pressed the Test Button (F2) on the start-up.
84
85(Main issues)
86-IRQs: some games have some issues with timing accurate IRQs,check/fix all of them.
87-Clean-ups and split the various chips(SCU,SMPC)into their respective files.
88-CD block:complete it.
89-The Cart-Dev mode hangs even with the -dev bios,I would like to see what it does on the real HW.
90-IC13 games on the bios dev doesn't even load the cartridge / crashes the emulation at start-up,
91 rom rearrange needed?
92-finish the DSP core.
93-Add the RS232c interface (serial port),needed by fhboxers.
94-(PCB owners) check if the clocks documented in the manuals are really right for ST-V.
95-SCSP to master irq: see if there is a sound cpu mask bit.
96-Does the device_set_clock really works?Investigate.
97-We need to check every game if can be completed or there are any hanging/crash/protection
98 issues on them.
99-Memo: Some tests done on the original & working PCB,to be implemented:
100 -The AD-Stick returns 0x00 or a similar value.
101 -The Ports E,F & G must return 0xff
102 -The regular BIOS tests (Memory Test) changes his background color at some point to
103  several gradients of red,green and blue.Current implementation remains black.I dunno
104  if this is a framebuffer write or a funky transparency issue (i.e TRANSPARENT_NONE
105  should instead show the back layer).
106 -RBG0 rotating can be checked on the "Advanced Test" menu thru the VDP1/VDP2 check.
107  It rotates clockwise IIRC.Also the ST-V logo when the game is in Multi mode rotates too.
108 -The MIDI communication check fails even on a ST-V board,somebody needs to check if there
109  is a MIDI port on the real PCB...
110-All games except shienryu: add default eeprom if necessary (1P/3P games for example).
111-Video emulation bugs: check stvvdp2.c file.
112
113(per-game issues)
114-stress: accesses the Sound Memory Expansion Area (0x05a00000-0x05afffff), unknown purpose;
115-smleague / finlarch: it randomly hangs / crashes,it works if you use a ridiculous MCFG_INTERLEAVE number,might need strict
116 SH-2 synching.
117-various: find idle skip if possible.
118-suikoenb/shanhigw + others: why do we get 2 credits on startup? Cause might be by a communication with the M68k
119-colmns97/puyosun/mausuke/cotton2/cottonbm: interrupt issues? we can't check the SCU mask
120 on SMPC or controls fail
121-mausuke/bakubaku/grdforce: need to sort out transparency on the colour mapped sprites
122-bakubaku: sound part is largely incomplete,caused by a tight loop at location PC=1048 of the sound cpu part.
123-myfairld: Apparently this game gives a black screen (either test mode and in-game mode),but let it wait for about
124 10 seconds and the game will load everything.This is because of a hellishly slow m68k sub-routine located at 54c2.
125 Likely to not be a bug but an in-game design issue.
126-myfairld: Micronet programmers had the "great" idea to *not* use the ST-V input standards,infact
127 joystick panel is mapped with input_port(10) instead of input_port(2),so for now use
128 the mahjong panel instead.
129-danchih: hanafuda panel doesn't work.
130-decathlt: Is currently using a strange protection DMA abus control,and it uses some sort of RLE
131 compression/encryption that serves as a gfxdecode.
132-findlove: controls doesn't work? Playing with the debugger at location $6063720 it makes it get furter,but controls
133 still doesn't work,missing irq?
134-batmanfr: Missing sound,caused by an extra ADSP chip which is on the cart.The CPU is a
135 ADSP-2181,and it's the same used by NBA Jam Extreme (ZN game).
136-vfremix: when you play Akira, there is a problem with third match: game doesn't upload all textures
137 and tiles and doesn't enable display, although gameplay is normal - wait a while to get back
138 to title screen after losing a match
139-sokyugrt: gameplay seems to be not smooth, timing?
140-seabass: crashes in stvcd.c - there is no CD and we report than we have one, and game tries
141 to read something, however it doesn't do it after nvram is deleted?
142-Protection issues:
143 \-ffreveng: boot vectors;
144 \-decathlt: in-game graphics;
145 \-elandore: human / dragons textures;
146 \-twcup98: tecmo logo / sprite movements;
147 \-astrass: text layer (kludged for now);
148
149
150*/
151
152100#include "emu.h"
153101#include "cpu/m68000/m68000.h"
154102#include "machine/eeprom.h"
r11640r11641
163111#include "coreutil.h"
164112
165113
166
114/* TODO: do this in a verboselog style */
167115#define LOG_CDB  0
168116#define LOG_SMPC 0
169117#define LOG_SCU  0
r11640r11641
181129
182130//static void stv_dump_ram(void);
183131
184static UINT32* ioga;
185static UINT16* scsp_regs;
186static int saturn_region;
187
188132/*VDP2 stuff*/
189133/*SMPC stuff*/
190134/*SCU stuff*/
r11640r11641
213157static void scu_dma_indirect(address_space *space, UINT8 dma_ch); /*DMA level 0 indirect transfer function*/
214158
215159
216int minit_boost,sinit_boost;
217attotime minit_boost_timeslice, sinit_boost_timeslice;
218160
219161//static int scanline;
220162
221static emu_timer *stv_rtc_timer;
222
223
224163/*A-Bus IRQ checks,where they could be located these?*/
225164#define ABUSIRQ(_irq_,_vector_) \
226165   { cputag_set_input_line_and_vector(device->machine(), "maincpu", _irq_, HOLD_LINE , _vector_); }
r11640r11641
4013407e
4023417f -w EXLE2/1
403342*/
404static UINT8 IOSEL1;
405static UINT8 IOSEL2;
406static UINT8 EXLE1;
407static UINT8 EXLE2;
408static UINT8 PDR1;
409static UINT8 PDR2;
410static int intback_stage = 0, smpcSR, pmode;
411static UINT8 SMEM[4];
412343
413#define SH2_DIRECT_MODE_PORT_1 IOSEL1 = 1
414#define SH2_DIRECT_MODE_PORT_2 IOSEL2 = 1
415#define SMPC_CONTROL_MODE_PORT_1 IOSEL1 = 0
416#define SMPC_CONTROL_MODE_PORT_2 IOSEL2 = 0
417
418
419
420static void system_reset(address_space *space)
421{
422   saturn_state *state = space->machine().driver_data<saturn_state>();
423
424   /*Only backup ram and SMPC ram are retained after that this command is issued.*/
425   memset(state->m_scu_regs ,0x00,0x000100);
426   memset(scsp_regs    ,0x00,0x001000);
427   memset(state->m_sound_ram  ,0x00,0x080000);
428   memset(state->m_workram_h,0x00,0x100000);
429   memset(state->m_workram_l,0x00,0x100000);
430   memset(stv_vdp2_regs,0x00,0x040000);
431   memset(stv_vdp2_vram,0x00,0x100000);
432   memset(stv_vdp2_cram,0x00,0x080000);
433   //vdp1
434   //A-Bus
435   /*Order is surely wrong but whatever...*/
436}
437
438344static READ8_HANDLER( stv_SMPC_r8 )
439345{
440346   saturn_state *state = space->machine().driver_data<saturn_state>();
r11640r11641
454360//  if (offset == 0x33) //country code
455361//      return_data = input_port_read(machine, "FAKE");
456362
457   if (cpu_get_pc(&space->device())==0x060020E6) return_data = 0x10;//???
458
459363   //if(LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x Returns %02x\n", space->device().tag(), cpu_get_pc(&space->device()), offset, return_data);
460364
461365
r11640r11641
486390   machine.scheduler().timer_set(attotime::zero, FUNC(stv_bankswitch_state), gameno);
487391}
488392
393static void smpc_master_on(running_machine &machine)
394{
395   saturn_state *state = machine.driver_data<saturn_state>();
396
397   device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, CLEAR_LINE);
398}
399
400static void smpc_slave_enable(running_machine &machine,UINT8 cmd)
401{
402   saturn_state *state = machine.driver_data<saturn_state>();
403
404   device_set_input_line(state->m_slave, INPUT_LINE_RESET, cmd ? ASSERT_LINE : CLEAR_LINE);
405}
406
407static void smpc_sound_enable(running_machine &machine,UINT8 cmd)
408{
409   saturn_state *state = machine.driver_data<saturn_state>();
410
411   device_set_input_line(state->m_audiocpu, INPUT_LINE_RESET, cmd ? ASSERT_LINE : CLEAR_LINE);
412   state->m_en_68k = cmd ^ 1;
413}
414
415static void smpc_system_reset(running_machine &machine)
416{
417   saturn_state *state = machine.driver_data<saturn_state>();
418
419   /*Only backup ram and SMPC ram are retained after that this command is issued.*/
420   memset(state->m_scu_regs ,0x00,0x000100);
421   memset(state->m_scsp_regs,0x00,0x001000);
422   memset(state->m_sound_ram,0x00,0x080000);
423   memset(state->m_workram_h,0x00,0x100000);
424   memset(state->m_workram_l,0x00,0x100000);
425   memset(state->m_vdp2_regs,0x00,0x040000);
426   memset(state->m_vdp2_vram,0x00,0x100000);
427   memset(state->m_vdp2_cram,0x00,0x080000);
428   memset(state->m_vdp1_vram,0x00,0x100000);
429   //A-Bus
430
431   device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, PULSE_LINE);
432}
433
434static void smpc_change_clock(running_machine &machine, UINT8 cmd)
435{
436   saturn_state *state = machine.driver_data<saturn_state>();
437   UINT32 xtal;
438
439   xtal = cmd ? MASTER_CLOCK_320 : MASTER_CLOCK_352;
440
441   machine.device("maincpu")->set_unscaled_clock(xtal/2);
442   machine.device("slave")->set_unscaled_clock(xtal/2);
443   machine.device("audiocpu")->set_unscaled_clock(xtal/5);
444
445   state->m_vdp2.pixel_clock = cmd;
446   stv_vdp2_dynamic_res_change(machine);
447
448   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi?
449}
450
451static void smpc_intbackhelper(running_machine &machine)
452{
453   saturn_state *state = machine.driver_data<saturn_state>();
454   int pad;
455   static const char *const padnames[] = { "JOY1", "JOY2" };
456
457   if (state->m_smpc.intback_stage == 1)
458   {
459      state->m_smpc.intback_stage++;
460      return;
461   }
462
463   pad = input_port_read(machine, padnames[state->m_smpc.intback_stage-2]);
464
465//  if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2);
466   state->m_smpc_ram[33] = 0xf1;   // no tap, direct connect
467   state->m_smpc_ram[35] = 0x02;   // saturn pad
468   state->m_smpc_ram[37] = pad>>8;
469   state->m_smpc_ram[39] = pad & 0xff;
470
471   if (state->m_smpc.intback_stage == 3)
472   {
473      state->m_smpc.smpcSR = (0x80 | state->m_smpc.pmode);   // pad 2, no more data, echo back pad mode set by intback
474   }
475   else
476   {
477      state->m_smpc.smpcSR = (0xe0 | state->m_smpc.pmode);   // pad 1, more data, echo back pad mode set by intback
478   }
479
480   state->m_smpc.intback_stage++;
481}
482
483/* sys_type 1 == STV, 0 == SATURN */
484static void smpc_intback(running_machine &machine, UINT8 sys_type,system_time systime)
485{
486   saturn_state *state = machine.driver_data<saturn_state>();
487   state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
488
489   if(sys_type == 0)
490   {
491      state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100);
492       state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100);
493      state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month + 1);
494       state->m_smpc_ram[0x29] = dec_2_bcd(systime.local_time.mday);
495       state->m_smpc_ram[0x2b] = dec_2_bcd(systime.local_time.hour);
496       state->m_smpc_ram[0x2d] = dec_2_bcd(systime.local_time.minute);
497       state->m_smpc_ram[0x2f] = dec_2_bcd(systime.local_time.second);
498   }
499
500   state->m_smpc_ram[0x31]=0x00;  //?
501
502   //state->m_smpc_ram[0x33]=input_port_read(space->machine(), "FAKE");
503
504   state->m_smpc_ram[0x35]=0x00;
505   state->m_smpc_ram[0x37]=0x00;
506
507   state->m_smpc_ram[0x39]=sys_type ? 0xff : state->m_smpc.SMEM[0];
508   state->m_smpc_ram[0x3b]=sys_type ? 0xff : state->m_smpc.SMEM[1];
509   state->m_smpc_ram[0x3d]=sys_type ? 0xff : state->m_smpc.SMEM[2];
510   state->m_smpc_ram[0x3f]=sys_type ? 0xff : state->m_smpc.SMEM[3];
511
512   state->m_smpc_ram[0x41]=0xff;
513   state->m_smpc_ram[0x43]=0xff;
514   state->m_smpc_ram[0x45]=0xff;
515   state->m_smpc_ram[0x47]=0xff;
516   state->m_smpc_ram[0x49]=0xff;
517   state->m_smpc_ram[0x4b]=0xff;
518   state->m_smpc_ram[0x4d]=0xff;
519   state->m_smpc_ram[0x4f]=0xff;
520   state->m_smpc_ram[0x51]=0xff;
521   state->m_smpc_ram[0x53]=0xff;
522   state->m_smpc_ram[0x55]=0xff;
523   state->m_smpc_ram[0x57]=0xff;
524   state->m_smpc_ram[0x59]=0xff;
525   state->m_smpc_ram[0x5b]=0xff;
526   state->m_smpc_ram[0x5d]=0xff;
527
528   if(sys_type == 0)
529   {
530      state->m_smpc.smpcSR = 0x60;      // peripheral data ready, no reset, etc.
531      state->m_smpc.pmode = state->m_smpc_ram[1]>>4;
532
533      state->m_smpc.intback_stage = 1;
534
535      smpc_intbackhelper(machine);
536   }
537
538   //  /*This is for RTC,cartridge code and similar stuff...*/
539   //if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline);
540   device_set_input_line_and_vector(state->m_maincpu, 8, (stv_irq.smpc) ? HOLD_LINE : CLEAR_LINE, 0x47);
541}
542
543static void smpc_rtc_write(running_machine &machine)
544{
545   saturn_state *state = machine.driver_data<saturn_state>();
546   state->m_smpc_ram[0x2f] = state->m_smpc_ram[0x0d];
547   state->m_smpc_ram[0x2d] = state->m_smpc_ram[0x0b];
548   state->m_smpc_ram[0x2b] = state->m_smpc_ram[0x09];
549   state->m_smpc_ram[0x29] = state->m_smpc_ram[0x07];
550   state->m_smpc_ram[0x27] = state->m_smpc_ram[0x05];
551   state->m_smpc_ram[0x25] = state->m_smpc_ram[0x03];
552   state->m_smpc_ram[0x23] = state->m_smpc_ram[0x01];
553}
554
555static void smpc_memory_setting(running_machine &machine)
556{
557   saturn_state *state = machine.driver_data<saturn_state>();
558   state->m_smpc.SMEM[0] = state->m_smpc_ram[1];
559   state->m_smpc.SMEM[1] = state->m_smpc_ram[3];
560   state->m_smpc.SMEM[2] = state->m_smpc_ram[5];
561   state->m_smpc.SMEM[3] = state->m_smpc_ram[7];
562}
563
564static void smpc_nmi_req(running_machine &machine)
565{
566   saturn_state *state = machine.driver_data<saturn_state>();
567
568   /*NMI is unconditionally requested?*/
569   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE);
570}
571
572static void smpc_nmi_set(running_machine &machine,UINT8 cmd)
573{
574   saturn_state *state = machine.driver_data<saturn_state>();
575
576   state->m_NMI_reset = cmd ^ 1;
577   state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
578}
579
489580static WRITE8_HANDLER( stv_SMPC_w8 )
490581{
491582   saturn_state *state = space->machine().driver_data<saturn_state>();
r11640r11641
497588
498589   if(offset == 0x75)
499590   {
591      /*
592        -xx- ---- PDR1
593        ---x ---- EEPROM write bit
594        ---- x--- EEPROM CLOCK line
595        ---- -x-- EEPROM CS line
596        ---- --xx A-Bus bank bits
597        */
500598      eeprom_device *eeprom = space->machine().device<eeprom_device>("eeprom");
501599      eeprom->set_clock_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
502600      eeprom->write_bit(data & 0x10);
r11640r11641
505603
506604      stv_select_game(space->machine(), state->m_stv_multi_bank);
507605
508//      if (data & 0x01)
509//          if(LOG_SMPC) logerror("bit 0 active\n");
510//      if (data & 0x02)
511//          if(LOG_SMPC) logerror("bit 1 active\n");
512//      if (data & 0x10)
513         //if(LOG_SMPC) logerror("bit 4 active\n");//LOT
514      //if(LOG_SMPC) logerror("SMPC: ram [0x75] = %02x\n",state->m_smpc_ram[0x75]);
515      PDR1 = (data & 0x60);
606      state->m_smpc.PDR1 = (data & 0x60);
516607   }
517608
518609   if(offset == 0x77)
519610   {
520611      /*
521            ACTIVE LOW
522            bit 4(0x10) - Enable Sound System
612            -xx- ---- PDR2
613            ---x ---- Enable Sound System (ACTIVE LOW)
523614        */
524615      //popmessage("PDR2 = %02x",state->m_smpc_ram[0x77]);
525616
r11640r11641
528619      state->m_en_68k = ((state->m_smpc_ram[0x77] & 0x10) >> 4) ^ 1;
529620
530621      //if(LOG_SMPC) logerror("SMPC: ram [0x77] = %02x\n",state->m_smpc_ram[0x77]);
531      PDR2 = (data & 0x60);
622      state->m_smpc.PDR2 = (data & 0x60);
532623   }
533624
534625   if(offset == 0x7d)
535626   {
536      if(state->m_smpc_ram[0x7d] & 1)
537         SH2_DIRECT_MODE_PORT_1;
538      else
539         SMPC_CONTROL_MODE_PORT_1;
540
541      if(state->m_smpc_ram[0x7d] & 2)
542         SH2_DIRECT_MODE_PORT_2;
543      else
544         SMPC_CONTROL_MODE_PORT_2;
627      /*
628        ---- --x- IOSEL2 direct (1) / control mode (0) port select
629        ---- ---x IOSEL1 direct (1) / control mode (0) port select
630        */
631      state->m_smpc.IOSEL1 = (state->m_smpc_ram[0x7d] & 1) >> 0;
632      state->m_smpc.IOSEL2 = (state->m_smpc_ram[0x7d] & 2) >> 1;
545633   }
546634
547   /*TODO: probably this is wrong...*/
548635   if(offset == 0x7f)
549636   {
550637      //enable PAD irq & VDP2 external latch for port 1/2
551      EXLE1 = state->m_smpc_ram[0x7f] & 1 ? 1 : 0;
552      EXLE2 = state->m_smpc_ram[0x7f] & 2 ? 1 : 0;
553      if(EXLE1 || EXLE2)
638      state->m_smpc.EXLE1 = (state->m_smpc_ram[0x7f] & 1) >> 0;
639      state->m_smpc.EXLE2 = (state->m_smpc_ram[0x7f] & 2) >> 1;
640      if(state->m_smpc.EXLE1 || state->m_smpc.EXLE2)
554641      {
555642         //if(LOG_SMPC) logerror ("Interrupt: PAD irq at scanline %04x, Vector 0x48 Level 0x08\n",scanline);
556         cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.pad) ? HOLD_LINE : CLEAR_LINE, 0x48);
643         //cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.pad) ? HOLD_LINE : CLEAR_LINE, 0x48);
557644      }
558645   }
559646
560   if (offset == 0x1f)
647   if (offset == 0x1f) // COMREG
561648   {
562649      switch (data)
563650      {
564651         case 0x00:
565652            if(LOG_SMPC) logerror ("SMPC: Master ON\n");
566            state->m_smpc_ram[0x5f]=0x00;
653            smpc_master_on(space->machine());
567654            break;
568655         //in theory 0x01 is for Master OFF,but obviously is not used.
569656         case 0x02:
570            if(LOG_SMPC) logerror ("SMPC: Slave ON\n");
571            state->m_smpc_ram[0x5f]=0x02;
572            cputag_set_input_line(space->machine(), "slave", INPUT_LINE_RESET, CLEAR_LINE);
573            break;
574657         case 0x03:
575            if(LOG_SMPC) logerror ("SMPC: Slave OFF\n");
576            state->m_smpc_ram[0x5f]=0x03;
577            space->machine().scheduler().trigger(1000);
578            cputag_set_input_line(space->machine(), "slave", INPUT_LINE_RESET, ASSERT_LINE);
658            if(LOG_SMPC) logerror ("SMPC: Slave %s\n",(data & 1) ? "off" : "on");
659            smpc_slave_enable(space->machine(),(data & 1));
579660            break;
580661         case 0x06:
581            if(LOG_SMPC) logerror ("SMPC: Sound ON\n");
582            /* wrong? */
583            state->m_smpc_ram[0x5f]=0x06;
584            cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_RESET, CLEAR_LINE);
585            break;
586662         case 0x07:
587            if(LOG_SMPC) logerror ("SMPC: Sound OFF\n");
588            state->m_smpc_ram[0x5f]=0x07;
663            if(LOG_SMPC) logerror ("SMPC: Sound %s, ignored\n",(data & 1) ? "off" : "on");
589664            break;
590665         /*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/
591666         //case 0x08:
592667         //case 0x09:
593668         case 0x0d:
594669            if(LOG_SMPC) logerror ("SMPC: System Reset\n");
595            state->m_smpc_ram[0x5f]=0x0d;
596            cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
597            system_reset(space);
670            smpc_system_reset(space->machine());
598671            break;
599672         case 0x0e:
600            if(LOG_SMPC) logerror ("SMPC: Change Clock to 352\n");
601            state->m_smpc_ram[0x5f]=0x0e;
602            space->machine().device("maincpu")->set_unscaled_clock(MASTER_CLOCK_352/2);
603            space->machine().device("slave")->set_unscaled_clock(MASTER_CLOCK_352/2);
604            space->machine().device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_352/5);
605            cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi?
606            break;
607673         case 0x0f:
608            if(LOG_SMPC) logerror ("SMPC: Change Clock to 320\n");
609            state->m_smpc_ram[0x5f]=0x0f;
610            space->machine().device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2);
611            space->machine().device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2);
612            space->machine().device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_320/5);
613            cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi?
674            if(LOG_SMPC) logerror ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352");
675            smpc_change_clock(space->machine(),data & 1);
614676            break;
615677         /*"Interrupt Back"*/
616678         case 0x10:
617679            if(LOG_SMPC) logerror ("SMPC: Status Acquire\n");
618            state->m_smpc_ram[0x5f]=0x10;
619            state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
620            //state->m_smpc_ram[0x23] = DectoBCD(systime.local_time.year /100);
621            //state->m_smpc_ram[0x25] = DectoBCD(systime.local_time.year %100);
622            //state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month+1);
623            //state->m_smpc_ram[0x29] = DectoBCD(systime.local_time.mday);
624            //state->m_smpc_ram[0x2b] = DectoBCD(systime.local_time.hour);
625            //state->m_smpc_ram[0x2d] = DectoBCD(systime.local_time.minute);
626            //state->m_smpc_ram[0x2f] = DectoBCD(systime.local_time.second);
627
628            state->m_smpc_ram[0x31]=0x00;  //?
629
630            //state->m_smpc_ram[0x33]=input_port_read(space->machine(), "FAKE");
631
632            state->m_smpc_ram[0x35]=0x00;
633            state->m_smpc_ram[0x37]=0x00;
634
635            state->m_smpc_ram[0x39]=0xff;
636            state->m_smpc_ram[0x3b]=0xff;
637            state->m_smpc_ram[0x3d]=0xff;
638            state->m_smpc_ram[0x3f]=0xff;
639            state->m_smpc_ram[0x41]=0xff;
640            state->m_smpc_ram[0x43]=0xff;
641            state->m_smpc_ram[0x45]=0xff;
642            state->m_smpc_ram[0x47]=0xff;
643            state->m_smpc_ram[0x49]=0xff;
644            state->m_smpc_ram[0x4b]=0xff;
645            state->m_smpc_ram[0x4d]=0xff;
646            state->m_smpc_ram[0x4f]=0xff;
647            state->m_smpc_ram[0x51]=0xff;
648            state->m_smpc_ram[0x53]=0xff;
649            state->m_smpc_ram[0x55]=0xff;
650            state->m_smpc_ram[0x57]=0xff;
651            state->m_smpc_ram[0x59]=0xff;
652            state->m_smpc_ram[0x5b]=0xff;
653            state->m_smpc_ram[0x5d]=0xff;
654
655         //  /*This is for RTC,cartridge code and similar stuff...*/
656            /*System Manager(SMPC) irq*/
657            {
658               //if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline);
659               cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.smpc) ? HOLD_LINE : CLEAR_LINE, 0x47);
660            }
661         break;
680            smpc_intback(space->machine(),1,systime);
681            break;
662682         /* RTC write*/
663683         case 0x16:
664684            if(LOG_SMPC) logerror("SMPC: RTC write\n");
665            state->m_smpc_ram[0x2f] = state->m_smpc_ram[0x0d];
666            state->m_smpc_ram[0x2d] = state->m_smpc_ram[0x0b];
667            state->m_smpc_ram[0x2b] = state->m_smpc_ram[0x09];
668            state->m_smpc_ram[0x29] = state->m_smpc_ram[0x07];
669            state->m_smpc_ram[0x27] = state->m_smpc_ram[0x05];
670            state->m_smpc_ram[0x25] = state->m_smpc_ram[0x03];
671            state->m_smpc_ram[0x23] = state->m_smpc_ram[0x01];
672            state->m_smpc_ram[0x5f]=0x16;
673         break;
685            smpc_rtc_write(space->machine());
686            break;
674687         /* SMPC memory setting*/
675688         case 0x17:
676689            if(LOG_SMPC) logerror ("SMPC: memory setting\n");
677            state->m_smpc_ram[0x5f]=0x17;
678         break;
690            //smpc_memory_setting(space->machine());
691            break;
679692         case 0x18:
680693            if(LOG_SMPC) logerror ("SMPC: NMI request\n");
681            state->m_smpc_ram[0x5f]=0x18;
682            /*NMI is unconditionally requested?*/
683            cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
694            smpc_nmi_req(space->machine());
684695            break;
685696         case 0x19:
686            if(LOG_SMPC) logerror ("SMPC: NMI Enable\n");
687            state->m_smpc_ram[0x5f]=0x19;
688            state->m_NMI_reset = 0;
689            state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
690            break;
691697         case 0x1a:
692            if(LOG_SMPC) logerror ("SMPC: NMI Disable\n");
693            state->m_smpc_ram[0x5f]=0x1a;
694            state->m_NMI_reset = 1;
695            state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
698            if(LOG_SMPC) logerror ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En");
699            smpc_nmi_set(space->machine(),data & 1);
696700            break;
697701         default:
698            if(LOG_SMPC) logerror ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
702            printf ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
699703      }
700704
701705      // we've processed the command, clear status flag
706      state->m_smpc_ram[0x5f] = data; //read-back command
702707      state->m_smpc_ram[0x63] = 0x00;
703708      /*TODO:emulate the timing of each command...*/
704709   }
705710}
706711
707
708static void smpc_intbackhelper(running_machine &machine)
709{
710   saturn_state *state = machine.driver_data<saturn_state>();
711   int pad;
712   static const char *const padnames[] = { "JOY1", "JOY2" };
713
714   if (intback_stage == 1)
715   {
716      intback_stage++;
717      return;
718   }
719
720   pad = input_port_read(machine, padnames[intback_stage-2]);
721
722//  if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2);
723   state->m_smpc_ram[33] = 0xf1;   // no tap, direct connect
724   state->m_smpc_ram[35] = 0x02;   // saturn pad
725   state->m_smpc_ram[37] = pad>>8;
726   state->m_smpc_ram[39] = pad & 0xff;
727
728   if (intback_stage == 3)
729   {
730      smpcSR = (0x80 | pmode);   // pad 2, no more data, echo back pad mode set by intback
731   }
732   else
733   {
734      smpcSR = (0xe0 | pmode);   // pad 1, more data, echo back pad mode set by intback
735   }
736
737   intback_stage++;
738}
739
740712static READ8_HANDLER( saturn_SMPC_r8 )
741713{
742714   saturn_state *state = space->machine().driver_data<saturn_state>();
r11640r11641
745717   return_data = state->m_smpc_ram[offset];
746718
747719   if ((offset == 0x61))
748      return_data = smpcSR;
720      return_data = state->m_smpc.smpcSR;
749721
750722   if (offset == 0x75)//PDR1 read
751723   {
752      if (IOSEL1)
724      if (state->m_smpc.IOSEL1)
753725      {
754726         int hshake;
755727
756         hshake = (PDR1>>5) & 3;
728         hshake = (state->m_smpc.PDR1>>5) & 3;
757729
758730         if (LOG_SMPC) logerror("SMPC: SH-2 direct mode, returning data for phase %d\n", hshake);
759731
r11640r11641
787759      return_data =  0xff; // | EEPROM_read_bit());
788760   }
789761
790   if (offset == 0x33) return_data = saturn_region;
762   if (offset == 0x33) return_data = state->saturn_region;
791763
792764   if (LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x (%d) Returns %02x\n", space->device().tag(), cpu_get_pc(&space->device()), offset, offset>>1, return_data);
793765
r11640r11641
811783
812784   last = state->m_smpc_ram[offset];
813785
814   if ((intback_stage > 0) && (offset == 1) && (((data ^ 0x80)&0x80) == (last&0x80)))
786   if ((state->m_smpc.intback_stage > 0) && (offset == 1) && (((data ^ 0x80)&0x80) == (last&0x80)))
815787   {
816      if (LOG_SMPC) logerror("SMPC: CONTINUE request, stage %d\n", intback_stage);
817      if (intback_stage != 3)
788      if (LOG_SMPC) logerror("SMPC: CONTINUE request, stage %d\n", state->m_smpc.intback_stage);
789      if (state->m_smpc.intback_stage != 3)
818790      {
819         intback_stage = 2;
791         state->m_smpc.intback_stage = 2;
820792      }
821793      smpc_intbackhelper(machine);
822794      cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x47);
r11640r11641
825797   if ((offset == 1) && (data & 0x40))
826798   {
827799      if (LOG_SMPC) logerror("SMPC: BREAK request\n");
828      intback_stage = 0;
800      state->m_smpc.intback_stage = 0;
829801   }
830802
831803   state->m_smpc_ram[offset] = data;
832804
833805   if (offset == 0x75)   // PDR1
834806   {
835      PDR1 = (data & state->m_smpc_ram[0x79]);
807      state->m_smpc.PDR1 = (data & state->m_smpc_ram[0x79]);
836808   }
837809
838810   if (offset == 0x77)   // PDR2
839811   {
840      PDR2 = (data & state->m_smpc_ram[0x7b]);
812      state->m_smpc.PDR2 = (data & state->m_smpc_ram[0x7b]);
841813   }
842814
843815   if(offset == 0x7d)
844816   {
845      if(state->m_smpc_ram[0x7d] & 1)
846         SH2_DIRECT_MODE_PORT_1;
847      else
848         SMPC_CONTROL_MODE_PORT_1;
849
850      if(state->m_smpc_ram[0x7d] & 2)
851         SH2_DIRECT_MODE_PORT_2;
852      else
853         SMPC_CONTROL_MODE_PORT_2;
817      state->m_smpc.IOSEL1 = state->m_smpc_ram[0x7d] & 1;
818      state->m_smpc.IOSEL2 = (state->m_smpc_ram[0x7d] & 2) >> 1;
854819   }
855820
856821   if(offset == 0x7f)
857822   {
858823      //enable PAD irq & VDP2 external latch for port 1/2
859      EXLE1 = state->m_smpc_ram[0x7f] & 1 ? 1 : 0;
860      EXLE2 = state->m_smpc_ram[0x7f] & 2 ? 1 : 0;
861      if(EXLE1 || EXLE2)
862         if(!(state->m_scu_regs[40] & 0x0100)) /*Pad irq*/
863         {
864            if(LOG_SMPC) logerror ("Interrupt: PAD irq, Vector 0x48 Level 0x08\n");
865            cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x48);
866         }
824      state->m_smpc.EXLE1 = (state->m_smpc_ram[0x7f] & 1) >> 0;
825      state->m_smpc.EXLE2 = (state->m_smpc_ram[0x7f] & 2) >> 1;
826      //if(state->m_smpc.EXLE1 || state->m_smpc.EXLE2)
827      //  cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.pad) ? HOLD_LINE : CLEAR_LINE, 0x48);
867828   }
868829
869830   if (offset == 0x1f)
r11640r11641
872833      {
873834         case 0x00:
874835            if(LOG_SMPC) logerror ("SMPC: Master ON\n");
875            state->m_smpc_ram[0x5f]=0x00;
836            smpc_master_on(space->machine());
876837            break;
877         //in theory 0x01 is for Master OFF,but obviously is not used.
838         //in theory 0x01 is for Master OFF
878839         case 0x02:
879            if(LOG_SMPC) logerror ("SMPC: Slave ON\n");
880            state->m_smpc_ram[0x5f]=0x02;
881            cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, CLEAR_LINE);
882            break;
883840         case 0x03:
884            if(LOG_SMPC) logerror ("SMPC: Slave OFF\n");
885            state->m_smpc_ram[0x5f]=0x03;
886            machine.scheduler().trigger(1000);
887            cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, ASSERT_LINE);
841            if(LOG_SMPC) logerror ("SMPC: Slave %s\n",(data & 1) ? "off" : "on");
842            smpc_slave_enable(space->machine(),data & 1);
888843            break;
889844         case 0x06:
890            if(LOG_SMPC) logerror ("SMPC: Sound ON\n");
891            /* wrong? */
892            state->m_smpc_ram[0x5f]=0x06;
893            cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, CLEAR_LINE);
894            state->m_en_68k = 1;
895            break;
896845         case 0x07:
897            if(LOG_SMPC) logerror ("SMPC: Sound OFF\n");
898            cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
899            state->m_en_68k = 0;
900            state->m_smpc_ram[0x5f]=0x07;
846            if(LOG_SMPC) logerror ("SMPC: Sound %s\n",(data & 1) ? "off" : "on");
847            smpc_sound_enable(space->machine(),data & 1);
901848            break;
902849         /*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/
903850         //case 0x08:
904851         //case 0x09:
905852         case 0x0d:
906853            if(LOG_SMPC) logerror ("SMPC: System Reset\n");
907            state->m_smpc_ram[0x5f]=0x0d;
908            cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
909            system_reset(space);
854            smpc_system_reset(space->machine());
910855            break;
911856         case 0x0e:
912            if(LOG_SMPC) logerror ("SMPC: Change Clock to 352\n");
913            state->m_smpc_ram[0x5f]=0x0e;
914            machine.device("maincpu")->set_unscaled_clock(MASTER_CLOCK_352/2);
915            machine.device("slave")->set_unscaled_clock(MASTER_CLOCK_352/2);
916            machine.device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_352/5);
917            cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi?
918            break;
919857         case 0x0f:
920            if(LOG_SMPC) logerror ("SMPC: Change Clock to 320\n");
921            state->m_smpc_ram[0x5f]=0x0f;
922            machine.device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2);
923            machine.device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2);
924            machine.device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_320/5);
925            cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi?
858            if(LOG_SMPC) logerror ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352");
859            smpc_change_clock(space->machine(),data & 1);
926860            break;
927861         /*"Interrupt Back"*/
928862         case 0x10:
929                      if(LOG_SMPC) logerror ("SMPC: Status Acquire (IntBack)\n");
930            state->m_smpc_ram[0x5f]=0x10;
931            state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
932            state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100);
933             state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100);
934             state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month + 1);
935             state->m_smpc_ram[0x29] = dec_2_bcd(systime.local_time.mday);
936             state->m_smpc_ram[0x2b] = dec_2_bcd(systime.local_time.hour);
937             state->m_smpc_ram[0x2d] = dec_2_bcd(systime.local_time.minute);
938             state->m_smpc_ram[0x2f] = dec_2_bcd(systime.local_time.second);
939
940            state->m_smpc_ram[0x31]=0x00;  //?
941
942
943            state->m_smpc_ram[0x35]=0x00;
944            state->m_smpc_ram[0x37]=0x00;
945
946            state->m_smpc_ram[0x39] = SMEM[0];
947            state->m_smpc_ram[0x3b] = SMEM[1];
948            state->m_smpc_ram[0x3d] = SMEM[2];
949            state->m_smpc_ram[0x3f] = SMEM[3];
950
951            state->m_smpc_ram[0x41]=0xff;
952            state->m_smpc_ram[0x43]=0xff;
953            state->m_smpc_ram[0x45]=0xff;
954            state->m_smpc_ram[0x47]=0xff;
955            state->m_smpc_ram[0x49]=0xff;
956            state->m_smpc_ram[0x4b]=0xff;
957            state->m_smpc_ram[0x4d]=0xff;
958            state->m_smpc_ram[0x4f]=0xff;
959            state->m_smpc_ram[0x51]=0xff;
960            state->m_smpc_ram[0x53]=0xff;
961            state->m_smpc_ram[0x55]=0xff;
962            state->m_smpc_ram[0x57]=0xff;
963            state->m_smpc_ram[0x59]=0xff;
964            state->m_smpc_ram[0x5b]=0xff;
965            state->m_smpc_ram[0x5d]=0xff;
966
967            smpcSR = 0x60;      // peripheral data ready, no reset, etc.
968            pmode = state->m_smpc_ram[1]>>4;
969
970            intback_stage = 1;
971
972         //  /*This is for RTC,cartridge code and similar stuff...*/
973         //  if(!(state->m_scu_regs[40] & 0x0080)) /*System Manager(SMPC) irq*/ /* we can't check this .. breaks controls .. probably issues elsewhere? */
974            {
975//                  if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline);
976               smpc_intbackhelper(machine);
977               cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x47);
978            }
979         break;
863                if(LOG_SMPC) logerror ("SMPC: Status Acquire (IntBack)\n");
864              smpc_intback(space->machine(),0,systime);
865            break;
980866         /* RTC write*/
981867         case 0x16:
982868            if(LOG_SMPC) logerror("SMPC: RTC write\n");
983            state->m_smpc_ram[0x2f] = state->m_smpc_ram[0x0d];
984            state->m_smpc_ram[0x2d] = state->m_smpc_ram[0x0b];
985            state->m_smpc_ram[0x2b] = state->m_smpc_ram[0x09];
986            state->m_smpc_ram[0x29] = state->m_smpc_ram[0x07];
987            state->m_smpc_ram[0x27] = state->m_smpc_ram[0x05];
988            state->m_smpc_ram[0x25] = state->m_smpc_ram[0x03];
989            state->m_smpc_ram[0x23] = state->m_smpc_ram[0x01];
990            state->m_smpc_ram[0x5f]=0x16;
991         break;
869            smpc_rtc_write(space->machine());
870            break;
992871         /* SMPC memory setting*/
993872         case 0x17:
994873            if(LOG_SMPC) logerror ("SMPC: memory setting\n");
995                SMEM[0] = state->m_smpc_ram[1];
996                SMEM[1] = state->m_smpc_ram[3];
997                SMEM[2] = state->m_smpc_ram[5];
998                SMEM[3] = state->m_smpc_ram[7];
999
1000            state->m_smpc_ram[0x5f]=0x17;
1001         break;
874            smpc_memory_setting(space->machine());
875            break;
1002876         case 0x18:
1003877            if(LOG_SMPC) logerror ("SMPC: NMI request\n");
1004            state->m_smpc_ram[0x5f]=0x18;
1005            /*NMI is unconditionally requested?*/
1006            cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
878            smpc_nmi_req(space->machine());
1007879            break;
1008880         case 0x19:
1009            if(LOG_SMPC) logerror ("SMPC: NMI Enable\n");
1010            state->m_smpc_ram[0x5f]=0x19;
1011            state->m_NMI_reset = 0;
1012            state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
1013            break;
1014881         case 0x1a:
1015            if(LOG_SMPC) logerror ("SMPC: NMI Disable\n");
1016            state->m_smpc_ram[0x5f]=0x1a;
1017            state->m_NMI_reset = 1;
1018            state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6);
1019
882            if(LOG_SMPC) logerror ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En");
883            smpc_nmi_set(space->machine(),data & 1);
1020884            break;
1021885         default:
1022            if(LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
886            printf ("cpu %s (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
1023887      }
1024888
1025889      // we've processed the command, clear status flag
890      state->m_smpc_ram[0x5f] = data; //read-back for last command issued
1026891      state->m_smpc_ram[0x63] = 0x00;
1027892      /*TODO:emulate the timing of each command...*/
1028893   }
r11640r11641
1068933
1069934static READ32_HANDLER ( stv_io_r32 )
1070935{
936   saturn_state *state = space->machine().driver_data<saturn_state>();
1071937//  if(LOG_IOGA) logerror("(PC=%08X): I/O r %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, mem_mask);
1072938//  popmessage("SEL: %02x MUX: %02x OFF: %02x",port_sel,mux_data,offset*4);
1073939
r11640r11641
1120986      }
1121987      case 0x04/4:
1122988      if ( strcmp(space->machine().system().name,"critcrsh") == 0 )
1123         return ((input_port_read(space->machine(), "SYSTEM") << 16) & ((input_port_read(space->machine(), "P1") & 1) ? 0xffef0000 : 0xffff0000)) | (ioga[1]);
989         return ((input_port_read(space->machine(), "SYSTEM") << 16) & ((input_port_read(space->machine(), "P1") & 1) ? 0xffef0000 : 0xffff0000)) | (state->m_ioga[1]);
1124990      else
1125         return (input_port_read(space->machine(), "SYSTEM") << 16) | (ioga[1]);
991         return (input_port_read(space->machine(), "SYSTEM") << 16) | (state->m_ioga[1]);
1126992
1127993      case 0x08/4:
1128994      switch(port_sel)
1129995      {
1130996         case 0x77:   return (input_port_read(space->machine(), "UNUSED") << 16) | (input_port_read(space->machine(), "EXTRA"));
1131997         case 0x67:   return 0xffffffff;/**/
1132         case 0x20:  return 0xffff0000 | (ioga[2] & 0xffff);
1133         case 0x10:  return ((ioga[2] & 0xffff) << 16) | 0xffff;
998         case 0x20:  return 0xffff0000 | (state->m_ioga[2] & 0xffff);
999         case 0x10:  return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff;
11341000         case 0x60:  return 0xffffffff;/**/
11351001         default:
11361002         return 0xffffffff;
r11640r11641
11381004      case 0x0c/4:
11391005      switch(port_sel)
11401006      {
1141         case 0x60:  return ((ioga[2] & 0xffff) << 16) | 0xffff;
1007         case 0x60:  return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff;
11421008         default:
11431009         //popmessage("offs: 3 %02x",port_sel);
11441010         return 0xffffffff;
r11640r11641
11491015      {
11501016         case 0x77:
11511017         {
1152            //popmessage("(PC=%06x) offs 5 %04x %02x",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16));
1153            logerror("(PC=%06x) offs 5 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16));
1018            //popmessage("(PC=%06x) offs 5 %04x %02x",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
1019            logerror("(PC=%06x) offs 5 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
11541020
1155            //stv_m_workram_h[0x8e830/4] = ((ioga[5] & 0xff0000) >> 16) ^ 0x3;
1156            //stv_m_workram_h[0x8e834/4] = ((ioga[5] & 0xff0000) >> 16) ^ 0x3;
1157            return (ioga[5] & 0xff0000) >> 16;//stv_m_workram_h[0x8e830/4];//sound board data
1021            //stv_m_workram_h[0x8e830/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3;
1022            //stv_m_workram_h[0x8e834/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3;
1023            return (state->m_ioga[5] & 0xff0000) >> 16;//stv_m_workram_h[0x8e830/4];//sound board data
11581024         }
11591025         default: return 0xffffffff;
11601026      }
11611027      case 0x18/4:
11621028      switch(port_sel)
11631029      {
1164         case 0x60:  return ioga[5];
1030         case 0x60:  return state->m_ioga[5];
11651031         case 0x77:
11661032         {
1167            //popmessage("(PC=%06x) offs 6 %04x %02x",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16));
1168            logerror("(PC=%06x) offs 6 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16));
1033            //popmessage("(PC=%06x) offs 6 %04x %02x",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
1034            logerror("(PC=%06x) offs 6 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
11691035            return 0;//sound board status,non-zero = processing
11701036         }
11711037         default:
r11640r11641
11781044      port_i++;
11791045      return port_ad[port_i & 7];
11801046      default:
1181      return ioga[offset];
1047      return state->m_ioga[offset];
11821048   }
11831049}
11841050
11851051static WRITE32_HANDLER ( stv_io_w32 )
11861052{
1053   saturn_state *state = space->machine().driver_data<saturn_state>();
11871054//  if(LOG_IOGA) logerror("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask);
11881055
11891056//  printf("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask);
r11640r11641
11941061         if(ACCESSING_BITS_0_7)
11951062         {
11961063            /*Why does the BIOS tests these as ACTIVE HIGH? A program bug?*/
1197            ioga[1] = (data) & 0xff;
1064            state->m_ioga[1] = (data) & 0xff;
11981065            coin_counter_w(space->machine(), 0,~data & 0x01);
11991066            coin_counter_w(space->machine(), 1,~data & 0x02);
12001067            coin_lockout_w(space->machine(), 0,~data & 0x04);
r11640r11641
12071074      case 0x08/4:
12081075         if(ACCESSING_BITS_16_23)
12091076         {
1210            ioga[2] = data >> 16;
1211            mux_data = ioga[2];
1077            state->m_ioga[2] = data >> 16;
1078            mux_data = state->m_ioga[2];
12121079         }
12131080         else if(ACCESSING_BITS_0_7)
1214            ioga[2] = data;
1081            state->m_ioga[2] = data;
12151082         break;
12161083      case 0x0c/4:
12171084         if(ACCESSING_BITS_16_23)
1218            ioga[3] = data;
1085            state->m_ioga[3] = data;
12191086         break;
12201087      case 0x10/4:
12211088         if(ACCESSING_BITS_16_23)
r11640r11641
12231090         break;
12241091      case 0x14/4:
12251092         if(ACCESSING_BITS_16_23)
1226            ioga[5] = data;
1093            state->m_ioga[5] = data;
12271094         break;
12281095      //case 0x18/4:
12291096      case 0x1c/4:
12301097         //technical bowling tests here
12311098         if(ACCESSING_BITS_16_23)
1232            ioga[7] = data;
1099            state->m_ioga[7] = data;
12331100         break;
12341101
12351102   }
r11640r11641
13351202
13361203#define DMA_STATUS            (state->m_scu_regs[31])
13371204/*These macros sets the various DMA status flags.*/
1338#define D0MV_1   DMA_STATUS|=0x10
1339#define D1MV_1   DMA_STATUS|=0x100
1340#define D2MV_1   DMA_STATUS|=0x1000
1341#define D0MV_0   DMA_STATUS&=~0x10
1342#define D1MV_0   DMA_STATUS&=~0x100
1343#define D2MV_0   DMA_STATUS&=~0x1000
1205#define DnMV_1(_ch_) DMA_STATUS|=(0x10 << 4 * _ch_)
1206#define DnMV_0(_ch_) DMA_STATUS&=~(0x10 << 4 * _ch_)
13441207
13451208static UINT32 scu_add_tmp;
13461209
13471210/*For area checking*/
1348#define ABUS(_lv_)       ((state->m_scu_src[_lv_] & 0x07ffffff) >= 0x02000000) && ((state->m_scu_src[_lv_] & 0x07ffffff) <= 0x04ffffff)
1211#define ABUS(_lv_)       ((state->m_scu.src[_lv_] & 0x07ffffff) >= 0x02000000) && ((state->m_scu.src[_lv_] & 0x07ffffff) <= 0x04ffffff)
13491212#define BBUS(_lv_)       ((scu_##_lv_ & 0x07ffffff) >= 0x05a00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05ffffff)
13501213#define VDP1_REGS(_lv_)  ((scu_##_lv_ & 0x07ffffff) >= 0x05d00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05dfffff)
13511214#define VDP2(_lv_)       ((scu_##_lv_ & 0x07ffffff) >= 0x05e00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05fdffff)
r11640r11641
14181281   switch(offset)
14191282   {
14201283      /*LV 0 DMA*/
1421      case 0:   case 8: case 16:  state->m_scu_src[DMA_CH]  = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break;
1422      case 1:   case 9: case 17:  state->m_scu_dst[DMA_CH]  = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break;
1423      case 2: case 10: case 18: state->m_scu_size[DMA_CH] = ((state->m_scu_regs[offset] & ((offset == 2) ? 0x000fffff : 0x1fff)) >> 0); break;
1284      case 0:   case 8: case 16:  state->m_scu.src[DMA_CH]  = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break;
1285      case 1:   case 9: case 17:  state->m_scu.dst[DMA_CH]  = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break;
1286      case 2: case 10: case 18: state->m_scu.size[DMA_CH] = ((state->m_scu_regs[offset] & ((offset == 2) ? 0x000fffff : 0x1fff)) >> 0); break;
14241287      case 3: case 11: case 19:
14251288         /*Read address add value for DMA lv 0*/
1426         state->m_scu_src_add[DMA_CH] = (state->m_scu_regs[offset] & 0x100) ? 4 : 1;
1289         state->m_scu.src_add[DMA_CH] = (state->m_scu_regs[offset] & 0x100) ? 4 : 1;
14271290
14281291         /*Write address add value for DMA lv 0*/
1429         state->m_scu_dst_add[DMA_CH] = 2 << (state->m_scu_regs[offset] & 7);
1292         state->m_scu.dst_add[DMA_CH] = 2 << (state->m_scu_regs[offset] & 7);
14301293         break;
14311294      case 4: case 12: case 20:
14321295/*
r11640r11641
14411304      if(state->m_scu_regs[offset] & 1 && ((state->m_scu_regs[offset+1] & 7) == 7) && state->m_scu_regs[offset] & 0x100)
14421305      {
14431306         if(DIRECT_MODE(DMA_CH)) { scu_dma_direct(space,DMA_CH);   }
1444         else                  { scu_dma_indirect(space,DMA_CH); }
1307         else                { scu_dma_indirect(space,DMA_CH); }
14451308
14461309         state->m_scu_regs[offset]&=~1;//disable starting bit.
14471310      }
r11640r11641
14501313      if(INDIRECT_MODE(DMA_CH))
14511314      {
14521315         if(LOG_SCU) logerror("Indirect Mode DMA lv %d set\n",DMA_CH);
1453         if(!DWUP(DMA_CH)) state->m_scu_index[DMA_CH] = state->m_scu_dst[DMA_CH];
1316         if(!DWUP(DMA_CH)) state->m_scu.index[DMA_CH] = state->m_scu.dst[DMA_CH];
14541317      }
14551318
14561319      /*Start factor enable bits,bit 2,bit 1 and bit 0*/
r11640r11641
15641427
15651428   cputag_set_input_line_and_vector(machine, "maincpu", 5, (stv_irq.dma_end[0]) ? HOLD_LINE : CLEAR_LINE, 0x4b);
15661429
1567   D0MV_0;
1430   DnMV_0(0);
15681431}
15691432
15701433/*Lv 1 DMA end irq*/
r11640r11641
15741437
15751438   cputag_set_input_line_and_vector(machine, "maincpu", 6, (stv_irq.dma_end[1]) ? HOLD_LINE : CLEAR_LINE, 0x4a);
15761439
1577   D1MV_0;
1440   DnMV_0(1);
15781441}
15791442
15801443/*Lv 2 DMA end irq*/
r11640r11641
15841447
15851448   cputag_set_input_line_and_vector(machine, "maincpu", 6, (stv_irq.dma_end[2]) ? HOLD_LINE : CLEAR_LINE, 0x49);
15861449
1587   D2MV_0;
1450   DnMV_0(2);
15881451}
15891452
15901453static void scu_dma_direct(address_space *space, UINT8 dma_ch)
15911454{
15921455   saturn_state *state = space->machine().driver_data<saturn_state>();
15931456   static UINT32 tmp_src,tmp_dst,tmp_size;
1594   if(LOG_SCU) logerror("DMA lv 0 transfer START\n"
1595                      "Start %08x End %08x Size %04x\n",state->m_scu_src[0],state->m_scu_dst[0],state->m_scu_size[0]);
1596   if(LOG_SCU) logerror("Start Add %04x Destination Add %04x\n",state->m_scu_src_add[0],state->m_scu_dst_add[0]);
15971457
1598   D0MV_1;
1458   if(LOG_SCU) printf("DMA lv %d transfer START\n"
1459                      "Start %08x End %08x Size %04x\n",dma_ch,state->m_scu.src[dma_ch],state->m_scu.dst[dma_ch],state->m_scu.size[dma_ch]);
1460   if(LOG_SCU) printf("Start Add %04x Destination Add %04x\n",state->m_scu.src_add[dma_ch],state->m_scu.dst_add[dma_ch]);
15991461
1462   DnMV_1(dma_ch);
1463
16001464   /* max size */
1601   if(state->m_scu_size[dma_ch] == 0) { state->m_scu_size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; }
1465   if(state->m_scu.size[dma_ch] == 0) { state->m_scu.size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; }
16021466
16031467   /*set here the boundaries checks*/
16041468   /*...*/
16051469
1606   if((state->m_scu_dst_add[dma_ch] != state->m_scu_src_add[dma_ch]) && (ABUS(dma_ch)))
1470   if((state->m_scu.dst_add[dma_ch] != state->m_scu.src_add[dma_ch]) && (ABUS(dma_ch)))
16071471   {
16081472      logerror("A-Bus invalid transfer,sets to default\n");
1609      scu_add_tmp = (state->m_scu_dst_add[dma_ch]*0x100) | (state->m_scu_src_add[dma_ch]);
1610      state->m_scu_dst_add[dma_ch] = state->m_scu_src_add[dma_ch] = 4;
1473      scu_add_tmp = (state->m_scu.dst_add[dma_ch]*0x100) | (state->m_scu.src_add[dma_ch]);
1474      state->m_scu.dst_add[dma_ch] = state->m_scu.src_add[dma_ch] = 4;
16111475      scu_add_tmp |= 0x80000000;
16121476   }
16131477
r11640r11641
16371501   if(VDP1_REGS(dst_0))
16381502   {
16391503      logerror("VDP1 register access,must be in word units\n");
1640      scu_add_tmp = (state->m_scu_dst_add[0]*0x100) | (state->m_scu_src_add[0]);
1641      state->m_scu_dst_add[0] = state->m_scu_src_add[0] = 2;
1504      scu_add_tmp = (state->m_scu.dst_add[0]*0x100) | (state->m_scu.src_add[0]);
1505      state->m_scu.dst_add[0] = state->m_scu.src_add[0] = 2;
16421506      scu_add_tmp |= 0x80000000;
16431507   }
16441508   if(DRUP(0))
16451509   {
16461510      logerror("Data read update = 1,read address add value must be 1 too\n");
1647      scu_add_tmp = (state->m_scu_dst_add[0]*0x100) | (state->m_scu_src_add[0]);
1648      state->m_scu_src_add[0] = 4;
1511      scu_add_tmp = (state->m_scu.dst_add[0]*0x100) | (state->m_scu.src_add[0]);
1512      state->m_scu.src_add[0] = 4;
16491513      scu_add_tmp |= 0x80000000;
16501514   }
16511515
1652   if (WORK_RAM_H(dst_0) && (state->m_scu_dst_add[0] != 4))
1516   if (WORK_RAM_H(dst_0) && (state->m_scu.dst_add[0] != 4))
16531517   {
1654      scu_add_tmp = (state->m_scu_dst_add[0]*0x100) | (state->m_scu_src_add[0]);
1655      state->m_scu_dst_add[0] = 4;
1518      scu_add_tmp = (state->m_scu.dst_add[0]*0x100) | (state->m_scu.src_add[0]);
1519      state->m_scu.dst_add[0] = 4;
16561520      scu_add_tmp |= 0x80000000;
16571521   }
16581522   #endif
16591523
1660   tmp_size = state->m_scu_size[dma_ch];
1661   if(!(DRUP(dma_ch))) tmp_src = state->m_scu_src[dma_ch];
1662   if(!(DWUP(dma_ch))) tmp_dst = state->m_scu_dst[dma_ch];
1524   tmp_size = state->m_scu.size[dma_ch];
1525   if(!(DRUP(dma_ch))) tmp_src = state->m_scu.src[dma_ch];
1526   if(!(DWUP(dma_ch))) tmp_dst = state->m_scu.dst[dma_ch];
16631527
1664   for (; state->m_scu_size[dma_ch] > 0; state->m_scu_size[dma_ch]-=state->m_scu_dst_add[dma_ch])
1528   for (; state->m_scu.size[dma_ch] > 0; state->m_scu.size[dma_ch]-=state->m_scu.dst_add[dma_ch])
16651529   {
1666      if(state->m_scu_dst_add[dma_ch] == 2)
1667         space->write_word(state->m_scu_dst[dma_ch],space->read_word(state->m_scu_src[dma_ch]));
1668      else if(state->m_scu_dst_add[dma_ch] == 8)
1530      if(state->m_scu.dst_add[dma_ch] == 2)
1531         space->write_word(state->m_scu.dst[dma_ch],space->read_word(state->m_scu.src[dma_ch]));
1532      else if(state->m_scu.dst_add[dma_ch] == 8)
16691533      {
1670         space->write_word(state->m_scu_dst[dma_ch],  space->read_word(state->m_scu_src[dma_ch]  ));
1671         space->write_word(state->m_scu_dst[dma_ch]+2,space->read_word(state->m_scu_src[dma_ch]  ));
1672         space->write_word(state->m_scu_dst[dma_ch]+4,space->read_word(state->m_scu_src[dma_ch]+2));
1673         space->write_word(state->m_scu_dst[dma_ch]+6,space->read_word(state->m_scu_src[dma_ch]+2));
1534         space->write_word(state->m_scu.dst[dma_ch],  space->read_word(state->m_scu.src[dma_ch]  ));
1535         space->write_word(state->m_scu.dst[dma_ch]+2,space->read_word(state->m_scu.src[dma_ch]  ));
1536         space->write_word(state->m_scu.dst[dma_ch]+4,space->read_word(state->m_scu.src[dma_ch]+2));
1537         space->write_word(state->m_scu.dst[dma_ch]+6,space->read_word(state->m_scu.src[dma_ch]+2));
16741538      }
16751539      else
16761540      {
1677         space->write_word(state->m_scu_dst[dma_ch],  space->read_word(state->m_scu_src[dma_ch]  ));
1678         space->write_word(state->m_scu_dst[dma_ch]+2,space->read_word(state->m_scu_src[dma_ch]+2));
1541         space->write_word(state->m_scu.dst[dma_ch],  space->read_word(state->m_scu.src[dma_ch]  ));
1542         space->write_word(state->m_scu.dst[dma_ch]+2,space->read_word(state->m_scu.src[dma_ch]+2));
16791543      }
16801544
1681      state->m_scu_dst[dma_ch]+=state->m_scu_dst_add[dma_ch];
1682      state->m_scu_src[dma_ch]+=state->m_scu_src_add[dma_ch];
1545      state->m_scu.dst[dma_ch]+=state->m_scu.dst_add[dma_ch];
1546      state->m_scu.src[dma_ch]+=state->m_scu.src_add[dma_ch];
16831547   }
16841548
1685   state->m_scu_size[dma_ch] = tmp_size;
1686   if(!(DRUP(dma_ch))) state->m_scu_src[dma_ch] = tmp_src;
1687   if(!(DWUP(dma_ch))) state->m_scu_dst[dma_ch] = tmp_dst;
1549   state->m_scu.size[dma_ch] = tmp_size;
1550   if(!(DRUP(dma_ch))) state->m_scu.src[dma_ch] = tmp_src;
1551   if(!(DWUP(dma_ch))) state->m_scu.dst[dma_ch] = tmp_dst;
16881552
1553   if(dma_ch != 2)
16891554   if(LOG_SCU) logerror("DMA transfer END\n");
16901555
16911556   /*TODO: timing of this, clean up */
r11640r11641
16981563
16991564   if(scu_add_tmp & 0x80000000)
17001565   {
1701      state->m_scu_dst_add[dma_ch] = (scu_add_tmp & 0xff00) >> 8;
1702      state->m_scu_src_add[dma_ch] = (scu_add_tmp & 0x00ff) >> 0;
1566      state->m_scu.dst_add[dma_ch] = (scu_add_tmp & 0xff00) >> 8;
1567      state->m_scu.src_add[dma_ch] = (scu_add_tmp & 0x00ff) >> 0;
17031568      scu_add_tmp^=0x80000000;
17041569   }
17051570}
r11640r11641
17131578   /*temporary storage for the transfer data*/
17141579   UINT32 tmp_src;
17151580
1716   D0MV_1;
1581   DnMV_1(dma_ch);
17171582
1718   if(state->m_scu_index[dma_ch] == 0) { state->m_scu_index[dma_ch] = state->m_scu_dst[0]; }
1583   if(state->m_scu.index[dma_ch] == 0) { state->m_scu.index[dma_ch] = state->m_scu.dst[0]; }
17191584
17201585   do{
1721      tmp_src = state->m_scu_index[dma_ch];
1586      tmp_src = state->m_scu.index[dma_ch];
17221587
1723      state->m_scu_size[dma_ch] = space->read_dword(state->m_scu_index[dma_ch]);
1724      state->m_scu_src[dma_ch]  = space->read_dword(state->m_scu_index[dma_ch]+8);
1725      state->m_scu_dst[dma_ch]  = space->read_dword(state->m_scu_index[dma_ch]+4);
1588      state->m_scu.size[dma_ch] = space->read_dword(state->m_scu.index[dma_ch]);
1589      state->m_scu.src[dma_ch]  = space->read_dword(state->m_scu.index[dma_ch]+8);
1590      state->m_scu.dst[dma_ch]  = space->read_dword(state->m_scu.index[dma_ch]+4);
17261591
17271592      /*Indirect Mode end factor*/
1728      if(state->m_scu_src[dma_ch] & 0x80000000)
1593      if(state->m_scu.src[dma_ch] & 0x80000000)
17291594         job_done = 1;
17301595
17311596      #if 0
r11640r11641
17361601      }
17371602      #endif
17381603
1739      if(LOG_SCU) logerror("DMA lv %d indirect mode transfer START\n"
1740                         "Start %08x End %08x Size %04x\n",dma_ch,state->m_scu_src[dma_ch],state->m_scu_dst[dma_ch],state->m_scu_size[dma_ch]);
1741      if(LOG_SCU) logerror("Start Add %04x Destination Add %04x\n",state->m_scu_src_add[dma_ch],state->m_scu_dst_add[dma_ch]);
1604      if(LOG_SCU) printf("DMA lv %d indirect mode transfer START\n"
1605                         "Start %08x End %08x Size %04x\n",dma_ch,state->m_scu.src[dma_ch],state->m_scu.dst[dma_ch],state->m_scu.size[dma_ch]);
1606      if(LOG_SCU) printf("Start Add %04x Destination Add %04x\n",state->m_scu.src_add[dma_ch],state->m_scu.dst_add[dma_ch]);
17421607
17431608      //guess,but I believe it's right.
1744      state->m_scu_src[dma_ch] &=0x07ffffff;
1745      state->m_scu_dst[dma_ch] &=0x07ffffff;
1746      state->m_scu_size[dma_ch] &= ((dma_ch == 0) ? 0xfffff : 0x1fff);
1609      state->m_scu.src[dma_ch] &=0x07ffffff;
1610      state->m_scu.dst[dma_ch] &=0x07ffffff;
1611      state->m_scu.size[dma_ch] &= ((dma_ch == 0) ? 0xfffff : 0x1fff);
17471612
1748      if(state->m_scu_size[dma_ch] == 0) { state->m_scu_size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; }
1613      if(state->m_scu.size[dma_ch] == 0) { state->m_scu.size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; }
17491614
1750      for (; state->m_scu_size[dma_ch] > 0; state->m_scu_size[dma_ch]-=state->m_scu_dst_add[dma_ch])
1615      for (; state->m_scu.size[dma_ch] > 0; state->m_scu.size[dma_ch]-=state->m_scu.dst_add[dma_ch])
17511616      {
1752         if(state->m_scu_dst_add[dma_ch] == 2)
1753            space->write_word(state->m_scu_dst[dma_ch],space->read_word(state->m_scu_src[dma_ch]));
1617         if(state->m_scu.dst_add[dma_ch] == 2)
1618            space->write_word(state->m_scu.dst[dma_ch],space->read_word(state->m_scu.src[dma_ch]));
17541619         else
17551620         {
17561621            /* some games, eg columns97 are a bit weird, I'm not sure this is correct
r11640r11641
17581623                  can't access 2 byte boundaries, and the end of the sprite list never gets marked,
17591624                  the length of the transfer is also set to a 2 byte boundary, maybe the add values
17601625                  should be different, I don't know */
1761            space->write_word(state->m_scu_dst[dma_ch],space->read_word(state->m_scu_src[dma_ch]));
1762            space->write_word(state->m_scu_dst[dma_ch]+2,space->read_word(state->m_scu_src[dma_ch]+2));
1626            space->write_word(state->m_scu.dst[dma_ch],space->read_word(state->m_scu.src[dma_ch]));
1627            space->write_word(state->m_scu.dst[dma_ch]+2,space->read_word(state->m_scu.src[dma_ch]+2));
17631628         }
1764         state->m_scu_dst[dma_ch]+=state->m_scu_dst_add[dma_ch];
1765         state->m_scu_src[dma_ch]+=state->m_scu_src_add[dma_ch];
1629         state->m_scu.dst[dma_ch]+=state->m_scu.dst_add[dma_ch];
1630         state->m_scu.src[dma_ch]+=state->m_scu.src_add[dma_ch];
17661631      }
17671632
1768      //if(DRUP(0))   space->write_dword(tmp_src+8,state->m_scu_src[0]|job_done ? 0x80000000 : 0);
1769      //if(DWUP(0)) space->write_dword(tmp_src+4,state->m_scu_dst[0]);
1633      //if(DRUP(0))   space->write_dword(tmp_src+8,state->m_scu.src[0]|job_done ? 0x80000000 : 0);
1634      //if(DWUP(0)) space->write_dword(tmp_src+4,state->m_scu.dst[0]);
17701635
1771      state->m_scu_index[dma_ch] = tmp_src+0xc;
1636      state->m_scu.index[dma_ch] = tmp_src+0xc;
17721637
17731638   }while(job_done == 0);
17741639
17751640   /*TODO: timing of this, clean up */
17761641   switch(dma_ch)
17771642   {
1778      case 0: space->machine().scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv0_ended)); break;
1779      case 1: space->machine().scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv1_ended)); break;
1780      case 2: space->machine().scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv2_ended)); break;
1643      case 0: space->machine().scheduler().timer_set(attotime::from_usec(3000), FUNC(dma_lv0_ended)); break;
1644      case 1: space->machine().scheduler().timer_set(attotime::from_usec(3000), FUNC(dma_lv1_ended)); break;
1645      case 2: space->machine().scheduler().timer_set(attotime::from_usec(3000), FUNC(dma_lv2_ended)); break;
17811646   }
17821647}
17831648
r11640r11641
18051670/* communication,SLAVE CPU acquires data from the MASTER CPU and triggers an irq.  */
18061671static WRITE32_HANDLER( minit_w )
18071672{
1808   logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data);
1809   space->machine().scheduler().boost_interleave(minit_boost_timeslice, attotime::from_usec(minit_boost));
1673   saturn_state *state = space->machine().driver_data<saturn_state>();
1674
1675   //logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data);
1676   space->machine().scheduler().boost_interleave(state->m_minit_boost_timeslice, attotime::from_usec(state->m_minit_boost));
18101677   space->machine().scheduler().trigger(1000);
1811   sh2_set_frt_input(space->machine().device("slave"), PULSE_LINE);
1678   sh2_set_frt_input(state->m_slave, PULSE_LINE);
18121679}
18131680
18141681static WRITE32_HANDLER( sinit_w )
18151682{
1816   logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data);
1817   space->machine().scheduler().boost_interleave(sinit_boost_timeslice, attotime::from_usec(sinit_boost));
1818   sh2_set_frt_input(space->machine().device("maincpu"), PULSE_LINE);
1683   saturn_state *state = space->machine().driver_data<saturn_state>();
1684
1685   //logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data);
1686   space->machine().scheduler().boost_interleave(state->m_sinit_boost_timeslice, attotime::from_usec(state->m_sinit_boost));
1687   sh2_set_frt_input(state->m_maincpu, PULSE_LINE);
18191688}
18201689
1821static READ32_HANDLER(saturn_m_backupram_r)
1690static READ32_HANDLER(saturn_backupram_r)
18221691{
18231692   saturn_state *state = space->machine().driver_data<saturn_state>();
18241693
18251694   return state->m_backupram[offset] & 0x00ff00ff;   // yes, it makes sure the "holes" are there.
18261695}
18271696
1828static WRITE32_HANDLER(saturn_m_backupram_w)
1697static WRITE32_HANDLER(saturn_backupram_w)
18291698{
18301699   saturn_state *state = space->machine().driver_data<saturn_state>();
18311700
r11640r11641
18671736static ADDRESS_MAP_START( saturn_mem, AS_PROGRAM, 32 )
18681737   AM_RANGE(0x00000000, 0x0007ffff) AM_ROM AM_SHARE("share6")  // bios
18691738   AM_RANGE(0x00100000, 0x0010007f) AM_READWRITE8(saturn_SMPC_r8, saturn_SMPC_w8,0xffffffff)
1870   AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_m_backupram_r, saturn_m_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram)
1739   AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_backupram_r, saturn_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram)
18711740   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_MIRROR(0x100000) AM_SHARE("share2") AM_BASE_MEMBER(saturn_state,m_workram_l)
18721741   AM_RANGE(0x01000000, 0x01000003) AM_MIRROR(0x7ffffc) AM_WRITE(minit_w)
18731742   AM_RANGE(0x01800000, 0x01800003) AM_MIRROR(0x7ffffc) AM_WRITE(sinit_w)
r11640r11641
18771746   AM_RANGE(0x05a00000, 0x05a7ffff) AM_READWRITE16(saturn_soundram_r, saturn_soundram_w,0xffffffff)
18781747   AM_RANGE(0x05b00000, 0x05b00fff) AM_DEVREADWRITE16("scsp", scsp_r, scsp_w, 0xffffffff)
18791748   /* VDP1 */
1880   /*0x05c00000-0x05c7ffff VRAM*/
1881   /*0x05c80000-0x05c9ffff Frame Buffer 0*/
1882   /*0x05ca0000-0x05cbffff Frame Buffer 1*/
1883   /*0x05d00000-0x05d7ffff VDP1 Regs */
1884   AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(stv_vdp1_vram_r, stv_vdp1_vram_w)
1885   AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(stv_vdp1_framebuffer0_r, stv_vdp1_framebuffer0_w)
1886   AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(stv_vdp1_regs_r, stv_vdp1_regs_w)
1887   AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(stv_vdp2_vram_r, stv_vdp2_vram_w)
1888   AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(stv_vdp2_cram_r, stv_vdp2_cram_w)
1889   AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(stv_vdp2_regs_r, stv_vdp2_regs_w)
1749   AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(saturn_vdp1_vram_r, saturn_vdp1_vram_w)
1750   AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(saturn_vdp1_framebuffer0_r, saturn_vdp1_framebuffer0_w)
1751   AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(saturn_vdp1_regs_r, saturn_vdp1_regs_w)
1752   AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(saturn_vdp2_vram_r, saturn_vdp2_vram_w)
1753   AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(saturn_vdp2_cram_r, saturn_vdp2_cram_w)
1754   AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(saturn_vdp2_regs_r, saturn_vdp2_regs_w)
18901755   AM_RANGE(0x05fe0000, 0x05fe00cf) AM_READWRITE(saturn_scu_r, saturn_scu_w)
18911756   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_MIRROR(0x01f00000) AM_SHARE("share3") AM_BASE_MEMBER(saturn_state,m_workram_h)
18921757   AM_RANGE(0x20000000, 0x2007ffff) AM_ROM AM_SHARE("share6")  // bios mirror
r11640r11641
18961761static ADDRESS_MAP_START( stv_mem, AS_PROGRAM, 32 )
18971762   AM_RANGE(0x00000000, 0x0007ffff) AM_ROM AM_SHARE("share6")  // bios
18981763   AM_RANGE(0x00100000, 0x0010007f) AM_READWRITE8(stv_SMPC_r8, stv_SMPC_w8,0xffffffff)
1899   AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_m_backupram_r,saturn_m_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram)
1764   AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_backupram_r,saturn_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram)
19001765   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_MIRROR(0x100000) AM_SHARE("share2") AM_BASE_MEMBER(saturn_state,m_workram_l)
1901   AM_RANGE(0x00400000, 0x0040001f) AM_READWRITE(stv_io_r32, stv_io_w32) AM_BASE(&ioga) AM_SHARE("share4") AM_MIRROR(0x20)
1766   AM_RANGE(0x00400000, 0x0040001f) AM_READWRITE(stv_io_r32, stv_io_w32) AM_BASE_MEMBER(saturn_state,m_ioga) AM_SHARE("share4") AM_MIRROR(0x20)
19021767   AM_RANGE(0x01000000, 0x01000003) AM_MIRROR(0x7ffffc) AM_WRITE(minit_w)
19031768   AM_RANGE(0x01800000, 0x01800003) AM_MIRROR(0x7ffffc) AM_WRITE(sinit_w)
19041769   AM_RANGE(0x02000000, 0x04ffffff) AM_ROM AM_SHARE("share7") AM_REGION("abus", 0) // cartridge
r11640r11641
19071772   AM_RANGE(0x05a00000, 0x05afffff) AM_READWRITE16(saturn_soundram_r, saturn_soundram_w,0xffffffff)
19081773   AM_RANGE(0x05b00000, 0x05b00fff) AM_DEVREADWRITE16("scsp", scsp_r, scsp_w, 0xffffffff)
19091774   /* VDP1 */
1910   AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(stv_vdp1_vram_r, stv_vdp1_vram_w)
1911   AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(stv_vdp1_framebuffer0_r, stv_vdp1_framebuffer0_w)
1912   AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(stv_vdp1_regs_r, stv_vdp1_regs_w)
1913   AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(stv_vdp2_vram_r, stv_vdp2_vram_w)
1914   AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(stv_vdp2_cram_r, stv_vdp2_cram_w)
1915   AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(stv_vdp2_regs_r, stv_vdp2_regs_w)
1775   AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(saturn_vdp1_vram_r, saturn_vdp1_vram_w)
1776   AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(saturn_vdp1_framebuffer0_r, saturn_vdp1_framebuffer0_w)
1777   AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(saturn_vdp1_regs_r, saturn_vdp1_regs_w)
1778   AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(saturn_vdp2_vram_r, saturn_vdp2_vram_w)
1779   AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(saturn_vdp2_cram_r, saturn_vdp2_cram_w)
1780   AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(saturn_vdp2_regs_r, saturn_vdp2_regs_w)
19161781   AM_RANGE(0x05fe0000, 0x05fe00cf) AM_READWRITE(saturn_scu_r, saturn_scu_w)
19171782   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_MIRROR(0x01f00000) AM_SHARE("share3") AM_BASE_MEMBER(saturn_state,m_workram_h)
19181783   AM_RANGE(0x20000000, 0x2007ffff) AM_ROM AM_SHARE("share6")  // bios mirror
r11640r11641
23002165   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
23012166INPUT_PORTS_END
23022167
2168#ifdef UNUSED_FUNCTION
23032169static WRITE32_HANDLER ( w60ffc44_write )
23042170{
23052171   saturn_state *state = space->machine().driver_data<saturn_state>();
r11640r11641
23192185   logerror("cpu %s (PC=%08X): 60ffc48_write write = %08X & %08X\n", space->device().tag(), cpu_get_pc(&space->device()), data, mem_mask);
23202186   //minit_w(offset,data,mem_mask);
23212187}
2188#endif
23222189
23232190#ifdef UNUSED_FUNCTION
23242191static void print_game_info(void);
r11640r11641
23322199   machine.base_datetime(systime);
23332200
23342201   /* amount of time to boost interleave for on MINIT / SINIT, needed for communication to work */
2335   minit_boost = 400;
2336   sinit_boost = 400;
2337   minit_boost_timeslice = attotime::zero;
2338   sinit_boost_timeslice = attotime::zero;
2202   state->m_minit_boost = 400;
2203   state->m_sinit_boost = 400;
2204   state->m_minit_boost_timeslice = attotime::zero;
2205   state->m_sinit_boost_timeslice = attotime::zero;
23392206
23402207   state->m_smpc_ram = auto_alloc_array(machine, UINT8, 0x80);
23412208   state->m_scu_regs = auto_alloc_array(machine, UINT32, 0x100/4);
2342   scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2);
2209   state->m_scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2);
23432210
23442211   install_stvbios_speedups(machine);
23452212
r11640r11641
23502217   sh2drc_set_options(machine.device("slave"), SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL);
23512218
23522219   /* debug .. watch the command buffer rsgun, cottonbm etc. appear to use to communicate between cpus */
2353   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) );
2354   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) );
2355   machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) );
2356   machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) );
2220   //machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) );
2221   //machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) );
2222   //machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) );
2223   //machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) );
23572224
23582225    state->m_smpc_ram[0x31] = 0x00; //CTG1=0 CTG0=0 (correct??)
23592226//  state->m_smpc_ram[0x33] = input_port_read(machine, "FAKE");
r11640r11641
25312398   state->m_smpc_ram[0x2f]++;
25322399
25332400   /* seconds from 9 -> 10*/
2534   if((state->m_smpc_ram[0x2f] & 0x0f) >= 0x0a)          { state->m_smpc_ram[0x2f]+=0x10; state->m_smpc_ram[0x2f]&=0xf0; }
2401   if((state->m_smpc_ram[0x2f] & 0x0f) >= 0x0a)         { state->m_smpc_ram[0x2f]+=0x10; state->m_smpc_ram[0x2f]&=0xf0; }
25352402   /* seconds from 59 -> 0 */
2536   if((state->m_smpc_ram[0x2f] & 0xf0) >= 0x60)          { state->m_smpc_ram[0x2d]++;     state->m_smpc_ram[0x2f] = 0; }
2403   if((state->m_smpc_ram[0x2f] & 0xf0) >= 0x60)         { state->m_smpc_ram[0x2d]++;     state->m_smpc_ram[0x2f] = 0; }
25372404   /* minutes from 9 -> 10 */
2538   if((state->m_smpc_ram[0x2d] & 0x0f) >= 0x0a)          { state->m_smpc_ram[0x2d]+=0x10; state->m_smpc_ram[0x2d]&=0xf0; }
2405   if((state->m_smpc_ram[0x2d] & 0x0f) >= 0x0a)         { state->m_smpc_ram[0x2d]+=0x10; state->m_smpc_ram[0x2d]&=0xf0; }
25392406   /* minutes from 59 -> 0 */
2540   if((state->m_smpc_ram[0x2d] & 0xf0) >= 0x60)          { state->m_smpc_ram[0x2b]++;     state->m_smpc_ram[0x2d] = 0; }
2407   if((state->m_smpc_ram[0x2d] & 0xf0) >= 0x60)         { state->m_smpc_ram[0x2b]++;     state->m_smpc_ram[0x2d] = 0; }
25412408   /* hours from 9 -> 10 */
2542   if((state->m_smpc_ram[0x2b] & 0x0f) >= 0x0a)          { state->m_smpc_ram[0x2b]+=0x10; state->m_smpc_ram[0x2b]&=0xf0; }
2409   if((state->m_smpc_ram[0x2b] & 0x0f) >= 0x0a)         { state->m_smpc_ram[0x2b]+=0x10; state->m_smpc_ram[0x2b]&=0xf0; }
25432410   /* hours from 23 -> 0 */
25442411   if((state->m_smpc_ram[0x2b] & 0xff) >= 0x24)            { state->m_smpc_ram[0x29]++; state->m_smpc_ram[0x27]+=0x10; state->m_smpc_ram[0x2b] = 0; }
25452412   /* week day name sunday -> monday */
r11640r11641
25972464   // save states
25982465   state_save_register_global_pointer(machine, state->m_smpc_ram, 0x80);
25992466   state_save_register_global_pointer(machine, state->m_scu_regs, 0x100/4);
2600   state_save_register_global_pointer(machine, scsp_regs, 0x1000/2);
2601//  state_save_register_global(machine, stv_vblank);
2602//  state_save_register_global(machine, stv_hblank);
2467   state_save_register_global_pointer(machine, state->m_scsp_regs,  0x1000/2);
26032468   state_save_register_global(machine, state->m_NMI_reset);
26042469   state_save_register_global(machine, state->m_en_68k);
26052470   state_save_register_global(machine, timer_0);
26062471   state_save_register_global(machine, timer_1);
26072472//  state_save_register_global(machine, scanline);
2608   state_save_register_global(machine, IOSEL1);
2609   state_save_register_global(machine, IOSEL2);
2610   state_save_register_global(machine, EXLE1);
2611   state_save_register_global(machine, EXLE2);
2612   state_save_register_global(machine, PDR1);
2613   state_save_register_global(machine, PDR2);
2473   state_save_register_global(machine, state->m_smpc.IOSEL1);
2474   state_save_register_global(machine, state->m_smpc.IOSEL2);
2475   state_save_register_global(machine, state->m_smpc.EXLE1);
2476   state_save_register_global(machine, state->m_smpc.EXLE2);
2477   state_save_register_global(machine, state->m_smpc.PDR1);
2478   state_save_register_global(machine, state->m_smpc.PDR2);
26142479   state_save_register_global(machine, port_sel);
26152480   state_save_register_global(machine, mux_data);
26162481   state_save_register_global(machine, scsp_last_line);
r11640r11641
26272492    state->m_smpc_ram[0x2d] = DectoBCD(systime.local_time.minute);
26282493    state->m_smpc_ram[0x2f] = DectoBCD(systime.local_time.second);
26292494
2630   stv_rtc_timer = machine.scheduler().timer_alloc(FUNC(stv_rtc_increment));
2495   state->m_stv_rtc_timer = machine.scheduler().timer_alloc(FUNC(stv_rtc_increment));
26312496}
26322497
26332498
r11640r11641
26392504   // save states
26402505   state_save_register_global_pointer(machine, state->m_smpc_ram, 0x80);
26412506   state_save_register_global_pointer(machine, state->m_scu_regs, 0x100/4);
2642   state_save_register_global_pointer(machine, scsp_regs, 0x1000/2);
2643   state_save_register_global(machine, stv_vblank);
2644   state_save_register_global(machine, stv_hblank);
2507   state_save_register_global_pointer(machine, state->m_scsp_regs,  0x1000/2);
26452508   state_save_register_global(machine, state->m_NMI_reset);
26462509   state_save_register_global(machine, state->m_en_68k);
26472510   state_save_register_global(machine, timer_0);
26482511   state_save_register_global(machine, timer_1);
2649   state_save_register_global(machine, IOSEL1);
2650   state_save_register_global(machine, IOSEL2);
2651   state_save_register_global(machine, EXLE1);
2652   state_save_register_global(machine, EXLE2);
2653   state_save_register_global(machine, PDR1);
2654   state_save_register_global(machine, PDR2);
2512   state_save_register_global(machine, state->m_smpc.IOSEL1);
2513   state_save_register_global(machine, state->m_smpc.IOSEL2);
2514   state_save_register_global(machine, state->m_smpc.EXLE1);
2515   state_save_register_global(machine, state->m_smpc.EXLE2);
2516   state_save_register_global(machine, state->m_smpc.PDR1);
2517   state_save_register_global(machine, state->m_smpc.PDR2);
26552518//  state_save_register_global(machine, port_sel);
26562519//  state_save_register_global(machine, mux_data);
26572520   state_save_register_global(machine, scsp_last_line);
2658   state_save_register_global(machine, intback_stage);
2659   state_save_register_global(machine, pmode);
2660   state_save_register_global(machine, smpcSR);
2661   state_save_register_global_array(machine, SMEM);
2521   state_save_register_global(machine, state->m_smpc.intback_stage);
2522   state_save_register_global(machine, state->m_smpc.pmode);
2523   state_save_register_global(machine, state->m_smpc.smpcSR);
2524   state_save_register_global_array(machine, state->m_smpc.SMEM);
26622525
26632526   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stvcd_exit), &machine));
26642527}
r11640r11641
28572720   cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, ASSERT_LINE);
28582721   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
28592722
2860   smpcSR = 0x40;   // this bit is always on according to docs
2723   state->m_smpc.smpcSR = 0x40;   // this bit is always on according to docs
28612724
28622725   timer_0 = 0;
28632726   timer_1 = 0;
r11640r11641
29152778   vblank_out_timer->adjust(machine.primary_screen->time_until_pos(0));
29162779   scan_timer->adjust(machine.primary_screen->time_until_pos(224, 352));
29172780
2918   stv_rtc_timer->adjust(attotime::zero, 0, attotime::from_seconds(1));
2781   state->m_stv_rtc_timer->adjust(attotime::zero, 0, attotime::from_seconds(1));
29192782   state->m_prev_bankswitch = 0xff;
29202783}
29212784
r11640r11641
30362899
30372900static DEVICE_IMAGE_LOAD( stv_cart )
30382901{
3039//   saturn_state *state = image.device().machine().driver_data<saturn_state>();
2902//  saturn_state *state = image.device().machine().driver_data<saturn_state>();
30402903   const struct stv_cart_region *stv_cart = &stv_cart_table[0], *this_cart;
3041   //const char   *pcb_name;
2904   //const char    *pcb_name;
30422905
30432906   /* First, determine where this cart has to be loaded */
30442907   while (stv_cart->tag)
r11640r11641
30782941   }
30792942
30802943   //if ((pcb_name = image.get_feature("pcb_type")) == NULL)
3081   //   return IMAGE_INIT_FAIL;
2944   //  return IMAGE_INIT_FAIL;
30822945
30832946   return IMAGE_INIT_PASS;
30842947}
r11640r11641
31082971   saturn_state *state = machine.driver_data<saturn_state>();
31092972   system_time systime;
31102973
3111   saturn_region = rgn;
2974   state->saturn_region = rgn;
31122975
31132976   // set compatible options
31142977   sh2drc_set_options(machine.device("maincpu"), SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL);
r11640r11641
31182981   machine.current_datetime(systime);
31192982
31202983   /* amount of time to boost interleave for on MINIT / SINIT, needed for communication to work */
3121   minit_boost = 400;
3122   sinit_boost = 400;
3123   minit_boost_timeslice = attotime::zero;
3124   sinit_boost_timeslice = attotime::zero;
2984   state->m_minit_boost = 400;
2985   state->m_sinit_boost = 400;
2986   state->m_minit_boost_timeslice = attotime::zero;
2987   state->m_sinit_boost_timeslice = attotime::zero;
31252988
31262989   state->m_smpc_ram = auto_alloc_array(machine, UINT8, 0x80);
31272990   state->m_scu_regs = auto_alloc_array(machine, UINT32, 0x100/4);
3128   scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2);
2991   state->m_scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2);
31292992
31302993   state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100);
31312994   state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100);
r11640r11641
32813144   ROM_REGION32_BE( 0x3000000, "game2", ROMREGION_ERASE00 )
32823145
32833146   ROM_REGION32_BE( 0x3000000, "game3", ROMREGION_ERASE00 )
3147
3148   ROM_REGION16_BE( 0x80, "eeprom", 0 ) // preconfigured to multi cart mode
3149   ROM_LOAD( "stvbios.nv", 0x0000, 0x0080, CRC(15432ae2) SHA1(7d9364d546f3d3f839ec36be148076f8d26a65a6) )
32843150ROM_END
32853151
32863152/*
r11640r11641
330631720x2800000 - 0x2bfffff IC11
330731730x2c00000 - 0x2ffffff IC12
33083174
3309Update:Issue fixed,see stvhacks.c for more details (TODO: Clean-up that)
33103175*/
33113176
33123177
r11640r11641
44024267GAME( 1995, sandor,    stvbios, stv,      stv,      sandor,    ROT0,   "Sega",                    "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44034268GAME( 1997, thunt,     sandor,  stv,      stv,      thunt,     ROT0,   "Sega",                         "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44044269GAME( 1997, thuntk,    sandor,  stv,      stv,      sandor,    ROT0,   "Sega / Deniam",              "Puzzle & Action: BoMulEul Chajara (JUET 970125 V2.00K)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
4270GAME( 1995, smleague,  stvbios, stv,      stv,      smleague,   ROT0,   "Sega",                    "Super Major League (U 960108 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
4271GAME( 1995, finlarch,  smleague,stv,      stv,      finlarch,   ROT0,   "Sega",                    "Final Arch (J 950714 V1.001)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44054272GAME( 1996, sokyugrt,  stvbios, stv,      stv,      sokyugrt,   ROT0,   "Raizing / Eighting",         "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44064273GAME( 1995, suikoenb,  stvbios, stv,      stv,      suikoenb,   ROT0,   "Data East",                   "Suikoenbu / Outlaws of the Lost Dynasty (JUETL 950314 V2.001)", GAME_IMPERFECT_SOUND )
44074274GAME( 1996, vfkids,    stvbios, stv,      stv,      stv,       ROT0,   "Sega",                   "Virtua Fighter Kids (JUET 960319 V0.000)", GAME_IMPERFECT_SOUND )
r11640r11641
44114278/* Almost */
44124279GAME( 1997, vmahjong,  stvbios, stv,      stvmp,   stv,       ROT0,   "Micronet",                    "Virtual Mahjong (J 961214 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44134280GAME( 1998, twcup98,   stvbios, stv,      stv,      twcup98,   ROT0,   "Tecmo",                       "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING ) // player movement
4414GAME( 1995, smleague,  stvbios, stv,      stv,      smleague,   ROT0,   "Sega",                    "Super Major League (U 960108 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
4415GAME( 1995, finlarch,  smleague,stv,      stv,      finlarch,   ROT0,   "Sega",                    "Final Arch (J 950714 V1.001)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44164281GAME( 1998, elandore,  stvbios, stv,      stv,      elandore,   ROT0,   "Sai-Mate",                "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
44174282
44184283/* Unemulated printer device */
src/mame/drivers/jpmsys5.c
r11640r11641
4343   int m_touch_data_count;
4444   int m_touch_data[3];
4545   int m_touch_shift_cnt;
46   int m_lamp_strobe;
47   int m_mpxclk;
48   int m_muxram[255];
4649   UINT8 m_a0_acia_dcd;
4750   UINT8 m_a0_data_out;
4851   UINT8 m_a0_data_in;
r11640r11641
204207   return 0;
205208}
206209
210static void sys5_draw_lamps(jpmsys5_state *state)
211{
212   int i;
213   for (i = 0; i <8; i++)
214   {
215      output_set_lamp_value( (16*state->m_lamp_strobe)+i,  (state->m_muxram[(4*state->m_lamp_strobe)] & (1 << i)) !=0);
216      output_set_lamp_value((16*state->m_lamp_strobe)+i+8, (state->m_muxram[(4*state->m_lamp_strobe) +1 ] & (1 << i)) !=0);
217      output_set_indexed_value("sys5led",(8*state->m_lamp_strobe)+i,(state->m_muxram[(4*state->m_lamp_strobe) +2 ] & (1 << i)) !=0);
218   }
219}
207220
208221/****************************************
209222 *
r11640r11641
238251
239252static WRITE16_HANDLER( mux_w )
240253{
241   /* TODO: Lamps! */
254   jpmsys5_state *state = space->machine().driver_data<jpmsys5_state>();
255   state->m_muxram[offset]=data;
242256}
243257
244258static READ16_HANDLER( mux_r )
r11640r11641
467481   cputag_set_input_line(device->machine(), "maincpu", INT_6840PTM, state ? ASSERT_LINE : CLEAR_LINE);
468482}
469483
484static WRITE8_DEVICE_HANDLER(u26_o1_callback)
485{
486   jpmsys5_state *state = device->machine().driver_data<jpmsys5_state>();
487   if (state->m_mpxclk !=data)
488   {
489      if (!data) //falling edge
490      {
491         state->m_lamp_strobe++;
492         if (state->m_lamp_strobe >15)
493         {
494            state->m_lamp_strobe =0;
495         }
496      }
497      sys5_draw_lamps(state);
498   }
499   state->m_mpxclk = data;
500}
501
502
470503static const ptm6840_interface ptm_intf =
471504{
472505   1000000,
473506   { 0, 0, 0 },
474   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
507   { DEVCB_HANDLER(u26_o1_callback), DEVCB_NULL, DEVCB_NULL },
475508   DEVCB_LINE(ptm_irq)
476509};
477510
r11640r11641
700733GAME( 1994, monopoly, 0,        jpmsys5v, monopoly, 0, ROT0, "JPM", "Monopoly",         0 )
701734GAME( 1995, monoplcl, monopoly, jpmsys5v, monopoly, 0, ROT0, "JPM", "Monopoly Classic", 0 )
702735GAME( 1995, monopldx, 0,        jpmsys5v, monopoly, 0, ROT0, "JPM", "Monopoly Deluxe",  0 )
736
737//AWP Skeleton driver
738#include "video/awpvid.h"
739#include "machine/steppers.h"
740#include "machine/roc10937.h"
741
742static ADDRESS_MAP_START( 68000_awp_map, AS_PROGRAM, 16 )
743   AM_RANGE(0x000000, 0x01ffff) AM_ROM
744   AM_RANGE(0x01fffe, 0x01ffff) AM_WRITE(rombank_w)
745   AM_RANGE(0x020000, 0x03ffff) AM_ROMBANK("bank1")
746   AM_RANGE(0x040000, 0x043fff) AM_RAM AM_SHARE("nvram")
747   AM_RANGE(0x046000, 0x046001) AM_WRITENOP
748   AM_RANGE(0x046020, 0x046021) AM_DEVREADWRITE8_MODERN("acia6850_0", acia6850_device, status_read, control_write, 0xff)
749   AM_RANGE(0x046022, 0x046023) AM_DEVREADWRITE8_MODERN("acia6850_0", acia6850_device, data_read, data_write, 0xff)
750   AM_RANGE(0x046040, 0x04604f) AM_DEVREADWRITE8_MODERN("6840ptm", ptm6840_device, read, write, 0xff)
751   AM_RANGE(0x046060, 0x046061) AM_READ_PORT("DIRECT") AM_WRITENOP
752   AM_RANGE(0x046062, 0x046063) AM_WRITENOP
753   AM_RANGE(0x046064, 0x046065) AM_WRITENOP
754   AM_RANGE(0x046066, 0x046067) AM_WRITENOP
755   AM_RANGE(0x046080, 0x046081) AM_DEVREADWRITE8_MODERN("acia6850_1", acia6850_device, status_read, control_write, 0xff)
756   AM_RANGE(0x046082, 0x046083) AM_DEVREADWRITE8_MODERN("acia6850_1", acia6850_device, data_read, data_write, 0xff)
757   AM_RANGE(0x046084, 0x046085) AM_READ(unk_r) // PIA?
758   AM_RANGE(0x046088, 0x046089) AM_READ(unk_r) // PIA?
759   AM_RANGE(0x04608c, 0x04608d) AM_DEVREADWRITE8_MODERN("acia6850_2", acia6850_device, status_read, control_write, 0xff)
760   AM_RANGE(0x04608e, 0x04608f) AM_DEVREADWRITE8_MODERN("acia6850_2", acia6850_device, data_read, data_write, 0xff)
761   AM_RANGE(0x0460a0, 0x0460a3) AM_DEVWRITE8("ym2413", ym2413_w, 0x00ff)
762   AM_RANGE(0x0460c0, 0x0460c1) AM_WRITENOP
763   AM_RANGE(0x048000, 0x04801f) AM_READWRITE(coins_r, coins_w)
764   AM_RANGE(0x04c000, 0x04c0ff) AM_READ(mux_r) AM_WRITE(mux_w)
765   AM_RANGE(0x04c100, 0x04c105) AM_DEVREADWRITE("upd7759", jpm_upd7759_r, jpm_upd7759_w)
766ADDRESS_MAP_END
767
768/*************************************
769 *
770 *  Port definitions
771 *
772 *************************************/
773
774static INPUT_PORTS_START( popeye )
775   PORT_START("DSW")
776   PORT_DIPNAME( 0x01, 0x01, "Change state to enter test" ) PORT_DIPLOCATION("SW2:1")
777   PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
778   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
779   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:2")
780   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
781   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
782   PORT_DIPNAME( 0x04, 0x04, "Alarm" ) PORT_DIPLOCATION("SW2:3")
783   PORT_DIPSETTING(   0x04, "Discontinue alarm when jam is cleared" )
784   PORT_DIPSETTING(   0x00, "Continue alarm until back door open" )
785   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:4")
786   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
787   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
788   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:5")
789   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
790   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
791   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW2:6")
792   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
793   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
794   PORT_DIPNAME( 0xc0, 0x00, "Payout Percentage" ) PORT_DIPLOCATION("SW2:7,8")
795   PORT_DIPSETTING(   0x00, "50%" )
796   PORT_DIPSETTING(   0x80, "45%" )
797   PORT_DIPSETTING(   0x40, "40%" )
798   PORT_DIPSETTING(   0xc0, "30%" )
799
800   PORT_START("DIRECT")
801   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Back door") PORT_CODE(KEYCODE_R) PORT_TOGGLE
802   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Cash door") PORT_CODE(KEYCODE_T) PORT_TOGGLE
803   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Refill key") PORT_CODE(KEYCODE_Y) PORT_TOGGLE
804   PORT_DIPNAME( 0x08, 0x08, DEF_STR ( Unknown ) )
805   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
806   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
807   PORT_DIPNAME( 0x10, 0x10, DEF_STR ( Unknown ) )
808   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
809   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
810   PORT_DIPNAME( 0x20, 0x20, DEF_STR ( Unknown ) )
811   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
812   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
813   PORT_DIPNAME( 0x40, 0x40, "Reset" ) PORT_DIPLOCATION("SW1:1")
814   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
815   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
816   PORT_DIPNAME( 0x80, 0x00, DEF_STR ( Unknown ) )
817   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
818   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
819
820   PORT_START("COINS")
821   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_NAME("10p")
822   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_NAME("20p")
823   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_NAME("50p")
824   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN4 ) PORT_NAME("100p")
825   PORT_BIT( 0xc3, IP_ACTIVE_LOW, IPT_UNUSED )
826
827INPUT_PORTS_END
828
829/*************************************
830 *
831 *  Initialisation
832 *
833 *************************************/
834
835static MACHINE_START( jpmsys5 )
836{
837   memory_set_bankptr(machine, "bank1", machine.region("maincpu")->base());
838}
839
840static MACHINE_RESET( jpmsys5 )
841{
842   jpmsys5_state *state = machine.driver_data<jpmsys5_state>();
843   state->m_a2_data_in = 1;
844   state->m_a2_acia_dcd = 0;
845}
846
847/*************************************
848 *
849 *  Machine driver
850 *
851 *************************************/
852
853static MACHINE_CONFIG_START( jpmsys5, jpmsys5_state )
854   MCFG_CPU_ADD("maincpu", M68000, 8000000)
855   MCFG_CPU_PROGRAM_MAP(68000_awp_map)
856
857   MCFG_ACIA6850_ADD("acia6850_0", acia0_if)
858   MCFG_ACIA6850_ADD("acia6850_1", acia1_if)
859   MCFG_ACIA6850_ADD("acia6850_2", acia2_if)
860
861   MCFG_NVRAM_ADD_0FILL("nvram")
862
863   MCFG_MACHINE_START(jpmsys5)
864   MCFG_MACHINE_RESET(jpmsys5)
865   MCFG_SPEAKER_STANDARD_MONO("mono")
866
867   MCFG_SOUND_ADD("upd7759", UPD7759, UPD7759_STANDARD_CLOCK)
868   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
869
870   /* Earlier revisions use an SAA1099 */
871   MCFG_SOUND_ADD("ym2413", YM2413, 4000000 ) /* Unconfirmed */
872   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
873
874   /* 6840 PTM */
875   MCFG_PTM6840_ADD("6840ptm", ptm_intf)
876   MCFG_DEFAULT_LAYOUT(layout_awpvid16)
877MACHINE_CONFIG_END
878
879/*************************************
880 *
881 *  ROM definition(s)
882 *
883 *************************************/
884
885ROM_START( m_popeye )
886   ROM_REGION( 0x300000, "maincpu", 0 )
887   ROM_LOAD16_BYTE( "popeye_std_p1.bin", 0x000000, 0x10000, CRC(a8d5394c) SHA1(5be0cd8bc4cdb230a839f83e1297bc57dde20d94) )
888   ROM_LOAD16_BYTE( "popeye_std_p2.bin", 0x000001, 0x10000, CRC(5537afc2) SHA1(3e90fef908b80939c781a85a2ac9783de62d4122) )
889
890   ROM_REGION( 0x80000, "upd7759", 0 )
891   ROM_LOAD( "popsnd.bin", 0x00000, 0x80000, CRC(67378dbc) SHA1(83f87e35bb2c73a788c0ed778b33f3710eb95406) )
892ROM_END
893
894GAME( 1994, m_popeye, 0, jpmsys5, popeye, 0, ROT0, "JPM", "Popeye (20p/8 GBP Token)", GAME_NOT_WORKING )
src/mame/drivers/arkanoid.c
r11640r11641
878878INPUT_PORTS_END
879879
880880static INPUT_PORTS_START( brixian )
881         PORT_START("SYSTEM")
881       PORT_START("SYSTEM")
882882   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
883883   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
884884   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
src/osd/sdl/man/mame.1
r11640r11641
520520.B \-[no]use_bezels, \-[no]bezel
521521Enables/disables the display of bezels. The default is ON
522522(\-use_bezels).
523.TP
524.B \-[no]use_cpanels, \-[no]cpanel
525Enables/disables the display of cpanels. The default is ON
526(\-use_bezels).
527.TP
528.B \-[no]use_marquees, \-[no]marquee
529Enables/disables the display of marquees. The default is ON
530(\-use_bezels).
523531.\"
524532.\" *******************************************************
525533.SS Screen options
src/osd/windows/winmain.c
r11640r11641
327327   { WINOPTION_FILTER ";d3dfilter;flt",              "1",        OPTION_BOOLEAN,    "enable bilinear filtering on screen output" },
328328
329329   // post-processing options
330   { NULL,                                                    NULL,        OPTION_HEADER,     "DIRECT3D POST-PROCESSING OPTIONS" },
331   { WINOPTION_HLSL_ENABLE";hlsl",                           "0",           OPTION_BOOLEAN,    "enable HLSL post-processing (PS3.0 required)" },
332   { WINOPTION_HLSLPATH,                                       "hlsl",       OPTION_STRING,     "path to hlsl files" },
333   { WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)",         "0.0",         OPTION_FLOAT,       "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" },
330   { NULL,                                                   NULL,        OPTION_HEADER,     "DIRECT3D POST-PROCESSING OPTIONS" },
331   { WINOPTION_HLSL_ENABLE";hlsl",                        "0",        OPTION_BOOLEAN,    "enable HLSL post-processing (PS3.0 required)" },
332   { WINOPTION_HLSLPATH,                                      "hlsl",     OPTION_STRING,     "path to hlsl files" },
333   { WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)",         "0.0",      OPTION_FLOAT,     "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" },
334334   { WINOPTION_SHADOW_MASK_TEXTURE";fs_shadwt(0.0-1.0)",       "aperture.png", OPTION_STRING,  "shadow mask texture name" },
335   { WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww",            "640",        OPTION_INTEGER,   "shadow mask width, in phosphor dots" },
335   { WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww",            "640",       OPTION_INTEGER,   "shadow mask width, in phosphor dots" },
336336   { WINOPTION_SHADOW_MASK_COUNT_Y";fs_shadwh",            "480",       OPTION_INTEGER,   "shadow mask height, in phosphor dots" },
337337   { WINOPTION_SHADOW_MASK_USIZE";fs_shadwu(0.0-1.0)",         "0.1875",    OPTION_FLOAT,      "shadow mask texture size in U direction" },
338338   { WINOPTION_SHADOW_MASK_VSIZE";fs_shadwv(0.0-1.0)",         "0.1875",    OPTION_FLOAT,      "shadow mask texture size in V direction" },
339   { WINOPTION_OVERSAMPLE_X";fs_overx(0.1-9.0)",               "1.0",         OPTION_FLOAT,       "oversample amount in screen-relative X direction, multiple" },
340   { WINOPTION_OVERSAMPLE_Y";fs_overy(0.1-9.0)",               "1.0",         OPTION_FLOAT,        "oversample amount in screen-relative Y direction, multiple" },
341   { WINOPTION_CURVATURE";fs_curv(0.0-4.0)",                  "0.0",       OPTION_FLOAT,       "screen curvature amount" },
342   { WINOPTION_SCREEN_SCALE_TOP";fs_scalex(0.0-2.0)",          "1.0",       OPTION_FLOAT,       "screen scale, top" },
343   { WINOPTION_SCREEN_SCALE_BOTTOM";fs_scaley(0.0-2.0)",        "1.0",       OPTION_FLOAT,       "screen scale, bottom" },
339   { WINOPTION_OVERSAMPLE_X";fs_overx(0.1-9.0)",              "1.0",      OPTION_FLOAT,     "oversample amount in screen-relative X direction, multiple" },
340   { WINOPTION_OVERSAMPLE_Y";fs_overy(0.1-9.0)",              "1.0",      OPTION_FLOAT,     "oversample amount in screen-relative Y direction, multiple" },
341   { WINOPTION_CURVATURE";fs_curv(0.0-4.0)",                 "0.0",       OPTION_FLOAT,     "screen curvature amount" },
342   { WINOPTION_SCREEN_SCALE_TOP";fs_scalex(0.0-2.0)",          "1.0",       OPTION_FLOAT,     "screen scale, top" },
343   { WINOPTION_SCREEN_SCALE_BOTTOM";fs_scaley(0.0-2.0)",      "1.0",       OPTION_FLOAT,     "screen scale, bottom" },
344344   /* Beam-related values below this line*/
345   { WINOPTION_PINCUSHION";fs_pin(0.0-4.0)",                  "0.0",       OPTION_FLOAT,       "pincushion amount" },
346   { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)",          "0.0",       OPTION_FLOAT,       "overall alpha scaling value for scanlines" },
347   { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)",           "1.0",       OPTION_FLOAT,       "overall height scaling value for scanlines" },
348   { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-1.0)",    "1.0",       OPTION_FLOAT,       "overall brightness scaling value for scanlines (multiplicative)" },
349   { WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)",   "0.6",       OPTION_FLOAT,       "overall brightness offset value for scanlines (additive)" },
350   { WINOPTION_SCANLINE_OFFSET";fs_scanjt(0.0-4.0)",          "0.0",       OPTION_FLOAT,       "overall interlace jitter scaling value for scanlines" },
351   { WINOPTION_DEFOCUS_X";fs_focusx(0.0-16.0)",                "0.0",       OPTION_FLOAT,      "overall defocus scaling value in screen-relative X direction" },
352   { WINOPTION_DEFOCUS_Y";fs_focusy(0.0-16.0)",                "0.0",       OPTION_FLOAT,      "overall defocus scaling value in screen-relative Y direction" },
353   { WINOPTION_RED_CONVERGE_X";fs_redcvx(-1.0-1.0)",          "0.0",       OPTION_FLOAT,       "red convergence in screen-relative X direction" },
354   { WINOPTION_RED_CONVERGE_Y";fs_redcvy(-1.0-1.0)",          "0.0",       OPTION_FLOAT,       "red convergence in screen-relative Y direction" },
355   { WINOPTION_GREEN_CONVERGE_X";fs_grncvx(-1.0-1.0)",        "0.0",       OPTION_FLOAT,       "green convergence in screen-relative X direction" },
356   { WINOPTION_GREEN_CONVERGE_Y";fs_grncvy(-1.0-1.0)",        "0.0",       OPTION_FLOAT,       "green convergence in screen-relative Y direction" },
357   { WINOPTION_BLUE_CONVERGE_X";fs_blucvx(-1.0-1.0)",         "0.0",       OPTION_FLOAT,       "blue convergence in screen-relative X direction" },
358   { WINOPTION_BLUE_CONVERGE_Y";fs_blucvy(-1.0-1.0)",         "0.0",       OPTION_FLOAT,       "blue convergence in screen-relative Y direction" },
359   { WINOPTION_RED_RADIAL_CONVERGE_X";fs_redrcvx(-16 - 16)",   "0.0",       OPTION_FLOAT,       "red radial convergence in screen-relative X direction" },
360   { WINOPTION_RED_RADIAL_CONVERGE_Y";fs_redrcvy(-16 - 16)",   "0.0",       OPTION_FLOAT,       "red radial convergence in screen-relative Y direction" },
361   { WINOPTION_GREEN_RADIAL_CONVERGE_X";fs_grnrcvx(-16 - 16)",   "0.0",       OPTION_FLOAT,       "green radial convergence in screen-relative X direction" },
362   { WINOPTION_GREEN_RADIAL_CONVERGE_Y";fs_grnrcvy(-16 - 16)",   "0.0",       OPTION_FLOAT,       "green radial convergence in screen-relative Y direction" },
363   { WINOPTION_BLUE_RADIAL_CONVERGE_X";fs_blurcvx(-16 - 16)",   "0.0",       OPTION_FLOAT,       "blue radial convergence in screen-relative X direction" },
364   { WINOPTION_BLUE_RADIAL_CONVERGE_Y";fs_blurcvy(-16 - 16)",   "0.0",       OPTION_FLOAT,       "blue radial convergence in screen-relative Y direction" },
345   { WINOPTION_PINCUSHION";fs_pin(0.0-4.0)",                 "0.0",       OPTION_FLOAT,     "pincushion amount" },
346   { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)",          "0.0",       OPTION_FLOAT,     "overall alpha scaling value for scanlines" },
347   { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)",           "1.0",       OPTION_FLOAT,     "overall height scaling value for scanlines" },
348   { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-1.0)",    "1.0",       OPTION_FLOAT,     "overall brightness scaling value for scanlines (multiplicative)" },
349   { WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)",   "0.6",       OPTION_FLOAT,     "overall brightness offset value for scanlines (additive)" },
350   { WINOPTION_SCANLINE_OFFSET";fs_scanjt(0.0-4.0)",          "0.0",       OPTION_FLOAT,     "overall interlace jitter scaling value for scanlines" },
351   { WINOPTION_DEFOCUS_X";fs_focusx(0.0-16.0)",            "0.0",       OPTION_FLOAT,      "overall defocus scaling value in screen-relative X direction" },
352   { WINOPTION_DEFOCUS_Y";fs_focusy(0.0-16.0)",            "0.0",       OPTION_FLOAT,      "overall defocus scaling value in screen-relative Y direction" },
353   { WINOPTION_RED_CONVERGE_X";fs_redcvx(-1.0-1.0)",          "0.0",       OPTION_FLOAT,     "red convergence in screen-relative X direction" },
354   { WINOPTION_RED_CONVERGE_Y";fs_redcvy(-1.0-1.0)",          "0.0",       OPTION_FLOAT,     "red convergence in screen-relative Y direction" },
355   { WINOPTION_GREEN_CONVERGE_X";fs_grncvx(-1.0-1.0)",        "0.0",       OPTION_FLOAT,     "green convergence in screen-relative X direction" },
356   { WINOPTION_GREEN_CONVERGE_Y";fs_grncvy(-1.0-1.0)",        "0.0",       OPTION_FLOAT,     "green convergence in screen-relative Y direction" },
357   { WINOPTION_BLUE_CONVERGE_X";fs_blucvx(-1.0-1.0)",         "0.0",       OPTION_FLOAT,     "blue convergence in screen-relative X direction" },
358   { WINOPTION_BLUE_CONVERGE_Y";fs_blucvy(-1.0-1.0)",         "0.0",       OPTION_FLOAT,     "blue convergence in screen-relative Y direction" },
359   { WINOPTION_RED_RADIAL_CONVERGE_X";fs_redrcvx(-16 - 16)",   "0.0",       OPTION_FLOAT,     "red radial convergence in screen-relative X direction" },
360   { WINOPTION_RED_RADIAL_CONVERGE_Y";fs_redrcvy(-16 - 16)",   "0.0",       OPTION_FLOAT,     "red radial convergence in screen-relative Y direction" },
361   { WINOPTION_GREEN_RADIAL_CONVERGE_X";fs_grnrcvx(-16 - 16)",   "0.0",       OPTION_FLOAT,     "green radial convergence in screen-relative X direction" },
362   { WINOPTION_GREEN_RADIAL_CONVERGE_Y";fs_grnrcvy(-16 - 16)",   "0.0",       OPTION_FLOAT,     "green radial convergence in screen-relative Y direction" },
363   { WINOPTION_BLUE_RADIAL_CONVERGE_X";fs_blurcvx(-16 - 16)",   "0.0",       OPTION_FLOAT,     "blue radial convergence in screen-relative X direction" },
364   { WINOPTION_BLUE_RADIAL_CONVERGE_Y";fs_blurcvy(-16 - 16)",   "0.0",       OPTION_FLOAT,     "blue radial convergence in screen-relative Y direction" },
365365   /* RGB colorspace convolution below this line */
366   { WINOPTION_RED_MATRIX_R";fs_matrr(-2.0-2.0)",              "1.0",       OPTION_FLOAT,       "red output signal generated by red input signal" },
367   { WINOPTION_RED_MATRIX_G";fs_matrg(-2.0-2.0)",              "0.0",       OPTION_FLOAT,       "red output signal generated by green input signal" },
368   { WINOPTION_RED_MATRIX_B";fs_matrb(-2.0-2.0)",              "0.0",       OPTION_FLOAT,       "red output signal generated by blue input signal" },
369   { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)",            "0.0",       OPTION_FLOAT,       "green output signal generated by red input signal" },
370   { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)",           "1.0",       OPTION_FLOAT,       "green output signal generated by green input signal" },
371   { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)",           "0.0",       OPTION_FLOAT,       "green output signal generated by blue input signal" },
372   { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)",              "0.0",       OPTION_FLOAT,       "blue output signal generated by red input signal" },
373   { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)",              "0.0",       OPTION_FLOAT,       "blue output signal generated by green input signal" },
374   { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)",              "1.0",       OPTION_FLOAT,       "blue output signal generated by blue input signal" },
375   { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)",            "0.0",       OPTION_FLOAT,       "green output signal generated by red input signal" },
376   { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)",           "1.0",       OPTION_FLOAT,       "green output signal generated by green input signal" },
377   { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)",           "0.0",       OPTION_FLOAT,       "green output signal generated by blue input signal" },
378   { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)",              "0.0",       OPTION_FLOAT,       "blue output signal generated by red input signal" },
379   { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)",              "0.0",       OPTION_FLOAT,       "blue output signal generated by green input signal" },
380   { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)",              "1.0",       OPTION_FLOAT,       "blue output signal generated by blue input signal" },
366   { WINOPTION_RED_MATRIX_R";fs_matrr(-2.0-2.0)",            "1.0",       OPTION_FLOAT,     "red output signal generated by red input signal" },
367   { WINOPTION_RED_MATRIX_G";fs_matrg(-2.0-2.0)",            "0.0",       OPTION_FLOAT,     "red output signal generated by green input signal" },
368   { WINOPTION_RED_MATRIX_B";fs_matrb(-2.0-2.0)",            "0.0",       OPTION_FLOAT,     "red output signal generated by blue input signal" },
369   { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)",          "0.0",       OPTION_FLOAT,     "green output signal generated by red input signal" },
370   { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)",           "1.0",       OPTION_FLOAT,     "green output signal generated by green input signal" },
371   { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)",           "0.0",       OPTION_FLOAT,     "green output signal generated by blue input signal" },
372   { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)",           "0.0",       OPTION_FLOAT,     "blue output signal generated by red input signal" },
373   { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)",           "0.0",       OPTION_FLOAT,     "blue output signal generated by green input signal" },
374   { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)",           "1.0",       OPTION_FLOAT,     "blue output signal generated by blue input signal" },
375   { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)",          "0.0",       OPTION_FLOAT,     "green output signal generated by red input signal" },
376   { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)",           "1.0",       OPTION_FLOAT,     "green output signal generated by green input signal" },
377   { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)",           "0.0",       OPTION_FLOAT,     "green output signal generated by blue input signal" },
378   { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)",           "0.0",       OPTION_FLOAT,     "blue output signal generated by red input signal" },
379   { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)",           "0.0",       OPTION_FLOAT,     "blue output signal generated by green input signal" },
380   { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)",           "1.0",       OPTION_FLOAT,     "blue output signal generated by blue input signal" },
381381   { WINOPTION_SATURATION";fs_sat(0.0-4.0)",                  "1.0",       OPTION_FLOAT,      "saturation scaling value" },
382382   { WINOPTION_RED_OFFSET";fs_redoff(-1.0-1.0)",              "0.0",       OPTION_FLOAT,      "red signal offset value (additive)" },
383383   { WINOPTION_GREEN_OFFSET";fs_grnoff(-1.0-1.0)",            "0.0",       OPTION_FLOAT,      "green signal offset value (additive)" },
r11640r11641
385385   { WINOPTION_RED_SCALE";fs_redmul(0.0-2.0)",                "1.0",       OPTION_FLOAT,      "red signal scaling value (multiplicative)" },
386386   { WINOPTION_GREEN_SCALE";fs_grnmul(0.0-2.0)",              "1.0",       OPTION_FLOAT,      "green signal scaling value (multiplicative)" },
387387   { WINOPTION_BLUE_SCALE";fs_blumul(0.0-2.0)",               "1.0",       OPTION_FLOAT,      "blue signal scaling value (multiplicative)" },
388   { WINOPTION_RED_POWER";fs_redpow(0.01-32.0)",                "1.0",       OPTION_FLOAT,      "red signal power value (exponential)" },
389   { WINOPTION_GREEN_POWER";fs_grnpow(0.01-32.0)",              "1.0",       OPTION_FLOAT,      "green signal power value (exponential)" },
390   { WINOPTION_BLUE_POWER";fs_blupow(0.01-32.0)",               "1.0",       OPTION_FLOAT,      "blue signal power value (exponential)" },
388   { WINOPTION_RED_POWER";fs_redpow(0.01-32.0)",              "1.0",       OPTION_FLOAT,      "red signal power value (exponential)" },
389   { WINOPTION_GREEN_POWER";fs_grnpow(0.01-32.0)",            "1.0",       OPTION_FLOAT,      "green signal power value (exponential)" },
390   { WINOPTION_BLUE_POWER";fs_blupow(0.01-32.0)",             "1.0",       OPTION_FLOAT,      "blue signal power value (exponential)" },
391391   { WINOPTION_RED_FLOOR";fs_redfl(0.0-1.0)",                 "0.0",       OPTION_FLOAT,      "red signal floor level" },
392392   { WINOPTION_GREEN_FLOOR";fs_grnfl(0.0-1.0)",               "0.0",       OPTION_FLOAT,      "green signal floor level" },
393393   { WINOPTION_BLUE_FLOOR";fs_blufl(0.0-1.0)",                "0.0",       OPTION_FLOAT,      "blue signal floor level" },
r11640r11641
395395   { WINOPTION_GREEN_PHOSPHOR";fs_grnpho(0.0-1.0)",           "0.0",       OPTION_FLOAT,      "green phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
396396   { WINOPTION_BLUE_PHOSPHOR";fs_grnpho(0.0-1.0)",            "0.0",       OPTION_FLOAT,      "blue phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
397397   /* NTSC simulation below this line */
398   { WINOPTION_YIQ_ENABLE";yiq",                           "0",           OPTION_BOOLEAN,    "enable YIQ-space HLSL post-processing" },
398   { WINOPTION_YIQ_ENABLE";yiq",                          "0",        OPTION_BOOLEAN,    "enable YIQ-space HLSL post-processing" },
399399   { WINOPTION_YIQ_WVALUE";yiqw",                        "4.1187867", OPTION_FLOAT,      "W value for YIQ signal processing" },
400   { WINOPTION_YIQ_AVALUE";yiqa",                        "0.5",        OPTION_FLOAT,      "A value for YIQ signal processing" },
400   { WINOPTION_YIQ_AVALUE";yiqa",                        "0.5",       OPTION_FLOAT,      "A value for YIQ signal processing" },
401401   { WINOPTION_YIQ_BVALUE";yiqb",                        "0.5",      OPTION_FLOAT,      "B value for YIQ signal processing" },
402   { WINOPTION_YIQ_FSCVALUE";yiqfsc",                     "1.5",         OPTION_FLOAT,      "Fsc value for YIQ signal processing" },
403   { WINOPTION_YIQ_FSCSCALE";yiqfscs",                     "1.0",        OPTION_FLOAT,      "Incoming Fsc scaling value for YIQ signal processing" },
402   { WINOPTION_YIQ_FSCVALUE";yiqfsc",                     "1.5",        OPTION_FLOAT,      "Fsc value for YIQ signal processing" },
403   { WINOPTION_YIQ_FSCSCALE";yiqfscs",                     "1.0",       OPTION_FLOAT,      "Incoming Fsc scaling value for YIQ signal processing" },
404404   { WINOPTION_YIQ_PHASE_COUNT";yiqp",                     "2",       OPTION_INTEGER,   "Phase Count value for YIQ signal processing" },
405405
406406   // per-window options
r11640r11641
449449   { NULL }
450450};
451451
452
453
454452//**************************************************************************
455453//  MAIN ENTRY POINT
456454//**************************************************************************
src/osd/windows/winmain.h
r11640r11641
9696#define WINOPTION_SCANLINE_AMOUNT         "scanline_alpha"
9797#define WINOPTION_SCANLINE_SCALE         "scanline_size"
9898#define WINOPTION_SCANLINE_BRIGHT_SCALE    "scanline_bright_scale"
99#define WINOPTION_SCANLINE_BRIGHT_OFFSET    "scanline_bright_offset"
99#define WINOPTION_SCANLINE_BRIGHT_OFFSET   "scanline_bright_offset"
100100#define WINOPTION_SCANLINE_OFFSET         "scanline_jitter"
101101#define WINOPTION_DEFOCUS_X               "defocus_x"
102102#define WINOPTION_DEFOCUS_Y               "defocus_y"
src/osd/windows/drawd3d.c
r11640r11641
650650   }
651651
652652   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Darkness", 0, 0, 100, 1, slider_shadow_mask_alpha, (void*)d3d); tailptr = &(*tailptr)->next;
653   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask X Count", 1, 640, 1024, 0, slider_shadow_mask_x_count, (void*)d3d); tailptr = &(*tailptr)->next;
654   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Y Count", 1, 640, 1024, 0, slider_shadow_mask_y_count, (void*)d3d); tailptr = &(*tailptr)->next;
653   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask X Count", 1, 640, 1024, 1, slider_shadow_mask_x_count, (void*)d3d); tailptr = &(*tailptr)->next;
654   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Y Count", 1, 480, 1024, 1, slider_shadow_mask_y_count, (void*)d3d); tailptr = &(*tailptr)->next;
655655   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Pixel Count X", 1, 3, 32, 1, slider_shadow_mask_usize, (void*)d3d); tailptr = &(*tailptr)->next;
656656   *tailptr = slider_alloc(d3d->window->machine(), "Shadow Mask Pixel Count Y", 1, 3, 32, 1, slider_shadow_mask_vsize, (void*)d3d); tailptr = &(*tailptr)->next;
657657   *tailptr = slider_alloc(d3d->window->machine(), "Screen Curvature", 0, 0, 100, 1, slider_curvature, (void*)d3d); tailptr = &(*tailptr)->next;
r11640r11641
675675   *tailptr = slider_alloc(d3d->window->machine(), "Green Convergence Y", -1500, 0, 1500, 1, slider_green_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
676676   *tailptr = slider_alloc(d3d->window->machine(), "Blue Convergence X", -1500, 0, 1500, 1, slider_blue_radial_converge_x, (void*)d3d); tailptr = &(*tailptr)->next;
677677   *tailptr = slider_alloc(d3d->window->machine(), "Blue Convergence Y", -1500, 0, 1500, 1, slider_blue_radial_converge_y, (void*)d3d); tailptr = &(*tailptr)->next;
678   *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Red Input", -400, 200, 400, 5, slider_red_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
678   *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Red Input", -400, 0, 400, 5, slider_red_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
679679   *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Green Input", -400, 0, 400, 5, slider_red_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
680680   *tailptr = slider_alloc(d3d->window->machine(), "Red Output from Blue Input", -400, 0, 400, 5, slider_red_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
681681   *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Red Input", -400, 0, 400, 5, slider_green_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
682   *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Green Input", -400, 200, 400, 5, slider_green_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
682   *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Green Input", -400, 0, 400, 5, slider_green_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
683683   *tailptr = slider_alloc(d3d->window->machine(), "Green Output from Blue Input", -400, 0, 400, 5, slider_green_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
684684   *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Red Input", -400, 0, 400, 5, slider_blue_from_r, (void*)d3d); tailptr = &(*tailptr)->next;
685685   *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Green Input", -400, 0, 400, 5, slider_blue_from_g, (void*)d3d); tailptr = &(*tailptr)->next;
686   *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Blue Input", -400, 200, 400, 5, slider_blue_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
686   *tailptr = slider_alloc(d3d->window->machine(), "Blue Output from Blue Input", -400, 0, 400, 5, slider_blue_from_b, (void*)d3d); tailptr = &(*tailptr)->next;
687687   *tailptr = slider_alloc(d3d->window->machine(), "Red DC Offset", -100, 0, 100, 1, slider_red_offset, (void*)d3d); tailptr = &(*tailptr)->next;
688688   *tailptr = slider_alloc(d3d->window->machine(), "Green DC Offset", -100, 0, 100, 1, slider_green_offset, (void*)d3d); tailptr = &(*tailptr)->next;
689689   *tailptr = slider_alloc(d3d->window->machine(), "Blue DC Offset", -100, 0, 100, 1, slider_blue_offset, (void*)d3d); tailptr = &(*tailptr)->next;
src/emu/cpu/i86/instr286.c
r11640r11641
107107         i80286_interrupt_descriptor(cpustate,number,1,-1);
108108      }
109109   } catch(UINT32 e) { i80286_trap2(cpustate, e); }
110   if(cpustate->trap_level == 3)
110   if(cpustate->trap_level == 3)
111111      // this is supposed to triggered by support hardware
112112      // create a shutdown output line that causes a reset
113113      // NMI can wake processor without reset
r11640r11641
128128{
129129   if (!IDXTBL(selector)) return GENERAL_PROTECTION_FAULT;
130130   if (!SEGDESC(rights)) return GENERAL_PROTECTION_FAULT;
131   
131
132132   switch(operation) {
133133      case I80286_READ:
134134         if (CODE(rights) && !READ(rights)) return GENERAL_PROTECTION_FAULT;
r11640r11641
228228   cpustate->flags = CompressFlags();
229229   if (type == CALL) WriteWord(BASE(ndesc)+TSS_BACK*2, cpustate->tr.sel);
230230   if (type == IRET) cpustate->flags &= ~0x4000;
231
231
232232   otss[TSS_IP] = cpustate->pc-cpustate->base[CS];
233233   otss[TSS_FLAG] = cpustate->flags;
234234   otss[TSS_AX] = cpustate->regs.w[AX];
r11640r11641
282282
283283   if (type == CALL) cpustate->flags |= 0x4000;
284284   cpustate->msw |= 8;
285     
285
286286   cpustate->ldtr.sel=ntss[TSS_LDT]; // docs say nothing about whether a null ldt can be in a tss
287287   cpustate->ldtr.limit=LIMIT(desc);
288288   cpustate->ldtr.base=BASE(desc);
r11640r11641
298298      if(error_code == GENERAL_PROTECTION_FAULT) e = TRAP(INVALID_TSS,(e >> 16)); // #NP fault is correct
299299      throw e;
300300   }
301   
301
302302   i80286_data_descriptor_full(cpustate, ES, ntss[TSS_ES], RPL(ntss[TSS_CS]), TRAP(INVALID_TSS,IDXTBL(ntss[TSS_ES])));
303303   i80286_data_descriptor_full(cpustate, DS, ntss[TSS_DS], RPL(ntss[TSS_CS]), TRAP(INVALID_TSS,IDXTBL(ntss[TSS_DS])));
304304}
r11640r11641
324324         if (!CODE(r)) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(selector));
325325         if (CONF(r)) { if(DPL(r)>CPL) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(selector)); }
326326         else if ((RPL(selector)>CPL) || (DPL(r)!=CPL)) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(selector));
327         
327
328328         if (!PRES(r)) throw TRAP(SEG_NOT_PRESENT,IDXTBL(selector));  // this order is important
329329         if (offset > LIMIT(desc)) throw TRAP(GENERAL_PROTECTION_FAULT, 0);
330330         SET_ACC(desc);
r11640r11641
411411
412412   if(!PM) return PREFIX86(_interrupt)(cpustate, number);
413413
414   if ((number<<3)>=cpustate->idtr.limit)
414   if ((number<<3)>=cpustate->idtr.limit)
415415      throw TRAP(GENERAL_PROTECTION_FAULT,(number*8+2+(hwint&&1)));
416416
417417   desc[0] = ReadWord(cpustate->idtr.base+(number<<3));
r11640r11641
421421   if (!hwint && (DPL(r)<CPL)) throw TRAP(GENERAL_PROTECTION_FAULT,(number*8+2+(hwint&&1)));
422422   if (!PRES(r)) throw TRAP(SEG_NOT_PRESENT,(number*8+2+(hwint&&1)));
423423   gatesel = GATESEL(desc);
424   
424
425425   switch (GATE(r)) {
426426   case TASKGATE:
427427      gatesel = GATESEL(gatedesc);
r11640r11641
452452         cpustate->regs.w[SP] = tss_sp;
453453         PUSH(oldss);
454454         PUSH(oldsp);
455      }
455      }
456456      SET_ACC(gatedesc);
457457      WriteWord(addr+4, gatedesc[2]);
458458      PREFIX(_pushf(cpustate));
r11640r11641
635635      if (PM&&(CPL!=0)) throw TRAP(GENERAL_PROTECTION_FAULT,0);
636636      cpustate->msw =        (cpustate->msw&1)|ReadWord(0x806);
637637      cpustate->tr.sel =     ReadWord(0x816);
638      tmp =                   ReadWord(0x818);
638      tmp =                  ReadWord(0x818);
639639      ExpandFlags(tmp);
640640      cpustate->flags = tmp;
641641      cpustate->flags = CompressFlags();
r11640r11641
715715   ExpandFlags(flags);
716716   cpustate->flags = flags;
717717   cpustate->flags = CompressFlags();
718   
718
719719   if (cpustate->TF) PREFIX(_trap)(cpustate);
720720   /* if the IF is set, and an interrupt is pending, signal an interrupt */
721721   if (cpustate->IF && cpustate->irq_state)
r11640r11641
756756      desc[1] = ReadWord(addr+2);
757757      desc[2] = ReadWord(addr+4);
758758      r = RIGHTS(desc);
759     
759
760760      if (NT && iret) {
761761         i80286_switch_task(cpustate, ReadWord(cpustate->tr.base+TSS_BACK*2), IRET);
762762         return cpustate->flags;
763763      }
764     
764
765765      if (!CODE(r) || !SEGDESC(r)) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(sel));
766766      if (CONF(r)) { if(DPL(r)>RPL(sel)) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(sel)); }
767767      else if (DPL(r)!=RPL(sel)) throw TRAP(GENERAL_PROTECTION_FAULT,IDXTBL(sel));
src/emu/cpu/i86/instr86.c
r11640r11641
382382         cpustate->AuxVal = 1;
383383         PutbackRMWord(ModRM,dst);
384384         break;
385      case 0x38:   /* SAR ew,count */         
385      case 0x38:   /* SAR ew,count */
386386         for(int i=0;i<count-1;i++) dst = ((INT16)dst) >> 1;
387387         cpustate->CarryVal = dst & 0x01;
388388         dst = ((INT16)((WORD)dst)) >> 1;
r11640r11641
18561856      cpustate->pc = cpustate->prevpc;
18571857      return PREFIX86(_invalid)(cpustate);
18581858   }
1859     
1859
18601860   PutRMWord(ModRM,cpustate->sregs[(ModRM & 0x38) >> 3]);
18611861}
18621862
r11640r11641
28002800   if (cpustate->irq_state)
28012801#ifdef I80286
28022802      i80286_interrupt_descriptor(cpustate, (*cpustate->irq_callback)(cpustate->device, 0), 2, -1);
2803#else     
2803#else
28042804      PREFIX86(_interrupt)(cpustate, (UINT32)-1);
28052805#endif
28062806}
src/emu/cpu/sh2/sh2comn.c
r11640r11641
755755   sh2_timer_resync(sh2);
756756   sh2->icr = sh2->frc;
757757   sh2->m[4] |= ICF;
758   logerror("SH2.%s: ICF activated (%x)\n", sh2->device->tag(), sh2->pc & AM);
758   //logerror("SH2.%s: ICF activated (%x)\n", sh2->device->tag(), sh2->pc & AM);
759759   sh2_recalc_irq(sh2);
760760}
761761
src/emu/video/mc6845.c
r11640r11641
779779   m_adjust_active = 0;
780780   m_horiz_sync_pos = 1;
781781   m_vert_sync_pos = 1;
782   m_de = 0;     
782   m_de = 0;
783783   m_sync_width = 1;
784784   m_vert_char_total = 0;
785785   m_vert_disp = 0;
src/emu/emuopts.c
r11640r11641
121121   { OPTION_USE_BACKDROPS ";backdrop",                  "1",         OPTION_BOOLEAN,    "enable backdrops if artwork is enabled and available" },
122122   { OPTION_USE_OVERLAYS ";overlay",                    "1",         OPTION_BOOLEAN,    "enable overlays if artwork is enabled and available" },
123123   { OPTION_USE_BEZELS ";bezel",                        "1",         OPTION_BOOLEAN,    "enable bezels if artwork is enabled and available" },
124   { OPTION_USE_CPANELS ";cpanel",                      "1",         OPTION_BOOLEAN,    "enable cpanels if artwork is enabled and available" },
125   { OPTION_USE_MARQUEES ";marquee",                    "1",         OPTION_BOOLEAN,    "enable marquees if artwork is enabled and available" },
124126
125127   // screen options
126128   { NULL,                                              NULL,        OPTION_HEADER,     "CORE SCREEN OPTIONS" },
src/emu/emuopts.h
r11640r11641
131131#define OPTION_USE_BACKDROPS      "use_backdrops"
132132#define OPTION_USE_OVERLAYS         "use_overlays"
133133#define OPTION_USE_BEZELS         "use_bezels"
134#define OPTION_USE_CPANELS         "use_cpanels"
135#define OPTION_USE_MARQUEES         "use_marquees"
134136
135137// core screen options
136138#define OPTION_BRIGHTNESS         "brightness"
r11640r11641
278280   bool use_backdrops() const { return bool_value(OPTION_USE_BACKDROPS); }
279281   bool use_overlays() const { return bool_value(OPTION_USE_OVERLAYS); }
280282   bool use_bezels() const { return bool_value(OPTION_USE_BEZELS); }
283   bool use_cpanels() const { return bool_value(OPTION_USE_CPANELS); }
284   bool use_marquees() const { return bool_value(OPTION_USE_MARQUEES); }
281285
282286   // core screen options
283287   float brightness() const { return float_value(OPTION_BRIGHTNESS); }
src/emu/uimenu.c
r11640r11641
8080   VIDEO_ITEM_BACKDROPS,
8181   VIDEO_ITEM_OVERLAYS,
8282   VIDEO_ITEM_BEZELS,
83   VIDEO_ITEM_CPANELS,
84   VIDEO_ITEM_MARQUEES,
8385   VIDEO_ITEM_ZOOM,
8486   VIDEO_ITEM_VIEW
8587};
r11640r11641
30243026      if (curval < curslider->maxval)
30253027         flags |= MENU_FLAG_RIGHT_ARROW;
30263028      ui_menu_item_append(menu, curslider->description, tempstring, flags, (void *)curslider);
3027
3028      if (menuless_mode)
3029         break;
30303029   }
30313030
30323031   ui_menu_set_custom_render(menu, menu_sliders_custom_render, 0.0f, 2.0f * ui_get_line_height(machine) + 2.0f * UI_BOX_TB_BORDER);
r11640r11641
32133212            }
32143213            break;
32153214
3215         case VIDEO_ITEM_CPANELS:
3216            if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
3217            {
3218               target->set_cpanels_enabled(!target->cpanels_enabled());
3219               changed = TRUE;
3220            }
3221            break;
3222
3223         case VIDEO_ITEM_MARQUEES:
3224            if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
3225            {
3226               target->set_marquees_enabled(!target->marquees_enabled());
3227               changed = TRUE;
3228            }
3229            break;
3230
32163231         case VIDEO_ITEM_ZOOM:
32173232            if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
32183233            {
r11640r11641
32873302   enabled = target->bezels_enabled();
32883303   ui_menu_item_append(menu, "Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS);
32893304
3305   /* cpanel item */
3306   enabled = target->cpanels_enabled();
3307   ui_menu_item_append(menu, "CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS);
3308
3309   /* marquee item */
3310   enabled = target->marquees_enabled();
3311   ui_menu_item_append(menu, "Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES);
3312
32903313   /* cropping */
32913314   enabled = target->zoom_to_screen();
32923315   ui_menu_item_append(menu, "View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM);
src/emu/video.c
r11640r11641
152152      m_snap_target->set_backdrops_enabled(false);
153153      m_snap_target->set_overlays_enabled(false);
154154      m_snap_target->set_bezels_enabled(false);
155      m_snap_target->set_cpanels_enabled(false);
156      m_snap_target->set_marquees_enabled(false);
155157      m_snap_target->set_screen_overlay_enabled(false);
156158      m_snap_target->set_zoom_to_screen(false);
157159   }
src/emu/inptport.c
r11640r11641
974974   /* detokenize into the list */
975975   (*constructor)(device, portlist, errorbuf);
976976
977   // collapse fields and sort the list
977   // collapse fields and sort the list
978978   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
979979      port->collapse_fields(errorbuf);
980980}
r11640r11641
30043004void field_config_insert(input_field_config &newfield, input_port_value &disallowedbits, astring &errorbuf)
30053005{
30063006   input_port_value lowbit;
3007   
3007
30083008   /* verify against the disallowed bits, but only if we are condition-free */
30093009   if (newfield.condition.condition == PORTCOND_ALWAYS)
30103010   {
src/emu/inptport.h
r11640r11641
706706   simple_list<input_field_config> &fieldlist() { return m_fieldlist; }
707707   const char *tag() const { return m_tag; }
708708   int modcount() const { return m_modcount; }
709   
709
710710   void bump_modcount() { m_modcount++; }
711   
711
712712   void collapse_fields(astring &errorbuf);
713713
714714   /* these fields are only valid if the port is live */
src/emu/rendlay.c
r11640r11641
16731673     m_backdrop_list(machine.respool()),
16741674     m_screen_list(machine.respool()),
16751675     m_overlay_list(machine.respool()),
1676     m_bezel_list(machine.respool())
1676     m_bezel_list(machine.respool()),
1677     m_cpanel_list(machine.respool()),
1678     m_marquee_list(machine.respool())
16771679{
16781680   // allocate a copy of the name
16791681   m_name = xml_get_attribute_string_with_subst(machine, viewnode, "name", "");
r11640r11641
17001702   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "bezel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "bezel"))
17011703      m_bezel_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
17021704
1705   // load cpanel items
1706   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "cpanel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "cpanel"))
1707      m_cpanel_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
1708
1709   // load marquee items
1710   for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "marquee"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "marquee"))
1711      m_marquee_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
1712
17031713   // recompute the data for the view based on a default layer config
17041714   recompute(render_layer_config());
17051715}
r11640r11641
17271737      case ITEM_LAYER_SCREEN:      return m_screen_list.first();
17281738      case ITEM_LAYER_OVERLAY:   return m_overlay_list.first();
17291739      case ITEM_LAYER_BEZEL:      return m_bezel_list.first();
1740      case ITEM_LAYER_CPANEL:      return m_cpanel_list.first();
1741      case ITEM_LAYER_MARQUEE:   return m_marquee_list.first();
17301742      default:               return NULL;
17311743   }
17321744}
r11640r11641
17551767         case ITEM_LAYER_BACKDROP:   m_layenabled[layer] = layerconfig.backdrops_enabled();   break;
17561768         case ITEM_LAYER_OVERLAY:   m_layenabled[layer] = layerconfig.overlays_enabled();   break;
17571769         case ITEM_LAYER_BEZEL:      m_layenabled[layer] = layerconfig.bezels_enabled();      break;
1770         case ITEM_LAYER_CPANEL:      m_layenabled[layer] = layerconfig.cpanels_enabled();   break;
1771         case ITEM_LAYER_MARQUEE:   m_layenabled[layer] = layerconfig.marquees_enabled();   break;
17581772         default:               m_layenabled[layer] = true;                        break;
17591773      }
17601774
src/emu/rendlay.h
r11640r11641
5454   ITEM_LAYER_SCREEN,
5555   ITEM_LAYER_OVERLAY,
5656   ITEM_LAYER_BEZEL,
57   ITEM_LAYER_CPANEL,
58   ITEM_LAYER_MARQUEE,
5759   ITEM_LAYER_MAX
5860};
5961DECLARE_ENUM_OPERATORS(item_layer);
r11640r11641
192194   friend class simple_list<layout_view>;
193195
194196public:
195   // an item is a single backdrop, screen, overlay, or bezel item
197   // an item is a single backdrop, screen, overlay, bezel, cpanel, or marquee item
196198   class item
197199   {
198200      friend class layout_view;
r11640r11641
243245   bool layer_enabled(item_layer layer) const { return m_layenabled[layer]; }
244246
245247   //
246   bool has_art() const { return (m_backdrop_list.count() + m_overlay_list.count() + m_bezel_list.count() != 0); }
248   bool has_art() const { return (m_backdrop_list.count() + m_overlay_list.count() + m_bezel_list.count() + m_cpanel_list.count() + m_marquee_list.count() != 0); }
247249   float effective_aspect(render_layer_config config) const { return (config.zoom_to_screen() && m_screens.count() != 0) ? m_scraspect : m_aspect; }
248250
249251   // operations
r11640r11641
264266   simple_list<item>   m_screen_list;      // list of screen items
265267   simple_list<item>   m_overlay_list;      // list of overlay items
266268   simple_list<item>   m_bezel_list;      // list of bezel items
269   simple_list<item>   m_cpanel_list;      // list of marquee items
270   simple_list<item>   m_marquee_list;      // list of marquee items
267271};
268272
269273
src/emu/render.c
r11640r11641
143143};
144144
145145// layer orders
146static const int layer_order_standard[] = { ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BACKDROP, ITEM_LAYER_BEZEL };
147static const int layer_order_alternate[] = { ITEM_LAYER_BACKDROP, ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BEZEL };
146static const int layer_order_standard[] = { ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BACKDROP, ITEM_LAYER_BEZEL, ITEM_LAYER_CPANEL, ITEM_LAYER_MARQUEE };
147static const int layer_order_alternate[] = { ITEM_LAYER_BACKDROP, ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BEZEL, ITEM_LAYER_CPANEL, ITEM_LAYER_MARQUEE };
148148
149149
150150
r11640r11641
204204inline item_layer get_layer_and_blendmode(const layout_view &view, int index, int &blendmode)
205205{
206206   //  if we have multiple backdrop pieces and no overlays, render:
207    //      backdrop (add) + screens (add) + bezels (alpha)
207    //      backdrop (add) + screens (add) + bezels (alpha) + cpanels (alpha) + marquees (alpha)
208208    //  else render:
209    //      screens (add) + overlays (RGB multiply) + backdrop (add) + bezels (alpha)
209    //      screens (add) + overlays (RGB multiply) + backdrop (add) + bezels (alpha) + cpanels (alpha) + marquees (alpha)
210210
211211    const int *layer_order = layer_order_standard;
212212   if (view.first_item(ITEM_LAYER_BACKDROP) != NULL && view.first_item(ITEM_LAYER_BACKDROP)->next() != NULL && view.first_item(ITEM_LAYER_OVERLAY) == NULL)
r11640r11641
10691069   m_base_layerconfig.set_backdrops_enabled(manager.machine().options().use_backdrops());
10701070   m_base_layerconfig.set_overlays_enabled(manager.machine().options().use_overlays());
10711071   m_base_layerconfig.set_bezels_enabled(manager.machine().options().use_bezels());
1072   m_base_layerconfig.set_cpanels_enabled(manager.machine().options().use_cpanels());
1073   m_base_layerconfig.set_marquees_enabled(manager.machine().options().use_marquees());
10721074   m_base_layerconfig.set_zoom_to_screen(manager.machine().options().artwork_crop());
10731075
10741076   // determine the base orientation based on options
r11640r11641
21012103   if (tmpint == 0 || tmpint == 1)
21022104      set_bezels_enabled(tmpint);
21032105
2106   tmpint = xml_get_attribute_int(&targetnode, "cpanels", -1);
2107   if (tmpint == 0 || tmpint == 1)
2108      set_cpanels_enabled(tmpint);
2109
2110   tmpint = xml_get_attribute_int(&targetnode, "marquees", -1);
2111   if (tmpint == 0 || tmpint == 1)
2112      set_marquees_enabled(tmpint);
2113
21042114   tmpint = xml_get_attribute_int(&targetnode, "zoom", -1);
21052115   if (tmpint == 0 || tmpint == 1)
21062116      set_zoom_to_screen(tmpint);
r11640r11641
21582168      xml_set_attribute_int(&targetnode, "backdrops", m_layerconfig.backdrops_enabled());
21592169      xml_set_attribute_int(&targetnode, "overlays", m_layerconfig.overlays_enabled());
21602170      xml_set_attribute_int(&targetnode, "bezels", m_layerconfig.bezels_enabled());
2171      xml_set_attribute_int(&targetnode, "cpanels", m_layerconfig.cpanels_enabled());
2172      xml_set_attribute_int(&targetnode, "marquees", m_layerconfig.marquees_enabled());
21612173      xml_set_attribute_int(&targetnode, "zoom", m_layerconfig.zoom_to_screen());
21622174      changed = true;
21632175   }
src/emu/render.h
r11640r11641
290290   static const UINT8 ENABLE_BACKDROP         = 0x01;   // enable backdrop layers
291291   static const UINT8 ENABLE_OVERLAY         = 0x02;   // enable overlay layers
292292   static const UINT8 ENABLE_BEZEL            = 0x04;   // enable bezel layers
293   static const UINT8 ZOOM_TO_SCREEN         = 0x08;   // zoom to screen area by default
294   static const UINT8 ENABLE_SCREEN_OVERLAY   = 0x10;   // enable screen overlays
295   static const UINT8 DEFAULT = ENABLE_BACKDROP | ENABLE_OVERLAY | ENABLE_BEZEL | ENABLE_SCREEN_OVERLAY;
293   static const UINT8 ENABLE_CPANEL         = 0x08;   // enable cpanel layers
294   static const UINT8 ENABLE_MARQUEE         = 0x10;   // enable marquee layers
295   static const UINT8 ZOOM_TO_SCREEN         = 0x20;   // zoom to screen area by default
296   static const UINT8 ENABLE_SCREEN_OVERLAY   = 0x40;   // enable screen overlays
297   static const UINT8 DEFAULT = ENABLE_BACKDROP | ENABLE_OVERLAY | ENABLE_BEZEL | ENABLE_CPANEL | ENABLE_MARQUEE | ENABLE_SCREEN_OVERLAY;
296298
297299public:
298300   render_layer_config()
r11640r11641
304306   bool backdrops_enabled() const { return ((m_state & ENABLE_BACKDROP) != 0); }
305307   bool overlays_enabled() const { return ((m_state & ENABLE_OVERLAY) != 0); }
306308   bool bezels_enabled() const { return ((m_state & ENABLE_BEZEL) != 0); }
309   bool cpanels_enabled() const { return ((m_state & ENABLE_CPANEL) != 0); }
310   bool marquees_enabled() const { return ((m_state & ENABLE_MARQUEE) != 0); }
307311   bool screen_overlay_enabled() const { return ((m_state & ENABLE_SCREEN_OVERLAY) != 0); }
308312   bool zoom_to_screen() const { return ((m_state & ZOOM_TO_SCREEN) != 0); }
309313
310314   render_layer_config &set_backdrops_enabled(bool enable) { if (enable) m_state |= ENABLE_BACKDROP; else m_state &= ~ENABLE_BACKDROP; return *this; }
311315   render_layer_config &set_overlays_enabled(bool enable) { if (enable) m_state |= ENABLE_OVERLAY; else m_state &= ~ENABLE_OVERLAY; return *this; }
312316   render_layer_config &set_bezels_enabled(bool enable) { if (enable) m_state |= ENABLE_BEZEL; else m_state &= ~ENABLE_BEZEL; return *this; }
317   render_layer_config &set_cpanels_enabled(bool enable) { if (enable) m_state |= ENABLE_CPANEL; else m_state &= ~ENABLE_CPANEL; return *this; }
318   render_layer_config &set_marquees_enabled(bool enable) { if (enable) m_state |= ENABLE_MARQUEE; else m_state &= ~ENABLE_MARQUEE; return *this; }
313319   render_layer_config &set_screen_overlay_enabled(bool enable) { if (enable) m_state |= ENABLE_SCREEN_OVERLAY; else m_state &= ~ENABLE_SCREEN_OVERLAY; return *this; }
314320   render_layer_config &set_zoom_to_screen(bool zoom) { if (zoom) m_state |= ZOOM_TO_SCREEN; else m_state &= ~ZOOM_TO_SCREEN; return *this; }
315321
r11640r11641
625631   bool backdrops_enabled() const { return m_layerconfig.backdrops_enabled(); }
626632   bool overlays_enabled() const { return m_layerconfig.overlays_enabled(); }
627633   bool bezels_enabled() const { return m_layerconfig.bezels_enabled(); }
634   bool cpanels_enabled() const { return m_layerconfig.cpanels_enabled(); }
635   bool marquees_enabled() const { return m_layerconfig.marquees_enabled(); }
628636   bool screen_overlay_enabled() const { return m_layerconfig.screen_overlay_enabled(); }
629637   bool zoom_to_screen() const { return m_layerconfig.zoom_to_screen(); }
630638
r11640r11641
632640   void set_backdrops_enabled(bool enable) { m_layerconfig.set_backdrops_enabled(enable); update_layer_config(); }
633641   void set_overlays_enabled(bool enable) { m_layerconfig.set_overlays_enabled(enable); update_layer_config(); }
634642   void set_bezels_enabled(bool enable) { m_layerconfig.set_bezels_enabled(enable); update_layer_config(); }
643   void set_cpanels_enabled(bool enable) { m_layerconfig.set_cpanels_enabled(enable); update_layer_config(); }
644   void set_marquees_enabled(bool enable) { m_layerconfig.set_marquees_enabled(enable); update_layer_config(); }
635645   void set_screen_overlay_enabled(bool enable) { m_layerconfig.set_screen_overlay_enabled(enable); update_layer_config(); }
636646   void set_zoom_to_screen(bool zoom) { m_layerconfig.set_zoom_to_screen(zoom); update_layer_config(); }
637647
src/emu/machine/k053252.c
r11640r11641
22
33    Konami 053252 chip emulation, codenamed "CCU"
44
5   device emulation by Angelo Salese, based off notes by Olivier Galibert
5    device emulation by Angelo Salese, based off notes by Olivier Galibert
66
77============================================================================================================================
88
r11640r11641
2525
2626(*) hblank duration 512 (0x200), hdisp 384 (0x180), vblank duration 288 (0x120), vdisp 256 (0x100)
2727
28    Definitions from GX, look similar, all values big-endian, write-only:
28    Definitions from GX, look similar, all values big-endian, write-only:
2929
30   0-1: bits 9-0: HC        - Total hblank duration (-1)     Hres ~ (HC+1) - HFP - HBP - 8*(HSW+1)
31   2-3: bits 8-0: HFP       - HBlank front porch
32   4-5: bits 8-0: HBP       - HBlank back porch
33   6  : bits 7-0: INT1EN
34   7  : bits 7-0: INT2EN
35   8-9: bits 8-0: VC        - Total vblank duration
36   a  : bits 7-0: VFP       - VBlank front porch             Vres ~ VC - VFP - VBP - (VSW+1)
37   b  : bits 7-0: VBP       - VBlank back porch
38   c  : bits 7-4: VSW       - V-Sync Width
39   c  : bits 3-0: HSW       - H-Sync Width
40   d  : bits 7-0: INT-TIME
41   e  : bits 7-0: INT1ACK
42   f  : bits 7-0: INT2ACK
30    0-1: bits 9-0: HC        - Total hblank duration (-1)     Hres ~ (HC+1) - HFP - HBP - 8*(HSW+1)
31    2-3: bits 8-0: HFP       - HBlank front porch
32    4-5: bits 8-0: HBP       - HBlank back porch
33    6  : bits 7-0: INT1EN
34    7  : bits 7-0: INT2EN
35    8-9: bits 8-0: VC        - Total vblank duration
36    a  : bits 7-0: VFP       - VBlank front porch             Vres ~ VC - VFP - VBP - (VSW+1)
37    b  : bits 7-0: VBP       - VBlank back porch
38    c  : bits 7-4: VSW       - V-Sync Width
39    c  : bits 3-0: HSW       - H-Sync Width
40    d  : bits 7-0: INT-TIME
41    e  : bits 7-0: INT1ACK
42    f  : bits 7-0: INT2ACK
4343
44    Read-only:
45   e-f: bits 8-0: VCT
44     Read-only:
45    e-f: bits 8-0: VCT
4646
4747TODO:
4848- xexex sets up 0x20 as the VC? default value?
src/emu/machine/k053252.h
r11640r11641
1919   devcb_write_line   int2_en;
2020   devcb_write_line   int1_ack;
2121   devcb_write_line   int2_ack;
22//   devcb_write8       int_time;
22//  devcb_write8       int_time;
2323   int                offsx;
2424   int                offsy;
2525};
src/emu/driver.h
r11640r11641
100100   const char *      year;                  /* year the game was released */
101101   const char *      manufacturer;            /* manufacturer of the game */
102102   machine_config_constructor machine_config;      /* machine driver tokens */
103   ioport_constructor    ipt;               /* pointer to array of input port tokens */
103   ioport_constructor   ipt;               /* pointer to array of input port tokens */
104104   void            (*driver_init)(running_machine &machine); /* DRIVER_INIT callback */
105105   const rom_entry *   rom;                  /* pointer to list of ROMs for the game */
106106   const char *      compatible_with;
src/emu/delegate.h
r11640r11641
421421   static delegate_generic_class *late_bind_helper(delegate_late_bind &object)
422422   {
423423      return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_FunctionClass *>(&object));
424   }
424   }
425425
426426   // internal state
427427   const char *            m_name;            // name string
r11640r11641
593593      if (m_object != NULL && m_rawfunction.m_function != 0)
594594         m_function = reinterpret_cast<generic_static_func>(m_rawfunction.convert_to_generic(m_object));
595595   }
596   
596
597597   // late binding helper
598598   template<class _FunctionClass>
599599   static delegate_generic_class *late_bind_helper(delegate_late_bind &object)
600600   {
601601      return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_FunctionClass *>(&object));
602   }
602   }
603603
604604   // internal state
605605   const char *            m_name;            // name string
src/emu/mconfig.c
r11640r11641
7575      const slot_interface *intf = slot->get_slot_interfaces();
7676      if (intf != NULL)
7777      {
78         const char *selval = options.value(owner.tag());         
79         if (options.seqid(owner.tag())==0) {     
78         const char *selval = options.value(owner.tag());
79         if (options.seqid(owner.tag())==0) {
8080            selval = slot->get_default_card();
8181         }
8282         if (selval) {
src/version.c
r11640r11641
3838***************************************************************************/
3939
4040extern const char build_version[];
41const char build_version[] = "0.142u3 ("__DATE__")";
41const char build_version[] = "0.142u4 ("__DATE__")";
docs/hlsl.txt
r0r11641
1HLSL-Related Enable Switches
2----------------------------
3
4Name                    Values      Description
5hlsl_enable             0/1             Enables HLSL post-processing in Direct3D 9 modes.
6yiq_enable              0/1             Enables YIQ-colorspace post-processing. Causes a
7                                        performance drop but gives a much more authentic
8                                        NTSC TV appearance on TV-based systems when configured
9                                        properly.
10hlslpath                [path]          Path to the .fx files that are in use.
11
12
13Color-Processing Parameters
14---------------------------
15
16Name                    Values      Description
17red_from_r              -2.0 to 2.0     These parameters define a 3x3 matrix which is multiplied
18red_from_g              -2.0 to 2.0     by the incoming RGB signal. This can be used for any
19red_from_b              -2.0 to 2.0     standard matrix convolution, including H/S/V or simply
20green_from_r            -2.0 to 2.0     affecting the TV-style tint.
21green_from_g            -2.0 to 2.0     
22green_from_b            -2.0 to 2.0     
23blue_from_r             -2.0 to 2.0     
24blue_from_g             -2.0 to 2.0     
25blue_from_b             -2.0 to 2.0     
26red_scale               -2.0 to 2.0     These parameters define a value for each color channel
27green_scale             -2.0 to 2.0     that is multiplied with said channel after matrix
28blue_scale              -2.0 to 2.0     convolution.
29red_offset              -1.0 to 1.0     These parameters define a value for each color channel
30green_offset            -1.0 to 1.0     that is added to said channel after scaling and after
31blue_offset             -1.0 to 1.0     matrix convolution.
32saturation               0.0 to 4.0     This parameter defines the amount each color channel is
33                                        raised above said channel's baseline grayscale value.
34                                        A value of 0.0 gives a gamma-correct grayscale image,
35                                        whereas 1.0 is full saturation, with each channel being
36                                        oversaturated equally beyond that.
37red_power               -4.0 to 4.0     These parameters define the exponent for each color
38green_power             -4.0 to 4.0     channel that is applied after scaling, offsetting,
39blue_power              -4.0 to 4.0     saturation and matrix convolution.
40red_floor                0.0 to 1.0     These parameters define the lower limit of each final
41green_floor              0.0 to 1.0     color channel value; 0.05, for example, raises the
42blue_floor               0.0 to 1.0     minimum to 0.05 but re-scales to leave the max at 1.0.
43
44
45Convergence-Processing Parameters
46---------------------------------
47
48Name                    Values      Description
49red_converge_x          -150 to 150     These parameters define the overall convergence, in pixel
50red_converge_y          -150 to 150     space, for each channel. Radial convergence occurs
51green_converge_x        -150 to 150     relative to the center of the screen, whereas the other
52green_converge_y        -150 to 150     six define overall translation values.
53blue_converge_x         -150 to 150     
54blue_converge_y         -150 to 150     
55red_radial_converge_x   -150 to 150     
56red_radial_converge_y   -150 to 150     
57green_radial_converge_x -150 to 150     
58green_radial_converge_y -150 to 150     
59blue_radial_converge_x  -150 to 150     
60blue_radial_converge_y  -150 to 150     
61defocus_x                0.0 to 32.0    These parameters define the overall defocus radius for
62defocus_y                0.0 to 32.0    the three post-converged beams.
63
64
65Front-Surface Processing Parameters
66-----------------------------------
67
68Name                    Values      Description
69red_phosphor_life        0.0 to 1.0     These parameters define the phosphor lifetime for each
70green_phosphor_life      0.0 to 1.0     channel, with 0.0 representing no phosphorescence and
71blue_phosphor_life       0.0 to 1.0     1.0 leaving the channel on indefinitely.
72scanline_alpha           0.0 to 1.0     The overall darkness of each scanline furrow.
73scanline_size            0.0 to 4.0     The overall height of each scanline.
74scanline_bright_scale    0.0 to 2.0     The overall brightness multiplier for each scanline.
75scanline_bright_offset   0.0 to 1.0     The overall brightness additive value for each scanline.
76scanline_jitter          0.0 to 2.0     The relative scanline movement per field.
77shadow_mask_alpha        0.0 to 1.0     The ovearll darkness of each shadow mask pixel.
78shadow_mask_texture      [filename]     A PNG that defines the shadow mask for each pixel.
79shadow_mask_x_count      1+             The count of shadow mask elements, X (usually 640-ish)
80shadow_mask_y_count      1+             The count of shadow mask elements, X (usually 480-ish)
81shadow_mask_usize        0.0 to 1.0     These parameters define the *in-use* pixel count on the
82shadow_mask_vsize        0.0 to 1.0     X and Y axes of the shadow mask texture.
83curvature                0.0 to 1.0     Screen curvature. Affects borders and shadow mask.
84pincushion               0.0 to 1.0     Image curvature. Affects the source image only.
85oversample_x             1.0 to 4.0     These parameters define a multiplier for each axis of the
86oversample_y             1.0 to 4.0     internal render target. Powerful GPU necessary.
87
88
89NTSC Processing Parameters
90--------------------------
91
92Name                    Values      Description
93yiq_w                    4.1187867      W parameter for: C(t) = Y(t) + I(t)sin(Wt) + Q(t)cos(Wt)
94yiq_a                    0.0            A parameter for: t = x + ay + b;
95yiq_b                    0.5            B parameter for: t = x + ay + b;
96yiq_fsc                  1.5            Relative color subcarrier frequency
97yiq_fsc_scale            1.0            Color subcarrier frequency scale
98yiq_phase_count          2              Number of frames for NTSC processing (3 for NES, else 2)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team