📄 build.c
字号:
char buffer[80], *dabuffer; long i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col; long templong, templong1, templong2, opageoffset, doubvel; long startwall, endwall, dax, day, daz, x1, y1, x2, y2, x3, y3, x4, y4; long highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect; short pag, suckwall=0, sucksect, newnumwalls, newnumsectors, split=0, bad; short splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum; short splitstartwall=0, splitendwall, loopnum; short mousx, mousy, bstatus; long centerx, centery, circlerad; short circlewall, circlepoints, circleang1, circleang2, circleangdir; long sectorhighlightx=0, sectorhighlighty=0; short cursectorhighlight, sectorhighlightstat; short hitsect, hitwall, hitsprite; long hitx, hity, hitz; walltype *wal; searchx = scale(searchx,640,xdim); searchy = scale(searchy,480,ydim); oposz = posz; qsetmode640480(); pageoffset = 0; ydim16 = 144; drawline16(0,0,639,0,7); drawline16(0,143,639,143,7); drawline16(0,0,0,143,7); drawline16(639,0,639,143,7); drawline16(0,24,639,24,7); drawline16(192,0,192,24,7); statusbar_printext16_noupdate(9L,9L,4,-1,kensig,0); statusbar_printext16(8L,8L,12,-1,kensig,0); printmessage16("Version: 9/23/95"); drawline16(0,143-24,639,143-24,7); drawline16(256,143-24,256,143,7); pageoffset = 92160; ydim16 = 336; /* rcg08312000 whoops. Missed this one. */ #ifdef PLATFORM_DOS outpw(0x3d4,0x000c); outpw(0x3d4,0x000d); #endif pag = 0; highlightcnt = -1; cursectorhighlight = -1; /* * White out all bordering lines of grab that are * not highlighted on both sides */ for(i=highlightsectorcnt-1;i>=0;i--) { startwall = sector[highlightsector[i]].wallptr; endwall = startwall + sector[highlightsector[i]].wallnum; for(j=startwall;j<endwall;j++) { if (wall[j].nextwall >= 0) { for(k=highlightsectorcnt-1;k>=0;k--) if (highlightsector[k] == wall[j].nextsector) break; if (k < 0) { wall[wall[j].nextwall].nextwall = -1; wall[wall[j].nextwall].nextsector = -1; wall[j].nextwall = -1; wall[j].nextsector = -1; } } } } for(i=0;i<(MAXWALLS>>3);i++) /* Clear all highlights */ show2dwall[i] = 0; for(i=0;i<(MAXSPRITES>>3);i++) show2dsprite[i] = 0; sectorhighlightstat = -1; newnumwalls = -1; joinsector[0] = -1; circlewall = -1; circlepoints = 7; oldmousebstatus = 0; keystatus[buildkeys[14]] = 0; while ((keystatus[buildkeys[14]]>>1) == 0) { _idle(); oldmousebstatus = bstatus; getmousevalues(&mousx,&mousy,&bstatus); searchx += (mousx>>1); searchy += (mousy>>1); if (searchx < 8) searchx = 8; if (searchx > 631) searchx = 631; if (searchy < 8) searchy = 8; if (searchy > 341) searchy = 341; if (keystatus[0x3b] > 0) posx--, keystatus[0x3b] = 0; if (keystatus[0x3c] > 0) posx++, keystatus[0x3c] = 0; if (keystatus[0x3d] > 0) posy--, keystatus[0x3d] = 0; if (keystatus[0x3e] > 0) posy++, keystatus[0x3e] = 0; if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; if (angvel != 0) /* ang += angvel * constant */ { /* ENGINE calculates angvel for you */ doubvel = synctics; if (keystatus[buildkeys[4]] > 0) /* Lt. shift makes turn velocity 50% faster */ doubvel += (synctics>>1); ang += ((angvel*doubvel)>>4); ang = (ang+2048)&2047; } if ((vel|svel) != 0) { doubvel = synctics; if (keystatus[buildkeys[4]] > 0) /* Lt. shift doubles forward velocity */ doubvel += synctics; xvect = 0, yvect = 0; if (vel != 0) { xvect += ((vel*doubvel*(long)sintable[(ang+2560)&2047])>>3); yvect += ((vel*doubvel*(long)sintable[(ang+2048)&2047])>>3); } if (svel != 0) { xvect += ((svel*doubvel*(long)sintable[(ang+2048)&2047])>>3); yvect += ((svel*doubvel*(long)sintable[(ang+1536)&2047])>>3); } clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); } getpoint(searchx,searchy,&mousxplc,&mousyplc); linehighlight = getlinehighlight(mousxplc, mousyplc); if (newnumwalls >= numwalls) { dax = mousxplc; day = mousyplc; adjustmark(&dax,&day,newnumwalls); wall[newnumwalls].x = dax; wall[newnumwalls].y = day; } ydim16 = 336; templong = numwalls; numwalls = newnumwalls; if (numwalls < 0) numwalls = templong; clear2dscreen(); draw2dgrid(posx,posy,ang,zoom,grid); x2 = mulscale14(startposx-posx,zoom); /* Draw brown arrow (start) */ y2 = mulscale14(startposy-posy,zoom); if (((320+x2) >= 2) && ((320+x2) <= 637)) if (((200+y2) >= 2) && ((200+y2) <= ydim16-3)) { x1 = mulscale11(sintable[(startang+2560)&2047],zoom) / 768; y1 = mulscale11(sintable[(startang+2048)&2047],zoom) / 768; drawline16((320+x2)+x1,(200+y2)+y1,(320+x2)-x1,(200+y2)-y1,6); drawline16((320+x2)+x1,(200+y2)+y1,(320+x2)+y1,(200+y2)-x1,6); drawline16((320+x2)+x1,(200+y2)+y1,(320+x2)-y1,(200+y2)+x1,6); } draw2dscreen(posx,posy,ang,zoom,grid); if ((showtags == 1) && (zoom >= 768)) { for(i=0;i<numsectors;i++) { dabuffer = (char *)ExtGetSectorCaption(i); if (dabuffer[0] != 0) { dax = 0; /* Get average point of sector */ day = 0; startwall = sector[i].wallptr; endwall = startwall + sector[i].wallnum - 1; for(j=startwall;j<=endwall;j++) { dax += wall[j].x; day += wall[j].y; } if (endwall > startwall) { dax /= (endwall-startwall+1); day /= (endwall-startwall+1); } dax = mulscale14(dax-posx,zoom); day = mulscale14(day-posy,zoom); x1 = 320+dax-(strlen(dabuffer)<<1); y1 = 200+day-4; x2 = x1 + (strlen(dabuffer)<<2)+2; y2 = y1 + 7; if ((x1 >= 0) && (x2 < 640) && (y1 >= 0) && (y2 < ydim16)) { #ifdef PLATFORM_DOS printext16(x1,y1+(pageoffset/640),0,7,dabuffer,1); #else printext16(x1,y1,0,7,dabuffer,1); #endif } /* if */ } } x3 = divscale14(-320,zoom)+posx; y3 = divscale14(-196,zoom)+posy; x4 = divscale14(320,zoom)+posx; y4 = divscale14(ydim16-196,zoom)+posy; for(i=numwalls-1,wal=&wall[i];i>=0;i--,wal--) { /* Get average point of wall */ dax = ((wal->x+wall[wal->point2].x)>>1); day = ((wal->y+wall[wal->point2].y)>>1); if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4)) { dabuffer = (char *)ExtGetWallCaption(i); if (dabuffer[0] != 0) { dax = mulscale14(dax-posx,zoom); day = mulscale14(day-posy,zoom); x1 = 320+dax-(strlen(dabuffer)<<1); y1 = 200+day-4; x2 = x1 + (strlen(dabuffer)<<2)+2; y2 = y1 + 7; if ((x1 >= 0) && (x2 < 640) && (y1 >= 0) && (y2 < ydim16)) { #ifdef PLATFORM_DOS printext16(x1,y1+(pageoffset/640),0,4,dabuffer,1); #else printext16(x1,y1,0,4,dabuffer,1); #endif } /* if */ } } } i = 0; j = numsprites; while ((j > 0) && (i < MAXSPRITES)) { if (sprite[i].statnum < MAXSTATUS) { dabuffer = (char *)ExtGetSpriteCaption(i); if (dabuffer[0] != 0) { /* Get average point of sprite */ dax = sprite[i].x; day = sprite[i].y; dax = mulscale14(dax-posx,zoom); day = mulscale14(day-posy,zoom); x1 = 320+dax-(strlen(dabuffer)<<1); y1 = 200+day-4; x2 = x1 + (strlen(dabuffer)<<2)+2; y2 = y1 + 7; if ((x1 >= 0) && (x2 < 640) && (y1 >= 0) && (y2 < ydim16)) { if ((sprite[i].cstat&1) == 0) col = 3; else col = 5; { #ifdef PLATFORM_DOS printext16(x1,y1+(pageoffset/640),0,col,dabuffer,1); #else printext16(x1,y1,0,col,dabuffer,1); #endif } /* if */ } } j--; } i++; } } printcoords16(posx,posy,ang); numwalls = templong; if (highlightsectorcnt > 0) for(i=0;i<highlightsectorcnt;i++) fillsector(highlightsector[i],2); col = 15-((gridlock<<1)+gridlock); drawline16(searchx,searchy-8,searchx,searchy-1,col); drawline16(searchx+1,searchy-8,searchx+1,searchy-1,col); drawline16(searchx,searchy+2,searchx,searchy+9,col); drawline16(searchx+1,searchy+2,searchx+1,searchy+9,col); drawline16(searchx-8,searchy,searchx-1,searchy,col); drawline16(searchx-8,searchy+1,searchx-1,searchy+1,col); drawline16(searchx+2,searchy,searchx+9,searchy,col); drawline16(searchx+2,searchy+1,searchx+9,searchy+1,col); /* Draw the white pixel closest to mouse cursor on linehighlight */ getclosestpointonwall(mousxplc,mousyplc,(long)linehighlight,&dax,&day); x2 = mulscale14(dax-posx,zoom); y2 = mulscale14(day-posy,zoom); if (wall[linehighlight].nextsector >= 0) drawline16(320+x2,200+y2,320+x2,200+y2,15); else drawline16(320+x2,200+y2,320+x2,200+y2,5); if (keystatus[88] > 0) /* F12 */ { keystatus[88] = 0; i = pageoffset; pageoffset = 92160; j = ydim16; ydim16 = 480; outpw(0x3d4,0x000c); outpw(0x3d4,0x000d); clear2dscreen(); draw2dgrid(posx,posy,ang,zoom,grid); draw2dscreen(posx,posy,ang,zoom,grid); screencapture("captxxxx.pcx",keystatus[0x2a]|keystatus[0x36]); pageoffset = i; ydim16 = j; } if (keystatus[0x30] > 0) /* B (clip Blocking xor) (2D) */ { pointhighlight = getpointhighlight(mousxplc, mousyplc); linehighlight = getlinehighlight(mousxplc, mousyplc); if ((pointhighlight&0xc000) == 16384) { sprite[pointhighlight&16383].cstat ^= 1; sprite[pointhighlight&16383].cstat &= ~256; sprite[pointhighlight&16383].cstat |= ((sprite[pointhighlight&16383].cstat&1)<<8); asksave = 1; } else if (linehighlight >= 0) { wall[linehighlight].cstat ^= 1; wall[linehighlight].cstat &= ~64; if ((wall[linehighlight].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) { wall[wall[linehighlight].nextwall].cstat &= ~(1+64); wall[wall[linehighlight].nextwall].cstat |= (wall[linehighlight].cstat&1); } asksave = 1; } keystatus[0x30] = 0; } if (keystatus[0x21] > 0) /* F (F alone does nothing in 2D right now) */ { keystatus[0x21] = 0; if ((keystatus[0x38]|keystatus[0xb8]) > 0) /* ALT-F (relative alignmment flip) */ { linehighlight = getlinehighlight(mousxplc, mousyplc); if (linehighlight >= 0) { setfirstwall(sectorofwall(linehighlight),linehighlight); asksave = 1; printmessage16("This wall now sector's first wall (sector[].wallptr)"); } } } if (keystatus[0x18] > 0) /* O (ornament onto wall) (2D) */ { keystatus[0x18] = 0; if ((pointhighlight&0xc000) == 16384) { asksave = 1; i = (pointhighlight&16383); hitscan(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum, sintable[(sprite[i].ang+2560+1024)&2047], sintable[(sprite[i].ang+2048+1024)&2047], 0, &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); sprite[i].x = hitx; sprite[i].y = hity; sprite[i].z = hitz; changespritesect(i,hitsect); if (hitwall >= 0) sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); /* Make sure sprite's in right sector */ if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) { j = wall[hitwall].point2; sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); } } } if (keystatus[0x33] > 0) /* , (2D) */ { if (highlightsectorcnt > 0) { k = 0; dax = 0; day = 0; for(i=0;i<highlightsectorcnt;i++) { startwall = sector[highlightsector[i]].wallptr; endwall = startwall+sector[highlightsector[i]].wallnum-1; for(j=startwall;j<=endwall;j++) { dax += wall[j].x; day += wall[j].y; k++; } } if (k > 0) { dax /= k; day /= k; } k = (keystatus[0x2a]|keystatus[0x36]); if (k == 0) { if ((gridlock > 0) && (grid > 0)) { dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); } } for(i=0;i<highlightsectorcnt;i++) { startwall = sector[highlightsector[i]].wallptr; endwall = startwall+sector[highlightsector[i]].wallnum-1; for(j=startwall;j<=endwall;j++) { if (k == 0) { x3 = wall[j].x; y3 = wall[j].y; wall[j].x = dax+day-y3; wall[j].y = day+x3-dax; } else { rotatepoint(dax,day,wall[j].x,wall[j].y,1,&wall[j].x,&wall[j].y); } } j = headspritesect[highlightsector[i]]; while (j != -1) { if (k == 0) { x3 = sprite[j].x; y3 = sprite[j].y; sprite[j].x = dax+day-y3; sprite[j].y = day+x3-dax; sprite[j].ang = ((sprite[j].ang+512)&2047); } else { rotatepoint(dax,day,sprite[j].x,sprite[j].y,1,&sprite[j].x,&sprite[j].y); sprite[j].ang = ((sprite[j].ang+1)&2047); } j = nextspritesect[j]; } } if (k == 0) keystatus[0x33] = 0; asksave = 1; } else { if (pointhighlight >= 16384) { i = pointhighlight-16384; if ((keystatus[0x2a]|keystatus[0x36]) > 0) sprite[i].ang = ((sprite[i].ang+2048-1)&2047); else { sprite[i].ang = ((sprite[i].ang+2048-128)&2047); keystatus[0x33] = 0; } clearmidstatbar16(); showspritedata((short)pointhighlight-16384); } } } if (keystatus[0x34] > 0) /* . (2D) */ { if (highlightsectorcnt > 0) { k = 0; dax = 0; day = 0; for(i=0;i<highlightsectorcnt;i++) { startwall = sector[highlightsector[i]].wallptr; endwall = startwall+sector[highlightsector[i]].wallnum-1; for(j=startwall;j<=endwall;j++) { dax += wall[j].x; day += wall[j].y; k++; } } if (k > 0) { dax /= k; day /= k; } k = (keystatus[0x2a]|keystatus[0x36]); if (k == 0) { if ((gridlock > 0) &&
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -