src/mess/video/hd44780.c
| r10256 | r10257 | |
| 7 | 7 | - 5x10 chars |
| 8 | 8 | - dump internal CGROM |
| 9 | 9 | |
| 10 | | HACKS: |
| 11 | | - A00 10 bit chars are tacked onto recreated chrrom at $700 (until internal rom is dumped) |
| 12 | | - A00/A02 drawing selected by sizeof romfile, A02 is $800, A00 is $860 |
| 10 | HACKS: |
| 11 | - A00 10 bit chars are tacked onto recreated chrrom at $700 (until internal rom is dumped) |
| 12 | - A00/A02 drawing selected by sizeof romfile, A02 is $800, A00 is $860 |
| 13 | 13 | |
| 14 | 14 | ***************************************************************************/ |
| 15 | 15 | |
| r10256 | r10257 | |
| 116 | 116 | |
| 117 | 117 | timer_adjust_periodic(m_blink_timer, ATTOTIME_IN_MSEC(409), 0, ATTOTIME_IN_MSEC(409)); |
| 118 | 118 | |
| 119 | | state_save_register_device_item( this, 0, ac); |
| 120 | | state_save_register_device_item( this, 0, ac_mode); |
| 121 | | state_save_register_device_item( this, 0, data_bus_flag); |
| 122 | | state_save_register_device_item( this, 0, cursor_pos); |
| 123 | | state_save_register_device_item( this, 0, display_on); |
| 124 | | state_save_register_device_item( this, 0, cursor_on); |
| 125 | | state_save_register_device_item( this, 0, shift_on); |
| 126 | | state_save_register_device_item( this, 0, blink_on); |
| 127 | | state_save_register_device_item( this, 0, direction); |
| 128 | | state_save_register_device_item( this, 0, data_len); |
| 129 | | state_save_register_device_item( this, 0, n_line); |
| 130 | | state_save_register_device_item( this, 0, char_size); |
| 119 | state_save_register_device_item( this, 0, m_ac); |
| 120 | state_save_register_device_item( this, 0, m_ac_mode); |
| 121 | state_save_register_device_item( this, 0, m_data_bus_flag); |
| 122 | state_save_register_device_item( this, 0, m_cursor_pos); |
| 123 | state_save_register_device_item( this, 0, m_display_on); |
| 124 | state_save_register_device_item( this, 0, m_cursor_on); |
| 125 | state_save_register_device_item( this, 0, m_shift_on); |
| 126 | state_save_register_device_item( this, 0, m_blink_on); |
| 127 | state_save_register_device_item( this, 0, m_direction); |
| 128 | state_save_register_device_item( this, 0, m_data_len); |
| 129 | state_save_register_device_item( this, 0, m_num_line); |
| 130 | state_save_register_device_item( this, 0, m_char_size); |
| 131 | 131 | state_save_register_device_item( this, 0, disp_shift); |
| 132 | | state_save_register_device_item( this, 0, blink); |
| 133 | | state_save_register_device_item_array( this, 0, ddram); |
| 134 | | state_save_register_device_item_array( this, 0, cgram); |
| 132 | state_save_register_device_item( this, 0, m_blink); |
| 133 | state_save_register_device_item_array( this, 0, m_ddram); |
| 134 | state_save_register_device_item_array( this, 0, m_cgram); |
| 135 | 135 | |
| 136 | 136 | } |
| 137 | 137 | |
| r10256 | r10257 | |
| 142 | 142 | |
| 143 | 143 | void hd44780_device::device_reset() |
| 144 | 144 | { |
| 145 | | busy_flag = 0; |
| 145 | m_busy_flag = 0; |
| 146 | 146 | |
| 147 | | memset(ddram, 0x20, ARRAY_LENGTH(ddram)); // can't use 0 here as it would show CGRAM instead of blank space on a soft reset |
| 148 | | memset(cgram, 0, ARRAY_LENGTH(cgram)); |
| 149 | | ac = 0; |
| 150 | | ac_mode = 0; |
| 151 | | data_bus_flag = 0; |
| 152 | | cursor_pos = 0; |
| 153 | | display_on = 0; |
| 154 | | cursor_on = 0; |
| 155 | | shift_on = 0; |
| 156 | | blink_on = 0; |
| 157 | | direction = 1; |
| 158 | | data_len = -1; // must not be 0 or 1 on intial start to pick up first 4/8 bit mode change |
| 159 | | n_line = 0; |
| 160 | | char_size = 0; |
| 147 | memset(m_ddram, 0x20, sizeof(m_ddram)); // can't use 0 here as it would show CGRAM instead of blank space on a soft reset |
| 148 | memset(m_cgram, 0, sizeof(m_cgram)); |
| 149 | m_ac = 0; |
| 150 | m_ac_mode = 0; |
| 151 | m_data_bus_flag = 0; |
| 152 | m_cursor_pos = 0; |
| 153 | m_display_on = 0; |
| 154 | m_cursor_on = 0; |
| 155 | m_shift_on = 0; |
| 156 | m_blink_on = 0; |
| 157 | m_direction = 1; |
| 158 | m_data_len = -1; // must not be 0 or 1 on intial start to pick up first 4/8 bit mode change |
| 159 | m_num_line = 0; |
| 160 | m_char_size = 0; |
| 161 | 161 | disp_shift = 0; |
| 162 | | blink = 0; |
| 162 | m_blink = 0; |
| 163 | 163 | |
| 164 | 164 | set_busy_flag(1520); |
| 165 | 165 | } |
| r10256 | r10257 | |
| 173 | 173 | switch(id) |
| 174 | 174 | { |
| 175 | 175 | case BUSY_TIMER: |
| 176 | | busy_flag = 0; |
| 176 | m_busy_flag = 0; |
| 177 | 177 | break; |
| 178 | 178 | |
| 179 | 179 | case BLINKING_TIMER: |
| 180 | | blink = !blink; |
| 180 | m_blink = !m_blink; |
| 181 | 181 | break; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | void hd44780_device::set_busy_flag(UINT16 usec) |
| 186 | 186 | { |
| 187 | | busy_flag = 1; |
| 187 | m_busy_flag = 1; |
| 188 | 188 | |
| 189 | 189 | timer_adjust_oneshot( m_busy_timer, ATTOTIME_IN_USEC( usec ), 0 ); |
| 190 | 190 | |
| r10256 | r10257 | |
| 200 | 200 | |
| 201 | 201 | bitmap_fill(bitmap, cliprect, 0); |
| 202 | 202 | |
| 203 | | if (display_on) |
| 203 | if (m_display_on) |
| 204 | 204 | for (int l=0; l<m_config.height; l++) |
| 205 | 205 | for (int i=0; i<m_config.width; i++) |
| 206 | 206 | { |
| 207 | 207 | UINT8 line_base = l * 0x40; |
| 208 | | UINT8 line_size = (n_line) ? 40 : 80; |
| 208 | UINT8 line_size = (m_num_line) ? 40 : 80; |
| 209 | 209 | INT8 char_pos = line_base + i; |
| 210 | 210 | |
| 211 | 211 | // if specified uses the custom layout |
| r10256 | r10257 | |
| 225 | 225 | } |
| 226 | 226 | for (int y=0; y<8; y++) |
| 227 | 227 | for (int x=0; x<5; x++) |
| 228 | | if (ddram[char_pos] <= 0x10) |
| 228 | if (m_ddram[char_pos] <= 0x10) |
| 229 | 229 | { |
| 230 | 230 | //draw CGRAM characters |
| 231 | | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(cgram[(ddram[char_pos]&0x07)*8+y], 4-x); |
| 231 | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(m_cgram[(m_ddram[char_pos]&0x07)*8+y], 4-x); |
| 232 | 232 | } |
| 233 | 233 | else |
| 234 | 234 | { |
| 235 | 235 | //draw CGROM characters |
| 236 | | if (region()->bytes() <= 0x800) { |
| 237 | | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x); |
| 238 | | } else { |
| 239 | | if(ddram[char_pos] < 0xe0) { |
| 240 | | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(ddram[char_pos]*8+y), 4-x); |
| 241 | | } else { |
| 242 | | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((ddram[char_pos]-0xe0)*11)+y), 4-x); |
| 243 | | } |
| 236 | if (region()->bytes() <= 0x800) |
| 237 | { |
| 238 | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x); |
| 244 | 239 | } |
| 240 | else |
| 241 | { |
| 242 | if(m_ddram[char_pos] < 0xe0) |
| 243 | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(m_ddram[char_pos]*8+y), 4-x); |
| 244 | else |
| 245 | *BITMAP_ADDR16(bitmap, l*9 + y, i*6 + x) = BIT(region()->u8(0x700+((m_ddram[char_pos]-0xe0)*11)+y), 4-x); |
| 246 | } |
| 245 | 247 | } |
| 246 | 248 | |
| 247 | 249 | // if is the correct position draw cursor and blink |
| 248 | | if (char_pos == cursor_pos) |
| 250 | if (char_pos == m_cursor_pos) |
| 249 | 251 | { |
| 250 | 252 | //draw the cursor |
| 251 | | if (cursor_on) |
| 253 | if (m_cursor_on) |
| 252 | 254 | for (int x=0; x<5; x++) |
| 253 | 255 | *BITMAP_ADDR16(bitmap, l*9 + 7, i * 6 + x) = 1; |
| 254 | 256 | |
| 255 | | if (!blink && blink_on) |
| 257 | if (!m_blink && m_blink_on) |
| 256 | 258 | for (int y=0; y<7; y++) |
| 257 | 259 | for (int x=0; x<5; x++) |
| 258 | 260 | *BITMAP_ADDR16(bitmap, l*9 + y, i * 6 + x) = 1; |
| r10256 | r10257 | |
| 265 | 267 | |
| 266 | 268 | void hd44780_device::control_write(offs_t offset, UINT8 data) |
| 267 | 269 | { |
| 268 | | if (busy_flag) |
| 269 | | { |
| 270 | | logerror("HD44780 '%s' Instruction %02x refused due of busy flag\n", tag(), data); |
| 271 | | return; |
| 272 | | } |
| 273 | | |
| 274 | 270 | if (BIT(data, 7)) // Set DDRAM Address |
| 275 | 271 | { |
| 276 | | ac_mode = 0; |
| 277 | | ac = data & 0x7f; |
| 272 | m_ac_mode = 0; |
| 273 | m_ac = data & 0x7f; |
| 278 | 274 | if (data != 0x81) // not in datasheet spec |
| 279 | | cursor_pos = ac; |
| 275 | m_cursor_pos = m_ac; |
| 280 | 276 | set_busy_flag(37); |
| 281 | 277 | } |
| 282 | 278 | else if (BIT(data, 6)) // Set CGRAM Address |
| 283 | 279 | { |
| 284 | | ac_mode = 1; |
| 285 | | ac = data & 0x3f; |
| 280 | m_ac_mode = 1; |
| 281 | m_ac = data & 0x3f; |
| 286 | 282 | set_busy_flag(37); |
| 287 | 283 | } |
| 288 | 284 | else if (BIT(data, 5)) // Function Set |
| 289 | 285 | { |
| 290 | 286 | // datasheet says you can't change char size after first function set without altering 4/8 bit mode |
| 291 | | if (BIT(data, 4) != data_len) { |
| 292 | | char_size = BIT(data, 2); |
| 293 | | } |
| 294 | | data_len = BIT(data, 4); |
| 295 | | n_line = BIT(data, 3); |
| 287 | if (BIT(data, 4) != m_data_len) |
| 288 | m_char_size = BIT(data, 2); |
| 289 | |
| 290 | m_data_len = BIT(data, 4); |
| 291 | m_num_line = BIT(data, 3); |
| 296 | 292 | set_busy_flag(37); |
| 297 | 293 | } |
| 298 | 294 | else if (BIT(data, 4)) // Cursor or display shift |
| r10256 | r10257 | |
| 303 | 299 | disp_shift += direct; |
| 304 | 300 | else |
| 305 | 301 | { |
| 306 | | ac += direct; |
| 307 | | cursor_pos += direct; |
| 302 | m_ac += direct; |
| 303 | m_cursor_pos += direct; |
| 308 | 304 | } |
| 309 | 305 | |
| 310 | 306 | set_busy_flag(37); |
| 311 | 307 | } |
| 312 | 308 | else if (BIT(data, 3)) // Display on/off Control |
| 313 | 309 | { |
| 314 | | display_on = BIT(data, 2); |
| 315 | | cursor_on = BIT(data, 1); |
| 316 | | blink_on = BIT(data, 0); |
| 310 | m_display_on = BIT(data, 2); |
| 311 | m_cursor_on = BIT(data, 1); |
| 312 | m_blink_on = BIT(data, 0); |
| 317 | 313 | |
| 318 | 314 | set_busy_flag(37); |
| 319 | 315 | } |
| 320 | 316 | else if (BIT(data, 2)) // Entry Mode set |
| 321 | 317 | { |
| 322 | | direction = (BIT(data, 1)) ? +1 : -1; |
| 318 | m_direction = (BIT(data, 1)) ? +1 : -1; |
| 323 | 319 | |
| 324 | | shift_on = BIT(data, 0); |
| 320 | m_shift_on = BIT(data, 0); |
| 325 | 321 | |
| 326 | 322 | set_busy_flag(37); |
| 327 | 323 | } |
| 328 | 324 | else if (BIT(data, 1)) // return home |
| 329 | 325 | { |
| 330 | | ac = 0; |
| 331 | | cursor_pos = 0; |
| 332 | | ac_mode = 0; // datasheet does not specifically say this but mephisto won't run without it |
| 333 | | direction = 1; |
| 326 | m_ac = 0; |
| 327 | m_cursor_pos = 0; |
| 328 | m_ac_mode = 0; // datasheet does not specifically say this but mephisto won't run without it |
| 329 | m_direction = 1; |
| 334 | 330 | disp_shift = 0; |
| 335 | 331 | set_busy_flag(1520); |
| 336 | 332 | } |
| 337 | 333 | else if (BIT(data, 0)) // clear display |
| 338 | 334 | { |
| 339 | | ac = 0; |
| 340 | | cursor_pos = 0; |
| 341 | | ac_mode = 0; |
| 342 | | direction = 1; |
| 335 | m_ac = 0; |
| 336 | m_cursor_pos = 0; |
| 337 | m_ac_mode = 0; |
| 338 | m_direction = 1; |
| 343 | 339 | disp_shift = 0; |
| 344 | | memset(ddram, 0x20, ARRAY_LENGTH(ddram)); |
| 345 | | // nothing in datasheet says to clear CGRAM |
| 346 | | // memset(cgram, 0x20, ARRAY_LENGTH(cgram)); |
| 340 | memset(m_ddram, 0x20, sizeof(m_ddram)); |
| 347 | 341 | set_busy_flag(1520); |
| 348 | 342 | } |
| 349 | 343 | } |
| 350 | 344 | |
| 351 | 345 | UINT8 hd44780_device::control_read(offs_t offset) |
| 352 | 346 | { |
| 353 | | return busy_flag<<7 || ac&0x7f; |
| 347 | return m_busy_flag<<7 || m_ac&0x7f; |
| 354 | 348 | } |
| 355 | 349 | |
| 356 | | void hd44780_device::update_ac(void) // data_bus_flag was left as global so old savestates will work |
| 350 | void hd44780_device::update_ac(void) // m_data_bus_flag was left as global so old savestates will work |
| 357 | 351 | { |
| 358 | | int new_ac = ac + direction; |
| 359 | | ac = (new_ac < 0) ? 0 : ((new_ac > 0x7f) ? 0x7f : new_ac); |
| 360 | | if (ac_mode == 0) { |
| 361 | | cursor_pos = ac; |
| 362 | | // display is shifted only after a write |
| 363 | | if (shift_on && data_bus_flag == 1) disp_shift += direction; |
| 352 | int new_ac = m_ac + m_direction; |
| 353 | m_ac = (new_ac < 0) ? 0 : ((new_ac > 0x7f) ? 0x7f : new_ac); |
| 354 | if (m_ac_mode == 0) |
| 355 | { |
| 356 | m_cursor_pos = m_ac; |
| 357 | // display is shifted only after a write |
| 358 | if (m_shift_on && m_data_bus_flag == 1) disp_shift += m_direction; |
| 359 | } |
| 360 | m_data_bus_flag = 0; |
| 364 | 361 | } |
| 365 | | data_bus_flag = 0; |
| 366 | | } |
| 367 | 362 | |
| 368 | 363 | |
| 369 | 364 | void hd44780_device::data_write(offs_t offset, UINT8 data) |
| 370 | 365 | { |
| 371 | | if (busy_flag) |
| 366 | if (m_busy_flag) |
| 372 | 367 | { |
| 373 | 368 | logerror("HD44780 '%s' Ignoring data write %02x due of busy flag\n", tag(), data); |
| 374 | 369 | return; |
| 375 | 370 | } |
| 376 | 371 | |
| 377 | | if (ac_mode == 0) ddram[ac] = data; |
| 378 | | else cgram[ac] = data; |
| 379 | | data_bus_flag = 1; |
| 372 | if (m_ac_mode == 0) m_ddram[m_ac] = data; |
| 373 | else m_cgram[m_ac] = data; |
| 374 | m_data_bus_flag = 1; |
| 380 | 375 | update_ac(); |
| 381 | 376 | set_busy_flag(41); |
| 382 | 377 | } |
| r10256 | r10257 | |
| 385 | 380 | { |
| 386 | 381 | UINT8 data; |
| 387 | 382 | |
| 388 | | if (ac_mode == 0) |
| 389 | | data = ddram[ac]; |
| 390 | | else { |
| 391 | | data = cgram[ac]; |
| 392 | | } |
| 383 | if (m_ac_mode == 0) |
| 384 | data = m_ddram[m_ac]; |
| 385 | else |
| 386 | data = m_cgram[m_ac]; |
| 393 | 387 | |
| 394 | | data_bus_flag = 2; |
| 388 | m_data_bus_flag = 2; |
| 395 | 389 | update_ac(); |
| 396 | 390 | |
| 397 | 391 | set_busy_flag(41); |
src/mess/video/ef9345.c
| r10256 | r10257 | |
| 109 | 109 | // calculate the internal RAM offset |
| 110 | 110 | inline UINT16 ef9345_device::indexram(UINT8 r) |
| 111 | 111 | { |
| 112 | | UINT8 x = registers[r]; |
| 113 | | UINT8 y = registers[r - 1]; |
| 112 | UINT8 x = m_registers[r]; |
| 113 | UINT8 y = m_registers[r - 1]; |
| 114 | 114 | if (y < 8) |
| 115 | 115 | y &= 1; |
| 116 | 116 | return ((x&0x3f) | ((x & 0x40) << 6) | ((x & 0x80) << 4) | ((y & 0x1f) << 6) | ((y & 0x20) << 8)); |
| r10256 | r10257 | |
| 119 | 119 | // calculate the internal ROM offset |
| 120 | 120 | inline UINT16 ef9345_device::indexrom(UINT8 r) |
| 121 | 121 | { |
| 122 | | UINT8 x = registers[r]; |
| 123 | | UINT8 y = registers[r - 1]; |
| 122 | UINT8 x = m_registers[r]; |
| 123 | UINT8 y = m_registers[r - 1]; |
| 124 | 124 | if (y < 8) |
| 125 | 125 | y &= 1; |
| 126 | 126 | return((x&0x3f)|((x&0x40)<<6)|((x&0x80)<<4)|((y&0x1f)<<6)); |
| r10256 | r10257 | |
| 129 | 129 | // increment x |
| 130 | 130 | inline void ef9345_device::inc_x(UINT8 r) |
| 131 | 131 | { |
| 132 | | UINT8 i = (registers[r] & 0x3f) + 1; |
| 132 | UINT8 i = (m_registers[r] & 0x3f) + 1; |
| 133 | 133 | if (i > 39) |
| 134 | 134 | { |
| 135 | 135 | i -= 40; |
| 136 | | state |= 0x40; |
| 136 | m_state |= 0x40; |
| 137 | 137 | } |
| 138 | | registers[r] = (registers[r] & 0xc0) | i; |
| 138 | m_registers[r] = (m_registers[r] & 0xc0) | i; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // increment y |
| 142 | 142 | inline void ef9345_device::inc_y(UINT8 r) |
| 143 | 143 | { |
| 144 | | UINT8 i = (registers[r] & 0x1f) + 1; |
| 144 | UINT8 i = (m_registers[r] & 0x1f) + 1; |
| 145 | 145 | if (i > 31) |
| 146 | 146 | i -= 24; |
| 147 | | registers[r] = (registers[r] & 0xe0) | i; |
| 147 | m_registers[r] = (m_registers[r] & 0xe0) | i; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
| r10256 | r10257 | |
| 169 | 169 | |
| 170 | 170 | void ef9345_device::device_start() |
| 171 | 171 | { |
| 172 | | screen = machine->device<screen_device>(m_config.screen_tag); |
| 172 | m_screen = machine->device<screen_device>(m_config.screen_tag); |
| 173 | 173 | |
| 174 | | assert(screen != NULL); |
| 174 | assert(m_screen != NULL); |
| 175 | 175 | |
| 176 | 176 | m_busy_timer = device_timer_alloc(*this, BUSY_TIMER); |
| 177 | 177 | m_blink_timer = device_timer_alloc(*this, BLINKING_TIMER); |
| 178 | 178 | |
| 179 | | videoram = space(0); |
| 180 | | charset = region(); |
| 179 | m_videoram = space(0); |
| 180 | m_charset = region(); |
| 181 | 181 | |
| 182 | | screen_out = auto_bitmap_alloc(machine, 496, screen->height() , BITMAP_FORMAT_INDEXED16); |
| 182 | m_screen_out = auto_bitmap_alloc(machine, 496, m_screen->height() , BITMAP_FORMAT_INDEXED16); |
| 183 | 183 | |
| 184 | 184 | timer_adjust_periodic(m_blink_timer, ATTOTIME_IN_MSEC(500), 0, ATTOTIME_IN_MSEC(500)); |
| 185 | 185 | |
| 186 | 186 | init_accented_chars(); |
| 187 | 187 | |
| 188 | | state_save_register_device_item_array(this, 0, border); |
| 189 | | state_save_register_device_item_array(this, 0, registers); |
| 190 | | state_save_register_device_item_array(this, 0, last_dial); |
| 191 | | state_save_register_device_item_array(this, 0, ram_base); |
| 192 | | state_save_register_device_item(this, 0, bf); |
| 193 | | state_save_register_device_item(this, 0, char_mode); |
| 194 | | state_save_register_device_item(this, 0, state); |
| 195 | | state_save_register_device_item(this, 0, TGS); |
| 196 | | state_save_register_device_item(this, 0, MAT); |
| 197 | | state_save_register_device_item(this, 0, PAT); |
| 198 | | state_save_register_device_item(this, 0, DOR); |
| 199 | | state_save_register_device_item(this, 0, ROR); |
| 200 | | state_save_register_device_item(this, 0, block); |
| 201 | | state_save_register_device_item(this, 0, blink); |
| 202 | | state_save_register_device_item(this, 0, latchc0); |
| 203 | | state_save_register_device_item(this, 0, latchm); |
| 204 | | state_save_register_device_item(this, 0, latchi); |
| 205 | | state_save_register_device_item(this, 0, latchu); |
| 188 | state_save_register_device_item_array(this, 0, m_border); |
| 189 | state_save_register_device_item_array(this, 0, m_registers); |
| 190 | state_save_register_device_item_array(this, 0, m_last_dial); |
| 191 | state_save_register_device_item_array(this, 0, m_ram_base); |
| 192 | state_save_register_device_item(this, 0, m_bf); |
| 193 | state_save_register_device_item(this, 0, m_char_mode); |
| 194 | state_save_register_device_item(this, 0, m_state); |
| 195 | state_save_register_device_item(this, 0, m_tgs); |
| 196 | state_save_register_device_item(this, 0, m_mat); |
| 197 | state_save_register_device_item(this, 0, m_pat); |
| 198 | state_save_register_device_item(this, 0, m_dor); |
| 199 | state_save_register_device_item(this, 0, m_ror); |
| 200 | state_save_register_device_item(this, 0, m_block); |
| 201 | state_save_register_device_item(this, 0, m_blink); |
| 202 | state_save_register_device_item(this, 0, m_latchc0); |
| 203 | state_save_register_device_item(this, 0, m_latchm); |
| 204 | state_save_register_device_item(this, 0, m_latchi); |
| 205 | state_save_register_device_item(this, 0, m_latchu); |
| 206 | 206 | |
| 207 | | state_save_register_device_item_bitmap(this, 0, screen_out); |
| 207 | state_save_register_device_item_bitmap(this, 0, m_screen_out); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | //------------------------------------------------- |
| r10256 | r10257 | |
| 212 | 212 | //------------------------------------------------- |
| 213 | 213 | void ef9345_device::device_reset() |
| 214 | 214 | { |
| 215 | | TGS = MAT = PAT = DOR = ROR = 0; |
| 216 | | state = 0; |
| 217 | | bf = 0; |
| 218 | | block = 0; |
| 219 | | blink = 0; |
| 220 | | latchc0 = 0; |
| 221 | | latchm = 0; |
| 222 | | latchi = 0; |
| 223 | | latchu = 0; |
| 224 | | char_mode = 0; |
| 215 | m_tgs = m_mat = m_pat = m_dor = m_ror = 0; |
| 216 | m_state = 0; |
| 217 | m_bf = 0; |
| 218 | m_block = 0; |
| 219 | m_blink = 0; |
| 220 | m_latchc0 = 0; |
| 221 | m_latchm = 0; |
| 222 | m_latchi = 0; |
| 223 | m_latchu = 0; |
| 224 | m_char_mode = 0; |
| 225 | 225 | |
| 226 | | memset(last_dial, 0, ARRAY_LENGTH(last_dial) * sizeof(UINT8)); |
| 227 | | memset(registers, 0, ARRAY_LENGTH(registers) * sizeof(UINT8)); |
| 228 | | memset(border, 0, ARRAY_LENGTH(border) * sizeof(UINT8)); |
| 229 | | memset(border, 0, ARRAY_LENGTH(ram_base) * sizeof(UINT16)); |
| 226 | memset(m_last_dial, 0, sizeof(m_last_dial)); |
| 227 | memset(m_registers, 0, sizeof(m_registers)); |
| 228 | memset(m_border, 0, sizeof(m_border)); |
| 229 | memset(m_border, 0, sizeof(m_ram_base)); |
| 230 | 230 | |
| 231 | | bitmap_fill(screen_out, NULL, 0); |
| 231 | bitmap_fill(m_screen_out, NULL, 0); |
| 232 | 232 | |
| 233 | 233 | set_video_mode(); |
| 234 | 234 | } |
| r10256 | r10257 | |
| 241 | 241 | switch(id) |
| 242 | 242 | { |
| 243 | 243 | case BUSY_TIMER: |
| 244 | | bf = 0; |
| 244 | m_bf = 0; |
| 245 | 245 | break; |
| 246 | 246 | |
| 247 | 247 | case BLINKING_TIMER: |
| 248 | | blink = !blink; |
| 248 | m_blink = !m_blink; |
| 249 | 249 | break; |
| 250 | 250 | } |
| 251 | 251 | } |
| r10256 | r10257 | |
| 254 | 254 | // set busy flag and timer to clear it |
| 255 | 255 | void ef9345_device::set_busy_flag(int period) |
| 256 | 256 | { |
| 257 | | bf = 1; |
| 257 | m_bf = 1; |
| 258 | 258 | timer_adjust_oneshot(m_busy_timer, ATTOTIME_IN_USEC(period), 0); |
| 259 | 259 | } |
| 260 | 260 | |
| r10256 | r10257 | |
| 262 | 262 | void ef9345_device::draw_char_40(UINT8 *c, UINT16 x, UINT16 y) |
| 263 | 263 | { |
| 264 | 264 | //verify size limit |
| 265 | | if (y * 10 >= screen->height() || x * 8 >= screen->width()) |
| 265 | if (y * 10 >= m_screen->height() || x * 8 >= m_screen->width()) |
| 266 | 266 | return; |
| 267 | 267 | |
| 268 | 268 | for(int i = 0; i < 10; i++) |
| 269 | 269 | for(int j = 0; j < 8; j++) |
| 270 | | *BITMAP_ADDR16(screen_out, y * 10 + i, x * 8 + j) = c[8 * i + j] & 0x07; |
| 270 | *BITMAP_ADDR16(m_screen_out, y * 10 + i, x * 8 + j) = c[8 * i + j] & 0x07; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // draw a char in 80 char line mode |
| 274 | 274 | void ef9345_device::draw_char_80(UINT8 *c, UINT16 x, UINT16 y) |
| 275 | 275 | { |
| 276 | 276 | // verify size limit |
| 277 | | if (y * 10 >= screen->height() || x * 6 >= screen->width()) |
| 277 | if (y * 10 >= m_screen->height() || x * 6 >= m_screen->width()) |
| 278 | 278 | return; |
| 279 | 279 | |
| 280 | 280 | for(int i = 0; i < 10; i++) |
| 281 | 281 | for(int j = 0; j < 6; j++) |
| 282 | | *BITMAP_ADDR16(screen_out, y * 10 + i, x * 6 + j) = c[6 * i + j] & 0x07; |
| 282 | *BITMAP_ADDR16(m_screen_out, y * 10 + i, x * 6 + j) = c[6 * i + j] & 0x07; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | |
| 286 | 286 | // set then ef9345 mode |
| 287 | 287 | void ef9345_device::set_video_mode(void) |
| 288 | 288 | { |
| 289 | | char_mode = ((PAT & 0x80) >> 5) | ((TGS & 0xc0) >> 6); |
| 290 | | UINT16 new_width = (char_mode == MODE12x80 || char_mode == MODE8x80) ? 492 : 336; |
| 289 | m_char_mode = ((m_pat & 0x80) >> 5) | ((m_tgs & 0xc0) >> 6); |
| 290 | UINT16 new_width = (m_char_mode == MODE12x80 || m_char_mode == MODE8x80) ? 492 : 336; |
| 291 | 291 | |
| 292 | | if (screen->width() != new_width) |
| 292 | if (m_screen->width() != new_width) |
| 293 | 293 | { |
| 294 | | rectangle visarea = screen->visible_area(); |
| 294 | rectangle visarea = m_screen->visible_area(); |
| 295 | 295 | visarea.max_x = new_width - 1; |
| 296 | 296 | |
| 297 | | screen->configure(new_width, screen->height(), visarea, screen->frame_period().attoseconds); |
| 297 | m_screen->configure(new_width, m_screen->height(), visarea, m_screen->frame_period().attoseconds); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | //border color |
| 301 | | memset(border, MAT & 0x07, ARRAY_LENGTH(border)); |
| 301 | memset(m_border, m_mat & 0x07, sizeof(m_border)); |
| 302 | 302 | |
| 303 | | //set the base for the videoram charset |
| 304 | | ram_base[0] = ((DOR & 0x07) << 11); |
| 305 | | ram_base[1] = ram_base[0]; |
| 306 | | ram_base[2] = ((DOR & 0x30) << 8); |
| 307 | | ram_base[3] = ram_base[2] + 0x0800; |
| 303 | //set the base for the m_videoram charset |
| 304 | m_ram_base[0] = ((m_dor & 0x07) << 11); |
| 305 | m_ram_base[1] = m_ram_base[0]; |
| 306 | m_ram_base[2] = ((m_dor & 0x30) << 8); |
| 307 | m_ram_base[3] = m_ram_base[2] + 0x0800; |
| 308 | 308 | |
| 309 | 309 | //address of the current memory block |
| 310 | | block = 0x0800 * ((((ROR & 0xf0) >> 4) | ((ROR & 0x40) >> 5) | ((ROR & 0x20) >> 3)) & 0x0c); |
| 310 | m_block = 0x0800 * ((((m_ror & 0xf0) >> 4) | ((m_ror & 0x40) >> 5) | ((m_ror & 0x20) >> 3)) & 0x0c); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // initialize the ef9345 accented chars |
| r10256 | r10257 | |
| 316 | 316 | UINT16 i, j; |
| 317 | 317 | for(j = 0; j < 0x10; j++) |
| 318 | 318 | for(i = 0; i < 0x200; i++) |
| 319 | | acc_char[(j << 9) + i] = charset->u8(0x0600 + i); |
| 319 | m_acc_char[(j << 9) + i] = m_charset->u8(0x0600 + i); |
| 320 | 320 | |
| 321 | 321 | for(j = 0; j < 0x200; j += 0x40) |
| 322 | 322 | for(i = 0; i < 4; i++) |
| 323 | 323 | { |
| 324 | | acc_char[0x0200 + j + i + 4] |= 0x1c; //tilde |
| 325 | | acc_char[0x0400 + j + i + 4] |= 0x10; //acute |
| 326 | | acc_char[0x0400 + j + i + 8] |= 0x08; //acute |
| 327 | | acc_char[0x0600 + j + i + 4] |= 0x04; //grave |
| 328 | | acc_char[0x0600 + j + i + 8] |= 0x08; //grave |
| 324 | m_acc_char[0x0200 + j + i + 4] |= 0x1c; //tilde |
| 325 | m_acc_char[0x0400 + j + i + 4] |= 0x10; //acute |
| 326 | m_acc_char[0x0400 + j + i + 8] |= 0x08; //acute |
| 327 | m_acc_char[0x0600 + j + i + 4] |= 0x04; //grave |
| 328 | m_acc_char[0x0600 + j + i + 8] |= 0x08; //grave |
| 329 | 329 | |
| 330 | | acc_char[0x0a00 + j + i + 4] |= 0x1c; //tilde |
| 331 | | acc_char[0x0c00 + j + i + 4] |= 0x10; //acute |
| 332 | | acc_char[0x0c00 + j + i + 8] |= 0x08; //acute |
| 333 | | acc_char[0x0e00 + j + i + 4] |= 0x04; //grave |
| 334 | | acc_char[0x0e00 + j + i + 8] |= 0x08; //grave |
| 330 | m_acc_char[0x0a00 + j + i + 4] |= 0x1c; //tilde |
| 331 | m_acc_char[0x0c00 + j + i + 4] |= 0x10; //acute |
| 332 | m_acc_char[0x0c00 + j + i + 8] |= 0x08; //acute |
| 333 | m_acc_char[0x0e00 + j + i + 4] |= 0x04; //grave |
| 334 | m_acc_char[0x0e00 + j + i + 8] |= 0x08; //grave |
| 335 | 335 | |
| 336 | | acc_char[0x1200 + j + i + 4] |= 0x08; //point |
| 337 | | acc_char[0x1400 + j + i + 4] |= 0x14; //trema |
| 338 | | acc_char[0x1600 + j + i + 32] |= 0x08; //cedilla |
| 339 | | acc_char[0x1600 + j + i + 36] |= 0x04; //cedilla |
| 336 | m_acc_char[0x1200 + j + i + 4] |= 0x08; //point |
| 337 | m_acc_char[0x1400 + j + i + 4] |= 0x14; //trema |
| 338 | m_acc_char[0x1600 + j + i + 32] |= 0x08; //cedilla |
| 339 | m_acc_char[0x1600 + j + i + 36] |= 0x04; //cedilla |
| 340 | 340 | |
| 341 | | acc_char[0x1a00 + j + i + 4] |= 0x08; //point |
| 342 | | acc_char[0x1c00 + j + i + 4] |= 0x14; //trema |
| 343 | | acc_char[0x1e00 + j + i + 32] |= 0x08; //cedilla |
| 344 | | acc_char[0x1e00 + j + i + 36] |= 0x04; //cedilla |
| 341 | m_acc_char[0x1a00 + j + i + 4] |= 0x08; //point |
| 342 | m_acc_char[0x1c00 + j + i + 4] |= 0x14; //trema |
| 343 | m_acc_char[0x1e00 + j + i + 32] |= 0x08; //cedilla |
| 344 | m_acc_char[0x1e00 + j + i + 36] |= 0x04; //cedilla |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | | // read a char in charset or in videoram |
| 348 | // read a char in charset or in m_videoram |
| 349 | 349 | UINT8 ef9345_device::read_char(UINT8 index, UINT16 addr) |
| 350 | 350 | { |
| 351 | 351 | if (index < 0x04) |
| 352 | | return charset->u8(0x0800*index + addr); |
| 352 | return m_charset->u8(0x0800*index + addr); |
| 353 | 353 | else if (index < 0x08) |
| 354 | | return acc_char[0x0800*(index&3) + addr]; |
| 354 | return m_acc_char[0x0800*(index&3) + addr]; |
| 355 | 355 | else if (index < 0x0c) |
| 356 | | return videoram->read_byte(ram_base[index-8] + addr); |
| 356 | return m_videoram->read_byte(m_ram_base[index-8] + addr); |
| 357 | 357 | else |
| 358 | | return videoram->read_byte(addr); |
| 358 | return m_videoram->read_byte(addr); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | // calculate the dial position of the char |
| 362 | 362 | UINT8 ef9345_device::get_dial(UINT8 x, UINT8 attrib) |
| 363 | 363 | { |
| 364 | | if (x > 0 && last_dial[x-1] == 1) //top right |
| 365 | | last_dial[x] = 2; |
| 366 | | else if (x > 0 && last_dial[x-1] == 5) //half right |
| 367 | | last_dial[x] = 10; |
| 368 | | else if (last_dial[x] == 1) //bottom left |
| 369 | | last_dial[x] = 4; |
| 370 | | else if (last_dial[x] == 2) //bottom right |
| 371 | | last_dial[x] = 8; |
| 372 | | else if (last_dial[x] == 3) //lower half |
| 373 | | last_dial[x] = 12; |
| 374 | | else if (attrib == 1) //Left half |
| 375 | | last_dial[x] = 5; |
| 376 | | else if (attrib == 2) //half high |
| 377 | | last_dial[x] = 3; |
| 378 | | else if (attrib == 3) //top left |
| 379 | | last_dial[x] = 1; |
| 380 | | else //none |
| 381 | | last_dial[x] = 0; |
| 364 | if (x > 0 && m_last_dial[x-1] == 1) //top right |
| 365 | m_last_dial[x] = 2; |
| 366 | else if (x > 0 && m_last_dial[x-1] == 5) //half right |
| 367 | m_last_dial[x] = 10; |
| 368 | else if (m_last_dial[x] == 1) //bottom left |
| 369 | m_last_dial[x] = 4; |
| 370 | else if (m_last_dial[x] == 2) //bottom right |
| 371 | m_last_dial[x] = 8; |
| 372 | else if (m_last_dial[x] == 3) //lower half |
| 373 | m_last_dial[x] = 12; |
| 374 | else if (attrib == 1) //Left half |
| 375 | m_last_dial[x] = 5; |
| 376 | else if (attrib == 2) //half high |
| 377 | m_last_dial[x] = 3; |
| 378 | else if (attrib == 3) //top left |
| 379 | m_last_dial[x] = 1; |
| 380 | else //none |
| 381 | m_last_dial[x] = 0; |
| 382 | 382 | |
| 383 | | return last_dial[x]; |
| 383 | return m_last_dial[x]; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // zoom the char |
| r10256 | r10257 | |
| 413 | 413 | UINT16 ef9345_device::indexblock(UINT16 x, UINT16 y) |
| 414 | 414 | { |
| 415 | 415 | UINT16 i = x, j; |
| 416 | | j = (y == 0) ? ((TGS & 0x20) >> 5) : ((ROR & 0x1f) + y - 1); |
| 416 | j = (y == 0) ? ((m_tgs & 0x20) >> 5) : ((m_ror & 0x1f) + y - 1); |
| 417 | 417 | |
| 418 | 418 | //right side of a double width character |
| 419 | | if ((TGS & 0x80) == 0 && x > 0) |
| 419 | if ((m_tgs & 0x80) == 0 && x > 0) |
| 420 | 420 | { |
| 421 | | if (last_dial[x - 1] == 1) i--; |
| 422 | | if (last_dial[x - 1] == 4) i--; |
| 423 | | if (last_dial[x - 1] == 5) i--; |
| 421 | if (m_last_dial[x - 1] == 1) i--; |
| 422 | if (m_last_dial[x - 1] == 4) i--; |
| 423 | if (m_last_dial[x - 1] == 5) i--; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | return 0x40 * j + i; |
| r10256 | r10257 | |
| 432 | 432 | UINT16 i; |
| 433 | 433 | UINT8 pix[80]; |
| 434 | 434 | |
| 435 | | if (flash && PAT & 0x40 && blink) |
| 435 | if (flash && m_pat & 0x40 && m_blink) |
| 436 | 436 | c1 = c0; //flash |
| 437 | | if (hided && PAT & 0x08) |
| 437 | if (hided && m_pat & 0x08) |
| 438 | 438 | c1 = c0; //hided |
| 439 | 439 | if (negative) //negative |
| 440 | 440 | { |
| r10256 | r10257 | |
| 443 | 443 | c0 = i; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | | if ((PAT & 0x30) == 0x30) |
| 446 | if ((m_pat & 0x30) == 0x30) |
| 447 | 447 | insert = 0; //active area mark |
| 448 | 448 | if (insert == 0) |
| 449 | | c1 += 8; //foreground color |
| 450 | | if ((PAT & 0x30) == 0x00) |
| 449 | c1 += 8; //foreground color |
| 450 | if ((m_pat & 0x30) == 0x00) |
| 451 | 451 | insert = 1; //insert mode |
| 452 | 452 | if (insert == 0) |
| 453 | | c0 += 8; //background color |
| 453 | c0 += 8; //background color |
| 454 | 454 | |
| 455 | 455 | //draw the cursor |
| 456 | | i = (registers[6] & 0x1f); |
| 456 | i = (m_registers[6] & 0x1f); |
| 457 | 457 | if (i < 8) |
| 458 | 458 | i &= 1; |
| 459 | 459 | |
| 460 | | if (iblock == 0x40 * i + (registers[7] & 0x3f)) //cursor position |
| 460 | if (iblock == 0x40 * i + (m_registers[7] & 0x3f)) //cursor position |
| 461 | 461 | { |
| 462 | | switch(MAT & 0x70) |
| 462 | switch(m_mat & 0x70) |
| 463 | 463 | { |
| 464 | 464 | case 0x40: //00 = fixed complemented |
| 465 | 465 | c0 = (23 - c0) & 15; |
| r10256 | r10257 | |
| 469 | 469 | underline = 1; |
| 470 | 470 | break; |
| 471 | 471 | case 0x60: //10 = flash complemented |
| 472 | | if (blink) |
| 472 | if (m_blink) |
| 473 | 473 | { |
| 474 | 474 | c0 = (23 - c0) & 15; |
| 475 | 475 | c1 = (23 - c1) & 15; |
| 476 | 476 | } |
| 477 | 477 | break; |
| 478 | 478 | case 0x70: //11 = flash underlined |
| 479 | | if (blink) |
| 479 | if (m_blink) |
| 480 | 480 | underline = 1; |
| 481 | 481 | break; |
| 482 | 482 | } |
| r10256 | r10257 | |
| 499 | 499 | zoom(pix, dial); |
| 500 | 500 | |
| 501 | 501 | //doubles the height of the char |
| 502 | | if (MAT & 0x80) |
| 502 | if (m_mat & 0x80) |
| 503 | 503 | zoom(pix, (y & 0x01) ? 0x0c : 0x03); |
| 504 | 504 | |
| 505 | 505 | draw_char_40(pix, x + 1 , y + 1); |
| r10256 | r10257 | |
| 520 | 520 | UINT16 ramindex; |
| 521 | 521 | |
| 522 | 522 | //quadrichrome don't suppor double size |
| 523 | | last_dial[x] = 0; |
| 523 | m_last_dial[x] = 0; |
| 524 | 524 | |
| 525 | 525 | //initialize the color table |
| 526 | 526 | for(j = 1, n = 0, i = 0; i < 8; i++) |
| r10256 | r10257 | |
| 559 | 559 | { |
| 560 | 560 | UINT8 c0, c1, pix[60]; |
| 561 | 561 | UINT16 i, j, d; |
| 562 | | |
| 563 | | c1 = (a & 1) ? (DOR >> 4) & 7 : DOR & 7; //foreground color = DOR |
| 564 | | c0 = MAT & 7; //background color = MAT |
| 565 | 562 | |
| 563 | c1 = (a & 1) ? (m_dor >> 4) & 7 : m_dor & 7; //foreground color = DOR |
| 564 | c0 = m_mat & 7; //background color = MAT |
| 565 | |
| 566 | 566 | switch(c & 0x80) |
| 567 | 567 | { |
| 568 | 568 | case 0: //alphanumeric G0 set |
| r10256 | r10257 | |
| 572 | 572 | //A3: N = negative |
| 573 | 573 | //C0-6: character code |
| 574 | 574 | |
| 575 | | if ((a & 4) && (PAT & 0x40) && (blink)) |
| 576 | | c1 = c0; //flash |
| 575 | if ((a & 4) && (m_pat & 0x40) && (m_blink)) |
| 576 | c1 = c0; //flash |
| 577 | 577 | if (a & 8) //negative |
| 578 | 578 | { |
| 579 | 579 | i = c1; |
| r10256 | r10257 | |
| 631 | 631 | UINT8 a, b, c0, c1, i, f, m, n, u, type, dial; |
| 632 | 632 | UINT16 address, iblock; |
| 633 | 633 | |
| 634 | | iblock = (MAT & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y); |
| 635 | | a = videoram->read_byte(block + iblock); |
| 636 | | b = videoram->read_byte(block + iblock + 0x0800); |
| 634 | iblock = (m_mat & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y); |
| 635 | a = m_videoram->read_byte(m_block + iblock); |
| 636 | b = m_videoram->read_byte(m_block + iblock + 0x0800); |
| 637 | 637 | |
| 638 | 638 | dial = get_dial(x, (a & 0x80) ? 0 : (((a & 0x20) >> 5) | ((a & 0x10) >> 3))); |
| 639 | 639 | |
| r10256 | r10257 | |
| 650 | 650 | |
| 651 | 651 | //reset attributes latch |
| 652 | 652 | if (x == 0) |
| 653 | | latchm = latchi = latchu = latchc0 = 0; |
| 653 | m_latchm = m_latchi = m_latchu = m_latchc0 = 0; |
| 654 | 654 | |
| 655 | 655 | if (type == 4) |
| 656 | 656 | { |
| 657 | | latchm = b & 1; |
| 658 | | latchi = (b & 2) >> 1; |
| 659 | | latchu = (b & 4) >> 2; |
| 657 | m_latchm = b & 1; |
| 658 | m_latchi = (b & 2) >> 1; |
| 659 | m_latchu = (b & 4) >> 2; |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | if (a & 0x80) |
| 663 | | latchc0 = (a & 0x70) >> 4; |
| 663 | m_latchc0 = (a & 0x70) >> 4; |
| 664 | 664 | |
| 665 | 665 | //char attributes |
| 666 | | c0 = latchc0; //background |
| 666 | c0 = m_latchc0; //background |
| 667 | 667 | c1 = a & 0x07; //foreground |
| 668 | | i = latchi; //insert mode |
| 668 | i = m_latchi; //insert mode |
| 669 | 669 | f = (a & 0x08) >> 3; //flash |
| 670 | | m = latchm; //hided |
| 670 | m = m_latchm; //hided |
| 671 | 671 | n = (a & 0x80) ? 0: ((a & 0x40) >> 6); //negative |
| 672 | | u = latchu; //underline |
| 672 | u = m_latchu; //underline |
| 673 | 673 | |
| 674 | 674 | bichrome40(type, address, dial, iblock, x, y, c0, c1, i, f, m, n, u); |
| 675 | 675 | } |
| r10256 | r10257 | |
| 680 | 680 | UINT8 a, b, c, c0, c1, i, f, m, n, u, type, dial; |
| 681 | 681 | UINT16 address, iblock; |
| 682 | 682 | |
| 683 | | iblock = (MAT & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y); |
| 684 | | c = videoram->read_byte(block + iblock); |
| 685 | | b = videoram->read_byte(block + iblock + 0x0800); |
| 686 | | a = videoram->read_byte(block + iblock + 0x1000); |
| 683 | iblock = (m_mat & 0x80 && y > 1) ? indexblock(x, y / 2) : indexblock(x, y); |
| 684 | c = m_videoram->read_byte(m_block + iblock); |
| 685 | b = m_videoram->read_byte(m_block + iblock + 0x0800); |
| 686 | a = m_videoram->read_byte(m_block + iblock + 0x1000); |
| 687 | 687 | |
| 688 | 688 | if ((b & 0xc0) == 0xc0) |
| 689 | 689 | { |
| r10256 | r10257 | |
| 713 | 713 | void ef9345_device::makechar_12x80(UINT16 x, UINT16 y) |
| 714 | 714 | { |
| 715 | 715 | UINT16 iblock = indexblock(x, y); |
| 716 | | bichrome80(videoram->read_byte(block + iblock), (videoram->read_byte(block + iblock + 0x1000) >> 4) & 0x0f, 2 * x + 1, y + 1); |
| 717 | | bichrome80(videoram->read_byte(block + iblock + 0x0800), videoram->read_byte(block + iblock + 0x1000) & 0x0f, 2 * x + 2, y + 1); |
| 716 | bichrome80(m_videoram->read_byte(m_block + iblock), (m_videoram->read_byte(m_block + iblock + 0x1000) >> 4) & 0x0f, 2 * x + 1, y + 1); |
| 717 | bichrome80(m_videoram->read_byte(m_block + iblock + 0x0800), m_videoram->read_byte(m_block + iblock + 0x1000) & 0x0f, 2 * x + 2, y + 1); |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | void ef9345_device::draw_border(UINT16 line) |
| 721 | 721 | { |
| 722 | | if (char_mode == MODE12x80 || char_mode == MODE8x80) |
| 722 | if (m_char_mode == MODE12x80 || m_char_mode == MODE8x80) |
| 723 | 723 | for(int i = 0; i < 82; i++) |
| 724 | | draw_char_80(border, i, line); |
| 724 | draw_char_80(m_border, i, line); |
| 725 | 725 | else |
| 726 | 726 | for(int i = 0; i < 42; i++) |
| 727 | | draw_char_40(border, i, line); |
| 727 | draw_char_40(m_border, i, line); |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | void ef9345_device::makechar(UINT16 x, UINT16 y) |
| 731 | 731 | { |
| 732 | | switch (char_mode) |
| 732 | switch (m_char_mode) |
| 733 | 733 | { |
| 734 | 734 | case MODE24x40: |
| 735 | 735 | makechar_24x40(x, y); |
| 736 | 736 | break; |
| 737 | 737 | case MODEVAR40: |
| 738 | 738 | case MODE8x80: |
| 739 | | logerror("Unemulated EF9345 mode: %02x\n", char_mode); |
| 739 | logerror("Unemulated EF9345 mode: %02x\n", m_char_mode); |
| 740 | 740 | break; |
| 741 | 741 | case MODE12x80: |
| 742 | 742 | makechar_12x80(x, y); |
| r10256 | r10257 | |
| 745 | 745 | makechar_16x40(x, y); |
| 746 | 746 | break; |
| 747 | 747 | default: |
| 748 | | logerror("Unknown EF9345 mode: %02x\n", char_mode); |
| 748 | logerror("Unknown EF9345 mode: %02x\n", m_char_mode); |
| 749 | 749 | break; |
| 750 | 750 | } |
| 751 | 751 | } |
| r10256 | r10257 | |
| 753 | 753 | // Execute EF9345 command |
| 754 | 754 | void ef9345_device::ef9345_exec(UINT8 cmd) |
| 755 | 755 | { |
| 756 | | state = 0; |
| 757 | | if ((registers[5] & 0x3f) == 39) state |= 0x10; //S4(LXa) set |
| 758 | | if ((registers[7] & 0x3f) == 39) state |= 0x20; //S5(LXm) set |
| 756 | m_state = 0; |
| 757 | if ((m_registers[5] & 0x3f) == 39) m_state |= 0x10; //S4(LXa) set |
| 758 | if ((m_registers[7] & 0x3f) == 39) m_state |= 0x20; //S5(LXm) set |
| 759 | 759 | |
| 760 | 760 | UINT16 a = indexram(7); |
| 761 | 761 | |
| r10256 | r10257 | |
| 764 | 764 | case 0x00: //KRF: R1,R2,R3->ram |
| 765 | 765 | case 0x01: //KRF: R1,R2,R3->ram + increment |
| 766 | 766 | set_busy_flag(4); |
| 767 | | videoram->write_byte(a, registers[1]); |
| 768 | | videoram->write_byte(a + 0x0800, registers[2]); |
| 769 | | videoram->write_byte(a + 0x1000, registers[3]); |
| 767 | m_videoram->write_byte(a, m_registers[1]); |
| 768 | m_videoram->write_byte(a + 0x0800, m_registers[2]); |
| 769 | m_videoram->write_byte(a + 0x1000, m_registers[3]); |
| 770 | 770 | if (cmd&1) inc_x(7); |
| 771 | 771 | break; |
| 772 | 772 | case 0x02: //KRG: R1,R2->ram |
| 773 | 773 | case 0x03: //KRG: R1,R2->ram + increment |
| 774 | 774 | set_busy_flag(5.5); |
| 775 | | videoram->write_byte(a, registers[1]); |
| 776 | | videoram->write_byte(a + 0x0800, registers[2]); |
| 775 | m_videoram->write_byte(a, m_registers[1]); |
| 776 | m_videoram->write_byte(a + 0x0800, m_registers[2]); |
| 777 | 777 | if (cmd&1) inc_x(7); |
| 778 | 778 | break; |
| 779 | 779 | case 0x08: //KRF: ram->R1,R2,R3 |
| 780 | 780 | case 0x09: //KRF: ram->R1,R2,R3 + increment |
| 781 | 781 | set_busy_flag(7.5); |
| 782 | | registers[1] = videoram->read_byte(a); |
| 783 | | registers[2] = videoram->read_byte(a + 0x0800); |
| 784 | | registers[3] = videoram->read_byte(a + 0x1000); |
| 782 | m_registers[1] = m_videoram->read_byte(a); |
| 783 | m_registers[2] = m_videoram->read_byte(a + 0x0800); |
| 784 | m_registers[3] = m_videoram->read_byte(a + 0x1000); |
| 785 | 785 | if (cmd&1) inc_x(7); |
| 786 | 786 | break; |
| 787 | 787 | case 0x0a: //KRG: ram->R1,R2 |
| 788 | 788 | case 0x0b: //KRG: ram->R1,R2 + increment |
| 789 | 789 | set_busy_flag(7.5); |
| 790 | | registers[1] = videoram->read_byte(a); |
| 791 | | registers[2] = videoram->read_byte(a + 0x0800); |
| 790 | m_registers[1] = m_videoram->read_byte(a); |
| 791 | m_registers[2] = m_videoram->read_byte(a + 0x0800); |
| 792 | 792 | if (cmd&1) inc_x(7); |
| 793 | 793 | break; |
| 794 | 794 | case 0x30: //OCT: R1->RAM, main pointer |
| 795 | 795 | case 0x31: //OCT: R1->RAM, main pointer + inc |
| 796 | 796 | set_busy_flag(4); |
| 797 | | videoram->write_byte(indexram(7), registers[1]); |
| 797 | m_videoram->write_byte(indexram(7), m_registers[1]); |
| 798 | 798 | |
| 799 | 799 | if (cmd&1) |
| 800 | 800 | { |
| 801 | 801 | inc_x(7); |
| 802 | | if ((registers[7] & 0x3f) == 0) |
| 802 | if ((m_registers[7] & 0x3f) == 0) |
| 803 | 803 | inc_y(6); |
| 804 | 804 | } |
| 805 | 805 | break; |
| 806 | 806 | case 0x34: //OCT: R1->RAM, aux pointer |
| 807 | 807 | case 0x35: //OCT: R1->RAM, aux pointer + inc |
| 808 | 808 | set_busy_flag(4); |
| 809 | | videoram->write_byte(indexram(5), registers[1]); |
| 809 | m_videoram->write_byte(indexram(5), m_registers[1]); |
| 810 | 810 | |
| 811 | 811 | if (cmd&1) |
| 812 | 812 | inc_x(5); |
| r10256 | r10257 | |
| 814 | 814 | case 0x38: //OCT: RAM->R1, main pointer |
| 815 | 815 | case 0x39: //OCT: RAM->R1, main pointer + inc |
| 816 | 816 | set_busy_flag(4.5); |
| 817 | | registers[1] = videoram->read_byte(indexram(7)); |
| 817 | m_registers[1] = m_videoram->read_byte(indexram(7)); |
| 818 | 818 | |
| 819 | 819 | if (cmd&1) |
| 820 | 820 | { |
| 821 | 821 | inc_x(7); |
| 822 | 822 | |
| 823 | | if ((registers[7] & 0x3f) == 0) |
| 823 | if ((m_registers[7] & 0x3f) == 0) |
| 824 | 824 | inc_y(6); |
| 825 | 825 | } |
| 826 | 826 | break; |
| 827 | 827 | case 0x3c: //OCT: RAM->R1, aux pointer |
| 828 | 828 | case 0x3d: //OCT: RAM->R1, aux pointer + inc |
| 829 | 829 | set_busy_flag(4.5); |
| 830 | | registers[1] = videoram->read_byte(indexram(5)); |
| 830 | m_registers[1] = m_videoram->read_byte(indexram(5)); |
| 831 | 831 | |
| 832 | 832 | if (cmd&1) |
| 833 | 833 | inc_x(5); |
| r10256 | r10257 | |
| 835 | 835 | case 0x50: //KRL: 80 UINT8 - 12 bits write |
| 836 | 836 | case 0x51: //KRL: 80 UINT8 - 12 bits write + inc |
| 837 | 837 | set_busy_flag(12.5); |
| 838 | | videoram->write_byte(a, registers[1]); |
| 838 | m_videoram->write_byte(a, m_registers[1]); |
| 839 | 839 | switch((a / 0x0800) & 1) |
| 840 | 840 | { |
| 841 | 841 | case 0: |
| 842 | 842 | { |
| 843 | | UINT8 tmp_data = videoram->read_byte(a + 0x1000); |
| 844 | | videoram->write_byte(a + 0x1000, (tmp_data & 0x0f) | (registers[3] & 0xf0)); |
| 843 | UINT8 tmp_data = m_videoram->read_byte(a + 0x1000); |
| 844 | m_videoram->write_byte(a + 0x1000, (tmp_data & 0x0f) | (m_registers[3] & 0xf0)); |
| 845 | 845 | break; |
| 846 | 846 | } |
| 847 | 847 | case 1: |
| 848 | 848 | { |
| 849 | | UINT8 tmp_data = videoram->read_byte(a + 0x0800); |
| 850 | | videoram->write_byte(a + 0x0800, (tmp_data & 0xf0) | (registers[3] & 0x0f)); |
| 849 | UINT8 tmp_data = m_videoram->read_byte(a + 0x0800); |
| 850 | m_videoram->write_byte(a + 0x0800, (tmp_data & 0xf0) | (m_registers[3] & 0x0f)); |
| 851 | 851 | break; |
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | if (cmd&1) |
| 855 | 855 | { |
| 856 | | if ((registers[7] & 0x80) == 0x00) { registers[7] |= 0x80; return; } |
| 857 | | registers[7] &= 0x80; |
| 856 | if ((m_registers[7] & 0x80) == 0x00) { m_registers[7] |= 0x80; return; } |
| 857 | m_registers[7] &= 0x80; |
| 858 | 858 | inc_x(7); |
| 859 | 859 | } |
| 860 | 860 | break; |
| 861 | 861 | case 0x58: //KRL: 80 UINT8 - 12 bits read |
| 862 | 862 | case 0x59: //KRL: 80 UINT8 - 12 bits read + inc |
| 863 | 863 | set_busy_flag(11.5); |
| 864 | | registers[1] = videoram->read_byte(a); |
| 864 | m_registers[1] = m_videoram->read_byte(a); |
| 865 | 865 | switch((a / 0x0800) & 1) |
| 866 | 866 | { |
| 867 | 867 | case 0: |
| 868 | | registers[3] = videoram->read_byte(a + 0x1000); |
| 868 | m_registers[3] = m_videoram->read_byte(a + 0x1000); |
| 869 | 869 | break; |
| 870 | 870 | case 1: |
| 871 | | registers[3] = videoram->read_byte(a + 0x0800); |
| 871 | m_registers[3] = m_videoram->read_byte(a + 0x0800); |
| 872 | 872 | break; |
| 873 | 873 | } |
| 874 | 874 | if (cmd&1) |
| 875 | 875 | { |
| 876 | | if ((registers[7] & 0x80) == 0x00) |
| 876 | if ((m_registers[7] & 0x80) == 0x00) |
| 877 | 877 | { |
| 878 | | registers[7] |= 0x80; |
| 878 | m_registers[7] |= 0x80; |
| 879 | 879 | break;; |
| 880 | 880 | } |
| 881 | | registers[7] &= 0x80; |
| 881 | m_registers[7] &= 0x80; |
| 882 | 882 | inc_x(7); |
| 883 | 883 | } |
| 884 | 884 | break; |
| r10256 | r10257 | |
| 892 | 892 | set_busy_flag(2); |
| 893 | 893 | switch(cmd&7) |
| 894 | 894 | { |
| 895 | | case 1: TGS = registers[1]; break; |
| 896 | | case 2: MAT = registers[1]; break; |
| 897 | | case 3: PAT = registers[1]; break; |
| 898 | | case 4: DOR = registers[1]; break; |
| 899 | | case 7: ROR = registers[1]; break; |
| 895 | case 1: m_tgs = m_registers[1]; break; |
| 896 | case 2: m_mat = m_registers[1]; break; |
| 897 | case 3: m_pat = m_registers[1]; break; |
| 898 | case 4: m_dor = m_registers[1]; break; |
| 899 | case 7: m_ror = m_registers[1]; break; |
| 900 | 900 | } |
| 901 | 901 | set_video_mode(); |
| 902 | | state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 902 | m_state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 903 | 903 | break; |
| 904 | 904 | case 0x88: //IND: ROM->R1 |
| 905 | 905 | case 0x89: //IND: TGS->R1 |
| r10256 | r10257 | |
| 910 | 910 | set_busy_flag(3.5); |
| 911 | 911 | switch(cmd&7) |
| 912 | 912 | { |
| 913 | | case 0: registers[1] = charset->u8(indexrom(7) & 0x1fff); |
| 914 | | case 1: registers[1] = TGS; break; |
| 915 | | case 2: registers[1] = MAT; break; |
| 916 | | case 3: registers[1] = PAT; break; |
| 917 | | case 4: registers[1] = DOR; break; |
| 918 | | case 7: registers[1] = ROR; break; |
| 913 | case 0: m_registers[1] = m_charset->u8(indexrom(7) & 0x1fff); |
| 914 | case 1: m_registers[1] = m_tgs; break; |
| 915 | case 2: m_registers[1] = m_mat; break; |
| 916 | case 3: m_registers[1] = m_pat; break; |
| 917 | case 4: m_registers[1] = m_dor; break; |
| 918 | case 7: m_registers[1] = m_ror; break; |
| 919 | 919 | } |
| 920 | | state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 920 | m_state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 921 | 921 | break; |
| 922 | 922 | case 0x90: //NOP: no operation |
| 923 | 923 | case 0x91: //NOP: no operation |
| r10256 | r10257 | |
| 927 | 927 | case 0xb0: //INY: increment Y |
| 928 | 928 | set_busy_flag(2); |
| 929 | 929 | inc_y(6); |
| 930 | | state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 930 | m_state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 931 | 931 | break; |
| 932 | 932 | case 0xd5: //MVB: move buffer MP->AP stop |
| 933 | 933 | case 0xd6: //MVB: move buffer MP->AP nostop |
| r10256 | r10257 | |
| 951 | 951 | for(i = 0; i < 1280; i++) |
| 952 | 952 | { |
| 953 | 953 | a1 = indexram(r1); a2 = indexram(r2); |
| 954 | | videoram->write_byte(a2, videoram->read_byte(a1)); |
| 954 | m_videoram->write_byte(a2, m_videoram->read_byte(a1)); |
| 955 | 955 | |
| 956 | | if (n > 1) videoram->write_byte(a2 + 0x0800, videoram->read_byte(a1 + 0x0800)); |
| 957 | | if (n > 2) videoram->write_byte(a2 + 0x1000, videoram->read_byte(a1 + 0x1000)); |
| 956 | if (n > 1) m_videoram->write_byte(a2 + 0x0800, m_videoram->read_byte(a1 + 0x0800)); |
| 957 | if (n > 2) m_videoram->write_byte(a2 + 0x1000, m_videoram->read_byte(a1 + 0x1000)); |
| 958 | 958 | |
| 959 | 959 | inc_x(r1); |
| 960 | 960 | inc_x(r2); |
| 961 | | if ((registers[5] & 0x3f) == 0 && (cmd&1)) |
| 961 | if ((m_registers[5] & 0x3f) == 0 && (cmd&1)) |
| 962 | 962 | break; |
| 963 | 963 | |
| 964 | | if ((registers[7] & 0x3f) == 0) |
| 964 | if ((m_registers[7] & 0x3f) == 0) |
| 965 | 965 | { |
| 966 | 966 | if (cmd&1) |
| 967 | 967 | break; |
| r10256 | r10257 | |
| 971 | 971 | |
| 972 | 972 | busy += 4 * n; |
| 973 | 973 | } |
| 974 | | state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 974 | m_state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 975 | 975 | set_busy_flag(busy); |
| 976 | 976 | } |
| 977 | 977 | break; |
| r10256 | r10257 | |
| 993 | 993 | |
| 994 | 994 | void ef9345_device::video_update(bitmap_t *bitmap, const rectangle *cliprect) |
| 995 | 995 | { |
| 996 | | copybitmap(bitmap, screen_out, 0, 0, 0, 0, cliprect); |
| 996 | copybitmap(bitmap, m_screen_out, 0, 0, 0, 0, cliprect); |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | void ef9345_device::update_scanline(UINT16 scanline) |
| r10256 | r10257 | |
| 1001 | 1001 | UINT16 i; |
| 1002 | 1002 | |
| 1003 | 1003 | if (scanline == 250) |
| 1004 | | state &= 0xfb; |
| 1004 | m_state &= 0xfb; |
| 1005 | 1005 | |
| 1006 | 1006 | set_busy_flag(104); |
| 1007 | 1007 | |
| 1008 | | if (char_mode == MODE12x80 || char_mode == MODE8x80) |
| 1008 | if (m_char_mode == MODE12x80 || m_char_mode == MODE8x80) |
| 1009 | 1009 | { |
| 1010 | | draw_char_80(border, 0, (scanline / 10) + 1); |
| 1011 | | draw_char_80(border, 81, (scanline / 10) + 1); |
| 1010 | draw_char_80(m_border, 0, (scanline / 10) + 1); |
| 1011 | draw_char_80(m_border, 81, (scanline / 10) + 1); |
| 1012 | 1012 | } |
| 1013 | 1013 | else |
| 1014 | 1014 | { |
| 1015 | | draw_char_40(border, 0, (scanline / 10) + 1); |
| 1016 | | draw_char_40(border, 41, (scanline / 10) + 1); |
| 1015 | draw_char_40(m_border, 0, (scanline / 10) + 1); |
| 1016 | draw_char_40(m_border, 41, (scanline / 10) + 1); |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | if (scanline == 0) |
| 1020 | 1020 | { |
| 1021 | | state |= 0x04; |
| 1021 | m_state |= 0x04; |
| 1022 | 1022 | draw_border(0); |
| 1023 | | if (PAT & 1) |
| 1023 | if (m_pat & 1) |
| 1024 | 1024 | for(i = 0; i < 40; i++) |
| 1025 | 1025 | makechar(i, (scanline / 10)); |
| 1026 | 1026 | else |
| 1027 | 1027 | for(i = 0; i < 42; i++) |
| 1028 | | draw_char_40(border, i, 1); |
| 1028 | draw_char_40(m_border, i, 1); |
| 1029 | 1029 | } |
| 1030 | 1030 | else if (scanline < 120) |
| 1031 | 1031 | { |
| 1032 | | if (PAT & 2) |
| 1032 | if (m_pat & 2) |
| 1033 | 1033 | for(i = 0; i < 40; i++) |
| 1034 | 1034 | makechar(i, (scanline / 10)); |
| 1035 | 1035 | else |
| r10256 | r10257 | |
| 1037 | 1037 | } |
| 1038 | 1038 | else if (scanline < 250) |
| 1039 | 1039 | { |
| 1040 | | if (PAT & 4) |
| 1040 | if (m_pat & 4) |
| 1041 | 1041 | for(i = 0; i < 40; i++) |
| 1042 | 1042 | makechar(i, (scanline / 10)); |
| 1043 | 1043 | else |
| r10256 | r10257 | |
| 1051 | 1051 | READ8_MEMBER( ef9345_device::data_r ) |
| 1052 | 1052 | { |
| 1053 | 1053 | if (offset & 7) |
| 1054 | | return registers[offset & 7]; |
| 1054 | return m_registers[offset & 7]; |
| 1055 | 1055 | |
| 1056 | | if (bf) |
| 1057 | | state |= 0x80; |
| 1056 | if (m_bf) |
| 1057 | m_state |= 0x80; |
| 1058 | 1058 | else |
| 1059 | | state &= 0x7f; |
| 1059 | m_state &= 0x7f; |
| 1060 | 1060 | |
| 1061 | | return state; |
| 1061 | return m_state; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | 1064 | WRITE8_MEMBER( ef9345_device::data_w ) |
| 1065 | 1065 | { |
| 1066 | | registers[offset & 7] = data; |
| 1066 | m_registers[offset & 7] = data; |
| 1067 | 1067 | |
| 1068 | 1068 | if (offset & 8) |
| 1069 | | ef9345_exec(registers[0] & 0xff); |
| 1069 | ef9345_exec(m_registers[0] & 0xff); |
| 1070 | 1070 | } |
src/mess/video/hd44352.c
| r10256 | r10257 | |
| 112 | 112 | m_on_timer = device_timer_alloc(*this, ON_TIMER); |
| 113 | 113 | timer_adjust_periodic(m_on_timer, ATTOTIME_IN_HZ(m_clock/16384), 0, ATTOTIME_IN_HZ(m_clock/16384)); |
| 114 | 114 | |
| 115 | | state_save_register_device_item( this, 0, control_lines); |
| 116 | | state_save_register_device_item( this, 0, data_bus); |
| 117 | | state_save_register_device_item( this, 0, state); |
| 118 | | state_save_register_device_item( this, 0, offset); |
| 119 | | state_save_register_device_item( this, 0, char_width); |
| 120 | | state_save_register_device_item( this, 0, bank); |
| 121 | | state_save_register_device_item( this, 0, lcd_on); |
| 122 | | state_save_register_device_item( this, 0, scroll); |
| 123 | | state_save_register_device_item( this, 0, contrast); |
| 124 | | state_save_register_device_item( this, 0, byte_count); |
| 125 | | state_save_register_device_item( this, 0, cursor_status); |
| 126 | | state_save_register_device_item( this, 0, cursor_x); |
| 127 | | state_save_register_device_item( this, 0, cursor_y); |
| 128 | | state_save_register_device_item( this, 0, cursor_lcd); |
| 129 | | state_save_register_device_item_array( this, 0, video_ram[0]); |
| 130 | | state_save_register_device_item_array( this, 0, video_ram[1]); |
| 131 | | state_save_register_device_item_array( this, 0, par); |
| 132 | | state_save_register_device_item_array( this, 0, cursor); |
| 133 | | state_save_register_device_item_array( this, 0, custom_char[0]); |
| 134 | | state_save_register_device_item_array( this, 0, custom_char[1]); |
| 135 | | state_save_register_device_item_array( this, 0, custom_char[2]); |
| 136 | | state_save_register_device_item_array( this, 0, custom_char[3]); |
| 115 | state_save_register_device_item( this, 0, m_control_lines); |
| 116 | state_save_register_device_item( this, 0, m_data_bus); |
| 117 | state_save_register_device_item( this, 0, m_state); |
| 118 | state_save_register_device_item( this, 0, m_offset); |
| 119 | state_save_register_device_item( this, 0, m_char_width); |
| 120 | state_save_register_device_item( this, 0, m_bank); |
| 121 | state_save_register_device_item( this, 0, m_lcd_on); |
| 122 | state_save_register_device_item( this, 0, m_scroll); |
| 123 | state_save_register_device_item( this, 0, m_contrast); |
| 124 | state_save_register_device_item( this, 0, m_byte_count); |
| 125 | state_save_register_device_item( this, 0, m_cursor_status); |
| 126 | state_save_register_device_item( this, 0, m_cursor_x); |
| 127 | state_save_register_device_item( this, 0, m_cursor_y); |
| 128 | state_save_register_device_item( this, 0, m_cursor_lcd); |
| 129 | state_save_register_device_item_array( this, 0, m_video_ram[0]); |
| 130 | state_save_register_device_item_array( this, 0, m_video_ram[1]); |
| 131 | state_save_register_device_item_array( this, 0, m_par); |
| 132 | state_save_register_device_item_array( this, 0, m_cursor); |
| 133 | state_save_register_device_item_array( this, 0, m_custom_char[0]); |
| 134 | state_save_register_device_item_array( this, 0, m_custom_char[1]); |
| 135 | state_save_register_device_item_array( this, 0, m_custom_char[2]); |
| 136 | state_save_register_device_item_array( this, 0, m_custom_char[3]); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
| r10256 | r10257 | |
| 143 | 143 | |
| 144 | 144 | void hd44352_device::device_reset() |
| 145 | 145 | { |
| 146 | | memset(video_ram, 0x00, 0x300); |
| 147 | | memset(par, 0x00, 3); |
| 148 | | memset(custom_char, 0x00, 4*8); |
| 149 | | memset(cursor, 0x00, 8); |
| 150 | | control_lines = 0; |
| 151 | | data_bus = 0xff; |
| 152 | | state = 0; |
| 153 | | bank = 0; |
| 154 | | offset = 0; |
| 155 | | char_width = 6; |
| 156 | | lcd_on = 0; |
| 157 | | scroll = 0; |
| 158 | | byte_count = 0; |
| 159 | | cursor_status = 0; |
| 160 | | cursor_x = 0; |
| 161 | | cursor_y = 0; |
| 162 | | cursor_lcd = 0; |
| 163 | | contrast = 0; |
| 146 | memset(m_video_ram, 0x00, sizeof(m_video_ram)); |
| 147 | memset(m_par, 0x00, sizeof(m_par)); |
| 148 | memset(m_custom_char, 0x00, sizeof(m_custom_char)); |
| 149 | memset(m_cursor, 0x00, sizeof(m_cursor)); |
| 150 | m_control_lines = 0; |
| 151 | m_data_bus = 0xff; |
| 152 | m_state = 0; |
| 153 | m_bank = 0; |
| 154 | m_offset = 0; |
| 155 | m_char_width = 6; |
| 156 | m_lcd_on = 0; |
| 157 | m_scroll = 0; |
| 158 | m_byte_count = 0; |
| 159 | m_cursor_status = 0; |
| 160 | m_cursor_x = 0; |
| 161 | m_cursor_y = 0; |
| 162 | m_cursor_lcd = 0; |
| 163 | m_contrast = 0; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
| r10256 | r10257 | |
| 172 | 172 | switch(id) |
| 173 | 173 | { |
| 174 | 174 | case ON_TIMER: |
| 175 | | if (control_lines & 0x40) |
| 175 | if (m_control_lines & 0x40) |
| 176 | 176 | { |
| 177 | 177 | devcb_call_write_line(&m_on, ASSERT_LINE); |
| 178 | 178 | devcb_call_write_line(&m_on, CLEAR_LINE); |
| r10256 | r10257 | |
| 187 | 187 | |
| 188 | 188 | int hd44352_device::video_update(bitmap_t &bitmap, const rectangle &cliprect) |
| 189 | 189 | { |
| 190 | | UINT8 cw = char_width; |
| 190 | UINT8 cw = m_char_width; |
| 191 | 191 | |
| 192 | 192 | bitmap_fill(&bitmap, &cliprect, 0); |
| 193 | 193 | |
| 194 | | if (control_lines&0x80 && lcd_on) |
| 194 | if (m_control_lines&0x80 && m_lcd_on) |
| 195 | 195 | { |
| 196 | 196 | for (int a=0; a<2; a++) |
| 197 | 197 | for (int py=0; py<4; py++) |
| 198 | 198 | for (int px=0; px<16; px++) |
| 199 | | if (BIT(cursor_status, 4) && px == cursor_x && py == cursor_y && a == cursor_lcd) |
| 199 | if (BIT(m_cursor_status, 4) && px == m_cursor_x && py == m_cursor_y && a == m_cursor_lcd) |
| 200 | 200 | { |
| 201 | 201 | //draw the cursor |
| 202 | 202 | for (int c=0; c<cw; c++) |
| 203 | 203 | { |
| 204 | | UINT8 d = compute_newval((cursor_status>>5) & 0x07, video_ram[a][py*16*cw + px*cw + c + scroll * 48], cursor[c]); |
| 204 | UINT8 d = compute_newval((m_cursor_status>>5) & 0x07, m_video_ram[a][py*16*cw + px*cw + c + m_scroll * 48], m_cursor[c]); |
| 205 | 205 | for (int b=0; b<8; b++) |
| 206 | 206 | { |
| 207 | 207 | *BITMAP_ADDR16(&bitmap, py*8 + b, a*cw*16 + px*cw + c) = BIT(d, 7-b); |
| r10256 | r10257 | |
| 212 | 212 | { |
| 213 | 213 | for (int c=0; c<cw; c++) |
| 214 | 214 | { |
| 215 | | UINT8 d = video_ram[a][py*16*cw + px*cw + c + scroll * 48]; |
| 215 | UINT8 d = m_video_ram[a][py*16*cw + px*cw + c + m_scroll * 48]; |
| 216 | 216 | for (int b=0; b<8; b++) |
| 217 | 217 | { |
| 218 | 218 | *BITMAP_ADDR16(&bitmap, py*8 + b, a*cw*16 + px*cw + c) = BIT(d, 7-b); |
| r10256 | r10257 | |
| 227 | 227 | |
| 228 | 228 | void hd44352_device::control_write(UINT8 data) |
| 229 | 229 | { |
| 230 | | if(control_lines == data) |
| 231 | | state = 0; |
| 230 | if(m_control_lines == data) |
| 231 | m_state = 0; |
| 232 | 232 | |
| 233 | | control_lines = data; |
| 233 | m_control_lines = data; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | UINT8 hd44352_device::compute_newval(UINT8 type, UINT8 oldval, UINT8 newval) |
| r10256 | r10257 | |
| 261 | 261 | switch ((UINT8)pos/8) |
| 262 | 262 | { |
| 263 | 263 | case 0xcf: |
| 264 | | return custom_char[0][pos%8]; |
| 264 | return m_custom_char[0][pos%8]; |
| 265 | 265 | case 0xdf: |
| 266 | | return custom_char[1][pos%8]; |
| 266 | return m_custom_char[1][pos%8]; |
| 267 | 267 | case 0xef: |
| 268 | | return custom_char[2][pos%8]; |
| 268 | return m_custom_char[2][pos%8]; |
| 269 | 269 | case 0xff: |
| 270 | | return custom_char[3][pos%8]; |
| 270 | return m_custom_char[3][pos%8]; |
| 271 | 271 | default: |
| 272 | 272 | return region()->u8(pos); |
| 273 | 273 | } |
| r10256 | r10257 | |
| 276 | 276 | void hd44352_device::data_write(UINT8 data) |
| 277 | 277 | { |
| 278 | 278 | // verify that controller is active |
| 279 | | if (!(control_lines&0x80)) |
| 279 | if (!(m_control_lines&0x80)) |
| 280 | 280 | return; |
| 281 | 281 | |
| 282 | | if (control_lines & 0x01) |
| 282 | if (m_control_lines & 0x01) |
| 283 | 283 | { |
| 284 | | if (!(control_lines&0x02) && !(control_lines&0x04)) |
| 284 | if (!(m_control_lines&0x02) && !(m_control_lines&0x04)) |
| 285 | 285 | return; |
| 286 | 286 | |
| 287 | | switch (state) |
| 287 | switch (m_state) |
| 288 | 288 | { |
| 289 | 289 | case 0: //parameter 0 |
| 290 | | par[state++] = data; |
| 290 | m_par[m_state++] = data; |
| 291 | 291 | break; |
| 292 | 292 | case 1: //parameter 1 |
| 293 | | par[state++] = data; |
| 293 | m_par[m_state++] = data; |
| 294 | 294 | break; |
| 295 | 295 | case 2: //parameter 2 |
| 296 | | par[state++] = data; |
| 296 | m_par[m_state++] = data; |
| 297 | 297 | break; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | | switch (par[0] & 0x0f) |
| 300 | switch (m_par[0] & 0x0f) |
| 301 | 301 | { |
| 302 | 302 | case LCD_BYTE_INPUT: |
| 303 | 303 | case LCD_CHAR_OUTPUT: |
| 304 | 304 | { |
| 305 | | if (state == 1) |
| 306 | | bank = BIT(data, 4); |
| 307 | | else if (state == 2) |
| 308 | | offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48); |
| 309 | | else if (state == 3) |
| 310 | | offset += ((data & 0x03) * 96); |
| 305 | if (m_state == 1) |
| 306 | m_bank = BIT(data, 4); |
| 307 | else if (m_state == 2) |
| 308 | m_offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48); |
| 309 | else if (m_state == 3) |
| 310 | m_offset += ((data & 0x03) * 96); |
| 311 | 311 | } |
| 312 | 312 | break; |
| 313 | 313 | case LCD_BYTE_OUTPUT: |
| 314 | 314 | { |
| 315 | | if (state == 1) |
| 316 | | bank = BIT(data, 4); |
| 317 | | else if (state == 2) |
| 318 | | offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48); |
| 319 | | else if (state == 3) |
| 320 | | offset += ((data & 0x03) * 96); |
| 315 | if (m_state == 1) |
| 316 | m_bank = BIT(data, 4); |
| 317 | else if (m_state == 2) |
| 318 | m_offset = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48); |
| 319 | else if (m_state == 3) |
| 320 | m_offset += ((data & 0x03) * 96); |
| 321 | 321 | } |
| 322 | 322 | break; |
| 323 | 323 | case LCD_ON_OFF: |
| 324 | 324 | { |
| 325 | | if (state == 1) |
| 326 | | lcd_on = BIT(data, 4); |
| 327 | | data_bus = 0xff; |
| 328 | | state = 0; |
| 325 | if (m_state == 1) |
| 326 | m_lcd_on = BIT(data, 4); |
| 327 | m_data_bus = 0xff; |
| 328 | m_state = 0; |
| 329 | 329 | } |
| 330 | 330 | break; |
| 331 | 331 | case LCD_SCROLL_CHAR_WIDTH: |
| 332 | 332 | { |
| 333 | | if (state == 1) |
| 333 | if (m_state == 1) |
| 334 | 334 | { |
| 335 | | char_width = 8-((data>>4)&3); |
| 336 | | scroll = ((data>>6)&3); |
| 335 | m_char_width = 8-((data>>4)&3); |
| 336 | m_scroll = ((data>>6)&3); |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | | data_bus = 0xff; |
| 340 | | state = 0; |
| 339 | m_data_bus = 0xff; |
| 340 | m_state = 0; |
| 341 | 341 | } |
| 342 | 342 | break; |
| 343 | 343 | case LCD_CURSOR_STATUS: |
| 344 | 344 | { |
| 345 | | if (state == 1) |
| 346 | | cursor_status = data; |
| 347 | | data_bus = 0xff; |
| 348 | | state = 0; |
| 345 | if (m_state == 1) |
| 346 | m_cursor_status = data; |
| 347 | m_data_bus = 0xff; |
| 348 | m_state = 0; |
| 349 | 349 | } |
| 350 | 350 | break; |
| 351 | 351 | case LCD_CONTRAST: |
| 352 | 352 | { |
| 353 | | if (state == 1) |
| 354 | | contrast = (contrast & 0x00ffff) | (data<<16); |
| 355 | | else if (state == 2) |
| 356 | | contrast = (contrast & 0xff00ff) | (data<<8); |
| 357 | | else if (state == 3) |
| 353 | if (m_state == 1) |
| 354 | m_contrast = (m_contrast & 0x00ffff) | (data<<16); |
| 355 | else if (m_state == 2) |
| 356 | m_contrast = (m_contrast & 0xff00ff) | (data<<8); |
| 357 | else if (m_state == 3) |
| 358 | 358 | { |
| 359 | | contrast = (contrast & 0xffff00) | (data<<0); |
| 360 | | state = 0; |
| 359 | m_contrast = (m_contrast & 0xffff00) | (data<<0); |
| 360 | m_state = 0; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | | data_bus = 0xff; |
| 363 | m_data_bus = 0xff; |
| 364 | 364 | } |
| 365 | 365 | break; |
| 366 | 366 | case LCD_IRQ_FREQUENCY: |
| 367 | 367 | { |
| 368 | | if (state == 1) |
| 368 | if (m_state == 1) |
| 369 | 369 | { |
| 370 | 370 | UINT32 on_timer_rate; |
| 371 | 371 | |
| r10256 | r10257 | |
| 388 | 388 | |
| 389 | 389 | timer_adjust_periodic(m_on_timer, ATTOTIME_IN_HZ(m_clock/on_timer_rate), 0, ATTOTIME_IN_HZ(m_clock/on_timer_rate)); |
| 390 | 390 | } |
| 391 | | data_bus = 0xff; |
| 392 | | state = 0; |
| 391 | m_data_bus = 0xff; |
| 392 | m_state = 0; |
| 393 | 393 | } |
| 394 | 394 | break; |
| 395 | 395 | case LCD_CURSOR_POSITION: |
| 396 | 396 | { |
| 397 | | if (state == 1) |
| 398 | | cursor_lcd = BIT(data, 4); //0:left lcd 1:right lcd; |
| 399 | | else if (state == 2) |
| 400 | | cursor_x = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48); |
| 401 | | else if (state == 3) |
| 397 | if (m_state == 1) |
| 398 | m_cursor_lcd = BIT(data, 4); //0:left lcd 1:right lcd; |
| 399 | else if (m_state == 2) |
| 400 | m_cursor_x = ((data>>1)&0x3f) % 48 + (BIT(data,7) * 48); |
| 401 | else if (m_state == 3) |
| 402 | 402 | { |
| 403 | | cursor_y = data & 0x03; |
| 404 | | state = 0; |
| 403 | m_cursor_y = data & 0x03; |
| 404 | m_state = 0; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | | data_bus = 0xff; |
| 407 | m_data_bus = 0xff; |
| 408 | 408 | } |
| 409 | 409 | break; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | | byte_count = 0; |
| 413 | | data_bus = 0xff; |
| 412 | m_byte_count = 0; |
| 413 | m_data_bus = 0xff; |
| 414 | 414 | } |
| 415 | 415 | else |
| 416 | 416 | { |
| 417 | | switch (par[0] & 0x0f) |
| 417 | switch (m_par[0] & 0x0f) |
| 418 | 418 | { |
| 419 | 419 | case LCD_BYTE_INPUT: |
| 420 | 420 | { |
| 421 | | if (((par[0]>>5) & 0x07) != 0x03) |
| 421 | if (((m_par[0]>>5) & 0x07) != 0x03) |
| 422 | 422 | break; |
| 423 | 423 | |
| 424 | | offset %= 0x180; |
| 425 | | data_bus = ((video_ram[bank][offset]<<4)&0xf0) | ((video_ram[bank][offset]>>4)&0x0f); |
| 426 | | offset++; byte_count++; |
| 424 | m_offset %= 0x180; |
| 425 | m_data_bus = ((m_video_ram[m_bank][m_offset]<<4)&0xf0) | ((m_video_ram[m_bank][m_offset]>>4)&0x0f); |
| 426 | m_offset++; m_byte_count++; |
| 427 | 427 | } |
| 428 | 428 | break; |
| 429 | 429 | case LCD_BYTE_OUTPUT: |
| 430 | 430 | { |
| 431 | | offset %= 0x180; |
| 432 | | video_ram[bank][offset] = compute_newval((par[0]>>5) & 0x07, video_ram[bank][offset], data); |
| 433 | | offset++; byte_count++; |
| 431 | m_offset %= 0x180; |
| 432 | m_video_ram[m_bank][m_offset] = compute_newval((m_par[0]>>5) & 0x07, m_video_ram[m_bank][m_offset], data); |
| 433 | m_offset++; m_byte_count++; |
| 434 | 434 | |
| 435 | | data_bus = 0xff; |
| 435 | m_data_bus = 0xff; |
| 436 | 436 | } |
| 437 | 437 | break; |
| 438 | 438 | case LCD_CHAR_OUTPUT: |
| 439 | 439 | { |
| 440 | 440 | int char_pos = data*8; |
| 441 | 441 | |
| 442 | | for (int i=0; i<char_width; i++) |
| 442 | for (int i=0; i<m_char_width; i++) |
| 443 | 443 | { |
| 444 | | offset %= 0x180; |
| 445 | | video_ram[bank][offset] = compute_newval((par[0]>>5) & 0x07, video_ram[bank][offset], get_char(char_pos)); |
| 446 | | offset++; char_pos++; |
| 444 | m_offset %= 0x180; |
| 445 | m_video_ram[m_bank][m_offset] = compute_newval((m_par[0]>>5) & 0x07, m_video_ram[m_bank][m_offset], get_char(char_pos)); |
| 446 | m_offset++; char_pos++; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | | byte_count++; |
| 450 | | data_bus = 0xff; |
| 449 | m_byte_count++; |
| 450 | m_data_bus = 0xff; |
| 451 | 451 | } |
| 452 | 452 | break; |
| 453 | 453 | case LCD_CURSOR_GRAPHIC: |
| 454 | | if (byte_count<8) |
| 454 | if (m_byte_count<8) |
| 455 | 455 | { |
| 456 | | cursor[byte_count] = data; |
| 457 | | byte_count++; |
| 458 | | data_bus = 0xff; |
| 456 | m_cursor[m_byte_count] = data; |
| 457 | m_byte_count++; |
| 458 | m_data_bus = 0xff; |
| 459 | 459 | } |
| 460 | 460 | break; |
| 461 | 461 | case LCD_CURSOR_CHAR: |
| 462 | | if (byte_count<1) |
| 462 | if (m_byte_count<1) |
| 463 | 463 | { |
| 464 | 464 | UINT8 char_code = ((data<<4)&0xf0) | ((data>>4)&0x0f); |
| 465 | 465 | |
| 466 | 466 | for (int i=0; i<8; i++) |
| 467 | | cursor[i] = get_char(char_code*8 + i); |
| 467 | m_cursor[i] = get_char(char_code*8 + i); |
| 468 | 468 | |
| 469 | | byte_count++; |
| 470 | | data_bus = 0xff; |
| 469 | m_byte_count++; |
| 470 | m_data_bus = 0xff; |
| 471 | 471 | } |
| 472 | 472 | break; |
| 473 | 473 | case LCD_USER_CHARACTER: |
| 474 | | if (byte_count<8) |
| 474 | if (m_byte_count<8) |
| 475 | 475 | { |
| 476 | | custom_char[(par[0]&0x03)][byte_count] = data; |
| 477 | | byte_count++; |
| 478 | | data_bus = 0xff; |
| 476 | m_custom_char[(m_par[1]&0x03)][m_byte_count] = data; |
| 477 | m_byte_count++; |
| 478 | m_data_bus = 0xff; |
| 479 | 479 | } |
| 480 | 480 | break; |
| 481 | 481 | default: |
| 482 | | data_bus = 0xff; |
| 482 | m_data_bus = 0xff; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | | state=0; |
| 485 | m_state=0; |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | UINT8 hd44352_device::data_read() |
| 490 | 490 | { |
| 491 | | return data_bus; |
| 491 | return m_data_bus; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | // devices |
| 495 | 495 | const device_type HD44352 = hd44352_device_config::static_alloc_device_config; |
| 496 | | |