• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revision9df70368f7a7c57b9f2933e3212a76daab336964 (tree)
Time2018-05-28 22:28:46
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][X1] Copy VRAMs to shadow data at starting a frame.Reduce flickering a lot.

Change Summary

Incremental Difference

--- a/source/src/qt/machines/x1/menuclasses.h
+++ b/source/src/qt/machines/x1/menuclasses.h
@@ -16,13 +16,7 @@ public:
1616 Object_Menu_Control_X1(QObject *parent, USING_FLAGS *p);
1717 ~Object_Menu_Control_X1();
1818 signals:
19-#if !defined(_X1)
20- void sig_display_mode(int);
21-#endif
2219 public slots:
23-#if !defined(_X1)
24- void do_set_display_mode(void);
25-#endif
2620 };
2721
2822 class Action_Control_X1 : public Action_Control
@@ -41,11 +35,6 @@ class CSP_Logger;
4135 class META_MainWindow : public Ui_MainWindow {
4236 Q_OBJECT
4337 protected:
44-#if !defined(_X1)
45- QActionGroup *actionGroup_DisplayMode;
46- class Action_Control_X1 *action_Emu_DisplayMode[2]; // 0=Hi / 1 = Lo
47- QMenu *menu_Emu_DisplayMode;
48-#endif
4938 void setupUI_Emu(void);
5039 void retranslateUi(void);
5140 public:
--- a/source/src/vm/x1/display.cpp
+++ b/source/src/vm/x1/display.cpp
@@ -123,6 +123,27 @@ void DISPLAY::initialize()
123123 // register event
124124 register_frame_event(this);
125125 register_vline_event(this);
126+
127+ // Copy images to draw buffers.
128+ my_memcpy(dr_text, text, sizeof(dr_text));
129+ my_memcpy(dr_cg, cg, sizeof(dr_cg));
130+ my_memcpy(dr_pri_line, pri_line, sizeof(dr_pri_line));
131+ my_memcpy(dr_palette_pc, palette_pc, sizeof(dr_palette_pc));
132+ dr_priority = priority;
133+#ifdef _X1TURBOZ
134+ dr_zpriority = zpriority;
135+ my_memcpy(dr_zcg, zcg, sizeof(dr_zcg));
136+ my_memcpy(dr_aen_line, aen_line, sizeof(dr_aen_line));
137+ my_memcpy(dr_zpalette_pc, zpalette_pc, sizeof(zpalette_pc));
138+ zpalette_pc[8 + 0] = zpalette_pc[16 + 0x000];
139+ zpalette_pc[8 + 1] = zpalette_pc[16 + 0x00f];
140+ zpalette_pc[8 + 2] = zpalette_pc[16 + 0x0f0];
141+ zpalette_pc[8 + 3] = zpalette_pc[16 + 0x0ff];
142+ zpalette_pc[8 + 4] = zpalette_pc[16 + 0xf00];
143+ zpalette_pc[8 + 5] = zpalette_pc[16 + 0xf0f];
144+ zpalette_pc[8 + 6] = zpalette_pc[16 + 0xff0];
145+ zpalette_pc[8 + 7] = zpalette_pc[16 + 0xfff];
146+#endif
126147 }
127148
128149 void DISPLAY::reset()
@@ -149,6 +170,27 @@ void DISPLAY::reset()
149170
150171 kaddr = kofs = kflag = 0;
151172 kanji_ptr = &kanji[0];
173+
174+ // Copy images to draw buffers.
175+ my_memcpy(dr_text, text, sizeof(dr_text));
176+ my_memcpy(dr_cg, cg, sizeof(dr_cg));
177+ my_memcpy(dr_pri_line, pri_line, sizeof(dr_pri_line));
178+ my_memcpy(dr_palette_pc, palette_pc, sizeof(dr_palette_pc));
179+ dr_priority = priority;
180+#ifdef _X1TURBOZ
181+ dr_zpriority = zpriority;
182+ my_memcpy(dr_zcg, zcg, sizeof(dr_zcg));
183+ my_memcpy(dr_aen_line, aen_line, sizeof(dr_aen_line));
184+ my_memcpy(dr_zpalette_pc, zpalette_pc, sizeof(zpalette_pc));
185+ zpalette_pc[8 + 0] = zpalette_pc[16 + 0x000];
186+ zpalette_pc[8 + 1] = zpalette_pc[16 + 0x00f];
187+ zpalette_pc[8 + 2] = zpalette_pc[16 + 0x0f0];
188+ zpalette_pc[8 + 3] = zpalette_pc[16 + 0x0ff];
189+ zpalette_pc[8 + 4] = zpalette_pc[16 + 0xf00];
190+ zpalette_pc[8 + 5] = zpalette_pc[16 + 0xf0f];
191+ zpalette_pc[8 + 6] = zpalette_pc[16 + 0xff0];
192+ zpalette_pc[8 + 7] = zpalette_pc[16 + 0xfff];
193+#endif
152194 }
153195
154196 void DISPLAY::write_io8(uint32_t addr, uint32_t data)
@@ -541,12 +583,42 @@ void DISPLAY::event_frame()
541583 int vt_total = ((regs[4] & 0x7f) + 1) * ch_height + (regs[5] & 0x1f);
542584 hireso = (vt_total > 400);
543585 #endif
544-
586+ int vlen;
587+#ifdef _X1TURBO_FEATURE
588+ vlen = (hireso) ? 400 : 200;
589+#else
590+ vlen = 200;
591+#endif
592+ if(vlen > 0) {
593+ // Copy images to draw buffers.
594+ my_memcpy(dr_text, text, sizeof(uint8_t) * vlen * (640 + 8));
595+ my_memcpy(dr_cg, cg, sizeof(uint8_t) * vlen * 640);
596+ my_memcpy(dr_pri_line, pri_line, sizeof(uint8_t) * vlen * 8 * 8);
597+ }
598+ my_memcpy(dr_palette_pc, palette_pc, sizeof(dr_palette_pc));
599+ dr_priority = priority;
545600 // initialize draw screen
546601 memset(text, 0, sizeof(text));
547602 memset(cg, 0, sizeof(cg));
548603 memset(pri_line, 0, sizeof(pri_line));
549604 #ifdef _X1TURBOZ
605+ if(vlen > 0) {
606+ // Copy images to draw buffers.
607+ my_memcpy(&(dr_zcg[0][0][0]), &(zcg[0][0][0]), sizeof(uint8_t) * vlen * 640);
608+ //my_memcpy(dr_aen_line, aen_line, sizeof(bool) * vlen);
609+ }
610+ my_memcpy(dr_aen_line, aen_line, sizeof(aen_line));
611+ dr_zpriority = zpriority;
612+ my_memcpy(dr_zpalette_pc, zpalette_pc, sizeof(zpalette_pc));
613+ zpalette_pc[8 + 0] = zpalette_pc[16 + 0x000];
614+ zpalette_pc[8 + 1] = zpalette_pc[16 + 0x00f];
615+ zpalette_pc[8 + 2] = zpalette_pc[16 + 0x0f0];
616+ zpalette_pc[8 + 3] = zpalette_pc[16 + 0x0ff];
617+ zpalette_pc[8 + 4] = zpalette_pc[16 + 0xf00];
618+ zpalette_pc[8 + 5] = zpalette_pc[16 + 0xf0f];
619+ zpalette_pc[8 + 6] = zpalette_pc[16 + 0xff0];
620+ zpalette_pc[8 + 7] = zpalette_pc[16 + 0xfff];
621+
550622 memset(zcg, 0, sizeof(zcg));
551623 memset(aen_line, 0, sizeof(aen_line));
552624 #endif
@@ -557,6 +629,46 @@ void DISPLAY::event_frame()
557629 void DISPLAY::event_vline(int v, int clock)
558630 {
559631 cur_vline = v;
632+
633+#if 0
634+ // Copy images to draw buffers.
635+ int vlimit;
636+#ifdef _X1TURBO_FEATURE
637+ vlimit = (hireso) ? 400 : 200;
638+#else
639+ vlimit = 200;
640+#endif
641+ if((v > vlimit) || (v < 0)) return;
642+
643+ if(v == vlimit) {
644+ my_memcpy(dr_palette_pc, palette_pc, sizeof(palette_pc));
645+#ifdef _X1TURBOZ
646+ my_memcpy(dr_zpalette_pc, zpalette_pc, sizeof(zpalette_pc));
647+#endif
648+ // Copy images to draw buffers.
649+ //my_memcpy(&(dr_text[v][0]), &(text[v][0]), sizeof(uint8_t) * (640 + 8));
650+ //my_memcpy(&(dr_cg[v][0]), &(cg[v][0]), sizeof(uint8_t) * 640);
651+ //my_memcpy(&(dr_pri_line[v][0][0]), &(pri_line[v][0][0]), sizeof(uint8_t) * 8 * 8);
652+#ifdef _X1TURBOZ
653+ //my_memcpy(&(dr_zcg[0][v][0]), &(zcg[0][v][0]), sizeof(uint8_t) * 640);
654+ //my_memcpy(&(dr_zcg[1][v][0]), &(zcg[1][v][0]), sizeof(uint8_t) * 640);
655+ //dr_aen_line[v] = aen_line[v];
656+#endif
657+ } else if(v == 0) {
658+ return;
659+ }
660+ // Copy images to draw buffers.
661+ my_memcpy(&(dr_text[v - 1][0]), &(text[v - 1][0]), sizeof(uint8_t) * (640 + 8));
662+ my_memcpy(&(dr_cg[v - 1][0]), &(cg[v -1 ][0]), sizeof(uint8_t) * 640);
663+ my_memcpy(&(dr_pri_line[v - 1][0][0]), &(pri_line[v - 1][0][0]), sizeof(uint8_t) * 8 * 8);
664+ dr_priority = priority;
665+#ifdef _X1TURBOZ
666+ my_memcpy(&(dr_zcg[0][v - 1 ][0]), &(zcg[0][v - 1][0]), sizeof(uint8_t) * 640);
667+ my_memcpy(&(dr_zcg[1][v - 1][0]), &(zcg[1][v - 1][0]), sizeof(uint8_t) * 640);
668+ dr_zpriority = zpriority;
669+ dr_aen_line[v - 1] = aen_line[v - 1];
670+#endif
671+#endif
560672 }
561673
562674 #ifdef _X1TURBO_FEATURE
@@ -732,14 +844,14 @@ void DISPLAY::draw_screen()
732844 {
733845 // copy to real screen
734846 #ifdef _X1TURBOZ
735- zpalette_pc[8 + 0] = zpalette_pc[16 + 0x000];
736- zpalette_pc[8 + 1] = zpalette_pc[16 + 0x00f];
737- zpalette_pc[8 + 2] = zpalette_pc[16 + 0x0f0];
738- zpalette_pc[8 + 3] = zpalette_pc[16 + 0x0ff];
739- zpalette_pc[8 + 4] = zpalette_pc[16 + 0xf00];
740- zpalette_pc[8 + 5] = zpalette_pc[16 + 0xf0f];
741- zpalette_pc[8 + 6] = zpalette_pc[16 + 0xff0];
742- zpalette_pc[8 + 7] = zpalette_pc[16 + 0xfff];
847+ dr_zpalette_pc[8 + 0] = dr_zpalette_pc[16 + 0x000];
848+ dr_zpalette_pc[8 + 1] = dr_zpalette_pc[16 + 0x00f];
849+ dr_zpalette_pc[8 + 2] = dr_zpalette_pc[16 + 0x0f0];
850+ dr_zpalette_pc[8 + 3] = dr_zpalette_pc[16 + 0x0ff];
851+ dr_zpalette_pc[8 + 4] = dr_zpalette_pc[16 + 0xf00];
852+ dr_zpalette_pc[8 + 5] = dr_zpalette_pc[16 + 0xf0f];
853+ dr_zpalette_pc[8 + 6] = dr_zpalette_pc[16 + 0xff0];
854+ dr_zpalette_pc[8 + 7] = dr_zpalette_pc[16 + 0xfff];
743855 #endif
744856 #ifdef _X1TURBO_FEATURE
745857 if(hireso) {
@@ -749,10 +861,10 @@ void DISPLAY::draw_screen()
749861 // 40 columns
750862 for(int y = 0; y < 400; y++) {
751863 scrntype_t* dest = emu->get_screen_buffer(y);
752- uint8_t* src_text = text[y];
864+ uint8_t* src_text = dr_text[y];
753865 #ifdef _X1TURBOZ
754- if(aen_line[y]) {
755- uint16_t* src_cg0 = zcg[0][y];
866+ if(dr_aen_line[y]) {
867+ uint16_t* src_cg0 = dr_zcg[0][y];
756868
757869 for(int x = 0, x2 = 0; x < 320; x++, x2 += 2) {
758870 uint16_t cg00 = src_cg0[x] | (src_cg0[x] >> 2);
@@ -761,13 +873,13 @@ void DISPLAY::draw_screen()
761873 }
762874 } else {
763875 #endif
764- uint8_t* src_cg = cg[y];
876+ uint8_t* src_cg = dr_cg[y];
765877
766878 for(int x = 0, x2 = 0; x < 320; x++, x2 += 2) {
767879 #ifdef _X1TURBOZ
768- dest[x2] = dest[x2 + 1] = zpalette_pc[pri_line[y][src_cg[x]][src_text[x]]];
880+ dest[x2] = dest[x2 + 1] = dr_zpalette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
769881 #else
770- dest[x2] = dest[x2 + 1] = palette_pc[pri_line[y][src_cg[x]][src_text[x]]];
882+ dest[x2] = dest[x2 + 1] = dr_palette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
771883 #endif
772884 }
773885 #ifdef _X1TURBOZ
@@ -778,10 +890,10 @@ void DISPLAY::draw_screen()
778890 // 80 columns
779891 for(int y = 0; y < 400; y++) {
780892 scrntype_t* dest = emu->get_screen_buffer(y);
781- uint8_t* src_text = text[y];
893+ uint8_t* src_text = dr_text[y];
782894 #ifdef _X1TURBOZ
783- if(aen_line[y]) {
784- uint16_t* src_cg0 = zcg[0][y];
895+ if(dr_aen_line[y]) {
896+ uint16_t* src_cg0 = dr_zcg[0][y];
785897
786898 for(int x = 0; x < 640; x++) {
787899 uint16_t cg00 = src_cg0[x] | (src_cg0[x] >> 2);
@@ -790,13 +902,13 @@ void DISPLAY::draw_screen()
790902 }
791903 } else {
792904 #endif
793- uint8_t* src_cg = cg[y];
905+ uint8_t* src_cg = dr_cg[y];
794906
795907 for(int x = 0; x < 640; x++) {
796908 #ifdef _X1TURBOZ
797- dest[x] = zpalette_pc[pri_line[y][src_cg[x]][src_text[x]]];
909+ dest[x] = dr_zpalette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
798910 #else
799- dest[x] = palette_pc[pri_line[y][src_cg[x]][src_text[x]]];
911+ dest[x] = dr_palette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
800912 #endif
801913 }
802914 #ifdef _X1TURBOZ
@@ -816,11 +928,11 @@ void DISPLAY::draw_screen()
816928 for(int y = 0; y < 200; y++) {
817929 scrntype_t* dest0 = emu->get_screen_buffer(y * 2 + 0);
818930 scrntype_t* dest1 = emu->get_screen_buffer(y * 2 + 1);
819- uint8_t* src_text = text[y];
931+ uint8_t* src_text = dr_text[y];
820932 #ifdef _X1TURBOZ
821- if(aen_line[y]) {
822- uint16_t* src_cg0 = zcg[0][y];
823- uint16_t* src_cg1 = zcg[1][y];
933+ if(dr_aen_line[y]) {
934+ uint16_t* src_cg0 = dr_zcg[0][y];
935+ uint16_t* src_cg1 = dr_zcg[1][y];
824936
825937 if(C64) {
826938 for(int x = 0, x2 = 0; x < 320; x++, x2 += 2) {
@@ -839,13 +951,13 @@ void DISPLAY::draw_screen()
839951 } else {
840952 #endif
841953 scrntype_t* dest = emu->get_screen_buffer(y);
842- uint8_t* src_cg = cg[y];
954+ uint8_t* src_cg = dr_cg[y];
843955
844956 for(int x = 0, x2 = 0; x < 320; x++, x2 += 2) {
845957 #ifdef _X1TURBOZ
846- dest0[x2] = dest0[x2 + 1] = zpalette_pc[pri_line[y][src_cg[x]][src_text[x]]];
958+ dest0[x2] = dest0[x2 + 1] = dr_zpalette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
847959 #else
848- dest0[x2] = dest0[x2 + 1] = palette_pc[pri_line[y][src_cg[x]][src_text[x]]];
960+ dest0[x2] = dest0[x2 + 1] = dr_palette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
849961 #endif
850962 }
851963 #ifdef _X1TURBOZ
@@ -862,10 +974,10 @@ void DISPLAY::draw_screen()
862974 for(int y = 0; y < 200; y++) {
863975 scrntype_t* dest0 = emu->get_screen_buffer(y * 2 + 0);
864976 scrntype_t* dest1 = emu->get_screen_buffer(y * 2 + 1);
865- uint8_t* src_text = text[y];
977+ uint8_t* src_text = dr_text[y];
866978 #ifdef _X1TURBOZ
867979 if(aen_line[y]) {
868- uint16_t* src_cg0 = zcg[0][y];
980+ uint16_t* src_cg0 = dr_zcg[0][y];
869981
870982 for(int x = 0; x < 640; x++) {
871983 uint16_t cg00 = src_cg0[x] | (src_cg0[x] >> 2);
@@ -874,13 +986,13 @@ void DISPLAY::draw_screen()
874986 }
875987 } else {
876988 #endif
877- uint8_t* src_cg = cg[y];
989+ uint8_t* src_cg = dr_cg[y];
878990
879991 for(int x = 0; x < 640; x++) {
880992 #ifdef _X1TURBOZ
881- dest0[x] = zpalette_pc[pri_line[y][src_cg[x]][src_text[x]]];
993+ dest0[x] = dr_zpalette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
882994 #else
883- dest0[x] = palette_pc[pri_line[y][src_cg[x]][src_text[x]]];
995+ dest0[x] = dr_palette_pc[dr_pri_line[y][src_cg[x]][src_text[x]]];
884996 #endif
885997 }
886998 #ifdef _X1TURBOZ
@@ -1182,15 +1294,15 @@ scrntype_t DISPLAY::get_zpriority(uint8_t text, uint16_t cg0, uint16_t cg1)
11821294 {
11831295 if((mode2 & 8) && (text == (mode2 & 7))) {
11841296 int digital = ((cg0 >> 9) & 4) | ((cg0 >> 6) & 2) | ((cg0 >> 3) & 1);
1185- if(!(priority & (1 << digital))) {
1297+ if(!(dr_priority & (1 << digital))) {
11861298 return 0;
11871299 }
11881300 }
1189- uint16_t fore = ((zpriority & 0x18) != 0x18) ? cg0 : cg1;
1190- uint16_t back = ((zpriority & 0x18) != 0x18) ? cg1 : cg0;
1301+ uint16_t fore = ((dr_zpriority & 0x18) != 0x18) ? cg0 : cg1;
1302+ uint16_t back = ((dr_zpriority & 0x18) != 0x18) ? cg1 : cg0;
11911303 uint16_t disp;
11921304
1193- switch(zpriority & 0x13) {
1305+ switch(dr_zpriority & 0x13) {
11941306 case 0x00:
11951307 case 0x02:
11961308 disp = text ? text : (fore + 16);
@@ -1218,7 +1330,7 @@ scrntype_t DISPLAY::get_zpriority(uint8_t text, uint16_t cg0, uint16_t cg1)
12181330 // if((mode2 & 0x20) && disp == (0x00f + 16)) {
12191331 // return 0;
12201332 // }
1221- return zpalette_pc[disp];
1333+ return dr_zpalette_pc[disp];
12221334 }
12231335 #endif
12241336
@@ -1520,6 +1632,27 @@ bool DISPLAY::load_state(FILEIO* state_fio)
15201632 cur_blank = state_fio->FgetBool();
15211633
15221634 // post process
1635+ // Copy images to draw buffers.
1636+ my_memcpy(dr_text, text, sizeof(dr_text));
1637+ my_memcpy(dr_cg, cg, sizeof(dr_cg));
1638+ my_memcpy(dr_pri_line, pri_line, sizeof(dr_pri_line));
1639+ my_memcpy(dr_palette_pc, palette_pc, sizeof(dr_palette_pc));
1640+ dr_priority = priority;
1641+#ifdef _X1TURBOZ
1642+ dr_zpriority = zpriority;
1643+ my_memcpy(dr_zcg, zcg, sizeof(dr_zcg));
1644+ my_memcpy(dr_aen_line, aen_line, sizeof(dr_aen_line));
1645+ my_memcpy(dr_zpalette_pc, zpalette_pc, sizeof(zpalette_pc));
1646+ zpalette_pc[8 + 0] = zpalette_pc[16 + 0x000];
1647+ zpalette_pc[8 + 1] = zpalette_pc[16 + 0x00f];
1648+ zpalette_pc[8 + 2] = zpalette_pc[16 + 0x0f0];
1649+ zpalette_pc[8 + 3] = zpalette_pc[16 + 0x0ff];
1650+ zpalette_pc[8 + 4] = zpalette_pc[16 + 0xf00];
1651+ zpalette_pc[8 + 5] = zpalette_pc[16 + 0xf0f];
1652+ zpalette_pc[8 + 6] = zpalette_pc[16 + 0xff0];
1653+ zpalette_pc[8 + 7] = zpalette_pc[16 + 0xfff];
1654+#endif
1655+
15231656 update_crtc(); // force update timing
15241657
15251658 return true;
--- a/source/src/vm/x1/display.h
+++ b/source/src/vm/x1/display.h
@@ -56,6 +56,7 @@ private:
5656
5757 uint8_t pal[3];
5858 uint8_t priority, pri[8][8]; // pri[cg][txt]
59+ uint8_t dr_priority;
5960
6061 bool column40;
6162 #ifdef _X1TURBO_FEATURE
@@ -71,6 +72,8 @@ private:
7172 uint8_t zscroll;
7273 uint8_t zmode2;
7374 uint8_t ztpal[8];
75+ uint8_t dr_zpriority;
76+
7477 struct {
7578 uint8_t b, r, g;
7679 } zpal[4096];
@@ -81,17 +84,31 @@ private:
8184 uint8_t text[400][640];
8285 uint8_t cg[400][640];
8386 uint8_t pri_line[400][8][8];
87+
88+
89+ uint8_t dr_text[400][640];
90+ uint8_t dr_cg[400][640];
91+ uint8_t dr_pri_line[400][8][8];
8492 #else
8593 uint8_t text[200][640+8];
8694 uint8_t cg[200][640];
8795 uint8_t pri_line[200][8][8];
96+
97+ uint8_t dr_text[200][640+8];
98+ uint8_t dr_cg[200][640];
99+ uint8_t dr_pri_line[200][8][8];
88100 #endif
89101 #ifdef _X1TURBOZ
90102 uint16_t zcg[2][400][640];
91103 bool aen_line[400];
92104 scrntype_t zpalette_pc[8+8+4096]; // 0-7:text, 8-15:cg, 16-:4096cg
105+
106+ uint16_t dr_zcg[2][400][640];
107+ bool dr_aen_line[400];
108+ scrntype_t dr_zpalette_pc[8+8+4096]; // 0-7:text, 8-15:cg, 16-:4096cg
93109 #endif
94110 scrntype_t palette_pc[8+8]; // 0-7:text, 8-15:cg
111+ scrntype_t dr_palette_pc[8+8]; // 0-7:text, 8-15:cg
95112 bool prev_vert_double;
96113 int raster, cblink;
97114
Show on old repository browser