Previous 199869 Revisions Next

r20829 Friday 8th February, 2013 at 13:12:13 UTC by Miodrag Milanović
Modernization of drivers part 8 (no whatsnew)
[src/mame/drivers]itech32.c itech8.c
[src/mame/includes]ikki.h irobot.h ironhors.h itech32.h itech8.h
[src/mame/machine]irobot.c
[src/mame/video]ikki.c irobot.c ironhors.c itech32.c itech8.c

trunk/src/mame/drivers/itech8.c
r20828r20829
569569 *
570570 *************************************/
571571
572void itech8_update_interrupts(running_machine &machine, int periodic, int tms34061, int blitter)
572void itech8_state::itech8_update_interrupts(int periodic, int tms34061, int blitter)
573573{
574   itech8_state *state = machine.driver_data<itech8_state>();
575   device_type main_cpu_type = machine.device("maincpu")->type();
574   device_type main_cpu_type = machine().device("maincpu")->type();
576575
577576   /* update the states */
578   if (periodic != -1) state->m_periodic_int = periodic;
579   if (tms34061 != -1) state->m_tms34061_int = tms34061;
580   if (blitter != -1) state->m_blitter_int = blitter;
577   if (periodic != -1) m_periodic_int = periodic;
578   if (tms34061 != -1) m_tms34061_int = tms34061;
579   if (blitter != -1) m_blitter_int = blitter;
581580
582581   /* handle the 6809 case */
583582   if (main_cpu_type == M6809 || main_cpu_type == HD6309)
584583   {
585584      /* just modify lines that have changed */
586      if (periodic != -1) machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, periodic ? ASSERT_LINE : CLEAR_LINE);
587      if (tms34061 != -1) machine.device("maincpu")->execute().set_input_line(M6809_IRQ_LINE, tms34061 ? ASSERT_LINE : CLEAR_LINE);
588      if (blitter != -1) machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, blitter ? ASSERT_LINE : CLEAR_LINE);
585      if (periodic != -1) machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, periodic ? ASSERT_LINE : CLEAR_LINE);
586      if (tms34061 != -1) machine().device("maincpu")->execute().set_input_line(M6809_IRQ_LINE, tms34061 ? ASSERT_LINE : CLEAR_LINE);
587      if (blitter != -1) machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, blitter ? ASSERT_LINE : CLEAR_LINE);
589588   }
590589
591590   /* handle the 68000 case */
592591   else
593592   {
594      machine.device("maincpu")->execute().set_input_line(2, state->m_blitter_int ? ASSERT_LINE : CLEAR_LINE);
595      machine.device("maincpu")->execute().set_input_line(3, state->m_periodic_int ? ASSERT_LINE : CLEAR_LINE);
593      machine().device("maincpu")->execute().set_input_line(2, m_blitter_int ? ASSERT_LINE : CLEAR_LINE);
594      machine().device("maincpu")->execute().set_input_line(3, m_periodic_int ? ASSERT_LINE : CLEAR_LINE);
596595   }
597596}
598597
r20828r20829
606605
607606TIMER_CALLBACK_MEMBER(itech8_state::irq_off)
608607{
609   itech8_update_interrupts(machine(), 0, -1, -1);
608   itech8_update_interrupts(0, -1, -1);
610609}
611610
612611
613612INTERRUPT_GEN_MEMBER(itech8_state::generate_nmi)
614613{
615614   /* signal the NMI */
616   itech8_update_interrupts(machine(), 1, -1, -1);
615   itech8_update_interrupts(1, -1, -1);
617616   machine().scheduler().timer_set(attotime::from_usec(1), timer_expired_delegate(FUNC(itech8_state::irq_off),this));
618617
619618   if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", machine().primary_screen->vpos());
trunk/src/mame/drivers/itech32.c
r20828r20829
374374 *
375375 *************************************/
376376
377INLINE int determine_irq_state(itech32_state *state, int vint, int xint, int qint)
377inline int itech32_state::determine_irq_state(int vint, int xint, int qint)
378378{
379379   int level = 0;
380380
381381
382382   /* determine which level is active */
383   if (state->m_vint_state) level = 1;
384   if (state->m_xint_state) level = 2;
385   if (state->m_qint_state) level = 3;
383   if (m_vint_state) level = 1;
384   if (m_xint_state) level = 2;
385   if (m_qint_state) level = 3;
386386
387387   /* Driver's Edge shifts the interrupts a bit */
388   if (state->m_is_drivedge && level) level += 2;
388   if (m_is_drivedge && level) level += 2;
389389
390390   return level;
391391}
392392
393393
394void itech32_update_interrupts(running_machine &machine, int vint, int xint, int qint)
394void itech32_state::itech32_update_interrupts(int vint, int xint, int qint)
395395{
396   itech32_state *state = machine.driver_data<itech32_state>();
397396   /* update the states */
398   if (vint != -1) state->m_vint_state = vint;
399   if (xint != -1) state->m_xint_state = xint;
400   if (qint != -1) state->m_qint_state = qint;
397   if (vint != -1) m_vint_state = vint;
398   if (xint != -1) m_xint_state = xint;
399   if (qint != -1) m_qint_state = qint;
401400
402   if (state->m_is_drivedge)
401   if (m_is_drivedge)
403402   {
404      machine.device("maincpu")->execute().set_input_line(3, state->m_vint_state ? ASSERT_LINE : CLEAR_LINE);
405      machine.device("maincpu")->execute().set_input_line(4, state->m_xint_state ? ASSERT_LINE : CLEAR_LINE);
406      machine.device("maincpu")->execute().set_input_line(5, state->m_qint_state ? ASSERT_LINE : CLEAR_LINE);
403      machine().device("maincpu")->execute().set_input_line(3, m_vint_state ? ASSERT_LINE : CLEAR_LINE);
404      machine().device("maincpu")->execute().set_input_line(4, m_xint_state ? ASSERT_LINE : CLEAR_LINE);
405      machine().device("maincpu")->execute().set_input_line(5, m_qint_state ? ASSERT_LINE : CLEAR_LINE);
407406   }
408407   else
409408   {
410      machine.device("maincpu")->execute().set_input_line(1, state->m_vint_state ? ASSERT_LINE : CLEAR_LINE);
411      machine.device("maincpu")->execute().set_input_line(2, state->m_xint_state ? ASSERT_LINE : CLEAR_LINE);
412      machine.device("maincpu")->execute().set_input_line(3, state->m_qint_state ? ASSERT_LINE : CLEAR_LINE);
409      machine().device("maincpu")->execute().set_input_line(1, m_vint_state ? ASSERT_LINE : CLEAR_LINE);
410      machine().device("maincpu")->execute().set_input_line(2, m_xint_state ? ASSERT_LINE : CLEAR_LINE);
411      machine().device("maincpu")->execute().set_input_line(3, m_qint_state ? ASSERT_LINE : CLEAR_LINE);
413412   }
414413}
415414
r20828r20829
417416INTERRUPT_GEN_MEMBER(itech32_state::generate_int1)
418417{
419418   /* signal the NMI */
420   itech32_update_interrupts(machine(), 1, -1, -1);
419   itech32_update_interrupts(1, -1, -1);
421420   if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", machine().primary_screen->vpos());
422421}
423422
424423
425424WRITE16_MEMBER(itech32_state::int1_ack_w)
426425{
427   itech32_update_interrupts(machine(), 0, -1, -1);
426   itech32_update_interrupts(0, -1, -1);
428427}
429428
430429
r20828r20829
873872
874873void itech32_state::nvram_init(nvram_device &nvram, void *base, size_t length)
875874{
876   itech32_state *state = machine().driver_data<itech32_state>();
877875   // if nvram is the main RAM, don't overwrite exception vectors
878   int start = (base == state->m_main_ram) ? 0x80 : 0x00;
876   int start = (base == m_main_ram) ? 0x80 : 0x00;
879877   for (int i = start; i < length; i++)
880878      ((UINT8 *)base)[i] = machine().rand();
881879
882880   // due to accessing uninitialized RAM, we need this hack
883   if (state->m_is_drivedge)
884      ((UINT32 *)state->m_main_ram.target())[0x2ce4/4] = 0x0000001e;
881   if (m_is_drivedge)
882      ((UINT32 *)m_main_ram.target())[0x2ce4/4] = 0x0000001e;
885883}
886884
887885
r20828r20829
41114109 *
41124110 *************************************/
41134111
4114static void init_program_rom(running_machine &machine)
4112void itech32_state::init_program_rom()
41154113{
4116   itech32_state *state = machine.driver_data<itech32_state>();
4117   if (state->m_main_ram == NULL)
4118      state->m_main_ram.set_target(state->m_nvram, state->m_nvram.bytes());
4119   memcpy(state->m_main_ram, state->m_main_rom, 0x80);
4114   if (m_main_ram == NULL)
4115      m_main_ram.set_target(m_nvram, m_nvram.bytes());
4116   memcpy(m_main_ram, m_main_rom, 0x80);
41204117}
41214118
41224119
41234120DRIVER_INIT_MEMBER(itech32_state,timekill)
41244121{
4125   init_program_rom(machine());
4122   init_program_rom();
41264123   m_vram_height = 512;
41274124   m_planes = 2;
41284125   m_is_drivedge = 0;
r20828r20829
41314128
41324129DRIVER_INIT_MEMBER(itech32_state,hardyard)
41334130{
4134   init_program_rom(machine());
4131   init_program_rom();
41354132   m_vram_height = 1024;
41364133   m_planes = 1;
41374134   m_is_drivedge = 0;
r20828r20829
41404137
41414138DRIVER_INIT_MEMBER(itech32_state,bloodstm)
41424139{
4143   init_program_rom(machine());
4140   init_program_rom();
41444141   m_vram_height = 1024;
41454142   m_planes = 1;
41464143   m_is_drivedge = 0;
r20828r20829
41494146
41504147DRIVER_INIT_MEMBER(itech32_state,drivedge)
41514148{
4152   init_program_rom(machine());
4149   init_program_rom();
41534150   m_vram_height = 1024;
41544151   m_planes = 1;
41554152   m_is_drivedge = 1;
r20828r20829
41674164         ROM   P/N 1079 Rev 1 (contains graphic roms, 4MHz OSC + ITBWL-1 security PIC chip)
41684165         Sound P/N 1060 Rev 0 (see Hot Memory PCB layout above)
41694166   */
4170   init_program_rom(machine());
4167   init_program_rom();
41714168   m_vram_height = 1024;
41724169   m_planes = 1;
41734170
r20828r20829
41874184         ROM   P/N 1079 Rev 1 (contains graphic roms, 4MHz OSC + ITBWL-1 security PIC chip)
41884185         Sound P/N 1060 Rev 0 (see Hot Memory PCB layout above)
41894186   */
4190   init_program_rom(machine());
4187   init_program_rom();
41914188   m_vram_height = 1024;
41924189   m_planes = 1;
41934190
r20828r20829
42004197}
42014198
42024199
4203static void init_sftm_common(running_machine &machine, int prot_addr)
4200void itech32_state::init_sftm_common(int prot_addr)
42044201{
4205   itech32_state *state = machine.driver_data<itech32_state>();
4206   init_program_rom(machine);
4207   state->m_vram_height = 1024;
4208   state->m_planes = 1;
4209   state->m_is_drivedge = 0;
4202   init_program_rom();
4203   m_vram_height = 1024;
4204   m_planes = 1;
4205   m_is_drivedge = 0;
42104206
4211   state->m_itech020_prot_address = prot_addr;
4207   m_itech020_prot_address = prot_addr;
42124208
4213   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x300000, 0x300003, write32_delegate(FUNC(itech32_state::itech020_color2_w),state));
4214   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x380000, 0x380003, write32_delegate(FUNC(itech32_state::itech020_color1_w),state));
4209   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x300000, 0x300003, write32_delegate(FUNC(itech32_state::itech020_color2_w),this));
4210   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x380000, 0x380003, write32_delegate(FUNC(itech32_state::itech020_color1_w),this));
42154211}
42164212
42174213
42184214DRIVER_INIT_MEMBER(itech32_state,sftm)
42194215{
4220   init_sftm_common(machine(), 0x7a6a);
4216   init_sftm_common(0x7a6a);
42214217}
42224218
42234219
42244220DRIVER_INIT_MEMBER(itech32_state,sftm110)
42254221{
4226   init_sftm_common(machine(), 0x7a66);
4222   init_sftm_common(0x7a66);
42274223}
42284224
42294225
4230static void init_shuffle_bowl_common(running_machine &machine, int prot_addr)
4226void itech32_state::init_shuffle_bowl_common(int prot_addr)
42314227{
4232   itech32_state *state = machine.driver_data<itech32_state>();
42334228   /*
42344229       The newest versions of World Class Bowling are on the same exact
42354230       platform as Shuffle Shot. So We'll use the same general INIT
42364231       routine for these two programs.  IE: PCB P/N 1083 Rev 2
42374232   */
4238   init_program_rom(machine);
4239   state->m_vram_height = 1024;
4240   state->m_planes = 1;
4241   state->m_is_drivedge = 0;
4233   init_program_rom();
4234   m_vram_height = 1024;
4235   m_planes = 1;
4236   m_is_drivedge = 0;
42424237
4243   state->m_itech020_prot_address = prot_addr;
4238   m_itech020_prot_address = prot_addr;
42444239
4245   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x300000, 0x300003, write32_delegate(FUNC(itech32_state::itech020_color2_w),state));
4246   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x380000, 0x380003, write32_delegate(FUNC(itech32_state::itech020_color1_w),state));
4247   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x180800, 0x180803, read32_delegate(FUNC(itech32_state::trackball32_4bit_p1_r),state));
4248   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x181000, 0x181003, read32_delegate(FUNC(itech32_state::trackball32_4bit_p2_r),state));
4240   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x300000, 0x300003, write32_delegate(FUNC(itech32_state::itech020_color2_w),this));
4241   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x380000, 0x380003, write32_delegate(FUNC(itech32_state::itech020_color1_w),this));
4242   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x180800, 0x180803, read32_delegate(FUNC(itech32_state::trackball32_4bit_p1_r),this));
4243   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x181000, 0x181003, read32_delegate(FUNC(itech32_state::trackball32_4bit_p2_r),this));
42494244}
42504245
42514246
42524247DRIVER_INIT_MEMBER(itech32_state,shufshot)
42534248{
4254   init_shuffle_bowl_common(machine(), 0x111a);
4249   init_shuffle_bowl_common(0x111a);
42554250}
42564251
42574252
42584253DRIVER_INIT_MEMBER(itech32_state,wcbowln)
42594254{
42604255   /* The security PROM is NOT interchangeable between the Deluxe and "normal" versions. */
4261   init_shuffle_bowl_common(machine(), 0x1116);
4256   init_shuffle_bowl_common(0x1116);
42624257}
42634258
4264static void install_timekeeper(running_machine &machine)
4259void itech32_state::install_timekeeper()
42654260{
4266   device_t *device = machine.device("m48t02");
4267   machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(*device, 0x681000, 0x6817ff, FUNC(timekeeper_r), FUNC(timekeeper_w), 0xffffffff);
4261   device_t *device = machine().device("m48t02");
4262   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(*device, 0x681000, 0x6817ff, FUNC(timekeeper_r), FUNC(timekeeper_w), 0xffffffff);
42684263}
42694264
42704265DRIVER_INIT_MEMBER(itech32_state,wcbowlt)
42714266{
42724267   /* Tournament Version, Same protection memory address as WCB Deluxe, but uses the standard WCB pic ITBWL-3 */
4273   init_shuffle_bowl_common(machine(), 0x111a);
4268   init_shuffle_bowl_common(0x111a);
42744269
4275   install_timekeeper(machine());
4270   install_timekeeper();
42764271}
42774272
4278static void init_gt_common(running_machine &machine)
4273void itech32_state::init_gt_common()
42794274{
4280   itech32_state *state = machine.driver_data<itech32_state>();
4281   init_program_rom(machine);
4282   state->m_vram_height = 1024;
4283   state->m_planes = 2;
4284   state->m_is_drivedge = 0;
4275   init_program_rom();
4276   m_vram_height = 1024;
4277   m_planes = 2;
4278   m_is_drivedge = 0;
42854279
4286   state->m_itech020_prot_address = 0x112f;
4280   m_itech020_prot_address = 0x112f;
42874281}
42884282
42894283
r20828r20829
42974291       through GTClassic. This is _NOT_ a factory modification
42984292   */
42994293   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x200000, 0x200003, read32_delegate(FUNC(itech32_state::trackball32_8bit_r),this));
4300   init_gt_common(machine());
4294   init_gt_common();
43014295}
43024296
43034297
r20828r20829
43114305   */
43124306   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x180800, 0x180803, read32_delegate(FUNC(itech32_state::trackball32_4bit_p1_r),this));
43134307   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x181000, 0x181003, read32_delegate(FUNC(itech32_state::trackball32_4bit_p2_r),this));
4314   init_gt_common(machine());
4308   init_gt_common();
43154309}
43164310
43174311
r20828r20829
43224316   */
43234317   DRIVER_INIT_CALL(aama);
43244318
4325   install_timekeeper(machine());
4319   install_timekeeper();
43264320}
43274321
43284322
r20828r20829
43354329       Trackball info is read through 200202 (actually 200203).
43364330   */
43374331   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x200200, 0x200203, read32_delegate(FUNC(itech32_state::trackball32_4bit_p1_r),this));
4338   init_gt_common(machine());
4332   init_gt_common();
43394333}
43404334
43414335
r20828r20829
43494343       Player 2 trackball read through 200002
43504344   */
43514345   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x200000, 0x200003, read32_delegate(FUNC(itech32_state::trackball32_4bit_combined_r),this));
4352   init_gt_common(machine());
4346   init_gt_common();
43534347}
43544348
43554349
trunk/src/mame/machine/irobot.c
r20828r20829
2727         "%s, scanline: %d\n", (m).describe_context(), (m).primary_screen->vpos())
2828
2929
30static void irmb_run(running_machine &machine);
31
32
33/***********************************************************************/
34
35
36
3730READ8_MEMBER(irobot_state::irobot_sharedmem_r)
3831{
3932   if (m_outx == 3)
r20828r20829
7669   m_combase_mb = m_comRAM[(data >> 7) ^ 1];
7770   m_bufsel = data & 0x02;
7871   if (((data & 0x01) == 0x01) && (m_vg_clear == 0))
79      irobot_poly_clear(machine());
72      irobot_poly_clear();
8073
8174   m_vg_clear = data & 0x01;
8275
8376   if ((data & 0x04) && !(m_statwr & 0x04))
8477   {
85      irobot_run_video(machine());
78      irobot_run_video();
8679#if IR_TIMING
8780      if (m_irvg_running == 0)
8881         logerror("vg start ");
r20828r20829
9487      m_irvg_running=1;
9588   }
9689   if ((data & 0x10) && !(m_statwr & 0x10))
97      irmb_run(machine());
90      irmb_run();
9891   m_statwr = data;
9992}
10093
r20828r20829
287280#endif
288281
289282
290static UINT32 irmb_din(irobot_state *state, const irmb_ops *curop)
283UINT32 irobot_state::irmb_din(const irmb_ops *curop)
291284{
292285   UINT32 d = 0;
293286
294287   if (!(curop->flags & FL_MBMEMDEC) && (curop->flags & FL_MBRW))
295288   {
296      UINT32 ad = curop->diradd | (state->m_irmb_latch & curop->latchmask);
289      UINT32 ad = curop->diradd | (m_irmb_latch & curop->latchmask);
297290
298      if (curop->diren || (state->m_irmb_latch & 0x6000) == 0)
299         d = ((UINT16 *)state->m_mbRAM)[ad & 0xfff];             /* MB RAM read */
300      else if (state->m_irmb_latch & 0x4000)
301         d = ((UINT16 *)state->m_mbROM)[ad + 0x2000];                /* MB ROM read, CEMATH = 1 */
291      if (curop->diren || (m_irmb_latch & 0x6000) == 0)
292         d = ((UINT16 *)m_mbRAM)[ad & 0xfff];             /* MB RAM read */
293      else if (m_irmb_latch & 0x4000)
294         d = ((UINT16 *)m_mbROM)[ad + 0x2000];                /* MB ROM read, CEMATH = 1 */
302295      else
303         d = ((UINT16 *)state->m_mbROM)[ad & 0x1fff];                /* MB ROM read, CEMATH = 0 */
296         d = ((UINT16 *)m_mbROM)[ad & 0x1fff];                /* MB ROM read, CEMATH = 0 */
304297   }
305298   return d;
306299}
307300
308301
309static void irmb_dout(irobot_state *state, const irmb_ops *curop, UINT32 d)
302void irobot_state::irmb_dout(const irmb_ops *curop, UINT32 d)
310303{
311304   /* Write to video com ram */
312305   if (curop->ramsel == 3)
313      ((UINT16 *)state->m_combase_mb)[state->m_irmb_latch & 0x7ff] = d;
306      ((UINT16 *)m_combase_mb)[m_irmb_latch & 0x7ff] = d;
314307
315308   /* Write to mathox ram */
316309   if (!(curop->flags & FL_MBMEMDEC))
317310   {
318      UINT32 ad = curop->diradd | (state->m_irmb_latch & curop->latchmask);
311      UINT32 ad = curop->diradd | (m_irmb_latch & curop->latchmask);
319312
320      if (curop->diren || (state->m_irmb_latch & 0x6000) == 0)
321         ((UINT16 *)state->m_mbRAM)[ad & 0xfff] = d;             /* MB RAM write */
313      if (curop->diren || (m_irmb_latch & 0x6000) == 0)
314         ((UINT16 *)m_mbRAM)[ad & 0xfff] = d;             /* MB RAM write */
322315   }
323316}
324317
325318
326319/* Convert microcode roms to a more usable form */
327static void load_oproms(running_machine &machine)
320void irobot_state::load_oproms()
328321{
329   irobot_state *state = machine.driver_data<irobot_state>();
330   UINT8 *MB = state->memregion("proms")->base() + 0x20;
322   UINT8 *MB = memregion("proms")->base() + 0x20;
331323   int i;
332324
333325   /* allocate RAM */
334   state->m_mbops = auto_alloc_array(machine, irmb_ops, 1024);
326   m_mbops = auto_alloc_array(machine(), irmb_ops, 1024);
335327
336328   for (i = 0; i < 1024; i++)
337329   {
338330      int nxtadd, func, ramsel, diradd, latchmask, dirmask, time;
339331
340      state->m_mbops[i].areg = &state->m_irmb_regs[MB[0x0000 + i] & 0x0F];
341      state->m_mbops[i].breg = &state->m_irmb_regs[MB[0x0400 + i] & 0x0F];
332      m_mbops[i].areg = &m_irmb_regs[MB[0x0000 + i] & 0x0F];
333      m_mbops[i].breg = &m_irmb_regs[MB[0x0400 + i] & 0x0F];
342334      func = (MB[0x0800 + i] & 0x0F) << 5;
343335      func |= ((MB[0x0C00 +i] & 0x0F) << 1);
344336      func |= (MB[0x1000 + i] & 0x08) >> 3;
345337      time = MB[0x1000 + i] & 0x03;
346      state->m_mbops[i].flags = (MB[0x1000 + i] & 0x04) >> 2;
338      m_mbops[i].flags = (MB[0x1000 + i] & 0x04) >> 2;
347339      nxtadd = (MB[0x1400 + i] & 0x0C) >> 2;
348340      diradd = MB[0x1400 + i] & 0x03;
349341      nxtadd |= ((MB[0x1800 + i] & 0x0F) << 6);
350342      nxtadd |= ((MB[0x1C00 + i] & 0x0F) << 2);
351343      diradd |= (MB[0x2000 + i] & 0x0F) << 2;
352344      func |= (MB[0x2400 + i] & 0x0E) << 9;
353      state->m_mbops[i].flags |= (MB[0x2400 + i] & 0x01) << 1;
354      state->m_mbops[i].flags |= (MB[0x2800 + i] & 0x0F) << 2;
355      state->m_mbops[i].flags |= ((MB[0x2C00 + i] & 0x01) << 6);
356      state->m_mbops[i].flags |= (MB[0x2C00 + i] & 0x08) << 4;
345      m_mbops[i].flags |= (MB[0x2400 + i] & 0x01) << 1;
346      m_mbops[i].flags |= (MB[0x2800 + i] & 0x0F) << 2;
347      m_mbops[i].flags |= ((MB[0x2C00 + i] & 0x01) << 6);
348      m_mbops[i].flags |= (MB[0x2C00 + i] & 0x08) << 4;
357349      ramsel = (MB[0x2C00 + i] & 0x06) >> 1;
358350      diradd |= (MB[0x3000 + i] & 0x03) << 6;
359351
360      if (state->m_mbops[i].flags & FL_shift) func |= 0x200;
352      if (m_mbops[i].flags & FL_shift) func |= 0x200;
361353
362      state->m_mbops[i].func = func;
363      state->m_mbops[i].nxtop = &state->m_mbops[nxtadd];
354      m_mbops[i].func = func;
355      m_mbops[i].nxtop = &m_mbops[nxtadd];
364356
365357      /* determine the number of 12MHz cycles for this operation */
366358      if (time == 3)
367         state->m_mbops[i].cycles = 2;
359         m_mbops[i].cycles = 2;
368360      else
369         state->m_mbops[i].cycles = 3 + time;
361         m_mbops[i].cycles = 3 + time;
370362
371363      /* precompute the hardcoded address bits and the mask to be used on the latch value */
372364      if (ramsel == 0)
r20828r20829
384376      else
385377         dirmask |= 0x0003;
386378
387      state->m_mbops[i].ramsel = ramsel;
388      state->m_mbops[i].diradd = diradd & dirmask;
389      state->m_mbops[i].latchmask = latchmask;
390      state->m_mbops[i].diren = (ramsel == 0);
379      m_mbops[i].ramsel = ramsel;
380      m_mbops[i].diradd = diradd & dirmask;
381      m_mbops[i].latchmask = latchmask;
382      m_mbops[i].diren = (ramsel == 0);
391383
392384#if DISASSEMBLE_MB_ROM
393      disassemble_instruction(&state->m_mbops[i]);
385      disassemble_instruction(&m_mbops[i]);
394386#endif
395387   }
396388}
r20828r20829
406398      m_irmb_regs[i] = 0;
407399   }
408400   m_irmb_latch=0;
409   load_oproms(machine());
401   load_oproms();
410402}
411403
412404TIMER_DEVICE_CALLBACK_MEMBER(irobot_state::irobot_irmb_done_callback)
r20828r20829
525517#define JUMP3   if (!nflag) curop = curop->nxtop; else curop++;
526518#define JUMP4   if (nflag) curop = curop->nxtop; else curop++;
527519#define JUMP5   curop = curop->nxtop;
528#define JUMP6   state->m_irmb_stack[SP] = curop + 1; SP = (SP + 1) & 15; curop = curop->nxtop;
529#define JUMP7   SP = (SP - 1) & 15; curop = state->m_irmb_stack[SP];
520#define JUMP6   m_irmb_stack[SP] = curop + 1; SP = (SP + 1) & 15; curop = curop->nxtop;
521#define JUMP7   SP = (SP - 1) & 15; curop = m_irmb_stack[SP];
530522
531523
532524/* Run mathbox */
533static void irmb_run(running_machine &machine)
525void irobot_state::irmb_run()
534526{
535   irobot_state *state = machine.driver_data<irobot_state>();
536   const irmb_ops *prevop = &state->m_mbops[0];
537   const irmb_ops *curop = &state->m_mbops[0];
527   const irmb_ops *prevop = &m_mbops[0];
528   const irmb_ops *curop = &m_mbops[0];
538529
539530   UINT32 Q = 0;
540531   UINT32 Y = 0;
r20828r20829
579570         case 0x02:  ADD(0, Q);                                          break;
580571         case 0x03:  ADD(0, *curop->breg);                               break;
581572         case 0x04:  ADD(0, *curop->areg);                               break;
582         case 0x05:  tmp = irmb_din(state, curop); ADD(tmp, *curop->areg);       break;
583         case 0x06:  tmp = irmb_din(state, curop); ADD(tmp, Q);                  break;
584         case 0x07:  tmp = irmb_din(state, curop); ADD(tmp, 0);                  break;
573         case 0x05:  tmp = irmb_din(curop); ADD(tmp, *curop->areg);       break;
574         case 0x06:  tmp = irmb_din(curop); ADD(tmp, Q);                  break;
575         case 0x07:  tmp = irmb_din(curop); ADD(tmp, 0);                  break;
585576         case 0x08:  SUBR(*curop->areg, Q);                              break;
586577         case 0x09:  SUBR(*curop->areg, *curop->breg);                   break;
587578         case 0x0a:  SUBR(0, Q);                                         break;
588579         case 0x0b:  SUBR(0, *curop->breg);                              break;
589580         case 0x0c:  SUBR(0, *curop->areg);                              break;
590         case 0x0d:  tmp = irmb_din(state, curop); SUBR(tmp, *curop->areg);      break;
591         case 0x0e:  tmp = irmb_din(state, curop); SUBR(tmp, Q);             break;
592         case 0x0f:  tmp = irmb_din(state, curop); SUBR(tmp, 0);             break;
581         case 0x0d:  tmp = irmb_din(curop); SUBR(tmp, *curop->areg);      break;
582         case 0x0e:  tmp = irmb_din(curop); SUBR(tmp, Q);             break;
583         case 0x0f:  tmp = irmb_din(curop); SUBR(tmp, 0);             break;
593584         case 0x10:  SUB(*curop->areg, Q);                               break;
594585         case 0x11:  SUB(*curop->areg, *curop->breg);                    break;
595586         case 0x12:  SUB(0, Q);                                          break;
596587         case 0x13:  SUB(0, *curop->breg);                               break;
597588         case 0x14:  SUB(0, *curop->areg);                               break;
598         case 0x15:  tmp = irmb_din(state, curop); SUB(tmp, *curop->areg);       break;
599         case 0x16:  tmp = irmb_din(state, curop); SUB(tmp, Q);                  break;
600         case 0x17:  tmp = irmb_din(state, curop); SUB(tmp, 0);                  break;
589         case 0x15:  tmp = irmb_din(curop); SUB(tmp, *curop->areg);       break;
590         case 0x16:  tmp = irmb_din(curop); SUB(tmp, Q);                  break;
591         case 0x17:  tmp = irmb_din(curop); SUB(tmp, 0);                  break;
601592         case 0x18:  OR(*curop->areg, Q);                                break;
602593         case 0x19:  OR(*curop->areg, *curop->breg);                     break;
603594         case 0x1a:  OR(0, Q);                                           break;
604595         case 0x1b:  OR(0, *curop->breg);                                break;
605596         case 0x1c:  OR(0, *curop->areg);                                break;
606         case 0x1d:  OR(irmb_din(state, curop), *curop->areg);                   break;
607         case 0x1e:  OR(irmb_din(state, curop), Q);                              break;
608         case 0x1f:  OR(irmb_din(state, curop), 0);                              break;
597         case 0x1d:  OR(irmb_din(curop), *curop->areg);                   break;
598         case 0x1e:  OR(irmb_din(curop), Q);                              break;
599         case 0x1f:  OR(irmb_din(curop), 0);                              break;
609600         case 0x20:  AND(*curop->areg, Q);                               break;
610601         case 0x21:  AND(*curop->areg, *curop->breg);                    break;
611602         case 0x22:  AND(0, Q);                                          break;
612603         case 0x23:  AND(0, *curop->breg);                               break;
613604         case 0x24:  AND(0, *curop->areg);                               break;
614         case 0x25:  AND(irmb_din(state, curop), *curop->areg);                  break;
615         case 0x26:  AND(irmb_din(state, curop), Q);                         break;
616         case 0x27:  AND(irmb_din(state, curop), 0);                         break;
605         case 0x25:  AND(irmb_din(curop), *curop->areg);                  break;
606         case 0x26:  AND(irmb_din(curop), Q);                         break;
607         case 0x27:  AND(irmb_din(curop), 0);                         break;
617608         case 0x28:  IAND(*curop->areg, Q);                              break;
618609         case 0x29:  IAND(*curop->areg, *curop->breg);                   break;
619610         case 0x2a:  IAND(0, Q);                                         break;
620611         case 0x2b:  IAND(0, *curop->breg);                              break;
621612         case 0x2c:  IAND(0, *curop->areg);                              break;
622         case 0x2d:  IAND(irmb_din(state, curop), *curop->areg);             break;
623         case 0x2e:  IAND(irmb_din(state, curop), Q);                            break;
624         case 0x2f:  IAND(irmb_din(state, curop), 0);                            break;
613         case 0x2d:  IAND(irmb_din(curop), *curop->areg);             break;
614         case 0x2e:  IAND(irmb_din(curop), Q);                            break;
615         case 0x2f:  IAND(irmb_din(curop), 0);                            break;
625616         case 0x30:  XOR(*curop->areg, Q);                               break;
626617         case 0x31:  XOR(*curop->areg, *curop->breg);                    break;
627618         case 0x32:  XOR(0, Q);                                          break;
628619         case 0x33:  XOR(0, *curop->breg);                               break;
629620         case 0x34:  XOR(0, *curop->areg);                               break;
630         case 0x35:  XOR(irmb_din(state, curop), *curop->areg);                  break;
631         case 0x36:  XOR(irmb_din(state, curop), Q);                         break;
632         case 0x37:  XOR(irmb_din(state, curop), 0);                         break;
621         case 0x35:  XOR(irmb_din(curop), *curop->areg);                  break;
622         case 0x36:  XOR(irmb_din(curop), Q);                         break;
623         case 0x37:  XOR(irmb_din(curop), 0);                         break;
633624         case 0x38:  IXOR(*curop->areg, Q);                              break;
634625         case 0x39:  IXOR(*curop->areg, *curop->breg);                   break;
635626         case 0x3a:  IXOR(0, Q);                                         break;
636627         case 0x3b:  IXOR(0, *curop->breg);                              break;
637628         case 0x3c:  IXOR(0, *curop->areg);                              break;
638         case 0x3d:  IXOR(irmb_din(state, curop), *curop->areg);             break;
639         case 0x3e:  IXOR(irmb_din(state, curop), Q);                            break;
640default:    case 0x3f:  IXOR(irmb_din(state, curop), 0);                            break;
629         case 0x3d:  IXOR(irmb_din(curop), *curop->areg);             break;
630         case 0x3e:  IXOR(irmb_din(curop), Q);                            break;
631default:    case 0x3f:  IXOR(irmb_din(curop), 0);                            break;
641632      }
642633
643634      /* Evaluate flags */
r20828r20829
788779
789780      /* Do write */
790781      if (!(prevop->flags & FL_MBRW))
791         irmb_dout(state, prevop, Y);
782         irmb_dout(prevop, Y);
792783
793784      /* ADDEN */
794785      if (!(prevop->flags & FL_ADDEN))
795786      {
796787         if (prevop->flags & FL_MBRW)
797            state->m_irmb_latch = irmb_din(state, prevop);
788            m_irmb_latch = irmb_din(prevop);
798789         else
799            state->m_irmb_latch = Y;
790            m_irmb_latch = Y;
800791      }
801792   }
802793   g_profiler.stop();
r20828r20829
805796
806797
807798#if IR_TIMING
808   if (state->m_irmb_running == 0)
799   if (m_irmb_running == 0)
809800   {
810      state->m_irmb_timer->adjust(attotime::from_hz(12000000) * icount);
801      m_irmb_timer->adjust(attotime::from_hz(12000000) * icount);
811802      logerror("mb start ");
812      IR_CPU_STATE(machine);
803      IR_CPU_STATE(machine());
813804   }
814805   else
815806   {
816807      logerror("mb start [busy!] ");
817      IR_CPU_STATE(machine);
818      state->m_irmb_timer->adjust(attotime::from_hz(200) * icount);
808      IR_CPU_STATE(machine());
809      m_irmb_timer->adjust(attotime::from_hz(200) * icount);
819810   }
820811#else
821   machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, ASSERT_LINE);
812   machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, ASSERT_LINE);
822813#endif
823   state->m_irmb_running=1;
814   m_irmb_running=1;
824815}
825816
826817
trunk/src/mame/includes/itech32.h
r20828r20829
163163   INTERRUPT_GEN_MEMBER(generate_int1);
164164   TIMER_CALLBACK_MEMBER(delayed_sound_data_w);
165165   TIMER_CALLBACK_MEMBER(scanline_interrupt);
166   inline offs_t compute_safe_address(int x, int y);
167   inline void disable_clipping();
168   inline void enable_clipping();
169   void logblit(const char *tag);
170   void update_interrupts(int fast);
171   void draw_raw(UINT16 *base, UINT16 color);
172   void draw_raw_drivedge(UINT16 *base, UINT16 *zbase, UINT16 color);
173   inline void draw_rle_fast(UINT16 *base, UINT16 color);
174   inline void draw_rle_fast_xflip(UINT16 *base, UINT16 color);
175   inline void draw_rle_slow(UINT16 *base, UINT16 color);
176   void draw_rle(UINT16 *base, UINT16 color);
177   void shiftreg_clear(UINT16 *base, UINT16 *zbase);
178   void handle_video_command();
179   inline int determine_irq_state(int vint, int xint, int qint);
180   void itech32_update_interrupts(int vint, int xint, int qint);
181   void init_program_rom();
182   void init_sftm_common(int prot_addr);
183   void init_shuffle_bowl_common(int prot_addr);
184   void install_timekeeper();
185   void init_gt_common();
166186};
167187
168/*----------- defined in drivers/itech32.c -----------*/
169void itech32_update_interrupts(running_machine &machine, int vint, int xint, int qint);
trunk/src/mame/includes/ikki.h
r20828r20829
3737   virtual void palette_init();
3838   UINT32 screen_update_ikki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939   TIMER_DEVICE_CALLBACK_MEMBER(ikki_irq);
40   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4041};
trunk/src/mame/includes/irobot.h
r20828r20829
8383   TIMER_CALLBACK_MEMBER(scanline_callback);
8484   TIMER_DEVICE_CALLBACK_MEMBER(irobot_irvg_done_callback);
8585   TIMER_DEVICE_CALLBACK_MEMBER(irobot_irmb_done_callback);
86   void _irobot_poly_clear(UINT8 *bitmap_base);
87   void irobot_poly_clear();
88   void draw_line(UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col);
89   void irobot_run_video();
90   UINT32 irmb_din(const irmb_ops *curop);
91   void irmb_dout(const irmb_ops *curop, UINT32 d);
92   void load_oproms();
93   void irmb_run();
8694};
87
88/*----------- defined in video/irobot.c -----------*/
89void irobot_poly_clear(running_machine &machine);
90void irobot_run_video(running_machine &machine);
trunk/src/mame/includes/ironhors.h
r20828r20829
5252   UINT32 screen_update_farwest(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   TIMER_DEVICE_CALLBACK_MEMBER(ironhors_irq);
5454   TIMER_DEVICE_CALLBACK_MEMBER(farwest_irq);
55   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
56   void farwest_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5557};
trunk/src/mame/includes/itech8.h
r20828r20829
104104   TIMER_CALLBACK_MEMBER(delayed_sound_data_w);
105105   TIMER_CALLBACK_MEMBER(blitter_done);
106106   TIMER_DEVICE_CALLBACK_MEMBER(grmatch_palette_update);
107   inline UINT8 fetch_next_raw();
108   inline void consume_raw(int count);
109   inline UINT8 fetch_next_rle();
110   inline void consume_rle(int count);
111   void perform_blit(address_space &space);
112   void itech8_update_interrupts(int periodic, int tms34061, int blitter);
107113};
108114
109
110/*----------- defined in drivers/itech8.c -----------*/
111
112void itech8_update_interrupts(running_machine &machine, int periodic, int tms34061, int blitter);
113
114
115115/*----------- defined in machine/slikshot.c -----------*/
116116
117117DECLARE_READ8_HANDLER( slikz80_port_r );
trunk/src/mame/video/ikki.c
r20828r20829
6161}
6262
6363
64static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
64void ikki_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
6565{
66   ikki_state *state = machine.driver_data<ikki_state>();
67   UINT8 *spriteram = state->m_spriteram;
66   UINT8 *spriteram = m_spriteram;
6867   int y;
6968   offs_t offs;
7069
71   state->m_sprite_bitmap.fill(state->m_punch_through_pen, cliprect);
70   m_sprite_bitmap.fill(m_punch_through_pen, cliprect);
7271
73   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
72   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
7473   {
7574      int code = (spriteram[offs + 2] & 0x80) | (spriteram[offs + 1] >> 1);
7675      int color = spriteram[offs + 2] & 0x3f;
r20828r20829
7877      int x = spriteram[offs + 3];
7978         y = spriteram[offs + 0];
8079
81      if (state->m_flipscreen)
80      if (m_flipscreen)
8281         x = 240 - x;
8382      else
8483         y = 224 - y;
r20828r20829
9291      if (y > 240)
9392         y = y - 256;
9493
95      drawgfx_transmask(state->m_sprite_bitmap,cliprect, machine.gfx[1],
94      drawgfx_transmask(m_sprite_bitmap,cliprect, machine().gfx[1],
9695            code, color,
97            state->m_flipscreen,state->m_flipscreen,
96            m_flipscreen,m_flipscreen,
9897            x,y,
99            colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0));
98            colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0));
10099   }
101100
102101   /* copy the sprite bitmap into the main bitmap, skipping the transparent pixels */
r20828r20829
106105
107106      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
108107      {
109         UINT16 pen = state->m_sprite_bitmap.pix16(y, x);
108         UINT16 pen = m_sprite_bitmap.pix16(y, x);
110109
111         if (colortable_entry_get_value(machine.colortable, pen) != 0x100)
110         if (colortable_entry_get_value(machine().colortable, pen) != 0x100)
112111            bitmap.pix16(y, x) = pen;
113112      }
114113   }
r20828r20829
182181         x,y);
183182   }
184183
185   draw_sprites(machine(), bitmap, cliprect);
184   draw_sprites(bitmap, cliprect);
186185
187186   /* mask sprites */
188187
trunk/src/mame/video/itech32.c
r20828r20829
131131
132132#define ADJUSTED_HEIGHT(x) ((((x) >> 1) & 0x100) | ((x) & 0xff))
133133
134INLINE offs_t compute_safe_address(itech32_state *state, int x, int y)
134inline offs_t itech32_state::compute_safe_address(int x, int y)
135135{
136   return ((y & state->m_vram_ymask) * 512) + (x & state->m_vram_xmask);
136   return ((y & m_vram_ymask) * 512) + (x & m_vram_xmask);
137137}
138138
139INLINE void disable_clipping(itech32_state *state)
139inline void itech32_state::disable_clipping()
140140{
141   state->m_clip_save = state->m_clip_rect;
142   state->m_clip_rect.set(0, 0xfff, 0, 0xfff);
143   state->m_scaled_clip_rect.set(0, 0xfff << 8, 0, 0xfff << 8);
141   m_clip_save = m_clip_rect;
142   m_clip_rect.set(0, 0xfff, 0, 0xfff);
143   m_scaled_clip_rect.set(0, 0xfff << 8, 0, 0xfff << 8);
144144}
145145
146INLINE void enable_clipping(itech32_state *state)
146inline void itech32_state::enable_clipping()
147147{
148   state->m_clip_rect = state->m_clip_save;
148   m_clip_rect = m_clip_save;
149149
150   state->m_scaled_clip_rect.min_x = state->m_clip_rect.min_x << 8;
151   state->m_scaled_clip_rect.max_x = state->m_clip_rect.max_x << 8;
152   state->m_scaled_clip_rect.min_y = state->m_clip_rect.min_y << 8;
153   state->m_scaled_clip_rect.max_y = state->m_clip_rect.max_y << 8;
150   m_scaled_clip_rect.min_x = m_clip_rect.min_x << 8;
151   m_scaled_clip_rect.max_x = m_clip_rect.max_x << 8;
152   m_scaled_clip_rect.min_y = m_clip_rect.min_y << 8;
153   m_scaled_clip_rect.max_y = m_clip_rect.max_y << 8;
154154}
155155
156156
r20828r20829
365365 *
366366 *************************************/
367367
368static void logblit(running_machine &machine, const char *tag)
368void itech32_state::logblit(const char *tag)
369369{
370   itech32_state *state = machine.driver_data<itech32_state>();
371   if (!machine.input().code_pressed(KEYCODE_L))
370   if (!machine().input().code_pressed(KEYCODE_L))
372371      return;
373   if (state->m_is_drivedge && state->VIDEO_TRANSFER_FLAGS == 0x5490)
372   if (m_is_drivedge && VIDEO_TRANSFER_FLAGS == 0x5490)
374373   {
375374      /* polygon drawing */
376375      logerror("%s: e=%d%d f=%04x s=(%03x-%03x,%03x) w=%03x h=%03x b=%02x%04x c=%02x%02x ss=%04x,%04x ds=%04x,%04x ls=%04x%04x rs=%04x%04x u80=%04x", tag,
377         state->m_enable_latch[0], state->m_enable_latch[1],
378         state->VIDEO_TRANSFER_FLAGS,
379         state->VIDEO_TRANSFER_X, state->VIDEO_RIGHTCLIP, state->VIDEO_TRANSFER_Y, state->VIDEO_TRANSFER_WIDTH, state->VIDEO_TRANSFER_HEIGHT,
380         state->VIDEO_TRANSFER_ADDRHI, state->VIDEO_TRANSFER_ADDRLO,
381         state->m_color_latch[0] >> 8, state->m_color_latch[1] >> 8,
382         state->VIDEO_SRC_XSTEP, state->VIDEO_SRC_YSTEP,
383         state->VIDEO_DST_XSTEP, state->VIDEO_DST_YSTEP,
384         state->VIDEO_LEFTSTEPHI, state->VIDEO_LEFTSTEPLO, state->VIDEO_RIGHTSTEPHI, state->VIDEO_RIGHTSTEPLO,
385         state->VIDEO_STARTSTEP);
376         m_enable_latch[0], m_enable_latch[1],
377         VIDEO_TRANSFER_FLAGS,
378         VIDEO_TRANSFER_X, VIDEO_RIGHTCLIP, VIDEO_TRANSFER_Y, VIDEO_TRANSFER_WIDTH, VIDEO_TRANSFER_HEIGHT,
379         VIDEO_TRANSFER_ADDRHI, VIDEO_TRANSFER_ADDRLO,
380         m_color_latch[0] >> 8, m_color_latch[1] >> 8,
381         VIDEO_SRC_XSTEP, VIDEO_SRC_YSTEP,
382         VIDEO_DST_XSTEP, VIDEO_DST_YSTEP,
383         VIDEO_LEFTSTEPHI, VIDEO_LEFTSTEPLO, VIDEO_RIGHTSTEPHI, VIDEO_RIGHTSTEPLO,
384         VIDEO_STARTSTEP);
386385   }
387386
388   else if (state->m_video[0x16/2] == 0x100 && state->m_video[0x18/2] == 0x100 &&
389      state->m_video[0x1a/2] == 0x000 && state->m_video[0x1c/2] == 0x100 &&
390      state->m_video[0x1e/2] == 0x000 && state->m_video[0x20/2] == 0x000)
387   else if (m_video[0x16/2] == 0x100 && m_video[0x18/2] == 0x100 &&
388      m_video[0x1a/2] == 0x000 && m_video[0x1c/2] == 0x100 &&
389      m_video[0x1e/2] == 0x000 && m_video[0x20/2] == 0x000)
391390   {
392391      logerror("%s: e=%d%d f=%04x c=%02x%02x %02x%04x -> (%03x,%03x) %3dx%3dc=(%03x,%03x)-(%03x,%03x)", tag,
393            state->m_enable_latch[0], state->m_enable_latch[1],
394            state->VIDEO_TRANSFER_FLAGS,
395            state->m_color_latch[0] >> 8, state->m_color_latch[1] >> 8,
396            state->VIDEO_TRANSFER_ADDRHI, state->VIDEO_TRANSFER_ADDRLO,
397            state->VIDEO_TRANSFER_X, state->VIDEO_TRANSFER_Y,
398            state->VIDEO_TRANSFER_WIDTH, ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT),
399            state->VIDEO_LEFTCLIP, state->VIDEO_TOPCLIP, state->VIDEO_RIGHTCLIP, state->VIDEO_BOTTOMCLIP);
392            m_enable_latch[0], m_enable_latch[1],
393            VIDEO_TRANSFER_FLAGS,
394            m_color_latch[0] >> 8, m_color_latch[1] >> 8,
395            VIDEO_TRANSFER_ADDRHI, VIDEO_TRANSFER_ADDRLO,
396            VIDEO_TRANSFER_X, VIDEO_TRANSFER_Y,
397            VIDEO_TRANSFER_WIDTH, ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT),
398            VIDEO_LEFTCLIP, VIDEO_TOPCLIP, VIDEO_RIGHTCLIP, VIDEO_BOTTOMCLIP);
400399   }
401400   else
402401   {
403402      logerror("%s: e=%d%d f=%04x c=%02x%02x %02x%04x -> (%03x,%03x) %3dx%3d c=(%03x,%03x)-(%03x,%03x) s=%04x %04x %04x %04x %04x %04x", tag,
404            state->m_enable_latch[0], state->m_enable_latch[1],
405            state->VIDEO_TRANSFER_FLAGS,
406            state->m_color_latch[0] >> 8, state->m_color_latch[1] >> 8,
407            state->VIDEO_TRANSFER_ADDRHI, state->VIDEO_TRANSFER_ADDRLO,
408            state->VIDEO_TRANSFER_X, state->VIDEO_TRANSFER_Y,
409            state->VIDEO_TRANSFER_WIDTH, ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT),
410            state->VIDEO_LEFTCLIP, state->VIDEO_TOPCLIP, state->VIDEO_RIGHTCLIP, state->VIDEO_BOTTOMCLIP,
411            state->m_video[0x16/2], state->m_video[0x18/2], state->m_video[0x1a/2],
412            state->m_video[0x1c/2], state->m_video[0x1e/2], state->m_video[0x20/2]);
403            m_enable_latch[0], m_enable_latch[1],
404            VIDEO_TRANSFER_FLAGS,
405            m_color_latch[0] >> 8, m_color_latch[1] >> 8,
406            VIDEO_TRANSFER_ADDRHI, VIDEO_TRANSFER_ADDRLO,
407            VIDEO_TRANSFER_X, VIDEO_TRANSFER_Y,
408            VIDEO_TRANSFER_WIDTH, ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT),
409            VIDEO_LEFTCLIP, VIDEO_TOPCLIP, VIDEO_RIGHTCLIP, VIDEO_BOTTOMCLIP,
410            m_video[0x16/2], m_video[0x18/2], m_video[0x1a/2],
411            m_video[0x1c/2], m_video[0x1e/2], m_video[0x20/2]);
413412   }
414   if (state->m_is_drivedge) logerror(" v0=%08x v1=%08x v2=%08x v3=%08x", state->m_drivedge_zbuf_control[0], state->m_drivedge_zbuf_control[1], state->m_drivedge_zbuf_control[2], state->m_drivedge_zbuf_control[3]);
413   if (m_is_drivedge) logerror(" v0=%08x v1=%08x v2=%08x v3=%08x", m_drivedge_zbuf_control[0], m_drivedge_zbuf_control[1], m_drivedge_zbuf_control[2], m_drivedge_zbuf_control[3]);
415414   logerror("\n");
416415}
417416
r20828r20829
423422 *
424423 *************************************/
425424
426static void update_interrupts(running_machine &machine, int fast)
425void itech32_state::update_interrupts(int fast)
427426{
428   itech32_state *state = machine.driver_data<itech32_state>();
429427   int scanline_state = 0, blitter_state = 0;
430428
431   if (state->VIDEO_INTSTATE & state->VIDEO_INTENABLE & VIDEOINT_SCANLINE)
429   if (VIDEO_INTSTATE & VIDEO_INTENABLE & VIDEOINT_SCANLINE)
432430      scanline_state = 1;
433   if (state->VIDEO_INTSTATE & state->VIDEO_INTENABLE & VIDEOINT_BLITTER)
431   if (VIDEO_INTSTATE & VIDEO_INTENABLE & VIDEOINT_BLITTER)
434432      blitter_state = 1;
435433
436   itech32_update_interrupts(machine, -1, blitter_state, scanline_state);
434   itech32_update_interrupts(-1, blitter_state, scanline_state);
437435}
438436
439437
r20828r20829
447445   VIDEO_INTSTATE |= VIDEOINT_SCANLINE;
448446
449447   /* update the interrupt state */
450   update_interrupts(machine(), 0);
448   update_interrupts(0);
451449}
452450
453451
r20828r20829
458456 *
459457 *************************************/
460458
461static void draw_raw(itech32_state *state, UINT16 *base, UINT16 color)
459void itech32_state::draw_raw(UINT16 *base, UINT16 color)
462460{
463   UINT8 *src = &state->m_grom_base[(state->m_grom_bank | ((state->VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | state->VIDEO_TRANSFER_ADDRLO) % state->m_grom_size];
464   int transparent_pen = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
465   int width = state->VIDEO_TRANSFER_WIDTH << 8;
466   int height = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT) << 8;
467   int xsrcstep = state->VIDEO_SRC_XSTEP;
468   int ysrcstep = state->VIDEO_SRC_YSTEP;
469   int sx, sy = (state->VIDEO_TRANSFER_Y & 0xfff) << 8;
470   int startx = (state->VIDEO_TRANSFER_X & 0xfff) << 8;
461   UINT8 *src = &m_grom_base[(m_grom_bank | ((VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | VIDEO_TRANSFER_ADDRLO) % m_grom_size];
462   int transparent_pen = (VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
463   int width = VIDEO_TRANSFER_WIDTH << 8;
464   int height = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT) << 8;
465   int xsrcstep = VIDEO_SRC_XSTEP;
466   int ysrcstep = VIDEO_SRC_YSTEP;
467   int sx, sy = (VIDEO_TRANSFER_Y & 0xfff) << 8;
468   int startx = (VIDEO_TRANSFER_X & 0xfff) << 8;
471469   int xdststep = 0x100;
472   int ydststep = state->VIDEO_DST_YSTEP;
470   int ydststep = VIDEO_DST_YSTEP;
473471   int x, y;
474472
475473   /* adjust for (lack of) clipping */
476   if (!(state->VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
477      disable_clipping(state);
474   if (!(VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
475      disable_clipping();
478476
479477   /* adjust for scaling */
480   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE)
481      xdststep = state->VIDEO_DST_XSTEP;
478   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE)
479      xdststep = VIDEO_DST_XSTEP;
482480
483481   /* adjust for flipping */
484   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
482   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
485483      xdststep = -xdststep;
486   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
484   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
487485      ydststep = -ydststep;
488486
489487   /* loop over Y in src pixels */
r20828r20829
492490      UINT8 *rowsrc = &src[(y >> 8) * (width >> 8)];
493491
494492      /* simpler case: VIDEO_YSTEP_PER_X is zero */
495      if (state->VIDEO_YSTEP_PER_X == 0)
493      if (VIDEO_YSTEP_PER_X == 0)
496494      {
497495         /* clip in the Y direction */
498         if (sy >= state->m_scaled_clip_rect.min_y && sy < state->m_scaled_clip_rect.max_y)
496         if (sy >= m_scaled_clip_rect.min_y && sy < m_scaled_clip_rect.max_y)
499497         {
500498            UINT32 dstoffs;
501499
r20828r20829
504502            if (xdststep > 0)
505503            {
506504               /* skip left pixels */
507               for (x = 0; x < width && sx < state->m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep) ;
505               for (x = 0; x < width && sx < m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep) ;
508506
509507               /* compute the address */
510               dstoffs = compute_safe_address(state, sx >> 8, sy >> 8) - (sx >> 8);
508               dstoffs = compute_safe_address(sx >> 8, sy >> 8) - (sx >> 8);
511509
512510               /* render middle pixels */
513               for ( ; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
511               for ( ; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
514512               {
515513                  int pixel = rowsrc[x >> 8];
516514                  if (pixel != transparent_pen)
517                     base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
515                     base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
518516               }
519517            }
520518            else
521519            {
522520               /* skip right pixels */
523               for (x = 0; x < width && sx >= state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep) ;
521               for (x = 0; x < width && sx >= m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep) ;
524522
525523               /* compute the address */
526               dstoffs = compute_safe_address(state, sx >> 8, sy >> 8) - (sx >> 8);
524               dstoffs = compute_safe_address(sx >> 8, sy >> 8) - (sx >> 8);
527525
528526               /* render middle pixels */
529               for ( ; x < width && sx >= state->m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
527               for ( ; x < width && sx >= m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
530528               {
531529                  int pixel = rowsrc[x >> 8];
532530                  if (pixel != transparent_pen)
533                     base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
531                     base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
534532               }
535533            }
536534         }
r20828r20829
539537      /* slow case: VIDEO_YSTEP_PER_X is non-zero */
540538      else
541539      {
542         int ystep = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DYDXSIGN) ? -state->VIDEO_YSTEP_PER_X : state->VIDEO_YSTEP_PER_X;
540         int ystep = (VIDEO_TRANSFER_FLAGS & XFERFLAG_DYDXSIGN) ? -VIDEO_YSTEP_PER_X : VIDEO_YSTEP_PER_X;
543541         int ty = sy;
544542
545543         /* render all pixels */
546544         sx = startx;
547         for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
548            if (state->m_scaled_clip_rect.contains(sx, ty))
545         for (x = 0; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
546            if (m_scaled_clip_rect.contains(sx, ty))
549547            {
550548               int pixel = rowsrc[x >> 8];
551549               if (pixel != transparent_pen)
552                  base[compute_safe_address(state, sx >> 8, ty >> 8)] = pixel | color;
550                  base[compute_safe_address(sx >> 8, ty >> 8)] = pixel | color;
553551            }
554552      }
555553
556554      /* apply skew */
557      if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DXDYSIGN)
558         startx += state->VIDEO_XSTEP_PER_Y;
555      if (VIDEO_TRANSFER_FLAGS & XFERFLAG_DXDYSIGN)
556         startx += VIDEO_XSTEP_PER_Y;
559557      else
560         startx -= state->VIDEO_XSTEP_PER_Y;
558         startx -= VIDEO_XSTEP_PER_Y;
561559   }
562560
563561   /* restore cliprects */
564   if (!(state->VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
565      enable_clipping(state);
562   if (!(VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
563      enable_clipping();
566564}
567565
568566
569static void draw_raw_drivedge(itech32_state *state, UINT16 *base, UINT16 *zbase, UINT16 color)
567void itech32_state::draw_raw_drivedge(UINT16 *base, UINT16 *zbase, UINT16 color)
570568{
571   UINT8 *src = &state->m_grom_base[(state->m_grom_bank | ((state->VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | state->VIDEO_TRANSFER_ADDRLO) % state->m_grom_size];
572   int transparent_pen = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
573   int width = state->VIDEO_TRANSFER_WIDTH << 8;
574   int height = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT) << 8;
575   int xsrcstep = state->VIDEO_SRC_XSTEP;
576   int ysrcstep = state->VIDEO_SRC_YSTEP;
577   int sx, sy = ((state->VIDEO_TRANSFER_Y & 0xfff) << 8) + 0x80;
578   int startx = ((state->VIDEO_TRANSFER_X & 0xfff) << 8) + 0x80;
569   UINT8 *src = &m_grom_base[(m_grom_bank | ((VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | VIDEO_TRANSFER_ADDRLO) % m_grom_size];
570   int transparent_pen = (VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
571   int width = VIDEO_TRANSFER_WIDTH << 8;
572   int height = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT) << 8;
573   int xsrcstep = VIDEO_SRC_XSTEP;
574   int ysrcstep = VIDEO_SRC_YSTEP;
575   int sx, sy = ((VIDEO_TRANSFER_Y & 0xfff) << 8) + 0x80;
576   int startx = ((VIDEO_TRANSFER_X & 0xfff) << 8) + 0x80;
579577   int xdststep = 0x100;
580   int ydststep = state->VIDEO_DST_YSTEP;
581   INT32 z0 = state->m_drivedge_zbuf_control[2] & 0x7ff00;
582   INT32 zmatch = (state->m_drivedge_zbuf_control[2] & 0x1f) << 11;
578   int ydststep = VIDEO_DST_YSTEP;
579   INT32 z0 = m_drivedge_zbuf_control[2] & 0x7ff00;
580   INT32 zmatch = (m_drivedge_zbuf_control[2] & 0x1f) << 11;
583581   INT32 srcdelta = 0;
584582   int x, y;
585583
586584   /* adjust for (lack of) clipping */
587   if (!(state->VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
588      disable_clipping(state);
585   if (!(VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
586      disable_clipping();
589587
590588   /* adjust for scaling */
591   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE)
592      xdststep = state->VIDEO_DST_XSTEP;
589   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE)
590      xdststep = VIDEO_DST_XSTEP;
593591
594592   /* adjust for flipping */
595   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
593   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
596594      xdststep = -xdststep;
597   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
595   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
598596      ydststep = -ydststep;
599597
600598   /* loop over Y in src pixels */
r20828r20829
603601      UINT8 *rowsrc = src + (srcdelta >> 8);
604602
605603      /* in the polygon case, we don't factor in the Y */
606      if (state->VIDEO_TRANSFER_FLAGS != 0x5490)
604      if (VIDEO_TRANSFER_FLAGS != 0x5490)
607605         rowsrc += (y >> 8) * (width >> 8);
608606      else
609607         width = 1000 << 8;
610608
611609      /* simpler case: VIDEO_YSTEP_PER_X is zero */
612      if (state->VIDEO_YSTEP_PER_X == 0)
610      if (VIDEO_YSTEP_PER_X == 0)
613611      {
614612         /* clip in the Y direction */
615         if (sy >= state->m_scaled_clip_rect.min_y && sy < state->m_scaled_clip_rect.max_y)
613         if (sy >= m_scaled_clip_rect.min_y && sy < m_scaled_clip_rect.max_y)
616614         {
617615            UINT32 dstoffs, zbufoffs;
618616            INT32 z = z0;
r20828r20829
622620            if (xdststep > 0)
623621            {
624622               /* skip left pixels */
625               for (x = 0; x < width && sx < state->m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
626                  z += (INT32)state->m_drivedge_zbuf_control[0];
623               for (x = 0; x < width && sx < m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
624                  z += (INT32)m_drivedge_zbuf_control[0];
627625
628626               /* compute the address */
629               dstoffs = compute_safe_address(state, sx >> 8, sy >> 8) - (sx >> 8);
630               zbufoffs = compute_safe_address(state, sx >> 8, sy >> 8) - (sx >> 8);
627               dstoffs = compute_safe_address(sx >> 8, sy >> 8) - (sx >> 8);
628               zbufoffs = compute_safe_address(sx >> 8, sy >> 8) - (sx >> 8);
631629
632630               /* render middle pixels */
633               if (state->m_drivedge_zbuf_control[3] & 0x8000)
631               if (m_drivedge_zbuf_control[3] & 0x8000)
634632               {
635                  for ( ; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
633                  for ( ; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
636634                  {
637635                     int pixel = rowsrc[x >> 8];
638636                     if (pixel != transparent_pen)
639637                     {
640                        base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
641                        zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] = (z >> 8) | zmatch;
638                        base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
639                        zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] = (z >> 8) | zmatch;
642640                     }
643                     z += (INT32)state->m_drivedge_zbuf_control[0];
641                     z += (INT32)m_drivedge_zbuf_control[0];
644642                  }
645643               }
646               else if (state->m_drivedge_zbuf_control[3] & 0x4000)
644               else if (m_drivedge_zbuf_control[3] & 0x4000)
647645               {
648                  for ( ; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
646                  for ( ; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
649647                  {
650648                     int pixel = rowsrc[x >> 8];
651                     if (pixel != transparent_pen && zmatch == (zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] & (0x1f << 11)))
652                        base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
653                     z += (INT32)state->m_drivedge_zbuf_control[0];
649                     if (pixel != transparent_pen && zmatch == (zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] & (0x1f << 11)))
650                        base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
651                     z += (INT32)m_drivedge_zbuf_control[0];
654652                  }
655653               }
656654               else
657655               {
658                  for ( ; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
656                  for ( ; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
659657                  {
660658                     int pixel = rowsrc[x >> 8];
661                     if (pixel != transparent_pen && ((z >> 8) <= (zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] & 0x7ff)))
659                     if (pixel != transparent_pen && ((z >> 8) <= (zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] & 0x7ff)))
662660                     {
663                        base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
664                        zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] = (z >> 8) | zmatch;
661                        base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
662                        zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] = (z >> 8) | zmatch;
665663                     }
666                     z += (INT32)state->m_drivedge_zbuf_control[0];
664                     z += (INT32)m_drivedge_zbuf_control[0];
667665                  }
668666               }
669667            }
670668            else
671669            {
672670               /* skip right pixels */
673               for (x = 0; x < width && sx >= state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
674                  z += (INT32)state->m_drivedge_zbuf_control[0];
671               for (x = 0; x < width && sx >= m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep)
672                  z += (INT32)m_drivedge_zbuf_control[0];
675673
676674               /* compute the address */
677               dstoffs = compute_safe_address(state, sx >> 8, sy >> 8) - (sx >> 8);
678               zbufoffs = compute_safe_address(state, sx >> 8, sy >> 8) - (sx >> 8);
675               dstoffs = compute_safe_address(sx >> 8, sy >> 8) - (sx >> 8);
676               zbufoffs = compute_safe_address(sx >> 8, sy >> 8) - (sx >> 8);
679677
680678               /* render middle pixels */
681               if (state->m_drivedge_zbuf_control[3] & 0x8000)
679               if (m_drivedge_zbuf_control[3] & 0x8000)
682680               {
683                  for ( ; x < width && sx >= state->m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
681                  for ( ; x < width && sx >= m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
684682                  {
685683                     int pixel = rowsrc[x >> 8];
686684                     if (pixel != transparent_pen)
687685                     {
688                        base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
689                        zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] = (z >> 8) | zmatch;
686                        base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
687                        zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] = (z >> 8) | zmatch;
690688                     }
691                     z += (INT32)state->m_drivedge_zbuf_control[0];
689                     z += (INT32)m_drivedge_zbuf_control[0];
692690                  }
693691               }
694               else if (state->m_drivedge_zbuf_control[3] & 0x4000)
692               else if (m_drivedge_zbuf_control[3] & 0x4000)
695693               {
696                  for ( ; x < width && sx >= state->m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
694                  for ( ; x < width && sx >= m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
697695                  {
698696                     int pixel = rowsrc[x >> 8];
699                     if (pixel != transparent_pen && zmatch == (zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] & (0x1f << 11)))
700                        base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
701                     z += (INT32)state->m_drivedge_zbuf_control[0];
697                     if (pixel != transparent_pen && zmatch == (zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] & (0x1f << 11)))
698                        base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
699                     z += (INT32)m_drivedge_zbuf_control[0];
702700                  }
703701               }
704702               else
705703               {
706                  for ( ; x < width && sx >= state->m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
704                  for ( ; x < width && sx >= m_scaled_clip_rect.min_x; x += xsrcstep, sx += xdststep)
707705                  {
708706                     int pixel = rowsrc[x >> 8];
709                     if (pixel != transparent_pen && ((z >> 8) <= (zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] & 0x7ff)))
707                     if (pixel != transparent_pen && ((z >> 8) <= (zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] & 0x7ff)))
710708                     {
711                        base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = pixel | color;
712                        zbase[(zbufoffs + (sx >> 8)) & state->m_vram_mask] = (z >> 8) | zmatch;
709                        base[(dstoffs + (sx >> 8)) & m_vram_mask] = pixel | color;
710                        zbase[(zbufoffs + (sx >> 8)) & m_vram_mask] = (z >> 8) | zmatch;
713711                     }
714                     z += (INT32)state->m_drivedge_zbuf_control[0];
712                     z += (INT32)m_drivedge_zbuf_control[0];
715713                  }
716714               }
717715            }
r20828r20829
721719      /* slow case: VIDEO_YSTEP_PER_X is non-zero */
722720      else
723721      {
724         int ystep = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DYDXSIGN) ? -state->VIDEO_YSTEP_PER_X : state->VIDEO_YSTEP_PER_X;
722         int ystep = (VIDEO_TRANSFER_FLAGS & XFERFLAG_DYDXSIGN) ? -VIDEO_YSTEP_PER_X : VIDEO_YSTEP_PER_X;
725723         int ty = sy;
726724         INT32 z = z0;
727725
728726         /* render all pixels */
729727         sx = startx;
730         if (state->m_drivedge_zbuf_control[3] & 0x8000)
728         if (m_drivedge_zbuf_control[3] & 0x8000)
731729         {
732            for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
733               if (state->m_scaled_clip_rect.contains(sx, ty))
730            for (x = 0; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
731               if (m_scaled_clip_rect.contains(sx, ty))
734732               {
735733                  int pixel = rowsrc[x >> 8];
736734                  if (pixel != transparent_pen)
737735                  {
738                     base[compute_safe_address(state, sx >> 8, ty >> 8)] = pixel | color;
739                     zbase[compute_safe_address(state, sx >> 8, ty >> 8)] = (z >> 8) | zmatch;
736                     base[compute_safe_address(sx >> 8, ty >> 8)] = pixel | color;
737                     zbase[compute_safe_address(sx >> 8, ty >> 8)] = (z >> 8) | zmatch;
740738                  }
741                  z += (INT32)state->m_drivedge_zbuf_control[0];
739                  z += (INT32)m_drivedge_zbuf_control[0];
742740               }
743741         }
744         else if (state->m_drivedge_zbuf_control[3] & 0x4000)
742         else if (m_drivedge_zbuf_control[3] & 0x4000)
745743         {
746            for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
747               if (state->m_scaled_clip_rect.contains(sx, ty))
744            for (x = 0; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
745               if (m_scaled_clip_rect.contains(sx, ty))
748746               {
749747                  int pixel = rowsrc[x >> 8];
750                  UINT16 *zbuf = &zbase[compute_safe_address(state, sx >> 8, ty >> 8)];
748                  UINT16 *zbuf = &zbase[compute_safe_address(sx >> 8, ty >> 8)];
751749                  if (pixel != transparent_pen && zmatch == (*zbuf & (0x1f << 11)))
752750                  {
753                     base[compute_safe_address(state, sx >> 8, ty >> 8)] = pixel | color;
751                     base[compute_safe_address(sx >> 8, ty >> 8)] = pixel | color;
754752                     *zbuf = (z >> 8) | zmatch;
755753                  }
756                  z += (INT32)state->m_drivedge_zbuf_control[0];
754                  z += (INT32)m_drivedge_zbuf_control[0];
757755               }
758756         }
759757         else
760758         {
761            for (x = 0; x < width && sx < state->m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
762               if (state->m_scaled_clip_rect.contains(sx, ty))
759            for (x = 0; x < width && sx < m_scaled_clip_rect.max_x; x += xsrcstep, sx += xdststep, ty += ystep)
760               if (m_scaled_clip_rect.contains(sx, ty))
763761               {
764762                  int pixel = rowsrc[x >> 8];
765                  UINT16 *zbuf = &zbase[compute_safe_address(state, sx >> 8, ty >> 8)];
763                  UINT16 *zbuf = &zbase[compute_safe_address(sx >> 8, ty >> 8)];
766764                  if (pixel != transparent_pen && ((z >> 8) <= (*zbuf & 0x7ff)))
767765                  {
768                     base[compute_safe_address(state, sx >> 8, ty >> 8)] = pixel | color;
766                     base[compute_safe_address(sx >> 8, ty >> 8)] = pixel | color;
769767                     *zbuf = (z >> 8) | zmatch;
770768                  }
771                  z += (INT32)state->m_drivedge_zbuf_control[0];
769                  z += (INT32)m_drivedge_zbuf_control[0];
772770               }
773771         }
774772      }
775773
776774      /* apply skew */
777      if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DXDYSIGN)
778         startx += state->VIDEO_XSTEP_PER_Y;
775      if (VIDEO_TRANSFER_FLAGS & XFERFLAG_DXDYSIGN)
776         startx += VIDEO_XSTEP_PER_Y;
779777      else
780         startx -= state->VIDEO_XSTEP_PER_Y;
778         startx -= VIDEO_XSTEP_PER_Y;
781779
782780      /* update the per-scanline parameters */
783      if (state->VIDEO_TRANSFER_FLAGS == 0x5490)
781      if (VIDEO_TRANSFER_FLAGS == 0x5490)
784782      {
785         startx += (INT32)((state->VIDEO_LEFTSTEPHI << 16) | state->VIDEO_LEFTSTEPLO);
786         state->m_scaled_clip_rect.max_x += (INT32)((state->VIDEO_RIGHTSTEPHI << 16) | state->VIDEO_RIGHTSTEPLO);
787         srcdelta += (INT16)state->VIDEO_STARTSTEP;
783         startx += (INT32)((VIDEO_LEFTSTEPHI << 16) | VIDEO_LEFTSTEPLO);
784         m_scaled_clip_rect.max_x += (INT32)((VIDEO_RIGHTSTEPHI << 16) | VIDEO_RIGHTSTEPLO);
785         srcdelta += (INT16)VIDEO_STARTSTEP;
788786      }
789      z0 += (INT32)state->m_drivedge_zbuf_control[1];
787      z0 += (INT32)m_drivedge_zbuf_control[1];
790788   }
791789
792790   /* restore cliprects */
793   if (!(state->VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
794      enable_clipping(state);
791   if (!(VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
792      enable_clipping();
795793
796794   /* reflect the final values into registers */
797   state->VIDEO_TRANSFER_X = (state->VIDEO_TRANSFER_X & ~0xfff) | (startx >> 8);
798   state->VIDEO_RIGHTCLIP = (state->VIDEO_RIGHTCLIP & ~0xfff) | (state->m_scaled_clip_rect.max_x >> 8);
799   state->VIDEO_TRANSFER_Y = (state->VIDEO_TRANSFER_Y & ~0xfff) | ((state->VIDEO_TRANSFER_Y + (y >> 8)) & 0xfff);
800   state->VIDEO_TRANSFER_ADDRLO += srcdelta >> 8;
795   VIDEO_TRANSFER_X = (VIDEO_TRANSFER_X & ~0xfff) | (startx >> 8);
796   VIDEO_RIGHTCLIP = (VIDEO_RIGHTCLIP & ~0xfff) | (m_scaled_clip_rect.max_x >> 8);
797   VIDEO_TRANSFER_Y = (VIDEO_TRANSFER_Y & ~0xfff) | ((VIDEO_TRANSFER_Y + (y >> 8)) & 0xfff);
798   VIDEO_TRANSFER_ADDRLO += srcdelta >> 8;
801799
802   state->m_drivedge_zbuf_control[2] = (state->m_drivedge_zbuf_control[2] & ~0x7ff00) | (z0 & 0x7ff00);
800   m_drivedge_zbuf_control[2] = (m_drivedge_zbuf_control[2] & ~0x7ff00) | (z0 & 0x7ff00);
803801}
804802
805803
r20828r20829
848846 *
849847 *************************************/
850848
851INLINE void draw_rle_fast(itech32_state *state, UINT16 *base, UINT16 color)
849inline void itech32_state::draw_rle_fast(UINT16 *base, UINT16 color)
852850{
853   UINT8 *src = &state->m_grom_base[(state->m_grom_bank | ((state->VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | state->VIDEO_TRANSFER_ADDRLO) % state->m_grom_size];
854   int transparent_pen = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
855   int width = state->VIDEO_TRANSFER_WIDTH;
856   int height = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT);
857   int sx = state->VIDEO_TRANSFER_X & 0xfff;
858   int sy = (state->VIDEO_TRANSFER_Y & 0xfff) << 8;
851   UINT8 *src = &m_grom_base[(m_grom_bank | ((VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | VIDEO_TRANSFER_ADDRLO) % m_grom_size];
852   int transparent_pen = (VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
853   int width = VIDEO_TRANSFER_WIDTH;
854   int height = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT);
855   int sx = VIDEO_TRANSFER_X & 0xfff;
856   int sy = (VIDEO_TRANSFER_Y & 0xfff) << 8;
859857   int xleft, y, count = 0, val = 0, innercount;
860   int ydststep = state->VIDEO_DST_YSTEP;
858   int ydststep = VIDEO_DST_YSTEP;
861859   int lclip, rclip;
862860
863861   /* determine clipping */
864   lclip = state->m_clip_rect.min_x - sx;
862   lclip = m_clip_rect.min_x - sx;
865863   if (lclip < 0) lclip = 0;
866   rclip = sx + width - state->m_clip_rect.max_x;
864   rclip = sx + width - m_clip_rect.max_x;
867865   if (rclip < 0) rclip = 0;
868866   width -= lclip + rclip;
869867   sx += lclip;
870868
871869   /* adjust for flipping */
872   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
870   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
873871      ydststep = -ydststep;
874872
875873   /* loop over Y in src pixels */
r20828r20829
878876      UINT32 dstoffs;
879877
880878      /* clip in the Y direction */
881      if (sy < state->m_scaled_clip_rect.min_y || sy >= state->m_scaled_clip_rect.max_y)
879      if (sy < m_scaled_clip_rect.min_y || sy >= m_scaled_clip_rect.max_y)
882880      {
883881         SKIP_RLE(width + lclip + rclip, xleft, count, innercount, src);
884882         continue;
885883      }
886884
887885      /* compute the address */
888      dstoffs = compute_safe_address(state, sx, sy >> 8);
886      dstoffs = compute_safe_address(sx, sy >> 8);
889887
890888      /* left clip */
891889      SKIP_RLE(lclip, xleft, count, innercount, src);
r20828r20829
902900            {
903901               int pixel = *src++;
904902               if (pixel != transparent_pen)
905                  base[dstoffs & state->m_vram_mask] = color | pixel;
903                  base[dstoffs & m_vram_mask] = color | pixel;
906904               dstoffs++;
907905            }
908906
r20828r20829
911909         {
912910            val |= color;
913911            while (innercount--)
914               base[dstoffs++ & state->m_vram_mask] = val;
912               base[dstoffs++ & m_vram_mask] = val;
915913         }
916914
917915         /* run of transparent repeats */
r20828r20829
925923}
926924
927925
928INLINE void draw_rle_fast_xflip(itech32_state *state, UINT16 *base, UINT16 color)
926inline void itech32_state::draw_rle_fast_xflip(UINT16 *base, UINT16 color)
929927{
930   UINT8 *src = &state->m_grom_base[(state->m_grom_bank | ((state->VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | state->VIDEO_TRANSFER_ADDRLO) % state->m_grom_size];
931   int transparent_pen = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
932   int width = state->VIDEO_TRANSFER_WIDTH;
933   int height = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT);
934   int sx = state->VIDEO_TRANSFER_X & 0xfff;
935   int sy = (state->VIDEO_TRANSFER_Y & 0xfff) << 8;
928   UINT8 *src = &m_grom_base[(m_grom_bank | ((VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | VIDEO_TRANSFER_ADDRLO) % m_grom_size];
929   int transparent_pen = (VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
930   int width = VIDEO_TRANSFER_WIDTH;
931   int height = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT);
932   int sx = VIDEO_TRANSFER_X & 0xfff;
933   int sy = (VIDEO_TRANSFER_Y & 0xfff) << 8;
936934   int xleft, y, count = 0, val = 0, innercount;
937   int ydststep = state->VIDEO_DST_YSTEP;
935   int ydststep = VIDEO_DST_YSTEP;
938936   int lclip, rclip;
939937
940938   /* determine clipping */
941   lclip = sx - state->m_clip_rect.max_x;
939   lclip = sx - m_clip_rect.max_x;
942940   if (lclip < 0) lclip = 0;
943   rclip = state->m_clip_rect.min_x - (sx - width);
941   rclip = m_clip_rect.min_x - (sx - width);
944942   if (rclip < 0) rclip = 0;
945943   width -= lclip + rclip;
946944   sx -= lclip;
947945
948946   /* adjust for flipping */
949   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
947   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
950948      ydststep = -ydststep;
951949
952950   /* loop over Y in src pixels */
r20828r20829
955953      UINT32 dstoffs;
956954
957955      /* clip in the Y direction */
958      if (sy < state->m_scaled_clip_rect.min_y || sy >= state->m_scaled_clip_rect.max_y)
956      if (sy < m_scaled_clip_rect.min_y || sy >= m_scaled_clip_rect.max_y)
959957      {
960958         SKIP_RLE(width + lclip + rclip, xleft, count, innercount, src);
961959         continue;
962960      }
963961
964962      /* compute the address */
965      dstoffs = compute_safe_address(state, sx, sy >> 8);
963      dstoffs = compute_safe_address(sx, sy >> 8);
966964
967965      /* left clip */
968966      SKIP_RLE(lclip, xleft, count, innercount, src);
r20828r20829
979977            {
980978               int pixel = *src++;
981979               if (pixel != transparent_pen)
982                  base[dstoffs & state->m_vram_mask] = color | pixel;
980                  base[dstoffs & m_vram_mask] = color | pixel;
983981               dstoffs--;
984982            }
985983
r20828r20829
988986         {
989987            val |= color;
990988            while (innercount--)
991               base[dstoffs-- & state->m_vram_mask] = val;
989               base[dstoffs-- & m_vram_mask] = val;
992990         }
993991
994992         /* run of transparent repeats */
r20828r20829
10091007 *
10101008 *************************************/
10111009
1012INLINE void draw_rle_slow(itech32_state *state, UINT16 *base, UINT16 color)
1010inline void itech32_state::draw_rle_slow(UINT16 *base, UINT16 color)
10131011{
1014   UINT8 *src = &state->m_grom_base[(state->m_grom_bank | ((state->VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | state->VIDEO_TRANSFER_ADDRLO) % state->m_grom_size];
1015   int transparent_pen = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
1016   int width = state->VIDEO_TRANSFER_WIDTH;
1017   int height = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT);
1018   int sx, sy = (state->VIDEO_TRANSFER_Y & 0xfff) << 8;
1012   UINT8 *src = &m_grom_base[(m_grom_bank | ((VIDEO_TRANSFER_ADDRHI & 0xff) << 16) | VIDEO_TRANSFER_ADDRLO) % m_grom_size];
1013   int transparent_pen = (VIDEO_TRANSFER_FLAGS & XFERFLAG_TRANSPARENT) ? 0xff : -1;
1014   int width = VIDEO_TRANSFER_WIDTH;
1015   int height = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT);
1016   int sx, sy = (VIDEO_TRANSFER_Y & 0xfff) << 8;
10191017   int xleft, y, count = 0, val = 0, innercount;
10201018   int xdststep = 0x100;
1021   int ydststep = state->VIDEO_DST_YSTEP;
1022   int startx = (state->VIDEO_TRANSFER_X & 0xfff) << 8;
1019   int ydststep = VIDEO_DST_YSTEP;
1020   int startx = (VIDEO_TRANSFER_X & 0xfff) << 8;
10231021
10241022   /* adjust for scaling */
1025   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE)
1026      xdststep = state->VIDEO_DST_XSTEP;
1023   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE)
1024      xdststep = VIDEO_DST_XSTEP;
10271025
10281026   /* adjust for flipping */
1029   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
1027   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
10301028      xdststep = -xdststep;
1031   if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
1029   if (VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP)
10321030      ydststep = -ydststep;
10331031
10341032   /* loop over Y in src pixels */
r20828r20829
10371035      UINT32 dstoffs;
10381036
10391037      /* clip in the Y direction */
1040      if (sy < state->m_scaled_clip_rect.min_y || sy >= state->m_scaled_clip_rect.max_y)
1038      if (sy < m_scaled_clip_rect.min_y || sy >= m_scaled_clip_rect.max_y)
10411039      {
10421040         SKIP_RLE(width, xleft, count, innercount, src);
10431041         continue;
r20828r20829
10451043
10461044      /* compute the address */
10471045      sx = startx;
1048      dstoffs = compute_safe_address(state, state->m_clip_rect.min_x, sy >> 8) - state->m_clip_rect.min_x;
1046      dstoffs = compute_safe_address(m_clip_rect.min_x, sy >> 8) - m_clip_rect.min_x;
10491047
10501048      /* loop until gone */
10511049      for (xleft = width; xleft > 0; )
r20828r20829
10591057            {
10601058               int pixel = *src++;
10611059               if (pixel != transparent_pen)
1062                  if (sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x)
1063                     base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = color | pixel;
1060                  if (sx >= m_scaled_clip_rect.min_x && sx < m_scaled_clip_rect.max_x)
1061                     base[(dstoffs + (sx >> 8)) & m_vram_mask] = color | pixel;
10641062            }
10651063
10661064         /* run of non-transparent repeats */
r20828r20829
10681066         {
10691067            val |= color;
10701068            for ( ; innercount--; sx += xdststep)
1071               if (sx >= state->m_scaled_clip_rect.min_x && sx < state->m_scaled_clip_rect.max_x)
1072                  base[(dstoffs + (sx >> 8)) & state->m_vram_mask] = val;
1069               if (sx >= m_scaled_clip_rect.min_x && sx < m_scaled_clip_rect.max_x)
1070                  base[(dstoffs + (sx >> 8)) & m_vram_mask] = val;
10731071         }
10741072
10751073         /* run of transparent repeats */
r20828r20829
10781076      }
10791077
10801078      /* apply skew */
1081      if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DXDYSIGN)
1082         startx += state->VIDEO_XSTEP_PER_Y;
1079      if (VIDEO_TRANSFER_FLAGS & XFERFLAG_DXDYSIGN)
1080         startx += VIDEO_XSTEP_PER_Y;
10831081      else
1084         startx -= state->VIDEO_XSTEP_PER_Y;
1082         startx -= VIDEO_XSTEP_PER_Y;
10851083   }
10861084}
10871085
10881086
10891087
1090static void draw_rle(itech32_state *state, UINT16 *base, UINT16 color)
1088void itech32_state::draw_rle(UINT16 *base, UINT16 color)
10911089{
10921090   /* adjust for (lack of) clipping */
1093   if (!(state->VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
1094      disable_clipping(state);
1091   if (!(VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
1092      disable_clipping();
10951093
10961094   /* if we have an X scale, draw it slow */
1097   if (((state->VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE) && state->VIDEO_DST_XSTEP != 0x100) || state->VIDEO_XSTEP_PER_Y)
1098      draw_rle_slow(state, base, color);
1095   if (((VIDEO_TRANSFER_FLAGS & XFERFLAG_DSTXSCALE) && VIDEO_DST_XSTEP != 0x100) || VIDEO_XSTEP_PER_Y)
1096      draw_rle_slow(base, color);
10991097
11001098   /* else draw it fast */
1101   else if (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
1102      draw_rle_fast_xflip(state, base, color);
1099   else if (VIDEO_TRANSFER_FLAGS & XFERFLAG_XFLIP)
1100      draw_rle_fast_xflip(base, color);
11031101   else
1104      draw_rle_fast(state, base, color);
1102      draw_rle_fast(base, color);
11051103
11061104   /* restore cliprects */
1107   if (!(state->VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
1108      enable_clipping(state);
1105   if (!(VIDEO_TRANSFER_FLAGS & XFERFLAG_CLIP))
1106      enable_clipping();
11091107}
11101108
11111109
r20828r20829
11161114 *
11171115 *************************************/
11181116
1119static void shiftreg_clear(itech32_state *state, UINT16 *base, UINT16 *zbase)
1117void itech32_state::shiftreg_clear(UINT16 *base, UINT16 *zbase)
11201118{
1121   int ydir = (state->VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP) ? -1 : 1;
1122   int height = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT);
1123   int sx = state->VIDEO_TRANSFER_X & 0xfff;
1124   int sy = state->VIDEO_TRANSFER_Y & 0xfff;
1119   int ydir = (VIDEO_TRANSFER_FLAGS & XFERFLAG_YFLIP) ? -1 : 1;
1120   int height = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT);
1121   int sx = VIDEO_TRANSFER_X & 0xfff;
1122   int sy = VIDEO_TRANSFER_Y & 0xfff;
11251123   UINT16 *src;
11261124   int y;
11271125
11281126   /* first line is the source */
1129   src = &base[compute_safe_address(state, sx, sy)];
1127   src = &base[compute_safe_address(sx, sy)];
11301128   sy += ydir;
11311129
11321130   /* loop over height */
11331131   for (y = 1; y < height; y++)
11341132   {
1135      memcpy(&base[compute_safe_address(state, sx, sy)], src, 512*2);
1133      memcpy(&base[compute_safe_address(sx, sy)], src, 512*2);
11361134      if (zbase)
11371135      {
1138         UINT16 zval = ((state->m_drivedge_zbuf_control[2] >> 8) & 0x7ff) | ((state->m_drivedge_zbuf_control[2] & 0x1f) << 11);
1139         UINT16 *dst = &zbase[compute_safe_address(state, sx, sy)];
1136         UINT16 zval = ((m_drivedge_zbuf_control[2] >> 8) & 0x7ff) | ((m_drivedge_zbuf_control[2] & 0x1f) << 11);
1137         UINT16 *dst = &zbase[compute_safe_address(sx, sy)];
11401138         int x;
11411139         for (x = 0; x < 512; x++)
11421140            *dst++ = zval;
r20828r20829
11531151 *
11541152 *************************************/
11551153
1156static void handle_video_command(running_machine &machine)
1154void itech32_state::handle_video_command()
11571155{
1158   itech32_state *state = machine.driver_data<itech32_state>();
11591156   /* only 6 known commands */
1160   switch (state->VIDEO_COMMAND)
1157   switch (VIDEO_COMMAND)
11611158   {
11621159      /* command 1: blit raw data */
11631160      case 1:
11641161         g_profiler.start(PROFILER_USER1);
1165         if (BLIT_LOGGING) logblit(machine, "Blit Raw");
1162         if (BLIT_LOGGING) logblit("Blit Raw");
11661163
1167         if (state->m_is_drivedge)
1164         if (m_is_drivedge)
11681165         {
1169            if (state->m_enable_latch[0]) draw_raw_drivedge(state, state->m_videoplane[0], state->m_videoplane[1], state->m_color_latch[0]);
1166            if (m_enable_latch[0]) draw_raw_drivedge(m_videoplane[0], m_videoplane[1], m_color_latch[0]);
11701167         }
11711168         else
11721169         {
1173            if (state->m_enable_latch[0]) draw_raw(state, state->m_videoplane[0], state->m_color_latch[0]);
1174            if (state->m_enable_latch[1]) draw_raw(state, state->m_videoplane[1], state->m_color_latch[1]);
1170            if (m_enable_latch[0]) draw_raw(m_videoplane[0], m_color_latch[0]);
1171            if (m_enable_latch[1]) draw_raw(m_videoplane[1], m_color_latch[1]);
11751172         }
11761173
11771174         g_profiler.stop();
r20828r20829
11801177      /* command 2: blit RLE-compressed data */
11811178      case 2:
11821179         g_profiler.start(PROFILER_USER2);
1183         if (BLIT_LOGGING) logblit(machine, "Blit RLE");
1180         if (BLIT_LOGGING) logblit("Blit RLE");
11841181
1185         if (state->m_enable_latch[0]) draw_rle(state, state->m_videoplane[0], state->m_color_latch[0]);
1186         if (state->m_enable_latch[1]) draw_rle(state, state->m_videoplane[1], state->m_color_latch[1]);
1182         if (m_enable_latch[0]) draw_rle(m_videoplane[0], m_color_latch[0]);
1183         if (m_enable_latch[1]) draw_rle(m_videoplane[1], m_color_latch[1]);
11871184
11881185         g_profiler.stop();
11891186         break;
11901187
11911188      /* command 3: set up raw data transfer */
11921189      case 3:
1193         if (BLIT_LOGGING) logblit(machine, "Raw Xfer");
1194         state->m_xfer_xcount = state->VIDEO_TRANSFER_WIDTH;
1195         state->m_xfer_ycount = ADJUSTED_HEIGHT(state->VIDEO_TRANSFER_HEIGHT);
1196         state->m_xfer_xcur = state->VIDEO_TRANSFER_X & 0xfff;
1197         state->m_xfer_ycur = state->VIDEO_TRANSFER_Y & 0xfff;
1190         if (BLIT_LOGGING) logblit("Raw Xfer");
1191         m_xfer_xcount = VIDEO_TRANSFER_WIDTH;
1192         m_xfer_ycount = ADJUSTED_HEIGHT(VIDEO_TRANSFER_HEIGHT);
1193         m_xfer_xcur = VIDEO_TRANSFER_X & 0xfff;
1194         m_xfer_ycur = VIDEO_TRANSFER_Y & 0xfff;
11981195         break;
11991196
12001197      /* command 4: flush? */
r20828r20829
12081205      /* command 6: perform shift register copy */
12091206      case 6:
12101207         g_profiler.start(PROFILER_USER3);
1211         if (BLIT_LOGGING) logblit(machine, "ShiftReg");
1208         if (BLIT_LOGGING) logblit("ShiftReg");
12121209
1213         if (state->m_is_drivedge)
1210         if (m_is_drivedge)
12141211         {
1215            if (state->m_enable_latch[0]) shiftreg_clear(state, state->m_videoplane[0], state->m_videoplane[1]);
1212            if (m_enable_latch[0]) shiftreg_clear(m_videoplane[0], m_videoplane[1]);
12161213         }
12171214         else
12181215         {
1219            if (state->m_enable_latch[0]) shiftreg_clear(state, state->m_videoplane[0], NULL);
1220            if (state->m_enable_latch[1]) shiftreg_clear(state, state->m_videoplane[1], NULL);
1216            if (m_enable_latch[0]) shiftreg_clear(m_videoplane[0], NULL);
1217            if (m_enable_latch[1]) shiftreg_clear(m_videoplane[1], NULL);
12211218         }
12221219
12231220         g_profiler.stop();
12241221         break;
12251222
12261223      default:
1227         if (BLIT_LOGGING) logerror("Unknown blit command %d\n", state->VIDEO_COMMAND);
1224         if (BLIT_LOGGING) logerror("Unknown blit command %d\n", VIDEO_COMMAND);
12281225         break;
12291226   }
12301227
12311228   /* tell the processor we're done */
1232   state->VIDEO_INTSTATE |= VIDEOINT_BLITTER;
1233   update_interrupts(machine, 1);
1229   VIDEO_INTSTATE |= VIDEOINT_BLITTER;
1230   update_interrupts(1);
12341231}
12351232
12361233
r20828r20829
12521249   {
12531250      case 0x02/2:    /* VIDEO_INTACK */
12541251         VIDEO_INTSTATE = old & ~data;
1255         update_interrupts(machine(), 1);
1252         update_interrupts(1);
12561253         break;
12571254
12581255      case 0x04/2:    /* VIDEO_TRANSFER */
12591256         if (VIDEO_COMMAND == 3 && m_xfer_ycount)
12601257         {
1261            itech32_state *state = machine().driver_data<itech32_state>();
1262            offs_t addr = compute_safe_address(state, m_xfer_xcur, m_xfer_ycur);
1258            offs_t addr = compute_safe_address(m_xfer_xcur, m_xfer_ycur);
12631259            if (m_enable_latch[0])
12641260            {
12651261               VIDEO_TRANSFER = m_videoplane[0][addr];
r20828r20829
12781274         break;
12791275
12801276      case 0x08/2:    /* VIDEO_COMMAND */
1281         handle_video_command(machine());
1277         handle_video_command();
12821278         break;
12831279
12841280      case 0x0a/2:    /* VIDEO_INTENABLE */
1285         update_interrupts(machine(), 1);
1281         update_interrupts(1);
12861282         break;
12871283
12881284      case 0x24/2:    /* VIDEO_LEFTCLIP */
r20828r20829
14151411   /* loop over height */
14161412   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
14171413   {
1418      UINT16 *src1 = &m_videoplane[0][compute_safe_address(this, VIDEO_DISPLAY_XORIGIN1, VIDEO_DISPLAY_YORIGIN1 + y)];
1414      UINT16 *src1 = &m_videoplane[0][compute_safe_address(VIDEO_DISPLAY_XORIGIN1, VIDEO_DISPLAY_YORIGIN1 + y)];
14191415
14201416      /* handle multi-plane case */
14211417      if (m_planes > 1)
14221418      {
1423         UINT16 *src2 = &m_videoplane[1][compute_safe_address(this, VIDEO_DISPLAY_XORIGIN2 + VIDEO_DISPLAY_XSCROLL2, VIDEO_DISPLAY_YORIGIN2 + VIDEO_DISPLAY_YSCROLL2 + y)];
1419         UINT16 *src2 = &m_videoplane[1][compute_safe_address(VIDEO_DISPLAY_XORIGIN2 + VIDEO_DISPLAY_XSCROLL2, VIDEO_DISPLAY_YORIGIN2 + VIDEO_DISPLAY_YSCROLL2 + y)];
14241420         UINT16 scanline[384];
14251421         int x;
14261422
trunk/src/mame/video/itech8.c
r20828r20829
138138 *
139139 *************************************/
140140
141static void generate_interrupt(running_machine &machine, int state)
141static void generate_interrupt(running_machine &machine, int state_num)
142142{
143   itech8_update_interrupts(machine, -1, state, -1);
143   itech8_state *state = machine.driver_data<itech8_state>();
144   state->itech8_update_interrupts(-1, state_num, -1);
144145
145   if (FULL_LOGGING && state) logerror("------------ DISPLAY INT (%d) --------------\n", machine.primary_screen->vpos());
146   if (FULL_LOGGING && state_num) logerror("------------ DISPLAY INT (%d) --------------\n", machine.primary_screen->vpos());
146147}
147148
148149
r20828r20829
215216 *
216217 *************************************/
217218
218INLINE UINT8 fetch_next_raw(itech8_state *state)
219inline UINT8 itech8_state::fetch_next_raw()
219220{
220   return state->m_grom_base[state->m_fetch_offset++ % state->m_grom_size];
221   return m_grom_base[m_fetch_offset++ % m_grom_size];
221222}
222223
223224
224INLINE void consume_raw(itech8_state *state, int count)
225inline void itech8_state::consume_raw(int count)
225226{
226   state->m_fetch_offset += count;
227   m_fetch_offset += count;
227228}
228229
229230
230INLINE UINT8 fetch_next_rle(itech8_state *state)
231inline UINT8 itech8_state::fetch_next_rle()
231232{
232   if (state->m_fetch_rle_count == 0)
233   if (m_fetch_rle_count == 0)
233234   {
234      state->m_fetch_rle_count = state->m_grom_base[state->m_fetch_offset++ % state->m_grom_size];
235      state->m_fetch_rle_literal = state->m_fetch_rle_count & 0x80;
236      state->m_fetch_rle_count &= 0x7f;
235      m_fetch_rle_count = m_grom_base[m_fetch_offset++ % m_grom_size];
236      m_fetch_rle_literal = m_fetch_rle_count & 0x80;
237      m_fetch_rle_count &= 0x7f;
237238
238      if (!state->m_fetch_rle_literal)
239         state->m_fetch_rle_value = state->m_grom_base[state->m_fetch_offset++ % state->m_grom_size];
239      if (!m_fetch_rle_literal)
240         m_fetch_rle_value = m_grom_base[m_fetch_offset++ % m_grom_size];
240241   }
241242
242   state->m_fetch_rle_count--;
243   if (state->m_fetch_rle_literal)
244      state->m_fetch_rle_value = state->m_grom_base[state->m_fetch_offset++ % state->m_grom_size];
243   m_fetch_rle_count--;
244   if (m_fetch_rle_literal)
245      m_fetch_rle_value = m_grom_base[m_fetch_offset++ % m_grom_size];
245246
246   return state->m_fetch_rle_value;
247   return m_fetch_rle_value;
247248}
248249
249250
250INLINE void consume_rle(itech8_state *state, int count)
251inline void itech8_state::consume_rle(int count)
251252{
252253   while (count)
253254   {
254255      int num_to_consume;
255256
256      if (state->m_fetch_rle_count == 0)
257      if (m_fetch_rle_count == 0)
257258      {
258         state->m_fetch_rle_count = state->m_grom_base[state->m_fetch_offset++ % state->m_grom_size];
259         state->m_fetch_rle_literal = state->m_fetch_rle_count & 0x80;
260         state->m_fetch_rle_count &= 0x7f;
259         m_fetch_rle_count = m_grom_base[m_fetch_offset++ % m_grom_size];
260         m_fetch_rle_literal = m_fetch_rle_count & 0x80;
261         m_fetch_rle_count &= 0x7f;
261262
262         if (!state->m_fetch_rle_literal)
263            state->m_fetch_rle_value = state->m_grom_base[state->m_fetch_offset++ % state->m_grom_size];
263         if (!m_fetch_rle_literal)
264            m_fetch_rle_value = m_grom_base[m_fetch_offset++ % m_grom_size];
264265      }
265266
266      num_to_consume = (count < state->m_fetch_rle_count) ? count : state->m_fetch_rle_count;
267      num_to_consume = (count < m_fetch_rle_count) ? count : m_fetch_rle_count;
267268      count -= num_to_consume;
268269
269      state->m_fetch_rle_count -= num_to_consume;
270      if (state->m_fetch_rle_literal)
271         state->m_fetch_offset += num_to_consume;
270      m_fetch_rle_count -= num_to_consume;
271      if (m_fetch_rle_literal)
272         m_fetch_offset += num_to_consume;
272273   }
273274}
274275
r20828r20829
280281 *
281282 *************************************/
282283
283static void perform_blit(address_space &space)
284void itech8_state::perform_blit(address_space &space)
284285{
285   itech8_state *state = space.machine().driver_data<itech8_state>();
286   struct tms34061_display &tms_state = state->m_tms_state;
287   UINT8 *blitter_data = state->m_blitter_data;
288   offs_t addr = state->m_tms_state.regs[TMS34061_XYADDRESS] | ((tms_state.regs[TMS34061_XYOFFSET] & 0x300) << 8);
286   struct tms34061_display &tms_state = m_tms_state;
287   UINT8 *blitter_data = m_blitter_data;
288   offs_t addr = m_tms_state.regs[TMS34061_XYADDRESS] | ((tms_state.regs[TMS34061_XYOFFSET] & 0x300) << 8);
289289   UINT8 shift = (BLITTER_FLAGS & BLITFLAG_SHIFT) ? 4 : 0;
290290   int transparent = (BLITTER_FLAGS & BLITFLAG_TRANSPARENT);
291291   int ydir = (BLITTER_FLAGS & BLITFLAG_YFLIP) ? -1 : 1;
r20828r20829
304304   if (FULL_LOGGING)
305305      logerror("Blit: scan=%d  src=%06x @ (%05x) for %dx%d ... flags=%02x\n",
306306            space.machine().primary_screen->vpos(),
307            (state->m_grom_bank << 16) | (BLITTER_ADDRHI << 8) | BLITTER_ADDRLO,
307            (m_grom_bank << 16) | (BLITTER_ADDRHI << 8) | BLITTER_ADDRLO,
308308            tms_state.regs[TMS34061_XYADDRESS] | ((tms_state.regs[TMS34061_XYOFFSET] & 0x300) << 8),
309309            BLITTER_WIDTH, BLITTER_HEIGHT, BLITTER_FLAGS);
310310
311311   /* initialize the fetcher */
312   state->m_fetch_offset = (state->m_grom_bank << 16) | (BLITTER_ADDRHI << 8) | BLITTER_ADDRLO;
313   state->m_fetch_rle_count = 0;
312   m_fetch_offset = (m_grom_bank << 16) | (BLITTER_ADDRHI << 8) | BLITTER_ADDRLO;
313   m_fetch_rle_count = 0;
314314
315315   /* RLE starts with a couple of extra 0's */
316316   if (rle)
317      state->m_fetch_offset += 2;
317      m_fetch_offset += 2;
318318
319319   /* select 4-bit versus 8-bit transparency */
320320   if (BLITTER_OUTPUT & 0x40)
r20828r20829
346346      /* skip src and dest */
347347      addr += xdir * (width + skip[0] + skip[1]);
348348      if (rle)
349         consume_rle(state, width + skip[0] + skip[1]);
349         consume_rle(width + skip[0] + skip[1]);
350350      else
351         consume_raw(state, width + skip[0] + skip[1]);
351         consume_raw(width + skip[0] + skip[1]);
352352
353353      /* back up one and reverse directions */
354354      addr -= xdir;
r20828r20829
363363      /* skip left */
364364      addr += xdir * skip[y & 1];
365365      if (rle)
366         consume_rle(state, skip[y & 1]);
366         consume_rle(skip[y & 1]);
367367      else
368         consume_raw(state, skip[y & 1]);
368         consume_raw(skip[y & 1]);
369369
370370      /* loop over width */
371371      for (x = 0; x < width; x++)
372372      {
373         UINT8 pix = rle ? fetch_next_rle(state) : fetch_next_raw(state);
373         UINT8 pix = rle ? fetch_next_rle() : fetch_next_raw();
374374
375375         /* swap pixels for X flip in 4bpp mode */
376376         if (xflip && transmaskhi != 0xff)
r20828r20829
399399      /* skip right */
400400      addr += xdir * skip[~y & 1];
401401      if (rle)
402         consume_rle(state, skip[~y & 1]);
402         consume_rle(skip[~y & 1]);
403403      else
404         consume_raw(state, skip[~y & 1]);
404         consume_raw(skip[~y & 1]);
405405
406406      /* back up one and reverse directions */
407407      addr -= xdir;
r20828r20829
423423{
424424   /* turn off blitting and generate an interrupt */
425425   m_blit_in_progress = 0;
426   itech8_update_interrupts(machine(), -1, -1, 1);
426   itech8_update_interrupts(-1, -1, 1);
427427
428428   if (FULL_LOGGING) logerror("------------ BLIT DONE (%d) --------------\n", machine().primary_screen->vpos());
429429}
r20828r20829
450450   /* a read from offset 3 clears the interrupt and returns the status */
451451   if (offset == 3)
452452   {
453      itech8_update_interrupts(machine(), -1, -1, 0);
453      itech8_update_interrupts(-1, -1, 0);
454454      if (m_blit_in_progress)
455455         result |= 0x80;
456456      else
trunk/src/mame/video/ironhors.c
r20828r20829
150150   m_bg_tilemap->set_scroll_rows(32);
151151}
152152
153static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
153void ironhors_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
154154{
155   ironhors_state *state = machine.driver_data<ironhors_state>();
156155   int offs;
157156   UINT8 *sr;
158157
159   if (state->m_spriterambank != 0)
160      sr = state->m_spriteram;
158   if (m_spriterambank != 0)
159      sr = m_spriteram;
161160   else
162      sr = state->m_spriteram2;
161      sr = m_spriteram2;
163162
164   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 5)
163   for (offs = 0; offs < m_spriteram.bytes(); offs += 5)
165164   {
166165      int sx = sr[offs + 3];
167166      int sy = sr[offs + 2];
168167      int flipx = sr[offs + 4] & 0x20;
169168      int flipy = sr[offs + 4] & 0x40;
170169      int code = (sr[offs] << 2) + ((sr[offs + 1] & 0x03) << 10) + ((sr[offs + 1] & 0x0c) >> 2);
171      int color = ((sr[offs + 1] & 0xf0) >> 4) + 16 * state->m_palettebank;
172   //  int mod = state->flip_screen() ? -8 : 8;
170      int color = ((sr[offs + 1] & 0xf0) >> 4) + 16 * m_palettebank;
171   //  int mod = flip_screen() ? -8 : 8;
173172
174      if (state->flip_screen())
173      if (flip_screen())
175174      {
176175         sx = 240 - sx;
177176         sy = 240 - sy;
r20828r20829
182181      switch (sr[offs + 4] & 0x0c)
183182      {
184183         case 0x00:  /* 16x16 */
185            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
184            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
186185                  code/4,
187186                  color,
188187                  flipx,flipy,
r20828r20829
191190
192191         case 0x04:  /* 16x8 */
193192            {
194               if (state->flip_screen()) sy += 8; // this fixes the train wheels' position
193               if (flip_screen()) sy += 8; // this fixes the train wheels' position
195194
196               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
195               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
197196                     code & ~1,
198197                     color,
199198                     flipx,flipy,
200199                     flipx?sx+8:sx,sy,0);
201               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
200               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
202201                     code | 1,
203202                     color,
204203                     flipx,flipy,
r20828r20829
208207
209208         case 0x08:  /* 8x16 */
210209            {
211               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
210               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
212211                     code & ~2,
213212                     color,
214213                     flipx,flipy,
215214                     sx,flipy?sy+8:sy,0);
216               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
215               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
217216                     code | 2,
218217                     color,
219218                     flipx,flipy,
r20828r20829
223222
224223         case 0x0c:  /* 8x8 */
225224            {
226               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
225               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
227226                     code,
228227                     color,
229228                     flipx,flipy,
r20828r20829
242241      m_bg_tilemap->set_scrollx(row, m_scroll[row]);
243242
244243   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
245   draw_sprites(machine(), bitmap, cliprect);
244   draw_sprites(bitmap, cliprect);
246245   return 0;
247246}
248247
r20828r20829
263262   m_bg_tilemap->set_scroll_rows(32);
264263}
265264
266static void farwest_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
265void ironhors_state::farwest_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
267266{
268   ironhors_state *state = machine.driver_data<ironhors_state>();
269267   int offs;
270   UINT8 *sr = state->m_spriteram2;
271   UINT8 *sr2 = state->m_spriteram;
268   UINT8 *sr = m_spriteram2;
269   UINT8 *sr2 = m_spriteram;
272270
273   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
271   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
274272   {
275273      int sx = sr[offs + 2];
276274      int sy = sr[offs + 1];
277275      int flipx = sr[offs + 3] & 0x20;
278276      int flipy = sr[offs + 3] & 0x40;
279277      int code = (sr[offs] << 2) + ((sr2[offs] & 0x03) << 10) + ((sr2[offs] & 0x0c) >> 2);
280      int color = ((sr2[offs] & 0xf0) >> 4) + 16 * state->m_palettebank;
278      int color = ((sr2[offs] & 0xf0) >> 4) + 16 * m_palettebank;
281279
282280   //  int mod = flip_screen() ? -8 : 8;
283281
r20828r20829
292290      switch (sr[offs + 3] & 0x0c)
293291      {
294292         case 0x00:  /* 16x16 */
295            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
293            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
296294                  code/4,
297295                  color,
298296                  flipx,flipy,
r20828r20829
301299
302300         case 0x04:  /* 16x8 */
303301            {
304               if (state->flip_screen()) sy += 8; // this fixes the train wheels' position
302               if (flip_screen()) sy += 8; // this fixes the train wheels' position
305303
306               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
304               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
307305                     code & ~1,
308306                     color,
309307                     flipx,flipy,
310308                     flipx?sx+8:sx,sy,0);
311               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
309               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
312310                     code | 1,
313311                     color,
314312                     flipx,flipy,
r20828r20829
318316
319317         case 0x08:  /* 8x16 */
320318            {
321               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
319               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
322320                     code & ~2,
323321                     color,
324322                     flipx,flipy,
325323                     sx,flipy?sy+8:sy,0);
326               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
324               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
327325                     code | 2,
328326                     color,
329327                     flipx,flipy,
r20828r20829
333331
334332         case 0x0c:  /* 8x8 */
335333            {
336               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
334               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
337335                     code,
338336                     color,
339337                     flipx,flipy,
r20828r20829
352350      m_bg_tilemap->set_scrollx(row, m_scroll[row]);
353351
354352   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
355   farwest_draw_sprites(machine(), bitmap, cliprect);
353   farwest_draw_sprites(bitmap, cliprect);
356354   return 0;
357355}
trunk/src/mame/video/irobot.c
r20828r20829
7676}
7777
7878
79static void _irobot_poly_clear(running_machine &machine, UINT8 *bitmap_base)
79void irobot_state::_irobot_poly_clear(UINT8 *bitmap_base)
8080{
81   memset(bitmap_base, 0, BITMAP_WIDTH * machine.primary_screen->height());
81   memset(bitmap_base, 0, BITMAP_WIDTH * machine().primary_screen->height());
8282}
8383
84void irobot_poly_clear(running_machine &machine)
84void irobot_state::irobot_poly_clear()
8585{
86   irobot_state *state = machine.driver_data<irobot_state>();
87   UINT8 *bitmap_base = state->m_bufsel ? state->m_polybitmap2 : state->m_polybitmap1;
88   _irobot_poly_clear(machine, bitmap_base);
86   UINT8 *bitmap_base = m_bufsel ? m_polybitmap2 : m_polybitmap1;
87   _irobot_poly_clear(bitmap_base);
8988}
9089
9190
r20828r20829
102101   m_polybitmap2 = auto_alloc_array(machine(), UINT8, BITMAP_WIDTH * height);
103102
104103   /* clear the bitmaps so we start with valid palette look-up values for drawing */
105   _irobot_poly_clear(machine(), m_polybitmap1);
106   _irobot_poly_clear(machine(), m_polybitmap2);
104   _irobot_poly_clear(m_polybitmap1);
105   _irobot_poly_clear(m_polybitmap2);
107106
108107   /* Set clipping */
109108   m_ir_xmin = m_ir_ymin = 0;
r20828r20829
162161     modified from a routine written by Andrew Caldwell
163162 */
164163
165static void draw_line(running_machine &machine, UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col)
164void irobot_state::draw_line(UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col)
166165{
167   irobot_state *state = machine.driver_data<irobot_state>();
168166   int dx,dy,sx,sy,cx,cy;
169167
170168   dx = abs(x1-x2);
r20828r20829
178176   {
179177      for (;;)
180178      {
181         if (x1 >= state->m_ir_xmin && x1 < state->m_ir_xmax && y1 >= state->m_ir_ymin && y1 < state->m_ir_ymax)
179         if (x1 >= m_ir_xmin && x1 < m_ir_xmax && y1 >= m_ir_ymin && y1 < m_ir_ymax)
182180               draw_pixel (x1, y1, col);
183181            if (x1 == x2) break;
184182            x1 += sx;
r20828r20829
194192   {
195193      for (;;)
196194      {
197         if (x1 >= state->m_ir_xmin && x1 < state->m_ir_xmax && y1 >= state->m_ir_ymin && y1 < state->m_ir_ymax)
195         if (x1 >= m_ir_xmin && x1 < m_ir_xmax && y1 >= m_ir_ymin && y1 < m_ir_ymax)
198196            draw_pixel (x1, y1, col);
199197         if (y1 == y2) break;
200198         y1 += sy;
r20828r20829
211209
212210#define ROUND_TO_PIXEL(x)   ((x >> 7) - 128)
213211
214void irobot_run_video(running_machine &machine)
212void irobot_state::irobot_run_video()
215213{
216   irobot_state *state = machine.driver_data<irobot_state>();
217214   UINT8 *polybitmap;
218   UINT16 *combase16 = (UINT16 *)state->m_combase;
215   UINT16 *combase16 = (UINT16 *)m_combase;
219216   int sx,sy,ex,ey,sx2,ey2;
220217   int color;
221218   UINT32 d1;
r20828r20829
223220   int shp;
224221   INT32 word1,word2;
225222
226   logerror("Starting Polygon Generator, Clear=%d\n",state->m_vg_clear);
223   logerror("Starting Polygon Generator, Clear=%d\n",m_vg_clear);
227224
228   if (state->m_bufsel)
229      polybitmap = state->m_polybitmap2;
225   if (m_bufsel)
226      polybitmap = m_polybitmap2;
230227   else
231      polybitmap = state->m_polybitmap1;
228      polybitmap = m_polybitmap1;
232229
233230   lpnt=0;
234231   while (lpnt < 0x7ff)
r20828r20829
249246            color = sy & 0x3f;
250247            sx = ROUND_TO_PIXEL(sx);
251248            sy = ROUND_TO_PIXEL(sy);
252            if (sx >= state->m_ir_xmin && sx < state->m_ir_xmax && sy >= state->m_ir_ymin && sy < state->m_ir_ymax)
249            if (sx >= m_ir_xmin && sx < m_ir_xmax && sy >= m_ir_ymin && sy < m_ir_ymax)
253250               draw_pixel(sx,sy,color);
254251            spnt+=2;
255252         }//while object
r20828r20829
269266            sx = combase16[spnt+3];
270267            word1 = (INT16)combase16[spnt+2];
271268            ex = sx + word1 * (ey - sy + 1);
272            draw_line(machine, polybitmap, ROUND_TO_PIXEL(sx),sy,ROUND_TO_PIXEL(ex),ey,color);
269            draw_line(polybitmap, ROUND_TO_PIXEL(sx),sy,ROUND_TO_PIXEL(ex),ey,color);
273270            spnt+=4;
274271         }//while object
275272      }//if line
r20828r20829
303300
304301            while(1)
305302            {
306               if (sy >= state->m_ir_ymin && sy < state->m_ir_ymax)
303               if (sy >= m_ir_ymin && sy < m_ir_ymax)
307304               {
308305                  int x1 = ROUND_TO_PIXEL(sx);
309306                  int x2 = ROUND_TO_PIXEL(sx2);
310307                  int temp;
311308
312309                  if (x1 > x2) temp = x1, x1 = x2, x2 = temp;
313                  if (x1 < state->m_ir_xmin) x1 = state->m_ir_xmin;
314                  if (x2 >= state->m_ir_xmax) x2 = state->m_ir_xmax - 1;
310                  if (x1 < m_ir_xmin) x1 = m_ir_xmin;
311                  if (x2 >= m_ir_xmax) x2 = m_ir_xmax - 1;
315312                  if (x1 < x2)
316313                     fill_hline(x1 + 1, x2, sy, color);
317314               }

Previous 199869 Revisions Next


© 1997-2024 The MAME Team