From 1bba1daa8b4e4d8f4caddd4ea5f4053c2c496852 Mon Sep 17 00:00:00 2001 From: cracyc Date: Thu, 27 Jul 2023 19:45:28 -0500 Subject: pc9801: fix scroll and apply reverse attribute after blink --- src/mame/nec/pc9801.h | 1 + src/mame/nec/pc9801_v.cpp | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/mame/nec/pc9801.h b/src/mame/nec/pc9801.h index 6347a0e31f5..57145b26eb1 100644 --- a/src/mame/nec/pc9801.h +++ b/src/mame/nec/pc9801.h @@ -222,6 +222,7 @@ private: void write_sasi_req(int state); uint8_t sasi_status_r(); void sasi_ctrl_w(uint8_t data); + void draw_text(bitmap_rgb32 &bitmap, uint32_t addr, int y, int wd, int pitch, int lr, int cursor_on, int cursor_addr, bool lower); // uint8_t winram_r(); // void winram_w(uint8_t data); diff --git a/src/mame/nec/pc9801_v.cpp b/src/mame/nec/pc9801_v.cpp index 7b52c8403c1..0be1391f2e3 100644 --- a/src/mame/nec/pc9801_v.cpp +++ b/src/mame/nec/pc9801_v.cpp @@ -73,6 +73,11 @@ UPD7220_DISPLAY_PIXELS_MEMBER( pc9801_state::hgdc_display_pixels ) ************************************************/ UPD7220_DRAW_TEXT_LINE_MEMBER( pc9801_state::hgdc_draw_text ) +{ + draw_text(bitmap, addr, y, wd, pitch, lr, cursor_on, cursor_addr, false); +} + +void pc9801_state::draw_text(bitmap_rgb32 &bitmap, uint32_t addr, int y, int wd, int pitch, int lr, int cursor_on, int cursor_addr, bool lower) { rgb_t const *const palette = m_palette->palette()->entry_list_raw(); @@ -84,6 +89,12 @@ UPD7220_DRAW_TEXT_LINE_MEMBER( pc9801_state::hgdc_draw_text ) uint8_t x_step; uint8_t lastul = 0; + + int scroll_start = 33 - (m_txt_scroll_reg[4] & 0x1f); + int scroll_end = scroll_start + m_txt_scroll_reg[5]; + int scroll = m_txt_scroll_reg[3] % 20; + int line = y / lr; + for(int x=0;x= scroll_start) && (line <= scroll_end)) + { + if(!lower) + { + if(!yi) + yi = scroll; + else + res_y -= scroll; + } + else if(lower) + { + if(yi >= scroll) + break; + res_y += lr - scroll; + } + } + for(int xi=0;xi<8;xi++) { int res_x = ((x+kanji_lr)*8+xi) * (m_video_ff[WIDTH40_REG]+1); - int res_y = y+yi - (m_txt_scroll_reg[3] % 20); if(!m_screen->visible_area().contains(res_x, res_y)) continue; @@ -172,7 +198,6 @@ UPD7220_DRAW_TEXT_LINE_MEMBER( pc9801_state::hgdc_draw_text ) tile_data = (m_char_rom[tile*char_size+m_video_ff[FONTSEL_REG]*0x800+yi]); } - if(reverse) { tile_data^=0xff; } if(yi == lr-1) { if(u_line) tile_data = 0x0f; @@ -187,6 +212,8 @@ UPD7220_DRAW_TEXT_LINE_MEMBER( pc9801_state::hgdc_draw_text ) if(blink && m_screen->frame_number() & 0x10) tile_data = 0; + if(reverse) { tile_data^=0xff; } + int pen; if(yi >= char_size) pen = -1; @@ -209,6 +236,8 @@ UPD7220_DRAW_TEXT_LINE_MEMBER( pc9801_state::hgdc_draw_text ) lastul = u_line; } } + if(scroll && !lower && (line >= scroll_start) && (line <= scroll_end)) + return draw_text(bitmap, addr += pitch, y, wd, pitch, lr, cursor_on, cursor_addr, true); } /************************************************* -- cgit v1.2.3