Previous 199869 Revisions Next

r29613 Sunday 13th April, 2014 at 17:34:40 UTC by Fabio Priuli
updated lsi53c810 to use delegates, and moved some formerly static
stuff into bebox and model3 classes. nw.
[src/emu/machine]53c810.c 53c810.h
[src/mame/drivers]model3.c
[src/mame/includes]model3.h
[src/mame/video]model3.c
[src/mess/drivers]bebox.c
[src/mess/includes]bebox.h
[src/mess/machine]bebox.c

trunk/src/mess/machine/bebox.c
r29612r29613
116116 *
117117 *************************************/
118118
119static void bebox_update_interrupts(running_machine &machine);
120
121119static void bebox_mbreg32_w(UINT32 *target, UINT64 data, UINT64 mem_mask)
122120{
123121   int i;
r29612r29613
163161         logerror("BeBox CPU #0 pc=0x%08X imask=0x%08x\n",
164162            (unsigned) space.device().safe_pc( ), m_cpu_imask[0]);
165163      }
166      bebox_update_interrupts(space.machine());
164      bebox_update_interrupts();
167165   }
168166}
169167
r29612r29613
180178         logerror("BeBox CPU #1 pc=0x%08X imask=0x%08x\n",
181179            (unsigned) space.device() .safe_pc( ), m_cpu_imask[1]);
182180      }
183      bebox_update_interrupts(space.machine());
181      bebox_update_interrupts();
184182   }
185183}
186184
r29612r29613
253251}
254252
255253
256static void bebox_update_interrupts(running_machine &machine)
254void bebox_state::bebox_update_interrupts()
257255{
258   bebox_state *state = machine.driver_data<bebox_state>();
259   int cpunum;
260256   UINT32 interrupt;
261257   static const char *const cputags[] = { "ppc1", "ppc2" };
262258
263   for (cpunum = 0; cpunum < 2; cpunum++)
259   for (int cpunum = 0; cpunum < 2; cpunum++)
264260   {
265      interrupt = state->m_interrupts & state->m_cpu_imask[cpunum];
261      interrupt = m_interrupts & m_cpu_imask[cpunum];
266262
267263      if (LOG_INTERRUPTS)
268264      {
269265         logerror("\tbebox_update_interrupts(): CPU #%d [%08X|%08X] IRQ %s\n", cpunum,
270            state->m_interrupts, state->m_cpu_imask[cpunum], interrupt ? "on" : "off");
266            m_interrupts, m_cpu_imask[cpunum], interrupt ? "on" : "off");
271267      }
272268
273      machine.device(cputags[cpunum])->execute().set_input_line(INPUT_LINE_IRQ0, interrupt ? ASSERT_LINE : CLEAR_LINE);
269      machine().device(cputags[cpunum])->execute().set_input_line(INPUT_LINE_IRQ0, interrupt ? ASSERT_LINE : CLEAR_LINE);
274270   }
275271}
276272
277273
278void bebox_set_irq_bit(running_machine &machine, unsigned int interrupt_bit, int val)
274void bebox_state::bebox_set_irq_bit(unsigned int interrupt_bit, int val)
279275{
280   bebox_state *state = machine.driver_data<bebox_state>();
281276   static const char *const interrupt_names[32] =
282277   {
283278      NULL,
r29612r29613
321316      assert_always((interrupt_bit < ARRAY_LENGTH(interrupt_names)) && (interrupt_names[interrupt_bit] != NULL), "Raising invalid interrupt");
322317
323318      logerror("bebox_set_irq_bit(): pc[0]=0x%08x pc[1]=0x%08x %s interrupt #%u (%s)\n",
324         (unsigned) machine.device("ppc1")->safe_pc(),
325         (unsigned) machine.device("ppc2")->safe_pc(),
319         (unsigned) machine().device("ppc1")->safe_pc(),
320         (unsigned) machine().device("ppc2")->safe_pc(),
326321         val ? "Asserting" : "Clearing",
327322         interrupt_bit, interrupt_names[interrupt_bit]);
328323   }
329324
330   old_interrupts = state->m_interrupts;
325   old_interrupts = m_interrupts;
331326   if (val)
332      state->m_interrupts |= 1 << interrupt_bit;
327      m_interrupts |= 1 << interrupt_bit;
333328   else
334      state->m_interrupts &= ~(1 << interrupt_bit);
329      m_interrupts &= ~(1 << interrupt_bit);
335330
336331   /* if interrupt values have changed, update the lines */
337   if (state->m_interrupts != old_interrupts)
338      bebox_update_interrupts(machine);
332   if (m_interrupts != old_interrupts)
333      bebox_update_interrupts();
339334}
340335
341336
r29612r29613
394389
395390WRITE_LINE_MEMBER( bebox_state::fdc_interrupt )
396391{
397   bebox_set_irq_bit(machine(), 13, state);
392   bebox_set_irq_bit(13, state);
398393   m_pic8259_1->ir6_w(state);
399394}
400395
r29612r29613
408403{
409404   UINT32 result;
410405   result = m_pic8259_1->acknowledge();
411   bebox_set_irq_bit(space.machine(), 5, 0);   /* HACK */
406   bebox_set_irq_bit(5, 0);   /* HACK */
412407   return ((UINT64) result) << 56;
413408}
414409
r29612r29613
421416
422417WRITE_LINE_MEMBER(bebox_state::bebox_pic8259_master_set_int_line)
423418{
424   bebox_set_irq_bit(machine(), 5, state);
419   bebox_set_irq_bit(5, state);
425420}
426421
427422WRITE_LINE_MEMBER(bebox_state::bebox_pic8259_slave_set_int_line)
r29612r29613
443438
444439WRITE_LINE_MEMBER(bebox_state::bebox_ide_interrupt)
445440{
446   bebox_set_irq_bit(machine(), 7, state);
441   bebox_set_irq_bit(7, state);
447442   m_pic8259_1->ir6_w(state);
448443}
449444
trunk/src/mess/includes/bebox.h
r29612r29613
105105   DECLARE_WRITE_LINE_MEMBER( fdc_interrupt );
106106   DECLARE_FLOPPY_FORMATS( floppy_formats );
107107
108   LSI53C810_FETCH_CB(scsi_fetch);
109   LSI53C810_IRQ_CB(scsi_irq_callback);
110   LSI53C810_DMA_CB(scsi_dma_callback);
111
112   void bebox_set_irq_bit(unsigned int interrupt_bit, int val);
113   void bebox_update_interrupts();   
114
108115protected:
109116   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
110117};
r29612r29613
119126extern const ins8250_interface bebox_uart_inteface_2;
120127extern const ins8250_interface bebox_uart_inteface_3;
121128
122void bebox_set_irq_bit(running_machine &machine, unsigned int interrupt_bit, int val);
123
124129UINT32 scsi53c810_pci_read(device_t *busdevice, device_t *device, int function, int offset, UINT32 mem_mask);
125130void scsi53c810_pci_write(device_t *busdevice, device_t *device, int function, int offset, UINT32 data, UINT32 mem_mask);
126131
trunk/src/mess/drivers/bebox.c
r29612r29613
100100                        ((x << 8) & 0xff0000) | \
101101                        ((x << 24) & 0xff000000))
102102
103static UINT32 scsi53c810_fetch(running_machine &machine, UINT32 dsp)
103LSI53C810_FETCH_CB(bebox_state::scsi_fetch)
104104{
105   UINT32 result;
106   bebox_state *state = machine.driver_data<bebox_state>();
107   result = state->m_ppc1->space(AS_PROGRAM).read_dword(dsp & 0x7FFFFFFF);
105   UINT32 result = m_ppc1->space(AS_PROGRAM).read_dword(dsp & 0x7FFFFFFF);
108106   return BYTE_REVERSE32(result);
109107}
110108
111109
112static void scsi53c810_irq_callback(running_machine &machine, int value)
110LSI53C810_IRQ_CB(bebox_state::scsi_irq_callback)
113111{
114   bebox_set_irq_bit(machine, 21, value);
112   bebox_set_irq_bit(21, state);
115113}
116114
117115
118static void scsi53c810_dma_callback(running_machine &machine, UINT32 src, UINT32 dst, int length, int byteswap)
116LSI53C810_DMA_CB(bebox_state::scsi_dma_callback)
119117{
120118}
121119
122
123static const struct LSI53C810interface lsi53c810_intf =
124{
125   &scsi53c810_irq_callback,
126   &scsi53c810_dma_callback,
127   &scsi53c810_fetch,
128};
129
130
131120FLOPPY_FORMATS_MEMBER( bebox_state::floppy_formats )
132121   FLOPPY_PC_FORMAT
133122FLOPPY_FORMATS_END
r29612r29613
150139
151140WRITE_LINE_MEMBER(bebox_state::bebox_keyboard_interrupt)
152141{
153   bebox_set_irq_bit(machine(), 16, state);
142   bebox_set_irq_bit(16, state);
154143   m_pic8259_1->ir1_w(state);
155144}
156145
r29612r29613
202191   MCFG_SCSIBUS_ADD("scsi")
203192   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_0)
204193   MCFG_SCSIDEV_ADD("scsi:cdrom", SCSICD, SCSI_ID_3)
205   MCFG_LSI53C810_ADD( "scsi:lsi53c810", lsi53c810_intf)
194   MCFG_DEVICE_ADD("scsi:lsi53c810", LSI53C810, 0)
195   MCFG_LSI53C810_IRQ_CB(bebox_state, scsi_irq_callback)
196   MCFG_LSI53C810_DMA_CB(bebox_state, scsi_dma_callback)
197   MCFG_LSI53C810_FETCH_CB(bebox_state, scsi_fetch)
206198
207199   MCFG_IDE_CONTROLLER_ADD( "ide", ata_devices, "hdd", NULL, false ) /* FIXME */
208200   MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(bebox_state, bebox_ide_interrupt))
trunk/src/mame/drivers/model3.c
r29612r29613
662662#include "includes/model3.h"
663663
664664
665static void real3d_dma_callback(running_machine &machine, UINT32 src, UINT32 dst, int length, int byteswap);
666
667
668
669static void update_irq_state(running_machine &machine)
665void model3_state::update_irq_state()
670666{
671   model3_state *state = machine.driver_data<model3_state>();
672   if ((state->m_irq_enable & state->m_irq_state) || state->m_scsi_irq_state)
667   if ((m_irq_enable & m_irq_state) || m_scsi_irq_state)
673668   {
674//      printf("IRQ set: state %x enable %x scsi %x\n", state->m_irq_state, state->m_irq_enable, state->m_scsi_irq_state);
675      state->m_maincpu->set_input_line(PPC_IRQ, ASSERT_LINE);
676      state->m_scsi_irq_state = 0;
669//      printf("IRQ set: state %x enable %x scsi %x\n", m_irq_state, m_irq_enable, m_scsi_irq_state);
670      m_maincpu->set_input_line(PPC_IRQ, ASSERT_LINE);
671      m_scsi_irq_state = 0;
677672   }
678673   else
679674   {
680//      printf("IRQ clear: state %x enable %x scsi %x\n", state->m_irq_state, state->m_irq_enable, state->m_scsi_irq_state);
681      state->m_maincpu->set_input_line(PPC_IRQ, CLEAR_LINE);
675//      printf("IRQ clear: state %x enable %x scsi %x\n", m_irq_state, m_irq_enable, m_scsi_irq_state);
676      m_maincpu->set_input_line(PPC_IRQ, CLEAR_LINE);
682677   }
683678}
684679
685void model3_set_irq_line(running_machine &machine, UINT8 bit, int line)
680void model3_state::set_irq_line(UINT8 bit, int line)
686681{
687   model3_state *state = machine.driver_data<model3_state>();
688682   if (line != CLEAR_LINE)
689      state->m_irq_state |= bit;
683      m_irq_state |= bit;
690684   else
691      state->m_irq_state &= ~bit;
692   update_irq_state(machine);
685      m_irq_state &= ~bit;
686   update_irq_state();
693687}
694688
695689
r29612r29613
10561050   }
10571051}
10581052
1059static UINT32 scsi_fetch(running_machine &machine, UINT32 dsp)
1053LSI53C810_FETCH_CB(model3_state::scsi_fetch)
10601054{
1061   model3_state *drvstate = machine.driver_data<model3_state>();
1062   address_space &space = drvstate->m_maincpu->space(AS_PROGRAM);
1063   UINT32 result;
1064   result = space.read_dword(dsp);
1055   address_space &space = m_maincpu->space(AS_PROGRAM);
1056   UINT32 result = space.read_dword(dsp);
10651057   return FLIPENDIAN_INT32(result);
10661058}
10671059
1068static void scsi_irq_callback(running_machine &machine, int state)
1060LSI53C810_IRQ_CB(model3_state::scsi_irq_callback)
10691061{
1070   model3_state *drvstate = machine.driver_data<model3_state>();
1071   drvstate->m_scsi_irq_state = state;
1072   update_irq_state(machine);
1062   m_scsi_irq_state = state;
1063   update_irq_state();
10731064}
10741065
10751066/*****************************************************************************/
r29612r29613
11121103            int length = FLIPENDIAN_INT32((UINT32)(data >> 32)) * 4;
11131104            if (m_dma_endian & 0x80)
11141105            {
1115               real3d_dma_callback(machine(), m_dma_source, m_dma_dest, length, 0);
1106               real3d_dma_callback(m_dma_source, m_dma_dest, length, 0);
11161107            }
11171108            else
11181109            {
1119               real3d_dma_callback(machine(), m_dma_source, m_dma_dest, length, 1);
1110               real3d_dma_callback(m_dma_source, m_dma_dest, length, 1);
11201111            }
11211112            m_dma_irq |= 0x01;
1122            scsi_irq_callback(machine(), 1);
1113            scsi_irq_callback(1);
11231114            return;
11241115         }
11251116         else if(ACCESSING_BITS_16_23)
11261117         {
11271118            if(data & 0x10000) {
11281119               m_dma_irq &= ~0x1;
1129               scsi_irq_callback(machine(), 0);
1120               scsi_irq_callback(0);
11301121            }
11311122            return;
11321123         }
r29612r29613
11571148   logerror("real3d_dma_w: %08X, %08X%08X, %08X%08X", offset, (UINT32)(data >> 32), (UINT32)(data), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask));
11581149}
11591150
1160static void real3d_dma_callback(running_machine &machine, UINT32 src, UINT32 dst, int length, int byteswap)
1151LSI53C810_DMA_CB(model3_state::real3d_dma_callback)
11611152{
1162   model3_state *drvstate = machine.driver_data<model3_state>();
1163   address_space &space = drvstate->m_maincpu->space(AS_PROGRAM);
11641153   switch(dst >> 24)
11651154   {
11661155      case 0x88:      /* Display List End Trigger */
1167         real3d_display_list_end(machine);
1156         real3d_display_list_end();
11681157         break;
11691158      case 0x8c:      /* Display List RAM 2 */
1170         real3d_display_list2_dma(space, src, dst, length, byteswap);
1159         real3d_display_list2_dma(src, dst, length, byteswap);
11711160         break;
11721161      case 0x8e:      /* Display List RAM 1 */
1173         real3d_display_list1_dma(space, src, dst, length, byteswap);
1162         real3d_display_list1_dma(src, dst, length, byteswap);
11741163         break;
11751164      case 0x90:      /* VROM Texture Download */
1176         real3d_vrom_texture_dma(space, src, dst, length, byteswap);
1165         real3d_vrom_texture_dma(src, dst, length, byteswap);
11771166         break;
11781167      case 0x94:      /* Texture FIFO */
1179         real3d_texture_fifo_dma(space, src, length, byteswap);
1168         real3d_texture_fifo_dma(src, length, byteswap);
11801169         break;
11811170      case 0x98:      /* Polygon RAM */
1182         real3d_polygon_ram_dma(space, src, dst, length, byteswap);
1171         real3d_polygon_ram_dma(src, dst, length, byteswap);
11831172         break;
11841173      case 0x9c:      /* Unknown */
11851174         break;
11861175      default:
1187         logerror("dma_callback: %08X, %08X, %d at %08X", src, dst, length, machine.device("maincpu")->safe_pc());
1176         logerror("dma_callback: %08X, %08X, %d at %08X", src, dst, length, machine().device("maincpu")->safe_pc());
11881177         break;
11891178   }
11901179}
11911180
11921181/*****************************************************************************/
11931182
1194static const struct LSI53C810interface lsi53c810_intf =
1195{
1196   &scsi_irq_callback,
1197   &real3d_dma_callback,
1198   &scsi_fetch,
1199};
1200
12011183static void configure_fast_ram(running_machine &machine)
12021184{
12031185   model3_state *state = machine.driver_data<model3_state>();
r29612r29613
12121194{
12131195   if (m_sound_irq_enable)
12141196   {
1215      model3_set_irq_line(machine(), 0x40, ASSERT_LINE);
1197      set_irq_line(0x40, ASSERT_LINE);
12161198   }
12171199}
12181200
r29612r29613
16171599   {
16181600      case 0:
16191601         // clear the interrupt
1620         model3_set_irq_line(machine(), 0x40, CLEAR_LINE);
1602         set_irq_line(0x40, CLEAR_LINE);
16211603
16221604         if (m_dsbz80 != NULL)
16231605         {
r29612r29613
53955377   int scanline = param;
53965378
53975379   if (scanline == 384)
5398      model3_set_irq_line(machine(), 0x02, ASSERT_LINE);
5380      set_irq_line(0x02, ASSERT_LINE);
53995381   else if(scanline == 0)
5400      model3_set_irq_line(machine(), 0x0d, ASSERT_LINE);
5382      set_irq_line(0x0d, ASSERT_LINE);
54015383}
54025384
54035385static const powerpc_config model3_10 =
r29612r29613
54575439   MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
54585440
54595441   MCFG_SCSIBUS_ADD("scsi")
5460   MCFG_LSI53C810_ADD( "scsi:lsi53c810", lsi53c810_intf)
5442   MCFG_DEVICE_ADD("scsi:lsi53c810", LSI53C810, 0)
5443   MCFG_LSI53C810_IRQ_CB(model3_state, scsi_irq_callback)
5444   MCFG_LSI53C810_DMA_CB(model3_state, real3d_dma_callback)
5445   MCFG_LSI53C810_FETCH_CB(model3_state, scsi_fetch)
54615446MACHINE_CONFIG_END
54625447
54635448static MACHINE_CONFIG_START( model3_15, model3_state )
r29612r29613
54975482   MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
54985483
54995484   MCFG_SCSIBUS_ADD("scsi")
5500   MCFG_LSI53C810_ADD( "scsi:lsi53c810", lsi53c810_intf)
5485   MCFG_DEVICE_ADD("scsi:lsi53c810", LSI53C810, 0)
5486   MCFG_LSI53C810_IRQ_CB(model3_state, scsi_irq_callback)
5487   MCFG_LSI53C810_DMA_CB(model3_state, real3d_dma_callback)
5488   MCFG_LSI53C810_FETCH_CB(model3_state, scsi_fetch)
55015489MACHINE_CONFIG_END
55025490
55035491static MACHINE_CONFIG_DERIVED(scud, model3_15)
trunk/src/mame/includes/model3.h
r29612r29613
214214   TIMER_DEVICE_CALLBACK_MEMBER(model3_interrupt);
215215   void model3_exit();
216216   DECLARE_WRITE8_MEMBER(scsp_irq);
217   LSI53C810_DMA_CB(real3d_dma_callback);
218   LSI53C810_FETCH_CB(scsi_fetch);
219   LSI53C810_IRQ_CB(scsi_irq_callback);
220   void update_irq_state();
221   void set_irq_line(UINT8 bit, int line);
222   void real3d_display_list_end();
223   void real3d_display_list1_dma(UINT32 src, UINT32 dst, int length, int byteswap);
224   void real3d_display_list2_dma(UINT32 src, UINT32 dst, int length, int byteswap);
225   void real3d_vrom_texture_dma(UINT32 src, UINT32 dst, int length, int byteswap);
226   void real3d_texture_fifo_dma(UINT32 src, int length, int byteswap);
227   void real3d_polygon_ram_dma(UINT32 src, UINT32 dst, int length, int byteswap);
217228};
218229
219
220/*----------- defined in drivers/model3.c -----------*/
221
222void model3_set_irq_line(running_machine &machine, UINT8 bit, int state);
223
224
225230/*----------- defined in machine/model3.c -----------*/
226231
227232void model3_machine_init(running_machine &machine, int step);
r29612r29613
229234void model3_tap_write(running_machine &machine, int tck, int tms, int tdi, int trst);
230235void model3_tap_reset(running_machine &machine);
231236
232
233/*----------- defined in video/model3.c -----------*/
234
235void real3d_display_list_end(running_machine &machine);
236void real3d_display_list1_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap);
237void real3d_display_list2_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap);
238void real3d_vrom_texture_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap);
239void real3d_texture_fifo_dma(address_space &space, UINT32 src, int length, int byteswap);
240void real3d_polygon_ram_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap);
trunk/src/mame/video/model3.c
r29612r29613
446446   {
447447      case 0x00/8:    logerror("vid_reg0: %08X%08X\n", (UINT32)(data>>32),(UINT32)(data)); m_vid_reg0 = data; break;
448448      case 0x08/8:    break;      /* ??? */
449      case 0x10/8:    model3_set_irq_line(machine(), (data >> 56) & 0x0f, CLEAR_LINE); break;     /* VBL IRQ Ack */
449      case 0x10/8:    set_irq_line((data >> 56) & 0x0f, CLEAR_LINE); break;     /* VBL IRQ Ack */
450450
451451      case 0x20/8:    m_layer_enable = (data >> 52);  break;
452452
r29612r29613
747747   }
748748}
749749
750void real3d_display_list_end(running_machine &machine)
750void model3_state::real3d_display_list_end()
751751{
752   model3_state *state = machine.driver_data<model3_state>();
753752   /* upload textures if there are any in the FIFO */
754   if (state->m_texture_fifo_pos > 0)
753   if (m_texture_fifo_pos > 0)
755754   {
756755      int i = 0;
757      while(i < state->m_texture_fifo_pos)
756      while (i < m_texture_fifo_pos)
758757      {
759         int length = (state->m_texture_fifo[i] / 2) + 2;
760         UINT32 header = state->m_texture_fifo[i+1];
761         real3d_upload_texture(machine, header, &state->m_texture_fifo[i+2]);
758         int length = (m_texture_fifo[i] / 2) + 2;
759         UINT32 header = m_texture_fifo[i+1];
760         real3d_upload_texture(machine(), header, &m_texture_fifo[i+2]);
762761         i += length;
763762      };
764763   }
765   state->m_texture_fifo_pos = 0;
766   state->m_zbuffer.fill(0);
767   state->m_bitmap3d.fill(0x8000);
768   real3d_traverse_display_list(machine);
764   m_texture_fifo_pos = 0;
765   m_zbuffer.fill(0);
766   m_bitmap3d.fill(0x8000);
767   real3d_traverse_display_list(machine());
769768   //state->m_real3d_display_list = 1;
770769}
771770
772void real3d_display_list1_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap)
771void model3_state::real3d_display_list1_dma(UINT32 src, UINT32 dst, int length, int byteswap)
773772{
774   model3_state *state = space.machine().driver_data<model3_state>();
775   int i;
773   address_space &space = m_maincpu->space(AS_PROGRAM);
776774   int d = (dst & 0xffffff) / 4;
777   for(i=0; i < length; i+=4) {
775   for (int i = 0; i < length; i += 4)
776   {
778777      UINT32 w;
779778      if (byteswap) {
780779         w = BYTE_REVERSE32(space.read_dword(src));
781780      } else {
782781         w = space.read_dword(src);
783782      }
784      state->m_display_list_ram[d++] = w;
783      m_display_list_ram[d++] = w;
785784      src += 4;
786785   }
787786}
788787
789void real3d_display_list2_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap)
788void model3_state::real3d_display_list2_dma(UINT32 src, UINT32 dst, int length, int byteswap)
790789{
791   model3_state *state = space.machine().driver_data<model3_state>();
792   int i;
790   address_space &space = m_maincpu->space(AS_PROGRAM);
793791   int d = (dst & 0xffffff) / 4;
794   for(i=0; i < length; i+=4) {
792   for (int i = 0; i < length; i += 4)
793   {
795794      UINT32 w;
796795      if (byteswap) {
797796         w = BYTE_REVERSE32(space.read_dword(src));
798797      } else {
799798         w = space.read_dword(src);
800799      }
801      state->m_culling_ram[d++] = w;
800      m_culling_ram[d++] = w;
802801      src += 4;
803802   }
804803}
805804
806void real3d_vrom_texture_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap)
805void model3_state::real3d_vrom_texture_dma(UINT32 src, UINT32 dst, int length, int byteswap)
807806{
808   model3_state *state = space.machine().driver_data<model3_state>();
807   address_space &space = m_maincpu->space(AS_PROGRAM);
809808   if((dst & 0xff) == 0) {
810809      UINT32 address, header;
811810
r29612r29613
816815         address = space.read_dword((src+0));
817816         header = space.read_dword((src+4));
818817      }
819      real3d_upload_texture(space.machine(), header, (UINT32*)&state->m_vrom[address]);
818      real3d_upload_texture(space.machine(), header, (UINT32*)&m_vrom[address]);
820819   }
821820}
822821
823void real3d_texture_fifo_dma(address_space &space, UINT32 src, int length, int byteswap)
822void model3_state::real3d_texture_fifo_dma(UINT32 src, int length, int byteswap)
824823{
825   model3_state *state = space.machine().driver_data<model3_state>();
826   int i;
827   for(i=0; i < length; i+=4) {
824   address_space &space = m_maincpu->space(AS_PROGRAM);
825   for (int i = 0; i < length; i += 4)
826   {
828827      UINT32 w;
829828      if (byteswap) {
830829         w = BYTE_REVERSE32(space.read_dword(src));
831830      } else {
832831         w = space.read_dword(src);
833832      }
834      state->m_texture_fifo[state->m_texture_fifo_pos] = w;
835      state->m_texture_fifo_pos++;
833      m_texture_fifo[m_texture_fifo_pos] = w;
834      m_texture_fifo_pos++;
836835      src += 4;
837836   }
838837}
839838
840void real3d_polygon_ram_dma(address_space &space, UINT32 src, UINT32 dst, int length, int byteswap)
839void model3_state::real3d_polygon_ram_dma(UINT32 src, UINT32 dst, int length, int byteswap)
841840{
842   model3_state *state = space.machine().driver_data<model3_state>();
843   int i;
841   address_space &space = m_maincpu->space(AS_PROGRAM);
844842   int d = (dst & 0xffffff) / 4;
845   for(i=0; i < length; i+=4) {
843   for (int i = 0; i < length; i += 4)
844   {
846845      UINT32 w;
847846      if (byteswap) {
848847         w = BYTE_REVERSE32(space.read_dword(src));
849848      } else {
850849         w = space.read_dword(src);
851850      }
852      state->m_polygon_ram[d++] = w;
851      m_polygon_ram[d++] = w;
853852      src += 4;
854853   }
855854}
856855
857856WRITE64_MEMBER(model3_state::real3d_cmd_w)
858857{
859   real3d_display_list_end(machine());
858   real3d_display_list_end();
860859}
861860
862861
trunk/src/emu/machine/53c810.c
r29612r29613
99
1010UINT32 lsi53c810_device::FETCH()
1111{
12   UINT32 r = fetch(machine(), dsp);
12   UINT32 r = m_fetch_cb(dsp);
1313   dsp += 4;
1414   return r;
1515}
r29612r29613
2626   int count;
2727
2828   count = dcmd & 0xffffff;
29   if(dma_callback != NULL) {
30      dma_callback(machine(), src, dst, count, 1);
31   }
29   if (!m_dma_cb.isnull())
30      m_dma_cb(src, dst, count, 1);
3231}
3332
3433void lsi53c810_device::dmaop_interrupt()
r29612r29613
4140   istat |= 0x1;   /* DMA interrupt pending */
4241   dstat |= 0x4;   /* SIR (SCRIPTS Interrupt Instruction Received) */
4342
44   if(irq_callback != NULL) {
45      irq_callback(machine(), 1);
46   }
43   if (!m_irq_cb.isnull())
44      m_irq_cb(1);
45
4746   dma_icount = 0;
4847   halted = 1;
4948}
r29612r29613
5958
6059   // normal indirect
6160   if (dcmd & 0x20000000)
62      address = fetch(machine(), address);
61      address = m_fetch_cb(address);
6362
6463   // table indirect
6564   if (dcmd & 0x10000000)
r29612r29613
7473      dsps += dsa;
7574
7675      logerror("Loading from table at %x\n", dsps);
77      count = fetch(machine(),dsps);
78      address = fetch(machine(),dsps+4);
76      count = m_fetch_cb(dsps);
77      address = m_fetch_cb(dsps + 4);
7978   }
8079
8180   logerror("block move: address %x count %x phase %x\n", address, count, (dcmd>>24)&7);
r29612r29613
428427         return (dsa >> 24) & 0xff;
429428      case 0x14:      /* ISTAT */
430429         // clear the interrupt on service
431         if(irq_callback != NULL)
432         {
433            irq_callback(machine(), 0);
434         }
430         if (!m_irq_cb.isnull())
431            m_irq_cb(0);
435432
436433         return istat;
437434      case 0x2c:      /* DSP [7-0] */
r29612r29613
572569
573570            istat |= 0x3;   /* DMA interrupt pending */
574571            dstat |= 0x8;   /* SSI (Single Step Interrupt) */
575            if(irq_callback != NULL) {
576               irq_callback(machine(), 1);
577            }
572            if (!m_irq_cb.isnull())
573               m_irq_cb(1);
578574         }
579575         else if(dcntl & 0x04 && !halted)    /* manual start DMA */
580576         {
r29612r29613
610606
611607void lsi53c810_device::add_opcode(UINT8 op, UINT8 mask, opcode_handler_delegate handler)
612608{
613   int i;
614   for(i=0; i < 256; i++) {
615      if((i & mask) == op) {
609   for (int i = 0; i < 256; i++)
610   {
611      if ((i & mask) == op)
612      {
616613         dma_opcode[i] = handler;
617614      }
618615   }
r29612r29613
623620{
624621}
625622
626void lsi53c810_device::device_config_complete()
627{
628   // inherit a copy of the static data
629   const LSI53C810interface *intf = reinterpret_cast<const LSI53C810interface *>(static_config());
630   if (intf != NULL)
631   {
632      *static_cast<LSI53C810interface *>(this) = *intf;
633   }
634}
635
636623void lsi53c810_device::device_start()
637624{
638   int i;
639
640   for(i = 0; i < 256; i++)
625   m_irq_cb.bind_relative_to(*owner());
626   m_dma_cb.bind_relative_to(*owner());
627   m_fetch_cb.bind_relative_to(*owner());
628   
629   for (int i = 0; i < 256; i++)
641630   {
642      dma_opcode[i] = opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_invalid ), this);
631      dma_opcode[i] = opcode_handler_delegate(FUNC(lsi53c810_device::dmaop_invalid), this);
643632   }
644633
645634   add_opcode(0x00, 0xc0, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_block_move ), this));
r29612r29613
662651   memset(devices, 0, sizeof(devices));
663652
664653   // try to open the devices
665   for( device_t *device = owner()->first_subdevice(); device != NULL; device = device->next() )
654   for (device_t *device = owner()->first_subdevice(); device != NULL; device = device->next())
666655   {
667656      scsihle_device *scsidev = dynamic_cast<scsihle_device *>(device);
668      if( scsidev != NULL )
657      if (scsidev != NULL)
669658      {
670659         devices[scsidev->GetDeviceID()] = scsidev;
671660      }
r29612r29613
704693
705694UINT32 lsi53c810_device::lsi53c810_dasm_fetch(UINT32 pc)
706695{
707   return fetch(machine(), pc);
696   return m_fetch_cb(pc);
708697}
709698
710699unsigned lsi53c810_device::lsi53c810_dasm(char *buf, UINT32 pc)
trunk/src/emu/machine/53c810.h
r29612r29613
33
44#include "machine/scsihle.h"
55
6struct LSI53C810interface
7{
8   void (*irq_callback)(running_machine &machine, int); /* IRQ callback */
9   void (*dma_callback)(running_machine &machine, UINT32, UINT32, int, int);   /* DMA callback */
10   UINT32 (*fetch)(running_machine &machine, UINT32 dsp);
11};
6typedef device_delegate<void (int state)> lsi53c810_irq_delegate;
7#define LSI53C810_IRQ_CB(name)  void name(int state)
128
13#define MCFG_LSI53C810_ADD( _tag, _config ) \
14   MCFG_DEVICE_ADD( _tag, LSI53C810, 0 ) \
15   MCFG_DEVICE_CONFIG(_config)
9typedef device_delegate<void (UINT32 src, UINT32 dst, int length, int byteswap)> lsi53c810_dma_delegate;
10#define LSI53C810_DMA_CB(name)  void name(UINT32 src, UINT32 dst, int length, int byteswap)
1611
17class lsi53c810_device : public device_t,
18                  public LSI53C810interface
12typedef device_delegate<UINT32 (UINT32 dsp)> lsi53c810_fetch_delegate;
13#define LSI53C810_FETCH_CB(name)  UINT32 name(UINT32 dsp)
14
15
16class lsi53c810_device : public device_t
1917{
2018public:
2119   // construction/destruction
2220   lsi53c810_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2321
22   static void set_irq_callback(device_t &device, lsi53c810_irq_delegate callback) { downcast<lsi53c810_device &>(device).m_irq_cb = callback; }
23   static void set_dma_callback(device_t &device, lsi53c810_dma_delegate callback) { downcast<lsi53c810_device &>(device).m_dma_cb = callback; }
24   static void set_fetch_callback(device_t &device, lsi53c810_fetch_delegate callback) { downcast<lsi53c810_device &>(device).m_fetch_cb = callback; }
25   
2426   void lsi53c810_read_data(int bytes, UINT8 *pData);
2527   void lsi53c810_write_data(int bytes, UINT8 *pData);
2628
r29612r29613
2931
3032protected:
3133   // device-level overrides
32   virtual void device_config_complete();
3334   virtual void device_start();
3435
3536private:
3637   typedef delegate<void (void)> opcode_handler_delegate;
3738   opcode_handler_delegate dma_opcode[256];
3839
40   lsi53c810_irq_delegate m_irq_cb;
41   lsi53c810_dma_delegate m_dma_cb;
42   lsi53c810_fetch_delegate m_fetch_cb;
43
3944   UINT32 FETCH();
4045   void dmaop_invalid();
4146   void dmaop_move_memory();
r29612r29613
100105// device type definition
101106extern const device_type LSI53C810;
102107
108
109#define MCFG_LSI53C810_IRQ_CB(_class, _method) \
110   lsi53c810_device::set_irq_callback(*device, lsi53c810_irq_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
111
112#define MCFG_LSI53C810_DMA_CB(_class, _method) \
113   lsi53c810_device::set_dma_callback(*device, lsi53c810_dma_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
114
115#define MCFG_LSI53C810_FETCH_CB(_class, _method) \
116   lsi53c810_device::set_fetch_callback(*device, lsi53c810_fetch_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
117
103118#endif

Previous 199869 Revisions Next


© 1997-2024 The MAME Team