src/mess/video/msm6255.c
| r4239 | r4240 | |
| 10 | 10 | #include "driver.h" |
| 11 | 11 | #include "msm6255.h" |
| 12 | 12 | |
| 13 | /*************************************************************************** |
| 14 | PARAMETERS |
| 15 | ***************************************************************************/ |
| 16 | |
| 13 | 17 | #define MSM6255_MOR_GRAPHICS 0x01 |
| 14 | 18 | #define MSM6255_MOR_4_BIT_PARALLEL 0x02 |
| 15 | 19 | #define MSM6255_MOR_2_BIT_PARALLEL 0x04 |
| r4239 | r4240 | |
| 46 | 50 | MSM6255_REGISTER_CUR |
| 47 | 51 | }; |
| 48 | 52 | |
| 53 | /*************************************************************************** |
| 54 | TYPE DEFINITIONS |
| 55 | ***************************************************************************/ |
| 56 | |
| 49 | 57 | typedef struct _msm6255_t msm6255_t; |
| 50 | 58 | struct _msm6255_t |
| 51 | 59 | { |
| 52 | 60 | const msm6255_interface *intf; /* interface */ |
| 61 | |
| 53 | 62 | const device_config *screen; /* screen */ |
| 54 | 63 | |
| 55 | 64 | UINT8 ir; /* instruction register */ |
| r4239 | r4240 | |
| 67 | 76 | int frame; /* frame counter */ |
| 68 | 77 | }; |
| 69 | 78 | |
| 79 | /*************************************************************************** |
| 80 | INLINE FUNCTIONS |
| 81 | ***************************************************************************/ |
| 82 | |
| 70 | 83 | INLINE msm6255_t *get_safe_token(const device_config *device) |
| 71 | 84 | { |
| 72 | 85 | assert(device != NULL); |
| 73 | 86 | assert(device->token != NULL); |
| 74 | | |
| 75 | 87 | return (msm6255_t *)device->token; |
| 76 | 88 | } |
| 77 | 89 | |
| 78 | | /* Register Access */ |
| 90 | /*************************************************************************** |
| 91 | IMPLEMENTATION |
| 92 | ***************************************************************************/ |
| 79 | 93 | |
| 94 | /*------------------------------------------------- |
| 95 | msm6255_register_r - register read |
| 96 | -------------------------------------------------*/ |
| 97 | |
| 80 | 98 | READ8_DEVICE_HANDLER( msm6255_register_r ) |
| 81 | 99 | { |
| 82 | 100 | msm6255_t *msm6255 = get_safe_token(device); |
| r4239 | r4240 | |
| 122 | 140 | } |
| 123 | 141 | } |
| 124 | 142 | |
| 143 | /*------------------------------------------------- |
| 144 | msm6255_register_w - register write |
| 145 | -------------------------------------------------*/ |
| 146 | |
| 125 | 147 | WRITE8_DEVICE_HANDLER( msm6255_register_w ) |
| 126 | 148 | { |
| 127 | 149 | msm6255_t *msm6255 = get_safe_token(device); |
| r4239 | r4240 | |
| 173 | 195 | } |
| 174 | 196 | } |
| 175 | 197 | |
| 176 | | /* Screen Update */ |
| 198 | /*------------------------------------------------- |
| 199 | update_cursor - update cursor state |
| 200 | -------------------------------------------------*/ |
| 177 | 201 | |
| 178 | | static void msm6255_update_cursor(const device_config *device) |
| 202 | static void update_cursor(const device_config *device) |
| 179 | 203 | { |
| 180 | 204 | msm6255_t *msm6255 = get_safe_token(device); |
| 181 | 205 | |
| r4239 | r4240 | |
| 219 | 243 | } |
| 220 | 244 | } |
| 221 | 245 | |
| 222 | | static void msm6255_draw_scanline(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra) |
| 246 | /*------------------------------------------------- |
| 247 | draw_scanline - draw one scanline |
| 248 | -------------------------------------------------*/ |
| 249 | |
| 250 | static void draw_scanline(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra) |
| 223 | 251 | { |
| 224 | 252 | msm6255_t *msm6255 = get_safe_token(device); |
| 225 | 253 | |
| r4239 | r4240 | |
| 257 | 285 | } |
| 258 | 286 | } |
| 259 | 287 | |
| 260 | | static void msm6255_update_graphics(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 288 | /*------------------------------------------------- |
| 289 | update_graphics - draw graphics mode screen |
| 290 | -------------------------------------------------*/ |
| 291 | |
| 292 | static void update_graphics(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 261 | 293 | { |
| 262 | 294 | msm6255_t *msm6255 = get_safe_token(device); |
| 263 | 295 | |
| r4239 | r4240 | |
| 272 | 304 | |
| 273 | 305 | for (y = 0; y < nx; y++) |
| 274 | 306 | { |
| 275 | | // draw upper half scanline |
| 276 | | |
| 307 | /* draw upper half scanline */ |
| 277 | 308 | UINT16 ma = sar + (y * hn); |
| 309 | draw_scanline(device, bitmap, cliprect, y, ma, 0); |
| 278 | 310 | |
| 279 | | msm6255_draw_scanline(device, bitmap, cliprect, y, ma, 0); |
| 280 | | |
| 281 | | // draw lower half scanline |
| 282 | | |
| 311 | /* draw lower half scanline */ |
| 283 | 312 | ma = sar + ((y + nx) * hn); |
| 284 | | |
| 285 | | msm6255_draw_scanline(device, bitmap, cliprect, y + nx, ma, 0); |
| 313 | draw_scanline(device, bitmap, cliprect, y + nx, ma, 0); |
| 286 | 314 | } |
| 287 | 315 | } |
| 288 | 316 | |
| 289 | | static void msm6255_update_text(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 317 | /*------------------------------------------------- |
| 318 | update_text - draw text mode screen |
| 319 | -------------------------------------------------*/ |
| 320 | |
| 321 | static void update_text(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 290 | 322 | { |
| 291 | 323 | msm6255_t *msm6255 = get_safe_token(device); |
| 292 | 324 | |
| r4239 | r4240 | |
| 297 | 329 | |
| 298 | 330 | int sy, y; |
| 299 | 331 | |
| 300 | | msm6255_update_cursor(device); |
| 332 | update_cursor(device); |
| 301 | 333 | |
| 302 | 334 | for (sy = 0; sy < nx; sy++) |
| 303 | 335 | { |
| 304 | 336 | for (y = 0; y < vp; y++) |
| 305 | 337 | { |
| 306 | | // draw upper half scanline |
| 307 | | |
| 338 | /* draw upper half scanline */ |
| 308 | 339 | UINT16 ma = sar + ((sy * vp) + y) * hn; |
| 340 | draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y); |
| 309 | 341 | |
| 310 | | msm6255_draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y); |
| 311 | | |
| 312 | | // draw lower half scanline |
| 313 | | |
| 342 | /* draw lower half scanline */ |
| 314 | 343 | ma = sar + (((sy + nx) * vp) + y) * hn; |
| 315 | | |
| 316 | | msm6255_draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y); |
| 344 | draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y); |
| 317 | 345 | } |
| 318 | 346 | } |
| 319 | 347 | } |
| 320 | 348 | |
| 349 | /*------------------------------------------------- |
| 350 | update_text - draw screen |
| 351 | -------------------------------------------------*/ |
| 352 | |
| 321 | 353 | void msm6255_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 322 | 354 | { |
| 323 | 355 | msm6255_t *msm6255 = get_safe_token(device); |
| r4239 | r4240 | |
| 326 | 358 | { |
| 327 | 359 | if (msm6255->mor & MSM6255_MOR_GRAPHICS) |
| 328 | 360 | { |
| 329 | | msm6255_update_graphics(device, bitmap, cliprect); |
| 361 | update_graphics(device, bitmap, cliprect); |
| 330 | 362 | } |
| 331 | 363 | else |
| 332 | 364 | { |
| 333 | | msm6255_update_text(device, bitmap, cliprect); |
| 365 | update_text(device, bitmap, cliprect); |
| 334 | 366 | } |
| 335 | 367 | } |
| 336 | 368 | else |
| r4239 | r4240 | |
| 339 | 371 | } |
| 340 | 372 | } |
| 341 | 373 | |
| 342 | | /* Device Interface */ |
| 374 | /*------------------------------------------------- |
| 375 | DEVICE_START( msm6255 ) |
| 376 | -------------------------------------------------*/ |
| 343 | 377 | |
| 344 | 378 | static DEVICE_START( msm6255 ) |
| 345 | 379 | { |
| 346 | 380 | msm6255_t *msm6255 = get_safe_token(device); |
| 347 | 381 | |
| 348 | | // validate arguments |
| 382 | /* resolve callbacks */ |
| 383 | msm6255->intf = device->static_config; |
| 384 | assert(msm6255->intf->char_ram_r != NULL); |
| 349 | 385 | |
| 350 | | assert(device != NULL); |
| 351 | | assert(device->tag != NULL); |
| 352 | | assert(device->static_config != NULL); |
| 353 | | |
| 354 | | msm6255->intf = device->static_config; |
| 355 | | |
| 356 | | assert(msm6255->intf->char_ram_r != NULL); |
| 357 | | |
| 358 | | // get the screen device |
| 359 | | |
| 386 | /* get the screen */ |
| 360 | 387 | msm6255->screen = devtag_get_device(device->machine, VIDEO_SCREEN, msm6255->intf->screen_tag); |
| 361 | 388 | assert(msm6255->screen != NULL); |
| 362 | 389 | |
| 363 | | // register for state saving |
| 390 | /* register for state saving */ |
| 364 | 391 | state_save_register_device_item(device, 0, msm6255->ir); |
| 365 | 392 | state_save_register_device_item(device, 0, msm6255->mor); |
| 366 | 393 | state_save_register_device_item(device, 0, msm6255->pr); |
| r4239 | r4240 | |
| 371 | 398 | state_save_register_device_item(device, 0, msm6255->sur); |
| 372 | 399 | state_save_register_device_item(device, 0, msm6255->clr); |
| 373 | 400 | state_save_register_device_item(device, 0, msm6255->cur); |
| 374 | | |
| 375 | 401 | state_save_register_device_item(device, 0, msm6255->cursor); |
| 376 | 402 | state_save_register_device_item(device, 0, msm6255->frame); |
| 377 | 403 | } |
| 378 | 404 | |
| 405 | /*------------------------------------------------- |
| 406 | DEVICE_RESET( msm6255 ) |
| 407 | -------------------------------------------------*/ |
| 408 | |
| 379 | 409 | static DEVICE_RESET( msm6255 ) |
| 380 | 410 | { |
| 381 | 411 | msm6255_t *msm6255 = get_safe_token(device); |
| r4239 | r4240 | |
| 383 | 413 | msm6255->frame = 0; |
| 384 | 414 | } |
| 385 | 415 | |
| 416 | /*------------------------------------------------- |
| 417 | DEVICE_SET_INFO( msm6255 ) |
| 418 | -------------------------------------------------*/ |
| 419 | |
| 386 | 420 | static DEVICE_SET_INFO( msm6255 ) |
| 387 | 421 | { |
| 388 | 422 | switch (state) |
| r4239 | r4240 | |
| 391 | 425 | } |
| 392 | 426 | } |
| 393 | 427 | |
| 428 | /*------------------------------------------------- |
| 429 | DEVICE_GET_INFO( msm6255 ) |
| 430 | -------------------------------------------------*/ |
| 431 | |
| 394 | 432 | DEVICE_GET_INFO( msm6255 ) |
| 395 | 433 | { |
| 396 | 434 | switch (state) |
| 397 | 435 | { |
| 398 | 436 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 399 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(msm6255_t); break; |
| 400 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 401 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 437 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(msm6255_t); break; |
| 438 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 439 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 402 | 440 | |
| 403 | 441 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 404 | 442 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(msm6255); break; |
| 405 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(msm6255); break; |
| 406 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 407 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(msm6255); break; |
| 443 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(msm6255); break; |
| 444 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 445 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(msm6255); break; |
| 408 | 446 | |
| 409 | 447 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 410 | | case DEVINFO_STR_NAME: strcpy(info->s, "OKI MSM6255"); break; |
| 411 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "OKI MSM6255"); break; |
| 412 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 413 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 414 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 448 | case DEVINFO_STR_NAME: strcpy(info->s, "OKI MSM6255"); break; |
| 449 | case DEVINFO_STR_FAMILY: strcpy(info->s, "OKI MSM6255"); break; |
| 450 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 451 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 452 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 415 | 453 | } |
| 416 | 454 | } |
src/mess/video/msm6255.h
| r4239 | r4240 | |
| 10 | 10 | #ifndef __MSM6255_VIDEO__ |
| 11 | 11 | #define __MSM6255_VIDEO__ |
| 12 | 12 | |
| 13 | | typedef UINT8 (*msm6255_char_ram_read_func)(const device_config *device, UINT16 ma, UINT8 ra); |
| 14 | | #define MSM6255_CHAR_RAM_READ(name) UINT8 name(const device_config *device, UINT16 ma, UINT8 ra) |
| 13 | /*************************************************************************** |
| 14 | MACROS / CONSTANTS |
| 15 | ***************************************************************************/ |
| 15 | 16 | |
| 16 | 17 | #define MSM6255 DEVICE_GET_INFO_NAME(msm6255) |
| 17 | 18 | |
| 18 | | #define MDRV_MSM6255_ADD(_tag, _intrf) \ |
| 19 | | MDRV_DEVICE_ADD(_tag, MSM6255, 0) \ |
| 20 | | MDRV_DEVICE_CONFIG(_intrf) |
| 19 | #define MDRV_MSM6255_ADD(_tag, _clock, _config) \ |
| 20 | MDRV_DEVICE_ADD(_tag, MSM6255, _clock) \ |
| 21 | MDRV_DEVICE_CONFIG(_config) |
| 21 | 22 | |
| 22 | 23 | #define MDRV_MSM6255_REMOVE(_tag) \ |
| 23 | 24 | MDRV_DEVICE_REMOVE(_tag, MSM6255) |
| 24 | 25 | |
| 25 | | /* interface */ |
| 26 | #define MSM6255_INTERFACE(_name) \ |
| 27 | const msm6255_interface (_name) = |
| 28 | |
| 29 | #define MSM6255_CHAR_RAM_READ(_name) \ |
| 30 | UINT8 _name(const device_config *device, UINT16 ma, UINT8 ra) |
| 31 | |
| 32 | /*************************************************************************** |
| 33 | TYPE DEFINITIONS |
| 34 | ***************************************************************************/ |
| 35 | |
| 36 | typedef UINT8 (*msm6255_char_ram_read_func)(const device_config *device, UINT16 ma, UINT8 ra); |
| 37 | |
| 26 | 38 | typedef struct _msm6255_interface msm6255_interface; |
| 27 | 39 | struct _msm6255_interface |
| 28 | 40 | { |
| 29 | 41 | const char *screen_tag; /* screen we are acting on */ |
| 30 | | int pixel_clock; /* the pixel clock of the chip */ |
| 42 | |
| 31 | 43 | int character_clock; /* the character clock of the chip */ |
| 32 | 44 | |
| 33 | | /* character memory read function */ |
| 45 | /* ROM/RAM data read function */ |
| 34 | 46 | msm6255_char_ram_read_func char_ram_r; |
| 35 | 47 | }; |
| 36 | 48 | |
| 49 | /*************************************************************************** |
| 50 | PROTOTYPES |
| 51 | ***************************************************************************/ |
| 52 | |
| 37 | 53 | /* device interface */ |
| 38 | 54 | DEVICE_GET_INFO( msm6255 ); |
| 39 | 55 | |