Previous 199869 Revisions Next

r34719 Tuesday 27th January, 2015 at 21:35:09 UTC by Couriersud
Amended comment about prescale. (nw)
[/trunk]makefile
[hash]lantutor.xml pasogo.xml
[src]version.c
[src/build]flags_clang.mak
[src/emu]clifront.c cliopts.c devfind.c devfind.h distate.c emucore.c emuopts.c emuopts.h luaengine.c machine.c mame.c parameters.c render.c render.h rendfont.c
[src/emu/bus/a8sio]a8sio.c cassette.c
[src/emu/bus/nes_ctrl]4score.c 4score.h arkpaddle.c arkpaddle.h bcbattle.c ctrl.c ctrl.h fckeybrd.c ftrainer.c hori.c hori.h joypad.c joypad.h konamihs.c miracle.c miracle.h mjpanel.c pachinko.c partytap.c powerpad.c suborkey.c zapper.c
[src/emu/bus/sms_ctrl]joypad.c
[src/emu/bus/vcs]dpc.c
[src/emu/cpu/arcompact]arcompact.c arcompact.h arcompact_execute.c
[src/emu/cpu/h8]h8.c
[src/emu/cpu/i386]i386dasm.c
[src/emu/cpu/m6502]m4510.c m6502.c m6502.h om4510.lst om65ce02.lst
[src/emu/cpu/m68000]m68k_in.c m68kcpu.c m68kfpu.inc
[src/emu/cpu/tms0980]tms0980.c tms0980d.c
[src/emu/drivers]xtal.h
[src/emu/machine]intelfsh.c jvshost.c netlist.c
[src/emu/netlist]nl_base.c nl_base.h nl_config.h nl_factory.c nl_setup.c nl_setup.h plists.h pstate.c
[src/emu/netlist/analog]nld_ms_direct.h nld_ms_gauss_seidel.h nld_opamps.c nld_solver.c nld_solver.h
[src/emu/netlist/devices]net_lib.c nld_4020.c nld_cmos.h nld_system.h
[src/emu/sound]qs1000.c tiasound.c
[src/emu/ui]barcode.c devctrl.h devopt.c devopt.h filemngr.c imgcntrl.c imgcntrl.h info.c inputmap.c sliders.c slotopt.h tapectrl.c
[src/emu/video]h63484.c h63484.h
[src/lib/util]coretmpl.h palette.h
[src/mame]mame.lst
[src/mame/audio]mario.c seibu.c seibu.h
[src/mame/drivers]aleck64.c backfire.c bfm_sc4h.c bfm_sc5.c bfm_swp.c bishi.c btime.c cabal.c calomega.c cps1.c ddenlovr.c dec0.c deco156.c dgpix.c dkong.c dynax.c eolith.c eolith16.c eolithsp.c exidy.c funkball.c galaxian.c gticlub.c gts80a.c gumbo.c gunpey.c hikaru.c limenko.c lordgun.c maygayep.c midas.c model2.c model3.c naomi.c nmk16.c overdriv.c peplus.c psikyosh.c psychic5.c seta2.c shanghai.c silkroad.c stv.c taitottl.c toaplan2.c tourtabl.c twinkle.c tx1.c vegaeo.c vicdual.c zn.c
[src/mame/includes]bfm_sc45.h bfm_sc5.h bishi.h bogeyman.h calomega.h cave.h dec0.h dynax.h eolith.h exidy.h hyhoo.h lordgun.h m58.h mario.h model2.h nb1413m3.h nmk16.h paradise.h pastelg.h powerins.h quizpani.h senjyo.h silkroad.h stadhero.h stfight.h stlforce.h strnskil.h toaplan2.h tx1.h vaportra.h xyonix.h
[src/mame/layout]gts80a_caveman.lay
[src/mame/machine]315-5838_317-0229_comp.c 315-5838_317-0229_comp.h 315-5881_crypt.c dec0.c mie.c mie.h stfight.c stvprot.c
[src/mame/video]eolith.c gp9001.c pastelg.c taitoair.c tia.c tia.h tx1.c
[src/mess]mess.mak
[src/mess/drivers]a2600.c banctec.c bw12.c c65.c c65_old.c cat.c gamate.c hp16500.c hp9k_3xx.c nes.c ngen.c pasogo.c splitsec.c tispeak.c vt100.c
[src/mess/includes]c65.h mac.h
[src/mess/machine]amstrad.c c65.c* c65_old.c macadb.c nes.c
[src/osd]osdcore.c osdepend.h
[src/osd/modules]osdmodule.c osdmodule.h
[src/osd/modules/debugger]debug_module.h debugint.c debugqt.c debugwin.c none.c
[src/osd/modules/font]font_module.h font_none.c font_osx.c font_sdl.c font_windows.c
[src/osd/modules/lib]osdlib_macosx.c osdlib_os2.c osdlib_unix.c osdlib_win32.c osdobj_common.c osdobj_common.h
[src/osd/modules/midi]none.c portmidi.c
[src/osd/modules/sound]direct_sound.c js_sound.c none.c sdl_sound.c sound_module.h
[src/osd/modules/sync]sync_mini.c sync_ntc.c sync_os2.c sync_sdl.c sync_tc.c sync_windows.c work_osd.c
[src/osd/osdmini]minimisc.c
[src/osd/sdl]blit13.h draw13.c drawogl.c input.c netdev_pcap.c netdev_pcap_osx.c osdsdl.h sdl.mak sdldir.c sdlfile.c sdlmain.c sdlos_macosx.c sdlos_unix.c sdlos_win32.c sdlptty_unix.c strconv.c video.c video.h window.c window.h
[src/osd/windows]vconv.c windows.mak
[src/tools]chdman.c nltool.c

trunk/hash/lantutor.xml
r243230r243231
3838      <publisher>Texas Instruments</publisher>
3939      <part name="cart" interface="lantutor">
4040         <dataarea name="rom" size="0x10000">
41<!--            <rom name="cd2315.vsm" size="0x4000" crc="" sha1="" offset="0x0000" /> -->
42<!--            <rom name="cd2316.vsm" size="0x4000" crc="" sha1="" offset="0x4000" /> -->
41<!--         <rom name="cd2315.vsm" size="0x4000" crc="" sha1="" offset="0x0000" /> -->
42<!--         <rom name="cd2316.vsm" size="0x4000" crc="" sha1="" offset="0x4000" /> -->
4343            <rom name="cd2317.vsm" size="0x4000" crc="53231c0b" sha1="472117c3d0e28437fa8faa054f98088e06efc2a1" offset="0x8000" />
4444            <rom name="cd2318.vsm" size="0x4000" crc="6c0727bc" sha1="132e39755b122f2cbec6f3e767f5d256a9c1e7ae" offset="0xc000" />
4545         </dataarea>
trunk/hash/pasogo.xml
r243230r243231
22<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
33<softwarelist name="pasogo" description="Koei PasoGo cartridges">
44
5<!--
5<!--
66  Koei PasoGo (パソ碁) undumped games
77
88  Taikyoku-kun I ~ 対局くん I [KS-1001]
trunk/makefile
r243230r243231
607607# warnings only applicable to C++ compiles
608608CPPONLYFLAGS += \
609609   -Woverloaded-virtual
610   
611include $(SRC)/build/cc_detection.mak
610612
611613ifdef SANITIZE
612614CCOMFLAGS += -fsanitize=$(SANITIZE)
613
614615ifneq (,$(findstring thread,$(SANITIZE)))
615616CCOMFLAGS += -fPIE
616617endif
618ifneq (,$(findstring memory,$(SANITIZE)))
619ifneq (,$(findstring clang,$(CC)))
620CCOMFLAGS += -fsanitize-memory-track-origins -fPIE
617621endif
622endif
623ifneq (,$(findstring undefined,$(SANITIZE)))
624ifneq (,$(findstring clang,$(CC)))
625# TODO: check if linker is clang++
626# produces a lot of messages - disable it for now
627CCOMFLAGS += -fno-sanitize=alignment
628# these are false positives because of the way our delegates work
629CCOMFLAGS += -fno-sanitize=function
630# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c when this isn't disabled
631CCOMFLAGS += -fno-sanitize=shift
632# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c, src/emu/cpu/m6809/hd6309.c when this isn't disabled
633CCOMFLAGS += -fno-sanitize=object-size
634# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c, src/emu/cpu/m6809/konami.c, src/emu/cpu/m6809/hd6309.c, src/emu/video/psx.c when this isn't disabled
635CCOMFLAGS += -fno-sanitize=vptr
636# clang takes forever to compile src/emu/video/psx.c when this isn't disabled
637CCOMFLAGS += -fno-sanitize=null
638# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c when this isn't disabled
639CCOMFLAGS += -fno-sanitize=signed-integer-overflow
640endif
641endif
642endif
618643
619include $(SRC)/build/cc_detection.mak
620
621644#-------------------------------------------------
622645# include paths
623646#-------------------------------------------------
r243230r243231
756779ZLIB = $(OBJ)/libz.a
757780else
758781LIBS += -lz
759BASELIBS += -lz
760782ZLIB =
761783endif
762784
r243230r243231
767789# $(OBJ)/libflac++.a
768790else
769791LIBS += -lFLAC
770BASELIBS += -lFLAC
771792FLAC_LIB =
772793endif
773794
r243230r243231
933954   $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ)
934955   @echo Linking $@...
935956ifeq ($(TARGETOS),emscripten)
936# Emscripten's linker seems to be stricter about the ordering of .a files
957   # Emscripten's linker seems to be stricter about the ordering of .a files
937958   $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $(VERSIONOBJ) -Wl,--start-group $^ -Wl,--end-group $(LIBS) -o $@
938959else
939960   $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $(VERSIONOBJ) $^ $(LIBS) -o $@
trunk/src/build/flags_clang.mak
r243230r243231
99# caused by src/mame/video/jagblit.inc on older clang versions
1010CCOMFLAGS += -Wno-constant-logical-operand
1111
12ifneq (,$(findstring undefined,$(SANITIZE)))
13# TODO: check if linker is clang++
14# produces a lot of messages - disable it for now
15CCOMFLAGS += -fno-sanitize=alignment
16# these are false positives because of the way our delegates work
17CCOMFLAGS += -fno-sanitize=function
18endif
19
20ifneq (,$(findstring memory,$(SANITIZE)))
21CCOMFLAGS += -fsanitize-memory-track-origins -fPIE
22endif
23
2412# TODO: needs to use $(CC)
2513TEST_CLANG := $(shell clang --version)
2614
r243230r243231
4129CCOMFLAGS += -Wno-unknown-warning-option
4230# XCode 6.0.1 gives this when using SDL2 in /Library/Frameworks/SDL2.framework/Headers/SDL_syswm.h:150 included from src/osd/sdl/sdlinc.h
4331CCOMFLAGS += -Wno-extern-c-compat
44
45ifneq (,$(findstring undefined,$(SANITIZE)))
46# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c when this isn't disabled
47CCOMFLAGS += -fno-sanitize=shift
48# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c, src/emu/cpu/m6809/hd6309.c when this isn't disabled
49CCOMFLAGS += -fno-sanitize=object-size
50# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c, src/emu/cpu/m6809/konami.c, src/emu/cpu/m6809/hd6309.c, src/emu/video/psx.c when this isn't disabled
51CCOMFLAGS += -fno-sanitize=vptr
52# clang takes forever to compile src/emu/video/psx.c when this isn't disabled
53CCOMFLAGS += -fno-sanitize=null
54# clang takes forever to compile src/emu/cpu/tms57002/tms57002.c when this isn't disabled
55CCOMFLAGS += -fno-sanitize=signed-integer-overflow
5632endif
57endif
5833
5934ifeq ($(TARGETOS),emscripten)
6035CCOMFLAGS += -Qunused-arguments
trunk/src/emu/bus/a8sio/a8sio.c
r243230r243231
217217SLOT_INTERFACE_START(a8sio_cards)
218218   SLOT_INTERFACE("cassette", A8SIO_CASSETTE)
219219SLOT_INTERFACE_END
220
trunk/src/emu/bus/a8sio/cassette.c
r243230r243231
115115         break;
116116   }
117117}
118
trunk/src/emu/bus/nes_ctrl/4score.c
r243230r243231
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
7
8
9 TODO: current implementation is a HACK, due to limitations of the
7 
8 
9 TODO: current implementation is a HACK, due to limitations of the
1010 slot system!
1111 A real Four Score would be connected to both the controller ports of
1212 the NES, but current core cannot emulate something like this until
1313 devices can live their own life and being connected to other devices
1414 at request.
15 In current implementation the device has to be mounted separately in
15 In current implementation the device has to be mounted separately in
1616 the two ports and each enables 2 inputs (this is more or less as hacky
1717 as the non-slot previous one, where the 4 ports were always available
1818 to the emulated system, but it's not a great consolation :( )
r243230r243231
2222 since we could at best have two switches to disable the second player
2323 inputs.
2424
25 Note: Two Pads are hardcoded in inputs below, instead of acting as
25 Note: Two Pads are hardcoded in inputs below, instead of acting as
2626 passthrough for 2 standard joypad devices, in order to show in the
2727 internal UI that they belong to P1+P3 and P2+P4, otherwise they would
2828 be listed as P1+P2 and P3+P4 respectively. This *HAS* to be changed
r243230r243231
171171{
172172   if (data & 0x01)
173173      return;
174
174   
175175   // P3 & P4 inputs in NES Four Score are read serially with P1 & P2
176176   m_latch  = m_joypad1->read();
177   m_latch |= (m_joypad3->read() << 8); // pad 3
177   m_latch |= (m_joypad3->read() << 8); // pad 3
178178   m_latch |= (0x08 << 16); // signature
179179}
180180
r243230r243231
182182{
183183   if (data & 0x01)
184184      return;
185
185   
186186   // P3 & P4 inputs in NES Four Score are read serially with P1 & P2
187187   m_latch = m_joypad2->read();
188   m_latch |= (m_joypad4->read() << 8); // pad 4
188   m_latch |= (m_joypad4->read() << 8); // pad 4
189189   m_latch |= (0x04 << 16); // signature
190190}
trunk/src/emu/bus/nes_ctrl/4score.h
r243230r243231
4747public:
4848   // construction/destruction
4949   nes_4score_p1p3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
50
50   
5151   virtual ioport_constructor device_input_ports() const;
52
52   
5353protected:
5454   virtual void write(UINT8 data);
55
55   
5656private:
5757   required_ioport m_joypad1;
5858   required_ioport m_joypad3;
r243230r243231
6767   nes_4score_p2p4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
6868
6969   virtual ioport_constructor device_input_ports() const;
70
70   
7171protected:
7272   virtual void write(UINT8 data);
73
73   
7474private:
7575   required_ioport m_joypad2;
7676   required_ioport m_joypad4;
trunk/src/emu/bus/nes_ctrl/arkpaddle.c
r243230r243231
105105UINT8 nes_vausfc_device::read_exp(offs_t offset)
106106{
107107   UINT8 ret = 0;
108   if (offset == 0)    //$4016
108   if (offset == 0)   //$4016
109109      ret = m_button->read() << 1;
110   else    //$4017
110   else   //$4017
111111   {
112112      ret = (m_latch & 0x80) >> 6;
113113      m_latch <<= 1;
trunk/src/emu/bus/nes_ctrl/arkpaddle.h
r243230r243231
5656public:
5757   // construction/destruction
5858   nes_vausfc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
59
59   
6060protected:
6161   virtual UINT8 read_bit34() { return 0; }
6262   virtual UINT8 read_exp(offs_t offset);
trunk/src/emu/bus/nes_ctrl/bcbattle.c
r243230r243231
55    TODO: this should be actually emulated as a standalone system with
66    a few 7segments LEDs, once we get a dump of its BIOS
77    At the moment we only emulated the connection with a Famicom
8
8
99    Copyright MESS Team.
1010    Visit http://mamedev.org for licensing and usage restrictions.
1111
r243230r243231
5757         if (m_reader->get_byte_length() == 13)
5858         {
5959            for (int i = 0; i < 13; i++)
60               m_current_barcode[i] = m_reader->read_code() + '0';
60               m_current_barcode[i] = m_reader->read_code() + '0';
6161         }
6262         else if (m_reader->get_byte_length() == 8)
6363         {
6464            for (int i = 0; i < 5; i++)
65               m_current_barcode[i] = 0x20;
65               m_current_barcode[i] = 0x20;
6666            for (int i = 5; i < 13; i++)
67               m_current_barcode[i] = m_reader->read_code() + '0';
67               m_current_barcode[i] = m_reader->read_code() + '0';
6868         }
6969         // read one more, to reset the internal byte counter
7070         m_reader->read_code();
7171
7272         // the string "SUNSOFT" is accepted as well by Barcode World
73         m_current_barcode[13] = 'E';
74         m_current_barcode[14] = 'P';
75         m_current_barcode[15] = 'O';
76         m_current_barcode[16] = 'C';
77         m_current_barcode[17] = 'H';
78         m_current_barcode[18] = 0x0d;
79         m_current_barcode[19] = 0x0a;
73         m_current_barcode[13] = 'E';
74         m_current_barcode[14] = 'P';
75         m_current_barcode[15] = 'O';
76         m_current_barcode[16] = 'C';
77         m_current_barcode[17] = 'H';
78         m_current_barcode[18] = 0x0d;
79         m_current_barcode[19] = 0x0a;
8080         m_pending_code = 1;
8181      }
8282      m_new_code = m_reader->get_pending_code();
r243230r243231
110110   // and sending the proper serial bits, instead of our read_current_bit() function!
111111   battler_timer = timer_alloc(TIMER_BATTLER);
112112   battler_timer->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(1000));
113
113   
114114   save_item(NAME(m_current_barcode));
115115   save_item(NAME(m_new_code));
116116   save_item(NAME(m_pending_code));
r243230r243231
184184UINT8 nes_bcbattle_device::read_exp(offs_t offset)
185185{
186186   UINT8 ret = 0;
187   if (offset == 1)    //$4017
187   if (offset == 1)   //$4017
188188   {
189189      ret |= read_current_bit() << 2;
190190   }
trunk/src/emu/bus/nes_ctrl/ctrl.c
r243230r243231
11/**********************************************************************
22
3    Nintendo Family Computer & Entertainment System controller ports
3    Nintendo Family Computer & Entertainment System controller ports
44    and Family Computer expansion port emulation
55
66    Here we emulate in fact 3 different kind of ports, which are
r243230r243231
99      corresponding address ($4016 for port1, $4017 for port2)
1010    - FC controller ports: these are only hooked to bit 0 of the
1111      corresponding address (so that e.g. a NES Zapper could not
12      be connected to a later FC AV model, because its inputs
12      be connected to a later FC AV model, because its inputs
1313      would not be detected)
1414    - FC expansion port: this is hooked to bits 0-4 of both addresses
1515    To make things a little bit more complex, old FC models have the
1616    controller hardwired to the unit, and the P2 controllers are
17    directly hooked also to one of the expansion port lines (namely,
17    directly hooked also to one of the expansion port lines (namely,
1818    microphone inputs from P2 go to $4016 bit 2)
1919
20    Even if the controller port and the expansion port are
20    Even if the controller port and the expansion port are
2121    physically different (the FC expansion is a 15pin port, while
2222    the controller ports are 7pin), we emulate them as variants of a
2323    common device, exposing the following handlers:
r243230r243231
2525      inputs from controllers
2626    - read_bit34: for bit3,4 reading, expected to be at the correct
2727      offset (but we don't currently check for read_bit34 & 0xf8==0)
28    - read_exp: for reads going through the expansion, with a offset
28    - read_exp: for reads going through the expansion, with a offset
2929      parameter to decide whether we are reading from $4016 and $4017
3030    - write: to acknowledge writes to $4016
3131
32    The driver emulation will take care to only call the correct
33    handlers they have hooks for: Basic usage is that the expansion
34    port calls read_exp, FC ctrl ports call read_bit0, and NES ctrl
35    ports call both read_bit0 and read_bit34. However, to cope with
36    the original FC microphone, we will have the second controller
32    The driver emulation will take care to only call the correct
33    handlers they have hooks for: Basic usage is that the expansion
34    port calls read_exp, FC ctrl ports call read_bit0, and NES ctrl
35    ports call both read_bit0 and read_bit34. However, to cope with
36    the original FC microphone, we will have the second controller
3737    port calling read_exp too.
3838
3939    Copyright MESS Team.
r243230r243231
168168   SLOT_INTERFACE("joypad", NES_JOYPAD)
169169   SLOT_INTERFACE("zapper", NES_ZAPPER)
170170   SLOT_INTERFACE("4score_p1p3", NES_4SCORE_P1P3)
171   SLOT_INTERFACE("miracle_piano", NES_MIRACLE)
171//   SLOT_INTERFACE("miracle_piano", NES_MIRACLE)
172172SLOT_INTERFACE_END
173173
174174SLOT_INTERFACE_START( nes_control_port2_devices )
trunk/src/emu/bus/nes_ctrl/ctrl.h
r243230r243231
11/**********************************************************************
22
3    Nintendo Family Computer & Entertainment System controller port
3    Nintendo Family Computer & Entertainment System controller port
44    emulation
55
66    Copyright MESS Team.
r243230r243231
3232   // construction/destruction
3333   device_nes_control_port_interface(const machine_config &mconfig, device_t &device);
3434   virtual ~device_nes_control_port_interface();
35
35   
3636   virtual UINT8 read_bit0() { return 0; };
3737   virtual UINT8 read_bit34() { return 0; };
3838   virtual UINT8 read_exp(offs_t offset) { return 0; };
3939   virtual void write(UINT8 data) { };
40
40   
4141protected:
4242   nes_control_port_device *m_port;
4343};
trunk/src/emu/bus/nes_ctrl/fckeybrd.c
r243230r243231
1818
1919static INPUT_PORTS_START( fc_keyboard )
2020   PORT_START("FCKEY.0")
21   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
22   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
21   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
22   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)         
2323   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR('[')
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']')
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Kana")
26   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RSHIFT)
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']')   
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Kana")                             
26   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RSHIFT)                     
2727   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)    PORT_CHAR('\\')
28   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_BACKSPACE)
28   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_BACKSPACE)
2929
3030   PORT_START("FCKEY.1")
31   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
31   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
3232   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')
33   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')
34   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';')
35   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('_')
36   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('/')
37   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')
33   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')   
34   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';')   
35   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('_')                             
36   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CHAR('/')                             
37   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')   
3838   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('^')
3939
4040   PORT_START("FCKEY.2")
41   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
41   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
4242   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
4343   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
4444   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
r243230r243231
4848   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
4949
5050   PORT_START("FCKEY.3")
51   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
51   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
5252   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
5353   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
5454   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
r243230r243231
5858   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
5959
6060   PORT_START("FCKEY.4")
61   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
61   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
6262   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
6363   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
6464   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
r243230r243231
6868   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
6969
7070   PORT_START("FCKEY.5")
71   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
71   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
7272   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
7373   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
7474   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
r243230r243231
7878   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')
7979
8080   PORT_START("FCKEY.6")
81   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
81   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
8282   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
8383   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
8484   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
r243230r243231
8888   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
8989
9090   PORT_START("FCKEY.7")
91   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))
92   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_MAMEKEY(ESC))
93   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
94   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2)
95   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)        PORT_CHAR(UCHAR_SHIFT_1)
96   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Grph") PORT_CODE(KEYCODE_LALT)
97   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')
98   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')
91   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))         
92   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_MAMEKEY(ESC))       
93   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')                       
94   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2) 
95   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)        PORT_CHAR(UCHAR_SHIFT_1) 
96   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Grph") PORT_CODE(KEYCODE_LALT)     
97   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')           
98   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')           
9999
100100   PORT_START("FCKEY.8")
101   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Clr")
102   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP)    PORT_CHAR(UCHAR_MAMEKEY(UP))
103   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
104   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
106   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)     PORT_CHAR(' ')
107   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Del") PORT_CODE(KEYCODE_DEL)
108   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ins") PORT_CODE(KEYCODE_INSERT)
101   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Clr")                               
102   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP)    PORT_CHAR(UCHAR_MAMEKEY(UP))     
103   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))   
104   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))     
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))     
106   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)     PORT_CHAR(' ')   
107   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Del") PORT_CODE(KEYCODE_DEL)       
108   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ins") PORT_CODE(KEYCODE_INSERT)     
109109INPUT_PORTS_END
110110
111111
r243230r243231
183183UINT8 nes_fckeybrd_device::read_exp(offs_t offset)
184184{
185185   UINT8 ret = 0;
186   if (offset == 0)    //$4016
186   if (offset == 0)   //$4016
187187   {
188188      // FC Keyboard: tape input
189189      if ((m_cassette->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)
r243230r243231
195195            ret |= 0x02;
196196      }
197197   }
198   else    //$4017
198   else   //$4017
199199   {
200200      // FC Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4
201201      if (m_fck_scan < 9)
r243230r243231
216216   // tape output (not fully tested)
217217   if ((m_cassette->get_state() & CASSETTE_MASK_UISTATE) == CASSETTE_RECORD)
218218      m_cassette->output(((data & 0x07) == 0x07) ? +1.0 : -1.0);
219
219   
220220   if (BIT(data, 2))   // keyboard active
221221   {
222222      UINT8 out = BIT(data, 1);   // scan
223
223     
224224      if (m_fck_mode && !out && ++m_fck_scan > 9)
225225         m_fck_scan = 0;
226
226     
227227      m_fck_mode = out;   // access lower or upper 4 bits
228
228     
229229      if (BIT(data, 0))   // reset
230230         m_fck_scan = 0;
231231   }
trunk/src/emu/bus/nes_ctrl/ftrainer.c
r243230r243231
119119UINT8 nes_ftrainer_device::read_exp(offs_t offset)
120120{
121121   UINT8 ret = 0;
122   if (offset == 1)    //$4017
122   if (offset == 1)   //$4017
123123   {
124124      if (!BIT(m_row_scan, 0))
125125      {
trunk/src/emu/bus/nes_ctrl/hori.c
r243230r243231
11/**********************************************************************
22
33    Nintendo Family Computer Hori Twin (and 4P?) adapters
4
5    Emulation of the 4Players adapter is quite pointless: if 2P mode
4 
5    Emulation of the 4Players adapter is quite pointless: if 2P mode
66    (default mode) it behaves like a Hori Twin adapter, in 4P mode
77    it has P1 and P2 inputs overwriting the inputs coming from the
88    main controllers (possibly creating a bit of confusion, since
r243230r243231
117117UINT8 nes_horitwin_device::read_exp(offs_t offset)
118118{
119119   UINT8 ret = 0;
120   if (offset == 0)    //$4016
120   if (offset == 0)   //$4016
121121      ret |= (m_port1->read_bit0() << 1);
122   else    //$4017
122   else   //$4017
123123      ret |= (m_port2->read_bit0() << 1);
124124   return ret;
125125}
r243230r243231
127127UINT8 nes_hori4p_device::read_exp(offs_t offset)
128128{
129129   UINT8 ret = 0;
130   if (m_cfg->read() == 0) // 2P
130   if (m_cfg->read() == 0)   // 2P
131131   {
132      if (offset == 0)    //$4016
132      if (offset == 0)   //$4016
133133         ret |= (m_port1->read_bit0() << 1);
134      else    //$4017
134      else   //$4017
135135         ret |= (m_port2->read_bit0() << 1);
136136   }
137   else    // 4P
137   else   // 4P
138138   {
139      if (offset == 0)    //$4016
139      if (offset == 0)   //$4016
140140      {
141141         ret |= (m_port1->read_bit0() << 0);
142142         ret |= (m_port3->read_bit0() << 1);
143143      }
144      else    //$4017
144      else   //$4017
145145      {
146146         ret |= (m_port2->read_bit0() << 0);
147147         ret |= (m_port4->read_bit0() << 1);
trunk/src/emu/bus/nes_ctrl/hori.h
r243230r243231
5151public:
5252   // construction/destruction
5353   nes_hori4p_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
54
54   
5555   virtual ioport_constructor device_input_ports() const;
5656   virtual machine_config_constructor device_mconfig_additions() const;
57
58protected:
57   
58protected:   
5959   // device-level overrides
6060   virtual void device_start() {}
61
61   
6262   virtual UINT8 read_exp(offs_t offset);
6363   virtual void write(UINT8 data);
64
64   
6565private:
6666   required_device<nes_control_port_device> m_port1;
6767   required_device<nes_control_port_device> m_port2;
trunk/src/emu/bus/nes_ctrl/joypad.c
r243230r243231
33    Nintendo Family Computer & Entertainment System Joypads
44
55    The original Famicom had two hardwired controller, with the second
6    controller slightly different from the first one: it featured no
6    controller slightly different from the first one: it featured no
77    Start nor Select buttons, but had a built-in microphone (with
88    very limited capabilities, since it basically only detected two
99    states: something blowing into it / nothing blowing into it) for
1010    some games to react to users "talking" into it
11
12    Crazy Climber Pads are not really a kind of separate controllers,
13    but just a couple of small sticks to be put on top of d-pads of
14    the regular controllers. Users should then control the game by
15    using both controllers, turned 90 degrees, as a couple of dual
11 
12    Crazy Climber Pads are not really a kind of separate controllers,
13    but just a couple of small sticks to be put on top of d-pads of
14    the regular controllers. Users should then control the game by
15    using both controllers, turned 90 degrees, as a couple of dual
1616    sticks like in the arcade control panel. However, we emulate them
1717    separately so to map the controls to a friendlier default.
1818
r243230r243231
2020    by Hori, but possibly licensed by Nintendo, since it use the official
2121    logo and brand) which fits into the expansion port and allows to
2222    daisy chain a second controller to the first one, to play 4players
23    game (an image of such connection is shown e.g. in Nekketsu Koukou
23    game (an image of such connection is shown e.g. in Nekketsu Koukou
2424    Dodgeball Bu manual)
25
25
2626    Copyright MESS Team.
2727    Visit http://mamedev.org for licensing and usage restrictions.
2828
r243230r243231
4545   PORT_START("JOYPAD")
4646   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
4747   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
48   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
49   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
48   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
49   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
5050   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
5151   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
5252   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
r243230r243231
5858   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
5959   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
6060   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("Microphone")
61   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
61   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
6262   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
6363   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
6464   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
r243230r243231
6969   PORT_START("JOYPAD")
7070   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
7171   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
72   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
73   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
72   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
73   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
7474   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_8WAY
7575   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_8WAY
7676   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_8WAY
r243230r243231
8181   PORT_START("JOYPAD")
8282   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
8383   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
84   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
85   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
84   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
85   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
8686   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_8WAY
8787   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_8WAY
8888   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_8WAY
r243230r243231
103103   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
104104   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
105105   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
106   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY     PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
107   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
108   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
109   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY  PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
110   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY     PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
111   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
112   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
113   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY  PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
106   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY      PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
107   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
108   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
109   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x01)
110   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY      PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
111   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
112   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
113   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY   PORT_CONDITION("CONFIG", 0x01, EQUALS, 0x00)
114114INPUT_PORTS_END
115115
116116//-------------------------------------------------
r243230r243231
245245UINT8 nes_fcpad2_device::read_exp(offs_t offset)
246246{
247247   UINT8 ret = 0;
248   if (!offset)    // microphone input
248   if (!offset)   // microphone input
249249      ret |= m_joypad->read() & 0x04;
250250
251251   return ret;
r243230r243231
260260UINT8 nes_arcstick_device::read_exp(offs_t offset)
261261{
262262   UINT8 ret = 0;
263   if (offset == 0)    //$4016
263   if (offset == 0)   //$4016
264264   {
265      if ((m_cfg->read() & 2) == 0)   // we are P1 input
265      if ((m_cfg->read() & 2) == 0)   // we are P1 input
266266      {
267267         ret |= (m_latch & 1) << 1;
268268         m_latch >>= 1;
r243230r243231
270270      else
271271         ret |= m_daisychain->read_exp(0);
272272   }
273   else    //$4017
273   else    //$4017
274274   {
275      if ((m_cfg->read() & 2) == 2)   // we are P2 input
275      if ((m_cfg->read() & 2) == 2)   // we are P2 input
276276      {
277277         ret |= (m_latch & 1) << 1;
278278         m_latch >>= 1;
r243230r243231
280280      else
281281         ret |= m_daisychain->read_exp(1);
282282   }
283
283   
284284   return ret;
285285}
286286
r243230r243231
292292{
293293   if (data & 0x01)
294294      return;
295
295   
296296   m_latch = m_joypad->read();
297297}
298298
r243230r243231
311311
312312   if (data & 0x01)
313313      return;
314
314   
315315   m_latch = m_joypad->read();
316316}
317
trunk/src/emu/bus/nes_ctrl/joypad.h
r243230r243231
5151public:
5252   // construction/destruction
5353   nes_fcpad2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
54
54   
5555   virtual ioport_constructor device_input_ports() const;
56
56   
5757protected:
5858   virtual UINT8 read_exp(offs_t offset);
5959   virtual void write(UINT8 data);
r243230r243231
6666public:
6767   // construction/destruction
6868   nes_ccpadl_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
69
69   
7070   virtual ioport_constructor device_input_ports() const;
7171};
7272
r243230r243231
7777public:
7878   // construction/destruction
7979   nes_ccpadr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
80
80   
8181   virtual ioport_constructor device_input_ports() const;
8282};
8383
r243230r243231
8888public:
8989   // construction/destruction
9090   nes_arcstick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
91
91   
9292   virtual ioport_constructor device_input_ports() const;
9393   virtual machine_config_constructor device_mconfig_additions() const;
9494
r243230r243231
9696   virtual UINT8 read_bit0() { return 0; }
9797   virtual UINT8 read_exp(offs_t offset);
9898   virtual void write(UINT8 data);
99
99   
100100   required_device<nes_control_port_device> m_daisychain;
101101   required_ioport m_cfg;
102102};
trunk/src/emu/bus/nes_ctrl/konamihs.c
r243230r243231
8181UINT8 nes_konamihs_device::read_exp(offs_t offset)
8282{
8383   UINT8 ret = 0;
84   if (offset == 1)    //$4017
84   if (offset == 1)   //$4017
8585   {
8686      ret |= m_latch_p1 << 1;
8787      ret |= m_latch_p2 << 3;
trunk/src/emu/bus/nes_ctrl/miracle.c
r243230r243231
11/**********************************************************************
22
33    Nintendo Entertainment System - Miracle Piano Keyboard
4 
5    TODO: basically everything, this is just a skeleton with no
6    real MIDI handling at the moment.
47
5    TODO: MIDI input, output is now working.
6
78    Copyright MESS Team.
89    Visit http://mamedev.org for licensing and usage restrictions.
910
1011**********************************************************************/
1112
1213#include "miracle.h"
14#include "bus/midi/midi.h"
1315
1416#define MIRACLE_MIDI_WAITING 0
15#define MIRACLE_MIDI_RECEIVE 1      // receive byte from piano
16#define MIRACLE_MIDI_SEND 2         // send byte to piano
17#define MIRACLE_MIDI_RECEIVE 1
18#define MIRACLE_MIDI_SEND 2
1719
1820//**************************************************************************
1921//  DEVICE DEFINITIONS
r243230r243231
2325
2426
2527MACHINE_CONFIG_FRAGMENT( nes_miracle )
26   MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
27   MCFG_MIDI_RX_HANDLER(WRITELINE(nes_miracle_device, rx_w))
28//   MCFG_CPU_ADD("piano_cpu", I8051, XTAL_11_0592MHz)   // xtal to be verified
2829
30   MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
2931   MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
3032MACHINE_CONFIG_END
3133
r243230r243231
4547   {
4648      m_strobe_clock++;
4749   }
48   else
49   {
50      device_serial_interface::device_timer(timer, id, param, ptr);
51   }
5250}
5351
5452//**************************************************************************
r243230r243231
6058//-------------------------------------------------
6159
6260nes_miracle_device::nes_miracle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
63               device_t(mconfig, NES_MIRACLE, "Miracle Piano Controller", tag, owner, clock, "nes_miracle", __FILE__),
64               device_serial_interface(mconfig, *this),
65               device_nes_control_port_interface(mconfig, *this),
66               m_midiin(*this, "mdin"),
67               m_midiout(*this, "mdout")
61               device_t(mconfig, NES_MIRACLE, "Miracle Piano Controller", tag, owner, clock, "nes_miracle", __FILE__)
62               , device_nes_control_port_interface(mconfig, *this)
63//               , m_cpu(*this, "piano_cpu")
6864{
6965}
7066
r243230r243231
9490   m_sent_bits = 0;
9591   m_strobe_clock = 0;
9692   m_midi_mode = MIRACLE_MIDI_WAITING;
97
98   // set standard MIDI parameters
99   set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
100   set_rcv_rate(31250);
101   set_tra_rate(31250);
102
103   m_xmit_read = m_xmit_write = 0;
104   m_recv_read = m_recv_write = 0;
105   m_read_status = m_status_bit = false;
106   m_tx_busy = false;
10793}
10894
10995
r243230r243231
11197//  read
11298//-------------------------------------------------
11399
100// TODO: here, reads from serial midi in bit0, when in MIDI_SEND mode
101
114102UINT8 nes_miracle_device::read_bit0()
115103{
116104   UINT8 ret = 0;
105   if (m_strobe_clock >= 66)
106   {
107      // more than 66 clocks since strobe on write means send mode
108      m_midi_mode = MIRACLE_MIDI_SEND;
109      strobe_timer->reset();
110      m_strobe_on = 0;
111      m_strobe_clock = 0;
112//      printf("send start\n");
113   }
117114
118   if (m_midi_mode == MIRACLE_MIDI_RECEIVE)
115   if (m_midi_mode == MIRACLE_MIDI_SEND)
119116   {
120      if (m_status_bit)
121      {
122         m_status_bit = false;
123         ret = (m_read_status) ? 1 : 0;
124      }
125      else
126      {
127         ret = (m_data_sent & 0x80) ? 0 : 1;
128         m_data_sent <<= 1;
129      }
117      //NES reads from Miracle Piano!
118      // ret |= ...
130119   }
131120
132121   return ret;
r243230r243231
136125//  write
137126//-------------------------------------------------
138127
139// c4fc = start of recv routine
140// c53a = start of send routine
128// TODO: here, writes to serial midi in bit0, when in MIDI_RECEIVE mode
141129
142130void nes_miracle_device::write(UINT8 data)
143131{
144//   printf("write: %d (%d %02x %d)\n", data & 1, m_sent_bits, m_data_sent, m_midi_mode);
145
146   if (m_midi_mode == MIRACLE_MIDI_SEND)
147   {
148      //NES writes (data & 1) to Miracle Piano!
149      // 1st write is data present flag (1=data present)
150      // next 8 writes are actual data bits (with ^1)
151      m_sent_bits++;
152      m_data_sent <<= 1;
153      m_data_sent |= (data & 1);
154      // then we go back to waiting
155      if (m_sent_bits == 8)
156      {
157//         printf("xmit MIDI byte %02x\n", m_data_sent);
158         xmit_char(m_data_sent);
159         m_midi_mode = MIRACLE_MIDI_WAITING;
160         m_sent_bits = 0;
161      }
162
163      return;
164   }
165
166132   if (data == 1 && !m_strobe_on)
167133   {
168134      strobe_timer->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(1));
169135      m_strobe_on = 1;
170136      return;
171137   }
172
138   
173139   if (m_strobe_on)
174140   {
175141      // was timer running?
176142      if (m_strobe_clock > 0)
177143      {
178//         printf("got strobe at %d clocks\n", m_strobe_clock);
179
180144         if (m_strobe_clock < 66 && data == 0)
181145         {
182            // short delay is recieve mode
146            // less than 66 clocks before new write means receive mode
183147            m_midi_mode = MIRACLE_MIDI_RECEIVE;
148//            printf("receive start\n");
184149            strobe_timer->reset();
185150            m_strobe_on = 0;
186151            m_strobe_clock = 0;
187
188            m_status_bit = true;
189            if (m_recv_read != m_recv_write)
190            {
191//               printf("Getting %02x from Miracle[%d]\n", m_recvring[m_recv_read], m_recv_read);
192               m_data_sent = m_recvring[m_recv_read++];
193               if (m_recv_read >= RECV_RING_SIZE)
194               {
195                  m_recv_read = 0;
196               }
197               m_read_status = true;
198            }
199            else
200            {
201               m_read_status = false;
202//               printf("Miracle has no data\n");
203            }
204152            return;
205153         }
206         else if (m_strobe_clock >= 66)
207         {
208            // more than 66 clocks since strobe on write means send mode
209            m_midi_mode = MIRACLE_MIDI_SEND;
210            strobe_timer->reset();
211            m_strobe_on = 0;
212            m_strobe_clock = 0;
213            m_sent_bits = 1;
214            m_data_sent <<= 1;
215            m_data_sent |= (data & 1);
216            return;
217         }
218154      }
219155
220156      if (m_midi_mode == MIRACLE_MIDI_SEND &&  data == 0)
221157      {
222158         // strobe off after the end of a byte
223159         m_midi_mode = MIRACLE_MIDI_WAITING;
160//         printf("send end\n");
224161      }
225162   }
226}
227163
228void nes_miracle_device::rcv_complete()    // Rx completed receiving byte
229{
230   receive_register_extract();
231   UINT8 rcv = get_received_char();
232
233//   printf("Got %02x -> [%d]\n", rcv, m_recv_write);
234   m_recvring[m_recv_write++] = rcv;
235   if (m_recv_write >= RECV_RING_SIZE)
164   if (m_midi_mode == MIRACLE_MIDI_RECEIVE)
236165   {
237      m_recv_write = 0;
238   }
239}
240
241void nes_miracle_device::tra_complete()    // Tx completed sending byte
242{
243   // is there more waiting to send?
244   if (m_xmit_read != m_xmit_write)
245   {
246      transmit_register_setup(m_xmitring[m_xmit_read++]);
247      if (m_xmit_read >= XMIT_RING_SIZE)
166      //NES writes (data & 1) to Miracle Piano!
167      // 1st write is data present flag (1=data present)
168      // next 8 writes are actual data bits (with ^1)
169      m_sent_bits++;
170      // then we go back to waiting
171      if (m_sent_bits == 9)
248172      {
249         m_xmit_read = 0;
173//         printf("receive end\n");
174         m_midi_mode = MIRACLE_MIDI_WAITING;
175         m_sent_bits = 0;
250176      }
251177   }
252   else
253   {
254      m_tx_busy = false;
255   }
256178}
257
258void nes_miracle_device::tra_callback()    // Tx send bit
259{
260   UINT8 bit = transmit_register_get_data_bit();
261
262   // send this to midi out
263   m_midiout->write_txd(bit);
264}
265
266void nes_miracle_device::xmit_char(UINT8 data)
267{
268   // if tx is busy it'll pick this up automatically when it completes
269   // if not, send now!
270   if (!m_tx_busy)
271   {
272      m_tx_busy = true;
273      transmit_register_setup(data);
274   }
275   else
276   {
277      // tx is busy, it'll pick this up next time
278      m_xmitring[m_xmit_write++] = data;
279      if (m_xmit_write >= XMIT_RING_SIZE)
280      {
281         m_xmit_write = 0;
282      }
283   }
284}
285
trunk/src/emu/bus/nes_ctrl/miracle.h
r243230r243231
1515
1616#include "emu.h"
1717#include "ctrl.h"
18#include "bus/midi/midi.h"
18//#include "cpu/mcs51/mcs51.h"
1919
2020//**************************************************************************
2121//  TYPE DEFINITIONS
r243230r243231
2424// ======================> nes_miracle_device
2525
2626class nes_miracle_device : public device_t,
27                     public device_serial_interface,
2827                     public device_nes_control_port_interface
2928{
3029public:
31   static const int XMIT_RING_SIZE = 64;
32   static const int RECV_RING_SIZE = 64;
33
3430   // construction/destruction
3531   nes_miracle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3632
3733   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
3834   virtual machine_config_constructor device_mconfig_additions() const;
3935
40   // serial overrides
41   virtual void rcv_complete();    // Rx completed receiving byte
42   virtual void tra_complete();    // Tx completed sending byte
43   virtual void tra_callback();    // Tx send bit
44
45   void xmit_char(UINT8 data);
46
47   required_device<midi_port_device> m_midiin, m_midiout;
48
4936protected:
5037   // device-level overrides
5138   virtual void device_start();
r243230r243231
5744   static const device_timer_id TIMER_STROBE_ON = 0;
5845   emu_timer *strobe_timer;
5946
47   //required_device<i8051_device> m_cpu;
6048   int m_strobe_on, m_midi_mode, m_sent_bits;
6149   UINT32 m_strobe_clock;
62   UINT8 m_data_sent;
63   UINT8 m_xmitring[XMIT_RING_SIZE], m_recvring[RECV_RING_SIZE];
64   int m_xmit_read, m_xmit_write;
65   int m_recv_read, m_recv_write;
66   bool m_tx_busy, m_read_status, m_status_bit;
6750};
6851
6952// device type definition
trunk/src/emu/bus/nes_ctrl/mjpanel.c
r243230r243231
1818
1919static INPUT_PORTS_START( nes_mjpanel )
2020   PORT_START("MJPANEL.0")
21   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
21   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
2222
2323   PORT_START("MJPANEL.1")
24   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
25   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_N )
26   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_M )
27   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
28   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
29   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
30   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
24   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
25   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_N )
26   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_M )
27   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
28   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
29   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
30   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
3131
3232   PORT_START("MJPANEL.2")
33   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
34   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
35   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
36   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
37   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
38   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
39   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
40   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
33   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
34   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
35   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
36   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
37   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
38   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
39   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
40   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
4141
4242   PORT_START("MJPANEL.3")
43   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
44   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_RON )
45   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH )
46   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI )
47   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_PON )
48   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN )
49   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("Mahjong Select")
50   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("Mahjong Start")
43   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
44   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_RON )
45   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH )
46   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI )
47   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_PON )
48   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN )
49   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("Mahjong Select")
50   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("Mahjong Start")
5151INPUT_PORTS_END
5252
5353
r243230r243231
124124{
125125   if (data & 0x01)
126126      return;
127
127   
128128   if (data & 0xf8)
129129      logerror("Error: Mahjong panel read with mux data %02x\n", (data & 0xfe));
130130   else
trunk/src/emu/bus/nes_ctrl/pachinko.c
r243230r243231
2020   PORT_START("JOYPAD")
2121   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("A")
2222   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("B")
23   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
23   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT )
24   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START )
2525   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
2626   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
2727   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
r243230r243231
8585{
8686   UINT8 ret = 0;
8787   // this controller behaves like a standard P3 joypad, with longer stream of inputs
88   if (offset == 0)    //$4016
88   if (offset == 0)   //$4016
8989   {
9090      ret |= (m_latch & 1) << 1;
9191      m_latch >>= 1;
r243230r243231
101101{
102102   if (data & 0x01)
103103      return;
104
104   
105105   m_latch = m_joypad->read();
106106   m_latch |= ((m_trigger->read() ^ 0xff) & 0xff) << 8;
107107   m_latch |= 0xff0000;
trunk/src/emu/bus/nes_ctrl/partytap.c
r243230r243231
8181UINT8 nes_partytap_device::read_exp(offs_t offset)
8282{
8383   UINT8 ret = 0;
84   if (offset == 1)    //$4017
84   if (offset == 1)   //$4017
8585   {
8686      ret |= m_latch & 0x1c;
8787      m_latch >>= 3;
trunk/src/emu/bus/nes_ctrl/powerpad.c
r243230r243231
130130{
131131   if (data & 0x01)
132132      return;
133
133   
134134   m_latch[0] = m_ipt1->read();
135135   m_latch[1] = m_ipt2->read() | 0xf0;
136136}
trunk/src/emu/bus/nes_ctrl/suborkey.c
r243230r243231
2222   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
2323   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
2424   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
25   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
2626   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
2727   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')
2828   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
r243230r243231
3232   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
3333   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
3434   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END))
35   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))
35   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))     
3636   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
3737   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
3838   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
3939
4040   PORT_START("SUBOR.2")
41   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
42   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
43   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NEXT")
41   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
42   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)             
43   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NEXT")                                         
4444   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
45   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
46   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PRIOR")
45   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))     
46   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PRIOR")                                     
4747   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
48   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME))
48   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME))
4949
5050   PORT_START("SUBOR.3")
5151   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')
5252   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
5353   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
54   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')
55   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
54   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')       
55   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
5656   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
5757   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
5858   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)  PORT_CHAR('.')
5959
6060   PORT_START("SUBOR.4")
61   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR(']')
62   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
63   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
64   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
65   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
66   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')
67   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')
68   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
61   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR(']')       
62   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)             
63   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))     
64   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
65   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))     
66   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')       
67   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')       
68   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
6969
7070   PORT_START("SUBOR.5")
7171   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
72   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
72   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
7373   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
7474   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB)   PORT_CHAR('\t')
75   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
75   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))       
7676   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
7777   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')
78   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2)
78   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL)      PORT_CHAR(UCHAR_SHIFT_2)     
7979
8080   PORT_START("SUBOR.6")
8181   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')
8282   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
8383   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
8484   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
85   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
85   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
8686   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
8787   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
8888   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
r243230r243231
9292   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':')
9393   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'')
9494   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/')
95   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
95   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
9696   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P)     PORT_CHAR('P')
9797   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('=')
98   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)    PORT_CHAR(UCHAR_SHIFT_1)
98   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT)    PORT_CHAR(UCHAR_SHIFT_1) 
9999
100100   PORT_START("SUBOR.8")
101101   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
102102   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
103103   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
104104   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
105   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
106106   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
107107   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
108108   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
r243230r243231
111111   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
112112
113113   PORT_START("SUBOR.10")
114   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LMENU")
114   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LMENU")
115115   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
116116   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
117   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F11)       PORT_CHAR(UCHAR_MAMEKEY(F11))
118   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F12)       PORT_CHAR(UCHAR_MAMEKEY(F12))
117   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F11)       PORT_CHAR(UCHAR_MAMEKEY(F11))
118   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F12)       PORT_CHAR(UCHAR_MAMEKEY(F12))
119119   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
120120   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
121121   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
r243230r243231
124124   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS_PAD)PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
125125   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD)  PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))
126126   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK)  PORT_CHAR(UCHAR_MAMEKEY(ASTERISK))
127   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
128   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))
129   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
127   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))   
128   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))       
129   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))   
130130   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH_PAD)PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD))
131   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK)   PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK))
131   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK)   PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK))
132132
133133   PORT_START("SUBOR.12")
134   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`')
134   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`')               
135135   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
136   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PAUSE")
137   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE2")
138   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))
136   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("PAUSE")                                         
137   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE2")                                       
138   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))         
139139   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
140   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD)
140   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD)       
141141   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
142142INPUT_PORTS_END
143143
r243230r243231
198198UINT8 nes_suborkey_device::read_exp(offs_t offset)
199199{
200200   UINT8 ret = 0;
201   if (offset == 1)    //$4017
201   if (offset == 1)   //$4017
202202   {
203203      // Subor Keyboard: rows of the keyboard matrix are read 4-bits at time and returned as bit1->bit4
204204      if (m_fck_scan < 13)
r243230r243231
206206      else
207207         ret |= 0x1e;
208208   }
209
209   
210210   return ret;
211211}
212212
r243230r243231
218218{
219219   if (BIT(data, 2))   // keyboard active
220220   {
221      UINT8 out = BIT(data, 1);   // scan
221      UINT8 out = BIT(data, 1);   // scan     
222222      if (m_fck_mode && !out && ++m_fck_scan > 12)
223223         m_fck_scan = 0;
224
224     
225225      m_fck_mode = out;   // access lower or upper 4 bits
226
226     
227227      if (BIT(data, 0))   // reset
228228         m_fck_scan = 0;
229229   }
trunk/src/emu/bus/nes_ctrl/zapper.c
r243230r243231
8080UINT8 nes_zapper_device::read_bit34()
8181{
8282   UINT8 ret = m_trigger->read();
83   if (!m_port->m_brightpixel_cb.isnull() &&
83   if (!m_port->m_brightpixel_cb.isnull() &&
8484      m_port->m_brightpixel_cb(m_lightx->read(), m_lighty->read()))
8585      ret &= ~0x08; // sprite hit
8686   else
r243230r243231
9191UINT8 nes_zapper_device::read_exp(offs_t offset)
9292{
9393   UINT8 ret = 0;
94   if (offset == 1)    // $4017
94   if (offset == 1)   // $4017
9595      ret |= nes_zapper_device::read_bit34();
9696   return ret;
9797}
trunk/src/emu/bus/sms_ctrl/joypad.c
r243230r243231
2020
2121static INPUT_PORTS_START( sms_joypad )
2222   PORT_START("JOYPAD")
23   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
24   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
25   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
26   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
23   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
24   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
25   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
26   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
2727   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )   // Vcc
2828   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )  // TL
2929   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )   // TH
trunk/src/emu/bus/vcs/dpc.c
r243230r243231
3737      save_item(NAME(m_df[i].music_mode), i);
3838      save_item(NAME(m_df[i].osc_clk), i);
3939   }
40
40   
4141   save_item(NAME(m_movamt));
4242   save_item(NAME(m_latch_62));
4343   save_item(NAME(m_latch_64));
trunk/src/emu/clifront.c
r243230r243231
3636class media_identifier
3737{
3838public:
39   // construction/destruction
40   media_identifier(cli_options &options);
39    // construction/destruction
40    media_identifier(cli_options &options);
4141
42   // getters
43   int total() const { return m_total; }
44   int matches() const { return m_matches; }
45   int nonroms() const { return m_nonroms; }
42    // getters
43    int total() const { return m_total; }
44    int matches() const { return m_matches; }
45    int nonroms() const { return m_nonroms; }
4646
47   // operations
48   void reset() { m_total = m_matches = m_nonroms = 0; }
49   void identify(const char *name);
50   void identify_file(const char *name);
51   void identify_data(const char *name, const UINT8 *data, int length);
52   int find_by_hash(const hash_collection &hashes, int length);
47    // operations
48    void reset() { m_total = m_matches = m_nonroms = 0; }
49    void identify(const char *name);
50    void identify_file(const char *name);
51    void identify_data(const char *name, const UINT8 *data, int length);
52    int find_by_hash(const hash_collection &hashes, int length);
5353
5454private:
55   // internal state
56   driver_enumerator   m_drivlist;
57   int                 m_total;
58   int                 m_matches;
59   int                 m_nonroms;
55    // internal state
56    driver_enumerator   m_drivlist;
57    int                 m_total;
58    int                 m_matches;
59    int                 m_nonroms;
6060};
6161
6262
r243230r243231
16191619      }
16201620
16211621   if (!m_osd.execute_command(m_options.command()))
1622      // if we get here, we don't know what has been requested
1623      throw emu_fatalerror(MAMERR_INVALID_CONFIG, "Unknown command '%s' specified", m_options.command());
1622        // if we get here, we don't know what has been requested
1623        throw emu_fatalerror(MAMERR_INVALID_CONFIG, "Unknown command '%s' specified", m_options.command());
16241624}
16251625
16261626
trunk/src/emu/cliopts.c
r243230r243231
6060cli_options::cli_options()
6161: emu_options()
6262{
63   add_entries(cli_options::s_option_entries);
63    add_entries(cli_options::s_option_entries);
6464}
65
trunk/src/emu/cpu/arcompact/arcompact.c
r243230r243231
5151arcompact_device::arcompact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
5252   : cpu_device(mconfig, ARCA5, "ARCtangent-A5", tag, owner, clock, "arca5", __FILE__)
5353   , m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0) // some docs describe these as 'middle endian'?!
54   , m_io_config( "io", ENDIANNESS_LITTLE, 32, AUX_SPACE_ADDRESS_WIDTH, 0, ADDRESS_MAP_NAME( arcompact_auxreg_map ) )
54   , m_io_config( "io", ENDIANNESS_LITTLE, 32, AUX_SPACE_ADDRESS_WIDTH, 0, ADDRESS_MAP_NAME( arcompact_auxreg_map ) )
5555{
5656}
5757
trunk/src/emu/cpu/arcompact/arcompact.h
r243230r243231
6060public:
6161   // construction/destruction
6262   arcompact_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
63
63   
6464   DECLARE_READ32_MEMBER( arcompact_auxreg002_LPSTART_r);
6565   DECLARE_WRITE32_MEMBER(arcompact_auxreg002_LPSTART_w);
6666   DECLARE_READ32_MEMBER( arcompact_auxreg003_LPEND_r);
6767   DECLARE_WRITE32_MEMBER(arcompact_auxreg003_LPEND_w);
68
68   
6969   DECLARE_READ32_MEMBER( arcompact_auxreg00a_STATUS32_r);
7070   DECLARE_READ32_MEMBER( arcompact_auxreg025_INTVECTORBASE_r);
7171   DECLARE_WRITE32_MEMBER( arcompact_auxreg025_INTVECTORBASE_w);
7272
73
73   
7474protected:
7575   // device-level overrides
7676   virtual void device_start();
r243230r243231
184184   ARCOMPACT_RETTYPE arcompact_handle04_1c(OPS_32);
185185   ARCOMPACT_RETTYPE arcompact_handle04_1d(OPS_32);
186186//  ARCOMPACT_RETTYPE arcompact_handle04_20(OPS_32);
187//  ARCOMPACT_RETTYPE arcompact_handle04_21(OPS_32);
187//   ARCOMPACT_RETTYPE arcompact_handle04_21(OPS_32);
188188   ARCOMPACT_RETTYPE arcompact_handle04_22(OPS_32);
189189   ARCOMPACT_RETTYPE arcompact_handle04_23(OPS_32);
190190   ARCOMPACT_RETTYPE arcompact_handle04_28(OPS_32);
191191   ARCOMPACT_RETTYPE arcompact_handle04_29(OPS_32);
192//  ARCOMPACT_RETTYPE arcompact_handle04_2a(OPS_32);
192//   ARCOMPACT_RETTYPE arcompact_handle04_2a(OPS_32);
193193//  ARCOMPACT_RETTYPE arcompact_handle04_2b(OPS_32);
194194   ARCOMPACT_RETTYPE arcompact_handle04_2f_00(OPS_32);
195195   ARCOMPACT_RETTYPE arcompact_handle04_2f_01(OPS_32);
196196//  ARCOMPACT_RETTYPE arcompact_handle04_2f_02(OPS_32);
197//  ARCOMPACT_RETTYPE arcompact_handle04_2f_03(OPS_32);
197//   ARCOMPACT_RETTYPE arcompact_handle04_2f_03(OPS_32);
198198   ARCOMPACT_RETTYPE arcompact_handle04_2f_04(OPS_32);
199199   ARCOMPACT_RETTYPE arcompact_handle04_2f_05(OPS_32);
200200   ARCOMPACT_RETTYPE arcompact_handle04_2f_06(OPS_32);
r243230r243231
770770   ARCOMPACT_RETTYPE arcompact_handle19_0x_helper(OPS_16, const char* optext, int shift, int format);
771771   ARCOMPACT_RETTYPE arcompact_handle1e_0x_helper(OPS_16, const char* optext);
772772   ARCOMPACT_RETTYPE arcompact_handle1e_03_0x_helper(OPS_16, const char* optext);
773   
773774
774
775775   UINT32 handle_jump_to_addr(int delay, int link, UINT32 address, UINT32 next_addr);
776776   UINT32 handle_jump_to_register(int delay, int link, UINT32 reg, UINT32 next_addr, int flag);
777777
trunk/src/emu/cpu/arcompact/arcompact_execute.c
r243230r243231
21422142         size = 8;
21432143      }
21442144
2145   //  c = limm;
2145   //   c = limm;
21462146
21472147   }
21482148   else
r243230r243231
21512151      // Jcc [c]         0010 0RRR 1110 0000 0RRR CCCC CC0Q QQQQ
21522152      // no conditional links to ILINK1, ILINK2?
21532153
2154   //  c = m_regs[creg];
2154   //   c = m_regs[creg];
21552155   }
21562156
21572157   if (!check_condition(condition))
trunk/src/emu/cpu/h8/h8.c
r243230r243231
114114   save_item(NAME(EXR));
115115   save_item(NAME(CCR));
116116   save_item(NAME(TMP1));
117   save_item(NAME(TMP2));
118117   save_item(NAME(inst_state));
119118   save_item(NAME(inst_substate));
120   save_item(NAME(irq_vector));
121   save_item(NAME(taken_irq_vector));
122   save_item(NAME(irq_level));
123   save_item(NAME(taken_irq_level));
124   save_item(NAME(irq_nmi));
125119
126120   m_icountptr = &icount;
127121
trunk/src/emu/cpu/i386/i386dasm.c
r243230r243231
9898#define ALWAYS64            0x400
9999#define SPECIAL64           0x800
100100#define SPECIAL64_ENT(x)    (SPECIAL64 | ((x) << 24))
101#define GROUP_MOD           0x1000
101#define GROUP_MOD         0x1000
102102
103103struct I386_OPCODE {
104104   const char *mnemonic;
r243230r243231
19531953   { "group0F0D",          group0F0D_table         },
19541954   { "group0F12",          group0F12_table         },
19551955   { "group0F16",          group0F16_table         },
1956   { "group0F18",          group0F18_table         },
1956   { "group0F18",           group0F18_table         },
19571957   { "group0F71",          group0F71_table         },
19581958   { "group0F72",          group0F72_table         },
19591959   { "group0F73",          group0F73_table         },
trunk/src/emu/cpu/m6502/m4510.c
r243230r243231
7575   nomap = true;
7676
7777   // Wild guess, this setting makes the cpu start executing some code in the c65 driver
78   //map_offset[1] = 0x2e000;
79   //map_enable = 0x80;
78   map_offset[1] = 0x30000;
79   map_enable = 0x80;
8080   m65ce02_device::device_reset();
8181}
8282
r243230r243231
8686   {
8787      address = map(address);
8888   }
89   
89
9090   return true;
9191}
9292
trunk/src/emu/cpu/m6502/m6502.c
r243230r243231
579579      break;
580580
581581   case DASM_rw2:
582      sprintf(buffer, " $%04x", (pc & 0xf0000) | UINT16(pc + 2 + INT16((opram[2] << 8) | opram[1])));
582      sprintf(buffer, " $%04x", (pc & 0xf0000) | UINT16(pc + 3 + INT16((opram[2] << 8) | opram[1])));
583583      flags |= 3;
584584      break;
585585
trunk/src/emu/cpu/m6502/m6502.h
r243230r243231
220220
221221   // inline helpers
222222   static inline bool page_changing(UINT16 base, int delta) { return ((base + delta) ^ base) & 0xff00; }
223   static inline UINT16 set_l(UINT16 base, UINT16 val) { return (base & 0xff00) | val; }
224   static inline UINT16 set_h(UINT16 base, UINT16 val) { return (base & 0x00ff) | (val << 8); }
223   static inline UINT16 set_l(UINT16 base, UINT8 val) { return (base & 0xff00) | val; }
224   static inline UINT16 set_h(UINT16 base, UINT8 val) { return (base & 0x00ff) | (val << 8); }
225225
226226   inline void dec_SP() { SP = set_l(SP, SP-1); }
227227   inline void inc_SP() { SP = set_l(SP, SP+1); }
trunk/src/emu/cpu/m6502/om4510.lst
r243230r243231
99   map_offset[0] = (A<<8) | ((X & 0xf) << 16);
1010   map_offset[1] = (Y<<8) | ((Z & 0xf) << 16);
1111   map_enable = ((X & 0xf0) >> 4) | (Z & 0xf0);
12   logerror("MAP execute\n");
13   logerror("0x0000 - 0x1fff = %08x\n",map_enable & 1 ? map_offset[0]+0x0000 : 0x0000);
14   logerror("0x2000 - 0x3fff = %08x\n",map_enable & 2 ? map_offset[0]+0x2000 : 0x2000);
15   logerror("0x4000 - 0x5fff = %08x\n",map_enable & 4 ? map_offset[0]+0x4000 : 0x4000);
16   logerror("0x6000 - 0x7fff = %08x\n",map_enable & 8 ? map_offset[0]+0x6000 : 0x6000);
17   logerror("0x8000 - 0x9fff = %08x\n",map_enable & 16 ? map_offset[1]+0x8000 : 0x8000);
18   logerror("0xa000 - 0xbfff = %08x\n",map_enable & 32 ? map_offset[1]+0xa000 : 0xa000);
19   logerror("0xc000 - 0xdfff = %08x\n",map_enable & 64 ? map_offset[1]+0xc000 : 0xc000);
20   logerror("0xe000 - 0xffff = %08x\n",map_enable & 128 ? map_offset[1]+0xe000 : 0xe000);
2112   prefetch();
trunk/src/emu/cpu/m6502/om65ce02.lst
r243230r243231
245245   TMP = read_pc();
246246   TMP = set_h(TMP, read_pc());
247247   if(!(P & F_C))
248      PC += TMP-1;
248      PC += TMP;
249249   prefetch();
250250
251251bcs_ce_rel
r243230r243231
258258   TMP = read_pc();
259259   TMP = set_h(TMP, read_pc());
260260   if(P & F_C)
261      PC += TMP-1;
261      PC += TMP;
262262   prefetch();
263263
264264beq_ce_rel
r243230r243231
271271   TMP = read_pc();
272272   TMP = set_h(TMP, read_pc());
273273   if(P & F_Z)
274      PC += TMP-1;
274      PC += TMP;
275275   prefetch();
276276
277277bit_ce_abx
r243230r243231
307307   TMP = read_pc();
308308   TMP = set_h(TMP, read_pc());
309309   if(P & F_N)
310      PC += TMP-1;
310      PC += TMP;
311311   prefetch();
312312
313313bne_ce_rel
r243230r243231
320320   TMP = read_pc();
321321   TMP = set_h(TMP, read_pc());
322322   if(!(P & F_Z))
323      PC += TMP-1;
323      PC += TMP;
324324   prefetch();
325325
326326bpl_ce_rel
r243230r243231
333333   TMP = read_pc();
334334   TMP = set_h(TMP, read_pc());
335335   if(!(P & F_N))
336      PC += TMP-1;
336      PC += TMP;
337337   prefetch();
338338
339339bra_ce_rel
r243230r243231
344344bra_rw2
345345   TMP = read_pc();
346346   TMP = set_h(TMP, read_pc());
347   PC += TMP - 1;
347   PC += TMP;
348348   prefetch();
349349
350350brk_ce_imp
r243230r243231
379379   write(SP, PC);
380380   dec_SP_ce();
381381   TMP = set_h(TMP, read_pc());
382   PC += TMP-1;
382   PC += TMP;
383383   prefetch();
384384
385385bvc_ce_rel
r243230r243231
392392   TMP = read_pc();
393393   TMP = set_h(TMP, read_pc());
394394   if(!(P & F_V))
395      PC += TMP-1;
395      PC += TMP;
396396   prefetch();
397397
398398bvs_ce_rel
r243230r243231
405405   TMP = read_pc();
406406   TMP = set_h(TMP, read_pc());
407407   if(P & F_V)
408      PC += TMP-1;
408      PC += TMP;
409409   prefetch();
410410
411411clc_ce_imp
r243230r243231
419419cle_imp
420420   read_pc_noinc();
421421   P &= ~F_E;
422   logerror("CLE\n");
423422   prefetch();
424423
425424cli_ce_imp
trunk/src/emu/cpu/m68000/m68k_in.c
r243230r243231
272272extern void m68040_fpu_op0(m68000_base_device *m68k);
273273extern void m68040_fpu_op1(m68000_base_device *m68k);
274274extern void m68881_mmu_ops(m68000_base_device *m68k);
275extern void m68881_ftrap(m68000_base_device *m68k);
275extern void m68881_ftrap(m68000_base_device *m68k);
276276
277277/* ======================================================================== */
278278/* ========================= INSTRUCTION HANDLERS ========================= */
trunk/src/emu/cpu/m68000/m68kcpu.c
r243230r243231
699699   {
700700      /* only the 68010 throws this unique type-1000 frame */
701701      m68ki_stack_frame_1000(m68k, REG_PPC(m68k), sr, EXCEPTION_BUS_ERROR);
702   }
702   }
703703   else if (m68k->mmu_tmp_buserror_address == REG_PPC(m68k))
704704   {
705705      m68ki_stack_frame_1010(m68k, sr, EXCEPTION_BUS_ERROR, REG_PPC(m68k), m68k->mmu_tmp_buserror_address);
trunk/src/emu/cpu/m68000/m68kfpu.inc
r243230r243231
21772177      // trap here
21782178      m68ki_exception_trap(m68k, EXCEPTION_TRAPV);
21792179   }
2180   else    // fall through, requires eating the operand
2180   else   // fall through, requires eating the operand
21812181   {
21822182      switch (m68k->ir & 0x7)
21832183      {
2184         case 2: // word operand
2184         case 2:   // word operand
21852185            OPER_I_16(m68k);
21862186            break;
21872187
r243230r243231
21892189            OPER_I_32(m68k);
21902190            break;
21912191
2192         case 4: // no operand
2192         case 4:   // no operand
21932193            break;
21942194      }
21952195   }
21962196}
2197
trunk/src/emu/cpu/tms0980/tms0980.c
r243230r243231
10371037
10381038      m_ps = m_ps << 4 | m_pa;
10391039      m_pa = m_pb;
1040
1040     
10411041      m_cs = m_cs << 2 | m_ca;
10421042      m_ca = m_cb;
10431043   }
r243230r243231
10571057
10581058      m_pc = m_sr & m_pc_mask;
10591059      m_sr >>= m_pc_bits;
1060
1060     
10611061      m_pa = m_pb = m_ps & 0xf;
10621062      m_ps >>= 4;
1063
1063     
10641064      m_ca = m_cb = m_cs & 3;
10651065      m_cs >>= 2;
10661066   }
trunk/src/emu/cpu/tms0980/tms0980d.c
r243230r243231
1// license:BSD-3-Clause
2// copyright-holders:Wilbert Pol, hap
3/*
1/*******************************************************************
42
5  TMS0980/TMS1000-family disassembler
3  TMS0980 disassembly
64
7*/
5*******************************************************************/
86
97#include "emu.h"
108#include "debugger.h"
119#include "tms0980.h"
1210
1311
12#define _OVER DASMFLAG_STEP_OVER
13#define _OUT  DASMFLAG_STEP_OUT
14
15
1416enum e_mnemonics {
1517   zA10AAC=0, zA6AAC, zA8AAC, zAC1AC, zACACC, zACNAA, zALEC, zALEM, zAMAAC, zBRANCH, zCALL, zCCLA,
1618   zCLA, zCLO, zCOMC, zCOMX, zCOMX8, zCPAIZ, zCTMDYN, zDAN, zDMAN, zDMEA, zDNAA,
r243230r243231
2224   zILL
2325};
2426
27
28enum e_addressing {
29   zB0=0, zI2, zI3, zI4, zB7
30};
31
32
2533static const char *const s_mnemonic[] = {
26   "A10AAC", "A6AAC", "A8AAC", "AC1AC", "ACACC", "ACNAA", "ALEC", "ALEM", "AMAAC", "BRANCH", "CALL", "CCLA",
27   "CLA", "CLO", "COMC", "COMX", "COMX8", "CPAIZ", "CTMDYN", "DAN", "DMAN", "DMEA", "DNAA",
28   "DYN", "IA", "IMAC", "IYC", "KNEZ", "LDP", "LDX", "LDX", "LDX", "MNEA", "MNEZ",
29   "NDMEA", "OFF", "RBIT", "REAC", "RETN", "RSTR", "SAL", "SAMAN", "SBIT",
30   "SBL", "SEAC", "SETR", "TAM", "TAMACS", "TAMDYN", "TAMIY", "TAMIYC", "TAMZA",
31   "TAY", "TBIT", "TCMIY", "TCY", "TDO", "TKA", "TKM", "TMA",
32   "TMY", "TYA", "XDA", "XMA", "YMCY", "YNEA", "YNEC",
33   "?"
34   "a10aac", "a6aac", "a8aac", "ac1ac", "acacc", "acnaa", "alec", "alem", "amaac", "branch", "call", "ccla",
35   "cla", "clo", "comc", "comx", "comx8", "cpaiz", "ctmdyn", "dan", "dman", "dmea", "dnaa",
36   "dyn", "ia", "imac", "iyc", "knez", "ldp", "ldx", "ldx", "ldx", "mnea", "mnez",
37   "ndmea", "off", "rbit", "reac", "retn", "rstr", "sal", "saman", "sbit",
38   "sbl", "seac", "setr", "tam", "tamacs", "tamdyn", "tamiy", "tamiyc", "tamza",
39   "tay", "tbit", "tcmiy", "tcy", "tdo", "tka", "tkm", "tma",
40   "tmy", "tya", "xda", "xma", "ymcy", "ynea", "ynec",
41   "illegal"
3442};
3543
3644
37#define _OVER DASMFLAG_STEP_OVER
38#define _OUT  DASMFLAG_STEP_OUT
39
4045static const UINT32 s_flags[] = {
4146   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _OVER, 0,
4247   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
r243230r243231
4954};
5055
5156
52enum e_addressing {
53   zB0=0, zI2, zI3, zI4, zB7
54};
55
5657static const UINT8 s_addressing[] = {
5758   zB0, zB0, zB0, zI4, zI4, zI4, zI4, zB0, zB0, zB7, zB7, zB0,
5859   zB0, zB0, zB0, zB0, zB0, zB0, zB0, zB0, zB0, zB0, zB0,
trunk/src/emu/devfind.c
r243230r243231
114114
115115void finder_base::printf_warning(const char *format, ...)
116116{
117   va_list argptr;
118   char buffer[1024];
117    va_list argptr;
118    char buffer[1024];
119119
120   /* do the output */
121   va_start(argptr, format);
122   vsnprintf(buffer, 1024, format, argptr);
123   osd_printf_warning("%s", buffer);
124   va_end(argptr);
120    /* do the output */
121    va_start(argptr, format);
122    vsnprintf(buffer, 1024, format, argptr);
123    osd_printf_warning("%s", buffer);
124    va_end(argptr);
125125}
trunk/src/emu/devfind.h
r243230r243231
5757   void *find_memshare(UINT8 width, size_t &bytes, bool required);
5858   bool report_missing(bool found, const char *objname, bool required);
5959
60   void printf_warning(const char *format, ...) ATTR_PRINTF(2,3);
60    void printf_warning(const char *format, ...) ATTR_PRINTF(2,3);
6161
6262   // internal state
6363   finder_base *m_next;
trunk/src/emu/distate.c
r243230r243231
8989
9090device_state_entry::device_state_entry(int index, device_state_interface *dev)
9191   : m_device_state(dev),
92      m_next(NULL),
92       m_next(NULL),
9393      m_index(index),
9494      m_dataptr(NULL),
9595      m_datamask(0),
trunk/src/emu/drivers/xtal.h
r243230r243231
5757   XTAL_2_5MHz         = 2500000,      /* Janken Man units */
5858   XTAL_3MHz           = 3000000,      /* Probably only used to drive 68705 or similar MCUs on 80's Taito PCBs */
5959   XTAL_3_12MHz        = 3120000,      /* SP0250 clock on Gottlieb games */
60   XTAL_3_5MHz         = 3500000,      /* Reported by Commodore 65 document, true xtal unchecked on PCB */
6160   XTAL_3_52128MHz     = 3521280,      /* RCA COSMAC VIP */
6261   XTAL_3_579545MHz    = 3579545,      /* NTSC color subcarrier, extremely common, used on 100's of PCBs (Keytronic custom part #48-300-010 is equivalent) */
6362   XTAL_3_6864MHz      = 3686400,      /* CPS3 */
trunk/src/emu/emucore.c
r243230r243231
1717emu_fatalerror::emu_fatalerror(const char *format, ...)
1818: code(0)
1919{
20   if (format == NULL)
21   {
22      text[0] = '\0';
23   }
24   else
25   {
26      va_list ap;
27      va_start(ap, format);
28      vsprintf(text, format, ap);
29      va_end(ap);
30   }
31   osd_break_into_debugger(text);
20    if (format == NULL)
21    {
22        text[0] = '\0';
23    }
24    else
25    {
26        va_list ap;
27        va_start(ap, format);
28        vsprintf(text, format, ap);
29        va_end(ap);
30    }
31    osd_break_into_debugger(text);
3232}
3333
3434emu_fatalerror::emu_fatalerror(const char *format, va_list ap)
3535: code(0)
3636{
37   if (format == NULL)
38   {
39      text[0] = '\0';
40   }
41   else
42   {
43      vsprintf(text, format, ap);
44   }
45   osd_break_into_debugger(text);
37    if (format == NULL)
38    {
39        text[0] = '\0';
40    }
41    else
42    {
43        vsprintf(text, format, ap);
44    }
45    osd_break_into_debugger(text);
4646}
4747
4848emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, ...)
4949: code(_exitcode)
5050{
51   if (format == NULL)
52   {
53      text[0] = '\0';
54   }
55   else
56   {
57      va_list ap;
58      va_start(ap, format);
59      vsprintf(text, format, ap);
60      va_end(ap);
61   }
51    if (format == NULL)
52    {
53        text[0] = '\0';
54    }
55    else
56    {
57        va_list ap;
58        va_start(ap, format);
59        vsprintf(text, format, ap);
60        va_end(ap);
61    }
6262}
6363
6464emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, va_list ap)
6565: code(_exitcode)
6666{
67   if (format == NULL)
68   {
69      text[0] = '\0';
70   }
71   else
72   {
73      vsprintf(text, format, ap);
74   }
67    if (format == NULL)
68    {
69        text[0] = '\0';
70    }
71    else
72    {
73        vsprintf(text, format, ap);
74    }
7575}
7676
7777
r243230r243231
8989
9090void fatalerror(const char *format, ...)
9191{
92   va_list ap;
93   va_start(ap, format);
94   emu_fatalerror error(format, ap);
95   va_end(ap);
96   throw error;
92    va_list ap;
93    va_start(ap, format);
94    emu_fatalerror error(format, ap);
95    va_end(ap);
96    throw error;
9797}
9898
9999void fatalerror_exitcode(running_machine &machine, int exitcode, const char *format, ...)
100100{
101   va_list ap;
102   va_start(ap, format);
103   emu_fatalerror error(exitcode, format, ap);
104   va_end(ap);
105   throw error;
101    va_list ap;
102    va_start(ap, format);
103    emu_fatalerror error(exitcode, format, ap);
104    va_end(ap);
105    throw error;
106106}
trunk/src/emu/emuopts.c
r243230r243231
150150
151151   // debugging options
152152   { NULL,                                              NULL,        OPTION_HEADER,     "CORE DEBUGGING OPTIONS" },
153   { OPTION_VERBOSE ";v",                               "0",         OPTION_BOOLEAN,    "display additional diagnostic information" },
154   { OPTION_LOG,                                        "0",         OPTION_BOOLEAN,    "generate an error.log file" },
155   { OPTION_OSLOG,                                      "0",         OPTION_BOOLEAN,    "output error.log data to the system debugger" },
156   { OPTION_DEBUG ";d",                                 "0",         OPTION_BOOLEAN,    "enable/disable debugger" },
153    { OPTION_VERBOSE ";v",                               "0",         OPTION_BOOLEAN,    "display additional diagnostic information" },
154    { OPTION_LOG,                                        "0",         OPTION_BOOLEAN,    "generate an error.log file" },
155    { OPTION_OSLOG,                                      "0",         OPTION_BOOLEAN,    "output error.log data to the system debugger" },
156    { OPTION_DEBUG ";d",                                 "0",         OPTION_BOOLEAN,    "enable/disable debugger" },
157157   { OPTION_UPDATEINPAUSE,                              "0",         OPTION_BOOLEAN,    "keep calling video updates while in pause" },
158158   { OPTION_DEBUGSCRIPT,                                NULL,        OPTION_STRING,     "script for debugger" },
159159
trunk/src/emu/emuopts.h
r243230r243231
318318   bool joystick_contradictory() const { return bool_value(OPTION_JOYSTICK_CONTRADICTORY); }
319319   int coin_impulse() const { return int_value(OPTION_COIN_IMPULSE); }
320320
321   // core debugging options
322   bool log() const { return bool_value(OPTION_LOG); }
323   bool debug() const { return bool_value(OPTION_DEBUG); }
324   bool verbose() const { return bool_value(OPTION_VERBOSE); }
325   bool oslog() const { return bool_value(OPTION_OSLOG); }
321    // core debugging options
322    bool log() const { return bool_value(OPTION_LOG); }
323    bool debug() const { return bool_value(OPTION_DEBUG); }
324    bool verbose() const { return bool_value(OPTION_VERBOSE); }
325    bool oslog() const { return bool_value(OPTION_OSLOG); }
326326   const char *debug_script() const { return value(OPTION_DEBUGSCRIPT); }
327327   bool update_in_pause() const { return bool_value(OPTION_UPDATEINPAUSE); }
328328
trunk/src/emu/luaengine.c
r243230r243231
714714   render_container &rc = sc->container();
715715   ui_manager &ui = sc->machine().ui();
716716   ui.draw_text_full(&rc, msg, x, y , (1.0f - x),
717                  JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR,
718                  UI_TEXT_BG_COLOR, NULL, NULL);
717                  JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR,
718                  UI_TEXT_BG_COLOR, NULL, NULL);
719719
720720   return 0;
721721}
trunk/src/emu/machine.c
r243230r243231
108108
109109osd_interface &running_machine::osd() const
110110{
111   return m_manager.osd();
111    return m_manager.osd();
112112}
113113
114114//-------------------------------------------------
r243230r243231
142142      m_save(*this),
143143      m_memory(*this),
144144      m_ioport(*this),
145      m_parameters(*this),
145      m_parameters(*this),
146146      m_scheduler(*this)
147147{
148148   memset(&m_base_time, 0, sizeof(m_base_time));
trunk/src/emu/machine/intelfsh.c
r243230r243231
253253      m_size = 0x400000;
254254      m_maker_id = MFG_INTEL;
255255      m_device_id = 0x14;
256//      m_sector_is_4k = true; 128kb?
256//      m_sector_is_4k = true; 128kb?
257257      map = ADDRESS_MAP_NAME( memory_map16_32Mb );
258258      break;
259259   case FLASH_SST_39VF020:
trunk/src/emu/machine/jvshost.c
r243230r243231
4848   // - have the message length without the two header bytes but with the checksum byte in the second byte
4949   // - have at least one command byte
5050   if(send_size < 3 || send_buffer[0] == 0x00 || send_buffer[1] != send_size-1) {
51                logerror("JVS checksum error\n");
52                // "This message is crap" doesn't exist so call it checksum error
53                recv_buffer[0] = 0x00;
54                recv_buffer[1] = 0x02;
55                recv_buffer[2] = 0x03;
56                recv_size = 3;
57        } else {
51      logerror("JVS checksum error\n");
52   } /*
53      Naomi suchie3 have bad working controls with this
54   
55      // "This message is crap" doesn't exist so call it checksum error
56      recv_buffer[0] = 0x00;
57      recv_buffer[1] = 0x02;
58      recv_buffer[2] = 0x03;
59      recv_size = 3;
60
61   } else */ {
5862      if(first_device) {
5963         first_device->message(send_buffer[0], send_buffer+2, send_size-2, recv_buffer+2, recv_size);
6064         recv_is_encoded = false;
r243230r243231
116120   if(!size)
117121      return;
118122   UINT32 add = 1;
119   UINT8 sum = 0;
120123   for(UINT32 i=0; i<size; i++)
121      sum += buffer[i];
122   buffer[size++] = sum;
123   for(UINT32 i=0; i<size; i++)
124124      if(buffer[i] == 0xd0 || buffer[i] == 0xe0)
125125         add++;
126   UINT32 nsize = size+add;
126127   for(UINT32 i=size; i; i--) {
127128      UINT8 t = buffer[i-1];
128129      if(t == 0xd0 || t == 0xe0) {
r243230r243231
133134         buffer[i+add-1] = t;
134135   }
135136   buffer[0] = 0xe0;
136   size += add;
137   UINT8 sum = 0;
138   for(UINT32 i=1; i<nsize; i++)
139      sum += buffer[i];
140   buffer[nsize++] = sum;
141   size = nsize;
137142}
138143
139144void jvs_host::decode(UINT8 *buffer, UINT32 &size)
r243230r243231
141146   if(!size)
142147      return;
143148   UINT32 pos = 0;
144   for(UINT32 i=0; i<size; i++) {
149   for(UINT32 i=0; i<size-1; i++) {
145150      UINT8 t = buffer[i];
146151      if(!i && t == 0xe0)
147152         continue;
r243230r243231
151156      }
152157      buffer[pos++] = t;
153158   }
154   size = pos ? pos - 1 : 0;
159   size = pos;
155160}
trunk/src/emu/machine/netlist.c
r243230r243231
440440               if (td != NULL) save_pointer(td, s->m_name, s->m_count);
441441            }
442442            break;
443         case DT_FLOAT:
444            {
445               float *td = s->resolved<float>();
446               if (td != NULL) save_pointer(td, s->m_name, s->m_count);
447            }
448            break;
443            case DT_FLOAT:
444                {
445                    float *td = s->resolved<float>();
446                    if (td != NULL) save_pointer(td, s->m_name, s->m_count);
447                }
448                break;
449449         case DT_INT64:
450450            save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count);
451451            break;
trunk/src/emu/mame.c
r243230r243231
9494
9595osd_interface &machine_manager::osd() const
9696{
97   return m_osd;
97    return m_osd;
9898}
9999
100100
trunk/src/emu/netlist/analog/nld_ms_direct.h
r243230r243231
1414public:
1515
1616   netlist_matrix_solver_direct_t(const netlist_solver_parameters_t &params, int size);
17   netlist_matrix_solver_direct_t(const eSolverType type, const netlist_solver_parameters_t &params, int size);
17    netlist_matrix_solver_direct_t(const eSolverType type, const netlist_solver_parameters_t &params, int size);
1818
1919   virtual ~netlist_matrix_solver_direct_t();
2020
r243230r243231
6969   {
7070      //delete[] m_A[k];
7171   }
72   for (int k = 0; k < N(); k++)
73   {
74      nl_free(m_terms[k]);
75      nl_free(m_row_ops[k]);
76   }
77   nl_free(m_row_ops[N()]);
78   //delete[] m_last_RHS;
72    for (int k = 0; k < N(); k++)
73    {
74        nl_free(m_terms[k]);
75        nl_free(m_row_ops[k]);
76    }
77    nl_free(m_row_ops[N()]);
78    //delete[] m_last_RHS;
7979   //delete[] m_RHS;
8080   nl_free_array(m_terms);
8181   nl_free_array(m_rails_temp);
r243230r243231
193193    * Sorting as a general matrix pre-conditioning is mentioned in
194194    * literature but I have found no articles about Gauss Seidel.
195195    *
196    * For Gaussian Elimination however increasing order is better suited.
197    * FIXME: Even better would be to sort on elements right of the matrix diagonal.
198    *
196     * For Gaussian Elimination however increasing order is better suited.
197     * FIXME: Even better would be to sort on elements right of the matrix diagonal.
198     *
199199    */
200200
201   int sort_order = (type() == GAUSS_SEIDEL ? 1 : -1);
201    int sort_order = (type() == GAUSS_SEIDEL ? 1 : -1);
202202
203203   for (int k = 0; k < N() / 2; k++)
204204      for (int i = 0; i < N() - 1; i++)
205205      {
206         if ((m_terms[i]->m_railstart - m_terms[i+1]->m_railstart) * sort_order < 0)
206            if ((m_terms[i]->m_railstart - m_terms[i+1]->m_railstart) * sort_order < 0)
207207         {
208208            std::swap(m_terms[i],m_terms[i+1]);
209209            m_nets.swap(i, i+1);
r243230r243231
475475, m_dim(size)
476476, m_lp_fact(0)
477477{
478   m_terms = nl_alloc_array(terms_t *, N());
479   m_rails_temp = nl_alloc_array(terms_t, N());
478    m_terms = nl_alloc_array(terms_t *, N());
479    m_rails_temp = nl_alloc_array(terms_t, N());
480480
481   for (int k = 0; k < N(); k++)
482   {
483      m_terms[k] = nl_alloc(terms_t);
484      m_row_ops[k] = vector_ops_t::create_ops(k);
485   }
486   m_row_ops[N()] = vector_ops_t::create_ops(N());
481    for (int k = 0; k < N(); k++)
482    {
483        m_terms[k] = nl_alloc(terms_t);
484        m_row_ops[k] = vector_ops_t::create_ops(k);
485    }
486    m_row_ops[N()] = vector_ops_t::create_ops(N());
487487}
488488
489489
trunk/src/emu/netlist/analog/nld_ms_gauss_seidel.h
r243230r243231
1717public:
1818
1919   netlist_matrix_solver_gauss_seidel_t(const netlist_solver_parameters_t &params, int size)
20      : netlist_matrix_solver_direct_t<m_N, _storage_N>(netlist_matrix_solver_t::GAUSS_SEIDEL, params, size)
20      : netlist_matrix_solver_direct_t<m_N, _storage_N>(netlist_matrix_solver_t::GAUSS_SEIDEL, params, size)
2121      , m_lp_fact(0)
2222      , m_gs_fail(0)
2323      , m_gs_total(0)
2424      {
25         const char *p = osd_getenv("NETLIST_STATS");
26         if (p != NULL)
27            m_log_stats = (bool) atoi(p);
28         else
29            m_log_stats = false;
25           const char *p = osd_getenv("NETLIST_STATS");
26           if (p != NULL)
27               m_log_stats = (bool) atoi(p);
28           else
29               m_log_stats = false;
3030      }
3131
3232   virtual ~netlist_matrix_solver_gauss_seidel_t() {}
r243230r243231
5252template <int m_N, int _storage_N>
5353void netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::log_stats()
5454{
55   if (this->m_stat_calculations != 0 && m_log_stats)
56   {
57      printf("==============================================\n");
58      printf("Solver %s\n", this->name().cstr());
59      printf("       ==> %d nets\n", this->N()); //, (*(*groups[i].first())->m_core_terms.first())->name().cstr());
60      printf("       has %s elements\n", this->is_dynamic() ? "dynamic" : "no dynamic");
61      printf("       has %s elements\n", this->is_timestep() ? "timestep" : "no timestep");
62      printf("       %6.3f average newton raphson loops\n", (double) this->m_stat_newton_raphson / (double) this->m_stat_vsolver_calls);
63      printf("       %10d invocations (%6d Hz)  %10d gs fails (%6.2f%%) %6.3f average\n",
64            this->m_stat_calculations,
65            this->m_stat_calculations * 10 / (int) (this->netlist().time().as_double() * 10.0),
66            this->m_gs_fail,
67            100.0 * (double) this->m_gs_fail / (double) this->m_stat_calculations,
68            (double) this->m_gs_total / (double) this->m_stat_calculations);
69   }
55    if (this->m_stat_calculations != 0 && m_log_stats)
56    {
57        printf("==============================================\n");
58        printf("Solver %s\n", this->name().cstr());
59        printf("       ==> %d nets\n", this->N()); //, (*(*groups[i].first())->m_core_terms.first())->name().cstr());
60        printf("       has %s elements\n", this->is_dynamic() ? "dynamic" : "no dynamic");
61        printf("       has %s elements\n", this->is_timestep() ? "timestep" : "no timestep");
62        printf("       %6.3f average newton raphson loops\n", (double) this->m_stat_newton_raphson / (double) this->m_stat_vsolver_calls);
63        printf("       %10d invocations (%6d Hz)  %10d gs fails (%6.2f%%) %6.3f average\n",
64                this->m_stat_calculations,
65                this->m_stat_calculations * 10 / (int) (this->netlist().time().as_double() * 10.0),
66                this->m_gs_fail,
67                100.0 * (double) this->m_gs_fail / (double) this->m_stat_calculations,
68                (double) this->m_gs_total / (double) this->m_stat_calculations);
69    }
7070}
7171
7272template <int m_N, int _storage_N>
r243230r243231
299299      //if (fabs(gabs_t - fabs(gtot_t)) > 1e-20)
300300      //    printf("%d %e abs: %f tot: %f\n",k, gabs_t / gtot_t -1.0, gabs_t, gtot_t);
301301
302      gabs_t *= 0.95; // avoid rounding issues
302        gabs_t *= 0.95; // avoid rounding issues
303303      if (!USE_GABS || gabs_t <= gtot_t)
304304      {
305305         w[k] = ws / gtot_t;
r243230r243231
343343      this->m_nets[k]->m_cur_Analog = new_V[k];
344344
345345   this->m_gs_total += resched_cnt;
346   this->m_stat_calculations++;
346    this->m_stat_calculations++;
347347
348348   if (resched)
349349   {
trunk/src/emu/netlist/analog/nld_opamps.c
r243230r243231
3131   NET_C(R1.2, R2.2, G1.ON)
3232   VCVS(G1)
3333   PARAM(G1.G, 10000000)
34   //PARAM(G1.RI, 1)
34    //PARAM(G1.RI, 1)
3535   PARAM(G1.RO, RES_K(8))
3636
3737NETLIST_END()
trunk/src/emu/netlist/analog/nld_solver.c
r243230r243231
9999
100100ATTR_COLD netlist_matrix_solver_t::netlist_matrix_solver_t(const eSolverType type, const netlist_solver_parameters_t &params)
101101: m_stat_calculations(0),
102   m_stat_newton_raphson(0),
103   m_stat_vsolver_calls(0),
104   m_params(params),
105   m_cur_ts(0),
106   m_type(type)
102  m_stat_newton_raphson(0),
103  m_stat_vsolver_calls(0),
104 m_params(params),
105 m_cur_ts(0),
106 m_type(type)
107107{
108108}
109109
r243230r243231
257257template<class C >
258258void netlist_matrix_solver_t::solve_base(C *p)
259259{
260   m_stat_vsolver_calls++;
260    m_stat_vsolver_calls++;
261261   if (is_dynamic())
262262   {
263263      int this_resched;
r243230r243231
270270         newton_loops++;
271271      } while (this_resched > 1 && newton_loops < m_params.m_nr_loops);
272272
273      m_stat_newton_raphson += newton_loops;
273        m_stat_newton_raphson += newton_loops;
274274      // reschedule ....
275275      if (this_resched > 1 && !m_Q_sync.net().is_queued())
276276      {
r243230r243231
438438      return nl_alloc(netlist_matrix_solver_direct2_t, m_params);
439439   else
440440   {
441      typedef netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N> solver_N;
441       typedef netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N> solver_N;
442442      if (size >= gs_threshold)
443443         return nl_alloc(solver_N, m_params, size);
444444      else
trunk/src/emu/netlist/analog/nld_solver.h
r243230r243231
197197
198198   enum eSolverType
199199   {
200      GAUSSIAN_ELIMINATION,
201      GAUSS_SEIDEL
200       GAUSSIAN_ELIMINATION,
201       GAUSS_SEIDEL
202202   };
203203
204204   ATTR_COLD netlist_matrix_solver_t(const eSolverType type, const netlist_solver_parameters_t &params);
r243230r243231
243243   plinearlist_t<netlist_analog_net_t *> m_nets;
244244   plinearlist_t<netlist_analog_output_t *> m_inps;
245245
246   int m_stat_calculations;
247   int m_stat_newton_raphson;
248   int m_stat_vsolver_calls;
246    int m_stat_calculations;
247    int m_stat_newton_raphson;
248    int m_stat_vsolver_calls;
249249
250250   const netlist_solver_parameters_t &m_params;
251251
r243230r243231
264264
265265   ATTR_HOT void update_inputs();
266266
267   const eSolverType m_type;
267    const eSolverType m_type;
268268};
269269
270270
trunk/src/emu/netlist/devices/net_lib.c
r243230r243231
7878   ENTRY(VCCS,                 VCCS,                   "-")
7979   ENTRY(CCCS,                 CCCS,                   "-")
8080   ENTRY(dummy_input,          DUMMY_INPUT,            "-")
81   ENTRY(frontier,             FRONTIER,               "+I,Q")
81    ENTRY(frontier,             FRONTIER,               "+I,Q")
8282   ENTRY(QBJT_EB,              QBJT_EB,                "model")
8383   ENTRY(QBJT_switch,          QBJT_SW,                "model")
8484   ENTRY(ttl_input,            TTL_INPUT,              "IN")
r243230r243231
148148   ENTRY(SN74LS629_dip,        SN74LS629_DIP,          "1.CAP1,2.CAP2")
149149   ENTRY(NE555_dip,            NE555_DIP,              "-")
150150}
151
trunk/src/emu/netlist/devices/nld_4020.c
r243230r243231
4343   register_output("Q5", m_Q[4]);
4444   register_output("Q6", m_Q[5]);
4545   register_output("Q7", m_Q[6]);
46   register_output("Q8", m_Q[7]);
46    register_output("Q8", m_Q[7]);
4747   register_output("Q9", m_Q[8]);
4848   register_output("Q10", m_Q[9]);
4949   register_output("Q11", m_Q[10]);
trunk/src/emu/netlist/devices/nld_cmos.h
r243230r243231
2121
2222   protected:
2323      ATTR_HOT void update() {};
24      ATTR_HOT void start()
25      {
26         register_input("VDD,", m_vdd);
27         register_input("VSS,", m_vss);
28      };
24        ATTR_HOT void start()
25        {
26            register_input("VDD,", m_vdd);
27            register_input("VSS,", m_vss);
28        };
2929      ATTR_HOT void reset()  {};
3030
3131public:
trunk/src/emu/netlist/devices/nld_system.h
r243230r243231
4040      NET_REGISTER_DEV(dummy_input, _name)
4141
4242#define FRONTIER(_name, _IN, _OUT)                                             \
43      NET_REGISTER_DEV(frontier, _name)                                      \
44      NET_C(_IN, _name.I)                                                    \
45      NET_C(_OUT, _name.Q)
43        NET_REGISTER_DEV(frontier, _name)                                      \
44        NET_C(_IN, _name.I)                                                    \
45        NET_C(_OUT, _name.Q)                                                   \
46
4647// -----------------------------------------------------------------------------
4748// mainclock
4849// -----------------------------------------------------------------------------
r243230r243231
158159class NETLIB_NAME(frontier) : public netlist_device_t
159160{
160161public:
161   ATTR_COLD NETLIB_NAME(frontier)()
162         : netlist_device_t(DUMMY) { }
162    ATTR_COLD NETLIB_NAME(frontier)()
163            : netlist_device_t(DUMMY) { }
163164
164   ATTR_COLD virtual ~NETLIB_NAME(frontier)() {}
165    ATTR_COLD virtual ~NETLIB_NAME(frontier)() {}
165166
166167protected:
167168
168   ATTR_COLD void start()
169   {
170      register_input("I", m_I);
171      register_output("Q", m_Q);
172   }
169    ATTR_COLD void start()
170    {
171        register_input("I", m_I);
172        register_output("Q", m_Q);
173    }
173174
174   ATTR_COLD void reset()
175   {
176   }
175    ATTR_COLD void reset()
176    {
177    }
177178
178   ATTR_HOT ATTR_ALIGN void update()
179   {
180      OUTANALOG(m_Q, INPANALOG(m_I));
181   }
179    ATTR_HOT ATTR_ALIGN void update()
180    {
181        OUTANALOG(m_Q, INPANALOG(m_I));
182    }
182183
183184private:
184   netlist_analog_input_t m_I;
185   netlist_analog_output_t m_Q;
185    netlist_analog_input_t m_I;
186    netlist_analog_output_t m_Q;
186187
187188};
188189
trunk/src/emu/netlist/nl_base.c
r243230r243231
10011001   net.toggle_new_Q();
10021002   net.set_time(netlist().time() + m_inc);
10031003}
1004
trunk/src/emu/netlist/nl_base.h
r243230r243231
337337      CAPACITOR,  // Capacitor
338338      DIODE,      // Diode
339339      DUMMY,      // DUMMY device without function
340      FRONTIER,   // Net frontier
340        FRONTIER,   // Net frontier
341341      BJT_EB,     // BJT(Ebers-Moll)
342342      BJT_SWITCH, // BJT(Switch)
343343      VCVS,       // Voltage controlled voltage source
r243230r243231
12681268
12691269ATTR_HOT inline const netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() const
12701270{
1271   nl_assert(family() == LOGIC);
1271    nl_assert(family() == LOGIC);
12721272   return static_cast<const netlist_logic_net_t &>(*this);
12731273}
12741274
12751275ATTR_HOT inline netlist_analog_net_t & RESTRICT netlist_net_t::as_analog()
12761276{
1277   nl_assert(family() == ANALOG);
1277    nl_assert(family() == ANALOG);
12781278   return static_cast<netlist_analog_net_t &>(*this);
12791279}
12801280
trunk/src/emu/netlist/nl_config.h
r243230r243231
121121class nl_fatalerror : public std::exception
122122{
123123public:
124   nl_fatalerror(const char *format, ...) ATTR_PRINTF(2,3)
125   {
126      char text[1024];
127      va_list ap;
128      va_start(ap, format);
129      vsprintf(text, format, ap);
130      va_end(ap);
131      osd_printf_error("%s\n", text);
132   }
133   nl_fatalerror(const char *format, va_list ap)
134   {
135      char text[1024];
136      vsprintf(text, format, ap);
137      osd_printf_error("%s\n", text);
138   }
124    nl_fatalerror(const char *format, ...) ATTR_PRINTF(2,3)
125    {
126        char text[1024];
127        va_list ap;
128        va_start(ap, format);
129        vsprintf(text, format, ap);
130        va_end(ap);
131        osd_printf_error("%s\n", text);
132    }
133    nl_fatalerror(const char *format, va_list ap)
134    {
135        char text[1024];
136        vsprintf(text, format, ap);
137        osd_printf_error("%s\n", text);
138    }
139139};
140140
141141//============================================================
trunk/src/emu/netlist/nl_factory.c
r243230r243231
5656
5757ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list()
5858{
59   if (m_def_param.startsWith("+"))
60      return nl_util::split(m_def_param.substr(1), ",");
61   else
62      return nl_util::pstring_list();
59    if (m_def_param.startsWith("+"))
60        return nl_util::split(m_def_param.substr(1), ",");
61    else
62        return nl_util::pstring_list();
6363}
6464
6565ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params()
6666{
67   if (m_def_param.startsWith("+") || m_def_param.equals("-"))
68      return nl_util::pstring_list();
69   else
70      return nl_util::split(m_def_param, ",");
67    if (m_def_param.startsWith("+") || m_def_param.equals("-"))
68        return nl_util::pstring_list();
69    else
70        return nl_util::split(m_def_param, ",");
7171}
7272
7373
trunk/src/emu/netlist/nl_setup.c
r243230r243231
9797
9898netlist_device_t *netlist_setup_t::register_dev(const pstring &classname, const pstring &name)
9999{
100   netlist_device_t *dev = factory().new_device_by_classname(classname);
101   if (dev == NULL)
102      netlist().error("Class %s not found!\n", classname.cstr());
103   return register_dev(dev, name);
100    netlist_device_t *dev = factory().new_device_by_classname(classname);
101    if (dev == NULL)
102        netlist().error("Class %s not found!\n", classname.cstr());
103    return register_dev(dev, name);
104104}
105105
106106template <class T>
r243230r243231
697697
698698void netlist_setup_t::start_devices()
699699{
700   //FIXME: we need a nl_getenv
700    //FIXME: we need a nl_getenv
701701   if (getenv("NL_LOGS"))
702702   {
703703      NL_VERBOSE_OUT(("Creating dynamic logs ...\n"));
trunk/src/emu/netlist/nl_setup.h
r243230r243231
146146   void namespace_push(const pstring &aname);
147147   void namespace_pop();
148148
149   netlist_factory_t &factory() { return *m_factory; }
150   const netlist_factory_t &factory() const { return *m_factory; }
149    netlist_factory_t &factory() { return *m_factory; }
150    const netlist_factory_t &factory() const { return *m_factory; }
151151
152   /* not ideal, but needed for save_state */
153   tagmap_terminal_t  m_terminals;
152    /* not ideal, but needed for save_state */
153    tagmap_terminal_t  m_terminals;
154154
155   void print_stats() const;
155    void print_stats() const;
156156
157157protected:
158158
trunk/src/emu/netlist/plists.h
r243230r243231
6060   ATTR_COLD ~plinearlist_t()
6161   {
6262      if (m_list != NULL)
63         nl_free_array(m_list);
63          nl_free_array(m_list);
6464      m_list = NULL;
6565   }
6666
r243230r243231
183183      else
184184      {
185185         if (m_list != NULL)
186            nl_free_array(m_list);
186             nl_free_array(m_list);
187187         m_list = NULL;
188188         m_count = 0;
189189      }
trunk/src/emu/netlist/pstate.c
r243230r243231
2424         "DT_INT8",
2525         "DT_INT",
2626         "DT_BOOLEAN",
27         "DT_FLOAT"
27            "DT_FLOAT"
2828   };
2929
3030   NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr));
r243230r243231
6464
6565template<> ATTR_COLD void pstate_manager_t::save_item(pstate_callback_t &state, const void *owner, const pstring &stname)
6666{
67   //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
68   pstate_entry_t *p = nl_alloc(pstate_entry_t, stname, owner, &state);
69   m_save.add(p);
70   state.register_state(*this, stname);
67    //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
68    pstate_entry_t *p = nl_alloc(pstate_entry_t, stname, owner, &state);
69    m_save.add(p);
70    state.register_state(*this, stname);
7171}
trunk/src/emu/parameters.c
r243230r243231
2424{
2525   m_parameters.add(tag, value);
2626}
27
trunk/src/emu/render.c
r243230r243231
207207
208208render_texinfo &render_texinfo::operator=(const render_texinfo &src)
209209{
210   free_palette();
211   base = src.base;
212   rowpixels = src.rowpixels;
213   width = src.width;
214   height = src.height;
215   seqid = src.seqid;
216   osddata = src.osddata;
217   m_palette = src.m_palette;
218   if (m_palette != NULL)
219   {
220      m_palette->ref_count++;
221   }
222   return *this;
210    free_palette();
211    base = src.base;
212    rowpixels = src.rowpixels;
213    width = src.width;
214    height = src.height;
215    seqid = src.seqid;
216    osddata = src.osddata;
217    m_palette = src.m_palette;
218    if (m_palette != NULL)
219    {
220        m_palette->ref_count++;
221    }
222    return *this;
223223}
224224
225225render_texinfo::render_texinfo(const render_texinfo &src)
226226{
227   base = src.base;
228   rowpixels = src.rowpixels;
229   width = src.width;
230   height = src.height;
231   seqid = src.seqid;
232   osddata = src.osddata;
233   m_palette = src.m_palette;
234   if (m_palette != NULL)
235   {
236      m_palette->ref_count++;
237   }
227    base = src.base;
228    rowpixels = src.rowpixels;
229    width = src.width;
230    height = src.height;
231    seqid = src.seqid;
232    osddata = src.osddata;
233    m_palette = src.m_palette;
234    if (m_palette != NULL)
235    {
236        m_palette->ref_count++;
237    }
238238}
239239
240240void render_texinfo::set_palette(const dynamic_array<rgb_t> *source)
241241{
242   free_palette();
243   if (source != NULL)
244   {
245      m_palette = global_alloc(render_palette_copy);
246      m_palette->palette.copyfrom(*source);
247      m_palette->ref_count = 1;
248   }
249   else
250   {
251      m_palette = NULL;
252   }
242    free_palette();
243    if (source != NULL)
244    {
245        m_palette = global_alloc(render_palette_copy);
246        m_palette->palette.copyfrom(*source);
247        m_palette->ref_count = 1;
248    }
249    else
250    {
251        m_palette = NULL;
252    }
253253}
254254
255255void render_texinfo::free_palette()
256256{
257   if (m_palette != NULL)
258   {
259      m_palette->ref_count--;
260      if (m_palette->ref_count == 0)
261      {
262         global_free(m_palette);
263      }
264   }
265   m_palette = NULL;
257    if (m_palette != NULL)
258    {
259        m_palette->ref_count--;
260        if (m_palette->ref_count == 0)
261        {
262            global_free(m_palette);
263        }
264    }
265    m_palette = NULL;
266266}
267267
268268
r243230r243231
277277
278278void render_primitive::reset()
279279{
280   // public state
281   type = INVALID;
282   bounds.x0 = 0;
283   bounds.y0 = 0;
284   bounds.x1 = 0;
285   bounds.y1 = 0;
286   color.a = 0;
287   color.r = 0;
288   color.g = 0;
289   color.b = 0;
290   flags = 0;
291   width = 0.0f;
292   texture.set_palette(NULL);
293   texture = render_texinfo();
294   texcoords.bl.u = 0.0f;
295   texcoords.bl.v = 0.0f;
296   texcoords.br.u = 0.0f;
297   texcoords.br.v = 0.0f;
298   texcoords.tl.u = 0.0f;
299   texcoords.tl.v = 0.0f;
300   texcoords.tr.u = 0.0f;
301   texcoords.tr.v = 0.0f;
280    // public state
281    type = INVALID;
282    bounds.x0 = 0;
283    bounds.y0 = 0;
284    bounds.x1 = 0;
285    bounds.y1 = 0;
286    color.a = 0;
287    color.r = 0;
288    color.g = 0;
289    color.b = 0;
290    flags = 0;
291    width = 0.0f;
292    texture.set_palette(NULL);
293    texture = render_texinfo();
294    texcoords.bl.u = 0.0f;
295    texcoords.bl.v = 0.0f;
296    texcoords.br.u = 0.0f;
297    texcoords.br.v = 0.0f;
298    texcoords.tl.u = 0.0f;
299    texcoords.tl.v = 0.0f;
300    texcoords.tr.u = 0.0f;
301    texcoords.tr.v = 0.0f;
302302
303   // do not clear m_next!
304   // memset(&type, 0, FPTR(&texcoords + 1) - FPTR(&type));
303    // do not clear m_next!
304    // memset(&type, 0, FPTR(&texcoords + 1) - FPTR(&type));
305305}
306306
307307
r243230r243231
556556      texinfo.width = swidth;
557557      texinfo.height = sheight;
558558      // will be set later
559      texinfo.set_palette(NULL);
559        texinfo.set_palette(NULL);
560560      texinfo.seqid = ++m_curseq;
561561   }
562562   else
563563   {
564      // make sure we can recover the original argb32 bitmap
565      bitmap_argb32 dummy;
566      bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy;
564        // make sure we can recover the original argb32 bitmap
565        bitmap_argb32 dummy;
566        bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy;
567567
568      // is it a size we already have?
569      scaled_texture *scaled = NULL;
570      int scalenum;
571      for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
572      {
573         scaled = &m_scaled[scalenum];
568        // is it a size we already have?
569        scaled_texture *scaled = NULL;
570        int scalenum;
571        for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
572        {
573            scaled = &m_scaled[scalenum];
574574
575         // we need a non-NULL bitmap with matching dest size
576         if (scaled->bitmap != NULL && dwidth == scaled->bitmap->width() && dheight == scaled->bitmap->height())
577            break;
578      }
575            // we need a non-NULL bitmap with matching dest size
576            if (scaled->bitmap != NULL && dwidth == scaled->bitmap->width() && dheight == scaled->bitmap->height())
577                break;
578        }
579579
580      // did we get one?
581      if (scalenum == ARRAY_LENGTH(m_scaled))
582      {
583         int lowest = -1;
580        // did we get one?
581        if (scalenum == ARRAY_LENGTH(m_scaled))
582        {
583            int lowest = -1;
584584
585         // didn't find one -- take the entry with the lowest seqnum
586         for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
587            if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap))
588               lowest = scalenum;
589         assert_always(lowest != -1, "Too many live texture instances!");
585            // didn't find one -- take the entry with the lowest seqnum
586            for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
587                if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap))
588                    lowest = scalenum;
589            assert_always(lowest != -1, "Too many live texture instances!");
590590
591         // throw out any existing entries
592         scaled = &m_scaled[lowest];
593         if (scaled->bitmap != NULL)
594         {
595            m_manager->invalidate_all(scaled->bitmap);
596            global_free(scaled->bitmap);
597         }
591            // throw out any existing entries
592            scaled = &m_scaled[lowest];
593            if (scaled->bitmap != NULL)
594            {
595                m_manager->invalidate_all(scaled->bitmap);
596                global_free(scaled->bitmap);
597            }
598598
599         // allocate a new bitmap
600         scaled->bitmap = global_alloc(bitmap_argb32(dwidth, dheight));
601         scaled->seqid = ++m_curseq;
599            // allocate a new bitmap
600            scaled->bitmap = global_alloc(bitmap_argb32(dwidth, dheight));
601            scaled->seqid = ++m_curseq;
602602
603         // let the scaler do the work
604         (*m_scaler)(*scaled->bitmap, srcbitmap, m_sbounds, m_param);
605      }
603            // let the scaler do the work
604            (*m_scaler)(*scaled->bitmap, srcbitmap, m_sbounds, m_param);
605        }
606606
607      // finally fill out the new info
608      primlist.add_reference(scaled->bitmap);
609      texinfo.base = &scaled->bitmap->pix32(0);
610      texinfo.rowpixels = scaled->bitmap->rowpixels();
611      texinfo.width = dwidth;
612      texinfo.height = dheight;
613      // will be set later
614      texinfo.set_palette(NULL);
615      texinfo.seqid = scaled->seqid;
607        // finally fill out the new info
608        primlist.add_reference(scaled->bitmap);
609        texinfo.base = &scaled->bitmap->pix32(0);
610        texinfo.rowpixels = scaled->bitmap->rowpixels();
611        texinfo.width = dwidth;
612        texinfo.height = dheight;
613        // will be set later
614        texinfo.set_palette(NULL);
615        texinfo.seqid = scaled->seqid;
616616   }
617617}
618618
r243230r243231
18171817               height = MIN(height, m_maxtexheight);
18181818
18191819               curitem->texture()->get_scaled(width, height, prim->texture, list);
1820               // set the palette
1820                    // set the palette
18211821#if 1
18221822               const dynamic_array<rgb_t> *adjusted_pal = curitem->texture()->get_adjusted_palette(container);
1823               prim->texture.set_palette(adjusted_pal);
1823                    prim->texture.set_palette(adjusted_pal);
18241824#else
1825               prim->texture.palette = curitem->texture()->get_adjusted_palette(container);
1825                    prim->texture.palette = curitem->texture()->get_adjusted_palette(container);
18261826#endif
18271827
1828               // determine UV coordinates and apply clipping
1829               prim->texcoords = oriented_texcoords[finalorient];
1830               clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
1828                    // determine UV coordinates and apply clipping
1829                    prim->texcoords = oriented_texcoords[finalorient];
1830                    clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
18311831
1832               // apply the final orientation from the quad flags and then build up the final flags
1833               prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) |
1834                           PRIMFLAG_TEXORIENT(finalorient) |
1835                           PRIMFLAG_TEXFORMAT(curitem->texture()->format());
1836               if (blendmode != -1)
1837                  prim->flags |= PRIMFLAG_BLENDMODE(blendmode);
1838               else
1839                  prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
1832                    // apply the final orientation from the quad flags and then build up the final flags
1833                    prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) |
1834                                    PRIMFLAG_TEXORIENT(finalorient) |
1835                                    PRIMFLAG_TEXFORMAT(curitem->texture()->format());
1836                    if (blendmode != -1)
1837                        prim->flags |= PRIMFLAG_BLENDMODE(blendmode);
1838                    else
1839                        prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
18401840            }
18411841            else
18421842            {
r243230r243231
18761876            (container_xform.orientation & ORIENTATION_SWAP_XY) ? width : height, prim->texture, list);
18771877
18781878      // determine UV coordinates
1879      prim->texcoords = oriented_texcoords[container_xform.orientation];
1879        prim->texcoords = oriented_texcoords[container_xform.orientation];
18801880
1881      // set the flags and add it to the list
1882      prim->flags = PRIMFLAG_TEXORIENT(container_xform.orientation) |
1883                  PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY) |
1884                  PRIMFLAG_TEXFORMAT(container.overlay()->format()) |
1885                  PRIMFLAG_TEXSHADE(1);
1881        // set the flags and add it to the list
1882        prim->flags = PRIMFLAG_TEXORIENT(container_xform.orientation) |
1883                        PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY) |
1884                        PRIMFLAG_TEXFORMAT(container.overlay()->format()) |
1885                        PRIMFLAG_TEXSHADE(1);
18861886
1887      list.append_or_return(*prim, false);
1887        list.append_or_return(*prim, false);
18881888   }
18891889}
18901890
r243230r243231
19251925
19261926      texture->get_scaled(width, height, prim->texture, list);
19271927
1928      // compute the clip rect
1929      render_bounds cliprect;
1930      cliprect.x0 = render_round_nearest(xform.xoffs);
1931      cliprect.y0 = render_round_nearest(xform.yoffs);
1932      cliprect.x1 = render_round_nearest(xform.xoffs + xform.xscale);
1933      cliprect.y1 = render_round_nearest(xform.yoffs + xform.yscale);
1934      sect_render_bounds(&cliprect, &m_bounds);
1928        // compute the clip rect
1929        render_bounds cliprect;
1930        cliprect.x0 = render_round_nearest(xform.xoffs);
1931        cliprect.y0 = render_round_nearest(xform.yoffs);
1932        cliprect.x1 = render_round_nearest(xform.xoffs + xform.xscale);
1933        cliprect.y1 = render_round_nearest(xform.yoffs + xform.yscale);
1934        sect_render_bounds(&cliprect, &m_bounds);
19351935
1936      // determine UV coordinates and apply clipping
1937      prim->texcoords = oriented_texcoords[xform.orientation];
1938      bool clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
1936        // determine UV coordinates and apply clipping
1937        prim->texcoords = oriented_texcoords[xform.orientation];
1938        bool clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
19391939
19401940      // add to the list or free if we're clipped out
19411941      list.append_or_return(*prim, clipped);
trunk/src/emu/render.h
r243230r243231
213213
214214struct render_palette_copy
215215{
216   int ref_count;
217   dynamic_array<rgb_t> palette;
216    int ref_count;
217    dynamic_array<rgb_t> palette;
218218};
219219
220220class render_texinfo
221221{
222222public:
223   render_texinfo()
224   : base(NULL), rowpixels(0), width(0), height(0),
225      seqid(0), osddata(0), m_palette(NULL)
226   {}
223    render_texinfo()
224    : base(NULL), rowpixels(0), width(0), height(0),
225      seqid(0), osddata(0), m_palette(NULL)
226    {}
227227
228   render_texinfo(const render_texinfo &src);
228    render_texinfo(const render_texinfo &src);
229229
230   ~render_texinfo()
231   {
232      free_palette();
233   }
230    ~render_texinfo()
231    {
232        free_palette();
233    }
234234
235   render_texinfo &operator=(const render_texinfo &src);
235    render_texinfo &operator=(const render_texinfo &src);
236236
237237   void *              base;               // base of the data
238238   UINT32              rowpixels;          // pixels per row
r243230r243231
241241   UINT32              seqid;              // sequence ID
242242   UINT64              osddata;            // aux data to pass to osd
243243
244   const rgb_t *       palette() const { return ((m_palette == NULL) ? NULL : &m_palette->palette[0]); }
244    const rgb_t *       palette() const { return ((m_palette == NULL) ? NULL : &m_palette->palette[0]); }
245245
246   void set_palette(const dynamic_array<rgb_t> *source);
246    void set_palette(const dynamic_array<rgb_t> *source);
247247
248248private:
249   void free_palette();
249    void free_palette();
250250
251   render_palette_copy *m_palette;     // palette for PALETTE16 textures, LUTs for RGB15/RGB32
251    render_palette_copy *m_palette;     // palette for PALETTE16 textures, LUTs for RGB15/RGB32
252252};
253253
254254
trunk/src/emu/rendfont.c
r243230r243231
9292      m_osdfont = manager.machine().osd().font_alloc();
9393      if (m_osdfont != NULL)
9494      {
95         if (m_osdfont->open(manager.machine().options().font_path(), filename, m_height))
96         {
97            m_scale = 1.0f / (float)m_height;
98            m_format = FF_OSD;
99            return;
100         }
101         global_free(m_osdfont);
102         m_osdfont = NULL;
95          if (m_osdfont->open(manager.machine().options().font_path(), filename, m_height))
96          {
97               m_scale = 1.0f / (float)m_height;
98               m_format = FF_OSD;
99               return;
100          }
101          global_free(m_osdfont);
102          m_osdfont = NULL;
103103      }
104104   }
105105
r243230r243231
136136   // release the OSD font
137137   if (m_osdfont != NULL)
138138   {
139      m_osdfont->close();
140      global_free(m_osdfont);
139        m_osdfont->close();
140        global_free(m_osdfont);
141141   }
142142}
143143
trunk/src/emu/sound/qs1000.c
r243230r243231
246246
247247   save_item(NAME(m_serial_data_in));
248248   save_item(NAME(m_wave_regs));
249
249   
250250   for (int i = 0; i < QS1000_CHANNELS; i++)
251251   {
252252      save_item(NAME(m_channels[i].m_acc), i);
trunk/src/emu/sound/tiasound.c
r243230r243231
597597      chip->P5[chan] = 0;
598598      chip->P9[chan] = 0;
599599   }
600
600   
601601   tia_save_state(device, chip);
602602
603603   return chip;
trunk/src/emu/ui/barcode.c
r243230r243231
2020
2121
2222/**************************************************
23
23
2424 BARCODE READER MENU
25
25
2626 **************************************************/
2727
2828
r243230r243231
5151void ui_menu_barcode_reader::populate()
5252{
5353   if (current_device())
54   {
54   {     
5555      astring buffer;
5656      const char *new_barcode;
5757
r243230r243231
6868      {
6969         new_barcode = m_barcode_buffer;
7070      }
71
71     
7272      item_append("New Barcode:", new_barcode, 0, ITEMREF_NEW_BARCODE);
73
73     
7474      // finish up the menu
7575      item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
7676      item_append("Enter Code", NULL, 0, ITEMREF_ENTER_BARCODE);
77
77     
7878      customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
7979   }
8080}
r243230r243231
103103            if (event->itemref == ITEMREF_SELECT_READER)
104104               previous();
105105            break;
106
106           
107107         case IPT_UI_RIGHT:
108108            if (event->itemref == ITEMREF_SELECT_READER)
109109               next();
trunk/src/emu/ui/devctrl.h
r243230r243231
99    printers)
1010    The base class contains calls to get the total number of devices of
1111    the same kind connected to the driver, and shortcuts to switch current
12    device to next one or previous one attached. This allows, for instance,
13    users to pass from a device to another one by simply pressing left/right
14    and the menu is rebuilt accordingly, without the need of a preliminary
12    device to next one or previous one attached. This allows, for instance,
13    users to pass from a device to another one by simply pressing left/right
14    and the menu is rebuilt accordingly, without the need of a preliminary
1515    submenu listing available devices of the same kind.
1616
1717    Copyright Nicola Salmoria and the MAME Team.
trunk/src/emu/ui/devopt.c
r243230r243231
6666
6767         // get cpu specific clock that takes internal multiplier/dividers into account
6868         int clock = exec->device().clock();
69
69         
7070         // count how many identical CPUs we have
7171         int count = 1;
7272         const char *name = exec->device().name();
r243230r243231
7777               if (exectags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE)
7878                  count++;
7979         }
80
80         
8181         // if more than one, prepend a #x in front of the CPU name
8282         if (count > 1)
8383            string.catprintf("  %d" UTF8_MULTIPLY, count);
8484         else
8585            string.cat("  ");
8686         string.cat(name);
87
87         
8888         // display clock in kHz or MHz
8989         if (clock >= 1000000)
9090            string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
r243230r243231
9292            string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
9393      }
9494   }
95
95   
9696   // display screen information
9797   screen_device_iterator scriter(*dev);
9898   if (scriter.count() > 0)
r243230r243231
101101      for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next())
102102      {
103103         string.catprintf("  Screen '%s': ", screen->tag());
104
104         
105105         if (screen->screen_type() == SCREEN_TYPE_VECTOR)
106106            string.cat("Vector\n");
107107         else
108108         {
109109            const rectangle &visarea = screen->visible_area();
110
110           
111111            string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
112                           visarea.width(), visarea.height(),
113                           (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
114                           ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds));
112                         visarea.width(), visarea.height(),
113                         (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
114                         ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds));
115115         }
116116      }
117117   }
118
118   
119119   // loop over all sound chips
120120   sound_interface_iterator snditer(*dev);
121121   if (snditer.count() > 0)
r243230r243231
126126      {
127127         if (soundtags.add(sound->device().tag(), 1, FALSE) == TMERR_DUPLICATE)
128128            continue;
129
129         
130130         // count how many identical sound chips we have
131131         int count = 1;
132132         sound_interface_iterator sndinneriter(*dev);
r243230r243231
142142         else
143143            string.cat("  ");
144144         string.cat(sound->device().name());
145
145         
146146         // display clock in kHz or MHz
147147         int clock = sound->device().clock();
148148         if (clock >= 1000000)
r243230r243231
156156
157157   // scan for BIOS settings
158158   int bios = 0;
159   if (dev->rom_region())
159   if (dev->rom_region())
160160   {
161161      astring bios_str;
162162      // first loop through roms in search of default bios (shortname)
r243230r243231
174174               bios_str.cpy(ROM_GETHASHDATA(rom));
175175         }
176176      }
177
177     
178178      if (bios)
179179         string.catprintf("* BIOS settings:\n  %d options    [default: %s]\n", bios, bios_str.cstr());
180180   }
181
181   
182182   int input = 0, input_mj = 0, input_hana = 0, input_gamble = 0, input_analog = 0, input_adjust = 0;
183183   int input_keypad = 0, input_keyboard = 0, dips = 0, confs = 0;
184184   astring errors, dips_opt, confs_opt;
r243230r243231
265265      for (const device_image_interface *imagedev = imgiter.first(); imagedev != NULL; imagedev = imgiter.next())
266266         string.catprintf("  %s    [tag: %s]\n", imagedev->image_type_name(), imagedev->device().tag());
267267   }
268
268   
269269   slot_interface_iterator slotiter(*dev);
270270   if (slotiter.count() > 0)
271271   {
r243230r243231
275275   }
276276
277277   if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs
278         + input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0)
278      + input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0)
279279      string.cat("[None]\n");
280280
281281   const_cast<machine_config &>(machine().config()).device_remove(&machine().config().root_device(), m_option->name());
trunk/src/emu/ui/devopt.h
r243230r243231
11/***************************************************************************
22
33    ui/devopt.h
4
4
55    Internal menu for the device configuration.
6
6
77    Copyright Nicola Salmoria and the MAME Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
99
trunk/src/emu/ui/filemngr.c
r243230r243231
6464{
6565   // get the image type/id
6666   instance.printf("%s (%s)", img->instance_name(), img->brief_instance_name());
67
67   
6868   // get the base name
6969   if (img->basename() != NULL)
7070   {
7171      filename.cpy(img->basename());
72
72     
7373      // if the image has been loaded through softlist, also show the loaded part
7474      if (img->part_entry() != NULL)
7575      {
r243230r243231
107107      item_append(m_warnings, NULL, MENU_FLAG_DISABLE, NULL);
108108      item_append("", NULL, MENU_FLAG_DISABLE, NULL);
109109   }
110
110     
111111   // cycle through all devices for this system
112112   device_iterator iter(machine().root_device());
113113   tagmap_t<UINT8> devtags;
r243230r243231
120120      // check whether it owns an image interface
121121      image_interface_iterator subiter(*dev);
122122      if (subiter.count() > 0)
123      {
123      {         
124124         // if so, cycle through all its image interfaces
125125         image_interface_iterator subiter(*dev);
126126         for (device_image_interface *scan = subiter.first(); scan != NULL; scan = subiter.next())
r243230r243231
172172         if (selected_device != NULL)
173173         {
174174            ui_menu::stack_push(selected_device->get_selection_menu(machine(), container));
175
175           
176176            // reset the existing menu
177177            reset(UI_MENU_RESET_REMEMBER_POSITION);
178178         }
r243230r243231
182182
183183// force file manager menu
184184void ui_menu_file_manager::force_file_manager(running_machine &machine, render_container *container, const char *warnings)
185{
185{   
186186   // reset the menu stack
187187   ui_menu::stack_reset(machine);
188
188   
189189   // add the quit entry followed by the game select entry
190190   ui_menu *quit = auto_alloc_clear(machine, ui_menu_quit_game(machine, container));
191191   quit->set_special_main_menu(true);
192192   ui_menu::stack_push(quit);
193193   ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_file_manager(machine, container, warnings)));
194
194   
195195   // force the menus on
196196   machine.ui().show_menu();
197
197   
198198   // make sure MAME is paused
199199   machine.pause();
200200}
trunk/src/emu/ui/imgcntrl.c
r243230r243231
328328      state = create_ok ? CREATE_FILE : START_FILE;
329329      handle();
330330      break;
331
331         
332332   case DO_CREATE: {
333333      astring path;
334334      zippath_combine(path, current_directory, current_file);
trunk/src/emu/ui/imgcntrl.h
r243230r243231
2727
2828protected:
2929   enum {
30      START_FILE, START_OTHER_PART, START_SOFTLIST,
31      SELECT_PARTLIST, SELECT_ONE_PART, SELECT_OTHER_PART,
30      START_FILE, START_OTHER_PART, START_SOFTLIST,
31      SELECT_PARTLIST, SELECT_ONE_PART, SELECT_OTHER_PART,
3232      SELECT_FILE, CREATE_FILE, CREATE_CONFIRM, CHECK_CREATE, DO_CREATE, SELECT_SOFTLIST,
3333      LAST_ID
3434   };
trunk/src/emu/ui/info.c
r243230r243231
8989
9090         // display long filename
9191         item_append(image->longname(), "", MENU_FLAG_DISABLE, NULL);
92
92         
9393         // display manufacturer and year
9494         string.catprintf("%s, %s", image->manufacturer(), image->year());
9595         item_append(string, "", MENU_FLAG_DISABLE, NULL);
9696
9797         // display supported information, if available
98         switch (image->supported())
98         switch (image->supported())
9999         {
100            case SOFTWARE_SUPPORTED_NO:
100            case SOFTWARE_SUPPORTED_NO:
101101               item_append("Not supported", "", MENU_FLAG_DISABLE, NULL);
102102               break;
103            case SOFTWARE_SUPPORTED_PARTIAL:
103            case SOFTWARE_SUPPORTED_PARTIAL:
104104               item_append("Partially supported", "", MENU_FLAG_DISABLE, NULL);
105105               break;
106            default:
106            default:
107107               break;
108108         }
109109      }
trunk/src/emu/ui/inputmap.c
r243230r243231
487487   if (menu_event != NULL && menu_event->itemref != NULL)
488488   {
489489      // reset
490      if ((FPTR)menu_event->itemref == 1)
490      if ((FPTR)menu_event->itemref == 1)
491491      {
492492         if (menu_event->iptkey == IPT_UI_SELECT)
493493            machine().schedule_hard_reset();
r243230r243231
498498         ioport_field *field = (ioport_field *)menu_event->itemref;
499499         ioport_field::user_settings settings;
500500         int changed = false;
501
501         
502502         switch (menu_event->iptkey)
503503         {
504504            /* if selected, reset to default value */
r243230r243231
508508               field->set_user_settings(settings);
509509               changed = true;
510510               break;
511
511               
512512            /* left goes to previous setting */
513513            case IPT_UI_LEFT:
514514               field->select_previous_setting();
515515               changed = true;
516516               break;
517
517               
518518            /* right goes to next setting */
519519            case IPT_UI_RIGHT:
520520               field->select_next_setting();
521521               changed = true;
522522               break;
523523         }
524
524         
525525         /* if anything changed, rebuild the menu, trying to stay on the same field */
526526         if (changed)
527527            reset(UI_MENU_RESET_REMEMBER_REF);
r243230r243231
628628         }
629629   if (type == IPT_DIPSWITCH)
630630      custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0;
631
631   
632632   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
633633   item_append("Reset",  NULL, 0, (void *)1);
634634}
r243230r243231
661661   {
662662      const ioport_diplocation *diploc;
663663      UINT32 selectedmask = 0;
664
664     
665665      // determine the mask of selected bits
666666      if ((FPTR)selectedref != 1)
667667      {
668668         ioport_field *field = (ioport_field *)selectedref;
669
669         
670670         if (field != NULL && field->first_diplocation() != NULL)
671671            for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
672672               if (strcmp(dip->name, diploc->name()) == 0)
673673                  selectedmask |= 1 << (diploc->number() - 1);
674674      }
675
675     
676676      // draw one switch
677677      custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
678678      y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT);
r243230r243231
884884                  }
885885
886886                  name.cpy(field->name());
887
887                 
888888                  /* allocate a data item for tracking what this menu item refers to */
889889                  data = (analog_item_data *)m_pool_alloc(sizeof(*data));
890890                  data->field = field;
trunk/src/emu/ui/sliders.c
r243230r243231
242242UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state)
243243{
244244   UINT32 result;
245
245   
246246   /* if this is the first call, push the sliders menu */
247247   if (state)
248248      ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_sliders(machine, container, true)));
249
249   
250250   /* handle standard menus */
251251   result = ui_menu::ui_handler(machine, container, state);
252
252   
253253   /* if we are cancelled, pop the sliders menu */
254254   if (result == UI_HANDLER_CANCEL)
255255      ui_menu::stack_pop(machine);
256
256   
257257   ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack);
258258   return uim && uim->menuless_mode ? 0 : UI_HANDLER_CANCEL;
259259}
trunk/src/emu/ui/slotopt.h
r243230r243231
11/***************************************************************************
22
33    ui/slotopt.h
4
4
55    Internal menu for the slot options.
6
6
77    Copyright Nicola Salmoria and the MAME Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
99
trunk/src/emu/ui/tapectrl.c
r243230r243231
5656void ui_menu_tape_control::populate()
5757{
5858   if (current_device())
59   {
59   {     
6060      // name of tape
6161      item_append(current_display_name(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", current_display_flags(), TAPECMD_SELECT);
6262
r243230r243231
6767         double t0 = current_device()->get_position();
6868         double t1 = current_device()->get_length();
6969         UINT32 tapeflags = 0;
70
70         
7171         // state
7272         if (t1 > 0)
7373         {
r243230r243231
7676            if (t0 < t1)
7777               tapeflags |= MENU_FLAG_RIGHT_ARROW;
7878         }
79
79         
8080         get_time_string(timepos, current_device(), NULL, NULL);
8181         state = current_device()->get_state();
8282         item_append(
8383                  (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
8484                  ?   "stopped"
8585                  :   ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
86                        ? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
87                        : ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
88                        ),
86                      ? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
87                      : ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
88                      ),
8989                  timepos,
9090                  tapeflags,
9191                  TAPECMD_SLIDER);
92
92         
9393         // pause or stop
9494         item_append("Pause/Stop", NULL, 0, TAPECMD_STOP);
95
95         
9696         // play
9797         item_append("Play", NULL, 0, TAPECMD_PLAY);
98
98         
9999         // record
100100         item_append("Record", NULL, 0, TAPECMD_RECORD);
101
101         
102102         // rewind
103103         item_append("Rewind", NULL, 0, TAPECMD_REWIND);
104
104         
105105         // fast forward
106106         item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD);
107107      }
trunk/src/emu/video/h63484.c
r243230r243231
20012001void h63484_device::device_start()
20022002{
20032003   m_display_cb.bind_relative_to(*owner());
2004
2004   
20052005   register_save_state();
20062006}
20072007
trunk/src/emu/video/h63484.h
r243230r243231
107107   void video_registers_w(int offset);
108108   int translate_command(UINT16 data);
109109   void draw_graphics_line(bitmap_ind16 &bitmap, const rectangle &cliprect, int vs, int y, int layer_n, bool active, bool ins_window);
110
110   
111111   void register_save_state();
112112
113113   h63484_display_delegate  m_display_cb;
trunk/src/lib/util/coretmpl.h
r243230r243231
100100   void resize_keep_and_clear_new(int count, UINT8 data = 0) { int oldcount = m_count; resize_keep(count); if (oldcount < m_count) clear_internal(oldcount, m_count - oldcount, data); }
101101
102102   // batch operations
103   void copyfrom(const dynamic_array<_ElementType> &source)
104   {
105      resize(source.count());
106      for (int i=0; i < source.count(); i++)
107         m_array[i] = source[i];
108   }
103    void copyfrom(const dynamic_array<_ElementType> &source)
104    {
105        resize(source.count());
106        for (int i=0; i < source.count(); i++)
107            m_array[i] = source[i];
108    }
109109
110110private:
111111   // internal helpers
trunk/src/lib/util/palette.h
r243230r243231
171171   // entry list getters
172172   const rgb_t *entry_list_raw() const { return m_entry_color; }
173173   const dynamic_array<rgb_t> *entry_list_adjusted_darray() const { return &m_adjusted_color; }
174   const rgb_t *entry_list_adjusted() const { return m_adjusted_color; }
174    const rgb_t *entry_list_adjusted() const { return m_adjusted_color; }
175175   const rgb_t *entry_list_adjusted_rgb15() const { return m_adjusted_rgb15; }
176176
177177   // group adjustments
trunk/src/mame/audio/mario.c
r243230r243231
4646/* ---------------------------------------------------------------------- */
4747static NETLIST_START(nl_mario_snd0)
4848
49   RES(R17, RES_K(27))               /* 20 according to parts list           */
50                              /* 27 verified, 30K in schematics       */
51   CAP(C14, CAP_U(4.7))              /* verified                             */
49    RES(R17, RES_K(27))               /* 20 according to parts list           */
50                                      /* 27 verified, 30K in schematics       */
51    CAP(C14, CAP_U(4.7))              /* verified                             */
5252
53   TTL_74123(2H_A)
54   NET_C(2H_A.VCC, V5)
55   NET_C(2H_A.GND, GND)
56   NET_C(SOUND0.Q, 2H_A.B)
57   NET_C(GND, 2H_A.A)
58   NET_C(2H_A.CLRQ, ttlhigh)         /* NOT IN SCHEMATICS                    */
59   DIODE(D1, "1N4148")               /* FIXME: try to identify */
60   TTL_7404_INVERT(1H_A, 2H_A.QQ)
61   NET_C(R17.1, V5)
62   NET_C(R17.2, D1.A, C14.1)
63   NET_C(D1.K, 2H_A.RC)
64   NET_C(C14.2, 2H_A.C)
53    TTL_74123(2H_A)
54    NET_C(2H_A.VCC, V5)
55    NET_C(2H_A.GND, GND)
56    NET_C(SOUND0.Q, 2H_A.B)
57    NET_C(GND, 2H_A.A)
58    NET_C(2H_A.CLRQ, ttlhigh)         /* NOT IN SCHEMATICS                    */
59    DIODE(D1, "1N4148")               /* FIXME: try to identify */
60    TTL_7404_INVERT(1H_A, 2H_A.QQ)
61    NET_C(R17.1, V5)
62    NET_C(R17.2, D1.A, C14.1)
63    NET_C(D1.K, 2H_A.RC)
64    NET_C(C14.2, 2H_A.C)
6565
66   RES(R6, RES_K(4.7))               /* verified                             */
67   CAP(C3, CAP_U(10))                /* verified                             */
66    RES(R6, RES_K(4.7))               /* verified                             */
67    CAP(C3, CAP_U(10))                /* verified                             */
6868
69   NET_C(1H_A.Q, R6.1)
70   NET_C(R6.2, C3.1, 1J_A.FC)
71   NET_C(R6.2, 2J_A.FC)
72   NET_C(C3.2, GND)
69    NET_C(1H_A.Q, R6.1)
70    NET_C(R6.2, C3.1, 1J_A.FC)
71    NET_C(R6.2, 2J_A.FC)
72    NET_C(C3.2, GND)
7373
74   //#define MR_C6       CAP_N(3.9)        /* verified                           */
74    //#define MR_C6       CAP_N(3.9)        /* verified                           */
7575
76   SN74LS629(1J_A, CAP_N(3.9))
77   NET_C(1J_A.RNG, V5)
78   NET_C(1J_A.ENQ, ttllow)
79   NET_C(GND, 1J_A.GND)
76    SN74LS629(1J_A, CAP_N(3.9))
77    NET_C(1J_A.RNG, V5)
78    NET_C(1J_A.ENQ, ttllow)
79    NET_C(GND, 1J_A.GND)
8080
81   //#define MR_C17      CAP_N(22)        /* verified                            */
81    //#define MR_C17      CAP_N(22)        /* verified                            */
8282
83   SN74LS629(2J_A, CAP_N(22))
84   NET_C(2J_A.RNG, V5)
85   NET_C(2J_A.ENQ, ttllow)
86   NET_C(GND, 2J_A.GND)
83    SN74LS629(2J_A, CAP_N(22))
84    NET_C(2J_A.RNG, V5)
85    NET_C(2J_A.ENQ, ttllow)
86    NET_C(GND, 2J_A.GND)
8787
88   TTL_7486_XOR(1K_A, 1J_A.Y, 2J_A.Y)
89   TTL_7408_AND(2K_A, 2H_A.Q, 1K_A)
88    TTL_7486_XOR(1K_A, 1J_A.Y, 2J_A.Y)
89    TTL_7408_AND(2K_A, 2H_A.Q, 1K_A)
9090NETLIST_END()
9191
9292/* ---------------------------------------------------------------------- */
r243230r243231
9696// FIXME: Diodes are 1S953
9797static NETLIST_START(nl_mario_snd7)
9898
99   RES(R61, RES_K(47))
100   CAP(C41, CAP_U(4.7))              /* verified                             */
99    RES(R61, RES_K(47))
100    CAP(C41, CAP_U(4.7))              /* verified                             */
101101
102   TTL_74123(4L_A)
103   NET_C(4L_A.VCC, V5)
104   NET_C(4L_A.GND, GND)
105   NET_C(SOUND7.Q, 4L_A.B)
106   NET_C(GND, 4L_A.A)
107   NET_C(4L_A.CLRQ, ttlhigh)         /* NOT IN SCHEMATICS                    */
108   DIODE(D10, "1N4148")               /* FIXME: try to identify */
109   TTL_7404_INVERT(4J_A, 4L_A.Q)
110   NET_C(R61.1, V5)
111   NET_C(R61.2, D10.A, C41.1)
112   NET_C(D10.K, 4L_A.RC)
113   NET_C(C41.2, 4L_A.C)
102    TTL_74123(4L_A)
103    NET_C(4L_A.VCC, V5)
104    NET_C(4L_A.GND, GND)
105    NET_C(SOUND7.Q, 4L_A.B)
106    NET_C(GND, 4L_A.A)
107    NET_C(4L_A.CLRQ, ttlhigh)         /* NOT IN SCHEMATICS                    */
108    DIODE(D10, "1N4148")               /* FIXME: try to identify */
109    TTL_7404_INVERT(4J_A, 4L_A.Q)
110    NET_C(R61.1, V5)
111    NET_C(R61.2, D10.A, C41.1)
112    NET_C(D10.K, 4L_A.RC)
113    NET_C(C41.2, 4L_A.C)
114114
115   RES(R65, RES_K(10))
116   CAP(C44, CAP_U(3.3))              /* verified                             */
115    RES(R65, RES_K(10))
116    CAP(C44, CAP_U(3.3))              /* verified                             */
117117
118   SN74LS629(4K_A, CAP_U(0.022))
119   NET_C(4K_A.RNG, V5)
120   NET_C(4K_A.ENQ, ttllow)
121   NET_C(GND, 4K_A.GND)
122   NET_C(R65.1, 4J_A.Q)
123   NET_C(R65.2, 4K_A.FC, C44.1)
124   NET_C(C44.2, GND)
118    SN74LS629(4K_A, CAP_U(0.022))
119    NET_C(4K_A.RNG, V5)
120    NET_C(4K_A.ENQ, ttllow)
121    NET_C(GND, 4K_A.GND)
122    NET_C(R65.1, 4J_A.Q)
123    NET_C(R65.2, 4K_A.FC, C44.1)
124    NET_C(C44.2, GND)
125125
126   CD_4020(3H, 4K_B.Y, ttllow, V5, GND)
127   TTL_7404_INVERT(4J_B, 3H.Q12)
126    CD_4020(3H, 4K_B.Y, ttllow, V5, GND)
127    TTL_7404_INVERT(4J_B, 3H.Q12)
128128
129   RES(R64, RES_K(20))
130   CAP(C43, CAP_U(3.3))              /* verified                             */
129    RES(R64, RES_K(20))
130    CAP(C43, CAP_U(3.3))              /* verified                             */
131131
132   SN74LS629(4K_B, CAP_U(0.0047))
133   NET_C(4K_B.RNG, V5)
134   NET_C(4K_B.ENQ, ttllow)
135   NET_C(GND, 4K_B.GND)
136   NET_C(R64.1, 4J_B.Q)
137   NET_C(R64.2, 4K_B.FC, C43.1)
138   NET_C(C43.2, GND)
132    SN74LS629(4K_B, CAP_U(0.0047))
133    NET_C(4K_B.RNG, V5)
134    NET_C(4K_B.ENQ, ttllow)
135    NET_C(GND, 4K_B.GND)
136    NET_C(R64.1, 4J_B.Q)
137    NET_C(R64.2, 4K_B.FC, C43.1)
138    NET_C(C43.2, GND)
139139
140   TTL_7486_XOR(1K_C, 3H.Q4, 4K_A.Y)
141   TTL_7408_AND(2K_C, 4L_A.Q, 1K_C)
140    TTL_7486_XOR(1K_C, 3H.Q4, 4K_A.Y)
141    TTL_7408_AND(2K_C, 4L_A.Q, 1K_C)
142142
143143NETLIST_END()
144144
r243230r243231
146146/* DAC sound                                                            */
147147/* ---------------------------------------------------------------------- */
148148static NETLIST_START(nl_mario_dac)
149   RES(R34, RES_M(2))
150   RES(R35, RES_M(1))
151   RES(R36, RES_M(1.8))
152   LM3900(3M_1)
153   NET_C(3M_1.VM, GND)
154   NET_C(3M_1.VP, V5)
149    RES(R34, RES_M(2))
150    RES(R35, RES_M(1))
151    RES(R36, RES_M(1.8))
152    LM3900(3M_1)
153    NET_C(3M_1.VM, GND)
154    NET_C(3M_1.VP, V5)
155155
156   NET_C(DAC.VOUT, R34.1)
157   NET_C(3M_1.MINUS, R34.2, R35.2)
158   NET_C(3M_1.OUT, R35.1)
159   NET_C(3M_1.PLUS, R36.1)
160   NET_C(R36.2, GND)
156    NET_C(DAC.VOUT, R34.1)
157    NET_C(3M_1.MINUS, R34.2, R35.2)
158    NET_C(3M_1.OUT, R35.1)
159    NET_C(3M_1.PLUS, R36.1)
160    NET_C(R36.2, GND)
161161
162   RES(R21, RES_M(1.8))
163   RES(R23, RES_K(10))
164   RES(R25, RES_K(10))
165   RES(R37, RES_K(750))
166   RES(R38, RES_K(360))
167   RES(R39, RES_K(750))
162    RES(R21, RES_M(1.8))
163    RES(R23, RES_K(10))
164    RES(R25, RES_K(10))
165    RES(R37, RES_K(750))
166    RES(R38, RES_K(360))
167    RES(R39, RES_K(750))
168168
169   CAP(C18, CAP_P(100))
170   CAP(C19, CAP_U(10))
171   CAP(C20, CAP_U(1))
172   CAP(C30, CAP_P(100))
169    CAP(C18, CAP_P(100))
170    CAP(C19, CAP_U(10))
171    CAP(C20, CAP_U(1))
172    CAP(C30, CAP_P(100))
173173
174   LM3900(3M_2)
175   NET_C(3M_2.VM, GND)
176   NET_C(3M_2.VP, V5)
174    LM3900(3M_2)
175    NET_C(3M_2.VM, GND)
176    NET_C(3M_2.VP, V5)
177177
178   NET_C(R35.1, C20.1)
179   NET_C(C20.2, R37.1)
180   NET_C(R37.2, R38.2, C18.1, R39.2)
178    NET_C(R35.1, C20.1)
179    NET_C(C20.2, R37.1)
180    NET_C(R37.2, R38.2, C18.1, R39.2)
181181
182   NET_C(C18.2, GND)
183   NET_C(R38.1, C30.2, 3M_2.MINUS)
184   NET_C(3M_2.OUT, R39.1, C30.1)
182    NET_C(C18.2, GND)
183    NET_C(R38.1, C30.2, 3M_2.MINUS)
184    NET_C(3M_2.OUT, R39.1, C30.1)
185185
186   NET_C(R21.1, 3M_2.PLUS)
187   NET_C(R21.2, C19.1, R25.2, R23.1)
188   NET_C(C19.2, R23.2, GND)
189   NET_C(R25.1, V5)
186    NET_C(R21.1, 3M_2.PLUS)
187    NET_C(R21.2, C19.1, R25.2, R23.1)
188    NET_C(C19.2, R23.2, GND)
189    NET_C(R25.1, V5)
190190NETLIST_END()
191191
192192static NETLIST_START(nl_mario)
193193
194   /* Standard stuff */
194    /* Standard stuff */
195195
196   SOLVER(Solver, 48000)
197   PARAM(Solver.ACCURACY, 1e-8)
198   PARAM(Solver.SOR_FACTOR, 1.0)
199   PARAM(Solver.GS_THRESHOLD, 5)
200   PARAM(Solver.GS_LOOPS, 4)
201   //PARAM(Solver.LTE,     5e-2) // Default is not enough for paddle control
202   PARAM(Solver.DYNAMIC_TS,  0)
203   ANALOG_INPUT(V5, 5)
196    SOLVER(Solver, 48000)
197    PARAM(Solver.ACCURACY, 1e-8)
198    PARAM(Solver.SOR_FACTOR, 1.0)
199    PARAM(Solver.GS_THRESHOLD, 5)
200    PARAM(Solver.GS_LOOPS, 4)
201    //PARAM(Solver.LTE,     5e-2) // Default is not enough for paddle control
202    PARAM(Solver.DYNAMIC_TS,  0)
203    ANALOG_INPUT(V5, 5)
204204
205   TTL_INPUT(SOUND0, 1)
206   INCLUDE(nl_mario_snd0)
205    TTL_INPUT(SOUND0, 1)
206    INCLUDE(nl_mario_snd0)
207207
208   TTL_INPUT(SOUND7, 1)
209   INCLUDE(nl_mario_snd7)
208    TTL_INPUT(SOUND7, 1)
209    INCLUDE(nl_mario_snd7)
210210
211   R2R_DAC(DAC, 3.4, 10000.0, 8)
212   NET_C(DAC.VGND, GND)
211    R2R_DAC(DAC, 3.4, 10000.0, 8)
212    NET_C(DAC.VGND, GND)
213213
214   INCLUDE(nl_mario_dac)
214    INCLUDE(nl_mario_dac)
215215
216   /* ---------------------------------------------------------------------- */
217   /* mixing                                                                 */
218   /* ---------------------------------------------------------------------- */
216    /* ---------------------------------------------------------------------- */
217    /* mixing                                                                 */
218    /* ---------------------------------------------------------------------- */
219219
220   RES(R20, RES_K(22))               /* verified                             */
221   RES(R19, RES_K(22))               /* verified                             */
222   RES(R40, RES_K(22))               /* verified                             */
223   RES(R41, RES_K(100))              /* verified                             */
224   CAP(C31, CAP_U(0.022))            /*                             */
220    RES(R20, RES_K(22))               /* verified                             */
221    RES(R19, RES_K(22))               /* verified                             */
222    RES(R40, RES_K(22))               /* verified                             */
223    RES(R41, RES_K(100))              /* verified                             */
224    CAP(C31, CAP_U(0.022))            /*                             */
225225
226   NET_C(2K_A.Q, R20.1)
227   NET_C(GND, R19.1) //FIXME
228   NET_C(2K_C.Q, R41.1)
226    NET_C(2K_A.Q, R20.1)
227    NET_C(GND, R19.1) //FIXME
228    NET_C(2K_C.Q, R41.1)
229229
230230#if 1
231   RES(DUM, RES_K(22))
232   NET_C(R39.1, DUM.1)
233   NET_C(DUM.2, GND)
234   FRONTIER(front1, R39.1, R40.1)
231    RES(DUM, RES_K(22))
232    NET_C(R39.1, DUM.1)
233    NET_C(DUM.2, GND)
234    FRONTIER(front1, R39.1, R40.1)
235235#else
236   NET_C(R39.1, R40.1)
236    NET_C(R39.1, R40.1)
237237#endif
238238
239   NET_C(R20.2, R19.2, R40.2, R41.2, C31.1)
240   NET_C(C31.2, GND)
239    NET_C(R20.2, R19.2, R40.2, R41.2, C31.1)
240    NET_C(C31.2, GND)
241241
242   CAP(C32, CAP_U(1))                /* verified                             */
243   RES(R42, RES_K(43))               /* verified                             */
244   RES(R43, RES_K(100))              /* verified                             */
242    CAP(C32, CAP_U(1))                /* verified                             */
243    RES(R42, RES_K(43))               /* verified                             */
244    RES(R43, RES_K(100))              /* verified                             */
245245
246   NET_C(C31.1, C32.1)
247   NET_C(C32.2, R42.1, R43.2, Q10.B)
248   //NET_C(C32.2, R42.1, R43.2)
249   NET_C(R43.1, V5)
250   NET_C(R42.2, GND)
246    NET_C(C31.1, C32.1)
247    NET_C(C32.2, R42.1, R43.2, Q10.B)
248    //NET_C(C32.2, R42.1, R43.2)
249    NET_C(R43.1, V5)
250    NET_C(R42.2, GND)
251251#if 1
252   RES(R63, RES_K(1))                /*                                      */
253   RES(R62, 150)                     /*                                      */
252    RES(R63, RES_K(1))                /*                                      */
253    RES(R62, 150)                     /*                                      */
254254
255   QBJT_EB(Q10, "2SC1815")
255    QBJT_EB(Q10, "2SC1815")
256256
257   NET_C(R62.2, GND)
258   NET_C(R62.1, Q10.E)
257    NET_C(R62.2, GND)
258    NET_C(R62.1, Q10.E)
259259
260   NET_C(R63.1, V5)
261   NET_C(R63.2, Q10.C)
260    NET_C(R63.1, V5)
261    NET_C(R63.2, Q10.C)
262262
263   CAP(C42, CAP_U(0.1))
264   CAP(C47, CAP_U(4.7))
265   RES(VR1, RES_K(10))
263    CAP(C42, CAP_U(0.1))
264    CAP(C47, CAP_U(4.7))
265    RES(VR1, RES_K(10))
266266
267   NET_C(C42.1, C47.1, R62.1)
268   NET_C(C42.2, GND)
269   NET_C(C47.2, VR1.1)
270   NET_C(VR1.2, GND)
267    NET_C(C42.1, C47.1, R62.1)
268    NET_C(C42.2, GND)
269    NET_C(C47.2, VR1.1)
270    NET_C(VR1.2, GND)
271271#endif
272   /* ---------------------------------------------------------------------- */
273   /* Output                                                                 */
274   /* ---------------------------------------------------------------------- */
272    /* ---------------------------------------------------------------------- */
273    /* Output                                                                 */
274    /* ---------------------------------------------------------------------- */
275275
276   RES(ROUT, 1000000)
276    RES(ROUT, 1000000)
277277
278   //NET_C(Q10.C, ROUT.1)
279   //NET_C(R43.2, ROUT.1)
280   NET_C(VR1.1, ROUT.1)
278    //NET_C(Q10.C, ROUT.1)
279    //NET_C(R43.2, ROUT.1)
280    NET_C(VR1.1, ROUT.1)
281281
282   NET_C(GND, ROUT.2)
282    NET_C(GND, ROUT.2)
283283
284284NETLIST_END()
285285
r243230r243231
790790#if OLD_SOUND
791791   m_discrete->write(space, DS_SOUND0_INP, 0);
792792#else
793   m_audio_snd0->write(data);
793    m_audio_snd0->write(data);
794794#endif
795795}
796796
r243230r243231
835835#if OLD_SOUND
836836         machine().device<discrete_device>("discrete")->write(space, DS_SOUND7_INP, data & 1);
837837#else
838         m_audio_snd7->write((data & 1) ^ 1);
838          m_audio_snd7->write((data & 1) ^ 1);
839839#endif
840840         break;
841841   }
r243230r243231
891891   MCFG_DISCRETE_INTF(mario)
892892   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1)
893893#else
894   MCFG_SOUND_ADD("snd_nl", NETLIST_SOUND, 48000)
895   MCFG_NETLIST_SETUP(nl_mario)
896   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
894    MCFG_SOUND_ADD("snd_nl", NETLIST_SOUND, 48000)
895    MCFG_NETLIST_SETUP(nl_mario)
896    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
897897
898   MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd0", "SOUND0.IN", 0, 1)
899   MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd7", "SOUND7.IN", 0, 1)
900   MCFG_NETLIST_LOGIC_INPUT("snd_nl", "dac", "DAC.VAL", 0, 255)
898    MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd0", "SOUND0.IN", 0, 1)
899    MCFG_NETLIST_LOGIC_INPUT("snd_nl", "snd7", "SOUND7.IN", 0, 1)
900    MCFG_NETLIST_LOGIC_INPUT("snd_nl", "dac", "DAC.VAL", 0, 255)
901901
902   MCFG_NETLIST_STREAM_OUTPUT("snd_nl", 0, "ROUT.1")
903   MCFG_NETLIST_ANALOG_MULT_OFFSET(150000.0, 0.0)
902    MCFG_NETLIST_STREAM_OUTPUT("snd_nl", 0, "ROUT.1")
903    MCFG_NETLIST_ANALOG_MULT_OFFSET(150000.0, 0.0)
904904#endif
905905
906906MACHINE_CONFIG_END
trunk/src/mame/audio/seibu.c
r243230r243231
229229   update_irq_lines(RST18_CLEAR);
230230}
231231
232WRITE_LINE_MEMBER( seibu_sound_device::fm_irqhandler )
232void seibu_sound_device::ym3812_irqhandler(int linestate)
233233{
234   update_irq_lines(linestate ? RST10_ASSERT : RST10_CLEAR);
235}
236
237WRITE_LINE_MEMBER( seibu_sound_device::ym2151_irqhandler )
238{
234239   update_irq_lines(state ? RST10_ASSERT : RST10_CLEAR);
235240}
236241
242void seibu_sound_device::ym2203_irqhandler(int linestate)
243{
244   update_irq_lines(linestate ? RST10_ASSERT : RST10_CLEAR);
245}
246
237247WRITE8_MEMBER( seibu_sound_device::bank_w )
238248{
239249   space.machine().root_device().membank("bank1")->set_entry(data & 1);
trunk/src/mame/audio/seibu.h
r243230r243231
4545
4646   DECLARE_READ16_MEMBER( main_word_r );
4747   DECLARE_WRITE16_MEMBER( main_word_w );
48
4849   DECLARE_WRITE16_MEMBER( main_mustb_w );
50
4951   DECLARE_WRITE8_MEMBER( irq_clear_w );
5052   DECLARE_WRITE8_MEMBER( rst10_ack_w );
5153   DECLARE_WRITE8_MEMBER( rst18_ack_w );
5254   DECLARE_WRITE8_MEMBER( bank_w );
5355   DECLARE_WRITE8_MEMBER( coin_w );
54   WRITE_LINE_MEMBER( fm_irqhandler );
56   void ym3812_irqhandler(int linestate);
57   WRITE_LINE_MEMBER(ym2151_irqhandler);
58   void ym2203_irqhandler(int linestate);
5559   DECLARE_READ8_MEMBER( soundlatch_r );
5660   DECLARE_READ8_MEMBER( main_data_pending_r );
5761   DECLARE_WRITE8_MEMBER( main_data_w );
r243230r243231
189193#define SEIBU_SOUND_SYSTEM_YM3812_INTERFACE(freq1,freq2)            \
190194   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
191195                                                   \
192   MCFG_SOUND_ADD("ymsnd", YM3812, freq1)                          \
193   MCFG_YM3812_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler)) \
196   MCFG_SOUND_ADD("ymsnd", YM3812, freq1)                              \
197   MCFG_YM3812_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym3812_irqhandler)) \
194198   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)                      \
195199                                                   \
196200   MCFG_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_LOW)              \
r243230r243231
199203#define SEIBU_SOUND_SYSTEM_YM3812_RAIDEN_INTERFACE(freq1,freq2)     \
200204   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
201205                                                   \
202   MCFG_SOUND_ADD("ymsnd", YM3812, freq1)                          \
203   MCFG_YM3812_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler)) \
206   MCFG_SOUND_ADD("ymsnd", YM3812, freq1)                              \
207   MCFG_YM3812_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym3812_irqhandler)) \
204208   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)                      \
205209                                                   \
206210   MCFG_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_HIGH)             \
r243230r243231
209213#define SEIBU_SOUND_SYSTEM_YM2151_INTERFACE(freq1,freq2)            \
210214   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
211215                                                   \
212   MCFG_YM2151_ADD("ymsnd", freq1)                                 \
213   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler)) \
216   MCFG_YM2151_ADD("ymsnd", freq1)                             \
217   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler)) \
214218   MCFG_SOUND_ROUTE(0, "mono", 0.50)                               \
215219   MCFG_SOUND_ROUTE(1, "mono", 0.50)                               \
216220                                                   \
r243230r243231
220224#define SEIBU_AIRRAID_SOUND_SYSTEM_YM2151_INTERFACE(freq1)          \
221225   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
222226                                                   \
223   MCFG_YM2151_ADD("ymsnd", freq1)                                 \
224   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler)) \
227   MCFG_YM2151_ADD("ymsnd", freq1)                             \
228   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler)) \
225229   MCFG_SOUND_ROUTE(0, "mono", 0.50)                               \
226230   MCFG_SOUND_ROUTE(1, "mono", 0.50)
227231
228#define SEIBU_SOUND_SYSTEM_YM2151_RAIDEN2_INTERFACE(freq1, freq2, regiona, regionb) \
232#define SEIBU_SOUND_SYSTEM_YM2151_RAIDEN2_INTERFACE(freq1,freq2,regiona, regionb)      \
229233   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
230234                                                   \
231   MCFG_YM2151_ADD("ymsnd", freq1)                                 \
232   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler)) \
235   MCFG_YM2151_ADD("ymsnd", freq1)                             \
236   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler)) \
233237   MCFG_SOUND_ROUTE(0, "mono", 0.50)                               \
234238   MCFG_SOUND_ROUTE(1, "mono", 0.50)                               \
235239                                                   \
r243230r243231
243247   MCFG_SPEAKER_STANDARD_MONO("mono")                              \
244248                                                   \
245249   MCFG_SOUND_ADD("ym1", YM2203, freq)                             \
246   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler)) \
250   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2203_irqhandler)) \
247251   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)                     \
248252                                                   \
249253   MCFG_SOUND_ADD("ym2", YM2203, freq)                             \
r243230r243231
251255
252256#define SEIBU_SOUND_SYSTEM_ADPCM_INTERFACE                          \
253257   MCFG_SOUND_ADD("adpcm1", SEIBU_ADPCM, 8000)                     \
254   MCFG_SEIBU_ADPCM_ROMREGION("adpcm1")                            \
258   MCFG_SEIBU_ADPCM_ROMREGION("adpcm1")                      \
255259   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)                     \
256260                                                   \
257261   MCFG_SOUND_ADD("adpcm2", SEIBU_ADPCM, 8000)                     \
258   MCFG_SEIBU_ADPCM_ROMREGION("adpcm2")                            \
262   MCFG_SEIBU_ADPCM_ROMREGION("adpcm2")                      \
259263   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
260264
261265/**************************************************************************/
trunk/src/mame/drivers/aleck64.c
r243230r243231
178178public:
179179   aleck64_state(const machine_config &mconfig, device_type type, const char *tag)
180180      : n64_state(mconfig, type, tag),
181         m_e90_vram(*this,"e90vram"),
182         m_e90_pal(*this,"e90pal"),
181        m_e90_vram(*this,"e90vram"),
182        m_e90_pal(*this,"e90pal"),
183183         m_dip_read_offset(0) { }
184184
185185   optional_shared_ptr<UINT32> m_e90_vram;
r243230r243231
322322ADDRESS_MAP_END
323323
324324/*
325 E90 protection handlers
325 E90 protection handlers
326326*/
327327
328328READ16_MEMBER(aleck64_state::e90_prot_r)
r243230r243231
332332}
333333
334334WRITE16_MEMBER(aleck64_state::e90_prot_w)
335{
335{   
336336   switch(offset*2)
337337   {
338338      case 0x16:
r243230r243231
342342         if(data & 1) // 0 -> 1 transition
343343         {
344344            //for(int i=0;i<0x1000;i+=4)
345            //  space.write_dword(0x007502f4+i,space.read_dword(0xd0000000+i));
345            //   space.write_dword(0x007502f4+i,space.read_dword(0xd0000000+i));
346346         }
347347         break;
348348      //0x1e bit 0 probably enables the chip
r243230r243231
882882{
883883   bitmap.fill(0, cliprect);
884884   screen_update_n64(screen,bitmap,cliprect);
885
885   
886886   for(int offs=0;offs<0x1000/4;offs+=2)
887887   {
888888      int xi,yi;
r243230r243231
904904      r&=0x1f;
905905      g&=0x1f;
906906      b&=0x1f;
907      r = (r << 3) | (r >> 2);
907      r = (r << 3) | (r >> 2);
908908      g = (g << 3) | (g >> 2);
909      b = (b << 3) | (b >> 2);
909      b = (b << 3) | (b >> 2);
910910      for(yi=0;yi<8;yi++)
911911         for(xi=0;xi<8;xi++)
912912         {
913913            int res_x,res_y;
914914            res_x = x+xi + 4;
915915            res_y = y+yi + 7;
916
916           
917917            if(cliprect.contains(res_x, res_y))
918918               bitmap.pix32(res_y, res_x) = r << 16 | g << 8 | b;
919919         }
r243230r243231
926926   MCFG_CPU_PROGRAM_MAP(e90_map)
927927
928928   MCFG_SCREEN_MODIFY("screen")
929   MCFG_SCREEN_UPDATE_DRIVER(aleck64_state, screen_update_e90)
929   MCFG_SCREEN_UPDATE_DRIVER(aleck64_state, screen_update_e90)   
930930MACHINE_CONFIG_END
931931
932932DRIVER_INIT_MEMBER(aleck64_state,aleck64)
trunk/src/mame/drivers/backfire.c
r243230r243231
106106   required_ioport m_io_in3;
107107   required_device<palette_device> m_palette;
108108   required_shared_ptr<UINT32> m_generic_paletteram_32;
109   DECLARE_WRITE_LINE_MEMBER(sound_irq_gen);
109110};
110111
111112//UINT32 *backfire_180010, *backfire_188010;
r243230r243231
438439GFXDECODE_END
439440
440441
442WRITE_LINE_MEMBER(backfire_state::sound_irq_gen)
443{
444   logerror("sound irq\n");
445}
446
441447INTERRUPT_GEN_MEMBER(backfire_state::deco32_vbl_interrupt)
442448{
443449   device.execute().set_input_line(ARM_IRQ_LINE, HOLD_LINE);
r243230r243231
553559   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
554560
555561   MCFG_SOUND_ADD("ymz", YMZ280B, 28000000 / 2)
562   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(backfire_state, sound_irq_gen))
556563   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
557564   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
558565MACHINE_CONFIG_END
trunk/src/mame/drivers/bfm_sc4h.c
r243230r243231
610610}
611611
612612
613WRITE_LINE_MEMBER(sc4_state::bfm_sc4_irqhandler)
614{
615   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
616}
617
618
619
613620WRITE_LINE_MEMBER(sc4_state::bfm_sc4_duart_irq_handler)
614621{
615622   // triggers after reel tests on luckb, at the start on dnd...
r243230r243231
702709//  MCFG_DEFAULT_LAYOUT(layout_bfm_sc4)
703710
704711   MCFG_SOUND_ADD("ymz", YMZ280B, 16000000) // ?? Mhz
712   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(sc4_state, bfm_sc4_irqhandler))
705713   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
706714MACHINE_CONFIG_END
707715
trunk/src/mame/drivers/bfm_sc5.c
r243230r243231
186186}
187187
188188
189
190WRITE_LINE_MEMBER(bfm_sc5_state::bfm_sc5_ym_irqhandler)
191{
192   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
193}
194
195
196
189197WRITE_LINE_MEMBER(bfm_sc5_state::bfm_sc5_duart_irq_handler)
190198{
191199   printf("bfm_sc5_duart_irq_handler\n");
r243230r243231
227235   MCFG_DEFAULT_LAYOUT(layout_bfm_sc5)
228236
229237   MCFG_SOUND_ADD("ymz", YMZ280B, 16000000) // ?? Mhz
238   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(bfm_sc5_state, bfm_sc5_ym_irqhandler))
230239   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
231240MACHINE_CONFIG_END
trunk/src/mame/drivers/bfm_swp.c
r243230r243231
122122   {
123123      return 0;
124124   }
125   DECLARE_WRITE_LINE_MEMBER(irqhandler);
125126
126127protected:
127128
r243230r243231
131132   virtual void machine_start();
132133};
133134
135
136WRITE_LINE_MEMBER(bfm_swp_state::irqhandler)
137{
138}
139
140
134141READ32_MEMBER(bfm_swp_state::bfm_swp_mem_r)
135142{
136143   int pc = space.device().safe_pc();
r243230r243231
211218   MCFG_SPEAKER_STANDARD_MONO("mono")
212219
213220   MCFG_SOUND_ADD("ymz", YMZ280B, 10000000 )
221   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(bfm_swp_state, irqhandler))
214222   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
215223MACHINE_CONFIG_END
216224
trunk/src/mame/drivers/bishi.c
r243230r243231
357357INPUT_PORTS_END
358358
359359
360WRITE_LINE_MEMBER(bishi_state::sound_irq_gen)
361{
362   m_maincpu->set_input_line(M68K_IRQ_1, (state) ? ASSERT_LINE : CLEAR_LINE);
363}
364
365
360366void bishi_state::machine_start()
361367{
362368   save_item(NAME(m_cur_control));
r243230r243231
407413   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
408414
409415   MCFG_SOUND_ADD("ymz", YMZ280B, SOUND_CLOCK) /* 16.9344MHz */
410   MCFG_YMZ280B_IRQ_HANDLER(INPUTLINE("maincpu", M68K_IRQ_1))
416   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(bishi_state, sound_irq_gen))
411417   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
412418   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
413419MACHINE_CONFIG_END
trunk/src/mame/drivers/btime.c
r243230r243231
19401940   ROM_LOAD( "w3-f.4a",     0xc000, 0x1000, CRC(9aadd252) SHA1(c6da7ef46333d525e676c59f03ccc908108b41ba) )
19411941   ROM_LOAD( "w2-f.6a",     0xd000, 0x1000, CRC(f131a5bb) SHA1(84b7dea112dce12e5cb235a13f6dc4edcfb18c06) )
19421942   ROM_LOAD( "w1-f.9a",     0xe000, 0x1000, CRC(a6ce9a19) SHA1(e8f380e17a21fb33504d6efe9d01d0f903fa25e1) )
1943//  ROM_LOAD( "w1-f",        0xe000, 0x1000, CRC(c8ec57c5) SHA1(904a9ed0a7f1230c611bf473b9bc52e63eb56dbe) ) // 0x7d3 is 0x10 instead of 0x00, 1 bit different, looks out of place, bad?
1943//   ROM_LOAD( "w1-f",        0xe000, 0x1000, CRC(c8ec57c5) SHA1(904a9ed0a7f1230c611bf473b9bc52e63eb56dbe) ) // 0x7d3 is 0x10 instead of 0x00, 1 bit different, looks out of place, bad?
19441944   ROM_LOAD( "w0-f.9a",     0xf000, 0x1000, CRC(b3787a92) SHA1(7f40621dc739c1108a5df43142ab04709a380219) )
19451945
19461946   ROM_REGION( 0x10000, "audiocpu", 0 )
trunk/src/mame/drivers/cabal.c
r243230r243231
484484   MCFG_SPEAKER_STANDARD_MONO("mono")
485485
486486   MCFG_YM2151_ADD("ymsnd", XTAL_3_579545MHz) /* verified on pcb */
487   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler))
487   MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2151_irqhandler))
488488   MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.80)
489489
490490   MCFG_SOUND_ADD("adpcm1", SEIBU_ADPCM, 8000) /* it should use the msm5205 */
trunk/src/mame/drivers/calomega.c
r243230r243231
36583658DRIVER_INIT_MEMBER(calomega_state,comg080)
36593659{
36603660   DRIVER_INIT_CALL(sys903);
3661
3661   
36623662   /* Injecting missing Start and NMI vectors...
36633663      Start = $2042;  NMI = $26f8;
36643664      Also a fake vector at $3ff8-$3ff9. The code checks these values to continue.
trunk/src/mame/drivers/cps1.c
r243230r243231
93229322   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
93239323   ROM_LOAD16_WORD_SWAP("q5 - 34_90629b.8f", 0x00000, 0x80000, CRC(de54487f) SHA1(75b228a6c702c82d4d9a2a992933b5c3c420f6c2) )
93249324   ROM_LOAD16_WORD_SWAP("q5 - 33_90629b.6f", 0x80000, 0x80000, CRC(93248458) SHA1(9dcdc6838f52efc9a0a6333fd0d734946db12dbd) )
9325
9325   
93269326   ROM_REGION( 0x200000, "gfx", 0 )
93279327   ROMX_LOAD( "q5 - 06_90629b.8a",  0x000000, 0x80000, CRC(09d0e7ce) SHA1(ea502b975986222acce82ce8396348af72e1df72) , ROM_GROUPWORD | ROM_SKIP(6) )
93289328   ROMX_LOAD( "q5 - 08_90629b.10a", 0x000002, 0x80000, CRC(22e4ce9a) SHA1(9e49aec8e1d6d15a68da63e69765b82fd53a9562) , ROM_GROUPWORD | ROM_SKIP(6) )
trunk/src/mame/drivers/ddenlovr.c
r243230r243231
154154      : dynax_state(mconfig, type, tag),
155155      m_dsw_sel16(*this, "dsw_sel16"),
156156      m_protection1(*this, "protection1"),
157      m_protection2(*this, "protection2") { }
157      m_protection2(*this, "protection2")   { }
158     
158159
159
160160   optional_shared_ptr<UINT16> m_dsw_sel16;
161161   optional_shared_ptr<UINT16> m_protection1;
162162   optional_shared_ptr<UINT16> m_protection2;
trunk/src/mame/drivers/dec0.c
r243230r243231
530530{
531531   save_item(NAME(m_automat_adpcm_byte));
532532   save_item(NAME(m_automat_msm5205_vclk_toggle));
533   save_item(NAME(m_automat_scroll_regs));
533   save_item(NAME(m_automat_scroll_regs));   
534534}
535535
536536
trunk/src/mame/drivers/deco156.c
r243230r243231
6666   UINT32 screen_update_wcvol95(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
6767   INTERRUPT_GEN_MEMBER(deco32_vbl_interrupt);
6868   void descramble_sound( const char *tag );
69   DECLARE_WRITE_LINE_MEMBER(sound_irq_gen);
6970   DECO16IC_BANK_CB_MEMBER(bank_callback);
7071   DECOSPR_PRIORITY_CB_MEMBER(pri_callback);
7172};
r243230r243231
314315
315316/**********************************************************************************/
316317
318WRITE_LINE_MEMBER(deco156_state::sound_irq_gen)
319{
320   logerror("sound irq\n");
321}
322
317323INTERRUPT_GEN_MEMBER(deco156_state::deco32_vbl_interrupt)
318324{
319325   device.execute().set_input_line(ARM_IRQ_LINE, HOLD_LINE);
r243230r243231
435441   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
436442
437443   MCFG_SOUND_ADD("ymz", YMZ280B, 28000000 / 2)
444   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(deco156_state, sound_irq_gen))
438445   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
439446   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
440447MACHINE_CONFIG_END
trunk/src/mame/drivers/dgpix.c
r243230r243231
164164
165165   required_device<cpu_device> m_maincpu;
166166   required_ioport m_vblank;
167
167   
168168   UINT32 *m_vram;
169169   int m_vbuffer;
170170   int m_flash_roms;
171171   int m_old_vbuf;
172172   UINT32 m_flash_cmd;
173173   INT32 m_first_offset;
174
174   
175175   DECLARE_READ32_MEMBER(flash_r);
176176   DECLARE_WRITE32_MEMBER(flash_w);
177177   DECLARE_WRITE32_MEMBER(vram_w);
r243230r243231
179179   DECLARE_WRITE32_MEMBER(vbuffer_w);
180180   DECLARE_WRITE32_MEMBER(coin_w);
181181   DECLARE_READ32_MEMBER(vblank_r);
182
182   
183183   DECLARE_DRIVER_INIT(elfin);
184184   DECLARE_DRIVER_INIT(jumpjump);
185185   DECLARE_DRIVER_INIT(xfiles);
186186   DECLARE_DRIVER_INIT(xfilesk);
187187   DECLARE_DRIVER_INIT(kdynastg);
188188   DECLARE_DRIVER_INIT(fmaniac3);
189
189   
190190   virtual void machine_start();
191191   virtual void machine_reset();
192192   virtual void video_start();
193
193   
194194   UINT32 screen_update_dgpix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
195195};
196196
trunk/src/mame/drivers/dkong.c
r243230r243231
341341
342342    That kit included the following 4 EPROM's
343343
344    USA (c) 1981 Nintendo of America set
344    USA (c) 1981 Nintendo of America set
345345    ------------------------------------
346346
347347    Filename Label Type Loc/PCB *Label *Loc/PCB CSum
trunk/src/mame/drivers/dynax.c
r243230r243231
43784378
43794379   membank("bank1")->configure_entries(0, 0x10, &MAIN[0x8000],  0x8000);
43804380   membank("bank2")->configure_entries(0, 12,   &SOUND[0x8000], 0x8000);
4381
4381   
43824382   MACHINE_START_CALL_MEMBER(dynax);
43834383}
43844384
trunk/src/mame/drivers/eolith.c
r243230r243231
14941494
14951495   // Configure the sound ROM banking
14961496   membank("sound_bank")->configure_entries(0, 16, memregion("sounddata")->base(), 0x8000);
1497
1497   
14981498   save_item(NAME(m_sound_data));
14991499}
15001500
trunk/src/mame/drivers/eolith16.c
r243230r243231
2525
2626   UINT16 *m_vram;
2727   int m_vbuffer;
28
28   
2929   DECLARE_WRITE16_MEMBER(eeprom_w);
3030   DECLARE_READ16_MEMBER(eolith16_custom_r);
3131   DECLARE_WRITE16_MEMBER(vram_w);
3232   DECLARE_READ16_MEMBER(vram_r);
33
33   
3434   DECLARE_DRIVER_INIT(eolith16);
3535   DECLARE_VIDEO_START(eolith16);
3636   DECLARE_PALETTE_INIT(eolith16);
37
37   
3838   UINT32 screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939};
4040
trunk/src/mame/drivers/eolithsp.c
r243230r243231
8484      }
8585      n_game++;
8686   }
87
87   
8888   save_item(NAME(m_speedup_vblank));
8989   save_item(NAME(m_speedup_scanline));
9090}
trunk/src/mame/drivers/exidy.c
r243230r243231
187187WRITE8_MEMBER(exidy_state::fax_bank_select_w)
188188{
189189   membank("bank1")->set_entry(data & 0x1f);
190
190   
191191   if ((data & 0x1f) > 0x17)
192192      logerror("Banking to unpopulated ROM bank %02X!\n", data & 0x1f);
193
193   
194194}
195195
196196
trunk/src/mame/drivers/funkball.c
r243230r243231
356356static ADDRESS_MAP_START( flashbank_map, AS_PROGRAM, 32, funkball_state )
357357   AM_RANGE(0x00000000, 0x003fffff) AM_DEVREADWRITE16("u29", intel_28f320j5_device, read, write, 0xffffffff ) // needed to boot
358358   AM_RANGE(0x00400000, 0x007fffff) AM_DEVREADWRITE16("u30", intel_28f320j5_device, read, write, 0xffffffff ) // i assume it maps directly after
359//  AM_RANGE(0x02000000, 0x023fffff) AM_DEVREADWRITE16("u3", intel_28f320j5_device, read, write, 0xffffffff ) // sound program, don't think it matters where we map it, might not even be visible in this space
359//   AM_RANGE(0x02000000, 0x023fffff) AM_DEVREADWRITE16("u3", intel_28f320j5_device, read, write, 0xffffffff ) // sound program, don't think it matters where we map it, might not even be visible in this space
360360   /* it checks for 64MBit chips at 0x80000000 the way things are set up, they must return an intel Flash ID of 0x15 */
361361ADDRESS_MAP_END
362362
trunk/src/mame/drivers/galaxian.c
r243230r243231
14991499   AM_RANGE(0x1200, 0x12ff) AM_MIRROR(0x0100) AM_RAM_WRITE(galaxian_objram_w) AM_SHARE("spriteram")
15001500   AM_RANGE(0x1400, 0x1400) AM_MIRROR(0x03ff) AM_READ(watchdog_reset_r)
15011501   AM_RANGE(0x4000, 0xbfff) AM_ROM
1502//  AM_RANGE(0xc000, 0xc003) AM_MIRROR(0x3efc) AM_DEVREADWRITE("ppi8255_1", i8255_device, read, write)
1503//  AM_RANGE(0xc100, 0xc103) AM_MIRROR(0x3efc) AM_DEVREADWRITE("ppi8255_0", i8255_device, read, write)
1502//   AM_RANGE(0xc000, 0xc003) AM_MIRROR(0x3efc) AM_DEVREADWRITE("ppi8255_1", i8255_device, read, write)
1503//   AM_RANGE(0xc100, 0xc103) AM_MIRROR(0x3efc) AM_DEVREADWRITE("ppi8255_0", i8255_device, read, write)
15041504ADDRESS_MAP_END
15051505
15061506static ADDRESS_MAP_START( anteaterg_map, AS_PROGRAM, 8, galaxian_state )
trunk/src/mame/drivers/gticlub.c
r243230r243231
281281   optional_device<k001006_device> m_k001006_2;
282282   optional_device<k001604_device> m_k001604_1;
283283   optional_device<k001604_device> m_k001604_2;
284
284   
285285   required_shared_ptr<UINT32> m_work_ram;
286286   required_shared_ptr<UINT32> m_generic_paletteram_32;
287
287   
288288   optional_ioport m_analog0, m_analog1, m_analog2, m_analog3;
289
289   
290290   required_ioport_array<4> m_ports;
291
291   
292292   DECLARE_IOPORT_ARRAY(ports);
293293
294294   DECLARE_WRITE32_MEMBER(paletteram32_w);
trunk/src/mame/drivers/gts80a.c
r243230r243231
427427ADDRESS_MAP_END
428428
429429static ADDRESS_MAP_START( video_io_map, AS_IO, 8, caveman_state )
430//  AM_RANGE(0x000, 0x002) AM_READWRITE() // 8259 irq controller
431//  AM_RANGE(0x100, 0x102) AM_READWRITE() // HD46505
432//  AM_RANGE(0x200, 0x200) AM_READWRITE() // 8212 in, ?? out
433//  AM_RANGE(0x300, 0x300) AM_READWRITE() // soundlatch (command?) in, ?? out
430//   AM_RANGE(0x000, 0x002) AM_READWRITE() // 8259 irq controller
431//   AM_RANGE(0x100, 0x102) AM_READWRITE() // HD46505
432//   AM_RANGE(0x200, 0x200) AM_READWRITE() // 8212 in, ?? out
433//   AM_RANGE(0x300, 0x300) AM_READWRITE() // soundlatch (command?) in, ?? out
434434
435//  AM_RANGE(0x400, 0x400) AM_READ() // joystick inputs
436//  AM_RANGE(0x500, 0x506) AM_WRITE() // palette
435//   AM_RANGE(0x400, 0x400) AM_READ() // joystick inputs
436//   AM_RANGE(0x500, 0x506) AM_WRITE() // palette
437437
438438ADDRESS_MAP_END
439439
trunk/src/mame/drivers/gumbo.c
r243230r243231
229229
230230static MACHINE_CONFIG_START( gumbo, gumbo_state )
231231
232   MCFG_CPU_ADD("maincpu", M68000, XTAL_14_31818MHz/2)
232   MCFG_CPU_ADD("maincpu", M68000, 14318180 /2)     // or 10mhz? ?
233233   MCFG_CPU_PROGRAM_MAP(gumbo_map)
234234   MCFG_CPU_VBLANK_INT_DRIVER("screen", gumbo_state,  irq1_line_hold) // all the same
235235
r243230r243231
248248
249249   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
250250
251   MCFG_OKIM6295_ADD("oki", XTAL_14_31818MHz/16, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified
251   MCFG_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified
252252   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47)
253253   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47)
254254MACHINE_CONFIG_END
trunk/src/mame/drivers/gunpey.c
r243230r243231
263263
264264   int write_dest_byte(UINT8 usedata);
265265   //UINT16 main_m_vram[0x800][0x800];
266
267   DECLARE_WRITE_LINE_MEMBER(sound_irq_gen);
266268};
267269
268270
r243230r243231
13141316
13151317/***************************************************************************************/
13161318
1319
1320WRITE_LINE_MEMBER(gunpey_state::sound_irq_gen)
1321{
1322   logerror("sound irq\n");
1323}
1324
1325
1326/***************************************************************************************/
1327
13171328static INPUT_PORTS_START( gunpey )
13181329   PORT_START("DSW1")  // IN0 - 7f40
13191330   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:1,2")
r243230r243231
14561467   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25)
14571468
14581469   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
1470   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(gunpey_state, sound_irq_gen))
14591471   MCFG_SOUND_ROUTE(0, "lspeaker", 0.25)
14601472   MCFG_SOUND_ROUTE(1, "rspeaker", 0.25)
14611473MACHINE_CONFIG_END
trunk/src/mame/drivers/hikaru.c
r243230r243231
571571   /* ic66 unpopulated */
572572
573573   // 834-14149   2000     317-0294-COM   Hikaru
574   ROM_PARAMETER( ":rom_board:segam2crypt:key", "291b02c7" )
574   ROM_PARAMETER( ":rom_board:segam2crypt:key", "091b02c7" )
575575ROM_END
576576
577577
r243230r243231
609609   ROM_LOAD32_WORD( "mpr-23564.ic66", 0xe000002, 0x1000000, CRC(255724b6) SHA1(1b382fad165831de3f2e39352c031146759dfc69) )
610610
611611   // 834-14144   2001     317-0297-COM   Hikaru
612   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2912c68a" )
612   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0912c68a" )
613613ROM_END
614614
615615ROM_START( podrace )
r243230r243231
663663
664664   // current 315-5881 decryption simulation code can't produce valid output data with any of keys
665665   // 834-14002   2001     317-0277-COM   Hikaru
666   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2903dad5" )
666   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0903dad5" )
667667ROM_END
668668
669669ROM_START( braveff )
trunk/src/mame/drivers/limenko.c
r243230r243231
3434public:
3535   limenko_state(const machine_config &mconfig, device_type type, const char *tag)
3636      : driver_device(mconfig, type, tag),
37      m_maincpu(*this, "maincpu"),
38      m_oki(*this, "oki"),
39      m_qs1000(*this, "qs1000"),
40      m_gfxdecode(*this, "gfxdecode"),
41      m_palette(*this, "palette"),
4237      m_mainram(*this, "mainram"),
4338      m_fg_videoram(*this, "fg_videoram"),
4439      m_md_videoram(*this, "md_videoram"),
4540      m_bg_videoram(*this, "bg_videoram"),
4641      m_spriteram(*this, "spriteram"),
4742      m_spriteram2(*this, "spriteram2"),
48      m_videoreg(*this, "videoreg") { }
43      m_videoreg(*this, "videoreg"),
44      m_maincpu(*this, "maincpu"),
45      m_oki(*this, "oki"),
46      m_gfxdecode(*this, "gfxdecode"),
47      m_palette(*this, "palette")   { }
4948
50   required_device<cpu_device> m_maincpu;
51   optional_device<okim6295_device> m_oki;
52   optional_device<qs1000_device> m_qs1000;
53   required_device<gfxdecode_device> m_gfxdecode;
54   required_device<palette_device> m_palette;
55   
5649   required_shared_ptr<UINT32> m_mainram;
5750   required_shared_ptr<UINT32> m_fg_videoram;
5851   required_shared_ptr<UINT32> m_md_videoram;
r243230r243231
6053   required_shared_ptr<UINT32> m_spriteram;
6154   required_shared_ptr<UINT32> m_spriteram2;
6255   required_shared_ptr<UINT32> m_videoreg;
63   
6456   tilemap_t *m_bg_tilemap;
6557   tilemap_t *m_md_tilemap;
6658   tilemap_t *m_fg_tilemap;
67   
6859   int m_spriteram_bit;
6960   bitmap_ind16 m_sprites_bitmap;
7061   bitmap_ind8 m_sprites_bitmap_pri;
7162   int m_prev_sprites_count;
7263   UINT8 m_spotty_sound_cmd;
73   
7464   DECLARE_WRITE32_MEMBER(limenko_coincounter_w);
7565   DECLARE_WRITE32_MEMBER(bg_videoram_w);
7666   DECLARE_WRITE32_MEMBER(md_videoram_w);
r243230r243231
8575   DECLARE_READ32_MEMBER(legendoh_speedup_r);
8676   DECLARE_READ32_MEMBER(sb2003_speedup_r);
8777   DECLARE_READ32_MEMBER(spotty_speedup_r);
78   DECLARE_CUSTOM_INPUT_MEMBER(spriteram_bit_r);
79
8880   DECLARE_READ8_MEMBER(qs1000_p1_r);
8981   DECLARE_WRITE8_MEMBER(qs1000_p1_w);
9082   DECLARE_WRITE8_MEMBER(qs1000_p2_w);
9183   DECLARE_WRITE8_MEMBER(qs1000_p3_w);
92   
93   DECLARE_CUSTOM_INPUT_MEMBER(spriteram_bit_r);
94
9584   DECLARE_DRIVER_INIT(common);
9685   DECLARE_DRIVER_INIT(sb2003);
9786   DECLARE_DRIVER_INIT(dynabomb);
9887   DECLARE_DRIVER_INIT(legendoh);
9988   DECLARE_DRIVER_INIT(spotty);
100   
10189   TILE_GET_INFO_MEMBER(get_bg_tile_info);
10290   TILE_GET_INFO_MEMBER(get_md_tile_info);
10391   TILE_GET_INFO_MEMBER(get_fg_tile_info);
104   
10592   virtual void video_start();
10693   UINT32 screen_update_limenko(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
10794   void draw_single_sprite(bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,int priority);
10895   void draw_sprites(UINT32 *sprites, const rectangle &cliprect, int count);
10996   void copy_sprites(bitmap_ind16 &bitmap, bitmap_ind16 &sprites_bitmap, bitmap_ind8 &priority_bitmap, const rectangle &cliprect);
97   required_device<cpu_device> m_maincpu;
98   optional_device<okim6295_device> m_oki;
99   required_device<gfxdecode_device> m_gfxdecode;
100   required_device<palette_device> m_palette;
110101};
111102
112103/*****************************************************************************************************
r243230r243231
174165
175166WRITE32_MEMBER(limenko_state::limenko_soundlatch_w)
176167{
168   qs1000_device *qs1000 = machine().device<qs1000_device>("qs1000");
169
177170   soundlatch_byte_w(space, 0, data >> 16);
178   m_qs1000->set_irq(ASSERT_LINE);
171   qs1000->set_irq(ASSERT_LINE);
179172
180173   machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
181174}
r243230r243231
205198   // ...x .... - ?
206199   // ..x. .... - /IRQ clear
207200
201   qs1000_device *qs1000 = machine().device<qs1000_device>("qs1000");
202
208203   membank("qs1000:bank")->set_entry(data & 0x07);
209204
210205   if (!BIT(data, 5))
211      m_qs1000->set_irq(CLEAR_LINE);
206      qs1000->set_irq(CLEAR_LINE);
212207}
213208
214209/*****************************************************************************************************
r243230r243231
505500
506501   m_sprites_bitmap.allocate(384,240);
507502   m_sprites_bitmap_pri.allocate(384,240);
508   
509   save_item(NAME(m_spriteram_bit));
510   save_item(NAME(m_prev_sprites_count));
511503}
512504
513505UINT32 limenko_state::screen_update_limenko(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r243230r243231
11461138   m_maincpu->space(AS_PROGRAM).install_read_handler(0x6626c, 0x6626f, read32_delegate(FUNC(limenko_state::spotty_speedup_r), this));
11471139
11481140   m_spriteram_bit = 1;
1149   
1150   save_item(NAME(m_spotty_sound_cmd));
11511141}
11521142
1153GAME( 2000, dynabomb, 0,      limenko, sb2003, limenko_state,   dynabomb, ROT0, "Limenko", "Dynamite Bomber (Korea, Rev 1.5)",   GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1154GAME( 2000, legendoh, 0,      limenko, legendoh, limenko_state, legendoh, ROT0, "Limenko", "Legend of Heroes",                   GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1155GAME( 2003, sb2003,   0,      limenko, sb2003, limenko_state,   sb2003,   ROT0, "Limenko", "Super Bubble 2003 (World, Ver 1.0)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1156GAME( 2003, sb2003a,  sb2003, limenko, sb2003, limenko_state,   sb2003,   ROT0, "Limenko", "Super Bubble 2003 (Asia, Ver 1.0)",  GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1143GAME( 2000, dynabomb, 0,      limenko, sb2003, limenko_state,   dynabomb, ROT0, "Limenko", "Dynamite Bomber (Korea, Rev 1.5)",   GAME_IMPERFECT_SOUND )
1144GAME( 2000, legendoh, 0,      limenko, legendoh, limenko_state, legendoh, ROT0, "Limenko", "Legend of Heroes",                   GAME_IMPERFECT_SOUND )
1145GAME( 2003, sb2003,   0,      limenko, sb2003, limenko_state,   sb2003,   ROT0, "Limenko", "Super Bubble 2003 (World, Ver 1.0)", GAME_IMPERFECT_SOUND )
1146GAME( 2003, sb2003a,  sb2003, limenko, sb2003, limenko_state,   sb2003,   ROT0, "Limenko", "Super Bubble 2003 (Asia, Ver 1.0)",  GAME_IMPERFECT_SOUND )
11571147
1158// this game only uses the same graphics chip used in Limenko's system
1159GAME( 2001, spotty,   0,      spotty,  spotty, limenko_state,   spotty,   ROT0, "Prince Co.", "Spotty (Ver. 2.0.2)",             GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
1148// this game only use the same graphics chip used in limenko's system
1149GAME( 2001, spotty,   0,      spotty,  spotty, limenko_state,   spotty,   ROT0, "Prince Co.", "Spotty (Ver. 2.0.2)",             GAME_NO_SOUND )
trunk/src/mame/drivers/lordgun.c
r243230r243231
4747#include "sound/ymf278b.h"
4848#include "includes/lordgun.h"
4949
50
5150/***************************************************************************
5251
5352    Memory Maps - Main
r243230r243231
6059   {
6160      case 0x00/2: // increment counter
6261      {
63         m_protection_data++;
64         m_protection_data &= 0x1f;
62         m_lordgun_protection_data++;
63         m_lordgun_protection_data &= 0x1f;
6564
6665         return;
6766      }
6867
6968      case 0xc0/2: // reset protection device
7069      {
71         m_protection_data = 0;
70         m_lordgun_protection_data = 0;
7271
7372         return;
7473      }
r243230r243231
8180   {
8281      case 0x40/2: // bitswap and xor counter
8382      {
84         UINT8 x = m_protection_data;
83         UINT8 x = m_lordgun_protection_data;
8584
86         m_protection_data  = ((( x >> 0) | ( x >> 1)) & 1) << 4;
87         m_protection_data |=  ((~x >> 2) & 1) << 3;
88         m_protection_data |= (((~x >> 4) | ( x >> 0)) & 1) << 2;
89         m_protection_data |=  (( x >> 3) & 1) << 1;
90         m_protection_data |= (((~x >> 0) | ( x >> 2)) & 1) << 0;
85         m_lordgun_protection_data  = ((( x >> 0) | ( x >> 1)) & 1) << 4;
86         m_lordgun_protection_data |=  ((~x >> 2) & 1) << 3;
87         m_lordgun_protection_data |= (((~x >> 4) | ( x >> 0)) & 1) << 2;
88         m_lordgun_protection_data |=  (( x >> 3) & 1) << 1;
89         m_lordgun_protection_data |= (((~x >> 0) | ( x >> 2)) & 1) << 0;
9190
9291         return 0;
9392      }
9493
9594      case 0x80/2: // return value if conditions are met
9695      {
97         if ((m_protection_data & 0x11) == 0x01) return 0x10;
98         if ((m_protection_data & 0x06) == 0x02) return 0x10;
99         if ((m_protection_data & 0x09) == 0x08) return 0x10;
96         if ((m_lordgun_protection_data & 0x11) == 0x01) return 0x10;
97         if ((m_lordgun_protection_data & 0x06) == 0x02) return 0x10;
98         if ((m_lordgun_protection_data & 0x09) == 0x08) return 0x10;
10099
101100         return 0;
102101      }
r243230r243231
111110   {
112111      case 0xc0/2: // reset protection device
113112      {
114         m_protection_data = 0;
113         m_lordgun_protection_data = 0;
115114
116115         return;
117116      }
r243230r243231
124123   {
125124      case 0x00/2: // de-increment counter
126125      {
127         m_protection_data--;
128         m_protection_data &= 0x1f;
126         m_lordgun_protection_data--;
127         m_lordgun_protection_data &= 0x1f;
129128
130129         return 0;
131130      }
132131
133132      case 0x40/2: // bitswap and xor counter
134133      {
135         UINT8 x = m_protection_data;
134         UINT8 x = m_lordgun_protection_data;
136135
137         m_protection_data  = (((x >> 3) ^ (x >> 2)) & 1) << 4;
138         m_protection_data |= (((x >> 2) ^ (x >> 1)) & 1) << 3;
139         m_protection_data |= (((x >> 1) ^ (x >> 0)) & 1) << 2;
140         m_protection_data |= (((x >> 4) ^ (x >> 0)) & 1) << 1;
141         m_protection_data |= (((x >> 4) ^ (x >> 3)) & 1) << 0;
136         m_lordgun_protection_data  = (((x >> 3) ^ (x >> 2)) & 1) << 4;
137         m_lordgun_protection_data |= (((x >> 2) ^ (x >> 1)) & 1) << 3;
138         m_lordgun_protection_data |= (((x >> 1) ^ (x >> 0)) & 1) << 2;
139         m_lordgun_protection_data |= (((x >> 4) ^ (x >> 0)) & 1) << 1;
140         m_lordgun_protection_data |= (((x >> 4) ^ (x >> 3)) & 1) << 0;
142141
143142         return 0;
144143      }
145144
146145      case 0x80/2: // return value if conditions are met
147146      {
148         if ((m_protection_data & 0x11) == 0x00) return 0x20;
149         if ((m_protection_data & 0x06) != 0x06) return 0x20;
150         if ((m_protection_data & 0x18) == 0x00) return 0x20;
147         if ((m_lordgun_protection_data & 0x11) == 0x00) return 0x20;
148         if ((m_lordgun_protection_data & 0x06) != 0x06) return 0x20;
149         if ((m_lordgun_protection_data & 0x18) == 0x00) return 0x20;
151150
152151         return 0;
153152      }
r243230r243231
623622
624623***************************************************************************/
625624
626void lordgun_state::machine_start()
627{
628   save_item(NAME(m_protection_data));
629   save_item(NAME(m_priority));
630   save_item(NAME(m_whitescreen));
631}
632
633625static MACHINE_CONFIG_START( lordgun, lordgun_state )
634626   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
635627   MCFG_CPU_PROGRAM_MAP(lordgun_map)
r243230r243231
10351027
10361028***************************************************************************/
10371029
1038DRIVER_INIT_MEMBER(lordgun_state, lordgun)
1030DRIVER_INIT_MEMBER(lordgun_state,lordgun)
10391031{
1032   int i;
10401033   UINT16 *rom = (UINT16 *)memregion("maincpu")->base();
10411034   int rom_size = 0x100000;
10421035
1043   for(int i = 0; i < rom_size/2; i++)
1036   for(i = 0; i < rom_size/2; i++)
10441037   {
10451038      UINT16 x = rom[i];
10461039
r243230r243231
10491042
10501043      rom[i] = x;
10511044   }
1052   
1053   save_item(NAME(m_old));
1054   
1055   for (int i = 0; i < 2; i++)
1056   {
1057      save_item(NAME(m_gun[i].scr_x), i);
1058      save_item(NAME(m_gun[i].scr_y), i);
1059      save_item(NAME(m_gun[i].hw_x), i);
1060      save_item(NAME(m_gun[i].hw_y), i);
1061   }
10621045}
10631046
1064DRIVER_INIT_MEMBER(lordgun_state, aliencha)
1065{
1066   save_item(NAME(m_aliencha_dip_sel));
1067}
1068
10691047/***************************************************************************
10701048
10711049    Game Drivers
10721050
10731051***************************************************************************/
10741052
1075GAME( 1994, lordgun,   0,        lordgun,  lordgun,  lordgun_state, lordgun,  ROT0, "IGS", "Lord of Gun (USA)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
1076GAME( 1994, aliencha,  0,        aliencha, aliencha, driver_device, 0,        ROT0, "IGS", "Alien Challenge (World)", GAME_SUPPORTS_SAVE )
1077GAME( 1994, alienchac, aliencha, aliencha, aliencha, driver_device, 0,        ROT0, "IGS", "Alien Challenge (China)", GAME_SUPPORTS_SAVE )
1053GAME( 1994, lordgun,   0,        lordgun,  lordgun,  lordgun_state, lordgun,  ROT0, "IGS", "Lord of Gun (USA)",       GAME_IMPERFECT_GRAPHICS )
1054GAME( 1994, aliencha,  0,        aliencha, aliencha, driver_device, 0,        ROT0, "IGS", "Alien Challenge (World)", 0 )
1055GAME( 1994, alienchac, aliencha, aliencha, aliencha, driver_device, 0,        ROT0, "IGS", "Alien Challenge (China)", 0 )
trunk/src/mame/drivers/maygayep.c
r243230r243231
5050   required_device<cpu_device> m_maincpu;
5151public:
5252   DECLARE_DRIVER_INIT(maygayep);
53   DECLARE_WRITE_LINE_MEMBER(irqhandler);
5354};
5455
5556// bp 29e58 in ep_simp reads the 'INITIALISE . . .' string
r243230r243231
100101
101102}
102103
104WRITE_LINE_MEMBER(maygayep_state::irqhandler)
105{
106}
107
108
103109static MACHINE_CONFIG_START( maygayep, maygayep_state )
104110   MCFG_CPU_ADD("maincpu", H83002, 16000000 )
105111   MCFG_CPU_PROGRAM_MAP( maygayep_map )
r243230r243231
107113   MCFG_SPEAKER_STANDARD_MONO("mono")
108114
109115   MCFG_SOUND_ADD("ymz", YMZ280B, 10000000 )
116   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(maygayep_state, irqhandler))
110117   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
111118MACHINE_CONFIG_END
112119
trunk/src/mame/drivers/midas.c
r243230r243231
8585
8686
8787   UINT32 screen_update_midas(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
88   DECLARE_WRITE_LINE_MEMBER(livequiz_irqhandler);
8889   required_device<cpu_device> m_maincpu;
8990   required_device<eeprom_serial_93cxx_device> m_eeprom;
9091   required_device<gfxdecode_device> m_gfxdecode;
r243230r243231
606607{
607608}
608609
610
611
612
613WRITE_LINE_MEMBER(midas_state::livequiz_irqhandler)
614{
615   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
616}
617
618
609619void midas_state::screen_eof_midas(screen_device &screen, bool state)
610620{
611621   if (state) m_sprgen->buffer_vram();
r243230r243231
637647   /* sound hardware */
638648   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
639649   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
650   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(midas_state, livequiz_irqhandler))
640651   MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
641652   MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
642653MACHINE_CONFIG_END
r243230r243231
670681   /* sound hardware */
671682   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
672683   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
684   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(midas_state, livequiz_irqhandler))
673685   MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
674686   MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
675687MACHINE_CONFIG_END
trunk/src/mame/drivers/model2.c
r243230r243231
24912491
24922492static MACHINE_CONFIG_DERIVED( model2a_0229, model2a )
24932493   MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0)
2494//  MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
2494//   MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
24952495MACHINE_CONFIG_END
24962496
24972497READ8_MEMBER(model2_state::driveio_port_r)
r243230r243231
25992599
26002600static MACHINE_CONFIG_DERIVED( model2b_0229, model2b )
26012601   MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0)
2602//  MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
2602//   MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
26032603MACHINE_CONFIG_END
26042604
26052605
r243230r243231
35713571   ROM_LOAD("mpr-20815.37", 0x600000, 0x200000, CRC(1b5aaae4) SHA1(32b4bf6c096fdccdd5d8f1ddb6c27d3389a52234) )
35723572
35733573   //             1998     317-0236-COM   Model 2
3574   ROM_PARAMETER( ":315_5881:key", "2c2a4a93" )
3574   ROM_PARAMETER( ":315_5881:key", "0c2a4a93" )
35753575
35763576   MODEL2_CPU_BOARD
35773577   MODEL2A_VID_BOARD
r243230r243231
36223622   ROM_LOAD("mpr-20815.37", 0x600000, 0x200000, CRC(1b5aaae4) SHA1(32b4bf6c096fdccdd5d8f1ddb6c27d3389a52234) )
36233623
36243624   //             1998     317-0236-COM   Model 2
3625   ROM_PARAMETER( ":315_5881:key", "2c2a4a93" )
3625   ROM_PARAMETER( ":315_5881:key", "0c2a4a93" )
36263626
36273627   MODEL2_CPU_BOARD
36283628   MODEL2A_VID_BOARD
r243230r243231
36733673   ROM_LOAD("mpr-20815.37", 0x600000, 0x200000, CRC(1b5aaae4) SHA1(32b4bf6c096fdccdd5d8f1ddb6c27d3389a52234) )
36743674
36753675   //             1998     317-0236-COM   Model 2
3676   ROM_PARAMETER( ":315_5881:key", "2c2a4a93" )
3676   ROM_PARAMETER( ":315_5881:key", "0c2a4a93" )
36773677ROM_END
36783678
36793679ROM_START( dyndeka2b ) /* Dynamite Deka 2 (Japan), Model 2B */
r243230r243231
37213721   ROM_LOAD("mpr-20815.37", 0x600000, 0x200000, CRC(1b5aaae4) SHA1(32b4bf6c096fdccdd5d8f1ddb6c27d3389a52234) )
37223722
37233723   //             1998     317-0236-COM   Model 2
3724   ROM_PARAMETER( ":315_5881:key", "2c2a4a93" )
3724   ROM_PARAMETER( ":315_5881:key", "0c2a4a93" )
37253725ROM_END
37263726
37273727ROM_START( dynamcopc ) /* Dynamite Cop (USA), Model 2C */
r243230r243231
37693769   ROM_LOAD("mpr-20815.37", 0x600000, 0x200000, CRC(1b5aaae4) SHA1(32b4bf6c096fdccdd5d8f1ddb6c27d3389a52234) ) /* Located at position 35 on 2C-CRX rom board */
37703770
37713771   //             1998     317-0236-COM   Model 2
3772   ROM_PARAMETER( ":315_5881:key", "2c2a4a93" )
3772   ROM_PARAMETER( ":315_5881:key", "0c2a4a93" )
37733773ROM_END
37743774
37753775ROM_START( schamp ) /* Sonic Championship, Model 2B - Sega ROM board ID# 834-12786 */
r243230r243231
58905890ROM_END
58915891
58925892DRIVER_INIT_MEMBER(model2_state,genprot)
5893{
5893{   
58945894   //astring key = parameter(":315_5881:key");
58955895   m_maincpu->space(AS_PROGRAM).install_ram(0x01d80000, 0x01d8ffff);
58965896   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x01d90000, 0x01d9ffff, read32_delegate(FUNC(model2_state::model2_5881prot_r), this), write32_delegate(FUNC(model2_state::model2_5881prot_w), this));
r243230r243231
59475947
59485948DRIVER_INIT_MEMBER(model2_state,sgt24h)
59495949{
5950//  DRIVER_INIT_CALL(genprot);
5950//   DRIVER_INIT_CALL(genprot);
59515951
59525952   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x01a10000, 0x01a1ffff, read32_delegate(FUNC(model2_state::jaleco_network_r),this), write32_delegate(FUNC(model2_state::jaleco_network_w),this));
59535953
r243230r243231
59655965DRIVER_INIT_MEMBER(model2_state,doa)
59665966{
59675967   m_0229crypt->install_doa_protection();
5968
5968   
59695969   UINT32 *ROM = (UINT32 *)memregion("maincpu")->base();
59705970   ROM[0x630/4] = 0x08000004;
59715971   ROM[0x808/4] = 0x08000004;
trunk/src/mame/drivers/model3.c
r243230r243231
16961696      {
16971697         UINT8* base;
16981698         retvalue = m_cryptdevice->do_decrypt(base);
1699         //  retvalue = ((retvalue & 0xff00) >> 8) | ((retvalue & 0x00ff) << 8); // don't endian swap the return value on this hardware
1699         //   retvalue = ((retvalue & 0xff00) >> 8) | ((retvalue & 0x00ff) << 8); // don't endian swap the return value on this hardware
17001700         retvalue <<= 16;
17011701      }
17021702
1703   //  printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1703   //   printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
17041704   }
17051705   else
17061706   {
r243230r243231
33363336   ROM_FILL( 0x000000, 0x80000, 0 )
33373337
33383338   //             ????     317-0237-COM   Model 3
3339   ROM_PARAMETER( ":315_5881:key", "29234e96" )
3339   ROM_PARAMETER( ":315_5881:key", "09234e96" )
33403340ROM_END
33413341
33423342ROM_START( vs29815 )    /* Step 1.5, ROM board ID# 834-13495 VS2 VER98 STEP 1.5 */
r243230r243231
34893489   ROM_FILL( 0x000000, 0x80000, 0 )
34903490
34913491   //             ????     317-0245-COM   Model 3
3492   ROM_PARAMETER( ":315_5881:key", "29222ac8" )
3492   ROM_PARAMETER( ":315_5881:key", "09222ac8" )
34933493ROM_END
34943494
34953495ROM_START( vs299b ) /* Step 2.0 */
r243230r243231
35673567   ROM_FILL( 0x000000, 0x80000, 0 )
35683568
35693569   //             ????     317-0245-COM   Model 3
3570   ROM_PARAMETER( ":315_5881:key", "29222ac8" )
3570   ROM_PARAMETER( ":315_5881:key", "09222ac8" )
35713571ROM_END
35723572
35733573ROM_START( vs299a ) /* Step 2.0 */
r243230r243231
37233723   ROM_FILL( 0x000000, 0x80000, 0 )
37243724
37253725   //             ????     317-0245-COM   Model 3
3726   ROM_PARAMETER( ":315_5881:key", "29222ac8" )
3726   ROM_PARAMETER( ":315_5881:key", "09222ac8" )
37273727ROM_END
37283728
37293729ROM_START( von2 )   /* Step 2.0 */
r243230r243231
38023802   ROM_FILL( 0x000000, 0x80000, 0 )
38033803
38043804   //             ????     317-0234-COM   Model 3
3805   ROM_PARAMETER( ":315_5881:key", "292a0e97" )
3805   ROM_PARAMETER( ":315_5881:key", "092a0e97" )
38063806ROM_END
38073807
38083808ROM_START( von254g )    /* Step 2.0, Sega game ID# is 833-13789 */
r243230r243231
38813881   ROM_FILL( 0x000000, 0x80000, 0 )
38823882
38833883   //             ????     317-0234-COM   Model 3
3884   ROM_PARAMETER( ":315_5881:key", "292a0e97" )
3884   ROM_PARAMETER( ":315_5881:key", "092a0e97" )
38853885ROM_END
38863886
38873887ROM_START( skichamp )   /* Step 2.0 */
r243230r243231
40284028   ROM_LOAD( "epr21119.ic8",  0x00000, 0x10000, CRC(65082b14) SHA1(6c3c192dd6ef3780c6202dd63fc6086328928818) )
40294029
40304030   //             ????     317-0241-COM   Model 3
4031   ROM_PARAMETER( ":315_5881:key", "31272a01" )
4031   ROM_PARAMETER( ":315_5881:key", "11272a01" )
40324032ROM_END
40334033
40344034ROM_START( swtrilgya )  /* Step 2.1, Sega game ID# is 833-13586, ROM board ID# 834-13587 STAR WARS TRILOGY, Security board ID# 837-13588-COM */
r243230r243231
41004100   ROM_FILL( 0x000000, 0x80000, 0 )
41014101
41024102   //             ????     317-0241-COM   Model 3
4103   ROM_PARAMETER( ":315_5881:key", "31272a01" )
4103   ROM_PARAMETER( ":315_5881:key", "11272a01" )
41044104ROM_END
41054105
41064106ROM_START( dirtdvls )   /* Step 2.1, Sega game ID# is 833-13427, ROM board ID# 834-13528 DRT */
r243230r243231
41644164   ROM_FILL( 0x000000, 0x80000, 0 )
41654165
41664166   //             ????     317-0238-COM   Model 3
4167   ROM_PARAMETER( ":315_5881:key", "29290f17" )
4167   ROM_PARAMETER( ":315_5881:key", "09290f17" )
41684168ROM_END
41694169
41704170ROM_START( dirtdvlsa )  /* Step 2.1 */
r243230r243231
43114311   ROM_LOAD( "epr-20985.bin", 0x000000, 0x010000, CRC(b139481d) SHA1(05fca7db7c8b084c53bd157ba3e8296f1a961a99) )
43124312
43134313   //             ????     317-0239-COM   Model 3
4314   ROM_PARAMETER( ":315_5881:key", "29250e16" )
4314   ROM_PARAMETER( ":315_5881:key", "09250e16" )
43154315ROM_END
43164316
43174317ROM_START( dayto2pe )   /* Step 2.1, Sega game ID# is 833-13610 DAYTONA USA2 SP, ROM board ID# 834-13609 DAYTONA USA2 SP, Security board ID# 837-13645-COM */
r243230r243231
43944394   ROM_LOAD( "epr-20985.bin", 0x000000, 0x010000, CRC(b139481d) SHA1(05fca7db7c8b084c53bd157ba3e8296f1a961a99) )
43954395
43964396   //             ????     317-5045-COM   Model 3
4397   ROM_PARAMETER( ":315_5881:key", "29222cc4" )
4397   ROM_PARAMETER( ":315_5881:key", "0" ) // unknown
43984398ROM_END
43994399
44004400ROM_START( srally2 )    /* Step 2.0, Sega game ID# is 833-13373, ROM board ID# 834-13374 SRT TWIN */
r243230r243231
47494749   ROM_FILL( 0x000000, 0x80000, 0 )
47504750
47514751   //             ????     317-0235-COM   Model 3
4752   ROM_PARAMETER( ":315_5881:key", "29260e96" )
4752   ROM_PARAMETER( ":315_5881:key", "09260e96" )
47534753ROM_END
47544754
47554755ROM_START( spikeout )   /* Step 2.1 */
r243230r243231
48294829   ROM_FILL( 0x000000, 0x80000, 0 )
48304830
48314831   //             ????     317-0240-COM   Model 3
4832   ROM_PARAMETER( ":315_5881:key", "292f2b04" )
4832   ROM_PARAMETER( ":315_5881:key", "092f2b04" )
48334833ROM_END
48344834
48354835ROM_START( spikeofe )   /* Step 2.1, Sega game ID# is 833-13746, ROM board ID# 834-13747 SPK F/E, Security board ID# 837-13726-COM */
r243230r243231
49094909   ROM_FILL( 0x000000, 0x80000, 0 )
49104910
49114911   //             ????     317-0247-COM   Model 3
4912   ROM_PARAMETER( ":315_5881:key", "29236fc8" )
4912   ROM_PARAMETER( ":315_5881:key", "09236fc8" )
49134913ROM_END
49144914
49154915ROM_START( eca )    /* Step 2.1, ROM board ID# 834-13946-01 ECA */
r243230r243231
49804980   ROM_FILL( 0x000000, 0x80000, 0 )
49814981
49824982   //             ????     317-0265-COM   Model 3
4983   ROM_PARAMETER( ":315_5881:key", "2923aa91" )
4983   ROM_PARAMETER( ":315_5881:key", "0923aa91" )
49844984ROM_END
49854985
49864986ROM_START( ecax )   /* Step 2.1 */
r243230r243231
50515051   ROM_FILL( 0x000000, 0x80000, 0 )
50525052
50535053   //             ????     317-0265-COM   Model 3
5054   ROM_PARAMETER( ":315_5881:key", "2923aa91" )
5054   ROM_PARAMETER( ":315_5881:key", "0923aa91" )
50555055ROM_END
50565056
50575057ROM_START( ecap )   /* Step 2.1 - Proto or Location test - No security dongle */
r243230r243231
51255125   ROM_FILL( 0x000000, 0x80000, 0 )
51265126
51275127   //             ????     317-0265-COM   Model 3
5128   ROM_PARAMETER( ":315_5881:key", "2923aa91" )
5128   ROM_PARAMETER( ":315_5881:key", "0923aa91" )
51295129ROM_END
51305130
51315131ROM_START( magtruck )   /* Step 2.1, Sega game ID# is 833-13601-01 (Export), ROM board ID# 834-13600-01 RCS EXP (Export), Security board ID# 837-13599-COM */
r243230r243231
51845184   ROM_FILL( 0x000000, 0x80000, 0 )
51855185
51865186   //             ????     317-0243-COM   Model 3
5187   ROM_PARAMETER( ":315_5881:key", "29266e45" )
5187   ROM_PARAMETER( ":315_5881:key", "09266e45" )
51885188ROM_END
51895189
51905190ROM_START( oceanhun )   /* Step 2.0, Sega game ID# is 833-13571, ROM board ID# 834-13572 THE OCEAN HUNTER, 317-0242-COM security chip (837-13576-COM security board) */
r243230r243231
52555255   ROM_FILL( 0x000000, 0x80000, 0 )
52565256
52575257   //             ????     317-0242-COM   Model 3
5258   ROM_PARAMETER( ":315_5881:key", "292b6a01" )
5258   ROM_PARAMETER( ":315_5881:key", "092b6a01" )
52595259ROM_END
52605260
52615261ROM_START( lamachin )   /* Step 2.0, Sega game ID# is 833-13664, ROM board ID# 834-13665 L.A.MACHINEGUNS, 317-0244-COM security chip (837-13666-COM security board) */
r243230r243231
53275327   ROM_FILL( 0x000000, 0x80000, 0 )
53285328
53295329   //             ????     317-0244-COM   Model 3
5330   ROM_PARAMETER( ":315_5881:key", "292a2bc5" )
5330   ROM_PARAMETER( ":315_5881:key", "092a2bc5" )
53315331ROM_END
53325332
53335333/* Model 3 sound board emulation */
r243230r243231
55845584      dat = m_maincpu->space().read_word((0xf0180000 + 4 * addr)); // every other word is unused in this RAM, probably 32-bit ram on 64-bit bus?
55855585   }
55865586
5587//  dat = ((dat & 0xff00) >> 8) | ((dat & 0x00ff) << 8);
5588//  printf("reading %04x\n", dat);
5587//   dat = ((dat & 0xff00) >> 8) | ((dat & 0x00ff) << 8);
5588//   printf("reading %04x\n", dat);
55895589
55905590   return dat;
55915591}
r243230r243231
56295629
56305630DRIVER_INIT_MEMBER(model3_state, genprot)
56315631{
5632//  astring key = parameter(":315_5881:key");
5632//   astring key = parameter(":315_5881:key");
56335633
56345634   m_maincpu->space(AS_PROGRAM).install_ram(0xf0180000, 0xf019ffff, 0, 0x0e000000);
56355635
5636   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this) );
5636   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this) );                   
56375637
56385638}
56395639
r243230r243231
58465846
58475847DRIVER_INIT_MEMBER(model3_state,swtrilgy)
58485848{
5849
58495850   UINT32 *rom = (UINT32*)memregion("user1")->base();
58505851   DRIVER_INIT_CALL(model3_20);
58515852
r243230r243231
58895890
58905891DRIVER_INIT_MEMBER(model3_state,daytona2)
58915892{
5892//  UINT32 *rom = (UINT32*)memregion("user1")->base();
5893//   UINT32 *rom = (UINT32*)memregion("user1")->base();
58935894   DRIVER_INIT_CALL(model3_20);
58945895
58955896   m_maincpu->space(AS_PROGRAM).install_write_handler(0xc3800000, 0xc3800007, write64_delegate(FUNC(model3_state::daytona2_rombank_w),this));
r243230r243231
59055906
59065907DRIVER_INIT_MEMBER(model3_state,dayto2pe)
59075908{
5908//  UINT32 *rom = (UINT32*)memregion("user1")->base();
5909//   UINT32 *rom = (UINT32*)memregion("user1")->base();
59095910   DRIVER_INIT_CALL(model3_20);
59105911
59115912   m_maincpu->space(AS_PROGRAM).install_write_handler(0xc3800000, 0xc3800007, write64_delegate(FUNC(model3_state::daytona2_rombank_w),this));
59125913   m_maincpu->space(AS_PROGRAM).install_read_bank(0xc3000000, 0xc37fffff, "bank2" );
59135914
5914//  rom[(0x606784^4)/4] = 0x60000000;
5915//  rom[(0x69a3fc^4)/4] = 0x60000000;       // jump to encrypted code
5916//  rom[(0x618b28^4)/4] = 0x60000000;       // jump to encrypted code
5915//   rom[(0x606784^4)/4] = 0x60000000;
5916//   rom[(0x69a3fc^4)/4] = 0x60000000;       // jump to encrypted code
5917//   rom[(0x618b28^4)/4] = 0x60000000;       // jump to encrypted code
59175918
5918//  rom[(0x64ca34^4)/4] = 0x60000000;       // dec
5919//   rom[(0x64ca34^4)/4] = 0x60000000;       // dec
59195920
59205921   DRIVER_INIT_CALL(genprot);
59215922}
trunk/src/mame/drivers/naomi.c
r243230r243231
32213221   ROM_LOAD("mpr-23427.ic8",   0x4000000, 0x0800000, CRC(5851d525) SHA1(1cb1073542d75a3bcc0d363ed31d49bcaf1fd494) )
32223222
32233223   // 840-0044    2000     317-0289-COM   Naomi
3224   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28103347" )
3224   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08103347" )
32253225ROM_END
32263226
32273227ROM_START( csmasho )
r243230r243231
32403240   ROM_LOAD("mpr-23427.ic8", 0x4000000, 0x0800000, CRC(5851d525) SHA1(1cb1073542d75a3bcc0d363ed31d49bcaf1fd494) )
32413241
32423242   // 840-0044    2000     317-0289-COM   Naomi
3243   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28103347" )
3243   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08103347" )
32443244ROM_END
32453245
32463246/*
r243230r243231
34653465   ROM_LOAD("mpr-22098.ic14s", 0x7000000, 0x0800000, CRC(f9824d2e) SHA1(f20f8cc2b1bef9077ede1cb874da8f2a335d39de) )
34663466
34673467   // 840-0016    1999     317-0262-JPN   Naomi
3468   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fee35" )
3468   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fee35" )
34693469ROM_END
34703470
34713471ROM_START( derbyocw )
r243230r243231
36073607   ROM_LOAD("mpr-21574.ic21s", 0xa800000, 0x0800000, CRC(d794a42c) SHA1(a79c7818c6ec993e718494b1d5407eb270a29abe) )
36083608
36093609   // 840-0001    1998     317-0246-JPN   Naomi
3610   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280e6ae1" )
3610   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080e6ae1" )
36113611ROM_END
36123612
36133613/*
r243230r243231
36713671   ROM_LOAD("mpr-22140.ic19s", 0x9800000, 0x0800000, CRC(4cb54893) SHA1(a99b39cc3c82c3cf90f794bb8c8ba60638a6f921) )
36723672
36733673   // 840-0019    1999     317-0269-JPN   Naomi
3674   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2804ae71" )
3674   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0804ae71" )
36753675ROM_END
36763676
36773677ROM_START( smlg99 )
r243230r243231
37043704   ROM_LOAD( "mpr-22058.ic21s", 0xa800000, 0x800000, CRC(f16edaa0) SHA1(e093f5594df43c592a9acd45002ecc65035c2435) )
37053705
37063706   // 840-0012    1999     317-0259-COM   Naomi
3707   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28048a01" )
3707   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08048a01" )
37083708ROM_END
37093709
37103710/*
r243230r243231
37463746   ROM_LOAD("mpr-21901.ic21s", 0xa800000, 0x0800000, CRC(266a3eea) SHA1(795ecc5589a0152b9cf1e03e454ed1ea01501942) )
37473747
37483748   // 834-13842   1999     317-0254-COM   Naomi
3749   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280e8f84" )
3749   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080e8f84" )
37503750
37513751   ROM_REGION( 0x10000, "drivebd", 0 ) /* drive board ROM */
37523752   ROM_LOAD( "epr-21867.bin", 0x000000, 0x010000, CRC(4f93a2a0) SHA1(875907e7fcfc44850e2c60c12268ac61c742f217) )
r243230r243231
37813781   ROM_LOAD( "mpr-22847.ic21s", 0xa800000, 0x800000, CRC(955ad42e) SHA1(e396ca02b5786557434632c4fac56af3a4a9f8ce) )
37823782
37833783   // 834-13950   1999     317-0267-COM   Naomi
3784   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2806efd4" )
3784   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0806efd4" )
37853785ROM_END
37863786
37873787// There is also a development cart (171-7885A). Content is the same.
r243230r243231
38143814   ROM_LOAD( "mpr-23398.ic21s", 0xa800000, 0x800000, CRC(ea4d4d2a) SHA1(3dc9c7164516ae7f3b988c088ab819d8fd40d75e) )
38153815
38163816   // 840-0042    2001     317-0287-COM   Naomi
3817   ROM_PARAMETER( ":rom_board:segam2crypt:key", "281666c6" )
3817   ROM_PARAMETER( ":rom_board:segam2crypt:key", "081666c6" )
38183818ROM_END
38193819
38203820ROM_START( alpiltdx )
r243230r243231
38363836   ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
38373837
38383838   // 834-?????   1999     317-0251-COM   Naomi
3839   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28070e41" )
3839   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08070e41" )
38403840
38413841   // on-cart X76F100 eeprom contents
38423842   ROM_REGION( 0x84, "naomibd_eeprom", 0 )
r243230r243231
38623862   ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
38633863
38643864   // 840-0005    1999     317-0251-COM   Naomi
3865   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28070e41" )
3865   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08070e41" )
38663866ROM_END
38673867
38683868ROM_START( hotd2 )
r243230r243231
40004000   ROM_LOAD("mpr-21831.ic11", 0x5800000, 0x0800000, CRC(751848d0) SHA1(9c2267fd3c6f9ea5f2679bb2ca20d511a49b2845) )
40014001
40024002   // 840-0007    1999     317-0253-JPN   Naomi
4003   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28074a61" )
4003   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08074a61" )
40044004ROM_END
40054005
40064006/*
r243230r243231
40904090   ROM_LOAD( "x76f100.ic37", 0x000000, 0x000084, CRC(c79251d5) SHA1(3e70bbbb6d28bade7eec7e27d716463045656f98) )
40914091
40924092   // 840-0008    1999     317-0255-JPN   Naomi
4093   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28028ea5" )
4093   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08028ea5" )
40944094ROM_END
40954095
40964096ROM_START( tduno2 )
r243230r243231
41674167   ROM_LOAD( "mpr-23534.ic10", 0x9800000, 0x1000000, CRC(62ed85b6) SHA1(b88336bc6115c92a839981cb0c0d0a67b1f7eda5) )
41684168
41694169   // 840-0043    2000     317-0288-COM   Naomi
4170   ROM_PARAMETER( ":rom_board:segam2crypt:key", "281c2347" )
4170   ROM_PARAMETER( ":rom_board:segam2crypt:key", "081c2347" )
41714171ROM_END
41724172
41734173ROM_START( crakndj2 )
r243230r243231
42014201   ROM_LOAD( "rom20.ic20s",  0xa000000, 0x800000, CRC(aabcd580) SHA1(9455e218ab381c7ad5adb2884da39ca7948169d5) )
42024202
42034203   // 840-0068    2001     317-0311-COM   Naomi
4204   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28428247" )
4204   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08428247" )
42054205ROM_END
42064206
42074207ROM_START( samba2k )
r243230r243231
42234223   ROM_LOAD( "mpr-23599.ic11", 0x0a800000, 0x1000000, CRC(1fd2e792) SHA1(6f299e527be529f85d0e8b4ce0e7a06ac0d25fe9) )
42244224
42254225   // 840-0047    2000     317-0295-COM   Naomi
4226   ROM_PARAMETER( ":rom_board:segam2crypt:key", "281702cf" )
4226   ROM_PARAMETER( ":rom_board:segam2crypt:key", "081702cf" )
42274227ROM_END
42284228
42294229ROM_START( alienfnt )
r243230r243231
42394239   ROM_LOAD( "mpr-23585.ic5",   0x4800000, 0x1000000, CRC(883a6482) SHA1(e3145710df793b7fd67f02707904416210a71978) )
42404240
42414241   // 840-0048    2001     317-0293-COM   Naomi
4242   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28174343" )
4242   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08174343" )
42434243ROM_END
42444244
42454245ROM_START( alienfnta )
r243230r243231
42554255   ROM_LOAD( "mpr-23585.ic5",   0x4800000, 0x1000000, CRC(883a6482) SHA1(e3145710df793b7fd67f02707904416210a71978) )
42564256
42574257   // 840-0048    2001     317-0293-COM   Naomi
4258   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28174343" )
4258   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08174343" )
42594259ROM_END
42604260
42614261/*
r243230r243231
45184518   ROM_LOAD("mpr-22034.ic10",0x5000000, 0x0800000, CRC(3aa5ce5e) SHA1(f00a906235e4522d6fc2ac771324114346875314) )
45194519
45204520   // 840-0011    1999     317-0257-COM   Naomi
4521   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2802ca85" )
4521   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0802ca85" )
45224522ROM_END
45234523
45244524/* Crazy Taxi */
r243230r243231
45434543   ROM_LOAD( "mpr-21683.ic15s", 0x7800000, 0x800000, CRC(ac8a27e0) SHA1(8e71d853a102dd6c164d5326e6d157ccfb8c7b36) )
45444544
45454545   // 840-0002    1999     317-0248-COM   Naomi
4546   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280d2f45" )
4546   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080d2f45" )
45474547ROM_END
45484548
45494549/* Jambo! Safari */
r243230r243231
45634563   ROM_LOAD( "mpr-22825.ic8",  0x4000000, 0x800000, CRC(85bada10) SHA1(b6e15d8f1d6bca12ffa4816ed0393c04ca500fba) )
45644564
45654565   // 840-0013    1999     317-0264-COM   Naomi
4566   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fab95" )
4566   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fab95" )
45674567ROM_END
45684568
45694569/* 18 Wheeler (deluxe) (Rev A) */
r243230r243231
45954595   ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) )
45964596
45974597   // 840-0023    2000     317-0273-COM   Naomi
4598   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2807cf54" )
4598   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0807cf54" )
45994599
46004600   // JVS I/O board 837-13844, code is for a Z80 of unknown type (it's inside the big Sega ASIC)
46014601   ROM_REGION( 0x20000, "jvsio", ROMREGION_ERASEFF)
r243230r243231
46374637   ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) )
46384638
46394639   // 840-0023    2000     317-0273-COM   Naomi
4640   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2807cf54" )
4640   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0807cf54" )
46414641
46424642   // JVS I/O board 837-13844, code is for a Z80 of unknown type (it's inside the big Sega ASIC)
46434643   ROM_REGION( 0x20000, "jvsio", ROMREGION_ERASEFF)
r243230r243231
46794679   ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) )
46804680
46814681   // 840-0023    2000     317-0273-COM   Naomi
4682   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2807cf54" )
4682   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0807cf54" )
46834683
46844684   // JVS I/O board 837-13844, code is for a Z80 of unknown type (it's inside the big Sega ASIC)
46854685   ROM_REGION( 0x20000, "jvsio", ROMREGION_ERASEFF)
r243230r243231
47124712   ROM_LOAD( "mpr-22992.ic15s", 0x7800000, 0x800000, CRC(5eb6c4c6) SHA1(5dc1bced7ebd7d7e01f74d03706ec4a96585628d) )
47134713
47144714   // 840-0025    1999     317-0274-JPN   Naomi
4715   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280b8ef5" )
4715   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080b8ef5" )
47164716ROM_END
47174717
47184718/* Sega Strike Fighter */
r243230r243231
47444744   ROM_LOAD( "mpr-23321.ic20s", 0xa000000, 0x800000, CRC(018627d4) SHA1(2519f39ad046d14f602648fed39bc3719185b55e) )
47454745
47464746   // 840-0035    2000     317-0281-COM   Naomi
4747   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28132303" )
4747   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08132303" )
47484748ROM_END
47494749
47504750// EPR ROM have different number, possible updated/bugfixed re-release or STD/DLX version, difference with original set is unknown, have "Rev.A" label too
r243230r243231
47764776   ROM_LOAD( "mpr-23321.ic20s", 0xa000000, 0x800000, CRC(018627d4) SHA1(2519f39ad046d14f602648fed39bc3719185b55e) )
47774777
47784778   // 840-0035    2000     317-0281-COM   Naomi
4779   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28132303" )
4779   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08132303" )
47804780ROM_END
47814781
47824782
r243230r243231
47964796   ROM_LOAD( "mpr-22915.ic6", 0x3000000, 0x800000, CRC(e48148ac) SHA1(c1273353eeaf9bb6b185f133281d7d04271bc895) )
47974797
47984798   // 840-0018    1999     317-0268-COM   Naomi
4799   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2808ae51" )
4799   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0808ae51" )
48004800ROM_END
48014801
48024802/*
r243230r243231
48534853   ROM_LOAD("mpr-23340.ic17s",0x8800000, 0x0800000, CRC(001604f8) SHA1(615ec027d383d44d4aadb1175be6320e4139d7d1) )
48544854
48554855   // 840-0041    2000     317-0286-COM   Naomi
4856   ROM_PARAMETER( ":rom_board:segam2crypt:key", "281a66ca" )
4856   ROM_PARAMETER( ":rom_board:segam2crypt:key", "081a66ca" )
48574857ROM_END
48584858
48594859
r243230r243231
50615061   ROM_LOAD("mpr-22160.ic19s",0x9800000, 0x0800000, CRC(579eef4e) SHA1(bfcabd57f623647053afcedcabfbc74e5736819f) )
50625062
50635063   // 840-0017    1999     317-0266-COM   Naomi
5064   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fea94" )
5064   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fea94" )
50655065ROM_END
50665066
50675067/*
r243230r243231
51545154   ROM_LOAD("mpr-22965.ic16s",0x8000000, 0x0800000, CRC(8f7bfa8a) SHA1(19f137b1552978d232785c4408805b71835585c6) )
51555155
51565156   // 840-0020    1999     317-0270-COM   Naomi
5157   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280a8b5d" )
5157   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080a8b5d" )
51585158ROM_END
51595159
51605160// prototype - only works with US BIOS
r243230r243231
51825182   ROM_LOAD("mpr-22965.ic16s",0x8000000, 0x0800000, CRC(8f7bfa8a) SHA1(19f137b1552978d232785c4408805b71835585c6) )
51835183
51845184   // 840-0020    1999     317-0270-COM   Naomi
5185   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280a8b5d" )
5185   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080a8b5d" )
51865186ROM_END
51875187
51885188/*
r243230r243231
54655465   ROM_LOAD("mpr-22948.ic21s", 0xa800000, 0x0800000, CRC(1b0de917) SHA1(fd1742ea9bb2f1ce871ee3266171f26634e1c8e7) )
54665466
54675467   // 840-0021    2000     317-0271-COM   Naomi
5468   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28068b58" )
5468   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08068b58" )
54695469ROM_END
54705470
54715471ROM_START( virnbap )
r243230r243231
54975497   ROM_LOAD("mpr-22948.ic21s", 0xa800000, 0x0800000, CRC(1b0de917) SHA1(fd1742ea9bb2f1ce871ee3266171f26634e1c8e7) )
54985498
54995499   // 840-0021    2000     317-0271-COM   Naomi
5500   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28068b58" )
5500   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08068b58" )
55015501ROM_END
55025502
55035503/*
r243230r243231
55505550   ROM_LOAD("mpr-21923.ic15s",0x7800000, 0x0400000, CRC(d127d9a5) SHA1(78c95357344ea15469b84fa8b1332e76521892cd) )
55515551
55525552   // 840-0010    1999     317-0258-COM   Naomi
5553   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28088b08" )
5553   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08088b08" )
55545554ROM_END
55555555
55565556/*
r243230r243231
55955595   ROM_LOAD("mpr-22926.ic11",0x5800000, 0x0800000, CRC(57eec89d) SHA1(dd8f9a9155e51ee5260f559449fb0ea245077952) )
55965596
55975597   // 840-0015    1999     317-0263-COM   Naomi
5598   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2803eb15" )
5598   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0803eb15" )
55995599ROM_END
56005600
56015601/*
r243230r243231
56215621   ROM_LOAD( "mpr-22269.ic8", 0x7800000, 0x1000000, CRC(6c0cf740) SHA1(da10b33a6e54afbe1d7e52801216e7119b0b33b1) )
56225622
56235623   // 840-0040    2000     317-0285-COM   Naomi
5624   ROM_PARAMETER( ":rom_board:segam2crypt:key", "281627c3" )
5624   ROM_PARAMETER( ":rom_board:segam2crypt:key", "081627c3" )
56255625ROM_END
56265626
56275627ROM_START( mushik2e )
r243230r243231
59385938   ROM_LOAD("mpr-21726.ic19s",0x9800000, 0x0800000, CRC(429bf290) SHA1(6733e1bcf100e73ab43273f6feedc187fcaa55d4) )
59395939
59405940   // 840-0003    1999     317-0249-COM   Naomi
5941   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28012b41" )
5941   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08012b41" )
59425942ROM_END
59435943
59445944ROM_START( gunsur2 )
r243230r243231
62006200   ROM_LOAD( "maz1ma8.4d",  0x8000000, 0x1000000, CRC(d46c9f40) SHA1(45eec7fa3d4261f12438e841254fa75d572331b3) )
62016201
62026202   // 25869812    2002     317-0266-COM   Naomi
6203   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fea94" )
6203   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fea94" )
62046204ROM_END
62056205
62066206ROM_START( mazana )
r243230r243231
62196219   ROM_LOAD( "maz1ma8.4d",  0x8000000, 0x1000000, CRC(d46c9f40) SHA1(45eec7fa3d4261f12438e841254fa75d572331b3) )
62206220
62216221   // 25869812    2002     317-0266-COM   Naomi
6222   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280fea94" )
6222   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080fea94" )
62236223ROM_END
62246224
62256225ROM_START( vtenis2c )
r243230r243231
63926392   ROM_LOAD( "ic16s.bin", 0x8000000, 0x800000, CRC(b8493dbe) SHA1(b641417e1bda49341e7ff86340072d74e3330665) )
63936393
63946394   // 840-0073    2001     317-0316-JPN   Naomi
6395   ROM_PARAMETER( ":rom_board:segam2crypt:key", "294bc3e3" )
6395   ROM_PARAMETER( ":rom_board:segam2crypt:key", "094bc3e3" )
63966396ROM_END
63976397
63986398ROM_START( ringout )
r243230r243231
64136413   ROM_LOAD( "mpr-21770.ic10", 0x5000000, 0x800000, CRC(c5308e61) SHA1(e51f8026351d5ffbda2a5bed39aeef543366febf) )
64146414
64156415   // 840-0004    1999     317-0250-COM   Naomi
6416   ROM_PARAMETER( ":rom_board:segam2crypt:key", "280b1e40" )
6416   ROM_PARAMETER( ":rom_board:segam2crypt:key", "080b1e40" )
64176417ROM_END
64186418
64196419ROM_START( vonot )
r243230r243231
64376437   ROM_LOAD( "mpr-23194.ic13s", 0x6800000, 0x800000, CRC(5adea0bd) SHA1(f8614ba83d5f61556c3db1a1796a02ed2c51ce2a) )
64386438
64396439   // 840-0028    2000     317-0279-COM   Naomi
6440   ROM_PARAMETER( ":rom_board:segam2crypt:key", "28010715" )
6440   ROM_PARAMETER( ":rom_board:segam2crypt:key", "08010715" )
64416441ROM_END
64426442
64436443ROM_START( derbyo2k )
r243230r243231
78017801   ROM_LOAD( "mpr-23662.ic11", 0xa800000, 0x0800000, CRC(d6ef7d68) SHA1(4ee396af6c5caf4c5af6e9ad0e03a7ac2c5039f4) )
78027802
78037803   // 840-0061    2001     317-0310-COM   Naomi 2
7804   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2cee834a" )
7804   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0cee834a" )
78057805ROM_END
78067806
78077807ROM_START( vstrik3cb )
r243230r243231
78237823   ROM_LOAD( "mpr-23662.ic11", 0xa800000, 0x0800000, CRC(d6ef7d68) SHA1(4ee396af6c5caf4c5af6e9ad0e03a7ac2c5039f4) )
78247824
78257825   // 840-0061    2001     317-0310-COM   Naomi 2
7826   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2cee834a" )
7826   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0cee834a" )
78277827ROM_END
78287828
78297829ROM_START( wldrider )
r243230r243231
78447844   ROM_LOAD( "mpr-23620.ic10", 0x9800000, 0x1000000, CRC(67aa15a9) SHA1(42c24cbf7069c27430a71509a872cd1c4224aaeb) )
78457845
78467846   // 840-0046    2001     317-0301-COM   Naomi 2
7847   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7a703" )
7847   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7a703" )
78487848ROM_END
78497849
78507850ROM_START( vf4cart )
r243230r243231
78667866   ROM_LOAD( "mpr-23784.ic11", 0xa800000, 0x1000000, CRC(f74f2fee) SHA1(84b07baa6d116727e66ef27e24ba6484c3393891) )
78677867
78687868   // 840-0080    2002     317-0324-COM   Naomi 2
7869   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2eef2f96" )
7869   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0eef2f96" )
78707870ROM_END
78717871
78727872// There is also a development cart (171-7885A) with 20x 64Mb FlashROMs instead of 10x 128Mb MaskROMs. Content is the same.
r243230r243231
79897989   ROM_LOAD( "mpr-23703.ic11", 0xa800000, 0x1000000, CRC(702b8b4a) SHA1(3a8dfde458f341e7db20664382b9fce2b6e5d462) )
79907990
79917991   // 840-0062    2001     317-0313-COM   Naomi 2
7992   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" )
7992   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" )
79937993ROM_END
79947994
79957995ROM_START( clubkrtd )
r243230r243231
80338033   ROM_LOAD( "mpr-23703.ic11", 0xa800000, 0x1000000, CRC(702b8b4a) SHA1(3a8dfde458f341e7db20664382b9fce2b6e5d462) )
80348034
80358035   // 840-0062    2001     317-0313-COM   Naomi 2
8036   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" )
8036   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" )
80378037ROM_END
80388038
80398039ROM_START( clubkprz )
r243230r243231
80668066   ROM_LOAD( "at25010.ic3s", 0x000000, 0x000084, CRC(0142d8be) SHA1(5922b6c47b12b19e1fa7bbe9aae391905038a7ff) )
80678067
80688068   // 840-0062    2001     317-0313-COM   Naomi 2
8069   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" )
8069   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" )
80708070ROM_END
80718071
80728072ROM_START( clubkpzb )
r243230r243231
80958095   ROM_COPY( "rom_board", 0x1000000, 0x400000, 0xc00000 )
80968096
80978097   // 840-0062    2001     317-0313-COM   Naomi 2
8098   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" )
8098   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" )
80998099
81008100   // this dump can't be used as main_eeprom, because that's exactly 0x80 bytes
81018101   ROM_REGION(0x84, "some_eeprom", 0)
r243230r243231
81308130   ROM_COPY( "rom_board", 0x1000000, 0x400000, 0xc00000 )
81318131
81328132   // 840-0062    2001     317-0313-COM   Naomi 2
8133   ROM_PARAMETER( ":rom_board:segam2crypt:key", "2ce7d742" )
8133   ROM_PARAMETER( ":rom_board:segam2crypt:key", "0ce7d742" )
81348134ROM_END
81358135
81368136// uses the same mask roms data as clubk2k3, but not in 32bit dissected form, EPR doesn't have checksumms for them, so rom test shows all roms as BAD
trunk/src/mame/drivers/nmk16.c
r243230r243231
37803780GFXDECODE_END
37813781
37823782
3783
3784
3785WRITE_LINE_MEMBER(nmk16_state::ym2203_irqhandler)
3786{
3787   m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
3788}
37833789/*
37843790----
37853791
r243230r243231
38883894   MCFG_SPEAKER_STANDARD_MONO("mono")
38893895
38903896   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
3891   MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
3897   MCFG_YM2203_IRQ_HANDLER(WRITELINE(nmk16_state, ym2203_irqhandler))
38923898   MCFG_SOUND_ROUTE(0, "mono", 0.50)
38933899   MCFG_SOUND_ROUTE(1, "mono", 0.50)
38943900   MCFG_SOUND_ROUTE(2, "mono", 0.50)
r243230r243231
44154421   MCFG_SPEAKER_STANDARD_MONO("mono")
44164422
44174423   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4418   MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
4424   MCFG_YM2203_IRQ_HANDLER(WRITELINE(nmk16_state, ym2203_irqhandler))
44194425   MCFG_SOUND_ROUTE(0, "mono", 0.50)
44204426   MCFG_SOUND_ROUTE(1, "mono", 0.50)
44214427   MCFG_SOUND_ROUTE(2, "mono", 0.50)
r243230r243231
44584464   MCFG_SPEAKER_STANDARD_MONO("mono")
44594465
44604466   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4461   MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
4467   MCFG_YM2203_IRQ_HANDLER(WRITELINE(nmk16_state, ym2203_irqhandler))
44624468   MCFG_SOUND_ROUTE(0, "mono", 0.50)
44634469   MCFG_SOUND_ROUTE(1, "mono", 0.50)
44644470   MCFG_SOUND_ROUTE(2, "mono", 0.50)
r243230r243231
45004506   MCFG_SPEAKER_STANDARD_MONO("mono")
45014507
45024508   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4503   MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
4509   MCFG_YM2203_IRQ_HANDLER(WRITELINE(nmk16_state, ym2203_irqhandler))
45044510   MCFG_SOUND_ROUTE(0, "mono", 0.50)
45054511   MCFG_SOUND_ROUTE(1, "mono", 0.50)
45064512   MCFG_SOUND_ROUTE(2, "mono", 0.50)
r243230r243231
46304636   MCFG_SPEAKER_STANDARD_MONO("mono")
46314637
46324638   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4633   MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
4639   MCFG_YM2203_IRQ_HANDLER(WRITELINE(nmk16_state, ym2203_irqhandler))
46344640   MCFG_SOUND_ROUTE(0, "mono", 0.50)
46354641   MCFG_SOUND_ROUTE(1, "mono", 0.50)
46364642   MCFG_SOUND_ROUTE(2, "mono", 0.50)
trunk/src/mame/drivers/overdriv.c
r243230r243231
475475
476476GAMEL( 1990, overdriv,         0, overdriv, overdriv, driver_device, 0, ROT90, "Konami", "Over Drive (set 1)", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_overdriv )
477477GAMEL( 1990, overdriva, overdriv, overdriv, overdriv, driver_device, 0, ROT90, "Konami", "Over Drive (set 2)", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_overdriv )
478GAMEL( 1990, overdrivb, overdriv, overdriv, overdriv, driver_device, 0, ROT90, "Konami", "Over Drive (set 3)", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_overdriv )
478GAMEL( 1990, overdrivb, overdriv, overdriv, overdriv, driver_device, 0, ROT90, "Konami", "Over Drive (set 3)", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_overdriv )
No newline at end of file
trunk/src/mame/drivers/peplus.c
r243230r243231
51125112   ROM_LOAD( "cap960.u50", 0x0000, 0x0100, CRC(00dd8d0a) SHA1(542763b12aeb0aec2b410f7c075c52907f45d171) )
51135113ROM_END
51145114
5115ROM_START( peps0366 ) /* Normal board : Double Diamonds Deluxe Slots (PS0366) - Payout 94.99% */
5116   ROM_REGION( 0x10000, "maincpu", 0 )
5117   ROM_LOAD( "ps0366_569-a2c.u68",   0x00000, 0x10000, CRC(32fd35c5) SHA1(8562608bc45328559b7c04ef4026384862bf2d51) ) /* 2 Coins Max / 1 Line */
5118
5119   ROM_REGION( 0x020000, "gfx1", 0 )
5120   ROM_LOAD( "mro-cg1303.u72",  0x00000, 0x8000, CRC(f5bcc47f) SHA1(b132960a095996d1790df4dcedf14a29169fe667) )
5121   ROM_LOAD( "mgo-cg1303.u73",  0x08000, 0x8000, CRC(e16cc01b) SHA1(086f2ac533d868dbaa3852516b6fef344dddff13) )
5122   ROM_LOAD( "mbo-cg1303.u74",  0x10000, 0x8000, CRC(2c1ffea2) SHA1(efc16869f994415a03663205ca2396e4c26e25a3) )
5123   ROM_LOAD( "mxo-cg1303.u75",  0x18000, 0x8000, CRC(7c4578e0) SHA1(70b6cf02225a4804592f44c90365f370fb83281a) )
5124
5125   ROM_REGION( 0x100, "proms", 0 )
5126   ROM_LOAD( "cap1303.u50", 0x0000, 0x0100, CRC(5341ea30) SHA1(63c8f7fa94dcb772c308b307f755a188b9b5e7eb) )
5127ROM_END
5128
5129ROM_START( peps0372 ) /* Normal board : Double Diamonds Deluxe Slots (PS0372) - Payout 90.10% */
5130   ROM_REGION( 0x10000, "maincpu", 0 )
5131   ROM_LOAD( "ps0372_569-a2c.u68",   0x00000, 0x10000, CRC(45573591) SHA1(0a15313af506817528eb7319a0994b6993412965) ) /* 3 Coins Max / 1 Line */
5132
5133   ROM_REGION( 0x020000, "gfx1", 0 )
5134   ROM_LOAD( "mro-cg1303.u72",  0x00000, 0x8000, CRC(f5bcc47f) SHA1(b132960a095996d1790df4dcedf14a29169fe667) )
5135   ROM_LOAD( "mgo-cg1303.u73",  0x08000, 0x8000, CRC(e16cc01b) SHA1(086f2ac533d868dbaa3852516b6fef344dddff13) )
5136   ROM_LOAD( "mbo-cg1303.u74",  0x10000, 0x8000, CRC(2c1ffea2) SHA1(efc16869f994415a03663205ca2396e4c26e25a3) )
5137   ROM_LOAD( "mxo-cg1303.u75",  0x18000, 0x8000, CRC(7c4578e0) SHA1(70b6cf02225a4804592f44c90365f370fb83281a) )
5138
5139   ROM_REGION( 0x100, "proms", 0 )
5140   ROM_LOAD( "cap1303.u50", 0x0000, 0x0100, CRC(5341ea30) SHA1(63c8f7fa94dcb772c308b307f755a188b9b5e7eb) )
5141ROM_END
5142
5143ROM_START( peps0373 ) /* Normal board : Double Diamonds Deluxe Slots (PS0373) - Payout 87.56% */
5144   ROM_REGION( 0x10000, "maincpu", 0 )
5145   ROM_LOAD( "ps0373_583-a6c.u68",   0x00000, 0x10000, CRC(085bed76) SHA1(8775f7c9654f92eab616cdda4505cbde30154889) ) /* 3 Coins Max / 1 Line */
5146
5147   ROM_REGION( 0x020000, "gfx1", 0 )
5148   ROM_LOAD( "mro-cg1303.u72",  0x00000, 0x8000, CRC(f5bcc47f) SHA1(b132960a095996d1790df4dcedf14a29169fe667) )
5149   ROM_LOAD( "mgo-cg1303.u73",  0x08000, 0x8000, CRC(e16cc01b) SHA1(086f2ac533d868dbaa3852516b6fef344dddff13) )
5150   ROM_LOAD( "mbo-cg1303.u74",  0x10000, 0x8000, CRC(2c1ffea2) SHA1(efc16869f994415a03663205ca2396e4c26e25a3) )
5151   ROM_LOAD( "mxo-cg1303.u75",  0x18000, 0x8000, CRC(7c4578e0) SHA1(70b6cf02225a4804592f44c90365f370fb83281a) )
5152
5153   ROM_REGION( 0x100, "proms", 0 )
5154   ROM_LOAD( "cap1303.u50", 0x0000, 0x0100, CRC(5341ea30) SHA1(63c8f7fa94dcb772c308b307f755a188b9b5e7eb) )
5155ROM_END
5156
51575115ROM_START( peps0426 ) /* Normal board : Sizzling Sevens Slots (PS0268) - Payout 90.35% */
51585116   ROM_REGION( 0x10000, "maincpu", 0 )
51595117   ROM_LOAD( "ps0426_571-a3h.u68",   0x00000, 0x10000, CRC(b53771c1) SHA1(23fccd5facb98fc83b8903946435be4f15199ff8) ) /* 3 Coins Max / 1 Lines */
r243230r243231
92909248GAMEL(1996, peps0298, peps0042, peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0298) Double Diamond Slots",          0, layout_pe_slots )
92919249GAMEL(1996, peps0308, 0,        peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0308) Double Jackpot Slots",          0, layout_pe_slots )
92929250GAMEL(1996, peps0364, peps0021, peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0364) Red White & Blue Slots",        0, layout_pe_slots )
9293GAMEL(1996, peps0366, 0,        peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0366) Double Diamond Deluxe Slots",   0, layout_pe_slots )
9294GAMEL(1996, peps0372, peps0366, peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0372) Double Diamond Deluxe Slots",   0, layout_pe_slots )
9295GAMEL(1996, peps0373, peps0366, peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0373) Double Diamond Deluxe Slots",   0, layout_pe_slots )
92969251GAMEL(1996, peps0426, 0,        peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0426) Sizzling Sevens Slots",         0, layout_pe_slots )
92979252GAMEL(1996, peps0581, peps0021, peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0581) Red White & Blue Slots",        0, layout_pe_slots )
92989253GAMEL(1996, peps0615, 0,        peplus, peplus_slots,   peplus_state, peplus,   ROT0,  "IGT - International Game Technology", "Player's Edge Plus (PS0615) Chaos Slots",                   0, layout_pe_slots )
trunk/src/mame/drivers/psikyosh.c
r243230r243231
778778
779779   MCFG_SCREEN_ADD("screen", RASTER)
780780   MCFG_SCREEN_REFRESH_RATE(60)
781   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
781782   MCFG_SCREEN_SIZE(64*8, 32*8)
782783   MCFG_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 28*8-1)
783784   MCFG_SCREEN_UPDATE_DRIVER(psikyosh_state, screen_update_psikyosh)
r243230r243231
812813   MCFG_CPU_MODIFY("maincpu")
813814   MCFG_CPU_PROGRAM_MAP(ps5_map)
814815
815   /* Measured Hsync 16.165 KHz, Vsync 61.68 Hz */
816816   /* Ideally this would be driven off the video register. However, it doesn't changeat runtime and MAME will pick a better screen resolution if it knows upfront */
817817   MCFG_SCREEN_MODIFY("screen")
818   MCFG_SCREEN_RAW_PARAMS(MASTER_CLOCK/8, 443, 0, 40*8, 262, 0, 30*8)
818   MCFG_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1)
819819MACHINE_CONFIG_END
820820
821821
trunk/src/mame/drivers/psychic5.c
r243230r243231
947947GAME( 1987, psychic5,  0,        psychic5, psychic5, driver_device, 0, ROT270, "Jaleco / NMK", "Psychic 5 (World)", 0 ) // "Oversea's version V2.00 CHANGED BY TAMIO NAKASATO" text present in ROM, various modifications (English names, more complete attract demo etc.)
948948GAME( 1987, psychic5j, psychic5, psychic5, psychic5, driver_device, 0, ROT270, "Jaleco / NMK", "Psychic 5 (Japan)", 0 )
949949GAME( 1988, bombsa,    0,        bombsa,   bombsa,   driver_device, 0, ROT270, "Jaleco", "Bombs Away", GAME_NOT_WORKING )
950
trunk/src/mame/drivers/seta2.c
r243230r243231
15841584   PORT_DIPSETTING(      0x0040, DEF_STR( 1C_5C ) )
15851585   PORT_DIPSETTING(      0x0000, "1 Coin/10 Credits" )
15861586
1587   PORT_START("DSW2")  // $400302.w    PORT_START("DSW2")  // $400302.w
1587   PORT_START("DSW2")  // $400302.w   PORT_START("DSW2")  // $400302.w
15881588   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:1")  // used
15891589   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
15901590   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
r243230r243231
16481648
16491649static INPUT_PORTS_START( endrichs )
16501650   PORT_INCLUDE(reelquak)
1651
1651   
16521652   PORT_MODIFY("DSW1")  // $400300.w
16531653   PORT_DIPNAME( 0x0001, 0x0001, "Payout Style" ) PORT_DIPLOCATION("SW1:1")
16541654   PORT_DIPSETTING(      0x0001, "Normal Payout" )
trunk/src/mame/drivers/shanghai.c
r243230r243231
514514
515515   /* same as standard seibu ym2203, but "ym1" also reads "DSW" */
516516   MCFG_SOUND_ADD("ym1", YM2203, XTAL_16MHz/4)
517   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, fm_irqhandler))
517   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("seibu_sound", seibu_sound_device, ym2203_irqhandler))
518518   MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSW"))
519519   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
520520
trunk/src/mame/drivers/silkroad.c
r243230r243231
388388ROM_END
389389
390390
391GAME( 1999, silkroad,         0, silkroad, silkroad, driver_device, 0, ROT0, "Unico", "The Legend of Silkroad", GAME_SUPPORTS_SAVE )
392GAME( 1999, silkroada, silkroad, silkroad, silkroad, driver_device, 0, ROT0, "Unico", "The Legend of Silkroad (larger ROMs)", GAME_SUPPORTS_SAVE ) // same content but fewer GFX roms of a larger size
391GAME( 1999, silkroad,         0, silkroad, silkroad, driver_device, 0, ROT0, "Unico", "The Legend of Silkroad", 0 )
392GAME( 1999, silkroada, silkroad, silkroad, silkroad, driver_device, 0, ROT0, "Unico", "The Legend of Silkroad (larger ROMs)", 0 ) // same content but fewer GFX roms of a larger size
trunk/src/mame/drivers/stv.c
r243230r243231
18441844   ROM_LOAD16_WORD_SWAP( "mpr20833.9",     0x2000000, 0x0400000, CRC(cb6af231) SHA1(4a2e5d7c2fd6179c19cdefa84a03f9a34fbb9e70) ) // good (was .19s)
18451845
18461846   // 25349801    1998     317-5040-COM   ST-V      (yes, the 317-5040-COM chip was reused for 3 different games and on both Naomi and ST-V!)
1847   ROM_PARAMETER( ":315_5881:key", "052e2901" )
1847   ROM_PARAMETER( ":315_5881:key", "052e2901" )
18481848ROM_END
18491849
18501850ROM_START( bakubaku )
trunk/src/mame/drivers/taitottl.c
r243230r243231
226226 MS06   M8  74s287      missile animated graphics
227227 MS05   11F IM5610      200pt tank R->L graphic
228228 MS05   11E IM5610      200pt tank L->R graphic
229 MS04   N7  IM5610      player missile trajectory pattern
229 MS04   N7  IM5610       player missile trajectory pattern
230230 MS03   F3  IM5610      anti-missile ack-ack graphics
231231 MS02   L12 IM5610      missile left/right position
232232 MS01   D8  IM5610      100pt tanks graphics
233
233
234234*/
235235
236236ROM_START( missilex )
237237   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASE00 )
238238
239239   ROM_REGION( 0x0800, "roms", ROMREGION_ERASE00 )
240   ROM_LOAD( "cr11.4l",      0x0000, 0x0200, CRC(3d10a407) SHA1(1a85581c34d7e6766eaebbcc9895ed0ab2f94387) )
240   ROM_LOAD( "cr11.4l",      0x0000, 0x0200, CRC(3d10a407) SHA1(1a85581c34d7e6766eaebbcc9895ed0ab2f94387) )
241241   ROM_LOAD( "ms09.6f",      0x0000, 0x0200, CRC(80787642) SHA1(9de2419f0ba16f9c2b06e417c1ebba441fdae053) )
242   ROM_LOAD( "ms08.2c",      0x0000, 0x0200, CRC(dd785590) SHA1(7ba6b6f6091595852d6feaef5a029b2aca684440) )
243   ROM_LOAD( "ms07.8n",      0x0000, 0x0200, CRC(e278d03a) SHA1(c40975e5807936fed40cda4a6881f6aef0e7f350) )
244   ROM_LOAD( "ms06.8m",      0x0000, 0x0200, CRC(fe6c9192) SHA1(d110e010cf685ee18479ca7f890fa9da2fa71603) )
245   ROM_LOAD( "ms05.11f",     0x0000, 0x0020, CRC(845fe0cc) SHA1(ce8db615c1f7be242fc2ee25c1ef75e8608a771a) )
246   ROM_LOAD( "ms05.11e",     0x0000, 0x0020, CRC(845fe0cc) SHA1(ce8db615c1f7be242fc2ee25c1ef75e8608a771a) )
247   ROM_LOAD( "ms04.7n",      0x0000, 0x0020, CRC(34d0bee4) SHA1(41848def6aeb128ec985c158f3ed01c5b20bdcf6) )
248   ROM_LOAD( "ms03.3f",      0x0000, 0x0020, CRC(d139f5fa) SHA1(29c05143d05553c2cb2831f9624f307f59436850) )
249   ROM_LOAD( "ms02.12l",     0x0000, 0x0020, CRC(157b7e68) SHA1(d1a98267af1562e6126faaf0850906224f8a608d) )
250   ROM_LOAD( "ms01.8d",      0x0000, 0x0020, CRC(e89e76c3) SHA1(1149b5d1f93baa8aecd54a618083cc13b63a894d) )
242   ROM_LOAD( "ms08.2c",      0x0000, 0x0200, CRC(dd785590) SHA1(7ba6b6f6091595852d6feaef5a029b2aca684440) )
243   ROM_LOAD( "ms07.8n",      0x0000, 0x0200, CRC(e278d03a) SHA1(c40975e5807936fed40cda4a6881f6aef0e7f350) )
244   ROM_LOAD( "ms06.8m",      0x0000, 0x0200, CRC(fe6c9192) SHA1(d110e010cf685ee18479ca7f890fa9da2fa71603) )
245   ROM_LOAD( "ms05.11f",     0x0000, 0x0020, CRC(845fe0cc) SHA1(ce8db615c1f7be242fc2ee25c1ef75e8608a771a) )
246   ROM_LOAD( "ms05.11e",     0x0000, 0x0020, CRC(845fe0cc) SHA1(ce8db615c1f7be242fc2ee25c1ef75e8608a771a) )
247   ROM_LOAD( "ms04.7n",      0x0000, 0x0020, CRC(34d0bee4) SHA1(41848def6aeb128ec985c158f3ed01c5b20bdcf6) )
248   ROM_LOAD( "ms03.3f",      0x0000, 0x0020, CRC(d139f5fa) SHA1(29c05143d05553c2cb2831f9624f307f59436850) )
249   ROM_LOAD( "ms02.12l",     0x0000, 0x0020, CRC(157b7e68) SHA1(d1a98267af1562e6126faaf0850906224f8a608d) )
250   ROM_LOAD( "ms01.8d",      0x0000, 0x0020, CRC(e89e76c3) SHA1(1149b5d1f93baa8aecd54a618083cc13b63a894d) )
251251ROM_END
252252
253253
trunk/src/mame/drivers/toaplan2.c
r243230r243231
30493049GFXDECODE_END
30503050
30513051
3052WRITE_LINE_MEMBER(toaplan2_state::bbakraid_irqhandler)
3053{
3054   // Not used ???  Connected to a test pin (TP082)
3055   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
3056}
3057
3058
30523059static MACHINE_CONFIG_START( tekipaki, toaplan2_state )
30533060
30543061   /* basic machine hardware */
r243230r243231
39964003   MCFG_SPEAKER_STANDARD_MONO("mono")
39974004
39984005   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
3999   // IRQ not used ???  Connected to a test pin (TP082)
4006   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(toaplan2_state, bbakraid_irqhandler))
40004007   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
40014008MACHINE_CONFIG_END
40024009
trunk/src/mame/drivers/tourtabl.c
r243230r243231
2121      m_maincpu(*this, "maincpu") { }
2222
2323   required_device<cpu_device> m_maincpu;
24
24   
2525   DECLARE_WRITE8_MEMBER(tourtabl_led_w);
2626   DECLARE_READ16_MEMBER(tourtabl_read_input_port);
2727   DECLARE_READ8_MEMBER(tourtabl_get_databus_contents);
trunk/src/mame/drivers/twinkle.c
r243230r243231
669669
670670WRITE8_MEMBER(twinkle_state::shared_psx_w)
671671{
672//  printf("shared_psx_w: %04x, %04x, %04x\n", offset, data, mem_mask);
672//   printf("shared_psx_w: %04x, %04x, %04x\n", offset, data, mem_mask);
673673
674674   m_spu_shared[offset] = data;
675675
676676   if (offset == 0x03fe && data == 0xff)
677677   {
678//      printf("spu command %02x %02x\n", m_spu_shared[1], m_spu_shared[3]);
678//      printf("spu command %02x %02x\n", m_spu_shared[1], m_spu_shared[3]);
679679
680680      m_audiocpu->set_input_line(M68K_IRQ_4, HOLD_LINE);
681681   }
r243230r243231
785785            //           work for us until we figure out what's actually going on.
786786            if (m_spu_ata_dma < 0x200000)
787787            {
788               m_waveram[m_spu_ata_dma++] = data;
788               m_waveram[m_spu_ata_dma++] = data;
789789            }
790790         }
791791
r243230r243231
808808{
809809   UINT16 result = m_spu_shared[offset];
810810
811//  printf("shared_68k_r: %04x, %04x, %04x\n", offset, result, mem_mask);
811//   printf("shared_68k_r: %04x, %04x, %04x\n", offset, result, mem_mask);
812812
813813   return result;
814814}
815815
816816WRITE16_MEMBER(twinkle_state::shared_68k_w)
817817{
818//  printf("shared_68k_w: %04x, %04x, %04x\n", offset, data, mem_mask);
818//   printf("shared_68k_w: %04x, %04x, %04x\n", offset, data, mem_mask);
819819
820820   m_spu_shared[offset] = data & 0xff;
821821}
822822
823823READ16_MEMBER(twinkle_state::unk_68k_r)
824824{
825   return 0xffff;  // must return 0xff for 68000 POST to complete properly
825   return 0xffff;   // must return 0xff for 68000 POST to complete properly
826826}
827827
828828static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 16, twinkle_state )
r243230r243231
840840   AM_RANGE(0x34000e, 0x34000f) AM_WRITENOP
841841   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE("rfsnd", rf5c400_device, rf5c400_r, rf5c400_w)
842842   AM_RANGE(0x800000, 0xbfffff) AM_READWRITE(twinkle_waveram_r, twinkle_waveram_w )
843   AM_RANGE(0xfe0000, 0xffffff) AM_RAM // ...and the RAM test checks this last 128k (mirror of the work RAM at 0x100000?)
843   AM_RANGE(0xfe0000, 0xffffff) AM_RAM   // ...and the RAM test checks this last 128k (mirror of the work RAM at 0x100000?)
844844ADDRESS_MAP_END
845845
846846/* SCSI */
trunk/src/mame/drivers/tx1.c
r243230r243231
795795   ROM_REGION( 0x10000, "audio_cpu", 0 )
796796   ROM_LOAD( "8411-136027-157.11", 0x00000, 0x2000, CRC(10ae3075) SHA1(69c5f62f2473aba848383eed3cecf15e273d86ca) )
797797
798   ROM_REGION( 0x8000, "char_tiles", 0 )
798   ROM_REGION( 0x20000, "char_tiles", 0 )
799799   ROM_LOAD( "8411-136027-156.204", 0x0000, 0x4000, CRC(60f3c616) SHA1(59c4361891e4274e27e6279c919e8fd6803af7cf) )
800800   ROM_LOAD( "8411-136027-155.174", 0x4000, 0x4000, CRC(e59a6b72) SHA1(c10efa77ab421ac60b97227a8d547f50f8415670) )
801801
802   ROM_REGION( 0x10000, "obj_tiles", 0 )
802   ROM_REGION( 0x40000, "obj_tiles", 0 )
803803   ROM_LOAD( "8411-136027-114.203", 0x0000, 0x4000, CRC(fc91328b) SHA1(e57fd2056b65d37cf2e1f0af56616c6555df3006) )
804804   ROM_LOAD( "8411-136027-116.258", 0x4000, 0x4000, CRC(5745f671) SHA1(6e471633cd6de9926b3361a84430c088e1f6a097) )
805805   ROM_LOAD( "8411-136027-115.173", 0x8000, 0x4000, CRC(720e5873) SHA1(151d9063c35b26f5876cf94bdf0c2665ec701bbd) )
806806   ROM_LOAD( "8411-136027-117.232", 0xc000, 0x4000, CRC(3c68d0bc) SHA1(2dbaf2a268b90214fd61c016ac945d4371057826) )
807807
808   ROM_REGION( 0x6000, "road", 0 )
808   ROM_REGION( 0x40000, "gfx3", 0 )
809809   ROM_LOAD( "8411-136027-146.56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) )
810810   ROM_LOAD( "8411-136027-147.66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) )
811811   ROM_LOAD( "8411-136027-148.76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) )
r243230r243231
816816   ROM_LOAD16_BYTE( "136027-143.ic223",    0x8000, 0x0200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) )
817817   ROM_LOAD16_BYTE( "136027-142.ic213",    0x8001, 0x0200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) )
818818
819   ROM_REGION( 0x8000, "obj_map", 0 )
819   ROM_REGION( 0x50000, "obj_map", 0 )
820820   ROM_LOAD( "8411-136027-119.106", 0x0000, 0x4000, CRC(88eec0fb) SHA1(81d7a69dc1a4b3b81d7f28d97a3f80697cdcc6eb) )
821821   ROM_LOAD( "8411-136027-120.73",  0x4000, 0x4000, CRC(407cbe65) SHA1(e1c11b65f3c6abde6d55afeaffdb39cdd6d66377) )
822822
823   ROM_REGION( 0x6000, "obj_luts", 0 )
823   ROM_REGION( 0x50000, "user3", 0 )
824824   ROM_LOAD( "8411-136027-113.48",  0x0000, 0x2000, CRC(4b3d7956) SHA1(fc2432dd69f3be7007d4fd6f7c86c7c19453b1ba) )
825825   ROM_LOAD( "8411-136027-118.281", 0x2000, 0x4000, CRC(de418dc7) SHA1(1233e2f7499ec5a73a40ee336d3fe26c06187784) )
826826
r243230r243231
882882   ROM_REGION( 0x10000, "audio_cpu", 0 )
883883   ROM_LOAD( "tx1_22h.ic9", 0x00000, 0x2000, CRC(66376232) SHA1(b8a026dae47173e7760eea4f52e67e525ad1b70b) )
884884
885   ROM_REGION( 0x8000, "char_tiles", 0 )
885   ROM_REGION( 0x20000, "char_tiles", 0 )
886886   ROM_LOAD( "tx1_21a.ic204", 0x0000, 0x4000, CRC(cd3441ad) SHA1(8e6597b3177b8aaa34ed3373d85fc4b6231e1333) )
887887   ROM_LOAD( "tx1_20a.ic174", 0x4000, 0x4000, CRC(dbe595fc) SHA1(1ed2f775f0a1b46a2ffbc056eb4ef732ed546d3c) )
888888
889   ROM_REGION( 0x10000, "obj_tiles", 0 )
889   ROM_REGION( 0x40000, "obj_tiles", 0 )
890890   ROM_LOAD( "tx1_16b.ic203", 0x0000, 0x4000, CRC(1141c965) SHA1(4b90c1428bcbd72d0449c064856a5596269b3fc6) )
891891   ROM_LOAD( "tx1_18b.ic258", 0x4000, 0x4000, CRC(0ad36d68) SHA1(fd5a65c56557c1bc9c0f3916f15f62500b52bfe0) )
892892   ROM_LOAD( "tx1_15b.ic173", 0x8000, 0x4000, CRC(30d1a8d5) SHA1(b4c585b7b8a8920bb3949d643e9e10c17d4009a0) )
893893   ROM_LOAD( "tx1_17b.ic232", 0xc000, 0x4000, CRC(364bb354) SHA1(a26581ca1088b979285471e2c6595048df84d75e) )
894894
895   ROM_REGION( 0x6000, "road", 0 )
895   ROM_REGION( 0x40000, "gfx3", 0 )
896896   ROM_LOAD( "tx1_5a.ic56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) )
897897   ROM_LOAD( "tx1_6a.ic66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) )
898898   ROM_LOAD( "tx1_7a.ic76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) )
r243230r243231
903903   ROM_LOAD16_BYTE( "xb02b.ic223",   0x8000, 0x0200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) )
904904   ROM_LOAD16_BYTE( "xb01b.ic213",   0x8001, 0x0200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) )
905905
906   ROM_REGION( 0x8000, "obj_map", 0 )
906   ROM_REGION( 0x50000, "obj_map", 0 )
907907   ROM_LOAD( "tx1_14b.ic106", 0x0000, 0x4000, CRC(68c63d6e) SHA1(110e02b99c44d31041be588bd14642e26890ecbd) )
908908   ROM_LOAD( "tx1_13b.ic73",  0x4000, 0x4000, CRC(b0c581b2) SHA1(20926bc15e7c97045b219b828acfcdd99b8712a6) )
909909
910   ROM_REGION( 0x6000, "obj_luts", 0 )
910   ROM_REGION( 0x50000, "user3", 0 )
911911   ROM_LOAD( "tx1_12b.ic48",  0x0000, 0x2000, CRC(4b3d7956) SHA1(fc2432dd69f3be7007d4fd6f7c86c7c19453b1ba) )
912912   ROM_LOAD( "tx1_19b.ic281", 0x2000, 0x4000, CRC(cb250de6) SHA1(4bf3006986fb8cbb3dd4fa988e6471633614e4bb) )
913913
r243230r243231
963963   ROM_REGION( 0x10000, "audio_cpu", 0 ) /* Label was missing */
964964   ROM_LOAD( "8411-136027-157.11", 0x00000, 0x2000, CRC(10ae3075) SHA1(69c5f62f2473aba848383eed3cecf15e273d86ca) ) /* Unconfirmed TC013A or the later TC013B */
965965
966   ROM_REGION( 0x8000, "char_tiles", 0 )
966   ROM_REGION( 0x20000, "char_tiles", 0 )
967967   ROM_LOAD( "tx1_21a.ic204", 0x0000, 0x4000, CRC(cd3441ad) SHA1(8e6597b3177b8aaa34ed3373d85fc4b6231e1333) )
968968   ROM_LOAD( "tx1_20a.ic174", 0x4000, 0x4000, CRC(dbe595fc) SHA1(1ed2f775f0a1b46a2ffbc056eb4ef732ed546d3c) )
969969
970   ROM_REGION( 0x10000, "obj_tiles", 0 )
970   ROM_REGION( 0x40000, "obj_tiles", 0 )
971971   ROM_LOAD( "tx1_16b.ic203", 0x0000, 0x4000, CRC(1141c965) SHA1(4b90c1428bcbd72d0449c064856a5596269b3fc6) )
972972   ROM_LOAD( "tx1_18b.ic258", 0x4000, 0x4000, CRC(0ad36d68) SHA1(fd5a65c56557c1bc9c0f3916f15f62500b52bfe0) )
973973   ROM_LOAD( "tx1_15b.ic173", 0x8000, 0x4000, CRC(30d1a8d5) SHA1(b4c585b7b8a8920bb3949d643e9e10c17d4009a0) )
974974   ROM_LOAD( "tx1_17b.ic232", 0xc000, 0x4000, CRC(364bb354) SHA1(a26581ca1088b979285471e2c6595048df84d75e) )
975975
976   ROM_REGION( 0x6000, "road", 0 )
976   ROM_REGION( 0x40000, "gfx3", 0 )
977977   ROM_LOAD( "tx1_5a.ic56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) )
978978   ROM_LOAD( "tx1_6a.ic66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) )
979979   ROM_LOAD( "tx1_7a.ic76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) )
r243230r243231
984984   ROM_LOAD16_BYTE( "xb02b.ic223",   0x8000, 0x0200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) )
985985   ROM_LOAD16_BYTE( "xb01b.ic213",   0x8001, 0x0200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) )
986986
987   ROM_REGION( 0x8000, "obj_map", 0 )
987   ROM_REGION( 0x50000, "obj_map", 0 )
988988   ROM_LOAD( "tx1_14b.ic106", 0x0000, 0x4000, CRC(68c63d6e) SHA1(110e02b99c44d31041be588bd14642e26890ecbd) )
989989   ROM_LOAD( "tx1_13b.ic73",  0x4000, 0x4000, CRC(b0c581b2) SHA1(20926bc15e7c97045b219b828acfcdd99b8712a6) )
990990
991   ROM_REGION( 0x6000, "obj_luts", 0 )
991   ROM_REGION( 0x50000, "user3", 0 )
992992   ROM_LOAD( "tx1_12b.ic48",  0x0000, 0x2000, CRC(4b3d7956) SHA1(fc2432dd69f3be7007d4fd6f7c86c7c19453b1ba) )
993993   ROM_LOAD( "tx1_19b.ic281", 0x2000, 0x4000, CRC(cb250de6) SHA1(4bf3006986fb8cbb3dd4fa988e6471633614e4bb) )
994994
r243230r243231
10721072   ROM_LOAD( "bug25.157", 0x2c000, 0x4000, CRC(80c4e045) SHA1(be3b537d3ed3ee74fc51059aa744dca4d63431f6) )
10731073   ROM_RELOAD(            0x38000, 0x4000 )
10741074
1075   ROM_REGION( 0x8000, "road", 0 )
1075   ROM_REGION( 0x40000, "road", 0 )
10761076   ROM_LOAD( "bug12.58", 0x0000, 0x2000, CRC(bd34d55c) SHA1(05a719a6eff5af3aaaa1e0ee783b18597582ed64) )
10771077   ROM_LOAD( "bug11.57", 0x2000, 0x2000, CRC(a44d43eb) SHA1(c4d68c7e123506acaa6adc353579cac19ecb3a9d) )
10781078   ROM_LOAD( "bb3.137",  0x4000, 0x0200, CRC(ad76f3fb) SHA1(bf96f903b32e009a2592df0f28cc3e20b039f4d4) )
r243230r243231
10861086   ROM_LOAD16_BYTE( "bb1.245",   0x8000, 0x0200, CRC(0ddbd36d) SHA1(7a08901a350c315d46ab8d0aa881db384b9f37d2) )
10871087   ROM_LOAD16_BYTE( "bb2.220",   0x8001, 0x0200, CRC(71d47de1) SHA1(2da9aeb3f2ebb1114631c8042a37c4f4c18e741b) )
10881088
1089   ROM_REGION( 0x10000, "obj_map", 0 )
1089   ROM_REGION( 0x100000, "obj_map", 0 )
10901090   ROM_LOAD( "bug16.210", 0x0000, 0x4000, CRC(8b64409e) SHA1(1fb4c6923e6a9e1f2a63a2c335b63e2bdc44b61f) )
10911091   ROM_LOAD( "bug14.209", 0x4000, 0x4000, CRC(4e765282) SHA1(f7d69d39823a8b33bd0e5b1bd78a5d68a293e221) )
10921092   ROM_LOAD( "bug17.182", 0x8000, 0x4000, CRC(a5d84df6) SHA1(4e33ef0bee383e0d47b0c679cd2a54edb7ca0e3e) )
10931093   ROM_LOAD( "bug15.181", 0xc000, 0x4000, CRC(d519de10) SHA1(535d05e11af65be65f3d9924b0c48faf8dcfd1bf) )
10941094
1095   ROM_REGION( 0x6000, "obj_luts", 0 )
1095   ROM_REGION( 0x10000, "obj_luts", 0 )
10961096   ROM_LOAD( "bug13.124", 0x0000, 0x2000, CRC(53604d7a) SHA1(bfa304cd885162ece7a5f54988d9880fc541eb3a) )
10971097   ROM_LOAD( "bug18.156", 0x2000, 0x4000, CRC(e58321a6) SHA1(81be87d3c6046bb375c74362dc940f0269b39d1d) )
10981098
r243230r243231
11611161   ROM_LOAD( "bug30s.145", 0x20000, 0x8000, CRC(11d8e2a8) SHA1(9bf198229a12d331e8e7352b7ee3f39f6891f517) )
11621162   ROM_LOAD( "bug23s.142", 0x28000, 0x8000, CRC(015db5d8) SHA1(39ef8b44f2eb9399fb1555cffa6763e06d59c181) )
11631163
1164   ROM_REGION( 0x8000, "road", 0 )
1164   ROM_REGION( 0x40000, "road", 0 )
11651165   ROM_LOAD( "bug11s.225",0x0000, 0x4000, CRC(771af4e1) SHA1(a42b164dd0567c78c0d308ee48d63e5a284897bb) )
11661166   ROM_LOAD( "bb3s.195",  0x4000, 0x0200, CRC(2ab3d5ff) SHA1(9f8359cb4ba2e7d15dbb9dc21cd71c0902cd2153) )
11671167   ROM_LOAD( "bb4s.193",  0x4200, 0x0200, CRC(630f68a4) SHA1(d730f050353c688f81d090e33e00cd35e7b7b6fa) )
r243230r243231
11741174   ROM_LOAD16_BYTE( "bb1.163",  0x8000, 0x0200, CRC(0ddbd36d) SHA1(7a08901a350c315d46ab8d0aa881db384b9f37d2) )
11751175   ROM_LOAD16_BYTE( "bb2.162",  0x8001, 0x0200, CRC(71d47de1) SHA1(2da9aeb3f2ebb1114631c8042a37c4f4c18e741b) )
11761176
1177   ROM_REGION( 0x10000, "obj_map", 0 )
1177   ROM_REGION( 0x100000, "obj_map", 0 )
11781178   ROM_LOAD( "bug16s.139", 0x0000, 0x8000, CRC(1903a9ad) SHA1(526c404c15e3f04b4afb27dee66e9deb0a6b9704) )
11791179   ROM_LOAD( "bug17s.140", 0x8000, 0x8000, CRC(82cabdd4) SHA1(94324fcf83c373621fc40553473ae3cb552ab704) )
11801180
1181   ROM_REGION( 0x6000, "obj_luts", 0 )
1181   ROM_REGION( 0x10000, "obj_luts", 0 )
11821182   ROM_LOAD( "bug13.32",   0x0000, 0x2000, CRC(53604d7a) SHA1(bfa304cd885162ece7a5f54988d9880fc541eb3a) )
11831183   ROM_LOAD( "bug18s.141", 0x2000, 0x4000, CRC(67786327) SHA1(32cc1f5bc654497c968ddcd4af29720c6d659482) )
11841184
trunk/src/mame/drivers/vegaeo.c
r243230r243231
2626
2727   UINT32 *m_vega_vram;
2828   UINT8 m_vega_vbuffer;
29
29   
3030   DECLARE_WRITE32_MEMBER(vega_vram_w);
3131   DECLARE_READ32_MEMBER(vega_vram_r);
3232   DECLARE_WRITE32_MEMBER(vega_misc_w);
trunk/src/mame/drivers/vicdual.c
r243230r243231
35353535GAME( 1981, pulsar,     0,        pulsar,    pulsar,    driver_device, 0, ROT270, "Sega", "Pulsar", GAME_IMPERFECT_SOUND )
35363536GAME( 1979, heiankyo,   0,        heiankyo,  heiankyo,  driver_device, 0, ROT270, "Denki Onkyo", "Heiankyo Alien", GAME_NO_SOUND )
35373537GAME( 19??, alphaho,    0,        alphaho,   alphaho,   driver_device, 0, ROT270, "Data East Corporation", "Alpha Fighter / Head On", GAME_WRONG_COLORS | GAME_NO_SOUND )
3538
trunk/src/mame/drivers/zn.c
r243230r243231
9090   DECLARE_WRITE8_MEMBER(coh1001l_bank_w);
9191   DECLARE_WRITE16_MEMBER(coh1001l_latch_w);
9292   DECLARE_WRITE16_MEMBER(coh1001l_sound_unk_w);
93   DECLARE_WRITE_LINE_MEMBER(coh1001l_ymz_irq);
9394   DECLARE_WRITE8_MEMBER(coh1002v_bank_w);
9495   DECLARE_WRITE8_MEMBER(coh1002m_bank_w);
9596   DECLARE_READ8_MEMBER(cbaj_sound_main_status_r);
r243230r243231
22722273      VSync        - 60Hz
22732274*/
22742275
2276WRITE_LINE_MEMBER(zn_state::coh1001l_ymz_irq)
2277{
2278   m_audiocpu->set_input_line(2, state ? ASSERT_LINE : CLEAR_LINE);
2279}
2280
22752281WRITE16_MEMBER(zn_state::coh1001l_sound_unk_w)
22762282{
22772283   // irq ack maybe?
r243230r243231
23202326   MCFG_MACHINE_RESET_OVERRIDE(zn_state, coh1001l)
23212327
23222328   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
2323   MCFG_YMZ280B_IRQ_HANDLER(INPUTLINE("audiocpu", 2))
2329   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(zn_state, coh1001l_ymz_irq))
23242330   MCFG_SOUND_ROUTE(0, "lspeaker", 0.35)
23252331   MCFG_SOUND_ROUTE(1, "rspeaker", 0.35)
23262332MACHINE_CONFIG_END
trunk/src/mame/includes/bfm_sc45.h
r243230r243231
592592   DECLARE_MACHINE_START(sc4);
593593   DECLARE_MACHINE_RESET(sc4);
594594
595   DECLARE_WRITE_LINE_MEMBER(bfm_sc4_irqhandler);
595596
596597   void bfm_sc4_68307_porta_w(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask);
597598   DECLARE_WRITE8_MEMBER( bfm_sc4_reel3_w );
trunk/src/mame/includes/bfm_sc5.h
r243230r243231
1616   required_device<m68000_base_device> m_maincpu;
1717
1818   DECLARE_DRIVER_INIT(sc5);
19   DECLARE_WRITE_LINE_MEMBER(bfm_sc5_ym_irqhandler);
1920   DECLARE_READ8_MEMBER( sc5_10202F0_r );
2021   DECLARE_WRITE8_MEMBER( sc5_10202F0_w );
2122   DECLARE_WRITE16_MEMBER( sc5_duart_w );
trunk/src/mame/includes/bishi.h
r243230r243231
5555   virtual void video_start();
5656   UINT32 screen_update_bishi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5757   TIMER_DEVICE_CALLBACK_MEMBER(bishi_scanline);
58   DECLARE_WRITE_LINE_MEMBER(sound_irq_gen);
5859   K056832_CB_MEMBER(tile_callback);
5960};
trunk/src/mame/includes/bogeyman.h
r243230r243231
2121      m_colorram(*this, "colorram"),
2222      m_colorram2(*this, "colorram2"),
2323      m_spriteram(*this, "spriteram")  { }
24
24   
2525   /* devices */
2626   required_device<cpu_device> m_maincpu;
2727   required_device<gfxdecode_device> m_gfxdecode;
2828   required_device<palette_device> m_palette;
2929   required_device<ay8910_device> m_ay1;
3030   required_device<ay8910_device> m_ay2;
31
31   
3232   /* memory pointers */
3333   required_shared_ptr<UINT8> m_videoram;
3434   required_shared_ptr<UINT8> m_videoram2;
r243230r243231
4545   int        m_psg_latch;
4646   int        m_last_write;
4747   int        m_colbank;
48
48   
4949   DECLARE_WRITE8_MEMBER(ay8910_latch_w);
5050   DECLARE_WRITE8_MEMBER(ay8910_control_w);
5151   DECLARE_WRITE8_MEMBER(videoram_w);
r243230r243231
5454   DECLARE_WRITE8_MEMBER(colorram2_w);
5555   DECLARE_WRITE8_MEMBER(paletteram_w);
5656   DECLARE_WRITE8_MEMBER(colbank_w);
57
57   
5858   TILE_GET_INFO_MEMBER(get_bg_tile_info);
5959   TILE_GET_INFO_MEMBER(get_fg_tile_info);
60
60   
6161   virtual void machine_start();
6262   virtual void machine_reset();
6363   virtual void video_start();
64
64   
6565   DECLARE_PALETTE_INIT(bogeyman);
6666   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6767   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
trunk/src/mame/includes/calomega.h
r243230r243231
5151   TILE_GET_INFO_MEMBER(get_bg_tile_info);
5252   UINT32 screen_update_calomega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   DECLARE_PALETTE_INIT(calomega);
54
54   
5555protected:
5656   virtual void video_start();
5757
r243230r243231
6464
6565   required_shared_ptr<UINT8> m_videoram;
6666   required_shared_ptr<UINT8> m_colorram;
67
67   
6868   optional_ioport m_in0;
6969   optional_ioport m_in0_0;
7070   optional_ioport m_in0_1;
r243230r243231
7272   optional_ioport m_in0_3;
7373   optional_ioport m_frq;
7474   optional_ioport m_sw2;
75
75     
7676   UINT8 m_tx_line;
7777   int m_s903_mux_data;
7878   int m_s905_mux_data;
trunk/src/mame/includes/cave.h
r243230r243231
3737         m_paletteram(*this, "paletteram"),
3838         m_maincpu(*this, "maincpu"),
3939         m_audiocpu(*this, "audiocpu"),
40         m_nmk112(*this, "nmk112"),
4041         m_oki(*this, "oki"),
4142         m_int_timer(*this, "int_timer"),
4243         m_int_timer_left(*this, "int_timer_left"),
r243230r243231
121122   /* devices */
122123   required_device<cpu_device> m_maincpu;
123124   optional_device<cpu_device> m_audiocpu;
125   optional_device<nmk112_device> m_nmk112;
124126   optional_device<okim6295_device> m_oki;
125127   required_device<timer_device> m_int_timer;
126128   optional_device<timer_device> m_int_timer_left;
trunk/src/mame/includes/dec0.h
r243230r243231
2424      m_paletteram(*this, "palette"),
2525      m_robocop_shared_ram(*this, "robocop_shared"),
2626      m_hippodrm_shared_ram(*this, "hippodrm_shared") { }
27
27     
2828   required_device<cpu_device> m_maincpu;
2929   required_device<cpu_device> m_audiocpu;
3030   optional_device<cpu_device> m_subcpu;
r243230r243231
7777   DECLARE_READ16_MEMBER(ffantasybl_242024_r);
7878   DECLARE_WRITE_LINE_MEMBER(sound_irq);
7979   DECLARE_WRITE_LINE_MEMBER(sound_irq2);
80
80   
8181   DECLARE_DRIVER_INIT(robocop);
8282   DECLARE_DRIVER_INIT(hippodrm);
8383   DECLARE_DRIVER_INIT(hbarrel);
r243230r243231
8686   DECLARE_DRIVER_INIT(baddudes);
8787   DECLARE_DRIVER_INIT(midresb);
8888   DECLARE_DRIVER_INIT(ffantasybl);
89
89   
9090   virtual void machine_start();
9191   DECLARE_MACHINE_RESET(slyspy);
9292   DECLARE_VIDEO_START(dec0);
9393   DECLARE_VIDEO_START(dec0_nodma);
94
94   
9595   UINT32 screen_update_hbarrel(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9696   UINT32 screen_update_baddudes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9797   UINT32 screen_update_birdtry(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
r243230r243231
9999   UINT32 screen_update_hippodrm(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
100100   UINT32 screen_update_slyspy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
101101   UINT32 screen_update_midres(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
102
102   
103103   void baddudes_i8751_write(int data);
104104   void birdtry_i8751_write(int data);
105105   void dec0_i8751_write(int data);
r243230r243231
118118   UINT8 m_automat_adpcm_byte;
119119   int m_automat_msm5205_vclk_toggle;
120120   UINT16 m_automat_scroll_regs[4];
121
121   
122122   DECLARE_WRITE16_MEMBER(automat_control_w);
123123   DECLARE_WRITE8_MEMBER(automat_adpcm_w);
124124   DECLARE_READ16_MEMBER( automat_palette_r );
r243230r243231
128128      COMBINE_DATA(&m_automat_scroll_regs[offset]);
129129   }
130130   DECLARE_WRITE_LINE_MEMBER(automat_vclk_cb);
131
131   
132132   virtual void machine_start();
133
133   
134134   UINT32 screen_update_automat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
135135   UINT32 screen_update_secretab(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
136136};
trunk/src/mame/includes/dynax.h
r243230r243231
213213   DECLARE_WRITE8_MEMBER(jantouki_blitter2_rev2_w);
214214   DECLARE_WRITE8_MEMBER(hanamai_priority_w);
215215   DECLARE_WRITE8_MEMBER(tenkai_priority_w);
216
216   
217217   DECLARE_DRIVER_INIT(mjelct3);
218218   DECLARE_DRIVER_INIT(blktouch);
219219   DECLARE_DRIVER_INIT(mjelct3a);
220220   DECLARE_DRIVER_INIT(mjreach);
221221   DECLARE_DRIVER_INIT(maya);
222
222   
223223   UINT32 screen_update_hanamai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
224224   UINT32 screen_update_hnoridur(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
225225   UINT32 screen_update_sprtmtch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
226226   UINT32 screen_update_mjdialq2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
227227   UINT32 screen_update_jantouki_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
228228   UINT32 screen_update_jantouki_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
229
229   
230230   INTERRUPT_GEN_MEMBER(sprtmtch_vblank_interrupt);
231231   INTERRUPT_GEN_MEMBER(jantouki_vblank_interrupt);
232232   INTERRUPT_GEN_MEMBER(jantouki_sound_vblank_interrupt);
233233   INTERRUPT_GEN_MEMBER(yarunara_clock_interrupt);
234234   INTERRUPT_GEN_MEMBER(mjelctrn_vblank_interrupt);
235
235   
236236   TIMER_DEVICE_CALLBACK_MEMBER(neruton_irq_scanline);
237237   TIMER_DEVICE_CALLBACK_MEMBER(majxtal7_vblank_interrupt);
238238   TIMER_DEVICE_CALLBACK_MEMBER(tenkai_interrupt);
239
239   
240240   void tenkai_update_rombank();
241241   void gekisha_bank_postload();
242
242   
243243   DECLARE_WRITE_LINE_MEMBER(sprtmtch_sound_callback);
244244   DECLARE_WRITE_LINE_MEMBER(jantouki_sound_callback);
245245   DECLARE_WRITE_LINE_MEMBER(adpcm_int);
r243230r243231
268268   DECLARE_VIDEO_START(mcnpshnt);
269269   DECLARE_PALETTE_INIT(janyuki);
270270   DECLARE_VIDEO_START(neruton);
271
271   
272272   inline void blitter_plot_pixel( int layer, int mask, int x, int y, int pen, int wrap, int flags );
273273   int blitter_drawgfx( int layer, int mask, const char *gfx, int src, int pen, int x, int y, int wrap, int flags );
274274   void dynax_blitter_start( int flags );
trunk/src/mame/includes/eolith.h
r243230r243231
2727   optional_device<qs1000_device> m_qs1000;
2828   required_device<screen_device> m_screen;
2929   required_device<palette_device> m_palette;
30
30   
3131   optional_ioport m_in0; // klondkp doesn't have it
3232   optional_ioport m_eepromoutport;
3333   optional_ioport m_penx1port;
3434   optional_ioport m_peny1port;
3535   optional_ioport m_penx2port;
3636   optional_ioport m_peny2port;
37
37   
3838   optional_memory_bank m_sndbank;
39
39   
4040   int m_coin_counter_bit;
4141   int m_buffer;
4242   UINT32 *m_vram;
4343
4444   UINT8 m_sound_data;
45
45   
4646   // speedups - see machine/eolithsp.c
4747   int m_speedup_address;
4848   int m_speedup_address2;
r243230r243231
6666   DECLARE_READ8_MEMBER(qs1000_p1_r);
6767   DECLARE_WRITE8_MEMBER(qs1000_p1_w);
6868   DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000);
69
69   
7070   DECLARE_DRIVER_INIT(eolith);
7171   DECLARE_DRIVER_INIT(landbrk);
7272   DECLARE_DRIVER_INIT(hidctch3);
7373   DECLARE_DRIVER_INIT(hidctch2);
7474   DECLARE_DRIVER_INIT(hidnc2k);
7575   DECLARE_DRIVER_INIT(landbrka);
76
76   
7777   DECLARE_MACHINE_RESET(eolith);
7878   DECLARE_VIDEO_START(eolith);
79
79   
8080   UINT32 screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
81
81   
8282   TIMER_DEVICE_CALLBACK_MEMBER(eolith_speedup);
8383};
trunk/src/mame/includes/exidy.h
r243230r243231
5757   required_device<gfxdecode_device> m_gfxdecode;
5858   required_device<screen_device> m_screen;
5959   required_device<palette_device> m_palette;
60
60   
6161   required_shared_ptr<UINT8> m_videoram;
6262   required_shared_ptr<UINT8> m_sprite1_xpos;
6363   required_shared_ptr<UINT8> m_sprite1_ypos;
r243230r243231
7777   bitmap_ind16 m_motion_object_1_vid;
7878   bitmap_ind16 m_motion_object_2_vid;
7979   bitmap_ind16 m_motion_object_2_clip;
80
80   
8181   DECLARE_WRITE8_MEMBER(fax_bank_select_w);
8282   DECLARE_READ8_MEMBER(exidy_interrupt_r);
83
83   
8484   DECLARE_CUSTOM_INPUT_MEMBER(teetert_input_r);
85
85   
8686   DECLARE_DRIVER_INIT(fax);
8787   DECLARE_DRIVER_INIT(sidetrac);
8888   DECLARE_DRIVER_INIT(pepper2);
r243230r243231
9393   DECLARE_DRIVER_INIT(venture);
9494   DECLARE_DRIVER_INIT(spectar);
9595   DECLARE_DRIVER_INIT(phantoma);
96
96   
9797   virtual void video_start();
9898   DECLARE_MACHINE_START(teetert);
99
99   
100100   UINT32 screen_update_exidy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
101
101   
102102   INTERRUPT_GEN_MEMBER(exidy_vblank_interrupt);
103
103   
104104   void exidy_video_config(UINT8 _collision_mask, UINT8 _collision_invert, int _is_2bpp);
105105   inline void latch_condition(int collision);
106106   inline void set_1_color(int index, int which);
trunk/src/mame/includes/hyhoo.h
r243230r243231
3232   int m_highcolorflag;
3333   int m_flipscreen;
3434   bitmap_rgb32 m_tmpbitmap;
35
35   
3636   DECLARE_WRITE8_MEMBER(hyhoo_blitter_w);
3737   DECLARE_WRITE8_MEMBER(hyhoo_romsel_w);
38
38   
3939   DECLARE_CUSTOM_INPUT_MEMBER(nb1413m3_busyflag_r);
40
40   
4141   virtual void video_start();
42
42   
4343   UINT32 screen_update_hyhoo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
4444   void hyhoo_gfxdraw();
4545
trunk/src/mame/includes/lordgun.h
r243230r243231
1717public:
1818   lordgun_state(const machine_config &mconfig, device_type type, const char *tag)
1919      : driver_device(mconfig, type, tag),
20         m_priority_ram(*this, "priority_ram"),
21         m_scrollram(*this, "scrollram"),
22         m_spriteram(*this, "spriteram"),
23         m_vram(*this, "vram"),
24         m_scroll_x(*this, "scroll_x"),
25         m_scroll_y(*this, "scroll_y") ,
2026      m_maincpu(*this, "maincpu"),
2127      m_soundcpu(*this, "soundcpu"),
2228      m_oki(*this, "oki"),
r243230r243231
2430      m_gfxdecode(*this, "gfxdecode"),
2531      m_screen(*this, "screen"),
2632      m_palette(*this, "palette"),
27      m_generic_paletteram_16(*this, "paletteram"),
28      m_priority_ram(*this, "priority_ram"),
29      m_scrollram(*this, "scrollram"),
30      m_spriteram(*this, "spriteram"),
31      m_vram(*this, "vram"),
32      m_scroll_x(*this, "scroll_x"),
33      m_scroll_y(*this, "scroll_y") { }
33      m_generic_paletteram_16(*this, "paletteram") { }
3434
35   required_device<cpu_device> m_maincpu;
36   required_device<cpu_device> m_soundcpu;
37   required_device<okim6295_device> m_oki;
38   required_device<eeprom_serial_93cxx_device> m_eeprom;
39   required_device<gfxdecode_device> m_gfxdecode;
40   required_device<screen_device> m_screen;
41   required_device<palette_device> m_palette;
42   
43   required_shared_ptr<UINT16> m_generic_paletteram_16;
4435   required_shared_ptr<UINT16> m_priority_ram;
4536   required_shared_ptr<UINT16> m_scrollram;
4637   required_shared_ptr<UINT16> m_spriteram;
47   required_shared_ptr_array<UINT16, 4> m_vram;
48   required_shared_ptr_array<UINT16, 4> m_scroll_x;
49   required_shared_ptr_array<UINT16, 4> m_scroll_y;
5038
5139   UINT8 m_old;
5240   UINT8 m_aliencha_dip_sel;
5341   UINT16 m_priority;
42   required_shared_ptr_array<UINT16, 4> m_vram;
43   required_shared_ptr_array<UINT16, 4> m_scroll_x;
44   required_shared_ptr_array<UINT16, 4> m_scroll_y;
5445   int m_whitescreen;
5546   lordgun_gun_data m_gun[2];
5647   tilemap_t *m_tilemap[4];
5748   bitmap_ind16 *m_bitmaps[5];
5849
59   UINT16 m_protection_data;
50   UINT16 m_lordgun_protection_data;
6051   DECLARE_WRITE16_MEMBER(lordgun_protection_w);
6152   DECLARE_READ16_MEMBER(lordgun_protection_r);
6253   DECLARE_WRITE16_MEMBER(aliencha_protection_w);
r243230r243231
8071   DECLARE_READ8_MEMBER(aliencha_dip_r);
8172   DECLARE_WRITE8_MEMBER(aliencha_dip_w);
8273   DECLARE_WRITE8_MEMBER(lordgun_okibank_w);
83
84   DECLARE_DRIVER_INIT(aliencha);
8574   DECLARE_DRIVER_INIT(lordgun);
86
8775   TILE_GET_INFO_MEMBER(get_tile_info_0);
8876   TILE_GET_INFO_MEMBER(get_tile_info_1);
8977   TILE_GET_INFO_MEMBER(get_tile_info_2);
9078   TILE_GET_INFO_MEMBER(get_tile_info_3);
91
92   virtual void machine_start();
9379   virtual void video_start();
94
9580   UINT32 screen_update_lordgun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9681   inline void get_tile_info(tile_data &tileinfo, tilemap_memory_index tile_index, int _N_);
9782   inline void lordgun_vram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _N_);
9883   void lorddgun_calc_gun_scr(int i);
9984   void lordgun_update_gun(int i);
10085   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
86   required_device<cpu_device> m_maincpu;
87   required_device<cpu_device> m_soundcpu;
88   required_device<okim6295_device> m_oki;
89   required_device<eeprom_serial_93cxx_device> m_eeprom;
90   required_device<gfxdecode_device> m_gfxdecode;
91   required_device<screen_device> m_screen;
92   required_device<palette_device> m_palette;
93   required_shared_ptr<UINT16> m_generic_paletteram_16;
10194};
10295
10396/*----------- defined in video/lordgun.c -----------*/
trunk/src/mame/includes/m58.h
r243230r243231
1313      m_scroll_x_high(*this, "scroll_x_high"),
1414      m_scroll_y_low(*this, "scroll_y_low"),
1515      m_score_panel_disabled(*this, "score_disable") { }
16
16   
1717   /* devices */
1818   required_device<cpu_device> m_maincpu;
1919   required_device<gfxdecode_device> m_gfxdecode;
2020   required_device<screen_device> m_screen;
2121   required_device<palette_device> m_palette;
22
22   
2323   /* memory pointers */
2424   required_shared_ptr<UINT8> m_videoram;
2525   required_shared_ptr<UINT8> m_spriteram;
r243230r243231
3131   /* video-related */
3232   tilemap_t*             m_bg_tilemap;
3333   bitmap_ind16             m_scroll_panel_bitmap;
34
34   
3535   DECLARE_WRITE8_MEMBER(videoram_w);
3636   DECLARE_WRITE8_MEMBER(scroll_panel_w);
3737   DECLARE_WRITE8_MEMBER(flipscreen_w);
38
38   
3939   DECLARE_DRIVER_INIT(yard85);
4040   virtual void video_start();
4141   DECLARE_PALETTE_INIT(m58);
42
42   
4343   TILE_GET_INFO_MEMBER(get_bg_tile_info);
4444   TILEMAP_MAPPER_MEMBER(tilemap_scan_rows);
45
45   
4646   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4747   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
4848   void draw_panel( bitmap_ind16 &bitmap, const rectangle &cliprect );
trunk/src/mame/includes/mario.h
r243230r243231
5454      m_discrete(*this, "discrete"),
5555#else
5656      m_audio_snd0(*this, "snd_nl:snd0"),
57      m_audio_snd7(*this, "snd_nl:snd7"),
58      m_audio_dac(*this, "snd_nl:dac"),
57        m_audio_snd7(*this, "snd_nl:snd7"),
58        m_audio_dac(*this, "snd_nl:dac"),
5959#endif
6060      m_spriteram(*this, "spriteram"),
6161      m_videoram(*this, "videoram"),
r243230r243231
7171   optional_device<discrete_device> m_discrete;
7272#else
7373   optional_device<netlist_mame_logic_input_t> m_audio_snd0;
74   optional_device<netlist_mame_logic_input_t> m_audio_snd7;
75   optional_device<netlist_mame_logic_input_t> m_audio_dac;
74    optional_device<netlist_mame_logic_input_t> m_audio_snd7;
75    optional_device<netlist_mame_logic_input_t> m_audio_dac;
7676#endif
7777
7878   /* memory pointers */
trunk/src/mame/includes/model2.h
r243230r243231
224224   DECLARE_WRITE32_MEMBER(copro_tgp_fifoout_push);
225225   DECLARE_READ8_MEMBER(virtuacop_lightgun_r);
226226   DECLARE_READ8_MEMBER(virtuacop_lightgun_offscreen_r);
227
227   
228228   UINT16 crypt_read_callback(UINT32 addr);
229229
230230   bool copro_fifoin_pop(device_t *device, UINT32 *result,UINT32 offset, UINT32 mem_mask);
trunk/src/mame/includes/nb1413m3.h
r243230r243231
129129
130130   // (static) configuration helpers
131131   static void set_type(device_t &device, int type) { downcast<nb1413m3_device &>(device).m_nb1413m3_type = type; }
132
132   
133133   enum
134134   {
135135      TIMER_CB
r243230r243231
169169   virtual void device_start();
170170   virtual void device_reset();
171171   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
172
172   
173173private:
174174
175175   int m_74ls193_counter;
trunk/src/mame/includes/nmk16.h
r243230r243231
1111      m_audiocpu(*this, "audiocpu"),
1212      m_oki1(*this, "oki1"),
1313      m_oki2(*this, "oki2"),
14      m_nmk112(*this, "nmk112"),
1415      m_nmk_bgvideoram0(*this, "nmk_bgvideoram0"),
1516      m_nmk_txvideoram(*this, "nmk_txvideoram"),
1617      m_mainram(*this, "mainram"),
r243230r243231
3334   optional_device<cpu_device> m_audiocpu;
3435   optional_device<okim6295_device> m_oki1;
3536   optional_device<okim6295_device> m_oki2;
37   optional_device<nmk112_device> m_nmk112;
3638   required_shared_ptr<UINT16> m_nmk_bgvideoram0;
3739   optional_shared_ptr<UINT16> m_nmk_txvideoram;
3840   required_shared_ptr<UINT16> m_mainram;
r243230r243231
194196   void decode_gfx();
195197   void decode_tdragonb();
196198   void decode_ssmissin();
199   DECLARE_WRITE_LINE_MEMBER(ym2203_irqhandler);
200
197201};
trunk/src/mame/includes/paradise.h
r243230r243231
1616      m_videoram(*this, "videoram"),
1717      m_paletteram(*this, "paletteram"),
1818      m_spriteram(*this, "spriteram") { }
19
19     
2020   /* devices */
2121   required_device<cpu_device> m_maincpu;
2222   optional_device<okim6295_device> m_oki2;
r243230r243231
3636   tilemap_t *m_tilemap_0;
3737   tilemap_t *m_tilemap_1;
3838   tilemap_t *m_tilemap_2;
39
39   
4040   bitmap_ind16 m_tmpbitmap;
4141   UINT8 m_palbank;
4242   UINT8 m_priority;
4343   UINT8 m_pixbank;
4444   int m_sprite_inc;
4545   int m_irq_count;
46
46   
4747   DECLARE_WRITE8_MEMBER(paradise_rombank_w);
4848   DECLARE_WRITE8_MEMBER(torus_coin_counter_w);
4949   DECLARE_WRITE8_MEMBER(paradise_flipscreen_w);
r243230r243231
5656   DECLARE_WRITE8_MEMBER(paradise_pixmap_w);
5757   DECLARE_WRITE8_MEMBER(paradise_priority_w);
5858   DECLARE_WRITE8_MEMBER(paradise_okibank_w);
59
59   
6060   DECLARE_DRIVER_INIT(torus);
6161   DECLARE_DRIVER_INIT(paradise);
6262   DECLARE_DRIVER_INIT(tgtball);
63
63   
6464   TILE_GET_INFO_MEMBER(get_tile_info_0);
6565   TILE_GET_INFO_MEMBER(get_tile_info_1);
6666   TILE_GET_INFO_MEMBER(get_tile_info_2);
67
67   
6868   virtual void machine_start();
6969   virtual void machine_reset();
7070   virtual void video_start();
71
71   
7272   UINT32 screen_update_paradise(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7373   UINT32 screen_update_torus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7474   UINT32 screen_update_madball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
75
75   
7676   INTERRUPT_GEN_MEMBER(paradise_irq);
77
77   
7878   void update_pix_palbank();
7979   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
8080};
trunk/src/mame/includes/pastelg.h
r243230r243231
3434   int m_palbank;
3535   UINT8 *m_videoram;
3636   int m_flipscreen_old;
37
37   
3838   DECLARE_READ8_MEMBER(pastelg_sndrom_r);
3939   DECLARE_READ8_MEMBER(pastelg_irq_ack_r);
4040   DECLARE_READ8_MEMBER(threeds_inputport1_r);
r243230r243231
4545   DECLARE_WRITE8_MEMBER(threeds_output_w);
4646   DECLARE_READ8_MEMBER(threeds_rom_readback_r);
4747   DECLARE_WRITE8_MEMBER(pastelg_romsel_w);
48
48   
4949   DECLARE_CUSTOM_INPUT_MEMBER(nb1413m3_busyflag_r);
5050   DECLARE_CUSTOM_INPUT_MEMBER(nb1413m3_hackbusyflag_r);
51
51   
5252   virtual void machine_start();
5353   virtual void video_start();
54
54   
5555   DECLARE_PALETTE_INIT(pastelg);
5656   UINT32 screen_update_pastelg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5757   int pastelg_blitter_src_addr_r();
r243230r243231
6161protected:
6262   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
6363};
64
trunk/src/mame/includes/powerins.h
r243230r243231
77      : driver_device(mconfig, type, tag),
88      m_maincpu(*this, "maincpu"),
99      m_soundcpu(*this, "soundcpu"),
10      m_nmk112(*this, "nmk112"),
1011      m_vctrl_0(*this, "vctrl_0"),
1112      m_vram_0(*this, "vram_0"),
1213      m_vram_1(*this, "vram_1"),
r243230r243231
1920
2021   required_device<cpu_device> m_maincpu;
2122   optional_device<cpu_device> m_soundcpu;
23   optional_device<nmk112_device> m_nmk112;
2224   required_shared_ptr<UINT16> m_vctrl_0;
2325   required_shared_ptr<UINT16> m_vram_0;
2426   required_shared_ptr<UINT16> m_vram_1;
trunk/src/mame/includes/quizpani.h
r243230r243231
66   quizpani_state(const machine_config &mconfig, device_type type, const char *tag)
77      : driver_device(mconfig, type, tag),
88      m_maincpu(*this, "maincpu"),
9      m_nmk112(*this, "nmk112"),
910      m_scrollreg(*this, "scrollreg"),
1011      m_bg_videoram(*this, "bg_videoram"),
1112      m_txt_videoram(*this, "txt_videoram"),
1213      m_gfxdecode(*this, "gfxdecode") { }
1314
1415   required_device<cpu_device> m_maincpu;
16   required_device<nmk112_device> m_nmk112;
1517   required_shared_ptr<UINT16> m_scrollreg;
1618   required_shared_ptr<UINT16> m_bg_videoram;
1719   required_shared_ptr<UINT16> m_txt_videoram;
trunk/src/mame/includes/senjyo.h
r243230r243231
3636   required_device<dac_device> m_dac;
3737   required_device<gfxdecode_device> m_gfxdecode;
3838   required_device<palette_device> m_palette;
39
39   
4040   /* memory pointers */
4141   required_shared_ptr<UINT8> m_spriteram;
4242   required_shared_ptr<UINT8> m_fgscroll;
r243230r243231
5858   // game specific initialization
5959   int m_is_senjyo;
6060   int m_scrollhack;
61
61   
6262   UINT8 m_sound_cmd;
6363   int m_single_volume;
6464   int m_sound_state;
r243230r243231
6767   tilemap_t *m_bg1_tilemap;
6868   tilemap_t *m_bg2_tilemap;
6969   tilemap_t *m_bg3_tilemap;
70
70   
7171   DECLARE_WRITE8_MEMBER(flip_screen_w);
7272   DECLARE_WRITE8_MEMBER(paletteram_w);
7373   DECLARE_WRITE8_MEMBER(starforb_scrolly2);
r243230r243231
8282   DECLARE_WRITE8_MEMBER(sound_cmd_w);
8383   DECLARE_WRITE8_MEMBER(irq_ctrl_w);
8484   DECLARE_READ8_MEMBER(pio_pa_r);
85
85   
8686   DECLARE_DRIVER_INIT(starfora);
8787   DECLARE_DRIVER_INIT(senjyo);
8888   DECLARE_DRIVER_INIT(starfore);
8989   DECLARE_DRIVER_INIT(starforc);
90
90   
9191   TILE_GET_INFO_MEMBER(get_fg_tile_info);
9292   TILE_GET_INFO_MEMBER(senjyo_bg1_tile_info);
9393   TILE_GET_INFO_MEMBER(starforc_bg1_tile_info);
9494   TILE_GET_INFO_MEMBER(get_bg2_tile_info);
9595   TILE_GET_INFO_MEMBER(get_bg3_tile_info);
96
96   
9797   virtual void machine_start();
9898   virtual void machine_reset();
9999   virtual void video_start();
trunk/src/mame/includes/silkroad.h
r243230r243231
55public:
66   silkroad_state(const machine_config &mconfig, device_type type, const char *tag)
77      : driver_device(mconfig, type, tag),
8      m_maincpu(*this, "maincpu"),
9      m_oki1(*this, "oki1"),
10      m_gfxdecode(*this, "gfxdecode"),
11      m_palette(*this, "palette"),
12      m_generic_paletteram_32(*this, "paletteram"),
138      m_vidram(*this, "vidram"),
149      m_vidram2(*this, "vidram2"),
1510      m_vidram3(*this, "vidram3"),
1611      m_sprram(*this, "sprram"),
17      m_regs(*this, "regs") { }
12      m_regs(*this, "regs"),
13      m_maincpu(*this, "maincpu"),
14      m_oki1(*this, "oki1"),
15      m_gfxdecode(*this, "gfxdecode"),
16      m_palette(*this, "palette"),
17      m_generic_paletteram_32(*this, "paletteram") { }
1818
19   required_device<cpu_device> m_maincpu;
20   required_device<okim6295_device> m_oki1;
21   required_device<gfxdecode_device> m_gfxdecode;
22   required_device<palette_device> m_palette;
23   
24   required_shared_ptr<UINT32> m_generic_paletteram_32;
2519   required_shared_ptr<UINT32> m_vidram;
2620   required_shared_ptr<UINT32> m_vidram2;
2721   required_shared_ptr<UINT32> m_vidram3;
2822   required_shared_ptr<UINT32> m_sprram;
2923   required_shared_ptr<UINT32> m_regs;
30   
3124   tilemap_t *m_fg_tilemap;
3225   tilemap_t *m_fg2_tilemap;
3326   tilemap_t *m_fg3_tilemap;
34   
3527   DECLARE_WRITE32_MEMBER(paletteram32_xRRRRRGGGGGBBBBB_dword_w);
3628   DECLARE_WRITE32_MEMBER(silk_coin_counter_w);
3729   DECLARE_WRITE32_MEMBER(silkroad_fgram_w);
3830   DECLARE_WRITE32_MEMBER(silkroad_fgram2_w);
3931   DECLARE_WRITE32_MEMBER(silkroad_fgram3_w);
4032   DECLARE_WRITE32_MEMBER(silk_6295_bank_w);
41   
4233   TILE_GET_INFO_MEMBER(get_fg_tile_info);
4334   TILE_GET_INFO_MEMBER(get_fg2_tile_info);
4435   TILE_GET_INFO_MEMBER(get_fg3_tile_info);
45   
4636   virtual void video_start();
47   
4837   UINT32 screen_update_silkroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4938   void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
39   required_device<cpu_device> m_maincpu;
40   required_device<okim6295_device> m_oki1;
41   required_device<gfxdecode_device> m_gfxdecode;
42   required_device<palette_device> m_palette;
43   required_shared_ptr<UINT32> m_generic_paletteram_32;
5044};
trunk/src/mame/includes/stadhero.h
r243230r243231
1919   required_device<deco_bac06_device> m_tilegen1;
2020   required_device<deco_mxc06_device> m_spritegen;
2121   required_device<gfxdecode_device> m_gfxdecode;
22
22   
2323   required_shared_ptr<UINT16> m_spriteram;
2424   required_shared_ptr<UINT16> m_pf1_data;
2525
2626   tilemap_t *m_pf1_tilemap;
27
27   
2828   DECLARE_WRITE16_MEMBER(stadhero_control_w);
2929   DECLARE_WRITE16_MEMBER(stadhero_pf1_data_w);
30
30   
3131   virtual void video_start();
32
32   
3333   TILE_GET_INFO_MEMBER(get_pf1_tile_info);
3434   UINT32 screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3535};
trunk/src/mame/includes/stfight.h
r243230r243231
2828   required_device<msm5205_device> m_msm;
2929   required_device<gfxdecode_device> m_gfxdecode;
3030   required_device<palette_device> m_palette;
31
31   
3232   optional_shared_ptr<UINT8> m_text_char_ram;
3333   optional_shared_ptr<UINT8> m_text_attr_ram;
3434   optional_shared_ptr<UINT8> m_tx_vram;
trunk/src/mame/includes/stlforce.h
r243230r243231
3636   required_shared_ptr<UINT16> m_mhigh_scrollram;
3737   required_shared_ptr<UINT16> m_vidattrram;
3838   required_shared_ptr<UINT16> m_spriteram;
39
39   
4040   tilemap_t *m_bg_tilemap;
4141   tilemap_t *m_mlow_tilemap;
4242   tilemap_t *m_mhigh_tilemap;
4343   tilemap_t *m_tx_tilemap;
4444
4545   int m_sprxoffs;
46
46   
4747   DECLARE_WRITE16_MEMBER(stlforce_bg_videoram_w);
4848   DECLARE_WRITE16_MEMBER(stlforce_mlow_videoram_w);
4949   DECLARE_WRITE16_MEMBER(stlforce_mhigh_videoram_w);
5050   DECLARE_WRITE16_MEMBER(stlforce_tx_videoram_w);
5151   DECLARE_WRITE16_MEMBER(eeprom_w);
5252   DECLARE_WRITE16_MEMBER(oki_bank_w);
53
53   
5454   DECLARE_DRIVER_INIT(twinbrat);
5555   DECLARE_DRIVER_INIT(stlforce);
56
56   
5757   TILE_GET_INFO_MEMBER(get_stlforce_bg_tile_info);
5858   TILE_GET_INFO_MEMBER(get_stlforce_mlow_tile_info);
5959   TILE_GET_INFO_MEMBER(get_stlforce_mhigh_tile_info);
6060   TILE_GET_INFO_MEMBER(get_stlforce_tx_tile_info);
61
61   
6262   virtual void video_start();
6363   UINT32 screen_update_stlforce(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6464   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
trunk/src/mame/includes/strnskil.h
r243230r243231
1515   required_device<cpu_device> m_subcpu;
1616   required_device<gfxdecode_device> m_gfxdecode;
1717   required_device<palette_device> m_palette;
18
18   
1919   required_shared_ptr<UINT8> m_videoram;
2020   required_shared_ptr<UINT8> m_xscroll;
2121   required_shared_ptr<UINT8> m_spriteram;
r243230r243231
2323   UINT8 m_scrl_ctrl;
2424   tilemap_t *m_bg_tilemap;
2525   UINT8 m_irq_source;
26
26   
2727   TIMER_DEVICE_CALLBACK_MEMBER(strnskil_irq);
2828
2929   DECLARE_READ8_MEMBER(strnskil_d800_r);
r243230r243231
3232   DECLARE_WRITE8_MEMBER(protection_w);
3333   DECLARE_WRITE8_MEMBER(strnskil_videoram_w);
3434   DECLARE_WRITE8_MEMBER(strnskil_scrl_ctrl_w);
35
35   
3636   DECLARE_DRIVER_INIT(banbam);
3737   DECLARE_DRIVER_INIT(pettanp);
38
38   
3939   TILE_GET_INFO_MEMBER(get_bg_tile_info);
40
41   virtual void machine_start();
40   
41   virtual void machine_start();   
4242   virtual void video_start();
4343   DECLARE_PALETTE_INIT(strnskil);
4444   UINT32 screen_update_strnskil(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
trunk/src/mame/includes/toaplan2.h
r243230r243231
153153   void truxton2_postload();
154154   void create_tx_tilemap(int dx = 0, int dx_flipped = 0);
155155   void toaplan2_vblank_irq(int irq_line);
156   DECLARE_WRITE_LINE_MEMBER(bbakraid_irqhandler);
156157
157158   UINT8 m_pwrkick_hopper;
158159   DECLARE_CUSTOM_INPUT_MEMBER(pwrkick_hopper_status_r);
trunk/src/mame/includes/tx1.h
r243230r243231
107107         m_objram(*this, "objram"),
108108         m_rcram(*this, "rcram"),
109109         m_z80_ram(*this, "z80_ram"),
110         m_char_tiles(*this, "char_tiles"),
111         m_obj_tiles(*this, "obj_tiles"),
112         m_road_rom(*this, "road"),
113         m_obj_map(*this, "obj_map"),
114         m_obj_luts(*this, "obj_luts"),
115         m_proms(*this, "proms"),
116110         m_screen(*this, "screen") { }
117111
118112   required_device<cpu_device> m_maincpu;
r243230r243231
123117   required_shared_ptr<UINT16> m_objram;
124118   required_shared_ptr<UINT16> m_rcram;
125119   required_shared_ptr<UINT8> m_z80_ram;
126
127   required_region_ptr<UINT8> m_char_tiles;
128   required_region_ptr<UINT8> m_obj_tiles;
129   required_region_ptr<UINT8> m_road_rom;
130   required_region_ptr<UINT8> m_obj_map;
131   required_region_ptr<UINT8> m_obj_luts;
132   required_region_ptr<UINT8> m_proms;
133
134120   required_device<screen_device> m_screen;
135121
136122   emu_timer *m_interrupt_timer;
trunk/src/mame/includes/vaportra.h
r243230r243231
4444   DECLARE_WRITE16_MEMBER(vaportra_priority_w);
4545   DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_rg_w);
4646   DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_b_w);
47
47   
4848   DECLARE_DRIVER_INIT(vaportra);
4949   virtual void machine_start();
5050   virtual void machine_reset();
51
51   
5252   UINT32 screen_update_vaportra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   void update_24bitcol( int offset );
54
54   
5555   DECO16IC_BANK_CB_MEMBER(bank_callback);
5656};
trunk/src/mame/includes/xyonix.h
r243230r243231
99
1010   required_device<cpu_device> m_maincpu;
1111   required_device<gfxdecode_device> m_gfxdecode;
12
12   
1313   required_shared_ptr<UINT8> m_vidram;
14
14   
1515   tilemap_t *m_tilemap;
1616
1717   int m_e0_data;
1818   int m_credits;
1919   int m_coins;
2020   int m_prev_coin;
21
21   
2222   DECLARE_WRITE8_MEMBER(irqack_w);
2323   DECLARE_READ8_MEMBER(io_r);
2424   DECLARE_WRITE8_MEMBER(io_w);
2525   DECLARE_WRITE8_MEMBER(vidram_w);
26
26   
2727   virtual void machine_start();
2828   virtual void video_start();
2929   TILE_GET_INFO_MEMBER(get_tile_info);
3030   DECLARE_PALETTE_INIT(xyonix);
3131   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32
32   
3333   void handle_coins(int coin);
3434};
trunk/src/mame/layout/gts80a_caveman.lay
r243230r243231
151151      <bezel name="text2" element="P4"><bounds left="100" right="180" top="90" bottom="102" /></bezel>
152152      <bezel name="text1" element="P5"><bounds left="100" right="180" top="150" bottom="162" /></bezel>
153153      <bezel name="text0" element="P6"><bounds left="100" right="180" top="210" bottom="222" /></bezel>
154
154   
155155      <screen index="0">
156156         <bounds x="320" y="0" width="320" height="240" />
157157      </screen>
158   </view>
158    </view>
159159</mamelayout>
trunk/src/mame/machine/315-5838_317-0229_comp.c
r243230r243231
11/* Sega Compression (and possibly encryption) device
22
3    315-5838 - Decathlete (ST-V)
4    317-0229 - Dead or Alive (Model 2A)
3   315-5838 - Decathlete (ST-V)
4   317-0229 - Dead or Alive (Model 2A)
55
6    Package Type: TQFP100
6   Package Type: TQFP100
77
8    This appears to be a dual channel compression chip, used in 1996, predating the 5881.
9    Decathlete uses it to compress ALL the game graphics, Dead or Alive uses it for a
10    dumb security check, decompressing a single string.
8   This appears to be a dual channel compression chip, used in 1996, predating the 5881.
9   Decathlete uses it to compress ALL the game graphics, Dead or Alive uses it for a
10   dumb security check, decompressing a single string.
1111
12    Each channel appears to be connected to a different set of ROMs, however there is
13    defintiely only a single 315-5838 chip. (could the different channels actually just
14    be mirror addresses, with part of the address determining the ROMs to use?)
12   Each channel appears to be connected to a different set of ROMs, however there is
13   defintiely only 315-5838 single chip.
1514
16    Dead of Alive only uses a single channel, and has the source data in RAM, not ROM.
17    This is similar to how some 5881 games were set up, with the ST-V versions decrypting
18    data directly from ROM and the Model 2 ones using a RAM source buffer.
15   Dead of Alive only uses a single channel, and has the source data in RAM, not ROM.
16   This is similar to how some 5881 games were set up, with the ST-V versions decrypting
17   data directly from ROM and the Model 2 ones using a RAM source buffer.
1918
20    Looking at the values read I don't think there is any address based encryption, for
21    example many blocks where you'd expect a zero fill start with repeating patterns
22    of 8f708f70 (different lengths) channel would appear to relate to compressed 0x00 data
19   Looking at the values read I don't think there is any address based encryption, for
20   example many blocks where you'd expect a zero fill start with repeating patterns
21   of 8f708f70 (different lengths) which would appear to relate to compressed 0x00 data
2322
24    read addr 0071253c, blah_r 8f708f70 - read count count 00000004
25    read addr 00712540, blah_r 8f708f70 - read count count 00000008
26    read addr 00712544, blah_r 8f708f70 - read count count 0000000c
27    read addr 00712548, blah_r 8f708f70 - read count count 00000010
28    read addr 0071254c, blah_r 8f708f70 - read count count 00000014
29    read addr 00712550, blah_r 8f708f70 - read count count 00000018
30    read addr 00712554, blah_r 8f708f70 - read count count 0000001c
23   read addr 0071253c, blah_r 8f708f70 - read count count 00000004
24   read addr 00712540, blah_r 8f708f70 - read count count 00000008
25   read addr 00712544, blah_r 8f708f70 - read count count 0000000c
26   read addr 00712548, blah_r 8f708f70 - read count count 00000010
27   read addr 0071254c, blah_r 8f708f70 - read count count 00000014
28   read addr 00712550, blah_r 8f708f70 - read count count 00000018
29   read addr 00712554, blah_r 8f708f70 - read count count 0000001c
3130
3231*/
3332
r243230r243231
4746
4847void sega_315_5838_comp_device::device_start()
4948{
50   for (int i = 0; i < 2; i++)
51   {
52      m_channel[i].m_decathlt_lastcount = 0;
53      m_channel[i].m_decathlt_prot_uploadmode = 0;
54      m_channel[i].m_decathlt_prot_uploadoffset = 0;
55      m_channel[i].m_read_ch.bind_relative_to(*owner());
49   m_decathlt_lastcount = 0;
50   m_decathlt_prot_uploadmode = 0;
51   m_decathlt_prot_uploadoffset = 0;
5652
57   }
53   m_read_ch1.bind_relative_to(*owner());
54   m_read_ch2.bind_relative_to(*owner());
5855}
5956
6057void sega_315_5838_comp_device::device_reset()
6158{
62   for (int i = 0; i < 2; i++)
63   {
64      m_channel[i].m_srcoffset = 0;
65      m_channel[i].m_decathlt_lastcount = 0;
66      m_channel[i].m_decathlt_prot_uploadmode = 0;
67      m_channel[i].m_decathlt_prot_uploadoffset = 0;
68   }
59   memset(m_decathlt_protregs, 0, sizeof(m_decathlt_protregs));
60   m_decathlt_lastcount = 0;
61   m_decathlt_prot_uploadmode = 0;
62   m_decathlt_prot_uploadoffset = 0;
63   m_decathlt_part = 1;
6964
7065   m_protstate = 0;
7166}
r243230r243231
8277#endif
8378
8479
85READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot1_r)
80READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot_r)
8681{
87   return genericdecathlt_prot_r(mem_mask, 0);
82   return genericdecathlt_prot_r(offset, mem_mask, 0);
8883}
8984
90READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot2_r)
85READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot_ch2_r)
9186{
92   return genericdecathlt_prot_r(mem_mask, 1);
87   return genericdecathlt_prot_r(offset, mem_mask, 1);
9388}
9489
9590
96UINT32 sega_315_5838_comp_device::genericdecathlt_prot_r(UINT32 mem_mask, int channel)
91UINT32 sega_315_5838_comp_device::genericdecathlt_prot_r(UINT32 offset, UINT32 mem_mask, int which)
9792{
98//  UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base();
99//  UINT32 retvalue = 0xffff;
10093
101   switch (m_channel[channel].m_srcoffset)
94//   UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base();
95
96   if (offset==2)
10297   {
103      default:
98//      UINT32 retvalue = 0xffff;
10499
105      m_channel[channel].m_decathlt_lastcount++;
100      switch (m_decathlt_protregs[0])
101      {
102         default:
106103
107      UINT32 tempdata = 0;
108      tempdata |= m_channel[channel].m_read_ch(m_channel[channel].m_srcoffset) << 0;
109      m_channel[channel].m_srcoffset++;
110      tempdata |= m_channel[channel].m_read_ch(m_channel[channel].m_srcoffset) << 16;
111      m_channel[channel].m_srcoffset++;
104         m_decathlt_lastcount++;
112105
106         UINT32 tempdata = 0;
113107
114      #ifdef DEBUG_DATA_DUMP
115      //printf("read addr %08x, blah_r %08x - read count count %08x\n", m_channel[channel].m_srcoffset*2, tempdata,  m_channel[channel].m_decathlt_lastcount*4);
116      fwrite(&tempdata, 1, 4, tempfile);
117      #else
118      logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_channel[channel].m_srcoffset*2, tempdata,  m_channel[channel].m_decathlt_lastcount*4);
119      #endif
108         if (which == 0)
109         {
110            tempdata |= m_read_ch1(m_decathlt_protregs[0]) << 16;
111            m_decathlt_protregs[0]++;
112            tempdata |= m_read_ch1(m_decathlt_protregs[0]) << 0;
113            m_decathlt_protregs[0]++;
114         }
115         else
116         {
117            tempdata |= m_read_ch2(m_decathlt_protregs[0]) << 16;
118            m_decathlt_protregs[0]++;
119            tempdata |= m_read_ch2(m_decathlt_protregs[0]) << 0;
120            m_decathlt_protregs[0]++;
121         }
120122
121      return tempdata;
123         #ifdef DEBUG_DATA_DUMP
124         //printf("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0]*2, tempdata,  m_decathlt_lastcount*4);
125         fwrite(&tempdata, 1, 4, tempfile);
126         #else
127         logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0]*2, tempdata,  m_decathlt_lastcount*4);
128         #endif
129
130         return tempdata;
122131#if 0
123      case 0x03228e4:
124         if (fake0) retvalue = fake0[(((0x20080/4)+m_channel[channel].m_decathlt_lastcount))];
125         m_channel[channel].m_decathlt_lastcount++;
126         return retvalue;
132         case 0x03228e4:
133            if (fake0) retvalue = fake0[(((0x20080/4)+m_decathlt_lastcount))];
134            m_decathlt_lastcount++;
135            return retvalue;
127136
128      case 0x00a9f3a:
129         if (fake0) retvalue = fake0[(((0x00000/4)+m_channel[channel].m_decathlt_lastcount))];
130         m_channel[channel].m_decathlt_lastcount++;
131         return retvalue;
137         case 0x00a9f3a:
138            if (fake0) retvalue = fake0[(((0x00000/4)+m_decathlt_lastcount))];
139            m_decathlt_lastcount++;
140            return retvalue;
132141
133      case 0x0213ab4:
134         if (fake0) retvalue = fake0[(((0x40000/4)+m_channel[channel].m_decathlt_lastcount))];
135         m_channel[channel].m_decathlt_lastcount++;
136         return retvalue;
142         case 0x0213ab4:
143            if (fake0) retvalue = fake0[(((0x40000/4)+m_decathlt_lastcount))];
144            m_decathlt_lastcount++;
145            return retvalue;
137146
138      case 0x01efaf0:
139         if (fake0) retvalue = fake0[(((0x60000/4)+m_channel[channel].m_decathlt_lastcount))];
140         m_channel[channel].m_decathlt_lastcount++;
141         return retvalue;
147         case 0x01efaf0:
148            if (fake0) retvalue = fake0[(((0x60000/4)+m_decathlt_lastcount))];
149            m_decathlt_lastcount++;
150            return retvalue;
142151
143      case 0x033f16c:
144      case 0x038929c:
152         case 0x033f16c:
153         case 0x038929c:
145154
146155
147156
148      case 0x00de05a:
149      case 0x0334258:
150      case 0x019fb82:
151      case 0x033dbf6:
152      case 0x0011ac6:
153      case 0x00060dc:
154      case 0x0000002:
155      case 0x0008c90:
156      case 0x035cdc8:
157      case 0x0327960:
158      case 0x0329b8c:
159      case 0x00d6e92:
160      case 0x000081e:
161      case 0x00035d6:
162      case 0x00089a6:
163      case 0x03315f4:
164      case 0x0023fe0:
165      case 0x001e290:
166      case 0x0026e86:
167      case 0x0012494:
168      case 0x001b35a:
169      case 0x0018424:
157         case 0x00de05a:
158         case 0x0334258:
159         case 0x019fb82:
160         case 0x033dbf6:
161         case 0x0011ac6:
162         case 0x00060dc:
163         case 0x0000002:
164         case 0x0008c90:
165         case 0x035cdc8:
166         case 0x0327960:
167         case 0x0329b8c:
168         case 0x00d6e92:
169         case 0x000081e:
170         case 0x00035d6:
171         case 0x00089a6:
172         case 0x03315f4:
173         case 0x0023fe0:
174         case 0x001e290:
175         case 0x0026e86:
176         case 0x0012494:
177         case 0x001b35a:
178         case 0x0018424:
170179
171         return retvalue;
180            return retvalue;
172181#endif
182      }
183
184
173185   }
186   else
187   {
188      logerror("%06x Decathlete prot R offset %04x mask %08x regs %08x, %08x, %08x, %08x\n", safe_pc(), offset, mem_mask, m_decathlt_protregs[0], m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]);
189   }
174190
175   return 0xffffffff;
191   return m_decathlt_protregs[offset];
176192}
177193
178void sega_315_5838_comp_device::set_prot_addr(UINT32 data, UINT32 mem_mask, int channel)
194
195void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which)
179196{
180//  printf("set_prot_addr\n");
181   COMBINE_DATA(&m_channel[channel].m_srcoffset);
182197
183   //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",channel, m_channel[channel].m_decathlt_lastcount*4);
184   m_channel[channel].m_decathlt_lastcount = 0;
198   printf("write_prot_data %08x %08x %08x\n", offset, data, mem_mask);
185199
186   if (mem_mask == 0x0000ffff)
200   m_decathlt_protregs[offset] = (data&mem_mask)|(m_decathlt_protregs[offset]&~mem_mask);
201//  m_decathlt_protregs[0] = 0x0c00000/4;
202
203   if (offset==0) // seems to set a source address
187204   {
188      printf("set source address to %08x (channel %d)\n", m_channel[channel].m_srcoffset, channel);
189   }
205      m_decathlt_part ^=1;
190206
207      //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",which, m_decathlt_lastcount*4);
208      m_decathlt_lastcount = 0;
209      if (m_decathlt_part==1) logerror("%d Decathlete prot W offset %04x data %08x, %08x, >>> regs %08x <<<<, %08x, %08x, %08x\n",which, offset, data, m_decathlt_protregs[0], m_decathlt_protregs[0]*4, m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]);
191210
192211#ifdef DEBUG_DATA_DUMP
193   if (mem_mask == 0x0000ffff)
194   {
195      if (tempfile)
196         fclose(tempfile);
197
198      char filename[256];
199      sprintf(filename, "%d_compressed_%08x", channel, m_channel[channel].m_srcoffset * 2);
200      tempfile = fopen(filename, "w+b");
201
202      // the table and dictionary are uploaded repeatedly, usually before groups of data transfers but
203      // it's always the same tables (one pair for each channel)
212      if (mem_mask == 0x0000ffff)
204213      {
205         FILE* fp;
206         sprintf(filename, "%d_compressed_table1", channel);
207         fp = fopen(filename, "w+b");
208         fwrite(&m_channel[channel].m_decathlt_prottable1, 24, 2, fp);
209         fclose(fp);
210      }
214         if (tempfile)
215            fclose(tempfile);
211216
212      {
213         FILE* fp;
214         sprintf(filename, "%d_compressed_dictionary", channel);
215         fp = fopen(filename, "w+b");
216         fwrite(&m_channel[channel].m_decathlt_dictionary, 128, 2, fp);
217         fclose(fp);
217         char filename[256];
218         sprintf(filename, "%d_compressed_%08x", which, m_decathlt_protregs[0] );
219         tempfile = fopen(filename, "w+b");
218220      }
219   }
220221#endif
221222
222}
223
224void sega_315_5838_comp_device::set_upload_mode(UINT16 data, int channel)
225{
226   if ((data == 0x8000) || (data == 0x0000))
227   {
228   //  logerror("changed to upload mode 1\n");
229      m_channel[channel].m_decathlt_prot_uploadmode = 1;
230      m_channel[channel].m_decathlt_prot_uploadoffset = 0;
231223   }
232   else if ((data == 0x8080) || (data == 0x0080))
233   {
234      m_channel[channel].m_decathlt_prot_uploadmode = 2;
235      m_channel[channel].m_decathlt_prot_uploadoffset = 0;
236   }
237   else
238   {
239      fatalerror("unknown upload mode\n");
240   }
241}
242224
243void sega_315_5838_comp_device::upload_table_data(UINT16 data, int channel)
244{
245   if (m_channel[channel].m_decathlt_prot_uploadmode == 1)
225   if (offset==1) // uploads 2 tables...
246226   {
247      if (m_channel[channel].m_decathlt_prot_uploadoffset >= 24)
227      if (mem_mask==0xffff0000)
248228      {
249         fatalerror("upload mode 1 error, too big\n");
250         return;
229         if (data == 0x80000000)
230         {
231         //  logerror("changed to upload mode 1\n");
232            m_decathlt_prot_uploadmode = 1;
233            m_decathlt_prot_uploadoffset = 0;
234         }
235         else if (data == 0x80800000)
236         {
237         //  logerror("changed to upload mode 2\n");
238            m_decathlt_prot_uploadmode = 2;
239            m_decathlt_prot_uploadoffset = 0;
240         }
241         else
242         {
243         //  logerror("unknown upload mode\n");
244            m_decathlt_prot_uploadmode = 2;
245            m_decathlt_prot_uploadoffset = 0;
246         }
247
248//          logerror("ARGH! %08x %08x\n",mem_mask,data);
251249      }
250      else if (mem_mask==0x0000ffff)
251      {
252         if (m_decathlt_prot_uploadmode==1)
253         {
254            if (m_decathlt_prot_uploadoffset>=24)
255            {
256            //  logerror("upload mode 1 error, too big\n");
257               return;
258            }
252259
253      //logerror("uploading table 1 %04x %04x\n",m_channel[channel].m_decathlt_prot_uploadoffset, data&0xffff);
254      m_channel[channel].m_decathlt_prottable1[m_channel[channel].m_decathlt_prot_uploadoffset] = data & 0xffff;
255      m_channel[channel].m_decathlt_prot_uploadoffset++;
256      printf("unk table 1 %04x (channel %d)\n", data & 0xffff, channel);
257   }
258   else if (m_channel[channel].m_decathlt_prot_uploadmode == 2)
259   {
260      if (m_channel[channel].m_decathlt_prot_uploadoffset >= 128)
261      {
262         fatalerror("upload mode 2 error, too big\n");
263         return;
260            //logerror("uploading table 1 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff);
261            m_decathlt_prottable1[m_decathlt_prot_uploadoffset]=data&0xffff;
262            m_decathlt_prot_uploadoffset++;
263
264            printf("table 1 %04x\n", data & 0xffff);
265
266            {
267               /* 0x18 (24) values in this table, rom data is 0x1800000 long, maybe it has
268                  something to do with that? or 24-address b    its?
269
270                  uploaded values appear to be 12-bit, some are repeated
271               */
272
273               {
274                  FILE* fp;
275                  if (which==1) fp = fopen("table1x","wb");
276                  else fp = fopen("table1","wb");
277
278                  {
279                     fwrite(&m_decathlt_prottable1,24,2,fp);
280                  }
281                  fclose(fp);
282               }
283            }
284
285         }
286         else if (m_decathlt_prot_uploadmode==2)
287         {
288            if (m_decathlt_prot_uploadoffset>=128)
289            {
290               //logerror("upload mode 2 error, too big\n");
291               return;
292            }
293
294            //logerror("uploading table 2 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff);
295            m_decathlt_prottable2[m_decathlt_prot_uploadoffset]=data&0xffff;
296            m_decathlt_prot_uploadoffset++;
297
298            printf("dictionary %04x\n", data & 0xffff);
299
300
301            {
302               /* the table uploaded here is a 256 byte table with 256 unique values, remaps something? */
303
304               {
305                  FILE* fp;
306                  if (which==1) fp = fopen("table2x","wb");
307                  else fp = fopen("table2","wb");
308
309                  {
310                     fwrite(&m_decathlt_prottable2,128,2,fp);
311                  }
312                  fclose(fp);
313               }
314            }
315         }
316         else
317         {
318         //  logerror("unknown upload mode!\n");
319         }
264320      }
265
266      //logerror("uploading table 2 %04x %04x\n",m_channel[channel].m_decathlt_prot_uploadoffset, data&0xffff);
267      m_channel[channel].m_decathlt_dictionary[m_channel[channel].m_decathlt_prot_uploadoffset] = data & 0xffff;
268      m_channel[channel].m_decathlt_prot_uploadoffset++;
269      printf("dictionary %04x (channel %d)\n", data & 0xffff, channel);
270321   }
271}
272322
273void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int channel, int rev_words)
274{
275   if (mem_mask==0xffff0000)
323   if (offset>1)
276324   {
277      if (rev_words==0) set_upload_mode(data >> 16, channel);
278      else upload_table_data(data >>16, channel);
325   //  logerror("higher offset write\n");
279326   }
280   else if (mem_mask == 0x0000ffff)
281   {
282      if (rev_words==0) upload_table_data(data & 0xffff, channel);
283      else set_upload_mode(data & 0xffff, channel);
284   }
285   else
286   {
287      fatalerror("write_prot_data invalid mem_mask\b");
288   }
327
289328}
290329
330WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w )
331{
332   write_prot_data(data,mem_mask, offset, 0);
291333
334}
292335
293WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w_doa )  { write_prot_data(data, mem_mask, 0, 1); }
294WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w)  { write_prot_data(data, mem_mask, 0, 0); }
295WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w)  { write_prot_data(data, mem_mask, 1, 0); }
336WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w )
337{
338   write_prot_data(data,mem_mask, offset, 1);
296339
297WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_srcaddr_w ) { set_prot_addr(data, mem_mask, 0); }
298WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_srcaddr_w)  { set_prot_addr(data, mem_mask, 1); }
299340
341}
300342
301343void sega_315_5838_comp_device::install_decathlt_protection()
302344{
345   /* It uploads 2 tables here, then performs what looks like a number of transfers, setting
346      a source address of some kind (scrambled?) and then making many reads from a single address */
347
303348   //todo, install these in the driver, they differ between games
304349   cpu_device* cpu = (cpu_device*)machine().device(":maincpu");
305350
306   cpu->space(AS_PROGRAM).install_write_handler(0x37FFFF0, 0x37FFFF3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_srcaddr_w), this)); // set compressed data source address
307   cpu->space(AS_PROGRAM).install_write_handler(0x37FFFF4, 0x37FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this)); // upload tables
308   cpu->space(AS_PROGRAM).install_read_handler(0x37FFFF8, 0x37FFFFb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_r), this)); // read decompressed data
309351
310   // the device is addressed here too, uploading a different set of tables and accessing a different part of ROM
311   cpu->space(AS_PROGRAM).install_write_handler(0x27FFFF0, 0x27FFFF3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_srcaddr_w), this)); // set compressed data source address
312   cpu->space(AS_PROGRAM).install_write_handler(0x27FFFF4, 0x27FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this)); // upload tables
313   cpu->space(AS_PROGRAM).install_read_handler(0x27FFFF8, 0x27FFFFb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_r), this)); // read decompressed data
352   cpu->space(AS_PROGRAM).install_readwrite_handler(0x37FFFF0, 0x37FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this));
353   /* It accesses the device at this address too, with different tables, for the game textures, should it just act like a mirror, or a secondary device? */
354   cpu->space(AS_PROGRAM).install_readwrite_handler(0x27FFFF0, 0x27FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_ch2_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this));
314355}
315356
316357
r243230r243231
346387{
347388   printf("doa_prot_w %08x %08x %08x\n", offset*4, data, mem_mask);
348389
349   m_protstate = 0;
390   if (offset == 0x7ff2 / 4)
391   {
392      if (data == 0)
393      {
394         m_protstate = 0;
395         strcpy((char *)m_protram, "  TECMO LTD.  DEAD OR ALIVE  1996.10.22  VER. 1.00"); // this is the single decompressed string DOA needs
396      }
397   }
398   else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
350399}
351400
352401
r243230r243231
354403{
355404   //todo, install these in the driver, they differ between games
356405   cpu_device* cpu = (cpu_device*)machine().device(":maincpu");
357
358   m_protstate = 0;
359   strcpy((char *)m_protram, "  TECMO LTD.  DEAD OR ALIVE  1996.10.22  VER. 1.00"); // this is the single decompressed string DOA needs, note, 2 spaces at start, might indicate a dummy read like with 5881 on Model 2
360
361406   cpu->space(AS_PROGRAM).install_readwrite_handler(0x01d80000, 0x01dfffff, read32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_w), this));
362   cpu->space(AS_PROGRAM).install_write_handler(0x01d87ff0, 0x01d87ff3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_srcaddr_w), this)); // set compressed data source address (always set 0, data is in RAM)
363   cpu->space(AS_PROGRAM).install_write_handler(0x01d87ff4, 0x01d87ff7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w_doa), this)); // upload tab
364//  cpu->space(AS_PROGRAM).install_read_handler(0x01d87ff8, 0x01d87ffb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_r), this)); // read decompressed data
365
366}
407}
No newline at end of file
trunk/src/mame/machine/315-5838_317-0229_comp.h
r243230r243231
44#ifndef __SEGA315_5838_COMP__
55#define __SEGA315_5838_COMP__
66
7#define CHANNELS 2
8
97typedef device_delegate<UINT16 (UINT32)> sega_dec_read_delegate;
108
119extern const device_type SEGA315_5838_COMP;
r243230r243231
2220   // construction/destruction
2321   sega_315_5838_comp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2422
23   sega_dec_read_delegate m_read_ch1;
2524   sega_dec_read_delegate m_read_ch2;
2625
2726   static void set_read_cb_ch1(device_t &device,sega_dec_read_delegate readcb)
2827   {
2928      sega_315_5838_comp_device &dev = downcast<sega_315_5838_comp_device &>(device);
30      dev.m_channel[0].m_read_ch = readcb;
29      dev.m_read_ch1 = readcb;
3130   }
3231
3332   static void set_read_cb_ch2(device_t &device,sega_dec_read_delegate readcb)
3433   {
3534      sega_315_5838_comp_device &dev = downcast<sega_315_5838_comp_device &>(device);
36      dev.m_channel[1].m_read_ch = readcb;
35      dev.m_read_ch2 = readcb;
3736   }
3837
39   DECLARE_READ32_MEMBER(decathlt_prot1_r);
40   DECLARE_READ32_MEMBER(decathlt_prot2_r);;
41   UINT32 genericdecathlt_prot_r(UINT32 mem_mask, int channel);
38   DECLARE_READ32_MEMBER(decathlt_prot_r);
39   DECLARE_READ32_MEMBER(decathlt_prot_ch2_r);;
40   UINT32 genericdecathlt_prot_r(UINT32 offset, UINT32 mem_mask, int which);
4241
43   void write_prot_data(UINT32 data, UINT32 mem_mask, int channel, int rev_words);
44
45   void upload_table_data(UINT16 data, int channel);
46   void set_upload_mode(UINT16 data, int channel);
47   void set_prot_addr(UINT32 data, UINT32 mem_mask, int channel);
48
49   DECLARE_WRITE32_MEMBER(decathlt_prot1_w_doa);
42   void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which);
5043   DECLARE_WRITE32_MEMBER(decathlt_prot1_w);
5144   DECLARE_WRITE32_MEMBER(decathlt_prot2_w);
52   DECLARE_WRITE32_MEMBER(decathlt_prot1_srcaddr_w);
53   DECLARE_WRITE32_MEMBER(decathlt_prot2_srcaddr_w);
54
5545   void install_decathlt_protection();
5646   void install_doa_protection();
5747
r243230r243231
6555private:
6656
6757   // Decathlete specific variables and functions (see machine/decathlt.c)
68   struct channel_type
69   {
70      UINT32 m_srcoffset;
71      UINT16 m_decathlt_prottable1[24];
72      UINT16 m_decathlt_dictionary[128];
58   UINT32 m_decathlt_protregs[4];
59   UINT32 m_decathlt_lastcount;
60   UINT32 m_decathlt_part;
61   UINT32 m_decathlt_prot_uploadmode;
62   UINT32 m_decathlt_prot_uploadoffset;
63   UINT16 m_decathlt_prottable1[24];
64   UINT16 m_decathlt_prottable2[128];
7365
74      UINT32 m_decathlt_lastcount;
75      UINT32 m_decathlt_prot_uploadmode;
76      UINT32 m_decathlt_prot_uploadoffset;
77      sega_dec_read_delegate m_read_ch;
78
79   };
80
81   channel_type m_channel[2];
82
83
84
8566   // Doa
8667   int m_protstate;
8768   int m_prot_a;
trunk/src/mame/machine/315-5881_crypt.c
r243230r243231
8282      {
8383         if (done_compression == 1)
8484            enc_start();
85           
8586
8687
87
8888         line_fill();
8989      }
9090      base = line_buffer + line_buffer_pos;
r243230r243231
148148given plaintext word, and the remaining 2 to the next plaintext word.
149149
150150The underlying block cipher consists of two 4-round Feistel Networks (FN): the first one takes the counter (16 bits),
151the game-key (>=30 bits; probably 64) and the sequence-key (16 bits) and output a middle result (16 bits) which will act
151the game-key (>=29 bits; probably 64) and the sequence-key (16 bits) and output a middle result (16 bits) which will act
152152as another key for the second one. The second FN will take the encrypted word (16 bits), the game-key, the sequence-key
153153and the result from the first FN and will output the decrypted word (16 bits).
154154
r243230r243231
176176
177177void key2label(uint32_t key)
178178{
179    int bcd0 = ((BIT(key,17)<<3)|(BIT(key,7)<<2)|(BIT(key,14)<<1)|BIT(key,19))^9;
180    int bcd1 = ((BIT(key,20)<<3)|(BIT(key,1)<<2)|(BIT(key,4)<<1)|BIT(key,13))^5;
181    int bcd2 = (BIT(key,9)<<1)|BIT(key,22);
182    int bcd3 = ((BIT(key,9)<<2)|BIT(key,9))^5;
183
184    char chiplabel[13];
185    sprintf(chiplabel, "317-%d%d%d%d-%s", bcd3, bcd2, bcd1, bcd0, (BIT(key,5)?"JPN":"COM"));
186
187    printf("%s", chiplabel);
179   int bcd0 = ((BIT(key,17)<<3)|(BIT(key,7)<<2)|(BIT(key,14)<<1)|BIT(key,19))^9;
180   int bcd1 = ((BIT(key,20)<<3)|(BIT(key,1)<<2)|(BIT(key,4)<<1)|BIT(key,13))^5;
181   int bcd2 = (BIT(key,9)<<1)|BIT(key,22);
182   int bcd3 = ((BIT(key,9)<<2)|BIT(key,9))^5;
183   
184   char chiplabel[13];
185   sprintf(chiplabel, "317-%d%d%d%d-%s", bcd3, bcd2, bcd1, bcd0, (BIT(key,5)?"JPN":"COM"));
186   
187   printf("%s", chiplabel);
188188}
189189
190190Given the use of the BCD-encoded security module labels, it's expected that at least other 6 additional bits be present in the
r243230r243231
196196
197197In the second Feistel Network, every key bit seem to be used at most once (the various uses of current bit #9 are fictitious, as
198198that bit really represent various bits in the real key; see comments on the use of the labels above). Given that, it seems probable
199that the real key is 64 bits long, exactly as in the related CPS-2 scheme, and the designers tried to cover all 96 input bits with
199that the real key is 64 bits long, exactly as in the related CPS-2 scheme, and the designers tried to cover all 96 input bits with
200200the bits provening from the game key, the sequence key and the result from the first feistel network (64+16+16=96). In the first
201201Feistel Network, as only 80 bits are available, some bits would be used twice (as can be partially seen in the current implementation).
202The fact that only 30 bits out of the expected 64 have been observed till now would be due to the generation of the key by composing
202The fact that only 29 bits out of the expected 64 have been observed till now would be due to the generation of the key by composing
203203low-entropy sources.
204204
205205****************************************************************************************/
r243230r243231
453453
454454      {
455455         {
456            2,2,0,3,0,3,1,0,1,1,2,3,2,3,1,0,0,0,3,2,2,0,2,3,1,3,2,0,3,3,1,3,
456            2,2,0,3,0,3,1,0,1,1,2,3,2,3,1,0,0,0,3,2,2,0,2,3,1,3,2,0,3,3,1,3,           
457457            // unused?
458458            255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
459459         },
r243230r243231
511511
512512const int sega_315_5881_crypt_device::fn1_game_key_scheduling[FN1GK][2] = {
513513   {1,29},  {1,71},  {2,4},   {2,54},  {3,8},   {4,56},  {4,73},  {5,11},
514   {6,51},  {7,92},  {8,89},  {9,9},   {9,39},  {9,58},  {10,90}, {11,6},
515   {12,64}, {13,49}, {14,44}, {15,40}, {16,69}, {17,15}, {18,23}, {18,43},
516   {19,82}, {20,81}, {21,32}, {22,5},  {23,66}, {24,13}, {24,45}, {25,12},
517   {25,35}, {26,61}, {27,10}, {27,59}, {28,25}, {29,86}
514   {6,51},  {7,92},  {8,89},  {9,9},   {9,39},  {9,58},  {9,86},  {10,90},
515   {11,6},  {12,64}, {13,49}, {14,44}, {15,40}, {16,69}, {17,15}, {18,23},
516   {18,43}, {19,82}, {20,81}, {21,32}, {22,5},  {23,66}, {24,13}, {24,45},
517   {25,12}, {25,35}, {26,61}, {27,10}, {27,59}, {28,25}
518518};
519519
520520const int sega_315_5881_crypt_device::fn2_game_key_scheduling[FN2GK][2] = {
521521   {0,0},   {1,3},   {2,11},  {3,20},  {4,22},  {5,23},  {6,29},  {7,38},
522   {8,39},  {9,55},  {9,86},  {9,87},  {10,50}, {11,57}, {12,59}, {13,61},
523   {14,63}, {15,67}, {16,72}, {17,83}, {18,88}, {19,94}, {20,35}, {21,17},
524   {22,6},  {23,85}, {24,16}, {25,25}, {26,92}, {27,47}, {28,28}, {29,90}
522   {8,39},  {9,55},  {9,86},  {9,87},  {9,90},  {10,50}, {11,57}, {12,59},
523   {13,61}, {14,63}, {15,67}, {16,72}, {17,83}, {18,88}, {19,94}, {20,35},
524   {21,17}, {22,6},  {23,85}, {24,16}, {25,25}, {26,92}, {27,47}, {28,28}
525525};
526526
527527const int sega_315_5881_crypt_device::fn1_sequence_key_scheduling[20][2] = {
r243230r243231
680680
681681   prot_cur_address ++;
682682
683//  printf("get_decrypted_16 %04x\n", res);
683//   printf("get_decrypted_16 %04x\n", res);
684684
685685   return res;
686686}
r243230r243231
691691   block_pos = 0;
692692   done_compression = 0;
693693   buffer_pos = BUFFER_SIZE;
694
694   
695695   if (buffer_bit2 != 15) // if we have remaining bits in the decompression buffer we shouldn't read the next word yet but should instead use the bits we have?? (twcup98) (might just be because we should be pulling bytes not words?)
696696   {
697//      printf("buffer_bit2 is %d\n", buffer_bit2);
697//      printf("buffer_bit2 is %d\n", buffer_bit2);
698698      dec_header = (buffer2a & 0x0003) << 16;
699699   }
700700   else
r243230r243231
710710   // etc. after each block a new header must be read, it looks like compressed and uncompressed blocks
711711   // can be mixed like this, I don't know if the length is src length of decompressed length.
712712   // deathcox and others confirm format as 0x20000 bit as compressed bit, 0x1ff00 bits as block size 1, 0x000ff bits as block size 2
713   // for compressed streams the 'line size' is block size 1.
713   // for compressed streams the 'line size' is block size 1. 
714714
715715   block_numlines = ((dec_header & 0x000000ff) >> 0) + 1;
716716   int blocky = ((dec_header & 0x0001ff00) >> 8) + 1;
r243230r243231
824824
825825int sega_315_5881_crypt_device::get_compressed_bit()
826826{
827//  if(buffer_pos == BUFFER_SIZE)
828//      enc_fill();
827//   if(buffer_pos == BUFFER_SIZE)
828//      enc_fill();
829829
830830   if (buffer_bit2 == 15)
831831   {
r243230r243231
833833      buffer2a = get_decrypted_16();
834834      buffer2[0] = buffer2a;
835835      buffer2[1] = buffer2a >> 8;
836   //  block_pos+=2;
836   //   block_pos+=2;
837837      buffer_pos = 0;
838838
839839   }
r243230r243231
842842      buffer_bit2++;
843843   }
844844
845//  if (buffer_bit ==7) printf("using byte %02x\n", buffer2[(buffer_pos&1) ^ 1]);
845//   if (buffer_bit ==7) printf("using byte %02x\n", buffer2[(buffer_pos&1) ^ 1]);
846846
847847   int res = (buffer2[(buffer_pos&1)^1] >> buffer_bit) & 1;
848848   buffer_bit--;
trunk/src/mame/machine/dec0.c
r243230r243231
364364   RAM[0x1af] = 0x60; /* RTS prot area */
365365   RAM[0x1db] = 0x60; /* RTS prot area */
366366   RAM[0x21a] = 0x60; /* RTS prot area */
367
367   
368368   save_item(NAME(m_hippodrm_msb));
369369   save_item(NAME(m_hippodrm_lsb));
370370}
r243230r243231
377377   /* Slyspy sound cpu has some protection */
378378   RAM[0xf2d] = 0xea;
379379   RAM[0xf2e] = 0xea;
380
380   
381381   save_item(NAME(m_slyspy_state));
382382}
383383
trunk/src/mame/machine/mie.c
r243230r243231
3333   AM_RANGE(0x00, 0x07) AM_READWRITE(gpio_r, gpio_w)
3434   AM_RANGE(0x08, 0x08) AM_READWRITE(gpiodir_r, gpiodir_w)
3535   AM_RANGE(0x0f, 0x0f) AM_READWRITE(adc_r, adc_w)
36   AM_RANGE(0x10, 0x10) AM_READWRITE(jvs_r, jvs_w)      // ports 1x and 2x is standard UARTs, TODO handle it properly
36   AM_RANGE(0x10, 0x10) AM_READWRITE(jvs_r, jvs_w)
3737   AM_RANGE(0x12, 0x12) AM_WRITE(jvs_dest_w)
38   AM_RANGE(0x13, 0x13) AM_WRITE(jvs_lcr_w)
3938   AM_RANGE(0x15, 0x15) AM_READ(jvs_status_r)
4039   AM_RANGE(0x30, 0x30) AM_READWRITE(irq_enable_r, irq_enable_w)
4140   AM_RANGE(0x50, 0x50) AM_READWRITE(maple_irqlevel_r, maple_irqlevel_w)
r243230r243231
320319
321320READ8_MEMBER(mie_device::jvs_r)
322321{
323   if (jvs_lcr & 0x80)
324      return 0;
325
326322   const UINT8 *buf;
327323   UINT32 size;
328324   jvs->get_encoded_reply(buf, size);
r243230r243231
333329
334330WRITE8_MEMBER(mie_device::jvs_w)
335331{
336   if (jvs_lcr & 0x80)
337      return;
338
339   jvs->push(data);
332   // Hack until the ports are better understood
333   if(jvs_dest == 2)
334      jvs->push(data);
340335}
341336
342337WRITE8_MEMBER(mie_device::jvs_dest_w)
r243230r243231
364359   jvs_control = data;
365360}
366361
367WRITE8_MEMBER(mie_device::jvs_lcr_w)
368{
369   jvs_lcr = data;
370}
371
372362READ8_MEMBER(mie_device::jvs_sense_r)
373363{
374364   return 0x8c | (jvs->get_address_set_line() ? 2 : 0) | (jvs->get_presence_line() ? 0 : 1);
trunk/src/mame/machine/mie.h
r243230r243231
6161   DECLARE_READ8_MEMBER(jvs_status_r);
6262   DECLARE_WRITE8_MEMBER(jvs_control_w);
6363   DECLARE_READ8_MEMBER(jvs_sense_r);
64   DECLARE_WRITE8_MEMBER(jvs_lcr_w);
6564
6665   DECLARE_READ8_MEMBER(read_ff);
6766   DECLARE_READ8_MEMBER(read_00);
r243230r243231
107106   UINT8 gpiodir, gpio_val[8];
108107   UINT8 irq_enable, irq_pending, maple_irqlevel;
109108   UINT8 jvs_control, jvs_dest;
110   UINT8 jvs_lcr;
111109
112110   void raise_irq(int level);
113111   void recalc_irq();
trunk/src/mame/machine/stfight.c
r243230r243231
6363            ( ( ( src ^ A ) >> 1 ) & 0x08 ) |
6464            ( ~( ( src >> 6 ) ^ A ) & 0x01 );
6565   }
66
66   
6767}
6868
6969DRIVER_INIT_MEMBER(stfight_state,stfight)
trunk/src/mame/machine/stvprot.c
r243230r243231
3939         UINT16 res2 = m_cryptdevice->do_decrypt(base);
4040         res = ((res & 0xff00) >> 8) | ((res & 0x00ff) << 8);
4141         res2 = ((res2 & 0xff00) >> 8) | ((res2 & 0x00ff) << 8);
42
43         return res2 | (res << 16);
42           
43         return res2 | (res << 16);         
4444      }
4545      return m_a_bus[offset];
4646   }
trunk/src/mame/mame.lst
r243230r243231
209209warofbug        // (c) 1981 Armenia
210210warofbugu       // (c) 1981 Armenia
211211warofbugg       // German Version
212spactrai        //
212spactrai      //
213213redufo          // (c) Artic
214214redufob         // bootleg
215215exodus          // Subelectro - bootleg?
r243230r243231
26792679snowbrosd       // MIN16-02 (c) 1990 Toaplan + Dooyong license
26802680wintbob         // bootleg
26812681snowbroswb      //
2682toto            //
2682toto         //
26832683// modified snowbros 'clone' hardware
26842684honeydol        // (c) 1995 Barko Corp
26852685twinadv         // (c) 1995 Barko Corp
r243230r243231
34143414ddsomjr1        // 06/02/1996 (c) 1996 (Japan)
34153415ddsomj          // 19/06/1996 (c) 1996 (Japan)
34163416ddsoma          // 19/06/1996 (c) 1996 (Asia)
3417ddsomar1        // 08/02/1996 (c) 1996 (Asia)
3417ddsomar1      // 08/02/1996 (c) 1996 (Asia)
34183418ddsomh          // 23/02/1996 (c) 1996 (Hispanic)
34193419ddsomb          // 23/02/1996 (c) 1996 (Brazil)
34203420sfa2            // 06/03/1996 (c) 1996 (Euro)
r243230r243231
53815381sprtjam         // 2000.11.13 Sports Jam
53825382pjustic         // 2000.12 Moero Justice Gakuen / Project Justice
53835383samba2k         // 2000.12 Samba de Amigo Ver.2000
5384shaktam         // 2000.12.28 Shakatto Tambourine (Rev B)
5384shaktam           // 2000.12.28 Shakatto Tambourine (Rev B)
53855385            // 2000.?? Boat Race Ocean Heats
53865386csmash          // 2000.?? Cosmic Smash
53875387csmasho         // 2000.?? Cosmic Smash (original)
r243230r243231
67106710popn1           // GX803 (c) 1998 (Asia)
67116711//popn1j        // GX803 (c) 1998 (Japan)
67126712popn2           // GX831 (c) 1998 (Japan)
6713popn3           // GX980 (c) 1999 (Japan)
6713popn3            // GX980 (c) 1999 (Japan)
67146714//popnstex      // GX970 (c) 1999 (Japan)
67156715
67166716// Firebeat games
r243230r243231
69646964quantum1        // 136016           (c) 1982        // made by Gencomp
69656965quantump        // 136016           (c) 1982        // made by Gencomp
69666966bwidow          // 136017           (c) 1982
6967bwidowp         // (proto)          (c) 1982
6967bwidowp         // (proto)         (c) 1982
69686968starwars        // 136021           (c) 1983
69696969starwars1       // 136021           (c) 1983
69706970starwarso       // 136021           (c) 1983
r243230r243231
1121711217peps0298        // (c) 1996 IGT - International Game Technology
1121811218peps0308        // (c) 1996 IGT - International Game Technology
1121911219peps0364        // (c) 1996 IGT - International Game Technology
11220peps0366        // (c) 1996 IGT - International Game Technology
11221peps0372        // (c) 1996 IGT - International Game Technology
11222peps0373        // (c) 1996 IGT - International Game Technology
1122311220peps0426        // (c) 1996 IGT - International Game Technology
1122411221peps0581        // (c) 1996 IGT - International Game Technology
1122511222peps0615        // (c) 1996 IGT - International Game Technology
trunk/src/mame/video/eolith.c
r243230r243231
3333VIDEO_START_MEMBER(eolith_state,eolith)
3434{
3535   m_vram = auto_alloc_array(machine(), UINT32, 0x40000*2/4);
36   save_pointer(NAME(m_vram), 0x40000*2/4);
36   save_pointer(NAME(m_vram), 0x40000*2/4);
3737   save_item(NAME(m_buffer));
3838}
3939
trunk/src/mame/video/gp9001.c
r243230r243231
175175   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(gp9001_fg_tmap_w) AM_SHARE("vram_fg")
176176   AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(gp9001_top_tmap_w) AM_SHARE("vram_top")
177177   AM_RANGE(0x3000, 0x37ff) AM_RAM AM_SHARE("spriteram") AM_MIRROR(0x0800)
178//  AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror?
178//   AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror?
179179ADDRESS_MAP_END
180180
181181
trunk/src/mame/video/pastelg.c
r243230r243231
283283   int height = m_screen->height();
284284
285285   m_videoram = auto_alloc_array_clear(machine(), UINT8, width * height);
286
286   
287287   save_item(NAME(m_blitter_desty));
288288   save_item(NAME(m_blitter_sizex));
289289   save_item(NAME(m_blitter_sizey));
trunk/src/mame/video/taitoair.c
r243230r243231
230230         int xx2 = x2 >> TAITOAIR_FRAC_SHIFT;
231231         int grad_col;
232232         int base_color;
233
233         
234234         if (xx1 <= cliprect.max_x || xx2 >= cliprect.min_x)
235235         {
236236            if (xx1 < cliprect.min_x)
237237               xx1 = cliprect.min_x;
238238            if (xx2 > cliprect.max_x)
239239               xx2 = cliprect.max_x;
240
240           
241241            if(color & 0x40)
242242            {
243243               /* Non-terrain elements are colored with this. */
trunk/src/mame/video/tia.c
r243230r243231
430430   helper[0] = auto_bitmap_ind16_alloc(machine(), cx, TIA_MAX_SCREEN_HEIGHT);
431431   helper[1] = auto_bitmap_ind16_alloc(machine(), cx, TIA_MAX_SCREEN_HEIGHT);
432432   helper[2] = auto_bitmap_ind16_alloc(machine(), cx, TIA_MAX_SCREEN_HEIGHT);
433
433   
434434   register_save_state();
435435}
436436
trunk/src/mame/video/tia.h
r243230r243231
199199   bitmap_ind16 *helper[3];
200200
201201   UINT16 screen_height;
202
202   
203203   void register_save_state();
204204};
205205
trunk/src/mame/video/tx1.c
r243230r243231
113113
114114PALETTE_INIT_MEMBER(tx1_state,tx1)
115115{
116   const UINT8 *const color_prom = &m_proms[0];
116   const UINT8 *color_prom = memregion("proms")->base();
117117   int i;
118118
119119   static const res_net_info tx1_net_info =
r243230r243231
233233   UINT16 *tx1_vram = m_vram;
234234   INT32 x, y;
235235   UINT32 scroll_x;
236   UINT8 *chars, *gfx2;
236237
237238   /* 2bpp characters */
238   const UINT8 *const chars = &m_char_tiles[0];
239   const UINT8 *const gfx2 = &m_char_tiles[0x4000];
239   chars = memregion("char_tiles")->base();
240   gfx2 = chars + 0x4000;
240241
241242   /* X scroll value is the last word in char RAM */
242243   scroll_x = tx1_vram[0xfff] & 0x3ff;
r243230r243231
413414   UINT8   pix[2][4][3];
414415
415416   /* Road slice map ROMs */
416   const UINT8 *const rom_a = &m_road_rom[0];
417   const UINT8 *const rom_b = &m_road_rom[0x2000];
418   const UINT8 *const rom_c = &m_road_rom[0x4000];
417   const UINT8 *const gfx3 = memregion("gfx3")->base();
418   const UINT8 *const rom_a = gfx3;
419   const UINT8 *const rom_b = gfx3 + 0x2000;
420   const UINT8 *const rom_c = gfx3 + 0x4000;
419421
420422   /* Pixel data */
421   const UINT8 *const prom_a = &m_proms[0x1100];
422   const UINT8 *const prom_b = &m_proms[0x1300];
423   const UINT8 *const prom_c = &m_proms[0x1500];
424   const UINT8 *const vprom  = &m_proms[0x1700];
423   const UINT8 *const proms = memregion("proms")->base();
424   const UINT8 *const prom_a = proms + 0x1100;
425   const UINT8 *const prom_b = proms + 0x1300;
426   const UINT8 *const prom_c = proms + 0x1500;
427   const UINT8 *const vprom  = proms + 0x1700;
425428
426429   rva9_8  = (tx1_vregs.flags & 3) << 8;
427430   rva7    = !BIT(tx1_vregs.flags, TX1_RDFLAG_RVA7) << 7;
r243230r243231
852855   UINT32 offs;
853856
854857   /* The many lookup table ROMs */
855   const UINT8 *const ic48 = &m_obj_luts[0];
856   const UINT8 *const ic281 = &m_obj_luts[0x2000];
858   const UINT8 *const ic48 = memregion("user3")->base();
859   const UINT8 *const ic281 = ic48 + 0x2000;
857860
858   const UINT8 *const ic190 = &m_proms[0xc00];
859   const UINT8 *const ic162 = &m_proms[0xe00];
860   const UINT8 *const ic25  = &m_proms[0x1000];
861   const UINT8 *const proms = memregion("proms")->base();
862   const UINT8 *const ic190 = proms + 0xc00;
863   const UINT8 *const ic162 = proms + 0xe00;
864   const UINT8 *const ic25  = proms + 0x1000;
861865
862   const UINT8 *const ic106 = &m_obj_map[0];
863   const UINT8 *const ic73  = &m_obj_map[0x4000];
866   const UINT8 *const ic106 = memregion("obj_map")->base();
867   const UINT8 *const ic73  = ic106 + 0x4000;
864868
865   const UINT8 *const pixdata_rgn = &m_obj_tiles[0];
869   const UINT8 *const pixdata_rgn = memregion("obj_tiles")->base();
866870
867871   for (offs = 0x0; offs <= 0x300; offs += 8)
868872   {
r243230r243231
991995                  dataend |= ic106_data & 0x40;
992996
993997                  /* Retrieve data for an 8x8 tile */
994                  ic73_data = ic73[rom_addr2 & 0x3fff];
998                  ic73_data = ic73[rom_addr2];
995999
9961000                  /* This is the data from the LUT pair */
9971001                  lut_data = (ic106_data << 8) | ic73_data;
r243230r243231
11261130void tx1_state::tx1_combine_layers(bitmap_ind16 &bitmap, int screen)
11271131{
11281132   int x, y;
1129   UINT8 *chr_pal = &m_proms[0x900];
1133   UINT8 *chr_pal = memregion("proms")->base() + 0x900;
11301134
11311135   int x_offset = screen * 256;
11321136
r243230r243231
12521256
12531257PALETTE_INIT_MEMBER(tx1_state,buggyboy)
12541258{
1255   const UINT8 *const color_prom = &m_proms[0];
1259   const UINT8 *color_prom = memregion("proms")->base();
12561260   int i;
12571261
12581262   for (i = 0; i < 0x100; i++)
r243230r243231
12971301   UINT16 *buggyboy_vram = m_vram;
12981302   INT32 x, y;
12991303   UINT32 scroll_x, scroll_y;
1304   UINT8 *chars, *gfx2;
13001305   UINT32 total_width;
13011306   UINT32 x_mask;
13021307
13031308   /* 2bpp characters */
1304   const UINT8 *const chars = &m_char_tiles[0];
1305   const UINT8 *const gfx2 = &m_char_tiles[0x4000];
1309   chars = memregion("char_tiles")->base();
1310   gfx2 = memregion("char_tiles")->base() + 0x4000;
13061311
13071312   /* X/Y scroll values are the last word in char RAM */
13081313   if (wide)
r243230r243231
14441449   UINT8 d1 = 0;
14451450
14461451   /* ROM/PROM lookup tables */
1447   const UINT8 *const rom   = &m_road_rom[0];
1448   const UINT8 *const prom0 = &m_road_rom[0x4000];
1449   const UINT8 *const prom1 = &m_road_rom[0x4200];
1450   const UINT8 *const prom2 = &m_road_rom[0x4400];
1452   const UINT8 *rom   = memregion("road")->base();
1453   const UINT8 *prom0 = rom + 0x4000;
1454   const UINT8 *prom1 = rom + 0x4200;
1455   const UINT8 *prom2 = rom + 0x4400;
14511456
14521457   /* Latch road reverse bit */
14531458   *_rorev = !( (rom_en && rom_flip) || (!rom_en && (ls161 & 0x4000)) );
r243230r243231
15381543   UINT32 rva20_6;
15391544
15401545   /* ROM/PROM lookup tables */
1541   const UINT8 *const rcols = &m_proms[0x1500];
1542   const UINT8 *const vprom = &m_road_rom[0x4600];
1546   const UINT8 *rcols = (UINT8*)(memregion("proms")->base() + 0x1500);
1547   const UINT8 *vprom   = memregion("road")->base() + 0x4600;
15431548
15441549   /* Extract constant values */
15451550   tcmd     = ((vregs.scol & 0xc000) >> 12) | ((vregs.scol & 0x00c0) >> 6);
r243230r243231
21652170   UINT32 rva20_6;
21662171
21672172   /* ROM/PROM lookup tables */
2168   const UINT8 *const rcols = &m_proms[0x1500];
2169   const UINT8 *const vprom = &m_road_rom[0x4600];
2173   const UINT8 *rcols = (UINT8*)(memregion("proms")->base() + 0x1500);
2174   const UINT8 *vprom = memregion("road")->base() + 0x4600;
21702175
21712176   /* Extract constant values */
21722177   tcmd     = ((vregs.scol & 0xc000) >> 12) | ((vregs.scol & 0x00c0) >> 6);
r243230r243231
25722577   UINT32 x_stride;
25732578
25742579   /* The many lookup table ROMs */
2575   const UINT8 *const bug13  = &m_obj_luts[0];
2576   const UINT8 *const bug18s = &m_obj_luts[0x2000];
2577   const UINT8 *const bb8    = &m_proms[0x1600];
2580   const UINT8 *const bug13  = (UINT8*)memregion("obj_luts")->base();
2581   const UINT8 *const bug18s = bug13 + 0x2000;
2582   const UINT8 *const bb8    = (UINT8*)memregion("proms")->base() + 0x1600;
25782583
2579   const UINT8 *const bug16s = &m_obj_map[0];
2580   const UINT8 *const bug17s = &m_obj_map[0x8000];
2584   const UINT8 *const bug16s = (UINT8*)memregion("obj_map")->base();
2585   const UINT8 *const bug17s = bug16s + 0x8000;
25812586
2582   const UINT8 *const bb9o = &m_proms[0x500];
2583   const UINT8 *const bb9e = &m_proms[0xd00];
2587   const UINT8 *const bb9o = (UINT8*)memregion("proms")->base() + 0x500;
2588   const UINT8 *const bb9e = bb9o + 0x800;
25842589
2585   const UINT8 *const pixdata_rgn = &m_obj_tiles[0];
2590   const UINT8 *const pixdata_rgn = (UINT8*)memregion("obj_tiles")->base();
25862591
25872592   if (wide)
25882593   {
r243230r243231
29222927
29232928void tx1_state::bb_combine_layers(bitmap_ind16 &bitmap, int screen)
29242929{
2925   UINT8 *chr_pal = &m_proms[0x400];
2930   UINT8 *chr_pal = memregion("proms")->base() + 0x400;
29262931   UINT32 bmp_stride;
29272932   UINT32 x_offset;
29282933   UINT32 y;
trunk/src/mess/drivers/a2600.c
r243230r243231
316316
317317   /* Banks may have changed, reset the cpu so it uses the correct reset vector */
318318   m_maincpu->reset();
319
319   
320320   save_item(NAME(m_current_screen_height));
321321}
322322
trunk/src/mess/drivers/banctec.c
r243230r243231
5959
6060MC6845_ON_UPDATE_ADDR_CHANGED(banctec_state::crtc_addr)
6161{
62   /* What is this function meant to do ? */
62  /* What is this function meant to do ? */
6363}
6464
6565/******************************
r243230r243231
103103
104104   MCFG_GFXDECODE_ADD("gfxdecode", "palette", banctec)
105105   MCFG_PALETTE_ADD("palette", 2)
106//  MCFG_PALETTE_INIT_OWNER(banctec_state, banctec)
106//   MCFG_PALETTE_INIT_OWNER(banctec_state, banctec)
107107
108108   MCFG_MC6845_ADD("crtc", R6545_1, "screen", XTAL_20MHz) /* (?) */
109109   MCFG_MC6845_SHOW_BORDER_AREA(false)
trunk/src/mess/drivers/bw12.c
r243230r243231
484484   save_item(NAME(m_motor_on));
485485   save_item(NAME(m_motor0));
486486   save_item(NAME(m_motor1));
487   save_item(NAME(m_centronics_busy));
488   save_item(NAME(m_centronics_fault));
489   save_item(NAME(m_centronics_perror));
490   machine().save().register_postload(save_prepost_delegate(FUNC(bw12_state::bankswitch), this));
491487}
492488
493489void bw12_state::machine_reset()
trunk/src/mess/drivers/c65.c
r243230r243231
1// license: MAME
2// copyright-holders: Angelo Salese
31/***************************************************************************
42
5C=65 / C=64DX (c) 1991 Commodore
3    commodore c65 home computer
4    PeT mess@utanet.at
65
7Attempt at rewriting the driver ...
6    documention
7     www.funet.fi
88
9TODO:
10- I need to subtract border color to -1 in order to get blue color (-> register is 6 and blue color is 5 in palette array).
11  Also top-left logo seems to draw wrong palette for entries 4,5,6,7. CPU core bug?
9***************************************************************************/
1210
13Note:
14- VIC-4567 will be eventually be added via compile switch, once that I
15  get the hang of the system (and checking where the old code fails
16  eventually)
11/*
1712
18***************************************************************************/
132008 - Driver Updates
14---------------------
1915
16(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
2017
21#include "emu.h"
22#include "cpu/m6502/m4510.h"
2318
24#define MAIN_CLOCK XTAL_3_5MHz
19[CBM systems which belong to this driver]
2520
26class c65_state : public driver_device
27{
28public:
29   c65_state(const machine_config &mconfig, device_type type, const char *tag)
30      : driver_device(mconfig, type, tag),
31         m_maincpu(*this, "maincpu"),
32         m_screen(*this, "screen"),
33         m_palette(*this, "palette"),
34         m_workram(*this, "wram"),
35         m_palred(*this, "redpal"),
36         m_palgreen(*this, "greenpal"),
37         m_palblue(*this, "bluepal"),
38         m_dmalist(*this, "dmalist"),
39         m_cram(*this, "cram"),
40         m_gfxdecode(*this, "gfxdecode")
41   { }
21* Commodore 65 (1989)
4222
43   // devices
44   required_device<m4510_device> m_maincpu;
45   required_device<screen_device> m_screen;
46   required_device<palette_device> m_palette;
47   required_shared_ptr<UINT8> m_workram;
48   required_shared_ptr<UINT8> m_palred;
49   required_shared_ptr<UINT8> m_palgreen;
50   required_shared_ptr<UINT8> m_palblue;
51   required_shared_ptr<UINT8> m_dmalist;
52   required_shared_ptr<UINT8> m_cram;
53   required_device<gfxdecode_device> m_gfxdecode;
23Also known as C64 DX at early stages of the project. It was cancelled
24around 1990-1991. Only few units survive (they were sold after Commodore
25liquidation in 1994).
5426
55   UINT8 *m_iplrom;
27CPU: CSG 4510 (3.54 MHz)
28RAM: 128 kilobytes, expandable to 8 megabytes
29ROM: 128 kilobytes
30Video: CSG 4569 "VIC-III" (6 Video modes; Resolutions from 320x200 to
31    1280x400; 80 columns text; Palette of 4096 colors)
32Sound: CSG 8580 "SID" x2 (6 voice stereo synthesizer/digital sound
33    capabilities)
34Ports: CSG 4510 (2 Joystick/Mouse ports; CBM Serial port; CBM 'USER'
35    port; CBM Monitor port; Power and reset switches; C65 bus drive
36    port; RGBI video port; 2 RCA audio ports; RAM expansion port; C65
37    expansion port)
38Keyboard: Full-sized 77 key QWERTY (12 programmable function keys;
39    4 direction cursor-pad)
40Additional Hardware: Built in 3.5" DD disk drive (1581 compatible)
41Miscellaneous: Partially implemented Commodore 64 emulation
5642
57   
58   DECLARE_READ8_MEMBER(vic4567_dummy_r);
59   DECLARE_WRITE8_MEMBER(vic4567_dummy_w);
60   DECLARE_WRITE8_MEMBER(PalRed_w);
61   DECLARE_WRITE8_MEMBER(PalGreen_w);
62   DECLARE_WRITE8_MEMBER(PalBlue_w);
63   DECLARE_WRITE8_MEMBER(DMAgic_w);
64   DECLARE_READ8_MEMBER(CIASelect_r);
65   DECLARE_WRITE8_MEMBER(CIASelect_w);
66   
67   DECLARE_READ8_MEMBER(dummy_r);
68   
69   // screen updates
70   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
71   DECLARE_PALETTE_INIT(c65);
72   DECLARE_DRIVER_INIT(c65);
73   DECLARE_DRIVER_INIT(c65pal);
74   
75   INTERRUPT_GEN_MEMBER(vic3_vblank_irq);
76protected:
77   // driver_device overrides
78   virtual void machine_start();
79   virtual void machine_reset();
43[Notes]
8044
81   virtual void video_start();
82private:
83   UINT8 m_VIC2_IRQPend, m_VIC2_IRQMask;
84   /* 0x20: border color (TODO: different thread?) */
85   UINT8 m_VIC2_EXTColor;
86   /* 0x30: banking + PAL + EXT SYNC */
87   UINT8 m_VIC3_ControlA;
88   /* 0x31: video modes */
89   UINT8 m_VIC3_ControlB;
90   void PalEntryFlush(UINT8 offset);
91   void DMAgicExecute(address_space &space,UINT32 address);
92   int inner_x_char(int xoffs);
93   int inner_y_char(int yoffs);
94};
45The datasette port was removed here. C65 supports an additional "dumb"
46drive externally. It also features, in addition to the standard CBM
47bus serial (available in all modes), a Fast and a Burst serial bus
48(both available in C65 mode only)
9549
96void c65_state::video_start()
97{
98}
50*/
9951
100// TODO: inline?
101int c65_state::inner_x_char(int xoffs)
52
53#include "emu.h"
54#include "cpu/m6502/m4510.h"
55#include "machine/mos6526.h"
56#include "machine/cbm_snqk.h"
57#include "includes/c65.h"
58#include "bus/cbmiec/cbmiec.h"
59#include "machine/ram.h"
60
61static void cbm_c65_quick_sethiaddress( address_space &space, UINT16 hiaddress )
10262{
103   return xoffs>>3;
63   space.write_byte(0x82, hiaddress & 0xff);
64   space.write_byte(0x83, hiaddress >> 8);
10465}
10566
106int c65_state::inner_y_char(int yoffs)
67QUICKLOAD_LOAD_MEMBER( c65_state, cbm_c65 )
10768{
108   return yoffs>>3;
69   return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_c65_quick_sethiaddress);
10970}
11071
111UINT32 c65_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
112{
113   int y,x;
114   int border_color = m_VIC2_EXTColor & 0xf;
115   
116   // TODO: border area
117   for(y=0;y<m_screen->height();y++)
118   {
119      for(x=0;x<m_screen->width();x++)
120      {
121         //int, xi,yi,xm,ym,dot_x;
122         int xi = inner_x_char(x);
123         int yi = inner_y_char(y);
124         int xm = 7 - (x & 7);
125         int ym = (y & 7);
126         UINT8 tile = m_workram[xi+yi*80+0x800];
127         UINT8 attr = m_cram[xi+yi*80];
128         if(attr & 0xf0)
129            attr = machine().rand() & 0xf;
130         
131         int enable_dot = ((m_iplrom[(tile<<3)+ym+0xd000] >> xm) & 1);
132                 
133         //if(cliprect.contains(x, y))
134         bitmap.pix16(y, x) = m_palette->pen((enable_dot) ? attr & 0xf : border_color);
72/*************************************
73 *
74 *  Main CPU memory handlers
75 *
76 *************************************/
13577
136         
137         //gfx->opaque(bitmap,cliprect,tile,0,0,0,x*8,y*8);
138      }
139   }
78static ADDRESS_MAP_START( c65_mem , AS_PROGRAM, 8, c65_state )
79   AM_RANGE(0x00000, 0x07fff) AM_RAMBANK("bank11")
80   AM_RANGE(0x08000, 0x09fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank12")
81   AM_RANGE(0x0a000, 0x0bfff) AM_READ_BANK("bank2") AM_WRITE_BANK("bank13")
82   AM_RANGE(0x0c000, 0x0cfff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank14")
83   AM_RANGE(0x0d000, 0x0d7ff) AM_READ_BANK("bank4") AM_WRITE_BANK("bank5")
84   AM_RANGE(0x0d800, 0x0dbff) AM_READ_BANK("bank6") AM_WRITE_BANK("bank7")
85   AM_RANGE(0x0dc00, 0x0dfff) AM_READ_BANK("bank8") AM_WRITE_BANK("bank9")
86   AM_RANGE(0x0e000, 0x0ffff) AM_READ_BANK("bank10") AM_WRITE_BANK("bank15")
87   AM_RANGE(0x10000, 0x1f7ff) AM_RAM
88   AM_RANGE(0x1f800, 0x1ffff) AM_RAM AM_SHARE("colorram")
14089
141   return 0;
142}
90   AM_RANGE(0x20000, 0x23fff) AM_ROM /* &c65_dos,     maps to 0x8000    */
91   AM_RANGE(0x24000, 0x28fff) AM_ROM /* reserved */
92   AM_RANGE(0x29000, 0x29fff) AM_ROM AM_SHARE("c65_chargen")
93   AM_RANGE(0x2a000, 0x2bfff) AM_ROM AM_SHARE("basic")
94   AM_RANGE(0x2c000, 0x2cfff) AM_ROM AM_SHARE("interface")
95   AM_RANGE(0x2d000, 0x2dfff) AM_ROM AM_SHARE("chargen")
96   AM_RANGE(0x2e000, 0x2ffff) AM_ROM AM_SHARE("kernal")
14397
144READ8_MEMBER(c65_state::vic4567_dummy_r)
145{
146   UINT8 res;
98   AM_RANGE(0x30000, 0x31fff) AM_ROM /*&c65_monitor,     monitor maps to 0x6000    */
99   AM_RANGE(0x32000, 0x37fff) AM_ROM /*&c65_basic, */
100   AM_RANGE(0x38000, 0x3bfff) AM_ROM /*&c65_graphics, */
101   AM_RANGE(0x3c000, 0x3dfff) AM_ROM /* reserved */
102   AM_RANGE(0x3e000, 0x3ffff) AM_ROM /* &c65_kernal, */
147103
148   res=0xff;
149   switch(offset)
150   {
151      case 0x11:
152         res = (m_screen->vpos() & 0x100) >> 1;
153         return res;
154      case 0x12:
155         res = (m_screen->vpos() & 0xff);
156         return res;
157      case 0x20:
158         return m_VIC2_EXTColor;
159      case 0x19:
160         return m_VIC2_IRQPend;
161      case 0x30:
162         return m_VIC3_ControlA;
163      case 0x31:
164         return m_VIC3_ControlB;
165   }
166   
167   if(!space.debugger_access())
168      printf("%02x\n",offset); // TODO: PC
169   return res;
170}
104   AM_RANGE(0x40000, 0x7ffff) AM_NOP
105   /* 8 megabyte full address space! */
106ADDRESS_MAP_END
171107
172WRITE8_MEMBER(c65_state::vic4567_dummy_w)
108
109/*************************************
110 *
111 *  Input Ports
112 *
113 *************************************/
114
115static INPUT_PORTS_START( c65 )
116   PORT_START( "ROW0" )
117   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Down Up") PORT_CODE(KEYCODE_RALT)        PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(UP))
118   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3)                                    PORT_CHAR(UCHAR_MAMEKEY(F5))
119   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2)                                    PORT_CHAR(UCHAR_MAMEKEY(F3))
120   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1)                                    PORT_CHAR(UCHAR_MAMEKEY(F1))
121   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4)                                    PORT_CHAR(UCHAR_MAMEKEY(F7))
122   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Right Left") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
123   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER)             PORT_CHAR(13)
124   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("INST DEL") PORT_CODE(KEYCODE_BACKSPACE)       PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
125
126   PORT_START( "ROW1" )
127   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Left)") PORT_CODE(KEYCODE_LSHIFT)      PORT_CHAR(UCHAR_SHIFT_1)
128   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E)         PORT_CHAR('E')
129   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S)         PORT_CHAR('S')
130   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z)         PORT_CHAR('Z')
131   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4)         PORT_CHAR('4') PORT_CHAR('$')
132   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A)         PORT_CHAR('A')
133   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W)         PORT_CHAR('W')
134   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3)         PORT_CHAR('3') PORT_CHAR('#')
135
136   PORT_START( "ROW2" )
137   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X)         PORT_CHAR('X')
138   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T)         PORT_CHAR('T')
139   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F)         PORT_CHAR('F')
140   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C)         PORT_CHAR('C')
141   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6)         PORT_CHAR('6') PORT_CHAR('&')
142   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D)         PORT_CHAR('D')
143   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R)         PORT_CHAR('R')
144   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5)         PORT_CHAR('5') PORT_CHAR('%')
145
146   PORT_START( "ROW3" )
147   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V)         PORT_CHAR('V')
148   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U)         PORT_CHAR('U')
149   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H)         PORT_CHAR('H')
150   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B)         PORT_CHAR('B')
151   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8)         PORT_CHAR('8') PORT_CHAR('(')
152   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G)         PORT_CHAR('G')
153   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y)         PORT_CHAR('Y')
154   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7)         PORT_CHAR('7') PORT_CHAR('\'')
155
156   PORT_START( "ROW4" )
157   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N)         PORT_CHAR('N')
158   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O)         PORT_CHAR('O')
159   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K)         PORT_CHAR('K')
160   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M)         PORT_CHAR('M')
161   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0)         PORT_CHAR('0')
162   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J)         PORT_CHAR('J')
163   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I)         PORT_CHAR('I')
164   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9)         PORT_CHAR('9') PORT_CHAR(')')
165
166   PORT_START( "ROW5" )
167   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA)     PORT_CHAR(',') PORT_CHAR('<')
168   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')
169   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON)     PORT_CHAR(':') PORT_CHAR('[')
170   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)      PORT_CHAR('.') PORT_CHAR('>')
171   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('-')
172   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L)         PORT_CHAR('L')
173   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P)         PORT_CHAR('P')
174   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS)     PORT_CHAR('+')
175
176   PORT_START( "ROW6" )
177   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH)                             PORT_CHAR('/') PORT_CHAR('?')
178   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91  Pi") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x2191) PORT_CHAR(0x03C0)
179   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH)                         PORT_CHAR('=')
180   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
181   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CLR HOME") PORT_CODE(KEYCODE_INSERT)      PORT_CHAR(UCHAR_MAMEKEY(HOME))
182   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE)                             PORT_CHAR(';') PORT_CHAR(']')
183   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)                        PORT_CHAR('*')
184   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)                        PORT_CHAR('\xA3')
185
186   PORT_START( "ROW7" )
187   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RUN STOP") PORT_CODE(KEYCODE_HOME)
188   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q)                                 PORT_CHAR('Q')
189   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CBM") PORT_CODE(KEYCODE_LALT)
190   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)                             PORT_CHAR(' ')
191   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2)                                 PORT_CHAR('2') PORT_CHAR('"')
192   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB)                               PORT_CHAR(UCHAR_SHIFT_2)
193   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_TILDE)   PORT_CHAR(0x2190)
194   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1)                                 PORT_CHAR('1') PORT_CHAR('!')
195   PORT_START("FUNCT")
196   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_F1)
197   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13 F14") PORT_CODE(KEYCODE_F11)
198   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11 F12") PORT_CODE(KEYCODE_F10)
199   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9 F10") PORT_CODE(KEYCODE_F9)
200   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_F12)
201   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ALT") PORT_CODE(KEYCODE_F2)       /* non blocking */
202   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB)
203   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NO SCRL") PORT_CODE(KEYCODE_F4)
204
205   PORT_START( "SPECIAL" )  /* special keys */
206   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR)
207   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
208   PORT_CONFNAME( 0x20, 0x00, "(C65) Caps Lock (switch)") PORT_CODE(KEYCODE_F3)
209   PORT_CONFSETTING(   0x00, DEF_STR( Off ) )
210   PORT_CONFSETTING(   0x20, DEF_STR( On ) )
211   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
212
213   PORT_START("CTRLSEL")   /* Controller selection */
214   PORT_CONFNAME( 0x07, 0x00, "Gameport A" )
215   PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) )
216   PORT_CONFSETTING( 0x01, "Paddles 1 & 2" )
217   PORT_CONFSETTING( 0x02, "Mouse 1351" )
218   PORT_CONFSETTING( 0x03, "Mouse (Non Proportional) 1350" )
219   PORT_CONFSETTING( 0x04, "Lightpen" )
220//  PORT_CONFSETTING( 0x05, "Koala Pad" )
221   PORT_CONFSETTING( 0x06, "Lightgun" )
222   PORT_CONFSETTING( 0x07, "No Device Connected" )
223   PORT_CONFNAME( 0x70, 0x00, "Gameport B" )
224   PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) )
225   PORT_CONFSETTING( 0x10, "Paddles 3 & 4" )
226//  PORT_CONFSETTING( 0x20, "Mouse 1351" )
227//  PORT_CONFSETTING( 0x30, "Mouse (Non Proportional) 1350" )
228   PORT_CONFSETTING( 0x70, "No Device Connected" )
229   PORT_CONFNAME( 0x80, 0x00, "Swap Gameport A and B") PORT_CODE(KEYCODE_F1) PORT_TOGGLE
230   PORT_CONFSETTING(   0x00, DEF_STR( No ) )
231   PORT_CONFSETTING(   0x80, DEF_STR( Yes ) )
232
233   PORT_START("JOY1_1B")
234   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
235   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
236   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
237   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
238   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
239   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
240
241   PORT_START("JOY2_1B")
242   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
243   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
244   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
245   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
246   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
247   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
248
249   /* Mouse Commodore 1350 was basically working as a Joystick */
250   PORT_START("JOY1_2B")
251   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Up") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
252   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Down") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
253   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Left") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
254   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Right") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
255   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 1") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
256   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 2") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
257   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
258
259   /* Still to verify how many mices you were able to plug into a c64 */
260   /* Only one, for now */
261   PORT_START("JOY2_2B")
262   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
263/*  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH)
264    PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
265    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
266    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
267    PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
268    PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_PGUP) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
269    PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
270*/
271   PORT_START("PADDLE1")
272   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
273
274   PORT_START("PADDLE2")
275   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_DOWN) PORT_CODE_INC(KEYCODE_UP) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
276
277   PORT_START("PADDLE3")
278   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_HOME) PORT_CODE_INC(KEYCODE_PGUP) PORT_PLAYER(3) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
279
280   PORT_START("PADDLE4")
281   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_END) PORT_CODE_INC(KEYCODE_PGDN) PORT_PLAYER(4) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
282
283   PORT_START("TRACKX")
284   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
285
286   PORT_START("TRACKY")
287   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
288
289   PORT_START("LIGHTX")
290   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04)
291
292   PORT_START("LIGHTY")
293   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04)
294
295   PORT_START("OTHER")
296   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle 1 Button") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
297   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Paddle 2 Button") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
298   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Paddle 3 Button") PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
299   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4) PORT_NAME("Paddle 4 Button") PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
300   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Lightpen Signal") PORT_CODE(KEYCODE_LCONTROL) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04)
301   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button Left") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
302   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Button Right") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)INPUT_PORTS_END
303
304
305static INPUT_PORTS_START( c65ger )
306   PORT_INCLUDE( c65 )
307
308   PORT_MODIFY( "ROW1" )
309   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z  { Y }") PORT_CODE(KEYCODE_Z)                   PORT_CHAR('Z')
310   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3  #  { 3  Paragraph }") PORT_CODE(KEYCODE_3)     PORT_CHAR('3') PORT_CHAR('#')
311
312   PORT_MODIFY( "ROW3" )
313   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Y  { Z }") PORT_CODE(KEYCODE_Y)                   PORT_CHAR('Y')
314   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("7 ' { 7  / }") PORT_CODE(KEYCODE_7)               PORT_CHAR('7') PORT_CHAR('\'')
315
316   PORT_MODIFY( "ROW4" )
317   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0  { = }") PORT_CODE(KEYCODE_0)                   PORT_CHAR('0')
318
319   PORT_MODIFY( "ROW5" )
320   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(",  <  { ; }") PORT_CODE(KEYCODE_COMMA)            PORT_CHAR(',') PORT_CHAR('<')
321   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Paragraph  \xE2\x86\x91  { \xc3\xbc }") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR(0x00A7) PORT_CHAR(0x2191)
322   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(":  [  { \xc3\xa4 }") PORT_CODE(KEYCODE_COLON)     PORT_CHAR(':') PORT_CHAR('[')
323   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(".  >  { : }") PORT_CODE(KEYCODE_STOP)             PORT_CHAR('.') PORT_CHAR('>')
324   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("-  { '  ` }") PORT_CODE(KEYCODE_EQUALS)           PORT_CHAR('-')
325   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("+  { \xc3\x9f ? }") PORT_CODE(KEYCODE_MINUS)      PORT_CHAR('+')
326
327   PORT_MODIFY( "ROW6" )
328   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/  ?  { -  _ }") PORT_CODE(KEYCODE_SLASH)         PORT_CHAR('/') PORT_CHAR('?')
329   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Sum Pi  { ]  \\ }") PORT_CODE(KEYCODE_DEL)        PORT_CHAR(0x03A3) PORT_CHAR(0x03C0)
330   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("=  { #  ' }") PORT_CODE(KEYCODE_BACKSLASH)        PORT_CHAR('=')
331   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(";  ]  { \xc3\xb6 }") PORT_CODE(KEYCODE_QUOTE)     PORT_CHAR(';') PORT_CHAR(']')
332   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("*  `  { +  * }") PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR('*') PORT_CHAR('`')
333   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\\  { [ \xE2\x86\x91 }") PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xa3')
334
335   PORT_MODIFY( "ROW7" )
336   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("_  { <  > }") PORT_CODE(KEYCODE_TILDE)            PORT_CHAR('_')
337
338   PORT_MODIFY("SPECIAL") /* special keys */
339   PORT_DIPNAME( 0x20, 0x00, "(C65) DIN ASC (switch)") PORT_CODE(KEYCODE_F3)
340   PORT_DIPSETTING(    0x00, "ASC" )
341   PORT_DIPSETTING(    0x20, "DIN" )
342INPUT_PORTS_END
343
344
345
346/*************************************
347 *
348 *  Sound definitions
349 *
350 *************************************/
351
352int c65_state::c64_paddle_read( device_t *device, address_space &space, int which )
173353{
174   switch(offset)
354   int pot1 = 0xff, pot2 = 0xff, pot3 = 0xff, pot4 = 0xff, temp;
355   UINT8 cia0porta = machine().device<mos6526_device>("cia_0")->pa_r(space, 0);
356   int controller1 = ioport("CTRLSEL")->read() & 0x07;
357   int controller2 = ioport("CTRLSEL")->read() & 0x70;
358   /* Notice that only a single input is defined for Mouse & Lightpen in both ports */
359   switch (controller1)
175360   {
176      case 0x19:
177         m_VIC2_IRQPend = data & 0x8f;
361      case 0x01:
362         if (which)
363            pot2 = ioport("PADDLE2")->read();
364         else
365            pot1 = ioport("PADDLE1")->read();
178366         break;
179      case 0x1a:
180         m_VIC2_IRQMask = data & 0xf;
367
368      case 0x02:
369         if (which)
370            pot2 = ioport("TRACKY")->read();
371         else
372            pot1 = ioport("TRACKX")->read();
181373         break;
182      case 0x20:
183         m_VIC2_EXTColor = data & 0xf;
374
375      case 0x03:
376         if (which && (ioport("JOY1_2B")->read() & 0x20))  /* Joy1 Button 2 */
377            pot1 = 0x00;
184378         break;
185      /* KEY register, handles vic-iii and vic-ii modes via two consecutive writes
186        0xa5 -> 0x96 vic-iii mode
187          any other write vic-ii mode
188        */
189      //case 0x2f: break;
190      case 0x30:
191         if((data & 0xfe) != 0x64)
192            printf("CONTROL A %02x\n",data);
193         m_VIC3_ControlA = data;
379
380      case 0x04:
381         if (which)
382            pot2 = ioport("LIGHTY")->read();
383         else
384            pot1 = ioport("LIGHTX")->read();
194385         break;
195      case 0x31:
196         printf("CONTROL B %02x\n",data);
197         m_VIC3_ControlB = data;
386
387      case 0x06:
388         if (which && (ioport("OTHER")->read() & 0x04))    /* Lightpen Signal */
389            pot2 = 0x00;
198390         break;
391
392      case 0x00:
393      case 0x07:
394         break;
395
199396      default:
200         if(!space.debugger_access())
201            printf("%02x %02x\n",offset,data);
397         logerror("Invalid Controller Setting %d\n", controller1);
202398         break;
203399   }
204400
205}
401   switch (controller2)
402   {
403      case 0x10:
404         if (which)
405            pot4 = ioport("PADDLE4")->read();
406         else
407            pot3 = ioport("PADDLE3")->read();
408         break;
206409
207void c65_state::PalEntryFlush(UINT8 offset)
208{
209   m_palette->set_pen_color(offset, pal4bit(m_palred[offset]), pal4bit(m_palgreen[offset]), pal4bit(m_palblue[offset]));
210}
410      case 0x20:
411         if (which)
412            pot4 = ioport("TRACKY")->read();
413         else
414            pot3 = ioport("TRACKX")->read();
415         break;
211416
212WRITE8_MEMBER(c65_state::PalRed_w)
213{
214   m_palred[offset] = data;
215   PalEntryFlush(offset);
216}
417      case 0x30:
418         if (which && (ioport("JOY2_2B")->read() & 0x20))  /* Joy2 Button 2 */
419            pot4 = 0x00;
420         break;
217421
218WRITE8_MEMBER(c65_state::PalGreen_w)
219{
220   m_palgreen[offset] = data;
221   PalEntryFlush(offset);
222}
422      case 0x40:
423         if (which)
424            pot4 = ioport("LIGHTY")->read();
425         else
426            pot3 = ioport("LIGHTX")->read();
427         break;
223428
224WRITE8_MEMBER(c65_state::PalBlue_w)
225{
226   m_palblue[offset] = data;
227   PalEntryFlush(offset);
228}
429      case 0x60:
430         if (which && (ioport("OTHER")->read() & 0x04))    /* Lightpen Signal */
431            pot4 = 0x00;
432         break;
229433
230void c65_state::DMAgicExecute(address_space &space,UINT32 address)
231{
232   UINT8 cmd;// = space.read_byte(address++);
233   UINT16 length; //= space.read_byte(address++);
234   UINT32 src, dst;
235   static const char *const dma_cmd_string[] =
434      case 0x00:
435      case 0x70:
436         break;
437
438      default:
439         logerror("Invalid Controller Setting %d\n", controller1);
440         break;
441   }
442
443   if (ioport("CTRLSEL")->read() & 0x80)     /* Swap */
236444   {
237      "COPY",                 // 0
238      "MIX",
239      "SWAP",
240      "FILL"
241   };
242   cmd = space.read_byte(address++);
243   length = space.read_byte(address++);
244   length|=(space.read_byte(address++)<<8);
245   src = space.read_byte(address++);
246   src|=(space.read_byte(address++)<<8);
247   src|=(space.read_byte(address++)<<16);
248   dst = space.read_byte(address++);
249   dst|=(space.read_byte(address++)<<8);
250   dst|=(space.read_byte(address++)<<16);
445      temp = pot1; pot1 = pot3; pot3 = temp;
446      temp = pot2; pot2 = pot4; pot4 = temp;
447   }
251448
252   if(cmd & 0xfc)
253      printf("%02x\n",cmd & 0xfc);
254   switch(cmd & 3)
449   switch (cia0porta & 0xc0)
255450   {
256      case 0: // copy - TODO: untested
257      {
258            if(length != 1)
259               printf("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no");
260            UINT32 SourceIndex;
261            UINT32 DestIndex;
262            UINT16 SizeIndex;
263            SourceIndex = src & 0xfffff;
264            DestIndex = dst & 0xfffff;
265            SizeIndex = length;
266            do
267            {
268               space.write_byte(DestIndex++,space.read_byte(SourceIndex++));
269               SizeIndex--;
270            }while(SizeIndex != 0);
451      case 0x40:
452         return which ? pot2 : pot1;
271453
272         return;
273      }
274      case 3: // fill
275         {
276            /* TODO: upper bits of source */
277            printf("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src & 0xff,dst,length,cmd & 4 ? "yes" : "no");
278            UINT8 FillValue;
279            UINT32 DestIndex;
280            UINT16 SizeIndex;
281            FillValue = src & 0xff;
282            DestIndex = dst & 0xfffff;
283            SizeIndex = length;
284            do
285            {
286               space.write_byte(DestIndex++,FillValue);
287               SizeIndex--;
288            }while(SizeIndex != 0);
289         }
290         return;
291   }
292   printf("DMAgic %s %08x %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no");
293}
454      case 0x80:
455         return which ? pot4 : pot3;
294456
457      case 0xc0:
458         return which ? pot2 : pot1;
295459
296WRITE8_MEMBER(c65_state::DMAgic_w)
297{
298   m_dmalist[offset] = data;
299   if(offset == 0)
300      DMAgicExecute(space,(m_dmalist[0])|(m_dmalist[1]<<8)|(m_dmalist[2]<<16));
460      default:
461         return 0;
462   }
301463}
302464
303READ8_MEMBER(c65_state::CIASelect_r)
465READ8_MEMBER( c65_state::sid_potx_r )
304466{
305   if(m_VIC3_ControlA & 1)
306      return m_cram[offset];
307   else
308   {
309      // CIA at 0xdc00
310   }
311
312   return 0xff;
467   return c64_paddle_read(m_sid_r, space, 0);
313468}
314469
315WRITE8_MEMBER(c65_state::CIASelect_w)
470READ8_MEMBER( c65_state::sid_poty_r )
316471{
317   if(m_VIC3_ControlA & 1)
318      m_cram[offset] = data;
319   else
320   {
321      // CIA at 0xdc00
322   }
323   
472   return c64_paddle_read(m_sid_r, space, 1);
324473}
325474
326READ8_MEMBER(c65_state::dummy_r)
475
476/*************************************
477 *
478 *  VIC III interfaces
479 *
480 *************************************/
481
482UINT32 c65_state::screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
327483{
484   m_vic->video_update(bitmap, cliprect);
328485   return 0;
329486}
330487
331static ADDRESS_MAP_START( c65_map, AS_PROGRAM, 8, c65_state )
332   AM_RANGE(0x00000, 0x07fff) AM_RAM AM_SHARE("wram") // TODO: bank
333   AM_RANGE(0x0c800, 0x0cfff) AM_ROM AM_REGION("maincpu", 0xc800)
334   AM_RANGE(0x0d000, 0x0d07f) AM_READWRITE(vic4567_dummy_r,vic4567_dummy_w) // 0x0d000, 0x0d07f VIC-4567
335   AM_RANGE(0x0d080, 0x0d081) AM_READ(dummy_r) // 0x0d080, 0x0d09f FDC
336   // 0x0d0a0, 0x0d0ff Ram Expansion Control (REC)
337   AM_RANGE(0x0d100, 0x0d1ff) AM_RAM_WRITE(PalRed_w) AM_SHARE("redpal")// 0x0d100, 0x0d1ff Red Palette
338   AM_RANGE(0x0d200, 0x0d2ff) AM_RAM_WRITE(PalGreen_w) AM_SHARE("greenpal") // 0x0d200, 0x0d2ff Green Palette
339   AM_RANGE(0x0d300, 0x0d3ff) AM_RAM_WRITE(PalBlue_w) AM_SHARE("bluepal") // 0x0d300, 0x0d3ff Blue Palette
340   // 0x0d400, 0x0d4*f Right SID
341   // 0x0d440, 0x0d4*f Left  SID
342   // 0x0d600, 0x0d6** UART
343   AM_RANGE(0x0d700, 0x0d702) AM_WRITE(DMAgic_w) AM_SHARE("dmalist") // 0x0d700, 0x0d7** DMAgic
344   //AM_RANGE(0x0d703, 0x0d703) AM_READ(DMAgic_r)
345   // 0x0d800, 0x0d8** Color matrix
346   AM_RANGE(0x0d800, 0x0dfff) AM_READWRITE(CIASelect_r,CIASelect_w) AM_SHARE("cram")
347   // 0x0dc00, 0x0dc** CIA-1
348   // 0x0dd00, 0x0dd** CIA-2
349   // 0x0de00, 0x0de** Ext I/O Select 1
350   // 0x0df00, 0x0df** Ext I/O Select 2 (RAM window?)
351   AM_RANGE(0x0e000, 0x0ffff) AM_ROM AM_REGION("maincpu",0x0e000)
352   AM_RANGE(0x10000, 0x1f7ff) AM_RAM
353   AM_RANGE(0x1f800, 0x1ffff) AM_RAM // VRAM attributes
354   AM_RANGE(0x20000, 0x3ffff) AM_ROM AM_REGION("maincpu",0)
355ADDRESS_MAP_END
356
357
358
359static INPUT_PORTS_START( c65 )
360   /* dummy active high structure */
361   PORT_START("SYSA")
362   PORT_DIPNAME( 0x01, 0x00, "SYSA" )
363   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
364   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
365   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
366   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
367   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
368   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
369   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
370   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
371   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
372   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
373   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
374   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
375   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
376   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
377   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
378   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
379   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
380   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
381   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
382   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
383   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
384   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
385   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
386
387   /* dummy active low structure */
388   PORT_START("DSWA")
389   PORT_DIPNAME( 0x01, 0x01, "DSWA" )
390   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
391   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
392   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
393   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
394   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
395   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
396   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
397   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
398   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
399   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
400   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
401   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
402   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
403   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
404   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
405   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
406   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
407   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
408   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
409   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
410   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
411   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
412   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
413INPUT_PORTS_END
414
415
416void c65_state::machine_start()
488READ8_MEMBER(c65_state::c65_lightpen_x_cb)
417489{
418   m_iplrom = memregion("maincpu")->base();
419
420   save_pointer(NAME(m_cram.target()), 0x800);
490   return ioport("LIGHTX")->read() & ~0x01;
421491}
422492
423void c65_state::machine_reset()
493READ8_MEMBER(c65_state::c65_lightpen_y_cb)
424494{
495   return ioport("LIGHTY")->read() & ~0x01;
425496}
426497
427
428PALETTE_INIT_MEMBER(c65_state, c65)
498READ8_MEMBER(c65_state::c65_lightpen_button_cb)
429499{
430   // TODO: initial state?
500   return ioport("OTHER")->read() & 0x04;
431501}
432502
433static const gfx_layout charlayout =
503READ8_MEMBER(c65_state::c65_c64_mem_r)
434504{
435   8,8,
436   0x1000/8,
437   1,
438   { RGN_FRAC(0,1) },
439   { 0, 1, 2, 3, 4, 5, 6, 7 },
440   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
441   8*8
442};
505   return m_memory[offset];
506}
443507
444static GFXDECODE_START( c65 )
445   GFXDECODE_ENTRY( "maincpu", 0xd000, charlayout,     0, 16 ) // another identical copy is at 0x9000
446GFXDECODE_END
447
448INTERRUPT_GEN_MEMBER(c65_state::vic3_vblank_irq)
508INTERRUPT_GEN_MEMBER(c65_state::vic3_raster_irq)
449509{
450   //if(m_VIC2_IRQMask & 1)
451   //   m_maincpu->set_input_line(M4510_IRQ_LINE,HOLD_LINE);
510   m_vic->raster_interrupt_gen();
452511}
453512
513/*************************************
514 *
515 *  Machine driver
516 *
517 *************************************/
518
454519static MACHINE_CONFIG_START( c65, c65_state )
455
456520   /* basic machine hardware */
457   MCFG_CPU_ADD("maincpu",M4510,MAIN_CLOCK)
458   MCFG_CPU_PROGRAM_MAP(c65_map)
459   MCFG_CPU_VBLANK_INT_DRIVER("screen",c65_state,vic3_vblank_irq)
521   MCFG_CPU_ADD("maincpu", M4510, 3500000)  /* or VIC6567_CLOCK, */
522   MCFG_CPU_PROGRAM_MAP(c65_mem)
523   MCFG_CPU_VBLANK_INT_DRIVER("screen", c65_state,  c65_frame_interrupt)
524   MCFG_CPU_PERIODIC_INT_DRIVER(c65_state, vic3_raster_irq,  VIC6567_HRETRACERATE)
460525
526   MCFG_MACHINE_START_OVERRIDE(c65_state, c65 )
527
461528   /* video hardware */
462529   MCFG_SCREEN_ADD("screen", RASTER)
463//  MCFG_SCREEN_REFRESH_RATE(60)
464//  MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
465   MCFG_SCREEN_UPDATE_DRIVER(c65_state, screen_update)
466//  MCFG_SCREEN_SIZE(32*8, 32*8)
467//  MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)
468   MCFG_SCREEN_RAW_PARAMS(MAIN_CLOCK, 910, 0, 640, 525, 0, 200) // mods needed
469   MCFG_SCREEN_PALETTE("palette")
530   MCFG_SCREEN_REFRESH_RATE(VIC6567_VRETRACERATE)
531   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
532   MCFG_SCREEN_SIZE(525 * 2, 520 * 2)
533   MCFG_SCREEN_VISIBLE_AREA(VIC6567_STARTVISIBLECOLUMNS ,(VIC6567_STARTVISIBLECOLUMNS + VIC6567_VISIBLECOLUMNS - 1) * 2, VIC6567_STARTVISIBLELINES, VIC6567_STARTVISIBLELINES + VIC6567_VISIBLELINES - 1)
534   MCFG_SCREEN_UPDATE_DRIVER(c65_state, screen_update_c65)
535   MCFG_SCREEN_PALETTE("vic3:palette")
470536
471   MCFG_GFXDECODE_ADD("gfxdecode", "palette", c65)
537   MCFG_DEVICE_ADD("vic3", VIC3, 0)
538   MCFG_VIC3_CPU("maincpu")
539   MCFG_VIC3_TYPE(VIC4567_NTSC)
540   MCFG_VIC3_LIGHTPEN_X_CB(READ8(c65_state, c65_lightpen_x_cb))
541   MCFG_VIC3_LIGHTPEN_Y_CB(READ8(c65_state, c65_lightpen_y_cb))
542   MCFG_VIC3_LIGHTPEN_BUTTON_CB(READ8(c65_state, c65_lightpen_button_cb))
543   MCFG_VIC3_DMA_READ_CB(READ8(c65_state, c65_dma_read))
544   MCFG_VIC3_DMA_READ_COLOR_CB(READ8(c65_state, c65_dma_read_color))
545   MCFG_VIC3_INTERRUPT_CB(WRITELINE(c65_state, c65_vic_interrupt))
546   MCFG_VIC3_PORT_CHANGED_CB(WRITE8(c65_state, c65_bankswitch_interface))
547   MCFG_VIC3_C64_MEM_R_CB(READ8(c65_state, c65_c64_mem_r))
472548
473   MCFG_PALETTE_ADD("palette", 0x100)
474   MCFG_PALETTE_INIT_OWNER(c65_state, c65)
549   /* sound hardware */
550   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
551   MCFG_SOUND_ADD("sid_r", MOS8580, 985248)
552   MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r))
553   MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r))
554   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
555   MCFG_SOUND_ADD("sid_l", MOS8580, 985248)
556   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
475557
558   /* quickload */
559   MCFG_QUICKLOAD_ADD("quickload", c65_state, cbm_c65, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS)
560
561   /* cia */
562   MCFG_DEVICE_ADD("cia_0", MOS6526, 3500000)
563   MCFG_MOS6526_TOD(60)
564   MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia0_interrupt))
565   MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_a_r))
566   MCFG_MOS6526_PB_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_b_r))
567   MCFG_MOS6526_PB_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia0_port_b_w))
568
569   MCFG_DEVICE_ADD("cia_1", MOS6526, 3500000)
570   MCFG_MOS6526_TOD(60)
571   MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia1_interrupt))
572   MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia1_port_a_r))
573   MCFG_MOS6526_PA_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia1_port_a_w))
574
575   /* floppy from serial bus */
576   MCFG_CBM_IEC_ADD(NULL)
577
578   /* internal ram */
579   MCFG_RAM_ADD(RAM_TAG)
580   MCFG_RAM_DEFAULT_SIZE("128K")
581   MCFG_RAM_EXTRA_OPTIONS("640K,4224K")
582MACHINE_CONFIG_END
583
584static MACHINE_CONFIG_DERIVED( c65pal, c65 )
585   MCFG_SCREEN_MODIFY("screen")
586   MCFG_SCREEN_REFRESH_RATE(VIC6569_VRETRACERATE)
587   MCFG_SCREEN_SIZE(625 * 2, 520 * 2)
588   MCFG_SCREEN_VISIBLE_AREA(VIC6569_STARTVISIBLECOLUMNS, (VIC6569_STARTVISIBLECOLUMNS + VIC6569_VISIBLECOLUMNS - 1) * 2, VIC6569_STARTVISIBLELINES, VIC6569_STARTVISIBLELINES + VIC6569_VISIBLELINES - 1)
589   MCFG_SCREEN_PALETTE("vic3:palette")
590
591   MCFG_DEVICE_MODIFY("vic3")
592   MCFG_VIC3_TYPE(VIC4567_PAL)
593
476594   /* sound hardware */
477   MCFG_SPEAKER_STANDARD_MONO("mono")
478//  MCFG_SOUND_ADD("aysnd", AY8910, MAIN_CLOCK/4)
479//  MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
595   MCFG_SOUND_REPLACE("sid_r", MOS8580, 1022727)
596   MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r))
597   MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r))
598   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
599   MCFG_SOUND_REPLACE("sid_l", MOS8580, 1022727)
600   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
601
602   /* cia */
603   MCFG_DEVICE_MODIFY("cia_0")
604   MCFG_MOS6526_TOD(50)
605
606   MCFG_DEVICE_MODIFY("cia_1")
607   MCFG_MOS6526_TOD(50)
480608MACHINE_CONFIG_END
481609
482610
483/***************************************************************************
611/*************************************
612 *
613 *  ROM definition(s)
614 *
615 *************************************/
484616
485  Game driver(s)
486617
487***************************************************************************/
488
489618ROM_START( c65 )
490   ROM_REGION( 0x20000, "maincpu", 0 )
619   ROM_REGION( 0x400000, "maincpu", 0 )
491620   ROM_SYSTEM_BIOS( 0, "910111", "V0.9.910111" )
492   ROMX_LOAD( "910111.bin", 0x0000, 0x20000, CRC(c5d8d32e) SHA1(71c05f098eff29d306b0170e2c1cdeadb1a5f206), ROM_BIOS(1) )
621   ROMX_LOAD( "910111.bin", 0x20000, 0x20000, CRC(c5d8d32e) SHA1(71c05f098eff29d306b0170e2c1cdeadb1a5f206), ROM_BIOS(1) )
493622   ROM_SYSTEM_BIOS( 1, "910523", "V0.9.910523" )
494   ROMX_LOAD( "910523.bin", 0x0000, 0x20000, CRC(e8235dd4) SHA1(e453a8e7e5b95de65a70952e9d48012191e1b3e7), ROM_BIOS(2) )
623   ROMX_LOAD( "910523.bin", 0x20000, 0x20000, CRC(e8235dd4) SHA1(e453a8e7e5b95de65a70952e9d48012191e1b3e7), ROM_BIOS(2) )
495624   ROM_SYSTEM_BIOS( 2, "910626", "V0.9.910626" )
496   ROMX_LOAD( "910626.bin", 0x0000, 0x20000, CRC(12527742) SHA1(07c185b3bc58410183422f7ac13a37ddd330881b), ROM_BIOS(3) )
625   ROMX_LOAD( "910626.bin", 0x20000, 0x20000, CRC(12527742) SHA1(07c185b3bc58410183422f7ac13a37ddd330881b), ROM_BIOS(3) )
497626   ROM_SYSTEM_BIOS( 3, "910828", "V0.9.910828" )
498   ROMX_LOAD( "910828.bin", 0x0000, 0x20000, CRC(3ee40b06) SHA1(b63d970727a2b8da72a0a8e234f3c30a20cbcb26), ROM_BIOS(4) )
627   ROMX_LOAD( "910828.bin", 0x20000, 0x20000, CRC(3ee40b06) SHA1(b63d970727a2b8da72a0a8e234f3c30a20cbcb26), ROM_BIOS(4) )
499628   ROM_SYSTEM_BIOS( 4, "911001", "V0.9.911001" )
500   ROMX_LOAD( "911001.bin", 0x0000, 0x20000, CRC(0888b50f) SHA1(129b9a2611edaebaa028ac3e3f444927c8b1fc5d), ROM_BIOS(5) )
629   ROMX_LOAD( "911001.bin", 0x20000, 0x20000, CRC(0888b50f) SHA1(129b9a2611edaebaa028ac3e3f444927c8b1fc5d), ROM_BIOS(5) )
501630ROM_END
502631
503632ROM_START( c64dx )
504   ROM_REGION( 0x20000, "maincpu", 0 )
505   ROM_LOAD( "910429.bin", 0x0000, 0x20000, CRC(b025805c) SHA1(c3b05665684f74adbe33052a2d10170a1063ee7d) )
633   ROM_REGION( 0x400000, "maincpu", 0 )
634   ROM_LOAD( "910429.bin", 0x20000, 0x20000, CRC(b025805c) SHA1(c3b05665684f74adbe33052a2d10170a1063ee7d) )
506635ROM_END
507636
508DRIVER_INIT_MEMBER(c65_state,c65)
509{
510//   m_dma.version = 2;
511//   c65_common_driver_init();
512}
637/***************************************************************************
513638
514DRIVER_INIT_MEMBER(c65_state,c65pal)
515{
516//   m_dma.version = 1;
517//   c65_common_driver_init();
518//   m_pal = 1;
519}
639  Game driver(s)
520640
521COMP( 1991, c65,    0,      0,      c65,    c65, c65_state, c65,    "Commodore Business Machines",  "Commodore 65 Development System (Prototype, NTSC)", GAME_NOT_WORKING )
522COMP( 1991, c64dx,  c65,    0,      c65,    c65, c65_state, c65pal, "Commodore Business Machines",  "Commodore 64DX Development System (Prototype, PAL, German)", GAME_NOT_WORKING )
641***************************************************************************/
642
643/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT    COMPANY                         FULLNAME                                              FLAGS */
644
645COMP( 1991, c65,    0,      0,      c65,    c65, c65_state,    c65,    "Commodore Business Machines",  "Commodore 65 Development System (Prototype, NTSC)", GAME_NOT_WORKING )
646COMP( 1991, c64dx,  c65,    0,      c65pal, c65ger, c65_state, c65pal, "Commodore Business Machines",  "Commodore 64DX Development System (Prototype, PAL, German)", GAME_NOT_WORKING )
trunk/src/mess/drivers/c65_old.c
r243230r243231
1/***************************************************************************
2
3    commodore c65 home computer
4    PeT mess@utanet.at
5
6    documention
7     www.funet.fi
8
9***************************************************************************/
10
11/*
12
132008 - Driver Updates
14---------------------
15
16(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
17
18
19[CBM systems which belong to this driver]
20
21* Commodore 65 (1989)
22
23Also known as C64 DX at early stages of the project. It was cancelled
24around 1990-1991. Only few units survive (they were sold after Commodore
25liquidation in 1994).
26
27CPU: CSG 4510 (3.54 MHz)
28RAM: 128 kilobytes, expandable to 8 megabytes
29ROM: 128 kilobytes
30Video: CSG 4569 "VIC-III" (6 Video modes; Resolutions from 320x200 to
31    1280x400; 80 columns text; Palette of 4096 colors)
32Sound: CSG 8580 "SID" x2 (6 voice stereo synthesizer/digital sound
33    capabilities)
34Ports: CSG 4510 (2 Joystick/Mouse ports; CBM Serial port; CBM 'USER'
35    port; CBM Monitor port; Power and reset switches; C65 bus drive
36    port; RGBI video port; 2 RCA audio ports; RAM expansion port; C65
37    expansion port)
38Keyboard: Full-sized 77 key QWERTY (12 programmable function keys;
39    4 direction cursor-pad)
40Additional Hardware: Built in 3.5" DD disk drive (1581 compatible)
41Miscellaneous: Partially implemented Commodore 64 emulation
42
43[Notes]
44
45The datasette port was removed here. C65 supports an additional "dumb"
46drive externally. It also features, in addition to the standard CBM
47bus serial (available in all modes), a Fast and a Burst serial bus
48(both available in C65 mode only)
49
50*/
51
52
53#include "emu.h"
54#include "cpu/m6502/m4510.h"
55#include "machine/mos6526.h"
56#include "machine/cbm_snqk.h"
57#include "includes/c65.h"
58#include "bus/cbmiec/cbmiec.h"
59#include "machine/ram.h"
60
61static void cbm_c65_quick_sethiaddress( address_space &space, UINT16 hiaddress )
62{
63   space.write_byte(0x82, hiaddress & 0xff);
64   space.write_byte(0x83, hiaddress >> 8);
65}
66
67QUICKLOAD_LOAD_MEMBER( c65_state, cbm_c65 )
68{
69   return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_c65_quick_sethiaddress);
70}
71
72/*************************************
73 *
74 *  Main CPU memory handlers
75 *
76 *************************************/
77
78static ADDRESS_MAP_START( c65_mem , AS_PROGRAM, 8, c65_state )
79   AM_RANGE(0x00000, 0x07fff) AM_RAMBANK("bank11")
80   AM_RANGE(0x08000, 0x09fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank12")
81   AM_RANGE(0x0a000, 0x0bfff) AM_READ_BANK("bank2") AM_WRITE_BANK("bank13")
82   AM_RANGE(0x0c000, 0x0cfff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank14")
83   AM_RANGE(0x0d000, 0x0d7ff) AM_READ_BANK("bank4") AM_WRITE_BANK("bank5")
84   AM_RANGE(0x0d800, 0x0dbff) AM_READ_BANK("bank6") AM_WRITE_BANK("bank7")
85   AM_RANGE(0x0dc00, 0x0dfff) AM_READ_BANK("bank8") AM_WRITE_BANK("bank9")
86   AM_RANGE(0x0e000, 0x0ffff) AM_READ_BANK("bank10") AM_WRITE_BANK("bank15")
87   AM_RANGE(0x10000, 0x1f7ff) AM_RAM
88   AM_RANGE(0x1f800, 0x1ffff) AM_RAM AM_SHARE("colorram")
89
90   AM_RANGE(0x20000, 0x23fff) AM_ROM /* &c65_dos,     maps to 0x8000    */
91   AM_RANGE(0x24000, 0x28fff) AM_ROM /* reserved */
92   AM_RANGE(0x29000, 0x29fff) AM_ROM AM_SHARE("c65_chargen")
93   AM_RANGE(0x2a000, 0x2bfff) AM_ROM AM_SHARE("basic")
94   AM_RANGE(0x2c000, 0x2cfff) AM_ROM AM_SHARE("interface")
95   AM_RANGE(0x2d000, 0x2dfff) AM_ROM AM_SHARE("chargen")
96   AM_RANGE(0x2e000, 0x2ffff) AM_ROM AM_SHARE("kernal")
97
98   AM_RANGE(0x30000, 0x31fff) AM_ROM /*&c65_monitor,     monitor maps to 0x6000    */
99   AM_RANGE(0x32000, 0x37fff) AM_ROM /*&c65_basic, */
100   AM_RANGE(0x38000, 0x3bfff) AM_ROM /*&c65_graphics, */
101   AM_RANGE(0x3c000, 0x3dfff) AM_ROM /* reserved */
102   AM_RANGE(0x3e000, 0x3ffff) AM_ROM /* &c65_kernal, */
103
104   AM_RANGE(0x40000, 0x7ffff) AM_NOP
105   /* 8 megabyte full address space! */
106ADDRESS_MAP_END
107
108
109/*************************************
110 *
111 *  Input Ports
112 *
113 *************************************/
114
115static INPUT_PORTS_START( c65 )
116   PORT_START( "ROW0" )
117   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Down Up") PORT_CODE(KEYCODE_RALT)        PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(UP))
118   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3)                                    PORT_CHAR(UCHAR_MAMEKEY(F5))
119   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2)                                    PORT_CHAR(UCHAR_MAMEKEY(F3))
120   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1)                                    PORT_CHAR(UCHAR_MAMEKEY(F1))
121   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4)                                    PORT_CHAR(UCHAR_MAMEKEY(F7))
122   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Crsr Right Left") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
123   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER)             PORT_CHAR(13)
124   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("INST DEL") PORT_CODE(KEYCODE_BACKSPACE)       PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
125
126   PORT_START( "ROW1" )
127   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Left)") PORT_CODE(KEYCODE_LSHIFT)      PORT_CHAR(UCHAR_SHIFT_1)
128   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E)         PORT_CHAR('E')
129   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S)         PORT_CHAR('S')
130   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z)         PORT_CHAR('Z')
131   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4)         PORT_CHAR('4') PORT_CHAR('$')
132   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A)         PORT_CHAR('A')
133   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W)         PORT_CHAR('W')
134   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3)         PORT_CHAR('3') PORT_CHAR('#')
135
136   PORT_START( "ROW2" )
137   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X)         PORT_CHAR('X')
138   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T)         PORT_CHAR('T')
139   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F)         PORT_CHAR('F')
140   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C)         PORT_CHAR('C')
141   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6)         PORT_CHAR('6') PORT_CHAR('&')
142   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D)         PORT_CHAR('D')
143   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R)         PORT_CHAR('R')
144   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5)         PORT_CHAR('5') PORT_CHAR('%')
145
146   PORT_START( "ROW3" )
147   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V)         PORT_CHAR('V')
148   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U)         PORT_CHAR('U')
149   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H)         PORT_CHAR('H')
150   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B)         PORT_CHAR('B')
151   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8)         PORT_CHAR('8') PORT_CHAR('(')
152   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G)         PORT_CHAR('G')
153   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y)         PORT_CHAR('Y')
154   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7)         PORT_CHAR('7') PORT_CHAR('\'')
155
156   PORT_START( "ROW4" )
157   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N)         PORT_CHAR('N')
158   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O)         PORT_CHAR('O')
159   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K)         PORT_CHAR('K')
160   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M)         PORT_CHAR('M')
161   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0)         PORT_CHAR('0')
162   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J)         PORT_CHAR('J')
163   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I)         PORT_CHAR('I')
164   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9)         PORT_CHAR('9') PORT_CHAR(')')
165
166   PORT_START( "ROW5" )
167   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA)     PORT_CHAR(',') PORT_CHAR('<')
168   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')
169   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON)     PORT_CHAR(':') PORT_CHAR('[')
170   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP)      PORT_CHAR('.') PORT_CHAR('>')
171   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS)    PORT_CHAR('-')
172   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L)         PORT_CHAR('L')
173   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P)         PORT_CHAR('P')
174   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS)     PORT_CHAR('+')
175
176   PORT_START( "ROW6" )
177   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH)                             PORT_CHAR('/') PORT_CHAR('?')
178   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91  Pi") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x2191) PORT_CHAR(0x03C0)
179   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH)                         PORT_CHAR('=')
180   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
181   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CLR HOME") PORT_CODE(KEYCODE_INSERT)      PORT_CHAR(UCHAR_MAMEKEY(HOME))
182   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE)                             PORT_CHAR(';') PORT_CHAR(']')
183   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)                        PORT_CHAR('*')
184   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)                        PORT_CHAR('\xA3')
185
186   PORT_START( "ROW7" )
187   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RUN STOP") PORT_CODE(KEYCODE_HOME)
188   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q)                                 PORT_CHAR('Q')
189   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CBM") PORT_CODE(KEYCODE_LALT)
190   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE)                             PORT_CHAR(' ')
191   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2)                                 PORT_CHAR('2') PORT_CHAR('"')
192   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB)                               PORT_CHAR(UCHAR_SHIFT_2)
193   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_TILDE)   PORT_CHAR(0x2190)
194   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1)                                 PORT_CHAR('1') PORT_CHAR('!')
195   PORT_START("FUNCT")
196   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_F1)
197   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13 F14") PORT_CODE(KEYCODE_F11)
198   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11 F12") PORT_CODE(KEYCODE_F10)
199   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9 F10") PORT_CODE(KEYCODE_F9)
200   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_F12)
201   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ALT") PORT_CODE(KEYCODE_F2)       /* non blocking */
202   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB)
203   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NO SCRL") PORT_CODE(KEYCODE_F4)
204
205   PORT_START( "SPECIAL" )  /* special keys */
206   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR)
207   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
208   PORT_CONFNAME( 0x20, 0x00, "(C65) Caps Lock (switch)") PORT_CODE(KEYCODE_F3)
209   PORT_CONFSETTING(   0x00, DEF_STR( Off ) )
210   PORT_CONFSETTING(   0x20, DEF_STR( On ) )
211   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
212
213   PORT_START("CTRLSEL")   /* Controller selection */
214   PORT_CONFNAME( 0x07, 0x00, "Gameport A" )
215   PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) )
216   PORT_CONFSETTING( 0x01, "Paddles 1 & 2" )
217   PORT_CONFSETTING( 0x02, "Mouse 1351" )
218   PORT_CONFSETTING( 0x03, "Mouse (Non Proportional) 1350" )
219   PORT_CONFSETTING( 0x04, "Lightpen" )
220//  PORT_CONFSETTING( 0x05, "Koala Pad" )
221   PORT_CONFSETTING( 0x06, "Lightgun" )
222   PORT_CONFSETTING( 0x07, "No Device Connected" )
223   PORT_CONFNAME( 0x70, 0x00, "Gameport B" )
224   PORT_CONFSETTING( 0x00, DEF_STR( Joystick ) )
225   PORT_CONFSETTING( 0x10, "Paddles 3 & 4" )
226//  PORT_CONFSETTING( 0x20, "Mouse 1351" )
227//  PORT_CONFSETTING( 0x30, "Mouse (Non Proportional) 1350" )
228   PORT_CONFSETTING( 0x70, "No Device Connected" )
229   PORT_CONFNAME( 0x80, 0x00, "Swap Gameport A and B") PORT_CODE(KEYCODE_F1) PORT_TOGGLE
230   PORT_CONFSETTING(   0x00, DEF_STR( No ) )
231   PORT_CONFSETTING(   0x80, DEF_STR( Yes ) )
232
233   PORT_START("JOY1_1B")
234   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
235   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
236   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
237   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
238   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x00)
239   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
240
241   PORT_START("JOY2_1B")
242   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
243   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
244   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
245   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
246   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x00)
247   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
248
249   /* Mouse Commodore 1350 was basically working as a Joystick */
250   PORT_START("JOY1_2B")
251   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Up") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
252   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Down") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
253   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Left") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
254   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Right") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
255   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 1") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
256   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 2") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03)
257   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
258
259   /* Still to verify how many mices you were able to plug into a c64 */
260   /* Only one, for now */
261   PORT_START("JOY2_2B")
262   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
263/*  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH)
264    PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
265    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
266    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
267    PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
268    PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_PGUP) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30)
269    PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
270*/
271   PORT_START("PADDLE1")
272   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
273
274   PORT_START("PADDLE2")
275   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_DOWN) PORT_CODE_INC(KEYCODE_UP) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
276
277   PORT_START("PADDLE3")
278   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_HOME) PORT_CODE_INC(KEYCODE_PGUP) PORT_PLAYER(3) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
279
280   PORT_START("PADDLE4")
281   PORT_BIT( 0xff, 128, IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CENTERDELTA(0) PORT_CODE_DEC(KEYCODE_END) PORT_CODE_INC(KEYCODE_PGDN) PORT_PLAYER(4) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
282
283   PORT_START("TRACKX")
284   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
285
286   PORT_START("TRACKY")
287   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
288
289   PORT_START("LIGHTX")
290   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04)
291
292   PORT_START("LIGHTY")
293   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04)
294
295   PORT_START("OTHER")
296   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Paddle 1 Button") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
297   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Paddle 2 Button") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01)
298   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Paddle 3 Button") PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
299   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4) PORT_NAME("Paddle 4 Button") PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10)
300   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Lightpen Signal") PORT_CODE(KEYCODE_LCONTROL) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x04)
301   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button Left") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)
302   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Button Right") PORT_CODE(KEYCODE_LALT) PORT_CODE(JOYCODE_BUTTON2) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02)INPUT_PORTS_END
303
304
305static INPUT_PORTS_START( c65ger )
306   PORT_INCLUDE( c65 )
307
308   PORT_MODIFY( "ROW1" )
309   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z  { Y }") PORT_CODE(KEYCODE_Z)                   PORT_CHAR('Z')
310   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3  #  { 3  Paragraph }") PORT_CODE(KEYCODE_3)     PORT_CHAR('3') PORT_CHAR('#')
311
312   PORT_MODIFY( "ROW3" )
313   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Y  { Z }") PORT_CODE(KEYCODE_Y)                   PORT_CHAR('Y')
314   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("7 ' { 7  / }") PORT_CODE(KEYCODE_7)               PORT_CHAR('7') PORT_CHAR('\'')
315
316   PORT_MODIFY( "ROW4" )
317   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0  { = }") PORT_CODE(KEYCODE_0)                   PORT_CHAR('0')
318
319   PORT_MODIFY( "ROW5" )
320   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(",  <  { ; }") PORT_CODE(KEYCODE_COMMA)            PORT_CHAR(',') PORT_CHAR('<')
321   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Paragraph  \xE2\x86\x91  { \xc3\xbc }") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR(0x00A7) PORT_CHAR(0x2191)
322   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(":  [  { \xc3\xa4 }") PORT_CODE(KEYCODE_COLON)     PORT_CHAR(':') PORT_CHAR('[')
323   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(".  >  { : }") PORT_CODE(KEYCODE_STOP)             PORT_CHAR('.') PORT_CHAR('>')
324   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("-  { '  ` }") PORT_CODE(KEYCODE_EQUALS)           PORT_CHAR('-')
325   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("+  { \xc3\x9f ? }") PORT_CODE(KEYCODE_MINUS)      PORT_CHAR('+')
326
327   PORT_MODIFY( "ROW6" )
328   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/  ?  { -  _ }") PORT_CODE(KEYCODE_SLASH)         PORT_CHAR('/') PORT_CHAR('?')
329   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Sum Pi  { ]  \\ }") PORT_CODE(KEYCODE_DEL)        PORT_CHAR(0x03A3) PORT_CHAR(0x03C0)
330   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("=  { #  ' }") PORT_CODE(KEYCODE_BACKSLASH)        PORT_CHAR('=')
331   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(";  ]  { \xc3\xb6 }") PORT_CODE(KEYCODE_QUOTE)     PORT_CHAR(';') PORT_CHAR(']')
332   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("*  `  { +  * }") PORT_CODE(KEYCODE_CLOSEBRACE)    PORT_CHAR('*') PORT_CHAR('`')
333   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\\  { [ \xE2\x86\x91 }") PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xa3')
334
335   PORT_MODIFY( "ROW7" )
336   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("_  { <  > }") PORT_CODE(KEYCODE_TILDE)            PORT_CHAR('_')
337
338   PORT_MODIFY("SPECIAL") /* special keys */
339   PORT_DIPNAME( 0x20, 0x00, "(C65) DIN ASC (switch)") PORT_CODE(KEYCODE_F3)
340   PORT_DIPSETTING(    0x00, "ASC" )
341   PORT_DIPSETTING(    0x20, "DIN" )
342INPUT_PORTS_END
343
344
345
346/*************************************
347 *
348 *  Sound definitions
349 *
350 *************************************/
351
352int c65_state::c64_paddle_read( device_t *device, address_space &space, int which )
353{
354   int pot1 = 0xff, pot2 = 0xff, pot3 = 0xff, pot4 = 0xff, temp;
355   UINT8 cia0porta = machine().device<mos6526_device>("cia_0")->pa_r(space, 0);
356   int controller1 = ioport("CTRLSEL")->read() & 0x07;
357   int controller2 = ioport("CTRLSEL")->read() & 0x70;
358   /* Notice that only a single input is defined for Mouse & Lightpen in both ports */
359   switch (controller1)
360   {
361      case 0x01:
362         if (which)
363            pot2 = ioport("PADDLE2")->read();
364         else
365            pot1 = ioport("PADDLE1")->read();
366         break;
367
368      case 0x02:
369         if (which)
370            pot2 = ioport("TRACKY")->read();
371         else
372            pot1 = ioport("TRACKX")->read();
373         break;
374
375      case 0x03:
376         if (which && (ioport("JOY1_2B")->read() & 0x20))  /* Joy1 Button 2 */
377            pot1 = 0x00;
378         break;
379
380      case 0x04:
381         if (which)
382            pot2 = ioport("LIGHTY")->read();
383         else
384            pot1 = ioport("LIGHTX")->read();
385         break;
386
387      case 0x06:
388         if (which && (ioport("OTHER")->read() & 0x04))    /* Lightpen Signal */
389            pot2 = 0x00;
390         break;
391
392      case 0x00:
393      case 0x07:
394         break;
395
396      default:
397         logerror("Invalid Controller Setting %d\n", controller1);
398         break;
399   }
400
401   switch (controller2)
402   {
403      case 0x10:
404         if (which)
405            pot4 = ioport("PADDLE4")->read();
406         else
407            pot3 = ioport("PADDLE3")->read();
408         break;
409
410      case 0x20:
411         if (which)
412            pot4 = ioport("TRACKY")->read();
413         else
414            pot3 = ioport("TRACKX")->read();
415         break;
416
417      case 0x30:
418         if (which && (ioport("JOY2_2B")->read() & 0x20))  /* Joy2 Button 2 */
419            pot4 = 0x00;
420         break;
421
422      case 0x40:
423         if (which)
424            pot4 = ioport("LIGHTY")->read();
425         else
426            pot3 = ioport("LIGHTX")->read();
427         break;
428
429      case 0x60:
430         if (which && (ioport("OTHER")->read() & 0x04))    /* Lightpen Signal */
431            pot4 = 0x00;
432         break;
433
434      case 0x00:
435      case 0x70:
436         break;
437
438      default:
439         logerror("Invalid Controller Setting %d\n", controller1);
440         break;
441   }
442
443   if (ioport("CTRLSEL")->read() & 0x80)     /* Swap */
444   {
445      temp = pot1; pot1 = pot3; pot3 = temp;
446      temp = pot2; pot2 = pot4; pot4 = temp;
447   }
448
449   switch (cia0porta & 0xc0)
450   {
451      case 0x40:
452         return which ? pot2 : pot1;
453
454      case 0x80:
455         return which ? pot4 : pot3;
456
457      case 0xc0:
458         return which ? pot2 : pot1;
459
460      default:
461         return 0;
462   }
463}
464
465READ8_MEMBER( c65_state::sid_potx_r )
466{
467   return c64_paddle_read(m_sid_r, space, 0);
468}
469
470READ8_MEMBER( c65_state::sid_poty_r )
471{
472   return c64_paddle_read(m_sid_r, space, 1);
473}
474
475
476/*************************************
477 *
478 *  VIC III interfaces
479 *
480 *************************************/
481
482UINT32 c65_state::screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
483{
484   m_vic->video_update(bitmap, cliprect);
485   return 0;
486}
487
488READ8_MEMBER(c65_state::c65_lightpen_x_cb)
489{
490   return ioport("LIGHTX")->read() & ~0x01;
491}
492
493READ8_MEMBER(c65_state::c65_lightpen_y_cb)
494{
495   return ioport("LIGHTY")->read() & ~0x01;
496}
497
498READ8_MEMBER(c65_state::c65_lightpen_button_cb)
499{
500   return ioport("OTHER")->read() & 0x04;
501}
502
503READ8_MEMBER(c65_state::c65_c64_mem_r)
504{
505   return m_memory[offset];
506}
507
508INTERRUPT_GEN_MEMBER(c65_state::vic3_raster_irq)
509{
510   m_vic->raster_interrupt_gen();
511}
512
513/*************************************
514 *
515 *  Machine driver
516 *
517 *************************************/
518
519static MACHINE_CONFIG_START( c65, c65_state )
520   /* basic machine hardware */
521   MCFG_CPU_ADD("maincpu", M4510, 3500000)  /* or VIC6567_CLOCK, */
522   MCFG_CPU_PROGRAM_MAP(c65_mem)
523   MCFG_CPU_VBLANK_INT_DRIVER("screen", c65_state,  c65_frame_interrupt)
524   MCFG_CPU_PERIODIC_INT_DRIVER(c65_state, vic3_raster_irq,  VIC6567_HRETRACERATE)
525
526   MCFG_MACHINE_START_OVERRIDE(c65_state, c65 )
527
528   /* video hardware */
529   MCFG_SCREEN_ADD("screen", RASTER)
530   MCFG_SCREEN_REFRESH_RATE(VIC6567_VRETRACERATE)
531   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
532   MCFG_SCREEN_SIZE(525 * 2, 520 * 2)
533   MCFG_SCREEN_VISIBLE_AREA(VIC6567_STARTVISIBLECOLUMNS ,(VIC6567_STARTVISIBLECOLUMNS + VIC6567_VISIBLECOLUMNS - 1) * 2, VIC6567_STARTVISIBLELINES, VIC6567_STARTVISIBLELINES + VIC6567_VISIBLELINES - 1)
534   MCFG_SCREEN_UPDATE_DRIVER(c65_state, screen_update_c65)
535   MCFG_SCREEN_PALETTE("vic3:palette")
536
537   MCFG_DEVICE_ADD("vic3", VIC3, 0)
538   MCFG_VIC3_CPU("maincpu")
539   MCFG_VIC3_TYPE(VIC4567_NTSC)
540   MCFG_VIC3_LIGHTPEN_X_CB(READ8(c65_state, c65_lightpen_x_cb))
541   MCFG_VIC3_LIGHTPEN_Y_CB(READ8(c65_state, c65_lightpen_y_cb))
542   MCFG_VIC3_LIGHTPEN_BUTTON_CB(READ8(c65_state, c65_lightpen_button_cb))
543   MCFG_VIC3_DMA_READ_CB(READ8(c65_state, c65_dma_read))
544   MCFG_VIC3_DMA_READ_COLOR_CB(READ8(c65_state, c65_dma_read_color))
545   MCFG_VIC3_INTERRUPT_CB(WRITELINE(c65_state, c65_vic_interrupt))
546   MCFG_VIC3_PORT_CHANGED_CB(WRITE8(c65_state, c65_bankswitch_interface))
547   MCFG_VIC3_C64_MEM_R_CB(READ8(c65_state, c65_c64_mem_r))
548
549   /* sound hardware */
550   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
551   MCFG_SOUND_ADD("sid_r", MOS8580, 985248)
552   MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r))
553   MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r))
554   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
555   MCFG_SOUND_ADD("sid_l", MOS8580, 985248)
556   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
557
558   /* quickload */
559   MCFG_QUICKLOAD_ADD("quickload", c65_state, cbm_c65, "p00,prg", CBM_QUICKLOAD_DELAY_SECONDS)
560
561   /* cia */
562   MCFG_DEVICE_ADD("cia_0", MOS6526, 3500000)
563   MCFG_MOS6526_TOD(60)
564   MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia0_interrupt))
565   MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_a_r))
566   MCFG_MOS6526_PB_INPUT_CALLBACK(READ8(c65_state, c65_cia0_port_b_r))
567   MCFG_MOS6526_PB_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia0_port_b_w))
568
569   MCFG_DEVICE_ADD("cia_1", MOS6526, 3500000)
570   MCFG_MOS6526_TOD(60)
571   MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(c65_state, c65_cia1_interrupt))
572   MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(c65_state, c65_cia1_port_a_r))
573   MCFG_MOS6526_PA_OUTPUT_CALLBACK(WRITE8(c65_state, c65_cia1_port_a_w))
574
575   /* floppy from serial bus */
576   MCFG_CBM_IEC_ADD(NULL)
577
578   /* internal ram */
579   MCFG_RAM_ADD(RAM_TAG)
580   MCFG_RAM_DEFAULT_SIZE("128K")
581   MCFG_RAM_EXTRA_OPTIONS("640K,4224K")
582MACHINE_CONFIG_END
583
584static MACHINE_CONFIG_DERIVED( c65pal, c65 )
585   MCFG_SCREEN_MODIFY("screen")
586   MCFG_SCREEN_REFRESH_RATE(VIC6569_VRETRACERATE)
587   MCFG_SCREEN_SIZE(625 * 2, 520 * 2)
588   MCFG_SCREEN_VISIBLE_AREA(VIC6569_STARTVISIBLECOLUMNS, (VIC6569_STARTVISIBLECOLUMNS + VIC6569_VISIBLECOLUMNS - 1) * 2, VIC6569_STARTVISIBLELINES, VIC6569_STARTVISIBLELINES + VIC6569_VISIBLELINES - 1)
589   MCFG_SCREEN_PALETTE("vic3:palette")
590
591   MCFG_DEVICE_MODIFY("vic3")
592   MCFG_VIC3_TYPE(VIC4567_PAL)
593
594   /* sound hardware */
595   MCFG_SOUND_REPLACE("sid_r", MOS8580, 1022727)
596   MCFG_MOS6581_POTX_CALLBACK(READ8(c65_state, sid_potx_r))
597   MCFG_MOS6581_POTY_CALLBACK(READ8(c65_state, sid_poty_r))
598   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
599   MCFG_SOUND_REPLACE("sid_l", MOS8580, 1022727)
600   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
601
602   /* cia */
603   MCFG_DEVICE_MODIFY("cia_0")
604   MCFG_MOS6526_TOD(50)
605
606   MCFG_DEVICE_MODIFY("cia_1")
607   MCFG_MOS6526_TOD(50)
608MACHINE_CONFIG_END
609
610
611/*************************************
612 *
613 *  ROM definition(s)
614 *
615 *************************************/
616
617
618ROM_START( c65 )
619   ROM_REGION( 0x400000, "maincpu", 0 )
620   ROM_SYSTEM_BIOS( 0, "910111", "V0.9.910111" )
621   ROMX_LOAD( "910111.bin", 0x20000, 0x20000, CRC(c5d8d32e) SHA1(71c05f098eff29d306b0170e2c1cdeadb1a5f206), ROM_BIOS(1) )
622   ROM_SYSTEM_BIOS( 1, "910523", "V0.9.910523" )
623   ROMX_LOAD( "910523.bin", 0x20000, 0x20000, CRC(e8235dd4) SHA1(e453a8e7e5b95de65a70952e9d48012191e1b3e7), ROM_BIOS(2) )
624   ROM_SYSTEM_BIOS( 2, "910626", "V0.9.910626" )
625   ROMX_LOAD( "910626.bin", 0x20000, 0x20000, CRC(12527742) SHA1(07c185b3bc58410183422f7ac13a37ddd330881b), ROM_BIOS(3) )
626   ROM_SYSTEM_BIOS( 3, "910828", "V0.9.910828" )
627   ROMX_LOAD( "910828.bin", 0x20000, 0x20000, CRC(3ee40b06) SHA1(b63d970727a2b8da72a0a8e234f3c30a20cbcb26), ROM_BIOS(4) )
628   ROM_SYSTEM_BIOS( 4, "911001", "V0.9.911001" )
629   ROMX_LOAD( "911001.bin", 0x20000, 0x20000, CRC(0888b50f) SHA1(129b9a2611edaebaa028ac3e3f444927c8b1fc5d), ROM_BIOS(5) )
630ROM_END
631
632ROM_START( c64dx )
633   ROM_REGION( 0x400000, "maincpu", 0 )
634   ROM_LOAD( "910429.bin", 0x20000, 0x20000, CRC(b025805c) SHA1(c3b05665684f74adbe33052a2d10170a1063ee7d) )
635ROM_END
636
637/***************************************************************************
638
639  Game driver(s)
640
641***************************************************************************/
642
643/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT    COMPANY                         FULLNAME                                              FLAGS */
644
645COMP( 1991, c65,    0,      0,      c65,    c65, c65_state,    c65,    "Commodore Business Machines",  "Commodore 65 Development System (Prototype, NTSC)", GAME_NOT_WORKING )
646COMP( 1991, c64dx,  c65,    0,      c65pal, c65ger, c65_state, c65pal, "Commodore Business Machines",  "Commodore 64DX Development System (Prototype, PAL, German)", GAME_NOT_WORKING )
647
648
trunk/src/mess/drivers/cat.c
r243230r243231
223223    Pins:
224224    1: GND through 220k resistor r78
225225    2: ? phone hook related? anode of diode d7; one of the pins of relay k2; topmost (boardwise) pin of transistor Q10
226    3: 74HCT34 pin
226    3: 74HCT34 pin
227227
228228J5: locking-tab-type "CONN HEADER VERT 4POS .100 TIN" connector for supplying power
229229    through a small cable with a berg connector at the other end, to the floppy drive
r243230r243231
240240    /HICE is !a15
241241    /ROM_OE comes from pin 14 of DECODE_E pal, and is shorted to /ROM_OE' by the cuttable jumper B1 which is not cut
242242    /ROM_OE' goes to the two EPROMS
243    DECODE_18 is DECODE_E pal pin 18
243   DECODE_18 is DECODE_E pal pin 18
244244    pin 1 (GND) is in the lower left and the pins count low-high then to the right
245245    (gnd N/C   E_CLK     R/W    /ROM_OE a17 vcc a14 a13 a8 a9 a11 /ROM_OE' a10 a15 d7 d6 d5 d4 d3 )
246246    (GND /IPL1 DECODE_18 /RESET gnd     a16 vcc a12 a7  a6 a5 a4  a3       a2  a1  a0 d0 d1 d2 gnd)
r243230r243231
369369// pin 13 (PB3) :
370370// pin 14 (PB4) :
371371// pin 15 (PB5) :
372// pin 16 (PB6) :
372// pin 16 (PB6) :
373373// pin 17 (PB7) :
374// pin 18 (CB1) : ?from/to? Floppy connector j3 pin 8
375// pin 19 (CB2) : ?from/to? 6522 @ u35 pin 16 (PB6)
374// pin 18 (CB1) : ?from/to? Floppy connector j3 pin 8
375// pin 19 (CB2) : ?from/to? 6522 @ u35 pin 16 (PB6)
376376// pin 21 (/IRQ) : out to 68008 /IPL1 pin 41
377377// pin 22 (R/W) : in from 68008 R/W pin 30
378378// pin 23 (/CS2) : in from DECODE E pin 18
r243230r243231
384384// pin 39 (CA2) is through inductor L11 and resistor r128 to peripheral connector pin 35 <end minus 26>
385385// pin 40 (CA1) is through inductor L30 and resistor r138 to peripheral connector pin 53 <end minus 8>
386386
387// 6522 @ u35
387// 6522 @ u35
388388// pin 2 (PA0) :
389389// pin 3 (PA1) :
390390// pin 4 (PA2) :
r243230r243231
421421// pin 4 (Y2) : out to 6522 @u35 pin 11
422422// pin 5 (A2) : in from 4N37 @ u48 pin 5 (output side emitter pin) (tied via R189 to gnd) <ring indicator?>
423423// pin 6 (B2) : in from 4N37 @ u48 pin 5 (output side emitter pin) (tied via R189 to gnd) <ring indicator?>
424// pin 8 (B3) :
425// pin 9 (A3) :
426// pin 10 (Y3) :
424// pin 8 (B3) :
425// pin 9 (A3) :
426// pin 10 (Y3) :
427427// pin 11 (B4) : in from 68008 A15
428428// pin 12 (A4) : in from 68008 A15
429429// pin 13 (Y4) : out to EPROM @ U31 /CE
r243230r243231
17431743    * ||||\-------------Q? ?
17441744    * |||\--------------Q? ?
17451745    * ||\---------------Q> output to decode pal pin 2
1746    * |\----------------->? output? to ram multiplexer 'A' pins
1746    * |\----------------->? output? to ram multiplexer 'A' pins
17471747    * \------------------< ?
17481748    */
17491749   ROM_LOAD( "timing_b.ampal16r4a.u9.jed", 0x0000, 0xb08, CRC(643e6e83) SHA1(7db167883f9d6cf385ce496d08976dc16fc3e2c3))
trunk/src/mess/drivers/gamate.c
r243230r243231
2020      : driver_device(mconfig, type, tag)
2121      , m_maincpu(*this, "maincpu")
2222      , m_cart(*this, "cartslot")
23#ifdef USE_GFX
23#ifdef USE_GFX     
2424      , m_gfxdecode(*this, "gfxdecode")
2525#endif
2626      , m_io_joy(*this, "JOY")
r243230r243231
5353
5454   struct
5555   {
56   UINT8 reg[8];
57   struct {
58      bool write;
59      bool page2; // else page1
56     UINT8 reg[8];
57     struct {
58       bool write;
59       bool page2; // else page1
6060   UINT8 ypos, xpos/*tennis*/;
61      UINT8 data[2][0x100][0x20];
62      } bitmap;
63   UINT8 x, y;
61       UINT8 data[2][0x100][0x20];
62     } bitmap;
63     UINT8 x, y;
6464      bool y_increment;
6565   } video;
6666
6767   struct {
68      bool set;
68     bool set;
6969      int bit_shifter;
7070      UINT8 cartridge_byte;
7171      UINT16 address; // in reality something more like short local cartridge address offset
7272      bool unprotected;
7373      bool failed;
74
74     
7575   } card_protection;
7676
7777   required_device<cpu_device> m_maincpu;
r243230r243231
8484   required_shared_ptr<UINT8> m_bios;
8585   emu_timer *timer1;
8686   emu_timer *timer2;
87   UINT8 bank_multi;
87   UINT8 bank_multi; 
8888   UINT8 *m_cart_ptr;
8989};
9090
9191WRITE8_MEMBER( gamate_state::gamate_cart_protection_w )
9292{
93      logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
94
93        logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
94 
9595   switch (offset) {
9696   case 0:
9797      card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0);
r243230r243231
105105}
106106READ8_MEMBER( gamate_state::gamate_cart_protection_r )
107107{
108   UINT8 ret=1;
109   if (card_protection.bit_shifter==7 && card_protection.unprotected) {
110   ret=m_cart_ptr[bank_multi*0x4000];
111   } else {
108
109  UINT8 ret=1;
110  if (card_protection.bit_shifter==7 && card_protection.unprotected) {
111    ret=m_cart_ptr[bank_multi*0x4000];
112  } else {
112113   card_protection.bit_shifter++;
113114   if (card_protection.bit_shifter==8) {
114115      card_protection.bit_shifter=0;
r243230r243231
117118   }
118119   ret=(card_protection.cartridge_byte&0x80)?2:0;
119120   if (card_protection.bit_shifter==7 && !card_protection.failed) { // now protection chip on cartridge activates cartridge chip select on cpu accesses
120//        m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
121//        m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
121122   }
122123   card_protection.cartridge_byte<<=1;
123   }
124   logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
125   return ret;
124  }
125  logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
126  return ret;
126127}
127128
128129READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked
129130
130131WRITE8_MEMBER( gamate_state::protection_reset )
131132{
132   // writes 0x20
133   card_protection.address=0x6005-0x6001;
134   card_protection.bit_shifter=0;
135   card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];//m_cart_rom[card_protection.address++];
136   card_protection.failed=false;
137   card_protection.unprotected=false;
133  // writes 0x20
134  card_protection.address=0x6005-0x6001;
135  card_protection.bit_shifter=0;
136  card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];//m_cart_rom[card_protection.address++];
137  card_protection.failed=false;
138  card_protection.unprotected=false;
138139}
139140
140141READ8_MEMBER( gamate_state::newer_protection_set )
141142{
142   card_protection.set=true;
143   return 0;
143  card_protection.set=true;
144  return 0;
144145}
145146
146147
147148WRITE8_MEMBER( gamate_state::gamate_video_w )
148149{
149   video.reg[offset]=data;
150   switch (offset) {
151   case 1: video.bitmap.write=data&0xc0; // more addressing mode
150  video.reg[offset]=data;
151  switch (offset) {
152  case 1: video.bitmap.write=data&0xc0; // more addressing mode
152153      video.y_increment=data&0x40;
153154      break;
154155   case 2: video.bitmap.xpos=data;break; // at least 7 bits
155156   case 3: video.bitmap.ypos=data;break; // at least 7 bits
156   case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break;
157   case 5: video.y=data;break;
158   case 7:
159   if (video.bitmap.write) {
160      if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/)
161      video.bitmap.data[video.bitmap.page2][video.y][video.x]=data;
162      else
163      logerror("%.6f %04x video bitmap x %x invalid\n",machine().time().as_double(), m_maincpu->pc(), video.x);
164   } else {
165      video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
166   }
167   if (video.y_increment) video.y++;
157  case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break;
158  case 5: video.y=data;break;
159  case 7:
160    if (video.bitmap.write) {
161      if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/)
162        video.bitmap.data[video.bitmap.page2][video.y][video.x]=data;
163      else
164        logerror("%.6f %04x video bitmap x %x invalid\n",machine().time().as_double(), m_maincpu->pc(), video.x);
165    } else {
166        video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
167    }
168    if (video.y_increment) video.y++;
168169      else video.x++;
169   }
170  }
170171}
171172
172173WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w )
173174{
174   bank_multi=data;
175   membank("bankmulti")->set_base(m_cart_ptr+0x4000*data+1);
175  bank_multi=data;
176  membank("bankmulti")->set_base(m_cart_ptr+0x4000*data+1);
176177}
177178
178179WRITE8_MEMBER( gamate_state::cart_bankswitch_w )
r243230r243231
183184READ8_MEMBER( gamate_state::gamate_video_r )
184185{
185186   if (offset!=6) return 0;
186   UINT8 data=0;
187   if (video.bitmap.write) {
188      if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/)
189      data=video.bitmap.data[video.bitmap.page2][video.y][video.x];
190      else
191      logerror("%.6f video bitmap x %x invalid\n",machine().time().as_double(),video.x);
192   } else {
193   data=video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
194   }
195   if (m_maincpu->pc()<0xf000)
196   logerror("%.6f video read %04x %02x\n",machine().time().as_double(),offset, data);
197   return data;
187  UINT8 data=0;
188  if (video.bitmap.write) {
189      if (video.x<ARRAY_LENGTH(video.bitmap.data[0][0]) /*&& video.y<ARRAY_LENGTH(video.bitmap.data[0])*/)
190        data=video.bitmap.data[video.bitmap.page2][video.y][video.x];
191      else
192        logerror("%.6f video bitmap x %x invalid\n",machine().time().as_double(),video.x);
193  } else {
194    data=video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
195  }
196  if (m_maincpu->pc()<0xf000)
197    logerror("%.6f video read %04x %02x\n",machine().time().as_double(),offset, data);
198  return data;
198199}
199200
200201WRITE8_MEMBER( gamate_state::gamate_audio_w )
201202{
202   logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data);
203  logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data);
203204}
204205
205206READ8_MEMBER( gamate_state::gamate_audio_r )
206207{
207   logerror("%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset);
208  logerror("%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset);
208209   return 0;
209210}
210211
211212
212213READ8_MEMBER( gamate_state::gamate_pad_r )
213214{
214   UINT8 data=m_io_joy->read();
215   return data;
215  UINT8 data=m_io_joy->read();
216  return data;
216217}
217218
218219static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state )
219   AM_RANGE(0x0000, 0x03ff) AM_RAM
220   AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
221   AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
222   AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
223   AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
224   AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
225   AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
220    AM_RANGE(0x0000, 0x03ff) AM_RAM
221  AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
222  AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
223  AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
224  AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
225  AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
226  AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
226227
227   AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
228   AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
228  AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
229  AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
229230
230231   AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w)
231232   AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w)
232233   AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w)
233234
234   AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
235  AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
235236ADDRESS_MAP_END
236237
237238
r243230r243231
250251#ifdef USE_GFX
251252static const struct gfx_layout gamate_charlayout =
252253{
253      4,      /* width of object */
254      1,      /* height of object */
255      256,/* 256 characters */
256      2,      /* bits per pixel */
257      { 0,4 }, /* no bitplanes */
258      /* x offsets */
259      { 0,1,2,3 },
260      /* y offsets */
261      { 0 },
262      8*1 /* size of 1 object in bits */
254        4,      /* width of object */
255        1,      /* height of object */
256        256,/* 256 characters */
257        2,      /* bits per pixel */
258        { 0,4 }, /* no bitplanes */
259        /* x offsets */
260        { 0,1,2,3 },
261        /* y offsets */
262        { 0 },
263        8*1 /* size of 1 object in bits */
263264};
264265
265266static GFXDECODE_START( gamate )
266      GFXDECODE_ENTRY( "gfx1", 0x0000, gamate_charlayout, 0, 0x100 )
267        GFXDECODE_ENTRY( "gfx1", 0x0000, gamate_charlayout, 0, 0x100 )
267268GFXDECODE_END
268269#endif
269270
270271/* palette in red, green, blue tribles */
271272static const unsigned char gamate_colors[4][3] =
272273{
273   { 255,255,255 },
274   { 0xa0, 0xa0, 0xa0 },
275   { 0x60, 0x60, 0x60 },
276   { 0, 0, 0 }
274  { 255,255,255 },
275  { 0xa0, 0xa0, 0xa0 },
276  { 0x60, 0x60, 0x60 },
277  { 0, 0, 0 }
277278};
278279
279280PALETTE_INIT_MEMBER(gamate_state, gamate)
r243230r243231
298299
299300UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
300301{
301   int x, y, j;
302   for (y=0;y<152;y++) {
303   for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {
304      UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f];
305      UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f];
302  int x, y, j;
303  for (y=0;y<152;y++) {
304    for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {
305      UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f];
306      UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f];
306307#ifdef USE_GFX
307      m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1&0xf)|((d2&0xf)<<4), 0,0,0,x+4,y);
308      m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1&0xf)|((d2&0xf)<<4), 0,0,0,x+4,y);
308309   m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, (d1>>4)|(d2&0xf0),0,0,0,x,y);
309310#else
310      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
311      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
312#endif
313   }
314   }
315   return 0;
311      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
312      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
313#endif     
314    }
315  }
316  return 0;
316317}
317318
318319DRIVER_INIT_MEMBER(gamate_state,gamate)
r243230r243231
321322#ifdef USE_GFX
322323   UINT8 *gfx=memregion("gfx1")->base();
323324   for (int i=0; i<256; i++) gfx[i]=i;
324#endif
325#endif   
325326   timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamate_state::gamate_timer),this));
326327   timer2 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamate_state::gamate_timer2),this));
327328}
r243230r243231
331332{
332333   m_cart_ptr = memregion("maincpu")->base() + 0x6000;
333334   if (m_cart->exists()) {
334//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
335//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
335336      m_cart_ptr = m_cart->get_rom_base();
336337      membank("bankmulti")->set_base(m_cart->get_rom_base()+1);
337338      membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset
338339   }
339//  m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
340//   m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
340341   card_protection.set=false;
341342   bank_multi=0;
342343   card_protection.unprotected=false;
r243230r243231
389390
390391#ifdef USE_GFX
391392   MCFG_GFXDECODE_ADD("gfxdecode", "palette", gamate )
392#endif
393#endif   
393394   MCFG_PALETTE_ADD("palette", ARRAY_LENGTH(gamate_colors))
394395   MCFG_PALETTE_INIT_OWNER(gamate_state, gamate)
395396   MCFG_DEFAULT_LAYOUT(layout_lcd)
r243230r243231
407408   ROMX_LOAD("gamate_bios_umc.bin", 0xf000, 0x1000, CRC(07090415) SHA1(ea449dc607601f9a68d855ad6ab53800d2e99297), ROM_BIOS(1) )
408409   ROM_SYSTEM_BIOS(1, "newer", "NEWER")
409410   ROMX_LOAD("gamate_bios_9130__unknown__bit_icasc00001_9130-bs_r32261.bin", 0xf000, 0x1000, CRC(03a5f3a7) SHA1(4e9dfbfe916ca485530ef4221593ab68738e2217), ROM_BIOS(2) )
410#ifdef USE_GFX
411#ifdef USE_GFX   
411412   ROM_REGION(0x100,"gfx1", ROMREGION_ERASEFF)
412#endif
413#endif   
413414ROM_END
414415
415416
416417/*    YEAR  NAME      PARENT  COMPAT    MACHINE   INPUT    CLASS          INIT      COMPANY    FULLNAME */
417418CONS( 19??, gamate,  0,      0,        gamate,  gamate, gamate_state, gamate, "Bit Corp", "Gamate", GAME_NO_SOUND)
419
420
trunk/src/mess/drivers/hp16500.c
r243230r243231
1919    MC68000 @ 10 MHz
2020    MC68A45 CRTC
2121    Z0765A08PSC floppy controller (NEC765 type)
22    TMS9914A GPIB bus interface
22   TMS9914A GPIB bus interface
2323    SCN2661 DUART/timer
2424
2525  16500b:
r243230r243231
5050#include "video/mc6845.h"
5151#include "machine/mc68681.h"
5252
53#define MAINCPU_TAG "maincpu"
54#define CRTC_TAG    "crtc"
55#define SCREEN_TAG  "screen"
56#define DUART_TAG   "duart"
53#define MAINCPU_TAG   "maincpu"
54#define CRTC_TAG   "crtc"
55#define SCREEN_TAG   "screen"
56#define DUART_TAG   "duart"
5757
5858class hp16500_state : public driver_device
5959{
trunk/src/mess/drivers/hp9k_3xx.c
r243230r243231
11// license:BSD-3-Clause
22// copyright-holders:R. Belmont
33/***************************************************************************
4
4
55  hp9k3xx.c: preliminary driver for HP9000 300 Series (aka HP9000/3xx)
66
77  Currently supporting:
r243230r243231
1616      MC68881 FPU
1717
1818  330:
19      MC68020 CPU @ 16.67 MHz
20      MC68851 MMU
21      MC68881 FPU
19     MC68020 CPU @ 16.67 MHz
20     MC68851 MMU
21     MC68881 FPU
2222
2323  340:
2424      MC68030 CPU @ 16.67 MHz w/built-in MMU
25      MC68881 FPU
25     MC68881 FPU
2626
2727  380:
2828    MC68040 CPU @ 25 MHz w/built-in MMU and FPU
2929
3030  382:
3131    MC68040 CPU @ 25? MHz w/built-in MMU and FPU
32    Built-in VGA compatible video
32   Built-in VGA compatible video
3333
3434  All models have an MC6840 PIT on IRQ6 clocked at 250 kHz.
3535
r243230r243231
132132
133133// shared mappings for all 9000/3xx systems
134134static ADDRESS_MAP_START(hp9k3xx_common, AS_PROGRAM, 32, hp9k3xx_state)
135   AM_RANGE(0x00000000, 0x0001ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP  // writes to 1fffc are the LED
135   AM_RANGE(0x00000000, 0x0001ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP   // writes to 1fffc are the LED
136136
137   AM_RANGE(0x00500000, 0x0050000f) AM_RAM // this is sufficient to pass the DMA test for now
137   AM_RANGE(0x00500000, 0x0050000f) AM_RAM   // this is sufficient to pass the DMA test for now
138138
139   AM_RANGE(0x00510000, 0x00510003) AM_READWRITE(buserror_r, buserror_w)   // no "Alpha display"
140   AM_RANGE(0x00538000, 0x00538003) AM_READWRITE(buserror_r, buserror_w)   // no "Graphics"
141   AM_RANGE(0x005c0000, 0x005c0003) AM_READWRITE(buserror_r, buserror_w)   // no add-on FP coprocessor
139   AM_RANGE(0x00510000, 0x00510003) AM_READWRITE(buserror_r, buserror_w)    // no "Alpha display"
140   AM_RANGE(0x00538000, 0x00538003) AM_READWRITE(buserror_r, buserror_w)   // no "Graphics"
141   AM_RANGE(0x005c0000, 0x005c0003) AM_READWRITE(buserror_r, buserror_w)   // no add-on FP coprocessor
142142   AM_RANGE(0x005f8000, 0x005f800f) AM_DEVREADWRITE8(PTM6840_TAG, ptm6840_device, read, write, 0x00ff00ff)
143143ADDRESS_MAP_END
144144
145145// 9000/310 - has onboard video that the graphics card used in other 3xxes conflicts with
146146static ADDRESS_MAP_START(hp9k310_map, AS_PROGRAM, 16, hp9k3xx_state)
147   AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP  // writes to 1fffc are the LED
147   AM_RANGE(0x000000, 0x01ffff) AM_ROM AM_REGION("maincpu",0) AM_WRITENOP   // writes to 1fffc are the LED
148148
149   AM_RANGE(0x510000, 0x510003) AM_READWRITE(buserror16_r, buserror16_w)   // no "Alpha display"
150   AM_RANGE(0x538000, 0x538003) AM_READWRITE(buserror16_r, buserror16_w)   // no "Graphics"
151   AM_RANGE(0x5c0000, 0x5c0003) AM_READWRITE(buserror16_r, buserror16_w)   // no add-on FP coprocessor
149   AM_RANGE(0x510000, 0x510003) AM_READWRITE(buserror16_r, buserror16_w)    // no "Alpha display"
150   AM_RANGE(0x538000, 0x538003) AM_READWRITE(buserror16_r, buserror16_w)   // no "Graphics"
151   AM_RANGE(0x5c0000, 0x5c0003) AM_READWRITE(buserror16_r, buserror16_w)   // no add-on FP coprocessor
152152
153153   AM_RANGE(0x5f8000, 0x5f800f) AM_DEVREADWRITE8(PTM6840_TAG, ptm6840_device, read, write, 0x00ff)
154154
155   AM_RANGE(0x200000, 0x2fffff) AM_RAM AM_SHARE("vram16")  // 98544 mono framebuffer
156   AM_RANGE(0x560000, 0x563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
155   AM_RANGE(0x200000, 0x2fffff) AM_RAM AM_SHARE("vram16")   // 98544 mono framebuffer
156   AM_RANGE(0x560000, 0x563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
157157
158158   AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(buserror16_r, buserror16_w)
159159   AM_RANGE(0x800000, 0xffffff) AM_RAM
r243230r243231
161161
162162// 9000/320
163163static ADDRESS_MAP_START(hp9k320_map, AS_PROGRAM, 32, hp9k3xx_state)
164   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram")    // 98544 mono framebuffer
165   AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
164   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram")   // 98544 mono framebuffer
165   AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
166166
167167   AM_RANGE(0xffe00000, 0xffefffff) AM_READWRITE(buserror_r, buserror_w)
168168   AM_RANGE(0xfff00000, 0xffffffff) AM_RAM
r243230r243231
172172
173173// 9000/330 and 9000/340
174174static ADDRESS_MAP_START(hp9k330_map, AS_PROGRAM, 32, hp9k3xx_state)
175   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram")    // 98544 mono framebuffer
176   AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
175   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram")   // 98544 mono framebuffer
176   AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
177177
178178   AM_RANGE(0xffb00000, 0xffbfffff) AM_READWRITE(buserror_r, buserror_w)
179179   AM_RANGE(0xffc00000, 0xffffffff) AM_RAM
r243230r243231
183183
184184// 9000/370 - 8 MB RAM standard
185185static ADDRESS_MAP_START(hp9k370_map, AS_PROGRAM, 32, hp9k3xx_state)
186   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram")    // 98544 mono framebuffer
187   AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
186   AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_SHARE("vram")   // 98544 mono framebuffer
187   AM_RANGE(0x00560000, 0x00563fff) AM_ROM AM_REGION("graphics", 0x0000)   // 98544 mono ROM
188188
189189   AM_RANGE(0xff700000, 0xff7fffff) AM_READWRITE(buserror_r, buserror_w)
190190   AM_RANGE(0xff800000, 0xffffffff) AM_RAM
r243230r243231
292292   MCFG_CPU_PROGRAM_MAP(hp9k310_map)
293293
294294   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
295   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
295   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
296296   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
297297
298298   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
308308   MCFG_CPU_PROGRAM_MAP(hp9k320_map)
309309
310310   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
311   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
311   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
312312   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
313313
314314   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
324324   MCFG_CPU_PROGRAM_MAP(hp9k330_map)
325325
326326   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
327   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
327   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
328328   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
329329
330330   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
340340   MCFG_CPU_PROGRAM_MAP(hp9k330_map)
341341
342342   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
343   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
343   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
344344   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
345345
346346   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
356356   MCFG_CPU_PROGRAM_MAP(hp9k370_map)
357357
358358   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
359   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
359   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
360360   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
361361
362362   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
368368
369369static MACHINE_CONFIG_START( hp9k380, hp9k3xx_state )
370370   /* basic machine hardware */
371   MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz?  33?
371   MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000)   // 25 MHz?  33?
372372   MCFG_CPU_PROGRAM_MAP(hp9k330_map)
373373
374374   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
375   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
375   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
376376   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
377377
378378   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
384384
385385static MACHINE_CONFIG_START( hp9k382, hp9k3xx_state )
386386   /* basic machine hardware */
387   MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000) // 25 MHz?  33?
387   MCFG_CPU_ADD(MAINCPU_TAG, M68040, 25000000)   // 25 MHz?  33?
388388   MCFG_CPU_PROGRAM_MAP(hp9k382_map)
389389
390390   MCFG_DEVICE_ADD(PTM6840_TAG, PTM6840, 0)
391   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)  // from oscillator module next to the 6840
391   MCFG_PTM6840_INTERNAL_CLOCK(250000.0f)   // from oscillator module next to the 6840
392392   MCFG_PTM6840_EXTERNAL_CLOCKS(250000.0f, 250000.0f, 250000.0f)
393393
394394   MCFG_SCREEN_ADD( "screen", RASTER)
r243230r243231
400400
401401ROM_START( hp9k310 )
402402   ROM_REGION( 0x20000, MAINCPU_TAG, 0 )
403   ROM_LOAD16_BYTE( "1818-3771.bin", 0x000001, 0x008000, CRC(b9e4e3ad) SHA1(ed6f1fad94a15d95362701dbe124b52877fc3ec4) )
404   ROM_LOAD16_BYTE( "1818-3772.bin", 0x000000, 0x008000, CRC(a3665919) SHA1(ec1bc7e5b7990a1b09af947a06401e8ed3cb0516) )
403   ROM_LOAD16_BYTE( "1818-3771.bin", 0x000001, 0x008000, CRC(b9e4e3ad) SHA1(ed6f1fad94a15d95362701dbe124b52877fc3ec4) )
404   ROM_LOAD16_BYTE( "1818-3772.bin", 0x000000, 0x008000, CRC(a3665919) SHA1(ec1bc7e5b7990a1b09af947a06401e8ed3cb0516) )
405405
406406   ROM_REGION( 0x800, "mcu", 0 )
407   ROM_LOAD( "1820-4784_1.bin", 0x000000, 0x000800, CRC(e929044a) SHA1(90849a10bdb8c6e38e73ce027c9c0ad8b3956b1b) )
408   ROM_LOAD( "1820-4784_2.bin", 0x000000, 0x000800, CRC(8defcf50) SHA1(d3abfea468a43db7c2369500a3e390e77a8e22e6) )
407   ROM_LOAD( "1820-4784_1.bin", 0x000000, 0x000800, CRC(e929044a) SHA1(90849a10bdb8c6e38e73ce027c9c0ad8b3956b1b) )
408   ROM_LOAD( "1820-4784_2.bin", 0x000000, 0x000800, CRC(8defcf50) SHA1(d3abfea468a43db7c2369500a3e390e77a8e22e6) )
409409
410410   ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE )
411411   ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000000, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) )
r243230r243231
413413
414414ROM_START( hp9k320 )
415415   ROM_REGION( 0x20000, MAINCPU_TAG, 0 )
416   ROM_LOAD16_BYTE( "5061-6538.bin", 0x000001, 0x004000, CRC(d6aafeb1) SHA1(88c6b0b2f504303cbbac0c496c26b85458ac5d63) )
417   ROM_LOAD16_BYTE( "5061-6539.bin", 0x000000, 0x004000, CRC(a7ff104c) SHA1(c640fe68314654716bd41b04c6a7f4e560036c7e) )
418   ROM_LOAD16_BYTE( "5061-6540.bin", 0x008001, 0x004000, CRC(4f6796d6) SHA1(fd254897ac1afb8628f40ea93213f60a082c8d36) )
419   ROM_LOAD16_BYTE( "5061-6541.bin", 0x008000, 0x004000, CRC(39d32998) SHA1(6de1bda75187b0878c03c074942b807cf2924f0e) )
416   ROM_LOAD16_BYTE( "5061-6538.bin", 0x000001, 0x004000, CRC(d6aafeb1) SHA1(88c6b0b2f504303cbbac0c496c26b85458ac5d63) )
417   ROM_LOAD16_BYTE( "5061-6539.bin", 0x000000, 0x004000, CRC(a7ff104c) SHA1(c640fe68314654716bd41b04c6a7f4e560036c7e) )
418   ROM_LOAD16_BYTE( "5061-6540.bin", 0x008001, 0x004000, CRC(4f6796d6) SHA1(fd254897ac1afb8628f40ea93213f60a082c8d36) )
419   ROM_LOAD16_BYTE( "5061-6541.bin", 0x008000, 0x004000, CRC(39d32998) SHA1(6de1bda75187b0878c03c074942b807cf2924f0e) )
420420
421421   ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT )
422422   ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) )
r243230r243231
424424
425425ROM_START( hp9k330 )
426426   ROM_REGION( 0x20000, MAINCPU_TAG, 0 )
427   ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) )
428   ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) )
427   ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) )
428   ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) )
429429
430430   ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT )
431431   ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) )
r243230r243231
433433
434434ROM_START( hp9k340 )
435435   ROM_REGION( 0x20000, MAINCPU_TAG, 0 )
436   ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) )
437   ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) )
436   ROM_LOAD16_BYTE( "1818-4416.bin", 0x000000, 0x010000, CRC(cd71e85e) SHA1(3e83a80682f733417fdc3720410e45a2cfdcf869) )
437   ROM_LOAD16_BYTE( "1818-4417.bin", 0x000001, 0x010000, CRC(374d49db) SHA1(a12cbf6c151e2f421da4571000b5dffa3ef403b3) )
438438
439439   ROM_REGION( 0x4000, "graphics", ROMREGION_ERASEFF | ROMREGION_BE | ROMREGION_32BIT )
440440   ROM_LOAD16_BYTE( "98544_1818-1999.bin", 0x000001, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) )
trunk/src/mess/drivers/nes.c
r243230r243231
214214{
215215   m_ciram = auto_alloc_array(machine(), UINT8, 0x800);
216216   setup_disk(m_disk);
217
217   
218218   // register saves
219219   save_item(NAME(m_last_frame_flip));
220220   save_pointer(NAME(m_ciram), 0x800);
trunk/src/mess/drivers/ngen.c
r243230r243231
406406
407407// X-bus module select
408408// The bootstrap ROM creates a table at 0:FC9h, with a count, followed by the module IDs of each
409// expansion module.  The base I/O address for the currently selected module is set by writing to
409// expansion module.  The base I/O address for the currently selected module is set by writing to
410410// this register (bits 0-7 are ignored)
411411// TODO: make expansion modules slot devices
412412WRITE16_MEMBER(ngen_state::xbus_w)
r243230r243231
435435READ16_MEMBER(ngen_state::xbus_r)
436436{
437437   UINT16 ret = 0xffff;
438
438   
439439   switch(m_xbus_current)
440440   {
441441      case 0x00:
r243230r243231
647647
648648READ8_MEMBER(ngen_state::dma_3_dack_r)
649649{
650   UINT16 ret = 0xffff;
651
650   UINT16 ret = 0xffff;
651   
652652   if((m_hdc_control & 0x04) && m_disk_rom)
653653   {
654654      ret = m_disk_rom->base()[m_disk_rom_ptr++] << 8;
r243230r243231
659659         //m_dmac->dreq3_w(0);
660660      }
661661   }
662   m_dma_high_byte = ret & 0xff00;
662   m_dma_high_byte = ret & 0xff00;
663663   return ret;
664664}
665665
r243230r243231
737737
738738static ADDRESS_MAP_START( ngen_io, AS_IO, 16, ngen_state )
739739   AM_RANGE(0x0000, 0x0001) AM_READWRITE(xbus_r,xbus_w)
740
740   
741741   // Floppy/Hard disk module
742//  AM_RANGE(0x0100, 0x0107) AM_DEVREADWRITE8("fdc",wd2797_t,read,write,0x00ff)  // a guess for now
743//  AM_RANGE(0x0108, 0x0109) AM_WRITE8(fdc_control_w,0x00ff)
744//  AM_RANGE(0x010a, 0x010b) AM_WRITE8(hdc_control_w,0x00ff)
745//  AM_RANGE(0x010e, 0x010f) AM_WRITE8(disk_addr_ext,0x00ff)  // X-Bus extended address register
746//  AM_RANGE(0x0110, 0x0117) AM_DEVREADWRITE8("fdc_timer",pit8253_device,read,write,0x00ff)
742//   AM_RANGE(0x0100, 0x0107) AM_DEVREADWRITE8("fdc",wd2797_t,read,write,0x00ff)  // a guess for now
743//   AM_RANGE(0x0108, 0x0109) AM_WRITE8(fdc_control_w,0x00ff)
744//   AM_RANGE(0x010a, 0x010b) AM_WRITE8(hdc_control_w,0x00ff)
745//   AM_RANGE(0x010e, 0x010f) AM_WRITE8(disk_addr_ext,0x00ff)  // X-Bus extended address register
746//   AM_RANGE(0x0110, 0x0117) AM_DEVREADWRITE8("fdc_timer",pit8253_device,read,write,0x00ff)
747747   // 0x0120-0x012f - WD1010 Winchester disk controller (unemulated)
748//  AM_RANGE(0x0130, 0x0137) AM_DEVREADWRITE8("hdc_timer",pit8253_device,read,write,0x00ff)
749
748//   AM_RANGE(0x0130, 0x0137) AM_DEVREADWRITE8("hdc_timer",pit8253_device,read,write,0x00ff)
749   
750750ADDRESS_MAP_END
751751
752752static ADDRESS_MAP_START( ngen386_mem, AS_PROGRAM, 32, ngen_state )
r243230r243231
851851
852852   // keyboard UART (patent says i8251 is used for keyboard communications, it is located on the video board)
853853   MCFG_DEVICE_ADD("videouart", I8251, 0)  // main clock unknown, Rx/Tx clocks are 19.53kHz
854//  MCFG_I8251_TXEMPTY_HANDLER(DEVWRITELINE("pic",pic8259_device,ir4_w))
854//   MCFG_I8251_TXEMPTY_HANDLER(DEVWRITELINE("pic",pic8259_device,ir4_w))
855855   MCFG_I8251_TXD_HANDLER(DEVWRITELINE("keyboard", rs232_port_device, write_txd))
856856   MCFG_RS232_PORT_ADD("keyboard", keyboard, "ngen")
857857   MCFG_RS232_RXD_HANDLER(DEVWRITELINE("videouart", i8251_device, write_rxd))
r243230r243231
865865   MCFG_WD_FDC_DRQ_CALLBACK(DEVWRITELINE("maincpu",i80186_cpu_device,drq1_w))
866866   MCFG_WD_FDC_FORCE_READY
867867   MCFG_DEVICE_ADD("fdc_timer", PIT8253, 0)
868   MCFG_PIT8253_CLK0(XTAL_20MHz / 20)
868   MCFG_PIT8253_CLK0(XTAL_20MHz / 20) 
869869   MCFG_PIT8253_OUT0_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w))  // clocked on FDC data register access
870870   MCFG_PIT8253_CLK1(XTAL_20MHz / 20)
871871   MCFG_PIT8253_OUT1_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w))  // 1MHz
872872   MCFG_PIT8253_CLK2(XTAL_20MHz / 10)
873   MCFG_PIT8253_OUT2_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w))
873   MCFG_PIT8253_OUT2_HANDLER(DEVWRITELINE("pic",pic8259_device,ir7_w)) 
874874   // TODO: WD1010 HDC (not implemented), use WD2010 for now
875875   MCFG_DEVICE_ADD("hdc", WD2010, XTAL_20MHz / 4)
876876   MCFG_WD2010_IN_BCS_CB(READ8(ngen_state,hd_buffer_r))
trunk/src/mess/drivers/pasogo.c
r243230r243231
681681   astring region_tag;
682682   m_maincpu_rom = memregion("maincpu");
683683   m_cart_rom = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG));
684   if (!m_cart_rom)    // this should never happen, since we make carts mandatory!
684   if (!m_cart_rom)   // this should never happen, since we make carts mandatory!
685685      m_cart_rom = memregion("maincpu");
686686
687687   membank("bank27")->set_base(m_cart_rom->base());
trunk/src/mess/drivers/splitsec.c
r243230r243231
44
55  Parker Brothers Split Second
66  * TMS1400NLL MP7314-N2 (die labeled MP7314)
7
7 
88  This is an electronic handheld reflex gaming device, it's straightforward
99  to use. The included mini-games are:
1010  1, 2, 3: Mad Maze*
r243230r243231
1212  6: Auto Cross
1313  7: Stomp
1414  8: Speedball
15
15 
1616  *: higher number indicates higher difficulty
1717
1818
r243230r243231
167167{
168168   // R8: speaker out
169169   m_speaker->level_w(data >> 8 & 1);
170
170   
171171   // R9,R10: input mux
172172   // R0-R7: led columns
173173   m_r = data;
trunk/src/mess/drivers/tispeak.c
r243230r243231
693693COMP( 1980, snspella,   snspell, 0, snspell,  snspell,  tispeak_state, snspell,  "Texas Instruments", "Speak & Spell (US set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
694694COMP( 1978, snspelluk,  snspell, 0, snspell,  snspell,  tispeak_state, snspell,  "Texas Instruments", "Speak & Spell (UK set 1)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
695695COMP( 1981, snspelluka, snspell, 0, snspell,  snspell,  tispeak_state, snspell,  "Texas Instruments", "Speak & Spell (UK set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) // different voice actor
696COMP( 1979, snspelljp,  snspell, 0, snspell,  snspell,  tispeak_state, snspell,  "Texas Instruments", "Speak & Spell (Japan)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
696COMP( 1979, snspelljp,  snspell, 0, snspell,  snspell,  tispeak_state, snspell,  "Texas Instruments", "Speak & Spell (Japan)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
697697COMP( 1980, ladictee,   snspell, 0, snspell,  snspell,  tispeak_state, snspell,  "Texas Instruments", "La Dictee Magique (France)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) // doesn't work due to missing CD2702 MCU dump, German version has CD2702 too
698698
699699COMP( 1980, snmath,     0,       0, snmath,   snmath,   driver_device, 0,        "Texas Instruments", "Speak & Math (US prototype)", GAME_IMPERFECT_SOUND ) // also US set 1
trunk/src/mess/drivers/vt100.c
r243230r243231
758758// does not have integrated STP or AVO populated
759759// 8085 based instead of I8080
760760   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
761   ROM_LOAD( "23-028e4-00.e71", 0x0000, 0x2000, NO_DUMP) // rom is unique to vt101; "CN55004N 8232 // DEC TP03 // 23-028E4-00" 24-pin mask rom (mc68764 pinout)
761   ROM_LOAD( "23-???e4-00.e71", 0x0000, 0x2000, NO_DUMP) // rom is unique to vt101
762762   //e69 socket is empty/unpopulated on vt101?
763763   //e67 socket is empty/unpopulated on vt101?
764764
trunk/src/mess/includes/c65.h
r243230r243231
1/*****************************************************************************
2 *
3 * includes/c65.h
4 *
5 ****************************************************************************/
16
7#ifndef C65_H_
8#define C65_H_
9
10#include "machine/mos6526.h"
11#include "bus/cbmiec/cbmiec.h"
12#include "imagedev/snapquik.h"
13#include "machine/ram.h"
14#include "sound/mos6581.h"
15#include "video/vic4567.h"
16
17#define C64_MAX_ROMBANK 64 // .crt files contain multiple 'CHIPs', i.e. rom banks (of variable size) with headers. Known carts have at most 64 'CHIPs'.
18
19struct C64_ROM {
20   int addr, size, index, start;
21};
22
23struct c64_cart_t {
24   C64_ROM     bank[C64_MAX_ROMBANK];
25   INT8        game;
26   INT8        exrom;
27   UINT8       mapper;
28   UINT8       n_banks;
29};
30
31struct dma_t
32{
33   int version;
34   UINT8 data[4];
35};
36
37struct fdc_t
38{
39   int state;
40
41   UINT8 reg[0x0f];
42
43   UINT8 buffer[0x200];
44   int cpu_pos;
45   int fdc_pos;
46
47   UINT16 status;
48
49   attotime time;
50   int head,track,sector;
51};
52
53struct expansion_ram_t
54{
55   UINT8 reg;
56};
57
58class c65_state : public driver_device
59{
60public:
61   c65_state(const machine_config &mconfig, device_type type, const char *tag)
62      : driver_device(mconfig, type, tag),
63         m_cia0(*this, "cia_0"),
64         m_cia1(*this, "cia_1"),
65         m_sid_r(*this, "sid_r"),
66         m_vic(*this, "vic3"),
67         m_iec(*this, CBM_IEC_TAG),
68         m_colorram(*this, "colorram"),
69         m_basic(*this, "basic"),
70         m_chargen(*this, "chargen"),
71         m_kernal(*this, "kernal"),
72         m_c65_chargen(*this, "c65_chargen"),
73         m_interface(*this, "interface"),
74         m_roml_writable(0),
75      m_maincpu(*this, "maincpu"),
76      m_ram(*this, RAM_TAG) { }
77
78   required_device<mos6526_device> m_cia0;
79   required_device<mos6526_device> m_cia1;
80   required_device<mos6581_device> m_sid_r;
81   required_device<vic3_device> m_vic;
82   optional_device<cbm_iec_device> m_iec;
83
84   required_shared_ptr<UINT8> m_colorram;
85   required_shared_ptr<UINT8> m_basic;
86   required_shared_ptr<UINT8> m_chargen;
87   required_shared_ptr<UINT8> m_kernal;
88   required_shared_ptr<UINT8> m_c65_chargen;
89   required_shared_ptr<UINT8> m_interface;
90   int m_old_level;
91   int m_old_data;
92   int m_old_exrom;
93   int m_old_game;
94   UINT8 m_vicirq;
95   emu_timer *m_datasette_timer;
96   emu_timer *m_cartridge_timer;
97   UINT8 *m_memory;
98   int m_pal;
99   int m_tape_on;
100   UINT8 *m_c64_roml;
101   UINT8 *m_c64_romh;
102   UINT8 *m_vicaddr;
103   UINT8 *m_c128_vicaddr;
104   UINT8 m_game;
105   UINT8 m_exrom;
106   UINT8 *m_io_mirror;
107   UINT8 m_port_data;
108   UINT8 *m_roml;
109   UINT8 *m_romh;
110   int m_roml_writable;
111   int m_ultimax;
112   int m_cia1_on;
113   int m_io_enabled;
114   int m_is_sx64;
115   UINT8 *m_io_ram_w_ptr;
116   UINT8 *m_io_ram_r_ptr;
117   c64_cart_t m_cart;
118   int m_nmilevel; int m_charset_select;
119   int m_c64mode;
120   UINT8 m_6511_port;
121   UINT8 m_keyline;
122   int m_old_value;
123   dma_t m_dma;
124   int m_dump_dma;
125   fdc_t m_fdc;
126   expansion_ram_t m_expansion_ram;
127   int m_io_on;
128   int m_io_dc00_on;
129   int m_cia0_irq, m_cia1_irq;
130   DECLARE_DRIVER_INIT(c65);
131   DECLARE_DRIVER_INIT(c65pal);
132
133   DECLARE_READ8_MEMBER( c64_lightpen_x_cb );
134   DECLARE_READ8_MEMBER( c64_lightpen_y_cb );
135   DECLARE_READ8_MEMBER( c64_lightpen_button_cb );
136   DECLARE_READ8_MEMBER( c64_dma_read );
137   DECLARE_READ8_MEMBER( c64_dma_read_ultimax );
138   DECLARE_READ8_MEMBER( c64_dma_read_color );
139   DECLARE_WRITE_LINE_MEMBER( c64_vic_interrupt );
140   DECLARE_READ8_MEMBER( c64_rdy_cb );
141   DECLARE_READ8_MEMBER( sid_potx_r );
142   DECLARE_READ8_MEMBER( sid_poty_r );
143   DECLARE_MACHINE_START(c65);
144   UINT32 screen_update_c65(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
145   INTERRUPT_GEN_MEMBER(vic3_raster_irq);
146   INTERRUPT_GEN_MEMBER(c65_frame_interrupt);
147   DECLARE_READ8_MEMBER(c65_cia0_port_a_r);
148   DECLARE_READ8_MEMBER(c65_cia0_port_b_r);
149   DECLARE_WRITE8_MEMBER(c65_cia0_port_b_w);
150   DECLARE_READ8_MEMBER(c65_cia1_port_a_r);
151   DECLARE_WRITE8_MEMBER(c65_cia1_port_a_w);
152   DECLARE_WRITE_LINE_MEMBER(c65_cia1_interrupt);
153   void c64_legacy_driver_init();
154   DECLARE_DEVICE_IMAGE_LOAD_MEMBER( c64_cart );
155   DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( c64_cart );
156   DECLARE_WRITE_LINE_MEMBER(c65_cia0_interrupt);
157   DECLARE_READ8_MEMBER(c65_lightpen_x_cb);
158   DECLARE_READ8_MEMBER(c65_lightpen_y_cb);
159   DECLARE_READ8_MEMBER(c65_lightpen_button_cb);
160   DECLARE_READ8_MEMBER(c65_c64_mem_r);
161   DECLARE_READ8_MEMBER(c65_dma_read);
162   DECLARE_READ8_MEMBER(c65_dma_read_color);
163   DECLARE_WRITE_LINE_MEMBER(c65_vic_interrupt);
164   DECLARE_WRITE8_MEMBER(c65_bankswitch_interface);
165   DECLARE_READ8_MEMBER( c65_read_mem );
166   DECLARE_WRITE8_MEMBER( c65_write_mem );
167   DECLARE_READ8_MEMBER( c65_ram_expansion_r );
168   DECLARE_WRITE8_MEMBER( c65_ram_expansion_w );
169   DECLARE_WRITE8_MEMBER( c65_write_io );
170   DECLARE_WRITE8_MEMBER( c65_write_io_dc00 );
171   DECLARE_READ8_MEMBER( c65_read_io );
172   DECLARE_READ8_MEMBER( c65_read_io_dc00 );
173   DECLARE_QUICKLOAD_LOAD_MEMBER( cbm_c65 );
174
175   int c64_paddle_read( device_t *device, address_space &space, int which );
176   void c65_nmi(  );
177   void c65_irq( int level );
178   void c65_dma_port_w( int offset, int value );
179   int c65_dma_port_r( int offset );
180   void c65_6511_port_w( int offset, int value );
181   int c65_6511_port_r( int offset );
182   void c65_fdc_state(void);
183   void c65_fdc_w( int offset, int data );
184   int c65_fdc_r( int offset );
185   void c65_bankswitch(  );
186   void c65_colorram_write( int offset, int value );
187   void c65_common_driver_init(  );
188
189   required_device<cpu_device> m_maincpu;
190   required_device<ram_device> m_ram;
191};
192
193MACHINE_CONFIG_EXTERN( c64_cartslot );
194
195#endif /* C65_H_ */
trunk/src/mess/includes/mac.h
r243230r243231
291291   INT32 m_adb_linestate;
292292   bool  m_adb_srqflag;
293293#define kADBKeyBufSize 32
294      UINT8 m_adb_keybuf[kADBKeyBufSize];
295      UINT8 m_adb_keybuf_start;
296      UINT8 m_adb_keybuf_end;
294        UINT8 m_adb_keybuf[kADBKeyBufSize];
295        UINT8 m_adb_keybuf_start;
296        UINT8 m_adb_keybuf_end;
297297
298298   // Portable/PB100 Power Manager IC comms (chapter 4, "Guide to the Macintosh Family Hardware", second edition)
299299   UINT8 m_pm_data_send, m_pm_data_recv, m_pm_ack, m_pm_req, m_pm_cmd[32], m_pm_out[32], m_pm_dptr, m_pm_sptr, m_pm_slen, m_pm_state;
trunk/src/mess/machine/amstrad.c
r243230r243231
30343034
30353035   astring region_tag;
30363036   m_region_cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG));
3037   if (!m_region_cart) // this should never happen, since we make carts mandatory!
3037   if (!m_region_cart)   // this should never happen, since we make carts mandatory!
30383038      m_region_cart = memregion("maincpu");
30393039}
30403040
r243230r243231
30783078
30793079   astring region_tag;
30803080   m_region_cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG));
3081   if (!m_region_cart) // this should never happen, since we make carts mandatory!
3081   if (!m_region_cart)   // this should never happen, since we make carts mandatory!
30823082      m_region_cart = memregion("maincpu");
30833083}
30843084
trunk/src/mess/machine/c65.c
r0r243231
1/***************************************************************************
2    commodore c65 home computer
3    peter.trauner@jk.uni-linz.ac.at
4    documention
5     www.funet.fi
6 ***************************************************************************/
7
8#include "emu.h"
9
10#include "includes/c65.h"
11#include "cpu/m6502/m4510.h"
12#include "sound/mos6581.h"
13#include "machine/mos6526.h"
14#include "bus/cbmiec/cbmiec.h"
15#include "machine/ram.h"
16#include "video/vic4567.h"
17#include "imagedev/cassette.h"
18#include "crsshair.h"
19#include "formats/cbm_tap.h"
20
21#define VERBOSE_LEVEL 0
22#define DBG_LOG( MACHINE, N, M, A ) \
23   do { \
24      if(VERBOSE_LEVEL >= N) \
25      { \
26         if( M ) \
27            logerror("%11.6f: %-24s", MACHINE.time().as_double(), (char*) M ); \
28         logerror A; \
29      } \
30   } while (0)
31
32
33
34/***********************************************
35
36    Input Reading - Common Components
37
38***********************************************/
39
40/* These are needed by c64, c65 and c128, each machine has also additional specific
41components in its INTERRUPT_GEN */
42
43/* keyboard lines */
44UINT8 c64_keyline[10];
45
46void cbm_common_init(void)
47{
48   int i;
49
50   for (i = 0; i < ARRAY_LENGTH(c64_keyline); i++)
51      c64_keyline[i] = 0xff;
52}
53
54static TIMER_CALLBACK( lightpen_tick )
55{
56   if (((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x04) || ((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x06))
57   {
58      /* enable lightpen crosshair */
59      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
60   }
61   else
62   {
63      /* disable lightpen crosshair */
64      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
65   }
66}
67
68void cbm_common_interrupt( device_t *device )
69{
70   int value, i;
71   int controller1 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x07;
72   int controller2 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x70;
73   static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" };
74
75   /* Lines 0-7 : common keyboard */
76   for (i = 0; i < 8; i++)
77   {
78      value = 0xff;
79      value &= ~device->machine().root_device().ioport(c64ports[i])->read();
80
81      /* Shift Lock is mapped on Left Shift */
82      if ((i == 1) && (device->machine().root_device().ioport("SPECIAL")->read() & 0x40))
83         value &= ~0x80;
84
85      c64_keyline[i] = value;
86   }
87
88
89   value = 0xff;
90   switch(controller1)
91   {
92      case 0x00:
93         value &= ~device->machine().root_device().ioport("JOY1_1B")->read();            /* Joy1 Directions + Button 1 */
94         break;
95
96      case 0x01:
97         if (device->machine().root_device().ioport("OTHER")->read() & 0x40)         /* Paddle2 Button */
98            value &= ~0x08;
99         if (device->machine().root_device().ioport("OTHER")->read() & 0x80)         /* Paddle1 Button */
100            value &= ~0x04;
101         break;
102
103      case 0x02:
104         if (device->machine().root_device().ioport("OTHER")->read() & 0x02)         /* Mouse Button Left */
105            value &= ~0x10;
106         if (device->machine().root_device().ioport("OTHER")->read() & 0x01)         /* Mouse Button Right */
107            value &= ~0x01;
108         break;
109
110      case 0x03:
111         value &= ~(device->machine().root_device().ioport("JOY1_2B")->read() & 0x1f);   /* Joy1 Directions + Button 1 */
112         break;
113
114      case 0x04:
115/* was there any input on the lightpen? where is it mapped? */
116//          if (device->machine().root_device().ioport("OTHER")->read() & 0x04)           /* Lightpen Signal */
117//              value &= ?? ;
118         break;
119
120      case 0x07:
121         break;
122
123      default:
124         logerror("Invalid Controller 1 Setting %d\n", controller1);
125         break;
126   }
127
128   c64_keyline[8] = value;
129
130
131   value = 0xff;
132   switch(controller2)
133   {
134      case 0x00:
135         value &= ~device->machine().root_device().ioport("JOY2_1B")->read();            /* Joy2 Directions + Button 1 */
136         break;
137
138      case 0x10:
139         if (device->machine().root_device().ioport("OTHER")->read() & 0x10)         /* Paddle4 Button */
140            value &= ~0x08;
141         if (device->machine().root_device().ioport("OTHER")->read() & 0x20)         /* Paddle3 Button */
142            value &= ~0x04;
143         break;
144
145      case 0x20:
146         if (device->machine().root_device().ioport("OTHER")->read() & 0x02)         /* Mouse Button Left */
147            value &= ~0x10;
148         if (device->machine().root_device().ioport("OTHER")->read() & 0x01)         /* Mouse Button Right */
149            value &= ~0x01;
150         break;
151
152      case 0x30:
153         value &= ~(device->machine().root_device().ioport("JOY2_2B")->read() & 0x1f);   /* Joy2 Directions + Button 1 */
154         break;
155
156      case 0x40:
157/* was there any input on the lightpen? where is it mapped? */
158//          if (device->machine().root_device().ioport("OTHER")->read() & 0x04)           /* Lightpen Signal */
159//              value &= ?? ;
160         break;
161
162      case 0x70:
163         break;
164
165      default:
166         logerror("Invalid Controller 2 Setting %d\n", controller2);
167         break;
168   }
169
170   c64_keyline[9] = value;
171
172//  vic2_frame_interrupt does nothing so this is not necessary
173//  vic2_frame_interrupt (device);
174
175   /* check if lightpen has been chosen as input: if so, enable crosshair */
176   device->machine().scheduler().timer_set(attotime::zero, FUNC(lightpen_tick));
177
178   set_led_status (device->machine(), 1, device->machine().root_device().ioport("SPECIAL")->read() & 0x40 ? 1 : 0);        /* Shift Lock */
179   set_led_status (device->machine(), 0, device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ? 1 : 0);        /* Joystick Swap */
180}
181
182
183/***********************************************
184
185    CIA Common Handlers
186
187***********************************************/
188
189/* These are shared by c64, c65 and c128. c65 and c128 also have additional specific
190components (to select/read additional keyboard lines) */
191
192/*
193 *  CIA 0 - Port A
194 * bits 7-0 keyboard line select
195 * bits 7,6: paddle select( 01 port a, 10 port b)
196 * bit 4: joystick a fire button
197 * bits 3,2: Paddles port a fire button
198 * bits 3-0: joystick a direction
199 *
200 *  CIA 0 - Port B
201 * bits 7-0: keyboard raw values
202 * bit 4: joystick b fire button, lightpen select
203 * bits 3,2: paddle b fire buttons (left,right)
204 * bits 3-0: joystick b direction
205 *
206 * flag cassette read input, serial request in
207 * irq to irq connected
208 */
209
210UINT8 cbm_common_cia0_port_a_r( device_t *device, UINT8 output_b )
211{
212   UINT8 value = 0xff;
213
214   if (!(output_b & 0x80))
215   {
216      UINT8 t = 0xff;
217      if (!(c64_keyline[7] & 0x80)) t &= ~0x80;
218      if (!(c64_keyline[6] & 0x80)) t &= ~0x40;
219      if (!(c64_keyline[5] & 0x80)) t &= ~0x20;
220      if (!(c64_keyline[4] & 0x80)) t &= ~0x10;
221      if (!(c64_keyline[3] & 0x80)) t &= ~0x08;
222      if (!(c64_keyline[2] & 0x80)) t &= ~0x04;
223      if (!(c64_keyline[1] & 0x80)) t &= ~0x02;
224      if (!(c64_keyline[0] & 0x80)) t &= ~0x01;
225      value &= t;
226   }
227
228   if (!(output_b & 0x40))
229   {
230      UINT8 t = 0xff;
231      if (!(c64_keyline[7] & 0x40)) t &= ~0x80;
232      if (!(c64_keyline[6] & 0x40)) t &= ~0x40;
233      if (!(c64_keyline[5] & 0x40)) t &= ~0x20;
234      if (!(c64_keyline[4] & 0x40)) t &= ~0x10;
235      if (!(c64_keyline[3] & 0x40)) t &= ~0x08;
236      if (!(c64_keyline[2] & 0x40)) t &= ~0x04;
237      if (!(c64_keyline[1] & 0x40)) t &= ~0x02;
238      if (!(c64_keyline[0] & 0x40)) t &= ~0x01;
239      value &= t;
240   }
241
242   if (!(output_b & 0x20))
243   {
244      UINT8 t = 0xff;
245      if (!(c64_keyline[7] & 0x20)) t &= ~0x80;
246      if (!(c64_keyline[6] & 0x20)) t &= ~0x40;
247      if (!(c64_keyline[5] & 0x20)) t &= ~0x20;
248      if (!(c64_keyline[4] & 0x20)) t &= ~0x10;
249      if (!(c64_keyline[3] & 0x20)) t &= ~0x08;
250      if (!(c64_keyline[2] & 0x20)) t &= ~0x04;
251      if (!(c64_keyline[1] & 0x20)) t &= ~0x02;
252      if (!(c64_keyline[0] & 0x20)) t &= ~0x01;
253      value &= t;
254   }
255
256   if (!(output_b & 0x10))
257   {
258      UINT8 t = 0xff;
259      if (!(c64_keyline[7] & 0x10)) t &= ~0x80;
260      if (!(c64_keyline[6] & 0x10)) t &= ~0x40;
261      if (!(c64_keyline[5] & 0x10)) t &= ~0x20;
262      if (!(c64_keyline[4] & 0x10)) t &= ~0x10;
263      if (!(c64_keyline[3] & 0x10)) t &= ~0x08;
264      if (!(c64_keyline[2] & 0x10)) t &= ~0x04;
265      if (!(c64_keyline[1] & 0x10)) t &= ~0x02;
266      if (!(c64_keyline[0] & 0x10)) t &= ~0x01;
267      value &= t;
268   }
269
270   if (!(output_b & 0x08))
271   {
272      UINT8 t = 0xff;
273      if (!(c64_keyline[7] & 0x08)) t &= ~0x80;
274      if (!(c64_keyline[6] & 0x08)) t &= ~0x40;
275      if (!(c64_keyline[5] & 0x08)) t &= ~0x20;
276      if (!(c64_keyline[4] & 0x08)) t &= ~0x10;
277      if (!(c64_keyline[3] & 0x08)) t &= ~0x08;
278      if (!(c64_keyline[2] & 0x08)) t &= ~0x04;
279      if (!(c64_keyline[1] & 0x08)) t &= ~0x02;
280      if (!(c64_keyline[0] & 0x08)) t &= ~0x01;
281      value &= t;
282   }
283
284   if (!(output_b & 0x04))
285   {
286      UINT8 t = 0xff;
287      if (!(c64_keyline[7] & 0x04)) t &= ~0x80;
288      if (!(c64_keyline[6] & 0x04)) t &= ~0x40;
289      if (!(c64_keyline[5] & 0x04)) t &= ~0x20;
290      if (!(c64_keyline[4] & 0x04)) t &= ~0x10;
291      if (!(c64_keyline[3] & 0x04)) t &= ~0x08;
292      if (!(c64_keyline[2] & 0x04)) t &= ~0x04;
293      if (!(c64_keyline[1] & 0x04)) t &= ~0x02;
294      if (!(c64_keyline[0] & 0x04)) t &= ~0x01;
295      value &= t;
296   }
297
298   if (!(output_b & 0x02))
299   {
300      UINT8 t = 0xff;
301      if (!(c64_keyline[7] & 0x02)) t &= ~0x80;
302      if (!(c64_keyline[6] & 0x02)) t &= ~0x40;
303      if (!(c64_keyline[5] & 0x02)) t &= ~0x20;
304      if (!(c64_keyline[4] & 0x02)) t &= ~0x10;
305      if (!(c64_keyline[3] & 0x02)) t &= ~0x08;
306      if (!(c64_keyline[2] & 0x02)) t &= ~0x04;
307      if (!(c64_keyline[1] & 0x02)) t &= ~0x02;
308      if (!(c64_keyline[0] & 0x02)) t &= ~0x01;
309      value &= t;
310   }
311
312   if (!(output_b & 0x01))
313   {
314      UINT8 t = 0xff;
315      if (!(c64_keyline[7] & 0x01)) t &= ~0x80;
316      if (!(c64_keyline[6] & 0x01)) t &= ~0x40;
317      if (!(c64_keyline[5] & 0x01)) t &= ~0x20;
318      if (!(c64_keyline[4] & 0x01)) t &= ~0x10;
319      if (!(c64_keyline[3] & 0x01)) t &= ~0x08;
320      if (!(c64_keyline[2] & 0x01)) t &= ~0x04;
321      if (!(c64_keyline[1] & 0x01)) t &= ~0x02;
322      if (!(c64_keyline[0] & 0x01)) t &= ~0x01;
323      value &= t;
324   }
325
326   if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 )
327      value &= c64_keyline[8];
328   else
329      value &= c64_keyline[9];
330
331   return value;
332}
333
334UINT8 cbm_common_cia0_port_b_r( device_t *device, UINT8 output_a )
335{
336   UINT8 value = 0xff;
337
338   if (!(output_a & 0x80)) value &= c64_keyline[7];
339   if (!(output_a & 0x40)) value &= c64_keyline[6];
340   if (!(output_a & 0x20)) value &= c64_keyline[5];
341   if (!(output_a & 0x10)) value &= c64_keyline[4];
342   if (!(output_a & 0x08)) value &= c64_keyline[3];
343   if (!(output_a & 0x04)) value &= c64_keyline[2];
344   if (!(output_a & 0x02)) value &= c64_keyline[1];
345   if (!(output_a & 0x01)) value &= c64_keyline[0];
346
347   if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 )
348      value &= c64_keyline[9];
349   else
350      value &= c64_keyline[8];
351
352   return value;
353}
354
355
356/***********************************************
357
358    CBM Cartridges
359
360***********************************************/
361
362
363/*  All the cartridge specific code has been moved
364    to machine/ drivers. Once more informations
365    surface about the cart expansions for systems
366    in c65.c, c128.c, cbmb.c and pet.c, the shared
367    code could be refactored to have here the
368    common functions                                */
369
370
371
372/***********************************************
373
374    CBM Datasette Tapes
375
376***********************************************/
377
378#if 0
379const cassette_interface cbm_cassette_interface =
380{
381   cbm_cassette_formats,
382   NULL,
383   (cassette_state) (CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED),
384   NULL
385};
386#endif
387
388
389/*UINT8 *c65_basic; */
390/*UINT8 *c65_kernal; */
391/*UINT8 *c65_dos; */
392/*UINT8 *c65_monitor; */
393/*UINT8 *c65_graphics; */
394
395
396void c65_state::c65_nmi(  )
397{
398   if (m_nmilevel != (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq)   /* KEY_RESTORE */
399   {
400      m_maincpu->set_input_line(INPUT_LINE_NMI, (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq);
401
402      m_nmilevel = (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq;
403   }
404}
405
406
407/***********************************************
408
409    CIA Interfaces
410
411***********************************************/
412
413/*
414 *  CIA 0 - Port A keyboard line select
415 *  CIA 0 - Port B keyboard line read
416 *
417 *  flag cassette read input, serial request in
418 *  irq to irq connected
419 *
420 *  see machine/cbm.c
421 */
422
423READ8_MEMBER(c65_state::c65_cia0_port_a_r)
424{
425   UINT8 cia0portb = m_cia0->pb_r(space, 0);
426
427   return cbm_common_cia0_port_a_r(m_cia0, cia0portb);
428}
429
430READ8_MEMBER(c65_state::c65_cia0_port_b_r)
431{
432   UINT8 value = 0xff;
433   UINT8 cia0porta = m_cia0->pa_r(space, 0);
434
435   value &= cbm_common_cia0_port_b_r(m_cia0, cia0porta);
436
437   if (!(m_6511_port & 0x02))
438      value &= m_keyline;
439
440   return value;
441}
442
443WRITE8_MEMBER(c65_state::c65_cia0_port_b_w)
444{
445//  was there lightpen support in c65 video chip?
446//  vic3_device *vic3 = machine().device<vic3_device>("vic3");
447//  vic3->lightpen_write(data & 0x10);
448}
449
450void c65_state::c65_irq( int level )
451{
452   if (level != m_old_level)
453   {
454      DBG_LOG(machine(), 3, "mos4510", ("irq %s\n", level ? "start" : "end"));
455      m_maincpu->set_input_line(M4510_IRQ_LINE, level);
456      m_old_level = level;
457   }
458}
459
460/* is this correct for c65 as well as c64? */
461WRITE_LINE_MEMBER(c65_state::c65_cia0_interrupt)
462{
463   m_cia0_irq = state;
464   c65_irq(state || m_vicirq);
465}
466
467/* is this correct for c65 as well as c64? */
468WRITE_LINE_MEMBER(c65_state::c65_vic_interrupt)
469{
470#if 1
471   if (state != m_vicirq)
472   {
473      c65_irq (state || m_cia0_irq);
474      m_vicirq = state;
475   }
476#endif
477}
478
479/*
480 * CIA 1 - Port A
481 * bit 7 serial bus data input
482 * bit 6 serial bus clock input
483 * bit 5 serial bus data output
484 * bit 4 serial bus clock output
485 * bit 3 serial bus atn output
486 * bit 2 rs232 data output
487 * bits 1-0 vic-chip system memory bank select
488 *
489 * CIA 1 - Port B
490 * bit 7 user rs232 data set ready
491 * bit 6 user rs232 clear to send
492 * bit 5 user
493 * bit 4 user rs232 carrier detect
494 * bit 3 user rs232 ring indicator
495 * bit 2 user rs232 data terminal ready
496 * bit 1 user rs232 request to send
497 * bit 0 user rs232 received data
498 *
499 * flag restore key or rs232 received data input
500 * irq to nmi connected ?
501 */
502READ8_MEMBER(c65_state::c65_cia1_port_a_r)
503{
504   UINT8 value = 0xff;
505
506   if (!m_iec->clk_r())
507      value &= ~0x40;
508
509   if (!m_iec->data_r())
510      value &= ~0x80;
511
512   return value;
513}
514
515WRITE8_MEMBER(c65_state::c65_cia1_port_a_w)
516{
517   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
518
519   m_iec->atn_w(!BIT(data, 3));
520   m_iec->clk_w(!BIT(data, 4));
521   m_iec->data_w(!BIT(data, 5));
522
523   m_vicaddr = m_memory + helper[data & 0x03];
524}
525
526WRITE_LINE_MEMBER(c65_state::c65_cia1_interrupt)
527{
528   m_cia1_irq = state;
529   c65_nmi();
530}
531
532/***********************************************
533
534    Memory Handlers
535
536***********************************************/
537
538/* processor has only 1 mega address space !? */
539/* and system 8 megabyte */
540/* dma controller and bankswitch hardware ?*/
541READ8_MEMBER( c65_state::c65_read_mem )
542{
543   UINT8 result;
544   if (offset <= 0x0ffff)
545      result = m_memory[offset];
546   else
547      result = space.read_byte(offset);
548   return result;
549}
550
551WRITE8_MEMBER( c65_state::c65_write_mem )
552{
553   if (offset <= 0x0ffff)
554      m_memory[offset] = data;
555   else
556      space.write_byte(offset, data);
557}
558
559/* dma chip at 0xd700
560  used:
561   writing banknumber to offset 2
562   writing hibyte to offset 1
563   writing lobyte to offset 0
564    cpu holded, dma transfer(data at address) executed, cpu activated
565
566  command data:
567   0 command (0 copy, 3 fill)
568   1,2 length
569   3,4,5 source
570   6,7,8 dest
571   9 subcommand
572   10 mod
573
574   version 1:
575   seldom copy (overlapping) from 0x402002 to 0x402008
576   (making place for new line in basic area)
577   for whats this bit 0x400000, or is this really the address?
578   maybe means add counter to address for access,
579   so allowing up or down copies, and reordering copies
580
581   version 2:
582   cmd 0x30 used for this
583*/
584void c65_state::c65_dma_port_w( int offset, int value )
585{
586   PAIR pair, src, dst, len;
587   UINT8 cmd, fill;
588   int i;
589   address_space &space = m_maincpu->space(AS_PROGRAM);
590
591   switch (offset & 3)
592   {
593   case 2:
594   case 1:
595      m_dma.data[offset & 3] = value;
596      break;
597   case 0:
598      pair.b.h3 = 0;
599      pair.b.h2 = m_dma.data[2];
600      pair.b.h = m_dma.data[1];
601      pair.b.l = m_dma.data[0]=value;
602      cmd = c65_read_mem(space, pair.d++);
603      len.w.h = 0;
604      len.b.l = c65_read_mem(space, pair.d++);
605      len.b.h = c65_read_mem(space, pair.d++);
606      src.b.h3 = 0;
607      fill = src.b.l = c65_read_mem(space, pair.d++);
608      src.b.h = c65_read_mem(space, pair.d++);
609      src.b.h2 = c65_read_mem(space, pair.d++);
610      dst.b.h3 = 0;
611      dst.b.l = c65_read_mem(space, pair.d++);
612      dst.b.h = c65_read_mem(space, pair.d++);
613      dst.b.h2 = c65_read_mem(space, pair.d++);
614
615      switch (cmd)
616      {
617      case 0:
618         if (src.d == 0x3ffff) m_dump_dma = 1;
619         if (m_dump_dma)
620            DBG_LOG(space.machine(), 1,"dma copy job",
621                  ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n",
622                     len.w.l, src.d, dst.d, c65_read_mem(space, pair.d),
623                     c65_read_mem(space, pair.d + 1) ) );
624         if ((m_dma.version == 1)
625               && ( (src.d&0x400000) || (dst.d & 0x400000)))
626         {
627            if (!(src.d & 0x400000))
628            {
629               dst.d &= ~0x400000;
630               for (i = 0; i < len.w.l; i++)
631                  c65_write_mem(space, dst.d--, c65_read_mem(space, src.d++));
632            }
633            else if (!(dst.d & 0x400000))
634            {
635               src.d &= ~0x400000;
636               for (i = 0; i < len.w.l; i++)
637                  c65_write_mem(space, dst.d++, c65_read_mem(space, src.d--));
638            }
639            else
640            {
641               src.d &= ~0x400000;
642               dst.d &= ~0x400000;
643               for (i = 0; i < len.w.l; i++)
644                  c65_write_mem(space, --dst.d, c65_read_mem(space, --src.d));
645            }
646         }
647         else
648         {
649            for (i = 0; i < len.w.l; i++)
650               c65_write_mem(space, dst.d++, c65_read_mem(space, src.d++));
651         }
652         break;
653      case 3:
654         DBG_LOG(space.machine(), 3,"dma fill job",
655               ("len:%.4x value:%.2x dst:%.6x sub:%.2x modrm:%.2x\n",
656                  len.w.l, fill, dst.d, c65_read_mem(space, pair.d),
657                  c65_read_mem(space, pair.d + 1)));
658            for (i = 0; i < len.w.l; i++)
659               c65_write_mem(space, dst.d++, fill);
660            break;
661      case 0x30:
662         DBG_LOG(space.machine(), 1,"dma copy down",
663               ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n",
664                  len.w.l, src.d, dst.d, c65_read_mem(space, pair.d),
665                  c65_read_mem(space, pair.d + 1) ) );
666         for (i = 0; i < len.w.l; i++)
667            c65_write_mem(space, dst.d--,c65_read_mem(space, src.d--));
668         break;
669      default:
670         DBG_LOG(space.machine(), 1,"dma job",
671               ("cmd:%.2x len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n",
672                  cmd,len.w.l, src.d, dst.d, c65_read_mem(space, pair.d),
673                  c65_read_mem(space, pair.d + 1)));
674      }
675      break;
676   default:
677      DBG_LOG(space.machine(), 1, "dma chip write", ("%.3x %.2x\n", offset, value));
678      break;
679   }
680}
681
682int c65_state::c65_dma_port_r( int offset )
683{
684   /* offset 3 bit 7 in progress ? */
685   DBG_LOG(machine(), 2, "dma chip read", ("%.3x\n", offset));
686   return 0x7f;
687}
688
689void c65_state::c65_6511_port_w( int offset, int value )
690{
691   if (offset == 7)
692   {
693      m_6511_port = value;
694   }
695   DBG_LOG(machine(), 2, "r6511 write", ("%.2x %.2x\n", offset, value));
696}
697
698int c65_state::c65_6511_port_r( int offset )
699{
700   int data = 0xff;
701
702   if (offset == 7)
703   {
704      if (ioport("SPECIAL")->read() & 0x20)
705         data &= ~1;
706   }
707   DBG_LOG(machine(), 2, "r6511 read", ("%.2x\n", offset));
708
709   return data;
710}
711
712/* one docu states custom 4191 disk controller
713 (for 2 1MB MFM disk drives, 1 internal, the other extern (optional) 1565
714 with integrated 512 byte buffer
715
716 0->0 reset ?
717
718 0->1, 0->0, wait until 2 positiv, 1->0 ???
719
720 0->0, 0 not 0 means no drive ???, other system entries
721
722
723 reg 0 write/read
724  0,1 written
725  bit 1 set
726  bit 2 set
727  bit 3 set
728  bit 4 set
729
730
731 reg 0 read
732  bit 0
733  bit 1
734  bit 2
735  0..2 ->$1d4
736
737 reg 1 write
738  $01 written
739  $18 written
740  $46 written
741  $80 written
742  $a1 written
743  $01 written, dec
744  $10 written
745
746 reg 2 read/write?(lsr)
747  bit 2
748  bit 4
749  bit 5 busy waiting until zero, then reading reg 7
750  bit 6 operation not activ flag!? or set overflow pin used
751  bit 7 busy flag?
752
753 reg 3 read/write?(rcr)
754  bit 1
755  bit 3
756  bit 7 busy flag?
757
758 reg 4
759  track??
760  0 written
761  read -> $1d2
762  cmp #$50
763  bcs
764
765
766 reg 5
767  sector ??
768  1 written
769  read -> $1d3
770  cmp #$b bcc
771
772
773 reg 6
774  head ??
775  0 written
776  read -> $1d1
777  cmp #2 bcc
778
779 reg 7 read
780  #4e written
781  12 times 0, a1 a1 a1 fe  written
782
783 reg 8 read
784  #ff written
785  16 times #ff written
786
787 reg 9
788  #60 written
789
790might use the set overflow input
791
792$21a6c 9a6c format
793$21c97 9c97 write operation
794$21ca0 9ca0 get byte?
795$21cab 9cab read reg 7
796$21caf 9caf write reg 7
797$21cb3
798*/
799
800#define FDC_LOST 4
801#define FDC_CRC 8
802#define FDC_RNF 0x10
803#define FDC_BUSY 0x80
804#define FDC_IRQ 0x200
805
806#define FDC_CMD_MOTOR_SPIN_UP 0x10
807
808#if 0
809void c65_state::c65_fdc_state(void)
810{
811   switch (m_fdc.state)
812   {
813   case FDC_CMD_MOTOR_SPIN_UP:
814      if (machine().time() - m_fdc.time)
815      {
816         m_fdc.state = 0;
817         m_fdc.status &= ~FDC_BUSY;
818      }
819      break;
820   }
821}
822#endif
823
824void c65_state::c65_fdc_w( int offset, int data )
825{
826   DBG_LOG(machine(), 1, "fdc write", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data));
827   switch (offset & 0xf)
828   {
829   case 0:
830      m_fdc.reg[0] = data;
831      break;
832   case 1:
833      m_fdc.reg[1] = data;
834      switch (data & 0xf9)
835      {
836      case 0x20: // wait for motor spin up
837         m_fdc.status &= ~(FDC_IRQ|FDC_LOST|FDC_CRC|FDC_RNF);
838         m_fdc.status |= FDC_BUSY;
839         m_fdc.time = machine().time();
840         m_fdc.state = FDC_CMD_MOTOR_SPIN_UP;
841         break;
842      case 0: // cancel
843         m_fdc.status &= ~(FDC_BUSY);
844         m_fdc.state = 0;
845         break;
846      case 0x80: // buffered write
847      case 0x40: // buffered read
848      case 0x81: // unbuffered write
849      case 0x41: // unbuffered read
850      case 0x30:case 0x31: // step
851         break;
852      }
853      break;
854   case 2: case 3: // read only
855      break;
856   case 4:
857      m_fdc.reg[offset & 0xf] = data;
858      m_fdc.track = data;
859      break;
860   case 5:
861      m_fdc.reg[offset & 0xf] = data;
862      m_fdc.sector = data;
863      break;
864   case 6:
865      m_fdc.reg[offset & 0xf] = data;
866      m_fdc.head = data;
867      break;
868   case 7:
869      m_fdc.buffer[m_fdc.cpu_pos++] = data;
870      break;
871   default:
872      m_fdc.reg[offset & 0xf] = data;
873      break;
874   }
875}
876
877int c65_state::c65_fdc_r( int offset )
878{
879   UINT8 data = 0;
880   switch (offset & 0xf)
881   {
882   case 0:
883      data = m_fdc.reg[0];
884      break;
885   case 1:
886      data = m_fdc.reg[1];
887      break;
888   case 2:
889      data = m_fdc.status;
890      break;
891   case 3:
892      data = m_fdc.status >> 8;
893      break;
894   case 4:
895      data = m_fdc.track;
896      break;
897   case 5:
898      data = m_fdc.sector;
899      break;
900   case 6:
901      data = m_fdc.head;
902      break;
903   case 7:
904      data = m_fdc.buffer[m_fdc.cpu_pos++];
905      break;
906   default:
907      data = m_fdc.reg[offset & 0xf];
908      break;
909   }
910   DBG_LOG(machine(), 1, "fdc read", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data));
911   return data;
912}
913
914/* version 1 ramcheck
915   write 0:0
916   read write read write 80000,90000,f0000
917   write 0:8
918   read write read write 80000,90000,f0000
919
920   version 2 ramcheck???
921   read 0:
922   write 0:0
923   read 0:
924   first read and second read bit 0x80 set --> nothing
925   write 0:0
926   read 0
927   write 0:ff
928*/
929
930READ8_MEMBER( c65_state::c65_ram_expansion_r )
931{
932   UINT8 data = 0xff;
933   if (m_ram->size() > (128 * 1024))
934      data = m_expansion_ram.reg;
935   return data;
936}
937
938WRITE8_MEMBER( c65_state::c65_ram_expansion_w )
939{
940   offs_t expansion_ram_begin;
941   offs_t expansion_ram_end;
942
943   if (m_ram->size() > (128 * 1024))
944   {
945      m_expansion_ram.reg = data;
946
947      expansion_ram_begin = 0x80000;
948      expansion_ram_end = 0x80000 + (m_ram->size() - 128*1024) - 1;
949
950      if (data == 0x00) {
951         space.install_readwrite_bank(expansion_ram_begin, expansion_ram_end,"bank16");
952         membank("bank16")->set_base(m_ram->pointer() + 128*1024);
953      } else {
954         space.nop_readwrite(expansion_ram_begin, expansion_ram_end);
955      }
956   }
957}
958
959WRITE8_MEMBER( c65_state::c65_write_io )
960{
961   mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r");
962   mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l");
963   vic3_device *vic3 = machine().device<vic3_device>("vic3");
964
965   switch (offset & 0xf00)
966   {
967   case 0x000:
968      if (offset < 0x80)
969         vic3->port_w(space, offset & 0x7f, data);
970      else if (offset < 0xa0)
971         c65_fdc_w(offset & 0x1f, data);
972      else
973      {
974         c65_ram_expansion_w(space, offset & 0x1f, data, mem_mask);
975         /*ram expansion crtl optional */
976      }
977      break;
978   case 0x100:
979   case 0x200:
980   case 0x300:
981      vic3->palette_w(space, offset - 0x100, data);
982      break;
983   case 0x400:
984      if (offset<0x420) /* maybe 0x20 */
985         sid_0->write(space, offset & 0x3f, data);
986      else if (offset<0x440)
987         sid_1->write(space, offset & 0x3f, data);
988      else
989         DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data));
990      break;
991   case 0x500:
992      DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data));
993      break;
994   case 0x600:
995      c65_6511_port_w(offset & 0xff,data);
996      break;
997   case 0x700:
998      c65_dma_port_w(offset & 0xff, data);
999      break;
1000   }
1001}
1002
1003WRITE8_MEMBER( c65_state::c65_write_io_dc00 )
1004{
1005   switch (offset & 0xf00)
1006   {
1007   case 0x000:
1008      m_cia0->write(space, offset, data);
1009      break;
1010   case 0x100:
1011      m_cia1->write(space, offset, data);
1012      break;
1013   case 0x200:
1014   case 0x300:
1015      DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset+0xc00, data));
1016      break;
1017   }
1018}
1019
1020READ8_MEMBER( c65_state::c65_read_io )
1021{
1022   mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r");
1023   mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l");
1024   vic3_device *vic3 = machine().device<vic3_device>("vic3");
1025
1026   switch (offset & 0xf00)
1027   {
1028   case 0x000:
1029      if (offset < 0x80)
1030         return vic3->port_r(space, offset & 0x7f);
1031      if (offset < 0xa0)
1032         return c65_fdc_r(offset & 0x1f);
1033      else
1034      {
1035         return c65_ram_expansion_r(space, offset & 0x1f, mem_mask);
1036         /*return; ram expansion crtl optional */
1037      }
1038   case 0x100:
1039   case 0x200:
1040   case 0x300:
1041   /* read only !? */
1042      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset));
1043      break;
1044   case 0x400:
1045      if (offset < 0x420)
1046         return sid_0->read(space, offset & 0x3f);
1047      if (offset < 0x440)
1048         return sid_1->read(space, offset & 0x3f);
1049      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset));
1050      break;
1051   case 0x500:
1052      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset));
1053      break;
1054   case 0x600:
1055      return c65_6511_port_r(offset&0xff);
1056   case 0x700:
1057      return c65_dma_port_r(offset&0xff);
1058   }
1059   return 0xff;
1060}
1061
1062READ8_MEMBER( c65_state::c65_read_io_dc00 )
1063{
1064   switch (offset & 0x300)
1065   {
1066   case 0x000:
1067      return m_cia0->read(space, offset);
1068   case 0x100:
1069      return m_cia1->read(space, offset);
1070   case 0x200:
1071   case 0x300:
1072      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset+0xc00));
1073      break;
1074   }
1075   return 0xff;
1076}
1077
1078
1079/*
1080d02f:
1081 init a5 96 written (seems to be switch to c65 or vic3 mode)
1082 go64 0 written
1083*/
1084
1085/* bit 1 external sync enable (genlock)
1086   bit 2 palette enable
1087   bit 6 vic3 c65 character set */
1088WRITE8_MEMBER(c65_state::c65_bankswitch_interface)
1089{
1090   DBG_LOG(machine(), 2, "c65 bankswitch", ("%.2x\n",data));
1091
1092   if (m_io_on)
1093   {
1094      if (data & 1)
1095      {
1096         membank("bank8")->set_base(m_colorram + 0x400);
1097         membank("bank9")->set_base(m_colorram + 0x400);
1098         m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8");
1099         m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9");
1100      }
1101      else
1102      {
1103         m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this));
1104         m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this));
1105      }
1106   }
1107
1108   m_io_dc00_on = !(data & 1);
1109#if 0
1110   /* cartridge roms !?*/
1111   if (data & 0x08)
1112      membank("bank1")->set_base(m_roml);
1113   else
1114      membank("bank1")->set_base(m_memory + 0x8000);
1115
1116   if (data & 0x10)
1117      membank("bank2")->set_base(m_basic);
1118   else
1119      membank("bank2")->set_base(m_memory + 0xa000);
1120#endif
1121   if ((m_old_value^data) & 0x20)
1122   {
1123   /* bankswitching faulty when doing actual page */
1124      if (data & 0x20)
1125         membank("bank3")->set_base(m_basic);
1126      else
1127         membank("bank3")->set_base(m_memory + 0xc000);
1128   }
1129   m_charset_select = data & 0x40;
1130#if 0
1131   /* cartridge roms !?*/
1132   if (data & 0x80)
1133      membank("bank8")->set_base(m_kernal);
1134   else
1135      membank("bank6")->set_base(m_memory + 0xe000);
1136#endif
1137   m_old_value = data;
1138}
1139
1140void c65_state::c65_bankswitch(  )
1141{
1142   int data, loram, hiram, charen;
1143
1144   data = 0x00; // machine().device<m4510_device>("maincpu")->get_port();
1145   if (data == m_old_data)
1146      return;
1147
1148   DBG_LOG(machine(), 1, "bankswitch", ("%d\n", data & 7));
1149   loram = (data & 1) ? 1 : 0;
1150   hiram = (data & 2) ? 1 : 0;
1151   charen = (data & 4) ? 1 : 0;
1152
1153   if ((!m_game && m_exrom) || (loram && hiram && !m_exrom))
1154      membank("bank1")->set_base(m_roml);
1155   else
1156      membank("bank1")->set_base(m_memory + 0x8000);
1157
1158   if ((!m_game && m_exrom && hiram) || (!m_exrom))
1159      membank("bank2")->set_base(m_romh);
1160   else if (loram && hiram)
1161      membank("bank2")->set_base(m_basic);
1162   else
1163      membank("bank2")->set_base(m_memory + 0xa000);
1164
1165   if ((!m_game && m_exrom) || (charen && (loram || hiram)))
1166   {
1167      m_io_on = 1;
1168      membank("bank6")->set_base(m_colorram);
1169      membank("bank7")->set_base(m_colorram);
1170
1171      if (m_io_dc00_on)
1172      {
1173         m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this));
1174         m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this));
1175      }
1176      else
1177      {
1178         m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8");
1179         m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9");
1180         membank("bank8")->set_base(m_colorram + 0x400);
1181         membank("bank9")->set_base(m_colorram + 0x400);
1182      }
1183      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0d000, 0x0d7ff, read8_delegate(FUNC(c65_state::c65_read_io),this));
1184      m_maincpu->space(AS_PROGRAM).install_write_handler(0x0d000, 0x0d7ff, write8_delegate(FUNC(c65_state::c65_write_io),this));
1185   }
1186   else
1187   {
1188      m_io_on = 0;
1189      membank("bank5")->set_base(m_memory + 0xd000);
1190      membank("bank7")->set_base(m_memory + 0xd800);
1191      membank("bank9")->set_base(m_memory + 0xdc00);
1192      if (!charen && (loram || hiram))
1193      {
1194         membank("bank4")->set_base(m_chargen);
1195         membank("bank6")->set_base(m_chargen + 0x800);
1196         membank("bank8")->set_base(m_chargen + 0xc00);
1197      }
1198      else
1199      {
1200         membank("bank4")->set_base(m_memory + 0xd000);
1201         membank("bank6")->set_base(m_memory + 0xd800);
1202         membank("bank8")->set_base(m_memory + 0xdc00);
1203      }
1204      m_maincpu->space(AS_PROGRAM).install_read_bank(0x0d000, 0x0d7ff, "bank4");
1205      m_maincpu->space(AS_PROGRAM).install_write_bank(0x0d000, 0x0d7ff, "bank5");
1206   }
1207
1208   if (!m_game && m_exrom)
1209   {
1210      membank("bank10")->set_base(m_romh);
1211   }
1212   else
1213   {
1214      if (hiram)
1215      {
1216         membank("bank10")->set_base(m_kernal);
1217      }
1218      else
1219      {
1220         membank("bank10")->set_base(m_memory + 0xe000);
1221      }
1222   }
1223   m_old_data = data;
1224}
1225
1226#ifdef UNUSED_FUNCTION
1227void c65_state::c65_colorram_write( int offset, int value )
1228{
1229   m_colorram[offset & 0x7ff] = value | 0xf0;
1230}
1231#endif
1232
1233/*
1234 * only 14 address lines
1235 * a15 and a14 portlines
1236 * 0x1000-0x1fff, 0x9000-0x9fff char rom
1237 */
1238READ8_MEMBER(c65_state::c65_dma_read)
1239{
1240   if (!m_game && m_exrom)
1241   {
1242      if (offset < 0x3000)
1243         return m_memory[offset];
1244      return m_romh[offset & 0x1fff];
1245   }
1246   if ((m_vicaddr == m_memory) || (m_vicaddr == m_memory + 0x8000))
1247   {
1248      if (offset < 0x1000)
1249         return m_vicaddr[offset & 0x3fff];
1250      if (offset < 0x2000) {
1251         if (m_charset_select)
1252            return m_chargen[offset & 0xfff];
1253         else
1254            return m_chargen[offset & 0xfff];
1255      }
1256      return m_vicaddr[offset & 0x3fff];
1257   }
1258   return m_vicaddr[offset & 0x3fff];
1259}
1260
1261READ8_MEMBER(c65_state::c65_dma_read_color)
1262{
1263   if (m_c64mode)
1264      return m_colorram[offset & 0x3ff] & 0xf;
1265   return m_colorram[offset & 0x7ff];
1266}
1267
1268void c65_state::c65_common_driver_init(  )
1269{
1270   m_memory = auto_alloc_array_clear(machine(), UINT8, 0x10000);
1271   membank("bank11")->set_base(m_memory + 0x00000);
1272   membank("bank12")->set_base(m_memory + 0x08000);
1273   membank("bank13")->set_base(m_memory + 0x0a000);
1274   membank("bank14")->set_base(m_memory + 0x0c000);
1275   membank("bank15")->set_base(m_memory + 0x0e000);
1276
1277   cbm_common_init();
1278   m_keyline = 0xff;
1279
1280   m_pal = 0;
1281   m_charset_select = 0;
1282   m_6511_port = 0xff;
1283   m_vicirq = 0;
1284   m_old_data = -1;
1285
1286   /* C65 had no datasette port */
1287   m_tape_on = 0;
1288   m_game = 1;
1289   m_exrom = 1;
1290
1291   /*memset(m_memory + 0x40000, 0, 0x800000 - 0x40000); */
1292}
1293
1294DRIVER_INIT_MEMBER(c65_state,c65)
1295{
1296   m_dma.version = 2;
1297   c65_common_driver_init();
1298}
1299
1300DRIVER_INIT_MEMBER(c65_state,c65pal)
1301{
1302   m_dma.version = 1;
1303   c65_common_driver_init();
1304   m_pal = 1;
1305}
1306
1307MACHINE_START_MEMBER(c65_state,c65)
1308{
1309   /* clear upper memory */
1310   memset(m_ram->pointer() + 128*1024, 0xff, m_ram->size() -  128*1024);
1311
1312//removed   cbm_drive_0_config (SERIAL, 10);
1313//removed   cbm_drive_1_config (SERIAL, 11);
1314   m_vicaddr = m_memory;
1315
1316   m_c64mode = 0;
1317
1318   c65_bankswitch_interface(m_maincpu->space(AS_PROGRAM),0,0xff);
1319   c65_bankswitch();
1320}
1321
1322
1323INTERRUPT_GEN_MEMBER(c65_state::c65_frame_interrupt)
1324{
1325   int value;
1326
1327   c65_nmi();
1328
1329   /* common keys input ports */
1330   cbm_common_interrupt(&device);
1331
1332   /* c65 specific: function keys input ports */
1333   value = 0xff;
1334
1335   value &= ~ioport("FUNCT")->read();
1336   m_keyline = value;
1337}
trunk/src/mess/machine/c65_old.c
r243230r243231
1/***************************************************************************
2    commodore c65 home computer
3    peter.trauner@jk.uni-linz.ac.at
4    documention
5     www.funet.fi
6 ***************************************************************************/
7
8#include "emu.h"
9
10#include "includes/c65.h"
11#include "cpu/m6502/m4510.h"
12#include "sound/mos6581.h"
13#include "machine/mos6526.h"
14#include "bus/cbmiec/cbmiec.h"
15#include "machine/ram.h"
16#include "video/vic4567.h"
17#include "imagedev/cassette.h"
18#include "crsshair.h"
19#include "formats/cbm_tap.h"
20
21#define VERBOSE_LEVEL 0
22#define DBG_LOG( MACHINE, N, M, A ) \
23   do { \
24      if(VERBOSE_LEVEL >= N) \
25      { \
26         if( M ) \
27            logerror("%11.6f: %-24s", MACHINE.time().as_double(), (char*) M ); \
28         logerror A; \
29      } \
30   } while (0)
31
32
33
34/***********************************************
35
36    Input Reading - Common Components
37
38***********************************************/
39
40/* These are needed by c64, c65 and c128, each machine has also additional specific
41components in its INTERRUPT_GEN */
42
43/* keyboard lines */
44UINT8 c64_keyline[10];
45
46void cbm_common_init(void)
47{
48   int i;
49
50   for (i = 0; i < ARRAY_LENGTH(c64_keyline); i++)
51      c64_keyline[i] = 0xff;
52}
53
54static TIMER_CALLBACK( lightpen_tick )
55{
56   if (((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x04) || ((machine.root_device().ioport("CTRLSEL")->read() & 0x07) == 0x06))
57   {
58      /* enable lightpen crosshair */
59      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
60   }
61   else
62   {
63      /* disable lightpen crosshair */
64      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
65   }
66}
67
68void cbm_common_interrupt( device_t *device )
69{
70   int value, i;
71   int controller1 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x07;
72   int controller2 = device->machine().root_device().ioport("CTRLSEL")->read() & 0x70;
73   static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" };
74
75   /* Lines 0-7 : common keyboard */
76   for (i = 0; i < 8; i++)
77   {
78      value = 0xff;
79      value &= ~device->machine().root_device().ioport(c64ports[i])->read();
80
81      /* Shift Lock is mapped on Left Shift */
82      if ((i == 1) && (device->machine().root_device().ioport("SPECIAL")->read() & 0x40))
83         value &= ~0x80;
84
85      c64_keyline[i] = value;
86   }
87
88
89   value = 0xff;
90   switch(controller1)
91   {
92      case 0x00:
93         value &= ~device->machine().root_device().ioport("JOY1_1B")->read();            /* Joy1 Directions + Button 1 */
94         break;
95
96      case 0x01:
97         if (device->machine().root_device().ioport("OTHER")->read() & 0x40)         /* Paddle2 Button */
98            value &= ~0x08;
99         if (device->machine().root_device().ioport("OTHER")->read() & 0x80)         /* Paddle1 Button */
100            value &= ~0x04;
101         break;
102
103      case 0x02:
104         if (device->machine().root_device().ioport("OTHER")->read() & 0x02)         /* Mouse Button Left */
105            value &= ~0x10;
106         if (device->machine().root_device().ioport("OTHER")->read() & 0x01)         /* Mouse Button Right */
107            value &= ~0x01;
108         break;
109
110      case 0x03:
111         value &= ~(device->machine().root_device().ioport("JOY1_2B")->read() & 0x1f);   /* Joy1 Directions + Button 1 */
112         break;
113
114      case 0x04:
115/* was there any input on the lightpen? where is it mapped? */
116//          if (device->machine().root_device().ioport("OTHER")->read() & 0x04)           /* Lightpen Signal */
117//              value &= ?? ;
118         break;
119
120      case 0x07:
121         break;
122
123      default:
124         logerror("Invalid Controller 1 Setting %d\n", controller1);
125         break;
126   }
127
128   c64_keyline[8] = value;
129
130
131   value = 0xff;
132   switch(controller2)
133   {
134      case 0x00:
135         value &= ~device->machine().root_device().ioport("JOY2_1B")->read();            /* Joy2 Directions + Button 1 */
136         break;
137
138      case 0x10:
139         if (device->machine().root_device().ioport("OTHER")->read() & 0x10)         /* Paddle4 Button */
140            value &= ~0x08;
141         if (device->machine().root_device().ioport("OTHER")->read() & 0x20)         /* Paddle3 Button */
142            value &= ~0x04;
143         break;
144
145      case 0x20:
146         if (device->machine().root_device().ioport("OTHER")->read() & 0x02)         /* Mouse Button Left */
147            value &= ~0x10;
148         if (device->machine().root_device().ioport("OTHER")->read() & 0x01)         /* Mouse Button Right */
149            value &= ~0x01;
150         break;
151
152      case 0x30:
153         value &= ~(device->machine().root_device().ioport("JOY2_2B")->read() & 0x1f);   /* Joy2 Directions + Button 1 */
154         break;
155
156      case 0x40:
157/* was there any input on the lightpen? where is it mapped? */
158//          if (device->machine().root_device().ioport("OTHER")->read() & 0x04)           /* Lightpen Signal */
159//              value &= ?? ;
160         break;
161
162      case 0x70:
163         break;
164
165      default:
166         logerror("Invalid Controller 2 Setting %d\n", controller2);
167         break;
168   }
169
170   c64_keyline[9] = value;
171
172//  vic2_frame_interrupt does nothing so this is not necessary
173//  vic2_frame_interrupt (device);
174
175   /* check if lightpen has been chosen as input: if so, enable crosshair */
176   device->machine().scheduler().timer_set(attotime::zero, FUNC(lightpen_tick));
177
178   set_led_status (device->machine(), 1, device->machine().root_device().ioport("SPECIAL")->read() & 0x40 ? 1 : 0);        /* Shift Lock */
179   set_led_status (device->machine(), 0, device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 ? 1 : 0);        /* Joystick Swap */
180}
181
182
183/***********************************************
184
185    CIA Common Handlers
186
187***********************************************/
188
189/* These are shared by c64, c65 and c128. c65 and c128 also have additional specific
190components (to select/read additional keyboard lines) */
191
192/*
193 *  CIA 0 - Port A
194 * bits 7-0 keyboard line select
195 * bits 7,6: paddle select( 01 port a, 10 port b)
196 * bit 4: joystick a fire button
197 * bits 3,2: Paddles port a fire button
198 * bits 3-0: joystick a direction
199 *
200 *  CIA 0 - Port B
201 * bits 7-0: keyboard raw values
202 * bit 4: joystick b fire button, lightpen select
203 * bits 3,2: paddle b fire buttons (left,right)
204 * bits 3-0: joystick b direction
205 *
206 * flag cassette read input, serial request in
207 * irq to irq connected
208 */
209
210UINT8 cbm_common_cia0_port_a_r( device_t *device, UINT8 output_b )
211{
212   UINT8 value = 0xff;
213
214   if (!(output_b & 0x80))
215   {
216      UINT8 t = 0xff;
217      if (!(c64_keyline[7] & 0x80)) t &= ~0x80;
218      if (!(c64_keyline[6] & 0x80)) t &= ~0x40;
219      if (!(c64_keyline[5] & 0x80)) t &= ~0x20;
220      if (!(c64_keyline[4] & 0x80)) t &= ~0x10;
221      if (!(c64_keyline[3] & 0x80)) t &= ~0x08;
222      if (!(c64_keyline[2] & 0x80)) t &= ~0x04;
223      if (!(c64_keyline[1] & 0x80)) t &= ~0x02;
224      if (!(c64_keyline[0] & 0x80)) t &= ~0x01;
225      value &= t;
226   }
227
228   if (!(output_b & 0x40))
229   {
230      UINT8 t = 0xff;
231      if (!(c64_keyline[7] & 0x40)) t &= ~0x80;
232      if (!(c64_keyline[6] & 0x40)) t &= ~0x40;
233      if (!(c64_keyline[5] & 0x40)) t &= ~0x20;
234      if (!(c64_keyline[4] & 0x40)) t &= ~0x10;
235      if (!(c64_keyline[3] & 0x40)) t &= ~0x08;
236      if (!(c64_keyline[2] & 0x40)) t &= ~0x04;
237      if (!(c64_keyline[1] & 0x40)) t &= ~0x02;
238      if (!(c64_keyline[0] & 0x40)) t &= ~0x01;
239      value &= t;
240   }
241
242   if (!(output_b & 0x20))
243   {
244      UINT8 t = 0xff;
245      if (!(c64_keyline[7] & 0x20)) t &= ~0x80;
246      if (!(c64_keyline[6] & 0x20)) t &= ~0x40;
247      if (!(c64_keyline[5] & 0x20)) t &= ~0x20;
248      if (!(c64_keyline[4] & 0x20)) t &= ~0x10;
249      if (!(c64_keyline[3] & 0x20)) t &= ~0x08;
250      if (!(c64_keyline[2] & 0x20)) t &= ~0x04;
251      if (!(c64_keyline[1] & 0x20)) t &= ~0x02;
252      if (!(c64_keyline[0] & 0x20)) t &= ~0x01;
253      value &= t;
254   }
255
256   if (!(output_b & 0x10))
257   {
258      UINT8 t = 0xff;
259      if (!(c64_keyline[7] & 0x10)) t &= ~0x80;
260      if (!(c64_keyline[6] & 0x10)) t &= ~0x40;
261      if (!(c64_keyline[5] & 0x10)) t &= ~0x20;
262      if (!(c64_keyline[4] & 0x10)) t &= ~0x10;
263      if (!(c64_keyline[3] & 0x10)) t &= ~0x08;
264      if (!(c64_keyline[2] & 0x10)) t &= ~0x04;
265      if (!(c64_keyline[1] & 0x10)) t &= ~0x02;
266      if (!(c64_keyline[0] & 0x10)) t &= ~0x01;
267      value &= t;
268   }
269
270   if (!(output_b & 0x08))
271   {
272      UINT8 t = 0xff;
273      if (!(c64_keyline[7] & 0x08)) t &= ~0x80;
274      if (!(c64_keyline[6] & 0x08)) t &= ~0x40;
275      if (!(c64_keyline[5] & 0x08)) t &= ~0x20;
276      if (!(c64_keyline[4] & 0x08)) t &= ~0x10;
277      if (!(c64_keyline[3] & 0x08)) t &= ~0x08;
278      if (!(c64_keyline[2] & 0x08)) t &= ~0x04;
279      if (!(c64_keyline[1] & 0x08)) t &= ~0x02;
280      if (!(c64_keyline[0] & 0x08)) t &= ~0x01;
281      value &= t;
282   }
283
284   if (!(output_b & 0x04))
285   {
286      UINT8 t = 0xff;
287      if (!(c64_keyline[7] & 0x04)) t &= ~0x80;
288      if (!(c64_keyline[6] & 0x04)) t &= ~0x40;
289      if (!(c64_keyline[5] & 0x04)) t &= ~0x20;
290      if (!(c64_keyline[4] & 0x04)) t &= ~0x10;
291      if (!(c64_keyline[3] & 0x04)) t &= ~0x08;
292      if (!(c64_keyline[2] & 0x04)) t &= ~0x04;
293      if (!(c64_keyline[1] & 0x04)) t &= ~0x02;
294      if (!(c64_keyline[0] & 0x04)) t &= ~0x01;
295      value &= t;
296   }
297
298   if (!(output_b & 0x02))
299   {
300      UINT8 t = 0xff;
301      if (!(c64_keyline[7] & 0x02)) t &= ~0x80;
302      if (!(c64_keyline[6] & 0x02)) t &= ~0x40;
303      if (!(c64_keyline[5] & 0x02)) t &= ~0x20;
304      if (!(c64_keyline[4] & 0x02)) t &= ~0x10;
305      if (!(c64_keyline[3] & 0x02)) t &= ~0x08;
306      if (!(c64_keyline[2] & 0x02)) t &= ~0x04;
307      if (!(c64_keyline[1] & 0x02)) t &= ~0x02;
308      if (!(c64_keyline[0] & 0x02)) t &= ~0x01;
309      value &= t;
310   }
311
312   if (!(output_b & 0x01))
313   {
314      UINT8 t = 0xff;
315      if (!(c64_keyline[7] & 0x01)) t &= ~0x80;
316      if (!(c64_keyline[6] & 0x01)) t &= ~0x40;
317      if (!(c64_keyline[5] & 0x01)) t &= ~0x20;
318      if (!(c64_keyline[4] & 0x01)) t &= ~0x10;
319      if (!(c64_keyline[3] & 0x01)) t &= ~0x08;
320      if (!(c64_keyline[2] & 0x01)) t &= ~0x04;
321      if (!(c64_keyline[1] & 0x01)) t &= ~0x02;
322      if (!(c64_keyline[0] & 0x01)) t &= ~0x01;
323      value &= t;
324   }
325
326   if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 )
327      value &= c64_keyline[8];
328   else
329      value &= c64_keyline[9];
330
331   return value;
332}
333
334UINT8 cbm_common_cia0_port_b_r( device_t *device, UINT8 output_a )
335{
336   UINT8 value = 0xff;
337
338   if (!(output_a & 0x80)) value &= c64_keyline[7];
339   if (!(output_a & 0x40)) value &= c64_keyline[6];
340   if (!(output_a & 0x20)) value &= c64_keyline[5];
341   if (!(output_a & 0x10)) value &= c64_keyline[4];
342   if (!(output_a & 0x08)) value &= c64_keyline[3];
343   if (!(output_a & 0x04)) value &= c64_keyline[2];
344   if (!(output_a & 0x02)) value &= c64_keyline[1];
345   if (!(output_a & 0x01)) value &= c64_keyline[0];
346
347   if ( device->machine().root_device().ioport("CTRLSEL")->read() & 0x80 )
348      value &= c64_keyline[9];
349   else
350      value &= c64_keyline[8];
351
352   return value;
353}
354
355
356/***********************************************
357
358    CBM Cartridges
359
360***********************************************/
361
362
363/*  All the cartridge specific code has been moved
364    to machine/ drivers. Once more informations
365    surface about the cart expansions for systems
366    in c65.c, c128.c, cbmb.c and pet.c, the shared
367    code could be refactored to have here the
368    common functions                                */
369
370
371
372/***********************************************
373
374    CBM Datasette Tapes
375
376***********************************************/
377
378#if 0
379const cassette_interface cbm_cassette_interface =
380{
381   cbm_cassette_formats,
382   NULL,
383   (cassette_state) (CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED),
384   NULL
385};
386#endif
387
388
389/*UINT8 *c65_basic; */
390/*UINT8 *c65_kernal; */
391/*UINT8 *c65_dos; */
392/*UINT8 *c65_monitor; */
393/*UINT8 *c65_graphics; */
394
395
396void c65_state::c65_nmi(  )
397{
398   if (m_nmilevel != (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq)   /* KEY_RESTORE */
399   {
400      m_maincpu->set_input_line(INPUT_LINE_NMI, (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq);
401
402      m_nmilevel = (ioport("SPECIAL")->read() & 0x80) || m_cia1_irq;
403   }
404}
405
406
407/***********************************************
408
409    CIA Interfaces
410
411***********************************************/
412
413/*
414 *  CIA 0 - Port A keyboard line select
415 *  CIA 0 - Port B keyboard line read
416 *
417 *  flag cassette read input, serial request in
418 *  irq to irq connected
419 *
420 *  see machine/cbm.c
421 */
422
423READ8_MEMBER(c65_state::c65_cia0_port_a_r)
424{
425   UINT8 cia0portb = m_cia0->pb_r(space, 0);
426
427   return cbm_common_cia0_port_a_r(m_cia0, cia0portb);
428}
429
430READ8_MEMBER(c65_state::c65_cia0_port_b_r)
431{
432   UINT8 value = 0xff;
433   UINT8 cia0porta = m_cia0->pa_r(space, 0);
434
435   value &= cbm_common_cia0_port_b_r(m_cia0, cia0porta);
436
437   if (!(m_6511_port & 0x02))
438      value &= m_keyline;
439
440   return value;
441}
442
443WRITE8_MEMBER(c65_state::c65_cia0_port_b_w)
444{
445//  was there lightpen support in c65 video chip?
446//  vic3_device *vic3 = machine().device<vic3_device>("vic3");
447//  vic3->lightpen_write(data & 0x10);
448}
449
450void c65_state::c65_irq( int level )
451{
452   if (level != m_old_level)
453   {
454      DBG_LOG(machine(), 3, "mos4510", ("irq %s\n", level ? "start" : "end"));
455      m_maincpu->set_input_line(M4510_IRQ_LINE, level);
456      m_old_level = level;
457   }
458}
459
460/* is this correct for c65 as well as c64? */
461WRITE_LINE_MEMBER(c65_state::c65_cia0_interrupt)
462{
463   m_cia0_irq = state;
464   c65_irq(state || m_vicirq);
465}
466
467/* is this correct for c65 as well as c64? */
468WRITE_LINE_MEMBER(c65_state::c65_vic_interrupt)
469{
470#if 1
471   if (state != m_vicirq)
472   {
473      c65_irq (state || m_cia0_irq);
474      m_vicirq = state;
475   }
476#endif
477}
478
479/*
480 * CIA 1 - Port A
481 * bit 7 serial bus data input
482 * bit 6 serial bus clock input
483 * bit 5 serial bus data output
484 * bit 4 serial bus clock output
485 * bit 3 serial bus atn output
486 * bit 2 rs232 data output
487 * bits 1-0 vic-chip system memory bank select
488 *
489 * CIA 1 - Port B
490 * bit 7 user rs232 data set ready
491 * bit 6 user rs232 clear to send
492 * bit 5 user
493 * bit 4 user rs232 carrier detect
494 * bit 3 user rs232 ring indicator
495 * bit 2 user rs232 data terminal ready
496 * bit 1 user rs232 request to send
497 * bit 0 user rs232 received data
498 *
499 * flag restore key or rs232 received data input
500 * irq to nmi connected ?
501 */
502READ8_MEMBER(c65_state::c65_cia1_port_a_r)
503{
504   UINT8 value = 0xff;
505
506   if (!m_iec->clk_r())
507      value &= ~0x40;
508
509   if (!m_iec->data_r())
510      value &= ~0x80;
511
512   return value;
513}
514
515WRITE8_MEMBER(c65_state::c65_cia1_port_a_w)
516{
517   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
518
519   m_iec->atn_w(!BIT(data, 3));
520   m_iec->clk_w(!BIT(data, 4));
521   m_iec->data_w(!BIT(data, 5));
522
523   m_vicaddr = m_memory + helper[data & 0x03];
524}
525
526WRITE_LINE_MEMBER(c65_state::c65_cia1_interrupt)
527{
528   m_cia1_irq = state;
529   c65_nmi();
530}
531
532/***********************************************
533
534    Memory Handlers
535
536***********************************************/
537
538/* processor has only 1 mega address space !? */
539/* and system 8 megabyte */
540/* dma controller and bankswitch hardware ?*/
541READ8_MEMBER( c65_state::c65_read_mem )
542{
543   UINT8 result;
544   if (offset <= 0x0ffff)
545      result = m_memory[offset];
546   else
547      result = space.read_byte(offset);
548   return result;
549}
550
551WRITE8_MEMBER( c65_state::c65_write_mem )
552{
553   if (offset <= 0x0ffff)
554      m_memory[offset] = data;
555   else
556      space.write_byte(offset, data);
557}
558
559/* dma chip at 0xd700
560  used:
561   writing banknumber to offset 2
562   writing hibyte to offset 1
563   writing lobyte to offset 0
564    cpu holded, dma transfer(data at address) executed, cpu activated
565
566  command data:
567   0 command (0 copy, 3 fill)
568   1,2 length
569   3,4,5 source
570   6,7,8 dest
571   9 subcommand
572   10 mod
573
574   version 1:
575   seldom copy (overlapping) from 0x402002 to 0x402008
576   (making place for new line in basic area)
577   for whats this bit 0x400000, or is this really the address?
578   maybe means add counter to address for access,
579   so allowing up or down copies, and reordering copies
580
581   version 2:
582   cmd 0x30 used for this
583*/
584void c65_state::c65_dma_port_w( int offset, int value )
585{
586   PAIR pair, src, dst, len;
587   UINT8 cmd, fill;
588   int i;
589   address_space &space = m_maincpu->space(AS_PROGRAM);
590
591   switch (offset & 3)
592   {
593   case 2:
594   case 1:
595      m_dma.data[offset & 3] = value;
596      break;
597   case 0:
598      pair.b.h3 = 0;
599      pair.b.h2 = m_dma.data[2];
600      pair.b.h = m_dma.data[1];
601      pair.b.l = m_dma.data[0]=value;
602      cmd = c65_read_mem(space, pair.d++);
603      len.w.h = 0;
604      len.b.l = c65_read_mem(space, pair.d++);
605      len.b.h = c65_read_mem(space, pair.d++);
606      src.b.h3 = 0;
607      fill = src.b.l = c65_read_mem(space, pair.d++);
608      src.b.h = c65_read_mem(space, pair.d++);
609      src.b.h2 = c65_read_mem(space, pair.d++);
610      dst.b.h3 = 0;
611      dst.b.l = c65_read_mem(space, pair.d++);
612      dst.b.h = c65_read_mem(space, pair.d++);
613      dst.b.h2 = c65_read_mem(space, pair.d++);
614
615      switch (cmd)
616      {
617      case 0:
618         if (src.d == 0x3ffff) m_dump_dma = 1;
619         if (m_dump_dma)
620            DBG_LOG(space.machine(), 1,"dma copy job",
621                  ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n",
622                     len.w.l, src.d, dst.d, c65_read_mem(space, pair.d),
623                     c65_read_mem(space, pair.d + 1) ) );
624         if ((m_dma.version == 1)
625               && ( (src.d&0x400000) || (dst.d & 0x400000)))
626         {
627            if (!(src.d & 0x400000))
628            {
629               dst.d &= ~0x400000;
630               for (i = 0; i < len.w.l; i++)
631                  c65_write_mem(space, dst.d--, c65_read_mem(space, src.d++));
632            }
633            else if (!(dst.d & 0x400000))
634            {
635               src.d &= ~0x400000;
636               for (i = 0; i < len.w.l; i++)
637                  c65_write_mem(space, dst.d++, c65_read_mem(space, src.d--));
638            }
639            else
640            {
641               src.d &= ~0x400000;
642               dst.d &= ~0x400000;
643               for (i = 0; i < len.w.l; i++)
644                  c65_write_mem(space, --dst.d, c65_read_mem(space, --src.d));
645            }
646         }
647         else
648         {
649            for (i = 0; i < len.w.l; i++)
650               c65_write_mem(space, dst.d++, c65_read_mem(space, src.d++));
651         }
652         break;
653      case 3:
654         DBG_LOG(space.machine(), 3,"dma fill job",
655               ("len:%.4x value:%.2x dst:%.6x sub:%.2x modrm:%.2x\n",
656                  len.w.l, fill, dst.d, c65_read_mem(space, pair.d),
657                  c65_read_mem(space, pair.d + 1)));
658            for (i = 0; i < len.w.l; i++)
659               c65_write_mem(space, dst.d++, fill);
660            break;
661      case 0x30:
662         DBG_LOG(space.machine(), 1,"dma copy down",
663               ("len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n",
664                  len.w.l, src.d, dst.d, c65_read_mem(space, pair.d),
665                  c65_read_mem(space, pair.d + 1) ) );
666         for (i = 0; i < len.w.l; i++)
667            c65_write_mem(space, dst.d--,c65_read_mem(space, src.d--));
668         break;
669      default:
670         DBG_LOG(space.machine(), 1,"dma job",
671               ("cmd:%.2x len:%.4x src:%.6x dst:%.6x sub:%.2x modrm:%.2x\n",
672                  cmd,len.w.l, src.d, dst.d, c65_read_mem(space, pair.d),
673                  c65_read_mem(space, pair.d + 1)));
674      }
675      break;
676   default:
677      DBG_LOG(space.machine(), 1, "dma chip write", ("%.3x %.2x\n", offset, value));
678      break;
679   }
680}
681
682int c65_state::c65_dma_port_r( int offset )
683{
684   /* offset 3 bit 7 in progress ? */
685   DBG_LOG(machine(), 2, "dma chip read", ("%.3x\n", offset));
686   return 0x7f;
687}
688
689void c65_state::c65_6511_port_w( int offset, int value )
690{
691   if (offset == 7)
692   {
693      m_6511_port = value;
694   }
695   DBG_LOG(machine(), 2, "r6511 write", ("%.2x %.2x\n", offset, value));
696}
697
698int c65_state::c65_6511_port_r( int offset )
699{
700   int data = 0xff;
701
702   if (offset == 7)
703   {
704      if (ioport("SPECIAL")->read() & 0x20)
705         data &= ~1;
706   }
707   DBG_LOG(machine(), 2, "r6511 read", ("%.2x\n", offset));
708
709   return data;
710}
711
712/* one docu states custom 4191 disk controller
713 (for 2 1MB MFM disk drives, 1 internal, the other extern (optional) 1565
714 with integrated 512 byte buffer
715
716 0->0 reset ?
717
718 0->1, 0->0, wait until 2 positiv, 1->0 ???
719
720 0->0, 0 not 0 means no drive ???, other system entries
721
722
723 reg 0 write/read
724  0,1 written
725  bit 1 set
726  bit 2 set
727  bit 3 set
728  bit 4 set
729
730
731 reg 0 read
732  bit 0
733  bit 1
734  bit 2
735  0..2 ->$1d4
736
737 reg 1 write
738  $01 written
739  $18 written
740  $46 written
741  $80 written
742  $a1 written
743  $01 written, dec
744  $10 written
745
746 reg 2 read/write?(lsr)
747  bit 2
748  bit 4
749  bit 5 busy waiting until zero, then reading reg 7
750  bit 6 operation not activ flag!? or set overflow pin used
751  bit 7 busy flag?
752
753 reg 3 read/write?(rcr)
754  bit 1
755  bit 3
756  bit 7 busy flag?
757
758 reg 4
759  track??
760  0 written
761  read -> $1d2
762  cmp #$50
763  bcs
764
765
766 reg 5
767  sector ??
768  1 written
769  read -> $1d3
770  cmp #$b bcc
771
772
773 reg 6
774  head ??
775  0 written
776  read -> $1d1
777  cmp #2 bcc
778
779 reg 7 read
780  #4e written
781  12 times 0, a1 a1 a1 fe  written
782
783 reg 8 read
784  #ff written
785  16 times #ff written
786
787 reg 9
788  #60 written
789
790might use the set overflow input
791
792$21a6c 9a6c format
793$21c97 9c97 write operation
794$21ca0 9ca0 get byte?
795$21cab 9cab read reg 7
796$21caf 9caf write reg 7
797$21cb3
798*/
799
800#define FDC_LOST 4
801#define FDC_CRC 8
802#define FDC_RNF 0x10
803#define FDC_BUSY 0x80
804#define FDC_IRQ 0x200
805
806#define FDC_CMD_MOTOR_SPIN_UP 0x10
807
808#if 0
809void c65_state::c65_fdc_state(void)
810{
811   switch (m_fdc.state)
812   {
813   case FDC_CMD_MOTOR_SPIN_UP:
814      if (machine().time() - m_fdc.time)
815      {
816         m_fdc.state = 0;
817         m_fdc.status &= ~FDC_BUSY;
818      }
819      break;
820   }
821}
822#endif
823
824void c65_state::c65_fdc_w( int offset, int data )
825{
826   DBG_LOG(machine(), 1, "fdc write", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data));
827   switch (offset & 0xf)
828   {
829   case 0:
830      m_fdc.reg[0] = data;
831      break;
832   case 1:
833      m_fdc.reg[1] = data;
834      switch (data & 0xf9)
835      {
836      case 0x20: // wait for motor spin up
837         m_fdc.status &= ~(FDC_IRQ|FDC_LOST|FDC_CRC|FDC_RNF);
838         m_fdc.status |= FDC_BUSY;
839         m_fdc.time = machine().time();
840         m_fdc.state = FDC_CMD_MOTOR_SPIN_UP;
841         break;
842      case 0: // cancel
843         m_fdc.status &= ~(FDC_BUSY);
844         m_fdc.state = 0;
845         break;
846      case 0x80: // buffered write
847      case 0x40: // buffered read
848      case 0x81: // unbuffered write
849      case 0x41: // unbuffered read
850      case 0x30:case 0x31: // step
851         break;
852      }
853      break;
854   case 2: case 3: // read only
855      break;
856   case 4:
857      m_fdc.reg[offset & 0xf] = data;
858      m_fdc.track = data;
859      break;
860   case 5:
861      m_fdc.reg[offset & 0xf] = data;
862      m_fdc.sector = data;
863      break;
864   case 6:
865      m_fdc.reg[offset & 0xf] = data;
866      m_fdc.head = data;
867      break;
868   case 7:
869      m_fdc.buffer[m_fdc.cpu_pos++] = data;
870      break;
871   default:
872      m_fdc.reg[offset & 0xf] = data;
873      break;
874   }
875}
876
877int c65_state::c65_fdc_r( int offset )
878{
879   UINT8 data = 0;
880   switch (offset & 0xf)
881   {
882   case 0:
883      data = m_fdc.reg[0];
884      break;
885   case 1:
886      data = m_fdc.reg[1];
887      break;
888   case 2:
889      data = m_fdc.status;
890      break;
891   case 3:
892      data = m_fdc.status >> 8;
893      break;
894   case 4:
895      data = m_fdc.track;
896      break;
897   case 5:
898      data = m_fdc.sector;
899      break;
900   case 6:
901      data = m_fdc.head;
902      break;
903   case 7:
904      data = m_fdc.buffer[m_fdc.cpu_pos++];
905      break;
906   default:
907      data = m_fdc.reg[offset & 0xf];
908      break;
909   }
910   DBG_LOG(machine(), 1, "fdc read", ("%.5x %.2x %.2x\n", machine().device("maincpu")->safe_pc(), offset, data));
911   return data;
912}
913
914/* version 1 ramcheck
915   write 0:0
916   read write read write 80000,90000,f0000
917   write 0:8
918   read write read write 80000,90000,f0000
919
920   version 2 ramcheck???
921   read 0:
922   write 0:0
923   read 0:
924   first read and second read bit 0x80 set --> nothing
925   write 0:0
926   read 0
927   write 0:ff
928*/
929
930READ8_MEMBER( c65_state::c65_ram_expansion_r )
931{
932   UINT8 data = 0xff;
933   if (m_ram->size() > (128 * 1024))
934      data = m_expansion_ram.reg;
935   return data;
936}
937
938WRITE8_MEMBER( c65_state::c65_ram_expansion_w )
939{
940   offs_t expansion_ram_begin;
941   offs_t expansion_ram_end;
942
943   if (m_ram->size() > (128 * 1024))
944   {
945      m_expansion_ram.reg = data;
946
947      expansion_ram_begin = 0x80000;
948      expansion_ram_end = 0x80000 + (m_ram->size() - 128*1024) - 1;
949
950      if (data == 0x00) {
951         space.install_readwrite_bank(expansion_ram_begin, expansion_ram_end,"bank16");
952         membank("bank16")->set_base(m_ram->pointer() + 128*1024);
953      } else {
954         space.nop_readwrite(expansion_ram_begin, expansion_ram_end);
955      }
956   }
957}
958
959WRITE8_MEMBER( c65_state::c65_write_io )
960{
961   mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r");
962   mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l");
963   vic3_device *vic3 = machine().device<vic3_device>("vic3");
964
965   switch (offset & 0xf00)
966   {
967   case 0x000:
968      if (offset < 0x80)
969         vic3->port_w(space, offset & 0x7f, data);
970      else if (offset < 0xa0)
971         c65_fdc_w(offset & 0x1f, data);
972      else
973      {
974         c65_ram_expansion_w(space, offset & 0x1f, data, mem_mask);
975         /*ram expansion crtl optional */
976      }
977      break;
978   case 0x100:
979   case 0x200:
980   case 0x300:
981      vic3->palette_w(space, offset - 0x100, data);
982      break;
983   case 0x400:
984      if (offset<0x420) /* maybe 0x20 */
985         sid_0->write(space, offset & 0x3f, data);
986      else if (offset<0x440)
987         sid_1->write(space, offset & 0x3f, data);
988      else
989         DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data));
990      break;
991   case 0x500:
992      DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset, data));
993      break;
994   case 0x600:
995      c65_6511_port_w(offset & 0xff,data);
996      break;
997   case 0x700:
998      c65_dma_port_w(offset & 0xff, data);
999      break;
1000   }
1001}
1002
1003WRITE8_MEMBER( c65_state::c65_write_io_dc00 )
1004{
1005   switch (offset & 0xf00)
1006   {
1007   case 0x000:
1008      m_cia0->write(space, offset, data);
1009      break;
1010   case 0x100:
1011      m_cia1->write(space, offset, data);
1012      break;
1013   case 0x200:
1014   case 0x300:
1015      DBG_LOG(machine(), 1, "io write", ("%.3x %.2x\n", offset+0xc00, data));
1016      break;
1017   }
1018}
1019
1020READ8_MEMBER( c65_state::c65_read_io )
1021{
1022   mos6581_device *sid_0 = machine().device<mos6581_device>("sid_r");
1023   mos6581_device *sid_1 = machine().device<mos6581_device>("sid_l");
1024   vic3_device *vic3 = machine().device<vic3_device>("vic3");
1025
1026   switch (offset & 0xf00)
1027   {
1028   case 0x000:
1029      if (offset < 0x80)
1030         return vic3->port_r(space, offset & 0x7f);
1031      if (offset < 0xa0)
1032         return c65_fdc_r(offset & 0x1f);
1033      else
1034      {
1035         return c65_ram_expansion_r(space, offset & 0x1f, mem_mask);
1036         /*return; ram expansion crtl optional */
1037      }
1038   case 0x100:
1039   case 0x200:
1040   case 0x300:
1041   /* read only !? */
1042      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset));
1043      break;
1044   case 0x400:
1045      if (offset < 0x420)
1046         return sid_0->read(space, offset & 0x3f);
1047      if (offset < 0x440)
1048         return sid_1->read(space, offset & 0x3f);
1049      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset));
1050      break;
1051   case 0x500:
1052      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset));
1053      break;
1054   case 0x600:
1055      return c65_6511_port_r(offset&0xff);
1056   case 0x700:
1057      return c65_dma_port_r(offset&0xff);
1058   }
1059   return 0xff;
1060}
1061
1062READ8_MEMBER( c65_state::c65_read_io_dc00 )
1063{
1064   switch (offset & 0x300)
1065   {
1066   case 0x000:
1067      return m_cia0->read(space, offset);
1068   case 0x100:
1069      return m_cia1->read(space, offset);
1070   case 0x200:
1071   case 0x300:
1072      DBG_LOG(machine(), 1, "io read", ("%.3x\n", offset+0xc00));
1073      break;
1074   }
1075   return 0xff;
1076}
1077
1078
1079/*
1080d02f:
1081 init a5 96 written (seems to be switch to c65 or vic3 mode)
1082 go64 0 written
1083*/
1084
1085/* bit 1 external sync enable (genlock)
1086   bit 2 palette enable
1087   bit 6 vic3 c65 character set */
1088WRITE8_MEMBER(c65_state::c65_bankswitch_interface)
1089{
1090   DBG_LOG(machine(), 2, "c65 bankswitch", ("%.2x\n",data));
1091
1092   if (m_io_on)
1093   {
1094      if (data & 1)
1095      {
1096         membank("bank8")->set_base(m_colorram + 0x400);
1097         membank("bank9")->set_base(m_colorram + 0x400);
1098         m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8");
1099         m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9");
1100      }
1101      else
1102      {
1103         m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this));
1104         m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this));
1105      }
1106   }
1107
1108   m_io_dc00_on = !(data & 1);
1109#if 0
1110   /* cartridge roms !?*/
1111   if (data & 0x08)
1112      membank("bank1")->set_base(m_roml);
1113   else
1114      membank("bank1")->set_base(m_memory + 0x8000);
1115
1116   if (data & 0x10)
1117      membank("bank2")->set_base(m_basic);
1118   else
1119      membank("bank2")->set_base(m_memory + 0xa000);
1120#endif
1121   if ((m_old_value^data) & 0x20)
1122   {
1123   /* bankswitching faulty when doing actual page */
1124      if (data & 0x20)
1125         membank("bank3")->set_base(m_basic);
1126      else
1127         membank("bank3")->set_base(m_memory + 0xc000);
1128   }
1129   m_charset_select = data & 0x40;
1130#if 0
1131   /* cartridge roms !?*/
1132   if (data & 0x80)
1133      membank("bank8")->set_base(m_kernal);
1134   else
1135      membank("bank6")->set_base(m_memory + 0xe000);
1136#endif
1137   m_old_value = data;
1138}
1139
1140void c65_state::c65_bankswitch(  )
1141{
1142   int data, loram, hiram, charen;
1143
1144   data = 0x00; // machine().device<m4510_device>("maincpu")->get_port();
1145   if (data == m_old_data)
1146      return;
1147
1148   DBG_LOG(machine(), 1, "bankswitch", ("%d\n", data & 7));
1149   loram = (data & 1) ? 1 : 0;
1150   hiram = (data & 2) ? 1 : 0;
1151   charen = (data & 4) ? 1 : 0;
1152
1153   if ((!m_game && m_exrom) || (loram && hiram && !m_exrom))
1154      membank("bank1")->set_base(m_roml);
1155   else
1156      membank("bank1")->set_base(m_memory + 0x8000);
1157
1158   if ((!m_game && m_exrom && hiram) || (!m_exrom))
1159      membank("bank2")->set_base(m_romh);
1160   else if (loram && hiram)
1161      membank("bank2")->set_base(m_basic);
1162   else
1163      membank("bank2")->set_base(m_memory + 0xa000);
1164
1165   if ((!m_game && m_exrom) || (charen && (loram || hiram)))
1166   {
1167      m_io_on = 1;
1168      membank("bank6")->set_base(m_colorram);
1169      membank("bank7")->set_base(m_colorram);
1170
1171      if (m_io_dc00_on)
1172      {
1173         m_maincpu->space(AS_PROGRAM).install_read_handler(0x0dc00, 0x0dfff, read8_delegate(FUNC(c65_state::c65_read_io_dc00),this));
1174         m_maincpu->space(AS_PROGRAM).install_write_handler(0x0dc00, 0x0dfff, write8_delegate(FUNC(c65_state::c65_write_io_dc00),this));
1175      }
1176      else
1177      {
1178         m_maincpu->space(AS_PROGRAM).install_read_bank(0x0dc00, 0x0dfff, "bank8");
1179         m_maincpu->space(AS_PROGRAM).install_write_bank(0x0dc00, 0x0dfff, "bank9");
1180         membank("bank8")->set_base(m_colorram + 0x400);
1181         membank("bank9")->set_base(m_colorram + 0x400);
1182      }
1183      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0d000, 0x0d7ff, read8_delegate(FUNC(c65_state::c65_read_io),this));
1184      m_maincpu->space(AS_PROGRAM).install_write_handler(0x0d000, 0x0d7ff, write8_delegate(FUNC(c65_state::c65_write_io),this));
1185   }
1186   else
1187   {
1188      m_io_on = 0;
1189      membank("bank5")->set_base(m_memory + 0xd000);
1190      membank("bank7")->set_base(m_memory + 0xd800);
1191      membank("bank9")->set_base(m_memory + 0xdc00);
1192      if (!charen && (loram || hiram))
1193      {
1194         membank("bank4")->set_base(m_chargen);
1195         membank("bank6")->set_base(m_chargen + 0x800);
1196         membank("bank8")->set_base(m_chargen + 0xc00);
1197      }
1198      else
1199      {
1200         membank("bank4")->set_base(m_memory + 0xd000);
1201         membank("bank6")->set_base(m_memory + 0xd800);
1202         membank("bank8")->set_base(m_memory + 0xdc00);
1203      }
1204      m_maincpu->space(AS_PROGRAM).install_read_bank(0x0d000, 0x0d7ff, "bank4");
1205      m_maincpu->space(AS_PROGRAM).install_write_bank(0x0d000, 0x0d7ff, "bank5");
1206   }
1207
1208   if (!m_game && m_exrom)
1209   {
1210      membank("bank10")->set_base(m_romh);
1211   }
1212   else
1213   {
1214      if (hiram)
1215      {
1216         membank("bank10")->set_base(m_kernal);
1217      }
1218      else
1219      {
1220         membank("bank10")->set_base(m_memory + 0xe000);
1221      }
1222   }
1223   m_old_data = data;
1224}
1225
1226#ifdef UNUSED_FUNCTION
1227void c65_state::c65_colorram_write( int offset, int value )
1228{
1229   m_colorram[offset & 0x7ff] = value | 0xf0;
1230}
1231#endif
1232
1233/*
1234 * only 14 address lines
1235 * a15 and a14 portlines
1236 * 0x1000-0x1fff, 0x9000-0x9fff char rom
1237 */
1238READ8_MEMBER(c65_state::c65_dma_read)
1239{
1240   if (!m_game && m_exrom)
1241   {
1242      if (offset < 0x3000)
1243         return m_memory[offset];
1244      return m_romh[offset & 0x1fff];
1245   }
1246   if ((m_vicaddr == m_memory) || (m_vicaddr == m_memory + 0x8000))
1247   {
1248      if (offset < 0x1000)
1249         return m_vicaddr[offset & 0x3fff];
1250      if (offset < 0x2000) {
1251         if (m_charset_select)
1252            return m_chargen[offset & 0xfff];
1253         else
1254            return m_chargen[offset & 0xfff];
1255      }
1256      return m_vicaddr[offset & 0x3fff];
1257   }
1258   return m_vicaddr[offset & 0x3fff];
1259}
1260
1261READ8_MEMBER(c65_state::c65_dma_read_color)
1262{
1263   if (m_c64mode)
1264      return m_colorram[offset & 0x3ff] & 0xf;
1265   return m_colorram[offset & 0x7ff];
1266}
1267
1268void c65_state::c65_common_driver_init(  )
1269{
1270   m_memory = auto_alloc_array_clear(machine(), UINT8, 0x10000);
1271   membank("bank11")->set_base(m_memory + 0x00000);
1272   membank("bank12")->set_base(m_memory + 0x08000);
1273   membank("bank13")->set_base(m_memory + 0x0a000);
1274   membank("bank14")->set_base(m_memory + 0x0c000);
1275   membank("bank15")->set_base(m_memory + 0x0e000);
1276
1277   cbm_common_init();
1278   m_keyline = 0xff;
1279
1280   m_pal = 0;
1281   m_charset_select = 0;
1282   m_6511_port = 0xff;
1283   m_vicirq = 0;
1284   m_old_data = -1;
1285
1286   /* C65 had no datasette port */
1287   m_tape_on = 0;
1288   m_game = 1;
1289   m_exrom = 1;
1290
1291   /*memset(m_memory + 0x40000, 0, 0x800000 - 0x40000); */
1292}
1293
1294DRIVER_INIT_MEMBER(c65_state,c65)
1295{
1296   m_dma.version = 2;
1297   c65_common_driver_init();
1298}
1299
1300DRIVER_INIT_MEMBER(c65_state,c65pal)
1301{
1302   m_dma.version = 1;
1303   c65_common_driver_init();
1304   m_pal = 1;
1305}
1306
1307MACHINE_START_MEMBER(c65_state,c65)
1308{
1309   /* clear upper memory */
1310   memset(m_ram->pointer() + 128*1024, 0xff, m_ram->size() -  128*1024);
1311
1312//removed   cbm_drive_0_config (SERIAL, 10);
1313//removed   cbm_drive_1_config (SERIAL, 11);
1314   m_vicaddr = m_memory;
1315
1316   m_c64mode = 0;
1317
1318   c65_bankswitch_interface(m_maincpu->space(AS_PROGRAM),0,0xff);
1319   c65_bankswitch();
1320}
1321
1322
1323INTERRUPT_GEN_MEMBER(c65_state::c65_frame_interrupt)
1324{
1325   int value;
1326
1327   c65_nmi();
1328
1329   /* common keys input ports */
1330   cbm_common_interrupt(&device);
1331
1332   /* c65 specific: function keys input ports */
1333   value = 0xff;
1334
1335   value &= ~ioport("FUNCT")->read();
1336   m_keyline = value;
1337}
1338
trunk/src/mess/machine/macadb.c
r243230r243231
427427                     {
428428                        if(m_adb_keybuf_start == m_adb_keybuf_end)
429429                        {
430   //                              printf("%s: buffer empty\n", __func__);
430   //                        printf("%s: buffer empty\n", __func__);
431431                           m_adb_buffer[0] = 0xff;
432432                           m_adb_buffer[1] = 0xff;
433433                        }
trunk/src/mess/machine/nes.c
r243230r243231
139139   // bit 0 to controller port
140140   ret |= m_ctrl1->read_bit0();
141141
142   // expansion port bits (in the original FC, P2 controller was hooked to these lines
142   // expansion port bits (in the original FC, P2 controller was hooked to these lines
143143   // too, so in principle some homebrew hardware modification could use the same
144144   // connection with P1 controller too)
145145   ret |= m_ctrl1->read_exp(0);
r243230r243231
160160   // bit 0 to controller port
161161   ret |= m_ctrl2->read_bit0();
162162
163   // expansion port bits (in the original FC, P2 controller was hooked to these lines
163   // expansion port bits (in the original FC, P2 controller was hooked to these lines
164164   // too, so in principle some homebrew hardware modification could use the same
165165   // connection with P1 controller too)
166166   ret |= m_ctrl1->read_exp(1);
r243230r243231
193193{
194194   // get the pixel at the gun position
195195   UINT32 pix = m_ppu->get_pixel(x, y);
196
196   
197197   // get the color base from the ppu
198198   UINT32 color_base = m_ppu->get_colorbase();
199
199   
200200   // check if the cursor is over a bright pixel
201201   if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
202202      (pix == color_base + 0x33) || (pix == color_base + 0x34))
trunk/src/mess/mess.mak
r243230r243231
10881088   $(MESS_DRIVERS)/c128.o      \
10891089   $(MESS_DRIVERS)/c64.o       \
10901090   $(MESS_DRIVERS)/c64dtv.o    \
1091   $(MESS_DRIVERS)/c65.o \
1091   $(MESS_DRIVERS)/c65.o $(MESS_MACHINE)/c65.o \
10921092   $(MESS_DRIVERS)/c900.o      \
10931093   $(MESS_DRIVERS)/cbm2.o      \
10941094   $(MESS_DRIVERS)/clcd.o      \
trunk/src/osd/modules/debugger/debug_module.h
r243230r243231
2020{
2121public:
2222
23   virtual ~debug_module() { }
23    virtual ~debug_module() { }
2424
25   virtual void init_debugger(running_machine &machine) = 0;
26   virtual void wait_for_debugger(device_t &device, bool firststop) = 0;
27   virtual void debugger_update() = 0;
25    virtual void init_debugger(running_machine &machine) = 0;
26    virtual void wait_for_debugger(device_t &device, bool firststop) = 0;
27    virtual void debugger_update() = 0;
2828};
2929
3030
trunk/src/osd/modules/debugger/debugint.c
r243230r243231
2727class debug_internal : public osd_module, public debug_module
2828{
2929public:
30   debug_internal()
31   : osd_module(OSD_DEBUG_PROVIDER, "internal"), debug_module(),
32      m_machine(NULL)
33   {
34   }
30    debug_internal()
31    : osd_module(OSD_DEBUG_PROVIDER, "internal"), debug_module(),
32      m_machine(NULL)
33    {
34    }
3535
36   virtual ~debug_internal() { }
36    virtual ~debug_internal() { }
3737
38   virtual int init() { return 0;}
39   virtual void exit();
38    virtual int init() { return 0;}
39    virtual void exit();
4040
41   virtual void init_debugger(running_machine &machine);
42   virtual void wait_for_debugger(device_t &device, bool firststop);
43   virtual void debugger_update();
41    virtual void init_debugger(running_machine &machine);
42    virtual void wait_for_debugger(device_t &device, bool firststop);
43    virtual void debugger_update();
4444
4545private:
46   running_machine *m_machine;
46    running_machine *m_machine;
4747};
4848
4949
trunk/src/osd/modules/debugger/debugqt.c
r243230r243231
3737class debug_qt : public osd_module, public debug_module
3838{
3939public:
40   debug_qt()
41   : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(),
42      m_machine(NULL)
43   {
44   }
40    debug_qt()
41    : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(),
42      m_machine(NULL)
43    {
44    }
4545
46   virtual ~debug_qt() { }
46    virtual ~debug_qt() { }
4747
48   virtual int init() { return 0;}
49   virtual void exit() { }
48    virtual int init() { return 0;}
49    virtual void exit() { }
5050
51   virtual void init_debugger(running_machine &machine);
52   virtual void wait_for_debugger(device_t &device, bool firststop);
53   virtual void debugger_update();
51    virtual void init_debugger(running_machine &machine);
52    virtual void wait_for_debugger(device_t &device, bool firststop);
53    virtual void debugger_update();
5454
5555private:
56   running_machine *m_machine;
56    running_machine *m_machine;
5757};
5858
5959//============================================================
r243230r243231
357357}
358358
359359#else /* SDLMAME_UNIX */
360   MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
360    MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
361361#endif
362362
363363MODULE_DEFINITION(DEBUG_QT, debug_qt)
trunk/src/osd/modules/debugger/debugwin.c
r243230r243231
4444class debugger_windows : public osd_module, public debug_module
4545{
4646public:
47   debugger_windows()
48   : osd_module(OSD_DEBUG_PROVIDER, "windows"), debug_module(),
49      m_machine(NULL)
50   {
51   }
47    debugger_windows()
48    : osd_module(OSD_DEBUG_PROVIDER, "windows"), debug_module(),
49      m_machine(NULL)
50    {
51    }
5252
53   virtual ~debugger_windows() { }
53    virtual ~debugger_windows() { }
5454
55   virtual int init() { return 0;}
56   virtual void exit();
55    virtual int init() { return 0;}
56    virtual void exit();
5757
58   virtual void init_debugger(running_machine &machine);
59   virtual void wait_for_debugger(device_t &device, bool firststop);
60   virtual void debugger_update();
58    virtual void init_debugger(running_machine &machine);
59    virtual void wait_for_debugger(device_t &device, bool firststop);
60    virtual void debugger_update();
6161
6262private:
63   running_machine *m_machine;
63    running_machine *m_machine;
6464};
6565//============================================================
6666//  PARAMETERS
r243230r243231
30943094      smart_show_window(info->wnd, show);
30953095}
30963096#else /* not windows */
3097   MODULE_NOT_SUPPORTED(debugger_windows, OSD_DEBUG_PROVIDER, "windows")
3097    MODULE_NOT_SUPPORTED(debugger_windows, OSD_DEBUG_PROVIDER, "windows")
30983098#endif
30993099
31003100MODULE_DEFINITION(DEBUG_WINDOWS, debugger_windows)
trunk/src/osd/modules/debugger/none.c
r243230r243231
1212class debug_none : public osd_module, public debug_module
1313{
1414public:
15   debug_none()
16   : osd_module(OSD_DEBUG_PROVIDER, "none"), debug_module(),
17      m_machine(NULL)
18   {
19   }
15    debug_none()
16    : osd_module(OSD_DEBUG_PROVIDER, "none"), debug_module(),
17      m_machine(NULL)
18    {
19    }
2020
21   virtual ~debug_none() { }
21    virtual ~debug_none() { }
2222
23   virtual int init() { return 0;}
24   virtual void exit() { }
23    virtual int init() { return 0;}
24    virtual void exit() { }
2525
26   virtual void init_debugger(running_machine &machine);
27   virtual void wait_for_debugger(device_t &device, bool firststop);
28   virtual void debugger_update();
26    virtual void init_debugger(running_machine &machine);
27    virtual void wait_for_debugger(device_t &device, bool firststop);
28    virtual void debugger_update();
2929
3030private:
31   running_machine *m_machine;
31    running_machine *m_machine;
3232};
3333
3434void debug_none::init_debugger(running_machine &machine)
3535{
36   m_machine = &machine;
36    m_machine = &machine;
3737}
3838
3939void debug_none::wait_for_debugger(device_t &device, bool firststop)
trunk/src/osd/modules/font/font_module.h
r243230r243231
1818class font_module
1919{
2020public:
21   virtual ~font_module() { }
22   virtual osd_font *font_alloc() = 0;
21    virtual ~font_module() { }
22    virtual osd_font *font_alloc() = 0;
2323};
2424
2525
trunk/src/osd/modules/font/font_none.c
r243230r243231
1414class osd_font_none : public osd_font
1515{
1616public:
17   virtual ~osd_font_none() {};
17    virtual ~osd_font_none() {};
1818
19   virtual bool open(const char *font_path, const char *name, int &height);
20   virtual void close();
21   virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
19    virtual bool open(const char *font_path, const char *name, int &height);
20    virtual void close();
21    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
2222private:
2323};
2424
2525bool osd_font_none::open(const char *font_path, const char *_name, int &height)
2626{
27   return false;
27    return false;
2828}
2929
3030//-------------------------------------------------
r243230r243231
4646
4747bool osd_font_none::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
4848{
49   return false;
49    return false;
5050}
5151
5252class font_none : public osd_module, public font_module
5353{
5454public:
55   font_none()
56   : osd_module(OSD_FONT_PROVIDER, "none"), font_module()
57   {
58   }
55    font_none()
56    : osd_module(OSD_FONT_PROVIDER, "none"), font_module()
57    {
58    }
5959
60   osd_font *font_alloc()
61   {
62      return global_alloc(osd_font_none);
63   }
60    osd_font *font_alloc()
61    {
62        return global_alloc(osd_font_none);
63    }
6464};
6565
6666MODULE_DEFINITION(FONT_NONE, font_none)
67
trunk/src/osd/modules/font/font_osx.c
r243230r243231
2626class osd_font_osx : public osd_font
2727{
2828public:
29   virtual ~osd_font_osx() {};
29    virtual ~osd_font_osx() {};
3030
31   virtual bool open(const char *font_path, const char *name, int &height);
32   virtual void close();
33   virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
31    virtual bool open(const char *font_path, const char *name, int &height);
32    virtual void close();
33    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
3434private:
35   CTFontRef m_font;
35    CTFontRef m_font;
3636};
3737
3838bool osd_font_osx::open(const char *font_path, const char *_name, int &height)
3939{
40   CFStringRef font_name = NULL;
41   CTFontRef ct_font = NULL;
42   CTFontDescriptorRef font_descriptor;
43   CGAffineTransform affine_transform = CGAffineTransformIdentity;
40    CFStringRef font_name = NULL;
41    CTFontRef ct_font = NULL;
42    CTFontDescriptorRef font_descriptor;
43    CGAffineTransform affine_transform = CGAffineTransformIdentity;
4444
45   m_font = NULL;
46   astring name(_name);
47   printf("FONT NAME %s\n", _name);
45    m_font = NULL;
46    astring name(_name);
47    printf("FONT NAME %s\n", _name);
4848#if 0
49   if (name == "default")
50   {
51      name = "LucidaGrande";
52   }
49    if (name == "default")
50    {
51        name = "LucidaGrande";
52    }
5353#endif
54   /* handle bdf fonts in the core */
55   if (name.len() > 4)
56      if (name.makeupper().substr(name.len()-4,4) == ".BDF" )
57         return false;
54    /* handle bdf fonts in the core */
55    if (name.len() > 4)
56        if (name.makeupper().substr(name.len()-4,4) == ".BDF" )
57            return false;
5858
59   font_name = CFStringCreateWithCString( NULL, name.cstr(), kCFStringEncodingUTF8 );
60   if( font_name != NULL )
61   {
62      font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, 0.0); //POINT_SIZE );
59    font_name = CFStringCreateWithCString( NULL, name.cstr(), kCFStringEncodingUTF8 );
60    if( font_name != NULL )
61    {
62        font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, 0.0); //POINT_SIZE );
6363
64      if( font_descriptor != NULL )
65      {
66         ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform );
64        if( font_descriptor != NULL )
65        {
66            ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform );
6767
68         CFRelease( font_descriptor );
69      }
70   }
68            CFRelease( font_descriptor );
69        }
70    }
7171
72   CFRelease( font_name );
72    CFRelease( font_name );
7373
74   if (!ct_font)
75   {
76      osd_printf_verbose("Couldn't find/open font %s, using MAME default\n", name.cstr());
77      return false;
78   }
74    if (!ct_font)
75    {
76        osd_printf_verbose("Couldn't find/open font %s, using MAME default\n", name.cstr());
77        return false;
78    }
7979
80   CFStringRef real_name = CTFontCopyPostScriptName( ct_font );
81   char real_name_c_string[255];
82   CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 );
83   osd_printf_verbose("Matching font: %s\n", real_name_c_string);
84   CFRelease( real_name );
80    CFStringRef real_name = CTFontCopyPostScriptName( ct_font );
81    char real_name_c_string[255];
82    CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 );
83    osd_printf_verbose("Matching font: %s\n", real_name_c_string);
84    CFRelease( real_name );
8585
86   CGFloat line_height = 0.0;
87   line_height += CTFontGetAscent(ct_font);
88   line_height += CTFontGetDescent(ct_font);
89   line_height += CTFontGetLeading(ct_font);
90   height = ceilf(line_height * EXTRA_HEIGHT);
86    CGFloat line_height = 0.0;
87    line_height += CTFontGetAscent(ct_font);
88    line_height += CTFontGetDescent(ct_font);
89    line_height += CTFontGetLeading(ct_font);
90    height = ceilf(line_height * EXTRA_HEIGHT);
9191
92   m_font = ct_font;
93   return true;
92    m_font = ct_font;
93    return true;
9494}
9595
9696//-------------------------------------------------
r243230r243231
100100
101101void osd_font_osx::close()
102102{
103   if( m_font != NULL )
104   {
105      CFRelease( m_font );
106   }
103    if( m_font != NULL )
104    {
105        CFRelease( m_font );
106    }
107107}
108108
109109//-------------------------------------------------
r243230r243231
116116
117117bool osd_font_osx::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
118118{
119   UniChar uni_char;
120   CGGlyph glyph;
121   CTFontRef ct_font = m_font;
122   const CFIndex count = 1;
123   CGRect bounding_rect, success_rect;
124   CGContextRef context_ref;
119    UniChar uni_char;
120    CGGlyph glyph;
121    CTFontRef ct_font = m_font;
122    const CFIndex count = 1;
123    CGRect bounding_rect, success_rect;
124    CGContextRef context_ref;
125125
126   if( chnum == ' ' )
127   {
128      uni_char = 'n';
129      CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count );
130      success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count );
131      uni_char = chnum;
132      CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count );
133   }
134   else
135   {
136      uni_char = chnum;
137      CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count );
138      success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count );
139   }
126    if( chnum == ' ' )
127    {
128        uni_char = 'n';
129        CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count );
130        success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count );
131        uni_char = chnum;
132        CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count );
133    }
134    else
135    {
136        uni_char = chnum;
137        CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count );
138        success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count );
139    }
140140
141   if( CGRectEqualToRect( success_rect, CGRectNull ) == false )
142   {
143      size_t bitmap_width;
144      size_t bitmap_height;
141    if( CGRectEqualToRect( success_rect, CGRectNull ) == false )
142    {
143        size_t bitmap_width;
144        size_t bitmap_height;
145145
146      bitmap_width = ceilf(bounding_rect.size.width * EXTRA_WIDTH);
147      bitmap_width = bitmap_width == 0 ? 1 : bitmap_width;
146        bitmap_width = ceilf(bounding_rect.size.width * EXTRA_WIDTH);
147        bitmap_width = bitmap_width == 0 ? 1 : bitmap_width;
148148
149      bitmap_height = ceilf( (CTFontGetAscent(ct_font) + CTFontGetDescent(ct_font) + CTFontGetLeading(ct_font)) * EXTRA_HEIGHT);
149        bitmap_height = ceilf( (CTFontGetAscent(ct_font) + CTFontGetDescent(ct_font) + CTFontGetLeading(ct_font)) * EXTRA_HEIGHT);
150150
151      xoffs = yoffs = 0;
152      width = bitmap_width;
151        xoffs = yoffs = 0;
152        width = bitmap_width;
153153
154      size_t bits_per_component;
155      CGColorSpaceRef color_space;
156      CGBitmapInfo bitmap_info = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst;
154        size_t bits_per_component;
155        CGColorSpaceRef color_space;
156        CGBitmapInfo bitmap_info = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst;
157157
158      color_space = CGColorSpaceCreateDeviceRGB();
159      bits_per_component = 8;
158        color_space = CGColorSpaceCreateDeviceRGB();
159        bits_per_component = 8;
160160
161      bitmap.allocate(bitmap_width, bitmap_height);
161        bitmap.allocate(bitmap_width, bitmap_height);
162162
163      context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info );
163        context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info );
164164
165      if( context_ref != NULL )
166      {
167         CGFontRef font_ref;
168         font_ref = CTFontCopyGraphicsFont( ct_font, NULL );
169         CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) );
170         CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0);
171         CGContextSetFont( context_ref, font_ref );
172         CGContextSetFontSize( context_ref, POINT_SIZE );
173         CGContextShowGlyphs( context_ref, &glyph, count );
174         CGFontRelease( font_ref );
175         CGContextRelease( context_ref );
176      }
165        if( context_ref != NULL )
166        {
167            CGFontRef font_ref;
168            font_ref = CTFontCopyGraphicsFont( ct_font, NULL );
169            CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) );
170            CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0);
171            CGContextSetFont( context_ref, font_ref );
172            CGContextSetFontSize( context_ref, POINT_SIZE );
173            CGContextShowGlyphs( context_ref, &glyph, count );
174            CGFontRelease( font_ref );
175            CGContextRelease( context_ref );
176        }
177177
178      CGColorSpaceRelease( color_space );
179   }
178        CGColorSpaceRelease( color_space );
179    }
180180
181   return bitmap.valid();
181    return bitmap.valid();
182182}
183183
184184
185185class font_osx : public osd_module, public font_module
186186{
187187public:
188   font_osx()
189   : osd_module(OSD_FONT_PROVIDER, "osx"), font_module()
190   {
191   }
188    font_osx()
189    : osd_module(OSD_FONT_PROVIDER, "osx"), font_module()
190    {
191    }
192192
193   osd_font *font_alloc()
194   {
195      return global_alloc(osd_font_osx);
196   }
193    osd_font *font_alloc()
194    {
195        return global_alloc(osd_font_osx);
196    }
197197
198198};
199199#else /* SDLMAME_UNIX */
200   MODULE_NOT_SUPPORTED(font_osx, OSD_FONT_PROVIDER, "osx")
200    MODULE_NOT_SUPPORTED(font_osx, OSD_FONT_PROVIDER, "osx")
201201#endif
202202
203203MODULE_DEFINITION(FONT_OSX, font_osx)
trunk/src/osd/modules/font/font_sdl.c
r243230r243231
3232class osd_font_sdl : public osd_font
3333{
3434public:
35   virtual ~osd_font_sdl() {};
35    virtual ~osd_font_sdl() {};
3636
37   virtual bool open(const char *font_path, const char *name, int &height);
38   virtual void close();
39   virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
37    virtual bool open(const char *font_path, const char *name, int &height);
38    virtual void close();
39    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
4040private:
4141#ifndef SDLMAME_HAIKU
42   TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles);
42    TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles);
4343#endif
44   bool BDF_Check_Magic(astring name);
45   TTF_Font * TTF_OpenFont_Magic(astring name, int fsize);
46   TTF_Font *m_font;
44    bool BDF_Check_Magic(astring name);
45    TTF_Font * TTF_OpenFont_Magic(astring name, int fsize);
46    TTF_Font *m_font;
4747};
4848
4949bool osd_font_sdl::open(const char *font_path, const char *_name, int &height)
5050{
51   TTF_Font *font = (TTF_Font *)NULL;
52   bool bakedstyles = false;
53   int style = 0;
51    TTF_Font *font = (TTF_Font *)NULL;
52    bool bakedstyles = false;
53    int style = 0;
5454
55   // accept qualifiers from the name
56   astring name(_name);
55    // accept qualifiers from the name
56    astring name(_name);
5757
58   if (name == "default")
59   {
60      name = "Liberation Sans";
61   }
58    if (name == "default")
59    {
60        name = "Liberation Sans";
61    }
6262
63   bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0);
64   bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0);
65   bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0);
66   bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0);
63    bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0);
64    bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0);
65    bool underline = (name.replace(0, "[U]", "") + name.replace(0, "[u]", "") > 0);
66    bool strike = (name.replace(0, "[S]", "") + name.replace(0, "[s]", "") > 0);
6767
68   // first up, try it as a filename
69   font = TTF_OpenFont_Magic(name, POINT_SIZE);
68    // first up, try it as a filename
69    font = TTF_OpenFont_Magic(name, POINT_SIZE);
7070
71   // if no success, try the font path
71    // if no success, try the font path
7272
73   if (!font)
74   {
75      osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH);
76      //emu_file file(options().font_path(), OPEN_FLAG_READ);
77      emu_file file(font_path, OPEN_FLAG_READ);
78      if (file.open(name) == FILERR_NONE)
79      {
80         astring full_name = file.fullpath();
81         font = TTF_OpenFont_Magic(full_name, POINT_SIZE);
82         if (font)
83            osd_printf_verbose("Found font %s\n", full_name.cstr());
84      }
85   }
73    if (!font)
74    {
75        osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH);
76        //emu_file file(options().font_path(), OPEN_FLAG_READ);
77        emu_file file(font_path, OPEN_FLAG_READ);
78        if (file.open(name) == FILERR_NONE)
79        {
80            astring full_name = file.fullpath();
81            font = TTF_OpenFont_Magic(full_name, POINT_SIZE);
82            if (font)
83                osd_printf_verbose("Found font %s\n", full_name.cstr());
84        }
85    }
8686
87   // if that didn't work, crank up the FontConfig database
87    // if that didn't work, crank up the FontConfig database
8888#ifndef SDLMAME_HAIKU
89   if (!font)
90   {
91      font = search_font_config(name, bold, italic, underline, bakedstyles);
92   }
89    if (!font)
90    {
91        font = search_font_config(name, bold, italic, underline, bakedstyles);
92    }
9393#endif
9494
95   if (!font)
96   {
97      if (!BDF_Check_Magic(name))
98      {
99         osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr());
100      }
101      return NULL;
102   }
95    if (!font)
96    {
97        if (!BDF_Check_Magic(name))
98        {
99            osd_printf_verbose("font %s is not TrueType or BDF, using MAME default\n", name.cstr());
100        }
101        return NULL;
102    }
103103
104   // apply styles
105   if (!bakedstyles)
106   {
107      style |= bold ? TTF_STYLE_BOLD : 0;
108      style |= italic ? TTF_STYLE_ITALIC : 0;
109   }
110   style |= underline ? TTF_STYLE_UNDERLINE : 0;
111   // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH
104    // apply styles
105    if (!bakedstyles)
106    {
107        style |= bold ? TTF_STYLE_BOLD : 0;
108        style |= italic ? TTF_STYLE_ITALIC : 0;
109    }
110    style |= underline ? TTF_STYLE_UNDERLINE : 0;
111    // SDL_ttf 2.0.9 and earlier does not define TTF_STYLE_STRIKETHROUGH
112112#if SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL) > SDL_VERSIONNUM(2,0,9)
113   style |= strike ? TTF_STYLE_STRIKETHROUGH : 0;
113    style |= strike ? TTF_STYLE_STRIKETHROUGH : 0;
114114#else
115   if (strike)
116      osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n");
115    if (strike)
116        osd_printf_warning("Ignoring strikethrough for SDL_TTF older than 2.0.10\n");
117117#endif // PATCHLEVEL
118   TTF_SetFontStyle(font, style);
118    TTF_SetFontStyle(font, style);
119119
120   height = TTF_FontLineSkip(font);
120    height = TTF_FontLineSkip(font);
121121
122   m_font = font;
123   return true;
122    m_font = font;
123    return true;
124124}
125125
126126//-------------------------------------------------
r243230r243231
130130
131131void osd_font_sdl::close()
132132{
133   TTF_CloseFont(this->m_font);
133    TTF_CloseFont(this->m_font);
134134}
135135
136136//-------------------------------------------------
r243230r243231
143143
144144bool osd_font_sdl::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
145145{
146   TTF_Font *ttffont;
147   SDL_Surface *drawsurf;
148   SDL_Color fcol = { 0xff, 0xff, 0xff };
149   UINT16 ustr[16];
146    TTF_Font *ttffont;
147    SDL_Surface *drawsurf;
148    SDL_Color fcol = { 0xff, 0xff, 0xff };
149    UINT16 ustr[16];
150150
151   ttffont = m_font;
151    ttffont = m_font;
152152
153   memset(ustr,0,sizeof(ustr));
154   ustr[0] = (UINT16)chnum;
155   drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol);
153    memset(ustr,0,sizeof(ustr));
154    ustr[0] = (UINT16)chnum;
155    drawsurf = TTF_RenderUNICODE_Solid(ttffont, ustr, fcol);
156156
157   // was nothing returned?
158   if (drawsurf)
159   {
160      // allocate a MAME destination bitmap
161      bitmap.allocate(drawsurf->w, drawsurf->h);
157    // was nothing returned?
158    if (drawsurf)
159    {
160        // allocate a MAME destination bitmap
161        bitmap.allocate(drawsurf->w, drawsurf->h);
162162
163      // copy the rendered character image into it
164      for (int y = 0; y < bitmap.height(); y++)
165      {
166         UINT32 *dstrow = &bitmap.pix32(y);
167         UINT8 *srcrow = (UINT8 *)drawsurf->pixels;
163        // copy the rendered character image into it
164        for (int y = 0; y < bitmap.height(); y++)
165        {
166            UINT32 *dstrow = &bitmap.pix32(y);
167            UINT8 *srcrow = (UINT8 *)drawsurf->pixels;
168168
169         srcrow += (y * drawsurf->pitch);
169            srcrow += (y * drawsurf->pitch);
170170
171         for (int x = 0; x < drawsurf->w; x++)
172         {
173            dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff);
174         }
175      }
171            for (int x = 0; x < drawsurf->w; x++)
172            {
173                dstrow[x] = srcrow[x] ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff);
174            }
175        }
176176
177      // what are these?
178      xoffs = yoffs = 0;
179      width = drawsurf->w;
177        // what are these?
178        xoffs = yoffs = 0;
179        width = drawsurf->w;
180180
181      SDL_FreeSurface(drawsurf);
182   }
181        SDL_FreeSurface(drawsurf);
182    }
183183
184   return bitmap.valid();
184    return bitmap.valid();
185185}
186186
187187TTF_Font * osd_font_sdl::TTF_OpenFont_Magic(astring name, int fsize)
188188{
189   emu_file file(OPEN_FLAG_READ);
190   if (file.open(name) == FILERR_NONE)
191   {
192      unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
193      unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 };
194      file.read(buffer,5);
195      if (memcmp(buffer, magic, 5))
196         return NULL;
197   }
198   return TTF_OpenFont(name.cstr(), POINT_SIZE);
189    emu_file file(OPEN_FLAG_READ);
190    if (file.open(name) == FILERR_NONE)
191    {
192        unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
193        unsigned char magic[5] = { 0x00, 0x01, 0x00, 0x00, 0x00 };
194        file.read(buffer,5);
195        if (memcmp(buffer, magic, 5))
196            return NULL;
197    }
198    return TTF_OpenFont(name.cstr(), POINT_SIZE);
199199}
200200
201201bool osd_font_sdl::BDF_Check_Magic(astring name)
202202{
203   emu_file file(OPEN_FLAG_READ);
204   if (file.open(name) == FILERR_NONE)
205   {
206      unsigned char buffer[9];
207      unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' };
208      file.read(buffer, 9);
209      file.close();
210      if (!memcmp(buffer, magic, 9))
211         return true;
212   }
203    emu_file file(OPEN_FLAG_READ);
204    if (file.open(name) == FILERR_NONE)
205    {
206        unsigned char buffer[9];
207        unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' };
208        file.read(buffer, 9);
209        file.close();
210        if (!memcmp(buffer, magic, 9))
211            return true;
212    }
213213
214   return false;
214    return false;
215215}
216216
217217#ifndef SDLMAME_HAIKU
218218TTF_Font *osd_font_sdl::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles)
219219{
220   TTF_Font *font = (TTF_Font *)NULL;
221   FcConfig *config;
222   FcPattern *pat;
223   FcObjectSet *os;
224   FcFontSet *fontset;
225   FcValue val;
220    TTF_Font *font = (TTF_Font *)NULL;
221    FcConfig *config;
222    FcPattern *pat;
223    FcObjectSet *os;
224    FcFontSet *fontset;
225    FcValue val;
226226
227   config = FcConfigGetCurrent();
228   pat = FcPatternCreate();
229   os = FcObjectSetCreate();
230   FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
227    config = FcConfigGetCurrent();
228    pat = FcPatternCreate();
229    os = FcObjectSetCreate();
230    FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
231231
232   // try and get a font with the requested styles baked-in
233   if (bold)
234   {
235      if (italic)
236      {
237         FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic");
238      }
239      else
240      {
241         FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold");
242      }
243   }
244   else if (italic)
245   {
246      FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic");
247   }
248   else
249   {
250      FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
251   }
232    // try and get a font with the requested styles baked-in
233    if (bold)
234    {
235        if (italic)
236        {
237            FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold Italic");
238        }
239        else
240        {
241            FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Bold");
242        }
243    }
244    else if (italic)
245    {
246        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Italic");
247    }
248    else
249    {
250        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
251    }
252252
253   FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
253    FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
254254
255   FcObjectSetAdd(os, FC_FILE);
256   fontset = FcFontList(config, pat, os);
255    FcObjectSetAdd(os, FC_FILE);
256    fontset = FcFontList(config, pat, os);
257257
258   for (int i = 0; i < fontset->nfont; i++)
259   {
260      if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
261      {
262         continue;
263      }
258    for (int i = 0; i < fontset->nfont; i++)
259    {
260        if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
261        {
262            continue;
263        }
264264
265      if (val.type != FcTypeString)
266      {
267         continue;
268      }
265        if (val.type != FcTypeString)
266        {
267            continue;
268        }
269269
270      osd_printf_verbose("Matching font: %s\n", val.u.s);
271      {
272         astring match_name((const char*)val.u.s);
273         font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
274      }
270        osd_printf_verbose("Matching font: %s\n", val.u.s);
271        {
272            astring match_name((const char*)val.u.s);
273            font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
274        }
275275
276      if (font)
277      {
278         bakedstyles = true;
279         break;
280      }
281   }
276        if (font)
277        {
278            bakedstyles = true;
279            break;
280        }
281    }
282282
283   // didn't get a font above?  try again with no baked-in styles
284   if (!font)
285   {
286      FcPatternDestroy(pat);
287      FcFontSetDestroy(fontset);
283    // didn't get a font above?  try again with no baked-in styles
284    if (!font)
285    {
286        FcPatternDestroy(pat);
287        FcFontSetDestroy(fontset);
288288
289      pat = FcPatternCreate();
290      FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
291      FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
292      FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
293      fontset = FcFontList(config, pat, os);
289        pat = FcPatternCreate();
290        FcPatternAddString(pat, FC_FAMILY, (const FcChar8 *)name.cstr());
291        FcPatternAddString(pat, FC_STYLE, (const FcChar8 *)"Regular");
292        FcPatternAddString(pat, FC_FONTFORMAT, (const FcChar8 *)"TrueType");
293        fontset = FcFontList(config, pat, os);
294294
295      for (int i = 0; i < fontset->nfont; i++)
296      {
297         if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
298         {
299            continue;
300         }
295        for (int i = 0; i < fontset->nfont; i++)
296        {
297            if (FcPatternGet(fontset->fonts[i], FC_FILE, 0, &val) != FcResultMatch)
298            {
299                continue;
300            }
301301
302         if (val.type != FcTypeString)
303         {
304            continue;
305         }
302            if (val.type != FcTypeString)
303            {
304                continue;
305            }
306306
307         osd_printf_verbose("Matching unstyled font: %s\n", val.u.s);
308         {
309            astring match_name((const char*)val.u.s);
310            font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
311         }
307            osd_printf_verbose("Matching unstyled font: %s\n", val.u.s);
308            {
309                astring match_name((const char*)val.u.s);
310                font = TTF_OpenFont_Magic(match_name, POINT_SIZE);
311            }
312312
313         if (font)
314         {
315            break;
316         }
317      }
318   }
313            if (font)
314            {
315                break;
316            }
317        }
318    }
319319
320   FcPatternDestroy(pat);
321   FcObjectSetDestroy(os);
322   FcFontSetDestroy(fontset);
323   return font;
320    FcPatternDestroy(pat);
321    FcObjectSetDestroy(os);
322    FcFontSetDestroy(fontset);
323    return font;
324324}
325325#endif
326326
r243230r243231
328328class font_sdl : public osd_module, public font_module
329329{
330330public:
331   font_sdl()
332   : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module()
333   {
334   }
331    font_sdl()
332    : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module()
333    {
334    }
335335
336   osd_font *font_alloc()
337   {
338      return global_alloc(osd_font_sdl);
339   }
336    osd_font *font_alloc()
337    {
338        return global_alloc(osd_font_sdl);
339    }
340340
341   int init()
342   {
343      if (TTF_Init() == -1)
344      {
345         osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError());
346         return -1;
347      }
348      return 0;
349   }
341    int init()
342    {
343        if (TTF_Init() == -1)
344        {
345            osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError());
346            return -1;
347        }
348        return 0;
349    }
350350
351   virtual void exit()
352   {
353      TTF_Quit();
354   }
351    virtual void exit()
352    {
353        TTF_Quit();
354    }
355355};
356356#else /* SDLMAME_UNIX */
357   MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl")
357    MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl")
358358#endif
359359
360360MODULE_DEFINITION(FONT_SDL, font_sdl)
361
362
trunk/src/osd/modules/font/font_windows.c
r243230r243231
3434class osd_font_windows : public osd_font
3535{
3636public:
37   virtual ~osd_font_windows() {};
37    virtual ~osd_font_windows() {};
3838
39   virtual bool open(const char *font_path, const char *name, int &height);
40   virtual void close();
41   virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
39    virtual bool open(const char *font_path, const char *name, int &height);
40    virtual void close();
41    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
4242private:
43   HGDIOBJ m_font;
43    HGDIOBJ m_font;
4444};
4545
4646bool osd_font_windows::open(const char *font_path, const char *_name, int &height)
4747{
48   // accept qualifiers from the name
49   astring name(_name);
50   if (name == "default") name = "Tahoma";
51   bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0);
52   bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0);
48    // accept qualifiers from the name
49    astring name(_name);
50    if (name == "default") name = "Tahoma";
51    bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0);
52    bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0);
5353
54   // build a basic LOGFONT description of what we want
55   LOGFONT logfont;
56   logfont.lfHeight = DEFAULT_FONT_HEIGHT;
57   logfont.lfWidth = 0;
58   logfont.lfEscapement = 0;
59   logfont.lfOrientation = 0;
60   logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM;
61   logfont.lfItalic = italic;
62   logfont.lfUnderline = FALSE;
63   logfont.lfStrikeOut = FALSE;
64   logfont.lfCharSet = ANSI_CHARSET;
65   logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
66   logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
67   logfont.lfQuality = NONANTIALIASED_QUALITY;
68   logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
54    // build a basic LOGFONT description of what we want
55    LOGFONT logfont;
56    logfont.lfHeight = DEFAULT_FONT_HEIGHT;
57    logfont.lfWidth = 0;
58    logfont.lfEscapement = 0;
59    logfont.lfOrientation = 0;
60    logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM;
61    logfont.lfItalic = italic;
62    logfont.lfUnderline = FALSE;
63    logfont.lfStrikeOut = FALSE;
64    logfont.lfCharSet = ANSI_CHARSET;
65    logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
66    logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
67    logfont.lfQuality = NONANTIALIASED_QUALITY;
68    logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
6969
70   // copy in the face name
71   TCHAR *face = tstring_from_utf8(name);
72   _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR));
73   logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0;
74   osd_free(face);
70    // copy in the face name
71    TCHAR *face = tstring_from_utf8(name);
72    _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR));
73    logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0;
74    osd_free(face);
7575
76   // create the font
77   height = logfont.lfHeight;
78   m_font = CreateFontIndirect(&logfont);
79   if (m_font == NULL)
80      return false;
76    // create the font
77    height = logfont.lfHeight;
78    m_font = CreateFontIndirect(&logfont);
79    if (m_font == NULL)
80        return false;
8181
82   // select it into a temp DC and get the real font name
83   HDC dummyDC = CreateCompatibleDC(NULL);
84   HGDIOBJ oldfont = SelectObject(dummyDC, m_font);
85   TCHAR realname[100];
86   GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname);
87   SelectObject(dummyDC, oldfont);
88   DeleteDC(dummyDC);
82    // select it into a temp DC and get the real font name
83    HDC dummyDC = CreateCompatibleDC(NULL);
84    HGDIOBJ oldfont = SelectObject(dummyDC, m_font);
85    TCHAR realname[100];
86    GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname);
87    SelectObject(dummyDC, oldfont);
88    DeleteDC(dummyDC);
8989
90   // if it doesn't match our request, fail
91   char *utf = utf8_from_tstring(realname);
92   int result = core_stricmp(utf, name);
93   osd_free(utf);
90    // if it doesn't match our request, fail
91    char *utf = utf8_from_tstring(realname);
92    int result = core_stricmp(utf, name);
93    osd_free(utf);
9494
95   // if we didn't match, nuke our font and fall back
96   if (result != 0)
97   {
98      DeleteObject(m_font);
99      m_font = NULL;
100      return false;
101   }
102   return true;
95    // if we didn't match, nuke our font and fall back
96    if (result != 0)
97    {
98        DeleteObject(m_font);
99        m_font = NULL;
100        return false;
101    }
102    return true;
103103}
104104
105105//-------------------------------------------------
r243230r243231
109109
110110void osd_font_windows::close()
111111{
112   // delete the font ojbect
113   if (m_font != NULL)
114      DeleteObject(m_font);
112    // delete the font ojbect
113    if (m_font != NULL)
114        DeleteObject(m_font);
115115
116116}
117117
r243230r243231
125125
126126bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
127127{
128   // create a dummy DC to work with
129   HDC dummyDC = CreateCompatibleDC(NULL);
130   HGDIOBJ oldfont = SelectObject(dummyDC, m_font);
128    // create a dummy DC to work with
129    HDC dummyDC = CreateCompatibleDC(NULL);
130    HGDIOBJ oldfont = SelectObject(dummyDC, m_font);
131131
132   // get the text metrics
133   TEXTMETRIC metrics = { 0 };
134   GetTextMetrics(dummyDC, &metrics);
132    // get the text metrics
133    TEXTMETRIC metrics = { 0 };
134    GetTextMetrics(dummyDC, &metrics);
135135
136   // get the width of this character
137   ABC abc;
138   if (!GetCharABCWidths(dummyDC, chnum, chnum, &abc))
139   {
140      abc.abcA = 0;
141      abc.abcC = 0;
142      GetCharWidth32(dummyDC, chnum, chnum, reinterpret_cast<LPINT>(&abc.abcB));
143   }
144   width = abc.abcA + abc.abcB + abc.abcC;
136    // get the width of this character
137    ABC abc;
138    if (!GetCharABCWidths(dummyDC, chnum, chnum, &abc))
139    {
140        abc.abcA = 0;
141        abc.abcC = 0;
142        GetCharWidth32(dummyDC, chnum, chnum, reinterpret_cast<LPINT>(&abc.abcB));
143    }
144    width = abc.abcA + abc.abcB + abc.abcC;
145145
146   // determine desired bitmap size
147   int bmwidth = (50 + abc.abcA + abc.abcB + abc.abcC + 50 + 31) & ~31;
148   int bmheight = 50 + metrics.tmHeight + 50;
146    // determine desired bitmap size
147    int bmwidth = (50 + abc.abcA + abc.abcB + abc.abcC + 50 + 31) & ~31;
148    int bmheight = 50 + metrics.tmHeight + 50;
149149
150   // describe the bitmap we want
151   BYTE bitmapinfodata[sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)] = { 0 };
152   BITMAPINFO &info = *reinterpret_cast<BITMAPINFO *>(bitmapinfodata);
153   info.bmiHeader.biSize = sizeof(info.bmiHeader);
154   info.bmiHeader.biWidth = bmwidth;
155   info.bmiHeader.biHeight = -bmheight;
156   info.bmiHeader.biPlanes = 1;
157   info.bmiHeader.biBitCount = 1;
158   info.bmiHeader.biCompression = BI_RGB;
159   info.bmiHeader.biSizeImage = 0;
160   info.bmiHeader.biXPelsPerMeter = GetDeviceCaps(dummyDC, HORZRES) / GetDeviceCaps(dummyDC, HORZSIZE);
161   info.bmiHeader.biYPelsPerMeter = GetDeviceCaps(dummyDC, VERTRES) / GetDeviceCaps(dummyDC, VERTSIZE);
162   info.bmiHeader.biClrUsed = 0;
163   info.bmiHeader.biClrImportant = 0;
164   RGBQUAD col1 = info.bmiColors[0];
165   RGBQUAD col2 = info.bmiColors[1];
166   col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00;
167   col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff;
150    // describe the bitmap we want
151    BYTE bitmapinfodata[sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)] = { 0 };
152    BITMAPINFO &info = *reinterpret_cast<BITMAPINFO *>(bitmapinfodata);
153    info.bmiHeader.biSize = sizeof(info.bmiHeader);
154    info.bmiHeader.biWidth = bmwidth;
155    info.bmiHeader.biHeight = -bmheight;
156    info.bmiHeader.biPlanes = 1;
157    info.bmiHeader.biBitCount = 1;
158    info.bmiHeader.biCompression = BI_RGB;
159    info.bmiHeader.biSizeImage = 0;
160    info.bmiHeader.biXPelsPerMeter = GetDeviceCaps(dummyDC, HORZRES) / GetDeviceCaps(dummyDC, HORZSIZE);
161    info.bmiHeader.biYPelsPerMeter = GetDeviceCaps(dummyDC, VERTRES) / GetDeviceCaps(dummyDC, VERTSIZE);
162    info.bmiHeader.biClrUsed = 0;
163    info.bmiHeader.biClrImportant = 0;
164    RGBQUAD col1 = info.bmiColors[0];
165    RGBQUAD col2 = info.bmiColors[1];
166    col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00;
167    col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff;
168168
169   // create a DIB to render to
170   BYTE *bits;
171   HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0);
172   HGDIOBJ oldbitmap = SelectObject(dummyDC, dib);
169    // create a DIB to render to
170    BYTE *bits;
171    HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0);
172    HGDIOBJ oldbitmap = SelectObject(dummyDC, dib);
173173
174   // clear the bitmap
175   int rowbytes = bmwidth / 8;
176   memset(bits, 0, rowbytes * bmheight);
174    // clear the bitmap
175    int rowbytes = bmwidth / 8;
176    memset(bits, 0, rowbytes * bmheight);
177177
178   // now draw the character
179   WCHAR tempchar = chnum;
180   SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff));
181   SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00));
182   ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL);
178    // now draw the character
179    WCHAR tempchar = chnum;
180    SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff));
181    SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00));
182    ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL);
183183
184   // characters are expected to be full-height
185   rectangle actbounds;
186   actbounds.min_y = 50;
187   actbounds.max_y = 50 + metrics.tmHeight - 1;
184    // characters are expected to be full-height
185    rectangle actbounds;
186    actbounds.min_y = 50;
187    actbounds.max_y = 50 + metrics.tmHeight - 1;
188188
189   // determine the actual left of the character
190   for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++)
191   {
192      BYTE *offs = bits + actbounds.min_x;
193      UINT8 summary = 0;
194      for (int y = 0; y < bmheight; y++)
195         summary |= offs[y * rowbytes];
196      if (summary != 0)
197      {
198         actbounds.min_x *= 8;
199         if (!(summary & 0x80)) actbounds.min_x++;
200         if (!(summary & 0xc0)) actbounds.min_x++;
201         if (!(summary & 0xe0)) actbounds.min_x++;
202         if (!(summary & 0xf0)) actbounds.min_x++;
203         if (!(summary & 0xf8)) actbounds.min_x++;
204         if (!(summary & 0xfc)) actbounds.min_x++;
205         if (!(summary & 0xfe)) actbounds.min_x++;
206         break;
207      }
208   }
189    // determine the actual left of the character
190    for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++)
191    {
192        BYTE *offs = bits + actbounds.min_x;
193        UINT8 summary = 0;
194        for (int y = 0; y < bmheight; y++)
195            summary |= offs[y * rowbytes];
196        if (summary != 0)
197        {
198            actbounds.min_x *= 8;
199            if (!(summary & 0x80)) actbounds.min_x++;
200            if (!(summary & 0xc0)) actbounds.min_x++;
201            if (!(summary & 0xe0)) actbounds.min_x++;
202            if (!(summary & 0xf0)) actbounds.min_x++;
203            if (!(summary & 0xf8)) actbounds.min_x++;
204            if (!(summary & 0xfc)) actbounds.min_x++;
205            if (!(summary & 0xfe)) actbounds.min_x++;
206            break;
207        }
208    }
209209
210   // determine the actual right of the character
211   for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--)
212   {
213      BYTE *offs = bits + actbounds.max_x;
214      UINT8 summary = 0;
215      for (int y = 0; y < bmheight; y++)
216         summary |= offs[y * rowbytes];
217      if (summary != 0)
218      {
219         actbounds.max_x *= 8;
220         if (summary & 0x7f) actbounds.max_x++;
221         if (summary & 0x3f) actbounds.max_x++;
222         if (summary & 0x1f) actbounds.max_x++;
223         if (summary & 0x0f) actbounds.max_x++;
224         if (summary & 0x07) actbounds.max_x++;
225         if (summary & 0x03) actbounds.max_x++;
226         if (summary & 0x01) actbounds.max_x++;
227         break;
228      }
229   }
210    // determine the actual right of the character
211    for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--)
212    {
213        BYTE *offs = bits + actbounds.max_x;
214        UINT8 summary = 0;
215        for (int y = 0; y < bmheight; y++)
216            summary |= offs[y * rowbytes];
217        if (summary != 0)
218        {
219            actbounds.max_x *= 8;
220            if (summary & 0x7f) actbounds.max_x++;
221            if (summary & 0x3f) actbounds.max_x++;
222            if (summary & 0x1f) actbounds.max_x++;
223            if (summary & 0x0f) actbounds.max_x++;
224            if (summary & 0x07) actbounds.max_x++;
225            if (summary & 0x03) actbounds.max_x++;
226            if (summary & 0x01) actbounds.max_x++;
227            break;
228        }
229    }
230230
231   // allocate a new bitmap
232   if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y)
233   {
234      bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y);
231    // allocate a new bitmap
232    if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y)
233    {
234        bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y);
235235
236      // copy the bits into it
237      for (int y = 0; y < bitmap.height(); y++)
238      {
239         UINT32 *dstrow = &bitmap.pix32(y);
240         UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes];
241         for (int x = 0; x < bitmap.width(); x++)
242         {
243            int effx = x + actbounds.min_x;
244            dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff);
245         }
246      }
236        // copy the bits into it
237        for (int y = 0; y < bitmap.height(); y++)
238        {
239            UINT32 *dstrow = &bitmap.pix32(y);
240            UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes];
241            for (int x = 0; x < bitmap.width(); x++)
242            {
243                int effx = x + actbounds.min_x;
244                dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff);
245            }
246        }
247247
248      // set the final offset values
249      xoffs = actbounds.min_x - (50 + abc.abcA);
250      yoffs = actbounds.max_y - (50 + metrics.tmAscent);
251   }
248        // set the final offset values
249        xoffs = actbounds.min_x - (50 + abc.abcA);
250        yoffs = actbounds.max_y - (50 + metrics.tmAscent);
251    }
252252
253   // de-select the font and release the DC
254   SelectObject(dummyDC, oldbitmap);
255   DeleteObject(dib);
256   SelectObject(dummyDC, oldfont);
257   DeleteDC(dummyDC);
258   return bitmap.valid();
253    // de-select the font and release the DC
254    SelectObject(dummyDC, oldbitmap);
255    DeleteObject(dib);
256    SelectObject(dummyDC, oldfont);
257    DeleteDC(dummyDC);
258    return bitmap.valid();
259259}
260260
261261class font_win : public osd_module, public font_module
262262{
263263public:
264   font_win()
265   : osd_module(OSD_FONT_PROVIDER, "win"), font_module()
266   {
267   }
264    font_win()
265    : osd_module(OSD_FONT_PROVIDER, "win"), font_module()
266    {
267    }
268268
269   osd_font *font_alloc()
270   {
271      return global_alloc(osd_font_windows);
272   }
269    osd_font *font_alloc()
270    {
271        return global_alloc(osd_font_windows);
272    }
273273
274274};
275275#else /* SDLMAME_UNIX */
276   MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win")
276    MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win")
277277#endif
278278
279279MODULE_DEFINITION(FONT_WINDOWS, font_win)
trunk/src/osd/modules/lib/osdlib_macosx.c
r243230r243231
3434
3535const char *osd_getenv(const char *name)
3636{
37   return getenv(name);
37    return getenv(name);
3838}
3939
4040//============================================================
r243230r243231
4343
4444int osd_setenv(const char *name, const char *value, int overwrite)
4545{
46   return setenv(name, value, overwrite);
46    return setenv(name, value, overwrite);
4747}
4848
4949//============================================================
r243230r243231
5252
5353void osd_process_kill(void)
5454{
55   kill(getpid(), SIGKILL);
55    kill(getpid(), SIGKILL);
5656}
5757
5858//============================================================
r243230r243231
6161
6262int osd_get_num_processors(void)
6363{
64   int processors = 1;
64    int processors = 1;
6565
66   struct host_basic_info host_basic_info;
67   unsigned int count;
68   kern_return_t r;
69   mach_port_t my_mach_host_self;
66    struct host_basic_info host_basic_info;
67    unsigned int count;
68    kern_return_t r;
69    mach_port_t my_mach_host_self;
7070
71   count = HOST_BASIC_INFO_COUNT;
72   my_mach_host_self = mach_host_self();
73   if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS )
74   {
75      processors = host_basic_info.avail_cpus;
76   }
77   mach_port_deallocate(mach_task_self(), my_mach_host_self);
71    count = HOST_BASIC_INFO_COUNT;
72    my_mach_host_self = mach_host_self();
73    if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS )
74    {
75        processors = host_basic_info.avail_cpus;
76    }
77    mach_port_deallocate(mach_task_self(), my_mach_host_self);
7878
79   return processors;
79    return processors;
8080}
8181
8282//============================================================
r243230r243231
8686void *osd_malloc(size_t size)
8787{
8888#ifndef MALLOC_DEBUG
89   return malloc(size);
89    return malloc(size);
9090#else
9191#error "MALLOC_DEBUG not yet supported"
9292#endif
r243230r243231
100100void *osd_malloc_array(size_t size)
101101{
102102#ifndef MALLOC_DEBUG
103   return malloc(size);
103    return malloc(size);
104104#else
105105#error "MALLOC_DEBUG not yet supported"
106106#endif
r243230r243231
114114void osd_free(void *ptr)
115115{
116116#ifndef MALLOC_DEBUG
117   free(ptr);
117    free(ptr);
118118#else
119119#error "MALLOC_DEBUG not yet supported"
120120#endif
r243230r243231
131131void *osd_alloc_executable(size_t size)
132132{
133133#if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX)
134   return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
134    return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
135135#elif defined(SDLMAME_UNIX)
136   return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0);
136    return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0);
137137#endif
138138}
139139
r243230r243231
146146void osd_free_executable(void *ptr, size_t size)
147147{
148148#ifdef SDLMAME_SOLARIS
149   munmap((char *)ptr, size);
149    munmap((char *)ptr, size);
150150#else
151   munmap(ptr, size);
151    munmap(ptr, size);
152152#endif
153153}
154154
r243230r243231
158158
159159void osd_break_into_debugger(const char *message)
160160{
161   #ifdef MAME_DEBUG
162   printf("MAME exception: %s\n", message);
163   printf("Attempting to fall into debugger\n");
164   kill(getpid(), SIGTRAP);
165   #else
166   printf("Ignoring MAME exception: %s\n", message);
167   #endif
161    #ifdef MAME_DEBUG
162    printf("MAME exception: %s\n", message);
163    printf("Attempting to fall into debugger\n");
164    kill(getpid(), SIGTRAP);
165    #else
166    printf("Ignoring MAME exception: %s\n", message);
167    #endif
168168}
169169
170170
r243230r243231
191191
192192static osd_ticks_t init_cycle_counter(void)
193193{
194   osd_ticks_t start, end;
195   osd_ticks_t a, b;
194    osd_ticks_t start, end;
195    osd_ticks_t a, b;
196196
197   cycle_counter = mach_cycle_counter;
198   ticks_counter = mach_cycle_counter;
197    cycle_counter = mach_cycle_counter;
198    ticks_counter = mach_cycle_counter;
199199
200   // wait for an edge on the timeGetTime call
201   a = SDL_GetTicks();
202   do
203   {
204      b = SDL_GetTicks();
205   } while (a == b);
200    // wait for an edge on the timeGetTime call
201    a = SDL_GetTicks();
202    do
203    {
204        b = SDL_GetTicks();
205    } while (a == b);
206206
207   // get the starting cycle count
208   start = (*cycle_counter)();
207    // get the starting cycle count
208    start = (*cycle_counter)();
209209
210   // now wait for 1/4 second total
211   do
212   {
213      a = SDL_GetTicks();
214   } while (a - b < 250);
210    // now wait for 1/4 second total
211    do
212    {
213        a = SDL_GetTicks();
214    } while (a - b < 250);
215215
216   // get the ending cycle count
217   end = (*cycle_counter)();
216    // get the ending cycle count
217    end = (*cycle_counter)();
218218
219   // compute ticks_per_sec
220   ticks_per_second = (end - start) * 4;
219    // compute ticks_per_sec
220    ticks_per_second = (end - start) * 4;
221221
222   // return the current cycle count
223   return (*cycle_counter)();
222    // return the current cycle count
223    return (*cycle_counter)();
224224}
225225
226226//============================================================
r243230r243231
232232//============================================================
233233static osd_ticks_t mach_cycle_counter(void)
234234{
235   return mach_absolute_time();
235    return mach_absolute_time();
236236}
237237
238238//============================================================
r243230r243231
241241
242242osd_ticks_t osd_ticks(void)
243243{
244   return (*cycle_counter)();
244    return (*cycle_counter)();
245245}
246246
247247
r243230r243231
251251
252252osd_ticks_t osd_ticks_per_second(void)
253253{
254   if (ticks_per_second == 0)
255   {
256      // if we haven't computed the value yet, there's no time like the present
257      init_cycle_counter();
258   }
259   return ticks_per_second;
254    if (ticks_per_second == 0)
255    {
256        // if we haven't computed the value yet, there's no time like the present
257        init_cycle_counter();
258    }
259    return ticks_per_second;
260260}
261261
262262
r243230r243231
267267
268268void osd_sleep(osd_ticks_t duration)
269269{
270   UINT32 msec;
270    UINT32 msec;
271271
272   // make sure we've computed ticks_per_second
273   if (ticks_per_second == 0)
274      (void)osd_ticks();
272    // make sure we've computed ticks_per_second
273    if (ticks_per_second == 0)
274        (void)osd_ticks();
275275
276   // convert to milliseconds, rounding down
277   msec = (UINT32)(duration * 1000 / ticks_per_second);
276    // convert to milliseconds, rounding down
277    msec = (UINT32)(duration * 1000 / ticks_per_second);
278278
279   // only sleep if at least 2 full milliseconds
280   if (msec >= 2)
281   {
282      // take a couple of msecs off the top for good measure
283      msec -= 2;
284      usleep(msec*1000);
285   }
279    // only sleep if at least 2 full milliseconds
280    if (msec >= 2)
281    {
282        // take a couple of msecs off the top for good measure
283        msec -= 2;
284        usleep(msec*1000);
285    }
286286}
trunk/src/osd/modules/lib/osdlib_os2.c
r243230r243231
3131
3232const char *osd_getenv(const char *name)
3333{
34   return getenv(name);
34    return getenv(name);
3535}
3636
3737//============================================================
r243230r243231
4040
4141int osd_setenv(const char *name, const char *value, int overwrite)
4242{
43   return setenv(name, value, overwrite);
43    return setenv(name, value, overwrite);
4444}
4545
4646//============================================================
r243230r243231
4949
5050void osd_process_kill(void)
5151{
52   fprintf(stderr,"osd_process_kill missing in OS/2 build\n");
52    fprintf(stderr,"osd_process_kill missing in OS/2 build\n");
5353}
5454
5555//============================================================
r243230r243231
5858
5959int osd_get_num_processors(void)
6060{
61   ULONG numprocs = 1;
61    ULONG numprocs = 1;
6262
63   DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs));
63    DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs));
6464
65   return numprocs;
65    return numprocs;
6666}
6767
6868//============================================================
r243230r243231
7272void *osd_malloc(size_t size)
7373{
7474#ifndef MALLOC_DEBUG
75   return malloc(size);
75    return malloc(size);
7676#else
7777#error "MALLOC_DEBUG not yet supported"
7878#endif
r243230r243231
8686void *osd_malloc_array(size_t size)
8787{
8888#ifndef MALLOC_DEBUG
89   return malloc(size);
89    return malloc(size);
9090#else
9191#error "MALLOC_DEBUG not yet supported"
9292#endif
r243230r243231
100100void osd_free(void *ptr)
101101{
102102#ifndef MALLOC_DEBUG
103   free(ptr);
103    free(ptr);
104104#else
105105#error "MALLOC_DEBUG not yet supported"
106106#endif
r243230r243231
116116
117117void *osd_alloc_executable(size_t size)
118118{
119   void *p;
119    void *p;
120120
121   DosAllocMem( &p, size, fALLOC );
122   return p;
121    DosAllocMem( &p, size, fALLOC );
122    return p;
123123}
124124
125125//============================================================
r243230r243231
130130
131131void osd_free_executable(void *ptr, size_t size)
132132{
133   DosFreeMem( ptr );
133    DosFreeMem( ptr );
134134}
135135
136136//============================================================
r243230r243231
139139
140140void osd_break_into_debugger(const char *message)
141141{
142   printf("Ignoring MAME exception: %s\n", message);
142    printf("Ignoring MAME exception: %s\n", message);
143143}
144144
145145//============================================================
r243230r243231
167167
168168static osd_ticks_t init_cycle_counter(void)
169169{
170   osd_ticks_t start, end;
171   osd_ticks_t a, b;
170    osd_ticks_t start, end;
171    osd_ticks_t a, b;
172172
173   ULONG  frequency;
174   PTIB   ptib;
175   ULONG  ulClass;
176   ULONG  ulDelta;
173    ULONG  frequency;
174    PTIB   ptib;
175    ULONG  ulClass;
176    ULONG  ulDelta;
177177
178   DosGetInfoBlocks( &ptib, NULL );
179   ulClass = HIBYTE( ptib->tib_ptib2->tib2_ulpri );
180   ulDelta = LOBYTE( ptib->tib_ptib2->tib2_ulpri );
178    DosGetInfoBlocks( &ptib, NULL );
179    ulClass = HIBYTE( ptib->tib_ptib2->tib2_ulpri );
180    ulDelta = LOBYTE( ptib->tib_ptib2->tib2_ulpri );
181181
182   if ( DosTmrQueryFreq( &frequency ) == 0 )
183   {
184      // use performance counter if available as it is constant
185      cycle_counter = performance_cycle_counter;
186      ticks_counter = performance_cycle_counter;
182    if ( DosTmrQueryFreq( &frequency ) == 0 )
183    {
184        // use performance counter if available as it is constant
185        cycle_counter = performance_cycle_counter;
186        ticks_counter = performance_cycle_counter;
187187
188      ticks_per_second = frequency;
188        ticks_per_second = frequency;
189189
190      // return the current cycle count
191      return (*cycle_counter)();
192   }
193   else
194   {
195      fprintf(stderr, "No Timer available!\n");
196      exit(-1);
197   }
190        // return the current cycle count
191        return (*cycle_counter)();
192    }
193    else
194    {
195        fprintf(stderr, "No Timer available!\n");
196        exit(-1);
197    }
198198
199   // temporarily set our priority higher
200   DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 );
199    // temporarily set our priority higher
200    DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 );
201201
202   // wait for an edge on the timeGetTime call
203   a = SDL_GetTicks();
204   do
205   {
206      b = SDL_GetTicks();
207   } while (a == b);
202    // wait for an edge on the timeGetTime call
203    a = SDL_GetTicks();
204    do
205    {
206        b = SDL_GetTicks();
207    } while (a == b);
208208
209   // get the starting cycle count
210   start = (*cycle_counter)();
209    // get the starting cycle count
210    start = (*cycle_counter)();
211211
212   // now wait for 1/4 second total
213   do
214   {
215      a = SDL_GetTicks();
216   } while (a - b < 250);
212    // now wait for 1/4 second total
213    do
214    {
215        a = SDL_GetTicks();
216    } while (a - b < 250);
217217
218   // get the ending cycle count
219   end = (*cycle_counter)();
218    // get the ending cycle count
219    end = (*cycle_counter)();
220220
221   // compute ticks_per_sec
222   ticks_per_second = (end - start) * 4;
221    // compute ticks_per_sec
222    ticks_per_second = (end - start) * 4;
223223
224   // restore our priority
225   DosSetPriority( PRTYS_THREAD, ulClass, ulDelta, 0 );
224    // restore our priority
225    DosSetPriority( PRTYS_THREAD, ulClass, ulDelta, 0 );
226226
227   // return the current cycle count
228   return (*cycle_counter)();
227    // return the current cycle count
228    return (*cycle_counter)();
229229}
230230
231231//============================================================
r243230r243231
234234
235235static osd_ticks_t performance_cycle_counter(void)
236236{
237   QWORD qwTime;
237    QWORD qwTime;
238238
239   DosTmrQueryTime( &qwTime );
240   return (osd_ticks_t)qwTime.ulLo;
239    DosTmrQueryTime( &qwTime );
240    return (osd_ticks_t)qwTime.ulLo;
241241}
242242
243243//============================================================
r243230r243231
246246
247247osd_ticks_t osd_ticks(void)
248248{
249   return (*cycle_counter)();
249    return (*cycle_counter)();
250250}
251251
252252
r243230r243231
256256
257257osd_ticks_t osd_ticks_per_second(void)
258258{
259   if (ticks_per_second == 0)
260   {
261      // if we haven't computed the value yet, there's no time like the present
262      init_cycle_counter();
263   }
264   return ticks_per_second;
259    if (ticks_per_second == 0)
260    {
261        // if we haven't computed the value yet, there's no time like the present
262        init_cycle_counter();
263    }
264    return ticks_per_second;
265265}
266266
267267
r243230r243231
271271
272272void osd_sleep(osd_ticks_t duration)
273273{
274   UINT32 msec;
274    UINT32 msec;
275275
276   // make sure we've computed ticks_per_second
277   if (ticks_per_second == 0)
278      (void)osd_ticks();
276    // make sure we've computed ticks_per_second
277    if (ticks_per_second == 0)
278        (void)osd_ticks();
279279
280   // convert to milliseconds, rounding down
281   msec = (UINT32)(duration * 1000 / ticks_per_second);
280    // convert to milliseconds, rounding down
281    msec = (UINT32)(duration * 1000 / ticks_per_second);
282282
283   // only sleep if at least 2 full milliseconds
284   if (msec >= 2)
285   {
286      // take a couple of msecs off the top for good measure
287      msec -= 2;
288      usleep(msec*1000);
289   }
283    // only sleep if at least 2 full milliseconds
284    if (msec >= 2)
285    {
286        // take a couple of msecs off the top for good measure
287        msec -= 2;
288        usleep(msec*1000);
289    }
290290}
291
trunk/src/osd/modules/lib/osdlib_unix.c
r243230r243231
3030
3131const char *osd_getenv(const char *name)
3232{
33   return getenv(name);
33    return getenv(name);
3434}
3535
3636//============================================================
r243230r243231
3939
4040int osd_setenv(const char *name, const char *value, int overwrite)
4141{
42   return setenv(name, value, overwrite);
42    return setenv(name, value, overwrite);
4343}
4444
4545//============================================================
r243230r243231
4848
4949void osd_process_kill(void)
5050{
51   kill(getpid(), SIGKILL);
51    kill(getpid(), SIGKILL);
5252}
5353
5454//============================================================
r243230r243231
5757
5858int osd_get_num_processors(void)
5959{
60   int processors = 1;
60    int processors = 1;
6161
6262#if defined(_SC_NPROCESSORS_ONLN)
63   processors = sysconf(_SC_NPROCESSORS_ONLN);
63    processors = sysconf(_SC_NPROCESSORS_ONLN);
6464#endif
65   return processors;
65    return processors;
6666}
6767
6868//============================================================
r243230r243231
7272void *osd_malloc(size_t size)
7373{
7474#ifndef MALLOC_DEBUG
75   return malloc(size);
75    return malloc(size);
7676#else
7777#error "MALLOC_DEBUG not yet supported"
7878#endif
r243230r243231
8686void *osd_malloc_array(size_t size)
8787{
8888#ifndef MALLOC_DEBUG
89   return malloc(size);
89    return malloc(size);
9090#else
9191#error "MALLOC_DEBUG not yet supported"
9292#endif
r243230r243231
100100void osd_free(void *ptr)
101101{
102102#ifndef MALLOC_DEBUG
103   free(ptr);
103    free(ptr);
104104#else
105105#error "MALLOC_DEBUG not yet supported"
106106#endif
r243230r243231
116116void *osd_alloc_executable(size_t size)
117117{
118118#if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX)
119   return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
119    return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
120120#elif defined(SDLMAME_UNIX)
121   return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0);
121    return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0);
122122#endif
123123}
124124
r243230r243231
131131void osd_free_executable(void *ptr, size_t size)
132132{
133133#ifdef SDLMAME_SOLARIS
134   munmap((char *)ptr, size);
134    munmap((char *)ptr, size);
135135#else
136   munmap(ptr, size);
136    munmap(ptr, size);
137137#endif
138138}
139139
r243230r243231
143143
144144void osd_break_into_debugger(const char *message)
145145{
146   #ifdef MAME_DEBUG
147   printf("MAME exception: %s\n", message);
148   printf("Attempting to fall into debugger\n");
149   kill(getpid(), SIGTRAP);
150   #else
151   printf("Ignoring MAME exception: %s\n", message);
152   #endif
146    #ifdef MAME_DEBUG
147    printf("MAME exception: %s\n", message);
148    printf("Attempting to fall into debugger\n");
149    kill(getpid(), SIGTRAP);
150    #else
151    printf("Ignoring MAME exception: %s\n", message);
152    #endif
153153}
154154
155155
r243230r243231
160160osd_ticks_t osd_ticks(void)
161161{
162162#ifdef SDLMAME_EMSCRIPTEN
163      return (osd_ticks_t)(emscripten_get_now() * 1000.0);
163        return (osd_ticks_t)(emscripten_get_now() * 1000.0);
164164#else
165      struct timeval    tp;
166      static osd_ticks_t start_sec = 0;
165        struct timeval    tp;
166        static osd_ticks_t start_sec = 0;
167167
168      gettimeofday(&tp, NULL);
169      if (start_sec==0)
170         start_sec = tp.tv_sec;
171      return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec;
168        gettimeofday(&tp, NULL);
169        if (start_sec==0)
170            start_sec = tp.tv_sec;
171        return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec;
172172#endif
173173}
174174
r243230r243231
179179
180180osd_ticks_t osd_ticks_per_second(void)
181181{
182   return (osd_ticks_t) 1000000;
182    return (osd_ticks_t) 1000000;
183183}
184184
185185//============================================================
r243230r243231
188188
189189void osd_sleep(osd_ticks_t duration)
190190{
191   UINT32 msec;
191    UINT32 msec;
192192
193   // convert to milliseconds, rounding down
194   msec = (UINT32)(duration * 1000 / osd_ticks_per_second());
193    // convert to milliseconds, rounding down
194    msec = (UINT32)(duration * 1000 / osd_ticks_per_second());
195195
196   // only sleep if at least 2 full milliseconds
197   if (msec >= 2)
198   {
199      // take a couple of msecs off the top for good measure
200      msec -= 2;
201      usleep(msec*1000);
202   }
196    // only sleep if at least 2 full milliseconds
197    if (msec >= 2)
198    {
199        // take a couple of msecs off the top for good measure
200        msec -= 2;
201        usleep(msec*1000);
202    }
203203}
trunk/src/osd/modules/lib/osdlib_win32.c
r243230r243231
5353
5454const char *osd_getenv(const char *name)
5555{
56   return getenv(name);
56    return getenv(name);
5757}
5858
5959
r243230r243231
6363
6464int osd_setenv(const char *name, const char *value, int overwrite)
6565{
66   char *buf;
67   int result;
66    char *buf;
67    int result;
6868
69   if (!overwrite)
70   {
71      if (osd_getenv(name) != NULL)
72         return 0;
73   }
74   buf = (char *) osd_malloc_array(strlen(name)+strlen(value)+2);
75   sprintf(buf, "%s=%s", name, value);
76   result = putenv(buf);
69    if (!overwrite)
70    {
71        if (osd_getenv(name) != NULL)
72            return 0;
73    }
74    buf = (char *) osd_malloc_array(strlen(name)+strlen(value)+2);
75    sprintf(buf, "%s=%s", name, value);
76    result = putenv(buf);
7777
78   /* will be referenced by environment
79    * Therefore it is not freed here
80    */
78    /* will be referenced by environment
79     * Therefore it is not freed here
80     */
8181
82   return result;
82    return result;
8383}
8484
8585//============================================================
r243230r243231
8888
8989void osd_process_kill(void)
9090{
91   TerminateProcess(GetCurrentProcess(), -1);
91    TerminateProcess(GetCurrentProcess(), -1);
9292}
9393
9494//============================================================
r243230r243231
9797
9898int osd_get_num_processors(void)
9999{
100   SYSTEM_INFO info;
100    SYSTEM_INFO info;
101101
102   // otherwise, fetch the info from the system
103   GetSystemInfo(&info);
102    // otherwise, fetch the info from the system
103    GetSystemInfo(&info);
104104
105   // max out at 4 for now since scaling above that seems to do poorly
106   return MIN(info.dwNumberOfProcessors, 4);
105    // max out at 4 for now since scaling above that seems to do poorly
106    return MIN(info.dwNumberOfProcessors, 4);
107107}
108108
109109//============================================================
r243230r243231
113113void *osd_malloc(size_t size)
114114{
115115#ifndef MALLOC_DEBUG
116   return HeapAlloc(GetProcessHeap(), 0, size);
116    return HeapAlloc(GetProcessHeap(), 0, size);
117117#else
118   // add in space for the size
119   size += sizeof(size_t);
118    // add in space for the size
119    size += sizeof(size_t);
120120
121   // basic objects just come from the heap
122   void *result = HeapAlloc(GetProcessHeap(), 0, size);
121    // basic objects just come from the heap
122    void *result = HeapAlloc(GetProcessHeap(), 0, size);
123123
124   // store the size and return and pointer to the data afterward
125   *reinterpret_cast<size_t *>(result) = size;
126   return reinterpret_cast<UINT8 *>(result) + sizeof(size_t);
124    // store the size and return and pointer to the data afterward
125    *reinterpret_cast<size_t *>(result) = size;
126    return reinterpret_cast<UINT8 *>(result) + sizeof(size_t);
127127#endif
128128}
129129
r243230r243231
135135void *osd_malloc_array(size_t size)
136136{
137137#ifndef MALLOC_DEBUG
138   return HeapAlloc(GetProcessHeap(), 0, size);
138    return HeapAlloc(GetProcessHeap(), 0, size);
139139#else
140   // add in space for the size
141   size += sizeof(size_t);
140    // add in space for the size
141    size += sizeof(size_t);
142142
143   // round the size up to a page boundary
144   size_t rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
143    // round the size up to a page boundary
144    size_t rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
145145
146   // reserve that much memory, plus two guard pages
147   void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
148   if (page_base == NULL)
149      return NULL;
146    // reserve that much memory, plus two guard pages
147    void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
148    if (page_base == NULL)
149        return NULL;
150150
151   // now allow access to everything but the first and last pages
152   page_base = VirtualAlloc(reinterpret_cast<UINT8 *>(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE);
153   if (page_base == NULL)
154      return NULL;
151    // now allow access to everything but the first and last pages
152    page_base = VirtualAlloc(reinterpret_cast<UINT8 *>(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE);
153    if (page_base == NULL)
154        return NULL;
155155
156   // work backwards from the page base to get to the block base
157   void *result = GUARD_ALIGN_START ? page_base : (reinterpret_cast<UINT8 *>(page_base) + rounded_size - size);
156    // work backwards from the page base to get to the block base
157    void *result = GUARD_ALIGN_START ? page_base : (reinterpret_cast<UINT8 *>(page_base) + rounded_size - size);
158158
159   // store the size at the start with a flag indicating it has a guard page
160   *reinterpret_cast<size_t *>(result) = size | 0x80000000;
161   return reinterpret_cast<UINT8 *>(result) + sizeof(size_t);
159    // store the size at the start with a flag indicating it has a guard page
160    *reinterpret_cast<size_t *>(result) = size | 0x80000000;
161    return reinterpret_cast<UINT8 *>(result) + sizeof(size_t);
162162#endif
163163}
164164
r243230r243231
170170void osd_free(void *ptr)
171171{
172172#ifndef MALLOC_DEBUG
173   HeapFree(GetProcessHeap(), 0, ptr);
173    HeapFree(GetProcessHeap(), 0, ptr);
174174#else
175   size_t size = reinterpret_cast<size_t *>(ptr)[-1];
175    size_t size = reinterpret_cast<size_t *>(ptr)[-1];
176176
177   // if no guard page, just free the pointer
178   if ((size & 0x80000000) == 0)
179      HeapFree(GetProcessHeap(), 0, reinterpret_cast<UINT8 *>(ptr) - sizeof(size_t));
177    // if no guard page, just free the pointer
178    if ((size & 0x80000000) == 0)
179        HeapFree(GetProcessHeap(), 0, reinterpret_cast<UINT8 *>(ptr) - sizeof(size_t));
180180
181   // large items need more care
182   else
183   {
184      ULONG_PTR page_base = (reinterpret_cast<ULONG_PTR>(ptr) - sizeof(size_t)) & ~(PAGE_SIZE - 1);
185      VirtualFree(reinterpret_cast<void *>(page_base - PAGE_SIZE), 0, MEM_RELEASE);
186   }
181    // large items need more care
182    else
183    {
184        ULONG_PTR page_base = (reinterpret_cast<ULONG_PTR>(ptr) - sizeof(size_t)) & ~(PAGE_SIZE - 1);
185        VirtualFree(reinterpret_cast<void *>(page_base - PAGE_SIZE), 0, MEM_RELEASE);
186    }
187187#endif
188188}
189189
r243230r243231
197197
198198void *osd_alloc_executable(size_t size)
199199{
200   return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
200    return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
201201}
202202
203203
r243230r243231
209209
210210void osd_free_executable(void *ptr, size_t size)
211211{
212   VirtualFree(ptr, 0, MEM_RELEASE);
212    VirtualFree(ptr, 0, MEM_RELEASE);
213213}
214214
215215
r243230r243231
220220void osd_break_into_debugger(const char *message)
221221{
222222#ifdef OSD_WINDOWS
223   if (IsDebuggerPresent())
224   {
225      win_output_debug_string_utf8(message);
226      DebugBreak();
227   }
228   else if (s_debugger_stack_crawler != NULL)
229      (*s_debugger_stack_crawler)();
223    if (IsDebuggerPresent())
224    {
225        win_output_debug_string_utf8(message);
226        DebugBreak();
227    }
228    else if (s_debugger_stack_crawler != NULL)
229        (*s_debugger_stack_crawler)();
230230#else
231   if (IsDebuggerPresent())
232   {
233      OutputDebugStringA(message);
234      DebugBreak();
235   }
231    if (IsDebuggerPresent())
232    {
233        OutputDebugStringA(message);
234        DebugBreak();
235    }
236236#endif
237237}
238238
r243230r243231
252252
253253osd_ticks_t osd_ticks(void)
254254{
255   LARGE_INTEGER performance_count;
255    LARGE_INTEGER performance_count;
256256
257   // if we're suspended, just return that
258   if (suspend_ticks != 0)
259      return suspend_ticks;
257    // if we're suspended, just return that
258    if (suspend_ticks != 0)
259        return suspend_ticks;
260260
261   // if we have a per second count, just go for it
262   if (ticks_per_second != 0)
263   {
264      // QueryPerformanceCounter if we can
265      if (using_qpc)
266      {
267         QueryPerformanceCounter(&performance_count);
268         return (osd_ticks_t)performance_count.QuadPart - suspend_ticks;
269      }
261    // if we have a per second count, just go for it
262    if (ticks_per_second != 0)
263    {
264        // QueryPerformanceCounter if we can
265        if (using_qpc)
266        {
267            QueryPerformanceCounter(&performance_count);
268            return (osd_ticks_t)performance_count.QuadPart - suspend_ticks;
269        }
270270
271      // otherwise, fall back to timeGetTime
272      else
273         return (osd_ticks_t)timeGetTime() - suspend_ticks;
274   }
271        // otherwise, fall back to timeGetTime
272        else
273            return (osd_ticks_t)timeGetTime() - suspend_ticks;
274    }
275275
276   // if not, we have to determine it
277   using_qpc = QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0);
278   if (using_qpc)
279      ticks_per_second = (osd_ticks_t)performance_count.QuadPart;
280   else
281      ticks_per_second = 1000;
276    // if not, we have to determine it
277    using_qpc = QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0);
278    if (using_qpc)
279        ticks_per_second = (osd_ticks_t)performance_count.QuadPart;
280    else
281        ticks_per_second = 1000;
282282
283   // call ourselves to get the first value
284   return osd_ticks();
283    // call ourselves to get the first value
284    return osd_ticks();
285285}
286286
287287
r243230r243231
291291
292292osd_ticks_t osd_ticks_per_second(void)
293293{
294   if (ticks_per_second == 0)
295      osd_ticks();
296   return ticks_per_second;
294    if (ticks_per_second == 0)
295        osd_ticks();
296    return ticks_per_second;
297297}
298298
299299//============================================================
r243230r243231
302302
303303void osd_sleep(osd_ticks_t duration)
304304{
305   DWORD msec;
305    DWORD msec;
306306
307   // make sure we've computed ticks_per_second
308   if (ticks_per_second == 0)
309      (void)osd_ticks();
307    // make sure we've computed ticks_per_second
308    if (ticks_per_second == 0)
309        (void)osd_ticks();
310310
311   // convert to milliseconds, rounding down
312   msec = (DWORD)(duration * 1000 / ticks_per_second);
311    // convert to milliseconds, rounding down
312    msec = (DWORD)(duration * 1000 / ticks_per_second);
313313
314   // only sleep if at least 2 full milliseconds
315   if (msec >= 2)
316   {
317      HANDLE current_thread = GetCurrentThread();
318      int old_priority = GetThreadPriority(current_thread);
314    // only sleep if at least 2 full milliseconds
315    if (msec >= 2)
316    {
317        HANDLE current_thread = GetCurrentThread();
318        int old_priority = GetThreadPriority(current_thread);
319319
320      // take a couple of msecs off the top for good measure
321      msec -= 2;
320        // take a couple of msecs off the top for good measure
321        msec -= 2;
322322
323      // bump our thread priority super high so that we get
324      // priority when we need it
325      SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL);
326      Sleep(msec);
327      SetThreadPriority(current_thread, old_priority);
328   }
323        // bump our thread priority super high so that we get
324        // priority when we need it
325        SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL);
326        Sleep(msec);
327        SetThreadPriority(current_thread, old_priority);
328    }
329329}
trunk/src/osd/modules/lib/osdobj_common.c
r243230r243231
1717
1818const options_entry osd_options::s_option_entries[] =
1919{
20   { NULL,                                   NULL,       OPTION_HEADER,     "OSD FONT OPTIONS" },
21   { OSD_FONT_PROVIDER,                      "auto",     OPTION_STRING,     "provider for ui font: " },
20    { NULL,                                   NULL,       OPTION_HEADER,     "OSD FONT OPTIONS" },
21    { OSD_FONT_PROVIDER,                      "auto",     OPTION_STRING,     "provider for ui font: " },
2222
23   { NULL,                                   NULL,       OPTION_HEADER,     "OSD CLI OPTIONS" },
24   { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist",  "0",        OPTION_COMMAND,    "list available MIDI I/O devices" },
25   { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0",     OPTION_COMMAND,    "list available network adapters" },
23    { NULL,                                   NULL,       OPTION_HEADER,     "OSD CLI OPTIONS" },
24    { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist",  "0",        OPTION_COMMAND,    "list available MIDI I/O devices" },
25    { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0",     OPTION_COMMAND,    "list available network adapters" },
2626
27   // debugging options
28   { NULL,                                   NULL,       OPTION_HEADER,     "OSD DEBUGGING OPTIONS" },
29   { OSDOPTION_DEBUGGER,                     OSDOPTVAL_AUTO,      OPTION_STRING,    "debugger used : " },
30   { OSDOPTION_WATCHDOG ";wdog",             "0",        OPTION_INTEGER,    "force the program to terminate if no updates within specified number of seconds" },
27    // debugging options
28    { NULL,                                   NULL,       OPTION_HEADER,     "OSD DEBUGGING OPTIONS" },
29    { OSDOPTION_DEBUGGER,                     OSDOPTVAL_AUTO,      OPTION_STRING,    "debugger used : " },
30    { OSDOPTION_WATCHDOG ";wdog",             "0",        OPTION_INTEGER,    "force the program to terminate if no updates within specified number of seconds" },
3131
32   // performance options
33   { NULL,                                   NULL,       OPTION_HEADER,     "OSD PERFORMANCE OPTIONS" },
34   { OSDOPTION_MULTITHREADING ";mt",         "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
35   { OSDOPTION_NUMPROCESSORS ";np",          OSDOPTVAL_AUTO,      OPTION_STRING,     "number of processors; this overrides the number the system reports" },
36   { OSDOPTION_BENCH,                        "0",        OPTION_INTEGER,    "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" },
37   // video options
38   { NULL,                                   NULL,       OPTION_HEADER,     "OSD VIDEO OPTIONS" },
32    // performance options
33    { NULL,                                   NULL,       OPTION_HEADER,     "OSD PERFORMANCE OPTIONS" },
34    { OSDOPTION_MULTITHREADING ";mt",         "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
35    { OSDOPTION_NUMPROCESSORS ";np",          OSDOPTVAL_AUTO,      OPTION_STRING,     "number of processors; this overrides the number the system reports" },
36    { OSDOPTION_BENCH,                        "0",        OPTION_INTEGER,    "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" },
37    // video options
38    { NULL,                                   NULL,       OPTION_HEADER,     "OSD VIDEO OPTIONS" },
3939// OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience
40   { OSDOPTION_VIDEO,                        OSDOPTVAL_AUTO,     OPTION_STRING,     "video output method: " },
41   { OSDOPTION_NUMSCREENS "(1-4)",           "1",        OPTION_INTEGER,    "number of screens to create; usually, you want just one" },
42   { OSDOPTION_WINDOW ";w",                  "0",        OPTION_BOOLEAN,    "enable window mode; otherwise, full screen mode is assumed" },
43   { OSDOPTION_MAXIMIZE ";max",              "1",        OPTION_BOOLEAN,    "default to maximized windows; otherwise, windows will be minimized" },
44   { OSDOPTION_KEEPASPECT ";ka",             "1",        OPTION_BOOLEAN,    "constrain to the proper aspect ratio" },
45   { OSDOPTION_UNEVENSTRETCH ";ues",         "1",        OPTION_BOOLEAN,    "allow non-integer stretch factors" },
46   { OSDOPTION_WAITVSYNC ";vs",              "0",        OPTION_BOOLEAN,    "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
47   { OSDOPTION_SYNCREFRESH ";srf",           "0",        OPTION_BOOLEAN,    "enable using the start of VBLANK for throttling instead of the game time" },
40    { OSDOPTION_VIDEO,                        OSDOPTVAL_AUTO,     OPTION_STRING,     "video output method: " },
41    { OSDOPTION_NUMSCREENS "(1-4)",           "1",        OPTION_INTEGER,    "number of screens to create; usually, you want just one" },
42    { OSDOPTION_WINDOW ";w",                  "0",        OPTION_BOOLEAN,    "enable window mode; otherwise, full screen mode is assumed" },
43    { OSDOPTION_MAXIMIZE ";max",              "1",        OPTION_BOOLEAN,    "default to maximized windows; otherwise, windows will be minimized" },
44    { OSDOPTION_KEEPASPECT ";ka",             "1",        OPTION_BOOLEAN,    "constrain to the proper aspect ratio" },
45    { OSDOPTION_UNEVENSTRETCH ";ues",         "1",        OPTION_BOOLEAN,    "allow non-integer stretch factors" },
46    { OSDOPTION_WAITVSYNC ";vs",              "0",        OPTION_BOOLEAN,    "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
47    { OSDOPTION_SYNCREFRESH ";srf",           "0",        OPTION_BOOLEAN,    "enable using the start of VBLANK for throttling instead of the game time" },
4848
49   // per-window options
50   { NULL,                                   NULL,             OPTION_HEADER,    "OSD PER-WINDOW VIDEO OPTIONS" },
51   { OSDOPTION_SCREEN,                   OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
52   { OSDOPTION_ASPECT ";screen_aspect",  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio for all screens; 'auto' here will try to make a best guess" },
53   { OSDOPTION_RESOLUTION ";r",          OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
54   { OSDOPTION_VIEW,                     OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for all screens" },
49    // per-window options
50    { NULL,                                   NULL,             OPTION_HEADER,    "OSD PER-WINDOW VIDEO OPTIONS" },
51    { OSDOPTION_SCREEN,                   OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
52    { OSDOPTION_ASPECT ";screen_aspect",  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio for all screens; 'auto' here will try to make a best guess" },
53    { OSDOPTION_RESOLUTION ";r",          OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
54    { OSDOPTION_VIEW,                     OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for all screens" },
5555
56   { OSDOPTION_SCREEN "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
57   { OSDOPTION_ASPECT "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
58   { OSDOPTION_RESOLUTION "0;r0",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
59   { OSDOPTION_VIEW "0",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the first screen" },
56    { OSDOPTION_SCREEN "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
57    { OSDOPTION_ASPECT "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
58    { OSDOPTION_RESOLUTION "0;r0",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
59    { OSDOPTION_VIEW "0",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the first screen" },
6060
61   { OSDOPTION_SCREEN "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the second screen; 'auto' here will try to make a best guess" },
62   { OSDOPTION_ASPECT "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
63   { OSDOPTION_RESOLUTION "1;r1",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
64   { OSDOPTION_VIEW "1",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the second screen" },
61    { OSDOPTION_SCREEN "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the second screen; 'auto' here will try to make a best guess" },
62    { OSDOPTION_ASPECT "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
63    { OSDOPTION_RESOLUTION "1;r1",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
64    { OSDOPTION_VIEW "1",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the second screen" },
6565
66   { OSDOPTION_SCREEN "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the third screen; 'auto' here will try to make a best guess" },
67   { OSDOPTION_ASPECT "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
68   { OSDOPTION_RESOLUTION "2;r2",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
69   { OSDOPTION_VIEW "2",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the third screen" },
66    { OSDOPTION_SCREEN "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the third screen; 'auto' here will try to make a best guess" },
67    { OSDOPTION_ASPECT "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
68    { OSDOPTION_RESOLUTION "2;r2",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
69    { OSDOPTION_VIEW "2",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the third screen" },
7070
71   { OSDOPTION_SCREEN "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
72   { OSDOPTION_ASPECT "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
73   { OSDOPTION_RESOLUTION "3;r3",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
74   { OSDOPTION_VIEW "3",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the fourth screen" },
71    { OSDOPTION_SCREEN "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
72    { OSDOPTION_ASPECT "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
73    { OSDOPTION_RESOLUTION "3;r3",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
74    { OSDOPTION_VIEW "3",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the fourth screen" },
7575
76   // full screen options
77   { NULL,                                   NULL,  OPTION_HEADER,     "OSD FULL SCREEN OPTIONS" },
78   { OSDOPTION_SWITCHRES,                    "0",   OPTION_BOOLEAN,    "enable resolution switching" },
76    // full screen options
77    { NULL,                                   NULL,  OPTION_HEADER,     "OSD FULL SCREEN OPTIONS" },
78    { OSDOPTION_SWITCHRES,                    "0",   OPTION_BOOLEAN,    "enable resolution switching" },
7979
80   // sound options
81   { NULL,                                   NULL,  OPTION_HEADER,     "OSD SOUND OPTIONS" },
82   { OSDOPTION_SOUND,                        OSDOPTVAL_AUTO, OPTION_STRING,     "sound output method: " },
83   { OSDOPTION_AUDIO_LATENCY "(1-5)",        "2",   OPTION_INTEGER,    "set audio latency (increase to reduce glitches, decrease for responsiveness)" },
80    // sound options
81    { NULL,                                   NULL,  OPTION_HEADER,     "OSD SOUND OPTIONS" },
82    { OSDOPTION_SOUND,                        OSDOPTVAL_AUTO, OPTION_STRING,     "sound output method: " },
83    { OSDOPTION_AUDIO_LATENCY "(1-5)",        "2",   OPTION_INTEGER,    "set audio latency (increase to reduce glitches, decrease for responsiveness)" },
8484
85   // End of list
86   { NULL }
85    // End of list
86    { NULL }
8787};
8888
8989osd_options::osd_options()
9090: cli_options()
9191{
92   add_entries(osd_options::s_option_entries);
92    add_entries(osd_options::s_option_entries);
9393};
9494
9595
r243230r243231
9999
100100osd_common_t::osd_common_t(osd_options &options)
101101   : m_machine(NULL),
102      m_options(options),
103      m_sound(NULL),
104      m_debugger(NULL)
102     m_options(options),
103     m_sound(NULL),
104     m_debugger(NULL)
105105
106106{
107107}
r243230r243231
110110
111111void osd_common_t::register_options()
112112{
113   REGISTER_MODULE(m_mod_man, FONT_OSX);
114   REGISTER_MODULE(m_mod_man, FONT_WINDOWS);
115   REGISTER_MODULE(m_mod_man, FONT_SDL);
116   REGISTER_MODULE(m_mod_man, FONT_NONE);
117113
118   REGISTER_MODULE(m_mod_man, SOUND_DSOUND);
119   REGISTER_MODULE(m_mod_man, SOUND_JS);
120   REGISTER_MODULE(m_mod_man, SOUND_SDL);
121   REGISTER_MODULE(m_mod_man, SOUND_NONE);
114    REGISTER_MODULE(m_mod_man, FONT_OSX);
115    REGISTER_MODULE(m_mod_man, FONT_WINDOWS);
116    REGISTER_MODULE(m_mod_man, FONT_SDL);
117    REGISTER_MODULE(m_mod_man, FONT_NONE);
122118
119    REGISTER_MODULE(m_mod_man, SOUND_DSOUND);
120    REGISTER_MODULE(m_mod_man, SOUND_JS);
121    REGISTER_MODULE(m_mod_man, SOUND_SDL);
122    REGISTER_MODULE(m_mod_man, SOUND_NONE);
123
123124#ifdef SDLMAME_MACOSX
124   REGISTER_MODULE(m_mod_man, DEBUG_OSX);
125    REGISTER_MODULE(m_mod_man, DEBUG_OSX);
125126#endif
126   REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS);
127   REGISTER_MODULE(m_mod_man, DEBUG_QT);
128   REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL);
129   REGISTER_MODULE(m_mod_man, DEBUG_NONE);
127    REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS);
128    REGISTER_MODULE(m_mod_man, DEBUG_QT);
129    REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL);
130    REGISTER_MODULE(m_mod_man, DEBUG_NONE);
130131
131   // after initialization we know which modules are supported
132    // after initialization we know which modules are supported
132133
133   const char *names[20];
134   int num;
135   m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names);
136   dynamic_array<const char *> dnames;
137   for (int i = 0; i < num; i++)
138      dnames.append(names[i]);
139   update_option(OSD_FONT_PROVIDER, dnames);
134    const char *names[20];
135    int num;
136    m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names);
137    dynamic_array<const char *> dnames;
138    for (int i = 0; i < num; i++)
139        dnames.append(names[i]);
140    update_option(OSD_FONT_PROVIDER, dnames);
140141
141   m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names);
142   dnames.reset();
143   for (int i = 0; i < num; i++)
144      dnames.append(names[i]);
145   update_option(OSD_SOUND_PROVIDER, dnames);
142    m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names);
143    dnames.reset();
144    for (int i = 0; i < num; i++)
145        dnames.append(names[i]);
146    update_option(OSD_SOUND_PROVIDER, dnames);
146147
147   // Register debugger options and update options
148   m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names);
149   dnames.reset();
150   for (int i = 0; i < num; i++)
151      dnames.append(names[i]);
152   update_option(OSD_DEBUG_PROVIDER, dnames);
148    // Register debugger options and update options
149    m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names);
150    dnames.reset();
151    for (int i = 0; i < num; i++)
152        dnames.append(names[i]);
153    update_option(OSD_DEBUG_PROVIDER, dnames);
153154
154   // Register video options and update options
155   video_options_add("none", NULL);
156   video_register();
157   update_option(OSDOPTION_VIDEO, m_video_names);
155    // Register video options and update options
156    video_options_add("none", NULL);
157    video_register();
158    update_option(OSDOPTION_VIDEO, m_video_names);
158159}
159160
160161void osd_common_t::update_option(const char * key, dynamic_array<const char *> &values)
r243230r243231
304305   // It provides an array of stereo samples in L-R order which should be
305306   // output at the configured sample_rate.
306307   //
307   m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame);
308    m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame);
308309}
309310
310311
r243230r243231
321322   //    while (attenuation++ < 0)
322323   //       volume /= 1.122018454;      //  = (10 ^ (1/20)) = 1dB
323324   //
324   if (m_sound != NULL)
325      m_sound->set_mastervolume(attenuation);
325    if (m_sound != NULL)
326        m_sound->set_mastervolume(attenuation);
326327}
327328
328329
r243230r243231
397398
398399bool osd_common_t::execute_command(const char *command)
399400{
400   if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0)
401   {
402      network_init();
403      osd_list_network_adapters();
404      network_exit();
405      return true;
406   }
407   else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0)
408   {
409      osd_list_midi_devices();
410      return true;
411   }
401    if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0)
402    {
403        network_init();
404        osd_list_network_adapters();
405        network_exit();
406        return true;
407    }
408    else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0)
409    {
410        osd_list_midi_devices();
411        return true;
412    }
412413
413   return false;
414    return false;
414415
415416}
416417
r243230r243231
436437#endif
437438   midi_init();
438439
439   m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER);
440    m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER);
440441
441   m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER);
442   m_sound->m_sample_rate = options().sample_rate();
443   m_sound->m_audio_latency = options().audio_latency();
442    m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER);
443    m_sound->m_sample_rate = options().sample_rate();
444    m_sound->m_audio_latency = options().audio_latency();
444445
445   m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER);
446    m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER);
446447
447   m_mod_man.init();
448    m_mod_man.init();
448449
449450}
450451
r243230r243231
523524
524525void osd_common_t::osd_exit()
525526{
526   m_mod_man.exit();
527    m_mod_man.exit();
527528
528   exit_subsystems();
529    exit_subsystems();
529530}
530531
531532void osd_common_t::video_options_add(const char *name, void *type)
r243230r243231
536537
537538bool osd_common_t::midi_init()
538539{
539   // this should be done on the OS_level
540   return osd_midi_init();
540    // this should be done on the OS_level
541    return osd_midi_init();
541542}
542543
543544void osd_common_t::midi_exit()
544545{
545   osd_midi_exit();
546    osd_midi_exit();
546547}
548
549
trunk/src/osd/modules/lib/osdobj_common.h
r243230r243231
6262class osd_options : public cli_options
6363{
6464public:
65   // construction/destruction
66   osd_options();
65    // construction/destruction
66    osd_options();
6767
68   // debugging options
69   const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
70   int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
68    // debugging options
69    const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
70    int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
7171
72   // performance options
73   bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); }
74   const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); }
75   int bench() const { return int_value(OSDOPTION_BENCH); }
72    // performance options
73    bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); }
74    const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); }
75    int bench() const { return int_value(OSDOPTION_BENCH); }
7676
77   // video options
78   const char *video() const { return value(OSDOPTION_VIDEO); }
79   int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); }
80   bool window() const { return bool_value(OSDOPTION_WINDOW); }
81   bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); }
82   bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); }
83   bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); }
84   bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); }
85   bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); }
77    // video options
78    const char *video() const { return value(OSDOPTION_VIDEO); }
79    int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); }
80    bool window() const { return bool_value(OSDOPTION_WINDOW); }
81    bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); }
82    bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); }
83    bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); }
84    bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); }
85    bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); }
8686
87   // per-window options
88   const char *screen() const { return value(OSDOPTION_SCREEN); }
89   const char *aspect() const { return value(OSDOPTION_ASPECT); }
90   const char *resolution() const { return value(OSDOPTION_RESOLUTION); }
91   const char *view() const { return value(OSDOPTION_VIEW); }
92   const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); }
93   const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); }
94   const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); }
95   const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); }
87    // per-window options
88    const char *screen() const { return value(OSDOPTION_SCREEN); }
89    const char *aspect() const { return value(OSDOPTION_ASPECT); }
90    const char *resolution() const { return value(OSDOPTION_RESOLUTION); }
91    const char *view() const { return value(OSDOPTION_VIEW); }
92    const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); }
93    const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); }
94    const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); }
95    const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); }
9696
97   // full screen options
98   bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); }
97    // full screen options
98    bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); }
9999
100   // sound options
101   const char *sound() const { return value(OSDOPTION_SOUND); }
102   int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); }
100    // sound options
101    const char *sound() const { return value(OSDOPTION_SOUND); }
102    int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); }
103103
104104private:
105   static const options_entry s_option_entries[];
105    static const options_entry s_option_entries[];
106106};
107107
108108// ======================> osd_interface
r243230r243231
142142   // video overridables
143143   virtual void *get_slider_list();
144144
145   // command option overrides
146   virtual bool execute_command(const char *command);
145    // command option overrides
146    virtual bool execute_command(const char *command);
147147
148   osd_font *font_alloc() { return m_font_module->font_alloc(); }
148    osd_font *font_alloc() { return m_font_module->font_alloc(); }
149149
150150   // FIXME: everything below seems to be osd specific and not part of
151151   //        this INTERFACE but part of the osd IMPLEMENTATION
152152
153   // getters
154   running_machine &machine() { assert(m_machine != NULL); return *m_machine; }
153    // getters
154    running_machine &machine() { assert(m_machine != NULL); return *m_machine; }
155155
156156
157   virtual void debugger_update();
157    virtual void debugger_update();
158158
159   virtual void init_subsystems();
159    virtual void init_subsystems();
160160
161   virtual bool video_init();
162   virtual void video_register();
163   virtual bool window_init();
161    virtual bool video_init();
162    virtual void video_register();
163    virtual bool window_init();
164164
165   virtual void input_resume();
166   virtual bool output_init();
167   virtual bool network_init();
168   virtual bool midi_init();
165    virtual void input_resume();
166    virtual bool output_init();
167    virtual bool network_init();
168    virtual bool midi_init();
169169
170   virtual void exit_subsystems();
171   virtual void video_exit();
172   virtual void window_exit();
173   virtual void input_exit();
174   virtual void output_exit();
175   virtual void network_exit();
176   virtual void midi_exit();
170    virtual void exit_subsystems();
171    virtual void video_exit();
172    virtual void window_exit();
173    virtual void input_exit();
174    virtual void output_exit();
175    virtual void network_exit();
176    virtual void midi_exit();
177177
178   virtual void osd_exit();
178    virtual void osd_exit();
179179
180   virtual void video_options_add(const char *name, void *type);
180    virtual void video_options_add(const char *name, void *type);
181181
182   osd_options &options() { return m_options; }
182    osd_options &options() { return m_options; }
183183
184184protected:
185   virtual bool input_init();
186   virtual void input_pause();
185    virtual bool input_init();
186    virtual void input_pause();
187187
188188private:
189189   // internal state
190190   running_machine *   m_machine;
191191   osd_options& m_options;
192192
193   osd_module_manager m_mod_man;
194   font_module *m_font_module;
193    osd_module_manager m_mod_man;
194    font_module *m_font_module;
195195
196196   void update_option(const char * key, dynamic_array<const char *> &values);
197   // FIXME: should be elsewhere
198   osd_module *select_module_options(const core_options &opts, const astring &opt_name)
199   {
200      astring opt_val = opts.value(opt_name);
201      if (opt_val == "auto")
202         opt_val = "";
203      else if (!m_mod_man.type_has_name(opt_name, opt_val))
204      {
205         osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr());
206         opt_val = "";
207      }
208      return m_mod_man.select_module(opt_name, opt_val);
209   }
197    // FIXME: should be elsewhere
198    osd_module *select_module_options(const core_options &opts, const astring &opt_name)
199    {
200        astring opt_val = opts.value(opt_name);
201        if (opt_val == "auto")
202            opt_val = "";
203        else if (!m_mod_man.type_has_name(opt_name, opt_val))
204        {
205            osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr());
206            opt_val = "";
207        }
208        return m_mod_man.select_module(opt_name, opt_val);
209    }
210210
211   template<class C>
212   C select_module_options(const core_options &opts, const astring &opt_name)
213   {
214      return dynamic_cast<C>(select_module_options(opts, opt_name));
215   }
211    template<class C>
212    C select_module_options(const core_options &opts, const astring &opt_name)
213    {
214        return dynamic_cast<C>(select_module_options(opts, opt_name));
215    }
216216
217217protected:
218218   sound_module* m_sound;
trunk/src/osd/modules/midi/none.c
r243230r243231
1010
1111struct osd_midi_device
1212{
13   int dummy;
13    int dummy;
1414};
1515
1616bool osd_midi_init()
1717{
18   return true;
18    return true;
1919}
2020
2121void osd_midi_exit()
r243230r243231
2424
2525void osd_list_midi_devices(void)
2626{
27   osd_printf_warning("\nMIDI is not supported in this build\n");
27    osd_printf_warning("\nMIDI is not supported in this build\n");
2828}
2929
3030osd_midi_device *osd_open_midi_input(const char *devname)
3131{
32   return NULL;
32    return NULL;
3333}
3434
3535osd_midi_device *osd_open_midi_output(const char *devname)
3636{
37   return NULL;
37    return NULL;
3838}
3939
4040void osd_close_midi_channel(osd_midi_device *dev)
r243230r243231
4343
4444bool osd_poll_midi_channel(osd_midi_device *dev)
4545{
46   return false;
46    return false;
4747}
4848
4949int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut)
5050{
51   return 0;
51    return 0;
5252}
5353
5454void osd_write_midi_channel(osd_midi_device *dev, UINT8 data)
trunk/src/osd/modules/midi/portmidi.c
r243230r243231
1616
1717struct osd_midi_device
1818{
19   PortMidiStream *pmStream;
20   PmEvent rx_evBuf[RX_EVENT_BUF_SIZE];
21   UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes
22   int xmit_cnt;
23   UINT8 last_status;
24   bool rx_sysex;
19    PortMidiStream *pmStream;
20    PmEvent rx_evBuf[RX_EVENT_BUF_SIZE];
21    UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes
22    int xmit_cnt;
23    UINT8 last_status;
24    bool rx_sysex;
2525};
2626
2727bool osd_midi_init()
2828{
29   Pm_Initialize();
30   return true;
29    Pm_Initialize();
30    return true;
3131}
3232
3333void osd_midi_exit()
3434{
35   Pm_Terminate();
35    Pm_Terminate();
3636}
3737
3838void osd_list_midi_devices(void)
3939{
40   int num_devs = Pm_CountDevices();
41   const PmDeviceInfo *pmInfo;
40    int num_devs = Pm_CountDevices();
41    const PmDeviceInfo *pmInfo;
4242
43   printf("\n");
43    printf("\n");
4444
45   if (num_devs == 0)
46   {
47      printf("No MIDI ports were found\n");
48      return;
49   }
45    if (num_devs == 0)
46    {
47        printf("No MIDI ports were found\n");
48        return;
49    }
5050
51   printf("MIDI input ports:\n");
52   for (int i = 0; i < num_devs; i++)
53   {
54      pmInfo = Pm_GetDeviceInfo(i);
51    printf("MIDI input ports:\n");
52    for (int i = 0; i < num_devs; i++)
53    {
54        pmInfo = Pm_GetDeviceInfo(i);
5555
56      if (pmInfo->input)
57      {
58         printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : "");
59      }
60   }
56        if (pmInfo->input)
57        {
58            printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : "");
59        }
60    }
6161
62   printf("\nMIDI output ports:\n");
63   for (int i = 0; i < num_devs; i++)
64   {
65      pmInfo = Pm_GetDeviceInfo(i);
62    printf("\nMIDI output ports:\n");
63    for (int i = 0; i < num_devs; i++)
64    {
65        pmInfo = Pm_GetDeviceInfo(i);
6666
67      if (pmInfo->output)
68      {
69         printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : "");
70      }
71   }
67        if (pmInfo->output)
68        {
69            printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : "");
70        }
71    }
7272}
7373
7474osd_midi_device *osd_open_midi_input(const char *devname)
7575{
76   int num_devs = Pm_CountDevices();
77   int found_dev = -1;
78   const PmDeviceInfo *pmInfo;
79   PortMidiStream *stm;
80   osd_midi_device *ret;
76    int num_devs = Pm_CountDevices();
77    int found_dev = -1;
78    const PmDeviceInfo *pmInfo;
79    PortMidiStream *stm;
80    osd_midi_device *ret;
8181
82   if (!strcmp("default", devname))
83   {
84      found_dev = Pm_GetDefaultInputDeviceID();
85   }
86   else
87   {
88      for (int i = 0; i < num_devs; i++)
89      {
90         pmInfo = Pm_GetDeviceInfo(i);
82    if (!strcmp("default", devname))
83    {
84        found_dev = Pm_GetDefaultInputDeviceID();
85    }
86    else
87    {
88        for (int i = 0; i < num_devs; i++)
89        {
90            pmInfo = Pm_GetDeviceInfo(i);
9191
92         if (pmInfo->input)
93         {
94            if (!strcmp(devname, pmInfo->name))
95            {
96               found_dev = i;
97               break;
98            }
99         }
100      }
101   }
92            if (pmInfo->input)
93            {
94                if (!strcmp(devname, pmInfo->name))
95                {
96                    found_dev = i;
97                    break;
98                }
99            }
100        }
101    }
102102
103   if (found_dev >= 0)
104   {
105      if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError)
106      {
107         ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
108         memset(ret, 0, sizeof(osd_midi_device));
109         ret->pmStream = stm;
110         return ret;
111      }
112      else
113      {
114         printf("Couldn't open PM device\n");
115         return NULL;
116      }
117   }
118   else
119   {
120      return NULL;
121   }
103    if (found_dev >= 0)
104    {
105        if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError)
106        {
107            ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
108            memset(ret, 0, sizeof(osd_midi_device));
109            ret->pmStream = stm;
110            return ret;
111        }
112        else
113        {
114            printf("Couldn't open PM device\n");
115            return NULL;
116        }
117    }
118    else
119    {
120        return NULL;
121    }
122122}
123123
124124osd_midi_device *osd_open_midi_output(const char *devname)
125125{
126   int num_devs = Pm_CountDevices();
127   int found_dev = -1;
128   const PmDeviceInfo *pmInfo;
129   PortMidiStream *stm;
130   osd_midi_device *ret;
126    int num_devs = Pm_CountDevices();
127    int found_dev = -1;
128    const PmDeviceInfo *pmInfo;
129    PortMidiStream *stm;
130    osd_midi_device *ret;
131131
132   if (!strcmp("default", devname))
133   {
134      found_dev = Pm_GetDefaultOutputDeviceID();
135   }
136   else
137   {
138      for (int i = 0; i < num_devs; i++)
139      {
140         pmInfo = Pm_GetDeviceInfo(i);
132    if (!strcmp("default", devname))
133    {
134        found_dev = Pm_GetDefaultOutputDeviceID();
135    }
136    else
137    {
138        for (int i = 0; i < num_devs; i++)
139        {
140            pmInfo = Pm_GetDeviceInfo(i);
141141
142         if (pmInfo->output)
143         {
144            if (!strcmp(devname, pmInfo->name))
145            {
146               found_dev = i;
147               break;
148            }
149         }
150      }
151   }
142            if (pmInfo->output)
143            {
144                if (!strcmp(devname, pmInfo->name))
145                {
146                    found_dev = i;
147                    break;
148                }
149            }
150        }
151    }
152152
153   if (found_dev >= 0)
154   {
155      if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError)
156      {
157         ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
158         memset(ret, 0, sizeof(osd_midi_device));
159         ret->pmStream = stm;
160         return ret;
161      }
162      else
163      {
164         printf("Couldn't open PM device\n");
165         return NULL;
166      }
167   }
168   else
169   {
170      return NULL;
171   }
172   return NULL;
153    if (found_dev >= 0)
154    {
155        if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError)
156        {
157            ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
158            memset(ret, 0, sizeof(osd_midi_device));
159            ret->pmStream = stm;
160            return ret;
161        }
162        else
163        {
164            printf("Couldn't open PM device\n");
165            return NULL;
166        }
167    }
168    else
169    {
170        return NULL;
171    }
172    return NULL;
173173}
174174
175175void osd_close_midi_channel(osd_midi_device *dev)
176176{
177   Pm_Close(dev->pmStream);
178   osd_free(dev);
177    Pm_Close(dev->pmStream);
178    osd_free(dev);
179179}
180180
181181bool osd_poll_midi_channel(osd_midi_device *dev)
182182{
183   PmError chk = Pm_Poll(dev->pmStream);
183    PmError chk = Pm_Poll(dev->pmStream);
184184
185   return (chk == pmGotData) ? true : false;
185    return (chk == pmGotData) ? true : false;
186186}
187187
188188int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut)
189189{
190   int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE);
191   int bytesOut = 0;
190    int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE);
191    int bytesOut = 0;
192192
193   if (msgsRead <= 0)
194   {
195      return 0;
196   }
193    if (msgsRead <= 0)
194    {
195        return 0;
196    }
197197
198   for (int msg = 0; msg < msgsRead; msg++)
199   {
200      UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message);
198    for (int msg = 0; msg < msgsRead; msg++)
199    {
200        UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message);
201201
202      if (dev->rx_sysex)
203      {
204         if (status & 0x80)  // sys real-time imposing on us?
205         {
206            if ((status == 0xf2) || (status == 0xf3))
207            {
208               *pOut++ = status;
209               *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
210               *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
211               bytesOut += 3;
212            }
213            else
214            {
215               *pOut++ = status;
216               bytesOut++;
217               if (status == MIDI_EOX)
218               {
219                  dev->rx_sysex = false;
220               }
221            }
222         }
223         else    // shift out the sysex bytes
224         {
225            for (int i = 0; i < 4; i++)
226            {
227               UINT8 byte = dev->rx_evBuf[msg].message & 0xff;
228               *pOut++ = byte;
229               bytesOut++;
230               if (byte == MIDI_EOX)
231               {
232                  dev->rx_sysex = false;
233                  break;
234               }
235               dev->rx_evBuf[msg].message >>= 8;
236            }
237         }
238      }
239      else
240      {
241         switch ((status>>4) & 0xf)
242         {
243            case 0xc:   // 2-byte messages
244            case 0xd:
245               *pOut++ = status;
246               *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
247               bytesOut += 2;
248               break;
202        if (dev->rx_sysex)
203        {
204            if (status & 0x80)  // sys real-time imposing on us?
205            {
206                if ((status == 0xf2) || (status == 0xf3))
207                {
208                    *pOut++ = status;
209                    *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
210                    *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
211                    bytesOut += 3;
212                }
213                else
214                {
215                    *pOut++ = status;
216                    bytesOut++;
217                    if (status == MIDI_EOX)
218                    {
219                        dev->rx_sysex = false;
220                    }
221                }
222            }
223            else    // shift out the sysex bytes
224            {
225                for (int i = 0; i < 4; i++)
226                {
227                    UINT8 byte = dev->rx_evBuf[msg].message & 0xff;
228                    *pOut++ = byte;
229                    bytesOut++;
230                    if (byte == MIDI_EOX)
231                    {
232                        dev->rx_sysex = false;
233                        break;
234                    }
235                    dev->rx_evBuf[msg].message >>= 8;
236                }
237            }
238        }
239        else
240        {
241            switch ((status>>4) & 0xf)
242            {
243                case 0xc:   // 2-byte messages
244                case 0xd:
245                    *pOut++ = status;
246                    *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
247                    bytesOut += 2;
248                    break;
249249
250            case 0xf:   // system common
251               switch (status & 0xf)
252               {
253                  case 0: // System Exclusive
254                  {
255                     *pOut++ = status;   // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe
256                     *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff;
257                     *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff;
258                     UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff;
259                     bytesOut += 4;
260                     dev->rx_sysex = (last != MIDI_EOX);
261                     break;
262                  }
250                case 0xf:   // system common
251                    switch (status & 0xf)
252                    {
253                        case 0: // System Exclusive
254                        {
255                            *pOut++ = status;   // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe
256                            *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff;
257                            *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff;
258                            UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff;
259                            bytesOut += 4;
260                            dev->rx_sysex = (last != MIDI_EOX);
261                            break;
262                        }
263263
264                  case 7: // End of System Exclusive
265                     *pOut++ = status;
266                     bytesOut += 1;
267                     dev->rx_sysex = false;
268                     break;
264                        case 7: // End of System Exclusive
265                            *pOut++ = status;
266                            bytesOut += 1;
267                            dev->rx_sysex = false;
268                            break;
269269
270                  case 2: // song pos
271                  case 3: // song select
272                     *pOut++ = status;
273                     *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
274                     *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
275                     bytesOut += 3;
276                     break;
270                        case 2: // song pos
271                        case 3: // song select
272                            *pOut++ = status;
273                            *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
274                            *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
275                            bytesOut += 3;
276                            break;
277277
278                  default:    // all other defined Fx messages are 1 byte
279                     break;
280               }
281               break;
278                        default:    // all other defined Fx messages are 1 byte
279                            break;
280                    }
281                    break;
282282
283            default:
284               *pOut++ = status;
285               *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
286               *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
287               bytesOut += 3;
288               break;
289         }
290      }
291   }
283                default:
284                    *pOut++ = status;
285                    *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message);
286                    *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message);
287                    bytesOut += 3;
288                    break;
289            }
290        }
291    }
292292
293   return bytesOut;
293    return bytesOut;
294294}
295295
296296void osd_write_midi_channel(osd_midi_device *dev, UINT8 data)
297297{
298   int bytes_needed = 0;
299   PmEvent ev;
300   ev.timestamp = 0;   // use the current time
298    int bytes_needed = 0;
299    PmEvent ev;
300    ev.timestamp = 0;   // use the current time
301301
302302//  printf("write: %02x (%d)\n", data, dev->xmit_cnt);
303303
304   // reject data bytes when no valid status exists
305   if ((dev->last_status == 0) && !(data & 0x80))
306   {
307      dev->xmit_cnt = 0;
308      return;
309   }
304    // reject data bytes when no valid status exists
305    if ((dev->last_status == 0) && !(data & 0x80))
306    {
307        dev->xmit_cnt = 0;
308        return;
309    }
310310
311   if (dev->xmit_cnt >= 4)
312   {
313      printf("MIDI out: packet assembly overflow, contact MAMEdev!\n");
314      return;
315   }
311    if (dev->xmit_cnt >= 4)
312    {
313        printf("MIDI out: packet assembly overflow, contact MAMEdev!\n");
314        return;
315    }
316316
317   // handle sysex
318   if (dev->last_status == MIDI_SYSEX)
319   {
317    // handle sysex
318    if (dev->last_status == MIDI_SYSEX)
319    {
320320//      printf("sysex: %02x (%d)\n", data, dev->xmit_cnt);
321321
322      // if we get a status that isn't sysex, assume it's system common
323      if ((data & 0x80) && (data != MIDI_EOX))
324      {
322        // if we get a status that isn't sysex, assume it's system common
323        if ((data & 0x80) && (data != MIDI_EOX))
324        {
325325//          printf("common during sysex!\n");
326         ev.message = Pm_Message(data, 0, 0);
327         Pm_Write(dev->pmStream, &ev, 1);
328         return;
329      }
326            ev.message = Pm_Message(data, 0, 0);
327            Pm_Write(dev->pmStream, &ev, 1);
328            return;
329        }
330330
331      dev->xmit_in[dev->xmit_cnt++] = data;
331        dev->xmit_in[dev->xmit_cnt++] = data;
332332
333      // if EOX or 4 bytes filled, transmit 4 bytes
334      if ((dev->xmit_cnt == 4) || (data == MIDI_EOX))
335      {
336         ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24);
337         Pm_Write(dev->pmStream, &ev, 1);
338         dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0;
339         dev->xmit_cnt = 0;
333        // if EOX or 4 bytes filled, transmit 4 bytes
334        if ((dev->xmit_cnt == 4) || (data == MIDI_EOX))
335        {
336            ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24);
337            Pm_Write(dev->pmStream, &ev, 1);
338            dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0;
339            dev->xmit_cnt = 0;
340340
341341//          printf("SysEx packet: %08x\n", ev.message);
342342
343         // if this is EOX, kill the running status
344         if (data == MIDI_EOX)
345         {
346            dev->last_status = 0;
347         }
348      }
343            // if this is EOX, kill the running status
344            if (data == MIDI_EOX)
345            {
346                dev->last_status = 0;
347            }
348        }
349349
350      return;
351   }
350        return;
351    }
352352
353   // handle running status.  don't allow system real-time messages to be considered as running status.
354   if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8))
355   {
356      dev->last_status = data;
357   }
353    // handle running status.  don't allow system real-time messages to be considered as running status.
354    if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8))
355    {
356        dev->last_status = data;
357    }
358358
359   if ((dev->xmit_cnt == 0) && !(data & 0x80))
360   {
361      dev->xmit_in[dev->xmit_cnt++] = dev->last_status;
362      dev->xmit_in[dev->xmit_cnt++] = data;
359    if ((dev->xmit_cnt == 0) && !(data & 0x80))
360    {
361        dev->xmit_in[dev->xmit_cnt++] = dev->last_status;
362        dev->xmit_in[dev->xmit_cnt++] = data;
363363//      printf("\trunning status: [%d] = %02x, [%d] = %02x, last_status = %02x\n", dev->xmit_cnt-2, dev->last_status, dev->xmit_cnt-1, data, dev->last_status);
364   }
365   else
366   {
367      dev->xmit_in[dev->xmit_cnt++] = data;
364    }
365    else
366    {
367        dev->xmit_in[dev->xmit_cnt++] = data;
368368//      printf("\tNRS: [%d] = %02x\n", dev->xmit_cnt-1, data);
369   }
369    }
370370
371   if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX))
372   {
371    if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX))
372    {
373373//      printf("Start SysEx!\n");
374      dev->last_status = MIDI_SYSEX;
375      return;
376   }
374        dev->last_status = MIDI_SYSEX;
375        return;
376    }
377377
378   // are we there yet?
378    // are we there yet?
379379//  printf("status check: %02x\n", dev->xmit_in[0]);
380   switch ((dev->xmit_in[0]>>4) & 0xf)
381   {
382      case 0xc:   // 2-byte messages
383      case 0xd:
384         bytes_needed = 2;
385         break;
380    switch ((dev->xmit_in[0]>>4) & 0xf)
381    {
382        case 0xc:   // 2-byte messages
383        case 0xd:
384            bytes_needed = 2;
385            break;
386386
387      case 0xf:   // system common
388         switch (dev->xmit_in[0] & 0xf)
389         {
390            case 0: // System Exclusive is handled above
391               break;
387        case 0xf:   // system common
388            switch (dev->xmit_in[0] & 0xf)
389            {
390                case 0: // System Exclusive is handled above
391                    break;
392392
393            case 7: // End of System Exclusive
394               bytes_needed = 1;
395               break;
393                case 7: // End of System Exclusive
394                    bytes_needed = 1;
395                    break;
396396
397            case 2: // song pos
398            case 3: // song select
399               bytes_needed = 3;
400               break;
397                case 2: // song pos
398                case 3: // song select
399                    bytes_needed = 3;
400                    break;
401401
402            default:    // all other defined Fx messages are 1 byte
403               bytes_needed = 1;
404               break;
405         }
406         break;
402                default:    // all other defined Fx messages are 1 byte
403                    bytes_needed = 1;
404                    break;
405            }
406            break;
407407
408      default:
409         bytes_needed = 3;
410         break;
411   }
408        default:
409            bytes_needed = 3;
410            break;
411    }
412412
413   if (dev->xmit_cnt == bytes_needed)
414   {
415      ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]);
416      Pm_Write(dev->pmStream, &ev, 1);
417      dev->xmit_cnt = 0;
418   }
413    if (dev->xmit_cnt == bytes_needed)
414    {
415        ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]);
416        Pm_Write(dev->pmStream, &ev, 1);
417        dev->xmit_cnt = 0;
418    }
419419
420420}
trunk/src/osd/modules/osdmodule.c
r243230r243231
77
88osd_module_manager::osd_module_manager()
99{
10   for (int i=0; i<MAX_MODULES; i++)
11   {
12      m_modules[i]  = NULL;
13      m_selected[i] = NULL;
14   }
10    for (int i=0; i<MAX_MODULES; i++)
11    {
12        m_modules[i]  = NULL;
13        m_selected[i] = NULL;
14    }
1515}
1616osd_module_manager::~osd_module_manager()
1717{
18   for (int i = 0; m_modules[i] != NULL; i++)
19   {
20      m_modules[i]->~osd_module();
21      osd_free(m_modules[i]);
22   }
18    for (int i = 0; m_modules[i] != NULL; i++)
19    {
20        m_modules[i]->~osd_module();
21        osd_free(m_modules[i]);
22    }
2323}
2424
2525void osd_module_manager::register_module(const module_type &mod_type)
2626{
27   osd_module *module = mod_type();
28   if (module->probe())
29   {
30      osd_printf_verbose("===> registered module %s %s\n", module->name(), module->type());
27    osd_module *module = mod_type();
28    if (module->probe())
29    {
30        osd_printf_verbose("===> registered module %s %s\n", module->name(), module->type());
3131
32      int i;
33      for (i = 0; m_modules[i] != NULL; i++)
34         ;
35      m_modules[i] = module;
36   }
37   else
38   {
39      osd_printf_verbose("===> not supported %s %s\n", module->name(), module->type());
40      module->~osd_module();
41      osd_free(module);
42   }
32        int i;
33        for (i = 0; m_modules[i] != NULL; i++)
34            ;
35        m_modules[i] = module;
36    }
37    else
38    {
39        osd_printf_verbose("===> not supported %s %s\n", module->name(), module->type());
40        module->~osd_module();
41        osd_free(module);
42    }
4343}
4444
4545bool osd_module_manager::type_has_name(const char *type, const char *name)
4646{
47   return (get_module_index(type, name) >= 0);
47    return (get_module_index(type, name) >= 0);
4848}
4949
5050osd_module *osd_module_manager::get_module_generic(const char *type, const char *name)
5151{
52   int i = get_module_index(type, name);
53   if (i>=0)
54      return m_modules[i];
55   else
56      return NULL;
52    int i = get_module_index(type, name);
53    if (i>=0)
54        return m_modules[i];
55    else
56        return NULL;
5757}
5858
5959osd_module *osd_module_manager::select_module(const char *type, const char *name)
6060{
61   osd_module *m = get_module_generic(type, name);
61    osd_module *m = get_module_generic(type, name);
6262
63   // FIXME: check if already exists!
64   int i;
65   for (i = 0; m_selected[i] != NULL; i++)
66      ;
67   m_selected[i] = m;
68   return m;
63    // FIXME: check if already exists!
64    int i;
65    for (i = 0; m_selected[i] != NULL; i++)
66        ;
67    m_selected[i] = m;
68    return m;
6969}
7070
7171void osd_module_manager::init()
7272{
73   for (int i = 0; m_selected[i] != NULL; i++)
74   {
75      m_selected[i]->init();
76   }
73    for (int i = 0; m_selected[i] != NULL; i++)
74    {
75        m_selected[i]->init();
76    }
7777}
7878
7979void osd_module_manager::exit()
8080{
81   // Find count
82   int cnt;
83   for (cnt = 0; m_selected[cnt] != NULL; cnt++)
84      ;
85   for (int i = cnt - 1; i >= 0; i--)
86   {
87      m_selected[i]->exit();
88      m_selected[i] = NULL;
89   }
81    // Find count
82    int cnt;
83    for (cnt = 0; m_selected[cnt] != NULL; cnt++)
84        ;
85    for (int i = cnt - 1; i >= 0; i--)
86    {
87        m_selected[i]->exit();
88        m_selected[i] = NULL;
89    }
9090}
9191
9292int osd_module_manager::get_module_index(const char *type, const char *name)
9393{
94   for (int i = 0; m_modules[i] != NULL; i++)
95   {
96      if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0)))
97         return i;
98   }
99   return -1;
94    for (int i = 0; m_modules[i] != NULL; i++)
95    {
96        if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0)))
97            return i;
98    }
99    return -1;
100100}
101101
102102void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[])
103103{
104   *num = 0;
105   for (int i = 0; m_modules[i] != NULL; i++)
106   {
107      if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max))
108      {
109         names[*num] = m_modules[i]->name();
110         *num = *num + 1;
111      }
104    *num = 0;
105    for (int i = 0; m_modules[i] != NULL; i++)
106    {
107        if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max))
108        {
109            names[*num] = m_modules[i]->name();
110            *num = *num + 1;
111        }
112112
113   }
113    }
114114}
115
116
trunk/src/osd/modules/osdmodule.h
r243230r243231
2626{
2727public:
2828
29   osd_module(const char *type, const char *name)
30   : m_name(name), m_type(type)
31   {}
32   virtual ~osd_module() { }
29    osd_module(const char *type, const char *name)
30    : m_name(name), m_type(type)
31    {}
32    virtual ~osd_module() { }
3333
34   const char * name() const { return m_name; }
35   const char * type() const { return m_type; }
34    const char * name() const { return m_name; }
35    const char * type() const { return m_type; }
3636
37   virtual bool probe() const { return true; }
37    virtual bool probe() const { return true; }
3838
39   virtual int init() { return 0; }
40   virtual void exit() { }
39    virtual int init() { return 0; }
40    virtual void exit() { }
4141
4242private:
43   astring     m_name;
44   astring     m_type;
43    astring     m_name;
44    astring     m_type;
4545};
4646
4747// a module_type is simply a pointer to its alloc function
r243230r243231
5151template<class _ModuleClass>
5252osd_module *module_creator()
5353{
54   void *p = osd_malloc(sizeof(_ModuleClass));
55   return new(p) _ModuleClass;
54    void *p = osd_malloc(sizeof(_ModuleClass));
55    return new(p) _ModuleClass;
5656}
5757
5858class osd_module_manager
5959{
6060public:
6161
62   static const int MAX_MODULES = 32;
62    static const int MAX_MODULES = 32;
6363
64   osd_module_manager();
65   ~osd_module_manager();
64    osd_module_manager();
65    ~osd_module_manager();
6666
67   void register_module(const module_type &mod_type);
68   bool type_has_name(const char *type, const char *name);
67    void register_module(const module_type &mod_type);
68    bool type_has_name(const char *type, const char *name);
6969
70   osd_module *get_module_generic(const char *type, const char *name);
70    osd_module *get_module_generic(const char *type, const char *name);
7171
72   template<class C>
73   C select_module(const char *type, const char *name = "")
74   {
75      return dynamic_cast<C>(select_module(type, name));
76   }
72    template<class C>
73    C select_module(const char *type, const char *name = "")
74    {
75        return dynamic_cast<C>(select_module(type, name));
76    }
7777
78   osd_module *select_module(const char *type, const char *name = "");
78    osd_module *select_module(const char *type, const char *name = "");
7979
80   void get_module_names(const char *type, const int max, int *num, const char *names[]);
80    void get_module_names(const char *type, const int max, int *num, const char *names[]);
8181
82   void init();
82    void init();
8383
84   void exit();
84    void exit();
8585
8686private:
87   int get_module_index(const char *type, const char *name);
87    int get_module_index(const char *type, const char *name);
8888
89   osd_module *m_modules[MAX_MODULES];
90   osd_module *m_selected[MAX_MODULES];
89    osd_module *m_modules[MAX_MODULES];
90    osd_module *m_selected[MAX_MODULES];
9191};
9292
9393#define MODULE_DEFINITION(_id, _class) \
94   extern const module_type _id ;  \
95   const module_type _id = &module_creator< _class >;
94    extern const module_type _id ;  \
95    const module_type _id = &module_creator< _class >;
9696
9797
9898#define MODULE_NOT_SUPPORTED(_mod, _type, _name) \
99   class _mod : public osd_module { \
100   public: \
101      _mod () \
102      : osd_module(_type, _name) {} \
103      bool probe() const { return false; } \
104   };
99    class _mod : public osd_module { \
100    public: \
101        _mod () \
102        : osd_module(_type, _name) {} \
103        bool probe() const { return false; } \
104    };
105105
106106#endif  /* __OSDMODULE_H__ */
trunk/src/osd/modules/sound/direct_sound.c
r243230r243231
5151{
5252public:
5353
54   sound_direct_sound()
55   : osd_module(OSD_SOUND_PROVIDER, "dsound"), sound_module()
56   {
57   }
58   virtual ~sound_direct_sound() { }
54    sound_direct_sound()
55    : osd_module(OSD_SOUND_PROVIDER, "dsound"), sound_module()
56    {
57    }
58    virtual ~sound_direct_sound() { }
5959
60   virtual int init();
61   virtual void exit();
60    virtual int init();
61    virtual void exit();
6262
63   // sound_module
63    // sound_module
6464
65   virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame);
66   virtual void set_mastervolume(int attenuation);
65    virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame);
66    virtual void set_mastervolume(int attenuation);
6767
6868private:
69   HRESULT      dsound_init();
70   void         dsound_kill();
71   HRESULT      dsound_create_buffers();
72   void         dsound_destroy_buffers();
73   void         copy_sample_data(const INT16 *data, int bytes_to_copy);
69    HRESULT      dsound_init();
70    void         dsound_kill();
71    HRESULT      dsound_create_buffers();
72    void         dsound_destroy_buffers();
73    void         copy_sample_data(const INT16 *data, int bytes_to_copy);
7474
7575};
7676
r243230r243231
448448}
449449
450450#else /* SDLMAME_UNIX */
451   MODULE_NOT_SUPPORTED(sound_direct_sound, OSD_SOUND_PROVIDER, "dsound")
451    MODULE_NOT_SUPPORTED(sound_direct_sound, OSD_SOUND_PROVIDER, "dsound")
452452#endif
453453
454454MODULE_DEFINITION(SOUND_DSOUND, sound_direct_sound)
trunk/src/osd/modules/sound/js_sound.c
r243230r243231
1313
1414#if (defined(SDLMAME_EMSCRIPTEN))
1515
16#include "js_sound.h"
1617#include "emscripten.h"
1718
1819class sound_js : public osd_module, public sound_module
1920{
2021public:
2122
22   sound_js()
23   : osd_module(OSD_SOUND_PROVIDER, "js"), sound_module()
24   {
25   }
26   virtual ~sound_js() { }
23    sound_js()
24    : osd_module(OSD_SOUND_PROVIDER, "js"), sound_module()
25    {
26    }
27    virtual ~sound_js() { }
2728
28   virtual int init();
29   virtual void exit();
29    virtual int init();
30    virtual void exit();
3031
31   // sound_module
32    // sound_module
3233
33   virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame)
34   {
35      EM_ASM_ARGS({
36      // Forward audio stream update on to JS backend implementation.
37      jsmess_update_audio_stream($1, $2);
38      }, (unsigned int)buffer, samples_this_frame);
39   }
40   virtual void set_mastervolume(int attenuation)
41   {
42      EM_ASM_ARGS({
43      // Forward volume update on to JS backend implementation.
44      jsmess_set_mastervolume($0);
45      }, attenuation);
46   }
34    virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame)
35    {
36        EM_ASM_ARGS({
37        // Forward audio stream update on to JS backend implementation.
38        jsmess_update_audio_stream($1, $2);
39        }, (unsigned int)buffer, samples_this_frame);
40    }
41    virtual void set_mastervolume(int attenuation)
42    {
43        EM_ASM_ARGS({
44        // Forward volume update on to JS backend implementation.
45        jsmess_set_mastervolume($0);
46        }, attenuation);
47    }
4748
4849};
4950
5051#else /* SDLMAME_UNIX */
51   MODULE_NOT_SUPPORTED(sound_js, OSD_SOUND_PROVIDER, "js")
52    MODULE_NOT_SUPPORTED(sound_js, OSD_SOUND_PROVIDER, "js")
5253#endif
5354
5455MODULE_DEFINITION(SOUND_JS, sound_js)
trunk/src/osd/modules/sound/none.c
r243230r243231
1414class sound_none : public osd_module, public sound_module
1515{
1616public:
17   sound_none()
18   : osd_module(OSD_SOUND_PROVIDER, "none"), sound_module()
19   {
20   }
21   virtual ~sound_none() { }
17    sound_none()
18    : osd_module(OSD_SOUND_PROVIDER, "none"), sound_module()
19    {
20    }
21    virtual ~sound_none() { }
2222
23   virtual int init() { return 0; }
24   virtual void exit() { }
23    virtual int init() { return 0; }
24    virtual void exit() { }
2525
26   // sound_module
26    // sound_module
2727
28   virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) { }
29   virtual void set_mastervolume(int attenuation) { }
28    virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) { }
29    virtual void set_mastervolume(int attenuation) { }
3030
3131};
3232
trunk/src/osd/modules/sound/sdl_sound.c
r243230r243231
1212#include "sound_module.h"
1313#include "modules/osdmodule.h"
1414
15#if (!defined(OSD_WINDOWS))
15#if (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(OSD_WINDOWS))
1616
1717// standard sdl header
1818#include "../../sdl/sdlinc.h"
r243230r243231
4343{
4444public:
4545
46   friend void sdl_callback(void *userdata, Uint8 *stream, int len);
46    friend void sdl_callback(void *userdata, Uint8 *stream, int len);
4747
48   // number of samples per SDL callback
49   static const int SDL_XFER_SAMPLES = 512;
48    // number of samples per SDL callback
49    static const int SDL_XFER_SAMPLES = 512;
5050
51   sound_sdl()
52   : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(),
53      stream_in_initialized(0),
54      stream_loop(0),
55      attenuation(0)
56   {
57      sdl_xfer_samples = SDL_XFER_SAMPLES;
58   }
59   virtual ~sound_sdl() { }
51    sound_sdl()
52    : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(),
53      stream_in_initialized(0),
54      stream_loop(0),
55      attenuation(0)
56    {
57        sdl_xfer_samples = SDL_XFER_SAMPLES;
58    }
59    virtual ~sound_sdl() { }
6060
61   virtual int init();
62   virtual void exit();
61    virtual int init();
62    virtual void exit();
6363
64   // sound_module
64    // sound_module
6565
66   virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame);
67   virtual void set_mastervolume(int attenuation);
66    virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame);
67    virtual void set_mastervolume(int attenuation);
6868
6969private:
70   int lock_buffer(bool is_throttled, long offset, long size, void **buffer1, long *length1, void **buffer2, long *length2);
71   void unlock_buffer(void);
72   void att_memcpy(void *dest, const INT16 *data, int bytes_to_copy);
73   void copy_sample_data(bool is_throttled, const INT16 *data, int bytes_to_copy);
74   int sdl_create_buffers(void);
75   void sdl_destroy_buffers(void);
70    int lock_buffer(bool is_throttled, long offset, long size, void **buffer1, long *length1, void **buffer2, long *length2);
71    void unlock_buffer(void);
72    void att_memcpy(void *dest, const INT16 *data, int bytes_to_copy);
73    void copy_sample_data(bool is_throttled, const INT16 *data, int bytes_to_copy);
74    int sdl_create_buffers(void);
75    void sdl_destroy_buffers(void);
7676
77   int sdl_xfer_samples;
78   int stream_in_initialized;
79   int stream_loop;
80   int attenuation;
77    int sdl_xfer_samples;
78    int stream_in_initialized;
79    int stream_loop;
80    int attenuation;
8181
82   int              buf_locked;
82    int              buf_locked;
8383
84   INT8             *stream_buffer;
85   volatile INT32   stream_playpos;
84    INT8             *stream_buffer;
85    volatile INT32   stream_playpos;
8686
87   UINT32           stream_buffer_size;
88   UINT32           stream_buffer_in;
87    UINT32           stream_buffer_size;
88    UINT32           stream_buffer_in;
8989
90   // buffer over/underflow counts
91   int              buffer_underflows;
92   int              buffer_overflows;
90    // buffer over/underflow counts
91    int              buffer_underflows;
92    int              buffer_overflows;
9393
9494
9595};
r243230r243231
354354//============================================================
355355static void sdl_callback(void *userdata, Uint8 *stream, int len)
356356{
357   sound_sdl *thiz = (sound_sdl *) userdata;
357    sound_sdl *thiz = (sound_sdl *) userdata;
358358   int len1, len2, sb_in;
359359
360360   sb_in = thiz->stream_buffer_in;
r243230r243231
379379      len2 = 0;
380380   }
381381
382   memcpy(stream, thiz->stream_buffer + thiz->stream_playpos, len1);
383   memset(thiz->stream_buffer + thiz->stream_playpos, 0, len1); // no longer needed
384   if (len2)
385   {
386      memcpy(stream+len1, thiz->stream_buffer, len2);
387      memset(thiz->stream_buffer, 0, len2); // no longer needed
388   }
382    memcpy(stream, thiz->stream_buffer + thiz->stream_playpos, len1);
383    memset(thiz->stream_buffer + thiz->stream_playpos, 0, len1); // no longer needed
384    if (len2)
385    {
386        memcpy(stream+len1, thiz->stream_buffer, len2);
387        memset(thiz->stream_buffer, 0, len2); // no longer needed
388    }
389389
390390
391391   // move the play cursor
392   thiz->stream_playpos += len1 + len2;
392    thiz->stream_playpos += len1 + len2;
393393   if (thiz->stream_playpos >= thiz->stream_buffer_size)
394394   {
395      thiz->stream_playpos -= thiz->stream_buffer_size;
395       thiz->stream_playpos -= thiz->stream_buffer_size;
396396      thiz->stream_loop = 0;
397397
398398      if (LOG_SOUND)
r243230r243231
416416   SDL_AudioSpec   aspec, obtained;
417417   char audio_driver[16] = "";
418418
419   if (LOG_SOUND)
420      sound_log = fopen(SDLMAME_SOUND_LOG, "w");
419    if (LOG_SOUND)
420        sound_log = fopen(SDLMAME_SOUND_LOG, "w");
421421
422   // skip if sound disabled
423   if (sample_rate() != 0)
424   {
425      if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
426         osd_printf_error("Could not initialize SDL %s\n", SDL_GetError());
427         return -1;
428      }
422    // skip if sound disabled
423    if (sample_rate() != 0)
424    {
425        if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
426            osd_printf_error("Could not initialize SDL %s\n", SDL_GetError());
427            return -1;
428        }
429429
430      osd_printf_verbose("Audio: Start initialization\n");
431   #if (SDLMAME_SDL2)
432      strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver));
433   #else
434      SDL_AudioDriverName(audio_driver, sizeof(audio_driver));
435   #endif
436      osd_printf_verbose("Audio: Driver is %s\n", audio_driver);
430        osd_printf_verbose("Audio: Start initialization\n");
431    #if (SDLMAME_SDL2)
432        strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver));
433    #else
434        SDL_AudioDriverName(audio_driver, sizeof(audio_driver));
435    #endif
436        osd_printf_verbose("Audio: Driver is %s\n", audio_driver);
437437
438      sdl_xfer_samples = SDL_XFER_SAMPLES;
439      stream_in_initialized = 0;
440      stream_loop = 0;
438        sdl_xfer_samples = SDL_XFER_SAMPLES;
439        stream_in_initialized = 0;
440        stream_loop = 0;
441441
442      // set up the audio specs
443      aspec.freq = sample_rate();
444      aspec.format = AUDIO_S16SYS;    // keep endian independent
445      aspec.channels = n_channels;
446      aspec.samples = sdl_xfer_samples;
447      aspec.callback = sdl_callback;
448      aspec.userdata = this;
442        // set up the audio specs
443        aspec.freq = sample_rate();
444        aspec.format = AUDIO_S16SYS;    // keep endian independent
445        aspec.channels = n_channels;
446        aspec.samples = sdl_xfer_samples;
447        aspec.callback = sdl_callback;
448        aspec.userdata = this;
449449
450      if (SDL_OpenAudio(&aspec, &obtained) < 0)
451         goto cant_start_audio;
450        if (SDL_OpenAudio(&aspec, &obtained) < 0)
451            goto cant_start_audio;
452452
453      osd_printf_verbose("Audio: frequency: %d, channels: %d, samples: %d\n",
454                     obtained.freq, obtained.channels, obtained.samples);
453        osd_printf_verbose("Audio: frequency: %d, channels: %d, samples: %d\n",
454                            obtained.freq, obtained.channels, obtained.samples);
455455
456      sdl_xfer_samples = obtained.samples;
456        sdl_xfer_samples = obtained.samples;
457457
458      audio_latency = m_audio_latency;
458        audio_latency = m_audio_latency;
459459
460      // pin audio latency
461      if (audio_latency > MAX_AUDIO_LATENCY)
462      {
463         audio_latency = MAX_AUDIO_LATENCY;
464      }
465      else if (audio_latency < 1)
466      {
467         audio_latency = 1;
468      }
460        // pin audio latency
461        if (audio_latency > MAX_AUDIO_LATENCY)
462        {
463            audio_latency = MAX_AUDIO_LATENCY;
464        }
465        else if (audio_latency < 1)
466        {
467            audio_latency = 1;
468        }
469469
470      // compute the buffer sizes
471      stream_buffer_size = (sample_rate() * 2 * sizeof(INT16) * (2 + audio_latency)) / 30;
472      stream_buffer_size = (stream_buffer_size / 1024) * 1024;
473      if (stream_buffer_size < 1024)
474         stream_buffer_size = 1024;
470        // compute the buffer sizes
471        stream_buffer_size = (sample_rate() * 2 * sizeof(INT16) * (2 + audio_latency)) / 30;
472        stream_buffer_size = (stream_buffer_size / 1024) * 1024;
473        if (stream_buffer_size < 1024)
474            stream_buffer_size = 1024;
475475
476      // create the buffers
477      if (sdl_create_buffers())
478         goto cant_create_buffers;
476        // create the buffers
477        if (sdl_create_buffers())
478            goto cant_create_buffers;
479479
480      // set the startup volume
481      set_mastervolume(attenuation);
482      osd_printf_verbose("Audio: End initialization\n");
483      return 0;
480        // set the startup volume
481        set_mastervolume(attenuation);
482        osd_printf_verbose("Audio: End initialization\n");
483        return 0;
484484
485      // error handling
486   cant_create_buffers:
487   cant_start_audio:
488      osd_printf_verbose("Audio: Initialization failed. SDL error: %s\n", SDL_GetError());
485        // error handling
486    cant_create_buffers:
487    cant_start_audio:
488        osd_printf_verbose("Audio: Initialization failed. SDL error: %s\n", SDL_GetError());
489489
490      return -1;
491   }
490        return -1;
491    }
492492
493   return 0;
493    return 0;
494494}
495495
496496
r243230r243231
501501
502502void sound_sdl::exit()
503503{
504   // if nothing to do, don't do it
505   if (sample_rate() == 0)
506      return;
504    // if nothing to do, don't do it
505    if (sample_rate() == 0)
506        return;
507507
508   osd_printf_verbose("sdl_kill: closing audio\n");
508    osd_printf_verbose("sdl_kill: closing audio\n");
509509   SDL_CloseAudio();
510510
511511   SDL_QuitSubSystem(SDL_INIT_AUDIO);
512512
513   // kill the buffers
514   sdl_destroy_buffers();
513    // kill the buffers
514    sdl_destroy_buffers();
515515
516   // print out over/underflow stats
517   if (buffer_overflows || buffer_underflows)
518      osd_printf_verbose("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows);
516    // print out over/underflow stats
517    if (buffer_overflows || buffer_underflows)
518        osd_printf_verbose("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows);
519519
520   if (LOG_SOUND)
521   {
522      fprintf(sound_log, "Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows);
523      fclose(sound_log);
524   }
520    if (LOG_SOUND)
521    {
522        fprintf(sound_log, "Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows);
523        fclose(sound_log);
524    }
525525}
526526
527527
r243230r243231
555555
556556
557557#else /* SDLMAME_UNIX */
558   MODULE_NOT_SUPPORTED(sound_sdl, OSD_SOUND_PROVIDER, "sdl")
558    MODULE_NOT_SUPPORTED(sound_sdl, OSD_SOUND_PROVIDER, "sdl")
559559#endif
560560
561561MODULE_DEFINITION(SOUND_SDL, sound_sdl)
trunk/src/osd/modules/sound/sound_module.h
r243230r243231
1818class sound_module
1919{
2020public:
21   sound_module() : m_sample_rate(0), m_audio_latency(1) { }
21    sound_module() : m_sample_rate(0), m_audio_latency(1) { }
2222
23   virtual ~sound_module() { }
23    virtual ~sound_module() { }
2424
25   virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) = 0;
26   virtual void set_mastervolume(int attenuation) = 0;
25    virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) = 0;
26    virtual void set_mastervolume(int attenuation) = 0;
2727
28   int sample_rate() { return m_sample_rate; }
28    int sample_rate() { return m_sample_rate; }
2929
30   int m_sample_rate;
31   int m_audio_latency;
30    int m_sample_rate;
31    int m_audio_latency;
3232};
3333
3434#endif /* FONT_MODULE_H_ */
trunk/src/osd/modules/sync/sync_mini.c
r243230r243231
160160void osd_thread_wait_free(osd_thread *thread)
161161{
162162}
163
trunk/src/osd/modules/sync/sync_ntc.c
r243230r243231
411411{
412412   if (timeout == OSD_EVENT_WAIT_INFINITE)
413413      timeout = osd_ticks_per_second() * (osd_ticks_t)10000;
414
414   
415415   pthread_mutex_lock(&event->mutex);
416416   if (!timeout)
417417   {
r243230r243231
531531   pthread_join(thread->thread, NULL);
532532   free(thread);
533533}
534
trunk/src/osd/modules/sync/sync_os2.c
r243230r243231
388388{
389389   ULONG rc;
390390   ULONG timeout_param;
391
391   
392392   if (timeout == OSD_EVENT_WAIT_INFINITE)
393393      timeout_param = SEM_INDEFINITE_WAIT;
394394   else
trunk/src/osd/modules/sync/sync_sdl.c
r243230r243231
326326   thread->callback = callback;
327327   thread->param = cbparam;
328328#ifdef SDLMAME_SDL2
329   thread->thread = SDL_CreateThread(worker_thread_entry, "Thread", thread);
329    thread->thread = SDL_CreateThread(worker_thread_entry, "Thread", thread);
330330#else
331   thread->thread = SDL_CreateThread(worker_thread_entry, thread);
331    thread->thread = SDL_CreateThread(worker_thread_entry, thread);
332332#endif
333333   if ( thread->thread == NULL )
334334   {
r243230r243231
366366   SDL_WaitThread(thread->thread, &status);
367367   free(thread);
368368}
369
trunk/src/osd/modules/sync/sync_tc.c
r243230r243231
246246{
247247   if (timeout == OSD_EVENT_WAIT_INFINITE)
248248      timeout = osd_ticks_per_second() * (osd_ticks_t)10000;
249
249   
250250   pthread_mutex_lock(&event->mutex);
251251   if (!timeout)
252252   {
r243230r243231
389389   pthread_join(thread->thread, NULL);
390390   free(thread);
391391}
392
trunk/src/osd/modules/sync/sync_windows.c
r243230r243231
244244      timeout_param = INFINITE;
245245   else
246246      timeout_param = timeout * 1000 / osd_ticks_per_second();
247
247   
248248   int ret = WaitForSingleObject((HANDLE) event, timeout_param);
249249   return (ret == WAIT_OBJECT_0);
250250}
trunk/src/osd/modules/sync/work_osd.c
r243230r243231
7070template<typename _PtrType>
7171static void spin_while(const volatile _PtrType * volatile ptr, const _PtrType val, const osd_ticks_t timeout, const int invert = 0)
7272{
73   osd_ticks_t stopspin = osd_ticks() + timeout;
73    osd_ticks_t stopspin = osd_ticks() + timeout;
7474
75   do {
76      int spin = 10000;
77      while (--spin)
78      {
79         if ((*ptr != val) ^ invert)
80            return;
81      }
82   } while (((*ptr == val) ^ invert) && osd_ticks() < stopspin);
75    do {
76        int spin = 10000;
77        while (--spin)
78        {
79            if ((*ptr != val) ^ invert)
80                return;
81        }
82    } while (((*ptr == val) ^ invert) && osd_ticks() < stopspin);
8383}
8484
8585template<typename _PtrType>
8686static void spin_while_not(const volatile _PtrType * volatile ptr, const _PtrType val, const osd_ticks_t timeout)
8787{
88   spin_while(ptr, val, timeout, 1);
88    spin_while(ptr, val, timeout, 1);
8989}
9090
9191
r243230r243231
553553   if (item->event == NULL)
554554   {
555555      // TODO: do we need to measure the spin time here as well? and how can we do it?
556      spin_while(&item->done, 0, timeout);
556        spin_while(&item->done, 0, timeout);
557557   }
558558
559559   // otherwise, block on the event until done
trunk/src/osd/osdcore.c
r243230r243231
5454output_delegate osd_set_output_channel(output_channel channel, output_delegate callback)
5555{
5656   if (!(channel < OSD_OUTPUT_CHANNEL_COUNT) || callback.isnull())
57   {
58      throw std::exception();
59   }
57    {
58       throw std::exception();
59    }
6060
6161   /* return the originals if requested */
6262   output_delegate prevcb = output_cb[channel];
r243230r243231
166166   va_end(argptr);
167167}
168168#endif
169
trunk/src/osd/osdepend.h
r243230r243231
3232class osd_font
3333{
3434public:
35   virtual ~osd_font() {}
35    virtual ~osd_font() {}
3636
37   virtual bool open(const char *font_path, const char *name, int &height) = 0;
38   virtual void close() = 0;
39   virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0;
37    virtual bool open(const char *font_path, const char *name, int &height) = 0;
38    virtual void close() = 0;
39    virtual bool get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0;
4040};
4141
4242// ======================> osd_interface
trunk/src/osd/osdmini/minimisc.c
r243230r243231
8181   // can't support clipboards generically
8282   return NULL;
8383}
84
trunk/src/osd/sdl/blit13.h
r243230r243231
114114
115115#define TEXCOPY_M( _name, _src_type, _dest_type,  _op, _len_div) \
116116INLINE void texcopy_##_name (const texture_info *texture, const render_texinfo *texsource) { \
117   ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \
117    ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \
118118   int x, y; \
119119   /* loop over Y */ \
120120   for (y = 0; y < texsource->height; y++) { \
r243230r243231
134134
135135#define TEXROT( _name, _src_type, _dest_type, _op) \
136136INLINE void texcopy_rot_##_name (const texture_info *texture, const render_texinfo *texsource) { \
137   ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \
137    ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \
138138   int x, y; \
139139   const quad_setup_data *setup = &texture->m_setup; \
140140   int dudx = setup->dudx; \
trunk/src/osd/sdl/draw13.c
r243230r243231
4848
4949static inline bool is_opaque(const float &a)
5050{
51   return (a >= 1.0f);
51    return (a >= 1.0f);
5252}
5353
5454static inline bool is_transparent(const float &a)
5555{
56   return (a <  0.0001f);
56    return (a <  0.0001f);
5757}
5858
5959//============================================================
r243230r243231
6363
6464struct quad_setup_data
6565{
66   quad_setup_data()
67   : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
68      rotwidth(0), rotheight(0)
69   {}
70   void compute(const render_primitive &prim);
66    quad_setup_data()
67    : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
68      rotwidth(0), rotheight(0)
69    {}
70    void compute(const render_primitive &prim);
7171
7272   INT32           dudx, dvdx, dudy, dvdy;
7373   INT32           startu, startv;
r243230r243231
105105/* texture_info holds information about a texture */
106106class texture_info
107107{
108   friend class simple_list<texture_info>;
108    friend class simple_list<texture_info>;
109109public:
110   texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
111   ~texture_info();
110    texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
111    ~texture_info();
112112
113   void set_data(const render_texinfo &texsource, const UINT32 flags);
114   void render_quad(const render_primitive *prim, const int x, const int y);
115   bool matches(const render_primitive &prim, const quad_setup_data &setup);
113    void set_data(const render_texinfo &texsource, const UINT32 flags);
114    void render_quad(const render_primitive *prim, const int x, const int y);
115    bool matches(const render_primitive &prim, const quad_setup_data &setup);
116116
117   copy_info_t *compute_size_type();
117    copy_info_t *compute_size_type();
118118
119119   void                *m_pixels;            // pixels for the texture
120120   int                 m_pitch;
r243230r243231
125125   osd_ticks_t         m_last_access;
126126
127127   int raw_width() const { return m_texinfo.width; }
128   int raw_height() const { return m_texinfo.height; }
128    int raw_height() const { return m_texinfo.height; }
129129
130   texture_info *next() { return m_next; }
131   const render_texinfo &texinfo() const { return m_texinfo; }
132   render_texinfo &texinfo() { return m_texinfo; }
130    texture_info *next() { return m_next; }
131    const render_texinfo &texinfo() const { return m_texinfo; }
132    render_texinfo &texinfo() { return m_texinfo; }
133133
134   const HashT hash() const { return m_hash; }
135   const UINT32 flags() const { return m_flags; }
136   const bool is_pixels_owned() const { // do we own / allocated it ?
137      return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC)
138            && (m_copyinfo->func != NULL)) ;
139   }
134    const HashT hash() const { return m_hash; }
135    const UINT32 flags() const { return m_flags; }
136    const bool is_pixels_owned() const { // do we own / allocated it ?
137        return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC)
138                && (m_copyinfo->func != NULL)) ;
139    }
140140
141141private:
142   Uint32              m_sdl_access;
143   SDL_Renderer *      m_renderer;
144   render_texinfo      m_texinfo;            // copy of the texture info
145   HashT               m_hash;               // hash value for the texture (must be >= pointer size)
146   UINT32              m_flags;              // rendering flags
142    Uint32              m_sdl_access;
143    SDL_Renderer *      m_renderer;
144    render_texinfo      m_texinfo;            // copy of the texture info
145    HashT               m_hash;               // hash value for the texture (must be >= pointer size)
146    UINT32              m_flags;              // rendering flags
147147
148   SDL_Texture *       m_texture_id;
149   int                 m_is_rotated;
148    SDL_Texture *       m_texture_id;
149    int                 m_is_rotated;
150150
151   int                 m_format;             // texture format
152   SDL_BlendMode       m_sdl_blendmode;
151    int                 m_format;             // texture format
152    SDL_BlendMode       m_sdl_blendmode;
153153
154   texture_info *      m_next;               // next texture in the list
154    texture_info *      m_next;               // next texture in the list
155155};
156156
157157/* sdl_info is the information about SDL for the current screen */
158158struct sdl_info
159159{
160   sdl_info()
161   : m_blittimer(0), m_renderer(NULL),
162      m_hofs(0), m_vofs(0),
163      m_resize_pending(0), m_resize_width(0), m_resize_height(0),
164      m_last_blit_time(0), m_last_blit_pixels(0)
165   {}
160    sdl_info()
161    : m_blittimer(0), m_renderer(NULL),
162      m_hofs(0), m_vofs(0),
163      m_resize_pending(0), m_resize_width(0), m_resize_height(0),
164      m_last_blit_time(0), m_last_blit_pixels(0)
165    {}
166166
167   void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
167    void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
168168
169   texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
170   texture_info *texture_update(const render_primitive &prim);
169    texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
170    texture_info *texture_update(const render_primitive &prim);
171171
172172   INT32           m_blittimer;
173173
r243230r243231
389389   target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0);
390390   target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0);
391391
392   SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode);
393   set_coloralphamode(m_texture_id, &prim->color);
394   SDL_RenderCopy(m_renderer,  m_texture_id, NULL, &target_rect);
392    SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode);
393    set_coloralphamode(m_texture_id, &prim->color);
394    SDL_RenderCopy(m_renderer,  m_texture_id, NULL, &target_rect);
395395}
396396
397397void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
398398{
399   SDL_Rect target_rect;
399    SDL_Rect target_rect;
400400
401   target_rect.x = x;
402   target_rect.y = y;
403   target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0);
404   target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0);
401    target_rect.x = x;
402    target_rect.y = y;
403    target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0);
404    target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0);
405405
406   if (texture)
407   {
408      copy_info_t *copyinfo = texture->m_copyinfo;
409      copyinfo->time -= osd_ticks();
410      texture->render_quad(prim, x, y);
411      copyinfo->time += osd_ticks();
406    if (texture)
407    {
408        copy_info_t *copyinfo = texture->m_copyinfo;
409        copyinfo->time -= osd_ticks();
410        texture->render_quad(prim, x, y);
411        copyinfo->time += osd_ticks();
412412
413      copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height()));
414      if (m_last_blit_pixels)
415      {
416         copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels;
417      }
418      copyinfo->samples++;
419      copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time;
420   }
421   else
422   {
423      UINT32 sr = (UINT32)(255.0f * prim->color.r);
424      UINT32 sg = (UINT32)(255.0f * prim->color.g);
425      UINT32 sb = (UINT32)(255.0f * prim->color.b);
426      UINT32 sa = (UINT32)(255.0f * prim->color.a);
413        copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height()));
414        if (m_last_blit_pixels)
415        {
416            copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels;
417        }
418        copyinfo->samples++;
419        copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time;
420    }
421    else
422    {
423        UINT32 sr = (UINT32)(255.0f * prim->color.r);
424        UINT32 sg = (UINT32)(255.0f * prim->color.g);
425        UINT32 sb = (UINT32)(255.0f * prim->color.b);
426        UINT32 sa = (UINT32)(255.0f * prim->color.a);
427427
428      SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
429      SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa);
430      SDL_RenderFillRect(m_renderer, &target_rect);
431   }
428        SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
429        SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa);
430        SDL_RenderFillRect(m_renderer, &target_rect);
431    }
432432}
433433
434434static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat)
r243230r243231
518518   else
519519      osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>");
520520
521   /* Enable bilinear filtering in case it is supported.
522    * This applies to all texture operations. However, artwort is pre-scaled
523    * and thus shouldn't be affected.
524    */
525   if (video_config.filter)
526   {
527      SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
528   }
529   else
530   {
531      SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
532   }
521    /* Enable bilinear filtering in case it is supported.
522     * This applies to all texture operations. However, artwort is pre-scaled
523     * and thus shouldn't be affected.
524     */
525    if (video_config.filter)
526    {
527        SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
528    }
529    else
530    {
531        SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
532    }
533533
534534   return 0;
535535}
r243230r243231
604604   {
605605      SDL_DisplayMode mode;
606606      //SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
607      SDL_GetWindowDisplayMode(window->sdl_window, &mode);
607        SDL_GetWindowDisplayMode(window->sdl_window, &mode);
608608      sdl->m_original_mode = mode;
609609      mode.w = width;
610610      mode.h = height;
r243230r243231
630630            osd_printf_warning("Ignoring depth %d\n", window->depth);
631631         }
632632      }
633      SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
633        SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
634634#ifndef SDLMAME_WIN32
635      /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
636       * is in place after the mode switch - which will most likely be the case
637       * This is a hack to work around a deficiency in SDL2
638       */
639      SDL_WarpMouseInWindow(window->sdl_window, 1, 1);
635        /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
636         * is in place after the mode switch - which will most likely be the case
637         * This is a hack to work around a deficiency in SDL2
638         */
639        SDL_WarpMouseInWindow(window->sdl_window, 1, 1);
640640#endif
641641   }
642642   else
r243230r243231
736736      SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
737737      sdl->m_resize_pending = 0;
738738      SDL_RenderSetViewport(sdl->m_renderer, NULL);
739      //sdlvideo_monitor_refresh(window->monitor());
739       //sdlvideo_monitor_refresh(window->monitor());
740740
741741   }
742742
r243230r243231
855855
856856   drawsdl2_destroy_all_textures(window);
857857
858   if (window->fullscreen() && video_config.switchres)
859   {
860      SDL_SetWindowFullscreen(window->sdl_window, 0);    // Try to set mode
861      SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode);    // Try to set mode
862      SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN);    // Try to set mode
863   }
858    if (window->fullscreen() && video_config.switchres)
859    {
860        SDL_SetWindowFullscreen(window->sdl_window, 0);    // Try to set mode
861        SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode);    // Try to set mode
862        SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN);    // Try to set mode
863    }
864864
865   SDL_DestroyWindow(window->sdl_window);
865    SDL_DestroyWindow(window->sdl_window);
866866
867867   global_free(sdl);
868868   window->dxdata = NULL;
r243230r243231
889889      {
890890         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
891891         {
892            int perf = bi->perf;
892             int perf = bi->perf;
893893            if (perf == 0)
894894               return bi;
895895            else if (perf > (maxperf * 102) / 100)
r243230r243231
920920
921921bool texture_info::matches(const render_primitive &prim, const quad_setup_data &setup)
922922{
923   return  texinfo().base == prim.texture.base &&
924         texinfo().width == prim.texture.width &&
925         texinfo().height == prim.texture.height &&
926         texinfo().rowpixels == prim.texture.rowpixels &&
927         m_setup.dudx == setup.dudx &&
928         m_setup.dvdx == setup.dvdx &&
929         m_setup.dudy == setup.dudy &&
930         m_setup.dvdy == setup.dvdy &&
931         ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0;
923    return  texinfo().base == prim.texture.base &&
924            texinfo().width == prim.texture.width &&
925            texinfo().height == prim.texture.height &&
926            texinfo().rowpixels == prim.texture.rowpixels &&
927            m_setup.dudx == setup.dudx &&
928            m_setup.dvdx == setup.dvdx &&
929            m_setup.dudy == setup.dudy &&
930            m_setup.dvdy == setup.dvdy &&
931            ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0;
932932}
933933
934934//============================================================
r243230r243231
937937
938938texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags)
939939{
940
940941   // fill in the core data
941   m_renderer = renderer;
942    m_renderer = renderer;
942943   m_hash = texture_compute_hash(texsource, flags);
943944   m_flags = flags;
944945   m_texinfo = texsource;
r243230r243231
996997
997998   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
998999   {
999      if (m_copyinfo->func != NULL)
1000         m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp);
1001      else
1002         m_pixels = NULL;
1000       if (m_copyinfo->func != NULL)
1001           m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp);
1002       else
1003           m_pixels = NULL;
10031004   }
10041005   m_last_access = osd_ticks();
10051006
r243230r243231
10071008
10081009texture_info::~texture_info()
10091010{
1010   if ( is_pixels_owned() && (m_pixels != NULL) )
1011      free(m_pixels);
1012   SDL_DestroyTexture(m_texture_id);
1011    if ( is_pixels_owned() && (m_pixels != NULL) )
1012        free(m_pixels);
1013    SDL_DestroyTexture(m_texture_id);
10131014}
10141015
10151016//============================================================
r243230r243231
10811082
10821083#if 0
10831084   printf("tl.u %f tl.v %f\n", texcoords->tl.u, texcoords->tl.v);
1084   printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v);
1085   printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v);
1086   printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v);
1085    printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v);
1086    printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v);
1087    printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v);
10871088   /* compute start and delta U,V coordinates now */
10881089#endif
10891090
r243230r243231
11611162   if (texture == NULL && prim.texture.base != NULL)
11621163   {
11631164      texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags));
1164      /* add us to the texture list */
1165       /* add us to the texture list */
11651166      m_texlist.prepend(*texture);
11661167
11671168   }
r243230r243231
11901191   if(window->primlist)
11911192   {
11921193      window->primlist->acquire_lock();
1193      sdl->m_texlist.reset();
1194      window->primlist->release_lock();
1194        sdl->m_texlist.reset();
1195        window->primlist->release_lock();
11951196   }
11961197   else
1197      sdl->m_texlist.reset();
1198        sdl->m_texlist.reset();
11981199}
trunk/src/osd/sdl/drawogl.c
r243230r243231
161161/* texture_info holds information about a texture */
162162struct texture_info
163163{
164   texture_info()
165   : hash(0), flags(0), rawwidth(0), rawheight(0),
166      rawwidth_create(0), rawheight_create(0),
167      type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0),
168      texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL),
169      data_own(0), texCoordBufferName(0)
170   {
171      for (int i=0; i<2; i++)
172      {
173         mpass_textureunit[i] = 0;
174         mpass_texture_mamebm[i] = 0;
175         mpass_fbo_mamebm[i] = 0;
176         mpass_texture_scrn[i] = 0;
177         mpass_fbo_scrn[i] = 0;
178      }
179      for (int i=0; i<8; i++)
180         texCoord[i] = 0.0f;
181   }
164    texture_info()
165    : hash(0), flags(0), rawwidth(0), rawheight(0),
166      rawwidth_create(0), rawheight_create(0),
167      type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0),
168      texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL),
169      data_own(0), texCoordBufferName(0)
170    {
171        for (int i=0; i<2; i++)
172        {
173            mpass_textureunit[i] = 0;
174            mpass_texture_mamebm[i] = 0;
175            mpass_fbo_mamebm[i] = 0;
176            mpass_texture_scrn[i] = 0;
177            mpass_fbo_scrn[i] = 0;
178        }
179        for (int i=0; i<8; i++)
180            texCoord[i] = 0.0f;
181    }
182182
183183   HashT               hash;               // hash value for the texture (must be >= pointer size)
184184   UINT32              flags;              // rendering flags
r243230r243231
217217/* sdl_info is the information about SDL for the current screen */
218218struct sdl_info
219219{
220   sdl_info()
221   : blittimer(0), extra_flags(0),
220    sdl_info()
221    : blittimer(0), extra_flags(0),
222222#if (SDLMAME_SDL2)
223      gl_context_id(0),
223      gl_context_id(0),
224224#else
225      sdlsurf(NULL),
225      sdlsurf(NULL),
226226#endif
227      initialized(0),
228      last_blendmode(0),
229      texture_max_width(0),
230      texture_max_height(0),
231      texpoweroftwo(0),
232      usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL),
233      glsl_program_num(0),
234      glsl_program_mb2sc(0),
235      usetexturerect(0),
236      init_context(0),
237      last_hofs(0.0f),
238      last_vofs(0.0f),
239      surf_w(0),
240      surf_h(0)
241   {
242      for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++)
243         texhash[i] = NULL;
244      for (int i=0; i < 2*GLSL_SHADER_MAX; i++)
245         glsl_program[i] = 0;
246      for (int i=0; i < 8; i++)
247         texVerticex[i] = 0.0f;
248   }
227      initialized(0),
228      last_blendmode(0),
229      texture_max_width(0),
230      texture_max_height(0),
231      texpoweroftwo(0),
232      usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL),
233      glsl_program_num(0),
234      glsl_program_mb2sc(0),
235      usetexturerect(0),
236      init_context(0),
237      last_hofs(0.0f),
238      last_vofs(0.0f),
239      surf_w(0),
240      surf_h(0)
241    {
242        for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++)
243            texhash[i] = NULL;
244        for (int i=0; i < 2*GLSL_SHADER_MAX; i++)
245            glsl_program[i] = 0;
246        for (int i=0; i < 8; i++)
247            texVerticex[i] = 0.0f;
248    }
249249
250250   INT32           blittimer;
251251   UINT32          extra_flags;
r243230r243231
30793079      sdl->texhash[i] = NULL;
30803080      if (texture != NULL)
30813081      {
3082         if(sdl->usevbo)
3083         {
3084            pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) );
3085            texture->texCoordBufferName=0;
3086         }
3082            if(sdl->usevbo)
3083            {
3084                pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) );
3085                texture->texCoordBufferName=0;
3086            }
30873087
3088         if(sdl->usepbo && texture->pbo)
3089         {
3090            pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) );
3091            texture->pbo=0;
3092         }
3088            if(sdl->usepbo && texture->pbo)
3089            {
3090                pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) );
3091                texture->pbo=0;
3092            }
30933093
3094         if( sdl->glsl_program_num > 1 )
3095         {
3096            assert(sdl->usefbo);
3097            pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]);
3098            glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]);
3099         }
3094            if( sdl->glsl_program_num > 1 )
3095            {
3096                assert(sdl->usefbo);
3097                pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]);
3098                glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]);
3099            }
31003100
3101         if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 )
3102         {
3103            assert(sdl->usefbo);
3104            pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]);
3105            glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
3106         }
3101            if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 )
3102            {
3103                assert(sdl->usefbo);
3104                pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]);
3105                glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
3106            }
31073107
3108         glDeleteTextures(1, (GLuint *)&texture->texture);
3109         if ( texture->data_own )
3110         {
3111            free(texture->data);
3112            texture->data=NULL;
3113            texture->data_own=FALSE;
3114         }
3115         global_free(texture);
3108            glDeleteTextures(1, (GLuint *)&texture->texture);
3109            if ( texture->data_own )
3110            {
3111                free(texture->data);
3112                texture->data=NULL;
3113                texture->data_own=FALSE;
3114            }
3115            global_free(texture);
31163116      }
31173117      i++;
31183118   }
trunk/src/osd/sdl/input.c
r243230r243231
19861986            else
19871987            {
19881988#ifndef SDLMAME_WIN32
1989               /* FIXME: SDL2 sends some spurious resize events on Ubuntu
1990                * while in fullscreen mode. Ignore them for now.
1991                */
1992               if (!window->fullscreen())
1989                /* FIXME: SDL2 sends some spurious resize events on Ubuntu
1990                 * while in fullscreen mode. Ignore them for now.
1991                 */
1992                if (!window->fullscreen())
19931993#endif
1994               {
1995                  //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event));
1996                  if (event.window.data1 != window->width || event.window.data2 != window->height)
1997                     window->window_resize(event.window.data1, event.window.data2);
1998               }
1994                {
1995                       //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event));
1996                       if (event.window.data1 != window->width || event.window.data2 != window->height)
1997                           window->window_resize(event.window.data1, event.window.data2);
1998                }
19991999            }
20002000            focus_window = window;
20012001            break;
trunk/src/osd/sdl/netdev_pcap.c
r243230r243231
9898      return;
9999   }
100100
101   while(devs)
102   {
103      add_netdev(devs->name, devs->description, create_pcap);
104      devs = devs->next;
105   }
101    while(devs)
102    {
103        add_netdev(devs->name, devs->description, create_pcap);
104        devs = devs->next;
105    }
106106}
107107
108108void deinit_pcap()
trunk/src/osd/sdl/netdev_pcap_osx.c
r243230r243231
150150   }
151151
152152#if 1
153   while(devs)
154   {
155      add_netdev(devs->name, devs->description, create_pcap);
156      devs = devs->next;
157   }
153    while(devs)
154    {
155        add_netdev(devs->name, devs->description, create_pcap);
156        devs = devs->next;
157    }
158158#else
159159   if (devs)
160160   {
trunk/src/osd/sdl/osdsdl.h
r243230r243231
3030      #define SDL13_COMBINE_RESIZE (0)
3131   #endif
3232#else
33   #define SDLMAME_INIT_IN_WORKER_THREAD   (0)
33    #define SDLMAME_INIT_IN_WORKER_THREAD   (0)
3434   #define SDL13_COMBINE_RESIZE (0)
3535#endif
3636
r243230r243231
199199   #ifdef USE_NETWORK
200200   virtual bool network_init();
201201   #endif
202   //virtual bool midi_init();
202    //virtual bool midi_init();
203203
204204   virtual void video_exit();
205205   virtual void window_exit();
r243230r243231
208208   #ifdef USE_NETWORK
209209   virtual void network_exit();
210210   #endif
211   //virtual void midi_exit();
211    //virtual void midi_exit();
212212
213   sdl_options &options() { return m_options; }
213    sdl_options &options() { return m_options; }
214214
215215private:
216216   virtual void osd_exit();
r243230r243231
220220   // FIXME: remove machine usage
221221   void extract_video_config(running_machine &machine);
222222
223   sdl_options &m_options;
223    sdl_options &m_options;
224224
225225   watchdog *m_watchdog;
226226
trunk/src/osd/sdl/sdl.mak
r243230r243231
738738   $(OSDOBJ)/modules/debugger/qt/debugqtdeviceinformationwindow.moc.o
739739
740740DEFS += -DUSE_QTDEBUG=1
741
741   
742742else
743743DEFS += -DUSE_QTDEBUG=0
744744endif
trunk/src/osd/sdl/sdldir.c
r243230r243231
152152
153153   if (tmpstr[0] == '$')
154154   {
155
155156      envstr = (char *) osd_malloc_array(strlen(tmpstr)+1);
156157
157158      strcpy(envstr, tmpstr);
trunk/src/osd/sdl/sdlfile.c
r243230r243231
188188
189189      envstr[i] = '\0';
190190
191      const char *envval = osd_getenv(&envstr[1]);
191        const char *envval = osd_getenv(&envstr[1]);
192192      if (envval != NULL)
193193      {
194194         j = strlen(envval) + strlen(tmpstr) + 1;
r243230r243231
505505
506506osd_directory_entry *osd_stat(const char *path)
507507{
508   int err;
509   osd_directory_entry *result = NULL;
510   #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
511   struct stat st;
512   #else
513   struct stat64 st;
514   #endif
508    int err;
509    osd_directory_entry *result = NULL;
510    #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
511    struct stat st;
512    #else
513    struct stat64 st;
514    #endif
515515
516   #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
517   err = stat(path, &st);
518   #else
519   err = stat64(path, &st);
520   #endif
516    #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
517    err = stat(path, &st);
518    #else
519    err = stat64(path, &st);
520    #endif
521521
522   if( err == -1) return NULL;
522    if( err == -1) return NULL;
523523
524   // create an osd_directory_entry; be sure to make sure that the caller can
525   // free all resources by just freeing the resulting osd_directory_entry
526   result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1);
527   strcpy(((char *) result) + sizeof(*result), path);
528   result->name = ((char *) result) + sizeof(*result);
529   result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE;
530   result->size = (UINT64)st.st_size;
524    // create an osd_directory_entry; be sure to make sure that the caller can
525    // free all resources by just freeing the resulting osd_directory_entry
526    result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1);
527    strcpy(((char *) result) + sizeof(*result), path);
528    result->name = ((char *) result) + sizeof(*result);
529    result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE;
530    result->size = (UINT64)st.st_size;
531531
532   return result;
532    return result;
533533}
534534
535535//============================================================
r243230r243231
538538
539539file_error osd_get_full_path(char **dst, const char *path)
540540{
541   file_error err;
542   char path_buffer[512];
541    file_error err;
542    char path_buffer[512];
543543
544   err = FILERR_NONE;
544    err = FILERR_NONE;
545545
546   if (getcwd(path_buffer, 511) == NULL)
547   {
548      printf("osd_get_full_path: failed!\n");
549      err = FILERR_FAILURE;
550   }
551   else
552   {
553      *dst = (char *)osd_malloc_array(strlen(path_buffer)+strlen(path)+3);
546    if (getcwd(path_buffer, 511) == NULL)
547    {
548        printf("osd_get_full_path: failed!\n");
549        err = FILERR_FAILURE;
550    }
551    else
552    {
553        *dst = (char *)osd_malloc_array(strlen(path_buffer)+strlen(path)+3);
554554
555      // if it's already a full path, just pass it through
556      if (path[0] == '/')
557      {
558         strcpy(*dst, path);
559      }
560      else
561      {
562         sprintf(*dst, "%s%s%s", path_buffer, PATH_SEPARATOR, path);
563      }
564   }
555        // if it's already a full path, just pass it through
556        if (path[0] == '/')
557        {
558            strcpy(*dst, path);
559        }
560        else
561        {
562            sprintf(*dst, "%s%s%s", path_buffer, PATH_SEPARATOR, path);
563        }
564    }
565565
566   return err;
566    return err;
567567}
568568
569569//============================================================
r243230r243231
572572
573573const char *osd_get_volume_name(int idx)
574574{
575   if (idx!=0) return NULL;
576   return "/";
575    if (idx!=0) return NULL;
576    return "/";
577577}
578578
579579#endif
trunk/src/osd/sdl/sdlmain.c
r243230r243231
319319#endif
320320
321321   {
322      sdl_options options;
322       sdl_options options;
323323      sdl_osd_interface osd(options);
324324      osd.register_options();
325325      cli_frontend frontend(options, osd);
r243230r243231
688688}
689689
690690#endif
691
692
trunk/src/osd/sdl/sdlos_macosx.c
r243230r243231
121121
122122   return result;
123123}
124
trunk/src/osd/sdl/sdlos_unix.c
r243230r243231
147147   return result;
148148}
149149#endif
150
151
152
trunk/src/osd/sdl/sdlos_win32.c
r243230r243231
101101
102102   return result;
103103}
104
trunk/src/osd/sdl/sdlptty_unix.c
r243230r243231
111111
112112file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize)
113113{
114   return FILERR_ACCESS_DENIED;
114    return FILERR_ACCESS_DENIED;
115115}
116116
117117file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
118118{
119   return FILERR_ACCESS_DENIED;
119    return FILERR_ACCESS_DENIED;
120120}
121121
122122file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
123123{
124   return FILERR_ACCESS_DENIED;
124    return FILERR_ACCESS_DENIED;
125125}
126126
127127file_error sdl_close_ptty(osd_file *file)
128128{
129   return FILERR_ACCESS_DENIED;
129    return FILERR_ACCESS_DENIED;
130130}
131131#endif
trunk/src/osd/sdl/strconv.c
r243230r243231
127127
128128int osd_uchar_from_osdchar(unicode_char *uchar, const char *osdchar, size_t count)
129129{
130   wchar_t wch;
130    wchar_t wch;
131131
132   count = mbstowcs(&wch, (char *)osdchar, 1);
133   if (count != -1)
134      *uchar = wch;
135   else
136      *uchar = 0;
132    count = mbstowcs(&wch, (char *)osdchar, 1);
133    if (count != -1)
134        *uchar = wch;
135    else
136        *uchar = 0;
137137
138   return count;
138    return count;
139139}
140140
141141#endif
trunk/src/osd/sdl/video.c
r243230r243231
154154
155155   #if defined(SDLMAME_WIN32)
156156   SDL_GetDesktopDisplayMode(monitor->handle, &dmode);
157   #else
158   SDL_GetCurrentDisplayMode(monitor->handle, &dmode);
159   #endif
157    #else
158    SDL_GetCurrentDisplayMode(monitor->handle, &dmode);
159    #endif
160160   monitor->monitor_width = dmode.w;
161161   monitor->monitor_height = dmode.h;
162162   monitor->center_width = dmode.w;
r243230r243231
227227         SDL_VideoDriverName(monitor->monitor_device, sizeof(monitor->monitor_device)-1);
228228         if (first_call==0)
229229         {
230            const char *dimstr = osd_getenv(SDLENV_DESKTOPDIM);
230            char *dimstr = osd_getenv(SDLENV_DESKTOPDIM);
231231            const SDL_VideoInfo *sdl_vi;
232232
233233            sdl_vi = SDL_GetVideoInfo();
trunk/src/osd/sdl/video.h
r243230r243231
9191
9292   // global configuration
9393   int                 windowed;               // start windowed?
94   int                 prescale;               // prescale factor (not currently supported)
94   int                 prescale;               // prescale factor (supported by accel driver)
9595   int                 keepaspect;             // keep aspect ratio?
9696   int                 numscreens;             // number of screens
9797   int                 centerh;
trunk/src/osd/sdl/window.c
r243230r243231
270270    * The code below will document which hints were set.
271271    */
272272   const char * hints[] = { SDL_HINT_FRAMEBUFFER_ACCELERATION,
273         SDL_HINT_RENDER_DRIVER, SDL_HINT_RENDER_OPENGL_SHADERS,
274         SDL_HINT_RENDER_SCALE_QUALITY,
275         SDL_HINT_RENDER_VSYNC,
276         SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XINERAMA,
277         SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_GRAB_KEYBOARD,
278         SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
279         SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_IDLE_TIMER_DISABLED,
280         SDL_HINT_ORIENTATIONS,
281         SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG,
282         SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_HINT_ALLOW_TOPMOST,
283         SDL_HINT_TIMER_RESOLUTION,
273           SDL_HINT_RENDER_DRIVER, SDL_HINT_RENDER_OPENGL_SHADERS,
274            SDL_HINT_RENDER_SCALE_QUALITY,
275            SDL_HINT_RENDER_VSYNC,
276            SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XINERAMA,
277            SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_GRAB_KEYBOARD,
278            SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
279            SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_IDLE_TIMER_DISABLED,
280            SDL_HINT_ORIENTATIONS,
281            SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG,
282            SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_HINT_ALLOW_TOPMOST,
283            SDL_HINT_TIMER_RESOLUTION,
284284#if SDL_VERSION_ATLEAST(2, 0, 2)
285         SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
286         SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
287         SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
288         SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES,
285            SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
286            SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
287            SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
288            SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES,
289289#endif
290290#if SDL_VERSION_ATLEAST(2, 0, 3)
291         SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED,
292         SDL_HINT_WINRT_PRIVACY_POLICY_URL, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL,
293         SDL_HINT_WINRT_HANDLE_BACK_BUTTON,
291            SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED,
292            SDL_HINT_WINRT_PRIVACY_POLICY_URL, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL,
293            SDL_HINT_WINRT_HANDLE_BACK_BUTTON,
294294#endif
295         NULL
296   };
295            NULL
296    };
297297
298298
299   osd_printf_verbose("\nHints:\n");
300   for (int i = 0; hints[i] != NULL; i++)
301      osd_printf_verbose("\t%-40s %s\n", hints[i], SDL_GetHint(hints[i]));
299    osd_printf_verbose("\nHints:\n");
300    for (int i = 0; hints[i] != NULL; i++)
301        osd_printf_verbose("\t%-40s %s\n", hints[i], SDL_GetHint(hints[i]));
302302#endif
303303
304304   // set up the window list
r243230r243231
10181018
10191019      if (osd_event_wait(rendered_event, event_wait_ticks))
10201020      {
1021         if ((!fullscreen()) || (video_config.switchres))
1022         {
1023            blit_surface_size(width, height);
1024         }
1025         else
1026         {
1027            blit_surface_size(monitor()->center_width, monitor()->center_height);
1028         }
1021          if ((!fullscreen()) || (video_config.switchres))
1022          {
1023              blit_surface_size(width, height);
1024          }
1025          else
1026          {
1027              blit_surface_size(monitor()->center_width, monitor()->center_height);
1028          }
10291029
10301030         // ensure the target bounds are up-to-date, and then get the primitives
1031         set_target_bounds(this);
1031          set_target_bounds(this);
10321032
10331033         render_primitive_list &primlist = target->get_primitives();
10341034
trunk/src/osd/sdl/window.h
r243230r243231
6161      m_fullscreen = !video_config.windowed;
6262      prescale = video_config.prescale;
6363
64      windowed_width = config->width;
65      windowed_height = config->height;
64        windowed_width = config->width;
65        windowed_height = config->height;
6666   }
6767
6868   void video_window_update(running_machine &machine);
trunk/src/osd/windows/vconv.c
r243230r243231
9191   // warning C4510: 'xxx' : default constructor could not be generated
9292   // warning C4512: 'xxx' : assignment operator could not be generated
9393   // warning C4514: 'xxx' : unreferenced inline function has been removed
94   // warning C4619: #pragma warning : there is no warning number 'xxx'
94   // warning C4619: #pragma warning : there is no warning number 'xxx'
9595   // warning C4571: Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
9696   // warning C4610: struct 'xxx' can never be instantiated - user defined constructor required
9797   // warning C4625: 'xxx' : copy constructor could not be generated because a base class copy constructor is inaccessible or deleted
trunk/src/osd/windows/windows.mak
r243230r243231
313313
314314ifeq ($(CROSS_BUILD),1)
315315   LDFLAGS += -static
316endif
316endif   
317317
318318# TODO: needs to use $(CC)
319319TEST_GCC := $(shell gcc --version)
trunk/src/tools/chdman.c
r243230r243231
17021702            report_error(1, "Invalid size string");
17031703      }
17041704   }
1705
1705   
17061706   // process compression
17071707   chd_codec_type compression[4];
17081708   memcpy(compression, s_default_hd_compression, sizeof(compression));
r243230r243231
17571757      if (sscanf(metadata, HARD_DISK_METADATA_FORMAT, &cylinders, &heads, &sectors, &sector_size) != 4)
17581758         report_error(1, "Error parsing hard disk metadata in parent CHD");
17591759   }
1760
1760     
17611761   // validate the size
17621762   if (filesize % sector_size != 0)
17631763      report_error(1, "Data size is not divisible by sector size %d", sector_size);
trunk/src/tools/nltool.c
r243230r243231
8888};
8989
9090NETLIST_START(dummy)
91   /* Standard stuff */
91    /* Standard stuff */
9292
93   CLOCK(clk, 1000) // 1000 Hz
94   SOLVER(Solver, 48000)
93    CLOCK(clk, 1000) // 1000 Hz
94    SOLVER(Solver, 48000)
9595
9696NETLIST_END()
9797
r243230r243231
172172      nl_util::pstring_list ll = nl_util::split(m_logs, ":");
173173      for (int i=0; i < ll.count(); i++)
174174      {
175         pstring name = "log_" + ll[i];
175            pstring name = "log_" + ll[i];
176176         /*netlist_device_t *nc = */ m_setup->register_dev("nld_log", name);
177177         m_setup->register_link(name + ".I", ll[i]);
178178      }
r243230r243231
241241   nt.init();
242242   const netlist_factory_t::list_t &list = nt.setup().factory().list();
243243
244   netlist_sources_t sources;
244    netlist_sources_t sources;
245245
246   sources.add(netlist_source_t("dummy", &netlist_dummy));
247   sources.parse(nt.setup(),"dummy");
246    sources.add(netlist_source_t("dummy", &netlist_dummy));
247    sources.parse(nt.setup(),"dummy");
248248
249249   nt.setup().start_devices();
250250   nt.setup().resolve_inputs();
trunk/src/version.c
r243230r243231
88
99***************************************************************************/
1010
11#define BARE_BUILD_VERSION "0.158"
11#define BARE_BUILD_VERSION "0.157"
1212
1313extern const char bare_build_version[];
1414extern const char build_version[];


Previous 199869 Revisions Next


© 1997-2024 The MAME Team