• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: コミット

Common Source Code Project for Qt (a.k.a for FM-7).


コミットメタ情報

リビジョンb995c897b29ef9dfa40e8963ba564a334e7a53a9 (tree)
日時2020-03-25 03:58:44
作者K.Ohta <whatisthis.sowhat@gmai...>
コミッターK.Ohta

ログメッセージ

[VM][FMTOWNS][VRAM] TVRAM: Don't arrive CGROM.Fix weird scrolling for text layer.

変更サマリ

差分

--- a/source/src/vm/fmtowns/towns_crtc.cpp
+++ b/source/src/vm/fmtowns/towns_crtc.cpp
@@ -88,7 +88,8 @@ void TOWNS_CRTC::reset()
8888 {
8989 // initialize
9090 display_enabled = false;
91- vblank = vsync = hsync = true;
91+ vblank = true;
92+ vsync = hsync = false;
9293
9394 // memset(regs, 0, sizeof(regs));
9495 crtc_ch = 0;
@@ -223,7 +224,8 @@ void TOWNS_CRTC::reset()
223224 set_lines_per_frame(512);
224225 //set_pixels_per_line(640);
225226
226- set_vsync(vsync, true);
227+ write_signals(&outputs_int_vsync, 0x0);
228+
227229 hst_tmp = 640;
228230 vst_tmp = 400;
229231 for(int i = 0; i < 4; i++) {
@@ -256,7 +258,8 @@ void TOWNS_CRTC::set_vsync(bool val, bool force)
256258 {
257259 if((vsync != val) || (force)) {
258260 vsync = val;
259- write_signals(&outputs_int_vsync, (val) ? 0xffffffff : 0x00000000);
261+ write_signals(&outputs_int_vsync, (val) ? 0x00000000 : 0xffffffff);
262+// if(!(val)) write_signals(&outputs_int_vsync, 0xffffffff);
260263 }
261264 }
262265 void TOWNS_CRTC::restart_display()
@@ -752,7 +755,7 @@ uint16_t TOWNS_CRTC::read_reg30()
752755 data |= ((hdisp[1]) ? 0x2000 : 0);
753756 data |= ((hdisp[0]) ? 0x1000 : 0);
754757 //data |= ((eet) ? 0x0800 : 0);
755- data |= ((vsync) ? 0x0400 : 0);
758+ data |= (!(vsync) ? 0x0400 : 0);
756759 data |= (!(hsync) ? 0x0200 : 0);
757760 //data |= ((video_in) ? 0x0100 : 0);
758761 //data |= ((half_tone) ? 0x0008 : 0);
@@ -868,8 +871,8 @@ uint32_t TOWNS_CRTC::read_io8(uint32_t addr)
868871 case 0xfda0:
869872 {
870873 uint8_t d = 0xfc;
871- d = d | ((vsync) ? 0x01 : 0);
872- d = d | ((hsync) ? 0x02 : 0);
874+ d = d | ((vsync) ? 0x00 : 0x01);
875+ d = d | ((hsync) ? 0x00 : 0x02);
873876 return d;
874877 }
875878 break;
@@ -1447,79 +1450,96 @@ void TOWNS_CRTC::draw_screen()
14471450
14481451 // From MAME 0.216
14491452 // ToDo: Will refine.
1453+uint32_t TOWNS_CRTC::get_font_address(uint32_t c, uint8_t &attr)
1454+{
1455+ static const uint32_t addr_base_jis = 0x00000;
1456+ static const uint32_t addr_base_ank = 0x3d800;
1457+ uint32_t romaddr = 0;
1458+ attr = tvram_snapshot[c + 1];
1459+ if((attr & 0xc0) == 0) {
1460+ uint8_t ank = tvram_snapshot[c];
1461+ romaddr = addr_base_ank + (ank * 16);
1462+ } else if((attr & 0xc0) == 0x40) { // KANJI LEFT
1463+ pair32_t jis;
1464+ jis.b.h = tvram_snapshot[c + 0x2000]; // CA000-CAFFF
1465+ jis.b.l = tvram_snapshot[c + 0x2001]; // CA000-CAFFF
1466+ if(jis.b.h < 0x30) {
1467+ romaddr =
1468+ (((uint32_t)(jis.b.l & 0x1f)) << 4) |
1469+ ((uint32_t)((jis.b.l - 0x20) & 0x20) << 8) |
1470+ ((uint32_t)((jis.b.l - 0x20) & 0x40) << 6) |
1471+ (((uint32_t)(jis.b.h & 0x07)) << 9);
1472+ romaddr <<= 1;
1473+// romaddr >>= 1;
1474+ } else if(jis.b.h < 0x70) {
1475+ romaddr =
1476+ (((uint32_t)(jis.b.l & 0x1f)) << 5) +
1477+ ((uint32_t)((jis.b.l - 0x20) & 0x60) << 9) +
1478+ ((uint32_t)((jis.b.h & 0x0f)) << 10) +
1479+ ((uint32_t)((jis.b.h - 0x30) & 0x70) * 0xc00) +
1480+ 0x8000;
1481+// romaddr <<= 1;
1482+ } else {
1483+ romaddr =
1484+ (((uint32_t)(jis.b.l & 0x1f)) << 4) |
1485+ ((uint32_t)((jis.b.l - 0x20) & 0x20) << 8) |
1486+ ((uint32_t)((jis.b.l - 0x20) & 0x40) << 6) |
1487+ (((uint32_t)(jis.b.h & 0x07)) << 9);
1488+ romaddr <<= 1;
1489+ romaddr |= 0x38000;
1490+ }
1491+ romaddr = addr_base_jis + romaddr;
1492+// romaddr >>= 1;
1493+ }
1494+ return romaddr;
1495+}
1496+
14501497 void TOWNS_CRTC::render_text()
14511498 {
1452- uint32_t addr_base_jis = 0x00000;
1453- uint32_t addr_base_ank = 0x3d800;
1454- uint32_t linesize = regs[24] * 4;
1499+// uint32_t linesize = regs[24] * 4;
14551500 int c = 0;
14561501 for(int y = 0; y < 25; y++) {
1502+ uint32_t linesize = regs[24] * 4;
1503+ uint32_t addr_of = y * (linesize * 16);
1504+ if(c >= 0x1000) break;
1505+ uint32_t romaddr;
14571506 for(int x = 0; x < 80; x++) {
1458- uint32_t addr_of = ((x * 4) + (y * (linesize * 16)) + 1) & 0x3ffff;
1459- uint32_t attr = tvram_snapshot[c + 1];
1460- pair32_t jis;
1461- uint32_t romaddr;
1462- if((attr & 0xc0) == 0) {
1463- // ANK
1464- uint8_t ank = tvram_snapshot[c + 0];
1465-// uint8_t ank = 0x36;
1466- romaddr = addr_base_ank + (ank * 16);
1467- } else if((attr & 0xc0) != 0x80) {
1468- // JIS
1469- jis.b.h = tvram_snapshot[c + 0x1000]; // CA000-CAFFF
1470- jis.b.l = tvram_snapshot[c + 0x1001]; // CA000-CAFFF
1471- if(jis.b.h < 0x30) {
1472- romaddr =
1473- (((uint32_t)(jis.b.l & 0x1f)) << 4) |
1474- ((uint32_t)((jis.b.l - 0x20) & 0x20) << 8) |
1475- ((uint32_t)((jis.b.l - 0x20) & 0x40) << 6) |
1476- (((uint32_t)(jis.b.h & 0x07)) << 9);
1477- romaddr <<= 1;
1478-// romaddr >>= 1;
1479- } else if(jis.b.h < 0x70) {
1480- romaddr =
1481- (((uint32_t)(jis.b.l & 0x1f)) << 5) +
1482- ((uint32_t)((jis.b.l - 0x20) & 0x60) << 9) +
1483- ((uint32_t)((jis.b.h & 0x0f)) << 10) +
1484- ((uint32_t)((jis.b.h - 0x30) & 0x70) * 0xc00) +
1485- 0x8000;
1486-// romaddr >>= 1;
1487- } else {
1488- romaddr =
1489- (((uint32_t)(jis.b.l & 0x1f)) << 4) |
1490- ((uint32_t)((jis.b.l - 0x20) & 0x20) << 8) |
1491- ((uint32_t)((jis.b.l - 0x20) & 0x40) << 6) |
1492- (((uint32_t)(jis.b.h & 0x07)) << 9);
1493- romaddr <<= 1;
1494- romaddr |= 0x38000;
1495- }
1496- romaddr = addr_base_jis + romaddr;
1497-// romaddr >>= 1;
1507+ uint8_t attr;
1508+ uint32_t t = get_font_address(c, attr);
1509+ if(((attr & 0xc0) == 0) || ((attr & 0xc0) == 0x40)) {
1510+ // ANK OR KANJI LEFT
1511+ romaddr = t;
1512+ } else if((attr & 0xc0) == 0x80) {
1513+ // KANJI RIGHT
1514+ romaddr = romaddr + 1;
1515+ } else {
1516+ // Illegal
1517+ addr_of = (addr_of + 4) & 0x3ffff;
1518+ c += 2;
1519+ continue;
14981520 }
14991521 // Get data
15001522 uint32_t color = attr & 0x07;
15011523 uint8_t tmpdata = 0;
15021524 if(attr & 0x20) color |= 0x08;
1525+
15031526 // Do render
15041527 // out_debug_log("ROMADDR=%08X", romaddr);
1528+ uint32_t of = addr_of;
15051529 for(int column = 0; column < 16; column++) {
15061530 if(d_font != NULL) {
15071531 if((attr & 0xc0) == 0) {
15081532 // ANK
15091533 tmpdata = d_font->read_signal(SIG_TOWNS_FONT_PEEK_DATA + column + romaddr);
1510- } else if((attr & 0xc0) == 0x80) {
1511- tmpdata = d_font->read_signal(SIG_TOWNS_FONT_PEEK_DATA + column * 2 + romaddr + 1);
15121534 } else {
1513- tmpdata = d_font->read_signal(SIG_TOWNS_FONT_PEEK_DATA + column * 2 + romaddr + 0);
1535+ tmpdata = d_font->read_signal(SIG_TOWNS_FONT_PEEK_DATA + column * 2 + romaddr);
15141536 }
1515-
15161537 }
15171538 if(attr & 0x08)
15181539 {
15191540 tmpdata = ~tmpdata;
15201541 }
15211542 uint32_t pix = 0;
1522- uint32_t of = addr_of;
15231543 uint8_t *p = d_vram->get_vram_address(of + 0x40000);
15241544 for(int nb = 0; nb < 8; nb += 2) {
15251545 pix = 0;
@@ -1530,10 +1550,10 @@ void TOWNS_CRTC::render_text()
15301550 pix = pix | ((color & 0x0f) << 0);
15311551 }
15321552 if(p != NULL) *p++ = pix;
1533- of++;
15341553 }
1535- addr_of = (addr_of + linesize) & 0x3ffff;
1554+ of = (of + linesize) & 0x3ffff;
15361555 }
1556+ addr_of = (addr_of + 4) & 0x3ffff;
15371557 c += 2;
15381558 }
15391559 }
@@ -1768,12 +1788,11 @@ void TOWNS_CRTC::event_pre_frame()
17681788 // ToDo: Resize texture.
17691789 //set_pixels_per_line(pixels_per_line);
17701790 }
1771-// if(d_sprite->read_signal(SIG_TOWNS_SPRITE_TVRAM_ENABLED) != 0) {
1772-// if(((voutreg_ctrl & 0x1f) == 0x14) || ((voutreg_ctrl & 0x1f) == 0x11)) {
1773-// d_sprite->get_tvram_snapshot(tvram_snapshot);
1774-// render_text();
1775-// }
1776-// }
1791+ // Render VRAM
1792+ if(d_sprite->read_signal(SIG_TOWNS_SPRITE_TVRAM_ENABLED) != 0) {
1793+ d_sprite->get_tvram_snapshot(tvram_snapshot);
1794+ render_text();
1795+ }
17771796 }
17781797
17791798 void TOWNS_CRTC::event_frame()
@@ -1786,6 +1805,7 @@ void TOWNS_CRTC::event_frame()
17861805 line_count[0] = line_count[1] = 0;
17871806 vert_line_count = -1;
17881807 hsync = false;
1808+
17891809 // out_debug_log(_T("FRAME EVENT LINES=%d FRAMEus=%f Hus=%f VST1us=%f VST2us=%f"),lines_per_frame, frame_us, horiz_us, vst1_us, vst2_us);
17901810 for(int i = 0; i < 2; i++) {
17911811 crtout_top[i] = crtout[i];
@@ -1812,7 +1832,7 @@ void TOWNS_CRTC::event_frame()
18121832 } else {
18131833 set_vsync(true, true);
18141834 }
1815- if(vst2_us > 0.0) {
1835+ if((vst2_us > 0.0) && (vst2_us > vst1_us)) {
18161836 register_event(this, EVENT_CRTC_VST2, vst2_us, false, &event_id_vst2);
18171837 }
18181838 for(int i = 0; i < 2; i++) {
@@ -1843,13 +1863,6 @@ void TOWNS_CRTC::event_frame()
18431863 if(horiz_us > 0.0) {
18441864 register_event(this, EVENT_CRTC_HSTART, horiz_us, false, &event_id_hstart); // HSTART
18451865 }
1846- // Draw Text layer
1847- if(d_sprite->read_signal(SIG_TOWNS_SPRITE_TVRAM_ENABLED) != 0) {
1848-// if(((voutreg_ctrl & 0x1f) == 0x14) || ((voutreg_ctrl & 0x1f) == 0x11)) {
1849- d_sprite->get_tvram_snapshot(tvram_snapshot);
1850- render_text();
1851-// }
1852- }
18531866 }
18541867
18551868 void TOWNS_CRTC::event_callback(int event_id, int err)
@@ -1998,6 +2011,7 @@ void TOWNS_CRTC::write_signal(int ch, uint32_t data, uint32_t mask)
19982011 }
19992012 }
20002013
2014+
20012015 #define STATE_VERSION 1
20022016
20032017 bool TOWNS_CRTC::process_state(FILEIO* state_fio, bool loading)
--- a/source/src/vm/fmtowns/towns_crtc.h
+++ b/source/src/vm/fmtowns/towns_crtc.h
@@ -271,7 +271,7 @@ protected:
271271 uint8_t apalette_256_rgb[256][4]; // R * 65536 + G * 256 + B
272272 scrntype_t apalette_256_pixel[256]; // Not saved. Must be calculated.
273273
274- uint8_t tvram_snapshot[4096 * 2];
274+ uint8_t tvram_snapshot[0x4000];
275275
276276 // FM-R50 emulation
277277 uint8_t r50_planemask; // MMIO 000CF882h : BIT 5(C0) and BIT2 to 0
@@ -330,6 +330,7 @@ protected:
330330
331331 void set_crtc_clock(uint16_t val);
332332 uint16_t read_reg30();
333+ uint32_t __FASTCALL get_font_address(uint32_t c, uint8_t &attr);
333334
334335 virtual void __FASTCALL calc_apalette16(int layer, int index);
335336 virtual void __FASTCALL calc_apalette256(int index);
--- a/source/src/vm/fmtowns/towns_memory.cpp
+++ b/source/src/vm/fmtowns/towns_memory.cpp
@@ -32,12 +32,11 @@ void TOWNS_MEMORY::config_page00()
3232 set_memory_rw (0x000c0000, 0x000cffff, ram_pagec);
3333 set_memory_mapped_io_rw(0x000c0000, 0x000c7fff, d_vram);
3434 set_memory_mapped_io_rw(0x000c8000, 0x000c8fff, d_sprite);
35-// set_memory_rw (0x000c9000, 0x000c9fff, &(ram_pagec[0x0900]));
3635 set_memory_mapped_io_rw(0x000ca000, 0x000cafff, d_sprite);
37- if(ankcg_enabled) {
38- set_memory_mapped_io_r(0x000ca000, 0x000ca7ff, d_font);
39- set_memory_mapped_io_r(0x000cb000, 0x000cbfff, d_font);
40- }
36+// if(ankcg_enabled) {
37+// set_memory_mapped_io_r(0x000ca000, 0x000ca7ff, d_font);
38+// set_memory_mapped_io_r(0x000cb000, 0x000cbfff, d_font);
39+// }
4140 set_memory_mapped_io_rw(0x000cf000, 0x000cffff, this);
4241 set_memory_rw (0x000d0000, 0x000d7fff, ram_paged);
4342 set_memory_mapped_io_rw(0x000d8000, 0x000d9fff, d_dictionary); // CMOS
@@ -45,15 +44,10 @@ void TOWNS_MEMORY::config_page00()
4544 set_memory_rw (0x00000000, 0x000bffff, ram_page0);
4645 set_memory_rw (0x000c0000, 0x000cffff, ram_pagec);
4746 set_memory_rw (0x000d0000, 0x000d9fff, ram_paged);
48-// set_memory_mapped_io_rw(0x000cc000, 0x000cffff, this);
4947 }
5048 set_memory_rw (0x000da000, 0x000effff, ram_pagee);
5149 set_memory_rw (0x000f0000, 0x000f7fff, ram_pagef);
5250 set_memory_mapped_io_rw(0x000f8000, 0x000fffff, d_sysrom);
53- if(ankcg_enabled) {
54-// set_memory_mapped_io_r(0x000ca000, 0x000ca7ff, d_font);
55-// set_memory_mapped_io_r(0x000cb000, 0x000cbfff, d_font);
56- }
5751 }
5852
5953 void TOWNS_MEMORY::initialize()
@@ -400,9 +394,6 @@ void TOWNS_MEMORY::write_io8(uint32_t addr, uint32_t data)
400394 case 0x0404: // System Status Reg.
401395 dma_is_vram = ((data & 0x80) == 0);
402396 config_page00();
403- if(d_font != NULL) {
404- d_font->write_signal(SIG_TOWNS_FONT_DMA_IS_VRAM, (dma_is_vram) ? 0xffffffff : 0x00000000, 0xffffffff);
405- }
406397 break;
407398 case 0x05c0:
408399 extra_nmi_mask = ((data & 0x08) == 0);
@@ -527,11 +518,11 @@ void TOWNS_MEMORY::write_memory_mapped_io8(uint32_t addr, uint32_t data)
527518 }
528519 break;
529520 case 0x19:
530- if(d_sprite != NULL) {
521+// if(d_sprite != NULL) {
531522 // d_sprite->write_signal(SIG_TOWNS_SPRITE_ANKCG, ((data & 1) == 0) ? 0xffffffff : 0, 0xffffffff);
532523 ankcg_enabled = ((data & 1) == 0) ? true : false;
533524 config_page00();
534- }
525+// }
535526 break;
536527 case 0x20:
537528 break;
--- a/source/src/vm/fmtowns/towns_vram.cpp
+++ b/source/src/vm/fmtowns/towns_vram.cpp
@@ -707,8 +707,8 @@ uint32_t TOWNS_VRAM::read_mmio8(uint32_t addr)
707707 case 0xcff86:
708708 {
709709 uint8_t d;
710- d = (d_crtc->read_signal(SIG_TOWNS_CRTC_VSYNC) != 0) ? 0x04 : 0;
711- d = d | ((d_crtc->read_signal(SIG_TOWNS_CRTC_HSYNC) != 0) ? 0x80 : 0);
710+ d = (d_crtc->read_signal(SIG_TOWNS_CRTC_VSYNC) == 0) ? 0x04 : 0;
711+ d = d | ((d_crtc->read_signal(SIG_TOWNS_CRTC_HSYNC) == 0) ? 0x80 : 0);
712712 d = d | 0x10;
713713 return d;
714714 }
旧リポジトリブラウザで表示