Previous 199869 Revisions Next

r20501 Saturday 26th January, 2013 at 19:12:31 UTC by Wilbert Pol
(MESS) jr100.c: Tagmap cleanups (nw)
[src/mess/drivers]jr100.c

trunk/src/mess/drivers/jr100.c
r20500r20501
2525{
2626public:
2727   jr100_state(const machine_config &mconfig, device_type type, const char *tag)
28      : driver_device(mconfig, type, tag) ,
29      m_ram(*this, "ram"),
30      m_pcg(*this, "pcg"),
31      m_vram(*this, "vram"){ }
28      : driver_device(mconfig, type, tag)
29      , m_ram(*this, "ram")
30      , m_pcg(*this, "pcg")
31      , m_vram(*this, "vram")
32      , m_via(*this, "via")
33      , m_cassette(*this, CASSETTE_TAG)
34      , m_beeper(*this, BEEPER_TAG)
35      , m_speaker(*this, SPEAKER_TAG)
36      , m_region_maincpu(*this, "maincpu")
37      , m_line0(*this, "LINE0")
38      , m_line1(*this, "LINE1")
39      , m_line2(*this, "LINE2")
40      , m_line3(*this, "LINE3")
41      , m_line4(*this, "LINE4")
42      , m_line5(*this, "LINE5")
43      , m_line6(*this, "LINE6")
44      , m_line7(*this, "LINE7")
45      , m_line8(*this, "LINE8")
46   { }
3247
3348   required_shared_ptr<UINT8> m_ram;
3449   required_shared_ptr<UINT8> m_pcg;
3550   required_shared_ptr<UINT8> m_vram;
3651   UINT8 m_keyboard_line;
3752   bool m_use_pcg;
38   UINT8 m_speaker;
53   UINT8 m_speaker_data;
3954   UINT16 m_t1latch;
4055   UINT8 m_beep_en;
4156   DECLARE_WRITE8_MEMBER(jr100_via_w);
r20500r20501
4863   DECLARE_WRITE8_MEMBER(jr100_via_write_a);
4964   DECLARE_WRITE8_MEMBER(jr100_via_write_b);
5065   DECLARE_WRITE_LINE_MEMBER(jr100_via_write_cb2);
66
67protected:
68   required_device<via6522_device> m_via;
69   required_device<cassette_image_device> m_cassette;
70   required_device<device_t> m_beeper;
71   required_device<device_t> m_speaker;
72   required_memory_region m_region_maincpu;
73   required_ioport m_line0;
74   required_ioport m_line1;
75   required_ioport m_line2;
76   required_ioport m_line3;
77   required_ioport m_line4;
78   required_ioport m_line5;
79   required_ioport m_line6;
80   required_ioport m_line7;
81   required_ioport m_line8;
5182};
5283
5384
r20500r20501
6293      m_beep_en = ((data & 0xe0) == 0xe0);
6394
6495      if(!m_beep_en)
65         beep_set_state(machine().device(BEEPER_TAG),0);
96         beep_set_state(m_beeper,0);
6697   }
6798
6899   /* T1L-L */
r20500r20501
81112      /* writing here actually enables the beeper, if above masking condition is satisfied */
82113      if(m_beep_en)
83114      {
84         beep_set_state(machine().device(BEEPER_TAG),1);
85         beep_set_frequency(machine().device(BEEPER_TAG),894886.25 / (double)(m_t1latch) / 2.0);
115         beep_set_state(m_beeper,1);
116         beep_set_frequency(m_beeper,894886.25 / (double)(m_t1latch) / 2.0);
86117      }
87118   }
88   via6522_device *via = machine().device<via6522_device>("via");
89   via->write(space,offset,data);
119   m_via->write(space,offset,data);
90120}
91121
92122static ADDRESS_MAP_START(jr100_mem, AS_PROGRAM, 8, jr100_state )
r20500r20501
167197
168198void jr100_state::machine_start()
169199{
170   beep_set_frequency(machine().device(BEEPER_TAG),0);
171   beep_set_state(machine().device(BEEPER_TAG),0);
200   beep_set_frequency(m_beeper,0);
201   beep_set_state(m_beeper,0);
172202}
173203
174204void jr100_state::machine_reset()
r20500r20501
183213{
184214   int x,y,xi,yi;
185215
186   UINT8 *rom_pcg = memregion("maincpu")->base() + 0xe000;
216   UINT8 *rom_pcg = m_region_maincpu->base() + 0xe000;
187217   for (y = 0; y < 24; y++)
188218   {
189219      for (x = 0; x < 32; x++)
r20500r20501
226256   GFXDECODE_ENTRY( "maincpu", 0xe000, tiles8x8_layout, 0, 1 )
227257GFXDECODE_END
228258
229static const char *const keynames[] = {
230   "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
231   "LINE8", NULL, NULL, NULL, NULL, NULL, NULL, NULL
232};
233
234
235259READ8_MEMBER(jr100_state::jr100_via_read_b)
236260{
237261   UINT8 val = 0x1f;
238   if (keynames[m_keyboard_line]) {
239      val = ioport(keynames[m_keyboard_line])->read();
262   switch ( m_keyboard_line )
263   {
264      case 0: val = m_line0->read(); break;
265      case 1: val = m_line1->read(); break;
266      case 2: val = m_line2->read(); break;
267      case 3: val = m_line3->read(); break;
268      case 4: val = m_line4->read(); break;
269      case 5: val = m_line5->read(); break;
270      case 6: val = m_line6->read(); break;
271      case 7: val = m_line7->read(); break;
272      case 8: val = m_line8->read(); break;
240273   }
241274   return val;
242275}
r20500r20501
249282WRITE8_MEMBER(jr100_state::jr100_via_write_b)
250283{
251284   m_use_pcg = (data & 0x20) ? TRUE : FALSE;
252   m_speaker = data>>7;
285   m_speaker_data = data>>7;
253286}
254287
255288WRITE_LINE_MEMBER(jr100_state::jr100_via_write_cb2)
256289{
257   machine().device<cassette_image_device>(CASSETTE_TAG)->output(state ? -1.0 : +1.0);
290   m_cassette->output(state ? -1.0 : +1.0);
258291}
259292static const via6522_interface jr100_via_intf =
260293{
r20500r20501
283316
284317TIMER_DEVICE_CALLBACK_MEMBER(jr100_state::sound_tick)
285318{
286   device_t *speaker = machine().device(SPEAKER_TAG);
287   speaker_level_w(speaker,m_speaker);
288   m_speaker = 0;
319   speaker_level_w(m_speaker,m_speaker_data);
320   m_speaker_data = 0;
289321
290   via6522_device *via = machine().device<via6522_device>("via");
291   double level = (machine().device<cassette_image_device>(CASSETTE_TAG)->input());
322   double level = (m_cassette->input());
292323   if (level > 0.0) {
293      via->write_ca1(0);
294      via->write_cb1(0);
324      m_via->write_ca1(0);
325      m_via->write_cb1(0);
295326   } else {
296      via->write_ca1(1);
297      via->write_cb1(1);
327      m_via->write_ca1(1);
328      m_via->write_cb1(1);
298329   }
299
300
301330}
302331
303332static UINT32 readByLittleEndian(UINT8 *buf,int pos)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team