• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revisionb5b6c6a8e1d3f105bd4e759a64b8fbb95dead3b8 (tree)
Time2019-01-10 18:00:10
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][FMTOWNS][VRAM][WIP] Implementing.

Change Summary

Incremental Difference

--- a/source/src/vm/fmtowns/towns_vram.cpp
+++ b/source/src/vm/fmtowns/towns_vram.cpp
@@ -21,17 +21,25 @@ namespace FMTOWNS {
2121
2222 void TOWNS_VRAM::initialize()
2323 {
24-#ifdef _USE_ALPHA_CHANNEL
2524 for(int i = 0; i < 32768; i++) {
2625 uint8_t g = (i / (32 * 32)) & 0x1f;
2726 uint8_t r = (i / 32) & 0x1f;
2827 uint8_t b = i & 0x1f;
2928 table_32768c[i] = RGBA_COLOR(r << 3, g << 3, b << 3, 0xff);
29+ table_32768c[i + 32768] = table_32768c[i];
30+ alpha_32768c[i] = RGBA_COLOR(255, 255, 255, 255);
31+ alpha_32768c[i + 32768] = RGBA_COLOR(0, 0, 0, 0);
32+ mask_32768c[i] = 0xffff;
33+ mask_32768c[i + 32768] = 0x0000;
3034 }
31- for(int i = 32768; i < 65536; i++) {
32- table_32768c[i] = _CLEAR_COLOR;
35+ for(int i = 0; i < 256; i++) {
36+ int chigh = i & 0xf0;
37+ int clow = i & 0x0f;
38+ uint8_t alpha;
39+ alpha_16c[ i << 2 ] = (chigh == 0) ? RGBA_COLOR(0, 0, 0, 0) : RGBA_COLOR(255, 255, 255, 255);
40+ alpha_16c[(i << 2) + 1] = (clow == 0) ? RGBA_COLOR(0, 0, 0, 0) : RGBA_COLOR(255, 255, 255, 255);
41+ mask_16c[i] = ((chigh == 0) ? 0x00: 0xf0) | ((clow == 0) ? 0x00 : 0x0f);
3342 }
34-#endif
3543 for(int i = 0; i < TOWNS_CRTC_MAX_LINES; i++) {
3644 line_rendered[0][i] = false;
3745 line_rendered[1][i] = false;
@@ -100,7 +108,7 @@ void TOWNS_VRAM::write_data8(uint32_t addr, uint32_t data)
100108 // ToDo: Mask Register.
101109 bool dirty;
102110 uint32_t naddr = addr & 0x7ffff;
103-
111+
104112 #ifdef __LITTLE_ENDIAN__
105113 uint8_t* p = (uint8_t*)vram;
106114 n = p[naddr];
@@ -128,26 +136,6 @@ void TOWNS_VRAM::write_data8(uint32_t addr, uint32_t data)
128136 #else
129137 vram[naddr >> 1] = d.w;
130138 #endif
131-
132-#if 0
133- if((naddr & 1) != 0) {
134- // Upper address: Change mask for 32768colors.
135- uint16_t nd = (n < 0x80) ? 0xffff : 0x0000;
136- alpha_32768_byte[naddr >> 1] = (uint8_t)nd;
137- alpha_32768_word[naddr >> 1] = nd;
138- mask_32768_word[naddr >> 1] = ~nd;
139- }
140- // ToDo: Mask/alpha16.
141- uint16_t nu = ((n & 0xf0) != 0) ? 0x0000 : 0xffff;
142- uint16_t nl = ((n & 0x0f) != 0) ? 0x0000 : 0xffff;
143- naddr = naddr << 1;
144- alpha_16_byte[naddr + 0] = (uint8_t)nu;
145- alpha_16_byte[naddr + 1] = (uint8_t)nl;
146- alpha_16_word[naddr + 0] = nu;
147- alpha_16_word[naddr + 1] = nl;
148- mask_16_byte[naddr + 0] = ~nu;
149- mask_16_byte[naddr + 1] = ~nl;
150-#endif
151139 }
152140 }
153141
@@ -163,35 +151,9 @@ void TOWNS_VRAM::write_data16(uint32_t addr, uint32_t data)
163151 dirty = ((uint16_t)data != d) ? true : false;
164152
165153 if(dirty) {
166- dirty_flag[naddr >> 2] = true;
154+ dirty_flag[naddr >> 3] = true;
167155 // ToDo: Mask register
168156 vram[naddr] = data;
169-#if 0
170- uint16_t alphaw = (nw.w < 0x8000) ? 0xffff : 0x0000;
171- alpha_32768_byte[naddr >> 1] = (uint8_t)alphaw;
172- alpha_32768_word[naddr >> 1] = alphaw;
173- mask_32768_word[naddr >> 1] = ~alphaw;
174-
175-
176- uint16_t n0 = ((nw.b.h & 0xf0) != 0) ? 0x0000 : 0xffff;
177- uint16_t n1 = ((nw.b.h & 0x0f) != 0) ? 0x0000 : 0xffff;
178- uint16_t n2 = ((nw.b.l & 0xf0) != 0) ? 0x0000 : 0xffff;
179- uint16_t n3 = ((nw.b.l & 0x0f) != 0) ? 0x0000 : 0xffff;
180- naddr = naddr << 1;
181- alpha_16_byte[naddr + 0] = (uint8_t)n0;
182- alpha_16_byte[naddr + 1] = (uint8_t)n1;
183- alpha_16_byte[naddr + 2] = (uint8_t)n2;
184- alpha_16_byte[naddr + 3] = (uint8_t)n3;
185- alpha_16_word[naddr + 0] = n0;
186- alpha_16_word[naddr + 1] = n1;
187- alpha_16_word[naddr + 2] = n2;
188- alpha_16_word[naddr + 3] = n3;
189-
190- mask_16_byte[naddr + 0] = ~n0;
191- mask_16_byte[naddr + 1] = ~n1;
192- mask_16_byte[naddr + 2] = ~n2;
193- mask_16_byte[naddr + 3] = ~n3;
194-#endif
195157 }
196158 }
197159
@@ -216,7 +178,7 @@ void TOWNS_VRAM::write_data32(uint32_t addr, uint32_t data)
216178
217179 if(dirty) {
218180 // ToDo: Mask register
219- dirty_flag[(naddr >> 2) + 0] = true;
181+ dirty_flag[naddr >> 3] = true;
220182
221183 #ifdef __LITTLE_ENDIAN__
222184 p[naddr >> 1] = data;
@@ -228,7 +190,72 @@ void TOWNS_VRAM::write_data32(uint32_t addr, uint32_t data)
228190 }
229191 }
230192
231-
193+// Check dirty and calc alpha by 8 bytes.
194+bool TOWNS_VRAM::check_dirty_and_calc_alpha(uint32_t addr)
195+{
196+ __DECL_ALIGNED(16) uint16_t pix_cache_16[4];
197+ __DECL_ALIGNED(16) uint8_t pix_cache_8[8];
198+ __DECL_ALIGNED(16) uint8_t pix_cache_4[16];
199+
200+ __DECL_ALIGNED(4 * sizeof(scrntype_t)) scrntype_t alpha_cache_16[4];
201+ __DECL_ALIGNED(16) uint16_t mask_cache_16[4];
202+ __DECL_ALIGNED(16) uint16_t mask_cache_16_neg[4];
203+ __DECL_ALIGNED(16) uint8_t mask_cache_4[8];
204+ __DECL_ALIGNED(16) uint8_t mask_cache_4_neg[8];
205+ __DECL_ALIGNED(16) scrntype_t alpha_cache_4[16];
206+ bool dirty = dirty_flag[addr >> 3];
207+ // If Not dirty, alpha/mask already calced.
208+ if(dirty) {
209+ uint32_t layer = (addr >= 0x40000) ? 1 : 0;
210+ uint32_t naddr = addr & 0x3ffff;
211+ // alpha32768
212+ uint16_t *vptr = vram_ptr[layer];
213+ uint16_t *vptr8 = (uint8_t*)vptr;
214+ for(int i = 0; i < 4; i++) {
215+ pix_cache_16[i] = vptr[naddr >> 1];
216+ }
217+ for(int i = 0; i < 4; i++) {
218+ alpha_cache_16[i] = alpha_32768c[pix_cache_16[i]];
219+ mask_cache_16[i] = mask_32768c[pix_cache_16[i]];
220+ mask_cache_16_neg[i] = ~mask_cache_16[i];
221+ }
222+ scrntype_t* palpha = &(alpha_buffer_32768[addr >> 1]);
223+ uint16_t* pmask16 = &(mask_buffer_32768[addr >> 1]);
224+ uint16_t* pmask16_neg = &(mask_buffer_32768_neg[addr >> 1]);
225+ for(int i = 0; i < 4; i++) {
226+ palpha[i] = alpha_cache_16[i];
227+ pmask16[i] = mask_cache_16[i];
228+ pmask16_neg[i] = mask_cache_16_neg[i];
229+ }
230+
231+ for(int i = 0; i < 8; i++) {
232+ pix_cache_8[i] = vptr8[naddr];
233+ }
234+ // Alpha8
235+
236+ for(int i = 0; i < 8; i++) {
237+ alpha_cache_4[i << 1] = alpha_16c[pix_cache_8[i] << 1];
238+ alpha_cache_4[(i << 1) + 1] = alpha_16c[(pix_cache_8[i] << 1) + 1];
239+ }
240+ for(int i = 0; i < 8; i++) {
241+ mask_cache_4[i] = mask_16c[pix_cache_8[i]];
242+ mask_cache_4_neg[i] = ~mask_cache_4[i];
243+ }
244+ palpha = &(alpha_buffer_16[addr << 1]);
245+ uint16_t* pmask4 = &(mask_buffer_16[addr]);
246+ uint16_t* pmask4_neg = &(mask_buffer_16_neg[addr]);
247+ for(int i = 0; i < 16; i++) {
248+ palpha[i] = alpha_cache_4[i];
249+ }
250+ for(int i = 0; i < 8; i++) {
251+ pmask4[i] = mask_cache_4[i];
252+ pmask4_neg[i] = mask_cache_4_neg[i];
253+ }
254+ }
255+ return dirty;
256+}
257+
258+
232259 uint32_t TOWNS_VRAM::read_plane_data8(uint32_t addr)
233260 {
234261 // Plane Access
@@ -425,17 +452,15 @@ void TOWNS_CRTC::set_apalette_num(int layer, uint8_t val)
425452 }
426453
427454 // Renderers
428-void TOWNS_CRTC::render_line_16(int layer, bool upper_layer, scrntype_t *framebuffer, uint8_t *vramptr, uint32_t startaddr, uint32_t words)
455+void TOWNS_CRTC::render_line_16_boundary(int layer, scrntype_t *framebuffer, uint8_t *vramptr, uint32_t startaddr, uint32_t words)
429456 {
457+ // Simplify render: Must set 16pixels
430458 uint32_t wordptr = 0;
431459 int nwords = (int)words / 16;
432460 int ip;
433461 uint32_t src;
434462 uint32_t src1, src2;
435- __DECL_ALIGNED(16) uint8_t srcdat[16];
436- __DECL_ALIGNED(sizeof(scrntype_t) * 16) scrntype_t tmpdat[16];
437-
438- __DECL_ALIGNED(sizeof(scrntype_t) * 16) scrntype_t alpha_cache_16[16];
463+ __DECL_ALIGNED(8) uint8_t srcdat[8];
439464 __DECL_ALIGNED(sizeof(scrntype_t) * 16) scrntype_t data_cache_16[16];
440465
441466 scrntype_t *pdst = framebuffer;
@@ -451,7 +476,7 @@ void TOWNS_CRTC::render_line_16(int layer, bool upper_layer, scrntype_t *framebu
451476 pp = &(pp[offset_base]);
452477
453478 for(ip = 0; ip < nwords; ip++) {
454- if(!dirty_flag[(offset_base >> 3)]) {
479+ if(!check_dirty_and_calc_alpha(offset_base)) {
455480 pdst += 16;
456481 pp += 8;
457482 offset_base += 8;
@@ -463,79 +488,57 @@ void TOWNS_CRTC::render_line_16(int layer, bool upper_layer, scrntype_t *framebu
463488 srcdat[(ii << 1) + 1] = srcdat[ii << 1] & 0x0f;
464489 srcdat[ii << 1] = (srcdat[ii << 1] & 0x0f) >> 4;
465490 }
466-
491+ scrntype_t* aptr = alpha_buffer_16[offset_base << 1];
467492 for(int ii = 0; ii < 16; ii++) {
468493 data_cache_16[ii] = apalette_16[layer][srcdat1[ii]];
469494 }
470- if(upper_layer) {
471- // ToDo: For hadrdware that does not upport alpha blending(not RGBA32).
472- for(int ii = 0; ii < 16; i++) {
473- alpha_cache_16[ii] = (srcdat[ii] == 0) ? RGBA_COLOR(0, 0, 0, 0) : RGBA_COLOR(255, 255, 255, 255);
474- }
475- for(int ii = 0; ii < 16; i++) {
476- tmpdat[ii] = alpha_cache_16_byte[ii] * data_cache_16[ii];
477- }
478- } else {
479- // ToDo: For hadrdware that does not upport alpha blending(not RGBA32).
480- for(int ii = 0; ii < 16; i++) {
481- alpha_cache_16[ii] = (srcdat[ii] == 0) ? RGBA_COLOR(0,0,0,255) : RGBA_COLOR(255, 255, 255, 255);
482- }
483- for(int ii = 0; ii < 16; i++) {
484- tmpdat[ii] = alpha_cache_16_byte[ii] * data_cache_16[ii];
485- }
486- }
495+ // ToDo: For hadrdware that does not support alpha blending(not RGBA32).
487496 for(int ii = 0; ii < 16; ii++) {
488- pdst[ii] = tmpdat[ii];
497+ pdst[ii] = data_cache_16[ii];
489498 }
490499 pdst += 16;
491500 pp += 8;
501+ offset_base += 8;
492502 }
493- int mod_words = words - (nwords * 16);
494- uint8_t sdat1, sdat2;
495- scrntype_t c1, c2;
503+}
504+
505+void TOWNS_CRTC::render_line_16_not_boundary(int layer, scrntype_t *framebuffer, uint8_t *vramptr, uint32_t startaddr, uint32_t words)
506+{
507+ // Simplify render: Must set 32pixels
508+ uint32_t wordptr = 0;
509+ int ip;
510+ uint32_t src;
511+ uint32_t src1, src2;
512+ scrntype_t *pdst = framebuffer;
513+ uint8_t *pp = (uint8_t *)vramptr;
514+ if(framebuffer == NULL) return;
515+ if(vramptr == NULL) return;
516+
517+ uintptr_t offset_base = (uintptr_t)startaddr;
518+ uintptr_t base = ((layer == 0) ? 0x00000 : 0x40000);
519+ uintptr_t offset;
520+ // offet_base = (offset_base + [value_of_offset_register]) & mask.
521+ offset_base = (offet_base & 0x3ffff) + base;
522+ pp = &(pp[offset_base]);
496523
497- if(mod_words > 0) {
498- offset_base = (uintptr_t)startaddr;
499- // offet_base = (offset_base + [value_of_offset_register]) & mask.
500- offset_base = ((offet_base + nwords) & 0x3ffff) + base;
501- if(dirty_flag[offset_base >> 3]) {
502- dirty_flag[offset_base >> 3] = false;
503- for(int ii = 0; ii < mod_words; i++) {
504- if((ii & 1) == 0) {
505- sdat1 = *pp;
506- sdat2 = sdat1 & 0x0f;
507- sdat1 = (sdat1 & 0xf0) >> 4;
508- if(upper_layer) {
509- c1 = (sdat1 == 0) ? RGBA_COLOR(0, 0, 0, 0) : RGBA_COLOR(255, 255, 255, 255);
510- c2 = (sdat2 == 0) ? RGBA_COLOR(0, 0, 0, 0) : RGBA_COLOR(255, 255, 255, 255);
511- } else {
512- c1 = (sdat1 == 0) ? RGBA_COLOR(0, 0, 0, 255) : RGBA_COLOR(255, 255, 255, 255);
513- c2 = (sdat2 == 0) ? RGBA_COLOR(0, 0, 0, 255) : RGBA_COLOR(255, 255, 255, 255);
514- }
515- }
516- if((ii & 1) == 0) {
517- tmpdat[ii] = c1 * apalette_16_pixel[layer][sdat1];
518- } else {
519- tmpdat[ii] = c2 * apalette_16_pixel[layer][sdat2];
520- }
521- pp++;
522- }
523- for(int ii = 0; ii < mod_words; i++) {
524- pdst[ii] = tmpdat[ii];
525- }
524+ if(check_dirty_and_calc_alpha(offset_base)) {
525+ //dirty_flag[(offset_base >> 3)] = false; // OK?
526+ for(ip = 0; ip < words; ip++) {
527+ uint8_t sdat = pp[ip];
528+ scrntype_t pdat = apalette_16[layer][sdat];
529+ pdst[ii] = pdat;
526530 }
527531 }
528532 }
529533
530-void TOWNS_CRTC::render_line_256(int layer, bool upper_layer, scrntype_t *framebuffer, uint8_t *vramptr, uint32_t startaddr, uint32_t words)
534+void TOWNS_CRTC::render_line_256_boundary(int layer, scrntype_t *framebuffer, uint8_t *vramptr, uint32_t startaddr, uint32_t words)
531535 {
532536 uint32_t wordptr = 0;
533537 int nwords = (int)words / 8;
534538 int ip;
535- __DECL_ALIGNED(8) uint32_t src[2];
536- __DECL_ALIGNED(8) uint8_t srcdat[8];
537- scrntype_t *pdst = __builtin_assume_aligned(framebuffer, sizeof(scrntype_t) * 4);
538- uint32_t *pp = (uint32_t *)vramptr;
539+ __DECL_ALIGNED(16) uint8_t src[8];
540+ scrntype_t *pdst = __builtin_assume_aligned(framebuffer, sizeof(scrntype_t));
541+ uint8_t *pp = (uint8_t *)vramptr;
539542
540543 if(framebuffer == NULL) return;
541544 if(vramptr == NULL) return;
@@ -547,67 +550,61 @@ void TOWNS_CRTC::render_line_256(int layer, bool upper_layer, scrntype_t *frameb
547550 pp = &(pp[offset_base >> 2]);
548551
549552 for(ip = 0; ip < nwords; ip++) {
550- if(dirty_flag[offset_base >> 3]) {
551- src[0] = pp[0];
552- src[1] = pp[1];
553-#if defined(__LITTLE_ENDIAN__)
554- srcdat[0] = (uint8_t)((src[0] & 0xff000000) >> 24);
555- srcdat[1] = (uint8_t)((src[0] & 0x00ff0000) >> 16);
556- srcdat[2] = (uint8_t)((src[0] & 0x0000ff00) >> 8);
557- srcdat[3] = (uint8_t) (src[0] & 0x000000ff);
558-
559- srcdat[4] = (uint8_t)((src[1] & 0xff000000) >> 24);
560- srcdat[5] = (uint8_t)((src[1] & 0x00ff0000) >> 16);
561- srcdat[6] = (uint8_t)((src[1] & 0x0000ff00) >> 8);
562- srcdat[7] = (uint8_t) (src[1] & 0x000000ff);
563-#else
564- srcdat[0] = (uint8_t)( src[0] & 0x000000ff);
565- srcdat[1] = (uint8_t)((src[0] & 0x0000ff00) >> 8);
566- srcdat[2] = (uint8_t)((src[0] & 0x00ff0000) >> 16);
567- srcdat[3] = (uint8_t)((src[0] & 0xff000000) >> 24);
568-
569- srcdat[4] = (uint8_t)( src[1] & 0x000000ff);
570- srcdat[5] = (uint8_t)((src[1] & 0x0000ff00) >> 8);
571- srcdat[6] = (uint8_t)((src[1] & 0x00ff0000) >> 16);
572- srcdat[7] = (uint8_t)((src[1] & 0xff000000) >> 24);
573-#endif
553+ if(check_dirty_and_calc_alpha(offset_base)) {
554+ dirty_flag[offset_base >> 3] = false;
555+ for(int i = 0; i < 8; i++) {
556+ src[i] = pp[i];
557+ }
574558 // ToDo: Super Impose.
575559 for(int i = 0; i < 8; i++) {
576- pdst[i] = apalette_256_pixel[srcdat[i]];
560+ pdst[i] = apalette_256_pixel[src[i]];
577561 }
578562 }
579- pp += 2;
563+ offset_base += 8;
564+ pp += 8;
580565 pdst += 8;
581566 }
582- int mod_words = words - (nwords * 4);
583- if(mod_words > 0) {
584- uint8_t src8;
585- uint8_t *p8 = (uint8_t *)(&pp[ip]);
586- for(int i = 0; i < mod_words; i++) {
587- src8 = p8[i];
567+}
568+
569+void TOWNS_CRTC::render_line_256_not_boundary(int layer, scrntype_t *framebuffer, uint8_t *vramptr, uint32_t startaddr, uint32_t words)
570+{
571+ uint32_t wordptr = 0;
572+ int nwords = (int)words / 8;
573+ int ip;
574+ uint8_t *pp = (uint8_t *)vramptr;
575+ uint8_t src;
576+ if(framebuffer == NULL) return;
577+ if(vramptr == NULL) return;
578+
579+ uintptr_t offset_base = (uintptr_t)startaddr;
580+ uintptr_t base = ((layer == 0) ? 0x00000 : 0x40000);
581+ // offet_base = (offset_base + [value_of_offset_register]) & mask.
582+ offset_base = (offet_base & 0x3ffff) + base;
583+ pp = &(pp[offset_base >> 2]);
584+
585+ for(ip = 0; ip < nwords; ip++) {
586+ if(check_dirty_and_calc_alpha(offset_base + ip)) {
587+ // Keep dirty?
588+ src = pp[ip];
588589 // ToDo: Super Impose.
589- pdst[i] = apalette_256_pixel[src8];
590+ pdst[ip] = apalette_256_pixel[src];
590591 }
591592 }
592593 }
593594
595+
594596 // To be used table??
595-void TOWNS_CRTC::render_line_32768(int layer, bool do_impose, scrntype_t *pixcache, uint16_t *vramptr, uint32_t words)
597+void TOWNS_CRTC::render_line_32768_boundary(int layer, scrntype_t *pixcache, uint16_t *vramptr, uint32_t words)
596598 {
597599 uint32_t wordptr = 0;
598- int nwords = (int)words / 8;
600+ int nwords = (int)words / 4;
599601 int ip;
600602 uint16_t src16;
601603 scrntype_t *pdst = pixcache;
602604 uint16_t *pp = (uint16_t *)vramptr;
603605 uint16_t *cachep = (uint16_t *)srcdat;
604- __DECL_ALIGNED(16) pair16_t rgb[8];
605- __DECL_ALIGNED(8) uint8_t a[8];
606- __DECL_ALIGNED(8) uint8_t r[8];
607- __DECL_ALIGNED(8) uint8_t g[8];
608- __DECL_ALIGNED(8) uint8_t b[8];
609- __DECL_ALIGNED(sizeof(scrntype_t) * 8) scrntype_t dcache[8];
610-
606+ __DECL_ALIGNED(16) uint16_t rgb[4];
607+ __DECL_ALIGNED(sizeof(scrntype_t) * 4) scrntype_t dcache[4];
611608 int i = 0;
612609
613610 if(framebuffer == NULL) return;
@@ -618,67 +615,159 @@ void TOWNS_CRTC::render_line_32768(int layer, bool do_impose, scrntype_t *pixcac
618615 // offet_base = (offset_base + [value_of_offset_register]) & mask.
619616 offset_base = (offet_base & 0x3ffff) + base;
620617 pp = &(pp[offset_base >> 1]);
618+
621619 for(ip = 0; ip < nwords; ip++) {
622- if(dirty_flag[offset_base >> 3]) {
623- dirty_flags[offset_base >> 3] = false;
624- for(int i = 0; i < 8; i++) {
625- rgb[i].w = pp[i];
620+ if(check_dirty_and_calc_alpha(offset_base)) {
621+ dirty_flag[(offset_base >> 3)] = false;
622+ for(int i = 0; i < 4; i++) {
623+ rgb[i] = pp[i];
626624 }
627- for(int i = 0; i < 8; i++) {
628- dcache[i] = _CLEAR_COLOR;
625+ for(int ii = 0; ii < 4; ii++) {
626+ dcache[ii] = table_32768c[rgb[ii]];
629627 }
630-
631- for(int ii = 0; ii < 8; ii++) {
632- //g5r5b5
633- g[ii] = rgb[ii].b.h & 0x7c;
634- b[ii] = rgb[ii].b.l & 0x1f;
628+ for(int ii = 0; ii < 4; ii++) {
629+ pdst[ii] = dcache[ii];
635630 }
636- for(int ii = 0; ii < 8; ii++) {
637- //g5r5b5
638- b[ii] = b[ii] << 3;
631+ }
632+ offset_base += 8;
633+ pdst += 4;
634+ pp += 4;
635+ }
636+}
637+
638+void TOWNS_CRTC::render_line_32768_not_boundary(int layer, scrntype_t *pixcache, uint16_t *vramptr, uint32_t words)
639+{
640+ uint32_t wordptr = 0;
641+ int nwords = (int)words / 4;
642+ int ip;
643+ uint16_t src16;
644+ scrntype_t *pdst = pixcache;
645+ uint16_t *pp = (uint16_t *)vramptr;
646+ uint16_t *cachep = (uint16_t *)srcdat;
647+ int i = 0;
648+
649+ if(framebuffer == NULL) return;
650+ if(vramptr == NULL) return;
651+
652+ uintptr_t offset_base = (uintptr_t)startaddr;
653+ uintptr_t base = ((layer == 0) ? 0x00000 : 0x40000);
654+ // offet_base = (offset_base + [value_of_offset_register]) & mask.
655+ offset_base = (offet_base & 0x3ffff) + base;
656+ pp = &(pp[offset_base >> 1]);
657+
658+ for(ip = 0; ip < words; ip++) {
659+ if(check_dirty_and_calc_alpha(offset_base)) {
660+ // Keep dirty?
661+ pdst[ip] = table_32768c[pp[ip]];
662+ }
663+ offset_base++;
664+ }
665+}
666+// ToDo: Super impose.
667+void TOWNS_CRTC::mix_layers(scrntype* dst, scrntype_t* upper, scrntype_t *upper_alpha, scrntype_t* lower, int width)
668+{
669+ scrntype_t* src1 = upper;
670+ scrntype_t* src2 = lower;
671+
672+ __DECL_ALIGNED(sizeof(scrntype_t) * 8) scrntype_t dcache1[8];
673+ __DECL_ALIGNED(sizeof(scrntype_t) * 8) scrntype_t dcache2[8];
674+ __DECL_ALIGNED(sizeof(scrntype_t) * 8) scrntype_t dcache3[8];
675+ __DECL_ALIGNED(sizeof(scrntype_t) * 8) scrntype_t acache1[8];
676+ __DECL_ALIGNED(sizeof(scrntype_t) * 8) scrntype_t acache2[8];
677+ if(src1 == NULL) {
678+ if(src2 == NULL) {
679+ for(int i = 0; i < width; i++) {
680+ dst[i] = RGBA_COLOR(0, 0, 0, 255);
681+ }
682+ } else {
683+ // Upper don't display, lower displayed.
684+ int iwidth = width / 8;
685+ for(int i = 0; i < iwidth; i++) {
686+ for(int ii = 0; ii < 8; ii++) {
687+ dcache2[ii] = src2[ii];
688+ }
689+ for(int ii = 0; ii < 8; ii++) {
690+ dst[ii] = dcache2[ii];
691+ }
692+ src2 += 8;
693+ dst += 8;
639694 }
640- for(int ii = 0; ii < 8; ii++) {
641- r[ii] = ((rgb[ii].b.h & 0x03) << 6) | ((rgb[ii].b.l & 0xe0) >> 2);
695+ width = width - (iwidth * 8);
696+ if(width > 0) {
697+ for(int i = 0; i < width; i++) {
698+ sdt[i] = src2[i];
699+ }
642700 }
643- if(do_impose) {
701+ }
702+ } else {
703+ if(src2 == NULL) { // upper only
704+ int iwidth = width / 8;
705+ for(int i = 0; i < iwidth; i++) {
644706 for(int ii = 0; ii < 8; ii++) {
645- a[ii] = (rgb[ii].h < 0x80) ? 0xff : 0x00;
707+ dcache1[ii] = src1[ii];
646708 }
647- } else {
648709 for(int ii = 0; ii < 8; ii++) {
649- a[ii] = 0xff;
710+ dst[ii] = dcache1[ii];
650711 }
712+ src1 += 8;
713+ dst += 8;
651714 }
652- for(int ii = 0; ii < 8; ii++) {
653- dcache[ii] = RGBA_COLOR(r[ii], g[ii], b[ii], a[ii]);
715+ width = width - (iwidth * 8);
716+ if(width > 0) {
717+ for(int i = 0; i < width; i++) {
718+ sdt[i] = src2[i];
719+ }
654720 }
655- for(int ii = 0; ii < 8; ii++) {
656- pdst[ii] = dcache[ii];
721+ } else { // Both lives
722+ if(upper_alpha == NULL) {
723+ for(int i = 0; i < 8; i++) {
724+ acache1[i] = RGBA_COLOR(255, 255, 255, 255);
725+ }
726+ }
727+ int iwidth = width / 8;
728+ for(int i = 0; i < iwidth; i++) {
729+ if(upper_alpha != NULL) {
730+ for(int ii = 0; ii < 8; i++) {
731+ acache1[ii] = upper_alpha[ii];
732+ }
733+ upper_alpha += 8;
734+ }
735+ for(int ii = 0; ii < 8; i++) {
736+ acache2[ii] = ~acache1[ii];
737+ }
738+ for(int ii = 0; ii < 8; ii++) {
739+ dcache1[ii] = src1[ii];
740+ dcache2[ii] = src2[ii];
741+ }
742+ for(int ii = 0; ii < 8; ii++) {
743+ dcache2[ii] = dcache2[ii] * acache1[ii]; // Mask Upper
744+ //dcache3[ii] = (dcache2[ii] == RGBA_COLOR(0, 0, 0, 0)) ? dcache1[ii] : dcache2[ii];
745+ dcache1[ii] = dcache1[ii] * acache2[ii]; // Mask Lower.
746+ dcache3[ii] = dcache1[ii] | dcache2[ii];
747+ }
748+ for(int ii = 0; ii < 8; ii++) {
749+ dst[ii] = dcache3[ii];
750+ }
751+ src1 += 8;
752+ src2 += 8;
753+ dst += 8;
754+ }
755+ width = width - (iwidth * 8) ;
756+ scrntype_t d1, d2, a1, a2;
757+ for(int i = 0; i < width; i++) {
758+ if(upper_alpha != NULL) {
759+ a1 = upper_alpha[i];
760+ } else {
761+ a1 = RGBA_COLOR(255, 255, 255, 255);
762+ }
763+ a2 = ~a1;
764+ d1 = src1[i];
765+ d2 = src2[i];
766+ d2 = d2 * a1;
767+ d1 = d1 * a2;
768+ dst[i] = d1 | d2;
657769 }
658770 }
659- offset_base += 8;
660- pdst += 8;
661- pp += 16;
662- }
663- for(int i = 0; i < 8; i++) {
664- dcache[i] = _CLEAR_COLOR;
665- }
666- int mod_words = words - nwords * 8;
667- for(ip = 0; ip < mod_words; ip++) {
668- rgb[ip].w = pp[ip];
669- //g5r5b5
670- g[ip] = rgb[ip].b.h & 0x7c;
671- r[ip] = ((rgb[ip].b.h & 0x03) << 6) | ((rgb[ip].b.l & 0xe0) >> 2);
672- b[ip] = (rgb[ip].b.l & 0x1f) << 3;
673- if(do_impose) {
674- a[ip] = (rgb[ip].b.h < 0x80) ? 0xff : 0x00;
675- } else {
676- a[i] = 0xff;
677- }
678- dcache[ip] = RGBA_COLOR(r[ip], g[ip], b[ip], a[ip]);
679- }
680- for(ip = 0; ip < mod_words; ip++) {
681- pdst[ip] = dcache[ip];
682771 }
683772 }
684773
@@ -809,6 +898,29 @@ __exit_0:
809898 return;
810899 }
811900
901+void TOWNS_VRAM::draw_screen()
902+{
903+ // Note: This renderer will contain three types (at least:)
904+ // 1. Software Zoom, Hardware stack (Using GPU for stack, Using CPU for zoom)
905+ // 2. Softare Zoom, Software stack (Using only host-CPU).
906+ // 3. Hardware Zoom, Hardware stack (Using GPU and compute shader?).
907+ // To implement 1., Zooming all screen don't wish to use CPU, per raster Zooming wish to use GPU.
908+ // At first, will implement 2.As of CSP platform implement only single frame buffer area.
909+ //
910+ // Answer values(excepts 2.):
911+ // Note: Upper layer = layer1, lower layer = layer2.
912+ // a. Pixel Layers of 1/2.
913+ // b. Alpha Layers of 1.
914+ // c. Layer using flags both layer1, layer2.
915+ // d. Data of Layers (1/2).
916+ // e. Source screen width and height per layer.
917+ // f. Offset sourcfe-pixel-address per raster.
918+ // g. Source raster width per layer and scanline.
919+ // h. Offset dst-pixel-position in raster per layer.
920+ // - 20190110 K.Ohta.
921+}
922+
923+
812924 }
813925 #undef _CLEAR_COLOR
814926
--- a/source/src/vm/fmtowns/towns_vram.h
+++ b/source/src/vm/fmtowns/towns_vram.h
@@ -49,7 +49,12 @@ protected:
4949 uint32_t vram_size[2]; // Layer [01] size [bytes].
5050 uint32_t vram_offset[2]; // Layer [01] address offset.
5151
52- scrntype_t table_32768c[65536];
52+ __DECL_ALIGNED(sizeof(scrntype_t) * 4) scrntype_t table_32768c[65536];
53+ __DECL_ALIGNED(sizeof(scrntype_t) * 4) scrntype_t alpha_32768c[65536];
54+ __DECL_ALIGNED(sizeof(uint16_t) * 8) uint16_t mask_32768c[65536];
55+
56+ __DECL_ALIGNED(sizeof(scrntype_t) * 4) scrntype_t alpha_16c[8 * 8 * 2];
57+ __DECL_ALIGNED(sizeof(uint16_t) * 8) uint16_t mask_16c[8 * 8];
5358
5459 uint32_t layer_virtual_width[2];
5560 uint32_t layer_virtual_height[2];
@@ -63,17 +68,14 @@ protected:
6368
6469 bool dirty_flag[0x80000 >> 3]; // Per 8bytes : 16pixels(16colors) / 8pixels(256) / 4pixels(32768)
6570
66-#if 0
67- // WIP: Still not use mask rendering.
68- uint16_t mask_32768_word[0x80000 >> 1];
69- uint16_t alpha_32768_word[0x80000 >> 1];
70- uint8_t alpha_32768_byte[0x80000 >> 1];
71-
72- uint16_t mask_16_word[0x80000 << 1];
73- uint16_t alpha_16_word[0x80000 << 1];
74- uint8_t alpha_16_byte[0x80000 << 1];
71+ scrntype_t alpha_buffer_32768[0x80000 >> 1];
72+ scrntype_t alpha_buffer_16[0x80000 << 1];
7573
76-#endif
74+ uint16_t mask_buffer_32768[0x80000 >> 1];
75+ uint16_t mask_buffer_32768_neg[0x80000 >> 1];
76+ uint8_t mask_buffer_16[0x80000];
77+ uint8_t mask_buffer_16_neg[0x80000];
78+
7779
7880 uint16_t vram[0x80000 / 2]; // Related by machine.
7981
Show on old repository browser