From: QBall1723 AT aol DOT com Subject: djgpp inliine anyone? Date: Fri, 14 Nov 1997 06:51:13 -0600 http: //members.aol.com/qball1723/index.htm Message-ID: <879447733.1174@dejanews.com> Newsgroups: rec.games.programmer,comp.os.msdos.djgpp Organization: Deja News Usenet Posting Service Lines: 131 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hello All, I've been tinkering with DJGPP2 lately... and I'd like to see the thread that ensues, when you folks start ripping into this with DJGPP's inline assembly.... I'd really like to convert it - and I've already seen the thread that began when someone asked how to clear a 320x400x256 (a.k.a Mode Z) page QUICKLY! The code that follows is part of the "sliver engine" a ray caster I made uses... - it started out as 16-bit (C for windows - circa 1990 actually) C code... ...some of you might not like the fact I use scale tables... but alas the examples I learned from that attained ANY kind of speed used this... I'm going to include some of the declarations from outside the function I'd like to see optimized into 32-bit DJGPP inline asm, and also the allocation & initialization of the scale table itself Here goes: *************************** a few globals *************************** 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;(not used)// index into texture after clipping int *scale_row; // row of scale value look up table to use **************************** THE FUNCTION I'D LIKE TO OPTIMIZE - in the case of my program, you know going in the: sliver_texture - some 64x64 sprite sliver_column - the column of the sprite that will be used to texture a vertical "sliver", sliver_top, sliver_bottom, sliver_scale, sliver_ray (which column of the screen is to be rendered) and scale_row ****************************** 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 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 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... Thank you for taking the time to look over my hack-kneed code! -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet