+ switch((sprite_table[num].rotate) & 7) {
+ case 0:
+ rot_type = ROT_FMTOWNS_SPRITE_0;
+ is_mirror = false;
+ break;
+ case 1:
+ rot_type = ROT_FMTOWNS_SPRITE_180;
+ is_mirror = true;
+ break;
+ case 2:
+ rot_type = ROT_FMTOWNS_SPRITE_180;
+ is_mirror = false;
+ break;
+ case 3:
+ rot_type = ROT_FMTOWNS_SPRITE_0;
+ is_mirror = true;
+ break;
+ case 4:
+ rot_type = ROT_FMTOWNS_SPRITE_270;
+ is_mirror = true;
+ break;
+ case 5:
+ rot_type = ROT_FMTOWNS_SPRITE_90;
+ is_mirror = false;
+ break;
+ case 6:
+ rotate = false;
+ rot_type = ROT_FMTOWNS_SPRITE_270;
+ is_mirror = false;
+ break;
+ case 7:
+ rot_type = ROT_FMTOWNS_SPRITE_90;
+ is_mirror = true;
+ break;
+ }
+ uint32_t index_num = cache_index[target_num].attribute & 0x3ff;
+ if(index_num < 128) return;
+
+ uint8_t* src = &(pattern_ram[index_num << 7]);
+ bool is_32768 = cache_index[target_num].is_32768;
+ bool is_halfx = cache_index[target_num].is_halfx;
+ bool is_halfy = cache_index[target_num].is_halfy;
+
+ switch(rot_type) {
+ case ROT_FMTOWNS_SPRITE_00:
+ rot_data_0(src, is_mirror, cache_index[target_num].pixels, cache_index[target_num].masks, is_32768, is_halfx, is_halfy);
+ break;
+ case ROT_FMTOWNS_SPRITE_90:
+ rot_data_0(src, is_mirror, cache_index[target_num].pixels, cache_index[target_num].masks, is_32768, is_halfx, is_halfy);
+ break;
+ case ROT_FMTOWNS_SPRITE_180:
+ rot_data_0(src, is_mirror, cache_index[target_num].pixels, cache_index[target_num].masks, is_32768, is_halfx, is_halfy);
+ break;
+ case ROT_FMTOWNS_SPRITE_270:
+ rot_data_0(src, is_mirror, cache_index[target_num].pixels, cache_index[target_num].masks, is_32768, is_halfx, is_halfy);
+ break;
+ }
+ // ToDo: wrap round.This is still bogus implement.
+ // ToDo: Separate writing buffer and integrate cache.
+ // copy cache to buffer
+ uint16_t* pp = cache_index[target_num].pixels;
+ uint16_t* pq = cache_index[target_num].masks;
+ uint16_t* pd = dst_pixel;
+ if(is_halfx) {
+ uint16_t cacheline[8];
+ uint16_t mcacheline[8];
+ uint16_t pcacheline[8];
+ int ysize = 16;
+ if(is_halfy) {
+ ysize = 8;
+ }
+ for(int y = 0; y < ysize; y++) {
+__DECL_VECTORIZED_LOOP
+ for(int x = 0; x < 8; x++) {
+ cacheline[x] = pp[x];
+ mcacheline[x] = pq[x];
+ }
+__DECL_VECTORIZED_LOOP
+ for(int x = 0; x < 8; x++) {
+ pcacheline[x] = pd[x] & mcacheline[x];
+ mcacheline[x] = ~mcacheline[x];
+ cacheline[x] = cacheline[x] & mcacheline[x];
+ }
+__DECL_VECTORIZED_LOOP
+ for(int x = 0; x < 8; x++) {
+ pd[x] = pcacheline[x] | mcacheline[x];
+ }
+ pd = pd + stride;
+ pp += 8;
+ pq += 8;
+ }
+ } else { // Not halfx
+ uint16_t cacheline[16];
+ uint16_t mcacheline[16];
+ uint16_t pcacheline[16];
+ int ysize = 16;
+ if(is_halfy) {
+ ysize = 8;
+ }
+ for(int y = 0; y < ysize; y++) {
+__DECL_VECTORIZED_LOOP
+ for(int x = 0; x < 16; x++) {
+ cacheline[x] = pp[x];
+ mcacheline[x] = pq[x];
+ }
+__DECL_VECTORIZED_LOOP
+ for(int x = 0; x < 16; x++) {
+ pcacheline[x] = pd[x] & mcacheline[x];
+ mcacheline[x] = ~mcacheline[x];
+ cacheline[x] = cacheline[x] & mcacheline[x];
+ }
+__DECL_VECTORIZED_LOOP
+ for(int x = 0; x < 16; x++) {
+ pd[x] = pcacheline[x] | mcacheline[x];
+ }
+ pd = pd + stride;
+ pp += 8;
+ pq += 8;
+ }
+ }