src/mess/video/crt9007.c
| r9643 | r9644 | |
| 14 | 14 | - interrupts |
| 15 | 15 | - status register |
| 16 | 16 | - reset |
| 17 | | - DMA mode (currently forcing to non-DMA mode) |
| 17 | - non-DMA mode |
| 18 | - DMA mode |
| 18 | 19 | - cursor/blank skew |
| 19 | 20 | - sequential breaks |
| 20 | 21 | - interlaced mode |
| r9643 | r9644 | |
| 33 | 34 | #include "emu.h" |
| 34 | 35 | #include "crt9007.h" |
| 35 | 36 | |
| 36 | | /*************************************************************************** |
| 37 | | PARAMETERS |
| 38 | | ***************************************************************************/ |
| 39 | 37 | |
| 38 | |
| 39 | //************************************************************************** |
| 40 | // MACROS / CONSTANTS |
| 41 | //************************************************************************** |
| 42 | |
| 40 | 43 | #define LOG 1 |
| 41 | 44 | |
| 42 | 45 | #define HAS_VALID_PARAMETERS \ |
| 43 | | (crt9007->reg[0x00] && crt9007->reg[0x01] && crt9007->reg[0x07] && crt9007->reg[0x08] && crt9007->reg[0x09]) |
| 46 | (m_reg[0x00] && m_reg[0x01] && m_reg[0x07] && m_reg[0x08] && m_reg[0x09]) |
| 44 | 47 | |
| 45 | 48 | #define CHARACTERS_PER_HORIZONTAL_PERIOD \ |
| 46 | | crt9007->reg[0x00] |
| 49 | m_reg[0x00] |
| 47 | 50 | |
| 48 | 51 | #define CHARACTERS_PER_DATA_ROW \ |
| 49 | | (crt9007->reg[0x01] + 1) |
| 52 | (m_reg[0x01] + 1) |
| 50 | 53 | |
| 51 | 54 | #define HORIZONTAL_DELAY \ |
| 52 | | crt9007->reg[0x02] |
| 55 | m_reg[0x02] |
| 53 | 56 | |
| 54 | 57 | #define HORIZONTAL_SYNC_WIDTH \ |
| 55 | | crt9007->reg[0x03] |
| 58 | m_reg[0x03] |
| 56 | 59 | |
| 57 | 60 | #define VERTICAL_SYNC_WIDTH \ |
| 58 | | crt9007->reg[0x04] |
| 61 | m_reg[0x04] |
| 59 | 62 | |
| 60 | 63 | #define VERTICAL_DELAY \ |
| 61 | | (crt9007->reg[0x05] - 1) |
| 64 | (m_reg[0x05] - 1) |
| 62 | 65 | |
| 63 | 66 | #define PIN_CONFIGURATION \ |
| 64 | | (crt9007->reg[0x06] >> 6) |
| 67 | (m_reg[0x06] >> 6) |
| 65 | 68 | |
| 66 | 69 | #define CURSOR_SKEW \ |
| 67 | | ((crt9007->reg[0x06] >> 3) & 0x07) |
| 70 | ((m_reg[0x06] >> 3) & 0x07) |
| 68 | 71 | |
| 69 | 72 | #define BLANK_SKEW \ |
| 70 | | (crt9007->reg[0x06] & 0x07) |
| 73 | (m_reg[0x06] & 0x07) |
| 71 | 74 | |
| 72 | 75 | #define VISIBLE_DATA_ROWS_PER_FRAME \ |
| 73 | | (crt9007->reg[0x07] + 1) |
| 76 | (m_reg[0x07] + 1) |
| 74 | 77 | |
| 75 | 78 | #define SCAN_LINES_PER_DATA_ROW \ |
| 76 | | ((crt9007->reg[0x08] & 0x1f) + 1) |
| 79 | ((m_reg[0x08] & 0x1f) + 1) |
| 77 | 80 | |
| 78 | 81 | #define SCAN_LINES_PER_FRAME \ |
| 79 | | (((crt9007->reg[0x08] << 3) & 0x0700) | crt9007->reg[0x09]) |
| 82 | (((m_reg[0x08] << 3) & 0x0700) | m_reg[0x09]) |
| 80 | 83 | |
| 81 | 84 | #define DMA_BURST_COUNT \ |
| 82 | | (crt9007->reg[0x0a] & 0x0f) |
| 85 | (m_reg[0x0a] & 0x0f) |
| 83 | 86 | |
| 84 | 87 | #define DMA_BURST_DELAY \ |
| 85 | | ((crt9007->reg[0x0a] >> 4) & 0x07) |
| 88 | ((m_reg[0x0a] >> 4) & 0x07) |
| 86 | 89 | |
| 87 | 90 | #define DMA_DISABLE \ |
| 88 | | BIT(crt9007->reg[0x0a], 7) |
| 91 | BIT(m_reg[0x0a], 7) |
| 89 | 92 | |
| 90 | 93 | #define SINGLE_HEIGHT_CURSOR \ |
| 91 | | BIT(crt9007->reg[0x0b], 0) |
| 94 | BIT(m_reg[0x0b], 0) |
| 92 | 95 | |
| 93 | 96 | #define OPERATION_MODE \ |
| 94 | | ((crt9007->reg[0x0b] >> 1) & 0x07) |
| 97 | ((m_reg[0x0b] >> 1) & 0x07) |
| 95 | 98 | |
| 96 | 99 | #define INTERLACE_MODE \ |
| 97 | | ((crt9007->reg[0x0b] >> 4) & 0x03) |
| 100 | ((m_reg[0x0b] >> 4) & 0x03) |
| 98 | 101 | |
| 99 | 102 | #define PAGE_BLANK \ |
| 100 | | BIT(crt9007->reg[0x0b], 6) |
| 103 | BIT(m_reg[0x0b], 6) |
| 101 | 104 | |
| 102 | 105 | #define TABLE_START \ |
| 103 | | (((crt9007->reg[0x0d] << 8) & 0x3f00) | crt9007->reg[0x0c]) |
| 106 | (((m_reg[0x0d] << 8) & 0x3f00) | m_reg[0x0c]) |
| 104 | 107 | |
| 105 | 108 | #define ADDRESS_MODE \ |
| 106 | | ((crt9007->reg[0x0d] >> 6) & 0x03) |
| 109 | ((m_reg[0x0d] >> 6) & 0x03) |
| 107 | 110 | |
| 108 | 111 | #define AUXILIARY_ADDRESS_1 \ |
| 109 | | (((crt9007->reg[0x0f] << 8) & 0x3f00) | crt9007->reg[0x0e]) |
| 112 | (((m_reg[0x0f] << 8) & 0x3f00) | m_reg[0x0e]) |
| 110 | 113 | |
| 111 | 114 | #define ROW_ATTRIBUTES_1 \ |
| 112 | | ((crt9007->reg[0x0f] >> 6) & 0x03) |
| 115 | ((m_reg[0x0f] >> 6) & 0x03) |
| 113 | 116 | |
| 114 | 117 | #define SEQUENTIAL_BREAK_1 \ |
| 115 | | crt9007->reg[0x10] |
| 118 | m_reg[0x10] |
| 116 | 119 | |
| 117 | 120 | #define SEQUENTIAL_BREAK_2 \ |
| 118 | | crt9007->reg[0x12] |
| 121 | m_reg[0x12] |
| 119 | 122 | |
| 120 | 123 | #define DATA_ROW_START \ |
| 121 | | crt9007->reg[0x11] |
| 124 | m_reg[0x11] |
| 122 | 125 | |
| 123 | 126 | #define DATA_ROW_END \ |
| 124 | | crt9007->reg[0x12] |
| 127 | m_reg[0x12] |
| 125 | 128 | |
| 126 | 129 | #define AUXILIARY_ADDRESS_2 \ |
| 127 | | (((crt9007->reg[0x14] << 8) & 0x3f00) | crt9007->reg[0x13]) |
| 130 | (((m_reg[0x14] << 8) & 0x3f00) | m_reg[0x13]) |
| 128 | 131 | |
| 129 | 132 | #define ROW_ATTRIBUTES_2 \ |
| 130 | | ((crt9007->reg[0x14] >> 6) & 0x03) |
| 133 | ((m_reg[0x14] >> 6) & 0x03) |
| 131 | 134 | |
| 132 | 135 | #define SMOOTH_SCROLL_OFFSET \ |
| 133 | | ((crt9007->reg[0x17] >> 1) & 0x3f) |
| 136 | ((m_reg[0x17] >> 1) & 0x3f) |
| 134 | 137 | |
| 135 | 138 | #define SMOOTH_SCROLL_OFFSET_OVERFLOW \ |
| 136 | | BIT(crt9007->reg[0x17], 7) |
| 139 | BIT(m_reg[0x17], 7) |
| 137 | 140 | |
| 138 | 141 | #define VERTICAL_CURSOR \ |
| 139 | | crt9007->reg[0x18] |
| 142 | m_reg[0x18] |
| 140 | 143 | |
| 141 | 144 | #define HORIZONTAL_CURSOR \ |
| 142 | | crt9007->reg[0x19] |
| 145 | m_reg[0x19] |
| 143 | 146 | |
| 144 | 147 | #define FRAME_TIMER \ |
| 145 | | BIT(crt9007->reg[0x1a], 0) |
| 148 | BIT(m_reg[0x1a], 0) |
| 146 | 149 | |
| 147 | 150 | #define LIGHT_PEN_INTERRUPT \ |
| 148 | | BIT(crt9007->reg[0x1a], 5) |
| 151 | BIT(m_reg[0x1a], 5) |
| 149 | 152 | |
| 150 | 153 | #define VERTICAL_RETRACE_INTERRUPT \ |
| 151 | | BIT(crt9007->reg[0x1a], 6) |
| 154 | BIT(m_reg[0x1a], 6) |
| 152 | 155 | |
| 153 | 156 | #define VERTICAL_LIGHT_PEN \ |
| 154 | | crt9007->reg[0x3b] |
| 157 | m_reg[0x3b] |
| 155 | 158 | |
| 156 | 159 | #define HORIZONTAL_LIGHT_PEN \ |
| 157 | | crt9007->reg[0x3c] |
| 160 | m_reg[0x3c] |
| 158 | 161 | |
| 162 | |
| 163 | // interlace |
| 159 | 164 | enum |
| 160 | 165 | { |
| 161 | 166 | NON_INTERLACED = 0, |
| r9643 | r9644 | |
| 163 | 168 | NORMAL_VIDEO_INTERFACE, |
| 164 | 169 | }; |
| 165 | 170 | |
| 171 | |
| 172 | // operation modes |
| 166 | 173 | enum |
| 167 | 174 | { |
| 168 | 175 | OPERATION_MODE_REPETITIVE_MEMORY_ADDRESSING = 0, |
| r9643 | r9644 | |
| 171 | 178 | OPERATION_MODE_ATTRIBUTE_ASSEMBLE = 7 |
| 172 | 179 | }; |
| 173 | 180 | |
| 181 | |
| 182 | // addressing modes |
| 174 | 183 | enum |
| 175 | 184 | { |
| 176 | 185 | ADDRESS_MODE_SEQUENTIAL_ADDRESSING = 0, |
| r9643 | r9644 | |
| 179 | 188 | ADDRESS_MODE_LINKED_LIST_ROW_TABLE |
| 180 | 189 | }; |
| 181 | 190 | |
| 182 | | #define STATUS_INTERRUPT_PENDING 0x80 |
| 183 | | #define STATUS_VERTICAL_RETRACE 0x40 |
| 184 | | #define STATUS_LIGHT_PEN_UPDATE 0x20 |
| 185 | | #define STATUS_ODD_EVEN 0x04 |
| 186 | | #define STATUS_FRAME_TIMER_OCCURRED 0x01 |
| 187 | 191 | |
| 188 | | /*************************************************************************** |
| 189 | | TYPE DEFINITIONS |
| 190 | | ***************************************************************************/ |
| 192 | // status register bits |
| 193 | const int STATUS_INTERRUPT_PENDING = 0x80; |
| 194 | const int STATUS_VERTICAL_RETRACE = 0x40; |
| 195 | const int STATUS_LIGHT_PEN_UPDATE = 0x20; |
| 196 | const int STATUS_ODD_EVEN = 0x04; |
| 197 | const int STATUS_FRAME_TIMER_OCCURRED = 0x01; |
| 191 | 198 | |
| 192 | | typedef struct _crt9007_t crt9007_t; |
| 193 | | struct _crt9007_t |
| 194 | | { |
| 195 | | devcb_resolved_write_line out_int_func; |
| 196 | | devcb_resolved_write_line out_dmar_func; |
| 197 | | devcb_resolved_write_line out_hs_func; |
| 198 | | devcb_resolved_write_line out_vs_func; |
| 199 | | devcb_resolved_read8 in_vd_func; |
| 200 | 199 | |
| 201 | | crt9007_draw_scanline_func draw_scanline_func; |
| 202 | 200 | |
| 203 | | screen_device *screen; /* screen */ |
| 201 | //************************************************************************** |
| 202 | // GLOBAL VARIABLES |
| 203 | //************************************************************************** |
| 204 | 204 | |
| 205 | | /* registers */ |
| 206 | | UINT8 reg[0x3d]; |
| 207 | | UINT8 status; |
| 205 | // devices |
| 206 | const device_type CRT9007 = crt9007_device_config::static_alloc_device_config; |
| 208 | 207 | |
| 209 | | int disp; |
| 210 | | int hpixels_per_column; |
| 211 | 208 | |
| 212 | | /* runtime variables, do not state save */ |
| 213 | | int vsync_start; |
| 214 | | int vsync_end; |
| 215 | | int vfp; |
| 216 | | int hsync_start; |
| 217 | | int hsync_end; |
| 218 | | int hfp; |
| 209 | // default address map |
| 210 | static ADDRESS_MAP_START( crt9007, 0, 8 ) |
| 211 | AM_RANGE(0x0000, 0x3fff) AM_RAM |
| 212 | ADDRESS_MAP_END |
| 219 | 213 | |
| 220 | | /* timers */ |
| 221 | | emu_timer *vsync_timer; /* vertical sync timer */ |
| 222 | | emu_timer *hsync_timer; /* horizontal sync timer */ |
| 223 | | }; |
| 224 | 214 | |
| 225 | | /*************************************************************************** |
| 226 | | INLINE FUNCTIONS |
| 227 | | ***************************************************************************/ |
| 228 | 215 | |
| 229 | | INLINE crt9007_t *get_safe_token(running_device *device) |
| 216 | //************************************************************************** |
| 217 | // DEVICE CONFIGURATION |
| 218 | //************************************************************************** |
| 219 | |
| 220 | //------------------------------------------------- |
| 221 | // crt9007_device_config - constructor |
| 222 | //------------------------------------------------- |
| 223 | |
| 224 | crt9007_device_config::crt9007_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 225 | : device_config(mconfig, static_alloc_device_config, "SMC CRT9007", tag, owner, clock), |
| 226 | device_config_memory_interface(mconfig, *this), |
| 227 | m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(crt9007)) |
| 230 | 228 | { |
| 231 | | assert(device != NULL); |
| 232 | | return (crt9007_t *)downcast<legacy_device_base *>(device)->token(); |
| 233 | 229 | } |
| 234 | 230 | |
| 235 | | INLINE const crt9007_interface *get_interface(running_device *device) |
| 231 | |
| 232 | //------------------------------------------------- |
| 233 | // static_alloc_device_config - allocate a new |
| 234 | // configuration object |
| 235 | //------------------------------------------------- |
| 236 | |
| 237 | device_config *crt9007_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 236 | 238 | { |
| 237 | | assert(device != NULL); |
| 238 | | assert(device->type() == CRT9007); |
| 239 | | return (const crt9007_interface *) device->baseconfig().static_config(); |
| 239 | return global_alloc(crt9007_device_config(mconfig, tag, owner, clock)); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | | /*************************************************************************** |
| 243 | | IMPLEMENTATION |
| 244 | | ***************************************************************************/ |
| 245 | 242 | |
| 246 | | /*------------------------------------------------- |
| 247 | | update_vsync_timer - |
| 248 | | -------------------------------------------------*/ |
| 243 | //------------------------------------------------- |
| 244 | // alloc_device - allocate a new device object |
| 245 | //------------------------------------------------- |
| 249 | 246 | |
| 250 | | static void update_vsync_timer(crt9007_t *crt9007, int state) |
| 247 | device_t *crt9007_device_config::alloc_device(running_machine &machine) const |
| 251 | 248 | { |
| 252 | | int next_y = state ? crt9007->vsync_start : crt9007->vsync_end; |
| 249 | return auto_alloc(&machine, crt9007_device(machine, *this)); |
| 250 | } |
| 253 | 251 | |
| 254 | | attotime duration = crt9007->screen->time_until_pos(next_y, 0); |
| 255 | 252 | |
| 256 | | timer_adjust_oneshot(crt9007->vsync_timer, duration, !state); |
| 253 | //------------------------------------------------- |
| 254 | // memory_space_config - return a description of |
| 255 | // any address spaces owned by this device |
| 256 | //------------------------------------------------- |
| 257 | |
| 258 | const address_space_config *crt9007_device_config::memory_space_config(int spacenum) const |
| 259 | { |
| 260 | return (spacenum == 0) ? &m_space_config : NULL; |
| 257 | 261 | } |
| 258 | 262 | |
| 259 | | /*------------------------------------------------- |
| 260 | | TIMER_CALLBACK( vsync_tick ) |
| 261 | | -------------------------------------------------*/ |
| 262 | 263 | |
| 263 | | static TIMER_CALLBACK( vsync_tick ) |
| 264 | //------------------------------------------------- |
| 265 | // device_config_complete - perform any |
| 266 | // operations now that the configuration is |
| 267 | // complete |
| 268 | //------------------------------------------------- |
| 269 | |
| 270 | void crt9007_device_config::device_config_complete() |
| 264 | 271 | { |
| 265 | | running_device *device = (running_device *)ptr; |
| 266 | | crt9007_t *crt9007 = get_safe_token(device); |
| 272 | // inherit a copy of the static data |
| 273 | const crt9007_interface *intf = reinterpret_cast<const crt9007_interface *>(static_config()); |
| 274 | if (intf != NULL) |
| 275 | *static_cast<crt9007_interface *>(this) = *intf; |
| 267 | 276 | |
| 268 | | devcb_call_write_line(&crt9007->out_vs_func, param); |
| 277 | // or initialize to defaults if none provided |
| 278 | else |
| 279 | { |
| 280 | memset(&out_int_func, 0, sizeof(out_int_func)); |
| 281 | memset(&out_dmar_func, 0, sizeof(out_dmar_func)); |
| 282 | memset(&out_vs_func, 0, sizeof(out_vs_func)); |
| 283 | memset(&out_hs_func, 0, sizeof(out_hs_func)); |
| 284 | memset(&out_vlt_func, 0, sizeof(out_vlt_func)); |
| 285 | memset(&out_curs_func, 0, sizeof(out_curs_func)); |
| 286 | memset(&out_drb_func, 0, sizeof(out_drb_func)); |
| 287 | memset(&out_slg_func, 0, sizeof(out_slg_func)); |
| 288 | memset(&out_sld_func, 0, sizeof(out_sld_func)); |
| 289 | } |
| 290 | } |
| 269 | 291 | |
| 270 | | update_vsync_timer(crt9007, param); |
| 292 | |
| 293 | |
| 294 | //************************************************************************** |
| 295 | // INLINE HELPERS |
| 296 | //************************************************************************** |
| 297 | |
| 298 | //------------------------------------------------- |
| 299 | // readbyte - read a byte at the given address |
| 300 | //------------------------------------------------- |
| 301 | |
| 302 | inline UINT8 crt9007_device::readbyte(offs_t address) |
| 303 | { |
| 304 | return space()->read_byte(address); |
| 271 | 305 | } |
| 272 | 306 | |
| 273 | | /*------------------------------------------------- |
| 274 | | update_hsync_timer - |
| 275 | | -------------------------------------------------*/ |
| 276 | 307 | |
| 277 | | static void update_hsync_timer(crt9007_t *crt9007, int state) |
| 308 | //------------------------------------------------- |
| 309 | // update_hsync_timer - |
| 310 | //------------------------------------------------- |
| 311 | |
| 312 | inline void crt9007_device::update_hsync_timer(int state) |
| 278 | 313 | { |
| 279 | | int y = crt9007->screen->vpos(); |
| 314 | int y = m_screen->vpos(); |
| 280 | 315 | |
| 281 | | int next_x = state ? crt9007->hsync_start : crt9007->hsync_end; |
| 316 | int next_x = state ? m_hsync_start : m_hsync_end; |
| 282 | 317 | int next_y = (y + 1) % SCAN_LINES_PER_FRAME; |
| 283 | 318 | |
| 284 | | attotime duration = crt9007->screen->time_until_pos(next_y, next_x); |
| 319 | attotime duration = m_screen->time_until_pos(next_y, next_x); |
| 285 | 320 | |
| 286 | | timer_adjust_oneshot(crt9007->hsync_timer, duration, !state); |
| 321 | timer_adjust_oneshot(m_hsync_timer, duration, !state); |
| 287 | 322 | } |
| 288 | 323 | |
| 289 | | /*------------------------------------------------- |
| 290 | | TIMER_CALLBACK( hsync_tick ) |
| 291 | | -------------------------------------------------*/ |
| 292 | 324 | |
| 293 | | static TIMER_CALLBACK( hsync_tick ) |
| 325 | //------------------------------------------------- |
| 326 | // update_vsync_timer - |
| 327 | //------------------------------------------------- |
| 328 | |
| 329 | inline void crt9007_device::update_vsync_timer(int state) |
| 294 | 330 | { |
| 295 | | running_device *device = (running_device *)ptr; |
| 296 | | crt9007_t *crt9007 = get_safe_token(device); |
| 331 | int next_y = state ? m_vsync_start : m_vsync_end; |
| 297 | 332 | |
| 298 | | devcb_call_write_line(&crt9007->out_hs_func, param); |
| 333 | attotime duration = m_screen->time_until_pos(next_y, 0); |
| 299 | 334 | |
| 300 | | update_hsync_timer(crt9007, param); |
| 335 | timer_adjust_oneshot(m_vsync_timer, duration, !state); |
| 301 | 336 | } |
| 302 | 337 | |
| 303 | | /*------------------------------------------------- |
| 304 | | recompute_parameters - |
| 305 | | -------------------------------------------------*/ |
| 306 | 338 | |
| 307 | | static void recompute_parameters(running_device *device) |
| 339 | //------------------------------------------------- |
| 340 | // update_vlt_timer - |
| 341 | //------------------------------------------------- |
| 342 | |
| 343 | inline void crt9007_device::update_vlt_timer(int state) |
| 308 | 344 | { |
| 309 | | crt9007_t *crt9007 = get_safe_token(device); |
| 345 | // TODO |
| 346 | } |
| 310 | 347 | |
| 311 | | /* check that necessary registers have been loaded */ |
| 348 | |
| 349 | //------------------------------------------------- |
| 350 | // update_curs_timer - |
| 351 | //------------------------------------------------- |
| 352 | |
| 353 | inline void crt9007_device::update_curs_timer(int state) |
| 354 | { |
| 355 | // TODO |
| 356 | } |
| 357 | |
| 358 | |
| 359 | //------------------------------------------------- |
| 360 | // update_drb_timer - |
| 361 | //------------------------------------------------- |
| 362 | |
| 363 | inline void crt9007_device::update_drb_timer(int state) |
| 364 | { |
| 365 | // TODO |
| 366 | } |
| 367 | |
| 368 | |
| 369 | //------------------------------------------------- |
| 370 | // recompute_parameters - |
| 371 | //------------------------------------------------- |
| 372 | |
| 373 | inline void crt9007_device::recompute_parameters() |
| 374 | { |
| 375 | // check that necessary registers have been loaded |
| 312 | 376 | if (!HAS_VALID_PARAMETERS) return; |
| 313 | 377 | |
| 314 | | int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * crt9007->hpixels_per_column; |
| 378 | int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * m_hpixels_per_column; |
| 315 | 379 | int vert_pix_total = SCAN_LINES_PER_FRAME; |
| 316 | 380 | |
| 317 | | attoseconds_t refresh = HZ_TO_ATTOSECONDS(device->clock()) * horiz_pix_total * vert_pix_total; |
| 381 | attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock()) * horiz_pix_total * vert_pix_total; |
| 318 | 382 | |
| 319 | | crt9007->hsync_start = (CHARACTERS_PER_HORIZONTAL_PERIOD - HORIZONTAL_SYNC_WIDTH) * crt9007->hpixels_per_column; |
| 320 | | crt9007->hsync_end = 0; |
| 321 | | crt9007->hfp = (HORIZONTAL_DELAY - HORIZONTAL_SYNC_WIDTH) * crt9007->hpixels_per_column; |
| 383 | m_hsync_start = (CHARACTERS_PER_HORIZONTAL_PERIOD - HORIZONTAL_SYNC_WIDTH) * m_hpixels_per_column; |
| 384 | m_hsync_end = 0; |
| 385 | m_hfp = (HORIZONTAL_DELAY - HORIZONTAL_SYNC_WIDTH) * m_hpixels_per_column; |
| 322 | 386 | |
| 323 | | crt9007->vsync_start = SCAN_LINES_PER_FRAME - VERTICAL_SYNC_WIDTH; |
| 324 | | crt9007->vsync_end = 0; |
| 325 | | crt9007->vfp = VERTICAL_DELAY - VERTICAL_SYNC_WIDTH; |
| 387 | m_vsync_start = SCAN_LINES_PER_FRAME - VERTICAL_SYNC_WIDTH; |
| 388 | m_vsync_end = 0; |
| 389 | m_vfp = VERTICAL_DELAY - VERTICAL_SYNC_WIDTH; |
| 326 | 390 | |
| 327 | 391 | rectangle visarea; |
| 328 | 392 | |
| 329 | | visarea.min_x = crt9007->hsync_end; |
| 330 | | visarea.max_x = crt9007->hsync_start - 1; |
| 393 | visarea.min_x = m_hsync_end; |
| 394 | visarea.max_x = m_hsync_start - 1; |
| 331 | 395 | |
| 332 | | visarea.min_y = crt9007->vsync_end; |
| 333 | | visarea.max_y = crt9007->vsync_start - 1; |
| 396 | visarea.min_y = m_vsync_end; |
| 397 | visarea.max_y = m_vsync_start - 1; |
| 334 | 398 | |
| 335 | 399 | if (LOG) |
| 336 | 400 | { |
| 337 | | logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", device->tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 338 | | logerror("CRT9007 '%s' Visible Area: (%u, %u) - (%u, %u)\n", device->tag(), visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y); |
| 401 | logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 402 | logerror("CRT9007 '%s' Visible Area: (%u, %u) - (%u, %u)\n", tag(), visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y); |
| 339 | 403 | } |
| 340 | 404 | |
| 341 | | crt9007->screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh); |
| 405 | m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh); |
| 342 | 406 | |
| 343 | | update_hsync_timer(crt9007, 1); |
| 344 | | update_vsync_timer(crt9007, 1); |
| 407 | update_hsync_timer(1); |
| 408 | update_vsync_timer(1); |
| 409 | update_vlt_timer(1); |
| 410 | update_curs_timer(1); |
| 411 | update_drb_timer(1); |
| 345 | 412 | } |
| 346 | 413 | |
| 347 | | /*------------------------------------------------- |
| 348 | | crt9007_r - register read |
| 349 | | -------------------------------------------------*/ |
| 350 | 414 | |
| 351 | | READ8_DEVICE_HANDLER( crt9007_r ) |
| 415 | //************************************************************************** |
| 416 | // LIVE DEVICE |
| 417 | //************************************************************************** |
| 418 | |
| 419 | //------------------------------------------------- |
| 420 | // crt9007_device - constructor |
| 421 | //------------------------------------------------- |
| 422 | |
| 423 | crt9007_device::crt9007_device(running_machine &_machine, const crt9007_device_config &config) |
| 424 | : device_t(_machine, config), |
| 425 | device_memory_interface(_machine, config, *this), |
| 426 | m_config(config) |
| 352 | 427 | { |
| 353 | | crt9007_t *crt9007 = get_safe_token(device); |
| 428 | for (int i = 0; i < 0x3d; i++) |
| 429 | m_reg[i] = 0; |
| 430 | } |
| 354 | 431 | |
| 432 | |
| 433 | //------------------------------------------------- |
| 434 | // device_start - device-specific startup |
| 435 | //------------------------------------------------- |
| 436 | |
| 437 | void crt9007_device::device_start() |
| 438 | { |
| 439 | // allocate timers |
| 440 | m_hsync_timer = device_timer_alloc(*this, TIMER_HSYNC); |
| 441 | m_vsync_timer = device_timer_alloc(*this, TIMER_VSYNC); |
| 442 | m_vlt_timer = device_timer_alloc(*this, TIMER_VLT); |
| 443 | m_curs_timer = device_timer_alloc(*this, TIMER_CURS); |
| 444 | m_drb_timer = device_timer_alloc(*this, TIMER_DRB); |
| 445 | |
| 446 | // resolve callbacks |
| 447 | devcb_resolve_write_line(&m_out_int_func, &m_config.out_int_func, this); |
| 448 | devcb_resolve_write_line(&m_out_dmar_func, &m_config.out_dmar_func, this); |
| 449 | devcb_resolve_write_line(&m_out_hs_func, &m_config.out_hs_func, this); |
| 450 | devcb_resolve_write_line(&m_out_vs_func, &m_config.out_vs_func, this); |
| 451 | devcb_resolve_write_line(&m_out_vlt_func, &m_config.out_vlt_func, this); |
| 452 | devcb_resolve_write_line(&m_out_curs_func, &m_config.out_curs_func, this); |
| 453 | devcb_resolve_write_line(&m_out_drb_func, &m_config.out_drb_func, this); |
| 454 | |
| 455 | // get the screen device |
| 456 | m_screen = machine->device<screen_device>(m_config.screen_tag); |
| 457 | assert(m_screen != NULL); |
| 458 | |
| 459 | // set horizontal pixels per column |
| 460 | m_hpixels_per_column = m_config.hpixels_per_column; |
| 461 | |
| 462 | // register for state saving |
| 463 | // state_save_register_device_item(this, 0, ); |
| 464 | } |
| 465 | |
| 466 | |
| 467 | //------------------------------------------------- |
| 468 | // device_reset - device-specific reset |
| 469 | //------------------------------------------------- |
| 470 | |
| 471 | void crt9007_device::device_reset() |
| 472 | { |
| 473 | m_disp = 0; |
| 474 | |
| 475 | // HS = 1 |
| 476 | devcb_call_write_line(&m_out_hs_func, 1); |
| 477 | |
| 478 | // VS = 1 |
| 479 | devcb_call_write_line(&m_out_vs_func, 1); |
| 480 | |
| 481 | // CBLANK = 1 |
| 482 | // devcb_call_write_line(&m_out_cblank_func, 0); |
| 483 | |
| 484 | // CURS = 0 |
| 485 | devcb_call_write_line(&m_out_curs_func, 0); |
| 486 | |
| 487 | // VLT = 0 |
| 488 | devcb_call_write_line(&m_out_vlt_func, 0); |
| 489 | |
| 490 | // DRB = 1 |
| 491 | devcb_call_write_line(&m_out_drb_func, 1); |
| 492 | |
| 493 | // INT = 0 |
| 494 | devcb_call_write_line(&m_out_int_func, CLEAR_LINE); |
| 495 | |
| 496 | // 28 (DMAR) = 0 |
| 497 | devcb_call_write_line(&m_out_dmar_func, CLEAR_LINE); |
| 498 | |
| 499 | // 29 (WBEN) = 0 |
| 500 | |
| 501 | // 30 (SLG) = 0 |
| 502 | // devcb_call_write_line(&m_out_slg_func, 0); |
| 503 | |
| 504 | // 31 (SLD) = 0 |
| 505 | // devcb_call_write_line(&m_out_sld_func, 0); |
| 506 | |
| 507 | // 32 (LPSTB) = 0 |
| 508 | } |
| 509 | |
| 510 | |
| 511 | //------------------------------------------------- |
| 512 | // device_clock_changed - handle clock change |
| 513 | //------------------------------------------------- |
| 514 | |
| 515 | void crt9007_device::device_clock_changed() |
| 516 | { |
| 517 | recompute_parameters(); |
| 518 | } |
| 519 | |
| 520 | |
| 521 | //------------------------------------------------- |
| 522 | // device_timer - handle timer events |
| 523 | //------------------------------------------------- |
| 524 | |
| 525 | void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 526 | { |
| 527 | switch (id) |
| 528 | { |
| 529 | case TIMER_HSYNC: |
| 530 | devcb_call_write_line(&m_out_hs_func, param); |
| 531 | update_hsync_timer(param); |
| 532 | break; |
| 533 | |
| 534 | case TIMER_VSYNC: |
| 535 | devcb_call_write_line(&m_out_vs_func, param); |
| 536 | update_vsync_timer(param); |
| 537 | break; |
| 538 | |
| 539 | case TIMER_VLT: |
| 540 | devcb_call_write_line(&m_out_vlt_func, param); |
| 541 | update_vlt_timer(param); |
| 542 | break; |
| 543 | |
| 544 | case TIMER_CURS: |
| 545 | devcb_call_write_line(&m_out_curs_func, param); |
| 546 | update_curs_timer(param); |
| 547 | break; |
| 548 | |
| 549 | case TIMER_DRB: |
| 550 | devcb_call_write_line(&m_out_drb_func, param); |
| 551 | update_drb_timer(param); |
| 552 | break; |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | |
| 557 | //------------------------------------------------- |
| 558 | // read - register read |
| 559 | //------------------------------------------------- |
| 560 | |
| 561 | READ8_MEMBER( crt9007_device::read ) |
| 562 | { |
| 355 | 563 | UINT8 data = 0; |
| 356 | 564 | |
| 357 | 565 | switch (offset) |
| 358 | 566 | { |
| 359 | 567 | case 0x15: |
| 360 | | crt9007->disp = 1; |
| 361 | | if (LOG) logerror("CRT9007 '%s' Start\n", device->tag()); |
| 568 | if (LOG) logerror("CRT9007 '%s' Start\n", tag()); |
| 569 | m_disp = 1; |
| 362 | 570 | break; |
| 363 | 571 | |
| 364 | 572 | case 0x16: |
| 365 | | crt9007->disp = 0; |
| 366 | | if (LOG) logerror("CRT9007 '%s' Reset\n", device->tag()); |
| 573 | if (LOG) logerror("CRT9007 '%s' Reset\n", tag()); |
| 574 | device_reset(); |
| 367 | 575 | break; |
| 368 | 576 | |
| 369 | 577 | case 0x38: |
| r9643 | r9644 | |
| 375 | 583 | break; |
| 376 | 584 | |
| 377 | 585 | case 0x3a: |
| 378 | | data = crt9007->status; |
| 586 | data = m_status; |
| 379 | 587 | break; |
| 380 | 588 | |
| 381 | 589 | case 0x3b: |
| r9643 | r9644 | |
| 387 | 595 | break; |
| 388 | 596 | |
| 389 | 597 | default: |
| 390 | | logerror("CRT9007 '%s' Read from Invalid Register: %02x!\n", device->tag(), offset); |
| 598 | logerror("CRT9007 '%s' Read from Invalid Register: %02x!\n", tag(), offset); |
| 391 | 599 | } |
| 392 | 600 | |
| 393 | 601 | return data; |
| 394 | 602 | } |
| 395 | 603 | |
| 396 | | /*------------------------------------------------- |
| 397 | | crt9007_w - register write |
| 398 | | -------------------------------------------------*/ |
| 399 | 604 | |
| 400 | | WRITE8_DEVICE_HANDLER( crt9007_w ) |
| 605 | //------------------------------------------------- |
| 606 | // write - register write |
| 607 | //------------------------------------------------- |
| 608 | |
| 609 | WRITE8_MEMBER( crt9007_device::write ) |
| 401 | 610 | { |
| 402 | | crt9007_t *crt9007 = get_safe_token(device); |
| 611 | m_reg[offset] = data; |
| 403 | 612 | |
| 404 | | crt9007->reg[offset] = data; |
| 405 | | |
| 406 | 613 | switch (offset) |
| 407 | 614 | { |
| 408 | 615 | case 0x00: |
| 409 | | recompute_parameters(device); |
| 410 | | if (LOG) logerror("CRT9007 '%s' Characters per Horizontal Period: %u\n", device->tag(), CHARACTERS_PER_HORIZONTAL_PERIOD); |
| 616 | recompute_parameters(); |
| 617 | if (LOG) logerror("CRT9007 '%s' Characters per Horizontal Period: %u\n", tag(), CHARACTERS_PER_HORIZONTAL_PERIOD); |
| 411 | 618 | break; |
| 412 | 619 | |
| 413 | 620 | case 0x01: |
| 414 | | recompute_parameters(device); |
| 415 | | if (LOG) logerror("CRT9007 '%s' Characters per Data Row: %u\n", device->tag(), CHARACTERS_PER_DATA_ROW); |
| 621 | recompute_parameters(); |
| 622 | if (LOG) logerror("CRT9007 '%s' Characters per Data Row: %u\n", tag(), CHARACTERS_PER_DATA_ROW); |
| 416 | 623 | break; |
| 417 | 624 | |
| 418 | 625 | case 0x02: |
| 419 | | recompute_parameters(device); |
| 420 | | if (LOG) logerror("CRT9007 '%s' Horizontal Delay: %u\n", device->tag(), HORIZONTAL_DELAY); |
| 626 | recompute_parameters(); |
| 627 | if (LOG) logerror("CRT9007 '%s' Horizontal Delay: %u\n", tag(), HORIZONTAL_DELAY); |
| 421 | 628 | break; |
| 422 | 629 | |
| 423 | 630 | case 0x03: |
| 424 | | recompute_parameters(device); |
| 425 | | if (LOG) logerror("CRT9007 '%s' Horizontal Sync Width: %u\n", device->tag(), HORIZONTAL_SYNC_WIDTH); |
| 631 | recompute_parameters(); |
| 632 | if (LOG) logerror("CRT9007 '%s' Horizontal Sync Width: %u\n", tag(), HORIZONTAL_SYNC_WIDTH); |
| 426 | 633 | break; |
| 427 | 634 | |
| 428 | 635 | case 0x04: |
| 429 | | recompute_parameters(device); |
| 430 | | if (LOG) logerror("CRT9007 '%s' Vertical Sync Width: %u\n", device->tag(), VERTICAL_SYNC_WIDTH); |
| 636 | recompute_parameters(); |
| 637 | if (LOG) logerror("CRT9007 '%s' Vertical Sync Width: %u\n", tag(), VERTICAL_SYNC_WIDTH); |
| 431 | 638 | break; |
| 432 | 639 | |
| 433 | 640 | case 0x05: |
| 434 | | recompute_parameters(device); |
| 435 | | if (LOG) logerror("CRT9007 '%s' Vertical Delay: %u\n", device->tag(), VERTICAL_DELAY); |
| 641 | recompute_parameters(); |
| 642 | if (LOG) logerror("CRT9007 '%s' Vertical Delay: %u\n", tag(), VERTICAL_DELAY); |
| 436 | 643 | break; |
| 437 | 644 | |
| 438 | 645 | case 0x06: |
| 439 | | recompute_parameters(device); |
| 646 | recompute_parameters(); |
| 440 | 647 | if (LOG) |
| 441 | 648 | { |
| 442 | | logerror("CRT9007 '%s' Pin Configuration: %u\n", device->tag(), PIN_CONFIGURATION); |
| 443 | | logerror("CRT9007 '%s' Cursor Skew: %u\n", device->tag(), CURSOR_SKEW); |
| 444 | | logerror("CRT9007 '%s' Blank Skew: %u\n", device->tag(), BLANK_SKEW); |
| 649 | logerror("CRT9007 '%s' Pin Configuration: %u\n", tag(), PIN_CONFIGURATION); |
| 650 | logerror("CRT9007 '%s' Cursor Skew: %u\n", tag(), CURSOR_SKEW); |
| 651 | logerror("CRT9007 '%s' Blank Skew: %u\n", tag(), BLANK_SKEW); |
| 445 | 652 | } |
| 446 | 653 | break; |
| 447 | 654 | |
| 448 | 655 | case 0x07: |
| 449 | | recompute_parameters(device); |
| 450 | | if (LOG) logerror("CRT9007 '%s' Visible Data Rows per Frame: %u\n", device->tag(), VISIBLE_DATA_ROWS_PER_FRAME); |
| 656 | recompute_parameters(); |
| 657 | if (LOG) logerror("CRT9007 '%s' Visible Data Rows per Frame: %u\n", tag(), VISIBLE_DATA_ROWS_PER_FRAME); |
| 451 | 658 | break; |
| 452 | 659 | |
| 453 | 660 | case 0x08: |
| 454 | | recompute_parameters(device); |
| 455 | | if (LOG) logerror("CRT9007 '%s' Scan Lines per Data Row: %u\n", device->tag(), SCAN_LINES_PER_DATA_ROW); |
| 661 | recompute_parameters(); |
| 662 | if (LOG) logerror("CRT9007 '%s' Scan Lines per Data Row: %u\n", tag(), SCAN_LINES_PER_DATA_ROW); |
| 456 | 663 | break; |
| 457 | 664 | |
| 458 | 665 | case 0x09: |
| 459 | | recompute_parameters(device); |
| 460 | | if (LOG) logerror("CRT9007 '%s' Scan Lines per Frame: %u\n", device->tag(), SCAN_LINES_PER_FRAME); |
| 666 | recompute_parameters(); |
| 667 | if (LOG) logerror("CRT9007 '%s' Scan Lines per Frame: %u\n", tag(), SCAN_LINES_PER_FRAME); |
| 461 | 668 | break; |
| 462 | 669 | |
| 463 | 670 | case 0x0a: |
| 464 | 671 | if (LOG) |
| 465 | 672 | { |
| 466 | | logerror("CRT9007 '%s' DMA Burst Count: %u\n", device->tag(), DMA_BURST_COUNT); |
| 467 | | logerror("CRT9007 '%s' DMA Burst Delay: %u\n", device->tag(), DMA_BURST_DELAY); |
| 468 | | logerror("CRT9007 '%s' DMA Disable: %u\n", device->tag(), DMA_DISABLE); |
| 673 | logerror("CRT9007 '%s' DMA Burst Count: %u\n", tag(), DMA_BURST_COUNT); |
| 674 | logerror("CRT9007 '%s' DMA Burst Delay: %u\n", tag(), DMA_BURST_DELAY); |
| 675 | logerror("CRT9007 '%s' DMA Disable: %u\n", tag(), DMA_DISABLE); |
| 469 | 676 | } |
| 470 | 677 | break; |
| 471 | 678 | |
| 472 | 679 | case 0x0b: |
| 473 | 680 | if (LOG) |
| 474 | 681 | { |
| 475 | | logerror("CRT9007 '%s' %s Height Cursor\n", device->tag(), SINGLE_HEIGHT_CURSOR ? "Single" : "Double"); |
| 476 | | logerror("CRT9007 '%s' Operation Mode: %u\n", device->tag(), OPERATION_MODE); |
| 477 | | logerror("CRT9007 '%s' Interlace Mode: %u\n", device->tag(), INTERLACE_MODE); |
| 478 | | logerror("CRT9007 '%s' %s Mechanism\n", device->tag(), PAGE_BLANK ? "Page Blank" : "Smooth Scroll"); |
| 682 | logerror("CRT9007 '%s' %s Height Cursor\n", tag(), SINGLE_HEIGHT_CURSOR ? "Single" : "Double"); |
| 683 | logerror("CRT9007 '%s' Operation Mode: %u\n", tag(), OPERATION_MODE); |
| 684 | logerror("CRT9007 '%s' Interlace Mode: %u\n", tag(), INTERLACE_MODE); |
| 685 | logerror("CRT9007 '%s' %s Mechanism\n", tag(), PAGE_BLANK ? "Page Blank" : "Smooth Scroll"); |
| 479 | 686 | } |
| 480 | 687 | break; |
| 481 | 688 | |
| r9643 | r9644 | |
| 485 | 692 | case 0x0d: |
| 486 | 693 | if (LOG) |
| 487 | 694 | { |
| 488 | | logerror("CRT9007 '%s' Table Start Register: %04x\n", device->tag(), TABLE_START); |
| 489 | | logerror("CRT9007 '%s' Address Mode: %u\n", device->tag(), ADDRESS_MODE); |
| 695 | logerror("CRT9007 '%s' Table Start Register: %04x\n", tag(), TABLE_START); |
| 696 | logerror("CRT9007 '%s' Address Mode: %u\n", tag(), ADDRESS_MODE); |
| 490 | 697 | } |
| 491 | 698 | break; |
| 492 | 699 | |
| r9643 | r9644 | |
| 496 | 703 | case 0x0f: |
| 497 | 704 | if (LOG) |
| 498 | 705 | { |
| 499 | | logerror("CRT9007 '%s' Auxialiary Address Register 1: %04x\n", device->tag(), AUXILIARY_ADDRESS_1); |
| 500 | | logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag(), ROW_ATTRIBUTES_1); |
| 706 | logerror("CRT9007 '%s' Auxialiary Address Register 1: %04x\n", tag(), AUXILIARY_ADDRESS_1); |
| 707 | logerror("CRT9007 '%s' Row Attributes: %u\n", tag(), ROW_ATTRIBUTES_1); |
| 501 | 708 | } |
| 502 | 709 | break; |
| 503 | 710 | |
| 504 | 711 | case 0x10: |
| 505 | | if (LOG) logerror("CRT9007 '%s' Sequential Break Register 1: %u\n", device->tag(), SEQUENTIAL_BREAK_1); |
| 712 | if (LOG) logerror("CRT9007 '%s' Sequential Break Register 1: %u\n", tag(), SEQUENTIAL_BREAK_1); |
| 506 | 713 | break; |
| 507 | 714 | |
| 508 | 715 | case 0x11: |
| 509 | | if (LOG) logerror("CRT9007 '%s' Data Row Start Register: %u\n", device->tag(), DATA_ROW_START); |
| 716 | if (LOG) logerror("CRT9007 '%s' Data Row Start Register: %u\n", tag(), DATA_ROW_START); |
| 510 | 717 | break; |
| 511 | 718 | |
| 512 | 719 | case 0x12: |
| 513 | | if (LOG) logerror("CRT9007 '%s' Data Row End/Sequential Break Register 2: %u\n", device->tag(), SEQUENTIAL_BREAK_2); |
| 720 | if (LOG) logerror("CRT9007 '%s' Data Row End/Sequential Break Register 2: %u\n", tag(), SEQUENTIAL_BREAK_2); |
| 514 | 721 | break; |
| 515 | 722 | |
| 516 | 723 | case 0x13: |
| r9643 | r9644 | |
| 519 | 726 | case 0x14: |
| 520 | 727 | if (LOG) |
| 521 | 728 | { |
| 522 | | logerror("CRT9007 '%s' Auxiliary Address Register 2: %04x\n", device->tag(), AUXILIARY_ADDRESS_2); |
| 523 | | logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag(), ROW_ATTRIBUTES_2); |
| 729 | logerror("CRT9007 '%s' Auxiliary Address Register 2: %04x\n", tag(), AUXILIARY_ADDRESS_2); |
| 730 | logerror("CRT9007 '%s' Row Attributes: %u\n", tag(), ROW_ATTRIBUTES_2); |
| 524 | 731 | } |
| 525 | 732 | break; |
| 526 | 733 | |
| 527 | 734 | case 0x15: |
| 528 | | crt9007->disp = 1; |
| 529 | | if (LOG) logerror("CRT9007 '%s' Start\n", device->tag()); |
| 735 | if (LOG) logerror("CRT9007 '%s' Start\n", tag()); |
| 736 | m_disp = 1; |
| 530 | 737 | break; |
| 531 | 738 | |
| 532 | 739 | case 0x16: |
| 533 | | crt9007->disp = 0; |
| 534 | | if (LOG) logerror("CRT9007 '%s' Reset\n", device->tag()); |
| 740 | if (LOG) logerror("CRT9007 '%s' Reset\n", tag()); |
| 741 | device_reset(); |
| 535 | 742 | break; |
| 536 | 743 | |
| 537 | 744 | case 0x17: |
| 538 | 745 | if (LOG) |
| 539 | 746 | { |
| 540 | | logerror("CRT9007 '%s' Smooth Scroll Offset: %u\n", device->tag(), SMOOTH_SCROLL_OFFSET); |
| 541 | | logerror("CRT9007 '%s' Smooth Scroll Offset Overflow: %u\n", device->tag(), SMOOTH_SCROLL_OFFSET_OVERFLOW); |
| 747 | logerror("CRT9007 '%s' Smooth Scroll Offset: %u\n", tag(), SMOOTH_SCROLL_OFFSET); |
| 748 | logerror("CRT9007 '%s' Smooth Scroll Offset Overflow: %u\n", tag(), SMOOTH_SCROLL_OFFSET_OVERFLOW); |
| 542 | 749 | } |
| 543 | 750 | break; |
| 544 | 751 | |
| 545 | 752 | case 0x18: |
| 546 | | if (LOG) logerror("CRT9007 '%s' Vertical Cursor Register: %u\n", device->tag(), VERTICAL_CURSOR); |
| 753 | if (LOG) logerror("CRT9007 '%s' Vertical Cursor Register: %u\n", tag(), VERTICAL_CURSOR); |
| 547 | 754 | break; |
| 548 | 755 | |
| 549 | 756 | case 0x19: |
| 550 | | if (LOG) logerror("CRT9007 '%s' Horizontal Cursor Register: %u\n", device->tag(), HORIZONTAL_CURSOR); |
| 757 | if (LOG) logerror("CRT9007 '%s' Horizontal Cursor Register: %u\n", tag(), HORIZONTAL_CURSOR); |
| 551 | 758 | break; |
| 552 | 759 | |
| 553 | 760 | case 0x1a: |
| 554 | 761 | if (LOG) |
| 555 | 762 | { |
| 556 | | logerror("CRT9007 '%s' Frame Timer: %u\n", device->tag(), FRAME_TIMER); |
| 557 | | logerror("CRT9007 '%s' Light Pen Interrupt: %u\n", device->tag(), LIGHT_PEN_INTERRUPT); |
| 558 | | logerror("CRT9007 '%s' Vertical Retrace Interrupt: %u\n", device->tag(), VERTICAL_RETRACE_INTERRUPT); |
| 763 | logerror("CRT9007 '%s' Frame Timer: %u\n", tag(), FRAME_TIMER); |
| 764 | logerror("CRT9007 '%s' Light Pen Interrupt: %u\n", tag(), LIGHT_PEN_INTERRUPT); |
| 765 | logerror("CRT9007 '%s' Vertical Retrace Interrupt: %u\n", tag(), VERTICAL_RETRACE_INTERRUPT); |
| 559 | 766 | } |
| 560 | 767 | break; |
| 561 | 768 | |
| 562 | 769 | default: |
| 563 | | logerror("CRT9007 '%s' Write to Invalid Register: %02x!\n", device->tag(), offset); |
| 770 | logerror("CRT9007 '%s' Write to Invalid Register: %02x!\n", tag(), offset); |
| 564 | 771 | } |
| 565 | 772 | } |
| 566 | 773 | |
| 567 | | /*------------------------------------------------- |
| 568 | | crt9007_ack_w - DMA acknowledge |
| 569 | | -------------------------------------------------*/ |
| 570 | 774 | |
| 571 | | WRITE8_DEVICE_HANDLER( crt9007_ack_w ) |
| 572 | | { |
| 573 | | } |
| 775 | //------------------------------------------------- |
| 776 | // ack_w - DMA acknowledge |
| 777 | //------------------------------------------------- |
| 574 | 778 | |
| 575 | | /*------------------------------------------------- |
| 576 | | crt9007_lpstb_w - light pen strobe |
| 577 | | -------------------------------------------------*/ |
| 578 | | |
| 579 | | WRITE_LINE_DEVICE_HANDLER( crt9007_lpstb_w ) |
| 779 | WRITE_LINE_MEMBER( crt9007_device::ack_w ) |
| 580 | 780 | { |
| 781 | // TODO |
| 581 | 782 | } |
| 582 | 783 | |
| 583 | | /*------------------------------------------------- |
| 584 | | crt9007_set_clock - set device clock |
| 585 | | -------------------------------------------------*/ |
| 586 | 784 | |
| 587 | | void crt9007_set_clock(running_device *device, UINT32 clock) |
| 588 | | { |
| 589 | | device->set_unscaled_clock(clock); |
| 590 | | recompute_parameters(device); |
| 591 | | } |
| 785 | //------------------------------------------------- |
| 786 | // lpstb_w - light pen strobe |
| 787 | //------------------------------------------------- |
| 592 | 788 | |
| 593 | | /*------------------------------------------------- |
| 594 | | crt9007_set_hpixels_per_column |
| 595 | | -------------------------------------------------*/ |
| 596 | | |
| 597 | | void crt9007_set_hpixels_per_column(running_device *device, int hpixels_per_column) |
| 789 | WRITE_LINE_MEMBER( crt9007_device::lpstb_w ) |
| 598 | 790 | { |
| 599 | | crt9007_t *crt9007 = get_safe_token(device); |
| 600 | | |
| 601 | | crt9007->hpixels_per_column = hpixels_per_column; |
| 602 | | recompute_parameters(device); |
| 791 | // TODO |
| 603 | 792 | } |
| 604 | 793 | |
| 605 | | /*------------------------------------------------- |
| 606 | | crt9007_update - update screen |
| 607 | | -------------------------------------------------*/ |
| 608 | 794 | |
| 609 | | void crt9007_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 610 | | { |
| 611 | | crt9007_t *crt9007 = get_safe_token(device); |
| 795 | //------------------------------------------------- |
| 796 | // set_hpixels_per_column - |
| 797 | //------------------------------------------------- |
| 612 | 798 | |
| 613 | | if (crt9007->disp && HAS_VALID_PARAMETERS) |
| 614 | | { |
| 615 | | int min_y = crt9007->vfp; |
| 616 | | int max_y = min_y + (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW); |
| 617 | | |
| 618 | | for (int y = min_y; y < max_y; y++) |
| 619 | | { |
| 620 | | int sl = (y - min_y) % SCAN_LINES_PER_DATA_ROW; |
| 621 | | int sy = (y - min_y) / SCAN_LINES_PER_DATA_ROW; |
| 622 | | int cursor_x = (sy == VERTICAL_CURSOR) ? HORIZONTAL_CURSOR : -1; |
| 623 | | UINT16 addr = TABLE_START + (sy * CHARACTERS_PER_DATA_ROW); |
| 624 | | // UINT8 data = devcb_call_read8(&crt9007->in_vd_func, addr); |
| 625 | | |
| 626 | | crt9007->draw_scanline_func(device, bitmap, cliprect, addr, sl, 0, y, crt9007->hfp, CHARACTERS_PER_DATA_ROW, cursor_x); |
| 627 | | |
| 628 | | addr++; |
| 629 | | } |
| 630 | | } |
| 631 | | else |
| 632 | | { |
| 633 | | bitmap_fill(bitmap, cliprect, get_black_pen(device->machine)); |
| 634 | | } |
| 635 | | } |
| 636 | | |
| 637 | | /*------------------------------------------------- |
| 638 | | DEVICE_START( crt9007 ) |
| 639 | | -------------------------------------------------*/ |
| 640 | | |
| 641 | | static DEVICE_START( crt9007 ) |
| 799 | void crt9007_device::set_hpixels_per_column(int hpixels_per_column) |
| 642 | 800 | { |
| 643 | | crt9007_t *crt9007 = (crt9007_t *)downcast<legacy_device_base *>(device)->token(); |
| 644 | | const crt9007_interface *intf = get_interface(device); |
| 645 | | |
| 646 | | /* resolve callbacks */ |
| 647 | | devcb_resolve_write_line(&crt9007->out_int_func, &intf->out_int_func, device); |
| 648 | | devcb_resolve_write_line(&crt9007->out_dmar_func, &intf->out_dmar_func, device); |
| 649 | | devcb_resolve_write_line(&crt9007->out_hs_func, &intf->out_hs_func, device); |
| 650 | | devcb_resolve_write_line(&crt9007->out_vs_func, &intf->out_vs_func, device); |
| 651 | | devcb_resolve_read8(&crt9007->in_vd_func, &intf->in_vd_func, device); |
| 652 | | |
| 653 | | crt9007->draw_scanline_func = intf->draw_scanline_func; |
| 654 | | assert(crt9007->draw_scanline_func != NULL); |
| 655 | | |
| 656 | | /* get the screen device */ |
| 657 | | crt9007->screen = device->machine->device<screen_device>(intf->screen_tag); |
| 658 | | assert(crt9007->screen != NULL); |
| 659 | | |
| 660 | | /* set horizontal pixels per column */ |
| 661 | | crt9007->hpixels_per_column = intf->hpixels_per_column; |
| 662 | | |
| 663 | | /* create the timers */ |
| 664 | | crt9007->vsync_timer = timer_alloc(device->machine, vsync_tick, (void *)device); |
| 665 | | crt9007->hsync_timer = timer_alloc(device->machine, hsync_tick, (void *)device); |
| 666 | | |
| 667 | | /* register for state saving */ |
| 668 | | // state_save_register_device_item(device, 0, crt9007->); |
| 801 | m_hpixels_per_column = hpixels_per_column; |
| 802 | recompute_parameters(); |
| 669 | 803 | } |
| 670 | | |
| 671 | | /*------------------------------------------------- |
| 672 | | DEVICE_RESET( crt9007 ) |
| 673 | | -------------------------------------------------*/ |
| 674 | | |
| 675 | | static DEVICE_RESET( crt9007 ) |
| 676 | | { |
| 677 | | // crt9007_t *crt9007 = (crt9007_t *)downcast<legacy_device_base *>(device)->token(); |
| 678 | | } |
| 679 | | |
| 680 | | /*------------------------------------------------- |
| 681 | | DEVICE_GET_INFO( crt9007 ) |
| 682 | | -------------------------------------------------*/ |
| 683 | | |
| 684 | | DEVICE_GET_INFO( crt9007 ) |
| 685 | | { |
| 686 | | switch (state) |
| 687 | | { |
| 688 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 689 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 690 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(crt9007_t); break; |
| 691 | | |
| 692 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 693 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(crt9007); break; |
| 694 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 695 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(crt9007); break; |
| 696 | | |
| 697 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 698 | | case DEVINFO_STR_NAME: strcpy(info->s, "SMC CRT9007"); break; |
| 699 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "SMC CRT9007"); break; |
| 700 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 701 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 702 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 703 | | } |
| 704 | | } |
| 705 | | |
| 706 | | DEFINE_LEGACY_DEVICE(CRT9007, crt9007); |