• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revision559fecd562a2d90322399d721704dc2b8aed8a92 (tree)
Zeit2018-02-20 03:01:33
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][FM7][DISPLAY] Not use event_vline() as determine H/V SYNC.
[VM][FM7][DISPLAY] Use event_frame() to kick VSTART.Not loop.
[VM][FM7][DISPLAY] Duplicate palette (pixel) value at VSYNC.Fix rendering with DRAGON BUSTER, LUXOL and more softwares.

Ändern Zusammenfassung

Diff

--- a/source/src/vm/fm7/display.cpp
+++ b/source/src/vm/fm7/display.cpp
@@ -103,7 +103,7 @@ void DISPLAY::reset_some_devices()
103103 displine = 0;
104104 active_page = 0;
105105
106-#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
106+//#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
107107 vsync = true;
108108 vblank = true;
109109 hblank = false;
@@ -123,15 +123,16 @@ void DISPLAY::reset_some_devices()
123123 usec = 0.51 * 1000.0;
124124 }
125125 //usec = 16.0;
126- register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
126+ //register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
127127 mainio->write_signal(SIG_DISPLAY_DISPLAY, 0x00, 0xff);
128128 mainio->write_signal(SIG_DISPLAY_VSYNC, 0xff, 0xff);
129-#endif
129+//#endif
130+ display_page = 0;
131+ display_page_bak = 0;
132+
130133 #if defined(_FM77AV_VARIANTS)
131134 offset_77av = false;
132135 offset_point_bank1 = 0;
133- display_page = 0;
134- display_page_bak = 0;
135136
136137 subcpu_resetreq = false;
137138 subrom_bank_using = subrom_bank;
@@ -167,6 +168,7 @@ void DISPLAY::reset_some_devices()
167168 alu->write_signal(SIG_ALU_PLANES, 3, 3);
168169 #endif
169170 for(i = 0; i < 8; i++) set_dpalette(i, i);
171+ memcpy(dpalette_pixel, dpalette_pixel_tmp, sizeof(dpalette_pixel));
170172 //do_firq(!firq_mask && key_firq_req);
171173
172174 #if defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
@@ -207,6 +209,7 @@ void DISPLAY::reset()
207209 analog_palette_g[i] = (i & 0xf00) >> 4;
208210 analog_palette_b[i] = (i & 0x00f) << 4;
209211 calc_apalette(i);
212+ memcpy(analog_palette_pixel, analog_palette_pixel_tmp, sizeof(analog_palette_pixel));
210213 }
211214 subrom_bank = 0;
212215 cgrom_bank = 0;
@@ -241,6 +244,7 @@ void DISPLAY::reset()
241244 for(i = 0; i < 8; i++) set_dpalette(i, i);
242245 # endif
243246 #endif
247+ memcpy(dpalette_pixel, dpalette_pixel_tmp, sizeof(dpalette_pixel));
244248 //enter_display();
245249
246250 if(nmi_event_id >= 0) cancel_event(this, nmi_event_id);
@@ -394,7 +398,7 @@ void DISPLAY::set_dpalette(uint32_t addr, uint8_t val)
394398 r = ((val & 0x02) != 0x00)? 255 : 0x00;
395399 g = ((val & 0x04) != 0x00)? 255 : 0x00;
396400
397- dpalette_pixel[addr] = RGB_COLOR(r, g, b);
401+ dpalette_pixel_tmp[addr] = RGB_COLOR(r, g, b);
398402 palette_changed = true;
399403 }
400404
@@ -744,7 +748,7 @@ void DISPLAY::calc_apalette(uint16_t idx)
744748 if(g != 0) g |= 0x0f;
745749 if(r != 0) r |= 0x0f;
746750 if(b != 0) b |= 0x0f;
747- analog_palette_pixel[idx] = RGB_COLOR(r, g, b);
751+ analog_palette_pixel_tmp[idx] = RGB_COLOR(r, g, b);
748752 }
749753
750754 // FD32
@@ -1160,7 +1164,7 @@ void DISPLAY::copy_vram_all()
11601164 }
11611165
11621166 // Timing values from XM7 . Thanks Ryu.
1163-#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
1167+//#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
11641168 void DISPLAY::event_callback_hdisp(void)
11651169 {
11661170 bool f = false;
@@ -1266,6 +1270,7 @@ void DISPLAY::event_callback_vstart(void)
12661270 usec = 1840.0; // 1846.5
12671271 }
12681272 register_event(this, EVENT_FM7SUB_HDISP, usec, false, &hdisp_event_id); // NEXT CYCLE_
1273+ //register_event(this, EVENT_FM7SUB_HBLANK, usec, false, &hdisp_event_id); // NEXT CYCLE_
12691274 vblank_count = 0;
12701275 } else {
12711276 if(display_mode == DISPLAY_MODE_8_400L) {
@@ -1285,6 +1290,7 @@ void DISPLAY::event_callback_vsync(void)
12851290 vsync = true;
12861291 //write_access_page = (write_access_page + 1) & 1;
12871292 displine = 0;
1293+
12881294 if(display_mode == DISPLAY_MODE_8_400L) {
12891295 usec = 0.33 * 1000.0;
12901296 } else {
@@ -1292,49 +1298,29 @@ void DISPLAY::event_callback_vsync(void)
12921298 }
12931299 mainio->write_signal(SIG_DISPLAY_VSYNC, 0x01, 0xff);
12941300 mainio->write_signal(SIG_DISPLAY_DISPLAY, 0x00, 0xff);
1295- register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
1301+ //register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
12961302
1303+ if(palette_changed) {
1304+#if defined(_FM77AV_VARIANTS)
1305+ memcpy(analog_palette_pixel, analog_palette_pixel_tmp, sizeof(analog_palette_pixel));
1306+#endif
1307+ memcpy(dpalette_pixel, dpalette_pixel_tmp, sizeof(dpalette_pixel));
1308+ vram_wrote_shadow = true;
1309+ for(int yy = 0; yy < 400; yy++) {
1310+ vram_draw_table[yy] = true;
1311+ }
1312+ palette_changed = false;
1313+ }
12971314 // Transfer on VSYNC
12981315 if((config.dipswitch & FM7_DIPSW_SYNC_TO_HSYNC) == 0) {
12991316 bool ff = false;
13001317 int lines = 200;
13011318 if(display_mode == DISPLAY_MODE_8_400L) lines = 400;
1302-# if 0
1303- if(need_transfer_line) {
1304- if(vram_wrote) ff = true;
1305- //if(need_transfer_line) ff = true;
1306- //}
1307- for(displine = 0; displine < lines; displine++) {
1308- if(ff) break;
1309- for(int iii = 0; iii < 5 ; iii++) {
1310- if(vram_wrote_table[iii + displine * 5]) {
1311- ff = true;
1312- break;
1313- }
1314- }
1315- }
1316- displine = 0;
1317- }
1318-
1319- if(ff) {
1320- for(int yy = 0; yy < lines; yy++) {
1321- if(!vram_draw_table[yy]) {
1322- displine = yy;
1323- copy_vram_per_line(0, 4);
1324- vram_draw_table[yy] = true;
1325- }
1326- }
1327- //copy_vram_all();
1328- vram_wrote_shadow = true;
1329- screen_update_flag = true;
1330- vram_wrote = false;
1331- }
1332-# else
13331319 if(need_transfer_line) {
13341320 if(vram_wrote) { // transfer all line
13351321 for(displine = 0; displine < lines; displine++) {
13361322 //if(!vram_draw_table[displine]) {
1337- copy_vram_per_line(0, 4);
1323+ copy_vram_per_line(0, 4);
13381324 //}
13391325 }
13401326 vram_wrote = false;
@@ -1375,7 +1361,6 @@ void DISPLAY::event_callback_vsync(void)
13751361 break;
13761362 }
13771363 }
1378-# endif
13791364 } else {
13801365 // TRANSFER per HSYNC a.k.a SYNC-TO-HSYNC.
13811366 int lines = 200;
@@ -1413,7 +1398,7 @@ void DISPLAY::event_callback_vsync(void)
14131398 }
14141399 }
14151400
1416-#endif
1401+//#endif
14171402
14181403 void DISPLAY::event_callback(int event_id, int err)
14191404 {
@@ -1432,7 +1417,7 @@ void DISPLAY::event_callback(int event_id, int err)
14321417 case EVENT_FM7SUB_DISPLAY_NMI_OFF: // per 20.00ms
14331418 do_nmi(false);
14341419 break;
1435-#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
1420+//#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
14361421 case EVENT_FM7SUB_HDISP:
14371422 event_callback_hdisp();
14381423 break;
@@ -1445,7 +1430,7 @@ void DISPLAY::event_callback(int event_id, int err)
14451430 case EVENT_FM7SUB_VSYNC:
14461431 event_callback_vsync();
14471432 break;
1448-#endif
1433+//#endif
14491434 case EVENT_FM7SUB_CLR_BUSY:
14501435 set_subbusy();
14511436 break;
@@ -1457,6 +1442,22 @@ void DISPLAY::event_callback(int event_id, int err)
14571442
14581443 void DISPLAY::event_frame()
14591444 {
1445+ double usec;
1446+ vblank = true;
1447+ hblank = false;
1448+ vsync = true;
1449+ //write_access_page = (write_access_page + 1) & 1;
1450+ displine = 0;
1451+ if(display_mode == DISPLAY_MODE_8_400L) {
1452+ usec = 0.33 * 1000.0;
1453+ } else {
1454+ usec = 0.51 * 1000.0;
1455+ }
1456+ mainio->write_signal(SIG_DISPLAY_VSYNC, 0x01, 0xff);
1457+ mainio->write_signal(SIG_DISPLAY_DISPLAY, 0x00, 0xff);
1458+ register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
1459+ vblank_count = 0;
1460+#if 0
14601461 #if !defined(_FM77AV_VARIANTS) && !defined(_FM77L4)
14611462 int yy;
14621463 bool f = false;
@@ -1500,7 +1501,8 @@ void DISPLAY::event_frame()
15001501 }
15011502 }
15021503
1503-#endif
1504+#endif
1505+#endif
15041506 }
15051507
15061508 void DISPLAY::event_vline(int v, int clock)
@@ -2939,14 +2941,17 @@ void DISPLAY::initialize()
29392941 analog_palette_g[i] = (i & 0xf00) >> 4;
29402942 analog_palette_b[i] = (i & 0x00f) << 4;
29412943 calc_apalette(i);
2944+ memcpy(analog_palette_pixel, analog_palette_pixel_tmp, sizeof(analog_palette_pixel));
29422945 }
29432946 #endif
2944-#if defined(_FM77AV_VARIANTS)
2947+ for(i = 0; i < 8; i++) set_dpalette(i, i);
2948+ memcpy(dpalette_pixel, dpalette_pixel_tmp, sizeof(dpalette_pixel));
2949+//#if defined(_FM77AV_VARIANTS)
29452950 hblank_event_id = -1;
29462951 hdisp_event_id = -1;
29472952 vsync_event_id = -1;
29482953 vstart_event_id = -1;
2949-#endif
2954+//#endif
29502955 #if defined(_FM8)
29512956 clock_fast = false;
29522957 #else
@@ -2984,10 +2989,10 @@ void DISPLAY::initialize()
29842989 #endif
29852990
29862991 palette_changed = true;
2987-#if !defined(_FM77AV_VARIANTS) && !defined(_FM77L4)
2988- register_vline_event(this);
2992+//#if !defined(_FM77AV_VARIANTS) && !defined(_FM77L4)
2993+ //register_vline_event(this);
29892994 register_frame_event(this);
2990-#endif
2995+//#endif
29912996 setup_display_mode();
29922997 }
29932998
@@ -3060,14 +3065,7 @@ void DISPLAY::save_state(FILEIO *state_fio)
30603065 state_fio->FputBool(kanjisub);
30613066 state_fio->FputUint16_BE(kanjiaddr.w.l);
30623067
3063- state_fio->FputBool(vblank);
3064- state_fio->FputBool(vsync);
3065- state_fio->FputBool(hblank);
3066- state_fio->FputInt32_BE(vblank_count);
3067-
30683068 state_fio->FputBool(mode320);
3069- state_fio->FputInt8(display_page);
3070- state_fio->FputInt8(display_page_bak);
30713069 state_fio->FputInt32_BE(cgrom_bank);
30723070 #if defined(_FM77AV40) || defined(_FM77AV40SX)|| defined(_FM77AV40SX) || \
30733071 defined(_FM77AV20) || defined(_FM77AV20EX) || defined(_FM77AV20SX)
@@ -3125,14 +3123,22 @@ void DISPLAY::save_state(FILEIO *state_fio)
31253123 // V2
31263124 {
31273125 state_fio->FputInt32_BE(nmi_event_id);
3128-#if defined(_FM77AV_VARIANTS)
3126+//#if defined(_FM77AV_VARIANTS)
31293127 state_fio->FputInt32_BE(hblank_event_id);
31303128 state_fio->FputInt32_BE(hdisp_event_id);
31313129 state_fio->FputInt32_BE(vsync_event_id);
31323130 state_fio->FputInt32_BE(vstart_event_id);
3133-#endif
3131+//#endif
31343132 state_fio->FputBool(firq_mask);
31353133 state_fio->FputBool(vram_accessflag);
3134+
3135+ state_fio->FputInt8(display_page);
3136+ state_fio->FputInt8(display_page_bak);
3137+
3138+ state_fio->FputBool(vblank);
3139+ state_fio->FputBool(vsync);
3140+ state_fio->FputBool(hblank);
3141+ state_fio->FputInt32_BE(vblank_count);
31363142 }
31373143 }
31383144
@@ -3176,6 +3182,8 @@ bool DISPLAY::load_state(FILEIO *state_fio)
31763182 #else
31773183 state_fio->Fread(dpalette_data, sizeof(dpalette_data), 1);
31783184 for(addr = 0; addr < 8; addr++) set_dpalette(addr, dpalette_data[addr]);
3185+ memcpy(dpalette_pixel, dpalette_pixel_tmp, sizeof(dpalette_pixel));
3186+
31793187 multimode_accessmask = state_fio->FgetUint8();
31803188 multimode_dispmask = state_fio->FgetUint8();
31813189 for(i = 0; i < 4; i++) {
@@ -3214,14 +3222,7 @@ bool DISPLAY::load_state(FILEIO *state_fio)
32143222 kanjiaddr.d = 0;
32153223 kanjiaddr.w.l = state_fio->FgetUint16_BE();
32163224
3217- vblank = state_fio->FgetBool();
3218- vsync = state_fio->FgetBool();
3219- hblank = state_fio->FgetBool();
3220- vblank_count = state_fio->FgetInt32_BE();
3221-
32223225 mode320 = state_fio->FgetBool();
3223- display_page = state_fio->FgetInt8();
3224- display_page_bak = state_fio->FgetInt8();
32253226 cgrom_bank = state_fio->FgetInt32_BE();
32263227 #if defined(_FM77AV40) || defined(_FM77AV40SX)|| defined(_FM77AV40SX) || \
32273228 defined(_FM77AV20) || defined(_FM77AV20EX) || defined(_FM77AV20SX)
@@ -3242,6 +3243,7 @@ bool DISPLAY::load_state(FILEIO *state_fio)
32423243 state_fio->Fread(analog_palette_g, sizeof(analog_palette_g), 1);
32433244 state_fio->Fread(analog_palette_b, sizeof(analog_palette_b), 1);
32443245 for(i = 0; i < 4096; i++) calc_apalette(i);
3246+ memcpy(analog_palette_pixel, analog_palette_pixel_tmp, sizeof(analog_palette_pixel));
32453247
32463248 diag_load_subrom_a = state_fio->FgetBool();
32473249 diag_load_subrom_b = state_fio->FgetBool();
@@ -3284,12 +3286,20 @@ bool DISPLAY::load_state(FILEIO *state_fio)
32843286 }
32853287 if(version >= 2) { //V2
32863288 nmi_event_id = state_fio->FgetInt32_BE();
3287-#if defined(_FM77AV_VARIANTS)
3289+//#if defined(_FM77AV_VARIANTS)
32883290 hblank_event_id = state_fio->FgetInt32_BE();
32893291 hdisp_event_id = state_fio->FgetInt32_BE();
32903292 vsync_event_id = state_fio->FgetInt32_BE();
32913293 vstart_event_id = state_fio->FgetInt32_BE();
3292-#endif
3294+//#endif
3295+ display_page = state_fio->FgetInt8();
3296+ display_page_bak = state_fio->FgetInt8();
3297+
3298+ vblank = state_fio->FgetBool();
3299+ vsync = state_fio->FgetBool();
3300+ hblank = state_fio->FgetBool();
3301+ vblank_count = state_fio->FgetInt32_BE();
3302+
32933303 firq_mask = state_fio->FgetBool();
32943304 vram_accessflag = state_fio->FgetBool();
32953305 frame_skip_count_draw = 3;
--- a/source/src/vm/fm7/fm7_display.h
+++ b/source/src/vm/fm7/fm7_display.h
@@ -134,14 +134,14 @@ protected:
134134 // Event handler
135135 int nmi_event_id;
136136
137-#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
137+//#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
138138 int hblank_event_id;
139139 int hdisp_event_id;
140140 int vsync_event_id;
141141 int vstart_event_id;
142142
143143 int vblank_count;
144-#endif
144+//#endif
145145 #if defined(_FM77AV_VARIANTS)
146146 bool subcpu_resetreq;
147147 bool power_on_reset;
@@ -151,6 +151,9 @@ protected:
151151 DEVICE *ins_led;
152152 DEVICE *kana_led;
153153 DEVICE *caps_led;
154+
155+ int8_t display_page;
156+ int8_t display_page_bak;
154157 #if defined(_FM77_VARIANTS)
155158 # if defined(_FM77L4)
156159 bool mode400line;
@@ -167,8 +170,6 @@ protected:
167170 bool mode256k;
168171 # endif
169172 bool mode320;
170- int8_t display_page;
171- int8_t display_page_bak;
172173 int cgrom_bank;
173174 #if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX)|| \
174175 defined(_FM77AV20) || defined(_FM77AV20SX) || defined(_FM77AV20EX)
@@ -195,6 +196,7 @@ protected:
195196 bool diag_load_subrom_c;
196197
197198 scrntype_t dpalette_pixel[8];
199+ scrntype_t dpalette_pixel_tmp[8];
198200 uint8_t dpalette_data[8];
199201 #if defined(_FM77AV_VARIANTS)
200202 pair_t apalette_index;
@@ -202,6 +204,7 @@ protected:
202204 uint8_t analog_palette_g[4096];
203205 uint8_t analog_palette_b[4096];
204206 scrntype_t analog_palette_pixel[4096];
207+ scrntype_t analog_palette_pixel_tmp[4096];
205208 #endif // FM77AV etc...
206209 #if defined(_FM77AV_VARIANTS)
207210 uint8_t io_w_latch[0x40];
@@ -321,12 +324,12 @@ protected:
321324 uint32_t read_bios(const _TCHAR *name, uint8_t *ptr, uint32_t size);
322325 void draw_screen2();
323326
324-#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
327+//#if defined(_FM77AV_VARIANTS) || defined(_FM77L4)
325328 void event_callback_vstart(void);
326329 void event_callback_vsync(void);
327330 void event_callback_hdisp(void);
328331 void event_callback_hblank(void);
329-#endif
332+//#endif
330333 public:
331334 DISPLAY(VM *parent_vm, EMU *parent_emu);
332335 ~DISPLAY();
--- a/source/src/vm/fm7/vram.cpp
+++ b/source/src/vm/fm7/vram.cpp
@@ -736,14 +736,14 @@ void DISPLAY::draw_screen2()
736736 return;
737737 }
738738 crt_flag_bak = crt_flag;
739- if(!vram_wrote_shadow && !palette_changed) return;
739+ if(!vram_wrote_shadow) return;
740740 vram_wrote_shadow = false;
741- if(palette_changed) {
742- for(y = 0; y < 400; y++) {
743- vram_draw_table[y] = true;
744- }
745- palette_changed = false;
746- }
741+ //if(palette_changed) {
742+ // for(y = 0; y < 400; y++) {
743+ // vram_draw_table[y] = true;
744+ // }
745+ // palette_changed = false;
746+ //}
747747 if(display_mode == DISPLAY_MODE_8_200L) {
748748 int ii;
749749 #if 1
Show on old repository browser