trunk/src/emu/video/hd44780.c
| r31225 | r31226 | |
| 156 | 156 | |
| 157 | 157 | void hd44780_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 158 | 158 | { |
| 159 | | switch(id) |
| 159 | switch (id) |
| 160 | 160 | { |
| 161 | 161 | case TIMER_BUSY: |
| 162 | 162 | m_busy_flag = false; |
| r31225 | r31226 | |
| 188 | 188 | { |
| 189 | 189 | if (m_active_ram == DDRAM) |
| 190 | 190 | { |
| 191 | | if(direction == 1) |
| 191 | if (direction == 1) |
| 192 | 192 | { |
| 193 | | if(m_num_line == 2 && m_ac == 0x27) |
| 193 | if (m_num_line == 2 && m_ac == 0x27) |
| 194 | 194 | m_ac = 0x40; |
| 195 | | else if((m_num_line == 2 && m_ac == 0x67) || (m_num_line == 1 && m_ac == 0x4f)) |
| 195 | else if ((m_num_line == 2 && m_ac == 0x67) || (m_num_line == 1 && m_ac == 0x4f)) |
| 196 | 196 | m_ac = 0x00; |
| 197 | 197 | else |
| 198 | 198 | m_ac = (m_ac + direction) & 0x7f; |
| 199 | 199 | } |
| 200 | 200 | else |
| 201 | 201 | { |
| 202 | | if(m_num_line == 2 && m_ac == 0x00) |
| 202 | if (m_num_line == 2 && m_ac == 0x00) |
| 203 | 203 | m_ac = 0x67; |
| 204 | | else if(m_num_line == 1 && m_ac == 0x00) |
| 204 | else if (m_num_line == 1 && m_ac == 0x00) |
| 205 | 205 | m_ac = 0x4f; |
| 206 | | else if(m_num_line == 2 && m_ac == 0x40) |
| 206 | else if (m_num_line == 2 && m_ac == 0x40) |
| 207 | 207 | m_ac = 0x27; |
| 208 | 208 | else |
| 209 | 209 | m_ac = (m_ac + direction) & 0x7f; |
| r31225 | r31226 | |
| 219 | 219 | { |
| 220 | 220 | if (direction == 1) |
| 221 | 221 | { |
| 222 | | if(m_disp_shift == 0x4f) |
| 222 | if (m_disp_shift == 0x4f) |
| 223 | 223 | m_disp_shift = 0x00; |
| 224 | 224 | else |
| 225 | 225 | m_disp_shift++; |
| 226 | 226 | } |
| 227 | 227 | else |
| 228 | 228 | { |
| 229 | | if(m_disp_shift == 0x00) |
| 229 | if (m_disp_shift == 0x00) |
| 230 | 230 | m_disp_shift = 0x4f; |
| 231 | 231 | else |
| 232 | 232 | m_disp_shift--; |
| r31225 | r31226 | |
| 294 | 294 | { |
| 295 | 295 | UINT8 line_size = 80 / m_num_line; |
| 296 | 296 | |
| 297 | | for (int line=0; line<m_num_line; line++) |
| 297 | for (int line = 0; line < m_num_line; line++) |
| 298 | 298 | { |
| 299 | | for (int pos=0; pos<line_size; pos++) |
| 299 | for (int pos = 0; pos < line_size; pos++) |
| 300 | 300 | { |
| 301 | 301 | UINT16 char_pos = line * 0x40 + ((pos + m_disp_shift) % line_size); |
| 302 | 302 | |
| r31225 | r31226 | |
| 307 | 307 | if (m_char_size == 8) |
| 308 | 308 | char_base = (m_ddram[char_pos] & 0x07) * 8; |
| 309 | 309 | else |
| 310 | | char_base = ((m_ddram[char_pos]>>1) & 0x03) * 16; |
| 310 | char_base = ((m_ddram[char_pos] >> 1) & 0x03) * 16; |
| 311 | 311 | } |
| 312 | 312 | else |
| 313 | 313 | { |
| r31225 | r31226 | |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | const UINT8 * charset = (m_ddram[char_pos] < 0x10) ? m_cgram : m_cgrom; |
| 319 | | UINT8 *dest = m_render_buf + 16*(line*line_size + pos); |
| 319 | UINT8 *dest = m_render_buf + 16 * (line * line_size + pos); |
| 320 | 320 | memcpy (dest, charset + char_base, m_char_size); |
| 321 | 321 | |
| 322 | 322 | if (char_pos == m_ac) |
| 323 | 323 | { |
| 324 | 324 | // draw the cursor |
| 325 | 325 | if (m_cursor_on) |
| 326 | | dest[m_char_size-1] = 0x1f; |
| 326 | dest[m_char_size - 1] = 0x1f; |
| 327 | 327 | |
| 328 | 328 | if (!m_blink && m_blink_on) |
| 329 | 329 | memset(dest, 0x1f, m_char_size); |
| r31225 | r31226 | |
| 342 | 342 | |
| 343 | 343 | UINT8 line_size = 80 / m_num_line; |
| 344 | 344 | |
| 345 | | for (int line=0; line<m_num_line; line++) |
| 345 | for (int line = 0; line < m_num_line; line++) |
| 346 | 346 | { |
| 347 | | for (int pos=0; pos<line_size; pos++) |
| 347 | for (int pos = 0; pos < line_size; pos++) |
| 348 | 348 | { |
| 349 | | const UINT8 *src = img + 16*(line*line_size + pos); |
| 350 | | for (int y=0; y<m_char_size; y++) |
| 351 | | for (int x=0; x<5; x++) |
| 349 | const UINT8 *src = img + 16 * (line * line_size + pos); |
| 350 | for (int y = 0; y < m_char_size; y++) |
| 351 | for (int x = 0; x < 5; x++) |
| 352 | 352 | pixel_update(bitmap, line, pos, y, x, BIT(src[y], 4 - x)); |
| 353 | 353 | } |
| 354 | 354 | } |
| r31225 | r31226 | |
| 358 | 358 | |
| 359 | 359 | READ8_MEMBER(hd44780_device::read) |
| 360 | 360 | { |
| 361 | | switch(offset & 0x01) |
| 361 | switch (offset & 0x01) |
| 362 | 362 | { |
| 363 | 363 | case 0: return control_read(space, 0); |
| 364 | 364 | case 1: return data_read(space, 0); |
| r31225 | r31226 | |
| 369 | 369 | |
| 370 | 370 | WRITE8_MEMBER(hd44780_device::write) |
| 371 | 371 | { |
| 372 | | switch(offset & 0x01) |
| 372 | switch (offset & 0x01) |
| 373 | 373 | { |
| 374 | 374 | case 0: control_write(space, 0, data); break; |
| 375 | 375 | case 1: data_write(space, 0, data); break; |
| r31225 | r31226 | |
| 389 | 389 | } |
| 390 | 390 | else |
| 391 | 391 | { |
| 392 | | m_ir |= ((data>>4) & 0x0f); |
| 392 | m_ir |= ((data >> 4) & 0x0f); |
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | else |
| r31225 | r31226 | |
| 512 | 512 | if (m_nibble) |
| 513 | 513 | return (m_busy_flag ? 0x80 : 0) | (m_ac & 0x70); |
| 514 | 514 | else |
| 515 | | return (m_ac<<4) & 0xf0; |
| 515 | return (m_ac << 4) & 0xf0; |
| 516 | 516 | } |
| 517 | 517 | else |
| 518 | 518 | { |
| r31225 | r31226 | |
| 539 | 539 | } |
| 540 | 540 | else |
| 541 | 541 | { |
| 542 | | m_dr |= ((data>>4) & 0x0f); |
| 542 | m_dr |= ((data >> 4) & 0x0f); |
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | else |
| r31225 | r31226 | |
| 574 | 574 | if (m_nibble) |
| 575 | 575 | return data & 0xf0; |
| 576 | 576 | else |
| 577 | | data = (data<<4) & 0xf0; |
| 577 | data = (data << 4) & 0xf0; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | if (!space.debugger_access()) |