Previous 15994 Revisions Next

r8759 Wednesday 11th August, 2010 at 17:06:24 UTC by Angelo Salese
[JR-200]: Added preliminary beeper
[src/mess/drivers]jr200.c

src/mess/drivers/jr200.c
r8758r8759
11/***************************************************************************
22
3    JR-200
3    JR-200 (c) 1982 National / Panasonic
44
5    12/05/2009 Skeleton driver.
5   preliminary driver by Roberto Zandoną and Angelo Salese
66
77    http://www.armchairarcade.com/neo/node/1598
88
9   TODO:
10   - Timings are basically screwed, it's too fast in idle mode, too slow
11     when the beeper fires for a syntax error;
12   - MN1544 4-bit CPU core and ROM dump
13
914****************************************************************************/
1015
11/*
12
13    TODO:
14
15    - MN1544 4-bit CPU core and ROM dump
16
17*/
18
1916#include "emu.h"
2017#include "cpu/m6800/m6800.h"
18#include "sound/beep.h"
2119
22static UINT8 *textram;
20static UINT8 *jr200_vram,*jr200_cram;
2321static UINT8 *border;
2422static UINT8 io_reg[0x20] = {
2523   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
r8758r8759
3836   { 0x66, 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0x3b, 0x3a },
3937   { 0x0d, 0x0a, 0x1e, 0x31, 0x32, 0x33, 0x7a, 0x78 },
4038   { 0x63, 0x76, 0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x2f },
41   { 0x1d, 0x1f, 0x1c, 0x30, 0x2e, 0x20, 0x00, 0x00 }
39   { 0x1d, 0x1f, 0x1c, 0x30, 0x2e, 0x20, 0x03, 0x00 }
4240   },
4341
4442   /* shifted */
r8758r8759
8179   }
8280};
8381
82
83static VIDEO_START( jr200 )
84{
85}
86
87static VIDEO_UPDATE( jr200 )
88{
89   int i,j;
90   const gfx_element *gfx = screen->machine->gfx[0];
91
92   bitmap_fill(bitmap, cliprect, border[0x0000] * 2 + 1);
93
94   for (i = 0; i < 0x02ff; i += 0x20)
95      for (j = 0; j < 0x20; j++)
96      {
97         UINT8 code = jr200_vram[0x000 + i + j];
98         UINT8 col = jr200_cram[0x000 + i + j];
99
100         if (col & 0x80)
101         {
102            UINT8 pixel01 = (jr200_vram[0x0000 + i + j] >> 3) & 0x07;
103            UINT8 pixel00 = (jr200_vram[0x0000 + i + j] >> 0) & 0x07;
104            UINT8 pixel11 = (jr200_cram[0x0000 + i + j] >> 3) & 0x07;
105            UINT8 pixel10 = (jr200_cram[0x0000 + i + j] >> 0) & 0x07;
106            plot_box(bitmap, 16 + j * 8    , 16 + (i >> 5) * 8    , 4, 4, pixel00 * 2 + 1);
107            plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8    , 4, 4, pixel01 * 2 + 1);
108            plot_box(bitmap, 16 + j * 8    , 16 + (i >> 5) * 8 + 4, 4, 4, pixel10 * 2 + 1);
109            plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8 + 4, 4, 4, pixel11 * 2 + 1);
110         }
111         else
112         {
113            drawgfx_opaque(bitmap, cliprect, gfx, code, col & 0x3f, 0, 0, 16 + j * 8, 16 + (i >> 5) * 8);
114         }
115      }
116   return 0;
117}
118
84119#if 0
85120static READ8_HANDLER( test_r )
86121{
r8758r8759
88123}
89124#endif
90125
91static WRITE8_HANDLER( io_reg_w )
92{
93   io_reg[offset] = data;
94}
95
96126static READ8_HANDLER( io_reg_r )
97127{
98128   UINT8 value = 0x00;
r8758r8759
168198   return value;
169199}
170200
201static WRITE8_HANDLER( io_reg_w )
202{
203   io_reg[offset] = data;
204
205   switch(offset)
206   {
207      /* set beeper active */
208      case 0x19:
209         beep_set_state(space->machine->device("beeper"),(data == 0x0e) ? 1 : 0);
210         break;
211      /* set beeper frequency (TODO: correct frequency algorhythm) */
212      case 0x1a:
213      case 0x1b:
214         {
215            UINT32 beep_freq;
216
217            beep_freq = ((io_reg[0x1a]<<8) | (io_reg[0x1b] & 0xff)) + 1;
218
219            beep_set_frequency(space->machine->device("beeper"),84000 / beep_freq);
220         }
221         break;
222   }
223}
224
171225/*
172226    0000-3fff RAM
173227    4000-4fff RAM ( 4k expansion)
174228    4000-7fff RAM (16k expansion)
175229    4000-bfff RAM (32k expansion)
176    c100-c3FF text code
177    c500-c7ff text color
178    ca00      border color
179230*/
180231
181232static ADDRESS_MAP_START(jr200_mem, ADDRESS_SPACE_PROGRAM, 8)
182   AM_RANGE(0x0000, 0x000c) AM_RAM
183   AM_RANGE(0x000d, 0x000d) AM_RAM
184   AM_RANGE(0x000e, 0x3fff) AM_RAM
233   AM_RANGE(0x0000, 0x3fff) AM_RAM
185234   AM_RANGE(0xa000, 0xbfff) AM_ROM
186   AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_BASE(&textram)
235//   AM_RANGE(0xc000, 0xc0ff) AM_RAM //PCG area (1)
236   AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr200_vram)
237//   AM_RANGE(0xc400, 0xc4ff) AM_RAM //PCG area (2)
238   AM_RANGE(0xc500, 0xc7ff) AM_RAM AM_BASE(&jr200_cram)
239//   0xc800 - 0xcfff I / O area
187240   AM_RANGE(0xc800, 0xc81f) AM_READWRITE(io_reg_r, io_reg_w)
188241   AM_RANGE(0xca00, 0xca00) AM_RAM AM_BASE(&border)
242//   AM_RANGE(0xd000, 0xd7ff) AM_ROM //BIOS PCG RAM
189243   AM_RANGE(0xe000, 0xffff) AM_ROM
190244ADDRESS_MAP_END
191245
r8758r8759
292346   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RIGHT CTRL") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
293347INPUT_PORTS_END
294348
349static MACHINE_START(jr200)
350{
351   beep_set_frequency(machine->device("beeper"),0);
352   beep_set_state(machine->device("beeper"),0);
353}
295354
296355static MACHINE_RESET(jr200)
297356{
357
298358}
299359
300360static PALETTE_INIT( jr200 )
r8758r8759
308368   }
309369}
310370
311static VIDEO_START( jr200 )
312{
313}
314
315static VIDEO_UPDATE( jr200 )
316{
317   int i,j;
318   const gfx_element *gfx = screen->machine->gfx[0];
319
320   bitmap_fill(bitmap, cliprect, border[0x0000] * 2 + 1);
321
322   for (i = 0; i < 0x02ff; i += 0x20)
323      for (j = 0; j < 0x20; j++)
324      {
325         UINT8 code = textram[0x0100 + i + j];
326         UINT8 col = textram[0x0500 + i + j];
327
328         if (col & 0x80)
329         {
330            UINT8 pixel01 = (textram[0x0100 + i + j] >> 3) & 0x07;
331            UINT8 pixel00 = (textram[0x0100 + i + j] >> 0) & 0x07;
332            UINT8 pixel11 = (textram[0x0500 + i + j] >> 3) & 0x07;
333            UINT8 pixel10 = (textram[0x0500 + i + j] >> 0) & 0x07;
334            plot_box(bitmap, 16 + j * 8    , 16 + (i >> 5) * 8    , 4, 4, pixel00 * 2 + 1);
335            plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8    , 4, 4, pixel01 * 2 + 1);
336            plot_box(bitmap, 16 + j * 8    , 16 + (i >> 5) * 8 + 4, 4, 4, pixel10 * 2 + 1);
337            plot_box(bitmap, 16 + j * 8 + 4, 16 + (i >> 5) * 8 + 4, 4, 4, pixel11 * 2 + 1);
338         }
339         else
340         {
341            drawgfx_transpen(bitmap, cliprect, gfx, code, col & 0x3f, 0, 0, 16 + j * 8, 16 + (i >> 5) * 8, 15);
342         }
343      }
344   return 0;
345}
346
347371static const gfx_layout tiles8x8_layout =
348372{
349373   8,8,
r8758r8759
362386
363387static INTERRUPT_GEN( jr200_nmi )
364388{
365   cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
389//   cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
366390}
367391
368392static INTERRUPT_GEN( jr200_irq )
r8758r8759
375399   MDRV_CPU_ADD("maincpu", M6802, 890000) /* MN1800A */
376400   MDRV_CPU_PROGRAM_MAP(jr200_mem)
377401   MDRV_CPU_IO_MAP(jr200_io)
378   // MDRV_CPU_VBLANK_INT("screen", jr200_irq)
402   MDRV_CPU_VBLANK_INT("screen", jr200_irq)
379403   MDRV_CPU_PERIODIC_INT(jr200_nmi,20)
380   MDRV_CPU_PERIODIC_INT(jr200_irq,20)
381/*
382    MDRV_CPU_ADD("mn1544", MN1544, ?)
383*/
404//   MDRV_CPU_PERIODIC_INT(jr200_irq,20)
405
406//   MDRV_CPU_ADD("mn1544", MN1544, ?)
407
408   MDRV_MACHINE_START(jr200)
384409   MDRV_MACHINE_RESET(jr200)
385410
386411   /* video hardware */
387412   MDRV_SCREEN_ADD("screen", RASTER)
388   MDRV_SCREEN_REFRESH_RATE(50)
413   MDRV_SCREEN_REFRESH_RATE(60)
389414   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
390415   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
391416   MDRV_SCREEN_SIZE(16 + 256 + 16, 16 + 192 + 16) /* border size not accurate */
r8758r8759
394419   MDRV_GFXDECODE(jr200)
395420   MDRV_PALETTE_LENGTH(128)
396421   MDRV_PALETTE_INIT(jr200)
422
397423   MDRV_VIDEO_START(jr200)
398424   MDRV_VIDEO_UPDATE(jr200)
425
426   MDRV_SPEAKER_STANDARD_MONO("mono")
427
428   // AY-8910 ?
429
430   MDRV_SOUND_ADD("beeper", BEEP, 0)
431   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.50)
399432MACHINE_DRIVER_END
400433
401 
402434
435
403436/* ROM definition */
404437ROM_START( jr200 )
405438   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team