Previous 15994 Revisions Next

r9923 Wednesday 5th January, 2011 at 13:38:50 UTC by Miodrag Milanović
Sync with MAME, MESSRAM moved to emu section
[src/emu]driver.h emu.mak emuopts.c emuopts.h info.c inptport.c uimenu.c
[src/emu/cpu]cpu.mak drcbex64.c drcfe.c drcfe.h
[src/emu/cpu/arm7]arm7core.c
[src/emu/cpu/mips]mips3drc.c mips3fe.c mips3fe.h
[src/emu/cpu/nec]necdasm.c
[src/emu/cpu/powerpc]ppcdrc.c ppcfe.c ppcfe.h
[src/emu/cpu/rsp]rsp.c rsp.h rspdrc.c rspfe.c rspfe.h
[src/emu/cpu/sh2]sh2comn.h sh2drc.c sh2fe.c
[src/emu/machine]ram.c* ram.h*
[src/emu/sound]disc_dev.c disc_flt.c disc_inp.c disc_mth.c disc_sys.c disc_wav.c discrete.c discrete.h
[src/mess]mess.c mess.h mess.mak
[src/mess/audio]mac.c
[src/mess/devices]coco_vhd.c messram.c messram.h multcart.c
[src/mess/drivers]a310.c abc1600.c abc80.c abc80x.c aim65.c amstrad.c apple1.c apple2.c apple2gs.c apple3.c apricot.c aquarius.c at.c atari.c atarist.c atm.c atom.c avigo.c b2m.c bebox.c beta.c bullet.c bw12.c bw2.c c16.c c65.c c80.c cgc7900.c cgenie.c coco.c comx35.c cosmicos.c crvision.c cybiko.c dai.c dgn_beta.c e01.c einstein.c elf.c elwro800.c enterp.c eti660.c exp85.c fk1.c fmtowns.c galaxy.c gb.c huebler.c jtc.c kc.c kyocera.c lc80.c llc.c lviv.c mac.c mc10.c mc1000.c micronic.c mikromik.c mtx.c mz700.c nanos.c nascom1.c nc.c newbrain.c ob68k1a.c ondra.c orion.c osbexec.c osborne1.c osi.c palm.c partner.c pc.c pc8001.c pc8401a.c pce220.c pcw.c pcw16.c pecom.c pentagon.c pet.c phc25.c pk8000.c pk8020.c pmd85.c pocketc.c poly880.c portfoli.c pp01.c prestige.c prof180x.c prof80.c ptcsol.c px4.c px8.c pyl601.c ql.c qx10.c rmnimbus.c rt1715.c rx78.c samcoupe.c sapi1.c scorpion.c sg1000.c spc1000.c spec128.c special.c specpls3.c spectrum.c svi318.c sym1.c tandy2k.c tek405x.c thomson.c tiki100.c timex.c tmc1800.c tmc2000e.c tmc600.c trs80m2.c tvc.c unixpc.c v1050.c vcs80.c vector06.c vg5k.c vic20.c victor9k.c vidbrain.c vip.c vixen.c vt220.c vt240.c vt320.c vt520.c vtech1.c x68k.c xerox820.c xor100.c z80ne.c z88.c zx.c
[src/mess/formats]comx35_comx.c
[src/mess/includes]abc80.h abc80x.h bullet.h bw12.h bw2.h comx35.h gb.h kyocera.h mac.h ob68k1a.h ql.h sg1000.h tandy2k.h tek405x.h tmc600.h v1050.h victor9k.h vip.h vixen.h xerox820.h xor100.h
[src/mess/machine]6883sam.c aim65.c amstrad.c apple1.c apple2.c apple2gs.c apple3.c at.c ataricrt.c b2m.c bebox.c c16.c c65.c cgenie.c coco.c comx35.c cybiko.c dai.c dgn_beta.c galaxy.c gb.c kc.c llc.c lviv.c mac.c mpc105.c mtx.c mz700.c nascom1.c ondra.c orion.c osborne1.c partner.c pc.c pc1350.c pc1401.c pc1403.c pecom.c pet.c pk8020.c pmd85.c pp01.c rmnimbus.c rt1715.c samcoupe.c special.c svi318.c sym1.c tf20.c thomson.c vector06.c zx.c
[src/mess/osd/winui]optionsms.c propertiesms.c
[src/mess/tools/messtest]testmess.c
[src/mess/video]apple2.c apple3.c b2m.c coco3.c dgn_beta.c epnick.c fmtowns.c kc.c mac.c mc68328.c nc.c ondra.c orion.c pc_t1t.c pcw.c pcw16.c pk8020.c pmd85.c pp01.c special.c timex.c vector06.c x68k.c z88.c

src/emu/cpu/cpu.mak
r9922r9923
842842$(CPUOBJ)/mips/r3000.o:   $(CPUSRC)/mips/r3000.c \
843843         $(CPUSRC)/mips/r3000.h
844844
845$(CPUOBJ)/mips/mips3.o:   $(CPUSRC)/mips/mips3.h \
846         $(CPUSRC)/mips/mips3com.h \
847         $(CPUSRC)/mips/mips3.c
845$(CPUOBJ)/mips/mips3.o:   $(CPUSRC)/mips/mips3.h $(CPUSRC)/mips/mips3com.h \
846            $(CPUSRC)/mips/mips3.c
848847
849848$(CPUOBJ)/mips/mips3com.o:   $(CPUSRC)/mips/mips3.h \
850849            $(CPUSRC)/mips/mips3com.h
src/emu/cpu/drcfe.c
r9922r9923
44
55    Generic dynamic recompiler frontend structures and utilities.
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138****************************************************************************
1239
1340    Future improvements/changes:
r9922r9923
2148#include "drcfe.h"
2249
2350
24/***************************************************************************
25    CONSTANTS
26***************************************************************************/
51//**************************************************************************
52//  CONSTANTS
53//**************************************************************************
2754
28#define MAX_STACK_DEPTH      100
55const UINT32 MAX_STACK_DEPTH = 100;
2956
3057
3158
32/***************************************************************************
33    TYPE DEFINITIONS
34***************************************************************************/
59//**************************************************************************
60//  TYPE DEFINITIONS
61//**************************************************************************
3562
36/* an entry that maps branches for our code walking */
37typedef struct _pc_stack_entry pc_stack_entry;
38struct _pc_stack_entry
63// an entry that maps branches for our code walking
64struct pc_stack_entry
3965{
4066   offs_t            targetpc;
4167   offs_t            srcpc;
4268};
4369
4470
45/* internal state */
46struct _drcfe_state
47{
48   /* configuration parameters */
49   UINT32            window_start;            /* code window start offset = startpc - window_start */
50   UINT32            window_end;               /* code window end offset = startpc + window_end */
51   UINT32            max_sequence;            /* maximum instructions to include in a sequence */
5271
53   drcfe_describe_func   describe;               /* callback to describe a single instruction */
54   void *            param;                  /* parameter for the callback */
72//**************************************************************************
73//  DRC FRONTEND
74//**************************************************************************
5575
56   /* CPU parameters */
57   cpu_device *      cpudevice;               /* CPU device object */
58   address_space *program;               /* program address space for this CPU */
59   offs_t            pageshift;               /* shift to convert address to a page index */
76//-------------------------------------------------
77//  drc_frontend - constructor
78//-------------------------------------------------
6079
61   /* opcode descriptor arrays */
62   opcode_desc *      desc_live_list;            /* head of list of live descriptions */
63   opcode_desc *      desc_free_list;            /* head of list of free descriptions */
64   opcode_desc **      desc_array;               /* array of descriptions in PC order */
65   UINT32            desc_array_size;         /* size of the array */
66};
67
68
69
70/***************************************************************************
71    FUNCTION PROTOTYPES
72***************************************************************************/
73
74static opcode_desc *describe_one(drcfe_state *drcfe, offs_t curpc, const opcode_desc *prevdesc);
75static opcode_desc **build_sequence(drcfe_state *drcfe, opcode_desc **tailptr, int start, int end, UINT32 endflag);
76static void accumulate_required_backwards(opcode_desc *desc, UINT32 *reqmask);
77static void release_descriptions(drcfe_state *drcfe, opcode_desc *desc);
78
79
80
81/***************************************************************************
82    INLINE FUNCTIONS
83***************************************************************************/
84
85/*-------------------------------------------------
86    desc_alloc - allocate a new opcode description
87-------------------------------------------------*/
88
89INLINE opcode_desc *desc_alloc(drcfe_state *drcfe)
80drc_frontend::drc_frontend(device_t &cpu, UINT32 window_start, UINT32 window_end, UINT32 max_sequence)
81   : m_window_start(window_start),
82     m_window_end(window_end),
83     m_max_sequence(max_sequence),
84     m_cpudevice(downcast<cpu_device &>(cpu)),
85     m_program(m_cpudevice.space(AS_PROGRAM)),
86     m_pageshift(m_cpudevice.space_config(AS_PROGRAM)->m_page_shift),
87     m_desc_live_list(cpu.machine->m_respool),
88     m_desc_allocator(cpu.machine->m_respool),
89     m_desc_array(auto_alloc_array_clear(cpu.machine, opcode_desc *, window_end + window_start + 2))
9090{
91   opcode_desc *desc = drcfe->desc_free_list;
92
93   /* pull a description off of the free list or allocate a new one */
94   if (desc != NULL)
95      drcfe->desc_free_list = desc->next;
96   else
97      desc = auto_alloc(drcfe->cpudevice->machine, opcode_desc);
98   return desc;
9991}
10092
10193
102/*-------------------------------------------------
103    desc_free - free an opcode description
104-------------------------------------------------*/
94//-------------------------------------------------
95//  ~drc_frontend - destructor
96//-------------------------------------------------
10597
106INLINE void desc_free(drcfe_state *drcfe, opcode_desc *desc)
98drc_frontend::~drc_frontend()
10799{
108   /* just put ourselves on the free list */
109   desc->next = drcfe->desc_free_list;
110   drcfe->desc_free_list = desc;
111}
100   // release any descriptions we've accumulated
101   release_descriptions();
112102
113
114
115/***************************************************************************
116    CORE IMPLEMENTATION
117***************************************************************************/
118
119/*-------------------------------------------------
120    drcfe_init - initializate the drcfe state
121-------------------------------------------------*/
122
123drcfe_state *drcfe_init(device_t *cpu, const drcfe_config *config, void *param)
124{
125   drcfe_state *drcfe;
126
127   /* allocate some memory to hold the state */
128   drcfe = auto_alloc_clear(cpu->machine, drcfe_state);
129
130   /* allocate the description array */
131   drcfe->desc_array = auto_alloc_array_clear(cpu->machine, opcode_desc *, config->window_end + config->window_start + 2);
132
133   /* copy in configuration information */
134   drcfe->window_start = config->window_start;
135   drcfe->window_end = config->window_end;
136   drcfe->max_sequence = config->max_sequence;
137   drcfe->describe = config->describe;
138   drcfe->param = param;
139
140   /* initialize the state */
141   drcfe->cpudevice = downcast<cpu_device *>(cpu);
142   drcfe->program = drcfe->cpudevice->space(AS_PROGRAM);
143   drcfe->pageshift = drcfe->cpudevice->space_config(AS_PROGRAM)->m_page_shift;
144
145   return drcfe;
103   // free the description array
104   auto_free(m_cpudevice.machine, m_desc_array);
146105}
147106
148107
149/*-------------------------------------------------
150    drcfe_exit - clean up after ourselves
151-------------------------------------------------*/
108//-------------------------------------------------
109//  describe_code - describe a sequence of code
110//  that falls within the configured window
111//  relative to the specified startpc
112//-------------------------------------------------
152113
153void drcfe_exit(drcfe_state *drcfe)
114const opcode_desc *drc_frontend::describe_code(offs_t startpc)
154115{
155   /* release any descriptions we've accumulated */
156   release_descriptions(drcfe, drcfe->desc_live_list);
116   // release any descriptions we've accumulated
117   release_descriptions();
157118
158   /* free our free list of descriptions */
159   while (drcfe->desc_free_list != NULL)
160   {
161      opcode_desc *freeme = drcfe->desc_free_list;
162      drcfe->desc_free_list = drcfe->desc_free_list->next;
163      auto_free(drcfe->cpudevice->machine, freeme);
164   }
165
166   /* free the description array */
167   auto_free(drcfe->cpudevice->machine, drcfe->desc_array);
168
169   /* free the object itself */
170   auto_free(drcfe->cpudevice->machine, drcfe);
171}
172
173
174/*-------------------------------------------------
175    drcfe_describe_code - describe a sequence of
176    code that falls within the configured window
177    relative to the specified startpc
178-------------------------------------------------*/
179
180const opcode_desc *drcfe_describe_code(drcfe_state *drcfe, offs_t startpc)
181{
182   offs_t minpc = startpc - MIN(drcfe->window_start, startpc);
183   offs_t maxpc = startpc + MIN(drcfe->window_end, 0xffffffff - startpc);
119   // add the initial PC to the stack
184120   pc_stack_entry pcstack[MAX_STACK_DEPTH];
185121   pc_stack_entry *pcstackptr = &pcstack[0];
186   opcode_desc **tailptr;
187
188   /* release any descriptions we've accumulated */
189   release_descriptions(drcfe, drcfe->desc_live_list);
190   drcfe->desc_live_list = NULL;
191
192   /* add the initial PC to the stack */
193122   pcstackptr->srcpc = 0;
194123   pcstackptr->targetpc = startpc;
195124   pcstackptr++;
196125
197   /* loop while we still have a stack */
126   // loop while we still have a stack
127   offs_t minpc = startpc - MIN(m_window_start, startpc);
128   offs_t maxpc = startpc + MIN(m_window_end, 0xffffffff - startpc);
198129   while (pcstackptr != &pcstack[0])
199130   {
131      // if we've already hit this PC, just mark it a branch target and continue
200132      pc_stack_entry *curstack = --pcstackptr;
201      opcode_desc *curdesc;
202      offs_t curpc;
203
204      /* if we've already hit this PC, just mark it a branch target and continue */
205      curdesc = drcfe->desc_array[curstack->targetpc - minpc];
133      opcode_desc *curdesc = m_desc_array[curstack->targetpc - minpc];
206134      if (curdesc != NULL)
207135      {
208136         curdesc->flags |= OPFLAG_IS_BRANCH_TARGET;
209137
210         /* if the branch crosses a page boundary, mark the target as needing to revalidate */
211         if (drcfe->pageshift != 0 && ((curstack->srcpc ^ curdesc->pc) >> drcfe->pageshift) != 0)
138         // if the branch crosses a page boundary, mark the target as needing to revalidate
139         if (m_pageshift != 0 && ((curstack->srcpc ^ curdesc->pc) >> m_pageshift) != 0)
212140            curdesc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION;
213141
214         /* continue processing */
142         // continue processing
215143         continue;
216144      }
217145
218      /* loop until we exit the block */
219      for (curpc = curstack->targetpc; curpc >= minpc && curpc < maxpc && drcfe->desc_array[curpc - minpc] == NULL; curpc += drcfe->desc_array[curpc - minpc]->length)
146      // loop until we exit the block
147      for (offs_t curpc = curstack->targetpc; curpc >= minpc && curpc < maxpc && m_desc_array[curpc - minpc] == NULL; curpc += m_desc_array[curpc - minpc]->length)
220148      {
221         /* allocate a new description and describe this instruction */
222         drcfe->desc_array[curpc - minpc] = curdesc = describe_one(drcfe, curpc, curdesc);
149         // allocate a new description and describe this instruction
150         m_desc_array[curpc - minpc] = curdesc = describe_one(curpc, curdesc);
223151
224         /* first instruction in a sequence is always a branch target */
152         // first instruction in a sequence is always a branch target
225153         if (curpc == curstack->targetpc)
226154            curdesc->flags |= OPFLAG_IS_BRANCH_TARGET;
227155
228         /* stop if we hit a page fault */
156         // stop if we hit a page fault
229157         if (curdesc->flags & OPFLAG_COMPILER_PAGE_FAULT)
230158            break;
231159
232         /* if we are the first instruction in the whole window, we must validate the TLB */
233         if (curpc == startpc && drcfe->pageshift != 0)
160         // if we are the first instruction in the whole window, we must validate the TLB
161         if (curpc == startpc && m_pageshift != 0)
234162            curdesc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION;
235163
236         /* if we are a branch within the block range, add the branch target to our stack */
164         // if we are a branch within the block range, add the branch target to our stack
237165         if ((curdesc->flags & OPFLAG_IS_BRANCH) && curdesc->targetpc >= minpc && curdesc->targetpc < maxpc && pcstackptr < &pcstack[MAX_STACK_DEPTH])
238166         {
239167            curdesc->flags |= OPFLAG_INTRABLOCK_BRANCH;
r9922r9923
242170            pcstackptr++;
243171         }
244172
245         /* if we're done, we're done */
173         // if we're done, we're done
246174         if (curdesc->flags & OPFLAG_END_SEQUENCE)
247175            break;
248176      }
249177   }
250178
251   /* now build the list of descriptions in order */
252   /* first from startpc -> maxpc, then from minpc -> startpc */
253   tailptr = build_sequence(drcfe, &drcfe->desc_live_list, startpc - minpc, maxpc - minpc, OPFLAG_REDISPATCH);
254   tailptr = build_sequence(drcfe, tailptr, minpc - minpc, startpc - minpc, OPFLAG_RETURN_TO_START);
255   return drcfe->desc_live_list;
179   // now build the list of descriptions in order
180   // first from startpc -> maxpc, then from minpc -> startpc
181   build_sequence(startpc - minpc, maxpc - minpc, OPFLAG_REDISPATCH);
182   build_sequence(minpc - minpc, startpc - minpc, OPFLAG_RETURN_TO_START);
183   return m_desc_live_list.first();
256184}
257185
258186
187//-------------------------------------------------
188//  describe_one - describe a single instruction,
189//  recursively describing opcodes in delay
190//  slots of branches as well
191//-------------------------------------------------
259192
260/***************************************************************************
261    INTERNAL HELPERS
262***************************************************************************/
263
264/*-------------------------------------------------
265    describe_one - describe a single instruction,
266    recursively describing opcodes in delay
267    slots of branches as well
268-------------------------------------------------*/
269
270static opcode_desc *describe_one(drcfe_state *drcfe, offs_t curpc, const opcode_desc *prevdesc)
193opcode_desc *drc_frontend::describe_one(offs_t curpc, const opcode_desc *prevdesc)
271194{
272   opcode_desc *desc = desc_alloc(drcfe);
273
274   /* initialize the description */
195   // initialize the description
196   opcode_desc *desc = m_desc_allocator.alloc();
275197   memset(desc, 0, sizeof(*desc));
276198   desc->pc = curpc;
277199   desc->physpc = curpc;
278200   desc->targetpc = BRANCH_TARGET_DYNAMIC;
279201
280   /* call the callback to describe an instruction */
281   if (!(*drcfe->describe)(drcfe->param, desc, prevdesc))
202   // call the callback to describe an instruction
203   if (!describe(*desc, prevdesc))
282204   {
283205      desc->flags |= OPFLAG_WILL_CAUSE_EXCEPTION | OPFLAG_INVALID_OPCODE;
284206      return desc;
285207   }
286208
287   /* validate the TLB if we are exactly at the start of a page, or if we cross a page boundary */
288   if (drcfe->pageshift != 0 && (((curpc - 1) ^ (curpc + desc->length - 1)) >> drcfe->pageshift) != 0)
209   // validate the TLB if we are exactly at the start of a page, or if we cross a page boundary
210   if (m_pageshift != 0 && (((curpc - 1) ^ (curpc + desc->length - 1)) >> m_pageshift) != 0)
289211      desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION;
290212
291   /* validate stuff */
213   // validate stuff
292214   assert(desc->length > 0 || (desc->flags & OPFLAG_VIRTUAL_NOOP) != 0);
293215
294   /* if we are a branch with delay slots, recursively walk those */
216   // if we are a branch with delay slots, recursively walk those
295217   if (desc->flags & OPFLAG_IS_BRANCH)
296218   {
297      opcode_desc **tailptr = &desc->delay;
219      // iterate over slots and describe them
298220      offs_t delaypc = curpc + desc->length;
299221      opcode_desc *prev = desc;
300      UINT8 slotnum;
301
302      /* iterate over slots and describe them */
303      for (slotnum = 0; slotnum < desc->delayslots; slotnum++)
222      for (UINT8 slotnum = 0; slotnum < desc->delayslots; slotnum++)
304223      {
305         /* recursively describe the next instruction */
306         *tailptr = describe_one(drcfe, delaypc, prev);
307         if (*tailptr == NULL)
224         // recursively describe the next instruction
225         opcode_desc *delaydesc = describe_one(delaypc, prev);
226         if (delaydesc == NULL)
308227            break;
228         desc->delay.append(*delaydesc);
229         prev = desc;
309230
310         /* set the delay slot flag and a pointer back to the original branch */
311         (*tailptr)->flags |= OPFLAG_IN_DELAY_SLOT;
312         (*tailptr)->branch = desc;
313         (*tailptr)->prev = prev;
314         prev = *tailptr;
231         // set the delay slot flag and a pointer back to the original branch
232         delaydesc->flags |= OPFLAG_IN_DELAY_SLOT;
233         delaydesc->branch = desc;
315234
316         /* stop if we hit a page fault */
317         if ((*tailptr)->flags & OPFLAG_COMPILER_PAGE_FAULT)
235         // stop if we hit a page fault
236         if (delaydesc->flags & OPFLAG_COMPILER_PAGE_FAULT)
318237            break;
319238
320         /* otherwise, advance */
321         delaypc += (*tailptr)->length;
322         tailptr = &(*tailptr)->next;
239         // otherwise, advance
240         delaypc += delaydesc->length;
323241      }
324242   }
325
326243   return desc;
327244}
328245
329246
330/*-------------------------------------------------
331    build_sequence - build an ordered sequence
332    of instructions
333-------------------------------------------------*/
247//-------------------------------------------------
248//  build_sequence - build an ordered sequence
249//  of instructions
250//-------------------------------------------------
334251
335static opcode_desc **build_sequence(drcfe_state *drcfe, opcode_desc **tailptr, int start, int end, UINT32 endflag)
252void drc_frontend::build_sequence(int start, int end, UINT32 endflag)
336253{
337   opcode_desc *prev = NULL;
254   // iterate in order from start to end, picking up all non-NULL instructions
338255   int consecutive = 0;
339256   int seqstart = -1;
340257   int skipsleft = 0;
341   int descnum;
342
343   /* iterate in order from start to end, picking up all non-NULL instructions */
344   for (descnum = start; descnum < end; descnum++)
345      if (drcfe->desc_array[descnum] != NULL)
258   for (int descnum = start; descnum < end; descnum++)
259      if (m_desc_array[descnum] != NULL)
346260      {
347         opcode_desc *curdesc = drcfe->desc_array[descnum];
348         opcode_desc *nextdesc = NULL;
349         int nextdescnum;
350         UINT8 skipnum;
351
352         /* determine the next instruction, taking skips into account */
353         nextdescnum = descnum + curdesc->length;
354         nextdesc = (nextdescnum < end) ? drcfe->desc_array[nextdescnum] : NULL;
355         for (skipnum = 0; skipnum < curdesc->skipslots && nextdesc != NULL; skipnum++)
261         // determine the next instruction, taking skips into account
262         opcode_desc *curdesc = m_desc_array[descnum];
263         int nextdescnum = descnum + curdesc->length;
264         opcode_desc *nextdesc = (nextdescnum < end) ? m_desc_array[nextdescnum] : NULL;
265         for (UINT8 skipnum = 0; skipnum < curdesc->skipslots && nextdesc != NULL; skipnum++)
356266         {
357267            nextdescnum = nextdescnum + nextdesc->length;
358            nextdesc = (nextdescnum < end) ? drcfe->desc_array[nextdescnum] : NULL;
268            nextdesc = (nextdescnum < end) ? m_desc_array[nextdescnum] : NULL;
359269         }
360270
361         /* start a new sequence if we aren't already in the middle of one */
271         // start a new sequence if we aren't already in the middle of one
362272         if (seqstart == -1 && skipsleft == 0)
363273         {
364            /* tag all start-of-sequence instructions as needing TLB verification */
274            // tag all start-of-sequence instructions as needing TLB verification
365275            curdesc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION;
366276            seqstart = descnum;
367277         }
368278
369         /* if we are the last instruction, indicate end-of-sequence and redispatch */
279         // if we are the last instruction, indicate end-of-sequence and redispatch
370280         if (nextdesc == NULL)
371281         {
372282            curdesc->flags |= OPFLAG_END_SEQUENCE;
r9922r9923
374284               curdesc->flags |= endflag;
375285         }
376286
377         /* otherwise, do some analysis based on the next instruction */
287         // otherwise, do some analysis based on the next instruction
378288         else
379289         {
380            opcode_desc *scandesc = NULL;
290            // if there are instructions between us and the next instruction, we must end our sequence here
381291            int scandescnum;
382
383            /* if there are instructions between us and the next instruction, we must end our sequence here */
292            opcode_desc *scandesc = NULL;
384293            for (scandescnum = descnum + 1; scandescnum < end; scandescnum++)
385294            {
386               scandesc = drcfe->desc_array[scandescnum];
295               scandesc = m_desc_array[scandescnum];
387296               if (scandesc != NULL || scandesc == nextdesc)
388297                  break;
389298            }
390299            if (scandesc != nextdesc)
391300               curdesc->flags |= OPFLAG_END_SEQUENCE;
392301
393            /* if the next instruction is a branch target, mark this instruction as end of sequence */
302            // if the next instruction is a branch target, mark this instruction as end of sequence
394303            if (nextdesc->flags & OPFLAG_IS_BRANCH_TARGET)
395304               curdesc->flags |= OPFLAG_END_SEQUENCE;
396305         }
397306
398         /* if we exceed the maximum consecutive count, cut off the sequence */
399         if (++consecutive >= drcfe->max_sequence)
307         // if we exceed the maximum consecutive count, cut off the sequence
308         if (++consecutive >= m_max_sequence)
400309            curdesc->flags |= OPFLAG_END_SEQUENCE;
401310         if (curdesc->flags & OPFLAG_END_SEQUENCE)
402311            consecutive = 0;
403312
404         /* if this is the end of a sequence, work backwards */
313         // if this is the end of a sequence, work backwards
405314         if (curdesc->flags & OPFLAG_END_SEQUENCE)
406315         {
316            // figure out which registers we *must* generate, assuming at the end all must be
407317            UINT32 reqmask[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff };
408            int backdesc;
409
410            /* figure out which registers we *must* generate, assuming at the end all must be */
411318            if (seqstart != -1)
412               for (backdesc = descnum; backdesc != seqstart - 1; backdesc--)
413                  if (drcfe->desc_array[backdesc] != NULL)
414                     accumulate_required_backwards(drcfe->desc_array[backdesc], reqmask);
319               for (int backdesc = descnum; backdesc != seqstart - 1; backdesc--)
320                  if (m_desc_array[backdesc] != NULL)
321                     accumulate_required_backwards(*m_desc_array[backdesc], reqmask);
415322
416            /* reset the register states */
323            // reset the register states
417324            seqstart = -1;
418325         }
419326
420         /* if we have instructions remaining to be skipped, and this instruction is a branch target */
421         /* belay the skip order */
327         // if we have instructions remaining to be skipped, and this instruction is a branch target
328         // belay the skip order
422329         if (skipsleft > 0 && (curdesc->flags & OPFLAG_IS_BRANCH_TARGET))
423330            skipsleft = 0;
424331
425         /* if we're not getting skipped, add us to the end of the list and clear our array slot */
332         // if we're not getting skipped, add us to the end of the list and clear our array slot
426333         if (skipsleft == 0)
427         {
428            *tailptr = curdesc;
429            tailptr = &curdesc->next;
430            curdesc->prev = prev;
431            prev = curdesc;
432         }
334            m_desc_live_list.append(*curdesc);
433335         else
434            desc_free(drcfe, curdesc);
336            m_desc_allocator.reclaim(*curdesc);
435337
436         /* if the current instruction starts skipping, reset our skip count */
437         /* otherwise, just decrement */
338         // if the current instruction starts skipping, reset our skip count
339         // otherwise, just decrement
438340         if (curdesc->skipslots > 0)
439341            skipsleft = curdesc->skipslots;
440342         else if (skipsleft > 0)
441343            skipsleft--;
442344      }
443345
444   /* zap the array */
445   memset(&drcfe->desc_array[start], 0, (end - start) * sizeof(drcfe->desc_array[0]));
446
447   /* return the final tailptr */
448   return tailptr;
346   // zap the array
347   memset(&m_desc_array[start], 0, (end - start) * sizeof(m_desc_array[0]));
449348}
450349
451350
452/*-------------------------------------------------
453    accumulate_required_backwards - recursively
454    accumulate live register liveness information
455    walking in a backwards direction
456-------------------------------------------------*/
351//-------------------------------------------------
352//  accumulate_required_backwards - recursively
353//  accumulate live register liveness information
354//  walking in a backwards direction
355//-------------------------------------------------
457356
458static void accumulate_required_backwards(opcode_desc *desc, UINT32 *reqmask)
357void drc_frontend::accumulate_required_backwards(opcode_desc &desc, UINT32 *reqmask)
459358{
460   /* recursively handle delay slots */
461   if (desc->delay != NULL)
462      accumulate_required_backwards(desc->delay, reqmask);
359   // recursively handle delay slots
360   if (desc.delay.first() != NULL)
361      accumulate_required_backwards(*desc.delay.first(), reqmask);
463362
464   /* if this is a branch, we have to reset our requests */
465   if (desc->flags & OPFLAG_IS_BRANCH)
363   // if this is a branch, we have to reset our requests
364   if (desc.flags & OPFLAG_IS_BRANCH)
466365      reqmask[0] = reqmask[1] = reqmask[2] = reqmask[3] = 0xffffffff;
467366
468   /* determine the required registers */
469   desc->regreq[0] = desc->regout[0] & reqmask[0];
470   desc->regreq[1] = desc->regout[1] & reqmask[1];
471   desc->regreq[2] = desc->regout[2] & reqmask[2];
472   desc->regreq[3] = desc->regout[3] & reqmask[3];
367   // determine the required registers
368   desc.regreq[0] = desc.regout[0] & reqmask[0];
369   desc.regreq[1] = desc.regout[1] & reqmask[1];
370   desc.regreq[2] = desc.regout[2] & reqmask[2];
371   desc.regreq[3] = desc.regout[3] & reqmask[3];
473372
474   /* any registers modified by this instruction aren't required upstream until referenced */
475   reqmask[0] &= ~desc->regout[0];
476   reqmask[1] &= ~desc->regout[1];
477   reqmask[2] &= ~desc->regout[2];
478   reqmask[3] &= ~desc->regout[3];
373   // any registers modified by this instruction aren't required upstream until referenced
374   reqmask[0] &= ~desc.regout[0];
375   reqmask[1] &= ~desc.regout[1];
376   reqmask[2] &= ~desc.regout[2];
377   reqmask[3] &= ~desc.regout[3];
479378
480   /* any registers required by this instruction now get marked required */
481   reqmask[0] |= desc->regin[0];
482   reqmask[1] |= desc->regin[1];
483   reqmask[2] |= desc->regin[2];
484   reqmask[3] |= desc->regin[3];
379   // any registers required by this instruction now get marked required
380   reqmask[0] |= desc.regin[0];
381   reqmask[1] |= desc.regin[1];
382   reqmask[2] |= desc.regin[2];
383   reqmask[3] |= desc.regin[3];
485384}
486385
487386
488/*-------------------------------------------------
489    release_descriptions - release any
490    descriptions we've allocated back to the
491    free list
492------------------------------------------------*/
387//-------------------------------------------------
388//  release_descriptions - release any
389//  descriptions we've allocated back to the
390//  free list
391//------------------------------------------------
493392
494static void release_descriptions(drcfe_state *drcfe, opcode_desc *desc)
393void drc_frontend::release_descriptions()
495394{
496   /* loop while we still have valid entries */
497   while (desc != NULL)
498   {
499      opcode_desc *freeme = desc;
500
501      /* recursively release delay slots */
502      if (desc->delay != NULL)
503         release_descriptions(drcfe, desc->delay);
504      desc = desc->next;
505      desc_free(drcfe, freeme);
506   }
395   // release all delay slots first
396   for (opcode_desc *curdesc = m_desc_live_list.first(); curdesc != NULL; curdesc = curdesc->next())
397      m_desc_allocator.reclaim_all(curdesc->delay);
398   
399   // reclaim all the descriptors
400   m_desc_allocator.reclaim_all(m_desc_live_list);
507401}
src/emu/cpu/drcfe.h
r9922r9923
44
55    Generic dynamic recompiler frontend structures and utilities.
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138****************************************************************************
1239
1340    Concepts:
r9922r9923
3764#define __DRCFE_H__
3865
3966
40/***************************************************************************
41    CONSTANTS
42***************************************************************************/
67//**************************************************************************
68//  CONSTANTS
69//**************************************************************************
4370
44/* this defines a branch targetpc that is dynamic at runtime */
45#define BRANCH_TARGET_DYNAMIC         (~0)
71// this defines a branch targetpc that is dynamic at runtime
72const offs_t BRANCH_TARGET_DYNAMIC = ~0;
4673
4774
48/* opcode branch flags */
49#define OPFLAG_IS_UNCONDITIONAL_BRANCH   0x00000001      /* instruction is unconditional branch */
50#define OPFLAG_IS_CONDITIONAL_BRANCH   0x00000002      /* instruction is conditional branch */
51#define OPFLAG_IS_BRANCH            (OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_IS_CONDITIONAL_BRANCH)
52#define OPFLAG_IS_BRANCH_TARGET         0x00000004      /* instruction is the target of a branch */
53#define OPFLAG_IN_DELAY_SLOT         0x00000008      /* instruction is in the delay slot of a branch */
54#define OPFLAG_INTRABLOCK_BRANCH      0x00000010      /* instruction branches within the block */
75// opcode branch flags
76const UINT32 OPFLAG_IS_UNCONDITIONAL_BRANCH   = 0x00000001;      // instruction is unconditional branch
77const UINT32 OPFLAG_IS_CONDITIONAL_BRANCH   = 0x00000002;      // instruction is conditional branch
78const UINT32 OPFLAG_IS_BRANCH            = (OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_IS_CONDITIONAL_BRANCH);
79const UINT32 OPFLAG_IS_BRANCH_TARGET      = 0x00000004;      // instruction is the target of a branch
80const UINT32 OPFLAG_IN_DELAY_SLOT         = 0x00000008;      // instruction is in the delay slot of a branch
81const UINT32 OPFLAG_INTRABLOCK_BRANCH      = 0x00000010;      // instruction branches within the block
5582
56/* opcode exception flags */
57#define OPFLAG_CAN_TRIGGER_SW_INT      0x00000020      /* instruction can trigger a software interrupt */
58#define OPFLAG_CAN_EXPOSE_EXTERNAL_INT   0x00000040      /* instruction can expose an external interrupt */
59#define OPFLAG_CAN_CAUSE_EXCEPTION      0x00000080      /* instruction may generate exception */
60#define OPFLAG_WILL_CAUSE_EXCEPTION      0x00000100      /* instruction will generate exception */
61#define OPFLAG_PRIVILEGED            0x00000200      /* instruction is privileged */
83// opcode exception flags
84const UINT32 OPFLAG_CAN_TRIGGER_SW_INT      = 0x00000020;      // instruction can trigger a software interrupt
85const UINT32 OPFLAG_CAN_EXPOSE_EXTERNAL_INT   = 0x00000040;      // instruction can expose an external interrupt
86const UINT32 OPFLAG_CAN_CAUSE_EXCEPTION      = 0x00000080;      // instruction may generate exception
87const UINT32 OPFLAG_WILL_CAUSE_EXCEPTION   = 0x00000100;      // instruction will generate exception
88const UINT32 OPFLAG_PRIVILEGED            = 0x00000200;      // instruction is privileged
6289
63/* opcode virtual->physical translation flags */
64#define OPFLAG_VALIDATE_TLB            0x00000400      /* instruction must validate TLB before execution */
65#define OPFLAG_MODIFIES_TRANSLATION      0x00000800      /* instruction modifies the TLB */
66#define OPFLAG_COMPILER_PAGE_FAULT      0x00001000      /* compiler hit a page fault when parsing */
67#define OPFLAG_COMPILER_UNMAPPED      0x00002000      /* compiler hit unmapped memory when parsing */
90// opcode virtual->physical translation flags
91const UINT32 OPFLAG_VALIDATE_TLB         = 0x00000400;      // instruction must validate TLB before execution
92const UINT32 OPFLAG_MODIFIES_TRANSLATION   = 0x00000800;      // instruction modifies the TLB
93const UINT32 OPFLAG_COMPILER_PAGE_FAULT      = 0x00001000;      // compiler hit a page fault when parsing
94const UINT32 OPFLAG_COMPILER_UNMAPPED      = 0x00002000;      // compiler hit unmapped memory when parsing
6895
69/* opcode flags */
70#define OPFLAG_INVALID_OPCODE         0x00004000      /* instruction is invalid */
71#define OPFLAG_VIRTUAL_NOOP            0x00008000      /* instruction is a virtual no-op */
96// opcode flags
97const UINT32 OPFLAG_INVALID_OPCODE         = 0x00004000;      // instruction is invalid
98const UINT32 OPFLAG_VIRTUAL_NOOP         = 0x00008000;      // instruction is a virtual no-op
7299
73/* opcode sequence flow flags */
74#define OPFLAG_REDISPATCH            0x00010000      /* instruction must redispatch after completion */
75#define OPFLAG_RETURN_TO_START         0x00020000      /* instruction must jump back to the beginning after completion */
76#define OPFLAG_END_SEQUENCE            0x00040000      /* this is the last instruction in a sequence */
77#define OPFLAG_CAN_CHANGE_MODES         0x00080000      /* instruction can change modes */
100// opcode sequence flow flags
101const UINT32 OPFLAG_REDISPATCH            = 0x00010000;      // instruction must redispatch after completion
102const UINT32 OPFLAG_RETURN_TO_START         = 0x00020000;      // instruction must jump back to the beginning after completion
103const UINT32 OPFLAG_END_SEQUENCE         = 0x00040000;      // this is the last instruction in a sequence
104const UINT32 OPFLAG_CAN_CHANGE_MODES      = 0x00080000;      // instruction can change modes
78105
79/* execution semantics */
80#define OPFLAG_READS_MEMORY            0x00100000      /* instruction reads memory */
81#define OPFLAG_WRITES_MEMORY         0x00200000      /* instruction writes memory */
106// execution semantics
107const UINT32 OPFLAG_READS_MEMORY         = 0x00100000;      // instruction reads memory
108const UINT32 OPFLAG_WRITES_MEMORY         = 0x00200000;      // instruction writes memory
82109
83110
84111
85/***************************************************************************
86    TYPE DEFINITIONS
87***************************************************************************/
112//**************************************************************************
113//  TYPE DEFINITIONS
114//**************************************************************************
88115
89/* opaque internal state */
90typedef struct _drcfe_state drcfe_state;
116// description of a given opcode
117struct opcode_desc
118{
119   opcode_desc *next() const { return m_next; }
91120
121   // links to other descriptions
122   opcode_desc *   m_next;               // pointer to next description
123   opcode_desc *   branch;               // pointer back to branch description for delay slots
124   simple_list<opcode_desc> delay;         // pointer to delay slot description
92125
93/* description of a given opcode */
94typedef struct _opcode_desc opcode_desc;
95struct _opcode_desc
96{
97   /* links to other descriptions */
98   opcode_desc *   next;               /* pointer to next description */
99   opcode_desc *   prev;               /* pointer to previous description */
100   opcode_desc *   branch;               /* pointer back to branch description for delay slots */
101   opcode_desc *   delay;               /* pointer to delay slot description */
126   // information about the current PC
127   offs_t         pc;                  // PC of this opcode
128   offs_t         physpc;               // physical PC of this opcode
129   offs_t         targetpc;            // target PC if we are a branch, or BRANCH_TARGET_DYNAMIC
102130
103   /* information about the current PC */
104   offs_t         pc;                  /* PC of this opcode */
105   offs_t         physpc;               /* physical PC of this opcode */
106   offs_t         targetpc;            /* target PC if we are a branch, or BRANCH_TARGET_DYNAMIC */
107
108   /* copy of up to 16 bytes of opcode */
131   // copy of up to 16 bytes of opcode
109132   union
110133   {
111134      UINT8      b[16];
112135      UINT16      w[8];
113136      UINT32      l[4];
114137      UINT64      q[2];
115   } opptr;                        /* pointer to opcode memory */
138   } opptr;                        // pointer to opcode memory
116139
117   /* information about this instruction's execution */
118   UINT8         length;               /* length in bytes of this opcode */
119   UINT8         delayslots;            /* number of delay slots (for branches) */
120   UINT8         skipslots;            /* number of skip slots (for branches) */
121   UINT32         flags;               /* OPFLAG_* opcode flags */
122   UINT32         cycles;               /* number of cycles needed to execute */
140   // information about this instruction's execution
141   UINT8         length;               // length in bytes of this opcode
142   UINT8         delayslots;            // number of delay slots (for branches)
143   UINT8         skipslots;            // number of skip slots (for branches)
144   UINT32         flags;               // OPFLAG_* opcode flags
145   UINT32         cycles;               // number of cycles needed to execute
123146
124   /* register usage information */
125   UINT32         regin[4];            /* input registers */
126   UINT32         regout[4];            /* output registers */
127   UINT32         regreq[4];            /* required output registers */
147   // register usage information
148   UINT32         regin[4];            // input registers
149   UINT32         regout[4];            // output registers
150   UINT32         regreq[4];            // required output registers
128151};
129152
130153
131/* callback function that is used to describe a single opcode */
132typedef int (*drcfe_describe_func)(void *param, opcode_desc *desc, const opcode_desc *prev);
133
134
135/* description of a given opcode */
136typedef struct _drcfe_config drcfe_config;
137struct _drcfe_config
154// DRC frontend state
155class drc_frontend
138156{
139   UINT32         window_start;         /* code window start offset = startpc - window_start */
140   UINT32         window_end;            /* code window end offset = startpc + window_end */
141   UINT32         max_sequence;         /* maximum instructions to include in a sequence */
142   drcfe_describe_func   describe;            /* callback to describe a single instruction */
143};
157public:
158   // construction/destruction
159   drc_frontend(device_t &cpu, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
160   virtual ~drc_frontend();
161   
162   // describe a block
163   const opcode_desc *describe_code(offs_t startpc);
144164
165protected:   
166   // required overrides
167   virtual bool describe(opcode_desc &desc, const opcode_desc *prev) = 0;
145168
169private:
170   // internal helpers
171   opcode_desc *describe_one(offs_t curpc, const opcode_desc *prevdesc);
172   void build_sequence(int start, int end, UINT32 endflag);
173   void accumulate_required_backwards(opcode_desc &desc, UINT32 *reqmask);
174   void release_descriptions();
146175
147/***************************************************************************
148    FUNCTION PROTOTYPES
149***************************************************************************/
176   // configuration parameters
177   UINT32            m_window_start;            // code window start offset = startpc - window_start
178   UINT32            m_window_end;            // code window end offset = startpc + window_end
179   UINT32            m_max_sequence;            // maximum instructions to include in a sequence
150180
151/* initializate the drcfe state */
152drcfe_state *drcfe_init(device_t *cpu, const drcfe_config *config, void *param);
181   // CPU parameters
182   cpu_device &      m_cpudevice;            // CPU device object
183   address_space *      m_program;               // program address space for this CPU
184   offs_t            m_pageshift;            // shift to convert address to a page index
153185
154/* clean up after ourselves */
155void drcfe_exit(drcfe_state *drcfe);
186   // opcode descriptor arrays
187   simple_list<opcode_desc> m_desc_live_list;      // list of live descriptions
188   fixed_allocator<opcode_desc> m_desc_allocator;   // fixed allocator for descriptions
189   opcode_desc **      m_desc_array;            // array of descriptions in PC order
190};
156191
157/* describe a sequence of code that falls within the configured window relative to the specified startpc */
158const opcode_desc *drcfe_describe_code(drcfe_state *drcfe, offs_t startpc);
159192
160
161193#endif /* __DRCFE_H__ */
src/emu/cpu/drcbex64.c
r9922r9923
276276
277277   x86code *            debug_cpu_instruction_hook;/* debugger callback */
278278   x86code *            debug_log_hashjmp;      /* hashjmp debugging */
279   x86code *            debug_log_hashjmp_fail;   /* hashjmp debugging */
279280   x86code *            drcmap_get_value;      /* map lookup helper */
280281   data_accessors         accessors[ADDRESS_SPACES];   /* memory accessors */
281282   address_space *   space[ADDRESS_SPACES];   /* address spaces */
r9922r9923
316317
317318/* private helper functions */
318319static void fixup_label(void *parameter, drccodeptr labelcodeptr);
319static void debug_log_hashjmp(int mode, offs_t pc);
320static void debug_log_hashjmp(offs_t pc, int mode);
321static void debug_log_hashjmp_fail();
320322
321323
322324
r9922r9923
731733   /* get pointers to C functions we need to call */
732734   drcbe->debug_cpu_instruction_hook = (x86code *)debugger_instruction_hook;
733735   if (LOG_HASHJMPS)
736   {
734737      drcbe->debug_log_hashjmp = (x86code *)debug_log_hashjmp;
738      drcbe->debug_log_hashjmp_fail = (x86code *)debug_log_hashjmp_fail;
739   }
735740   drcbe->drcmap_get_value = (x86code *)drcmap_get_value;
736741
737742   /* allocate hash tables */
r9922r9923
29832988    logging of hashjmps
29842989-------------------------------------------------*/
29852990
2986static void debug_log_hashjmp(int mode, offs_t pc)
2991static void debug_log_hashjmp(offs_t pc, int mode)
29872992{
29882993   printf("mode=%d PC=%08X\n", mode, pc);
29892994}
29902995
29912996
2997/*-------------------------------------------------
2998    debug_log_hashjmp - callback to handle
2999    logging of hashjmps
3000-------------------------------------------------*/
29923001
3002static void debug_log_hashjmp_fail()
3003{
3004   printf("  (FAIL)\n");
3005}
3006
3007
3008
29933009/***************************************************************************
29943010    COMPILE-TIME OPCODES
29953011***************************************************************************/
r9922r9923
32493265   }
32503266
32513267   /* in all cases, if there is no code, we return here to generate the exception */
3268   if (LOG_HASHJMPS)
3269      emit_smart_call_m64(drcbe, &dst, &drcbe->debug_log_hashjmp_fail);
3270
32523271   emit_mov_m32_p32(drcbe, &dst, MABS(drcbe, &drcbe->state.exp), &pcp);            // mov   [exp],param
32533272   emit_sub_r64_imm(&dst, REG_RSP, 8);                                       // sub   rsp,8
32543273   emit_call_m64(&dst, MABS(drcbe, exp.value));                              // call  [exp]
src/emu/cpu/rsp/rspfe.c
r9922r9923
1 /***************************************************************************
1/***************************************************************************
22
33    rspfe.c
44
r9922r9923
1414#include "rspfe.h"
1515#include "rsp.h"
1616
17/***************************************************************************
18    FUNCTION PROTOTYPES
19***************************************************************************/
17//**************************************************************************
18//  RSP FRONTEND
19//**************************************************************************
2020
21static int describe_instruction_special(rsp_state *rsp, UINT32 op, opcode_desc *desc);
22static int describe_instruction_regimm(rsp_state *rsp, UINT32 op, opcode_desc *desc);
23static int describe_instruction_cop0(rsp_state *rsp, UINT32 op, opcode_desc *desc);
24static int describe_instruction_cop2(rsp_state *rsp, UINT32 op, opcode_desc *desc);
21//-------------------------------------------------
22//  rsp_frontend - constructor
23//-------------------------------------------------
2524
26/***************************************************************************
27    INSTRUCTION PARSERS
28***************************************************************************/
25rsp_frontend::rsp_frontend(rsp_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence)
26   : drc_frontend(*state.device, window_start, window_end, max_sequence),
27     m_context(state)
28{
29}
2930
30/*-------------------------------------------------
31    describe_instruction - build a description
32    of a single instruction
33-------------------------------------------------*/
3431
35int rspfe_describe(void *param, opcode_desc *desc, const opcode_desc *prev)
32//-------------------------------------------------
33//  describe - build a description of a single
34//  instruction
35//-------------------------------------------------
36
37bool rsp_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
3638{
37   rsp_state *rsp = (rsp_state *)param;
3839   UINT32 op, opswitch;
3940
40   /* fetch the opcode */
41   op = desc->opptr.l[0] = rsp->direct->read_decrypted_dword(desc->physpc | 0x1000);
41   // fetch the opcode
42   op = desc.opptr.l[0] = m_context.direct->read_decrypted_dword(desc.physpc | 0x1000);
4243
43   /* all instructions are 4 bytes and default to a single cycle each */
44   desc->length = 4;
45   desc->cycles = 1;
44   // all instructions are 4 bytes and default to a single cycle each
45   desc.length = 4;
46   desc.cycles = 1;
4647
47   /* parse the instruction */
48   // parse the instruction
4849   opswitch = op >> 26;
4950   switch (opswitch)
5051   {
51      case 0x00:   /* SPECIAL */
52         return describe_instruction_special(rsp, op, desc);
52      case 0x00:   // SPECIAL
53         return describe_special(op, desc);
5354
54      case 0x01:   /* REGIMM */
55         return describe_instruction_regimm(rsp, op, desc);
55      case 0x01:   // REGIMM
56         return describe_regimm(op, desc);
5657
57      case 0x10:   /* COP0 */
58         return describe_instruction_cop0(rsp, op, desc);
58      case 0x10:   // COP0
59         return describe_cop0(op, desc);
5960
60      case 0x12:   /* COP2 */
61         return describe_instruction_cop2(rsp, op, desc);
61      case 0x12:   // COP2
62         return describe_cop2(op, desc);
6263
63      case 0x02:   /* J */
64         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
65         desc->targetpc = ((UIMM26 << 2) & 0x00000fff) | 0x1000;
66         desc->delayslots = 1;
67         return TRUE;
64      case 0x02:   // J
65         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
66         desc.targetpc = ((LIMMVAL << 2) & 0x00000fff) | 0x1000;
67         desc.delayslots = 1;
68         return true;
6869
69      case 0x03:   /* JAL */
70         desc->regout[0] |= REGFLAG_R(31);
71         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
72         desc->targetpc = ((UIMM26 << 2) & 0x00000fff) | 0x1000;
73         desc->delayslots = 1;
74         return TRUE;
70      case 0x03:   // JAL
71         desc.regout[0] |= REGFLAG_R(31);
72         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
73         desc.targetpc = ((LIMMVAL << 2) & 0x00000fff) | 0x1000;
74         desc.delayslots = 1;
75         return true;
7576
76      case 0x04:   /* BEQ */
77      case 0x05:   /* BNE */
77      case 0x04:   // BEQ
78      case 0x05:   // BNE
7879         if ((opswitch == 0x04 || opswitch == 0x14) && RSREG == RTREG)
79            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
80            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
8081         else
8182         {
82            desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
83            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
83            desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
84            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
8485         }
85         desc->targetpc = ((desc->pc + 4 + (SIMM16 << 2)) & 0x00000fff) | 0x1000;
86         desc->delayslots = 1;
87         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
88         return TRUE;
86         desc.targetpc = ((desc.pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
87         desc.delayslots = 1;
88         desc.skipslots = (opswitch & 0x10) ? 1 : 0;
89         return true;
8990
90      case 0x06:   /* BLEZ */
91      case 0x07:   /* BGTZ */
91      case 0x06:   // BLEZ
92      case 0x07:   // BGTZ
9293         if ((opswitch == 0x06 || opswitch == 0x16) && RSREG == 0)
93            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
94            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
9495         else
9596         {
96            desc->regin[0] |= REGFLAG_R(RSREG);
97            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
97            desc.regin[0] |= REGFLAG_R(RSREG);
98            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
9899         }
99         desc->targetpc = ((desc->pc + 4 + (SIMM16 << 2)) & 0x00000fff) | 0x1000;
100         desc->delayslots = 1;
101         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
102         return TRUE;
100         desc.targetpc = ((desc.pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
101         desc.delayslots = 1;
102         desc.skipslots = (opswitch & 0x10) ? 1 : 0;
103         return true;
103104
104      case 0x08:   /* ADDI */
105         desc->regin[0] |= REGFLAG_R(RSREG);
106         desc->regout[0] |= REGFLAG_R(RTREG);
107         return TRUE;
105      case 0x08:   // ADDI
106         desc.regin[0] |= REGFLAG_R(RSREG);
107         desc.regout[0] |= REGFLAG_R(RTREG);
108         return true;
108109
109      case 0x09:   /* ADDIU */
110      case 0x0a:   /* SLTI */
111      case 0x0b:   /* SLTIU */
112      case 0x0c:   /* ANDI */
113      case 0x0d:   /* ORI */
114      case 0x0e:   /* XORI */
115         desc->regin[0] |= REGFLAG_R(RSREG);
116         desc->regout[0] |= REGFLAG_R(RTREG);
117         return TRUE;
110      case 0x09:   // ADDIU
111      case 0x0a:   // SLTI
112      case 0x0b:   // SLTIU
113      case 0x0c:   // ANDI
114      case 0x0d:   // ORI
115      case 0x0e:   // XORI
116         desc.regin[0] |= REGFLAG_R(RSREG);
117         desc.regout[0] |= REGFLAG_R(RTREG);
118         return true;
118119
119      case 0x0f:   /* LUI */
120         desc->regout[0] |= REGFLAG_R(RTREG);
121         return TRUE;
120      case 0x0f:   // LUI
121         desc.regout[0] |= REGFLAG_R(RTREG);
122         return true;
122123
123      case 0x20:   /* LB */
124      case 0x21:   /* LH */
125      case 0x23:   /* LW */
126      case 0x24:   /* LBU */
127      case 0x25:   /* LHU */
128      case 0x27:   /* LWU */
129         desc->regin[0] |= REGFLAG_R(RSREG);
130         desc->regout[0] |= REGFLAG_R(RTREG);
131         desc->flags |= OPFLAG_READS_MEMORY;
132         return TRUE;
124      case 0x20:   // LB
125      case 0x21:   // LH
126      case 0x23:   // LW
127      case 0x24:   // LBU
128      case 0x25:   // LHU
129      case 0x27:   // LWU
130         desc.regin[0] |= REGFLAG_R(RSREG);
131         desc.regout[0] |= REGFLAG_R(RTREG);
132         desc.flags |= OPFLAG_READS_MEMORY;
133         return true;
133134
134      case 0x28:   /* SB */
135      case 0x29:   /* SH */
136      case 0x2b:   /* SW */
137         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
138         desc->flags |= OPFLAG_WRITES_MEMORY;
139         return TRUE;
135      case 0x28:   // SB
136      case 0x29:   // SH
137      case 0x2b:   // SW
138         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
139         desc.flags |= OPFLAG_WRITES_MEMORY;
140         return true;
140141
141      case 0x32:   /* LWC2 */
142         desc->regin[0] |= REGFLAG_R(RSREG);
143         desc->flags |= OPFLAG_READS_MEMORY;
144         return TRUE;
142      case 0x32:   // LWC2
143         desc.regin[0] |= REGFLAG_R(RSREG);
144         desc.flags |= OPFLAG_READS_MEMORY;
145         return true;
145146
146      case 0x3a:   /* SWC2 */
147         desc->regin[0] |= REGFLAG_R(RSREG);
148         desc->flags |= OPFLAG_WRITES_MEMORY;
149         return TRUE;
147      case 0x3a:   // SWC2
148         desc.regin[0] |= REGFLAG_R(RSREG);
149         desc.flags |= OPFLAG_WRITES_MEMORY;
150         return true;
150151   }
151152
152   return FALSE;
153   return false;
153154}
154155
155156
156/*-------------------------------------------------
157    describe_instruction_special - build a
158    description of a single instruction in the
159    'special' group
160-------------------------------------------------*/
157//-------------------------------------------------
158//  describe_special - build a description of a
159//  single instruction in the 'special' group
160//-------------------------------------------------
161161
162static int describe_instruction_special(rsp_state *rsp, UINT32 op, opcode_desc *desc)
162bool rsp_frontend::describe_special(UINT32 op, opcode_desc &desc)
163163{
164164   switch (op & 63)
165165   {
166      case 0x00:   /* SLL */
167      case 0x02:   /* SRL */
168      case 0x03:   /* SRA */
169         desc->regin[0] |= REGFLAG_R(RTREG);
170         desc->regout[0] |= REGFLAG_R(RDREG);
171         return TRUE;
166      case 0x00:   // SLL
167      case 0x02:   // SRL
168      case 0x03:   // SRA
169         desc.regin[0] |= REGFLAG_R(RTREG);
170         desc.regout[0] |= REGFLAG_R(RDREG);
171         return true;
172172
173      case 0x04:   /* SLLV */
174      case 0x06:   /* SRLV */
175      case 0x07:   /* SRAV */
176      case 0x21:   /* ADDU */
177      case 0x23:   /* SUBU */
178      case 0x24:   /* AND */
179      case 0x25:   /* OR */
180      case 0x26:   /* XOR */
181      case 0x27:   /* NOR */
182      case 0x2a:   /* SLT */
183      case 0x2b:   /* SLTU */
184         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
185         desc->regout[0] |= REGFLAG_R(RDREG);
186         return TRUE;
173      case 0x04:   // SLLV
174      case 0x06:   // SRLV
175      case 0x07:   // SRAV
176      case 0x21:   // ADDU
177      case 0x23:   // SUBU
178      case 0x24:   // AND
179      case 0x25:   // OR
180      case 0x26:   // XOR
181      case 0x27:   // NOR
182      case 0x2a:   // SLT
183      case 0x2b:   // SLTU
184         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
185         desc.regout[0] |= REGFLAG_R(RDREG);
186         return true;
187187
188      case 0x20:   /* ADD */
189      case 0x22:   /* SUB */
190         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
191         desc->regout[0] |= REGFLAG_R(RDREG);
192         return TRUE;
188      case 0x20:   // ADD
189      case 0x22:   // SUB
190         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
191         desc.regout[0] |= REGFLAG_R(RDREG);
192         return true;
193193
194      case 0x08:   /* JR */
195         desc->regin[0] |= REGFLAG_R(RSREG);
196         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
197         desc->targetpc = BRANCH_TARGET_DYNAMIC;
198         desc->delayslots = 1;
199         return TRUE;
194      case 0x08:   // JR
195         desc.regin[0] |= REGFLAG_R(RSREG);
196         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
197         desc.targetpc = BRANCH_TARGET_DYNAMIC;
198         desc.delayslots = 1;
199         return true;
200200
201      case 0x09:   /* JALR */
202         desc->regin[0] |= REGFLAG_R(RSREG);
203         desc->regout[0] |= REGFLAG_R(RDREG);
204         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
205         desc->targetpc = BRANCH_TARGET_DYNAMIC;
206         desc->delayslots = 1;
207         return TRUE;
201      case 0x09:   // JALR
202         desc.regin[0] |= REGFLAG_R(RSREG);
203         desc.regout[0] |= REGFLAG_R(RDREG);
204         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
205         desc.targetpc = BRANCH_TARGET_DYNAMIC;
206         desc.delayslots = 1;
207         return true;
208208
209      case 0x0d:   /* BREAK */
210         desc->flags |= OPFLAG_END_SEQUENCE;
211         desc->targetpc = BRANCH_TARGET_DYNAMIC;
212         return TRUE;
209      case 0x0d:   // BREAK
210         desc.flags |= OPFLAG_END_SEQUENCE;
211         desc.targetpc = BRANCH_TARGET_DYNAMIC;
212         return true;
213213   }
214214
215   return FALSE;
215   return false;
216216}
217217
218218
219/*-------------------------------------------------
220    describe_instruction_regimm - build a
221    description of a single instruction in the
222    'regimm' group
223-------------------------------------------------*/
219//-------------------------------------------------
220//  describe_regimm - build a description of a
221//  single instruction in the 'regimm' group
222//-------------------------------------------------
224223
225static int describe_instruction_regimm(rsp_state *rsp, UINT32 op, opcode_desc *desc)
224bool rsp_frontend::describe_regimm(UINT32 op, opcode_desc &desc)
226225{
227226   switch (RTREG)
228227   {
229      case 0x00:   /* BLTZ */
230      case 0x01:   /* BGEZ */
228      case 0x00:   // BLTZ
229      case 0x01:   // BGEZ
231230         if (RTREG == 0x01 && RSREG == 0)
232            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
231            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
233232         else
234233         {
235            desc->regin[0] |= REGFLAG_R(RSREG);
236            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
234            desc.regin[0] |= REGFLAG_R(RSREG);
235            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
237236         }
238         desc->targetpc = ((desc->pc + 4 + (SIMM16 << 2)) & 0x00000fff) | 0x1000;
239         desc->delayslots = 1;
240         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
241         return TRUE;
237         desc.targetpc = ((desc.pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
238         desc.delayslots = 1;
239         desc.skipslots = (RTREG & 0x02) ? 1 : 0;
240         return true;
242241
243      case 0x10:   /* BLTZAL */
244      case 0x11:   /* BGEZAL */
242      case 0x10:   // BLTZAL
243      case 0x11:   // BGEZAL
245244         if (RTREG == 0x11 && RSREG == 0)
246            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
245            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
247246         else
248247         {
249            desc->regin[0] |= REGFLAG_R(RSREG);
250            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
248            desc.regin[0] |= REGFLAG_R(RSREG);
249            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
251250         }
252         desc->regout[0] |= REGFLAG_R(31);
253         desc->targetpc = ((desc->pc + 4 + (SIMM16 << 2)) & 0x00000fff) | 0x1000;
254         desc->delayslots = 1;
255         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
256         return TRUE;
251         desc.regout[0] |= REGFLAG_R(31);
252         desc.targetpc = ((desc.pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
253         desc.delayslots = 1;
254         desc.skipslots = (RTREG & 0x02) ? 1 : 0;
255         return true;
257256   }
258257
259   return FALSE;
258   return false;
260259}
261260
262261
263/*-------------------------------------------------
264    describe_instruction_cop0 - build a
265    description of a single instruction in the
266    COP0 group
267-------------------------------------------------*/
262//-------------------------------------------------
263//  describe_cop0 - build a description of a
264//  single instruction in the COP0 group
265//-------------------------------------------------
268266
269static int describe_instruction_cop0(rsp_state *rsp, UINT32 op, opcode_desc *desc)
267bool rsp_frontend::describe_cop0(UINT32 op, opcode_desc &desc)
270268{
271269   switch (RSREG)
272270   {
273      case 0x00:   /* MFCz */
274         desc->regout[0] |= REGFLAG_R(RTREG);
275         return TRUE;
271      case 0x00:   // MFCz
272         desc.regout[0] |= REGFLAG_R(RTREG);
273         return true;
276274
277      case 0x04:   /* MTCz */
278         desc->regin[0] |= REGFLAG_R(RTREG);
279         return TRUE;
275      case 0x04:   // MTCz
276         desc.regin[0] |= REGFLAG_R(RTREG);
277         return true;
280278   }
281279
282   return FALSE;
280   return false;
283281}
284282
285/*-------------------------------------------------
286    describe_instruction_cop2 - build a
287    description of a single instruction in the
288    COP2 group
289-------------------------------------------------*/
283//-------------------------------------------------
284//  describe_cop2 - build a description of a
285//  single instruction in the COP2 group
286//-------------------------------------------------
290287
291static int describe_instruction_cop2(rsp_state *rsp, UINT32 op, opcode_desc *desc)
288bool rsp_frontend::describe_cop2(UINT32 op, opcode_desc &desc)
292289{
293290   switch (RSREG)
294291   {
295      case 0x00:   /* MFCz */
296      case 0x02:   /* CFCz */
297         desc->regout[0] |= REGFLAG_R(RTREG);
298         return TRUE;
292      case 0x00:   // MFCz
293      case 0x02:   // CFCz
294         desc.regout[0] |= REGFLAG_R(RTREG);
295         return true;
299296
300      case 0x04:   /* MTCz */
301      case 0x06:   /* CTCz */
302         desc->regin[0] |= REGFLAG_R(RTREG);
303         return TRUE;
297      case 0x04:   // MTCz
298      case 0x06:   // CTCz
299         desc.regin[0] |= REGFLAG_R(RTREG);
300         return true;
304301   }
305302
306   return FALSE;
303   return false;
307304}
src/emu/cpu/rsp/rsp.c
r9922r9923
3737   return (rsp_state *)downcast<legacy_cpu_device *>(device)->token();
3838}
3939
40#define SIMM16      ((INT32)(INT16)(op))
41#define UIMM16      ((UINT16)(op))
42#define UIMM26      (op & 0x03ffffff)
43
4044#define JUMP_ABS(addr)         { rsp->nextpc = 0x04001000 | (((addr) << 2) & 0xfff); }
4145#define JUMP_ABS_L(addr,l)      { rsp->nextpc = 0x04001000 | (((addr) << 2) & 0xfff); rsp->r[l] = rsp->pc + 4; }
4246#define JUMP_REL(offset)      { rsp->nextpc = 0x04001000 | ((rsp->pc + ((offset) << 2)) & 0xfff); }
src/emu/cpu/rsp/rspfe.h
r9922r9923
1515#ifndef __RSPFE_H__
1616#define __RSPFE_H__
1717
18#include "rsp.h"
1819#include "cpu/drcfe.h"
1920
2021
21/***************************************************************************
22    CONSTANTS
23***************************************************************************/
22//**************************************************************************
23//  CONSTANTS
24//**************************************************************************
2425
25/* register flags 0 */
26// register flags 0
2627#define REGFLAG_R(n)               (((n) == 0) ? 0 : (1 << (n)))
2728
28/***************************************************************************
29    FUNCTION PROTOTYPES
30***************************************************************************/
3129
32int rspfe_describe(void *param, opcode_desc *desc, const opcode_desc *prev);
3330
31//**************************************************************************
32//  TYPE DEFINITIONS
33//**************************************************************************
34
35class rsp_frontend : public drc_frontend
36{
37public:
38   // construction/destruction
39   rsp_frontend(rsp_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
40
41protected:
42   // required overrides
43   virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
44
45private:
46   // internal helpers
47   bool describe_special(UINT32 op, opcode_desc &desc);
48   bool describe_regimm(UINT32 op, opcode_desc &desc);
49   bool describe_cop0(UINT32 op, opcode_desc &desc);
50   bool describe_cop2(UINT32 op, opcode_desc &desc);
51
52   // internal state
53   rsp_state &m_context;
54};
55
56
57
3458#endif /* __RSPFE_H__ */
src/emu/cpu/rsp/rsp.h
r9922r9923
117117#define IS_FLOAT(o)    (((o) & (1 << 23)) == 0)
118118#define IS_INTEGRAL(o)   (((o) & (1 << 23)) != 0)
119119
120#define SIMM16         ((INT16)(op))
121#define UIMM16         ((UINT16)(op))
122#define UIMM26         (op & 0x03ffffff)
120#define SIMMVAL         ((INT16)op)
121#define UIMMVAL         ((UINT16)op)
122#define LIMMVAL         (op & 0x03ffffff)
123123
124124#define RSP_STATUS_HALT          0x0001
125125#define RSP_STATUS_BROKE         0x0002
src/emu/cpu/rsp/rspdrc.c
r9922r9923
106106   /* core state */
107107   drccache *         cache;                  /* pointer to the DRC code cache */
108108   drcuml_state *      drcuml;                  /* DRC UML generator state */
109   drcfe_state *      drcfe;                  /* pointer to the DRC front-end state */
109   rsp_frontend *      drcfe;                  /* pointer to the DRC front-end state */
110110   UINT32            drcoptions;               /* configurable DRC options */
111111
112112   /* internal stuff */
r9922r9923
151151static void cfunc_cfc2(void *param);
152152static void cfunc_mtc2(void *param);
153153static void cfunc_ctc2(void *param);
154//static void cfunc_swc2(void *param);
155//static void cfunc_lwc2(void *param);
154156static void cfunc_sp_set_status_cb(void *param);
155157
156158static void cfunc_rsp_lbv(void *param);
r9922r9923
516518
517519/*****************************************************************************/
518520
521/* Legacy.  Going forward, this will be transitioned into unrolled opcode decodes. */
522static const int vector_elements_1[16][8] =
523{
524   { 0, 1, 2, 3, 4, 5, 6, 7 },      // none
525   { 0, 1, 2, 3, 4, 5, 6 ,7 },      // ???
526   { 1, 3, 5, 7, 0, 2, 4, 6 },      // 0q
527   { 0, 2, 4, 6, 1, 3, 5, 7 },      // 1q
528   { 1, 2, 3, 5, 6, 7, 0, 4 },      // 0h
529   { 0, 2, 3, 4, 6, 7, 1, 5 },      // 1h
530   { 0, 1, 3, 4, 5, 7, 2, 6 },      // 2h
531   { 0, 1, 2, 4, 5, 6, 3, 7 },      // 3h
532   { 1, 2, 3, 4, 5, 6, 7, 0 },      // 0
533   { 0, 2, 3, 4, 5, 6, 7, 1 },      // 1
534   { 0, 1, 3, 4, 5, 6, 7, 2 },      // 2
535   { 0, 1, 2, 4, 5, 6, 7, 3 },      // 3
536   { 0, 1, 2, 3, 5, 6, 7, 4 },      // 4
537   { 0, 1, 2, 3, 4, 6, 7, 5 },      // 5
538   { 0, 1, 2, 3, 4, 5, 7, 6 },      // 6
539   { 0, 1, 2, 3, 4, 5, 6, 7 },      // 7
540};
541
542/* Legacy.  Going forward, this will be transitioned into unrolled opcode decodes. */
519543static const int vector_elements_2[16][8] =
520544{
521545   { 0, 1, 2, 3, 4, 5, 6, 7 },      // none
r9922r9923
579603
580604static CPU_INIT( rsp )
581605{
582   drcfe_config feconfig =
583   {
584      COMPILE_BACKWARDS_BYTES,   /* code window start offset = startpc - window_start */
585      COMPILE_FORWARDS_BYTES,      /* code window end offset = startpc + window_end */
586      COMPILE_MAX_SEQUENCE,      /* maximum instructions to include in a sequence */
587      rspfe_describe            /* callback to describe a single instruction */
588   };
589606   rsp_state *rsp;
590607   drccache *cache;
591608   UINT32 flags = 0;
r9922r9923
645662   drcuml_symbol_add(rsp->impstate->drcuml, &rsp->impstate->numcycles, sizeof(rsp->impstate->numcycles), "numcycles");
646663
647664   /* initialize the front-end helper */
648   if (SINGLE_INSTRUCTION_MODE)
649   {
650      feconfig.max_sequence = 1;
651   }
652   rsp->impstate->drcfe = drcfe_init(device, &feconfig, rsp);
665   rsp->impstate->drcfe = auto_alloc(device->machine, rsp_frontend(*rsp, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE));
653666
654667   /* compute the register parameters */
655668   for (regnum = 0; regnum < 32; regnum++)
r9922r9923
697710   rsp_state *rsp = get_safe_token(device);
698711
699712   /* clean up the DRC */
700   drcfe_exit(rsp->impstate->drcfe);
713   auto_free(device->machine, rsp->impstate->drcfe);
701714   drcuml_free(rsp->impstate->drcuml);
702715   drccache_free(rsp->impstate->cache);
703716}
r9922r9923
757770
758771   int end = index + 2;
759772
760   if(end > 16) printf("LSV past end\n");
761
762773   for (int i = index; i < end; i++)
763774   {
764775      VREG_B(dest, i) = READ8(rsp, ea);
r9922r9923
790801
791802   int end = index + 4;
792803
793   if(end > 16) printf("LLV past end\n");
794
795804   for (int i = index; i < end; i++)
796805   {
797806      VREG_B(dest, i) = READ8(rsp, ea);
r9922r9923
823832
824833   int end = index + 8;
825834
826   if(end > 16) printf("LDV past end\n");
827
828835   for (int i = index; i < end; i++)
829836   {
830837      VREG_B(dest, i) = READ8(rsp, ea);
r9922r9923
12211228
12221229   int end = index + 2;
12231230
1224   if(end > 16) printf("SSV past end\n");
1225
12261231   for (int i = index; i < end; i++)
12271232   {
12281233      WRITE8(rsp, ea, VREG_B(dest, i));
r9922r9923
12541259
12551260   int end = index + 4;
12561261
1257   if(end > 16) printf("SLV past end\n");
1258
12591262   for (int i = index; i < end; i++)
12601263   {
12611264      WRITE8(rsp, ea, VREG_B(dest, i));
r9922r9923
12871290
12881291   end = index + 8;
12891292
1290   if(end > 16) printf("SDV past end\n");
1291
12921293   for (int i = index; i < end; i++)
12931294   {
12941295      WRITE8(rsp, ea, VREG_B(dest, i));
r9922r9923
34673468   g_profiler.start(PROFILER_DRC_COMPILE);
34683469
34693470   /* get a description of this sequence */
3470   desclist = drcfe_describe_code(rsp->impstate->drcfe, pc);
3471   desclist = rsp->impstate->drcfe->describe_code(pc);
34713472
34723473   /* if we get an error back, flush the cache and try again */
34733474   if (setjmp(errorbuf) != 0)
r9922r9923
34793480   block = drcuml_block_begin(drcuml, 8192, &errorbuf);
34803481
34813482   /* loop until we get through all instruction sequences */
3482   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next)
3483   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next())
34833484   {
34843485      const opcode_desc *curdesc;
34853486      UINT32 nextpc;
r9922r9923
34893490         UML_COMMENT(block, "-------------------------");                  // comment
34903491
34913492      /* determine the last instruction in this sequence */
3492      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next)
3493      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next())
34933494         if (seqlast->flags & OPFLAG_END_SEQUENCE)
34943495            break;
34953496      assert(seqlast != NULL);
r9922r9923
35243525         UML_LABEL(block, seqhead->pc | 0x80000000);                        // label   seqhead->pc
35253526
35263527      /* iterate over instructions in the sequence and compile them */
3527      for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next)
3528      for (curdesc = seqhead; curdesc != seqlast->next(); curdesc = curdesc->next())
35283529         generate_sequence_instruction(rsp, block, &compiler, curdesc);
35293530
35303531      /* if we need to return to the start, do it */
r9922r9923
35393540      generate_update_cycles(rsp, block, &compiler, IMM(nextpc), TRUE);         // <subtract cycles>
35403541
35413542      /* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */
3542      if (seqlast->next == NULL || seqlast->next->pc != nextpc)
3543      if (seqlast->next() == NULL || seqlast->next()->pc != nextpc)
35433544         UML_HASHJMP(block, IMM(0), IMM(nextpc), rsp->impstate->nocode);         // hashjmp <mode>,nextpc,nocode
35443545   }
35453546
r9922r9923
37883789      UML_COMMENT(block, "[Validation for %08X]", seqhead->pc | 0x1000);               // comment
37893790   }
37903791   /* loose verify or single instruction: just compare and fail */
3791   if (!(rsp->impstate->drcoptions & RSPDRC_STRICT_VERIFY) || seqhead->next == NULL)
3792   if (!(rsp->impstate->drcoptions & RSPDRC_STRICT_VERIFY) || seqhead->next() == NULL)
37923793   {
37933794      if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP))
37943795      {
r9922r9923
38063807      void *base = rsp->direct->read_decrypted_ptr(seqhead->physpc | 0x1000);
38073808      UML_LOAD(block, IREG(0), base, IMM(0), DWORD);                        // load    i0,base,0,dword
38083809      sum += seqhead->opptr.l[0];
3809      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
3810      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
38103811         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
38113812         {
38123813            base = rsp->direct->read_decrypted_ptr(curdesc->physpc | 0x1000);
38133814            UML_LOAD(block, IREG(1), base, IMM(0), DWORD);                  // load    i1,base,dword
38143815            UML_ADD(block, IREG(0), IREG(0), IREG(1));                     // add     i0,i0,i1
38153816            sum += curdesc->opptr.l[0];
3816
3817            if (curdesc->delay != NULL && (curdesc == seqlast || (curdesc->next != NULL && curdesc->next->physpc != curdesc->delay->physpc)))
3818            {
3819               base = rsp->direct->read_decrypted_ptr(curdesc->delay->physpc | 0x1000);
3820               UML_LOAD(block, IREG(1), base, IMM(0), DWORD);               // load    i1,base,dword
3821               UML_ADD(block, IREG(0), IREG(0), IREG(1));                  // add     i0,i0,i1
3822               sum += curdesc->delay->opptr.l[0];
3823            }
38243817         }
38253818      UML_CMP(block, IREG(0), IMM(sum));                                 // cmp     i0,sum
38263819      UML_EXHc(block, IF_NE, rsp->impstate->nocode, IMM(epc(seqhead)));         // exne    nocode,seqhead->pc
r9922r9923
39053898   }
39063899
39073900   /* compile the delay slot using temporary compiler state */
3908   assert(desc->delay != NULL);
3909   generate_sequence_instruction(rsp, block, &compiler_temp, desc->delay);      // <next instruction>
3901   assert(desc->delay.first() != NULL);
3902   generate_sequence_instruction(rsp, block, &compiler_temp, desc->delay.first());      // <next instruction>
39103903
39113904   /* update the cycles and jump through the hash table to the target */
39123905   if (desc->targetpc != BRANCH_TARGET_DYNAMIC)
r9922r9923
42174210
42184211      case 0x0f:   /* LUI - MIPS I */
42194212         if (RTREG != 0)
4220            UML_MOV(block, R32(RTREG), IMM(SIMM16 << 16));               // dmov    <rtreg>,SIMM16 << 16
4213            UML_MOV(block, R32(RTREG), IMM(SIMMVAL << 16));               // dmov    <rtreg>,SIMMVAL << 16
42214214         return TRUE;
42224215
42234216      case 0x08:   /* ADDI - MIPS I */
42244217      case 0x09:   /* ADDIU - MIPS I */
42254218         if (RTREG != 0)
42264219         {
4227            UML_ADD(block, R32(RTREG), R32(RSREG), IMM(SIMM16));            // add     i0,<rsreg>,SIMM16,V
4220            UML_ADD(block, R32(RTREG), R32(RSREG), IMM(SIMMVAL));            // add     i0,<rsreg>,SIMMVAL,V
42284221         }
42294222         return TRUE;
42304223
42314224      case 0x0a:   /* SLTI - MIPS I */
42324225         if (RTREG != 0)
42334226         {
4234            UML_CMP(block, R32(RSREG), IMM(SIMM16));                     // dcmp    <rsreg>,SIMM16
4227            UML_CMP(block, R32(RSREG), IMM(SIMMVAL));                     // dcmp    <rsreg>,SIMMVAL
42354228            UML_SETc(block, IF_L, R32(RTREG));                           // dset    <rtreg>,l
42364229         }
42374230         return TRUE;
r9922r9923
42394232      case 0x0b:   /* SLTIU - MIPS I */
42404233         if (RTREG != 0)
42414234         {
4242            UML_CMP(block, R32(RSREG), IMM(SIMM16));                     // dcmp    <rsreg>,SIMM16
4235            UML_CMP(block, R32(RSREG), IMM(SIMMVAL));                     // dcmp    <rsreg>,SIMMVAL
42434236            UML_SETc(block, IF_B, R32(RTREG));                           // dset    <rtreg>,b
42444237         }
42454238         return TRUE;
r9922r9923
42474240
42484241      case 0x0c:   /* ANDI - MIPS I */
42494242         if (RTREG != 0)
4250            UML_AND(block, R32(RTREG), R32(RSREG), IMM(UIMM16));            // dand    <rtreg>,<rsreg>,UIMM16
4243            UML_AND(block, R32(RTREG), R32(RSREG), IMM(UIMMVAL));            // dand    <rtreg>,<rsreg>,UIMMVAL
42514244         return TRUE;
42524245
42534246      case 0x0d:   /* ORI - MIPS I */
42544247         if (RTREG != 0)
4255            UML_OR(block, R32(RTREG), R32(RSREG), IMM(UIMM16));            // dor     <rtreg>,<rsreg>,UIMM16
4248            UML_OR(block, R32(RTREG), R32(RSREG), IMM(UIMMVAL));            // dor     <rtreg>,<rsreg>,UIMMVAL
42564249         return TRUE;
42574250
42584251      case 0x0e:   /* XORI - MIPS I */
42594252         if (RTREG != 0)
4260            UML_XOR(block, R32(RTREG), R32(RSREG), IMM(UIMM16));            // dxor    <rtreg>,<rsreg>,UIMM16
4253            UML_XOR(block, R32(RTREG), R32(RSREG), IMM(UIMMVAL));            // dxor    <rtreg>,<rsreg>,UIMMVAL
42614254         return TRUE;
42624255
42634256      /* ----- memory load operations ----- */
42644257
42654258      case 0x20:   /* LB - MIPS I */
4266         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4259         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
42674260         UML_CALLH(block, rsp->impstate->read8);                           // callh   read8
42684261         if (RTREG != 0)
42694262            UML_SEXT(block, R32(RTREG), IREG(0), BYTE);                  // dsext   <rtreg>,i0,byte
r9922r9923
42724265         return TRUE;
42734266
42744267      case 0x21:   /* LH - MIPS I */
4275         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4268         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
42764269         UML_CALLH(block, rsp->impstate->read16);                        // callh   read16
42774270         if (RTREG != 0)
42784271            UML_SEXT(block, R32(RTREG), IREG(0), WORD);                  // dsext   <rtreg>,i0,word
r9922r9923
42814274         return TRUE;
42824275
42834276      case 0x23:   /* LW - MIPS I */
4284         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4277         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
42854278         UML_CALLH(block, rsp->impstate->read32);                        // callh   read32
42864279         if (RTREG != 0)
42874280            UML_MOV(block, R32(RTREG), IREG(0));
r9922r9923
42904283         return TRUE;
42914284
42924285      case 0x24:   /* LBU - MIPS I */
4293         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4286         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
42944287         UML_CALLH(block, rsp->impstate->read8);                           // callh   read8
42954288         if (RTREG != 0)
42964289            UML_AND(block, R32(RTREG), IREG(0), IMM(0xff));               // dand    <rtreg>,i0,0xff
r9922r9923
42994292         return TRUE;
43004293
43014294      case 0x25:   /* LHU - MIPS I */
4302         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4295         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
43034296         UML_CALLH(block, rsp->impstate->read16);                        // callh   read16
43044297         if (RTREG != 0)
43054298            UML_AND(block, R32(RTREG), IREG(0), IMM(0xffff));               // dand    <rtreg>,i0,0xffff
r9922r9923
43144307      /* ----- memory store operations ----- */
43154308
43164309      case 0x28:   /* SB - MIPS I */
4317         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4310         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
43184311         UML_MOV(block, IREG(1), R32(RTREG));                           // mov     i1,<rtreg>
43194312         UML_CALLH(block, rsp->impstate->write8);                        // callh   write8
43204313         if (!in_delay_slot)
r9922r9923
43224315         return TRUE;
43234316
43244317      case 0x29:   /* SH - MIPS I */
4325         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16));                  // add     i0,<rsreg>,SIMM16
4318         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
43264319         UML_MOV(block, IREG(1), R32(RTREG));                           // mov     i1,<rtreg>
43274320         UML_CALLH(block, rsp->impstate->write16);                        // callh   write16
43284321         if (!in_delay_slot)
r9922r9923
43304323         return TRUE;
43314324
43324325      case 0x2b:   /* SW - MIPS I */
4333         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMM16 ));                  // add     i0,<rsreg>,SIMM16
4326         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
43344327         UML_MOV(block, IREG(1), R32(RTREG));                           // mov     i1,<rtreg>
43354328         UML_CALLH(block, rsp->impstate->write32);                        // callh   write32
43364329         if (!in_delay_slot)
r9922r9923
46694662   rsp_state *rsp = (rsp_state*)param;
46704663   UINT32 op = rsp->impstate->arg0;
46714664   int el = (op >> 7) & 0xf;
4672   VREG_B(RDREG, (el+0) & 0xf) = (RTVAL >> 8) & 0xff;
4673   VREG_B(RDREG, (el+1) & 0xf) = (RTVAL >> 0) & 0xff;
4665   VREG_B(VS1REG, (el+0) & 0xf) = (RTVAL >> 8) & 0xff;
4666   VREG_B(VS1REG, (el+1) & 0xf) = (RTVAL >> 0) & 0xff;
46744667}
46754668
46764669static void cfunc_ctc2(void *param)
src/emu/cpu/powerpc/ppcfe.h
r9922r9923
44
55    Front-end for PowerPC recompiler
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138***************************************************************************/
1239
1340#ifndef __PPCFE_H__
1441#define __PPCFE_H__
1542
43#include "ppccom.h"
1644#include "cpu/drcfe.h"
1745
1846
19/***************************************************************************
20    CONSTANTS
21***************************************************************************/
47//**************************************************************************
48//  MACROS
49//**************************************************************************
2250
23/* register flags 0 */
51// register flags 0
2452#define REGFLAG_R(n)               (1 << (n))
2553#define REGFLAG_RZ(n)               (((n) == 0) ? 0 : REGFLAG_R(n))
2654
27/* register flags 1 */
55// register flags 1
2856#define REGFLAG_FR(n)               (1 << (n))
2957
30/* register flags 2 */
58// register flags 2
3159#define REGFLAG_CR(n)               (0xf0000000 >> (4 * (n)))
3260#define REGFLAG_CR_BIT(n)            (0x80000000 >> (n))
3361
34/* register flags 3 */
62// register flags 3
3563#define REGFLAG_XER_CA               (1 << 0)
3664#define REGFLAG_XER_OV               (1 << 1)
3765#define REGFLAG_XER_SO               (1 << 2)
r9922r9923
4270
4371
4472
45/***************************************************************************
46    FUNCTION PROTOTYPES
47***************************************************************************/
73//**************************************************************************
74//  TYPE DEFINITIONS
75//**************************************************************************
4876
49int ppcfe_describe(void *param, opcode_desc *desc, const opcode_desc *prev);
77class ppc_frontend : public drc_frontend
78{
79public:
80   // construction/destruction
81   ppc_frontend(powerpc_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
5082
83protected:
84   // required overrides
85   virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
86
87private:
88   // inlines
89   UINT32 compute_spr(UINT32 spr) const { return ((spr >> 5) | (spr << 5)) & 0x3ff; }
90   bool is_403_class() const { return (m_context.flavor == PPC_MODEL_403GA || m_context.flavor == PPC_MODEL_403GB || m_context.flavor == PPC_MODEL_403GC || m_context.flavor == PPC_MODEL_403GCX || m_context.flavor == PPC_MODEL_405GP); }
91   bool is_601_class() const { return (m_context.flavor == PPC_MODEL_601); }
92   bool is_602_class() const { return (m_context.flavor == PPC_MODEL_602); }
93   bool is_603_class() const { return (m_context.flavor == PPC_MODEL_603 || m_context.flavor == PPC_MODEL_603E || m_context.flavor == PPC_MODEL_603EV || m_context.flavor == PPC_MODEL_603R); }
94
95   // internal helpers
96   bool describe_13(UINT32 op, opcode_desc &desc, const opcode_desc *prev);
97   bool describe_1f(UINT32 op, opcode_desc &desc, const opcode_desc *prev);
98   bool describe_3b(UINT32 op, opcode_desc &desc, const opcode_desc *prev);
99   bool describe_3f(UINT32 op, opcode_desc &desc, const opcode_desc *prev);
100
101   // internal state
102   powerpc_state &m_context;
103};
104
105
51106#endif /* __PPCFE_H__ */
src/emu/cpu/powerpc/ppcdrc.c
r9922r9923
165165   /* core state */
166166   drccache *         cache;                  /* pointer to the DRC code cache */
167167   drcuml_state *      drcuml;                  /* DRC UML generator state */
168   drcfe_state *      drcfe;                  /* pointer to the DRC front-end state */
168   ppc_frontend *      drcfe;                  /* pointer to the DRC front-end state */
169169   UINT32            drcoptions;               /* configurable DRC options */
170170
171171   /* parameters for subroutines */
r9922r9923
548548
549549static void ppcdrc_init(powerpc_flavor flavor, UINT8 cap, int tb_divisor, legacy_cpu_device *device, device_irq_callback irqcallback)
550550{
551   drcfe_config feconfig =
552   {
553      COMPILE_BACKWARDS_BYTES,   /* code window start offset = startpc - window_start */
554      COMPILE_FORWARDS_BYTES,      /* code window end offset = startpc + window_end */
555      COMPILE_MAX_SEQUENCE,      /* maximum instructions to include in a sequence */
556      ppcfe_describe            /* callback to describe a single instruction */
557   };
558551   powerpc_state *ppc;
559552   drcbe_info beinfo;
560553   UINT32 flags = 0;
r9922r9923
633626   drcuml_symbol_add(ppc->impstate->drcuml, &ppc->impstate->fcmp_cr_table, sizeof(ppc->impstate->fcmp_cr_table), "fcmp_cr_table");
634627
635628   /* initialize the front-end helper */
636   if (SINGLE_INSTRUCTION_MODE)
637      feconfig.max_sequence = 1;
638   ppc->impstate->drcfe = drcfe_init(device, &feconfig, ppc);
629   ppc->impstate->drcfe = auto_alloc(device->machine, ppc_frontend(*ppc, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE));
639630
640631   /* initialize the implementation state tables */
641632   memcpy(ppc->impstate->fpmode, fpmode_source, sizeof(fpmode_source));
r9922r9923
738729   ppccom_exit(ppc);
739730
740731   /* clean up the DRC */
741   drcfe_exit(ppc->impstate->drcfe);
732   auto_free(device->machine, ppc->impstate->drcfe);
742733   drcuml_free(ppc->impstate->drcuml);
743734   drccache_free(ppc->impstate->cache);
744735}
r9922r9923
946937   int override = FALSE;
947938   drcuml_block *block;
948939   jmp_buf errorbuf;
949
940logerror("Compile %08X\n", pc);
950941   g_profiler.start(PROFILER_DRC_COMPILE);
951942
952943   /* get a description of this sequence */
953   desclist = drcfe_describe_code(ppc->impstate->drcfe, pc);
944   desclist = ppc->impstate->drcfe->describe_code(pc);
954945   if (LOG_UML || LOG_NATIVE)
955946      log_opcode_desc(drcuml, desclist, 0);
956947
r9922r9923
962953   block = drcuml_block_begin(drcuml, 4096, &errorbuf);
963954
964955   /* loop until we get through all instruction sequences */
965   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next)
956   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next())
966957   {
967958      const opcode_desc *curdesc;
968959      UINT32 nextpc;
r9922r9923
972963         UML_COMMENT(block, "-------------------------");                        // comment
973964
974965      /* determine the last instruction in this sequence */
975      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next)
966      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next())
976967         if (seqlast->flags & OPFLAG_END_SEQUENCE)
977968            break;
978969      assert(seqlast != NULL);
r9922r9923
1007998         UML_LABEL(block, seqhead->pc | 0x80000000);                              // label   seqhead->pc | 0x80000000
1008999
10091000      /* iterate over instructions in the sequence and compile them */
1010      for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next)
1001      for (curdesc = seqhead; curdesc != seqlast->next(); curdesc = curdesc->next())
10111002         generate_sequence_instruction(ppc, block, &compiler, curdesc);               // <instruction>
10121003
10131004      /* if we need to return to the start, do it */
r9922r9923
10241015      /* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */
10251016      if (seqlast->flags & OPFLAG_CAN_CHANGE_MODES)
10261017         UML_HASHJMP(block, MEM(&ppc->impstate->mode), IMM(nextpc), ppc->impstate->nocode);// hashjmp <mode>,nextpc,nocode
1027      else if (seqlast->next == NULL || seqlast->next->pc != nextpc)
1018      else if (seqlast->next() == NULL || seqlast->next()->pc != nextpc)
10281019         UML_HASHJMP(block, IMM(ppc->impstate->mode), IMM(nextpc), ppc->impstate->nocode);// hashjmp <mode>,nextpc,nocode
10291020   }
10301021
r9922r9923
12331224   drcuml_state *drcuml = ppc->impstate->drcuml;
12341225   drcuml_block *block;
12351226   jmp_buf errorbuf;
1236   int isi, label = 1;
1227   int isi, exit, label = 1;
12371228
12381229   /* if we get an error back, we're screwed */
12391230   if (setjmp(errorbuf) != 0)
r9922r9923
12511242   alloc_handle(drcuml, &ppc->impstate->tlb_mismatch, "tlb_mismatch");
12521243   UML_HANDLE(block, ppc->impstate->tlb_mismatch);                                 // handle  tlb_mismatch
12531244   UML_RECOVER(block, IREG(0), MAPVAR_PC);                                       // recover i0,PC
1245   UML_SHR(block, IREG(1), IREG(0), IMM(12));                                    // shr     i1,i0,12
1246   UML_LOAD(block, IREG(2), (void *)vtlb_table(ppc->vtlb), IREG(1), DWORD);            // load    i2,[vtlb],i1,dword
12541247   UML_MOV(block, MEM(&ppc->param0), IREG(0));                                    // mov     [param0],i0
12551248   UML_MOV(block, MEM(&ppc->param1), IMM(TRANSLATE_FETCH));                        // mov     [param1],TRANSLATE_FETCH
12561249   UML_CALLC(block, ppccom_tlb_fill, ppc);                                       // callc   tlbfill,ppc
1257   UML_SHR(block, IREG(1), IREG(0), IMM(12));                                    // shr     i1,i0,12
12581250   UML_LOAD(block, IREG(1), (void *)vtlb_table(ppc->vtlb), IREG(1), DWORD);            // load    i1,[vtlb],i1,dword
12591251   UML_TEST(block, IREG(1), IMM(VTLB_FETCH_ALLOWED));                              // test    i1,VTLB_FETCH_ALLOWED
12601252   UML_JMPc(block, IF_Z, isi = label++);                                       // jmp     isi,z
1253   UML_CMP(block, IREG(2), IMM(0));                                          // cmp     i2,0
1254   UML_JMPc(block, IF_NZ, exit = label++);                                       // jmp     exit,nz
1255   UML_HASHJMP(block, MEM(&ppc->impstate->mode), IREG(0), ppc->impstate->nocode);         // hashjmp <mode>,i0,nocode
1256   UML_LABEL(block, exit);                                                // exit:
12611257   UML_MOV(block, MEM(&ppc->pc), IREG(0));                                       // mov     <pc>,i0
12621258   save_fast_iregs(ppc, block);                                             // <save fastregs>
12631259   UML_EXIT(block, IMM(EXECUTE_MISSING_CODE));                                    // exit    EXECUTE_MISSING_CODE
r9922r9923
20932089      UML_COMMENT(block, "[Validation for %08X]", seqhead->pc);                     // comment
20942090
20952091   /* loose verify or single instruction: just compare and fail */
2096   if (!(ppc->impstate->drcoptions & PPCDRC_STRICT_VERIFY) || seqhead->next == NULL)
2092   if (!(ppc->impstate->drcoptions & PPCDRC_STRICT_VERIFY) || seqhead->next() == NULL)
20972093   {
20982094      if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP))
20992095      {
r9922r9923
21082104   else
21092105   {
21102106#if 0
2111      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
2107      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
21122108         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
21132109         {
21142110            void *base = ppc->direct->read_decrypted_ptr(seqhead->physpc, ppc->codexor);
r9922r9923
21212117      void *base = ppc->direct->read_decrypted_ptr(seqhead->physpc, ppc->codexor);
21222118      UML_LOAD(block, IREG(0), base, IMM(0), DWORD);                              // load    i0,base,dword
21232119      sum += seqhead->opptr.l[0];
2124      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
2120      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
21252121         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
21262122         {
21272123            base = ppc->direct->read_decrypted_ptr(curdesc->physpc, ppc->codexor);
r9922r9923
42404236      drcuml_log_printf(drcuml, "\nDescriptor list @ %08X\n", desclist->pc);
42414237
42424238   /* output each descriptor */
4243   for ( ; desclist != NULL; desclist = desclist->next)
4239   for ( ; desclist != NULL; desclist = desclist->next())
42444240   {
42454241      char buffer[100];
42464242
r9922r9923
42634259      drcuml_log_printf(drcuml, "\n");
42644260
42654261      /* if we have a delay slot, output it recursively */
4266      if (desclist->delay != NULL)
4267         log_opcode_desc(drcuml, desclist->delay, indent + 1);
4262      if (desclist->delay.first() != NULL)
4263         log_opcode_desc(drcuml, desclist->delay.first(), indent + 1);
42684264
42694265      /* at the end of a sequence add a dividing line */
42704266      if (desclist->flags & OPFLAG_END_SEQUENCE)
src/emu/cpu/powerpc/ppcfe.c
r9922r9923
44
55    Front-end for PowerPC recompiler
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138***************************************************************************/
1239
1340#include "emu.h"
r9922r9923
1542#include "ppccom.h"
1643
1744
18/***************************************************************************
19    MACROS
20***************************************************************************/
45//**************************************************************************
46//  MACROS
47//**************************************************************************
2148
22#define GPR_USED(desc, x)         do { (desc)->regin[0] |= REGFLAG_R(x); } while (0)
23#define GPR_USED_OR_ZERO(desc, x)   do { (desc)->regin[0] |= ((x) == 0 ? 0 : REGFLAG_R(x)); } while (0)
24#define GPR_MODIFIED(desc, x)      do { (desc)->regout[0] |= REGFLAG_R(x); } while (0)
49#define GPR_USED(desc, x)         do { (desc).regin[0] |= REGFLAG_R(x); } while (0)
50#define GPR_USED_OR_ZERO(desc, x)   do { (desc).regin[0] |= ((x) == 0 ? 0 : REGFLAG_R(x)); } while (0)
51#define GPR_MODIFIED(desc, x)      do { (desc).regout[0] |= REGFLAG_R(x); } while (0)
2552
26#define FPR_USED(desc, x)         do { (desc)->regin[1] |= REGFLAG_FR(x); } while (0)
27#define FPR_MODIFIED(desc, x)      do { (desc)->regout[1] |= REGFLAG_FR(x); } while (0)
53#define FPR_USED(desc, x)         do { (desc).regin[1] |= REGFLAG_FR(x); } while (0)
54#define FPR_MODIFIED(desc, x)      do { (desc).regout[1] |= REGFLAG_FR(x); } while (0)
2855
29#define CR_USED(desc, x)         do { (desc)->regin[2] |= REGFLAG_CR(x); } while (0)
30#define CR_BIT_USED(desc, x)      do { (desc)->regin[2] |= REGFLAG_CR_BIT(x); } while (0)
31#define CR_MODIFIED(desc, x)      do { (desc)->regout[2] |= REGFLAG_CR(x); } while (0)
32#define CR_BIT_MODIFIED(desc, x)   do { (desc)->regout[2] |= REGFLAG_CR_BIT(x); } while (0)
56#define CR_USED(desc, x)         do { (desc).regin[2] |= REGFLAG_CR(x); } while (0)
57#define CR_BIT_USED(desc, x)      do { (desc).regin[2] |= REGFLAG_CR_BIT(x); } while (0)
58#define CR_MODIFIED(desc, x)      do { (desc).regout[2] |= REGFLAG_CR(x); } while (0)
59#define CR_BIT_MODIFIED(desc, x)   do { (desc).regout[2] |= REGFLAG_CR_BIT(x); } while (0)
3360
34#define XER_CA_USED(desc)         do { (desc)->regin[3] |= REGFLAG_XER_CA; } while (0)
35#define XER_OV_USED(desc)         do { (desc)->regin[3] |= REGFLAG_XER_OV; } while (0)
36#define XER_SO_USED(desc)         do { (desc)->regin[3] |= REGFLAG_XER_SO; } while (0)
37#define XER_COUNT_USED(desc)      do { (desc)->regin[3] |= REGFLAG_XER_COUNT; } while (0)
38#define XER_CA_MODIFIED(desc)      do { (desc)->regout[3] |= REGFLAG_XER_CA; } while (0)
39#define XER_OV_MODIFIED(desc)      do { (desc)->regout[3] |= REGFLAG_XER_OV; } while (0)
40#define XER_SO_MODIFIED(desc)      do { (desc)->regout[3] |= REGFLAG_XER_SO; } while (0)
41#define XER_COUNT_MODIFIED(desc)   do { (desc)->regout[3] |= REGFLAG_XER_COUNT; } while (0)
61#define XER_CA_USED(desc)         do { (desc).regin[3] |= REGFLAG_XER_CA; } while (0)
62#define XER_OV_USED(desc)         do { (desc).regin[3] |= REGFLAG_XER_OV; } while (0)
63#define XER_SO_USED(desc)         do { (desc).regin[3] |= REGFLAG_XER_SO; } while (0)
64#define XER_COUNT_USED(desc)      do { (desc).regin[3] |= REGFLAG_XER_COUNT; } while (0)
65#define XER_CA_MODIFIED(desc)      do { (desc).regout[3] |= REGFLAG_XER_CA; } while (0)
66#define XER_OV_MODIFIED(desc)      do { (desc).regout[3] |= REGFLAG_XER_OV; } while (0)
67#define XER_SO_MODIFIED(desc)      do { (desc).regout[3] |= REGFLAG_XER_SO; } while (0)
68#define XER_COUNT_MODIFIED(desc)   do { (desc).regout[3] |= REGFLAG_XER_COUNT; } while (0)
4269
43#define CTR_USED(desc)            do { (desc)->regin[3] |= REGFLAG_CTR; } while (0)
44#define CTR_MODIFIED(desc)         do { (desc)->regout[3] |= REGFLAG_CTR; } while (0)
45#define LR_USED(desc)            do { (desc)->regin[3] |= REGFLAG_LR; } while (0)
46#define LR_MODIFIED(desc)         do { (desc)->regout[3] |= REGFLAG_LR; } while (0)
70#define CTR_USED(desc)            do { (desc).regin[3] |= REGFLAG_CTR; } while (0)
71#define CTR_MODIFIED(desc)         do { (desc).regout[3] |= REGFLAG_CTR; } while (0)
72#define LR_USED(desc)            do { (desc).regin[3] |= REGFLAG_LR; } while (0)
73#define LR_MODIFIED(desc)         do { (desc).regout[3] |= REGFLAG_LR; } while (0)
4774
48#define FPSCR_USED(desc, x)         do { (desc)->regin[3] |= REGFLAG_FPSCR(x); } while (0)
49#define FPSCR_MODIFIED(desc, x)      do { (desc)->regout[3] |= REGFLAG_FPSCR(x); } while (0)
75#define FPSCR_USED(desc, x)         do { (desc).regin[3] |= REGFLAG_FPSCR(x); } while (0)
76#define FPSCR_MODIFIED(desc, x)      do { (desc).regout[3] |= REGFLAG_FPSCR(x); } while (0)
5077
5178
5279
53/***************************************************************************
54    FUNCTION PROTOTYPES
55***************************************************************************/
80//**************************************************************************
81//  PPC FRONTEND
82//**************************************************************************
5683
57static int describe_instruction_13(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev);
58static int describe_instruction_1f(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev);
59static int describe_instruction_3b(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev);
60static int describe_instruction_3f(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev);
84//-------------------------------------------------
85//  ppc_frontend - constructor
86//-------------------------------------------------
6187
62
63
64/***************************************************************************
65    INLINE FUNCTIONS
66***************************************************************************/
67
68/*-------------------------------------------------
69    compute_spr - compute the SPR index from the
70    SPR field of an opcode
71-------------------------------------------------*/
72
73INLINE UINT32 compute_spr(UINT32 spr)
88ppc_frontend::ppc_frontend(powerpc_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence)
89   : drc_frontend(*state.device, window_start, window_end, max_sequence),
90     m_context(state)
7491{
75   return ((spr >> 5) | (spr << 5)) & 0x3ff;
7692}
7793
7894
79/*-------------------------------------------------
80    is_403_class - are we one of the 403 variants?
81-------------------------------------------------*/
95//-------------------------------------------------
96//  describe - build a description of a single
97//  instruction
98//-------------------------------------------------
8299
83INLINE int is_403_class(const powerpc_state *ppc)
100bool ppc_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
84101{
85   return (ppc->flavor == PPC_MODEL_403GA || ppc->flavor == PPC_MODEL_403GB || ppc->flavor == PPC_MODEL_403GC || ppc->flavor == PPC_MODEL_403GCX || ppc->flavor == PPC_MODEL_405GP);
86}
87
88
89/*-------------------------------------------------
90    is_601_class - are we one of the 601 variants?
91-------------------------------------------------*/
92
93INLINE int is_601_class(const powerpc_state *ppc)
94{
95   return (ppc->flavor == PPC_MODEL_601);
96}
97
98
99/*-------------------------------------------------
100    is_602_class - are we one of the 602 variants?
101-------------------------------------------------*/
102
103INLINE int is_602_class(const powerpc_state *ppc)
104{
105   return (ppc->flavor == PPC_MODEL_602);
106}
107
108
109/*-------------------------------------------------
110    is_603_class - are we one of the 603 variants?
111-------------------------------------------------*/
112
113INLINE int is_603_class(const powerpc_state *ppc)
114{
115   return (ppc->flavor == PPC_MODEL_603 || ppc->flavor == PPC_MODEL_603E || ppc->flavor == PPC_MODEL_603EV || ppc->flavor == PPC_MODEL_603R);
116}
117
118
119
120/***************************************************************************
121    INSTRUCTION PARSERS
122***************************************************************************/
123
124/*-------------------------------------------------
125    ppcfe_describe - build a description
126    of a single instruction
127-------------------------------------------------*/
128
129int ppcfe_describe(void *param, opcode_desc *desc, const opcode_desc *prev)
130{
131   powerpc_state *ppc = (powerpc_state *)param;
132102   UINT32 op, opswitch;
133103   int regnum;
134104
135   /* compute the physical PC */
136   if (!ppccom_translate_address(ppc, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc->physpc))
105   // compute the physical PC
106   if (!ppccom_translate_address(&m_context, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc.physpc))
137107   {
138      /* uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and */
139      /* mark as needing to validate; otherwise, just end the sequence here */
140      desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE;
141      return TRUE;
108      // uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and
109      // mark as needing to validate; otherwise, just end the sequence here
110      desc.flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE;
111      return true;
142112   }
143113
144   /* fetch the opcode */
145   op = desc->opptr.l[0] = ppc->direct->read_decrypted_dword(desc->physpc, ppc->codexor);
114   // fetch the opcode
115   op = desc.opptr.l[0] = m_context.direct->read_decrypted_dword(desc.physpc, m_context.codexor);
146116
147   /* all instructions are 4 bytes and default to a single cycle each */
148   desc->length = 4;
149   desc->cycles = 1;
117   // all instructions are 4 bytes and default to a single cycle each
118   desc.length = 4;
119   desc.cycles = 1;
150120
151   /* parse the instruction */
121   // parse the instruction
152122   opswitch = op >> 26;
153123   switch (opswitch)
154124   {
155      case 0x02:   /* TDI - 64-bit only */
156      case 0x1e:   /* 0x1e group - 64-bit only */
157      case 0x3a:   /* 0x3a group - 64-bit only */
158      case 0x3e:   /* 0x3e group - 64-bit only */
159         return FALSE;
125      case 0x02:   // TDI - 64-bit only
126      case 0x1e:   // 0x1e group - 64-bit only
127      case 0x3a:   // 0x3a group - 64-bit only
128      case 0x3e:   // 0x3e group - 64-bit only
129         return false;
160130
161      case 0x03:   /* TWI */
131      case 0x03:   // TWI
162132         GPR_USED(desc, G_RA(op));
163         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
164         if (is_603_class(ppc))
165            desc->cycles = 2;   /* 603 */
166         return TRUE;
133         desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
134         if (is_603_class())
135            desc.cycles = 2;   // 603
136         return true;
167137
168      case 0x07:   /* MULLI */
138      case 0x07:   // MULLI
169139         GPR_USED(desc, G_RA(op));
170140         GPR_MODIFIED(desc, G_RD(op));
171         if (is_403_class(ppc))
172            desc->cycles = 4;   /* 4XX */
173         else if (is_601_class(ppc))
174            desc->cycles = 5;   /* 601 */
175         else if (is_603_class(ppc))
176            desc->cycles = 2;   /* 603: 2-3 */
141         if (is_403_class())
142            desc.cycles = 4;   // 4XX
143         else if (is_601_class())
144            desc.cycles = 5;   // 601
145         else if (is_603_class())
146            desc.cycles = 2;   // 603: 2-3
177147         else
178            desc->cycles = 2;   /* ??? */
179         return TRUE;
148            desc.cycles = 2;   // ???
149         return true;
180150
181      case 0x0e:   /* ADDI */
182      case 0x0f:   /* ADDIS */
151      case 0x0e:   // ADDI
152      case 0x0f:   // ADDIS
183153         GPR_USED_OR_ZERO(desc, G_RA(op));
184154         GPR_MODIFIED(desc, G_RD(op));
185         return TRUE;
155         return true;
186156
187      case 0x0a:   /* CMPLI */
188      case 0x0b:   /* CMPI */
157      case 0x0a:   // CMPLI
158      case 0x0b:   // CMPI
189159         GPR_USED(desc, G_RA(op));
190160         XER_SO_USED(desc);
191161         CR_MODIFIED(desc, G_CRFD(op));
192         return TRUE;
162         return true;
193163
194      case 0x08:   /* SUBFIC */
195      case 0x0c:   /* ADDIC */
164      case 0x08:   // SUBFIC
165      case 0x0c:   // ADDIC
196166         GPR_USED(desc, G_RA(op));
197167         GPR_MODIFIED(desc, G_RD(op));
198168         XER_CA_MODIFIED(desc);
199         return TRUE;
169         return true;
200170
201      case 0x0d:   /* ADDIC. */
171      case 0x0d:   // ADDIC.
202172         GPR_USED(desc, G_RA(op));
203173         XER_SO_USED(desc);
204174         GPR_MODIFIED(desc, G_RT(op));
205175         XER_CA_MODIFIED(desc);
206176         CR_MODIFIED(desc, 0);
207         return TRUE;
177         return true;
208178
209      case 0x10:   /* BCx */
179      case 0x10:   // BCx
210180         if (!(G_BO(op) & 0x10))
211181         {
212182            CR_BIT_USED(desc, G_BI(op));
213            /* branch folding */
183            // branch folding
214184            if (prev == NULL || prev->regout[2] == 0)
215               desc->cycles = 0;
185               desc.cycles = 0;
216186         }
217187         if (!(G_BO(op) & 0x04))
218188         {
r9922r9923
222192         if (op & M_LK)
223193            LR_MODIFIED(desc);
224194         if ((G_BO(op) & 0x14) == 0x14)
225            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
195            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
226196         else
227            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
228         desc->targetpc = (INT16)(G_BD(op) << 2) + ((op & M_AA) ? 0 : desc->pc);
229         if (desc->targetpc == desc->pc && desc->cycles == 0)
230            desc->cycles = 1;
231         return TRUE;
197            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
198         desc.targetpc = (INT16)(G_BD(op) << 2) + ((op & M_AA) ? 0 : desc.pc);
199         if (desc.targetpc == desc.pc && desc.cycles == 0)
200            desc.cycles = 1;
201         return true;
232202
233      case 0x11:   /* SC */
234         if (!(ppc->cap & (PPCCAP_OEA | PPCCAP_4XX)))
235            return FALSE;
236         desc->flags |= OPFLAG_WILL_CAUSE_EXCEPTION;
237         if (is_601_class(ppc))
238            desc->cycles = 16;   /* 601 */
239         else if (is_603_class(ppc))
240            desc->cycles = 3;   /* 603 */
203      case 0x11:   // SC
204         if (!(m_context.cap & (PPCCAP_OEA | PPCCAP_4XX)))
205            return false;
206         desc.flags |= OPFLAG_WILL_CAUSE_EXCEPTION;
207         if (is_601_class())
208            desc.cycles = 16;   // 601
209         else if (is_603_class())
210            desc.cycles = 3;   // 603
241211         else
242            desc->cycles = 3;   /* ??? */
243         return TRUE;
212            desc.cycles = 3;   // ???
213         return true;
244214
245      case 0x12:   /* Bx */
215      case 0x12:   // Bx
246216         if (op & M_LK)
247217            LR_MODIFIED(desc);
248         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
249         desc->targetpc = ((INT32)(G_LI(op) << 8) >> 6) + ((op & M_AA) ? 0 : desc->pc);
250         /* branch folding */
251         if (desc->targetpc != desc->pc)
252            desc->cycles = 0;
253         return TRUE;
218         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
219         desc.targetpc = ((INT32)(G_LI(op) << 8) >> 6) + ((op & M_AA) ? 0 : desc.pc);
220         // branch folding
221         if (desc.targetpc != desc.pc)
222            desc.cycles = 0;
223         return true;
254224
255      case 0x13:   /* 0x13 group */
256         return describe_instruction_13(ppc, op, desc, prev);
225      case 0x13:   // 0x13 group
226         return describe_13(op, desc, prev);
257227
258      case 0x14:   /* RLWIMIx */
228      case 0x14:   // RLWIMIx
259229         GPR_USED(desc, G_RS(op));
260230         GPR_USED(desc, G_RA(op));
261231         GPR_MODIFIED(desc, G_RA(op));
r9922r9923
264234            XER_SO_USED(desc);
265235            CR_MODIFIED(desc, 0);
266236         }
267         return TRUE;
237         return true;
268238
269      case 0x15:   /* RLWINMx */
239      case 0x15:   // RLWINMx
270240         GPR_USED(desc, G_RS(op));
271241         GPR_MODIFIED(desc, G_RA(op));
272242         if (op & M_RC)
r9922r9923
274244            XER_SO_USED(desc);
275245            CR_MODIFIED(desc, 0);
276246         }
277         return TRUE;
247         return true;
278248
279      case 0x17:   /* RLWNMx */
249      case 0x17:   // RLWNMx
280250         GPR_USED(desc, G_RS(op));
281251         GPR_USED(desc, G_RB(op));
282252         GPR_MODIFIED(desc, G_RA(op));
r9922r9923
285255            XER_SO_USED(desc);
286256            CR_MODIFIED(desc, 0);
287257         }
288         return TRUE;
258         return true;
289259
290      case 0x18:   /* ORI */
291      case 0x19:   /* ORIS */
292      case 0x1a:   /* XORI */
293      case 0x1b:   /* XORIS */
260      case 0x18:   // ORI
261      case 0x19:   // ORIS
262      case 0x1a:   // XORI
263      case 0x1b:   // XORIS
294264         GPR_USED(desc, G_RS(op));
295265         GPR_MODIFIED(desc, G_RA(op));
296         return TRUE;
266         return true;
297267
298      case 0x1c:   /* ANDI. */
299      case 0x1d:   /* ANDIS. */
268      case 0x1c:   // ANDI.
269      case 0x1d:   // ANDIS.
300270         GPR_USED(desc, G_RS(op));
301271         XER_SO_USED(desc);
302272         GPR_MODIFIED(desc, G_RA(op));
303273         CR_MODIFIED(desc, 0);
304         return TRUE;
274         return true;
305275
306      case 0x1f:   /* 0x1f group */
307         return describe_instruction_1f(ppc, op, desc, prev);
276      case 0x1f:   // 0x1f group
277         return describe_1f(op, desc, prev);
308278
309      case 0x20:   /* LWZ */
310      case 0x22:   /* LBZ */
311      case 0x28:   /* LHZ */
312      case 0x2a:   /* LHA */
279      case 0x20:   // LWZ
280      case 0x22:   // LBZ
281      case 0x28:   // LHZ
282      case 0x2a:   // LHA
313283         GPR_USED_OR_ZERO(desc, G_RA(op));
314284         GPR_MODIFIED(desc, G_RD(op));
315         desc->flags |= OPFLAG_READS_MEMORY;
316         return TRUE;
285         desc.flags |= OPFLAG_READS_MEMORY;
286         return true;
317287
318      case 0x21:   /* LWZU */
319      case 0x23:   /* LBZU */
320      case 0x29:   /* LHZU */
321      case 0x2b:   /* LHAU */
288      case 0x21:   // LWZU
289      case 0x23:   // LBZU
290      case 0x29:   // LHZU
291      case 0x2b:   // LHAU
322292         if (G_RA(op) == 0 || G_RA(op) == G_RD(op))
323            return FALSE;
293            return false;
324294         GPR_USED(desc, G_RA(op));
325295         GPR_MODIFIED(desc, G_RD(op));
326296         GPR_MODIFIED(desc, G_RA(op));
327         desc->flags |= OPFLAG_READS_MEMORY;
328         return TRUE;
297         desc.flags |= OPFLAG_READS_MEMORY;
298         return true;
329299
330      case 0x24:   /* STW */
331      case 0x26:   /* STB */
332      case 0x2c:   /* STH */
300      case 0x24:   // STW
301      case 0x26:   // STB
302      case 0x2c:   // STH
333303         GPR_USED_OR_ZERO(desc, G_RA(op));
334304         GPR_USED(desc, G_RS(op));
335         desc->flags |= OPFLAG_WRITES_MEMORY;
336         return TRUE;
305         desc.flags |= OPFLAG_WRITES_MEMORY;
306         return true;
337307
338      case 0x25:   /* STWU */
339      case 0x27:   /* STBU */
340      case 0x2d:   /* STHU */
308      case 0x25:   // STWU
309      case 0x27:   // STBU
310      case 0x2d:   // STHU
341311         if (G_RA(op) == 0)
342            return FALSE;
312            return false;
343313         GPR_USED(desc, G_RA(op));
344314         GPR_USED(desc, G_RS(op));
345315         GPR_MODIFIED(desc, G_RA(op));
346         desc->flags |= OPFLAG_WRITES_MEMORY;
347         return TRUE;
316         desc.flags |= OPFLAG_WRITES_MEMORY;
317         return true;
348318
349      case 0x2e:   /* LMW */
319      case 0x2e:   // LMW
350320         GPR_USED_OR_ZERO(desc, G_RA(op));
351321         for (regnum = G_RD(op); regnum < 32; regnum++)
352322            GPR_MODIFIED(desc, regnum);
353         desc->flags |= OPFLAG_READS_MEMORY;
354         desc->cycles = 32 - G_RD(op);
355         return TRUE;
323         desc.flags |= OPFLAG_READS_MEMORY;
324         desc.cycles = 32 - G_RD(op);
325         return true;
356326
357      case 0x2f:   /* STMW */
327      case 0x2f:   // STMW
358328         GPR_USED_OR_ZERO(desc, G_RA(op));
359329         for (regnum = G_RS(op); regnum < 32; regnum++)
360330            GPR_USED(desc, regnum);
361         desc->flags |= OPFLAG_WRITES_MEMORY;
362         desc->cycles = 32 - G_RS(op);
363         return TRUE;
331         desc.flags |= OPFLAG_WRITES_MEMORY;
332         desc.cycles = 32 - G_RS(op);
333         return true;
364334
365      case 0x30:   /* LFS */
366      case 0x32:   /* LFD */
367         if (!(ppc->cap & PPCCAP_FPU))
368            return FALSE;
335      case 0x30:   // LFS
336      case 0x32:   // LFD
337         if (!(m_context.cap & PPCCAP_FPU))
338            return false;
369339         GPR_USED_OR_ZERO(desc, G_RA(op));
370340         FPR_MODIFIED(desc, G_RD(op));
371         desc->flags |= OPFLAG_READS_MEMORY;
372         return TRUE;
341         desc.flags |= OPFLAG_READS_MEMORY;
342         return true;
373343
374      case 0x31:   /* LFSU */
375      case 0x33:   /* LFDU */
376         if (!(ppc->cap & PPCCAP_FPU))
377            return FALSE;
344      case 0x31:   // LFSU
345      case 0x33:   // LFDU
346         if (!(m_context.cap & PPCCAP_FPU))
347            return false;
378348         if (G_RA(op) == 0)
379            return FALSE;
349            return false;
380350         GPR_USED(desc, G_RA(op));
381351         GPR_MODIFIED(desc, G_RA(op));
382352         FPR_MODIFIED(desc, G_RD(op));
383         desc->flags |= OPFLAG_READS_MEMORY;
384         return TRUE;
353         desc.flags |= OPFLAG_READS_MEMORY;
354         return true;
385355
386      case 0x34:   /* STFS */
387      case 0x36:   /* STFD */
388         if (!(ppc->cap & PPCCAP_FPU))
389            return FALSE;
356      case 0x34:   // STFS
357      case 0x36:   // STFD
358         if (!(m_context.cap & PPCCAP_FPU))
359            return false;
390360         GPR_USED_OR_ZERO(desc, G_RA(op));
391361         FPR_USED(desc, G_RS(op));
392         desc->flags |= OPFLAG_WRITES_MEMORY;
393         return TRUE;
362         desc.flags |= OPFLAG_WRITES_MEMORY;
363         return true;
394364
395      case 0x35:   /* STFSU */
396      case 0x37:   /* STFDU */
397         if (!(ppc->cap & PPCCAP_FPU))
398            return FALSE;
365      case 0x35:   // STFSU
366      case 0x37:   // STFDU
367         if (!(m_context.cap & PPCCAP_FPU))
368            return false;
399369         if (G_RA(op) == 0)
400            return FALSE;
370            return false;
401371         GPR_USED(desc, G_RA(op));
402372         GPR_MODIFIED(desc, G_RA(op));
403373         FPR_USED(desc, G_RS(op));
404         desc->flags |= OPFLAG_WRITES_MEMORY;
405         return TRUE;
374         desc.flags |= OPFLAG_WRITES_MEMORY;
375         return true;
406376
407      case 0x3b:   /* 0x3b group */
408         return describe_instruction_3b(ppc, op, desc, prev);
377      case 0x3b:   // 0x3b group
378         return describe_3b(op, desc, prev);
409379
410      case 0x3f:   /* 0x3f group */
411         return describe_instruction_3f(ppc, op, desc, prev);
380      case 0x3f:   // 0x3f group
381         return describe_3f(op, desc, prev);
412382   }
413383
414   return FALSE;
384   return false;
415385}
416386
417387
r9922r9923
421391    0x13 group
422392-------------------------------------------------*/
423393
424static int describe_instruction_13(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev)
394bool ppc_frontend::describe_13(UINT32 op, opcode_desc &desc, const opcode_desc *prev)
425395{
426396   UINT32 opswitch = (op >> 1) & 0x3ff;
427397
428398   switch (opswitch)
429399   {
430      case 0x000:   /* MTCRF */
400      case 0x000:   // MTCRF
431401         CR_USED(desc, G_CRFS(op));
432402         CR_MODIFIED(desc, G_CRFD(op));
433         /* CR logical folding */
403         // CR logical folding
434404         if (prev == NULL || prev->regout[2] == 0)
435            desc->cycles = 0;
436         return TRUE;
405            desc.cycles = 0;
406         return true;
437407
438      case 0x010:   /* BCLRx */
408      case 0x010:   // BCLRx
439409         LR_USED(desc);
440410         if (!(G_BO(op) & 0x10))
441411            CR_BIT_USED(desc, G_BI(op));
r9922r9923
447417         if (op & M_LK)
448418            LR_MODIFIED(desc);
449419         if ((G_BO(op) & 0x14) == 0x14)
450            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
420            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
451421         else
452            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
453         desc->targetpc = BRANCH_TARGET_DYNAMIC;
454         return TRUE;
422            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
423         desc.targetpc = BRANCH_TARGET_DYNAMIC;
424         return true;
455425
456      case 0x021:   /* CRNOR */
457      case 0x081:   /* CRANDC */
458      case 0x0c1:   /* CRXOR */
459      case 0x0e1:   /* CRNAND */
460      case 0x101:   /* CRAND */
461      case 0x121:   /* CREQV */
462      case 0x1a1:   /* CRORC */
463      case 0x1c1:   /* CROR */
426      case 0x021:   // CRNOR
427      case 0x081:   // CRANDC
428      case 0x0c1:   // CRXOR
429      case 0x0e1:   // CRNAND
430      case 0x101:   // CRAND
431      case 0x121:   // CREQV
432      case 0x1a1:   // CRORC
433      case 0x1c1:   // CROR
464434         CR_BIT_USED(desc, G_CRBA(op));
465435         CR_BIT_USED(desc, G_CRBB(op));
466436         CR_BIT_MODIFIED(desc, G_CRBD(op));
467         /* CR logical folding */
437         // CR logical folding
468438         if (prev == NULL || prev->regout[2] == 0)
469            desc->cycles = 0;
470         return TRUE;
439            desc.cycles = 0;
440         return true;
471441
472      case 0x032:   /* RFI */
473         if (!(ppc->cap & (PPCCAP_OEA | PPCCAP_4XX)))
474            return FALSE;
475         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_CAUSE_EXCEPTION;
476         desc->targetpc = BRANCH_TARGET_DYNAMIC;
477         if (is_601_class(ppc))
478            desc->cycles = 13;   /* 601 */
479         else if (is_603_class(ppc))
480            desc->cycles = 3;   /* 603 */
442      case 0x032:   // RFI
443         if (!(m_context.cap & (PPCCAP_OEA | PPCCAP_4XX)))
444            return false;
445         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_CAUSE_EXCEPTION;
446         desc.targetpc = BRANCH_TARGET_DYNAMIC;
447         if (is_601_class())
448            desc.cycles = 13;   // 601
449         else if (is_603_class())
450            desc.cycles = 3;   // 603
481451         else
482            desc->cycles = 3;   /* ??? */
483         return TRUE;
452            desc.cycles = 3;   // ???
453         return true;
484454
485      case 0x033:   /* RFCI */
486         if (!(ppc->cap & PPCCAP_4XX))
487            return FALSE;
488         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_CAUSE_EXCEPTION;
489         desc->targetpc = BRANCH_TARGET_DYNAMIC;
490         return TRUE;
455      case 0x033:   // RFCI
456         if (!(m_context.cap & PPCCAP_4XX))
457            return false;
458         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_CAUSE_EXCEPTION;
459         desc.targetpc = BRANCH_TARGET_DYNAMIC;
460         return true;
491461
492      case 0x096:   /* ISYNC */
493         if (!(ppc->cap & (PPCCAP_VEA | PPCCAP_4XX)))
494            return FALSE;
495         if (is_601_class(ppc))
496            desc->cycles = 6;   /* 601 */
497         return TRUE;
462      case 0x096:   // ISYNC
463         if (!(m_context.cap & (PPCCAP_VEA | PPCCAP_4XX)))
464            return false;
465         if (is_601_class())
466            desc.cycles = 6;   // 601
467         return true;
498468
499      case 0x210:   /* BCCTRx */
469      case 0x210:   // BCCTRx
500470         CTR_USED(desc);
501471         if (!(G_BO(op) & 0x10))
502472            CR_BIT_USED(desc, G_BI(op));
503473         if (!(G_BO(op) & 0x04))
504            return FALSE;
474            return false;
505475         if (op & M_LK)
506476            LR_MODIFIED(desc);
507477         if ((G_BO(op) & 0x14) == 0x14)
508            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
478            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
509479         else
510            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
511         desc->targetpc = BRANCH_TARGET_DYNAMIC;
512         return TRUE;
480            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
481         desc.targetpc = BRANCH_TARGET_DYNAMIC;
482         return true;
513483   }
514484
515   return FALSE;
485   return false;
516486}
517487
518488
r9922r9923
522492    0x1f group
523493-------------------------------------------------*/
524494
525static int describe_instruction_1f(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev)
495bool ppc_frontend::describe_1f(UINT32 op, opcode_desc &desc, const opcode_desc *prev)
526496{
527497   UINT32 opswitch = (op >> 1) & 0x3ff;
528498   int spr, regnum;
529499
530500   switch (opswitch)
531501   {
532      case 0x009:   /* MULHDUx - 64-bit only */
533      case 0x015:   /* LDX - 64-bit only */
534      case 0x01b:   /* SLDx - 64-bit only */
535      case 0x035:   /* LDUX - 64-bit only */
536      case 0x03a:   /* CNTLZDx - 64-bit only */
537      case 0x044:   /* TD - 64-bit only */
538      case 0x049:   /* MULHDx - 64-bit only */
539      case 0x054:   /* LDARX - 64-bit only */
540      case 0x095:   /* STDX - 64-bit only */
541      case 0x0b5:   /* STDUX - 64-bit only */
542      case 0x0d6:   /* STDCX. - 64-bit only */
543      case 0x0e9:   /* MULLD - 64-bit only */
544      case 0x2e9:   /* MULLDO - 64-bit only */
545      case 0x155:   /* LWAX - 64-bit only */
546      case 0x175:   /* LWAUX - 64-bit only */
547      case 0x33a: /* SRADIx - 64-bit only */
548      case 0x33b: /* SRADIx - 64-bit only */
549      case 0x1b2:   /* SLBIE - 64-bit only */
550      case 0x1c9:   /* DIVDUx - 64-bit only */
551      case 0x3c9:   /* DIVDUOx - 64-bit only */
552      case 0x1e9:   /* DIVDx - 64-bit only */
553      case 0x3e9:   /* DIVDOx - 64-bit only */
554      case 0x1f2:   /* SLBIA - 64-bit only */
555      case 0x21b:   /* SRDx - 64-bit only */
556      case 0x31a:   /* SRADx - 64-bit only */
557      case 0x3da:   /* EXTSW - 64-bit only */
558         return FALSE;
502      case 0x009:   // MULHDUx - 64-bit only
503      case 0x015:   // LDX - 64-bit only
504      case 0x01b:   // SLDx - 64-bit only
505      case 0x035:   // LDUX - 64-bit only
506      case 0x03a:   // CNTLZDx - 64-bit only
507      case 0x044:   // TD - 64-bit only
508      case 0x049:   // MULHDx - 64-bit only
509      case 0x054:   // LDARX - 64-bit only
510      case 0x095:   // STDX - 64-bit only
511      case 0x0b5:   // STDUX - 64-bit only
512      case 0x0d6:   // STDCX. - 64-bit only
513      case 0x0e9:   // MULLD - 64-bit only
514      case 0x2e9:   // MULLDO - 64-bit only
515      case 0x155:   // LWAX - 64-bit only
516      case 0x175:   // LWAUX - 64-bit only
517      case 0x33a: // SRADIx - 64-bit only
518      case 0x33b: // SRADIx - 64-bit only
519      case 0x1b2:   // SLBIE - 64-bit only
520      case 0x1c9:   // DIVDUx - 64-bit only
521      case 0x3c9:   // DIVDUOx - 64-bit only
522      case 0x1e9:   // DIVDx - 64-bit only
523      case 0x3e9:   // DIVDOx - 64-bit only
524      case 0x1f2:   // SLBIA - 64-bit only
525      case 0x21b:   // SRDx - 64-bit only
526      case 0x31a:   // SRADx - 64-bit only
527      case 0x3da:   // EXTSW - 64-bit only
528         return false;
559529
560      case 0x000:   /* CMP */
561      case 0x020:   /* CMPL */
530      case 0x000:   // CMP
531      case 0x020:   // CMPL
562532         GPR_USED(desc, G_RA(op));
563533         GPR_USED(desc, G_RB(op));
564534         XER_SO_USED(desc);
565535         CR_MODIFIED(desc, G_CRFD(op));
566         return TRUE;
536         return true;
567537
568      case 0x004:   /* TW */
538      case 0x004:   // TW
569539         GPR_USED(desc, G_RA(op));
570540         GPR_USED(desc, G_RB(op));
571         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
572         if (is_603_class(ppc))
573            desc->cycles = 2;   /* 603 */
574         return TRUE;
541         desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
542         if (is_603_class())
543            desc.cycles = 2;   // 603
544         return true;
575545
576      case 0x008:   /* SUBFCx */
577      case 0x00a:   /* ADDCx */
546      case 0x008:   // SUBFCx
547      case 0x00a:   // ADDCx
578548         GPR_USED(desc, G_RA(op));
579549         GPR_USED(desc, G_RB(op));
580550         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
584554            XER_SO_USED(desc);
585555            CR_MODIFIED(desc, 0);
586556         }
587         return TRUE;
557         return true;
588558
589      case 0x088:   /* SUBFEx */
590      case 0x08a:   /* ADDEx */
559      case 0x088:   // SUBFEx
560      case 0x08a:   // ADDEx
591561         GPR_USED(desc, G_RA(op));
592562         GPR_USED(desc, G_RB(op));
593563         XER_CA_USED(desc);
r9922r9923
598568            XER_SO_USED(desc);
599569            CR_MODIFIED(desc, 0);
600570         }
601         return TRUE;
571         return true;
602572
603      case 0x0c8:   /* SUBFZEx */
604      case 0x0ca:   /* ADDZEx */
605      case 0x0e8:   /* SUBFMEx */
606      case 0x0ea:   /* ADDMEx */
573      case 0x0c8:   // SUBFZEx
574      case 0x0ca:   // ADDZEx
575      case 0x0e8:   // SUBFMEx
576      case 0x0ea:   // ADDMEx
607577         GPR_USED(desc, G_RA(op));
608578         XER_CA_USED(desc);
609579         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
613583            XER_SO_USED(desc);
614584            CR_MODIFIED(desc, 0);
615585         }
616         return TRUE;
586         return true;
617587
618      case 0x00b:   /* MULHWUx */
619      case 0x04b:   /* MULHWx */
620      case 0x0eb:   /* MULLWx */
588      case 0x00b:   // MULHWUx
589      case 0x04b:   // MULHWx
590      case 0x0eb:   // MULLWx
621591         GPR_USED(desc, G_RA(op));
622592         GPR_USED(desc, G_RB(op));
623593         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
626596            XER_SO_USED(desc);
627597            CR_MODIFIED(desc, 0);
628598         }
629         if (is_403_class(ppc))
630            desc->cycles = 4;   /* 4XX */
631         else if (is_601_class(ppc))
632            desc->cycles = 5;   /* 601: 5/9/10 */
633         else if (is_603_class(ppc))
634            desc->cycles = 2;   /* 603: 2,3,4,5,6 */
599         if (is_403_class())
600            desc.cycles = 4;   // 4XX
601         else if (is_601_class())
602            desc.cycles = 5;   // 601: 5/9/10
603         else if (is_603_class())
604            desc.cycles = 2;   // 603: 2,3,4,5,6
635605         else
636            desc->cycles = 2;   /* ??? */
637         return TRUE;
606            desc.cycles = 2;   // ???
607         return true;
638608
639      case 0x1cb:   /* DIVWUx */
640      case 0x1eb:   /* DIVWx */
609      case 0x1cb:   // DIVWUx
610      case 0x1eb:   // DIVWx
641611         GPR_USED(desc, G_RA(op));
642612         GPR_USED(desc, G_RB(op));
643613         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
646616            XER_SO_USED(desc);
647617            CR_MODIFIED(desc, 0);
648618         }
649         if (is_403_class(ppc))
650            desc->cycles = 33;   /* 4XX */
651         else if (is_601_class(ppc))
652            desc->cycles = 36;   /* 601 */
653         else if (is_603_class(ppc))
654            desc->cycles = 37;   /* 603 */
619         if (is_403_class())
620            desc.cycles = 33;   // 4XX
621         else if (is_601_class())
622            desc.cycles = 36;   // 601
623         else if (is_603_class())
624            desc.cycles = 37;   // 603
655625         else
656            desc->cycles = 33;   /* ??? */
657         return TRUE;
626            desc.cycles = 33;   // ???
627         return true;
658628
659      case 0x028:   /* SUBFx */
660      case 0x10a:   /* ADDx */
629      case 0x028:   // SUBFx
630      case 0x10a:   // ADDx
661631         GPR_USED(desc, G_RA(op));
662632         GPR_USED(desc, G_RB(op));
663633         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
666636            XER_SO_USED(desc);
667637            CR_MODIFIED(desc, 0);
668638         }
669         return TRUE;
639         return true;
670640
671      case 0x208:   /* SUBFCOx */
672      case 0x20a:   /* ADDCOx */
641      case 0x208:   // SUBFCOx
642      case 0x20a:   // ADDCOx
673643         GPR_USED(desc, G_RA(op));
674644         GPR_USED(desc, G_RB(op));
675645         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
678648         XER_CA_MODIFIED(desc);
679649         if (op & M_RC)
680650            CR_MODIFIED(desc, 0);
681         return TRUE;
651         return true;
682652
683      case 0x288:   /* SUBFEOx */
684      case 0x28a:   /* ADDEOx */
653      case 0x288:   // SUBFEOx
654      case 0x28a:   // ADDEOx
685655         GPR_USED(desc, G_RA(op));
686656         GPR_USED(desc, G_RB(op));
687657         XER_CA_USED(desc);
r9922r9923
691661         XER_CA_MODIFIED(desc);
692662         if (op & M_RC)
693663            CR_MODIFIED(desc, 0);
694         return TRUE;
664         return true;
695665
696      case 0x2c8:   /* SUBFZEOx */
697      case 0x2ca:   /* ADDZEOx */
698      case 0x2e8:   /* SUBFMEOx */
699      case 0x2ea:   /* ADDMEOx */
666      case 0x2c8:   // SUBFZEOx
667      case 0x2ca:   // ADDZEOx
668      case 0x2e8:   // SUBFMEOx
669      case 0x2ea:   // ADDMEOx
700670         GPR_USED(desc, G_RA(op));
701671         XER_CA_USED(desc);
702672         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
705675         XER_CA_MODIFIED(desc);
706676         if (op & M_RC)
707677            CR_MODIFIED(desc, 0);
708         return TRUE;
678         return true;
709679
710      case 0x2eb:   /* MULLWOx */
680      case 0x2eb:   // MULLWOx
711681         GPR_USED(desc, G_RA(op));
712682         GPR_USED(desc, G_RB(op));
713683         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
715685         XER_SO_MODIFIED(desc);
716686         if (op & M_RC)
717687            CR_MODIFIED(desc, 0);
718         if (is_403_class(ppc))
719            desc->cycles = 4;   /* 4XX */
720         else if (is_601_class(ppc))
721            desc->cycles = 5;   /* 601: 5/9/10 */
722         else if (is_603_class(ppc))
723            desc->cycles = 2;   /* 603: 2,3,4,5,6 */
688         if (is_403_class())
689            desc.cycles = 4;   // 4XX
690         else if (is_601_class())
691            desc.cycles = 5;   // 601: 5/9/10
692         else if (is_603_class())
693            desc.cycles = 2;   // 603: 2,3,4,5,6
724694         else
725            desc->cycles = 2;   /* ??? */
726         return TRUE;
695            desc.cycles = 2;   // ???
696         return true;
727697
728      case 0x3cb:   /* DIVWUOx */
729      case 0x3eb:   /* DIVWOx */
698      case 0x3cb:   // DIVWUOx
699      case 0x3eb:   // DIVWOx
730700         GPR_USED(desc, G_RA(op));
731701         GPR_USED(desc, G_RB(op));
732702         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
734704         XER_SO_MODIFIED(desc);
735705         if (op & M_RC)
736706            CR_MODIFIED(desc, 0);
737         if (is_403_class(ppc))
738            desc->cycles = 33;   /* 4XX */
739         else if (is_601_class(ppc))
740            desc->cycles = 36;   /* 601 */
741         else if (is_603_class(ppc))
742            desc->cycles = 37;   /* 603 */
707         if (is_403_class())
708            desc.cycles = 33;   // 4XX
709         else if (is_601_class())
710            desc.cycles = 36;   // 601
711         else if (is_603_class())
712            desc.cycles = 37;   // 603
743713         else
744            desc->cycles = 33;   /* ??? */
745         return TRUE;
714            desc.cycles = 33;   // ???
715         return true;
746716
747      case 0x228:   /* SUBFOx */
748      case 0x30a:   /* ADDOx */
717      case 0x228:   // SUBFOx
718      case 0x30a:   // ADDOx
749719         GPR_USED(desc, G_RA(op));
750720         GPR_USED(desc, G_RB(op));
751721         GPR_MODIFIED(desc, G_RD(op));
r9922r9923
753723         XER_SO_MODIFIED(desc);
754724         if (op & M_RC)
755725            CR_MODIFIED(desc, 0);
756         return TRUE;
726         return true;
757727
758      case 0x013:   /* MFCR */
728      case 0x013:   // MFCR
759729         CR_USED(desc, 0);
760730         CR_USED(desc, 1);
761731         CR_USED(desc, 2);
r9922r9923
765735         CR_USED(desc, 6);
766736         CR_USED(desc, 7);
767737         GPR_MODIFIED(desc, G_RD(op));
768         return TRUE;
738         return true;
769739
770      case 0x136:   /* ECIWX */
771         if (!(ppc->cap & PPCCAP_VEA))
772            return FALSE;
773      case 0x014:   /* LWARX */
774      case 0x017:   /* LWZX */
775      case 0x057:   /* LBZX */
776      case 0x117:   /* LHZX */
777      case 0x157:   /* LHAX */
778      case 0x216:   /* LWBRX */
779      case 0x316:   /* LHBRX */
740      case 0x136:   // ECIWX
741         if (!(m_context.cap & PPCCAP_VEA))
742            return false;
743      case 0x014:   // LWARX
744      case 0x017:   // LWZX
745      case 0x057:   // LBZX
746      case 0x117:   // LHZX
747      case 0x157:   // LHAX
748      case 0x216:   // LWBRX
749      case 0x316:   // LHBRX
780750         GPR_USED_OR_ZERO(desc, G_RA(op));
781751         GPR_USED(desc, G_RB(op));
782752         GPR_MODIFIED(desc, G_RD(op));
783         desc->flags |= OPFLAG_READS_MEMORY;
784         return TRUE;
753         desc.flags |= OPFLAG_READS_MEMORY;
754         return true;
785755
786      case 0x018:   /* SLWx */
787      case 0x01c:   /* ANDx */
788      case 0x03c:   /* ANDCx */
789      case 0x07c:   /* NORx */
790      case 0x11c:   /* EQVx */
791      case 0x13c:   /* XORx */
792      case 0x19c:   /* ORCx */
793      case 0x1bc:   /* ORx */
794      case 0x1dc:   /* NANDx */
756      case 0x018:   // SLWx
757      case 0x01c:   // ANDx
758      case 0x03c:   // ANDCx
759      case 0x07c:   // NORx
760      case 0x11c:   // EQVx
761      case 0x13c:   // XORx
762      case 0x19c:   // ORCx
763      case 0x1bc:   // ORx
764      case 0x1dc:   // NANDx
795765         GPR_USED(desc, G_RS(op));
796766         GPR_USED(desc, G_RB(op));
797767         GPR_MODIFIED(desc, G_RA(op));
r9922r9923
800770            XER_SO_USED(desc);
801771            CR_MODIFIED(desc, 0);
802772         }
803         return TRUE;
773         return true;
804774
805      case 0x218:   /* SRWx */
806      case 0x318:   /* SRAWx */
775      case 0x218:   // SRWx
776      case 0x318:   // SRAWx
807777         GPR_USED(desc, G_RS(op));
808778         GPR_USED(desc, G_RB(op));
809779         GPR_MODIFIED(desc, G_RA(op));
r9922r9923
813783            XER_SO_USED(desc);
814784            CR_MODIFIED(desc, 0);
815785         }
816         return TRUE;
786         return true;
817787
818      case 0x01a:   /* CNTLZWx */
819      case 0x39a:   /* EXTSHx */
820      case 0x3ba:   /* EXTSBx */
788      case 0x01a:   // CNTLZWx
789      case 0x39a:   // EXTSHx
790      case 0x3ba:   // EXTSBx
821791         GPR_USED(desc, G_RS(op));
822792         GPR_MODIFIED(desc, G_RA(op));
823793         if (op & M_RC)
r9922r9923
825795            XER_SO_USED(desc);
826796            CR_MODIFIED(desc, 0);
827797         }
828         return TRUE;
798         return true;
829799
830      case 0x036:   /* DCBST */
831      case 0x056:   /* DCBF */
832      case 0x0f6:   /* DCBTST */
833      case 0x116:   /* DCBT */
834      case 0x2f6:   /* DCBA */
835      case 0x3d6:   /* ICBI */
836         if (!(ppc->cap & (PPCCAP_VEA | PPCCAP_4XX)))
837            return FALSE;
800      case 0x036:   // DCBST
801      case 0x056:   // DCBF
802      case 0x0f6:   // DCBTST
803      case 0x116:   // DCBT
804      case 0x2f6:   // DCBA
805      case 0x3d6:   // ICBI
806         if (!(m_context.cap & (PPCCAP_VEA | PPCCAP_4XX)))
807            return false;
838808         GPR_USED_OR_ZERO(desc, G_RA(op));
839809         GPR_USED(desc, G_RB(op));
840         return TRUE;
810         return true;
841811
842      case 0x1d6:   /* DCBI */
843         if (!(ppc->cap & (PPCCAP_OEA | PPCCAP_4XX)))
844            return FALSE;
812      case 0x1d6:   // DCBI
813         if (!(m_context.cap & (PPCCAP_OEA | PPCCAP_4XX)))
814            return false;
845815         GPR_USED_OR_ZERO(desc, G_RA(op));
846816         GPR_USED(desc, G_RB(op));
847         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
848         return TRUE;
817         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
818         return true;
849819
850      case 0x037:   /* LWZUX */
851      case 0x077:   /* LBZUX */
852      case 0x137:   /* LHZUX */
853      case 0x177:   /* LHAUX */
820      case 0x037:   // LWZUX
821      case 0x077:   // LBZUX
822      case 0x137:   // LHZUX
823      case 0x177:   // LHAUX
854824         if (G_RA(op) == 0 || G_RA(op) == G_RD(op))
855            return FALSE;
825            return false;
856826         GPR_USED(desc, G_RA(op));
857827         GPR_USED(desc, G_RB(op));
858828         GPR_MODIFIED(desc, G_RD(op));
859829         GPR_MODIFIED(desc, G_RA(op));
860         desc->flags |= OPFLAG_READS_MEMORY;
861         return TRUE;
830         desc.flags |= OPFLAG_READS_MEMORY;
831         return true;
862832
863      case 0x153:   /* MFSPR */
833      case 0x153:   // MFSPR
864834         GPR_MODIFIED(desc, G_RD(op));
865835         spr = compute_spr(G_SPR(op));
866836         if (spr == SPR_LR)
r9922r9923
875845            XER_SO_USED(desc);
876846         }
877847         if (spr & 0x010)
878            desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
879         if ((ppc->cap & PPCCAP_4XX) && spr == SPR4XX_TBLU)
880            desc->cycles = POWERPC_COUNT_READ_TBL;
881         else if ((ppc->cap & PPCCAP_VEA) && spr == SPRVEA_TBL_R)
882            desc->cycles = POWERPC_COUNT_READ_TBL;
883         else if ((ppc->cap & PPCCAP_OEA) && spr == SPROEA_DEC)
884            desc->cycles = POWERPC_COUNT_READ_DEC;
885         return TRUE;
848            desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
849         if ((m_context.cap & PPCCAP_4XX) && spr == SPR4XX_TBLU)
850            desc.cycles = POWERPC_COUNT_READ_TBL;
851         else if ((m_context.cap & PPCCAP_VEA) && spr == SPRVEA_TBL_R)
852            desc.cycles = POWERPC_COUNT_READ_TBL;
853         else if ((m_context.cap & PPCCAP_OEA) && spr == SPROEA_DEC)
854            desc.cycles = POWERPC_COUNT_READ_DEC;
855         return true;
886856
887      case 0x053:   /* MFMSR */
857      case 0x053:   // MFMSR
888858         GPR_MODIFIED(desc, G_RD(op));
889         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
890         if (is_601_class(ppc))
891            desc->cycles = 2;   /* 601 */
892         return TRUE;
859         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
860         if (is_601_class())
861            desc.cycles = 2;   // 601
862         return true;
893863
894      case 0x253:   /* MFSR */
864      case 0x253:   // MFSR
895865         GPR_MODIFIED(desc, G_RD(op));
896         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
897         return TRUE;
866         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
867         return true;
898868
899      case 0x293:   /* MFSRIN */
869      case 0x293:   // MFSRIN
900870         GPR_USED(desc, G_RB(op));
901871         GPR_MODIFIED(desc, G_RD(op));
902         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
903         return TRUE;
872         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
873         return true;
904874
905      case 0x173:   /* MFTB */
906         if (!(ppc->cap & PPCCAP_VEA))
907            return FALSE;
875      case 0x173:   // MFTB
876         if (!(m_context.cap & PPCCAP_VEA))
877            return false;
908878         GPR_MODIFIED(desc, G_RD(op));
909879         spr = compute_spr(G_SPR(op));
910880         if (spr == SPRVEA_TBL_R)
911            desc->cycles = POWERPC_COUNT_READ_TBL;
912         return TRUE;
881            desc.cycles = POWERPC_COUNT_READ_TBL;
882         return true;
913883
914      case 0x068:   /* NEGx */
884      case 0x068:   // NEGx
915885         GPR_USED(desc, G_RA(op));
916886         GPR_MODIFIED(desc, G_RD(op));
917887         if (op & M_RC)
r9922r9923
919889            XER_SO_USED(desc);
920890            CR_MODIFIED(desc, 0);
921891         }
922         return TRUE;
892         return true;
923893
924      case 0x268:   /* NEGOx */
894      case 0x268:   // NEGOx
925895         GPR_USED(desc, G_RA(op));
926896         GPR_MODIFIED(desc, G_RD(op));
927897         XER_OV_MODIFIED(desc);
928898         XER_SO_MODIFIED(desc);
929899         if (op & M_RC)
930900            CR_MODIFIED(desc, 0);
931         return TRUE;
901         return true;
932902
933      case 0x090:   /* MTCRF */
903      case 0x090:   // MTCRF
934904         GPR_USED(desc, G_RS(op));
935905         if (G_CRM(op) & 0x80) CR_MODIFIED(desc, 0);
936906         if (G_CRM(op) & 0x40) CR_MODIFIED(desc, 1);
r9922r9923
940910         if (G_CRM(op) & 0x04) CR_MODIFIED(desc, 5);
941911         if (G_CRM(op) & 0x02) CR_MODIFIED(desc, 6);
942912         if (G_CRM(op) & 0x01) CR_MODIFIED(desc, 7);
943         return TRUE;
913         return true;
944914
945      case 0x092:   /* MTMSR */
915      case 0x092:   // MTMSR
946916         GPR_USED(desc, G_RS(op));
947         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
948         if (is_601_class(ppc))
949            desc->cycles = 17;   /* 601 */
950         else if (is_603_class(ppc))
951            desc->cycles = 2;   /* 603 */
952         return TRUE;
917         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
918         if (is_601_class())
919            desc.cycles = 17;   // 601
920         else if (is_603_class())
921            desc.cycles = 2;   // 603
922         return true;
953923
954      case 0x0d2:   /* MTSR */
955         if (!(ppc->cap & PPCCAP_OEA))
956            return FALSE;
924      case 0x0d2:   // MTSR
925         if (!(m_context.cap & PPCCAP_OEA))
926            return false;
957927         GPR_USED(desc, G_RS(op));
958         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
959         return TRUE;
928         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
929         return true;
960930
961      case 0x1d3:   /* MTSPR */
931      case 0x1d3:   // MTSPR
962932         GPR_USED(desc, G_RS(op));
963933         spr = compute_spr(G_SPR(op));
964934         if (spr == SPR_LR)
r9922r9923
973943            XER_SO_MODIFIED(desc);
974944         }
975945         if (spr & 0x010)
976            desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
977         return TRUE;
946            desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
947         return true;
978948
979      case 0x1b6:   /* ECOWX */
980         if (!(ppc->cap & PPCCAP_VEA))
981            return FALSE;
982      case 0x096:   /* STWCX. */
983      case 0x097:   /* STWX */
984      case 0x0d7:   /* STBX */
985      case 0x197:   /* STHX */
986      case 0x296:   /* STWBRX */
987      case 0x396:   /* STHBRX */
949      case 0x1b6:   // ECOWX
950         if (!(m_context.cap & PPCCAP_VEA))
951            return false;
952      case 0x096:   // STWCX.
953      case 0x097:   // STWX
954      case 0x0d7:   // STBX
955      case 0x197:   // STHX
956      case 0x296:   // STWBRX
957      case 0x396:   // STHBRX
988958         GPR_USED_OR_ZERO(desc, G_RA(op));
989959         GPR_USED(desc, G_RB(op));
990960         GPR_USED(desc, G_RS(op));
991         desc->flags |= OPFLAG_WRITES_MEMORY;
992         return TRUE;
961         desc.flags |= OPFLAG_WRITES_MEMORY;
962         return true;
993963
994      case 0x0b7:   /* STWUX */
995      case 0x0f7:   /* STBUX */
996      case 0x1b7:   /* STHUX */
964      case 0x0b7:   // STWUX
965      case 0x0f7:   // STBUX
966      case 0x1b7:   // STHUX
997967         if (G_RA(op) == 0)
998            return FALSE;
968            return false;
999969         GPR_USED(desc, G_RA(op));
1000970         GPR_USED(desc, G_RB(op));
1001971         GPR_USED(desc, G_RS(op));
1002972         GPR_MODIFIED(desc, G_RA(op));
1003         desc->flags |= OPFLAG_WRITES_MEMORY;
1004         return TRUE;
973         desc.flags |= OPFLAG_WRITES_MEMORY;
974         return true;
1005975
1006      case 0x0f2:   /* MTSRIN */
1007         if (!(ppc->cap & PPCCAP_OEA))
1008            return FALSE;
976      case 0x0f2:   // MTSRIN
977         if (!(m_context.cap & PPCCAP_OEA))
978            return false;
1009979         GPR_USED(desc, G_RS(op));
1010980         GPR_USED(desc, G_RB(op));
1011         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1012         return TRUE;
981         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
982         return true;
1013983
1014      case 0x132:   /* TLBIE */
1015         if (!(ppc->cap & PPCCAP_OEA))
1016            return FALSE;
984      case 0x132:   // TLBIE
985         if (!(m_context.cap & PPCCAP_OEA))
986            return false;
1017987         GPR_USED(desc, G_RB(op));
1018         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1019         return TRUE;
988         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
989         return true;
1020990
1021      case 0x172:   /* TLBIA */
1022         if (!(ppc->cap & PPCCAP_OEA) || (ppc->cap & PPCCAP_603_MMU))
1023            return FALSE;
1024         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1025         return TRUE;
991      case 0x172:   // TLBIA
992         if (!(m_context.cap & PPCCAP_OEA) || (m_context.cap & PPCCAP_603_MMU))
993            return false;
994         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
995         return true;
1026996
1027      case 0x3d2:   /* TLBLD */
1028      case 0x3f2:   /* TLBLI */
1029         if (!(ppc->cap & PPCCAP_603_MMU) && !is_602_class(ppc))
1030            return FALSE;
1031         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1032         return TRUE;
997      case 0x3d2:   // TLBLD
998      case 0x3f2:   // TLBLI
999         if (!(m_context.cap & PPCCAP_603_MMU) && !is_602_class())
1000            return false;
1001         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1002         return true;
10331003
1034      case 0x200:   /* MCRXR */
1004      case 0x200:   // MCRXR
10351005         XER_CA_USED(desc);
10361006         XER_OV_USED(desc);
10371007         XER_SO_USED(desc);
r9922r9923
10391009         XER_CA_MODIFIED(desc);
10401010         XER_OV_MODIFIED(desc);
10411011         XER_SO_MODIFIED(desc);
1042         return TRUE;
1012         return true;
10431013
1044      case 0x215:   /* LSWX */
1014      case 0x215:   // LSWX
10451015         GPR_USED_OR_ZERO(desc, G_RA(op));
10461016         GPR_USED(desc, G_RB(op));
10471017         XER_COUNT_USED(desc);
10481018         for (regnum = 0; regnum < 32; regnum++)
10491019            GPR_MODIFIED(desc, regnum);
1050         desc->flags |= OPFLAG_READS_MEMORY;
1051         return TRUE;
1020         desc.flags |= OPFLAG_READS_MEMORY;
1021         return true;
10521022
1053      case 0x217:   /* LFSX */
1054      case 0x257:   /* LFDX */
1055         if (!(ppc->cap & PPCCAP_FPU))
1056            return FALSE;
1023      case 0x217:   // LFSX
1024      case 0x257:   // LFDX
1025         if (!(m_context.cap & PPCCAP_FPU))
1026            return false;
10571027         GPR_USED_OR_ZERO(desc, G_RA(op));
10581028         GPR_USED(desc, G_RB(op));
10591029         FPR_MODIFIED(desc, G_RD(op));
1060         desc->flags |= OPFLAG_READS_MEMORY;
1061         return TRUE;
1030         desc.flags |= OPFLAG_READS_MEMORY;
1031         return true;
10621032
1063      case 0x236:   /* TLBSYNC */
1064         if (!(ppc->cap & PPCCAP_OEA))
1065            return FALSE;
1066         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1067         return TRUE;
1033      case 0x236:   // TLBSYNC
1034         if (!(m_context.cap & PPCCAP_OEA))
1035            return false;
1036         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1037         return true;
10681038
1069      case 0x256:   /* SYNC */
1070         return TRUE;
1039      case 0x256:   // SYNC
1040         return true;
10711041
1072      case 0x356:   /* EIEIO */
1073         if (!(ppc->cap & PPCCAP_VEA))
1074            return FALSE;
1075         return TRUE;
1042      case 0x356:   // EIEIO
1043         if (!(m_context.cap & PPCCAP_VEA))
1044            return false;
1045         return true;
10761046
1077      case 0x237:   /* LFSUX */
1078      case 0x277:   /* LFDUX */
1079         if (!(ppc->cap & PPCCAP_FPU))
1080            return FALSE;
1047      case 0x237:   // LFSUX
1048      case 0x277:   // LFDUX
1049         if (!(m_context.cap & PPCCAP_FPU))
1050            return false;
10811051         if (G_RA(op) == 0)
1082            return FALSE;
1052            return false;
10831053         GPR_USED(desc, G_RA(op));
10841054         GPR_USED(desc, G_RB(op));
10851055         GPR_MODIFIED(desc, G_RA(op));
10861056         FPR_MODIFIED(desc, G_RD(op));
1087         desc->flags |= OPFLAG_READS_MEMORY;
1088         return TRUE;
1057         desc.flags |= OPFLAG_READS_MEMORY;
1058         return true;
10891059
1090      case 0x255:   /* LSWI */
1060      case 0x255:   // LSWI
10911061         GPR_USED_OR_ZERO(desc, G_RA(op));
10921062         for (regnum = 0; regnum < ((G_NB(op) - 1) & 0x1f) + 1; regnum += 4)
10931063            GPR_MODIFIED(desc, (G_RD(op) + regnum / 4) % 32);
1094         desc->flags |= OPFLAG_READS_MEMORY;
1095         desc->cycles = (((G_NB(op) - 1) & 0x1f) + 1 + 3) / 4;
1096         return TRUE;
1064         desc.flags |= OPFLAG_READS_MEMORY;
1065         desc.cycles = (((G_NB(op) - 1) & 0x1f) + 1 + 3) / 4;
1066         return true;
10971067
1098      case 0x295:   /* STSWX */
1068      case 0x295:   // STSWX
10991069         GPR_USED_OR_ZERO(desc, G_RA(op));
11001070         GPR_USED(desc, G_RB(op));
11011071         XER_COUNT_USED(desc);
11021072         for (regnum = 0; regnum < 32; regnum++)
11031073            GPR_USED(desc, regnum);
1104         desc->flags |= OPFLAG_WRITES_MEMORY;
1105         return TRUE;
1074         desc.flags |= OPFLAG_WRITES_MEMORY;
1075         return true;
11061076
1107      case 0x2d5:   /* STSWI */
1077      case 0x2d5:   // STSWI
11081078         GPR_USED_OR_ZERO(desc, G_RA(op));
11091079         for (regnum = 0; regnum < ((G_NB(op) - 1) & 0x1f) + 1; regnum += 4)
11101080            GPR_USED(desc, (G_RD(op) + regnum / 4) % 32);
1111         desc->flags |= OPFLAG_WRITES_MEMORY;
1112         desc->cycles = (((G_NB(op) - 1) & 0x1f) + 1 + 3) / 4;
1113         return TRUE;
1081         desc.flags |= OPFLAG_WRITES_MEMORY;
1082         desc.cycles = (((G_NB(op) - 1) & 0x1f) + 1 + 3) / 4;
1083         return true;
11141084
1115      case 0x297:   /* STFSX */
1116      case 0x2d7:   /* STFDX */
1117      case 0x3d7:   /* STFIWX */
1118         if (!(ppc->cap & PPCCAP_FPU))
1119            return FALSE;
1085      case 0x297:   // STFSX
1086      case 0x2d7:   // STFDX
1087      case 0x3d7:   // STFIWX
1088         if (!(m_context.cap & PPCCAP_FPU))
1089            return false;
11201090         GPR_USED_OR_ZERO(desc, G_RA(op));
11211091         GPR_USED(desc, G_RB(op));
11221092         FPR_USED(desc, G_RS(op));
1123         desc->flags |= OPFLAG_WRITES_MEMORY;
1124         return TRUE;
1093         desc.flags |= OPFLAG_WRITES_MEMORY;
1094         return true;
11251095
1126      case 0x2b7:   /* STFSUX */
1127      case 0x2f7:   /* STFDUX */
1128         if (!(ppc->cap & PPCCAP_FPU))
1129            return FALSE;
1096      case 0x2b7:   // STFSUX
1097      case 0x2f7:   // STFDUX
1098         if (!(m_context.cap & PPCCAP_FPU))
1099            return false;
11301100         if (G_RA(op) == 0)
1131            return FALSE;
1101            return false;
11321102         GPR_USED_OR_ZERO(desc, G_RA(op));
11331103         GPR_USED(desc, G_RB(op));
11341104         GPR_MODIFIED(desc, G_RA(op));
11351105         FPR_USED(desc, G_RS(op));
1136         desc->flags |= OPFLAG_WRITES_MEMORY;
1137         return TRUE;
1106         desc.flags |= OPFLAG_WRITES_MEMORY;
1107         return true;
11381108
1139      case 0x338:   /* SRAWIx */
1109      case 0x338:   // SRAWIx
11401110         GPR_USED(desc, G_RS(op));
11411111         GPR_MODIFIED(desc, G_RA(op));
11421112         XER_CA_MODIFIED(desc);
r9922r9923
11451115            XER_SO_USED(desc);
11461116            CR_MODIFIED(desc, 0);
11471117         }
1148         return TRUE;
1118         return true;
11491119
1150      case 0x3f6:   /* DCBZ */
1151         if (!(ppc->cap & (PPCCAP_VEA | PPCCAP_4XX)))
1152            return FALSE;
1120      case 0x3f6:   // DCBZ
1121         if (!(m_context.cap & (PPCCAP_VEA | PPCCAP_4XX)))
1122            return false;
11531123         GPR_USED_OR_ZERO(desc, G_RA(op));
11541124         GPR_USED(desc, G_RB(op));
1155         desc->flags |= OPFLAG_WRITES_MEMORY;
1156         return TRUE;
1125         desc.flags |= OPFLAG_WRITES_MEMORY;
1126         return true;
11571127
1158      case 0x106:   /* ICBT */
1159      case 0x1c6:   /* DCCCI */
1160      case 0x3c6:   /* ICCCI */
1161         if (!(ppc->cap & PPCCAP_4XX))
1162            return FALSE;
1128      case 0x106:   // ICBT
1129      case 0x1c6:   // DCCCI
1130      case 0x3c6:   // ICCCI
1131         if (!(m_context.cap & PPCCAP_4XX))
1132            return false;
11631133         GPR_USED_OR_ZERO(desc, G_RA(op));
11641134         GPR_USED(desc, G_RB(op));
1165         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1166         return TRUE;
1135         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1136         return true;
11671137
1168      case 0x1e6:   /* DCREAD */
1169      case 0x3e6:   /* ICREAD */
1170         if (!(ppc->cap & PPCCAP_4XX))
1171            return FALSE;
1138      case 0x1e6:   // DCREAD
1139      case 0x3e6:   // ICREAD
1140         if (!(m_context.cap & PPCCAP_4XX))
1141            return false;
11721142         GPR_USED_OR_ZERO(desc, G_RA(op));
11731143         GPR_USED(desc, G_RB(op));
11741144         GPR_MODIFIED(desc, G_RT(op));
1175         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1176         return TRUE;
1145         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1146         return true;
11771147
1178      case 0x143:   /* MFDCR */
1179         if (!(ppc->cap & PPCCAP_4XX))
1180            return FALSE;
1148      case 0x143:   // MFDCR
1149         if (!(m_context.cap & PPCCAP_4XX))
1150            return false;
11811151         GPR_MODIFIED(desc, G_RD(op));
1182         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1183         return TRUE;
1152         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1153         return true;
11841154
1185      case 0x1c3:   /* MTDCR */
1186         if (!(ppc->cap & PPCCAP_4XX))
1187            return FALSE;
1155      case 0x1c3:   // MTDCR
1156         if (!(m_context.cap & PPCCAP_4XX))
1157            return false;
11881158         GPR_USED(desc, G_RS(op));
1189         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
1190         return TRUE;
1159         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
1160         return true;
11911161
1192      case 0x083:   /* WRTEE */
1193         if (!(ppc->cap & PPCCAP_4XX))
1194            return FALSE;
1162      case 0x083:   // WRTEE
1163         if (!(m_context.cap & PPCCAP_4XX))
1164            return false;
11951165         GPR_USED(desc, G_RS(op));
1196         desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
1197         return TRUE;
1166         desc.flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
1167         return true;
11981168
1199      case 0x0a3:   /* WRTEEI */
1200         if (!(ppc->cap & PPCCAP_4XX))
1201            return FALSE;
1169      case 0x0a3:   // WRTEEI
1170         if (!(m_context.cap & PPCCAP_4XX))
1171            return false;
12021172         if (op & MSR_EE)
1203            desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
1204         return TRUE;
1173            desc.flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
1174         return true;
12051175
1206      case 0x254: /* ESA */
1207      case 0x274: /* DSA */
1208         if (!is_602_class(ppc))
1209            return FALSE;
1210         desc->flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1211         return TRUE;
1176      case 0x254: // ESA
1177      case 0x274: // DSA
1178         if (!is_602_class())
1179            return false;
1180         desc.flags |= OPFLAG_PRIVILEGED | OPFLAG_CAN_CAUSE_EXCEPTION;
1181         return true;
12121182   }
12131183
1214   return FALSE;
1184   return false;
12151185}
12161186
12171187
r9922r9923
12211191    0x3b group
12221192-------------------------------------------------*/
12231193
1224static int describe_instruction_3b(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev)
1194bool ppc_frontend::describe_3b(UINT32 op, opcode_desc &desc, const opcode_desc *prev)
12251195{
12261196   UINT32 opswitch = (op >> 1) & 0x1f;
12271197
1228   if (!(ppc->cap & PPCCAP_FPU))
1229      return FALSE;
1198   if (!(m_context.cap & PPCCAP_FPU))
1199      return false;
12301200
12311201   switch (opswitch)
12321202   {
1233      case 0x12:   /* FDIVSx */
1203      case 0x12:   // FDIVSx
12341204         FPR_USED(desc, G_RA(op));
12351205         FPR_USED(desc, G_RB(op));
12361206         FPR_MODIFIED(desc, G_RD(op));
12371207         if (op & M_RC)
12381208            CR_MODIFIED(desc, 1);
1239         if (is_601_class(ppc))
1240            desc->cycles = 17;   /* 601 */
1241         else if (is_603_class(ppc))
1242            desc->cycles = 18;   /* 603 */
1209         if (is_601_class())
1210            desc.cycles = 17;   // 601
1211         else if (is_603_class())
1212            desc.cycles = 18;   // 603
12431213         else
1244            desc->cycles = 17;   /* ??? */
1214            desc.cycles = 17;   // ???
12451215         FPSCR_MODIFIED(desc, 4);
1246         return TRUE;
1216         return true;
12471217
1248      case 0x14:   /* FSUBSx */
1249      case 0x15:   /* FADDSx */
1218      case 0x14:   // FSUBSx
1219      case 0x15:   // FADDSx
12501220         FPR_USED(desc, G_RA(op));
12511221         FPR_USED(desc, G_RB(op));
12521222         FPR_MODIFIED(desc, G_RD(op));
12531223         if (op & M_RC)
12541224            CR_MODIFIED(desc, 1);
12551225         FPSCR_MODIFIED(desc, 4);
1256         return TRUE;
1226         return true;
12571227
1258      case 0x19:   /* FMULSx - not the same form as FSUB/FADD! */
1228      case 0x19:   // FMULSx - not the same form as FSUB/FADD!
12591229         FPR_USED(desc, G_RA(op));
12601230         FPR_USED(desc, G_REGC(op));
12611231         FPR_MODIFIED(desc, G_RD(op));
12621232         if (op & M_RC)
12631233            CR_MODIFIED(desc, 1);
12641234         FPSCR_MODIFIED(desc, 4);
1265         return TRUE;
1235         return true;
12661236
1267      case 0x16:   /* FSQRTSx */
1268      case 0x18:   /* FRESx */
1237      case 0x16:   // FSQRTSx
1238      case 0x18:   // FRESx
12691239         FPR_USED(desc, G_RB(op));
12701240         FPR_MODIFIED(desc, G_RD(op));
12711241         if (op & M_RC)
12721242            CR_MODIFIED(desc, 1);
12731243         FPSCR_MODIFIED(desc, 4);
1274         return TRUE;
1244         return true;
12751245
1276      case 0x1c:   /* FMSUBSx */
1277      case 0x1d:   /* FMADDSx */
1278      case 0x1e:   /* FNMSUBSx */
1279      case 0x1f:   /* FNMADDSx */
1246      case 0x1c:   // FMSUBSx
1247      case 0x1d:   // FMADDSx
1248      case 0x1e:   // FNMSUBSx
1249      case 0x1f:   // FNMADDSx
12801250         FPR_USED(desc, G_RA(op));
12811251         FPR_USED(desc, G_RB(op));
12821252         FPR_USED(desc, G_REGC(op));
r9922r9923
12841254         if (op & M_RC)
12851255            CR_MODIFIED(desc, 1);
12861256         FPSCR_MODIFIED(desc, 4);
1287         return TRUE;
1257         return true;
12881258   }
12891259
1290   return FALSE;
1260   return false;
12911261}
12921262
12931263
r9922r9923
12971267    0x3f group
12981268-------------------------------------------------*/
12991269
1300static int describe_instruction_3f(powerpc_state *ppc, UINT32 op, opcode_desc *desc, const opcode_desc *prev)
1270bool ppc_frontend::describe_3f(UINT32 op, opcode_desc &desc, const opcode_desc *prev)
13011271{
13021272   UINT32 opswitch = (op >> 1) & 0x3ff;
13031273
1304   if (!(ppc->cap & PPCCAP_FPU))
1305      return FALSE;
1274   if (!(m_context.cap & PPCCAP_FPU))
1275      return false;
13061276
13071277   if (opswitch & 0x10)
13081278   {
13091279      opswitch &= 0x1f;
13101280      switch (opswitch)
13111281      {
1312         case 0x12:   /* FDIVx */
1282         case 0x12:   // FDIVx
13131283            FPR_USED(desc, G_RA(op));
13141284            FPR_USED(desc, G_RB(op));
13151285            FPR_MODIFIED(desc, G_RD(op));
13161286            if (op & M_RC)
13171287               CR_MODIFIED(desc, 1);
1318            if (is_601_class(ppc))
1319               desc->cycles = 31;   /* 601 */
1320            else if (is_603_class(ppc))
1321               desc->cycles = 33;   /* 603 */
1288            if (is_601_class())
1289               desc.cycles = 31;   // 601
1290            else if (is_603_class())
1291               desc.cycles = 33;   // 603
13221292            else
1323               desc->cycles = 31;   /* ??? */
1293               desc.cycles = 31;   // ???
13241294            FPSCR_MODIFIED(desc, 4);
1325            return TRUE;
1295            return true;
13261296
1327         case 0x19:   /* FMULx */
1297         case 0x19:   // FMULx
13281298            FPR_USED(desc, G_RA(op));
13291299            FPR_USED(desc, G_REGC(op));
13301300            FPR_MODIFIED(desc, G_RD(op));
13311301            if (op & M_RC)
13321302               CR_MODIFIED(desc, 1);
1333            desc->cycles = 2;   /* 601/603 */
1303            desc.cycles = 2;   // 601/603
13341304            FPSCR_MODIFIED(desc, 4);
1335            return TRUE;
1305            return true;
13361306
1337         case 0x14:   /* FSUBx */
1338         case 0x15:   /* FADDx */
1307         case 0x14:   // FSUBx
1308         case 0x15:   // FADDx
13391309            FPR_USED(desc, G_RA(op));
13401310            FPR_USED(desc, G_RB(op));
13411311            FPR_MODIFIED(desc, G_RD(op));
13421312            if (op & M_RC)
13431313               CR_MODIFIED(desc, 1);
13441314            FPSCR_MODIFIED(desc, 4);
1345            return TRUE;
1315            return true;
13461316
1347         case 0x16:   /* FSQRTx */
1348         case 0x1a:   /* FSQRTEx */
1317         case 0x16:   // FSQRTx
1318         case 0x1a:   // FSQRTEx
13491319            FPR_USED(desc, G_RB(op));
13501320            FPR_MODIFIED(desc, G_RD(op));
13511321            if (op & M_RC)
13521322               CR_MODIFIED(desc, 1);
13531323            FPSCR_MODIFIED(desc, 4);
1354            return TRUE;
1324            return true;
13551325
1356         case 0x17:   /* FSELx */
1326         case 0x17:   // FSELx
13571327            FPR_USED(desc, G_RA(op));
13581328            FPR_USED(desc, G_RB(op));
13591329            FPR_USED(desc, G_REGC(op));
13601330            FPR_MODIFIED(desc, G_RD(op));
13611331            if (op & M_RC)
13621332               CR_MODIFIED(desc, 1);
1363            desc->cycles = 2;   /* 601/603 */
1364            return TRUE;
1333            desc.cycles = 2;   // 601/603
1334            return true;
13651335
1366         case 0x1c:   /* FMSUBx */
1367         case 0x1d:   /* FMADDx */
1368         case 0x1e:   /* FNMSUBx */
1369         case 0x1f:   /* FNMADDx */
1336         case 0x1c:   // FMSUBx
1337         case 0x1d:   // FMADDx
1338         case 0x1e:   // FNMSUBx
1339         case 0x1f:   // FNMADDx
13701340            FPR_USED(desc, G_RA(op));
13711341            FPR_USED(desc, G_RB(op));
13721342            FPR_USED(desc, G_REGC(op));
13731343            FPR_MODIFIED(desc, G_RD(op));
13741344            if (op & M_RC)
13751345               CR_MODIFIED(desc, 1);
1376            desc->cycles = 2;   /* 601/603 */
1346            desc.cycles = 2;   // 601/603
13771347            FPSCR_MODIFIED(desc, 4);
1378            return TRUE;
1348            return true;
13791349      }
13801350   }
13811351   else
13821352   {
13831353      switch (opswitch)
13841354      {
1385         case 0x32e:   /* FCTIDx - 64-bit only */
1386         case 0x32f:   /* FCTIDZx - 64-bit only */
1387         case 0x34e:   /* FCFIDx - 64-bit only */
1388            return FALSE;
1355         case 0x32e:   // FCTIDx - 64-bit only
1356         case 0x32f:   // FCTIDZx - 64-bit only
1357         case 0x34e:   // FCFIDx - 64-bit only
1358            return false;
13891359
1390         case 0x000:   /* FCMPU */
1391         case 0x020:   /* FCMPO */
1360         case 0x000:   // FCMPU
1361         case 0x020:   // FCMPO
13921362            FPR_USED(desc, G_RA(op));
13931363            FPR_USED(desc, G_RB(op));
13941364            CR_MODIFIED(desc, G_CRFD(op));
1395            return TRUE;
1365            return true;
13961366
1397         case 0x00c:   /* FRSPx */
1398         case 0x00e:   /* FCTIWx */
1399         case 0x00f:   /* FCTIWZx */
1367         case 0x00c:   // FRSPx
1368         case 0x00e:   // FCTIWx
1369         case 0x00f:   // FCTIWZx
14001370            FPSCR_MODIFIED(desc, 4);
1401         case 0x028:   /* FNEGx */
1402         case 0x048:   /* FMRx */
1403         case 0x088:   /* FNABSx */
1404         case 0x108:   /* FABSx */
1371         case 0x028:   // FNEGx
1372         case 0x048:   // FMRx
1373         case 0x088:   // FNABSx
1374         case 0x108:   // FABSx
14051375            FPR_USED(desc, G_RB(op));
14061376            FPR_MODIFIED(desc, G_RD(op));
14071377            if (op & M_RC)
14081378               CR_MODIFIED(desc, 1);
1409            return TRUE;
1379            return true;
14101380
1411         case 0x026:   /* MTFSB1x */
1412         case 0x046:   /* MTFSB0x */
1381         case 0x026:   // MTFSB1x
1382         case 0x046:   // MTFSB0x
14131383            FPSCR_MODIFIED(desc, G_CRBD(op) / 4);
1414            return TRUE;
1384            return true;
14151385
1416         case 0x040:   /* MCRFS */
1386         case 0x040:   // MCRFS
14171387            FPSCR_USED(desc, G_CRFS(op));
14181388            CR_MODIFIED(desc, G_CRFD(op));
1419            return TRUE;
1389            return true;
14201390
1421         case 0x086:   /* MTFSFIx */
1391         case 0x086:   // MTFSFIx
14221392            FPSCR_MODIFIED(desc, G_CRFD(op));
1423            return TRUE;
1393            return true;
14241394
1425         case 0x247:   /* MFFSx */
1395         case 0x247:   // MFFSx
14261396            FPSCR_USED(desc, 0);
14271397            FPSCR_USED(desc, 1);
14281398            FPSCR_USED(desc, 2);
r9922r9923
14321402            FPSCR_USED(desc, 6);
14331403            FPSCR_USED(desc, 7);
14341404            FPR_MODIFIED(desc, G_RD(op));
1435            return TRUE;
1405            return true;
14361406
1437         case 0x2c7:   /* MTFSFx */
1407         case 0x2c7:   // MTFSFx
14381408            FPR_USED(desc, G_RB(op));
14391409            if (G_CRM(op) & 0x80) FPSCR_MODIFIED(desc, 0);
14401410            if (G_CRM(op) & 0x40) FPSCR_MODIFIED(desc, 1);
r9922r9923
14441414            if (G_CRM(op) & 0x04) FPSCR_MODIFIED(desc, 5);
14451415            if (G_CRM(op) & 0x02) FPSCR_MODIFIED(desc, 6);
14461416            if (G_CRM(op) & 0x01) FPSCR_MODIFIED(desc, 7);
1447            return TRUE;
1417            return true;
14481418      }
14491419   }
14501420
1451   return FALSE;
1421   return false;
14521422}
src/emu/cpu/sh2/sh2comn.h
r9922r9923
2121#include "cpu/drcfe.h"
2222#include "cpu/drcuml.h"
2323#include "cpu/drcumlsh.h"
24class sh2_frontend;
2425#endif
2526
2627#define SH2_CODE_XOR(a)      ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(2,0))
r9922r9923
155156#ifdef USE_SH2DRC
156157   drccache *         cache;                /* pointer to the DRC code cache */
157158   drcuml_state *      drcuml;               /* DRC UML generator state */
158   drcfe_state *      drcfe;               /* pointer to the DRC front-end state */
159   sh2_frontend *      drcfe;               /* pointer to the DRC front-end state */
159160   UINT32            drcoptions;         /* configurable DRC options */
160161
161162   /* internal stuff */
r9922r9923
184185#endif
185186} sh2_state;
186187
188#ifdef USE_SH2DRC
189class sh2_frontend : public drc_frontend
190{
191public:
192   sh2_frontend(sh2_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
193
194protected:   
195   virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
196
197private:
198   bool describe_group_0(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
199   bool describe_group_2(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
200   bool describe_group_3(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
201   bool describe_group_4(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
202   bool describe_group_6(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
203   bool describe_group_8(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
204   bool describe_group_12(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
205
206   sh2_state &m_context;
207};
208#endif
209
187210void sh2_common_init(sh2_state *sh2, legacy_cpu_device *device, device_irq_callback irqcallback);
188211void sh2_recalc_irq(sh2_state *sh2);
189212void sh2_set_irq_line(sh2_state *sh2, int irqline, int state);
src/emu/cpu/sh2/sh2drc.c
r9922r9923
674674
675675static CPU_INIT( sh2 )
676676{
677   drcfe_config feconfig =
678   {
679      COMPILE_BACKWARDS_BYTES,   /* code window start offset = startpc - window_start */
680      COMPILE_FORWARDS_BYTES,      /* code window end offset = startpc + window_end */
681      COMPILE_MAX_SEQUENCE,      /* maximum instructions to include in a sequence */
682      sh2_describe         /* callback to describe a single instruction */
683   };
684677   sh2_state *sh2 = get_safe_token(device);
685678   drccache *cache;
686679   drcbe_info beinfo;
r9922r9923
733726   drcuml_symbol_add(sh2->drcuml, &sh2->mach, sizeof(sh2->macl), "mach");
734727
735728   /* initialize the front-end helper */
736   if (SINGLE_INSTRUCTION_MODE)
737      feconfig.max_sequence = 1;
738   sh2->drcfe = drcfe_init(device, &feconfig, sh2);
729   sh2->drcfe = auto_alloc(device->machine, sh2_frontend(*sh2, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE));
739730
740731   /* compute the register parameters */
741732   for (regnum = 0; regnum < 16; regnum++)
r9922r9923
779770   sh2_state *sh2 = get_safe_token(device);
780771
781772   /* clean up the DRC */
782   drcfe_exit(sh2->drcfe);
773   auto_free(device->machine, sh2->drcfe);
783774   drcuml_free(sh2->drcuml);
784775   drccache_free(sh2->cache);
785776}
r9922r9923
941932   g_profiler.start(PROFILER_DRC_COMPILE);
942933
943934   /* get a description of this sequence */
944   desclist = drcfe_describe_code(sh2->drcfe, pc);
935   desclist = sh2->drcfe->describe_code(pc);
945936   if (LOG_UML || LOG_NATIVE)
946937      log_opcode_desc(drcuml, desclist, 0);
947938
r9922r9923
953944   block = drcuml_block_begin(drcuml, 4096, &errorbuf);
954945
955946   /* loop until we get through all instruction sequences */
956   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next)
947   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next())
957948   {
958949      const opcode_desc *curdesc;
959950      UINT32 nextpc;
r9922r9923
963954         UML_COMMENT(block, "-------------------------");                  // comment
964955
965956      /* determine the last instruction in this sequence */
966      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next)
957      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next())
967958         if (seqlast->flags & OPFLAG_END_SEQUENCE)
968959            break;
969960      assert(seqlast != NULL);
r9922r9923
1000991      }
1001992
1002993      /* iterate over instructions in the sequence and compile them */
1003      for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next)
994      for (curdesc = seqhead; curdesc != seqlast->next(); curdesc = curdesc->next())
1004995      {
1005996         generate_sequence_instruction(sh2, block, &compiler, curdesc, 0xffffffff);
1006997      }
r9922r9923
10201011      generate_update_cycles(sh2, block, &compiler, IMM(nextpc), TRUE);            // <subtract cycles>
10211012
10221013      /* SH2 has no modes */
1023      if (seqlast->next == NULL || seqlast->next->pc != nextpc)
1014      if (seqlast->next() == NULL || seqlast->next()->pc != nextpc)
10241015      {
10251016         UML_HASHJMP(block, IMM(0), IMM(nextpc), sh2->nocode);
10261017      }
r9922r9923
13901381      drcuml_log_printf(drcuml, "\nDescriptor list @ %08X\n", desclist->pc);
13911382
13921383   /* output each descriptor */
1393   for ( ; desclist != NULL; desclist = desclist->next)
1384   for ( ; desclist != NULL; desclist = desclist->next())
13941385   {
13951386      char buffer[100];
13961387
r9922r9923
14111402      drcuml_log_printf(drcuml, "\n");
14121403
14131404      /* if we have a delay slot, output it recursively */
1414      if (desclist->delay != NULL)
1415         log_opcode_desc(drcuml, desclist->delay, indent + 1);
1405      if (desclist->delay.first() != NULL)
1406         log_opcode_desc(drcuml, desclist->delay.first(), indent + 1);
14161407
14171408      /* at the end of a sequence add a dividing line */
14181409      if (desclist->flags & OPFLAG_END_SEQUENCE)
r9922r9923
15241515      UML_COMMENT(block, "[Validation for %08X]", seqhead->pc);               // comment
15251516
15261517   /* loose verify or single instruction: just compare and fail */
1527   if (!(sh2->drcoptions & SH2DRC_STRICT_VERIFY) || seqhead->next == NULL)
1518   if (!(sh2->drcoptions & SH2DRC_STRICT_VERIFY) || seqhead->next() == NULL)
15281519   {
15291520      if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP))
15301521      {
r9922r9923
15391530   else
15401531   {
15411532#if 0
1542      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
1533      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
15431534         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
15441535         {
15451536            base = sh2->direct->read_decrypted_ptr(curdesc->physpc, SH2_CODE_XOR(0));
r9922r9923
15521543      void *base = sh2->direct->read_decrypted_ptr(seqhead->physpc, SH2_CODE_XOR(0));
15531544      UML_LOAD(block, IREG(0), base, IMM(0), WORD);                        // load    i0,base,word
15541545      sum += seqhead->opptr.w[0];
1555      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
1546      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
15561547         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
15571548         {
15581549            base = sh2->direct->read_decrypted_ptr(curdesc->physpc, SH2_CODE_XOR(0));
r9922r9923
16611652   compiler_state compiler_temp = *compiler;
16621653
16631654   /* compile the delay slot using temporary compiler state */
1664   assert(desc->delay != NULL);
1665   generate_sequence_instruction(sh2, block, &compiler_temp, desc->delay, ovrpc);            // <next instruction>
1655   assert(desc->delay.first() != NULL);
1656   generate_sequence_instruction(sh2, block, &compiler_temp, desc->delay.first(), ovrpc);            // <next instruction>
16661657
16671658   /* update the label */
16681659   compiler->labelnum = compiler_temp.labelnum;
src/emu/cpu/sh2/sh2fe.c
r9922r9923
1414#include "sh2comn.h"
1515#include "cpu/drcfe.h"
1616
17/***************************************************************************
18    FUNCTION PROTOTYPES
19***************************************************************************/
2017
21static int describe_group_0(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
22static int describe_group_2(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
23static int describe_group_3(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
24static int describe_group_4(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
25static int describe_group_6(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
26static int describe_group_8(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
27static int describe_group_12(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode);
28
29
30
3118/***************************************************************************
3219    INSTRUCTION PARSERS
3320***************************************************************************/
3421
22sh2_frontend::sh2_frontend(sh2_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence)
23   : drc_frontend(*state.device, window_start, window_end, max_sequence),
24     m_context(state)
25{
26}
27
3528/*-------------------------------------------------
3629    describe_instruction - build a description
3730    of a single instruction
3831-------------------------------------------------*/
3932
40int sh2_describe(void *param, opcode_desc *desc, const opcode_desc *prev)
33bool sh2_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
4134{
42   sh2_state *context = (sh2_state *)param;
4335   UINT16 opcode;
4436
4537   /* fetch the opcode */
46   opcode = desc->opptr.w[0] = context->direct->read_decrypted_word(desc->physpc, SH2_CODE_XOR(0));
38   opcode = desc.opptr.w[0] = m_context.direct->read_decrypted_word(desc.physpc, SH2_CODE_XOR(0));
4739
4840   /* all instructions are 2 bytes and most are a single cycle */
49   desc->length = 2;
50   desc->cycles = 1;
41   desc.length = 2;
42   desc.cycles = 1;
5143
5244   switch (opcode>>12)
5345   {
5446      case  0:
55         return describe_group_0(context, desc, prev, opcode);
47         return describe_group_0(desc, prev, opcode);
5648
5749      case  1:   // MOVLS4
58         desc->regin[0] |= REGFLAG_R(Rn) | REGFLAG_R(Rm);
59         desc->flags |= OPFLAG_WRITES_MEMORY;
60         return TRUE;
50         desc.regin[0] |= REGFLAG_R(Rn) | REGFLAG_R(Rm);
51         desc.flags |= OPFLAG_WRITES_MEMORY;
52         return true;
6153
6254      case  2:
63         return describe_group_2(context, desc, prev, opcode);
55         return describe_group_2(desc, prev, opcode);
6456
6557      case  3:
66         return describe_group_3(context, desc, prev, opcode);
58         return describe_group_3(desc, prev, opcode);
6759
6860      case  4:
69         return describe_group_4(context, desc, prev, opcode);
61         return describe_group_4(desc, prev, opcode);
7062
7163      case  5:   // MOVLL4
72         desc->regin[0] |= REGFLAG_R(Rm);
73         desc->regout[0] |= REGFLAG_R(Rn);
74         desc->flags |= OPFLAG_READS_MEMORY;
75         return TRUE;
64         desc.regin[0] |= REGFLAG_R(Rm);
65         desc.regout[0] |= REGFLAG_R(Rn);
66         desc.flags |= OPFLAG_READS_MEMORY;
67         return true;
7668
7769      case  6:
78         return describe_group_6(context, desc, prev, opcode);
70         return describe_group_6(desc, prev, opcode);
7971
8072      case  7:   // ADDI
81         desc->regin[0] |= REGFLAG_R(Rn);
82         desc->regout[0] |= REGFLAG_R(Rn);
83         return TRUE;
73         desc.regin[0] |= REGFLAG_R(Rn);
74         desc.regout[0] |= REGFLAG_R(Rn);
75         return true;
8476
8577      case  8:
86         return describe_group_8(context, desc, prev, opcode);
78         return describe_group_8(desc, prev, opcode);
8779
8880      case  9:   // MOVWI
89         desc->regout[0] |= REGFLAG_R(Rn);
90         desc->flags |= OPFLAG_READS_MEMORY;
91         return TRUE;
81         desc.regout[0] |= REGFLAG_R(Rn);
82         desc.flags |= OPFLAG_READS_MEMORY;
83         return true;
9284
9385      case 11:   // BSR
94         desc->regout[1] |= REGFLAG_PR;
86         desc.regout[1] |= REGFLAG_PR;
9587         // (intentional fallthrough - BSR is BRA with the addition of PR = the return address)
9688      case 10:   // BRA
9789         {
9890            INT32 disp = ((INT32)opcode << 20) >> 20;
9991
100            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
101            desc->targetpc = (desc->pc + 2) + disp * 2 + 2;
102            desc->delayslots = 1;
103            desc->cycles = 2;
104            return TRUE;
92            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
93            desc.targetpc = (desc.pc + 2) + disp * 2 + 2;
94            desc.delayslots = 1;
95            desc.cycles = 2;
96            return true;
10597         }
10698
10799      case 12:
108         return describe_group_12(context, desc, prev, opcode);
100         return describe_group_12(desc, prev, opcode);
109101
110102      case 13:   // MOVLI
111         desc->regout[0] |= REGFLAG_R(Rn);
112         desc->flags |= OPFLAG_READS_MEMORY;
113         return TRUE;
103         desc.regout[0] |= REGFLAG_R(Rn);
104         desc.flags |= OPFLAG_READS_MEMORY;
105         return true;
114106
115107      case 14:   // MOVI
116         desc->regout[0] |= REGFLAG_R(Rn);
117         return TRUE;
108         desc.regout[0] |= REGFLAG_R(Rn);
109         return true;
118110
119111      case 15:   // NOP
120         return TRUE;
112         return true;
121113   }
122114
123   return FALSE;
115   return false;
124116}
125117
126static int describe_group_0(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
118bool sh2_frontend::describe_group_0(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
127119{
128120   switch (opcode & 0x3F)
129121   {
r9922r9923
143135   case 0x39: // NOP();
144136   case 0x3a: // NOP();
145137   case 0x3b: // NOP();
146      return TRUE;
138      return true;
147139
148140   case 0x02: // STCSR(Rn);
149      desc->regout[0] |= REGFLAG_R(Rn);
150      return TRUE;
141      desc.regout[0] |= REGFLAG_R(Rn);
142      return true;
151143
152144   case 0x03: // BSRF(Rn);
153      desc->regout[1] |= REGFLAG_PR;
145      desc.regout[1] |= REGFLAG_PR;
154146
155      desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
156      desc->targetpc = BRANCH_TARGET_DYNAMIC;
157      desc->delayslots = 1;
147      desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
148      desc.targetpc = BRANCH_TARGET_DYNAMIC;
149      desc.delayslots = 1;
158150
159      return TRUE;
151      return true;
160152
161153   case 0x04: // MOVBS0(Rm, Rn);
162154   case 0x05: // MOVWS0(Rm, Rn);
r9922r9923
170162   case 0x34: // MOVBS0(Rm, Rn);
171163   case 0x35: // MOVWS0(Rm, Rn);
172164   case 0x36: // MOVLS0(Rm, Rn);
173      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn) | REGFLAG_R(0);
174      desc->flags |= OPFLAG_READS_MEMORY;
175      return TRUE;
165      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn) | REGFLAG_R(0);
166      desc.flags |= OPFLAG_READS_MEMORY;
167      return true;
176168
177169   case 0x07: // MULL(Rm, Rn);
178170   case 0x17: // MULL(Rm, Rn);
179171   case 0x27: // MULL(Rm, Rn);
180172   case 0x37: // MULL(Rm, Rn);
181      desc->regin[0] |= REGFLAG_R(Rn) | REGFLAG_R(Rm);
182      desc->regout[1] |= REGFLAG_MACL;
183      desc->cycles = 2;
184      return TRUE;
173      desc.regin[0] |= REGFLAG_R(Rn) | REGFLAG_R(Rm);
174      desc.regout[1] |= REGFLAG_MACL;
175      desc.cycles = 2;
176      return true;
185177
186178   case 0x08: // CLRT();
187      desc->regout[1] |= REGFLAG_SR;
188      return TRUE;
179      desc.regout[1] |= REGFLAG_SR;
180      return true;
189181
190182   case 0x0a: // STSMACH(Rn);
191      desc->regout[0] |= REGFLAG_R(Rn);
192      desc->regout[1] |= REGFLAG_MACH;
193      return TRUE;
183      desc.regout[0] |= REGFLAG_R(Rn);
184      desc.regout[1] |= REGFLAG_MACH;
185      return true;
194186
195187   case 0x0b: // RTS();
196      desc->regin[1] |= REGFLAG_PR;
188      desc.regin[1] |= REGFLAG_PR;
197189
198      desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
199      desc->targetpc = BRANCH_TARGET_DYNAMIC;
200      desc->delayslots = 1;
201      desc->cycles = 2;
190      desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
191      desc.targetpc = BRANCH_TARGET_DYNAMIC;
192      desc.delayslots = 1;
193      desc.cycles = 2;
202194
203      return TRUE;
195      return true;
204196
205197   case 0x0c: // MOVBL0(Rm, Rn);
206198   case 0x0d: // MOVWL0(Rm, Rn);
r9922r9923
214206   case 0x3c: // MOVBL0(Rm, Rn);
215207   case 0x3d: // MOVWL0(Rm, Rn);
216208   case 0x3e: // MOVLL0(Rm, Rn);
217      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(0);
218      desc->regout[0] |= REGFLAG_R(Rn);
219      desc->flags |= OPFLAG_READS_MEMORY;
220      return TRUE;
209      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(0);
210      desc.regout[0] |= REGFLAG_R(Rn);
211      desc.flags |= OPFLAG_READS_MEMORY;
212      return true;
221213
222214   case 0x0f: // MAC_L(Rm, Rn);
223215   case 0x1f: // MAC_L(Rm, Rn);
224216   case 0x2f: // MAC_L(Rm, Rn);
225217   case 0x3f: // MAC_L(Rm, Rn);
226      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
227      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
228      desc->cycles = 3;
229      return TRUE;
218      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
219      desc.regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
220      desc.cycles = 3;
221      return true;
230222
231223   case 0x12: // STCGBR(Rn);
232      desc->regout[0] |= REGFLAG_R(Rn);
233      desc->regin[1] |= REGFLAG_GBR;
234      return TRUE;
224      desc.regout[0] |= REGFLAG_R(Rn);
225      desc.regin[1] |= REGFLAG_GBR;
226      return true;
235227
236228   case 0x18: // SETT();
237      desc->regout[1] |= REGFLAG_SR;
238      return TRUE;
229      desc.regout[1] |= REGFLAG_SR;
230      return true;
239231
240232   case 0x19: // DIV0U();
241      desc->regout[1] |= REGFLAG_SR;
242      return TRUE;
233      desc.regout[1] |= REGFLAG_SR;
234      return true;
243235
244236   case 0x1a: // STSMACL(Rn);
245      desc->regin[1] |= REGFLAG_MACL;
246      desc->regout[0] |= REGFLAG_R(Rn);
247      return TRUE;
237      desc.regin[1] |= REGFLAG_MACL;
238      desc.regout[0] |= REGFLAG_R(Rn);
239      return true;
248240
249241   case 0x1b: // SLEEP();
250      desc->cycles = 3;
251      return TRUE;
242      desc.cycles = 3;
243      return true;
252244
253245   case 0x22: // STCVBR(Rn);
254      desc->regin[0] |= REGFLAG_R(Rn);
255      desc->regout[1] |= REGFLAG_VBR;
256      return TRUE;
246      desc.regin[0] |= REGFLAG_R(Rn);
247      desc.regout[1] |= REGFLAG_VBR;
248      return true;
257249
258250   case 0x23: // BRAF(Rn);
259      desc->regin[0] |= REGFLAG_R(Rm);
260      desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
261      desc->targetpc = BRANCH_TARGET_DYNAMIC;
262      desc->delayslots = 1;
263      desc->cycles = 2;
264      return TRUE;
251      desc.regin[0] |= REGFLAG_R(Rm);
252      desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
253      desc.targetpc = BRANCH_TARGET_DYNAMIC;
254      desc.delayslots = 1;
255      desc.cycles = 2;
256      return true;
265257
266258   case 0x28: // CLRMAC();
267      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
268      return TRUE;
259      desc.regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
260      return true;
269261
270262   case 0x29: // MOVT(Rn);
271      desc->regin[1] |= REGFLAG_SR;
272      desc->regout[0] |= REGFLAG_R(Rn);
273      return TRUE;
263      desc.regin[1] |= REGFLAG_SR;
264      desc.regout[0] |= REGFLAG_R(Rn);
265      return true;
274266
275267   case 0x2a: // STSPR(Rn);
276      desc->regin[1] |= REGFLAG_PR;
277      desc->regout[0] |= REGFLAG_R(Rn);
278      return TRUE;
268      desc.regin[1] |= REGFLAG_PR;
269      desc.regout[0] |= REGFLAG_R(Rn);
270      return true;
279271
280272   case 0x2b: // RTE();
281      desc->regin[0] |= REGFLAG_R(15);
282      desc->regout[0] |= REGFLAG_R(15);
273      desc.regin[0] |= REGFLAG_R(15);
274      desc.regout[0] |= REGFLAG_R(15);
283275
284      desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
285      desc->targetpc = BRANCH_TARGET_DYNAMIC;
286      desc->delayslots = 1;
287      desc->cycles = 4;
276      desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE | OPFLAG_CAN_EXPOSE_EXTERNAL_INT;
277      desc.targetpc = BRANCH_TARGET_DYNAMIC;
278      desc.delayslots = 1;
279      desc.cycles = 4;
288280
289      return TRUE;
281      return true;
290282   }
291283
292   return FALSE;
284   return false;
293285}
294286
295static int describe_group_2(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
287bool sh2_frontend::describe_group_2(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
296288{
297289   switch (opcode & 15)
298290   {
299291   case  0: // MOVBS(Rm, Rn);
300292   case  1: // MOVWS(Rm, Rn);
301293   case  2: // MOVLS(Rm, Rn);
302      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
303      desc->flags |= OPFLAG_WRITES_MEMORY;
304      return TRUE;
294      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
295      desc.flags |= OPFLAG_WRITES_MEMORY;
296      return true;
305297
306298   case  3: // NOP();
307      return TRUE;
299      return true;
308300
309301   case  4: // MOVBM(Rm, Rn);
310302   case  5: // MOVWM(Rm, Rn);
311303   case  6: // MOVLM(Rm, Rn);
312304   case 13: // XTRCT(Rm, Rn);
313      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
314      desc->regout[0] |= REGFLAG_R(Rn);
315      desc->flags |= OPFLAG_WRITES_MEMORY;
316      return TRUE;
305      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
306      desc.regout[0] |= REGFLAG_R(Rn);
307      desc.flags |= OPFLAG_WRITES_MEMORY;
308      return true;
317309
318310   case  7: // DIV0S(Rm, Rn);
319311   case  8: // TST(Rm, Rn);
320312   case 12: // CMPSTR(Rm, Rn);
321      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
322      desc->regout[1] |= REGFLAG_SR;
323      return TRUE;
313      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
314      desc.regout[1] |= REGFLAG_SR;
315      return true;
324316
325317   case  9: // AND(Rm, Rn);
326318   case 10: // XOR(Rm, Rn);
327319   case 11: // OR(Rm, Rn);
328      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
329      desc->regout[0] |= REGFLAG_R(Rn);
330      return TRUE;
320      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
321      desc.regout[0] |= REGFLAG_R(Rn);
322      return true;
331323
332324   case 14: // MULU(Rm, Rn);
333325   case 15: // MULS(Rm, Rn);
334      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
335      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
336      desc->cycles = 2;
337      return TRUE;
326      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
327      desc.regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
328      desc.cycles = 2;
329      return true;
338330   }
339331
340   return FALSE;
332   return false;
341333}
342334
343static int describe_group_3(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
335bool sh2_frontend::describe_group_3(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
344336{
345337   switch (opcode & 15)
346338   {
r9922r9923
349341   case  3: // CMPGE(Rm, Rn);
350342   case  6: // CMPHI(Rm, Rn);
351343   case  7: // CMPGT(Rm, Rn);
352      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
353      desc->regout[1] |= REGFLAG_SR;
354      return TRUE;
344      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
345      desc.regout[1] |= REGFLAG_SR;
346      return true;
355347
356348   case  1: // NOP();
357349   case  9: // NOP();
358      return TRUE;
350      return true;
359351
360352   case  4: // DIV1(Rm, Rn);
361      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
362      desc->regout[0] |= REGFLAG_R(Rn);
363      desc->regout[1] |= REGFLAG_SR;
364      return TRUE;
353      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
354      desc.regout[0] |= REGFLAG_R(Rn);
355      desc.regout[1] |= REGFLAG_SR;
356      return true;
365357
366358   case  5: // DMULU(Rm, Rn);
367359   case 13: // DMULS(Rm, Rn);
368      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
369      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
370      desc->cycles = 2;
371      return TRUE;
360      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
361      desc.regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
362      desc.cycles = 2;
363      return true;
372364
373365   case  8: // SUB(Rm, Rn);
374366   case 12: // ADD(Rm, Rn);
375      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
376      desc->regout[0] |= REGFLAG_R(Rn);
377      return TRUE;
367      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
368      desc.regout[0] |= REGFLAG_R(Rn);
369      return true;
378370
379371   case 10: // SUBC(Rm, Rn);
380372   case 11: // SUBV(Rm, Rn);
381373   case 14: // ADDC(Rm, Rn);
382374   case 15: // ADDV(Rm, Rn);
383      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
384      desc->regin[1] |= REGFLAG_SR;
385      desc->regout[0] |= REGFLAG_R(Rn);
386      desc->regout[1] |= REGFLAG_SR;
387      return TRUE;
375      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
376      desc.regin[1] |= REGFLAG_SR;
377      desc.regout[0] |= REGFLAG_R(Rn);
378      desc.regout[1] |= REGFLAG_SR;
379      return true;
388380   }
389   return FALSE;
381   return false;
390382}
391383
392static int describe_group_4(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
384bool sh2_frontend::describe_group_4(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
393385{
394386   switch (opcode & 0x3F)
395387   {
r9922r9923
397389   case 0x01: // SHLR(Rn);
398390   case 0x04: // ROTL(Rn);
399391   case 0x05: // ROTR(Rn);
400      desc->regin[0] |= REGFLAG_R(Rn);
401      desc->regout[0] |= REGFLAG_R(Rn);
402      desc->regout[1] |= REGFLAG_SR;
403      return TRUE;
392      desc.regin[0] |= REGFLAG_R(Rn);
393      desc.regout[0] |= REGFLAG_R(Rn);
394      desc.regout[1] |= REGFLAG_SR;
395      return true;
404396
405397   case 0x02: // STSMMACH(Rn);
406      desc->regin[0] |= REGFLAG_R(Rn);
407      desc->regin[1] |= REGFLAG_MACH;
408      desc->regout[0] |= REGFLAG_R(Rn);
409      desc->flags |= OPFLAG_WRITES_MEMORY;
410      return TRUE;
398      desc.regin[0] |= REGFLAG_R(Rn);
399      desc.regin[1] |= REGFLAG_MACH;
400      desc.regout[0] |= REGFLAG_R(Rn);
401      desc.flags |= OPFLAG_WRITES_MEMORY;
402      return true;
411403
412404   case 0x03: // STCMSR(Rn);
413      desc->regin[0] |= REGFLAG_R(Rn);
414      desc->regout[0] |= REGFLAG_R(Rn);
415      desc->cycles = 2;
416      desc->flags |= OPFLAG_WRITES_MEMORY;
417      return TRUE;
405      desc.regin[0] |= REGFLAG_R(Rn);
406      desc.regout[0] |= REGFLAG_R(Rn);
407      desc.cycles = 2;
408      desc.flags |= OPFLAG_WRITES_MEMORY;
409      return true;
418410
419411   case 0x06: // LDSMMACH(Rn);
420      desc->regin[0] |= REGFLAG_R(Rn);
421      desc->regout[0] |= REGFLAG_R(Rn);
422      desc->regout[1] |= REGFLAG_MACH;
423      desc->flags |= OPFLAG_READS_MEMORY;
424      return TRUE;
412      desc.regin[0] |= REGFLAG_R(Rn);
413      desc.regout[0] |= REGFLAG_R(Rn);
414      desc.regout[1] |= REGFLAG_MACH;
415      desc.flags |= OPFLAG_READS_MEMORY;
416      return true;
425417
426418   case 0x07: // LDCMSR(Rn);
427      desc->regin[0] |= REGFLAG_R(Rn);
428      desc->regout[0] |= REGFLAG_R(Rn);
429      desc->regout[1] |= REGFLAG_SR;
430      desc->cycles = 3;
431      desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_END_SEQUENCE;
432      return TRUE;
419      desc.regin[0] |= REGFLAG_R(Rn);
420      desc.regout[0] |= REGFLAG_R(Rn);
421      desc.regout[1] |= REGFLAG_SR;
422      desc.cycles = 3;
423      desc.flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_END_SEQUENCE;
424      return true;
433425
434426   case 0x08: // SHLL2(Rn);
435427   case 0x09: // SHLR2(Rn);
r9922r9923
437429   case 0x19: // SHLR8(Rn);
438430   case 0x28: // SHLL16(Rn);
439431   case 0x29: // SHLR16(Rn);
440      desc->regin[0] |= REGFLAG_R(Rn);
441      desc->regout[0] |= REGFLAG_R(Rn);
442      return TRUE;
432      desc.regin[0] |= REGFLAG_R(Rn);
433      desc.regout[0] |= REGFLAG_R(Rn);
434      return true;
443435
444436   case 0x0a: // LDSMACH(Rn);
445      desc->regin[0] |= REGFLAG_R(Rn);
446      desc->regout[1] |= REGFLAG_MACH;
447      return TRUE;
437      desc.regin[0] |= REGFLAG_R(Rn);
438      desc.regout[1] |= REGFLAG_MACH;
439      return true;
448440
449441   case 0x0b: // JSR(Rn);
450      desc->regin[0] |= REGFLAG_R(Rn);
451      desc->regout[1] |= REGFLAG_PR;
452      desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
453      desc->targetpc = BRANCH_TARGET_DYNAMIC;
454      desc->delayslots = 1;
455      return TRUE;
442      desc.regin[0] |= REGFLAG_R(Rn);
443      desc.regout[1] |= REGFLAG_PR;
444      desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
445      desc.targetpc = BRANCH_TARGET_DYNAMIC;
446      desc.delayslots = 1;
447      return true;
456448
457449   case 0x0e: // LDCSR(Rn);
458      desc->regin[0] |= REGFLAG_R(Rn);
459      desc->regout[1] |= REGFLAG_SR;
460      desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_END_SEQUENCE;
461      return TRUE;
450      desc.regin[0] |= REGFLAG_R(Rn);
451      desc.regout[1] |= REGFLAG_SR;
452      desc.flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_END_SEQUENCE;
453      return true;
462454
463455   case 0x0f: // MAC_W(Rm, Rn);
464456   case 0x1f: // MAC_W(Rm, Rn);
465457   case 0x2f: // MAC_W(Rm, Rn);
466458   case 0x3f: // MAC_W(Rm, Rn);
467      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
468      desc->regin[1] |= REGFLAG_MACL | REGFLAG_MACH;
469      desc->regout[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
470      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
471      desc->cycles = 3;
472      return TRUE;
459      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
460      desc.regin[1] |= REGFLAG_MACL | REGFLAG_MACH;
461      desc.regout[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
462      desc.regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
463      desc.cycles = 3;
464      return true;
473465
474466   case 0x10: // DT(Rn);
475      desc->regin[0] |= REGFLAG_R(Rn);
476      desc->regin[1] |= REGFLAG_SR;
477      desc->regout[0] |= REGFLAG_R(Rn);
478      desc->regout[1] |= REGFLAG_SR;
479      return TRUE;
467      desc.regin[0] |= REGFLAG_R(Rn);
468      desc.regin[1] |= REGFLAG_SR;
469      desc.regout[0] |= REGFLAG_R(Rn);
470      desc.regout[1] |= REGFLAG_SR;
471      return true;
480472
481473   case 0x11: // CMPPZ(Rn);
482474   case 0x15: // CMPPL(Rn);
483      desc->regin[0] |= REGFLAG_R(Rn);
484      desc->regin[1] |= REGFLAG_SR;
485      desc->regout[1] |= REGFLAG_SR;
486      return TRUE;
475      desc.regin[0] |= REGFLAG_R(Rn);
476      desc.regin[1] |= REGFLAG_SR;
477      desc.regout[1] |= REGFLAG_SR;
478      return true;
487479
488480   case 0x12: // STSMMACL(Rn);
489      desc->regin[0] |= REGFLAG_R(Rn);
490      desc->regin[1] |= REGFLAG_MACL;
491      desc->regout[0] |= REGFLAG_R(Rn);
492      desc->flags |= OPFLAG_WRITES_MEMORY;
493      return TRUE;
481      desc.regin[0] |= REGFLAG_R(Rn);
482      desc.regin[1] |= REGFLAG_MACL;
483      desc.regout[0] |= REGFLAG_R(Rn);
484      desc.flags |= OPFLAG_WRITES_MEMORY;
485      return true;
494486
495487   case 0x13: // STCMGBR(Rn);
496      desc->regin[0] |= REGFLAG_R(Rn);
497      desc->regin[1] |= REGFLAG_GBR;
498      desc->regout[0] |= REGFLAG_R(Rn);
499      desc->flags |= OPFLAG_WRITES_MEMORY;
500      return TRUE;
488      desc.regin[0] |= REGFLAG_R(Rn);
489      desc.regin[1] |= REGFLAG_GBR;
490      desc.regout[0] |= REGFLAG_R(Rn);
491      desc.flags |= OPFLAG_WRITES_MEMORY;
492      return true;
501493
502494   case 0x16: // LDSMMACL(Rn);
503      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
504      desc->regout[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
505      desc->regout[1] |= REGFLAG_MACL;
506      desc->flags |= OPFLAG_READS_MEMORY;
507      return TRUE;
495      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
496      desc.regout[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
497      desc.regout[1] |= REGFLAG_MACL;
498      desc.flags |= OPFLAG_READS_MEMORY;
499      return true;
508500
509501   case 0x17: // LDCMGBR(Rn);
510      desc->regin[0] |= REGFLAG_R(Rn);
511      desc->regout[0] |= REGFLAG_R(Rn);
512      desc->regout[1] |= REGFLAG_GBR;
513      desc->flags |= OPFLAG_READS_MEMORY;
514      return TRUE;
502      desc.regin[0] |= REGFLAG_R(Rn);
503      desc.regout[0] |= REGFLAG_R(Rn);
504      desc.regout[1] |= REGFLAG_GBR;
505      desc.flags |= OPFLAG_READS_MEMORY;
506      return true;
515507
516508   case 0x1a: // LDSMACL(Rn);
517      desc->regin[0] |= REGFLAG_R(Rn);
518      desc->regout[1] |= REGFLAG_MACL;
519      return TRUE;
509      desc.regin[0] |= REGFLAG_R(Rn);
510      desc.regout[1] |= REGFLAG_MACL;
511      return true;
520512
521513   case 0x1b: // TAS(Rn);
522      desc->regin[0] |= REGFLAG_R(Rn);
523      desc->regin[1] |= REGFLAG_SR;
524      desc->regout[1] |= REGFLAG_SR;
525      desc->cycles = 4;
526      desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_WRITES_MEMORY;
527      return TRUE;
514      desc.regin[0] |= REGFLAG_R(Rn);
515      desc.regin[1] |= REGFLAG_SR;
516      desc.regout[1] |= REGFLAG_SR;
517      desc.cycles = 4;
518      desc.flags |= OPFLAG_READS_MEMORY | OPFLAG_WRITES_MEMORY;
519      return true;
528520
529521   case 0x1e: // LDCGBR(Rn);
530      desc->regin[0] |= REGFLAG_R(Rn);
531      desc->regout[1] |= REGFLAG_GBR;
532      return TRUE;
522      desc.regin[0] |= REGFLAG_R(Rn);
523      desc.regout[1] |= REGFLAG_GBR;
524      return true;
533525
534526   case 0x20: // SHAL(Rn);
535527   case 0x21: // SHAR(Rn);
536      desc->regin[0] |= REGFLAG_R(Rn);
537      desc->regout[0] |= REGFLAG_R(Rn);
538      desc->regout[1] |= REGFLAG_SR;
539      return TRUE;
528      desc.regin[0] |= REGFLAG_R(Rn);
529      desc.regout[0] |= REGFLAG_R(Rn);
530      desc.regout[1] |= REGFLAG_SR;
531      return true;
540532
541533   case 0x22: // STSMPR(Rn);
542      desc->regin[0] |= REGFLAG_R(Rn);
543      desc->regin[1] |= REGFLAG_PR;
544      desc->regout[0] |= REGFLAG_R(Rn);
545      desc->flags |= OPFLAG_WRITES_MEMORY;
546      return TRUE;
534      desc.regin[0] |= REGFLAG_R(Rn);
535      desc.regin[1] |= REGFLAG_PR;
536      desc.regout[0] |= REGFLAG_R(Rn);
537      desc.flags |= OPFLAG_WRITES_MEMORY;
538      return true;
547539
548540   case 0x23: // STCMVBR(Rn);
549      desc->regin[0] |= REGFLAG_R(Rn);
550      desc->regin[1] |= REGFLAG_VBR;
551      desc->regout[0] |= REGFLAG_R(Rn);
552      desc->flags |= OPFLAG_WRITES_MEMORY;
553      return TRUE;
541      desc.regin[0] |= REGFLAG_R(Rn);
542      desc.regin[1] |= REGFLAG_VBR;
543      desc.regout[0] |= REGFLAG_R(Rn);
544      desc.flags |= OPFLAG_WRITES_MEMORY;
545      return true;
554546
555547   case 0x24: // ROTCL(Rn);
556548   case 0x25: // ROTCR(Rn);
557      desc->regin[0] |= REGFLAG_R(Rn);
558      desc->regin[1] |= REGFLAG_SR;
559      desc->regout[0] |= REGFLAG_R(Rn);
560      desc->regout[1] |= REGFLAG_SR;
561      return TRUE;
549      desc.regin[0] |= REGFLAG_R(Rn);
550      desc.regin[1] |= REGFLAG_SR;
551      desc.regout[0] |= REGFLAG_R(Rn);
552      desc.regout[1] |= REGFLAG_SR;
553      return true;
562554
563555   case 0x26: // LDSMPR(Rn);
564      desc->regin[0] |= REGFLAG_R(Rn);
565      desc->regout[0] |= REGFLAG_R(Rn);
566      desc->regout[1] |= REGFLAG_PR;
567      desc->flags |= OPFLAG_READS_MEMORY;
568      return TRUE;
556      desc.regin[0] |= REGFLAG_R(Rn);
557      desc.regout[0] |= REGFLAG_R(Rn);
558      desc.regout[1] |= REGFLAG_PR;
559      desc.flags |= OPFLAG_READS_MEMORY;
560      return true;
569561
570562   case 0x27: // LDCMVBR(Rn);
571      desc->regin[0] |= REGFLAG_R(Rn);
572      desc->regout[0] |= REGFLAG_R(Rn);
573      desc->regout[1] |= REGFLAG_VBR;
574      desc->flags |= OPFLAG_READS_MEMORY;
575      return TRUE;
563      desc.regin[0] |= REGFLAG_R(Rn);
564      desc.regout[0] |= REGFLAG_R(Rn);
565      desc.regout[1] |= REGFLAG_VBR;
566      desc.flags |= OPFLAG_READS_MEMORY;
567      return true;
576568
577569   case 0x2a: // LDSPR(Rn);
578      desc->regin[0] |= REGFLAG_R(Rn);
579      desc->regout[1] |= REGFLAG_PR;
580      return TRUE;
570      desc.regin[0] |= REGFLAG_R(Rn);
571      desc.regout[1] |= REGFLAG_PR;
572      return true;
581573
582574   case 0x2b: // JMP(Rm);
583      desc->regin[0] |= REGFLAG_R(Rm);
584      desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
585      desc->targetpc = BRANCH_TARGET_DYNAMIC;
586      desc->delayslots = 1;
587      return TRUE;
575      desc.regin[0] |= REGFLAG_R(Rm);
576      desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
577      desc.targetpc = BRANCH_TARGET_DYNAMIC;
578      desc.delayslots = 1;
579      return true;
588580
589581   case 0x2e: // LDCVBR(Rn);
590      desc->regin[0] |= REGFLAG_R(Rn);
591      desc->regout[1] |= REGFLAG_VBR;
592      return TRUE;
582      desc.regin[0] |= REGFLAG_R(Rn);
583      desc.regout[1] |= REGFLAG_VBR;
584      return true;
593585
594586   case 0x0c: // NOP();
595587   case 0x0d: // NOP();
r9922r9923
613605   case 0x3c: // NOP();
614606   case 0x3d: // NOP();
615607   case 0x3e: // NOP();
616      return TRUE;
608      return true;
617609   }
618610
619   return FALSE;
611   return false;
620612}
621613
622static int describe_group_6(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
614bool sh2_frontend::describe_group_6(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
623615{
624616   switch (opcode & 15)
625617   {
r9922r9923
634626   case 13: // EXTUW(Rm, Rn);
635627   case 14: // EXTSB(Rm, Rn);
636628   case 15: // EXTSW(Rm, Rn);
637      desc->regin[0] |= REGFLAG_R(Rm);
638      desc->regout[0] |= REGFLAG_R(Rn);
639      return TRUE;
629      desc.regin[0] |= REGFLAG_R(Rm);
630      desc.regout[0] |= REGFLAG_R(Rn);
631      return true;
640632
641633   case  4: // MOVBP(Rm, Rn);
642634   case  5: // MOVWP(Rm, Rn);
643635   case  6: // MOVLP(Rm, Rn);
644      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
645      desc->regout[0] |= REGFLAG_R(Rn);
646      desc->flags |= OPFLAG_READS_MEMORY;
647      return TRUE;
636      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
637      desc.regout[0] |= REGFLAG_R(Rn);
638      desc.flags |= OPFLAG_READS_MEMORY;
639      return true;
648640
649641   case  8: // SWAPB(Rm, Rn);
650      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
651      desc->regout[0] |= REGFLAG_R(Rn);
652      return TRUE;
642      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
643      desc.regout[0] |= REGFLAG_R(Rn);
644      return true;
653645
654646   case 10: // NEGC(Rm, Rn);
655      desc->regin[0] |= REGFLAG_R(Rm);
656      desc->regout[0] |= REGFLAG_R(Rn);
657      desc->regout[1] |= REGFLAG_SR;
658      return TRUE;
647      desc.regin[0] |= REGFLAG_R(Rm);
648      desc.regout[0] |= REGFLAG_R(Rn);
649      desc.regout[1] |= REGFLAG_SR;
650      return true;
659651   }
660   return FALSE;
652   return false;
661653}
662654
663static int describe_group_8(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
655bool sh2_frontend::describe_group_8(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
664656{
665657   INT32 disp;
666658
r9922r9923
668660   {
669661   case  0 << 8: // MOVBS4(opcode & 0x0f, Rm);
670662   case  1 << 8: // MOVWS4(opcode & 0x0f, Rm);
671      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(0);
672      desc->flags |= OPFLAG_WRITES_MEMORY;
673      return TRUE;
663      desc.regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(0);
664      desc.flags |= OPFLAG_WRITES_MEMORY;
665      return true;
674666
675667   case  2<< 8: // NOP();
676668   case  3<< 8: // NOP();
r9922r9923
679671   case 10<< 8: // NOP();
680672   case 12<< 8: // NOP();
681673   case 14<< 8: // NOP();
682      return TRUE;
674      return true;
683675
684676   case  4<< 8: // MOVBL4(Rm, opcode & 0x0f);
685677   case  5<< 8: // MOVWL4(Rm, opcode & 0x0f);
686      desc->regin[0] |= REGFLAG_R(Rm);
687      desc->regout[0] |= REGFLAG_R(0);
688      desc->flags |= OPFLAG_READS_MEMORY;
689      return TRUE;
678      desc.regin[0] |= REGFLAG_R(Rm);
679      desc.regout[0] |= REGFLAG_R(0);
680      desc.flags |= OPFLAG_READS_MEMORY;
681      return true;
690682
691683   case  8<< 8: // CMPIM(opcode & 0xff);
692      desc->regin[0] |= REGFLAG_R(Rm);
693      desc->regin[1] |= REGFLAG_SR;
694      desc->regout[1] |= REGFLAG_SR;
695      return TRUE;
684      desc.regin[0] |= REGFLAG_R(Rm);
685      desc.regin[1] |= REGFLAG_SR;
686      desc.regout[1] |= REGFLAG_SR;
687      return true;
696688
697689   case  9<< 8: // BT(opcode & 0xff);
698690   case 11<< 8: // BF(opcode & 0xff);
699      desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
700      desc->cycles = 3;
691      desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
692      desc.cycles = 3;
701693      disp = ((INT32)opcode << 24) >> 24;
702      desc->targetpc = (desc->pc + 2) + disp * 2 + 2;
703      return TRUE;
694      desc.targetpc = (desc.pc + 2) + disp * 2 + 2;
695      return true;
704696
705697   case 13<< 8: // BTS(opcode & 0xff);
706698   case 15<< 8: // BFS(opcode & 0xff);
707      desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
708      desc->cycles = 2;
699      desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
700      desc.cycles = 2;
709701      disp = ((INT32)opcode << 24) >> 24;
710      desc->targetpc = (desc->pc + 2) + disp * 2 + 2;
711      desc->delayslots = 1;
712      return TRUE;
702      desc.targetpc = (desc.pc + 2) + disp * 2 + 2;
703      desc.delayslots = 1;
704      return true;
713705   }
714706
715   return FALSE;
707   return false;
716708}
717709
718static int describe_group_12(sh2_state *context, opcode_desc *desc, const opcode_desc *prev, UINT16 opcode)
710bool sh2_frontend::describe_group_12(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode)
719711{
720712   switch (opcode & (15<<8))
721713   {
722714   case  0<<8: // MOVBSG(opcode & 0xff);
723715   case  1<<8: // MOVWSG(opcode & 0xff);
724716   case  2<<8: // MOVLSG(opcode & 0xff);
725      desc->regin[0] |= REGFLAG_R(0);
726      desc->flags |= OPFLAG_WRITES_MEMORY;
727      return TRUE;
717      desc.regin[0] |= REGFLAG_R(0);
718      desc.flags |= OPFLAG_WRITES_MEMORY;
719      return true;
728720
729721   case  3<<8: // TRAPA(opcode & 0xff);
730      desc->regin[0] |= REGFLAG_R(15);
731      desc->regin[1] |= REGFLAG_VBR;
732      desc->regout[0] |= REGFLAG_R(15);
733      desc->cycles = 8;
734      desc->targetpc = BRANCH_TARGET_DYNAMIC;
735      desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
736      return TRUE;
722      desc.regin[0] |= REGFLAG_R(15);
723      desc.regin[1] |= REGFLAG_VBR;
724      desc.regout[0] |= REGFLAG_R(15);
725      desc.cycles = 8;
726      desc.targetpc = BRANCH_TARGET_DYNAMIC;
727      desc.flags |= OPFLAG_READS_MEMORY | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
728      return true;
737729
738730   case  4<<8: // MOVBLG(opcode & 0xff);
739731   case  5<<8: // MOVWLG(opcode & 0xff);
740732   case  6<<8: // MOVLLG(opcode & 0xff);
741733   case  7<<8: // MOVA(opcode & 0xff);
742      desc->regout[0] |= REGFLAG_R(0);
743      desc->flags |= OPFLAG_READS_MEMORY;
744      return TRUE;
734      desc.regout[0] |= REGFLAG_R(0);
735      desc.flags |= OPFLAG_READS_MEMORY;
736      return true;
745737
746738   case  8<<8: // TSTI(opcode & 0xff);
747      desc->regin[0] |= REGFLAG_R(0);
748      desc->regin[1] |= REGFLAG_SR;
749      desc->regout[1] |= REGFLAG_SR;
750      return TRUE;
739      desc.regin[0] |= REGFLAG_R(0);
740      desc.regin[1] |= REGFLAG_SR;
741      desc.regout[1] |= REGFLAG_SR;
742      return true;
751743
752744   case  9<<8: // ANDI(opcode & 0xff);
753745   case 10<<8: // XORI(opcode & 0xff);
754746   case 11<<8: // ORI(opcode & 0xff);
755      desc->regin[0] |= REGFLAG_R(0);
756      desc->regout[0] |= REGFLAG_R(0);
757      return TRUE;
747      desc.regin[0] |= REGFLAG_R(0);
748      desc.regout[0] |= REGFLAG_R(0);
749      return true;
758750
759751   case 12<<8: // TSTM(opcode & 0xff);
760752   case 13<<8: // ANDM(opcode & 0xff);
761753   case 14<<8: // XORM(opcode & 0xff);
762754   case 15<<8: // ORM(opcode & 0xff);
763      desc->regin[0] |= REGFLAG_R(0);
764      desc->regin[1] |= REGFLAG_SR | REGFLAG_GBR;
765      desc->regout[1] |= REGFLAG_SR;
766      desc->flags |= OPFLAG_READS_MEMORY;
767      return TRUE;
755      desc.regin[0] |= REGFLAG_R(0);
756      desc.regin[1] |= REGFLAG_SR | REGFLAG_GBR;
757      desc.regout[1] |= REGFLAG_SR;
758      desc.flags |= OPFLAG_READS_MEMORY;
759      return true;
768760   }
769761
770   return FALSE;
762   return false;
771763}
772764
src/emu/cpu/nec/necdasm.c
r9922r9923
11051105         break;
11061106
11071107      case PARAM_SFREG:
1108         d8 = FETCHD();
1109         s += sprintf( s, "%s", nec_sfreg[d8] );
1108         i8 = FETCHD();
1109         s += sprintf( s, "%s", nec_sfreg[i8] );
11101110         break;
11111111
11121112      case PARAM_1:
src/emu/cpu/mips/mips3fe.c
r9922r9923
44
55    Front-end for MIPS3 recompiler
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138***************************************************************************/
1239
1340#include "emu.h"
r9922r9923
1542#include "mips3com.h"
1643
1744
18/***************************************************************************
19    FUNCTION PROTOTYPES
20***************************************************************************/
45//**************************************************************************
46//  MIPS3 FRONTEND
47//**************************************************************************
2148
22static int describe_instruction_special(mips3_state *mips, UINT32 op, opcode_desc *desc);
23static int describe_instruction_regimm(mips3_state *mips, UINT32 op, opcode_desc *desc);
24static int describe_instruction_idt(mips3_state *mips, UINT32 op, opcode_desc *desc);
25static int describe_instruction_cop0(mips3_state *mips, UINT32 op, opcode_desc *desc);
26static int describe_instruction_cop1(mips3_state *mips, UINT32 op, opcode_desc *desc);
27static int describe_instruction_cop1x(mips3_state *mips, UINT32 op, opcode_desc *desc);
28static int describe_instruction_cop2(mips3_state *mips, UINT32 op, opcode_desc *desc);
49//-------------------------------------------------
50//  mips3_frontend - constructor
51//-------------------------------------------------
2952
53mips3_frontend::mips3_frontend(mips3_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence)
54   : drc_frontend(*state.device, window_start, window_end, max_sequence),
55     m_context(state)
56{
57}
3058
3159
32/***************************************************************************
33    INSTRUCTION PARSERS
34***************************************************************************/
60//-------------------------------------------------
61//  describe - build a description of a single
62//  instruction
63//-------------------------------------------------
3564
36/*-------------------------------------------------
37    describe_instruction - build a description
38    of a single instruction
39-------------------------------------------------*/
40
41int mips3fe_describe(void *param, opcode_desc *desc, const opcode_desc *prev)
65bool mips3_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
4266{
43   mips3_state *mips = (mips3_state *)param;
4467   UINT32 op, opswitch;
4568
46   /* compute the physical PC */
47   assert((desc->physpc & 3) == 0);
48   if (!mips3com_translate_address(mips, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc->physpc))
69   // compute the physical PC
70   assert((desc.physpc & 3) == 0);
71   if (!mips3com_translate_address(&m_context, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc.physpc))
4972   {
50      /* uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and */
51      /* mark as needing to validate; otherwise, just end the sequence here */
52      desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE;
53      return TRUE;
73      // uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and
74      // mark as needing to validate; otherwise, just end the sequence here
75      desc.flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE;
76      return true;
5477   }
5578
56   /* fetch the opcode */
57   assert((desc->physpc & 3) == 0);
58   op = desc->opptr.l[0] = mips->direct->read_decrypted_dword(desc->physpc);
79   // fetch the opcode
80   assert((desc.physpc & 3) == 0);
81   op = desc.opptr.l[0] = m_context.direct->read_decrypted_dword(desc.physpc);
5982
60   /* all instructions are 4 bytes and default to a single cycle each */
61   desc->length = 4;
62   desc->cycles = 1;
83   // all instructions are 4 bytes and default to a single cycle each
84   desc.length = 4;
85   desc.cycles = 1;
6386
64   /* parse the instruction */
87   // parse the instruction
6588   opswitch = op >> 26;
6689   switch (opswitch)
6790   {
68      case 0x00:   /* SPECIAL */
69         return describe_instruction_special(mips, op, desc);
91      case 0x00:   // SPECIAL
92         return describe_special(op, desc);
7093
71      case 0x01:   /* REGIMM */
72         return describe_instruction_regimm(mips, op, desc);
94      case 0x01:   // REGIMM
95         return describe_regimm(op, desc);
7396
74      case 0x10:   /* COP0 */
75         return describe_instruction_cop0(mips, op, desc);
97      case 0x10:   // COP0
98         return describe_cop0(op, desc);
7699
77      case 0x11:   /* COP1 */
78         return describe_instruction_cop1(mips, op, desc);
100      case 0x11:   // COP1
101         return describe_cop1(op, desc);
79102
80      case 0x12:   /* COP2 */
81         return describe_instruction_cop2(mips, op, desc);
103      case 0x12:   // COP2
104         return describe_cop2(op, desc);
82105
83      case 0x13:   /* COP1X - MIPS IV */
84         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
85            return FALSE;
86         return describe_instruction_cop1x(mips, op, desc);
106      case 0x13:   // COP1X - MIPS IV
107         if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
108            return false;
109         return describe_cop1x(op, desc);
87110
88      case 0x1c:   /* IDT-specific opcodes: mad/madu/mul on R4640/4650, msub on RC32364 */
89         return describe_instruction_idt(mips, op, desc);
111      case 0x1c:   // IDT-specific opcodes: mad/madu/mul on R4640/4650, msub on RC32364
112         return describe_idt(op, desc);
90113
91      case 0x02:   /* J */
92         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
93         desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
94         desc->delayslots = 1;
95         return TRUE;
114      case 0x02:   // J
115         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
116         desc.targetpc = (desc.pc & 0xf0000000) | (LIMMVAL << 2);
117         desc.delayslots = 1;
118         return true;
96119
97      case 0x03:   /* JAL */
98         desc->regout[0] |= REGFLAG_R(31);
99         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
100         desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
101         desc->delayslots = 1;
102         return TRUE;
120      case 0x03:   // JAL
121         desc.regout[0] |= REGFLAG_R(31);
122         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
123         desc.targetpc = (desc.pc & 0xf0000000) | (LIMMVAL << 2);
124         desc.delayslots = 1;
125         return true;
103126
104      case 0x04:   /* BEQ */
105      case 0x05:   /* BNE */
106      case 0x14:   /* BEQL */
107      case 0x15:   /* BNEL */
127      case 0x04:   // BEQ
128      case 0x05:   // BNE
129      case 0x14:   // BEQL
130      case 0x15:   // BNEL
108131         if ((opswitch == 0x04 || opswitch == 0x14) && RSREG == RTREG)
109            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
132            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
110133         else
111134         {
112            desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
113            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
135            desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
136            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
114137         }
115         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
116         desc->delayslots = 1;
117         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
118         return TRUE;
138         desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
139         desc.delayslots = 1;
140         desc.skipslots = (opswitch & 0x10) ? 1 : 0;
141         return true;
119142
120      case 0x06:   /* BLEZ */
121      case 0x07:   /* BGTZ */
122      case 0x16:   /* BLEZL */
123      case 0x17:   /* BGTZL */
143      case 0x06:   // BLEZ
144      case 0x07:   // BGTZ
145      case 0x16:   // BLEZL
146      case 0x17:   // BGTZL
124147         if ((opswitch == 0x06 || opswitch == 0x16) && RSREG == 0)
125            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
148            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
126149         else
127150         {
128            desc->regin[0] |= REGFLAG_R(RSREG);
129            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
151            desc.regin[0] |= REGFLAG_R(RSREG);
152            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
130153         }
131         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
132         desc->delayslots = 1;
133         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
134         return TRUE;
154         desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
155         desc.delayslots = 1;
156         desc.skipslots = (opswitch & 0x10) ? 1 : 0;
157         return true;
135158
136      case 0x08:   /* ADDI */
137      case 0x18:   /* DADDI */
138         desc->regin[0] |= REGFLAG_R(RSREG);
139         desc->regout[0] |= REGFLAG_R(RTREG);
140         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
141         return TRUE;
159      case 0x08:   // ADDI
160      case 0x18:   // DADDI
161         desc.regin[0] |= REGFLAG_R(RSREG);
162         desc.regout[0] |= REGFLAG_R(RTREG);
163         desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
164         return true;
142165
143      case 0x09:   /* ADDIU */
144      case 0x0a:   /* SLTI */
145      case 0x0b:   /* SLTIU */
146      case 0x0c:   /* ANDI */
147      case 0x0d:   /* ORI */
148      case 0x0e:   /* XORI */
149      case 0x19:   /* DADDIU */
150         desc->regin[0] |= REGFLAG_R(RSREG);
151         desc->regout[0] |= REGFLAG_R(RTREG);
152         return TRUE;
166      case 0x09:   // ADDIU
167      case 0x0a:   // SLTI
168      case 0x0b:   // SLTIU
169      case 0x0c:   // ANDI
170      case 0x0d:   // ORI
171      case 0x0e:   // XORI
172      case 0x19:   // DADDIU
173         desc.regin[0] |= REGFLAG_R(RSREG);
174         desc.regout[0] |= REGFLAG_R(RTREG);
175         return true;
153176
154      case 0x0f:   /* LUI */
155         desc->regout[0] |= REGFLAG_R(RTREG);
156         return TRUE;
177      case 0x0f:   // LUI
178         desc.regout[0] |= REGFLAG_R(RTREG);
179         return true;
157180
158      case 0x1a:   /* LDL */
159      case 0x1b:   /* LDR */
160      case 0x22:   /* LWL */
161      case 0x26:   /* LWR */
162         desc->regin[0] |= REGFLAG_R(RTREG);
163      case 0x20:   /* LB */
164      case 0x21:   /* LH */
165      case 0x23:   /* LW */
166      case 0x24:   /* LBU */
167      case 0x25:   /* LHU */
168      case 0x27:   /* LWU */
169      case 0x30:   /* LL */
170      case 0x34:   /* LLD */
171      case 0x37:   /* LD */
172         desc->regin[0] |= REGFLAG_R(RSREG);
173         desc->regout[0] |= REGFLAG_R(RTREG);
174         desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
175         return TRUE;
181      case 0x1a:   // LDL
182      case 0x1b:   // LDR
183      case 0x22:   // LWL
184      case 0x26:   // LWR
185         desc.regin[0] |= REGFLAG_R(RTREG);
186      case 0x20:   // LB
187      case 0x21:   // LH
188      case 0x23:   // LW
189      case 0x24:   // LBU
190      case 0x25:   // LHU
191      case 0x27:   // LWU
192      case 0x30:   // LL
193      case 0x34:   // LLD
194      case 0x37:   // LD
195         desc.regin[0] |= REGFLAG_R(RSREG);
196         desc.regout[0] |= REGFLAG_R(RTREG);
197         desc.flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
198         return true;
176199
177      case 0x28:   /* SB */
178      case 0x29:   /* SH */
179      case 0x2a:   /* SWL */
180      case 0x2b:   /* SW */
181      case 0x2c:   /* SDL */
182      case 0x2d:   /* SDR */
183      case 0x2e:   /* SWR */
184      case 0x3f:   /* SD */
185         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
186         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
187         return TRUE;
200      case 0x28:   // SB
201      case 0x29:   // SH
202      case 0x2a:   // SWL
203      case 0x2b:   // SW
204      case 0x2c:   // SDL
205      case 0x2d:   // SDR
206      case 0x2e:   // SWR
207      case 0x3f:   // SD
208         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
209         desc.flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
210         return true;
188211
189      case 0x38:   /* SC */
190      case 0x3c:   /* SCD */
191         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
192         desc->regout[0] |= REGFLAG_R(RTREG);
193         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
194         return TRUE;
212      case 0x38:   // SC
213      case 0x3c:   // SCD
214         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
215         desc.regout[0] |= REGFLAG_R(RTREG);
216         desc.flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
217         return true;
195218
196      case 0x31:   /* LWC1 */
197      case 0x35:   /* LDC1 */
198         desc->regin[0] |= REGFLAG_R(RSREG);
199         desc->regout[1] |= REGFLAG_CPR1(RTREG);
200         desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
201         return TRUE;
219      case 0x31:   // LWC1
220      case 0x35:   // LDC1
221         desc.regin[0] |= REGFLAG_R(RSREG);
222         desc.regout[1] |= REGFLAG_CPR1(RTREG);
223         desc.flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
224         return true;
202225
203      case 0x39:   /* SWC1 */
204      case 0x3d:   /* SDC1 */
205         desc->regin[0] |= REGFLAG_R(RSREG);
206         desc->regin[1] |= REGFLAG_CPR1(RTREG);
207         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
208         return TRUE;
226      case 0x39:   // SWC1
227      case 0x3d:   // SDC1
228         desc.regin[0] |= REGFLAG_R(RSREG);
229         desc.regin[1] |= REGFLAG_CPR1(RTREG);
230         desc.flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
231         return true;
209232
210      case 0x32:   /* LWC2 */
211      case 0x36:   /* LDC2 */
212         desc->regin[0] |= REGFLAG_R(RSREG);
213         desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
214         return TRUE;
233      case 0x32:   // LWC2
234      case 0x36:   // LDC2
235         desc.regin[0] |= REGFLAG_R(RSREG);
236         desc.flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
237         return true;
215238
216      case 0x3a:   /* SWC2 */
217      case 0x3e:   /* SDC2 */
218         desc->regin[0] |= REGFLAG_R(RSREG);
219         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
220         return TRUE;
239      case 0x3a:   // SWC2
240      case 0x3e:   // SDC2
241         desc.regin[0] |= REGFLAG_R(RSREG);
242         desc.flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
243         return true;
221244
222      case 0x33:   /* PREF */
223         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
224            return FALSE;
225      case 0x2f:   /* CACHE */
226         /* effective no-op */
227         return TRUE;
245      case 0x33:   // PREF
246         if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
247            return false;
248      case 0x2f:   // CACHE
249         // effective no-op
250         return true;
228251   }
229252
230   return FALSE;
253   return false;
231254}
232255
233256
234/*-------------------------------------------------
235    describe_instruction_special - build a
236    description of a single instruction in the
237    'special' group
238-------------------------------------------------*/
257//-------------------------------------------------
258//  describe_special - build a description of a
259//  single instruction in the 'special' group
260//-------------------------------------------------
239261
240static int describe_instruction_special(mips3_state *mips, UINT32 op, opcode_desc *desc)
262bool mips3_frontend::describe_special(UINT32 op, opcode_desc &desc)
241263{
242264   switch (op & 63)
243265   {
244      case 0x00:   /* SLL */
245      case 0x02:   /* SRL */
246      case 0x03:   /* SRA */
247      case 0x38:   /* DSLL */
248      case 0x3a:   /* DSRL */
249      case 0x3b:   /* DSRA */
250      case 0x3c:   /* DSLL32 */
251      case 0x3e:   /* DSRL32 */
252      case 0x3f:   /* DSRA32 */
253         desc->regin[0] |= REGFLAG_R(RTREG);
254         desc->regout[0] |= REGFLAG_R(RDREG);
255         return TRUE;
266      case 0x00:   // SLL
267      case 0x02:   // SRL
268      case 0x03:   // SRA
269      case 0x38:   // DSLL
270      case 0x3a:   // DSRL
271      case 0x3b:   // DSRA
272      case 0x3c:   // DSLL32
273      case 0x3e:   // DSRL32
274      case 0x3f:   // DSRA32
275         desc.regin[0] |= REGFLAG_R(RTREG);
276         desc.regout[0] |= REGFLAG_R(RDREG);
277         return true;
256278
257      case 0x0a:   /* MOVZ - MIPS IV */
258      case 0x0b:   /* MOVN - MIPS IV */
259         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
260            return FALSE;
261         desc->regin[0] |= REGFLAG_R(RDREG);
262      case 0x04:   /* SLLV */
263      case 0x06:   /* SRLV */
264      case 0x07:   /* SRAV */
265      case 0x14:   /* DSLLV */
266      case 0x16:   /* DSRLV */
267      case 0x17:   /* DSRAV */
268      case 0x21:   /* ADDU */
269      case 0x23:   /* SUBU */
270      case 0x24:   /* AND */
271      case 0x25:   /* OR */
272      case 0x26:   /* XOR */
273      case 0x27:   /* NOR */
274      case 0x2a:   /* SLT */
275      case 0x2b:   /* SLTU */
276      case 0x2d:   /* DADDU */
277      case 0x2f:   /* DSUBU */
278         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
279         desc->regout[0] |= REGFLAG_R(RDREG);
280         return TRUE;
279      case 0x0a:   // MOVZ - MIPS IV
280      case 0x0b:   // MOVN - MIPS IV
281         if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
282            return false;
283         desc.regin[0] |= REGFLAG_R(RDREG);
284      case 0x04:   // SLLV
285      case 0x06:   // SRLV
286      case 0x07:   // SRAV
287      case 0x14:   // DSLLV
288      case 0x16:   // DSRLV
289      case 0x17:   // DSRAV
290      case 0x21:   // ADDU
291      case 0x23:   // SUBU
292      case 0x24:   // AND
293      case 0x25:   // OR
294      case 0x26:   // XOR
295      case 0x27:   // NOR
296      case 0x2a:   // SLT
297      case 0x2b:   // SLTU
298      case 0x2d:   // DADDU
299      case 0x2f:   // DSUBU
300         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
301         desc.regout[0] |= REGFLAG_R(RDREG);
302         return true;
281303
282      case 0x20:   /* ADD */
283      case 0x22:   /* SUB */
284      case 0x2c:   /* DADD */
285      case 0x2e:   /* DSUB */
286         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
287         desc->regout[0] |= REGFLAG_R(RDREG);
288         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
289         return TRUE;
304      case 0x20:   // ADD
305      case 0x22:   // SUB
306      case 0x2c:   // DADD
307      case 0x2e:   // DSUB
308         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
309         desc.regout[0] |= REGFLAG_R(RDREG);
310         desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
311         return true;
290312
291      case 0x30:   /* TGE */
292      case 0x31:   /* TGEU */
293      case 0x32:   /* TLT */
294      case 0x33:   /* TLTU */
295      case 0x34:   /* TEQ */
296      case 0x36:   /* TNE */
297         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
298         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
299         return TRUE;
313      case 0x30:   // TGE
314      case 0x31:   // TGEU
315      case 0x32:   // TLT
316      case 0x33:   // TLTU
317      case 0x34:   // TEQ
318      case 0x36:   // TNE
319         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
320         desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
321         return true;
300322
301      case 0x01:   /* MOVF - MIPS IV */
302         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
303            return FALSE;
304         desc->regin[0] |= REGFLAG_R(RSREG);
305         desc->regin[2] |= REGFLAG_FCC;
306         desc->regout[0] |= REGFLAG_R(RDREG);
307         return TRUE;
323      case 0x01:   // MOVF - MIPS IV
324         if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
325            return false;
326         desc.regin[0] |= REGFLAG_R(RSREG);
327         desc.regin[2] |= REGFLAG_FCC;
328         desc.regout[0] |= REGFLAG_R(RDREG);
329         return true;
308330
309      case 0x08:   /* JR */
310         desc->regin[0] |= REGFLAG_R(RSREG);
311         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
312         desc->targetpc = BRANCH_TARGET_DYNAMIC;
313         desc->delayslots = 1;
314         return TRUE;
331      case 0x08:   // JR
332         desc.regin[0] |= REGFLAG_R(RSREG);
333         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
334         desc.targetpc = BRANCH_TARGET_DYNAMIC;
335         desc.delayslots = 1;
336         return true;
315337
316      case 0x09:   /* JALR */
317         desc->regin[0] |= REGFLAG_R(RSREG);
318         desc->regout[0] |= REGFLAG_R(RDREG);
319         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
320         desc->targetpc = BRANCH_TARGET_DYNAMIC;
321         desc->delayslots = 1;
322         return TRUE;
338      case 0x09:   // JALR
339         desc.regin[0] |= REGFLAG_R(RSREG);
340         desc.regout[0] |= REGFLAG_R(RDREG);
341         desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
342         desc.targetpc = BRANCH_TARGET_DYNAMIC;
343         desc.delayslots = 1;
344         return true;
323345
324      case 0x10:   /* MFHI */
325         desc->regin[0] |= REGFLAG_HI;
326         desc->regout[0] |= REGFLAG_R(RDREG);
327         return TRUE;
346      case 0x10:   // MFHI
347         desc.regin[0] |= REGFLAG_HI;
348         desc.regout[0] |= REGFLAG_R(RDREG);
349         return true;
328350
329      case 0x11:   /* MTHI */
330         desc->regin[0] |= REGFLAG_R(RSREG);
331         desc->regout[0] |= REGFLAG_HI;
332         return TRUE;
351      case 0x11:   // MTHI
352         desc.regin[0] |= REGFLAG_R(RSREG);
353         desc.regout[0] |= REGFLAG_HI;
354         return true;
333355
334      case 0x12:   /* MFLO */
335         desc->regin[2] |= REGFLAG_LO;
336         desc->regout[0] |= REGFLAG_R(RDREG);
337         return TRUE;
356      case 0x12:   // MFLO
357         desc.regin[2] |= REGFLAG_LO;
358         desc.regout[0] |= REGFLAG_R(RDREG);
359         return true;
338360
339      case 0x13:   /* MTLO */
340         desc->regin[0] |= REGFLAG_R(RSREG);
341         desc->regout[2] |= REGFLAG_LO;
342         return TRUE;
361      case 0x13:   // MTLO
362         desc.regin[0] |= REGFLAG_R(RSREG);
363         desc.regout[2] |= REGFLAG_LO;
364         return true;
343365
344      case 0x18:   /* MULT */
345      case 0x19:   /* MULTU */
346         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
347         desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
348         desc->cycles = 3;
349         return TRUE;
366      case 0x18:   // MULT
367      case 0x19:   // MULTU
368         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
369         desc.regout[2] |= REGFLAG_LO | REGFLAG_HI;
370         desc.cycles = 3;
371         return true;
350372
351      case 0x1a:   /* DIV */
352      case 0x1b:   /* DIVU */
353         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
354         desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
355         desc->cycles = 35;
356         return TRUE;
373      case 0x1a:   // DIV
374      case 0x1b:   // DIVU
375         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
376         desc.regout[2] |= REGFLAG_LO | REGFLAG_HI;
377         desc.cycles = 35;
378         return true;
357379
358      case 0x1c:   /* DMULT */
359      case 0x1d:   /* DMULTU */
360         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
361         desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
362         desc->cycles = 7;
363         return TRUE;
380      case 0x1c:   // DMULT
381      case 0x1d:   // DMULTU
382         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
383         desc.regout[2] |= REGFLAG_LO | REGFLAG_HI;
384         desc.cycles = 7;
385         return true;
364386
365      case 0x1e:   /* DDIV */
366      case 0x1f:   /* DDIVU */
367         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
368         desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
369         desc->cycles = 67;
370         return TRUE;
387      case 0x1e:   // DDIV
388      case 0x1f:   // DDIVU
389         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
390         desc.regout[2] |= REGFLAG_LO | REGFLAG_HI;
391         desc.cycles = 67;
392         return true;
371393
372      case 0x0c:   /* SYSCALL */
373      case 0x0d:   /* BREAK */
374         desc->flags |= OPFLAG_WILL_CAUSE_EXCEPTION | OPFLAG_END_SEQUENCE;
375         return TRUE;
394      case 0x0c:   // SYSCALL
395      case 0x0d:   // BREAK
396         desc.flags |= OPFLAG_WILL_CAUSE_EXCEPTION | OPFLAG_END_SEQUENCE;
397         return true;
376398
377      case 0x0f:   /* SYNC */
378         /* effective no-op */
379         return TRUE;
399      case 0x0f:   // SYNC
400         // effective no-op
401         return true;
380402   }
381403
382   return FALSE;
404   return false;
383405}
384406
385407
386/*-------------------------------------------------
387    describe_instruction_regimm - build a
388    description of a single instruction in the
389    'regimm' group
390-------------------------------------------------*/
408//-------------------------------------------------
409//  describe_regimm - build a description of a
410//  single instruction in the 'regimm' group
411//-------------------------------------------------
391412
392static int describe_instruction_regimm(mips3_state *mips, UINT32 op, opcode_desc *desc)
413bool mips3_frontend::describe_regimm(UINT32 op, opcode_desc &desc)
393414{
394415   switch (RTREG)
395416   {
396      case 0x00:   /* BLTZ */
397      case 0x01:   /* BGEZ */
398      case 0x02:   /* BLTZL */
399      case 0x03:   /* BGEZL */
417      case 0x00:   // BLTZ
418      case 0x01:   // BGEZ
419      case 0x02:   // BLTZL
420      case 0x03:   // BGEZL
400421         if (RTREG == 0x01 && RSREG == 0)
401            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
422            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
402423         else
403424         {
404            desc->regin[0] |= REGFLAG_R(RSREG);
405            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
425            desc.regin[0] |= REGFLAG_R(RSREG);
426            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
406427         }
407         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
408         desc->delayslots = 1;
409         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
410         return TRUE;
428         desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
429         desc.delayslots = 1;
430         desc.skipslots = (RTREG & 0x02) ? 1 : 0;
431         return true;
411432
412      case 0x08:   /* TGEI */
413      case 0x09:   /* TGEIU */
414      case 0x0a:   /* TLTI */
415      case 0x0b:   /* TLTIU */
416      case 0x0c:   /* TEQI */
417      case 0x0e:   /* TNEI */
418         desc->regin[0] |= REGFLAG_R(RSREG);
419         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
420         return TRUE;
433      case 0x08:   // TGEI
434      case 0x09:   // TGEIU
435      case 0x0a:   // TLTI
436      case 0x0b:   // TLTIU
437      case 0x0c:   // TEQI
438      case 0x0e:   // TNEI
439         desc.regin[0] |= REGFLAG_R(RSREG);
440         desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
441         return true;
421442
422      case 0x10:   /* BLTZAL */
423      case 0x11:   /* BGEZAL */
424      case 0x12:   /* BLTZALL */
425      case 0x13:   /* BGEZALL */
443      case 0x10:   // BLTZAL
444      case 0x11:   // BGEZAL
445      case 0x12:   // BLTZALL
446      case 0x13:   // BGEZALL
426447         if (RTREG == 0x11 && RSREG == 0)
427            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
448            desc.flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
428449         else
429450         {
430            desc->regin[0] |= REGFLAG_R(RSREG);
431            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
451            desc.regin[0] |= REGFLAG_R(RSREG);
452            desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
432453         }
433         desc->regout[0] |= REGFLAG_R(31);
434         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
435         desc->delayslots = 1;
436         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
437         return TRUE;
454         desc.regout[0] |= REGFLAG_R(31);
455         desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
456         desc.delayslots = 1;
457         desc.skipslots = (RTREG & 0x02) ? 1 : 0;
458         return true;
438459   }
439460
440   return FALSE;
461   return false;
441462}
442463
443464
444/*-------------------------------------------------
445    describe_instruction_idt - build a
446    description of a single instruction in the
447    IDT-specific group
448-------------------------------------------------*/
465//-------------------------------------------------
466//  describe_idt - build a description of a single
467//  instruction in the IDT-specific group
468//-------------------------------------------------
449469
450static int describe_instruction_idt(mips3_state *mips, UINT32 op, opcode_desc *desc)
470bool mips3_frontend::describe_idt(UINT32 op, opcode_desc &desc)
451471{
452   /* only on the R4650 */
453   if (mips->flavor != MIPS3_TYPE_R4650)
454      return FALSE;
472   // only on the R4650
473   if (m_context.flavor != MIPS3_TYPE_R4650)
474      return false;
455475
456476   switch (op & 0x1f)
457477   {
458      case 0: /* MAD */
459      case 1: /* MADU */
460         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
461         desc->regin[2] |= REGFLAG_LO | REGFLAG_HI;
462         desc->regout[2] |= REGFLAG_LO | REGFLAG_HI;
463         return TRUE;
478      case 0: // MAD
479      case 1: // MADU
480         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
481         desc.regin[2] |= REGFLAG_LO | REGFLAG_HI;
482         desc.regout[2] |= REGFLAG_LO | REGFLAG_HI;
483         return true;
464484
465      case 2: /* MUL */
466         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
467         desc->regout[0] |= REGFLAG_R(RDREG);
468         desc->cycles = 3;
469         return TRUE;
485      case 2: // MUL
486         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
487         desc.regout[0] |= REGFLAG_R(RDREG);
488         desc.cycles = 3;
489         return true;
470490   }
471491
472   return FALSE;
492   return false;
473493}
474494
475495
476/*-------------------------------------------------
477    describe_instruction_cop0 - build a
478    description of a single instruction in the
479    COP0 group
480-------------------------------------------------*/
496//-------------------------------------------------
497//  describe_cop0 - build a description of a
498//  single instruction in the COP0 group
499//-------------------------------------------------
481500
482static int describe_instruction_cop0(mips3_state *mips, UINT32 op, opcode_desc *desc)
501bool mips3_frontend::describe_cop0(UINT32 op, opcode_desc &desc)
483502{
484   /* any COP0 instruction can potentially cause an exception */
485   desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
503   // any COP0 instruction can potentially cause an exception
504   desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
486505
487506   switch (RSREG)
488507   {
489      case 0x00:   /* MFCz */
490      case 0x01:   /* DMFCz */
508      case 0x00:   // MFCz
509      case 0x01:   // DMFCz
491510         if (RDREG == COP0_Count)
492            desc->cycles += MIPS3_COUNT_READ_CYCLES;
511            desc.cycles += MIPS3_COUNT_READ_CYCLES;
493512         if (RDREG == COP0_Cause)
494            desc->cycles += MIPS3_CAUSE_READ_CYCLES;
495         desc->regout[0] |= REGFLAG_R(RTREG);
496         return TRUE;
513            desc.cycles += MIPS3_CAUSE_READ_CYCLES;
514         desc.regout[0] |= REGFLAG_R(RTREG);
515         return true;
497516
498      case 0x02:   /* CFCz */
499         desc->regout[0] |= REGFLAG_R(RTREG);
500         return TRUE;
517      case 0x02:   // CFCz
518         desc.regout[0] |= REGFLAG_R(RTREG);
519         return true;
501520
502      case 0x04:   /* MTCz */
503      case 0x05:   /* DMTCz */
504      case 0x06:   /* CTCz */
505         desc->regin[0] |= REGFLAG_R(RTREG);
521      case 0x04:   // MTCz
522      case 0x05:   // DMTCz
523      case 0x06:   // CTCz
524         desc.regin[0] |= REGFLAG_R(RTREG);
506525         if (RSREG == 0x04 || RSREG == 0x05)
507526         {
508527            if (RDREG == COP0_Cause)
509               desc->flags |= OPFLAG_CAN_TRIGGER_SW_INT;
528               desc.flags |= OPFLAG_CAN_TRIGGER_SW_INT;
510529            if (RDREG == COP0_Status)
511               desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
530               desc.flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
512531         }
513         return TRUE;
532         return true;
514533
515      case 0x08:   /* BC */
534      case 0x08:   // BC
516535         switch (RTREG)
517536         {
518            case 0x00:   /* BCzF */
519            case 0x01:   /* BCzT */
520               desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
521               desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
522               desc->delayslots = 1;
523               return TRUE;
537            case 0x00:   // BCzF
538            case 0x01:   // BCzT
539               desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
540               desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
541               desc.delayslots = 1;
542               return true;
524543         }
525         return FALSE;
544         return false;
526545
527546      case 0x10:   case 0x11:   case 0x12:   case 0x13:   case 0x14:   case 0x15:   case 0x16:   case 0x17:
528      case 0x18:   case 0x19:   case 0x1a:   case 0x1b:   case 0x1c:   case 0x1d:   case 0x1e:   case 0x1f:   /* COP */
547      case 0x18:   case 0x19:   case 0x1a:   case 0x1b:   case 0x1c:   case 0x1d:   case 0x1e:   case 0x1f:   // COP
529548         switch (op & 0x01ffffff)
530549         {
531            case 0x01:   /* TLBR */
532            case 0x08:   /* TLBP */
533            case 0x20:   /* WAIT */
534               return TRUE;
550            case 0x01:   // TLBR
551            case 0x08:   // TLBP
552            case 0x20:   // WAIT
553               return true;
535554
536            case 0x02:   /* TLBWI */
537            case 0x06:   /* TLBWR */
538               desc->flags |= OPFLAG_MODIFIES_TRANSLATION;
539               return TRUE;
555            case 0x02:   // TLBWI
556            case 0x06:   // TLBWR
557               desc.flags |= OPFLAG_MODIFIES_TRANSLATION;
558               return true;
540559
541            case 0x18:   /* ERET */
542               desc->flags |= OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
543               return TRUE;
560            case 0x18:   // ERET
561               desc.flags |= OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
562               return true;
544563         }
545         return FALSE;
564         return false;
546565   }
547566
548   return FALSE;
567   return false;
549568}
550569
551570
552/*-------------------------------------------------
553    describe_instruction_cop1 - build a
554    description of a single instruction in the
555    COP1 group
556-------------------------------------------------*/
571//-------------------------------------------------
572//  describe_cop1 - build a description of a
573//  single instruction in the COP1 group
574//-------------------------------------------------
557575
558static int describe_instruction_cop1(mips3_state *mips, UINT32 op, opcode_desc *desc)
576bool mips3_frontend::describe_cop1(UINT32 op, opcode_desc &desc)
559577{
560   /* any COP1 instruction can potentially cause an exception */
561//  desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
578   // any COP1 instruction can potentially cause an exception
579//  desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
562580
563581   switch (RSREG)
564582   {
565      case 0x00:   /* MFCz */
566      case 0x01:   /* DMFCz */
567         desc->regin[1] |= REGFLAG_CPR1(RDREG);
568         desc->regout[0] |= REGFLAG_R(RTREG);
569         return TRUE;
583      case 0x00:   // MFCz
584      case 0x01:   // DMFCz
585         desc.regin[1] |= REGFLAG_CPR1(RDREG);
586         desc.regout[0] |= REGFLAG_R(RTREG);
587         return true;
570588
571      case 0x02:   /* CFCz */
572         desc->regout[0] |= REGFLAG_R(RTREG);
573         return TRUE;
589      case 0x02:   // CFCz
590         desc.regout[0] |= REGFLAG_R(RTREG);
591         return true;
574592
575      case 0x04:   /* MTCz */
576      case 0x05:   /* DMTCz */
577         desc->regin[0] |= REGFLAG_R(RTREG);
578         desc->regout[1] |= REGFLAG_CPR1(RDREG);
579         return TRUE;
593      case 0x04:   // MTCz
594      case 0x05:   // DMTCz
595         desc.regin[0] |= REGFLAG_R(RTREG);
596         desc.regout[1] |= REGFLAG_CPR1(RDREG);
597         return true;
580598
581      case 0x06:   /* CTCz */
582         desc->regin[0] |= REGFLAG_R(RTREG);
583         return TRUE;
599      case 0x06:   // CTCz
600         desc.regin[0] |= REGFLAG_R(RTREG);
601         return true;
584602
585      case 0x08:   /* BC */
603      case 0x08:   // BC
586604         switch (RTREG & 3)
587605         {
588            case 0x00:   /* BCzF */
589            case 0x01:   /* BCzT */
590            case 0x02:   /* BCzFL */
591            case 0x03:   /* BCzTL */
592               desc->regin[2] |= REGFLAG_FCC;
593               desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
594               desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
595               desc->delayslots = 1;
596               desc->skipslots = (RTREG & 0x02) ? 1 : 0;
597               return TRUE;
606            case 0x00:   // BCzF
607            case 0x01:   // BCzT
608            case 0x02:   // BCzFL
609            case 0x03:   // BCzTL
610               desc.regin[2] |= REGFLAG_FCC;
611               desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
612               desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
613               desc.delayslots = 1;
614               desc.skipslots = (RTREG & 0x02) ? 1 : 0;
615               return true;
598616         }
599         return FALSE;
617         return false;
600618
601619      case 0x10:   case 0x11:   case 0x12:   case 0x13:   case 0x14:   case 0x15:   case 0x16:   case 0x17:
602      case 0x18:   case 0x19:   case 0x1a:   case 0x1b:   case 0x1c:   case 0x1d:   case 0x1e:   case 0x1f:   /* COP */
620      case 0x18:   case 0x19:   case 0x1a:   case 0x1b:   case 0x1c:   case 0x1d:   case 0x1e:   case 0x1f:   // COP
603621         switch (op & 0x3f)
604622         {
605            case 0x12:   /* MOVZ - MIPS IV */
606            case 0x13:   /* MOVN - MIPS IV */
607               if (mips->flavor < MIPS3_TYPE_MIPS_IV)
608                  return FALSE;
609            case 0x00:   /* ADD */
610            case 0x01:   /* SUB */
611            case 0x02:   /* MUL */
612            case 0x03:   /* DIV */
613               desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
614               desc->regout[1] |= REGFLAG_CPR1(FDREG);
615               return TRUE;
623            case 0x12:   // MOVZ - MIPS IV
624            case 0x13:   // MOVN - MIPS IV
625               if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
626                  return false;
627            case 0x00:   // ADD
628            case 0x01:   // SUB
629            case 0x02:   // MUL
630            case 0x03:   // DIV
631               desc.regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
632               desc.regout[1] |= REGFLAG_CPR1(FDREG);
633               return true;
616634
617            case 0x15:   /* RECIP - MIPS IV */
618            case 0x16:   /* RSQRT - MIPS IV */
619               if (mips->flavor < MIPS3_TYPE_MIPS_IV)
620                  return FALSE;
621            case 0x04:   /* SQRT */
622            case 0x05:   /* ABS */
623            case 0x06:   /* MOV */
624            case 0x07:   /* NEG */
625            case 0x08:   /* ROUND.L */
626            case 0x09:   /* TRUNC.L */
627            case 0x0a:   /* CEIL.L */
628            case 0x0b:   /* FLOOR.L */
629            case 0x0c:   /* ROUND.W */
630            case 0x0d:   /* TRUNC.W */
631            case 0x0e:   /* CEIL.W */
632            case 0x0f:   /* FLOOR.W */
633            case 0x20:   /* CVT.S */
634            case 0x21:   /* CVT.D */
635            case 0x24:   /* CVT.W */
636            case 0x25:   /* CVT.L */
637               desc->regin[1] |= REGFLAG_CPR1(FSREG);
638               desc->regout[1] |= REGFLAG_CPR1(FDREG);
639               return TRUE;
635            case 0x15:   // RECIP - MIPS IV
636            case 0x16:   // RSQRT - MIPS IV
637               if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
638                  return false;
639            case 0x04:   // SQRT
640            case 0x05:   // ABS
641            case 0x06:   // MOV
642            case 0x07:   // NEG
643            case 0x08:   // ROUND.L
644            case 0x09:   // TRUNC.L
645            case 0x0a:   // CEIL.L
646            case 0x0b:   // FLOOR.L
647            case 0x0c:   // ROUND.W
648            case 0x0d:   // TRUNC.W
649            case 0x0e:   // CEIL.W
650            case 0x0f:   // FLOOR.W
651            case 0x20:   // CVT.S
652            case 0x21:   // CVT.D
653            case 0x24:   // CVT.W
654            case 0x25:   // CVT.L
655               desc.regin[1] |= REGFLAG_CPR1(FSREG);
656               desc.regout[1] |= REGFLAG_CPR1(FDREG);
657               return true;
640658
641            case 0x11:   /* MOVT/F - MIPS IV */
642               if (mips->flavor < MIPS3_TYPE_MIPS_IV)
643                  return FALSE;
644               desc->regin[1] |= REGFLAG_CPR1(FSREG);
645               desc->regin[2] |= REGFLAG_FCC;
646               desc->regout[1] |= REGFLAG_CPR1(FDREG);
647               return TRUE;
659            case 0x11:   // MOVT/F - MIPS IV
660               if (m_context.flavor < MIPS3_TYPE_MIPS_IV)
661                  return false;
662               desc.regin[1] |= REGFLAG_CPR1(FSREG);
663               desc.regin[2] |= REGFLAG_FCC;
664               desc.regout[1] |= REGFLAG_CPR1(FDREG);
665               return true;
648666
649            case 0x30:   case 0x38:   /* C.F */
650            case 0x31:   case 0x39:   /* C.UN */
651               desc->regout[2] |= REGFLAG_FCC;
652               return TRUE;
667            case 0x30:   case 0x38:   // C.F
668            case 0x31:   case 0x39:   // C.UN
669               desc.regout[2] |= REGFLAG_FCC;
670               return true;
653671
654            case 0x32:   case 0x3a:   /* C.EQ */
655            case 0x33:   case 0x3b:   /* C.UEQ */
656            case 0x34:   case 0x3c:   /* C.OLT */
657            case 0x35:   case 0x3d:   /* C.ULT */
658            case 0x36:   case 0x3e:   /* C.OLE */
659            case 0x37:   case 0x3f:   /* C.ULE */
660               desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
661               desc->regout[2] |= REGFLAG_FCC;
662               return TRUE;
672            case 0x32:   case 0x3a:   // C.EQ
673            case 0x33:   case 0x3b:   // C.UEQ
674            case 0x34:   case 0x3c:   // C.OLT
675            case 0x35:   case 0x3d:   // C.ULT
676            case 0x36:   case 0x3e:   // C.OLE
677            case 0x37:   case 0x3f:   // C.ULE
678               desc.regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
679               desc.regout[2] |= REGFLAG_FCC;
680               return true;
663681         }
664         return FALSE;
682         return false;
665683   }
666684
667   return FALSE;
685   return false;
668686}
669687
670688
671/*-------------------------------------------------
672    describe_instruction_cop1x - build a
673    description of a single instruction in the
674    COP1X group
675-------------------------------------------------*/
689//-------------------------------------------------
690//  describe_cop1x - build a description of a
691//  single instruction in the COP1X group
692//-------------------------------------------------
676693
677static int describe_instruction_cop1x(mips3_state *mips, UINT32 op, opcode_desc *desc)
694bool mips3_frontend::describe_cop1x(UINT32 op, opcode_desc &desc)
678695{
679   /* any COP1 instruction can potentially cause an exception */
680//  desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
696   // any COP1 instruction can potentially cause an exception
697//  desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
681698
682699   switch (op & 0x3f)
683700   {
684      case 0x00:   /* LWXC1 */
685      case 0x01:   /* LDXC1 */
686         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
687         desc->regout[1] |= REGFLAG_CPR1(FDREG);
688         desc->flags |= OPFLAG_READS_MEMORY;
689         return TRUE;
701      case 0x00:   // LWXC1
702      case 0x01:   // LDXC1
703         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
704         desc.regout[1] |= REGFLAG_CPR1(FDREG);
705         desc.flags |= OPFLAG_READS_MEMORY;
706         return true;
690707
691      case 0x08:   /* SWXC1 */
692      case 0x09:   /* SDXC1 */
693         desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
694         desc->regin[1] |= REGFLAG_CPR1(FDREG);
695         desc->flags |= OPFLAG_WRITES_MEMORY;
696         return TRUE;
708      case 0x08:   // SWXC1
709      case 0x09:   // SDXC1
710         desc.regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
711         desc.regin[1] |= REGFLAG_CPR1(FDREG);
712         desc.flags |= OPFLAG_WRITES_MEMORY;
713         return true;
697714
698      case 0x0f:   /* PREFX */
699         /* effective no-op */
700         return TRUE;
715      case 0x0f:   // PREFX
716         // effective no-op
717         return true;
701718
702      case 0x20:   case 0x21:   /* MADD */
703      case 0x28:   case 0x29:   /* MSUB */
704      case 0x30:   case 0x31:   /* NMADD */
705      case 0x38:   case 0x39:   /* NMSUB */
706         desc->regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG) | REGFLAG_CPR1(FRREG);
707         desc->regout[1] |= REGFLAG_CPR1(FDREG);
708         return TRUE;
719      case 0x20:   case 0x21:   // MADD
720      case 0x28:   case 0x29:   // MSUB
721      case 0x30:   case 0x31:   // NMADD
722      case 0x38:   case 0x39:   // NMSUB
723         desc.regin[1] |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG) | REGFLAG_CPR1(FRREG);
724         desc.regout[1] |= REGFLAG_CPR1(FDREG);
725         return true;
709726   }
710727
711   return FALSE;
728   return false;
712729}
713730
714731
715/*-------------------------------------------------
716    describe_instruction_cop2 - build a
717    description of a single instruction in the
718    COP2 group
719-------------------------------------------------*/
732//-------------------------------------------------
733//  describe_cop2 - build a description of a
734//  single instruction in the COP2 group
735//-------------------------------------------------
720736
721static int describe_instruction_cop2(mips3_state *mips, UINT32 op, opcode_desc *desc)
737bool mips3_frontend::describe_cop2(UINT32 op, opcode_desc &desc)
722738{
723   /* any COP2 instruction can potentially cause an exception */
724   desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
739   // any COP2 instruction can potentially cause an exception
740   desc.flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
725741
726742   switch (RSREG)
727743   {
728      case 0x00:   /* MFCz */
729      case 0x01:   /* DMFCz */
730      case 0x02:   /* CFCz */
731         desc->regout[0] |= REGFLAG_R(RTREG);
732         return TRUE;
744      case 0x00:   // MFCz
745      case 0x01:   // DMFCz
746      case 0x02:   // CFCz
747         desc.regout[0] |= REGFLAG_R(RTREG);
748         return true;
733749
734      case 0x04:   /* MTCz */
735      case 0x05:   /* DMTCz */
736      case 0x06:   /* CTCz */
737         desc->regin[0] |= REGFLAG_R(RTREG);
738         return TRUE;
750      case 0x04:   // MTCz
751      case 0x05:   // DMTCz
752      case 0x06:   // CTCz
753         desc.regin[0] |= REGFLAG_R(RTREG);
754         return true;
739755
740      case 0x08:   /* BC */
756      case 0x08:   // BC
741757         switch (RTREG)
742758         {
743            case 0x00:   /* BCzF */
744            case 0x01:   /* BCzT */
745               desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
746               desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
747               desc->delayslots = 1;
748               return TRUE;
759            case 0x00:   // BCzF
760            case 0x01:   // BCzT
761               desc.flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
762               desc.targetpc = desc.pc + 4 + (SIMMVAL << 2);
763               desc.delayslots = 1;
764               return true;
749765         }
750         return FALSE;
766         return false;
751767   }
752768
753   return FALSE;
769   return false;
754770}
src/emu/cpu/mips/mips3fe.h
r9922r9923
44
55    Front-end for MIPS3 recompiler
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138***************************************************************************/
1239
1340#pragma once
r9922r9923
1542#ifndef __MIPS3FE_H__
1643#define __MIPS3FE_H__
1744
45#include "mips3com.h"
1846#include "cpu/drcfe.h"
1947
2048
21/***************************************************************************
22    CONSTANTS
23***************************************************************************/
49//**************************************************************************
50//  MACROS
51//**************************************************************************
2452
25/* register flags 0 */
53// register flags 0
2654#define REGFLAG_R(n)               (((n) == 0) ? 0 : (1 << (n)))
2755
28/* register flags 1 */
56// register flags 1
2957#define REGFLAG_CPR1(n)               (1 << (n))
3058
31/* register flags 2 */
59// register flags 2
3260#define REGFLAG_LO                  (1 << 0)
3361#define REGFLAG_HI                  (1 << 1)
3462#define REGFLAG_FCC                  (1 << 2)
3563
3664
3765
38/***************************************************************************
39    FUNCTION PROTOTYPES
40***************************************************************************/
66//**************************************************************************
67//  TYPE DEFINITIONS
68//**************************************************************************
4169
42int mips3fe_describe(void *param, opcode_desc *desc, const opcode_desc *prev);
70class mips3_frontend : public drc_frontend
71{
72public:
73   // construction/destruction
74   mips3_frontend(mips3_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
4375
76protected:
77   // required overrides
78   virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
79
80private:
81   // internal helpers
82   bool describe_special(UINT32 op, opcode_desc &desc);
83   bool describe_regimm(UINT32 op, opcode_desc &desc);
84   bool describe_idt(UINT32 op, opcode_desc &desc);
85   bool describe_cop0(UINT32 op, opcode_desc &desc);
86   bool describe_cop1(UINT32 op, opcode_desc &desc);
87   bool describe_cop1x(UINT32 op, opcode_desc &desc);
88   bool describe_cop2(UINT32 op, opcode_desc &desc);
89
90   // internal state
91   mips3_state &m_context;
92};
93
94
4495#endif /* __MIPS3FE_H__ */
src/emu/cpu/mips/mips3drc.c
r9922r9923
44
55    Universal machine language-based MIPS III/IV emulator.
66
7****************************************************************************
8
79    Copyright Aaron Giles
8    Released for general non-commercial use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10    All rights reserved.
1011
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1138****************************************************************************
1239
1340    Future improvements/changes:
r9922r9923
159186   /* core state */
160187   drccache *         cache;                  /* pointer to the DRC code cache */
161188   drcuml_state *      drcuml;                  /* DRC UML generator state */
162   drcfe_state *      drcfe;                  /* pointer to the DRC front-end state */
189   mips3_frontend *   drcfe;                  /* pointer to the DRC front-end state */
163190   UINT32            drcoptions;               /* configurable DRC options */
164191
165192   /* internal stuff */
r9922r9923
360387
361388static void mips3_init(mips3_flavor flavor, int bigendian, legacy_cpu_device *device, device_irq_callback irqcallback)
362389{
363   drcfe_config feconfig =
364   {
365      COMPILE_BACKWARDS_BYTES,   /* code window start offset = startpc - window_start */
366      COMPILE_FORWARDS_BYTES,      /* code window end offset = startpc + window_end */
367      COMPILE_MAX_SEQUENCE,      /* maximum instructions to include in a sequence */
368      mips3fe_describe         /* callback to describe a single instruction */
369   };
370390   mips3_state *mips3;
371391   drccache *cache;
372392   drcbe_info beinfo;
r9922r9923
445465   drcuml_symbol_add(mips3->impstate->drcuml, &mips3->impstate->fpmode, sizeof(mips3->impstate->fpmode), "fpmode");
446466
447467   /* initialize the front-end helper */
448   if (SINGLE_INSTRUCTION_MODE)
449      feconfig.max_sequence = 1;
450   mips3->impstate->drcfe = drcfe_init(device, &feconfig, mips3);
468   mips3->impstate->drcfe = auto_alloc(device->machine, mips3_frontend(*mips3, COMPILE_BACKWARDS_BYTES, COMPILE_FORWARDS_BYTES, SINGLE_INSTRUCTION_MODE ? 1 : COMPILE_MAX_SEQUENCE));
451469
452470   /* allocate memory for cache-local state and initialize it */
453471   memcpy(mips3->impstate->fpmode, fpmode_source, sizeof(fpmode_source));
r9922r9923
546564   mips3com_exit(mips3);
547565
548566   /* clean up the DRC */
549   drcfe_exit(mips3->impstate->drcfe);
567   auto_free(device->machine, mips3->impstate->drcfe);
550568   drcuml_free(mips3->impstate->drcuml);
551569   drccache_free(mips3->impstate->cache);
552570}
r9922r9923
745763   g_profiler.start(PROFILER_DRC_COMPILE);
746764
747765   /* get a description of this sequence */
748   desclist = drcfe_describe_code(mips3->impstate->drcfe, pc);
766   desclist = mips3->impstate->drcfe->describe_code(pc);
749767   if (LOG_UML || LOG_NATIVE)
750768      log_opcode_desc(drcuml, desclist, 0);
751769
r9922r9923
757775   block = drcuml_block_begin(drcuml, 4096, &errorbuf);
758776
759777   /* loop until we get through all instruction sequences */
760   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next)
778   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next())
761779   {
762780      const opcode_desc *curdesc;
763781      UINT32 nextpc;
r9922r9923
767785         UML_COMMENT(block, "-------------------------");                  // comment
768786
769787      /* determine the last instruction in this sequence */
770      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next)
788      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next())
771789         if (seqlast->flags & OPFLAG_END_SEQUENCE)
772790            break;
773791      assert(seqlast != NULL);
r9922r9923
802820         UML_LABEL(block, seqhead->pc | 0x80000000);                        // label   seqhead->pc | 0x80000000
803821
804822      /* iterate over instructions in the sequence and compile them */
805      for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next)
823      for (curdesc = seqhead; curdesc != seqlast->next(); curdesc = curdesc->next())
806824         generate_sequence_instruction(mips3, block, &compiler, curdesc);
807825
808826      /* if we need to return to the start, do it */
r9922r9923
820838      if (seqlast->flags & OPFLAG_CAN_CHANGE_MODES)
821839         UML_HASHJMP(block, MEM(&mips3->impstate->mode), IMM(nextpc), mips3->impstate->nocode);
822840                                                               // hashjmp <mode>,nextpc,nocode
823      else if (seqlast->next == NULL || seqlast->next->pc != nextpc)
841      else if (seqlast->next() == NULL || seqlast->next()->pc != nextpc)
824842         UML_HASHJMP(block, IMM(mips3->impstate->mode), IMM(nextpc), mips3->impstate->nocode);
825843                                                               // hashjmp <mode>,nextpc,nocode
826844   }
r9922r9923
15211539      UML_COMMENT(block, "[Validation for %08X]", seqhead->pc);               // comment
15221540
15231541   /* loose verify or single instruction: just compare and fail */
1524   if (!(mips3->impstate->drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next == NULL)
1542   if (!(mips3->impstate->drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next() == NULL)
15251543   {
15261544      if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP))
15271545      {
r9922r9923
15361554   else
15371555   {
15381556#if 0
1539      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
1557      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
15401558         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
15411559         {
15421560            void *base = mips3->direct->read_decrypted_ptr(seqhead->physpc);
r9922r9923
15491567      void *base = mips3->direct->read_decrypted_ptr(seqhead->physpc);
15501568      UML_LOAD(block, IREG(0), base, IMM(0), DWORD);                        // load    i0,base,0,dword
15511569      sum += seqhead->opptr.l[0];
1552      for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next)
1570      for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next())
15531571         if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP))
15541572         {
15551573            base = mips3->direct->read_decrypted_ptr(curdesc->physpc);
r9922r9923
15571575            UML_ADD(block, IREG(0), IREG(0), IREG(1));                     // add     i0,i0,i1
15581576            sum += curdesc->opptr.l[0];
15591577
1560            if (curdesc->delay != NULL && (curdesc == seqlast || (curdesc->next != NULL && curdesc->next->physpc != curdesc->delay->physpc)))
1578            if (curdesc->delay.first() != NULL && (curdesc == seqlast || (curdesc->next() != NULL && curdesc->next()->physpc != curdesc->delay.first()->physpc)))
15611579            {
1562               base = mips3->direct->read_decrypted_ptr(curdesc->delay->physpc);
1580               base = mips3->direct->read_decrypted_ptr(curdesc->delay.first()->physpc);
15631581               UML_LOAD(block, IREG(1), base, IMM(0), DWORD);               // load    i1,base,dword
15641582               UML_ADD(block, IREG(0), IREG(0), IREG(1));                  // add     i0,i0,i1
1565               sum += curdesc->delay->opptr.l[0];
1583               sum += curdesc->delay.first()->opptr.l[0];
15661584            }
15671585         }
15681586      UML_CMP(block, IREG(0), IMM(sum));                                 // cmp     i0,sum
r9922r9923
17101728      UML_DMOV(block, R64(linkreg), IMM((INT32)(desc->pc + 8)));               // dmov    <linkreg>,desc->pc + 8
17111729
17121730   /* compile the delay slot using temporary compiler state */
1713   assert(desc->delay != NULL);
1714   generate_sequence_instruction(mips3, block, &compiler_temp, desc->delay);      // <next instruction>
1731   assert(desc->delay.first() != NULL);
1732   generate_sequence_instruction(mips3, block, &compiler_temp, desc->delay.first());      // <next instruction>
17151733
17161734   /* update the cycles and jump through the hash table to the target */
17171735   if (desc->targetpc != BRANCH_TARGET_DYNAMIC)
r9922r9923
36483666      drcuml_log_printf(drcuml, "\nDescriptor list @ %08X\n", desclist->pc);
36493667
36503668   /* output each descriptor */
3651   for ( ; desclist != NULL; desclist = desclist->next)
3669   for ( ; desclist != NULL; desclist = desclist->next())
36523670   {
36533671      char buffer[100];
36543672
r9922r9923
36693687      drcuml_log_printf(drcuml, "\n");
36703688
36713689      /* if we have a delay slot, output it recursively */
3672      if (desclist->delay != NULL)
3673         log_opcode_desc(drcuml, desclist->delay, indent + 1);
3690      if (desclist->delay.first() != NULL)
3691         log_opcode_desc(drcuml, desclist->delay.first(), indent + 1);
36743692
36753693      /* at the end of a sequence add a dividing line */
36763694      if (desclist->flags & OPFLAG_END_SEQUENCE)
src/emu/cpu/arm7/arm7core.c
r9922r9923
11871187            if (rd == eR15)
11881188            {
11891189                R15 = newval + 8;
1190                // extra cycles for LDR(H,SH,SB) PC (5 total cycles)
1191                ARM7_ICOUNT -= 2;
11901192            }
11911193            else
11921194            {
r9922r9923
14231425    UINT32 op2, sc = 0, rd, rn, opcode;
14241426    UINT32 by, rdn;
14251427
1428   // Normal Data Processing : 1S
1429   // Data Processing with register specified shift : 1S + 1I
1430   // Data Processing with PC written : 2S + 1N
1431   // Data Processing with register specified shift and PC written : 2S + 1N + 1I
1432
14261433    opcode = (insn & INSN_OPCODE) >> INSN_OPCODE_SHIFT;
14271434
14281435    rd = 0;
r9922r9923
14551462        // LD TODO sc will always be 0 if this applies
14561463        if (!(insn & INSN_S))
14571464            sc = 0;
1465
1466        // extra cycle (register specified shift)
1467        ARM7_ICOUNT -= 1;
14581468    }
14591469
14601470    // LD TODO this comment is wrong
r9922r9923
15531563           {
15541564               R15 = (R15 & ~0x03FFFFFC) | (rd & 0x03FFFFFC);
15551565           }
1566            // extra cycles (PC written)
1567            ARM7_ICOUNT -= 2;
15561568        }
15571569        else
15581570        {
r9922r9923
15841596               SwitchMode( cpustate, temp & 3);
15851597                }
15861598
1599                // extra cycles (PC written)
1600                ARM7_ICOUNT -= 2;
1601
15871602                /* IRQ masks may have changed in this instruction */
15881603//              ARM7_CHECKIRQ;
15891604            }
r9922r9923
16201635                LOG(("%08x: TST class on R15 no s bit set\n", R15));
16211636#endif
16221637        }
1638        // extra cycles (PC written)
1639        ARM7_ICOUNT -= 2;
16231640    }
1641
1642    // compensate for the -3 at the end
1643    ARM7_ICOUNT += 2;
16241644}
16251645
16261646static void HandleMul(arm_state *cpustate, UINT32 insn)
16271647{
1628    UINT32 r;
1648    UINT32 r, rm, rs;
16291649
1650   // MUL takes 1S + mI and MLA 1S + (m+1)I cycles to execute, where S and I are as
1651   // defined in 6.2 Cycle Types on page 6-2.
1652   // m is the number of 8 bit multiplier array cycles required to complete the
1653   // multiply, which is controlled by the value of the multiplier operand
1654   // specified by Rs.
1655
1656   rm = GET_REGISTER(cpustate, insn & INSN_MUL_RM);
1657   rs = GET_REGISTER(cpustate, (insn & INSN_MUL_RS) >> INSN_MUL_RS_SHIFT);
1658
16301659    /* Do the basic multiply of Rm and Rs */
1631    r = GET_REGISTER(cpustate, insn & INSN_MUL_RM) *
1632        GET_REGISTER(cpustate, (insn & INSN_MUL_RS) >> INSN_MUL_RS_SHIFT);
1660    r = rm * rs;
16331661
16341662#if ARM7_DEBUG_CORE
16351663    if ((insn & INSN_MUL_RM) == 0xf ||
r9922r9923
16421670    if (insn & INSN_MUL_A)
16431671    {
16441672        r += GET_REGISTER(cpustate, (insn & INSN_MUL_RN) >> INSN_MUL_RN_SHIFT);
1673        // extra cycle for MLA
1674      ARM7_ICOUNT -= 1;
16451675    }
16461676
16471677    /* Write the result */
r9922r9923
16521682    {
16531683        SET_CPSR((GET_CPSR & ~(N_MASK | Z_MASK)) | HandleALUNZFlags(r));
16541684    }
1685
1686   if (rs & SIGN_BIT) rs = -rs;
1687   if (rs < 0x00000100) ARM7_ICOUNT -= 1 + 1;
1688   else if (rs < 0x00010000) ARM7_ICOUNT -= 1 + 2;
1689   else if (rs < 0x01000000) ARM7_ICOUNT -= 1 + 3;
1690   else ARM7_ICOUNT -= 1 + 4;
1691
1692   ARM7_ICOUNT += 3;
16551693}
16561694
16571695// todo: add proper cycle counts
r9922r9923
16611699    UINT32 rhi, rlo;
16621700    INT64 res = 0;
16631701
1702   // MULL takes 1S + (m+1)I and MLAL 1S + (m+2)I cycles to execute, where m is the
1703   // number of 8 bit multiplier array cycles required to complete the multiply, which is
1704   // controlled by the value of the multiplier operand specified by Rs.
1705
16641706    rm  = (INT32)GET_REGISTER(cpustate, insn & 0xf);
16651707    rs  = (INT32)GET_REGISTER(cpustate, ((insn >> 8) & 0xf));
16661708    rhi = (insn >> 16) & 0xf;
r9922r9923
16791721    {
16801722        INT64 acum = (INT64)((((INT64)(GET_REGISTER(cpustate, rhi))) << 32) | GET_REGISTER(cpustate, rlo));
16811723        res += acum;
1724        // extra cycle for MLA
1725      ARM7_ICOUNT -= 1;
16821726    }
16831727
16841728    /* Write the result (upper dword goes to RHi, lower to RLo) */
r9922r9923
16901734    {
16911735        SET_CPSR((GET_CPSR & ~(N_MASK | Z_MASK)) | HandleLongALUNZFlags(res));
16921736    }
1737
1738   if (rs < 0) rs = -rs;
1739   if (rs < 0x00000100) ARM7_ICOUNT -= 1 + 1 + 1;
1740   else if (rs < 0x00010000) ARM7_ICOUNT -= 1 + 2 + 1;
1741   else if (rs < 0x01000000) ARM7_ICOUNT -= 1 + 3 + 1;
1742   else ARM7_ICOUNT -= 1 + 4 + 1;
1743
1744   ARM7_ICOUNT += 3;
16931745}
16941746
16951747// todo: add proper cycle counts
r9922r9923
16991751    UINT32 rhi, rlo;
17001752    UINT64 res = 0;
17011753
1754   // MULL takes 1S + (m+1)I and MLAL 1S + (m+2)I cycles to execute, where m is the
1755   // number of 8 bit multiplier array cycles required to complete the multiply, which is
1756   // controlled by the value of the multiplier operand specified by Rs.
1757
17021758    rm  = (INT32)GET_REGISTER(cpustate, insn & 0xf);
17031759    rs  = (INT32)GET_REGISTER(cpustate, ((insn >> 8) & 0xf));
17041760    rhi = (insn >> 16) & 0xf;
r9922r9923
17171773    {
17181774        UINT64 acum = (UINT64)((((UINT64)(GET_REGISTER(cpustate, rhi))) << 32) | GET_REGISTER(cpustate, rlo));
17191775        res += acum;
1776        // extra cycle for MLA
1777      ARM7_ICOUNT -= 1;
17201778    }
17211779
17221780    /* Write the result (upper dword goes to RHi, lower to RLo) */
r9922r9923
17281786    {
17291787        SET_CPSR((GET_CPSR & ~(N_MASK | Z_MASK)) | HandleLongALUNZFlags(res));
17301788    }
1789
1790   if (rs < 0x00000100) ARM7_ICOUNT -= 1 + 1 + 1;
1791   else if (rs < 0x00010000) ARM7_ICOUNT -= 1 + 2 + 1;
1792   else if (rs < 0x01000000) ARM7_ICOUNT -= 1 + 3 + 1;
1793   else ARM7_ICOUNT -= 1 + 4 + 1;
1794
1795   ARM7_ICOUNT += 3;
17311796}
17321797
17331798static void HandleMemBlock(arm_state *cpustate, UINT32 insn)
r9922r9923
17411806        LOG(("%08x: Unaligned Mem Transfer @ %08x\n", R15, rbp));
17421807#endif
17431808
1809   // Normal LDM instructions take nS + 1N + 1I and LDM PC takes (n+1)S + 2N + 1I
1810   // incremental cycles, where S,N and I are as defined in 6.2 Cycle Types on page 6-2.
1811   // STM instructions take (n-1)S + 2N incremental cycles to execute, where n is the
1812   // number of words transferred.
1813
17441814    if (insn & INSN_BDT_L)
17451815    {
17461816        /* Loading */
r9922r9923
17951865                  SwitchMode(cpustate, temp & 3);
17961866                    }
17971867                }
1868                // LDM PC - takes 2 extra cycles
1869                ARM7_ICOUNT -= 2;
17981870            }
1799
1800         // note: the next statement should be located within the previous "if" statement (right?), however, doing so will break "39in1"
1801
1802            // LDM PC - takes 1 extra cycle
1803            ARM7_ICOUNT -= 1;
18041871        }
18051872        else
18061873        {
r9922r9923
18511918                  SwitchMode(cpustate, temp & 3);
18521919                    }
18531920                }
1854                // LDM PC - takes 1 extra cycle
1855                ARM7_ICOUNT -= 1;
1921                // LDM PC - takes 2 extra cycles
1922                ARM7_ICOUNT -= 2;
18561923            }
1857
1858            // LDM (NO PC) takes nS + 1n + 1I cycles (n = # of register transfers)
1859            ARM7_ICOUNT -= result + 1 + 1;
18601924        }
1925        // LDM (NO PC) takes (n)S + 1N + 1I cycles (n = # of register transfers)
1926        ARM7_ICOUNT -= result + 1 + 1;
18611927    } /* Loading */
18621928    else
18631929    {
r9922r9923
19291995        if (insn & (1 << eR15))
19301996            R15 -= 12;
19311997
1932        // STM takes (n+1)S+2N+1I cycles (n = # of register transfers)
1933        ARM7_ICOUNT -= (result + 1) + 2 + 1;
1998        // STM takes (n-1)S + 2N cycles (n = # of register transfers)
1999        ARM7_ICOUNT -= (result - 1) + 2;
19342000    }
19352001
19362002    // We will specify the cycle count for each case, so remove the -3 that occurs at the end
src/emu/emuopts.c
r9922r9923
159159   { "cheat;c",                     "0",         OPTION_BOOLEAN,    "enable cheat subsystem" },
160160   { "skip_gameinfo",               "0",         OPTION_BOOLEAN,    "skip displaying the information screen at startup" },
161161   { "uifont",                   "default",   0,                 "specify a font to use" },
162   { "ramsize;ram",             NULL,           0,             "size of RAM (if supported by driver)" },
163#ifdef MESS   
164   { "newui;nu",                    "0",        OPTION_BOOLEAN,    "use the new MESS UI" },
165#endif
162166
163167   /* image device options */
164168   { OPTION_ADDED_DEVICE_OPTIONS,    "0",        OPTION_BOOLEAN | OPTION_INTERNAL,   "image device-specific options have been added" },
r9922r9923
306310
307311   /* we need to dynamically add options when the device name is parsed */
308312   options_set_option_callback(opts, OPTION_GAMENAME, image_driver_name_callback);
309
310#ifdef MESS
311   mess_options_init(opts);
312#endif /* MESS */
313
314313   return opts;
315314}
src/emu/emuopts.h
r9922r9923
153153#define OPTION_CHEAT            "cheat"
154154#define OPTION_SKIP_GAMEINFO      "skip_gameinfo"
155155#define OPTION_UI_FONT            "uifont"
156#define OPTION_RAMSIZE            "ramsize"
156157
157158/* image device options */
158159#define OPTION_ADDED_DEVICE_OPTIONS   "added_device_options"
src/emu/uimenu.c
r9922r9923
17251725
17261726         /* add if we match the group and we have a valid name */
17271727         if (name != NULL && input_condition_true(machine, &field->condition) &&
1728#ifdef MESS
17291728            (field->category == 0 || input_category_active(machine, field->category)) &&
1730#endif /* MESS */
17311729            ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine, field->type, field->player) != IPG_INVALID))
17321730         {
17331731            input_seq_type seqtype;
src/emu/inptport.c
r9922r9923
47064706int input_machine_has_keyboard(running_machine *machine)
47074707{
47084708   int have_keyboard = FALSE;
4709#ifdef MESS
47104709   const input_field_config *field;
47114710   const input_port_config *port;
47124711   for (port = machine->m_portlist.first(); port != NULL; port = port->next())
r9922r9923
47204719         }
47214720      }
47224721   }
4723#endif
4724
47254722   return have_keyboard;
47264723}
47274724
src/emu/sound/disc_sys.c
r9922r9923
3939static void task_check(discrete_task *task, discrete_task *dest_task)
4040{
4141   int inputnum;
42   const linked_list_entry *node_entry;
43   const linked_list_entry *step_entry;
4442
4543   /* Determine, which nodes in the task are referenced by nodes in dest_task
4644     * and add them to the list of nodes to be buffered for further processing
4745     */
48   for (node_entry = task->list; node_entry != NULL; node_entry = node_entry->next)
46   for_each(node_description *, node_entry, &task->list)
4947   {
50      const node_description *task_node = (node_description *) node_entry->ptr;
48      node_description *task_node = node_entry.item();
5149
52      for (step_entry = dest_task->list; step_entry != NULL; step_entry = step_entry->next)
50      for_each(node_description *, step_entry, &dest_task->list)
5351      {
54         node_description *dest_node = (node_description *) step_entry->ptr;
52         node_description *dest_node = step_entry.item();
5553
5654         /* loop over all active inputs */
57         for (inputnum = 0; inputnum < dest_node->active_inputs; inputnum++)
55         for (inputnum = 0; inputnum < dest_node->active_inputs(); inputnum++)
5856         {
59            int inputnode = dest_node->block->input_node[inputnum];
57            int inputnode = dest_node->input_node(inputnum);
6058            if IS_VALUE_A_NODE(inputnode)
6159            {
62               if (NODE_DEFAULT_NODE(task_node->block->node) == NODE_DEFAULT_NODE(inputnode))
60               if (NODE_DEFAULT_NODE(task_node->block_node()) == NODE_DEFAULT_NODE(inputnode))
6361               {
6462                  discrete_source_node *source;
6563                  int i, found = -1;
6664
6765                  for (i = 0; i < task->numbuffered; i++)
68                     if (task->nodes[i]->block->node == inputnode)
66                     if (task->nodes[i]->block_node() == inputnode)
6967                     {
7068                        found = i;
7169                        break;
r9922r9923
8381                     i = task->numbuffered;
8482                     task->numbuffered++;
8583                  }
86                  discrete_log(task_node->info, "dso_task_start - buffering %d(%d) in task %p group %d referenced by %d group %d", NODE_INDEX(inputnode), NODE_CHILD_NODE_NUM(inputnode), task, task->task_group, NODE_BLOCKINDEX(dest_node), dest_task->task_group);
84                  discrete_log(task_node->info, "dso_task_start - buffering %d(%d) in task %p group %d referenced by %d group %d", NODE_INDEX(inputnode), NODE_CHILD_NODE_NUM(inputnode), task, task->task_group, dest_node->index(), dest_task->task_group);
8785
8886                  /* register into source list */
8987                  source = auto_alloc(dest_node->info->device->machine, discrete_source_node);
90                  linked_list_add(dest_node->info,
91                        &dest_task->source_list,
92                        source);
88                  dest_task->source_list.add_tail(source);
9389                  source->task = task;
9490                  source->output_node = i;
9591
r9922r9923
109105{
110106   DISCRETE_DECLARE_TASK
111107
112   const linked_list_entry *task_entry;
113
114108   task->task_group = (int) DISCRETE_INPUT(0);
115109
116110   if (task->task_group < 0 || task->task_group >= DISCRETE_MAX_TASK_GROUPS)
117111      fatalerror("discrete_dso_task: illegal task_group %d", task->task_group);
118112
119   for (task_entry = node->info->task_list; task_entry != NULL; task_entry = task_entry->next)
113   for_each(discrete_task *, dest_task, &node->info->task_list)
120114   {
121      discrete_task *dest_task = (discrete_task *) task_entry->ptr;
122
123      if (task->task_group > dest_task->task_group)
124         task_check(dest_task, task);
115      if (task->task_group > dest_task.item()->task_group)
116         task_check(dest_task.item(), task);
125117   }
126118
127119}
r9922r9923
140132{
141133   DISCRETE_DECLARE_TASK
142134
143   const linked_list_entry *entry;
144
145135   /* update source node buffer */
146   for (entry = task->source_list; entry != NULL; entry = entry->next)
136   for_each(discrete_source_node *, sn, &task->source_list)
147137   {
148      discrete_source_node *sn = (discrete_source_node *) entry->ptr;
149      sn->buffer = *sn->ptr++;
138      sn.item()->buffer = *sn.item()->ptr++;
150139   }
151140}
152141
r9922r9923
179168
180169   int log_num, node_num;
181170
182   log_num = node_module_index(node);
171   log_num = node->same_module_index(node->info->node_list);
183172   context->sample_num = 0;
184173
185174   sprintf(context->name, "discrete_%s_%d.csv", node->info->device->tag(), log_num);
r9922r9923
190179   fprintf(context->csv_file, "\"Sample Rate\", %d\n", node->info->sample_rate);
191180   fprintf(context->csv_file, "\n");
192181   fprintf(context->csv_file, "\"Sample\"");
193   for (node_num = 0; node_num < node->active_inputs; node_num++)
182   for (node_num = 0; node_num < node->active_inputs(); node_num++)
194183   {
195      fprintf(context->csv_file, ", \"NODE_%2d\"", NODE_INDEX(node->block->input_node[node_num]));
184      fprintf(context->csv_file, ", \"NODE_%2d\"", NODE_INDEX(node->input_node(node_num)));
196185   }
197186   fprintf(context->csv_file, "\n");
198187}
r9922r9923
214203
215204   /* Dump any csv logs */
216205   fprintf(context->csv_file, "%" I64FMT "d", ++context->sample_num);
217   for (nodenum = 0; nodenum < node->active_inputs; nodenum++)
206   for (nodenum = 0; nodenum < node->active_inputs(); nodenum++)
218207   {
219208      fprintf(context->csv_file, ", %f", *node->input[nodenum]);
220209   }
r9922r9923
227216
228217   int log_num;
229218
230   log_num = node_module_index(node);
219   log_num = node->same_module_index(node->info->node_list);
231220   sprintf(context->name, "discrete_%s_%d.wav", node->info->device->tag(), log_num);
232   context->wavfile = wav_open(context->name, node->info->sample_rate, node->active_inputs/2);
221   context->wavfile = wav_open(context->name, node->info->sample_rate, node->active_inputs()/2);
233222}
234223
235224DISCRETE_STOP( dso_wavlog )
r9922r9923
253242   val = DISCRETE_INPUT(0) * DISCRETE_INPUT(1);
254243   val = (val < -32768) ? -32768 : (val > 32767) ? 32767 : val;
255244   wave_data_l = (INT16)val;
256   if (node->active_inputs == 2)
245   if (node->active_inputs() == 2)
257246   {
258247      /* DISCRETE_WAVLOG1 */
259248      wav_add_data_16(context->wavfile, &wave_data_l, 1);
src/emu/sound/disc_inp.c
r9922r9923
4444   sound_stream *buffer_stream;
4545};
4646
47#if 0
4748INLINE discrete_info *get_safe_token(device_t *device)
4849{
4950   assert(device != NULL);
5051   assert(device->type() == DISCRETE);
5152   return (discrete_info *)downcast<legacy_device_base *>(device)->token();
5253}
54#endif
5355
5456READ8_DEVICE_HANDLER(discrete_sound_r)
5557{
56   discrete_info    *info = get_safe_token(device);
57   node_description *node = discrete_find_node(info, offset);
58
59   UINT8 data = 0;
60
61   /* Read the node input value if allowed */
62   if (node)
63   {
64      /* Bring the system up to now */
65      stream_update(info->discrete_stream);
66
67      data = (UINT8) node->output[NODE_CHILD_NODE_NUM(offset)];
68   }
69   else
70      fatalerror("discrete_sound_r read from non-existent NODE_%02d\n", offset-NODE_00);
71
72    return data;
58   discrete_device *disc_device = downcast<discrete_device *>(device);
59   return    disc_device->read( *disc_device->machine->firstcpu->space(), offset, 0xff);
7360}
7461
7562
7663WRITE8_DEVICE_HANDLER(discrete_sound_w)
7764{
78   discrete_info    *info = get_safe_token(device);
79   node_description *node = discrete_find_node(info, offset);
80
81   /* Update the node input value if it's a proper input node */
82   if (node)
83   {
84      struct dss_input_context *context = (struct dss_input_context *)node->context;
85      UINT8 new_data    = 0;
86
87      switch (node->module->type)
88      {
89         case DSS_INPUT_DATA:
90         case DSS_INPUT_BUFFER:
91            new_data = data;
92            break;
93         case DSS_INPUT_LOGIC:
94         case DSS_INPUT_PULSE:
95            new_data = data ? 1 : 0;
96            break;
97         case DSS_INPUT_NOT:
98            new_data = data ? 0 : 1;
99            break;
100      }
101
102      if (context->data != new_data)
103      {
104         if (context->is_buffered)
105         {
106            /* Bring the system up to now */
107            stream_update(context->buffer_stream);
108
109            context->data = new_data;
110         }
111         else
112         {
113            /* Bring the system up to now */
114            stream_update(info->discrete_stream);
115
116            context->data = new_data;
117
118            /* Update the node output here so we don't have to do it each step */
119            node->output[0] = new_data * context->gain + context->offset;
120         }
121      }
122   }
123   else
124   {
125      discrete_log(info, "discrete_sound_w write to non-existent NODE_%02d\n", offset-NODE_00);
126   }
65   discrete_device *disc_device = downcast<discrete_device *>(device);
66   disc_device->write(*disc_device->machine->firstcpu->space(), offset, data, 0xff);
12767}
12868
12969/************************************************************************
r9922r9923
172112
173113   double min, max;
174114
175   context->port = node->info->device->machine->m_portlist.find((const char *)node->custom);
115   context->port = node->info->device->machine->m_portlist.find((const char *)node->custom_data());
176116   if (context->port == NULL)
177      fatalerror("DISCRETE_ADJUSTMENT - NODE_%d has invalid tag", NODE_BLOCKINDEX(node));
117      fatalerror("DISCRETE_ADJUSTMENT - NODE_%d has invalid tag", node->index());
178118
179119   context->lastpval = 0x7fffffff;
180120   context->pmin     = DSS_ADJUSTMENT__PMIN;
r9922r9923
302242{
303243   DISCRETE_DECLARE_CONTEXT(dss_input)
304244
305   assert(DSS_INPUT_STREAM__STREAM < linked_list_count(node->info->input_list));
245   //assert(DSS_INPUT_STREAM__STREAM < node->info->input_list.count());
306246
307247   context->is_stream = TRUE;
308248   /* Stream out number is set during start */
r9922r9923
312252   context->ptr = NULL;
313253   //context->data = 0;
314254
315   if (node->block->type == DSS_INPUT_BUFFER)
255   if (node->block_type() == DSS_INPUT_BUFFER)
316256   {
317257      context->is_buffered = TRUE;
318258      context->buffer_stream = stream_create(node->info->device, 0, 1, node->info->sample_rate, (void *) node, buffer_stream_update);
src/emu/sound/disc_mth.c
r9922r9923
472472
473473   int      addr;
474474
475   context->size = node->active_inputs - DST_DIODE_MIX_INP_OFFSET;
475   context->size = node->active_inputs() - DST_DIODE_MIX_INP_OFFSET;
476476   assert(context->size <= 8);
477477
478478   for (addr = 0; addr < context->size; addr++)
r9922r9923
512512      if(DST_DIVIDE__DIV == 0)
513513      {
514514         node->output[0 ]= DBL_MAX;   /* Max out but don't break */
515         discrete_log(node->info, "dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",NODE_BLOCKINDEX(node));
515         discrete_log(node->info, "dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",node->index());
516516      }
517517      else
518518      {
r9922r9923
13381338         context->c_bit_flag |= 1 << bit;
13391339   }
13401340
1341   context->size = node->active_inputs - 1;
1341   context->size = node->active_inputs() - 1;
13421342
13431343   /*
13441344     * THERE IS NO ERROR CHECKING!!!!!!!!!
r9922r9923
14471447   else
14481448   {
14491449      /* Bad address.  We will leave the output alone. */
1450      discrete_log(node->info, "NODE_%02d - Address = %d. Out of bounds\n", NODE_BLOCKINDEX(node), addr);
1450      discrete_log(node->info, "NODE_%02d - Address = %d. Out of bounds\n", node->index(), addr);
14511451   }
14521452}
14531453
r9922r9923
14551455{
14561456   DISCRETE_DECLARE_CONTEXT(dst_size)
14571457
1458   context->size = node->active_inputs - 1;
1458   context->size = node->active_inputs() - 1;
14591459
14601460   DISCRETE_STEP_CALL(dst_multiplex);
14611461}
r9922r9923
17511751   double   number1,top;
17521752   int      trans_stack_ptr = 0;
17531753
1754   const char *fPTR = (const char *)node->custom;
1754   const char *fPTR = (const char *)node->custom_data();
17551755
17561756   top = HUGE_VAL;
17571757
r9922r9923
18321832            top = (int)number1 ^ (int)top;
18331833            break;
18341834         default:
1835            discrete_log(node->info, "dst_transform_step - Invalid function type/variable passed: %s",(const char *)node->custom);
1835            discrete_log(node->info, "dst_transform_step - Invalid function type/variable passed: %s",(const char *)node->custom_data());
18361836            /* that is enough to fatalerror */
1837            fatalerror("dst_transform_step - Invalid function type/variable passed: %s", (const char *)node->custom);
1837            fatalerror("dst_transform_step - Invalid function type/variable passed: %s", (const char *)node->custom_data());
18381838            break;
18391839      }
18401840   }
src/emu/sound/discrete.c
r9922r9923
8282 *************************************/
8383
8484static void init_nodes(discrete_info *info, const linked_list_entry *block_list, device_t *device);
85static void find_input_nodes(const discrete_info *info);
8685static node_description *discrete_find_node(const discrete_info *info, int node);
87static DEVICE_RESET( discrete );
88static STREAM_UPDATE( discrete_stream_update );
86//static DEVICE_RESET( discrete );
87//static STREAM_UPDATE( discrete_stream_update );
8988static STREAM_UPDATE( buffer_stream_update );
9089
9190static int profiling = 0;
r9922r9923
120119 *
121120 *************************************/
122121
123INLINE int node_module_index(const node_description *node)
124{
125   linked_list_entry *entry;
126   int index = 0;
127
128   for (entry = node->info->node_list; entry != NULL; entry = entry->next)
129   {
130      node_description *n = (node_description *) entry->ptr;
131
132      if (n == node)
133         return index;
134      if (n->module->type == node->module->type)
135         index++;
136   }
137   return -1;
138}
139
140122INLINE void linked_list_tail_add(const discrete_info *info, linked_list_entry ***list_tail_ptr, const void *ptr)
141123{
142124   **list_tail_ptr = auto_alloc(info->device->machine, linked_list_entry);
r9922r9923
318300   { DSS_NULL        ,"DSS_NULL"        , 0 ,0                                      ,NULL                  ,NULL                 ,NULL                  ,NULL                 }
319301};
320302
321INLINE void step_nodes_in_list(const linked_list_entry *list)
303INLINE void step_nodes_in_list(node_list_t &list)
322304{
323   const linked_list_entry *entry;
324305
325306   if (EXPECTED(!profiling))
326307   {
327      for (entry = list; entry != NULL; entry = entry->next)
308      for_each(node_description *, entry, &list)
328309      {
329         node_description *node = (node_description *) entry->ptr;
330
331310         /* Now step the node */
332         (*node->step)(node);
311         (*entry.item()->step)(entry.item());
333312      }
334313   }
335314   else
336315   {
337316      osd_ticks_t last = get_profile_ticks();
338317
339      for (entry = list; entry != NULL; entry = entry->next)
318      for_each(node_description *, entry, &list)
340319      {
341         node_description *node = (node_description *) entry->ptr;
320         node_description *node = entry.item();
342321
343322         node->run_time -= last;
344323         (*node->step)(node);
r9922r9923
476455 *  Master discrete system start
477456 *
478457 *************************************/
479
458#if 0
480459static DEVICE_START( discrete )
481460{
482461   linked_list_entry **intf;
483   const linked_list_entry *entry;
484462   const discrete_sound_block *intf_start = (discrete_sound_block *)device->baseconfig().static_config();
485463   discrete_info *info = get_safe_token(device);
486464   char name[32];
r9922r9923
516494   discrete_sanity_check(info);
517495
518496   /* Start with empty lists */
519   info->node_list = NULL;
520   info->output_list = NULL;
521   info->input_list = NULL;
497   info->node_list.reset();
498   info->output_list.reset();
499   info->input_list.reset();
522500
523501   /* allocate memory to hold pointers to nodes by index */
524502   info->indexed_node = auto_alloc_array_clear(device->machine, node_description *, DISCRETE_MAX_NODES);
r9922r9923
527505   init_nodes(info, info->block_list, device);
528506
529507   /* now go back and find pointers to all input nodes */
530   find_input_nodes(info);
508   for_each(node_description *, node, &info->node_list)
509   {
510      node.item()->find_input_nodes();
511   }
531512
532513   /* initialize the stream(s) */
533   info->discrete_stream = stream_create(device,linked_list_count(info->input_list), linked_list_count(info->output_list), info->sample_rate, info, discrete_stream_update);
514   info->discrete_stream = stream_create(device,info->input_list.count(), info->output_list.count(), info->sample_rate, info, discrete_stream_update);
534515
535516   /* allocate a queue */
536517
r9922r9923
538519
539520   /* Process nodes which have a start func */
540521
541   for (entry = info->node_list; entry != NULL; entry = entry->next)
522   for_each(node_description *, node, &info->node_list)
542523   {
543      node_description *node = (node_description *) entry->ptr;
544
545      if (node->module->start)
546         (*node->module->start)(node);
524      if (node.item()->module->start)
525         (*node.item()->module->start)(node.item());
547526   }
548527
549528}
529#endif
550530
551531
552
553532/*************************************
554533 *
555534 *  Master discrete system stop
556535 *
557536 *************************************/
558537
559static UINT64 list_run_time(const linked_list_entry *list)
538static UINT64 list_run_time(const node_list_t &list)
560539{
561   const linked_list_entry *entry;
562540   UINT64 total = 0;
563541
564   for (entry = list; entry != NULL; entry = entry->next)
542   for_each(node_description *, node, &list)
565543   {
566      node_description *node = (node_description *) entry->ptr;
567
568      total += node->run_time;
544      total += node.item()->run_time;
569545   }
570546   return total;
571547}
r9922r9923
576552   UINT64 total;
577553   UINT64 tresh;
578554   double tt;
579   linked_list_entry *entry;
580555
581556   /* calculate total time */
582557   total = list_run_time(info->node_list);
583   count = linked_list_count(info->node_list);
558   count = info->node_list.count();
584559   /* print statistics */
585560   printf("Total Samples  : %16" I64FMT "d\n", info->total_samples);
586561   tresh = total / count;
587562   printf("Threshold (mean): %16" I64FMT "d\n", tresh / info->total_samples );
588   for (entry = info->node_list; entry != NULL; entry = entry->next)
563   for_each(node_description *, node, &info->node_list)
589564   {
590      node_description *node = (node_description *) entry->ptr;
591
592      if (node->run_time > tresh)
593         printf("%3d: %20s %8.2f %10.2f\n", NODE_BLOCKINDEX(node), node->module->name, (float) node->run_time / (float) total * 100.0, ((float) node->run_time) / (float) info->total_samples);
565      if (node.item()->run_time > tresh)
566         printf("%3d: %20s %8.2f %10.2f\n", node.item()->index(), node.item()->module->name, (float) node.item()->run_time / (float) total * 100.0, ((float) node.item()->run_time) / (float) info->total_samples);
594567   }
595568
596569   /* Task information */
597   for (entry = info->task_list; entry != 0; entry = entry->next)
570   for_each(discrete_task *, task, &info->task_list)
598571   {
599      discrete_task *task = (discrete_task *) entry->ptr;
600      tt =  list_run_time(task->list);
572      tt =  list_run_time(task.item()->list);
601573
602      printf("Task(%d): %8.2f %15.2f\n", task->task_group, tt / (double) total * 100.0, tt / (double) info->total_samples);
574      printf("Task(%d): %8.2f %15.2f\n", task.item()->task_group, tt / (double) total * 100.0, tt / (double) info->total_samples);
603575   }
604576
605577   printf("Average samples/stream_update: %8.2f\n", (double) info->total_samples / (double) info->total_stream_updates);
606578}
607579
580#if 0
608581static DEVICE_STOP( discrete )
609582{
610583   discrete_info *info = get_safe_token(device);
611   const linked_list_entry *entry;
612584
613585   osd_work_queue_free(info->queue);
614586
r9922r9923
619591
620592   /* Process nodes which have a stop func */
621593
622   for (entry = info->node_list; entry != NULL; entry = entry->next)
594   for_each(node_description *, node, &info->node_list)
623595   {
624      node_description *node = (node_description *) entry->ptr;
625
626      if (node->module->stop)
627         (*node->module->stop)(node);
596      if (node.item()->module->stop)
597         (*node.item()->module->stop)(node.item());
628598   }
629599
630600   if (DISCRETE_DEBUGLOG)
r9922r9923
635605      info->disclogfile = NULL;
636606   }
637607}
608#endif
638609
639610
640
641611/*************************************
642612 *
643613 *  Master reset of all nodes
644614 *
645615 *************************************/
646
616#if 0
647617static DEVICE_RESET( discrete )
648618{
649619   const discrete_info *info = get_safe_token(device);
650   const linked_list_entry *entry;
651620
652621   /* loop over all nodes */
653   for (entry = info->node_list; entry != 0; entry = entry->next)
622   for_each (node_description *, node, &info->node_list)
654623   {
655      node_description *node = (node_description *) entry->ptr;
624      node.item()->output[0] = 0;
656625
657      node->output[0] = 0;
658
659626      /* if the node has a reset function, call it */
660      if (node->module->reset)
661         (*node->module->reset)(node);
627      if (node.item()->module->reset)
628         (*node.item()->module->reset)(node.item());
662629
663630      /* otherwise, just step it */
664      else if (node->step)
665         (*node->step)(node);
631      else if (node.item()->step)
632         (*node.item()->step)(node.item());
666633   }
667634}
635#endif
668636
669637/*************************************
670638 *
r9922r9923
674642
675643static void *task_callback(void *param, int threadid)
676644{
677   const linked_list_entry *list = (linked_list_entry *) param;
678   const linked_list_entry *entry;
645   task_list_t *list = (task_list_t *) param;
679646   int samples;
680647
681648   do
682649   {
683      for (entry = list; entry != 0; entry = entry->next)
650      for_each(discrete_task *, task, list)
684651      {
685         discrete_task      *task = (discrete_task *) entry->ptr;
686         INT32            prev_id;
687
688652         /* try to lock */
689         prev_id = compare_exchange32(&task->threadid, -1, threadid);
690         if (prev_id == -1 && task->threadid == threadid)
653         if (task.item()->lock_threadid(threadid))
691654         {
692            linked_list_entry   *src_entry;
655            samples = MIN(task.item()->samples, MAX_SAMPLES_PER_TASK_SLICE);
693656
694            samples = MIN(task->samples, MAX_SAMPLES_PER_TASK_SLICE);
695
696657            /* check dependencies */
697            for (src_entry = task->source_list; src_entry != NULL; src_entry = src_entry->next)
658            for_each(discrete_source_node *, sn, &task.item()->source_list)
698659            {
699               discrete_source_node *sn = (discrete_source_node *) src_entry->ptr;
700660               int avail;
701661
702               avail = sn->task->ptr[sn->output_node] - sn->ptr;
662               avail = sn.item()->task->ptr[sn.item()->output_node] - sn.item()->ptr;
703663               assert_always(avail >= 0, "task_callback: available samples are negative");
704664               if (avail < samples)
705665                  samples = avail;
706666            }
707667
708            task->samples -= samples;
709            assert_always(task->samples >=0, "task_callback: task_samples got negative");
668            task.item()->samples -= samples;
669            assert_always(task.item()->samples >=0, "task_callback: task_samples got negative");
710670            while (samples > 0)
711671            {
712672               /* step */
713               step_nodes_in_list(task->list);
673               step_nodes_in_list(task.item()->list);
714674               samples--;
715675            }
716            if (task->samples == 0)
676            if (task.item()->samples == 0)
717677            {
678               /* return and keep the task locked so it is not picked up by other worker threads */
718679               return NULL;
719680            }
720            task->threadid = -1;
681            task.item()->unlock();
721682         }
722683      }
723684   } while (1);
r9922r9923
738699     *(ptr++) = data;
739700}
740701
741
702#if 0
742703static STREAM_UPDATE( discrete_stream_update )
743704{
744705   discrete_info *info = (discrete_info *)param;
745   const linked_list_entry *entry;
746706   int outputnum;
747707   //, task_group;
748708
r9922r9923
750710      return;
751711
752712   /* Setup any output streams */
753   for (entry = info->output_list, outputnum = 0; entry != NULL; entry = entry->next, outputnum++)
713   outputnum = 0;
714   for_each(node_description *, node, &info->output_list)
754715   {
755      ((node_description *) entry->ptr)->context = (void *) outputs[outputnum];
716      node.item()->context = (void *) outputs[outputnum];
717      outputnum++;
756718   }
757719
758720   /* Setup any input streams */
759   for (entry = info->input_list; entry != NULL; entry = entry->next)
721   for_each(node_description *, node, &info->input_list)
760722   {
761      struct dss_input_context *context = (struct dss_input_context *) ((node_description *) entry->ptr)->context;
723      struct dss_input_context *context = (struct dss_input_context *) node.item()->context;
762724      context->ptr = (stream_sample_t *) inputs[context->stream_in_number];
763725   }
764726
765727   /* Setup tasks */
766   for (entry = info->task_list; entry != 0; entry = entry->next)
728   for_each(discrete_task *, task, &info->task_list)
767729   {
768      discrete_task      *task = (discrete_task *) entry->ptr;
769      linked_list_entry   *src_entry;
770730      int               i;
771731
772      task->samples = samples;
773      task->threadid = -1;
732      task.item()->samples = samples;
733      /* unlock the thread */
734      task.item()->unlock();
774735
775736      /* set up task buffers */
776      for (i = 0; i < task->numbuffered; i++)
777         task->ptr[i] = task->node_buf[i];
737      for (i = 0; i < task.item()->numbuffered; i++)
738         task.item()->ptr[i] = task.item()->node_buf[i];
778739
779740      /* initialize sources */
780      for (src_entry = task->source_list; src_entry != 0; src_entry = src_entry->next)
741      for_each(discrete_source_node *, sn, &task.item()->source_list)
781742      {
782         discrete_source_node *sn = (discrete_source_node *) src_entry->ptr;
783         sn->ptr = sn->task->node_buf[sn->output_node];
743         sn.item()->ptr = sn.item()->task->node_buf[sn.item()->output_node];
784744      }
785745   }
786746
787   for (entry = info->task_list; entry != 0; entry = entry->next)
747   for_each(discrete_task *, task, &info->task_list)
788748   {
789749      /* Fire a work item for each task */
790      osd_work_item_queue(info->queue, task_callback, (void *) info->task_list, WORK_ITEM_FLAG_AUTO_RELEASE);
750      osd_work_item_queue(info->queue, task_callback, (void *) &info->task_list, WORK_ITEM_FLAG_AUTO_RELEASE);
791751   }
792752   osd_work_queue_wait(info->queue, osd_ticks_per_second()*10);
793753
r9922r9923
798758   }
799759
800760}
761#endif
801762
802763
803
804764/*************************************
805765 *
806766 *  First pass init of nodes
r9922r9923
811771static void init_nodes(discrete_info *info, const linked_list_entry *block_list, device_t *device)
812772{
813773   const linked_list_entry   *entry;
814   linked_list_entry   *task_node_list = NULL;
815774   discrete_task *task = NULL;
816775   /* list tail pointers */
817   linked_list_entry   **task_node_list_ptr = NULL;
818   linked_list_entry   **node_list_ptr = &info->node_list;
819   linked_list_entry   **task_list_ptr = &info->task_list;
820   linked_list_entry   **output_list_ptr = &info->output_list;
821   linked_list_entry   **input_list_ptr = &info->input_list;
822776   int               has_tasks = 0;
823777
824778   /* check whether we have tasks ... */
r9922r9923
831785
832786   if (!has_tasks)
833787   {
834      /* set up a main task */
835      task_node_list = NULL;
836      task_node_list_ptr = &task_node_list;
788      /* make sure we have one simple task
789         * No need to create a node since there are no dependencies.
790         */
791      task = auto_alloc_clear(info->device->machine, discrete_task);
792      info->task_list.add_tail(task);
837793   }
838794
839795   /* loop over all nodes */
840796   for (entry = block_list; entry != NULL; entry = entry->next)
841797   {
842798      const discrete_sound_block *block = (discrete_sound_block *) entry->ptr;
843      node_description *node = auto_alloc_clear(info->device->machine, node_description);
844799      int modulenum;
845800
846801      /* find the requested module */
r9922r9923
850805      if (module_list[modulenum].type != block->type)
851806         fatalerror("init_nodes() - Unable to find discrete module type %d for NODE_%02d", block->type, NODE_INDEX(block->node));
852807
853      /* static inits */
854      node->context = NULL;
855      node->info = info;
856      node->module = &module_list[modulenum];
857      node->output[0] = 0.0;
858      node->block = block;
859      node->custom = block->custom;
860      node->active_inputs = block->active_inputs;
861      node->run_time = 0;
808      node_description *node = auto_alloc_clear(info->device->machine, node_description(info, &module_list[modulenum], block));
862809
863      /* setup module if custom */
864      if (block->type == DST_CUSTOM)
865      {
866         const discrete_custom_info *custom = (const discrete_custom_info *)node->custom;
867         node->module = &custom->module;
868         node->custom = custom->custom;
869      }
870
871      /* copy initial / default step function */
872      node->step = node->module->step;
873
874      /* allocate memory if necessary */
875      if (node->module->contextsize)
876         node->context = auto_alloc_array_clear(device->machine, UINT8, node->module->contextsize);
877
878810      /* keep track of special nodes */
879811      if (block->node == NODE_SPECIAL)
880812      {
r9922r9923
882814         {
883815            /* Output Node */
884816            case DSO_OUTPUT:
885               linked_list_tail_add(info, &output_list_ptr, node);
817               info->output_list.add_tail(node);
886818               break;
887819
888820            /* CSVlog Node for debugging */
r9922r9923
895827
896828            /* Task processing */
897829            case DSO_TASK_START:
898               if (task_node_list_ptr != NULL)
830               if (task != NULL)
899831                  fatalerror("init_nodes() - Nested DISCRETE_START_TASK.");
900832               task = auto_alloc_clear(info->device->machine, discrete_task);
901833               node->context = task;
902               task_node_list = NULL;
903               task_node_list_ptr = &task_node_list;
904834               break;
905835
906836            case DSO_TASK_END:
907               if (task_node_list_ptr == NULL)
837               if (task == NULL)
908838                  fatalerror("init_nodes() - NO DISCRETE_START_TASK.");
909839               task->numbuffered = 0;
910               task->list = task_node_list;
911840               task->task_group = -1; /* will be set later */
912               task->source_list = NULL;
913               linked_list_tail_add(info, &task_list_ptr, task);
841               task->source_list.reset();
842               info->task_list.add_tail(task);
914843               node->context = task;
915               task = NULL;
916               task_node_list = NULL;
844               //task = NULL;
917845               break;
918846
919847            default:
r9922r9923
932860      /* if we are an stream input node, track that */
933861      if (block->type == DSS_INPUT_STREAM)
934862      {
935         linked_list_tail_add(info, &input_list_ptr, node);
863         info->input_list.add_tail(node);
936864      }
937865      else if (block->type == DSS_INPUT_BUFFER)
938866      {
939         linked_list_tail_add(info, &input_list_ptr, node);
867         info->input_list.add_tail(node);
940868      }
941869
942870      /* add to node list */
943      linked_list_tail_add(info, &node_list_ptr, node);
871      info->node_list.add_tail(node);
944872
945873      /* our running order just follows the order specified */
946874      /* does the node step ? */
947875      if (node->step != NULL)
948876      {
949877         /* do we belong to a task? */
950         if (task_node_list_ptr == NULL)
878         if (task == NULL)
951879            fatalerror("init_nodes() - found node outside of task.");
952880         else
953            linked_list_tail_add(info, &task_node_list_ptr, node);
881            task->list.add_tail(node);
954882      }
955883
956884      if (block->type == DSO_TASK_END)
957885      {
958         task_node_list_ptr = NULL;
886         task = NULL;
959887      }
960888
961889      /* and register save state */
962      if (node->block->node != NODE_SPECIAL)
963         state_save_register_device_item_array(device, node->block->node, node->output);
890      node->save_state(device);
964891   }
965892
966893   if (!has_tasks)
967894   {
968      /* make sure we have one simple task
969         * No need to create a node since there are no dependencies.
970         */
971      task = auto_alloc_clear(info->device->machine, discrete_task);
972      task->numbuffered = 0;
973      task->list = task_node_list;
974      task->task_group = 0;
975      task->source_list = NULL;
976      linked_list_tail_add(info, &task_list_ptr, task);
977895   }
978896
979897   /* if no outputs, give an error */
980   if (linked_list_count(info->output_list) == 0)
898   if (info->output_list.count() == 0)
981899      fatalerror("init_nodes() - Couldn't find an output node");
982900}
983901
984902
985903/*************************************
986904 *
987 *  Find and attach all input nodes
905 *  node_description implementation
988906 *
989907 *************************************/
990908
991/* attempt to group all static node parameters together.
992 * Has a negative impact on performance - but it should
993 * reduce memory bandwidth - this is weird. */
909node_description::node_description(const discrete_info * xinfo, const discrete_module *xmodule, const discrete_sound_block *xblock) :
910   context(NULL),
911   module(xmodule),
912   info(xinfo),
913   run_time(0),
914   m_block(xblock)
915{
916   output[0] = 0.0;
917   m_custom = m_block->custom;
918   m_active_inputs = m_block->active_inputs;
994919
995#if 0
996static double dbuf[10240] = { 0.0, 1.0 };
997static int dbufptr = 2;
998
999static double *getDoublePtr(double val)
1000{
1001   int i;
1002   for (i=0; i < dbufptr; i += 1)
920   /* setup module if custom */
921   if (m_block->type == DST_CUSTOM)
1003922   {
1004      if (dbuf[i] == val)
1005      {
1006         return &dbuf[i];
1007      }
923      const discrete_custom_info *custom = (const discrete_custom_info *)m_custom;
924      module = &custom->module;
925      m_custom = custom->custom;
1008926   }
1009   dbuf[dbufptr] = val;
1010   dbufptr+=1;
1011   return &dbuf[dbufptr-1];
927
928   /* copy initial / default step function */
929   step = module->step;
930
931   /* allocate memory if necessary */
932   if (module->contextsize)
933      context =  global_alloc_array(UINT8, module->contextsize);
1012934}
1013#endif
1014935
1015static void find_input_nodes(const discrete_info *info)
936node_description::~node_description(void)
1016937{
1017   const linked_list_entry *entry;
938   if (module->contextsize)
939      global_free(context);
940}
941
942int node_description::index(void)
943{
944   return NODE_INDEX(m_block->node);
945}
946
947void node_description::save_state(device_t *device)
948{
949   if (m_block->node != NODE_SPECIAL)
950      state_save_register_device_item_array(device, m_block->node, output);
951}
952
953void node_description::find_input_nodes(void)
954{
1018955   int inputnum;
1019956
1020   /* loop over all nodes */
1021   for (entry = info->node_list; entry != NULL; entry = entry->next)
957   /* loop over all active inputs */
958   for (inputnum = 0; inputnum < m_active_inputs; inputnum++)
1022959   {
1023      node_description *node = (node_description *) entry->ptr;
1024      const discrete_sound_block *block = node->block;
960      int inputnode = m_block->input_node[inputnum];
1025961
1026      /* loop over all active inputs */
1027      for (inputnum = 0; inputnum < node->active_inputs; inputnum++)
962      /* if this input is node-based, find the node in the indexed list */
963      if IS_VALUE_A_NODE(inputnode)
1028964      {
1029         int inputnode = block->input_node[inputnum];
965         const node_description *node_ref = info->indexed_node[NODE_INDEX(inputnode)];
966         if (!node_ref)
967            fatalerror("discrete_start - NODE_%02d referenced a non existent node NODE_%02d", index(), NODE_INDEX(inputnode));
1030968
1031         /* if this input is node-based, find the node in the indexed list */
1032         if IS_VALUE_A_NODE(inputnode)
969         if ((NODE_CHILD_NODE_NUM(inputnode) >= node_ref->module->num_output) && (node_ref->module->type != DST_CUSTOM))
970            fatalerror("discrete_start - NODE_%02d referenced non existent output %d on node NODE_%02d", index(), NODE_CHILD_NODE_NUM(inputnode), NODE_INDEX(inputnode));
971
972         input[inputnum] = &(node_ref->output[NODE_CHILD_NODE_NUM(inputnode)]);   /* Link referenced node out to input */
973         m_input_is_node |= 1 << inputnum;         /* Bit flag if input is node */
974      }
975      else
976      {
977         /* warn if trying to use a node for an input that can only be static */
978         if IS_VALUE_A_NODE(m_block->initial[inputnum])
1033979         {
1034            const node_description *node_ref = info->indexed_node[NODE_INDEX(inputnode)];
1035            if (!node_ref)
1036               fatalerror("discrete_start - NODE_%02d referenced a non existent node NODE_%02d", NODE_BLOCKINDEX(node), NODE_INDEX(inputnode));
1037
1038            if ((NODE_CHILD_NODE_NUM(inputnode) >= node_ref->module->num_output) && (node_ref->module->type != DST_CUSTOM))
1039               fatalerror("discrete_start - NODE_%02d referenced non existent output %d on node NODE_%02d", NODE_BLOCKINDEX(node), NODE_CHILD_NODE_NUM(inputnode), NODE_INDEX(inputnode));
1040
1041            node->input[inputnum] = &(node_ref->output[NODE_CHILD_NODE_NUM(inputnode)]);   /* Link referenced node out to input */
1042            node->input_is_node |= 1 << inputnum;         /* Bit flag if input is node */
980            discrete_log(info, "Warning - discrete_start - NODE_%02d trying to use a node on static input %d",  index(), inputnum);
981            /* also report it in the error log so it is not missed */
982            logerror("Warning - discrete_start - NODE_%02d trying to use a node on static input %d",  index(), inputnum);
1043983         }
1044984         else
1045985         {
1046            /* warn if trying to use a node for an input that can only be static */
1047            if IS_VALUE_A_NODE(block->initial[inputnum])
1048            {
1049               discrete_log(info, "Warning - discrete_start - NODE_%02d trying to use a node on static input %d",  NODE_BLOCKINDEX(node), inputnum);
1050               /* also report it in the error log so it is not missed */
1051               logerror("Warning - discrete_start - NODE_%02d trying to use a node on static input %d",  NODE_BLOCKINDEX(node), inputnum);
1052            }
1053            else
1054            {
1055               node->input[inputnum] = &(node->block->initial[inputnum]);
1056               //node->input[inputnum] = getDoublePtr(node->block->initial[inputnum]);
1057            }
986            input[inputnum] = &(m_block->initial[inputnum]);
987            //node->input[inputnum] = getDoublePtr(node->block->initial[inputnum]);
1058988         }
1059989      }
1060      for (inputnum = node->active_inputs; inputnum < DISCRETE_MAX_INPUTS; inputnum++)
1061      {
1062         /* FIXME: Check that no nodes follow ! */
1063         node->input[inputnum] = &(block->initial[inputnum]);
1064      }
1065990   }
991   for (inputnum = m_active_inputs; inputnum < DISCRETE_MAX_INPUTS; inputnum++)
992   {
993      /* FIXME: Check that no nodes follow ! */
994      input[inputnum] = &(m_block->initial[inputnum]);
995   }
1066996}
1067997
998int node_description::same_module_index(const node_list_t &list)
999{
1000   int index = 0;
1001
1002   for_each(node_description *, n, &list)
1003   {
1004      if (n.item() == this)
1005         return index;
1006      if (n.item()->module->type == this->module->type)
1007         index++;
1008   }
1009   return -1;
1010}
1011
1012#if 0
10681013/**************************************************************************
10691014 * Generic get_info
10701015 **************************************************************************/
r9922r9923
10921037
10931038
10941039DEFINE_LEGACY_SOUND_DEVICE(DISCRETE, discrete);
1040#endif
1041
1042//**************************************************************************
1043//  GLOBAL VARIABLES
1044//**************************************************************************
1045
1046const device_type DISCRETE = discrete_device_config::static_alloc_device_config;
1047
1048//**************************************************************************
1049//  DEVICE CONFIGURATION
1050//**************************************************************************
1051
1052#if 0
1053//-------------------------------------------------
1054//  static_set_type - configuration helper to set
1055//  the chip type
1056//-------------------------------------------------
1057
1058void discrete_device_config::static_set_type(device_config *device, int type)
1059{
1060   discrete_device_config *asc = downcast<discrete_device_config *>(device);
1061   asc->m_type = type;
1062}
1063
1064//-------------------------------------------------
1065//  static_set_type - configuration helper to set
1066//  the IRQ callback
1067//-------------------------------------------------
1068
1069
1070void discrete_device_config::static_set_irqf(device_config *device, void (*irqf)(device_t *device, int state))
1071{
1072   discrete_device_config *asc = downcast<discrete_device_config *>(device);
1073   asc->m_irq_func = irqf;
1074}
1075#endif
1076
1077//-------------------------------------------------
1078//  discrete_device_config - constructor
1079//-------------------------------------------------
1080
1081discrete_device_config::discrete_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
1082   : device_config(mconfig, static_alloc_device_config, "DISCRETE", tag, owner, clock),
1083     device_config_sound_interface(mconfig, *this)
1084{
1085}
1086
1087
1088//-------------------------------------------------
1089//  static_alloc_device_config - allocate a new
1090//  configuration object
1091//-------------------------------------------------
1092
1093device_config *discrete_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
1094{
1095   return global_alloc(discrete_device_config(mconfig, tag, owner, clock));
1096}
1097
1098
1099//-------------------------------------------------
1100//  alloc_device - allocate a new device object
1101//-------------------------------------------------
1102
1103device_t *discrete_device_config::alloc_device(running_machine &machine) const
1104{
1105   return auto_alloc(&machine, discrete_device(machine, *this));
1106}
1107
1108
1109//-------------------------------------------------
1110//  discrete_device - constructor
1111//-------------------------------------------------
1112
1113discrete_device::discrete_device(running_machine &_machine, const discrete_device_config &config)
1114   : device_t(_machine, config),
1115     device_sound_interface(_machine, config, *this),
1116     m_config(config)
1117{
1118   //memset(&m_info, 0, sizeof(m_info));
1119
1120}
1121
1122discrete_device::~discrete_device(void)
1123{
1124   discrete_info *info = &m_info;
1125
1126   osd_work_queue_free(info->queue);
1127
1128   if (profiling)
1129   {
1130      display_profiling(info);
1131   }
1132
1133   /* Process nodes which have a stop func */
1134
1135   for_each(node_description *, node, &info->node_list)
1136   {
1137      if (node.item()->module->stop)
1138         (*node.item()->module->stop)(node.item());
1139   }
1140
1141   if (DISCRETE_DEBUGLOG)
1142   {
1143      /* close the debug log */
1144       if (info->disclogfile)
1145          fclose(info->disclogfile);
1146      info->disclogfile = NULL;
1147   }
1148}
1149
1150//-------------------------------------------------
1151//  device_start - device-specific startup
1152//-------------------------------------------------
1153
1154void discrete_device::device_start()
1155{
1156   // create the stream
1157   //m_stream = stream_create(this, 0, 2, 22257, this, static_stream_generate);
1158
1159   linked_list_entry **intf;
1160   const discrete_sound_block *intf_start = (discrete_sound_block *) baseconfig().static_config();
1161   discrete_info *info = &m_info;
1162   char name[32];
1163
1164   info->device = this;
1165
1166   /* If a clock is specified we will use it, otherwise run at the audio sample rate. */
1167   if (this->clock())
1168      info->sample_rate = this->clock();
1169   else
1170      info->sample_rate = this->machine->sample_rate;
1171   info->sample_time = 1.0 / info->sample_rate;
1172   info->neg_sample_time = - info->sample_time;
1173
1174   info->total_samples = 0;
1175   info->total_stream_updates = 0;
1176
1177   /* create the logfile */
1178   sprintf(name, "discrete%s.log", this->tag());
1179   if (DISCRETE_DEBUGLOG)
1180      info->disclogfile = fopen(name, "w");
1181
1182   /* enable profiling */
1183   if (getenv("DISCRETE_PROFILING"))
1184      profiling = atoi(getenv("DISCRETE_PROFILING"));
1185
1186   /* Build the final block list */
1187   info->block_list = NULL;
1188   intf = &info->block_list;
1189   discrete_build_list(info, intf_start, &intf);
1190
1191   /* first pass through the nodes: sanity check, fill in the indexed_nodes, and make a total count */
1192   discrete_sanity_check(info);
1193
1194   /* Start with empty lists */
1195   info->node_list.reset();
1196   info->output_list.reset();
1197   info->input_list.reset();
1198
1199   /* allocate memory to hold pointers to nodes by index */
1200   info->indexed_node = auto_alloc_array_clear(this->machine, node_description *, DISCRETE_MAX_NODES);
1201
1202   /* initialize the node data */
1203   init_nodes(info, info->block_list, this);
1204
1205   /* now go back and find pointers to all input nodes */
1206   for_each(node_description *, node, &info->node_list)
1207   {
1208      node.item()->find_input_nodes();
1209   }
1210
1211   /* initialize the stream(s) */
1212   info->discrete_stream = stream_create(this,info->input_list.count(), info->output_list.count(), info->sample_rate, this, static_stream_generate);
1213
1214   /* allocate a queue */
1215
1216   info->queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI | WORK_QUEUE_FLAG_HIGH_FREQ);
1217
1218   /* Process nodes which have a start func */
1219
1220   for_each(node_description *, node, &info->node_list)
1221   {
1222      if (node.item()->module->start)
1223         (*node.item()->module->start)(node.item());
1224   }
1225}
1226
1227
1228//-------------------------------------------------
1229//  device_reset - device-specific reset
1230//-------------------------------------------------
1231
1232void discrete_device::device_reset()
1233{
1234
1235   const discrete_info *info = &m_info;
1236   stream_update(info->discrete_stream);
1237
1238   /* loop over all nodes */
1239   for_each (node_description *, node, &info->node_list)
1240   {
1241      node.item()->output[0] = 0;
1242
1243      /* if the node has a reset function, call it */
1244      if (node.item()->module->reset)
1245         (*node.item()->module->reset)(node.item());
1246
1247      /* otherwise, just step it */
1248      else if (node.item()->step)
1249         (*node.item()->step)(node.item());
1250   }
1251}
1252
1253//-------------------------------------------------
1254//  stream_generate - handle update requests for
1255//  our sound stream
1256//-------------------------------------------------
1257
1258STREAM_UPDATE( discrete_device::static_stream_generate )
1259{
1260   reinterpret_cast<discrete_device *>(param)->stream_generate(inputs, outputs, samples);
1261}
1262
1263void discrete_device::stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples)
1264{
1265   discrete_info *info = &m_info;
1266   int outputnum;
1267   //, task_group;
1268
1269   if (samples == 0)
1270      return;
1271   /* Setup any output streams */
1272   outputnum = 0;
1273   for_each(node_description *, node, &info->output_list)
1274   {
1275      node.item()->context = (void *) outputs[outputnum];
1276      outputnum++;
1277   }
1278
1279   /* Setup any input streams */
1280   for_each(node_description *, node, &info->input_list)
1281   {
1282      struct dss_input_context *context = (struct dss_input_context *) node.item()->context;
1283      context->ptr = (stream_sample_t *) inputs[context->stream_in_number];
1284   }
1285
1286   /* Setup tasks */
1287   for_each(discrete_task *, task, &info->task_list)
1288   {
1289      int               i;
1290
1291      task.item()->samples = samples;
1292      /* unlock the thread */
1293      task.item()->unlock();
1294
1295      /* set up task buffers */
1296      for (i = 0; i < task.item()->numbuffered; i++)
1297         task.item()->ptr[i] = task.item()->node_buf[i];
1298
1299      /* initialize sources */
1300      for_each(discrete_source_node *, sn, &task.item()->source_list)
1301      {
1302         sn.item()->ptr = sn.item()->task->node_buf[sn.item()->output_node];
1303      }
1304   }
1305
1306   for_each(discrete_task *, task, &info->task_list)
1307   {
1308      /* Fire a work item for each task */
1309      osd_work_item_queue(info->queue, task_callback, (void *) &info->task_list, WORK_ITEM_FLAG_AUTO_RELEASE);
1310   }
1311   osd_work_queue_wait(info->queue, osd_ticks_per_second()*10);
1312
1313   if (profiling)
1314   {
1315      info->total_samples += samples;
1316      info->total_stream_updates++;
1317   }
1318}
1319
1320//-------------------------------------------------
1321//  read - read from the chip's registers and internal RAM
1322//-------------------------------------------------
1323
1324READ8_MEMBER( discrete_device::read )
1325{
1326   discrete_info    *info = &m_info;
1327   node_description *node = discrete_find_node(info, offset);
1328
1329   UINT8 data = 0;
1330
1331   /* Read the node input value if allowed */
1332   if (node)
1333   {
1334      /* Bring the system up to now */
1335      stream_update(info->discrete_stream);
1336
1337      data = (UINT8) node->output[NODE_CHILD_NODE_NUM(offset)];
1338   }
1339   else
1340      fatalerror("discrete_sound_r read from non-existent NODE_%02d\n", offset-NODE_00);
1341
1342    return data;
1343}
1344
1345//-------------------------------------------------
1346//  write - write to the chip's registers and internal RAM
1347//-------------------------------------------------
1348
1349WRITE8_MEMBER( discrete_device::write )
1350{
1351   discrete_info    *info = &m_info;
1352   node_description *node = discrete_find_node(info, offset);
1353
1354   /* Update the node input value if it's a proper input node */
1355   if (node)
1356   {
1357      struct dss_input_context *context = (struct dss_input_context *)node->context;
1358      UINT8 new_data    = 0;
1359
1360      switch (node->module->type)
1361      {
1362         case DSS_INPUT_DATA:
1363         case DSS_INPUT_BUFFER:
1364            new_data = data;
1365            break;
1366         case DSS_INPUT_LOGIC:
1367         case DSS_INPUT_PULSE:
1368            new_data = data ? 1 : 0;
1369            break;
1370         case DSS_INPUT_NOT:
1371            new_data = data ? 0 : 1;
1372            break;
1373      }
1374
1375      if (context->data != new_data)
1376      {
1377         if (context->is_buffered)
1378         {
1379            /* Bring the system up to now */
1380            stream_update(context->buffer_stream);
1381
1382            context->data = new_data;
1383         }
1384         else
1385         {
1386            /* Bring the system up to now */
1387            stream_update(info->discrete_stream);
1388
1389            context->data = new_data;
1390
1391            /* Update the node output here so we don't have to do it each step */
1392            node->output[0] = new_data * context->gain + context->offset;
1393         }
1394      }
1395   }
1396   else
1397   {
1398      discrete_log(info, "discrete_sound_w write to non-existent NODE_%02d\n", offset-NODE_00);
1399   }
1400}
src/emu/sound/discrete.h
r9922r9923
33#ifndef __DISCRETE_H__
44#define __DISCRETE_H__
55
6#include "devlegcy.h"
6//#include "devlegcy.h"
77#include "machine/rescap.h"
88
99/***********************************************************************
r9922r9923
34693469#include "streams.h"
34703470#include "wavwrite.h"
34713471
3472
3473
34743472/*************************************
34753473 *
34763474 *  macros
r9922r9923
35163514#define DISCRETE_STOP_CALL(_func)            DISCRETE_STOP_NAME(_func) (node)
35173515
35183516#define DISCRETE_DECLARE_CONTEXT(_name)         struct _name##_context *context = (struct _name##_context *)node->context;
3519#define DISCRETE_DECLARE_INFO(_name)         const _name *info = (const  _name *)node->custom;
3517#define DISCRETE_DECLARE_INFO(_name)         const _name *info = (const  _name *)node->custom_data();
35203518
35213519#define DISCRETE_CUSTOM_MODULE(_basename, _context_type) \
35223520   { DST_CUSTOM, "CUSTOM", 1, sizeof(_context_type), DISCRETE_RESET_NAME(_basename), DISCRETE_STEP_NAME(_basename) }
r9922r9923
37583756
37593757/*************************************
37603758 *
3759 *  Classes and structs to handle
3760 *  linked lists.
3761 *
3762 *************************************/
3763
3764typedef struct _linked_list_entry   linked_list_entry;
3765struct _linked_list_entry
3766{
3767   linked_list_entry   *next;
3768   const void         *ptr;
3769};
3770
3771template<class T> class enumerator_t
3772{
3773public:
3774   enumerator_t(linked_list_entry *first) : m_cur(first) { }
3775   ~enumerator_t() {  }
3776
3777   inline T item(void) { return (T) m_cur->ptr; }
3778   inline void next(void) { m_cur = m_cur->next; }
3779   inline bool has_item(void) { return (m_cur != NULL); }
3780private:
3781   linked_list_entry *m_cur;
3782};
3783
3784#define for_each(_T, _e, _l) for (enumerator_t<_T> _e = (_l)->enumerator() ;  _e.has_item(); _e.next())
3785
3786template<class T> class linked_list_t
3787{
3788public:
3789   linked_list_t() { m_first = NULL; m_last = NULL; }
3790   ~linked_list_t() { reset(); }
3791
3792   void add_tail(T object)
3793   {
3794      linked_list_entry *n = global_alloc(linked_list_entry);
3795      n->ptr = (void *) object;
3796      n->next = NULL;
3797      if (m_last == NULL)
3798      {
3799         m_last = n;
3800         m_first = n;
3801      }
3802      else
3803      {
3804         m_last->next = n;
3805         m_last = n;
3806      }
3807   }
3808   void add_head(T object)
3809   {
3810      linked_list_entry *n = global_alloc(linked_list_entry);
3811      n->ptr = (void *) object;
3812      n->next = NULL;
3813      if (m_last == NULL)
3814      {
3815         m_last = n;
3816         m_first = n;
3817      }
3818      else
3819      {
3820         n->next = m_first;
3821         m_first = n;
3822      }
3823   }
3824   void reset(void)
3825   {
3826      linked_list_entry *e = m_first;
3827      while (e != NULL)
3828      {
3829         linked_list_entry *o = e;
3830         e = e->next;
3831         global_free(o);
3832      }
3833      m_first = NULL; m_last = NULL;
3834   }
3835   inline int count(void) const
3836   {
3837      int cnt = 0;
3838      linked_list_entry *e = m_first;
3839      while (e != NULL)
3840      {
3841         e = e->next;
3842         cnt++;
3843      }
3844      return cnt;
3845   }
3846   inline enumerator_t<T> enumerator(void) const {enumerator_t<T> r(m_first); return r; }
3847private:
3848   linked_list_entry *m_first;
3849   linked_list_entry *m_last;
3850};
3851
3852/*************************************
3853 *
37613854 *  The discrete sound blocks as
37623855 *  defined in the drivers
37633856 *
r9922r9923
37773870
37783871/*************************************
37793872 *
3780 *  Discrete module definition
3873 *  Internal structure of a node
37813874 *
37823875 *************************************/
37833876
3784typedef struct _node_description node_description;
3877typedef struct _discrete_module discrete_module;
37853878typedef struct _discrete_info discrete_info;
37863879
3787typedef struct _discrete_module discrete_module;
3788struct _discrete_module
3789{
3790   int            type;
3791   const char *   name;
3792   int            num_output;            /* Total number of output nodes, i.e. Master node + 1 */
3793   size_t         contextsize;
3794   DISCRETE_FUNC((*reset));               /* Called to reset a node after creation or system reset */
3795   DISCRETE_FUNC((*step));               /* Called to execute one time delta of output update */
3796   DISCRETE_FUNC((*start));            /* Called to execute at device start */
3797   DISCRETE_FUNC((*stop));               /* Called to execute at device stop */
3798};
37993880
3881class node_description;
3882typedef linked_list_t<node_description *> node_list_t;
38003883
3801/*************************************
3802 *
3803 *  Internal structure of a node
3804 *
3805 *************************************/
38063884
3807struct _node_description
3885class node_description
38083886{
3809   /* this declaration order seems to be optimal */
3810   double            output[DISCRETE_MAX_OUTPUTS];      /* The node's last output value */
3887public:
3888   node_description(const discrete_info * info, const discrete_module *module, const discrete_sound_block *block);
38113889
3812   DISCRETE_FUNC((*step));                           /* Called to execute one time delta of output update */
3813   void *            context;                     /* Contextual information specific to this node type */
3890   ~node_description(void);
38143891
3892   /* Return the node index, i.e. X from NODE(X) */
3893   int index(void);
3894   /* Return the node number, i.e. NODE(X) */
3895   inline int block_node(void) { return m_block->node;  }
3896   /* Return the node type */
3897   inline int block_type(void) { return m_block->type; }
3898   /* Custom function specific initialisation data */
3899   inline const void *custom_data(void) { return m_custom; }
3900
3901   void find_input_nodes(void);
3902   void save_state(device_t *device);
3903
3904   inline int input_node(int inputnum) { return m_block->input_node[inputnum]; }
3905
3906   /* FIXME: this is used by csv and wav logs - going forward, ids should be explicitly passed */
3907   int same_module_index(const node_list_t &list);
3908
3909   /* The node's last output value */
3910   double            output[DISCRETE_MAX_OUTPUTS];
3911
3912   /* Called to execute one time delta of output update */
3913   DISCRETE_FUNC((*step));
3914
3915   /* Contextual information specific to this node type */
3916   void *            context;
3917
38153918   const double *      input[DISCRETE_MAX_INPUTS];         /* Addresses of Input values */
3816   int               active_inputs;                  /* Number of active inputs on this node type */
3817   int               input_is_node;                  /* Bit Flags.  1 in bit location means input_is_node */
3919   /* Number of active inputs on this node type */
3920   inline int         active_inputs(void) { return m_active_inputs; }
3921   /* Bit Flags.  1 in bit location means input_is_node */
3922   inline int         input_is_node(void) { return m_input_is_node; };
38183923
3819   const void *      custom;                        /* Custom function specific initialisation data */
3820
38213924   const discrete_module *module;                     /* Node's module info */
38223925   const discrete_info *info;                        /* Points to the parent */
3823   const discrete_sound_block *block;                  /* Points to the node's setup block. */
38243926
38253927   osd_ticks_t         run_time;
3928protected:
3929private:
3930   const discrete_sound_block *m_block;                  /* Points to the node's setup block. */
3931   int               m_active_inputs;                  /* Number of active inputs on this node type */
3932   /* Custom function specific initialisation data */
3933   const void *      m_custom;
3934   int               m_input_is_node;
3935
38263936};
38273937
38283938
38293939/*************************************
38303940 *
3941 *  Discrete module definition
3942 *
3943 *************************************/
3944
3945struct _discrete_module
3946{
3947   int            type;
3948   const char *   name;
3949   int            num_output;            /* Total number of output nodes, i.e. Master node + 1 */
3950   size_t         contextsize;
3951   DISCRETE_FUNC((*reset));               /* Called to reset a node after creation or system reset */
3952   DISCRETE_FUNC((*step));               /* Called to execute one time delta of output update */
3953   DISCRETE_FUNC((*start));            /* Called to execute at device start */
3954   DISCRETE_FUNC((*stop));               /* Called to execute at device stop */
3955};
3956
3957/*************************************
3958 *
38313959 *  Core runtime info
38323960 *
38333961 *  this structure is exposed mainly
r9922r9923
38363964 *
38373965 *************************************/
38383966
3839typedef struct _linked_list_entry   linked_list_entry;
3840struct _linked_list_entry
3841{
3842   linked_list_entry   *next;
3843   const void         *ptr;
3844};
38453967
3846typedef struct _discrete_task discrete_task;
3847struct _discrete_task
3968typedef struct _discrete_source_node discrete_source_node;
3969
3970typedef linked_list_t<discrete_source_node *> source_node_list_t;
3971
3972class discrete_task
38483973{
3849   const linked_list_entry *list;
3974public:
3975   discrete_task(void)
3976   : numbuffered(0), task_group(0), m_threadid(-1)
3977   {
3978      source_list.reset();
3979      list.reset();
3980   }
38503981
3851   volatile INT32         threadid;
3982   ~discrete_task(void) { }
3983
3984   //const linked_list_entry *list;
3985   node_list_t          list;
3986
38523987   volatile int         samples;
38533988
38543989   /* list of source nodes */
3855   linked_list_entry      *source_list;      /* discrete_source_node */
3990   source_node_list_t      source_list;      /* discrete_source_node */
38563991
3992   int                numbuffered;
38573993   int                  task_group;
3858   int                numbuffered;
38593994   double               *ptr[DISCRETE_MAX_TASK_OUTPUTS];
38603995   const double         *source[DISCRETE_MAX_TASK_OUTPUTS];
38613996
38623997   double               *node_buf[DISCRETE_MAX_TASK_OUTPUTS];
3863   const node_description   *nodes[DISCRETE_MAX_TASK_OUTPUTS];
3998   node_description      *nodes[DISCRETE_MAX_TASK_OUTPUTS];
3999
4000   inline bool lock_threadid(INT32 threadid)
4001   {
4002      INT32 prev_id;
4003      prev_id = compare_exchange32(&m_threadid, -1, threadid);
4004      return (prev_id == -1 && m_threadid == threadid);
4005   }
4006   inline void unlock(void) { m_threadid = -1; }
4007private:
4008   volatile INT32         m_threadid;
38644009};
38654010
3866typedef struct _discrete_source_node discrete_source_node;
4011typedef linked_list_t<discrete_task *> task_list_t;
4012
38674013struct _discrete_source_node
38684014{
38694015   const discrete_task   *task;
r9922r9923
38854031   node_description **indexed_node;
38864032
38874033   /* list of all nodes */
3888   linked_list_entry    *node_list;      /* node_description * */
4034   node_list_t         node_list;      /* node_description * */
38894035
38904036   /* list of discrete blocks after prescan (IMPORT, DELETE, REPLACE) */
38914037   linked_list_entry    *block_list;      /* discrete_sound_block * */
38924038
38934039   /* tasks */
3894   linked_list_entry    *task_list;      /* discrete_task_context * */
4040   task_list_t         task_list;      /* discrete_task_context * */
38954041
38964042   /* the input streams */
3897   linked_list_entry    *input_list;
4043   node_list_t         input_list;
38984044
38994045   /* output node tracking */
3900   linked_list_entry    *output_list;
4046   node_list_t         output_list;
39014047
39024048   /* the output stream */
39034049   sound_stream      *discrete_stream;
r9922r9923
42544400#error "DISCRETE_MAX_OUTPUTS != 8"
42554401#endif
42564402
4257#define NODE_BLOCKINDEX(_node)   NODE_INDEX((_node)->block->node)
4403//#define NODE_BLOCKINDEX(_node)   NODE_INDEX((_node)->block->node)
42584404
42594405#define NODE_RELATIVE(_x, _y) (NODE(NODE_INDEX(_x) + (_y)))
42604406
r9922r9923
44244570
44254571#define DISCRETE_SOUND_EXTERN(name) extern const discrete_sound_block name##_discrete_interface[]
44264572#define DISCRETE_SOUND_START(name) const discrete_sound_block name##_discrete_interface[] = {
4427#define DISCRETE_SOUND_END                                              { NODE_00, DSS_NULL     , 0, { NODE_NC }, { 0 } ,NULL  ,"DISCRETE_SOUND_END" }  };
44284573
4574#define DSC_SND_ENTRY(_nod, _dss, _num, _iact, _iinit, _custom, _name) { _nod, _dss, _num, _iact, _iinit, _custom, _name }
4575
4576
4577#define DISCRETE_SOUND_END                                              DSC_SND_ENTRY( NODE_00, DSS_NULL     , 0, DSE( NODE_NC ), DSE( 0 ) ,NULL  ,"DISCRETE_SOUND_END" )  };
4578#define DSE( ... ) { __VA_ARGS__ }
4579
44294580/*      Module Name                                                       out,  enum value,      #in,   {variable inputs},              {static inputs},    data pointer,   "name" */
44304581
44314582/* from disc_inp.c */
4432#define DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,TAG)                   { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,0   ,0   ,100  }, TAG   , "DISCRETE_ADJUSTMENT" },
4433#define DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,TAG,PMIN,PMAX)         { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,0   ,PMIN,PMAX }, TAG   , "DISCRETE_ADJUSTMENTX"  },
4434#define DISCRETE_CONSTANT(NODE,CONST)                                   { NODE, DSS_CONSTANT    , 1, { NODE_NC }, { CONST } ,NULL  ,"DISCRETE_CONSTANT" },
4435#define DISCRETE_INPUT_DATA(NODE)                                       { NODE, DSS_INPUT_DATA  , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,0 }, NULL, "DISCRETE_INPUT_DATA" },
4436#define DISCRETE_INPUTX_DATA(NODE,GAIN,OFFSET,INIT)                     { NODE, DSS_INPUT_DATA  , 3, { NODE_NC,NODE_NC,NODE_NC }, { GAIN,OFFSET,INIT }, NULL, "DISCRETE_INPUTX_DATA" },
4437#define DISCRETE_INPUT_LOGIC(NODE)                                      { NODE, DSS_INPUT_LOGIC , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,0 }, NULL, "DISCRETE_INPUT_LOGIC" },
4438#define DISCRETE_INPUTX_LOGIC(NODE,GAIN,OFFSET,INIT)                    { NODE, DSS_INPUT_LOGIC , 3, { NODE_NC,NODE_NC,NODE_NC }, { GAIN,OFFSET,INIT }, NULL, "DISCRETE_INPUTX_LOGIC" },
4439#define DISCRETE_INPUT_NOT(NODE)                                        { NODE, DSS_INPUT_NOT   , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,0 }, NULL, "DISCRETE_INPUT_NOT" },
4440#define DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT)                      { NODE, DSS_INPUT_NOT   , 3, { NODE_NC,NODE_NC,NODE_NC }, { GAIN,OFFSET,INIT }, NULL, "DISCRETE_INPUTX_NOT" },
4441#define DISCRETE_INPUT_PULSE(NODE,INIT)                                 { NODE, DSS_INPUT_PULSE , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,INIT }, NULL, "DISCRETE_INPUT_PULSE" },
4583#define DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,TAG)                   DSC_SND_ENTRY( NODE, DSS_ADJUSTMENT  , 7, DSE( NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( MIN,MAX,LOGLIN,0   ,0   ,100  ), TAG   , "DISCRETE_ADJUSTMENT" ),
4584#define DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,TAG,PMIN,PMAX)         DSC_SND_ENTRY( NODE, DSS_ADJUSTMENT  , 7, DSE( NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( MIN,MAX,LOGLIN,0   ,PMIN,PMAX ), TAG   , "DISCRETE_ADJUSTMENTX"  ),
4585#define DISCRETE_CONSTANT(NODE,CONST)                                   DSC_SND_ENTRY( NODE, DSS_CONSTANT    , 1, DSE( NODE_NC ), DSE( CONST ) ,NULL  ,"DISCRETE_CONSTANT" ),
4586#define DISCRETE_INPUT_DATA(NODE)                                       DSC_SND_ENTRY( NODE, DSS_INPUT_DATA  , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( 1,0,0 ), NULL, "DISCRETE_INPUT_DATA" ),
4587#define DISCRETE_INPUTX_DATA(NODE,GAIN,OFFSET,INIT)                     DSC_SND_ENTRY( NODE, DSS_INPUT_DATA  , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( GAIN,OFFSET,INIT ), NULL, "DISCRETE_INPUTX_DATA" ),
4588#define DISCRETE_INPUT_LOGIC(NODE)                                      DSC_SND_ENTRY( NODE, DSS_INPUT_LOGIC , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( 1,0,0 ), NULL, "DISCRETE_INPUT_LOGIC" ),
4589#define DISCRETE_INPUTX_LOGIC(NODE,GAIN,OFFSET,INIT)                    DSC_SND_ENTRY( NODE, DSS_INPUT_LOGIC , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( GAIN,OFFSET,INIT ), NULL, "DISCRETE_INPUTX_LOGIC" ),
4590#define DISCRETE_INPUT_NOT(NODE)                                        DSC_SND_ENTRY( NODE, DSS_INPUT_NOT   , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( 1,0,0 ), NULL, "DISCRETE_INPUT_NOT" ),
4591#define DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT)                      DSC_SND_ENTRY( NODE, DSS_INPUT_NOT   , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( GAIN,OFFSET,INIT ), NULL, "DISCRETE_INPUTX_NOT" ),
4592#define DISCRETE_INPUT_PULSE(NODE,INIT)                                 DSC_SND_ENTRY( NODE, DSS_INPUT_PULSE , 3, DSE( NODE_NC,NODE_NC,NODE_NC ), DSE( 1,0,INIT ), NULL, "DISCRETE_INPUT_PULSE" ),
44424593
4443#define DISCRETE_INPUT_STREAM(NODE, NUM)                                { NODE, DSS_INPUT_STREAM, 3, { NUM,NODE_NC,NODE_NC }, { NUM,1,0 }, NULL, "DISCRETE_INPUT_STREAM" },
4444#define DISCRETE_INPUTX_STREAM(NODE, NUM, GAIN,OFFSET)                  { NODE, DSS_INPUT_STREAM, 3, { NUM,NODE_NC,NODE_NC }, { NUM,GAIN,OFFSET }, NULL, "DISCRETE_INPUTX_STREAM" },
4594#define DISCRETE_INPUT_STREAM(NODE, NUM)                                DSC_SND_ENTRY( NODE, DSS_INPUT_STREAM, 3, DSE( NUM,NODE_NC,NODE_NC ), DSE( NUM,1,0 ), NULL, "DISCRETE_INPUT_STREAM" ),
4595#define DISCRETE_INPUTX_STREAM(NODE, NUM, GAIN,OFFSET)                  DSC_SND_ENTRY( NODE, DSS_INPUT_STREAM, 3, DSE( NUM,NODE_NC,NODE_NC ), DSE( NUM,GAIN,OFFSET ), NULL, "DISCRETE_INPUTX_STREAM" ),
44454596
4446#define DISCRETE_INPUT_BUFFER(NODE, NUM)                               { NODE, DSS_INPUT_BUFFER, 3, { NUM,NODE_NC,NODE_NC }, { NUM,1,0 }, NULL, "DISCRETE_INPUT_BUFFER" },
4597#define DISCRETE_INPUT_BUFFER(NODE, NUM)                               DSC_SND_ENTRY( NODE, DSS_INPUT_BUFFER, 3, DSE( NUM,NODE_NC,NODE_NC ), DSE( NUM,1,0 ), NULL, "DISCRETE_INPUT_BUFFER" ),
44474598
44484599/* from disc_wav.c */
44494600/* generic modules */
4450#define DISCRETE_COUNTER(NODE,ENAB,RESET,CLK,MIN,MAX,DIR,INIT0,CLKTYPE) { NODE, DSS_COUNTER     , 8, { ENAB,RESET,CLK,NODE_NC,NODE_NC,DIR,INIT0,NODE_NC }, { ENAB,RESET,CLK,MIN,MAX,DIR,INIT0,CLKTYPE }, NULL, "DISCRETE_COUNTER" },
4451#define DISCRETE_COUNTER_7492(NODE,ENAB,RESET,CLK,CLKTYPE)              { NODE, DSS_COUNTER     , 8, { ENAB,RESET,CLK,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,RESET,CLK,CLKTYPE,0,1,0,DISC_COUNTER_IS_7492 }, NULL, "DISCRETE_COUNTER_7492" },
4452#define DISCRETE_LFSR_NOISE(NODE,ENAB,RESET,CLK,AMPL,FEED,BIAS,LFSRTB)  { NODE, DSS_LFSR_NOISE  , 6, { ENAB,RESET,CLK,AMPL,FEED,BIAS }, { ENAB,RESET,CLK,AMPL,FEED,BIAS }, LFSRTB, "DISCRETE_LFSR_NOISE" },
4453#define DISCRETE_NOISE(NODE,ENAB,FREQ,AMPL,BIAS)                        { NODE, DSS_NOISE       , 4, { ENAB,FREQ,AMPL,BIAS }, { ENAB,FREQ,AMPL,BIAS }, NULL, "DISCRETE_NOISE" },
4454#define DISCRETE_NOTE(NODE,ENAB,CLK,DATA,MAX1,MAX2,CLKTYPE)             { NODE, DSS_NOTE        , 6, { ENAB,CLK,DATA,NODE_NC,NODE_NC,NODE_NC }, { ENAB,CLK,DATA,MAX1,MAX2,CLKTYPE }, NULL, "DISCRETE_NOTE" },
4455#define DISCRETE_SAWTOOTHWAVE(NODE,ENAB,FREQ,AMPL,BIAS,GRAD,PHASE)      { NODE, DSS_SAWTOOTHWAVE, 6, { ENAB,FREQ,AMPL,BIAS,NODE_NC,NODE_NC }, { ENAB,FREQ,AMPL,BIAS,GRAD,PHASE }, NULL, "DISCRETE_SAWTOOTHWAVE" },
4456#define DISCRETE_SINEWAVE(NODE,ENAB,FREQ,AMPL,BIAS,PHASE)               { NODE, DSS_SINEWAVE    , 5, { ENAB,FREQ,AMPL,BIAS,NODE_NC }, { ENAB,FREQ,AMPL,BIAS,PHASE }, NULL, "DISCRETE_SINEWAVE" },
4457#define DISCRETE_SQUAREWAVE(NODE,ENAB,FREQ,AMPL,DUTY,BIAS,PHASE)        { NODE, DSS_SQUAREWAVE  , 6, { ENAB,FREQ,AMPL,DUTY,BIAS,NODE_NC }, { ENAB,FREQ,AMPL,DUTY,BIAS,PHASE }, NULL, "DISCRETE_SQUAREWAVE" },
4458#define DISCRETE_SQUAREWFIX(NODE,ENAB,FREQ,AMPL,DUTY,BIAS,PHASE)        { NODE, DSS_SQUAREWFIX  , 6, { ENAB,FREQ,AMPL,DUTY,BIAS,NODE_NC }, { ENAB,FREQ,AMPL,DUTY,BIAS,PHASE }, NULL, "DISCRETE_SQUAREWFIX" },
4459#define DISCRETE_SQUAREWAVE2(NODE,ENAB,AMPL,T_OFF,T_ON,BIAS,TSHIFT)     { NODE, DSS_SQUAREWAVE2 , 6, { ENAB,AMPL,T_OFF,T_ON,BIAS,NODE_NC }, { ENAB,AMPL,T_OFF,T_ON,BIAS,TSHIFT }, NULL, "DISCRETE_SQUAREWAVE2" },
4460#define DISCRETE_TRIANGLEWAVE(NODE,ENAB,FREQ,AMPL,BIAS,PHASE)           { NODE, DSS_TRIANGLEWAVE, 5, { ENAB,FREQ,AMPL,BIAS,NODE_NC }, { ENAB,FREQ,AMPL,BIAS,PHASE }, NULL, "DISCRETE_TRIANGLEWAVE" },
4601#define DISCRETE_COUNTER(NODE,ENAB,RESET,CLK,MIN,MAX,DIR,INIT0,CLKTYPE) DSC_SND_ENTRY( NODE, DSS_COUNTER     , 8, DSE( ENAB,RESET,CLK,NODE_NC,NODE_NC,DIR,INIT0,NODE_NC ), DSE( ENAB,RESET,CLK,MIN,MAX,DIR,INIT0,CLKTYPE ), NULL, "DISCRETE_COUNTER" ),
4602#define DISCRETE_COUNTER_7492(NODE,ENAB,RESET,CLK,CLKTYPE)              DSC_SND_ENTRY( NODE, DSS_COUNTER     , 8, DSE( ENAB,RESET,CLK,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,RESET,CLK,CLKTYPE,0,1,0,DISC_COUNTER_IS_7492 ), NULL, "DISCRETE_COUNTER_7492" ),
4603#define DISCRETE_LFSR_NOISE(NODE,ENAB,RESET,CLK,AMPL,FEED,BIAS,LFSRTB)  DSC_SND_ENTRY( NODE, DSS_LFSR_NOISE  , 6, DSE( ENAB,RESET,CLK,AMPL,FEED,BIAS ), DSE( ENAB,RESET,CLK,AMPL,FEED,BIAS ), LFSRTB, "DISCRETE_LFSR_NOISE" ),
4604#define DISCRETE_NOISE(NODE,ENAB,FREQ,AMPL,BIAS)                        DSC_SND_ENTRY( NODE, DSS_NOISE       , 4, DSE( ENAB,FREQ,AMPL,BIAS ), DSE( ENAB,FREQ,AMPL,BIAS ), NULL, "DISCRETE_NOISE" ),
4605#define DISCRETE_NOTE(NODE,ENAB,CLK,DATA,MAX1,MAX2,CLKTYPE)             DSC_SND_ENTRY( NODE, DSS_NOTE        , 6, DSE( ENAB,CLK,DATA,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,CLK,DATA,MAX1,MAX2,CLKTYPE ), NULL, "DISCRETE_NOTE" ),
4606#define DISCRETE_SAWTOOTHWAVE(NODE,ENAB,FREQ,AMPL,BIAS,GRAD,PHASE)      DSC_SND_ENTRY( NODE, DSS_SAWTOOTHWAVE, 6, DSE( ENAB,FREQ,AMPL,BIAS,NODE_NC,NODE_NC ), DSE( ENAB,FREQ,AMPL,BIAS,GRAD,PHASE ), NULL, "DISCRETE_SAWTOOTHWAVE" ),
4607#define DISCRETE_SINEWAVE(NODE,ENAB,FREQ,AMPL,BIAS,PHASE)               DSC_SND_ENTRY( NODE, DSS_SINEWAVE    , 5, DSE( ENAB,FREQ,AMPL,BIAS,NODE_NC ), DSE( ENAB,FREQ,AMPL,BIAS,PHASE ), NULL, "DISCRETE_SINEWAVE" ),
4608#define DISCRETE_SQUAREWAVE(NODE,ENAB,FREQ,AMPL,DUTY,BIAS,PHASE)        DSC_SND_ENTRY( NODE, DSS_SQUAREWAVE  , 6, DSE( ENAB,FREQ,AMPL,DUTY,BIAS,NODE_NC ), DSE( ENAB,FREQ,AMPL,DUTY,BIAS,PHASE ), NULL, "DISCRETE_SQUAREWAVE" ),
4609#define DISCRETE_SQUAREWFIX(NODE,ENAB,FREQ,AMPL,DUTY,BIAS,PHASE)        DSC_SND_ENTRY( NODE, DSS_SQUAREWFIX  , 6, DSE( ENAB,FREQ,AMPL,DUTY,BIAS,NODE_NC ), DSE( ENAB,FREQ,AMPL,DUTY,BIAS,PHASE ), NULL, "DISCRETE_SQUAREWFIX" ),
4610#define DISCRETE_SQUAREWAVE2(NODE,ENAB,AMPL,T_OFF,T_ON,BIAS,TSHIFT)     DSC_SND_ENTRY( NODE, DSS_SQUAREWAVE2 , 6, DSE( ENAB,AMPL,T_OFF,T_ON,BIAS,NODE_NC ), DSE( ENAB,AMPL,T_OFF,T_ON,BIAS,TSHIFT ), NULL, "DISCRETE_SQUAREWAVE2" ),
4611#define DISCRETE_TRIANGLEWAVE(NODE,ENAB,FREQ,AMPL,BIAS,PHASE)           DSC_SND_ENTRY( NODE, DSS_TRIANGLEWAVE, 5, DSE( ENAB,FREQ,AMPL,BIAS,NODE_NC ), DSE( ENAB,FREQ,AMPL,BIAS,PHASE ), NULL, "DISCRETE_TRIANGLEWAVE" ),
44614612/* Component specific */
4462#define DISCRETE_INVERTER_OSC(NODE,ENAB,MOD,RCHARGE,RP,C,R2,INFO)       { NODE, DSS_INVERTER_OSC, 6, { ENAB,MOD,NODE_NC,NODE_NC,NODE_NC }, { ENAB,MOD,RCHARGE,RP,C,R2 }, INFO, "DISCRETE_INVERTER_OSC" },
4463#define DISCRETE_OP_AMP_OSCILLATOR(NODE,ENAB,INFO)                      { NODE, DSS_OP_AMP_OSC  , 1, { ENAB }, { ENAB }, INFO, "DISCRETE_OP_AMP_OSCILLATOR" },
4464#define DISCRETE_OP_AMP_VCO1(NODE,ENAB,VMOD1,INFO)                      { NODE, DSS_OP_AMP_OSC  , 2, { ENAB,VMOD1 }, { ENAB,VMOD1 }, INFO, "DISCRETE_OP_AMP_VCO1" },
4465#define DISCRETE_OP_AMP_VCO2(NODE,ENAB,VMOD1,VMOD2,INFO)                { NODE, DSS_OP_AMP_OSC  , 3, { ENAB,VMOD1,VMOD2 }, { ENAB,VMOD1,VMOD2 }, INFO, "DISCRETE_OP_AMP_VCO2" },
4466#define DISCRETE_SCHMITT_OSCILLATOR(NODE,ENAB,INP0,AMPL,TABLE)          { NODE, DSS_SCHMITT_OSC , 3, { ENAB,INP0,AMPL }, { ENAB,INP0,AMPL }, TABLE, "DISCRETE_SCHMITT_OSCILLATOR" },
4613#define DISCRETE_INVERTER_OSC(NODE,ENAB,MOD,RCHARGE,RP,C,R2,INFO)       DSC_SND_ENTRY( NODE, DSS_INVERTER_OSC, 6, DSE( ENAB,MOD,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,MOD,RCHARGE,RP,C,R2 ), INFO, "DISCRETE_INVERTER_OSC" ),
4614#define DISCRETE_OP_AMP_OSCILLATOR(NODE,ENAB,INFO)                      DSC_SND_ENTRY( NODE, DSS_OP_AMP_OSC  , 1, DSE( ENAB ), DSE( ENAB ), INFO, "DISCRETE_OP_AMP_OSCILLATOR" ),
4615#define DISCRETE_OP_AMP_VCO1(NODE,ENAB,VMOD1,INFO)                      DSC_SND_ENTRY( NODE, DSS_OP_AMP_OSC  , 2, DSE( ENAB,VMOD1 ), DSE( ENAB,VMOD1 ), INFO, "DISCRETE_OP_AMP_VCO1" ),
4616#define DISCRETE_OP_AMP_VCO2(NODE,ENAB,VMOD1,VMOD2,INFO)                DSC_SND_ENTRY( NODE, DSS_OP_AMP_OSC  , 3, DSE( ENAB,VMOD1,VMOD2 ), DSE( ENAB,VMOD1,VMOD2 ), INFO, "DISCRETE_OP_AMP_VCO2" ),
4617#define DISCRETE_SCHMITT_OSCILLATOR(NODE,ENAB,INP0,AMPL,TABLE)          DSC_SND_ENTRY( NODE, DSS_SCHMITT_OSC , 3, DSE( ENAB,INP0,AMPL ), DSE( ENAB,INP0,AMPL ), TABLE, "DISCRETE_SCHMITT_OSCILLATOR" ),
44674618/* Not yet implemented */
4468#define DISCRETE_ADSR_ENV(NODE,ENAB,TRIGGER,GAIN,ADSRTB)                { NODE, DSS_ADSR        , 3, { ENAB,TRIGGER,GAIN }, { ENAB,TRIGGER,GAIN }, ADSRTB, "DISCRETE_ADSR_ENV" },
4619#define DISCRETE_ADSR_ENV(NODE,ENAB,TRIGGER,GAIN,ADSRTB)                DSC_SND_ENTRY( NODE, DSS_ADSR        , 3, DSE( ENAB,TRIGGER,GAIN ), DSE( ENAB,TRIGGER,GAIN ), ADSRTB, "DISCRETE_ADSR_ENV" ),
44694620
44704621/* from disc_mth.c */
44714622/* generic modules */
4472#define DISCRETE_ADDER2(NODE,ENAB,INP0,INP1)                            { NODE, DST_ADDER       , 3, { ENAB,INP0,INP1 }, { ENAB,INP0,INP1 }, NULL, "DISCRETE_ADDER2" },
4473#define DISCRETE_ADDER3(NODE,ENAB,INP0,INP1,INP2)                       { NODE, DST_ADDER       , 4, { ENAB,INP0,INP1,INP2 }, { ENAB,INP0,INP1,INP2 }, NULL, "DISCRETE_ADDER3" },
4474#define DISCRETE_ADDER4(NODE,ENAB,INP0,INP1,INP2,INP3)                  { NODE, DST_ADDER       , 5, { ENAB,INP0,INP1,INP2,INP3 }, { ENAB,INP0,INP1,INP2,INP3 }, NULL, "DISCRETE_ADDER4" },
4475#define DISCRETE_CLAMP(NODE,INP0,MIN,MAX)                               { NODE, DST_CLAMP       , 3, { INP0,MIN,MAX }, { INP0,MIN,MAX }, NULL, "DISCRETE_CLAMP" },
4476#define DISCRETE_DIVIDE(NODE,ENAB,INP0,INP1)                            { NODE, DST_DIVIDE      , 3, { ENAB,INP0,INP1 }, { ENAB,INP0,INP1 }, NULL, "DISCRETE_DIVIDE" },
4477#define DISCRETE_GAIN(NODE,INP0,GAIN)                                   { NODE, DST_GAIN        , 3, { INP0,NODE_NC,NODE_NC }, { INP0,GAIN,0 }, NULL, "DISCRETE_GAIN" },
4478#define DISCRETE_INVERT(NODE,INP0)                                      { NODE, DST_GAIN        , 3, { INP0,NODE_NC,NODE_NC }, { INP0,-1,0 }, NULL, "DISCRETE_INVERT" },
4479#define DISCRETE_LOGIC_INVERT(NODE,INP0)                                { NODE, DST_LOGIC_INV   , 1, { INP0 }, { INP0 }, NULL, "DISCRETE_LOGIC_INVERT" },
4623#define DISCRETE_ADDER2(NODE,ENAB,INP0,INP1)                            DSC_SND_ENTRY( NODE, DST_ADDER       , 3, DSE( ENAB,INP0,INP1 ), DSE( ENAB,INP0,INP1 ), NULL, "DISCRETE_ADDER2" ),
4624#define DISCRETE_ADDER3(NODE,ENAB,INP0,INP1,INP2)                       DSC_SND_ENTRY( NODE, DST_ADDER       , 4, DSE( ENAB,INP0,INP1,INP2 ), DSE( ENAB,INP0,INP1,INP2 ), NULL, "DISCRETE_ADDER3" ),
4625#define DISCRETE_ADDER4(NODE,ENAB,INP0,INP1,INP2,INP3)                  DSC_SND_ENTRY( NODE, DST_ADDER       , 5, DSE( ENAB,INP0,INP1,INP2,INP3 ), DSE( ENAB,INP0,INP1,INP2,INP3 ), NULL, "DISCRETE_ADDER4" ),
4626#define DISCRETE_CLAMP(NODE,INP0,MIN,MAX)                               DSC_SND_ENTRY( NODE, DST_CLAMP       , 3, DSE( INP0,MIN,MAX ), DSE( INP0,MIN,MAX ), NULL, "DISCRETE_CLAMP" ),
4627#define DISCRETE_DIVIDE(NODE,ENAB,INP0,INP1)                            DSC_SND_ENTRY( NODE, DST_DIVIDE      , 3, DSE( ENAB,INP0,INP1 ), DSE( ENAB,INP0,INP1 ), NULL, "DISCRETE_DIVIDE" ),
4628#define DISCRETE_GAIN(NODE,INP0,GAIN)                                   DSC_SND_ENTRY( NODE, DST_GAIN        , 3, DSE( INP0,NODE_NC,NODE_NC ), DSE( INP0,GAIN,0 ), NULL, "DISCRETE_GAIN" ),
4629#define DISCRETE_INVERT(NODE,INP0)                                      DSC_SND_ENTRY( NODE, DST_GAIN        , 3, DSE( INP0,NODE_NC,NODE_NC ), DSE( INP0,-1,0 ), NULL, "DISCRETE_INVERT" ),
4630#define DISCRETE_LOGIC_INVERT(NODE,INP0)                                DSC_SND_ENTRY( NODE, DST_LOGIC_INV   , 1, DSE( INP0 ), DSE( INP0 ), NULL, "DISCRETE_LOGIC_INVERT" ),
44804631
4481#define DISCRETE_BIT_DECODE(NODE, INP, BIT_N, VOUT)                     { NODE, DST_BITS_DECODE , 4, { INP,NODE_NC,NODE_NC,NODE_NC }, { INP,BIT_N,BIT_N,VOUT }, NULL, "DISCRETE_BIT_DECODE" },
4482#define DISCRETE_BITS_DECODE(NODE, INP, BIT_FROM, BIT_TO, VOUT)         { NODE, DST_BITS_DECODE , 4, { INP,NODE_NC,NODE_NC,NODE_NC }, { INP,BIT_FROM,BIT_TO,VOUT }, NULL, "DISCRETE_BITS_DECODE" },
4632#define DISCRETE_BIT_DECODE(NODE, INP, BIT_N, VOUT)                     DSC_SND_ENTRY( NODE, DST_BITS_DECODE , 4, DSE( INP,NODE_NC,NODE_NC,NODE_NC ), DSE( INP,BIT_N,BIT_N,VOUT ), NULL, "DISCRETE_BIT_DECODE" ),
4633#define DISCRETE_BITS_DECODE(NODE, INP, BIT_FROM, BIT_TO, VOUT)         DSC_SND_ENTRY( NODE, DST_BITS_DECODE , 4, DSE( INP,NODE_NC,NODE_NC,NODE_NC ), DSE( INP,BIT_FROM,BIT_TO,VOUT ), NULL, "DISCRETE_BITS_DECODE" ),
44834634
4484#define DISCRETE_LOGIC_AND(NODE,INP0,INP1)                              { NODE, DST_LOGIC_AND   , 4, { INP0,INP1,NODE_NC,NODE_NC }, { INP0,INP1,1.0,1.0 }, NULL, "DISCRETE_LOGIC_AND" },
4485#define DISCRETE_LOGIC_AND3(NODE,INP0,INP1,INP2)                        { NODE, DST_LOGIC_AND   , 4, { INP0,INP1,INP2,NODE_NC }, { INP0,INP1,INP2,1.0 }, NULL, "DISCRETE_LOGIC_AND3" },
4486#define DISCRETE_LOGIC_AND4(NODE,INP0,INP1,INP2,INP3)                   { NODE, DST_LOGIC_AND   , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 } ,NULL, "DISCRETE_LOGIC_AND4" },
4487#define DISCRETE_LOGIC_NAND(NODE,INP0,INP1)                             { NODE, DST_LOGIC_NAND  , 4, { INP0,INP1,NODE_NC,NODE_NC }, { INP0,INP1,1.0,1.0 }, NULL, "DISCRETE_LOGIC_NAND" },
4488#define DISCRETE_LOGIC_NAND3(NODE,INP0,INP1,INP2)                       { NODE, DST_LOGIC_NAND  , 4, { INP0,INP1,INP2,NODE_NC }, { INP0,INP1,INP2,1.0 }, NULL, "DISCRETE_LOGIC_NAND3" },
4489#define DISCRETE_LOGIC_NAND4(NODE,INP0,INP1,INP2,INP3)                  { NODE, DST_LOGIC_NAND  , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 }, NULL, ")DISCRETE_LOGIC_NAND4" },
4490#define DISCRETE_LOGIC_OR(NODE,INP0,INP1)                               { NODE, DST_LOGIC_OR    , 4, { INP0,INP1,NODE_NC,NODE_NC }, { INP0,INP1,0.0,0.0 }, NULL, "DISCRETE_LOGIC_OR" },
4491#define DISCRETE_LOGIC_OR3(NODE,INP0,INP1,INP2)                         { NODE, DST_LOGIC_OR    , 4, { INP0,INP1,INP2,NODE_NC }, { INP0,INP1,INP2,0.0 }, NULL, "DISCRETE_LOGIC_OR3" },
4492#define DISCRETE_LOGIC_OR4(NODE,INP0,INP1,INP2,INP3)                    { NODE, DST_LOGIC_OR    , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 }, NULL, "DISCRETE_LOGIC_OR4" },
4493#define DISCRETE_LOGIC_NOR(NODE,INP0,INP1)                              { NODE, DST_LOGIC_NOR   , 4, { INP0,INP1,NODE_NC,NODE_NC }, { INP0,INP1,0.0,0.0 }, NULL, "DISCRETE_LOGIC_NOR" },
4494#define DISCRETE_LOGIC_NOR3(NODE,INP0,INP1,INP2)                        { NODE, DST_LOGIC_NOR   , 4, { INP0,INP1,INP2,NODE_NC }, { INP0,INP1,INP2,0.0 }, NULL, "DISCRETE_LOGIC_NOR3" },
4495#define DISCRETE_LOGIC_NOR4(NODE,INP0,INP1,INP2,INP3)                   { NODE, DST_LOGIC_NOR   , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 }, NULL, "DISCRETE_LOGIC_NOR4" },
4496#define DISCRETE_LOGIC_XOR(NODE,INP0,INP1)                              { NODE, DST_LOGIC_XOR   , 2, { INP0,INP1 }, { INP0,INP1 }, NULL, "DISCRETE_LOGIC_XOR" },
4497#define DISCRETE_LOGIC_XNOR(NODE,INP0,INP1)                             { NODE, DST_LOGIC_NXOR  , 2, { INP0,INP1 }, { INP0,INP1 }, NULL, "DISCRETE_LOGIC_XNOR" },
4498#define DISCRETE_LOGIC_DFLIPFLOP(NODE,RESET,SET,CLK,INP)                { NODE, DST_LOGIC_DFF   , 4, { RESET,SET,CLK,INP }, { RESET,SET,CLK,INP }, NULL, "DISCRETE_LOGIC_DFLIPFLOP" },
4499#define DISCRETE_LOGIC_JKFLIPFLOP(NODE,RESET,SET,CLK,J,K)               { NODE, DST_LOGIC_JKFF  , 5, { RESET,SET,CLK,J,K }, { RESET,SET,CLK,J,K }, NULL, "DISCRETE_LOGIC_JKFLIPFLOP" },
4500#define DISCRETE_LOGIC_SHIFT(NODE,INP0,RESET,CLK,SIZE,OPTIONS)          { NODE, DST_LOGIC_SHIFT , 5, { INP0,RESET,CLK,NODE_NC,NODE_NC }, { INP0,RESET,CLK,SIZE,OPTIONS }, NULL, "DISCRETE_LOGIC_SHIFT" },
4501#define DISCRETE_LOOKUP_TABLE(NODE,ADDR,SIZE,TABLE)                     { NODE, DST_LOOKUP_TABLE, 2, { ADDR,NODE_NC }, { ADDR,SIZE }, TABLE, "DISCRETE_LOOKUP_TABLE" },
4502#define DISCRETE_MULTIPLEX2(NODE,ADDR,INP0,INP1)                        { NODE, DST_MULTIPLEX   , 3, { ADDR,INP0,INP1 }, { ADDR,INP0,INP1 }, NULL, "DISCRETE_MULTIPLEX2" },
4503#define DISCRETE_MULTIPLEX4(NODE,ADDR,INP0,INP1,INP2,INP3)              { NODE, DST_MULTIPLEX   , 5, { ADDR,INP0,INP1,INP2,INP3 }, { ADDR,INP0,INP1,INP2,INP3 }, NULL, "DISCRETE_MULTIPLEX4" },
4504#define DISCRETE_MULTIPLEX8(NODE,ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7) { NODE, DST_MULTIPLEX, 9, { ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7 }, { ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7 }, NULL, "DISCRETE_MULTIPLEX8" },
4505#define DISCRETE_MULTIPLY(NODE,INP0,INP1)                               { NODE, DST_GAIN        , 3, { INP0,INP1,NODE_NC }, { INP0,INP1,0 }, NULL, "DISCRETE_MULTIPLY" },
4506#define DISCRETE_MULTADD(NODE,INP0,INP1,INP2)                           { NODE, DST_GAIN        , 3, { INP0,INP1,INP2 }, { INP0,INP1,INP2 }, NULL, "DISCRETE_MULTADD" },
4507#define DISCRETE_ONESHOT(NODE,TRIG,AMPL,WIDTH,TYPE)                     { NODE, DST_ONESHOT     , 5, { 0,TRIG,AMPL,WIDTH,NODE_NC }, { 0,TRIG,AMPL,WIDTH,TYPE }, NULL, "DISCRETE_ONESHOT" },
4508#define DISCRETE_ONESHOTR(NODE,RESET,TRIG,AMPL,WIDTH,TYPE)              { NODE, DST_ONESHOT     , 5, { RESET,TRIG,AMPL,WIDTH,NODE_NC }, { RESET,TRIG,AMPL,WIDTH,TYPE }, NULL, "One Shot Resetable" },
4509#define DISCRETE_ONOFF(NODE,ENAB,INP0)                                  { NODE, DST_GAIN        , 3, { ENAB,INP0,NODE_NC }, { 0,1,0 }, NULL, "DISCRETE_ONOFF" },
4510#define DISCRETE_RAMP(NODE,ENAB,RAMP,GRAD,START,END,CLAMP)              { NODE, DST_RAMP        , 6, { ENAB,RAMP,GRAD,START,END,CLAMP }, { ENAB,RAMP,GRAD,START,END,CLAMP }, NULL, "DISCRETE_RAMP" },
4511#define DISCRETE_SAMPLHOLD(NODE,INP0,CLOCK,CLKTYPE)                     { NODE, DST_SAMPHOLD    , 3, { INP0,CLOCK,NODE_NC }, { INP0,CLOCK,CLKTYPE }, NULL, "DISCRETE_SAMPLHOLD" },
4512#define DISCRETE_SWITCH(NODE,ENAB,SWITCH,INP0,INP1)                     { NODE, DST_SWITCH      , 4, { ENAB,SWITCH,INP0,INP1 }, { ENAB,SWITCH,INP0,INP1 }, NULL, "DISCRETE_SWITCH" },
4513#define DISCRETE_ASWITCH(NODE,CTRL,INP,THRESHOLD)                       { NODE, DST_ASWITCH     , 3, { CTRL,INP,THRESHOLD }, { CTRL,INP, THRESHOLD}, NULL, "Analog Switch" },
4514#define DISCRETE_TRANSFORM2(NODE,INP0,INP1,FUNCT)                       { NODE, DST_TRANSFORM   , 2, { INP0,INP1 }, { INP0,INP1 }, FUNCT, "DISCRETE_TRANSFORM2" },
4515#define DISCRETE_TRANSFORM3(NODE,INP0,INP1,INP2,FUNCT)                  { NODE, DST_TRANSFORM   , 3, { INP0,INP1,INP2 }, { INP0,INP1,INP2 }, FUNCT, "DISCRETE_TRANSFORM3" },
4516#define DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT)             { NODE, DST_TRANSFORM   , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 }, FUNCT, "DISCRETE_TRANSFORM4" },
4517#define DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT)        { NODE, DST_TRANSFORM   , 5, { INP0,INP1,INP2,INP3,INP4 }, { INP0,INP1,INP2,INP3,INP4 }, FUNCT, "DISCRETE_TRANSFORM5" },
4635#define DISCRETE_LOGIC_AND(NODE,INP0,INP1)                              DSC_SND_ENTRY( NODE, DST_LOGIC_AND   , 4, DSE( INP0,INP1,NODE_NC,NODE_NC ), DSE( INP0,INP1,1.0,1.0 ), NULL, "DISCRETE_LOGIC_AND" ),
4636#define DISCRETE_LOGIC_AND3(NODE,INP0,INP1,INP2)                        DSC_SND_ENTRY( NODE, DST_LOGIC_AND   , 4, DSE( INP0,INP1,INP2,NODE_NC ), DSE( INP0,INP1,INP2,1.0 ), NULL, "DISCRETE_LOGIC_AND3" ),
4637#define DISCRETE_LOGIC_AND4(NODE,INP0,INP1,INP2,INP3)                   DSC_SND_ENTRY( NODE, DST_LOGIC_AND   , 4, DSE( INP0,INP1,INP2,INP3 ), DSE( INP0,INP1,INP2,INP3 ) ,NULL, "DISCRETE_LOGIC_AND4" ),
4638#define DISCRETE_LOGIC_NAND(NODE,INP0,INP1)                             DSC_SND_ENTRY( NODE, DST_LOGIC_NAND  , 4, DSE( INP0,INP1,NODE_NC,NODE_NC ), DSE( INP0,INP1,1.0,1.0 ), NULL, "DISCRETE_LOGIC_NAND" ),
4639#define DISCRETE_LOGIC_NAND3(NODE,INP0,INP1,INP2)                       DSC_SND_ENTRY( NODE, DST_LOGIC_NAND  , 4, DSE( INP0,INP1,INP2,NODE_NC ), DSE( INP0,INP1,INP2,1.0 ), NULL, "DISCRETE_LOGIC_NAND3" ),
4640#define DISCRETE_LOGIC_NAND4(NODE,INP0,INP1,INP2,INP3)                  DSC_SND_ENTRY( NODE, DST_LOGIC_NAND  , 4, DSE( INP0,INP1,INP2,INP3 ), DSE( INP0,INP1,INP2,INP3 ), NULL, ")DISCRETE_LOGIC_NAND4" ),
4641#define DISCRETE_LOGIC_OR(NODE,INP0,INP1)                               DSC_SND_ENTRY( NODE, DST_LOGIC_OR    , 4, DSE( INP0,INP1,NODE_NC,NODE_NC ), DSE( INP0,INP1,0.0,0.0 ), NULL, "DISCRETE_LOGIC_OR" ),
4642#define DISCRETE_LOGIC_OR3(NODE,INP0,INP1,INP2)                         DSC_SND_ENTRY( NODE, DST_LOGIC_OR    , 4, DSE( INP0,INP1,INP2,NODE_NC ), DSE( INP0,INP1,INP2,0.0 ), NULL, "DISCRETE_LOGIC_OR3" ),
4643#define DISCRETE_LOGIC_OR4(NODE,INP0,INP1,INP2,INP3)                    DSC_SND_ENTRY( NODE, DST_LOGIC_OR    , 4, DSE( INP0,INP1,INP2,INP3 ), DSE( INP0,INP1,INP2,INP3 ), NULL, "DISCRETE_LOGIC_OR4" ),
4644#define DISCRETE_LOGIC_NOR(NODE,INP0,INP1)                              DSC_SND_ENTRY( NODE, DST_LOGIC_NOR   , 4, DSE( INP0,INP1,NODE_NC,NODE_NC ), DSE( INP0,INP1,0.0,0.0 ), NULL, "DISCRETE_LOGIC_NOR" ),
4645#define DISCRETE_LOGIC_NOR3(NODE,INP0,INP1,INP2)                        DSC_SND_ENTRY( NODE, DST_LOGIC_NOR   , 4, DSE( INP0,INP1,INP2,NODE_NC ), DSE( INP0,INP1,INP2,0.0 ), NULL, "DISCRETE_LOGIC_NOR3" ),
4646#define DISCRETE_LOGIC_NOR4(NODE,INP0,INP1,INP2,INP3)                   DSC_SND_ENTRY( NODE, DST_LOGIC_NOR   , 4, DSE( INP0,INP1,INP2,INP3 ), DSE( INP0,INP1,INP2,INP3 ), NULL, "DISCRETE_LOGIC_NOR4" ),
4647#define DISCRETE_LOGIC_XOR(NODE,INP0,INP1)                              DSC_SND_ENTRY( NODE, DST_LOGIC_XOR   , 2, DSE( INP0,INP1 ), DSE( INP0,INP1 ), NULL, "DISCRETE_LOGIC_XOR" ),
4648#define DISCRETE_LOGIC_XNOR(NODE,INP0,INP1)                             DSC_SND_ENTRY( NODE, DST_LOGIC_NXOR  , 2, DSE( INP0,INP1 ), DSE( INP0,INP1 ), NULL, "DISCRETE_LOGIC_XNOR" ),
4649#define DISCRETE_LOGIC_DFLIPFLOP(NODE,RESET,SET,CLK,INP)                DSC_SND_ENTRY( NODE, DST_LOGIC_DFF   , 4, DSE( RESET,SET,CLK,INP ), DSE( RESET,SET,CLK,INP ), NULL, "DISCRETE_LOGIC_DFLIPFLOP" ),
4650#define DISCRETE_LOGIC_JKFLIPFLOP(NODE,RESET,SET,CLK,J,K)               DSC_SND_ENTRY( NODE, DST_LOGIC_JKFF  , 5, DSE( RESET,SET,CLK,J,K ), DSE( RESET,SET,CLK,J,K ), NULL, "DISCRETE_LOGIC_JKFLIPFLOP" ),
4651#define DISCRETE_LOGIC_SHIFT(NODE,INP0,RESET,CLK,SIZE,OPTIONS)          DSC_SND_ENTRY( NODE, DST_LOGIC_SHIFT , 5, DSE( INP0,RESET,CLK,NODE_NC,NODE_NC ), DSE( INP0,RESET,CLK,SIZE,OPTIONS ), NULL, "DISCRETE_LOGIC_SHIFT" ),
4652#define DISCRETE_LOOKUP_TABLE(NODE,ADDR,SIZE,TABLE)                     DSC_SND_ENTRY( NODE, DST_LOOKUP_TABLE, 2, DSE( ADDR,NODE_NC ), DSE( ADDR,SIZE ), TABLE, "DISCRETE_LOOKUP_TABLE" ),
4653#define DISCRETE_MULTIPLEX2(NODE,ADDR,INP0,INP1)                        DSC_SND_ENTRY( NODE, DST_MULTIPLEX   , 3, DSE( ADDR,INP0,INP1 ), DSE( ADDR,INP0,INP1 ), NULL, "DISCRETE_MULTIPLEX2" ),
4654#define DISCRETE_MULTIPLEX4(NODE,ADDR,INP0,INP1,INP2,INP3)              DSC_SND_ENTRY( NODE, DST_MULTIPLEX   , 5, DSE( ADDR,INP0,INP1,INP2,INP3 ), DSE( ADDR,INP0,INP1,INP2,INP3 ), NULL, "DISCRETE_MULTIPLEX4" ),
4655#define DISCRETE_MULTIPLEX8(NODE,ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7) DSC_SND_ENTRY( NODE, DST_MULTIPLEX, 9, DSE( ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7 ), DSE( ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7 ), NULL, "DISCRETE_MULTIPLEX8" ),
4656#define DISCRETE_MULTIPLY(NODE,INP0,INP1)                               DSC_SND_ENTRY( NODE, DST_GAIN        , 3, DSE( INP0,INP1,NODE_NC ), DSE( INP0,INP1,0 ), NULL, "DISCRETE_MULTIPLY" ),
4657#define DISCRETE_MULTADD(NODE,INP0,INP1,INP2)                           DSC_SND_ENTRY( NODE, DST_GAIN        , 3, DSE( INP0,INP1,INP2 ), DSE( INP0,INP1,INP2 ), NULL, "DISCRETE_MULTADD" ),
4658#define DISCRETE_ONESHOT(NODE,TRIG,AMPL,WIDTH,TYPE)                     DSC_SND_ENTRY( NODE, DST_ONESHOT     , 5, DSE( 0,TRIG,AMPL,WIDTH,NODE_NC ), DSE( 0,TRIG,AMPL,WIDTH,TYPE ), NULL, "DISCRETE_ONESHOT" ),
4659#define DISCRETE_ONESHOTR(NODE,RESET,TRIG,AMPL,WIDTH,TYPE)              DSC_SND_ENTRY( NODE, DST_ONESHOT     , 5, DSE( RESET,TRIG,AMPL,WIDTH,NODE_NC ), DSE( RESET,TRIG,AMPL,WIDTH,TYPE ), NULL, "One Shot Resetable" ),
4660#define DISCRETE_ONOFF(NODE,ENAB,INP0)                                  DSC_SND_ENTRY( NODE, DST_GAIN        , 3, DSE( ENAB,INP0,NODE_NC ), DSE( 0,1,0 ), NULL, "DISCRETE_ONOFF" ),
4661#define DISCRETE_RAMP(NODE,ENAB,RAMP,GRAD,START,END,CLAMP)              DSC_SND_ENTRY( NODE, DST_RAMP        , 6, DSE( ENAB,RAMP,GRAD,START,END,CLAMP ), DSE( ENAB,RAMP,GRAD,START,END,CLAMP ), NULL, "DISCRETE_RAMP" ),
4662#define DISCRETE_SAMPLHOLD(NODE,INP0,CLOCK,CLKTYPE)                     DSC_SND_ENTRY( NODE, DST_SAMPHOLD    , 3, DSE( INP0,CLOCK,NODE_NC ), DSE( INP0,CLOCK,CLKTYPE ), NULL, "DISCRETE_SAMPLHOLD" ),
4663#define DISCRETE_SWITCH(NODE,ENAB,SWITCH,INP0,INP1)                     DSC_SND_ENTRY( NODE, DST_SWITCH      , 4, DSE( ENAB,SWITCH,INP0,INP1 ), DSE( ENAB,SWITCH,INP0,INP1 ), NULL, "DISCRETE_SWITCH" ),
4664#define DISCRETE_ASWITCH(NODE,CTRL,INP,THRESHOLD)                       DSC_SND_ENTRY( NODE, DST_ASWITCH     , 3, DSE( CTRL,INP,THRESHOLD ), DSE( CTRL,INP, THRESHOLD), NULL, "Analog Switch" ),
4665#define DISCRETE_TRANSFORM2(NODE,INP0,INP1,FUNCT)                       DSC_SND_ENTRY( NODE, DST_TRANSFORM   , 2, DSE( INP0,INP1 ), DSE( INP0,INP1 ), FUNCT, "DISCRETE_TRANSFORM2" ),
4666#define DISCRETE_TRANSFORM3(NODE,INP0,INP1,INP2,FUNCT)                  DSC_SND_ENTRY( NODE, DST_TRANSFORM   , 3, DSE( INP0,INP1,INP2 ), DSE( INP0,INP1,INP2 ), FUNCT, "DISCRETE_TRANSFORM3" ),
4667#define DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT)             DSC_SND_ENTRY( NODE, DST_TRANSFORM   , 4, DSE( INP0,INP1,INP2,INP3 ), DSE( INP0,INP1,INP2,INP3 ), FUNCT, "DISCRETE_TRANSFORM4" ),
4668#define DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT)        DSC_SND_ENTRY( NODE, DST_TRANSFORM   , 5, DSE( INP0,INP1,INP2,INP3,INP4 ), DSE( INP0,INP1,INP2,INP3,INP4 ), FUNCT, "DISCRETE_TRANSFORM5" ),
45184669/* Component specific */
4519#define DISCRETE_COMP_ADDER(NODE,DATA,TABLE)                            { NODE, DST_COMP_ADDER  , 1, { DATA }, { DATA }, TABLE, "DISCRETE_COMP_ADDER" },
4520#define DISCRETE_DAC_R1(NODE,DATA,VDATA,LADDER)                         { NODE, DST_DAC_R1      , 2, { DATA,NODE_NC }, { DATA,VDATA }, LADDER, "DISCRETE_DAC_R1" },
4521#define DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE)                       { NODE, DST_DIODE_MIX   , 3, { IN0,IN1 }, { IN0,IN1 }, TABLE, "DISCRETE_DIODE_MIXER2" },
4522#define DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE)                   { NODE, DST_DIODE_MIX   , 4, { IN0,IN1,IN2 }, { IN0,IN1,IN2 }, TABLE, "DISCRETE_DIODE_MIXER3" },
4523#define DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE)               { NODE, DST_DIODE_MIX   , 5, { IN0,IN1,IN2,IN3 }, { IN0,IN1,IN2,IN3 }, TABLE, "DISCRETE_DIODE_MIXER4" },
4524#define DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO)                         { NODE, DST_INTEGRATE   , 2, { TRG0,TRG1 }, { TRG0,TRG1 }, INFO, "DISCRETE_INTEGRATE" },
4525#define DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO)                         { NODE, DST_MIXER       , 3, { ENAB,IN0,IN1 }, { ENAB,IN0,IN1 }, INFO, "DISCRETE_MIXER2" },
4526#define DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO)                     { NODE, DST_MIXER       , 4, { ENAB,IN0,IN1,IN2 }, { ENAB,IN0,IN1,IN2 }, INFO, "DISCRETE_MIXER3" },
4527#define DISCRETE_MIXER4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO)                 { NODE, DST_MIXER       , 5, { ENAB,IN0,IN1,IN2,IN3 }, { ENAB,IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_MIXER4" },
4528#define DISCRETE_MIXER5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO)             { NODE, DST_MIXER       , 6, { ENAB,IN0,IN1,IN2,IN3,IN4 }, { ENAB,IN0,IN1,IN2,IN3,IN4 }, INFO, "DISCRETE_MIXER5" },
4529#define DISCRETE_MIXER6(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,INFO)         { NODE, DST_MIXER       , 7, { ENAB,IN0,IN1,IN2,IN3,IN4,IN5 }, { ENAB,IN0,IN1,IN2,IN3,IN4,IN5 }, INFO, "DISCRETE_MIXER6" },
4530#define DISCRETE_MIXER7(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)     { NODE, DST_MIXER       , 8, { ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, { ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, INFO, "DISCRETE_MIXER7" },
4531#define DISCRETE_MIXER8(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO) { NODE, DST_MIXER       , 9, { ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, { ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, INFO, "DISCRETE_MIXER8" },
4532#define DISCRETE_OP_AMP(NODE,ENAB,IN0,IN1,INFO)                         { NODE, DST_OP_AMP      , 3, { ENAB,IN0,IN1 }, { ENAB,IN0,IN1 }, INFO, "DISCRETE_OP_AMP" },
4533#define DISCRETE_OP_AMP_ONESHOT(NODE,TRIG,INFO)                         { NODE, DST_OP_AMP_1SHT , 1, { TRIG }, { TRIG }, INFO, "DISCRETE_OP_AMP_ONESHOT" },
4534#define DISCRETE_OP_AMP_TRIG_VCA(NODE,TRG0,TRG1,TRG2,IN0,IN1,INFO)      { NODE, DST_TVCA_OP_AMP , 5, { TRG0,TRG1,TRG2,IN0,IN1 }, { TRG0,TRG1,TRG2,IN0,IN1 }, INFO, "DISCRETE_OP_AMP_TRIG_VCA" },
4535#define DISCRETE_VCA(NODE,ENAB,IN0,CTRL,TYPE)                           { NODE, DST_VCA         , 4, { ENAB,IN0,CTRL,NODE_NC }, { ENAB,IN0,CTRL,TYPE }, NULL, "DISCRETE_VCA" },
4536#define DISCRETE_XTIME_BUFFER(NODE,IN0,LOW,HIGH)                        { NODE, DST_XTIME_BUFFER, 4, { IN0,LOW,HIGH,NODE_NC }, { IN0,LOW,HIGH,0 }, NULL, "DISCRETE_XTIME_BUFFER" },
4537#define DISCRETE_XTIME_INVERTER(NODE,IN0,LOW,HIGH)                      { NODE, DST_XTIME_BUFFER, 4, { IN0,LOW,HIGH,NODE_NC }, { IN0,LOW,HIGH,1 }, NULL, "DISCRETE_XTIME_INVERTER" },
4538#define DISCRETE_XTIME_AND(NODE,IN0,IN1,LOW,HIGH)                       { NODE, DST_XTIME_AND,    5, { IN0,IN1,LOW,HIGH,NODE_NC }, { IN0,IN1,LOW,HIGH,0 }, NULL, "DISCRETE_XTIME_AND" },
4539#define DISCRETE_XTIME_NAND(NODE,IN0,IN1,LOW,HIGH)                      { NODE, DST_XTIME_AND,    5, { IN0,IN1,LOW,HIGH,NODE_NC }, { IN0,IN1,LOW,HIGH,1 }, NULL, "DISCRETE_XTIME_NAND" },
4540#define DISCRETE_XTIME_OR(NODE,IN0,IN1,LOW,HIGH)                        { NODE, DST_XTIME_OR,     5, { IN0,IN1,LOW,HIGH,NODE_NC }, { IN0,IN1,LOW,HIGH,0 }, NULL, "DISCRETE_XTIME_OR" },
4541#define DISCRETE_XTIME_NOR(NODE,IN0,IN1,LOW,HIGH)                       { NODE, DST_XTIME_OR,     5, { IN0,IN1,LOW,HIGH,NODE_NC }, { IN0,IN1,LOW,HIGH,1 }, NULL, "DISCRETE_XTIME_NOR" },
4542#define DISCRETE_XTIME_XOR(NODE,IN0,IN1,LOW,HIGH)                       { NODE, DST_XTIME_XOR,    5, { IN0,IN1,LOW,HIGH,NODE_NC }, { IN0,IN1,LOW,HIGH,0 }, NULL, "DISCRETE_XTIME_XOR" },
4543#define DISCRETE_XTIME_XNOR(NODE,IN0,IN1,LOW,HIGH)                      { NODE, DST_XTIME_XNOR,   5, { IN0,IN1,LOW,HIGH,NODE_NC }, { IN0,IN1,LOW,HIGH,1 }, NULL, "DISCRETE_XTIME_XNOR" },
4670#define DISCRETE_COMP_ADDER(NODE,DATA,TABLE)                            DSC_SND_ENTRY( NODE, DST_COMP_ADDER  , 1, DSE( DATA ), DSE( DATA ), TABLE, "DISCRETE_COMP_ADDER" ),
4671#define DISCRETE_DAC_R1(NODE,DATA,VDATA,LADDER)                         DSC_SND_ENTRY( NODE, DST_DAC_R1      , 2, DSE( DATA,NODE_NC ), DSE( DATA,VDATA ), LADDER, "DISCRETE_DAC_R1" ),
4672#define DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE)                       DSC_SND_ENTRY( NODE, DST_DIODE_MIX   , 3, DSE( IN0,IN1 ), DSE( IN0,IN1 ), TABLE, "DISCRETE_DIODE_MIXER2" ),
4673#define DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE)                   DSC_SND_ENTRY( NODE, DST_DIODE_MIX   , 4, DSE( IN0,IN1,IN2 ), DSE( IN0,IN1,IN2 ), TABLE, "DISCRETE_DIODE_MIXER3" ),
4674#define DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE)               DSC_SND_ENTRY( NODE, DST_DIODE_MIX   , 5, DSE( IN0,IN1,IN2,IN3 ), DSE( IN0,IN1,IN2,IN3 ), TABLE, "DISCRETE_DIODE_MIXER4" ),
4675#define DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO)                         DSC_SND_ENTRY( NODE, DST_INTEGRATE   , 2, DSE( TRG0,TRG1 ), DSE( TRG0,TRG1 ), INFO, "DISCRETE_INTEGRATE" ),
4676#define DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO)                         DSC_SND_ENTRY( NODE, DST_MIXER       , 3, DSE( ENAB,IN0,IN1 ), DSE( ENAB,IN0,IN1 ), INFO, "DISCRETE_MIXER2" ),
4677#define DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO)                     DSC_SND_ENTRY( NODE, DST_MIXER       , 4, DSE( ENAB,IN0,IN1,IN2 ), DSE( ENAB,IN0,IN1,IN2 ), INFO, "DISCRETE_MIXER3" ),
4678#define DISCRETE_MIXER4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO)                 DSC_SND_ENTRY( NODE, DST_MIXER       , 5, DSE( ENAB,IN0,IN1,IN2,IN3 ), DSE( ENAB,IN0,IN1,IN2,IN3 ), INFO, "DISCRETE_MIXER4" ),
4679#define DISCRETE_MIXER5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO)             DSC_SND_ENTRY( NODE, DST_MIXER       , 6, DSE( ENAB,IN0,IN1,IN2,IN3,IN4 ), DSE( ENAB,IN0,IN1,IN2,IN3,IN4 ), INFO, "DISCRETE_MIXER5" ),
4680#define DISCRETE_MIXER6(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,INFO)         DSC_SND_ENTRY( NODE, DST_MIXER       , 7, DSE( ENAB,IN0,IN1,IN2,IN3,IN4,IN5 ), DSE( ENAB,IN0,IN1,IN2,IN3,IN4,IN5 ), INFO, "DISCRETE_MIXER6" ),
4681#define DISCRETE_MIXER7(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)     DSC_SND_ENTRY( NODE, DST_MIXER       , 8, DSE( ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6 ), DSE( ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6 ), INFO, "DISCRETE_MIXER7" ),
4682#define DISCRETE_MIXER8(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO) DSC_SND_ENTRY( NODE, DST_MIXER       , 9, DSE( ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 ), DSE( ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 ), INFO, "DISCRETE_MIXER8" ),
4683#define DISCRETE_OP_AMP(NODE,ENAB,IN0,IN1,INFO)                         DSC_SND_ENTRY( NODE, DST_OP_AMP      , 3, DSE( ENAB,IN0,IN1 ), DSE( ENAB,IN0,IN1 ), INFO, "DISCRETE_OP_AMP" ),
4684#define DISCRETE_OP_AMP_ONESHOT(NODE,TRIG,INFO)                         DSC_SND_ENTRY( NODE, DST_OP_AMP_1SHT , 1, DSE( TRIG ), DSE( TRIG ), INFO, "DISCRETE_OP_AMP_ONESHOT" ),
4685#define DISCRETE_OP_AMP_TRIG_VCA(NODE,TRG0,TRG1,TRG2,IN0,IN1,INFO)      DSC_SND_ENTRY( NODE, DST_TVCA_OP_AMP , 5, DSE( TRG0,TRG1,TRG2,IN0,IN1 ), DSE( TRG0,TRG1,TRG2,IN0,IN1 ), INFO, "DISCRETE_OP_AMP_TRIG_VCA" ),
4686#define DISCRETE_VCA(NODE,ENAB,IN0,CTRL,TYPE)                           DSC_SND_ENTRY( NODE, DST_VCA         , 4, DSE( ENAB,IN0,CTRL,NODE_NC ), DSE( ENAB,IN0,CTRL,TYPE ), NULL, "DISCRETE_VCA" ),
4687#define DISCRETE_XTIME_BUFFER(NODE,IN0,LOW,HIGH)                        DSC_SND_ENTRY( NODE, DST_XTIME_BUFFER, 4, DSE( IN0,LOW,HIGH,NODE_NC ), DSE( IN0,LOW,HIGH,0 ), NULL, "DISCRETE_XTIME_BUFFER" ),
4688#define DISCRETE_XTIME_INVERTER(NODE,IN0,LOW,HIGH)                      DSC_SND_ENTRY( NODE, DST_XTIME_BUFFER, 4, DSE( IN0,LOW,HIGH,NODE_NC ), DSE( IN0,LOW,HIGH,1 ), NULL, "DISCRETE_XTIME_INVERTER" ),
4689#define DISCRETE_XTIME_AND(NODE,IN0,IN1,LOW,HIGH)                       DSC_SND_ENTRY( NODE, DST_XTIME_AND,    5, DSE( IN0,IN1,LOW,HIGH,NODE_NC ), DSE( IN0,IN1,LOW,HIGH,0 ), NULL, "DISCRETE_XTIME_AND" ),
4690#define DISCRETE_XTIME_NAND(NODE,IN0,IN1,LOW,HIGH)                      DSC_SND_ENTRY( NODE, DST_XTIME_AND,    5, DSE( IN0,IN1,LOW,HIGH,NODE_NC ), DSE( IN0,IN1,LOW,HIGH,1 ), NULL, "DISCRETE_XTIME_NAND" ),
4691#define DISCRETE_XTIME_OR(NODE,IN0,IN1,LOW,HIGH)                        DSC_SND_ENTRY( NODE, DST_XTIME_OR,     5, DSE( IN0,IN1,LOW,HIGH,NODE_NC ), DSE( IN0,IN1,LOW,HIGH,0 ), NULL, "DISCRETE_XTIME_OR" ),
4692#define DISCRETE_XTIME_NOR(NODE,IN0,IN1,LOW,HIGH)                       DSC_SND_ENTRY( NODE, DST_XTIME_OR,     5, DSE( IN0,IN1,LOW,HIGH,NODE_NC ), DSE( IN0,IN1,LOW,HIGH,1 ), NULL, "DISCRETE_XTIME_NOR" ),
4693#define DISCRETE_XTIME_XOR(NODE,IN0,IN1,LOW,HIGH)                       DSC_SND_ENTRY( NODE, DST_XTIME_XOR,    5, DSE( IN0,IN1,LOW,HIGH,NODE_NC ), DSE( IN0,IN1,LOW,HIGH,0 ), NULL, "DISCRETE_XTIME_XOR" ),
4694#define DISCRETE_XTIME_XNOR(NODE,IN0,IN1,LOW,HIGH)                      DSC_SND_ENTRY( NODE, DST_XTIME_XNOR,   5, DSE( IN0,IN1,LOW,HIGH,NODE_NC ), DSE( IN0,IN1,LOW,HIGH,1 ), NULL, "DISCRETE_XTIME_XNOR" ),
45444695
45454696/* from disc_flt.c */
45464697/* generic modules */
4547#define DISCRETE_FILTER1(NODE,ENAB,INP0,FREQ,TYPE)                      { NODE, DST_FILTER1     , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,FREQ,TYPE }, NULL, "DISCRETE_FILTER1" },
4548#define DISCRETE_FILTER2(NODE,ENAB,INP0,FREQ,DAMP,TYPE)                 { NODE, DST_FILTER2     , 5, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,FREQ,DAMP,TYPE }, NULL, "DISCRETE_FILTER2" },
4698#define DISCRETE_FILTER1(NODE,ENAB,INP0,FREQ,TYPE)                      DSC_SND_ENTRY( NODE, DST_FILTER1     , 4, DSE( ENAB,INP0,NODE_NC,NODE_NC ), DSE( ENAB,INP0,FREQ,TYPE ), NULL, "DISCRETE_FILTER1" ),
4699#define DISCRETE_FILTER2(NODE,ENAB,INP0,FREQ,DAMP,TYPE)                 DSC_SND_ENTRY( NODE, DST_FILTER2     , 5, DSE( ENAB,INP0,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,INP0,FREQ,DAMP,TYPE ), NULL, "DISCRETE_FILTER2" ),
45494700/* Component specific */
4550#define DISCRETE_SALLEN_KEY_FILTER(NODE,ENAB,INP0,TYPE,INFO)            { NODE, DST_SALLEN_KEY  , 3, { ENAB,INP0,NODE_NC }, { ENAB,INP0,TYPE }, INFO, "DISCRETE_SALLEN_KEY_FILTER" },
4551#define DISCRETE_CRFILTER(NODE,INP0,RVAL,CVAL)                          { NODE, DST_CRFILTER    , 4, { INP0,RVAL,CVAL }, { INP0,RVAL,CVAL }, NULL, "DISCRETE_CRFILTER" },
4552#define DISCRETE_CRFILTER_VREF(NODE,INP0,RVAL,CVAL,VREF)                { NODE, DST_CRFILTER    , 5, { INP0,RVAL,CVAL,VREF }, { INP0,RVAL,CVAL,VREF }, NULL, "DISCRETE_CRFILTER_VREF" },
4553#define DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO)           { NODE, DST_OP_AMP_FILT , 4, { ENAB,INP0,INP1,NODE_NC }, { ENAB,INP0,INP1,TYPE }, INFO, "DISCRETE_OP_AMP_FILTER" },
4554#define DISCRETE_RC_CIRCUIT_1(NODE,INP0,INP1,RVAL,CVAL)                 { NODE, DST_RC_CIRCUIT_1, 4, { INP0,INP1,NODE_NC,NODE_NC }, { INP0,INP1,RVAL,CVAL }, NULL, "DISCRETE_RC_CIRCUIT_1" },
4555#define DISCRETE_RCDISC(NODE,ENAB,INP0,RVAL,CVAL)                       { NODE, DST_RCDISC      , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISC" },
4556#define DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)        { NODE, DST_RCDISC2     , 6, { SWITCH,INP0,NODE_NC,INP1,NODE_NC,NODE_NC }, { SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL }, NULL, "DISCRETE_RCDISC2" },
4557#define DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL,DJV)           { NODE, DST_RCDISC3     , 6, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL0,RVAL1,CVAL,DJV }, NULL, "DISCRETE_RCDISC3" },
4558#define DISCRETE_RCDISC4(NODE,ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE) { NODE, DST_RCDISC4     , 8, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE }, NULL, "DISCRETE_RCDISC4" },
4559#define DISCRETE_RCDISC5(NODE,ENAB,INP0,RVAL,CVAL)                      { NODE, DST_RCDISC5     , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISC5" },
4560#define DISCRETE_RCDISC_MODULATED(NODE,INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP)   { NODE, DST_RCDISC_MOD, 8, { INP0,INP1,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP }, NULL, "DISCRETE_RCDISC_MODULATED" },
4561#define DISCRETE_RCFILTER(NODE,INP0,RVAL,CVAL)                          { NODE, DST_RCFILTER    , 3, { INP0,RVAL,CVAL }, { INP0,RVAL,CVAL }, NULL, "DISCRETE_RCFILTER" },
4562#define DISCRETE_RCFILTER_VREF(NODE,INP0,RVAL,CVAL,VREF)                { NODE, DST_RCFILTER    , 4, { INP0,RVAL,CVAL,VREF }, { INP0,RVAL,CVAL,VREF }, NULL, "DISCRETE_RCFILTER_VREF" },
4563#define DISCRETE_RCFILTER_SW(NODE,ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4) { NODE, DST_RCFILTER_SW, 8, { ENAB,INP0,SW,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, NULL, "DISCRETE_RCFILTER_SW" },
4564#define DISCRETE_RCINTEGRATE(NODE,INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE)  { NODE, DST_RCINTEGRATE , 7, { INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE }, NULL, "DISCRETE_RCINTEGRATE" },
4701#define DISCRETE_SALLEN_KEY_FILTER(NODE,ENAB,INP0,TYPE,INFO)            DSC_SND_ENTRY( NODE, DST_SALLEN_KEY  , 3, DSE( ENAB,INP0,NODE_NC ), DSE( ENAB,INP0,TYPE ), INFO, "DISCRETE_SALLEN_KEY_FILTER" ),
4702#define DISCRETE_CRFILTER(NODE,INP0,RVAL,CVAL)                          DSC_SND_ENTRY( NODE, DST_CRFILTER    , 4, DSE( INP0,RVAL,CVAL ), DSE( INP0,RVAL,CVAL ), NULL, "DISCRETE_CRFILTER" ),
4703#define DISCRETE_CRFILTER_VREF(NODE,INP0,RVAL,CVAL,VREF)                DSC_SND_ENTRY( NODE, DST_CRFILTER    , 5, DSE( INP0,RVAL,CVAL,VREF ), DSE( INP0,RVAL,CVAL,VREF ), NULL, "DISCRETE_CRFILTER_VREF" ),
4704#define DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO)           DSC_SND_ENTRY( NODE, DST_OP_AMP_FILT , 4, DSE( ENAB,INP0,INP1,NODE_NC ), DSE( ENAB,INP0,INP1,TYPE ), INFO, "DISCRETE_OP_AMP_FILTER" ),
4705#define DISCRETE_RC_CIRCUIT_1(NODE,INP0,INP1,RVAL,CVAL)                 DSC_SND_ENTRY( NODE, DST_RC_CIRCUIT_1, 4, DSE( INP0,INP1,NODE_NC,NODE_NC ), DSE( INP0,INP1,RVAL,CVAL ), NULL, "DISCRETE_RC_CIRCUIT_1" ),
4706#define DISCRETE_RCDISC(NODE,ENAB,INP0,RVAL,CVAL)                       DSC_SND_ENTRY( NODE, DST_RCDISC      , 4, DSE( ENAB,INP0,NODE_NC,NODE_NC ), DSE( ENAB,INP0,RVAL,CVAL ), NULL, "DISCRETE_RCDISC" ),
4707#define DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)        DSC_SND_ENTRY( NODE, DST_RCDISC2     , 6, DSE( SWITCH,INP0,NODE_NC,INP1,NODE_NC,NODE_NC ), DSE( SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL ), NULL, "DISCRETE_RCDISC2" ),
4708#define DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL,DJV)           DSC_SND_ENTRY( NODE, DST_RCDISC3     , 6, DSE( ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,INP0,RVAL0,RVAL1,CVAL,DJV ), NULL, "DISCRETE_RCDISC3" ),
4709#define DISCRETE_RCDISC4(NODE,ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE) DSC_SND_ENTRY( NODE, DST_RCDISC4     , 8, DSE( ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE ), NULL, "DISCRETE_RCDISC4" ),
4710#define DISCRETE_RCDISC5(NODE,ENAB,INP0,RVAL,CVAL)                      DSC_SND_ENTRY( NODE, DST_RCDISC5     , 4, DSE( ENAB,INP0,NODE_NC,NODE_NC ), DSE( ENAB,INP0,RVAL,CVAL ), NULL, "DISCRETE_RCDISC5" ),
4711#define DISCRETE_RCDISC_MODULATED(NODE,INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP)   DSC_SND_ENTRY( NODE, DST_RCDISC_MOD, 8, DSE( INP0,INP1,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP ), NULL, "DISCRETE_RCDISC_MODULATED" ),
4712#define DISCRETE_RCFILTER(NODE,INP0,RVAL,CVAL)                          DSC_SND_ENTRY( NODE, DST_RCFILTER    , 3, DSE( INP0,RVAL,CVAL ), DSE( INP0,RVAL,CVAL ), NULL, "DISCRETE_RCFILTER" ),
4713#define DISCRETE_RCFILTER_VREF(NODE,INP0,RVAL,CVAL,VREF)                DSC_SND_ENTRY( NODE, DST_RCFILTER    , 4, DSE( INP0,RVAL,CVAL,VREF ), DSE( INP0,RVAL,CVAL,VREF ), NULL, "DISCRETE_RCFILTER_VREF" ),
4714#define DISCRETE_RCFILTER_SW(NODE,ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4) DSC_SND_ENTRY( NODE, DST_RCFILTER_SW, 8, DSE( ENAB,INP0,SW,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 ), NULL, "DISCRETE_RCFILTER_SW" ),
4715#define DISCRETE_RCINTEGRATE(NODE,INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE)  DSC_SND_ENTRY( NODE, DST_RCINTEGRATE , 7, DSE( INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE ), NULL, "DISCRETE_RCINTEGRATE" ),
45654716/* For testing - seem to be buggered.  Use versions not ending in N. */
4566#define DISCRETE_RCDISCN(NODE,ENAB,INP0,RVAL,CVAL)                      { NODE, DST_RCDISCN     , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISCN" },
4567#define DISCRETE_RCDISC2N(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)       { NODE, DST_RCDISC2N    , 6, { SWITCH,INP0,NODE_NC,INP1,NODE_NC,NODE_NC }, { SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL }, NULL, "DISCRETE_RCDISC2N" },
4568#define DISCRETE_RCFILTERN(NODE,ENAB,INP0,RVAL,CVAL)                    { NODE, DST_RCFILTERN   , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCFILTERN" },
4717#define DISCRETE_RCDISCN(NODE,ENAB,INP0,RVAL,CVAL)                      DSC_SND_ENTRY( NODE, DST_RCDISCN     , 4, DSE( ENAB,INP0,NODE_NC,NODE_NC ), DSE( ENAB,INP0,RVAL,CVAL ), NULL, "DISCRETE_RCDISCN" ),
4718#define DISCRETE_RCDISC2N(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)       DSC_SND_ENTRY( NODE, DST_RCDISC2N    , 6, DSE( SWITCH,INP0,NODE_NC,INP1,NODE_NC,NODE_NC ), DSE( SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL ), NULL, "DISCRETE_RCDISC2N" ),
4719#define DISCRETE_RCFILTERN(NODE,ENAB,INP0,RVAL,CVAL)                    DSC_SND_ENTRY( NODE, DST_RCFILTERN   , 4, DSE( ENAB,INP0,NODE_NC,NODE_NC ), DSE( ENAB,INP0,RVAL,CVAL ), NULL, "DISCRETE_RCFILTERN" ),
45694720
45704721/* from disc_dev.c */
45714722/* generic modules */
4572#define DISCRETE_CUSTOM1(NODE,IN0,INFO)                                 { NODE, DST_CUSTOM      , 1, { IN0 }, { IN0 }, INFO, "DISCRETE_CUSTOM1" },
4573#define DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)                             { NODE, DST_CUSTOM      , 2, { IN0,IN1 }, { IN0,IN1 }, INFO, "DISCRETE_CUSTOM2" },
4574#define DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO)                         { NODE, DST_CUSTOM      , 3, { IN0,IN1,IN2 }, { IN0,IN1,IN2 }, INFO, "DISCRETE_CUSTOM3" },
4575#define DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO)                     { NODE, DST_CUSTOM      , 4, { IN0,IN1,IN2,IN3 }, { IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_CUSTOM4" },
4576#define DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO)                 { NODE, DST_CUSTOM      , 5, { IN0,IN1,IN2,IN3,IN4 }, { IN0,IN1,IN2,IN3,IN4 }, INFO, "DISCRETE_CUSTOM5" },
4577#define DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO)             { NODE, DST_CUSTOM      , 6, { IN0,IN1,IN2,IN3,IN4,IN5 }, { IN0,IN1,IN2,IN3,IN4,IN5 }, INFO, "DISCRETE_CUSTOM6" },
4578#define DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)         { NODE, DST_CUSTOM      , 7, { IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, INFO, "DISCRETE_CUSTOM7" },
4579#define DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO)     { NODE, DST_CUSTOM      , 8, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, INFO, "DISCRETE_CUSTOM8" },
4580#define DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO) { NODE, DST_CUSTOM      , 9, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 }, INFO, "DISCRETE_CUSTOM9" },
4723#define DISCRETE_CUSTOM1(NODE,IN0,INFO)                                 DSC_SND_ENTRY( NODE, DST_CUSTOM      , 1, DSE( IN0 ), DSE( IN0 ), INFO, "DISCRETE_CUSTOM1" ),
4724#define DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)                             DSC_SND_ENTRY( NODE, DST_CUSTOM      , 2, DSE( IN0,IN1 ), DSE( IN0,IN1 ), INFO, "DISCRETE_CUSTOM2" ),
4725#define DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO)                         DSC_SND_ENTRY( NODE, DST_CUSTOM      , 3, DSE( IN0,IN1,IN2 ), DSE( IN0,IN1,IN2 ), INFO, "DISCRETE_CUSTOM3" ),
4726#define DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO)                     DSC_SND_ENTRY( NODE, DST_CUSTOM      , 4, DSE( IN0,IN1,IN2,IN3 ), DSE( IN0,IN1,IN2,IN3 ), INFO, "DISCRETE_CUSTOM4" ),
4727#define DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO)                 DSC_SND_ENTRY( NODE, DST_CUSTOM      , 5, DSE( IN0,IN1,IN2,IN3,IN4 ), DSE( IN0,IN1,IN2,IN3,IN4 ), INFO, "DISCRETE_CUSTOM5" ),
4728#define DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO)             DSC_SND_ENTRY( NODE, DST_CUSTOM      , 6, DSE( IN0,IN1,IN2,IN3,IN4,IN5 ), DSE( IN0,IN1,IN2,IN3,IN4,IN5 ), INFO, "DISCRETE_CUSTOM6" ),
4729#define DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)         DSC_SND_ENTRY( NODE, DST_CUSTOM      , 7, DSE( IN0,IN1,IN2,IN3,IN4,IN5,IN6 ), DSE( IN0,IN1,IN2,IN3,IN4,IN5,IN6 ), INFO, "DISCRETE_CUSTOM7" ),
4730#define DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO)     DSC_SND_ENTRY( NODE, DST_CUSTOM      , 8, DSE( IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 ), DSE( IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 ), INFO, "DISCRETE_CUSTOM8" ),
4731#define DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO) DSC_SND_ENTRY( NODE, DST_CUSTOM      , 9, DSE( IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 ), DSE( IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 ), INFO, "DISCRETE_CUSTOM9" ),
45814732/* Component specific */
4582#define DISCRETE_555_ASTABLE(NODE,RESET,R1,R2,C,OPTIONS)                { NODE, DSD_555_ASTBL   , 5, { RESET,R1,R2,C,NODE_NC }, { RESET,R1,R2,C,-1 }, OPTIONS, "DISCRETE_555_ASTABLE" },
4583#define DISCRETE_555_ASTABLE_CV(NODE,RESET,R1,R2,C,CTRLV,OPTIONS)       { NODE, DSD_555_ASTBL   , 5, { RESET,R1,R2,C,CTRLV }, { RESET,R1,R2,C,CTRLV }, OPTIONS, "DISCRETE_555_ASTABLE_CV" },
4584#define DISCRETE_555_MSTABLE(NODE,RESET,TRIG,R,C,OPTIONS)               { NODE, DSD_555_MSTBL   , 4, { RESET,TRIG,R,C }, { RESET,TRIG,R,C }, OPTIONS, "DISCRETE_555_MSTABLE" },
4585#define DISCRETE_555_CC(NODE,RESET,VIN,R,C,RBIAS,RGND,RDIS,OPTIONS)     { NODE, DSD_555_CC      , 7, { RESET,VIN,R,C,RBIAS,RGND,RDIS }, { RESET,VIN,R,C,RBIAS,RGND,RDIS }, OPTIONS, "DISCRETE_555_CC" },
4586#define DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS)                       { NODE, DSD_555_VCO1    , 3, { RESET,VIN,NODE_NC }, { RESET,VIN,-1 }, OPTIONS, "DISCRETE_555_VCO1" },
4587#define DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS)              { NODE, DSD_555_VCO1    , 3, { RESET,VIN,CTRLV }, { RESET,VIN,CTRLV }, OPTIONS, "DISCRETE_555_VCO1_CV" },
4588#define DISCRETE_566(NODE,VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS)           { NODE, DSD_566         , 7, { VMOD,R,C,NODE_NC,NODE_NC,VCHARGE,NODE_NC }, { VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS }, NULL, "DISCRETE_566" },
4589#define DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE) { NODE, DSD_LS624   , 8, { ENAB,VMOD,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE }, NULL, "DISCRETE_74LS624" },
4733#define DISCRETE_555_ASTABLE(NODE,RESET,R1,R2,C,OPTIONS)                DSC_SND_ENTRY( NODE, DSD_555_ASTBL   , 5, DSE( RESET,R1,R2,C,NODE_NC ), DSE( RESET,R1,R2,C,-1 ), OPTIONS, "DISCRETE_555_ASTABLE" ),
4734#define DISCRETE_555_ASTABLE_CV(NODE,RESET,R1,R2,C,CTRLV,OPTIONS)       DSC_SND_ENTRY( NODE, DSD_555_ASTBL   , 5, DSE( RESET,R1,R2,C,CTRLV ), DSE( RESET,R1,R2,C,CTRLV ), OPTIONS, "DISCRETE_555_ASTABLE_CV" ),
4735#define DISCRETE_555_MSTABLE(NODE,RESET,TRIG,R,C,OPTIONS)               DSC_SND_ENTRY( NODE, DSD_555_MSTBL   , 4, DSE( RESET,TRIG,R,C ), DSE( RESET,TRIG,R,C ), OPTIONS, "DISCRETE_555_MSTABLE" ),
4736#define DISCRETE_555_CC(NODE,RESET,VIN,R,C,RBIAS,RGND,RDIS,OPTIONS)     DSC_SND_ENTRY( NODE, DSD_555_CC      , 7, DSE( RESET,VIN,R,C,RBIAS,RGND,RDIS ), DSE( RESET,VIN,R,C,RBIAS,RGND,RDIS ), OPTIONS, "DISCRETE_555_CC" ),
4737#define DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS)                       DSC_SND_ENTRY( NODE, DSD_555_VCO1    , 3, DSE( RESET,VIN,NODE_NC ), DSE( RESET,VIN,-1 ), OPTIONS, "DISCRETE_555_VCO1" ),
4738#define DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS)              DSC_SND_ENTRY( NODE, DSD_555_VCO1    , 3, DSE( RESET,VIN,CTRLV ), DSE( RESET,VIN,CTRLV ), OPTIONS, "DISCRETE_555_VCO1_CV" ),
4739#define DISCRETE_566(NODE,VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS)           DSC_SND_ENTRY( NODE, DSD_566         , 7, DSE( VMOD,R,C,NODE_NC,NODE_NC,VCHARGE,NODE_NC ), DSE( VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS ), NULL, "DISCRETE_566" ),
4740#define DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE) DSC_SND_ENTRY( NODE, DSD_LS624   , 8, DSE( ENAB,VMOD,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC ), DSE( ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE ), NULL, "DISCRETE_74LS624" ),
45904741
45914742/* NOP */
4592#define DISCRETE_NOP(NODE)                                              { NODE, DSS_NOP         , 0, { 0 }, { 0 }, NULL, "DISCRETE_NOP" },
4743#define DISCRETE_NOP(NODE)                                              DSC_SND_ENTRY( NODE, DSS_NOP         , 0, DSE( 0 ), DSE( 0 ), NULL, "DISCRETE_NOP" ),
45934744
45944745/* logging */
4595#define DISCRETE_CSVLOG1(NODE1)                                         { NODE_SPECIAL, DSO_CSVLOG   , 1, { NODE1 }, { NODE1 }, NULL, "DISCRETE_CSVLOG1" },
4596#define DISCRETE_CSVLOG2(NODE1,NODE2)                                   { NODE_SPECIAL, DSO_CSVLOG   , 2, { NODE1,NODE2 }, { NODE1,NODE2 }, NULL, "DISCRETE_CSVLOG2" },
4597#define DISCRETE_CSVLOG3(NODE1,NODE2,NODE3)                             { NODE_SPECIAL, DSO_CSVLOG   , 3, { NODE1,NODE2,NODE3 }, { NODE1,NODE2,NODE3 }, NULL, "DISCRETE_CSVLOG3" },
4598#define DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4)                       { NODE_SPECIAL, DSO_CSVLOG   , 4, { NODE1,NODE2,NODE3,NODE4 }, { NODE1,NODE2,NODE3,NODE4 }, NULL, "DISCRETE_CSVLOG4" },
4599#define DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5)                 { NODE_SPECIAL, DSO_CSVLOG   , 5, { NODE1,NODE2,NODE3,NODE4,NODE5 }, { NODE1,NODE2,NODE3,NODE4,NODE5 }, NULL, "DISCRETE_CSVLOG5" },
4600#define DISCRETE_WAVLOG1(NODE1,GAIN1)                                  { NODE_SPECIAL, DSO_WAVELOG  , 2, { NODE1,NODE_NC }, { NODE1,GAIN1 }, NULL, "DISCRETE_WAVLOG1" },
4601#define DISCRETE_WAVLOG2(NODE1,GAIN1,NODE2,GAIN2)                      { NODE_SPECIAL, DSO_WAVELOG  , 4, { NODE1,NODE_NC,NODE2,NODE_NC }, { NODE1,GAIN1,NODE2,GAIN2 }, NULL, "DISCRETE_WAVLOG2" },
4746#define DISCRETE_CSVLOG1(NODE1)                                         DSC_SND_ENTRY( NODE_SPECIAL, DSO_CSVLOG   , 1, DSE( NODE1 ), DSE( NODE1 ), NULL, "DISCRETE_CSVLOG1" ),
4747#define DISCRETE_CSVLOG2(NODE1,NODE2)                                   DSC_SND_ENTRY( NODE_SPECIAL, DSO_CSVLOG   , 2, DSE( NODE1,NODE2 ), DSE( NODE1,NODE2 ), NULL, "DISCRETE_CSVLOG2" ),
4748#define DISCRETE_CSVLOG3(NODE1,NODE2,NODE3)                             DSC_SND_ENTRY( NODE_SPECIAL, DSO_CSVLOG   , 3, DSE( NODE1,NODE2,NODE3 ), DSE( NODE1,NODE2,NODE3 ), NULL, "DISCRETE_CSVLOG3" ),
4749#define DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4)                       DSC_SND_ENTRY( NODE_SPECIAL, DSO_CSVLOG   , 4, DSE( NODE1,NODE2,NODE3,NODE4 ), DSE( NODE1,NODE2,NODE3,NODE4 ), NULL, "DISCRETE_CSVLOG4" ),
4750#define DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5)                 DSC_SND_ENTRY( NODE_SPECIAL, DSO_CSVLOG   , 5, DSE( NODE1,NODE2,NODE3,NODE4,NODE5 ), DSE( NODE1,NODE2,NODE3,NODE4,NODE5 ), NULL, "DISCRETE_CSVLOG5" ),
4751#define DISCRETE_WAVLOG1(NODE1,GAIN1)                                  DSC_SND_ENTRY( NODE_SPECIAL, DSO_WAVELOG  , 2, DSE( NODE1,NODE_NC ), DSE( NODE1,GAIN1 ), NULL, "DISCRETE_WAVLOG1" ),
4752#define DISCRETE_WAVLOG2(NODE1,GAIN1,NODE2,GAIN2)                      DSC_SND_ENTRY( NODE_SPECIAL, DSO_WAVELOG  , 4, DSE( NODE1,NODE_NC,NODE2,NODE_NC ), DSE( NODE1,GAIN1,NODE2,GAIN2 ), NULL, "DISCRETE_WAVLOG2" ),
46024753
46034754/* import */
4604#define DISCRETE_IMPORT(INFO)                                           { NODE_SPECIAL, DSO_IMPORT   , 0, { 0 }, { 0 }, &(INFO##_discrete_interface), "DISCRETE_IMPORT" },
4605#define DISCRETE_DELETE(NODE_FROM, NODE_TO)                             { NODE_SPECIAL, DSO_DELETE   , 2, { NODE_FROM, NODE_TO }, { NODE_FROM, NODE_TO }, NULL, "DISCRETE_DELETE" },
4606#define DISCRETE_REPLACE                                           { NODE_SPECIAL, DSO_REPLACE  , 0, { 0 }, { 0 }, NULL, "DISCRETE_REPLACE" },
4755#define DISCRETE_IMPORT(INFO)                                           DSC_SND_ENTRY( NODE_SPECIAL, DSO_IMPORT   , 0, DSE( 0 ), DSE( 0 ), &(INFO##_discrete_interface), "DISCRETE_IMPORT" ),
4756#define DISCRETE_DELETE(NODE_FROM, NODE_TO)                             DSC_SND_ENTRY( NODE_SPECIAL, DSO_DELETE   , 2, DSE( NODE_FROM, NODE_TO ), DSE( NODE_FROM, NODE_TO ), NULL, "DISCRETE_DELETE" ),
4757#define DISCRETE_REPLACE                                           DSC_SND_ENTRY( NODE_SPECIAL, DSO_REPLACE  , 0, DSE( 0 ), DSE( 0 ), NULL, "DISCRETE_REPLACE" ),
46074758
46084759/* parallel tasks */
46094760
4610#define DISCRETE_TASK_START(TASK_GROUP)                                 { NODE_SPECIAL, DSO_TASK_START,1, { NODE_NC, NODE_NC }, { TASK_GROUP, 0 }, NULL, "DISCRETE_TASK_START" },
4611#define DISCRETE_TASK_END()                                             { NODE_SPECIAL, DSO_TASK_END , 1, { 0 }, { 0 }, NULL, "DISCRETE_TASK_END" },
4612//#define DISCRETE_TASK_SYNC()                                          { NODE_SPECIAL, DSO_TASK_SYNC, 0, { 0 }, { 0 }, NULL, "DISCRETE_TASK_SYNC" },
4761#define DISCRETE_TASK_START(TASK_GROUP)                                 DSC_SND_ENTRY( NODE_SPECIAL, DSO_TASK_START,1, DSE( NODE_NC, NODE_NC ), DSE( TASK_GROUP, 0 ), NULL, "DISCRETE_TASK_START" ),
4762#define DISCRETE_TASK_END()                                             DSC_SND_ENTRY( NODE_SPECIAL, DSO_TASK_END , 1, DSE( 0 ), DSE( 0 ), NULL, "DISCRETE_TASK_END" ),
4763//#define DISCRETE_TASK_SYNC()                                          DSC_SND_ENTRY( NODE_SPECIAL, DSO_TASK_SYNC, 0, DSE( 0 ), DSE( 0 ), NULL, "DISCRETE_TASK_SYNC" ),
46134764
46144765/* output */
4615#define DISCRETE_OUTPUT(OPNODE,GAIN)                                  { NODE_SPECIAL, DSO_OUTPUT   , 2, { OPNODE,NODE_NC }, { 0,GAIN }, NULL, "DISCRETE_OUTPUT" },
4766#define DISCRETE_OUTPUT(OPNODE,GAIN)                                  DSC_SND_ENTRY( NODE_SPECIAL, DSO_OUTPUT   , 2, DSE( OPNODE,NODE_NC ), DSE( 0,GAIN ), NULL, "DISCRETE_OUTPUT" ),
46164767
46174768
46184769/*************************************
r9922r9923
46244775WRITE8_DEVICE_HANDLER( discrete_sound_w );
46254776READ8_DEVICE_HANDLER( discrete_sound_r );
46264777
4627DECLARE_LEGACY_SOUND_DEVICE(DISCRETE, discrete);
4778//**************************************************************************
4779//  INTERFACE CONFIGURATION MACROS
4780//**************************************************************************
4781//FIXME: Later
4782#if 0
4783#define MCFG_DISCRETE_ADD(_tag, _clock, _type, _irqf) \
4784   MCFG_DEVICE_ADD(_tag, ASC, _clock) \
4785   MCFG_DISCRETE_TYPE(_type) \
4786   MCFG_IRQ_FUNC(_irqf)
46284787
4788#define MCFG_DISCRETE_REPLACE(_tag, _clock, _type, _irqf) \
4789   MCFG_DEVICE_REPLACE(_tag, ASC, _clock) \
4790   MCFG_DISCRETE_TYPE(_type) \
4791   MCFG_IRQ_FUNC(_irqf)
4792
4793#define MCFG_DISCRETE_TYPE(_type) \
4794   DISCRETE_device_config::static_set_type(device, _type); \
4795
4796#define MCFG_IRQ_FUNC(_irqf) \
4797   DISCRETE_device_config::static_set_irqf(device, _irqf); \
4798
4799#endif
4800
4801//**************************************************************************
4802//  TYPE DEFINITIONS
4803//**************************************************************************
4804
4805// ======================> discrete_device_config
4806
4807class discrete_device_config :   public device_config, public device_config_sound_interface
4808{
4809   friend class discrete_device;
4810
4811   // construction/destruction
4812   discrete_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
4813
4814public:
4815   // allocators
4816   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
4817   virtual device_t *alloc_device(running_machine &machine) const;
4818
4819   // inline configuration helpers
4820   //static void static_set_type(device_config *device, int type);
4821   //static void static_set_irqf(device_config *device, void (*irqf)(device_t *device, int state));
4822
4823protected:
4824   // inline data
4825};
4826
4827
4828
4829// ======================> discrete_device
4830
4831class discrete_device : public device_t, public device_sound_interface
4832{
4833   friend class discrete_device_config;
4834
4835   // construction/destruction
4836   discrete_device(running_machine &_machine, const discrete_device_config &config);
4837
4838public:
4839   DECLARE_READ8_MEMBER(read);
4840   DECLARE_WRITE8_MEMBER(write);
4841   //sound_stream *m_stream;
4842   virtual ~discrete_device(void);
4843
4844protected:
4845
4846   // device-level overrides
4847   virtual void device_start();
4848   virtual void device_reset();
4849
4850   // internal callbacks
4851   static STREAM_UPDATE( static_stream_generate );
4852   virtual void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples);
4853
4854   // internal state
4855   const discrete_device_config &m_config;
4856
4857   /* all for now */
4858   discrete_info m_info;
4859
4860private:
4861
4862
4863};
4864
4865
4866// device type definition
4867extern const device_type DISCRETE;
4868
4869
4870//DECLARE_LEGACY_SOUND_DEVICE(DISCRETE, discrete);
4871
46294872#endif /* __DISCRETE_H__ */
src/emu/sound/disc_dev.c
r9922r9923
398398
399399   node_description *v_charge_node;
400400
401   context->use_ctrlv   = (node->input_is_node >> 4) & 1;
401   context->use_ctrlv   = (node->input_is_node() >> 4) & 1;
402402   context->output_type = info->options & DISC_555_OUT_MASK;
403403
404404   /* Use the defaults or supplied values. */
r9922r9923
431431
432432   /* optimization if none of the values are nodes */
433433   context->has_rc_nodes = 0;
434   if (node->input_is_node & DSD_555_ASTBL_RC_MASK)
434   if (node->input_is_node() & DSD_555_ASTBL_RC_MASK)
435435      context->has_rc_nodes = 1;
436436   else
437437   {
r9922r9923
618618   context->output_type = info->options & DISC_555_OUT_MASK;
619619   if ((context->output_type == DISC_555_OUT_COUNT_F) || (context->output_type == DISC_555_OUT_COUNT_R))
620620   {
621      discrete_log(node->info, "Invalid Output type in NODE_%d.\n", NODE_BLOCKINDEX(node));
621      discrete_log(node->info, "Invalid Output type in NODE_%d.\n", node->index());
622622      context->output_type = DISC_555_OUT_SQW;
623623   }
624624
r9922r9923
649649
650650   /* optimization if none of the values are nodes */
651651   context->has_rc_nodes = 0;
652   if (node->input_is_node & DSD_555_MSTBL_RC_MASK)
652   if (node->input_is_node() & DSD_555_MSTBL_RC_MASK)
653653      context->has_rc_nodes = 1;
654654   else
655655      context->exp_charge = RC_CHARGE_EXP(DSD_555_MSTBL__R * DSD_555_MSTBL__C);
r9922r9923
10471047
10481048   /* optimization if none of the values are nodes */
10491049   context->has_rc_nodes = 0;
1050   if (node->input_is_node & DSD_555_CC_RC_MASK)
1050   if (node->input_is_node() & DSD_555_CC_RC_MASK)
10511051      context->has_rc_nodes = 1;
10521052   else
10531053   {
r9922r9923
14331433
14341434   /* There is no charge on the cap so the 555 goes high at init. */
14351435   context->flip_flop     = 1;
1436   context->ctrlv_is_node = (node->input_is_node >> 2) & 1;
1436   context->ctrlv_is_node = (node->input_is_node() >> 2) & 1;
14371437   context->v_out_high    = (info->v_out_high == DEFAULT_555_HIGH) ? info->v_pos - 1.2 : info->v_out_high;
14381438
14391439   /* Calculate 555 thresholds.
r9922r9923
16681668   context->fake_ac =  (int)DSD_566__OPTIONS & DISC_566_OUT_AC;
16691669
16701670   if (DSD_566__VNEG >= DSD_566__VPOS)
1671      fatalerror("[v_neg >= v_pos] in NODE_%d!\n", NODE_BLOCKINDEX(node));
1671      fatalerror("[v_neg >= v_pos] in NODE_%d!\n", node->index());
16721672
16731673   v_float = DSD_566__VPOS - DSD_566__VNEG;
16741674   v_int = (int)v_float;
16751675   if ( v_float < 10 || v_float > 15 )
1676      fatalerror("v_neg and/or v_pos out of range in NODE_%d\n", NODE_BLOCKINDEX(node));
1676      fatalerror("v_neg and/or v_pos out of range in NODE_%d\n", node->index());
16771677   if ( v_float != v_int )
16781678      /* fatal for now. */
1679      fatalerror("Power should be integer in NODE_%d\n", NODE_BLOCKINDEX(node));
1679      fatalerror("Power should be integer in NODE_%d\n", node->index());
16801680
16811681   context->flip_flop   = 0;
16821682   context->cap_voltage = 0;
src/emu/sound/disc_wav.c
r9922r9923
322322
323323
324324   if (!context->is_7492 && (DSS_COUNTER__MAX < DSS_COUNTER__MIN))
325      fatalerror("MAX < MIN in NODE_%02d", NODE_INDEX(node->block->node));
325      fatalerror("MAX < MIN in NODE_%02d", node->index());
326326
327327   context->out_type    = context->clock_type & DISC_OUT_MASK;
328328   context->clock_type &= DISC_CLK_MASK;
r9922r9923
532532   context->out_lfsr_reg = (info->flags & DISC_LFSR_FLAG_OUTPUT_SR_SN1) ? 1 : 0;
533533
534534   if ((info->clock_type < DISC_CLK_ON_F_EDGE) || (info->clock_type > DISC_CLK_IS_FREQ))
535      discrete_log(node->info, "Invalid clock type passed in NODE_%d\n", NODE_BLOCKINDEX(node));
535      discrete_log(node->info, "Invalid clock type passed in NODE_%d\n", node->index());
536536
537537   context->last = (DSS_COUNTER__CLOCK != 0);
538538   if (info->clock_type == DISC_CLK_IS_FREQ) context->t_clock = 1.0 / DSS_LFSR_NOISE__CLOCK;
r9922r9923
16981698#define DSS_INVERTER_OSC__C         DISCRETE_INPUT(4)
16991699#define DSS_INVERTER_OSC__R2      DISCRETE_INPUT(5)
17001700
1701INLINE double dss_inverter_tftab(const node_description *node, double x)
1701INLINE double dss_inverter_tftab(node_description *node, double x)
17021702{
17031703   DISCRETE_DECLARE_CONTEXT(dss_inverter_osc)
17041704   DISCRETE_DECLARE_INFO(discrete_inverter_osc_desc)
r9922r9923
17101710      return info->vB;
17111711}
17121712
1713INLINE double dss_inverter_tf(const node_description *node, double x)
1713INLINE double dss_inverter_tf(node_description *node, double x)
17141714{
17151715   DISCRETE_DECLARE_CONTEXT(dss_inverter_osc)
17161716   DISCRETE_DECLARE_INFO(discrete_inverter_osc_desc)
r9922r9923
17601760         vG2 = dss_inverter_tf(node,vG3);
17611761         break;
17621762      default:
1763         fatalerror("DISCRETE_INVERTER_OSC - Wrong type on NODE_%02d", NODE_BLOCKINDEX(node));
1763         fatalerror("DISCRETE_INVERTER_OSC - Wrong type on NODE_%02d", node->index());
17641764   }
17651765
17661766   clamped = 0;
r9922r9923
18261826         diff = diff - diff * exp(-node->info->sample_time/(context->c * rMix));
18271827         break;
18281828      default:
1829         fatalerror("DISCRETE_INVERTER_OSC - Wrong type on NODE_%02d", NODE_BLOCKINDEX(node));
1829         fatalerror("DISCRETE_INVERTER_OSC - Wrong type on NODE_%02d", node->index());
18301830   }
18311831   context->v_cap   += diff;
18321832   context->v_g2_old = vG2;
src/emu/sound/disc_flt.c
r9922r9923
179179{
180180   DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
181181
182   context->has_rc_nodes = node->input_is_node & 0x6;
182   context->has_rc_nodes = node->input_is_node() & 0x6;
183183   context->rc = DST_CRFILTER__R * DST_CRFILTER__C;
184184   context->exponent = RC_CHARGE_EXP(context->rc);
185185   context->vCap = 0;
r9922r9923
872872   /* some error checking. */
873873   if (DST_RCDISC4__R1 <= 0 || DST_RCDISC4__R2 <= 0 || DST_RCDISC4__C1 <= 0 || (DST_RCDISC4__R3 <= 0 &&  context->type == 1))
874874   {
875      discrete_log(node->info, "Invalid component values in NODE_%d.\n", NODE_BLOCKINDEX(node));
875      discrete_log(node->info, "Invalid component values in NODE_%d.\n", node->index());
876876      return;
877877   }
878878   if (DST_RCDISC4__VP < 3)
879879   {
880      discrete_log(node->info, "vP must be >= 3V in NODE_%d.\n", NODE_BLOCKINDEX(node));
880      discrete_log(node->info, "vP must be >= 3V in NODE_%d.\n", node->index());
881881      return;
882882   }
883883   if (DST_RCDISC4__TYPE < 1 || DST_RCDISC4__TYPE > 3)
884884   {
885      discrete_log(node->info, "Invalid circuit type in NODE_%d.\n", NODE_BLOCKINDEX(node));
885      discrete_log(node->info, "Invalid circuit type in NODE_%d.\n", node->index());
886886      return;
887887   }
888888
r9922r9923
11381138{
11391139   DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
11401140
1141   context->has_rc_nodes = node->input_is_node & 0x6;
1141   context->has_rc_nodes = node->input_is_node() & 0x6;
11421142   context->rc = DST_RCFILTER__R * DST_RCFILTER__C;
11431143   context->exponent = RC_CHARGE_EXP(context->rc);
11441144   context->vCap   = 0;
src/emu/info.c
r9922r9923
1010***************************************************************************/
1111
1212#include "emu.h"
13#include "machine/ram.h"
1314#include "sound/samples.h"
1415#include "info.h"
1516#include "xmlfile.h"
r9922r9923
990991   }
991992}
992993
994/* device iteration helpers */
995#define ram_first(config)            (config).m_devicelist.first(RAM)
996#define ram_next(previous)            ((previous)->typenext())
997
993998/*-------------------------------------------------
999    print_game_ramoptions - prints out all RAM
1000    options for this system
1001-------------------------------------------------*/
1002static void print_game_ramoptions(FILE *out, const game_driver *game, const machine_config &config)
1003{
1004   const device_config *device;
1005
1006   for (device = ram_first(config); device != NULL; device = ram_next(device))
1007   {
1008      ram_config *ram = (ram_config *)downcast<const legacy_device_config_base *>(device)->inline_config();
1009      fprintf(out, "\t\t<ramoption default=\"1\">%u</ramoption>\n",  ram_parse_string(ram->default_size));
1010      if (ram->extra_options != NULL)
1011      {
1012         int j;
1013         int size = strlen(ram->extra_options);
1014         char * const s = mame_strdup(ram->extra_options);
1015         char * const e = s + size;
1016         char *p = s;
1017         for (j=0;j<size;j++) {
1018            if (p[j]==',') p[j]=0;
1019         }
1020         /* try to parse each option */
1021         while(p <= e)
1022         {
1023            fprintf(out, "\t\t<ramoption>%u</ramoption>\n",  ram_parse_string(p));
1024            p += strlen(p);
1025            if (p == e)
1026               break;
1027            p += 1;
1028         }
1029
1030         osd_free(s);
1031      }
1032   }
1033}
1034
1035/*-------------------------------------------------
9941036    print_game_info - print the XML information
9951037    for one particular game driver
9961038-------------------------------------------------*/
r9922r9923
10261068      fprintf(out, " isbios=\"yes\"");
10271069   if (game->flags & GAME_NO_STANDALONE)
10281070      fprintf(out, " runnable=\"no\"");
1071   if (game->flags & GAME_MECHANICAL)
1072      fprintf(out, " ismechanical=\"yes\"");
10291073
10301074   /* display clone information */
10311075   clone_of = driver_get_clone(game);
r9922r9923
10641108   print_game_adjusters(out, game, portlist);
10651109   print_game_driver(out, game, config);
10661110   print_game_images( out, game, config );
1067   print_game_software_list( out, game, config );
1068#ifdef MESS
1069   print_mess_game_xml(out, game, config);
1070#endif /* MESS */
1071
1111   print_game_software_list( out, game, config );   
1112   print_game_ramoptions( out, game, config );
10721113   /* close the topmost tag */
10731114   fprintf(out, "\t</" XML_TOP ">\n");
10741115}
r9922r9923
10901131      "\t<!ATTLIST " XML_ROOT " build CDATA #IMPLIED>\n"
10911132      "\t<!ATTLIST " XML_ROOT " debug (yes|no) \"no\">\n"
10921133      "\t<!ATTLIST " XML_ROOT " mameconfig CDATA #REQUIRED>\n"
1093#ifdef MESS
10941134      "\t<!ELEMENT " XML_TOP " (description, year?, manufacturer, biosset*, rom*, disk*, sample*, chip*, display*, sound?, input?, dipswitch*, configuration*, category*, adjuster*, driver?, device*, ramoption*, softwarelist*)>\n"
1095#else
1096      "\t<!ELEMENT " XML_TOP " (description, year?, manufacturer, biosset*, rom*, disk*, sample*, chip*, display*, sound?, input?, dipswitch*, configuration*, category*, adjuster*, driver?, device*, softwarelist*)>\n"
1097#endif
10981135      "\t\t<!ATTLIST " XML_TOP " name CDATA #REQUIRED>\n"
10991136      "\t\t<!ATTLIST " XML_TOP " sourcefile CDATA #IMPLIED>\n"
11001137      "\t\t<!ATTLIST " XML_TOP " isbios (yes|no) \"no\">\n"
1138      "\t\t<!ATTLIST " XML_TOP " ismechanical (yes|no) \"no\">\n"
11011139      "\t\t<!ATTLIST " XML_TOP " runnable (yes|no) \"yes\">\n"
11021140      "\t\t<!ATTLIST " XML_TOP " cloneof CDATA #IMPLIED>\n"
11031141      "\t\t<!ATTLIST " XML_TOP " romof CDATA #IMPLIED>\n"
r9922r9923
12131251      "\t\t<!ELEMENT softwarelist EMPTY>\n"
12141252      "\t\t\t<!ATTLIST softwarelist name CDATA #REQUIRED>\n"
12151253      "\t\t\t<!ATTLIST softwarelist status (original|compatible) #REQUIRED>\n"
1216#ifdef MESS
12171254      "\t\t<!ELEMENT ramoption (#PCDATA)>\n"
12181255      "\t\t\t<!ATTLIST ramoption default CDATA #IMPLIED>\n"
1219#endif
12201256      "]>\n\n"
12211257      "<" XML_ROOT " build=\"%s\" debug=\""
12221258#ifdef MAME_DEBUG
src/emu/emu.mak
r9922r9923
188188   $(EMUMACHINE)/pic8259.o \
189189   $(EMUMACHINE)/pit8253.o \
190190   $(EMUMACHINE)/pd4990a.o \
191   $(EMUMACHINE)/ram.o \
191192   $(EMUMACHINE)/roc10937.o \
192193   $(EMUMACHINE)/rp5h01.o \
193194   $(EMUMACHINE)/rtc65271.o \
src/emu/machine/ram.c
r0r9923
1/*************************************************************************
2
3    RAM device
4
5    Provides a configurable amount of RAM to drivers
6
7**************************************************************************/
8
9#include <stdio.h>
10#include <ctype.h>
11
12#include "emu.h"
13#include "emuopts.h"
14#include "ram.h"
15
16
17/***************************************************************************
18    CONSTANTS
19***************************************************************************/
20
21#define RAM_STRING_BUFLEN   16
22#define MAX_RAM_OPTIONS      16
23
24
25/***************************************************************************
26    TYPE DEFINITIONS
27***************************************************************************/
28
29typedef struct _ram_state ram_state;
30struct _ram_state
31{
32   UINT32 size; /* total amount of ram configured */
33   UINT8 *ram;  /* pointer to the start of ram */
34};
35
36
37/*****************************************************************************
38    INLINE FUNCTIONS
39*****************************************************************************/
40
41INLINE ram_state *get_safe_token(device_t *device)
42{
43   assert(device != NULL);
44   assert(device->type() == RAM);
45
46   return (ram_state *)downcast<legacy_device_base *>(device)->token();
47}
48
49
50/*****************************************************************************
51    HELPER FUNCTIONS
52*****************************************************************************/
53
54/*-------------------------------------------------
55    ram_parse_string - convert a ram string to an
56    integer value
57-------------------------------------------------*/
58
59UINT32 ram_parse_string(const char *s)
60{
61   UINT32 ram;
62   char suffix = '\0';
63
64   s += sscanf(s, "%u%c", &ram, &suffix);
65
66   switch(tolower(suffix))
67   {
68   case 'k':
69      /* kilobytes */
70      ram *= 1024;
71      break;
72
73   case 'm':
74      /* megabytes */
75      ram *= 1024*1024;
76      break;
77
78   case '\0':
79      /* no suffix */
80      break;
81
82   default:
83      /* parse failure */
84      ram = 0;
85      break;
86   }
87
88   return ram;
89}
90
91/*****************************************************************************
92    DEVICE INTERFACE
93*****************************************************************************/
94
95static DEVICE_START( ram )
96{
97   ram_state *ram = get_safe_token(device);
98   ram_config *config = (ram_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config();
99
100   /* the device named 'ram' can get ram options from command line */
101   if (strcmp(device->tag(), RAM_TAG) == 0)
102   {
103      const char *ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
104
105      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
106         ram->size = ram_parse_string(ramsize_string);
107   }
108
109   /* if we didn't get a size yet, use the default */
110   if (ram->size == 0)
111      ram->size = ram_parse_string(config->default_size);
112
113   /* allocate space for the ram */
114   ram->ram = auto_alloc_array(device->machine, UINT8, ram->size);
115
116   /* reset ram to the default value */
117   memset(ram->ram, config->default_value, ram->size);
118
119   /* register for state saving */
120   state_save_register_device_item(device, 0, ram->size);
121   state_save_register_device_item_pointer(device, 0, ram->ram, ram->size);
122}
123
124static DEVICE_VALIDITY_CHECK( ram )
125{
126   ram_config *config = (ram_config *)downcast<const legacy_device_config_base *>(device)->inline_config();
127   const char *ramsize_string = NULL;
128   int is_valid = FALSE;
129   UINT32 specified_ram = 0;
130   int error = FALSE;
131   const char *gamename_option = NULL;
132
133   /* verify default ram value */
134   if (config!=NULL && ram_parse_string(config->default_size) == 0)
135   {
136      mame_printf_error("%s: '%s' has an invalid default RAM option: %s\n", driver->source_file, driver->name, config->default_size);
137      error = TRUE;
138   }
139
140   /* command line options are only parsed for the device named RAM_TAG */
141   if (device->tag()!=NULL && strcmp(device->tag(), RAM_TAG) == 0)
142   {
143      if (mame_options()==NULL) return FALSE;
144      /* verify command line ram option */
145      ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
146      gamename_option = options_get_string(mame_options(), OPTION_GAMENAME);
147
148      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
149      {
150         specified_ram = ram_parse_string(ramsize_string);
151
152         if (specified_ram == 0)
153         {
154            mame_printf_error("%s: '%s' cannot recognize the RAM option %s\n", driver->source_file, driver->name, ramsize_string);
155            error = TRUE;
156         }
157         if (gamename_option != NULL && *gamename_option != 0 && strcmp(gamename_option, driver->name) == 0)
158         {
159            /* compare command line option to default value */
160            if (ram_parse_string(config->default_size) == specified_ram)
161               is_valid = TRUE;
162
163            /* verify extra ram options */
164            if (config->extra_options != NULL)
165            {
166               int j;
167               int size = strlen(config->extra_options);
168               char * const s = mame_strdup(config->extra_options);
169               char * const e = s + size;
170               char *p = s;
171               for (j=0;j<size;j++) {
172                  if (p[j]==',') p[j]=0;
173               }
174
175               /* try to parse each option */
176               while(p <= e)
177               {
178                  UINT32 option_ram_size = ram_parse_string(p);
179
180                  if (option_ram_size == 0)
181                  {
182                     mame_printf_error("%s: '%s' has an invalid RAM option: %s\n", driver->source_file, driver->name, p);
183                     error = TRUE;
184                  }
185
186                  if (option_ram_size == specified_ram)
187                     is_valid = TRUE;
188
189                  p += strlen(p);
190                  if (p == e)
191                     break;
192                  p += 1;
193               }
194
195               osd_free(s);
196            }
197
198         } else {
199            /* if not for this driver then return ok */
200            is_valid = TRUE;
201         }
202      }
203      else
204      {
205         /* not specifying the ramsize on the command line is valid as well */
206         is_valid = TRUE;
207      }
208   }
209   else
210      is_valid = TRUE;
211
212   if (!is_valid)
213   {
214      mame_printf_error("%s: '%s' cannot recognize the RAM option %s", driver->source_file, driver->name, ramsize_string);
215      mame_printf_error(" (valid options are %s", config->default_size);
216
217      if (config->extra_options != NULL)
218         mame_printf_error(",%s).\n", config->extra_options);
219      else
220         mame_printf_error(").\n");
221
222      error = TRUE;
223   }
224
225   return error;
226
227}
228
229
230DEVICE_GET_INFO( ram )
231{
232   switch (state)
233   {
234      /* --- the following bits of info are returned as 64-bit signed integers --- */
235      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(ram_state);         break;
236      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(ram_config);            break;
237
238      /* --- the following bits of info are returned as pointers to data or functions --- */
239      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(ram);   break;
240      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
241      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
242      case DEVINFO_FCT_VALIDITY_CHECK:            info->p = (void*)DEVICE_VALIDITY_CHECK_NAME(ram); break;
243
244      /* --- the following bits of info are returned as NULL-terminated strings --- */
245      case DEVINFO_STR_NAME:                     strcpy(info->s, "RAM");            break;
246      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RAM");                  break;
247      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.00");               break;
248      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
249      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
250   }
251}
252
253/***************************************************************************
254    IMPLEMENTATION
255***************************************************************************/
256
257UINT32 ram_get_size(device_t *device)
258{
259   ram_state *ram = get_safe_token(device);
260   return ram->size;
261}
262
263UINT8 *ram_get_ptr(device_t *device)
264{
265   ram_state *ram = get_safe_token(device);
266   return ram->ram;
267}
268
269DEFINE_LEGACY_DEVICE(RAM, ram);
src/emu/machine/ram.h
r0r9923
1/*************************************************************************
2
3    RAM device
4
5    Provides a configurable amount of RAM to drivers
6
7**************************************************************************/
8
9#ifndef __RAM_H__
10#define __RAM_H__
11
12
13/***************************************************************************
14    CONSTANTS
15***************************************************************************/
16
17#define RAM_DEFAULT_VALUE   0xcd
18#define RAM_TAG            "ram"
19
20/***************************************************************************
21    TYPE DEFINITIONS
22***************************************************************************/
23
24typedef struct _ram_config ram_config;
25struct _ram_config
26{
27   const char *default_size;
28   const char *extra_options;
29   UINT8 default_value;
30};
31
32
33/***************************************************************************
34    DEVICE CONFIGURATION MACROS
35***************************************************************************/
36
37DECLARE_LEGACY_DEVICE(RAM, ram);
38
39#define MCFG_RAM_ADD(_tag) \
40   MCFG_DEVICE_ADD(_tag, RAM, 0) \
41   MCFG_DEVICE_CONFIG_DATA32(ram_config, default_value, RAM_DEFAULT_VALUE)
42
43#define MCFG_RAM_REMOVE(_tag) \
44   MCFG_DEVICE_REMOVE(_tag)
45
46#define MCFG_RAM_MODIFY(_tag) \
47   MCFG_DEVICE_MODIFY(_tag)   \
48   MCFG_DEVICE_CONFIG_DATAPTR(ram_config, extra_options, NULL)
49
50#define MCFG_RAM_DEFAULT_SIZE(_default_size) \
51   MCFG_DEVICE_CONFIG_DATAPTR(ram_config, default_size, _default_size)
52
53#define MCFG_RAM_EXTRA_OPTIONS(_extra_options) \
54   MCFG_DEVICE_CONFIG_DATAPTR(ram_config, extra_options, _extra_options)
55
56#define MCFG_RAM_DEFAULT_VALUE(_default_value) \
57   MCFG_DEVICE_CONFIG_DATA32(ram_config, default_value, _default_value)
58
59
60/***************************************************************************
61    FUNCTION PROTOTYPES
62***************************************************************************/
63
64UINT32 ram_get_size(device_t *device);
65UINT8 *ram_get_ptr(device_t *device);
66UINT32 ram_parse_string(const char *s);
67
68#endif /* __RAM_H__ */
src/emu/driver.h
r9922r9923
115115   &LAYOUT[0]                        \
116116};
117117
118#define CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
119extern const game_driver GAME_NAME(NAME) =   \
120{                                 \
121   __FILE__,                        \
122   #PARENT,                        \
123   #NAME,                           \
124   FULLNAME,                        \
125   #YEAR,                           \
126   COMPANY,                        \
127   MACHINE_CONFIG_NAME(MACHINE),         \
128   INPUT_PORTS_NAME(INPUT),            \
129   DRIVER_INIT_NAME(INIT),               \
130   ROM_NAME(NAME),                     \
131   #COMPAT,                        \
132   ROT0|(FLAGS),                     \
133   NULL                           \
134};
118135
136#define COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
137extern const game_driver GAME_NAME(NAME) =   \
138{                                 \
139   __FILE__,                        \
140   #PARENT,                        \
141   #NAME,                           \
142   FULLNAME,                        \
143   #YEAR,                           \
144   COMPANY,                        \
145   MACHINE_CONFIG_NAME(MACHINE),         \
146   INPUT_PORTS_NAME(INPUT),            \
147   DRIVER_INIT_NAME(INIT),               \
148   ROM_NAME(NAME),                     \
149   #COMPAT,                        \
150   ROT0|(FLAGS),            \
151   NULL                           \
152};
119153
120154/***************************************************************************
121155    GLOBAL VARIABLES
src/mess/devices/messram.c
r9922r9923
1/*************************************************************************
2
3    MESS RAM device
4
5    Provides a configurable amount of RAM to drivers
6
7**************************************************************************/
8
9#include <stdio.h>
10#include <ctype.h>
11
12#include "emu.h"
13#include "emuopts.h"
14#include "messram.h"
15
16
17/***************************************************************************
18    CONSTANTS
19***************************************************************************/
20
21#define RAM_STRING_BUFLEN   16
22#define MAX_RAM_OPTIONS      16
23
24
25/***************************************************************************
26    TYPE DEFINITIONS
27***************************************************************************/
28
29typedef struct _messram_state messram_state;
30struct _messram_state
31{
32   UINT32 size; /* total amount of ram configured */
33   UINT8 *ram;  /* pointer to the start of ram */
34};
35
36
37/*****************************************************************************
38    INLINE FUNCTIONS
39*****************************************************************************/
40
41INLINE messram_state *get_safe_token(device_t *device)
42{
43   assert(device != NULL);
44   assert(device->type() == MESSRAM);
45
46   return (messram_state *)downcast<legacy_device_base *>(device)->token();
47}
48
49
50/*****************************************************************************
51    HELPER FUNCTIONS
52*****************************************************************************/
53
54/*-------------------------------------------------
55    messram_parse_string - convert a ram string to an
56    integer value
57-------------------------------------------------*/
58
59UINT32 messram_parse_string(const char *s)
60{
61   UINT32 ram;
62   char suffix = '\0';
63
64   s += sscanf(s, "%u%c", &ram, &suffix);
65
66   switch(tolower(suffix))
67   {
68   case 'k':
69      /* kilobytes */
70      ram *= 1024;
71      break;
72
73   case 'm':
74      /* megabytes */
75      ram *= 1024*1024;
76      break;
77
78   case '\0':
79      /* no suffix */
80      break;
81
82   default:
83      /* parse failure */
84      ram = 0;
85      break;
86   }
87
88   return ram;
89}
90
91#ifdef UNUSED_FUNCTION
92const char *messram_string(char *buffer, UINT32 ram)
93{
94   const char *suffix;
95
96   if ((ram % (1024*1024)) == 0)
97   {
98      ram /= 1024*1024;
99      suffix = "m";
100   }
101   else if ((ram % 1024) == 0)
102   {
103      ram /= 1024;
104      suffix = "k";
105   }
106   else
107   {
108      suffix = "";
109   }
110   sprintf(buffer, "%u%s", ram, suffix);
111   return buffer;
112}
113#endif
114
115
116/*****************************************************************************
117    DEVICE INTERFACE
118*****************************************************************************/
119
120static DEVICE_START( messram )
121{
122   messram_state *messram = get_safe_token(device);
123   ram_config *config = (ram_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config();
124
125   /* the device named 'messram' can get ram options from command line */
126   if (strcmp(device->tag(), "messram") == 0)
127   {
128      const char *ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
129
130      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
131         messram->size = messram_parse_string(ramsize_string);
132   }
133
134   /* if we didn't get a size yet, use the default */
135   if (messram->size == 0)
136      messram->size = messram_parse_string(config->default_size);
137
138   /* allocate space for the ram */
139   messram->ram = auto_alloc_array(device->machine, UINT8, messram->size);
140
141   /* reset ram to the default value */
142   memset(messram->ram, config->default_value, messram->size);
143
144   /* register for state saving */
145   state_save_register_device_item(device, 0, messram->size);
146   state_save_register_device_item_pointer(device, 0, messram->ram, messram->size);
147}
148
149static DEVICE_VALIDITY_CHECK( messram )
150{
151   ram_config *config = (ram_config *)downcast<const legacy_device_config_base *>(device)->inline_config();
152   const char *ramsize_string = NULL;
153   int is_valid = FALSE;
154   UINT32 specified_ram = 0;
155   int error = FALSE;
156   const char *gamename_option = NULL;
157
158   /* verify default ram value */
159   if (config!=NULL && messram_parse_string(config->default_size) == 0)
160   {
161      mame_printf_error("%s: '%s' has an invalid default RAM option: %s\n", driver->source_file, driver->name, config->default_size);
162      error = TRUE;
163   }
164
165   /* command line options are only parsed for the device named "messram" */
166   if (device->tag()!=NULL && strcmp(device->tag(), "messram") == 0)
167   {
168      if (mame_options()==NULL) return FALSE;
169      /* verify command line ram option */
170      ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
171      gamename_option = options_get_string(mame_options(), OPTION_GAMENAME);
172
173      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
174      {
175         specified_ram = messram_parse_string(ramsize_string);
176
177         if (specified_ram == 0)
178         {
179            mame_printf_error("%s: '%s' cannot recognize the RAM option %s\n", driver->source_file, driver->name, ramsize_string);
180            error = TRUE;
181         }
182         if (gamename_option != NULL && *gamename_option != 0 && strcmp(gamename_option, driver->name) == 0)
183         {
184            /* compare command line option to default value */
185            if (messram_parse_string(config->default_size) == specified_ram)
186               is_valid = TRUE;
187
188            /* verify extra ram options */
189            if (config->extra_options != NULL)
190            {
191               int j;
192               int size = strlen(config->extra_options);
193               char * const s = mame_strdup(config->extra_options);
194               char * const e = s + size;
195               char *p = s;
196               for (j=0;j<size;j++) {
197                  if (p[j]==',') p[j]=0;
198               }
199
200               /* try to parse each option */
201               while(p <= e)
202               {
203                  UINT32 option_ram_size = messram_parse_string(p);
204
205                  if (option_ram_size == 0)
206                  {
207                     mame_printf_error("%s: '%s' has an invalid RAM option: %s\n", driver->source_file, driver->name, p);
208                     error = TRUE;
209                  }
210
211                  if (option_ram_size == specified_ram)
212                     is_valid = TRUE;
213
214                  p += strlen(p);
215                  if (p == e)
216                     break;
217                  p += 1;
218               }
219
220               osd_free(s);
221            }
222
223         } else {
224            /* if not for this driver then return ok */
225            is_valid = TRUE;
226         }
227      }
228      else
229      {
230         /* not specifying the ramsize on the command line is valid as well */
231         is_valid = TRUE;
232      }
233   }
234   else
235      is_valid = TRUE;
236
237   if (!is_valid)
238   {
239      mame_printf_error("%s: '%s' cannot recognize the RAM option %s", driver->source_file, driver->name, ramsize_string);
240      mame_printf_error(" (valid options are %s", config->default_size);
241
242      if (config->extra_options != NULL)
243         mame_printf_error(",%s).\n", config->extra_options);
244      else
245         mame_printf_error(").\n");
246
247      error = TRUE;
248   }
249
250   return error;
251
252}
253
254
255DEVICE_GET_INFO( messram )
256{
257   switch (state)
258   {
259      /* --- the following bits of info are returned as 64-bit signed integers --- */
260      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(messram_state);         break;
261      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(ram_config);            break;
262
263      /* --- the following bits of info are returned as pointers to data or functions --- */
264      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(messram);   break;
265      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
266      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
267      case DEVINFO_FCT_VALIDITY_CHECK:            info->p = (void*)DEVICE_VALIDITY_CHECK_NAME(messram); break;
268
269      /* --- the following bits of info are returned as NULL-terminated strings --- */
270      case DEVINFO_STR_NAME:                     strcpy(info->s, "MESS RAM");            break;
271      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RAM");                  break;
272      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.00");               break;
273      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
274      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
275   }
276}
277
278
279/***************************************************************************
280    IMPLEMENTATION
281***************************************************************************/
282
283UINT32 messram_get_size(device_t *device)
284{
285   messram_state *messram = get_safe_token(device);
286   return messram->size;
287}
288
289
290UINT8 *messram_get_ptr(device_t *device)
291{
292   messram_state *messram = get_safe_token(device);
293   return messram->ram;
294}
295
296
297#ifdef UNUSED_FUNCTION
298void messram_dump(device_t *device, const char *filename)
299{
300   messram_state *messram = get_safe_token(device);
301   file_error filerr;
302   mame_file *file;
303
304   /* use a default filename */
305   if (!filename)
306      filename = "ram.bin";
307
308   /* open the file */
309   filerr = mame_fopen(NULL, filename, OPEN_FLAG_WRITE, &file);
310   if (filerr == FILERR_NONE)
311   {
312      /* write the data */
313      mame_fwrite(file, messram->ram, messram->size);
314
315      /* close file */
316      mame_fclose(file);
317   }
318}
319#endif
320
321DEFINE_LEGACY_DEVICE(MESSRAM, messram);
src/mess/devices/messram.h
r9922r9923
1/*************************************************************************
2
3    MESS RAM device
4
5    Provides a configurable amount of RAM to drivers
6
7**************************************************************************/
8
9#ifndef __MESSRAM_H__
10#define __MESSRAM_H__
11
12
13/***************************************************************************
14    CONSTANTS
15***************************************************************************/
16
17#define RAM_DEFAULT_VALUE   0xcd
18
19
20/***************************************************************************
21    TYPE DEFINITIONS
22***************************************************************************/
23
24typedef struct _ram_config ram_config;
25struct _ram_config
26{
27   const char *default_size;
28   const char *extra_options;
29   UINT8 default_value;
30};
31
32
33/***************************************************************************
34    DEVICE CONFIGURATION MACROS
35***************************************************************************/
36
37DECLARE_LEGACY_DEVICE(MESSRAM, messram);
38
39#define MCFG_RAM_ADD(_tag) \
40   MCFG_DEVICE_ADD(_tag, MESSRAM, 0) \
41   MCFG_DEVICE_CONFIG_DATA32(ram_config, default_value, RAM_DEFAULT_VALUE)
42
43#define MCFG_RAM_REMOVE(_tag) \
44   MCFG_DEVICE_REMOVE(_tag)
45
46#define MCFG_RAM_MODIFY(_tag) \
47   MCFG_DEVICE_MODIFY(_tag)   \
48   MCFG_DEVICE_CONFIG_DATAPTR(ram_config, extra_options, NULL)
49
50#define MCFG_RAM_DEFAULT_SIZE(_default_size) \
51   MCFG_DEVICE_CONFIG_DATAPTR(ram_config, default_size, _default_size)
52
53#define MCFG_RAM_EXTRA_OPTIONS(_extra_options) \
54   MCFG_DEVICE_CONFIG_DATAPTR(ram_config, extra_options, _extra_options)
55
56#define MCFG_RAM_DEFAULT_VALUE(_default_value) \
57   MCFG_DEVICE_CONFIG_DATA32(ram_config, default_value, _default_value)
58
59
60/***************************************************************************
61    FUNCTION PROTOTYPES
62***************************************************************************/
63
64UINT32 messram_get_size(device_t *device);
65UINT8 *messram_get_ptr(device_t *device);
66#ifdef UNUSED_FUNCTION
67void messram_dump(device_t *device, const char *filename);
68const char *messram_string(char *buffer, UINT32 ram);
69#endif
70UINT32 messram_parse_string(const char *s);
71
72#endif /* __MESSRAM_H__ */
src/mess/devices/coco_vhd.c
r9922r9923
3939#include "emu.h"
4040#include "coco_vhd.h"
4141#include "includes/coco.h"
42#include "devices/messram.h"
42#include "machine/ram.h"
4343
4444
4545/***************************************************************************
r9922r9923
164164   switch(data)
165165   {
166166      case VHDCMD_READ: /* Read sector */
167         memset(&messram_get_ptr(device->machine->device("messram"))[phyOffset], 0, 256);
167         memset(&ram_get_ptr(device->machine->device(RAM_TAG))[phyOffset], 0, 256);
168168         if (total_size > seek_position)
169169         {
170170            bytes_to_read = (UINT32) MIN((UINT64) 256, total_size - seek_position);
171            result = image->fread(&messram_get_ptr(device->machine->device("messram"))[phyOffset], bytes_to_read);
171            result = image->fread(&ram_get_ptr(device->machine->device(RAM_TAG))[phyOffset], bytes_to_read);
172172            if (result != bytes_to_read)
173173            {
174174               vhd->status = VHDSTATUS_ACCESS_DENIED;
r9922r9923
180180         break;
181181
182182      case VHDCMD_WRITE: /* Write Sector */
183         result = image->fwrite(&(messram_get_ptr(device->machine->device("messram"))[phyOffset]), 256);
183         result = image->fwrite(&(ram_get_ptr(device->machine->device(RAM_TAG))[phyOffset]), 256);
184184
185185         if (result != 256)
186186         {
src/mess/devices/multcart.c
r9922r9923
1313#include "xmlfile.h"
1414#include "emu.h"
1515#include "hash.h"
16#include "messram.h"
16#include "machine/ram.h"
1717
1818/***************************************************************************
1919    TYPE DEFINITIONS
r9922r9923
227227      return MCERR_MISSING_RAM_LENGTH;
228228
229229   /* ...and parse it */
230   resource->length = messram_parse_string(length_string);
230   resource->length = ram_parse_string(length_string);
231231   if (resource->length <= 0)
232232      return MCERR_INVALID_RAM_SPEC;
233233
src/mess/osd/winui/optionsms.c
r9922r9923
4646
4747void MessSetupGameOptions(core_options *opts, int driver_index)
4848{
49   BOOL is_global = (driver_index == OPTIONS_TYPE_GLOBAL);
50   AddOptions(opts, mess_core_options, is_global);
51
5249   if (driver_index >= 0)
5350   {
5451      image_add_device_options(opts, drivers[driver_index]);
src/mess/osd/winui/propertiesms.c
r9922r9923
1515#include <tchar.h>
1616
1717#include "emu.h"
18#include "emuopts.h"
1819#include "image.h"
1920#include "screenshot.h"
2021#include "datamap.h"
r9922r9923
2425#include "mui_util.h"
2526#include "mui_opts.h"
2627#include "resourcems.h"
27#include "mess.h"
2828#include "propertiesms.h"
2929#include "optionsms.h"
3030#include "msuiutil.h"
3131#include "strconv.h"
3232#include "winutf8.h"
33#include "devices/messram.h"
33#include "machine/ram.h"
3434
3535static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR lpItem);
3636static BOOL SoftwareDirectories_OnDelete(HWND hDlg);
r9922r9923
210210
211211BOOL PropSheetFilter_Config(const machine_config *drv, const game_driver *gamedrv)
212212{
213   return (drv->m_devicelist.first(MESSRAM)!=NULL) || DriverHasDevice(gamedrv, IO_PRINTER);
213   return (drv->m_devicelist.first(RAM)!=NULL) || DriverHasDevice(gamedrv, IO_PRINTER);
214214}
215215
216216
r9922r9923
405405   machine_config cfg(*gamedrv);
406406
407407   // identify how many options that we have
408   device = cfg.m_devicelist.first(MESSRAM);
408   device = cfg.m_devicelist.first(RAM);
409409
410410   EnableWindow(control, (device != NULL));
411411   i = 0;
r9922r9923
416416
417417      // identify the current amount of RAM
418418      this_ram_string = options_get_string(opts, OPTION_RAMSIZE);
419      current_ram = (this_ram_string != NULL) ? messram_parse_string(this_ram_string) : 0;
419      current_ram = (this_ram_string != NULL) ? ram_parse_string(this_ram_string) : 0;
420420      if (current_ram == 0)
421         current_ram = messram_parse_string(config->default_size);
421         current_ram = ram_parse_string(config->default_size);
422422
423423      // by default, assume index 0
424424      current_index = 0;
425425
426426      {
427         ram = messram_parse_string(config->default_size);
427         ram = ram_parse_string(config->default_size);
428428         t_ramstring = tstring_from_utf8(config->default_size);
429429         if( !t_ramstring )
430430            return FALSE;
r9922r9923
450450         {
451451            i++;
452452            // identify this option
453            ram = messram_parse_string(p);
453            ram = ram_parse_string(p);
454454
455455            this_ram_string = p;
456456
src/mess/mess.c
r9922r9923
1212#include "lcd.lh"
1313#include "lcd_rot.lh"
1414
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717/* Globals */
1818const char mess_disclaimer[] =
r9922r9923
5050      "\n"
5151      "See config.txt and windows.txt for usage instructions.\n");
5252}
53
54/*************************************
55 *
56 *  Code used by print_mame_xml()
57 *
58 *************************************/
59
60/* device iteration helpers */
61#define ram_first(config)            (config).m_devicelist.first(MESSRAM)
62#define ram_next(previous)            ((previous)->typenext())
63
64/*-------------------------------------------------
65    print_game_ramoptions - prints out all RAM
66    options for this system
67-------------------------------------------------*/
68static void print_game_ramoptions(FILE *out, const game_driver *game, const machine_config &config)
69{
70   const device_config *device;
71
72   for (device = ram_first(config); device != NULL; device = ram_next(device))
73   {
74      ram_config *ram = (ram_config *)downcast<const legacy_device_config_base *>(device)->inline_config();
75      fprintf(out, "\t\t<ramoption default=\"1\">%u</ramoption>\n",  messram_parse_string(ram->default_size));
76      if (ram->extra_options != NULL)
77      {
78         int j;
79         int size = strlen(ram->extra_options);
80         char * const s = mame_strdup(ram->extra_options);
81         char * const e = s + size;
82         char *p = s;
83         for (j=0;j<size;j++) {
84            if (p[j]==',') p[j]=0;
85         }
86         /* try to parse each option */
87         while(p <= e)
88         {
89            fprintf(out, "\t\t<ramoption>%u</ramoption>\n",  messram_parse_string(p));
90            p += strlen(p);
91            if (p == e)
92               break;
93            p += 1;
94         }
95
96         osd_free(s);
97      }
98   }
99}
100
101
102/*-------------------------------------------------
103    print_mess_game_xml - print MESS specific game
104    information.
105-------------------------------------------------*/
106
107void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config &config)
108{
109   print_game_ramoptions( out, game, config );
110}
111
112/***************************************************************************
113    LOCAL VARIABLES
114***************************************************************************/
115
116const options_entry mess_core_options[] =
117{
118   { NULL,                     NULL,   OPTION_HEADER,                  "MESS SPECIFIC OPTIONS" },
119   { "ramsize;ram",            NULL,   0,                           "size of RAM (if supported by driver)" },
120   { "newui;nu",                   "0",    OPTION_BOOLEAN,                  "use the new MESS UI" },
121   { NULL }
122};
123
124/***************************************************************************
125    IMPLEMENTATION
126***************************************************************************/
127/*-------------------------------------------------
128    mess_options_init - called from core to add
129    MESS specific options
130-------------------------------------------------*/
131
132void mess_options_init(core_options *opts)
133{
134   /* add MESS-specific options */
135   options_add_entries(opts, mess_core_options);
136}
src/mess/mess.h
r9922r9923
99#ifndef __MESS_H__
1010#define __MESS_H__
1111
12#include "options.h"
13
14/******************************************************************************
15 * MESS' version of the GAME() macros of MAME
16 * CONS is for consoles
17 * COMP is for computers
18 ******************************************************************************/
19
20#define CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
21extern const game_driver GAME_NAME(NAME) =   \
22{                                 \
23   __FILE__,                        \
24   #PARENT,                        \
25   #NAME,                           \
26   FULLNAME,                        \
27   #YEAR,                           \
28   COMPANY,                        \
29   MACHINE_CONFIG_NAME(MACHINE),         \
30   INPUT_PORTS_NAME(INPUT),            \
31   DRIVER_INIT_NAME(INIT),               \
32   ROM_NAME(NAME),                     \
33   #COMPAT,                        \
34   ROT0|(FLAGS),                     \
35   NULL                           \
36};
37
38#define COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
39extern const game_driver GAME_NAME(NAME) =   \
40{                                 \
41   __FILE__,                        \
42   #PARENT,                        \
43   #NAME,                           \
44   FULLNAME,                        \
45   #YEAR,                           \
46   COMPANY,                        \
47   MACHINE_CONFIG_NAME(MACHINE),         \
48   INPUT_PORTS_NAME(INPUT),            \
49   DRIVER_INIT_NAME(INIT),               \
50   ROM_NAME(NAME),                     \
51   #COMPAT,                        \
52   ROT0|(FLAGS),            \
53   NULL                           \
54};
55
5612/***************************************************************************
5713    CONSTANTS
5814***************************************************************************/
59
60#define OPTION_RAMSIZE         "ramsize"
61#define OPTION_WRITECONFIG      "writeconfig"
6215#define LCD_FRAMES_PER_SECOND   30
6316
6417
r9922r9923
6619    GLOBALS
6720***************************************************************************/
6821
69extern const options_entry mess_core_options[];
70
7122extern const char layout_lcd[];   /* generic 1:1 lcd screen layout */
7223extern const char layout_lcd_rot[];   /* same, for use with ROT90 or ROT270 */
7324
r9922r9923
7930
8031void mess_display_help(void);
8132
82/* code used by print_mame_xml() */
83void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config &config);
84
85/* initialize MESS specific options (called from MAME core) */
86void mess_options_init(core_options *opts);
87
8833#endif /* __MESS_H__ */
src/mess/tools/messtest/testmess.c
r9922r9923
1818#include "sound/wavwrite.h"
1919#include "video/generic.h"
2020#include "render.h"
21#include "devices/messram.h"
21#include "machine/ram.h"
2222#include "debug/debugcpu.h"
2323
2424
r9922r9923
16041604
16051605   /* 'ramsize' attribute */
16061606   attr_node = xml_get_attribute(node, "ramsize");
1607   current_testcase.ram = attr_node ? messram_parse_string(attr_node->value) : 0;
1607   current_testcase.ram = attr_node ? ram_parse_string(attr_node->value) : 0;
16081608
16091609   /* 'wavwrite' attribute */
16101610   attr_node = xml_get_attribute(node, "wavwrite");
src/mess/audio/mac.c
r9922r9923
1212#include "sound/asc.h"
1313#include "includes/mac.h"
1414#include "streams.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717/***************************************************************************
1818    MACROS / CONSTANTS
r9922r9923
140140   mac_sound *token = get_token(device);
141141
142142   if (buffer)
143      token->mac_snd_buf_ptr = (UINT16 *) (messram_get_ptr(device->machine->device("messram")) + messram_get_size(device->machine->device("messram")) - MAC_MAIN_SND_BUF_OFFSET);
143      token->mac_snd_buf_ptr = (UINT16 *) (ram_get_ptr(device->machine->device(RAM_TAG)) + ram_get_size(device->machine->device(RAM_TAG)) - MAC_MAIN_SND_BUF_OFFSET);
144144   else
145      token->mac_snd_buf_ptr = (UINT16 *) (messram_get_ptr(device->machine->device("messram")) + messram_get_size(device->machine->device("messram")) - MAC_ALT_SND_BUF_OFFSET);
145      token->mac_snd_buf_ptr = (UINT16 *) (ram_get_ptr(device->machine->device(RAM_TAG)) + ram_get_size(device->machine->device(RAM_TAG)) - MAC_ALT_SND_BUF_OFFSET);
146146}
147147
148148
src/mess/machine/dgn_beta.c
r9922r9923
7070
7171#include "debug/debugcpu.h"
7272#include "debug/debugcon.h"
73#include "devices/messram.h"
73#include "machine/ram.h"
7474
7575
7676// Ram banking handlers.
r9922r9923
283283      //
284284      // Map block, $00-$BF are ram, $FC-$FF are Boot ROM
285285      //
286      if ((MapPage*4) < ((messram_get_size(machine->device("messram")) / 1024)-1))      // Block is ram
286      if ((MapPage*4) < ((ram_get_size(machine->device(RAM_TAG)) / 1024)-1))      // Block is ram
287287      {
288288         if (!is_last_page(Page))
289289         {
290            readbank = &messram_get_ptr(machine->device("messram"))[MapPage*RamPageSize];
290            readbank = &ram_get_ptr(machine->device(RAM_TAG))[MapPage*RamPageSize];
291291            if(state->LogDatWrites)
292292               debug_console_printf(machine, "Mapping page %X, pageno=%X, mess_ram)[%X]\n",Page,MapPage,(MapPage*RamPageSize));
293293         }
294294         else
295295         {
296            readbank = &messram_get_ptr(machine->device("messram"))[(MapPage*RamPageSize)-256];
296            readbank = &ram_get_ptr(machine->device(RAM_TAG))[(MapPage*RamPageSize)-256];
297297            logerror("Error RAM in Last page !\n");
298298         }
299299         writebank=bank_info[Page].handler;
r9922r9923
362362
363363   /* Map video ram to base of area it can use, that way we can take the literal RA */
364364   /* from the 6845 without having to mask it ! */
365   videoram=&messram_get_ptr(machine->device("messram"))[TextVidBasePage*RamPageSize];
365   videoram=&ram_get_ptr(machine->device(RAM_TAG))[TextVidBasePage*RamPageSize];
366366}
367367
368368// Return the value of a page register
r9922r9923
11001100   wd17xx_dden_w(fdc, CLEAR_LINE);
11011101   wd17xx_set_drive(fdc, 0);
11021102
1103   state->videoram = messram_get_ptr(machine.device("messram"));      /* Point video ram at the start of physical ram */
1103   state->videoram = ram_get_ptr(machine.device(RAM_TAG));      /* Point video ram at the start of physical ram */
11041104
11051105    dgnbeta_video_reset(&machine);
11061106    wd17xx_reset(fdc);
src/mess/machine/ataricrt.c
r9922r9923
88#include "emuopts.h"
99#include "includes/atari.h"
1010#include "ataridev.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313static int a800_cart_loaded = 0;
1414static int a800_cart_is_16k = 0;
r9922r9923
3737   }
3838
3939   /* install RAM */
40   ram_top = MIN(messram_get_size(machine->device("messram")), ram_size) - 1;
40   ram_top = MIN(ram_get_size(machine->device(RAM_TAG)), ram_size) - 1;
4141   memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
4242      0x0000, ram_top, 0, 0, SMH_BANK(2));
4343   memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
4444      0x0000, ram_top, 0, 0, SMH_BANK(2));
45   memory_set_bankptr(machine, 2, messram_get_ptr(machine->device("messram")));
45   memory_set_bankptr(machine, 2, ram_get_ptr(machine->device(RAM_TAG)));
4646}
4747#endif
4848
r9922r9923
6868         }
6969         else
7070         {
71            read_addr = &messram_get_ptr(machine->device("messram"))[0x08000];
72            write_addr = &messram_get_ptr(machine->device("messram"))[0x08000];
71            read_addr = &ram_get_ptr(machine->device(RAM_TAG))[0x08000];
72            write_addr = &ram_get_ptr(machine->device(RAM_TAG))[0x08000];
7373         }
7474         break;
7575   }
r9922r9923
119119   }
120120
121121   /* install RAM */
122   ram_top = MIN(messram_get_size(machine->device("messram")), ram_size) - 1;
122   ram_top = MIN(ram_get_size(machine->device(RAM_TAG)), ram_size) - 1;
123123   memory_install_readwrite_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0x0000, ram_top, 0, 0, "bank2");
124   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
124   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
125125
126126   /* cartridge */
127127   if (has_cart)
src/mess/machine/apple3.c
r9922r9923
2222#include "machine/applefdc.h"
2323#include "devices/appldriv.h"
2424#include "machine/6551.h"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626
2727
2828static void apple3_update_drives(device_t *device);
r9922r9923
263263{
264264   if (bank != (UINT16) ~0)
265265   {
266      bank %= messram_get_size(machine->device("messram")) / 0x8000;
267      if ((bank + 1) == (messram_get_size(machine->device("messram")) / 0x8000))
266      bank %= ram_get_size(machine->device(RAM_TAG)) / 0x8000;
267      if ((bank + 1) == (ram_get_size(machine->device(RAM_TAG)) / 0x8000))
268268         bank = 0x02;
269269   }
270270   offset += ((offs_t) bank) * 0x8000;
271   offset %= messram_get_size(machine->device("messram"));
272   return &messram_get_ptr(machine->device("messram"))[offset];
271   offset %= ram_get_size(machine->device(RAM_TAG));
272   return &ram_get_ptr(machine->device(RAM_TAG))[offset];
273273}
274274
275275
r9922r9923
284284   if (LOG_MEMORY)
285285   {
286286      #ifdef PTR64
287      //logerror("\tbank %s --> %02x/%04x [0x%08lx]\n", mame_bank, (unsigned) bank, (unsigned)offset, ptr - messram_get_ptr(machine->device("messram")));
287      //logerror("\tbank %s --> %02x/%04x [0x%08lx]\n", mame_bank, (unsigned) bank, (unsigned)offset, ptr - ram_get_ptr(machine->device(RAM_TAG)));
288288      #else
289      logerror("\tbank %s --> %02x/%04x [0x%08x]\n", mame_bank, (unsigned) bank, (unsigned)offset, ptr - messram_get_ptr(machine->device("messram")));
289      logerror("\tbank %s --> %02x/%04x [0x%08x]\n", mame_bank, (unsigned) bank, (unsigned)offset, ptr - ram_get_ptr(machine->device(RAM_TAG)));
290290      #endif
291291   }
292292}
r9922r9923
576576         else if (offset > 0x9FFF)
577577            result = apple3_bankaddr(machine,~0, offset - 0x8000);
578578         else
579            result = &messram_get_ptr(machine->device("messram"))[offset - 0x2000];
579            result = &ram_get_ptr(machine->device(RAM_TAG))[offset - 0x2000];
580580      }
581581      else if ((n >= 0x80) && (n <= 0x8E))
582582      {
src/mess/machine/c65.c
r9922r9923
1414#include "sound/sid6581.h"
1515#include "machine/6526cia.h"
1616#include "machine/cbmiec.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818#include "video/vic4567.h"
1919
2020#define VERBOSE_LEVEL 0
r9922r9923
646646{
647647   c65_state *state = space->machine->driver_data<c65_state>();
648648   UINT8 data = 0xff;
649   if (messram_get_size(space->machine->device("messram")) > (128 * 1024))
649   if (ram_get_size(space->machine->device(RAM_TAG)) > (128 * 1024))
650650      data = state->expansion_ram.reg;
651651   return data;
652652}
r9922r9923
657657   offs_t expansion_ram_begin;
658658   offs_t expansion_ram_end;
659659
660   if (messram_get_size(space->machine->device("messram")) > (128 * 1024))
660   if (ram_get_size(space->machine->device(RAM_TAG)) > (128 * 1024))
661661   {
662662      state->expansion_ram.reg = data;
663663
664664      expansion_ram_begin = 0x80000;
665      expansion_ram_end = 0x80000 + (messram_get_size(space->machine->device("messram")) - 128*1024) - 1;
665      expansion_ram_end = 0x80000 + (ram_get_size(space->machine->device(RAM_TAG)) - 128*1024) - 1;
666666
667667      if (data == 0x00) {
668668         memory_install_readwrite_bank(space, expansion_ram_begin, expansion_ram_end,0,0,"bank16");
669         memory_set_bankptr(space->machine, "bank16", messram_get_ptr(space->machine->device("messram")) + 128*1024);
669         memory_set_bankptr(space->machine, "bank16", ram_get_ptr(space->machine->device(RAM_TAG)) + 128*1024);
670670      } else {
671671         memory_nop_readwrite(space, expansion_ram_begin, expansion_ram_end,0,0);
672672      }
r9922r9923
10401040{
10411041   c65_state *state = machine->driver_data<c65_state>();
10421042   /* clear upper memory */
1043   memset(messram_get_ptr(machine->device("messram")) + 128*1024, 0xff, messram_get_size(machine->device("messram")) -  128*1024);
1043   memset(ram_get_ptr(machine->device(RAM_TAG)) + 128*1024, 0xff, ram_get_size(machine->device(RAM_TAG)) -  128*1024);
10441044
10451045//removed   cbm_drive_0_config (SERIAL, 10);
10461046//removed   cbm_drive_1_config (SERIAL, 11);
src/mess/machine/dai.c
r9922r9923
1717#include "includes/dai.h"
1818#include "machine/pit8253.h"
1919#include "machine/tms5501.h"
20#include "devices/messram.h"
20#include "machine/ram.h"
2121
2222#define DEBUG_DAI_PORTS   0
2323
r9922r9923
155155
156156MACHINE_RESET( dai )
157157{
158   memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
158   memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
159159}
160160
161161/***************************************************************************
src/mess/machine/pc1350.c
r9922r9923
33
44#include "includes/pocketc.h"
55#include "includes/pc1350.h"
6#include "devices/messram.h"
6#include "machine/ram.h"
77
88
99
r9922r9923
129129   timer_set(machine, ATTOTIME_IN_SEC(1), NULL, 0, pc1350_power_up);
130130
131131   memory_install_readwrite_bank(space, 0x6000, 0x6fff, 0, 0, "bank1");
132   memory_set_bankptr(machine, "bank1", &messram_get_ptr(machine->device("messram"))[0x0000]);
132   memory_set_bankptr(machine, "bank1", &ram_get_ptr(machine->device(RAM_TAG))[0x0000]);
133133
134   if (messram_get_size(machine->device("messram")) >= 0x3000)
134   if (ram_get_size(machine->device(RAM_TAG)) >= 0x3000)
135135   {
136136      memory_install_readwrite_bank(space, 0x4000, 0x5fff, 0, 0, "bank2");
137      memory_set_bankptr(machine, "bank2", &messram_get_ptr(machine->device("messram"))[0x1000]);
137      memory_set_bankptr(machine, "bank2", &ram_get_ptr(machine->device(RAM_TAG))[0x1000]);
138138   }
139139   else
140140   {
141141      memory_nop_readwrite(space, 0x4000, 0x5fff, 0, 0);
142142   }
143143
144   if (messram_get_size(machine->device("messram")) >= 0x5000)
144   if (ram_get_size(machine->device(RAM_TAG)) >= 0x5000)
145145   {
146146      memory_install_readwrite_bank(space, 0x2000, 0x3fff, 0, 0, "bank3");
147      memory_set_bankptr(machine, "bank3", &messram_get_ptr(machine->device("messram"))[0x3000]);
147      memory_set_bankptr(machine, "bank3", &ram_get_ptr(machine->device(RAM_TAG))[0x3000]);
148148   }
149149   else
150150   {
src/mess/machine/coco.c
r9922r9923
104104#include "devices/cococart.h"
105105#include "devices/cartslot.h"
106106#include "devices/flopdrv.h"
107#include "devices/messram.h"
107#include "machine/ram.h"
108108#include "crsshair.h"
109109
110110/***************************************************************************
r9922r9923
646646   int trailer_load = 0;
647647
648648   ROM = image.device().machine->region("maincpu")->base();
649   rambase = &messram_get_ptr(image.device().machine->device("messram"))[rambase_index];
649   rambase = &ram_get_ptr(image.device().machine->device(RAM_TAG))[rambase_index];
650650   rombase = &ROM[rombase_index];
651651   pakbase = &ROM[pakbase_index];
652652
653   if (messram_get_size(image.device().machine->device("messram")) < 0x10000)
653   if (ram_get_size(image.device().machine->device(RAM_TAG)) < 0x10000)
654654   {
655655      if (LOG_PAK)
656656         logerror("Cannot load PAK files without at least 64k.\n");
r9922r9923
728728
729729SNAPSHOT_LOAD ( coco3_pak )
730730{
731   return generic_pak_load(image, (0x70000 % messram_get_size(image.device().machine->device("messram"))), 0x0000, 0xc000);
731   return generic_pak_load(image, (0x70000 % ram_get_size(image.device().machine->device(RAM_TAG))), 0x0000, 0xc000);
732732}
733733
734734/***************************************************************************
r9922r9923
18901890       to access 32K of ram, and also allows the cocoe driver to access
18911891       the full 64K, as this uses Color Basic 1.2, which can configure 64K rams */
18921892
1893   if (messram_get_size(device->machine->device("messram")) > 0x8000)      /* 1 bank of 64K rams */
1893   if (ram_get_size(device->machine->device(RAM_TAG)) > 0x8000)      /* 1 bank of 64K rams */
18941894      result = (pia6821_get_output_b(state->pia_0) & 0x80) >> 5;
1895   else if (messram_get_size(device->machine->device("messram")) >= 0x4000)   /* 1 or 2 banks of 16K rams */
1895   else if (ram_get_size(device->machine->device(RAM_TAG)) >= 0x4000)   /* 1 or 2 banks of 16K rams */
18961896      result = 0x04;
18971897   else
18981898      result = 0x00;         /* 4K Rams */
r9922r9923
19131913       as both the 64 and Alpha, always have 64K rams, also the meaning of
19141914       the bit is different with respect to the CoCo 1 */
19151915
1916   if (messram_get_size(device->machine->device("messram")) > 0x8000)
1916   if (ram_get_size(device->machine->device(RAM_TAG)) > 0x8000)
19171917      result = 0x00;      /* 1 bank of 64K, rams */
19181918   else
19191919      result = 0x04;      /* 2 banks of 16K rams */
r9922r9923
19301930     */
19311931   int result;
19321932
1933   if (messram_get_size(device->machine->device("messram")) <= 0x1000)
1933   if (ram_get_size(device->machine->device(RAM_TAG)) <= 0x1000)
19341934      result = 0x00;               /* 4K: wire pia1_pb2 low */
1935   else if (messram_get_size(device->machine->device("messram")) <= 0x4000)
1935   else if (ram_get_size(device->machine->device(RAM_TAG)) <= 0x4000)
19361936      result = 0x04;               /* 16K: wire pia1_pb2 high */
19371937   else
19381938      result = (pia6821_get_output_b(state->pia_0) & 0x40) >> 4;      /* 32/64K: wire output of pia0_pb6 to input pia1_pb2  */
r9922r9923
19751975
19761976   switch (map)
19771977   {
1978      case 0x00   : state->bottom_32k=&messram_get_ptr(space->machine->device("messram"))[0x00000]; break;
1979      case 0x01   : state->bottom_32k=&messram_get_ptr(space->machine->device("messram"))[0x10000]; break;
1980      case 0x02   : state->bottom_32k=&messram_get_ptr(space->machine->device("messram"))[0x18000]; break;
1981      case 0x03   : state->bottom_32k=&messram_get_ptr(space->machine->device("messram"))[0x00000]; break;
1982      default   : state->bottom_32k=&messram_get_ptr(space->machine->device("messram"))[0x00000]; break; // Just to shut the compiler up !
1978      case 0x00   : state->bottom_32k=&ram_get_ptr(space->machine->device(RAM_TAG))[0x00000]; break;
1979      case 0x01   : state->bottom_32k=&ram_get_ptr(space->machine->device(RAM_TAG))[0x10000]; break;
1980      case 0x02   : state->bottom_32k=&ram_get_ptr(space->machine->device(RAM_TAG))[0x18000]; break;
1981      case 0x03   : state->bottom_32k=&ram_get_ptr(space->machine->device(RAM_TAG))[0x00000]; break;
1982      default   : state->bottom_32k=&ram_get_ptr(space->machine->device(RAM_TAG))[0x00000]; break; // Just to shut the compiler up !
19831983   }
19841984
19851985   setup_memory_map(space->machine);
r9922r9923
21002100      /* Lookup the apropreate wbank value dependent on ram size */
21012101      if (memsize==0)
21022102         wbank=memmap[block_index].wbank4;
2103      else if ((memsize==1) && (messram_get_size(machine->device("messram")) == 0x4000))   /* one bank of 16K rams */
2103      else if ((memsize==1) && (ram_get_size(machine->device(RAM_TAG)) == 0x4000))   /* one bank of 16K rams */
21042104         wbank=memmap[block_index].wbank16_1;
2105      else if ((memsize==1) && (messram_get_size(machine->device("messram")) == 0x8000))   /* two banks of 16K rams */
2105      else if ((memsize==1) && (ram_get_size(machine->device(RAM_TAG)) == 0x8000))   /* two banks of 16K rams */
21062106         wbank=memmap[block_index].wbank16_2;
21072107      else
21082108         wbank=memmap[block_index].wbank64;
r9922r9923
21162116         if(block_index<8)
21172117            memory_set_bankptr(machine, bank, &state->bottom_32k[memmap[wbank-1].start]);
21182118         else
2119            memory_set_bankptr(machine, bank,&messram_get_ptr(machine->device("messram"))[memmap[wbank-1].start]);
2119            memory_set_bankptr(machine, bank,&ram_get_ptr(machine->device(RAM_TAG))[memmap[wbank-1].start]);
21202120
21212121         memory_install_readwrite_bank(space, memmap[block_index].start, memmap[block_index].end, 0, 0, bank);
21222122      }
r9922r9923
21622162
21632163   if (!sam6883_maptype(device))      // Ignored in maptype 1
21642164   {
2165      if((messram_get_size(device->machine->device("messram"))>0x8000) && val)
2166         state->bottom_32k=&messram_get_ptr(device->machine->device("messram"))[0x8000];
2165      if((ram_get_size(device->machine->device(RAM_TAG))>0x8000) && val)
2166         state->bottom_32k=&ram_get_ptr(device->machine->device(RAM_TAG))[0x8000];
21672167      else
2168         state->bottom_32k=messram_get_ptr(device->machine->device("messram"));
2168         state->bottom_32k=ram_get_ptr(device->machine->device(RAM_TAG));
21692169
21702170      setup_memory_map(device->machine);
21712171   }
r9922r9923
22942294{
22952295   coco_state *state = device->machine->driver_data<coco_state>();
22962296   if(val)
2297      state->bottom_32k=messram_get_ptr(device->machine->device("messram"));   // Always reset, when in maptype 1
2297      state->bottom_32k=ram_get_ptr(device->machine->device(RAM_TAG));   // Always reset, when in maptype 1
22982298
22992299   setup_memory_map(device->machine);
23002300}
r9922r9923
23432343         /* this GIME register fixes logical addresses $FExx to physical
23442344             * addresses $7FExx ($1FExx if 128k */
23452345         assert(offset < 0x200);
2346         return ((messram_get_size(machine->device("messram")) - 0x200) & 0x7ffff) + offset;
2346         return ((ram_get_size(machine->device(RAM_TAG)) - 0x200) & 0x7ffff) + offset;
23472347      }
23482348      bank = 7;
23492349      offset += 0x1e00;
r9922r9923
23932393   }
23942394   else
23952395   {
2396      result = ((block * 0x2000) + offset) % messram_get_size(machine->device("messram"));
2396      result = ((block * 0x2000) + offset) % ram_get_size(machine->device(RAM_TAG));
23972397   }
23982398   return result;
23992399}
r9922r9923
24442444      else
24452445      {
24462446         /* offset into normal RAM */
2447         readbank = &messram_get_ptr(machine->device("messram"))[offset];
2447         readbank = &ram_get_ptr(machine->device(RAM_TAG))[offset];
24482448         memory_install_write_bank(space, bank_info[i].start, bank_info[i].end, 0, 0, bank);
24492449      }
24502450
r9922r9923
27272727{
27282728   UINT32 video_base;
27292729   video_base = coco3_get_video_base(device->machine, 0xE0, 0x3F);
2730   return &messram_get_ptr(device->machine->device("messram"))[video_base % messram_get_size(device->machine->device("messram"))];
2730   return &ram_get_ptr(device->machine->device(RAM_TAG))[video_base % ram_get_size(device->machine->device(RAM_TAG))];
27312731}
27322732
27332733
r9922r9923
28722872   state->bas_rom_bank = state->rom;
28732873
28742874   /* setup default pointer for botom 32K of ram */
2875   state->bottom_32k = messram_get_ptr(machine->device("messram"));
2875   state->bottom_32k = ram_get_ptr(machine->device(RAM_TAG));
28762876
28772877   /* setup printer output callback */
28782878   state->printer_out = init->printer_out_;
r9922r9923
28942894static void generic_coco12_dragon_init(running_machine *machine, const machine_init_interface *init)
28952895{
28962896   /* Set default RAM mapping */
2897   memory_set_bankptr(machine, "bank1", &messram_get_ptr(machine->device("messram"))[0]);
2897   memory_set_bankptr(machine, "bank1", &ram_get_ptr(machine->device(RAM_TAG))[0]);
28982898
28992899   /* Do generic Inits */
29002900   generic_init_machine(machine, init);
src/mess/machine/gb.c
r9922r9923
3838#include "emu.h"
3939#include "cpu/lr35902/lr35902.h"
4040#include "devices/cartslot.h"
41#include "devices/messram.h"
41#include "machine/ram.h"
4242#include "image.h"
4343#include "audio/gb.h"
4444#include "includes/gb.h"
r9922r9923
6363   MBC_UNKNOWN,   /* Unknown mapper                                */
6464};
6565
66/* messram_get_ptr(machine->device("messram")) layout defines */
66/* ram_get_ptr(machine->device(RAM_TAG)) layout defines */
6767#define CGB_START_VRAM_BANKS   0x0000
6868#define CGB_START_RAM_BANKS   ( 2 * 8 * 1024 )
6969
r9922r9923
373373   /* Allocate memory for internal ram */
374374   for( ii = 0; ii < 8; ii++ )
375375   {
376      state->GBC_RAMMap[ii] = messram_get_ptr(machine->device("messram")) + CGB_START_RAM_BANKS + ii * 0x1000;
376      state->GBC_RAMMap[ii] = ram_get_ptr(machine->device(RAM_TAG)) + CGB_START_RAM_BANKS + ii * 0x1000;
377377      memset (state->GBC_RAMMap[ii], 0, 0x1000);
378378   }
379379}
r9922r9923
16891689   {
16901690   case 0x00:   state->MBCType = MBC_NONE;   state->CartType = 0;            break;
16911691   case 0x01:   state->MBCType = MBC_MBC1;   state->CartType = 0;            break;
1692   case 0x02:   state->MBCType = MBC_MBC1;   state->CartType = RAM;            break;
1693   case 0x03:   state->MBCType = MBC_MBC1;   state->CartType = RAM | BATTERY;      break;
1692   case 0x02:   state->MBCType = MBC_MBC1;   state->CartType = CART_RAM;            break;
1693   case 0x03:   state->MBCType = MBC_MBC1;   state->CartType = CART_RAM | BATTERY;      break;
16941694   case 0x05:   state->MBCType = MBC_MBC2;   state->CartType = 0;            break;
16951695   case 0x06:   state->MBCType = MBC_MBC2;   state->CartType = BATTERY;         break;
1696   case 0x08:   state->MBCType = MBC_NONE;   state->CartType = RAM;            break;
1697   case 0x09:   state->MBCType = MBC_NONE;   state->CartType = RAM | BATTERY;      break;
1696   case 0x08:   state->MBCType = MBC_NONE;   state->CartType = CART_RAM;            break;
1697   case 0x09:   state->MBCType = MBC_NONE;   state->CartType = CART_RAM | BATTERY;      break;
16981698   case 0x0B:   state->MBCType = MBC_MMM01;   state->CartType = 0;            break;
1699   case 0x0C:   state->MBCType = MBC_MMM01;   state->CartType = RAM;            break;
1700   case 0x0D:   state->MBCType = MBC_MMM01;   state->CartType = RAM | BATTERY;      break;
1699   case 0x0C:   state->MBCType = MBC_MMM01;   state->CartType = CART_RAM;            break;
1700   case 0x0D:   state->MBCType = MBC_MMM01;   state->CartType = CART_RAM | BATTERY;      break;
17011701   case 0x0F:   state->MBCType = MBC_MBC3;   state->CartType = TIMER | BATTERY;      break;
1702   case 0x10:   state->MBCType = MBC_MBC3;   state->CartType = TIMER | RAM | BATTERY;   break;
1702   case 0x10:   state->MBCType = MBC_MBC3;   state->CartType = TIMER | CART_RAM | BATTERY;   break;
17031703   case 0x11:   state->MBCType = MBC_MBC3;   state->CartType = 0;            break;
1704   case 0x12:   state->MBCType = MBC_MBC3;   state->CartType = RAM;            break;
1705   case 0x13:   state->MBCType = MBC_MBC3;   state->CartType = RAM | BATTERY;      break;
1704   case 0x12:   state->MBCType = MBC_MBC3;   state->CartType = CART_RAM;            break;
1705   case 0x13:   state->MBCType = MBC_MBC3;   state->CartType = CART_RAM | BATTERY;      break;
17061706   case 0x15:   state->MBCType = MBC_MBC4;   state->CartType = 0;            break;
1707   case 0x16:   state->MBCType = MBC_MBC4;   state->CartType = RAM;            break;
1708   case 0x17:   state->MBCType = MBC_MBC4;   state->CartType = RAM | BATTERY;      break;
1707   case 0x16:   state->MBCType = MBC_MBC4;   state->CartType = CART_RAM;            break;
1708   case 0x17:   state->MBCType = MBC_MBC4;   state->CartType = CART_RAM | BATTERY;      break;
17091709   case 0x19:   state->MBCType = MBC_MBC5;   state->CartType = 0;            break;
1710   case 0x1A:   state->MBCType = MBC_MBC5;   state->CartType = RAM;            break;
1711   case 0x1B:   state->MBCType = MBC_MBC5;   state->CartType = RAM | BATTERY;      break;
1710   case 0x1A:   state->MBCType = MBC_MBC5;   state->CartType = CART_RAM;            break;
1711   case 0x1B:   state->MBCType = MBC_MBC5;   state->CartType = CART_RAM | BATTERY;      break;
17121712   case 0x1C:   state->MBCType = MBC_MBC5;   state->CartType = RUMBLE;         break;
17131713   case 0x1D:   state->MBCType = MBC_MBC5;   state->CartType = RUMBLE | SRAM;      break;
17141714   case 0x1E:   state->MBCType = MBC_MBC5;   state->CartType = RUMBLE | SRAM | BATTERY;   break;
src/mess/machine/b2m.c
r9922r9923
1616#include "machine/pic8259.h"
1717#include "machine/msm8251.h"
1818#include "includes/b2m.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020#include "devices/flopdrv.h"
2121
2222static READ8_HANDLER (b2m_keyboard_r )
r9922r9923
5757      case 1 :
5858                  memory_unmap_write(space, 0xe000, 0xffff, 0, 0);
5959
60                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
61                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x2800);
62                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x3000);
63                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x7000);
60                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
61                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x2800);
62                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x3000);
63                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x7000);
6464                  memory_set_bankptr(machine, "bank5", rom + 0x10000);
6565                  break;
6666#if 0
r9922r9923
6868                  memory_unmap_write(space, 0x3000, 0x6fff, 0, 0);
6969                  memory_unmap_write(space, 0xe000, 0xffff, 0, 0);
7070
71                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
72                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x2800);
71                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
72                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x2800);
7373                  memory_set_bankptr(machine, "bank3", rom + 0x12000);
7474                  memory_set_bankptr(machine, "bank4", rom + 0x16000);
7575                  memory_set_bankptr(machine, "bank5", rom + 0x10000);
r9922r9923
7979                  memory_unmap_write(space, 0x2800, 0x2fff, 0, 0);
8080                  memory_unmap_write(space, 0xe000, 0xffff, 0, 0);
8181
82                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
82                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
8383                  memory_install_read8_handler(space, 0x2800, 0x2fff, 0, 0, b2m_keyboard_r);
84                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x10000);
85                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x7000);
84                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000);
85                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x7000);
8686                  memory_set_bankptr(machine, "bank5", rom + 0x10000);
8787                  break;
8888      case 3 :
8989                  memory_unmap_write(space, 0x2800, 0x2fff, 0, 0);
9090                  memory_unmap_write(space, 0xe000, 0xffff, 0, 0);
9191
92                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
92                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
9393                  memory_install_read8_handler(space, 0x2800, 0x2fff, 0, 0, b2m_keyboard_r);
94                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x14000);
95                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x7000);
94                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x14000);
95                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x7000);
9696                  memory_set_bankptr(machine, "bank5", rom + 0x10000);
9797                  break;
9898      case 4 :
9999                  memory_unmap_write(space, 0x2800, 0x2fff, 0, 0);
100100                  memory_unmap_write(space, 0xe000, 0xffff, 0, 0);
101101
102                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
102                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
103103                  memory_install_read8_handler(space, 0x2800, 0x2fff, 0, 0, b2m_keyboard_r);
104                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x18000);
105                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x7000);
104                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x18000);
105                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x7000);
106106                  memory_set_bankptr(machine, "bank5", rom + 0x10000);
107107
108108                  break;
r9922r9923
110110                  memory_unmap_write(space, 0x2800, 0x2fff, 0, 0);
111111                  memory_unmap_write(space, 0xe000, 0xffff, 0, 0);
112112
113                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
113                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
114114                  memory_install_read8_handler(space, 0x2800, 0x2fff, 0, 0, b2m_keyboard_r);
115                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x1c000);
116                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x7000);
115                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x1c000);
116                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x7000);
117117                  memory_set_bankptr(machine, "bank5", rom + 0x10000);
118118
119119                  break;
120120      case 6 :
121                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
122                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x2800);
123                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x3000);
124                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x7000);
125                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xe000);
121                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
122                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x2800);
123                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x3000);
124                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x7000);
125                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xe000);
126126                  break;
127127      case 7 :
128128                  memory_unmap_write(space, 0x0000, 0x27ff, 0, 0);
src/mess/machine/aim65.c
r9922r9923
1818/* M6502 main CPU */
1919#include "cpu/m6502/m6502.h"
2020
21#include "devices/messram.h"
21#include "machine/ram.h"
2222
2323
2424/******************************************************************************
r9922r9923
171171
172172MACHINE_START( aim65 )
173173{
174   device_t *ram = machine->device("messram");
174   device_t *ram = machine->device(RAM_TAG);
175175   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
176176
177177   /* Init RAM */
178   memory_install_ram(space, 0x0000, messram_get_size(ram) - 1, 0, 0, messram_get_ptr(ram));
178   memory_install_ram(space, 0x0000, ram_get_size(ram) - 1, 0, 0, ram_get_ptr(ram));
179179}
180180
181181
src/mess/machine/thomson.c
r9922r9923
1212#include "includes/thomson.h"
1313#include "machine/6821pia.h"
1414#include "machine/ctronics.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717#define VERBOSE       0
1818#define VERBOSE_IRQ   0
r9922r9923
15721572
15731573   /* memory */
15741574   thom_cart_bank = 0;
1575   thom_vram = messram_get_ptr(machine->device("messram"));
1576   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x2000 );
1575   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
1576   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x2000 );
15771577   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
15781578   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
15791579   memory_set_bank( machine, THOM_BASE_BANK, 0 );
15801580   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
15811581   memory_set_bank( machine, THOM_CART_BANK, 0 );
15821582
1583   if ( messram_get_size(machine->device("messram")) > 24*1024 )
1583   if ( ram_get_size(machine->device(RAM_TAG)) > 24*1024 )
15841584   {
15851585      /* install 16 KB or 16 KB + 8 KB memory extensions */
15861586      /* BASIC instruction to see free memory: ?FRE(0) */
1587      int extram = messram_get_size(machine->device("messram")) - 24*1024;
1587      int extram = ram_get_size(machine->device(RAM_TAG)) - 24*1024;
15881588      memory_install_write_bank(space, 0x8000, 0x8000 + extram - 1, 0, 0, THOM_RAM_BANK);
15891589      memory_install_read_bank(space, 0x8000, 0x8000 + extram - 1, 0, 0, THOM_RAM_BANK );
1590      memory_configure_bank( machine, THOM_RAM_BANK,  0, 1, messram_get_ptr(machine->device("messram")) + 0x6000, extram );
1590      memory_configure_bank( machine, THOM_RAM_BANK,  0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x6000, extram );
15911591      memory_set_bank( machine, THOM_RAM_BANK, 0 );
15921592   }
15931593
r9922r9923
16651665   if ( bank != old_ram_bank )
16661666      LOG_BANK(( "to770_update_ram_bank: RAM bank change %i\n", bank ));
16671667
1668   if ( messram_get_size(machine->device("messram")) == 128*1024 || bank < 2 )
1668   if ( ram_get_size(machine->device(RAM_TAG)) == 128*1024 || bank < 2 )
16691669   {
16701670      memory_set_bank( machine, THOM_RAM_BANK, bank );
16711671      memory_install_write_bank(space, 0xa000, 0xdfff, 0, 0, THOM_RAM_BANK);
r9922r9923
18291829
18301830   /* memory */
18311831   thom_cart_bank = 0;
1832   thom_vram = messram_get_ptr(machine->device("messram"));
1833   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x4000 );
1834   memory_configure_bank( machine, THOM_RAM_BANK,  0, 6, messram_get_ptr(machine->device("messram")) + 0x8000, 0x4000 );
1832   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
1833   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x4000 );
1834   memory_configure_bank( machine, THOM_RAM_BANK,  0, 6, ram_get_ptr(machine->device(RAM_TAG)) + 0x8000, 0x4000 );
18351835   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
18361836   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
18371837   memory_set_bank( machine, THOM_BASE_BANK, 0 );
r9922r9923
22042204   /* memory */
22052205   thom_cart_bank = 0;
22062206   mo5_reg_cart = 0;
2207   thom_vram = messram_get_ptr(machine->device("messram"));
2208   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x8000 );
2207   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
2208   memory_configure_bank( machine, THOM_BASE_BANK, 0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x8000 );
22092209   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
2210   memory_configure_bank( machine, THOM_CART_BANK, 4, 4, messram_get_ptr(machine->device("messram")) + 0xc000, 0x4000 );
2210   memory_configure_bank( machine, THOM_CART_BANK, 4, 4, ram_get_ptr(machine->device(RAM_TAG)) + 0xc000, 0x4000 );
22112211   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, thom_vram, 0x2000 );
22122212   memory_set_bank( machine, THOM_BASE_BANK, 0 );
22132213   memory_set_bank( machine, THOM_CART_BANK, 0 );
r9922r9923
25412541   if ( old_ram_bank != bank )
25422542      LOG_BANK(( "to9_update_ram_bank: bank %i selected (pia=$%02X disk=%i)\n", bank, portb & 0xf8, disk ));
25432543
2544   if ( messram_get_size(machine->device("messram")) == 192*1024 || bank < 6 )
2544   if ( ram_get_size(machine->device(RAM_TAG)) == 192*1024 || bank < 6 )
25452545   {
25462546      memory_set_bank( machine, THOM_RAM_BANK, bank );
25472547      memory_install_write_bank( space, 0xa000, 0xdfff, 0, 0, THOM_RAM_BANK);
r9922r9923
31663166   to7_midi_init(machine);
31673167
31683168   /* memory */
3169   thom_vram = messram_get_ptr(machine->device("messram"));
3169   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
31703170   thom_cart_bank = 0;
31713171   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, thom_vram, 0x2000 );
31723172   memory_configure_bank( machine, THOM_CART_BANK, 0, 12, mem + 0x10000, 0x4000 );
3173   memory_configure_bank( machine, THOM_BASE_BANK, 0,  1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x4000 );
3174   memory_configure_bank( machine, THOM_RAM_BANK,  0, 10, messram_get_ptr(machine->device("messram")) + 0x8000, 0x4000 );
3173   memory_configure_bank( machine, THOM_BASE_BANK, 0,  1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x4000 );
3174   memory_configure_bank( machine, THOM_RAM_BANK,  0, 10, ram_get_ptr(machine->device(RAM_TAG)) + 0x8000, 0x4000 );
31753175   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
31763176   memory_set_bank( machine, THOM_CART_BANK, 0 );
31773177   memory_set_bank( machine, THOM_BASE_BANK, 0 );
r9922r9923
36083608        undistorted space, such as cartridge, page 0 (video), or page 1
36093609    */
36103610   to8_data_vpage = bank;
3611   if ( messram_get_size(machine->device("messram")) == 512*1024 || to8_data_vpage < 16 )
3611   if ( ram_get_size(machine->device(RAM_TAG)) == 512*1024 || to8_data_vpage < 16 )
36123612   {
36133613      memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage );
36143614      memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage );
r9922r9923
36503650      /* RAM space */
36513651      to8_cart_vpage = to8_reg_cart & 31;
36523652      bank = 8 + to8_cart_vpage;
3653      if ((to8_cart_vpage < 8 || messram_get_size(machine->device("messram")) == 512*1024) && (to8_reg_cart & 0x40)) {
3653      if ((to8_cart_vpage < 8 || ram_get_size(machine->device(RAM_TAG)) == 512*1024) && (to8_reg_cart & 0x40)) {
36543654         if (to8_cart_vpage <= 4) {
36553655            memory_install_write8_handler( space, 0x0000, 0x3fff, 0, 0,to8_vcart_w);
36563656         } else {
r9922r9923
36883688      }
36893689   }
36903690
3691   if ( messram_get_size(machine->device("messram")) == 512*1024 || bank < 16 )
3691   if ( ram_get_size(machine->device(RAM_TAG)) == 512*1024 || bank < 16 )
36923692   {
36933693      memory_set_bank( machine, THOM_CART_BANK, bank );
36943694   }
r9922r9923
41604160
41614161   /* memory */
41624162   thom_cart_bank = 0;
4163   thom_vram = messram_get_ptr(machine->device("messram"));
4163   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
41644164   memory_configure_bank( machine, THOM_CART_BANK, 0,  8, mem + 0x10000, 0x4000 );
4165   memory_configure_bank( machine, THOM_CART_BANK, 8, 32, messram_get_ptr(machine->device("messram")), 0x4000 );
4166   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, messram_get_ptr(machine->device("messram")), 0x2000 );
4167   memory_configure_bank( machine, TO8_SYS_LO,     0,  1, messram_get_ptr(machine->device("messram")) + 0x6000, 0x4000 );
4168   memory_configure_bank( machine, TO8_SYS_HI,     0,  1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x4000 );
4169   memory_configure_bank( machine, TO8_DATA_LO,    0, 32, messram_get_ptr(machine->device("messram")) + 0x2000, 0x4000 );
4170   memory_configure_bank( machine, TO8_DATA_HI,    0, 32, messram_get_ptr(machine->device("messram")) + 0x0000, 0x4000 );
4165   memory_configure_bank( machine, THOM_CART_BANK, 8, 32, ram_get_ptr(machine->device(RAM_TAG)), 0x4000 );
4166   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, ram_get_ptr(machine->device(RAM_TAG)), 0x2000 );
4167   memory_configure_bank( machine, TO8_SYS_LO,     0,  1, ram_get_ptr(machine->device(RAM_TAG)) + 0x6000, 0x4000 );
4168   memory_configure_bank( machine, TO8_SYS_HI,     0,  1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x4000 );
4169   memory_configure_bank( machine, TO8_DATA_LO,    0, 32, ram_get_ptr(machine->device(RAM_TAG)) + 0x2000, 0x4000 );
4170   memory_configure_bank( machine, TO8_DATA_HI,    0, 32, ram_get_ptr(machine->device(RAM_TAG)) + 0x0000, 0x4000 );
41714171   memory_configure_bank( machine, TO8_BIOS_BANK,  0,  2, mem + 0x30800, 0x2000 );
41724172   memory_set_bank( machine, THOM_CART_BANK, 0 );
41734173   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
r9922r9923
43304330
43314331   /* memory */
43324332   thom_cart_bank = 0;
4333   thom_vram = messram_get_ptr(machine->device("messram"));
4333   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
43344334   memory_configure_bank( machine, THOM_CART_BANK, 0,  8, mem + 0x10000, 0x4000 );
4335   memory_configure_bank( machine, THOM_CART_BANK, 8, 32, messram_get_ptr(machine->device("messram")), 0x4000 );
4336   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, messram_get_ptr(machine->device("messram")), 0x2000 );
4337   memory_configure_bank( machine, TO8_SYS_LO,     0,  1, messram_get_ptr(machine->device("messram")) + 0x6000, 0x4000 );
4338   memory_configure_bank( machine, TO8_SYS_HI,     0,  1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x4000 );
4339   memory_configure_bank( machine, TO8_DATA_LO,    0, 32, messram_get_ptr(machine->device("messram")) + 0x2000, 0x4000 );
4340   memory_configure_bank( machine, TO8_DATA_HI,    0, 32, messram_get_ptr(machine->device("messram")) + 0x0000, 0x4000 );
4335   memory_configure_bank( machine, THOM_CART_BANK, 8, 32, ram_get_ptr(machine->device(RAM_TAG)), 0x4000 );
4336   memory_configure_bank( machine, THOM_VRAM_BANK, 0,  2, ram_get_ptr(machine->device(RAM_TAG)), 0x2000 );
4337   memory_configure_bank( machine, TO8_SYS_LO,     0,  1, ram_get_ptr(machine->device(RAM_TAG)) + 0x6000, 0x4000 );
4338   memory_configure_bank( machine, TO8_SYS_HI,     0,  1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x4000 );
4339   memory_configure_bank( machine, TO8_DATA_LO,    0, 32, ram_get_ptr(machine->device(RAM_TAG)) + 0x2000, 0x4000 );
4340   memory_configure_bank( machine, TO8_DATA_HI,    0, 32, ram_get_ptr(machine->device(RAM_TAG)) + 0x0000, 0x4000 );
43414341   memory_configure_bank( machine, TO8_BIOS_BANK,  0,  2, mem + 0x30800, 0x2000 );
43424342   memory_set_bank( machine, THOM_CART_BANK, 0 );
43434343   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
r9922r9923
49544954   /* memory */
49554955   thom_cart_bank = 0;
49564956   mo5_reg_cart = 0;
4957   thom_vram = messram_get_ptr(machine->device("messram"));
4957   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
49584958   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
49594959   memory_configure_bank( machine, THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 );
49604960   memory_configure_bank( machine, THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 );
4961   memory_configure_bank( machine, THOM_CART_BANK, 8, 8, messram_get_ptr(machine->device("messram")), 0x4000 );
4962   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, messram_get_ptr(machine->device("messram")), 0x2000 );
4963   memory_configure_bank( machine, TO8_SYS_LO,     0, 1, messram_get_ptr(machine->device("messram")) + 0x6000, 0x4000 );
4964   memory_configure_bank( machine, TO8_SYS_HI,     0, 1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x4000 );
4965   memory_configure_bank( machine, TO8_DATA_LO,    0, 8, messram_get_ptr(machine->device("messram")) + 0x2000, 0x4000 );
4966   memory_configure_bank( machine, TO8_DATA_HI,    0, 8, messram_get_ptr(machine->device("messram")) + 0x0000, 0x4000 );
4961   memory_configure_bank( machine, THOM_CART_BANK, 8, 8, ram_get_ptr(machine->device(RAM_TAG)), 0x4000 );
4962   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, ram_get_ptr(machine->device(RAM_TAG)), 0x2000 );
4963   memory_configure_bank( machine, TO8_SYS_LO,     0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x6000, 0x4000 );
4964   memory_configure_bank( machine, TO8_SYS_HI,     0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x4000 );
4965   memory_configure_bank( machine, TO8_DATA_LO,    0, 8, ram_get_ptr(machine->device(RAM_TAG)) + 0x2000, 0x4000 );
4966   memory_configure_bank( machine, TO8_DATA_HI,    0, 8, ram_get_ptr(machine->device(RAM_TAG)) + 0x0000, 0x4000 );
49674967   memory_configure_bank( machine, TO8_BIOS_BANK,  0, 2, mem + 0x23000, 0x4000 );
49684968   memory_set_bank( machine, THOM_CART_BANK, 0 );
49694969   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
r9922r9923
52145214   /* memory */
52155215   thom_cart_bank = 0;
52165216   mo5_reg_cart = 0;
5217   thom_vram = messram_get_ptr(machine->device("messram"));
5217   thom_vram = ram_get_ptr(machine->device(RAM_TAG));
52185218   memory_configure_bank( machine, THOM_CART_BANK, 0, 4, mem + 0x10000, 0x4000 );
52195219   memory_configure_bank( machine, THOM_CART_BANK, 4, 2, mem + 0x1f000, 0x4000 );
52205220   memory_configure_bank( machine, THOM_CART_BANK, 6, 2, mem + 0x28000, 0x4000 );
5221   memory_configure_bank( machine, THOM_CART_BANK, 8, 8, messram_get_ptr(machine->device("messram")), 0x4000 );
5222   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, messram_get_ptr(machine->device("messram")), 0x2000 );
5223   memory_configure_bank( machine, TO8_SYS_LO,     0, 1, messram_get_ptr(machine->device("messram")) + 0x6000, 0x4000 );
5224   memory_configure_bank( machine, TO8_SYS_HI,     0, 1, messram_get_ptr(machine->device("messram")) + 0x4000, 0x4000 );
5225   memory_configure_bank( machine, TO8_DATA_LO,    0, 8, messram_get_ptr(machine->device("messram")) + 0x2000, 0x4000 );
5226   memory_configure_bank( machine, TO8_DATA_HI,    0, 8, messram_get_ptr(machine->device("messram")) + 0x0000, 0x4000 );
5221   memory_configure_bank( machine, THOM_CART_BANK, 8, 8, ram_get_ptr(machine->device(RAM_TAG)), 0x4000 );
5222   memory_configure_bank( machine, THOM_VRAM_BANK, 0, 2, ram_get_ptr(machine->device(RAM_TAG)), 0x2000 );
5223   memory_configure_bank( machine, TO8_SYS_LO,     0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x6000, 0x4000 );
5224   memory_configure_bank( machine, TO8_SYS_HI,     0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0x4000 );
5225   memory_configure_bank( machine, TO8_DATA_LO,    0, 8, ram_get_ptr(machine->device(RAM_TAG)) + 0x2000, 0x4000 );
5226   memory_configure_bank( machine, TO8_DATA_HI,    0, 8, ram_get_ptr(machine->device(RAM_TAG)) + 0x0000, 0x4000 );
52275227   memory_configure_bank( machine, TO8_BIOS_BANK,  0, 2, mem + 0x23000, 0x4000 );
52285228   memory_set_bank( machine, THOM_CART_BANK, 0 );
52295229   memory_set_bank( machine, THOM_VRAM_BANK, 0 );
src/mess/machine/pmd85.c
r9922r9923
1616#include "includes/pmd85.h"
1717#include "machine/msm8251.h"
1818#include "machine/pit8253.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020
2121
2222
r9922r9923
4444
4545      memory_set_bankptr(machine, "bank1", mem + 0x010000);
4646      memory_set_bankptr(machine, "bank3", mem + 0x010000);
47      memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xc000);
47      memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
4848
4949      memory_set_bankptr(machine, "bank6", mem + 0x010000);
5050      memory_set_bankptr(machine, "bank7", mem + 0x010000);
51      memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0xc000);
51      memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
5252   }
5353   else
5454   {
r9922r9923
6161      memory_install_read_bank(space, 0x1000, 0x1fff, 0, 0, "bank2");
6262      memory_install_read_bank(space, 0x3000, 0x3fff, 0, 0, "bank4");
6363
64      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
65      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x1000);
66      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
67      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x3000);
68      memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x4000);
64      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
65      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x1000);
66      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
67      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x3000);
68      memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
6969   }
7070}
7171
r9922r9923
8282      memory_unmap_write(space, 0x2000, 0x2fff, 0, 0);
8383
8484      memory_set_bankptr(machine, "bank1", mem + 0x010000);
85      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x9000);
85      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x9000);
8686      memory_set_bankptr(machine, "bank3", mem + 0x010000);
87      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xb000);
88      memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xc000);
87      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xb000);
88      memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
8989      memory_set_bankptr(machine, "bank6", mem + 0x010000);
90      memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x9000);
90      memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0x9000);
9191      memory_set_bankptr(machine, "bank8", mem + 0x010000);
92      memory_set_bankptr(machine, "bank9", messram_get_ptr(machine->device("messram")) + 0xb000);
93      memory_set_bankptr(machine, "bank10", messram_get_ptr(machine->device("messram")) + 0xc000);
92      memory_set_bankptr(machine, "bank9", ram_get_ptr(machine->device(RAM_TAG)) + 0xb000);
93      memory_set_bankptr(machine, "bank10", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
9494
9595   }
9696   else
r9922r9923
9898      memory_install_write_bank(space, 0x0000, 0x0fff, 0, 0, "bank1");
9999      memory_install_write_bank(space, 0x2000, 0x2fff, 0, 0, "bank3");
100100
101      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
102      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x1000);
103      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
104      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x5000);
105      memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x4000);
101      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
102      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x1000);
103      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
104      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x5000);
105      memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
106106   }
107107}
108108
r9922r9923
121121      memory_set_bankptr(machine, "bank6", mem + 0x010000);
122122      memory_set_bankptr(machine, "bank7", mem + 0x010000);
123123      memory_set_bankptr(machine, "bank8", mem + 0x010000);
124      memory_set_bankptr(machine, "bank9", messram_get_ptr(machine->device("messram")));
125      memory_set_bankptr(machine, "bank10", messram_get_ptr(machine->device("messram")) + 0x2000);
126      memory_set_bankptr(machine, "bank11", messram_get_ptr(machine->device("messram")) + 0x4000);
127      memory_set_bankptr(machine, "bank12", messram_get_ptr(machine->device("messram")) + 0x6000);
128      memory_set_bankptr(machine, "bank13", messram_get_ptr(machine->device("messram")) + 0x8000);
129      memory_set_bankptr(machine, "bank14", messram_get_ptr(machine->device("messram")) + 0xa000);
130      memory_set_bankptr(machine, "bank15", messram_get_ptr(machine->device("messram")) + 0xc000);
131      memory_set_bankptr(machine, "bank16", messram_get_ptr(machine->device("messram")) + 0xe000);
124      memory_set_bankptr(machine, "bank9", ram_get_ptr(machine->device(RAM_TAG)));
125      memory_set_bankptr(machine, "bank10", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
126      memory_set_bankptr(machine, "bank11", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
127      memory_set_bankptr(machine, "bank12", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
128      memory_set_bankptr(machine, "bank13", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
129      memory_set_bankptr(machine, "bank14", ram_get_ptr(machine->device(RAM_TAG)) + 0xa000);
130      memory_set_bankptr(machine, "bank15", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
131      memory_set_bankptr(machine, "bank16", ram_get_ptr(machine->device(RAM_TAG)) + 0xe000);
132132   }
133133   else
134134   {
135      memory_set_bankptr(machine,  "bank1", messram_get_ptr(machine->device("messram")));
136      memory_set_bankptr(machine,  "bank2", messram_get_ptr(machine->device("messram")) + 0x2000);
137      memory_set_bankptr(machine,  "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
138      memory_set_bankptr(machine,  "bank4", messram_get_ptr(machine->device("messram")) + 0x6000);
139      memory_set_bankptr(machine,  "bank5", messram_get_ptr(machine->device("messram")) + 0x8000);
140      memory_set_bankptr(machine,  "bank6", messram_get_ptr(machine->device("messram")) + 0xa000);
141      memory_set_bankptr(machine,  "bank7", messram_get_ptr(machine->device("messram")) + 0xc000);
142      memory_set_bankptr(machine,  "bank8", state->pmd853_memory_mapping ? machine->region("maincpu")->base() + 0x010000 : messram_get_ptr(machine->device("messram")) + 0xe000);
135      memory_set_bankptr(machine,  "bank1", ram_get_ptr(machine->device(RAM_TAG)));
136      memory_set_bankptr(machine,  "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
137      memory_set_bankptr(machine,  "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
138      memory_set_bankptr(machine,  "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
139      memory_set_bankptr(machine,  "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
140      memory_set_bankptr(machine,  "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0xa000);
141      memory_set_bankptr(machine,  "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
142      memory_set_bankptr(machine,  "bank8", state->pmd853_memory_mapping ? machine->region("maincpu")->base() + 0x010000 : ram_get_ptr(machine->device(RAM_TAG)) + 0xe000);
143143   }
144144}
145145
r9922r9923
158158
159159      memory_set_bankptr(machine, "bank1", mem + 0x010000);
160160      memory_set_bankptr(machine, "bank2", mem + 0x011000);
161      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xc000);
161      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
162162      memory_set_bankptr(machine, "bank5", mem + 0x010000);
163163      memory_set_bankptr(machine, "bank6", mem + 0x011000);
164      memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0xc000);
164      memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
165165   }
166166   else
167167   {
r9922r9923
169169      memory_install_write_bank(space, 0x1000, 0x33ff, 0, 0, "bank2");
170170      memory_install_write_bank(space, 0x3400, 0x3fff, 0, 0, "bank3");
171171
172      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
173      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x1000);
174      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x3400);
175      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
172      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
173      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x1000);
174      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x3400);
175      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
176176   }
177177}
178178
r9922r9923
188188      memory_unmap_write(space, 0x0000, 0x3fff, 0, 0);
189189
190190      memory_set_bankptr(machine, "bank1", mem + 0x010000);
191      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0xc000);
191      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
192192      memory_set_bankptr(machine, "bank3", mem + 0x010000);
193      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xc000);
193      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
194194   }
195195   else
196196   {
197197      memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1");
198198
199      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
200      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
199      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
200      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
201201   }
202202}
203203
r9922r9923
212212      memory_unmap_write(space, 0x0000, 0x3fff, 0, 0);
213213
214214      memory_set_bankptr(machine, "bank1", mem + 0x010000);
215      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
215      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
216216      memory_set_bankptr(machine, "bank3", mem + 0x010000);
217      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xc000);
217      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
218218   }
219219   else
220220   {
221221      memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1");
222      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
223      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
222      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
223      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
224224   }
225225}
226226
r9922r9923
963963         state->ppi_port_outputs[i][j] = 0;
964964
965965   /* memory initialization */
966   memset(messram_get_ptr(machine->device("messram")), 0, sizeof(unsigned char)*0x10000);
966   memset(ram_get_ptr(machine->device(RAM_TAG)), 0, sizeof(unsigned char)*0x10000);
967967   state->pmd853_memory_mapping = 1;
968968   state->startup_mem_map = 1;
969969   state->update_memory(machine);
src/mess/machine/6883sam.c
r9922r9923
5252**********************************************************************/
5353
5454#include "machine/6883sam.h"
55#include "devices/messram.h"
55#include "machine/ram.h"
5656
5757#define LOG_VIDEO_POSITION   0
5858
r9922r9923
223223      logerror("sam_m6847_get_video_ram(): scanline=%d video_position=0x%04X\n", scanline, video_position);
224224
225225   /* return actual position */
226   ram_base = sam->intf->get_rambase ? sam->intf->get_rambase(device) : messram_get_ptr(device->machine->device("messram"));
226   ram_base = sam->intf->get_rambase ? sam->intf->get_rambase(device) : ram_get_ptr(device->machine->device(RAM_TAG));
227227   return &ram_base[video_position];
228228}
229229
src/mess/machine/pet.c
r9922r9923
1616
1717#include "devices/cartslot.h"
1818#include "devices/cassette.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020
2121#define VERBOSE_LEVEL 0
2222#define DBG_LOG( MACHINE, N, M, A ) \
r9922r9923
701701   state->superpet = 0;
702702   state->cbm8096 = 0;
703703
704   memory_install_readwrite_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, messram_get_size(machine->device("messram")) - 1, 0, 0, "bank10");
704   memory_install_readwrite_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank10");
705705   memory_set_bankptr(machine, "bank10", state->memory);
706706
707   if (messram_get_size(machine->device("messram")) < 0x8000)
707   if (ram_get_size(machine->device(RAM_TAG)) < 0x8000)
708708   {
709      memory_nop_readwrite(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), messram_get_size(machine->device("messram")), 0x7FFF, 0, 0);
709      memory_nop_readwrite(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), ram_get_size(machine->device(RAM_TAG)), 0x7FFF, 0, 0);
710710   }
711711
712712   /* 2114 poweron ? 64 x 0xff, 64x 0, and so on */
713   for (i = 0; i < messram_get_size(machine->device("messram")); i += 0x40)
713   for (i = 0; i < ram_get_size(machine->device(RAM_TAG)); i += 0x40)
714714   {
715715      memset (state->memory + i, i & 0x40 ? 0 : 0xff, 0x40);
716716   }
r9922r9923
727727DRIVER_INIT( pet2001 )
728728{
729729   pet_state *state = machine->driver_data<pet_state>();
730   state->memory = messram_get_ptr(machine->device("messram"));
730   state->memory = ram_get_ptr(machine->device(RAM_TAG));
731731   pet_common_driver_init(machine);
732732   state->pet_basic1 = 1;
733733   pet_vh_init(machine);
r9922r9923
736736DRIVER_INIT( pet )
737737{
738738   pet_state *state = machine->driver_data<pet_state>();
739   state->memory = messram_get_ptr(machine->device("messram"));
739   state->memory = ram_get_ptr(machine->device(RAM_TAG));
740740   pet_common_driver_init(machine);
741741   pet_vh_init(machine);
742742}
r9922r9923
756756DRIVER_INIT( superpet )
757757{
758758   pet_state *state = machine->driver_data<pet_state>();
759   state->memory = messram_get_ptr(machine->device("messram"));
759   state->memory = ram_get_ptr(machine->device(RAM_TAG));
760760   pet_common_driver_init(machine);
761761   state->superpet = 1;
762762
src/mess/machine/c16.c
r9922r9923
1414#include "cpu/m6502/m6502.h"
1515#include "devices/cassette.h"
1616#include "devices/cartslot.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818#include "includes/c16.h"
1919#include "machine/cbmiec.h"
2020#include "sound/sid6581.h"
r9922r9923
108108{
109109   c16_state *state = machine->driver_data<c16_state>();
110110   UINT8 *rom = machine->region("maincpu")->base();
111   memory_set_bankptr(machine, "bank9", messram_get_ptr(state->messram));
111   memory_set_bankptr(machine, "bank9", ram_get_ptr(state->messram));
112112
113113   switch (state->lowrom)
114114   {
r9922r9923
185185
186186   ted7360_rom_switch_w(state->ted7360, 0);
187187
188   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(state->messram) + (0x8000 % messram_get_size(state->messram)));
189   memory_set_bankptr(space->machine, "bank3", messram_get_ptr(state->messram) + (0xc000 % messram_get_size(state->messram)));
190   memory_set_bankptr(space->machine, "bank4", messram_get_ptr(state->messram) + (0xfc00 % messram_get_size(state->messram)));
191   memory_set_bankptr(space->machine, "bank8", messram_get_ptr(state->messram) + (0xff20 % messram_get_size(state->messram)));
188   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(state->messram) + (0x8000 % ram_get_size(state->messram)));
189   memory_set_bankptr(space->machine, "bank3", ram_get_ptr(state->messram) + (0xc000 % ram_get_size(state->messram)));
190   memory_set_bankptr(space->machine, "bank4", ram_get_ptr(state->messram) + (0xfc00 % ram_get_size(state->messram)));
191   memory_set_bankptr(space->machine, "bank8", ram_get_ptr(state->messram) + (0xff20 % ram_get_size(state->messram)));
192192}
193193
194194UINT8 c16_read_keyboard( running_machine *machine, int databus )
r9922r9923
336336int c16_dma_read( running_machine *machine, int offset )
337337{
338338   c16_state *state = machine->driver_data<c16_state>();
339   return messram_get_ptr(state->messram)[offset % messram_get_size(state->messram)];
339   return ram_get_ptr(state->messram)[offset % ram_get_size(state->messram)];
340340}
341341
342342int c16_dma_read_rom( running_machine *machine, int offset )
r9922r9923
377377      }
378378   }
379379
380   return messram_get_ptr(state->messram)[offset % messram_get_size(state->messram)];
380   return ram_get_ptr(state->messram)[offset % ram_get_size(state->messram)];
381381}
382382
383383void c16_interrupt( running_machine *machine, int level )
r9922r9923
463463
464464   if (state->pal)
465465   {
466      memory_set_bankptr(machine, "bank1", messram_get_ptr(state->messram) + (0x4000 % messram_get_size(state->messram)));
466      memory_set_bankptr(machine, "bank1", ram_get_ptr(state->messram) + (0x4000 % ram_get_size(state->messram)));
467467
468      memory_set_bankptr(machine, "bank5", messram_get_ptr(state->messram) + (0x4000 % messram_get_size(state->messram)));
469      memory_set_bankptr(machine, "bank6", messram_get_ptr(state->messram) + (0x8000 % messram_get_size(state->messram)));
470      memory_set_bankptr(machine, "bank7", messram_get_ptr(state->messram) + (0xc000 % messram_get_size(state->messram)));
468      memory_set_bankptr(machine, "bank5", ram_get_ptr(state->messram) + (0x4000 % ram_get_size(state->messram)));
469      memory_set_bankptr(machine, "bank6", ram_get_ptr(state->messram) + (0x8000 % ram_get_size(state->messram)));
470      memory_set_bankptr(machine, "bank7", ram_get_ptr(state->messram) + (0xc000 % ram_get_size(state->messram)));
471471
472472      memory_install_write_bank(space, 0xff20, 0xff3d, 0, 0,"bank10");
473473      memory_install_write_bank(space, 0xff40, 0xffff, 0, 0, "bank11");
474      memory_set_bankptr(machine, "bank10", messram_get_ptr(state->messram) + (0xff20 % messram_get_size(state->messram)));
475      memory_set_bankptr(machine, "bank11", messram_get_ptr(state->messram) + (0xff40 % messram_get_size(state->messram)));
474      memory_set_bankptr(machine, "bank10", ram_get_ptr(state->messram) + (0xff20 % ram_get_size(state->messram)));
475      memory_set_bankptr(machine, "bank11", ram_get_ptr(state->messram) + (0xff40 % ram_get_size(state->messram)));
476476   }
477477   else
478478   {
479479      memory_install_write_bank(space, 0x4000, 0xfcff, 0, 0, "bank10");
480      memory_set_bankptr(machine, "bank10", messram_get_ptr(state->messram) + (0x4000 % messram_get_size(state->messram)));
480      memory_set_bankptr(machine, "bank10", ram_get_ptr(state->messram) + (0x4000 % ram_get_size(state->messram)));
481481   }
482482}
483483
r9922r9923
489489{
490490   c16_state *state = space->machine->driver_data<c16_state>();
491491
492   messram_get_ptr(state->messram)[0x1400 + offset] = data;
493   messram_get_ptr(state->messram)[0x5400 + offset] = data;
494   messram_get_ptr(state->messram)[0x9400 + offset] = data;
495   messram_get_ptr(state->messram)[0xd400 + offset] = data;
492   ram_get_ptr(state->messram)[0x1400 + offset] = data;
493   ram_get_ptr(state->messram)[0x5400 + offset] = data;
494   ram_get_ptr(state->messram)[0x9400 + offset] = data;
495   ram_get_ptr(state->messram)[0xd400 + offset] = data;
496496
497497   sid6581_w(state->sid, offset, data);
498498}
r9922r9923
501501{
502502   c16_state *state = space->machine->driver_data<c16_state>();
503503
504   messram_get_ptr(state->messram)[0xd400 + offset] = data;
504   ram_get_ptr(state->messram)[0xd400 + offset] = data;
505505
506506   sid6581_w(state->sid, offset, data);
507507}
src/mess/machine/rt1715.c
r9922r9923
1111#include "cpu/i8085/i8085.h"
1212#include "video/i8275.h"
1313#include "includes/rt1715.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515
1616
1717MACHINE_RESET( rt1715 )
1818{
1919   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
20   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0800);
21   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")));
20   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0800);
21   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)));
2222}
src/mess/machine/at.c
r9922r9923
3333
3434#include "machine/kb_keytro.h"
3535
36#include "devices/messram.h"
36#include "machine/ram.h"
3737
3838#define LOG_PORT80   0
3939#define LOG_KBDC   0
r9922r9923
173173   soundblaster_config(&soundblaster);
174174   kbdc8042_init(machine, at8042);
175175
176   if (messram_get_size(machine->device("messram")) > 0x0a0000)
176   if (ram_get_size(machine->device(RAM_TAG)) > 0x0a0000)
177177   {
178      offs_t ram_limit = 0x100000 + messram_get_size(machine->device("messram")) - 0x0a0000;
178      offs_t ram_limit = 0x100000 + ram_get_size(machine->device(RAM_TAG)) - 0x0a0000;
179179      memory_install_read_bank(space, 0x100000,  ram_limit - 1, 0, 0, "bank1");
180180      memory_install_write_bank(space, 0x100000,  ram_limit - 1, 0, 0, "bank1");
181      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0xa0000);
181      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0xa0000);
182182   }
183183}
184184
r9922r9923
420420{
421421   at_state *st = machine->driver_data<at_state>();
422422   pic8259_ir6_w(st->pic8259_master, state);
423//if ( messram_get_ptr(machine->device("messram"))[0x0490] == 0x74 )
424//  messram_get_ptr(machine->device("messram"))[0x0490] = 0x54;
423//if ( ram_get_ptr(machine->device(RAM_TAG))[0x0490] == 0x74 )
424//  ram_get_ptr(machine->device(RAM_TAG))[0x0490] = 0x54;
425425}
426426
427427
src/mess/machine/vector06.c
r9922r9923
1313#include "machine/wd17xx.h"
1414#include "devices/cassette.h"
1515#include "includes/vector06.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717
1818
1919
r9922r9923
161161      machine->device("maincpu")->reset();
162162   }
163163   if ((val & 2)==2) {
164      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
164      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
165165      machine->device("maincpu")->reset();
166166   }
167167}
r9922r9923
190190   memory_install_write_bank(space, 0x8000, 0xffff, 0, 0, "bank4");
191191
192192   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
193   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
194   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x8000);
195   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x8000);
193   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
194   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
195   memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
196196
197197   state->keyboard_mask = 0;
198198   state->color_index = 0;
src/mess/machine/orion.c
r9922r9923
1717#include "sound/ay8910.h"
1818#include "includes/orion.h"
1919#include "includes/radio86.h"
20#include "devices/messram.h"
20#include "machine/ram.h"
2121
2222#define SCREEN_WIDTH_384 48
2323#define SCREEN_WIDTH_480 60
r9922r9923
158158   orion_state *state = space->machine->driver_data<orion_state>();
159159   if (data!=state->orion128_memory_page )
160160   {
161      memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")) + (data & 3) * 0x10000);
161      memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)) + (data & 3) * 0x10000);
162162      state->orion128_memory_page = (data & 3);
163163   }
164164}
r9922r9923
170170   state->orion128_video_mode = 0;
171171   state->orion128_memory_page = -1;
172172   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0xf800);
173   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0xf000);
173   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0xf000);
174174   state->orion128_video_width = SCREEN_WIDTH_384;
175175   orion_set_video_mode(machine,384);
176176   radio86_init_keyboard(machine);
r9922r9923
288288   memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1");
289289   if ((state->orionz80_dispatcher & 0x80)==0)
290290   { // dispatcher on
291      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * bank_select + segment_select * 0x4000 );
291      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * bank_select + segment_select * 0x4000 );
292292   }
293293   else
294294   { // dispatcher off
295      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * state->orionz80_memory_page);
295      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * state->orionz80_memory_page);
296296   }
297297
298   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000 + 0x10000 * state->orionz80_memory_page);
298   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000 + 0x10000 * state->orionz80_memory_page);
299299
300300   if ((state->orionz80_dispatcher & 0x20) == 0)
301301   {
r9922r9923
313313      memory_unmap_write(space, 0xfc00, 0xfeff, 0, 0);
314314      memory_install_write8_handler(space, 0xff00, 0xffff, 0, 0, orionz80_sound_w);
315315
316      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf000);
316      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xf000);
317317      memory_set_bankptr(machine, "bank5", machine->region("maincpu")->base() + 0xf800);
318318
319319   }
320320   else
321321   {
322322      /* if it is full memory access */
323      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf000 + 0x10000 * state->orionz80_memory_page);
324      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xf400 + 0x10000 * state->orionz80_memory_page);
325      memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800 + 0x10000 * state->orionz80_memory_page);
323      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xf000 + 0x10000 * state->orionz80_memory_page);
324      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xf400 + 0x10000 * state->orionz80_memory_page);
325      memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800 + 0x10000 * state->orionz80_memory_page);
326326   }
327327}
328328
r9922r9923
365365
366366
367367   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0xf800);
368   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
369   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf000);
368   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
369   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xf000);
370370   memory_set_bankptr(machine, "bank5", machine->region("maincpu")->base() + 0xf800);
371371
372372
r9922r9923
447447
448448   if ((state->orionpro_dispatcher & 0x01)==0x00)
449449   {   // RAM0 segment disabled
450      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * page);
451      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0x2000);
450      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page);
451      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0x2000);
452452   }
453453   else
454454   {
455      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram0_segment & 31) * 0x4000);
456      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram0_segment & 31) * 0x4000 + 0x2000);
455      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + (state->orionpro_ram0_segment & 31) * 0x4000);
456      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + (state->orionpro_ram0_segment & 31) * 0x4000 + 0x2000);
457457   }
458458   if ((state->orionpro_dispatcher & 0x10)==0x10)
459459   {   // ROM1 enabled
r9922r9923
468468
469469   if ((state->orionpro_dispatcher & 0x02)==0x00)
470470   {   // RAM1 segment disabled
471      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0x4000);
471      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0x4000);
472472   }
473473   else
474474   {
475      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram1_segment & 31) * 0x4000);
475      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + (state->orionpro_ram1_segment & 31) * 0x4000);
476476   }
477477
478478   if ((state->orionpro_dispatcher & 0x04)==0x00)
479479   {   // RAM2 segment disabled
480      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0x8000);
480      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0x8000);
481481   }
482482   else
483483   {
484      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram2_segment & 31) * 0x4000);
484      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + (state->orionpro_ram2_segment & 31) * 0x4000);
485485   }
486486
487   memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0xc000);
487   memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0xc000);
488488
489489   if (is128)
490490   {
491      memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf000);
491      memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * 0 + 0xf000);
492492
493493      memory_install_write8_handler(space, 0xf400, 0xf4ff, 0, 0, orion128_system_w);
494494      memory_install_write8_handler(space, 0xf500, 0xf5ff, 0, 0, orion128_romdisk_w);
r9922r9923
506506      memory_install_write8_handler(space, 0xff00, 0xffff, 0, 0, orionz80_sound_w);
507507
508508
509      memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf800);
509      memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * 0 + 0xf800);
510510   }
511511   else
512512   {
513513      if ((state->orionpro_dispatcher & 0x40)==0x40)
514514      {   // FIX F000 enabled
515         memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf000);
516         memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf400);
517         memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf800);
515         memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * 0 + 0xf000);
516         memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * 0 + 0xf400);
517         memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * 0 + 0xf800);
518518      }
519519      else
520520      {
521         memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0xf000);
522         memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0xf400);
523         memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0xf800);
521         memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0xf000);
522         memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0xf400);
523         memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000 * page + 0xf800);
524524      }
525525   }
526526}
src/mess/machine/nascom1.c
r9922r9923
1717#include "devices/snapquik.h"
1818#include "devices/cassette.h"
1919#include "devices/flopdrv.h"
20#include "devices/messram.h"
20#include "machine/ram.h"
2121
2222#define NASCOM1_KEY_RESET   0x02
2323#define NASCOM1_KEY_INCR   0x01
r9922r9923
271271
272272DRIVER_INIT( nascom1 )
273273{
274   switch (messram_get_size(machine->device("messram")))
274   switch (ram_get_size(machine->device(RAM_TAG)))
275275   {
276276   case 1 * 1024:
277277      memory_nop_readwrite(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
r9922r9923
283283         0x1400, 0x4fff, 0, 0, "bank1");
284284      memory_nop_readwrite(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
285285         0x5000, 0xafff, 0, 0);
286      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
286      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
287287      break;
288288
289289   case 32 * 1024:
r9922r9923
291291         0x1400, 0x8fff, 0, 0, "bank1");
292292      memory_nop_readwrite(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
293293         0x9000, 0xafff, 0, 0);
294      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
294      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
295295      break;
296296
297297   case 40 * 1024:
298298      memory_install_readwrite_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
299299         0x1400, 0xafff, 0, 0, "bank1");
300      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
300      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
301301      break;
302302   }
303303}
src/mess/machine/osborne1.c
r9922r9923
2323#include "sound/beep.h"
2424#include "includes/osborne1.h"
2525#include "devices/flopdrv.h"
26#include "devices/messram.h"
26#include "machine/ram.h"
2727
2828#define RAMMODE      (0x01)
2929
r9922r9923
3434   /* Check whether regular RAM is enabled */
3535   if ( ! state->bank2_enabled || ( state->in_irq_handler && state->bankswitch == RAMMODE ) )
3636   {
37      messram_get_ptr(space->machine->device("messram"))[ offset ] = data;
37      ram_get_ptr(space->machine->device(RAM_TAG))[ offset ] = data;
3838   }
3939}
4040
r9922r9923
4545   /* Check whether regular RAM is enabled */
4646   if ( ! state->bank2_enabled || ( state->in_irq_handler && state->bankswitch == RAMMODE ) )
4747   {
48      messram_get_ptr(space->machine->device("messram"))[ 0x1000 + offset ] = data;
48      ram_get_ptr(space->machine->device(RAM_TAG))[ 0x1000 + offset ] = data;
4949   }
5050}
5151
r9922r9923
6161   /* Check whether regular RAM is enabled */
6262   if ( ! state->bank2_enabled )
6363   {
64      data = messram_get_ptr(space->machine->device("messram"))[ 0x2000 + offset ];
64      data = ram_get_ptr(space->machine->device(RAM_TAG))[ 0x2000 + offset ];
6565   }
6666   else
6767   {
r9922r9923
112112   /* Check whether regular RAM is enabled */
113113   if ( ! state->bank2_enabled )
114114   {
115      messram_get_ptr(space->machine->device("messram"))[ 0x2000 + offset ] = data;
115      ram_get_ptr(space->machine->device(RAM_TAG))[ 0x2000 + offset ] = data;
116116   }
117117   else
118118   {
119119      if ( state->in_irq_handler && state->bankswitch == RAMMODE )
120120      {
121         messram_get_ptr(space->machine->device("messram"))[ 0x2000 + offset ] = data;
121         ram_get_ptr(space->machine->device(RAM_TAG))[ 0x2000 + offset ] = data;
122122      }
123123      /* Handle writes to the I/O area */
124124      switch( offset & 0x0F00 )
r9922r9923
145145   /* Check whether regular RAM is enabled */
146146   if ( ! state->bank2_enabled || ( state->in_irq_handler && state->bankswitch == RAMMODE ) )
147147   {
148      messram_get_ptr(space->machine->device("messram"))[ 0x3000 + offset ] = data;
148      ram_get_ptr(space->machine->device(RAM_TAG))[ 0x3000 + offset ] = data;
149149   }
150150}
151151
r9922r9923
192192   }
193193   else
194194   {
195      memory_set_bankptr(space->machine,"bank1", messram_get_ptr(space->machine->device("messram")) );
196      memory_set_bankptr(space->machine,"bank2", messram_get_ptr(space->machine->device("messram")) + 0x1000 );
197      memory_set_bankptr(space->machine,"bank3", messram_get_ptr(space->machine->device("messram")) + 0x3000 );
195      memory_set_bankptr(space->machine,"bank1", ram_get_ptr(space->machine->device(RAM_TAG)) );
196      memory_set_bankptr(space->machine,"bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x1000 );
197      memory_set_bankptr(space->machine,"bank3", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x3000 );
198198   }
199   state->bank4_ptr = messram_get_ptr(space->machine->device("messram")) + ( ( state->bank3_enabled ) ? 0x10000 : 0xF000 );
199   state->bank4_ptr = ram_get_ptr(space->machine->device(RAM_TAG)) + ( ( state->bank3_enabled ) ? 0x10000 : 0xF000 );
200200   memory_set_bankptr(space->machine,"bank4", state->bank4_ptr );
201201   state->bankswitch = offset;
202202   state->in_irq_handler = 0;
r9922r9923
210210   {
211211      if ( ! state->bank2_enabled )
212212      {
213         direct.explicit_configure(0x2000, 0x2fff, 0x0fff, messram_get_ptr(machine->device("messram")) + 0x2000);
213         direct.explicit_configure(0x2000, 0x2fff, 0x0fff, ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
214214         return ~0;
215215      }
216216   }
r9922r9923
363363
364364      for ( x = 0; x < 52; x++ )
365365      {
366         UINT8   character = messram_get_ptr(machine->device("messram"))[ 0xF000 + ( ( address + x ) & 0xFFF ) ];
366         UINT8   character = ram_get_ptr(machine->device(RAM_TAG))[ 0xF000 + ( ( address + x ) & 0xFFF ) ];
367367         UINT8   cursor = character & 0x80;
368         UINT8   dim = messram_get_ptr(machine->device("messram"))[ 0x10000 + ( ( address + x ) & 0xFFF ) ] & 0x80;
368         UINT8   dim = ram_get_ptr(machine->device(RAM_TAG))[ 0x10000 + ( ( address + x ) & 0xFFF ) ] & 0x80;
369369         UINT8   bits = state->charrom[ state->charline * 128 + ( character & 0x7F ) ];
370370         int      bit;
371371
r9922r9923
451451
452452   state->charrom = machine->region( "gfx1" )->base();
453453
454   memset( messram_get_ptr(machine->device("messram")) + 0x10000, 0xFF, 0x1000 );
454   memset( ram_get_ptr(machine->device(RAM_TAG)) + 0x10000, 0xFF, 0x1000 );
455455
456456   for(drive=0;drive<2;drive++)
457457   {
src/mess/machine/amstrad.c
r9922r9923
4545#include "devices/snapquik.h"
4646#include "includes/amstrad.h"
4747#include "sound/ay8910.h"
48#include "devices/messram.h"
48#include "machine/ram.h"
4949
5050#define MANUFACTURER_NAME 0x07
5151#define TV_REFRESH_RATE 0x10
r9922r9923
507507      }
508508      return;
509509   }
510   command = (messram_get_ptr(machine->device("messram"))[state->asic.dma_addr[channel]+1] << 8) + messram_get_ptr(machine->device("messram"))[state->asic.dma_addr[channel]];
510   command = (ram_get_ptr(machine->device(RAM_TAG))[state->asic.dma_addr[channel]+1] << 8) + ram_get_ptr(machine->device(RAM_TAG))[state->asic.dma_addr[channel]];
511511//  logerror("DMA #%i: address %04x: command %04x\n",channel,state->asic.dma_addr[channel],command);
512512   switch (command & 0xf000)
513513   {
r9922r9923
615615      state->gate_array.address = ( ( state->gate_array.ma & 0x2000 ) << 2 ) | ( ( state->gate_array.ra & 0x06 ) << 11 ) | ( ( state->gate_array.ra & 0x01 ) << 14 ) | ( ( state->gate_array.ma & 0x7ff ) << 1 );
616616   else
617617      state->gate_array.address = ( ( state->gate_array.ma & 0x3000 ) << 2 ) | ( ( state->gate_array.ra & 0x07 ) << 11 ) | ( ( state->gate_array.ma & 0x3ff ) << 1 );
618   state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address ];
618   state->gate_array.data = ram_get_ptr(machine->device(RAM_TAG))[ state->gate_array.address ];
619619   state->gate_array.colour = state->GateArray_render_colours[ state->gate_array.mode_lookup[state->gate_array.data] ];
620620   state->gate_array.colour_ticks = state->gate_array.max_colour_ticks;
621621   state->gate_array.ticks = 0;
r9922r9923
651651            switch( state->gate_array.ticks)
652652            {
653653            case 8:
654               state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address + 1 ];
654               state->gate_array.data = ram_get_ptr(machine->device(RAM_TAG))[ state->gate_array.address + 1 ];
655655               state->gate_array.colour = state->GateArray_render_colours[ state->gate_array.mode_lookup[state->gate_array.data] ];
656656               break;
657657            case 16:
r9922r9923
687687      ma += state->asic.horiz_disp;
688688   }
689689   state->gate_array.address = ( ( ma & 0x3000 ) << 2 ) | ( ( state->gate_array.ra & 0x07 ) << 11 ) | ( ( ma & 0x3ff ) << 1 );
690   state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address ];
690   state->gate_array.data = ram_get_ptr(machine->device(RAM_TAG))[ state->gate_array.address ];
691691   caddr = 0x2400 + state->gate_array.mode_lookup[state->gate_array.data] * 2;
692692   state->gate_array.colour = state->asic.ram[caddr] + ( state->asic.ram[caddr+1] << 8 );
693693   state->gate_array.colour_ticks = state->gate_array.max_colour_ticks;
r9922r9923
739739                  {
740740                     UINT16 caddr;
741741
742                     state->gate_array.data = messram_get_ptr(machine->device("messram"))[ state->gate_array.address + 1 ];
742                     state->gate_array.data = ram_get_ptr(machine->device(RAM_TAG))[ state->gate_array.address + 1 ];
743743                     caddr = 0x2400 + state->gate_array.mode_lookup[state->gate_array.data] * 2;
744744                     state->gate_array.colour = state->asic.ram[caddr] + ( state->asic.ram[caddr+1] << 8 );
745745                  }
r9922r9923
15501550       for (i=0;i<4;i++)
15511551      {
15521552         BankIndex = RamConfigurations[(ConfigurationIndex << 2) + i];
1553         BankAddr = messram_get_ptr(machine->device("messram")) + (BankIndex << 14);
1553         BankAddr = ram_get_ptr(machine->device(RAM_TAG)) + (BankIndex << 14);
15541554         state->Aleste_RamBanks[i] = BankAddr;
15551555         state->AmstradCPC_RamBanks[i] = BankAddr;
15561556      }
r9922r9923
19621962      switch(page)
19631963      {
19641964      case 0:  /* 0x0000 - 0x3fff */
1965         memory_set_bankptr(space->machine,"bank1",messram_get_ptr(space->machine->device("messram"))+ramptr);
1966         memory_set_bankptr(space->machine,"bank2",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1967         memory_set_bankptr(space->machine,"bank9",messram_get_ptr(space->machine->device("messram"))+ramptr);
1968         memory_set_bankptr(space->machine,"bank10",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1969         state->Aleste_RamBanks[0] = messram_get_ptr(space->machine->device("messram"))+ramptr;
1965         memory_set_bankptr(space->machine,"bank1",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1966         memory_set_bankptr(space->machine,"bank2",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1967         memory_set_bankptr(space->machine,"bank9",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1968         memory_set_bankptr(space->machine,"bank10",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1969         state->Aleste_RamBanks[0] = ram_get_ptr(space->machine->device(RAM_TAG))+ramptr;
19701970         state->aleste_active_page[0] = data;
19711971         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x0000\n",ramptr,rampage);
19721972         break;
19731973      case 1:  /* 0x4000 - 0x7fff */
1974         memory_set_bankptr(space->machine,"bank3",messram_get_ptr(space->machine->device("messram"))+ramptr);
1975         memory_set_bankptr(space->machine,"bank4",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1976         memory_set_bankptr(space->machine,"bank11",messram_get_ptr(space->machine->device("messram"))+ramptr);
1977         memory_set_bankptr(space->machine,"bank12",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1978         state->Aleste_RamBanks[1] = messram_get_ptr(space->machine->device("messram"))+ramptr;
1974         memory_set_bankptr(space->machine,"bank3",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1975         memory_set_bankptr(space->machine,"bank4",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1976         memory_set_bankptr(space->machine,"bank11",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1977         memory_set_bankptr(space->machine,"bank12",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1978         state->Aleste_RamBanks[1] = ram_get_ptr(space->machine->device(RAM_TAG))+ramptr;
19791979         state->aleste_active_page[1] = data;
19801980         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x4000\n",ramptr,rampage);
19811981         break;
19821982      case 2:  /* 0x8000 - 0xbfff */
1983         memory_set_bankptr(space->machine,"bank5",messram_get_ptr(space->machine->device("messram"))+ramptr);
1984         memory_set_bankptr(space->machine,"bank6",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1985         memory_set_bankptr(space->machine,"bank13",messram_get_ptr(space->machine->device("messram"))+ramptr);
1986         memory_set_bankptr(space->machine,"bank14",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1987         state->Aleste_RamBanks[2] = messram_get_ptr(space->machine->device("messram"))+ramptr;
1983         memory_set_bankptr(space->machine,"bank5",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1984         memory_set_bankptr(space->machine,"bank6",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1985         memory_set_bankptr(space->machine,"bank13",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1986         memory_set_bankptr(space->machine,"bank14",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1987         state->Aleste_RamBanks[2] = ram_get_ptr(space->machine->device(RAM_TAG))+ramptr;
19881988         state->aleste_active_page[2] = data;
19891989         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x8000\n",ramptr,rampage);
19901990         break;
19911991      case 3:  /* 0xc000 - 0xffff */
1992         memory_set_bankptr(space->machine,"bank7",messram_get_ptr(space->machine->device("messram"))+ramptr);
1993         memory_set_bankptr(space->machine,"bank8",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1994         memory_set_bankptr(space->machine,"bank15",messram_get_ptr(space->machine->device("messram"))+ramptr);
1995         memory_set_bankptr(space->machine,"bank16",messram_get_ptr(space->machine->device("messram"))+ramptr+0x2000);
1996         state->Aleste_RamBanks[3] = messram_get_ptr(space->machine->device("messram"))+ramptr;
1992         memory_set_bankptr(space->machine,"bank7",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1993         memory_set_bankptr(space->machine,"bank8",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1994         memory_set_bankptr(space->machine,"bank15",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr);
1995         memory_set_bankptr(space->machine,"bank16",ram_get_ptr(space->machine->device(RAM_TAG))+ramptr+0x2000);
1996         state->Aleste_RamBanks[3] = ram_get_ptr(space->machine->device(RAM_TAG))+ramptr;
19971997         state->aleste_active_page[3] = data;
19981998         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0xc000\n",ramptr,rampage);
19991999         break;
r9922r9923
25002500         MemorySize = 64*1024;
25012501      }
25022502
2503      memcpy(messram_get_ptr(machine->device("messram")), &pSnapshot[0x0100], MemorySize);
2503      memcpy(ram_get_ptr(machine->device(RAM_TAG)), &pSnapshot[0x0100], MemorySize);
25042504   }
25052505   amstrad_rethinkMemory(machine);
25062506}
src/mess/machine/llc.c
r9922r9923
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
1212#include "includes/llc.h"
13#include "devices/messram.h"
13#include "machine/ram.h"
1414
1515
1616
r9922r9923
107107DRIVER_INIT(llc2)
108108{
109109   llc_state *state = machine->driver_data<llc_state>();
110   state->video_ram = messram_get_ptr(machine->device("messram")) + 0xc000;
110   state->video_ram = ram_get_ptr(machine->device(RAM_TAG)) + 0xc000;
111111}
112112
113113MACHINE_RESET( llc2 )
r9922r9923
124124   memory_set_bankptr(machine, "bank3", machine->region("maincpu")->base() + 0x6000);
125125
126126   memory_install_write_bank(space, 0xc000, 0xffff, 0, 0, "bank4");
127   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xc000);
127   memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
128128
129129}
130130
r9922r9923
133133   address_space *mem_space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
134134
135135   memory_install_write_bank(mem_space, 0x0000, 0xbfff, 0, 0, "bank1");
136   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
136   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
137137
138138   memory_install_write_bank(mem_space, 0x4000, 0x5fff, 0, 0, "bank2");
139   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0x4000);
139   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x4000);
140140
141141   memory_install_write_bank(mem_space, 0x6000, 0xbfff, 0, 0, "bank3");
142   memory_set_bankptr(space->machine, "bank3", messram_get_ptr(space->machine->device("messram")) + 0x6000);
142   memory_set_bankptr(space->machine, "bank3", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x6000);
143143
144144   memory_install_write_bank(mem_space, 0xc000, 0xffff, 0, 0, "bank4");
145   memory_set_bankptr(space->machine, "bank4", messram_get_ptr(space->machine->device("messram")) + 0xc000);
145   memory_set_bankptr(space->machine, "bank4", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xc000);
146146
147147}
148148
r9922r9923
155155      memory_set_bankptr(space->machine, "bank2", space->machine->region("maincpu")->base() + 0x10000);
156156   } else {
157157      memory_install_write_bank(mem_space, 0x4000, 0x5fff, 0, 0, "bank2");
158      memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0x4000);
158      memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x4000);
159159   }
160160
161161}
src/mess/machine/samcoupe.c
r9922r9923
77#include "emu.h"
88#include "includes/samcoupe.h"
99#include "machine/msm6242.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111
1212/***************************************************************************
1313    CONSTANTS
r9922r9923
4848   UINT8 *mem;
4949
5050   /* bank 3 */
51   if (state->lext >> 6 < messram_get_size(space->machine->device("messram")) >> 20)
52      mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (state->lext >> 6) * 0x100000 + (state->lext & 0x3f) * 0x4000];
51   if (state->lext >> 6 < ram_get_size(space->machine->device(RAM_TAG)) >> 20)
52      mem = &ram_get_ptr(space->machine->device(RAM_TAG))[(ram_get_size(space->machine->device(RAM_TAG)) & 0xfffff) + (state->lext >> 6) * 0x100000 + (state->lext & 0x3f) * 0x4000];
5353   else
5454      mem = NULL;
5555
5656   samcoupe_update_bank(space, 3, mem, FALSE);
5757
5858   /* bank 4 */
59   if (state->hext >> 6 < messram_get_size(space->machine->device("messram")) >> 20)
60      mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (state->hext >> 6) * 0x100000 + (state->hext & 0x3f) * 0x4000];
59   if (state->hext >> 6 < ram_get_size(space->machine->device(RAM_TAG)) >> 20)
60      mem = &ram_get_ptr(space->machine->device(RAM_TAG))[(ram_get_size(space->machine->device(RAM_TAG)) & 0xfffff) + (state->hext >> 6) * 0x100000 + (state->hext & 0x3f) * 0x4000];
6161   else
6262      mem = NULL;
6363
r9922r9923
6868void samcoupe_update_memory(address_space *space)
6969{
7070   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
71   const int PAGE_MASK = ((messram_get_size(space->machine->device("messram")) & 0xfffff) / 0x4000) - 1;
71   const int PAGE_MASK = ((ram_get_size(space->machine->device(RAM_TAG)) & 0xfffff) / 0x4000) - 1;
7272   UINT8 *rom = space->machine->region("maincpu")->base();
7373   UINT8 *memory;
7474   int is_readonly;
r9922r9923
7777    if (state->lmpr & LMPR_RAM0)   /* Is ram paged in at bank 1 */
7878   {
7979      if ((state->lmpr & 0x1F) <= PAGE_MASK)
80         memory = &messram_get_ptr(space->machine->device("messram"))[(state->lmpr & PAGE_MASK) * 0x4000];
80         memory = &ram_get_ptr(space->machine->device(RAM_TAG))[(state->lmpr & PAGE_MASK) * 0x4000];
8181      else
8282         memory = NULL;   /* Attempt to page in non existant ram region */
8383      is_readonly = FALSE;
r9922r9923
9292
9393   /* BANK2 */
9494   if (((state->lmpr + 1) & 0x1f) <= PAGE_MASK)
95      memory = &messram_get_ptr(space->machine->device("messram"))[((state->lmpr + 1) & PAGE_MASK) * 0x4000];
95      memory = &ram_get_ptr(space->machine->device(RAM_TAG))[((state->lmpr + 1) & PAGE_MASK) * 0x4000];
9696   else
9797      memory = NULL;   /* Attempt to page in non existant ram region */
9898   samcoupe_update_bank(space, 2, memory, FALSE);
r9922r9923
106106   {
107107      /* BANK3 */
108108      if ((state->hmpr & 0x1F) <= PAGE_MASK )
109         memory = &messram_get_ptr(space->machine->device("messram"))[(state->hmpr & PAGE_MASK)*0x4000];
109         memory = &ram_get_ptr(space->machine->device(RAM_TAG))[(state->hmpr & PAGE_MASK)*0x4000];
110110      else
111111         memory = NULL;   /* Attempt to page in non existant ram region */
112112      samcoupe_update_bank(space, 3, memory, FALSE);
r9922r9923
121121      else
122122      {
123123         if (((state->hmpr + 1) & 0x1f) <= PAGE_MASK)
124            memory = &messram_get_ptr(space->machine->device("messram"))[((state->hmpr + 1) & PAGE_MASK) * 0x4000];
124            memory = &ram_get_ptr(space->machine->device(RAM_TAG))[((state->hmpr + 1) & PAGE_MASK) * 0x4000];
125125         else
126126            memory = NULL;   /* Attempt to page in non existant ram region */
127127         is_readonly = FALSE;
r9922r9923
131131
132132   /* video memory location */
133133   if (state->vmpr & 0x40)   /* if bit set in 2 bank screen mode */
134      state->videoram = &messram_get_ptr(space->machine->device("messram"))[((state->vmpr & 0x1e) & PAGE_MASK) * 0x4000];
134      state->videoram = &ram_get_ptr(space->machine->device(RAM_TAG))[((state->vmpr & 0x1e) & PAGE_MASK) * 0x4000];
135135   else
136      state->videoram = &messram_get_ptr(space->machine->device("messram"))[((state->vmpr & 0x1f) & PAGE_MASK) * 0x4000];
136      state->videoram = &ram_get_ptr(space->machine->device(RAM_TAG))[((state->vmpr & 0x1f) & PAGE_MASK) * 0x4000];
137137}
138138
139139
src/mess/machine/comx35.c
r9922r9923
124124#include "includes/comx35.h"
125125#include "machine/rescap.h"
126126#include "devices/flopdrv.h"
127#include "devices/messram.h"
127#include "machine/ram.h"
128128
129129enum
130130{
r9922r9923
599599   memory_configure_bank(machine, "bank1", BANK_PRINTER_THERMAL, 1, machine->region("thermal")->base(), 0);
600600   memory_configure_bank(machine, "bank1", BANK_JOYCARD, 1, machine->region(CDP1802_TAG)->base(), 0);
601601   memory_configure_bank(machine, "bank1", BANK_80_COLUMNS, 1, machine->region("80column")->base(), 0);
602   memory_configure_bank(machine, "bank1", BANK_RAMCARD, 4, messram_get_ptr(m_ram), 0x2000);
602   memory_configure_bank(machine, "bank1", BANK_RAMCARD, 4, ram_get_ptr(m_ram), 0x2000);
603603
604604   memory_set_bank(machine, "bank1", 0);
605605
src/mess/machine/svi318.c
r9922r9923
1919#include "formats/svi_cas.h"
2020#include "sound/dac.h"
2121#include "sound/ay8910.h"
22#include "devices/messram.h"
22#include "machine/ram.h"
2323
2424enum {
2525   SVI_INTERNAL   = 0,
r9922r9923
717717      }
718718      break;
719719   case SVI_EXPRAM2:
720      if ( messram_get_size(machine->device("messram")) >= 64 * 1024 )
720      if ( ram_get_size(machine->device(RAM_TAG)) >= 64 * 1024 )
721721      {
722         state->svi.bankLow_ptr = messram_get_ptr(machine->device("messram")) + messram_get_size(machine->device("messram")) - 64 * 1024;
722         state->svi.bankLow_ptr = ram_get_ptr(machine->device(RAM_TAG)) + ram_get_size(machine->device(RAM_TAG)) - 64 * 1024;
723723         state->svi.bankLow_read_only = 0;
724724      }
725725      break;
726726   case SVI_EXPRAM3:
727      if ( messram_get_size(machine->device("messram")) > 128 * 1024 )
727      if ( ram_get_size(machine->device(RAM_TAG)) > 128 * 1024 )
728728      {
729         state->svi.bankLow_ptr = messram_get_ptr(machine->device("messram")) + messram_get_size(machine->device("messram")) - 128 * 1024;
729         state->svi.bankLow_ptr = ram_get_ptr(machine->device(RAM_TAG)) + ram_get_size(machine->device(RAM_TAG)) - 128 * 1024;
730730         state->svi.bankLow_read_only = 0;
731731      }
732732      break;
r9922r9923
738738   switch( state->svi.bankHigh1 )
739739   {
740740   case SVI_INTERNAL:
741      if ( messram_get_size(machine->device("messram")) == 16 * 1024 )
741      if ( ram_get_size(machine->device(RAM_TAG)) == 16 * 1024 )
742742      {
743         state->svi.bankHigh2_ptr = messram_get_ptr(machine->device("messram"));
743         state->svi.bankHigh2_ptr = ram_get_ptr(machine->device(RAM_TAG));
744744         state->svi.bankHigh2_read_only = 0;
745745      }
746746      else
747747      {
748         state->svi.bankHigh1_ptr = messram_get_ptr(machine->device("messram"));
748         state->svi.bankHigh1_ptr = ram_get_ptr(machine->device(RAM_TAG));
749749         state->svi.bankHigh1_read_only = 0;
750         state->svi.bankHigh2_ptr = messram_get_ptr(machine->device("messram")) + 0x4000;
750         state->svi.bankHigh2_ptr = ram_get_ptr(machine->device(RAM_TAG)) + 0x4000;
751751         state->svi.bankHigh2_read_only = 0;
752752      }
753753      break;
754754   case SVI_EXPRAM2:
755      if ( messram_get_size(machine->device("messram")) > 64 * 1024 )
755      if ( ram_get_size(machine->device(RAM_TAG)) > 64 * 1024 )
756756      {
757         state->svi.bankHigh1_ptr = messram_get_ptr(machine->device("messram")) + messram_get_size(machine->device("messram")) - 64 * 1024 + 32 * 1024;
757         state->svi.bankHigh1_ptr = ram_get_ptr(machine->device(RAM_TAG)) + ram_get_size(machine->device(RAM_TAG)) - 64 * 1024 + 32 * 1024;
758758         state->svi.bankHigh1_read_only = 0;
759         state->svi.bankHigh2_ptr = messram_get_ptr(machine->device("messram")) + messram_get_size(machine->device("messram")) - 64 * 1024 + 48 * 1024;
759         state->svi.bankHigh2_ptr = ram_get_ptr(machine->device(RAM_TAG)) + ram_get_size(machine->device(RAM_TAG)) - 64 * 1024 + 48 * 1024;
760760         state->svi.bankHigh2_read_only = 0;
761761      }
762762      break;
763763   case SVI_EXPRAM3:
764      if ( messram_get_size(machine->device("messram")) > 128 * 1024 )
764      if ( ram_get_size(machine->device(RAM_TAG)) > 128 * 1024 )
765765      {
766         state->svi.bankHigh1_ptr = messram_get_ptr(machine->device("messram")) + messram_get_size(machine->device("messram")) - 128 * 1024 + 32 * 1024;
766         state->svi.bankHigh1_ptr = ram_get_ptr(machine->device(RAM_TAG)) + ram_get_size(machine->device(RAM_TAG)) - 128 * 1024 + 32 * 1024;
767767         state->svi.bankHigh1_read_only = 0;
768         state->svi.bankHigh2_ptr = messram_get_ptr(machine->device("messram")) + messram_get_size(machine->device("messram")) - 128 * 1024 + 48 * 1024;
768         state->svi.bankHigh2_ptr = ram_get_ptr(machine->device(RAM_TAG)) + ram_get_size(machine->device(RAM_TAG)) - 128 * 1024 + 48 * 1024;
769769         state->svi.bankHigh2_read_only = 0;
770770      }
771771      break;
src/mess/machine/galaxy.c
r9922r9923
1111#include "cpu/z80/z80.h"
1212#include "includes/galaxy.h"
1313#include "devices/cassette.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515
1616/***************************************************************************
1717  I/O devices
r9922r9923
9595         cpu_set_reg(cpu, Z80_I,    data[0x40]);
9696         cpu_set_reg(cpu, Z80_R,    (data[0x44] & 0x7f) | (data[0x48] & 0x80));
9797
98         memcpy (messram_get_ptr(machine->device("messram")), data + 0x084c, (messram_get_size(machine->device("messram")) < 0x1800) ? messram_get_size(machine->device("messram")) : 0x1800);
98         memcpy (ram_get_ptr(machine->device(RAM_TAG)), data + 0x084c, (ram_get_size(machine->device(RAM_TAG)) < 0x1800) ? ram_get_size(machine->device(RAM_TAG)) : 0x1800);
9999
100100         break;
101101      case GALAXY_SNAPSHOT_V2_SIZE:
r9922r9923
122122         cpu_set_reg(cpu, Z80_I,    data[0x19]);
123123         cpu_set_reg(cpu, Z80_R,    data[0x1a]);
124124
125         memcpy (messram_get_ptr(machine->device("messram")), data + 0x0834, (messram_get_size(machine->device("messram")) < 0x1800) ? messram_get_size(machine->device("messram")) : 0x1800);
125         memcpy (ram_get_ptr(machine->device(RAM_TAG)), data + 0x0834, (ram_get_size(machine->device(RAM_TAG)) < 0x1800) ? ram_get_size(machine->device(RAM_TAG)) : 0x1800);
126126
127127         break;
128128   }
r9922r9923
160160DRIVER_INIT( galaxy )
161161{
162162   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
163   memory_install_readwrite_bank( space, 0x2800, 0x2800 + messram_get_size(machine->device("messram")) - 1, 0, 0, "bank1");
164   memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
163   memory_install_readwrite_bank( space, 0x2800, 0x2800 + ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank1");
164   memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
165165
166   if (messram_get_size(machine->device("messram")) < (6 + 48) * 1024)
166   if (ram_get_size(machine->device(RAM_TAG)) < (6 + 48) * 1024)
167167   {
168      memory_nop_readwrite( space, 0x2800 + messram_get_size(machine->device("messram")), 0xffff, 0, 0);
168      memory_nop_readwrite( space, 0x2800 + ram_get_size(machine->device(RAM_TAG)), 0xffff, 0, 0);
169169   }
170170}
171171
src/mess/machine/zx.c
r9922r9923
1111#include "includes/zx.h"
1212#include "devices/cassette.h"
1313#include "sound/speaker.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515
1616#define video_screen_get_refresh(screen)   (((screen_config *)(screen)->inline_config)->refresh)
1717
r9922r9923
5151{
5252   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
5353
54   memory_install_read_bank(space, 0x4000, 0x4000 + messram_get_size(machine->device("messram")) - 1, 0, 0, "bank1");
55   memory_install_write8_handler(space, 0x4000, 0x4000 + messram_get_size(machine->device("messram")) - 1, 0, 0, zx_ram_w);
54   memory_install_read_bank(space, 0x4000, 0x4000 + ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank1");
55   memory_install_write8_handler(space, 0x4000, 0x4000 + ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, zx_ram_w);
5656   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x4000);
5757}
5858
src/mess/machine/pc1401.c
r9922r9923
33
44#include "includes/pocketc.h"
55#include "includes/pc1401.h"
6#include "devices/messram.h"
6#include "machine/ram.h"
77
88/* C-CE while reset, program will not be destroyed! */
99
src/mess/machine/apple2gs.c
r9922r9923
116116#include "devices/flopdrv.h"
117117#include "cpu/g65816/g65816.h"
118118#include "sound/es5503.h"
119#include "devices/messram.h"
119#include "machine/ram.h"
120120#include "debugger.h"
121121
122122#define LOG_C0XX         0
r9922r9923
11931193{
11941194   apple2gs_state *state = space->machine->driver_data<apple2gs_state>();
11951195   offset += 0x000400;
1196   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1196   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
11971197
11981198   if (!(state->shadow & 0x01))
11991199   {
r9922r9923
12051205{
12061206   apple2gs_state *state = space->machine->driver_data<apple2gs_state>();
12071207   offset += 0x010400;
1208   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1208   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
12091209
12101210   if (!(state->shadow & 0x01))
12111211   {
r9922r9923
12171217{
12181218   apple2gs_state *state = space->machine->driver_data<apple2gs_state>();
12191219   offset += 0x002000;
1220   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1220   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
12211221
12221222   if (!(state->shadow & 0x02))
12231223   {
r9922r9923
12291229{
12301230   apple2gs_state *state = space->machine->driver_data<apple2gs_state>();
12311231   offset += 0x012000;
1232   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1232   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
12331233
12341234   if (!(state->shadow & 0x12) || !(state->shadow & 0x08))
12351235   {
r9922r9923
12411241{
12421242   apple2gs_state *state = space->machine->driver_data<apple2gs_state>();
12431243   offset += 0x004000;
1244   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1244   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
12451245
12461246   if ((offset >= 0x004000) && (offset <= 0x005FFF))
12471247   {
r9922r9923
12541254{
12551255   apple2gs_state *state = space->machine->driver_data<apple2gs_state>();
12561256   offset += 0x014000;
1257   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1257   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
12581258
12591259   if ((offset >= 0x014000) && (offset <= 0x015FFF))
12601260   {
r9922r9923
15021502
15031503   if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000))
15041504   {
1505      result = messram_get_ptr(machine->device("messram"))[address];
1505      result = ram_get_ptr(machine->device(RAM_TAG))[address];
15061506   }
15071507   else if ((address & 0x000F00) == 0x000000)
15081508   {
r9922r9923
15291529
15301530   if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000))
15311531   {
1532      messram_get_ptr(machine->device("messram"))[address] = data;
1532      ram_get_ptr(machine->device(RAM_TAG))[address] = data;
15331533   }
15341534   else if ((address & 0x000F00) == 0x000000)
15351535   {
r9922r9923
15561556   {
15571557      if ((state->shadow & 0x40) && ((address & 0xF00000) == 0x000000))
15581558      {
1559         opptr = &messram_get_ptr(machine->device("messram"))[address];
1559         opptr = &ram_get_ptr(machine->device(RAM_TAG))[address];
15601560      }
15611561      else if ((address & 0x000F00) == 0x000000)
15621562      {
r9922r9923
16341634   state_save_register_item_array(machine, "APPLE2GS_SLOWMEM", NULL, 0, state->slowmem);
16351635
16361636   /* install expanded memory */
1637   memory_install_readwrite_bank(space, 0x010000, messram_get_size(machine->device("messram")) - 1, 0, 0, "bank1");
1638   memory_set_bankptr(machine,"bank1", messram_get_ptr(machine->device("messram")) + 0x010000);
1637   memory_install_readwrite_bank(space, 0x010000, ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank1");
1638   memory_set_bankptr(machine,"bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x010000);
16391639
16401640   /* install hi memory */
16411641   memory_install_read_bank(space, 0xe00000, 0xe1ffff, 0, 0, "bank2");
r9922r9923
17501750   apple2gs_setup_memory(machine);
17511751
17521752   /* save state stuff.  note that the driver takes care of docram. */
1753   state_save_register_global_array(machine, messram_get_ptr(machine->device("messram")));
1753   state_save_register_global_array(machine, ram_get_ptr(machine->device(RAM_TAG)));
17541754
17551755   state_save_register_item(machine, "NEWVIDEO", NULL, 0, state->newvideo);
17561756
src/mess/machine/mac.c
r9922r9923
9494#include "sound/asc.h"
9595#include "includes/mac.h"
9696#include "debug/debugcpu.h"
97#include "devices/messram.h"
97#include "machine/ram.h"
9898#include "debugger.h"
9999
100100#define ADB_IS_BITBANG   ((mac->m_model == MODEL_MAC_SE || mac->m_model == MODEL_MAC_CLASSIC) || (mac->m_model >= MODEL_MAC_II && mac->m_model <= MODEL_MAC_IICI) || (mac->m_model == MODEL_MAC_SE30))
r9922r9923
402402   else
403403   {
404404      /* RAM */
405      memory_size = messram_get_size(m_ram);
406      memory_data = messram_get_ptr(m_ram);
405      memory_size = ram_get_size(m_ram);
406      memory_data = ram_get_ptr(m_ram);
407407      is_rom = FALSE;
408408   }
409409
r9922r9923
480480      else
481481      {
482482         /* RAM */
483         memory_size = messram_get_size(m_ram);
484         memory_data = messram_get_ptr(m_ram);
483         memory_size = ram_get_size(m_ram);
484         memory_data = ram_get_ptr(m_ram);
485485         is_rom = FALSE;
486486      }
487487
r9922r9923
31083108      mac_set_sound_buffer(machine->device("custom"), 1);
31093109
31103110      // classic will fail RAM test and try to boot appletalk if RAM is not all zero
3111      memset(messram_get_ptr(m_ram), 0, messram_get_size(m_ram));
3111      memset(ram_get_ptr(m_ram), 0, ram_get_size(m_ram));
31123112   }
31133113
31143114   m_scsi_interrupt = 0;
r9922r9923
32083208   else if (model < MODEL_MAC_II)
32093209   {
32103210      /* set up RAM mirror at 0x600000-0x6fffff (0x7fffff ???) */
3211      mac_install_memory(machine, 0x600000, 0x6fffff, messram_get_size(mac->m_ram), messram_get_ptr(mac->m_ram), FALSE, "bank2");
3211      mac_install_memory(machine, 0x600000, 0x6fffff, ram_get_size(mac->m_ram), ram_get_ptr(mac->m_ram), FALSE, "bank2");
32123212
32133213      /* set up ROM at 0x400000-0x43ffff (-0x5fffff for mac 128k/512k/512ke) */
32143214      mac_install_memory(machine, 0x400000, (model >= MODEL_MAC_PLUS) ? 0x43ffff : 0x5fffff,
r9922r9923
32183218   mac->m_overlay = -1;
32193219   mac->set_memory_overlay(1);
32203220
3221   memset(messram_get_ptr(mac->m_ram), 0, messram_get_size(mac->m_ram));
3221   memset(ram_get_ptr(mac->m_ram), 0, ram_get_size(mac->m_ram));
32223222
32233223   if ((model == MODEL_MAC_SE) || (model == MODEL_MAC_CLASSIC) || (model == MODEL_MAC_CLASSIC_II) || (model == MODEL_MAC_LC) ||
32243224       (model == MODEL_MAC_LC_II) || (model == MODEL_MAC_LC_III) || (model == MODEL_MAC_LC_III_PLUS) || ((mac->m_model >= MODEL_MAC_II) && (mac->m_model <= MODEL_MAC_SE30)) ||
src/mess/machine/mpc105.c
r9922r9923
99#include "emu.h"
1010#include "mpc105.h"
1111#include "machine/pci.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414#define LOG_MPC105      1
1515
r9922r9923
5858            |   (((mpc105->bank_registers[(bank / 4) + 6] >> (bank % 4) * 8)) & 0x03) << 28
5959            | 0x000FFFFF;
6060
61         end = MIN(end, begin + messram_get_size(machine->device("messram")) - 1);
61         end = MIN(end, begin + ram_get_size(machine->device(RAM_TAG)) - 1);
6262
6363         if ((begin + 0x100000) <= end)
6464         {
6565            if (LOG_MPC105)
66               logerror("\tbank #%d [%02d]: 0x%08X - 0x%08X [%p-%p]\n", bank, bank + mpc105->bank_base, begin, end, messram_get_ptr(machine->device("messram")), messram_get_ptr(machine->device("messram")) + (end - begin));
66               logerror("\tbank #%d [%02d]: 0x%08X - 0x%08X [%p-%p]\n", bank, bank + mpc105->bank_base, begin, end, ram_get_ptr(machine->device(RAM_TAG)), ram_get_ptr(machine->device(RAM_TAG)) + (end - begin));
6767
6868            if (mpc105->bank_base > 0)
6969            {
r9922r9923
7878                     0, 0, (write64_space_func) (FPTR)(bank + mpc105->bank_base));
7979               }
8080               sprintf(bank_str,"bank%d",bank + mpc105->bank_base);
81               memory_set_bankptr(machine, bank_str, messram_get_ptr(machine->device("messram")));
81               memory_set_bankptr(machine, bank_str, ram_get_ptr(machine->device(RAM_TAG)));
8282            }
8383         }
8484      }
src/mess/machine/mz700.c
r9922r9923
1919#include "machine/ctronics.h"
2020#include "sound/speaker.h"
2121#include "devices/cassette.h"
22#include "devices/messram.h"
22#include "machine/ram.h"
2323
2424#ifndef VERBOSE
2525#define VERBOSE 1
r9922r9923
182182
183183         /* ram from 0xa000 to 0xbfff */
184184         memory_install_readwrite_bank(spc, 0xa000, 0xbfff, 0, 0, "bank5");
185         memory_set_bankptr(space->machine, "bank5", messram_get_ptr(space->machine->device("messram")) + 0xa000);
185         memory_set_bankptr(space->machine, "bank5", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xa000);
186186      }
187187   }
188188
r9922r9923
194194   address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
195195
196196   memory_install_readwrite_bank(spc, 0x0000, 0x0fff, 0, 0, "bank1");
197   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
197   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
198198}
199199
200200WRITE8_HANDLER( mz800_bank_0_w )
r9922r9923
202202   address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
203203
204204   memory_install_readwrite_bank(spc, 0x0000, 0x7fff, 0, 0, "bank1");
205   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
205   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
206206}
207207
208208READ8_HANDLER( mz800_bank_1_r )
r9922r9923
212212
213213   /* switch in ram from 0x1000 to 0x1fff */
214214   memory_install_readwrite_bank(spc, 0x1000, 0x1fff, 0, 0, "bank2");
215   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0x1000);
215   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x1000);
216216
217217   if (mz->mz700_mode)
218218   {
219219      /* ram from 0xc000 to 0xcfff */
220220      memory_install_readwrite_bank(spc, 0xc000, 0xcfff, 0, 0, "bank6");
221      memory_set_bankptr(space->machine, "bank6", messram_get_ptr(space->machine->device("messram")) + 0xc000);
221      memory_set_bankptr(space->machine, "bank6", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xc000);
222222   }
223223   else
224224   {
225225      /* ram from 0x8000 to 0xbfff */
226226      memory_install_readwrite_bank(spc, 0x8000, 0xbfff, 0, 0, "bank4");
227      memory_set_bankptr(space->machine, "bank4", messram_get_ptr(space->machine->device("messram")) + 0x8000);
227      memory_set_bankptr(space->machine, "bank4", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x8000);
228228   }
229229
230230   return 0xff;
r9922r9923
241241      if (!mz->mz700_ram_lock)
242242      {
243243         memory_install_readwrite_bank(spc, 0xd000, 0xffff, 0, 0, "bank7");
244         memory_set_bankptr(space->machine, "bank7", messram_get_ptr(space->machine->device("messram")) + 0xd000);
244         memory_set_bankptr(space->machine, "bank7", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xd000);
245245         mz->mz700_ram_vram = FALSE;
246246      }
247247   }
r9922r9923
251251      if (!mz->mz800_ram_lock)
252252      {
253253         memory_install_readwrite_bank(spc, 0xe000, 0xffff, 0, 0, "bank8");
254         memory_set_bankptr(space->machine, "bank8", messram_get_ptr(space->machine->device("messram")) + 0xe000);
254         memory_set_bankptr(space->machine, "bank8", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xe000);
255255         mz->mz800_ram_monitor = FALSE;
256256      }
257257   }
r9922r9923
330330
331331      /* rest is ram is always ram in mz700 mode */
332332      memory_install_readwrite_bank(spc, 0x1000, 0xcfff, 0, 0, "bank2");
333      memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0x1000);
333      memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x1000);
334334   }
335335   else
336336   {
r9922r9923
341341
342342      /* ram from 0x2000 to 0x7fff */
343343      memory_install_readwrite_bank(spc, 0x2000, 0x7fff, 0, 0, "bank3");
344      memory_set_bankptr(space->machine, "bank3", messram_get_ptr(space->machine->device("messram")));
344      memory_set_bankptr(space->machine, "bank3", ram_get_ptr(space->machine->device(RAM_TAG)));
345345
346346      if (mz->hires_mode)
347347      {
r9922r9923
357357
358358         /* ram from 0xa000 to 0xbfff */
359359         memory_install_readwrite_bank(spc, 0xa000, 0xbfff, 0, 0, "bank5");
360         memory_set_bankptr(space->machine, "bank5", messram_get_ptr(space->machine->device("messram")) + 0xa000);
360         memory_set_bankptr(space->machine, "bank5", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xa000);
361361      }
362362
363363      /* ram from 0xc000 to 0xdfff */
364364      memory_install_readwrite_bank(spc, 0xc000, 0xdfff, 0, 0, "bank6");
365      memory_set_bankptr(space->machine, "bank6", messram_get_ptr(space->machine->device("messram")) + 0xc000);
365      memory_set_bankptr(space->machine, "bank6", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xc000);
366366
367367      /* mz800 monitor rom from 0xe000 to 0xffff */
368368      memory_install_read_bank(spc, 0xe000, 0xffff, 0, 0, "bank8");
src/mess/machine/sym1.c
r9922r9923
1818#include "machine/6532riot.h"
1919#include "machine/74145.h"
2020#include "sound/speaker.h"
21#include "devices/messram.h"
21#include "machine/ram.h"
2222
2323#define LED_REFRESH_DELAY  ATTOTIME_IN_USEC(70)
2424
r9922r9923
288288{
289289   sym1_state *state = machine->driver_data<sym1_state>();
290290   /* wipe expansion memory banks that are not installed */
291   if (messram_get_size(machine->device("messram")) < 4*1024)
291   if (ram_get_size(machine->device(RAM_TAG)) < 4*1024)
292292   {
293293      memory_nop_readwrite(cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM ),
294         messram_get_size(machine->device("messram")), 0x0fff, 0, 0);
294         ram_get_size(machine->device(RAM_TAG)), 0x0fff, 0, 0);
295295   }
296296
297297   /* allocate a timer to refresh the led display */
src/mess/machine/cgenie.c
r9922r9923
1616#include "sound/ay8910.h"
1717#include "sound/dac.h"
1818#include "devices/flopdrv.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020
2121#define AYWriteReg(chip,port,value) \
2222   ay8910_address_w(ay8910, 0,port);  \
r9922r9923
149149      memset(gfx + i * 8, i, 8);
150150
151151   /* set up RAM */
152   memory_install_read_bank(space, 0x4000, 0x4000 + messram_get_size(machine->device("messram")) - 1, 0, 0, "bank1");
153   memory_install_write8_handler(space, 0x4000, 0x4000 + messram_get_size(machine->device("messram")) - 1, 0, 0, cgenie_videoram_w);
154   state->videoram = messram_get_ptr(machine->device("messram"));
155   memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
152   memory_install_read_bank(space, 0x4000, 0x4000 + ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank1");
153   memory_install_write8_handler(space, 0x4000, 0x4000 + ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, cgenie_videoram_w);
154   state->videoram = ram_get_ptr(machine->device(RAM_TAG));
155   memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
156156   timer_pulse(machine,  ATTOTIME_IN_HZ(11025), NULL, 0, handle_cassette_input );
157157}
158158
src/mess/machine/ondra.c
r9922r9923
1111#include "cpu/z80/z80.h"
1212#include "devices/cassette.h"
1313#include "includes/ondra.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515
1616
1717static device_t *cassette_device_image(running_machine *machine)
r9922r9923
4646      memory_set_bankptr(machine, "bank1", mem + 0x010000);
4747   } else {
4848      memory_install_write_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, "bank1");
49      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
49      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
5050   }
51   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
51   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
5252   if (state->bank2_status==0) {
5353      memory_install_readwrite_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe000, 0xffff, 0, 0, "bank3");
54      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xe000);
54      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xe000);
5555   } else {
5656      memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe000, 0xffff, 0, 0);
5757      memory_install_read8_handler (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe000, 0xffff, 0, 0, ondra_keyboard_r);
src/mess/machine/lviv.c
r9922r9923
1616#include "machine/i8255a.h"
1717#include "includes/lviv.h"
1818#include "sound/speaker.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020
2121#define LVIV_SNAPSHOT_SIZE   82219
2222
r9922r9923
2929   lviv_state *state = machine->driver_data<lviv_state>();
3030   if (state->ppi_port_outputs[0][2] & 0x02)
3131   {
32      memory_set_bankptr(machine,"bank1", messram_get_ptr(machine->device("messram")));
33      memory_set_bankptr(machine,"bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
32      memory_set_bankptr(machine,"bank1", ram_get_ptr(machine->device(RAM_TAG)));
33      memory_set_bankptr(machine,"bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
3434   }
3535   else
3636   {
37      memory_set_bankptr(machine,"bank1", messram_get_ptr(machine->device("messram")) + 0x8000);
38      memory_set_bankptr(machine,"bank2", messram_get_ptr(machine->device("messram")) + 0xc000);
37      memory_set_bankptr(machine,"bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
38      memory_set_bankptr(machine,"bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
3939   }
4040}
4141
r9922r9923
182182      memory_install_write_bank(cpuspace, 0x8000, 0xbfff, 0, 0, "bank3");
183183      memory_unmap_write(cpuspace, 0xC000, 0xffff, 0, 0);
184184
185      memory_set_bankptr(space->machine,"bank1", messram_get_ptr(space->machine->device("messram")));
186      memory_set_bankptr(space->machine,"bank2", messram_get_ptr(space->machine->device("messram")) + 0x4000);
187      memory_set_bankptr(space->machine,"bank3", messram_get_ptr(space->machine->device("messram")) + 0x8000);
185      memory_set_bankptr(space->machine,"bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
186      memory_set_bankptr(space->machine,"bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x4000);
187      memory_set_bankptr(space->machine,"bank3", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x8000);
188188      memory_set_bankptr(space->machine,"bank4", space->machine->region("maincpu")->base() + 0x010000);
189189   }
190190   else
r9922r9923
234234   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
235235   space->set_direct_update_handler(direct_update_delegate_create_static(lviv_directoverride, *machine));
236236
237   state->video_ram = messram_get_ptr(machine->device("messram")) + 0xc000;
237   state->video_ram = ram_get_ptr(machine->device(RAM_TAG)) + 0xc000;
238238
239239   state->startup_mem_map = 1;
240240
r9922r9923
250250
251251   /*timer_pulse(machine, TIME_IN_NSEC(200), NULL, 0, lviv_draw_pixel);*/
252252
253   /*memset(messram_get_ptr(machine->device("messram")), 0, sizeof(unsigned char)*0xffff);*/
253   /*memset(ram_get_ptr(machine->device(RAM_TAG)), 0, sizeof(unsigned char)*0xffff);*/
254254}
255255
256256
r9922r9923
295295   cpu_set_reg(machine->device("maincpu"), I8085_PC, (hi << 8) | lo);
296296
297297   /* Memory dump */
298   memcpy (messram_get_ptr(machine->device("messram")), data+0x0011, 0xc000);
299   memcpy (messram_get_ptr(machine->device("messram"))+0xc000, data+0x10011, 0x4000);
298   memcpy (ram_get_ptr(machine->device(RAM_TAG)), data+0x0011, 0xc000);
299   memcpy (ram_get_ptr(machine->device(RAM_TAG))+0xc000, data+0x10011, 0x4000);
300300
301301   /* Ports */
302302   state->ppi_port_outputs[0][0] = data[0x14011+0xc0];
src/mess/machine/pc1403.c
r9922r9923
33
44#include "includes/pocketc.h"
55#include "includes/pc1403.h"
6#include "devices/messram.h"
6#include "machine/ram.h"
77
88/* C-CE while reset, program will not be destroyed! */
99
src/mess/machine/partner.c
r9922r9923
1717#include "includes/radio86.h"
1818#include "includes/partner.h"
1919#include "devices/flopdrv.h"
20#include "devices/messram.h"
20#include "machine/ram.h"
2121
2222
2323/* Driver initialization */
r9922r9923
168168      memory_set_bankptr(machine, "bank1", rom + 0x10000);
169169   } else {
170170      if (state->mem_page==7) {
171         memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x8000);
171         memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
172172      } else {
173         memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
173         memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
174174      }
175175   }
176176
177177    // BANK 2 (0x0800 - 0x3fff)
178178   if (state->mem_page==7) {
179      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x8800);
179      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x8800);
180180   } else {
181      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0800);
181      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0800);
182182   }
183183
184184    // BANK 3 (0x4000 - 0x5fff)
185185   if (state->mem_page==7) {
186      memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xC000);
186      memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xC000);
187187   } else {
188188      if (state->mem_page==10) {
189189         //window 1
190190         memory_unmap_write(space, 0x4000, 0x5fff, 0, 0);
191191         partner_window_1(machine, 3, 0, rom);
192192      } else {
193         memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
193         memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
194194      }
195195   }
196196
197197    // BANK 4 (0x6000 - 0x7fff)
198198   if (state->mem_page==7) {
199      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xe000);
199      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xe000);
200200   } else {
201      memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x6000);
201      memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
202202   }
203203
204204    // BANK 5 (0x8000 - 0x9fff)
r9922r9923
216216            partner_window_1(machine, 5, 0, rom);
217217            break;
218218      case 7:
219            memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x0000);
219            memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
220220            break;
221221      default:
222            memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x8000);
222            memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
223223            break;
224224   }
225225
r9922r9923
238238            memory_set_bankptr(machine, "bank6", rom + 0x12000); // BASIC
239239            break;
240240      case 7:
241            memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x2000);
241            memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
242242            break;
243243      default:
244            memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0xa000);
244            memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0xa000);
245245            break;
246246   }
247247
r9922r9923
261261            memory_set_bankptr(machine, "bank7", rom + 0x13800); // BASIC
262262            break;
263263      case 7:
264            memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x3800);
264            memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0x3800);
265265            break;
266266      default:
267            memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0xb800);
267            memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0xb800);
268268            break;
269269   }
270270
271271    // BANK 8 (0xc000 - 0xc7ff)
272272   switch (state->mem_page) {
273273      case 7:
274            memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0x4000);
274            memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
275275            break;
276276      case 8:
277277      case 10:
r9922r9923
279279            memory_set_bankptr(machine, "bank8", rom + 0x10000);
280280            break;
281281      default:
282            memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0xc000);
282            memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
283283            break;
284284   }
285285
286286    // BANK 9 (0xc800 - 0xcfff)
287287   switch (state->mem_page) {
288288      case 7:
289            memory_set_bankptr(machine, "bank9", messram_get_ptr(machine->device("messram")) + 0x4800);
289            memory_set_bankptr(machine, "bank9", ram_get_ptr(machine->device(RAM_TAG)) + 0x4800);
290290            break;
291291      case 8:
292292      case 9:
r9922r9923
299299            memory_set_bankptr(machine, "bank9", rom + 0x10800);
300300            break;
301301      default:
302            memory_set_bankptr(machine, "bank9", messram_get_ptr(machine->device("messram")) + 0xc800);
302            memory_set_bankptr(machine, "bank9", ram_get_ptr(machine->device(RAM_TAG)) + 0xc800);
303303            break;
304304   }
305305
306306    // BANK 10 (0xd000 - 0xd7ff)
307307   switch (state->mem_page) {
308308      case 7:
309            memory_set_bankptr(machine, "bank10", messram_get_ptr(machine->device("messram")) + 0x5000);
309            memory_set_bankptr(machine, "bank10", ram_get_ptr(machine->device(RAM_TAG)) + 0x5000);
310310            break;
311311      case 8:
312312      case 9:
r9922r9923
315315            partner_window_2(machine, 10, 0x0800, rom);
316316            break;
317317      default:
318            memory_set_bankptr(machine, "bank10", messram_get_ptr(machine->device("messram")) + 0xd000);
318            memory_set_bankptr(machine, "bank10", ram_get_ptr(machine->device(RAM_TAG)) + 0xd000);
319319            break;
320320   }
321321
src/mess/machine/apple1.c
r9922r9923
5050#include "cpu/m6502/m6502.h"
5151#include "image.h"
5252#include "devices/cassette.h"
53#include "devices/messram.h"
53#include "machine/ram.h"
5454
5555static TIMER_CALLBACK(apple1_kbd_poll);
5656static TIMER_CALLBACK(apple1_kbd_strobe_end);
r9922r9923
146146{
147147   address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
148148   /* Set up the handlers for MESS's dynamically-sized RAM. */
149   memory_install_readwrite_bank(space,0x0000, messram_get_size(machine->device("messram")) - 1, 0, 0, "bank1");
150   memory_set_bankptr(machine,"bank1", messram_get_ptr(machine->device("messram")));
149   memory_install_readwrite_bank(space,0x0000, ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0, "bank1");
150   memory_set_bankptr(machine,"bank1", ram_get_ptr(machine->device(RAM_TAG)));
151151
152152   /* Poll the keyboard input ports periodically.  These include both
153153       ordinary keys and the RESET and CLEAR SCREEN pushbutton
r9922r9923
244244
245245   end_addr = start_addr + datasize - 1;
246246
247   if ((start_addr < 0xE000 && end_addr > messram_get_size(image.device().machine->device("messram")) - 1)
247   if ((start_addr < 0xE000 && end_addr > ram_get_size(image.device().machine->device(RAM_TAG)) - 1)
248248      || end_addr > 0xEFFF)
249249   {
250250      logerror("apple1 - Snapshot won't fit in this memory configuration;\n"
src/mess/machine/bebox.c
r9922r9923
108108#include "machine/intelfsh.h"
109109#include "machine/8042kbdc.h"
110110#include "machine/53c810.h"
111#include "devices/messram.h"
111#include "machine/ram.h"
112112
113113#define LOG_CPUIMASK   1
114114#define LOG_UART      1
r9922r9923
11221122   memory_set_bankptr(machine, "bank2", machine->region("user2")->base());
11231123
11241124   /* install MESS managed RAM */
1125   memory_install_readwrite_bank(space_0, 0, messram_get_size(machine->device("messram")) - 1, 0, 0x02000000, "bank3");
1126   memory_install_readwrite_bank(space_1, 0, messram_get_size(machine->device("messram")) - 1, 0, 0x02000000, "bank3");
1127   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")));
1125   memory_install_readwrite_bank(space_0, 0, ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0x02000000, "bank3");
1126   memory_install_readwrite_bank(space_1, 0, ram_get_size(machine->device(RAM_TAG)) - 1, 0, 0x02000000, "bank3");
1127   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)));
11281128   
11291129   pc_vga_init(machine, &bebox_vga_interface, &cirrus_svga_interface);
11301130   kbdc8042_init(machine, &bebox_8042_interface);
src/mess/machine/mtx.c
r9922r9923
1111#include "includes/mtx.h"
1212#include "cpu/z80/z80.h"
1313#include "devices/cassette.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515#include "devices/snapquik.h"
1616#include "machine/ctronics.h"
1717#include "machine/z80ctc.h"
r9922r9923
7474    */
7575
7676   address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
77   device_t *messram = machine->device("messram");
77   device_t *messram = machine->device(RAM_TAG);
7878
7979//  UINT8 cbm_mode = data >> 7 & 0x01;
8080   UINT8 rom_page = data >> 4 & 0x07;
r9922r9923
8484   memory_set_bank(machine, "bank2", rom_page);
8585
8686   /* set ram bank, for invalid pages a nop-handler will be installed */
87   if (ram_page >= messram_get_size(messram)/0x8000)
87   if (ram_page >= ram_get_size(messram)/0x8000)
8888   {
8989      memory_nop_readwrite(program, 0x4000, 0x7fff, 0, 0);
9090      memory_nop_readwrite(program, 0x8000, 0xbfff, 0, 0);
9191   }
92   else if (ram_page + 1 == messram_get_size(messram)/0x8000)
92   else if (ram_page + 1 == ram_get_size(messram)/0x8000)
9393   {
9494      memory_nop_readwrite(program, 0x4000, 0x7fff, 0, 0);
9595      memory_install_readwrite_bank(program, 0x8000, 0xbfff, 0, 0, "bank4");
r9922r9923
404404MACHINE_START( mtx512 )
405405{
406406   mtx_state *state = machine->driver_data<mtx_state>();
407   device_t *messram = machine->device("messram");
407   device_t *messram = machine->device(RAM_TAG);
408408
409409   /* find devices */
410410   state->z80ctc = machine->device(Z80CTC_TAG);
r9922r9923
414414   /* configure memory */
415415   memory_set_bankptr(machine, "bank1", machine->region("user1")->base());
416416   memory_configure_bank(machine, "bank2", 0, 8, machine->region("user2")->base(), 0x2000);
417   memory_configure_bank(machine, "bank3", 0, messram_get_size(messram)/0x4000/2, messram_get_ptr(messram), 0x4000);
418   memory_configure_bank(machine, "bank4", 0, messram_get_size(messram)/0x4000/2, messram_get_ptr(messram) + messram_get_size(messram)/2, 0x4000);
417   memory_configure_bank(machine, "bank3", 0, ram_get_size(messram)/0x4000/2, ram_get_ptr(messram), 0x4000);
418   memory_configure_bank(machine, "bank4", 0, ram_get_size(messram)/0x4000/2, ram_get_ptr(messram) + ram_get_size(messram)/2, 0x4000);
419419
420420   /* setup tms9928a */
421421   TMS9928A_configure(&tms9928a_interface);
src/mess/machine/special.c
r9922r9923
1616#include "machine/pit8253.h"
1717#include "machine/wd17xx.h"
1818#include "includes/special.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020#include "devices/flopdrv.h"
2121
2222
r9922r9923
148148static WRITE8_HANDLER( video_memory_w )
149149{
150150   special_state *state = space->machine->driver_data<special_state>();
151   messram_get_ptr(space->machine->device("messram"))[0x9000 + offset] = data;
151   ram_get_ptr(space->machine->device(RAM_TAG))[0x9000 + offset] = data;
152152   state->specimx_colorram[offset]  = state->specimx_color;
153153}
154154
r9922r9923
169169   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
170170   memory_install_write_bank(space, 0xc000, 0xffbf, 0, 0, "bank3");
171171   memory_install_write_bank(space, 0xffc0, 0xffdf, 0, 0, "bank4");
172   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xffc0);
172   memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xffc0);
173173   switch(i)
174174   {
175175      case 0 :
176176            memory_install_write_bank(space, 0x0000, 0x8fff, 0, 0, "bank1");
177177            memory_install_write8_handler(space, 0x9000, 0xbfff, 0, 0, video_memory_w);
178178
179            memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
180            memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x9000);
181            memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xc000);
179            memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
180            memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x9000);
181            memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
182182            break;
183183      case 1 :
184184            memory_install_write_bank(space, 0x0000, 0x8fff, 0, 0, "bank1");
185185            memory_install_write_bank(space, 0x9000, 0xbfff, 0, 0, "bank2");
186186
187            memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000);
188            memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x19000);
189            memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x1c000);
187            memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000);
188            memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x19000);
189            memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x1c000);
190190            break;
191191      case 2 :
192192            memory_unmap_write(space, 0x0000, 0x8fff, 0, 0);
r9922r9923
196196            memory_set_bankptr(machine, "bank2", machine->region("maincpu")->base() + 0x19000);
197197            if (data & 0x80)
198198            {
199               memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x1c000);
199               memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x1c000);
200200            }
201201            else
202202            {
203               memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xc000);
203               memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
204204            }
205205            break;
206206   }
r9922r9923
328328      case   1:
329329      case   2:
330330      case   3:
331                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000*(bank1-1));
331                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000*(bank1-1));
332332                  break;
333333      case   0:
334334                  memory_unmap_write(space, 0x0000, 0x3fff, 0, 0);
r9922r9923
340340      case   1:
341341      case   2:
342342      case   3:
343                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x10000*(bank2-1) + 0x4000);
343                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000*(bank2-1) + 0x4000);
344344                  break;
345345      case   0:
346346                  memory_unmap_write(space, 0x4000, 0x8fff, 0, 0);
r9922r9923
352352      case   1:
353353      case   2:
354354      case   3:
355                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x10000*(bank3-1) + 0x9000);
355                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000*(bank3-1) + 0x9000);
356356                  break;
357357      case   0:
358358                  memory_unmap_write(space, 0x9000, 0xbfff, 0, 0);
r9922r9923
364364      case   1:
365365      case   2:
366366      case   3:
367                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x10000*(bank4-1) + 0x0c000);
368                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x10000*(bank4-1) + 0x0f000);
369                  memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x10000*(bank4-1) + 0x0f800);
367                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000*(bank4-1) + 0x0c000);
368                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000*(bank4-1) + 0x0f000);
369                  memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000*(bank4-1) + 0x0f800);
370370                  break;
371371      case   0:
372372                  memory_unmap_write(space, 0xc000, 0xefff, 0, 0);
src/mess/machine/rmnimbus.c
r9922r9923
5454#include "debug/debugcpu.h"
5555#include "debug/debugcon.h"
5656#include "devices/flopdrv.h"
57#include "devices/messram.h"
57#include "machine/ram.h"
5858#include "machine/er59256.h"
5959#include "machine/pic8259.h"
6060#include "machine/pit8253.h"
r9922r9923
18811881{
18821882   rmnimbus_state *state = machine->driver_data<rmnimbus_state>();
18831883    address_space *space = cputag_get_address_space( machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM );
1884    int     ramsize = messram_get_size(machine->device("messram"));
1884    int     ramsize = ram_get_size(machine->device(RAM_TAG));
18851885    int     ramblock = 0;
18861886    int     blockno;
18871887    char   bank[10];
1888    UINT8   *ram    = &messram_get_ptr(machine->device("messram"))[0];
1888    UINT8   *ram    = &ram_get_ptr(machine->device(RAM_TAG))[0];
18891889    UINT8   *map_blocks[3];
18901890    UINT8   *map_base;
18911891    int     map_blockno;
src/mess/machine/tf20.c
r9922r9923
1212#include "emu.h"
1313#include "tf20.h"
1414#include "cpu/z80/z80.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616#include "machine/upd7201.h"
1717#include "machine/upd765.h"
1818#include "devices/flopdrv.h"
r9922r9923
7676   address_space *prg = cpu_get_address_space(space->cpu, ADDRESS_SPACE_PROGRAM);
7777
7878   /* switch in ram */
79   memory_install_ram(prg, 0x0000, 0x7fff, 0, 0, messram_get_ptr(tf20->ram));
79   memory_install_ram(prg, 0x0000, 0x7fff, 0, 0, ram_get_ptr(tf20->ram));
8080
8181   return 0xff;
8282}
r9922r9923
345345   tf20->floppy_1 = device->subdevice(FLOPPY_1);
346346
347347   /* enable second half of ram */
348   memory_install_ram(prg, 0x8000, 0xffff, 0, 0, messram_get_ptr(tf20->ram) + 0x8000);
348   memory_install_ram(prg, 0x8000, 0xffff, 0, 0, ram_get_ptr(tf20->ram) + 0x8000);
349349}
350350
351351static DEVICE_RESET( tf20 )
src/mess/machine/cybiko.c
r9922r9923
2020#include "machine/pcf8593.h"
2121#include "machine/at45dbxx.h"
2222#include "machine/sst39vfx.h"
23#include "devices/messram.h"
23#include "machine/ram.h"
2424
2525#ifndef _H8S2XXX_H_
2626#define H8S_IO(xxxx) ((xxxx) - 0xFE40)
r9922r9923
8484{
8585   memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), start, start + size - 1, 0, mirror - size, "bank1");
8686   memory_install_write_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), start, start + size - 1, 0, mirror - size, "bank1");
87   memory_set_bankptr( machine, "bank1", messram_get_ptr(machine->device("messram")));
87   memory_set_bankptr( machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
8888}
8989
9090DRIVER_INIT( cybikov1 )
9191{
9292   _logerror( 0, ("init_cybikov1\n"));
93   init_ram_handler(machine, 0x200000, messram_get_size(machine->device("messram")), 0x200000);
93   init_ram_handler(machine, 0x200000, ram_get_size(machine->device(RAM_TAG)), 0x200000);
9494}
9595
9696DRIVER_INIT( cybikov2 )
9797{
9898   _logerror( 0, ("init_cybikov2\n"));
99   init_ram_handler(machine, 0x200000, messram_get_size(machine->device("messram")), 0x200000);
99   init_ram_handler(machine, 0x200000, ram_get_size(machine->device(RAM_TAG)), 0x200000);
100100}
101101
102102DRIVER_INIT( cybikoxt )
103103{
104104   _logerror( 0, ("init_cybikoxt\n"));
105   init_ram_handler(machine, 0x400000, messram_get_size(machine->device("messram")), 0x200000);
105   init_ram_handler(machine, 0x400000, ram_get_size(machine->device(RAM_TAG)), 0x200000);
106106}
107107
108108////////////////////
src/mess/machine/pp01.c
r9922r9923
1010#include "emu.h"
1111#include "cpu/i8085/i8085.h"
1212#include "includes/pp01.h"
13#include "devices/messram.h"
13#include "machine/ram.h"
1414
1515
1616WRITE8_HANDLER( pp01_video_write_mode_w )
r9922r9923
2727   if (BIT(state->video_write_mode,3)) {
2828      // Copy mode
2929      if(BIT(state->video_write_mode,0)) {
30         messram_get_ptr(machine->device("messram"))[0x6000+offset+addroffset] = data;
30         ram_get_ptr(machine->device(RAM_TAG))[0x6000+offset+addroffset] = data;
3131      } else {
32         messram_get_ptr(machine->device("messram"))[0x6000+offset+addroffset] = 0;
32         ram_get_ptr(machine->device(RAM_TAG))[0x6000+offset+addroffset] = 0;
3333      }
3434      if(BIT(state->video_write_mode,1)) {
35         messram_get_ptr(machine->device("messram"))[0xa000+offset+addroffset] = data;
35         ram_get_ptr(machine->device(RAM_TAG))[0xa000+offset+addroffset] = data;
3636      } else {
37         messram_get_ptr(machine->device("messram"))[0xa000+offset+addroffset] = 0;
37         ram_get_ptr(machine->device(RAM_TAG))[0xa000+offset+addroffset] = 0;
3838      }
3939      if(BIT(state->video_write_mode,2)) {
40         messram_get_ptr(machine->device("messram"))[0xe000+offset+addroffset] = data;
40         ram_get_ptr(machine->device(RAM_TAG))[0xe000+offset+addroffset] = data;
4141      } else {
42         messram_get_ptr(machine->device("messram"))[0xe000+offset+addroffset] = 0;
42         ram_get_ptr(machine->device(RAM_TAG))[0xe000+offset+addroffset] = 0;
4343      }
4444   } else {
4545      if (block==0) {
46         messram_get_ptr(machine->device("messram"))[0x6000+offset+addroffset] = data;
46         ram_get_ptr(machine->device(RAM_TAG))[0x6000+offset+addroffset] = data;
4747      }
4848      if (block==1) {
49         messram_get_ptr(machine->device("messram"))[0xa000+offset+addroffset] = data;
49         ram_get_ptr(machine->device(RAM_TAG))[0xa000+offset+addroffset] = data;
5050      }
5151      if (block==2) {
52         messram_get_ptr(machine->device("messram"))[0xe000+offset+addroffset] = data;
52         ram_get_ptr(machine->device(RAM_TAG))[0xe000+offset+addroffset] = data;
5353      }
5454   }
5555}
r9922r9923
118118               break;
119119      }
120120
121      memory_set_bankptr(machine, bank, messram_get_ptr(machine->device("messram")) + (data & 0x0F)* 0x1000);
121      memory_set_bankptr(machine, bank, ram_get_ptr(machine->device(RAM_TAG)) + (data & 0x0F)* 0x1000);
122122   } else if (data>=0xF8) {
123123      memory_install_read_bank (space, startaddr, endaddr, 0, 0, bank);
124124      memory_unmap_write(space, startaddr, endaddr, 0, 0);
src/mess/machine/apple2.c
r9922r9923
2222#include "devices/flopdrv.h"
2323#include "image.h"
2424#include "devices/cassette.h"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626#include "sound/speaker.h"
2727#include "profiler.h"
2828
r9922r9923
203203         else
204204         {
205205            /* RAM */
206            if (end_r >= messram_get_size(machine->device("messram")))
207               end_r = messram_get_size(machine->device("messram")) - 1;
206            if (end_r >= ram_get_size(machine->device(RAM_TAG)))
207               end_r = ram_get_size(machine->device(RAM_TAG)) - 1;
208208            offset = meminfo.read_mem & APPLE2_MEM_MASK;
209209            if (end_r >= begin)
210               rbase = &messram_get_ptr(machine->device("messram"))[offset];
210               rbase = &ram_get_ptr(machine->device(RAM_TAG))[offset];
211211         }
212212
213213         /* install the actual handlers */
r9922r9923
286286         else
287287         {
288288            /* RAM */
289            if (end_w >= messram_get_size(machine->device("messram")))
290               end_w = messram_get_size(machine->device("messram")) - 1;
289            if (end_w >= ram_get_size(machine->device(RAM_TAG)))
290               end_w = ram_get_size(machine->device(RAM_TAG)) - 1;
291291            offset = meminfo.write_mem & APPLE2_MEM_MASK;
292292            if (end_w >= begin)
293               wbase = &messram_get_ptr(machine->device("messram"))[offset];
293               wbase = &ram_get_ptr(machine->device(RAM_TAG))[offset];
294294         }
295295
296296
r9922r9923
10181018      //CMemory::mState |= CMemory::kVBLBar; // N: VBL' is true // FIX: MESS?
10191019   }
10201020
1021   return messram_get_ptr(machine->device("messram"))[address % messram_get_size(machine->device("messram"))]; // FIX: this seems to work, but is it right!?
1021   return ram_get_ptr(machine->device(RAM_TAG))[address % ram_get_size(machine->device(RAM_TAG))]; // FIX: this seems to work, but is it right!?
10221022}
10231023
10241024
r9922r9923
10941094static WRITE8_HANDLER ( apple2_mainram0400_w )
10951095{
10961096   offset += 0x400;
1097   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1097   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
10981098}
10991099
11001100static WRITE8_HANDLER ( apple2_mainram2000_w )
11011101{
11021102   offset += 0x2000;
1103   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1103   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
11041104}
11051105
11061106static WRITE8_HANDLER ( apple2_auxram0400_w )
11071107{
11081108   offset += 0x10400;
1109   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1109   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
11101110}
11111111
11121112static WRITE8_HANDLER ( apple2_auxram2000_w )
11131113{
11141114   offset += 0x12000;
1115   messram_get_ptr(space->machine->device("messram"))[offset] = data;
1115   ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
11161116}
11171117
11181118
r9922r9923
16131613   if (machine->region("maincpu")->bytes() < 0x8000)
16141614      a2_mask &= ~VAR_ROMSWITCH;
16151615
1616   if (messram_get_size(machine->device("messram")) <= 64*1024)
1616   if (ram_get_size(machine->device(RAM_TAG)) <= 64*1024)
16171617      a2_mask &= ~(VAR_RAMRD | VAR_RAMWRT | VAR_80STORE | VAR_ALTZP | VAR_80COL);
16181618}
16191619
src/mess/machine/pc.c
r9922r9923
4545#include "machine/8237dma.h"
4646
4747#include "machine/kb_keytro.h"
48#include "devices/messram.h"
48#include "machine/ram.h"
4949
5050#define VERBOSE_PIO 0   /* PIO (keyboard controller) */
5151
r9922r9923
618618         * 6-7  The number of floppy disk drives
619619         */
620620      data = input_port_read(device->machine, "DSW0") & 0xF3;
621      switch ( messram_get_size(machine->device("messram")) )
621      switch ( ram_get_size(machine->device(RAM_TAG)) )
622622      {
623623      case 16 * 1024:
624624         data |= 0x00;
r9922r9923
669669      /* read hi nibble of SW2 */
670670      data = data & 0xf0;
671671
672      switch ( messram_get_size(machine->device("messram")) - 64 * 1024 )
672      switch ( ram_get_size(machine->device(RAM_TAG)) - 64 * 1024 )
673673      {
674674      case 64 * 1024:      data |= 0x00; break;
675675      case 128 * 1024:   data |= 0x02; break;
r9922r9923
687687      case 896 * 1024:   data |= 0x0B; break;
688688      case 960 * 1024:   data |= 0x0D; break;
689689      }
690      if ( messram_get_size(machine->device("messram")) > 960 * 1024 )
690      if ( ram_get_size(machine->device(RAM_TAG)) > 960 * 1024 )
691691         data |= 0x0D;
692692
693693      PIO_LOG(1,"PIO_C_r (hi)",("$%02x\n", data));
r9922r9923
10321032
10331033   data&=~0x80;
10341034   data &= ~0x04;      /* floppy drive installed */
1035   if ( messram_get_size(device->machine->device("messram")) > 64 * 1024 )   /* more than 64KB ram installed */
1035   if ( ram_get_size(device->machine->device(RAM_TAG)) > 64 * 1024 )   /* more than 64KB ram installed */
10361036      data &= ~0x08;
10371037   data = ( data & ~0x01 ) | ( pcjr_keyb.latch ? 0x01: 0x00 );
10381038   if ( ! ( st->ppi_portb & 0x08 ) )
r9922r9923
11521152      init_pc_common(machine, flags, set_keyb_int_func);
11531153
11541154   /* MESS managed RAM */
1155   if ( messram_get_ptr(machine->device("messram")) )
1156      memory_set_bankptr( machine, "bank10", messram_get_ptr(machine->device("messram")) );
1155   if ( ram_get_ptr(machine->device(RAM_TAG)) )
1156      memory_set_bankptr( machine, "bank10", ram_get_ptr(machine->device(RAM_TAG)) );
11571157
11581158   /* FDC/HDC hardware */
11591159   pc_hdc_setup(machine, set_hdc_int_func);
src/mess/machine/pecom.c
r9922r9923
1111#include "sound/cdp1869.h"
1212#include "devices/cassette.h"
1313#include "includes/pecom.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515
1616static TIMER_CALLBACK( reset_tick )
1717{
r9922r9923
4040   memory_install_read_bank (space, 0xf000, 0xf7ff, 0, 0, "bank3");
4141   memory_install_read_bank (space, 0xf800, 0xffff, 0, 0, "bank4");
4242   memory_set_bankptr(machine, "bank1", rom + 0x8000);
43   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
43   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
4444   memory_set_bankptr(machine, "bank3", rom + 0xf000);
4545   memory_set_bankptr(machine, "bank4", rom + 0xf800);
4646
r9922r9923
7979   address_space *space2 = cputag_get_address_space(space->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
8080   UINT8 *rom = space->machine->region(CDP1802_TAG)->base();
8181   memory_install_write_bank(cputag_get_address_space(space->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, "bank1");
82   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")) + 0x0000);
82   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x0000);
8383
8484   if (data==2)
8585   {
src/mess/machine/pk8020.c
r9922r9923
1111#include "includes/pk8020.h"
1212#include "cpu/i8085/i8085.h"
1313#include "machine/wd17xx.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515#include "devices/flopdrv.h"
1616
1717static void pk8020_set_bank(running_machine *machine,UINT8 data);
r9922r9923
4949
5050static READ8_HANDLER(sysreg_r)
5151{
52   return messram_get_ptr(space->machine->device("messram"))[offset];
52   return ram_get_ptr(space->machine->device(RAM_TAG))[offset];
5353}
5454static WRITE8_HANDLER(sysreg_w)
5555{
r9922r9923
7474static READ8_HANDLER(text_r)
7575{
7676   pk8020_state *state = space->machine->driver_data<pk8020_state>();
77    if (state->attr == 3) state->text_attr=messram_get_ptr(space->machine->device("messram"))[0x40400+offset];
78   return messram_get_ptr(space->machine->device("messram"))[0x40000+offset];
77    if (state->attr == 3) state->text_attr=ram_get_ptr(space->machine->device(RAM_TAG))[0x40400+offset];
78   return ram_get_ptr(space->machine->device(RAM_TAG))[0x40000+offset];
7979}
8080
8181static WRITE8_HANDLER(text_w)
8282{
8383   pk8020_state *state = space->machine->driver_data<pk8020_state>();
84   messram_get_ptr(space->machine->device("messram"))[0x40000+offset] = data;
84   ram_get_ptr(space->machine->device(RAM_TAG))[0x40000+offset] = data;
8585   switch (state->attr) {
8686        case 0: break;
87        case 1: messram_get_ptr(space->machine->device("messram"))[0x40400+offset]=0x01;break;
88        case 2: messram_get_ptr(space->machine->device("messram"))[0x40400+offset]=0x00;break;
89        case 3: messram_get_ptr(space->machine->device("messram"))[0x40400+offset]=state->text_attr;break;
87        case 1: ram_get_ptr(space->machine->device(RAM_TAG))[0x40400+offset]=0x01;break;
88        case 2: ram_get_ptr(space->machine->device(RAM_TAG))[0x40400+offset]=0x00;break;
89        case 3: ram_get_ptr(space->machine->device(RAM_TAG))[0x40400+offset]=state->text_attr;break;
9090    }
9191}
9292
9393static READ8_HANDLER(gzu_r)
9494{
9595   pk8020_state *state = space->machine->driver_data<pk8020_state>();
96   UINT8 *addr = messram_get_ptr(space->machine->device("messram")) + 0x10000 + (state->video_page_access * 0xC000);
96   UINT8 *addr = ram_get_ptr(space->machine->device(RAM_TAG)) + 0x10000 + (state->video_page_access * 0xC000);
9797   UINT8 p0 = addr[offset];
9898   UINT8 p1 = addr[offset + 0x4000];
9999   UINT8 p2 = addr[offset + 0x8000];
r9922r9923
128128static WRITE8_HANDLER(gzu_w)
129129{
130130   pk8020_state *state = space->machine->driver_data<pk8020_state>();
131   UINT8 *addr = messram_get_ptr(space->machine->device("messram")) + 0x10000 + (state->video_page_access * 0xC000);
131   UINT8 *addr = ram_get_ptr(space->machine->device(RAM_TAG)) + 0x10000 + (state->video_page_access * 0xC000);
132132   UINT8 *plane_0 = addr;
133133   UINT8 *plane_1 = addr + 0x4000;
134134   UINT8 *plane_2 = addr + 0x8000;
r9922r9923
241241                  memory_install_read_bank (space, 0x0000, 0x37ff, 0, 0, "bank1");
242242                  memory_install_write_bank(space, 0x0000, 0x37ff, 0, 0, "bank2");
243243                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
244                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
244                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
245245                  // Keyboard
246246                  memory_install_read8_handler (space, 0x3800, 0x39ff, 0, 0, keyboard_r);
247247                  memory_install_write_bank(space, 0x3800, 0x39ff, 0, 0, "bank3");
248                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x3800);
248                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x3800);
249249                  // System reg
250250                  memory_install_read8_handler (space, 0x3a00, 0x3aff, 0, 0, sysreg_r);
251251                  memory_install_write8_handler(space, 0x3a00, 0x3aff, 0, 0, sysreg_w);
r9922r9923
258258                  // RAM
259259                  memory_install_read_bank (space, 0x4000, 0xffff, 0, 0, "bank4");
260260                  memory_install_write_bank(space, 0x4000, 0xffff, 0, 0, "bank5");
261                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
262                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x4000);
261                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
262                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
263263               }
264264               break;
265265      case 0x01 : {
r9922r9923
267267                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
268268                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
269269                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
270                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
270                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
271271                  // RAM
272272                  memory_install_read_bank (space, 0x2000, 0xffff, 0, 0, "bank3");
273273                  memory_install_write_bank(space, 0x2000, 0xffff, 0, 0, "bank4");
274                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
275                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
274                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
275                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
276276               }
277277               break;
278278      case 0x02 : {
r9922r9923
280280                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
281281                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
282282                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
283                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
283                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
284284                  // RAM
285285                  memory_install_read_bank (space, 0x4000, 0xffff, 0, 0, "bank3");
286286                  memory_install_write_bank(space, 0x4000, 0xffff, 0, 0, "bank4");
287                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
288                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
287                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
288                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
289289               }
290290               break;
291291      case 0x03 : {
292292                  // RAM
293293                  memory_install_read_bank (space, 0x0000, 0xffff, 0, 0, "bank1");
294294                  memory_install_write_bank(space, 0x0000, 0xffff, 0, 0, "bank2");
295                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
296                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
295                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
296                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
297297               }
298298               break;
299299      case 0x04 :
r9922r9923
303303                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
304304                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
305305                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
306                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
306                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
307307                  // RAM
308308                  memory_install_read_bank (space, 0x2000, 0xf7ff, 0, 0, "bank3");
309309                  memory_install_write_bank(space, 0x2000, 0xf7ff, 0, 0, "bank4");
310                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
311                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
310                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
311                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
312312                  // Keyboard
313313                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
314314                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank5");
315                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800);
315                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
316316                  // System reg
317317                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
318318                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
330330                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
331331                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
332332                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
333                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
333                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
334334                  // RAM
335335                  memory_install_read_bank (space, 0x4000, 0xf7ff, 0, 0, "bank3");
336336                  memory_install_write_bank(space, 0x4000, 0xf7ff, 0, 0, "bank4");
337                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
338                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
337                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
338                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
339339                  // Keyboard
340340                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
341341                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank5");
342                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800);
342                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
343343                  // System reg
344344                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
345345                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
356356                  // RAM
357357                  memory_install_read_bank (space, 0x0000, 0xf7ff, 0, 0, "bank1");
358358                  memory_install_write_bank(space, 0x0000, 0xf7ff, 0, 0, "bank2");
359                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
360                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
359                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
360                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
361361                  // Keyboard
362362                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
363363                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank3");
364                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf800);
364                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
365365                  // System reg
366366                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
367367                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
379379                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
380380                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
381381                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
382                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
382                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
383383                  // Keyboard
384384                  memory_install_read8_handler (space, 0x3800, 0x39ff, 0, 0, keyboard_r);
385385                  memory_install_write_bank(space, 0x3800, 0x39ff, 0, 0, "bank3");
386                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x3800);
386                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x3800);
387387                  // System reg
388388                  memory_install_read8_handler (space, 0x3a00, 0x3aff, 0, 0, sysreg_r);
389389                  memory_install_write8_handler(space, 0x3a00, 0x3aff, 0, 0, sysreg_w);
r9922r9923
396396                  // RAM
397397                  memory_install_read_bank (space, 0x4000, 0xbfff, 0, 0, "bank4");
398398                  memory_install_write_bank(space, 0x4000, 0xbfff, 0, 0, "bank5");
399                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
400                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x4000);
399                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
400                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
401401                  // Video RAM
402402                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
403403                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
410410                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
411411                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
412412                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
413                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
413                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
414414                  // RAM
415415                  memory_install_read_bank (space, 0x2000, 0xbfff, 0, 0, "bank3");
416416                  memory_install_write_bank(space, 0x2000, 0xbfff, 0, 0, "bank4");
417                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
418                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
417                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
418                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
419419                  // Video RAM
420420                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
421421                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
427427                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
428428                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
429429                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
430                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
430                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
431431                  // RAM
432432                  memory_install_read_bank (space, 0x4000, 0xbfff, 0, 0, "bank3");
433433                  memory_install_write_bank(space, 0x4000, 0xbfff, 0, 0, "bank4");
434                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
435                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
434                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
435                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
436436                  // Video RAM
437437                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
438438                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
443443                  // RAM
444444                  memory_install_read_bank (space, 0x0000, 0xbfff, 0, 0, "bank1");
445445                  memory_install_write_bank(space, 0x0000, 0xbfff, 0, 0, "bank2");
446                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
447                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
446                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
447                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
448448                  // Video RAM
449449                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
450450                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
457457                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
458458                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
459459                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
460                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
460                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
461461                  // RAM
462462                  memory_install_read_bank (space, 0x2000, 0x3fff, 0, 0, "bank3");
463463                  memory_install_write_bank(space, 0x2000, 0x3fff, 0, 0, "bank4");
464                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
465                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
464                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
465                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
466466                  // Video RAM
467467                  memory_install_read8_handler (space, 0x4000, 0x7fff, 0, 0, gzu_r);
468468                  memory_install_write8_handler(space, 0x4000, 0x7fff, 0, 0, gzu_w);
469469                  // RAM
470470                  memory_install_read_bank (space, 0x8000, 0xfdff, 0, 0, "bank5");
471471                  memory_install_write_bank(space, 0x8000, 0xfdff, 0, 0, "bank6");
472                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x8000);
473                  memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x8000);
472                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
473                  memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
474474                  // Devices
475475                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
476476                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
485485                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
486486                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
487487                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
488                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
488                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
489489                  // Video RAM
490490                  memory_install_read8_handler (space, 0x4000, 0x7fff, 0, 0, gzu_r);
491491                  memory_install_write8_handler(space, 0x4000, 0x7fff, 0, 0, gzu_w);
492492                  // RAM
493493                  memory_install_read_bank (space, 0x8000, 0xfdff, 0, 0, "bank5");
494494                  memory_install_write_bank(space, 0x8000, 0xfdff, 0, 0, "bank6");
495                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x8000);
496                  memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x8000);
495                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
496                  memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
497497                  // Devices
498498                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
499499                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
507507                  // RAM
508508                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
509509                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
510                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
511                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
510                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
511                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
512512                  // Video RAM
513513                  memory_install_read8_handler (space, 0x4000, 0x7fff, 0, 0, gzu_r);
514514                  memory_install_write8_handler(space, 0x4000, 0x7fff, 0, 0, gzu_w);
515515                  // RAM
516516                  memory_install_read_bank (space, 0x8000, 0xfdff, 0, 0, "bank3");
517517                  memory_install_write_bank(space, 0x8000, 0xfdff, 0, 0, "bank4");
518                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x8000);
519                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x8000);
518                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
519                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
520520                  // Devices
521521                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
522522                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
531531                  memory_install_read_bank (space, 0x0000, 0x5fff, 0, 0, "bank1");
532532                  memory_install_write_bank(space, 0x0000, 0x5fff, 0, 0, "bank2");
533533                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
534                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
534                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
535535                  // RAM
536536                  memory_install_read_bank (space, 0x6000, 0xf7ff, 0, 0, "bank3");
537537                  memory_install_write_bank(space, 0x6000, 0xf7ff, 0, 0, "bank4");
538                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x6000);
539                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x6000);
538                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
539                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
540540                  // Keyboard
541541                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
542542                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank5");
543                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800);
543                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
544544                  // System reg
545545                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
546546                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
558558                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
559559                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
560560                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
561                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
561                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
562562                  // RAM
563563                  memory_install_read_bank (space, 0x2000, 0xf7ff, 0, 0, "bank3");
564564                  memory_install_write_bank(space, 0x2000, 0xf7ff, 0, 0, "bank4");
565                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
566                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
565                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
566                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
567567                  // Keyboard
568568                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
569569                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank5");
570                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800);
570                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
571571                  // System reg
572572                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
573573                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
585585                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
586586                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
587587                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
588                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
588                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
589589                  // RAM
590590                  memory_install_read_bank (space, 0x4000, 0xf7ff, 0, 0, "bank3");
591591                  memory_install_write_bank(space, 0x4000, 0xf7ff, 0, 0, "bank4");
592                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
593                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
592                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
593                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
594594                  // Keyboard
595595                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
596596                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank5");
597                  memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800);
597                  memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
598598                  // System reg
599599                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
600600                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
611611                  // RAM
612612                  memory_install_read_bank (space, 0x0000, 0xf7ff, 0, 0, "bank1");
613613                  memory_install_write_bank(space, 0x0000, 0xf7ff, 0, 0, "bank2");
614                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
615                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
614                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
615                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
616616                  // Keyboard
617617                  memory_install_read8_handler (space, 0xf800, 0xf9ff, 0, 0, keyboard_r);
618618                  memory_install_write_bank(space, 0xf800, 0xf9ff, 0, 0, "bank3");
619                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf800);
619                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xf800);
620620                  // System reg
621621                  memory_install_read8_handler (space, 0xfa00, 0xfaff, 0, 0, sysreg_r);
622622                  memory_install_write8_handler(space, 0xfa00, 0xfaff, 0, 0, sysreg_w);
r9922r9923
634634                  memory_install_read_bank (space, 0x0000, 0x5fff, 0, 0, "bank1");
635635                  memory_install_write_bank(space, 0x0000, 0x5fff, 0, 0, "bank2");
636636                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
637                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
637                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
638638                  // RAM
639639                  memory_install_read_bank (space, 0x6000, 0xfdff, 0, 0, "bank3");
640640                  memory_install_write_bank(space, 0x6000, 0xfdff, 0, 0, "bank4");
641                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x6000);
642                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x6000);
641                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
642                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
643643                  // Devices
644644                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
645645                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
654654                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
655655                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
656656                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
657                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
657                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
658658                  // RAM
659659                  memory_install_read_bank (space, 0x2000, 0xfdff, 0, 0, "bank3");
660660                  memory_install_write_bank(space, 0x2000, 0xfdff, 0, 0, "bank4");
661                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
662                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
661                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
662                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
663663                  // Devices
664664                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
665665                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
674674                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
675675                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
676676                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
677                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
677                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
678678                  // RAM
679679                  memory_install_read_bank (space, 0x4000, 0xfdff, 0, 0, "bank3");
680680                  memory_install_write_bank(space, 0x4000, 0xfdff, 0, 0, "bank4");
681                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
682                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
681                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
682                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
683683                  // Devices
684684                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
685685                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
693693                  // RAM
694694                  memory_install_read_bank (space, 0x0000, 0xfdff, 0, 0, "bank1");
695695                  memory_install_write_bank(space, 0x0000, 0xfdff, 0, 0, "bank2");
696                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
697                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
696                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
697                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
698698                  // Devices
699699                  memory_install_read8_handler (space, 0xfe00, 0xfeff, 0, 0, devices_r);
700700                  memory_install_write8_handler(space, 0xfe00, 0xfeff, 0, 0, devices_w);
r9922r9923
709709                  memory_install_read_bank (space, 0x0000, 0x5fff, 0, 0, "bank1");
710710                  memory_install_write_bank(space, 0x0000, 0x5fff, 0, 0, "bank2");
711711                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
712                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
712                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
713713                  // RAM
714714                  memory_install_read_bank (space, 0x6000, 0xbeff, 0, 0, "bank3");
715715                  memory_install_write_bank(space, 0x6000, 0xbeff, 0, 0, "bank4");
716                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x6000);
717                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x6000);
716                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
717                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
718718                  // System reg
719719                  memory_install_read8_handler (space, 0xbf00, 0xbfff, 0, 0, sysreg_r);
720720                  memory_install_write8_handler(space, 0xbf00, 0xbfff, 0, 0, sysreg_w);
r9922r9923
729729                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
730730                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
731731                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
732                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
732                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
733733                  // RAM
734734                  memory_install_read_bank (space, 0x2000, 0xbeff, 0, 0, "bank3");
735735                  memory_install_write_bank(space, 0x2000, 0xbeff, 0, 0, "bank4");
736                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
737                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
736                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
737                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
738738                  // System reg
739739                  memory_install_read8_handler (space, 0xbf00, 0xbfff, 0, 0, sysreg_r);
740740                  memory_install_write8_handler(space, 0xbf00, 0xbfff, 0, 0, sysreg_w);
r9922r9923
749749                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
750750                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
751751                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
752                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
752                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
753753                  // RAM
754754                  memory_install_read_bank (space, 0x4000, 0xbeff, 0, 0, "bank3");
755755                  memory_install_write_bank(space, 0x4000, 0xbeff, 0, 0, "bank4");
756                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
757                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
756                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
757                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
758758                  // System reg
759759                  memory_install_read8_handler (space, 0xbf00, 0xbfff, 0, 0, sysreg_r);
760760                  memory_install_write8_handler(space, 0xbf00, 0xbfff, 0, 0, sysreg_w);
r9922r9923
768768                  // RAM
769769                  memory_install_read_bank (space, 0x0000, 0xbeff, 0, 0, "bank1");
770770                  memory_install_write_bank(space, 0x0000, 0xbeff, 0, 0, "bank2");
771                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
772                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
771                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
772                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
773773                  // System reg
774774                  memory_install_read8_handler (space, 0xbf00, 0xbfff, 0, 0, sysreg_r);
775775                  memory_install_write8_handler(space, 0xbf00, 0xbfff, 0, 0, sysreg_w);
r9922r9923
784784                  memory_install_read_bank (space, 0x0000, 0x5fff, 0, 0, "bank1");
785785                  memory_install_write_bank(space, 0x0000, 0x5fff, 0, 0, "bank2");
786786                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
787                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
787                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
788788                  // RAM
789789                  memory_install_read_bank (space, 0x6000, 0xbfff, 0, 0, "bank3");
790790                  memory_install_write_bank(space, 0x6000, 0xbfff, 0, 0, "bank4");
791                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x6000);
792                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x6000);
791                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
792                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x6000);
793793                  // Video RAM
794794                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
795795                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
801801                  memory_install_read_bank (space, 0x0000, 0x1fff, 0, 0, "bank1");
802802                  memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank2");
803803                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
804                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
804                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
805805                  // RAM
806806                  memory_install_read_bank (space, 0x2000, 0xbfff, 0, 0, "bank3");
807807                  memory_install_write_bank(space, 0x2000, 0xbfff, 0, 0, "bank4");
808                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x2000);
809                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x2000);
808                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
809                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x2000);
810810                  // Video RAM
811811                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
812812                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
818818                  memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1");
819819                  memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank2");
820820                  memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000);
821                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0000);
821                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
822822                  // RAM
823823                  memory_install_read_bank (space, 0x4000, 0xbfff, 0, 0, "bank3");
824824                  memory_install_write_bank(space, 0x4000, 0xbfff, 0, 0, "bank4");
825                  memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x4000);
826                  memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x4000);
825                  memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
826                  memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
827827                  // Video RAM
828828                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
829829                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
r9922r9923
834834                  // RAM
835835                  memory_install_read_bank (space, 0x0000, 0xbfff, 0, 0, "bank1");
836836                  memory_install_write_bank(space, 0x0000, 0xbfff, 0, 0, "bank2");
837                  memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
838                  memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
837                  memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
838                  memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
839839                  // Video RAM
840840                  memory_install_read8_handler (space, 0xc000, 0xffff, 0, 0, gzu_r);
841841                  memory_install_write8_handler(space, 0xc000, 0xffff, 0, 0, gzu_w);
src/mess/machine/kc.c
r9922r9923
1212
1313/* Devices */
1414#include "devices/cassette.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717#define KC_DEBUG 1
1818#define LOG(x) do { if (KC_DEBUG) logerror x; } while (0)
r9922r9923
111111   addr = (header->load_address_l & 0x0ff) | ((header->load_address_h & 0x0ff)<<8);
112112
113113   for (i=0; i<datasize; i++)
114      messram_get_ptr(image.device().machine->device("messram"))[(addr+i) & 0x0ffff] = data[i+128];
114      ram_get_ptr(image.device().machine->device(RAM_TAG))[(addr+i) & 0x0ffff] = data[i+128];
115115   return IMAGE_INIT_PASS;
116116}
117117
r9922r9923
11011101      /* ram8 block chosen */
11021102      ram8_block = ((state->kc85_84_data)>>4) & 0x01;
11031103
1104      mem_ptr = messram_get_ptr(machine->device("messram"))+0x08000+(ram8_block<<14);
1104      mem_ptr = ram_get_ptr(machine->device(RAM_TAG))+0x08000+(ram8_block<<14);
11051105
11061106      memory_set_bankptr(machine, "bank3", mem_ptr);
11071107      memory_set_bankptr(machine, "bank4", mem_ptr+0x02800);
r9922r9923
11671167
11681168      /* yes; set address of bank */
11691169      memory_install_read_bank(space, 0x0000, 0x3fff, 0, 0, "bank1");
1170      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
1170      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
11711171
11721172      /* write protect ram? */
11731173      if ((state->kc85_pio_data[0] & (1<<3))==0)
r9922r9923
11841184
11851185         /* ram is enabled and write enabled; and set address of bank */
11861186         memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank7");
1187         memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")));
1187         memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)));
11881188      }
11891189   }
11901190   else
r9922r9923
12081208   {
12091209      UINT8 *mem_ptr;
12101210
1211      mem_ptr = messram_get_ptr(machine->device("messram")) + 0x04000;
1211      mem_ptr = ram_get_ptr(machine->device(RAM_TAG)) + 0x04000;
12121212
12131213      /* yes */
12141214      memory_install_read_bank(space, 0x4000, 0x7fff, 0, 0, "bank2");
r9922r9923
14621462      /* yes */
14631463      memory_install_read_bank(space, 0x0000, 0x3fff, 0, 0, "bank1");
14641464      /* set address of bank */
1465      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
1465      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
14661466
14671467      /* write protect ram? */
14681468      if ((state->kc85_pio_data[0] & (1<<3))==0)
r9922r9923
14801480         /* ram is enabled and write enabled */
14811481         memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank6");
14821482         /* set address of bank */
1483         memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")));
1483         memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)));
14841484      }
14851485   }
14861486   else
r9922r9923
15041504    {
15051505        /* IRM enabled */
15061506        LOG(("IRM enabled\n"));
1507      ram_page = messram_get_ptr(machine->device("messram"))+0x08000;
1507      ram_page = ram_get_ptr(machine->device(RAM_TAG))+0x08000;
15081508
15091509      memory_set_bankptr(machine, "bank3", ram_page);
15101510      memory_set_bankptr(machine, "bank8", ram_page);
r9922r9923
15151515    {
15161516      /* RAM8 ACCESS */
15171517      LOG(("RAM8 enabled\n"));
1518      ram_page = messram_get_ptr(machine->device("messram")) + 0x04000;
1518      ram_page = ram_get_ptr(machine->device(RAM_TAG)) + 0x04000;
15191519
15201520      memory_set_bankptr(machine, "bank3", ram_page);
15211521      memory_install_read_bank(space, 0x8000, 0xbfff, 0, 0, "bank3");
r9922r9923
18581858   state->kc85_pio_data[0] = 0x0f;
18591859   state->kc85_pio_data[1] = 0x0f1;
18601860
1861   memory_set_bankptr(machine, "bank2",messram_get_ptr(machine->device("messram"))+0x0c000);
1862   memory_set_bankptr(machine, "bank7",messram_get_ptr(machine->device("messram"))+0x0c000);
1861   memory_set_bankptr(machine, "bank2",ram_get_ptr(machine->device(RAM_TAG))+0x0c000);
1862   memory_set_bankptr(machine, "bank7",ram_get_ptr(machine->device(RAM_TAG))+0x0c000);
18631863
18641864   state->kc85_z80pio = machine->device("z80pio");
18651865
src/mess/video/dgn_beta.c
r9922r9923
8282#include "emu.h"
8383#include "includes/dgn_beta.h"
8484#include "video/m6845.h"
85#include "devices/messram.h"
85#include "machine/ram.h"
8686
8787#include "debug/debugcpu.h"
8888#include "debug/debugcon.h"
r9922r9923
288288
289289   state->GCtrl=0;
290290
291   videoram=messram_get_ptr(machine->device("messram"));
291   videoram=ram_get_ptr(machine->device(RAM_TAG));
292292
293293   state->ClkMax=65000;
294294   state->FlashCount=0;
src/mess/video/apple3.c
r9922r9923
99
1010#include "emu.h"
1111#include "includes/apple3.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414#define   BLACK   0
1515#define DKRED   1
r9922r9923
101101   {
102102      for (x = 0; x < 40; x++)
103103      {
104         offset = messram_get_size(machine->device("messram")) - 0x8000 + text_map[y] + x + (state->flags & VAR_VM2 ? 0x0400 : 0x0000);
105         ch = messram_get_ptr(machine->device("messram"))[offset];
104         offset = ram_get_size(machine->device(RAM_TAG)) - 0x8000 + text_map[y] + x + (state->flags & VAR_VM2 ? 0x0400 : 0x0000);
105         ch = ram_get_ptr(machine->device(RAM_TAG))[offset];
106106
107107         if (state->flags & VAR_VM0)
108108         {
109109            /* color text */
110            offset = messram_get_size(machine->device("messram")) - 0x8000 + text_map[y] + x + (state->flags & VAR_VM2 ? 0x0000 : 0x0400);
111            bg = (messram_get_ptr(machine->device("messram"))[offset] >> 0) & 0x0F;
112            fg = (messram_get_ptr(machine->device("messram"))[offset] >> 4) & 0x0F;
110            offset = ram_get_size(machine->device(RAM_TAG)) - 0x8000 + text_map[y] + x + (state->flags & VAR_VM2 ? 0x0000 : 0x0400);
111            bg = (ram_get_ptr(machine->device(RAM_TAG))[offset] >> 0) & 0x0F;
112            fg = (ram_get_ptr(machine->device(RAM_TAG))[offset] >> 4) & 0x0F;
113113         }
114114         else
115115         {
r9922r9923
157157   {
158158      for (x = 0; x < 40; x++)
159159      {
160         offset = messram_get_size(machine->device("messram")) - 0x8000 + text_map[y] + x;
160         offset = ram_get_size(machine->device(RAM_TAG)) - 0x8000 + text_map[y] + x;
161161
162162         /* first character */
163         ch = messram_get_ptr(machine->device("messram"))[offset + 0x0000];
163         ch = ram_get_ptr(machine->device(RAM_TAG))[offset + 0x0000];
164164         char_data = &state->char_mem[(ch & 0x7F) * 8];
165165         fg = (ch & 0x80) ? GREEN : BLACK;
166166         bg = (ch & 0x80) ? BLACK : GREEN;
r9922r9923
175175         }
176176
177177         /* second character */
178         ch = messram_get_ptr(machine->device("messram"))[offset + 0x0400];
178         ch = ram_get_ptr(machine->device(RAM_TAG))[offset + 0x0400];
179179         char_data = &state->char_mem[(ch & 0x7F) * 8];
180180         fg = (ch & 0x80) ? GREEN : BLACK;
181181         bg = (ch & 0x80) ? BLACK : GREEN;
r9922r9923
206206   for (y = 0; y < 192; y++)
207207   {
208208      if (state->flags & VAR_VM2)
209         pix_info = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y]];
209         pix_info = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y]];
210210      else
211         pix_info = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x2000];
211         pix_info = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x2000];
212212      ptr = BITMAP_ADDR16(bitmap, y, 0);
213213
214214      for (i = 0; i < 40; i++)
r9922r9923
252252   {
253253      if (state->flags & VAR_VM2)
254254      {
255         pix_info = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y]];
256         col_info = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x2000];
255         pix_info = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y]];
256         col_info = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x2000];
257257      }
258258      else
259259      {
260         pix_info = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x2000];
261         col_info = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y]];
260         pix_info = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x2000];
261         col_info = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y]];
262262      }
263263      ptr = BITMAP_ADDR16(bitmap, y, 0);
264264
r9922r9923
297297   {
298298      if (state->flags & VAR_VM2)
299299      {
300         pix_info1 = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y]];
301         pix_info2 = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y] + 0x2000];
300         pix_info1 = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y]];
301         pix_info2 = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] + 0x2000];
302302      }
303303      else
304304      {
305         pix_info1 = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x2000];
306         pix_info2 = &messram_get_ptr(machine->device("messram"))[state->hgr_map[y]];
305         pix_info1 = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x2000];
306         pix_info2 = &ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y]];
307307      }
308308      ptr = BITMAP_ADDR16(bitmap, y, 0);
309309
r9922r9923
337337      pen = BITMAP_ADDR16(bitmap, y, 0);
338338      for (i = 0; i < 20; i++)
339339      {
340         pix.b.l  = messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x2000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 0];
341         pix.b.h  = messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x0000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 0];
342         pix.b.h2 = messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x2000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 1];
343         pix.b.h3 = messram_get_ptr(machine->device("messram"))[state->hgr_map[y] - 0x0000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 1];
340         pix.b.l  = ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x2000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 0];
341         pix.b.h  = ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x0000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 0];
342         pix.b.h2 = ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x2000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 1];
343         pix.b.h3 = ram_get_ptr(machine->device(RAM_TAG))[state->hgr_map[y] - 0x0000 + (i * 2) + (state->flags & VAR_VM2 ? 1 : 0) + 1];
344344
345345         pen[ 0] = pen[ 1] = pen[ 2] = pen[ 3] = ((pix.d >>  0) & 0x0F);
346346         pen[ 4] = pen[ 5] = pen[ 6] = pen[ 7] = ((pix.d >>  4) & 0x07) | ((pix.d >>  1) & 0x08);
src/mess/video/mac.c
r9922r9923
1515#include "emu.h"
1616#include "sound/asc.h"
1717#include "includes/mac.h"
18#include "devices/messram.h"
18#include "machine/ram.h"
1919
2020PALETTE_INIT( mac )
2121{
r9922r9923
4343   int y, x, b;
4444   mac_state *mac = screen->machine->driver_data<mac_state>();
4545
46   video_base = messram_get_size(screen->machine->device("messram")) - (mac->screen_buffer ? MAC_MAIN_SCREEN_BUF_OFFSET : MAC_ALT_SCREEN_BUF_OFFSET);
47   video_ram = (const UINT16 *) (messram_get_ptr(screen->machine->device("messram")) + video_base);
46   video_base = ram_get_size(screen->machine->device(RAM_TAG)) - (mac->screen_buffer ? MAC_MAIN_SCREEN_BUF_OFFSET : MAC_ALT_SCREEN_BUF_OFFSET);
47   video_ram = (const UINT16 *) (ram_get_ptr(screen->machine->device(RAM_TAG)) + video_base);
4848
4949   for (y = 0; y < MAC_V_VIS; y++)
5050   {
r9922r9923
420420   UINT32 *scanline;
421421   int x, y, hres, vres;
422422   mac_state *mac = screen->machine->driver_data<mac_state>();
423   UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
423   UINT8 *vram8 = (UINT8 *)ram_get_ptr(screen->machine->device(RAM_TAG));
424424
425425   switch (mac->m_rbv_montype)
426426   {
src/mess/video/nc.c
r9922r9923
88
99#include "emu.h"
1010#include "includes/nc.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313/***************************************************************************
1414  Start the video hardware emulation.
r9922r9923
9191    {
9292      int by;
9393      /* 64 bytes per line */
94      char *line_ptr = ((char*)messram_get_ptr(screen->machine->device("messram"))) + state->display_memory_start + (y<<6);
94      char *line_ptr = ((char*)ram_get_ptr(screen->machine->device(RAM_TAG))) + state->display_memory_start + (y<<6);
9595
9696      x = 0;
9797      for (by=0; by<width>>3; by++)
src/mess/video/z88.c
r9922r9923
77***************************************************************************/
88
99#include "emu.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111#include "includes/z88.h"
1212
1313
r9922r9923
119119/* convert absolute offset into correct address to get data from */
120120static unsigned char *z88_convert_address(running_machine *machine, unsigned long offset)
121121{
122//        return messram_get_ptr(machine->device("messram"));
122//        return ram_get_ptr(machine->device(RAM_TAG));
123123   if (offset>(32*16384))
124124   {
125125      unsigned long get_offset;
126126      get_offset = offset - (32*16384);
127127      get_offset = get_offset & 0x01fffff;
128      return messram_get_ptr(machine->device("messram")) + get_offset;
128      return ram_get_ptr(machine->device(RAM_TAG)) + get_offset;
129129   }
130130   else
131131   {
src/mess/video/pcw16.c
r9922r9923
11#include "emu.h"
22#include "includes/pcw16.h"
3#include "devices/messram.h"
3#include "machine/ram.h"
44
55
66/* 16 colours, + 1 for border */
r9922r9923
157157VIDEO_UPDATE( pcw16 )
158158{
159159   pcw16_state *state = screen->machine->driver_data<pcw16_state>();
160   unsigned char *pScanLine = (unsigned char *)messram_get_ptr(screen->machine->device("messram")) + 0x0fc00;   //0x03c00;  //0x020FC00;
160   unsigned char *pScanLine = (unsigned char *)ram_get_ptr(screen->machine->device(RAM_TAG)) + 0x0fc00;   //0x03c00;  //0x020FC00;
161161
162162   int y;
163163   int x;
r9922r9923
240240         {
241241            int byte;
242242
243            byte = messram_get_ptr(screen->machine->device("messram"))[Addr];
243            byte = ram_get_ptr(screen->machine->device(RAM_TAG))[Addr];
244244
245245            switch (mode)
246246            {
src/mess/video/epnick.c
r9922r9923
1414 ****************************************************************************/
1515
1616#include "emu.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818#include "includes/enterp.h"
1919
2020/* given a colour index in range 0..255 gives the Red component */
r9922r9923
10291029   ep_state *state = machine->driver_data<ep_state>();
10301030   state->nick = auto_alloc_clear(machine, NICK_STATE);
10311031
1032   state->nick->videoram = messram_get_ptr(machine->device("messram"));
1032   state->nick->videoram = ram_get_ptr(machine->device(RAM_TAG));
10331033   Nick_Init(state->nick);
10341034   VIDEO_START_CALL(generic_bitmapped);
10351035}
src/mess/video/b2m.c
r9922r9923
99
1010#include "emu.h"
1111#include "includes/b2m.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414VIDEO_START( b2m )
1515{
r9922r9923
2828      for (y = 0; y < 256; y++)
2929      {
3030         if (state->b2m_video_page==0) {
31            code1 = messram_get_ptr(screen->machine->device("messram"))[0x11000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
32            code2 = messram_get_ptr(screen->machine->device("messram"))[0x15000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
31            code1 = ram_get_ptr(screen->machine->device(RAM_TAG))[0x11000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
32            code2 = ram_get_ptr(screen->machine->device(RAM_TAG))[0x15000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
3333         } else {
34            code1 = messram_get_ptr(screen->machine->device("messram"))[0x19000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
35            code2 = messram_get_ptr(screen->machine->device("messram"))[0x1d000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
34            code1 = ram_get_ptr(screen->machine->device(RAM_TAG))[0x19000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
35            code2 = ram_get_ptr(screen->machine->device(RAM_TAG))[0x1d000 + x*256 + ((y + state->b2m_video_scroll) & 0xff)];
3636         }
3737         for (b = 7; b >= 0; b--)
3838         {
src/mess/video/pmd85.c
r9922r9923
1010
1111#include "emu.h"
1212#include "includes/pmd85.h"
13#include "devices/messram.h"
13#include "machine/ram.h"
1414
1515const unsigned char pmd85_palette[3*3] =
1616{
r9922r9923
4242   UINT16 *scanline = BITMAP_ADDR16(bitmap, pmd85_scanline, 0);
4343
4444   /* address of current line in PMD-85 video memory */
45   UINT8* pmd85_video_ram_line = messram_get_ptr(machine->device("messram")) + 0xc000 + 0x40*pmd85_scanline;
45   UINT8* pmd85_video_ram_line = ram_get_ptr(machine->device(RAM_TAG)) + 0xc000 + 0x40*pmd85_scanline;
4646
4747   for (x=0; x<288; x+=6)
4848   {
src/mess/video/x68k.c
r9922r9923
2828#include "emu.h"
2929#include "includes/x68k.h"
3030#include "machine/68901mfp.h"
31#include "devices/messram.h"
31#include "machine/ram.h"
3232
3333
3434
r9922r9923
12591259//  popmessage("Graphic layer scroll - %i, %i - %i, %i - %i, %i - %i, %i",
12601260//      state->crtc.reg[12],state->crtc.reg[13],state->crtc.reg[14],state->crtc.reg[15],state->crtc.reg[16],state->crtc.reg[17],state->crtc.reg[18],state->crtc.reg[19]);
12611261//  popmessage("IOC IRQ status - %02x",state->ioc.irqstatus);
1262//  popmessage("RAM: mouse data - %02x %02x %02x %02x",messram_get_ptr(machine->device("messram"))[0x931],messram_get_ptr(machine->device("messram"))[0x930],messram_get_ptr(machine->device("messram"))[0x933],messram_get_ptr(machine->device("messram"))[0x932]);
1262//  popmessage("RAM: mouse data - %02x %02x %02x %02x",ram_get_ptr(machine->device(RAM_TAG))[0x931],ram_get_ptr(machine->device(RAM_TAG))[0x930],ram_get_ptr(machine->device(RAM_TAG))[0x933],ram_get_ptr(machine->device(RAM_TAG))[0x932]);
12631263#endif
12641264   return 0;
12651265}
src/mess/video/ondra.c
r9922r9923
99
1010#include "emu.h"
1111#include "includes/ondra.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414
1515
r9922r9923
3131      {
3232         for (y = 127; y >=0; y--)
3333         {
34            code1 = messram_get_ptr(screen->machine->device("messram"))[0xd700 + Vaddr + 0x80];
35            code2 = messram_get_ptr(screen->machine->device("messram"))[0xd700 + Vaddr + 0x00];
34            code1 = ram_get_ptr(screen->machine->device(RAM_TAG))[0xd700 + Vaddr + 0x80];
35            code2 = ram_get_ptr(screen->machine->device(RAM_TAG))[0xd700 + Vaddr + 0x00];
3636            for (b = 0; b < 8; b++)
3737            {
3838               *BITMAP_ADDR16(bitmap, 2*y, x*8+b) =  ((code1 << b) & 0x80) ? 1 : 0;
src/mess/video/timex.c
r9922r9923
1515
1616#include "emu.h"
1717#include "includes/spectrum.h"
18#include "devices/messram.h"
18#include "machine/ram.h"
1919
2020INLINE void spectrum_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color)
2121{
r9922r9923
6464   scrx=TS2068_LEFT_BORDER;
6565   scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0);
6666
67   scr=messram_get_ptr(machine->device("messram")) + y*32;
67   scr=ram_get_ptr(machine->device(RAM_TAG)) + y*32;
6868   attr=scr + 0x2000;
6969
7070   for (x=0;x<32;x++)
r9922r9923
108108   scrx=TS2068_LEFT_BORDER;
109109   scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0);
110110
111   scr1=messram_get_ptr(machine->device("messram")) + y*32;
111   scr1=ram_get_ptr(machine->device(RAM_TAG)) + y*32;
112112   scr2=scr1 + 0x2000;
113113
114114   for (x=0;x<32;x++)
r9922r9923
144144   scrx=TS2068_LEFT_BORDER;
145145   scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0);
146146
147   scr = messram_get_ptr(machine->device("messram")) + y*32 + screen*0x2000;
148   attr = messram_get_ptr(machine->device("messram")) + ((scry>>3)*32) + screen*0x2000 + 0x1800;
147   scr = ram_get_ptr(machine->device(RAM_TAG)) + y*32 + screen*0x2000;
148   attr = ram_get_ptr(machine->device(RAM_TAG)) + ((scry>>3)*32) + screen*0x2000 + 0x1800;
149149
150150   for (x=0;x<32;x++)
151151   {
src/mess/video/pcw.c
r9922r9923
88
99#include "emu.h"
1010#include "includes/pcw.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313INLINE void pcw_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color)
1414{
r9922r9923
107107
108108            x = PCW_BORDER_WIDTH;
109109
110            roller_ram_ptr = messram_get_ptr(screen->machine->device("messram")) + state->roller_ram_addr + roller_ram_offs;
110            roller_ram_ptr = ram_get_ptr(screen->machine->device(RAM_TAG)) + state->roller_ram_addr + roller_ram_offs;
111111
112112            /* get line address */
113113            /* b16-14 control which bank the line is to be found in, b13-3 the address in the bank (in 16-byte units), and b2-0 the offset. Thus a roller RAM address bbbxxxxxxxxxxxyyy indicates bank bbb, address 00xxxxxxxxxxx0yyy. */
114114            line_data = ((unsigned char *)roller_ram_ptr)[0] | (((unsigned char *)roller_ram_ptr)[1]<<8);
115115
116116            /* calculate address of pixel data */
117            line_ptr = messram_get_ptr(screen->machine->device("messram")) + ((line_data & 0x0e000)<<1) + ((line_data & 0x01ff8)<<1) + (line_data & 0x07);
117            line_ptr = ram_get_ptr(screen->machine->device(RAM_TAG)) + ((line_data & 0x0e000)<<1) + ((line_data & 0x01ff8)<<1) + (line_data & 0x07);
118118
119119            for (by=0; by<90; by++)
120120            {
src/mess/video/vector06.c
r9922r9923
99
1010#include "emu.h"
1111#include "includes/vector06.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414VIDEO_START( vector06 )
1515{
r9922r9923
3434      {
3535         // port A form 8255 also used as scroll
3636         draw_y = ((255-y-state->keyboard_mask) & 0xff) +32;
37         code1 = messram_get_ptr(screen->machine->device("messram"))[0x8000 + x*256 + y];
38         code2 = messram_get_ptr(screen->machine->device("messram"))[0xa000 + x*256 + y];
39         code3 = messram_get_ptr(screen->machine->device("messram"))[0xc000 + x*256 + y];
40         code4 = messram_get_ptr(screen->machine->device("messram"))[0xe000 + x*256 + y];
37         code1 = ram_get_ptr(screen->machine->device(RAM_TAG))[0x8000 + x*256 + y];
38         code2 = ram_get_ptr(screen->machine->device(RAM_TAG))[0xa000 + x*256 + y];
39         code3 = ram_get_ptr(screen->machine->device(RAM_TAG))[0xc000 + x*256 + y];
40         code4 = ram_get_ptr(screen->machine->device(RAM_TAG))[0xe000 + x*256 + y];
4141         for (b = 0; b < 8; b++)
4242         {
4343            col = ((code1 >> b) & 0x01) * 8 + ((code2 >> b) & 0x01) * 4 + ((code3 >> b) & 0x01)* 2+ ((code4 >> b) & 0x01);
src/mess/video/mc68328.c
r9922r9923
1010#include "emu.h"
1111#include "includes/mc68328.h"
1212#include "machine/mc68328.h"
13#include "devices/messram.h"
13#include "machine/ram.h"
1414
1515/* THIS IS PRETTY MUCH TOTALLY WRONG AND DOESN'T REFLECT THE MC68328'S INTERNAL FUNCTIONALITY AT ALL! */
1616PALETTE_INIT( mc68328 )
r9922r9923
2929    device_t *mc68328_device = screen->machine->device(MC68328_TAG);
3030    mc68328_t* mc68328 = mc68328_get_safe_token( mc68328_device );
3131
32    const UINT16 *video_ram = (const UINT16 *)(messram_get_ptr(screen->machine->device("messram")) + (mc68328->regs.lssa & 0x00ffffff));
32    const UINT16 *video_ram = (const UINT16 *)(ram_get_ptr(screen->machine->device(RAM_TAG)) + (mc68328->regs.lssa & 0x00ffffff));
3333    UINT16 word;
3434    UINT16 *line;
3535    int y, x, b;
src/mess/video/orion.c
r9922r9923
1010
1111#include "emu.h"
1212#include "includes/orion.h"
13#include "devices/messram.h"
13#include "machine/ram.h"
1414
1515VIDEO_START( orion128 )
1616{
r9922r9923
3030   {
3131      for (y = 0; y < 256; y++)
3232      {
33         code1 = messram_get_ptr(screen->machine->device("messram"))[part1addr + y + x*256];
34         code2 = messram_get_ptr(screen->machine->device("messram"))[part2addr + y + x*256];
35         code3 = messram_get_ptr(screen->machine->device("messram"))[part1addr + y + x*256 + 0x4000];
36         code4 = messram_get_ptr(screen->machine->device("messram"))[part2addr + y + x*256 + 0x4000];
33         code1 = ram_get_ptr(screen->machine->device(RAM_TAG))[part1addr + y + x*256];
34         code2 = ram_get_ptr(screen->machine->device(RAM_TAG))[part2addr + y + x*256];
35         code3 = ram_get_ptr(screen->machine->device(RAM_TAG))[part1addr + y + x*256 + 0x4000];
36         code4 = ram_get_ptr(screen->machine->device(RAM_TAG))[part2addr + y + x*256 + 0x4000];
3737         if ((video_mode==14) || (video_mode==15)) {
3838            code2 = state->orionpro_pseudo_color;
3939         }
src/mess/video/pc_t1t.c
r9922r9923
1313#include "video/pc_video_mess.h"
1414#include "video/mc6845.h"
1515#include "machine/pic8259.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717
1818/***************************************************************************
1919
r9922r9923
763763         dram = ((data & 0x07) << 14);
764764         vram = ((data & 0x38) << (14-3));
765765      }
766      memory_set_bankptr( machine, "bank14", messram_get_ptr(machine->device("messram")) + vram );
767      pcjr.displayram = messram_get_ptr(machine->device("messram")) + dram;
766      memory_set_bankptr( machine, "bank14", ram_get_ptr(machine->device(RAM_TAG)) + vram );
767      pcjr.displayram = ram_get_ptr(machine->device(RAM_TAG)) + dram;
768768      pc_pcjr_mode_switch(machine);
769769   }
770770}
src/mess/video/fmtowns.c
r9922r9923
8686
8787#include "emu.h"
8888#include "machine/pic8259.h"
89#include "devices/messram.h"
89#include "machine/ram.h"
9090#include "includes/fmtowns.h"
9191
9292//#define CRTC_REG_DISP 1
r9922r9923
149149   UINT8 ret = 0;
150150
151151   if(state->towns_mainmem_enable != 0)
152      return messram_get_ptr(state->messram)[offset+0xc0000];
152      return ram_get_ptr(state->messram)[offset+0xc0000];
153153
154154   offset = offset << 2;
155155
r9922r9923
174174
175175   if(state->towns_mainmem_enable != 0)
176176   {
177      messram_get_ptr(state->messram)[offset+0xc0000] = data;
177      ram_get_ptr(state->messram)[offset+0xc0000] = data;
178178      return;
179179   }
180180   offset = offset << 2;
r9922r9923
335335   towns_state* state = space->machine->driver_data<towns_state>();
336336
337337   if(state->towns_mainmem_enable != 0)
338      return messram_get_ptr(state->messram)[offset+0xcff80];
338      return ram_get_ptr(state->messram)[offset+0xcff80];
339339
340340   return towns_video_cff80_r(space,offset);
341341}
r9922r9923
346346
347347   if(state->towns_mainmem_enable != 0)
348348   {
349      messram_get_ptr(state->messram)[offset+0xcff80] = data;
349      ram_get_ptr(state->messram)[offset+0xcff80] = data;
350350      return;
351351   }
352352   towns_video_cff80_w(space,offset,data);
r9922r9923
609609READ8_HANDLER(towns_spriteram_low_r)
610610{
611611   towns_state* state = space->machine->driver_data<towns_state>();
612   UINT8* RAM = messram_get_ptr(state->messram);
612   UINT8* RAM = ram_get_ptr(state->messram);
613613   UINT8* ROM = space->machine->region("user")->base();
614614
615615   if(offset < 0x1000)
r9922r9923
648648WRITE8_HANDLER(towns_spriteram_low_w)
649649{
650650   towns_state* state = space->machine->driver_data<towns_state>();
651   UINT8* RAM = messram_get_ptr(state->messram);
651   UINT8* RAM = ram_get_ptr(state->messram);
652652
653653   if(offset < 0x1000)
654654   {  // 0xc8000-0xc8fff
src/mess/video/coco3.c
r9922r9923
3131#include "machine/6883sam.h"
3232#include "video/coco6847.h"
3333#include "includes/coco.h"
34#include "devices/messram.h"
34#include "machine/ram.h"
3535
3636#if defined(__GNUC__) && (__GNUC__ >= 3)
3737#define RESTRICT   __restrict__
r9922r9923
534534      memcpy_dirty(&dirty, scanline_record->palette, video->palette_ram, 16);
535535
536536      /* get ready to copy the video memory; get position and offsets */
537      video_data = &messram_get_ptr(machine->device("messram"))[video->video_position % messram_get_size(machine->device("messram"))];
537      video_data = &ram_get_ptr(machine->device(RAM_TAG))[video->video_position % ram_get_size(machine->device(RAM_TAG))];
538538      video_offset = (state->gimereg[15] & 0x7F) * 2;
539539      video_data_size = sizeof(scanline_record->data);
540540
src/mess/video/special.c
r9922r9923
99
1010#include "emu.h"
1111#include "includes/special.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414
1515
r9922r9923
103103   {
104104      for (y = 0; y < 256; y++)
105105      {
106         code = messram_get_ptr(screen->machine->device("messram"))[0x9000 + y + x*256];
106         code = ram_get_ptr(screen->machine->device(RAM_TAG))[0x9000 + y + x*256];
107107         color = state->specimx_colorram[y + x*256];
108108         for (b = 7; b >= 0; b--)
109109         {
r9922r9923
146146   UINT8 *erik_video_ram_p1;
147147   UINT8 *erik_video_ram_p2;
148148
149   erik_video_ram_p1 =  messram_get_ptr(screen->machine->device("messram")) + 0x9000;
150   erik_video_ram_p2 =  messram_get_ptr(screen->machine->device("messram")) + 0xd000;
149   erik_video_ram_p1 =  ram_get_ptr(screen->machine->device(RAM_TAG)) + 0x9000;
150   erik_video_ram_p2 =  ram_get_ptr(screen->machine->device(RAM_TAG)) + 0xd000;
151151
152152   for (x = 0; x < 48; x++)
153153   {
src/mess/video/pp01.c
r9922r9923
99
1010#include "emu.h"
1111#include "includes/pp01.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414VIDEO_START( pp01 )
1515{
r9922r9923
2626    {
2727       for (x = 0; x < 32; x++)
2828       {
29            code_r = messram_get_ptr(screen->machine->device("messram"))[0x6000 + ((y+state->video_scroll)&0xff)*32 + x];
30            code_g = messram_get_ptr(screen->machine->device("messram"))[0xa000 + ((y+state->video_scroll)&0xff)*32 + x];
31            code_b = messram_get_ptr(screen->machine->device("messram"))[0xe000 + ((y+state->video_scroll)&0xff)*32 + x];
29            code_r = ram_get_ptr(screen->machine->device(RAM_TAG))[0x6000 + ((y+state->video_scroll)&0xff)*32 + x];
30            code_g = ram_get_ptr(screen->machine->device(RAM_TAG))[0xa000 + ((y+state->video_scroll)&0xff)*32 + x];
31            code_b = ram_get_ptr(screen->machine->device(RAM_TAG))[0xe000 + ((y+state->video_scroll)&0xff)*32 + x];
3232            for (b = 0; b < 8; b++)
3333            {
3434                col = (((code_r >> b) & 0x01) ? 4 : 0) + (((code_g >> b) & 0x01) ? 2 : 0) + (((code_b >> b) & 0x01) ? 1 : 0);
src/mess/video/apple2.c
r9922r9923
77#include "emu.h"
88#include "includes/apple2.h"
99#include "profiler.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111
1212/***************************************************************************/
1313
r9922r9923
451451
452452VIDEO_START( apple2 )
453453{
454   apple2_video_start(machine, messram_get_ptr(machine->device("messram")), messram_get_size(machine->device("messram")), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 4);
454   apple2_video_start(machine, ram_get_ptr(machine->device(RAM_TAG)), ram_get_size(machine->device(RAM_TAG)), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 4);
455455
456456   /* hack to fix the colors on apple2/apple2p */
457457   fgcolor = 0;
r9922r9923
461461
462462VIDEO_START( apple2p )
463463{
464   apple2_video_start(machine, messram_get_ptr(machine->device("messram")), messram_get_size(machine->device("messram")), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 8);
464   apple2_video_start(machine, ram_get_ptr(machine->device(RAM_TAG)), ram_get_size(machine->device(RAM_TAG)), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 8);
465465
466466   /* hack to fix the colors on apple2/apple2p */
467467   fgcolor = 0;
r9922r9923
471471
472472VIDEO_START( apple2e )
473473{
474   apple2_video_start(machine, messram_get_ptr(machine->device("messram")), messram_get_size(machine->device("messram")), 0, 8);
474   apple2_video_start(machine, ram_get_ptr(machine->device(RAM_TAG)), ram_get_size(machine->device(RAM_TAG)), 0, 8);
475475}
476476
477477
src/mess/video/pk8020.c
r9922r9923
88
99#include "emu.h"
1010#include "includes/pk8020.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313VIDEO_START( pk8020 )
1414{
r9922r9923
2424   {
2525      for (x = 0; x < 64; x++)
2626      {
27         UINT8 chr = messram_get_ptr(screen->machine->device("messram"))[x +(y*64) + 0x40000];
28         UINT8 attr= messram_get_ptr(screen->machine->device("messram"))[x +(y*64) + 0x40400];
27         UINT8 chr = ram_get_ptr(screen->machine->device(RAM_TAG))[x +(y*64) + 0x40000];
28         UINT8 attr= ram_get_ptr(screen->machine->device(RAM_TAG))[x +(y*64) + 0x40400];
2929         for (j = 0; j < 16; j++) {
3030            UINT32 addr = 0x10000 + x + ((y*16+j)*64) + (state->video_page * 0xC000);
31            UINT8 code1 = messram_get_ptr(screen->machine->device("messram"))[addr];
32            UINT8 code2 = messram_get_ptr(screen->machine->device("messram"))[addr + 0x4000];
33            UINT8 code3 = messram_get_ptr(screen->machine->device("messram"))[addr + 0x8000];
31            UINT8 code1 = ram_get_ptr(screen->machine->device(RAM_TAG))[addr];
32            UINT8 code2 = ram_get_ptr(screen->machine->device(RAM_TAG))[addr + 0x4000];
33            UINT8 code3 = ram_get_ptr(screen->machine->device(RAM_TAG))[addr + 0x8000];
3434            UINT8 code4 = gfx[((chr<<4) + j) + (state->font*0x1000)];
3535            if (attr) code4 ^= 0xff;
3636            for (b = 0; b < 8; b++)
src/mess/video/kc.c
r9922r9923
88
99#include "emu.h"
1010#include "includes/kc.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313/* KC85/4 and KC85/3 common graphics hardware */
1414
r9922r9923
717717{
718718#if 0
719719   /* colour ram takes up 0x02800 bytes */
720      unsigned char *pixel_ram = messram_get_ptr(machine->device("messram"))+0x08000;
720      unsigned char *pixel_ram = ram_get_ptr(machine->device(RAM_TAG))+0x08000;
721721    unsigned char *colour_ram = pixel_ram + 0x02800;
722722
723723    int x,y;
r9922r9923
758758
759759   struct grab_info grab_data;
760760
761   grab_data.pixel_ram = messram_get_ptr(screen->machine->device("messram"))+0x08000;
762   grab_data.colour_ram = messram_get_ptr(screen->machine->device("messram"))+0x08000 + 0x02800;
761   grab_data.pixel_ram = ram_get_ptr(screen->machine->device(RAM_TAG))+0x08000;
762   grab_data.colour_ram = ram_get_ptr(screen->machine->device(RAM_TAG))+0x08000 + 0x02800;
763763
764764   kc85_common_process_frame(screen->machine, bitmap, kc85_3_pixel_grab_callback,&grab_data);
765765
src/mess/includes/vixen.h
r9922r9923
33#ifndef __VIXEN__
44#define __VIXEN__
55
6#include "machine/ram.h"
7
68#define Z8400A_TAG      "5f"
79#define FDC1797_TAG      "5n"
810#define P8155H_TAG      "2n"
r9922r9923
2325        m_usart(*this, P8251A_TAG),
2426        m_discrete(*this, DISCRETE_TAG),
2527        m_ieee488(*this, IEEE488_TAG),
26        m_ram(*this, "messram"),
28        m_ram(*this, RAM_TAG),
2729        m_floppy0(*this, FLOPPY_0),
2830        m_floppy1(*this, FLOPPY_1),
2931        m_fdint(0),
src/mess/includes/vip.h
r9922r9923
66#include "cpu/cosmac/cosmac.h"
77#include "audio/vp550.h"
88#include "audio/vp595.h"
9#include "machine/ram.h"
910
1011#define SCREEN_TAG      "screen"
1112#define CDP1802_TAG      "u1"
r9922r9923
5960        m_vp595(*this, VP595_TAG),
6061        m_vp550(*this, VP550_TAG),
6162        m_vp551(*this, VP551_TAG),
62        m_ram(*this, "messram")
63        m_ram(*this, RAM_TAG)
6364   { }
6465
6566   required_device<cosmac_device> m_maincpu;
src/mess/includes/mac.h
r9922r9923
1111
1212#include "machine/8530scc.h"
1313#include "machine/6522via.h"
14#include "machine/ram.h"
1415
1516/* for Egret and CUDA streaming MCU commands, command types */
1617typedef enum
r9922r9923
182183      m_via1(*this, "via6522_0"),
183184      m_via2(*this, "via6522_1"),
184185      m_asc(*this, "asc"),
185      m_ram(*this, "messram")
186      m_ram(*this, RAM_TAG)
186187    { }
187188
188189   required_device<cpu_device> m_maincpu;
src/mess/includes/bw12.h
r9922r9923
11#ifndef __BW12__
22#define __BW12__
33
4#include "machine/ram.h"
5
46#define SCREEN_TAG         "screen"
57#define Z80_TAG            "ic35"
68#define MC6845_TAG         "ic14"
r9922r9923
2729        m_kbc(*this, AY3600_TAG),
2830        m_crtc(*this, MC6845_TAG),
2931        m_centronics(*this, CENTRONICS_TAG),
30        m_ram(*this, "messram"),
32        m_ram(*this, RAM_TAG),
3133        m_floppy0(*this, FLOPPY_0),
3234        m_floppy1(*this, FLOPPY_1),
3335        m_floppy_timer(*this, FLOPPY_TIMER_TAG)
src/mess/includes/gb.h
r9922r9923
2121#endif
2222
2323/* Cartridge types */
24#define RAM         0x01   /* Cartridge has RAM                             */
24#define CART_RAM   0x01   /* Cartridge has RAM                             */
2525#define BATTERY      0x02   /* Cartridge has a battery to save RAM           */
2626#define TIMER      0x04   /* Cartridge has a real-time-clock (MBC3 only)   */
2727#define RUMBLE      0x08   /* Cartridge has a rumble motor (MBC5 only)      */
src/mess/includes/xor100.h
r9922r9923
33#ifndef __XOR100__
44#define __XOR100__
55
6#include "machine/ram.h"
7
68#define SCREEN_TAG      "screen"
79#define Z80_TAG         "5b"
810#define I8251_A_TAG      "12b"
r9922r9923
2426        m_uart_b(*this, I8251_B_TAG),
2527        m_fdc(*this, WD1795_TAG),
2628        m_ctc(*this, Z80CTC_TAG),
27        m_ram(*this, "messram"),
29        m_ram(*this, RAM_TAG),
2830        m_terminal(*this, TERMINAL_TAG),
2931        m_floppy0(*this, FLOPPY_0),
3032        m_floppy1(*this, FLOPPY_1)
src/mess/includes/tmc600.h
r9922r9923
44#define __TMC600__
55
66#include "cpu/cosmac/cosmac.h"
7#include "machine/ram.h"
78
89#define SCREEN_TAG      "screen"
910#define CDP1802_TAG      "cdp1802"
r9922r9923
2223        m_maincpu(*this, CDP1802_TAG),
2324        m_vis(*this, CDP1869_TAG),
2425        m_cassette(*this, CASSETTE_TAG),
25        m_ram(*this, "messram")
26        m_ram(*this, RAM_TAG)
2627    { }
2728
2829   required_device<cosmac_device> m_maincpu;
src/mess/includes/abc80.h
r9922r9923
77#ifndef __ABC80__
88#define __ABC80__
99
10#include "machine/ram.h"
11
1012#define ABC80_XTAL      11980800.0
1113
1214#define ABC80_HTOTAL   384
r9922r9923
5557        m_pio(*this, Z80PIO_TAG),
5658        m_rs232(*this, RS232_TAG),
5759        m_cassette(*this, CASSETTE_TAG),
58        m_ram(*this, "messram")
60        m_ram(*this, RAM_TAG)
5961   { }
6062
6163   required_device<cpu_device> m_maincpu;
src/mess/includes/victor9k.h
r9922r9923
33#ifndef __VICTOR9K__
44#define __VICTOR9K__
55
6#include "machine/ram.h"
7
68#define SCREEN_TAG      "screen"
79#define I8088_TAG      "8l"
810#define I8048_TAG      "5d"
r9922r9923
3638        m_via1(*this, M6522_1_TAG),
3739        m_cvsd(*this, HC55516_TAG),
3840        m_crtc(*this, HD46505S_TAG),
39        m_ram(*this, "messram"),
41        m_ram(*this, RAM_TAG),
4042        m_floppy0(*this, FLOPPY_0),
4143        m_floppy1(*this, FLOPPY_1)
4244   { }
src/mess/includes/sg1000.h
r9922r9923
11#ifndef __SG1000__
22#define __SG1000__
33
4#include "machine/ram.h"
5
46#define SCREEN_TAG      "screen"
57#define Z80_TAG         "z80"
68#define SN76489A_TAG   "sn76489a"
r9922r9923
3032   sg1000_state(running_machine &machine, const driver_device_config_base &config)
3133      : driver_device(machine, config),
3234        m_maincpu(*this, Z80_TAG),
33        m_ram(*this, "messram")
35        m_ram(*this, RAM_TAG)
3436   { }
3537
3638   required_device<cpu_device> m_maincpu;
src/mess/includes/bw2.h
r9922r9923
11#ifndef __BW2__
22#define __BW2__
33
4#include "machine/ram.h"
5
46#define SCREEN_TAG      "screen"
57#define Z80_TAG         "ic1"
68#define I8255A_TAG      "ic4"
r9922r9923
3436        m_fdc(*this, WD2797_TAG),
3537        m_lcdc(*this, MSM6255_TAG),
3638        m_centronics(*this, CENTRONICS_TAG),
37        m_ram(*this, "messram"),
39        m_ram(*this, RAM_TAG),
3840        m_floppy0(*this, FLOPPY_0),
3941        m_floppy1(*this, FLOPPY_1)
4042   { }
src/mess/includes/v1050.h
r9922r9923
22#define __V1050__
33
44#include "devices/flopdrv.h"
5#include "machine/ram.h"
56
67#define SCREEN_TAG            "screen"
78
r9922r9923
5051        m_fdc(*this, MB8877_TAG),
5152        m_crtc(*this, H46505_TAG),
5253        m_centronics(*this, CENTRONICS_TAG),
53        m_ram(*this, "messram"),
54        m_ram(*this, RAM_TAG),
5455        m_discrete(*this, DISCRETE_TAG),
5556        m_floppy0(*this, FLOPPY_0),
5657        m_floppy1(*this, FLOPPY_1),
src/mess/includes/ql.h
r9922r9923
33#ifndef __QL__
44#define __QL__
55
6#include "machine/ram.h"
7
68#define SCREEN_TAG   "screen"
79
810#define M68008_TAG   "ic18"
r9922r9923
3032        m_speaker(*this, SPEAKER_TAG),
3133        m_mdv1(*this, MDV_1),
3234        m_mdv2(*this, MDV_2),
33        m_ram(*this, "messram")
35        m_ram(*this, RAM_TAG)
3436   { }
3537
3638   required_device<cpu_device> m_maincpu;
src/mess/includes/abc80x.h
r9922r9923
66#include "machine/abc77.h"
77#include "machine/z80ctc.h"
88#include "machine/z80dart.h"
9#include "machine/ram.h"
910
1011
11
1212//**************************************************************************
1313//   MACROS / CONSTANTS
1414//**************************************************************************
r9922r9923
6363        m_dart(*this, Z80DART_TAG),
6464        m_sio(*this, Z80SIO_TAG),
6565        m_discrete(*this, "discrete"),
66        m_ram(*this, "messram")
66        m_ram(*this, RAM_TAG)
6767   { }
6868
6969   required_device<cpu_device> m_maincpu;
r9922r9923
159159        m_crtc(*this, MC6845_TAG),
160160        abc77(*this, ABC77_TAG),
161161        m_discrete(*this, "discrete"),
162        m_ram(*this, "messram")
162        m_ram(*this, RAM_TAG)
163163   { }
164164
165165   required_device<cpu_device> m_maincpu;
r9922r9923
214214        m_crtc(*this, MC6845_TAG),
215215        m_rtc(*this, E0516_TAG),
216216        abc77(*this, ABC77_TAG),
217        m_ram(*this, "messram")
217        m_ram(*this, RAM_TAG)
218218   { }
219219
220220   required_device<cpu_device> m_maincpu;
src/mess/includes/tek405x.h
r9922r9923
33#ifndef __TEK405X__
44#define __TEK405X__
55
6#include "machine/ram.h"
7
68#define MC6800_TAG         "u61"
79#define MC6820_Y_TAG      "u561"
810#define MC6820_X_TAG      "u565"
r9922r9923
2931        m_acia(*this, MC6850_TAG),
3032        m_ieee(*this, IEEE488_TAG),
3133        m_speaker(*this, SPEAKER_TAG),
32        m_ram(*this, "messram")
34        m_ram(*this, RAM_TAG)
3335    { }
3436
3537   required_device<cpu_device> m_maincpu;
r9922r9923
132134   tek4052_state(running_machine &machine, const driver_device_config_base &config)
133135      : driver_device(machine, config),
134136        m_maincpu(*this, AM2901A_TAG),
135        m_ram(*this, "messram")
137        m_ram(*this, RAM_TAG)
136138    { }
137139
138140   required_device<cpu_device> m_maincpu;
src/mess/includes/bullet.h
r9922r9923
33#ifndef __BULLET__
44#define __BULLET__
55
6#include "machine/ram.h"
7
68#define Z80_TAG         "u20"
79#define Z80CTC_TAG      "u1"
810#define Z80DMA_TAG      "u50"
r9922r9923
2224        m_dart(*this, Z80DART_TAG),
2325        m_dmac(*this, Z80DMA_TAG),
2426        m_fdc(*this, MB8877_TAG),
25        m_ram(*this, "messram"),
27        m_ram(*this, RAM_TAG),
2628        m_floppy0(*this, FLOPPY_0),
2729        m_floppy1(*this, FLOPPY_1),
2830        m_terminal(*this, TERMINAL_TAG),
src/mess/includes/kyocera.h
r9922r9923
22#define __KYOCERA__
33
44#include "video/hd61830.h"
5#include "machine/ram.h"
56
67#define SCREEN_TAG      "screen"
78#define I8085_TAG      "m19"
r9922r9923
5152        m_centronics(*this, CENTRONICS_TAG),
5253        m_speaker(*this, SPEAKER_TAG),
5354        m_cassette(*this, CASSETTE_TAG),
54        m_ram(*this, "messram")
55        m_ram(*this, RAM_TAG)
5556   { }
5657
5758   required_device<cpu_device> m_maincpu;
r9922r9923
145146        m_centronics(*this, CENTRONICS_TAG),
146147        m_speaker(*this, SPEAKER_TAG),
147148        m_cassette(*this, CASSETTE_TAG),
148        m_ram(*this, "messram")
149        m_ram(*this, RAM_TAG)
149150   { }
150151
151152   required_device<cpu_device> m_maincpu;
src/mess/includes/comx35.h
r9922r9923
66#include "machine/cdp1871.h"
77#include "devices/snapquik.h"
88#include "machine/wd17xx.h"
9#include "machine/ram.h"
910
1011#define SCREEN_TAG         "screen"
1112#define MC6845_SCREEN_TAG   "screen80"
r9922r9923
4950        m_fdc(*this, WD1770_TAG),
5051        m_kbe(*this, CDP1871_TAG),
5152        m_cassette(*this, CASSETTE_TAG),
52        m_ram(*this, "messram")
53        m_ram(*this, RAM_TAG)
5354   { }
5455
5556   required_device<cosmac_device> m_maincpu;
src/mess/includes/xerox820.h
r9922r9923
11#ifndef __XEROX820__
22#define __XEROX820__
33
4#include "machine/ram.h"
5
46#define SCREEN_TAG      "screen"
57
68#define Z80_TAG         "u46"
r9922r9923
2426        m_kbpio(*this, Z80KBPIO_TAG),
2527        m_ctc(*this, Z80CTC_TAG),
2628        m_fdc(*this, WD1771_TAG),
27        m_ram(*this, "messram"),
29        m_ram(*this, RAM_TAG),
2830        m_floppy0(*this, FLOPPY_0),
2931        m_floppy1(*this, FLOPPY_1)
3032   { }
src/mess/includes/ob68k1a.h
r9922r9923
33#ifndef __OB68K1A__
44#define __OB68K1A__
55
6#include "machine/ram.h"
7
68#define MC68000L10_TAG   "u50"
79#define MC6821_0_TAG   "u32"
810#define MC6821_1_TAG   "u33"
r9922r9923
2325        m_pia0(*this, MC6821_0_TAG),
2426        m_pia1(*this, MC6821_1_TAG),
2527        m_terminal(*this, TERMINAL_TAG),
26        m_ram(*this, "messram")
28        m_ram(*this, RAM_TAG)
2729   { }
2830
2931   required_device<cpu_device> m_maincpu;
src/mess/includes/tandy2k.h
r9922r9923
11#ifndef __TANDY2K__
22#define __TANDY2K__
33
4#include "machine/ram.h"
5
46#define SCREEN_TAG      "screen"
57#define I80186_TAG      "u76"
68#define I8048_TAG      "m1"
r9922r9923
3537        m_vac(*this, CRT9021B_TAG),
3638        m_centronics(*this, CENTRONICS_TAG),
3739        m_speaker(*this, SPEAKER_TAG),
38        m_ram(*this, "messram"),
40        m_ram(*this, RAM_TAG),
3941        m_floppy0(*this, FLOPPY_0),
4042        m_floppy1(*this, FLOPPY_1)
4143   { }
src/mess/formats/comx35_comx.c
r9922r9923
99#include "emu.h"
1010#include "imageutl.h"
1111#include "formats/comx35_comx.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414/***************************************************************************
1515    PARAMETERS
r9922r9923
5252   UINT8 header[16] = {0};
5353   int size = image.length();
5454
55   if (size > messram_get_size(image.device().machine->device("messram")))
55   if (size > ram_get_size(image.device().machine->device(RAM_TAG)))
5656   {
5757      return IMAGE_INIT_FAIL;
5858   }
src/mess/mess.mak
r9922r9923
436436   $(MESS_FORMATS)/fdi_dsk.o   \
437437   $(MESS_DEVICES)/flopdrv.o   \
438438   $(MESS_DEVICES)/harddriv.o   \
439   $(MESS_DEVICES)/messram.o   \
440439   $(MESS_DEVICES)/microdrv.o   \
441440   $(MESS_DEVICES)/multcart.o   \
442441   $(MESS_DEVICES)/printer.o   \
src/mess/drivers/vip.c
r9922r9923
231231#include "video/cdp1861.h"
232232#include "video/cdp1862.h"
233233#include "machine/rescap.h"
234#include "devices/messram.h"
234#include "machine/ram.h"
235235
236236static QUICKLOAD_LOAD( vip );
237237
r9922r9923
261261{
262262   /* enable RAM */
263263   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
264   UINT8 *ram = messram_get_ptr(m_ram);
264   UINT8 *ram = ram_get_ptr(m_ram);
265265
266   switch (messram_get_size(m_ram))
266   switch (ram_get_size(m_ram))
267267   {
268268   case 1 * 1024:
269269      memory_install_ram(program, 0x0000, 0x03ff, 0, 0x7c00, ram);
r9922r9923
598598
599599void vip_state::machine_start()
600600{
601   UINT8 *ram = messram_get_ptr(m_ram);
601   UINT8 *ram = ram_get_ptr(m_ram);
602602
603603   /* randomize RAM contents */
604   for (UINT16 addr = 0; addr < messram_get_size(m_ram); addr++)
604   for (UINT16 addr = 0; addr < ram_get_size(m_ram); addr++)
605605   {
606606      ram[addr] = machine->rand() & 0xff;
607607   }
r9922r9923
726726   MCFG_CASSETTE_ADD("cassette", vip_cassette_config)
727727
728728   /* internal ram */
729   MCFG_RAM_ADD("messram")
729   MCFG_RAM_ADD(RAM_TAG)
730730   MCFG_RAM_DEFAULT_SIZE("2K")
731731   MCFG_RAM_EXTRA_OPTIONS("4K")
732732MACHINE_CONFIG_END
733733
734734static MACHINE_CONFIG_DERIVED( vp111, vip )
735735   /* internal ram */
736   MCFG_RAM_MODIFY("messram")
736   MCFG_RAM_MODIFY(RAM_TAG)
737737   MCFG_RAM_DEFAULT_SIZE("1K")
738738   MCFG_RAM_EXTRA_OPTIONS("2K,4K")
739739MACHINE_CONFIG_END
r9922r9923
778778      chip8_size = image.device().machine->region("chip8x")->bytes();
779779   }
780780
781   if ((size + chip8_size) > messram_get_size(image.device().machine->device("messram")))
781   if ((size + chip8_size) > ram_get_size(image.device().machine->device(RAM_TAG)))
782782   {
783783      return IMAGE_INIT_FAIL;
784784   }
src/mess/drivers/dgn_beta.c
r9922r9923
4646#include "formats/coco_dsk.h"
4747#include "devices/flopdrv.h"
4848#include "devices/coco_vhd.h"
49#include "devices/messram.h"
49#include "machine/ram.h"
5050
5151/*
5252 Colour codes are as below acording to os-9 headers, however the presise values
r9922r9923
351351   MCFG_FLOPPY_4_DRIVES_ADD(dgnbeta_floppy_config)
352352
353353   /* internal ram */
354   MCFG_RAM_ADD("messram")
354   MCFG_RAM_ADD(RAM_TAG)
355355   MCFG_RAM_DEFAULT_SIZE("256K")
356356   MCFG_RAM_EXTRA_OPTIONS("128K,384K,512K,640K,768K")
357357   /* Ram size can now be configured, since the machine was known as either the Dragon Beta or */
src/mess/drivers/elf.c
r9922r9923
2222#include "video/dm9368.h"
2323#include "machine/rescap.h"
2424#include "elf2.lh"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626
2727#define RUN(_machine)            BIT(input_port_read((_machine), "SPECIAL"), 0)
2828#define LOAD(_machine)            BIT(input_port_read((_machine), "SPECIAL"), 1)
r9922r9923
6565      if (MEMORY_PROTECT(space->machine))
6666      {
6767         /* latch data from memory */
68         data = messram_get_ptr(space->machine->device("messram"))[offset];
68         data = ram_get_ptr(space->machine->device(RAM_TAG))[offset];
6969      }
7070      else
7171      {
7272         /* write latched data to memory */
73         messram_get_ptr(space->machine->device("messram"))[offset] = data;
73         ram_get_ptr(space->machine->device(RAM_TAG))[offset] = data;
7474      }
7575
7676      /* write data to 7 segment displays */
r9922r9923
274274   /* setup memory banking */
275275   memory_install_read_bank(program, 0x0000, 0x00ff, 0, 0, "bank1");
276276   memory_install_write8_handler(program, 0x0000, 0x00ff, 0, 0, memory_w);
277   memory_configure_bank(machine, "bank1", 0, 1, messram_get_ptr(machine->device("messram")), 0);
277   memory_configure_bank(machine, "bank1", 0, 1, ram_get_ptr(machine->device(RAM_TAG)), 0);
278278   memory_set_bank(machine, "bank1", 0);
279279
280280   /* register for state saving */
r9922r9923
320320   MCFG_QUICKLOAD_ADD("quickload", elf, "bin", 0)
321321
322322   /* internal ram */
323   MCFG_RAM_ADD("messram")
323   MCFG_RAM_ADD(RAM_TAG)
324324   MCFG_RAM_DEFAULT_SIZE("256")
325325MACHINE_CONFIG_END
326326
r9922r9923
336336{
337337   int size = image.length();
338338
339   if (size > messram_get_size(image.device().machine->device("messram")))
339   if (size > ram_get_size(image.device().machine->device(RAM_TAG)))
340340   {
341341      return IMAGE_INIT_FAIL;
342342   }
343343
344   image.fread( messram_get_ptr(image.device().machine->device("messram")), size);
344   image.fread( ram_get_ptr(image.device().machine->device(RAM_TAG)), size);
345345
346346   return IMAGE_INIT_PASS;
347347}
src/mess/drivers/vt520.c
r9922r9923
77****************************************************************************/
88
99#include "emu.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111#include "cpu/mcs51/mcs51.h"
1212
1313
r9922r9923
8888   // On the board there are two M5M44256BJ-7 chips
8989   // Which are DRAM 256K x 4bit
9090   /* internal ram */
91   MCFG_RAM_ADD("messram")
91   MCFG_RAM_ADD(RAM_TAG)
9292   MCFG_RAM_DEFAULT_SIZE("256K")
9393MACHINE_CONFIG_END
9494
src/mess/drivers/pc8401a.c
r9922r9923
77#include "machine/upd1990a.h"
88#include "video/sed1330.h"
99#include "video/mc6845.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111
1212/*
1313
r9922r9923
142142      break;
143143
144144   case 3: /* RAM cartridge */
145      if (messram_get_size(machine->device("messram")) > 64)
145      if (ram_get_size(machine->device(RAM_TAG)) > 64)
146146      {
147147         memory_install_readwrite_bank(program, 0x8000, 0xbfff, 0, 0, "bank3");
148148         memory_set_bank(machine, "bank3", 3); // TODO or 4
r9922r9923
527527
528528   /* set up A0/A1 memory banking */
529529   memory_configure_bank(machine, "bank1", 0, 4, machine->region(Z80_TAG)->base(), 0x8000);
530   memory_configure_bank(machine, "bank1", 4, 2, messram_get_ptr(machine->device("messram")), 0x8000);
530   memory_configure_bank(machine, "bank1", 4, 2, ram_get_ptr(machine->device(RAM_TAG)), 0x8000);
531531   memory_set_bank(machine, "bank1", 0);
532532
533533   /* set up A2 memory banking */
534   memory_configure_bank(machine, "bank3", 0, 5, messram_get_ptr(machine->device("messram")), 0x4000);
534   memory_configure_bank(machine, "bank3", 0, 5, ram_get_ptr(machine->device(RAM_TAG)), 0x4000);
535535   memory_set_bank(machine, "bank3", 0);
536536
537537   /* set up A3 memory banking */
538   memory_configure_bank(machine, "bank4", 0, 1, messram_get_ptr(machine->device("messram")) + 0xc000, 0);
538   memory_configure_bank(machine, "bank4", 0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0xc000, 0);
539539   memory_configure_bank(machine, "bank4", 1, 1, state->crt_ram, 0);
540540   memory_set_bank(machine, "bank4", 0);
541541
542542   /* set up A4 memory banking */
543   memory_configure_bank(machine, "bank5", 0, 1, messram_get_ptr(machine->device("messram")) + 0xe800, 0);
543   memory_configure_bank(machine, "bank5", 0, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0xe800, 0);
544544   memory_set_bank(machine, "bank5", 0);
545545
546546   /* bank switch */
r9922r9923
669669   MCFG_CARTSLOT_NOT_MANDATORY
670670
671671   /* internal ram */
672   MCFG_RAM_ADD("messram")
672   MCFG_RAM_ADD(RAM_TAG)
673673   MCFG_RAM_DEFAULT_SIZE("64K")
674674   MCFG_RAM_EXTRA_OPTIONS("96K")
675675MACHINE_CONFIG_END
r9922r9923
690690   MCFG_FRAGMENT_ADD(pc8500_video)
691691
692692   /* internal ram */
693   MCFG_RAM_MODIFY("messram")
693   MCFG_RAM_MODIFY(RAM_TAG)
694694   MCFG_RAM_DEFAULT_SIZE("64K")
695695MACHINE_CONFIG_END
696696
src/mess/drivers/apple3.c
r9922r9923
1818#include "formats/ap2_dsk.h"
1919#include "machine/6551.h"
2020#include "machine/6522via.h"
21#include "devices/messram.h"
21#include "machine/ram.h"
2222#include "devices/appldriv.h"
2323
2424static ADDRESS_MAP_START( apple3_map, ADDRESS_SPACE_PROGRAM, 8 )
r9922r9923
109109   MCFG_VIA6522_ADD("via6522_1", 2000000, apple3_via_1_intf)
110110
111111   /* internal ram */
112   MCFG_RAM_ADD("messram")
112   MCFG_RAM_ADD(RAM_TAG)
113113   MCFG_RAM_DEFAULT_SIZE("512K")
114114MACHINE_CONFIG_END
115115
src/mess/drivers/osbexec.c
r9922r9923
1414#include "machine/6821pia.h"
1515#include "machine/z80dart.h"
1616#include "machine/pit8253.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818
1919
2020#define MAIN_CLOCK   23961600
r9922r9923
2727      : driver_device(machine, config),
2828         maincpu( *this, "maincpu" ),
2929         mb8877( *this, "mb8877" ),
30         messram( *this, "messram" ),
30         messram( *this, RAM_TAG ),
3131         pia_0( *this, "pia_0" ),
3232         pia_1( *this, "pia_1" ),
3333         sio( *this, "sio" ),
r9922r9923
6565
6666   void set_banks(running_machine *machine)
6767   {
68      UINT8 *messram_ptr = messram_get_ptr( messram );
68      UINT8 *ram_ptr = ram_get_ptr( messram );
6969
70      ram_0000 = messram_ptr;
70      ram_0000 = ram_ptr;
7171
7272      if ( pia0_porta & 0x01 )
7373         ram_0000 += 0x10000;
r9922r9923
8282      {
8383         memory_set_bankptr( machine, "0000", machine->region("maincpu")->base());
8484         /* When BIOS is enabled 2000-3FFF is set to the "ROM RAM" */
85         memory_set_bankptr( machine, "2000", messram_ptr + 0x20000 );
85         memory_set_bankptr( machine, "2000", ram_ptr + 0x20000 );
8686      }
8787
8888      if ( pia0_porta & 0x40 )
r9922r9923
654654   MCFG_FLOPPY_2_DRIVES_ADD(osbexec_floppy_config)
655655
656656   /* internal ram */
657   MCFG_RAM_ADD("messram")
657   MCFG_RAM_ADD(RAM_TAG)
658658   MCFG_RAM_DEFAULT_SIZE("136K")   /* 128KB Main RAM + RAM in ROM bank (8) */
659659MACHINE_CONFIG_END
660660
src/mess/drivers/c65.c
r9922r9923
6666#include "includes/c64.h"
6767#include "includes/c65.h"
6868#include "machine/cbmiec.h"
69#include "devices/messram.h"
69#include "machine/ram.h"
7070
7171/*************************************
7272 *
r9922r9923
328328   MCFG_FRAGMENT_ADD(c64_cartslot)
329329
330330   /* internal ram */
331   MCFG_RAM_ADD("messram")
331   MCFG_RAM_ADD(RAM_TAG)
332332   MCFG_RAM_DEFAULT_SIZE("128K")
333333   MCFG_RAM_EXTRA_OPTIONS("640K,4224K")
334334MACHINE_CONFIG_END
src/mess/drivers/dai.c
r9922r9923
6666#include "machine/pit8253.h"
6767#include "machine/tms5501.h"
6868#include "devices/cassette.h"
69#include "devices/messram.h"
69#include "machine/ram.h"
7070
7171/* I/O ports */
7272static ADDRESS_MAP_START( dai_io , ADDRESS_SPACE_IO, 8)
r9922r9923
245245   MCFG_TMS5501_ADD( "tms5501", dai_tms5501_interface )
246246
247247   /* internal ram */
248   MCFG_RAM_ADD("messram")
248   MCFG_RAM_ADD(RAM_TAG)
249249   MCFG_RAM_DEFAULT_SIZE("48K")
250250MACHINE_CONFIG_END
251251
src/mess/drivers/mc1000.c
r9922r9923
2828#include "sound/ay8910.h"
2929#include "machine/ctronics.h"
3030#include "machine/rescap.h"
31#include "devices/messram.h"
31#include "machine/ram.h"
3232
3333/* Memory Banking */
3434
r9922r9923
4141   memory_set_bank(machine, "bank2", state->mc6845_bank);
4242
4343   /* extended RAM */
44   if (messram_get_size(machine->device("messram")) > 16*1024)
44   if (ram_get_size(machine->device(RAM_TAG)) > 16*1024)
4545   {
4646      memory_install_readwrite_bank(program, 0x4000, 0x7fff, 0, 0, "bank3");
4747   }
r9922r9923
5353   /* MC6847 video RAM */
5454   if (state->mc6847_bank)
5555   {
56      if (messram_get_size(machine->device("messram")) > 16*1024)
56      if (ram_get_size(machine->device(RAM_TAG)) > 16*1024)
5757      {
5858         memory_install_readwrite_bank(program, 0x8000, 0x97ff, 0, 0, "bank4");
5959      }
r9922r9923
7070   memory_set_bank(machine, "bank4", state->mc6847_bank);
7171
7272   /* extended RAM */
73   if (messram_get_size(machine->device("messram")) > 16*1024)
73   if (ram_get_size(machine->device(RAM_TAG)) > 16*1024)
7474   {
7575      memory_install_readwrite_bank(program, 0x9800, 0xbfff, 0, 0, "bank5");
7676   }
r9922r9923
532532   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
533533
534534   /* internal ram */
535   MCFG_RAM_ADD("messram")
535   MCFG_RAM_ADD(RAM_TAG)
536536   MCFG_RAM_DEFAULT_SIZE("16K")
537537   MCFG_RAM_EXTRA_OPTIONS("48K")
538538MACHINE_CONFIG_END
src/mess/drivers/unixpc.c
r9922r9923
1313
1414#include "emu.h"
1515#include "cpu/m68000/m68000.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717#include "machine/wd17xx.h"
1818#include "devices/flopdrv.h"
1919#include "unixpc.lh"
r9922r9923
2929   unixpc_state(running_machine &machine, const driver_device_config_base &config)
3030      : driver_device(machine, config),
3131        m_maincpu(*this, "maincpu"),
32        m_ram(*this, "messram"),
32        m_ram(*this, RAM_TAG),
3333        m_wd2797(*this, "wd2797"),
3434        m_floppy(*this, FLOPPY_0)
3535   { }
r9922r9923
6363WRITE16_MEMBER( unixpc_state::romlmap_w )
6464{
6565   if (BIT(data, 15))
66      memory_install_ram(&space, 0x000000, 0x3fffff, 0, 0, messram_get_ptr(m_ram));
66      memory_install_ram(&space, 0x000000, 0x3fffff, 0, 0, ram_get_ptr(m_ram));
6767   else
6868      memory_install_rom(&space, 0x000000, 0x3fffff, 0, 0, space.machine->region("bootrom")->base());
6969}
r9922r9923
215215   MCFG_PALETTE_INIT(black_and_white)
216216
217217   // internal ram
218   MCFG_RAM_ADD("messram")
218   MCFG_RAM_ADD(RAM_TAG)
219219   MCFG_RAM_DEFAULT_SIZE("1M")
220220   MCFG_RAM_EXTRA_OPTIONS("2M")
221221
src/mess/drivers/coco.c
r9922r9923
4545#include "devices/coco_vhd.h"
4646#include "sound/ay8910.h"
4747#include "sound/dac.h"
48#include "devices/messram.h"
48#include "machine/ram.h"
4949#include "coco3.lh"
5050
5151#define SHOW_FULL_AREA         0
r9922r9923
792792   MCFG_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
793793
794794   /* internal ram */
795   MCFG_RAM_ADD("messram")
795   MCFG_RAM_ADD(RAM_TAG)
796796   MCFG_RAM_DEFAULT_SIZE("32K")
797797   MCFG_RAM_EXTRA_OPTIONS("64K")
798798
r9922r9923
841841   MCFG_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
842842
843843   /* internal ram */
844   MCFG_RAM_ADD("messram")
844   MCFG_RAM_ADD(RAM_TAG)
845845   MCFG_RAM_DEFAULT_SIZE("64K")
846846
847847   MCFG_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
r9922r9923
890890   MCFG_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
891891
892892   /* internal ram */
893   MCFG_RAM_ADD("messram")
893   MCFG_RAM_ADD(RAM_TAG)
894894   MCFG_RAM_DEFAULT_SIZE("128K")
895895
896896   MCFG_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
r9922r9923
949949   MCFG_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
950950
951951   /* internal ram */
952   MCFG_RAM_ADD("messram")
952   MCFG_RAM_ADD(RAM_TAG)
953953   MCFG_RAM_DEFAULT_SIZE("64K")
954954MACHINE_CONFIG_END
955955
r9922r9923
996996   MCFG_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
997997
998998   /* internal ram */
999   MCFG_RAM_ADD("messram")
999   MCFG_RAM_ADD(RAM_TAG)
10001000   MCFG_RAM_DEFAULT_SIZE("64K")
10011001
10021002   MCFG_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
r9922r9923
10431043   MCFG_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
10441044
10451045   /* internal ram */
1046   MCFG_RAM_ADD("messram")
1046   MCFG_RAM_ADD(RAM_TAG)
10471047   MCFG_RAM_DEFAULT_SIZE("16K")
10481048   MCFG_RAM_EXTRA_OPTIONS("4K,32K,64K")
10491049
r9922r9923
10901090   MCFG_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
10911091
10921092   /* internal ram */
1093   MCFG_RAM_ADD("messram")
1093   MCFG_RAM_ADD(RAM_TAG)
10941094   MCFG_RAM_DEFAULT_SIZE("64K")
10951095   MCFG_RAM_EXTRA_OPTIONS("16K")
10961096
r9922r9923
11371137   MCFG_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
11381138
11391139   /* internal ram */
1140   MCFG_RAM_ADD("messram")
1140   MCFG_RAM_ADD(RAM_TAG)
11411141   MCFG_RAM_DEFAULT_SIZE("64K")
11421142   MCFG_RAM_EXTRA_OPTIONS("16K")
11431143
r9922r9923
11961196   MCFG_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
11971197
11981198   /* internal ram */
1199   MCFG_RAM_ADD("messram")
1199   MCFG_RAM_ADD(RAM_TAG)
12001200   MCFG_RAM_DEFAULT_SIZE("512K")
12011201   MCFG_RAM_EXTRA_OPTIONS("128K,2M,8M")
12021202
r9922r9923
12221222static MACHINE_CONFIG_DERIVED( cocoe, coco )
12231223
12241224   /* internal ram */
1225   MCFG_RAM_MODIFY("messram")
1225   MCFG_RAM_MODIFY(RAM_TAG)
12261226   MCFG_RAM_DEFAULT_SIZE("64K")
12271227   MCFG_RAM_EXTRA_OPTIONS("4K,16K,32K")
12281228MACHINE_CONFIG_END
src/mess/drivers/spc1000.c
r9922r9923
1313#include "sound/ay8910.h"
1414#include "sound/wave.h"
1515#include "devices/cassette.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717
1818
1919class spc1000_state : public driver_device
r9922r9923
4343      memory_set_bankptr(space->machine, "bank1", space->machine->region("maincpu")->base());
4444      memory_set_bankptr(space->machine, "bank3", space->machine->region("maincpu")->base());
4545   } else {
46      memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
47      memory_set_bankptr(space->machine, "bank3", messram_get_ptr(space->machine->device("messram")) + 0x8000);
46      memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
47      memory_set_bankptr(space->machine, "bank3", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x8000);
4848   }
4949}
5050
r9922r9923
5656      memory_set_bankptr(space->machine, "bank1", space->machine->region("maincpu")->base());
5757      memory_set_bankptr(space->machine, "bank3", space->machine->region("maincpu")->base());
5858   } else {
59      memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
60      memory_set_bankptr(space->machine, "bank3", messram_get_ptr(space->machine->device("messram")) + 0x8000);
59      memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
60      memory_set_bankptr(space->machine, "bank3", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x8000);
6161   }
6262   return 0;
6363}
r9922r9923
220220   memory_install_write_bank(space, 0x8000, 0xffff, 0, 0, "bank4");
221221
222222   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base());
223   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
223   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
224224   memory_set_bankptr(machine, "bank3", machine->region("maincpu")->base());
225   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x8000);
225   memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
226226
227227   state->IPLK = 1;
228228}
r9922r9923
327327   MCFG_CASSETTE_ADD( "cassette", spc1000_cassette_config )
328328
329329   /* internal ram */
330   MCFG_RAM_ADD("messram")
330   MCFG_RAM_ADD(RAM_TAG)
331331   MCFG_RAM_DEFAULT_SIZE("64K")
332332MACHINE_CONFIG_END
333333
src/mess/drivers/pocketc.c
r9922r9923
1212#include "includes/pc1251.h"
1313#include "includes/pc1350.h"
1414#include "includes/pc1403.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717/* pc1430 no peek poke operations! */
1818
r9922r9923
859859   MCFG_VIDEO_UPDATE( pc1350 )
860860
861861   /* internal ram */
862   MCFG_RAM_ADD("messram")
862   MCFG_RAM_ADD(RAM_TAG)
863863   MCFG_RAM_DEFAULT_SIZE("4K")
864864   MCFG_RAM_EXTRA_OPTIONS("12K,20K")
865865MACHINE_CONFIG_END
src/mess/drivers/gb.c
r9922r9923
436436***************************************************************************/
437437
438438#include "emu.h"
439#include "machine/ram.h"
439440#include "cpu/lr35902/lr35902.h"
440441#include "devices/cartslot.h"
441#include "devices/messram.h"
442442#include "rendlay.h"
443443#include "audio/gb.h"
444444#include "includes/gb.h"
r9922r9923
640640   MCFG_PALETTE_INIT(gbc)
641641
642642   /* internal ram */
643   MCFG_RAM_ADD("messram")
643   MCFG_RAM_ADD(RAM_TAG)
644644   MCFG_RAM_DEFAULT_SIZE("48K") /* 2 pages of 8KB VRAM, 8 pages of 4KB RAM */
645645
646646   MCFG_CARTSLOT_ADD("cart")
src/mess/drivers/xor100.c
r9922r9923
2222#include "cpu/z80/z80.h"
2323#include "formats/basicdsk.h"
2424#include "devices/flopdrv.h"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626#include "machine/com8116.h"
2727#include "machine/ctronics.h"
2828#include "machine/i8255a.h"
r9922r9923
4444void xor100_state::bankswitch()
4545{
4646   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
47   int banks = messram_get_size(m_ram) / 0x10000;
47   int banks = ram_get_size(m_ram) / 0x10000;
4848
4949   switch (m_mode)
5050   {
r9922r9923
518518
519519void xor100_state::machine_start()
520520{
521   int banks = messram_get_size(m_ram) / 0x10000;
522   UINT8 *ram = messram_get_ptr(m_ram);
521   int banks = ram_get_size(m_ram) / 0x10000;
522   UINT8 *ram = ram_get_ptr(m_ram);
523523   UINT8 *rom = machine->region(Z80_TAG)->base();
524524
525525   /* setup memory banking */
r9922r9923
579579   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, xor100_terminal_intf)
580580
581581   /* internal ram */
582   MCFG_RAM_ADD("messram")
582   MCFG_RAM_ADD(RAM_TAG)
583583   MCFG_RAM_DEFAULT_SIZE("64K")
584584   MCFG_RAM_EXTRA_OPTIONS("128K,192K,256K,320K,384K,448K,512K")
585585MACHINE_CONFIG_END
src/mess/drivers/palm.c
r9922r9923
1414#include "includes/mc68328.h"
1515#include "sound/dac.h"
1616#include "debugger.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818
1919
2020class palm_state : public driver_device
r9922r9923
107107{
108108   palm_state *state = machine->driver_data<palm_state>();
109109    address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
110    memory_install_read_bank (space, 0x000000, messram_get_size(machine->device("messram")) - 1, messram_get_size(machine->device("messram")) - 1, 0, "bank1");
111    memory_install_write_bank(space, 0x000000, messram_get_size(machine->device("messram")) - 1, messram_get_size(machine->device("messram")) - 1, 0, "bank1");
112    memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
110    memory_install_read_bank (space, 0x000000, ram_get_size(machine->device(RAM_TAG)) - 1, ram_get_size(machine->device(RAM_TAG)) - 1, 0, "bank1");
111    memory_install_write_bank(space, 0x000000, ram_get_size(machine->device(RAM_TAG)) - 1, ram_get_size(machine->device(RAM_TAG)) - 1, 0, "bank1");
112    memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
113113
114114    state_save_register_global(machine, state->port_f_latch);
115115    state_save_register_global(machine, state->spim_data);
r9922r9923
122122{
123123    // Copy boot ROM
124124    UINT8* bios = machine->region("bios")->base();
125    memset(messram_get_ptr(machine->device("messram")), 0, messram_get_size(machine->device("messram")));
126    memcpy(messram_get_ptr(machine->device("messram")), bios, 0x20000);
125    memset(ram_get_ptr(machine->device(RAM_TAG)), 0, ram_get_size(machine->device(RAM_TAG)));
126    memcpy(ram_get_ptr(machine->device(RAM_TAG)), bios, 0x20000);
127127
128128    machine->device("maincpu")->reset();
129129}
r9922r9923
435435static MACHINE_CONFIG_DERIVED( pilot1k, palm )
436436
437437   /* internal ram */
438   MCFG_RAM_ADD("messram")
438   MCFG_RAM_ADD(RAM_TAG)
439439   MCFG_RAM_DEFAULT_SIZE("128K")
440440   MCFG_RAM_EXTRA_OPTIONS("512K,1M,2M,4M,8M")
441441MACHINE_CONFIG_END
r9922r9923
443443static MACHINE_CONFIG_DERIVED( pilot5k, palm )
444444
445445   /* internal ram */
446   MCFG_RAM_ADD("messram")
446   MCFG_RAM_ADD(RAM_TAG)
447447   MCFG_RAM_DEFAULT_SIZE("512K")
448448   MCFG_RAM_EXTRA_OPTIONS("1M,2M,4M,8M")
449449MACHINE_CONFIG_END
r9922r9923
451451static MACHINE_CONFIG_DERIVED( palmpro, palm )
452452
453453   /* internal ram */
454   MCFG_RAM_ADD("messram")
454   MCFG_RAM_ADD(RAM_TAG)
455455   MCFG_RAM_DEFAULT_SIZE("1M")
456456   MCFG_RAM_EXTRA_OPTIONS("2M,4M,8M")
457457MACHINE_CONFIG_END
r9922r9923
459459static MACHINE_CONFIG_DERIVED( palmiii, palm )
460460
461461   /* internal ram */
462   MCFG_RAM_ADD("messram")
462   MCFG_RAM_ADD(RAM_TAG)
463463   MCFG_RAM_DEFAULT_SIZE("2M")
464464   MCFG_RAM_EXTRA_OPTIONS("4M,8M")
465465MACHINE_CONFIG_END
r9922r9923
467467static MACHINE_CONFIG_DERIVED( palmv, palm )
468468
469469   /* internal ram */
470   MCFG_RAM_ADD("messram")
470   MCFG_RAM_ADD(RAM_TAG)
471471   MCFG_RAM_DEFAULT_SIZE("2M")
472472   MCFG_RAM_EXTRA_OPTIONS("4M,8M")
473473MACHINE_CONFIG_END
r9922r9923
475475static MACHINE_CONFIG_DERIVED( palmvx, palm )
476476
477477   /* internal ram */
478   MCFG_RAM_ADD("messram")
478   MCFG_RAM_ADD(RAM_TAG)
479479   MCFG_RAM_DEFAULT_SIZE("8M")
480480MACHINE_CONFIG_END
481481
src/mess/drivers/tmc600.c
r9922r9923
9090#include "cpu/cosmac/cosmac.h"
9191#include "sound/cdp1869.h"
9292#include "includes/tmc600.h"
93#include "devices/messram.h"
93#include "machine/ram.h"
9494
9595/* Read/Write Handlers */
9696
r9922r9923
252252   address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
253253
254254   /* configure RAM */
255   switch (messram_get_size(m_ram))
255   switch (ram_get_size(m_ram))
256256   {
257257   case 8*1024:
258258      memory_unmap_readwrite(program, 0x8000, 0xbfff, 0, 0);
r9922r9923
305305   MCFG_FLOPPY_2_DRIVES_ADD(tmc600_floppy_config)
306306
307307   /* internal ram */
308   MCFG_RAM_ADD("messram")
308   MCFG_RAM_ADD(RAM_TAG)
309309   MCFG_RAM_DEFAULT_SIZE("8K")
310310   MCFG_RAM_EXTRA_OPTIONS("16K,24K")
311311MACHINE_CONFIG_END
src/mess/drivers/b2m.c
r9922r9923
1717#include "machine/wd17xx.h"
1818#include "devices/flopdrv.h"
1919#include "formats/basicdsk.h"
20#include "devices/messram.h"
20#include "machine/ram.h"
2121#include "includes/b2m.h"
2222
2323
r9922r9923
244244   MCFG_FLOPPY_2_DRIVES_ADD(b2m_floppy_config)
245245
246246   /* internal ram */
247   MCFG_RAM_ADD("messram")
247   MCFG_RAM_ADD(RAM_TAG)
248248   MCFG_RAM_DEFAULT_SIZE("128K")
249249   MCFG_RAM_DEFAULT_VALUE(0x00)
250250MACHINE_CONFIG_END
src/mess/drivers/aim65.c
r9922r9923
2020#include "machine/6532riot.h"
2121#include "machine/6821pia.h"
2222#include "devices/cartslot.h"
23#include "devices/messram.h"
23#include "machine/ram.h"
2424#include "aim65.lh"
2525
2626
r9922r9923
222222   MCFG_CARTSLOT_NOT_MANDATORY
223223
224224   /* internal ram */
225   MCFG_RAM_ADD("messram")
225   MCFG_RAM_ADD(RAM_TAG)
226226   MCFG_RAM_DEFAULT_SIZE("4K")
227227   MCFG_RAM_EXTRA_OPTIONS("1K,2K,3K")
228228MACHINE_CONFIG_END
src/mess/drivers/vic20.c
r9922r9923
7777#include "formats/cbm_snqk.h"
7878#include "cpu/m6502/m6502.h"
7979#include "devices/cartslot.h"
80#include "devices/messram.h"
80#include "machine/ram.h"
8181#include "machine/6522via.h"
8282#include "machine/c1541.h"
8383#include "machine/cbmiec.h"
r9922r9923
532532   state->via1->set_unscaled_clock(cputag_get_clock(machine, M6502_TAG));
533533
534534   /* memory expansions */
535   switch (messram_get_size(machine->device("messram")))
535   switch (ram_get_size(machine->device(RAM_TAG)))
536536   {
537537   case 32*1024:
538538      memory_install_ram(program, 0x6000, 0x7fff, 0, 0, NULL);
r9922r9923
707707   MCFG_SOFTWARE_LIST_ADD("cart_list","vic1001_cart")
708708
709709   /* internal ram */
710   MCFG_RAM_ADD("messram")
710   MCFG_RAM_ADD(RAM_TAG)
711711   MCFG_RAM_DEFAULT_SIZE("5K")
712712   MCFG_RAM_EXTRA_OPTIONS("8K,16K,24K,32K")
713713MACHINE_CONFIG_END
src/mess/drivers/thomson.c
r9922r9923
7474#include "machine/ctronics.h"
7575#include "devices/flopdrv.h"
7676#include "formats/basicdsk.h"
77#include "devices/messram.h"
77#include "machine/ram.h"
7878#include "machine/serial.h"
7979
8080
r9922r9923
339339/* 0x10000 - 0x1ffff: 64 KB external ROM cartridge */
340340/* 0x20000 - 0x247ff: 18 KB floppy / network ROM controllers */
341341
342/* messram_get_ptr(machine->device("messram")) mapping:
342/* ram_get_ptr(machine->device(RAM_TAG)) mapping:
343343   0x0000 - 0x3fff: 16 KB video RAM (actually 8 K x 8 bits + 8 K x 6 bits)
344344   0x4000 - 0x5fff:  8 KB base RAM
345345   0x6000 - 0x9fff: 16 KB extended RAM
r9922r9923
670670     MCFG_CARTSLOT_LOAD(to7_cartridge)
671671
672672/* internal ram */
673   MCFG_RAM_ADD("messram")
673   MCFG_RAM_ADD(RAM_TAG)
674674   MCFG_RAM_DEFAULT_SIZE("40K")
675675   MCFG_RAM_EXTRA_OPTIONS("24K,48K")
676676
r9922r9923
761761/* 0x10000 - 0x1ffff: 64 KB external ROM cartridge */
762762/* 0x20000 - 0x247ff: 18 KB floppy / network ROM controllers */
763763
764/* messram_get_ptr(machine->device("messram")) mapping:
764/* ram_get_ptr(machine->device(RAM_TAG)) mapping:
765765   0x00000 - 0x03fff: 16 KB video RAM
766766   0x04000 - 0x07fff: 16 KB unbanked base RAM
767767   0x08000 - 0x1ffff: 6 * 16 KB banked extended RAM
r9922r9923
855855    MCFG_MC6846_MODIFY( "mc6846", to770_timer )
856856
857857   /* internal ram */
858   MCFG_RAM_MODIFY("messram")
858   MCFG_RAM_MODIFY(RAM_TAG)
859859   MCFG_RAM_DEFAULT_SIZE("128K")
860860   MCFG_RAM_EXTRA_OPTIONS("64K")
861861MACHINE_CONFIG_END
r9922r9923
948948/* 0x10000 - 0x1ffff: 16 KB integrated BASIC / 64 KB external cartridge */
949949/* 0x20000 - 0x247ff: 18 KB floppy / network ROM controllers */
950950
951/* messram_get_ptr(machine->device("messram")) mapping:
951/* ram_get_ptr(machine->device(RAM_TAG)) mapping:
952952   0x00000 - 0x03fff: 16 KB video RAM
953953   0x04000 - 0x0bfff: 32 KB unbanked base RAM
954954   0x0c000 - 0x1bfff: 4 * 16 KB bank extended RAM
r9922r9923
10411041   MCFG_CARTSLOT_LOAD(mo5_cartridge)
10421042
10431043   /* internal ram */
1044   MCFG_RAM_MODIFY("messram")
1044   MCFG_RAM_MODIFY(RAM_TAG)
10451045   MCFG_RAM_DEFAULT_SIZE("112K")
10461046MACHINE_CONFIG_END
10471047
r9922r9923
11531153/* 0x20000 - 0x3ffff: 128 KB internal software ROM */
11541154/* 0x40000 - 0x447ff: 18  KB external floppy / network ROM controllers */
11551155
1156/* messram_get_ptr(machine->device("messram")) mapping:
1156/* ram_get_ptr(machine->device(RAM_TAG)) mapping:
11571157   0x00000 - 0x03fff: 16 KB video RAM
11581158   0x04000 - 0x07fff: 16 KB unbanked base RAM
11591159   0x08000 - 0x2ffff: 10 * 16 KB banked extended RAM
r9922r9923
13781378     MCFG_MC6846_MODIFY( "mc6846", to9_timer )
13791379
13801380    /* internal ram */
1381   MCFG_RAM_MODIFY("messram")
1381   MCFG_RAM_MODIFY(RAM_TAG)
13821382   MCFG_RAM_DEFAULT_SIZE("192K")
13831383   MCFG_RAM_EXTRA_OPTIONS("128K")
13841384MACHINE_CONFIG_END
r9922r9923
14791479/* 0x30000 - 0x33fff: 16 KB BIOS ROM */
14801480/* 0x34000 - 0x387ff: 18 KB external floppy / network ROM controllers */
14811481
1482/* messram_get_ptr(machine->device("messram")) mapping: 512 KB flat (including video) */
1482/* ram_get_ptr(machine->device(RAM_TAG)) mapping: 512 KB flat (including video) */
14831483
14841484ADDRESS_MAP_END
14851485
r9922r9923
15961596     MCFG_MC6846_MODIFY( "mc6846", to8_timer )
15971597
15981598    /* internal ram */
1599   MCFG_RAM_MODIFY("messram")
1599   MCFG_RAM_MODIFY(RAM_TAG)
16001600   MCFG_RAM_DEFAULT_SIZE("512K")
16011601   MCFG_RAM_EXTRA_OPTIONS("256K")
16021602MACHINE_CONFIG_END
r9922r9923
16771677/* 0x30000 - 0x33fff: 16 KB BIOS ROM */
16781678/* 0x34000 - 0x387ff: 18 KB external floppy / network ROM controllers */
16791679
1680/* messram_get_ptr(machine->device("messram")) mapping: 512 KB flat (including video) */
1680/* ram_get_ptr(machine->device(RAM_TAG)) mapping: 512 KB flat (including video) */
16811681
16821682ADDRESS_MAP_END
16831683
r9922r9923
17451745     MCFG_MC6846_MODIFY( "mc6846", to9p_timer )
17461746
17471747   /* internal ram */
1748   MCFG_RAM_MODIFY("messram")
1748   MCFG_RAM_MODIFY(RAM_TAG)
17491749   MCFG_RAM_DEFAULT_SIZE("512K")
17501750MACHINE_CONFIG_END
17511751
r9922r9923
18381838/* 0x20000 - 0x2ffff: 64 KB BIOS ROM */
18391839/* 0x30000 - 0x347ff: 16 KB floppy / network ROM controllers */
18401840
1841/* messram_get_ptr(machine->device("messram")) mapping: 128 KB flat (including video) */
1841/* ram_get_ptr(machine->device(RAM_TAG)) mapping: 128 KB flat (including video) */
18421842
18431843ADDRESS_MAP_END
18441844
r9922r9923
20812081   MCFG_CARTSLOT_LOAD(mo5_cartridge)
20822082
20832083   /* internal ram */
2084   MCFG_RAM_MODIFY("messram")
2084   MCFG_RAM_MODIFY(RAM_TAG)
20852085   MCFG_RAM_DEFAULT_SIZE("128K")
20862086MACHINE_CONFIG_END
20872087
r9922r9923
21522152/* 0x20000 - 0x2ffff: 64 KB BIOS ROM */
21532153/* 0x30000 - 0x347ff: 16 KB floppy / network ROM controllers */
21542154
2155/* messram_get_ptr(machine->device("messram")) mapping: 128 KB flat (including video) */
2155/* ram_get_ptr(machine->device(RAM_TAG)) mapping: 128 KB flat (including video) */
21562156
21572157ADDRESS_MAP_END
21582158
r9922r9923
23072307   MCFG_CARTSLOT_LOAD(mo5_cartridge)
23082308
23092309   /* internal ram */
2310   MCFG_RAM_MODIFY("messram")
2310   MCFG_RAM_MODIFY(RAM_TAG)
23112311   MCFG_RAM_DEFAULT_SIZE("128K")
23122312MACHINE_CONFIG_END
23132313
src/mess/drivers/scorpion.c
r9922r9923
153153#include "sound/speaker.h"
154154#include "formats/tzx_cas.h"
155155#include "machine/beta.h"
156#include "devices/messram.h"
156#include "machine/ram.h"
157157
158158/****************************************************************************************************/
159159/* Zs Scorpion 256 */
r9922r9923
186186static void scorpion_update_memory(running_machine *machine)
187187{
188188   spectrum_state *state = machine->driver_data<spectrum_state>();
189   UINT8 *messram = messram_get_ptr(machine->device("messram"));
189   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
190190   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
191191
192192   state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14));
r9922r9923
305305static MACHINE_RESET( scorpion )
306306{
307307   spectrum_state *state = machine->driver_data<spectrum_state>();
308   UINT8 *messram = messram_get_ptr(machine->device("messram"));
308   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
309309   device_t *beta = machine->device(BETA_DISK_TAG);
310310   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
311311
r9922r9923
399399   MCFG_BETA_DISK_ADD(BETA_DISK_TAG)
400400
401401   /* internal ram */
402   MCFG_RAM_MODIFY("messram")
402   MCFG_RAM_MODIFY(RAM_TAG)
403403   MCFG_RAM_DEFAULT_SIZE("256K")
404404MACHINE_CONFIG_END
405405
src/mess/drivers/abc80.c
r9922r9923
183183#include "cpu/z80/z80daisy.h"
184184#include "devices/cassette.h"
185185#include "devices/flopdrv.h"
186#include "devices/messram.h"
186#include "machine/ram.h"
187187#include "devices/printer.h"
188188#include "machine/abcbus.h"
189189#include "machine/abc830.h"
r9922r9923
676676void abc80_state::machine_start()
677677{
678678   /* configure RAM expansion */
679   if (messram_get_size(m_ram) == 16 * 1024)
679   if (ram_get_size(m_ram) == 16 * 1024)
680680   {
681681      memory_unmap_readwrite(cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0);
682682   }
r9922r9923
728728   MCFG_CASSETTE_ADD(CASSETTE_TAG, abc80_cassette_config)
729729
730730   /* internal ram */
731   MCFG_RAM_ADD("messram")
731   MCFG_RAM_ADD(RAM_TAG)
732732   MCFG_RAM_DEFAULT_SIZE("16K")
733733   MCFG_RAM_EXTRA_OPTIONS("32K")
734734MACHINE_CONFIG_END
src/mess/drivers/pmd85.c
r9922r9923
178178#include "machine/pit8253.h"
179179#include "machine/msm8251.h"
180180#include "formats/pmd_pmd.h"
181#include "devices/messram.h"
181#include "machine/ram.h"
182182
183183/* I/O ports */
184184
r9922r9923
579579   MCFG_MSM8251_ADD("uart", default_msm8251_interface)
580580
581581   /* internal ram */
582   MCFG_RAM_ADD("messram")
582   MCFG_RAM_ADD(RAM_TAG)
583583   MCFG_RAM_DEFAULT_SIZE("64K")
584584MACHINE_CONFIG_END
585585
src/mess/drivers/spectrum.c
r9922r9923
277277#include "devices/snapquik.h"
278278#include "devices/cartslot.h"
279279#include "devices/cassette.h"
280#include "devices/messram.h"
280#include "machine/ram.h"
281281#include "formats/tzx_cas.h"
282282#include "formats/spec_snqk.h"
283283
r9922r9923
624624{
625625   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
626626
627   switch (messram_get_size(machine->device("messram")))
627   switch (ram_get_size(machine->device(RAM_TAG)))
628628   {
629629       case 48*1024:
630630      memory_install_ram(space, 0x8000, 0xffff, 0, 0, NULL); // Fall through
r9922r9923
753753MACHINE_CONFIG_DERIVED( spectrum, spectrum_common )
754754
755755   /* internal ram */
756   MCFG_RAM_ADD("messram")            // This configuration is verified only for the original ZX Spectrum.
756   MCFG_RAM_ADD(RAM_TAG)            // This configuration is verified only for the original ZX Spectrum.
757757   MCFG_RAM_DEFAULT_SIZE("48K")      // It's likely, but still to be checked, that many clones were produced only
758758   MCFG_RAM_EXTRA_OPTIONS("16K")      // in the 48k configuration, while others have extra memory (80k, 128K, 1024K)
759759   MCFG_RAM_DEFAULT_VALUE(0xff)      // available via bankswitching.
src/mess/drivers/atarist.c
r9922r9923
66#include "formats/atarist_dsk.h"
77#include "devices/cartslot.h"
88#include "devices/flopdrv.h"
9#include "devices/messram.h"
9#include "machine/ram.h"
1010#include "machine/6850acia.h"
1111#include "machine/68901mfp.h"
1212#include "machine/8530scc.h"
r9922r9923
483483   if (state->dmasnd_samples == 0)
484484   {
485485      int i;
486      UINT8 *RAM = messram_get_ptr(machine->device("messram"));
486      UINT8 *RAM = ram_get_ptr(machine->device(RAM_TAG));
487487
488488      for (i = 0; i < 8; i++)
489489      {
r9922r9923
14671467static void atarist_configure_memory(running_machine *machine)
14681468{
14691469   address_space *program = cputag_get_address_space(machine, M68000_TAG, ADDRESS_SPACE_PROGRAM);
1470   UINT8 *RAM = messram_get_ptr(machine->device("messram"));
1470   UINT8 *RAM = ram_get_ptr(machine->device(RAM_TAG));
14711471
1472   switch (messram_get_size(machine->device("messram")))
1472   switch (ram_get_size(machine->device(RAM_TAG)))
14731473   {
14741474   case 256 * 1024:
14751475      memory_install_ram(program, 0x000008, 0x03ffff, 0, 0, RAM + 8);
r9922r9923
16541654static void stbook_configure_memory(running_machine *machine)
16551655{
16561656   address_space *program = cputag_get_address_space(machine, M68000_TAG, ADDRESS_SPACE_PROGRAM);
1657   UINT8 *RAM = messram_get_ptr(machine->device("messram"));
1657   UINT8 *RAM = ram_get_ptr(machine->device(RAM_TAG));
16581658
1659   switch (messram_get_size(machine->device("messram")))
1659   switch (ram_get_size(machine->device(RAM_TAG)))
16601660   {
16611661   case 1024 * 1024:
16621662      memory_install_ram(program, 0x000008, 0x07ffff, 0, 0x080000, RAM + 8);
r9922r9923
18701870   MCFG_FRAGMENT_ADD(atarist_cartslot)
18711871
18721872   /* internal ram */
1873   MCFG_RAM_ADD("messram")
1873   MCFG_RAM_ADD(RAM_TAG)
18741874   MCFG_RAM_DEFAULT_SIZE("1024K")  // 1040ST
18751875   MCFG_RAM_EXTRA_OPTIONS("512K,256K") // 520ST, 260ST
18761876MACHINE_CONFIG_END
r9922r9923
18831883   MCFG_MACHINE_START(megast)
18841884
18851885   /* internal ram */
1886   MCFG_RAM_MODIFY("messram")
1886   MCFG_RAM_MODIFY(RAM_TAG)
18871887   MCFG_RAM_DEFAULT_SIZE("4M")  //  Mega ST 4
18881888   MCFG_RAM_EXTRA_OPTIONS("2M,1M") //  Mega ST 2 ,Mega ST 1
18891889MACHINE_CONFIG_END
r9922r9923
19411941   MCFG_FRAGMENT_ADD(atarist_cartslot)
19421942
19431943   /* internal ram */
1944   MCFG_RAM_ADD("messram")
1944   MCFG_RAM_ADD(RAM_TAG)
19451945   MCFG_RAM_DEFAULT_SIZE("1024K")  // 1040STe
19461946   MCFG_RAM_EXTRA_OPTIONS("512K") //  520STe
19471947MACHINE_CONFIG_END
r9922r9923
19561956   MCFG_FLOPPY_2_DRIVES_MODIFY(megaste_floppy_config)
19571957
19581958   /* internal ram */
1959   MCFG_RAM_MODIFY("messram")
1959   MCFG_RAM_MODIFY(RAM_TAG)
19601960   MCFG_RAM_DEFAULT_SIZE("4M")  //  Mega STe 4
19611961   MCFG_RAM_EXTRA_OPTIONS("2M,1M") //  Mega STe 2 ,Mega STe 1
19621962MACHINE_CONFIG_END
r9922r9923
20082008   MCFG_FRAGMENT_ADD(atarist_cartslot)
20092009
20102010   /* internal ram */
2011   MCFG_RAM_ADD("messram")
2011   MCFG_RAM_ADD(RAM_TAG)
20122012   MCFG_RAM_DEFAULT_SIZE("4M")
20132013   MCFG_RAM_EXTRA_OPTIONS("1M")
20142014MACHINE_CONFIG_END
src/mess/drivers/sg1000.c
r9922r9923
6969#include "devices/flopdrv.h"
7070#include "devices/cartslot.h"
7171#include "devices/cassette.h"
72#include "devices/messram.h"
72#include "machine/ram.h"
7373#include "devices/printer.h"
7474#include "formats/basicdsk.h"
7575#include "machine/ctronics.h"
r9922r9923
10191019
10201020   /* configure memory banking */
10211021   memory_configure_bank(machine, "bank1", 0, 1, machine->region(Z80_TAG)->base(), 0);
1022   memory_configure_bank(machine, "bank1", 1, 1, messram_get_ptr(m_ram), 0);
1023   memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(m_ram), 0);
1022   memory_configure_bank(machine, "bank1", 1, 1, ram_get_ptr(m_ram), 0);
1023   memory_configure_bank(machine, "bank2", 0, 1, ram_get_ptr(m_ram), 0);
10241024
10251025   /* register for state saving */
10261026   state_save_register_global(machine, m_keylatch);
r9922r9923
10751075   MCFG_SOFTWARE_LIST_ADD("cart_list","sg1000")
10761076
10771077   /* internal ram */
1078   MCFG_RAM_ADD("messram")
1078   MCFG_RAM_ADD(RAM_TAG)
10791079   MCFG_RAM_DEFAULT_SIZE("1K")
10801080MACHINE_CONFIG_END
10811081
r9922r9923
10931093   MCFG_CARTSLOT_NOT_MANDATORY
10941094   MCFG_CARTSLOT_LOAD(omv_cart)
10951095
1096   MCFG_RAM_MODIFY("messram")
1096   MCFG_RAM_MODIFY(RAM_TAG)
10971097   MCFG_RAM_DEFAULT_SIZE("2K")
10981098MACHINE_CONFIG_END
10991099
r9922r9923
11341134   MCFG_SOFTWARE_LIST_ADD("cart_list","sg1000")
11351135
11361136   /* internal ram */
1137   MCFG_RAM_ADD("messram")
1137   MCFG_RAM_ADD(RAM_TAG)
11381138   MCFG_RAM_DEFAULT_SIZE("2K")
11391139MACHINE_CONFIG_END
11401140
r9922r9923
11711171   MCFG_CASSETTE_ADD(CASSETTE_TAG, sc3000_cassette_config)
11721172
11731173   /* internal ram */
1174   MCFG_RAM_ADD("messram")
1174   MCFG_RAM_ADD(RAM_TAG)
11751175   MCFG_RAM_DEFAULT_SIZE("64K")
11761176MACHINE_CONFIG_END
11771177
src/mess/drivers/eti660.c
r9922r9923
1313#include "includes/eti660.h"
1414#include "cpu/cosmac/cosmac.h"
1515#include "devices/cassette.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717#include "machine/6821pia.h"
1818#include "machine/rescap.h"
1919#include "sound/cdp1864.h"
r9922r9923
334334   MCFG_CASSETTE_ADD(CASSETTE_TAG, eti660_cassette_config)
335335
336336   /* internal ram */
337   MCFG_RAM_ADD("messram")
337   MCFG_RAM_ADD(RAM_TAG)
338338   MCFG_RAM_DEFAULT_SIZE("3K")
339339MACHINE_CONFIG_END
340340
src/mess/drivers/px8.c
r9922r9923
3333#include "cpu/m6800/m6800.h"
3434#include "devices/cartslot.h"
3535#include "devices/cassette.h"
36#include "devices/messram.h"
36#include "machine/ram.h"
3737#include "machine/msm8251.h"
3838#include "machine/pf10.h"
3939#include "sound/wave.h"
r9922r9923
8787{
8888   px8_state *state = machine->driver_data<px8_state>();
8989   address_space *program = cputag_get_address_space(machine, UPD70008_TAG, ADDRESS_SPACE_PROGRAM);
90   UINT8 *ram = messram_get_ptr(machine->device("messram"));
90   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
9191   UINT8 *ipl_rom = machine->region(UPD70008_TAG)->base();
9292
9393   if (!state->bank0)
r9922r9923
909909   MCFG_CASSETTE_ADD(CASSETTE_TAG, px8_cassette_config)
910910
911911   /* internal ram */
912   MCFG_RAM_ADD("messram")
912   MCFG_RAM_ADD(RAM_TAG)
913913   MCFG_RAM_DEFAULT_SIZE("64K")
914914MACHINE_CONFIG_END
915915
src/mess/drivers/phc25.c
r9922r9923
4545#include "includes/phc25.h"
4646#include "cpu/z80/z80.h"
4747#include "devices/cassette.h"
48#include "devices/messram.h"
48#include "machine/ram.h"
4949#include "machine/ctronics.h"
5050#include "video/m6847.h"
5151#include "sound/ay8910.h"
r9922r9923
391391   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
392392
393393   /* internal ram */
394   MCFG_RAM_ADD("messram")
394   MCFG_RAM_ADD(RAM_TAG)
395395   MCFG_RAM_DEFAULT_SIZE("16K")
396396MACHINE_CONFIG_END
397397
src/mess/drivers/mikromik.c
r9922r9923
1212#include "video/i8275.h"
1313#include "video/upd7220.h"
1414#include "sound/speaker.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616#include "includes/mikromik.h"
1717
1818/*
r9922r9923
679679   memory_install_read_bank(program, 0x0000, 0x0fff, 0, 0, "bank1");
680680   memory_unmap_write(program, 0x0000, 0x0fff, 0, 0);
681681   memory_configure_bank(machine, "bank1", 0, 1, machine->region("bios")->base(), 0);
682   memory_configure_bank(machine, "bank1", 1, 1, messram_get_ptr(machine->device("messram")), 0);
682   memory_configure_bank(machine, "bank1", 1, 1, ram_get_ptr(machine->device(RAM_TAG)), 0);
683683   memory_set_bank(machine, "bank1", 0);
684684
685685   /* register for state saving */
r9922r9923
749749   MCFG_FLOPPY_2_DRIVES_ADD(mm1_floppy_config)
750750
751751   /* internal ram */
752   MCFG_RAM_ADD("messram")
752   MCFG_RAM_ADD(RAM_TAG)
753753   MCFG_RAM_DEFAULT_SIZE("64K")
754754MACHINE_CONFIG_END
755755
src/mess/drivers/spec128.c
r9922r9923
157157#include "sound/ay8910.h"
158158#include "sound/speaker.h"
159159#include "formats/tzx_cas.h"
160#include "devices/messram.h"
160#include "machine/ram.h"
161161
162162static const ay8910_interface spectrum_ay_interface =
163163{
r9922r9923
192192void spectrum_128_update_memory(running_machine *machine)
193193{
194194   spectrum_state *state = machine->driver_data<spectrum_state>();
195   UINT8 *messram = messram_get_ptr(machine->device("messram"));
195   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
196196   unsigned char *ChosenROM;
197197   int ROMSelection;
198198
r9922r9923
255255static MACHINE_RESET( spectrum_128 )
256256{
257257   spectrum_state *state = machine->driver_data<spectrum_state>();
258   UINT8 *messram = messram_get_ptr(machine->device("messram"));
258   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
259259
260260   memset(messram,0,128*1024);
261261   /* 0x0000-0x3fff always holds ROM */
r9922r9923
315315   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
316316
317317   /* internal ram */
318   MCFG_RAM_MODIFY("messram")
318   MCFG_RAM_MODIFY(RAM_TAG)
319319   MCFG_RAM_DEFAULT_SIZE("128K")
320320MACHINE_CONFIG_END
321321
src/mess/drivers/pet.c
r9922r9923
387387#include "includes/pet.h"
388388#include "machine/cbmipt.h"
389389#include "video/mc6845.h"
390#include "devices/messram.h"
390#include "machine/ram.h"
391391#include "machine/c2040.h"
392392
393393/* devices config */
r9922r9923
698698   MCFG_FRAGMENT_ADD(pet_cartslot)
699699
700700   /* internal ram */
701   MCFG_RAM_ADD("messram")
701   MCFG_RAM_ADD(RAM_TAG)
702702   MCFG_RAM_DEFAULT_SIZE("32K")
703703   MCFG_RAM_EXTRA_OPTIONS("8K,16K")
704704
r9922r9923
717717   MCFG_FRAGMENT_ADD(pet_cartslot)
718718
719719   /* internal ram */
720   MCFG_RAM_ADD("messram")
720   MCFG_RAM_ADD(RAM_TAG)
721721   MCFG_RAM_DEFAULT_SIZE("8K")
722722   MCFG_RAM_EXTRA_OPTIONS("4K")
723723
r9922r9923
771771   MCFG_FRAGMENT_ADD(pet4_cartslot)
772772
773773   /* internal ram */
774   MCFG_RAM_ADD("messram")
774   MCFG_RAM_ADD(RAM_TAG)
775775   MCFG_RAM_DEFAULT_SIZE("32K")
776776
777777   /* IEEE bus */
src/mess/drivers/c16.c
r9922r9923
116116#include "audio/ted7360.h"
117117#include "audio/t6721.h"
118118#include "cpu/m6502/m6502.h"
119#include "devices/messram.h"
119#include "machine/ram.h"
120120#include "formats/cbm_snqk.h"
121121#include "includes/cbm.h"
122122#include "includes/c16.h"
r9922r9923
452452   state->ted7360 = machine->device("ted7360");
453453   state->serbus = machine->device("iec");
454454   state->cassette = machine->device("cassette");
455   state->messram = machine->device("messram");
455   state->messram = machine->device(RAM_TAG);
456456   state->sid = machine->device("sid");
457457
458458   state_save_register_global(machine, state->old_level);
r9922r9923
504504   MCFG_CBM_IEC_ADD("iec", c16_iec_no_drives)
505505
506506   /* internal ram */
507   MCFG_RAM_ADD("messram")
507   MCFG_RAM_ADD(RAM_TAG)
508508   MCFG_RAM_DEFAULT_SIZE("64K")
509509   MCFG_RAM_EXTRA_OPTIONS("16K,32K")
510510MACHINE_CONFIG_END
r9922r9923
551551   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
552552
553553   /* internal ram */
554   MCFG_RAM_MODIFY("messram")
554   MCFG_RAM_MODIFY(RAM_TAG)
555555   MCFG_RAM_DEFAULT_SIZE("64K")
556556MACHINE_CONFIG_END
557557
r9922r9923
598598
599599static MACHINE_CONFIG_DERIVED( c264, c16 )
600600   /* internal ram */
601   MCFG_RAM_MODIFY("messram")
601   MCFG_RAM_MODIFY(RAM_TAG)
602602   MCFG_RAM_DEFAULT_SIZE("64K")
603603MACHINE_CONFIG_END
604604
src/mess/drivers/pcw.c
r9922r9923
103103#include "includes/pcw.h"
104104// pcw/pcw16 beeper
105105#include "sound/beep.h"
106#include "devices/messram.h"
106#include "machine/ram.h"
107107
108108#include "pcw.lh"
109109
r9922r9923
254254      memory_install_read_bank(space,block * 0x04000 + 0x0000, block * 0x04000 + 0x3fff, 0, 0,block_name);
255255//      LOG(("MEM: read block %i -> bank %i\n",block,bank));
256256   }
257   memory_set_bankptr(machine, block_name, messram_get_ptr(machine->device("messram")) + ((bank * 0x4000) % messram_get_size(machine->device("messram"))));
257   memory_set_bankptr(machine, block_name, ram_get_ptr(machine->device(RAM_TAG)) + ((bank * 0x4000) % ram_get_size(machine->device(RAM_TAG))));
258258}
259259
260260
r9922r9923
264264   char block_name[10];
265265
266266   sprintf(block_name,"bank%d",block+5);
267   memory_set_bankptr(machine, block_name, messram_get_ptr(machine->device("messram")) + ((bank * 0x4000) % messram_get_size(machine->device("messram"))));
267   memory_set_bankptr(machine, block_name, ram_get_ptr(machine->device(RAM_TAG)) + ((bank * 0x4000) % ram_get_size(machine->device(RAM_TAG))));
268268//  LOG(("MEM: write block %i -> bank %i\n",block,bank));
269269}
270270
r9922r9923
10891089   state->boot = 0;   // System starts up in bootstrap mode, disabled until it's possible to emulate it.
10901090
10911091   /* copy boot code into RAM - yes, it's skipping a step */
1092   memset(messram_get_ptr(machine->device("messram")),0x00,messram_get_size(machine->device("messram")));
1092   memset(ram_get_ptr(machine->device(RAM_TAG)),0x00,ram_get_size(machine->device(RAM_TAG)));
10931093   for(x=0;x<256;x++)
1094      messram_get_ptr(machine->device("messram"))[x+2] = code[x+0x300];
1094      ram_get_ptr(machine->device(RAM_TAG))[x+2] = code[x+0x300];
10951095
10961096   /* and hack our way past the MCU side of the boot process */
10971097   code[0x01] = 0x40;
r9922r9923
13731373   MCFG_FLOPPY_2_DRIVES_ADD(pcw_floppy_config)
13741374
13751375   /* internal ram */
1376   MCFG_RAM_ADD("messram")
1376   MCFG_RAM_ADD(RAM_TAG)
13771377   MCFG_RAM_DEFAULT_SIZE("256K")
13781378MACHINE_CONFIG_END
13791379
r9922r9923
13981398   MCFG_DEFAULT_LAYOUT( layout_pcw )
13991399
14001400   /* internal ram */
1401   MCFG_RAM_MODIFY("messram")
1401   MCFG_RAM_MODIFY(RAM_TAG)
14021402   MCFG_RAM_DEFAULT_SIZE("512K")
14031403MACHINE_CONFIG_END
14041404
r9922r9923
14081408   MCFG_CPU_IO_MAP(pcw9512_io)
14091409
14101410   /* internal ram */
1411   MCFG_RAM_MODIFY("messram")
1411   MCFG_RAM_MODIFY(RAM_TAG)
14121412   MCFG_RAM_DEFAULT_SIZE("512K")
14131413MACHINE_CONFIG_END
14141414
src/mess/drivers/osi.c
r9922r9923
186186#include "devices/flopdrv.h"
187187#include "formats/basicdsk.h"
188188#include "devices/cassette.h"
189#include "devices/messram.h"
189#include "machine/ram.h"
190190
191191/* Sound */
192192
r9922r9923
676676   memory_configure_bank(machine, "bank1", 0, 1, machine->region(M6502_TAG)->base(), 0);
677677   memory_set_bank(machine, "bank1", 0);
678678
679   switch (messram_get_size(machine->device("messram")))
679   switch (ram_get_size(machine->device(RAM_TAG)))
680680   {
681681   case 4*1024:
682682      memory_install_readwrite_bank(program, 0x0000, 0x0fff, 0, 0, "bank1");
r9922r9923
706706   memory_configure_bank(machine, "bank1", 0, 1, machine->region(M6502_TAG)->base(), 0);
707707   memory_set_bank(machine, "bank1", 0);
708708
709   switch (messram_get_size(machine->device("messram")))
709   switch (ram_get_size(machine->device(RAM_TAG)))
710710   {
711711   case 8*1024:
712712      memory_install_readwrite_bank(program, 0x0000, 0x1fff, 0, 0, "bank1");
r9922r9923
801801   MCFG_CASSETTE_ADD("cassette", default_cassette_config)
802802
803803   /* internal ram */
804   MCFG_RAM_ADD("messram")
804   MCFG_RAM_ADD(RAM_TAG)
805805   MCFG_RAM_DEFAULT_SIZE("4K")
806806   MCFG_RAM_EXTRA_OPTIONS("8K")
807807MACHINE_CONFIG_END
r9922r9923
825825   MCFG_CASSETTE_ADD("cassette", default_cassette_config)
826826
827827   /* internal ram */
828   MCFG_RAM_ADD("messram")
828   MCFG_RAM_ADD(RAM_TAG)
829829   MCFG_RAM_DEFAULT_SIZE("4K")
830830   MCFG_RAM_EXTRA_OPTIONS("8K")
831831MACHINE_CONFIG_END
r9922r9923
861861   MCFG_CASSETTE_ADD("cassette", default_cassette_config)
862862
863863   /* internal ram */
864   MCFG_RAM_ADD("messram")
864   MCFG_RAM_ADD(RAM_TAG)
865865   MCFG_RAM_DEFAULT_SIZE("8K")
866866   MCFG_RAM_EXTRA_OPTIONS("20K")
867867MACHINE_CONFIG_END
r9922r9923
881881   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, osi_floppy_config)
882882
883883   /* internal ram */
884   MCFG_RAM_MODIFY("messram")
884   MCFG_RAM_MODIFY(RAM_TAG)
885885   MCFG_RAM_DEFAULT_SIZE("20K")
886886MACHINE_CONFIG_END
887887
src/mess/drivers/rt1715.c
r9922r9923
1818#include "machine/z80sio.h"
1919#include "machine/z80pio.h"
2020#include "machine/z80dma.h"
21#include "devices/messram.h"
21#include "machine/ram.h"
2222#include "video/i8275.h"
2323
2424
r9922r9923
100100
101101static MACHINE_START( rt1715 )
102102{
103   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x0800);
104   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")));
103   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x0800);
104   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)));
105105}
106106
107107static MACHINE_RESET( rt1715 )
r9922r9923
115115   logerror("%s: rt1715_set_bank %02x\n", cpuexec_describe_context(space->machine), data);
116116
117117   /* disable ROM, enable RAM */
118   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
118   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
119119}
120120
121121
r9922r9923
348348   MCFG_Z80PIO_ADD("a72", XTAL_10MHz/4 /* ? */, rt1715_pio_control_intf)
349349
350350   /* internal ram */
351   MCFG_RAM_ADD("messram")
351   MCFG_RAM_ADD(RAM_TAG)
352352   MCFG_RAM_DEFAULT_SIZE("64K")
353353   MCFG_RAM_DEFAULT_VALUE(0x00)
354354MACHINE_CONFIG_END
src/mess/drivers/at.c
r9922r9923
5555#include "sound/dac.h"
5656#include "sound/speaker.h"
5757#include "sound/saa1099.h"
58#include "devices/messram.h"
58#include "machine/ram.h"
5959
6060#include "memconv.h"
6161
r9922r9923
549549   MCFG_FLOPPY_2_DRIVES_ADD(ibmat_floppy_config)
550550
551551   /* internal ram */
552   MCFG_RAM_ADD("messram")
552   MCFG_RAM_ADD(RAM_TAG)
553553   MCFG_RAM_DEFAULT_SIZE("1664K")
554554MACHINE_CONFIG_END
555555
r9922r9923
622622   MCFG_FLOPPY_2_DRIVES_ADD(ibmat_floppy_config)
623623
624624   /* internal ram */
625   MCFG_RAM_ADD("messram")
625   MCFG_RAM_ADD(RAM_TAG)
626626   MCFG_RAM_DEFAULT_SIZE("1664K")
627627MACHINE_CONFIG_END
628628
r9922r9923
693693   MCFG_FLOPPY_2_DRIVES_ADD(ibmat_floppy_config)
694694
695695   /* internal ram */
696   MCFG_RAM_ADD("messram")
696   MCFG_RAM_ADD(RAM_TAG)
697697   MCFG_RAM_DEFAULT_SIZE("1664K")
698698MACHINE_CONFIG_END
699699
r9922r9923
766766   MCFG_FLOPPY_2_DRIVES_ADD(ibmat_floppy_config)
767767
768768   /* internal ram */
769   MCFG_RAM_ADD("messram")
769   MCFG_RAM_ADD(RAM_TAG)
770770   MCFG_RAM_DEFAULT_SIZE("1664K")
771771MACHINE_CONFIG_END
772772
r9922r9923
841841   MCFG_FLOPPY_2_DRIVES_ADD(ibmat_floppy_config)
842842
843843   /* internal ram */
844   MCFG_RAM_ADD("messram")
844   MCFG_RAM_ADD(RAM_TAG)
845845   MCFG_RAM_DEFAULT_SIZE("1664K")
846846MACHINE_CONFIG_END
847847
src/mess/drivers/vector06.c
r9922r9923
1818#include "devices/flopdrv.h"
1919#include "formats/basicdsk.h"
2020#include "includes/vector06.h"
21#include "devices/messram.h"
21#include "machine/ram.h"
2222
2323/* Address maps */
2424static ADDRESS_MAP_START(vector06_mem, ADDRESS_SPACE_PROGRAM, 8)
r9922r9923
210210   MCFG_CARTSLOT_NOT_MANDATORY
211211
212212   /* internal ram */
213   MCFG_RAM_ADD("messram")
213   MCFG_RAM_ADD(RAM_TAG)
214214   MCFG_RAM_DEFAULT_SIZE("64K")
215215   MCFG_RAM_DEFAULT_VALUE(0x00)
216216MACHINE_CONFIG_END
src/mess/drivers/v1050.c
r9922r9923
110110#include "cpu/m6502/m6502.h"
111111#include "cpu/mcs48/mcs48.h"
112112#include "devices/flopdrv.h"
113#include "devices/messram.h"
113#include "machine/ram.h"
114114#include "formats/basicdsk.h"
115115#include "machine/ctronics.h"
116116#include "machine/i8214.h"
r9922r9923
11241124   cpu_set_irq_callback(m_maincpu, v1050_int_ack);
11251125
11261126   /* setup memory banking */
1127   UINT8 *ram = messram_get_ptr(machine->device("messram"));
1127   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
11281128
11291129   memory_configure_bank(machine, "bank1", 0, 2, ram, 0x10000);
11301130   memory_configure_bank(machine, "bank1", 2, 1, ram + 0x1c000, 0);
r9922r9923
12151215   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
12161216
12171217   /* internal ram */
1218   MCFG_RAM_ADD("messram")
1218   MCFG_RAM_ADD(RAM_TAG)
12191219   MCFG_RAM_DEFAULT_SIZE("128K")
12201220MACHINE_CONFIG_END
12211221
src/mess/drivers/cgc7900.c
r9922r9923
3838#include "cpu/m68000/m68000.h"
3939#include "cpu/mcs48/mcs48.h"
4040#include "formats/basicdsk.h"
41#include "devices/messram.h"
41#include "machine/ram.h"
4242#include "machine/msm8251.h"
4343#include "sound/ay8910.h"
4444
src/mess/drivers/ql.c
r9922r9923
4747#include "cpu/mcs51/mcs51.h"
4848#include "devices/cartslot.h"
4949#include "devices/flopdrv.h"
50#include "devices/messram.h"
50#include "machine/ram.h"
5151#include "devices/microdrv.h"
5252#include "formats/basicdsk.h"
5353#include "machine/zx8302.h"
r9922r9923
746746   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
747747
748748   // configure RAM
749   switch (messram_get_size(m_ram))
749   switch (ram_get_size(m_ram))
750750   {
751751   case 128*1024:
752752      memory_unmap_readwrite(program, 0x040000, 0x0fffff, 0, 0);
r9922r9923
829829   MCFG_SOFTWARE_LIST_ADD("cart_list", "ql")
830830
831831   // internal ram
832   MCFG_RAM_ADD("messram")
832   MCFG_RAM_ADD(RAM_TAG)
833833   MCFG_RAM_DEFAULT_SIZE("128K")
834834   MCFG_RAM_EXTRA_OPTIONS("192K,256K,384K,640K,896K")
835835MACHINE_CONFIG_END
r9922r9923
854854
855855static MACHINE_CONFIG_DERIVED( opd, ql )
856856   // internal ram
857   MCFG_RAM_MODIFY("messram")
857   MCFG_RAM_MODIFY(RAM_TAG)
858858   MCFG_RAM_DEFAULT_SIZE("128K")
859859   MCFG_RAM_EXTRA_OPTIONS("256K")
860860MACHINE_CONFIG_END
r9922r9923
867867
868868static MACHINE_CONFIG_DERIVED( megaopd, ql )
869869   // internal ram
870   MCFG_RAM_MODIFY("messram")
870   MCFG_RAM_MODIFY(RAM_TAG)
871871   MCFG_RAM_DEFAULT_SIZE("256K")
872872MACHINE_CONFIG_END
873873*/
src/mess/drivers/vt220.c
r9922r9923
88
99#include "emu.h"
1010#include "cpu/mcs51/mcs51.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313
1414class vt220_state : public driver_device
r9922r9923
3333
3434static MACHINE_RESET(vt220)
3535{
36   memset(messram_get_ptr(machine->device("messram")),0,16*1024);
36   memset(ram_get_ptr(machine->device(RAM_TAG)),0,16*1024);
3737}
3838
3939static VIDEO_START( vt220 )
r9922r9923
6868    MCFG_VIDEO_UPDATE(vt220)
6969
7070   /* internal ram */
71   MCFG_RAM_ADD("messram")
71   MCFG_RAM_ADD(RAM_TAG)
7272   MCFG_RAM_DEFAULT_SIZE("16K")
7373MACHINE_CONFIG_END
7474
src/mess/drivers/abc80x.c
r9922r9923
242242#include "cpu/mcs48/mcs48.h"
243243#include "devices/cassette.h"
244244#include "devices/printer.h"
245#include "devices/messram.h"
245#include "machine/ram.h"
246246#include "machine/z80ctc.h"
247247#include "machine/z80dart.h"
248248#include "machine/abcbus.h"
r9922r9923
535535   else
536536   {
537537      // low RAM selected
538      memory_install_ram(program, 0x0000, 0x7fff, 0, 0, messram_get_ptr(m_ram));
538      memory_install_ram(program, 0x0000, 0x7fff, 0, 0, ram_get_ptr(m_ram));
539539   }
540540}
541541
r9922r9923
547547void abc806_state::bankswitch()
548548{
549549   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
550   UINT32 videoram_mask = messram_get_size(m_ram) - (32 * 1024) - 1;
550   UINT32 videoram_mask = ram_get_size(m_ram) - (32 * 1024) - 1;
551551   int bank;
552552   char bank_name[10];
553553
r9922r9923
15601560void abc806_state::machine_start()
15611561{
15621562   UINT8 *mem = machine->region(Z80_TAG)->base();
1563   UINT32 videoram_size = messram_get_size(m_ram) - (32 * 1024);
1563   UINT32 videoram_size = ram_get_size(m_ram) - (32 * 1024);
15641564   int bank;
15651565   char bank_name[10];
15661566
r9922r9923
16591659   MCFG_ABC830_ADD("luxor_55_21046", ABCBUS_TAG, DRIVE_BASF_6106_08)
16601660
16611661   // internal ram
1662   MCFG_RAM_ADD("messram")
1662   MCFG_RAM_ADD(RAM_TAG)
16631663   MCFG_RAM_DEFAULT_SIZE("16K")
16641664   MCFG_RAM_EXTRA_OPTIONS("32K")
16651665MACHINE_CONFIG_END
r9922r9923
17021702   MCFG_ABC830_ADD("luxor_55_21046", ABCBUS_TAG, DRIVE_BASF_6106_08)
17031703
17041704   // internal ram
1705   MCFG_RAM_ADD("messram")
1705   MCFG_RAM_ADD(RAM_TAG)
17061706   MCFG_RAM_DEFAULT_SIZE("16K")
17071707   MCFG_RAM_EXTRA_OPTIONS("32K")
17081708MACHINE_CONFIG_END
r9922r9923
17451745   MCFG_TIMER_ADD_PERIODIC("keyboard", keyboard_tick, USEC(2500))
17461746
17471747   // internal ram
1748   MCFG_RAM_ADD("messram")
1748   MCFG_RAM_ADD(RAM_TAG)
17491749   MCFG_RAM_DEFAULT_SIZE("64K")
17501750MACHINE_CONFIG_END
17511751
r9922r9923
17851785   MCFG_TIMER_ADD_PERIODIC("keyboard", keyboard_tick, USEC(2500))
17861786
17871787   // internal ram
1788   MCFG_RAM_ADD("messram")
1788   MCFG_RAM_ADD(RAM_TAG)
17891789   MCFG_RAM_DEFAULT_SIZE("160K") // 32KB + 128KB
17901790   MCFG_RAM_EXTRA_OPTIONS("544K") // 32KB + 512KB
17911791MACHINE_CONFIG_END
src/mess/drivers/orion.c
r9922r9923
2222#include "devices/cartslot.h"
2323#include "formats/rk_cas.h"
2424#include "includes/orion.h"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626
2727/* Address maps */
2828
r9922r9923
162162   MCFG_CARTSLOT_ADD("cart")
163163
164164   /* internal ram */
165   MCFG_RAM_ADD("messram")
165   MCFG_RAM_ADD(RAM_TAG)
166166   MCFG_RAM_DEFAULT_SIZE("256K")
167167   MCFG_RAM_DEFAULT_VALUE(0x00)
168168MACHINE_CONFIG_END
r9922r9923
226226   MCFG_CARTSLOT_ADD("cart")
227227
228228   /* internal ram */
229   MCFG_RAM_ADD("messram")
229   MCFG_RAM_ADD(RAM_TAG)
230230   MCFG_RAM_DEFAULT_SIZE("512K")
231231   MCFG_RAM_DEFAULT_VALUE(0x00)
232232MACHINE_CONFIG_END
r9922r9923
280280   MCFG_CARTSLOT_ADD("cart")
281281
282282   /* internal ram */
283   MCFG_RAM_ADD("messram")
283   MCFG_RAM_ADD(RAM_TAG)
284284   MCFG_RAM_DEFAULT_SIZE("512K")
285285   MCFG_RAM_DEFAULT_VALUE(0x00)
286286MACHINE_CONFIG_END
src/mess/drivers/qx10.c
r9922r9923
2525#include "machine/8237dma.h"
2626#include "video/i82720.h"
2727#include "machine/upd765.h"
28#include "devices/messram.h"
28#include "machine/ram.h"
2929
3030#define MAIN_CLK   15974400
3131
r9922r9923
9090   }
9191   else
9292   {
93      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + drambank*64*1024);
93      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + drambank*64*1024);
9494   }
9595   if (state->memcmos)
9696   {
r9922r9923
9898   }
9999   else
100100   {
101      memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + drambank*64*1024 + 32*1024);
101      memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + drambank*64*1024 + 32*1024);
102102   }
103103}
104104
r9922r9923
535535   MCFG_MC146818_ADD( "rtc", MC146818_STANDARD )
536536   
537537   /* internal ram */
538   MCFG_RAM_ADD("messram")
538   MCFG_RAM_ADD(RAM_TAG)
539539   MCFG_RAM_DEFAULT_SIZE("256K")
540540MACHINE_CONFIG_END
541541
src/mess/drivers/tvc.c
r9922r9923
99#include "emu.h"
1010#include "cpu/z80/z80.h"
1111#include "video/mc6845.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313
1414
1515class tvc_state : public driver_device
r9922r9923
4242            break;
4343      case 0x10 : // RAM selected
4444            memory_install_readwrite_bank(space, 0x0000, 0x3fff, 0, 0, "bank1");
45            memory_set_bankptr(space->machine, "bank1", messram_get_ptr(machine->device("messram")));
45            memory_set_bankptr(space->machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
4646            break;
4747   }
4848   // Bank 2 is always RAM
49   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
49   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
5050   if ((data & 0x20)==0) {
5151      // Video RAM
52      memory_set_bankptr(space->machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x10000);
52      memory_set_bankptr(space->machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000);
5353   } else {
5454      // System RAM page 3
55      memory_set_bankptr(space->machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x8000);
55      memory_set_bankptr(space->machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
5656   }
5757   switch(data & 0xc0) {
5858      case 0x00 : // Cart ROM selected
r9922r9923
6767            break;
6868      case 0x80 : // RAM selected
6969            memory_install_readwrite_bank(space, 0xc000, 0xffff, 0, 0, "bank4");
70            memory_set_bankptr(space->machine, "bank4", messram_get_ptr(machine->device("messram"))+0xc000);
70            memory_set_bankptr(space->machine, "bank4", ram_get_ptr(machine->device(RAM_TAG))+0xc000);
7171            break;
7272      case 0xc0 : // External ROM selected
7373            memory_install_read_bank(space, 0xc000, 0xffff, 0, 0, "bank4");
r9922r9923
265265static MACHINE_RESET(tvc)
266266{
267267   tvc_state *state = machine->driver_data<tvc_state>();
268   memset(messram_get_ptr(machine->device("messram")),0,(64+14)*1024);
268   memset(ram_get_ptr(machine->device(RAM_TAG)),0,(64+14)*1024);
269269   tvc_set_mem_page(machine, 0);
270270   state->video_mode = 0;
271271}
r9922r9923
292292            for ( i = 0; i < x_count; i++ )
293293            {
294294               UINT16 offset = i  + (y * 64);
295               UINT8 data = messram_get_ptr(device->machine->device("messram"))[ offset + 0x10000];
295               UINT8 data = ram_get_ptr(device->machine->device(RAM_TAG))[ offset + 0x10000];
296296               *p++ = state->col[(data >> 7)];
297297               *p++ = state->col[(data >> 6)];
298298               *p++ = state->col[(data >> 5)];
r9922r9923
307307            for ( i = 0; i < x_count; i++ )
308308            {
309309               UINT16 offset = i  + (y * 64);
310               UINT8 data = messram_get_ptr(device->machine->device("messram"))[ offset + 0x10000];
310               UINT8 data = ram_get_ptr(device->machine->device(RAM_TAG))[ offset + 0x10000];
311311               *p++ = state->col[BIT(data,7)*2 + BIT(data,3)];
312312               *p++ = state->col[BIT(data,7)*2 + BIT(data,3)];
313313               *p++ = state->col[BIT(data,6)*2 + BIT(data,2)];
r9922r9923
322322            for ( i = 0; i < x_count; i++ )
323323            {
324324               UINT16 offset = i  + (y * 64);
325               UINT8 data = messram_get_ptr(device->machine->device("messram"))[ offset + 0x10000];
325               UINT8 data = ram_get_ptr(device->machine->device(RAM_TAG))[ offset + 0x10000];
326326               *p++ = state->col[(data >> 4) & 0xf];
327327               *p++ = state->col[(data >> 4) & 0xf];
328328               *p++ = state->col[(data >> 4) & 0xf];
r9922r9923
412412    MCFG_VIDEO_UPDATE(tvc)
413413
414414   /* internal ram */
415   MCFG_RAM_ADD("messram")
415   MCFG_RAM_ADD(RAM_TAG)
416416   MCFG_RAM_DEFAULT_SIZE("80K")
417417MACHINE_CONFIG_END
418418
src/mess/drivers/tmc1800.c
r9922r9923
120120#include "devices/snapquik.h"
121121#include "machine/rescap.h"
122122#include "sound/beep.h"
123#include "devices/messram.h"
123#include "machine/ram.h"
124124
125125#define TMC2000_BANK_RAM      0
126126#define TMC2000_BANK_ROM      1
r9922r9923
198198
199199   memory_set_bank(device->machine, "bank1", TMC2000_BANK_RAM);
200200
201   switch (messram_get_size(device->machine->device("messram")))
201   switch (ram_get_size(device->machine->device(RAM_TAG)))
202202   {
203203   case 4 * 1024:
204204      memory_install_readwrite_bank(cputag_get_address_space(device->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x0fff, 0, 0x7000, "bank1");
r9922r9923
787787   MCFG_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
788788
789789   // internal ram
790   MCFG_RAM_ADD("messram")
790   MCFG_RAM_ADD(RAM_TAG)
791791   MCFG_RAM_DEFAULT_SIZE("2K")
792792   MCFG_RAM_EXTRA_OPTIONS("4K")
793793MACHINE_CONFIG_END
r9922r9923
816816   MCFG_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
817817
818818   /* internal ram */
819   MCFG_RAM_ADD("messram")
819   MCFG_RAM_ADD(RAM_TAG)
820820   MCFG_RAM_DEFAULT_SIZE("2K")
821821   MCFG_RAM_EXTRA_OPTIONS("4K")
822822MACHINE_CONFIG_END
r9922r9923
839839   MCFG_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
840840
841841   /* internal ram */
842   MCFG_RAM_ADD("messram")
842   MCFG_RAM_ADD(RAM_TAG)
843843   MCFG_RAM_DEFAULT_SIZE("4K")
844844   MCFG_RAM_EXTRA_OPTIONS("16K,32K")
845845MACHINE_CONFIG_END
r9922r9923
862862   MCFG_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
863863
864864   /* internal ram */
865   MCFG_RAM_ADD("messram")
865   MCFG_RAM_ADD(RAM_TAG)
866866   MCFG_RAM_DEFAULT_SIZE("4K")
867867MACHINE_CONFIG_END
868868
r9922r9923
904904   UINT8 *ptr = image.device().machine->region(CDP1802_TAG)->base();
905905   int size = image.length();
906906
907   if (size > messram_get_size(image.device().machine->device("messram")))
907   if (size > ram_get_size(image.device().machine->device(RAM_TAG)))
908908   {
909909      return IMAGE_INIT_FAIL;
910910   }
src/mess/drivers/crvision.c
r9922r9923
137137#include "sound/sn76496.h"
138138#include "sound/wave.h"
139139#include "video/tms9928a.h"
140#include "devices/messram.h"
140#include "machine/ram.h"
141141
142142/***************************************************************************
143143    READ/WRITE HANDLERS
r9922r9923
10761076   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
10771077
10781078   /* internal ram */
1079   MCFG_RAM_ADD("messram")
1079   MCFG_RAM_ADD(RAM_TAG)
10801080   MCFG_RAM_DEFAULT_SIZE("1K")   // MAIN RAM
10811081   MCFG_RAM_EXTRA_OPTIONS("15K") // 16K expansion (lower 14K available only, upper 2K shared with BIOS ROM)
10821082MACHINE_CONFIG_END
r9922r9923
11541154   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, lasr2001_centronics_intf)
11551155
11561156   /* internal ram */
1157   MCFG_RAM_ADD("messram")
1157   MCFG_RAM_ADD(RAM_TAG)
11581158   MCFG_RAM_DEFAULT_SIZE("16K")
11591159   MCFG_RAM_EXTRA_OPTIONS("32K")
11601160
src/mess/drivers/fmtowns.c
r9922r9923
123123#include "machine/wd17xx.h"
124124#include "devices/flopdrv.h"
125125#include "machine/upd71071.h"
126#include "devices/messram.h"
126#include "machine/ram.h"
127127#include "includes/fmtowns.h"
128128#include "machine/nvram.h"
129129#include "devices/harddriv.h"
r9922r9923
993993{
994994   towns_state* state = space->machine->driver_data<towns_state>();
995995   if(state->towns_mainmem_enable != 0)
996      return messram_get_ptr(state->messram)[offset + 0xd8000];
996      return ram_get_ptr(state->messram)[offset + 0xd8000];
997997
998998   return state->m_nvram[offset];
999999}
r9922r9923
10021002{
10031003   towns_state* state = space->machine->driver_data<towns_state>();
10041004   if(state->towns_mainmem_enable != 0)
1005      messram_get_ptr(state->messram)[offset+0xd8000] = data;
1005      ram_get_ptr(state->messram)[offset+0xd8000] = data;
10061006   else
10071007      state->m_nvram[offset] = data;
10081008}
r9922r9923
10281028   {
10291029      ROM = space->machine->region("user")->base();
10301030
1031//      memory_set_bankptr(space->machine,1,messram_get_ptr(state->messram)+0xc0000);
1032//      memory_set_bankptr(space->machine,2,messram_get_ptr(state->messram)+0xc8000);
1033//      memory_set_bankptr(space->machine,3,messram_get_ptr(state->messram)+0xc9000);
1034//      memory_set_bankptr(space->machine,4,messram_get_ptr(state->messram)+0xca000);
1035//      memory_set_bankptr(space->machine,5,messram_get_ptr(state->messram)+0xca000);
1036//      memory_set_bankptr(space->machine,10,messram_get_ptr(state->messram)+0xca800);
1037      memory_set_bankptr(space->machine,"bank6",messram_get_ptr(state->messram)+0xcb000);
1038      memory_set_bankptr(space->machine,"bank7",messram_get_ptr(state->messram)+0xcb000);
1031//      memory_set_bankptr(space->machine,1,ram_get_ptr(state->messram)+0xc0000);
1032//      memory_set_bankptr(space->machine,2,ram_get_ptr(state->messram)+0xc8000);
1033//      memory_set_bankptr(space->machine,3,ram_get_ptr(state->messram)+0xc9000);
1034//      memory_set_bankptr(space->machine,4,ram_get_ptr(state->messram)+0xca000);
1035//      memory_set_bankptr(space->machine,5,ram_get_ptr(state->messram)+0xca000);
1036//      memory_set_bankptr(space->machine,10,ram_get_ptr(state->messram)+0xca800);
1037      memory_set_bankptr(space->machine,"bank6",ram_get_ptr(state->messram)+0xcb000);
1038      memory_set_bankptr(space->machine,"bank7",ram_get_ptr(state->messram)+0xcb000);
10391039      if(state->towns_system_port & 0x02)
1040         memory_set_bankptr(space->machine,"bank11",messram_get_ptr(state->messram)+0xf8000);
1040         memory_set_bankptr(space->machine,"bank11",ram_get_ptr(state->messram)+0xf8000);
10411041      else
10421042         memory_set_bankptr(space->machine,"bank11",ROM+0x238000);
1043      memory_set_bankptr(space->machine,"bank12",messram_get_ptr(state->messram)+0xf8000);
1043      memory_set_bankptr(space->machine,"bank12",ram_get_ptr(state->messram)+0xf8000);
10441044      return;
10451045   }
10461046   else  // enable I/O ports and VRAM
r9922r9923
10491049
10501050//      memory_set_bankptr(space->machine,1,towns_gfxvram+(towns_vram_rplane*0x8000));
10511051//      memory_set_bankptr(space->machine,2,towns_txtvram);
1052//      memory_set_bankptr(space->machine,3,messram_get_ptr(state->messram)+0xc9000);
1052//      memory_set_bankptr(space->machine,3,ram_get_ptr(state->messram)+0xc9000);
10531053//      if(towns_ankcg_enable != 0)
10541054//          memory_set_bankptr(space->machine,4,ROM+0x180000+0x3d000);  // ANK CG 8x8
10551055//      else
10561056//          memory_set_bankptr(space->machine,4,towns_txtvram+0x2000);
10571057//      memory_set_bankptr(space->machine,5,towns_txtvram+0x2000);
1058//      memory_set_bankptr(space->machine,10,messram_get_ptr(state->messram)+0xca800);
1058//      memory_set_bankptr(space->machine,10,ram_get_ptr(state->messram)+0xca800);
10591059      if(state->towns_ankcg_enable != 0)
10601060         memory_set_bankptr(space->machine,"bank6",ROM+0x180000+0x3d800);  // ANK CG 8x16
10611061      else
1062         memory_set_bankptr(space->machine,"bank6",messram_get_ptr(state->messram)+0xcb000);
1063      memory_set_bankptr(space->machine,"bank7",messram_get_ptr(state->messram)+0xcb000);
1062         memory_set_bankptr(space->machine,"bank6",ram_get_ptr(state->messram)+0xcb000);
1063      memory_set_bankptr(space->machine,"bank7",ram_get_ptr(state->messram)+0xcb000);
10641064      if(state->towns_system_port & 0x02)
1065         memory_set_bankptr(space->machine,"bank11",messram_get_ptr(state->messram)+0xf8000);
1065         memory_set_bankptr(space->machine,"bank11",ram_get_ptr(state->messram)+0xf8000);
10661066      else
10671067         memory_set_bankptr(space->machine,"bank11",ROM+0x238000);
1068      memory_set_bankptr(space->machine,"bank12",messram_get_ptr(state->messram)+0xf8000);
1068      memory_set_bankptr(space->machine,"bank12",ram_get_ptr(state->messram)+0xf8000);
10691069      return;
10701070   }
10711071}
r9922r9923
22982298   state->pic_master = machine->device("pic8259_master");
22992299   state->pic_slave = machine->device("pic8259_slave");
23002300   state->pit = machine->device("pit");
2301   state->messram = machine->device("messram");
2301   state->messram = machine->device(RAM_TAG);
23022302   state->cdrom = machine->device("cdrom");
23032303   state->cdda = machine->device("cdda");
23042304   state->scsi = machine->device<fmscsi_device>("scsi");
r9922r9923
25092509    MCFG_VIDEO_UPDATE(towns)
25102510
25112511   /* internal ram */
2512   MCFG_RAM_ADD("messram")
2512   MCFG_RAM_ADD(RAM_TAG)
25132513   MCFG_RAM_DEFAULT_SIZE("6M")
25142514MACHINE_CONFIG_END
25152515
src/mess/drivers/nascom1.c
r9922r9923
6363#include "formats/basicdsk.h"
6464#include "devices/cartslot.h"
6565#include "devices/cassette.h"
66#include "devices/messram.h"
66#include "machine/ram.h"
6767
6868
6969/*************************************
r9922r9923
306306   MCFG_CASSETTE_ADD( "cassette", default_cassette_config )
307307
308308   /* internal ram */
309   MCFG_RAM_ADD("messram")
309   MCFG_RAM_ADD(RAM_TAG)
310310   MCFG_RAM_DEFAULT_SIZE("40K")
311311   MCFG_RAM_EXTRA_OPTIONS("1K,16K,32K")
312312MACHINE_CONFIG_END
src/mess/drivers/newbrain.c
r9922r9923
1313#include "formats/basicdsk.h"
1414#include "devices/cassette.h"
1515#include "machine/rescap.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717#include "newbrain.lh"
1818
1919/*
r9922r9923
15751575   MCFG_CASSETTE_ADD("cassette2", newbrain_cassette_config)
15761576
15771577   /* internal ram */
1578   MCFG_RAM_ADD("messram")
1578   MCFG_RAM_ADD(RAM_TAG)
15791579   MCFG_RAM_DEFAULT_SIZE("32K")
15801580
15811581   MCFG_NEWBRAIN_SERIAL_ADD("serial")
r9922r9923
16251625   MCFG_FLOPPY_2_DRIVES_ADD(newbrain_floppy_config)
16261626
16271627   /* internal ram */
1628   MCFG_RAM_MODIFY("messram")
1628   MCFG_RAM_MODIFY(RAM_TAG)
16291629   MCFG_RAM_DEFAULT_SIZE("96K")
16301630MACHINE_CONFIG_END
16311631
src/mess/drivers/sapi1.c
r9922r9923
1818#include "cpu/i8085/i8085.h"
1919#include "cpu/z80/z80.h"
2020#include "includes/sapi1.h"
21#include "devices/messram.h"
21#include "machine/ram.h"
2222
2323
2424/* switch out the rom shadow */
r9922r9923
155155   MCFG_VIDEO_UPDATE(sapi1)
156156
157157   /* internal ram */
158   MCFG_RAM_ADD("messram")
158   MCFG_RAM_ADD(RAM_TAG)
159159   MCFG_RAM_DEFAULT_SIZE("64K")
160160MACHINE_CONFIG_END
161161
r9922r9923
183183   MCFG_VIDEO_UPDATE(sapizps3)
184184
185185   /* internal ram */
186   MCFG_RAM_ADD("messram")
186   MCFG_RAM_ADD(RAM_TAG)
187187   MCFG_RAM_DEFAULT_SIZE("64K")
188188MACHINE_CONFIG_END
189189
src/mess/drivers/einstein.c
r9922r9923
6161#include "sound/ay8910.h"
6262#include "video/mc6845.h"
6363#include "rendlay.h"
64#include "devices/messram.h"
64#include "machine/ram.h"
6565#include "includes/einstein.h"
6666
6767/***************************************************************************
r9922r9923
270270static void einstein_page_rom(running_machine *machine)
271271{
272272   einstein_state *einstein = machine->driver_data<einstein_state>();
273   memory_set_bankptr(machine, "bank1", einstein->rom_enabled ? machine->region("bios")->base() : messram_get_ptr(machine->device("messram")));
273   memory_set_bankptr(machine, "bank1", einstein->rom_enabled ? machine->region("bios")->base() : ram_get_ptr(machine->device(RAM_TAG)));
274274}
275275
276276/* writing to this port is a simple trigger, and switches between RAM and ROM */
r9922r9923
399399   einstein->ctc = machine->device(IC_I058);
400400
401401   /* initialize memory mapping */
402   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")));
403   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x8000);
402   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)));
403   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
404404   einstein->rom_enabled = 1;
405405   einstein_page_rom(machine);
406406
r9922r9923
775775
776776   /* RAM is provided by 8k DRAM ICs i009, i010, i011, i012, i013, i014, i015 and i016 */
777777   /* internal ram */
778   MCFG_RAM_ADD("messram")
778   MCFG_RAM_ADD(RAM_TAG)
779779   MCFG_RAM_DEFAULT_SIZE("64K")
780780MACHINE_CONFIG_END
781781
src/mess/drivers/fk1.c
r9922r9923
1111#include "machine/i8255a.h"
1212#include "machine/pit8253.h"
1313#include "machine/msm8251.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515
1616class fk1_state : public driver_device
1717{
r9922r9923
255255{
256256   address_space *space_mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
257257   memory_install_write_bank(space_mem, 0x0000, 0x3fff, 0, 0, "bank1");
258   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")));
259   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0x4000);
258   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG)));
259   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x4000);
260260   return 0;
261261}
262262
r9922r9923
265265   address_space *space_mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
266266   memory_unmap_write(space_mem, 0x0000, 0x3fff, 0, 0);
267267   memory_set_bankptr(space->machine, "bank1", space->machine->region("maincpu")->base());
268   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0x10000);
268   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0x10000);
269269   return 0;
270270}
271271
r9922r9923
381381   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
382382   memory_unmap_write(space, 0x0000, 0x3fff, 0, 0);
383383   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base()); // ROM
384   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x10000); // VRAM
385   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x8000);
386   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xc000);
384   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x10000); // VRAM
385   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
386   memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
387387
388388   cpu_set_irq_callback(machine->device("maincpu"), fk1_irq_callback);
389389}
r9922r9923
399399   fk1_state *state = screen->machine->driver_data<fk1_state>();
400400   UINT8 code;
401401   int y, x, b;
402   UINT8 *ram = messram_get_ptr(screen->machine->device("messram"));
402   UINT8 *ram = ram_get_ptr(screen->machine->device(RAM_TAG));
403403
404404   for (x = 0; x < 64; x++)
405405   {
r9922r9923
445445   MCFG_MSM8251_ADD("uart", default_msm8251_interface)
446446
447447   /* internal ram */
448   MCFG_RAM_ADD("messram")
448   MCFG_RAM_ADD(RAM_TAG)
449449   MCFG_RAM_DEFAULT_SIZE("80K") // 64 + 16
450450MACHINE_CONFIG_END
451451
src/mess/drivers/bullet.c
r9922r9923
6161#include "emu.h"
6262#include "cpu/z80/z80.h"
6363#include "devices/flopdrv.h"
64#include "devices/messram.h"
64#include "machine/ram.h"
6565#include "machine/ctronics.h"
6666#include "machine/terminal.h"
6767#include "machine/wd17xx.h"
r9922r9923
513513      offset |= 0x10000;
514514   }
515515
516   UINT8 *ram = messram_get_ptr(m_ram);
516   UINT8 *ram = ram_get_ptr(m_ram);
517517   UINT8 data = ram[offset];
518518
519519   switch (m_exdma >> 3)
r9922r9923
534534      offset |= 0x10000;
535535   }
536536
537   UINT8 *ram = messram_get_ptr(m_ram);
537   UINT8 *ram = ram_get_ptr(m_ram);
538538   ram[offset] = data;
539539
540540   switch (m_exdma >> 3)
r9922r9923
678678void bullet_state::machine_start()
679679{
680680   // setup memory banking
681   UINT8 *ram = messram_get_ptr(m_ram);
681   UINT8 *ram = ram_get_ptr(m_ram);
682682
683683   memory_configure_bank(machine, "bank1", 0, 2, ram, 0x10000);
684684   memory_configure_bank(machine, "bank1", 2, 1, machine->region(Z80_TAG)->base(), 0);
r9922r9923
748748   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
749749   
750750   // internal ram
751   MCFG_RAM_ADD("messram")
751   MCFG_RAM_ADD(RAM_TAG)
752752   MCFG_RAM_DEFAULT_SIZE("128K")
753753MACHINE_CONFIG_END
754754
src/mess/drivers/osborne1.c
r9922r9923
4242#include "formats/basicdsk.h"
4343#include "machine/wd17xx.h"
4444#include "machine/6821pia.h"
45#include "devices/messram.h"
45#include "machine/ram.h"
4646#include "includes/osborne1.h"
4747
4848
r9922r9923
269269   MCFG_FLOPPY_2_DRIVES_ADD(osborne1_floppy_config)
270270
271271   /* internal ram */
272   MCFG_RAM_ADD("messram")
272   MCFG_RAM_ADD(RAM_TAG)
273273   MCFG_RAM_DEFAULT_SIZE("68K")   /* 64KB Main RAM and 4Kbit video attribute RAM */
274274MACHINE_CONFIG_END
275275
src/mess/drivers/vtech1.c
r9922r9923
123123#include "devices/snapquik.h"
124124#include "devices/cassette.h"
125125#include "devices/z80bin.h"
126#include "devices/messram.h"
126#include "machine/ram.h"
127127#include "formats/vt_cas.h"
128128
129129
r9922r9923
696696   vtech1->printer = machine->device("printer");
697697
698698   /* ram */
699   vtech1->ram = messram_get_ptr(machine->device("messram"));
700   vtech1->ram_size = messram_get_size(machine->device("messram"));
699   vtech1->ram = ram_get_ptr(machine->device(RAM_TAG));
700   vtech1->ram_size = ram_get_size(machine->device(RAM_TAG));
701701
702702   /* setup memory banking */
703703   memory_set_bankptr(machine, "bank1", vtech1->ram);
r9922r9923
10471047   MCFG_CARTSLOT_EXTENSION_LIST("rom")
10481048
10491049   /* internal ram */
1050   MCFG_RAM_ADD("messram")
1050   MCFG_RAM_ADD(RAM_TAG)
10511051   MCFG_RAM_DEFAULT_SIZE("66K")
10521052   MCFG_RAM_EXTRA_OPTIONS("2K,18K,4098K")
10531053
r9922r9923
10651065    MCFG_CPU_PROGRAM_MAP(laser210_mem)
10661066
10671067   /* internal ram */
1068   MCFG_RAM_MODIFY("messram")
1068   MCFG_RAM_MODIFY(RAM_TAG)
10691069   MCFG_RAM_DEFAULT_SIZE("66K")
10701070   MCFG_RAM_EXTRA_OPTIONS("6K,22K,4098K")
10711071MACHINE_CONFIG_END
r9922r9923
10751075    MCFG_CPU_PROGRAM_MAP(laser310_mem)
10761076
10771077   /* internal ram */
1078   MCFG_RAM_MODIFY("messram")
1078   MCFG_RAM_MODIFY(RAM_TAG)
10791079   MCFG_RAM_DEFAULT_SIZE("66K")
10801080   MCFG_RAM_EXTRA_OPTIONS("16K,32K,4098K")
10811081MACHINE_CONFIG_END
src/mess/drivers/amstrad.c
r9922r9923
106106#include "devices/cassette.h"
107107#include "formats/tzx_cas.h"
108108
109#include "devices/messram.h"
109#include "machine/ram.h"
110110
111111#define MANUFACTURER_NAME 0x07
112112#define TV_REFRESH_RATE 0x10
r9922r9923
918918   MCFG_FLOPPY_2_DRIVES_ADD(cpc6128_floppy_config)
919919
920920   /* internal ram */
921   MCFG_RAM_ADD("messram")
921   MCFG_RAM_ADD(RAM_TAG)
922922   MCFG_RAM_DEFAULT_SIZE("128K")
923923MACHINE_CONFIG_END
924924
r9922r9923
982982   MCFG_FLOPPY_2_DRIVES_ADD(cpc6128_floppy_config)
983983
984984   /* internal ram */
985   MCFG_RAM_ADD("messram")
985   MCFG_RAM_ADD(RAM_TAG)
986986   MCFG_RAM_DEFAULT_SIZE("128K")
987987MACHINE_CONFIG_END
988988
r9922r9923
10241024   MCFG_FRAGMENT_ADD(cpcplus_cartslot)
10251025
10261026   /* internal ram */
1027   MCFG_RAM_ADD("messram")
1027   MCFG_RAM_ADD(RAM_TAG)
10281028   MCFG_RAM_DEFAULT_SIZE("64K")
10291029MACHINE_CONFIG_END
10301030
r9922r9923
10441044   MCFG_FLOPPY_2_DRIVES_MODIFY(aleste_floppy_config)
10451045
10461046   /* internal ram */
1047   MCFG_RAM_MODIFY("messram")
1047   MCFG_RAM_MODIFY(RAM_TAG)
10481048   MCFG_RAM_DEFAULT_SIZE("2M")
10491049MACHINE_CONFIG_END
10501050
src/mess/drivers/kyocera.c
r9922r9923
6767#include "cpu/i8085/i8085.h"
6868#include "devices/cartslot.h"
6969#include "devices/cassette.h"
70#include "devices/messram.h"
70#include "machine/ram.h"
7171#include "machine/ctronics.h"
7272#include "machine/upd1990a.h"
7373#include "machine/i8155.h"
r9922r9923
142142   switch (ram_bank)
143143   {
144144   case 0:
145      if (messram_get_size(m_ram) > 16 * 1024)
145      if (ram_get_size(m_ram) > 16 * 1024)
146146      {
147147         memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank2");
148148      }
r9922r9923
158158      break;
159159
160160   case 2:
161      if (messram_get_size(m_ram) > 32 * 1024)
161      if (ram_get_size(m_ram) > 32 * 1024)
162162         memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank2");
163163      else
164164         memory_unmap_readwrite(program, 0x8000, 0xffff, 0, 0);
165165      break;
166166
167167   case 3:
168      if (messram_get_size(m_ram) > 64 * 1024)
168      if (ram_get_size(m_ram) > 64 * 1024)
169169         memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank2");
170170      else
171171         memory_unmap_readwrite(program, 0x8000, 0xffff, 0, 0);
r9922r9923
488488      memory_set_bank(machine, "bank1", rom_bank);
489489   }
490490
491   if (messram_get_size(m_ram) < ((ram_bank + 1) * 24 * 1024))
491   if (ram_get_size(m_ram) < ((ram_bank + 1) * 24 * 1024))
492492   {
493493      /* invalid RAM bank */
494494      memory_unmap_readwrite(program, 0xa000, 0xffff, 0, 0);
r9922r9923
11401140   memory_set_bank(machine, "bank1", 0);
11411141
11421142   /* configure RAM banking */
1143   switch (messram_get_size(m_ram))
1143   switch (ram_get_size(m_ram))
11441144   {
11451145   case 16 * 1024:
11461146      memory_unmap_readwrite(program, 0x8000, 0xbfff, 0, 0);
r9922r9923
11521152      break;
11531153   }
11541154
1155   memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(m_ram), 0);
1155   memory_configure_bank(machine, "bank2", 0, 1, ram_get_ptr(m_ram), 0);
11561156   memory_set_bank(machine, "bank2", 0);
11571157
11581158   /* register for state saving */
r9922r9923
11641164
11651165void pc8201_state::machine_start()
11661166{
1167   UINT8 *ram = messram_get_ptr(m_ram);
1167   UINT8 *ram = ram_get_ptr(m_ram);
11681168
11691169   /* initialize RTC */
11701170   upd1990a_cs_w(m_rtc, 1);
r9922r9923
12071207   memory_set_bank(machine, "bank1", 0);
12081208
12091209   /* configure RAM banking */
1210   switch (messram_get_size(m_ram))
1210   switch (ram_get_size(m_ram))
12111211   {
12121212   case 8 * 1024:
12131213      memory_unmap_readwrite(program, 0x8000, 0xcfff, 0, 0);
r9922r9923
12291229      break;
12301230   }
12311231
1232   memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(m_ram), 0);
1232   memory_configure_bank(machine, "bank2", 0, 1, ram_get_ptr(m_ram), 0);
12331233   memory_set_bank(machine, "bank2", 0);
12341234
12351235   /* register for state saving */
r9922r9923
12481248   memory_set_bank(machine, "bank1", 0);
12491249
12501250   /* configure RAM banking */
1251   memory_configure_bank(machine, "bank2", 0, 3, messram_get_ptr(m_ram), 0x6000);
1251   memory_configure_bank(machine, "bank2", 0, 3, ram_get_ptr(m_ram), 0x6000);
12521252   memory_set_bank(machine, "bank2", 0);
12531253
12541254   /* register for state saving */
r9922r9923
13251325   MCFG_SOFTWARE_LIST_ADD("cart_list", "trsm100")
13261326
13271327   /* internal ram */
1328   MCFG_RAM_ADD("messram")
1328   MCFG_RAM_ADD(RAM_TAG)
13291329   MCFG_RAM_DEFAULT_SIZE("16K")
13301330   MCFG_RAM_EXTRA_OPTIONS("32K")
13311331MACHINE_CONFIG_END
r9922r9923
13671367   MCFG_SOFTWARE_LIST_ADD("cart_list", "pc8201")
13681368
13691369   /* internal ram */
1370   MCFG_RAM_ADD("messram")
1370   MCFG_RAM_ADD(RAM_TAG)
13711371   MCFG_RAM_DEFAULT_SIZE("16K")
13721372   MCFG_RAM_EXTRA_OPTIONS("32K,64K,96K")
13731373MACHINE_CONFIG_END
r9922r9923
14041404   MCFG_SOFTWARE_LIST_ADD("cart_list", "trsm100")
14051405
14061406   /* internal ram */
1407   MCFG_RAM_ADD("messram")
1407   MCFG_RAM_ADD(RAM_TAG)
14081408   MCFG_RAM_DEFAULT_SIZE("8K")
14091409   MCFG_RAM_EXTRA_OPTIONS("16K,24K,32K")
14101410MACHINE_CONFIG_END
14111411
14121412static MACHINE_CONFIG_DERIVED( tandy102, trsm100 )
1413   MCFG_RAM_MODIFY("messram")
1413   MCFG_RAM_MODIFY(RAM_TAG)
14141414   MCFG_RAM_DEFAULT_SIZE("24K")
14151415   MCFG_RAM_EXTRA_OPTIONS("32K")
14161416MACHINE_CONFIG_END
r9922r9923
14521452   MCFG_SOFTWARE_LIST_ADD("cart_list", "tandy200")
14531453
14541454   /* internal ram */
1455   MCFG_RAM_ADD("messram")
1455   MCFG_RAM_ADD(RAM_TAG)
14561456   MCFG_RAM_DEFAULT_SIZE("24K")
14571457   MCFG_RAM_EXTRA_OPTIONS("48K,72K")
14581458MACHINE_CONFIG_END
src/mess/drivers/llc.c
r9922r9923
1212#include "cpu/z80/z80daisy.h"
1313#include "machine/z80pio.h"
1414#include "machine/z80ctc.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616#include "includes/llc.h"
1717
1818/* Address maps */
r9922r9923
368368   MCFG_Z80CTC_ADD( "z80ctc", XTAL_3MHz, llc2_ctc_intf )
369369
370370   /* internal ram */
371   MCFG_RAM_ADD("messram")
371   MCFG_RAM_ADD(RAM_TAG)
372372   MCFG_RAM_DEFAULT_SIZE("64K")
373373MACHINE_CONFIG_END
374374/* ROM definition */
src/mess/drivers/samcoupe.c
r9922r9923
4545#include "formats/tzx_cas.h"
4646#include "devices/flopdrv.h"
4747#include "formats/coupedsk.h"
48#include "devices/messram.h"
48#include "machine/ram.h"
4949
5050/***************************************************************************
5151    CONSTANTS
r9922r9923
591591   MCFG_FLOPPY_2_DRIVES_ADD(samcoupe_floppy_config)
592592
593593   /* internal ram */
594   MCFG_RAM_ADD("messram")
594   MCFG_RAM_ADD(RAM_TAG)
595595   MCFG_RAM_DEFAULT_SIZE("512K")
596596   MCFG_RAM_EXTRA_OPTIONS("256K,1280K,1536K,2304K,2560K,3328K,3584K,4352K,4608K")
597597MACHINE_CONFIG_END
src/mess/drivers/comx35.c
r9922r9923
2525#include "devices/snapquik.h"
2626#include "machine/cdp1871.h"
2727#include "machine/wd17xx.h"
28#include "devices/messram.h"
28#include "machine/ram.h"
2929#include "video/mc6845.h"
3030
3131/* Memory Maps */
r9922r9923
375375   MCFG_FLOPPY_2_DRIVES_ADD(comx35_floppy_config)
376376
377377   /* internal ram */
378   MCFG_RAM_ADD("messram")
378   MCFG_RAM_ADD(RAM_TAG)
379379   MCFG_RAM_DEFAULT_SIZE("32K")
380380MACHINE_CONFIG_END
381381
r9922r9923
399399   MCFG_FLOPPY_2_DRIVES_ADD(comx35_floppy_config)
400400
401401   /* internal ram */
402   MCFG_RAM_ADD("messram")
402   MCFG_RAM_ADD(RAM_TAG)
403403   MCFG_RAM_DEFAULT_SIZE("32K")
404404MACHINE_CONFIG_END
405405
src/mess/drivers/jtc.c
r9922r9923
1313#include "machine/ctronics.h"
1414#include "sound/speaker.h"
1515#include "sound/wave.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717
1818/* Read/Write Handlers */
1919
r9922r9923
707707    MCFG_VIDEO_UPDATE(jtc)
708708
709709   /* internal ram */
710   MCFG_RAM_ADD("messram")
710   MCFG_RAM_ADD(RAM_TAG)
711711   MCFG_RAM_DEFAULT_SIZE("2K")
712712MACHINE_CONFIG_END
713713
r9922r9923
718718    MCFG_CPU_PROGRAM_MAP(jtc_es1988_mem)
719719
720720   /* internal ram */
721   MCFG_RAM_MODIFY("messram")
721   MCFG_RAM_MODIFY(RAM_TAG)
722722   MCFG_RAM_DEFAULT_SIZE("4K")
723723MACHINE_CONFIG_END
724724
r9922r9923
743743    MCFG_VIDEO_UPDATE(jtc_es23)
744744
745745   /* internal ram */
746   MCFG_RAM_ADD("messram")
746   MCFG_RAM_ADD(RAM_TAG)
747747   MCFG_RAM_DEFAULT_SIZE("4K")
748748MACHINE_CONFIG_END
749749
r9922r9923
768768    MCFG_VIDEO_UPDATE(jtc_es40)
769769
770770   /* internal ram */
771   MCFG_RAM_ADD("messram")
771   MCFG_RAM_ADD(RAM_TAG)
772772   MCFG_RAM_DEFAULT_SIZE("8K")
773773   MCFG_RAM_EXTRA_OPTIONS("16K,32K")
774774MACHINE_CONFIG_END
src/mess/drivers/tiki100.c
r9922r9923
3434#include "machine/z80pio.h"
3535#include "machine/wd17xx.h"
3636#include "sound/ay8910.h"
37#include "devices/messram.h"
37#include "machine/ram.h"
3838
3939INLINE device_t *get_floppy_image(running_machine *machine, int drive)
4040{
r9922r9923
593593
594594   /* setup memory banking */
595595   memory_configure_bank(machine, "bank1", BANK_ROM, 1, machine->region(Z80_TAG)->base(), 0);
596   memory_configure_bank(machine, "bank1", BANK_RAM, 1, messram_get_ptr(machine->device("messram")), 0);
596   memory_configure_bank(machine, "bank1", BANK_RAM, 1, ram_get_ptr(machine->device(RAM_TAG)), 0);
597597   memory_configure_bank(machine, "bank1", BANK_VIDEO_RAM, 1, state->video_ram, 0);
598598
599   memory_configure_bank(machine, "bank2", BANK_RAM, 1, messram_get_ptr(machine->device("messram")) + 0x4000, 0);
599   memory_configure_bank(machine, "bank2", BANK_RAM, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x4000, 0);
600600   memory_configure_bank(machine, "bank2", BANK_VIDEO_RAM, 1, state->video_ram + 0x4000, 0);
601601
602   memory_configure_bank(machine, "bank3", BANK_RAM, 1, messram_get_ptr(machine->device("messram")) + 0x8000, 0);
602   memory_configure_bank(machine, "bank3", BANK_RAM, 1, ram_get_ptr(machine->device(RAM_TAG)) + 0x8000, 0);
603603
604604   tiki100_bankswitch(machine);
605605
r9922r9923
691691   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
692692
693693   /* internal ram */
694   MCFG_RAM_ADD("messram")
694   MCFG_RAM_ADD(RAM_TAG)
695695   MCFG_RAM_DEFAULT_SIZE("64K")
696696MACHINE_CONFIG_END
697697
src/mess/drivers/atm.c
r9922r9923
77#include "sound/speaker.h"
88#include "machine/wd17xx.h"
99#include "machine/beta.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111
1212
1313class atm_state : public driver_device
r9922r9923
6262{
6363   spectrum_state *state = machine->driver_data<spectrum_state>();
6464   device_t *beta = machine->device(BETA_DISK_TAG);
65   UINT8 *messram = messram_get_ptr(machine->device("messram"));
65   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
6666
6767   state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14));
6868
r9922r9923
111111static MACHINE_RESET( atm )
112112{
113113   spectrum_state *state = machine->driver_data<spectrum_state>();
114   UINT8 *messram = messram_get_ptr(machine->device("messram"));
114   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
115115   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
116116   device_t *beta = machine->device(BETA_DISK_TAG);
117117
src/mess/drivers/abc1600.c
r9922r9923
2929#include "emu.h"
3030#include "cpu/m68000/m68000.h"
3131#include "devices/flopdrv.h"
32#include "devices/messram.h"
32#include "machine/ram.h"
3333#include "machine/8530scc.h"
3434#include "machine/abc99.h"
3535#include "machine/s1410.h"
r9922r9923
292292   MCFG_S1410_ADD()
293293
294294   // internal ram
295   MCFG_RAM_ADD("messram")
295   MCFG_RAM_ADD(RAM_TAG)
296296   MCFG_RAM_DEFAULT_SIZE("1M")
297297MACHINE_CONFIG_END
298298
src/mess/drivers/svi318.c
r9922r9923
2525#include "formats/svi_cas.h"
2626#include "sound/dac.h"
2727#include "sound/ay8910.h"
28#include "devices/messram.h"
28#include "machine/ram.h"
2929#include "rendlay.h"
3030
3131static ADDRESS_MAP_START( svi318_mem, ADDRESS_SPACE_PROGRAM, 8 )
r9922r9923
342342   MCFG_FRAGMENT_ADD( svi318_cartslot )
343343
344344   /* internal ram */
345   MCFG_RAM_ADD("messram")
345   MCFG_RAM_ADD(RAM_TAG)
346346   MCFG_RAM_DEFAULT_SIZE("16K")
347347   MCFG_RAM_EXTRA_OPTIONS("32K,96K,160K")
348348MACHINE_CONFIG_END
r9922r9923
359359static MACHINE_CONFIG_DERIVED( svi328, svi318 )
360360
361361   /* internal ram */
362   MCFG_RAM_MODIFY("messram")
362   MCFG_RAM_MODIFY(RAM_TAG)
363363   MCFG_RAM_DEFAULT_SIZE("64K")
364364   MCFG_RAM_EXTRA_OPTIONS("96K,160K")
365365MACHINE_CONFIG_END
r9922r9923
367367static MACHINE_CONFIG_DERIVED( svi328n, svi318n )
368368
369369   /* internal ram */
370   MCFG_RAM_MODIFY("messram")
370   MCFG_RAM_MODIFY(RAM_TAG)
371371   MCFG_RAM_DEFAULT_SIZE("64K")
372372   MCFG_RAM_EXTRA_OPTIONS("96K,160K")
373373MACHINE_CONFIG_END
r9922r9923
464464   MCFG_FRAGMENT_ADD( svi318_cartslot )
465465
466466   /* internal ram */
467   MCFG_RAM_ADD("messram")
467   MCFG_RAM_ADD(RAM_TAG)
468468   MCFG_RAM_DEFAULT_SIZE("64K")
469469   MCFG_RAM_EXTRA_OPTIONS("96K,160K")
470470MACHINE_CONFIG_END
src/mess/drivers/vcs80.c
r9922r9923
1313#include "cpu/z80/z80.h"
1414#include "cpu/z80/z80daisy.h"
1515#include "machine/z80pio.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717#include "vcs80.lh"
1818
1919/* Read/Write Handlers */
r9922r9923
226226   MCFG_Z80PIO_ADD(Z80PIO_TAG, XTAL_5MHz/2, pio_intf)
227227
228228   /* internal ram */
229   MCFG_RAM_ADD("messram")
229   MCFG_RAM_ADD(RAM_TAG)
230230   MCFG_RAM_DEFAULT_SIZE("1K")
231231MACHINE_CONFIG_END
232232
src/mess/drivers/ob68k1a.c
r9922r9923
6262
6363#include "emu.h"
6464#include "cpu/m68000/m68000.h"
65#include "devices/messram.h"
65#include "machine/ram.h"
6666#include "machine/6821pia.h"
6767#include "machine/6840ptm.h"
6868#include "machine/6850acia.h"
r9922r9923
286286   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
287287
288288   // configure RAM
289   switch (messram_get_size(m_ram))
289   switch (ram_get_size(m_ram))
290290   {
291291   case 32*1024:
292292      memory_unmap_readwrite(program, 0x008000, 0x01ffff, 0, 0);
r9922r9923
342342   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
343343   
344344   // internal ram
345   MCFG_RAM_ADD("messram")
345   MCFG_RAM_ADD(RAM_TAG)
346346   MCFG_RAM_DEFAULT_SIZE("32K")
347347   MCFG_RAM_EXTRA_OPTIONS("128K")
348348MACHINE_CONFIG_END
src/mess/drivers/tandy2k.c
r9922r9923
3030#include "cpu/i86/i86.h"
3131#include "cpu/mcs48/mcs48.h"
3232#include "devices/flopdrv.h"
33#include "devices/messram.h"
33#include "machine/ram.h"
3434#include "machine/ctronics.h"
3535#include "machine/i8255a.h"
3636#include "machine/msm8251.h"
r9922r9923
842842{
843843   /* memory banking */
844844   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
845   UINT8 *ram = messram_get_ptr(m_ram);
846   int ram_size = messram_get_size(m_ram);
845   UINT8 *ram = ram_get_ptr(m_ram);
846   int ram_size = ram_get_size(m_ram);
847847
848848   memory_install_ram(program, 0x00000, ram_size - 1, 0, 0, ram);
849849
r9922r9923
911911   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
912912
913913   /* internal ram */
914   MCFG_RAM_ADD("messram")
914   MCFG_RAM_ADD(RAM_TAG)
915915   MCFG_RAM_DEFAULT_SIZE("128K")
916916   MCFG_RAM_EXTRA_OPTIONS("256K,384K,512K,640K,768K,896K")
917917MACHINE_CONFIG_END
src/mess/drivers/nanos.c
r9922r9923
1515#include "machine/upd765.h"
1616#include "devices/flopdrv.h"
1717#include "formats/basicdsk.h"
18#include "devices/messram.h"
18#include "machine/ram.h"
1919
2020
2121class nanos_state : public driver_device
r9922r9923
263263         {
264264            if (ra < 8)
265265            {
266               chr = messram_get_ptr(screen->machine->device("messram"))[0xf800+ x];
266               chr = ram_get_ptr(screen->machine->device(RAM_TAG))[0xf800+ x];
267267
268268               /* get pattern of pixels for that character scanline */
269269               gfx = state->FNT[(chr<<3) | ra ];
r9922r9923
313313   if (BIT(data,7)) {
314314      memory_set_bankptr(device->machine, "bank1", device->machine->region("maincpu")->base());
315315   } else {
316      memory_set_bankptr(device->machine, "bank1", messram_get_ptr(device->machine->device("messram")));
316      memory_set_bankptr(device->machine, "bank1", ram_get_ptr(device->machine->device(RAM_TAG)));
317317   }
318318}
319319static UINT8 row_number(UINT8 code) {
r9922r9923
427427   memory_install_write_bank(space, 0x1000, 0xffff, 0, 0, "bank2");
428428
429429   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base());
430   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x1000);
431   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")));
430   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x1000);
431   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)));
432432
433433   floppy_mon_w(floppy_get_device(space->machine, 0), CLEAR_LINE);
434434   floppy_drive_set_ready_state(floppy_get_device(space->machine, 0), 1,1);
r9922r9923
532532   MCFG_FLOPPY_4_DRIVES_ADD(nanos_floppy_config)
533533
534534   /* internal ram */
535   MCFG_RAM_ADD("messram")
535   MCFG_RAM_ADD(RAM_TAG)
536536   MCFG_RAM_DEFAULT_SIZE("64K")
537537MACHINE_CONFIG_END
538538
src/mess/drivers/galaxy.c
r9922r9923
2929#include "devices/cassette.h"
3030#include "sound/ay8910.h"
3131#include "formats/gtp_cas.h"
32#include "devices/messram.h"
32#include "machine/ram.h"
3333
3434static ADDRESS_MAP_START (galaxyp_io, ADDRESS_SPACE_IO, 8)
3535   ADDRESS_MAP_GLOBAL_MASK(0x01)
r9922r9923
213213   MCFG_CASSETTE_ADD( "cassette", galaxy_cassette_config )
214214
215215   /* internal ram */
216   MCFG_RAM_ADD("messram")
216   MCFG_RAM_ADD(RAM_TAG)
217217   MCFG_RAM_DEFAULT_SIZE("6K")
218218   MCFG_RAM_EXTRA_OPTIONS("2K,22K,38K,54K")
219219MACHINE_CONFIG_END
r9922r9923
252252   MCFG_CASSETTE_ADD( "cassette", galaxy_cassette_config )
253253
254254   /* internal ram */
255   MCFG_RAM_ADD("messram")
255   MCFG_RAM_ADD(RAM_TAG)
256256   MCFG_RAM_DEFAULT_SIZE("38K")
257257MACHINE_CONFIG_END
258258
src/mess/drivers/huebler.c
r9922r9923
2828#include "machine/z80pio.h"
2929#include "machine/z80dart.h"
3030#include "machine/z80ctc.h"
31#include "devices/messram.h"
31#include "machine/ram.h"
3232
3333/* Keyboard */
3434
r9922r9923
416416   MCFG_CASSETTE_ADD(CASSETTE_TAG, amu880_cassette_config)
417417
418418   /* internal ram */
419   MCFG_RAM_ADD("messram")
419   MCFG_RAM_ADD(RAM_TAG)
420420   MCFG_RAM_DEFAULT_SIZE("64K")
421421MACHINE_CONFIG_END
422422
src/mess/drivers/vidbrain.c
r9922r9923
3131#include "cpu/f8/f8.h"
3232#include "devices/cartslot.h"
3333#include "devices/cassette.h"
34#include "devices/messram.h"
34#include "machine/ram.h"
3535#include "sound/discrete.h"
3636
3737
r9922r9923
504504   MCFG_SOFTWARE_LIST_ADD("cart_list", "vidbrain")
505505
506506   // internal ram
507   MCFG_RAM_ADD("messram")
507   MCFG_RAM_ADD(RAM_TAG)
508508   MCFG_RAM_DEFAULT_SIZE("1K")
509509MACHINE_CONFIG_END
510510
src/mess/drivers/zx.c
r9922r9923
4545#include "includes/zx.h"
4646#include "devices/cassette.h"
4747#include "formats/zx81_p.h"
48#include "devices/messram.h"
48#include "machine/ram.h"
4949
5050/* Memory Maps */
5151
r9922r9923
417417   MCFG_CASSETTE_ADD( "cassette", zx80_cassette_config )
418418
419419   /* internal ram */
420   MCFG_RAM_ADD("messram")
420   MCFG_RAM_ADD(RAM_TAG)
421421   MCFG_RAM_DEFAULT_SIZE("1K")
422422   MCFG_RAM_EXTRA_OPTIONS("16K")
423423MACHINE_CONFIG_END
r9922r9923
440440static MACHINE_CONFIG_DERIVED( ts1500, ts1000 )
441441
442442   /* internal ram */
443   MCFG_RAM_MODIFY("messram")
443   MCFG_RAM_MODIFY(RAM_TAG)
444444   MCFG_RAM_DEFAULT_SIZE("16K")
445445MACHINE_CONFIG_END
446446
r9922r9923
460460   MCFG_PALETTE_INIT(zx80)
461461
462462   /* internal ram */
463   MCFG_RAM_MODIFY("messram")
463   MCFG_RAM_MODIFY(RAM_TAG)
464464   MCFG_RAM_DEFAULT_SIZE("16K")
465465MACHINE_CONFIG_END
466466
r9922r9923
475475   MCFG_PALETTE_INIT(zx80)
476476
477477   /* internal ram */
478   MCFG_RAM_MODIFY("messram")
478   MCFG_RAM_MODIFY(RAM_TAG)
479479   MCFG_RAM_DEFAULT_SIZE("2K")
480480   MCFG_RAM_EXTRA_OPTIONS("16K")
481481MACHINE_CONFIG_END
src/mess/drivers/z80ne.c
r9922r9923
9595#include "devices/flopdrv.h"
9696#include "devices/cassette.h"
9797#include "formats/z80ne_dsk.h"
98#include "devices/messram.h"
98#include "machine/ram.h"
9999
100100/* peripheral chips */
101101#include "machine/ay31015.h"
r9922r9923
482482   MCFG_DEFAULT_LAYOUT(layout_z80ne)
483483
484484   /* internal ram */
485   MCFG_RAM_ADD("messram")
485   MCFG_RAM_ADD(RAM_TAG)
486486   MCFG_RAM_DEFAULT_SIZE("32K")
487487MACHINE_CONFIG_END
488488
r9922r9923
513513   MCFG_DEFAULT_LAYOUT(layout_z80net)
514514
515515   /* internal ram */
516   MCFG_RAM_MODIFY("messram")
516   MCFG_RAM_MODIFY(RAM_TAG)
517517   MCFG_RAM_DEFAULT_SIZE("32K")
518518   MCFG_RAM_EXTRA_OPTIONS("1K")
519519MACHINE_CONFIG_END
r9922r9923
549549   MCFG_MC6847_PALETTE(lx388palette)
550550
551551   /* internal ram */
552   MCFG_RAM_ADD("messram")
552   MCFG_RAM_ADD(RAM_TAG)
553553   MCFG_RAM_DEFAULT_SIZE("32K")
554554   MCFG_RAM_EXTRA_OPTIONS("1K")
555555MACHINE_CONFIG_END
r9922r9923
589589   MCFG_DEFAULT_LAYOUT(layout_z80netf)
590590
591591   /* internal ram */
592   MCFG_RAM_ADD("messram")
592   MCFG_RAM_ADD(RAM_TAG)
593593   MCFG_RAM_DEFAULT_SIZE("56K")
594594MACHINE_CONFIG_END
595595
src/mess/drivers/exp85.c
r9922r9923
2424#include "machine/i8155.h"
2525#include "machine/i8355.h"
2626#include "sound/speaker.h"
27#include "devices/messram.h"
27#include "machine/ram.h"
2828
2929/* Memory Maps */
3030
r9922r9923
236236   MCFG_CASSETTE_ADD(CASSETTE_TAG, exp85_cassette_config)
237237
238238   /* internal ram */
239   MCFG_RAM_ADD("messram")
239   MCFG_RAM_ADD(RAM_TAG)
240240   MCFG_RAM_DEFAULT_SIZE("256")
241241   MCFG_RAM_EXTRA_OPTIONS("4K")
242242MACHINE_CONFIG_END
src/mess/drivers/apple2gs.c
r9922r9923
5959#include "sound/ay8910.h"
6060#include "sound/speaker.h"
6161#include "devices/cassette.h"
62#include "devices/messram.h"
62#include "machine/ram.h"
6363#include "deprecat.h"
6464
6565static const gfx_layout apple2gs_text_layout =
r9922r9923
298298   MCFG_CASSETTE_ADD( "cassette", apple2gs_cassette_config )
299299
300300   /* internal ram */
301   MCFG_RAM_ADD("messram")
301   MCFG_RAM_ADD(RAM_TAG)
302302   MCFG_RAM_DEFAULT_SIZE("2M")
303303   MCFG_RAM_EXTRA_OPTIONS("64K")
304304   MCFG_RAM_DEFAULT_VALUE(0x00)
src/mess/drivers/vt320.c
r9922r9923
88
99#include "emu.h"
1010#include "cpu/mcs51/mcs51.h"
11#include "devices/messram.h"
11#include "machine/ram.h"
1212
1313
1414class vt320_state : public driver_device
r9922r9923
5959
6060static MACHINE_RESET(vt320)
6161{
62   memset(messram_get_ptr(machine->device("messram")),0,16*1024);
62   memset(ram_get_ptr(machine->device(RAM_TAG)),0,16*1024);
6363}
6464
6565static VIDEO_START( vt320 )
r9922r9923
9494    MCFG_VIDEO_UPDATE(vt320)
9595
9696   /* internal ram */
97   MCFG_RAM_ADD("messram")
97   MCFG_RAM_ADD(RAM_TAG)
9898   MCFG_RAM_DEFAULT_SIZE("16K")
9999MACHINE_CONFIG_END
100100
src/mess/drivers/trs80m2.c
r9922r9923
2222#include "cpu/mcs48/mcs48.h"
2323#include "cpu/m68000/m68000.h"
2424#include "devices/flopdrv.h"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626#include "machine/ctronics.h"
2727#include "machine/wd17xx.h"
2828#include "machine/z80ctc.h"
r9922r9923
160160   trs80m2_state *state = machine->driver_data<trs80m2_state>();
161161
162162   address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
163   device_t *messram = machine->device("messram");
163   device_t *messram = machine->device(RAM_TAG);
164164   UINT8 *rom = machine->region(Z80_TAG)->base();
165   UINT8 *ram = messram_get_ptr(messram);
166   int last_page = (messram_get_size(messram) / 0x8000) - 1;
165   UINT8 *ram = ram_get_ptr(messram);
166   int last_page = (ram_get_size(messram) / 0x8000) - 1;
167167
168168   if (state->boot_rom)
169169   {
r9922r9923
10471047   MCFG_TIMER_ADD_PERIODIC("keyboard", trs80m2_keyboard_tick, HZ(60))
10481048
10491049   /* internal RAM */
1050   MCFG_RAM_ADD("messram")
1050   MCFG_RAM_ADD(RAM_TAG)
10511051   MCFG_RAM_DEFAULT_SIZE("32K")
10521052   MCFG_RAM_EXTRA_OPTIONS("64K,96K,128K,160K,192K,224K,256K,288K,320K,352K,384K,416K,448K,480K,512K")
10531053MACHINE_CONFIG_END
r9922r9923
10621062   MCFG_PALETTE_INIT(monochrome_green)
10631063
10641064   /* internal RAM */
1065   MCFG_RAM_MODIFY("messram")
1065   MCFG_RAM_MODIFY(RAM_TAG)
10661066   MCFG_RAM_DEFAULT_SIZE("256K")
10671067   MCFG_RAM_EXTRA_OPTIONS("512K,768K,1M")
10681068MACHINE_CONFIG_END
src/mess/drivers/atari.c
r9922r9923
3939#include "machine/6821pia.h"
4040#include "video/gtia.h"
4141#include "sound/dac.h"
42#include "devices/messram.h"
42#include "machine/ram.h"
4343
4444/******************************************************************************
4545    Atari 800 memory map (preliminary)
r9922r9923
10611061   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
10621062
10631063   /* internal ram */
1064   MCFG_RAM_ADD("messram")
1064   MCFG_RAM_ADD(RAM_TAG)
10651065   MCFG_RAM_DEFAULT_SIZE("40K")
10661066
10671067   MCFG_ATARI_FDC_ADD("fdc")
r9922r9923
11551155   MCFG_FRAGMENT_ADD(a400_cartslot)
11561156
11571157   /* internal ram */
1158   MCFG_RAM_MODIFY("messram")
1158   MCFG_RAM_MODIFY(RAM_TAG)
11591159   MCFG_RAM_DEFAULT_SIZE("16K")
11601160MACHINE_CONFIG_END
11611161
r9922r9923
12411241   MCFG_SOFTWARE_LIST_ADD("cart_list","a5200")
12421242
12431243   /* internal ram */
1244   MCFG_RAM_MODIFY("messram")
1244   MCFG_RAM_MODIFY(RAM_TAG)
12451245   MCFG_RAM_DEFAULT_SIZE("16K")
12461246MACHINE_CONFIG_END
12471247
src/mess/drivers/mac.c
r9922r9923
4848#include "devices/sonydriv.h"
4949#include "devices/harddriv.h"
5050#include "formats/ap_dsk35.h"
51#include "devices/messram.h"
51#include "machine/ram.h"
5252#include "devices/chd_cd.h"
5353#include "sound/asc.h"
5454#include "sound/cdda.h"
r9922r9923
633633   MCFG_VIA6522_ADD("via6522_0", 1000000, mac_via6522_intf)
634634
635635   /* internal ram */
636   MCFG_RAM_ADD("messram")
636   MCFG_RAM_ADD(RAM_TAG)
637637   MCFG_RAM_DEFAULT_SIZE("512K")
638638MACHINE_CONFIG_END
639639
640640static MACHINE_CONFIG_DERIVED( mac128k, mac512ke )
641641
642642   /* internal ram */
643   MCFG_RAM_MODIFY("messram")
643   MCFG_RAM_MODIFY(RAM_TAG)
644644   MCFG_RAM_DEFAULT_SIZE("128K")
645645MACHINE_CONFIG_END
646646
r9922r9923
656656   MCFG_FLOPPY_SONY_2_DRIVES_MODIFY(mac_floppy_config)
657657
658658   /* internal ram */
659   MCFG_RAM_MODIFY("messram")
659   MCFG_RAM_MODIFY(RAM_TAG)
660660   MCFG_RAM_DEFAULT_SIZE("4M")
661661   MCFG_RAM_EXTRA_OPTIONS("1M,2M,2560K,4M")
662662MACHINE_CONFIG_END
r9922r9923
667667   MCFG_VIA6522_ADD("via6522_0", 1000000, mac_via6522_adb_intf)
668668
669669   /* internal ram */
670   MCFG_RAM_MODIFY("messram")
670   MCFG_RAM_MODIFY(RAM_TAG)
671671   MCFG_RAM_DEFAULT_SIZE("4M")
672672   MCFG_RAM_EXTRA_OPTIONS("2M,2560K,4M")
673673MACHINE_CONFIG_END
r9922r9923
716716   MCFG_HARDDISK_ADD( "harddisk2" )
717717
718718   /* internal ram */
719   MCFG_RAM_ADD("messram")
719   MCFG_RAM_ADD(RAM_TAG)
720720   MCFG_RAM_DEFAULT_SIZE("1M")
721721   MCFG_RAM_EXTRA_OPTIONS("1M,3M,5M,7M,9M")
722722
r9922r9923
768768   MCFG_HARDDISK_ADD( "harddisk2" )
769769
770770   /* internal ram */
771   MCFG_RAM_ADD("messram")
771   MCFG_RAM_ADD(RAM_TAG)
772772   MCFG_RAM_DEFAULT_SIZE("2M")
773773   MCFG_RAM_EXTRA_OPTIONS("8M,32M,64M,96M,128M")
774774MACHINE_CONFIG_END
r9922r9923
785785   MCFG_VIDEO_RESET(macrbv)
786786   MCFG_VIDEO_UPDATE(macrbvvram)
787787
788   MCFG_RAM_MODIFY("messram")
788   MCFG_RAM_MODIFY(RAM_TAG)
789789   MCFG_RAM_DEFAULT_SIZE("2M")
790790   MCFG_RAM_EXTRA_OPTIONS("4M,6M,8M,10M")
791791
r9922r9923
800800   MCFG_CPU_PROGRAM_MAP(maclc_map)
801801   MCFG_CPU_VBLANK_INT("screen", mac_rbv_vbl)
802802
803   MCFG_RAM_MODIFY("messram")
803   MCFG_RAM_MODIFY(RAM_TAG)
804804   MCFG_RAM_DEFAULT_SIZE("4M")
805805   MCFG_RAM_EXTRA_OPTIONS("6M,8M,10M")
806806MACHINE_CONFIG_END
r9922r9923
815815   MCFG_VIDEO_RESET(macrbv)
816816   MCFG_VIDEO_UPDATE(macrbvvram)
817817
818   MCFG_RAM_MODIFY("messram")
818   MCFG_RAM_MODIFY(RAM_TAG)
819819   MCFG_RAM_DEFAULT_SIZE("4M")
820820   MCFG_RAM_EXTRA_OPTIONS("8M,12M,16M,20M,24M,28M,32M,36M")
821821
r9922r9923
830830   MCFG_CPU_PROGRAM_MAP(macii_map)
831831   MCFG_CPU_VBLANK_INT("screen", mac_cb264_vbl)
832832
833   MCFG_RAM_MODIFY("messram")
833   MCFG_RAM_MODIFY(RAM_TAG)
834834   MCFG_RAM_DEFAULT_SIZE("2M")
835835   MCFG_RAM_EXTRA_OPTIONS("8M,32M,64M,96M,128M")
836836MACHINE_CONFIG_END
r9922r9923
881881   MCFG_HARDDISK_ADD( "harddisk2" )
882882
883883   /* internal ram */
884   MCFG_RAM_ADD("messram")
884   MCFG_RAM_ADD(RAM_TAG)
885885   MCFG_RAM_DEFAULT_SIZE("2M")
886886   MCFG_RAM_EXTRA_OPTIONS("8M,16M,32M,48M,64M,96M,128M")
887887MACHINE_CONFIG_END
r9922r9923
903903   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
904904   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
905905
906   MCFG_RAM_MODIFY("messram")
906   MCFG_RAM_MODIFY(RAM_TAG)
907907   MCFG_RAM_DEFAULT_SIZE("10M")
908908   MCFG_RAM_EXTRA_OPTIONS("2M,4M,6M,8M,10M")
909909MACHINE_CONFIG_END
r9922r9923
925925   MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
926926
927927   /* internal ram */
928   MCFG_RAM_MODIFY("messram")
928   MCFG_RAM_MODIFY(RAM_TAG)
929929   MCFG_RAM_DEFAULT_SIZE("2M")
930930   MCFG_RAM_EXTRA_OPTIONS("4M,8M,16M,32M,48M,64M")
931931MACHINE_CONFIG_END
r9922r9923
947947   MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
948948
949949   /* internal ram */
950   MCFG_RAM_MODIFY("messram")
950   MCFG_RAM_MODIFY(RAM_TAG)
951951   MCFG_RAM_DEFAULT_SIZE("2M")
952952   MCFG_RAM_EXTRA_OPTIONS("4M,8M,16M,32M,48M,64M")
953953MACHINE_CONFIG_END
r9922r9923
995995   MCFG_HARDDISK_ADD( "harddisk2" )
996996
997997   /* internal ram */
998   MCFG_RAM_ADD("messram")
998   MCFG_RAM_ADD(RAM_TAG)
999999   MCFG_RAM_DEFAULT_SIZE("8M")
10001000   MCFG_RAM_EXTRA_OPTIONS("16M,32M,64M,128M")
10011001MACHINE_CONFIG_END
src/mess/drivers/nc.c
r9922r9923
107107#include "formats/pc_dsk.h"      /* for NC200 disk image */
108108#include "devices/cartslot.h"
109109#include "sound/beep.h"
110#include "devices/messram.h"
110#include "machine/ram.h"
111111
112112
113113#define VERBOSE 0
r9922r9923
366366
367367         mem_bank = mem_bank & state->membank_internal_ram_mask;
368368
369         addr = messram_get_ptr(machine->device("messram")) + (mem_bank<<14);
369         addr = ram_get_ptr(machine->device(RAM_TAG)) + (mem_bank<<14);
370370
371371         memory_set_bankptr(machine, bank1, addr);
372372         memory_set_bankptr(machine, bank5, addr);
r9922r9923
439439   /* get size of memory data stored */
440440   mame_fread(state->file, &stored_size, sizeof(unsigned long));
441441
442   if (stored_size > messram_get_size(machine->device("messram")))
443      restore_size = messram_get_size(machine->device("messram"));
442   if (stored_size > ram_get_size(machine->device(RAM_TAG)))
443      restore_size = ram_get_size(machine->device(RAM_TAG));
444444   else
445445      restore_size = stored_size;
446446
447447   /* read as much as will fit into memory */
448   mame_fread(state->file, messram_get_ptr(machine->device("messram")), restore_size);
448   mame_fread(state->file, ram_get_ptr(machine->device(RAM_TAG)), restore_size);
449449   /* seek over remaining data */
450450   mame_fseek(state->file, SEEK_CUR,stored_size - restore_size);
451451}
r9922r9923
454454static void nc_common_store_memory_to_stream(running_machine *machine)
455455{
456456   nc_state *state = machine->driver_data<nc_state>();
457   UINT32 size = messram_get_size(machine->device("messram"));
457   UINT32 size = ram_get_size(machine->device(RAM_TAG));
458458   if (!state->file)
459459      return;
460460
r9922r9923
463463   mame_fwrite(state->file, &size, sizeof(UINT32));
464464
465465   /* write data block */
466   mame_fwrite(state->file, messram_get_ptr(machine->device("messram")), size);
466   mame_fwrite(state->file, ram_get_ptr(machine->device(RAM_TAG)), size);
467467}
468468
469469static void nc_common_open_stream_for_reading(running_machine *machine)
r9922r9923
17461746   MCFG_CARTSLOT_UNLOAD(nc_pcmcia_card)
17471747   
17481748   /* internal ram */
1749   MCFG_RAM_ADD("messram")
1749   MCFG_RAM_ADD(RAM_TAG)
17501750   MCFG_RAM_DEFAULT_SIZE("64K")
17511751
17521752   MCFG_NC_SERIAL_ADD("serial")
r9922r9923
17961796   MCFG_MC146818_ADD( "mc", MC146818_STANDARD )
17971797
17981798   /* internal ram */
1799   MCFG_RAM_MODIFY("messram")
1799   MCFG_RAM_MODIFY(RAM_TAG)
18001800   MCFG_RAM_DEFAULT_SIZE("128K")
18011801MACHINE_CONFIG_END
18021802
src/mess/drivers/pentagon.c
r9922r9923
77#include "sound/speaker.h"
88#include "formats/tzx_cas.h"
99#include "machine/beta.h"
10#include "devices/messram.h"
10#include "machine/ram.h"
1111
1212DIRECT_UPDATE_HANDLER( pentagon_direct )
1313{
r9922r9923
5353{
5454   spectrum_state *state = machine->driver_data<spectrum_state>();
5555   device_t *beta = machine->device(BETA_DISK_TAG);
56   UINT8 *messram = messram_get_ptr(machine->device("messram"));
56   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
5757   state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14));
5858
5959   memory_set_bankptr(machine, "bank4", messram + ((state->port_7ffd_data & 0x07) * 0x4000));
r9922r9923
106106static MACHINE_RESET( pentagon )
107107{
108108   spectrum_state *state = machine->driver_data<spectrum_state>();
109   UINT8 *messram = messram_get_ptr(machine->device("messram"));
109   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
110110   device_t *beta = machine->device(BETA_DISK_TAG);
111111   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
112112
r9922r9923
162162
163163static MACHINE_CONFIG_DERIVED( pent1024, pentagon )
164164   /* internal ram */
165   MCFG_RAM_MODIFY("messram")
165   MCFG_RAM_MODIFY(RAM_TAG)
166166   MCFG_RAM_DEFAULT_SIZE("1024K")
167167MACHINE_CONFIG_END
168168
src/mess/drivers/bw12.c
r9922r9923
2828#include "emu.h"
2929#include "cpu/z80/z80.h"
3030#include "devices/flopdrv.h"
31#include "devices/messram.h"
31#include "machine/ram.h"
3232#include "formats/basicdsk.h"
3333#include "machine/6821pia.h"
3434#include "machine/ctronics.h"
r9922r9923
6767
6868   case 2: /* BK1 */
6969   case 3: /* BK2 */
70      if (messram_get_size(m_ram) > 64*1024)
70      if (ram_get_size(m_ram) > 64*1024)
7171      {
7272         memory_install_readwrite_bank(program, 0x0000, 0x7fff, 0, 0, "bank1");
7373      }
r9922r9923
655655{
656656   /* setup memory banking */
657657   memory_configure_bank(machine, "bank1", 0, 1, machine->region(Z80_TAG)->base(), 0);
658   memory_configure_bank(machine, "bank1", 1, 1, messram_get_ptr(m_ram), 0);
659   memory_configure_bank(machine, "bank1", 2, 2, messram_get_ptr(m_ram) + 0x10000, 0x8000);
658   memory_configure_bank(machine, "bank1", 1, 1, ram_get_ptr(m_ram), 0);
659   memory_configure_bank(machine, "bank1", 2, 2, ram_get_ptr(m_ram) + 0x10000, 0x8000);
660660
661661   /* register for state saving */
662662   state_save_register_global(machine, m_bank);
r9922r9923
823823   MCFG_FLOPPY_2_DRIVES_ADD(bw12_floppy_config)
824824
825825   /* internal ram */
826   MCFG_RAM_ADD("messram")
826   MCFG_RAM_ADD(RAM_TAG)
827827   MCFG_RAM_DEFAULT_SIZE("64K")
828828MACHINE_CONFIG_END
829829
r9922r9923
832832   MCFG_FLOPPY_2_DRIVES_ADD(bw14_floppy_config)
833833
834834   /* internal ram */
835   MCFG_RAM_ADD("messram")
835   MCFG_RAM_ADD(RAM_TAG)
836836   MCFG_RAM_DEFAULT_SIZE("128K")
837837MACHINE_CONFIG_END
838838
src/mess/drivers/pk8000.c
r9922r9923
1515#include "sound/speaker.h"
1616#include "sound/wave.h"
1717#include "includes/pk8000.h"
18#include "devices/messram.h"
18#include "machine/ram.h"
1919
2020
2121class pk8000_state : public driver_device
r9922r9923
4545   switch(block1) {
4646      case 0:
4747            memory_set_bankptr(machine, "bank1", rom + 0x10000);
48            memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")));
48            memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)));
4949            break;
5050      case 1: break;
5151      case 2: break;
5252      case 3:
53            memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
54            memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")));
53            memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
54            memory_set_bankptr(machine, "bank5", ram_get_ptr(machine->device(RAM_TAG)));
5555            break;
5656   }
5757
5858   switch(block2) {
5959      case 0:
6060            memory_set_bankptr(machine, "bank2", rom + 0x14000);
61            memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x4000);
61            memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
6262            break;
6363      case 1: break;
6464      case 2: break;
6565      case 3:
66            memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000);
67            memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x4000);
66            memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
67            memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0x4000);
6868            break;
6969   }
7070   switch(block3) {
7171      case 0:
7272            memory_set_bankptr(machine, "bank3", rom + 0x18000);
73            memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x8000);
73            memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
7474            break;
7575      case 1: break;
7676      case 2: break;
7777      case 3:
78            memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x8000);
79            memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x8000);
78            memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
79            memory_set_bankptr(machine, "bank7", ram_get_ptr(machine->device(RAM_TAG)) + 0x8000);
8080            break;
8181   }
8282   switch(block4) {
8383      case 0:
8484            memory_set_bankptr(machine, "bank4", rom + 0x1c000);
85            memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0xc000);
85            memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
8686            break;
8787      case 1: break;
8888      case 2: break;
8989      case 3:
90            memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xc000);
91            memory_set_bankptr(machine, "bank8", messram_get_ptr(machine->device("messram")) + 0xc000);
90            memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
91            memory_set_bankptr(machine, "bank8", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
9292            break;
9393   }
9494}
r9922r9923
324324
325325static VIDEO_UPDATE( pk8000 )
326326{
327   return pk8000_video_update(screen, bitmap, cliprect, messram_get_ptr(screen->machine->device("messram")));
327   return pk8000_video_update(screen, bitmap, cliprect, ram_get_ptr(screen->machine->device(RAM_TAG)));
328328}
329329
330330/* Machine driver */
r9922r9923
371371    MCFG_CASSETTE_ADD( "cassette", pk8000_cassette_config )
372372
373373   /* internal ram */
374   MCFG_RAM_ADD("messram")
374   MCFG_RAM_ADD(RAM_TAG)
375375   MCFG_RAM_DEFAULT_SIZE("64K")
376376MACHINE_CONFIG_END
377377
src/mess/drivers/prestige.c
r9922r9923
7676
7777#include "emu.h"
7878#include "cpu/z80/z80.h"
79#include "devices/messram.h"
79#include "machine/ram.h"
8080#include "devices/cartslot.h"
8181
8282
r9922r9923
166166
167167static MACHINE_START(prestige)
168168{
169   UINT8 *ram = messram_get_ptr(machine->device("messram"));
169   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
170170
171171   memory_configure_bank(machine, "bank1", 0, 64, machine->region("maincpu")->base(), 0x4000);
172172   memory_configure_bank(machine, "bank2", 0, 64, machine->region("maincpu")->base(), 0x4000);
r9922r9923
252252   MCFG_CARTSLOT_LOAD(prestige_cart)
253253
254254   /* internal ram */
255   MCFG_RAM_ADD("messram")
255   MCFG_RAM_ADD(RAM_TAG)
256256   MCFG_RAM_DEFAULT_SIZE("32K")
257257   MCFG_RAM_EXTRA_OPTIONS("64K")
258258MACHINE_CONFIG_END
src/mess/drivers/z88.c
r9922r9923
1717#include "cpu/z80/z80.h"
1818#include "includes/z88.h"
1919#include "sound/speaker.h"
20#include "devices/messram.h"
21#include "devices/messram.h"
20#include "machine/ram.h"
21#include "machine/ram.h"
2222
2323
2424static void blink_reset(running_machine *machine)
r9922r9923
252252      }
253253      else
254254      {
255         read_addr = write_addr = messram_get_ptr(machine->device("messram")) + (block<<14);
255         read_addr = write_addr = ram_get_ptr(machine->device(RAM_TAG)) + (block<<14);
256256      }
257257   }
258258   else
r9922r9923
289289      else
290290      {
291291         /* ram bank 20 */
292         read_addr = messram_get_ptr(machine->device("messram"));
293         write_addr = messram_get_ptr(machine->device("messram"));
292         read_addr = ram_get_ptr(machine->device(RAM_TAG));
293         write_addr = ram_get_ptr(machine->device(RAM_TAG));
294294      }
295295
296296      z88_install_memory_handler_pair(machine, 0x0000, 0x2000, 9, read_addr, write_addr);
r9922r9923
304304
305305static MACHINE_RESET( z88 )
306306{
307   memset(messram_get_ptr(machine->device("messram")), 0x0ff, messram_get_size(machine->device("messram")));
307   memset(ram_get_ptr(machine->device(RAM_TAG)), 0x0ff, ram_get_size(machine->device(RAM_TAG)));
308308
309309   blink_reset(machine);
310310
r9922r9923
773773   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
774774
775775   /* internal ram */
776   MCFG_RAM_ADD("messram")
776   MCFG_RAM_ADD(RAM_TAG)
777777   MCFG_RAM_DEFAULT_SIZE("2M")
778778MACHINE_CONFIG_END
779779
src/mess/drivers/pce220.c
r9922r9923
1212
1313#include "emu.h"
1414#include "cpu/z80/z80.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717
1818class pce220_state : public driver_device
r9922r9923
112112   UINT8 bank = BIT(data,2);
113113   memory_install_write_bank(space_prg, 0x0000, 0x3fff, 0, 0, "bank1");
114114
115   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram"))+0x0000+bank*0x8000);
116   memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram"))+0x4000+bank*0x8000);
115   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(space->machine->device(RAM_TAG))+0x0000+bank*0x8000);
116   memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG))+0x4000+bank*0x8000);
117117}
118118
119119static ADDRESS_MAP_START(pce220_mem, ADDRESS_SPACE_PROGRAM, 8)
r9922r9923
248248    MCFG_VIDEO_UPDATE(pce220)
249249
250250   /* internal ram */
251   MCFG_RAM_ADD("messram")
251   MCFG_RAM_ADD(RAM_TAG)
252252   MCFG_RAM_DEFAULT_SIZE("64K") // 32K internal + 32K external card
253253MACHINE_CONFIG_END
254254
src/mess/drivers/pcw16.c
r9922r9923
104104/* Devices */
105105#include "formats/pc_dsk.h"      /* pc disk images */
106106#include "devices/flopdrv.h"
107#include "devices/messram.h"
107#include "machine/ram.h"
108108
109109// interrupt counter
110110/* controls which bank of 2mb address space is paged into memory */
r9922r9923
408408static void pcw16_update_bank(running_machine *machine, int bank)
409409{
410410   pcw16_state *state = machine->driver_data<pcw16_state>();
411   unsigned char *mem_ptr = messram_get_ptr(machine->device("messram"));
411   unsigned char *mem_ptr = ram_get_ptr(machine->device(RAM_TAG));
412412   int bank_id = 0;
413413   int bank_offs = 0;
414414   char bank1[10];
r9922r9923
450450   {
451451      bank_offs = 128;
452452      /* dram */
453      mem_ptr = messram_get_ptr(machine->device("messram"));
453      mem_ptr = ram_get_ptr(machine->device(RAM_TAG));
454454   }
455455
456456   mem_ptr = mem_ptr + ((bank_id - bank_offs)<<14);
r9922r9923
14531453   MCFG_FLOPPY_2_DRIVES_ADD(pcw16_floppy_config)
14541454
14551455   /* internal ram */
1456   MCFG_RAM_ADD("messram")
1456   MCFG_RAM_ADD(RAM_TAG)
14571457   MCFG_RAM_DEFAULT_SIZE("2M")
14581458   MCFG_INTEL_E28F008SA_ADD("flash0")
14591459   MCFG_INTEL_E28F008SA_ADD("flash1")
src/mess/drivers/mz700.c
r9922r9923
7575#include "sound/speaker.h"
7676#include "sound/wave.h"
7777#include "devices/cassette.h"
78#include "devices/messram.h"
78#include "machine/ram.h"
7979#include "formats/mz_cas.h"
8080
8181
r9922r9923
367367   MCFG_CASSETTE_ADD( "cassette", mz700_cassette_config )
368368
369369   /* internal ram */
370   MCFG_RAM_ADD("messram")
370   MCFG_RAM_ADD(RAM_TAG)
371371   MCFG_RAM_DEFAULT_SIZE("64K")
372372MACHINE_CONFIG_END
373373
src/mess/drivers/prof80.c
r9922r9923
3333#include "video/mc6845.h"
3434#include "formats/basicdsk.h"
3535#include "devices/flopdrv.h"
36#include "devices/messram.h"
36#include "machine/ram.h"
3737#include "machine/i8255a.h"
3838#include "machine/upd765.h"
3939#include "machine/upd1990a.h"
r9922r9923
153153{
154154   prof80_state *state = machine->driver_data<prof80_state>();
155155   address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
156   UINT8 *ram = messram_get_ptr(machine->device("messram"));
156   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
157157   UINT8 *rom = machine->region(Z80_TAG)->base();
158158   int bank;
159159
r9922r9923
13051305   MCFG_FLOPPY_4_DRIVES_ADD(prof80_floppy_config)
13061306
13071307   /* internal ram */
1308   MCFG_RAM_ADD("messram")
1308   MCFG_RAM_ADD(RAM_TAG)
13091309   MCFG_RAM_DEFAULT_SIZE("128K")
13101310MACHINE_CONFIG_END
13111311
src/mess/drivers/vt240.c
r9922r9923
1212#include "emu.h"
1313#include "cpu/i8085/i8085.h"
1414#include "cpu/t11/t11.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717
1818class vt240_state : public driver_device
src/mess/drivers/prof180x.c
r9922r9923
2424
2525#include "emu.h"
2626#include "cpu/z80/z80.h"
27#include "devices/messram.h"
27#include "machine/ram.h"
2828#include "machine/ctronics.h"
2929#include "machine/upd765.h"
3030#include "includes/prof180x.h"
r9922r9923
248248   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
249249
250250   /* internal ram */
251   MCFG_RAM_ADD("messram")
251   MCFG_RAM_ADD(RAM_TAG)
252252   MCFG_RAM_DEFAULT_SIZE("128K")
253253   MCFG_RAM_EXTRA_OPTIONS("256K,512K")
254254MACHINE_CONFIG_END
src/mess/drivers/sym1.c
r9922r9923
2020/* Layout */
2121#include "sym1.lh"
2222
23#include "devices/messram.h"
23#include "machine/ram.h"
2424
2525
2626/* pointers to memory locations */
r9922r9923
138138   MCFG_VIA6522_ADD("via6522_2", 0, sym1_via2)
139139
140140   /* internal ram */
141   MCFG_RAM_ADD("messram")
141   MCFG_RAM_ADD(RAM_TAG)
142142   MCFG_RAM_DEFAULT_SIZE("4K")
143143   MCFG_RAM_EXTRA_OPTIONS("1K,2K,3K")
144144MACHINE_CONFIG_END
src/mess/drivers/aquarius.c
r9922r9923
2828#include "devices/cartslot.h"
2929#include "devices/cassette.h"
3030#include "devices/printer.h"
31#include "devices/messram.h"
31#include "machine/ram.h"
3232
3333/***************************************************************************
3434    CONSTANTS
r9922r9923
216216static DRIVER_INIT( aquarius )
217217{
218218   /* install expansion memory if available */
219   if (messram_get_size(machine->device("messram")) > 0x1000)
219   if (ram_get_size(machine->device(RAM_TAG)) > 0x1000)
220220   {
221221      address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
222222
223      memory_install_readwrite_bank(space, 0x4000, 0x4000 + messram_get_size(machine->device("messram")) - 0x1000 - 1, 0, 0, "bank1");
224      memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
223      memory_install_readwrite_bank(space, 0x4000, 0x4000 + ram_get_size(machine->device(RAM_TAG)) - 0x1000 - 1, 0, 0, "bank1");
224      memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)));
225225   }
226226}
227227
r9922r9923
435435   MCFG_CARTSLOT_NOT_MANDATORY
436436
437437   /* internal ram */
438   MCFG_RAM_ADD("messram")
438   MCFG_RAM_ADD(RAM_TAG)
439439   MCFG_RAM_DEFAULT_SIZE("4K")
440440   MCFG_RAM_EXTRA_OPTIONS("8K,20K,36K")
441441MACHINE_CONFIG_END
src/mess/drivers/cgenie.c
r9922r9923
3636#include "sound/ay8910.h"
3737#include "sound/dac.h"
3838#include "formats/cgen_cas.h"
39#include "devices/messram.h"
39#include "machine/ram.h"
4040
4141static ADDRESS_MAP_START (cgenie_mem, ADDRESS_SPACE_PROGRAM, 8)
4242   AM_RANGE(0x0000, 0x3fff) AM_ROM
r9922r9923
561561   MCFG_CARTSLOT_NOT_MANDATORY
562562
563563   /* internal ram */
564   MCFG_RAM_ADD("messram")
564   MCFG_RAM_ADD(RAM_TAG)
565565   MCFG_RAM_DEFAULT_SIZE("16K")
566566   MCFG_RAM_EXTRA_OPTIONS("32K")
567567MACHINE_CONFIG_END
src/mess/drivers/specpls3.c
r9922r9923
156156/* +3 hardware */
157157#include "machine/upd765.h"
158158#include "devices/flopdrv.h"
159#include "devices/messram.h"
159#include "machine/ram.h"
160160
161161/****************************************************************************************************/
162162/* Spectrum + 3 specific functions */
r9922r9923
212212{
213213   spectrum_state *state = machine->driver_data<spectrum_state>();
214214   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
215   UINT8 *messram = messram_get_ptr(machine->device("messram"));
215   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
216216
217217   if (state->port_7ffd_data & 8)
218218   {
r9922r9923
355355static MACHINE_RESET( spectrum_plus3 )
356356{
357357   spectrum_state *state = machine->driver_data<spectrum_state>();
358   UINT8 *messram = messram_get_ptr(machine->device("messram"));
358   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
359359   memset(messram,0,128*1024);
360360
361361   MACHINE_RESET_CALL(spectrum);
src/mess/drivers/x68k.c
r9922r9923
134134#include "devices/harddriv.h"
135135#include "machine/x68k_hdc.h"
136136#include "includes/x68k.h"
137#include "devices/messram.h"
137#include "machine/ram.h"
138138#include "machine/nvram.h"
139139#include "x68000.lh"
140140
r9922r9923
15371537//  if(offset == 0x5a/2)  // 0x5a should be 0 if no SASI HDs are present.
15381538//      return 0x0000;
15391539   if(offset == 0x08/2)
1540      return messram_get_size(space->machine->device("messram")) >> 16;  // RAM size
1540      return ram_get_size(space->machine->device(RAM_TAG)) >> 16;  // RAM size
15411541#if 0
15421542   if(offset == 0x46/2)
15431543        return 0x0024;
r9922r9923
15531553{
15541554   x68k_state *state = space->machine->driver_data<x68k_state>();
15551555   if(offset == 0x08/4)
1556      return (messram_get_size(space->machine->device("messram")) & 0xffff0000);  // RAM size
1556      return (ram_get_size(space->machine->device(RAM_TAG)) & 0xffff0000);  // RAM size
15571557#if 0
15581558   if(offset == 0x46/2)
15591559        return 0x0024;
r9922r9923
16821682      v = 0x09;
16831683
16841684   // rather hacky, but this generally works for programs that check for MIDI hardware
1685   if(messram_get_ptr(machine->device("messram"))[v] != 0x02)  // normal vector for bus errors points to 02FF0540
1685   if(ram_get_ptr(machine->device(RAM_TAG))[v] != 0x02)  // normal vector for bus errors points to 02FF0540
16861686   {
1687      int addr = (messram_get_ptr(machine->device("messram"))[0x09] << 24) | (messram_get_ptr(machine->device("messram"))[0x08] << 16) |(messram_get_ptr(machine->device("messram"))[0x0b] << 8) | messram_get_ptr(machine->device("messram"))[0x0a];
1687      int addr = (ram_get_ptr(machine->device(RAM_TAG))[0x09] << 24) | (ram_get_ptr(machine->device(RAM_TAG))[0x08] << 16) |(ram_get_ptr(machine->device(RAM_TAG))[0x0b] << 8) | ram_get_ptr(machine->device(RAM_TAG))[0x0a];
16881688      int sp = cpu_get_reg(machine->device("maincpu"), STATE_GENSP);
16891689      int pc = cpu_get_reg(machine->device("maincpu"), STATE_GENPC);
16901690      int sr = cpu_get_reg(machine->device("maincpu"), M68K_SR);
16911691      //int pda = cpu_get_reg(machine->device("maincpu"), M68K_PREF_DATA);
16921692      if(strcmp(machine->gamedrv->name,"x68030") == 0)
16931693      {  // byte order varies on the 68030
1694         addr = (messram_get_ptr(machine->device("messram"))[0x0b] << 24) | (messram_get_ptr(machine->device("messram"))[0x0a] << 16) |(messram_get_ptr(machine->device("messram"))[0x09] << 8) | messram_get_ptr(machine->device("messram"))[0x08];
1694         addr = (ram_get_ptr(machine->device(RAM_TAG))[0x0b] << 24) | (ram_get_ptr(machine->device(RAM_TAG))[0x0a] << 16) |(ram_get_ptr(machine->device(RAM_TAG))[0x09] << 8) | ram_get_ptr(machine->device(RAM_TAG))[0x08];
16951695      }
16961696      cpu_set_reg(machine->device("maincpu"), STATE_GENSP, sp - 14);
1697      messram_get_ptr(machine->device("messram"))[sp-11] = (val & 0xff000000) >> 24;
1698      messram_get_ptr(machine->device("messram"))[sp-12] = (val & 0x00ff0000) >> 16;
1699      messram_get_ptr(machine->device("messram"))[sp-9] = (val & 0x0000ff00) >> 8;
1700      messram_get_ptr(machine->device("messram"))[sp-10] = (val & 0x000000ff);  // place address onto the stack
1701      messram_get_ptr(machine->device("messram"))[sp-3] = (pc & 0xff000000) >> 24;
1702      messram_get_ptr(machine->device("messram"))[sp-4] = (pc & 0x00ff0000) >> 16;
1703      messram_get_ptr(machine->device("messram"))[sp-1] = (pc & 0x0000ff00) >> 8;
1704      messram_get_ptr(machine->device("messram"))[sp-2] = (pc & 0x000000ff);  // place PC onto the stack
1705      messram_get_ptr(machine->device("messram"))[sp-5] = (sr & 0xff00) >> 8;
1706      messram_get_ptr(machine->device("messram"))[sp-6] = (sr & 0x00ff);  // place SR onto the stack
1697      ram_get_ptr(machine->device(RAM_TAG))[sp-11] = (val & 0xff000000) >> 24;
1698      ram_get_ptr(machine->device(RAM_TAG))[sp-12] = (val & 0x00ff0000) >> 16;
1699      ram_get_ptr(machine->device(RAM_TAG))[sp-9] = (val & 0x0000ff00) >> 8;
1700      ram_get_ptr(machine->device(RAM_TAG))[sp-10] = (val & 0x000000ff);  // place address onto the stack
1701      ram_get_ptr(machine->device(RAM_TAG))[sp-3] = (pc & 0xff000000) >> 24;
1702      ram_get_ptr(machine->device(RAM_TAG))[sp-4] = (pc & 0x00ff0000) >> 16;
1703      ram_get_ptr(machine->device(RAM_TAG))[sp-1] = (pc & 0x0000ff00) >> 8;
1704      ram_get_ptr(machine->device(RAM_TAG))[sp-2] = (pc & 0x000000ff);  // place PC onto the stack
1705      ram_get_ptr(machine->device(RAM_TAG))[sp-5] = (sr & 0xff00) >> 8;
1706      ram_get_ptr(machine->device(RAM_TAG))[sp-6] = (sr & 0x00ff);  // place SR onto the stack
17071707      cpu_set_reg(machine->device("maincpu"), STATE_GENPC, addr);  // real exceptions seem to take too long to be acknowledged
17081708      popmessage("Expansion access [%08x]: PC jump to %08x", val, addr);
17091709   }
r9922r9923
24562456   UINT8* romdata = machine->region("user2")->base();
24572457   attotime irq_time;
24582458
2459   memset(messram_get_ptr(machine->device("messram")),0,messram_get_size(machine->device("messram")));
2460   memcpy(messram_get_ptr(machine->device("messram")),romdata,8);
2459   memset(ram_get_ptr(machine->device(RAM_TAG)),0,ram_get_size(machine->device(RAM_TAG)));
2460   memcpy(ram_get_ptr(machine->device(RAM_TAG)),romdata,8);
24612461
24622462   // init keyboard
24632463   state->keyboard.delay = 500;  // 3*100+200
r9922r9923
25272527   state->spriteram = (UINT16*)machine->region("user1")->base();
25282528   memory_install_read16_handler(space,0x000000,0xbffffb,0xffffffff,0,(read16_space_func)x68k_emptyram_r);
25292529   memory_install_write16_handler(space,0x000000,0xbffffb,0xffffffff,0,(write16_space_func)x68k_emptyram_w);
2530   memory_install_readwrite_bank(space,0x000000,messram_get_size(machine->device("messram"))-1,0xffffffff,0,"bank1");
2531   memory_set_bankptr(machine, "bank1",messram_get_ptr(machine->device("messram")));
2530   memory_install_readwrite_bank(space,0x000000,ram_get_size(machine->device(RAM_TAG))-1,0xffffffff,0,"bank1");
2531   memory_set_bankptr(machine, "bank1",ram_get_ptr(machine->device(RAM_TAG)));
25322532   memory_install_read16_handler(space,0xc00000,0xdfffff,0xffffffff,0,x68k_gvram_r);
25332533   memory_install_write16_handler(space,0xc00000,0xdfffff,0xffffffff,0,x68k_gvram_w);
25342534   memory_set_bankptr(machine, "bank2",state->gvram);  // so that code in VRAM is executable - needed for Terra Cresta
r9922r9923
25582558   state->spriteram = (UINT16*)machine->region("user1")->base();
25592559   memory_install_read32_handler(space,0x000000,0xbffffb,0xffffffff,0,(read32_space_func)x68k_rom0_r);
25602560   memory_install_write32_handler(space,0x000000,0xbffffb,0xffffffff,0,(write32_space_func)x68k_rom0_w);
2561   memory_install_readwrite_bank(space,0x000000,messram_get_size(machine->device("messram"))-1,0xffffffff,0,"bank1");
2561   memory_install_readwrite_bank(space,0x000000,ram_get_size(machine->device(RAM_TAG))-1,0xffffffff,0,"bank1");
25622562   // mirror? Human68k 3.02 explicitly adds 0x3000000 to some pointers
2563   memory_install_readwrite_bank(space,0x3000000,0x3000000+messram_get_size(machine->device("messram"))-1,0xffffffff,0,"bank5");
2564   memory_set_bankptr(machine, "bank1",messram_get_ptr(machine->device("messram")));
2565   memory_set_bankptr(machine, "bank5",messram_get_ptr(machine->device("messram")));
2563   memory_install_readwrite_bank(space,0x3000000,0x3000000+ram_get_size(machine->device(RAM_TAG))-1,0xffffffff,0,"bank5");
2564   memory_set_bankptr(machine, "bank1",ram_get_ptr(machine->device(RAM_TAG)));
2565   memory_set_bankptr(machine, "bank5",ram_get_ptr(machine->device(RAM_TAG)));
25662566   memory_install_read32_handler(space,0xc00000,0xdfffff,0xffffffff,0,x68k_gvram32_r);
25672567   memory_install_write32_handler(space,0xc00000,0xdfffff,0xffffffff,0,x68k_gvram32_w);
25682568   memory_set_bankptr(machine, "bank2",state->gvram);  // so that code in VRAM is executable - needed for Terra Cresta
r9922r9923
26952695   MCFG_FLOPPY_4_DRIVES_ADD(x68k_floppy_config)
26962696
26972697   /* internal ram */
2698   MCFG_RAM_ADD("messram")
2698   MCFG_RAM_ADD(RAM_TAG)
26992699   MCFG_RAM_DEFAULT_SIZE("4M")
27002700   MCFG_RAM_EXTRA_OPTIONS("1M,2M,3M,5M,6M,7M,8M,9M,10M,11M,12M")
27012701MACHINE_CONFIG_END
src/mess/drivers/ondra.c
r9922r9923
1111#include "cpu/z80/z80.h"
1212#include "sound/wave.h"
1313#include "devices/cassette.h"
14#include "devices/messram.h"
14#include "machine/ram.h"
1515#include "includes/ondra.h"
1616
1717/* Address maps */
r9922r9923
150150   MCFG_CASSETTE_ADD( "cassette", ondra_cassette_config )
151151
152152   /* internal ram */
153   MCFG_RAM_ADD("messram")
153   MCFG_RAM_ADD(RAM_TAG)
154154   MCFG_RAM_DEFAULT_SIZE("64K")
155155   MCFG_RAM_DEFAULT_VALUE(0x00)
156156MACHINE_CONFIG_END
src/mess/drivers/victor9k.c
r9922r9923
2929#include "cpu/i86/i86.h"
3030#include "cpu/mcs48/mcs48.h"
3131#include "devices/flopdrv.h"
32#include "devices/messram.h"
32#include "machine/ram.h"
3333#include "machine/ctronics.h"
3434#include "machine/6522via.h"
3535#include "machine/ieee488.h"
r9922r9923
879879
880880   /* memory banking */
881881   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
882   UINT8 *ram = messram_get_ptr(m_ram);
883   int ram_size = messram_get_size(m_ram);
882   UINT8 *ram = ram_get_ptr(m_ram);
883   int ram_size = ram_get_size(m_ram);
884884
885885   memory_install_ram(program, 0x00000, ram_size - 1, 0, 0, ram);
886886}
r9922r9923
932932   MCFG_FLOPPY_2_DRIVES_ADD(victor9k_floppy_config)
933933
934934   /* internal ram */
935   MCFG_RAM_ADD("messram")
935   MCFG_RAM_ADD(RAM_TAG)
936936   MCFG_RAM_DEFAULT_SIZE("128K")
937937   MCFG_RAM_EXTRA_OPTIONS("256K,384K,512K,640K,768K,896K")
938938MACHINE_CONFIG_END
src/mess/drivers/pc8001.c
r9922r9923
2626#include "includes/pc8001.h"
2727#include "cpu/z80/z80.h"
2828#include "devices/cassette.h"
29#include "devices/messram.h"
29#include "machine/ram.h"
3030#include "machine/i8257.h"
3131#include "machine/ctronics.h"
3232#include "machine/i8214.h"
r9922r9923
441441{
442442   pc8001_state *state = machine->driver_data<pc8001_state>();
443443   address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
444   device_t *messram = machine->device("messram");
444   device_t *messram = machine->device(RAM_TAG);
445445
446446   /* look up devices */
447447   state->i8257 = machine->device(I8257_TAG);
r9922r9923
463463   memory_install_read_bank(program, 0x0000, 0x5fff, 0, 0, "bank1");
464464   memory_unmap_write(program, 0x0000, 0x5fff, 0, 0);
465465
466   switch (messram_get_size(messram))
466   switch (ram_get_size(messram))
467467   {
468468   case 16*1024:
469      memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram), 0);
469      memory_configure_bank(machine, "bank3", 0, 1, ram_get_ptr(messram), 0);
470470      memory_unmap_readwrite(program, 0x6000, 0xbfff, 0, 0);
471471      memory_unmap_readwrite(program, 0x8000, 0xbfff, 0, 0);
472472      memory_install_readwrite_bank(program, 0xc000, 0xffff, 0, 0, "bank3");
473473      break;
474474
475475   case 32*1024:
476      memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram), 0);
476      memory_configure_bank(machine, "bank3", 0, 1, ram_get_ptr(messram), 0);
477477      memory_unmap_readwrite(program, 0x6000, 0xbfff, 0, 0);
478478      memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank3");
479479      break;
480480
481481   case 64*1024:
482      memory_configure_bank(machine, "bank1", 0, 1, messram_get_ptr(messram), 0);
483      memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(messram) + 0x6000, 0);
484      memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram) + 0x8000, 0);
482      memory_configure_bank(machine, "bank1", 0, 1, ram_get_ptr(messram), 0);
483      memory_configure_bank(machine, "bank2", 0, 1, ram_get_ptr(messram) + 0x6000, 0);
484      memory_configure_bank(machine, "bank3", 0, 1, ram_get_ptr(messram) + 0x8000, 0);
485485      memory_install_readwrite_bank(program, 0x0000, 0x5fff, 0, 0, "bank1");
486486      memory_install_readwrite_bank(program, 0x6000, 0xbfff, 0, 0, "bank2");
487487      memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank3");
r9922r9923
550550   MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
551551   MCFG_CASSETTE_ADD(CASSETTE_TAG, pc8001_cassette_config)
552552
553   MCFG_RAM_ADD("messram")
553   MCFG_RAM_ADD(RAM_TAG)
554554   MCFG_RAM_DEFAULT_SIZE("16K")
555555   MCFG_RAM_EXTRA_OPTIONS("32K,64K")
556556MACHINE_CONFIG_END
r9922r9923
562562   MCFG_CPU_IO_MAP(pc8001mk2_io)
563563   MCFG_MACHINE_START(pc8001mk2)
564564
565   MCFG_RAM_MODIFY("messram")
565   MCFG_RAM_MODIFY(RAM_TAG)
566566   MCFG_RAM_DEFAULT_SIZE("64K")
567567MACHINE_CONFIG_END
568568
src/mess/drivers/beta.c
r9922r9923
2020#include "devices/cartslot.h"
2121#include "machine/6532riot.h"
2222#include "sound/speaker.h"
23#include "devices/messram.h"
23#include "machine/ram.h"
2424#include "beta.lh"
2525
2626/* Memory Maps */
r9922r9923
282282   MCFG_CARTSLOT_UNLOAD(beta_eprom)
283283
284284   /* internal ram */
285   MCFG_RAM_ADD("messram")
285   MCFG_RAM_ADD(RAM_TAG)
286286   MCFG_RAM_DEFAULT_SIZE("256")
287287MACHINE_CONFIG_END
288288
src/mess/drivers/px4.c
r9922r9923
99
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313#include "machine/ctronics.h"
1414#include "devices/cartslot.h"
1515#include "devices/cassette.h"
1616#include "machine/tf20.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818#include "px4.lh"
1919
2020
r9922r9923
475475
476476   /* ram, part 1 */
477477   memory_install_readwrite_bank(space, 0x0000, 0xdfff - size, 0, 0, "bank1");
478   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(px4->ram));
478   memory_set_bankptr(space->machine, "bank1", ram_get_ptr(px4->ram));
479479
480480   /* actual rom data, part 1 */
481481   memory_install_read_bank(space, 0xe000 - size, 0xffff - size, 0, 0, "bank2");
r9922r9923
492492
493493   /* ram, continued */
494494   memory_install_readwrite_bank(space, 0xe000, 0xffff, 0, 0, "bank4");
495   memory_set_bankptr(space->machine, "bank4", messram_get_ptr(px4->ram) + 0xe000);
495   memory_set_bankptr(space->machine, "bank4", ram_get_ptr(px4->ram) + 0xe000);
496496}
497497
498498/* bank register */
r9922r9923
515515      memory_nop_write(space_program, 0x0000, 0x7fff, 0, 0);
516516      memory_set_bankptr(space->machine, "bank1", space->machine->region("os")->base());
517517      memory_install_readwrite_bank(space_program, 0x8000, 0xffff, 0, 0, "bank2");
518      memory_set_bankptr(space->machine, "bank2", messram_get_ptr(px4->ram) + 0x8000);
518      memory_set_bankptr(space->machine, "bank2", ram_get_ptr(px4->ram) + 0x8000);
519519      break;
520520
521521   case 0x04:
522522      /* memory */
523523      memory_install_readwrite_bank(space_program, 0x0000, 0xffff, 0, 0, "bank1");
524      memory_set_bankptr(space->machine, "bank1", messram_get_ptr(px4->ram));
524      memory_set_bankptr(space->machine, "bank1", ram_get_ptr(px4->ram));
525525      break;
526526
527527   case 0x08: install_rom_capsule(space_program, 0x2000, "capsule1"); break;
r9922r9923
10361036      int y, x;
10371037
10381038      /* get vram start address */
1039      UINT8 *vram = &messram_get_ptr(px4->ram)[(px4->vadr & 0xf8) << 8];
1039      UINT8 *vram = &ram_get_ptr(px4->ram)[(px4->vadr & 0xf8) << 8];
10401040
10411041      for (y = 0; y < 64; y++)
10421042      {
r9922r9923
10801080   px4_state *px4 = machine->driver_data<px4_state>();
10811081
10821082   /* find devices */
1083   px4->ram = machine->device("messram");
1083   px4->ram = machine->device(RAM_TAG);
10841084
10851085   /* init 7508 */
10861086   px4->one_sec_int_enabled = TRUE;
r9922r9923
11051105
11061106   /* map os rom and last half of memory */
11071107   memory_set_bankptr(machine, "bank1", machine->region("os")->base());
1108   memory_set_bankptr(machine, "bank2", messram_get_ptr(px4->ram) + 0x8000);
1108   memory_set_bankptr(machine, "bank2", ram_get_ptr(px4->ram) + 0x8000);
11091109}
11101110
11111111static DRIVER_INIT( px4p )
r9922r9923
13821382   MCFG_TIMER_ADD_PERIODIC("frc", frc_tick, HZ(XTAL_7_3728MHz / 2 / 6))
13831383
13841384   /* internal ram */
1385   MCFG_RAM_ADD("messram")
1385   MCFG_RAM_ADD(RAM_TAG)
13861386   MCFG_RAM_DEFAULT_SIZE("64k")
13871387
13881388   /* centronics printer */
src/mess/drivers/lviv.c
r9922r9923
289289#include "devices/snapquik.h"
290290#include "devices/cassette.h"
291291#include "formats/lviv_lvt.h"
292#include "devices/messram.h"
292#include "machine/ram.h"
293293
294294/* I/O ports */
295295
r9922r9923
465465   MCFG_CASSETTE_ADD( "cassette", lviv_cassette_config )
466466
467467   /* internal ram */
468   MCFG_RAM_ADD("messram")
468   MCFG_RAM_ADD(RAM_TAG)
469469   MCFG_RAM_DEFAULT_SIZE("64K")
470470MACHINE_CONFIG_END
471471
src/mess/drivers/poly880.c
r9922r9923
1515#include "devices/cassette.h"
1616#include "machine/z80pio.h"
1717#include "machine/z80ctc.h"
18#include "devices/messram.h"
18#include "machine/ram.h"
1919#include "poly880.lh"
2020
2121/*
r9922r9923
305305   MCFG_CASSETTE_ADD(CASSETTE_TAG, poly880_cassette_config)
306306
307307   /* internal ram */
308   MCFG_RAM_ADD("messram")
308   MCFG_RAM_ADD(RAM_TAG)
309309   MCFG_RAM_DEFAULT_SIZE("1K")
310310MACHINE_CONFIG_END
311311
src/mess/drivers/timex.c
r9922r9923
156156#include "formats/spec_snqk.h"
157157#include "formats/timex_dck.h"
158158#include "machine/beta.h"
159#include "devices/messram.h"
159#include "machine/ram.h"
160160
161161static const ay8910_interface spectrum_ay_interface =
162162{
r9922r9923
227227void ts2068_update_memory(running_machine *machine)
228228{
229229   spectrum_state *state = machine->driver_data<spectrum_state>();
230   UINT8 *messram = messram_get_ptr(machine->device("messram"));
230   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
231231   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
232232   unsigned char *ChosenROM, *ExROM, *DOCK;
233233
r9922r9923
599599static MACHINE_RESET( tc2048 )
600600{
601601   spectrum_state *state = machine->driver_data<spectrum_state>();
602   UINT8 *messram = messram_get_ptr(machine->device("messram"));
602   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
603603
604604   memory_set_bankptr(machine, "bank1", messram);
605605   memory_set_bankptr(machine, "bank2", messram);
r9922r9923
658658   MCFG_CARTSLOT_UNLOAD(timex_cart)
659659
660660   /* internal ram */
661   MCFG_RAM_MODIFY("messram")
661   MCFG_RAM_MODIFY(RAM_TAG)
662662   MCFG_RAM_DEFAULT_SIZE("48K")
663663MACHINE_CONFIG_END
664664
r9922r9923
688688   MCFG_VIDEO_UPDATE( tc2048 )
689689
690690   /* internal ram */
691   MCFG_RAM_MODIFY("messram")
691   MCFG_RAM_MODIFY(RAM_TAG)
692692   MCFG_RAM_DEFAULT_SIZE("48K")
693693MACHINE_CONFIG_END
694694
src/mess/drivers/bw2.c
r9922r9923
3232#include "emu.h"
3333#include "cpu/z80/z80.h"
3434#include "devices/flopdrv.h"
35#include "devices/messram.h"
35#include "machine/ram.h"
3636#include "formats/basicdsk.h"
3737#include "machine/serial.h"
3838#include "machine/i8255a.h"
r9922r9923
7171
7272   m_bank = data & 0x07;
7373
74   switch (messram_get_size(m_ram))
74   switch (ram_get_size(m_ram))
7575   {
7676   case 64 * 1024:
7777      max_ram_bank = BANK_RAM1;
r9922r9923
153153
154154   m_bank = data & 0x07;
155155
156   switch (messram_get_size(m_ram))
156   switch (ram_get_size(m_ram))
157157   {
158158   case 64 * 1024:
159159   case 96 * 1024:
r9922r9923
734734void bw2_state::machine_start()
735735{
736736   /* allocate memory */
737   m_work_ram = auto_alloc_array(machine, UINT8, messram_get_size(m_ram));
737   m_work_ram = auto_alloc_array(machine, UINT8, ram_get_size(m_ram));
738738   m_video_ram = auto_alloc_array(machine, UINT8, BW2_VIDEORAM_SIZE);
739739   m_ramcard_ram = auto_alloc_array(machine, UINT8, BW2_RAMCARD_SIZE);
740740
r9922r9923
745745
746746   /* register for state saving */
747747   state_save_register_global(machine, m_kb_row);
748   state_save_register_global_pointer(machine, m_work_ram, messram_get_size(m_ram));
748   state_save_register_global_pointer(machine, m_work_ram, ram_get_size(m_ram));
749749   state_save_register_global_pointer(machine, m_ramcard_ram, BW2_RAMCARD_SIZE);
750750   state_save_register_global(machine, m_bank);
751751   state_save_register_global(machine, m_drive);
r9922r9923
818818   MCFG_SOFTWARE_LIST_ADD("flop_list","bw2")
819819
820820   /* internal ram */
821   MCFG_RAM_ADD("messram")
821   MCFG_RAM_ADD(RAM_TAG)
822822   MCFG_RAM_DEFAULT_SIZE("64K")
823823   MCFG_RAM_EXTRA_OPTIONS("96K,128K,160K,192K,224K")
824824
src/mess/drivers/enterp.c
r9922r9923
2121#include "machine/wd17xx.h"
2222#include "devices/flopdrv.h"
2323#include "formats/basicdsk.h"
24#include "devices/messram.h"
24#include "machine/ram.h"
2525#include "includes/enterp.h"
2626
2727#define ENTERPRISE_XTAL_X1   XTAL_8MHz
r9922r9923
7070   case 0xfa:
7171   case 0xfb:
7272      /* additional 64k ram */
73      if (messram_get_size(space->machine->device("messram")) == 128*1024)
73      if (ram_get_size(space->machine->device(RAM_TAG)) == 128*1024)
7474      {
7575         memory_install_readwrite_bank(space, start, end, 0, 0, page_num);
76         memory_set_bankptr(space->machine, page_num, messram_get_ptr(space->machine->device("messram")) + (index - 0xf4) * 0x4000);
76         memory_set_bankptr(space->machine, page_num, ram_get_ptr(space->machine->device(RAM_TAG)) + (index - 0xf4) * 0x4000);
7777      }
7878      else
7979      {
r9922r9923
8787   case 0xff:
8888      /* basic 64k ram */
8989      memory_install_readwrite_bank(space, start, end, 0, 0, page_num);
90      memory_set_bankptr(space->machine, page_num, messram_get_ptr(space->machine->device("messram")) + (index - 0xfc) * 0x4000);
90      memory_set_bankptr(space->machine, page_num, ram_get_ptr(space->machine->device(RAM_TAG)) + (index - 0xfc) * 0x4000);
9191      break;
9292
9393   default:
r9922r9923
476476   MCFG_FLOPPY_4_DRIVES_ADD(enterprise_floppy_config)
477477
478478   /* internal ram */
479   MCFG_RAM_ADD("messram")
479   MCFG_RAM_ADD(RAM_TAG)
480480   MCFG_RAM_DEFAULT_SIZE("64K")
481481MACHINE_CONFIG_END
482482
483483static MACHINE_CONFIG_DERIVED( ep128, ep64 )
484484   /* internal ram */
485   MCFG_RAM_MODIFY("messram")
485   MCFG_RAM_MODIFY(RAM_TAG)
486486   MCFG_RAM_DEFAULT_SIZE("128K")
487487MACHINE_CONFIG_END
488488
src/mess/drivers/portfoli.c
r9922r9923
8181#include "includes/portfoli.h"
8282#include "cpu/i86/i86.h"
8383#include "devices/cartslot.h"
84#include "devices/messram.h"
84#include "machine/ram.h"
8585#include "devices/printer.h"
8686#include "machine/ctronics.h"
8787#include "machine/i8255a.h"
r9922r9923
783783   cpu_set_irq_callback(m_maincpu, portfolio_int_ack);
784784
785785   /* memory expansions */
786   switch (messram_get_size(machine->device("messram")))
786   switch (ram_get_size(machine->device(RAM_TAG)))
787787   {
788788   case 128 * 1024:
789789      memory_unmap_readwrite(program, 0x1f000, 0x9efff, 0, 0);
r9922r9923
901901//   MCFG_SOFTWARE_LIST_ADD("cart_list", "pofo")
902902
903903   /* internal ram */
904   MCFG_RAM_ADD("messram")
904   MCFG_RAM_ADD(RAM_TAG)
905905   MCFG_RAM_DEFAULT_SIZE("128K")
906906   MCFG_RAM_EXTRA_OPTIONS("384K,640K")
907907
src/mess/drivers/mc10.c
r9922r9923
1515#include "video/ef9345.h"
1616#include "devices/cassette.h"
1717#include "formats/coco_cas.h"
18#include "devices/messram.h"
18#include "machine/ram.h"
1919
2020
2121/***************************************************************************
r9922r9923
205205   mc10->cassette = machine->device("cassette");
206206
207207   /* initialize memory */
208   mc10->ram = messram_get_ptr(machine->device("messram"));
209   mc10->ram_size = messram_get_size(machine->device("messram"));
208   mc10->ram = ram_get_ptr(machine->device(RAM_TAG));
209   mc10->ram_size = ram_get_size(machine->device(RAM_TAG));
210210
211211   memory_set_bankptr(machine, "bank1", mc10->ram);
212212
r9922r9923
234234   mc10->cassette = machine->device("cassette");
235235
236236   /* initialize memory */
237   mc10->ram = messram_get_ptr(machine->device("messram"));
238   mc10->ram_size = messram_get_size(machine->device("messram"));
237   mc10->ram = ram_get_ptr(machine->device(RAM_TAG));
238   mc10->ram_size = ram_get_size(machine->device(RAM_TAG));
239239
240240   memory_set_bankptr(machine, "bank1", mc10->ram);
241241
r9922r9923
510510   MCFG_CASSETTE_ADD("cassette", mc10_cassette_config)
511511
512512   /* internal ram */
513   MCFG_RAM_ADD("messram")
513   MCFG_RAM_ADD(RAM_TAG)
514514   MCFG_RAM_DEFAULT_SIZE("20K")
515515   MCFG_RAM_EXTRA_OPTIONS("4K")
516516MACHINE_CONFIG_END
r9922r9923
547547   MCFG_CASSETTE_ADD("cassette", mc10_cassette_config)
548548
549549   /* internal ram */
550   MCFG_RAM_ADD("messram")
550   MCFG_RAM_ADD(RAM_TAG)
551551   MCFG_RAM_DEFAULT_SIZE("24K")
552552   MCFG_RAM_EXTRA_OPTIONS("8K")
553553MACHINE_CONFIG_END
src/mess/drivers/atom.c
r9922r9923
113113#include "devices/cartslot.h"
114114#include "devices/cassette.h"
115115#include "devices/flopdrv.h"
116#include "devices/messram.h"
116#include "machine/ram.h"
117117#include "devices/snapquik.h"
118118#include "formats/atom_atm.h"
119119#include "formats/atom_tap.h"
r9922r9923
867867   MCFG_ATOM_CARTSLOT_ADD("cart")
868868
869869   /* internal ram */
870   MCFG_RAM_ADD("messram")
870   MCFG_RAM_ADD(RAM_TAG)
871871   MCFG_RAM_DEFAULT_SIZE("2K")
872872   MCFG_RAM_EXTRA_OPTIONS("4K,6K,8K,10K,12K")
873873
src/mess/drivers/apricot.c
r9922r9923
1616#include "machine/wd17xx.h"
1717#include "sound/sn76496.h"
1818#include "video/mc6845.h"
19#include "devices/messram.h"
19#include "machine/ram.h"
2020#include "devices/flopdrv.h"
2121#include "formats/apridisk.h"
2222
r9922r9923
176176static MC6845_UPDATE_ROW( apricot_update_row )
177177{
178178   apricot_state *apricot = device->machine->driver_data<apricot_state>();
179   UINT8 *ram = messram_get_ptr(device->machine->device("messram"));
179   UINT8 *ram = ram_get_ptr(device->machine->device(RAM_TAG));
180180   int i, x;
181181
182182   if (apricot->video_mode)
r9922r9923
239239   device_t *maincpu = machine->device("maincpu");
240240   address_space *prg = cpu_get_address_space(maincpu, ADDRESS_SPACE_PROGRAM);
241241
242   UINT8 *ram = messram_get_ptr(machine->device("messram"));
243   UINT32 ram_size = messram_get_size(machine->device("messram"));
242   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
243   UINT32 ram_size = ram_get_size(machine->device(RAM_TAG));
244244
245245   memory_unmap_readwrite(prg, 0x40000, 0xeffff, 0, 0);
246246   memory_install_ram(prg, 0x00000, ram_size - 1, 0, 0, ram);
r9922r9923
359359   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
360360
361361   /* internal ram */
362   MCFG_RAM_ADD("messram")
362   MCFG_RAM_ADD(RAM_TAG)
363363   MCFG_RAM_DEFAULT_SIZE("256k")
364364   MCFG_RAM_EXTRA_OPTIONS("384k,512k") /* with 1 or 2 128k expansion boards */
365365
src/mess/drivers/lc80.c
r9922r9923
2626#include "machine/z80pio.h"
2727#include "machine/z80ctc.h"
2828#include "sound/speaker.h"
29#include "devices/messram.h"
29#include "machine/ram.h"
3030#include "lc80.lh"
3131
3232/* Memory Maps */
r9922r9923
319319   memory_install_readwrite_bank(program, 0x0800, 0x0fff, 0, 0, "bank2");
320320   memory_install_readwrite_bank(program, 0x1000, 0x17ff, 0, 0, "bank3");
321321
322   switch (messram_get_size(machine->device("messram")))
322   switch (ram_get_size(machine->device(RAM_TAG)))
323323   {
324324   case 1*1024:
325325      memory_install_readwrite_bank(program, 0x2000, 0x23ff, 0, 0, "bank4");
r9922r9923
380380
381381   MCFG_CASSETTE_ADD(CASSETTE_TAG, lc80_cassette_config)
382382
383   MCFG_RAM_ADD("messram")
383   MCFG_RAM_ADD(RAM_TAG)
384384   MCFG_RAM_DEFAULT_SIZE("1K")
385385   MCFG_RAM_EXTRA_OPTIONS("2K,3K,4K")
386386MACHINE_CONFIG_END
r9922r9923
410410   MCFG_CASSETTE_ADD(CASSETTE_TAG, lc80_cassette_config)
411411
412412   /* internal ram */
413   MCFG_RAM_ADD("messram")
413   MCFG_RAM_ADD(RAM_TAG)
414414   MCFG_RAM_DEFAULT_SIZE("4K")
415415MACHINE_CONFIG_END
416416
src/mess/drivers/rx78.c
r9922r9923
4646#include "devices/cartslot.h"
4747#include "devices/cassette.h"
4848#include "sound/wave.h"
49#include "devices/messram.h"
49#include "machine/ram.h"
5050
5151
5252class rx78_state : public driver_device
r9922r9923
479479   MCFG_CARTSLOT_LOAD(rx78_cart)
480480   MCFG_CARTSLOT_INTERFACE("rx78_cart")
481481
482   MCFG_RAM_ADD("messram")
482   MCFG_RAM_ADD(RAM_TAG)
483483   MCFG_RAM_DEFAULT_SIZE("32k")
484484   MCFG_RAM_EXTRA_OPTIONS("16k")
485485
r9922r9923
510510
511511static DRIVER_INIT( rx78 )
512512{
513   UINT32 ram_size = messram_get_size(machine->device("messram"));
513   UINT32 ram_size = ram_get_size(machine->device(RAM_TAG));
514514   address_space *prg = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
515515
516516   if(ram_size == 0x4000)
src/mess/drivers/partner.c
r9922r9923
1919#include "formats/basicdsk.h"
2020#include "formats/rk_cas.h"
2121#include "includes/radio86.h"
22#include "devices/messram.h"
22#include "machine/ram.h"
2323#include "includes/partner.h"
2424
2525/* Address maps */
r9922r9923
224224   MCFG_FLOPPY_2_DRIVES_ADD(partner_floppy_config)
225225
226226   /* internal ram */
227   MCFG_RAM_ADD("messram")
227   MCFG_RAM_ADD(RAM_TAG)
228228   MCFG_RAM_DEFAULT_SIZE("64K")
229229   MCFG_RAM_DEFAULT_VALUE(0x00)
230230MACHINE_CONFIG_END
src/mess/drivers/apple1.c
r9922r9923
7373#include "includes/apple1.h"
7474#include "devices/snapquik.h"
7575#include "devices/cassette.h"
76#include "devices/messram.h"
76#include "machine/ram.h"
7777
7878/* port i/o functions */
7979
r9922r9923
259259       the RAM amounts listed here will be 4K below the actual RAM
260260       total. */
261261   /* internal ram */
262   MCFG_RAM_ADD("messram")
262   MCFG_RAM_ADD(RAM_TAG)
263263   MCFG_RAM_DEFAULT_SIZE("48K")
264264   MCFG_RAM_EXTRA_OPTIONS("4K,8K,12K,16K,20K,24K,28K,32K,36K,40K,44K")
265265
src/mess/drivers/c80.c
r9922r9923
1212#include "cpu/z80/z80daisy.h"
1313#include "machine/z80pio.h"
1414#include "devices/cassette.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616#include "c80.lh"
1717
1818/* Memory Maps */
r9922r9923
267267   MCFG_CASSETTE_ADD(CASSETTE_TAG, c80_cassette_config)
268268
269269   /* internal ram */
270   MCFG_RAM_ADD("messram")
270   MCFG_RAM_ADD(RAM_TAG)
271271   MCFG_RAM_DEFAULT_SIZE("1K")
272272MACHINE_CONFIG_END
273273
src/mess/drivers/tmc2000e.c
r9922r9923
3838#include "devices/cassette.h"
3939#include "sound/cdp1864.h"
4040#include "machine/rescap.h"
41#include "devices/messram.h"
41#include "machine/ram.h"
4242
4343/* Read/Write Handlers */
4444
r9922r9923
317317   MCFG_FLOPPY_2_DRIVES_ADD(tmc2000e_floppy_config)
318318
319319   /* internal ram */
320   MCFG_RAM_ADD("messram")
320   MCFG_RAM_ADD(RAM_TAG)
321321   MCFG_RAM_DEFAULT_SIZE("8K")
322322   MCFG_RAM_EXTRA_OPTIONS("40K")
323323MACHINE_CONFIG_END
src/mess/drivers/bebox.c
r9922r9923
3535#include "devices/chd_cd.h"
3636#include "devices/harddriv.h"
3737#include "formats/pc_dsk.h"
38#include "devices/messram.h"
38#include "machine/ram.h"
3939
4040static READ8_HANDLER(at_dma8237_1_r)  { return i8237_r(space->machine->device("dma8237_2"), offset / 2); }
4141static WRITE8_HANDLER(at_dma8237_1_w) { i8237_w(space->machine->device("dma8237_2"), offset / 2, data); }
r9922r9923
174174   MCFG_MC146818_ADD( "rtc", MC146818_STANDARD )
175175   
176176   /* internal ram */
177   MCFG_RAM_ADD("messram")
177   MCFG_RAM_ADD(RAM_TAG)
178178   MCFG_RAM_DEFAULT_SIZE("32M")
179179   MCFG_RAM_EXTRA_OPTIONS("8M,16M")
180180MACHINE_CONFIG_END
src/mess/drivers/tek405x.c
r9922r9923
2626
2727#include "emu.h"
2828#include "cpu/m6800/m6800.h"
29#include "devices/messram.h"
29#include "machine/ram.h"
3030#include "machine/6821pia.h"
3131#include "machine/6850acia.h"
3232#include "machine/ieee488.h"
r9922r9923
11681168   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
11691169
11701170   // configure RAM
1171   switch (messram_get_size(m_ram))
1171   switch (ram_get_size(m_ram))
11721172   {
11731173   case 8*1024:
11741174      memory_unmap_readwrite(program, 0x2000, 0x7fff, 0, 0);
r9922r9923
12411241   //MCFG_RS232_ADD(RS232_TAG, rs232_intf)
12421242
12431243   // internal ram
1244   MCFG_RAM_ADD("messram")
1244   MCFG_RAM_ADD(RAM_TAG)
12451245   MCFG_RAM_DEFAULT_SIZE("8K")
12461246   MCFG_RAM_EXTRA_OPTIONS("16K,24K,32K")
12471247MACHINE_CONFIG_END
r9922r9923
12741274   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
12751275
12761276   // internal ram
1277   MCFG_RAM_ADD("messram")
1277   MCFG_RAM_ADD(RAM_TAG)
12781278   MCFG_RAM_DEFAULT_SIZE("32K")
12791279   MCFG_RAM_EXTRA_OPTIONS("64K")
12801280MACHINE_CONFIG_END
src/mess/drivers/mtx.c
r9922r9923
2626#include "cpu/z80/z80.h"
2727#include "cpu/z80/z80daisy.h"
2828#include "devices/cassette.h"
29#include "devices/messram.h"
29#include "machine/ram.h"
3030#include "devices/snapquik.h"
3131#include "machine/ctronics.h"
3232#include "machine/z80ctc.h"
r9922r9923
358358   MCFG_TIMER_ADD_PERIODIC("cassette_timer", cassette_tick, HZ(44100))
359359
360360   /* internal ram */
361   MCFG_RAM_ADD("messram")
361   MCFG_RAM_ADD(RAM_TAG)
362362   MCFG_RAM_DEFAULT_SIZE("64K")
363363   MCFG_RAM_EXTRA_OPTIONS("96K,128K,160K,192K,224K,256K,288K,320K,352K,384K,416K,448K,480K,512K")
364364MACHINE_CONFIG_END
r9922r9923
370370static MACHINE_CONFIG_DERIVED( mtx500, mtx512 )
371371
372372   /* internal ram */
373   MCFG_RAM_MODIFY("messram")
373   MCFG_RAM_MODIFY(RAM_TAG)
374374   MCFG_RAM_DEFAULT_SIZE("32K")
375375   MCFG_RAM_EXTRA_OPTIONS("64K,96K,128K,160K,192K,224K,256K,288K,320K,352K,384K,416K,448K,480K,512K")
376376MACHINE_CONFIG_END
r9922r9923
390390   MCFG_Z80DART_ADD(Z80DART_TAG, XTAL_4MHz, dart_intf)
391391
392392   /* internal ram */
393   MCFG_RAM_MODIFY("messram")
393   MCFG_RAM_MODIFY(RAM_TAG)
394394   MCFG_RAM_DEFAULT_SIZE("128K")
395395   MCFG_RAM_EXTRA_OPTIONS("160K,192K,224K,256K,288K,320K,352K,384K,416K,448K,480K,512K")
396396MACHINE_CONFIG_END
src/mess/drivers/vg5k.c
r9922r9923
4141
4242#include "emu.h"
4343#include "cpu/z80/z80.h"
44#include "devices/messram.h"
44#include "machine/ram.h"
4545#include "devices/printer.h"
4646#include "video/ef9345.h"
4747#include "sound/dac.h"
r9922r9923
362362
363363   /* install expansion memory*/
364364   address_space *program = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
365   UINT8 *ram = messram_get_ptr(machine->device("messram"));
366   UINT16 ram_size = messram_get_size(machine->device("messram"));
365   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
366   UINT16 ram_size = ram_get_size(machine->device(RAM_TAG));
367367
368368   if (ram_size > 0x4000)
369369      memory_install_ram(program, 0x8000, 0x3fff + ram_size, 0, 0, ram);
r9922r9923
434434   MCFG_PRINTER_ADD("printer")
435435
436436   /* internal ram */
437   MCFG_RAM_ADD("messram")
437   MCFG_RAM_ADD(RAM_TAG)
438438   MCFG_RAM_DEFAULT_SIZE("16K")
439439   MCFG_RAM_EXTRA_OPTIONS("32K,48k")
440440MACHINE_CONFIG_END
src/mess/drivers/elwro800.c
r9922r9923
2828#include "devices/flopdrv.h"
2929#include "devices/cassette.h"
3030#include "formats/tzx_cas.h"
31#include "devices/messram.h"
31#include "machine/ram.h"
3232
3333
3434class elwro800_state : public spectrum_state
r9922r9923
103103static void elwro800jr_mmu_w(running_machine *machine, UINT8 data)
104104{
105105   UINT8 *prom = machine->region("proms")->base() + 0x200;
106   UINT8 *messram = messram_get_ptr(machine->device("messram"));
106   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
107107   UINT8 cs;
108108   UINT8 ls175;
109109   elwro800_state *state = machine->driver_data<elwro800_state>();
r9922r9923
508508static MACHINE_RESET(elwro800)
509509{
510510   elwro800_state *state = machine->driver_data<elwro800_state>();
511   UINT8 *messram = messram_get_ptr(machine->device("messram"));
511   UINT8 *messram = ram_get_ptr(machine->device(RAM_TAG));
512512
513513   state->df_on_databus = 0xdf;
514514   memset(messram, 0, 64*1024);
r9922r9923
613613   MCFG_FLOPPY_2_DRIVES_ADD(elwro800jr_floppy_config)
614614
615615   /* internal ram */
616   MCFG_RAM_ADD("messram")
616   MCFG_RAM_ADD(RAM_TAG)
617617   MCFG_RAM_DEFAULT_SIZE("64K")
618618MACHINE_CONFIG_END
619619
src/mess/drivers/special.c
r9922r9923
2222#include "formats/rk_cas.h"
2323#include "formats/smx_dsk.h"
2424#include "machine/wd17xx.h"
25#include "devices/messram.h"
25#include "machine/ram.h"
2626
2727/* Address maps */
2828static ADDRESS_MAP_START(specialist_mem, ADDRESS_SPACE_PROGRAM, 8)
r9922r9923
481481   MCFG_FLOPPY_2_DRIVES_ADD(specimx_floppy_config)
482482
483483   /* internal ram */
484   MCFG_RAM_ADD("messram")
484   MCFG_RAM_ADD(RAM_TAG)
485485   MCFG_RAM_DEFAULT_SIZE("128K")
486486   MCFG_RAM_DEFAULT_VALUE(0x00)
487487MACHINE_CONFIG_END
r9922r9923
522522   MCFG_FLOPPY_2_DRIVES_ADD(specimx_floppy_config)
523523
524524   /* internal ram */
525   MCFG_RAM_ADD("messram")
525   MCFG_RAM_ADD(RAM_TAG)
526526   MCFG_RAM_DEFAULT_SIZE("192K")
527527   MCFG_RAM_DEFAULT_VALUE(0x00)
528528MACHINE_CONFIG_END
src/mess/drivers/pyl601.c
r9922r9923
1212#include "devices/flopdrv.h"
1313#include "formats/basicdsk.h"
1414#include "machine/upd765.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717
1818class pyl601_state : public driver_device
r9922r9923
5050   }
5151   else
5252   {
53      memory_set_bankptr(space->machine, "bank2", messram_get_ptr(space->machine->device("messram")) + 0xc000);
53      memory_set_bankptr(space->machine, "bank2", ram_get_ptr(space->machine->device(RAM_TAG)) + 0xc000);
5454   }
5555}
5656
r9922r9923
7676static WRITE8_HANDLER (vdisk_data_w)
7777{
7878   pyl601_state *state = space->machine->driver_data<pyl601_state>();
79   messram_get_ptr(space->machine->device("messram"))[0x10000 + (state->vdisk_addr & 0x7ffff)] = data;
79   ram_get_ptr(space->machine->device(RAM_TAG))[0x10000 + (state->vdisk_addr & 0x7ffff)] = data;
8080   state->vdisk_addr++;
8181   state->vdisk_addr&=0x7ffff;
8282}
r9922r9923
8484static READ8_HANDLER (vdisk_data_r)
8585{
8686   pyl601_state *state = space->machine->driver_data<pyl601_state>();
87   UINT8 retVal = messram_get_ptr(space->machine->device("messram"))[0x10000 + (state->vdisk_addr & 0x7ffff)];
87   UINT8 retVal = ram_get_ptr(space->machine->device(RAM_TAG))[0x10000 + (state->vdisk_addr & 0x7ffff)];
8888   state->vdisk_addr++;
8989   state->vdisk_addr &= 0x7ffff;
9090   return retVal;
r9922r9923
344344{
345345   pyl601_state *state = machine->driver_data<pyl601_state>();
346346   state->key_code = 0xff;
347   memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
348   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0xc000);
349   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xe000);
350   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xe700);
347   memory_set_bankptr(machine, "bank1", ram_get_ptr(machine->device(RAM_TAG)) + 0x0000);
348   memory_set_bankptr(machine, "bank2", ram_get_ptr(machine->device(RAM_TAG)) + 0xc000);
349   memory_set_bankptr(machine, "bank3", ram_get_ptr(machine->device(RAM_TAG)) + 0xe000);
350   memory_set_bankptr(machine, "bank4", ram_get_ptr(machine->device(RAM_TAG)) + 0xe700);
351351   memory_set_bankptr(machine, "bank5", machine->region("maincpu")->base() + 0xf000);
352   memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0xf000);
352   memory_set_bankptr(machine, "bank6", ram_get_ptr(machine->device(RAM_TAG)) + 0xf000);
353353
354354   machine->device("maincpu")->reset();
355355}
r9922r9923
376376   {
377377      for (column = 0; column < x_count; column++)
378378      {
379         UINT8 code = messram_get_ptr(device->machine->device("messram"))[(((ma + column) & 0x0fff) + 0xf000)];
379         UINT8 code = ram_get_ptr(device->machine->device(RAM_TAG))[(((ma + column) & 0x0fff) + 0xf000)];
380380         code = ((code << 1) | (code >> 7)) & 0xff;
381381         if (column == cursor_x-2)
382382         {
r9922r9923
401401   {
402402      for (i = 0; i < x_count; i++)
403403      {
404         data = messram_get_ptr(device->machine->device("messram"))[(((ma + i) << 3) | (ra & 0x07)) & 0xffff];
404         data = ram_get_ptr(device->machine->device(RAM_TAG))[(((ma + i) << 3) | (ra & 0x07)) & 0xffff];
405405         for (bit = 0; bit < 8; bit++)
406406         {
407407            *BITMAP_ADDR16(bitmap, y, (i * 8) + bit) = BIT(data, 7) ? 1 : 0;
r9922r9923
422422   {
423423      for (column = 0; column < x_count; column++)
424424      {
425         UINT8 code = messram_get_ptr(device->machine->device("messram"))[(((ma + column) & 0x0fff) + 0xf000)];
425         UINT8 code = ram_get_ptr(device->machine->device(RAM_TAG))[(((ma + column) & 0x0fff) + 0xf000)];
426426         data = charrom[((code << 4) | (ra & 0x07)) & 0xfff];
427427         if (column == cursor_x)
428428         {
r9922r9923
444444   {
445445      for (i = 0; i < x_count; i++)
446446      {
447         data = messram_get_ptr(device->machine->device("messram"))[(((ma + i) << 3) | (ra & 0x07)) & 0xffff];
447         data = ram_get_ptr(device->machine->device(RAM_TAG))[(((ma + i) << 3) | (ra & 0x07)) & 0xffff];
448448         for (bit = 0; bit < 8; bit++)
449449         {
450450            *BITMAP_ADDR16(bitmap, y, (i * 8) + bit) = BIT(data, 7) ? 1 : 0;
r9922r9923
485485
486486static DRIVER_INIT(pyl601)
487487{
488   memset(messram_get_ptr(machine->device("messram")), 0, 64 * 1024);
488   memset(ram_get_ptr(machine->device(RAM_TAG)), 0, 64 * 1024);
489489}
490490
491491static INTERRUPT_GEN( pyl601_interrupt )
r9922r9923
580580   MCFG_FLOPPY_2_DRIVES_ADD(pyldin_floppy_config)
581581
582582   /* internal ram */
583   MCFG_RAM_ADD("messram")
583   MCFG_RAM_ADD(RAM_TAG)
584584   MCFG_RAM_DEFAULT_SIZE("576K") // 64 + 512
585585MACHINE_CONFIG_END
586586
src/mess/drivers/rmnimbus.c
r9922r9923
1313#include "cpu/mcs51/mcs51.h"
1414#include "devices/flopdrv.h"
1515#include "devices/harddriv.h"
16#include "devices/messram.h"
16#include "machine/ram.h"
1717#include "formats/flopimg.h"
1818#include "formats/pc_dsk.h"
1919#include "includes/rmnimbus.h"
r9922r9923
330330    MCFG_HARDDISK_ADD(HARDDISK3_TAG)
331331    MCFG_SCSIBUS_ADD(SCSIBUS_TAG, scsibus_config)
332332
333    MCFG_RAM_ADD("messram")
333    MCFG_RAM_ADD(RAM_TAG)
334334   MCFG_RAM_DEFAULT_SIZE("1536K")
335335   MCFG_RAM_EXTRA_OPTIONS("128K,256K,384K,512K,640K,1024K")
336336
src/mess/drivers/a310.c
r9922r9923
6262#include "sound/dac.h"
6363#include "includes/archimds.h"
6464#include "machine/i2cmem.h"
65#include "devices/messram.h"
65#include "machine/ram.h"
6666
6767
6868class a310_state : public driver_device
r9922r9923
103103
104104static DRIVER_INIT(a310)
105105{
106   UINT32 ram_size = messram_get_size(machine->device("messram"));
106   UINT32 ram_size = ram_get_size(machine->device(RAM_TAG));
107107
108108   archimedes_memc_physmem = auto_alloc_array(machine, UINT32, 0x01000000);
109109
r9922r9923
281281   MCFG_VIDEO_START(archimds_vidc)
282282   MCFG_VIDEO_UPDATE(archimds_vidc)
283283
284   MCFG_RAM_ADD("messram")
284   MCFG_RAM_ADD(RAM_TAG)
285285   MCFG_RAM_DEFAULT_SIZE("2M")
286286   MCFG_RAM_EXTRA_OPTIONS("512K, 1M, 4M, 8M, 16M")
287287
src/mess/drivers/avigo.c
r9922r9923
4444#include "machine/tc8521.h"
4545#include "machine/ins8250.h"
4646#include "sound/speaker.h"
47#include "devices/messram.h"
47#include "machine/ram.h"
4848
4949/*
5050    bit 7:                      ?? high priority. When it occurs, clear this bit.
r9922r9923
323323      /* %001 */
324324      /* ram */
325325      case 0x01:
326         addr = messram_get_ptr(machine->device("messram")) + ((state->ram_bank_l & 0x07)<<14);
326         addr = ram_get_ptr(machine->device(RAM_TAG)) + ((state->ram_bank_l & 0x07)<<14);
327327         memory_set_bankptr(machine, "bank3", addr);
328328         memory_set_bankptr(machine, "bank7", addr);
329329         state->banked_opbase[2] = ((UINT8 *) addr) - (2 * 0x4000);
r9922r9923
419419   state->flash_at_0x8000 = 0;
420420
421421   /* clear */
422   memset(messram_get_ptr(machine->device("messram")), 0, 128*1024);
422   memset(ram_get_ptr(machine->device(RAM_TAG)), 0, 128*1024);
423423
424424   addr = (unsigned char *)state->flashes[0]->space()->get_read_ptr(0);
425425   avigo_setbank(machine, 0, addr, avigo_flash_0x0000_read_handler, avigo_flash_0x0000_write_handler);
426426
427   avigo_setbank(machine, 3, messram_get_ptr(machine->device("messram")), NULL, NULL);
427   avigo_setbank(machine, 3, ram_get_ptr(machine->device(RAM_TAG)), NULL, NULL);
428428
429429   /* 0x08000 is specially banked! */
430430   avigo_refresh_memory(machine);
r9922r9923
983983   MCFG_INTEL_E28F008SA_ADD("flash2")
984984
985985   /* internal ram */
986   MCFG_RAM_ADD("messram")
986   MCFG_RAM_ADD(RAM_TAG)
987987   MCFG_RAM_DEFAULT_SIZE("128K")
988988MACHINE_CONFIG_END
989989
src/mess/drivers/cybiko.c
r9922r9923
2121#include "machine/pcf8593.h"
2222#include "machine/at45dbxx.h"
2323#include "machine/sst39vfx.h"
24#include "devices/messram.h"
24#include "machine/ram.h"
2525
2626/* Until support for the H8Sxxxx variants used by cybiko is added, we use H8_3002 (even if opcodes differ) */
2727#define H8S2241   H83002
r9922r9923
265265   MCFG_AT45DB041_ADD("flash1")
266266
267267   /* internal ram */
268   MCFG_RAM_ADD("messram")
268   MCFG_RAM_ADD(RAM_TAG)
269269   MCFG_RAM_DEFAULT_SIZE("512K")
270270   MCFG_RAM_EXTRA_OPTIONS("1M")
271271MACHINE_CONFIG_END
r9922r9923
283283   MCFG_SST39VF020_ADD("flash2", 16, ENDIANNESS_BIG)
284284
285285   /* internal ram */
286   MCFG_RAM_MODIFY("messram")
286   MCFG_RAM_MODIFY(RAM_TAG)
287287   MCFG_RAM_DEFAULT_SIZE("256K")
288288   MCFG_RAM_EXTRA_OPTIONS("512K,1M")
289289MACHINE_CONFIG_END
r9922r9923
305305   MCFG_SST39VF020_ADD("flash2", 16, ENDIANNESS_BIG)
306306
307307   /* internal ram */
308   MCFG_RAM_MODIFY("messram")
308   MCFG_RAM_MODIFY(RAM_TAG)
309309   MCFG_RAM_DEFAULT_SIZE("2M")
310310MACHINE_CONFIG_END
311311
src/mess/drivers/pp01.c
r9922r9923
99
1010#include "emu.h"
1111#include "cpu/i8085/i8085.h"
12#include "devices/messram.h"
12#include "machine/ram.h"
1313#include "includes/pp01.h"
1414
1515
r9922r9923
222222   MCFG_I8255A_ADD( "ppi8255", pp01_ppi8255_interface )
223223
224224   /* internal ram */
225   MCFG_RAM_ADD("messram")
225   MCFG_RAM_ADD(RAM_TAG)
226226   MCFG_RAM_DEFAULT_SIZE("64K")
227227   MCFG_RAM_DEFAULT_VALUE(0x00)
228228MACHINE_CONFIG_END
src/mess/drivers/apple2.c
r9922r9923
197197//#include "machine/a2z80.h"
198198#include "sound/ay8910.h"
199199#include "sound/speaker.h"
200#include "devices/messram.h"
200#include "machine/ram.h"
201201#include "machine/a2cffa.h"
202202#include "machine/idectrl.h"
203203#include "devices/harddriv.h"
r9922r9923
650650
651651static MACHINE_CONFIG_DERIVED( apple2, apple2_common )
652652   /* internal ram */
653   MCFG_RAM_ADD("messram")
653   MCFG_RAM_ADD(RAM_TAG)
654654   MCFG_RAM_DEFAULT_SIZE("64K")
655655   MCFG_RAM_EXTRA_OPTIONS("4K,8K,12K,16K,20K,24K,32K,36K,48K")
656656   MCFG_RAM_DEFAULT_VALUE(0x00)
r9922r9923
664664   MCFG_VIDEO_START(apple2p)
665665
666666   /* internal ram */
667   MCFG_RAM_ADD("messram")
667   MCFG_RAM_ADD(RAM_TAG)
668668   MCFG_RAM_DEFAULT_SIZE("64K")
669669   MCFG_RAM_EXTRA_OPTIONS("16K,32K,48K")
670670   MCFG_RAM_DEFAULT_VALUE(0x00)
r9922r9923
686686static MACHINE_CONFIG_DERIVED( apple2e, apple2_common )
687687   MCFG_VIDEO_START(apple2e)
688688   /* internal ram */
689   MCFG_RAM_ADD("messram")
689   MCFG_RAM_ADD(RAM_TAG)
690690   MCFG_RAM_DEFAULT_SIZE("128K")
691691   MCFG_RAM_EXTRA_OPTIONS("64K")
692692   MCFG_RAM_DEFAULT_VALUE(0x00)
r9922r9923
705705   MCFG_QUANTUM_PERFECT_CPU("maincpu")
706706
707707   /* internal ram */
708   MCFG_RAM_ADD("messram")
708   MCFG_RAM_ADD(RAM_TAG)
709709   MCFG_RAM_DEFAULT_SIZE("128K")
710710   MCFG_RAM_EXTRA_OPTIONS("64K")
711711   MCFG_RAM_DEFAULT_VALUE(0x00)
r9922r9923
714714static MACHINE_CONFIG_DERIVED( mprof3, apple2e )
715715
716716   /* internal ram */
717   MCFG_RAM_MODIFY("messram")
717   MCFG_RAM_MODIFY(RAM_TAG)
718718   MCFG_RAM_DEFAULT_SIZE("128K")
719719MACHINE_CONFIG_END
720720
src/mess/drivers/e01.c
r9922r9923
5050#include "includes/e01.h"
5151#include "cpu/m6502/m6502.h"
5252#include "devices/flopdrv.h"
53#include "devices/messram.h"
53#include "machine/ram.h"
5454#include "machine/ctronics.h"
5555#include "machine/6522via.h"
5656#include "machine/mc146818.h"
r9922r9923
386386{
387387   e01_state *state = machine->driver_data<e01_state>();
388388
389   UINT8 *ram = messram_get_ptr(machine->device("messram"));
389   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
390390   UINT8 *rom = machine->region(R65C102_TAG)->base();
391391
392392   /* setup memory banking */
r9922r9923
455455//  MCFG_CENTRONICS_ADD(CENTRONICS_TAG, e01_centronics_config)
456456
457457   /* internal ram */
458   MCFG_RAM_ADD("messram")
458   MCFG_RAM_ADD(RAM_TAG)
459459   MCFG_RAM_DEFAULT_SIZE("64K")
460460MACHINE_CONFIG_END
461461
src/mess/drivers/xerox820.c
r9922r9923
3232#include "cpu/i86/i86.h"
3333#include "formats/basicdsk.h"
3434#include "devices/flopdrv.h"
35#include "devices/messram.h"
35#include "machine/ram.h"
3636#include "machine/z80pio.h"
3737#include "machine/z80ctc.h"
3838#include "machine/z80dart.h"
r9922r9923
140140void xerox820_state::bankswitch(int bank)
141141{
142142   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
143   UINT8 *ram = messram_get_ptr(m_ram);
143   UINT8 *ram = ram_get_ptr(m_ram);
144144
145145   if (bank)
146146   {
r9922r9923
160160void xerox820ii_state::bankswitch(int bank)
161161{
162162   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
163   UINT8 *ram = messram_get_ptr(m_ram);
163   UINT8 *ram = ram_get_ptr(m_ram);
164164
165165   if (bank)
166166   {
r9922r9923
834834   MCFG_COM8116_ADD(COM8116_TAG, XTAL_5_0688MHz, com8116_intf)
835835
836836   /* internal ram */
837   MCFG_RAM_ADD("messram")
837   MCFG_RAM_ADD(RAM_TAG)
838838   MCFG_RAM_DEFAULT_SIZE("64K")
839839MACHINE_CONFIG_END
840840
r9922r9923
868868   MCFG_COM8116_ADD(COM8116_TAG, XTAL_5_0688MHz, com8116_intf)
869869
870870   /* internal ram */
871   MCFG_RAM_ADD("messram")
871   MCFG_RAM_ADD(RAM_TAG)
872872   MCFG_RAM_DEFAULT_SIZE("64K")
873873MACHINE_CONFIG_END
874874
r9922r9923
877877    MCFG_CPU_PROGRAM_MAP(xerox168_mem)
878878
879879   /* internal ram */
880   MCFG_RAM_MODIFY("messram")
880   MCFG_RAM_MODIFY(RAM_TAG)
881881   MCFG_RAM_DEFAULT_SIZE("192K")
882882   MCFG_RAM_EXTRA_OPTIONS("320K")
883883MACHINE_CONFIG_END
src/mess/drivers/pc.c
r9922r9923
158158#include "sound/3812intf.h"
159159
160160#include "machine/kb_keytro.h"
161#include "devices/messram.h"
161#include "machine/ram.h"
162162
163163#define ym3812_StdClock 3579545
164164
r9922r9923
16031603   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
16041604
16051605   /* internal ram */
1606   MCFG_RAM_ADD("messram")
1606   MCFG_RAM_ADD(RAM_TAG)
16071607   MCFG_RAM_DEFAULT_SIZE("640K")
16081608MACHINE_CONFIG_END
16091609
r9922r9923
16711671   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
16721672
16731673   /* internal ram */
1674   MCFG_RAM_ADD("messram")
1674   MCFG_RAM_ADD(RAM_TAG)
16751675   MCFG_RAM_DEFAULT_SIZE("640K")
16761676MACHINE_CONFIG_END
16771677
r9922r9923
17521752   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
17531753
17541754   /* internal ram */
1755   MCFG_RAM_ADD("messram")
1755   MCFG_RAM_ADD(RAM_TAG)
17561756   MCFG_RAM_DEFAULT_SIZE("640K")
17571757MACHINE_CONFIG_END
17581758
r9922r9923
18151815   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
18161816
18171817   /* internal ram */
1818   MCFG_RAM_ADD("messram")
1818   MCFG_RAM_ADD(RAM_TAG)
18191819   MCFG_RAM_DEFAULT_SIZE("640K")
18201820MACHINE_CONFIG_END
18211821
r9922r9923
19001900   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
19011901
19021902   /* internal ram */
1903   MCFG_RAM_ADD("messram")
1903   MCFG_RAM_ADD(RAM_TAG)
19041904   MCFG_RAM_DEFAULT_SIZE("640K")
19051905MACHINE_CONFIG_END
19061906
r9922r9923
19611961   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
19621962
19631963   /* internal ram */
1964   MCFG_RAM_ADD("messram")
1964   MCFG_RAM_ADD(RAM_TAG)
19651965   MCFG_RAM_DEFAULT_SIZE("640K")
19661966MACHINE_CONFIG_END
19671967
r9922r9923
20252025   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
20262026
20272027   /* internal ram */
2028   MCFG_RAM_ADD("messram")
2028   MCFG_RAM_ADD(RAM_TAG)
20292029   MCFG_RAM_DEFAULT_SIZE("640K")
20302030MACHINE_CONFIG_END
20312031
r9922r9923
20972097   MCFG_MC146818_ADD( "rtc", MC146818_IGNORE_CENTURY )
20982098
20992099   /* internal ram */
2100   MCFG_RAM_ADD("messram")
2100   MCFG_RAM_ADD(RAM_TAG)
21012101   MCFG_RAM_DEFAULT_SIZE("512K")
21022102MACHINE_CONFIG_END
21032103
r9922r9923
21062106   MCFG_CPU_PROGRAM_MAP(ppc640_map)
21072107
21082108   /* internal ram */
2109   MCFG_RAM_MODIFY("messram")
2109   MCFG_RAM_MODIFY(RAM_TAG)
21102110   MCFG_RAM_DEFAULT_SIZE("640K")
21112111MACHINE_CONFIG_END
21122112
r9922r9923
21542154   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
21552155
21562156   /* internal ram */
2157   MCFG_RAM_ADD("messram")
2157   MCFG_RAM_ADD(RAM_TAG)
21582158   MCFG_RAM_DEFAULT_SIZE("640K")
21592159MACHINE_CONFIG_END
21602160
r9922r9923
22032203   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
22042204
22052205   /* internal ram */
2206   MCFG_RAM_ADD("messram")
2206   MCFG_RAM_ADD(RAM_TAG)
22072207   MCFG_RAM_DEFAULT_SIZE("640K")
22082208MACHINE_CONFIG_END
22092209
r9922r9923
22632263   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
22642264
22652265   /* internal ram */
2266   MCFG_RAM_ADD("messram")
2266   MCFG_RAM_ADD(RAM_TAG)
22672267   MCFG_RAM_DEFAULT_SIZE("640K")
22682268MACHINE_CONFIG_END
22692269
r9922r9923
23122312   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
23132313
23142314   /* internal ram */
2315   MCFG_RAM_ADD("messram")
2315   MCFG_RAM_ADD(RAM_TAG)
23162316   MCFG_RAM_DEFAULT_SIZE("640K")
23172317MACHINE_CONFIG_END
23182318
r9922r9923
23612361   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
23622362
23632363   /* internal ram */
2364   MCFG_RAM_ADD("messram")
2364   MCFG_RAM_ADD(RAM_TAG)
23652365   MCFG_RAM_DEFAULT_SIZE("640K")
23662366MACHINE_CONFIG_END
23672367
r9922r9923
24102410   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
24112411
24122412   /* internal ram */
2413   MCFG_RAM_ADD("messram")
2413   MCFG_RAM_ADD(RAM_TAG)
24142414   MCFG_RAM_DEFAULT_SIZE("640K")
24152415MACHINE_CONFIG_END
24162416
r9922r9923
24732473   MCFG_CARTSLOT_LOAD(pcjr_cartridge)
24742474
24752475   /* internal ram */
2476   MCFG_RAM_ADD("messram")
2476   MCFG_RAM_ADD(RAM_TAG)
24772477   MCFG_RAM_DEFAULT_SIZE("640K")
24782478
24792479   /* Software lists */
r9922r9923
25382538   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
25392539
25402540   /* internal ram */
2541   MCFG_RAM_ADD("messram")
2541   MCFG_RAM_ADD(RAM_TAG)
25422542   MCFG_RAM_DEFAULT_SIZE("640K")
25432543MACHINE_CONFIG_END
25442544
r9922r9923
26012601   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
26022602
26032603   /* internal ram */
2604   MCFG_RAM_ADD("messram")
2604   MCFG_RAM_ADD(RAM_TAG)
26052605   MCFG_RAM_DEFAULT_SIZE("640K")
26062606MACHINE_CONFIG_END
26072607
src/mess/drivers/micronic.c
r9922r9923
119119#include "cpu/z80/z80.h"
120120#include "video/hd61830.h"
121121#include "machine/mc146818.h"
122#include "devices/messram.h"
122#include "machine/ram.h"
123123#include "sound/beep.h"
124124
125125static UINT8 keypad_r (running_machine *machine)
r9922r9923
403403   if (read_or_write)
404404   {
405405      mame_fwrite(file, state->ram, 0x8000);
406      mame_fwrite(file, messram_get_ptr(machine->device("messram")), 224*1024);
406      mame_fwrite(file, ram_get_ptr(machine->device(RAM_TAG)), 224*1024);
407407   }
408408   else
409409   {
410410      if (file)
411411      {
412412         mame_fread(file, state->ram, 0x8000);
413         mame_fread(file, messram_get_ptr(machine->device("messram")), 224*1024);         
413         mame_fread(file, ram_get_ptr(machine->device(RAM_TAG)), 224*1024);         
414414
415415         /* reload register A and B for restore the periodic irq state */
416416         mame_fseek(file, 0x4000a, SEEK_SET);
r9922r9923
463463   memory_configure_bank(machine, "bank1", 0x00, 0x02, machine->region(Z80_TAG)->base(), 0x10000);
464464
465465   /* RAM banks */
466   memory_configure_bank(machine, "bank1", 0x02, 0x07, messram_get_ptr(machine->device("messram")), 0x8000);
466   memory_configure_bank(machine, "bank1", 0x02, 0x07, ram_get_ptr(machine->device(RAM_TAG)), 0x8000);
467467
468468   state->rtc_periodic_irq = timer_alloc(machine, rtc_periodic_irq, 0);
469469   /* register for state saving */
r9922r9923
508508   MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
509509
510510   /* ram banks */
511   MCFG_RAM_ADD("messram")
511   MCFG_RAM_ADD(RAM_TAG)
512512   MCFG_RAM_DEFAULT_SIZE("224K")
513513
514514   MCFG_NVRAM_HANDLER(micronic)
src/mess/drivers/pecom.c
r9922r9923
1212#include "sound/wave.h"
1313#include "devices/cassette.h"
1414#include "includes/pecom.h"
15#include "devices/messram.h"
15#include "machine/ram.h"
1616
1717/* Address maps */
1818static ADDRESS_MAP_START(pecom64_mem, ADDRESS_SPACE_PROGRAM, 8)
r9922r9923
192192   MCFG_CASSETTE_ADD( "cassette", pecom_cassette_config )
193193
194194   /* internal ram */
195   MCFG_RAM_ADD("messram")
195   MCFG_RAM_ADD(RAM_TAG)
196196   MCFG_RAM_DEFAULT_SIZE("32K")
197197   MCFG_RAM_DEFAULT_VALUE(0x00)
198198MACHINE_CONFIG_END
src/mess/drivers/ptcsol.c
r9922r9923
2727#include "emu.h"
2828#include "cpu/i8085/i8085.h"
2929#include "machine/terminal.h"
30#include "devices/messram.h"
30#include "machine/ram.h"
3131
3232
3333class ptcsol_state : public driver_device
r9922r9923
196196   MCFG_VIDEO_UPDATE(sol20)
197197
198198   /* internal ram */
199//  MCFG_RAM_ADD("messram")
199//  MCFG_RAM_ADD(RAM_TAG)
200200//  MCFG_RAM_DEFAULT_SIZE("8K")
201201//  MCFG_RAM_EXTRA_OPTIONS("16K,32K")
202202   MCFG_GENERIC_TERMINAL_ADD("terminal", sol20_terminal_intf)
src/mess/drivers/cosmicos.c
r9922r9923
3636#include "includes/cosmicos.h"
3737#include "cpu/cosmac/cosmac.h"
3838#include "devices/cassette.h"
39#include "devices/messram.h"
39#include "machine/ram.h"
4040#include "devices/snapquik.h"
4141#include "machine/rescap.h"
4242#include "sound/cdp1864.h"
r9922r9923
284284{
285285   cosmicos_state *state = machine->driver_data<cosmicos_state>();
286286   address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
287   UINT8 *ram = messram_get_ptr(machine->device("messram"));
287   UINT8 *ram = ram_get_ptr(machine->device(RAM_TAG));
288288
289289   if (state->ram_disable)
290290   {
r9922r9923
552552   dm9368_rbi_w(state->dm9368, 1);
553553
554554   /* setup memory banking */
555   switch (messram_get_size(machine->device("messram")))
555   switch (ram_get_size(machine->device(RAM_TAG)))
556556   {
557557   case 256:
558558      memory_unmap_readwrite(program, 0x0000, 0xbfff, 0, 0);
r9922r9923
646646   MCFG_CASSETTE_ADD(CASSETTE_TAG, cosmicos_cassette_config)
647647
648648   /* internal ram */
649   MCFG_RAM_ADD("messram")
649   MCFG_RAM_ADD(RAM_TAG)
650650   MCFG_RAM_DEFAULT_SIZE("256")
651651   MCFG_RAM_EXTRA_OPTIONS("4K,48K")
652652MACHINE_CONFIG_END
src/mess/drivers/pk8020.c
r9922r9923
1414#include "devices/flopdrv.h"
1515#include "formats/basicdsk.h"
1616#include "includes/pk8020.h"
17#include "devices/messram.h"
17#include "machine/ram.h"
1818
1919/* Address maps */
2020static ADDRESS_MAP_START(pk8020_mem, ADDRESS_SPACE_PROGRAM, 8)
r9922r9923
242242   MCFG_FLOPPY_4_DRIVES_ADD(pk8020_floppy_config)
243243
244244   /* internal ram */
245   MCFG_RAM_ADD("messram")
245   MCFG_RAM_ADD(RAM_TAG)
246246   MCFG_RAM_DEFAULT_SIZE("258K")   //64 + 4*48 + 2
247247   MCFG_RAM_DEFAULT_VALUE(0x00)
248248MACHINE_CONFIG_END
src/mess/drivers/vixen.c
r9922r9923
5959#include "emu.h"
6060#include "cpu/z80/z80.h"
6161#include "devices/flopdrv.h"
62#include "devices/messram.h"
62#include "machine/ram.h"
6363#include "machine/i8155.h"
6464#include "machine/ieee488.h"
6565#include "machine/msm8251.h"
r9922r9923
726726void vixen_state::machine_start()
727727{
728728   // configure memory banking
729   UINT8 *ram = messram_get_ptr(m_ram);
729   UINT8 *ram = ram_get_ptr(m_ram);
730730
731731   memory_configure_bank(machine, "bank1", 0, 1, ram, 0);
732732   memory_configure_bank(machine, "bank1", 1, 1, machine->region(Z8400A_TAG)->base(), 0);
r9922r9923
810810   MCFG_IEEE488_ADD(IEEE488_TAG, ieee488_daisy)
811811   
812812   // internal ram
813   MCFG_RAM_ADD("messram")
813   MCFG_RAM_ADD(RAM_TAG)
814814   MCFG_RAM_DEFAULT_SIZE("64K")
815815MACHINE_CONFIG_END
816816
src/mess/drivers/kc.c
r9922r9923
2929#include "devices/cassette.h"
3030#include "devices/flopdrv.h"
3131#include "formats/basicdsk.h"
32#include "devices/messram.h"
32#include "machine/ram.h"
3333
3434static READ8_HANDLER(kc85_4_port_r)
3535{
r9922r9923
419419   MCFG_CASSETTE_ADD( "cassette", default_cassette_config )
420420
421421   /* internal ram */
422   MCFG_RAM_ADD("messram")
422   MCFG_RAM_ADD(RAM_TAG)
423423   MCFG_RAM_DEFAULT_SIZE("64K")
424424MACHINE_CONFIG_END
425425

Previous 15994 Revisions Next


© 1998-2018 The MESS Team