Previous 15994 Revisions Next

r14064 Monday 16th January, 2012 at 15:30:02 UTC by Miodrag Milanović
Sync with MAME r15054 (nw)
[src/emu]delegate.h drawgfxm.h info.c machine.c machine.h render.c render.h rendfont.c rendlay.c screen.c screen.h softlist.c tilemap.c tilemap.h ui.c uigfx.c
[src/emu/cpu/arm7]arm7.c arm7ops.c arm7ops.h arm7thmb.c
[src/emu/cpu/i386]i386.c i386priv.h
[src/emu/cpu/tms34010]tms34010.c
[src/emu/debugint]debugint.c
[src/emu/drivers]empty.c testcpu.c
[src/emu/imagedev]cartslot.h
[src/emu/machine]idectrl.c laserdsc.c laserdsc.h ldpr8210.c ldv1000.c ldvp931.c s3c24xx.c
[src/emu/sound]cdp1869.c
[src/emu/video]crt9007.c hd44102.c i8275.c mc6845.c pc_vga.c psx.c s2636.c tms9927.c upd3301.c v9938.c v9938.h vector.c voodoo.c
[src/lib/formats]ap_dsk35.c
[src/lib/util]bitmap.c bitmap.h
[src/mame]mame.lst mame.mak
[src/mame/drivers]alg.c aristmk6.c atarisy4.c bingor.c ccastles.c cloud9.c cps3.c cybertnk.c dlair.c flyball.c gei.c gpworld.c gunpey.c highvdeo.c hng64.c ichiban.c* igs009.c igs011.c itgambl2.c itgambl3.c jackie.c jantotsu.c kingdrby.c limenko.c luckgrln.c magicard.c majorpkr.c marinedt.c mediagx.c midzeus.c mogura.c namcoic.c naomi.c pcxt.c peplus.c pgm.c pgm2.c progolf.c rabbit.c savquest.c sfbonus.c srmp5.c taitowlf.c thayers.c tickee.c tmmjprd.c tonton.c vamphalf.c zn.c
[src/mame/includes]beathead.h stv.h
[src/mame/machine]megadriv.c n64.c pgmprot.c segamsys.c
[src/mame/video]angelkds.c archimds.c atari.c beathead.c blockout.c bosco.c canyon.c cchasm.c cps1.c dc.c deco32.c deco_mlc.c deniam.c exerion.c galaga.c galastrm.c galaxold.c gp9001.c grchamp.c groundfx.c hng64.c itech32.c jack.c jaguar.c konamigx.c lastduel.c lethalj.c lordgun.c m10.c m107.c m58.c magmax.c mermaid.c midzeus.c midzeus2.c model2.c model3.c namconb1.c namcos1.c namcos22.c nmk16.c pgm.c pitnrun.c pk8000.c policetr.c psikyosh.c psychic5.c rallyx.c realbrk.c redclash.c sega16sp.c segaybd.c senjyo.c shangha3.c skyraid.c sprint2.c ssv.c st0016.c starcrus.c starshp1.c stvvdp1.c stvvdp2.c suprloco.c taito_f2.c taitoic.c tank8.c taotaido.c toaplan1.c toaplan2.c triplhnt.c twin16.c twincobr.c vectrex.c videopin.c warpwarp.c wgp.c xmen.c ygv608.c zac2650.c
[src/osd/sdl]sdlmain.c

src/mame/mame.lst
r14063r14064
48134813smarinef      // 2000.03 Sega Marine Fishing
48144814wldkicks      // 2000.03 World Kicks
48154815pstone2         // 2000.04 Power Stone 2
4816toukon4            // 2000.04 Shin Nihon Prowrestling Toukon Retsuden 4 Arcade Edition
4816toukon4         // 2000.04 Shin Nihon Prowrestling Toukon Retsuden 4 Arcade Edition
48174817qmegamis      // 2000.05 Quiz Ah Megamisama
48184818derbyo2k      // 2000.06 Derby Owners Club 2000 Ver.2 (Rev A)
48194819vonot         // 2000.06 Virtual-on Oratorio Tangram M.S.B.S. ver.5.66 2000 Edition
r14063r14064
48874887quizqgd         // 2002.?? Quiz Keitai Q mode
48884888shootopl      // 2002.?? Shootout Pool
48894889shootpl         // 2002.?? Shootout Pool / Shootout Pool Prize (Rev A)
4890            // 2003.02 MushiKing The King Of Beetle
4890mtkob2         // 2003.02 MushiKing The King Of Beetle
48914891            // 2003.03 Sega Network Taisen Mahjong MJ
48924892ggxxrl         // 2003.03 Guilty Gear XX # Reload (Rev A)
48934893shikgam2      // 2003.04 Shikigami No Shiro II / The Castle of Shikigami II
r14063r14064
1066010660bingor4         // (c) 2002 Unknown
1066110661bingor5         // (c) 2002 Unknown
1066210662galgame         // (c) 1971 Computer Recreations, Inc
10663ichiban         // (c) 199? Excel
1066310664
1066410665// InterFlip / Recreativos Franco
1066510666videopkr      // (c) 1984 InterFlip
src/mame/machine/n64.c
r14063r14064
378378
379379// RDRAM Interface (RI)
380380
381#define RDRAM_CONFIG       (0)
381#define RDRAM_CONFIG      (0)
382382#define RDRAM_DEVICE_ID    (1)
383383#define RDRAM_DELAY         (2)
384384#define RDRAM_MODE         (3)
r14063r14064
13361336         pi_dma_dir = 0;
13371337         pi_status |= 1;
13381338
1339            attotime dma_period = attotime::from_hz(93750000) * (pi_rd_len + 1) * 3;
1340            //printf("want read dma in %d\n", (pi_rd_len + 1));
1341            pi_dma_timer->adjust(dma_period);
1339         attotime dma_period = attotime::from_hz(93750000) * (pi_rd_len + 1) * 3;
1340         //printf("want read dma in %d\n", (pi_rd_len + 1));
1341         pi_dma_timer->adjust(dma_period);
13421342         break;
13431343      }
13441344
r14063r14064
13481348         pi_dma_dir = 1;
13491349         pi_status |= 1;
13501350
1351            attotime dma_period = attotime::from_hz(93750000) * (pi_wr_len + 1) * 3;
1352            //printf("want write dma in %d\n", (pi_wr_len + 1));
1353            pi_dma_timer->adjust(dma_period);
1351         attotime dma_period = attotime::from_hz(93750000) * (pi_wr_len + 1) * 3;
1352         //printf("want write dma in %d\n", (pi_wr_len + 1));
1353         pi_dma_timer->adjust(dma_period);
13541354         break;
13551355      }
13561356
src/mame/machine/megadriv.c
r14063r14064
94129412      megadrive_sprite_collision=0;//? when to reset this ..
94139413      megadrive_imode = MEGADRIVE_REG0C_INTERLEAVE; // can't change mid-frame..
94149414      megadrive_imode_odd_frame^=1;
9415//     cputag_set_input_line(machine, "genesis_snd_z80", 0, CLEAR_LINE); // if the z80 interrupt hasn't happened by now, clear it..
9415//      cputag_set_input_line(machine, "genesis_snd_z80", 0, CLEAR_LINE); // if the z80 interrupt hasn't happened by now, clear it..
94169416
94179417      if (input_port_read_safe(screen.machine(), "RESET", 0x00) & 0x01)
94189418         cputag_set_input_line(screen.machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
r14063r14064
94819481         case 2:scr_width = 320;break;// configure_screen(0, 320-1, megadrive_visible_scanlines-1,(double)megadriv_framerate); break; /* technically invalid, but used in rare cases */
94829482         case 3:scr_width = 320;break;// configure_screen(0, 320-1, megadrive_visible_scanlines-1,(double)megadriv_framerate); break;
94839483      }
9484//     mame_printf_debug("my mode %02x", megadrive_vdp_register[0x0c]);
9484//      mame_printf_debug("my mode %02x", megadrive_vdp_register[0x0c]);
94859485
9486      visarea.min_x = 0;
9487      visarea.max_x = scr_width-1;
9488      visarea.min_y = 0;
9489      visarea.max_y = megadrive_visible_scanlines-1;
9486      visarea.set(0, scr_width-1, 0, megadrive_visible_scanlines-1);
94909487
94919488      screen.machine().primary_screen->configure(scr_width, megadrive_visible_scanlines, visarea, HZ_TO_ATTOSECONDS(megadriv_framerate));
94929489
94939490      if (0)
94949491      {
94959492         //int xxx;
9496//         UINT64 frametime;
9493//          UINT64 frametime;
94979494
94989495      //  /* reference */
9499//         frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate;
9496//          frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate;
95009497
95019498         //time_elapsed_since_crap = frame_timer->time_elapsed();
95029499         //xxx = screen.machine().device<cpudevice>("maincpu")->attotime_to_cycles(time_elapsed_since_crap);
src/mame/machine/segamsys.c
r14063r14064
11501150
11511151   if (chip->vdp_type!=GG_VDP) /* In GG mode the Game Gear resolution is fixed */
11521152   {
1153      rectangle visarea;
1153      rectangle visarea(0, 256-1, 0, sms_mode_table[chip->screen_mode].sms2_height-1);
11541154
1155      visarea.min_x = 0;
1156      visarea.max_x = 256-1;
1157      visarea.min_y = 0;
1158      visarea.max_y = sms_mode_table[chip->screen_mode].sms2_height-1;
1159
11601155      if (chip->chip_id==3) machine.primary_screen->configure(256, 256, visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate));
11611156
11621157   }
11631158   else /* 160x144 */
11641159   {
1165      rectangle visarea;
1166      visarea.min_x = (256-160)/2;
1167      visarea.max_x = (256-160)/2+160-1;
1168      visarea.min_y = (192-144)/2;
1169      visarea.max_y = (192-144)/2+144-1;
1160      rectangle visarea((256-160)/2, (256-160)/2+160-1, (192-144)/2, (192-144)/2+144-1);
11701161
11711162      machine.primary_screen->configure(256, 256, visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate));
11721163   }
src/mame/machine/pgmprot.c
r14063r14064
11631163
11641164         kov_value ^= kov_key;
11651165
1166      //   bprintf (PRINT_NORMAL, _T("ASIC27 command: %2.2x data: %4.4x\n"), (data ^ kov_key) & 0xff, kov_value);
1166      //  bprintf (PRINT_NORMAL, _T("ASIC27 command: %2.2x data: %4.4x\n"), (data ^ kov_key) & 0xff, kov_value);
11671167
11681168         switch ((data ^ kov_key) & 0xff)
11691169         {
r14063r14064
12821282
12831283            default:
12841284               kov_response = 0x880000;
1285      //         bprintf (PRINT_NORMAL, _T("Unknown ASIC27 command: %2.2x data: %4.4x\n"), (data ^ kov_key) & 0xff, kov_value);
1285      //          bprintf (PRINT_NORMAL, _T("Unknown ASIC27 command: %2.2x data: %4.4x\n"), (data ^ kov_key) & 0xff, kov_value);
12861286            break;
12871287         }
12881288
src/mame/includes/beathead.h
r14063r14064
2020   virtual void machine_reset();
2121
2222   virtual void video_start();
23   
23
2424   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2525
2626   required_device<asap_device> m_maincpu;
src/mame/includes/stv.h
r14063r14064
118118   legacy_cpu_device* m_maincpu;
119119   legacy_cpu_device* m_slave;
120120   legacy_cpu_device* m_audiocpu;
121   
121
122122   bitmap_rgb32 m_tmpbitmap;
123123};
124124
src/mame/mame.mak
r14063r14064
17331733   $(DRIVERS)/homedata.o $(VIDEO)/homedata.o \
17341734   $(DRIVERS)/hotblock.o \
17351735   $(DRIVERS)/hotstuff.o \
1736   $(DRIVERS)/ichiban.o \
17361737   $(DRIVERS)/imolagp.o \
17371738   $(DRIVERS)/intrscti.o \
17381739   $(DRIVERS)/istellar.o \
src/mame/video/deco_mlc.c
r14063r14064
501501   {
502502      deco_mlc_state *state = screen.machine().driver_data<deco_mlc_state>();
503503      /* Spriteram is definitely double buffered, as the vram lookup tables
504       are often updated a frame after spriteram is setup to point to a new
505       lookup table.  Without buffering incorrect one frame glitches are seen
506       in several places, especially in Hoops.
507       */
504        are often updated a frame after spriteram is setup to point to a new
505        lookup table.  Without buffering incorrect one frame glitches are seen
506        in several places, especially in Hoops.
507        */
508508      memcpy(state->m_mlc_buffered_spriteram, state->m_spriteram, 0x3000);
509509   }
510510}
src/mame/video/ygv608.c
r14063r14064
747747   const rectangle &visarea = screen.visible_area();
748748
749749   // clip to the current bitmap
750   finalclip.min_x = finalclip.min_y = 0;
751   finalclip.max_x = screen.width() - 1;
752   finalclip.max_y = screen.height() - 1;
750   finalclip.set(0, screen.width() - 1, 0, screen.height() - 1);
753751   finalclip &= cliprect;
754752
755753   // punt if not initialized
src/mame/video/stvvdp1.c
r14063r14064
20022002
20032003            case 0x0008:
20042004               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);
2005               state->m_vdp1.user_cliprect.min_x = stv2_current_sprite.CMDXA;
2006               state->m_vdp1.user_cliprect.min_y = stv2_current_sprite.CMDYA;
2007               state->m_vdp1.user_cliprect.max_x = stv2_current_sprite.CMDXC;
2008               state->m_vdp1.user_cliprect.max_y = stv2_current_sprite.CMDYC;
2005               state->m_vdp1.user_cliprect.set(stv2_current_sprite.CMDXA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDYC);
20092006               break;
20102007
20112008            case 0x0009:
20122009               if (VDP1_LOG) logerror ("Sprite List Set Command for System Clipping (0,0),(%d,%d)\n", stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC);
2013               state->m_vdp1.system_cliprect.min_x = 0;
2014               state->m_vdp1.system_cliprect.min_y = 0;
2015               state->m_vdp1.system_cliprect.max_x = stv2_current_sprite.CMDXC;
2016               state->m_vdp1.system_cliprect.max_y = stv2_current_sprite.CMDYC;
2010               state->m_vdp1.system_cliprect.set(0, stv2_current_sprite.CMDXC, 0, stv2_current_sprite.CMDYC);
20172011               break;
20182012
20192013            case 0x000a:
r14063r14064
21782172   stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw);
21792173   state->m_vdp1.framebuffer_clear_on_next_frame = 0;
21802174
2181   state->m_vdp1.system_cliprect.min_x = state->m_vdp1.system_cliprect.max_x = 0;
2182   state->m_vdp1.system_cliprect.min_y = state->m_vdp1.system_cliprect.max_y = 0;
2175   state->m_vdp1.system_cliprect.set(0, 0, 0, 0);
21832176   /* Kidou Senshi Z Gundam - Zenpen Zeta no Kodou loves to use the user cliprect vars in an undefined state ... */
2184   state->m_vdp1.user_cliprect.min_x = 0;
2185   state->m_vdp1.user_cliprect.min_y = 0;
2186   state->m_vdp1.user_cliprect.max_x = 512;
2187   state->m_vdp1.user_cliprect.max_y = 256;
2177   state->m_vdp1.user_cliprect.set(0, 512, 0, 256);
21882178
21892179   // save state
21902180   state_save_register_global_pointer(machine, state->m_vdp1_regs, 0x020/2);
src/mame/video/senjyo.c
r14063r14064
232232               sy = 255 - sy;
233233            }
234234
235            if (sy >= cliprect.min_y && sy <= cliprect.max_y &&
236               sx >= cliprect.min_x && sx <= cliprect.max_x)
235            if (cliprect.contains(sx, sy))
237236               bitmap.pix16(sy, sx) = offs < 0x200 ? 512 : 513;
238237         }
239238}
src/mame/video/twincobr.c
r14063r14064
524524      address_space *space = screen.machine().device("maincpu")->memory().space(AS_PROGRAM);
525525
526526      /* Spriteram is always 1 frame ahead, suggesting spriteram buffering.
527           There are no CPU output registers that control this so we
528           assume it happens automatically every frame, at the end of vblank */
527            There are no CPU output registers that control this so we
528            assume it happens automatically every frame, at the end of vblank */
529529      buffer_spriteram16_w(space,0,0,0xffff);
530530   }
531531}
src/mame/video/sprint2.c
r14063r14064
156156      const rectangle &visarea = screen.machine().primary_screen->visible_area();
157157
158158      /*
159        * Collisions are detected for both player cars:
160        *
161        * D7 => state->m_collision w/ white playfield
162        * D6 => state->m_collision w/ black playfield or another car
163        *
164        */
159         * Collisions are detected for both player cars:
160         *
161         * D7 => state->m_collision w/ white playfield
162         * D6 => state->m_collision w/ black playfield or another car
163         *
164         */
165165
166166      for (i = 0; i < 2; i++)
167167      {
r14063r14064
172172         rect.max_x = get_sprite_x(video_ram, i) + screen.machine().gfx[1]->width - 1;
173173         rect.max_y = get_sprite_y(video_ram, i) + screen.machine().gfx[1]->height - 1;
174174
175         if (rect.min_x < visarea.min_x)
176            rect.min_x = visarea.min_x;
177         if (rect.min_y < visarea.min_y)
178            rect.min_y = visarea.min_y;
179         if (rect.max_x > visarea.max_x)
180            rect.max_x = visarea.max_x;
181         if (rect.max_y > visarea.max_y)
182            rect.max_y = visarea.max_y;
175         rect &= visarea;
183176
184177         /* check for sprite-tilemap collisions */
185178
src/mame/video/policetr.c
r14063r14064
351351SCREEN_UPDATE_IND16( policetr )
352352{
353353   policetr_state *state = screen.machine().driver_data<policetr_state>();
354   int width = cliprect.max_x - cliprect.min_x + 1;
354   int width = cliprect.width();
355355   int y;
356356
357357   /* render all the scanlines from the dstbitmap to MAME's bitmap */
src/mame/video/stvvdp2.c
r14063r14064
42234223   saturn_state *state = machine.driver_data<saturn_state>();
42244224
42254225//  int window_applied = 0;
4226   rectangle mycliprect;
4227   mycliprect.min_x = cliprect.min_x;
4228   mycliprect.max_x = cliprect.max_x;
4229   mycliprect.min_y = cliprect.min_y;
4230   mycliprect.max_y = cliprect.max_y;
4226   rectangle mycliprect = cliprect;
42314227
42324228   if ( stv2_current_tilemap.linescroll_enable ||
42334229       stv2_current_tilemap.vertical_linescroll_enable ||
r14063r14064
52955291         stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
52965292      }
52975293
5298      mycliprect.min_x = cliprect.min_x;
5299      mycliprect.max_x = cliprect.max_x;
5300      mycliprect.min_y = cliprect.min_y;
5301      mycliprect.max_y = cliprect.max_y;
5294      mycliprect = cliprect;
53025295
53035296      if ( window_control )
53045297      {
r14063r14064
59625955
59635956   {
59645957      int vblank_period,hblank_period;
5965      rectangle visarea = machine.primary_screen->visible_area();
59665958      attoseconds_t refresh;;
5967      visarea.min_x = 0;
5968      visarea.max_x = horz_res-1;
5969      visarea.min_y = 0;
5970      visarea.max_y = vert_res-1;
5959      rectangle visarea(0, horz_res-1, 0, vert_res-1);
59715960
59725961      vblank_period = get_vblank_duration(machine);
59735962      hblank_period = get_hblank_duration(machine);
r14063r14064
63626351                                (STV_VDP2_SPW0A * 0x10) |
63636352                                (STV_VDP2_SPW1A * 0x20) |
63646353                                (STV_VDP2_SPSWA * 0x40);
6365   mycliprect.min_x = cliprect.min_x;
6366   mycliprect.max_x = cliprect.max_x;
6367   mycliprect.min_y = cliprect.min_y;
6368   mycliprect.max_y = cliprect.max_y;
6354   mycliprect = cliprect;
63696355
63706356   stv_vdp2_apply_window_on_layer(machine,mycliprect);
63716357
src/mame/video/itech32.c
r14063r14064
140140INLINE void disable_clipping(itech32_state *state)
141141{
142142   state->m_clip_save = state->m_clip_rect;
143
144   state->m_clip_rect.min_x = state->m_clip_rect.min_y = 0;
145   state->m_clip_rect.max_x = state->m_clip_rect.max_y = 0xfff;
146
147   state->m_scaled_clip_rect.min_x = state->m_scaled_clip_rect.min_y = 0;
148   state->m_scaled_clip_rect.max_x = state->m_scaled_clip_rect.max_y = 0xfff << 8;
143   state->m_clip_rect.set(0, 0xfff, 0, 0xfff);
144   state->m_scaled_clip_rect.set(0, 0xfff << 8, 0, 0xfff << 8);
149145}
150146
151147INLINE void enable_clipping(itech32_state *state)
r14063r14064
561557         /* render all pixels */
562558         sx = startx;
563559         for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
564            if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y &&
565               sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x)
560            if (state->m_scaled_clip_rect.contains(sx, ty))
566561            {
567562               int pixel = rowsrc[x >> 8];
568563               if (pixel != transparent_pen)
r14063r14064
747742         if (state->m_drivedge_zbuf_control[3] & 0x8000)
748743         {
749744            for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
750               if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y &&
751                  sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x)
745               if (state->m_scaled_clip_rect.contains(sx, ty))
752746               {
753747                  int pixel = rowsrc[x >> 8];
754748                  if (pixel != transparent_pen)
r14063r14064
762756         else if (state->m_drivedge_zbuf_control[3] & 0x4000)
763757         {
764758            for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
765               if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y &&
766                  sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x)
759               if (state->m_scaled_clip_rect.contains(sx, ty))
767760               {
768761                  int pixel = rowsrc[x >> 8];
769762                  UINT16 *zbuf = &zbase[compute_safe_address(state, sx >> 8, ty >> 8)];
r14063r14064
778771         else
779772         {
780773            for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
781               if (ty >= state->m_scaled_clip_rect.min_y && ty < state->m_scaled_clip_rect.max_y &&
782                  sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x)
774               if (state->m_scaled_clip_rect.contains(sx, ty))
783775               {
784776                  int pixel = rowsrc[x >> 8];
785777                  UINT16 *zbuf = &zbase[compute_safe_address(state, sx >> 8, ty >> 8)];
r14063r14064
14571449         }
14581450
14591451         /* draw from the buffer */
1460         draw_scanline16(bitmap, cliprect.min_x, y, cliprect.max_x - cliprect.min_x + 1, &scanline[cliprect.min_x], NULL);
1452         draw_scanline16(bitmap, cliprect.min_x, y, cliprect.width(), &scanline[cliprect.min_x], NULL);
14611453      }
14621454
14631455      /* otherwise, draw directly from VRAM */
14641456      else
1465         draw_scanline16(bitmap, cliprect.min_x, y, cliprect.max_x - cliprect.min_x + 1, &src1[cliprect.min_x], NULL);
1457         draw_scanline16(bitmap, cliprect.min_x, y, cliprect.width(), &src1[cliprect.min_x], NULL);
14661458   }
14671459   return 0;
14681460}
src/mame/video/deco32.c
r14063r14064
647647   // for now we only draw these 2 layers on the last update call
648648   if (cliprect.max_y == 247)
649649   {
650      rectangle clip;
651      clip.min_x = cliprect.min_x;
652      clip.max_x = cliprect.max_x;
653      clip.min_y = 8;
654      clip.max_y = 247;
650      rectangle clip(cliprect.min_x, cliprect.max_x, 8, 247);
655651
656652      dragngun_draw_sprites(screen.machine(),bitmap,clip,screen.machine().generic.buffered_spriteram.u32);
657653      deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, clip, 0, 0);
src/mame/video/midzeus.c
r14063r14064
184184
185185INLINE void waveram_plot(int y, int x, UINT16 color)
186186{
187   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
187   if (zeus_cliprect.contains(x, y))
188188      WAVERAM_WRITEPIX(zeus_renderbase, y, x, color);
189189}
190190
191191INLINE void waveram_plot_depth(int y, int x, UINT16 color, UINT16 depth)
192192{
193   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
193   if (zeus_cliprect.contains(x, y))
194194   {
195195      WAVERAM_WRITEPIX(zeus_renderbase, y, x, color);
196196      WAVERAM_WRITEDEPTH(zeus_renderbase, y, x, depth);
r14063r14064
199199
200200INLINE void waveram_plot_check_depth(int y, int x, UINT16 color, UINT16 depth)
201201{
202   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
202   if (zeus_cliprect.contains(x, y))
203203   {
204204      UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x);
205205      if (depth <= *depthptr)
r14063r14064
213213#ifdef UNUSED_FUNCTION
214214INLINE void waveram_plot_check_depth_nowrite(int y, int x, UINT16 color, UINT16 depth)
215215{
216   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
216   if (zeus_cliprect.contains(x, y))
217217   {
218218      UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x);
219219      if (depth <= *depthptr)
r14063r14064
743743         {
744744            int vtotal = zeusbase[0xca] >> 16;
745745            int htotal = zeusbase[0xc6] >> 16;
746            rectangle visarea;
747746
748            visarea.min_x = zeusbase[0xc6] & 0xffff;
749            visarea.max_x = htotal - 3;
750            visarea.min_y = 0;
751            visarea.max_y = zeusbase[0xc8] & 0xffff;
747            rectangle visarea(zeusbase[0xc6] & 0xffff, htotal - 3, 0, zeusbase[0xc8] & 0xffff);
752748            if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal)
753749            {
754750               machine.primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal)));
src/mame/video/grchamp.c
r14063r14064
148148         if( pixel != sprite_transp ){
149149            sx = x+x0;
150150            sy = y+y0;
151            if( (sx >= visarea->min_x) && (sx <= visarea->max_x) &&
152               (sy >= visarea->min_y) && (sy <= visarea->max_y) )
151            if(visarea->contains(sx, sy))
153152            {
154153               // Collision check uses only 16 pens!
155154               pixel = bitmap.pix16(sy, sx) % 16;
src/mame/video/segaybd.c
r14063r14064
5252   }
5353
5454   /* draw the yboard sprites */
55   yboard_clip.min_x = yboard_clip.min_y = 0;
56   yboard_clip.max_x = yboard_clip.max_y = 511;
55   yboard_clip.set(0, 511, 0, 511);
5756   segaic16_sprites_draw(screen, *state->m_tmp_bitmap, yboard_clip, 1);
5857
5958   /* apply rotation */
src/mame/video/skyraid.c
r14063r14064
5757         int color = val / 32;
5858         int count = val % 32;
5959
60         rectangle r;
60         rectangle r(x, x + 31 - count, y, y+ 1);
6161
62         r.min_y = y;
63         r.min_x = x;
64         r.max_y = y + 1;
65         r.max_x = x + 31 - count;
66
6762         bitmap.fill(color, r);
6863
6964         x += 32 - count;
src/mame/video/deniam.c
r14063r14064
269269               {
270270                  if (rom[i] & 0x0f)
271271                  {
272                     if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x &&
273                        y >= cliprect.min_y && y <= cliprect.max_y)
272                     if (cliprect.contains(sx + x, y))
274273                     {
275274                        if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0)
276275                           bitmap.pix16(y, sx + x) = color * 16 + (rom[i] & 0x0f);
r14063r14064
289288               {
290289                  if (rom[i] & 0xf0)
291290                  {
292                     if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x &&
293                        y >= cliprect.min_y && y <= cliprect.max_y)
291                     if (cliprect.contains(sx + x, y))
294292                     {
295293                        if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0)
296294                           bitmap.pix16(y, sx + x) = color * 16+(rom[i] >> 4);
r14063r14064
313311               {
314312                  if (rom[i] & 0xf0)
315313                  {
316                     if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x &&
317                        y >= cliprect.min_y && y <= cliprect.max_y)
314                     if (cliprect.contains(sx + x, y))
318315                     {
319316                        if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0)
320317                           bitmap.pix16(y, sx + x) = color * 16 + (rom[i] >> 4);
r14063r14064
333330               {
334331                  if (rom[i] & 0x0f)
335332                  {
336                     if (sx + x >= cliprect.min_x && sx + x <= cliprect.max_x &&
337                        y >= cliprect.min_y && y <= cliprect.max_y)
333                     if (cliprect.contains(sx + x, y))
338334                     {
339335                        if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0)
340336                           bitmap.pix16(y, sx + x) = color * 16 + (rom[i] & 0x0f);
src/mame/video/tank8.c
r14063r14064
158158
159159   for (i = 0; i < 8; i++)
160160   {
161      rectangle rect;
162
163161      int x = get_x_pos(state, 8 + i);
164162      int y = get_y_pos(state, 8 + i);
165163
166164      x -= 4; /* ? */
167165
168      rect.min_x = x;
169      rect.min_y = y;
170      rect.max_x = rect.min_x + 3;
171      rect.max_y = rect.min_y + 4;
166      rectangle rect(x, x + 3, y, y + 4);
167      rect &= cliprect;
172168
173      if (rect.min_x < cliprect.min_x)
174         rect.min_x = cliprect.min_x;
175      if (rect.min_y < cliprect.min_y)
176         rect.min_y = cliprect.min_y;
177      if (rect.max_x > cliprect.max_x)
178         rect.max_x = cliprect.max_x;
179      if (rect.max_y > cliprect.max_y)
180         rect.max_y = cliprect.max_y;
181
182169      bitmap.fill((i << 1) | 0x01, rect);
183170   }
184171}
src/mame/video/taitoic.c
r14063r14064
506506{
507507   UINT16 *dsti = &bitmap.pix16(y, x);
508508   UINT8 *dstp = &priority.pix8(y, x);
509   int length = cliprect.max_x - cliprect.min_x + 1;
509   int length = cliprect.width();
510510
511511   src += cliprect.min_x;
512512   dsti += cliprect.min_x;
r14063r14064
23522352         src_x = (256 - 64 - src_x) & width_mask;
23532353
23542354      // Col offsets are 'tilemap' space 0-511, and apply to blocks of 8 pixels at once
2355      for (x = 0; x <= (cliprect.max_x - cliprect.min_x); x++)
2355      for (x = 0; x < cliprect.width(); x++)
23562356      {
23572357         column_offset = tc0100scn->colscroll_ram[(src_x & 0x3ff) / 8];
23582358         p = src_bitmap.pix16((src_y - column_offset) & height_mask, src_x);
r14063r14064
32643264      int x_index, x_step;
32653265      int machine_flip = 0;   /* for  ROT 180 ? */
32663266
3267      UINT16 screen_width = 512; //cliprect.max_x - cliprect.min_x + 1;
3267      UINT16 screen_width = 512; //cliprect.width();
32683268      UINT16 min_y = cliprect.min_y;
32693269      UINT16 max_y = cliprect.max_y;
32703270
r14063r14064
34003400   int flipscreen = tc0480scp->pri_reg & 0x40;
34013401   int machine_flip = 0;   /* for  ROT 180 ? */
34023402
3403   UINT16 screen_width = 512; //cliprect.max_x - cliprect.min_x + 1;
3403   UINT16 screen_width = 512; //cliprect.width();
34043404   UINT16 min_y = cliprect.min_y;
34053405   UINT16 max_y = cliprect.max_y;
34063406
src/mame/video/cps1.c
r14063r14064
27232723
27242724            col = ((col & 0xe0) >> 1) + (screen.frame_number() / 16 & 0x0f);
27252725
2726            if (sx >= cliprect.min_x && sx <= cliprect.max_x &&
2727               sy >= cliprect.min_y && sy <= cliprect.max_y)
2726            if (cliprect.contains(sx, sy))
27282727               bitmap.pix16(sy, sx) = 0xa00 + col;
27292728         }
27302729      }
r14063r14064
27492748
27502749            col = ((col & 0xe0) >> 1) + (screen.frame_number() / 16 & 0x0f);
27512750
2752            if (sx >= cliprect.min_x && sx <= cliprect.max_x &&
2753               sy >= cliprect.min_y && sy <= cliprect.max_y)
2751            if (cliprect.contains(sx, sy))
27542752               bitmap.pix16(sy, sx) = 0x800 + col;
27552753         }
27562754      }
src/mame/video/starcrus.c
r14063r14064
167167   starcrus_state *state = machine.driver_data<starcrus_state>();
168168   int org_x, org_y;
169169   int sx, sy;
170   rectangle clip;
170   rectangle clip(0, 15, 0, 15);
171171
172   clip.min_x=0;
173   clip.max_x=15;
174   clip.min_y=0;
175   clip.max_y=15;
176
177172   state->m_ship1_vid->fill(0, clip);
178173   state->m_ship2_vid->fill(0, clip);
179174
r14063r14064
215210   starcrus_state *state = machine.driver_data<starcrus_state>();
216211   int org_x, org_y;
217212   int sx, sy;
218   rectangle clip;
213   rectangle clip(0, 15, 0, 15);
219214
220215   /* if both are scores, return */
221216   if ( ((state->m_p1_sprite & 0x08) == 0) &&
r14063r14064
224219      return 0;
225220   }
226221
227   clip.min_x=0;
228   clip.max_x=15;
229   clip.min_y=0;
230   clip.max_y=15;
231
232222   state->m_proj1_vid->fill(0, clip);
233223   state->m_proj2_vid->fill(0, clip);
234224
r14063r14064
276266   starcrus_state *state = machine.driver_data<starcrus_state>();
277267   int org_x, org_y;
278268   int sx, sy;
279   rectangle clip;
269   rectangle clip(0, 15, 0, 15);
280270
281271   /* if both are scores, return */
282272   if ( ((state->m_p1_sprite & 0x08) == 0) &&
r14063r14064
285275      return 0;
286276   }
287277
288   clip.min_x=0;
289   clip.max_x=15;
290   clip.min_y=0;
291   clip.max_y=15;
292
293278   state->m_ship1_vid->fill(0, clip);
294279   state->m_proj1_vid->fill(0, clip);
295280   state->m_proj2_vid->fill(0, clip);
r14063r14064
353338   starcrus_state *state = machine.driver_data<starcrus_state>();
354339   int org_x, org_y;
355340   int sx, sy;
356   rectangle clip;
341   rectangle clip(0, 15, 0, 15);
357342
358343   /* if both are scores, return */
359344   if ( ((state->m_p1_sprite & 0x08) == 0) &&
r14063r14064
362347      return 0;
363348   }
364349
365   clip.min_x=0;
366   clip.max_x=15;
367   clip.min_y=0;
368   clip.max_y=15;
369
370350   state->m_ship2_vid->fill(0, clip);
371351   state->m_proj1_vid->fill(0, clip);
372352   state->m_proj2_vid->fill(0, clip);
src/mame/video/mermaid.c
r14063r14064
316316         rect.max_x = sx + screen.machine().gfx[1]->width - 1;
317317         rect.max_y = sy + screen.machine().gfx[1]->height - 1;
318318
319         if (rect.min_x < visarea.min_x)
320            rect.min_x = visarea.min_x;
321         if (rect.min_y < visarea.min_y)
322            rect.min_y = visarea.min_y;
323         if (rect.max_x > visarea.max_x)
324            rect.max_x = visarea.max_x;
325         if (rect.max_y > visarea.max_y)
326            rect.max_y = visarea.max_y;
319         rect &= visarea;
327320
328321         // check collision sprite - background
329322
r14063r14064
426419         rect.max_x = sx + screen.machine().gfx[1]->width - 1;
427420         rect.max_y = sy + screen.machine().gfx[1]->height - 1;
428421
429         if (rect.min_x < visarea.min_x)
430            rect.min_x = visarea.min_x;
431         if (rect.min_y < visarea.min_y)
432            rect.min_y = visarea.min_y;
433         if (rect.max_x > visarea.max_x)
434            rect.max_x = visarea.max_x;
435         if (rect.max_y > visarea.max_y)
436            rect.max_y = visarea.max_y;
422         rect &= visarea;
437423
438424         // check collision sprite - sprite
439425
r14063r14064
514500         rect.max_x = sx + screen.machine().gfx[1]->width - 1;
515501         rect.max_y = sy + screen.machine().gfx[1]->height - 1;
516502
517         if (rect.min_x < visarea.min_x)
518            rect.min_x = visarea.min_x;
519         if (rect.min_y < visarea.min_y)
520            rect.min_y = visarea.min_y;
521         if (rect.max_x > visarea.max_x)
522            rect.max_x = visarea.max_x;
523         if (rect.max_y > visarea.max_y)
524            rect.max_y = visarea.max_y;
525
503         rect &= visarea;
504         
526505         // check collision sprite - sprite
527506
528507         state->m_helper.fill(0, rect);
src/mame/video/lethalj.c
r14063r14064
2424{
2525   static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" };
2626   const rectangle &visarea = machine.primary_screen->visible_area();
27   int width = visarea.max_x + 1 - visarea.min_x;
28   int height = visarea.max_y + 1 - visarea.min_y;
27   int width = visarea.width();
28   int height = visarea.height();
2929
3030   *x = ((input_port_read_safe(machine, gunnames[player * 2], 0x00) & 0xff) * width) / 255;
3131   *y = ((input_port_read_safe(machine, gunnames[1 + player * 2], 0x00) & 0xff) * height) / 255;
src/mame/video/namconb1.c
r14063r14064
143143   clip.min_y = (yclip>>16)    - 0x21;
144144   clip.max_y = (yclip&0xffff) - 0x21 - 1;
145145   /* intersect with master clip rectangle */
146   if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; }
147   if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; }
148   if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; }
149   if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; }
146   clip &= cliprect;
150147
151148   bitmap.fill(get_black_pen(screen.machine()), cliprect );
152149
r14063r14064
184181   clip.min_y = (yclip>>16)    - 0x21;
185182   clip.max_y = (yclip&0xffff) - 0x21 - 1;
186183   /* intersect with master clip rectangle */
187   if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; }
188   if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; }
189   if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; }
190   if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; }
184   clip &= cliprect;
191185
192186   bitmap.fill(get_black_pen(screen.machine()), cliprect );
193187
src/mame/video/model2.c
r14063r14064
928928   poly_manager *poly = state->m_poly;
929929   poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly);
930930   UINT8      renderer;
931   rectangle   vp;
932931
933932   /* select renderer based on attributes (bit15 = checker, bit14 = textured, bit13 = transparent */
934933   renderer = (tri->texheader[0] >> 13) & 7;
935934
936935   /* calculate and clip to viewport */
937   vp.min_x = tri->viewport[0] - 8;
938   vp.max_x = tri->viewport[2] - 8;
939   vp.min_y = (384-tri->viewport[3])+90;
940   vp.max_y = (384-tri->viewport[1])+90;
936   rectangle vp(tri->viewport[0] - 8, tri->viewport[2] - 8, (384-tri->viewport[3])+90, (384-tri->viewport[1])+90);
937   vp &= cliprect;
941938
942   if ( vp.min_x < cliprect.min_x ) vp.min_x = cliprect.min_x;
943   if ( vp.max_x > cliprect.max_x ) vp.max_x = cliprect.max_x;
944   if ( vp.min_y < cliprect.min_y ) vp.min_y = cliprect.min_y;
945   if ( vp.max_y > cliprect.max_y ) vp.max_y = cliprect.max_y;
946
947939   extra->state = state;
948940   extra->lumabase = ((tri->texheader[1] & 0xFF) << 7) + ((tri->luma >> 5) ^ 0x7);
949941   extra->colorbase = (tri->texheader[3] >> 6) & 0x3FF;
r14063r14064
27122704{
27132705   model2_state *state = machine.driver_data<model2_state>();
27142706   const rectangle &visarea = machine.primary_screen->visible_area();
2715   int   width = visarea.max_x - visarea.min_x;
2716   int   height = visarea.max_y - visarea.min_y;
2707   int   width = visarea.width();
2708   int   height = visarea.height();
27172709
27182710   state->m_sys24_bitmap.allocate(width, height+4);
27192711
src/mame/video/lordgun.c
r14063r14064
211211
212212   lorddgun_calc_gun_scr(machine, i);
213213
214   if (   (state->m_gun[i].scr_x < visarea.min_x)   ||
215         (state->m_gun[i].scr_x > visarea.max_x)   ||
216         (state->m_gun[i].scr_y < visarea.min_y)   ||
217         (state->m_gun[i].scr_y > visarea.max_y)   )
214   if (!visarea.contains(state->m_gun[i].scr_x, state->m_gun[i].scr_y))
218215      state->m_gun[i].hw_x = state->m_gun[i].hw_y = 0;
219216}
220217
src/mame/video/toaplan1.c
r14063r14064
10941094         {
10951095            const rectangle &visarea = machine.primary_screen->visible_area();
10961096
1097            sx_base = ((visarea.max_x + 1) - visarea.min_x) - (sx_base + 8);   /* visarea.x = 320 */
1098            sy_base = ((visarea.max_y + 1) - visarea.min_y) - (sy_base + 8);   /* visarea.y = 240 */
1099            sy_base += ((visarea.max_y + 1) - ((visarea.max_y + 1) - visarea.min_y)) * 2;   /* Horizontal games are offset so adjust by +0x20 */
1097            sx_base = visarea.width() - (sx_base + 8);   /* visarea.x = 320 */
1098            sy_base = visarea.height() - (sy_base + 8);   /* visarea.y = 240 */
1099            sy_base += ((visarea.max_y + 1) - visarea.height()) * 2;   /* Horizontal games are offset so adjust by +0x20 */
11001100         }
11011101
11021102         for (dim_y = 0; dim_y < sprite_sizey; dim_y += 8)
src/mame/video/dc.c
r14063r14064
10851085      {
10861086         if ((state_ta.grab[a].ispbase == state->pvrta_regs[PARAM_BASE]) && (state_ta.grab[a].valid == 1) && (state_ta.grab[a].busy == 0))
10871087         {
1088            rectangle clip;
1089
10901088            state_ta.grab[a].busy = 1;
10911089            state_ta.renderselect = a;
10921090            state_ta.start_render_received=1;
r14063r14064
10951093            state_ta.grab[a].fbwsof1=state->pvrta_regs[FB_W_SOF1];
10961094            state_ta.grab[a].fbwsof2=state->pvrta_regs[FB_W_SOF2];
10971095
1098            clip.min_x = 0;
1099            clip.max_x = 1023;
1100            clip.min_y = 0;
1101            clip.max_y = 1023;
1096            rectangle clip(0, 1023, 0, 1023);
11021097
11031098            // we've got a request to draw, so, draw to the accumulation buffer!
11041099            // this should really be done for each tile!
src/mame/video/pitnrun.c
r14063r14064
259259      if (flip_screen_y_get(screen.machine()))
260260         dy=128-dy;
261261
262      myclip.min_x=dx;
263      myclip.min_y=dy;
264      myclip.max_x=dx+127;
265      myclip.max_y=dy+127;
262      myclip.set(dx, dx+127, dy, dy+127);
263      myclip &= cliprect;
266264
267
268      if(myclip.min_y<cliprect.min_y)myclip.min_y=cliprect.min_y;
269      if(myclip.min_x<cliprect.min_x)myclip.min_x=cliprect.min_x;
270
271      if(myclip.max_y>cliprect.max_y)myclip.max_y=cliprect.max_y;
272      if(myclip.max_x>cliprect.max_x)myclip.max_x=cliprect.max_x;
273
274265      tilemap_draw(bitmap,myclip,state->m_bg, 0,0);
275266   }
276267
src/mame/video/midzeus2.c
r14063r14064
187187#ifdef UNUSED_FUNCTION
188188INLINE void waveram_plot(int y, int x, UINT32 color)
189189{
190   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
190   if (zeus_cliprect.contains(x, y))
191191      WAVERAM_WRITEPIX(zeus_renderbase, y, x, color);
192192}
193193#endif
194194
195195INLINE void waveram_plot_depth(int y, int x, UINT32 color, UINT16 depth)
196196{
197   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
197   if (zeus_cliprect.contains(x, y))
198198   {
199199      WAVERAM_WRITEPIX(zeus_renderbase, y, x, color);
200200      WAVERAM_WRITEDEPTH(zeus_renderbase, y, x, depth);
r14063r14064
204204#ifdef UNUSED_FUNCTION
205205INLINE void waveram_plot_check_depth(int y, int x, UINT32 color, UINT16 depth)
206206{
207   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
207   if (zeus_cliprect.contains(x, y))
208208   {
209209      UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x);
210210      if (depth <= *depthptr)
r14063r14064
219219#ifdef UNUSED_FUNCTION
220220INLINE void waveram_plot_check_depth_nowrite(int y, int x, UINT32 color, UINT16 depth)
221221{
222   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
222   if (zeus_cliprect.contains(x, y))
223223   {
224224      UINT16 *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x);
225225      if (depth <= *depthptr)
r14063r14064
564564         {
565565            int vtotal = zeusbase[0x37] & 0xffff;
566566            int htotal = zeusbase[0x34] >> 16;
567            rectangle visarea;
568567
569            visarea.min_x = zeusbase[0x33] >> 16;
570            visarea.max_x = (zeusbase[0x34] & 0xffff) - 1;
571            visarea.min_y = 0;
572            visarea.max_y = zeusbase[0x35] & 0xffff;
568            rectangle visarea(zeusbase[0x33] >> 16, (zeusbase[0x34] & 0xffff) - 1, 0, zeusbase[0x35] & 0xffff);
573569            if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal)
574570            {
575571               machine.primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 4.0 / (htotal * vtotal)));
src/mame/video/model3.c
r14063r14064
357357#endif
358358   state->m_screen_clip = (rectangle*)&cliprect;
359359
360   state->m_clip3d.min_x = cliprect.min_x;
361   state->m_clip3d.max_x = cliprect.max_x;
362   state->m_clip3d.min_y = cliprect.min_y;
363   state->m_clip3d.max_y = cliprect.max_y;
360   state->m_clip3d = cliprect;
364361
365362   /* layer disable debug keys */
366363   state->m_tick++;
src/mame/video/pgm.c
r14063r14064
3131         {
3232            if (!(destpri[xdrawpos]&2))
3333            {
34               dest[xdrawpos] = srcdat;   
35            }                 
34               dest[xdrawpos] = srcdat;
35            }
3636         }
3737      }
3838
r14063r14064
6060      {
6161         if (!(destpri[xdrawpos]&2))
6262         {
63            dest[xdrawpos] = srcdat;   
64         }   
63            dest[xdrawpos] = srcdat;
64         }
6565      }
6666      destpri[xdrawpos]|=1;
6767   }
r14063r14064
114114                     xdrawpos = xpos + xcntdraw;
115115                  else
116116                     xdrawpos = xpos + realxsize - xcntdraw;
117         
117
118118                  pgm_draw_pix(xdrawpos, pri, dest, destpri, srcdat);
119119
120120                  xcntdraw++;
r14063r14064
125125                     xdrawpos = xpos + realxsize - xcntdraw;
126126
127127                  pgm_draw_pix(xdrawpos, pri, dest, destpri, srcdat);
128               
128
129129                  xcntdraw++;
130130               }
131131               else if (xzoombit == 1 && xgrow == 0)
r14063r14064
140140                     xdrawpos = xpos + realxsize - xcntdraw;
141141
142142                  pgm_draw_pix(xdrawpos, pri, dest, destpri, srcdat);
143                 
143
144144                  xcntdraw++;
145145               }
146146            }
r14063r14064
184184
185185   /* precalculate where drawing will end, for flipped zoomed cases. */
186186   /* if we're to avoid pre-decoding the data for each sprite each time we draw then we have to draw the sprite data
187      in the order it is in ROM due to the nature of the compresson scheme.  This means drawing upwards from the end point
188      in the case of flipped sprites */
187       in the order it is in ROM due to the nature of the compresson scheme.  This means drawing upwards from the end point
188       in the case of flipped sprites */
189189   ycnt = 0;
190190   ycntdraw = 0;
191191   int realysize = 0;
r14063r14064
227227      {
228228         int temp_aoffset = state->m_aoffset;
229229         int temp_boffset = state->m_boffset;
230         
230
231231         if (!(flip & 0x02))
232232            ydrawpos = ypos + ycntdraw;
233233         else
r14063r14064
245245         }
246246
247247         ycntdraw++;
248     
248
249249         // we need to draw this line again, so restore our pointers to previous values
250250         state->m_aoffset = temp_aoffset;
251251         state->m_boffset = temp_boffset;
r14063r14064
301301         else
302302         {
303303            draw_sprite_line(machine, wide, NULL, NULL, xzoom, xgrow, flip, xpos, pri, realxsize, palt, 0);
304         
304
305305            if (!(flip & 0x02))
306306            {
307307               if (ydrawpos>224)
r14063r14064
312312               if (ydrawpos<0)
313313                  return;
314314            }
315         
315
316316         }
317317
318318         ycntdraw++;
r14063r14064
363363                     xdrawpos = xpos + realxsize - xcntdraw;
364364
365365                  pgm_draw_pix_nopri(xdrawpos, dest, destpri, srcdat);
366                 
366
367367                  xcntdraw++;
368368               }
369369
r14063r14064
405405                     xdrawpos = xpos + realxsize - xcntdraw;
406406
407407                  pgm_draw_pix_pri(xdrawpos, dest, destpri, srcdat);
408                 
408
409409                  xcntdraw++;
410410               }
411411
r14063r14064
452452
453453   while (ycnt < high)
454454   {
455   
455
456456      if (!(flip & 0x02))
457457         ydrawpos = ypos + ycntdraw;
458458      else
r14063r14064
467467      else
468468      {
469469         draw_sprite_line_basic(machine, wide, NULL, NULL, flip, xpos, pri, realxsize, palt, 0);
470         
470
471471         if (!(flip & 0x02))
472472         {
473473            if (ydrawpos>224)
r14063r14064
626626   state->m_bdatasize = machine.region("sprmask")->bytes() - 1;
627627   state->m_aoffset = 0;
628628   state->m_boffset = 0;
629   
629
630630   state->m_tx_tilemap = tilemap_create(machine, get_pgm_tx_tilemap_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
631631   tilemap_set_transparent_pen(state->m_tx_tilemap, 15);
632632
src/mame/video/st0016.c
r14063r14064
380380                           if (drawxpos > cliprect.max_x)
381381                              drawxpos -= 512; // wrap around
382382
383                           if ((drawxpos >= cliprect.min_x) && (drawxpos <= cliprect.max_x) && (drawypos >= cliprect.min_y) && (drawypos <= cliprect.max_y) )
383                           if (cliprect.contains(drawxpos, drawypos))
384384                           {
385385                              if(st0016_spriteram[offset+5]&0x40)
386386                              {
r14063r14064
546546                           if (drawxpos > cliprect.max_x)
547547                              drawxpos -= 512; // wrap around
548548
549                           if ((drawxpos >= cliprect.min_x) && (drawxpos <= cliprect.max_x) && (drawypos >= cliprect.min_y) && (drawypos <= cliprect.max_y) )
549                           if (cliprect.contains(drawxpos, drawypos))
550550                           {
551551
552552                              if(st0016_vregs[j+7]==0x12)
src/mame/video/beathead.c
r14063r14064
182182      }
183183
184184      /* then draw it */
185      draw_scanline16(bitmap, cliprect.min_x, y, cliprect.max_x - cliprect.min_x + 1, &scanline[cliprect.min_x], NULL);
185      draw_scanline16(bitmap, cliprect.min_x, y, cliprect.width(), &scanline[cliprect.min_x], NULL);
186186   }
187187   return 0;
188188}
src/mame/video/cchasm.c
r14063r14064
124124   cchasm_state *state = machine.driver_data<cchasm_state>();
125125   const rectangle &visarea = machine.primary_screen->visible_area();
126126
127   state->m_xcenter=((visarea.max_x + visarea.min_x)/2) << 16;
128   state->m_ycenter=((visarea.max_y + visarea.min_y)/2) << 16;
127   state->m_xcenter=visarea.xcenter() << 16;
128   state->m_ycenter=visarea.ycenter() << 16;
129129
130130   VIDEO_START_CALL(vector);
131131}
src/mame/video/toaplan2.c
r14063r14064
446446   rectangle clip;
447447   const rectangle &visarea = screen.visible_area();
448448
449   clip.min_x = visarea.min_x;
450   clip.max_x = visarea.max_x;
451   clip.min_y = visarea.min_y;
452   clip.max_y = visarea.max_y;
449   clip = visarea;
453450
454451   /* used for 'for use in' and '8ing' screen on bbakraid, raizing on batrider */
455452   for (line = 0; line < 256;line++)
src/mame/video/bosco.c
r14063r14064
271271            {
272272               if (flip) x += 20*8;
273273
274               if (x >= cliprect.min_x && x <= cliprect.max_x && y >= cliprect.min_y && y <= cliprect.max_y)
274               if (cliprect.contains(x, y))
275275                  bitmap.pix16(y, x) = STARS_COLOR_BASE + star_seed_tab[star_cntr].col;
276276            }
277277         }
src/mame/video/galastrm.c
r14063r14064
444444   UINT8 pivlayer[3];
445445   UINT16 priority;
446446   static const int primasks[4] = {0xfffc, 0xfff0, 0xff00, 0x0};
447   rectangle clip;
448447   bitmap_ind8 &priority_bitmap = screen.machine().priority_bitmap;
449448
450   clip.min_x = 0;
451   clip.min_y = 0;
452   clip.max_x = screen.width() -1;
453   clip.max_y = screen.height() -1;
449   rectangle clip(0, screen.width() -1, 0, screen.height() -1);
454450
455451   tc0100scn_tilemap_update(tc0100scn);
456452   tc0480scp_tilemap_update(tc0480scp);
src/mame/video/lastduel.c
r14063r14064
314314      address_space *space = screen.machine().device("maincpu")->memory().space(AS_PROGRAM);
315315
316316      /* Spriteram is always 1 frame ahead, suggesting buffering.  I can't find
317           a register to control this so I assume it happens automatically
318           every frame at the end of vblank */
317            a register to control this so I assume it happens automatically
318            every frame at the end of vblank */
319319      buffer_spriteram16_w(space, 0, 0, 0xffff);
320320   }
321321}
src/mame/video/namcos22.c
r14063r14064
293293   int cy = 240+vy;
294294   mClip.cx = cx;
295295   mClip.cy = cy;
296   mClip.scissor.min_x = cx + vw;
297   mClip.scissor.max_x = cx - vw;
298   mClip.scissor.min_y = cy + vh;
299   mClip.scissor.max_y = cy - vh;
296   mClip.scissor.set(cx + vw, cx - vw, cy + vh, cy - vh);
300297   if( mClip.scissor.min_x<0 )   mClip.scissor.min_x = 0;
301298   if( mClip.scissor.max_x>639 ) mClip.scissor.max_x = 639;
302299   if( mClip.scissor.min_y<0 )   mClip.scissor.min_y = 0;
r14063r14064
307304sprite_Clip( int min_x, int max_x, int min_y, int max_y )
308305{
309306   // cx/cy not used
310   mClip.scissor.min_x = min_x;
311   mClip.scissor.max_x = max_x;
312   mClip.scissor.min_y = min_y;
313   mClip.scissor.max_y = max_y;
307   mClip.scissor.set(min_x, max_x, min_y, max_y);
314308   if( mClip.scissor.min_x<0 )   mClip.scissor.min_x = 0;
315309   if( mClip.scissor.max_x>639 ) mClip.scissor.max_x = 639;
316310   if( mClip.scissor.min_y<0 )   mClip.scissor.min_y = 0;
r14063r14064
322316{
323317   mClip.cx = 320;
324318   mClip.cy = 240;
325   mClip.scissor.min_x = 0;
326   mClip.scissor.max_x = 639;
327   mClip.scissor.min_y = 0;
328   mClip.scissor.max_y = 479;
319   mClip.scissor.set(0, 639, 0, 479);
329320}
330321
331322typedef struct
src/mame/video/redclash.c
r14063r14064
283283         sx = 240 - sx;
284284      }
285285
286      if (sx >= cliprect.min_x && sx <= cliprect.max_x &&
287         sy >= cliprect.min_y && sy <= cliprect.max_y)
286      if (cliprect.contains(sx, sy))
288287         bitmap.pix16(sy, sx) = 0x19;
289288   }
290289}
r14063r14064
396395      else
397396         vcond = yloc & 0x01;
398397
399      if (xloc >= cliprect.min_x && xloc <= cliprect.max_x && yloc >= cliprect.min_y && yloc <= cliprect.max_y)
398      if (cliprect.contains(xloc, yloc))
400399      {
401400         if ((hcond ^ vcond) == 0)
402401         {
src/mame/video/galaxold.c
r14063r14064
623623   {
624624      x--;
625625
626      if ((x >= cliprect.min_x) && (x <= cliprect.max_x) && (y >= cliprect.min_y) && (y <= cliprect.max_y))
626      if (cliprect.contains(x, y))
627627         bitmap.pix16(y, x) = BULLETS_COLOR_BASE;
628628   }
629629}
r14063r14064
11431143   {
11441144      x--;
11451145
1146      if ((x >= cliprect.min_x) && (x <= cliprect.max_x) && (y >= cliprect.min_y) && (y <= cliprect.max_y))
1146      if (cliprect.contains(x, y))
11471147      {
11481148         int color;
11491149
r14063r14064
11631163
11641164   x = x - 6;
11651165
1166   if ((x >= cliprect.min_x) && (x <= cliprect.max_x) && (y >= cliprect.min_y) && (y <= cliprect.max_y))
1166   if (cliprect.contains(x, y))
11671167      /* yellow bullets */
11681168      bitmap.pix16(y, x) = BULLETS_COLOR_BASE;
11691169}
r14063r14064
11751175
11761176   x = x - 6;
11771177
1178   if ((x >= cliprect.min_x) && (x <= cliprect.max_x) && (y >= cliprect.min_y) && (y <= cliprect.max_y))
1178   if (cliprect.contains(x, y))
11791179      bitmap.pix16(y, x) = 32 + state->m_darkplnt_bullet_color;
11801180}
11811181
r14063r14064
12001200         x--;
12011201      }
12021202
1203      if ((x >= cliprect.min_x) && (x <= cliprect.max_x) && (y >= cliprect.min_y) && (y <= cliprect.max_y))
1203      if (cliprect.contains(x, y))
12041204         bitmap.pix16(y, x) = color;
12051205   }
12061206}
r14063r14064
13771377static void dambustr_draw_upper_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
13781378{
13791379   galaxold_state *state = machine.driver_data<galaxold_state>();
1380   rectangle clip;
13811380
13821381   if (flip_screen_x_get(machine))
13831382   {
1384      clip.min_x = 254 - state->m_dambustr_bg_split_line;
1385      clip.max_x = state->m_dambustr_bg_split_line;
1386      clip.min_y = 0;
1387      clip.max_y = 255;
1383      rectangle clip(254 - state->m_dambustr_bg_split_line, state->m_dambustr_bg_split_line, 0, 255);
13881384      copybitmap(bitmap, *state->m_dambustr_tmpbitmap, 0, 0, 0, 0, clip);
13891385   }
13901386   else
13911387   {
1392      clip.min_x = 0;
1393      clip.max_x = 254 - state->m_dambustr_bg_split_line;
1394      clip.min_y = 0;
1395      clip.max_y = 255;
1388      rectangle clip(0, 254 - state->m_dambustr_bg_split_line, 0, 255);
13961389      copybitmap(bitmap, *state->m_dambustr_tmpbitmap, 0, 0, 0, 0, clip);
13971390   }
13981391}
r14063r14064
14821475   if (state->m_flipscreen_y)
14831476      y = 255 - y;
14841477
1485   if ((x >= cliprect.min_x) && (x <= cliprect.max_x) && (y >= cliprect.min_y) && (y <= cliprect.max_y))
1478   if (cliprect.contains(x, y))
14861479      bitmap.pix16(y, x) = state->m_stars_colors_start + color;
14871480}
14881481
src/mame/video/wgp.c
r14063r14064
538538   int flipscreen = 0;   /* n/a */
539539   int machine_flip = 0;   /* for  ROT 180 ? */
540540
541   UINT16 screen_width = cliprect.max_x - cliprect.min_x + 1;
541   UINT16 screen_width = cliprect.width();
542542   UINT16 min_y = cliprect.min_y;
543543   UINT16 max_y = cliprect.max_y;
544544
src/mame/video/ssv.c
r14063r14064
628628
629629   /* Set up a clipping region for the tilemap slice .. */
630630
631   clip.min_x = sx;
632   clip.max_x = sx + xnum * 0x10 - 1;
633   clip.min_y = sy;
634   clip.max_y = sy + ynum * 0x8  - 1;
631   clip.set(sx, sx + xnum * 0x10 - 1, sy, sy + ynum * 0x8  - 1);
635632
636633   /* .. and clip it against the visible screen */
637634
src/mame/video/angelkds.c
r14063r14064
281281   bitmap.fill(0x3f, cliprect); /* is there a register controling the colour?, we currently use the last colour of the tx palette */
282282
283283   /* draw top of screen */
284   clip.min_x = 8*0;
285   clip.max_x = 8*16-1;
286   clip.min_y = visarea.min_y;
287   clip.max_y = visarea.max_y;
284   clip.set(8*0, 8*16-1, visarea.min_y, visarea.max_y);
288285
289286   if ((state->m_layer_ctrl & 0x80) == 0x00)
290287      tilemap_draw(bitmap, clip, state->m_bgtop_tilemap, 0, 0);
r14063r14064
295292      tilemap_draw(bitmap, clip, state->m_tx_tilemap, 0, 0);
296293
297294   /* draw bottom of screen */
298   clip.min_x = 8*16;
299   clip.max_x = 8*32-1;
300   clip.min_y = visarea.min_y;
301   clip.max_y = visarea.max_y;
295   clip.set(8*16, 8*32-1, visarea.min_y, visarea.max_y);
302296
303297   if ((state->m_layer_ctrl & 0x40) == 0x00)
304298      tilemap_draw(bitmap, clip, state->m_bgbot_tilemap, 0, 0);
src/mame/video/warpwarp.c
r14063r14064
217217
218218INLINE void geebee_plot(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, pen_t pen)
219219{
220   if (x >= cliprect.min_x && x <= cliprect.max_x && y >= cliprect.min_y && y <= cliprect.max_y)
220   if (cliprect.contains(x, y))
221221      bitmap.pix16(y, x) = pen;
222222}
223223
src/mame/video/jaguar.c
r14063r14064
237237{
238238   const rectangle &visarea = machine.primary_screen->visible_area();
239239
240   int width = visarea.max_x + 1 - visarea.min_x;
241   int height = visarea.max_y + 1 - visarea.min_y;
240   int width = visarea.width();
241   int height = visarea.height();
242242   /* only 2 lightguns are connected */
243243   *x = visarea.min_x + (((input_port_read(machine, player ? "FAKE2_X" : "FAKE1_X") & 0xff) * width) >> 8);
244244   *y = visarea.min_y + (((input_port_read(machine, player ? "FAKE2_Y" : "FAKE1_Y") & 0xff) * height) >> 8);
r14063r14064
751751               /* adjust for the half-lines */
752752               if (hperiod != 0 && vperiod != 0 && hbend < hbstart && vbend < vbstart && hbstart < hperiod)
753753               {
754                  rectangle visarea;
755                  visarea.min_x = hbend / 2;
756                  visarea.max_x = hbstart / 2 - 1;
757                  visarea.min_y = vbend / 2;
758                  visarea.max_y = vbstart / 2 - 1;
754                  rectangle visarea(hbend / 2, hbstart / 2 - 1, vbend / 2, vbstart / 2 - 1);
759755                  space->machine().primary_screen->configure(hperiod / 2, vperiod / 2, visarea, HZ_TO_ATTOSECONDS((double)pixel_clock * 2 / hperiod / vperiod));
760756               }
761757            }
src/mame/video/magmax.c
r14063r14064
7171   state_save_register_global(machine, state->m_flipscreen);
7272
7373   state->m_prom_tab = auto_alloc_array(machine, UINT32, 256);
74   
74
7575   machine.primary_screen->register_screen_bitmap(state->m_bitmap);
7676
7777   /* Allocate temporary bitmap */
src/mame/video/rallyx.c
r14063r14064
448448
449449static void plot_star( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, int color )
450450{
451   if (y < cliprect.min_y || y > cliprect.max_y ||
452      x < cliprect.min_x || x > cliprect.max_x)
451   if (!cliprect.contains(x, y))
453452      return;
454453
455454   if (flip_screen_x_get(machine))
src/mame/video/realbrk.c
r14063r14064
222222   int max_x = machine.primary_screen->width();
223223   int max_y = machine.primary_screen->height();
224224
225   rectangle spritetile_clip;
226   spritetile_clip.min_x = 0;
227   spritetile_clip.min_y = 0;
228   spritetile_clip.max_x = 31;
229   spritetile_clip.max_y = 31;
225   rectangle spritetile_clip(0, 31, 0, 31);
230226
231227   for ( offs = 0x3000/2; offs < 0x3600/2; offs += 2/2 )
232228   {
src/mame/video/namcos1.c
r14063r14064
395395   i = ((state->m_cus116[6] << 8) | state->m_cus116[7]) - 0x11 - 1;   // max y
396396   if (new_clip.max_y > i) new_clip.max_y = i;
397397
398   if (new_clip.max_x < new_clip.min_x || new_clip.max_y < new_clip.min_y)
398   if (new_clip.empty())
399399      return 0;
400400
401401
src/mame/video/galaga.c
r14063r14064
557557            x = (star_seed_tab[star_cntr].x + state->m_stars_scrollx) % 256 + x_align;
558558            y = (y_align + star_seed_tab[star_cntr].y + state->m_stars_scrolly) % 256;
559559
560            if (x >= cliprect.min_x && x <= cliprect.max_x && y >= cliprect.min_y && y <= cliprect.max_y)
560            if (cliprect.contains(x, y))
561561               bitmap.pix16(y, x) = STARS_COLOR_BASE + star_seed_tab[ star_cntr ].col;
562562         }
563563
src/mame/video/psychic5.c
r14063r14064
405405      switch (state->m_bg_clip_mode)
406406      {
407407      case  0: case  4: case  8: case 12: case 16:
408         clip.min_x = clip.max_x = clip.min_y = clip.max_y = 0;
408         clip.set(0, 0, 0, 0);
409409         break;
410410      case  1: clip.min_y = state->m_sy1; break;
411411      case  3: clip.max_y = state->m_sy2; break;
r14063r14064
416416      }
417417
418418      if (flip_screen_get(machine))
419      {
420         int min_x,max_x,min_y,max_y;
421         min_x = 255 - clip.max_x;
422         max_x = 255 - clip.min_x;
423         min_y = 255 - clip.max_y;
424         max_y = 255 - clip.min_y;
425         clip.min_x = min_x;
426         clip.max_x = max_x;
427         clip.min_y = min_y;
428         clip.max_y = max_y;
429      }
419         clip.set(255 - clip.max_x, 255 - clip.min_x, 255 - clip.max_y, 255 - clip.min_y);
430420   }
431421
432422   tilemap_draw(bitmap, clip, state->m_bg_tilemap, 0, 0);
src/mame/video/jack.c
r14063r14064
5252   SET_TILE_INFO(0, code, color, 0);
5353}
5454
55static UINT32 tilemap_scan_cols_flipy( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
55static TILEMAP_MAPPER( tilemap_scan_cols_flipy )
5656{
5757   /* logical (col,row) -> memory offset */
5858   return (col * num_rows) + (num_rows - 1 - row);
src/mame/video/blockout.c
r14063r14064
7777   int color;
7878   const rectangle &visarea = machine.primary_screen->visible_area();
7979
80   if (x < visarea.min_x || x > visarea.max_x || y < visarea.min_y || y > visarea.max_y)
80   if (!visarea.contains(x, y))
8181      return;
8282
8383   front = state->m_videoram[y * 256 + x / 2];
src/mame/video/canyon.c
r14063r14064
6565      int sx = 254 - state->m_videoram[0x3d0 + 2 * i + 0x5];
6666      int sy = 246 - state->m_videoram[0x3d0 + 2 * i + 0xc];
6767
68      rectangle rect;
68      rectangle rect(sx, sx + 1, sy, sy + 1);
69      rect &= cliprect;
6970
70      rect.min_x = sx;
71      rect.min_y = sy;
72      rect.max_x = sx + 1;
73      rect.max_y = sy + 1;
74
75      if (rect.min_x < cliprect.min_x) rect.min_x = cliprect.min_x;
76      if (rect.min_y < cliprect.min_y) rect.min_y = cliprect.min_y;
77      if (rect.max_x > cliprect.max_x) rect.max_x = cliprect.max_x;
78      if (rect.max_y > cliprect.max_y) rect.max_y = cliprect.max_y;
79
8071      bitmap.fill(1 + 2 * i, rect);
8172   }
8273}
src/mame/video/xmen.c
r14063r14064
154154      int offset;
155155
156156   //  const rectangle *visarea = screen.machine().primary_screen->visible_area();
157   //  cliprect.min_x = visarea->min_x;
158   //  cliprect.max_x = visarea->max_x;
159   //  cliprect.min_y = visarea->min_y;
160   //  cliprect.max_y = visarea->max_y;
157   //  cliprect = *visarea;
161158
162      cliprect.min_x = 0;
163      cliprect.max_x = 64 * 8 - 1;
164      cliprect.min_y = 2 * 8;
165      cliprect.max_y = 30 * 8 - 1;
159      cliprect.set(0, 64 * 8 - 1, 2 * 8, 30 * 8 - 1);
166160
167161
168162      if (screen.machine().primary_screen->frame_number() & 0x01)
r14063r14064
172166         memcpy(state->m_k053247_ram, state->m_xmen6p_spriteramright, 0x1000);
173167
174168         /* we write the entire content of the tileram to the chip to ensure
175              everything gets marked as dirty and the desired tilemap is rendered
176              this is not very efficient!
177              */
169               everything gets marked as dirty and the desired tilemap is rendered
170               this is not very efficient!
171               */
178172         for (offset = 0; offset < (0xc000 / 2); offset++)
179173         {
180174   //          K052109_lsb_w
r14063r14064
190184         memcpy(state->m_k053247_ram, state->m_xmen6p_spriteramleft, 0x1000);
191185
192186         /* we write the entire content of the tileram to the chip to ensure
193              everything gets marked as dirty and the desired tilemap is rendered
187               everything gets marked as dirty and the desired tilemap is rendered
194188
195              this is not very efficient!
196              */
189               this is not very efficient!
190               */
197191         for (offset = 0; offset < (0xc000 / 2); offset++)
198192         {
199193   //          K052109_lsb_w
r14063r14064
230224      k052109_tilemap_draw(state->m_k052109, *renderbitmap, cliprect, layer[2], 0, 4);
231225
232226   /* this isn't supported anymore and it is unsure if still needed; keeping here for reference
233       pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
227        pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
234228      k053247_sprites_draw(state->m_k053246, *renderbitmap, cliprect);
235229   }
236230}
src/mame/video/videopin.c
r14063r14064
4747   {
4848      for (col = 0; col < 48; col++)
4949      {
50         UINT32 offset = get_memory_offset(col, row, 48, 32);
50         UINT32 offset = state->m_bg_tilemap->memory_index(col, row);
5151
5252         if (state->m_video_ram[offset] & 0x80)   /* ball bit found */
5353         {
54            rectangle rect;
55
5654            int x = 8 * col;
5755            int y = 8 * row;
5856
r14063r14064
6159
6260            x += 4;   /* account for delayed loading of flip-flop C4 */
6361
64            rect.min_x = x;
65            rect.min_y = y;
66            rect.max_x = x + 15;
67            rect.max_y = y + 15;
62            rectangle rect(x, x + 15, y, y + 15);
63            rect &= cliprect;
6864
69            if (rect.min_x < cliprect.min_x)
70               rect.min_x = cliprect.min_x;
71            if (rect.min_y < cliprect.min_y)
72               rect.min_y = cliprect.min_y;
73            if (rect.max_x > cliprect.max_x)
74               rect.max_x = cliprect.max_x;
75            if (rect.max_y > cliprect.max_y)
76               rect.max_y = cliprect.max_y;
77
7865            x -= state->m_ball_x;
7966            y -= state->m_ball_y;
8067
src/mame/video/atari.c
r14063r14064
712712
713713   LOG(("atari antic_vh_start\n"));
714714    memset(&antic, 0, sizeof(antic));
715   
715
716716   antic.bitmap = auto_bitmap_ind16_alloc(machine, machine.primary_screen->width(), machine.primary_screen->height());
717717
718718   antic.renderer = antic_mode_0_xx;
src/mame/video/psikyosh.c
r14063r14064
342342   {
343343      rectangle cliprect;
344344
345      cliprect.min_x = 0;
346      cliprect.max_x = state->m_bg_bitmap.width() - 1;
347      cliprect.min_y = sy * 16;
348      cliprect.max_y = cliprect.min_y + 16 - 1;
345      cliprect.set(0, state->m_bg_bitmap.width() - 1, sy * 16, cliprect.min_y + 16 - 1);
349346
350347      state->m_bg_bitmap.fill(BG_TRANSPEN, cliprect);
351348      int width = size * 16;
r14063r14064
391388   int last_bank[32]; // corresponds to bank of bitmap in state->m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each
392389   for(int ii = 0; ii < 32; ii++) last_bank[ii] = -1;
393390
394   int scr_width = (cliprect.max_x-cliprect.min_x + 1);
395   int scr_height = (cliprect.max_y-cliprect.min_y + 1);
391   int scr_width = cliprect.width();
392   int scr_height = cliprect.height();
396393   UINT32 *scroll_reg = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4];
397394   UINT32 *pzab_reg   = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; // pri, zoom, alpha, bank
398395
src/mame/video/pk8000.c
r14063r14064
100100   int x,y,j,b;
101101   UINT16 offset = (pk8000_video_mode & 0xc0) << 8;
102102   rectangle my_rect;
103   my_rect.min_x = 0;
104   my_rect.max_x = 256+32-1;
105   my_rect.min_y = 0;
106   my_rect.max_y = 192+32-1;
103   my_rect.set(0, 256+32-1, 0, 192+32-1);
107104
108105   if (pk8000_video_enable) {
109106      bitmap.fill((pk8000_video_color >> 4) & 0x0f, my_rect);
src/mame/video/sega16sp.c
r14063r14064
11051105   /* clear out any scanlines we might be using */
11061106   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
11071107      if (!(rotatebase[y & ~1] & 0xc000))
1108         memset(&bitmap.pix16(y, cliprect.min_x), 0xff, (cliprect.max_x - cliprect.min_x + 1) * sizeof(UINT16));
1108         memset(&bitmap.pix16(y, cliprect.min_x), 0xff, cliprect.width() * sizeof(UINT16));
11091109
11101110   /* now scan backwards and render the sprites in order */
11111111   for (data = sega16sp->spriteram; !(data[0] & 0x8000) && !visited[next]; data = sega16sp->spriteram + next * 8)
src/mame/video/konamigx.c
r14063r14064
9090void K053936GP_set_cliprect(int chip, int minx, int maxx, int miny, int maxy)
9191{
9292   rectangle &cliprect = K053936_cliprect[chip];
93   cliprect.min_x = minx;
94   cliprect.max_x = maxx;
95   cliprect.min_y = miny;
96   cliprect.max_y = maxy;
93   cliprect.set(minx, maxx, miny, maxy);
9794}
9895
9996INLINE void K053936GP_copyroz32clip( running_machine &machine,
r14063r14064
10561053{
10571054   const rectangle &visarea = machine.primary_screen->visible_area();
10581055
1059   int w = visarea.max_x - visarea.min_x + 1;
1060   int h = visarea.max_y - visarea.min_y + 1;
1056   int w = visarea.width();
1057   int h = visarea.height();
10611058
10621059   UINT8 *zptr = gx_objzbuf;
10631060   int ecx = h;
r14063r14064
15751572               {
15761573                  int pixeldouble_output = 0;
15771574                  const rectangle &visarea = machine.primary_screen->visible_area();
1578                  int width = visarea.max_x - visarea.min_x + 1;
1575                  int width = visarea.width();
15791576
15801577                  if (width>512) // vsnetscr case
15811578                     pixeldouble_output = 1;
r14063r14064
23192316   gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine,512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
23202317
23212318
2322   gxtype1_roz_dstbitmapclip.min_x = 0;
2323   gxtype1_roz_dstbitmapclip.max_x = 512-1;
2324   gxtype1_roz_dstbitmapclip.min_y = 0;
2325   gxtype1_roz_dstbitmapclip.max_y = 512-1;
2319   gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1);
23262320
23272321
23282322   K053936_wraparound_enable(0, 1);
r14063r14064
23602354   gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine,512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
23612355
23622356
2363   gxtype1_roz_dstbitmapclip.min_x = 0;
2364   gxtype1_roz_dstbitmapclip.max_x = 512-1;
2365   gxtype1_roz_dstbitmapclip.min_y = 0;
2366   gxtype1_roz_dstbitmapclip.max_y = 512-1;
2357   gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1);
23672358
23682359
23692360   K053936_wraparound_enable(0, 1);
r14063r14064
24472438   {
24482439      // we're going to throw half of this away anyway in post-process, so only render what's needed
24492440      rectangle temprect;
2450      temprect.min_x = cliprect.min_x;
2441      temprect = cliprect;
24512442      temprect.max_x = cliprect.min_x+320;
2452      temprect.min_y = cliprect.min_y;
2453      temprect.max_y = cliprect.max_y;
24542443
24552444      if (konamigx_type3_psac2_actual_bank == 1) K053936_0_zoom_draw(*type3_roz_temp_bitmap, temprect,gx_psac_tilemap_alt, 0,0,0); // soccerss playfield
24562445      else K053936_0_zoom_draw(*type3_roz_temp_bitmap, temprect,gx_psac_tilemap, 0,0,0); // soccerss playfield
src/mame/video/vectrex.c
r14063r14064
284284   screen_device *screen = machine.first_screen();
285285   const rectangle &visarea = screen->visible_area();
286286
287   state->m_x_center=((visarea.max_x - visarea.min_x) / 2) << 16;
288   state->m_y_center=((visarea.max_y - visarea.min_y) / 2) << 16;
287   state->m_x_center=(visarea.width() / 2) << 16;
288   state->m_y_center=(visarea.height() / 2) << 16;
289289   state->m_x_max = visarea.max_x << 16;
290290   state->m_y_max = visarea.max_y << 16;
291291
r14063r14064
484484   screen_device *screen = machine.first_screen();
485485   const rectangle &visarea = screen->visible_area();
486486
487   state->m_x_center=((visarea.max_x - visarea.min_x) / 2) << 16;
488   state->m_y_center=((visarea.max_y - visarea.min_y) / 2) << 16;
487   state->m_x_center=(visarea.width() / 2) << 16;
488   state->m_y_center=(visarea.height() / 2) << 16;
489489   state->m_x_max = visarea.max_x << 16;
490490   state->m_y_max = visarea.max_y << 16;
491491
src/mame/video/starshp1.c
r14063r14064
399399      rect.min_y = get_sprite_vpos(state, 13);
400400      rect.max_x = rect.min_x + screen.machine().gfx[1]->width - 1;
401401      rect.max_y = rect.min_y + screen.machine().gfx[1]->height - 1;
402     
402
403403      rect &= state->m_helper.cliprect();
404404
405405      state->m_helper.fill(0, visarea);
src/mame/video/taito_f2.c
r14063r14064
971971   if (vblank_on)
972972   {
973973      /* spriteram[2] and [3] are 1 frame behind...
974          probably thundfox_eof_callback would work fine */
974           probably thundfox_eof_callback would work fine */
975975
976976      taitof2_state *state = screen.machine().driver_data<taitof2_state>();
977977      UINT16 *spriteram = state->m_spriteram;
src/mame/video/hng64.c
r14063r14064
11101110      int xinc,yinc;
11111111
11121112      const rectangle &visarea = machine.primary_screen->visible_area();
1113      clip.min_x = visarea.min_x;
1114      clip.max_x = visarea.max_x;
1115      clip.min_y = visarea.min_y;
1116      clip.max_y = visarea.max_y;
1113      clip = visarea;
11171114
11181115      if (global_tileregs&0x04000000) // globally selects alt scroll register layout???
11191116      {
r14063r14064
15411538      // Blit the color buffer into the primary bitmap
15421539      for (y = cliprect.min_y; y <= cliprect.max_y; y++)
15431540      {
1544         UINT32 *src = &state->m_colorBuffer3d[y * (cliprect.max_x-cliprect.min_x)];
1541         UINT32 *src = &state->m_colorBuffer3d[y * cliprect.width()];
15451542         UINT32 *dst = &bitmap.pix32(y, cliprect.min_x);
15461543
15471544         for (x = cliprect.min_x; x <= cliprect.max_x; x++)
r14063r14064
16981695   state->m_additive_tilemap_debug = 0;
16991696
17001697   // 3d Buffer Allocation
1701   state->m_depthBuffer3d = auto_alloc_array(machine, float,  (visarea.max_x)*(visarea.max_y));
1702   state->m_colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea.max_x)*(visarea.max_y));
1698   state->m_depthBuffer3d = auto_alloc_array(machine, float,  (visarea.max_x + 1)*(visarea.max_y + 1));
1699   state->m_colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea.max_x + 1)*(visarea.max_y + 1));
17031700}
17041701
17051702
src/mame/video/groundfx.c
r14063r14064
1010   state->m_spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
1111
1212   /* Hack */
13   state->m_hack_cliprect.min_x = 69;
14   state->m_hack_cliprect.max_x = 250;
15   state->m_hack_cliprect.min_y = 24 + 5;
16   state->m_hack_cliprect.max_y = 24 + 44;
13   state->m_hack_cliprect.set(69, 250, 24 + 5, 24 + 44);
1714}
1815
1916/***************************************************************
src/mame/video/suprloco.c
r14063r14064
169169      y = bitmap.height() - y - 1;
170170   }
171171
172   if (x < cliprect.min_x ||
173      x > cliprect.max_x ||
174      y < cliprect.min_y ||
175      y > cliprect.max_y)
176      return;
177
178   bitmap.pix16(y, x) = color;
172   if (cliprect.contains(x, y))
173      bitmap.pix16(y, x) = color;
179174}
180175
181176
src/mame/video/m58.c
r14063r14064
159159}
160160
161161
162static UINT32 yard_tilemap_scan_rows( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
162static TILEMAP_MAPPER( yard_tilemap_scan_rows )
163163{
164164   /* logical (col,row) -> memory offset */
165165   if (col >= 32)
src/mame/video/zac2650.c
r14063r14064
7979       {
8080          for (y = fy; y < fy + machine.gfx[expand]->height; y++)
8181            {
82             if ((x < visarea.min_x) ||
83                 (x > visarea.max_x) ||
84                 (y < visarea.min_y) ||
85                 (y > visarea.max_y))
86             {
87                continue;
88             }
89
90               Checksum += state->m_spritebitmap.pix16(y, x);
82             if (visarea.contains(x, y))
83                  Checksum += state->m_spritebitmap.pix16(y, x);
9184            }
9285       }
9386
r14063r14064
10598       {
10699          for (y = fy; y < fy + machine.gfx[expand]->height; y++)
107100            {
108             if ((x < visarea.min_x) ||
109                 (x > visarea.max_x) ||
110                 (y < visarea.min_y) ||
111                 (y > visarea.max_y))
112             {
113                continue;
114             }
115
116               Checksum -= state->m_spritebitmap.pix16(y, x);
101             if (visarea.contains(x, y))
102                  Checksum -= state->m_spritebitmap.pix16(y, x);
117103            }
118104       }
119105
r14063r14064
194180           {
195181              for (y = by; y < by + machine.gfx[expand]->height; y++)
196182                {
197                 if ((x < visarea.min_x) ||
198                     (x > visarea.max_x) ||
199                     (y < visarea.min_y) ||
200                     (y > visarea.max_y))
201                 {
202                    continue;
203                 }
204
205                   if (bitmap.pix16(y, x) != state->m_bitmap.pix16(y, x))
206                   {
207                       state->m_CollisionBackground = 0x80;
208                    break;
209                 }
183                 if (visarea.contains(x, y))
184                      if (bitmap.pix16(y, x) != state->m_bitmap.pix16(y, x))
185                      {
186                          state->m_CollisionBackground = 0x80;
187                       break;
188                    }
210189                }
211190           }
212191
src/mame/video/shangha3.c
r14063r14064
151151//if (shangha3_ram[offs+11] || shangha3_ram[offs+12])
152152//logerror("offs %04x: sx %04x sy %04x zoom %04x %04x %04x %04x fx %d fy %d\n",offs,sx,sy,zoomx,shangha3_ram[offs+11]),shangha3_ram[offs+12],zoomy,flipx,flipy);
153153
154         myclip.min_x = sx;
155         myclip.max_x = sx + sizex;
156         myclip.min_y = sy;
157         myclip.max_y = sy + sizey;
154         myclip.set(sx, sx + sizex, sy, sy + sizey);
158155         myclip &= rawbitmap.cliprect();
159156
160157         if (shangha3_ram[offs+4] & 0x08)   /* tilemap */
src/mame/video/taotaido.c
r14063r14064
208208   rectangle clip;
209209
210210   const rectangle &visarea = screen.visible_area();
211   clip.min_x = visarea.min_x;
212   clip.max_x = visarea.max_x;
213   clip.min_y = visarea.min_y;
214   clip.max_y = visarea.max_y;
211   clip = visarea;
215212
216213   for (line = 0; line < 224;line++)
217214   {
src/mame/video/m107.c
r14063r14064
319319   int line;
320320   rectangle clip;
321321   const rectangle &visarea = machine.primary_screen->visible_area();
322   clip.min_x = visarea.min_x;
323   clip.max_x = visarea.max_x;
324   clip.min_y = visarea.min_y;
325   clip.max_y = visarea.max_y;
322   clip = visarea;
326323
327324   if (state->m_control[0x08 + laynum] & 0x02)
328325   {
src/mame/video/twin16.c
r14063r14064
550550         state->m_need_process_spriteram = 1;
551551
552552         /* if the sprite preprocessor is used, sprite ram is copied to an external buffer first,
553           as evidenced by 1-frame sprite lag in gradius2 and devilw otherwise, though there's probably
554           more to it than that */
553            as evidenced by 1-frame sprite lag in gradius2 and devilw otherwise, though there's probably
554            more to it than that */
555555         memcpy(&screen.machine().generic.buffered_spriteram.u16[0x1800],state->m_sprite_buffer,0x800*sizeof(UINT16));
556556         memcpy(state->m_sprite_buffer,&screen.machine().generic.spriteram.u16[0x1800],0x800*sizeof(UINT16));
557557      }
src/mame/video/archimds.c
r14063r14064
6464
6565                     if(vidc_interlace)
6666                     {
67                        if ((res_x) >= 0 &&
68                           (res_y) >= 0 &&
69                           (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend)
67                        if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend)
7068                           bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen>>(xi))&0x1];
71                        if ((res_x) >= 0 &&
72                           (res_y) >= 0 &&
73                           (res_x) <= screen.visible_area().max_x && (res_y+1) <= screen.visible_area().max_y && (res_x) <= xend && (res_y+1) <= yend)
69                        if (cliprect.contains(res_x, res_y+1) && (res_x) <= xend && (res_y+1) <= yend)
7470                           bitmap.pix32(res_y+1, res_x) = screen.machine().pens[(pen>>(xi))&0x1];
7571                     }
7672                     else
7773                     {
78                        if ((res_x) >= 0 &&
79                           (res_y) >= 0 &&
80                           (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend)
74                        if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend)
8175                           bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen>>(xi))&0x1];
8276                     }
8377                  }
r14063r14064
10094
10195                  if(vidc_interlace)
10296                  {
103                     if ((res_x) >= 0 &&
104                        (res_y) >= 0 &&
105                        (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend)
97                     if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend)
10698                        bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen&0xff)+0x100];
107                     if ((res_x) >= 0 &&
108                        (res_y) >= 0 &&
109                        (res_x) <= screen.visible_area().max_x && (res_y+1) <= screen.visible_area().max_y && (res_x) <= xend && (res_y+1) <= yend)
99                     if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y+1) <= yend)
110100                        bitmap.pix32(res_y+1, res_x) = screen.machine().pens[(pen&0xff)+0x100];
111101                  }
112102                  else
113103                  {
114                     if ((res_x) >= 0 &&
115                        (res_y) >= 0 &&
116                        (res_x) <= screen.visible_area().max_x && (res_y) <= screen.visible_area().max_y && (res_x) <= xend && (res_y) <= yend)
104                     if (cliprect.contains(res_x, res_y) && (res_x) <= xend && (res_y) <= yend)
117105                        bitmap.pix32(res_y, res_x) = screen.machine().pens[(pen&0xff)+0x100];
118106                  }
119107
src/mame/video/triplhnt.c
r14063r14064
5959
6060      if (state->m_sprite_zoom)
6161      {
62         rect.min_x = hpos - 16;
63         rect.min_y = 196 - vpos;
64         rect.max_x = rect.min_x + 63;
65         rect.max_y = rect.min_y + 63;
62         rect.set(hpos - 16, hpos - 16 + 63, 196 - vpos, 196 - vpos + 63);
6663      }
6764      else
6865      {
69         rect.min_x = hpos - 16;
70         rect.min_y = 224 - vpos;
71         rect.max_x = rect.min_x + 31;
72         rect.max_y = rect.min_y + 31;
66         rect.set(hpos - 16, hpos - 16 + 31, 224 - vpos, 224 - vpos + 31);
7367      }
7468
7569      /* render sprite to auxiliary bitmap */
r14063r14064
7872         2 * code + state->m_sprite_bank, 0, code & 8, 0,
7973         rect.min_x, rect.min_y);
8074
81      if (rect.min_x < cliprect.min_x)
82         rect.min_x = cliprect.min_x;
83      if (rect.min_y < cliprect.min_y)
84         rect.min_y = cliprect.min_y;
85      if (rect.max_x > cliprect.max_x)
86         rect.max_x = cliprect.max_x;
87      if (rect.max_y > cliprect.max_y)
88         rect.max_y = cliprect.max_y;
75      rect &= cliprect;
8976
9077      /* check for collisions and copy sprite */
9178
src/mame/video/exerion.c
r14063r14064
339339      }
340340
341341      /* draw the scanline */
342      draw_scanline16(bitmap, cliprect.min_x, y, cliprect.max_x - cliprect.min_x + 1, &scanline[cliprect.min_x], NULL);
342      draw_scanline16(bitmap, cliprect.min_x, y, cliprect.width(), &scanline[cliprect.min_x], NULL);
343343   }
344344}
345345
src/mame/video/gp9001.c
r14063r14064
914914                     {
915915                        int drawxx = xx+sx;
916916
917                        if (drawxx>=cliprect.min_x && drawxx<=cliprect.max_x && drawyy>=cliprect.min_y && drawyy<=cliprect.max_y)
917                        if (cliprect.contains(drawxx, drawyy))
918918                        {
919919                           UINT8 pix = srcdata[count];
920920                           UINT16* dstptr = &bitmap.pix16(drawyy, drawxx);
src/mame/video/nmk16.c
r14063r14064
798798   {
799799      nmk16_state *state = screen.machine().driver_data<nmk16_state>();
800800      /* sprites are DMA'd from Main RAM to a private buffer automatically
801          (or at least this is how I interpret the datasheet) */
801           (or at least this is how I interpret the datasheet) */
802802
803803      /* -- I actually see little evidence to support this, sprite lag
804             in some games should be checked on real boards */
804              in some games should be checked on real boards */
805805
806806   //  memcpy(state->m_spriteram_old2,state->m_spriteram_old,0x1000);
807807      memcpy(state->m_spriteram_old2,state->m_mainram+0x8000/2,0x1000);
r14063r14064
815815   {
816816      nmk16_state *state = screen.machine().driver_data<nmk16_state>();
817817      /* sprites are DMA'd from Main RAM to a private buffer automatically
818          (or at least this is how I interpret the datasheet) */
818           (or at least this is how I interpret the datasheet) */
819819
820820      /* -- I actually see little evidence to support this, sprite lag
821             in some games should be checked on real boards */
821              in some games should be checked on real boards */
822822
823823      /* strahl sprites are allocated in memory range FF000-FFFFF */
824824
src/mame/video/m10.c
r14063r14064
4242   8*8   /* every char takes 8 consecutive bytes */
4343};
4444
45static UINT32 tilemap_scan( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
45static TILEMAP_MAPPER( tilemap_scan )
4646{
4747   return (31 - col) * 32 + row;
4848}
src/mame/drivers/magicard.c
r14063r14064
402402
403403            color = ((state->m_magicram[count]) & 0x000f)>>0;
404404
405            if(((x*4)+3)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
405            if(cliprect.contains((x*4)+3, y))
406406               bitmap.pix32(y, (x*4)+3) = screen.machine().pens[color];
407407
408408            color = ((state->m_magicram[count]) & 0x00f0)>>4;
409409
410            if(((x*4)+2)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
410            if(cliprect.contains((x*4)+2, y))
411411               bitmap.pix32(y, (x*4)+2) = screen.machine().pens[color];
412412
413413            color = ((state->m_magicram[count]) & 0x0f00)>>8;
414414
415            if(((x*4)+1)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
415            if(cliprect.contains((x*4)+1, y))
416416               bitmap.pix32(y, (x*4)+1) = screen.machine().pens[color];
417417
418418            color = ((state->m_magicram[count]) & 0xf000)>>12;
419419
420            if(((x*4)+0)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
420            if(cliprect.contains((x*4)+0, y))
421421               bitmap.pix32(y, (x*4)+0) = screen.machine().pens[color];
422422
423423            count++;
r14063r14064
434434
435435            color = ((state->m_magicram[count]) & 0x00ff)>>0;
436436
437            if(((x*2)+1)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
437            if(cliprect.contains((x*2)+1, y))
438438               bitmap.pix32(y, (x*2)+1) = screen.machine().pens[color];
439439
440440            color = ((state->m_magicram[count]) & 0xff00)>>8;
441441
442            if(((x*2)+0)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
442            if(cliprect.contains((x*2)+0, y))
443443               bitmap.pix32(y, (x*2)+0) = screen.machine().pens[color];
444444
445445            count++;
src/mame/drivers/ccastles.c
r14063r14064
210210   assert(state->m_vblank_end < state->m_vblank_start);
211211
212212   /* reconfigure the visible area to match */
213   visarea.min_x = 0;
214   visarea.max_x = 255;
215   visarea.min_y = state->m_vblank_end;
216   visarea.max_y = state->m_vblank_start - 1;
213   visarea.set(0, 255, state->m_vblank_end, state->m_vblank_start - 1);
217214   machine.primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL);
218215
219216   /* configure the ROM banking */
src/mame/drivers/mediagx.c
r14063r14064
251251      state->m_frame_width = width;
252252      state->m_frame_height = height;
253253
254      visarea.min_x = visarea.min_y = 0;
255      visarea.max_x = width - 1;
256      visarea.max_y = height - 1;
254      visarea.set(0, width - 1, 0, height - 1);
257255      machine.primary_screen->configure(width, height * 262 / 240, visarea, machine.primary_screen->frame_period().attoseconds);
258256   }
259257
src/mame/drivers/zn.c
r14063r14064
28082808   ROM_LOAD( "ts2u_04.2h", 0x0000000, 0x080000, CRC(ddb52e7c) SHA1(e77891abae7681d911ef6eba2e0920d81433ebe6) )
28092809
28102810   ROM_REGION32_LE( 0x2400000, "user2", 0 )
2811   ROM_LOAD( "ts2-05",  0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) )
2812   ROM_LOAD( "ts2-06m", 0x0400000, 0x400000, CRC(cd7e0a27) SHA1(325b5f2e653cdea07cddc9d20d12b5ab50dca949) )
2813   ROM_LOAD( "ts2-08m", 0x0800000, 0x400000, CRC(b1f7f115) SHA1(3f416d2aac07aa73a99593b5a21b047da60cea6a) )
2814   ROM_LOAD( "ts2-10",  0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) )
2811   ROM_LOAD( "ts2-05m.3h", 0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) )
2812   ROM_LOAD( "ts2-06m.4h", 0x0400000, 0x200000, CRC(67be6797) SHA1(521f69439ba7666f54d1008a291f3391f3a16499) )
2813   ROM_LOAD( "ts2-07m.5h", 0x0600000, 0x200000, CRC(db73e2b8) SHA1(239243f44c41df765789c14cc4036bb02e2ab373) )
2814   ROM_LOAD( "ts2-08m.2k", 0x0800000, 0x200000, CRC(01a48431) SHA1(6e395af726da91909e07dac25bb9b70b3ccebd4e) )
2815   ROM_LOAD( "ts2-09m.3k", 0x0a00000, 0x200000, CRC(83f408de) SHA1(415787c4dca604dd5611e16936a0ffa981dedf78) )
2816   ROM_LOAD( "ts2-10m.4k", 0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) )
28152817
28162818   ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
28172819   ROM_LOAD( "ts2_02.2e",  0x00000, 0x08000, CRC(2f45c461) SHA1(513b6b9b5a2f7c567c30c958e0e13834cd9bd266) )
28182820   ROM_CONTINUE(           0x10000, 0x18000 )
28192821
28202822   ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */
2821   ROM_LOAD16_WORD_SWAP( "ts2-01", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) )
2823   ROM_LOAD16_WORD_SWAP( "ts2-01m.3b", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) )
28222824ROM_END
28232825
28242826/* 95681-2 */
r14063r14064
28292831   ROM_LOAD( "ts2j_04.2h", 0x0000000, 0x080000, CRC(4aba8c5e) SHA1(a56001bf50bfc1b03036e88ae1febd1aac8c63c0) )
28302832
28312833   ROM_REGION32_LE( 0x2400000, "user2", 0 )
2832   ROM_LOAD( "ts2-05",  0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) )
2833   ROM_LOAD( "ts2-06m", 0x0400000, 0x400000, CRC(cd7e0a27) SHA1(325b5f2e653cdea07cddc9d20d12b5ab50dca949) )
2834   ROM_LOAD( "ts2-08m", 0x0800000, 0x400000, CRC(b1f7f115) SHA1(3f416d2aac07aa73a99593b5a21b047da60cea6a) )
2835   ROM_LOAD( "ts2-10",  0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) )
2834   ROM_LOAD( "ts2-05m.3h", 0x0000000, 0x400000, CRC(7f4228e2) SHA1(3690a76d19d97e55bc7b05a8456328697cfd7a77) )
2835   ROM_LOAD( "ts2-06m.4h", 0x0400000, 0x200000, CRC(67be6797) SHA1(521f69439ba7666f54d1008a291f3391f3a16499) )
2836   ROM_LOAD( "ts2-07m.5h", 0x0600000, 0x200000, CRC(db73e2b8) SHA1(239243f44c41df765789c14cc4036bb02e2ab373) )
2837   ROM_LOAD( "ts2-08m.2k", 0x0800000, 0x200000, CRC(01a48431) SHA1(6e395af726da91909e07dac25bb9b70b3ccebd4e) )
2838   ROM_LOAD( "ts2-09m.3k", 0x0a00000, 0x200000, CRC(83f408de) SHA1(415787c4dca604dd5611e16936a0ffa981dedf78) )
2839   ROM_LOAD( "ts2-10m.4k", 0x0c00000, 0x200000, CRC(ad90679a) SHA1(19dd30764f892ee7f89c78ccbccdaf4d6b0e6e09) )
28362840
28372841   ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
28382842   ROM_LOAD( "ts2_02.2e",  0x00000, 0x08000, CRC(2f45c461) SHA1(513b6b9b5a2f7c567c30c958e0e13834cd9bd266) )
28392843   ROM_CONTINUE(           0x10000, 0x18000 )
28402844
28412845   ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */
2842   ROM_LOAD16_WORD_SWAP( "ts2-01", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) )
2846   ROM_LOAD16_WORD_SWAP( "ts2-01m.3b", 0x0000000, 0x400000, CRC(d7a505e0) SHA1(f1b0cdea712101f695bd326eccd753eb79a07490) )
28432847ROM_END
28442848
28452849/* 95681-2 */
r14063r14064
28582862   ROM_LOAD( "ps1-10m.4k", 0x1400000, 0x400000, CRC(ff80c18a) SHA1(8d01717eed6ec1f508fe7c445da941fb84ef7d22) )
28592863
28602864   ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
2861   ROM_LOAD( "ps1_02a.2e", 0x000000, 0x008000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) )
2862   ROM_CONTINUE(           0x010000, 0x018000 )
2863   ROM_LOAD( "ps1_03a.3e", 0x028000, 0x020000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) )
2865   ROM_LOAD( "ps1_02a.2e", 0x00000, 0x08000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) )
2866   ROM_CONTINUE(           0x10000, 0x18000 )
2867   ROM_LOAD( "ps1_03a.3e", 0x28000, 0x20000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) )
28642868
28652869   ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */
2866   ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) )
2870   ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x0000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) )
28672871ROM_END
28682872
28692873/* 95681-2 */
r14063r14064
28822886   ROM_LOAD( "ps1-10m.4k", 0x1400000, 0x400000, CRC(ff80c18a) SHA1(8d01717eed6ec1f508fe7c445da941fb84ef7d22) )
28832887
28842888   ROM_REGION( 0x50000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
2885   ROM_LOAD( "ps1_02a.2e", 0x000000, 0x008000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) )
2886   ROM_CONTINUE(           0x010000, 0x018000 )
2887   ROM_LOAD( "ps1_03a.3e", 0x028000, 0x020000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) )
2889   ROM_LOAD( "ps1_02a.2e", 0x00000, 0x08000, CRC(b854df92) SHA1(ea71a613b5b19ec7e9c6e342e7743d320582a6bb) )
2890   ROM_CONTINUE(           0x10000, 0x18000 )
2891   ROM_LOAD( "ps1_03a.3e", 0x28000, 0x20000, CRC(a2562fbb) SHA1(3de02a4aa7ea620961ca2a5c331f38134033db79) )
28882892
28892893   ROM_REGION( 0x400000, "qsound", 0 ) /* Q Sound Samples */
2890   ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) )
2894   ROM_LOAD16_WORD_SWAP( "ps1-01m.3b", 0x0000000, 0x400000, CRC(0bfb17aa) SHA1(cf4482785a2a33ad814c8b1461c5bc8e8e027895) )
28912895ROM_END
28922896
28932897/* 95681-2 */
src/mame/drivers/itgambl2.c
r14063r14064
126126
127127         color = (blit_ram[count] & 0xff)>>0;
128128
129         if((x)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
129         if(cliprect.contains(x, y))
130130            bitmap.pix32(y, x) = screen.machine().pens[color];
131131
132132         count++;
src/mame/drivers/midzeus.c
r14063r14064
531531            { "GUNX1", "GUNY1" },
532532            { "GUNX2", "GUNY2" }
533533         };
534         gun_x[player] = input_port_read(space->machine(), names[player][0]) * (visarea.max_x + 1 - visarea.min_x) / 255 + visarea.min_x + BEAM_XOFFS;
535         gun_y[player] = input_port_read(space->machine(), names[player][1]) * (visarea.max_y + 1 - visarea.min_y) / 255 + visarea.min_y;
534         gun_x[player] = input_port_read(space->machine(), names[player][0]) * visarea.width() / 255 + visarea.min_x + BEAM_XOFFS;
535         gun_y[player] = input_port_read(space->machine(), names[player][1]) * visarea.height() / 255 + visarea.min_y;
536536         gun_timer[player]->adjust(space->machine().primary_screen->time_until_pos(MAX(0, gun_y[player] - BEAM_DY), MAX(0, gun_x[player] - BEAM_DX)), player);
537537      }
538538   }
src/mame/drivers/cybertnk.c
r14063r14064
208208
209209static void draw_pixel( bitmap_ind16 &bitmap, const rectangle &cliprect, int y, int x, int pen)
210210{
211   if (x>cliprect.max_x) return;
212   if (x<cliprect.min_x) return;
213   if (y>cliprect.max_y) return;
214   if (y<cliprect.min_y) return;
215
216   bitmap.pix16(y, x) = pen;
211   if (cliprect.contains(x, y))
212      bitmap.pix16(y, x) = pen;
217213}
218214
219215static UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int screen_shift)
src/mame/drivers/jantotsu.c
r14063r14064
158158            for(pen_i = 0;pen_i<4;pen_i++)
159159               color |= (((state->m_bitmap[count + pen_i*0x2000]) >> (7 - i)) & 1) << pen_i;
160160
161            if ((x + i) <= screen.visible_area().max_x && (y + 0) < screen.visible_area().max_y)
161            if (cliprect.contains(x + i, y))
162162               bitmap.pix32(y, x + i) = screen.machine().pens[color];
163163         }
164164
src/mame/drivers/highvdeo.c
r14063r14064
125125
126126         color = ((state->m_blit_ram[count]) & 0x00ff)>>0;
127127
128         if((x*2)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
128         if(cliprect.contains((x*2)+0, y))
129129            bitmap.pix32(y, (x*2)+0) = screen.machine().pens[color];
130130
131131         color = ((state->m_blit_ram[count]) & 0xff00)>>8;
132132
133         if(((x*2)+1)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
133         if(cliprect.contains((x*2)+1, y))
134134            bitmap.pix32(y, (x*2)+1) = screen.machine().pens[color];
135135
136136         count++;
r14063r14064
162162         b = (color & 0x001f) << 3;
163163         g = (color & 0x07e0) >> 3;
164164         r = (color & 0xf800) >> 8;
165         if(x<screen.visible_area().max_x && y<screen.visible_area().max_y)
165         if(cliprect.contains(x, y))
166166            bitmap.pix32(y, x) = b | (g<<8) | (r<<16);
167167
168168         count++;
src/mame/drivers/majorpkr.c
r14063r14064
532532   /* The following custom_clip is to exclude the last char column (unused)
533533       form the render. We need more proof about how the video is working.
534534    */
535   custom_clip.min_x=cliprect.min_x;
536   custom_clip.max_x=cliprect.max_x-16;
537   custom_clip.min_y=cliprect.min_y;
538   custom_clip.max_y=cliprect.max_y;
535   custom_clip = cliprect;
536   custom_clip.max_x -= 16;
539537
540538   tilemap_draw(bitmap, custom_clip, state->m_bg_tilemap, 0, 0);
541539   tilemap_draw(bitmap, custom_clip, state->m_fg_tilemap, 0, 0);
src/mame/drivers/ichiban.c
r0r14064
1/***************************************************************************
2
3Ichi Ban Jyan
4Excel, 199?
5
6TODO: code is encrypted (data, not opcodes)
7
8PCB Layout
9----------
10
11MJ911
12|----------------------------------|
13|MB3712 DSW-D DSW-C DSW-B DSW-A  SW|
14|   M6378                   BATT   |
15|VOL               6264         3  |
16|    YM2413 MJB                    |
17|M                  1           2  |
18|A  YM2149  MJG  |-------|         |
19|H               |ALTERA |  Z80    |
20|J          MJR  |EP1810 |         |
21|O               |       |  ALTERA |
22|N               |-------|  EP910  |
23|G                                 |
24|                                  |
25|      41464  41464                |
26|      41464  41464       18.432MHz|
27|----------------------------------|
28Notes:
29Z80 clock - 6.144MHz [18.432/3]
30YM2149 clock - 1.536MHz [18.432/12]
31YM2413 clock - 3.072MHz [18.432/6]
32VSync - 60.5686Hz
33HSync - 15.510kHz
34
35***************************************************************************/
36
37#define ADDRESS_MAP_MODERN
38
39#include "emu.h"
40#include "cpu/z80/z80.h"
41#include "sound/ay8910.h"
42#include "sound/2413intf.h"
43
44#define MAIN_CLOCK XTAL_18_432MHz
45
46class ichibanjyan_state : public driver_device
47{
48public:
49   ichibanjyan_state(const machine_config &mconfig, device_type type, const char *tag)
50      : driver_device(mconfig, type, tag),
51        m_maincpu(*this, "maincpu")
52   { }
53
54   // devices
55   required_device<cpu_device> m_maincpu;
56
57   // driver_device overrides
58   virtual void machine_start();
59   virtual void machine_reset();
60
61   virtual void video_start();
62   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
63
64   DECLARE_WRITE8_MEMBER( bank_w );
65};
66
67void ichibanjyan_state::video_start()
68{
69
70}
71
72UINT32 ichibanjyan_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
73{
74   return 0;
75}
76
77
78static ADDRESS_MAP_START( ichibanjyan_map, AS_PROGRAM, 8, ichibanjyan_state )
79   AM_RANGE(0x0000, 0x7fff) AM_ROMBANK("bank1")
80ADDRESS_MAP_END
81
82static ADDRESS_MAP_START( ichibanjyan_io, AS_IO, 8, ichibanjyan_state )
83   ADDRESS_MAP_GLOBAL_MASK(0xff)
84ADDRESS_MAP_END
85
86static INPUT_PORTS_START( ichibanjyan )
87INPUT_PORTS_END
88
89static const gfx_layout charlayout =
90{
91   8,8,
92   RGN_FRAC(1,1),
93   8,
94   { 0, 1, 2, 3, 4, 5, 6, 7 },
95   { STEP8( 0*512, 8 ) },
96   { STEP8( 0*512, 8*8 ) },
97   8*8*8
98};
99
100static GFXDECODE_START( ichibanjyan )
101   GFXDECODE_ENTRY( "gfx1", 0, charlayout,     0, 1 )
102   GFXDECODE_ENTRY( "gfx2", 0, charlayout,     0, 1 )
103GFXDECODE_END
104
105
106void ichibanjyan_state::machine_start()
107{
108   UINT8 *ROM = machine().region("code")->base();
109
110   memory_configure_bank(machine(), "bank1", 0, 4, ROM, 0x8000);
111}
112
113void ichibanjyan_state::machine_reset()
114{
115}
116
117
118static MACHINE_CONFIG_START( ichibanjyan, ichibanjyan_state )
119
120   /* basic machine hardware */
121   MCFG_CPU_ADD("maincpu",Z80,MAIN_CLOCK/3)
122   MCFG_CPU_PROGRAM_MAP(ichibanjyan_map)
123   MCFG_CPU_IO_MAP(ichibanjyan_io)
124
125   /* video hardware */
126   MCFG_SCREEN_ADD("screen", RASTER)
127   MCFG_SCREEN_REFRESH_RATE(60)
128   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
129   MCFG_SCREEN_UPDATE_DRIVER(ichibanjyan_state, screen_update)
130   MCFG_SCREEN_SIZE(32*8, 32*8)
131   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
132
133   MCFG_GFXDECODE(ichibanjyan)
134
135   MCFG_PALETTE_INIT(RRRR_GGGG_BBBB)
136   MCFG_PALETTE_LENGTH(512)
137
138   /* sound hardware */
139   MCFG_SPEAKER_STANDARD_MONO("mono")
140   MCFG_SOUND_ADD("aysnd", YM2149, MAIN_CLOCK/12)
141   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
142
143   MCFG_SOUND_ADD("ymsnd", YM2413, MAIN_CLOCK/6)
144   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
145MACHINE_CONFIG_END
146
147
148/***************************************************************************
149
150  Game driver(s)
151
152***************************************************************************/
153
154ROM_START( ichiban )
155   ROM_REGION( 0x20000, "code", 0 )
156   ROM_LOAD( "3.u15", 0, 0x20000, CRC(76240568) SHA1(cf055d1eaae25661a49ec4722a2c7caca862e66a) )
157
158   ROM_REGION( 0x20000, "gfx1", 0 )
159   ROM_LOAD( "1.u28", 0, 0x20000, CRC(2caa4d3f) SHA1(5e5af164880140b764c097a65388c22ba5ea572b) )
160
161   ROM_REGION( 0x20000, "gfx2", 0 )
162   ROM_LOAD( "2.u14", 0, 0x20000, CRC(b4834d8e) SHA1(836ddf7586dc5440faf88f5ec50a32265e9a0ec8) )
163
164   ROM_REGION( 0x600, "proms", 0 )
165   ROM_LOAD( "mjr.u36", 0x000, 0x200, CRC(31cd7a90) SHA1(1525ad19d748561a52626e4ab13df67d9bedf3b8) )
166   ROM_LOAD( "mjg.u37", 0x200, 0x200, CRC(5b3562aa) SHA1(ada60d2a5a5a657d7b209d18a23b685305d9ff7b) )
167   ROM_LOAD( "mjb.u38", 0x400, 0x200, CRC(0ef881cb) SHA1(44b61a443d683f5cb2d1b1a4f74d8a8f41021de5) )
168ROM_END
169
170GAME( 199?, ichiban,  0,   ichibanjyan,  ichibanjyan,  0,       ROT0, "Excel",      "Ichi Ban Jyan", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/pgm.c
r14063r14064
44324432static DRIVER_INIT( kovboot )
44334433{
44344434   pgm_basic_init(machine);
4435//   pgm_kov_decrypt(machine);
4435//  pgm_kov_decrypt(machine);
44364436   kovsh_latch_init(machine);
44374437   install_protection_asic_sim_kov(machine);
44384438}
src/mame/drivers/pcxt.c
r14063r14064
120120               for(pen_i = 0;pen_i<4;pen_i++)
121121                  color |= ((bg_rom[y*320/8+x+(pen_i*0x20000)+yi*0x400+state->m_bg_bank*0x2000+1] >> (7-xi)) & 1) << pen_i;
122122
123               if((x+xi)<screen.visible_area().max_x && ((y)+yi)<screen.visible_area().max_y)
123               if(cliprect.contains(x*8+xi, y*8+yi))
124124                  bitmap.pix32(y*8+yi, x*8+xi) = screen.machine().pens[color];
125125            }
126126         }
src/mame/drivers/naomi.c
r14063r14064
39373937   NAOMI_DEFAULT_EEPROM
39383938
39393939    ROM_REGION( 0x4000000, "rom_board", ROMREGION_ERASEFF)
3940    ROM_LOAD( "epr-23071.ic11",         0x0000000, 0x0200000, CRC(1b58f24a) SHA1(90f91af31beff9399c8d72ae0087bf4d3122cac2) )
3941    ROM_LOAD32_WORD( "mpr-23063.ic17s", 0x1000000, 0x0800000, CRC(9678a759) SHA1(6f2602c6eef8db0d4a145d832aec3ea0e0491c0c) )
3942    ROM_LOAD32_WORD( "mpr-23064.ic18",  0x1000002, 0x0800000, CRC(e159c44d) SHA1(fd0dcd74f7e214c7c9214bb04167f7c3acea30cf) )
3943    ROM_LOAD32_WORD( "mpr-23065.ic19s", 0x2000000, 0x0800000, CRC(10eff527) SHA1(c208529b0825ba45dc474c6aaa4b4c5557335c10) )
3944    ROM_LOAD32_WORD( "mpr-23066.ic20",  0x2000002, 0x0800000, CRC(4f9c1710) SHA1(7834bab5933a156656756f837c217e7820f2ae63) )
3945    ROM_LOAD32_WORD( "mpr-23067.ic21s", 0x3000000, 0x0800000, CRC(32724cd9) SHA1(7bfdd58dd5e69529125a720f51c53ebe526ef2e9) )
3946    ROM_LOAD32_WORD( "mpr-23068.ic22",  0x3000002, 0x0800000, CRC(2ce3e0ea) SHA1(805ec80273856ec6e5ee04fdca5fd1407c404f8e) )
3940    ROM_LOAD( "epr-23071.ic11",         0x0000000, 0x0200000, CRC(1b58f24a) SHA1(90f91af31beff9399c8d72ae0087bf4d3122cac2) )
3941    ROM_LOAD32_WORD( "mpr-23063.ic17s", 0x1000000, 0x0800000, CRC(9678a759) SHA1(6f2602c6eef8db0d4a145d832aec3ea0e0491c0c) )
3942    ROM_LOAD32_WORD( "mpr-23064.ic18",  0x1000002, 0x0800000, CRC(e159c44d) SHA1(fd0dcd74f7e214c7c9214bb04167f7c3acea30cf) )
3943    ROM_LOAD32_WORD( "mpr-23065.ic19s", 0x2000000, 0x0800000, CRC(10eff527) SHA1(c208529b0825ba45dc474c6aaa4b4c5557335c10) )
3944    ROM_LOAD32_WORD( "mpr-23066.ic20",  0x2000002, 0x0800000, CRC(4f9c1710) SHA1(7834bab5933a156656756f837c217e7820f2ae63) )
3945    ROM_LOAD32_WORD( "mpr-23067.ic21s", 0x3000000, 0x0800000, CRC(32724cd9) SHA1(7bfdd58dd5e69529125a720f51c53ebe526ef2e9) )
3946    ROM_LOAD32_WORD( "mpr-23068.ic22",  0x3000002, 0x0800000, CRC(2ce3e0ea) SHA1(805ec80273856ec6e5ee04fdca5fd1407c404f8e) )
39473947
39483948    ROM_REGION( 4, "rom_key", 0 )
3949    ROM_LOAD( "tduno2.key",   0x000000, 0x000004, CRC(8e0f0f3b) SHA1(914d3db8746c806d559539cc0851169161d32c04) )
3949    ROM_LOAD( "tduno2.key",   0x000000, 0x000004, CRC(8e0f0f3b) SHA1(914d3db8746c806d559539cc0851169161d32c04) )
39503950ROM_END
39513951
3952ROM_START( mtkob2 )
3953   NAOMI_BIOS
3954   NAOMI_DEFAULT_EEPROM
3955
3956    ROM_REGION( 0x4000000, "rom_board", ROMREGION_ERASEFF)
3957    ROM_LOAD( "epr-24217.ic11",         0x0000000, 0x0400000, CRC(5ecf807b) SHA1(f91d03a68a44d02970e360789b746bec9289275f) )
3958    ROM_LOAD32_WORD( "mpr-24218.ic17s", 0x1000000, 0x0800000, CRC(e8c51e1d) SHA1(e81f0580e144aa7a7e8c9399ffa09227b6e93675) )
3959    ROM_LOAD32_WORD( "mpr-24219.ic18",  0x1000002, 0x0800000, CRC(b0a5709f) SHA1(993f7a99d59a924641c37a549208723342007e5a) )
3960    ROM_LOAD32_WORD( "mpr-24220.ic19s", 0x2000000, 0x0800000, CRC(9f6cefe2) SHA1(499e17d2c284b340db6b124b63a23c7fa5045d0f) )
3961    ROM_LOAD32_WORD( "mpr-24221.ic20",  0x2000002, 0x0800000, CRC(73bf9cc6) SHA1(ab187cc0babd1435f5e8636331818d81de23636f) )
3962    ROM_LOAD32_WORD( "mpr-24222.ic21s", 0x3000000, 0x0800000, CRC(7098e728) SHA1(82f4f57efcee3063467c24758cefd406dccb1ea4) )
3963    ROM_LOAD32_WORD( "mpr-24223.ic22",  0x3000002, 0x0800000, CRC(eca13c90) SHA1(26a66906bf4ebda8697140d89eb5e493e941e8b2) )
3964
3965    ROM_REGION( 4, "rom_key", 0 )
3966    ROM_LOAD( "mtkob2-key.bin", 0x000000, 0x000004, CRC(db088208) SHA1(14d65ad2555183a445abcd93907c85df4032b41d) )
3967ROM_END
3968
39523969ROM_START( crackndj )
39533970   NAOMI_BIOS
39543971   NAOMI_DEFAULT_EEPROM
r14063r14064
54505467    NAOMI_DEFAULT_EEPROM
54515468
54525469    ROM_REGION( 0x10000000, "rom_board", ROMREGION_ERASEFF)
5453    ROM_LOAD( "trf1_fl0.2f",  0x0000000, 0x0800000, CRC(862e673d) SHA1(f2c90932ba4abe31d02e86f80ef3e2689342c384) )
5454    ROM_LOAD( "trf1_fl1.2d",  0x0800000, 0x0800000, CRC(59a935c9) SHA1(7298d83a27eac74bad18d716a791ab2016fe028f) )
5455    ROM_LOAD( "trf1_ma1.4n",  0x1000000, 0x1000000, CRC(b1b3ab96) SHA1(3dc4bcf796583a0fb51359a86a46d7883df54fad) )
5456    ROM_LOAD( "trf1_ma2.4m",  0x2000000, 0x1000000, CRC(a27d3dda) SHA1(b9ec4be5845cbe91fd7bc537669e96716513a5f0) )
5457    ROM_LOAD( "trf1_ma3.4l",  0x3000000, 0x1000000, CRC(345ec434) SHA1(986d9930e7de46b88936c898ba8b05d950262a1f) )
5458    ROM_LOAD( "trf1_ma4.4k",  0x4000000, 0x1000000, CRC(fc47a104) SHA1(07ced58c1b17719ac36db1589771e67ce16d912e) )
5459    ROM_LOAD( "trf1_ma5.4j",  0x5000000, 0x1000000, CRC(e1bb077d) SHA1(6b70d8103bf067319e9022742fc1dd843d7e5076) )
5460    ROM_LOAD( "trf1_ma6.4h",  0x6000000, 0x1000000, CRC(abae4d06) SHA1(56da2ca3551287942afabf37e7fd1b884bd3cac8) )
5461    ROM_LOAD( "trf1_ma7.4f",  0x7000000, 0x1000000, CRC(19d0092a) SHA1(2ae2dbf2f3958da9f69b3a8636c6837e4243bb67) )
5462    ROM_LOAD( "trf1_ma8.4e",  0x8000000, 0x1000000, CRC(6fbf34ab) SHA1(f4747d1a1c02e22502e68d72a4f0c152fa69d778) )
5463    ROM_LOAD( "trf1_ma9.4d",  0x9000000, 0x1000000, CRC(2fa36c5d) SHA1(6478687c91484141521ae79a997cecbcfbb7beae) )
5464    ROM_LOAD( "trf1_ma10.4c", 0xa000000, 0x1000000, CRC(bc866a37) SHA1(d4d12f285a3bc9136cf3fc2a59dba5ad557cc7d7) )
5465    ROM_LOAD( "trf1_ma11.4b", 0xb000000, 0x1000000, CRC(68d11482) SHA1(fe991ba5664d6ccf0aac5167f05c5a780f851ae9) )
5466    ROM_LOAD( "trf1_ma12.6p", 0xc000000, 0x1000000, CRC(a7c3bd3c) SHA1(ed5a24e4c47f686120577dae4550fb9378209cf8) )
5467    ROM_LOAD( "trf1_ma13.6n", 0xd000000, 0x1000000, CRC(e52d41fe) SHA1(e1769d42d6048f9621ca289af3ddeca7c14cee00) )
5468    ROM_LOAD( "trf1_ma14.6m", 0xe000000, 0x1000000, CRC(87cb31a0) SHA1(27aef9ac571a0b5e3a76e4ee22f5bc5d0ae962f2) )
5469    ROM_LOAD( "trf1_ma15.6l", 0xf000000, 0x1000000, CRC(42d318c5) SHA1(f9fe82ffbfc51fcb52333f94c55a7092e7124fb4) )
5470    ROM_LOAD( "trf1_fl0.2f",  0x0000000, 0x0800000, CRC(862e673d) SHA1(f2c90932ba4abe31d02e86f80ef3e2689342c384) )
5471    ROM_LOAD( "trf1_fl1.2d",  0x0800000, 0x0800000, CRC(59a935c9) SHA1(7298d83a27eac74bad18d716a791ab2016fe028f) )
5472    ROM_LOAD( "trf1_ma1.4n",  0x1000000, 0x1000000, CRC(b1b3ab96) SHA1(3dc4bcf796583a0fb51359a86a46d7883df54fad) )
5473    ROM_LOAD( "trf1_ma2.4m",  0x2000000, 0x1000000, CRC(a27d3dda) SHA1(b9ec4be5845cbe91fd7bc537669e96716513a5f0) )
5474    ROM_LOAD( "trf1_ma3.4l",  0x3000000, 0x1000000, CRC(345ec434) SHA1(986d9930e7de46b88936c898ba8b05d950262a1f) )
5475    ROM_LOAD( "trf1_ma4.4k",  0x4000000, 0x1000000, CRC(fc47a104) SHA1(07ced58c1b17719ac36db1589771e67ce16d912e) )
5476    ROM_LOAD( "trf1_ma5.4j",  0x5000000, 0x1000000, CRC(e1bb077d) SHA1(6b70d8103bf067319e9022742fc1dd843d7e5076) )
5477    ROM_LOAD( "trf1_ma6.4h",  0x6000000, 0x1000000, CRC(abae4d06) SHA1(56da2ca3551287942afabf37e7fd1b884bd3cac8) )
5478    ROM_LOAD( "trf1_ma7.4f",  0x7000000, 0x1000000, CRC(19d0092a) SHA1(2ae2dbf2f3958da9f69b3a8636c6837e4243bb67) )
5479    ROM_LOAD( "trf1_ma8.4e",  0x8000000, 0x1000000, CRC(6fbf34ab) SHA1(f4747d1a1c02e22502e68d72a4f0c152fa69d778) )
5480    ROM_LOAD( "trf1_ma9.4d",  0x9000000, 0x1000000, CRC(2fa36c5d) SHA1(6478687c91484141521ae79a997cecbcfbb7beae) )
5481    ROM_LOAD( "trf1_ma10.4c", 0xa000000, 0x1000000, CRC(bc866a37) SHA1(d4d12f285a3bc9136cf3fc2a59dba5ad557cc7d7) )
5482    ROM_LOAD( "trf1_ma11.4b", 0xb000000, 0x1000000, CRC(68d11482) SHA1(fe991ba5664d6ccf0aac5167f05c5a780f851ae9) )
5483    ROM_LOAD( "trf1_ma12.6p", 0xc000000, 0x1000000, CRC(a7c3bd3c) SHA1(ed5a24e4c47f686120577dae4550fb9378209cf8) )
5484    ROM_LOAD( "trf1_ma13.6n", 0xd000000, 0x1000000, CRC(e52d41fe) SHA1(e1769d42d6048f9621ca289af3ddeca7c14cee00) )
5485    ROM_LOAD( "trf1_ma14.6m", 0xe000000, 0x1000000, CRC(87cb31a0) SHA1(27aef9ac571a0b5e3a76e4ee22f5bc5d0ae962f2) )
5486    ROM_LOAD( "trf1_ma15.6l", 0xf000000, 0x1000000, CRC(42d318c5) SHA1(f9fe82ffbfc51fcb52333f94c55a7092e7124fb4) )
54705487
54715488    ROM_REGION( 4, "rom_key", 0 )
5472    ROM_LOAD( "tr4ae-key.bin", 0x000000, 0x000004, CRC(986a7cee) SHA1(70c3ff80f86de6a0655251658c66a156fb644995) )
5489    ROM_LOAD( "tr4ae-key.bin", 0x000000, 0x000004, CRC(986a7cee) SHA1(70c3ff80f86de6a0655251658c66a156fb644995) )
54735490ROM_END
54745491
54755492ROM_START( vtenis2c )
r14063r14064
77167733/* 0020 */ GAME( 1999, samba,    naomi,    naomim2, naomi,    naomi,    ROT0, "Sega", "Samba De Amigo (JPN) (Rev B)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77177734/* 0021 */ GAME( 2000, virnbao,  virnba,   naomim2, naomi,    naomi,    ROT0, "Sega", "Virtua NBA (JPN, USA, EXP, KOR, AUS) (original)", GAME_FLAGS )
77187735/* 0021-01 */ GAME( 2000,virnba, naomi,    naomi,   naomi,    naomi,    ROT0, "Sega", "Virtua NBA (JPN, USA, EXP, KOR, AUS)", GAME_FLAGS )
7719/* 0022 */ GAME( 2000, tduno2,   naomi,    naomim2, naomi,    naomi,    ROT0, "Sega", "Touch de Uno! 2", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
7736/* 0022 */ GAME( 2000, tduno2,   naomi,    naomim2, naomi,    naomi,    ROT0, "Sega", "Touch de Uno! 2", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77207737/* 0023 */ GAME( 2000, 18wheelr, naomi,    naomim2, 18wheelr, naomi,    ROT0, "Sega", "18 Wheeler Deluxe (Rev A) (JPN)", GAME_FLAGS )
77217738/* 0023 */ GAME( 2000, 18wheels, 18wheelr, naomim2, 18wheelr, naomi,    ROT0, "Sega", "18 Wheeler (Rev A) (JPN)", GAME_FLAGS )
77227739// 0025 Mars TV
r14063r14064
77467763/* 0126 */ GAME( 2003, oinori,   naomi,    naomi,   naomi,    naomi,    ROT0, "Sega", "Oinori-daimyoujin Matsuri", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77477764/* 0128 */ GAME( 2002, shootpl,  naomi,    naomim1, naomi,    naomi,    ROT0, "Sega", "Shootout Pool (JPN, USA, KOR, AUS) / Shootout Pool Prize (EXP)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77487765/* 0140 */ GAME( 2004, kick4csh, naomi,    naomim1, naomi,    kick4csh, ROT0, "Sega", "Kick '4' Cash", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
7749// 0150 MushiKing The King Of Beetle 2K3 2ND
7766/* 0150 */ GAME( 2003, mtkob2,   naomi,    naomim1, naomi,    naomi,    ROT0, "Sega", "Mushiking The King Of Beetle 2K3 2nd", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77507767// 0164 MushiKing The King Of Beetle II ENG
77517768// 0166 Touch De Zunou (Japan)
77527769// 0166 Touch De Zunou (Japan) (Rev A)
r14063r14064
77987815
77997816/* Cart games on Namco custom ROM board */
78007817/* 25209801 */ GAME( 2000, wldkicks, naomi, naomim2, naomi,    naomi,    ROT0, "Capcom / Namco", "World Kicks", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
7801/* 25349801 */ GAME( 2000, toukon4,  naomi, naomim2, naomi,    naomi,    ROT0, "Capcom / Namco", "Shin Nihon Pro Wrestling Toukon Retsuden 4 Arcade Edition", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
7818/* 25349801 */ GAME( 2000, toukon4,  naomi, naomim2, naomi,    naomi,    ROT0, "Capcom / Namco", "Shin Nihon Pro Wrestling Toukon Retsuden 4 Arcade Edition", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
78027819// 25469801 Ninja Assault
78037820/* 25709801 */ GAME( 2001, gunsur2,  naomi, naomi,   naomi,    naomi,    ROT0, "Capcom / Namco", "Gun Survivor 2 Biohazard Code: Veronica", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
78047821// 25869812 Mazan : Flash of the Blade
src/mame/drivers/vamphalf.c
r14063r14064
2121    Final Godori               (c) 2001 SemiCom            (version 2.20.5915)
2222    Wyvern Wings               (c) 2001 SemiCom
2323    Mr. Kicker                 (c) 2001 SemiCom [1]
24    Toy Land Adventure         (c) 2001 SemiCom [2]
24    Toy Land Adventure         (c) 2001 SemiCom
2525    Age Of Heroes - Silkroad 2 (c) 2001 Unico              (v0.63 - 2001/02/07)
2626
2727 Real games bugs:
2828 - dquizgo2: bugged video test
2929
3030 Notes:
31 [1]    Mr. Kicker game code crashes if the eeprom values are empty, because it replaces the SP register with a bogus value at PC = $18D0 before crashing.
32        It could be an original game bug or a hyperstone core bug
33 [2]    Toy Land Adventure is currently missing graphics roms which makes it non-working.
31 [1]    Mr. Kicker game code crashes if the eeprom values are empty, because it replaces
32        the SP register with a bogus value at PC = $18D0 before crashing. It could be an
33        original game bug or a hyperstone core bug. Also happens with High Score update.
3434
3535 Mr Kicker is also known to exist (not dumped) on the F-E1-16-010 PCB that
3636   Semicom also used for Toy Land Adventure & SemiComDate Quiz Go Go Episode 2 game.
r14063r14064
13281328ROM_START( toyland )
13291329   ROM_REGION16_BE( 0x100000, "user1", ROMREGION_ERASE00 ) /* Hyperstone CPU Code */
13301330   /* ROM1 empty */
1331   ROM_LOAD( "rom2",         0x80000, 0x080000, CRC(e3455002) SHA1(5ad7884f82fb125d70829accec02f238e7d9593c) )
1331   ROM_LOAD( "rom2.bin",         0x80000, 0x080000, CRC(e3455002) SHA1(5ad7884f82fb125d70829accec02f238e7d9593c) )
13321332
13331333   ROM_REGION( 0xc00000, "gfx1", 0 ) /* 16x16x8 Sprites */
1334   ROM_LOAD32_WORD( "roml00", 0x000000, 0x200000, NO_DUMP )
1335   ROM_LOAD32_WORD( "romu00", 0x000002, 0x200000, NO_DUMP )
1336   ROM_LOAD32_WORD( "roml01", 0x400000, 0x200000, NO_DUMP )
1337   ROM_LOAD32_WORD( "romu01", 0x400002, 0x200000, NO_DUMP )
1334   ROM_LOAD32_WORD( "roml00.bin", 0x000000, 0x200000, CRC(06f5673d) SHA1(23769015fc9a37d36b0fe4924964650aeca77573) )
1335   ROM_LOAD32_WORD( "romu00.bin", 0x000002, 0x200000, CRC(8c3db0e4) SHA1(6101ec550ae165338333fb04e0762edee65ca253) )
1336   ROM_LOAD32_WORD( "roml01.bin", 0x400000, 0x200000, CRC(076a84e1) SHA1(f58cb4cd874e1f3f266a5ccbf8ffb5e0111034d3) )
1337   ROM_LOAD32_WORD( "romu01.bin", 0x400002, 0x200000, CRC(1bc33d01) SHA1(a2a3e6b473cefe463dbd60bda98cb5a4df2bc81b) )
13381338   /* roml02 empty */
13391339   /* romu02 empty */
13401340   /* roml03 empty */
13411341   /* romu03 empty */
13421342
13431343   ROM_REGION( 0x40000, "oki", 0 ) /* Oki Samples */
1344   ROM_LOAD( "vrom1", 0x00000, 0x40000, CRC(d7e6fc5d) SHA1(ab5bca4035299214d98b222320276fbcaedb0898) )
1344   ROM_LOAD( "vrom1.bin", 0x00000, 0x40000, CRC(d7e6fc5d) SHA1(ab5bca4035299214d98b222320276fbcaedb0898) )
1345
1346   ROM_REGION16_BE( 0x80, "eeprom", 0 ) /* Default EEPROM */
1347   ROM_LOAD( "epr1.ic3", 0x0000, 0x0080, CRC(812f3d87) SHA1(744919ff4b44eaa3c4dcc75a1cc2f231ccbb4a3e) )
1348
13451349ROM_END
13461350
13471351/*
r14063r14064
19541958static READ16_HANDLER( toyland_speedup_r )
19551959{
19561960   vamphalf_state *state = space->machine().driver_data<vamphalf_state>();
1957   
1961
19581962   if (cpu_get_pc(&space->device()) == 0x130c2)
19591963      device_spin_until_interrupt(&space->device());
19601964
r14063r14064
21382142GAME( 2000, mrdig,    0,        mrdig,    common,   mrdig,    ROT0,   "Sun",               "Mr. Dig", 0 )
21392143GAME( 2001, finalgdr, 0,        finalgdr, finalgdr, finalgdr, ROT0,   "SemiCom",           "Final Godori (Korea, version 2.20.5915)", 0 )
21402144GAME( 2001, mrkicker, 0,        mrkicker, finalgdr, mrkicker, ROT0,   "SemiCom",           "Mr. Kicker", GAME_NOT_WORKING ) // game stops booting / working properly after you get a high score, or if you don't have a default eeprom with 'valid data.  It's never worked properly, CPU core issue?
2141GAME( 2001, toyland,  0,        coolmini, common,   toyland,  ROT0,   "SemiCom",           "Toy Land Adventure", GAME_NOT_WORKING ) /* Missing GRFX roms */
2145GAME( 2001, toyland,  0,        coolmini, common,   toyland,  ROT0,   "SemiCom",           "Toy Land Adventure", 0 )
21422146GAME( 2001, wyvernwg, 0,        wyvernwg, common,   wyvernwg, ROT270, "SemiCom (Game Vision license)", "Wyvern Wings", GAME_NO_SOUND )
21432147GAME( 2001, aoh,      0,        aoh,      aoh,      aoh,      ROT0,   "Unico",             "Age Of Heroes - Silkroad 2 (v0.63 - 2001/02/07)", 0 )
src/mame/drivers/atarisy4.c
r14063r14064
251251   poly_vertex v1, v2, v3;
252252   poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(state->m_poly);
253253
254   clip.min_x = 0;
255   clip.min_y = 0;
256   clip.max_x = 511;
257   clip.max_y = 511;
254   clip.set(0, 511, 0, 511);
258255
259256   extra->color = color;
260257   extra->screen_ram = state->m_screen_ram;
src/mame/drivers/pgm2.c
r14063r14064
116116   /* basic machine hardware */
117117   MCFG_CPU_ADD("maincpu", ARM7, 20000000)   // ?? unknown CPU, has internal ROM.
118118   MCFG_CPU_PROGRAM_MAP(pgm2_map)
119//   MCFG_DEVICE_DISABLE()
119//  MCFG_DEVICE_DISABLE()
120120
121121   MCFG_MACHINE_START( pgm2 )
122122   MCFG_MACHINE_RESET( pgm2 )
r14063r14064
152152   ROM_REGION( 0x1000000, "bgtile", 0 )
153153   ROM_LOAD16_BYTE( "ig-a.u35",  0x000000, 0x0800000, CRC(083a8315) SHA1(0dba25e132fbb12faa59ced648c27b881dc73478) )
154154   ROM_LOAD16_BYTE( "ig-a.u36",  0x000001, 0x0800000, CRC(e197221d) SHA1(5574b1e3da4b202db725be906dd868edc2fd4634) )
155   
155
156156   ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data
157157   ROM_LOAD32_WORD( "ig-a.u12",  0x000000, 0x1000000, CRC(113a331c) SHA1(ee6b31bb2b052cc8799573de0d2f0a83f0ab4f6a) )
158158   ROM_LOAD32_WORD( "ig-a.u16",  0x000002, 0x1000000, CRC(fbf411c8) SHA1(5089b5cc9bbf6496ef1367c6255e63e9ab895117) )
r14063r14064
175175   ROM_REGION( 0x1000000, "bgtile", 0 )
176176   ROM_LOAD16_BYTE( "ig-a.u35",  0x000000, 0x0800000, CRC(083a8315) SHA1(0dba25e132fbb12faa59ced648c27b881dc73478) )
177177   ROM_LOAD16_BYTE( "ig-a.u36",  0x000001, 0x0800000, CRC(e197221d) SHA1(5574b1e3da4b202db725be906dd868edc2fd4634) )
178   
178
179179   ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data
180180   ROM_LOAD32_WORD( "ig-a.u12",  0x000000, 0x1000000, CRC(113a331c) SHA1(ee6b31bb2b052cc8799573de0d2f0a83f0ab4f6a) )
181181   ROM_LOAD32_WORD( "ig-a.u16",  0x000002, 0x1000000, CRC(fbf411c8) SHA1(5089b5cc9bbf6496ef1367c6255e63e9ab895117) )
r14063r14064
198198   ROM_REGION( 0x1000000, "bgtile", 0 )
199199   ROM_LOAD16_BYTE( "ig-a3.u35",  0x000000, 0x0800000, CRC(2d46b1f6) SHA1(ea8c805eda6292e86a642e9633d8fee7054d10b1) )
200200   ROM_LOAD16_BYTE( "ig-a3.u36",  0x000001, 0x0800000, CRC(df710c36) SHA1(f826c3f496c4f17b46d18af1d8e02cac7b7027ac) )
201   
201
202202   ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data
203203   ROM_LOAD32_WORD( "ig-a3.u12",  0x000000, 0x1000000, CRC(0bf63836) SHA1(b8e4f1951f8074b475b795bd7840c5a375b6f5ef) )
204204   ROM_LOAD32_WORD( "ig-a3.u16",  0x000002, 0x1000000, CRC(4a378542) SHA1(5d06a8a8796285a786ebb690c34610f923ef5570) )
r14063r14064
221221   ROM_REGION( 0x1000000, "bgtile", 0 )
222222   ROM_LOAD16_BYTE( "ig-a3.u35",  0x000000, 0x0800000, CRC(2d46b1f6) SHA1(ea8c805eda6292e86a642e9633d8fee7054d10b1) )
223223   ROM_LOAD16_BYTE( "ig-a3.u36",  0x000001, 0x0800000, CRC(df710c36) SHA1(f826c3f496c4f17b46d18af1d8e02cac7b7027ac) )
224   
224
225225   ROM_REGION( 0x2000000, "spritesa", 0 ) // 1bpp sprite mask data
226226   ROM_LOAD32_WORD( "ig-a3.u12",  0x000000, 0x1000000, CRC(0bf63836) SHA1(b8e4f1951f8074b475b795bd7840c5a375b6f5ef) )
227227   ROM_LOAD32_WORD( "ig-a3.u16",  0x000002, 0x1000000, CRC(4a378542) SHA1(5d06a8a8796285a786ebb690c34610f923ef5570) )
r14063r14064
240240
241241   for (i = 1; i < len / 2; i+=2)
242242   {
243      UINT16 x = ixor;
243      UINT16 x = ixor;
244244
245245      if ( (i>>1) & 0x000001) x ^= 0x0010;
246246      if ( (i>>1) & 0x000002) x ^= 0x2004;
r14063r14064
265265
266266   for (i = 0; i < len / 2; i+=2)
267267   {
268      UINT16 x = ixor;
268      UINT16 x = ixor;
269269
270270      if ( (i>>1) & 0x000001) x ^= 0x9004;
271271      if ( (i>>1) & 0x000002) x ^= 0x0028;
src/mame/drivers/kingdrby.c
r14063r14064
222222   tilemap_set_scrolly( state->m_sc0w_tilemap,0, 32);
223223
224224   /* maybe it needs two window tilemaps? (one at the top, the other at the bottom)*/
225   clip.min_x = visarea.min_x;
226   clip.max_x = 256;
227   clip.min_y = 192;
228   clip.max_y = visarea.max_y;
225   clip.set(visarea.min_x, 256, 192, visarea.max_y);
229226
230227   /*TILEMAP_DRAW_CATEGORY + TILEMAP_DRAW_OPAQUE doesn't suit well?*/
231228   tilemap_draw(bitmap,cliprect,state->m_sc0_tilemap,0,0);
src/mame/drivers/gei.c
r14063r14064
8080      : driver_device(mconfig, type, tag) { }
8181
8282   virtual void video_start();
83   
83
8484   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
85   
85
8686   bitmap_ind16 m_bitmap;
8787
8888   UINT8 m_drawctrl[3];
src/mame/drivers/namcoic.c
r14063r14064
584584         }
585585
586586         /* Set the clipping rect to mask off the other portion of the sprite */
587         rect.min_x=sx;
588         rect.max_x=sx+(sizex-1);
589         rect.min_y=sy;
590         rect.max_y=sy+(sizey-1);
587         rect.set(sx, sx+(sizex-1), sy, sy+(sizey-1));
588         rect &= cliprect;
591589
592         if (cliprect.min_x > rect.min_x) rect.min_x = cliprect.min_x;
593         if (cliprect.max_x < rect.max_x) rect.max_x = cliprect.max_x;
594         if (cliprect.min_y > rect.min_y) rect.min_y = cliprect.min_y;
595         if (cliprect.max_y < rect.max_y) rect.max_y = cliprect.max_y;
596
597590         if( !bBigSprite )
598591         {
599592            sizex = 16;
r14063r14064
604597            sx -= (tile&1)?16:0;
605598            sy -= (tile&2)?16:0;
606599
607            rect.min_x=sx;
608            rect.max_x=sx+(sizex-1);
609            rect.min_y=sy;
610            rect.max_y=sy+(sizey-1);
600            rect.set(sx, sx+(sizex-1), sy, sy+(sizey-1));
611601            rect.min_x += (tile&1)?16:0;
612602            rect.max_x += (tile&1)?16:0;
613603            rect.min_y += (tile&2)?16:0;
r14063r14064
804794   hpos -= xscroll;
805795   vpos -= yscroll;
806796   pWinAttr = &spriteram16[0x2400/2+((palette>>8)&0xf)*4];
807   clip.min_x = pWinAttr[0] - xscroll;
808   clip.max_x = pWinAttr[1] - xscroll;
809   clip.min_y = pWinAttr[2] - yscroll;
810   clip.max_y = pWinAttr[3] - yscroll;
811   if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; }
812   if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; }
813   if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; }
814   if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; }
797   clip.set(pWinAttr[0] - xscroll, pWinAttr[1] - xscroll, pWinAttr[2] - yscroll, pWinAttr[3] - yscroll);
798   clip &= cliprect;
815799   hpos&=0x7ff; if( hpos&0x400 ) hpos |= ~0x7ff; /* sign extend */
816800   vpos&=0x7ff; if( vpos&0x400 ) vpos |= ~0x7ff; /* sign extend */
817801
r14063r14064
13101294         UnpackRozParam( pSource, &rozInfo );
13111295         if( pri == rozInfo.priority )
13121296         {
1313            clip.min_x = 0;
1314            clip.max_x = bitmap.width()-1;
1315            clip.min_y = clip.max_y = line;
1297            clip.set(0, bitmap.width()-1, line, line);
1298            clip &= cliprect;
13161299
1317            if( clip.min_x < cliprect.min_x ){ clip.min_x = cliprect.min_x; }
1318            if( clip.min_y < cliprect.min_y ){ clip.min_y = cliprect.min_y; }
1319            if( clip.max_x > cliprect.max_x ){ clip.max_x = cliprect.max_x; }
1320            if( clip.max_y > cliprect.max_y ){ clip.max_y = cliprect.max_y; }
1321
13221300            DrawRozHelper( bitmap, mRozTilemap[which], clip, &rozInfo );
13231301         } /* priority */
13241302      } /* enabled */
src/mame/drivers/aristmk6.c
r14063r14064
8686            g = (g << 2) | (g & 3);
8787            b = (b << 3) | (b & 0x7);
8888
89            if((x)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
89            if(cliprect.contains(x, y))
9090               bitmap.pix32(y, x) = r | g<<8 | b<<16;
9191
9292            count+=2;
r14063r14064
9797
9898            color = blit_ram[count];
9999
100            if((x)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
100            if(cliprect.contains(x, y))
101101               bitmap.pix32(y, x) = screen.machine().pens[color];
102102
103103            count++;
src/mame/drivers/tickee.c
r14063r14064
6060{
6161   const rectangle &visarea = machine.primary_screen->visible_area();
6262
63   *x = (((input_port_read(machine, player ? "GUNX2" : "GUNX1") & 0xff) * (visarea.max_x - visarea.min_x)) >> 8) + visarea.min_x;
64   *y = (((input_port_read(machine, player ? "GUNY2" : "GUNY1") & 0xff) * (visarea.max_y - visarea.min_y)) >> 8) + visarea.min_y;
63   *x = (((input_port_read(machine, player ? "GUNX2" : "GUNX1") & 0xff) * visarea.width()) >> 8) + visarea.min_x;
64   *y = (((input_port_read(machine, player ? "GUNY2" : "GUNY1") & 0xff) * visarea.height()) >> 8) + visarea.min_y;
6565}
6666
6767
src/mame/drivers/srmp5.c
r14063r14064
9292   UINT16 *sprite_list=state->m_sprram;
9393   UINT16 *sprite_list_end=&state->m_sprram[0x4000]; //guess
9494   UINT8 *pixels=(UINT8 *)state->m_tileram;
95   const rectangle &visarea = screen.visible_area();
9695
9796//Table surface seems to be tiles, but display corrupts when switching the scene if always ON.
9897//Currently the tiles are OFF.
r14063r14064
168167                        xs2 = (sprite_sublist[SPRITE_PALETTE] & 0x8000) ? (sizex - xs) : xs;
169168                        if(pen)
170169                        {
171                           if(xb+xs2<=visarea.max_x && xb+xs2>=visarea.min_x && yb+ys2<=visarea.max_y && yb+ys2>=visarea.min_y )
170                           if(cliprect.contains(xb+xs2, yb+ys2))
172171                           {
173172                              UINT16 pixdata=state->m_palram[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)];
174173                              bitmap.pix32(yb+ys2, xb+xs2) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19);
src/mame/drivers/gunpey.c
r14063r14064
8989         g = (color & 0x03e0) >> 2;
9090         r = (color & 0x7c00) >> 7;
9191
92         if(x<screen.visible_area().max_x && y<screen.visible_area().max_y)
92         if(cliprect.contains(x, y))
9393            bitmap.pix32(y, x) = b | (g<<8) | (r<<16);
9494
9595
src/mame/drivers/bingor.c
r14063r14064
474474
475475         color = (state->m_blit_ram[count] & 0xf000)>>12;
476476
477         if((x+3)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
477         if(cliprect.contains(x+3, y))
478478            bitmap.pix32(y, x+3) = screen.machine().pens[color];
479479
480480         color = (state->m_blit_ram[count] & 0x0f00)>>8;
481481
482         if((x+2)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
482         if(cliprect.contains(x+2, y))
483483            bitmap.pix32(y, x+2) = screen.machine().pens[color];
484484
485485         color = (state->m_blit_ram[count] & 0x00f0)>>4;
486486
487         if((x+1)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
487         if(cliprect.contains(x+1, y))
488488            bitmap.pix32(y, x+1) = screen.machine().pens[color];
489489
490490         color = (state->m_blit_ram[count] & 0x000f)>>0;
491491
492         if((x+0)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
492         if(cliprect.contains(x+0, y))
493493            bitmap.pix32(y, x+0) = screen.machine().pens[color];
494494
495495         count++;
src/mame/drivers/cloud9.c
r14063r14064
179179   assert(state->m_vblank_end < state->m_vblank_start);
180180
181181   /* reconfigure the visible area to match */
182   visarea.min_x = 0;
183   visarea.max_x = 255;
184   visarea.min_y = state->m_vblank_end + 1;
185   visarea.max_y = state->m_vblank_start;
182   visarea.set(0, 255, state->m_vblank_end + 1, state->m_vblank_start);
186183   machine.primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL);
187184
188185   /* create a timer for IRQs and set up the first callback */
src/mame/drivers/savquest.c
r14063r14064
7777
7878
7979   // driver_device overrides
80//   virtual void video_start();
80//  virtual void video_start();
8181};
8282
8383// Intel 82439TX System Controller (MXTC)
src/mame/drivers/sfbonus.c
r14063r14064
830830      //printf("%04x %04x %d\n",zz, xxxscroll, line/8);
831831
832832      /* draw top of screen */
833      clip.min_x = visarea.min_x;
834      clip.max_x = 511;
835      clip.min_y = startclipmin;
836      clip.max_y = startclipmin;
833      clip.set(visarea.min_x, 511, startclipmin, startclipmin);
837834
838835
839836
src/mame/drivers/tmmjprd.c
r14063r14064
192192
193193         if (!depth)
194194         {
195            if ((drawx < cliprect.max_x) && (drawx > cliprect.min_x) && (drawy < cliprect.max_y) && (drawy > cliprect.min_y))
195            if (cliprect.contains(drawx, drawy))
196196            {
197197               dat = (rom[(tileaddr*32)+count] & 0xf0)>>4;
198198               if (dat!=15)
r14063r14064
203203               }
204204            }
205205            drawx++;
206            if ((drawx < cliprect.max_x) && (drawx > cliprect.min_x) && (drawy < cliprect.max_y) && (drawy > cliprect.min_y))
206            if (cliprect.contains(drawx, drawy))
207207            {
208208               dat = (rom[(tileaddr*32)+count] & 0x0f);
209209               if (dat!=15)
r14063r14064
218218         }
219219         else
220220         {
221            if ((drawx < cliprect.max_x) && (drawx > cliprect.min_x) && (drawy < cliprect.max_y) && (drawy > cliprect.min_y))
221            if (cliprect.contains(drawx, drawy))
222222            {
223223               dat = (rom[(tileaddr*32)+count] & 0xff);
224224               if (dat!=255)
src/mame/drivers/luckgrln.c
r14063r14064
269269   const rectangle &visarea = screen.visible_area();
270270   int i;
271271
272   rectangle clip;
272   rectangle clip = visarea;
273273
274   clip.min_x = visarea.min_x;
275   clip.max_x = visarea.max_x;
276   clip.min_y = visarea.min_y;
277   clip.max_y = visarea.max_y;
278
279274   bitmap.fill(0, cliprect);
280275
281276   for (i= 0;i < 64;i++)
src/mame/drivers/itgambl3.c
r14063r14064
114114
115115         color = (blit_ram[count] & 0xff)>>0;
116116
117         if((x)<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
117         if(cliprect.contains(x, y))
118118            bitmap.pix32(y, x) = screen.machine().pens[color];
119119
120120         count++;
src/mame/drivers/limenko.c
r14063r14064
119119static WRITE32_HANDLER( spriteram_buffer_w )
120120{
121121   limenko_state *state = space->machine().driver_data<limenko_state>();
122   rectangle clip;
123   clip.min_x = 0;
124   clip.max_x = 383;
125   clip.min_y = 0;
126   clip.max_y = 239;
122   rectangle clip(0, 383, 0, 239);
127123
128124   state->m_sprites_bitmap_pri.fill(0, clip);
129125   state->m_sprites_bitmap.fill(0, clip);
src/mame/drivers/mogura.c
r14063r14064
8484   const rectangle &visarea = screen.visible_area();
8585
8686   /* tilemap layout is a bit strange ... */
87   rectangle clip;
88   clip.min_x = visarea.min_x;
87   rectangle clip = visarea;
8988   clip.max_x = 256 - 1;
90   clip.min_y = visarea.min_y;
91   clip.max_y = visarea.max_y;
9289   tilemap_set_scrollx(state->m_tilemap, 0, 256);
9390   tilemap_draw(bitmap, clip, state->m_tilemap, 0, 0);
9491
9592   clip.min_x = 256;
9693   clip.max_x = 512 - 1;
97   clip.min_y = visarea.min_y;
98   clip.max_y = visarea.max_y;
9994   tilemap_set_scrollx(state->m_tilemap, 0, -128);
10095   tilemap_draw(bitmap, clip, state->m_tilemap, 0, 0);
10196
src/mame/drivers/igs009.c
r14063r14064
298298         int rowenable = state->m_bg_scroll2[zz];
299299
300300         /* draw top of screen */
301         clip.min_x = visarea.min_x;
302         clip.max_x = visarea.max_x;
303         clip.min_y = startclipmin;
304         clip.max_y = startclipmin+2;
301         clip.set(visarea.min_x, visarea.max_x, startclipmin, startclipmin+2);
305302
306303         bitmap.fill(screen.machine().pens[rowenable], clip);
307304
src/mame/drivers/marinedt.c
r14063r14064
547547            int x = OBJ_X(state->m_obj1_x) + sx;
548548            int y = OBJ_Y(state->m_obj1_y) + sy;
549549
550            if (x < cliprect.min_x || x > cliprect.max_x || y < cliprect.min_y || y > cliprect.max_y)
550            if (!cliprect.contains(x, y))
551551               continue;
552552
553553            if (state->m_obj1->pix16(sy, sx) == 0)
src/mame/drivers/cps3.c
r14063r14064
847847   // between 0x00 and 0x80 (0x40 is normal, 0x80 would be 'view twice as much', 0x20 is 'view half as much')
848848   state->m_renderbuffer_bitmap.allocate(512*2,224*2);
849849
850   state->m_renderbuffer_clip.min_x = 0;
851   state->m_renderbuffer_clip.max_x = state->m_screenwidth-1;
852   state->m_renderbuffer_clip.min_y = 0;
853   state->m_renderbuffer_clip.max_y = 224-1;
850   state->m_renderbuffer_clip.set(0, state->m_screenwidth-1, 0, 224-1);
854851
855852   state->m_renderbuffer_bitmap.fill(0x3f, state->m_renderbuffer_clip);
856853
r14063r14064
912909
913910      if (drawline>cliprect.max_y+4) return;
914911
915      clip.min_x = cliprect.min_x;
916      clip.max_x = cliprect.max_x;
917      clip.min_y = drawline;
918      clip.max_y = drawline;
912      clip.set(cliprect.min_x, cliprect.max_x, drawline, drawline);
919913
920914      for (x=0;x<(cliprect.max_x/16)+2;x++)
921915      {
r14063r14064
964958      if (state->m_screenwidth!=496)
965959      {
966960         state->m_screenwidth = 496;
967         visarea.min_x = 0; visarea.max_x = 496-1;
968         visarea.min_y = 0; visarea.max_y = 224-1;
961         visarea.set(0, 496-1, 0, 224-1);
969962         screen.configure(496, 224, visarea, period);
970963      }
971964   }
r14063r14064
974967      if (state->m_screenwidth!=384)
975968      {
976969         state->m_screenwidth = 384;
977         visarea.min_x = 0; visarea.max_x = 384-1;
978         visarea.min_y = 0; visarea.max_y = 224-1;
970         visarea.set(0, 384-1, 0, 224-1);
979971         screen.configure(384, 224, visarea, period);
980972      }
981973   }
src/mame/drivers/tonton.c
r14063r14064
3636   tonton_state(const machine_config &mconfig, device_type type, const char *tag)
3737      : driver_device(mconfig, type, tag),
3838        m_v9938(*this, "v9938") { }
39   
39
4040   required_device<v9938_device> m_v9938;
4141};
4242
src/mame/drivers/flyball.c
r14063r14064
107107
108108   for (y = bally; y < bally + 2; y++)
109109      for (x = ballx; x < ballx + 2; x++)
110         if (x >= cliprect.min_x &&
111             x <= cliprect.max_x &&
112             y >= cliprect.min_y &&
113             y <= cliprect.max_y)
110         if (cliprect.contains(x, y))
114111            bitmap.pix16(y, x) = 1;
115112   return 0;
116113}
src/mame/drivers/progolf.c
r14063r14064
127127               {
128128                  color = state->m_fg_fb[(xi+yi*8)+count*0x40];
129129
130                  if((x+yi) <= cliprect.max_x && (256-y+xi) <= cliprect.max_y && color != 0)
130                  if(cliprect.contains(x+yi, 256-y+xi))
131131                     bitmap.pix16(x+yi, 256-y+xi) = screen.machine().pens[(color & 0x7)];
132132               }
133133            }
src/mame/drivers/jackie.c
r14063r14064
196196      int rowenable = state->m_bg_scroll2[j];
197197
198198      /* draw top of screen */
199      clip.min_x = visarea.min_x;
200      clip.max_x = visarea.max_x;
201      clip.min_y = startclipmin;
202      clip.max_y = startclipmin+1;
199      clip.set(visarea.min_x, visarea.max_x, startclipmin, startclipmin+1);
203200
204201      if (rowenable==0)
205202      {
src/mame/drivers/alg.c
r14063r14064
6464   if (xpos == -1 || ypos == -1)
6565      return FALSE;
6666
67   *x = visarea.min_x + xpos * (visarea.max_x - visarea.min_x + 1) / 255;
68   *y = visarea.min_y + ypos * (visarea.max_y - visarea.min_y + 1) / 255;
67   *x = visarea.min_x + xpos * visarea.width() / 255;
68   *y = visarea.min_y + ypos * visarea.height() / 255;
6969   return TRUE;
7070}
7171
src/mame/drivers/thayers.c
r14063r14064
387387
388388   if (BIT(data, 5))
389389   {
390      if (state->m_ldv1000 != NULL)
390      if (state->m_ldv1000 != NULL)
391391      {
392392         state->m_ldv1000->data_w(state->m_laserdisc_data);
393393         state->m_ldv1000->enter_w(BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
r14063r14064
760760   state->m_cart_present = 0;
761761   state->m_pr7820_enter = 0;
762762
763//   newtype = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820;
764//   laserdisc_set_type(state->m_laserdisc, newtype);
763//  newtype = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820;
764//  laserdisc_set_type(state->m_laserdisc, newtype);
765765}
766766
767767/* COP400 Interface */
src/mame/drivers/taitowlf.c
r14063r14064
8080
8181         color = (blit_ram[count] & 0xff);
8282
83         if((x)+0<screen.visible_area().max_x && ((y)+0)<screen.visible_area().max_y)
83         if(cliprect.contains(x+0, y))
8484            bitmap.pix32(y, x+0) = screen.machine().pens[color];
8585
8686         count++;
src/mame/drivers/dlair.c
r14063r14064
8585      if (m_ldv1000 != NULL) return m_ldv1000->status_strobe_r();
8686      return CLEAR_LINE;
8787   }
88   
88
8989   UINT8 laserdisc_ready_r()
9090   {
9191      if (m_ldv1000 != NULL) return m_ldv1000->command_strobe_r();
r14063r14064
968968
969969static DRIVER_INIT( fixed )
970970{
971//   dlair_state *state = machine.driver_data<dlair_state>();
972//   state->m_laserdisc_type = LASERDISC_TYPE_FIXED;
971//  dlair_state *state = machine.driver_data<dlair_state>();
972//  state->m_laserdisc_type = LASERDISC_TYPE_FIXED;
973973}
974974
975975
976976static DRIVER_INIT( variable )
977977{
978//   dlair_state *state = machine.driver_data<dlair_state>();
979//   state->m_laserdisc_type = LASERDISC_TYPE_VARIABLE;
978//  dlair_state *state = machine.driver_data<dlair_state>();
979//  state->m_laserdisc_type = LASERDISC_TYPE_VARIABLE;
980980}
981981
982982
src/mame/drivers/peplus.c
r14063r14064
321321    const rectangle &vis_area = device->machine().primary_screen->visible_area();
322322    int xt, yt;
323323
324    xt = x_val * (vis_area.max_x - vis_area.min_x) / 1024 + vis_area.min_x;
325    yt = y_val * (vis_area.max_y - vis_area.min_y) / 1024 + vis_area.min_y;
324    xt = x_val * vis_area.width() / 1024 + vis_area.min_x;
325    yt = y_val * vis_area.height() / 1024 + vis_area.min_y;
326326
327327     device->machine().scheduler().timer_set(device->machine().primary_screen->time_until_pos(yt, xt), FUNC(assert_lp_cb), 0, device);
328328}
src/mame/drivers/gpworld.c
r14063r14064
9797      y = bitmap.height() - y - 1;
9898   }
9999
100   if (x < cliprect.min_x ||
101      x > cliprect.max_x ||
102      y < cliprect.min_y ||
103      y > cliprect.max_y)
104      return;
105
106   bitmap.pix16(y, x) = color;
100   if (cliprect.contains(x, y))
101      bitmap.pix16(y, x) = color;
107102}
108103
109104static void gpworld_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
src/mame/drivers/hng64.c
r14063r14064
935935
936936      state->m_screen_dis = 0;
937937
938      visarea.min_x = min_x;
939      visarea.max_x = min_x + max_x - 1;
940      visarea.min_y = min_y;
941      visarea.max_y = min_y + max_y - 1;
938      visarea.set(min_x, min_x + max_x - 1, min_y, min_y + max_y - 1);
942939      space->machine().primary_screen->configure(HTOTAL, VTOTAL, visarea, space->machine().primary_screen->frame_period().attoseconds );
943940   }
944941}
src/mame/drivers/igs011.c
r14063r14064
436436         }
437437
438438         // plot it
439         if (x >= clip.min_x && x <= clip.max_x && y >= clip.min_y && y <= clip.max_y)
439         if (clip.contains(x, y))
440440         {
441441            if      (clear)            dest[x + y * 512] = clear_pen;
442442            else if (pen != trans_pen)   dest[x + y * 512] = pen | pen_hi;
src/mame/drivers/rabbit.c
r14063r14064
377377    tilemap_map_pen_to_layer(state->m_tilemap[3], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
378378
379379   state->m_sprite_bitmap = auto_bitmap_ind16_alloc(machine,0x1000,0x1000);
380   state->m_sprite_clip.min_x = 0;
381   state->m_sprite_clip.max_x = 0x1000-1;
382   state->m_sprite_clip.min_y = 0;
383   state->m_sprite_clip.max_y = 0x1000-1;
380   state->m_sprite_clip.set(0, 0x1000-1, 0, 0x1000-1);
384381}
385382
386383/*
src/osd/sdl/sdlmain.c
r14063r14064
777777   const CFIndex count = 1;
778778   CGRect bounding_rect, success_rect;
779779   CGContextRef context_ref;
780   
780
781781   if( chnum == ' ' )
782782   {
783783      uni_char = 'n';
r14063r14064
10621062   SDL_Surface *drawsurf;
10631063   SDL_Color fcol = { 0xff, 0xff, 0xff };
10641064   UINT16 ustr[16];
1065   
1065
10661066   ttffont = (TTF_Font *)font;
10671067
10681068   memset(ustr,0,sizeof(ustr));
src/emu/cpu/tms34010/tms34010.c
r14063r14064
11201120   UINT16 *dest = &bitmap.pix16(cliprect.min_y);
11211121   for (x = cliprect.min_x; x < params.heblnk; x++)
11221122      dest[x] = blackpen;
1123   for (x = params.hsblnk; x <= cliprect.max_y; x++)
1123   for (x = params.hsblnk; x <= cliprect.max_x; x++)
11241124      dest[x] = blackpen;
11251125   return 0;
11261126
r14063r14064
11681168   UINT32 *dest = &bitmap.pix32(cliprect.min_y);
11691169   for (x = cliprect.min_x; x < params.heblnk; x++)
11701170      dest[x] = blackpen;
1171   for (x = params.hsblnk; x <= cliprect.max_y; x++)
1171   for (x = params.hsblnk; x <= cliprect.max_x; x++)
11721172      dest[x] = blackpen;
11731173   return 0;
11741174}
src/emu/cpu/i386/i386priv.h
r14063r14064
419419            *address = (page_entry & 0xfffff000) | offset;
420420      }
421421   }
422   if(!ret)
422   if(!ret)
423423   {
424424      *error = ((rw && 1)<<1) | ((cpustate->CPL==3)?1<<2:0);
425425      return 0;
src/emu/cpu/i386/i386.c
r14063r14064
22602260   {
22612261      if(newflags & 0x00020000) // if returning to virtual 8086 mode
22622262      {
2263//         UINT8 SSRPL,SSDPL;
2263//          UINT8 SSRPL,SSDPL;
22642264         memset(&desc, 0, sizeof(desc));
22652265         desc.selector = newCS;
22662266         i386_load_protected_mode_segment(cpustate,&desc);
r14063r14064
22752275         /* Return to v86 mode */
22762276         logerror("IRET (%08x): Returning to Virtual 8086 mode.\n",cpustate->pc);
22772277         // Should these be done at this point?  The 386 programmers' reference is a bit confusing about this
2278/*         if(RPL != 3)
2279         {
2280            logerror("IRET to V86 (%08x): Return CS RPL is not 3\n",cpustate->pc);
2281            FAULT(FAULT_GP,newCS);
2282         }
2283         if(operand32 == 0)
2284         {
2285            if(REG16(SP)+36 > cpustate->sreg[SS].limit)
2286            {
2287               logerror("IRET to V86 (%08x): Stack does not have enough room left\n",cpustate->pc);
2288               FAULT(FAULT_SS,0);
2289            }
2290         }
2291         else
2292         {
2293            if(REG32(ESP)+36 > cpustate->sreg[SS].limit)
2294            {
2295               logerror("IRET to V86 (%08x): Stack does not have enough space left\n",cpustate->pc);
2296               FAULT(FAULT_SS,0);
2297            }
2298         }
2299         // code segment checks
2300         if((newCS & ~0x07) == 0)
2301         {
2302            logerror("IRET to V86 (%08x): Return CS selector is null\n",cpustate->pc);
2303            FAULT(FAULT_GP,newCS);
2304         }
2305         if(desc.flags & 0x04)
2306         {  // LDT
2307            if(newCS > cpustate->ldtr.limit)
2308            {
2309               logerror("IRET to V86 (%08x): Return CS selector is past LDT limit\n",cpustate->pc);
2310               FAULT(FAULT_GP,newCS);
2311            }
2312         }
2313         else
2314         {  // GDT
2315            if(newCS > cpustate->gdtr.limit)
2316            {
2317               logerror("IRET to V86 (%08x): Return CS selector is past GDT limit\n",cpustate->pc);
2318               FAULT(FAULT_GP,newCS);
2319            }
2320         }
2321         if((desc.flags & 0x18) != 0x18)
2322         {
2323            logerror("IRET to V86 (%08x): Return CS segment is not a code segment\n",cpustate->pc);
2324            FAULT(FAULT_GP,newCS);
2325         }
2326         if(DPL != 3)
2327         {
2328            logerror("IRET to V86 (%08x): Return CS segment does not have a DPL of 3\n",cpustate->pc);
2329            FAULT(FAULT_GP,newCS);
2330         }
2331         if(!(desc.flags & 0x0080))
2332         {
2333            logerror("IRET to V86 (%08x): Return CS segment is not present\n",cpustate->pc);
2334            FAULT(FAULT_NP,newCS);
2335         }
2336         // Stack segment checks
2337         if((newSS & ~0x07) == 0)
2338         {
2339            logerror("IRET to V86 (%08x): Return SS segment is null\n",cpustate->pc);
2340            FAULT(FAULT_GP,newSS);
2341         }
2342         if(desc.flags & 0x04)
2343         {  // LDT
2344            if(newSS > cpustate->ldtr.limit)
2345            {
2346               logerror("IRET to V86 (%08x): Return SS selector is past LDT limit\n",cpustate->pc);
2347               FAULT(FAULT_GP,newSS);
2348            }
2349         }
2350         else
2351         {  // GDT
2352            if(newSS > cpustate->gdtr.limit)
2353            {
2354               logerror("IRET to V86 (%08x): Return SS selector is past GDT limit\n",cpustate->pc);
2355               FAULT(FAULT_GP,newSS);
2356            }
2357         }
2358         if(SSRPL != RPL)
2359         {
2360            logerror("IRET to V86 (%08x): Return SS selector RPL is not equal to CS selector RPL\n",cpustate->pc);
2361            FAULT(FAULT_GP,newSS);
2362         }
2363         if(((stack.flags & 0x0018) != 0x10) && (!(stack.flags & 0x02)))
2364         {
2365            logerror("IRET to V86 (%08x): Return SS segment is not a writable data segment\n",cpustate->pc);
2366            FAULT(FAULT_GP,newSS);
2367         }
2368         if(SSDPL != RPL)
2369         {
2370            logerror("IRET to V86 (%08x): Return SS segment DPL is not equal to CS selector RPL\n",cpustate->pc);
2371            FAULT(FAULT_GP,newSS);
2372         }
2373         if(!(stack.flags & 0x0080))
2374         {
2375            logerror("IRET to V86 (%08x): Return SS segment is not present\n",cpustate->pc);
2376            FAULT(FAULT_NP,newSS);
2377         }
2278/*          if(RPL != 3)
2279            {
2280                logerror("IRET to V86 (%08x): Return CS RPL is not 3\n",cpustate->pc);
2281                FAULT(FAULT_GP,newCS);
2282            }
2283            if(operand32 == 0)
2284            {
2285                if(REG16(SP)+36 > cpustate->sreg[SS].limit)
2286                {
2287                    logerror("IRET to V86 (%08x): Stack does not have enough room left\n",cpustate->pc);
2288                    FAULT(FAULT_SS,0);
2289                }
2290            }
2291            else
2292            {
2293                if(REG32(ESP)+36 > cpustate->sreg[SS].limit)
2294                {
2295                    logerror("IRET to V86 (%08x): Stack does not have enough space left\n",cpustate->pc);
2296                    FAULT(FAULT_SS,0);
2297                }
2298            }
2299            // code segment checks
2300            if((newCS & ~0x07) == 0)
2301            {
2302                logerror("IRET to V86 (%08x): Return CS selector is null\n",cpustate->pc);
2303                FAULT(FAULT_GP,newCS);
2304            }
2305            if(desc.flags & 0x04)
2306            {  // LDT
2307                if(newCS > cpustate->ldtr.limit)
2308                {
2309                    logerror("IRET to V86 (%08x): Return CS selector is past LDT limit\n",cpustate->pc);
2310                    FAULT(FAULT_GP,newCS);
2311                }
2312            }
2313            else
2314            {  // GDT
2315                if(newCS > cpustate->gdtr.limit)
2316                {
2317                    logerror("IRET to V86 (%08x): Return CS selector is past GDT limit\n",cpustate->pc);
2318                    FAULT(FAULT_GP,newCS);
2319                }
2320            }
2321            if((desc.flags & 0x18) != 0x18)
2322            {
2323                logerror("IRET to V86 (%08x): Return CS segment is not a code segment\n",cpustate->pc);
2324                FAULT(FAULT_GP,newCS);
2325            }
2326            if(DPL != 3)
2327            {
2328                logerror("IRET to V86 (%08x): Return CS segment does not have a DPL of 3\n",cpustate->pc);
2329                FAULT(FAULT_GP,newCS);
2330            }
2331            if(!(desc.flags & 0x0080))
2332            {
2333                logerror("IRET to V86 (%08x): Return CS segment is not present\n",cpustate->pc);
2334                FAULT(FAULT_NP,newCS);
2335            }
2336            // Stack segment checks
2337            if((newSS & ~0x07) == 0)
2338            {
2339                logerror("IRET to V86 (%08x): Return SS segment is null\n",cpustate->pc);
2340                FAULT(FAULT_GP,newSS);
2341            }
2342            if(desc.flags & 0x04)
2343            {  // LDT
2344                if(newSS > cpustate->ldtr.limit)
2345                {
2346                    logerror("IRET to V86 (%08x): Return SS selector is past LDT limit\n",cpustate->pc);
2347                    FAULT(FAULT_GP,newSS);
2348                }
2349            }
2350            else
2351            {  // GDT
2352                if(newSS > cpustate->gdtr.limit)
2353                {
2354                    logerror("IRET to V86 (%08x): Return SS selector is past GDT limit\n",cpustate->pc);
2355                    FAULT(FAULT_GP,newSS);
2356                }
2357            }
2358            if(SSRPL != RPL)
2359            {
2360                logerror("IRET to V86 (%08x): Return SS selector RPL is not equal to CS selector RPL\n",cpustate->pc);
2361                FAULT(FAULT_GP,newSS);
2362            }
2363            if(((stack.flags & 0x0018) != 0x10) && (!(stack.flags & 0x02)))
2364            {
2365                logerror("IRET to V86 (%08x): Return SS segment is not a writable data segment\n",cpustate->pc);
2366                FAULT(FAULT_GP,newSS);
2367            }
2368            if(SSDPL != RPL)
2369            {
2370                logerror("IRET to V86 (%08x): Return SS segment DPL is not equal to CS selector RPL\n",cpustate->pc);
2371                FAULT(FAULT_GP,newSS);
2372            }
2373            if(!(stack.flags & 0x0080))
2374            {
2375                logerror("IRET to V86 (%08x): Return SS segment is not present\n",cpustate->pc);
2376                FAULT(FAULT_NP,newSS);
2377            }
23782378
2379         if(newEIP > desc.limit)
2380         {
2381            logerror("IRET to V86 (%08x): New EIP is past CS segment limit\n",cpustate->pc);
2382            FAULT(FAULT_GP,0);
2383         }
2384         */
2379            if(newEIP > desc.limit)
2380            {
2381                logerror("IRET to V86 (%08x): New EIP is past CS segment limit\n",cpustate->pc);
2382                FAULT(FAULT_GP,0);
2383            }
2384            */
23852385         set_flags(cpustate,newflags);
23862386         cpustate->eip = POP32(cpustate) & 0xffff;  // high 16 bits are ignored
23872387         cpustate->sreg[CS].selector = POP32(cpustate) & 0xffff;
23882388         POP32(cpustate);  // already set flags
2389//         if(RPL > CPL)
2389//          if(RPL > CPL)
23902390         {
23912391            newESP = POP32(cpustate);
23922392            newSS = POP32(cpustate) & 0xffff;
r14063r14064
26492649               FAULT(FAULT_GP,0)
26502650            }
26512651
2652//            if(operand32 == 0)
2653//               REG16(SP) += 10;
2654//            else
2655//               REG32(ESP) += 20;
2652//              if(operand32 == 0)
2653//                  REG16(SP) += 10;
2654//              else
2655//                  REG32(ESP) += 20;
26562656
26572657            if(operand32 == 0)
26582658            {
src/emu/cpu/arm7/arm7thmb.c
r14063r14064
2929// #define THUMB_RELADDR_SP    ((UINT16)0x0800)
3030   tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_0,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,      tg0a_1,
3131// #define THUMB_STACKOP_TYPE  ((UINT16)0x0f00)
32   tg0b_0,      tg0b_0,      tg0b_0,      tg0b_0,      tg0b_1,      tg0b_1,      tg0b_1,      tg0b_1,      tg0b_2,      tg0b_2,      tg0b_2,      tg0b_2,      tg0b_3,      tg0b_3,      tg0b_3,      tg0b_3,      tg0b_4,      tg0b_4,      tg0b_4,      tg0b_4,      tg0b_5,      tg0b_5,      tg0b_5,      tg0b_5,      tg0b_6,      tg0b_6,      tg0b_6,      tg0b_6,      tg0b_7,      tg0b_7,      tg0b_7,      tg0b_7,      tg0b_8,      tg0b_8,      tg0b_8,      tg0b_8,      tg0b_9,      tg0b_9,      tg0b_9,      tg0b_9,      tg0b_a,      tg0b_a,      tg0b_a,      tg0b_a,      tg0b_b,      tg0b_b,      tg0b_b,      tg0b_b,      tg0b_c,      tg0b_c,      tg0b_c,      tg0b_c,      tg0b_d,      tg0b_d,      tg0b_d,      tg0b_d,      tg0b_e,      tg0b_e,      tg0b_e,      tg0b_e,      tg0b_f,      tg0b_f,      tg0b_f,      tg0b_f,     
32   tg0b_0,      tg0b_0,      tg0b_0,      tg0b_0,      tg0b_1,      tg0b_1,      tg0b_1,      tg0b_1,      tg0b_2,      tg0b_2,      tg0b_2,      tg0b_2,      tg0b_3,      tg0b_3,      tg0b_3,      tg0b_3,      tg0b_4,      tg0b_4,      tg0b_4,      tg0b_4,      tg0b_5,      tg0b_5,      tg0b_5,      tg0b_5,      tg0b_6,      tg0b_6,      tg0b_6,      tg0b_6,      tg0b_7,      tg0b_7,      tg0b_7,      tg0b_7,      tg0b_8,      tg0b_8,      tg0b_8,      tg0b_8,      tg0b_9,      tg0b_9,      tg0b_9,      tg0b_9,      tg0b_a,      tg0b_a,      tg0b_a,      tg0b_a,      tg0b_b,      tg0b_b,      tg0b_b,      tg0b_b,      tg0b_c,      tg0b_c,      tg0b_c,      tg0b_c,      tg0b_d,      tg0b_d,      tg0b_d,      tg0b_d,      tg0b_e,      tg0b_e,      tg0b_e,      tg0b_e,      tg0b_f,      tg0b_f,      tg0b_f,      tg0b_f,
3333// #define THUMB_MULTLS        ((UINT16)0x0800)
3434   tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_0,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,      tg0c_1,
3535// #define THUMB_COND_TYPE     ((UINT16)0x0f00)
36   tg0d_0,      tg0d_0,      tg0d_0,      tg0d_0,      tg0d_1,      tg0d_1,      tg0d_1,      tg0d_1,      tg0d_2,      tg0d_2,      tg0d_2,      tg0d_2,      tg0d_3,      tg0d_3,      tg0d_3,      tg0d_3,      tg0d_4,      tg0d_4,      tg0d_4,      tg0d_4,      tg0d_5,      tg0d_5,      tg0d_5,      tg0d_5,      tg0d_6,      tg0d_6,      tg0d_6,      tg0d_6,      tg0d_7,      tg0d_7,      tg0d_7,      tg0d_7,      tg0d_8,      tg0d_8,      tg0d_8,      tg0d_8,      tg0d_9,      tg0d_9,      tg0d_9,      tg0d_9,      tg0d_a,      tg0d_a,      tg0d_a,      tg0d_a,      tg0d_b,      tg0d_b,      tg0d_b,      tg0d_b,      tg0d_c,      tg0d_c,      tg0d_c,      tg0d_c,      tg0d_d,      tg0d_d,      tg0d_d,      tg0d_d,      tg0d_e,      tg0d_e,      tg0d_e,      tg0d_e,      tg0d_f,      tg0d_f,      tg0d_f,      tg0d_f,     
36   tg0d_0,      tg0d_0,      tg0d_0,      tg0d_0,      tg0d_1,      tg0d_1,      tg0d_1,      tg0d_1,      tg0d_2,      tg0d_2,      tg0d_2,      tg0d_2,      tg0d_3,      tg0d_3,      tg0d_3,      tg0d_3,      tg0d_4,      tg0d_4,      tg0d_4,      tg0d_4,      tg0d_5,      tg0d_5,      tg0d_5,      tg0d_5,      tg0d_6,      tg0d_6,      tg0d_6,      tg0d_6,      tg0d_7,      tg0d_7,      tg0d_7,      tg0d_7,      tg0d_8,      tg0d_8,      tg0d_8,      tg0d_8,      tg0d_9,      tg0d_9,      tg0d_9,      tg0d_9,      tg0d_a,      tg0d_a,      tg0d_a,      tg0d_a,      tg0d_b,      tg0d_b,      tg0d_b,      tg0d_b,      tg0d_c,      tg0d_c,      tg0d_c,      tg0d_c,      tg0d_d,      tg0d_d,      tg0d_d,      tg0d_d,      tg0d_e,      tg0d_e,      tg0d_e,      tg0d_e,      tg0d_f,      tg0d_f,      tg0d_f,      tg0d_f,
3737// #define THUMB_BLOP_LO       ((UINT16)0x0800)
3838   tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_0,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,      tg0e_1,
3939// #define THUMB_BLOP_LO       ((UINT16)0x0800)
r14063r14064
116116
117117/* Arithmetic */
118118
119const void tg01_0(arm_state *cpustate, UINT32 pc, UINT32 insn)
119const void tg01_0(arm_state *cpustate, UINT32 pc, UINT32 insn)
120120{
121121   UINT32 rs, rd, rrs;
122122   INT32 offs;
r14063r14064
168168{
169169   UINT32 rn, rs, rd;
170170
171
171
172172    rn = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT);
173173    rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT);
174174    rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
r14063r14064
180180const void tg01_11(arm_state *cpustate, UINT32 pc, UINT32 insn) /* SUB Rd, Rs, Rn */
181181{
182182   UINT32 rn, rs, rd;
183
183
184184    rn = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT);
185185    rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT);
186186    rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
r14063r14064
192192const void tg01_12(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ADD Rd, Rs, #imm */
193193{
194194   UINT32 rs, rd, imm;
195
195
196196    imm = (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT;
197197    rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT);
198198    rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
r14063r14064
204204const void tg01_13(arm_state *cpustate, UINT32 pc, UINT32 insn) /* SUB Rd, Rs, #imm */
205205{
206206   UINT32 rs, rd, imm;
207
207
208208    imm = (insn & THUMB_ADDSUB_RNIMM) >> THUMB_ADDSUB_RNIMM_SHIFT;
209209    rs = GET_REGISTER(cpustate, (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT);
210210    rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
r14063r14064
215215
216216/* CMP / MOV */
217217
218const void tg02_0(arm_state *cpustate, UINT32 pc, UINT32 insn)
218const void tg02_0(arm_state *cpustate, UINT32 pc, UINT32 insn)
219219{
220220   UINT32 rd, op2;
221221
r14063r14064
227227   R15 += 2;
228228}
229229
230const void tg02_1(arm_state *cpustate, UINT32 pc, UINT32 insn)
230const void tg02_1(arm_state *cpustate, UINT32 pc, UINT32 insn)
231231{
232232   UINT32 rn, rd, op2;
233233
r14063r14064
273273const void tg04_00_00(arm_state *cpustate, UINT32 pc, UINT32 insn) /* AND Rd, Rs */
274274{
275275   UINT32 rs, rd;
276
276
277277   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
278278   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
279279   SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) & GET_REGISTER(cpustate, rs));
r14063r14064
286286const void tg04_00_01(arm_state *cpustate, UINT32 pc, UINT32 insn) /* EOR Rd, Rs */
287287{
288288   UINT32 rs, rd;
289
289
290290   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
291291   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
292292   SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) ^ GET_REGISTER(cpustate, rs));
r14063r14064
300300{
301301   UINT32 rs, rd, rrd;
302302   INT32 offs;
303
303
304304   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
305305   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
306306   rrd = GET_REGISTER(cpustate, rd);
r14063r14064
347347{
348348   UINT32 rs, rd, rrd;
349349   INT32 offs;
350
350
351351   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
352352   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
353353   rrd = GET_REGISTER(cpustate, rd);
r14063r14064
393393const void tg04_00_04(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ASR Rd, Rs */
394394{
395395   UINT32 rs, rd, rrs, rrd;
396
396
397397   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
398398   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
399399   rrs = GET_REGISTER(cpustate, rs)&0xff;
r14063r14064
436436const void tg04_00_05(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ADC Rd, Rs */
437437{
438438   UINT32 rn, rs, rd, op2;
439
439
440440   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
441441   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
442442   op2=(GET_CPSR & C_MASK) ? 1 : 0;
r14063r14064
462462const void tg04_00_07(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ROR Rd, Rs */
463463{
464464   UINT32 rs, rd, imm, rrd;
465
465
466466   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
467467   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
468468   rrd = GET_REGISTER(cpustate, rd);
r14063r14064
485485const void tg04_00_08(arm_state *cpustate, UINT32 pc, UINT32 insn) /* TST Rd, Rs */
486486{
487487   UINT32 rs, rd;
488
488
489489   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
490490   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
491491   SET_CPSR(GET_CPSR & ~(Z_MASK | N_MASK));
r14063r14064
497497const void tg04_00_09(arm_state *cpustate, UINT32 pc, UINT32 insn) /* NEG Rd, Rs */
498498{
499499   UINT32 rn, rs, rd, rrs;
500
500
501501   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
502502   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
503503   rrs = GET_REGISTER(cpustate, rs);
r14063r14064
510510const void tg04_00_0a(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Rd, Rs */
511511{
512512   UINT32 rn, rs, rd;
513
513
514514   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
515515   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
516516   rn = GET_REGISTER(cpustate, rd) - GET_REGISTER(cpustate, rs);
r14063r14064
522522const void tg04_00_0b(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMN Rd, Rs - check flags, add dasm */
523523{
524524   UINT32 rn, rs, rd;
525
525
526526   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
527527   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
528528   rn = GET_REGISTER(cpustate, rd) + GET_REGISTER(cpustate, rs);
r14063r14064
533533const void tg04_00_0c(arm_state *cpustate, UINT32 pc, UINT32 insn) /* ORR Rd, Rs */
534534{
535535   UINT32 rs, rd;
536
536
537537   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
538538   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
539539   SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) | GET_REGISTER(cpustate, rs));
r14063r14064
546546const void tg04_00_0d(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MUL Rd, Rs */
547547{
548548   UINT32 rn, rs, rd;
549
549
550550   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
551551   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
552552   rn = GET_REGISTER(cpustate, rd) * GET_REGISTER(cpustate, rs);
r14063r14064
560560const void tg04_00_0e(arm_state *cpustate, UINT32 pc, UINT32 insn) /* BIC Rd, Rs */
561561{
562562   UINT32 rs, rd;
563
563
564564   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
565565   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
566566   SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) & (~GET_REGISTER(cpustate, rs)));
r14063r14064
572572const void tg04_00_0f(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MVN Rd, Rs */
573573{
574574   UINT32 rs, rd, op2;
575
575
576576   rs = (insn & THUMB_ADDSUB_RS) >> THUMB_ADDSUB_RS_SHIFT;
577577   rd = (insn & THUMB_ADDSUB_RD) >> THUMB_ADDSUB_RD_SHIFT;
578578   op2 = GET_REGISTER(cpustate, rs);
r14063r14064
587587
588588const void tg04_01_00(arm_state *cpustate, UINT32 pc, UINT32 insn)
589589{
590//   UINT32 rs, rd;
591//   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
592//   rd = insn & THUMB_HIREG_RD;
590//  UINT32 rs, rd;
591//  rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
592//  rd = insn & THUMB_HIREG_RD;
593593
594594
595595   fatalerror("%08x: G4-1-0 Undefined Thumb instruction: %04x %x\n", pc, insn, (insn & THUMB_HIREG_H) >> THUMB_HIREG_H_SHIFT);
r14063r14064
604604   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
605605   rd = insn & THUMB_HIREG_RD;
606606
607
607
608608   SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rd) + GET_REGISTER(cpustate, rs+8));
609609   // emulate the effects of pre-fetch
610610   if (rs == 7)
r14063r14064
621621   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
622622   rd = insn & THUMB_HIREG_RD;
623623
624
624
625625   SET_REGISTER(cpustate, rd+8, GET_REGISTER(cpustate, rd+8) + GET_REGISTER(cpustate, rs));
626626   if (rd == 7)
627627   {
r14063r14064
637637   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
638638   rd = insn & THUMB_HIREG_RD;
639639
640
640
641641   SET_REGISTER(cpustate, rd+8, GET_REGISTER(cpustate, rd+8) + GET_REGISTER(cpustate, rs+8));
642642   // emulate the effects of pre-fetch
643643   if (rs == 7)
r14063r14064
667667const void tg04_01_11(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Rd, Hs */
668668{
669669   UINT32 rn, rs, rd;
670
670
671671   rs = GET_REGISTER(cpustate, ((insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT) + 8);
672672   rd = GET_REGISTER(cpustate, insn & THUMB_HIREG_RD);
673673   rn = rd - rs;
r14063r14064
678678const void tg04_01_12(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Hd, Rs */
679679{
680680   UINT32 rn, rs, rd;
681
681
682682   rs = GET_REGISTER(cpustate, ((insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT));
683683   rd = GET_REGISTER(cpustate, (insn & THUMB_HIREG_RD) + 8);
684684   rn = rd - rs;
r14063r14064
689689const void tg04_01_13(arm_state *cpustate, UINT32 pc, UINT32 insn) /* CMP Hd, Hs */
690690{
691691   UINT32 rn, rs, rd;
692
692
693693   rs = GET_REGISTER(cpustate, ((insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT) + 8);
694694   rd = GET_REGISTER(cpustate, (insn & THUMB_HIREG_RD) + 8);
695695   rn = rd - rs;
r14063r14064
703703const void tg04_01_20(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Rd, Rs (undefined) */
704704{
705705   UINT32 rs, rd;
706     
707   
706
707
708708   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
709709   rd = insn & THUMB_HIREG_RD;
710710   SET_REGISTER(cpustate, rd, GET_REGISTER(cpustate, rs));
r14063r14064
715715const void tg04_01_21(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Rd, Hs */
716716{
717717   UINT32 rs, rd;
718       
718
719719   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
720720   rd = insn & THUMB_HIREG_RD;
721721   if (rs == 7)
r14063r14064
733733const void tg04_01_22(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Hd, Rs */
734734{
735735   UINT32 rs, rd;
736
736
737737   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
738738   rd = insn & THUMB_HIREG_RD;
739739   SET_REGISTER(cpustate, rd + 8, GET_REGISTER(cpustate, rs));
r14063r14064
751751const void tg04_01_23(arm_state *cpustate, UINT32 pc, UINT32 insn) /* MOV Hd, Hs */
752752{
753753   UINT32 rs, rd;
754 
754
755755   rs = (insn & THUMB_HIREG_RS) >> THUMB_HIREG_RS_SHIFT;
756756   rd = insn & THUMB_HIREG_RD;
757757   if (rs == 7)
r14063r14064
826826
827827const void tg04_01_32(arm_state *cpustate, UINT32 pc, UINT32 insn)
828828{
829//   UINT32 addr;
830//   UINT32 rd;
829//  UINT32 addr;
830//  UINT32 rd;
831831
832832
833833   fatalerror("%08x: G4-3 Undefined Thumb instruction: %04x\n", pc, insn);
r14063r14064
837837
838838const void tg04_01_33(arm_state *cpustate, UINT32 pc, UINT32 insn)
839839{
840//   UINT32 addr;
841//   UINT32 rd;
840//  UINT32 addr;
841//  UINT32 rd;
842842
843843
844844   fatalerror("%08x: G4-3 Undefined Thumb instruction: %04x\n", pc, insn);
r14063r14064
851851
852852
853853
854const void tg04_0203(arm_state *cpustate, UINT32 pc, UINT32 insn)
854const void tg04_0203(arm_state *cpustate, UINT32 pc, UINT32 insn)
855855{
856856   UINT32 readword;
857857
r14063r14064
866866{
867867   UINT32 addr;
868868   UINT32 rm, rn, rd;
869
869
870870    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
871871    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
872872    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
873873    addr = GET_REGISTER(cpustate, rn) + GET_REGISTER(cpustate, rm);
874874    WRITE32(addr, GET_REGISTER(cpustate, rd));
875875    R15 += 2;
876
876
877877}
878878
879879const void tg05_1(arm_state *cpustate, UINT32 pc, UINT32 insn)  /* STRH Rd, [Rn, Rm] */
880880{
881881   UINT32 addr;
882882   UINT32 rm, rn, rd;
883
883
884884    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
885885    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
886886    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
894894{
895895   UINT32 addr;
896896   UINT32 rm, rn, rd;
897
897
898898    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
899899    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
900900    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
908908{
909909   UINT32 addr;
910910   UINT32 rm, rn, rd, op2;
911
911
912912    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
913913    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
914914    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
927927{
928928   UINT32 addr;
929929   UINT32 rm, rn, rd, op2;
930
930
931931    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
932932    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
933933    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
942942{
943943   UINT32 addr;
944944   UINT32 rm, rn, rd, op2;
945
945
946946    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
947947    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
948948    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
957957{
958958   UINT32 addr;
959959   UINT32 rm, rn, rd, op2;
960
960
961961    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
962962    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
963963    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
972972{
973973   UINT32 addr;
974974   UINT32 rm, rn, rd, op2;
975
975
976976    rm = (insn & THUMB_GROUP5_RM) >> THUMB_GROUP5_RM_SHIFT;
977977    rn = (insn & THUMB_GROUP5_RN) >> THUMB_GROUP5_RN_SHIFT;
978978    rd = (insn & THUMB_GROUP5_RD) >> THUMB_GROUP5_RD_SHIFT;
r14063r14064
11191119{
11201120   UINT32 addr;
11211121
1122
1122
11231123    addr = (insn & THUMB_INSN_IMM);
11241124    addr &= ~THUMB_INSN_IMM_S;
11251125    SET_REGISTER(cpustate, 13, GET_REGISTER(cpustate, 13) + ((insn & THUMB_INSN_IMM_S) ? -(addr << 2) : (addr << 2)));
r14063r14064
11291129
11301130const void tg0b_1(arm_state *cpustate, UINT32 pc, UINT32 insn)
11311131{
1132//   UINT32 addr;
1133//   INT32 offs;
1132//  UINT32 addr;
1133//  INT32 offs;
11341134
11351135    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
11361136    R15 += 2;
r14063r14064
11391139
11401140const void tg0b_2(arm_state *cpustate, UINT32 pc, UINT32 insn)
11411141{
1142//   UINT32 addr;
1143//   INT32 offs;
1142//  UINT32 addr;
1143//  INT32 offs;
11441144
11451145    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
11461146    R15 += 2;
r14063r14064
11491149
11501150const void tg0b_3(arm_state *cpustate, UINT32 pc, UINT32 insn)
11511151{
1152//   UINT32 addr;
1153//   INT32 offs;
1152//  UINT32 addr;
1153//  INT32 offs;
11541154
11551155    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
11561156    R15 += 2;
r14063r14064
11601160const void tg0b_4(arm_state *cpustate, UINT32 pc, UINT32 insn) /* PUSH {Rlist} */
11611161{
11621162   INT32 offs;
1163
1163
11641164    for (offs = 7; offs >= 0; offs--)
11651165    {
11661166        if (insn & (1 << offs))
r14063r14064
11761176const void tg0b_5(arm_state *cpustate, UINT32 pc, UINT32 insn) /* PUSH {Rlist}{LR} */
11771177{
11781178   INT32 offs;
1179
1179
11801180    SET_REGISTER(cpustate, 13, GET_REGISTER(cpustate, 13) - 4);
11811181    WRITE32(GET_REGISTER(cpustate, 13), GET_REGISTER(cpustate, 14));
11821182    for (offs = 7; offs >= 0; offs--)
r14063r14064
11931193
11941194const void tg0b_6(arm_state *cpustate, UINT32 pc, UINT32 insn)
11951195{
1196//   UINT32 addr;
1197//   INT32 offs;
1196//  UINT32 addr;
1197//  INT32 offs;
11981198
11991199    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12001200    R15 += 2;
r14063r14064
12031203
12041204const void tg0b_7(arm_state *cpustate, UINT32 pc, UINT32 insn)
12051205{
1206//   UINT32 addr;
1207//   INT32 offs;
1206//  UINT32 addr;
1207//  INT32 offs;
12081208
12091209    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12101210    R15 += 2;
r14063r14064
12131213
12141214const void tg0b_8(arm_state *cpustate, UINT32 pc, UINT32 insn)
12151215{
1216//   UINT32 addr;
1217//   INT32 offs;
1216//  UINT32 addr;
1217//  INT32 offs;
12181218
12191219    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12201220    R15 += 2;
r14063r14064
12231223
12241224const void tg0b_9(arm_state *cpustate, UINT32 pc, UINT32 insn)
12251225{
1226//   UINT32 addr;
1227//   INT32 offs;
1226//  UINT32 addr;
1227//  INT32 offs;
12281228
12291229    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12301230    R15 += 2;
r14063r14064
12331233
12341234const void tg0b_a(arm_state *cpustate, UINT32 pc, UINT32 insn)
12351235{
1236//   UINT32 addr;
1237//   INT32 offs;
1236//  UINT32 addr;
1237//  INT32 offs;
12381238
12391239    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12401240    R15 += 2;
r14063r14064
12431243
12441244const void tg0b_b(arm_state *cpustate, UINT32 pc, UINT32 insn)
12451245{
1246//   UINT32 addr;
1247//   INT32 offs;
1246//  UINT32 addr;
1247//  INT32 offs;
12481248
12491249    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12501250    R15 += 2;
r14063r14064
12541254const void tg0b_c(arm_state *cpustate, UINT32 pc, UINT32 insn) /* POP {Rlist} */
12551255{
12561256   INT32 offs;
1257
1257
12581258    for (offs = 0; offs < 8; offs++)
12591259    {
12601260        if (insn & (1 << offs))
r14063r14064
12701270const void tg0b_d(arm_state *cpustate, UINT32 pc, UINT32 insn) /* POP {Rlist}{PC} */
12711271{
12721272   INT32 offs;
1273
1273
12741274    for (offs = 0; offs < 8; offs++)
12751275    {
12761276        if (insn & (1 << offs))
r14063r14064
12861286
12871287const void tg0b_e(arm_state *cpustate, UINT32 pc, UINT32 insn)
12881288{
1289//   UINT32 addr;
1290//   INT32 offs;
1289//  UINT32 addr;
1290//  INT32 offs;
12911291
12921292    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
12931293    R15 += 2;
r14063r14064
12961296
12971297const void tg0b_f(arm_state *cpustate, UINT32 pc, UINT32 insn)
12981298{
1299//   UINT32 addr;
1300//   INT32 offs;
1299//  UINT32 addr;
1300//  INT32 offs;
13011301
13021302    fatalerror("%08x: Gb Undefined Thumb instruction: %04x\n", pc, insn);
13031303    R15 += 2;
r14063r14064
13611361            ld_st_address += 4;
13621362        }
13631363    }
1364   
1364
13651365   if (!rd_in_list)
13661366        SET_REGISTER(cpustate, rd, ld_st_address);
1367   
1367
13681368   R15 += 2;
13691369}
13701370
r14063r14064
13751375   INT32 offs;
13761376
13771377    offs = (INT8)(insn & THUMB_INSN_IMM);
1378//case
1378//case
13791379    if (Z_IS_SET(GET_CPSR))
13801380    {
13811381        R15 += 4 + (offs << 1);
r14063r14064
13921392   INT32 offs;
13931393
13941394    offs = (INT8)(insn & THUMB_INSN_IMM);
1395//case
1395//case
13961396    if (Z_IS_CLEAR(GET_CPSR))
13971397    {
13981398        R15 += 4 + (offs << 1);
r14063r14064
14091409   INT32 offs;
14101410
14111411    offs = (INT8)(insn & THUMB_INSN_IMM);
1412//case
1412//case
14131413    if (C_IS_SET(GET_CPSR))
14141414    {
14151415        R15 += 4 + (offs << 1);
r14063r14064
14261426   INT32 offs;
14271427
14281428    offs = (INT8)(insn & THUMB_INSN_IMM);
1429//case
1429//case
14301430    if (C_IS_CLEAR(GET_CPSR))
14311431    {
14321432        R15 += 4 + (offs << 1);
r14063r14064
14431443   INT32 offs;
14441444
14451445    offs = (INT8)(insn & THUMB_INSN_IMM);
1446//case
1446//case
14471447    if (N_IS_SET(GET_CPSR))
14481448    {
14491449        R15 += 4 + (offs << 1);
r14063r14064
14601460   INT32 offs;
14611461
14621462    offs = (INT8)(insn & THUMB_INSN_IMM);
1463//case
1463//case
14641464    if (N_IS_CLEAR(GET_CPSR))
14651465    {
14661466        R15 += 4 + (offs << 1);
r14063r14064
14771477   INT32 offs;
14781478
14791479    offs = (INT8)(insn & THUMB_INSN_IMM);
1480//case
1480//case
14811481    if (V_IS_SET(GET_CPSR))
14821482    {
14831483        R15 += 4 + (offs << 1);
r14063r14064
14941494   INT32 offs;
14951495
14961496    offs = (INT8)(insn & THUMB_INSN_IMM);
1497//case
1497//case
14981498    if (V_IS_CLEAR(GET_CPSR))
14991499    {
15001500        R15 += 4 + (offs << 1);
r14063r14064
15111511   INT32 offs;
15121512
15131513    offs = (INT8)(insn & THUMB_INSN_IMM);
1514//case
1514//case
15151515    if (C_IS_SET(GET_CPSR) && Z_IS_CLEAR(GET_CPSR))
15161516    {
15171517        R15 += 4 + (offs << 1);
r14063r14064
15281528   INT32 offs;
15291529
15301530    offs = (INT8)(insn & THUMB_INSN_IMM);
1531//case
1531//case
15321532    if (C_IS_CLEAR(GET_CPSR) || Z_IS_SET(GET_CPSR))
15331533    {
15341534        R15 += 4 + (offs << 1);
r14063r14064
15451545   INT32 offs;
15461546
15471547    offs = (INT8)(insn & THUMB_INSN_IMM);
1548//case
1548//case
15491549    if (!(GET_CPSR & N_MASK) == !(GET_CPSR & V_MASK))
15501550    {
15511551        R15 += 4 + (offs << 1);
r14063r14064
15621562   INT32 offs;
15631563
15641564    offs = (INT8)(insn & THUMB_INSN_IMM);
1565//case
1565//case
15661566    if (!(GET_CPSR & N_MASK) != !(GET_CPSR & V_MASK))
15671567    {
15681568        R15 += 4 + (offs << 1);
r14063r14064
15791579   INT32 offs;
15801580
15811581    offs = (INT8)(insn & THUMB_INSN_IMM);
1582//case
1582//case
15831583    if (Z_IS_CLEAR(GET_CPSR) && !(GET_CPSR & N_MASK) == !(GET_CPSR & V_MASK))
15841584    {
15851585        R15 += 4 + (offs << 1);
r14063r14064
16101610
16111611const void tg0d_e(arm_state *cpustate, UINT32 pc, UINT32 insn) // COND_AL:
16121612{
1613//   INT32 offs;
1613//  INT32 offs;
16141614
16151615//    offs = (INT8)(insn & THUMB_INSN_IMM);
1616//case
1616//case
16171617    fatalerror("%08x: Undefined Thumb instruction: %04x (ARM9 reserved)\n", pc, insn);
16181618    R15 += 2;
16191619
r14063r14064
16211621
16221622const void tg0d_f(arm_state *cpustate, UINT32 pc, UINT32 insn) // COND_NV:   // SWI (this is sort of a "hole" in the opcode encoding)
16231623{
1624//   INT32 offs;
1624//  INT32 offs;
16251625
16261626//    offs = (INT8)(insn & THUMB_INSN_IMM);
16271627
1628//case
1628//case
16291629    cpustate->pendingSwi = 1;
16301630    ARM7_CHECKIRQ;
16311631
r14063r14064
16331633
16341634 /* B #offs */
16351635
1636const void tg0e_0(arm_state *cpustate, UINT32 pc, UINT32 insn)
1636const void tg0e_0(arm_state *cpustate, UINT32 pc, UINT32 insn)
16371637{
16381638   INT32 offs;
16391639
r14063r14064
16491649const void tg0e_1(arm_state *cpustate, UINT32 pc, UINT32 insn)
16501650{
16511651   UINT32 addr;
1652   
1652
16531653    addr = GET_REGISTER(cpustate, 14);
16541654    addr += (insn & THUMB_BLOP_OFFS) << 1;
16551655    addr &= 0xfffffffc;
src/emu/cpu/arm7/arm7.c
r14063r14064
551551
552552         insn = cpustate->direct->read_decrypted_word(raddr);
553553         thumb_handler[(insn & 0xffc0) >> 6](cpustate, pc, insn);
554         
554
555555        }
556556        else
557557        {
src/emu/cpu/arm7/arm7ops.c
r14063r14064
18401840         HandleALU(cpustate, insn);
18411841      }
18421842   }
1843//   break;
1843//  break;
18441844}
18451845
18461846const void arm7ops_4567(arm_state *cpustate, UINT32 insn) /* Data Transfer - Single Data Access */
r14063r14064
18511851//case 7:
18521852   HandleMemSingle(cpustate, insn);
18531853   R15 += 4;
1854//   break;
1854//  break;
18551855}
1856   
1856
18571857const void arm7ops_89(arm_state *cpustate, UINT32 insn) /* Block Data Transfer/Access */
18581858{
18591859//case 8:
18601860//case 9:
18611861   HandleMemBlock(cpustate, insn);
18621862   R15 += 4;
1863//   break;
1863//  break;
18641864}
18651865
18661866const void arm7ops_ab(arm_state *cpustate, UINT32 insn) /* Branch or Branch & Link */
r14063r14064
18681868//case 0xa:
18691869//case 0xb:
18701870   HandleBranch(cpustate, insn);
1871//   break;
1871//  break;
18721872}
18731873
18741874const void arm7ops_cd(arm_state *cpustate, UINT32 insn) /* Co-Processor Data Transfer */
r14063r14064
18771877//case 0xd:
18781878   HandleCoProcDT(cpustate, insn);
18791879   R15 += 4;
1880//   break;
1880//  break;
18811881}
18821882
18831883const void arm7ops_e(arm_state *cpustate, UINT32 insn) /* Co-Processor Data Operation or Register Transfer */
r14063r14064
18881888   else
18891889      HandleCoProcDO(cpustate, insn);
18901890   R15 += 4;
1891//   break;
1891//  break;
18921892}
18931893
18941894const void arm7ops_f(arm_state *cpustate, UINT32 insn) /* Software Interrupt */
r14063r14064
18961896   cpustate->pendingSwi = 1;
18971897   ARM7_CHECKIRQ;
18981898   //couldn't find any cycle counts for SWI
1899//   break;
1899//  break;
19001900}
src/emu/cpu/arm7/arm7ops.h
r14063r14064
55const void arm7ops_ab(arm_state *cpustate, UINT32 insn);
66const void arm7ops_cd(arm_state *cpustate, UINT32 insn);
77const void arm7ops_e(arm_state *cpustate, UINT32 insn);
8const void arm7ops_f(arm_state *cpustate, UINT32 insn);
No newline at end of file
8const void arm7ops_f(arm_state *cpustate, UINT32 insn);
src/emu/video/upd3301.c
r14063r14064
169169
170170   rectangle visarea;
171171
172   visarea.min_x = 0;
173   visarea.min_y = 0;
174   visarea.max_x = (m_h * m_width) - 1;
175   visarea.max_y = (m_l * m_r) - 1;
172   visarea.set(0, (m_h * m_width) - 1, 0, (m_l * m_r) - 1);
176173
177174   if (LOG)
178175   {
src/emu/video/crt9007.c
r14063r14064
420420   // visible area
421421   rectangle visarea;
422422
423   visarea.min_x = m_hsync_end;
424   visarea.max_x = horiz_pix_total - 1;
423   visarea.set(m_hsync_end, horiz_pix_total - 1, m_vsync_end, vert_pix_total - 1);
425424
426   visarea.min_y = m_vsync_end;
427   visarea.max_y = vert_pix_total - 1;
428
429425   if (LOG)
430426   {
431427      logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
src/emu/video/mc6845.c
r14063r14064
324324
325325         attoseconds_t refresh = HZ_TO_ATTOSECONDS(m_clock) * (m_horiz_char_total + 1) * vert_pix_total;
326326
327         visarea.min_x = 0;
328         visarea.min_y = 0;
329         visarea.max_x = max_visible_x;
330         visarea.max_y = max_visible_y;
327         visarea.set(0, max_visible_x, 0, max_visible_y);
331328
332329         if (LOG) logerror("M6845 config screen: HTOTAL: 0x%x  VTOTAL: 0x%x  MAX_X: 0x%x  MAX_Y: 0x%x  HSYNC: 0x%x-0x%x  VSYNC: 0x%x-0x%x  Freq: %ffps\n",
333330                       horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
src/emu/video/hd44102.c
r14063r14064
284284         int sy = m_sy + z;
285285         int sx = m_sx + y;
286286
287         if ((sy >= cliprect.min_y) && (sy <= cliprect.max_y) && (sx >= cliprect.min_x) && (sx <= cliprect.max_x))
287         if (cliprect.contains(sx, sy))
288288         {
289289            int color = (m_status & STATUS_DISPLAY_OFF) ? 0 : BIT(data, z % 8);
290290
src/emu/video/voodoo.c
r14063r14064
930930   if (v->stats.display)
931931   {
932932      const rectangle &visible_area = v->screen->visible_area();
933      int screen_area = (visible_area.max_x - visible_area.min_x + 1) * (visible_area.max_y - visible_area.min_y + 1);
933      int screen_area = visible_area.width() * visible_area.height();
934934      char *statsptr = v->stats.buffer;
935935      int pixelcount;
936936      int i;
r14063r14064
25732573               rectangle visarea;
25742574
25752575               /* create a new visarea */
2576               visarea.min_x = hbp;
2577               visarea.max_x = hbp + hvis - 1;
2578               visarea.min_y = vbp;
2579               visarea.max_y = vbp + vvis - 1;
2576               visarea.set(hbp, hbp + hvis - 1, vbp, vbp + vvis - 1);
25802577
25812578               /* keep within bounds */
25822579               visarea.max_x = MIN(visarea.max_x, htotal - 1);
src/emu/video/i8275.c
r14063r14064
201201      vert_pix_total *= 2; // Use of spaced rows
202202   }
203203
204   visarea.min_x = 0;
205   visarea.min_y = 0;
206   visarea.max_x = horiz_pix_total - 1;
207   visarea.max_y = vert_pix_total - 1;
204   visarea.set(0, horiz_pix_total - 1, 0, vert_pix_total - 1);
208205
209206   i8275->screen->configure(horiz_pix_total, vert_pix_total, visarea,
210207            i8275->screen->frame_period().attoseconds);
src/emu/video/s2636.c
r14063r14064
162162               int tx = x + sx * (expand + 1) + ex;
163163
164164               /* get out if outside the drawing region */
165               if ((tx < cliprect.min_x) ||
166                  (tx > cliprect.max_x) ||
167                  (ty < cliprect.min_y) ||
168                  (ty > cliprect.max_y))
165               if (!cliprect.contains(tx, ty))
169166                  continue;
170167
171168               /* get out if current image bit is transparent */
r14063r14064
221218      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
222219         for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
223220         {
224            if ((x < cliprect.min_x) || (x > cliprect.max_x) ||
225               (y < cliprect.min_y) || (y > cliprect.max_y))
221            if (!cliprect.contains(x, y))
226222               continue;
227223
228224            checksum = checksum + s2636->collision_bitmap->pix16(y, x);
r14063r14064
235231      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
236232         for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
237233         {
238            if ((x < cliprect.min_x) || (x > cliprect.max_x) ||
239               (y < cliprect.min_y) || (y > cliprect.max_y))
234            if (!cliprect.contains(x, y))
240235               continue;
241236
242237            checksum = checksum - s2636->collision_bitmap->pix16(y, x);
src/emu/video/tms9927.c
r14063r14064
240240
241241   /* create a visible area */
242242   /* fix me: how do the offsets fit in here? */
243   visarea.min_x = 0;
244   visarea.max_x = tms->visible_hpix - 1;
245   visarea.min_y = 0;
246   visarea.max_y = tms->visible_vpix - 1;
243   visarea.set(0, tms->visible_hpix - 1, 0, tms->visible_vpix - 1);
247244
248245   refresh = HZ_TO_ATTOSECONDS(tms->clock) * tms->total_hpix * tms->total_vpix;
249246
src/emu/video/pc_vga.c
r14063r14064
181181
182182void pc_video_start(running_machine &machine)
183183{
184//   pc_choosevideomode = choosevideomode;
184//  pc_choosevideomode = choosevideomode;
185185   pc_current_height = -1;
186186   pc_current_width = -1;
187187}
src/emu/video/psx.c
r14063r14064
435435      n_screenwidth = 640;
436436      break;
437437   }
438   visarea.min_x = visarea.min_y = 0;
439   visarea.max_x = n_screenwidth - 1;
440   visarea.max_y = n_screenheight - 1;
438   visarea.set(0, n_screenwidth - 1, 0, n_screenheight - 1);
441439   machine().primary_screen->configure(n_screenwidth, n_screenheight, visarea, HZ_TO_ATTOSECONDS(refresh));
442440}
443441
src/emu/video/vector.c
r14063r14064
258258{
259259   UINT32 flags = PRIMFLAG_ANTIALIAS(screen.machine().options().antialias() ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD);
260260   const rectangle &visarea = screen.visible_area();
261   float xscale = 1.0f / (65536 * (visarea.max_x - visarea.min_x));
262   float yscale = 1.0f / (65536 * (visarea.max_y - visarea.min_y));
261   float xscale = 1.0f / (65536 * visarea.width());
262   float yscale = 1.0f / (65536 * visarea.height());
263263   float xoffs = (float)visarea.min_x;
264264   float yoffs = (float)visarea.min_y;
265265   point *curpoint;
src/emu/video/v9938.c
r14063r14064
257257
258258   // init v9938 512-color palette
259259   PALETTE_INIT_CALL(v9938);
260   
260
261261   if (v99x8_device::s_pal_indYJK == NULL)
262262      v99x8_device::s_pal_indYJK = global_alloc_array(UINT16, 0x20000);
263263
r14063r14064
585585   assert(m_screen != NULL);
586586   if (!m_screen->started())
587587      throw device_missing_dependencies();
588   
588
589589   if (!m_int_callback.isnull())
590590   {
591591      device_t *device = (m_int_callback_device_name != NULL) ? machine().device(m_int_callback_device_name) : NULL;
r14063r14064
18671867
18681868#define SHORT_WIDTH (256 + 16)
18691869#define LONG_WIDTH (512 + 32)
1870 
1870
18711871const v99x8_device::v99x8_mode v99x8_device::s_modes[] = {
18721872   { 0x02,
18731873      &v99x8_device::mode_text1<UINT16, LONG_WIDTH>,
r14063r14064
22742274#define CM_HMMC  0xF
22752275
22762276/*************************************************************/
2277// Many VDP commands are executed in some kind of loop but 
2278// essentially, there are only a few basic loop structures 
2279// that are re-used. We define the loop structures that are
2280// re-used here so that they have to be entered only once   
2277// Many VDP commands are executed in some kind of loop but
2278// essentially, there are only a few basic loop structures
2279// that are re-used. We define the loop structures that are
2280// re-used here so that they have to be entered only once
22812281/*************************************************************/
22822282#define pre_loop \
22832283    while ((cnt-=delta) > 0) {
r14063r14064
23312331//  ScrOf ScrOn ScrOf ScrOn
23322332static const int srch_timing[8]={
23332333  818, 1025,  818,  830, // ntsc
2334  696,  854,  696,  684  // pal
2334  696,  854,  696,  684  // pal
23352335};
23362336static const int line_timing[8]={
23372337  1063, 1259, 1063, 1161,
r14063r14064
31063106  if (ScrMode<5)
31073107    return(0);
31083108
3109  SM = ScrMode-5;         // Screen mode index 0..3
3109  SM = ScrMode-5;         // Screen mode index 0..3
31103110
31113111  m_mmc.CM = Op>>4;
31123112  if ((m_mmc.CM & 0x0C) != 0x0C && m_mmc.CM != 0)
src/emu/video/v9938.h
r14063r14064
7979   int get_transpen();
8080   bitmap_ind16 &get_bitmap() { return m_bitmap; }
8181   void update_mouse_state(int mx_delta, int my_delta, int button_state);
82   
82
8383   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8484
8585   DECLARE_READ8_MEMBER( read );
r14063r14064
9898
9999protected:
100100   int m_model;
101   
101
102102   // device overrides
103103   virtual void device_start();
104104   virtual void device_reset();
r14063r14064
110110   int vram_read (int offset);
111111   void check_int ();
112112   void register_write (int reg, int data);
113   
113
114114   template<typename _PixelType, int _Width> void default_border(const pen_t *pens, _PixelType *ln);
115115   template<typename _PixelType, int _Width> void graphic7_border(const pen_t *pens, _PixelType *ln);
116116   template<typename _PixelType, int _Width> void graphic5_border(const pen_t *pens, _PixelType *ln);
r14063r14064
135135   void refresh_line (int line);
136136
137137   void interrupt_start_vblank ();
138   
138
139139   UINT8 *VDPVRMP(UINT8 M, int MX, int X, int Y);
140140
141141   UINT8 VDPpoint5(int MXS, int SX, int SY);
src/emu/tilemap.c
r14063r14064
44
55    Generic tilemap management system.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7****************************************************************************
98
10***************************************************************************/
9    Copyright Aaron Giles
10    All rights reserved.
1111
12#include "emu.h"
13#include "profiler.h"
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
1415
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
1525
16/***************************************************************************
17    CONSTANTS
18***************************************************************************/
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
1937
20/* internal usage to mark tiles dirty */
21#define TILE_FLAG_DIRTY               0xff
22
23/* invalid logical index */
24#define INVALID_LOGICAL_INDEX         ((tilemap_logical_index)~0)
25
26/* maximum index in each array */
27#define MAX_PEN_TO_FLAGS            256
28
29
30/***************************************************************************
31    TYPE DEFINITIONS
3238***************************************************************************/
3339
34/* logical index */
35typedef UINT32 tilemap_logical_index;
40#include "emu.h"
41#include "profiler.h"
3642
3743
38/* internal set of transparency states for rendering */
39typedef enum
40{
41   WHOLLY_TRANSPARENT,
42   WHOLLY_OPAQUE,
43   MASKED
44} trans_t;
44//**************************************************************************
45//  INLINE FUNCTIONS
46//**************************************************************************
4547
48//-------------------------------------------------
49//  effective_rowscroll - return the effective
50//  rowscroll value for a given index, taking into
51//  account tilemap flip states
52//-------------------------------------------------
4653
47/* internal blitting callbacks */
48typedef void (*blitmask_func)(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
49typedef void (*blitopaque_func)(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
50
51
52/* blitting parameters for rendering */
53typedef struct _blit_parameters blit_parameters;
54struct _blit_parameters
54inline INT32 tilemap_t::effective_rowscroll(int index, UINT32 screen_width)
5555{
56   rectangle         cliprect;
57   blitmask_func      draw_masked;
58   blitopaque_func      draw_opaque;
59   UINT32            tilemap_priority_code;
60   UINT8            mask;
61   UINT8            value;
62   UINT8            alpha;
63};
56   // if we're flipping vertically, adjust the row number
57   if (m_attributes & TILEMAP_FLIPY)
58      index = m_scrollrows - 1 - index;
6459
65
66/* core tilemap structure */
67class tilemap_t
68{
69public:
70   tilemap_t(running_machine &machine)
71      : m_machine(machine) { }
72
73   running_machine &machine() const { return m_machine; }
74
75   tilemap_t *               next;            /* pointer to next tilemap */
76
77   /* basic tilemap metrics */
78   UINT32                  rows;            /* number of tile rows */
79   UINT32                  cols;            /* number of tile columns */
80   UINT32                  tilewidth;         /* width of a single tile in pixels */
81   UINT32                  tileheight;         /* height of a single tile in pixels */
82   UINT32                  width;            /* width of the full tilemap in pixels */
83   UINT32                  height;            /* height of the full tilemap in pixels */
84
85   /* logical <-> memory mappings */
86   tilemap_mapper_func         mapper;            /* callback to map a row/column to a memory index */
87   tilemap_logical_index *      memory_to_logical;   /* map from memory index to logical index */
88   tilemap_logical_index      max_logical_index;   /* maximum valid logical index */
89   tilemap_memory_index *      logical_to_memory;   /* map from logical index to memory index */
90   tilemap_memory_index      max_memory_index;   /* maximum valid memory index */
91
92   /* callback to interpret video RAM for the tilemap */
93   tile_get_info_func         tile_get_info;      /* callback to get information about a tile */
94   void *                  tile_get_info_object;/* object passed as the first parameter to the get_info functon */
95   tile_data               tileinfo;         /* structure to hold the data for a tile */
96   void *                  user_data;         /* user data value passed to the callback */
97
98   /* global tilemap states */
99   UINT8                  enable;            /* true if we are enabled */
100   UINT8                  attributes;         /* global attributes (flipx/y) */
101   UINT8                  all_tiles_dirty;   /* true if all tiles are dirty */
102   UINT8                  all_tiles_clean;   /* true if all tiles are clean */
103   UINT32                  palette_offset;      /* palette offset */
104   UINT32                  pen_data_offset;   /* pen data offset */
105   UINT32                  gfx_used;         /* bitmask of gfx items used */
106   UINT32                  gfx_dirtyseq[MAX_GFX_ELEMENTS]; /* dirtyseq values from last check */
107
108   /* scroll information */
109   UINT32                  scrollrows;         /* number of independently scrolled rows */
110   UINT32                  scrollcols;         /* number of independently scrolled colums */
111   INT32 *                  rowscroll;         /* array of rowscroll values */
112   INT32 *                  colscroll;         /* array of colscroll values */
113   INT32                  dx;               /* global horizontal scroll offset */
114   INT32                  dx_flipped;         /* global horizontal scroll offset when flipped */
115   INT32                  dy;               /* global vertical scroll offset */
116   INT32                  dy_flipped;         /* global vertical scroll offset when flipped */
117
118   /* pixel data */
119   bitmap_ind16         pixmap;            /* cached pixel data */
120
121   /* transparency mapping */
122   bitmap_ind8            flagsmap;         /* per-pixel flags */
123   UINT8 *                  tileflags;         /* per-tile flags */
124   UINT8 *                  pen_to_flags;      /* mapping of pens to flags */
125
126private:
127   running_machine &         m_machine;         /* pointer back to the owning machine */
128};
129
130
131struct _tilemap_private
132{
133   tilemap_t *      list;
134   tilemap_t **      tailptr;
135   int            instance;
136};
137
138
139
140/***************************************************************************
141    FUNCTION PROTOTYPES
142***************************************************************************/
143
144/* system management helpers */
145static tilemap_t *tilemap_create_common(running_machine &machine, void *get_info_object, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows);
146static void tilemap_exit(running_machine &machine);
147static void tilemap_postload(tilemap_t *tmap);
148static void tilemap_dispose(tilemap_t *tmap);
149
150/* logical <-> memory index mapping */
151static void mappings_create(tilemap_t *tmap);
152static void mappings_update(tilemap_t *tmap);
153
154/* tile rendering */
155static void pixmap_update(tilemap_t *tmap);
156static void tile_update(tilemap_t *tmap, tilemap_logical_index logindex, UINT32 cached_col, UINT32 cached_row);
157static UINT8 tile_draw(tilemap_t *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags, UINT8 pen_mask);
158static UINT8 tile_apply_bitmask(tilemap_t *tmap, const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags);
159
160/* drawing helpers */
161static void configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_format dest_format, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask);
162template<class _BitmapClass>
163static void tilemap_draw_instance(_BitmapClass &dest, tilemap_t *tmap, const blit_parameters *blit, int xpos, int ypos);
164template<class _BitmapClass>
165static void tilemap_draw_roz_core(_BitmapClass &dest, tilemap_t *tmap, const blit_parameters *blit,
166      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound);
167
168/* scanline rasterizers for drawing to the pixmap */
169inline void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode);
170inline void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode);
171inline void scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode);
172inline void scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode);
173inline void scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
174inline void scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
175inline void scanline_draw_opaque_rgb32_alpha(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
176inline void scanline_draw_masked_rgb32_alpha(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
177
178
179
180/***************************************************************************
181    INLINE FUNCTIONS
182***************************************************************************/
183
184/*-------------------------------------------------
185    effective_rowscroll - return the effective
186    rowscroll value for a given index, taking into
187    account tilemap flip states
188-------------------------------------------------*/
189
190INLINE INT32 effective_rowscroll(tilemap_t *tmap, int index, UINT32 screen_width)
191{
60   // adjust final result based on the horizontal flip and dx values
19261   INT32 value;
193
194   /* if we're flipping vertically, adjust the row number */
195   if (tmap->attributes & TILEMAP_FLIPY)
196      index = tmap->scrollrows - 1 - index;
197
198   /* adjust final result based on the horizontal flip and dx values */
199   if (!(tmap->attributes & TILEMAP_FLIPX))
200      value = tmap->dx - tmap->rowscroll[index];
62   if (!(m_attributes & TILEMAP_FLIPX))
63      value = m_dx - m_rowscroll[index];
20164   else
202      value = screen_width - tmap->width - (tmap->dx_flipped - tmap->rowscroll[index]);
65      value = screen_width - m_width - (m_dx_flipped - m_rowscroll[index]);
20366
204   /* clamp to 0..width */
67   // clamp to 0..width
20568   if (value < 0)
206      value = tmap->width - (-value) % tmap->width;
69      value = m_width - (-value) % m_width;
20770   else
208      value %= tmap->width;
71      value %= m_width;
20972   return value;
21073}
21174
21275
213/*-------------------------------------------------
214    effective_colscroll - return the effective
215    colscroll value for a given index, taking into
216    account tilemap flip states
217-------------------------------------------------*/
76//-------------------------------------------------
77//  effective_colscroll - return the effective
78//  colscroll value for a given index, taking into
79//  account tilemap flip states
80//-------------------------------------------------
21881
219INLINE INT32 effective_colscroll(tilemap_t *tmap, int index, UINT32 screen_height)
82inline INT32 tilemap_t::effective_colscroll(int index, UINT32 screen_height)
22083{
221   INT32 value;
84   // if we're flipping horizontally, adjust the column number
85   if (m_attributes & TILEMAP_FLIPX)
86      index = m_scrollcols - 1 - index;
22287
223   /* if we're flipping horizontally, adjust the column number */
224   if (tmap->attributes & TILEMAP_FLIPX)
225      index = tmap->scrollcols - 1 - index;
226
227   /* adjust final result based on the vertical flip and dx values */
228   if (!(tmap->attributes & TILEMAP_FLIPY))
229      value = tmap->dy - tmap->colscroll[index];
88   // adjust final result based on the vertical flip and dx values
89   INT32 value;
90   if (!(m_attributes & TILEMAP_FLIPY))
91      value = m_dy - m_colscroll[index];
23092   else
231      value = screen_height - tmap->height - (tmap->dy_flipped - tmap->colscroll[index]);
93      value = screen_height - m_height - (m_dy_flipped - m_colscroll[index]);
23294
233   /* clamp to 0..height */
95   // clamp to 0..height
23496   if (value < 0)
235      value = tmap->height - (-value) % tmap->height;
97      value = m_height - (-value) % m_height;
23698   else
237      value %= tmap->height;
99      value %= m_height;
238100   return value;
239101}
240102
241103
242/*-------------------------------------------------
243    indexed_tilemap - return a tilemap by index
244-------------------------------------------------*/
104//-------------------------------------------------
105//  gfx_tiles_changed - return TRUE if any
106//  gfx_elements used by this tilemap have
107//  changed
108//-------------------------------------------------
245109
246INLINE tilemap_t *indexed_tilemap(running_machine &machine, int index)
110inline bool tilemap_t::gfx_elements_changed()
247111{
248   tilemap_t *tmap;
112   UINT32 usedmask = m_gfx_used;
113   bool isdirty = false;
249114
250   /* find by the tilemap index */
251   for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next)
252      if (index-- == 0)
253         return tmap;
254
255   return NULL;
256}
257
258
259/*-------------------------------------------------
260    gfx_tiles_changed - return TRUE if any
261    gfx_elements used by this tilemap have
262    changed
263-------------------------------------------------*/
264
265INLINE int gfx_elements_changed(tilemap_t *tmap)
266{
267   UINT32 usedmask = tmap->gfx_used;
268   int isdirty = FALSE;
269   int gfxnum;
270
271   /* iterate over all used gfx types and set the dirty flag if any of them have changed */
272   for (gfxnum = 0; usedmask != 0; usedmask >>= 1, gfxnum++)
115   // iterate over all used gfx types and set the dirty flag if any of them have changed
116   for (int gfxnum = 0; usedmask != 0; usedmask >>= 1, gfxnum++)
273117      if ((usedmask & 1) != 0)
274         if (tmap->gfx_dirtyseq[gfxnum] != tmap->machine().gfx[gfxnum]->dirtyseq)
118         if (m_gfx_dirtyseq[gfxnum] != machine().gfx[gfxnum]->dirtyseq)
275119         {
276            tmap->gfx_dirtyseq[gfxnum] = tmap->machine().gfx[gfxnum]->dirtyseq;
277            isdirty = TRUE;
120            m_gfx_dirtyseq[gfxnum] = machine().gfx[gfxnum]->dirtyseq;
121            isdirty = true;
278122         }
279123
280124   return isdirty;
281125}
282126
283127
284/***************************************************************************
285    SYSTEM-WIDE MANAGEMENT
286***************************************************************************/
128//**************************************************************************
129//  SCANLINE RASTERIZERS
130//**************************************************************************
287131
288/*-------------------------------------------------
289    tilemap_init - initialize the tilemap system
290-------------------------------------------------*/
132//-------------------------------------------------
133//  scanline_draw_opaque_null - draw to a NULL
134//  bitmap, setting priority only
135//-------------------------------------------------
291136
292void tilemap_init(running_machine &machine)
137inline void tilemap_t::scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode)
293138{
294   if (machine.primary_screen == NULL || machine.primary_screen->width() == 0)
139   // skip entirely if not changing priority
140   if (pcode == 0xff00)
295141      return;
296142
297   machine.primary_screen->register_screen_bitmap(machine.priority_bitmap);
298   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(tilemap_exit), &machine));
143   // update priority across the scanline
144   for (int i = 0; i < count; i++)
145      pri[i] = (pri[i] & (pcode >> 8)) | pcode;
299146}
300147
301148
149//-------------------------------------------------
150//  scanline_draw_masked_null - draw to a NULL
151//  bitmap using a mask, setting priority only
152//-------------------------------------------------
302153
303/***************************************************************************
304    TILEMAP CREATION AND CONFIGURATION
305***************************************************************************/
306
307/*-------------------------------------------------
308    tilemap_create - create a new tilemap
309-------------------------------------------------*/
310
311tilemap_t *tilemap_create(running_machine &machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
154inline void tilemap_t::scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
312155{
313   return tilemap_create_common(machine, (void *)&machine, tile_get_info, mapper, tilewidth, tileheight, cols, rows);
156   // skip entirely if not changing priority
157   if (pcode == 0xff00)
158      return;
159
160   // update priority across the scanline, checking the mask
161   for (int i = 0; i < count; i++)
162      if ((maskptr[i] & mask) == value)
163         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
314164}
315165
316166
317/*-------------------------------------------------
318    tilemap_create - create a new tilemap that
319    is owned by a device
320-------------------------------------------------*/
321167
322tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
168//-------------------------------------------------
169//  scanline_draw_opaque_ind16 - draw to a 16bpp
170//  indexed bitmap
171//-------------------------------------------------
172
173inline void tilemap_t::scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode)
323174{
324   return tilemap_create_common(device->machine(), (void *)device, (tile_get_info_func)tile_get_info, mapper, tilewidth, tileheight, cols, rows);
325}
175   // special case for no palette offset
176   int pal = pcode >> 16;
177   if (pal == 0)
178   {
179      // use memcpy which should be well-optimized for the platform
180      memcpy(dest, source, count * 2);
326181
182      // skip the rest if not changing priority
183      if (pcode == 0xff00)
184         return;
327185
328/*-------------------------------------------------
329    tilemap_create_common - shared creation
330    function
331-------------------------------------------------*/
186      // update priority across the scanline
187      for (int i = 0; i < count; i++)
188         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
189   }
332190
333static tilemap_t *tilemap_create_common(running_machine &machine, void *get_info_object, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
334{
335   tilemap_t *tmap;
336   int tilemap_instance;
337   int group;
338
339   /* if no tilemap private data yet, allocate it */
340   if (machine.tilemap_data == NULL)
191   // priority case
192   else if ((pcode & 0xffff) != 0xff00)
341193   {
342      machine.tilemap_data = auto_alloc_clear(machine, tilemap_private);
343      machine.tilemap_data->tailptr = &machine.tilemap_data->list;
194      for (int i = 0; i < count; i++)
195      {
196         dest[i] = source[i] + pal;
197         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
198      }
344199   }
345   tilemap_instance = machine.tilemap_data->instance;
346200
347   /* allocate the tilemap itself */
348   tmap = auto_alloc_clear(machine, tilemap_t(machine));
349
350   /* fill in the basic metrics */
351   tmap->rows = rows;
352   tmap->cols = cols;
353   tmap->tilewidth = tilewidth;
354   tmap->tileheight = tileheight;
355   tmap->width = cols * tilewidth;
356   tmap->height = rows * tileheight;
357
358   /* set up the logical <-> memory mappings */
359   tmap->mapper = mapper;
360   mappings_create(tmap);
361
362   /* set up the tile map callbacks */
363   tmap->tile_get_info = tile_get_info;
364   tmap->tile_get_info_object = get_info_object;
365
366   /* set up the default pen mask */
367   tmap->tileinfo.pen_mask = 0xff;
368   tmap->tileinfo.gfxnum = 0xff;
369
370   /* initialize global states */
371   tmap->enable = TRUE;
372   tmap->all_tiles_dirty = TRUE;
373
374   /* initialize scroll information */
375   tmap->scrollrows = 1;
376   tmap->scrollcols = 1;
377   tmap->rowscroll = auto_alloc_array_clear(machine, INT32, tmap->height);
378   tmap->colscroll = auto_alloc_array_clear(machine, INT32, tmap->width);
379
380   /* allocate the pixel data cache */
381   tmap->pixmap.allocate(tmap->width, tmap->height);
382
383   /* allocate transparency mapping data */
384   tmap->tileflags = auto_alloc_array(machine, UINT8, tmap->max_logical_index);
385   tmap->flagsmap.allocate(tmap->width, tmap->height);
386   tmap->pen_to_flags = auto_alloc_array_clear(machine, UINT8, MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS);
387   for (group = 0; group < TILEMAP_NUM_GROUPS; group++)
388      tilemap_map_pens_to_layer(tmap, group, 0, 0, TILEMAP_PIXEL_LAYER0);
389
390   /* add us to the end of the list of tilemaps */
391   *machine.tilemap_data->tailptr = tmap;
392   machine.tilemap_data->tailptr = &tmap->next;
393
394   /* save relevant state */
395   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->enable));
396   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->attributes));
397   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->palette_offset));
398   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->pen_data_offset));
399   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->scrollrows));
400   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->scrollcols));
401   machine.save().save_pointer("tilemap", NULL, tilemap_instance, NAME(tmap->rowscroll), rows * tileheight);
402   machine.save().save_pointer("tilemap", NULL, tilemap_instance, NAME(tmap->colscroll), cols * tilewidth);
403   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dx));
404   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dx_flipped));
405   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dy));
406   machine.save().save_item("tilemap", NULL, tilemap_instance, NAME(tmap->dy_flipped));
407   machine.tilemap_data->instance++;
408
409   /* reset everything after a load */
410   machine.save().register_postload(save_prepost_delegate(FUNC(tilemap_postload), tmap));
411   return tmap;
201   // no priority case
202   else
203   {
204      for (int i = 0; i < count; i++)
205         dest[i] = source[i] + pal;
206   }
412207}
413208
414209
415/*-------------------------------------------------
416    tilemap_set_user_data - specify a parameter
417    to be passed into the tile_get_info callback
418-------------------------------------------------*/
210//-------------------------------------------------
211//  scanline_draw_masked_ind16 - draw to a 16bpp
212//  indexed bitmap using a mask
213//-------------------------------------------------
419214
420void tilemap_set_user_data(tilemap_t *tmap, void *user_data)
215inline void tilemap_t::scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
421216{
422   tmap->user_data = user_data;
423}
217   int pal = pcode >> 16;
424218
219   // priority case
220   if ((pcode & 0xffff) != 0xff00)
221   {
222      for (int i = 0; i < count; i++)
223         if ((maskptr[i] & mask) == value)
224         {
225            dest[i] = source[i] + pal;
226            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
227         }
228   }
425229
426/*-------------------------------------------------
427    tilemap_set_palette_offset - specify an offset
428    to be added to each pixel before looking up
429    the palette
430-------------------------------------------------*/
431
432void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset)
433{
434   tmap->palette_offset = offset;
230   // no priority case
231   else
232   {
233      for (int i = 0; i < count; i++)
234         if ((maskptr[i] & mask) == value)
235            dest[i] = source[i] + pal;
236   }
435237}
436238
437239
438/*-------------------------------------------------
439    tilemap_set_enable - set an enable flag for
440    the tilemap; if 0, requests to draw the
441    tilemap are ignored
442-------------------------------------------------*/
443240
444void tilemap_set_enable(tilemap_t *tmap, int enable)
445{
446   tmap->enable = (enable != 0);
447}
241//-------------------------------------------------
242//  scanline_draw_opaque_rgb32 - draw to a 32bpp
243//  RGB bitmap
244//-------------------------------------------------
448245
449/*-------------------------------------------------
450    tilemap_get_scrolldx - return the enable flag
451    for the tilemap
452-------------------------------------------------*/
453
454int tilemap_get_enable(tilemap_t *tmap)
246inline void tilemap_t::scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
455247{
456   return tmap->enable;
457}
248   const pen_t *clut = &pens[pcode >> 16];
458249
250   // priority case
251   if ((pcode & 0xffff) != 0xff00)
252   {
253      for (int i = 0; i < count; i++)
254      {
255         dest[i] = clut[source[i]];
256         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
257      }
258   }
459259
460/*-------------------------------------------------
461    tilemap_set_flip - set a global flip for the
462    tilemap
463-------------------------------------------------*/
464
465void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes)
466{
467   /* if we're changing things, force a refresh of the mappings and mark it all dirty */
468   if (tmap->attributes != attributes)
260   // no priority case
261   else
469262   {
470      tmap->attributes = attributes;
471      mappings_update(tmap);
263      for (int i = 0; i < count; i++)
264         dest[i] = clut[source[i]];
472265   }
473266}
474267
475268
476/*-------------------------------------------------
477    tilemap_set_flip_all - set a global flip for all
478    the tilemaps
479-------------------------------------------------*/
269//-------------------------------------------------
270//  scanline_draw_masked_rgb32 - draw to a 32bpp
271//  RGB bitmap using a mask
272//-------------------------------------------------
480273
481void tilemap_set_flip_all(running_machine &machine, UINT32 attributes)
274inline void tilemap_t::scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
482275{
483   tilemap_t *tmap;
276   const pen_t *clut = &pens[pcode >> 16];
484277
485   if (machine.tilemap_data == NULL)
486      return;
487
488   for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next)
489      tilemap_set_flip(tmap, attributes);
490}
491
492
493
494/***************************************************************************
495    DIRTY TILE MARKING
496***************************************************************************/
497
498/*-------------------------------------------------
499    tilemap_mark_tile_dirty - mark a single tile
500    dirty based on its memory index
501-------------------------------------------------*/
502
503void tilemap_mark_tile_dirty(tilemap_t *tmap, tilemap_memory_index memindex)
504{
505   /* only mark if within range */
506   if (memindex < tmap->max_memory_index)
278   // priority case
279   if ((pcode & 0xffff) != 0xff00)
507280   {
508      tilemap_logical_index logindex = tmap->memory_to_logical[memindex];
281      for (int i = 0; i < count; i++)
282         if ((maskptr[i] & mask) == value)
283         {
284            dest[i] = clut[source[i]];
285            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
286         }
287   }
509288
510      /* there may be no logical index for a given memory index */
511      if (logindex != INVALID_LOGICAL_INDEX)
512      {
513         tmap->tileflags[logindex] = TILE_FLAG_DIRTY;
514         tmap->all_tiles_clean = FALSE;
515      }
289   // no priority case
290   else
291   {
292      for (int i = 0; i < count; i++)
293         if ((maskptr[i] & mask) == value)
294            dest[i] = clut[source[i]];
516295   }
517296}
518297
519298
520/*-------------------------------------------------
521    tilemap_mark_all_tiles_dirty - mark all the
522    tiles in a tilemap dirty
523-------------------------------------------------*/
299//-------------------------------------------------
300//  scanline_draw_opaque_rgb32_alpha - draw to a
301//  32bpp RGB bitmap with alpha blending
302//-------------------------------------------------
524303
525void tilemap_mark_all_tiles_dirty(tilemap_t *tmap)
304inline void tilemap_t::scanline_draw_opaque_rgb32_alpha(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
526305{
527   /* mark all tiles dirty and clear the clean flag */
528   tmap->all_tiles_dirty = TRUE;
529   tmap->all_tiles_clean = FALSE;
530}
306   const pen_t *clut = &pens[pcode >> 16];
531307
532
533/*-------------------------------------------------
534    tilemap_mark_all_tiles_dirty_all - mark all the
535    tiles in all the tilemaps dirty
536-------------------------------------------------*/
537
538void tilemap_mark_all_tiles_dirty_all(running_machine &machine)
539{
540   tilemap_t *tmap;
541   for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next)
542      tilemap_mark_all_tiles_dirty(tmap);
543}
544
545
546/***************************************************************************
547    PEN-TO-LAYER MAPPING
548***************************************************************************/
549
550/*-------------------------------------------------
551    tilemap_map_pens_to_layer - specify the
552    mapping of one or more pens (where
553    (<pen> & mask) == pen) to a layer
554-------------------------------------------------*/
555
556void tilemap_map_pens_to_layer(tilemap_t *tmap, int group, pen_t pen, pen_t mask, UINT8 layermask)
557{
558   UINT8 *array = tmap->pen_to_flags + group * MAX_PEN_TO_FLAGS;
559   pen_t start, stop, cur;
560   UINT8 changed = FALSE;
561
562   assert(group < TILEMAP_NUM_GROUPS);
563   assert((layermask & TILEMAP_PIXEL_CATEGORY_MASK) == 0);
564
565   /* we start at the index where (pen & mask) == pen, and all other bits are 0 */
566   start = pen & mask;
567
568   /* we stop at the index where (pen & mask) == pen, and all other bits are 1 */
569   stop = start | ~mask;
570
571   /* clamp to the number of entries actually there */
572   stop = MIN(stop, MAX_PEN_TO_FLAGS - 1);
573
574   /* iterate and set */
575   for (cur = start; cur <= stop; cur++)
576      if ((cur & mask) == pen && array[cur] != layermask)
308   // priority case
309   if ((pcode & 0xffff) != 0xff00)
310   {
311      for (int i = 0; i < count; i++)
577312      {
578         changed = TRUE;
579         array[cur] = layermask;
313         dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
314         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
580315      }
316   }
581317
582   /* everything gets dirty if anything changed */
583   if (changed)
584      tilemap_mark_all_tiles_dirty(tmap);
318   // no priority case
319   else
320   {
321      for (int i = 0; i < count; i++)
322         dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
323   }
585324}
586325
587326
588/*-------------------------------------------------
589    tilemap_set_transparent_pen - set a single
590    transparent pen into the tilemap, mapping
591    all other pens to layer 0
592-------------------------------------------------*/
327//-------------------------------------------------
328//  scanline_draw_masked_rgb32_alpha - draw to a
329//  32bpp RGB bitmap using a mask and alpha
330//  blending
331//-------------------------------------------------
593332
594void tilemap_set_transparent_pen(tilemap_t *tmap, pen_t pen)
333inline void tilemap_t::scanline_draw_masked_rgb32_alpha(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
595334{
596   /* reset the whole pen map to opaque */
597   tilemap_map_pens_to_layer(tmap, 0, 0, 0, TILEMAP_PIXEL_LAYER0);
335   const pen_t *clut = &pens[pcode >> 16];
598336
599   /* set the single pen to transparent */
600    tilemap_map_pen_to_layer(tmap, 0, pen, TILEMAP_PIXEL_TRANSPARENT);
601}
337   // priority case
338   if ((pcode & 0xffff) != 0xff00)
339   {
340      for (int i = 0; i < count; i++)
341         if ((maskptr[i] & mask) == value)
342         {
343            dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
344            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
345         }
346   }
602347
603
604/*-------------------------------------------------
605    tilemap_set_transmask - set up the first 32
606    pens using a foreground mask (mapping to
607    layer 0) and a background mask (mapping to
608    layer 1)
609-------------------------------------------------*/
610
611void tilemap_set_transmask(tilemap_t *tmap, int group, UINT32 fgmask, UINT32 bgmask)
612{
613   pen_t pen;
614
615   /* iterate over all 32 pens specified */
616   for (pen = 0; pen < 32; pen++)
348   // no priority case
349   else
617350   {
618      UINT8 fgbits = ((fgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER0;
619      UINT8 bgbits = ((bgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER1;
620      tilemap_map_pen_to_layer(tmap, group, pen, fgbits | bgbits);
351      for (int i = 0; i < count; i++)
352         if ((maskptr[i] & mask) == value)
353            dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
621354   }
622355}
623356
624357
358//**************************************************************************
359//  TILEMAP CREATION AND CONFIGURATION
360//**************************************************************************
625361
626/***************************************************************************
627    TILEMAP SCROLLING
628***************************************************************************/
362//-------------------------------------------------
363//  tilemap_create_common - shared creation
364//  function
365//-------------------------------------------------
629366
630/*-------------------------------------------------
631    tilemap_set_scroll_rows - specify the number of
632    independently scrollable row units; each unit
633    covers height/scroll_rows pixels
634-------------------------------------------------*/
635
636void tilemap_set_scroll_rows(tilemap_t *tmap, UINT32 scroll_rows)
367tilemap_t::tilemap_t(tilemap_manager &manager, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows)
368   : m_next(NULL),
369     m_rows(rows),
370     m_cols(cols),
371     m_tilewidth(tilewidth),
372     m_tileheight(tileheight),
373     m_width(cols * tilewidth),
374     m_height(rows * tileheight),
375     m_mapper(mapper),
376     m_memory_to_logical(NULL),
377     m_max_logical_index(0),
378     m_logical_to_memory(NULL),
379     m_max_memory_index(0),
380     m_tile_get_info(tile_get_info),
381     m_user_data(NULL),
382     m_enable(true),
383     m_attributes(0),
384     m_all_tiles_dirty(true),
385     m_all_tiles_clean(false),
386     m_palette_offset(0),
387     m_pen_data_offset(0),
388     m_gfx_used(0),
389     m_scrollrows(1),
390     m_scrollcols(1),
391     m_rowscroll(auto_alloc_array_clear(manager.machine(), INT32, m_height)),
392     m_colscroll(auto_alloc_array_clear(manager.machine(), INT32, m_width)),
393     m_dx(0),
394     m_dx_flipped(0),
395     m_dy(0),
396     m_dy_flipped(0),
397     m_pixmap(m_width, m_height),
398     m_flagsmap(m_width, m_height),
399     m_tileflags(NULL),
400     m_manager(manager)
637401{
638   assert(scroll_rows <= tmap->height);
639   tmap->scrollrows = scroll_rows;
640}
402   // reset internal arrays
403   memset(m_gfx_dirtyseq, 0, sizeof(m_gfx_dirtyseq));
404   memset(m_pen_to_flags, 0, sizeof(m_pen_to_flags));
641405
406   // create the initial mappings
407   mappings_create();
642408
643/*-------------------------------------------------
644    tilemap_set_scroll_cols - specify the number of
645    independently scrollable column units; each
646    unit covers width/scroll_cols pixels
647-------------------------------------------------*/
409   // set up the default pen mask
410   memset(&m_tileinfo, 0, sizeof(m_tileinfo));
411   m_tileinfo.pen_mask = 0xff;
412   m_tileinfo.gfxnum = 0xff;
648413
649void tilemap_set_scroll_cols(tilemap_t *tmap, UINT32 scroll_cols)
650{
651   assert(scroll_cols <= tmap->width);
652   tmap->scrollcols = scroll_cols;
653}
414   // allocate transparency mapping data
415   m_tileflags = auto_alloc_array(machine(), UINT8, m_max_logical_index);
416   for (int group = 0; group < TILEMAP_NUM_GROUPS; group++)
417      map_pens_to_layer(group, 0, 0, TILEMAP_PIXEL_LAYER0);
654418
419   // save relevant state
420   int instance = manager.alloc_instance();
421   machine().save().save_item("tilemap", NULL, instance, NAME(m_enable));
422   machine().save().save_item("tilemap", NULL, instance, NAME(m_attributes));
423   machine().save().save_item("tilemap", NULL, instance, NAME(m_palette_offset));
424   machine().save().save_item("tilemap", NULL, instance, NAME(m_pen_data_offset));
425   machine().save().save_item("tilemap", NULL, instance, NAME(m_scrollrows));
426   machine().save().save_item("tilemap", NULL, instance, NAME(m_scrollcols));
427   machine().save().save_pointer("tilemap", NULL, instance, NAME(m_rowscroll), rows * tileheight);
428   machine().save().save_pointer("tilemap", NULL, instance, NAME(m_colscroll), cols * tilewidth);
429   machine().save().save_item("tilemap", NULL, instance, NAME(m_dx));
430   machine().save().save_item("tilemap", NULL, instance, NAME(m_dx_flipped));
431   machine().save().save_item("tilemap", NULL, instance, NAME(m_dy));
432   machine().save().save_item("tilemap", NULL, instance, NAME(m_dy_flipped));
655433
656/*-------------------------------------------------
657    tilemap_set_scrolldx - specify global
658    horizontal scroll offset, for non-flipped and
659    flipped cases
660-------------------------------------------------*/
661
662void tilemap_set_scrolldx(tilemap_t *tmap, int dx, int dx_flipped)
663{
664   tmap->dx = dx;
665   tmap->dx_flipped = dx_flipped;
434   // reset everything after a load
435   machine().save().register_postload(save_prepost_delegate(FUNC(tilemap_t::postload), this));
666436}
667437
668438
669/*-------------------------------------------------
670    tilemap_set_scrolldy - specify global
671    vertical scroll offset, for non-flipped and
672    flipped cases
673-------------------------------------------------*/
439//-------------------------------------------------
440//  ~tilemap_t - destructor
441//-------------------------------------------------
674442
675void tilemap_set_scrolldy(tilemap_t *tmap, int dy, int dy_flipped)
443tilemap_t::~tilemap_t()
676444{
677   tmap->dy = dy;
678   tmap->dy_flipped = dy_flipped;
679445}
680446
681447
682/*-------------------------------------------------
683    tilemap_get_scrolldx - return the global
684    horizontal scroll offset, based on current
685    flip state
686-------------------------------------------------*/
448//-------------------------------------------------
449//  mark_tile_dirty - mark a single tile dirty
450//  based on its memory index
451//-------------------------------------------------
687452
688int tilemap_get_scrolldx(tilemap_t *tmap)
453void tilemap_t::mark_tile_dirty(tilemap_memory_index memindex)
689454{
690   return (tmap->attributes & TILEMAP_FLIPX) ? tmap->dx_flipped : tmap->dx;
691}
692
693
694/*-------------------------------------------------
695    tilemap_get_scrolldy - return the global
696    vertical scroll offset, based on current
697    flip state
698-------------------------------------------------*/
699
700int tilemap_get_scrolldy(tilemap_t *tmap)
701{
702   return (tmap->attributes & TILEMAP_FLIPY) ? tmap->dy_flipped : tmap->dy;
703}
704
705
706/*-------------------------------------------------
707    tilemap_set_scrollx - specify the scroll value
708    for a row unit
709-------------------------------------------------*/
710
711void tilemap_set_scrollx(tilemap_t *tmap, int which, int value)
712{
713   if (which < tmap->scrollrows)
714      tmap->rowscroll[which] = value;
715}
716
717
718/*-------------------------------------------------
719    tilemap_set_scrolly - specify the scroll value
720    for a column unit
721-------------------------------------------------*/
722
723void tilemap_set_scrolly(tilemap_t *tmap, int which, int value)
724{
725   if (which < tmap->scrollcols)
726      tmap->colscroll[which] = value;
727}
728
729
730/*-------------------------------------------------
731    tilemap_get_scrollx - return the scroll value
732    for a row unit
733-------------------------------------------------*/
734
735int tilemap_get_scrollx(tilemap_t *tmap, int which)
736{
737   if (which < tmap->scrollrows)
738      return tmap->rowscroll[which];
739   else
740      return 0;
741}
742
743
744/*-------------------------------------------------
745    tilemap_get_scrolly - return the scroll value
746    for a column unit
747-------------------------------------------------*/
748
749int tilemap_get_scrolly(tilemap_t *tmap, int which)
750{
751   if (which < tmap->scrollcols)
752      return tmap->colscroll[which];
753   else
754      return 0;
755}
756
757
758
759/***************************************************************************
760    INTERNAL MAP ACCESS
761***************************************************************************/
762
763/*-------------------------------------------------
764    tilemap_get_pixmap - return a pointer to the
765    (updated) internal pixmap for a tilemap
766-------------------------------------------------*/
767
768bitmap_ind16 &tilemap_get_pixmap(tilemap_t *tmap)
769{
770   /* ensure all the tiles are up-to-date and then return the pixmap */
771   pixmap_update(tmap);
772   return tmap->pixmap;
773}
774
775
776/*-------------------------------------------------
777    tilemap_get_flagsmap - return a pointer to the
778    (updated) internal flagsmap for a tilemap
779-------------------------------------------------*/
780
781bitmap_ind8 &tilemap_get_flagsmap(tilemap_t *tmap)
782{
783   /* ensure all the tiles are up-to-date and then return the flagsmap */
784   pixmap_update(tmap);
785   return tmap->flagsmap;
786}
787
788
789/*-------------------------------------------------
790    tilemap_get_pixmap - return a pointer to the
791    (updated) internal per-tile flags for a tilemap
792-------------------------------------------------*/
793
794UINT8 *tilemap_get_tile_flags(tilemap_t *tmap)
795{
796   /* ensure all the tiles are up-to-date and then return the per-tile flags */
797   pixmap_update(tmap);
798   return tmap->tileflags;
799}
800
801
802
803/***************************************************************************
804    TILEMAP RENDERING
805***************************************************************************/
806
807/*-------------------------------------------------
808    tilemap_draw_primask - draw a tilemap to the
809    destination with clipping; pixels apply
810    priority/priority_mask to the priority bitmap
811-------------------------------------------------*/
812
813template<class _BitmapClass>
814void tilemap_draw_primask_common(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask)
815{
816   UINT32 width, height;
817   blit_parameters blit;
818   int xpos, ypos;
819
820   /* skip if disabled */
821   if (!tmap->enable)
822      return;
823
824g_profiler.start(PROFILER_TILEMAP_DRAW);
825   /* configure the blit parameters based on the input parameters */
826   configure_blit_parameters(&blit, tmap, dest.format(), cliprect, flags, priority, priority_mask);
827
828   /* if the whole map is dirty, mark it as such */
829   if (tmap->all_tiles_dirty || gfx_elements_changed(tmap))
455   // only mark if within range
456   if (memindex < m_max_memory_index)
830457   {
831      memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
832      tmap->all_tiles_dirty = FALSE;
833      tmap->gfx_used = 0;
834   }
835
836   width  = tmap->machine().primary_screen->width();
837   height = tmap->machine().primary_screen->height();
838
839   /* XY scrolling playfield */
840   if (tmap->scrollrows == 1 && tmap->scrollcols == 1)
841   {
842      int scrollx = effective_rowscroll(tmap, 0, width);
843      int scrolly = effective_colscroll(tmap, 0, height);
844
845      /* iterate to handle wraparound */
846      for (ypos = scrolly - tmap->height; ypos <= blit.cliprect.max_y; ypos += tmap->height)
847         for (xpos = scrollx - tmap->width; xpos <= blit.cliprect.max_x; xpos += tmap->width)
848            tilemap_draw_instance(dest, tmap, &blit, xpos, ypos);
849   }
850
851   /* scrolling rows + vertical scroll */
852   else if (tmap->scrollcols == 1)
853   {
854      const rectangle original_cliprect = blit.cliprect;
855      int rowheight = tmap->height / tmap->scrollrows;
856      int scrolly = effective_colscroll(tmap, 0, height);
857      int currow, nextrow;
858
859      /* iterate over Y to handle wraparound */
860      for (ypos = scrolly - tmap->height; ypos <= original_cliprect.max_y; ypos += tmap->height)
458      // there may be no logical index for a given memory index
459      logical_index logindex = m_memory_to_logical[memindex];
460      if (logindex != INVALID_LOGICAL_INDEX)
861461      {
862         int const firstrow = MAX((original_cliprect.min_y - ypos) / rowheight, 0);
863         int const lastrow =  MIN((original_cliprect.max_y - ypos) / rowheight, tmap->scrollrows - 1);
864
865         /* iterate over rows in the tilemap */
866         for (currow = firstrow; currow <= lastrow; currow = nextrow)
867         {
868            int scrollx = effective_rowscroll(tmap, currow, width);
869
870            /* scan forward until we find a non-matching row */
871            for (nextrow = currow + 1; nextrow <= lastrow; nextrow++)
872               if (effective_rowscroll(tmap, nextrow, width) != scrollx)
873                  break;
874
875            /* skip if disabled */
876            if (scrollx == TILE_LINE_DISABLED)
877               continue;
878
879            /* update the cliprect just for this set of rows */
880            blit.cliprect.min_y = currow * rowheight + ypos;
881            blit.cliprect.max_y = nextrow * rowheight - 1 + ypos;
882            blit.cliprect &= original_cliprect;
883
884            /* iterate over X to handle wraparound */
885            for (xpos = scrollx - tmap->width; xpos <= original_cliprect.max_x; xpos += tmap->width)
886               tilemap_draw_instance(dest, tmap, &blit, xpos, ypos);
887         }
462         m_tileflags[logindex] = TILE_FLAG_DIRTY;
463         m_all_tiles_clean = false;
888464      }
889465   }
890
891   /* scrolling columns + horizontal scroll */
892   else if (tmap->scrollrows == 1)
893   {
894      const rectangle original_cliprect = blit.cliprect;
895      int colwidth = tmap->width / tmap->scrollcols;
896      int scrollx = effective_rowscroll(tmap, 0, width);
897      int curcol, nextcol;
898
899      /* iterate over columns in the tilemap */
900      for (curcol = 0; curcol < tmap->scrollcols; curcol = nextcol)
901      {
902         int scrolly   = effective_colscroll(tmap, curcol, height);
903
904         /* scan forward until we find a non-matching column */
905         for (nextcol = curcol + 1; nextcol < tmap->scrollcols; nextcol++)
906            if (effective_colscroll(tmap, nextcol, height) != scrolly)
907               break;
908
909         /* skip if disabled */
910         if (scrolly == TILE_LINE_DISABLED)
911            continue;
912
913         /* iterate over X to handle wraparound */
914         for (xpos = scrollx - tmap->width; xpos <= original_cliprect.max_x; xpos += tmap->width)
915         {
916            /* update the cliprect just for this set of columns */
917            blit.cliprect.min_x = curcol * colwidth + xpos;
918            blit.cliprect.max_x = nextcol * colwidth - 1 + xpos;
919            blit.cliprect &= original_cliprect;
920
921            /* iterate over Y to handle wraparound */
922            for (ypos = scrolly - tmap->height; ypos <= original_cliprect.max_y; ypos += tmap->height)
923               tilemap_draw_instance(dest, tmap, &blit, xpos, ypos);
924         }
925      }
926   }
927g_profiler.stop();
928466}
929467
930void tilemap_draw_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask)
931{ tilemap_draw_primask_common(dest, cliprect, tmap, flags, priority, priority_mask); }
932468
933void tilemap_draw_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask)
934{ tilemap_draw_primask_common(dest, cliprect, tmap, flags, priority, priority_mask); }
469//-------------------------------------------------
470//  map_pens_to_layer - specify the mapping of one
471//  or more pens (where (<pen> & mask) == pen) to
472//  a layer
473//-------------------------------------------------
935474
936/*-------------------------------------------------
937    tilemap_draw_primask - draw a tilemap to the
938    destination with clipping and arbitrary
939    rotate/zoom; pixels apply priority/
940    priority_mask to the priority bitmap
941-------------------------------------------------*/
942
943template<class _BitmapClass>
944void tilemap_draw_roz_common(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap,
945      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
946      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
475void tilemap_t::map_pens_to_layer(int group, pen_t pen, pen_t mask, UINT8 layermask)
947476{
948   blit_parameters blit;
477   assert(group < TILEMAP_NUM_GROUPS);
478   assert((layermask & TILEMAP_PIXEL_CATEGORY_MASK) == 0);
949479
950/* notes:
951   - startx and starty MUST be UINT32 for calculations to work correctly
952   - srcbitmap->width and height are assumed to be a power of 2 to speed up wraparound
953   */
480   // we start at the index where (pen & mask) == pen, and all other bits are 0
481   pen_t start = pen & mask;
954482
955   /* skip if disabled */
956   if (!tmap->enable)
957      return;
483   // we stop at the index where (pen & mask) == pen, and all other bits are 1
484   pen_t stop = start | ~mask;
958485
959   /* see if this is just a regular render and if so, do a regular render */
960   if (incxx == (1 << 16) && incxy == 0 && incyx == 0 && incyy == (1 << 16) && wraparound)
961   {
962      tilemap_set_scrollx(tmap, 0, startx >> 16);
963      tilemap_set_scrolly(tmap, 0, starty >> 16);
964      tilemap_draw(dest, cliprect, tmap, flags, priority);
965      return;
966   }
486   // clamp to the number of entries actually there
487   stop = MIN(stop, MAX_PEN_TO_FLAGS - 1);
967488
968g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ);
969   /* configure the blit parameters */
970   configure_blit_parameters(&blit, tmap, dest.format(), cliprect, flags, priority, priority_mask);
489   // iterate and set
490   UINT8 *array = m_pen_to_flags + group * MAX_PEN_TO_FLAGS;
491   bool changed = false;
492   for (pen_t cur = start; cur <= stop; cur++)
493      if ((cur & mask) == pen && array[cur] != layermask)
494      {
495         changed = true;
496         array[cur] = layermask;
497      }
971498
972   /* get the full pixmap for the tilemap */
973   tilemap_get_pixmap(tmap);
974
975   /* then do the roz copy */
976   tilemap_draw_roz_core(dest, tmap, &blit, startx, starty, incxx, incxy, incyx, incyy, wraparound);
977g_profiler.stop();
499   // everything gets dirty if anything changed
500   if (changed)
501      mark_all_dirty();
978502}
979503
980void tilemap_draw_roz_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap,
981      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
982      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
983{ tilemap_draw_roz_common(dest, cliprect, tmap, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); }
984504
985void tilemap_draw_roz_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
986      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
987      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
988{ tilemap_draw_roz_common(dest, cliprect, tmap, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); }
505//-------------------------------------------------
506//  set_transparent_pen - set a single transparent
507//  pen into the tilemap, mapping all other pens
508//  to layer 0
509//-------------------------------------------------
989510
990
991/***************************************************************************
992    INDEXED TILEMAP HANDLING
993***************************************************************************/
994
995/*-------------------------------------------------
996    tilemap_count - return the number of tilemaps
997-------------------------------------------------*/
998
999int tilemap_count(running_machine &machine)
511void tilemap_t::set_transparent_pen(pen_t pen)
1000512{
1001   tilemap_t *tmap;
1002   int count = 0;
513   // reset the whole pen map to opaque
514   map_pens_to_layer(0, 0, 0, TILEMAP_PIXEL_LAYER0);
1003515
1004   if (machine.tilemap_data == NULL)
1005      return 0;
1006
1007   /* find by the tilemap index */
1008   for (tmap = machine.tilemap_data->list; tmap != NULL; tmap = tmap->next)
1009      count++;
1010   return count;
516   // set the single pen to transparent
517    map_pen_to_layer(0, pen, TILEMAP_PIXEL_TRANSPARENT);
1011518}
1012519
1013520
1014/*-------------------------------------------------
1015    tilemap_size_by_index - return the size of an
1016    indexed tilemap
1017-------------------------------------------------*/
521//-------------------------------------------------
522//  set_transmask - set up the first 32 pens using
523//  a foreground mask (mapping to layer 0) and a
524//  background mask (mapping to layer 1)
525//-------------------------------------------------
1018526
1019void tilemap_size_by_index(running_machine &machine, int number, UINT32 *width, UINT32 *height)
527void tilemap_t::set_transmask(int group, UINT32 fgmask, UINT32 bgmask)
1020528{
1021   tilemap_t *tmap = indexed_tilemap(machine, number);
1022   *width = tmap->width;
1023   *height = tmap->height;
1024}
1025
1026
1027/*-------------------------------------------------
1028    tilemap_draw_by_index - render an indexed
1029    tilemap with fixed characteristics (no
1030    priority)
1031-------------------------------------------------*/
1032
1033void tilemap_draw_by_index(running_machine &machine, bitmap_rgb32 &dest, int number, UINT32 scrollx, UINT32 scrolly)
1034{
1035   tilemap_t *tmap = indexed_tilemap(machine, number);
1036   blit_parameters blit;
1037   int xpos,ypos;
1038
1039   /* set up for the blit, using hard-coded parameters (no priority, etc) */
1040   configure_blit_parameters(&blit, tmap, dest.format(), dest.cliprect(), TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0, 0xff);
1041
1042   /* compute the effective scroll positions */
1043   scrollx = tmap->width  - scrollx % tmap->width;
1044   scrolly = tmap->height - scrolly % tmap->height;
1045
1046   /* if the whole map is dirty, mark it as such */
1047   if (tmap->all_tiles_dirty || gfx_elements_changed(tmap))
529   // iterate over all 32 pens specified
530   for (pen_t pen = 0; pen < 32; pen++)
1048531   {
1049      memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
1050      tmap->all_tiles_dirty = FALSE;
1051      tmap->gfx_used = 0;
532      UINT8 fgbits = ((fgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER0;
533      UINT8 bgbits = ((bgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER1;
534      map_pen_to_layer(group, pen, fgbits | bgbits);
1052535   }
1053
1054   /* iterate to handle wraparound */
1055   for (ypos = scrolly - tmap->height; ypos <= blit.cliprect.max_y; ypos += tmap->height)
1056      for (xpos = scrollx - tmap->width; xpos <= blit.cliprect.max_x; xpos += tmap->width)
1057         tilemap_draw_instance(dest, tmap, &blit, xpos, ypos);
1058536}
1059537
1060538
1061539
1062/***************************************************************************
1063    COMMON LOGICAL-TO-MEMORY MAPPERS
1064***************************************************************************/
540//**************************************************************************
541//  COMMON LOGICAL-TO-MEMORY MAPPERS
542//**************************************************************************
1065543
1066/*-------------------------------------------------
1067    tilemap_scan_rows
1068    tilemap_scan_rows_flip_x
1069    tilemap_scan_rows_flip_y
1070    tilemap_scan_rows_flip_xy - scan in row-major
1071    order with optional flipping
1072-------------------------------------------------*/
544//-------------------------------------------------
545//  tilemap_scan_rows
546//  tilemap_scan_rows_flip_x
547//  tilemap_scan_rows_flip_y
548//  tilemap_scan_rows_flip_xy - scan in row-major
549//  order with optional flipping
550//-------------------------------------------------
1073551
1074552TILEMAP_MAPPER( tilemap_scan_rows )
1075553{
r14063r14064
1092570}
1093571
1094572
1095/*-------------------------------------------------
1096    tilemap_scan_cols
1097    tilemap_scan_cols_flip_x
1098    tilemap_scan_cols_flip_y
1099    tilemap_scan_cols_flip_xy - scan in column-
1100    major order with optional flipping
1101-------------------------------------------------*/
573//-------------------------------------------------
574//  tilemap_scan_cols
575//  tilemap_scan_cols_flip_x
576//  tilemap_scan_cols_flip_y
577//  tilemap_scan_cols_flip_xy - scan in column-
578//  major order with optional flipping
579//-------------------------------------------------
1102580
1103581TILEMAP_MAPPER( tilemap_scan_cols )
1104582{
r14063r14064
1122600
1123601
1124602
1125/***************************************************************************
1126    SYSTEM MANAGEMENT HELPERS
1127***************************************************************************/
603//-------------------------------------------------
604//  postload - after loading a save state
605//  invalidate everything
606//-------------------------------------------------
1128607
1129/*-------------------------------------------------
1130    tilemap_exit - free memory allocated by the
1131    tilemap system
1132-------------------------------------------------*/
1133
1134static void tilemap_exit(running_machine &machine)
608void tilemap_t::postload()
1135609{
1136   tilemap_private *tilemap_data = machine.tilemap_data;
1137
1138   /* free all the tilemaps in the list */
1139   if (tilemap_data != NULL)
1140      while (tilemap_data->list != NULL)
1141      {
1142         tilemap_t *next = tilemap_data->list->next;
1143         tilemap_dispose(tilemap_data->list);
1144         tilemap_data->list = next;
1145      }
610   mappings_update();
1146611}
1147612
1148613
1149/*-------------------------------------------------
1150    tilemap_postload - after loading a save state
1151    invalidate everything
1152-------------------------------------------------*/
1153614
1154static void tilemap_postload(tilemap_t *tmap)
1155{
1156   mappings_update(tmap);
1157}
615//**************************************************************************
616//  LOGICAL <-> MEMORY INDEX MAPPING
617//**************************************************************************
1158618
619//-------------------------------------------------
620//  mappings_create - allocate memory for the
621//  mapping tables and compute their extents
622//-------------------------------------------------
1159623
1160/*-------------------------------------------------
1161    tilemap_dispose - dispose of a tilemap
1162-------------------------------------------------*/
1163
1164static void tilemap_dispose(tilemap_t *tmap)
624void tilemap_t::mappings_create()
1165625{
1166   tilemap_t **tmapptr;
626   // compute the maximum logical index
627   m_max_logical_index = m_rows * m_cols;
1167628
1168   /* walk the list of tilemaps; when we find ourself, remove it */
1169   for (tmapptr = &tmap->machine().tilemap_data->list; *tmapptr != NULL; tmapptr = &(*tmapptr)->next)
1170      if (*tmapptr == tmap)
629   // compute the maximum memory index
630   m_max_memory_index = 0;
631   for (UINT32 row = 0; row < m_rows; row++)
632      for (UINT32 col = 0; col < m_cols; col++)
1171633      {
1172         *tmapptr = tmap->next;
1173         break;
634         tilemap_memory_index memindex = memory_index(col, row);
635         m_max_memory_index = MAX(m_max_memory_index, memindex);
1174636      }
637   m_max_memory_index++;
1175638
1176   /* free allocated memory */
1177   auto_free(tmap->machine(), tmap->pen_to_flags);
1178   auto_free(tmap->machine(), tmap->tileflags);
1179   auto_free(tmap->machine(), tmap->colscroll);
1180   auto_free(tmap->machine(), tmap->rowscroll);
1181   auto_free(tmap->machine(), tmap->logical_to_memory);
1182   auto_free(tmap->machine(), tmap->memory_to_logical);
1183   auto_free(tmap->machine(), tmap);
639   // allocate the necessary mappings
640   m_memory_to_logical = auto_alloc_array(machine(), logical_index, m_max_memory_index);
641   m_logical_to_memory = auto_alloc_array(machine(), tilemap_memory_index, m_max_logical_index);
642
643   // update the mappings
644   mappings_update();
1184645}
1185646
1186647
648//-------------------------------------------------
649//  mappings_update - update the mappings after
650//  a major change (flip x/y changes)
651//-------------------------------------------------
1187652
1188/***************************************************************************
1189    LOGICAL <-> MEMORY INDEX MAPPING
1190***************************************************************************/
1191
1192/*-------------------------------------------------
1193    mappings_create - allocate memory for the
1194    mapping tables and compute their extents
1195-------------------------------------------------*/
1196
1197static void mappings_create(tilemap_t *tmap)
653void tilemap_t::mappings_update()
1198654{
1199   UINT32 col, row;
655   // initialize all the mappings to invalid values
656   memset(m_memory_to_logical, 0xff, m_max_memory_index * sizeof(m_memory_to_logical[0]));
1200657
1201   /* compute the maximum logical index */
1202   tmap->max_logical_index = tmap->rows * tmap->cols;
658   // now iterate over all logical indexes and populate the memory index
659   for (logical_index logindex = 0; logindex < m_max_logical_index; logindex++)
660   {
661      UINT32 logical_col = logindex % m_cols;
662      UINT32 logical_row = logindex / m_cols;
663      tilemap_memory_index memindex = memory_index(logical_col, logical_row);
1203664
1204   /* compute the maximum memory index */
1205   tmap->max_memory_index = 0;
1206   for (row = 0; row < tmap->rows; row++)
1207      for (col = 0; col < tmap->cols; col++)
1208      {
1209         tilemap_memory_index memindex = (*tmap->mapper)(col, row, tmap->cols, tmap->rows);
1210         tmap->max_memory_index = MAX(tmap->max_memory_index, memindex);
1211      }
1212   tmap->max_memory_index++;
665      // apply tilemap flip to get the final location to store
666      if (m_attributes & TILEMAP_FLIPX)
667         logical_col = (m_cols - 1) - logical_col;
668      if (m_attributes & TILEMAP_FLIPY)
669         logical_row = (m_rows - 1) - logical_row;
670      UINT32 flipped_logindex = logical_row * m_cols + logical_col;
1213671
1214   /* allocate the necessary mappings */
1215   tmap->memory_to_logical = auto_alloc_array(tmap->machine(), tilemap_logical_index, tmap->max_memory_index);
1216   tmap->logical_to_memory = auto_alloc_array(tmap->machine(), tilemap_memory_index, tmap->max_logical_index);
672      // fill in entries in both arrays
673      m_memory_to_logical[memindex] = flipped_logindex;
674      m_logical_to_memory[flipped_logindex] = memindex;
675   }
1217676
1218   /* update the mappings */
1219   mappings_update(tmap);
677   // mark the whole tilemap dirty
678   mark_all_dirty();
1220679}
1221680
1222681
1223/*-------------------------------------------------
1224    mappings_update - update the mappings after
1225    a major change (flip x/y changes)
1226-------------------------------------------------*/
1227682
1228static void mappings_update(tilemap_t *tmap)
1229{
1230   tilemap_logical_index logindex;
1231   tilemap_memory_index memindex;
683//**************************************************************************
684//  TILE RENDERING
685//**************************************************************************
1232686
1233   /* initialize all the mappings to invalid values */
1234   for (memindex = 0; memindex < tmap->max_memory_index; memindex++)
1235      tmap->memory_to_logical[memindex] = -1;
1236
1237   /* now iterate over all logical indexes and populate the memory index */
1238   for (logindex = 0; logindex < tmap->max_logical_index; logindex++)
687inline void tilemap_t::realize_all_dirty_tiles()
688{
689   // if all the tiles are marked dirty, or something in the gfx has changed,
690   // flush the dirty status to all tiles
691   if (m_all_tiles_dirty || gfx_elements_changed())
1239692   {
1240      UINT32 logical_col = logindex % tmap->cols;
1241      UINT32 logical_row = logindex / tmap->cols;
1242      memindex = (*tmap->mapper)(logical_col, logical_row, tmap->cols, tmap->rows);
1243      UINT32 flipped_logindex;
1244
1245      /* apply tilemap flip to get the final location to store */
1246      if (tmap->attributes & TILEMAP_FLIPX)
1247         logical_col = (tmap->cols - 1) - logical_col;
1248      if (tmap->attributes & TILEMAP_FLIPY)
1249         logical_row = (tmap->rows - 1) - logical_row;
1250      flipped_logindex = logical_row * tmap->cols + logical_col;
1251
1252      /* fill in entries in both arrays */
1253      tmap->memory_to_logical[memindex] = flipped_logindex;
1254      tmap->logical_to_memory[flipped_logindex] = memindex;
693      memset(m_tileflags, TILE_FLAG_DIRTY, m_max_logical_index);
694      m_all_tiles_dirty = false;
695      m_gfx_used = 0;
1255696   }
1256
1257   /* mark the whole tilemap dirty */
1258   tilemap_mark_all_tiles_dirty(tmap);
1259697}
1260698
699//-------------------------------------------------
700//  pixmap_update - update the entire pixmap
701//-------------------------------------------------
1261702
1262
1263/***************************************************************************
1264    TILE RENDERING
1265***************************************************************************/
1266
1267/*-------------------------------------------------
1268    pixmap_update - update the entire pixmap
1269-------------------------------------------------*/
1270
1271static void pixmap_update(tilemap_t *tmap)
703void tilemap_t::pixmap_update()
1272704{
1273   int mincol, maxcol, minrow, maxrow;
1274   int row, col;
705   // if the graphics changed, we need to mark everything dirty
706   if (gfx_elements_changed())
707      mark_all_dirty();
1275708
1276   /* if the graphics changed, we need to mark everything dirty */
1277   if (gfx_elements_changed(tmap))
1278      tilemap_mark_all_tiles_dirty(tmap);
1279
1280   /* if everything is clean, do nothing */
1281   if (tmap->all_tiles_clean)
709   // if everything is clean, do nothing
710   if (m_all_tiles_clean)
1282711      return;
1283712
1284713g_profiler.start(PROFILER_TILEMAP_DRAW);
1285714
1286   /* compute which columns and rows to update */
1287   mincol = minrow = 0;
1288   maxcol = tmap->cols - 1;
1289   maxrow = tmap->rows - 1;
715   // flush the dirty state to all tiles as appropriate
716   realize_all_dirty_tiles();
1290717
1291   /* if the whole map is dirty, mark it as such */
1292   if (tmap->all_tiles_dirty)
1293   {
1294      memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
1295      tmap->all_tiles_dirty = FALSE;
1296      tmap->gfx_used = 0;
1297   }
718   // iterate over rows and columns
719   logical_index logindex = 0;
720   for (int row = 0; row < m_rows; row++)
721      for (int col = 0; col < m_cols; col++, logindex++)
722         if (m_tileflags[logindex] == TILE_FLAG_DIRTY)
723            tile_update(logindex, col, row);
1298724
1299   /* iterate over rows */
1300   for (row = minrow; row <= maxrow; row++)
1301   {
1302      tilemap_logical_index logindex = row * tmap->cols;
725   // mark it all clean
726   m_all_tiles_clean = true;
1303727
1304      /* iterate over colums */
1305      for (col = mincol; col <= maxcol; col++)
1306         if (tmap->tileflags[logindex + col] == TILE_FLAG_DIRTY)
1307            tile_update(tmap, logindex + col, col, row);
1308   }
1309
1310   /* mark it all clean */
1311   if (mincol == 0 && minrow == 0 && maxcol == tmap->cols - 1 && maxcol == tmap->rows - 1)
1312      tmap->all_tiles_clean = TRUE;
1313
1314728g_profiler.stop();
1315729}
1316730
1317731
1318/*-------------------------------------------------
1319    tile_update - update a single dirty tile
1320-------------------------------------------------*/
732//-------------------------------------------------
733//  tile_update - update a single dirty tile
734//-------------------------------------------------
1321735
1322static void tile_update(tilemap_t *tmap, tilemap_logical_index logindex, UINT32 col, UINT32 row)
736void tilemap_t::tile_update(logical_index logindex, UINT32 col, UINT32 row)
1323737{
1324   UINT32 x0 = tmap->tilewidth * col;
1325   UINT32 y0 = tmap->tileheight * row;
1326   tilemap_memory_index memindex;
1327   UINT32 flags;
1328
1329738g_profiler.start(PROFILER_TILEMAP_UPDATE);
1330739
1331   /* call the get info callback for the associated memory index */
1332   memindex = tmap->logical_to_memory[logindex];
1333   (*tmap->tile_get_info)(*(running_machine *)tmap->tile_get_info_object, &tmap->tileinfo, memindex, tmap->user_data);
740   // call the get info callback for the associated memory index
741   tilemap_memory_index memindex = m_logical_to_memory[logindex];
742   m_tile_get_info(&m_tileinfo, memindex, m_user_data);
1334743
1335   /* apply the global tilemap flip to the returned flip flags */
1336   flags = tmap->tileinfo.flags ^ (tmap->attributes & 0x03);
744   // apply the global tilemap flip to the returned flip flags
745   UINT32 flags = m_tileinfo.flags ^ (m_attributes & 0x03);
1337746
1338   /* draw the tile, using either direct or transparent */
1339   tmap->tileflags[logindex] = tile_draw(tmap, tmap->tileinfo.pen_data + tmap->pen_data_offset, x0, y0,
1340      tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags, tmap->tileinfo.pen_mask);
747   // draw the tile, using either direct or transparent
748   UINT32 x0 = m_tilewidth * col;
749   UINT32 y0 = m_tileheight * row;
750   m_tileflags[logindex] = tile_draw(m_tileinfo.pen_data + m_pen_data_offset, x0, y0,
751      m_tileinfo.palette_base, m_tileinfo.category, m_tileinfo.group, flags, m_tileinfo.pen_mask);
1341752
1342   /* if mask data is specified, apply it */
1343   if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && tmap->tileinfo.mask_data != NULL)
1344      tmap->tileflags[logindex] = tile_apply_bitmask(tmap, tmap->tileinfo.mask_data, x0, y0, tmap->tileinfo.category, flags);
753   // if mask data is specified, apply it
754   if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && m_tileinfo.mask_data != NULL)
755      m_tileflags[logindex] = tile_apply_bitmask(m_tileinfo.mask_data, x0, y0, m_tileinfo.category, flags);
1345756
1346   /* track which gfx have been used for this tilemap */
1347   if (tmap->tileinfo.gfxnum != 0xff && (tmap->gfx_used & (1 << tmap->tileinfo.gfxnum)) == 0)
757   // track which gfx have been used for this tilemap
758   if (m_tileinfo.gfxnum != 0xff && (m_gfx_used & (1 << m_tileinfo.gfxnum)) == 0)
1348759   {
1349      tmap->gfx_used |= 1 << tmap->tileinfo.gfxnum;
1350      tmap->gfx_dirtyseq[tmap->tileinfo.gfxnum] = tmap->machine().gfx[tmap->tileinfo.gfxnum]->dirtyseq;
760      m_gfx_used |= 1 << m_tileinfo.gfxnum;
761      m_gfx_dirtyseq[m_tileinfo.gfxnum] = machine().gfx[m_tileinfo.gfxnum]->dirtyseq;
1351762   }
1352763
1353764g_profiler.stop();
1354765}
1355766
1356767
1357/*-------------------------------------------------
1358    tile_draw - draw a single tile to the
1359    tilemap's internal pixmap, using the pen as
1360    the pen_to_flags lookup value, and adding
1361    the palette_base
1362-------------------------------------------------*/
768//-------------------------------------------------
769//  tile_draw - draw a single tile to the
770//  tilemap's internal pixmap, using the pen as
771//  the pen_to_flags lookup value, and adding
772//  the palette_base
773//-------------------------------------------------
1363774
1364static UINT8 tile_draw(tilemap_t *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags, UINT8 pen_mask)
775UINT8 tilemap_t::tile_draw(const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags, UINT8 pen_mask)
1365776{
1366   const UINT8 *penmap = tmap->pen_to_flags + group * MAX_PEN_TO_FLAGS;
1367   bitmap_ind8 &flagsmap = tmap->flagsmap;
1368   bitmap_ind16 &pixmap = tmap->pixmap;
1369   int height = tmap->tileheight;
1370   int width = tmap->tilewidth;
1371   UINT8 andmask = ~0, ormask = 0;
1372   int dx0 = 1, dy0 = 1;
1373   int tx, ty;
1374
1375   /* OR in the force layer flags */
777   // OR in the force layer flags
1376778   category |= flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2);
1377779
1378   /* if we're vertically flipped, point to the bottom row and work backwards */
780   // if we're vertically flipped, point to the bottom row and work backwards
781   int dy0 = 1;
1379782   if (flags & TILE_FLIPY)
1380783   {
1381      y0 += height - 1;
784      y0 += m_tileheight - 1;
1382785      dy0 = -1;
1383786   }
1384787
1385   /* if we're horizontally flipped, point to the rightmost column and work backwards */
788   // if we're horizontally flipped, point to the rightmost column and work backwards
789   int dx0 = 1;
1386790   if (flags & TILE_FLIPX)
1387791   {
1388      x0 += width - 1;
792      x0 += m_tilewidth - 1;
1389793      dx0 = -1;
1390794   }
1391795
1392   /* in 4bpp mode, we draw in groups of 2 pixels, so halve the width now */
796   // in 4bpp mode, we draw in groups of 2 pixels, so halve the width now
797   int width = m_tilewidth;
1393798   if (flags & TILE_4BPP)
1394799   {
1395800      assert(width % 2 == 0);
1396801      width /= 2;
1397802   }
1398803
1399   /* iterate over rows */
1400   for (ty = 0; ty < height; ty++)
804   // iterate over rows
805   const UINT8 *penmap = m_pen_to_flags + group * MAX_PEN_TO_FLAGS;
806   UINT8 andmask = ~0, ormask = 0;
807   for (int ty = 0; ty < m_tileheight; ty++)
1401808   {
1402      UINT16 *pixptr = &pixmap.pix16(y0, x0);
1403      UINT8 *flagsptr = &flagsmap.pix8(y0, x0);
1404      int xoffs = 0;
809      UINT16 *pixptr = &m_pixmap.pix16(y0, x0);
810      UINT8 *flagsptr = &m_flagsmap.pix8(y0, x0);
1405811
1406      /* pre-advance to the next row */
812      // pre-advance to the next row
1407813      y0 += dy0;
1408814
1409      /* 8bpp data */
815      // 8bpp data
1410816      if (!(flags & TILE_4BPP))
1411817      {
1412         for (tx = 0; tx < width; tx++)
818         for (int tx = 0, xoffs = 0; tx < width; tx++, xoffs += dx0)
1413819         {
1414820            UINT8 pen = (*pendata++) & pen_mask;
1415821            UINT8 map = penmap[pen];
r14063r14064
1417823            flagsptr[xoffs] = map | category;
1418824            andmask &= map;
1419825            ormask |= map;
1420            xoffs += dx0;
1421826         }
1422827      }
1423828
1424      /* 4bpp data */
829      // 4bpp data
1425830      else
1426831      {
1427         for (tx = 0; tx < width; tx++)
832         for (int tx = 0, xoffs = 0; tx < width; tx++)
1428833         {
1429834            UINT8 data = *pendata++;
1430835            UINT8 pen, map;
r14063r14064
1451856}
1452857
1453858
1454/*-------------------------------------------------
1455    tile_apply_bitmask - apply a bitmask to an
1456    already-rendered tile by modifying the
1457    flagsmap appropriately
1458-------------------------------------------------*/
859//-------------------------------------------------
860//  tile_apply_bitmask - apply a bitmask to an
861//  already-rendered tile by modifying the
862//  flagsmap appropriately
863//-------------------------------------------------
1459864
1460static UINT8 tile_apply_bitmask(tilemap_t *tmap, const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags)
865UINT8 tilemap_t::tile_apply_bitmask(const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags)
1461866{
1462   bitmap_ind8 &flagsmap = tmap->flagsmap;
1463   int height = tmap->tileheight;
1464   int width = tmap->tilewidth;
1465   UINT8 andmask = ~0, ormask = 0;
1466   int dx0 = 1, dy0 = 1;
1467   int bitoffs = 0;
1468   int tx, ty;
1469
1470   /* if we're vertically flipped, point to the bottom row and work backwards */
867   // if we're vertically flipped, point to the bottom row and work backwards
868   int dy0 = 1;
1471869   if (flags & TILE_FLIPY)
1472870   {
1473      y0 += height - 1;
871      y0 += m_tileheight - 1;
1474872      dy0 = -1;
1475873   }
1476874
1477   /* if we're horizontally flipped, point to the rightmost column and work backwards */
875   // if we're horizontally flipped, point to the rightmost column and work backwards
876   int dx0 = 1;
1478877   if (flags & TILE_FLIPX)
1479878   {
1480      x0 += width - 1;
879      x0 += m_tilewidth - 1;
1481880      dx0 = -1;
1482881   }
1483882
1484   /* iterate over rows */
1485   for (ty = 0; ty < height; ty++)
883   // iterate over rows
884   UINT8 andmask = ~0, ormask = 0;
885   int bitoffs = 0;
886   for (int ty = 0; ty < m_tileheight; ty++)
1486887   {
1487      UINT8 *flagsptr = &flagsmap.pix8(y0, x0);
1488      int xoffs = 0;
1489
1490      /* pre-advance to the next row */
888      // pre-advance to the next row
889      UINT8 *flagsptr = &m_flagsmap.pix8(y0, x0);
1491890      y0 += dy0;
1492891
1493      /* anywhere the bitmask is 0 should be transparent */
1494      for (tx = 0; tx < width; tx++)
892      // anywhere the bitmask is 0 should be transparent
893      for (int tx = 0, xoffs = 0; tx < m_tilewidth; tx++, xoffs += dx0)
1495894      {
1496895         UINT8 map = flagsptr[xoffs];
1497896
r14063r14064
1499898            map = flagsptr[xoffs] = TILEMAP_PIXEL_TRANSPARENT | category;
1500899         andmask &= map;
1501900         ormask |= map;
1502         xoffs += dx0;
1503901         bitoffs++;
1504902      }
1505903   }
r14063r14064
1508906
1509907
1510908
1511/***************************************************************************
1512    DRAWING HELPERS
1513***************************************************************************/
909//**************************************************************************
910//  DRAWING HELPERS
911//**************************************************************************
1514912
1515/*-------------------------------------------------
1516    configure_blit_parameters - fill in the
1517    standard blit parameters based on the input
1518    data; this code is shared by normal, roz,
1519    and indexed drawing code
1520-------------------------------------------------*/
913//-------------------------------------------------
914//  configure_blit_parameters - fill in the
915//  standard blit parameters based on the input
916//  data; this code is shared by normal, roz,
917//  and indexed drawing code
918//-------------------------------------------------
1521919
1522static void configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_format dest_format, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask)
920void tilemap_t::configure_blit_parameters(blit_parameters &blit, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1523921{
1524   /* start with nothing */
1525   memset(blit, 0, sizeof(*blit));
922   // set the target bitmap
923   blit.cliprect = cliprect;
1526924
1527   /* set the target bitmap */
1528   blit->cliprect = cliprect;
925   // set the priority code and alpha
926   blit.tilemap_priority_code = priority | (priority_mask << 8) | (m_palette_offset << 16);
927   blit.alpha = (flags & TILEMAP_DRAW_ALPHA_FLAG) ? (flags >> 24) : 0xff;
1529928
1530   /* set the priority code and alpha */
1531   blit->tilemap_priority_code = priority | (priority_mask << 8) | (tmap->palette_offset << 16);
1532   blit->alpha = (flags & TILEMAP_DRAW_ALPHA_FLAG) ? (flags >> 24) : 0xff;
929   // tile priority; unless otherwise specified, draw anything in layer 0
930   blit.mask = TILEMAP_PIXEL_CATEGORY_MASK;
931   blit.value = flags & TILEMAP_PIXEL_CATEGORY_MASK;
1533932
1534   /* tile priority; unless otherwise specified, draw anything in layer 0 */
1535   blit->mask = TILEMAP_PIXEL_CATEGORY_MASK;
1536   blit->value   = flags & TILEMAP_PIXEL_CATEGORY_MASK;
1537
1538   /* if no layers specified, draw layer 0 */
933   // if no layers specified, draw layer 0
1539934   if ((flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2)) == 0)
1540935      flags |= TILEMAP_DRAW_LAYER0;
1541936
1542   /* OR in the bits from the draw masks */
1543   blit->mask |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2);
1544   blit->value |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2);
937   // OR in the bits from the draw masks
938   blit.mask |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2);
939   blit.value |= flags & (TILEMAP_DRAW_LAYER0 | TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_LAYER2);
1545940
1546   /* for all-opaque rendering, don't check any of the layer bits */
941   // for all-opaque rendering, don't check any of the layer bits
1547942   if (flags & TILEMAP_DRAW_OPAQUE)
1548943   {
1549      blit->mask &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2);
1550      blit->value &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2);
944      blit.mask &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2);
945      blit.value &= ~(TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1 | TILEMAP_PIXEL_LAYER2);
1551946   }
1552947
1553   /* don't check category if requested */
948   // don't check category if requested
1554949   if (flags & TILEMAP_DRAW_ALL_CATEGORIES)
1555950   {
1556      blit->mask &= ~TILEMAP_PIXEL_CATEGORY_MASK;
1557      blit->value &= ~TILEMAP_PIXEL_CATEGORY_MASK;
951      blit.mask &= ~TILEMAP_PIXEL_CATEGORY_MASK;
952      blit.value &= ~TILEMAP_PIXEL_CATEGORY_MASK;
1558953   }
1559954}
1560955
1561956
1562/*-------------------------------------------------
1563    tilemap_draw_instance - draw a single
1564    instance of the tilemap to the internal
1565    pixmap at the given xpos,ypos
1566-------------------------------------------------*/
957//-------------------------------------------------
958//  draw_common - draw a tilemap to the
959//  destination with clipping; pixels apply
960//  priority/priority_mask to the priority bitmap
961//-------------------------------------------------
1567962
1568963template<class _BitmapClass>
1569static void tilemap_draw_instance(_BitmapClass &dest, tilemap_t *tmap, const blit_parameters *blit, int xpos, int ypos)
964void tilemap_t::draw_common(_BitmapClass &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1570965{
1571   bitmap_ind8 &priority_bitmap = tmap->machine().priority_bitmap;
1572   const UINT16 *source_baseaddr;
1573   const UINT8 *mask_baseaddr;
1574   typename _BitmapClass::pixel_t *dest_baseaddr = NULL;
1575   UINT8 *priority_baseaddr;
1576   int dest_rowpixels = 0;
1577   int mincol, maxcol;
1578   int x1, y1, x2, y2;
1579   int y, nexty;
966   // skip if disabled
967   if (!m_enable)
968      return;
1580969
1581   /* clip destination coordinates to the tilemap */
1582   /* note that x2/y2 are exclusive, not inclusive */
1583   x1 = MAX(xpos, blit->cliprect.min_x);
1584   x2 = MIN(xpos + (int)tmap->width, blit->cliprect.max_x + 1);
1585   y1 = MAX(ypos, blit->cliprect.min_y);
1586   y2 = MIN(ypos + (int)tmap->height, blit->cliprect.max_y + 1);
970g_profiler.start(PROFILER_TILEMAP_DRAW);
971   // configure the blit parameters based on the input parameters
972   blit_parameters blit;
973   configure_blit_parameters(blit, cliprect, flags, priority, priority_mask);
1587974
1588   /* if totally clipped, stop here */
975   // flush the dirty state to all tiles as appropriate
976   realize_all_dirty_tiles();
977
978   UINT32 width  = machine().primary_screen->width();
979   UINT32 height = machine().primary_screen->height();
980
981   // XY scrolling playfield
982   if (m_scrollrows == 1 && m_scrollcols == 1)
983   {
984      // iterate to handle wraparound
985      int scrollx = effective_rowscroll(0, width);
986      int scrolly = effective_colscroll(0, height);
987      for (int ypos = scrolly - m_height; ypos <= blit.cliprect.max_y; ypos += m_height)
988         for (int xpos = scrollx - m_width; xpos <= blit.cliprect.max_x; xpos += m_width)
989            draw_instance(dest, blit, xpos, ypos);
990   }
991
992   // scrolling rows + vertical scroll
993   else if (m_scrollcols == 1)
994   {
995      const rectangle original_cliprect = blit.cliprect;
996
997      // iterate over Y to handle wraparound
998      int rowheight = m_height / m_scrollrows;
999      int scrolly = effective_colscroll(0, height);
1000      for (int ypos = scrolly - m_height; ypos <= original_cliprect.max_y; ypos += m_height)
1001      {
1002         int const firstrow = MAX((original_cliprect.min_y - ypos) / rowheight, 0);
1003         int const lastrow =  MIN((original_cliprect.max_y - ypos) / rowheight, m_scrollrows - 1);
1004
1005         // iterate over rows in the tilemap
1006         int nextrow;
1007         for (int currow = firstrow; currow <= lastrow; currow = nextrow)
1008         {
1009            // scan forward until we find a non-matching row
1010            int scrollx = effective_rowscroll(currow, width);
1011            for (nextrow = currow + 1; nextrow <= lastrow; nextrow++)
1012               if (effective_rowscroll(nextrow, width) != scrollx)
1013                  break;
1014
1015            // skip if disabled
1016            if (scrollx == TILE_LINE_DISABLED)
1017               continue;
1018
1019            // update the cliprect just for this set of rows
1020            blit.cliprect.min_y = currow * rowheight + ypos;
1021            blit.cliprect.max_y = nextrow * rowheight - 1 + ypos;
1022            blit.cliprect &= original_cliprect;
1023
1024            // iterate over X to handle wraparound
1025            for (int xpos = scrollx - m_width; xpos <= original_cliprect.max_x; xpos += m_width)
1026               draw_instance(dest, blit, xpos, ypos);
1027         }
1028      }
1029   }
1030
1031   // scrolling columns + horizontal scroll
1032   else if (m_scrollrows == 1)
1033   {
1034      const rectangle original_cliprect = blit.cliprect;
1035
1036      // iterate over columns in the tilemap
1037      int scrollx = effective_rowscroll(0, width);
1038      int colwidth = m_width / m_scrollcols;
1039      int nextcol;
1040      for (int curcol = 0; curcol < m_scrollcols; curcol = nextcol)
1041      {
1042         // scan forward until we find a non-matching column
1043         int scrolly   = effective_colscroll(curcol, height);
1044         for (nextcol = curcol + 1; nextcol < m_scrollcols; nextcol++)
1045            if (effective_colscroll(nextcol, height) != scrolly)
1046               break;
1047
1048         // skip if disabled
1049         if (scrolly == TILE_LINE_DISABLED)
1050            continue;
1051
1052         // iterate over X to handle wraparound
1053         for (int xpos = scrollx - m_width; xpos <= original_cliprect.max_x; xpos += m_width)
1054         {
1055            // update the cliprect just for this set of columns
1056            blit.cliprect.min_x = curcol * colwidth + xpos;
1057            blit.cliprect.max_x = nextcol * colwidth - 1 + xpos;
1058            blit.cliprect &= original_cliprect;
1059
1060            // iterate over Y to handle wraparound
1061            for (int ypos = scrolly - m_height; ypos <= original_cliprect.max_y; ypos += m_height)
1062               draw_instance(dest, blit, xpos, ypos);
1063         }
1064      }
1065   }
1066g_profiler.stop();
1067}
1068
1069void tilemap_t::draw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1070{ draw_common(dest, cliprect, flags, priority, priority_mask); }
1071
1072void tilemap_t::draw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1073{ draw_common(dest, cliprect, flags, priority, priority_mask); }
1074
1075
1076//-------------------------------------------------
1077//  draw_roz - draw a tilemap to the destination
1078//  with clipping and arbitrary rotate/zoom; pixels
1079//  apply priority/priority_mask to the priority
1080//  bitmap
1081//-------------------------------------------------
1082
1083template<class _BitmapClass>
1084void tilemap_t::draw_roz_common(_BitmapClass &dest, const rectangle &cliprect,
1085      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
1086      bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1087{
1088// notes:
1089// - startx and starty MUST be UINT32 for calculations to work correctly
1090// - srcbim_width and height are assumed to be a power of 2 to speed up wraparound
1091
1092   // skip if disabled
1093   if (!m_enable)
1094      return;
1095
1096   // see if this is just a regular render and if so, do a regular render
1097   if (incxx == (1 << 16) && incxy == 0 && incyx == 0 && incyy == (1 << 16) && wraparound)
1098   {
1099      set_scrollx(0, startx >> 16);
1100      set_scrolly(0, starty >> 16);
1101      draw(dest, cliprect, flags, priority, priority_mask);
1102      return;
1103   }
1104
1105g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ);
1106   // configure the blit parameters
1107   blit_parameters blit;
1108   configure_blit_parameters(blit, cliprect, flags, priority, priority_mask);
1109
1110   // get the full pixmap for the tilemap
1111   pixmap();
1112
1113   // then do the roz copy
1114   draw_roz_core(dest, blit, startx, starty, incxx, incxy, incyx, incyy, wraparound);
1115g_profiler.stop();
1116}
1117
1118void tilemap_t::draw_roz(bitmap_ind16 &dest, const rectangle &cliprect,
1119      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
1120      bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1121{ draw_roz_common(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); }
1122
1123void tilemap_t::draw_roz(bitmap_rgb32 &dest, const rectangle &cliprect,
1124      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
1125      bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
1126{ draw_roz_common(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); }
1127
1128
1129//-------------------------------------------------
1130//  draw_instance - draw a single instance of the
1131//  tilemap to the internal pixmap at the given
1132//  xpos,ypos
1133//-------------------------------------------------
1134
1135template<class _BitmapClass>
1136void tilemap_t::draw_instance(_BitmapClass &dest, const blit_parameters &blit, int xpos, int ypos)
1137{
1138   // clip destination coordinates to the tilemap
1139   // note that x2/y2 are exclusive, not inclusive
1140   int x1 = MAX(xpos, blit.cliprect.min_x);
1141   int x2 = MIN(xpos + (int)m_width, blit.cliprect.max_x + 1);
1142   int y1 = MAX(ypos, blit.cliprect.min_y);
1143   int y2 = MIN(ypos + (int)m_height, blit.cliprect.max_y + 1);
1144
1145   // if totally clipped, stop here
15891146   if (x1 >= x2 || y1 >= y2)
15901147      return;
15911148
1592   /* look up priority and destination base addresses for y1 */
1593   priority_baseaddr = &priority_bitmap.pix8(y1, xpos);
1149   // look up priority and destination base addresses for y1
1150   bitmap_ind8 &priority_bitmap = machine().priority_bitmap;
1151   UINT8 *priority_baseaddr = &priority_bitmap.pix8(y1, xpos);
1152   typename _BitmapClass::pixel_t *dest_baseaddr = NULL;
1153   int dest_rowpixels = 0;
15941154   if (dest.valid())
15951155   {
15961156      dest_rowpixels = dest.rowpixels();
15971157      dest_baseaddr = &dest.pix(y1, xpos);
15981158   }
15991159
1600   /* convert screen coordinates to source tilemap coordinates */
1160   // convert screen coordinates to source tilemap coordinates
16011161   x1 -= xpos;
16021162   y1 -= ypos;
16031163   x2 -= xpos;
16041164   y2 -= ypos;
16051165
1606   /* get tilemap pixels */
1607   source_baseaddr = &tmap->pixmap.pix16(y1);
1608   mask_baseaddr = &tmap->flagsmap.pix8(y1);
1166   // get tilemap pixels
1167   const UINT16 *source_baseaddr = &m_pixmap.pix16(y1);
1168   const UINT8 *mask_baseaddr = &m_flagsmap.pix8(y1);
16091169
1610   /* get start/stop columns, rounding outward */
1611   mincol = x1 / tmap->tilewidth;
1612   maxcol = (x2 + tmap->tilewidth - 1) / tmap->tilewidth;
1170   // get start/stop columns, rounding outward
1171   int mincol = x1 / m_tilewidth;
1172   int maxcol = (x2 + m_tilewidth - 1) / m_tilewidth;
16131173
1614   /* set up row counter */
1615   y = y1;
1616   nexty = tmap->tileheight * (y1 / tmap->tileheight) + tmap->tileheight;
1174   // set up row counter
1175   int y = y1;
1176   int nexty = m_tileheight * (y1 / m_tileheight) + m_tileheight;
16171177   nexty = MIN(nexty, y2);
16181178
1619   /* loop over tilemap rows */
1179   // loop over tilemap rows
16201180   for (;;)
16211181   {
1622      int row = y / tmap->tileheight;
1623      trans_t prev_trans = WHOLLY_TRANSPARENT;
1624      trans_t cur_trans;
1182      int row = y / m_tileheight;
16251183      int x_start = x1;
1626      int column;
16271184
1628      /* iterate across the applicable tilemap columns */
1629      for (column = mincol; column <= maxcol; column++)
1185      // iterate across the applicable tilemap columns
1186      trans_t prev_trans = WHOLLY_TRANSPARENT;
1187      trans_t cur_trans;
1188      for (int column = mincol; column <= maxcol; column++)
16301189      {
16311190         int x_end;
16321191
1633         /* we don't actually render the last column; it is always just used for flushing */
1192         // we don't actually render the last column; it is always just used for flushing
16341193         if (column == maxcol)
16351194            cur_trans = WHOLLY_TRANSPARENT;
16361195
1637         /* for other columns we look up the transparency information */
1196         // for other columns we look up the transparency information
16381197         else
16391198         {
1640            tilemap_logical_index logindex = row * tmap->cols + column;
1199            logical_index logindex = row * m_cols + column;
16411200
1642            /* if the current tile is dirty, fix it */
1643            if (tmap->tileflags[logindex] == TILE_FLAG_DIRTY)
1644               tile_update(tmap, logindex, column, row);
1201            // if the current tile is dirty, fix it
1202            if (m_tileflags[logindex] == TILE_FLAG_DIRTY)
1203               tile_update(logindex, column, row);
16451204
1646            /* if the current summary data is non-zero, we must draw masked */
1647            if ((tmap->tileflags[logindex] & blit->mask) != 0)
1205            // if the current summary data is non-zero, we must draw masked
1206            if ((m_tileflags[logindex] & blit.mask) != 0)
16481207               cur_trans = MASKED;
16491208
1650            /* otherwise, our transparency state is constant across the tile; fetch it */
1209            // otherwise, our transparency state is constant across the tile; fetch it
16511210            else
1652               cur_trans = ((mask_baseaddr[column * tmap->tilewidth] & blit->mask) == blit->value) ? WHOLLY_OPAQUE : WHOLLY_TRANSPARENT;
1211               cur_trans = ((mask_baseaddr[column * m_tilewidth] & blit.mask) == blit.value) ? WHOLLY_OPAQUE : WHOLLY_TRANSPARENT;
16531212         }
16541213
1655         /* if the transparency state is the same as last time, don't render yet */
1214         // if the transparency state is the same as last time, don't render yet
16561215         if (cur_trans == prev_trans)
16571216            continue;
16581217
1659         /* compute the end of this run, in pixels */
1660         x_end = column * tmap->tilewidth;
1218         // compute the end of this run, in pixels
1219         x_end = column * m_tilewidth;
16611220         x_end = MAX(x_end, x1);
16621221         x_end = MIN(x_end, x2);
16631222
1664         /* if we're rendering something, compute the pointers */
1223         // if we're rendering something, compute the pointers
16651224         if (prev_trans != WHOLLY_TRANSPARENT)
16661225         {
16671226            const UINT16 *source0 = source_baseaddr + x_start;
16681227            typename _BitmapClass::pixel_t *dest0 = dest_baseaddr + x_start;
16691228            UINT8 *pmap0 = priority_baseaddr + x_start;
1670            int cury;
16711229
1672            /* if we were opaque, use the opaque renderer */
1230            // if we were opaque, use the opaque renderer
16731231            if (prev_trans == WHOLLY_OPAQUE)
16741232            {
1675               for (cury = y; cury < nexty; cury++)
1233               for (int cury = y; cury < nexty; cury++)
16761234               {
16771235                  if (dest_baseaddr == NULL)
1678                     scanline_draw_opaque_null(x_end - x_start, pmap0, blit->tilemap_priority_code);
1236                     scanline_draw_opaque_null(x_end - x_start, pmap0, blit.tilemap_priority_code);
16791237                  else if (sizeof(*dest0) == 2)
1680                     scanline_draw_opaque_ind16(reinterpret_cast<UINT16 *>(dest0), source0, x_end - x_start, pmap0, blit->tilemap_priority_code);
1681                  else if (sizeof(*dest0) == 4 && blit->alpha >= 0xff)
1682                     scanline_draw_opaque_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, tmap->machine().pens, pmap0, blit->tilemap_priority_code);
1238                     scanline_draw_opaque_ind16(reinterpret_cast<UINT16 *>(dest0), source0, x_end - x_start, pmap0, blit.tilemap_priority_code);
1239                  else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff)
1240                     scanline_draw_opaque_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code);
16831241                  else if (sizeof(*dest0) == 4)
1684                     scanline_draw_opaque_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, tmap->machine().pens, pmap0, blit->tilemap_priority_code, blit->alpha);
1242                     scanline_draw_opaque_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code, blit.alpha);
16851243
16861244                  dest0 += dest_rowpixels;
1687                  source0 += tmap->pixmap.rowpixels();
1245                  source0 += m_pixmap.rowpixels();
16881246                  pmap0 += priority_bitmap.rowpixels();
16891247               }
16901248            }
16911249
1692            /* otherwise use the masked renderer */
1250            // otherwise use the masked renderer
16931251            else
16941252            {
16951253               const UINT8 *mask0 = mask_baseaddr + x_start;
1696               for (cury = y; cury < nexty; cury++)
1254               for (int cury = y; cury < nexty; cury++)
16971255               {
16981256                  if (dest_baseaddr == NULL)
1699                     scanline_draw_masked_null(mask0, blit->mask, blit->value, x_end - x_start, pmap0, blit->tilemap_priority_code);
1257                     scanline_draw_masked_null(mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code);
17001258                  else if (sizeof(*dest0) == 2)
1701                     scanline_draw_masked_ind16(reinterpret_cast<UINT16 *>(dest0), source0, mask0, blit->mask, blit->value, x_end - x_start, pmap0, blit->tilemap_priority_code);
1702                  else if (sizeof(*dest0) == 4 && blit->alpha >= 0xff)
1703                     scanline_draw_masked_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine().pens, pmap0, blit->tilemap_priority_code);
1259                     scanline_draw_masked_ind16(reinterpret_cast<UINT16 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code);
1260                  else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff)
1261                     scanline_draw_masked_rgb32(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code);
17041262                  else if (sizeof(*dest0) == 4)
1705                     scanline_draw_masked_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine().pens, pmap0, blit->tilemap_priority_code, blit->alpha);
1263                     scanline_draw_masked_rgb32_alpha(reinterpret_cast<UINT32 *>(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, machine().pens, pmap0, blit.tilemap_priority_code, blit.alpha);
17061264
17071265                  dest0 += dest_rowpixels;
1708                  source0 += tmap->pixmap.rowpixels();
1709                  mask0 += tmap->flagsmap.rowpixels();
1266                  source0 += m_pixmap.rowpixels();
1267                  mask0 += m_flagsmap.rowpixels();
17101268                  pmap0 += priority_bitmap.rowpixels();
17111269               }
17121270            }
17131271         }
17141272
1715         /* the new start is the end */
1273         // the new start is the end
17161274         x_start = x_end;
17171275         prev_trans = cur_trans;
17181276      }
17191277
1720      /* if this was the last row, stop */
1278      // if this was the last row, stop
17211279      if (nexty == y2)
17221280         break;
17231281
1724      /* advance to the next row on all our bitmaps */
1282      // advance to the next row on all our bitmaps
17251283      priority_baseaddr += priority_bitmap.rowpixels() * (nexty - y);
1726      source_baseaddr += tmap->pixmap.rowpixels() * (nexty - y);
1727      mask_baseaddr += tmap->flagsmap.rowpixels() * (nexty - y);
1284      source_baseaddr += m_pixmap.rowpixels() * (nexty - y);
1285      mask_baseaddr += m_flagsmap.rowpixels() * (nexty - y);
17281286      dest_baseaddr += dest_rowpixels * (nexty - y);
17291287
1730      /* increment the Y counter */
1288      // increment the Y counter
17311289      y = nexty;
1732      nexty += tmap->tileheight;
1290      nexty += m_tileheight;
17331291      nexty = MIN(nexty, y2);
17341292   }
17351293}
17361294
17371295
1738/*-------------------------------------------------
1739    tilemap_draw_roz_core - render the tilemap's
1740    pixmap to the destination with rotation
1741    and zoom
1742-------------------------------------------------*/
1296//-------------------------------------------------
1297//  tilemap_draw_roz_core - render the tilemap's
1298//  pixmap to the destination with rotation
1299//  and zoom
1300//-------------------------------------------------
17431301
17441302#define ROZ_PLOT_PIXEL(INPUT_VAL)                                 \
17451303do {                                                      \
r14063r14064
17521310} while (0)
17531311
17541312template<class _BitmapClass>
1755static void tilemap_draw_roz_core(_BitmapClass &destbitmap, tilemap_t *tmap, const blit_parameters *blit,
1756      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound)
1313void tilemap_t::draw_roz_core(_BitmapClass &destbitmap, const blit_parameters &blit,
1314      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound)
17571315{
1758   const pen_t *clut = &tmap->machine().pens[blit->tilemap_priority_code >> 16];
1759   bitmap_ind8 &priority_bitmap = tmap->machine().priority_bitmap;
1760   bitmap_ind16 &srcbitmap = tmap->pixmap;
1761   bitmap_ind8 &flagsmap = tmap->flagsmap;
1762   const int xmask = srcbitmap.width()-1;
1763   const int ymask = srcbitmap.height()-1;
1764   const int widthshifted = srcbitmap.width() << 16;
1765   const int heightshifted = srcbitmap.height() << 16;
1766   UINT32 priority = blit->tilemap_priority_code;
1767   UINT8 mask = blit->mask;
1768   UINT8 value = blit->value;
1769   UINT8 alpha = blit->alpha;
1770   UINT32 cx;
1771   UINT32 cy;
1772   int x;
1773   int sx;
1774   int sy;
1775   int ex;
1776   int ey;
1777   typename _BitmapClass::pixel_t *dest;
1778   UINT8 *pri;
1779   const UINT16 *src;
1780   const UINT8 *maskptr;
1316   // pre-cache all the inner loop values
1317   const pen_t *clut = &machine().pens[blit.tilemap_priority_code >> 16];
1318   bitmap_ind8 &priority_bitmap = machine().priority_bitmap;
1319   const int xmask = m_pixmap.width() - 1;
1320   const int ymask = m_pixmap.height() - 1;
1321   const int widthshifted = m_pixmap.width() << 16;
1322   const int heightshifted = m_pixmap.height() << 16;
1323   UINT32 priority = blit.tilemap_priority_code;
1324   UINT8 mask = blit.mask;
1325   UINT8 value = blit.value;
1326   UINT8 alpha = blit.alpha;
17811327
1782   /* pre-advance based on the cliprect */
1783   startx += blit->cliprect.min_x * incxx + blit->cliprect.min_y * incyx;
1784   starty += blit->cliprect.min_x * incxy + blit->cliprect.min_y * incyy;
1328   // pre-advance based on the cliprect
1329   startx += blit.cliprect.min_x * incxx + blit.cliprect.min_y * incyx;
1330   starty += blit.cliprect.min_x * incxy + blit.cliprect.min_y * incyy;
17851331
1786   /* extract start/end points */
1787   sx = blit->cliprect.min_x;
1788   sy = blit->cliprect.min_y;
1789   ex = blit->cliprect.max_x;
1790   ey = blit->cliprect.max_y;
1332   // extract start/end points
1333   int sx = blit.cliprect.min_x;
1334   int sy = blit.cliprect.min_y;
1335   int ex = blit.cliprect.max_x;
1336   int ey = blit.cliprect.max_y;
17911337
1792   /* optimized loop for the not rotated case */
1338   // optimized loop for the not rotated case
17931339   if (incxy == 0 && incyx == 0 && !wraparound)
17941340   {
1795      /* skip without drawing until we are within the bitmap */
1341      // skip without drawing until we are within the bitmap
17961342      while (startx >= widthshifted && sx <= ex)
17971343      {
17981344         startx += incxx;
17991345         sx++;
18001346      }
18011347
1802      /* early exit if we're done already */
1348      // early exit if we're done already
18031349      if (sx > ex)
18041350         return;
18051351
1806      /* loop over rows */
1352      // loop over rows
18071353      while (sy <= ey)
18081354      {
1809         /* only draw if Y is within range */
1355         // only draw if Y is within range
18101356         if (starty < heightshifted)
18111357         {
1812            /* initialize X counters */
1813            x = sx;
1814            cx = startx;
1815            cy = starty >> 16;
1358            // initialize X counters
1359            int x = sx;
1360            UINT32 cx = startx;
1361            UINT32 cy = starty >> 16;
18161362
1817            /* get source and priority pointers */
1818            pri = &priority_bitmap.pix8(sy, sx);
1819            src = &srcbitmap.pix16(cy);
1820            maskptr = &flagsmap.pix8(cy);
1821            dest = &destbitmap.pix(sy, sx);
1363            // get source and priority pointers
1364            UINT8 *pri = &priority_bitmap.pix8(sy, sx);
1365            const UINT16 *src = &m_pixmap.pix16(cy);
1366            const UINT8 *maskptr = &m_flagsmap.pix8(cy);
1367            typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
18221368
1823            /* loop over columns */
1369            // loop over columns
18241370            while (x <= ex && cx < widthshifted)
18251371            {
1826               /* plot if we match the mask */
1372               // plot if we match the mask
18271373               if ((maskptr[cx >> 16] & mask) == value)
18281374               {
18291375                  ROZ_PLOT_PIXEL(src[cx >> 16]);
18301376                  *pri = (*pri & (priority >> 8)) | priority;
18311377               }
18321378
1833               /* advance in X */
1379               // advance in X
18341380               cx += incxx;
18351381               x++;
18361382               dest++;
r14063r14064
18381384            }
18391385         }
18401386
1841         /* advance in Y */
1387         // advance in Y
18421388         starty += incyy;
18431389         sy++;
18441390      }
18451391   }
18461392
1847   /* wraparound case */
1393   // wraparound case
18481394   else if (wraparound)
18491395   {
1850      /* loop over rows */
1396      // loop over rows
18511397      while (sy <= ey)
18521398      {
1853         /* initialize X counters */
1854         x = sx;
1855         cx = startx;
1856         cy = starty;
1399         // initialize X counters
1400         int x = sx;
1401         UINT32 cx = startx;
1402         UINT32 cy = starty;
18571403
1858         /* get dest and priority pointers */
1859         dest = &destbitmap.pix(sy, sx);
1860         pri = &priority_bitmap.pix8(sy, sx);
1404         // get dest and priority pointers
1405         typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
1406         UINT8 *pri = &priority_bitmap.pix8(sy, sx);
18611407
1862         /* loop over columns */
1408         // loop over columns
18631409         while (x <= ex)
18641410         {
1865            /* plot if we match the mask */
1866            if ((flagsmap.pix8((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value)
1411            // plot if we match the mask
1412            if ((m_flagsmap.pix8((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value)
18671413            {
1868               ROZ_PLOT_PIXEL(srcbitmap.pix16((cy >> 16) & ymask, (cx >> 16) & xmask));
1414               ROZ_PLOT_PIXEL(m_pixmap.pix16((cy >> 16) & ymask, (cx >> 16) & xmask));
18691415               *pri = (*pri & (priority >> 8)) | priority;
18701416            }
18711417
1872            /* advance in X */
1418            // advance in X
18731419            cx += incxx;
18741420            cy += incxy;
18751421            x++;
r14063r14064
18771423            pri++;
18781424         }
18791425
1880         /* advance in Y */
1426         // advance in Y
18811427         startx += incyx;
18821428         starty += incyy;
18831429         sy++;
18841430      }
18851431   }
18861432
1887   /* non-wraparound case */
1433   // non-wraparound case
18881434   else
18891435   {
1890      /* loop over rows */
1436      // loop over rows
18911437      while (sy <= ey)
18921438      {
1893         /* initialize X counters */
1894         x = sx;
1895         cx = startx;
1896         cy = starty;
1439         // initialize X counters
1440         int x = sx;
1441         UINT32 cx = startx;
1442         UINT32 cy = starty;
18971443
1898         /* get dest and priority pointers */
1899         dest = &destbitmap.pix(sy, sx);
1900         pri = &priority_bitmap.pix8(sy, sx);
1444         // get dest and priority pointers
1445         typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
1446         UINT8 *pri = &priority_bitmap.pix8(sy, sx);
19011447
1902         /* loop over columns */
1448         // loop over columns
19031449         while (x <= ex)
19041450         {
1905            /* plot if we're within the bitmap and we match the mask */
1451            // plot if we're within the bitmap and we match the mask
19061452            if (cx < widthshifted && cy < heightshifted)
1907               if ((flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value)
1453               if ((m_flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value)
19081454               {
1909                  ROZ_PLOT_PIXEL(srcbitmap.pix16(cy >> 16, cx >> 16));
1455                  ROZ_PLOT_PIXEL(m_pixmap.pix16(cy >> 16, cx >> 16));
19101456                  *pri = (*pri & (priority >> 8)) | priority;
19111457               }
19121458
1913            /* advance in X */
1459            // advance in X
19141460            cx += incxx;
19151461            cy += incxy;
19161462            x++;
r14063r14064
19181464            pri++;
19191465         }
19201466
1921         /* advance in Y */
1467         // advance in Y
19221468         startx += incyx;
19231469         starty += incyy;
19241470         sy++;
r14063r14064
19271473}
19281474
19291475
1930/***************************************************************************
1931    SCANLINE RASTERIZERS
1932***************************************************************************/
1476//-------------------------------------------------
1477//  draw_debug - draw a debug version without any
1478//  rowscroll and with fixed parameters
1479//-------------------------------------------------
19331480
1934/*-------------------------------------------------
1935    scanline_draw_opaque_null - draw to a NULL
1936    bitmap, setting priority only
1937-------------------------------------------------*/
1938
1939inline void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode)
1481void tilemap_t::draw_debug(bitmap_rgb32 &dest, UINT32 scrollx, UINT32 scrolly)
19401482{
1941   int i;
1483   // set up for the blit, using hard-coded parameters (no priority, etc)
1484   blit_parameters blit;
1485   configure_blit_parameters(blit, dest.cliprect(), TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0, 0xff);
19421486
1943   /* skip entirely if not changing priority */
1944   if (pcode != 0xff00)
1945   {
1946      for (i = 0; i < count; i++)
1947         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
1948   }
1949}
1487   // compute the effective scroll positions
1488   scrollx = m_width  - scrollx % m_width;
1489   scrolly = m_height - scrolly % m_height;
19501490
1491   // flush the dirty state to all tiles as appropriate
1492   realize_all_dirty_tiles();
19511493
1952/*-------------------------------------------------
1953    scanline_draw_masked_null - draw to a NULL
1954    bitmap using a mask, setting priority only
1955-------------------------------------------------*/
1956
1957inline void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
1958{
1959   int i;
1960
1961   /* skip entirely if not changing priority */
1962   if (pcode != 0xff00)
1963   {
1964      for (i = 0; i < count; i++)
1965         if ((maskptr[i] & mask) == value)
1966            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
1967   }
1494   // iterate to handle wraparound
1495   for (int ypos = scrolly - m_height; ypos <= blit.cliprect.max_y; ypos += m_height)
1496      for (int xpos = scrollx - m_width; xpos <= blit.cliprect.max_x; xpos += m_width)
1497         draw_instance(dest, blit, xpos, ypos);
19681498}
19691499
19701500
19711501
1972/*-------------------------------------------------
1973    scanline_draw_opaque_ind16 - draw to a 16bpp
1974    indexed bitmap
1975-------------------------------------------------*/
1502//**************************************************************************
1503//  TILEMAP MANAGER
1504//**************************************************************************
19761505
1977inline void scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode)
1978{
1979   int pal = pcode >> 16;
1980   int i;
1506//-------------------------------------------------
1507//  tilemap_manager - constructor
1508//-------------------------------------------------
19811509
1982   /* special case for no palette offset */
1983   if (pal == 0)
1984   {
1985      memcpy(dest, source, count * 2);
1986
1987      /* priority if necessary */
1988      if (pcode != 0xff00)
1989      {
1990         for (i = 0; i < count; i++)
1991            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
1992      }
1993   }
1994
1995   /* priority case */
1996   else if ((pcode & 0xffff) != 0xff00)
1997   {
1998      for (i = 0; i < count; i++)
1999      {
2000         dest[i] = source[i] + pal;
2001         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
2002      }
2003   }
2004
2005   /* no priority case */
2006   else
2007   {
2008      for (i = 0; i < count; i++)
2009         dest[i] = source[i] + pal;
2010   }
2011}
2012
2013
2014/*-------------------------------------------------
2015    scanline_draw_masked_ind16 - draw to a 16bpp
2016    indexed bitmap using a mask
2017-------------------------------------------------*/
2018
2019inline void scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
1510tilemap_manager::tilemap_manager(running_machine &machine)
1511   : m_machine(machine),
1512     m_instance(0)
20201513{
2021   int pal = pcode >> 16;
2022   int i;
2023
2024   /* priority case */
2025   if ((pcode & 0xffff) != 0xff00)
2026   {
2027      for (i = 0; i < count; i++)
2028         if ((maskptr[i] & mask) == value)
2029         {
2030            dest[i] = source[i] + pal;
2031            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
2032         }
2033   }
2034
2035   /* no priority case */
2036   else
2037   {
2038      for (i = 0; i < count; i++)
2039         if ((maskptr[i] & mask) == value)
2040            dest[i] = source[i] + pal;
2041   }
1514   if (machine.primary_screen == NULL || machine.primary_screen->width() == 0)
1515      return;
1516   machine.primary_screen->register_screen_bitmap(machine.priority_bitmap);
20421517}
20431518
20441519
1520//-------------------------------------------------
1521//  set_flip_all - set a global flip for all the
1522//  tilemaps
1523//-------------------------------------------------
20451524
2046/*-------------------------------------------------
2047    scanline_draw_opaque_rgb32 - draw to a 32bpp
2048    RGB bitmap
2049-------------------------------------------------*/
2050
2051inline void scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
1525tilemap_t &tilemap_manager::create(tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows)
20521526{
2053   const pen_t *clut = &pens[pcode >> 16];
2054   int i;
2055
2056   /* priority case */
2057   if ((pcode & 0xffff) != 0xff00)
2058   {
2059      for (i = 0; i < count; i++)
2060      {
2061         dest[i] = clut[source[i]];
2062         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
2063      }
2064   }
2065
2066   /* no priority case */
2067   else
2068   {
2069      for (i = 0; i < count; i++)
2070         dest[i] = clut[source[i]];
2071   }
1527   return m_tilemap_list.append(*auto_alloc(machine(), tilemap_t(*this, tile_get_info, mapper, tilewidth, tileheight, cols, rows)));
20721528}
20731529
2074
2075/*-------------------------------------------------
2076    scanline_draw_masked_rgb32 - draw to a 32bpp
2077    RGB bitmap using a mask
2078-------------------------------------------------*/
2079
2080inline void scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
1530tilemap_t &tilemap_manager::create(tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
20811531{
2082   const pen_t *clut = &pens[pcode >> 16];
2083   int i;
2084
2085   /* priority case */
2086   if ((pcode & 0xffff) != 0xff00)
2087   {
2088      for (i = 0; i < count; i++)
2089         if ((maskptr[i] & mask) == value)
2090         {
2091            dest[i] = clut[source[i]];
2092            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
2093         }
2094   }
2095
2096   /* no priority case */
2097   else
2098   {
2099      for (i = 0; i < count; i++)
2100         if ((maskptr[i] & mask) == value)
2101            dest[i] = clut[source[i]];
2102   }
1532   return m_tilemap_list.append(*auto_alloc(machine(), tilemap_t(*this, tilemap_get_info_delegate(tile_get_info, "", &machine()), tilemap_mapper_delegate(mapper, "", &machine()), tilewidth, tileheight, cols, rows)));
21031533}
21041534
21051535
2106/*-------------------------------------------------
2107    scanline_draw_opaque_rgb32_alpha - draw to a
2108    32bpp RGB bitmap with alpha blending
2109-------------------------------------------------*/
1536//-------------------------------------------------
1537//  set_flip_all - set a global flip for all the
1538//  tilemaps
1539//-------------------------------------------------
21101540
2111inline void scanline_draw_opaque_rgb32_alpha(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
1541void tilemap_manager::set_flip_all(UINT32 attributes)
21121542{
2113   const pen_t *clut = &pens[pcode >> 16];
2114   int i;
2115
2116   /* priority case */
2117   if ((pcode & 0xffff) != 0xff00)
2118   {
2119      for (i = 0; i < count; i++)
2120      {
2121         dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
2122         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
2123      }
2124   }
2125
2126   /* no priority case */
2127   else
2128   {
2129      for (i = 0; i < count; i++)
2130         dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
2131   }
1543   for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next())
1544      tmap->set_flip(attributes);
21321545}
21331546
21341547
2135/*-------------------------------------------------
2136    scanline_draw_masked_rgb32_alpha - draw to a
2137    32bpp RGB bitmap using a mask and alpha
2138    blending
2139-------------------------------------------------*/
1548//-------------------------------------------------
1549//  mark_all_dirty - mark all the tiles in all the
1550//  tilemaps dirty
1551//-------------------------------------------------
21401552
2141inline void scanline_draw_masked_rgb32_alpha(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
1553void tilemap_manager::mark_all_dirty()
21421554{
2143   const pen_t *clut = &pens[pcode >> 16];
2144   int i;
2145
2146   /* priority case */
2147   if ((pcode & 0xffff) != 0xff00)
2148   {
2149      for (i = 0; i < count; i++)
2150         if ((maskptr[i] & mask) == value)
2151         {
2152            dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
2153            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
2154         }
2155   }
2156
2157   /* no priority case */
2158   else
2159   {
2160      for (i = 0; i < count; i++)
2161         if ((maskptr[i] & mask) == value)
2162            dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
2163   }
1555   for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next())
1556      tmap->mark_all_dirty();
21641557}
src/emu/tilemap.h
r14063r14064
44
55    Generic tilemap management system.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7****************************************************************************
98
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1038****************************************************************************
1139
1240    Core concepts:
r14063r14064
302330#define __TILEMAP_H__
303331
304332
305/***************************************************************************
306    CONSTANTS
307***************************************************************************/
333//**************************************************************************
334//  CONSTANTS
335//**************************************************************************
308336
309/* maximum number of groups */
337// maximum number of groups
310338#define TILEMAP_NUM_GROUPS            256
311339
312340
313/* these flags control tilemap_draw() behavior */
314#define TILEMAP_DRAW_CATEGORY_MASK      0x0f      /* specify the category to draw */
315#define TILEMAP_DRAW_CATEGORY(x)      (x)         /* specify category to draw */
316#define TILEMAP_DRAW_LAYER0            0x10      /* draw layer 0 */
317#define TILEMAP_DRAW_LAYER1            0x20      /* draw layer 1 */
318#define TILEMAP_DRAW_LAYER2            0x40      /* draw layer 2 */
319#define TILEMAP_DRAW_OPAQUE            0x80      /* draw everything, even transparent stuff */
320#define TILEMAP_DRAW_ALPHA_FLAG         0x100      /* draw with alpha blending (in the upper 8 bits) */
321#define TILEMAP_DRAW_ALPHA(x)         (TILEMAP_DRAW_ALPHA_FLAG | (rgb_clamp(x) << 24))
322#define TILEMAP_DRAW_ALL_CATEGORIES      0x200      /* draw all categories */
341// these flags control tilemap_draw() behavior
342const UINT32 TILEMAP_DRAW_CATEGORY_MASK = 0x0f;      // specify the category to draw
343const UINT32 TILEMAP_DRAW_LAYER0 = 0x10;         // draw layer 0
344const UINT32 TILEMAP_DRAW_LAYER1 = 0x20;         // draw layer 1
345const UINT32 TILEMAP_DRAW_LAYER2 = 0x40;         // draw layer 2
346const UINT32 TILEMAP_DRAW_OPAQUE = 0x80;         // draw everything, even transparent stuff
347const UINT32 TILEMAP_DRAW_ALPHA_FLAG = 0x100;      // draw with alpha blending (in the upper 8 bits)
348const UINT32 TILEMAP_DRAW_ALL_CATEGORIES = 0x200;   // draw all categories
323349
350// per-pixel flags in the transparency_bitmap
351const UINT8 TILEMAP_PIXEL_CATEGORY_MASK = 0x0f;      // category is stored in the low 4 bits
352const UINT8 TILEMAP_PIXEL_TRANSPARENT = 0x00;      // transparent if in none of the layers below
353const UINT8 TILEMAP_PIXEL_LAYER0 = 0x10;         // pixel is opaque in layer 0
354const UINT8 TILEMAP_PIXEL_LAYER1 = 0x20;         // pixel is opaque in layer 1
355const UINT8 TILEMAP_PIXEL_LAYER2 = 0x40;         // pixel is opaque in layer 2
324356
325/* per-pixel flags in the transparency_bitmap */
326#define TILEMAP_PIXEL_CATEGORY_MASK      0x0f      /* category is stored in the low 4 bits */
327#define TILEMAP_PIXEL_TRANSPARENT      0x00      /* transparent if in none of the layers below */
328#define TILEMAP_PIXEL_LAYER0         0x10      /* pixel is opaque in layer 0 */
329#define TILEMAP_PIXEL_LAYER1         0x20      /* pixel is opaque in layer 1 */
330#define TILEMAP_PIXEL_LAYER2         0x40      /* pixel is opaque in layer 2 */
357// per-tile flags, set by get_tile_info callback
358const UINT8 TILE_FLIPX = 0x01;                  // draw this tile horizontally flipped
359const UINT8 TILE_FLIPY = 0x02;                  // draw this tile vertically flipped
360const UINT8 TILE_4BPP = 0x04;                  // tile data is packed 4bpp
361const UINT8 TILE_FORCE_LAYER0 = TILEMAP_PIXEL_LAYER0; // force all pixels to be layer 0 (no transparency)
362const UINT8 TILE_FORCE_LAYER1 = TILEMAP_PIXEL_LAYER1; // force all pixels to be layer 1 (no transparency)
363const UINT8 TILE_FORCE_LAYER2 = TILEMAP_PIXEL_LAYER2; // force all pixels to be layer 2 (no transparency)
331364
365// tilemap global flags, used by tilemap_set_flip()
366const UINT32 TILEMAP_FLIPX = TILE_FLIPX;         // draw the tilemap horizontally flipped
367const UINT32 TILEMAP_FLIPY = TILE_FLIPY;         // draw the tilemap vertically flipped
332368
333/* per-tile flags, set by get_tile_info callback */
334#define TILE_FLIPX                  0x01      /* draw this tile horizontally flipped */
335#define TILE_FLIPY                  0x02      /* draw this tile vertically flipped */
336#define TILE_4BPP                  0x04      /* tile data is packed 4bpp */
337#define TILE_FORCE_LAYER0            TILEMAP_PIXEL_LAYER0 /* force all pixels to be layer 0 (no transparency) */
338#define TILE_FORCE_LAYER1            TILEMAP_PIXEL_LAYER1 /* force all pixels to be layer 1 (no transparency) */
339#define TILE_FORCE_LAYER2            TILEMAP_PIXEL_LAYER2 /* force all pixels to be layer 2 (no transparency) */
369// set this value for a scroll row/column to fully disable it
370const UINT32 TILE_LINE_DISABLED = 0x80000000;
340371
341372
342/* tilemap global flags, used by tilemap_set_flip() */
343#define TILEMAP_FLIPX               TILE_FLIPX   /* draw the tilemap horizontally flipped */
344#define TILEMAP_FLIPY               TILE_FLIPY   /* draw the tilemap vertically flipped */
345373
374//**************************************************************************
375//  TYPE DEFINITIONS
376//**************************************************************************
346377
347/* set this value for a scroll row/column to fully disable it */
348#define TILE_LINE_DISABLED            0x80000000
378// forward declarations
379class tilemap_t;
380class tilemap_manager;
349381
350382
383// global types
384typedef UINT32 tilemap_memory_index;
351385
352/***************************************************************************
353    MACROS
354***************************************************************************/
355386
356/* function definition for a get info callback */
357#define TILE_GET_INFO(_name)         void _name(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param)
358#define TILE_GET_INFO_DEVICE(_name)      void _name(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param)
387// tile_data is filled in by the get_tile_info callback
388struct tile_data
389{
390   const UINT8 *   pen_data;      // required
391   const UINT8 *   mask_data;      // required
392   pen_t         palette_base;   // defaults to 0
393   UINT8         category;      // defaults to 0; range from 0..15
394   UINT8         group;         // defaults to 0; range from 0..TILEMAP_NUM_GROUPS
395   UINT8         flags;         // defaults to 0; one or more of TILE_* flags above
396   UINT8         pen_mask;      // defaults to 0xff; mask to apply to pen_data while rendering the tile
397   UINT8         gfxnum;         // defaults to 0xff; specify index of machine.gfx for auto-invalidation on dirty
359398
360/* function definition for a logical-to-memory mapper */
361#define TILEMAP_MAPPER(_name)         tilemap_memory_index _name(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows)
399   void set(running_machine &machine, int _gfxnum, int rawcode, int rawcolor, int _flags)
400   {
401      const gfx_element *gfx = machine.gfx[_gfxnum];
402      int code = rawcode % gfx->total_elements;
403      pen_data = gfx_element_get_data(gfx, code);
404      palette_base = gfx->color_base + gfx->color_granularity * rawcolor;
405      flags = _flags;
406      if (gfx->flags & GFX_ELEMENT_PACKED)
407         flags |= TILE_4BPP;
408      gfxnum = _gfxnum;
409   }
410};
362411
363/* useful macro inside of a TILE_GET_INFO callback to set tile information  */
364#define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS)         tileinfo_set(machine, tileinfo, GFX, CODE, COLOR, FLAGS)
365#define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS)  tileinfo_set(device->machine(), tileinfo, GFX, CODE, COLOR, FLAGS)
366412
367/* Macros for setting tile attributes in the TILE_GET_INFO callback: */
368/*   TILE_FLIP_YX assumes that flipy is in bit 1 and flipx is in bit 0 */
369/*   TILE_FLIP_XY assumes that flipy is in bit 0 and flipx is in bit 1 */
370#define TILE_FLIPYX(YX)               ((YX) & 3)
371#define TILE_FLIPXY(XY)               ((((XY) & 2) >> 1) | (((XY) & 1) << 1))
413// modern delegates
414typedef delegate<void (tile_data *, tilemap_memory_index, void *)> tilemap_get_info_delegate;
415typedef delegate<tilemap_memory_index (UINT32, UINT32, UINT32, UINT32)> tilemap_mapper_delegate;
372416
373417
418// legacy callbacks
419typedef void (*tile_get_info_func)(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param);
420typedef void (*tile_get_info_device_func)(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param);
421typedef tilemap_memory_index (*tilemap_mapper_func)(running_machine &machine, UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows);
374422
375/***************************************************************************
376    TYPE DEFINITIONS
377***************************************************************************/
378423
379/* memory indexes are unsigned integers */
380typedef UINT32 tilemap_memory_index;
424// core tilemap structure
425class tilemap_t
426{
427   DISABLE_COPYING(tilemap_t);
428   
429   friend class tilemap_manager;
430   friend class simple_list<tilemap_t>;
431    friend resource_pool_object<tilemap_t>::~resource_pool_object();
381432
382/* opaque tilemap definition */
383class tilemap_t;
433   // logical index
434   typedef UINT32 logical_index;
384435
436   // internal usage to mark tiles dirty
437   static const UINT8 TILE_FLAG_DIRTY = 0xff;
385438
386/* tile_data is filled in by the get_tile_info callback */
387typedef struct _tile_data tile_data;
388struct _tile_data
389{
390   const UINT8 *   pen_data;      /* required */
391   const UINT8 *   mask_data;      /* required */
392   pen_t         palette_base;   /* defaults to 0 */
393   UINT8         category;      /* defaults to 0; range from 0..15 */
394   UINT8         group;         /* defaults to 0; range from 0..TILEMAP_NUM_GROUPS */
395   UINT8         flags;         /* defaults to 0; one or more of TILE_* flags above */
396   UINT8         pen_mask;      /* defaults to 0xff; mask to apply to pen_data while rendering the tile */
397   UINT8         gfxnum;         /* defaults to 0xff; specify index of machine.gfx for auto-invalidation on dirty */
439   // invalid logical index
440   static const logical_index INVALID_LOGICAL_INDEX = (logical_index)~0;
441
442   // maximum index in each array
443   static const int MAX_PEN_TO_FLAGS = 256;
444
445   // tilemap_manager controlls our allocations
446   tilemap_t(tilemap_manager &manager, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows);
447   ~tilemap_t();
448
449public:
450   // getters
451   running_machine &machine() const;
452   tilemap_t *next() const { return m_next; }
453   UINT32 width() const { return m_width; }
454   UINT32 height() const { return m_height; }
455   bool enabled() const { return m_enable; }
456   int scrolldx() const { return (m_attributes & TILEMAP_FLIPX) ? m_dx_flipped : m_dx; }
457   int scrolldy() const { return (m_attributes & TILEMAP_FLIPY) ? m_dy_flipped : m_dy; }
458   int scrollx(int which = 0) const { return (which < m_scrollrows) ? m_rowscroll[which] : 0; }
459   int scrolly(int which = 0) const { return (which < m_scrollcols) ? m_colscroll[which] : 0; }
460   bitmap_ind16 &pixmap() { pixmap_update(); return m_pixmap; }
461   bitmap_ind8 &flagsmap() { pixmap_update(); return m_flagsmap; }
462   UINT8 *tile_flags() { pixmap_update(); return m_tileflags; }
463   tilemap_memory_index memory_index(UINT32 col, UINT32 row) { return m_mapper(col, row, m_cols, m_rows); }
464   
465   // setters
466   void set_user_data(void *user_data) { m_user_data = user_data; }
467   void set_palette_offset(UINT32 offset) { m_palette_offset = offset; }
468   void set_enable(bool enable) { m_enable = enable; }
469   void set_scrolldx(int dx, int dx_flipped) { m_dx = dx; m_dx_flipped = dx_flipped; }
470   void set_scrolldy(int dy, int dy_flipped) { m_dy = dy; m_dy_flipped = dy_flipped; }
471   void set_scrollx(int which, int value) { if (which < m_scrollrows) m_rowscroll[which] = value; }
472   void set_scrolly(int which, int value) { if (which < m_scrollcols) m_colscroll[which] = value; }
473   void set_scrollx(int value) { set_scrollx(0, value); }
474   void set_scrolly(int value) { set_scrolly(0, value); }
475   void set_scroll_rows(UINT32 scroll_rows) { assert(scroll_rows <= m_height); m_scrollrows = scroll_rows; }
476   void set_scroll_cols(UINT32 scroll_cols) { assert(scroll_cols <= m_width); m_scrollcols = scroll_cols; }
477   void set_flip(UINT32 attributes) { if (m_attributes != attributes) { m_attributes = attributes; mappings_update(); } }
478
479   // dirtying
480   void mark_tile_dirty(tilemap_memory_index memindex);
481   void mark_all_dirty() { m_all_tiles_dirty = true; m_all_tiles_clean = false; }
482
483   // pen mapping
484   void map_pens_to_layer(int group, pen_t pen, pen_t mask, UINT8 layermask);
485   void map_pen_to_layer(int group, pen_t pen, UINT8 layermask) { map_pens_to_layer(group, pen, ~0, layermask); }
486   void set_transparent_pen(pen_t pen);
487   void set_transmask(int group, UINT32 fgmask, UINT32 bgmask);
488
489   // drawing
490   void draw(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff);
491   void draw(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff);
492   void draw_roz(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff);
493   void draw_roz(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask = 0xff);
494   void draw_debug(bitmap_rgb32 &dest, UINT32 scrollx, UINT32 scrolly);
495
496private:
497   // internal set of transparency states for rendering
498   enum trans_t
499   {
500      WHOLLY_TRANSPARENT,
501      WHOLLY_OPAQUE,
502      MASKED
503   };
504
505   // blitting parameters for rendering
506   struct blit_parameters
507   {
508      rectangle         cliprect;
509      UINT32            tilemap_priority_code;
510      UINT8            mask;
511      UINT8            value;
512      UINT8            alpha;
513   };
514   
515   // inline helpers
516   INT32 effective_rowscroll(int index, UINT32 screen_width);
517   INT32 effective_colscroll(int index, UINT32 screen_height);
518   bool gfx_elements_changed();
519   
520   // inline scanline rasterizers
521   void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode);
522   void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode);
523   void scanline_draw_opaque_ind16(UINT16 *dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode);
524   void scanline_draw_masked_ind16(UINT16 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode);
525   void scanline_draw_opaque_rgb32(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
526   void scanline_draw_masked_rgb32(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
527   void scanline_draw_opaque_rgb32_alpha(UINT32 *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
528   void scanline_draw_masked_rgb32_alpha(UINT32 *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
529
530   // internal helpers
531   void postload();
532   void mappings_create();
533   void mappings_update();
534   void realize_all_dirty_tiles();
535
536   // internal drawing
537   void pixmap_update();
538   void tile_update(logical_index logindex, UINT32 col, UINT32 row);
539   UINT8 tile_draw(const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags, UINT8 pen_mask);
540   UINT8 tile_apply_bitmask(const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags);
541   void configure_blit_parameters(blit_parameters &blit, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask);
542   template<class _BitmapClass> void draw_common(_BitmapClass &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask);
543   template<class _BitmapClass> void draw_roz_common(_BitmapClass &dest, const rectangle &cliprect, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask);
544   template<class _BitmapClass> void draw_instance(_BitmapClass &dest, const blit_parameters &blit, int xpos, int ypos);
545   template<class _BitmapClass> void draw_roz_core(_BitmapClass &destbitmap, const blit_parameters &blit, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound);
546
547   // basic tilemap metrics
548   tilemap_t *               m_next;               // pointer to next tilemap
549   UINT32                  m_rows;               // number of tile rows
550   UINT32                  m_cols;               // number of tile columns
551   UINT32                  m_tilewidth;         // width of a single tile in pixels
552   UINT32                  m_tileheight;         // height of a single tile in pixels
553   UINT32                  m_width;            // width of the full tilemap in pixels
554   UINT32                  m_height;            // height of the full tilemap in pixels
555
556   // logical <-> memory mappings
557   tilemap_mapper_delegate      m_mapper;            // callback to map a row/column to a memory index
558   logical_index *            m_memory_to_logical;   // map from memory index to logical index
559   logical_index            m_max_logical_index;   // maximum valid logical index
560   tilemap_memory_index *      m_logical_to_memory;   // map from logical index to memory index
561   tilemap_memory_index      m_max_memory_index;      // maximum valid memory index
562
563   // callback to interpret video RAM for the tilemap
564   tilemap_get_info_delegate   m_tile_get_info;      // callback to get information about a tile
565   tile_data               m_tileinfo;            // structure to hold the data for a tile
566   void *                  m_user_data;         // user data value passed to the callback
567
568   // global tilemap states
569   bool                  m_enable;            // true if we are enabled
570   UINT8                  m_attributes;         // global attributes (flipx/y)
571   bool                  m_all_tiles_dirty;      // true if all tiles are dirty
572   bool                  m_all_tiles_clean;      // true if all tiles are clean
573   UINT32                  m_palette_offset;      // palette offset
574   UINT32                  m_pen_data_offset;      // pen data offset
575   UINT32                  m_gfx_used;            // bitmask of gfx items used
576   UINT32                  m_gfx_dirtyseq[MAX_GFX_ELEMENTS]; // dirtyseq values from last check
577
578   // scroll information
579   UINT32                  m_scrollrows;         // number of independently scrolled rows
580   UINT32                  m_scrollcols;         // number of independently scrolled colums
581   INT32 *                  m_rowscroll;         // array of rowscroll values
582   INT32 *                  m_colscroll;         // array of colscroll values
583   INT32                  m_dx;               // global horizontal scroll offset
584   INT32                  m_dx_flipped;         // global horizontal scroll offset when flipped
585   INT32                  m_dy;               // global vertical scroll offset
586   INT32                  m_dy_flipped;         // global vertical scroll offset when flipped
587
588   // pixel data
589   bitmap_ind16            m_pixmap;            // cached pixel data
590
591   // transparency mapping
592   bitmap_ind8               m_flagsmap;            // per-pixel flags
593   UINT8 *                  m_tileflags;         // per-tile flags
594   UINT8                  m_pen_to_flags[MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS];      // mapping of pens to flags
595
596private:
597   tilemap_manager &         m_manager;            // reference to the owning manager
398598};
399599
400600
401/* callback function to get info about a tile */
402typedef void (*tile_get_info_func)(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param);
403typedef void (*tile_get_info_device_func)(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param);
601// tilemap manager
602class tilemap_manager
603{
604   friend class tilemap_t;
404605
405/* callback function to map a column,row pair to a memory index */
406typedef tilemap_memory_index (*tilemap_mapper_func)(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows);
606public:
607   // construction/destuction
608   tilemap_manager(running_machine &machine);
609   
610   // getters
611   running_machine &machine() const { return m_machine; }
612   
613   // tilemap creation
614   tilemap_t &create(tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows);
615   tilemap_t &create(tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows);
407616
617   // tilemap list information
618   tilemap_t *find(int index) { return m_tilemap_list.find(index); }
619   int count() const { return m_tilemap_list.count(); }
408620
621   // global operations on all tilemaps
622   void mark_all_dirty();
623   void set_flip_all(UINT32 attributes);
409624
410/***************************************************************************
411    FUNCTION PROTOTYPES
412***************************************************************************/
625private:
626   // allocate an instance index
627   int alloc_instance() { return ++m_instance; }
413628
629   // internal state
630   running_machine &      m_machine;
631   simple_list<tilemap_t>    m_tilemap_list;
632   int                  m_instance;
633};
414634
415/* ----- system-wide management ----- */
416635
417/* initialize the tilemap system -- not for use by drivers */
418void tilemap_init(running_machine &machine);
419636
637//**************************************************************************
638//  MACROS
639//**************************************************************************
420640
641// macros to help form flags for tilemap_draw
642#define TILEMAP_DRAW_CATEGORY(x)      (x)      // specify category to draw
643#define TILEMAP_DRAW_ALPHA(x)         (TILEMAP_DRAW_ALPHA_FLAG | (rgb_clamp(x) << 24))
421644
422/* ----- tilemap creation and configuration ----- */
645// function definition for a get info callback
646#define TILE_GET_INFO(_name)         void _name(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param)
647#define TILE_GET_INFO_DEVICE(_name)      void _name(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param)
423648
424/* create a new tilemap; note that tilemaps are tracked by the core so there is no dispose */
425tilemap_t *tilemap_create(running_machine &machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows);
649// function definition for a logical-to-memory mapper
650#define TILEMAP_MAPPER(_name)         tilemap_memory_index _name(running_machine &machine, UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows)
426651
427/* create a new tilemap that is owned by a device */
428tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows);
652// useful macro inside of a TILE_GET_INFO callback to set tile information
653#define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS)         tileinfo_set(machine, tileinfo, GFX, CODE, COLOR, FLAGS)
654#define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS)  tileinfo_set(device->machine(), tileinfo, GFX, CODE, COLOR, FLAGS)
429655
430/* specify a parameter to be passed into the tile_get_info callback */
431void tilemap_set_user_data(tilemap_t *tmap, void *user_data);
656// Macros for setting tile attributes in the TILE_GET_INFO callback:
657//   TILE_FLIP_YX assumes that flipy is in bit 1 and flipx is in bit 0
658//   TILE_FLIP_XY assumes that flipy is in bit 0 and flipx is in bit 1
659#define TILE_FLIPYX(YX)               ((YX) & 3)
660#define TILE_FLIPXY(XY)               ((((XY) & 2) >> 1) | (((XY) & 1) << 1))
432661
433/* specify an offset to be added to each pixel before looking up the palette.
434 * The offset only applies at final rendering time (e.g., tilemap_draw())
435 * It does not apply to the cached pixmap, which is provided by tilemap_get_pixmap().
436 */
437void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset);
438662
439/* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */
440void tilemap_set_enable(tilemap_t *tmap, int enable);
441663
442/* return enable flag for the tilemap */
443int tilemap_get_enable(tilemap_t *tmap);
664//**************************************************************************
665//  FUNCTION PROTOTYPES
666//**************************************************************************
444667
445/* set a global flip for the tilemap */
446void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes);
447668
448/* set a global flip for all tilemaps */
449void tilemap_set_flip_all(running_machine &machine, UINT32 attributes);
669// ----- tilemap creation and configuration -----
450670
671// create a new tilemap; note that tilemaps are tracked by the core so there is no dispose
672inline tilemap_t *tilemap_create(running_machine &machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
673{ return &machine.tilemap().create(tilemap_get_info_delegate(tile_get_info, "", &machine), tilemap_mapper_delegate(mapper, "", &machine), tilewidth, tileheight, cols, rows); }
451674
675// create a new tilemap that is owned by a device
676inline tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
677{ return &device->machine().tilemap().create(tilemap_get_info_delegate(tile_get_info, "", device), tilemap_mapper_delegate(mapper, "", &device->machine()), tilewidth, tileheight, cols, rows); }
452678
453/* ----- dirty tile marking ----- */
679// specify a parameter to be passed into the tile_get_info callback
680inline void tilemap_set_user_data(tilemap_t *tmap, void *user_data)
681{ tmap->set_user_data(user_data); }
454682
455/* mark a single tile dirty based on its memory index */
456void tilemap_mark_tile_dirty(tilemap_t *tmap, tilemap_memory_index memory_index);
683// specify an offset to be added to each pixel before looking up the palette.
684inline void tilemap_set_palette_offset(tilemap_t *tmap, UINT32 offset)
685{ tmap->set_palette_offset(offset); }
457686
458/* mark all the tiles dirty in a tilemap */
459void tilemap_mark_all_tiles_dirty(tilemap_t *tmap);
687// set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored
688inline void tilemap_set_enable(tilemap_t *tmap, int enable)
689{ tmap->set_enable(enable); }
460690
461/* mark all the tiles dirty in all tilemaps */
462void tilemap_mark_all_tiles_dirty_all(running_machine &machine);
691// return enable flag for the tilemap
692inline int tilemap_get_enable(tilemap_t *tmap)
693{ return tmap->enabled(); }
463694
695// set a global flip for the tilemap
696inline void tilemap_set_flip(tilemap_t *tmap, UINT32 attributes)
697{ tmap->set_flip(attributes); }
464698
699// set a global flip for all tilemaps
700inline void tilemap_set_flip_all(running_machine &machine, UINT32 attributes)
701{ machine.tilemap().set_flip_all(attributes); }
465702
466/* ----- pen-to-layer mapping ----- */
467703
468/* specify the mapping of one or more pens (where (<pen> & mask == pen) to a layer */
469void tilemap_map_pens_to_layer(tilemap_t *tmap, int group, pen_t pen, pen_t mask, UINT8 layermask);
470704
471/* set a single transparent pen into the tilemap, mapping all other pens to layer 0 */
472void tilemap_set_transparent_pen(tilemap_t *tmap, pen_t pen);
705// ----- dirty tile marking -----
473706
474/* set up the first 32 pens using a foreground (layer 0) mask and a background (layer 1) mask */
475void tilemap_set_transmask(tilemap_t *tmap, int group, UINT32 fgmask, UINT32 bgmask);
707// mark a single tile dirty based on its memory index
708inline void tilemap_mark_tile_dirty(tilemap_t *tmap, tilemap_memory_index memory_index)
709{ tmap->mark_tile_dirty(memory_index); }
476710
711// mark all the tiles dirty in a tilemap
712inline void tilemap_mark_all_tiles_dirty(tilemap_t *tmap)
713{ tmap->mark_all_dirty(); }
477714
715// mark all the tiles dirty in all tilemaps
716inline void tilemap_mark_all_tiles_dirty_all(running_machine &machine)
717{ machine.tilemap().mark_all_dirty(); }
478718
479/* ----- tilemap scrolling ----- */
480719
481/* specify the number of independently scrollable row units; each unit covers height/scroll_rows pixels */
482void tilemap_set_scroll_rows(tilemap_t *tmap, UINT32 scroll_rows);
483720
484/* specify the number of independently scrollable column units; each unit covers width/scroll_cols pixels */
485void tilemap_set_scroll_cols(tilemap_t *tmap, UINT32 scroll_cols);
721// ----- pen-to-layer mapping -----
486722
487/* specify global horizontal and vertical scroll offsets, for non-flipped and flipped cases */
488void tilemap_set_scrolldx(tilemap_t *tmap, int dx, int dx_if_flipped);
489void tilemap_set_scrolldy(tilemap_t *tmap, int dy, int dy_if_flipped);
723// specify the mapping of one or more pens (where (<pen> & mask == pen) to a layer
724inline void tilemap_map_pens_to_layer(tilemap_t *tmap, int group, pen_t pen, pen_t mask, UINT8 layermask)
725{ tmap->map_pens_to_layer(group, pen, mask, layermask); }
490726
491/* return the global horizontal or vertical scroll offset, based on current flip state */
492int tilemap_get_scrolldx(tilemap_t *tmap);
493int tilemap_get_scrolldy(tilemap_t *tmap);
727// set a single transparent pen into the tilemap, mapping all other pens to layer 0
728inline void tilemap_set_transparent_pen(tilemap_t *tmap, pen_t pen)
729{ tmap->set_transparent_pen(pen); }
494730
495/* specify the scroll value for a row/column unit */
496void tilemap_set_scrollx(tilemap_t *tmap, int row, int value);
497void tilemap_set_scrolly(tilemap_t *tmap, int col, int value);
731// set up the first 32 pens using a foreground (layer 0) mask and a background (layer 1) mask
732inline void tilemap_set_transmask(tilemap_t *tmap, int group, UINT32 fgmask, UINT32 bgmask)
733{ tmap->set_transmask(group, fgmask, bgmask); }
498734
499/* return the scroll value for a row/column unit */
500int tilemap_get_scrollx(tilemap_t *tmap, int row);
501int tilemap_get_scrolly(tilemap_t *tmap, int col);
502735
503736
737// ----- tilemap scrolling -----
504738
505/* ----- internal map access ----- */
739// specify the number of independently scrollable row units; each unit covers height/scroll_rows pixels
740inline void tilemap_set_scroll_rows(tilemap_t *tmap, UINT32 scroll_rows)
741{ tmap->set_scroll_rows(scroll_rows); }
506742
507/* return a pointer to the (updated) internal pixmap for a tilemap */
508bitmap_ind16 &tilemap_get_pixmap(tilemap_t *tmap);
743// specify the number of independently scrollable column units; each unit covers width/scroll_cols pixels
744inline void tilemap_set_scroll_cols(tilemap_t *tmap, UINT32 scroll_cols)
745{ tmap->set_scroll_cols(scroll_cols); }
509746
510/* return a pointer to the (updated) internal flagsmap for a tilemap */
511bitmap_ind8 &tilemap_get_flagsmap(tilemap_t *tmap);
747// specify global horizontal and vertical scroll offsets, for non-flipped and flipped cases
748inline void tilemap_set_scrolldx(tilemap_t *tmap, int dx, int dx_if_flipped)
749{ tmap->set_scrolldx(dx, dx_if_flipped); }
750inline void tilemap_set_scrolldy(tilemap_t *tmap, int dy, int dy_if_flipped)
751{ tmap->set_scrolldy(dy, dy_if_flipped); }
512752
513/* return a pointer to the (updated) internal per-tile flags for a tilemap */
514UINT8 *tilemap_get_tile_flags(tilemap_t *tmap);
753// return the global horizontal or vertical scroll offset, based on current flip state
754inline int tilemap_get_scrolldx(tilemap_t *tmap)
755{ return tmap->scrolldx(); }
756inline int tilemap_get_scrolldy(tilemap_t *tmap)
757{ return tmap->scrolldy(); }
515758
759// specify the scroll value for a row/column unit
760inline void tilemap_set_scrollx(tilemap_t *tmap, int row, int value)
761{ tmap->set_scrollx(row, value); }
762inline void tilemap_set_scrolly(tilemap_t *tmap, int col, int value)
763{ tmap->set_scrolly(col, value); }
516764
765// return the scroll value for a row/column unit
766inline int tilemap_get_scrollx(tilemap_t *tmap, int row)
767{ return tmap->scrollx(row); }
768inline int tilemap_get_scrolly(tilemap_t *tmap, int col)
769{ return tmap->scrolly(col); }
517770
518/* ----- tilemap rendering ----- */
519771
520/* draw a tilemap to the destination with clipping; pixels apply priority/priority_mask to the priority bitmap */
521void tilemap_draw_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask);
522void tilemap_draw_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask);
523772
524/* draw a tilemap to the destination with clipping and arbitrary rotate/zoom; */
525/* pixels apply priority/priority_mask to the priority bitmap */
526void tilemap_draw_roz_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap,
527      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
528      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask);
529void tilemap_draw_roz_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
530      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
531      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask);
773// ----- internal map access -----
532774
775// return a pointer to the (updated) internal pixmap for a tilemap
776inline bitmap_ind16 &tilemap_get_pixmap(tilemap_t *tmap)
777{ return tmap->pixmap(); }
533778
779// return a pointer to the (updated) internal flagsmap for a tilemap
780inline bitmap_ind8 &tilemap_get_flagsmap(tilemap_t *tmap)
781{ return tmap->flagsmap(); }
534782
535/* ----- indexed tilemap handling ----- */
783// return a pointer to the (updated) internal per-tile flags for a tilemap
784inline UINT8 *tilemap_get_tile_flags(tilemap_t *tmap)
785{ return tmap->tile_flags(); }
536786
537/* return the number of tilemaps */
538int tilemap_count(running_machine &machine);
539787
540/* return the size of an indexed tilemap */
541void tilemap_size_by_index(running_machine &machine, int number, UINT32 *width, UINT32 *height);
542788
543/* render an indexed tilemap with fixed characteristics (no priority) */
544void tilemap_draw_by_index(running_machine &machine, bitmap_rgb32 &dest, int number, UINT32 scrollx, UINT32 scrolly);
789// ----- tilemap rendering -----
545790
791// draw a tilemap to the destination with clipping; pixels apply priority/priority_mask to the priority bitmap
792inline void tilemap_draw_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask)
793{ tmap->draw(dest, cliprect, flags, priority, priority_mask); }
794inline void tilemap_draw_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority, UINT8 priority_mask)
795{ tmap->draw(dest, cliprect, flags, priority, priority_mask); }
546796
797// draw a tilemap to the destination with clipping and arbitrary rotate/zoom;
798// pixels apply priority/priority_mask to the priority bitmap
799inline void tilemap_draw_roz_primask(bitmap_ind16 &dest, const rectangle &cliprect, tilemap_t *tmap,
800      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
801      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
802{ tmap->draw_roz(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); }
803inline void tilemap_draw_roz_primask(bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
804      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
805      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask)
806{ tmap->draw_roz(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); }
547807
548/* ----- common logical-to-memory mappers ----- */
549808
550/* scan in row-major order with optional flipping */
809
810// ----- common logical-to-memory mappers -----
811
812// scan in row-major order with optional flipping
551813TILEMAP_MAPPER( tilemap_scan_rows );
552814TILEMAP_MAPPER( tilemap_scan_rows_flip_x );
553815TILEMAP_MAPPER( tilemap_scan_rows_flip_y );
554816TILEMAP_MAPPER( tilemap_scan_rows_flip_xy );
555817
556/* scan in column-major order with optional flipping */
818// scan in column-major order with optional flipping
557819TILEMAP_MAPPER( tilemap_scan_cols );
558820TILEMAP_MAPPER( tilemap_scan_cols_flip_x );
559821TILEMAP_MAPPER( tilemap_scan_cols_flip_y );
r14063r14064
561823
562824
563825
564/***************************************************************************
565    INLINE FUNCTIONS
566***************************************************************************/
826//**************************************************************************
827//  INLINE FUNCTIONS
828//**************************************************************************
567829
568830/*-------------------------------------------------
569831    tileinfo_set - set the values of a tileinfo
r14063r14064
571833-------------------------------------------------*/
572834
573835inline void tileinfo_set(running_machine &machine, tile_data *tileinfo, int gfxnum, int rawcode, int rawcolor, int flags)
574{
575   const gfx_element *gfx = machine.gfx[gfxnum];
576   int code = rawcode % gfx->total_elements;
577   tileinfo->pen_data = gfx_element_get_data(gfx, code);
578   tileinfo->palette_base = gfx->color_base + gfx->color_granularity * rawcolor;
579   tileinfo->flags = flags;
580   if (gfx->flags & GFX_ELEMENT_PACKED)
581      tileinfo->flags |= TILE_4BPP;
582   tileinfo->gfxnum = gfxnum;
583}
836{ tileinfo->set(machine, gfxnum, rawcode, rawcolor, flags); }
584837
585838
586839/*-------------------------------------------------
r14063r14064
589842-------------------------------------------------*/
590843
591844inline void tilemap_map_pen_to_layer(tilemap_t *tmap, int group, pen_t pen, UINT8 layermask)
592{
593   tilemap_map_pens_to_layer(tmap, group, pen, ~0, layermask);
594}
845{ tmap->map_pen_to_layer(group, pen, layermask); }
595846
596847
597848/*-------------------------------------------------
r14063r14064
601852
602853template<class _BitmapClass>
603854inline void tilemap_draw(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap, UINT32 flags, UINT8 priority)
604{
605   tilemap_draw_primask(dest, cliprect, tmap, flags, priority, 0xff);
606}
855{ tmap->draw(dest, cliprect, flags, priority); }
607856
608857
609858/*-------------------------------------------------
r14063r14064
615864inline void tilemap_draw_roz(_BitmapClass &dest, const rectangle &cliprect, tilemap_t *tmap,
616865      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
617866      int wraparound, UINT32 flags, UINT8 priority)
867{ tmap->draw_roz(dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority); }
868
869
870inline running_machine &tilemap_t::machine() const
618871{
619   tilemap_draw_roz_primask(dest, cliprect, tmap, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, 0xff);
872   return m_manager.machine();
620873}
621874
622875
623
624#endif   /* __TILEMAP_H__ */
876#endif   // __TILEMAP_H__
src/emu/rendlay.c
r14063r14064
211211      sprintf(temp, "~scr%dnativexaspect~", scrnum);
212212      if (!strncmp(string, temp, strlen(temp)))
213213      {
214         int num = device->visible_area().max_x + 1 - device->visible_area().min_x;
215         int den = device->visible_area().max_y + 1 - device->visible_area().min_y;
214         int num = device->visible_area().width();
215         int den = device->visible_area().height();
216216         reduce_fraction(num, den);
217217         *outputptr += sprintf(*outputptr, "%d", num);
218218         return strlen(temp);
r14063r14064
222222      sprintf(temp, "~scr%dnativeyaspect~", scrnum);
223223      if (!strncmp(string, temp, strlen(temp)))
224224      {
225         int num = device->visible_area().max_x + 1 - device->visible_area().min_x;
226         int den = device->visible_area().max_y + 1 - device->visible_area().min_y;
225         int num = device->visible_area().width();
226         int den = device->visible_area().height();
227227         reduce_fraction(num, den);
228228         *outputptr += sprintf(*outputptr, "%d", den);
229229         return strlen(temp);
r14063r14064
233233      sprintf(temp, "~scr%dwidth~", scrnum);
234234      if (!strncmp(string, temp, strlen(temp)))
235235      {
236         *outputptr += sprintf(*outputptr, "%d", device->visible_area().max_x + 1 - device->visible_area().min_x);
236         *outputptr += sprintf(*outputptr, "%d", device->visible_area().width());
237237         return strlen(temp);
238238      }
239239
r14063r14064
241241      sprintf(temp, "~scr%dheight~", scrnum);
242242      if (!strncmp(string, temp, strlen(temp)))
243243      {
244         *outputptr += sprintf(*outputptr, "%d", device->visible_area().max_y + 1 - device->visible_area().min_y);
244         *outputptr += sprintf(*outputptr, "%d", device->visible_area().height());
245245         return strlen(temp);
246246      }
247247   }
r14063r14064
749749   UINT32 inva = (1.0f - m_color.a) * 255.0;
750750
751751   // iterate over X and Y
752   for (UINT32 y = bounds.min_y; y < bounds.max_y; y++)
753      for (UINT32 x = bounds.min_x; x < bounds.max_x; x++)
752   for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++)
753      for (UINT32 x = bounds.min_x; x <= bounds.max_x; x++)
754754      {
755755         UINT32 finalr = r;
756756         UINT32 finalg = g;
r14063r14064
785785   UINT32 inva = (1.0f - m_color.a) * 255.0;
786786
787787   // find the center
788   float xcenter = (float)(bounds.min_x + bounds.max_x) * 0.5f;
789   float ycenter = (float)(bounds.min_y + bounds.max_y) * 0.5f;
790   float xradius = (float)(bounds.max_x - bounds.min_x) * 0.5f;
791   float yradius = (float)(bounds.max_y - bounds.min_y) * 0.5f;
788   float xcenter = float(bounds.xcenter()) * 0.5f;
789   float ycenter = float(bounds.ycenter()) * 0.5f;
790   float xradius = float(bounds.width()) * 0.5f;
791   float yradius = float(bounds.height()) * 0.5f;
792792   float ooyradius2 = 1.0f / (yradius * yradius);
793793
794794   // iterate over y
795   for (UINT32 y = bounds.min_y; y < bounds.max_y; y++)
795   for (UINT32 y = bounds.min_y; y <= bounds.max_y; y++)
796796   {
797797      float ycoord = ycenter - ((float)y + 0.5f);
798798      float xval = xradius * sqrt(1.0f - (ycoord * ycoord) * ooyradius2);
r14063r14064
842842   INT32 width;
843843   while (1)
844844   {
845      width = font->string_width(bounds.max_y - bounds.min_y, aspect, m_string);
846      if (width < bounds.max_x - bounds.min_x)
845      width = font->string_width(bounds.height(), aspect, m_string);
846      if (width < bounds.width())
847847         break;
848848      aspect *= 0.9f;
849849   }
850   INT32 curx = bounds.min_x + (bounds.max_x - bounds.min_x - width) / 2;
850   INT32 curx = bounds.min_x + (bounds.width() - width) / 2;
851851
852852   // allocate a temporary bitmap
853853   bitmap_argb32 tempbitmap(dest.width(), dest.height());
r14063r14064
857857   {
858858      // get the font bitmap
859859      rectangle chbounds;
860      font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.max_y - bounds.min_y, aspect, *s, chbounds);
860      font->get_scaled_bitmap_and_bounds(tempbitmap, bounds.height(), aspect, *s, chbounds);
861861
862862      // copy the data into the target
863      for (int y = 0; y < chbounds.max_y - chbounds.min_y; y++)
863      for (int y = 0; y < chbounds.height(); y++)
864864      {
865865         int effy = bounds.min_y + y;
866866         if (effy >= bounds.min_y && effy <= bounds.max_y)
867867         {
868868            UINT32 *src = &tempbitmap.pix32(y);
869869            UINT32 *d = &dest.pix32(effy);
870            for (int x = 0; x < chbounds.max_x - chbounds.min_x; x++)
870            for (int x = 0; x < chbounds.width(); x++)
871871            {
872872               int effx = curx + x + chbounds.min_x;
873873               if (effx >= bounds.min_x && effx <= bounds.max_x)
r14063r14064
888888      }
889889
890890      // advance in the X direction
891      curx += font->char_width(bounds.max_y - bounds.min_y, aspect, *s);
891      curx += font->char_width(bounds.height(), aspect, *s);
892892   }
893893
894894   // free the temporary bitmap and font
src/emu/machine.c
r14063r14064
149149     debug_flags(0),
150150     memory_data(NULL),
151151     palette_data(NULL),
152     tilemap_data(NULL),
153152     romload_data(NULL),
154153     input_data(NULL),
155154     input_port_data(NULL),
r14063r14064
170169     m_input(NULL),
171170     m_sound(NULL),
172171     m_video(NULL),
172     m_tilemap(NULL),
173173     m_debug_view(NULL),
174174     m_driver_device(NULL),
175175     m_current_phase(MACHINE_PHASE_PREINIT),
r14063r14064
305305
306306   // initialize image devices
307307   image_init(*this);
308   tilemap_init(*this);
308   m_tilemap = auto_alloc(*this, tilemap_manager(*this));
309309   crosshair_init(*this);
310310   network_init(*this);
311311
src/emu/sound/cdp1869.c
r14063r14064
953953      }
954954
955955      int cols = m_freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
956      int rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
956      int rows = screen_rect.height() / height;
957957
958958      UINT16 pmemsize = get_pmemsize(cols, rows);
959959      UINT16 addr = m_hma;
src/emu/machine.h
r14063r14064
179179class render_manager;
180180class sound_manager;
181181class video_manager;
182class tilemap_manager;
182183class debug_view_manager;
183184class osd_interface;
184185
185186typedef struct _memory_private memory_private;
186187typedef struct _palette_private palette_private;
187typedef struct _tilemap_private tilemap_private;
188188typedef struct _romload_private romload_private;
189189typedef struct _input_private input_private;
190190typedef struct _input_port_private input_port_private;
r14063r14064
342342   input_manager &input() const { assert(m_input != NULL); return *m_input; }
343343   sound_manager &sound() const { assert(m_sound != NULL); return *m_sound; }
344344   video_manager &video() const { assert(m_video != NULL); return *m_video; }
345   tilemap_manager &tilemap() const { assert(m_tilemap != NULL); return *m_tilemap; }
345346   debug_view_manager &debug_view() const { assert(m_debug_view != NULL); return *m_debug_view; }
346347   driver_device *driver_data() const { return m_driver_device; }
347348   template<class _DriverClass> _DriverClass *driver_data() const { return downcast<_DriverClass *>(m_driver_device); }
r14063r14064
429430   // internal core information
430431   memory_private *      memory_data;      // internal data from memory.c
431432   palette_private *      palette_data;      // internal data from palette.c
432   tilemap_private *      tilemap_data;      // internal data from tilemap.c
433433   romload_private *      romload_data;      // internal data from romload.c
434434   input_private *         input_data;         // internal data from input.c
435435   input_port_private *   input_port_data;   // internal data from inptport.c
r14063r14064
466466   input_manager *         m_input;            // internal data from input.c
467467   sound_manager *         m_sound;            // internal data from sound.c
468468   video_manager *         m_video;            // internal data from video.c
469   tilemap_manager *      m_tilemap;            // internal data from tilemap.c
469470   debug_view_manager *   m_debug_view;         // internal data from debugvw.c
470471
471472   // driver state
src/emu/ui.c
r14063r14064
11101110            const rectangle &visarea = screen->visible_area();
11111111
11121112            string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
1113                  visarea.max_x - visarea.min_x + 1,
1114                  visarea.max_y - visarea.min_y + 1,
1113                  visarea.width(), visarea.height(),
11151114                  (machine.system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
11161115                  ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds));
11171116         }
src/emu/render.c
r14063r14064
366366     m_param(NULL),
367367     m_curseq(0)
368368{
369   m_sbounds.min_x = m_sbounds.min_y = m_sbounds.max_x = m_sbounds.max_y = 0;
369   m_sbounds.set(0, -1, 0, -1);
370370   memset(m_scaled, 0, sizeof(m_scaled));
371371}
372372
r14063r14064
416416   // invalidate references to the original bitmap as well
417417   m_manager->invalidate_all(m_bitmap);
418418   m_bitmap = NULL;
419   m_sbounds.min_x = m_sbounds.min_y = m_sbounds.max_x = m_sbounds.max_y = 0;
419   m_sbounds.set(0, -1, 0, -1);
420420   m_format = TEXFORMAT_ARGB32;
421421   m_curseq = 0;
422422
r14063r14064
503503      texinfo.seqid = ++m_curseq;
504504      return true;
505505   }
506   
506
507507   // make sure we can recover the original argb32 bitmap
508   bitmap_argb32 &srcbitmap = downcast<bitmap_argb32 &>(*m_bitmap);
508   bitmap_argb32 dummy;
509   bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy;
509510
510511   // is it a size we already have?
511512   scaled_texture *scaled = NULL;
r14063r14064
12851286            float xscale, yscale;
12861287            if (!(orientation_add(m_orientation, screen->container().orientation()) & ORIENTATION_SWAP_XY))
12871288            {
1288               xscale = (float)(visarea.max_x + 1 - visarea.min_x) / (bounds.x1 - bounds.x0);
1289               yscale = (float)(visarea.max_y + 1 - visarea.min_y) / (bounds.y1 - bounds.y0);
1289               xscale = float(visarea.width()) / bounds.width();
1290               yscale = float(visarea.height()) / bounds.height();
12901291            }
12911292            else
12921293            {
1293               xscale = (float)(visarea.max_y + 1 - visarea.min_y) / (bounds.x1 - bounds.x0);
1294               yscale = (float)(visarea.max_x + 1 - visarea.min_x) / (bounds.y1 - bounds.y0);
1294               xscale = float(visarea.height()) / bounds.width();
1295               yscale = float(visarea.width()) / bounds.height();
12951296            }
12961297
12971298            // pick the greater
src/emu/render.h
r14063r14064
190190   float            y0;               // topmost Y coordinate
191191   float            x1;               // rightmost X coordinate
192192   float            y1;               // bottommost Y coordinate
193   
194   float width() const { return x1 - x0; }
195   float height() const { return y1 - y0; }
193196};
194197
195198
src/emu/drivers/empty.c
r14063r14064
6161      // force the UI to show the game select screen
6262      ui_menu_force_game_select(machine(), &machine().render().ui_container());
6363   }
64   
64
6565   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
6666   {
6767      bitmap.fill(RGB_BLACK);
src/emu/drivers/testcpu.c
r14063r14064
8080         0x986a0070      // stb r3,0x0070(r10)
8181      };
8282
83      // iterate over instructions     
83      // iterate over instructions
8484      for (int instnum = 0; instnum < ARRAY_LENGTH(sample_instructions); instnum++)
8585      {
8686         // write the instruction to execute, followed by a BLR which will terminate the
8787         // basic block in the DRC
8888         m_space->write_dword(RAM_BASE, sample_instructions[instnum]);
8989         m_space->write_dword(RAM_BASE + 4, 0x4e800020);
90         
90
9191         // initialize the register state
9292         m_cpu->set_state(PPC_PC, RAM_BASE);
9393         for (int regnum = 0; regnum < 32; regnum++)
r14063r14064
110110         // execute one instruction
111111         *m_cpu->m_icountptr = 0;
112112         m_cpu->run();
113         
113
114114         // dump the final register state
115115         printf("Final state:\n");
116116         dump_state(false);
117117      }
118     
118
119119      // all done; just bail
120120      throw emu_fatalerror(0, "All done");
121121   }
122   
122
123123   // startup code; do basic configuration and set a timer to go off immediately
124124   virtual void machine_start()
125125   {
126126      // find the CPU's address space
127127      m_space = m_cpu->space(AS_PROGRAM);
128     
128
129129      // configure DRC in the most compatible mode
130130      ppcdrc_set_options(m_cpu, PPCDRC_COMPATIBLE_OPTIONS);
131131
132132      // set a timer to go off right away
133133      timer_set(attotime::zero);
134134   }
135   
135
136136   // dump the current CPU state
137137   void dump_state(bool disassemble)
138138   {
r14063r14064
147147         for (int bytenum = 0; bytenum < maxbytes; bytenum++)
148148            instruction[bytenum] = m_space->read_byte(RAM_BASE + bytenum);
149149
150         // disassemble the current instruction         
150         // disassemble the current instruction
151151         bytes = m_cpu->disassemble(buffer, RAM_BASE, instruction, instruction) & DASMFLAG_LENGTHMASK;
152152      }
153     
153
154154      // output the registers
155155      printf("PC : %08X", UINT32(m_cpu->state(PPC_PC)));
156156      if (disassemble && bytes > 0)
r14063r14064
167167         if (regnum % 4 == 3) printf("\n");
168168      }
169169      printf("CR : %08X   LR : %08X   CTR: %08X   XER: %08X\n",
170            UINT32(m_cpu->state(PPC_CR)), UINT32(m_cpu->state(PPC_LR)),
170            UINT32(m_cpu->state(PPC_CR)), UINT32(m_cpu->state(PPC_LR)),
171171            UINT32(m_cpu->state(PPC_CTR)), UINT32(m_cpu->state(PPC_XER)));
172172      for (int regnum = 0; regnum < 32; regnum++)
173173      {
r14063r14064
175175         if (regnum % 4 == 3) printf("\n");
176176      }
177177   }
178   
178
179179   // report reads from anywhere
180180   READ64_MEMBER( general_r )
181181   {
src/emu/imagedev/cartslot.h
r14063r14064
4040   virtual bool call_load();
4141   virtual void call_unload();
4242   virtual void call_display_info() { if (m_device_displayinfo) m_device_displayinfo(*this); }
43   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) {    load_software_part_region( this, swlist, swname, start_entry ); return TRUE; }
43   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) {   load_software_part_region( this, swlist, swname, start_entry ); return TRUE; }
4444   virtual device_image_partialhash_func get_partial_hash() const { return m_device_partialhash; }
45   
45
4646   virtual iodevice_t image_type() const { return IO_CARTSLOT; }
4747
4848   virtual bool is_readable()  const { return 1; }
r14063r14064
5353   virtual const char *image_interface() const { return m_interface; }
5454   virtual const char *file_extensions() const { return m_extensions; }
5555   virtual const option_guide *create_option_guide() const { return NULL; }
56   
56
5757   void set_extensions(const char *_extensions) { m_extensions = _extensions; }
5858   void set_interface(const char *_interface) { m_interface = _interface; }
5959   void set_must_be_loaded(bool _must_be_loaded) { m_must_be_loaded = _must_be_loaded; }
r14063r14064
6767   // device-level overrides
6868    virtual void device_config_complete();
6969   virtual void device_start();
70   
70
7171   int load_cartridge(const rom_entry *romrgn, const rom_entry *roment, bool load);
7272   int process_cartridge(bool load);
73   
7473
74
7575   const char *               m_extensions;
7676   const char *               m_interface;
7777   bool                     m_must_be_loaded;
src/emu/softlist.c
r14063r14064
20152015                        mame_printf_error("%s: %s has a part (%s) with no data\n", list->file->filename(), swinfo->shortname, swpart->name);
20162016                        error = TRUE;
20172017                     }
2018                     
2018
20192019                     if (part_names.add(swpart->name, swinfo, FALSE) == TMERR_DUPLICATE)
20202020                     {
20212021                        mame_printf_error("%s: %s has a part (%s) whose name is duplicate\n", list->file->filename(), swinfo->shortname, swpart->name);
2022                        error = TRUE;
2022                        error = TRUE;
20232023                     }
20242024
20252025                     for (struct rom_entry *swdata = software_find_romdata(swpart, NULL); swdata != NULL;  swdata = software_romdata_next(swdata))
src/emu/uigfx.c
r14063r14064
154154   ui_gfx_state *state = &ui_gfx;
155155
156156   /* if we have nothing, implicitly cancel */
157   if (machine.total_colors() == 0 && machine.colortable == NULL && machine.gfx[0] == NULL && tilemap_count(machine) == 0)
157   if (machine.total_colors() == 0 && machine.colortable == NULL && machine.gfx[0] == NULL && machine.tilemap().count() == 0)
158158      goto cancel;
159159
160160   /* if we're not paused, mark the bitmap dirty */
r14063r14064
189189
190190      case 2:
191191         /* if we have tilemaps, display them */
192         if (tilemap_count(machine) > 0)
192         if (machine.tilemap().count() > 0)
193193         {
194194            tilemap_handler(machine, container, state);
195195            break;
r14063r14064
717717         rectangle cellbounds;
718718
719719         /* make a rect that covers this row */
720         cellbounds.min_x = 0;
721         cellbounds.max_x = state->bitmap->width() - 1;
722         cellbounds.min_y = y * cellypix;
723         cellbounds.max_y = (y + 1) * cellypix - 1;
720         cellbounds.set(0, state->bitmap->width() - 1, y * cellypix, (y + 1) * cellypix - 1);
724721
725722         /* only display if there is data to show */
726723         if (state->gfxset.offset[set] + y * xcells < gfx->total_elements)
r14063r14064
854851   char title[100];
855852
856853   /* get the size of the tilemap itself */
857   tilemap_size_by_index(machine, state->tilemap.which, &mapwidth, &mapheight);
854   tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
855   mapwidth = tilemap->width();
856   mapheight = tilemap->height();
858857   if (state->tilemap.rotate & ORIENTATION_SWAP_XY)
859858      { UINT32 temp = mapwidth; mapwidth = mapheight; mapheight = temp; }
860859
r14063r14064
906905   boxbounds.y1 = mapboxbounds.y1 + 0.5f * chheight;
907906
908907   /* figure out the title and expand the outer box to fit */
909   sprintf(title, "TMAP %d/%d %dx%d OFFS %d,%d", state->tilemap.which, tilemap_count(machine) - 1, mapwidth, mapheight, state->tilemap.xoffs, state->tilemap.yoffs);
908   sprintf(title, "TMAP %d/%d %dx%d OFFS %d,%d", state->tilemap.which, machine.tilemap().count() - 1, mapwidth, mapheight, state->tilemap.xoffs, state->tilemap.yoffs);
910909   titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title);
911910   if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
912911   {
r14063r14064
960959   /* clamp within range */
961960   if (state->tilemap.which < 0)
962961      state->tilemap.which = 0;
963   if (state->tilemap.which >= tilemap_count(machine))
964      state->tilemap.which = tilemap_count(machine) - 1;
962   if (state->tilemap.which >= machine.tilemap().count())
963      state->tilemap.which = machine.tilemap().count() - 1;
965964
966965   /* cache some info in locals */
967   tilemap_size_by_index(machine, state->tilemap.which, &mapwidth, &mapheight);
966   tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
967   mapwidth = tilemap->width();
968   mapheight = tilemap->height();
968969
969970   /* handle zoom (minus,plus) */
970971   if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
r14063r14064
10531054   /* handle the redraw */
10541055   if (state->bitmap_dirty)
10551056   {
1056      tilemap_draw_by_index(machine, *state->bitmap, state->tilemap.which, state->tilemap.xoffs, state->tilemap.yoffs);
1057      tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
1058      tilemap->draw_debug(*state->bitmap, state->tilemap.xoffs, state->tilemap.yoffs);
10571059
10581060      /* reset the texture to force an update */
10591061      state->texture->set_bitmap(*state->bitmap, state->bitmap->cliprect(), TEXFORMAT_RGB32);
src/emu/info.c
r14063r14064
681681      if (device->screen_type() != SCREEN_TYPE_VECTOR)
682682      {
683683         const rectangle &visarea = device->visible_area();
684         fprintf(m_output, " width=\"%d\"", visarea.max_x - visarea.min_x + 1);
685         fprintf(m_output, " height=\"%d\"", visarea.max_y - visarea.min_y + 1);
684         fprintf(m_output, " width=\"%d\"", visarea.width());
685         fprintf(m_output, " height=\"%d\"", visarea.height());
686686      }
687687
688688      // output refresh rate
src/emu/rendfont.c
r14063r14064
290290   // on entry, assume x0,y0 are the top,left coordinate of the cell and add
291291   // the character bounding box to that position
292292   float scale = m_scale * height;
293   bounds.x0 += (float)gl.xoffs * scale * aspect;
293   bounds.x0 += float(gl.xoffs) * scale * aspect;
294294
295295   // compute x1,y1 from there based on the bitmap size
296   bounds.x1 = bounds.x0 + (float)gl.bmwidth * scale * aspect;
297   bounds.y1 = bounds.y0 + (float)m_height * scale;
296   bounds.x1 = bounds.x0 + float(gl.bmwidth) * scale * aspect;
297   bounds.y1 = bounds.y0 + float(m_height) * scale;
298298
299299   // return the texture
300300   return gl.texture;
r14063r14064
313313   // on entry, assume x0,y0 are the top,left coordinate of the cell and add
314314   // the character bounding box to that position
315315   float scale = m_scale * height;
316   bounds.min_x = (float)gl.xoffs * scale * aspect;
316   bounds.min_x = float(gl.xoffs) * scale * aspect;
317317   bounds.min_y = 0;
318318
319319   // compute x1,y1 from there based on the bitmap size
320   bounds.max_x = bounds.min_x + (float)gl.bmwidth * scale * aspect;
321   bounds.max_y = bounds.min_y + (float)m_height * scale;
320   bounds.set_width(float(gl.bmwidth) * scale * aspect);
321   bounds.set_height(float(m_height) * scale);
322322
323323   // if the bitmap isn't big enough, bail
324   if (dest.width() < bounds.max_x - bounds.min_x || dest.height() < bounds.max_y - bounds.min_y)
324   if (dest.width() < bounds.width() || dest.height() < bounds.height())
325325      return;
326326
327327   // if no texture, fill the target
r14063r14064
332332   }
333333
334334   // scale the font
335   bitmap_argb32 tempbitmap(dest, bounds);
335   bitmap_argb32 tempbitmap(&dest.pix(0), bounds.width(), bounds.height(), dest.rowpixels());
336336   render_texture::hq_scale(tempbitmap, gl.bitmap, gl.bitmap.cliprect(), NULL);
337337}
338338
r14063r14064
344344
345345float render_font::char_width(float height, float aspect, unicode_char ch)
346346{
347   return (float)get_char(ch).width * m_scale * height * aspect;
347   return float(get_char(ch).width) * m_scale * height * aspect;
348348}
349349
350350
r14063r14064
361361      totwidth += get_char(*ptr).width;
362362
363363   // scale the final result based on height
364   return (float)totwidth * m_scale * height * aspect;
364   return float(totwidth) * m_scale * height * aspect;
365365}
366366
367367
r14063r14064
388388   }
389389
390390   // scale the final result based on height
391   return (float)totwidth * m_scale * height * aspect;
391   return float(totwidth) * m_scale * height * aspect;
392392}
393393
394394
src/emu/machine/idectrl.c
r14063r14064
120120   UINT16         num_cylinders;
121121   UINT8         num_sectors;
122122   UINT8         num_heads;
123   
123
124124   chd_file       *handle;
125125   hard_disk_file *disk;
126   bool         is_image_device;   
127};   
126   bool         is_image_device;
127};
128128
129129
130130typedef struct _ide_state ide_state;
r14063r14064
173173
174174   UINT8         gnetreadlock;
175175   ide_hardware *   hardware;
176   
176
177177   UINT8         cur_drive;
178178   ide_device      drive[2];
179179};
r14063r14064
18721872
18731873   /* set MAME harddisk handle */
18741874   config = (const ide_config *)downcast<const legacy_device_base *>(device)->inline_config();
1875   
1875
18761876   ide->drive[0].handle = get_disk_handle(device->machine(), (config->master != NULL) ? config->master : device->tag());
18771877   ide->drive[0].disk = hard_disk_open(ide->drive[0].handle);
18781878   ide->drive[0].is_image_device = false;
r14063r14064
19141914
19151915      /* build the features page */
19161916      ide_build_features(ide,0);
1917   }
1917   }
19181918   if (ide->drive[1].disk != NULL)
19191919   {
19201920      hdinfo = hard_disk_get_info(ide->drive[1].disk);
r14063r14064
19281928
19291929      /* build the features page */
19301930      ide_build_features(ide,1);
1931   }   
1931   }
19321932   if (config->hardware != NULL) {
19331933      ide->hardware = (ide_hardware *)config->hardware;
19341934      ide->hardware->get_info(ide->device, ide->drive[0].features, ide->drive[0].num_cylinders, ide->drive[0].num_sectors, ide->drive[0].num_heads);
r14063r14064
20552055            }
20562056         }
20572057      }
2058   }
2058   }
20592059   if (device->machine().device( hardtag_slave.cstr() )) {
20602060      if (!ide->drive[1].disk)
20612061      {
r14063r14064
20842084            }
20852085         }
20862086      }
2087   }   
2087   }
20882088   if (ide->hardware != NULL) {
20892089      ide->hardware->get_info(ide->device, ide->drive[0].features, ide->drive[0].num_cylinders, ide->drive[0].num_sectors, ide->drive[0].num_heads);
20902090      ide_generate_features (ide,0);
src/emu/machine/ldpr8210.c
r14063r14064
240240     m_i8049_port2(0)
241241{
242242}
243   
244243
244
245245//-------------------------------------------------
246//  control_w - write callback when the CONTROL
246//  control_w - write callback when the CONTROL
247247//  line is toggled
248248//-------------------------------------------------
249249
r14063r14064
252252   // set the new value and remember the last
253253   UINT8 prev = m_control;
254254   m_control = data;
255   
255
256256   // handle rising edge
257257   if (prev != ASSERT_LINE && data == ASSERT_LINE)
258258   {
r14063r14064
351351   switch (id)
352352   {
353353      // update the VBI data in the PIA as soon as it is ready;
354      // this must happen early in the frame because the player
354      // this must happen early in the frame because the player
355355      // logic relies on fetching it here
356356      case TID_VBI_DATA_FETCH:
357357
r14063r14064
396396            }
397397         }
398398         break;
399     
399
400400      // clear the VSYNC flag
401401      case TID_VSYNC_OFF:
402402         m_vsync = false;
403403         break;
404   
404
405405      // pass everything else onto the parent
406406      default:
407407         laserdisc_device::device_timer(timer, id, param, ptr);
r14063r14064
458458
459459
460460//-------------------------------------------------
461//  player_update - update callback, called on the
461//  player_update - update callback, called on the
462462//  first visible line of the frame
463463//-------------------------------------------------
464464
r14063r14064
639639       $04 = (in) SIZE 8/12
640640       $02 = (in) FG via op-amp (spindle motor stop detector)
641641       $01 = (in) SLOW TIMER OUT
642   */
642    */
643643
644644   UINT8 result = 0x00;
645645
r14063r14064
684684       $02 = (out) SCAN A (/SCAN)
685685       $01 = (out) JUMP TRG (jump back trigger, clock on high->low)
686686    */
687   
687
688688   // set the new value
689689   UINT8 prev = m_i8049_port1;
690690   m_i8049_port1 = data;
r14063r14064
933933
934934
935935//-------------------------------------------------
936//  data_w - write callback when the parallel data
936//  data_w - write callback when the parallel data
937937//  port is written to
938938//-------------------------------------------------
939939
r14063r14064
10281028      case TID_IRQ_OFF:
10291029         m_i8748_cpu->set_input_line(MCS48_INPUT_IRQ, CLEAR_LINE);
10301030         break;
1031     
1031
10321032      // latch data
10331033      case TID_LATCH_DATA:
10341034         m_data = param;
src/emu/machine/ldvp931.c
r14063r14064
146146{
147147   // control the CPU state
148148   m_i8049_cpu->set_input_line(INPUT_LINE_RESET, data);
149   
149
150150   // on an assert, reset the device state as well
151151   if (data == ASSERT_LINE)
152152      reset();
r14063r14064
154154
155155
156156//-------------------------------------------------
157//  data_r - handle a parallel data read from the
157//  data_r - handle a parallel data read from the
158158//  22VP931
159159//-------------------------------------------------
160160
r14063r14064
182182{
183183   // pass through to the parent
184184   laserdisc_device::device_start();
185   
185
186186   // allocate a timer
187187   m_tracktimer = timer_alloc(TID_HALF_TRACK);
188188}
r14063r14064
201201   m_i8049_out0 = 0;
202202   m_i8049_out1 = 0;
203203   m_i8049_port1 = 0;
204   
204
205205   m_daticval = 0;
206206   m_daticerp = 0;
207207   m_datastrobe = 0;
208   
208
209209   m_fromcontroller = 0;
210210   m_fromcontroller_pending = false;
211211   m_tocontroller = 0;
212212   m_tocontroller_pending = false;
213   
213
214214   m_trackdir = 0;
215215   m_trackstate = 0;
216   
216
217217   m_cmdcount = 0;
218218   m_advanced = 0;
219219}
r14063r14064
263263            timer_set(screen().time_until_pos(line*2, which * 2 * screen().width() / 4), TID_VBI_DATA_FETCH, (line << 2) + which);
264264         break;
265265      }
266     
266
267267      case TID_DEFERRED_DATA:
268268         // set the value and mark it pending
269269         if (LOG_COMMANDS && m_fromcontroller_pending)
r14063r14064
279279               printf("Cmd: %02X %02X %02X\n", m_cmdbuf[0], m_cmdbuf[1], m_cmdbuf[2]);
280280         }
281281         break;
282     
282
283283      case TID_IRQ_OFF:
284284         m_i8049_cpu->set_input_line(MCS48_INPUT_IRQ, CLEAR_LINE);
285285         break;
286     
286
287287      case TID_DATA_STROBE_OFF:
288288         m_datastrobe = 0;
289289         break;
290     
290
291291      case TID_ERP_OFF:
292292         m_daticerp = 0;
293293         break;
294     
294
295295      case TID_HALF_TRACK:
296296         // advance by the count and toggle the state
297297         m_trackstate ^= 1;
r14063r14064
301301            m_advanced += m_trackdir;
302302         }
303303         break;
304   
304
305305      // pass everything else onto the parent
306306      default:
307307         laserdisc_device::device_timer(timer, id, param, ptr);
r14063r14064
471471
472472
473473//-------------------------------------------------
474//  i8049_keypad_r - vestigial keypad/button
474//  i8049_keypad_r - vestigial keypad/button
475475//  controls
476476//-------------------------------------------------
477477
r14063r14064
517517
518518
519519//-------------------------------------------------
520//  i8049_to_controller_w - write a value back to
520//  i8049_to_controller_w - write a value back to
521521//  the external controller
522522//-------------------------------------------------
523523
r14063r14064
672672
673673
674674//-------------------------------------------------
675//  i8049_t1_r - return the T1 line status, which
675//  i8049_t1_r - return the T1 line status, which
676676//  is connected to the tracking state and is used
677677//  to count the number of tracks advanced
678678//-------------------------------------------------
src/emu/machine/laserdsc.c
r14063r14064
143143//**************************************************************************
144144
145145//-------------------------------------------------
146//  get_field_code - return raw field information
146//  get_field_code - return raw field information
147147//  read from the disc
148148//-------------------------------------------------
149149
r14063r14064
244244
245245
246246//-------------------------------------------------
247//  static_set_get_disc - set the get disc
247//  static_set_get_disc - set the get disc
248248//  delegate
249249//-------------------------------------------------
250250
r14063r14064
255255
256256
257257//-------------------------------------------------
258//  static_set_get_disc - set the audio interceptor
258//  static_set_get_disc - set the audio interceptor
259259//  delegate
260260//-------------------------------------------------
261261
r14063r14064
292292
293293//-------------------------------------------------
294294//  static_set_overlay - set the overlay visible
295//   subregion
295//  subregion
296296//-------------------------------------------------
297297
298298void laserdisc_device::static_set_overlay_clip(device_t &device, INT32 minx, INT32 maxx, INT32 miny, INT32 maxy)
r14063r14064
302302
303303
304304//-------------------------------------------------
305//  static_set_overlay_position - set the overlay
305//  static_set_overlay_position - set the overlay
306306//  position parameters
307307//-------------------------------------------------
308308
r14063r14064
316316
317317//-------------------------------------------------
318318//  static_set_overlay_scale - set the overlay
319//   scale parameters
319//  scale parameters
320320//-------------------------------------------------
321321
322322void laserdisc_device::static_set_overlay_scale(device_t &device, float scalex, float scaley)
r14063r14064
528528{
529529   // first update to the current time
530530   update_slider_pos();
531   
531
532532   // then update the track position
533533   add_and_clamp_track(numtracks);
534534   if (LOG_SLIDER)
r14063r14064
729729               advanceby = 1;
730730         }
731731         break;
732     
732
733733      default:
734734         // do nothing
735735         break;
r14063r14064
855855      // bind our handlers
856856      m_overupdate_ind16.bind_relative_to(*owner());
857857      m_overupdate_rgb32.bind_relative_to(*owner());
858   
858
859859      // configure bitmap formats
860860      bitmap_format format = !m_overupdate_ind16.isnull() ? BITMAP_FORMAT_IND16 : BITMAP_FORMAT_RGB32;
861861      texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32;
r14063r14064
867867         m_overbitmap[index].set_palette(machine().palette);
868868         m_overbitmap[index].resize(m_overwidth, m_overheight);
869869      }
870     
870
871871      // allocate overlay texture
872872      m_overtex = machine().render().texture_alloc();
873873      if (m_overtex == NULL)
r14063r14064
930930void laserdisc_device::update_slider_pos()
931931{
932932   attotime curtime = machine().time();
933   
933
934934   // if not moving, update to now
935935   if (m_attospertrack == 0)
936936      m_sliderupdate = curtime;
src/emu/machine/laserdsc.h
r14063r14064
165165// ======================> laserdisc_device
166166
167167// base laserdisc class
168class laserdisc_device :    public device_t,
168class laserdisc_device :   public device_t,
169169                     public device_sound_interface,
170170                     public laserdisc_overlay_config
171171{
r14063r14064
372372   bool            m_videoenable;         // is video enabled?
373373   render_texture *   m_videotex;            // texture for the video
374374   palette_t *         m_videopalette;         // palette for the video
375   
375
376376   // overlays
377377   bool            m_overenable;         // is the overlay enabled?
378378   screen_bitmap      m_overbitmap[2];      // overlay bitmaps
src/emu/machine/s3c24xx.c
r14063r14064
937937   }
938938   height = lineval + 1;
939939   s3c24xx->lcd.framerate = framerate;
940   visarea.min_x = 0;
941   visarea.min_y = 0;
942   visarea.max_x = width - 1;
943   visarea.max_y = height - 1;
940   visarea.set(0, width - 1, 0, height - 1);
944941   verboselog( device->machine(), 3, "LCD - visarea min_x %d min_y %d max_x %d max_y %d\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
945942   verboselog( device->machine(), 3, "video_screen_configure %d %d %f\n", width, height, s3c24xx->lcd.framerate);
946943   s3c24xx->lcd.hpos_min = 0;
src/emu/machine/ldv1000.c
r14063r14064
107107
108108static const ppi8255_interface ppi0intf =
109109{
110   DEVCB_NULL,                 
111   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portb_r),   
110   DEVCB_NULL,
111   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portb_r),
112112   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portc_r),
113   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_porta_w),   
114   DEVCB_NULL,                 
113   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_porta_w),
114   DEVCB_NULL,
115115   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi0_portc_w)
116116};
117117
118118
119119static const ppi8255_interface ppi1intf =
120120{
121   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_porta_r),   
122   DEVCB_NULL,                 
121   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_porta_r),
123122   DEVCB_NULL,
124   DEVCB_NULL,                 
125   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_portb_w),   
123   DEVCB_NULL,
124   DEVCB_NULL,
125   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_portb_w),
126126   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pioneer_ldv1000_device, ppi1_portc_w)
127127};
128128
r14063r14064
193193
194194
195195//-------------------------------------------------
196//  data_w - handle a parallel data write to the
196//  data_w - handle a parallel data write to the
197197//  LD-V1000
198198//-------------------------------------------------
199199
r14063r14064
222222{
223223   // pass through to the parent
224224   laserdisc_device::device_start();
225   
225
226226   // allocate timers
227227   m_multitimer = timer_alloc(TID_MULTIJUMP);
228228}
r14063r14064
273273            timer.adjust(MULTIJUMP_TRACK_TIME);
274274         break;
275275      }
276   
276
277277      case TID_VSYNC_OFF:
278278         m_vsync = false;
279279         break;
280     
280
281281      case TID_VBI_DATA_FETCH:
282282      {
283283         // appears to return data in reverse order
r14063r14064
315315         m_vbiindex = 0;
316316         break;
317317      }
318     
318
319319      // pass everything else onto the parent
320320      default:
321321         laserdisc_device::device_timer(timer, id, param, ptr);
r14063r14064
398398
399399
400400//-------------------------------------------------
401//  z80_decoder_display_port_w - handle writes to
401//  z80_decoder_display_port_w - handle writes to
402402//  the decoder/display chips
403403//-------------------------------------------------
404404
src/emu/screen.c
r14063r14064
139139   screen.m_vblank = screen.m_refresh / vtotal * (vtotal - (vbstart - vbend));
140140   screen.m_width = htotal;
141141   screen.m_height = vtotal;
142   screen.m_visarea.min_x = hbend;
143   screen.m_visarea.max_x = hbstart - 1;
144   screen.m_visarea.min_y = vbend;
145   screen.m_visarea.max_y = vbstart - 1;
142   screen.m_visarea.set(hbend, hbstart - 1, vbend, vbstart - 1);
146143}
147144
148145
r14063r14064
232229
233230
234231//-------------------------------------------------
235//  static_set_screen_vblank - set the screen
232//  static_set_screen_vblank - set the screen
236233//  VBLANK callback in the device configuration
237234//-------------------------------------------------
238235
r14063r14064
261258   // sanity check display area
262259   if (m_type != SCREEN_TYPE_VECTOR)
263260   {
264      if ((m_visarea.max_x < m_visarea.min_x) ||
265         (m_visarea.max_y < m_visarea.min_y) ||
266         (m_visarea.max_x >= m_width) ||
267         (m_visarea.max_y >= m_height))
261      if (m_visarea.empty() || m_visarea.max_x >= m_width || m_visarea.max_y >= m_height)
268262      {
269263         mame_printf_error("%s: %s screen '%s' has an invalid display area\n", driver.source_file, driver.name, tag());
270264         error = true;
r14063r14064
284278      mame_printf_error("%s: %s screen '%s' has a zero refresh rate\n", driver.source_file, driver.name, tag());
285279      error = true;
286280   }
287   
281
288282   return error;
289283}
290284
r14063r14064
299293   m_screen_update_ind16.bind_relative_to(*owner());
300294   m_screen_update_rgb32.bind_relative_to(*owner());
301295   m_screen_vblank.bind_relative_to(*owner());
302   
296
303297   // configure bitmap formats and allocate screen bitmaps
304298   texture_format texformat = !m_screen_update_ind16.isnull() ? TEXFORMAT_PALETTE16 : TEXFORMAT_RGB32;
305299   for (int index = 0; index < ARRAY_LENGTH(m_bitmap); index++)
r14063r14064
414408      case TID_VBLANK_START:
415409         vblank_begin();
416410         break;
417     
411
418412      // signal VBLANK end
419413      case TID_VBLANK_END:
420414         vblank_end();
421415         break;
422     
416
423417      // first visible scanline
424418      case TID_SCANLINE0:
425419         reset_partial_updates();
426420         break;
427     
421
428422      // subsequent scanlines when scanline updates are enabled
429423      case TID_SCANLINE:
430424
r14063r14064
472466   // if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now
473467    // from the visible area, otherwise just used the supplied value
474468   if (m_vblank == 0 && !m_oldstyle_vblank_supplied)
475      m_vblank_period = m_scantime * (height - (visarea.max_y + 1 - visarea.min_y));
469      m_vblank_period = m_scantime * (height - visarea.height());
476470   else
477471      m_vblank_period = m_vblank;
478472
r14063r14064
797791
798792
799793//-------------------------------------------------
800//  vblank_begin - call any external callbacks to
794//  vblank_begin - call any external callbacks to
801795//  signal the VBLANK period has begun
802796//-------------------------------------------------
803797
r14063r14064
829823
830824
831825//-------------------------------------------------
832//  vblank_end - call any external callbacks to
826//  vblank_end - call any external callbacks to
833827//  signal the VBLANK period has ended
834828//-------------------------------------------------
835829
r14063r14064
908902   int ystart = ((UINT32)rand() % 32767) * ystep / 32767;
909903   int srcx, srcy;
910904   int x, y;
911   
905
912906   switch (curbitmap.format())
913907   {
914908      default:
r14063r14064
929923         }
930924         break;
931925      }
932     
926
933927      case BITMAP_FORMAT_RGB32:
934928      {
935929         // iterate over rows in the destination
r14063r14064
967961   scaledvis.max_y = m_visarea.max_y * m_burnin.height() / m_height;
968962
969963   // wrap a bitmap around the subregion we care about
970   bitmap_argb32 finalmap(scaledvis.max_x + 1 - scaledvis.min_x, scaledvis.max_y + 1 - scaledvis.min_y);
964   bitmap_argb32 finalmap(scaledvis.width(), scaledvis.height());
971965   int srcwidth = m_burnin.width();
972966   int srcheight = m_burnin.height();
973967   int dstwidth = finalmap.width();
src/emu/screen.h
r14063r14064
8888        m_live(&m_rgb32) { }
8989   screen_bitmap(bitmap_ind16 &orig)
9090      : m_format(BITMAP_FORMAT_IND16),
91        m_texformat(TEXFORMAT_PALETTE16),
91        m_texformat(TEXFORMAT_PALETTE16),
9292        m_live(&m_ind16),
9393        m_ind16(orig, orig.cliprect()) { }
9494   screen_bitmap(bitmap_rgb32 &orig)
9595      : m_format(BITMAP_FORMAT_RGB32),
96        m_texformat(TEXFORMAT_RGB32),
96        m_texformat(TEXFORMAT_RGB32),
9797        m_live(&m_rgb32),
9898        m_rgb32(orig, orig.cliprect()) { }
99   
99
100100   // resizing
101101   void resize(int width, int height) { live().resize(width, height); }
102102
r14063r14064
104104   operator bitmap_t &() { return live(); }
105105   bitmap_ind16 &as_ind16() { assert(m_format == BITMAP_FORMAT_IND16); return m_ind16; }
106106   bitmap_rgb32 &as_rgb32() { assert(m_format == BITMAP_FORMAT_RGB32); return m_rgb32; }
107   
107
108108   // getters
109109   INT32 width() const { return live().width(); }
110110   INT32 height() const { return live().height(); }
r14063r14064
132132      m_ind16.reset();
133133      m_rgb32.reset();
134134   }
135   
135
136136private:
137137   // internal state
138138   bitmap_format      m_format;
r14063r14064
168168   int width() const { return m_width; }
169169   int height() const { return m_height; }
170170   const rectangle &visible_area() const { return m_visarea; }
171   const rectangle &cliprect() const { return m_bitmap[0].cliprect(); }
171172   bool oldstyle_vblank_supplied() const { return m_oldstyle_vblank_supplied; }
172173   attoseconds_t refresh_attoseconds() const { return m_refresh; }
173174   attoseconds_t vblank_attoseconds() const { return m_vblank; }
r14063r14064
219220   bool update_partial(int scanline);
220221   void update_now();
221222   void reset_partial_updates();
222   
223
223224   // additional helpers
224225   void register_vblank_callback(vblank_state_delegate vblank_callback);
225226   void register_screen_bitmap(bitmap_t &bitmap);
r14063r14064
323324         : m_next(NULL),
324325           m_bitmap(bitmap) { }
325326      auto_bitmap_item *next() const { return m_next; }
326     
327
327328      auto_bitmap_item *         m_next;
328329      bitmap_t &               m_bitmap;
329330   };
r14063r14064
406407
407408//-------------------------------------------------
408409//  screen_update_delegate_smart - collection of
409//   inline helpers which create the appropriate
410//   screen_update_delegate based on the input
411//   function type
410//  inline helpers which create the appropriate
411//  screen_update_delegate based on the input
412//  function type
412413//-------------------------------------------------
413414
414415inline screen_update_ind16_delegate screen_update_delegate_smart(UINT32 (*callback)(device_t *, screen_device &, bitmap_ind16 &, const rectangle &), const char *name)
src/emu/delegate.h
r14063r14064
278278
279279public:
280280   // define our traits
281   template<class _FunctionClass>
281   template<class _FunctionClass>
282282   struct traits
283283   {
284284      typedef typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type, _P5Type>::member_func_type member_func_type;
r14063r14064
530530
531531public:
532532   // define our traits
533   template<class _FunctionClass>
533   template<class _FunctionClass>
534534   struct traits
535535   {
536536      typedef typename delegate_traits<_FunctionClass, _ReturnType, _P1Type, _P2Type, _P3Type, _P4Type, _P5Type>::member_func_type member_func_type;
src/emu/debugint/debugint.c
r14063r14064
166166      this->state = flags | VIEW_STATE_NEEDS_UPDATE;
167167
168168      // initial size
169      this->bounds.min_x = 0;
170      this->bounds.min_y = 0;
171      this->bounds.max_x = 300;
172      this->bounds.max_y = 300;
169      this->bounds.set(0, 300, 0, 300);
173170
174171      /* specials */
175172      switch (type)
r14063r14064
377374   rectangle r;
378375
379376   dview_get_rect(dv, type, r);
380   if (x >= r.min_x && x <= r.max_x && y >= r.min_y && y <= r.max_y)
377   if (r.contains(x, y))
381378      return TRUE;
382379   return FALSE;
383380}
r14063r14064
396393   dview_draw_outlined_box(dv, RECT_DVIEW_HSB, 0, 0, VSB_WIDTH,HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00));
397394   dview_draw_outlined_box(dv, RECT_DVIEW_HSB, r.width() - VSB_WIDTH, 0, VSB_WIDTH, HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00));
398395
399   ts = (r.max_x - r.min_x + 1) - 2 * VSB_WIDTH;
396   ts = (r.width()) - 2 * VSB_WIDTH;
400397
401398   sz = (ts * (sb->page_size)) / (sb->upper - sb->lower);
402399   ts = ts - sz;
r14063r14064
420417   dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, r.height() - HSB_HEIGHT, VSB_WIDTH, HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00));
421418   dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, 0,                       VSB_WIDTH, HSB_HEIGHT, MAKE_ARGB(0xff, 0xff, 0x00, 0x00));
422419
423   ts = (r.max_y - r.min_y + 1) - 2 * HSB_HEIGHT;
420   ts = r.height() - 2 * HSB_HEIGHT;
424421
425422   sz = (ts * (sb->page_size)) / (sb->upper - sb->lower);
426423   ts = ts - sz;
src/emu/drawgfxm.h
r14063r14064
362362      assert(dest.valid());                                             \
363363      assert(gfx != NULL);                                             \
364364      assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid());                  \
365      assert(cliprect.min_x >= 0);                                       \
366      assert(cliprect.max_x < dest.width());                                 \
367      assert(cliprect.min_y >= 0);                                       \
368      assert(cliprect.max_y < dest.height());                                 \
365      assert(dest.cliprect().contains(cliprect));                              \
369366      assert(code < gfx->total_elements);                                    \
370367                                                                  \
371368      /* ignore empty/invalid cliprects */                                 \
r14063r14064
632629      assert(dest.valid());                                             \
633630      assert(gfx != NULL);                                             \
634631      assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid());                  \
635      assert(cliprect.min_x >= 0);                                       \
636      assert(cliprect.max_x < dest.width());                                 \
637      assert(cliprect.min_y >= 0);                                       \
638      assert(cliprect.max_y < dest.height());                              \
632      assert(dest.cliprect().contains(cliprect));                              \
639633                                                                  \
640634      /* ignore empty/invalid cliprects */                                 \
641635      if (cliprect.empty())                                             \
r14063r14064
807801      assert(dest.valid());                                             \
808802      assert(src.valid());                                             \
809803      assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid());                  \
810      assert(cliprect.min_x >= 0);                                       \
811      assert(cliprect.max_x < dest.width());                                 \
812      assert(cliprect.min_y >= 0);                                       \
813      assert(cliprect.max_y < dest.height());                              \
804      assert(dest.cliprect().contains(cliprect));                              \
814805                                                                  \
815806      /* ignore empty/invalid cliprects */                                 \
816807      if (cliprect.empty())                                             \
r14063r14064
981972   assert(dest.valid());                                             \
982973   assert(dest.valid());                                             \
983974   assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid());                  \
984   assert(cliprect.min_x >= 0);                                       \
985   assert(cliprect.max_x < dest.width());                                 \
986   assert(cliprect.min_y >= 0);                                       \
987   assert(cliprect.max_y < dest.height());                              \
988   assert(!wraparound || (src.width() & (src.width() - 1)) == 0);            \
975   assert(dest.cliprect().contains(cliprect));                              \
976   assert(!wraparound || (src.width() & (src.width() - 1)) == 0);               \
989977   assert(!wraparound || (src.height() & (src.height() - 1)) == 0);            \
990978                                                               \
991979   /* ignore empty/invalid cliprects */                                 \
r14063r14064
997985   srcfixheight = src.height() << 16;                                    \
998986                                                               \
999987   /* advance the starting coordinates to the top-left of the cliprect */         \
1000   startx += cliprect.min_x * incxx + cliprect.min_y * incyx;               \
1001   starty += cliprect.min_x * incxy + cliprect.min_y * incyy;               \
988   startx += cliprect.min_x * incxx + cliprect.min_y * incyx;                  \
989   starty += cliprect.min_x * incxy + cliprect.min_y * incyy;                  \
1002990                                                               \
1003991   /* compute how many blocks of 4 pixels we have */                        \
1004   numblocks = (cliprect.max_x + 1 - cliprect.min_x) / 4;                  \
1005   leftovers = (cliprect.max_x + 1 - cliprect.min_x) - 4 * numblocks;         \
992   numblocks = cliprect.width() / 4;                                    \
993   leftovers = cliprect.width() - 4 * numblocks;                           \
1006994                                                               \
1007995   /* if incxy and incyx are 0, then we aren't rotating, just zooming */         \
1008996   if (incxy == 0 && incyx == 0)                                       \
src/lib/formats/ap_dsk35.c
r14063r14064
12541254   { SECTOR_LOOP_END },
12551255   { END },
12561256};
1257   
12581257
1258
12591259bool dc42_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
12601260{
12611261   UINT8 h[0x54];
r14063r14064
13171317      if(pos == ts) {
13181318         pos = 0;
13191319         wrap++;
1320      }     
1320      }
13211321   }
13221322   return v;
13231323}
r14063r14064
13971397               UINT8 tr = gcr6bw_tb[h[0]] | (v2 & 1 ? 0x40 : 0x00);
13981398               UINT8 se = gcr6bw_tb[h[1]];
13991399               UINT8 si = v2 & 0x20 ? 1 : 0;
1400               //               UINT8 ds = v3 & 0x20 ? 1 : 0;
1401               //               UINT8 fmt = v3 & 0x1f;
1400               //                  UINT8 ds = v3 & 0x20 ? 1 : 0;
1401               //                  UINT8 fmt = v3 & 0x1f;
14021402               UINT8 c1 = (tr^se^v2^v3) & 0x3f;
14031403               UINT8 chk = gcr6bw_tb[h[4]];
14041404               if(chk == c1 && tr == track && si == head && se < nsect) {
src/lib/util/bitmap.c
r14063r14064
5959//**************************************************************************
6060
6161//-------------------------------------------------
62//  compute_rowpixels - compute an aligned
62//  compute_rowpixels - compute an aligned
6363//  rowpixels value
6464//-------------------------------------------------
6565
r14063r14064
161161
162162   // delete any existing stuff
163163   reset();
164   
164
165165   // handle empty requests cleanly
166166   if (width <= 0 || height <= 0)
167167      return;
r14063r14064
204204   int new_rowpixels = compute_rowpixels(width, xslop);
205205   UINT32 new_allocbytes = new_rowpixels * (height + 2 * yslop) * m_bpp / 8;
206206   new_allocbytes += BITMAP_OVERALL_ALIGN - 1;
207   
207
208208   // if we need more memory, just realloc
209209   if (new_allocbytes > m_allocbytes)
210210   {
r14063r14064
213213      set_palette(palette);
214214      return;
215215   }
216   
216
217217   // otherwise, reconfigure
218218   m_rowpixels = new_rowpixels;
219219   m_width = width;
r14063r14064
247247
248248
249249//-------------------------------------------------
250//  wrap -- wrap an array of memory; the target
250//  wrap -- wrap an array of memory; the target
251251//  bitmap does not own the memory
252252//-------------------------------------------------
253253
r14063r14064
255255{
256256   // delete any existing stuff
257257   reset();
258   
258
259259   // initialize relevant fields
260260   m_base = base;
261261   m_rowpixels = rowpixels;
r14063r14064
266266
267267
268268//-------------------------------------------------
269//  wrap -- wrap a subrectangle of an existing
270//  bitmap by copying its fields; the target
269//  wrap -- wrap a subrectangle of an existing
270//  bitmap by copying its fields; the target
271271//  bitmap does not own the memory
272272//-------------------------------------------------
273273
r14063r14064
279279
280280   // delete any existing stuff
281281   reset();
282   
282
283283   // copy relevant fields
284284   m_base = source.raw_pixptr(subrect.min_y, subrect.min_x);
285285   m_rowpixels = source.m_rowpixels;
r14063r14064
331331      case 8:
332332         // 8bpp always uses memset
333333         for (INT32 y = fill.min_y; y <= fill.max_y; y++)
334            memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.max_x + 1 - fill.min_x);
334            memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.width());
335335         break;
336336
337337      case 16:
r14063r14064
339339         if ((UINT8)(color >> 8) == (UINT8)color)
340340         {
341341            for (INT32 y = fill.min_y; y <= fill.max_y; y++)
342               memset(raw_pixptr(y, fill.min_x), (UINT8)color, (fill.max_x + 1 - fill.min_x) * 2);
342               memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.width() * 2);
343343         }
344344         else
345345         {
r14063r14064
353353            for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
354354            {
355355               destrow = &pixt<UINT16>(y, fill.min_x);
356               memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 2);
356               memcpy(destrow, destrow0, fill.width() * 2);
357357            }
358358         }
359359         break;
r14063r14064
363363         if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color)
364364         {
365365            for (INT32 y = fill.min_y; y <= fill.max_y; y++)
366               memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, (fill.max_x + 1 - fill.min_x) * 4);
366               memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, fill.width() * 4);
367367         }
368368         else
369369         {
r14063r14064
377377            for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
378378            {
379379               destrow = &pixt<UINT32>(y, fill.min_x);
380               memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 4);
380               memcpy(destrow, destrow0, fill.width() * 4);
381381            }
382382         }
383383         break;
r14063r14064
387387         if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color)
388388         {
389389            for (INT32 y = fill.min_y; y <= fill.max_y; y++)
390               memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, (fill.max_x + 1 - fill.min_x) * 8);
390               memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, fill.width() * 8);
391391         }
392392         else
393393         {
r14063r14064
401401            for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
402402            {
403403               destrow = &pixt<UINT64>(y, fill.min_x);
404               memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 4);
404               memcpy(destrow, destrow0, fill.width() * 8);
405405            }
406406         }
407407         break;
src/lib/util/bitmap.h
r14063r14064
103103   bool contains(const rectangle &rect) const { return (min_x <= rect.min_x && max_x >= rect.max_x && min_y <= rect.min_y && max_y >= rect.max_y); }
104104   INT32 width() const { return max_x + 1 - min_x; }
105105   INT32 height() const { return max_y + 1 - min_y; }
106   INT32 xcenter() const { return (min_x + max_x + 1) / 2; }
107   INT32 ycenter() const { return (min_y + max_y + 1) / 2; }
106108
107109   // setters
108110   void set(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; }
111   void setx(INT32 minx, INT32 maxx) { min_x = minx; max_x = maxx; }
112   void sety(INT32 miny, INT32 maxy) { min_y = miny; max_y = maxy; }
109113   void set_width(INT32 width) { max_x = min_x + width - 1; }
110114   void set_height(INT32 height) { max_y = min_y + height - 1; }
111115   void set_origin(INT32 x, INT32 y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; }
116   void set_size(INT32 width, INT32 height) { set_width(width); set_height(height); }
112117
113118   // internal state
114119   INT32         min_x;         // minimum X, or left coordinate
r14063r14064
205210protected:
206211   // construction/destruction -- subclasses only
207212   bitmap8_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 8, width, height, xslop, yslop) { }
208   bitmap8_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); }
213   bitmap8_t(bitmap_format format, UINT8 *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); }
209214   bitmap8_t(bitmap_format format, bitmap8_t &source, const rectangle &subrect) : bitmap_t(format, 8, source, subrect) { }
210215
211216public:
212217   // getters
213218   UINT8 bpp() const { return 8; }
214   
219
215220   // pixel accessors
216221   typedef UINT8 pixel_t;
217222   pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
r14063r14064
228233protected:
229234   // construction/destruction -- subclasses only
230235   bitmap16_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 16, width, height, xslop, yslop) { assert(valid_format(format)); }
231   bitmap16_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); }
236   bitmap16_t(bitmap_format format, UINT16 *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); }
232237   bitmap16_t(bitmap_format format, bitmap16_t &source, const rectangle &subrect) : bitmap_t(format, 16, source, subrect) { }
233238
234239public:
235240   // getters
236241   UINT8 bpp() const { return 16; }
237   
242
238243   // pixel accessors
239244   typedef UINT16 pixel_t;
240245   pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
r14063r14064
251256protected:
252257   // construction/destruction -- subclasses only
253258   bitmap32_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 32, width, height, xslop, yslop) { assert(valid_format(format)); }
254   bitmap32_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); }
259   bitmap32_t(bitmap_format format, UINT32 *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); }
255260   bitmap32_t(bitmap_format format, bitmap32_t &source, const rectangle &subrect) : bitmap_t(format, 32, source, subrect) { }
256261
257262public:
258263   // getters
259264   UINT8 bpp() const { return 32; }
260   
265
261266   // pixel accessors
262267   typedef UINT32 pixel_t;
263268   pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
r14063r14064
274279protected:
275280   // construction/destruction -- subclasses only
276281   bitmap64_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 64, width, height, xslop, yslop) { assert(valid_format(format)); }
277   bitmap64_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); }
282   bitmap64_t(bitmap_format format, UINT64 *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); }
278283   bitmap64_t(bitmap_format format, bitmap64_t &source, const rectangle &subrect) : bitmap_t(format, 64, source, subrect) { }
279284
280285public:
281286   // getters
282287   UINT8 bpp() const { return 64; }
283   
288
284289   // pixel accessors
285290   typedef UINT64 pixel_t;
286291   pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
r14063r14064
294299class bitmap_ind8 : public bitmap8_t
295300{
296301   static const bitmap_format k_bitmap_format = BITMAP_FORMAT_IND8;
297   
302
298303public:
299304   // construction/destruction
300305   bitmap_ind8(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap8_t(k_bitmap_format, width, height, xslop, yslop) { }
301   bitmap_ind8(void *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { }
306   bitmap_ind8(UINT8 *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { }
302307   bitmap_ind8(bitmap_ind8 &source, const rectangle &subrect) : bitmap8_t(k_bitmap_format, source, subrect) { }
303308   void wrap(UINT8 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
304309   void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
r14063r14064
315320public:
316321   // construction/destruction
317322   bitmap_ind16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { }
318   bitmap_ind16(void *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
323   bitmap_ind16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
319324   bitmap_ind16(bitmap_ind16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { }
320325   void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
321326   void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
r14063r14064
332337public:
333338   // construction/destruction
334339   bitmap_ind32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
335   bitmap_ind32(void *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
340   bitmap_ind32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
336341   bitmap_ind32(bitmap_ind32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
337342   void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
338343   void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
r14063r14064
349354public:
350355   // construction/destruction
351356   bitmap_ind64(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap64_t(k_bitmap_format, width, height, xslop, yslop) { }
352   bitmap_ind64(void *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { }
357   bitmap_ind64(UINT64 *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { }
353358   bitmap_ind64(bitmap_ind64 &source, const rectangle &subrect) : bitmap64_t(k_bitmap_format, source, subrect) { }
354359   void wrap(UINT64 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
355360   void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
r14063r14064
369374public:
370375   // construction/destruction
371376   bitmap_yuy16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { }
372   bitmap_yuy16(void *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
377   bitmap_yuy16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
373378   bitmap_yuy16(bitmap_yuy16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { }
374379   void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
375380   void wrap(bitmap_yuy16 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
r14063r14064
386391public:
387392   // construction/destruction
388393   bitmap_rgb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
389   bitmap_rgb32(void *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
394   bitmap_rgb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
390395   bitmap_rgb32(bitmap_rgb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
391396   void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
392397   void wrap(bitmap_rgb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
r14063r14064
403408public:
404409   // construction/destruction
405410   bitmap_argb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
406   bitmap_argb32(void *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
411   bitmap_argb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
407412   bitmap_argb32(bitmap_argb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
408413   void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
409414   void wrap(bitmap_argb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team