src/mess/video/hd44780.c
| r9749 | r9750 | |
| 114 | 114 | m_busy_timer = device_timer_alloc(*this, BUSY_TIMER); |
| 115 | 115 | m_blink_timer = device_timer_alloc(*this, BLINKING_TIMER); |
| 116 | 116 | |
| 117 | | timer_adjust_periodic(m_blink_timer, ATTOTIME_IN_MSEC(500), 0, ATTOTIME_IN_MSEC(500)); |
| 117 | timer_adjust_periodic(m_blink_timer, ATTOTIME_IN_MSEC(409), 0, ATTOTIME_IN_MSEC(409)); |
| 118 | 118 | |
| 119 | 119 | state_save_register_device_item( this, 0, ac); |
| 120 | 120 | state_save_register_device_item( this, 0, ac_mode); |
| r9749 | r9750 | |
| 173 | 173 | switch(id) |
| 174 | 174 | { |
| 175 | 175 | case BUSY_TIMER: |
| 176 | | if (data_bus_flag) |
| 177 | | { |
| 178 | | int new_ac = ac + direction; |
| 179 | | |
| 180 | | ac = (new_ac < 0) ? 0 : ((new_ac > 0x7f) ? 0x7f : new_ac); |
| 181 | | |
| 182 | | if (ac_mode == 0) |
| 183 | | { |
| 184 | | cursor_pos = ac; |
| 185 | | |
| 186 | | // display is shifted only after a write |
| 187 | | if (shift_on && data_bus_flag == 1) |
| 188 | | disp_shift += direction; |
| 189 | | } |
| 190 | | |
| 191 | | data_bus_flag = 0; |
| 192 | | } |
| 193 | | |
| 194 | 176 | busy_flag = 0; |
| 195 | 177 | break; |
| 196 | 178 | |
| r9749 | r9750 | |
| 205 | 187 | busy_flag = 1; |
| 206 | 188 | |
| 207 | 189 | timer_adjust_oneshot( m_busy_timer, ATTOTIME_IN_USEC( usec ), 0 ); |
| 190 | |
| 208 | 191 | } |
| 209 | 192 | |
| 210 | 193 | //************************************************************************** |
| r9749 | r9750 | |
| 364 | 347 | return busy_flag<<7 || ac&0x7f; |
| 365 | 348 | } |
| 366 | 349 | |
| 367 | | void hd44780_device::data_write(offs_t offset, UINT8 data) |
| 350 | void hd44780_device::update_ac(void) // data_bus_flag was left as global so old savestates will work |
| 368 | 351 | { |
| 369 | | static int lastac = 0; |
| 370 | | if (lastac != ac_mode) { |
| 371 | | lastac = ac_mode; |
| 372 | | } |
| 352 | int new_ac = ac + direction; |
| 353 | ac = (new_ac < 0) ? 0 : ((new_ac > 0x7f) ? 0x7f : new_ac); |
| 354 | if (ac_mode == 0) { |
| 355 | cursor_pos = ac; |
| 356 | // display is shifted only after a write |
| 357 | if (shift_on && data_bus_flag == 1) disp_shift += direction; |
| 358 | } |
| 359 | data_bus_flag = 0; |
| 360 | } |
| 373 | 361 | |
| 374 | | if (ac_mode == 0) |
| 375 | | ddram[ac] = data; |
| 376 | | else { |
| 377 | | cgram[ac] = data; |
| 378 | | } |
| 379 | | data_bus_flag = 1; |
| 380 | 362 | |
| 363 | void hd44780_device::data_write(offs_t offset, UINT8 data) |
| 364 | { |
| 365 | if (ac_mode == 0) ddram[ac] = data; |
| 366 | else cgram[ac] = data; |
| 367 | data_bus_flag = 1; |
| 368 | update_ac(); |
| 381 | 369 | set_busy_flag(41); |
| 382 | 370 | } |
| 383 | 371 | |
| r9749 | r9750 | |
| 392 | 380 | } |
| 393 | 381 | |
| 394 | 382 | data_bus_flag = 2; |
| 383 | update_ac(); |
| 395 | 384 | |
| 396 | 385 | set_busy_flag(41); |
| 397 | 386 | |