Previous 15994 Revisions Next

r6049 Monday 12th October, 2009 at 09:39:25 UTC by Dirk Best
Get rid of cpu_get_by_index()
[src/mess]mslegacy.c mslegacy.h
[src/mess/drivers]palm.c x68k.c
[src/mess/includes]mc68328.h
[src/mess/machine]at.c hd63450.c hd63450.h mc68328.c pc.c pc_turbo.c pc_turbo.h

src/mess/includes/mc68328.h
r6048r6049
9797typedef struct _mc68328_interface mc68328_interface;
9898struct _mc68328_interface
9999{
100    int parent_m68k_cpu_index;
100    const char *m68k_cpu_tag;
101101
102102    write8_device_func  out_port_a_func;    /* 8-bit output */
103103    write8_device_func  out_port_b_func;    /* 8-bit output */
src/mess/machine/at.c
r6048r6049
497497static WRITE8_HANDLER( at_kbdc8042_p2_w )
498498{
499499   at_state *st = space->machine->driver_data;
500   
500
501501   logerror("%04x: writing $%02x to P2\n", cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")), data );
502502
503503   at_set_gate_a20( space->machine, ( data & 0x02 ) ? 1 : 0 );
r6048r6049
567567   static int poll_delay = 4;
568568    UINT8 data = 0;
569569   at_state *st = space->machine->driver_data;
570   
570
571571   switch ( offset )
572572   {
573573   case 0:      /* A2 is wired to 8042 A0 */
r6048r6049
746746   };
747747
748748   init_at_common(machine, &at8042);
749   pc_turbo_setup(machine, 0, "DSW2", 0x02, 4.77/12, 1);
749   pc_turbo_setup(machine, machine->firstcpu, "DSW2", 0x02, 4.77/12, 1);
750750   pc_vga_init(machine, &vga_interface, NULL);
751751
752752   /* Attach keyboard to the keyboard controller */
r6048r6049
763763      KBDC8042_PS2, at_set_gate_a20, at_keyboard_interrupt, at_get_out2
764764   };
765765   init_at_common(machine, &at8042);
766   pc_turbo_setup(machine, 0, "DSW2", 0x02, 4.77/12, 1);
766   pc_turbo_setup(machine, machine->firstcpu, "DSW2", 0x02, 4.77/12, 1);
767767   pc_vga_init(machine, &vga_interface, NULL);
768768
769769   /* Attach keyboard to the keyboard controller */
src/mess/machine/pc_turbo.c
r6048r6049
77**********************************************************************/
88
99#include "driver.h"
10#include "mslegacy.h"
1110#include "pc_turbo.h"
1211
1312
1413struct pc_turbo_info
1514{
16   int cpunum;
15   const device_config *cpu;
1716   const char *port;
1817   int mask;
1918   int cur_val;
r6048r6049
3332   if (val != ti->cur_val)
3433   {
3534      ti->cur_val = val;
36      cpu_set_clockscale(cpu_get_by_index(machine, ti->cpunum), val ? ti->on_speed : ti->off_speed);
35      cpu_set_clockscale(ti->cpu, val ? ti->on_speed : ti->off_speed);
3736   }
3837}
3938
4039
4140
42int pc_turbo_setup(running_machine *machine, int cpunum, const char *port, int mask, double off_speed, double on_speed)
41int pc_turbo_setup(running_machine *machine, const device_config *cpu, const char *port, int mask, double off_speed, double on_speed)
4342{
4443   struct pc_turbo_info *ti;
4544
4645   ti = auto_alloc(machine, struct pc_turbo_info);
47   ti->cpunum = cpunum;
46   ti->cpu = cpu;
4847   ti->port = port;
4948   ti->mask = mask;
5049   ti->cur_val = -1;
src/mess/machine/pc_turbo.h
r6048r6049
99#ifndef PC_TURBO_H
1010#define PC_TURBO_H
1111
12int pc_turbo_setup(running_machine *machine, int cpunum, const char *port, int mask, double off_speed, double on_speed);
12int pc_turbo_setup(running_machine *machine, const device_config *cpu, const char *port, int mask, double off_speed, double on_speed);
1313
1414
1515#endif /* PC_TURBO_H */
src/mess/machine/mc68328.c
r6048r6049
88**********************************************************************/
99
1010#include "driver.h"
11#include "mslegacy.h"
1211#include "cpu/m68000/m68000.h"
1312#include "includes/mc68328.h"
1413#include "mc68328.h"
r6048r6049
3130static void mc68328_set_interrupt_line(const device_config *device, UINT32 line, UINT32 active)
3231{
3332    mc68328_t* mc68328 = mc68328_get_safe_token( device );
34   const device_config *cpu = cpu_get_by_index(device->machine, mc68328->iface->parent_m68k_cpu_index);
33    const device_config *cpu = devtag_get_device(device->machine, mc68328->iface->m68k_cpu_tag);
3534
3635    if(active)
3736    {
src/mess/machine/hd63450.c
r6048r6049
44    Largely based on documentation of the Sharp X68000
55*/
66
7#include "machine/hd63450.h"
8#include "mslegacy.h"
7#include "hd63450.h"
98
109typedef struct _hd63450_regs hd63450_regs;
1110struct _hd63450_regs
r6048r6049
250249   // Burst transfers will halt the CPU until the transfer is complete
251250   if((dmac->reg[channel].dcr & 0xc0) == 0x00)  // Burst transfer
252251   {
253      cpu_set_input_line(cpu_get_by_index(device->machine, dmac->intf->cpu), INPUT_LINE_HALT,ASSERT_LINE);
252      const device_config *cpu = devtag_get_device(device->machine, dmac->intf->cpu_tag);
253      cpu_set_input_line(cpu, INPUT_LINE_HALT, ASSERT_LINE);
254254      timer_adjust_periodic(dmac->timer[channel], attotime_zero, channel, dmac->burst_clock[channel]);
255255   }
256256   else
r6048r6049
427427            dmac->in_progress[x] = 0;
428428            dmac->reg[x].csr |= 0xe0;  // channel operation complete, block transfer complete
429429            dmac->reg[x].csr &= ~0x08;  // channel no longer active
430            if((dmac->reg[x].dcr & 0xc0) == 0x00)  // Burst transfer
431               cpu_set_input_line(cpu_get_by_index(device->machine, dmac->intf->cpu), INPUT_LINE_HALT,CLEAR_LINE);
432430
431            // Burst transfer
432            if((dmac->reg[x].dcr & 0xc0) == 0x00)
433            {
434               const device_config *cpu = devtag_get_device(device->machine, dmac->intf->cpu_tag);
435               cpu_set_input_line(cpu, INPUT_LINE_HALT, CLEAR_LINE);
436            }
437
433438            if(dmac->intf->dma_end)
434439               dmac->intf->dma_end(device->machine,x,dmac->reg[x].ccr & 0x08);
435440         }
src/mess/machine/pc.c
r6048r6049
605605   int data = 0xFF;
606606   running_machine *machine = device->machine;
607607   pc_state *st = device->machine->driver_data;
608   
608
609609   /* KB port A */
610610   if (st->ppi_keyboard_clear)
611611   {
r6048r6049
806806static WRITE8_HANDLER( ibm5150_kb_set_data_signal )
807807{
808808   pc_state *st = space->machine->driver_data;
809   
809
810810   st->ppi_data_signal = data;
811811
812812   st->ppi_data_callback( space, 0, st->ppi_data_signal );
r6048r6049
816816static void ibm5150_set_keyboard_interface( running_machine *machine, write8_space_func clock_cb, write8_space_func data_cb )
817817{
818818   pc_state *st = machine->driver_data;
819   
819
820820   st->ppi_clock_callback = clock_cb;
821821   st->ppi_data_callback = data_cb;
822822}
r6048r6049
840840   int data = 0xFF;
841841   running_machine *machine = device->machine;
842842   pc_state *st = device->machine->driver_data;
843   
843
844844   /* KB port A */
845845   if (st->ppi_keyboard_clear)
846846   {
r6048r6049
935935
936936static READ8_DEVICE_HANDLER (pc_ppi_porta_r)
937937{
938   int data = 0xFF;   
938   int data = 0xFF;
939939   running_machine *machine = device->machine;
940940   pc_state *st = device->machine->driver_data;
941941
r6048r6049
11811181DRIVER_INIT( bondwell )
11821182{
11831183   mess_init_pc_common(machine, PCCOMMON_KEYBOARD_PC, NULL, pc_set_irq_line);
1184   pc_turbo_setup(machine, 0, "DSW2", 0x02, 4.77/12, 1);
1184   pc_turbo_setup(machine, machine->firstcpu, "DSW2", 0x02, 4.77/12, 1);
11851185
11861186   /* Attach keyboard to the keyboard controller */
11871187   ibm5150_set_keyboard_interface( machine, kb_keytronic_set_clock_signal, kb_keytronic_set_data_signal );
r6048r6049
12231223DRIVER_INIT( t1000hx )
12241224{
12251225   mess_init_pc_common(machine, PCCOMMON_KEYBOARD_PC, pc_set_keyb_int, pc_set_irq_line);
1226   pc_turbo_setup(machine, 0, "DSW2", 0x02, 4.77/12, 1);
1226   pc_turbo_setup(machine, machine->firstcpu, "DSW2", 0x02, 4.77/12, 1);
12271227}
12281228
12291229DRIVER_INIT( pc200 )
r6048r6049
12391239   memory_install_read16_handler( space, 0xb0000, 0xbffff, 0, 0, pc200_videoram16le_r );
12401240   memory_install_write16_handler( space, 0xb0000, 0xbffff, 0, 0, pc200_videoram16le_w );
12411241   videoram_size=0x10000;
1242   videoram=memory_region(machine, "maincpu")+0xb0000;   
1242   videoram=memory_region(machine, "maincpu")+0xb0000;
12431243   mess_init_pc_common(machine, PCCOMMON_KEYBOARD_PC, pc_set_keyb_int, pc_set_irq_line);
12441244}
12451245
r6048r6049
12561256   memory_install_read16_handler( space, 0xb0000, 0xbffff, 0, 0, pc200_videoram16le_r );
12571257   memory_install_write16_handler( space, 0xb0000, 0xbffff, 0, 0, pc200_videoram16le_w );
12581258   videoram_size=0x10000;
1259   videoram=memory_region(machine, "maincpu")+0xb0000;   
1259   videoram=memory_region(machine, "maincpu")+0xb0000;
12601260   mess_init_pc_common(machine, PCCOMMON_KEYBOARD_PC, pc_set_keyb_int, pc_set_irq_line);
12611261   mc146818_init(machine, MC146818_IGNORE_CENTURY);
12621262}
src/mess/machine/hd63450.h
r6048r6049
77typedef struct _hd63450_interface hd63450_intf;
88struct _hd63450_interface
99{
10   int cpu;
10   const char *cpu_tag;
1111   attotime clock[4];
1212   attotime burst_clock[4];
1313   void (*dma_end)(running_machine *machine,int channel,int irq);  // called when the DMA transfer ends
src/mess/mslegacy.c
r6048r6049
7676{
7777   return mess_default_text[string_num];
7878}
79
80
81
82/***************************************************************************
83    CPU
84***************************************************************************/
85
86const device_config *cpu_get_by_index(running_machine *machine, int index)
87{
88   const device_config *cpu = cpu_first(machine->config);
89   while((cpu != NULL) && (index > 0))
90   {
91      cpu = cpu_next(cpu);
92      index--;
93   }
94   return cpu;
95}
src/mess/mslegacy.h
r6048r6049
7373/* uitext */
7474const char * ui_getstring (int string_num);
7575
76/* retrieves a CPU by index */
77const device_config *cpu_get_by_index(running_machine *machine, int index);
78
7976#endif /* MSLEGACY_H */
src/mess/drivers/palm.c
r6048r6049
142142
143143static const mc68328_interface palm_dragonball_iface =
144144{
145    0,
145   "maincpu",
146146
147147    NULL,                   // Port A Output
148148    NULL,                   // Port B Output
src/mess/drivers/x68k.c
r6048r6049
18851885
18861886static const hd63450_intf dmac_interface =
18871887{
1888   0,  // CPU - 68000
1888   "maincpu",  // CPU - 68000
18891889   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_USEC(4),STATIC_ATTOTIME_IN_HZ(15625/2)},  // Cycle steal mode timing (guesstimate)
18901890   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_NSEC(50),STATIC_ATTOTIME_IN_NSEC(50)}, // Burst mode timing (guesstimate)
18911891   x68k_dma_end,

Previous 15994 Revisions Next


© 1998-2018 The MESS Team