src/mess/video/cdp1864.c
| r2404 | r2405 | |
| 1 | 1 | #include "driver.h" |
| 2 | #include "sndintrf.h" |
| 3 | #include "streams.h" |
| 2 | 4 | #include "cpu/cdp1802/cdp1802.h" |
| 3 | 5 | #include "sound/beep.h" |
| 4 | 6 | #include "video/cdp1864.h" |
| 5 | 7 | |
| 6 | | static bitmap_t *cdptmpbitmap; |
| 8 | /* |
| 7 | 9 | |
| 8 | | static emu_timer *cdp1864_int_timer; |
| 9 | | static emu_timer *cdp1864_efx_timer; |
| 10 | | static emu_timer *cdp1864_dma_timer; |
| 10 | TODO: |
| 11 | 11 | |
| 12 | | typedef struct |
| 12 | - connect to sound system when possible |
| 13 | |
| 14 | */ |
| 15 | |
| 16 | #define CDP1864_DEFAULT_LATCH 0x35 |
| 17 | |
| 18 | #define CDP1864_CYCLES_DMA_START 2*8 |
| 19 | #define CDP1864_CYCLES_DMA_ACTIVE 8*8 |
| 20 | #define CDP1864_CYCLES_DMA_WAIT 6*8 |
| 21 | |
| 22 | typedef struct _cdp1864_t cdp1864_t; |
| 23 | struct _cdp1864_t |
| 13 | 24 | { |
| 14 | | int disp; |
| 15 | | int dmaout; |
| 16 | | int dmaptr; |
| 17 | | int audio; |
| 18 | | int bgcolor; |
| 19 | | int latch; |
| 20 | | int (*colorram_r)(UINT16 addr); |
| 21 | | } CDP1864_VIDEO_CONFIG; |
| 25 | const cdp1864_interface *intf; /* interface */ |
| 22 | 26 | |
| 23 | | static CDP1864_VIDEO_CONFIG cdp1864; |
| 27 | const device_config *screen; /* screen */ |
| 28 | bitmap_t *bitmap; /* bitmap */ |
| 29 | sound_stream *stream; /* sound output */ |
| 24 | 30 | |
| 25 | | static const int cdp1864_bgcolseq[] = { 2, 0, 1, 4 }; |
| 31 | /* video state */ |
| 32 | int disp; /* display on */ |
| 33 | int dmaout; /* DMA request active */ |
| 34 | int dmaptr; /* DMA pointer */ |
| 35 | int bgcolor; /* background color */ |
| 26 | 36 | |
| 27 | | int cdp1864_efx; |
| 37 | /* sound state */ |
| 38 | int audio; /* audio on */ |
| 39 | int latch; /* sound latch */ |
| 40 | INT16 signal; /* current signal */ |
| 41 | int incr; /* initial wave state */ |
| 28 | 42 | |
| 43 | /* timers */ |
| 44 | emu_timer *int_timer; /* interrupt timer */ |
| 45 | emu_timer *efx_timer; /* EFx timer */ |
| 46 | emu_timer *dma_timer; /* DMA timer */ |
| 47 | }; |
| 48 | |
| 49 | static const int CDP1864_BACKGROUND_COLOR_SEQUENCE[] = { 2, 0, 1, 4 }; |
| 50 | |
| 51 | INLINE cdp1864_t *get_safe_token(const device_config *device) |
| 52 | { |
| 53 | assert(device != NULL); |
| 54 | assert(device->token != NULL); |
| 55 | |
| 56 | return (cdp1864_t *)device->token; |
| 57 | } |
| 58 | |
| 59 | /* Timer Callbacks */ |
| 60 | |
| 29 | 61 | static TIMER_CALLBACK(cdp1864_int_tick) |
| 30 | 62 | { |
| 31 | | int scanline = video_screen_get_vpos(machine->primary_screen); |
| 63 | const device_config *device = ptr; |
| 64 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 32 | 65 | |
| 66 | int scanline = video_screen_get_vpos(cdp1864->screen); |
| 67 | |
| 33 | 68 | if (scanline == CDP1864_SCANLINE_INT_START) |
| 34 | 69 | { |
| 35 | | if (cdp1864.disp) |
| 70 | if (cdp1864->disp) |
| 36 | 71 | { |
| 37 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, HOLD_LINE); |
| 38 | | cdp1864.dmaptr = 0; |
| 72 | cdp1864->intf->on_int_changed(device, HOLD_LINE); |
| 73 | cdp1864->dmaptr = 0; |
| 39 | 74 | } |
| 40 | 75 | |
| 41 | | timer_adjust_oneshot(cdp1864_int_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_INT_END, 0), 0); |
| 76 | timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_END, 0), 0); |
| 42 | 77 | } |
| 43 | 78 | else |
| 44 | 79 | { |
| 45 | | if (cdp1864.disp) |
| 80 | if (cdp1864->disp) |
| 46 | 81 | { |
| 47 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 82 | cdp1864->intf->on_int_changed(device, CLEAR_LINE); |
| 48 | 83 | } |
| 49 | 84 | |
| 50 | | timer_adjust_oneshot(cdp1864_int_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_INT_START, 0), 0); |
| 85 | timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0); |
| 51 | 86 | } |
| 52 | 87 | } |
| 53 | 88 | |
| 54 | 89 | static TIMER_CALLBACK(cdp1864_efx_tick) |
| 55 | 90 | { |
| 56 | | int scanline = video_screen_get_vpos(machine->primary_screen); |
| 91 | const device_config *device = ptr; |
| 92 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 57 | 93 | |
| 94 | int scanline = video_screen_get_vpos(cdp1864->screen); |
| 95 | |
| 58 | 96 | switch (scanline) |
| 59 | 97 | { |
| 60 | 98 | case CDP1864_SCANLINE_EFX_TOP_START: |
| 61 | | cdp1864_efx = ASSERT_LINE; |
| 62 | | timer_adjust_oneshot(cdp1864_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_EFX_TOP_END, 0), 0); |
| 99 | cdp1864->intf->on_efx_changed(device, ASSERT_LINE); |
| 100 | timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_END, 0), 0); |
| 63 | 101 | break; |
| 64 | 102 | |
| 65 | 103 | case CDP1864_SCANLINE_EFX_TOP_END: |
| 66 | | cdp1864_efx = CLEAR_LINE; |
| 67 | | timer_adjust_oneshot(cdp1864_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0); |
| 104 | cdp1864->intf->on_efx_changed(device, CLEAR_LINE); |
| 105 | timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0); |
| 68 | 106 | break; |
| 69 | 107 | |
| 70 | 108 | case CDP1864_SCANLINE_EFX_BOTTOM_START: |
| 71 | | cdp1864_efx = ASSERT_LINE; |
| 72 | | timer_adjust_oneshot(cdp1864_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0); |
| 109 | cdp1864->intf->on_efx_changed(device, ASSERT_LINE); |
| 110 | timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0); |
| 73 | 111 | break; |
| 74 | 112 | |
| 75 | 113 | case CDP1864_SCANLINE_EFX_BOTTOM_END: |
| 76 | | cdp1864_efx = CLEAR_LINE; |
| 77 | | timer_adjust_oneshot(cdp1864_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0); |
| 114 | cdp1864->intf->on_efx_changed(device, CLEAR_LINE); |
| 115 | timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0); |
| 78 | 116 | break; |
| 79 | 117 | } |
| 80 | 118 | } |
| 81 | 119 | |
| 82 | 120 | static TIMER_CALLBACK(cdp1864_dma_tick) |
| 83 | 121 | { |
| 84 | | int scanline = video_screen_get_vpos(machine->primary_screen); |
| 122 | const device_config *device = ptr; |
| 123 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 85 | 124 | |
| 86 | | if (cdp1864.dmaout) |
| 125 | int scanline = video_screen_get_vpos(cdp1864->screen); |
| 126 | |
| 127 | if (cdp1864->dmaout) |
| 87 | 128 | { |
| 88 | | if (cdp1864.disp) |
| 129 | if (cdp1864->disp) |
| 89 | 130 | { |
| 90 | 131 | if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END) |
| 91 | 132 | { |
| 92 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE); |
| 133 | cdp1864->intf->on_dmao_changed(device, CLEAR_LINE); |
| 93 | 134 | } |
| 94 | 135 | } |
| 95 | 136 | |
| 96 | | timer_adjust_oneshot(cdp1864_dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_WAIT, 0), 0); |
| 137 | timer_adjust_oneshot(cdp1864->dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_WAIT, 0), 0); |
| 97 | 138 | |
| 98 | | cdp1864.dmaout = 0; |
| 139 | cdp1864->dmaout = 0; |
| 99 | 140 | } |
| 100 | 141 | else |
| 101 | 142 | { |
| 102 | | if (cdp1864.disp) |
| 143 | if (cdp1864->disp) |
| 103 | 144 | { |
| 104 | 145 | if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END) |
| 105 | 146 | { |
| 106 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, HOLD_LINE); |
| 147 | cdp1864->intf->on_dmao_changed(device, HOLD_LINE); |
| 107 | 148 | } |
| 108 | 149 | } |
| 109 | 150 | |
| 110 | | timer_adjust_oneshot(cdp1864_dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_ACTIVE, 0), 0); |
| 151 | timer_adjust_oneshot(cdp1864->dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_ACTIVE, 0), 0); |
| 111 | 152 | |
| 112 | | cdp1864.dmaout = 1; |
| 153 | cdp1864->dmaout = 1; |
| 113 | 154 | } |
| 114 | 155 | } |
| 115 | 156 | |
| 116 | | CDP1802_DMA_WRITE( cdp1864_dma_w ) |
| 157 | |
| 158 | /* Palette Initialization */ |
| 159 | |
| 160 | static void cdp1864_init_palette(running_machine *machine, double res_r, double res_g, double res_b, double res_bkg) |
| 117 | 161 | { |
| 118 | | int sx = video_screen_get_hpos(machine->primary_screen) + 4; |
| 119 | | int y = video_screen_get_vpos(machine->primary_screen); |
| 120 | | int x; |
| 162 | int i, r, g, b, luma; |
| 121 | 163 | |
| 122 | | for (x = 0; x < 8; x++) |
| 164 | double res_total = res_r + res_g + res_b; |
| 165 | |
| 166 | int weight_r = (res_r / res_total) * 100; |
| 167 | int weight_g = (res_g / res_total) * 100; |
| 168 | int weight_b = (res_b / res_total) * 100; |
| 169 | |
| 170 | for (i = 0; i < 8; i++) |
| 123 | 171 | { |
| 124 | | int color = cdp1864_bgcolseq[cdp1864.bgcolor]; |
| 172 | luma = (i & 4) ? weight_r : 0; |
| 173 | luma += (i & 1) ? weight_g : 0; |
| 174 | luma += (i & 2) ? weight_b : 0; |
| 125 | 175 | |
| 126 | | if (data & 0x80) |
| 127 | | { |
| 128 | | color = cdp1864.colorram_r(cdp1864.dmaptr); |
| 129 | | } |
| 176 | r = (i & 4) ? luma : 0; |
| 177 | g = (i & 1) ? luma : 0; |
| 178 | b = (i & 2) ? luma : 0; |
| 130 | 179 | |
| 131 | | *BITMAP_ADDR16(cdptmpbitmap, y, sx + x) = color; |
| 180 | luma = (luma * 0xff) / 100; |
| 132 | 181 | |
| 133 | | data <<= 1; |
| 182 | palette_set_color_rgb( machine, i, r, g, b ); |
| 134 | 183 | } |
| 135 | | |
| 136 | | cdp1864.dmaptr++; |
| 137 | 184 | } |
| 138 | 185 | |
| 139 | | WRITE8_HANDLER( cdp1864_step_bgcolor_w ) |
| 186 | /* Audio Output Enable */ |
| 187 | |
| 188 | void cdp1864_aoe_w(const device_config *device, int level) |
| 140 | 189 | { |
| 141 | | cdp1864.disp = 1; |
| 142 | | if (++cdp1864.bgcolor > 3) cdp1864.bgcolor = 0; |
| 190 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 191 | |
| 192 | if (level == 0) |
| 193 | { |
| 194 | cdp1864->latch = CDP1864_DEFAULT_LATCH; |
| 195 | } |
| 196 | |
| 197 | cdp1864->audio = level; |
| 198 | |
| 199 | beep_set_state(0, level); // TODO: remove this |
| 143 | 200 | } |
| 144 | 201 | |
| 145 | | WRITE8_HANDLER( cdp1864_tone_latch_w ) |
| 202 | /* Display On/Off */ |
| 203 | |
| 204 | READ8_DEVICE_HANDLER( cdp1864_dispon_r ) |
| 146 | 205 | { |
| 147 | | cdp1864.latch = data; |
| 148 | | beep_set_frequency(0, CDP1864_CLK_FREQ / 8 / 4 / (data + 1) / 2); |
| 206 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 207 | |
| 208 | cdp1864->disp = 1; |
| 209 | |
| 210 | return 0xff; |
| 149 | 211 | } |
| 150 | 212 | |
| 151 | | void cdp1864_audio_output_enable(int value) |
| 213 | READ8_DEVICE_HANDLER( cdp1864_dispoff_r ) |
| 152 | 214 | { |
| 153 | | if (value == 0) |
| 154 | | { |
| 155 | | cdp1864.latch = CDP1864_DEFAULT_LATCH; |
| 156 | | } |
| 215 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 157 | 216 | |
| 158 | | cdp1864.audio = value; |
| 217 | cdp1864->disp = 0; |
| 159 | 218 | |
| 160 | | beep_set_state(0, value); |
| 219 | cdp1864->intf->on_int_changed(device, CLEAR_LINE); |
| 220 | cdp1864->intf->on_dmao_changed(device, CLEAR_LINE); |
| 221 | |
| 222 | return 0xff; |
| 161 | 223 | } |
| 162 | 224 | |
| 163 | | READ8_HANDLER( cdp1864_dispon_r ) |
| 225 | /* Step Background Color */ |
| 226 | |
| 227 | WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w ) |
| 164 | 228 | { |
| 165 | | cdp1864.disp = 1; |
| 229 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 166 | 230 | |
| 167 | | return 0xff; |
| 231 | cdp1864->disp = 1; |
| 232 | |
| 233 | if (++cdp1864->bgcolor > 3) cdp1864->bgcolor = 0; |
| 168 | 234 | } |
| 169 | 235 | |
| 170 | | READ8_HANDLER( cdp1864_dispoff_r ) |
| 236 | /* Load Tone Latch */ |
| 237 | |
| 238 | WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w ) |
| 171 | 239 | { |
| 172 | | cdp1864.disp = 0; |
| 173 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 174 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE); |
| 240 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 175 | 241 | |
| 176 | | return 0xff; |
| 242 | cdp1864->latch = data; |
| 243 | beep_set_frequency(0, CDP1864_CLK_FREQ / 8 / 4 / (data + 1) / 2); // TODO: remove this |
| 177 | 244 | } |
| 178 | 245 | |
| 179 | | MACHINE_RESET( cdp1864 ) |
| 246 | /* DMA Write */ |
| 247 | |
| 248 | void cdp1864_dma_w(const device_config *device, UINT8 data) |
| 180 | 249 | { |
| 181 | | timer_adjust_oneshot(cdp1864_int_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_INT_START, 0), 0); |
| 182 | | timer_adjust_oneshot(cdp1864_efx_timer, video_screen_get_time_until_pos(machine->primary_screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0); |
| 183 | | timer_adjust_oneshot(cdp1864_dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_START, 0), 0); |
| 250 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 184 | 251 | |
| 185 | | cdp1864.disp = 0; |
| 186 | | cdp1864.dmaout = 0; |
| 187 | | cdp1864.dmaptr = 0; |
| 188 | | cdp1864.bgcolor = 0; |
| 252 | int sx = video_screen_get_hpos(cdp1864->screen) + 4; |
| 253 | int y = video_screen_get_vpos(cdp1864->screen); |
| 254 | int x; |
| 189 | 255 | |
| 190 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 191 | | cpunum_set_input_line(machine, 0, CDP1802_INPUT_LINE_DMAOUT, CLEAR_LINE); |
| 192 | | cdp1864_efx = CLEAR_LINE; |
| 256 | for (x = 0; x < 8; x++) |
| 257 | { |
| 258 | int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor]; |
| 193 | 259 | |
| 194 | | cdp1864_audio_output_enable(0); |
| 260 | if (data & 0x80) |
| 261 | { |
| 262 | color = cdp1864->intf->color_ram_r(device, cdp1864->dmaptr); |
| 263 | } |
| 264 | |
| 265 | *BITMAP_ADDR16(cdp1864->bitmap, y, sx + x) = color; |
| 266 | |
| 267 | data <<= 1; |
| 268 | } |
| 269 | |
| 270 | cdp1864->dmaptr++; |
| 195 | 271 | } |
| 196 | 272 | |
| 197 | | VIDEO_START( cdp1864 ) |
| 273 | /* Sound Update */ |
| 274 | |
| 275 | #ifdef UNUSED_FUNCTION |
| 276 | static void cdp1864_sound_update(const device_config *device, stream_sample_t **inputs, stream_sample_t **_buffer, int length) |
| 198 | 277 | { |
| 199 | | const device_config *screen = video_screen_first(machine->config); |
| 200 | | int width = video_screen_get_width(screen); |
| 201 | | int height = video_screen_get_height(screen); |
| 278 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 202 | 279 | |
| 203 | | cdp1864_int_timer = timer_alloc(cdp1864_int_tick, NULL); |
| 204 | | cdp1864_efx_timer = timer_alloc(cdp1864_efx_tick, NULL); |
| 205 | | cdp1864_dma_timer = timer_alloc(cdp1864_dma_tick, NULL); |
| 280 | INT16 signal = cdp1864->signal; |
| 281 | stream_sample_t *buffer = _buffer[0]; |
| 206 | 282 | |
| 207 | | /* allocate the temporary bitmap */ |
| 208 | | cdptmpbitmap = auto_bitmap_alloc(width, height, video_screen_get_format(screen)); |
| 283 | memset(buffer, 0, length * sizeof(*buffer)); |
| 209 | 284 | |
| 210 | | /* ensure the contents of the bitmap are saved */ |
| 211 | | state_save_register_bitmap("video", 0, "cdptmpbitmap", cdptmpbitmap); |
| 285 | if (cdp1864->audio) |
| 286 | { |
| 287 | double frequency = cdp1864->intf->clock / 8 / 4 / (cdp1864->latch + 1) / 2; |
| 212 | 288 | |
| 213 | | state_save_register_global(cdp1864.disp); |
| 214 | | state_save_register_global(cdp1864.dmaout); |
| 215 | | state_save_register_global(cdp1864.dmaptr); |
| 216 | | state_save_register_global(cdp1864.audio); |
| 217 | | state_save_register_global(cdp1864.bgcolor); |
| 218 | | state_save_register_global(cdp1864.latch); |
| 289 | int rate = device->machine->sample_rate / 2; |
| 290 | |
| 291 | /* get progress through wave */ |
| 292 | int incr = cdp1864->incr; |
| 293 | |
| 294 | if (signal < 0) |
| 295 | { |
| 296 | signal = -0x7fff; |
| 297 | } |
| 298 | else |
| 299 | { |
| 300 | signal = 0x7fff; |
| 301 | } |
| 302 | |
| 303 | while( length-- > 0 ) |
| 304 | { |
| 305 | *buffer++ = signal; |
| 306 | incr -= frequency; |
| 307 | while( incr < 0 ) |
| 308 | { |
| 309 | incr += rate; |
| 310 | signal = -signal; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | /* store progress through wave */ |
| 315 | cdp1864->incr = incr; |
| 316 | cdp1864->signal = signal; |
| 317 | } |
| 219 | 318 | } |
| 319 | #endif |
| 220 | 320 | |
| 221 | | VIDEO_UPDATE( cdp1864 ) |
| 321 | /* Screen Update */ |
| 322 | |
| 323 | void cdp1864_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 222 | 324 | { |
| 223 | | if (cdp1864.disp) |
| 325 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 326 | |
| 327 | if (cdp1864->disp) |
| 224 | 328 | { |
| 225 | | fillbitmap(bitmap, cdp1864_bgcolseq[cdp1864.bgcolor], cliprect); |
| 226 | | copybitmap_trans(bitmap, cdptmpbitmap, 0, 0, 0, 0, cliprect, cdp1864.bgcolor); |
| 329 | fillbitmap(bitmap, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor], cliprect); |
| 330 | copybitmap_trans(bitmap, cdp1864->bitmap, 0, 0, 0, 0, cliprect, cdp1864->bgcolor); |
| 227 | 331 | } |
| 228 | 332 | else |
| 229 | 333 | { |
| 230 | | fillbitmap(bitmap, get_black_pen(screen->machine), cliprect); |
| 334 | fillbitmap(bitmap, 0, cliprect); |
| 231 | 335 | } |
| 232 | | |
| 233 | | return 0; |
| 234 | 336 | } |
| 235 | 337 | |
| 236 | | static void cdp1864_init_palette(running_machine *machine, double res_r, double res_g, double res_b, double res_bkg) |
| 338 | /* Device Interface */ |
| 339 | |
| 340 | static DEVICE_START( cdp1864 ) |
| 237 | 341 | { |
| 238 | | int i, r, g, b, luma; |
| 342 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 343 | char unique_tag[30]; |
| 239 | 344 | |
| 240 | | double res_total = res_r + res_g + res_b; |
| 345 | /* validate arguments */ |
| 346 | assert(device != NULL); |
| 347 | assert(device->tag != NULL); |
| 348 | assert(strlen(device->tag) < 20); |
| 241 | 349 | |
| 242 | | int weight_r = (res_r / res_total) * 100; |
| 243 | | int weight_g = (res_g / res_total) * 100; |
| 244 | | int weight_b = (res_b / res_total) * 100; |
| 350 | cdp1864->intf = device->static_config; |
| 245 | 351 | |
| 246 | | for (i = 0; i < 8; i++) |
| 247 | | { |
| 248 | | luma = (i & 4) ? weight_r : 0; |
| 249 | | luma += (i & 1) ? weight_g : 0; |
| 250 | | luma += (i & 2) ? weight_b : 0; |
| 352 | assert(cdp1864->intf != NULL); |
| 353 | assert(cdp1864->intf->clock > 0); |
| 354 | assert(cdp1864->intf->on_int_changed != NULL); |
| 355 | assert(cdp1864->intf->on_dmao_changed != NULL); |
| 356 | assert(cdp1864->intf->on_efx_changed != NULL); |
| 251 | 357 | |
| 252 | | r = (i & 4) ? luma : 0; |
| 253 | | g = (i & 1) ? luma : 0; |
| 254 | | b = (i & 2) ? luma : 0; |
| 358 | /* get the screen device */ |
| 359 | cdp1864->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, cdp1864->intf->screen_tag); |
| 360 | assert(cdp1864->screen != NULL); |
| 255 | 361 | |
| 256 | | luma = (luma * 0xff) / 100; |
| 362 | /* allocate the temporary bitmap */ |
| 363 | cdp1864->bitmap = auto_bitmap_alloc(video_screen_get_width(cdp1864->screen), video_screen_get_height(cdp1864->screen), video_screen_get_format(cdp1864->screen)); |
| 257 | 364 | |
| 258 | | palette_set_color_rgb( machine, i, r, g, b ); |
| 365 | /* initialize the palette */ |
| 366 | cdp1864_init_palette(device->machine, cdp1864->intf->res_r, cdp1864->intf->res_g, cdp1864->intf->res_b, cdp1864->intf->res_bkg); |
| 367 | |
| 368 | /* create the timers */ |
| 369 | cdp1864->int_timer = timer_alloc(cdp1864_int_tick, (void *)device); |
| 370 | cdp1864->efx_timer = timer_alloc(cdp1864_efx_tick, (void *)device); |
| 371 | cdp1864->dma_timer = timer_alloc(cdp1864_dma_tick, (void *)device); |
| 372 | |
| 373 | /* register for state saving */ |
| 374 | state_save_combine_module_and_tag(unique_tag, "CDP1864", device->tag); |
| 375 | |
| 376 | state_save_register_item(unique_tag, 0, cdp1864->disp); |
| 377 | state_save_register_item(unique_tag, 0, cdp1864->dmaout); |
| 378 | state_save_register_item(unique_tag, 0, cdp1864->dmaptr); |
| 379 | state_save_register_item(unique_tag, 0, cdp1864->bgcolor); |
| 380 | |
| 381 | state_save_register_item(unique_tag, 0, cdp1864->audio); |
| 382 | state_save_register_item(unique_tag, 0, cdp1864->latch); |
| 383 | state_save_register_item(unique_tag, 0, cdp1864->signal); |
| 384 | state_save_register_item(unique_tag, 0, cdp1864->incr); |
| 385 | |
| 386 | state_save_register_bitmap(unique_tag, 0, "cdp1864->bitmap", cdp1864->bitmap); |
| 387 | } |
| 388 | |
| 389 | static DEVICE_RESET( cdp1864 ) |
| 390 | { |
| 391 | cdp1864_t *cdp1864 = get_safe_token(device); |
| 392 | |
| 393 | timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0); |
| 394 | timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0); |
| 395 | timer_adjust_oneshot(cdp1864->dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_START, 0), 0); |
| 396 | |
| 397 | cdp1864->disp = 0; |
| 398 | cdp1864->dmaout = 0; |
| 399 | cdp1864->dmaptr = 0; |
| 400 | cdp1864->bgcolor = 0; |
| 401 | |
| 402 | cdp1864->intf->on_int_changed(device, CLEAR_LINE); |
| 403 | cdp1864->intf->on_dmao_changed(device, CLEAR_LINE); |
| 404 | cdp1864->intf->on_efx_changed(device, CLEAR_LINE); |
| 405 | |
| 406 | cdp1864_aoe_w(device, 0); |
| 407 | } |
| 408 | |
| 409 | static DEVICE_SET_INFO( cdp1864 ) |
| 410 | { |
| 411 | switch (state) |
| 412 | { |
| 413 | /* no parameters to set */ |
| 259 | 414 | } |
| 260 | 415 | } |
| 261 | 416 | |
| 262 | | void cdp1864_configure(running_machine *machine, const CDP1864_interface *intf) |
| 417 | DEVICE_GET_INFO( cdp1864 ) |
| 263 | 418 | { |
| 264 | | cdp1864.colorram_r = intf->colorram_r; |
| 265 | | cdp1864_init_palette(machine, intf->res_r, intf->res_g, intf->res_b, intf->res_bkg); |
| 419 | switch (state) |
| 420 | { |
| 421 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 422 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1864_t); break; |
| 423 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 424 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 425 | |
| 426 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 427 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(cdp1864); break; |
| 428 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1864); break; |
| 429 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 430 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cdp1864); break; |
| 431 | |
| 432 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 433 | case DEVINFO_STR_NAME: info->s = "RCA CDP1861"; break; |
| 434 | case DEVINFO_STR_FAMILY: info->s = "RCA CDP1861"; break; |
| 435 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 436 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 437 | case DEVINFO_STR_CREDITS: info->s = "Copyright MESS Team"; break; |
| 438 | } |
| 266 | 439 | } |
src/mess/drivers/studio2.c
| r2404 | r2405 | |
| 110 | 110 | |
| 111 | 111 | #define SCREEN_TAG "main" |
| 112 | 112 | #define CDP1861_TAG "cdp1861" |
| 113 | #define CDP1864_TAG "cdp1864" |
| 113 | 114 | |
| 114 | 115 | /* Read/Write Handlers */ |
| 115 | 116 | |
| r2404 | r2405 | |
| 132 | 133 | AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w) |
| 133 | 134 | ADDRESS_MAP_END |
| 134 | 135 | |
| 135 | | #ifdef UNUSED_FUNCTION |
| 136 | 136 | static ADDRESS_MAP_START( mpt02_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 137 | 137 | AM_RANGE(0x0000, 0x07ff) AM_ROM |
| 138 | 138 | AM_RANGE(0x0800, 0x09ff) AM_RAM |
| r2404 | r2405 | |
| 141 | 141 | ADDRESS_MAP_END |
| 142 | 142 | |
| 143 | 143 | static ADDRESS_MAP_START( mpt02_io_map, ADDRESS_SPACE_IO, 8 ) |
| 144 | | AM_RANGE(0x01, 0x01) AM_READWRITE(cdp1864_dispon_r, cdp1864_step_bgcolor_w) |
| 144 | AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1864, CDP1864_TAG, cdp1864_dispon_r, cdp1864_step_bgcolor_w) |
| 145 | 145 | AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w) |
| 146 | | AM_RANGE(0x04, 0x04) AM_READWRITE(cdp1864_dispoff_r, cdp1864_tone_latch_w) |
| 146 | AM_RANGE(0x04, 0x04) AM_DEVREADWRITE(CDP1864, CDP1864_TAG, cdp1864_dispoff_r, cdp1864_tone_latch_w) |
| 147 | 147 | ADDRESS_MAP_END |
| 148 | | #endif |
| 149 | 148 | |
| 150 | 149 | /* Input Ports */ |
| 151 | 150 | |
| r2404 | r2405 | |
| 178 | 177 | /* Video */ |
| 179 | 178 | |
| 180 | 179 | static int cdp1861_efx; |
| 181 | | extern int cdp1864_efx; |
| 182 | 180 | |
| 183 | 181 | static CDP1861_ON_INT_CHANGED( studio2_int_w ) |
| 184 | 182 | { |
| r2404 | r2405 | |
| 213 | 211 | return 0; |
| 214 | 212 | } |
| 215 | 213 | |
| 214 | static int cdp1864_efx; |
| 215 | |
| 216 | static CDP1864_ON_INT_CHANGED( mpt02_int_w ) |
| 217 | { |
| 218 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_INT, level); |
| 219 | } |
| 220 | |
| 221 | static CDP1864_ON_DMAO_CHANGED( mpt02_dmao_w ) |
| 222 | { |
| 223 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, level); |
| 224 | } |
| 225 | |
| 226 | static CDP1864_ON_EFX_CHANGED( mpt02_efx_w ) |
| 227 | { |
| 228 | cdp1864_efx = level; |
| 229 | } |
| 230 | |
| 231 | static CDP1864_COLOR_RAM_READ( mpt02_colorram_r ) |
| 232 | { |
| 233 | return colorram[addr / 4]; // 0x04 = R, 0x02 = B, 0x01 = G |
| 234 | } |
| 235 | |
| 236 | static const cdp1864_interface mpt02_cdp1864_intf = |
| 237 | { |
| 238 | SCREEN_TAG, |
| 239 | CDP1864_CLK_FREQ, |
| 240 | mpt02_int_w, |
| 241 | mpt02_dmao_w, |
| 242 | mpt02_efx_w, |
| 243 | mpt02_colorram_r, |
| 244 | RES_K(2.2), // unverified |
| 245 | RES_K(1), // unverified |
| 246 | RES_K(5.1), // unverified |
| 247 | RES_K(4.7) // unverified |
| 248 | }; |
| 249 | |
| 250 | static VIDEO_UPDATE( mpt02 ) |
| 251 | { |
| 252 | const device_config *cdp1864 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 253 | |
| 254 | cdp1864_update(cdp1864, bitmap, cliprect); |
| 255 | |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 216 | 259 | /* CDP1802 Configuration */ |
| 217 | 260 | |
| 218 | 261 | static int cdp1802_mode = CDP1802_MODE_RESET; |
| r2404 | r2405 | |
| 268 | 311 | return ef; |
| 269 | 312 | } |
| 270 | 313 | |
| 314 | static CDP1802_DMA_WRITE( mpt02_dma_w ) |
| 315 | { |
| 316 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 317 | |
| 318 | cdp1864_dma_w(cdp1864, data); |
| 319 | } |
| 320 | |
| 271 | 321 | static const cdp1802_interface mpt02_config = |
| 272 | 322 | { |
| 273 | 323 | studio2_mode_r, |
| r2404 | r2405 | |
| 275 | 325 | NULL, |
| 276 | 326 | studio2_q_w, |
| 277 | 327 | NULL, |
| 278 | | cdp1864_dma_w |
| 328 | mpt02_dma_w |
| 279 | 329 | }; |
| 280 | 330 | |
| 281 | | /* machine Initialization */ |
| 331 | /* Machine Initialization */ |
| 282 | 332 | |
| 283 | 333 | static MACHINE_START( studio2 ) |
| 284 | 334 | { |
| 335 | state_save_register_global(cdp1861_efx); |
| 285 | 336 | state_save_register_global(cdp1802_mode); |
| 286 | 337 | state_save_register_global(keylatch); |
| 287 | 338 | } |
| r2404 | r2405 | |
| 292 | 343 | cdp1861->reset(cdp1861); |
| 293 | 344 | } |
| 294 | 345 | |
| 346 | static MACHINE_START( mpt02 ) |
| 347 | { |
| 348 | state_save_register_global(cdp1864_efx); |
| 349 | state_save_register_global(cdp1802_mode); |
| 350 | state_save_register_global(keylatch); |
| 351 | } |
| 352 | |
| 295 | 353 | static MACHINE_RESET( mpt02 ) |
| 296 | 354 | { |
| 297 | | MACHINE_RESET_CALL(cdp1864); |
| 355 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 356 | cdp1864->reset(cdp1864); |
| 298 | 357 | |
| 299 | 358 | cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); |
| 300 | 359 | } |
| r2404 | r2405 | |
| 302 | 361 | /* machine Drivers */ |
| 303 | 362 | |
| 304 | 363 | static MACHINE_DRIVER_START( studio2 ) |
| 305 | | |
| 306 | 364 | // basic machine hardware |
| 307 | 365 | |
| 308 | | MDRV_CPU_ADD_TAG("main", CDP1802, 3579545/2) // the real clock is derived from an oscillator circuit |
| 366 | MDRV_CPU_ADD(CDP1802, 3579545/2) // the real clock is derived from an oscillator circuit |
| 309 | 367 | MDRV_CPU_PROGRAM_MAP(studio2_map, 0) |
| 310 | 368 | MDRV_CPU_IO_MAP(studio2_io_map, 0) |
| 311 | 369 | MDRV_CPU_CONFIG(studio2_config) |
| r2404 | r2405 | |
| 334 | 392 | MACHINE_DRIVER_END |
| 335 | 393 | |
| 336 | 394 | static MACHINE_DRIVER_START( mpt02 ) |
| 337 | | |
| 338 | 395 | // basic machine hardware |
| 339 | 396 | |
| 340 | | MDRV_CPU_ADD_TAG("main", CDP1802, CDP1864_CLK_FREQ) |
| 341 | | MDRV_CPU_PROGRAM_MAP(studio2_map, 0) |
| 342 | | MDRV_CPU_IO_MAP(studio2_io_map, 0) |
| 397 | MDRV_CPU_ADD(CDP1802, CDP1864_CLK_FREQ) |
| 398 | MDRV_CPU_PROGRAM_MAP(mpt02_map, 0) |
| 399 | MDRV_CPU_IO_MAP(mpt02_io_map, 0) |
| 343 | 400 | MDRV_CPU_CONFIG(mpt02_config) |
| 401 | |
| 402 | MDRV_MACHINE_START(mpt02) |
| 344 | 403 | MDRV_MACHINE_RESET(mpt02) |
| 345 | 404 | |
| 346 | 405 | // video hardware |
| r2404 | r2405 | |
| 350 | 409 | MDRV_SCREEN_RAW_PARAMS(CDP1864_CLK_FREQ, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START) |
| 351 | 410 | |
| 352 | 411 | MDRV_PALETTE_LENGTH(8) |
| 353 | | MDRV_VIDEO_START(cdp1864) |
| 354 | | MDRV_VIDEO_UPDATE(cdp1864) |
| 412 | MDRV_VIDEO_UPDATE(mpt02) |
| 355 | 413 | |
| 414 | MDRV_DEVICE_ADD(CDP1864_TAG, CDP1864) |
| 415 | MDRV_DEVICE_CONFIG(mpt02_cdp1864_intf) |
| 416 | |
| 356 | 417 | // sound hardware |
| 357 | 418 | |
| 358 | 419 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| r2404 | r2405 | |
| 452 | 513 | timer_set(ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode); |
| 453 | 514 | } |
| 454 | 515 | |
| 455 | | static int mpt02_colorram_r(UINT16 addr) |
| 456 | | { |
| 457 | | return colorram[addr / 4]; // 0x04 = R, 0x02 = B, 0x01 = G |
| 458 | | } |
| 459 | | |
| 460 | | static const CDP1864_interface mpt02_CDP1864_interface = |
| 461 | | { |
| 462 | | RES_K(2.2), // unverified |
| 463 | | RES_K(1), // unverified |
| 464 | | RES_K(5.1), // unverified |
| 465 | | RES_K(4.7), // unverified |
| 466 | | mpt02_colorram_r |
| 467 | | }; |
| 468 | | |
| 469 | 516 | static TIMER_CALLBACK(mpt02_setup_beep) |
| 470 | 517 | { |
| 471 | 518 | beep_set_state( 0, 0 ); |
| r2404 | r2405 | |
| 475 | 522 | static DRIVER_INIT( mpt02 ) |
| 476 | 523 | { |
| 477 | 524 | timer_set(attotime_zero, NULL, 0, mpt02_setup_beep); |
| 478 | | cdp1864_configure(machine, &mpt02_CDP1864_interface); |
| 479 | 525 | } |
| 480 | 526 | |
| 481 | 527 | /* Game Drivers */ |
src/mess/drivers/tmc2000e.c
| r2404 | r2405 | |
| 7 | 7 | #include "sound/beep.h" |
| 8 | 8 | #include "rescap.h" |
| 9 | 9 | |
| 10 | #define SCREEN_TAG "main" |
| 11 | #define CDP1864_TAG "cdp1864" |
| 12 | |
| 10 | 13 | /* Read/Write Handlers */ |
| 11 | 14 | |
| 12 | 15 | static READ8_HANDLER( vismac_r ) |
| r2404 | r2405 | |
| 61 | 64 | ADDRESS_MAP_END |
| 62 | 65 | |
| 63 | 66 | static ADDRESS_MAP_START( tmc2000e_io_map, ADDRESS_SPACE_IO, 8 ) |
| 64 | | AM_RANGE(0x01, 0x01) AM_WRITE(cdp1864_tone_latch_w) |
| 65 | | AM_RANGE(0x02, 0x02) AM_WRITE(cdp1864_step_bgcolor_w) |
| 67 | AM_RANGE(0x01, 0x01) AM_DEVWRITE(CDP1864, CDP1864_TAG, cdp1864_tone_latch_w) |
| 68 | AM_RANGE(0x02, 0x02) AM_DEVWRITE(CDP1864, CDP1864_TAG, cdp1864_step_bgcolor_w) |
| 66 | 69 | AM_RANGE(0x03, 0x03) AM_READWRITE(ascii_keyboard_r, keyboard_latch_w) |
| 67 | 70 | AM_RANGE(0x04, 0x04) AM_READWRITE(io_r, io_w) |
| 68 | 71 | AM_RANGE(0x05, 0x05) AM_READWRITE(vismac_r, vismac_w) |
| r2404 | r2405 | |
| 91 | 94 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Run/Reset") PORT_CODE(KEYCODE_R) PORT_TOGGLE |
| 92 | 95 | INPUT_PORTS_END |
| 93 | 96 | |
| 97 | /* Video */ |
| 98 | |
| 99 | static int cdp1864_efx; |
| 100 | |
| 101 | static CDP1864_ON_INT_CHANGED( tmc2000e_int_w ) |
| 102 | { |
| 103 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_INT, level); |
| 104 | } |
| 105 | |
| 106 | static CDP1864_ON_DMAO_CHANGED( tmc2000e_dmao_w ) |
| 107 | { |
| 108 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, level); |
| 109 | } |
| 110 | |
| 111 | static CDP1864_ON_EFX_CHANGED( tmc2000e_efx_w ) |
| 112 | { |
| 113 | cdp1864_efx = level; |
| 114 | } |
| 115 | |
| 116 | static CDP1864_COLOR_RAM_READ( tmc2000e_colorram_r ) |
| 117 | { |
| 118 | return colorram[addr]; // 0x04 = R, 0x02 = B, 0x01 = G |
| 119 | } |
| 120 | |
| 121 | static const cdp1864_interface tmc2000e_cdp1864_intf = |
| 122 | { |
| 123 | SCREEN_TAG, |
| 124 | CDP1864_CLK_FREQ, |
| 125 | tmc2000e_int_w, |
| 126 | tmc2000e_dmao_w, |
| 127 | tmc2000e_efx_w, |
| 128 | tmc2000e_colorram_r, |
| 129 | RES_K(2.2), // unverified |
| 130 | RES_K(1), // unverified |
| 131 | RES_K(5.1), // unverified |
| 132 | RES_K(4.7) // unverified |
| 133 | }; |
| 134 | |
| 135 | static VIDEO_UPDATE( tmc2000e ) |
| 136 | { |
| 137 | const device_config *cdp1864 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 138 | |
| 139 | cdp1864_update(cdp1864, bitmap, cliprect); |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 94 | 144 | /* CDP1802 Interface */ |
| 95 | 145 | |
| 96 | 146 | static CDP1802_MODE_READ( tmc2000e_mode_r ) |
| r2404 | r2405 | |
| 126 | 176 | |
| 127 | 177 | static CDP1802_Q_WRITE( tmc2000e_q_w ) |
| 128 | 178 | { |
| 179 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 180 | |
| 129 | 181 | // CDP1864 sound generator on/off |
| 130 | | cdp1864_audio_output_enable(level); |
| 182 | cdp1864_aoe_w(cdp1864, level); |
| 131 | 183 | |
| 132 | 184 | // set Q led status |
| 133 | 185 | // leds: Wait, Q, Power |
| r2404 | r2405 | |
| 138 | 190 | // floppy control (FDC-6) |
| 139 | 191 | } |
| 140 | 192 | |
| 193 | static CDP1802_DMA_WRITE( tmc2000e_dma_w ) |
| 194 | { |
| 195 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 196 | |
| 197 | cdp1864_dma_w(cdp1864, data); |
| 198 | } |
| 199 | |
| 141 | 200 | static const cdp1802_interface tmc2000e_config = |
| 142 | 201 | { |
| 143 | 202 | tmc2000e_mode_r, |
| r2404 | r2405 | |
| 145 | 204 | NULL, |
| 146 | 205 | tmc2000e_q_w, |
| 147 | 206 | NULL, |
| 148 | | cdp1864_dma_w |
| 207 | tmc2000e_dma_w |
| 149 | 208 | }; |
| 150 | 209 | |
| 151 | 210 | /* Machine Initialization */ |
| r2404 | r2405 | |
| 157 | 216 | |
| 158 | 217 | static MACHINE_RESET( tmc2000e ) |
| 159 | 218 | { |
| 160 | | MACHINE_RESET_CALL(cdp1864); |
| 219 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 220 | cdp1864->reset(cdp1864); |
| 161 | 221 | |
| 162 | 222 | cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); |
| 163 | 223 | |
| r2404 | r2405 | |
| 167 | 227 | /* Machine Drivers */ |
| 168 | 228 | |
| 169 | 229 | static MACHINE_DRIVER_START( tmc2000e ) |
| 170 | | |
| 171 | 230 | // basic system hardware |
| 172 | 231 | |
| 173 | 232 | MDRV_CPU_ADD(CDP1802, XTAL_1_75MHz) |
| r2404 | r2405 | |
| 180 | 239 | |
| 181 | 240 | // video hardware |
| 182 | 241 | |
| 183 | | MDRV_SCREEN_ADD("main", RASTER) |
| 242 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 184 | 243 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 185 | 244 | MDRV_SCREEN_RAW_PARAMS(CDP1864_CLK_FREQ, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START) |
| 186 | 245 | |
| 187 | 246 | MDRV_PALETTE_LENGTH(8) |
| 188 | | MDRV_VIDEO_START(cdp1864) |
| 189 | | MDRV_VIDEO_UPDATE(cdp1864) |
| 247 | MDRV_VIDEO_UPDATE(tmc2000e) |
| 190 | 248 | |
| 249 | MDRV_DEVICE_ADD(CDP1864_TAG, CDP1864) |
| 250 | MDRV_DEVICE_CONFIG(tmc2000e_cdp1864_intf) |
| 251 | |
| 191 | 252 | // sound hardware |
| 192 | 253 | |
| 193 | 254 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| r2404 | r2405 | |
| 196 | 257 | |
| 197 | 258 | /* printer */ |
| 198 | 259 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 199 | | |
| 200 | 260 | MACHINE_DRIVER_END |
| 201 | 261 | |
| 202 | 262 | /* ROMs */ |
| r2404 | r2405 | |
| 250 | 310 | |
| 251 | 311 | /* Driver Initialization */ |
| 252 | 312 | |
| 253 | | static int tmc2000e_colorram_r(UINT16 addr) |
| 254 | | { |
| 255 | | return colorram[addr]; // 0x04 = R, 0x02 = B, 0x01 = G |
| 256 | | } |
| 257 | | |
| 258 | | static const CDP1864_interface tmc2000e_CDP1864_interface = |
| 259 | | { |
| 260 | | RES_K(2.2), // unverified |
| 261 | | RES_K(1), // unverified |
| 262 | | RES_K(5.1), // unverified |
| 263 | | RES_K(4.7), // unverified |
| 264 | | tmc2000e_colorram_r |
| 265 | | }; |
| 266 | | |
| 267 | 313 | static TIMER_CALLBACK(setup_beep) |
| 268 | 314 | { |
| 269 | 315 | beep_set_state(0, 0); |
| r2404 | r2405 | |
| 276 | 322 | set_led_status(2, 1); |
| 277 | 323 | |
| 278 | 324 | timer_set(attotime_zero, NULL, 0, setup_beep); |
| 279 | | |
| 280 | | cdp1864_configure(machine, &tmc2000e_CDP1864_interface); |
| 281 | 325 | } |
| 282 | 326 | |
| 283 | 327 | // YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME |
src/mess/drivers/tmc1800.c
| r2404 | r2405 | |
| 92 | 92 | #include "sound/beep.h" |
| 93 | 93 | #include "rescap.h" |
| 94 | 94 | |
| 95 | #define SCREEN_TAG "main" |
| 96 | #define CDP1864_TAG "cdp1864" |
| 97 | |
| 95 | 98 | extern VIDEO_START( osm200 ); |
| 96 | 99 | extern VIDEO_UPDATE( osm200 ); |
| 97 | 100 | |
| r2404 | r2405 | |
| 104 | 107 | keylatch = data; |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | | static WRITE8_HANDLER( tmc2000_bankswitch_w ) |
| 110 | static WRITE8_DEVICE_HANDLER( tmc2000_bankswitch_w ) |
| 108 | 111 | { |
| 109 | 112 | memory_set_bank(1, data & 0x01); |
| 110 | 113 | |
| 111 | | cdp1864_tone_latch_w(machine, 0, data); |
| 114 | cdp1864_tone_latch_w(device, 0, data); |
| 112 | 115 | } |
| 113 | 116 | |
| 114 | 117 | /* Memory Maps */ |
| r2404 | r2405 | |
| 132 | 135 | ADDRESS_MAP_END |
| 133 | 136 | |
| 134 | 137 | static ADDRESS_MAP_START( tmc2000_io_map, ADDRESS_SPACE_IO, 8 ) |
| 135 | | AM_RANGE(0x01, 0x01) AM_READWRITE(cdp1864_dispon_r, cdp1864_step_bgcolor_w) |
| 138 | AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1864, CDP1864_TAG, cdp1864_dispon_r, cdp1864_step_bgcolor_w) |
| 136 | 139 | AM_RANGE(0x02, 0x02) AM_WRITE(keyboard_latch_w) |
| 137 | | AM_RANGE(0x04, 0x04) AM_READWRITE(cdp1864_dispoff_r, tmc2000_bankswitch_w) |
| 140 | AM_RANGE(0x04, 0x04) AM_DEVREADWRITE(CDP1864, CDP1864_TAG, cdp1864_dispoff_r, tmc2000_bankswitch_w) |
| 138 | 141 | ADDRESS_MAP_END |
| 139 | 142 | |
| 140 | 143 | /* Input Ports */ |
| r2404 | r2405 | |
| 164 | 167 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Run/Reset") PORT_CODE(KEYCODE_R) PORT_TOGGLE |
| 165 | 168 | INPUT_PORTS_END |
| 166 | 169 | |
| 170 | /* Video */ |
| 171 | |
| 172 | static int cdp1864_efx; |
| 173 | |
| 174 | static CDP1864_ON_INT_CHANGED( tmc2000_int_w ) |
| 175 | { |
| 176 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_INT, level); |
| 177 | } |
| 178 | |
| 179 | static CDP1864_ON_DMAO_CHANGED( tmc2000_dmao_w ) |
| 180 | { |
| 181 | cpunum_set_input_line(device->machine, 0, CDP1802_INPUT_LINE_DMAOUT, level); |
| 182 | } |
| 183 | |
| 184 | static CDP1864_ON_EFX_CHANGED( tmc2000_efx_w ) |
| 185 | { |
| 186 | cdp1864_efx = level; |
| 187 | } |
| 188 | |
| 189 | static CDP1864_COLOR_RAM_READ( tmc2000_colorram_r ) |
| 190 | { |
| 191 | UINT8 data = colorram[addr]; // 0x04 = ~B, 0x02 = ~R, 0x01 = ~G |
| 192 | |
| 193 | return ~(((data & 0x04) >> 1) + ((data & 0x02) << 1) + (data & 0x01)) & 0x07; |
| 194 | } |
| 195 | |
| 196 | static const cdp1864_interface tmc2000_cdp1864_intf = |
| 197 | { |
| 198 | SCREEN_TAG, |
| 199 | CDP1864_CLK_FREQ, |
| 200 | tmc2000_int_w, |
| 201 | tmc2000_dmao_w, |
| 202 | tmc2000_efx_w, |
| 203 | tmc2000_colorram_r, |
| 204 | RES_K(2.2), // unverified |
| 205 | RES_K(1), // unverified |
| 206 | RES_K(5.1), // unverified |
| 207 | RES_K(4.7) // unverified |
| 208 | }; |
| 209 | |
| 210 | static VIDEO_UPDATE( tmc2000 ) |
| 211 | { |
| 212 | const device_config *cdp1864 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 213 | |
| 214 | cdp1864_update(cdp1864, bitmap, cliprect); |
| 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 167 | 219 | /* CDP1802 Interfaces */ |
| 168 | 220 | |
| 169 | 221 | // Telmac 1800 |
| r2404 | r2405 | |
| 236 | 288 | |
| 237 | 289 | static CDP1802_Q_WRITE( tmc2000_q_w ) |
| 238 | 290 | { |
| 291 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 292 | |
| 239 | 293 | // turn CDP1864 sound generator on/off |
| 240 | | cdp1864_audio_output_enable(level); |
| 294 | cdp1864_aoe_w(cdp1864, level); |
| 241 | 295 | |
| 242 | 296 | // set Q led status |
| 243 | 297 | set_led_status(1, level); |
| 244 | 298 | } |
| 245 | 299 | |
| 300 | static CDP1802_DMA_WRITE( tmc2000_dma_w ) |
| 301 | { |
| 302 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 303 | |
| 304 | cdp1864_dma_w(cdp1864, data); |
| 305 | } |
| 306 | |
| 246 | 307 | static const cdp1802_interface tmc2000_config = |
| 247 | 308 | { |
| 248 | 309 | tmc1800_mode_r, |
| r2404 | r2405 | |
| 250 | 311 | NULL, |
| 251 | 312 | tmc2000_q_w, |
| 252 | 313 | NULL, |
| 253 | | cdp1864_dma_w |
| 314 | tmc2000_dma_w |
| 254 | 315 | }; |
| 255 | 316 | |
| 256 | 317 | /* Machine Initialization */ |
| r2404 | r2405 | |
| 275 | 336 | |
| 276 | 337 | static MACHINE_RESET( tmc2000 ) |
| 277 | 338 | { |
| 278 | | MACHINE_RESET_CALL(cdp1864); |
| 339 | const device_config *cdp1864 = device_list_find_by_tag(machine->config->devicelist, CDP1864, CDP1864_TAG); |
| 340 | cdp1864->reset(cdp1864); |
| 279 | 341 | |
| 280 | 342 | cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); |
| 281 | 343 | |
| r2404 | r2405 | |
| 286 | 348 | /* Machine Drivers */ |
| 287 | 349 | |
| 288 | 350 | static MACHINE_DRIVER_START( tmc1800 ) |
| 289 | | |
| 290 | 351 | // basic system hardware |
| 291 | 352 | |
| 292 | 353 | MDRV_CPU_ADD(CDP1802, XTAL_1_75MHz) |
| r2404 | r2405 | |
| 299 | 360 | |
| 300 | 361 | // video hardware |
| 301 | 362 | |
| 302 | | MDRV_SCREEN_ADD("main", RASTER) |
| 363 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 303 | 364 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 304 | 365 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 199) |
| 305 | 366 | |
| r2404 | r2405 | |
| 310 | 371 | MACHINE_DRIVER_END |
| 311 | 372 | |
| 312 | 373 | static MACHINE_DRIVER_START( tmc2000 ) |
| 313 | | |
| 314 | 374 | // basic system hardware |
| 315 | 375 | |
| 316 | 376 | MDRV_CPU_ADD(CDP1802, XTAL_1_75MHz) |
| r2404 | r2405 | |
| 323 | 383 | |
| 324 | 384 | // video hardware |
| 325 | 385 | |
| 326 | | MDRV_SCREEN_ADD("main", RASTER) |
| 386 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 327 | 387 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 328 | 388 | MDRV_SCREEN_RAW_PARAMS(CDP1864_CLK_FREQ, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START) |
| 329 | 389 | |
| 330 | 390 | MDRV_PALETTE_LENGTH(8) |
| 331 | | MDRV_VIDEO_START(cdp1864) |
| 332 | | MDRV_VIDEO_UPDATE(cdp1864) |
| 391 | MDRV_VIDEO_UPDATE(tmc2000) |
| 333 | 392 | |
| 393 | MDRV_DEVICE_ADD(CDP1864_TAG, CDP1864) |
| 394 | MDRV_DEVICE_CONFIG(tmc2000_cdp1864_intf) |
| 395 | |
| 334 | 396 | // sound hardware |
| 335 | 397 | |
| 336 | 398 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| r2404 | r2405 | |
| 398 | 460 | |
| 399 | 461 | /* Driver Initialization */ |
| 400 | 462 | |
| 401 | | static int tmc2000_colorram_r(UINT16 addr) |
| 402 | | { |
| 403 | | UINT8 data = colorram[addr]; // 0x04 = ~B, 0x02 = ~R, 0x01 = ~G |
| 404 | | |
| 405 | | return ~(((data & 0x04) >> 1) + ((data & 0x02) << 1) + (data & 0x01)) & 0x07; |
| 406 | | } |
| 407 | | |
| 408 | | static const CDP1864_interface tmc2000_CDP1864_interface = |
| 409 | | { |
| 410 | | RES_K(2.2), // unverified |
| 411 | | RES_K(1), // unverified |
| 412 | | RES_K(5.1), // unverified |
| 413 | | RES_K(4.7), // unverified |
| 414 | | tmc2000_colorram_r |
| 415 | | }; |
| 416 | | |
| 417 | 463 | static TIMER_CALLBACK(setup_beep) |
| 418 | 464 | { |
| 419 | 465 | beep_set_state(0, 0); |
| r2404 | r2405 | |
| 428 | 474 | static DRIVER_INIT( tmc2000 ) |
| 429 | 475 | { |
| 430 | 476 | timer_set(attotime_zero, NULL, 0, setup_beep); |
| 431 | | cdp1864_configure(machine, &tmc2000_CDP1864_interface); |
| 432 | 477 | } |
| 433 | 478 | |
| 434 | 479 | /* System Drivers */ |