regs.w.dx = ptr.selector;
int386 ( 0x31, ®s, ®s );
}
void setVideoMode (int mode ) {
_asm {
mov ax, word ptr mode int 10h
13. Элементы виртуальной реальност
}
}
void setPalette ( RGB * palette ) {
DPMIDosPtr palPool;
DPMIAHocDosMem ( palPool, 3*256 /16 );
RGB * tmpPal = (RGB *) (palPool.segment * 16);
for (int i = 0; i < 256; i++ ) // convert from 8-bit to { . //6-bit values
tmpPal [i].red = palette [ij.red » 2;
tmpPal [ij.green = palette [ij.green » 2;
tmpPal [ij.blue = palette [i].blue » 2;
}
rmRegs.eax = 0x1012; // set palette
rmRegs.ebx = 0; // starting index
rmRegs.ecx = 256; // # of pal entries
rmRegs.es = palPool.segment; rmRegs.edx = 0;
RMVideoInt (); // execute video interrupt
DPMIFreeDosMem ( palPool); // free memory
}
void drawVertLine (int col, int top, int bottom, int color) {
char * vptr = col + 320 * top + (char *)0xA0000l;
while (top <= bottom ) {
* vptr = color; vptr += 320; top++;
}
}
void drawTexturedLine (int col, int top, int bottom, Texture * tex,
int textureOffset, Fixed texY, Fixed dTexY )
{
char * vptr = col + 320 * top + (char *)0xA0000l;
while (top <= bottom )
{
* vptr = tex -> data [textureOffset + tex -> width *
(fixed2lnt (texY) & (tex->height-1))]; vptr += SCREEN_WIDTH; texY +=dTexY; top++;
}
}
main () {
int done = 0;
Компьютерная графика. Полигональные модели
initFixMath (); wad.loadLevel (1,1); wad.loadPlayPal (); wad.loadColorMap ();
vertexCache = new VertexCache [numVertices];
// set viewer to start of level for (int i = 0; i < numThings; i++ ) if (things [i].type == 1 )
{
locX = things [i].x; locY = things [i].y; locZ = 0;
angle = (Angle) (( 0x4000! * things [i].angle ) / 90 ); break;
}
// load all textures for (i = 0; i < numSides; \++ )
{
texDict.getTexture ( sides [i].main_tx ); texDict.getTexture ( sides [ij.lowerjx ); texDict.getTexture ( sides [ij.uppeMx );
}
setVideoMode(0x13); setPalette ( playPal [0]);
clockj start = clock ();
while (Idone) {
drawView (); if (_bios_keybrd (_KEYBRD_READY ))