Mail Archives: djgpp/1997/11/13/10:01:26
From: | qball1723 AT aol DOT com (QBall1723)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | DJGPP inline solution anyone?
|
Date: | 13 Nov 1997 13:02:22 GMT
|
Lines: | 227
|
Message-ID: | <19971113130201.IAA27637@ladder01.news.aol.com>
|
NNTP-Posting-Host: | ladder01.news.aol.com
|
Organization: | AOL http://www.aol.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hello All,
I've just begun coding with DJGPP... and I'd like to get some input on
converting a routine originally written for 16-bit REAL MODE Dos... to DJGPP's
inline assembly....
... I may give TOO much information... but here goes.. (I'm including some
declarations & support routines...)
Thank you for reading this and trying to help me out!
********************* some declares
int *scale_table[MAX_SCALE+1]; // table with pre-computed scale indices
// parmeter block used by assembly language sliver engine
char *sliver_texture; // pointer to texture being rendered
int sliver_column; // index into texture i.e. which column of texture
int sliver_top; // starting Y position to render at
int sliver_bottom;
int sliver_scale; // overall height of sliver
int sliver_ray; // current ray being cast
int sliver_clip; // index into texture after clipping
int *scale_row; // row of scale value look up table to use
****************Here's the routine in question
void Render_Sliver(void)
{
// this is yet another version of the sliver scaler, however it uses look up
// tables with pre-computed scale indices.
// this draws vertical slivers fromthe middle of the strip to the top,
// and fromthe middle of the strip to the bottom.
char *work_sprite;
int *row;
char *draw_from;
int work_offset=0,offset,temp_offset,y_off,scale_off;
// alias a pointer to sprite for ease of access
work_sprite = sliver_texture;
// compute offset of sprite in video buffer
temp_offset = v_320[99] + sliver_ray;
// render top half of wall sliver
offset = temp_offset;
draw_from = double_buffer + offset;
work_offset = WALL_MIDDLE_OFFSET;
*draw_from = work_sprite[work_offset+sliver_column];
for (y_off=1; y_off<sliver_scale; y_off++)
{
draw_from -= 320;
work_offset = WALL_MIDDLE_OFFSET - scale_row[y_off];
*draw_from = work_sprite[work_offset+sliver_column];
} // end for y
// render bottomhalf of wall sliver
offset = temp_offset + 320;
draw_from = double_buffer + offset;
work_offset = WALL_MIDDLE_OFFSET;
*draw_from = work_sprite[work_offset+sliver_column];
for (y_off=0; y_off<(sliver_scale); y_off++)
{
draw_from += 320;
work_offset = WALL_MIDDLE_OFFSET + scale_row[y_off];
*draw_from = work_sprite[work_offset+sliver_column];
} // end for y
} // end Render_Sliver
*************allocation & initialization of scale_table
// create the lookup tables for the scaler
// there have the formof an array of pointers, where each pointer points
// another another array of data where the 'data' are the scale indices
for (scale=0; scale<=100; scale++)
{
scale_table[scale] = (int *)malloc(scale*sizeof(int)+1);
} // end for scale
for (scale=101; scale<=MAX_SCALE; scale++)
{
scale_table[scale] = (int *)malloc((101)*sizeof(int)+1);
} // end for scale
// create tables, sit back for a sec!
for (ang=ANGLE_0; ang<=ANGLE_360; ang++)
{
// build the scaler table. This table holds MAX_SCALE different arrays. Each
// array consists of the pre-computed indices for an object to be scaled
for (scale=1; scale<=99; scale++)
{
// create the indices for this scale
Create_Scale_Data(scale, (int *)scale_table[scale]);
} // end for scale
// THE SECOND Create_Scale_Data FUNCTION REFERED TO HERE IS USED
// TO COMPUTE SCALES FOR CASES WHERE THE BOTTOmAND THE TOP OF A WALL
// SLIVER ARE BEYOND THE VERTICAL EXTENTS OF THE VIEWPORT!
for (scale=99+1; scale<=MAX_SCALE; scale++)
{
// create the indices for this scale
Create_Scale_Data2(scale, (int *)scale_table[scale]);
} // end for scale
*******************************************
Initializers....
void Create_Scale_Data(int scaler, int *row)
{
// this function synthesizes the scaling of a texture sliver to all possible
// sizes and creates a huge look up table of the data.
int y_off;
float y_scale_index=0,
y_scale_step;
// compute scale step or number of source pixels to map to destination/cycle
y_scale_step = (float)32/(float)scaler;
y_scale_index+=y_scale_step;
for (y_off=0; y_off<scaler; y_off++)
{
// place data into proper array position for later use
row[y_off] = ((int)(y_scale_index+.4)) * SWATCH_WIDTH;
// test if we slightly went overboard
if (row[y_off] > WALL_MIDDLE_OFFSET) row[y_off] = WALL_MIDDLE_OFFSET;
// next index please
y_scale_index+=y_scale_step;
} // end for y_off
} // end Create_Scale_Data
void Create_Scale_Data2(int scaler, int *row)
{
// this function synthesizes the scaling of a texture sliver to all possible
// sizes and creates a huge look up table of the data.
// this adds data for cases where the vertical extents of the "sliver" are
// beyond the vertical extents of the viewport
int y_off;
float y_scale_index=0,
y_scale_step;
// compute scale step or number of source pixels to map to destination/cycle
y_scale_step = (float)32/(float)scaler;
y_scale_index+=y_scale_step;
for (y_off=0; y_off<99+1; y_off++)
{
// place data into proper array position for later use
row[y_off] = ((int)(y_scale_index+.3)) * SWATCH_WIDTH;
// test if we slightly went overboard
if (row[y_off] > WALL_MIDDLE_OFFSET) row[y_off] = WALL_MIDDLE_OFFSET;
// next index please
y_scale_index+=y_scale_step;
} // end for y_off
} // end Create_Scale_Data2
Again - thanks for checking this out!
Jim the loiterer
http://members.aol.com/qball1723/index.htm
(I make games)
- Raw text -