Previous 15994 Revisions Next

r8900 Wednesday 25th August, 2010 at 21:15:36 UTC by Angelo Salese
[JR100]: Added beeper sound
[src/mess/drivers]jr100.c

src/mess/drivers/jr100.c
r8899r8900
11/***************************************************************************
2   
2
33        JR-100 National / Panasonic
44
55        23/08/2010 Initial driver version
66
7        TODO:
8        - beeper doesn't work correctly when a key is pressed (should have
9          more time but it's quickly shut off), presumably there are M6802
10          timing bugs that causes this quirk.
11
712****************************************************************************/
813
914#include "emu.h"
r8899r8900
1217#include "devices/cassette.h"
1318#include "sound/wave.h"
1419#include "sound/speaker.h"
20#include "sound/beep.h"
1521#include "devices/snapquik.h"
1622
1723static UINT8 *jr100_ram;
r8899r8900
2127static bool jr100_use_pcg;
2228static UINT8 jr100_speaker;
2329
30static WRITE8_DEVICE_HANDLER( jr100_via_w )
31{
32   static UINT16 t1latch;
33   static UINT8 beep_en;
34
35   /* ACR: beeper masking */
36   if(offset == 0x0b)
37   {
38      //printf("BEEP %s\n",((data & 0xe0) == 0xe0) ? "ON" : "OFF");
39      beep_en = ((data & 0xe0) == 0xe0);
40
41      if(!beep_en)
42         beep_set_state(device->machine->device("beeper"),0);
43   }
44
45   /* T1L-L */
46   if(offset == 0x04)
47   {
48      t1latch = (t1latch & 0xff00) | (data & 0xff);
49      //printf("BEEP T1CL %02x\n",data);
50   }
51
52   /* T1L-H */
53   if(offset == 0x05)
54   {
55      t1latch = (t1latch & 0xff) | ((data & 0xff) << 8);
56      //printf("BEEP T1CH %02x\n",data);
57
58      /* writing here actually enables the beeper, if above masking condition is satisfied */
59      if(beep_en)
60      {
61         beep_set_state(device->machine->device("beeper"),1);
62         beep_set_frequency(device->machine->device("beeper"),894886.25 / (double)(t1latch) / 2.0);
63      }
64   }
65
66   via_w(device,offset,data);
67}
68
2469static ADDRESS_MAP_START(jr100_mem, ADDRESS_SPACE_PROGRAM, 8)
2570   ADDRESS_MAP_UNMAP_HIGH
2671   AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE(&jr100_ram)
2772   AM_RANGE(0xc000, 0xc0ff) AM_RAM AM_BASE(&jr100_pcg)
28   AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr100_vram)   
29   AM_RANGE(0xc800, 0xc80f) AM_DEVREADWRITE("via", via_r, via_w)
30   AM_RANGE(0xe000, 0xffff) AM_ROM   
73   AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr100_vram)
74   AM_RANGE(0xc800, 0xc80f) AM_DEVREADWRITE("via", via_r, jr100_via_w)
75   AM_RANGE(0xe000, 0xffff) AM_ROM
3176ADDRESS_MAP_END
3277
3378/* Input ports */
r8899r8900
97142   PORT_BIT(0xE0, IP_ACTIVE_LOW, IPT_UNUSED)
98143INPUT_PORTS_END
99144
145static MACHINE_START(jr100)
146{
147   beep_set_frequency(machine->device("beeper"),0);
148   beep_set_state(machine->device("beeper"),0);
149}
100150
101static MACHINE_RESET(jr100)
102{   
151static MACHINE_RESET(jr100)
152{
103153}
104154
105155static VIDEO_START( jr100 )
r8899r8900
197247   DEVCB_NULL,                                 /* out_cb1_func */
198248   DEVCB_NULL,                                 /* out_ca2_func */
199249   DEVCB_LINE(jr100_via_write_cb2),                  /* out_cb2_func */
200   DEVCB_NULL                                  /* irq_func */   
250   DEVCB_NULL                                  /* irq_func */
201251};
202252static const cassette_config jr100_cassette_config =
203253{
r8899r8900
209259
210260static TIMER_DEVICE_CALLBACK( sound_tick )
211261{
212   running_device *speaker = timer.machine->device("speaker");   
262   running_device *speaker = timer.machine->device("speaker");
213263   speaker_level_w(speaker,jr100_speaker);
214264   jr100_speaker = 0;
215   
265
216266   running_device *via = timer.machine->device("via");
217267   double level = cassette_input(timer.machine->device("cassette"));
218268   if (level > 0.0) {
r8899r8900
222272      via_ca1_w(via, 1);
223273      via_cb1_w(via, 1);
224274   }
225   
226   
275
276
227277}
228278
229static UINT32 readByLittleEndian(UINT8 *buf,int pos)
279static UINT32 readByLittleEndian(UINT8 *buf,int pos)
230280{
231   return buf[pos] + (buf[pos+1] << 8) + (buf[pos+2] << 16) + (buf[pos+3] << 24);
281   return buf[pos] + (buf[pos+1] << 8) + (buf[pos+2] << 16) + (buf[pos+3] << 24);
232282}
233283
234284static QUICKLOAD_LOAD(jr100)
r8899r8900
258308   UINT32 start_address = readByLittleEndian(buf,pos); pos+= 4;
259309   UINT32 code_length   = readByLittleEndian(buf,pos); pos+= 4;
260310   UINT32 flag         = readByLittleEndian(buf,pos); pos+= 4;
261   
311
262312   UINT32 end_address = start_address + code_length - 1;
263313   // copy code
264314   memcpy(jr100_ram + start_address,buf + pos,code_length);
r8899r8900
275325      jr100_ram[12] = ((end_address + 3) >> 8 & 0xFF);
276326      jr100_ram[13] = ((end_address + 3) & 0xFF);
277327    }
278   
328
279329   return IMAGE_INIT_PASS;
280330}
281331
r8899r8900
284334    MDRV_CPU_ADD("maincpu",M6802, XTAL_14_31818MHz / 4) // clock devided internaly by 4
285335    MDRV_CPU_PROGRAM_MAP(jr100_mem)
286336
337    MDRV_MACHINE_START(jr100)
287338    MDRV_MACHINE_RESET(jr100)
288   
339
289340    /* video hardware */
290341   MDRV_SCREEN_ADD("screen", RASTER)
291342   MDRV_SCREEN_REFRESH_RATE(60)
r8899r8900
300351
301352    MDRV_VIDEO_START(jr100)
302353    MDRV_VIDEO_UPDATE(jr100)
303   
354
304355   MDRV_VIA6522_ADD("via", XTAL_14_31818MHz / 16, jr100_via_intf)
305   
356
306357   MDRV_SPEAKER_STANDARD_MONO("mono")
307358   MDRV_SOUND_WAVE_ADD("wave", "cassette")
308359   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
309360   MDRV_SOUND_ADD("speaker", SPEAKER, 0)
310361   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
311362
312   MDRV_CASSETTE_ADD( "cassette", jr100_cassette_config )   
313   
363   MDRV_SOUND_ADD("beeper", BEEP, 0)
364   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.50)
365
366   MDRV_CASSETTE_ADD( "cassette", jr100_cassette_config )
367
314368   MDRV_TIMER_ADD_PERIODIC("sound_tick", sound_tick, HZ(XTAL_14_31818MHz / 16))
315   
369
316370   /* quickload */
317   MDRV_QUICKLOAD_ADD("quickload", jr100, "prg", 0)   
371   MDRV_QUICKLOAD_ADD("quickload", jr100, "prg", 0)
318372MACHINE_DRIVER_END
319373
320374

Previous 15994 Revisions Next


© 1998-2018 The MESS Team