Previous 199869 Revisions Next

r26549 Sunday 8th December, 2013 at 18:44:12 UTC by Angelo Salese
Added a core for uPD4992 RTC, used by Othello Derby and Power Kick [Angelo Salese]
[src/emu/machine]machine.mak upd4992.c* upd4992.h*
[src/mame]mame.mak
[src/mame/drivers]toaplan2.c
[src/mame/includes]toaplan2.h

trunk/src/emu/machine/machine.mak
r26548r26549
13851385
13861386#-------------------------------------------------
13871387#
1388#@src/emu/machine/upd4992.h,MACHINES += UPD4992
1389#-------------------------------------------------
1390
1391ifneq ($(filter UPD4992,$(MACHINES)),)
1392MACHINEOBJS += $(MACHINEOBJ)/upd4992.o
1393endif
1394
1395
1396#-------------------------------------------------
1397#
13881398#@src/emu/machine/upd4701.h,MACHINES += UPD4701
13891399#-------------------------------------------------
13901400
trunk/src/emu/machine/upd4992.c
r0r26549
1// license: MAME
2// copyright-holders: Angelo Salese
3/***************************************************************************
4
5   uPD4992 parallel RTC
6
7   TODO:
8   - Add timers
9   - Add leap year count
10   - Add 12 hours mode
11   - Add mode/control register
12
13***************************************************************************/
14
15#include "emu.h"
16#include "machine/upd4992.h"
17
18
19
20//**************************************************************************
21//  GLOBAL VARIABLES
22//**************************************************************************
23
24// device type definition
25const device_type UPD4992 = &device_creator<upd4992_device>;
26
27
28//**************************************************************************
29//  LIVE DEVICE
30//**************************************************************************
31
32//-------------------------------------------------
33//  upd4992_device - constructor
34//-------------------------------------------------
35
36upd4992_device::upd4992_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
37   : device_t(mconfig, UPD4992, "uPD4992", tag, owner, clock, "upd4992", __FILE__),
38     device_rtc_interface(mconfig, *this)
39{
40}
41
42
43//-------------------------------------------------
44//  device_validity_check - perform validity checks
45//  on this device
46//-------------------------------------------------
47
48void upd4992_device::device_validity_check(validity_checker &valid) const
49{
50}
51
52
53//-------------------------------------------------
54//  device_start - device-specific startup
55//-------------------------------------------------
56
57void upd4992_device::device_start()
58{
59   m_timer_clock = timer_alloc(TIMER_CLOCK);
60   m_timer_clock->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
61}
62
63
64//-------------------------------------------------
65//  device_reset - device-specific reset
66//-------------------------------------------------
67
68void upd4992_device::device_reset()
69{
70   set_current_time(machine());
71}
72
73
74void upd4992_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
75{
76   switch (id)
77   {
78   case TIMER_CLOCK:
79      advance_seconds();
80      break;
81   }
82}
83
84//-------------------------------------------------
85//  rtc_clock_updated -
86//-------------------------------------------------
87
88void upd4992_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
89{
90/*
91[2]
92x--- ---- 12/24H flag
93-x-- ---- AM/PM flag
94--xx ---- 10 hour digit
95---- xxxx 1s hour digit
96[3]
97xx-- ---- Leap year control
98--xx ---- Leap year counter
99---- xxxx Day of week digit
100[4]
101xxxx ---- 10s day digit
102---- xxxx 1s day digit
103[5]
104xxxx ---- 10s month digit
105---- xxxx 1s month digit
106[6]
107xxxx ---- 10s year digit
108---- xxxx 1s year digit
109[7]
110xxxx ---- Mode register
111---- xxxx Control Register
112*/
113   m_rtc_regs[0] = convert_to_bcd(second);
114   m_rtc_regs[1] = convert_to_bcd(minute);
115   m_rtc_regs[2] = convert_to_bcd(hour);
116   m_rtc_regs[3] = day_of_week-1;
117   m_rtc_regs[4] = convert_to_bcd(day);
118   m_rtc_regs[5] = convert_to_bcd(month);
119   m_rtc_regs[6] = convert_to_bcd(year);
120}
121
122//**************************************************************************
123//  READ/WRITE HANDLERS
124//**************************************************************************
125
126READ8_MEMBER( upd4992_device::read )
127{
128   return m_rtc_regs[offset];
129}
130
131WRITE8_MEMBER( upd4992_device::write )
132{
133   if(offset == 7)
134   {
135      if(data & 8)
136      {
137         if(data & 2) // reset
138         {
139            // ...
140         }
141
142         m_timer_clock->enable(data & 1);
143      }
144   }
145   else // TODO: perhaps there's a write inhibit?
146   {
147      m_rtc_regs[offset] = data;
148      set_time(1, bcd_to_integer(m_rtc_regs[6]),
149               bcd_to_integer(m_rtc_regs[5]),
150               bcd_to_integer(m_rtc_regs[4]),
151               m_rtc_regs[3]+1,
152               bcd_to_integer(m_rtc_regs[2]),
153               bcd_to_integer(m_rtc_regs[1]),
154               bcd_to_integer(m_rtc_regs[0]));
155   }
156}
Property changes on: trunk/src/emu/machine/upd4992.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/emu/machine/upd4992.h
r0r26549
1// license: ?
2// copyright-holders: Angelo Salese
3/***************************************************************************
4
5   uPD4992 RTC
6
7***************************************************************************/
8
9#pragma once
10
11#ifndef __UPD4992DEV_H__
12#define __UPD4992DEV_H__
13
14
15
16//**************************************************************************
17//  INTERFACE CONFIGURATION MACROS
18//**************************************************************************
19
20#define MCFG_UPD4992_ADD(_tag) \
21   MCFG_DEVICE_ADD(_tag, UPD4992, XTAL_32_768kHz)
22
23//**************************************************************************
24//  TYPE DEFINITIONS
25//**************************************************************************
26
27// ======================> upd4992_device
28
29class upd4992_device : public device_t,
30                  public device_rtc_interface
31{
32public:
33   // construction/destruction
34   upd4992_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
35
36   // I/O operations
37   DECLARE_WRITE8_MEMBER( write );
38   DECLARE_READ8_MEMBER( read );
39
40protected:
41   // device-level overrides
42   virtual void device_validity_check(validity_checker &valid) const;
43   virtual void device_start();
44   virtual void device_reset();
45   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
46   virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
47
48private:
49   enum
50   {
51      TIMER_CLOCK
52      //TIMER_TP,
53      //TIMER_DATA_OUT,
54      //TIMER_TEST_MODE
55   };
56
57   emu_timer *m_timer_clock;
58   UINT8 m_rtc_regs[8];
59};
60
61
62// device type definition
63extern const device_type UPD4992;
64
65
66
67//**************************************************************************
68//  GLOBAL VARIABLES
69//**************************************************************************
70
71
72
73#endif
Property changes on: trunk/src/emu/machine/upd4992.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mame/drivers/toaplan2.c
r26548r26549
356356#include "cpu/z80/z80.h"
357357#include "cpu/z180/z180.h"
358358#include "machine/eepromser.h"
359#include "machine/upd4992.h"
359360#include "sound/2151intf.h"
360361#include "sound/3812intf.h"
361362#include "sound/okim6295.h"
r26548r26549
12071208   AM_RANGE(0x700000, 0x700001) AM_READ(video_count_r)
12081209ADDRESS_MAP_END
12091210
1210/* TODO: write in a proper core */
1211WRITE8_MEMBER(toaplan2_state::upd4992_calendar_w)
1212{
1213}
1214
1215READ8_MEMBER(toaplan2_state::upd4992_calendar_r)
1216{
1217   system_time systime;
1218
1219   machine().base_datetime(systime);
1220
1221   switch (offset)
1222   {
1223      case 0:
1224         return ((systime.local_time.second/10)<<4) + (systime.local_time.second%10);
1225      case 1:
1226         return ((systime.local_time.minute/10)<<4) + (systime.local_time.minute%10);
1227      case 2:
1228         return ((systime.local_time.hour/10)<<4) + (systime.local_time.hour%10);
1229      case 3:
1230         return systime.local_time.weekday;
1231      case 4:
1232         return ((systime.local_time.mday/10)<<4) + (systime.local_time.mday%10);
1233      case 5:
1234         return (systime.local_time.month + 1);
1235      case 6:
1236         return (((systime.local_time.year%100)/10)<<4) + (systime.local_time.year%10);
1237      case 7:
1238      default:
1239         return 0;   /* status? the other registers are read only when bit 0 is clear */
1240   }
1241}
1242
12431211static ADDRESS_MAP_START( pwrkick_68k_mem, AS_PROGRAM, 16, toaplan2_state )
12441212   AM_RANGE(0x000000, 0x07ffff) AM_ROM
12451213   AM_RANGE(0x100000, 0x10ffff) AM_RAM
1246   AM_RANGE(0x200000, 0x20000f) AM_READWRITE8(upd4992_calendar_r,upd4992_calendar_w,0x00ff)
1214
1215   AM_RANGE(0x200000, 0x20000f) AM_DEVREADWRITE8("rtc", upd4992_device, read, write, 0x00ff )
12471216   AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001vdp_device, gp9001_vdp_r, gp9001_vdp_w)
12481217   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_word_w) AM_SHARE("paletteram")
12491218   AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff)
r26548r26549
12631232static ADDRESS_MAP_START( othldrby_68k_mem, AS_PROGRAM, 16, toaplan2_state )
12641233   AM_RANGE(0x000000, 0x07ffff) AM_ROM
12651234   AM_RANGE(0x100000, 0x10ffff) AM_RAM
1266   AM_RANGE(0x200000, 0x20000f) AM_READWRITE8(upd4992_calendar_r,upd4992_calendar_w,0x00ff)
1235
1236   AM_RANGE(0x200000, 0x20000f) AM_DEVREADWRITE8("rtc", upd4992_device, read, write, 0x00ff )
12671237   AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001vdp_device, gp9001_vdp_r, gp9001_vdp_w)
12681238   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_word_w) AM_SHARE("paletteram")
12691239   AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff)
r26548r26549
37373707   MCFG_CPU_VBLANK_INT_DRIVER("screen", toaplan2_state,  toaplan2_vblank_irq4)
37383708
37393709   MCFG_MACHINE_START_OVERRIDE(toaplan2_state,toaplan2)
3710   MCFG_UPD4992_ADD("rtc")
37403711
37413712   /* video hardware */
37423713   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
r26548r26549
37673738   MCFG_CPU_VBLANK_INT_DRIVER("screen", toaplan2_state,  toaplan2_vblank_irq4)
37683739
37693740   MCFG_MACHINE_START_OVERRIDE(toaplan2_state,toaplan2)
3741   MCFG_UPD4992_ADD("rtc")
37703742
37713743   /* video hardware */
37723744   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
trunk/src/mame/includes/toaplan2.h
r26548r26549
3535      m_nmk112(*this, "nmk112"),
3636      m_oki(*this, "oki"),
3737      m_oki1(*this, "oki1"),
38      m_eeprom(*this, "eeprom") {
38      m_eeprom(*this, "eeprom"),
39      m_rtc(*this, "rtc") {
3940      m_vdp0 = NULL;
4041      m_vdp1 = NULL;
4142   }
r26548r26549
155156   optional_device<okim6295_device> m_oki;
156157   optional_device<okim6295_device> m_oki1;
157158   optional_device<eeprom_serial_93cxx_device> m_eeprom;
159   optional_device<upd4992_device> m_rtc;
158160
159161   UINT8 m_pwrkick_hopper;
160162   DECLARE_CUSTOM_INPUT_MEMBER(pwrkick_hopper_status_r);
161163   DECLARE_WRITE8_MEMBER(pwrkick_coin_w);
162   DECLARE_READ8_MEMBER(upd4992_calendar_r);
163   DECLARE_WRITE8_MEMBER(upd4992_calendar_w);
164164
165165protected:
166166   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
trunk/src/mame/mame.mak
r26548r26549
465465MACHINES += TMS9901
466466MACHINES += TMS9902
467467MACHINES += UPD1990A
468MACHINES += UPD4992
468469MACHINES += UPD4701
469470MACHINES += UPD7002
470471MACHINES += UPD765

Previous 199869 Revisions Next


© 1997-2024 The MAME Team