Previous 15994 Revisions Next

r9147 Friday 17th September, 2010 at 02:11:42 UTC by Miodrag Milanović
Sync with MAME (still need to update with intelfsh and mc146818)
[ROOT]makefile
[src/build]build.mak
[src/emu]devcb.h devintrf.c devintrf.h emucore.h machine.c machine.h mconfig.h memory.c timer.c timer.h
[src/emu/machine]6522via.c 6522via.h
[src/emu/sound]asc.c* asc.h* sound.mak
[src/mess/drivers]a6809.c aim65.c aim65_40.c atom.c bbc.c e01.c ec65.c jr100.c mac.c microtan.c oric.c pet.c ssystem3.c sym1.c tk80bs.c vic20.c victor9k.c
[src/mess/formats]m65_snqk.c
[src/mess/includes]vic20.h
[src/mess/machine]aim65.c apple3.c at.c bbc.c c1541.c c1571.c c2040.c c9060.c concept.c lisa.c mac.c microtan.c oric.c pet.c vectrex.c vic1112.c
[src/mess/video]aim65.c vectrex.c
[src/osd/sdl]sdl.mak
[src/osd/windows]winmain.c winmain.h winmisc.c
[src/osd/winui]properties.c treeview.c

src/build/build.mak
r9146r9147
1818# set of build targets
1919#-------------------------------------------------
2020
21FILE2STR = $(BUILDOUT)/file2str$(BUILD_EXE)
22PNG2BDC = $(BUILDOUT)/png2bdc$(BUILD_EXE)
23VERINFO = $(BUILDOUT)/verinfo$(BUILD_EXE)
21FILE2STR_TARGET = $(BUILDOUT)/file2str$(BUILD_EXE)
22MAKEDEP_TARGET = $(BUILDOUT)/makedep$(BUILD_EXE)
23PNG2BDC_TARGET = $(BUILDOUT)/png2bdc$(BUILD_EXE)
24VERINFO_TARGET = $(BUILDOUT)/verinfo$(BUILD_EXE)
2425
26ifeq ($(TARGETOS),win32)
27FILE2STR = $(subst /,\,$(FILE2STR_TARGET))
28MAKEDEP = $(subst /,\,$(MAKEDEP_TARGET))
29PNG2BDC = $(subst /,\,$(PNG2BDC_TARGET))
30VERINFO = $(subst /,\,$(VERINFO_TARGET))
31else
32FILE2STR = $(FILE2STR_TARGET)
33MAKEDEP = $(MAKEDEP_TARGET)
34PNG2BDC = $(PNG2BDC_TARGET)
35VERINFO = $(VERINFO_TARGET)
36endif
37
2538ifneq ($(CROSS_BUILD),1)
2639BUILD += \
27   $(FILE2STR) \
28   $(PNG2BDC) \
29   $(VERINFO) \
40   $(FILE2STR_TARGET) \
41   $(MAKEDEP_TARGET) \
42   $(PNG2BDC_TARGET) \
43   $(VERINFO_TARGET) \
3044
3145
3246
r9146r9147
3751FILE2STROBJS = \
3852   $(BUILDOBJ)/file2str.o \
3953
40$(FILE2STR): $(FILE2STROBJS) $(LIBOCORE)
54$(FILE2STR_TARGET): $(FILE2STROBJS) $(LIBOCORE)
4155   @echo Linking $@...
4256   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
4357
4458
4559
4660#-------------------------------------------------
61# makedep
62#-------------------------------------------------
63
64MAKEDEPOBJS = \
65   $(BUILDOBJ)/makedep.o \
66
67$(MAKEDEP_TARGET): $(MAKEDEPOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB)
68   @echo Linking $@...
69   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
70
71
72
73#-------------------------------------------------
4774# png2bdc
4875#-------------------------------------------------
4976
5077PNG2BDCOBJS = \
5178   $(BUILDOBJ)/png2bdc.o \
5279
53$(PNG2BDC): $(PNG2BDCOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB)
80$(PNG2BDC_TARGET): $(PNG2BDCOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB)
5481   @echo Linking $@...
5582   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
5683
r9146r9147
6390VERINFOOBJS = \
6491   $(BUILDOBJ)/verinfo.o
6592
66$(VERINFO): $(VERINFOOBJS) $(LIBOCORE)
93$(VERINFO_TARGET): $(VERINFOOBJS) $(LIBOCORE)
6794   @echo Linking $@...
6895   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
6996
src/osd/sdl/sdl.mak
r9146r9147
161161
162162ifeq ($(TARGETOS),macosx)
163163BASE_TARGETOS = macosx
164DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX
164DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX -DSDLMAME_DARWIN
165165DEBUGOBJS = $(SDLOBJ)/debugosx.o
166166SYNC_IMPLEMENTATION = ntc
167167SDLMAIN = $(SDLOBJ)/SDLMain_tmpl.o
r9146r9147
208208DEBUGOBJS = $(SDLOBJ)/debugwin.o $(SDLOBJ)/dview.o $(SDLOBJ)/debug-sup.o $(SDLOBJ)/debug-intf.o
209209LIBS += -lgtk-win32-2.0 -lgdk-win32-2.0 -lgmodule-2.0 -lglib-2.0 -lgobject-2.0 \
210210   -lpango-1.0 -latk-1.0 -lgdk_pixbuf-2.0
211CCOMFLAGS += -mms-bitfields \
212   -I$(GTK_INSTALL_ROOT)/include/gtk-2.0 -I$(GTK_INSTALL_ROOT)/include/glib-2.0 \
211CCOMFLAGS += -mms-bitfields
212INCPATH += -I$(GTK_INSTALL_ROOT)/include/gtk-2.0 -I$(GTK_INSTALL_ROOT)/include/glib-2.0 \
213213   -I$(GTK_INSTALL_ROOT)/include/cairo -I$(GTK_INSTALL_ROOT)/include/pango-1.0 \
214214   -I$(GTK_INSTALL_ROOT)/include/atk-1.0 \
215215   -I$(GTK_INSTALL_ROOT)/lib/glib-2.0/include -I$(GTK_INSTALL_ROOT)/lib/gtk-2.0/include
r9146r9147
289289OSDCLEAN = sdlclean
290290
291291# add the debugger includes
292CCOMFLAGS += -Isrc/debug
292INCPATH += -Isrc/debug
293293
294294# add the prefix file
295CCOMFLAGS += -include $(SDLSRC)/sdlprefix.h
295INCPATH += -include $(SDLSRC)/sdlprefix.h
296296
297297#-------------------------------------------------
298298# BASE_TARGETOS specific configurations
r9146r9147
337337endif
338338
339339ifndef SDL_INSTALL_ROOT
340CCOMFLAGS += `sdl-config --cflags`
340INCPATH += `sdl-config --cflags`
341341LIBS += -lm `sdl-config --libs`
342342else
343CCOMFLAGS += -I$(SDL_INSTALL_ROOT)/include -D_GNU_SOURCE=1
343INCPATH += -I$(SDL_INSTALL_ROOT)/include
344CCOMFLAGS += -D_GNU_SOURCE=1
344345LIBS += -lm -L$(SDL_INSTALL_ROOT)/lib -Wl,-rpath,$(SDL_INSTALL_ROOT)/lib -lSDL
345346endif
346347
r9146r9147
357358OSDCOREOBJS += $(SDLMAIN)
358359
359360ifdef SDL_INSTALL_ROOT
360CCOMFLAGS += -I$(SDL_INSTALL_ROOT)/include
361INCPATH += -I$(SDL_INSTALL_ROOT)/include
361362LIBS += -L$(SDL_INSTALL_ROOT)/lib
362363#-Wl,-rpath,$(SDL_INSTALL_ROOT)/lib
363364endif
r9146r9147
387388# Remove the "/SDL" component from the include path so that we can compile
388389# files (header files are #include "SDL/something.h", so the extra "/SDL"
389390# causes a significant problem)
390CCOMFLAGS += `sdl-config --cflags | sed 's:/SDL::'` -DNO_SDL_GLEXT
391INCPATH += `sdl-config --cflags | sed 's:/SDL::'`
392CCOMFLAGS += -DNO_SDL_GLEXT
391393# Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m
392394LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread
393395endif
r9146r9147
400402
401403ifeq ($(BASE_TARGETOS),os2)
402404
403CCOMFLAGS += `sdl-config --cflags`
405INCPATH += `sdl-config --cflags`
404406LIBS += `sdl-config --libs`
405407
406408endif # OS2
r9146r9147
437439ifdef MESA_INSTALL_ROOT
438440LIBS += -L$(MESA_INSTALL_ROOT)/lib
439441LDFLAGS += -Wl,-rpath=$(MESA_INSTALL_ROOT)/lib
440CCOMFLAGS += -I$(MESA_INSTALL_ROOT)/include
442INCPATH += -I$(MESA_INSTALL_ROOT)/include
441443endif
442444endif
443445
r9146r9147
454456
455457# the new debugger relies on GTK+ in addition to the base SDLMAME needs
456458# Non-X11 builds can not use the debugger
457CCOMFLAGS += `pkg-config --cflags gtk+-2.0` `pkg-config --cflags gconf-2.0`
459INCPATH += `pkg-config --cflags-only-I gtk+-2.0` `pkg-config --cflags-only-I gconf-2.0`
460CCOMFLAGS += `pkg-config --cflags-only-other gtk+-2.0` `pkg-config --cflags-only-other gconf-2.0`
458461LIBS += `pkg-config --libs gtk+-2.0` `pkg-config --libs gconf-2.0`
459462#CCOMFLAGS += -DGTK_DISABLE_DEPRECATED
460463
461464# some systems still put important things in a different prefix
462465LIBS += -L/usr/X11/lib -L/usr/X11R6/lib -L/usr/openwin/lib
463466# make sure we can find X headers
464CCOMFLAGS += -I/usr/X11/include -I/usr/X11R6/include -I/usr/openwin/include
467INCPATH += -I/usr/X11/include -I/usr/X11R6/include -I/usr/openwin/include
465468endif # NO_X11
466469
467470#-------------------------------------------------
r9146r9147
482485endif # solaris
483486
484487# drawSDL depends on the core software renderer, so make sure it exists
485$(SDLOBJ)/drawsdl.o : $(SRC)/emu/rendersw.c $(SDLSRC)/drawogl.c $(SDLSRC)/texcopy.c
488$(SDLOBJ)/drawsdl.o : $(SRC)/emu/rendersw.c $(SDLSRC)/drawogl.c
489$(SDLOBJ)/drawogl.o : $(SDLSRC)/texcopy.c $(SDLSRC)/texsrc.h
486490
487491# draw13 depends on blit13.h
488492$(SDLOBJ)/draw13.o : $(SDLSRC)/blit13.h
src/osd/windows/winmain.c
r9146r9147
118118{
119119public:
120120   stack_walker();
121
121   
122122   FPTR ip() const { return m_stackframe.AddrPC.Offset; }
123123   FPTR sp() const { return m_stackframe.AddrStack.Offset; }
124124   FPTR frame() const { return m_stackframe.AddrFrame.Offset; }
125125
126   bool reset();
126127   void reset(CONTEXT &context, HANDLE thread);
127128   bool unwind();
128129
r9146r9147
138139   dynamic_bind<BOOL (WINAPI *)(HANDLE, LPCTSTR, BOOL)> m_sym_initialize;
139140   dynamic_bind<PVOID (WINAPI *)(HANDLE, DWORD64)> m_sym_function_table_access_64;
140141   dynamic_bind<DWORD64 (WINAPI *)(HANDLE, DWORD64)> m_sym_get_module_base_64;
142   dynamic_bind<VOID (WINAPI *)(PCONTEXT)> m_rtl_capture_context;
141143
142144   static bool      s_initialized;
143145};
r9146r9147
304306   { "multithreading;mt",        "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
305307   { "numprocessors;np",         "auto",     0,             "number of processors; this overrides the number the system reports" },
306308   { "profile",                  "0",        0,                 "enable profiling, specifying the stack depth to track" },
309   { "bench",                    "0",        0,                 "benchmark for the given number of emulated seconds; implies -video none -nosound -nothrottle" },
307310
308311   // video options
309312   { NULL,                       NULL,       OPTION_HEADER,     "WINDOWS VIDEO OPTIONS" },
r9146r9147
391394   // allocate symbols
392395   symbol_manager local_symbols(argv[0]);
393396   symbols = &local_symbols;
394
397   
395398   // set up exception handling
396399   pass_thru_filter = SetUnhandledExceptionFilter(exception_filter);
397400   SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
398401
402   // enable stack crawls for asserts
403   extern void (*s_debugger_stack_crawler)();
404   s_debugger_stack_crawler = winmain_dump_stack;
405
399406   // if we're a GUI app, out errors to message boxes
400407   if (win_is_gui_application() || is_double_click_start(argc))
401408   {
r9146r9147
450457void osd_init(running_machine *machine)
451458{
452459   const char *stemp;
460   
461   // determine if we are benchmarking, and adjust options appropriately
462   int bench = options_get_int(machine->options(), WINOPTION_BENCH);
463   if (bench > 0)
464   {
465      options_set_bool(machine->options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
466      options_set_bool(machine->options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM);
467      options_set_string(machine->options(), WINOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM);
468      options_set_int(machine->options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM);
469   }
453470
454471   // determine if we are profiling, and adjust options appropriately
455472   int profile = options_get_int(machine->options(), WINOPTION_PROFILE);
r9146r9147
457474   {
458475      options_set_bool(machine->options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
459476      options_set_bool(machine->options(), WINOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM);
460      options_set_bool(machine->options(), WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM);
477      options_set_int(machine->options(), WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM);
461478   }
462479
463480   // thread priority
r9146r9147
572589
573590
574591//============================================================
592//  winmain_dump_stack
593//============================================================
594
595void winmain_dump_stack()
596{
597   // set up the stack walker
598   stack_walker walker;
599   if (!walker.reset())
600      return;
601
602   // walk the stack
603   while (walker.unwind())
604      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == NULL) ? "" : symbols->symbol_for_address(walker.ip()));
605}
606
607
608//============================================================
575609//  check_for_double_click_start
576610//============================================================
577611
r9146r9147
744778
745779   // walk the stack
746780   while (walker.unwind())
747      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), symbols->symbol_for_address(walker.ip()));
781      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == NULL) ? "" : symbols->symbol_for_address(walker.ip()));
748782
749783   // exit
750784   return EXCEPTION_CONTINUE_SEARCH;
751785}
752786
753787
754
755788//**************************************************************************
756789//  STACK WALKER
757790//**************************************************************************
r9146r9147
767800     m_stack_walk_64(TEXT("dbghelp.dll"), "StackWalk64"),
768801     m_sym_initialize(TEXT("dbghelp.dll"), "SymInitialize"),
769802     m_sym_function_table_access_64(TEXT("dbghelp.dll"), "SymFunctionTableAccess64"),
770     m_sym_get_module_base_64(TEXT("dbghelp.dll"), "SymGetModuleBase64")
803     m_sym_get_module_base_64(TEXT("dbghelp.dll"), "SymGetModuleBase64"),
804     m_rtl_capture_context(TEXT("kernel32.dll"), "RtlCaptureContext")
771805{
772806   // zap the structs
773807   memset(&m_stackframe, 0, sizeof(m_stackframe));
r9146r9147
786820//  reset - set up a new context
787821//-------------------------------------------------
788822
823bool stack_walker::reset()
824{
825   // set up the initial state
826   if (!m_rtl_capture_context)
827      return false;
828   (*m_rtl_capture_context)(&m_context);
829   m_thread = GetCurrentThread();
830   m_first = true;
831
832   // initialize the stackframe
833   memset(&m_stackframe, 0, sizeof(m_stackframe));
834   m_stackframe.AddrPC.Mode = AddrModeFlat;
835   m_stackframe.AddrFrame.Mode = AddrModeFlat;
836   m_stackframe.AddrStack.Mode = AddrModeFlat;
837
838   // pull architecture-specific fields from the context
839#ifdef PTR64
840   m_stackframe.AddrPC.Offset = m_context.Rip;
841   m_stackframe.AddrFrame.Offset = m_context.Rsp;
842   m_stackframe.AddrStack.Offset = m_context.Rsp;
843#else
844   m_stackframe.AddrPC.Offset = m_context.Eip;
845   m_stackframe.AddrFrame.Offset = m_context.Ebp;
846   m_stackframe.AddrStack.Offset = m_context.Esp;
847#endif
848   return true;
849}
850
789851void stack_walker::reset(CONTEXT &initial, HANDLE thread)
790852{
791853   // set up the initial state
src/osd/windows/winmain.h
r9146r9147
5757#define WINOPTION_MULTITHREADING      "multithreading"
5858#define WINOPTION_NUMPROCESSORS         "numprocessors"
5959#define WINOPTION_PROFILE            "profile"
60#define WINOPTION_BENCH               "bench"
6061
6162// video options
6263#define WINOPTION_VIDEO               "video"
r9146r9147
148149
149150// use this to ping the watchdog
150151void winmain_watchdog_ping(void);
152void winmain_dump_stack();
src/osd/windows/winmisc.c
r9146r9147
5050// MAMEOS headers
5151#include "winutf8.h"
5252#include "strconv.h"
53#include "strconv.h"
5354
5455
5556//============================================================
r9146r9147
6869
6970
7071//============================================================
72//  GLOBAL VARIABLES
73//============================================================
74
75void (*s_debugger_stack_crawler)() = NULL;
76
77
78
79//============================================================
7180//  osd_malloc
7281//============================================================
7382
r9146r9147
167176      win_output_debug_string_utf8(message);
168177      DebugBreak();
169178   }
179   else if (s_debugger_stack_crawler != NULL)
180      (*s_debugger_stack_crawler)();
170181}
src/osd/winui/treeview.c
r9146r9147
924924   int i, j, device_folder_count = 0;
925925   LPTREEFOLDER device_folders[512];
926926   LPTREEFOLDER folder;
927   const device_config_execute_interface *device = NULL;
927   const device_config_execute_interface *device;
928928   int nFolder = numFolders;
929929
930930   for (i = 0; drivers[i] != NULL; i++)
r9146r9147
984984   int i, j, device_folder_count = 0;
985985   LPTREEFOLDER device_folders[512];
986986   LPTREEFOLDER folder;
987   const device_config_sound_interface *device = NULL;
987   const device_config_sound_interface *device;
988988   int nFolder = numFolders;
989989
990990   for (i = 0; drivers[i] != NULL; i++)
src/osd/winui/properties.c
r9146r9147
385385   memset(pspages, 0, sizeof(PROPSHEETPAGE) * possiblePropSheets);
386386
387387   maxPropSheets = 0;
388
388   
389389   i = ( isGame ) ? 0 : 2;
390390
391391   for (; g_propSheets[i].pfnDlgProc; i++)
392392   {
393      if (!gamedrv)
394      {
395         if (g_propSheets[i].bOnDefaultPage)
396         {
397            pspages[maxPropSheets].dwSize      = sizeof(PROPSHEETPAGE);
398            pspages[maxPropSheets].dwFlags     = 0;
399            pspages[maxPropSheets].hInstance   = hInst;
400            pspages[maxPropSheets].pszTemplate = MAKEINTRESOURCE(g_propSheets[i].dwDlgID);
401            pspages[maxPropSheets].pfnCallback = NULL;
402            pspages[maxPropSheets].lParam      = 0;
403            pspages[maxPropSheets].pfnDlgProc  = g_propSheets[i].pfnDlgProc;
404            maxPropSheets++;
405         }
406      }
407      else
408393      if ((gamedrv != NULL) || g_propSheets[i].bOnDefaultPage)
409394      {
410395         machine_config config(*gamedrv);
411
396         
412397         if (!gamedrv || !g_propSheets[i].pfnFilterProc || g_propSheets[i].pfnFilterProc(&config, gamedrv))
413398         {
414399            pspages[maxPropSheets].dwSize      = sizeof(PROPSHEETPAGE);
r9146r9147
422407         }
423408      }
424409   }
425
410   
426411   if (pnMaxPropSheets)
427412      *pnMaxPropSheets = maxPropSheets;
428413
src/emu/devcb.h
r9146r9147
6161    MACROS
6262***************************************************************************/
6363
64// static template for a read_line stub function that calls through a given READ_LINE_MEMBER
65template<class _Class, int (_Class::*_Function)()>
66int devcb_line_stub(device_t *device)
67{
68   _Class *target = downcast<_Class *>(device);
69   return (target->*_Function)();
70}
71
6472// static template for a read8 stub function that calls through a given READ8_MEMBER
6573template<class _Class, UINT8 (_Class::*_Function)(address_space &, offs_t, UINT8)>
6674UINT8 devcb_stub(device_t *device, offs_t offset)
r9146r9147
6977   return (target->*_Function)(*device->machine->m_nonspecific_space, offset, 0xff);
7078}
7179
80// static template for a write_line stub function that calls through a given WRITE_LINE_MEMBER
81template<class _Class, void (_Class::*_Function)(int state)>
82void devcb_line_stub(device_t *device, int state)
83{
84   _Class *target = downcast<_Class *>(device);
85   (target->*_Function)(state);
86}
87
7288// static template for a write8 stub function that calls through a given WRITE8_MEMBER
7389template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT8, UINT8)>
7490void devcb_stub(device_t *device, offs_t offset, UINT8 data)
r9146r9147
8096#define DEVCB_NULL                     { DEVCB_TYPE_NULL }
8197
8298/* standard line or read/write handlers with the calling device passed */
83#define DEVCB_LINE(func)               { DEVCB_TYPE_SELF, NULL, (func), NULL, NULL }
84#define DEVCB_LINE_GND                  { DEVCB_TYPE_SELF, NULL, devcb_line_gnd_r, NULL, NULL }
85#define DEVCB_LINE_VCC                  { DEVCB_TYPE_SELF, NULL, devcb_line_vcc_r, NULL, NULL }
86#define DEVCB_HANDLER(func)               { DEVCB_TYPE_SELF, NULL, NULL, (func), NULL }
99#define DEVCB_LINE(func)                  { DEVCB_TYPE_SELF, NULL, (func), NULL, NULL }
100#define DEVCB_LINE_MEMBER(func)               { DEVCB_TYPE_SELF, NULL, &devcb_line_stub<cls, &cls::memb>, NULL, NULL }
101#define DEVCB_LINE_GND                     { DEVCB_TYPE_SELF, NULL, devcb_line_gnd_r, NULL, NULL }
102#define DEVCB_LINE_VCC                     { DEVCB_TYPE_SELF, NULL, devcb_line_vcc_r, NULL, NULL }
103#define DEVCB_HANDLER(func)                  { DEVCB_TYPE_SELF, NULL, NULL, (func), NULL }
104#define DEVCB_MEMBER(cls,memb)               { DEVCB_TYPE_SELF, NULL, NULL, &devcb_stub<cls, &cls::memb>, NULL }
87105
88106/* line or read/write handlers for another device */
89#define DEVCB_DEVICE_LINE(tag,func)         { DEVCB_TYPE_DEVICE, tag, (func), NULL, NULL }
90#define DEVCB_DEVICE_HANDLER(tag,func)      { DEVCB_TYPE_DEVICE, tag, NULL, (func), NULL }
91#define DEVCB_DEVICE_MEMBER(tag,cls,memb)   { DEVCB_TYPE_DEVICE, tag, NULL, &devcb_stub<cls, &cls::memb>, NULL }
107#define DEVCB_DEVICE_LINE(tag,func)            { DEVCB_TYPE_DEVICE, tag, (func), NULL, NULL }
108#define DEVCB_DEVICE_LINE_MEMBER(tag,cls,memb)   { DEVCB_TYPE_DEVICE, tag, &devcb_line_stub<cls, &cls::memb>, NULL, NULL }
109#define DEVCB_DEVICE_HANDLER(tag,func)         { DEVCB_TYPE_DEVICE, tag, NULL, (func), NULL }
110#define DEVCB_DEVICE_MEMBER(tag,cls,memb)      { DEVCB_TYPE_DEVICE, tag, NULL, &devcb_stub<cls, &cls::memb>, NULL }
92111
93112/* read/write handlers for a given CPU's address space */
94113#define DEVCB_MEMORY_HANDLER(cpu,space,func) { DEVCB_TYPE_MEMORY(ADDRESS_SPACE_##space), (cpu), NULL, NULL, (func) }
r9146r9147
104123#define READ_LINE_DEVICE_HANDLER(name)      int  name(ATTR_UNUSED device_t *device)
105124#define WRITE_LINE_DEVICE_HANDLER(name)    void name(ATTR_UNUSED device_t *device, ATTR_UNUSED int state)
106125
126#define DECLARE_READ_LINE_MEMBER(name)      int  name()
127#define READ_LINE_MEMBER(name)            int  name()
128#define DECLARE_WRITE_LINE_MEMBER(name)    void name(ATTR_UNUSED int state)
129#define WRITE_LINE_MEMBER(name)             void name(ATTR_UNUSED int state)
130
107131/* macros for inline device handler initialization */
108132
109133#define MDRV_DEVICE_CONFIG_DEVCB_GENERIC(_access, _struct, _entry, _tag, _type, _linefunc, _devfunc, _spacefunc) \
src/emu/devintrf.c
r9146r9147
548548     m_baseconfig(config),
549549     m_unscaled_clock(config.m_clock),
550550     m_clock_scale(1.0),
551     m_attoseconds_per_clock((config.m_clock == 0) ? 0 : HZ_TO_ATTOSECONDS(config.m_clock))
551     m_attoseconds_per_clock((config.m_clock == 0) ? 0 : HZ_TO_ATTOSECONDS(config.m_clock)),
552     m_auto_finder_list(NULL)
552553{
553554}
554555
r9146r9147
692693   // populate the region field
693694   m_region = m_machine.region(tag());
694695
696   // find all the registered devices
697   for (auto_finder_base *autodev = m_auto_finder_list; autodev != NULL; autodev = autodev->m_next)
698      autodev->findit(*this);
699
695700   // let the interfaces do their pre-work
696701   for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next())
697702      intf->interface_pre_start();
r9146r9147
864869
865870
866871//-------------------------------------------------
872//  device_timer - called whenever a device timer
873//  fires
874//-------------------------------------------------
875
876void device_t::device_timer(emu_timer &timer, int param, void *ptr)
877{
878   // do nothing by default
879}
880
881
882//-------------------------------------------------
867883//  notify_clock_changed - notify all interfaces
868884//  that the clock has changed
869885//-------------------------------------------------
r9146r9147
877893   // then notify the device
878894   device_clock_changed();
879895}
896
897
898//-------------------------------------------------
899//  register_auto_finder - add a new item to the
900//  list of stuff to find after we go live
901//-------------------------------------------------
902
903void device_t::register_auto_finder(auto_finder_base &autodev)
904{
905   // add to this list
906   autodev.m_next = m_auto_finder_list;
907   m_auto_finder_list = &autodev;
908}
909
910
911//-------------------------------------------------
912//  auto_finder_base - constructor
913//-------------------------------------------------
914
915device_t::auto_finder_base::auto_finder_base(device_t &base, const char *tag)
916   : m_next(NULL),
917     m_tag(tag)
918{
919   // register ourselves with our device class
920   base.register_auto_finder(*this);
921}
922
923
924//-------------------------------------------------
925//  ~auto_finder_base - destructor
926//-------------------------------------------------
927
928device_t::auto_finder_base::~auto_finder_base()
929{
930}
931
932
933//-------------------------------------------------
934//  find_device - find a device; done here instead
935//  of inline in the template due to include
936//  dependency ordering
937//-------------------------------------------------
938
939device_t *device_t::auto_finder_base::find_device(device_t &base, const char *tag)
940{
941   return base.subdevice(tag);
942}
943
944
945//-------------------------------------------------
946//  find_shared_ptr - find a shared pointer
947//-------------------------------------------------
948
949void *device_t::auto_finder_base::find_shared_ptr(device_t &base, const char *tag)
950{
951   return memory_get_shared(*base.machine, tag);
952}
953
954
955//-------------------------------------------------
956//  find_shared_size - find a shared pointer size
957//-------------------------------------------------
958
959size_t device_t::auto_finder_base::find_shared_size(device_t &base, const char *tag)
960{
961   size_t result = 0;
962   memory_get_shared(*base.machine, tag, result);
963   return result;
964}
src/emu/devintrf.h
r9146r9147
126126class device_state_interface;
127127struct rom_entry;
128128class machine_config;
129class emu_timer;
129130
130131
131132// exception classes
r9146r9147
405406   const region_info *subregion(const char *tag) const;
406407   device_t *subdevice(const char *tag) const;
407408   device_t *siblingdevice(const char *tag) const;
409   template<class T> inline T *subdevice(const char *tag) { return downcast<T *>(subdevice(tag)); }
410   template<class T> inline T *siblingdevice(const char *tag) { return downcast<T *>(siblingdevice(tag)); }
408411
409412   // configuration helpers
410413   const device_config &baseconfig() const { return m_baseconfig; }
r9146r9147
422425   void set_clock_scale(double clockscale);
423426   attotime clocks_to_attotime(UINT64 clocks) const;
424427   UINT64 attotime_to_clocks(attotime duration) const;
428   void timer_fired(emu_timer &timer, int param, void *ptr) { device_timer(timer, param, ptr); }
425429
426430   // debugging
427431   device_debug *debug() const { return m_debug; }
r9146r9147
456460   virtual void device_post_load();
457461   virtual void device_clock_changed();
458462   virtual void device_debug_setup();
463   virtual void device_timer(emu_timer &timer, int param, void *ptr);
459464
460465   //------------------- end derived class overrides
461466
r9146r9147
480485   UINT32               m_unscaled_clock;      // unscaled clock
481486   double               m_clock_scale;         // clock scale factor
482487   attoseconds_t         m_attoseconds_per_clock;// period in attoseconds
488
489   // helper class to request auto-object discovery in the constructor of a derived class
490   class auto_finder_base
491   {
492   public:
493      // construction/destruction
494      auto_finder_base(device_t &base, const char *tag);
495      virtual ~auto_finder_base();
496
497      // getters
498      virtual void findit(device_t &base) = 0;
499     
500      // helpers
501      device_t *find_device(device_t &device, const char *tag);
502      void *find_shared_ptr(device_t &device, const char *tag);
503      size_t find_shared_size(device_t &device, const char *tag);
504   
505      // internal state
506      auto_finder_base *m_next;
507      const char *m_tag;
508   };
509
510   // templated version bound to a specific type
511   template<typename _TargetType, bool _Required>
512   class auto_finder_type : public auto_finder_base
513   {
514   public:
515      // construction/destruction
516      auto_finder_type(device_t &base, const char *tag)
517         : auto_finder_base(base, tag),
518           m_target(0) { }
519
520      // operators to make use transparent
521      operator _TargetType() { return m_target; }
522      operator _TargetType() const { return m_target; }
523      _TargetType operator->() { return m_target; }
524
525      // setter for setting the object
526      void set_target(_TargetType target)
527      {
528         m_target = target;
529         if (target == 0 && _Required)
530            throw emu_fatalerror("Unable to find required object '%s'", this->m_tag);
531      }
532
533      // internal state
534      _TargetType m_target;
535   };
536   
537   // optional device finder
538   template<class _DeviceClass>
539   class optional_device : public auto_finder_type<_DeviceClass *, false>
540   {
541   public:
542      optional_device(device_t &base, const char *tag) : auto_finder_type<_DeviceClass *, false>(base, tag) { }
543      virtual void findit(device_t &base) { set_target(downcast<_DeviceClass *>(find_device(base, this->m_tag))); }
544   };
545   
546   // required devices are similar but throw an error if they are not found
547   template<class _DeviceClass>
548   class required_device : public auto_finder_type<_DeviceClass *, true>
549   {
550   public:
551      required_device(device_t &base, const char *tag) : auto_finder_type<_DeviceClass *, true>(base, tag) { }
552      virtual void findit(device_t &base) { set_target(downcast<_DeviceClass *>(find_device(base, this->m_tag))); }
553   };
554   
555   // optional shared pointer finder
556   template<typename _PointerType>
557   class optional_shared_ptr : public auto_finder_type<_PointerType *, false>
558   {
559   public:
560      optional_shared_ptr(device_t &base, const char *tag) : auto_finder_type<_PointerType *, false>(base, tag) { }
561      virtual void findit(device_t &base) { set_target(reinterpret_cast<_PointerType *>(find_shared_ptr(base, this->m_tag))); }
562   };
563   
564   // required shared pointer finder
565   template<typename _PointerType>
566   class required_shared_ptr : public auto_finder_type<_PointerType *, true>
567   {
568   public:
569      required_shared_ptr(device_t &base, const char *tag) : auto_finder_type<_PointerType *, true>(base, tag) { }
570      virtual void findit(device_t &base) { set_target(reinterpret_cast<_PointerType *>(find_shared_ptr(base, this->m_tag))); }
571   };
572   
573   // optional shared pointer size finder
574   class optional_shared_size : public auto_finder_type<size_t, false>
575   {
576   public:
577      optional_shared_size(device_t &base, const char *tag) : auto_finder_type<size_t, false>(base, tag) { }
578      virtual void findit(device_t &base) { set_target(find_shared_size(base, this->m_tag)); }
579   };
580   
581   // required shared pointer size finder
582   class required_shared_size : public auto_finder_type<size_t, true>
583   {
584   public:
585      required_shared_size(device_t &base, const char *tag) : auto_finder_type<size_t, true>(base, tag) { }
586      virtual void findit(device_t &base) { set_target(find_shared_size(base, this->m_tag)); }
587   };
588   
589   // internal helpers
590   void register_auto_finder(auto_finder_base &autodev);
591
592   auto_finder_base *      m_auto_finder_list;
483593};
484594
485595
src/emu/machine.c
r9146r9147
11731173   if (next() != NULL)
11741174      throw device_missing_dependencies();
11751175
1176   // find all the registered devices
1177   for (auto_finder_base *autodev = m_auto_finder_list; autodev != NULL; autodev = autodev->m_next)
1178      autodev->findit(*this);
1179
11801176   // call the game-specific init
11811177   if (m_config.m_game->driver_init != NULL)
11821178      (*m_config.m_game->driver_init)(&m_machine);
r9146r9147
12111207}
12121208
12131209
1214//-------------------------------------------------
1215//  auto_finder_base - constructor
1216//-------------------------------------------------
12171210
1218void driver_device::register_auto_finder(auto_finder_base &autodev)
1219{
1220   // add to this list
1221   autodev.m_next = m_auto_finder_list;
1222   m_auto_finder_list = &autodev;
1223}
1224
1225
1226//-------------------------------------------------
1227//  auto_finder_base - constructor
1228//-------------------------------------------------
1229
1230driver_device::auto_finder_base::auto_finder_base(driver_device &base, const char *tag)
1231   : m_next(NULL),
1232     m_tag(tag)
1233{
1234   // register ourselves with our device class
1235   base.register_auto_finder(*this);
1236}
1237
1238
1239//-------------------------------------------------
1240//  ~auto_finder_base - destructor
1241//-------------------------------------------------
1242
1243driver_device::auto_finder_base::~auto_finder_base()
1244{
1245}
1246
1247
1248
12491211//**************************************************************************
12501212//  SYSTEM TIME
12511213//**************************************************************************
src/emu/sound/sound.mak
r9146r9147
7272                  $(SOUNDSRC)/disc_wav.c
7373
7474
75#-------------------------------------------------
76# Apple custom sound chips
77#-------------------------------------------------
7578
79ifneq ($(filter ASC,$(SOUNDS)),)
80SOUNDOBJS += $(SOUNDOBJ)/asc.o
81endif
82
83
84
7685#-------------------------------------------------
7786# Atari custom sound chips
7887#-------------------------------------------------
src/emu/sound/asc.c
r0r9147
1/***************************************************************************
2
3    asc.c
4
5    Apple Sound Chip (ASC) 344S0063
6    Enhanced Apple Sound Chip (EASC) 343S1063
7   
8    Emulation by R. Belmont
9
10***************************************************************************/
11
12#include "emu.h"
13#include "streams.h"
14#include "asc.h"
15
16//**************************************************************************
17//  GLOBAL VARIABLES
18//**************************************************************************
19
20//**************************************************************************
21//  DEVICE CONFIGURATION
22//**************************************************************************
23
24//-------------------------------------------------
25//  static_set_type - configuration helper to set
26//  the chip type
27//-------------------------------------------------
28
29void asc_device_config::static_set_type(device_config *device, int type)
30{
31   asc_device_config *asc = downcast<asc_device_config *>(device);
32   asc->m_type = type;
33}
34
35//-------------------------------------------------
36//  asc_device_config - constructor
37//-------------------------------------------------
38
39asc_device_config::asc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
40   : device_config(mconfig, static_alloc_device_config, "ASC", tag, owner, clock),
41     device_config_sound_interface(mconfig, *this)
42{
43}
44
45
46//-------------------------------------------------
47//  static_alloc_device_config - allocate a new
48//  configuration object
49//-------------------------------------------------
50
51device_config *asc_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
52{
53   return global_alloc(asc_device_config(mconfig, tag, owner, clock));
54}
55
56
57//-------------------------------------------------
58//  alloc_device - allocate a new device object
59//-------------------------------------------------
60
61device_t *asc_device_config::alloc_device(running_machine &machine) const
62{
63   return auto_alloc(&machine, asc_device(machine, *this));
64}
65
66//**************************************************************************
67//  LIVE DEVICE
68//**************************************************************************
69
70//-------------------------------------------------
71//  asc_device - constructor
72//-------------------------------------------------
73
74asc_device::asc_device(running_machine &_machine, const asc_device_config &config)
75   : device_t(_machine, config),
76     device_sound_interface(_machine, config, *this),
77     m_config(config),
78     m_chip_type(m_config.m_type)
79{
80}
81
82
83//-------------------------------------------------
84//  device_start - device-specific startup
85//-------------------------------------------------
86
87void asc_device::device_start()
88{
89   // create the stream
90   m_stream = stream_create(this, 0, 2, 22257, this, static_stream_generate);
91}
92
93
94//-------------------------------------------------
95//  device_reset - device-specific reset
96//-------------------------------------------------
97
98void asc_device::device_reset()
99{
100   stream_update(m_stream);
101}
102
103//-------------------------------------------------
104//  stream_generate - handle update requests for
105//  our sound stream
106//-------------------------------------------------
107
108STREAM_UPDATE( asc_device::static_stream_generate )
109{
110   reinterpret_cast<asc_device *>(param)->stream_generate(inputs, outputs, samples);
111}
112
113void asc_device::stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples)
114{
115   // reset the output stream
116   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
117}
118
119//-------------------------------------------------
120//  read - read from the chip's registers and internal RAM
121//-------------------------------------------------
122
123UINT8 asc_device::read(UINT16 offset)
124{
125   if (offset < 0x400)
126   {
127      return fifo_a[offset];
128   }
129   else if (offset < 0x800)
130   {
131      return fifo_b[offset-0x400];
132   }
133   else
134   {
135      switch (offset)
136      {
137         case 0x800:   // VERSION
138            switch (m_chip_type)
139            {
140               case ASC_TYPE_ASC:
141                  return 0;
142
143               case ASC_TYPE_V8:
144                  return 0xe8;
145
146               case ASC_TYPE_SONORA:
147                  return 0xbc;
148
149               default:
150                  return 0;
151            }
152            break;
153
154         case 0x804:   // FIFO Interrupt Status
155            if (m_chip_type == ASC_TYPE_V8)
156            {
157               return 3;
158            }
159            break;
160
161         default:
162            break;
163      }
164   }
165
166   return regs[offset-0x800];
167}
168
169//-------------------------------------------------
170//  write - write to the chip's registers and internal RAM
171//-------------------------------------------------
172
173void asc_device::write(UINT16 offset, UINT8 data)
174{
175   if (offset < 0x400)
176   {
177      fifo_a[offset] = data;
178   }
179   else if (offset < 0x800)
180   {
181      fifo_b[offset-0x400] = data;
182   }
183   else
184   {
185      regs[offset-0x800] = data;
186   }
187}
188
189const device_type ASC = asc_device_config::static_alloc_device_config;
190
src/emu/sound/asc.h
r0r9147
1/***************************************************************************
2
3    asc.h
4
5    Apple Sound Chip (ASC) 344S0063
6    Enhanced Apple Sound Chip (EASC) 343S1063
7
8***************************************************************************/
9
10#pragma once
11
12#ifndef __ASC_H__
13#define __ASC_H__
14
15#include "streams.h"
16
17
18
19//**************************************************************************
20//  CONSTANTS
21//**************************************************************************
22
23// chip behavior types
24enum
25{
26   ASC_TYPE_ASC = 0,   // original discrete Apple Sound Chip
27   ASC_TYPE_EASC = 1,   // discrete Enhanced Apple Sound Chip
28   ASC_TYPE_V8 = 2,   // Subset of ASC included in the V8 ASIC (LC/LCII)
29   ASC_TYPE_EAGLE = 3,   // Subset of ASC included in the Eagle ASIC (Classic II)
30   ASC_TYPE_SPICE = 4,   // Subset of ASC included in the Spice ASIC (Color Classic)
31   ASC_TYPE_SONORA = 5,   // Subset of ASC included in the Sonora ASIC (LCIII)
32   ASC_TYPE_VASP = 6,   // Subset of ASC included in the VASP ASIC  (IIvx/IIvi)
33   ASC_TYPE_ARDBEG = 7   // Subset of ASC included in the Ardbeg ASIC (LC520)
34};
35
36
37
38//**************************************************************************
39//  INTERFACE CONFIGURATION MACROS
40//**************************************************************************
41
42#define MDRV_ASC_ADD(_tag, _clock, _type) \
43   MDRV_DEVICE_ADD(_tag, ASC, _clock) \
44   MDRV_ASC_TYPE(_type)
45
46#define MDRV_ASC_REPLACE(_tag, _clock, _type) \
47   MDRV_DEVICE_REPLACE(_tag, ASC, _clock) \
48   MDRV_ASC_TYPE(_type)
49
50#define MDRV_ASC_TYPE(_type) \
51   asc_device_config::static_set_type(device, _type); \
52
53
54
55//**************************************************************************
56//  TYPE DEFINITIONS
57//**************************************************************************
58
59// ======================> asc_device_config
60
61class asc_device_config :   public device_config, public device_config_sound_interface
62{
63   friend class asc_device;
64
65   // construction/destruction
66   asc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
67
68public:
69   // allocators
70   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
71   virtual device_t *alloc_device(running_machine &machine) const;
72
73   // inline configuration helpers
74   static void static_set_type(device_config *device, int type);
75
76protected:
77   // device_config overrides
78   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
79
80   // internal state
81   const address_space_config  m_space_config;
82
83   // inline data
84   UINT8                  m_type;
85};
86
87
88
89// ======================> asc_device
90
91class asc_device : public device_t, public device_sound_interface
92{
93   friend class asc_device_config;
94
95   // construction/destruction
96   asc_device(running_machine &_machine, const asc_device_config &config);
97
98public:
99   UINT8 read(UINT16 offset);
100   void write(UINT16 offset, UINT8 data);
101
102protected:
103   // device-level overrides
104   virtual void device_start();
105   virtual void device_reset();
106
107   // internal callbacks
108   static STREAM_UPDATE( static_stream_generate );
109   virtual void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples);
110
111   // internal state
112   const asc_device_config &m_config;
113
114   UINT8   m_chip_type;
115   sound_stream *m_stream;
116
117   UINT8   fifo_a[0x400];
118   UINT8   fifo_b[0x400];
119
120   UINT8   regs[0x100];
121};
122
123
124// device type definition
125extern const device_type ASC;
126
127
128#endif /* __ASC_H__ */
129
src/emu/machine.h
r9146r9147
628628   virtual void device_start();
629629   virtual void device_reset();
630630   
631   // helper class to request auto-object discovery in the constructor of a derived class
632   class auto_finder_base
633   {
634   public:
635      // construction/destruction
636      auto_finder_base(driver_device &base, const char *tag);
637      virtual ~auto_finder_base();
638
639      // getters
640      virtual void findit(driver_device &base) = 0;
641   
642      // internal state
643      auto_finder_base *m_next;
644      const char *m_tag;
645   };
646
647   // templated version bound to a specific type
648   template<typename _TargetType, bool _Required>
649   class auto_finder_type : public auto_finder_base
650   {
651   public:
652      // construction/destruction
653      auto_finder_type(driver_device &base, const char *tag)
654         : auto_finder_base(base, tag),
655           m_target(NULL) { }
656
657      // operators to make use transparent
658      operator _TargetType() { return m_target; }
659      operator _TargetType() const { return m_target; }
660      _TargetType operator->() { return m_target; }
661
662      // setter for setting the object
663      void set_target(_TargetType target)
664      {
665         m_target = target;
666         if (target == 0 && _Required)
667            throw emu_fatalerror("Unable to find required object '%s'", this->m_tag);
668      }
669
670      // internal state
671      _TargetType m_target;
672   };
673   
674   // optional device finder
675   template<class _DeviceClass>
676   class optional_device : public auto_finder_type<_DeviceClass *, false>
677   {
678   public:
679      optional_device(driver_device &base, const char *tag) : auto_finder_type<_DeviceClass *, false>(base, tag) { }
680      virtual void findit(driver_device &base) { set_target(base.m_machine.device<_DeviceClass>(this->m_tag)); }
681   };
682   
683   // required devices are similar but throw an error if they are not found
684   template<class _DeviceClass>
685   class required_device : public auto_finder_type<_DeviceClass *, true>
686   {
687   public:
688      required_device(driver_device &base, const char *tag) : auto_finder_type<_DeviceClass *, true>(base, tag) { }
689      virtual void findit(driver_device &base) { set_target(base.m_machine.device<_DeviceClass>(this->m_tag)); }
690   };
691   
692   // optional shared pointer finder
693   template<typename _PointerType>
694   class optional_shared_ptr : public auto_finder_type<_PointerType *, false>
695   {
696   public:
697      optional_shared_ptr(driver_device &base, const char *tag) : auto_finder_type<_PointerType *, false>(base, tag) { }
698      virtual void findit(driver_device &base) { set_target(reinterpret_cast<_PointerType *>(memory_get_shared(base.m_machine, this->m_tag))); }
699   };
700   
701   // required shared pointer finder
702   template<typename _PointerType>
703   class required_shared_ptr : public auto_finder_type<_PointerType *, true>
704   {
705   public:
706      required_shared_ptr(driver_device &base, const char *tag) : auto_finder_type<_PointerType *, true>(base, tag) { }
707      virtual void findit(driver_device &base) { set_target(reinterpret_cast<_PointerType *>(memory_get_shared(base.m_machine, this->m_tag))); }
708   };
709   
710   // optional shared pointer size finder
711   class optional_shared_size : public auto_finder_type<size_t, false>
712   {
713   public:
714      optional_shared_size(driver_device &base, const char *tag) : auto_finder_type<size_t, false>(base, tag) { }
715      virtual void findit(driver_device &base) { size_t size; memory_get_shared(base.m_machine, this->m_tag, size); set_target(size); }
716   };
717   
718   // required shared pointer size finder
719   class required_shared_size : public auto_finder_type<size_t, true>
720   {
721   public:
722      required_shared_size(driver_device &base, const char *tag) : auto_finder_type<size_t, true>(base, tag) { }
723      virtual void findit(driver_device &base) { size_t size; memory_get_shared(base.m_machine, this->m_tag, size); set_target(size); }
724   };
725   
726   // internal helpers
727   void register_auto_finder(auto_finder_base &autodev);
728
729631   // internal state
730632   const driver_device_config_base &m_config;
731   auto_finder_base *m_auto_finder_list;
732633};
733634
734635
src/emu/memory.c
r9146r9147
280280   memory_block *         m_next;               // next memory block in the list
281281   running_machine &      m_machine;            // need the machine to free our memory
282282   address_space &         m_space;            // which address space are we associated with?
283   bool               m_isallocated;         // did we allocate this ourselves?
284283   offs_t               m_bytestart, m_byteend;   // byte-normalized start/end for verifying a match
285284   UINT8 *               m_data;               // pointer to the data for this block
285   UINT8 *               m_allocated;         // pointer to the actually allocated block
286286};
287287
288288
r9146r9147
19611961      // if we have a share entry, add it to our map
19621962      if (entry->m_share != NULL && m_machine.memory_data->sharemap.find(entry->m_share) == NULL)
19631963      {
1964         VPRINTF(("Creating share '%s' of length 0x%X\n", entry->m_share, entry->m_byteend + 1 - entry->m_bytestart));
19641965         memory_share *share = auto_alloc(&m_machine, memory_share(entry->m_byteend + 1 - entry->m_bytestart));
19651966         m_machine.memory_data->sharemap.add(entry->m_share, share, false);
19661967      }
r9146r9147
23262327            entry->m_memory = share->ptr();
23272328            VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' [%p]\n", entry->m_addrstart, entry->m_addrend, entry->m_share, entry->m_memory));
23282329         }
2330         else
2331         {
2332            VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' but not found\n", entry->m_addrstart, entry->m_addrend, entry->m_share));
2333         }
23292334      }
23302335
23312336      // otherwise, look for a match in this block
r9146r9147
23402345      {
23412346         memory_share *share = memdata->sharemap.find(entry->m_share);
23422347         if (share != NULL && share->ptr() == NULL)
2348         {
23432349            share->set_ptr(entry->m_memory);
2350            VPRINTF(("setting shared_ptr '%s' = %p\n", entry->m_share, entry->m_memory));
2351         }
23442352      }
23452353
23462354      // keep track of the first unassigned entry
r9146r9147
40534061   : m_next(NULL),
40544062     m_machine(space.m_machine),
40554063     m_space(space),
4056     m_isallocated(memory == NULL),
40574064     m_bytestart(bytestart),
40584065     m_byteend(byteend),
4059     m_data((memory != NULL) ? reinterpret_cast<UINT8 *>(memory) : auto_alloc_array_clear(&space.m_machine, UINT8, byteend + 1 - bytestart))
4066     m_data(reinterpret_cast<UINT8 *>(memory)),
4067     m_allocated(NULL)
40604068{
40614069   VPRINTF(("block_allocate('%s',%s,%08X,%08X,%p)\n", space.device().tag(), space.name(), bytestart, byteend, memory));
40624070
4071   // allocate a block if needed
4072   if (m_data == NULL)
4073   {
4074      offs_t length = byteend + 1 - bytestart;
4075      if (length < 4096)
4076         m_allocated = m_data = auto_alloc_array_clear(&space.m_machine, UINT8, length);
4077      else
4078      {
4079         m_allocated = auto_alloc_array_clear(&space.m_machine, UINT8, length + 0xfff);
4080         m_data = reinterpret_cast<UINT8 *>((reinterpret_cast<FPTR>(m_allocated) + 0xfff) & ~0xfff);
4081      }
4082   }
4083
40634084   // register for saving, but only if we're not part of a memory region
40644085   const region_info *region;
40654086   for (region = space.m_machine.m_regionlist.first(); region != NULL; region = region->next())
r9146r9147
40864107
40874108memory_block::~memory_block()
40884109{
4089   if (m_isallocated)
4090      auto_free(&m_machine, m_data);
4110   if (m_allocated != NULL)
4111      auto_free(&m_machine, m_allocated);
40914112}
40924113
40934114
r9146r9147
43534374   // compute the maximum possible subunits
43544375   int maxunits = m_datawidth / handlerbits;
43554376   assert(maxunits > 1);
4356   assert(maxunits < ARRAY_LENGTH(m_subshift));
4377   assert(maxunits <= ARRAY_LENGTH(m_subshift));
43574378
43584379   // walk the handlermask to find out how many we have
43594380   m_subunits = 0;
src/emu/machine/6522via.c
r9146r9147
218218    m_t2ll = 0xff; /* taken from vice */
219219    m_t2lh = 0xff;
220220    m_time2 = m_time1 = timer_get_time(&m_machine);
221    m_t1 = timer_alloc(&m_machine, t1_timeout_callback, (void *)this);
222    m_t2 = timer_alloc(&m_machine, t2_timeout_callback, (void *)this);
223    m_shift_timer = timer_alloc(&m_machine, shift_callback, (void *)this);
221    m_t1 = device_timer_alloc(*this);
222    m_t2 = device_timer_alloc(*this);
223    m_shift_timer = device_timer_alloc(*this);
224224
225225   /* Default clock is from CPU1 */
226226   if (clock() == 0)
r9146r9147
415415}
416416
417417
418/*-------------------------------------------------
419    TIMER_CALLBACK( via_shift_callback )
420-------------------------------------------------*/
421
422TIMER_CALLBACK( via6522_device::shift_callback )
418void via6522_device::device_timer(emu_timer &timer, int param, void *ptr)
423419{
424    via6522_device *via = reinterpret_cast<via6522_device *>(ptr);
425    via->shift();
426}
427
428
429/*-------------------------------------------------
430    TIMER_CALLBACK( via_t1_timeout )
431-------------------------------------------------*/
432
433TIMER_CALLBACK( via6522_device::t1_timeout_callback )
434{
435    via6522_device *via = reinterpret_cast<via6522_device *>(ptr);
436    via->t1_timeout();
437}
438
439void via6522_device::t1_timeout()
440{
441    if (T1_CONTINUOUS (m_acr))
442    {
443        if (T1_SET_PB7(m_acr))
444        {
445            m_out_b ^= 0x80;
446        }
447        timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0);
448    }
449   else
450    {
451        if (T1_SET_PB7(m_acr))
452        {
453            m_out_b |= 0x80;
454        }
455        m_t1_active = 0;
456        m_time1 = timer_get_time(&m_machine);
457    }
458    if (m_ddr_b)
420   // shift timer
421   if (&timer == m_shift_timer)
422      shift();
423   
424   // t1 timeout
425   else if (&timer == m_t1)
459426   {
460        UINT8 write_data = (m_out_b & m_ddr_b) | (m_ddr_b ^ 0xff);
461        devcb_call_write8(&m_out_b_func, 0, write_data);
427       if (T1_CONTINUOUS (m_acr))
428       {
429           if (T1_SET_PB7(m_acr))
430           {
431               m_out_b ^= 0x80;
432           }
433           timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0);
434       }
435      else
436       {
437           if (T1_SET_PB7(m_acr))
438           {
439               m_out_b |= 0x80;
440           }
441           m_t1_active = 0;
442           m_time1 = timer_get_time(&m_machine);
443       }
444       if (m_ddr_b)
445      {
446           UINT8 write_data = (m_out_b & m_ddr_b) | (m_ddr_b ^ 0xff);
447           devcb_call_write8(&m_out_b_func, 0, write_data);
448      }
449
450       if (!(m_ifr & INT_T1))
451       {
452         set_int(INT_T1);
453       }
462454   }
455   
456   // t2 timeout
457   else if (&timer == m_t2)
458   {
459       m_t2_active = 0;
460       m_time2 = timer_get_time(&m_machine);
463461
464    if (!(m_ifr & INT_T1))
465    {
466      set_int(INT_T1);
467    }
462       if (!(m_ifr & INT_T2))
463       {
464         set_int(INT_T2);
465       }
466   }
468467}
469468
470
471469/*-------------------------------------------------
472    TIMER_CALLBACK( via_t2_timeout )
473-------------------------------------------------*/
474
475TIMER_CALLBACK( via6522_device::t2_timeout_callback )
476{
477    via6522_device *via = reinterpret_cast<via6522_device *>(ptr);
478    via->t2_timeout();
479}
480
481void via6522_device::t2_timeout()
482{
483    m_t2_active = 0;
484    m_time2 = timer_get_time(&m_machine);
485
486    if (!(m_ifr & INT_T2))
487    {
488      set_int(INT_T2);
489    }
490}
491
492
493/*-------------------------------------------------
494470    via_r - CPU interface for VIA read
495471-------------------------------------------------*/
496472
497READ8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_r)
473READ8_MEMBER( via6522_device::read )
498474{
499475   int val = 0;
500476
r9146r9147
652628
653629    case VIA_SR:
654630      val = m_sr;
631      m_shift_counter=0;
655632      clear_int(INT_SR);
656633      if (SO_O2_CONTROL(m_acr))
657634      {
658         m_shift_counter=0;
659635         timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0);
660636      }
661637      if (SO_T2_CONTROL(m_acr))
662638      {
663         m_shift_counter=0;
664639         timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0);
665640      }
666641      break;
r9146r9147
689664    via_w - CPU interface for VIA write
690665-------------------------------------------------*/
691666
692WRITE8_DEVICE_HANDLER_TRAMPOLINE(via6522, via_w)
667WRITE8_MEMBER( via6522_device::write )
693668{
694669   offset &=0x0f;
695670
r9146r9147
858833      clear_int(INT_SR);
859834      if (SO_O2_CONTROL(m_acr))
860835      {
861         timer_set(&m_machine, cycles_to_time(2), (void *)this, 0, shift_callback);
836         timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0);
862837      }
863838      if (SO_T2_CONTROL(m_acr))
864839      {
865         timer_set(&m_machine, cycles_to_time((m_t2ll + 2)*2), (void *)this, 0, shift_callback);
840         timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0);
866841      }
867842      break;
868843
r9146r9147
959934    ca1_w - interface setting VIA port CA1 input
960935-------------------------------------------------*/
961936
962//void via6522_device::via_ca1_w(UINT8 state)
963WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_ca1_w)
937WRITE_LINE_MEMBER( via6522_device::write_ca1 )
964938{
965939   /* handle the active transition */
966940   if (state != m_in_ca1)
r9146r9147
1008982    ca2_w - interface setting VIA port CA2 input
1009983-------------------------------------------------*/
1010984
1011//void via6522_device::via_ca2_w(UINT8 state)
1012WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_ca2_w)
985WRITE_LINE_MEMBER( via6522_device::write_ca2 )
1013986{
1014987   /* CA2 is in input mode */
1015988   if (CA2_INPUT(m_pcr))
r9146r9147
10341007    cb1_w - interface setting VIA port CB1 input
10351008-------------------------------------------------*/
10361009
1037//void via6522_device::via_cb1_w(UINT8 state)
1038WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_cb1_w)
1010WRITE_LINE_MEMBER( via6522_device::write_cb1 )
10391011{
10401012   /* handle the active transition */
10411013   if (state != m_in_cb1)
r9146r9147
10831055    cb2_w - interface setting VIA port CB2 input
10841056-------------------------------------------------*/
10851057
1086//void via6522_device::via_cb2_w(UINT8 state)
1087WRITE_LINE_DEVICE_HANDLER_TRAMPOLINE(via6522, via_cb2_w)
1058WRITE_LINE_MEMBER( via6522_device::write_cb2 )
10881059{
10891060   /* CB2 is in input mode */
10901061   if (CB2_INPUT(m_pcr))
r9146r9147
11031074      }
11041075    }
11051076}
1106
1107
1108
1109/***************************************************************************
1110    TRAMPOLINES
1111***************************************************************************/
1112
1113READ_LINE_DEVICE_HANDLER(via_ca1_r) { return downcast<via6522_device *>(device)->via_ca1_r(); }
1114READ_LINE_DEVICE_HANDLER(via_ca2_r) { return downcast<via6522_device *>(device)->via_ca2_r(); }
1115READ_LINE_DEVICE_HANDLER(via_cb1_r) { return downcast<via6522_device *>(device)->via_cb1_r(); }
1116READ_LINE_DEVICE_HANDLER(via_cb2_r) { return downcast<via6522_device *>(device)->via_cb2_r(); }
1117WRITE8_DEVICE_HANDLER(via_porta_w) { downcast<via6522_device *>(device)->via_porta_w(data); }
1118READ8_DEVICE_HANDLER(via_portb_r) { return downcast<via6522_device *>(device)->via_portb_r(); }
1119WRITE8_DEVICE_HANDLER(via_portb_w) { downcast<via6522_device *>(device)->via_portb_w(data); }
src/emu/machine/6522via.h
r9146r9147
109109    via6522_device(running_machine &_machine, const via6522_device_config &_config);
110110
111111public:
112    UINT8 via_r(UINT32 offset);
113    void via_w(UINT32 offset, UINT8 data);
112    DECLARE_READ8_MEMBER( read );
113    DECLARE_WRITE8_MEMBER( write );
114114
115    void via_porta_w(UINT8 data) { m_in_a = data; }
115    DECLARE_WRITE8_MEMBER( write_porta ) { m_in_a = data; }
116116
117    UINT8 via_portb_r() { return m_in_b; }
118    void via_portb_w(UINT8 data) { m_in_b = data; }
117    DECLARE_READ8_MEMBER( read_portb ) { return m_in_b; }
118    DECLARE_WRITE8_MEMBER( write_portb ) { m_in_b = data; }
119119
120    UINT8 via_ca1_r() { return m_in_ca1; }
121    void via_ca1_w(UINT8 data);
120    DECLARE_READ_LINE_MEMBER( read_ca1 ) { return m_in_ca1; }
121    DECLARE_WRITE_LINE_MEMBER( write_ca1 );
122122
123    UINT8 via_ca2_r() { return m_in_ca2; }
124    void via_ca2_w(UINT8 data);
123    DECLARE_READ_LINE_MEMBER( read_ca2 ) { return m_in_ca2; }
124    DECLARE_WRITE_LINE_MEMBER( write_ca2 );
125125
126    UINT8 via_cb1_r() { return m_in_cb1; }
127    void via_cb1_w(UINT8 data);
126    DECLARE_READ_LINE_MEMBER( read_cb1 ) { return m_in_cb1; }
127    DECLARE_WRITE_LINE_MEMBER( write_cb1 );
128128
129    UINT8 via_cb2_r() { return m_in_cb2; }
130    void via_cb2_w(UINT8 data);
129    DECLARE_READ_LINE_MEMBER( read_cb2 ) { return m_in_cb2; }
130    DECLARE_WRITE_LINE_MEMBER( write_cb2 );
131131
132132protected:
133133    // device-level overrides
134134    virtual void device_start();
135135    virtual void device_reset();
136    virtual void device_post_load() { }
137    virtual void device_clock_changed() { }
136   virtual void device_timer(emu_timer &timer, int param, void *ptr);
138137
139    static TIMER_CALLBACK( t1_timeout_callback );
140    static TIMER_CALLBACK( t2_timeout_callback );
141    static TIMER_CALLBACK( shift_callback );
142
143138private:
144139    attotime cycles_to_time(int c);
145140    UINT32 time_to_cycles(attotime t);
r9146r9147
148143    void set_int(int data);
149144    void clear_int(int data);
150145    void shift();
151    void t1_timeout();
152    void t2_timeout();
153146
154147    devcb_resolved_read8 m_in_a_func;
155148    devcb_resolved_read8 m_in_b_func;
r9146r9147
212205extern const device_type VIA6522;
213206
214207
215
216/***************************************************************************
217    PROTOTYPES
218***************************************************************************/
219
220READ8_DEVICE_HANDLER(via_r);
221WRITE8_DEVICE_HANDLER(via_w);
222
223WRITE8_DEVICE_HANDLER(via_porta_w);
224
225READ8_DEVICE_HANDLER(via_portb_r);
226WRITE8_DEVICE_HANDLER(via_portb_w);
227
228READ_LINE_DEVICE_HANDLER(via_ca1_r);
229WRITE_LINE_DEVICE_HANDLER(via_ca1_w);
230
231READ_LINE_DEVICE_HANDLER(via_ca2_r);
232WRITE_LINE_DEVICE_HANDLER(via_ca2_w);
233
234READ_LINE_DEVICE_HANDLER(via_cb1_r);
235WRITE_LINE_DEVICE_HANDLER(via_cb1_w);
236
237READ_LINE_DEVICE_HANDLER(via_cb2_r);
238WRITE_LINE_DEVICE_HANDLER(via_cb2_w);
239
240208#endif /* __6522VIA_H__ */
src/emu/emucore.h
r9146r9147
303303      : code(_exitcode)
304304   {
305305      vsprintf(text, format, ap);
306      osd_break_into_debugger(text);
307306   }
308307
309308   const char *string() const { return text; }
src/emu/timer.c
r9146r9147
5656   attotime            period;         /* the repeat frequency of the timer */
5757   attotime            start;         /* time when the timer was started */
5858   attotime            expire;         /* time when the timer will expire */
59   device_t *            device;         /* for device timers, a pointer to the device */
5960};
6061
6162
r9146r9147
368369      global->callback_timer_expire_time = timer->expire;
369370
370371      /* call the callback */
371      if (was_enabled && timer->callback != NULL)
372      if (was_enabled)
372373      {
373         LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
374         g_profiler.start(PROFILER_TIMER_CALLBACK);
375         (*timer->callback)(machine, timer->ptr, timer->param);
376         g_profiler.stop();
374         if (timer->device != NULL)
375            timer->device->timer_fired(*timer, timer->param, timer->ptr);
376         else if (timer->callback != NULL)
377         {
378            LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
379            g_profiler.start(PROFILER_TIMER_CALLBACK);
380            (*timer->callback)(machine, timer->ptr, timer->param);
381            g_profiler.stop();
382         }
377383      }
378384
379385      /* clear the callback timer global */
r9146r9147
603609   timer->file = file;
604610   timer->line = line;
605611   timer->func = func;
612   timer->device = NULL;
606613
607614   /* compute the time of the next firing and insert into the list */
608615   timer->start = time;
r9146r9147
626633   return _timer_alloc_common(machine, callback, ptr, file, line, func, FALSE);
627634}
628635
636emu_timer *device_timer_alloc(device_t &device, void *ptr, int param)
637{
638   emu_timer *timer = _timer_alloc_common(device.machine, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE);
639   timer->param = param;
640   timer->device = &device;
641   return timer;
642}
629643
644
630645/*-------------------------------------------------
631646    timer_remove - remove a timer from the
632647    system
src/emu/timer.h
r9146r9147
6363typedef void (*timer_device_fired_func)(timer_device &timer, void *ptr, INT32 param);
6464
6565
66
67
6866struct timer_execution_state
6967{
7068   attotime            nextfire;      /* time that the head of the timer list will fire */
r9146r9147
150148/* allocate a permament timer that isn't primed yet */
151149emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func callback, void *param, const char *file, int line, const char *func);
152150
151/* allocate a permament device timer that isn't primed yet */
152emu_timer *device_timer_alloc(device_t &device, void *ptr = NULL, int param = 0);
153
153154/* adjust the time when this timer will fire and disable any periodic firings */
154155void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param);
155156
src/emu/mconfig.h
r9146r9147
114114
115115
116116
117// ======================> address_map_entry
117// ======================> machine_config
118118
119119// machine configuration definition
120120class machine_config
src/mess/machine/apple3.c
r9146r9147
263263
264264INTERRUPT_GEN( apple3_interrupt )
265265{
266   running_device *via_1 = device->machine->device("via6522_1");
266   via6522_device *via_1 = device->machine->device<via6522_device>("via6522_1");
267267
268   via_ca2_w(via_1, (AY3600_keydata_strobe_r() & 0x80) ? 1 : 0);
269   via_cb1_w(via_1, device->machine->primary_screen->vblank());
270   via_cb2_w(via_1, device->machine->primary_screen->vblank());
268   via_1->write_ca2((AY3600_keydata_strobe_r() & 0x80) ? 1 : 0);
269   via_1->write_cb1(device->machine->primary_screen->vblank());
270   via_1->write_cb2(device->machine->primary_screen->vblank());
271271}
272272
273273
r9146r9147
459459   {
460460      running_device *via_0 = space->machine->device("via6522_0");
461461      running_device *via_1 = space->machine->device("via6522_1");
462      memory_install_read8_device_handler(space, via_0, 0xFFD0, 0xFFDF, 0, 0, via_r);
463      memory_install_write8_device_handler(space, via_0, 0xFFD0, 0xFFDF, 0, 0, via_w);
464      memory_install_read8_device_handler(space, via_1, 0xFFE0, 0xFFEF, 0, 0, via_r);
465      memory_install_write8_device_handler(space, via_1, 0xFFE0, 0xFFEF, 0, 0, via_w);
462
463        space->install_handler(0xFFD0, 0xFFDF, 0, 0, read8_delegate_create(via6522_device, read, *via_0), write8_delegate_create(via6522_device, write, *via_0));
464      space->install_handler(0xFFE0, 0xFFEF, 0, 0, read8_delegate_create(via6522_device, read, *via_1), write8_delegate_create(via6522_device, write, *via_1));
466465   }
467466}
468467
src/mess/machine/aim65.c
r9146r9147
168168
169169MACHINE_START( aim65 )
170170{
171   running_device *via_0 = machine->device("via6522_0");
171   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
172172   running_device *ram = machine->device("messram");
173173   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
174174
175175   /* Init RAM */
176176   memory_install_ram(space, 0x0000, messram_get_size(ram) - 1, 0, 0, messram_get_ptr(ram));
177177
178   via_cb1_w(via_0, 1);
179   via_ca1_w(via_0, 0);
178   via_0->write_cb1(1);
179   via_0->write_ca1(0);
180180}
181181
182182
src/mess/machine/vic1112.c
r9146r9147
3131   int via1_irq;                  /* VIA #1 interrupt request */
3232
3333   /* devices */
34   running_device *via0;
35   running_device *via1;
36   running_device *bus;
34   via6522_device *via0;
35   via6522_device *via1;
36   via6522_device *bus;
3737};
3838
3939/***************************************************************************
r9146r9147
6767{
6868   vic1112_t *vic1112 = get_safe_token(device);
6969
70   via_cb1_w(vic1112->bus, state);
70   vic1112->bus->write_cb1(state);
7171}
7272
7373/*-------------------------------------------------
r9146r9147
298298   address_space *program = cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM);
299299
300300   /* find devices */
301   vic1112->via0 = device->subdevice(M6522_0_TAG);
302   vic1112->via1 = device->subdevice(M6522_1_TAG);
303   vic1112->bus = device->machine->device(config->bus_tag);
301   vic1112->via0 = device->subdevice<via6522_device>(M6522_0_TAG);
302   vic1112->via1 = device->subdevice<via6522_device>(M6522_1_TAG);
303   vic1112->bus = device->machine->device<via6522_device>(config->bus_tag);
304304
305305   /* set VIA clocks */
306306   vic1112->via0->set_unscaled_clock(device->machine->firstcpu->unscaled_clock());
307307   vic1112->via1->set_unscaled_clock(device->machine->firstcpu->unscaled_clock());
308308
309309   /* map VIAs to memory */
310   memory_install_readwrite8_device_handler(program, vic1112->via0, 0x9800, 0x980f, 0, 0, via_r, via_w);
311   memory_install_readwrite8_device_handler(program, vic1112->via1, 0x9810, 0x981f, 0, 0, via_r, via_w);
310   program->install_handler(0x9800, 0x980f, 0, 0, read8_delegate_create(via6522_device, read, *vic1112->via0), write8_delegate_create(via6522_device, write, *vic1112->via0));
311   program->install_handler(0x9810, 0x981f, 0, 0, read8_delegate_create(via6522_device, read, *vic1112->via1), write8_delegate_create(via6522_device, write, *vic1112->via1));
312312
313313   /* map ROM to memory */
314314   memory_install_rom(program, 0xb000, 0xb7ff, 0, 0, memory_region(device->machine, "vic1112:vic1112"));
src/mess/machine/c2040.c
r9146r9147
111111   running_device *riot0;
112112   running_device *riot1;
113113   running_device *miot;
114   running_device *via;
114   via6522_device *via;
115115   running_device *bus;
116116
117117   /* timers */
r9146r9147
259259      /* set byte ready flag */
260260      c2040->ready = ready;
261261
262      via_ca1_w(c2040->via, ready);
263      via_cb1_w(c2040->via, ERROR);
262      c2040->via->write_ca1(ready);
263      c2040->via->write_cb1(ERROR);
264264
265265      if ((device->type() == C8050) || (device->type() == C8250) || (device->type() == SFD1001))
266266      {
r9146r9147
442442static ADDRESS_MAP_START( c2040_fdc_map, ADDRESS_SPACE_PROGRAM, 8 )
443443   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
444444   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
445   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
445   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
446446   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
447447   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
448448   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
r9146r9147
475475static ADDRESS_MAP_START( c4040_fdc_map, ADDRESS_SPACE_PROGRAM, 8 )
476476   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
477477   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
478   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
478   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
479479   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
480480   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
481481   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
r9146r9147
507507static ADDRESS_MAP_START( c8050_fdc_map, ADDRESS_SPACE_PROGRAM, 8 )
508508   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
509509   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
510   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
510   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
511511   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
512512   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
513513   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
r9146r9147
539539static ADDRESS_MAP_START( sfd1001_fdc_map, ADDRESS_SPACE_PROGRAM, 8 )
540540   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
541541   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
542   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
542   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
543543   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w)
544544   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
545545   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
r9146r9147
842842   c2040->mode = state;
843843
844844   update_gcr_data(c2040);
845   via_cb1_w(device, ERROR);
845   c2040->via->write_cb1(ERROR);
846846}
847847
848848static WRITE_LINE_DEVICE_HANDLER( rw_sel_w )
r9146r9147
853853   c2040->rw = state;
854854
855855   update_gcr_data(c2040);
856   via_cb1_w(device, ERROR);
856   c2040->via->write_cb1(ERROR);
857857}
858858
859859static const via6522_interface via_intf =
r9146r9147
15111511   c2040->riot0 = device->subdevice(M6532_0_TAG);
15121512   c2040->riot1 = device->subdevice(M6532_1_TAG);
15131513   c2040->miot = device->subdevice(M6530_TAG);
1514   c2040->via = device->subdevice(M6522_TAG);
1514   c2040->via = device->subdevice<via6522_device>(M6522_TAG);
15151515   c2040->bus = device->machine->device(config->bus_tag);
15161516   c2040->unit[0].image = device->subdevice(FLOPPY_0);
15171517   c2040->unit[1].image = device->subdevice(FLOPPY_1);
src/mess/machine/pet.c
r9146r9147
456456
457457static WRITE8_HANDLER( cbm8096_io_w )
458458{
459   running_device *via_0 = space->machine->device("via6522_0");
459   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
460460   running_device *pia_0 = space->machine->device("pia_0");
461461   running_device *pia_1 = space->machine->device("pia_1");
462462   running_device *mc6845 = space->machine->device("crtc");
r9146r9147
466466   else if (offset < 0x20) ;
467467   else if (offset < 0x24) pia6821_w(pia_1, offset & 3, data);
468468   else if (offset < 0x40) ;
469   else if (offset < 0x50) via_w(via_0, offset & 0xf, data);
469   else if (offset < 0x50) via_0->write(*space, offset & 0xf, data);
470470   else if (offset < 0x80) ;
471471   else if (offset == 0x80) mc6845_address_w(mc6845, 0, data);
472472   else if (offset == 0x81) mc6845_register_w(mc6845, 0, data);
r9146r9147
474474
475475static READ8_HANDLER( cbm8096_io_r )
476476{
477   running_device *via_0 = space->machine->device("via6522_0");
477   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
478478   running_device *pia_0 = space->machine->device("pia_0");
479479   running_device *pia_1 = space->machine->device("pia_1");
480480   running_device *mc6845 = space->machine->device("crtc");
r9146r9147
485485   else if (offset < 0x20) ;
486486   else if (offset < 0x24) data = pia6821_r(pia_1, offset & 3);
487487   else if (offset < 0x40) ;
488   else if (offset < 0x50) data = via_r(via_0, offset & 0xf);
488   else if (offset < 0x50) data = via_0->read(*space, offset & 0xf);
489489   else if (offset < 0x80) ;
490490   else if (offset == 0x81) data = mc6845_register_r(mc6845, 0);
491491   return data;
r9146r9147
686686
687687static TIMER_CALLBACK( pet_tape2_timer )
688688{
689   running_device *via_0 = machine->device("via6522_0");
689   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
690690//  cassette 2
691691   UINT8 data = (cassette_input(machine->device("cassette2")) > +0.0) ? 1 : 0;
692   via_cb1_w(via_0, data);
692   via_0->write_cb1(data);
693693}
694694
695695
src/mess/machine/oric.c
r9146r9147
282282{
283283   int data;
284284   int input_port_9;
285   running_device *via_0 = machine->device("via6522_0");
285   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
286286
287287   data = 0;
288288
r9146r9147
302302      data = input_port_9>>4;
303303   }
304304
305   via_cb1_w(via_0, data);
305   via_0->write_cb1(data);
306306}
307307
308308static unsigned char previous_portb_data = 0;
r9146r9147
705705
706706static READ8_HANDLER (oric_jasmin_r)
707707{
708   running_device *via_0 = space->machine->device("via6522_0");
708   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
709709   running_device *fdc = space->machine->device("wd179x");
710710   unsigned char data = 0x0ff;
711711
r9146r9147
725725         data = wd17xx_data_r(fdc, 0);
726726         break;
727727      default:
728         data = via_r(via_0, offset & 0x0f);
728         data = via_0->read(*space,offset & 0x0f);
729729         //logerror("unhandled io read: %04x %02x\n", offset, data);
730730         break;
731731
r9146r9147
736736
737737static WRITE8_HANDLER(oric_jasmin_w)
738738{
739   running_device *via_0 = space->machine->device("via6522_0");
739   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
740740   running_device *fdc = space->machine->device("wd179x");
741741   switch (offset & 0x0f)
742742   {
r9146r9147
780780         break;
781781
782782      default:
783         via_w(via_0, offset & 0x0f, data);
783         via_0->write(*space,offset & 0x0f, data);
784784         break;
785785   }
786786}
r9146r9147
952952
953953      default:
954954         {
955            running_device *via_0 = space->machine->device("via6522_0");
956            data = via_r(via_0, offset & 0x0f);
955            via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
956            data = via_0->read(*space, offset & 0x0f);
957957         }
958958         break;
959959
r9146r9147
10011001
10021002      default:
10031003         {
1004            running_device *via_0 = space->machine->device("via6522_0");
1005            via_w(via_0, offset & 0x0f, data);
1004            via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
1005            via_0->write(*space, offset & 0x0f, data);
10061006         }
10071007         break;
10081008   }
r9146r9147
11461146
11471147READ8_HANDLER ( oric_IO_r )
11481148{
1149   running_device *via_0 = space->machine->device("via6522_0");
1149   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
11501150   switch (input_port_read(space->machine, "FLOPPY") & 0x07)
11511151   {
11521152      default:
r9146r9147
11791179      }
11801180   }
11811181   /* it is repeated */
1182   return via_r(via_0, offset & 0x0f);
1182   return via_0->read(*space, offset & 0x0f);
11831183}
11841184
11851185WRITE8_HANDLER ( oric_IO_w )
11861186{
1187   running_device *via_0 = space->machine->device("via6522_0");
1187   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
11881188   switch (input_port_read(space->machine, "FLOPPY") & 0x07)
11891189   {
11901190      default:
r9146r9147
12171217      //logerror("via 0 w: %04x %02x %04x\n", offset, data,(unsigned) cpu_get_reg(space->machine->device("maincpu"), STATE_GENPC));
12181218   }
12191219
1220   via_w(via_0, offset & 0x0f, data);
1220   via_0->write(*space, offset & 0x0f, data);
12211221}
12221222
12231223
src/mess/machine/at.c
r9146r9147
170170{
171171   address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
172172   mess_init_pc_common(machine, PCCOMMON_KEYBOARD_AT, at_set_keyb_int, at_set_irq_line);
173   mc146818_init(machine, MC146818_STANDARD);
174173   soundblaster_config(&soundblaster);
175174   kbdc8042_init(machine, at8042);
176175
src/mess/machine/c1541.c
r9146r9147
193193
194194   /* devices */
195195   running_device *cpu;
196   running_device *via0;
197   running_device *via1;
196   via6522_device *via0;
197   via6522_device *via1;
198198   running_device *bus;
199199   running_device *image;
200200
r9146r9147
278278      int byte_ready = !(byte && c1541->soe);
279279
280280      cpu_set_input_line(c1541->cpu, M6502_SET_OVERFLOW, byte_ready);
281      via_ca1_w(c1541->via1, byte_ready);
281      c1541->via1->write_ca1(byte_ready);
282282
283283      c1541->byte = byte;
284284   }
r9146r9147
374374   c1541_t *c1541 = get_safe_token(device);
375375   int data_out = !c1541->data_out && !(c1541->atna ^ !state);
376376
377   via_ca1_w(c1541->via0, !state);
377   c1541->via0->write_ca1(!state);
378378
379379   cbm_iec_data_w(c1541->bus, device, data_out);
380380}
r9146r9147
401401   int nrfd = c1541->nrfd_out;
402402   int ndac = c1541->ndac_out;
403403
404   via_ca1_w(c1541->via0, !state);
404   c1541->via0->write_ca1(!state);
405405
406406   if (!state ^ c1541->atna)
407407   {
r9146r9147
430430
431431static ADDRESS_MAP_START( c1540_map, ADDRESS_SPACE_PROGRAM, 8 )
432432   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
433   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
434   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
433   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
434   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
435435   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("c1540:c1540", 0x0000)
436436ADDRESS_MAP_END
437437
r9146r9147
441441
442442static ADDRESS_MAP_START( c1541_map, ADDRESS_SPACE_PROGRAM, 8 )
443443   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
444   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
445   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
444   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
445   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
446446   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("c1541:c1541", 0x0000)
447447ADDRESS_MAP_END
448448
r9146r9147
452452
453453static ADDRESS_MAP_START( c1541c_map, ADDRESS_SPACE_PROGRAM, 8 )
454454   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
455   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
456   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
455   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
456   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
457457   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("c1541:c1541c", 0x0000)
458458ADDRESS_MAP_END
459459
r9146r9147
463463
464464static ADDRESS_MAP_START( c1541ii_map, ADDRESS_SPACE_PROGRAM, 8 )
465465   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
466   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
467   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
466   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
467   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
468468   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("c1541:c1541ii", 0x0000)
469469ADDRESS_MAP_END
470470
r9146r9147
474474
475475static ADDRESS_MAP_START( sx1541_map, ADDRESS_SPACE_PROGRAM, 8 )
476476   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
477   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
478   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
477   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
478   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
479479   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("c1541:sx1541", 0x0000)
480480ADDRESS_MAP_END
481481
r9146r9147
485485
486486static ADDRESS_MAP_START( c2031_map, ADDRESS_SPACE_PROGRAM, 8 )
487487   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
488   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
489   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
488   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
489   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
490490   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("c2031:c2031", 0x0000)
491491ADDRESS_MAP_END
492492
r9146r9147
496496
497497static ADDRESS_MAP_START( oc118_map, ADDRESS_SPACE_PROGRAM, 8 )
498498   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x6000) AM_RAM
499   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
500   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
499   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
500   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x63f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
501501   AM_RANGE(0x8000, 0xbfff) AM_MIRROR(0x4000) AM_ROM AM_REGION("oc118:oc118", 0x0000)
502502ADDRESS_MAP_END
503503
r9146r9147
977977
978978   c1541->soe = state;
979979
980   cpu_set_input_line(c1541->cpu, M6502_SET_OVERFLOW, byte_ready);
981   via_ca1_w(device, byte_ready);
980   cpu_set_input_line(c1541->cpu, M6502_SET_OVERFLOW, byte_ready);   
981   c1541->via1->write_ca1(byte_ready);
982982}
983983
984984static WRITE_LINE_DEVICE_HANDLER( mode_w )
r9146r9147
12141214   c1541->cpu = device->subdevice(M6502_TAG);
12151215
12161216   /* find devices */
1217   c1541->via0 = device->subdevice(M6522_0_TAG);
1218   c1541->via1 = device->subdevice(M6522_1_TAG);
1217   c1541->via0 = device->subdevice<via6522_device>(M6522_0_TAG);
1218   c1541->via1 = device->subdevice<via6522_device>(M6522_1_TAG);
12191219   c1541->bus = device->machine->device(config->bus_tag);
12201220   c1541->image = device->subdevice(FLOPPY_0);
12211221
src/mess/machine/microtan.c
r9146r9147
340340static TIMER_CALLBACK(microtan_read_cassette)
341341{
342342   double level = cassette_input(cassette_device_image(machine));
343   running_device *via_0 = machine->device("via6522_0");
343   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
344344
345345   LOG(("microtan_read_cassette: %g\n", level));
346346   if (level < -0.07)
347      via_cb2_w(via_0, 0);
347      via_0->write_cb2(0);
348348   else if (level > +0.07)
349      via_cb2_w(via_0, 1);
349      via_0->write_cb2(1);
350350}
351351
352352READ8_HANDLER( microtan_sound_r )
src/mess/machine/mac.c
r9146r9147
632632static TIMER_CALLBACK(kbd_clock)
633633{
634634   int i;
635   running_device *via_0 = machine->device("via6522_0");
635   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
636636   mac_state *mac = machine->driver_data<mac_state>();
637637
638638   if (mac->kbd_comm == TRUE)
r9146r9147
641641      {
642642         /* Put data on CB2 if we are sending*/
643643         if (mac->kbd_receive == FALSE)
644            via_cb2_w(via_0, mac->kbd_shift_reg&0x80?1:0);
644            via_0->write_cb2(mac->kbd_shift_reg&0x80?1:0);
645645         mac->kbd_shift_reg <<= 1;
646         via_cb1_w(via_0, 0);
647         via_cb1_w(via_0, 1);
646         via_0->write_cb1(0);
647         via_0->write_cb1(1);
648648      }
649649      if (mac->kbd_receive == TRUE)
650650      {
r9146r9147
18521852
18531853static TIMER_CALLBACK(mac_adb_tick)
18541854{
1855   running_device *via_0 = machine->device("via6522_0");
1855   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
18561856   mac_state *mac = machine->driver_data<mac_state>();
18571857
18581858   // do one clock transition on CB1 to advance the VIA shifter
18591859   mac->adb_extclock ^= 1;
1860   via_cb1_w(via_0, mac->adb_extclock);
1860   via_0->write_cb1(mac->adb_extclock);
18611861   mac->adb_extclock ^= 1;
1862   via_cb1_w(via_0, mac->adb_extclock);
1862   via_0->write_cb1(mac->adb_extclock);
18631863
18641864   mac->adb_timer_ticks--;
18651865   if (!mac->adb_timer_ticks)
r9146r9147
26352635READ16_HANDLER ( mac_via_r )
26362636{
26372637   UINT16 data;
2638   running_device *via_0 = space->machine->device("via6522_0");
2638   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
26392639
26402640   offset >>= 8;
26412641   offset &= 0x0f;
26422642
26432643   if (LOG_VIA)
26442644      logerror("mac_via_r: offset=0x%02x\n", offset);
2645   data = via_r(via_0, offset);
2645   data = via_0->read(*space, offset);
26462646
26472647   return (data & 0xff) | (data << 8);
26482648}
26492649
26502650WRITE16_HANDLER ( mac_via_w )
26512651{
2652   running_device *via_0 = space->machine->device("via6522_0");
2652   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");;
26532653
26542654   offset >>= 8;
26552655   offset &= 0x0f;
r9146r9147
26582658      logerror("mac_via_w: offset=0x%02x data=0x%08x\n", offset, data);
26592659
26602660   if (ACCESSING_BITS_8_15)
2661      via_w(via_0, offset, (data >> 8) & 0xff);
2661      via_0->write(*space, offset, (data >> 8) & 0xff);
26622662}
26632663
26642664/* *************************************************************************
r9146r9147
26732673READ16_HANDLER ( mac_via2_r )
26742674{
26752675   int data;
2676   running_device *via_1 = space->machine->device("via6522_1");
2676   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
26772677
26782678   offset >>= 8;
26792679   offset &= 0x0f;
26802680
26812681   if (LOG_VIA)
26822682      logerror("mac_via2_r: offset=0x%02x\n", offset*2);
2683   data = via_r(via_1, offset);
2683   data = via_1->read(*space, offset);
26842684
26852685   return (data & 0xff) | (data << 8);
26862686}
26872687
26882688WRITE16_HANDLER ( mac_via2_w )
26892689{
2690   running_device *via_1 = space->machine->device("via6522_1");
2690   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
26912691
26922692   offset >>= 8;
26932693   offset &= 0x0f;
r9146r9147
26962696      logerror("mac_via2_w: offset=%x data=0x%08x\n", offset, data);
26972697
26982698   if (ACCESSING_BITS_8_15)
2699      via_w(via_1, offset, (data >> 8) & 0xff);
2699      via_1->write(*space, offset, (data >> 8) & 0xff);
27002700}
27012701
27022702
r9146r9147
27412741
27422742static WRITE8_DEVICE_HANDLER(mac_via2_out_b)
27432743{
2744   running_device *via_0 = device->machine->device("via6522_0");
2744   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
27452745
27462746//  logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu")));
27472747
27482748//  printf("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08);
27492749
27502750   // chain 60.15 Hz to VIA1
2751   via_ca1_w(via_0, data>>7);
2751   via_0->write_ca1(data>>7);
27522752}
27532753
27542754/* *************************************************************************
r9146r9147
30663066
30673067   if ((mac->mac_nubus_irq_state & 0x3f) != 0x3f)
30683068   {
3069      running_device *via_1 = machine->device("via6522_1");
3069      via6522_device *via_1 = machine->device<via6522_device>("via6522_1");
30703070
30713071      mac->via2_ca1 ^= 1;
3072      via_ca1_w(via_1, mac->via2_ca1);
3072      via_1->write_ca1(mac->via2_ca1);
30733073   }
30743074}
30753075
30763076static void mac_vblank_irq(running_machine *machine)
30773077{
30783078   static int irq_count = 0, ca1_data = 0, ca2_data = 0;
3079   running_device *via_0 = machine->device("via6522_0");
3079   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
30803080   mac_state *mac = machine->driver_data<mac_state>();
30813081
30823082   /* handle ADB keyboard/mouse */
r9146r9147
31053105   if (mac->mac_model < MODEL_MAC_II)
31063106   {
31073107      ca1_data ^= 1;
3108      via_ca1_w(via_0, ca1_data);
3108      via_0->write_ca1(ca1_data);
31093109   }
31103110
31113111   if (++irq_count == 60)
r9146r9147
31143114
31153115      ca2_data ^= 1;
31163116      /* signal 1 Hz irq on CA2 input on the VIA */
3117      via_ca2_w(via_0, ca2_data);
3117      via_0->write_ca2(ca2_data);
31183118
31193119      rtc_incticks(mac);
31203120   }
src/mess/machine/concept.c
r9146r9147
380380         /* NVIA versatile system interface */
381381         LOG(("concept_io_r: VIA read at address 0x03%4.4x\n", offset << 1));
382382         {
383            running_device *via_0 = space->machine->device("via6522_0");
384            return via_r(via_0, offset & 0xf);
383            via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
384            return via_0->read(*space, offset & 0xf);
385385         }
386386         break;
387387
r9146r9147
492492
493493      case 3:
494494         /* NVIA versatile system interface */
495         {
496            running_device *via_0 = space->machine->device("via6522_0");
497            via_w(via_0, offset & 0xf, data);
495         {           
496            via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
497            via_0->write(*space, offset & 0xf, data);
498498         }
499499         break;
500500
src/mess/machine/vectrex.c
r9146r9147
284284
285285TIMER_CALLBACK(vectrex_imager_eye)
286286{
287   running_device *via_0 = machine->device("via6522_0");
287   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
288288   int coffset;
289289   double rtime = (1.0 / vectrex_imager_freq);
290290
r9146r9147
301301         timer_set (machine, double_to_attotime(rtime * 0.50), NULL, 1, vectrex_imager_eye);
302302
303303         /* Index hole sensor is connected to IO7 which triggers also CA1 of VIA */
304         via_ca1_w(via_0, 1);
305         via_ca1_w(via_0, 0);
304         via_0->write_ca1(1);
305         via_0->write_ca1(0);
306306         vectrex_imager_pinlevel |= 0x80;
307307         timer_set (machine, double_to_attotime(rtime / 360.0), &vectrex_imager_pinlevel, 0, update_level);
308308      }
src/mess/machine/lisa.c
r9146r9147
347347
348348INLINE void COPS_send_data_if_possible(running_machine *machine)
349349{
350   running_device *via_0 = machine->device("via6522_0");
350   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
351   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
351352
352353   if ((! hold_COPS_data) && fifo_size && (! COPS_Ready))
353354   {
354355      logerror("Pushing one byte of data to VIA\n");
355356
356      via_porta_w(via_0, 0, fifo_data[fifo_head]);   /* output data */
357      via_0->write_porta(*space, 0, fifo_data[fifo_head]);   /* output data */
357358      if (fifo_head == mouse_data_offset)
358359         mouse_data_offset = -1;   /* we just phased out the mouse data in buffer */
359360      fifo_head = (fifo_head+1) & 0x7;
360361      fifo_size--;
361      via_ca1_w(via_0, 1);      /* pulse ca1 so that VIA reads it */
362      via_ca1_w(via_0, 0);      /* BTW, I have no idea how a real COPS does it ! */
362      via_0->write_ca1(1);      /* pulse ca1 so that VIA reads it */
363      via_0->write_ca1(0);      /* BTW, I have no idea how a real COPS does it ! */
363364   }
364365}
365366
r9146r9147
535536static TIMER_CALLBACK(read_COPS_command)
536537{
537538   int command;
538   running_device *via_0 = machine->device("via6522_0");
539
539   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
540   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
541   
540542   COPS_Ready = 0;
541543
542544   /*logerror("read_COPS_command : trying to send data to VIA\n");*/
543545   COPS_send_data_if_possible(machine);
544546
545547   /* some pull-ups allow the COPS to read 1s when the VIA port is not set as output */
546   command = (COPS_command | (~ via_r(via_0, VIA_DDRA))) & 0xff;
548   command = (COPS_command | (~ via_0->read(*space, VIA_DDRA))) & 0xff;
547549
548550   if (command & 0x80)
549551      return;   /* NOP */
r9146r9147
827829
828830static WRITE8_DEVICE_HANDLER(COPS_via_out_b)
829831{
830   running_device *via_0 = device->machine->device("via6522_0");
832   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
833   address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
831834
832835   /* pull-up */
833   data |= (~ via_r(via_0, VIA_DDRA)) & 0x01;
836   data |= (~ via_0->read(*space,VIA_DDRA)) & 0x01;
834837
835838   if (data & 0x01)
836839   {
r9146r9147
11791182   init_COPS(machine);
11801183
11811184   {
1182      running_device *via_0 = machine->device("via6522_0");
1185      via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
11831186      COPS_via_out_ca2(via_0, 0, 0);   /* VIA core forgets to do so */
11841187   }
11851188
r9146r9147
19141917
19151918static READ16_HANDLER ( lisa_IO_r )
19161919{
1917   running_device *via_0 = space->machine->device("via6522_0");
1918   running_device *via_1 = space->machine->device("via6522_1");
1920   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
1921   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
19191922   int answer=0;
19201923
19211924   switch ((offset & 0x7000) >> 12)
r9146r9147
19671970         case 2:   /* parallel port */
19681971            /* 1 VIA located at 0xD901 */
19691972            if (ACCESSING_BITS_0_7)
1970               return via_r(via_1, (offset >> 2) & 0xf);
1973               return via_1->read(*space, (offset >> 2) & 0xf);
19711974            break;
19721975
19731976         case 3:   /* keyboard/mouse cops via */
19741977            /* 1 VIA located at 0xDD81 */
19751978            if (ACCESSING_BITS_0_7)
1976               return via_r(via_0, offset & 0xf);
1979               return via_0->read(*space, offset & 0xf);
19771980            break;
19781981         }
19791982      }
r9146r9147
20432046
20442047static WRITE16_HANDLER ( lisa_IO_w )
20452048{
2046   running_device *via_0 = space->machine->device("via6522_0");
2047   running_device *via_1 = space->machine->device("via6522_1");
2049   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
2050   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
20482051
20492052   switch ((offset & 0x7000) >> 12)
20502053   {
r9146r9147
20922095
20932096         case 2:   /* paralel port */
20942097            if (ACCESSING_BITS_0_7)
2095               via_w(via_1, (offset >> 2) & 0xf, data & 0xff);
2098               via_1->write(*space, (offset >> 2) & 0xf, data & 0xff);
20962099            break;
20972100
20982101         case 3:   /* keyboard/mouse cops via */
20992102            if (ACCESSING_BITS_0_7)
2100               via_w(via_0, offset & 0xf, data & 0xff);
2103               via_0->write(*space, offset & 0xf, data & 0xff);
21012104            break;
21022105         }
21032106      }
src/mess/machine/c9060.c
r9146r9147
146146static ADDRESS_MAP_START( c9060_fdc_map, ADDRESS_SPACE_PROGRAM, 8 )
147147   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
148148   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
149   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
149   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE_MODERN(M6522_TAG, via6522_device, read, write)
150150   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
151151   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
152152   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
src/mess/machine/c1571.c
r9146r9147
8383
8484   /* devices */
8585   running_device *cpu;
86   running_device *via0;
87   running_device *via1;
86   via6522_device *via0;
87   via6522_device *via1;
8888   running_device *cia;
8989   running_device *wd1770;
9090   running_device *serial_bus;
r9146r9147
195195      int byte_ready = !(byte && c1571->soe);
196196
197197      cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
198      via_ca1_w(c1571->via1, byte_ready);
198      c1571->via1->write_ca1(byte_ready);
199199
200200      c1571->byte = byte;
201201   }
r9146r9147
309309{
310310   c1571_t *c1571 = get_safe_token(device);
311311
312   via_ca1_w(c1571->via0, !state);
312   c1571->via0->write_ca1(!state);
313313   iec_data_w(device);
314314}
315315
r9146r9147
359359
360360static ADDRESS_MAP_START( c1570_map, ADDRESS_SPACE_PROGRAM, 8 )
361361   AM_RANGE(0x0000, 0x07ff) AM_RAM
362   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
363   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
362   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
363   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
364364   AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
365365   AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, mos6526_r, mos6526_w)
366366   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1570:c1570", 0)
r9146r9147
372372
373373static ADDRESS_MAP_START( c1571_map, ADDRESS_SPACE_PROGRAM, 8 )
374374   AM_RANGE(0x0000, 0x07ff) AM_RAM
375   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x03f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
376   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x03f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
375   AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x03f0) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
376   AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x03f0) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
377377   AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
378378   AM_RANGE(0x4000, 0x400f) AM_MIRROR(0x3ff0) AM_DEVREADWRITE(M6526_TAG, mos6526_r, mos6526_w)
379379   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571:c1571", 0)
r9146r9147
385385
386386static ADDRESS_MAP_START( c1571cr_map, ADDRESS_SPACE_PROGRAM, 8 )
387387   AM_RANGE(0x0000, 0x07ff) AM_RAM
388   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
389   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
388   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
389   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
390390//  AM_RANGE(0x2000, 0x2005) 5710 FDC
391391//  AM_RANGE(0x400c, 0x400e) 5710 CIA
392392//  AM_RANGE(0x4010, 0x4017) 5710 CIA
r9146r9147
721721   c1571->soe = state;
722722
723723   cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
724   via_ca1_w(device, byte_ready);
724   c1571->via1->write_ca1(byte_ready);
725725}
726726
727727static WRITE_LINE_DEVICE_HANDLER( mode_w )
r9146r9147
823823static WRITE_LINE_DEVICE_HANDLER( wpt_w )
824824{
825825   c1571_t *c1571 = get_safe_token(device->owner());
826
827   via_ca2_w(c1571->via0, !state);
826   
827   c1571->via0->write_ca2(!state);
828828}
829829
830830static const floppy_config c1570_floppy_config =
r9146r9147
950950   c1571->cpu = device->subdevice(M6502_TAG);
951951
952952   /* find devices */
953   c1571->via0 = device->subdevice(M6522_0_TAG);
954   c1571->via1 = device->subdevice(M6522_1_TAG);
953   c1571->via0 = device->subdevice<via6522_device>(M6522_0_TAG);
954   c1571->via1 = device->subdevice<via6522_device>(M6522_1_TAG);
955955   c1571->cia = device->subdevice(M6526_TAG);
956956   c1571->wd1770 = device->subdevice(WD1770_TAG);
957957   c1571->serial_bus = device->machine->device(config->serial_bus_tag);
src/mess/machine/bbc.c
r9146r9147
609609
610610
611611   if ((offset>=0x200) && (offset<=0x2ff)) /* SHEILA */
612   {
613      running_device *via_0 = space->machine->device("via6522_0");
614      running_device *via_1 = space->machine->device("via6522_1");
612   {     
613      via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
614      via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
615615
616616      myo=offset-0x200;
617617      if ((myo>=0x00) && (myo<=0x07)) return bbc_6845_r(space, myo-0x00);      /* Video Controller */
r9146r9147
632632      if ((myo>=0x30) && (myo<=0x33)) return 0xfe;                  /* page select */
633633      if ((myo>=0x34) && (myo<=0x37)) return bbcm_ACCCON_read(space, myo-0x34);   /* ACCCON */
634634      if ((myo>=0x38) && (myo<=0x3f)) return 0xfe;                  /* NC ?? */
635      if ((myo>=0x40) && (myo<=0x5f)) return via_r(via_0, myo-0x40);
636      if ((myo>=0x60) && (myo<=0x7f)) return via_r(via_1, myo-0x60);
635      if ((myo>=0x40) && (myo<=0x5f)) return via_0->read(*space,myo-0x40);
636      if ((myo>=0x60) && (myo<=0x7f)) return via_1->read(*space,myo-0x60);
637637      if ((myo>=0x80) && (myo<=0x9f)) return 0xfe;
638638      if ((myo>=0xa0) && (myo<=0xbf)) return 0xfe;
639639      if ((myo>=0xc0) && (myo<=0xdf)) return 0xfe;
r9146r9147
649649
650650   if ((offset>=0x200) && (offset<=0x2ff)) /* SHEILA */
651651   {
652      running_device *via_0 = space->machine->device("via6522_0");
653      running_device *via_1 = space->machine->device("via6522_1");
652      via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
653      via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
654654
655655      myo=offset-0x200;
656656      if ((myo>=0x00) && (myo<=0x07)) bbc_6845_w(space, myo-0x00,data);         /* Video Controller */
r9146r9147
671671      if ((myo>=0x30) && (myo<=0x33)) page_selectbm_w(space, myo-0x30,data);      /* page select */
672672      if ((myo>=0x34) && (myo<=0x37)) bbcm_ACCCON_write(space, myo-0x34,data);   /* ACCCON */
673673      //if ((myo>=0x38) && (myo<=0x3f))                                   /* NC ?? */
674      if ((myo>=0x40) && (myo<=0x5f)) via_w(via_0, myo-0x40, data);
675      if ((myo>=0x60) && (myo<=0x7f)) via_w(via_1, myo-0x60, data);
674      if ((myo>=0x40) && (myo<=0x5f)) via_0->write(*space,myo-0x40, data);
675      if ((myo>=0x60) && (myo<=0x7f)) via_1->write(*space,myo-0x60, data);
676676      //if ((myo>=0x80) && (myo<=0x9f))
677677      //if ((myo>=0xa0) && (myo<=0xbf))
678678      //if ((myo>=0xc0) && (myo<=0xdf))
r9146r9147
813813      "COL0", "COL1", "COL2", "COL3", "COL4",
814814      "COL5", "COL6", "COL7", "COL8", "COL9"
815815   };
816   running_device *via_0 = device->machine->device("via6522_0");
816   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
817817
818818   /* only do auto scan if keyboard is not enabled */
819819   if (b3_keyboard == 1)
r9146r9147
829829                 being pressed on the selected column */
830830         if ((input_port_read(device->machine, colnames[column]) | 0x01) != 0xff)
831831         {
832            via_ca2_w(via_0, 1);
832            via_0->write_ca2(1);
833833         }
834834         else
835835         {
836            via_ca2_w(via_0, 0);
836            via_0->write_ca2(0);
837837         }
838838
839839      }
840840      else
841841      {
842         via_ca2_w(via_0, 0);
842         via_0->write_ca2(0);
843843      }
844844   }
845845}
r9146r9147
851851      "COL0", "COL1", "COL2", "COL3", "COL4",
852852      "COL5", "COL6", "COL7", "COL8", "COL9"
853853   };
854   running_device *via_0 = device->machine->device("via6522_0");
854   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
855855
856856   /* only do auto scan if keyboard is not enabled */
857857   if (b3_keyboard == 1)
r9146r9147
869869                 being pressed on the selected column */
870870         if ((input_port_read(device->machine, colnames[column]) | 0x01) != 0xff)
871871         {
872            via_ca2_w(via_0, 1);
872            via_0->write_ca2(1);
873873         }
874874         else
875875         {
876            via_ca2_w(via_0, 0);
876            via_0->write_ca2(0);
877877         }
878878
879879      }
880880      else
881881      {
882         via_ca2_w(via_0, 0);
882         via_0->write_ca2(0);
883883      }
884884   }
885885}
r9146r9147
895895      "COL0", "COL1", "COL2", "COL3", "COL4",
896896      "COL5", "COL6", "COL7", "COL8", "COL9"
897897   };
898   running_device *via_0 = space->machine->device("via6522_0");
898   via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");
899899
900900   column = data & 0x0f;
901901   row = (data>>4) & 0x07;
r9146r9147
919919
920920   if ((res | 1) != 0xff)
921921   {
922      via_ca2_w(via_0, 1);
922      via_0->write_ca2(1);
923923   }
924924   else
925925   {
926      via_ca2_w(via_0, 0);
926      via_0->write_ca2(0);
927927   }
928928
929929   return (data & 0x7f) | (bit<<7);
r9146r9147
13421342
13431343static UPD7002_EOC(BBC_uPD7002_EOC)
13441344{
1345   running_device *via_0 = device->machine->device("via6522_0");
1346   via_cb1_w(via_0, data);
1345   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
1346   via_0->write_cb1(data);
13471347}
13481348
13491349const uPD7002_interface bbc_uPD7002 =
r9146r9147
13811381}
13821382
13831383static TIMER_CALLBACK(bbc_tape_timer_cb)
1384{
1384{   
13851385
13861386   double dev_val;
13871387   dev_val=cassette_input(machine->device("cassette"));
r9146r9147
20582058{
20592059   bbc_Master=1;
20602060   bbc_tape_timer = timer_alloc(machine, bbc_tape_timer_cb, NULL);
2061   mc146818_init(machine, MC146818_STANDARD);
20622061}
20632062
20642063MACHINE_START( bbca )
src/mess/video/vectrex.c
r9146r9147
9898{
9999   if (vectrex_lightpen_port & 1)
100100   {
101      running_device *via_0 = machine->device("via6522_0");
102      via_ca1_w(via_0, 1);
103      via_ca1_w(via_0, 0);
101      via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
102      via_0->write_ca1(1);
103      via_0->write_ca1(0);
104104   }
105105
106106   if (vectrex_lightpen_port & 2)
r9146r9147
131131
132132READ8_HANDLER(vectrex_via_r)
133133{
134   running_device *via = space->machine->device("via6522_0");
135   return via_r(via, offset);
134   via6522_device *via = space->machine->device<via6522_device>("via6522_0");
135   return via->read(*space, offset);
136136}
137137
138138WRITE8_HANDLER(vectrex_via_w)
139139{
140   running_device *via = space->machine->device("via6522_0");
140   via6522_device *via = space->machine->device<via6522_device>("via6522_0");
141141   attotime period;
142142
143143   switch (offset)
r9146r9147
160160                          period);
161161      break;
162162   }
163   via_w(via, offset, data);
163   via->write(*space, offset, data);
164164}
165165
166166
src/mess/video/aim65.c
r9146r9147
8484
8585static TIMER_CALLBACK(aim65_printer_timer)
8686{
87   running_device *via_0 = machine->device("via6522_0");
87   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
8888
89   via_cb1_w(via_0, printer_level);
90   via_ca1_w(via_0, !printer_level);
89   via_0->write_cb1(printer_level);
90   via_0->write_cb1(!printer_level);
9191   printer_level = !printer_level;
9292   aim65_printer_inc();
9393}
r9146r9147
9595
9696WRITE8_DEVICE_HANDLER( aim65_printer_on )
9797{
98   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
9899   if (!data)
99100   {
100101      aim65_printer_cr();
101102      timer_adjust_periodic(print_timer, attotime_zero, 0, ATTOTIME_IN_USEC(10));
102      via_cb1_w(device, 0);
103      via_0->write_cb1(0);
103104      printer_level = 1;
104105   }
105106   else
src/mess/includes/vic20.h
r9146r9147
11#ifndef __VIC20__
22#define __VIC20__
33
4#include "machine/6522via.h"
5
46#define SCREEN_TAG      "screen"
57#define M6502_TAG      "ue10"
68#define M6522_0_TAG      "uab3"
r9146r9147
2426   int key_col;
2527
2628   /* devices */
27   running_device *via0;
28   running_device *via1;
29   via6522_device *via0;
30   via6522_device *via1;
2931   running_device *iec;
3032   running_device *cassette;
3133   running_device *mos6560;
src/mess/formats/m65_snqk.c
r9146r9147
218218{
219219    UINT8 *RAM = memory_region(machine, "maincpu");
220220    address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
221    running_device *via_0 = machine->device("via6522_0");
222    running_device *via_1 = machine->device("via6522_1");
221    via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
222    via6522_device *via_1 = machine->device<via6522_device>("via6522_1");
223223    running_device *ay8910 = machine->device("ay8910.1");
224224
225225    /* check for .DMP file format */
r9146r9147
276276
277277        /* first set of VIA6522 registers */
278278        for (i = 0; i < 16; i++ )
279            via_w(via_0, i, snapshot_buff[base++]);
279            via_0->write(*space, i, snapshot_buff[base++]);
280280
281281        /* second set of VIA6522 registers */
282282        for (i = 0; i < 16; i++ )
283            via_w(via_1, i, snapshot_buff[base++]);
283            via_1->write(*space, i, snapshot_buff[base++]);
284284
285285        /* microtan IO bff0-bfff */
286286        for (i = 0; i < 16; i++ )
src/mess/drivers/a6809.c
r9146r9147
2121   AM_RANGE(0x0400,0x07ff) AM_DEVREADWRITE("saa5050", saa5050_videoram_r, saa5050_videoram_w)
2222   AM_RANGE(0x0800,0x0800) AM_DEVWRITE("mc6845", mc6845_address_w)
2323   AM_RANGE(0x0801,0x0801) AM_DEVREADWRITE("mc6845", mc6845_register_r , mc6845_register_w)
24   AM_RANGE(0x0900,0x090f) AM_MIRROR(0xf0)AM_DEVREADWRITE("via", via_r, via_w)
24   AM_RANGE(0x0900,0x090f) AM_MIRROR(0xf0) AM_DEVREADWRITE_MODERN("via", via6522_device, read, write)
2525   AM_RANGE(0xf000,0xf7ff) AM_ROM // optional ROM
2626   AM_RANGE(0xf800,0xffff) AM_ROM
2727ADDRESS_MAP_END
src/mess/drivers/aim65.c
r9146r9147
3131/* Note: RAM is mapped dynamically in machine/aim65.c */
3232static ADDRESS_MAP_START( aim65_mem, ADDRESS_SPACE_PROGRAM, 8 )
3333   AM_RANGE( 0x1000, 0x9fff ) AM_NOP /* User available expansions */
34   AM_RANGE( 0xa000, 0xa00f ) AM_MIRROR(0x3f0) AM_DEVREADWRITE("via6522_1", via_r, via_w) /* User VIA */
34   AM_RANGE( 0xa000, 0xa00f ) AM_MIRROR(0x3f0) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)/* User VIA */
3535   AM_RANGE( 0xa400, 0xa47f ) AM_RAM /* RIOT RAM */
3636   AM_RANGE( 0xa480, 0xa497 ) AM_DEVREADWRITE("riot", riot6532_r, riot6532_w)
3737   AM_RANGE( 0xa498, 0xa7ff ) AM_NOP /* Not available */
38   AM_RANGE( 0xa800, 0xa80f ) AM_MIRROR(0x3f0) AM_DEVREADWRITE("via6522_0", via_r, via_w)
38   AM_RANGE( 0xa800, 0xa80f ) AM_MIRROR(0x3f0) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
3939   AM_RANGE( 0xac00, 0xac03 ) AM_DEVREADWRITE("pia6821", pia6821_r, pia6821_w)
4040   AM_RANGE( 0xac04, 0xac43 ) AM_RAM /* PIA RAM */
4141   AM_RANGE( 0xac44, 0xafff ) AM_NOP /* Not available */
src/mess/drivers/vic20.c
r9146r9147
100100//  AM_RANGE(0x6000, 0x7fff) BLK3
101101   AM_RANGE(0x8000, 0x8fff) AM_ROM
102102   AM_RANGE(0x9000, 0x900f) AM_DEVREADWRITE(M6560_TAG, mos6560_port_r, mos6560_port_w)
103   AM_RANGE(0x9110, 0x911f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
104   AM_RANGE(0x9120, 0x912f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
103   AM_RANGE(0x9110, 0x911f) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
104   AM_RANGE(0x9120, 0x912f) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
105105   AM_RANGE(0x9400, 0x97ff) AM_RAM
106106//  AM_RANGE(0x9800, 0x9bff) I/O2
107107//  AM_RANGE(0x9c00, 0x9fff) I/O3
r9146r9147
427427   vic20_state *state = timer.machine->driver_data<vic20_state>();
428428   int data = (cassette_input(state->cassette) > +0.0) ? 1 : 0;
429429
430   via_ca1_w(state->via1, data);
430   state->via1->write_ca1(data);
431431}
432432
433433/* IEC Serial Bus */
r9146r9147
435435static CBM_IEC_DAISY( cbm_iec_daisy )
436436{
437437   { M6522_0_TAG },
438   { M6522_1_TAG, DEVCB_DEVICE_LINE(M6522_1_TAG, via_cb1_w) },
438   { M6522_1_TAG, DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_cb1), },
439439   { C1541_IEC(C1540_TAG) },
440440   { NULL}
441441};
r9146r9147
520520   address_space *program = cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM);
521521
522522   /* find devices */
523   state->via0 = machine->device(M6522_0_TAG);
524   state->via1 = machine->device(M6522_1_TAG);
523   state->via0 = machine->device<via6522_device>(M6522_0_TAG);
524   state->via1 = machine->device<via6522_device>(M6522_1_TAG);
525525   state->iec = machine->device(IEC_TAG);
526526   state->cassette = machine->device(CASSETTE_TAG);
527527   state->cassette_timer = machine->device<timer_device>(TIMER_C1530_TAG);
src/mess/drivers/pet.c
r9146r9147
406406   AM_RANGE(0xa000, 0xe7ff) AM_ROM
407407   AM_RANGE(0xe810, 0xe813) AM_DEVREADWRITE("pia_0", pia6821_r, pia6821_w)
408408   AM_RANGE(0xe820, 0xe823) AM_DEVREADWRITE("pia_1", pia6821_r, pia6821_w)
409   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
409   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
410410/*  AM_RANGE(0xe900, 0xe91f) AM_DEVREAD("ieee_bus", cbm_ieee_state)    // for debugging */
411411   AM_RANGE(0xf000, 0xffff) AM_ROM
412412ADDRESS_MAP_END
r9146r9147
416416   AM_RANGE(0xa000, 0xe7ff) AM_ROM
417417   AM_RANGE(0xe810, 0xe813) AM_DEVREADWRITE("pia_0", pia6821_r, pia6821_w)
418418   AM_RANGE(0xe820, 0xe823) AM_DEVREADWRITE("pia_1", pia6821_r, pia6821_w)
419   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
419   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
420420   AM_RANGE(0xe880, 0xe880) AM_DEVWRITE("crtc", mc6845_address_w)
421421   AM_RANGE(0xe881, 0xe881) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
422422   AM_RANGE(0xf000, 0xffff) AM_ROM
r9146r9147
433433#else
434434   AM_RANGE(0xe810, 0xe813) AM_DEVREADWRITE("pia_0", pia6821_r, pia6821_w)
435435   AM_RANGE(0xe820, 0xe823) AM_DEVREADWRITE("pia_1", pia6821_r, pia6821_w)
436   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
436   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
437437   AM_RANGE(0xe880, 0xe880) AM_DEVWRITE("crtc", mc6845_address_w)
438438   AM_RANGE(0xe881, 0xe881) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
439439#endif
r9146r9147
464464   AM_RANGE(0xa000, 0xe7ff) AM_ROM
465465   AM_RANGE(0xe810, 0xe813) AM_DEVREADWRITE("pia_0", pia6821_r, pia6821_w)
466466   AM_RANGE(0xe820, 0xe823) AM_DEVREADWRITE("pia_1", pia6821_r, pia6821_w)
467   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
467   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
468468   AM_RANGE(0xe880, 0xe880) AM_DEVWRITE("crtc", mc6845_address_w)
469469   AM_RANGE(0xe881, 0xe881) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
470470   /* 0xefe0, 0xefe3, mos 6702 */
r9146r9147
480480   AM_RANGE(0xa000, 0xe7ff) AM_ROM
481481   AM_RANGE(0xe810, 0xe813) AM_DEVREADWRITE("pia_0", pia6821_r, pia6821_w)
482482   AM_RANGE(0xe820, 0xe823) AM_DEVREADWRITE("pia_1", pia6821_r, pia6821_w)
483   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
483   AM_RANGE(0xe840, 0xe84f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
484484   AM_RANGE(0xe880, 0xe880) AM_DEVWRITE("crtc", mc6845_address_w)
485485   AM_RANGE(0xe881, 0xe881) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
486486   AM_RANGE(0xeff8, 0xefff) AM_READWRITE(superpet_r, superpet_w)
src/mess/drivers/oric.c
r9146r9147
6969Memory region &c000-&ffff can be ram or rom. */
7070static ADDRESS_MAP_START(telestrat_mem, ADDRESS_SPACE_PROGRAM, 8)
7171   AM_RANGE( 0x0000, 0x02ff) AM_RAM
72   AM_RANGE( 0x0300, 0x030f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
72   AM_RANGE( 0x0300, 0x030f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
7373   AM_RANGE( 0x0310, 0x031b) AM_READWRITE( oric_microdisc_r, oric_microdisc_w )
7474   AM_RANGE( 0x031c, 0x031f) AM_DEVREADWRITE("acia",  acia_6551_r, acia_6551_w )
75   AM_RANGE( 0x0320, 0x032f) AM_DEVREADWRITE("via6522_1", via_r, via_w)
75   AM_RANGE( 0x0320, 0x032f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)
7676   AM_RANGE( 0x0400, 0xbfff) AM_RAM
7777   AM_RANGE( 0xc000, 0xffff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank2")
7878ADDRESS_MAP_END
r9146r9147
356356static const centronics_interface oric_centronics_config =
357357{
358358   FALSE,
359   DEVCB_DEVICE_LINE("via6522_0", via_ca1_w),
359   DEVCB_DEVICE_LINE_MEMBER("via6522_0", via6522_device, write_ca1),
360360   DEVCB_NULL,
361361   DEVCB_NULL
362362};
src/mess/drivers/tk80bs.c
r9146r9147
2828
2929static ADDRESS_MAP_START(tk80_mem, ADDRESS_SPACE_PROGRAM, 8)
3030   ADDRESS_MAP_UNMAP_HIGH
31   AM_RANGE(0x0000, 0x03ff) AM_ROM
31   AM_RANGE(0x0000, 0x02ff) AM_ROM
32   AM_RANGE(0x0300, 0x03ff) AM_RAM // EEPROM
3233   AM_RANGE(0x8000, 0x83ff) AM_RAM // RAM
3334ADDRESS_MAP_END
3435
3536static ADDRESS_MAP_START( tk80_io , ADDRESS_SPACE_IO, 8)
3637   ADDRESS_MAP_UNMAP_HIGH
38   //AM_RANGE(0xf8, 0xfb) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w)
3739ADDRESS_MAP_END
3840
3941/* Input ports */
r9146r9147
301303   GFXDECODE_ENTRY( "gfx", 0x0000, tk80bs_charlayout, 0, 1 )
302304GFXDECODE_END
303305
304#if 0
305306static READ8_DEVICE_HANDLER( key_matrix_r )
306307{
307308   printf("A R\n");
r9146r9147
329330   DEVCB_NULL,                     /* Port B write */
330331   DEVCB_HANDLER(serial_out_w)         /* Port C write */
331332};
332#endif
333333
334
334335static MACHINE_CONFIG_START( tk80, driver_device )
335336    /* basic machine hardware */
336337    MDRV_CPU_ADD("maincpu",I8080, XTAL_1MHz)
r9146r9147
349350    MDRV_PALETTE_LENGTH(2)
350351    MDRV_PALETTE_INIT(black_and_white)
351352
353   MDRV_I8255A_ADD( "ppi8255_0", ppi8255_intf_0 )
354   
352355    MDRV_VIDEO_START(tk80)
353356    MDRV_VIDEO_UPDATE(tk80)
354357MACHINE_CONFIG_END
src/mess/drivers/microtan.c
r9146r9147
5959   AM_RANGE(0xbc01, 0xbc01) AM_DEVREADWRITE("ay8910.1", ay8910_r, ay8910_data_w)
6060   AM_RANGE(0xbc02, 0xbc02) AM_DEVWRITE("ay8910.2", ay8910_address_w)
6161   AM_RANGE(0xbc03, 0xbc03) AM_DEVREADWRITE("ay8910.2", ay8910_r, ay8910_data_w)
62   AM_RANGE(0xbfc0, 0xbfcf) AM_DEVREADWRITE("via6522_0", via_r, via_w)
62   AM_RANGE(0xbfc0, 0xbfcf) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
6363   AM_RANGE(0xbfd0, 0xbfd3) AM_DEVREADWRITE("acia", acia_6551_r, acia_6551_w)
64   AM_RANGE(0xbfe0, 0xbfef) AM_DEVREADWRITE("via6522_1", via_r, via_w)
64   AM_RANGE(0xbfe0, 0xbfef) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)
6565   AM_RANGE(0xbff0, 0xbfff) AM_READWRITE(microtan_bffx_r, microtan_bffx_w)
6666   AM_RANGE(0xc000, 0xe7ff) AM_ROM
6767   AM_RANGE(0xf000, 0xffff) AM_ROM
src/mess/drivers/ssystem3.c
r9146r9147
216216
217217static WRITE8_DEVICE_HANDLER(ssystem3_via_write_b)
218218{
219   running_device *via_0 = device->machine->device("via6522_0");
219   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
220   address_space* space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
220221   UINT8 d;
221222
222223   ssystem3_playfield_write(device->machine, data&1, data&8);
r9146r9147
225226   d=ssystem3_via_read_b(via_0, 0)&~0x40;
226227   if (data&0x80) d|=0x40;
227228   //  d&=~0x8f;
228   via_portb_w( via_0, 0, d );
229   via_0->write_portb(*space,0, d );
229230}
230231
231232static const via6522_interface ssystem3_via_config=
r9146r9147
259260  probably zusatzger??t memory (battery powered ram 256x4? at 0x4000)
260261  $40ff low nibble ram if playfield module (else init with normal playfield)
261262 */
262   AM_RANGE( 0x6000, 0x600f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
263   AM_RANGE( 0x6000, 0x600f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)
263264#if 1
264265   AM_RANGE( 0xc000, 0xdfff) AM_ROM
265266   AM_RANGE( 0xf000, 0xffff) AM_ROM
src/mess/drivers/aim65_40.c
r9146r9147
5858static ADDRESS_MAP_START( aim65_40_mem, ADDRESS_SPACE_PROGRAM, 8 )
5959   AM_RANGE(0x0000, 0x3fff) AM_RAM
6060   AM_RANGE(0xa000, 0xff7f) AM_ROM
61   AM_RANGE(0xffa0, 0xffaf) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
62   AM_RANGE(0xffb0, 0xffbf) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
63   AM_RANGE(0xffc0, 0xffcf) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
61   AM_RANGE(0xffa0, 0xffaf) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
62   AM_RANGE(0xffb0, 0xffbf) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
63   AM_RANGE(0xffc0, 0xffcf) AM_DEVREADWRITE_MODERN(M6522_0_TAG, via6522_device, read, write)
6464   AM_RANGE(0xffd0, 0xffd3) AM_DEVREADWRITE(M6551_TAG, acia_6551_r, acia_6551_w)
6565   AM_RANGE(0xffe0, 0xffff) AM_ROM
6666ADDRESS_MAP_END
src/mess/drivers/jr100.c
r9146r9147
2727static bool jr100_use_pcg;
2828static UINT8 jr100_speaker;
2929
30static WRITE8_DEVICE_HANDLER( jr100_via_w )
30static WRITE8_HANDLER( jr100_via_w )
3131{
3232   static UINT16 t1latch;
3333   static UINT8 beep_en;
r9146r9147
3939      beep_en = ((data & 0xe0) == 0xe0);
4040
4141      if(!beep_en)
42         beep_set_state(device->machine->device("beeper"),0);
42         beep_set_state(space->machine->device("beeper"),0);
4343   }
4444
4545   /* T1L-L */
r9146r9147
5858      /* writing here actually enables the beeper, if above masking condition is satisfied */
5959      if(beep_en)
6060      {
61         beep_set_state(device->machine->device("beeper"),1);
62         beep_set_frequency(device->machine->device("beeper"),894886.25 / (double)(t1latch) / 2.0);
61         beep_set_state(space->machine->device("beeper"),1);
62         beep_set_frequency(space->machine->device("beeper"),894886.25 / (double)(t1latch) / 2.0);
6363      }
6464   }
65
66   via_w(device,offset,data);
65   via6522_device *via = space->machine->device<via6522_device>("via");   
66   via->write(*space,offset,data);
6767}
6868
6969static ADDRESS_MAP_START(jr100_mem, ADDRESS_SPACE_PROGRAM, 8)
r9146r9147
7171   AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE(&jr100_ram)
7272   AM_RANGE(0xc000, 0xc0ff) AM_RAM AM_BASE(&jr100_pcg)
7373   AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr100_vram)
74   AM_RANGE(0xc800, 0xc80f) AM_DEVREADWRITE("via", via_r, jr100_via_w)
74   AM_RANGE(0xc800, 0xc80f) AM_DEVREAD_MODERN("via", via6522_device, read) AM_WRITE(jr100_via_w)
7575   AM_RANGE(0xe000, 0xffff) AM_ROM
7676ADDRESS_MAP_END
7777
r9146r9147
263263   speaker_level_w(speaker,jr100_speaker);
264264   jr100_speaker = 0;
265265
266   running_device *via = timer.machine->device("via");
266   via6522_device *via = timer.machine->device<via6522_device>("via");
267267   double level = cassette_input(timer.machine->device("cassette"));
268268   if (level > 0.0) {
269      via_ca1_w(via, 0);
270      via_cb1_w(via, 0);
269      via->write_ca1(0);
270      via->write_cb1(0);
271271   } else {
272      via_ca1_w(via, 1);
273      via_cb1_w(via, 1);
272      via->write_ca1(1);
273      via->write_cb1(1);
274274   }
275275
276276
src/mess/drivers/mac.c
r9146r9147
228228static READ16_HANDLER ( mac_rbv_r )
229229{
230230   int data;
231   running_device *via_1 = space->machine->device("via6522_1");
231   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
232232
233233   logerror("rbv_r: %x, mask %x\n", offset, mem_mask);
234234
r9146r9147
250250   offset >>= 8;
251251   offset &= 0x0f;
252252
253   data = via_r(via_1, offset);
253   data = via_1->read(*space, offset);
254254
255255   return (data & 0xff) | (data << 8);
256256}
257257
258258static WRITE16_HANDLER ( mac_rbv_w )
259259{
260   running_device *via_1 = space->machine->device("via6522_1");
260   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
261261
262262   logerror("rbv_w: %x to offset %x, mask %x\n", data, offset, mem_mask);
263263
r9146r9147
265265   offset &= 0x0f;
266266
267267   if (ACCESSING_BITS_8_15)
268      via_w(via_1, offset, (data >> 8) & 0xff);
268      via_1->write(*space, offset, (data >> 8) & 0xff);
269269}
270270
271271// LC/LC II "V8" video and friends
r9146r9147
277277static READ16_HANDLER ( mac_v8_r )
278278{
279279   int data, viaoffs;
280   running_device *via_1 = space->machine->device("via6522_1");
280   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
281281
282282//  printf("v8_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu));
283283
r9146r9147
286286   switch (offset)
287287   {
288288      case 0:
289         data = via_r(via_1, viaoffs);
289         data = via_1->read(*space, viaoffs);
290290         return (data<<8) | v8_regs[0];
291291
292292      default:
293         data = via_r(via_1, viaoffs);
293         data = via_1->read(*space, viaoffs);
294294         return (data<<8)|data;
295295   }
296296
r9146r9147
298298
299299static WRITE16_HANDLER ( mac_v8_w )
300300{
301   running_device *via_1 = space->machine->device("via6522_1");
301   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
302302   int viaoffs;
303303
304304//  printf("v8_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu));
r9146r9147
310310      case 0:
311311         if (ACCESSING_BITS_8_15)
312312         {
313            via_w(via_1, viaoffs, (data >> 8) & 0xff);
313            via_1->write(*space, viaoffs, (data >> 8) & 0xff);
314314         }
315315         else
316316         {
r9146r9147
321321      default:
322322         if (ACCESSING_BITS_8_15)
323323         {
324            via_w(via_1, viaoffs, (data >> 8) & 0xff);
324            via_1->write(*space, viaoffs, (data >> 8) & 0xff);
325325         }
326326         break;
327327   }
r9146r9147
369369static READ16_HANDLER ( mac_sonora_r )
370370{
371371   int data, viaoffs;
372   running_device *via_1 = space->machine->device("via6522_1");
372   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
373373
374374//  printf("sonora_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu));
375375
r9146r9147
378378   switch (offset)
379379   {
380380      case 0:
381         data = via_r(via_1, viaoffs);
381         data = via_1->read(*space, viaoffs);
382382         return (data<<8) | sonora_regs[0];
383383
384384      default:
385         data = via_r(via_1, viaoffs);
385         data = via_1->read(*space, viaoffs);
386386         return (data<<8)|data;
387387   }
388388
r9146r9147
390390
391391static WRITE16_HANDLER ( mac_sonora_w )
392392{
393   running_device *via_1 = space->machine->device("via6522_1");
393   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
394394   int viaoffs;
395395
396396//  printf("sonora_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu));
r9146r9147
402402      case 0:
403403         if (ACCESSING_BITS_8_15)
404404         {
405            via_w(via_1, viaoffs, (data >> 8) & 0xff);
405            via_1->write(*space, viaoffs, (data >> 8) & 0xff);
406406         }
407407         else
408408         {
r9146r9147
413413      default:
414414         if (ACCESSING_BITS_8_15)
415415         {
416            via_w(via_1, viaoffs, (data >> 8) & 0xff);
416            via_1->write(*space, viaoffs, (data >> 8) & 0xff);
417417         }
418418         break;
419419   }
src/mess/drivers/sym1.c
r9146r9147
4343   AM_RANGE(0x0800, 0x0bff) AM_RAMBANK("bank3") AM_BASE(&sym1_ram_2k)
4444   AM_RANGE(0x0c00, 0x0fff) AM_RAMBANK("bank4") AM_BASE(&sym1_ram_3k)
4545   AM_RANGE(0x8000, 0x8fff) AM_ROM AM_BASE(&sym1_monitor)       /* U20 Monitor ROM */
46   AM_RANGE(0xa000, 0xa00f) AM_DEVREADWRITE("via6522_0", via_r, via_w)      /* U25 VIA #1 */
46   AM_RANGE(0xa000, 0xa00f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)      /* U25 VIA #1 */
4747   AM_RANGE(0xa400, 0xa40f) AM_DEVREADWRITE("riot", riot6532_r, riot6532_w)  /* U27 RIOT */
4848   AM_RANGE(0xa600, 0xa67f) AM_RAMBANK("bank5") AM_BASE(&sym1_riot_ram)  /* U27 RIOT RAM */
49   AM_RANGE(0xa800, 0xa80f) AM_DEVREADWRITE("via6522_1", via_r, via_w)      /* U28 VIA #2 */
50   AM_RANGE(0xac00, 0xac0f) AM_DEVREADWRITE("via6522_2", via_r, via_w)      /* U29 VIA #3 */
49   AM_RANGE(0xa800, 0xa80f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)      /* U28 VIA #2 */
50   AM_RANGE(0xac00, 0xac0f) AM_DEVREADWRITE_MODERN("via6522_2", via6522_device, read, write)      /* U29 VIA #3 */
5151   AM_RANGE(0xb000, 0xefff) AM_ROM
5252ADDRESS_MAP_END
5353
src/mess/drivers/victor9k.c
r9146r9147
4949   AM_RANGE(0xe0040, 0xe0043) AM_DEVREADWRITE(UPD7201_TAG, upd7201_cd_ba_r, upd7201_cd_ba_w)
5050   AM_RANGE(0xe8000, 0xe8000) AM_DEVREADWRITE(HD46505S_TAG, mc6845_status_r, mc6845_address_w)
5151   AM_RANGE(0xe8001, 0xe8001) AM_DEVREADWRITE(HD46505S_TAG, mc6845_register_r, mc6845_register_w)
52   AM_RANGE(0xe8020, 0xe802f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
53   AM_RANGE(0xe8040, 0xe804f) AM_DEVREADWRITE(M6522_2_TAG, via_r, via_w)
52   AM_RANGE(0xe8020, 0xe802f) AM_DEVREADWRITE_MODERN(M6522_1_TAG, via6522_device, read, write)
53   AM_RANGE(0xe8040, 0xe804f) AM_DEVREADWRITE_MODERN(M6522_2_TAG, via6522_device, read, write)
5454   AM_RANGE(0xe8060, 0xe8061) AM_DEVREADWRITE(MC6852_TAG, mc6852_r, mc6852_w)
55   AM_RANGE(0xe8080, 0xe808f) AM_DEVREADWRITE(M6522_3_TAG, via_r, via_w)
56   AM_RANGE(0xe80a0, 0xe80af) AM_DEVREADWRITE(M6522_4_TAG, via_r, via_w)
57   AM_RANGE(0xe80c0, 0xe80cf) AM_DEVREADWRITE(M6522_6_TAG, via_r, via_w)
58   AM_RANGE(0xe80e0, 0xe80ef) AM_DEVREADWRITE(M6522_5_TAG, via_r, via_w)
55   AM_RANGE(0xe8080, 0xe808f) AM_DEVREADWRITE_MODERN(M6522_3_TAG, via6522_device, read, write)
56   AM_RANGE(0xe80a0, 0xe80af) AM_DEVREADWRITE_MODERN(M6522_4_TAG, via6522_device, read, write)
57   AM_RANGE(0xe80c0, 0xe80cf) AM_DEVREADWRITE_MODERN(M6522_6_TAG, via6522_device, read, write)
58   AM_RANGE(0xe80e0, 0xe80ef) AM_DEVREADWRITE_MODERN(M6522_5_TAG, via6522_device, read, write)
5959   AM_RANGE(0xf0000, 0xf0fff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(victor9k_state, video_ram)
6060   AM_RANGE(0xfe000, 0xfffff) AM_ROM AM_REGION(I8088_TAG, 0)
6161ADDRESS_MAP_END
r9146r9147
958958
959959static IEEE488_DAISY( ieee488_daisy )
960960{
961   { M6522_1_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(M6522_1_TAG, via_ca1_w), DEVCB_DEVICE_LINE(M6522_1_TAG, via_ca2_w) },
961   { M6522_1_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_ca1), DEVCB_DEVICE_LINE_MEMBER(M6522_1_TAG, via6522_device, write_ca2) },
962962   { NULL }
963963};
964964
src/mess/drivers/atom.c
r9146r9147
205205   AM_RANGE(0xb000, 0xb003) AM_MIRROR(0x3fc) AM_DEVREADWRITE(INS8255_TAG, i8255a_r, i8255a_w)
206206//  AM_RANGE(0xb400, 0xb403) AM_DEVREADWRITE(MC6854_TAG, mc6854_r, mc6854_w)
207207//  AM_RANGE(0xb404, 0xb404) AM_READ_PORT("ECONET")
208   AM_RANGE(0xb800, 0xb80f) AM_MIRROR(0x3f0) AM_DEVREADWRITE(R6522_TAG, via_r, via_w)
208   AM_RANGE(0xb800, 0xb80f) AM_MIRROR(0x3f0) AM_DEVREADWRITE_MODERN(R6522_TAG, via6522_device, read, write)
209209   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION(SY6502_TAG, 0)
210210ADDRESS_MAP_END
211211
r9146r9147
595595static const centronics_interface atom_centronics_config =
596596{
597597   FALSE,
598   DEVCB_DEVICE_LINE(R6522_TAG, via_ca1_w),
598   DEVCB_DEVICE_LINE_MEMBER(R6522_TAG, via6522_device,write_ca1),
599599   DEVCB_NULL,
600600   DEVCB_NULL
601601};
src/mess/drivers/ec65.c
r9146r9147
3737   AM_RANGE(0xe000, 0xe003) AM_DEVREADWRITE(PIA6821_TAG, pia6821_r, pia6821_w)
3838   AM_RANGE(0xe010, 0xe010) AM_DEVREADWRITE(ACIA6850_TAG, acia6850_stat_r, acia6850_ctrl_w)
3939   AM_RANGE(0xe011, 0xe011) AM_DEVREADWRITE(ACIA6850_TAG, acia6850_data_r, acia6850_data_w)
40   AM_RANGE(0xe100, 0xe10f) AM_DEVREADWRITE(VIA6522_0_TAG, via_r, via_w)
41   AM_RANGE(0xe110, 0xe11f) AM_DEVREADWRITE(VIA6522_1_TAG, via_r, via_w)
40   AM_RANGE(0xe100, 0xe10f) AM_DEVREADWRITE_MODERN(VIA6522_0_TAG, via6522_device, read, write)
41   AM_RANGE(0xe110, 0xe11f) AM_DEVREADWRITE_MODERN(VIA6522_1_TAG, via6522_device, read, write)
4242   AM_RANGE(0xe130, 0xe133) AM_DEVREADWRITE(ACIA6551_TAG,  acia_6551_r, acia_6551_w )
4343   AM_RANGE(0xe140, 0xe140) AM_DEVWRITE(MC6845_TAG, mc6845_address_w)
4444   AM_RANGE(0xe141, 0xe141) AM_DEVREADWRITE(MC6845_TAG, mc6845_register_r , mc6845_register_w)
src/mess/drivers/e01.c
r9146r9147
231231   AM_RANGE(0xfc04, 0xfc04) AM_MIRROR(0x00c3) AM_READWRITE(rtc_data_r, rtc_data_w)
232232   AM_RANGE(0xfc08, 0xfc08) AM_MIRROR(0x00c0) AM_READ(ram_select_r) AM_DEVWRITE(WD2793_TAG, floppy_w)
233233   AM_RANGE(0xfc0c, 0xfc0f) AM_MIRROR(0x00c0) AM_DEVREADWRITE(WD2793_TAG, wd17xx_r, wd17xx_w)
234   AM_RANGE(0xfc10, 0xfc1f) AM_MIRROR(0x00c0) AM_DEVREADWRITE(R6522_TAG, via_r, via_w)
234   AM_RANGE(0xfc10, 0xfc1f) AM_MIRROR(0x00c0) AM_DEVREADWRITE_MODERN(R6522_TAG, via6522_device, read, write)
235235   AM_RANGE(0xfc20, 0xfc23) AM_MIRROR(0x00c0) AM_DEVREADWRITE(MC6854_TAG, mc6854_r, mc6854_w)
236236   AM_RANGE(0xfc24, 0xfc24) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_disable_r, network_irq_disable_w)
237237   AM_RANGE(0xfc28, 0xfc28) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_enable_r, network_irq_enable_w)
src/mess/drivers/bbc.c
r9146r9147
117117                                                               /* W: fe20-fe2f  Video ULA      Video system chip               */
118118   AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(bbc_fe_r     , bbc_page_selecta_w   )   /* R: fe30-fe3f  NC             Not Connected                   */
119119                                                               /* W: fe30-fe3f  84LS161        Paged ROM selector              */
120   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE("via6522_0", via_r, via_w)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
120   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
121121   AM_RANGE(0xfe60, 0xfe7f) AM_NOP                                       /*    fe60-fe7f  6522 VIA       1 USER VIA                      */
122122   AM_RANGE(0xfe80, 0xfe9f) AM_NOP                                       /*    fe80-fe9f  8271/1770 FDC  1 Floppy disc controller        */
123123   AM_RANGE(0xfea0, 0xfebf) AM_READ     (bbc_fe_r                        )   /*    fea0-febf  68B54 ADLC     1 ECONET controller             */
r9146r9147
151151                                                               /* W: fe20-fe2f  Video ULA      Video system chip               */
152152   AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(bbc_fe_r     , bbc_page_selectb_w   )   /* R: fe30-fe3f  NC             Not Connected                   */
153153                                                               /* W: fe30-fe3f  84LS161        Paged ROM selector              */
154   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE("via6522_0", via_r, via_w)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
155   AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE("via6522_1", via_r, via_w)   /*    fe60-fe7f  6522 VIA       USER VIA                        */
154   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
155   AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)   /*    fe60-fe7f  6522 VIA       USER VIA                        */
156156   AM_RANGE(0xfe80, 0xfe9f) AM_READWRITE(bbc_disc_r      , bbc_disc_w      )   /*    fe80-fe9f  8271 FDC       Floppy disc controller          */
157157   AM_RANGE(0xfea0, 0xfebf) AM_READ    (bbc_fe_r                        )   /*    fea0-febf  68B54 ADLC     ECONET controller               */
158158   AM_RANGE(0xfec0, 0xfedf) AM_DEVREADWRITE("upd7002",uPD7002_r,uPD7002_w   )   /*    fec0-fedf  uPD7002        Analogue to digital converter   */
r9146r9147
186186                                                               /* W: fe20-fe2f  Video ULA      Video system chip               */
187187   AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(bbc_fe_r      , bbc_page_selectbp_w   )   /* R: fe30-fe3f  NC             Not Connected                   */
188188                                                               /* W: fe30-fe3f  84LS161        Paged ROM selector              */
189   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE("via6522_0", via_r, via_w)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
190   AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE("via6522_1", via_r, via_w)   /*    fe60-fe7f  6522 VIA       USER VIA                        */
189   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
190   AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)   /*    fe60-fe7f  6522 VIA       USER VIA                        */
191191   AM_RANGE(0xfe80, 0xfe9f) AM_READWRITE(bbc_wd1770_read   , bbc_wd1770_write   )   /*    fe80-fe9f  1770 FDC       Floppy disc controller          */
192192   AM_RANGE(0xfea0, 0xfebf) AM_READ     (bbc_fe_r                     )   /*    fea0-febf  68B54 ADLC     ECONET controller               */
193193   AM_RANGE(0xfec0, 0xfedf) AM_DEVREADWRITE("upd7002", uPD7002_r, uPD7002_w)   /*    fec0-fedf  uPD7002        Analogue to digital converter   */
r9146r9147
223223                                                               /* W: fe20-fe2f  Video ULA      Video system chip               */
224224   AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(bbc_fe_r      , bbc_page_selectbp_w   )   /* R: fe30-fe3f  NC             Not Connected                   */
225225                                                               /* W: fe30-fe3f  84LS161        Paged ROM selector              */
226   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE("via6522_0", via_r, via_w)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
227   AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE("via6522_1", via_r, via_w)   /*    fe60-fe7f  6522 VIA       USER VIA                        */
226   AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)   /*    fe40-fe5f  6522 VIA       SYSTEM VIA                      */
227   AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)   /*    fe60-fe7f  6522 VIA       USER VIA                        */
228228   AM_RANGE(0xfe80, 0xfe9f) AM_READWRITE(bbc_wd1770_read   , bbc_wd1770_write   )   /*    fe80-fe9f  1770 FDC       Floppy disc controller          */
229229   AM_RANGE(0xfea0, 0xfebf) AM_READ     (bbc_fe_r                     )   /*    fea0-febf  68B54 ADLC     ECONET controller               */
230230   AM_RANGE(0xfec0, 0xfedf) AM_DEVREADWRITE("upd7002",uPD7002_r, uPD7002_w   )   /*    fec0-fedf  uPD7002        Analogue to digital converter   */
r9146r9147
289289    AM_RANGE(0xfe30, 0xfe33) AM_READWRITE(return8_FE        , bbc_page_selectbp_w   )         fe30-fe33  84LS161        Paged ROM selector
290290    AM_RANGE(0xfe34, 0xfe37) AM_READWRITE(bbcm_ACCCON_read  , bbcm_ACCCON_write )         fe34-fe37  ACCCON         ACCCON select Latch
291291    AM_RANGE(0xfe38, 0xfe3f) AM_READ     (return8_FE                            )         fe38-fe3f  NC
292    AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE("via6522_0", via_r, via_w)          fe40-fe5f  6522 VIA       SYSTEM VIA
293    AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE("via6522_1", via_r, via_w)          fe60-fe7f  6522 VIA       USER VIA
292    AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE_MODERN("via6522_0", via6522_device, read, write)          fe40-fe5f  6522 VIA       SYSTEM VIA
293    AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE_MODERN("via6522_1", via6522_device, read, write)          fe60-fe7f  6522 VIA       USER VIA
294294    AM_RANGE(0xfe80, 0xfe9f) AM_READ     (return8_FE                            )         fe80-fe9f  NC
295295    AM_RANGE(0xfea0, 0xfebf) AM_READ     (return8_FE                            )         fea0-febf  68B54 ADLC     ECONET controller
296296    AM_RANGE(0xfec0, 0xfedf) AM_READ     (return8_FE                            )         fec0-fedf  NC
r9146r9147
710710
711711static INTERRUPT_GEN( bbcb_vsync )
712712{
713   running_device *via_0 = device->machine->device("via6522_0");
714   via_ca1_w(via_0, 1);
715   via_ca1_w(via_0, 0);
713   via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
714   via_0->write_ca1(1);
715   via_0->write_ca1(0);
716716   bbc_frameclock();
717717}
718718
r9146r9147
736736
737737static WRITE_LINE_DEVICE_HANDLER(bbcb_ack_w)
738738{
739   via_ca1_w(device, !state); /* ack seems to be inverted? */
739   via6522_device *via_1 = device->machine->device<via6522_device>("via6522_1");
740   via_1->write_ca1(!state); /* ack seems to be inverted? */
740741}
741742
742743static const centronics_interface bbcb_centronics_config =
743744{
744745   FALSE,
745   DEVCB_DEVICE_LINE("via6522_1", bbcb_ack_w),
746   DEVCB_DEVICE_LINE("via6522_1",bbcb_ack_w),
746747   DEVCB_NULL,
747748   DEVCB_NULL
748749};
makefile
r9146r9147
2424#-------------------------------------------------
2525
2626ifndef TARGET
27TARGET = mess
27TARGET = mame
2828endif
2929
3030ifndef SUBTARGET
r9146r9147
489489#-------------------------------------------------
490490
491491# add core include paths
492CCOMFLAGS += \
492INCPATH += \
493493   -I$(SRC)/$(TARGET) \
494494   -I$(OBJ)/$(TARGET)/layout \
495495   -I$(SRC)/emu \
r9146r9147
500500   -I$(SRC)/osd/$(OSD) \
501501
502502
503
503504#-------------------------------------------------
504505# archiving flags
505506#-------------------------------------------------
r9146r9147
585586
586587# add expat XML library
587588ifeq ($(BUILD_EXPAT),1)
588CCOMFLAGS += -I$(SRC)/lib/expat
589INCPATH += -I$(SRC)/lib/expat
589590EXPAT = $(OBJ)/libexpat.a
590591else
591592LIBS += -lexpat
r9146r9147
594595
595596# add ZLIB compression library
596597ifeq ($(BUILD_ZLIB),1)
597CCOMFLAGS += -I$(SRC)/lib/zlib
598INCPATH += -I$(SRC)/lib/zlib
598599ZLIB = $(OBJ)/libz.a
599600else
600601LIBS += -lz
r9146r9147
643644include $(SRC)/tools/tools.mak
644645
645646# combine the various definitions to one
647CCOMFLAGS += $(INCPATH)
646648CDEFS = $(DEFS)
647649
648650
r9146r9147
655657
656658buildtools: maketree $(BUILD)
657659
660# In order to keep dependencies reasonable, we exclude objects in the base of
661# $(SRC)/emu, as well as all the OSD objects and anything in the $(OBJ) tree
662depend: maketree $(MAKEDEP_TARGET)
663   @echo Rebuilding depend.mak...
664   $(MAKEDEP) -I. $(INCPATH) -X$(SRC)/emu -X$(SRC)/osd/... -X$(OBJ)/... src/mame > depend.mak
665
666INCPATH += \
667   -I$(SRC)/$(TARGET) \
668   -I$(OBJ)/$(TARGET)/layout \
669   -I$(SRC)/emu \
670   -I$(OBJ)/emu \
671   -I$(OBJ)/emu/layout \
672   -I$(SRC)/lib/util \
673   -I$(SRC)/osd \
674   -I$(SRC)/osd/$(OSD) \
675
658676tools: maketree $(TOOLS)
659677
660678maketree: $(sort $(OBJDIRS))
r9146r9147
725743   @echo Compiling $<...
726744   $(CC) $(CDEFS) $(CFLAGS) -S $< -o $@
727745
728$(OBJ)/%.lh: $(SRC)/%.lay $(FILE2STR)
746$(OBJ)/%.lh: $(SRC)/%.lay $(FILE2STR_TARGET)
729747   @echo Converting $<...
730748   @$(FILE2STR) $< $@ layout_$(basename $(notdir $<))
731749
732$(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC) $(FILE2STR)
750$(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC_TARGET) $(FILE2STR_TARGET)
733751   @echo Converting $<...
734752   @$(PNG2BDC) $< $(OBJ)/temp.bdc
735753   @$(FILE2STR) $(OBJ)/temp.bdc $@ font_$(basename $(notdir $<)) UINT8
r9146r9147
745763   $(CC) $(CDEFS) $(COBJFLAGS) $(CCOMFLAGS) -c $< -o $@
746764endif
747765
766
767
768#-------------------------------------------------
769# optional dependencies file
770#-------------------------------------------------
771
772-include depend.mak

Previous 15994 Revisions Next


© 1998-2018 The MESS Team