1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
// license:BSD-3-Clause
// copyright-holders:hap
// thanks-to:digshadow, segher
/*******************************************************************************
Bandai Tamagotchi generation 1 hardware
* PCB label TMG-M1
* Seiko Epson E0C6S46 MCU under epoxy
*******************************************************************************/
#include "emu.h"
#include "cpu/e0c6200/e0c6s46.h"
#include "sound/spkrdev.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#include "tama.lh"
namespace {
class tamag1_state : public driver_device
{
public:
tamag1_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_out_x(*this, "%u.%u", 0U, 0U)
{ }
void tama(machine_config &config);
DECLARE_INPUT_CHANGED_MEMBER(input_changed);
private:
void tama_palette(palette_device &palette) const;
E0C6S46_PIXEL_UPDATE(pixel_update);
virtual void machine_start() override;
required_device<e0c6s46_device> m_maincpu;
output_finder<16, 40> m_out_x;
};
void tamag1_state::machine_start()
{
m_out_x.resolve();
}
/*******************************************************************************
Video
*******************************************************************************/
E0C6S46_PIXEL_UPDATE(tamag1_state::pixel_update)
{
// 16 COM(common) pins, 40 SEG(segment) pins from MCU,
// 32x16 LCD screen:
static const int seg2x[0x28] =
{
0, 1, 2, 3, 4, 5, 6, 7,
35, 8, 9,10,11,12,13,14,
15,34,33,32,31,30,29,28,
27,26,25,24,36,23,22,21,
20,19,18,17,16,37,38,39
};
int y = com, x = seg2x[seg];
if (cliprect.contains(x, y))
bitmap.pix(y, x) = state;
// 2 rows of indicators:
// above screen: 0:meal, 1:lamp, 2:play, 3:medicine
// under screen: 4:bath, 5:scales, 6:shout, 7:attention
// they are on pin SEG8(x=35) + COM0-3, pin SEG28(x=36) + COM12-15
// output to y.x
m_out_x[y][x] = state;
}
void tamag1_state::tama_palette(palette_device &palette) const
{
palette.set_pen_color(0, rgb_t(0xf1, 0xf0, 0xf9)); // background
palette.set_pen_color(1, rgb_t(0x3c, 0x38, 0x38)); // lcd pixel
}
/*******************************************************************************
Input Ports
*******************************************************************************/
INPUT_CHANGED_MEMBER(tamag1_state::input_changed)
{
// inputs are hooked up backwards here, because MCU input
// ports are all tied to its interrupt controller
int line = param;
int state = newval ? ASSERT_LINE : CLEAR_LINE;
m_maincpu->set_input_line(line, state);
}
static INPUT_PORTS_START( tama )
PORT_START("K0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, E0C6S46_LINE_K00)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, E0C6S46_LINE_K01)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, E0C6S46_LINE_K02)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END
/*******************************************************************************
Machine Configs
*******************************************************************************/
void tamag1_state::tama(machine_config &config)
{
/* basic machine hardware */
E0C6S46(config, m_maincpu, 32.768_kHz_XTAL);
m_maincpu->set_pixel_update_cb(FUNC(tamag1_state::pixel_update));
m_maincpu->write_r<4>().set("speaker", FUNC(speaker_sound_device::level_w)).bit(3);
/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD));
screen.set_refresh_hz(32.768_kHz_XTAL/1024);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
screen.set_size(40, 16);
screen.set_visarea(0, 32-1, 0, 16-1);
screen.set_screen_update("maincpu", FUNC(e0c6s46_device::screen_update));
screen.set_palette("palette");
config.set_default_layout(layout_tama);
PALETTE(config, "palette", FUNC(tamag1_state::tama_palette), 2);
/* sound hardware */
SPEAKER(config, "mono").front_center();
SPEAKER_SOUND(config, "speaker").add_route(ALL_OUTPUTS, "mono", 0.25);
}
/*******************************************************************************
ROM Definitions
*******************************************************************************/
ROM_START( tama )
ROM_REGION( 0x3000, "maincpu", 0 )
ROM_LOAD( "tama.bin", 0x0000, 0x3000, CRC(5c864cb1) SHA1(4b4979cf92dc9d2fb6d7295a38f209f3da144f72) )
ROM_REGION( 0x3000, "maincpu:test", 0 )
ROM_LOAD( "test.bin", 0x0000, 0x3000, CRC(4372220e) SHA1(6e13d015113e16198c0059b9d0c38d7027ae7324) ) // this rom is on the die too, test pin enables it?
ROM_END
} // anonymous namespace
/*******************************************************************************
Drivers
*******************************************************************************/
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY, FULLNAME, FLAGS
CONS( 1997, tama, 0, 0, tama, tama, tamag1_state, empty_init, "Bandai", "Tamagotchi (USA)", MACHINE_SUPPORTS_SAVE )
|