OSDN Git Service

[VM][FM7][DISPLAY] Use flags array to determine not accessble.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 16 May 2017 13:19:27 +0000 (22:19 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 16 May 2017 13:19:27 +0000 (22:19 +0900)
source/src/vm/fm7/display.cpp
source/src/vm/fm7/fm7_display.h
source/src/vm/fm7/vram.cpp

index f00cc61..ee6d93c 100644 (file)
@@ -67,6 +67,10 @@ void DISPLAY::reset_cpuonly()
        palette_changed = true;
        multimode_accessmask = 0;
        multimode_dispmask = 0;
+       for(i = 0; i < 4; i++) {
+               multimode_accessflags[i] = ((multimode_accessmask & (1 << i)) != 0) ? true : false;
+               multimode_dispflags[i] = ((multimode_dispmask & (1 << i)) != 0) ? true : false;
+       }
        firq_mask = false;
        //cancel_request = false;
        switch(config.cpu_type){
@@ -221,8 +225,12 @@ void DISPLAY::reset()
 #else
 # if defined(_FM8)
        for(i = 0; i < 8; i++) set_dpalette(i, i);
-       multimode_accessmask = 0x00;
-       multimode_dispmask = 0x00;
+       //multimode_accessmask = 0x00;
+       //multimode_dispmask = 0x00;
+       //for(i = 0; i < 4; i++) {
+       //      multimode_accessflags[i] = ((multimode_accessmask & (1 << color)) != 0) ? true : false;
+       //      multimode_dispflags[i] = ((multimode_dispmask & (1 << color)) != 0) ? true : false;
+       //}
 # endif
 #endif 
        //enter_display();
@@ -332,6 +340,10 @@ void DISPLAY::set_multimode(uint8_t val)
 #if !defined(_FM8)     
        multimode_accessmask = val & 0x07;
        multimode_dispmask = (val & 0x70) >> 4;
+       for(int i = 0; i < 4; i++) {
+               multimode_accessflags[i] = ((multimode_accessmask & (1 << i)) != 0) ? true : false;
+               multimode_dispflags[i] = ((multimode_dispmask & (1 << i)) != 0) ? true : false;
+       }
        vram_wrote = true;
 # if defined(_FM77AV_VARIANTS)
        alu->write_signal(SIG_ALU_MULTIPAGE, multimode_accessmask, 0x07);
@@ -1269,26 +1281,37 @@ void DISPLAY::event_callback(int event_id, int err)
                mainio->write_signal(SIG_DISPLAY_DISPLAY, 0x00, 0xff);
                register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
                if((config.dipswitch & FM7_DIPSW_SYNC_TO_HSYNC) == 0) {
-                               bool ff = false;
-                               if(vram_wrote) {
-                                       if(need_transfer_line) ff = true;
+                       bool ff = false;
+                       int lines = 200;
+                       if(display_mode == DISPLAY_MODE_8_400L) lines = 400;
+                       if(need_transfer_line) {
+                               if(vram_wrote) ff = true;
+                               //if(need_transfer_line) ff = true;
+                               //}
+                               for(displine = 0; displine < lines; displine++) {
+                                       if(ff) break;
+                                       for(int iii = 0; iii < 5 ; iii++) {
+                                               if(vram_wrote_table[iii + displine * 5]) {
+                                                       ff = true;
+                                                       break;
+                                               }
+                                       }
                                }
-                               if(ff) {
-                                       int lines = 200;
-                                       if(display_mode == DISPLAY_MODE_8_400L) lines = 400;
-                                       for(int yy = 0; yy < lines; yy++) {
-                                               //if(!vram_draw_table[yy]) {
-                                                       displine = yy;
-                                                       copy_vram_per_line(0, 4);
-                                                       vram_draw_table[yy] = true;
-                                               //}
+                               displine = 0;
+                       }
+                       if(ff) {
+                               for(int yy = 0; yy < lines; yy++) {
+                                       if(!vram_draw_table[yy]) {
+                                               displine = yy;
+                                               copy_vram_per_line(0, 4);
+                                               vram_draw_table[yy] = true;
                                        }
-                                  
-                                       //copy_vram_all();
-                                       vram_wrote_shadow = true;
-                                       screen_update_flag = true;
-                                       vram_wrote = false;
                                }
+                               //copy_vram_all();
+                               vram_wrote_shadow = true;
+                               screen_update_flag = true;
+                               vram_wrote = false;
+                       }
                } else {
                        int lines = 200;
                        if(display_mode == DISPLAY_MODE_8_400L) lines = 400;
@@ -1296,9 +1319,9 @@ void DISPLAY::event_callback(int event_id, int err)
                                if(vram_wrote) {
                                        for(int yy = 0; yy < lines; yy++) {
                                                //if(!vram_draw_table[yy]) {
-                                                       displine = yy;
-                                                       copy_vram_per_line(0, 4);
-                                               //}
+                                               displine = yy;
+                                               copy_vram_per_line(0, 4);
+                                                       //}
                                        }
                                        displine = 0;
                                        vram_wrote = false;
@@ -1775,7 +1798,8 @@ uint32_t DISPLAY::read_vram_data8(uint32_t addr)
        }
 # endif
 # if !defined(_FM8)            
-       if((multimode_accessmask & (1 << color)) != 0) return 0xff;
+       //if((multimode_accessmask & (1 << color)) != 0) return 0xff;
+       if(multimode_accessflags[color]) return 0xff;
 # endif                
 #if defined(_FM77AV_VARIANTS)
        if (active_page != 0) {
@@ -2545,7 +2569,8 @@ void DISPLAY::write_cpu_vram_data8(uint32_t addr, uint8_t data)
        }
 #endif
 #if !defined(_FM8)
-       if((multimode_accessmask & (1 << color)) != 0) return;
+       //if((multimode_accessmask & (1 << color)) != 0) return;
+       if(multimode_accessflags[color]) return;
 #endif         
        write_vram_data8(addr & 0xffff, data);
 }
@@ -2560,7 +2585,8 @@ void DISPLAY::write_dma_vram_data8(uint32_t addr, uint8_t data)
        }
 #endif
 #if !defined(_FM8)
-       if((multimode_accessmask & (1 << color)) != 0) return;
+       //if((multimode_accessmask & (1 << color)) != 0) return;
+       if(multimode_accessflags[color]) return;
 #endif         
        write_vram_data8(addr & 0xffff, data);
 }
@@ -2749,7 +2775,12 @@ void DISPLAY::initialize()
        is_cyclesteal = true;
 #else
        is_cyclesteal = false;
-#endif 
+#endif
+       multimode_accessmask = multimode_dispmask = 0;
+       for(i = 0; i < 4; i++) {
+               multimode_accessflags[i] = ((multimode_accessmask & (1 << i)) != 0) ? true : false;
+               multimode_dispflags[i] = ((multimode_dispmask & (1 << i)) != 0) ? true : false;
+       }
 //     emu->set_vm_screen_size(640, 200, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH_ASPECT, WINDOW_HEIGHT_ASPECT);
        emu->set_vm_screen_size(640, 200, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH_ASPECT, WINDOW_HEIGHT_ASPECT);
        enter_display();
@@ -2954,6 +2985,10 @@ bool DISPLAY::load_state(FILEIO *state_fio)
                for(addr = 0; addr < 8; addr++) set_dpalette(addr, dpalette_data[addr]);
                multimode_accessmask = state_fio->FgetUint8();
                multimode_dispmask = state_fio->FgetUint8();
+               for(i = 0; i < 4; i++) {
+                       multimode_accessflags[i] = ((multimode_accessmask & (1 << i)) != 0) ? true : false;
+                       multimode_dispflags[i] = ((multimode_dispmask & (1 << i)) != 0) ? true : false;
+               }
 #endif
                offset_point = state_fio->FgetUint32_BE();
 #if defined(_FM77AV_VARIANTS)
index 2372f5c..314bd15 100644 (file)
@@ -211,6 +211,8 @@ protected:
 #endif
        uint8_t multimode_accessmask;
        uint8_t multimode_dispmask;
+       bool multimode_accessflags[4];
+       bool multimode_dispflags[4];
    
        uint32_t offset_point;
        pair_t tmp_offset_point[2];
@@ -274,11 +276,11 @@ protected:
        DEVICE *subcpu;
        DEVICE *keyboard;
        bool vram_wrote;
-       void GETVRAM_8_200L(int yoff, scrntype_t *p, uint32_t rgbmask, bool window_inv);
+       void GETVRAM_8_200L(int yoff, scrntype_t *p, bool window_inv);
        void GETVRAM_4096(int yoff, scrntype_t *p, uint32_t rgbmask, bool window_inv);
 #if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
-       void GETVRAM_8_400L(int yoff, scrntype_t *p, uint32_t mask, bool window_inv);
-       void GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask);
+       void GETVRAM_8_400L(int yoff, scrntype_t *p, bool window_inv);
+       void GETVRAM_256k(int yoff, scrntype_t *p);
 #endif   
        uint8_t read_vram_l4_400l(uint32_t addr, uint32_t offset);
        uint32_t read_mmio(uint32_t addr);
index 66d6580..f0f039e 100644 (file)
@@ -53,7 +53,7 @@ void DISPLAY::write_vram_l4_400l(uint32_t addr, uint32_t offset, uint32_t data)
 #endif 
 }
 
-void DISPLAY::GETVRAM_8_200L(int yoff, scrntype_t *p, uint32_t mask,
+void DISPLAY::GETVRAM_8_200L(int yoff, scrntype_t *p, 
                                                                        bool window_inv = false)
 {
        uint8_t b, r, g;
@@ -79,9 +79,15 @@ void DISPLAY::GETVRAM_8_200L(int yoff, scrntype_t *p, uint32_t mask,
 #if defined(_FM77AV_VARIANTS)
        if(display_page_bak == 1) yoff_d += 0xc000;
 #endif
+#if 0
        if(mask & 0x01) b = gvram_shadow[yoff_d + 0x00000];
        if(mask & 0x02) r = gvram_shadow[yoff_d + 0x04000];
        if(mask & 0x04) g = gvram_shadow[yoff_d + 0x08000];
+#else
+       if(!multimode_dispflags[0]) b = gvram_shadow[yoff_d + 0x00000];
+       if(!multimode_dispflags[1]) r = gvram_shadow[yoff_d + 0x04000];
+       if(!multimode_dispflags[2]) g = gvram_shadow[yoff_d + 0x08000];
+#endif
 #if 1
        uint16_t *pg = &(bit_trans_table_0[g][0]);
        uint16_t *pr = &(bit_trans_table_1[r][0]);
@@ -119,7 +125,7 @@ void DISPLAY::GETVRAM_8_200L(int yoff, scrntype_t *p, uint32_t mask,
 }
 
 #if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
-void DISPLAY::GETVRAM_8_400L(int yoff, scrntype_t *p, uint32_t mask,
+void DISPLAY::GETVRAM_8_400L(int yoff, scrntype_t *p, 
                                                         bool window_inv = false)
 {
        uint8_t b, r, g;
@@ -141,9 +147,15 @@ void DISPLAY::GETVRAM_8_400L(int yoff, scrntype_t *p, uint32_t mask,
        if(dpage != 0) yoff_d += 0x18000;
 # endif
        b = r = g = 0;
+#if 0
        if(mask & 0x01) b = gvram_shadow[yoff_d + 0x00000];
        if(mask & 0x02) r = gvram_shadow[yoff_d + 0x08000];
        if(mask & 0x04) g = gvram_shadow[yoff_d + 0x10000];
+#else
+       if(!multimode_dispflags[0]) b = gvram_shadow[yoff_d + 0x00000];
+       if(!multimode_dispflags[1]) r = gvram_shadow[yoff_d + 0x08000];
+       if(!multimode_dispflags[2]) g = gvram_shadow[yoff_d + 0x10000];
+#endif
 #if 1
        uint16_t *pg = &(bit_trans_table_0[g][0]);
        uint16_t *pr = &(bit_trans_table_1[r][0]);
@@ -179,7 +191,7 @@ void DISPLAY::GETVRAM_8_400L(int yoff, scrntype_t *p, uint32_t mask,
 #endif
 }
 
-void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
+void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p)
 {
        uint32_t b3, r3, g3;
        uint32_t b4, r4, g4;
@@ -204,7 +216,8 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
        uint8_t  bb[8], rr[8], gg[8];
        uint16_t *p0, *p1, *p2, *p3, *p4, *p5;
        uint32_t _btmp[8], _rtmp[8], _gtmp[8];
-       if(mask & 0x01) {
+//     if(mask & 0x01) {
+       if(!multimode_dispflags[0]) {
                // B
                bb[0] = gvram_shadow[yoff_d1];
                bb[1] = gvram_shadow[yoff_d1 + 0x02000];
@@ -229,7 +242,8 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
                        _btmp[i] = 0;
                }
        }
-       if(mask & 0x02) {
+       if(!multimode_dispflags[1]) {
+               //if(mask & 0x02) {
                // R
                rr[0] = gvram_shadow[yoff_d1 + 0x04000];
                rr[1] = gvram_shadow[yoff_d1 + 0x06000];
@@ -254,7 +268,8 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
                        _rtmp[i] = 0;
                }
        }
-       if(mask & 0x04) {
+       if(!multimode_dispflags[2]) {
+               //if(mask & 0x04) {
                // G
                gg[0] = gvram_shadow[yoff_d1 + 0x08000];
                gg[1] = gvram_shadow[yoff_d1 + 0x0a000];
@@ -284,7 +299,8 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
        }
        
 #else
-       if(mask & 0x01) {
+       if(!multimode_dispflags[0]) {
+               //if(mask & 0x01) {
                b3  = gvram_shadow[yoff_d1] << 24;
                b3 |= gvram_shadow[yoff_d1 + 0x02000] << 16;
                
@@ -294,7 +310,8 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
                b4  = gvram_shadow[yoff_d1 + 0x18000] << 8;
                b4 |= gvram_shadow[yoff_d1 + 0x1a000] << 0;
        }
-       if(mask & 0x02) {
+       if(!multimode_dispflags[1]) {
+               //if(mask & 0x02) {
                r3  = gvram_shadow[yoff_d1 + 0x04000] << 24;
                r3 |= gvram_shadow[yoff_d1 + 0x06000] << 16;
                r3 |= gvram_shadow[yoff_d2 + 0x10000] << 8;
@@ -303,7 +320,8 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
                r4 |= gvram_shadow[yoff_d1 + 0x1e000] << 0;
        }
 
-       if(mask & 0x04) {
+       if(!multimode_dispflags[2]) {
+               //if(mask & 0x04) {
                g3  = gvram_shadow[yoff_d1 + 0x08000] << 24;
                g3 |= gvram_shadow[yoff_d1 + 0x0a000] << 16;
                g3 |= gvram_shadow[yoff_d2 + 0x14000] << 8;
@@ -317,21 +335,24 @@ void DISPLAY::GETVRAM_256k(int yoff, scrntype_t *p, uint32_t mask)
        for(_shift = 7; _shift >= 0; _shift--) {
                _bit = 0x01010101 << _shift;
                r = g = b = 0;
-               if(mask & 0x01) {
+               if(!multimode_dispflags[0]) {
+                       //if(mask & 0x01) {
                        btmp = (b3 & _bit) >> _shift;
                        b = (((btmp & (0x01 << 24)) != 0) ? 0x80 : 0) | (((btmp & (0x01 << 16)) != 0)? 0x40 : 0)
                                | (((btmp & (0x01 << 8)) != 0) ? 0x20 : 0) | (((btmp & 0x01) != 0) ? 0x10   : 0);
                        btmp = (b4 & _bit) >> _shift;
                        b = b | (((btmp & (0x01 << 8)) != 0) ? 0x08 : 0) | (((btmp & 0x01) != 0) ? 0x04 : 0);
                }
-               if(mask & 0x02) {
+               if(!multimode_dispflags[1]) {
+                       //if(mask & 0x02) {
                        rtmp = (r3 & _bit) >> _shift;
                        r = ((rtmp & (0x01 << 24)) ? 0x80 : 0) | ((rtmp & (0x01 << 16)) ? 0x40 : 0)
                                | ((rtmp & (0x01 << 8)) ? 0x20 : 0) | ((rtmp & 0x01) ? 0x10   : 0);
                        rtmp = (r4 & _bit) >> _shift;
                        r = r | ((rtmp & (0x01 << 8)) ? 0x08 : 0) | ((rtmp & 0x01) ? 0x04 : 0);
                }
-               if(mask & 0x04) {
+               if(!multimode_dispflags[2]) {
+                       //if(mask & 0x04) {
                        gtmp = (g3 & _bit) >> _shift;
                        g = ((gtmp & (0x01 << 24)) ? 0x80 : 0) | ((gtmp & (0x01 << 16)) ? 0x40 : 0)
                                | ((gtmp & (0x01 << 8)) ? 0x20 : 0) | ((gtmp & 0x01) ? 0x10   : 0);
@@ -355,7 +376,7 @@ void DISPLAY::GETVRAM_4096(int yoff, scrntype_t *p, uint32_t mask,
        uint32_t b3, r3, g3;
        uint8_t  bb[4], rr[4], gg[4];
        uint16_t pixels[8];
-       uint16_t __masks[8] = {(uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask};
+       const uint16_t __masks[8] = {(uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask, (uint16_t)mask};
        scrntype_t b, r, g;
        uint32_t idx;;
        scrntype_t pixel;
@@ -450,7 +471,7 @@ void DISPLAY::draw_screen2()
        int x;
        scrntype_t *p, *pp;
        int yoff;
-       uint32_t rgbmask;
+       //uint32_t rgbmask;
        uint32_t yoff_d1, yoff_d2;
        uint16_t wx_begin, wx_end, wy_low, wy_high;
        
@@ -530,7 +551,7 @@ void DISPLAY::draw_screen2()
                int ii;
                emu->set_vm_screen_size(640, 200, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH_ASPECT, WINDOW_HEIGHT_ASPECT);
                yoff = 0;
-               rgbmask = ~multimode_dispmask;
+               //rgbmask = ~multimode_dispmask;
                for(y = 0; y < 200; y ++) {
                        if(!vram_draw_table[y]) continue;
                        vram_draw_table[y] = false;
@@ -542,9 +563,9 @@ void DISPLAY::draw_screen2()
                        if(window_opened && (wy_low <= y) && (wy_high > y)) {
                                        for(x = 0; x < 80; x++) {
                                                if((x >= wx_begin) && (x < wx_end)) {
-                                                       GETVRAM_8_200L(yoff, p, rgbmask, true);
+                                                       GETVRAM_8_200L(yoff, p, true);
                                                } else {
-                                                       GETVRAM_8_200L(yoff, p, rgbmask, false);
+                                                       GETVRAM_8_200L(yoff, p, false);
                                                }
                                                p += 8;
                                                yoff++;
@@ -554,7 +575,7 @@ void DISPLAY::draw_screen2()
                        {
                                for(x = 0; x < 10; x++) {
                                        for(ii = 0; ii < 8; ii++) {
-                                               GETVRAM_8_200L(yoff + ii, p, rgbmask, false);
+                                               GETVRAM_8_200L(yoff + ii, p, false);
                                                p += 8;
                                        }
                                        yoff += 8;
@@ -569,10 +590,16 @@ void DISPLAY::draw_screen2()
                uint32_t mask = 0;
                int ii;
                yoff = 0;
+#if 0
                rgbmask = multimode_dispmask;
                if((rgbmask & 0x01) == 0) mask = 0x00f;
                if((rgbmask & 0x02) == 0) mask = mask | 0x0f0;
                if((rgbmask & 0x04) == 0) mask = mask | 0xf00;
+#else
+               if(!multimode_dispflags[0]) mask = 0x00f;
+               if(!multimode_dispflags[1]) mask = mask | 0x0f0;
+               if(!multimode_dispflags[2]) mask = mask | 0xf00;
+#endif
                for(y = 0; y < 200; y ++) {
                        if(!vram_draw_table[y]) continue;
                        vram_draw_table[y] = false;
@@ -611,7 +638,7 @@ void DISPLAY::draw_screen2()
                int ii;
                emu->set_vm_screen_size(640, 400, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH_ASPECT, WINDOW_HEIGHT_ASPECT);
                yoff = 0;
-               rgbmask = ~multimode_dispmask;
+               //rgbmask = ~multimode_dispmask;
                for(y = 0; y < 400; y++) {
                        if(!vram_draw_table[y]) continue;
                        vram_draw_table[y] = false;
@@ -624,9 +651,9 @@ void DISPLAY::draw_screen2()
                        if(window_opened && (wy_low <= y) && (wy_high  > y)) {
                                for(x = 0; x < 80; x++) {
                                        if((x >= wx_begin) && (x < wx_end)) {
-                                               GETVRAM_8_400L(yoff, p, rgbmask, true);
+                                               GETVRAM_8_400L(yoff, p, true);
                                        } else {
-                                               GETVRAM_8_400L(yoff, p, rgbmask, false);
+                                               GETVRAM_8_400L(yoff, p, false);
                                        }
                                        p += 8;
                                        yoff++;
@@ -636,7 +663,7 @@ void DISPLAY::draw_screen2()
                        for(x = 0; x < 10; x++) {
 
                                for(ii = 0; ii < 8; ii++) {
-                                       GETVRAM_8_400L(yoff + ii, p, rgbmask);
+                                       GETVRAM_8_400L(yoff + ii, p);
                                        p += 8;
                                }
                                yoff += 8;
@@ -646,7 +673,7 @@ void DISPLAY::draw_screen2()
        } else if(display_mode == DISPLAY_MODE_256k) {
                int ii;
                emu->set_vm_screen_size(320, 200, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH_ASPECT, WINDOW_HEIGHT_ASPECT);
-               rgbmask = ~multimode_dispmask;
+               //rgbmask = ~multimode_dispmask;
                for(y = 0; y < 200; y++) {
                        if(!vram_draw_table[y]) continue;
                        vram_draw_table[y] = false;
@@ -657,7 +684,7 @@ void DISPLAY::draw_screen2()
                        {
                                for(x = 0; x < 5; x++) {
                                        for(ii = 0; ii < 8; ii++) {
-                                               GETVRAM_256k(yoff + ii, p, rgbmask);
+                                               GETVRAM_256k(yoff + ii, p);
                                                p += 8;
                                        }
                                        yoff += 8;