mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-29 09:05:41 +00:00
Removed unused dirty rectangle code.
This commit is contained in:
parent
e00a372cef
commit
c38ec7d5af
|
@ -453,161 +453,6 @@ void CRender2D::DrawCompleteLayer(int layerNum, const UINT16 *nameTableBase)
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 496, 384, GL_RGBA, GL_UNSIGNED_BYTE, surf);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 496, 384, GL_RGBA, GL_UNSIGNED_BYTE, surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DrawRect():
|
|
||||||
*
|
|
||||||
* Draws a rectangular portion of the given layer and uploads it. Scrolling is
|
|
||||||
* applied but the result must be clipped against the rectangular window
|
|
||||||
* defined here by tileX, tileY, tileW, and tileH.
|
|
||||||
*
|
|
||||||
* Clipping for the right side is not checked, which will always work as long
|
|
||||||
* as the X and Y tile positions never exceed 61 and 47, respectively (the
|
|
||||||
* dimensions of the physical display; there is border space because the
|
|
||||||
* layers are 64x64).
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* layerNum Layer number (0 or 1).
|
|
||||||
* nameTableBase Pointer to the layer's name table.
|
|
||||||
* tileX Position of upper-left corner of rectangle on the
|
|
||||||
* screen, in units of 8-pixel tiles (0-61).
|
|
||||||
* tileY "" (0-47)
|
|
||||||
* tileW Width of rectangular region in tiles.
|
|
||||||
* tileH "" (height)
|
|
||||||
*/
|
|
||||||
void CRender2D::DrawRect(int layerNum, const UINT16 *nameTableBase, int tileX, int tileY, int tileW, int tileH)
|
|
||||||
{
|
|
||||||
UINT32 *dest = surf; // destination surface to write to
|
|
||||||
const UINT16 *maskTable; // pointer to start of mask table
|
|
||||||
const UINT16 *hScrollTablePri, *hScrollTableAlt; // pointers to line scroll tables
|
|
||||||
const UINT16 *nameTablePri = nameTableBase; // primary (this layer) name table
|
|
||||||
const UINT16 *nameTableAlt = &nameTableBase[64*64]; // alternate layer's name table
|
|
||||||
const UINT16 *nameTable;
|
|
||||||
int colorDepthPri, colorDepthAlt; // primary and alternate layer color depths
|
|
||||||
int hScrollPri, hScrollAlt; // primary and alternate layer scroll offsets
|
|
||||||
int vScrollPri, vScrollAlt;
|
|
||||||
int hFullScrollPri, hFullScrollAlt; // full-screen horizontal scroll values (from registers)
|
|
||||||
int hOffset, vOffset; // pixel offsets
|
|
||||||
int ntOffset; // offset in name table
|
|
||||||
int tx;
|
|
||||||
bool lineScrollPri, lineScrollAlt; // line scrolling enable/disable
|
|
||||||
UINT16 mask;
|
|
||||||
|
|
||||||
// Determine layer color depths (1 if 4-bit, 0 if 8-bit)
|
|
||||||
colorDepthPri = regs[0x20/4] & (1<<(12+layerNum*2));
|
|
||||||
colorDepthAlt = regs[0x20/4] & (1<<(12+layerNum*2+1));
|
|
||||||
|
|
||||||
// Line scroll tables
|
|
||||||
hScrollTablePri = (UINT16 *) &vram[(0xF6000+layerNum*2*0x400)/4];
|
|
||||||
hScrollTableAlt = (UINT16 *) &vram[(0xF6000+layerNum*2*0x400+0x400)/4];
|
|
||||||
|
|
||||||
// Get correct offset into mask table
|
|
||||||
maskTable = (UINT16 *) &vram[0xF7000/4];
|
|
||||||
if (layerNum == 0)
|
|
||||||
++maskTable; // little endian, layer 0 is second word in each pair
|
|
||||||
|
|
||||||
// Load horizontal full-screen scroll values and scroll mode
|
|
||||||
hFullScrollPri = regs[0x60/4+layerNum*2]&0x3FF;
|
|
||||||
hFullScrollAlt = regs[0x60/4+layerNum*2+1]&0x3FF;
|
|
||||||
lineScrollPri = regs[0x60/4+layerNum*2]&0x8000;
|
|
||||||
lineScrollAlt = regs[0x60/4+layerNum*2+1]&0x8000;
|
|
||||||
|
|
||||||
// Load vertical scroll values
|
|
||||||
vScrollPri = (regs[0x60/4+layerNum*2]>>16)&0x3FF;
|
|
||||||
vScrollAlt = (regs[0x60/4+layerNum*2+1]>>16)&0x3FF;
|
|
||||||
|
|
||||||
// Iterate over actual line on screen
|
|
||||||
for (int y = tileY*8; y < (tileY+tileH)*8; y++)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Load horizontal scroll values
|
|
||||||
if (lineScrollPri)
|
|
||||||
hScrollPri = hScrollTablePri[y];
|
|
||||||
else
|
|
||||||
hScrollPri = hFullScrollPri;
|
|
||||||
if (lineScrollAlt)
|
|
||||||
hScrollAlt = hScrollTableAlt[y];
|
|
||||||
else
|
|
||||||
hScrollAlt = hFullScrollAlt;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draw all tiles from primary layer first
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Compute scroll offsets into name table and destination
|
|
||||||
hOffset = -(hScrollPri&7);
|
|
||||||
vOffset = (y+vScrollPri)&7;
|
|
||||||
ntOffset = tileX+hScrollPri/8;
|
|
||||||
|
|
||||||
// Advance name table to our line (prior to h-scrolling)
|
|
||||||
nameTable = &nameTablePri[64*((y+vScrollPri)/8) & 0xFFF]; // clamp to 64x64=0x1000
|
|
||||||
|
|
||||||
// Each bit in the mask table corresponds to 4 tiles
|
|
||||||
mask = maskTable[y*2];
|
|
||||||
|
|
||||||
// Render a line!
|
|
||||||
//TODO: add one if scrolling
|
|
||||||
for (tx = 0; tx < tileW; tx++)
|
|
||||||
{
|
|
||||||
if ( ((mask<<((tileX+tx)/4)) & 0x8000) )
|
|
||||||
{
|
|
||||||
if (colorDepthPri)
|
|
||||||
DrawTileLine4Bit(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset); // make sure ^1 belongs inside parenthesis...
|
|
||||||
else
|
|
||||||
DrawTileLine8Bit(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset);
|
|
||||||
}
|
|
||||||
hOffset += 8;
|
|
||||||
ntOffset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When scrolling, extra tile must be rendered at right edge of region
|
|
||||||
if ( ((mask<<((tileX+tx)/4)) & 0x8000) ) // re-use the last mask bit (mask doesn't scroll)
|
|
||||||
{
|
|
||||||
if (colorDepthPri)
|
|
||||||
DrawTileLine4BitRightClip(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset, hScrollPri&7);
|
|
||||||
else
|
|
||||||
DrawTileLine8BitRightClip(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset, hScrollPri&7);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draw the alternate layer wherever the primary layer was masked
|
|
||||||
*/
|
|
||||||
|
|
||||||
hOffset = -(hScrollAlt&7);
|
|
||||||
vOffset = (y+vScrollAlt)&7;
|
|
||||||
ntOffset = tileX+hScrollAlt/8;
|
|
||||||
nameTable = &nameTableAlt[64*((y+vScrollAlt)/8)];
|
|
||||||
mask = maskTable[y*2];
|
|
||||||
for (tx = 0; tx < tileW; tx++)
|
|
||||||
{
|
|
||||||
if (0 == ((mask<<((tileX+tx)/4)) & 0x8000))
|
|
||||||
{
|
|
||||||
if (colorDepthAlt)
|
|
||||||
DrawTileLine4Bit(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset);
|
|
||||||
else
|
|
||||||
DrawTileLine8Bit(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset);
|
|
||||||
}
|
|
||||||
hOffset += 8;
|
|
||||||
ntOffset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When scrolling, extra tile must be rendered at right edge of region
|
|
||||||
if (0 == ((mask<<((tileX+tx)/4)) & 0x8000)) // re-use the last mask bit (mask doesn't scroll)
|
|
||||||
{
|
|
||||||
if (colorDepthAlt)
|
|
||||||
DrawTileLine4BitRightClip(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset, hScrollAlt&7);
|
|
||||||
else
|
|
||||||
DrawTileLine8BitRightClip(dest, hOffset, nameTable[(ntOffset^1)&63], vOffset, hScrollAlt&7);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next line
|
|
||||||
dest += tileW*8; // image surface is only as wide as the rectangle we're updating
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upload
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, tileX*8, tileY*8, tileW*8, tileH*8, GL_RGBA, GL_UNSIGNED_BYTE, surf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updates any changed portions of a layer
|
// Updates any changed portions of a layer
|
||||||
void CRender2D::UpdateLayer(int layerNum)
|
void CRender2D::UpdateLayer(int layerNum)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue