no message
This commit is contained in:
		
							
								
								
									
										50
									
								
								src/tic.c
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								src/tic.c
									
									
									
									
									
								
							@@ -1664,7 +1664,6 @@ static inline void memset4(void *dst, u32 val, u32 dwords)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void api_blit(tic_mem* tic, tic_scanline scanline, tic_overlap overlap)
 | 
					static void api_blit(tic_mem* tic, tic_scanline scanline, tic_overlap overlap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32* out = tic->screen;
 | 
					 | 
				
			||||||
	const u32* pal = tic_palette_blit(&tic->ram.vram.palette);
 | 
						const u32* pal = tic_palette_blit(&tic->ram.vram.palette);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(scanline)
 | 
						if(scanline)
 | 
				
			||||||
@@ -1676,6 +1675,8 @@ static void api_blit(tic_mem* tic, tic_scanline scanline, tic_overlap overlap)
 | 
				
			|||||||
	enum {Top = (TIC80_FULLHEIGHT-TIC80_HEIGHT)/2, Bottom = Top};
 | 
						enum {Top = (TIC80_FULLHEIGHT-TIC80_HEIGHT)/2, Bottom = Top};
 | 
				
			||||||
	enum {Left = (TIC80_FULLWIDTH-TIC80_WIDTH)/2, Right = Left};
 | 
						enum {Left = (TIC80_FULLWIDTH-TIC80_WIDTH)/2, Right = Left};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						u32* out = tic->screen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset4(&out[0 * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH*Top);
 | 
						memset4(&out[0 * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH*Top);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	u32* rowPtr = out + Top*TIC80_FULLWIDTH;
 | 
						u32* rowPtr = out + Top*TIC80_FULLWIDTH;
 | 
				
			||||||
@@ -1683,51 +1684,16 @@ static void api_blit(tic_mem* tic, tic_scanline scanline, tic_overlap overlap)
 | 
				
			|||||||
	for(s32 r = 0, y = tic->ram.vram.vars.offset.y; r < TIC80_HEIGHT; r++, y++, rowPtr += TIC80_FULLWIDTH)
 | 
						for(s32 r = 0, y = tic->ram.vram.vars.offset.y; r < TIC80_HEIGHT; r++, y++, rowPtr += TIC80_FULLWIDTH)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		memset4(rowPtr, pal[tic->ram.vram.vars.border], Left);
 | 
							memset4(rowPtr, pal[tic->ram.vram.vars.border], Left);
 | 
				
			||||||
 | 
							memset4(rowPtr + Left, pal[tic->ram.vram.vars.bg], TIC80_WIDTH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							u32* colPtr = rowPtr + Left;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(y >= 0 && y < TIC80_HEIGHT)
 | 
							if(y >= 0 && y < TIC80_HEIGHT)
 | 
				
			||||||
		{
 | 
								for(s32 c = 0, x = (tic->ram.vram.vars.offset.x + TIC80_WIDTH) % TIC80_WIDTH, pos = y * TIC80_WIDTH; c < TIC80_WIDTH; c++, colPtr++, x++)
 | 
				
			||||||
			u32* colPtr = rowPtr + Left;
 | 
					 | 
				
			||||||
			s32 offset = tic->ram.vram.vars.offset.x;
 | 
					 | 
				
			||||||
			s32 count = TIC80_WIDTH;
 | 
					 | 
				
			||||||
			s32 index = y * TIC80_WIDTH;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (offset > 0) 
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				memset4(rowPtr + Left, pal[tic->ram.vram.vars.bg], offset);
 | 
									if(x >= TIC80_WIDTH) x %= TIC80_WIDTH;
 | 
				
			||||||
				count -= offset;
 | 
									*colPtr = pal[tic_tool_peek4(tic->ram.vram.screen.data, pos + x)];
 | 
				
			||||||
				colPtr += offset;
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else 
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				count += offset;
 | 
					 | 
				
			||||||
				index -= offset;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			// copy the first pixel if the line is not alligned to bytes.
 | 
					 | 
				
			||||||
			if (index & 1 && count > 0) 
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				*colPtr++ = pal[tic_tool_peek4(tic->ram.vram.screen.data, index)];
 | 
					 | 
				
			||||||
				index++;
 | 
					 | 
				
			||||||
				count--;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			for(s32 c = 0, di = index >> 1; c < count >> 1; c++)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				// copy two pixels in one cycle
 | 
					 | 
				
			||||||
				u8 val = tic->ram.vram.screen.data[di++];
 | 
					 | 
				
			||||||
				*colPtr++ = pal[val & 0xf];
 | 
					 | 
				
			||||||
				*colPtr++ = pal[val >> 4];
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			// copy the remaining pixel
 | 
					 | 
				
			||||||
			if (count & 1) *colPtr = pal[tic_tool_peek4(tic->ram.vram.screen.data, index + count/2*2)];
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (offset < 0) memset4(rowPtr + Left + TIC80_WIDTH + offset, pal[tic->ram.vram.vars.bg], -offset);
 | 
					 | 
				
			||||||
		} 
 | 
					 | 
				
			||||||
		else 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			memset4(rowPtr + Left, pal[tic->ram.vram.vars.bg], TIC80_WIDTH);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		memset4(rowPtr + (TIC80_FULLWIDTH-Right), pal[tic->ram.vram.vars.border], Right);
 | 
							memset4(rowPtr + (TIC80_FULLWIDTH-Right), pal[tic->ram.vram.vars.border], Right);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user