summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Curt Coder <curtcoder@mail.com>2008-04-02 14:43:06 +0000
committer Curt Coder <curtcoder@mail.com>2008-04-02 14:43:06 +0000
commit1859e012d294b3f93c0f466e3aa09825443c59c3 (patch)
tree9cf1c0b6a3297b91c060e5005d7adb18967f4325 /src
parent12589d9abd05aaec947239deb7e6454285a40d94 (diff)
- converted CDP1869 to the new device system
- refactored to represent how the hardware actually works - added PMA latching on OUT5 - separated Cidelsa video to its own file
Diffstat (limited to 'src')
-rw-r--r--src/emu/video/cdp1869.c956
-rw-r--r--src/emu/video/cdp1869.h114
-rw-r--r--src/mame/drivers/cidelsa.c429
-rw-r--r--src/mame/includes/cidelsa.h38
-rw-r--r--src/mame/mame.mak2
-rw-r--r--src/mame/video/cidelsa.c298
6 files changed, 1194 insertions, 643 deletions
diff --git a/src/emu/video/cdp1869.c b/src/emu/video/cdp1869.c
index 1002fcdde4a..82563f3ab20 100644
--- a/src/emu/video/cdp1869.c
+++ b/src/emu/video/cdp1869.c
@@ -1,5 +1,6 @@
#include "driver.h"
-#include "deprecat.h"
+#include "sndintrf.h"
+#include "streams.h"
#include "cpu/cdp1802/cdp1802.h"
#include "video/cdp1869.h"
#include "sound/cdp1869.h"
@@ -8,34 +9,357 @@
TODO:
- - convert CDP1869 into a device with video/sound
- - add predisplay/display timers
+ - connect to sound system when possible
+ - white noise
+ - scanline based update
+ - fix flashing spaceship in destryer/altair
+ - fix flashing player in draco
*/
-typedef struct
+#define CDP1869_WEIGHT_RED 30 /* % of max luminance */
+#define CDP1869_WEIGHT_GREEN 59
+#define CDP1869_WEIGHT_BLUE 11
+
+#define CDP1869_COLUMNS_HALF 20
+#define CDP1869_COLUMNS_FULL 40
+#define CDP1869_ROWS_HALF 12
+#define CDP1869_ROWS_FULL_PAL 25
+#define CDP1869_ROWS_FULL_NTSC 24
+
+enum
+{
+ CDB0 = 0,
+ CDB1,
+ CDB2,
+ CDB3,
+ CDB4,
+ CDB5,
+ CCB0,
+ CCB1
+};
+
+typedef struct _cdp1869_t cdp1869_t;
+struct _cdp1869_t
+{
+ const cdp1869_interface *intf; /* interface */
+ const device_config *screen; /* screen */
+ sound_stream *stream; /* sound output */
+
+ /* video state */
+ int dispoff; /* display off */
+ int fresvert; /* full resolution vertical */
+ int freshorz; /* full resolution horizontal */
+ int cmem; /* character memory access mode */
+ int dblpage; /* double page mode */
+ int line16; /* 16-line hi-res mode */
+ int line9; /* 9 line mode */
+ int cfc; /* color format control */
+ UINT8 col; /* character color control */
+ UINT8 bkg; /* background color */
+ UINT16 pma; /* page memory address */
+ UINT16 hma; /* home memory address */
+
+ /* video timer */
+ emu_timer *prd_changed_timer; /* predisplay changed timer */
+
+ /* sound state */
+ INT16 signal; /* current signal */
+ int incr; /* initial wave state */
+ int toneoff; /* tone off */
+ int wnoff; /* white noise off */
+ UINT8 tonediv; /* tone divisor */
+ UINT8 tonefreq; /* tone range select */
+ UINT8 toneamp; /* tone output amplitude */
+ UINT8 wnfreq; /* white noise range select */
+ UINT8 wnamp; /* white noise output amplitude */
+};
+
+INLINE cdp1869_t *get_safe_token(const device_config *device)
{
- int ntsc_pal;
- int dispoff;
- int fresvert, freshorz;
- int dblpage, line16, line9, cmem, cfc;
- UINT8 col, bkg;
- UINT16 pma, hma;
- UINT8 cram[CDP1869_CHARRAM_SIZE];
- UINT8 pram[CDP1869_PAGERAM_SIZE];
- int cramsize, pramsize;
- UINT8 (*color_callback)(UINT8 cramdata, UINT16 cramaddr, UINT16 pramaddr);
-} CDP1869_VIDEO_CONFIG;
-
-static CDP1869_VIDEO_CONFIG cdp1869;
+ assert(device != NULL);
+ assert(device->token != NULL);
+
+ return (cdp1869_t *)device->token;
+}
+
+/* Predisplay Timer */
+
+static void update_prd_changed_timer(cdp1869_t *cdp1869)
+{
+ if (cdp1869->prd_changed_timer != NULL)
+ {
+ attotime duration;
+ int start, end, level;
+ int scanline = video_screen_get_vpos(cdp1869->screen);
+ int next_scanline;
+
+ if (cdp1869->intf->pal_ntsc == CDP1869_NTSC)
+ {
+ start = CDP1869_SCANLINE_PREDISPLAY_START_NTSC;
+ end = CDP1869_SCANLINE_PREDISPLAY_END_NTSC;
+ }
+ else
+ {
+ start = CDP1869_SCANLINE_PREDISPLAY_START_PAL;
+ end = CDP1869_SCANLINE_PREDISPLAY_END_PAL;
+ }
+
+ if (scanline < start)
+ {
+ next_scanline = start;
+ level = 0;
+ }
+ else if (scanline < end)
+ {
+ next_scanline = end;
+ level = 1;
+ }
+ else
+ {
+ next_scanline = start;
+ level = 0;
+ }
+
+ if (cdp1869->dispoff)
+ {
+ level = 1;
+ }
+
+ duration = video_screen_get_time_until_pos(cdp1869->screen, next_scanline, 0);
+ timer_adjust_oneshot(cdp1869->prd_changed_timer, duration, level);
+ }
+}
+
+static TIMER_CALLBACK( prd_changed_tick )
+{
+ const device_config *device = ptr;
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ /* call the callback function -- we know it exists */
+ cdp1869->intf->on_prd_changed(device, param);
+
+ update_prd_changed_timer(cdp1869);
+}
+
+/* State Save Postload */
+
+static void cdp1869_state_save_postload(void *param)
+{
+ update_prd_changed_timer(param);
+}
+
+/* CDP1802 X Register */
static UINT16 cdp1802_get_r_x(void)
{
return activecpu_get_reg(CDP1802_R0 + activecpu_get_reg(CDP1802_X));
}
-WRITE8_HANDLER ( cdp1869_out3_w )
+/* Palette Initialization */
+
+static rgb_t cdp1869_get_rgb(int i, int c, int l)
+{
+ int luma = 0, r, g, b;
+
+ luma += (l & 4) ? CDP1869_WEIGHT_RED : 0;
+ luma += (l & 1) ? CDP1869_WEIGHT_GREEN : 0;
+ luma += (l & 2) ? CDP1869_WEIGHT_BLUE : 0;
+
+ luma = (luma * 0xff) / 100;
+
+ r = (c & 4) ? luma : 0;
+ g = (c & 1) ? luma : 0;
+ b = (c & 2) ? luma : 0;
+
+ return MAKE_RGB(r, g, b);
+}
+
+/* Screen Update */
+
+static int cdp1869_get_lines(const device_config *device)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ if (cdp1869->line16 && !cdp1869->dblpage)
+ {
+ return 16;
+ }
+ else if (!cdp1869->line9)
+ {
+ return 9;
+ }
+ else
+ {
+ return 8;
+ }
+}
+
+static UINT16 cdp1869_get_pmemsize(const device_config *device, int cols, int rows)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ int pmemsize = cols * rows;
+
+ if (cdp1869->dblpage) pmemsize *= 2;
+ if (cdp1869->line16) pmemsize *= 2;
+
+ return pmemsize;
+}
+
+static UINT16 cdp1869_get_pma(const device_config *device)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ if (cdp1869->dblpage)
+ {
+ return cdp1869->pma;
+ }
+ else
+ {
+ return cdp1869->pma & 0x3ff;
+ }
+}
+
+static int cdp1869_get_pen(const device_config *device, int ccb0, int ccb1, int pcb)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ int r = 0, g = 0, b = 0, color;
+
+ switch (cdp1869->col)
+ {
+ case 0:
+ r = ccb0;
+ b = ccb1;
+ g = pcb;
+ break;
+
+ case 1:
+ r = ccb0;
+ b = pcb;
+ g = ccb1;
+ break;
+
+ case 2:
+ case 3:
+ r = pcb;
+ b = ccb0;
+ g = ccb1;
+ break;
+ }
+
+ color = (r << 2) + (b << 1) + g;
+
+ if (cdp1869->cfc)
+ {
+ return color + ((cdp1869->bkg + 1) * 8);
+ }
+ else
+ {
+ return color;
+ }
+}
+
+static void cdp1869_draw_line(const device_config *device, bitmap_t *bitmap, int x, int y, int data, int color)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ int i;
+
+ data <<= 2;
+
+ for (i = 0; i < CDP1869_CHAR_WIDTH; i++)
+ {
+ if (data & 0x80)
+ {
+ *BITMAP_ADDR16(bitmap, y, x) = color;
+
+ if (!cdp1869->fresvert)
+ {
+ *BITMAP_ADDR16(bitmap, y + 1, x) = color;
+ }
+
+ if (!cdp1869->freshorz)
+ {
+ *BITMAP_ADDR16(bitmap, y, x + 1) = color;
+
+ if (!cdp1869->fresvert)
+ {
+ *BITMAP_ADDR16(bitmap, y + 1, x + 1) = color;
+ }
+ }
+ }
+
+ if (!cdp1869->freshorz)
+ {
+ x++;
+ }
+
+ x++;
+
+ data <<= 1;
+ }
+}
+
+static void cdp1869_draw_char(const device_config *device, bitmap_t *bitmap, int x, int y, UINT16 pma, const rectangle *screenrect)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
+ UINT8 cma = 0;
+
+ for (cma = 0; cma < cdp1869_get_lines(device); cma++)
+ {
+ UINT8 data = cdp1869->intf->char_ram_r(device, pma, cma);
+
+ int ccb0 = BIT(data, CCB0);
+ int ccb1 = BIT(data, CCB1);
+ int pcb = cdp1869->intf->pcb_r(device, pma, cma);
+
+ int color = cdp1869_get_pen(device, ccb0, ccb1, pcb);
+
+ cdp1869_draw_line(device, bitmap, screenrect->min_x + x, screenrect->min_y + y, data, color);
+
+ y++;
+
+ if (!cdp1869->fresvert)
+ {
+ y++;
+ }
+ }
+}
+
+/* Palette Initialization */
+
+PALETTE_INIT( cdp1869 )
{
+ int i, c, l;
+
+ // color-on-color display (CFC=0)
+
+ for (i = 0; i < 8; i++)
+ {
+ palette_set_color(machine, i, cdp1869_get_rgb(i, i, 15));
+ }
+
+ // tone-on-tone display (CFC=1)
+
+ for (c = 0; c < 8; c++)
+ {
+ for (l = 0; l < 8; l++)
+ {
+ palette_set_color(machine, i, cdp1869_get_rgb(i, c, l));
+ i++;
+ }
+ }
+}
+
+/* Register Access */
+
+WRITE8_DEVICE_HANDLER( cdp1869_out3_w )
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
/*
bit description
@@ -49,15 +373,17 @@ WRITE8_HANDLER ( cdp1869_out3_w )
7 fres horz
*/
- cdp1869.bkg = (data & 0x07);
- cdp1869.cfc = (data & 0x08) >> 3;
- cdp1869.dispoff = (data & 0x10) >> 4;
- cdp1869.col = (data & 0x60) >> 5;
- cdp1869.freshorz = (data & 0x80) >> 7;
+ cdp1869->bkg = data & 0x07;
+ cdp1869->cfc = BIT(data, 3);
+ cdp1869->dispoff = BIT(data, 4);
+ cdp1869->col = (data & 0x60) >> 5;
+ cdp1869->freshorz = BIT(data, 7);
}
-WRITE8_HANDLER ( cdp1869_out4_w )
+WRITE8_DEVICE_HANDLER( cdp1869_out4_w )
{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
UINT16 word = cdp1802_get_r_x();
/*
@@ -81,14 +407,22 @@ WRITE8_HANDLER ( cdp1869_out4_w )
15 always 0
*/
- cdp1869_set_toneamp(0, word & 0x0f);
- cdp1869_set_tonefreq(0, (word & 0x70) >> 4);
- cdp1869_set_toneoff(0, (word & 0x80) >> 7);
- cdp1869_set_tonediv(0, (word & 0x7f00) >> 8);
+ cdp1869->toneamp = word & 0x0f;
+ cdp1869->tonefreq = (word & 0x70) >> 4;
+ cdp1869->toneoff = BIT(word, 7);
+ cdp1869->tonediv = (word & 0x7f00) >> 8;
+
+ // fork out to CDP1869 sound core
+ cdp1869_set_toneamp(0, cdp1869->toneamp);
+ cdp1869_set_tonefreq(0, cdp1869->tonefreq);
+ cdp1869_set_toneoff(0, cdp1869->toneoff);
+ cdp1869_set_tonediv(0, cdp1869->tonediv);
}
-WRITE8_HANDLER ( cdp1869_out5_w )
+WRITE8_DEVICE_HANDLER( cdp1869_out5_w )
{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
UINT16 word = cdp1802_get_r_x();
/*
@@ -112,19 +446,40 @@ WRITE8_HANDLER ( cdp1869_out5_w )
15 wn off
*/
- cdp1869.cmem = (word & 0x01);
- cdp1869.line9 = (word & 0x08) >> 3;
- cdp1869.line16 = (word & 0x20) >> 5;
- cdp1869.dblpage = (word & 0x40) >> 6;
- cdp1869.fresvert = (word & 0x80) >> 7;
+ cdp1869->cmem = BIT(word, 0);
+ cdp1869->line9 = BIT(word, 3);
+
+ if (cdp1869->intf->pal_ntsc == CDP1869_NTSC)
+ {
+ cdp1869->line16 = BIT(word, 5);
+ }
+
+ cdp1869->dblpage = BIT(word, 6);
+ cdp1869->fresvert = BIT(word, 7);
- cdp1869_set_wnamp(0, (word & 0x0f00) >> 8);
- cdp1869_set_wnfreq(0, (word & 0x7000) >> 12);
- cdp1869_set_wnoff(0, (word & 0x8000) >> 15);
+ cdp1869->wnamp = (word & 0x0f00) >> 8;
+ cdp1869->wnfreq = (word & 0x7000) >> 12;
+ cdp1869->wnoff = BIT(word, 15);
+
+ // fork out to CDP1869 sound core
+ cdp1869_set_wnamp(0, cdp1869->wnamp);
+ cdp1869_set_wnfreq(0, cdp1869->wnfreq);
+ cdp1869_set_wnoff(0, cdp1869->wnoff);
+
+ if (cdp1869->cmem)
+ {
+ cdp1869->pma = word;
+ }
+ else
+ {
+ cdp1869->pma = 0;
+ }
}
-WRITE8_HANDLER ( cdp1869_out6_w )
+WRITE8_DEVICE_HANDLER( cdp1869_out6_w )
{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
UINT16 word = cdp1802_get_r_x();
/*
@@ -148,11 +503,13 @@ WRITE8_HANDLER ( cdp1869_out6_w )
15 x
*/
- cdp1869.pma = word & 0x7ff;
+ cdp1869->pma = word & 0x7ff;
}
-WRITE8_HANDLER ( cdp1869_out7_w )
+WRITE8_DEVICE_HANDLER( cdp1869_out7_w )
{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+
UINT16 word = cdp1802_get_r_x();
/*
@@ -176,143 +533,64 @@ WRITE8_HANDLER ( cdp1869_out7_w )
15 x
*/
- cdp1869.hma = word & 0x7fc;
+ cdp1869->hma = word & 0x7fc;
}
-static void cdp1869_set_color(int i, int c, int l)
-{
- int luma = 0, r, g, b;
-
- luma += (l & 4) ? CDP1869_WEIGHT_RED : 0;
- luma += (l & 1) ? CDP1869_WEIGHT_GREEN : 0;
- luma += (l & 2) ? CDP1869_WEIGHT_BLUE : 0;
-
- luma = (luma * 0xff) / 100;
-
- r = (c & 4) ? luma : 0;
- g = (c & 1) ? luma : 0;
- b = (c & 2) ? luma : 0;
-
- palette_set_color( Machine, i, MAKE_RGB(r, g, b) );
-}
+/* Page RAM Access */
-PALETTE_INIT( cdp1869 )
+READ8_DEVICE_HANDLER( cdp1869_pageram_r )
{
- int i, c, l;
+ cdp1869_t *cdp1869 = get_safe_token(device);
- // color-on-color display (CFC=0)
+ UINT16 pma;
- for (i = 0; i < 8; i++)
+ if (cdp1869->cmem)
{
- cdp1869_set_color(i, i, 15);
- }
-
- // tone-on-tone display (CFC=1)
-
- for (c = 0; c < 8; c++)
- {
- for (l = 0; l < 8; l++)
- {
- cdp1869_set_color(i, c, l);
- i++;
- }
- }
-}
-
-static int cdp1869_get_lines(void)
-{
- if (cdp1869.line16 && !cdp1869.dblpage)
- {
- return 16;
- }
- else if (!cdp1869.line9)
- {
- return 9;
+ pma = cdp1869_get_pma(device);
}
else
{
- return 8;
+ pma = offset;
}
+
+ return cdp1869->intf->page_ram_r(device, pma);
}
-static UINT16 cdp1869_get_pmemsize(int cols, int rows)
+WRITE8_DEVICE_HANDLER( cdp1869_pageram_w )
{
- int pmemsize = cols * rows;
+ cdp1869_t *cdp1869 = get_safe_token(device);
- if (cdp1869.dblpage) pmemsize *= 2;
- if (cdp1869.line16) pmemsize *= 2;
-
- return pmemsize;
-}
+ UINT16 pma;
-static UINT16 cdp1869_get_pma(void)
-{
- if (cdp1869.dblpage)
+ if (cdp1869->cmem)
{
- return cdp1869.pma;
+ pma = cdp1869_get_pma(device);
}
else
{
- return cdp1869.pma & 0x3ff;
- }
-}
-
-UINT16 cdp1869_get_cma(UINT16 offset)
-{
- int column = cdp1869.pram[cdp1869_get_pma()];
- int row = offset & 0x07;
-
- int addr = (column << 3) + row;
-
- if ((offset & 0x08) && (cdp1869_get_lines() > 8))
- {
- addr += (CDP1869_CHARRAM_SIZE / 2);
+ pma = offset;
}
- return addr;
+ cdp1869->intf->page_ram_w(device, pma, data);
}
-static UINT8 cdp1869_read_pageram(UINT16 addr)
-{
- if (addr >= cdp1869.pramsize)
- {
- return 0xff;
- }
- else
- {
- return cdp1869.pram[addr];
- }
-}
+/* Character RAM Access */
-#ifdef UNUSED_FUNCTION
-UINT8 cdp1869_read_charram(UINT16 addr)
+READ8_DEVICE_HANDLER( cdp1869_charram_r )
{
- if (addr >= cdp1869.cramsize)
- {
- return 0xff;
- }
- else
- {
- return cdp1869.cram[addr];
- }
-}
-#endif
+ cdp1869_t *cdp1869 = get_safe_token(device);
-WRITE8_HANDLER ( cdp1869_charram_w )
-{
- if (cdp1869.cmem)
+ if (cdp1869->cmem)
{
- UINT16 addr = cdp1869_get_cma(offset);
- cdp1869.cram[addr] = data;
- }
-}
+ UINT16 pma = cdp1869_get_pma(device);
+ UINT8 cma = offset & 0x0f;
-READ8_HANDLER ( cdp1869_charram_r )
-{
- if (cdp1869.cmem)
- {
- UINT16 addr = cdp1869_get_cma(offset);
- return cdp1869.cram[addr];
+ if (cdp1869_get_lines(device) == 8)
+ {
+ cma &= 0x07;
+ }
+
+ return cdp1869->intf->char_ram_r(device, pma, cma);
}
else
{
@@ -320,260 +598,266 @@ READ8_HANDLER ( cdp1869_charram_r )
}
}
-WRITE8_HANDLER ( cdp1869_pageram_w )
+WRITE8_DEVICE_HANDLER( cdp1869_charram_w )
{
- UINT16 addr;
+ cdp1869_t *cdp1869 = get_safe_token(device);
- if (cdp1869.cmem)
- {
- addr = cdp1869_get_pma();
- }
- else
+ if (cdp1869->cmem)
{
- addr = offset;
- }
-
- cdp1869.pram[addr] = data;
-}
+ UINT16 pma = cdp1869_get_pma(device);
+ UINT8 cma = offset & 0x0f;
-READ8_HANDLER ( cdp1869_pageram_r )
-{
- UINT16 addr;
+ if (cdp1869_get_lines(device) == 8)
+ {
+ cma &= 0x07;
+ }
- if (cdp1869.cmem)
- {
- addr = cdp1869_get_pma();
+ cdp1869->intf->char_ram_w(device, pma, cma, data);
}
- else
- {
- addr = offset;
- }
-
- return cdp1869.pram[addr];
}
-static int cdp1869_get_color(int ccb0, int ccb1, int pcb)
+/* Screen Update */
+
+void cdp1869_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
{
- int r = 0, g = 0, b = 0, color;
+ cdp1869_t *cdp1869 = get_safe_token(device);
- switch (cdp1869.col)
- {
- case 0:
- r = ccb0;
- g = pcb;
- b = ccb1;
- break;
+ rectangle screen_rect, outer;
- case 1:
- r = ccb0;
- g = ccb1;
- b = pcb;
+ switch (cdp1869->intf->pal_ntsc)
+ {
+ case CDP1869_NTSC:
+ outer.min_x = CDP1869_HBLANK_END;
+ outer.max_x = CDP1869_HBLANK_START - 1;
+ outer.min_y = CDP1869_SCANLINE_VBLANK_END_NTSC;
+ outer.max_y = CDP1869_SCANLINE_VBLANK_START_NTSC - 1;
+ screen_rect.min_x = CDP1869_SCREEN_START_NTSC;
+ screen_rect.max_x = CDP1869_SCREEN_END - 1;
+ screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_NTSC;
+ screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_NTSC - 1;
break;
- case 2:
- case 3:
- r = pcb;
- g = ccb1;
- b = ccb0;
+ default:
+ case CDP1869_PAL:
+ outer.min_x = CDP1869_HBLANK_END;
+ outer.max_x = CDP1869_HBLANK_START - 1;
+ outer.min_y = CDP1869_SCANLINE_VBLANK_END_PAL;
+ outer.max_y = CDP1869_SCANLINE_VBLANK_START_PAL - 1;
+ screen_rect.min_x = CDP1869_SCREEN_START_PAL;
+ screen_rect.max_x = CDP1869_SCREEN_END - 1;
+ screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_PAL;
+ screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_PAL - 1;
break;
}
- color = (r << 2) + (b << 1) + g;
+ sect_rect(&outer, cliprect);
+ fillbitmap(bitmap, device->machine->pens[cdp1869->bkg], &outer);
- if (cdp1869.cfc)
- {
- return color + ((cdp1869.bkg + 1) * 8);
- }
- else
+ if (!cdp1869->dispoff)
{
- return color;
- }
-}
+ int sx, sy, rows, cols, width, height;
+ UINT16 addr, pmemsize;
-static void cdp1869_draw_line(running_machine *machine, bitmap_t *bitmap, int x, int y, int data, int color)
-{
- int i;
+ width = CDP1869_CHAR_WIDTH;
+ height = cdp1869_get_lines(device);
- data <<= 2;
+ if (!cdp1869->freshorz)
+ {
+ width *= 2;
+ }
- for (i = 0; i < CDP1869_CHAR_WIDTH; i++)
- {
- if (data & 0x80)
+ if (!cdp1869->fresvert)
{
- *BITMAP_ADDR16(bitmap, y, x) = machine->pens[color];
+ height *= 2;
+ }
- if (!cdp1869.fresvert)
- {
- *BITMAP_ADDR16(bitmap, y + 1, x) = machine->pens[color];
- }
+ cols = cdp1869->freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
+ rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
- if (!cdp1869.freshorz)
- {
- *BITMAP_ADDR16(bitmap, y, x + 1) = machine->pens[color];
+ pmemsize = cdp1869_get_pmemsize(device, cols, rows);
- if (!cdp1869.fresvert)
- {
- *BITMAP_ADDR16(bitmap, y + 1, x + 1) = machine->pens[color];
- }
- }
- }
+ addr = cdp1869->hma;
- if (!cdp1869.freshorz)
+ for (sy = 0; sy < rows; sy++)
{
- x++;
- }
+ for (sx = 0; sx < cols; sx++)
+ {
+ int x = sx * width;
+ int y = sy * height;
- x++;
+ cdp1869_draw_char(device, bitmap, x, y, addr, &screen_rect);
- data <<= 1;
+ addr++;
+
+ if (addr == pmemsize) addr = 0;
+ }
+ }
}
}
-static void cdp1869_draw_char(running_machine *machine, bitmap_t *bitmap, int x, int y, UINT16 pramaddr, const rectangle *screenrect)
+/* Sound Update */
+
+#ifdef UNUSED_FUNCTION
+static void cdp1869_sum_square_wave(stream_sample_t *buffer, double frequency, double amplitude)
{
- int i;
- UINT8 code = cdp1869_read_pageram(pramaddr);
- UINT16 addr = code * 8;
- UINT16 addr2 = addr + (CDP1869_CHARRAM_SIZE / 2);
+ // do a fast fourier transform on all the waves in the white noise range
+}
- for (i = 0; i < cdp1869_get_lines(); i++)
- {
- UINT8 data = cdp1869.cram[addr];
+static void cdp1869_sound_update(const device_config *device, stream_sample_t **inputs, stream_sample_t **_buffer, int length)
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
- UINT8 colorbits = cdp1869.color_callback(data, addr, pramaddr);
+ INT16 signal = cdp1869->signal;
+ stream_sample_t *buffer = _buffer[0];
- int pcb = colorbits & 0x01;
- int ccb1 = (colorbits & 0x02) >> 1;
- int ccb0 = (colorbits & 0x04) >> 2;
+ memset(buffer, 0, length * sizeof(*buffer));
- int color = cdp1869_get_color(ccb0, ccb1, pcb);
+ if (!cdp1869->toneoff && cdp1869->toneamp)
+ {
+ double frequency = (cdp1869->intf->pixel_clock / 2) / (512 >> cdp1869->tonefreq) / (cdp1869->tonediv + 1);
- cdp1869_draw_line(machine, bitmap, screenrect->min_x + x, screenrect->min_y + y, data, color);
+ int rate = device->machine->sample_rate / 2;
- addr++;
- y++;
+ /* get progress through wave */
+ int incr = cdp1869->incr;
- if (!cdp1869.fresvert)
+ if (signal < 0)
{
- y++;
+ signal = -(cdp1869->toneamp * (0x07fff / 15));
+ }
+ else
+ {
+ signal = cdp1869->toneamp * (0x07fff / 15);
}
- if (i == 7)
+ while( length-- > 0 )
{
- addr = addr2;
+ *buffer++ = signal;
+ incr -= frequency;
+ while( incr < 0 )
+ {
+ incr += rate;
+ signal = -signal;
+ }
}
- }
-}
-VIDEO_START( cdp1869 )
-{
- state_save_register_item("cdp1869", 0, cdp1869.ntsc_pal);
- state_save_register_item("cdp1869", 0, cdp1869.dispoff);
- state_save_register_item("cdp1869", 0, cdp1869.fresvert);
- state_save_register_item("cdp1869", 0, cdp1869.freshorz);
- state_save_register_item("cdp1869", 0, cdp1869.dblpage);
- state_save_register_item("cdp1869", 0, cdp1869.line16);
- state_save_register_item("cdp1869", 0, cdp1869.line9);
- state_save_register_item("cdp1869", 0, cdp1869.cmem);
- state_save_register_item("cdp1869", 0, cdp1869.cfc);
- state_save_register_item("cdp1869", 0, cdp1869.col);
- state_save_register_item("cdp1869", 0, cdp1869.bkg);
- state_save_register_item("cdp1869", 0, cdp1869.pma);
- state_save_register_item("cdp1869", 0, cdp1869.hma);
- state_save_register_item_array("cdp1869", 0, cdp1869.cram);
- state_save_register_item_array("cdp1869", 0, cdp1869.pram);
- state_save_register_item("cdp1869", 0, cdp1869.cramsize);
- state_save_register_item("cdp1869", 0, cdp1869.pramsize);
-}
+ /* store progress through wave */
+ cdp1869->incr = incr;
+ cdp1869->signal = signal;
+ }
-VIDEO_UPDATE( cdp1869 )
-{
- fillbitmap(bitmap, get_black_pen(screen->machine), cliprect);
+ if (!cdp1869->wnoff)
+ {
+ int wndiv;
+ double amplitude = cdp1869->wnamp * ((0.78*5) / 15);
- if (!cdp1869.dispoff)
- {
- int sx, sy, rows, cols, width, height;
- UINT16 addr, pmemsize;
- rectangle screen_rect, outer;
+ for (wndiv = 0; wndiv < 128; wndiv++)
+ {
+ double frequency = (cdp1869->intf->pixel_clock / 2) / (4096 >> cdp1869->wnfreq) / (wndiv + 1);
- switch (cdp1869.ntsc_pal)
- {
- case CDP1869_NTSC:
- outer.min_x = CDP1869_HBLANK_END;
- outer.max_x = CDP1869_HBLANK_START - 1;
- outer.min_y = CDP1869_SCANLINE_VBLANK_END_NTSC;
- outer.max_y = CDP1869_SCANLINE_VBLANK_START_NTSC - 1;
- screen_rect.min_x = CDP1869_SCREEN_START_NTSC;
- screen_rect.max_x = CDP1869_SCREEN_END - 1;
- screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_NTSC;
- screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_NTSC - 1;
- break;
-
- default:
- case CDP1869_PAL:
- outer.min_x = CDP1869_HBLANK_END;
- outer.max_x = CDP1869_HBLANK_START - 1;
- outer.min_y = CDP1869_SCANLINE_VBLANK_END_PAL;
- outer.max_y = CDP1869_SCANLINE_VBLANK_START_PAL - 1;
- screen_rect.min_x = CDP1869_SCREEN_START_PAL;
- screen_rect.max_x = CDP1869_SCREEN_END - 1;
- screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_PAL;
- screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_PAL - 1;
- break;
- }
+ cdp1869_sum_square_wave(buffer, frequency, amplitude);
+ }
+ }
+}
+#endif
- sect_rect(&outer, cliprect);
- fillbitmap(bitmap, screen->machine->pens[cdp1869.bkg], &outer);
+/* Device Interface */
- width = CDP1869_CHAR_WIDTH;
- height = cdp1869_get_lines();
+static DEVICE_START( cdp1869 )
+{
+ cdp1869_t *cdp1869 = get_safe_token(device);
+ char unique_tag[30];
- if (!cdp1869.freshorz)
- {
- width *= 2;
- }
+ // validate arguments
- if (!cdp1869.fresvert)
- {
- height *= 2;
- }
+ assert(device != NULL);
+ assert(device->tag != NULL);
+ assert(strlen(device->tag) < 20);
+ assert(device->static_config != NULL);
- cols = cdp1869.freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
- rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
+ cdp1869->intf = device->static_config;
- pmemsize = cdp1869_get_pmemsize(cols, rows);
+ assert(cdp1869->intf->page_ram_r != NULL);
+ assert(cdp1869->intf->page_ram_w != NULL);
+ assert(cdp1869->intf->pcb_r != NULL);
+ assert(cdp1869->intf->char_ram_r != NULL);
+ assert(cdp1869->intf->char_ram_w != NULL);
- addr = cdp1869.hma;
+ // set initial values
- for (sy = 0; sy < rows; sy++)
- {
- for (sx = 0; sx < cols; sx++)
- {
- int x = sx * width;
- int y = sy * height;
+ cdp1869->toneoff = 1;
+ cdp1869->wnoff = 1;
- cdp1869_draw_char(screen->machine, bitmap, x, y, addr, &screen_rect);
+ // get the screen device
- addr++;
+ cdp1869->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, cdp1869->intf->screen_tag);
+ assert(cdp1869->screen != NULL);
- if (addr == pmemsize) addr = 0;
- }
- }
+ // allocate timers
+
+ if (cdp1869->intf->on_prd_changed != NULL)
+ {
+ cdp1869->prd_changed_timer = timer_alloc(prd_changed_tick, (void *)device);
+ update_prd_changed_timer(cdp1869);
}
- return 0;
+ // register for state saving
+
+ state_save_combine_module_and_tag(unique_tag, "CDP1869", device->tag);
+ state_save_register_func_postload_ptr(cdp1869_state_save_postload, cdp1869);
+
+ state_save_register_item(unique_tag, 0, cdp1869->dispoff);
+ state_save_register_item(unique_tag, 0, cdp1869->fresvert);
+ state_save_register_item(unique_tag, 0, cdp1869->freshorz);
+ state_save_register_item(unique_tag, 0, cdp1869->cmem);
+ state_save_register_item(unique_tag, 0, cdp1869->dblpage);
+ state_save_register_item(unique_tag, 0, cdp1869->line16);
+ state_save_register_item(unique_tag, 0, cdp1869->line9);
+ state_save_register_item(unique_tag, 0, cdp1869->cfc);
+ state_save_register_item(unique_tag, 0, cdp1869->col);
+ state_save_register_item(unique_tag, 0, cdp1869->bkg);
+ state_save_register_item(unique_tag, 0, cdp1869->pma);
+ state_save_register_item(unique_tag, 0, cdp1869->hma);
+
+ state_save_register_item(unique_tag, 0, cdp1869->signal);
+ state_save_register_item(unique_tag, 0, cdp1869->incr);
+ state_save_register_item(unique_tag, 0, cdp1869->toneoff);
+ state_save_register_item(unique_tag, 0, cdp1869->wnoff);
+ state_save_register_item(unique_tag, 0, cdp1869->tonediv);
+ state_save_register_item(unique_tag, 0, cdp1869->tonefreq);
+ state_save_register_item(unique_tag, 0, cdp1869->toneamp);
+ state_save_register_item(unique_tag, 0, cdp1869->wnfreq);
+ state_save_register_item(unique_tag, 0, cdp1869->wnamp);
}
-void cdp1869_configure(const CDP1869_interface *intf)
+static DEVICE_SET_INFO( cdp1869 )
{
- if (intf->charrom_region != REGION_INVALID)
+ switch (state)
{
- UINT8 *memory = memory_region(intf->charrom_region);
- memcpy(cdp1869.cram, memory, intf->charram_size);
+ /* no parameters to set */
}
+}
- cdp1869.ntsc_pal = intf->video_format;
- cdp1869.cramsize = intf->charram_size;
- cdp1869.pramsize = intf->pageram_size;
- cdp1869.color_callback = intf->get_color_bits;
+DEVICE_GET_INFO( cdp1869_video )
+{
+ switch (state)
+ {
+ /* --- the following bits of info are returned as 64-bit signed integers --- */
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1869_t); break;
+ case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
+ case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
+
+ /* --- the following bits of info are returned as pointers to data or functions --- */
+ case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(cdp1869); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1869); break;
+ case DEVINFO_FCT_STOP: /* Nothing */ break;
+ case DEVINFO_FCT_RESET: /* Nothing */ break;
+
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME: info->s = "RCA CDP1869"; break;
+ case DEVINFO_STR_FAMILY: info->s = "RCA CDP1869"; break;
+ case DEVINFO_STR_VERSION: info->s = "1.0"; break;
+ case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break;
+ case DEVINFO_STR_CREDITS: info->s = "Copyright Nicola Salmoria and the MAME Team"; break;
+ }
}
diff --git a/src/emu/video/cdp1869.h b/src/emu/video/cdp1869.h
index 3320f020633..e5bb914abe2 100644
--- a/src/emu/video/cdp1869.h
+++ b/src/emu/video/cdp1869.h
@@ -34,13 +34,6 @@
#ifndef __CDP1869_VIDEO__
#define __CDP1869_VIDEO__
-typedef enum _cdp1869_video_format cdp1869_video_format;
-
-enum _cdp1869_video_format {
- CDP1869_NTSC,
- CDP1869_PAL
-};
-
#define CDP1869_DOT_CLK_PAL 5626000.0
#define CDP1869_DOT_CLK_NTSC 5670000.0
#define CDP1869_COLOR_CLK_PAL 8867236.0
@@ -54,8 +47,8 @@ enum _cdp1869_video_format {
#define CDP1869_HSYNC_START (56 * CDP1869_CHAR_WIDTH)
#define CDP1869_HSYNC_END (60 * CDP1869_CHAR_WIDTH)
#define CDP1869_HBLANK_START (54 * CDP1869_CHAR_WIDTH)
-#define CDP1869_HBLANK_END (5 * CDP1869_CHAR_WIDTH)
-#define CDP1869_SCREEN_START_PAL (9 * CDP1869_CHAR_WIDTH)
+#define CDP1869_HBLANK_END ( 5 * CDP1869_CHAR_WIDTH)
+#define CDP1869_SCREEN_START_PAL ( 9 * CDP1869_CHAR_WIDTH)
#define CDP1869_SCREEN_START_NTSC (10 * CDP1869_CHAR_WIDTH)
#define CDP1869_SCREEN_START (10 * CDP1869_CHAR_WIDTH)
#define CDP1869_SCREEN_END (50 * CDP1869_CHAR_WIDTH)
@@ -83,48 +76,85 @@ enum _cdp1869_video_format {
#define CDP1869_SCANLINE_PREDISPLAY_END_NTSC 228
#define CDP1869_VISIBLE_SCANLINES_NTSC (CDP1869_SCANLINE_DISPLAY_END_NTSC - CDP1869_SCANLINE_DISPLAY_START_NTSC)
-#define CDP1869_FPS_PAL CDP1869_DOT_CLK_PAL / CDP1869_SCREEN_WIDTH / CDP1869_TOTAL_SCANLINES_PAL
-#define CDP1869_FPS_NTSC CDP1869_DOT_CLK_NTSC / CDP1869_SCREEN_WIDTH / CDP1869_TOTAL_SCANLINES_NTSC
+#define CDP1869_PALETTE_LENGTH 8+64
+
+#define CDP1869_VIDEO DEVICE_GET_INFO_NAME(cdp1869_video)
+
+typedef UINT8 (*cdp1869_char_ram_read_func)(const device_config *device, UINT16 pma, UINT8 cma);
+#define CDP1869_CHAR_RAM_READ(name) UINT8 name(const device_config *device, UINT16 pma, UINT8 cma)
-#define CDP1869_WEIGHT_RED 30 // % of max luminance
-#define CDP1869_WEIGHT_GREEN 59
-#define CDP1869_WEIGHT_BLUE 11
+typedef void (*cdp1869_char_ram_write_func)(const device_config *device, UINT16 pma, UINT8 cma, UINT8 data);
+#define CDP1869_CHAR_RAM_WRITE(name) void name(const device_config *device, UINT16 pma, UINT8 cma, UINT8 data)
-#define CDP1869_CHARRAM_SIZE 0x1000
-#define CDP1869_PAGERAM_SIZE 0x800
+typedef UINT8 (*cdp1869_page_ram_read_func)(const device_config *device, UINT16 pma);
+#define CDP1869_PAGE_RAM_READ(name) UINT8 name(const device_config *device, UINT16 pma)
-#define CDP1869_COLUMNS_HALF 20
-#define CDP1869_COLUMNS_FULL 40
-#define CDP1869_ROWS_HALF 12
-#define CDP1869_ROWS_FULL_PAL 25
-#define CDP1869_ROWS_FULL_NTSC 24
+typedef void (*cdp1869_page_ram_write_func)(const device_config *device, UINT16 pma, UINT8 data);
+#define CDP1869_PAGE_RAM_WRITE(name) void name(const device_config *device, UINT16 pma, UINT8 data)
+
+typedef int (*cdp1869_pcb_read_func)(const device_config *device, UINT16 pma, UINT8 cma);
+#define CDP1869_PCB_READ(name) int name(const device_config *device, UINT16 pma, UINT8 cma)
+
+typedef void (*cdp1869_on_prd_changed_func) (const device_config *device, int prd);
+#define CDP1869_ON_PRD_CHANGED(name) void name(const device_config *device, int prd)
+
+typedef enum _cdp1869_format cdp1869_format;
+enum _cdp1869_format {
+ CDP1869_NTSC = 0,
+ CDP1869_PAL
+};
-typedef struct CDP1869_interface
+/* interface */
+typedef struct _cdp1869_interface cdp1869_interface;
+struct _cdp1869_interface
{
- cdp1869_video_format video_format; // display format (NTSC/PAL)
- int charrom_region; // memory region to load CHARRAM from
- UINT16 charram_size; // CHARRAM size
- UINT16 pageram_size; // PAGERAM size
- UINT8 (*get_color_bits)(UINT8 cramdata, UINT16 cramaddr, UINT16 pramaddr); // 0x01 = PCB, 0x02 = CCB0, 0x04 = CCB1
-} CDP1869_interface;
-
-WRITE8_HANDLER ( cdp1869_out3_w );
-WRITE8_HANDLER ( cdp1869_out4_w );
-WRITE8_HANDLER ( cdp1869_out5_w );
-WRITE8_HANDLER ( cdp1869_out6_w );
-WRITE8_HANDLER ( cdp1869_out7_w );
+ const char *screen_tag; /* screen we are acting on */
+ int pixel_clock; /* the dot clock of the chip */
+ int color_clock; /* the chroma clock of the chip */
+ cdp1869_format pal_ntsc; /* screen format */
+
+ /* page memory read function */
+ cdp1869_page_ram_read_func page_ram_r;
+
+ /* page memory write function */
+ cdp1869_page_ram_write_func page_ram_w;
+
+ /* page memory color bit read function */
+ cdp1869_pcb_read_func pcb_r;
+
+ /* character memory read function */
+ cdp1869_char_ram_read_func char_ram_r;
+
+ /* character memory write function */
+ cdp1869_char_ram_write_func char_ram_w;
+
+ /* if specified, this gets called for every change of the predisplay pin (CDP1870/76 pin 1) */
+ cdp1869_on_prd_changed_func on_prd_changed;
+};
+
+/* device interface */
+DEVICE_GET_INFO( cdp1869_video );
+
+/* palette initialization */
PALETTE_INIT( cdp1869 );
-VIDEO_START( cdp1869 );
-VIDEO_UPDATE( cdp1869 );
-READ8_HANDLER ( cdp1869_charram_r );
-READ8_HANDLER ( cdp1869_pageram_r );
-WRITE8_HANDLER ( cdp1869_charram_w );
-WRITE8_HANDLER ( cdp1869_pageram_w );
+/* io port access */
+WRITE8_DEVICE_HANDLER( cdp1869_out3_w );
+WRITE8_DEVICE_HANDLER( cdp1869_out4_w );
+WRITE8_DEVICE_HANDLER( cdp1869_out5_w );
+WRITE8_DEVICE_HANDLER( cdp1869_out6_w );
+WRITE8_DEVICE_HANDLER( cdp1869_out7_w );
+
+/* character memory access */
+READ8_DEVICE_HANDLER ( cdp1869_charram_r );
+WRITE8_DEVICE_HANDLER ( cdp1869_charram_w );
-void cdp1869_configure(const CDP1869_interface *intf);
+/* page memory access */
+READ8_DEVICE_HANDLER ( cdp1869_pageram_r );
+WRITE8_DEVICE_HANDLER ( cdp1869_pageram_w );
-UINT16 cdp1869_get_cma(UINT16 offset);
+/* updates the screen */
+void cdp1869_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
#endif
diff --git a/src/mame/drivers/cidelsa.c b/src/mame/drivers/cidelsa.c
index dc81fb64588..be055a3c384 100644
--- a/src/mame/drivers/cidelsa.c
+++ b/src/mame/drivers/cidelsa.c
@@ -1,9 +1,11 @@
#include "driver.h"
+#include "deprecat.h"
#include "cpu/cdp1802/cdp1802.h"
#include "cpu/cop400/cop400.h"
#include "video/cdp1869.h"
#include "sound/cdp1869.h"
#include "sound/ay8910.h"
+#include "cidelsa.h"
/*
@@ -14,118 +16,137 @@
*/
-#define DESTRYER_CHR1 3579000.0 // unverified
-#define DESTRYER_CHR2 XTAL_5_7143MHz
-#define ALTAIR_CHR1 3579000.0 // unverified
-#define ALTAIR_CHR2 CDP1869_DOT_CLK_PAL // unverified
-#define DRACO_CHR1 XTAL_4_43361MHz
-#define DRACO_CHR2 CDP1869_DOT_CLK_PAL // unverified
-#define DRACO_SND_CHR1 XTAL_2_01216MHz
+#define CDP1869_TAG "cdp1869"
/* CDP1802 Interface */
-static int cdp1869_prd;
-static int cdp1869_pcb;
-static UINT8 *pcb_ram; // 2048x1 bit PCB ram
-
-static int cdp1802_mode = CDP1802_MODE_RESET;
-
static UINT8 cidelsa_mode_r(void)
{
- return cdp1802_mode;
+ cidelsa_state *state = Machine->driver_data;
+
+ return state->cdp1802_mode;
}
static UINT8 cidelsa_ef_r(void)
{
+ /*
+ EF1 CDP1869 _PRD
+ EF2 Test
+ EF3 Coin 2
+ EF4 Coin 1
+ */
+
return readinputportbytag("EF");
}
+static void cidelsa_q_w(int q)
+{
+ cidelsa_state *state = Machine->driver_data;
+
+ state->cdp1802_q = q;
+}
+
static const CDP1802_CONFIG cidelsa_cdp1802_config =
{
- cidelsa_mode_r, // MODE input
- cidelsa_ef_r, // EF input
- NULL, // SC output
- NULL, // Q output
- NULL, // DMA read
- NULL // DMA write
+ cidelsa_mode_r, // MODE
+ cidelsa_ef_r, // EF
+ NULL, // SC
+ cidelsa_q_w, // Q
+ NULL, // DMA read
+ NULL // DMA write
};
-/* Draco Sound Interface */
-
-static int draco_sound;
-static int draco_ay_latch;
+/* Sound Interface */
-static WRITE8_HANDLER ( draco_sound_bankswitch_w )
+static WRITE8_HANDLER( draco_sound_bankswitch_w )
{
- memory_set_bank(1, BIT(data, 3));
+ /*
+
+ pin description
+
+ D0 not connected
+ D1 not connected
+ D2 not connected
+ D3 2716 A10
+
+ */
+
+ int bank = BIT(data, 3);
+
+ memory_set_bank(1, bank);
}
-static WRITE8_HANDLER ( draco_sound_g_w )
+static WRITE8_HANDLER( draco_sound_g_w )
{
+ cidelsa_state *state = machine->driver_data;
+
/*
- G1 G0 description
+ G1 G0 description
- 0 0 IAB inactive
- 0 1 DWS write to PSG
- 1 0 DTB read from PSG
- 1 1 INTAK latch address
+ 0 0 IAB inactive
+ 0 1 DWS write to PSG
+ 1 0 DTB read from PSG
+ 1 1 INTAK latch address
*/
switch (data)
{
case 0x01:
- AY8910_write_port_0_w(machine, 0, draco_ay_latch);
+ AY8910_write_port_0_w(machine, 0, state->draco_ay_latch);
break;
case 0x02:
- draco_ay_latch = AY8910_read_port_0_r(machine, 0);
+ state->draco_ay_latch = AY8910_read_port_0_r(machine, 0);
break;
case 0x03:
- AY8910_control_port_0_w(machine, 0, draco_ay_latch);
+ AY8910_control_port_0_w(machine, 0, state->draco_ay_latch);
break;
}
}
-static READ8_HANDLER ( draco_sound_in_r )
+static READ8_HANDLER( draco_sound_in_r )
{
- return ~draco_sound & 0x07; // inverted
+ cidelsa_state *state = machine->driver_data;
+
+ return ~(state->draco_sound) & 0x07;
}
-static READ8_HANDLER ( draco_sound_ay8910_r )
+static READ8_HANDLER( draco_sound_ay8910_r )
{
- return draco_ay_latch;
+ cidelsa_state *state = machine->driver_data;
+
+ return state->draco_ay_latch;
}
-static WRITE8_HANDLER ( draco_sound_ay8910_w )
+static WRITE8_HANDLER( draco_sound_ay8910_w )
{
- draco_ay_latch = data;
+ cidelsa_state *state = machine->driver_data;
+
+ state->draco_ay_latch = data;
}
-static WRITE8_HANDLER ( draco_ay8910_port_a_w )
+static WRITE8_HANDLER( draco_ay8910_port_a_w )
{
/*
-
bit description
- 0 N/C
- 1 N/C
- 2 N/C
- 3 N/C
- 4 N/C
- 5 N/C
- 6 N/C
- 7 N/C
-
+ 0 not connected
+ 1 not connected
+ 2 not connected
+ 3 not connected
+ 4 not connected
+ 5 not connected
+ 6 not connected
+ 7 not connected
*/
}
-static WRITE8_HANDLER ( draco_ay8910_port_b_w )
+static WRITE8_HANDLER( draco_ay8910_port_b_w )
{
/*
-
bit description
0 RELE0
@@ -133,27 +154,25 @@ static WRITE8_HANDLER ( draco_ay8910_port_b_w )
2 sound output -> * -> 22K capacitor -> GND
3 sound output -> * -> 220K capacitor -> GND
4 5V -> 1K resistor -> * -> 10uF capacitor -> GND (volume pot voltage adjustment)
- 5 N/C
- 6 N/C
- 7 N/C
-
+ 5 not connected
+ 6 not connected
+ 7 not connected
*/
}
static const struct AY8910interface ay8910_interface =
{
- 0, // port A read
- 0, // port B read
- draco_ay8910_port_a_w, // port A write
- draco_ay8910_port_b_w // port B write
+ 0,
+ 0,
+ draco_ay8910_port_a_w,
+ draco_ay8910_port_b_w
};
/* Read/Write Handlers */
-static WRITE8_HANDLER ( destryer_out1_w )
+static WRITE8_HANDLER( destryer_out1_w )
{
/*
-
bit description
0
@@ -164,14 +183,12 @@ static WRITE8_HANDLER ( destryer_out1_w )
5
6
7
-
*/
}
-static WRITE8_HANDLER ( altair_out1_w )
+static WRITE8_HANDLER( altair_out1_w )
{
/*
-
bit description
0 S1 (CARTUCHO)
@@ -182,50 +199,31 @@ static WRITE8_HANDLER ( altair_out1_w )
5 LGF
6 CONT. M2
7 CONT. M1
-
*/
- set_led_status(0, BIT(data, 3)); // 1P
- set_led_status(1, BIT(data, 4)); // 2P
- set_led_status(2, BIT(data, 5)); // FIRE
+ set_led_status(0, data & 0x08); // 1P
+ set_led_status(1, data & 0x10); // 2P
+ set_led_status(2, data & 0x20); // FIRE
}
-static WRITE8_HANDLER ( draco_out1_w )
+static WRITE8_HANDLER( draco_out1_w )
{
- /*
+ cidelsa_state *state = machine->driver_data;
+ /*
bit description
0 3K9 -> Green signal
1 820R -> Blue signal
2 510R -> Red signal
- 3 1K -> N/C
- 4 N/C
+ 3 1K -> not connected
+ 4 not connected
5 SONIDO A -> COP402 IN0
6 SONIDO B -> COP402 IN1
7 SONIDO C -> COP402 IN2
-
*/
- draco_sound = (data >> 5) & 0x07;
-}
-
-static WRITE8_HANDLER ( cidelsa_charram_w )
-{
- int addr = cdp1869_get_cma(offset);
-
- pcb_ram[addr] = activecpu_get_reg(CDP1802_Q);
-
- cdp1869_charram_w(machine, offset, data);
-}
-
-static READ8_HANDLER ( cidelsa_charram_r )
-{
- int addr = cdp1869_get_cma(offset);
-
- cdp1869_pcb = pcb_ram[addr];
-
- return cdp1869_charram_r(machine, offset);
+ state->draco_sound = (data & 0xe0) >> 5;
}
/* Memory Maps */
@@ -235,25 +233,25 @@ static READ8_HANDLER ( cidelsa_charram_r )
static ADDRESS_MAP_START( destryer_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x2000, 0x20ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
- AM_RANGE(0xf400, 0xf7ff) AM_READWRITE(cidelsa_charram_r, cidelsa_charram_w)
- AM_RANGE(0xf800, 0xffff) AM_READWRITE(cdp1869_pageram_r, cdp1869_pageram_w)
+ AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
+ AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( destryea_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x3000, 0x30ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
- AM_RANGE(0xf400, 0xf7ff) AM_READWRITE(cidelsa_charram_r, cidelsa_charram_w)
- AM_RANGE(0xf800, 0xffff) AM_READWRITE(cdp1869_pageram_r, cdp1869_pageram_w)
+ AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
+ AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( destryer_io_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x01, 0x01) AM_READ_PORT("IN0") AM_WRITE(destryer_out1_w)
AM_RANGE(0x02, 0x02) AM_READ_PORT("IN1")
- AM_RANGE(0x03, 0x03) AM_WRITE(cdp1869_out3_w)
- AM_RANGE(0x04, 0x04) AM_WRITE(cdp1869_out4_w)
- AM_RANGE(0x05, 0x05) AM_WRITE(cdp1869_out5_w)
- AM_RANGE(0x06, 0x06) AM_WRITE(cdp1869_out6_w)
- AM_RANGE(0x07, 0x07) AM_WRITE(cdp1869_out7_w)
+ AM_RANGE(0x03, 0x03) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out3_w)
+ AM_RANGE(0x04, 0x04) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out4_w)
+ AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out5_w)
+ AM_RANGE(0x06, 0x06) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out6_w)
+ AM_RANGE(0x07, 0x07) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out7_w)
ADDRESS_MAP_END
// Altair
@@ -261,18 +259,18 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( altair_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x2fff) AM_ROM
AM_RANGE(0x3000, 0x30ff) AM_RAM
- AM_RANGE(0xf400, 0xf7ff) AM_READWRITE(cidelsa_charram_r, cidelsa_charram_w)
- AM_RANGE(0xf800, 0xffff) AM_READWRITE(cdp1869_pageram_r, cdp1869_pageram_w)
+ AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
+ AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( altair_io_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x01, 0x01) AM_READ_PORT("IN0") AM_WRITE(altair_out1_w)
AM_RANGE(0x02, 0x02) AM_READ_PORT("IN1")
- AM_RANGE(0x03, 0x03) AM_WRITE(cdp1869_out3_w)
- AM_RANGE(0x04, 0x04) AM_READ_PORT("IN2") AM_WRITE(cdp1869_out4_w)
- AM_RANGE(0x05, 0x05) AM_WRITE(cdp1869_out5_w)
- AM_RANGE(0x06, 0x06) AM_WRITE(cdp1869_out6_w)
- AM_RANGE(0x07, 0x07) AM_WRITE(cdp1869_out7_w)
+ AM_RANGE(0x03, 0x03) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out3_w)
+ AM_RANGE(0x04, 0x04) AM_READ_PORT("IN2") AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out4_w)
+ AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out5_w)
+ AM_RANGE(0x06, 0x06) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out6_w)
+ AM_RANGE(0x07, 0x07) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out7_w)
ADDRESS_MAP_END
// Draco
@@ -280,18 +278,18 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( draco_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
- AM_RANGE(0xf400, 0xf7ff) AM_READWRITE(cidelsa_charram_r, cidelsa_charram_w)
- AM_RANGE(0xf800, 0xffff) AM_READWRITE(cdp1869_pageram_r, cdp1869_pageram_w)
+ AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
+ AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( draco_io_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x01, 0x01) AM_READ_PORT("IN0") AM_WRITE(draco_out1_w)
AM_RANGE(0x02, 0x02) AM_READ_PORT("IN1")
- AM_RANGE(0x03, 0x03) AM_WRITE(cdp1869_out3_w)
- AM_RANGE(0x04, 0x04) AM_READ_PORT("IN2") AM_WRITE(cdp1869_out4_w)
- AM_RANGE(0x05, 0x05) AM_WRITE(cdp1869_out5_w)
- AM_RANGE(0x06, 0x06) AM_WRITE(cdp1869_out6_w)
- AM_RANGE(0x07, 0x07) AM_WRITE(cdp1869_out7_w)
+ AM_RANGE(0x03, 0x03) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out3_w)
+ AM_RANGE(0x04, 0x04) AM_READ_PORT("IN2") AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out4_w)
+ AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out5_w)
+ AM_RANGE(0x06, 0x06) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out6_w)
+ AM_RANGE(0x07, 0x07) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_out7_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( draco_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
@@ -311,12 +309,16 @@ ADDRESS_MAP_END
static CUSTOM_INPUT( cdp1869_pcb_r )
{
- return cdp1869_pcb;
+ cidelsa_state *state = machine->driver_data;
+
+ return state->cdp1869_pcb;
}
static CUSTOM_INPUT( cdp1869_predisplay_r )
{
- return cdp1869_prd;
+ cidelsa_state *state = machine->driver_data;
+
+ return state->cdp1869_prd;
}
static INPUT_PORTS_START( destryer )
@@ -461,118 +463,49 @@ static INPUT_PORTS_START( draco )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 ) // M1
INPUT_PORTS_END
-/* Video Timer Callbacks */
-
-static TIMER_CALLBACK( altair_prd_start )
-{
- cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE);
- cdp1869_prd = 1; // inverted
-}
-
-static TIMER_CALLBACK( altair_prd_end )
-{
- cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, CLEAR_LINE);
- cdp1869_prd = 0; // inverted
-}
-
-static TIMER_CALLBACK( draco_prd_start )
-{
- cdp1869_prd = 0;
-}
-
-static TIMER_CALLBACK( draco_prd_end )
-{
- cdp1869_prd = 1;
-}
-
/* Machine Start */
static TIMER_CALLBACK( set_cpu_mode )
{
- cdp1802_mode = CDP1802_MODE_RUN;
-}
-
-static UINT8 cidelsa_get_color_bits(UINT8 cramdata, UINT16 cramaddr, UINT16 pramaddr)
-{
- int ccb0 = BIT(cramdata, 6);
- int ccb1 = BIT(cramdata, 7);
- int pcb = BIT(pcb_ram[cramaddr & 0x7ff], 0);
+ cidelsa_state *state = machine->driver_data;
- return (ccb0 << 2) + (ccb1 << 1) + pcb;
+ state->cdp1802_mode = CDP1802_MODE_RUN;
}
-static const CDP1869_interface destryer_CDP1869_interface =
-{
- CDP1869_PAL, // display format
- REGION_INVALID, // character RAM region
- 0x800, // character RAM size
- 0x400, // page RAM size
- cidelsa_get_color_bits // color callback function
-};
-
-static const CDP1869_interface draco_CDP1869_interface =
+static MACHINE_START( cidelsa )
{
- CDP1869_PAL, // display format
- REGION_INVALID, // character RAM region
- 0x800, // character RAM size
- 0x800, // page RAM size
- cidelsa_get_color_bits // color callback function
-};
-
-static MACHINE_START( destryer )
-{
- // allocate PCB RAM
-
- pcb_ram = auto_malloc(0x800);
-
- // configure CDP1869
+ cidelsa_state *state = machine->driver_data;
- cdp1869_configure(&destryer_CDP1869_interface);
-
- // allocate one-shot CPU mode set timer
+ // reset the CPU
+ state->cdp1802_mode = CDP1802_MODE_RESET;
timer_set(ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
- // save state support
+ // register save states
- state_save_register_global(cdp1802_mode);
- state_save_register_global_pointer(pcb_ram, 0x800);
- state_save_register_global(cdp1869_prd);
- state_save_register_global(cdp1869_pcb);
+ state_save_register_global(state->cdp1802_mode);
}
static MACHINE_START( draco )
{
- // configure COP402 ROM banking
-
- UINT8 *ROM = memory_region(REGION_CPU2);
- memory_configure_bank(1, 0, 2, &ROM[0x000], 0x400);
-
- // allocate PCB RAM
+ cidelsa_state *state = machine->driver_data;
- pcb_ram = auto_malloc(0x800);
+ MACHINE_START_CALL( cidelsa );
- // configure CDP1869
+ // COP402 memory banking
- cdp1869_configure(&draco_CDP1869_interface);
-
- // allocate one-shot CPU mode set timer
-
- timer_set(ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
+ memory_configure_bank(1, 0, 2, memory_region(REGION_CPU2), 0x400);
+ memory_set_bank(1, 0);
- // save state support
+ // register save states
- state_save_register_global(cdp1802_mode);
- state_save_register_global_pointer(pcb_ram, 0x800);
- state_save_register_global(cdp1869_prd);
- state_save_register_global(cdp1869_pcb);
- state_save_register_global(draco_sound);
- state_save_register_global(draco_ay_latch);
+ state_save_register_global(state->draco_sound);
+ state_save_register_global(state->draco_ay_latch);
}
/* Machine Reset */
-static MACHINE_RESET( destryer )
+static MACHINE_RESET( cidelsa )
{
cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE);
}
@@ -580,6 +513,8 @@ static MACHINE_RESET( destryer )
/* Machine Drivers */
static MACHINE_DRIVER_START( destryer )
+ MDRV_DRIVER_DATA(cidelsa_state)
+
// basic system hardware
MDRV_CPU_ADD(CDP1802, DESTRYER_CHR1)
@@ -587,23 +522,13 @@ static MACHINE_DRIVER_START( destryer )
MDRV_CPU_IO_MAP(destryer_io_map, 0)
MDRV_CPU_CONFIG(cidelsa_cdp1802_config)
MDRV_NVRAM_HANDLER(generic_0fill)
- MDRV_MACHINE_START(destryer)
- MDRV_MACHINE_RESET(destryer)
-
- // video hardware
- MDRV_PALETTE_LENGTH(8+64)
- MDRV_PALETTE_INIT(cdp1869)
- MDRV_VIDEO_START(cdp1869)
- MDRV_VIDEO_UPDATE(cdp1869)
+ MDRV_MACHINE_START(cidelsa)
+ MDRV_MACHINE_RESET(cidelsa)
- MDRV_SCREEN_ADD("main", RASTER)
- MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_RAW_PARAMS(DESTRYER_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
- MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.4, 0.044)
+ // video hardware
- MDRV_TIMER_ADD_SCANLINE("prd_start", altair_prd_start, "main", CDP1869_SCANLINE_PREDISPLAY_START_PAL, CDP1869_TOTAL_SCANLINES_PAL)
- MDRV_TIMER_ADD_SCANLINE("prd_end", altair_prd_end, "main", CDP1869_SCANLINE_PREDISPLAY_END_PAL, CDP1869_TOTAL_SCANLINES_PAL)
+ MDRV_IMPORT_FROM(destryer_video)
// sound hardware
@@ -614,6 +539,8 @@ static MACHINE_DRIVER_START( destryer )
MACHINE_DRIVER_END
static MACHINE_DRIVER_START( destryea )
+ MDRV_DRIVER_DATA(cidelsa_state)
+
// basic system hardware
MDRV_CPU_ADD(CDP1802, DESTRYER_CHR1)
@@ -621,23 +548,13 @@ static MACHINE_DRIVER_START( destryea )
MDRV_CPU_IO_MAP(destryer_io_map, 0)
MDRV_CPU_CONFIG(cidelsa_cdp1802_config)
MDRV_NVRAM_HANDLER(generic_0fill)
- MDRV_MACHINE_START(destryer)
- MDRV_MACHINE_RESET(destryer)
- // video hardware
-
- MDRV_PALETTE_LENGTH(8+64)
- MDRV_PALETTE_INIT(cdp1869)
- MDRV_VIDEO_START(cdp1869)
- MDRV_VIDEO_UPDATE(cdp1869)
+ MDRV_MACHINE_START(cidelsa)
+ MDRV_MACHINE_RESET(cidelsa)
- MDRV_SCREEN_ADD("main", RASTER)
- MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_RAW_PARAMS(DESTRYER_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
- MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.4, 0.044)
+ // video hardware
- MDRV_TIMER_ADD_SCANLINE("prd_start", altair_prd_start, "main", CDP1869_SCANLINE_PREDISPLAY_START_PAL, CDP1869_TOTAL_SCANLINES_PAL)
- MDRV_TIMER_ADD_SCANLINE("prd_end", altair_prd_end, "main", CDP1869_SCANLINE_PREDISPLAY_END_PAL, CDP1869_TOTAL_SCANLINES_PAL)
+ MDRV_IMPORT_FROM(destryer_video)
// sound hardware
@@ -648,29 +565,21 @@ static MACHINE_DRIVER_START( destryea )
MACHINE_DRIVER_END
static MACHINE_DRIVER_START( altair )
+ MDRV_DRIVER_DATA(cidelsa_state)
+
// basic system hardware
MDRV_CPU_ADD(CDP1802, ALTAIR_CHR1)
MDRV_CPU_PROGRAM_MAP(altair_map, 0)
MDRV_CPU_IO_MAP(altair_io_map, 0)
MDRV_CPU_CONFIG(cidelsa_cdp1802_config)
- MDRV_MACHINE_START(destryer)
- MDRV_MACHINE_RESET(destryer)
-
- // video hardware
- MDRV_PALETTE_LENGTH(8+64)
- MDRV_PALETTE_INIT(cdp1869)
- MDRV_VIDEO_START(cdp1869)
- MDRV_VIDEO_UPDATE(cdp1869)
+ MDRV_MACHINE_START(cidelsa)
+ MDRV_MACHINE_RESET(cidelsa)
- MDRV_SCREEN_ADD("main", RASTER)
- MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_RAW_PARAMS(ALTAIR_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
- MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.4, 0.044)
+ // video hardware
- MDRV_TIMER_ADD_SCANLINE("prd_start", altair_prd_start, "main", CDP1869_SCANLINE_PREDISPLAY_START_PAL, CDP1869_TOTAL_SCANLINES_PAL)
- MDRV_TIMER_ADD_SCANLINE("prd_end", altair_prd_end, "main", CDP1869_SCANLINE_PREDISPLAY_END_PAL, CDP1869_TOTAL_SCANLINES_PAL)
+ MDRV_IMPORT_FROM(altair_video)
// sound hardware
@@ -681,6 +590,8 @@ static MACHINE_DRIVER_START( altair )
MACHINE_DRIVER_END
static MACHINE_DRIVER_START( draco )
+ MDRV_DRIVER_DATA(cidelsa_state)
+
// basic system hardware
MDRV_CPU_ADD(CDP1802, DRACO_CHR1)
@@ -688,8 +599,9 @@ static MACHINE_DRIVER_START( draco )
MDRV_CPU_IO_MAP(draco_io_map, 0)
MDRV_CPU_CONFIG(cidelsa_cdp1802_config)
MDRV_NVRAM_HANDLER(generic_0fill)
+
MDRV_MACHINE_START(draco)
- MDRV_MACHINE_RESET(destryer)
+ MDRV_MACHINE_RESET(cidelsa)
MDRV_CPU_ADD(COP420, DRACO_SND_CHR1) // COP402N
MDRV_CPU_PROGRAM_MAP(draco_sound_map, 0)
@@ -697,18 +609,7 @@ static MACHINE_DRIVER_START( draco )
// video hardware
- MDRV_PALETTE_LENGTH(8+64)
- MDRV_PALETTE_INIT(cdp1869)
- MDRV_VIDEO_START(cdp1869)
- MDRV_VIDEO_UPDATE(cdp1869)
-
- MDRV_SCREEN_ADD("main", RASTER)
- MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_RAW_PARAMS(DRACO_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
- MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.360, 0.024)
-
- MDRV_TIMER_ADD_SCANLINE("prd_start", draco_prd_start, "main", CDP1869_SCANLINE_PREDISPLAY_START_PAL, CDP1869_TOTAL_SCANLINES_PAL)
- MDRV_TIMER_ADD_SCANLINE("prd_end", draco_prd_end, "main", CDP1869_SCANLINE_PREDISPLAY_END_PAL, CDP1869_TOTAL_SCANLINES_PAL)
+ MDRV_IMPORT_FROM(draco_video)
// sound hardware
@@ -768,7 +669,7 @@ ROM_END
/* Game Drivers */
-GAME( 1980, destryer, 0, destryer, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
-GAME( 1980, destryea, destryer, destryea, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 2)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
-GAME( 1981, altair, 0, altair, altair, 0, ROT90, "Cidelsa", "Altair", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
+GAME( 1980, destryer, 0, destryer, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 1)", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
+GAME( 1980, destryea, destryer, destryea, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 2)", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
+GAME( 1981, altair, 0, altair, altair, 0, ROT90, "Cidelsa", "Altair", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
GAME( 1981, draco, 0, draco, draco, 0, ROT90, "Cidelsa", "Draco", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
diff --git a/src/mame/includes/cidelsa.h b/src/mame/includes/cidelsa.h
new file mode 100644
index 00000000000..ccac5b50219
--- /dev/null
+++ b/src/mame/includes/cidelsa.h
@@ -0,0 +1,38 @@
+#ifndef __CIDELSA__
+#define __CIDELSA__
+
+#include "video/cdp1869.h"
+
+#define DESTRYER_CHR1 3579000.0 // unverified
+#define DESTRYER_CHR2 XTAL_5_7143MHz
+#define ALTAIR_CHR1 3579000.0 // unverified
+#define ALTAIR_CHR2 CDP1869_DOT_CLK_PAL // unverified
+#define DRACO_CHR1 XTAL_4_43361MHz
+#define DRACO_CHR2 CDP1869_DOT_CLK_PAL // unverified
+#define DRACO_SND_CHR1 XTAL_2_01216MHz
+
+typedef struct _cidelsa_state cidelsa_state;
+
+struct _cidelsa_state
+{
+ int cdp1802_mode;
+ int cdp1802_q;
+
+ int cdp1869_prd;
+ int cdp1869_pcb;
+
+ int draco_sound;
+ int draco_ay_latch;
+
+ UINT8 *pageram;
+ UINT8 *pcbram;
+ UINT8 *charram;
+};
+
+/*----------- defined in video/cidelsa.c -----------*/
+
+MACHINE_DRIVER_EXTERN( destryer_video );
+MACHINE_DRIVER_EXTERN( altair_video );
+MACHINE_DRIVER_EXTERN( draco_video );
+
+#endif
diff --git a/src/mame/mame.mak b/src/mame/mame.mak
index 465cdf4dff8..44b73742d1e 100644
--- a/src/mame/mame.mak
+++ b/src/mame/mame.mak
@@ -1515,7 +1515,7 @@ $(MAMEOBJ)/misc.a: \
$(DRIVERS)/carrera.o \
$(DRIVERS)/cave.o $(VIDEO)/cave.o \
$(DRIVERS)/cherrym.o \
- $(DRIVERS)/cidelsa.o \
+ $(DRIVERS)/cidelsa.o $(VIDEO)/cidelsa.o \
$(DRIVERS)/coinmstr.o \
$(DRIVERS)/comebaby.o \
$(DRIVERS)/coolpool.o \
diff --git a/src/mame/video/cidelsa.c b/src/mame/video/cidelsa.c
new file mode 100644
index 00000000000..c4b9b0d38db
--- /dev/null
+++ b/src/mame/video/cidelsa.c
@@ -0,0 +1,298 @@
+#include "driver.h"
+#include "video/cdp1869.h"
+#include "cidelsa.h"
+
+#define CIDELSA_PAGERAM_SIZE 0x400
+#define DRACO_PAGERAM_SIZE 0x800
+#define CIDELSA_CHARRAM_SIZE 0x800
+
+#define CIDELSA_PAGERAM_MASK 0x3ff
+#define DRACO_PAGERAM_MASK 0x7ff
+#define CIDELSA_CHARRAM_MASK 0x7ff
+
+#define SCREEN_TAG "main"
+#define CDP1869_TAG "cdp1869"
+
+/* Page RAM Access */
+
+static CDP1869_PAGE_RAM_READ(cidelsa_pageram_r)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT16 addr = pma & CIDELSA_PAGERAM_MASK;
+
+ if (BIT(pma, 10))
+ {
+ return 0xff;
+ }
+
+ return state->pageram[addr];
+}
+
+static CDP1869_PAGE_RAM_WRITE(cidelsa_pageram_w)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT16 addr = pma & CIDELSA_PAGERAM_MASK;
+
+ if (BIT(pma, 10))
+ {
+ return;
+ }
+
+ state->pageram[addr] = data;
+}
+
+static CDP1869_PAGE_RAM_READ(draco_pageram_r)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT16 addr = pma & DRACO_PAGERAM_MASK;
+
+ return state->pageram[addr];
+}
+
+static CDP1869_PAGE_RAM_WRITE(draco_pageram_w)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT16 addr = pma & DRACO_PAGERAM_MASK;
+
+ state->pageram[addr] = data;
+}
+
+/* Character RAM Access */
+
+static CDP1869_CHAR_RAM_READ(cidelsa_charram_r)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT8 column = BIT(pma, 10) ? 0xff : state->pageram[pma & CIDELSA_PAGERAM_MASK];
+ UINT16 addr = ((column << 3) | (cma & 0x07)) & CIDELSA_CHARRAM_MASK;
+
+ UINT8 data = state->charram[addr];
+ state->cdp1869_pcb = state->pcbram[addr];
+
+ return data;
+}
+
+static CDP1869_CHAR_RAM_WRITE(cidelsa_charram_w)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT8 column = BIT(pma, 10) ? 0xff : state->pageram[pma & CIDELSA_PAGERAM_MASK];
+ UINT16 addr = ((column << 3) | (cma & 0x07)) & CIDELSA_CHARRAM_MASK;
+
+ state->charram[addr] = data;
+ state->pcbram[addr] = state->cdp1802_q;
+}
+
+static CDP1869_CHAR_RAM_READ(draco_charram_r)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT8 column = state->pageram[pma & DRACO_PAGERAM_MASK];
+ UINT16 addr = ((column << 3) | (cma & 0x07)) & CIDELSA_CHARRAM_MASK;
+
+ UINT8 data = state->charram[addr];
+ state->cdp1869_pcb = state->pcbram[addr];
+
+ return data;
+}
+
+static CDP1869_CHAR_RAM_WRITE(draco_charram_w)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT8 column = state->pageram[pma & DRACO_PAGERAM_MASK];
+ UINT16 addr = ((column << 3) | (cma & 0x07)) & CIDELSA_CHARRAM_MASK;
+
+ state->charram[addr] = data;
+ state->pcbram[addr] = state->cdp1802_q;
+}
+
+/* Page Color Bit Access */
+
+static CDP1869_PCB_READ(cidelsa_pcb_r)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT8 column = state->pageram[pma & CIDELSA_PAGERAM_MASK];
+ UINT16 addr = ((column << 3) | (cma & 0x07)) & CIDELSA_CHARRAM_MASK;
+
+ return state->pcbram[addr];
+}
+
+static CDP1869_PCB_READ(draco_pcb_r)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ UINT8 column = state->pageram[pma & DRACO_PAGERAM_MASK];
+ UINT16 addr = ((column << 3) | (cma & 0x07)) & CIDELSA_CHARRAM_MASK;
+
+ return state->pcbram[addr];
+}
+
+/* Predisplay Changed Handler */
+
+static CDP1869_ON_PRD_CHANGED(cidelsa_prd_changed)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ // PRD is inverted
+
+ cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, !prd);
+ state->cdp1869_prd = !prd;
+}
+
+static CDP1869_ON_PRD_CHANGED(draco_prd_changed)
+{
+ cidelsa_state *state = device->machine->driver_data;
+
+ state->cdp1869_prd = prd;
+}
+
+/* CDP1869 Interface */
+
+static const cdp1869_interface destryer_cdp1869_intf =
+{
+ SCREEN_TAG,
+ DESTRYER_CHR2,
+ 0,
+ CDP1869_PAL,
+ cidelsa_pageram_r,
+ cidelsa_pageram_w,
+ cidelsa_pcb_r,
+ cidelsa_charram_r,
+ cidelsa_charram_w,
+ cidelsa_prd_changed,
+};
+
+static const cdp1869_interface altair_cdp1869_intf =
+{
+ SCREEN_TAG,
+ ALTAIR_CHR2,
+ 0,
+ CDP1869_PAL,
+ cidelsa_pageram_r,
+ cidelsa_pageram_w,
+ cidelsa_pcb_r,
+ cidelsa_charram_r,
+ cidelsa_charram_w,
+ cidelsa_prd_changed,
+};
+
+static const cdp1869_interface draco_cdp1869_intf =
+{
+ SCREEN_TAG,
+ DRACO_CHR2,
+ 0,
+ CDP1869_PAL,
+ draco_pageram_r,
+ draco_pageram_w,
+ draco_pcb_r,
+ draco_charram_r,
+ draco_charram_w,
+ draco_prd_changed,
+};
+
+/* Video Start */
+
+static VIDEO_START(cidelsa)
+{
+ cidelsa_state *state = machine->driver_data;
+
+ // allocate memory
+
+ state->pageram = auto_malloc(CIDELSA_PAGERAM_SIZE);
+ state->pcbram = auto_malloc(CIDELSA_CHARRAM_SIZE);
+ state->charram = auto_malloc(CIDELSA_CHARRAM_SIZE);
+
+ // register for save state
+
+ state_save_register_global(state->cdp1869_prd);
+ state_save_register_global(state->cdp1869_pcb);
+ state_save_register_global_pointer(state->pageram, CIDELSA_PAGERAM_SIZE);
+ state_save_register_global_pointer(state->pcbram, CIDELSA_CHARRAM_SIZE);
+ state_save_register_global_pointer(state->charram, CIDELSA_CHARRAM_SIZE);
+}
+
+static VIDEO_START(draco)
+{
+ cidelsa_state *state = machine->driver_data;
+
+ // allocate memory
+
+ state->pageram = auto_malloc(DRACO_PAGERAM_SIZE);
+ state->pcbram = auto_malloc(CIDELSA_CHARRAM_SIZE);
+ state->charram = auto_malloc(CIDELSA_CHARRAM_SIZE);
+
+ // register for save state
+
+ state_save_register_global(state->cdp1869_prd);
+ state_save_register_global(state->cdp1869_pcb);
+ state_save_register_global_pointer(state->pageram, DRACO_PAGERAM_SIZE);
+ state_save_register_global_pointer(state->pcbram, CIDELSA_CHARRAM_SIZE);
+ state_save_register_global_pointer(state->charram, CIDELSA_CHARRAM_SIZE);
+}
+
+/* Video Update */
+
+static VIDEO_UPDATE( cidelsa )
+{
+ const device_config *cdp1869 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1869_VIDEO, CDP1869_TAG);
+
+ cdp1869_update(cdp1869, bitmap, cliprect);
+
+ return 0;
+}
+
+/* Machine Drivers */
+
+MACHINE_DRIVER_START( destryer_video )
+ MDRV_PALETTE_LENGTH(CDP1869_PALETTE_LENGTH)
+ MDRV_PALETTE_INIT(cdp1869)
+
+ MDRV_VIDEO_START(cidelsa)
+ MDRV_VIDEO_UPDATE(cidelsa)
+
+ MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
+ MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
+ MDRV_SCREEN_RAW_PARAMS(DESTRYER_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
+ MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.4, 0.044)
+
+ MDRV_DEVICE_ADD(CDP1869_TAG, CDP1869_VIDEO)
+ MDRV_DEVICE_CONFIG(destryer_cdp1869_intf)
+MACHINE_DRIVER_END
+
+MACHINE_DRIVER_START( altair_video )
+ MDRV_PALETTE_LENGTH(CDP1869_PALETTE_LENGTH)
+ MDRV_PALETTE_INIT(cdp1869)
+
+ MDRV_VIDEO_START(cidelsa)
+ MDRV_VIDEO_UPDATE(cidelsa)
+
+ MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
+ MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
+ MDRV_SCREEN_RAW_PARAMS(ALTAIR_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
+ MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.4, 0.044)
+
+ MDRV_DEVICE_ADD(CDP1869_TAG, CDP1869_VIDEO)
+ MDRV_DEVICE_CONFIG(altair_cdp1869_intf)
+MACHINE_DRIVER_END
+
+MACHINE_DRIVER_START( draco_video )
+ MDRV_PALETTE_LENGTH(CDP1869_PALETTE_LENGTH)
+ MDRV_PALETTE_INIT(cdp1869)
+
+ MDRV_VIDEO_START(draco)
+ MDRV_VIDEO_UPDATE(cidelsa)
+
+ MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
+ MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
+ MDRV_SCREEN_RAW_PARAMS(DRACO_CHR2, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
+ MDRV_SCREEN_DEFAULT_POSITION(1.226, 0.012, 1.360, 0.024)
+
+ MDRV_DEVICE_ADD(CDP1869_TAG, CDP1869_VIDEO)
+ MDRV_DEVICE_CONFIG(draco_cdp1869_intf)
+MACHINE_DRIVER_END