src/mess/video/cdp1861.c
| r2391 | r2392 | |
| 1 | 1 | #include "driver.h" |
| 2 | | #include "deprecat.h" |
| 3 | | #include "cpu/cdp1802/cdp1802.h" |
| 4 | | #include "video/cdp1861.h" |
| 2 | #include "cdp1861.h" |
| 5 | 3 | |
| 6 | | static bitmap_t *cdptmpbitmap; |
| 4 | #define CDP1861_CYCLES_DMA_START 2*8 |
| 5 | #define CDP1861_CYCLES_DMA_ACTIVE 8*8 |
| 6 | #define CDP1861_CYCLES_DMA_WAIT 6*8 |
| 7 | 7 | |
| 8 | | static emu_timer *cdp1861_int_timer; |
| 9 | | static emu_timer *cdp1861_efx_timer; |
| 10 | | static emu_timer *cdp1861_dma_timer; |
| 8 | typedef struct _cdp1861_t cdp1861_t; |
| 9 | struct _cdp1861_t |
| 10 | { |
| 11 | const cdp1861_interface *intf; |
| 11 | 12 | |
| 12 | | typedef struct |
| 13 | const device_config *screen; /* screen */ |
| 14 | bitmap_t *bitmap; /* bitmap */ |
| 15 | |
| 16 | int disp; /* display on */ |
| 17 | int dmaout; /* DMA request active */ |
| 18 | |
| 19 | /* timers */ |
| 20 | emu_timer *int_timer; /* interrupt timer */ |
| 21 | emu_timer *efx_timer; /* EFx timer */ |
| 22 | emu_timer *dma_timer; /* DMA timer */ |
| 23 | }; |
| 24 | |
| 25 | INLINE cdp1861_t *get_safe_token(const device_config *device) |
| 13 | 26 | { |
| 14 | | int disp; |
| 15 | | int dmaout; |
| 16 | | } CDP1861_VIDEO_CONFIG; |
| 27 | assert(device != NULL); |
| 28 | assert(device->token != NULL); |
| 17 | 29 | |
| 18 | | static CDP1861_VIDEO_CONFIG cdp1861; |
| 30 | return (cdp1861_t *)device->token; |
| 31 | } |
| 19 | 32 | |
| 20 | | int cdp1861_efx; |
| 21 | | |
| 22 | 33 | static TIMER_CALLBACK(cdp1861_int_tick) |
| 23 | 34 | { |
| 24 | | int scanline = video_screen_get_vpos(machine->primary_screen); |
| 35 | const device_config *device = ptr; |
| 36 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 25 | 37 | |
| 38 | int scanline = video_screen_get_vpos(cdp1861->screen); |
| 39 | |
| 26 | 40 | if (scanline == CDP1861_SCANLINE_INT_START) |
| 27 | 41 | { |
| 28 | | if (cdp1861.disp) |
| 42 | if (cdp1861->disp) |
| 29 | 43 | { |
| 30 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, HOLD_LINE); |
| 44 | cdp1861->intf->on_int_changed(device, HOLD_LINE); |
| 31 | 45 | } |
| 32 | 46 | |
| 33 | | timer_adjust_oneshot(cdp1861_int_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_INT_END, 0), 0); |
| 47 | timer_adjust_oneshot(cdp1861->int_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_INT_END, 0), 0); |
| 34 | 48 | } |
| 35 | 49 | else |
| 36 | 50 | { |
| 37 | | if (cdp1861.disp) |
| 51 | if (cdp1861->disp) |
| 38 | 52 | { |
| 39 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 53 | cdp1861->intf->on_int_changed(device, CLEAR_LINE); |
| 40 | 54 | } |
| 41 | 55 | |
| 42 | | timer_adjust_oneshot(cdp1861_int_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_INT_START, 0), 0); |
| 56 | timer_adjust_oneshot(cdp1861->int_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_INT_START, 0), 0); |
| 43 | 57 | } |
| 44 | 58 | } |
| 45 | 59 | |
| 46 | 60 | static TIMER_CALLBACK(cdp1861_efx_tick) |
| 47 | 61 | { |
| 48 | | int scanline = video_screen_get_vpos(machine->primary_screen); |
| 62 | const device_config *device = ptr; |
| 63 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 49 | 64 | |
| 65 | int scanline = video_screen_get_vpos(cdp1861->screen); |
| 66 | |
| 50 | 67 | switch (scanline) |
| 51 | 68 | { |
| 52 | 69 | case CDP1861_SCANLINE_EFX_TOP_START: |
| 53 | | cdp1861_efx = ASSERT_LINE; |
| 54 | | timer_adjust_oneshot(cdp1861_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_EFX_TOP_END, 0), 0); |
| 70 | cdp1861->intf->on_efx_changed(device, ASSERT_LINE); |
| 71 | timer_adjust_oneshot(cdp1861->efx_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_EFX_TOP_END, 0), 0); |
| 55 | 72 | break; |
| 56 | 73 | |
| 57 | 74 | case CDP1861_SCANLINE_EFX_TOP_END: |
| 58 | | cdp1861_efx = CLEAR_LINE; |
| 59 | | timer_adjust_oneshot(cdp1861_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_EFX_BOTTOM_START, 0), 0); |
| 75 | cdp1861->intf->on_efx_changed(device, CLEAR_LINE); |
| 76 | timer_adjust_oneshot(cdp1861->efx_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_EFX_BOTTOM_START, 0), 0); |
| 60 | 77 | break; |
| 61 | 78 | |
| 62 | 79 | case CDP1861_SCANLINE_EFX_BOTTOM_START: |
| 63 | | cdp1861_efx = ASSERT_LINE; |
| 64 | | timer_adjust_oneshot(cdp1861_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_EFX_BOTTOM_END, 0), 0); |
| 80 | cdp1861->intf->on_efx_changed(device, ASSERT_LINE); |
| 81 | timer_adjust_oneshot(cdp1861->efx_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_EFX_BOTTOM_END, 0), 0); |
| 65 | 82 | break; |
| 66 | 83 | |
| 67 | 84 | case CDP1861_SCANLINE_EFX_BOTTOM_END: |
| 68 | | cdp1861_efx = CLEAR_LINE; |
| 69 | | timer_adjust_oneshot(cdp1861_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_EFX_TOP_START, 0), 0); |
| 85 | cdp1861->intf->on_efx_changed(device, CLEAR_LINE); |
| 86 | timer_adjust_oneshot(cdp1861->efx_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_EFX_TOP_START, 0), 0); |
| 70 | 87 | break; |
| 71 | 88 | } |
| 72 | 89 | } |
| 73 | 90 | |
| 74 | 91 | static TIMER_CALLBACK(cdp1861_dma_tick) |
| 75 | 92 | { |
| 76 | | int scanline = video_screen_get_vpos(machine->primary_screen); |
| 93 | const device_config *device = ptr; |
| 94 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 77 | 95 | |
| 78 | | if (cdp1861.dmaout) |
| 96 | int scanline = video_screen_get_vpos(cdp1861->screen); |
| 97 | |
| 98 | if (cdp1861->dmaout) |
| 79 | 99 | { |
| 80 | | if (cdp1861.disp) |
| 100 | if (cdp1861->disp) |
| 81 | 101 | { |
| 82 | 102 | if (scanline >= CDP1861_SCANLINE_DISPLAY_START && scanline < CDP1861_SCANLINE_DISPLAY_END) |
| 83 | 103 | { |
| 84 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE); |
| 104 | cdp1861->intf->on_dmao_changed(device, CLEAR_LINE); |
| 85 | 105 | } |
| 86 | 106 | } |
| 87 | 107 | |
| 88 | | timer_adjust_oneshot(cdp1861_dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_WAIT, 0), 0); |
| 108 | timer_adjust_oneshot(cdp1861->dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_WAIT, 0), 0); |
| 89 | 109 | |
| 90 | | cdp1861.dmaout = 0; |
| 110 | cdp1861->dmaout = 0; |
| 91 | 111 | } |
| 92 | 112 | else |
| 93 | 113 | { |
| 94 | | if (cdp1861.disp) |
| 114 | if (cdp1861->disp) |
| 95 | 115 | { |
| 96 | 116 | if (scanline >= CDP1861_SCANLINE_DISPLAY_START && scanline < CDP1861_SCANLINE_DISPLAY_END) |
| 97 | 117 | { |
| 98 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, HOLD_LINE); |
| 118 | cdp1861->intf->on_dmao_changed(device, HOLD_LINE); |
| 99 | 119 | } |
| 100 | 120 | } |
| 101 | 121 | |
| 102 | | timer_adjust_oneshot(cdp1861_dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_ACTIVE, 0), 0); |
| 122 | timer_adjust_oneshot(cdp1861->dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_ACTIVE, 0), 0); |
| 103 | 123 | |
| 104 | | cdp1861.dmaout = 1; |
| 124 | cdp1861->dmaout = 1; |
| 105 | 125 | } |
| 106 | 126 | } |
| 107 | 127 | |
| 108 | | void cdp1861_dma_w(UINT8 data) |
| 128 | /* Display On/Off */ |
| 129 | |
| 130 | READ8_DEVICE_HANDLER( cdp1861_dispon_r ) |
| 109 | 131 | { |
| 110 | | int sx = video_screen_get_hpos(Machine->primary_screen) + 4; |
| 111 | | int y = video_screen_get_vpos(Machine->primary_screen); |
| 112 | | int x; |
| 132 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 113 | 133 | |
| 114 | | for (x = 0; x < 8; x++) |
| 115 | | { |
| 116 | | int color = (data & 0x80) >> 7; |
| 117 | | *BITMAP_ADDR16(cdptmpbitmap, y, sx + x) = color; |
| 118 | | data <<= 1; |
| 119 | | } |
| 134 | cdp1861->disp = 1; |
| 135 | |
| 136 | return 0xff; |
| 120 | 137 | } |
| 121 | 138 | |
| 122 | | MACHINE_RESET( cdp1861 ) |
| 139 | WRITE8_DEVICE_HANDLER( cdp1861_dispoff_w ) |
| 123 | 140 | { |
| 124 | | timer_adjust_oneshot(cdp1861_int_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_INT_START, 0), 0); |
| 125 | | timer_adjust_oneshot(cdp1861_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1861_SCANLINE_EFX_TOP_START, 0), 0); |
| 126 | | timer_adjust_oneshot(cdp1861_dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_START, 0), 0); |
| 141 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 127 | 142 | |
| 128 | | cdp1861.disp = 0; |
| 129 | | cdp1861.dmaout = 0; |
| 143 | cdp1861->disp = 0; |
| 130 | 144 | |
| 131 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 132 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE); |
| 133 | | cdp1861_efx = CLEAR_LINE; |
| 145 | cdp1861->intf->on_int_changed(device, CLEAR_LINE); |
| 146 | cdp1861->intf->on_dmao_changed(device, CLEAR_LINE); |
| 134 | 147 | } |
| 135 | 148 | |
| 136 | | READ8_HANDLER( cdp1861_dispon_r ) |
| 149 | /* DMA Write */ |
| 150 | |
| 151 | void cdp1861_dma_w(const device_config *device, UINT8 data) |
| 137 | 152 | { |
| 138 | | cdp1861.disp = 1; |
| 153 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 139 | 154 | |
| 140 | | return 0xff; |
| 155 | int sx = video_screen_get_hpos(cdp1861->screen) + 4; |
| 156 | int y = video_screen_get_vpos(cdp1861->screen); |
| 157 | int x; |
| 158 | |
| 159 | for (x = 0; x < 8; x++) |
| 160 | { |
| 161 | int color = BIT(data, 7); |
| 162 | *BITMAP_ADDR16(cdp1861->bitmap, y, sx + x) = color; |
| 163 | data <<= 1; |
| 164 | } |
| 141 | 165 | } |
| 142 | 166 | |
| 143 | | WRITE8_HANDLER( cdp1861_dispoff_w ) |
| 167 | /* Screen Update */ |
| 168 | |
| 169 | void cdp1861_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 144 | 170 | { |
| 145 | | cdp1861.disp = 0; |
| 146 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 147 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE); |
| 171 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 172 | |
| 173 | if (cdp1861->disp) |
| 174 | { |
| 175 | copybitmap(bitmap, cdp1861->bitmap, 0, 0, 0, 0, cliprect); |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | fillbitmap(bitmap, 0, cliprect); |
| 180 | } |
| 148 | 181 | } |
| 149 | 182 | |
| 150 | | VIDEO_START( cdp1861 ) |
| 183 | /* Device Interface */ |
| 184 | |
| 185 | static DEVICE_START( cdp1861 ) |
| 151 | 186 | { |
| 152 | | const device_config *screen = video_screen_first(machine->config); |
| 153 | | int width = video_screen_get_width(screen); |
| 154 | | int height = video_screen_get_height(screen); |
| 187 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 188 | char unique_tag[30]; |
| 155 | 189 | |
| 156 | | cdp1861_int_timer = timer_alloc(cdp1861_int_tick, NULL); |
| 157 | | cdp1861_efx_timer = timer_alloc(cdp1861_efx_tick, NULL); |
| 158 | | cdp1861_dma_timer = timer_alloc(cdp1861_dma_tick, NULL); |
| 190 | /* validate arguments */ |
| 191 | assert(device != NULL); |
| 192 | assert(device->tag != NULL); |
| 193 | assert(strlen(device->tag) < 20); |
| 159 | 194 | |
| 195 | cdp1861->intf = device->static_config; |
| 196 | |
| 197 | assert(cdp1861->intf != NULL); |
| 198 | assert(cdp1861->intf->on_int_changed != NULL); |
| 199 | assert(cdp1861->intf->on_dmao_changed != NULL); |
| 200 | assert(cdp1861->intf->on_efx_changed != NULL); |
| 201 | |
| 202 | /* get the screen device */ |
| 203 | cdp1861->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, cdp1861->intf->screen_tag); |
| 204 | assert(cdp1861->screen != NULL); |
| 205 | |
| 160 | 206 | /* allocate the temporary bitmap */ |
| 161 | | cdptmpbitmap = auto_bitmap_alloc(width, height, video_screen_get_format(screen)); |
| 207 | cdp1861->bitmap = auto_bitmap_alloc(video_screen_get_width(cdp1861->screen), video_screen_get_height(cdp1861->screen), video_screen_get_format(cdp1861->screen)); |
| 162 | 208 | |
| 163 | | /* ensure the contents of the bitmap are saved */ |
| 164 | | state_save_register_bitmap("video", 0, "cdptmpbitmap", cdptmpbitmap); |
| 209 | /* create the timers */ |
| 210 | cdp1861->int_timer = timer_alloc(cdp1861_int_tick, (void *)device); |
| 211 | cdp1861->efx_timer = timer_alloc(cdp1861_efx_tick, (void *)device); |
| 212 | cdp1861->dma_timer = timer_alloc(cdp1861_dma_tick, (void *)device); |
| 165 | 213 | |
| 166 | | state_save_register_global(cdp1861.disp); |
| 167 | | state_save_register_global(cdp1861.dmaout); |
| 214 | /* register for state saving */ |
| 215 | state_save_combine_module_and_tag(unique_tag, "CDP1861", device->tag); |
| 216 | |
| 217 | state_save_register_item(unique_tag, 0, cdp1861->disp); |
| 218 | state_save_register_item(unique_tag, 0, cdp1861->dmaout); |
| 219 | state_save_register_bitmap(unique_tag, 0, "cdp1861->bitmap", cdp1861->bitmap); |
| 168 | 220 | } |
| 169 | 221 | |
| 170 | | VIDEO_UPDATE( cdp1861 ) |
| 222 | static DEVICE_RESET( cdp1861 ) |
| 171 | 223 | { |
| 172 | | if (cdp1861.disp) |
| 224 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 225 | |
| 226 | timer_adjust_oneshot(cdp1861->int_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_INT_START, 0), 0); |
| 227 | timer_adjust_oneshot(cdp1861->efx_timer, video_screen_get_time_until_pos(cdp1861->screen, CDP1861_SCANLINE_EFX_TOP_START, 0), 0); |
| 228 | timer_adjust_oneshot(cdp1861->dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_START, 0), 0); |
| 229 | |
| 230 | cdp1861->disp = 0; |
| 231 | cdp1861->dmaout = 0; |
| 232 | |
| 233 | cdp1861->intf->on_int_changed(device, CLEAR_LINE); |
| 234 | cdp1861->intf->on_dmao_changed(device, CLEAR_LINE); |
| 235 | cdp1861->intf->on_efx_changed(device, CLEAR_LINE); |
| 236 | } |
| 237 | |
| 238 | static DEVICE_SET_INFO( cdp1861 ) |
| 239 | { |
| 240 | switch (state) |
| 173 | 241 | { |
| 174 | | copybitmap(bitmap, cdptmpbitmap, 0, 0, 0, 0, cliprect); |
| 242 | /* no parameters to set */ |
| 175 | 243 | } |
| 176 | | else |
| 244 | } |
| 245 | |
| 246 | DEVICE_GET_INFO( cdp1861 ) |
| 247 | { |
| 248 | switch (state) |
| 177 | 249 | { |
| 178 | | fillbitmap(bitmap, get_black_pen(screen->machine), cliprect); |
| 250 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 251 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1861_t); break; |
| 252 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 253 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 254 | |
| 255 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 256 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(cdp1861); break; |
| 257 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1861); break; |
| 258 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 259 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cdp1861); break; |
| 260 | |
| 261 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 262 | case DEVINFO_STR_NAME: info->s = "RCA CDP1861"; break; |
| 263 | case DEVINFO_STR_FAMILY: info->s = "RCA CDP1861"; break; |
| 264 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 265 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 266 | case DEVINFO_STR_CREDITS: info->s = "Copyright MESS Team"; break; |
| 179 | 267 | } |
| 180 | | |
| 181 | | return 0; |
| 182 | 268 | } |
src/mess/drivers/vip.c
| r2391 | r2392 | |
| 24 | 24 | |
| 25 | 25 | #define XTAL XTAL_3_52128MHz |
| 26 | 26 | |
| 27 | | extern int cdp1861_efx; |
| 27 | #define SCREEN_TAG "main" |
| 28 | #define CDP1861_TAG "cdp1861" |
| 28 | 29 | |
| 29 | 30 | /* Read/Write Handlers */ |
| 30 | 31 | |
| r2391 | r2392 | |
| 49 | 50 | ADDRESS_MAP_END |
| 50 | 51 | |
| 51 | 52 | static ADDRESS_MAP_START( vip_io_map, ADDRESS_SPACE_IO, 8 ) |
| 52 | | AM_RANGE(0x01, 0x01) AM_READWRITE(cdp1861_dispon_r, cdp1861_dispoff_w) |
| 53 | AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1861, CDP1861_TAG, cdp1861_dispon_r, cdp1861_dispoff_w) |
| 53 | 54 | AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w) |
| 54 | 55 | // AM_RANGE(0x03, 0x03) AM_READWRITE(io_r, io_w) |
| 55 | 56 | AM_RANGE(0x04, 0x04) AM_WRITE(bankswitch_w) |
| r2391 | r2392 | |
| 80 | 81 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Run/Reset") PORT_CODE(KEYCODE_R) PORT_TOGGLE |
| 81 | 82 | INPUT_PORTS_END |
| 82 | 83 | |
| 84 | /* Video */ |
| 85 | |
| 86 | static int cdp1861_efx; |
| 87 | |
| 88 | static CDP1861_ON_INT_CHANGED( vip_int_w ) |
| 89 | { |
| 90 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_INT, level); |
| 91 | } |
| 92 | |
| 93 | static CDP1861_ON_DMAO_CHANGED( vip_dmao_w ) |
| 94 | { |
| 95 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, level); |
| 96 | } |
| 97 | |
| 98 | static CDP1861_ON_EFX_CHANGED( vip_efx_w ) |
| 99 | { |
| 100 | cdp1861_efx = level; |
| 101 | } |
| 102 | |
| 103 | static void vip_dma_w(UINT8 data) |
| 104 | { |
| 105 | const device_config *cdp1861 = device_list_find_by_tag(Machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 106 | |
| 107 | cdp1861_dma_w(cdp1861, data); |
| 108 | } |
| 109 | |
| 110 | static const cdp1861_interface vip_cdp1861_intf = |
| 111 | { |
| 112 | SCREEN_TAG, |
| 113 | XTAL_3_52128MHz, |
| 114 | vip_int_w, |
| 115 | vip_dmao_w, |
| 116 | vip_efx_w |
| 117 | }; |
| 118 | |
| 119 | static VIDEO_UPDATE( vip ) |
| 120 | { |
| 121 | const device_config *cdp1861 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 122 | |
| 123 | cdp1861_update(cdp1861, bitmap, cliprect); |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 83 | 128 | /* CDP1802 Configuration */ |
| 84 | 129 | |
| 85 | 130 | static int vip_run; |
| r2391 | r2392 | |
| 102 | 147 | { |
| 103 | 148 | if (!vip_reset) |
| 104 | 149 | { |
| 105 | | machine_reset_cdp1861(Machine); |
| 150 | const device_config *cdp1861 = device_list_find_by_tag(Machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 151 | cdp1861->reset(cdp1861); |
| 106 | 152 | vip_reset = 1; |
| 107 | 153 | vip_run = 0; |
| 108 | 154 | } |
| r2391 | r2392 | |
| 136 | 182 | NULL, |
| 137 | 183 | vip_q_w, |
| 138 | 184 | NULL, |
| 139 | | cdp1861_dma_w |
| 185 | vip_dma_w |
| 140 | 186 | }; |
| 141 | 187 | |
| 142 | | PALETTE_INIT( vip ) |
| 143 | | { |
| 144 | | palette_set_color(machine,0,RGB_BLACK); /* black */ |
| 145 | | palette_set_color(machine,1,RGB_WHITE); /* white */ |
| 146 | | palette_set_color(machine,2,RGB_WHITE); /* white */ |
| 147 | | palette_set_color(machine,3,RGB_BLACK); /* black */ |
| 148 | | } |
| 149 | | |
| 150 | 188 | /* Machine Initialization */ |
| 151 | 189 | |
| 152 | 190 | static MACHINE_START( vip ) |
| r2391 | r2392 | |
| 177 | 215 | |
| 178 | 216 | static MACHINE_RESET( vip ) |
| 179 | 217 | { |
| 180 | | MACHINE_RESET_CALL(cdp1861); |
| 218 | const device_config *cdp1861 = device_list_find_by_tag(machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 219 | cdp1861->reset(cdp1861); |
| 181 | 220 | memory_set_bank(1, 1); |
| 182 | 221 | } |
| 183 | 222 | |
| r2391 | r2392 | |
| 194 | 233 | MDRV_MACHINE_RESET(vip) |
| 195 | 234 | |
| 196 | 235 | /* video hardware */ |
| 197 | | MDRV_SCREEN_ADD("main", RASTER) |
| 236 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 198 | 237 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 199 | 238 | MDRV_SCREEN_RAW_PARAMS(XTAL/2, CDP1861_SCREEN_WIDTH, CDP1861_HBLANK_END, CDP1861_HBLANK_START, CDP1861_TOTAL_SCANLINES, CDP1861_SCANLINE_VBLANK_END, CDP1861_SCANLINE_VBLANK_START) |
| 200 | 239 | |
| 201 | | MDRV_PALETTE_LENGTH(4) |
| 202 | | MDRV_PALETTE_INIT(vip) |
| 203 | | MDRV_VIDEO_START(cdp1861) |
| 204 | | MDRV_VIDEO_UPDATE(cdp1861) |
| 240 | MDRV_PALETTE_LENGTH(2) |
| 241 | MDRV_PALETTE_INIT(black_and_white) |
| 242 | MDRV_VIDEO_UPDATE(vip) |
| 205 | 243 | |
| 244 | MDRV_DEVICE_ADD(CDP1861_TAG, CDP1861) |
| 245 | MDRV_DEVICE_CONFIG(vip_cdp1861_intf) |
| 246 | |
| 206 | 247 | /* sound hardware */ |
| 207 | 248 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 208 | 249 | MDRV_SOUND_ADD(BEEP, 0) |
src/mess/drivers/studio2.c
| r2391 | r2392 | |
| 108 | 108 | #include "sound/beep.h" |
| 109 | 109 | #include "sound/discrete.h" |
| 110 | 110 | |
| 111 | | extern int cdp1861_efx; |
| 112 | | extern int cdp1864_efx; |
| 111 | #define SCREEN_TAG "main" |
| 112 | #define CDP1861_TAG "cdp1861" |
| 113 | 113 | |
| 114 | 114 | /* Read/Write Handlers */ |
| 115 | 115 | |
| r2391 | r2392 | |
| 128 | 128 | ADDRESS_MAP_END |
| 129 | 129 | |
| 130 | 130 | static ADDRESS_MAP_START( studio2_io_map, ADDRESS_SPACE_IO, 8 ) |
| 131 | | AM_RANGE(0x01, 0x01) AM_READ(cdp1861_dispon_r) |
| 131 | AM_RANGE(0x01, 0x01) AM_DEVREAD(CDP1861, CDP1861_TAG, cdp1861_dispon_r) |
| 132 | 132 | AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w) |
| 133 | 133 | ADDRESS_MAP_END |
| 134 | 134 | |
| r2391 | r2392 | |
| 175 | 175 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Player 2/Right 9") PORT_CODE(KEYCODE_3_PAD) |
| 176 | 176 | INPUT_PORTS_END |
| 177 | 177 | |
| 178 | /* Video */ |
| 179 | |
| 180 | static int cdp1861_efx; |
| 181 | extern int cdp1864_efx; |
| 182 | |
| 183 | static CDP1861_ON_INT_CHANGED( studio2_int_w ) |
| 184 | { |
| 185 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_INT, level); |
| 186 | } |
| 187 | |
| 188 | static CDP1861_ON_DMAO_CHANGED( studio2_dmao_w ) |
| 189 | { |
| 190 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, level); |
| 191 | } |
| 192 | |
| 193 | static CDP1861_ON_EFX_CHANGED( studio2_efx_w ) |
| 194 | { |
| 195 | cdp1861_efx = level; |
| 196 | } |
| 197 | |
| 198 | static void studio2_dma_w(UINT8 data) |
| 199 | { |
| 200 | const device_config *cdp1861 = device_list_find_by_tag(Machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 201 | |
| 202 | cdp1861_dma_w(cdp1861, data); |
| 203 | } |
| 204 | |
| 205 | static const cdp1861_interface studio2_cdp1861_intf = |
| 206 | { |
| 207 | SCREEN_TAG, |
| 208 | XTAL_3_52128MHz, |
| 209 | studio2_int_w, |
| 210 | studio2_dmao_w, |
| 211 | studio2_efx_w |
| 212 | }; |
| 213 | |
| 214 | static VIDEO_UPDATE( studio2 ) |
| 215 | { |
| 216 | const device_config *cdp1861 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 217 | |
| 218 | cdp1861_update(cdp1861, bitmap, cliprect); |
| 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 178 | 223 | /* CDP1802 Configuration */ |
| 179 | 224 | |
| 180 | 225 | static int cdp1802_mode = CDP1802_MODE_RESET; |
| r2391 | r2392 | |
| 208 | 253 | NULL, |
| 209 | 254 | studio2_q_w, |
| 210 | 255 | NULL, |
| 211 | | cdp1861_dma_w |
| 256 | studio2_dma_w |
| 212 | 257 | }; |
| 213 | 258 | |
| 214 | 259 | static UINT8 mpt02_ef_r(void) |
| r2391 | r2392 | |
| 243 | 288 | |
| 244 | 289 | static MACHINE_RESET( studio2 ) |
| 245 | 290 | { |
| 246 | | MACHINE_RESET_CALL(cdp1861); |
| 291 | const device_config *cdp1861 = device_list_find_by_tag(machine->config->devicelist, CDP1861, CDP1861_TAG); |
| 292 | cdp1861->reset(cdp1861); |
| 247 | 293 | } |
| 248 | 294 | |
| 249 | 295 | static MACHINE_RESET( mpt02 ) |
| r2391 | r2392 | |
| 269 | 315 | |
| 270 | 316 | // video hardware |
| 271 | 317 | |
| 272 | | MDRV_SCREEN_ADD("main", RASTER) |
| 318 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 273 | 319 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 274 | 320 | MDRV_SCREEN_RAW_PARAMS(3579545/2, CDP1861_SCREEN_WIDTH, CDP1861_HBLANK_END, CDP1861_HBLANK_START, CDP1861_TOTAL_SCANLINES, CDP1861_SCANLINE_VBLANK_END, CDP1861_SCANLINE_VBLANK_START) |
| 275 | 321 | |
| 276 | 322 | MDRV_PALETTE_LENGTH(2) |
| 277 | 323 | MDRV_PALETTE_INIT(black_and_white) |
| 278 | | MDRV_VIDEO_START(cdp1861) |
| 279 | | MDRV_VIDEO_UPDATE(cdp1861) |
| 324 | MDRV_VIDEO_UPDATE(studio2) |
| 280 | 325 | |
| 326 | MDRV_DEVICE_ADD(CDP1861_TAG, CDP1861) |
| 327 | MDRV_DEVICE_CONFIG(studio2_cdp1861_intf) |
| 328 | |
| 281 | 329 | // sound hardware |
| 282 | 330 | |
| 283 | 331 | MDRV_SPEAKER_STANDARD_MONO("mono") |