Common Source Code Project for Qt (a.k.a for FM-7).
Revisión | 71105e512743b96f3392f5730c9726cdf2b1796c (tree) |
---|---|
Tiempo | 2022-05-04 01:48:02 |
Autor | K.Ohta <whatisthis.sowhat@gmai...> |
Commiter | K.Ohta |
[VM][FMTOWNS][PLANE_VRAM] Optimize for speed.
@@ -34,7 +34,7 @@ void PLANEVRAM::write_io8(uint32_t addr, uint32_t data) | ||
34 | 34 | r50_ramsel = data & 0x0f; |
35 | 35 | break; |
36 | 36 | case 0xff82: |
37 | - if(d_crtc != NULL) { | |
37 | + __LIKELY_IF(d_crtc != NULL) { | |
38 | 38 | d_crtc->write_signal(SIG_TOWNS_CRTC_MMIO_CFF82H, data, 0xffffffff); |
39 | 39 | // out_debug_log(_T("WRITE CFF82h <- %02X"), data); |
40 | 40 | } |
@@ -48,7 +48,7 @@ void PLANEVRAM::write_io8(uint32_t addr, uint32_t data) | ||
48 | 48 | case 0xffa0: |
49 | 49 | break; |
50 | 50 | default: |
51 | - if(d_sprite != NULL) { | |
51 | + __LIKELY_IF(d_sprite != NULL) { | |
52 | 52 | d_sprite->write_data8(addr & 0x7fff, data); |
53 | 53 | } |
54 | 54 | break; |
@@ -65,7 +65,9 @@ uint32_t PLANEVRAM::read_io8(uint32_t addr) | ||
65 | 65 | return ((r50_readplane << 6) | r50_ramsel); |
66 | 66 | break; |
67 | 67 | case 0xff82: |
68 | - return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF82H); | |
68 | + __LIKELY_IF(d_crtc != NULL) { | |
69 | + return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF82H); | |
70 | + } | |
69 | 71 | break; |
70 | 72 | case 0xff83: |
71 | 73 | return ((r50_gvramsel != 0x00000) ? 0x10 : 0x00); |
@@ -74,7 +76,9 @@ uint32_t PLANEVRAM::read_io8(uint32_t addr) | ||
74 | 76 | return 0x7f; // Reserve.FIRQ |
75 | 77 | break; |
76 | 78 | case 0xff86: |
77 | - return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF86H); | |
79 | + __LIKELY_IF(d_crtc != NULL) { | |
80 | + return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF86H); | |
81 | + } | |
78 | 82 | break; |
79 | 83 | case 0xffa0: |
80 | 84 | { |
@@ -85,7 +89,7 @@ uint32_t PLANEVRAM::read_io8(uint32_t addr) | ||
85 | 89 | } |
86 | 90 | break; |
87 | 91 | default: |
88 | - if(d_sprite != NULL) { | |
92 | + __LIKELY_IF(d_sprite != NULL) { | |
89 | 93 | return d_sprite->read_data8(addr & 0x7fff); |
90 | 94 | } |
91 | 95 | break; |
@@ -107,44 +111,44 @@ uint32_t PLANEVRAM::read_memory_mapped_io8(uint32_t addr) | ||
107 | 111 | |
108 | 112 | // 8bit -> 32bit |
109 | 113 | uint8_t val = 0; |
110 | - const uint8_t nmask[4] = {0x11, 0x22, 0x44, 0x88}; | |
111 | - uint8_t hmask = nmask[r50_readplane & 3] & 0xf0; | |
112 | - uint8_t lmask = nmask[r50_readplane & 3] & 0x0f; | |
113 | - uint8_t hval = 0x80; | |
114 | - uint8_t lval = 0x40; | |
114 | + const uint8_t lmask = 1 << (r50_readplane & 3); | |
115 | + const uint8_t hmask = lmask << 4; | |
115 | 116 | |
116 | 117 | d_vram->lock(); |
117 | 118 | __DECL_ALIGNED(8) uint8_t extra_p[8]; |
118 | 119 | __DECL_ALIGNED(8) uint8_t extra_mask[8]; |
119 | - __DECL_ALIGNED(8) uint8_t extra_value[8]; | |
120 | + const uint8_t extra_value[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; | |
120 | 121 | __DECL_ALIGNED(8) uint8_t extra_bool[8]; |
122 | + __DECL_ALIGNED(8) uint8_t cache[4]; | |
121 | 123 | |
122 | 124 | __DECL_VECTORIZED_LOOP |
123 | - for(int i = 0; i < 8; i += 2) { | |
124 | - extra_p[i ] = p[i >> 1]; | |
125 | - extra_p[i + 1] = p[i >> 1]; | |
125 | + for(int i = 0; i < 4; i++) { | |
126 | + cache[i] = p[i]; | |
127 | + } | |
128 | + | |
129 | +__DECL_VECTORIZED_LOOP | |
130 | + for(int i = 0, j = 0; i < 8; i += 2, j++) { | |
131 | + extra_p[i ] = cache[j]; | |
132 | + extra_p[i + 1] = cache[j]; | |
126 | 133 | } |
127 | 134 | __DECL_VECTORIZED_LOOP |
128 | 135 | for(int i = 0; i < 8; i += 2) { |
129 | 136 | extra_mask[i ] = hmask; |
130 | 137 | extra_mask[i + 1] = lmask; |
131 | 138 | } |
139 | + | |
132 | 140 | __DECL_VECTORIZED_LOOP |
133 | - for(int i = 0; i < 8; i += 2) { | |
134 | - extra_value[i ] = hval; | |
135 | - extra_value[i + 1] = lval; | |
136 | - hval >>= 2; | |
137 | - lval >>= 2; | |
141 | + for(int i = 0; i < 8; i++) { | |
142 | + extra_bool[i] = ((extra_mask[i] & extra_p[i]) != 0) ? 0xff : 0x00; | |
138 | 143 | } |
139 | 144 | |
140 | 145 | __DECL_VECTORIZED_LOOP |
141 | 146 | for(int i = 0; i < 8; i++) { |
142 | - extra_bool[i] = ((extra_mask[i] & extra_p[i]) != 0) ? 0xff : 0x00; | |
147 | + extra_bool[i] &= extra_value[i]; | |
143 | 148 | } |
144 | - | |
145 | 149 | __DECL_VECTORIZED_LOOP |
146 | 150 | for(int i = 0; i < 8; i++) { |
147 | - val |= (extra_bool[i] & extra_value[i]); | |
151 | + val |= extra_bool[i]; | |
148 | 152 | } |
149 | 153 | d_vram->unlock(); |
150 | 154 |