Skip to content

Commit ef0a31c

Browse files
committed
From: Atari Ace [mailto:[email protected]]
Sent: Sunday, June 07, 2009 9:54 AM To: [email protected] Cc: [email protected] Subject: [patch] "Regularize" some interfaces in MAME Hi mamedev, This patch adjusts the code in a few places to be more regular in it object approach. It recognizes five idioms. 1. device_configs should be passed const. dsp56k.h took a non-const device_config for no particular reason, necessitating casting where used. A few other places cast to non-const, in most cases unnecessarily. 2. running_machines should be passed non-const. A few places used const in different ways on running_machines, instead of the idiomatic non-const running_machine. 3. Eliminate passing running_machine explicitly where it can be computed. esrip.c, m37710.c, sfbonus.c had cases where the machine could easily be eliminated. 4. Pass the object machine/config first. In some cases this makes the interface object oriented, in some cases it simply makes it more idiomatic with the rest of MAME. 5. Prefer (screen, bitmap, cliprect) to (machine, bitmap, cliprect). Fully implementing this would be a large patch, this patch simply does it for the one core 'device', tms9928a.c.
1 parent ce83de8 commit ef0a31c

File tree

23 files changed

+160
-128
lines changed

23 files changed

+160
-128
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,7 @@ src/mame/includes/vsnes.h svneol=native#text/plain
25552555
src/mame/includes/warpwarp.h svneol=native#text/plain
25562556
src/mame/includes/wc90.h svneol=native#text/plain
25572557
src/mame/includes/williams.h svneol=native#text/plain
2558+
src/mame/includes/wiping.h svneol=native#text/plain
25582559
src/mame/includes/wrally.h svneol=native#text/plain
25592560
src/mame/includes/wwfwfest.h svneol=native#text/plain
25602561
src/mame/includes/xmen.h svneol=native#text/plain

src/emu/cpu/arm7/arm7.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static CPU_INIT( arm7 )
8686
arm_state *cpustate = get_safe_token(device);
8787

8888
// must call core
89-
arm7_core_init("arm7", device);
89+
arm7_core_init(device, "arm7");
9090

9191
cpustate->irq_callback = irqcallback;
9292
cpustate->device = device;

src/emu/cpu/arm7/arm7core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int storeDec(arm_state *cpustate, UINT32 pat, UINT32 rbv)
507507
***************************************************************************/
508508

509509
// CPU INIT
510-
static void arm7_core_init(const char *cpuname, const device_config *device)
510+
static void arm7_core_init(const device_config *device, const char *cpuname)
511511
{
512512
arm_state *cpustate = get_safe_token(device);
513513

src/emu/cpu/dsp56k/dsp56k.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ typedef struct
243243
PUBLIC FUNCTIONS
244244
***************************************************************************/
245245

246-
void dsp56k_host_interface_write(device_config* device, UINT8 offset, UINT8 data);
247-
UINT8 dsp56k_host_interface_read(device_config* device, UINT8 offset);
246+
void dsp56k_host_interface_write(const device_config* device, UINT8 offset, UINT8 data);
247+
UINT8 dsp56k_host_interface_read(const device_config* device, UINT8 offset);
248248

249-
UINT16 dsp56k_get_peripheral_memory(device_config* device, UINT16 addr);
249+
UINT16 dsp56k_get_peripheral_memory(const device_config* device, UINT16 addr);
250250

251251
#endif /* __DSP56K_H__ */

src/emu/cpu/dsp56k/dsp56mem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static void dsp56k_host_interface_reset(dsp56k_core* cpustate)
610610

611611
/* These two functions are exposed to the outside world */
612612
/* They represent the host side of the dsp56k's host interface */
613-
void dsp56k_host_interface_write(device_config* device, UINT8 offset, UINT8 data)
613+
void dsp56k_host_interface_write(const device_config* device, UINT8 offset, UINT8 data)
614614
{
615615
dsp56k_core* cpustate = get_safe_token(device);
616616

@@ -706,7 +706,7 @@ void dsp56k_host_interface_write(device_config* device, UINT8 offset, UINT8 data
706706
}
707707
}
708708

709-
UINT8 dsp56k_host_interface_read(device_config* device, UINT8 offset)
709+
UINT8 dsp56k_host_interface_read(const device_config* device, UINT8 offset)
710710
{
711711
dsp56k_core* cpustate = get_safe_token(device);
712712

@@ -934,7 +934,7 @@ static void dsp56k_io_reset(dsp56k_core* cpustate)
934934

935935

936936
/* MISC*/
937-
UINT16 dsp56k_get_peripheral_memory(device_config* device, UINT16 addr)
937+
UINT16 dsp56k_get_peripheral_memory(const device_config* device, UINT16 addr)
938938
{
939939
// TODO // THIS COMES BACK dsp56k_core* cpustate = get_safe_token(device);
940940
return dsp56k_peripheral_ram[A2O(addr)];

src/emu/cpu/esrip/esrip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int get_lbrm(esrip_state *cpustate)
368368
return (val >> sel) & 1;
369369
}
370370

371-
INLINE int check_jmp(esrip_state *cpustate, running_machine *machine, UINT8 jmp_ctrl)
371+
INLINE int check_jmp(esrip_state *cpustate, UINT8 jmp_ctrl)
372372
{
373373
int ret = 0;
374374

@@ -382,7 +382,7 @@ INLINE int check_jmp(esrip_state *cpustate, running_machine *machine, UINT8 jmp_
382382
/* T3 */ case 6: ret = BIT(cpustate->t, 2); break;
383383
/* T4 */ case 1: ret = BIT(cpustate->t, 3); break;
384384
/* /LBRM */ case 5: ret = !get_lbrm(cpustate); break;
385-
/* /HBLANK */ case 3: ret = !get_hblank(machine); break;
385+
/* /HBLANK */ case 3: ret = !get_hblank(cpustate->device->machine); break;
386386
/* JMP */ case 7: ret = 0; break;
387387
}
388388

@@ -1762,7 +1762,7 @@ static CPU_EXECUTE( esrip )
17621762

17631763
if ((((cpustate->l5 >> 3) & 0x1f) & 0x18) != 0x18)
17641764
{
1765-
if ( check_jmp(cpustate, device->machine, (cpustate->l5 >> 3) & 0x1f) )
1765+
if ( check_jmp(cpustate, (cpustate->l5 >> 3) & 0x1f) )
17661766
next_pc = cpustate->l1;
17671767
else
17681768
next_pc = cpustate->pc + 1;

src/emu/cpu/m37710/m37710.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static void m37710_external_tick(m37710i_cpu_struct *cpustate, int timer, int st
303303
}
304304
}
305305

306-
static void m37710_recalc_timer(m37710i_cpu_struct *cpustate, running_machine *machine, int timer)
306+
static void m37710_recalc_timer(m37710i_cpu_struct *cpustate, int timer)
307307
{
308308
int tval;
309309
static const int tcr[8] = { 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d };
@@ -505,7 +505,7 @@ static void m37710_internal_w(m37710i_cpu_struct *cpustate, int offset, UINT8 da
505505
if ((data & (1<<i)) && !(cpustate->m37710_regs[offset] & (1<<i)))
506506
{
507507
cpustate->m37710_regs[offset] |= (1<<i);
508-
m37710_recalc_timer(cpustate, cpustate->device->machine, i);
508+
m37710_recalc_timer(cpustate, i);
509509
}
510510
}
511511

src/emu/cpu/pdp1/tx0.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void tx0_write(tx0_state *cpustate, offs_t address, int data)
127127
;
128128
}
129129

130-
static void tx0_init_common(int is_64kw, const device_config *device, cpu_irq_callback irqcallback)
130+
static void tx0_init_common(const device_config *device, cpu_irq_callback irqcallback, int is_64kw)
131131
{
132132
tx0_state *cpustate = get_safe_token(device);
133133

@@ -143,12 +143,12 @@ static void tx0_init_common(int is_64kw, const device_config *device, cpu_irq_ca
143143

144144
static CPU_INIT( tx0_64kw )
145145
{
146-
tx0_init_common(1, device, irqcallback);
146+
tx0_init_common(device, irqcallback, 1);
147147
}
148148

149149
static CPU_INIT( tx0_8kw)
150150
{
151-
tx0_init_common(0, device, irqcallback);
151+
tx0_init_common(device, irqcallback, 0);
152152
}
153153

154154
static CPU_RESET( tx0 )

src/emu/machine/i2cmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ int i2cmem_read( running_machine *machine, int chip, int line )
406406
return 0;
407407
}
408408

409-
static void nvram_handler_i2cmem( int chip, running_machine *machine, mame_file *file, int read_or_write )
409+
static void nvram_handler_i2cmem( running_machine *machine, mame_file *file, int read_or_write, int chip )
410410
{
411411
struct i2cmem_chip *c;
412412

@@ -428,4 +428,4 @@ static void nvram_handler_i2cmem( int chip, running_machine *machine, mame_file
428428
}
429429
}
430430

431-
NVRAM_HANDLER( i2cmem_0 ) { nvram_handler_i2cmem( 0, machine, file, read_or_write ); }
431+
NVRAM_HANDLER( i2cmem_0 ) { nvram_handler_i2cmem( machine, file, read_or_write, 0 ); }

src/emu/video.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ DEVICE_GET_INFO( video_screen )
13431343
static TIMER_CALLBACK( vblank_begin_callback )
13441344
{
13451345
int i;
1346-
device_config *screen = (device_config *)ptr;
1346+
const device_config *screen = (const device_config *)ptr;
13471347
screen_state *state = get_safe_token(screen);
13481348

13491349
/* reset the starting VBLANK time */
@@ -1363,7 +1363,7 @@ static TIMER_CALLBACK( vblank_begin_callback )
13631363

13641364
/* if no VBLANK period, call the VBLANK end callback immedietely, otherwise reset the timer */
13651365
if (state->vblank_period == 0)
1366-
vblank_end_callback(machine, screen, 0);
1366+
vblank_end_callback(machine, ptr, 0);
13671367
else
13681368
timer_adjust_oneshot(state->vblank_end_timer, video_screen_get_time_until_vblank_end(screen), 0);
13691369
}

0 commit comments

Comments
 (0)