Previous 199869 Revisions Next

r36145 Saturday 28th February, 2015 at 16:34:22 UTC by Couriersud
Fix mame restart (builtin game selector) in draw13.c. [CourierSud]
[src/mame/drivers]flyball.c
[src/osd/modules/render]draw13.c

trunk/src/mame/drivers/flyball.c
r244656r244657
2828public:
2929   enum
3030   {
31      TIMER_POT_ASSERT,
32      TIMER_POT_CLEAR,
33      TIMER_QUARTER
31      TIMER_FLYBALL_POT_ASSERT,
32      TIMER_FLYBALL_POT_CLEAR,
33      TIMER_FLYBALL_QUARTER
3434   };
3535
3636   flyball_state(const machine_config &mconfig, device_type type, const char *tag)
3737      : driver_device(mconfig, type, tag),
38      m_playfield_ram(*this, "playfield_ram"),
3839      m_maincpu(*this, "maincpu"),
3940      m_gfxdecode(*this, "gfxdecode"),
4041      m_screen(*this, "screen"),
41      m_palette(*this, "palette"),
42      m_playfield_ram(*this, "playfield_ram") { }
42      m_palette(*this, "palette") { }
4343
44   /* devices */
45   required_device<cpu_device> m_maincpu;
46   required_device<gfxdecode_device> m_gfxdecode;
47   required_device<screen_device> m_screen;
48   required_device<palette_device> m_palette;
49
5044   /* memory pointers */
5145   required_shared_ptr<UINT8> m_playfield_ram;
5246
r244656r244657
6155   /* misc */
6256   UINT8    m_potmask;
6357   UINT8    m_potsense;
64   
65   emu_timer *m_pot_clear_timer;
66   emu_timer *m_quarter_timer;
67   
68   DECLARE_READ8_MEMBER(input_r);
69   DECLARE_READ8_MEMBER(scanline_r);
70   DECLARE_READ8_MEMBER(potsense_r);
71   DECLARE_WRITE8_MEMBER(potmask_w);
72   DECLARE_WRITE8_MEMBER(pitcher_pic_w);
73   DECLARE_WRITE8_MEMBER(ball_vert_w);
74   DECLARE_WRITE8_MEMBER(ball_horz_w);
75   DECLARE_WRITE8_MEMBER(pitcher_vert_w);
76   DECLARE_WRITE8_MEMBER(pitcher_horz_w);
77   DECLARE_WRITE8_MEMBER(misc_w);
78   
79   TILEMAP_MAPPER_MEMBER(get_memory_offset);
80   TILE_GET_INFO_MEMBER(get_tile_info);
81   
58
59   /* devices */
60   required_device<cpu_device> m_maincpu;
61   required_device<gfxdecode_device> m_gfxdecode;
62   required_device<screen_device> m_screen;
63   required_device<palette_device> m_palette;
64
65   DECLARE_READ8_MEMBER(flyball_input_r);
66   DECLARE_READ8_MEMBER(flyball_scanline_r);
67   DECLARE_READ8_MEMBER(flyball_potsense_r);
68   DECLARE_WRITE8_MEMBER(flyball_potmask_w);
69   DECLARE_WRITE8_MEMBER(flyball_pitcher_pic_w);
70   DECLARE_WRITE8_MEMBER(flyball_ball_vert_w);
71   DECLARE_WRITE8_MEMBER(flyball_ball_horz_w);
72   DECLARE_WRITE8_MEMBER(flyball_pitcher_vert_w);
73   DECLARE_WRITE8_MEMBER(flyball_pitcher_horz_w);
74   DECLARE_WRITE8_MEMBER(flyball_misc_w);
75   TILEMAP_MAPPER_MEMBER(flyball_get_memory_offset);
76   TILE_GET_INFO_MEMBER(flyball_get_tile_info);
8277   virtual void machine_start();
8378   virtual void machine_reset();
8479   virtual void video_start();
8580   DECLARE_PALETTE_INIT(flyball);
86   
87   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
88   
89   TIMER_CALLBACK_MEMBER(joystick_callback);
90   TIMER_CALLBACK_MEMBER(quarter_callback);
81   UINT32 screen_update_flyball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
82   TIMER_CALLBACK_MEMBER(flyball_joystick_callback);
83   TIMER_CALLBACK_MEMBER(flyball_quarter_callback);
9184
9285protected:
9386   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
r244656r244657
10093 *
10194 *************************************/
10295
103TILEMAP_MAPPER_MEMBER(flyball_state::get_memory_offset)
96TILEMAP_MAPPER_MEMBER(flyball_state::flyball_get_memory_offset)
10497{
10598   if (col == 0)
10699      col = num_cols;
r244656r244657
109102}
110103
111104
112TILE_GET_INFO_MEMBER(flyball_state::get_tile_info)
105TILE_GET_INFO_MEMBER(flyball_state::flyball_get_tile_info)
113106{
114107   UINT8 data = m_playfield_ram[tile_index];
115108   int flags = ((data & 0x40) ? TILE_FLIPX : 0) | ((data & 0x80) ? TILE_FLIPY : 0);
r244656r244657
124117
125118void flyball_state::video_start()
126119{
127   m_tmap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(flyball_state::get_tile_info),this), tilemap_mapper_delegate(FUNC(flyball_state::get_memory_offset),this), 8, 16, 32, 16);
120   m_tmap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(flyball_state::flyball_get_tile_info),this), tilemap_mapper_delegate(FUNC(flyball_state::flyball_get_memory_offset),this), 8, 16, 32, 16);
128121}
129122
130123
131UINT32 flyball_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
124UINT32 flyball_state::screen_update_flyball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
132125{
133126   int pitcherx = m_pitcher_horz;
134127   int pitchery = m_pitcher_vert - 31;
r244656r244657
158151{
159152   switch (id)
160153   {
161   case TIMER_POT_ASSERT:
162      joystick_callback(ptr, param);
154   case TIMER_FLYBALL_POT_ASSERT:
155      flyball_joystick_callback(ptr, param);
163156      break;
164   case TIMER_POT_CLEAR:
157   case TIMER_FLYBALL_POT_CLEAR:
165158      m_maincpu->set_input_line(0, CLEAR_LINE);
166159      break;
167   case TIMER_QUARTER:
168      quarter_callback(ptr, param);
160   case TIMER_FLYBALL_QUARTER:
161      flyball_quarter_callback(ptr, param);
169162      break;
170163
171164   default:
r244656r244657
174167}
175168
176169
177TIMER_CALLBACK_MEMBER(flyball_state::joystick_callback)
170TIMER_CALLBACK_MEMBER(flyball_state::flyball_joystick_callback)
178171{
179172   int potsense = param;
180173
r244656r244657
182175   {
183176      // pot irq is active at hsync
184177      m_maincpu->set_input_line(0, ASSERT_LINE);
185      m_pot_clear_timer->adjust(attotime::from_ticks(32, PIXEL_CLOCK), 0);
178      timer_set(attotime::from_ticks(32, PIXEL_CLOCK), TIMER_FLYBALL_POT_CLEAR, 0);
186179   }
187180
188181   m_potsense |= potsense;
189182}
190183
191184
192TIMER_CALLBACK_MEMBER(flyball_state::quarter_callback)
185TIMER_CALLBACK_MEMBER(flyball_state::flyball_quarter_callback)
193186{
194187   int scanline = param;
195188   int potsense[64], i;
r244656r244657
203196
204197   for (i = 0; i < 64; i++)
205198      if (potsense[i] != 0)
206         timer_set(m_screen->time_until_pos(scanline + i), TIMER_POT_ASSERT, potsense[i]);
199         timer_set(m_screen->time_until_pos(scanline + i), TIMER_FLYBALL_POT_ASSERT, potsense[i]);
207200
208201   scanline += 0x40;
209202   scanline &= 0xff;
210203
211   m_quarter_timer->adjust(m_screen->time_until_pos(scanline), scanline);
204   timer_set(m_screen->time_until_pos(scanline), TIMER_FLYBALL_QUARTER, scanline);
212205
213206   m_potsense = 0;
214207   m_potmask = 0;
r244656r244657
222215 *************************************/
223216
224217/* two physical buttons (start game and stop runner) share the same port bit */
225READ8_MEMBER(flyball_state::input_r)
218READ8_MEMBER(flyball_state::flyball_input_r)
226219{
227220   return ioport("IN0")->read() & ioport("IN1")->read();
228221}
229222
230READ8_MEMBER(flyball_state::scanline_r)
223READ8_MEMBER(flyball_state::flyball_scanline_r)
231224{
232225   return m_screen->vpos() & 0x3f;
233226}
234227
235READ8_MEMBER(flyball_state::potsense_r)
228READ8_MEMBER(flyball_state::flyball_potsense_r)
236229{
237230   return m_potsense & ~m_potmask;
238231}
239232
240WRITE8_MEMBER(flyball_state::potmask_w)
233WRITE8_MEMBER(flyball_state::flyball_potmask_w)
241234{
242235   m_potmask |= data & 0xf;
243236}
244237
245WRITE8_MEMBER(flyball_state::pitcher_pic_w)
238WRITE8_MEMBER(flyball_state::flyball_pitcher_pic_w)
246239{
247240   m_pitcher_pic = data & 0xf;
248241}
249242
250WRITE8_MEMBER(flyball_state::ball_vert_w)
243WRITE8_MEMBER(flyball_state::flyball_ball_vert_w)
251244{
252245   m_ball_vert = data;
253246}
254247
255WRITE8_MEMBER(flyball_state::ball_horz_w)
248WRITE8_MEMBER(flyball_state::flyball_ball_horz_w)
256249{
257250   m_ball_horz = data;
258251}
259252
260WRITE8_MEMBER(flyball_state::pitcher_vert_w)
253WRITE8_MEMBER(flyball_state::flyball_pitcher_vert_w)
261254{
262255   m_pitcher_vert = data;
263256}
264257
265WRITE8_MEMBER(flyball_state::pitcher_horz_w)
258WRITE8_MEMBER(flyball_state::flyball_pitcher_horz_w)
266259{
267260   m_pitcher_horz = data;
268261}
269262
270WRITE8_MEMBER(flyball_state::misc_w)
263WRITE8_MEMBER(flyball_state::flyball_misc_w)
271264{
272265   int bit = ~data & 1;
273266
r244656r244657
305298   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
306299   AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x100) AM_RAM
307300   AM_RANGE(0x0800, 0x0800) AM_NOP
308   AM_RANGE(0x0801, 0x0801) AM_WRITE(pitcher_pic_w)
309   AM_RANGE(0x0802, 0x0802) AM_READ(scanline_r)
310   AM_RANGE(0x0803, 0x0803) AM_READ(potsense_r)
311   AM_RANGE(0x0804, 0x0804) AM_WRITE(ball_vert_w)
312   AM_RANGE(0x0805, 0x0805) AM_WRITE(ball_horz_w)
313   AM_RANGE(0x0806, 0x0806) AM_WRITE(pitcher_vert_w)
314   AM_RANGE(0x0807, 0x0807) AM_WRITE(pitcher_horz_w)
315   AM_RANGE(0x0900, 0x0900) AM_WRITE(potmask_w)
316   AM_RANGE(0x0a00, 0x0a07) AM_WRITE(misc_w)
317   AM_RANGE(0x0b00, 0x0b00) AM_READ(input_r)
301   AM_RANGE(0x0801, 0x0801) AM_WRITE(flyball_pitcher_pic_w)
302   AM_RANGE(0x0802, 0x0802) AM_READ(flyball_scanline_r)
303   AM_RANGE(0x0803, 0x0803) AM_READ(flyball_potsense_r)
304   AM_RANGE(0x0804, 0x0804) AM_WRITE(flyball_ball_vert_w)
305   AM_RANGE(0x0805, 0x0805) AM_WRITE(flyball_ball_horz_w)
306   AM_RANGE(0x0806, 0x0806) AM_WRITE(flyball_pitcher_vert_w)
307   AM_RANGE(0x0807, 0x0807) AM_WRITE(flyball_pitcher_horz_w)
308   AM_RANGE(0x0900, 0x0900) AM_WRITE(flyball_potmask_w)
309   AM_RANGE(0x0a00, 0x0a07) AM_WRITE(flyball_misc_w)
310   AM_RANGE(0x0b00, 0x0b00) AM_READ(flyball_input_r)
318311   AM_RANGE(0x0d00, 0x0eff) AM_WRITEONLY AM_SHARE("playfield_ram")
319312   AM_RANGE(0x1000, 0x1fff) AM_ROM AM_REGION("maincpu", 0)
320313ADDRESS_MAP_END
r244656r244657
428421   for (int i = 0; i < len; i++)
429422      buf[i ^ 0x1ff] = ROM[i];
430423   memcpy(ROM, buf, len);
431   
432   m_pot_clear_timer = timer_alloc(TIMER_POT_CLEAR);
433   m_quarter_timer = timer_alloc(TIMER_QUARTER);
434424
435425   save_item(NAME(m_pitcher_vert));
436426   save_item(NAME(m_pitcher_horz));
r244656r244657
443433
444434void flyball_state::machine_reset()
445435{
446   m_quarter_timer->adjust(m_screen->time_until_pos(0));
436   timer_set(m_screen->time_until_pos(0), TIMER_FLYBALL_QUARTER);
447437
448438   m_pitcher_vert = 0;
449439   m_pitcher_horz = 0;
r244656r244657
467457   MCFG_SCREEN_REFRESH_RATE(60)
468458   MCFG_SCREEN_SIZE(256, 262)
469459   MCFG_SCREEN_VISIBLE_AREA(0, 255, 0, 239)
470   MCFG_SCREEN_UPDATE_DRIVER(flyball_state, screen_update)
460   MCFG_SCREEN_UPDATE_DRIVER(flyball_state, screen_update_flyball)
471461   MCFG_SCREEN_PALETTE("palette")
472462
473463   MCFG_GFXDECODE_ADD("gfxdecode", "palette", flyball)
r244656r244657
535525 *
536526 *************************************/
537527
538GAME( 1976, flyball,  0,       flyball, flyball, driver_device, 0, 0, "Atari", "Flyball (rev 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
539GAME( 1976, flyball1, flyball, flyball, flyball, driver_device, 0, 0, "Atari", "Flyball (rev 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
528GAME( 1976, flyball,  0,       flyball, flyball, driver_device, 0, 0, "Atari", "Flyball (rev 2)", GAME_NO_SOUND )
529GAME( 1976, flyball1, flyball, flyball, flyball, driver_device, 0, 0, "Atari", "Flyball (rev 1)", GAME_NO_SOUND )
trunk/src/osd/modules/render/draw13.c
r244656r244657
8787{
8888   friend class simple_list<texture_info>;
8989public:
90   texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
90   texture_info(sdl_info13 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
9191   ~texture_info();
9292
9393   void set_data(const render_texinfo &texsource, const UINT32 flags);
r244656r244657
118118
119119private:
120120   Uint32              m_sdl_access;
121   SDL_Renderer *      m_sdl_renderer;
121   sdl_info13 *         m_renderer;
122122   render_texinfo      m_texinfo;            // copy of the texture info
123123   HashT               m_hash;               // hash value for the texture (must be >= pointer size)
124124   UINT32              m_flags;              // rendering flags
r244656r244657
143143{
144144public:
145145   sdl_info13(osd_window *w)
146   : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL),
146   : osd_renderer(w, FLAG_NONE), m_sdl_renderer(NULL), m_blittimer(0),
147147      m_last_hofs(0), m_last_vofs(0),
148148      m_width(0), m_height(0),
149149      m_blit_dim(0,0),
150150      m_last_blit_time(0), m_last_blit_pixels(0)
151   {}
151   {
152      for (int i=0; i < 30; i++)
153      {
154         fmt_support[i].format = 0;
155         fmt_support[i].status = 0;
156      }
157   }
152158
153159   /* virtual */ int create();
154160   /* virtual */ int draw(const int update);
r244656r244657
165171      window().target()->set_bounds(m_blit_dim.width(), m_blit_dim.height(), window().aspect());
166172      return &window().target()->get_primitives();
167173   }
174   int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat);
168175
176   SDL_Renderer *  m_sdl_renderer;
177
169178private:
170179   void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
171180
r244656r244657
183192   SDL_Surface         *m_sdlsurf;
184193#endif
185194
186   SDL_Renderer *  m_sdl_renderer;
187195   simple_list<texture_info>  m_texlist;                // list of active textures
188196
189197   float           m_last_hofs;
r244656r244657
194202
195203   osd_dim         m_blit_dim;
196204
205   struct
206   {
207      Uint32  format;
208      int     status;
209   } fmt_support[30];
210
197211   // Stats
198212   INT64           m_last_blit_time;
199213   INT64           m_last_blit_pixels;
r244656r244657
317331
318332static copy_info_t *blit_info[SDL_TEXFORMAT_LAST+1];
319333
320static struct
321{
322   Uint32  format;
323   int     status;
324} fmt_support[30] = { { 0, 0 } };
325
326
327334//============================================================
328335//  INLINES
329336//============================================================
r244656r244657
400407
401408   SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode);
402409   set_coloralphamode(m_texture_id, &prim->color);
403   SDL_RenderCopy(m_sdl_renderer,  m_texture_id, NULL, &target_rect);
410   SDL_RenderCopy(m_renderer->m_sdl_renderer,  m_texture_id, NULL, &target_rect);
404411}
405412
406413void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
r244656r244657
440447   }
441448}
442449
443static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat)
450int sdl_info13::RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat)
444451{
445452   int i;
446453   SDL_Texture *texid;
r244656r244657
454461   /* not tested yet */
455462   fmt_support[i].format = format;
456463   fmt_support[i + 1].format = 0;
457   texid = SDL_CreateTexture(renderer, format, access, 16, 16);
464   texid = SDL_CreateTexture(m_sdl_renderer, format, access, 16, 16);
458465   if (texid)
459466   {
460467      fmt_support[i].status = 1;
r244656r244657
545552   int i;
546553   copy_info_t *bi, *freeme;
547554   for (i = 0; i <= SDL_TEXFORMAT_LAST; i++)
555   {
548556      for (bi = blit_info[i]; bi != NULL; )
549557      {
550558         if (bi->pixel_count)
r244656r244657
555563         bi = bi->next;
556564         global_free(freeme);
557565      }
566      blit_info[i] = NULL;
567   }
558568}
559569
560570//============================================================
r244656r244657
796806      if ((m_is_rotated == bi->blitter->m_is_rot)
797807            && (m_sdl_blendmode == bi->bm_mask))
798808      {
799         if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
809         if (m_renderer->RendererSupportsFormat(bi->dst_fmt, m_sdl_access, bi->dstname))
800810         {
801811            int perf = bi->perf;
802812            if (perf == 0)
r244656r244657
816826   {
817827      if ((m_is_rotated == bi->blitter->m_is_rot)
818828         && (m_sdl_blendmode == bi->bm_mask))
819         if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
829         if (m_renderer->RendererSupportsFormat(bi->dst_fmt, m_sdl_access, bi->dstname))
820830            return bi;
821831   }
822832   //FIXME: crash implement a -do nothing handler */
r244656r244657
851861//  texture_create
852862//============================================================
853863
854texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags)
864texture_info::texture_info(sdl_info13 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags)
855865{
856866   // fill in the core data
857   m_sdl_renderer = renderer;
867   m_renderer = renderer;
858868   m_hash = texture_compute_hash(texsource, flags);
859869   m_flags = flags;
860870   m_texinfo = texsource;
r244656r244657
903913
904914   m_copyinfo = compute_size_type();
905915
906   m_texture_id = SDL_CreateTexture(m_sdl_renderer, m_copyinfo->dst_fmt, m_sdl_access,
916   m_texture_id = SDL_CreateTexture(m_renderer->m_sdl_renderer, m_copyinfo->dst_fmt, m_sdl_access,
907917         m_setup.rotwidth, m_setup.rotheight);
908918
909919   if (!m_texture_id)
r244656r244657
10761086   // if we didn't find one, create a new texture
10771087   if (texture == NULL && prim.texture.base != NULL)
10781088   {
1079      texture = global_alloc(texture_info(m_sdl_renderer, prim.texture, setup, prim.flags));
1089      texture = global_alloc(texture_info(this, prim.texture, setup, prim.flags));
10801090      /* add us to the texture list */
10811091      m_texlist.prepend(*texture);
10821092


Previous 199869 Revisions Next


© 1997-2024 The MAME Team