Fixed advmame2x scaler to work with new line mode
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1633
This commit is contained in:
parent
1f0493d050
commit
8a0520845e
3 changed files with 73 additions and 42 deletions
|
@ -33,6 +33,8 @@ bool RENDER_StartUpdate(void);
|
|||
void RENDER_EndUpdate(void);
|
||||
void RENDER_SetPal(Bit8u entry,Bit8u red,Bit8u green,Bit8u blue);
|
||||
extern RENDER_Line_Handler RENDER_DrawLine;
|
||||
extern Bit8u * RENDER_TempLine;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: render.cpp,v 1.24 2004-01-30 13:40:49 qbix79 Exp $ */
|
||||
/* $Id: render.cpp,v 1.25 2004-01-31 22:38:27 harekiet Exp $ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
@ -81,12 +81,7 @@ static struct {
|
|||
PalData pal;
|
||||
struct {
|
||||
Bit8u hlines[RENDER_MAXHEIGHT];
|
||||
Bit16u hindex[RENDER_MAXHEIGHT];
|
||||
} normal;
|
||||
struct {
|
||||
Bit16u hindex[RENDER_MAXHEIGHT];
|
||||
Bitu line_starts[RENDER_MAXHEIGHT][3];
|
||||
} advmame2x;
|
||||
#if (C_SSHOT)
|
||||
struct {
|
||||
RENDER_Operation type;
|
||||
|
@ -101,7 +96,9 @@ static struct {
|
|||
bool updating;
|
||||
} render;
|
||||
|
||||
Bit8u render_line_cache[4][RENDER_MAXWIDTH*4]; //Bit32u pixels
|
||||
RENDER_Line_Handler RENDER_DrawLine;
|
||||
Bit8u * RENDER_TempLine;
|
||||
|
||||
/* Forward declerations */
|
||||
static void RENDER_ResetPal(void);
|
||||
|
@ -279,10 +276,12 @@ bool RENDER_StartUpdate(void) {
|
|||
render.frameskip.count=0;
|
||||
if (render.src.bpp==8) Check_Palette();
|
||||
render.op.line=0;
|
||||
RENDER_TempLine=render_line_cache[0];
|
||||
switch (render.op.type) {
|
||||
case OP_None:
|
||||
case OP_Normal2x:
|
||||
case OP_AdvMame2x:
|
||||
am2x.cmd_index=am2x.cmd_data;
|
||||
if (!GFX_StartUpdate(render.op.pixels,render.op.pitch)) return false;
|
||||
RENDER_DrawLine=render.op.line_handler;;
|
||||
break;
|
||||
|
@ -338,16 +337,6 @@ void RENDER_EndUpdate(void) {
|
|||
render.updating=false;
|
||||
}
|
||||
|
||||
static void SetAdvMameTable(Bitu index,Bits src0,Bits src1,Bits src2) {
|
||||
if (src0<0) src0=0;
|
||||
if ((Bitu)src0>=render.src.height) src0=render.src.height-1;
|
||||
if ((Bitu)src1>=render.src.height) src1=render.src.height-1;
|
||||
if ((Bitu)src2>=render.src.height) src2=render.src.height-1;
|
||||
render.advmame2x.line_starts[index][0]=src0*render.src.pitch;
|
||||
render.advmame2x.line_starts[index][1]=src1*render.src.pitch;
|
||||
render.advmame2x.line_starts[index][2]=src2*render.src.pitch;
|
||||
}
|
||||
|
||||
void RENDER_ReInit(void) {
|
||||
if (render.updating) RENDER_EndUpdate();
|
||||
Bitu width=render.src.width;
|
||||
|
@ -382,7 +371,6 @@ normalop:
|
|||
gfx_scaleh*=scaleh;
|
||||
render.op.line_handler=Normal_8[index];
|
||||
for (Bitu i=0;i<render.src.height;i++) {
|
||||
render.normal.hindex[i]=i;
|
||||
render.normal.hlines[i]=0;
|
||||
}
|
||||
} else {
|
||||
|
@ -397,13 +385,12 @@ normalop:
|
|||
} else render.op.line_handler=Normal_8[index];
|
||||
width*=scalew;
|
||||
double lines=0.0;
|
||||
gfx_scaleh=(gfx_scaleh*render.src.height-(double)render.src.height)/(double)render.src.height;
|
||||
height=0;
|
||||
for (Bitu i=0;i<render.src.height;i++) {
|
||||
render.normal.hindex[i]=height++;
|
||||
lines+=gfx_scaleh;
|
||||
Bitu temp_lines=(Bitu)(lines);
|
||||
lines=lines+gfx_scaleh-temp_lines;
|
||||
render.normal.hlines[i]=temp_lines;
|
||||
lines-=temp_lines;
|
||||
render.normal.hlines[i]=(temp_lines>0) ? temp_lines-1 : 0;
|
||||
height+=temp_lines;
|
||||
}
|
||||
}
|
||||
|
@ -424,29 +411,31 @@ normalop:
|
|||
double src_add=(double)height/(double)render.src.height;
|
||||
double src_index=0;
|
||||
double src_lines=0;
|
||||
Bitu src_done=0;
|
||||
Bitu height=0;
|
||||
am2x.cmd_index=am2x.cmd_data;
|
||||
am2x.buf_pos=0;am2x.buf_used=0;
|
||||
for (i=0;i<=(Bits)render.src.height;i++) {
|
||||
render.advmame2x.hindex[i]=(Bitu)src_index;
|
||||
src_lines+=src_add;
|
||||
Bitu lines=(Bitu)src_lines;
|
||||
src_lines-=lines;
|
||||
src_index+=src_add;
|
||||
src_lines+=src_add;
|
||||
switch (lines) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
SetAdvMameTable(height++,i,i,i);
|
||||
AdvMame2x_AddLine(i,i,i);
|
||||
break;
|
||||
case 2:
|
||||
SetAdvMameTable(height++,i-1,i,i+1);
|
||||
SetAdvMameTable(height++,i+1,i,i-1);
|
||||
AdvMame2x_AddLine(i-1,i,i+1);
|
||||
AdvMame2x_AddLine(i+1,i,i-1);
|
||||
break;
|
||||
default:
|
||||
SetAdvMameTable(height++,i-1,i,i+1);
|
||||
for (lines-=2;lines>0;lines--) SetAdvMameTable(height++,i,i,i);
|
||||
SetAdvMameTable(height++,i+1,i,i-1);
|
||||
AdvMame2x_AddLine(i-1,i,i+1);
|
||||
for (lines-=2;lines>0;lines--) AdvMame2x_AddLine(i,i,i);
|
||||
AdvMame2x_AddLine(i+1,i,i-1);
|
||||
break;
|
||||
}
|
||||
AdvMame2x_CheckLines(i);
|
||||
}
|
||||
render.op.line_handler=AdvMame2x_8_Table[index];
|
||||
}
|
||||
|
|
|
@ -36,6 +36,48 @@
|
|||
#ifndef __SCALE2X_H
|
||||
#define __SCALE2X_H
|
||||
|
||||
#define AM2XBUF 16
|
||||
|
||||
static struct {
|
||||
Bits buf[AM2XBUF][4];
|
||||
Bitu buf_used;Bitu buf_pos;
|
||||
Bit8u cmd_data[4096]; //1024 lines should be enough?
|
||||
Bit8u * cmd_index;
|
||||
Bit8u * cache[4];
|
||||
Bitu cache_index;
|
||||
} am2x;
|
||||
|
||||
|
||||
static void AdvMame2x_AddLine(Bits s0,Bits s1,Bits s2) {
|
||||
if (s0<0) s0=0;
|
||||
if (s1<0) s1=0;
|
||||
if (s2<0) s2=0;
|
||||
if (s0>=(Bits)render.src.height) s0=render.src.height-1;
|
||||
if (s1>=(Bits)render.src.height) s1=render.src.height-1;
|
||||
if (s2>=(Bits)render.src.height) s2=render.src.height-1;
|
||||
Bitu pos=(am2x.buf_used+am2x.buf_pos)&(AM2XBUF-1);
|
||||
am2x.buf[pos][0]=s0;
|
||||
am2x.buf[pos][1]=s1;
|
||||
am2x.buf[pos][2]=s2;
|
||||
s0=s0 > s1 ? s0 : s1;
|
||||
s0=s0 > s2 ? s0 : s2;
|
||||
am2x.buf[pos][3]=s0;
|
||||
am2x.buf_used++;
|
||||
}
|
||||
|
||||
static void AdvMame2x_CheckLines(Bits last) {
|
||||
Bitu lines=0;Bit8u * line_count=am2x.cmd_index++;
|
||||
while (am2x.buf_used) {
|
||||
if (am2x.buf[am2x.buf_pos][3]>last) break;
|
||||
*am2x.cmd_index++=am2x.buf[am2x.buf_pos][0]&3;
|
||||
*am2x.cmd_index++=am2x.buf[am2x.buf_pos][1]&3;
|
||||
*am2x.cmd_index++=am2x.buf[am2x.buf_pos][2]&3;
|
||||
am2x.buf_used--;lines++;
|
||||
am2x.buf_pos=(am2x.buf_pos+1)&(AM2XBUF-1);
|
||||
}
|
||||
*line_count=lines;
|
||||
}
|
||||
|
||||
template <Bitu sbpp,Bitu dbpp>
|
||||
static void AdvMame2x_line(Bit8u * dst, const Bit8u * src0, const Bit8u * src1, const Bit8u * src2, Bitu count) {
|
||||
AddDst<dbpp>(dst,ConvBPP<sbpp,dbpp>(src1[0]));
|
||||
|
@ -54,19 +96,17 @@ static void AdvMame2x_line(Bit8u * dst, const Bit8u * src0, const Bit8u * src1,
|
|||
|
||||
template <Bitu sbpp,Bitu dbpp>
|
||||
static void AdvMame2x(Bit8u * src) {
|
||||
#if 0
|
||||
_dy=render.advmame2x.hindex[y+_dy];
|
||||
y=render.advmame2x.hindex[y];
|
||||
Bit8u * dest=render.op.pixels+render.op.pitch*y;
|
||||
src-=render.advmame2x.line_starts[y][0];
|
||||
for (;y<_dy;y++) {
|
||||
Bit8u * src0=src+render.advmame2x.line_starts[y][0];
|
||||
Bit8u * src1=src+render.advmame2x.line_starts[y][1];
|
||||
Bit8u * src2=src+render.advmame2x.line_starts[y][2];
|
||||
AdvMame2x_line<sbpp,dbpp>(dest,src0,src1,src2,render.src.width);
|
||||
dest+=render.op.pitch;
|
||||
RENDER_TempLine=render_line_cache[render.op.line&3];
|
||||
am2x.cache[render.op.line&3]=src;
|
||||
Bitu lines=*am2x.cmd_index++;
|
||||
while (lines--) {
|
||||
Bit8u * src0=am2x.cache[*am2x.cmd_index++];
|
||||
Bit8u * src1=am2x.cache[*am2x.cmd_index++];
|
||||
Bit8u * src2=am2x.cache[*am2x.cmd_index++];
|
||||
AdvMame2x_line<sbpp,dbpp>(render.op.pixels,src0,src1,src2,render.src.width);
|
||||
render.op.pixels+=render.op.pitch;
|
||||
}
|
||||
#endif
|
||||
render.op.line++;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue