|
From: Vincent H. <ya...@us...> - 2005-06-26 18:52:10
|
Update of /cvsroot/twin-e/twin-e/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv754/src Modified Files: HQRlib.c animAction.c cube.c fullRedraw.c images.c mainSDL.c moveActor.c music.c renderer.c room.c samples.c vars.h Log Message: Buggy clipped poly Sound (wrong pitch) Midi music (deactivated, cause problems) One major script bug fixed Index: renderer.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/renderer.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** renderer.c 12 Jun 2005 20:19:29 -0000 1.21 --- renderer.c 26 Jun 2005 18:51:57 -0000 1.22 *************** *** 18,21 **** --- 18,22 ---- #include "lba.h" + #include "math.h" #ifdef GAME_DEBUG *************** *** 679,682 **** --- 680,711 ---- typedef struct computedVertex computedVertex; + void circle_fill(int x,int y, int radius, byte color) + { + int currentLine; + + radius+=1; + + for(currentLine = -radius; currentLine <= radius; currentLine++) + { + double width; + + if(abs(currentLine) != radius) + { + width = sin(acos((float)currentLine/(float)radius)); + } + else + { + width = 0; + } + + width *= radius; + + if(width < 0) + width = - width; + + drawLine(x-width/2,currentLine + y, x+width/2, currentLine+y, color); + } + } + int finishRender(unsigned char *esi) { *************** *** 970,974 **** if (temp) // pour les cercles (2) { ! // numOfPrimitives+=temp; do { --- 999,1003 ---- if (temp) // pour les cercles (2) { ! _numOfPrimitives+=temp; do { *************** *** 979,983 **** --- 1008,1023 ---- osystem_addSphere( _flattenPointTable[center/6].x, _flattenPointTable[center/6].y, _flattenPointTable[center/6].z, size, color); + *(unsigned char*)edi = color; + WRITE_LE_S16(edi+1, _flattenPointTable[center/6].x); + WRITE_LE_S16(edi+3, _flattenPointTable[center/6].y); + WRITE_LE_S16(edi+5, size); + + renderTabEntryPtr->depth = _flattenPointTable[center/6].z; + renderTabEntryPtr->renderType = 2; + renderTabEntryPtr->dataPtr = edi; + renderTabEntryPtr++; + esi += 8; + edi += 7; }while (--temp); } *************** *** 1066,1077 **** // char circleColor; - /* int circleParam1; int circleParam2; int circleParam3; eax = *(int*) esi; ! circleParam1 = eax & 0xFF; circleParam2 = (eax & 0xFFFF00) >> 8; esi += 4; --- 1106,1123 ---- // char circleColor; int circleParam1; int circleParam2; int circleParam3; + int circleParam4; + int circleParam5; eax = *(int*) esi; ! circleParam1 = *(unsigned char*)esi; ! circleParam4 = READ_LE_S16(esi+1); ! circleParam5 = READ_LE_S16(esi+3); ! circleParam3 = READ_LE_S16(esi+5); ! ! /* circleParam1 = eax & 0xFF; circleParam2 = (eax & 0xFFFF00) >> 8; esi += 4; *************** *** 1081,1085 **** esi += 4; circleParam5 = *(short int*)esi; ! esi += 2; if(!isUsingOrhoProjection) --- 1127,1131 ---- esi += 4; circleParam5 = *(short int*)esi; ! esi += 2; */ if(!isUsingOrhoProjection) *************** *** 1102,1108 **** if(circleParam5 - circleParam3 < renderTop) ! renderTop = circileParam5 - circleParam3; ! prepareCircle(circleParam3*/ } --- 1148,1155 ---- if(circleParam5 - circleParam3 < renderTop) ! renderTop = circleParam5 - circleParam3; ! circle_fill(circleParam4, circleParam5, circleParam3, circleParam1); ! /*prepareCircle(circleParam3*/ } *************** *** 1137,1140 **** --- 1184,1188 ---- int color; int j; + int currentLine; // char borrow; *************** *** 1145,1149 **** float varf4; ! if (vtop <= 0 || vbottom <= 0) return; if (vleft <= 0 || vright <= 0) --- 1193,1197 ---- float varf4; ! /* if (vtop <= 0 || vbottom <= 0) return; if (vleft <= 0 || vright <= 0) *************** *** 1154,1160 **** // return; if (vtop >= 480 || vbottom >= 480) ! return; ! out = frontVideoBuffer + screenLockupTable[vtop]; ptr1 = &polyTab[vtop]; --- 1202,1208 ---- // return; if (vtop >= 480 || vbottom >= 480) ! return;*/ ! out = frontVideoBuffer + 640*vtop; ptr1 = &polyTab[vtop]; *************** *** 1172,1227 **** case 0: // flat polygon { do { ! stop = ptr1[480]; ! start = ptr1[0]; ! ptr1++; ! hsize = stop - start; ! if (hsize >= 0) ! { ! hsize++; ! out2 = start + out; ! for (j = 0; j < hsize; j++) { ! *(out2++) = color; } } out += 640; }while(--vsize); break; } case 1: // copper { do { ! start = ptr1[0]; ! stop = ptr1[480]; ! ! ptr1++; ! hsize = stop - start; ! ! if(hsize>=0) { ! unsigned short int mask = 0x43DB; ! unsigned short int dx; ! ! dx = (unsigned char)color; ! dx |= 0x300; ! hsize++; ! out2 = start + out; ! for(j = 0; j< hsize; j++) { ! start += mask; ! start = (start &0xFF00) | ((start&0xFF) & (unsigned char)(dx>>8)) ; ! start = (start &0xFF00) | ((start&0xFF) + (dx&0xFF)); ! *(out2++) = start&0xFF; ! mask = (mask << 2) | (mask >> 14); ! mask++; } } out += 640; }while(--vsize); break; --- 1220,1295 ---- case 0: // flat polygon { + currentLine = vtop; do { ! if(currentLine >=0 && currentLine <480) ! { ! stop = ptr1[480]; ! start = ptr1[0]; ! ptr1++; ! hsize = stop - start; ! if (hsize >= 0) { ! hsize++; ! out2 = start + out; ! ! for(j = start; j < hsize+start; j++) ! { ! if(j>=0 && j<640) ! out[j] = color; ! } } } out += 640; + currentLine++; }while(--vsize); break; + } case 1: // copper { + currentLine = vtop; do { ! if(currentLine >=0 && currentLine <480) { ! start = ptr1[0]; ! stop = ptr1[480]; ! ptr1++; ! hsize = stop - start; ! ! if(hsize>=0) { ! unsigned short int mask = 0x43DB; ! unsigned short int dx; ! int startCopy; ! ! dx = (unsigned char)color; ! dx |= 0x300; ! ! hsize++; ! out2 = start + out; ! startCopy = start; ! ! for(j = startCopy; j< hsize+startCopy; j++) ! { ! start += mask; ! start = (start &0xFF00) | ((start&0xFF) & (unsigned char)(dx>>8)) ; ! start = (start &0xFF00) | ((start&0xFF) + (dx&0xFF)); ! if(j>=0 && j<640) ! { ! out[j] = start&0xFF; ! } ! mask = (mask << 2) | (mask >> 14); ! mask++; ! } } + } out += 640; + currentLine++; }while(--vsize); break; *************** *** 1229,1251 **** case 2: // bopper ? (1 pixel sur 2) // pas implementé comme à l'origine // BUGGYYYY ! { do { ! start = ptr1[0]; ! stop = ptr1[480]; ! ptr1++; ! hsize = stop - start; ! ! if(hsize >= 0) { ! hsize++; ! out2 = start + out; ! for (j = 0; j < hsize; j++) { ! if((int)out2&1) ! *(out2) = color; ! out2++; } } out += 640; }while(--vsize); break; --- 1297,1330 ---- case 2: // bopper ? (1 pixel sur 2) // pas implementé comme à l'origine // BUGGYYYY ! { + currentLine = vtop; do { ! if(currentLine >=0 && currentLine <480) { ! start = ptr1[0]; ! stop = ptr1[480]; ! ptr1++; ! hsize = stop - start; ! ! if(hsize >= 0) { ! hsize++; ! out2 = start + out; ! for (j = start; j < hsize+start; j++) ! { ! if((start+(vtop%1))&1) ! { ! if(j>=0&&j<640) ! { ! out[j] = color; ! } ! } ! out2++; ! } } + } out += 640; + currentLine++; }while(--vsize); break; *************** *** 1256,1292 **** unsigned char bh=0; do { ! start = ptr1[0]; ! stop = ptr1[480]; ! ptr1++; ! hsize = stop - start; ! ! if(hsize >= 0) { ! hsize++; ! out2 = start + out; ! ! hsize/=2; ! if(hsize>1) { ! unsigned short int ax; ! bh ^= 1; ! ax = (unsigned short int)(int) out2; ! ax &= 1; ! if(ax ^ bh) { ! out2++; ! } ! for (j = 0; j < hsize; j++) ! { ! *(out2) = (unsigned char)color; ! out2+=2; } } } out+=640; ! }while(--vsize); break; --- 1335,1376 ---- unsigned char bh=0; + currentLine = vtop; do { ! if(currentLine >=0 && currentLine <480) { ! start = ptr1[0]; ! stop = ptr1[480]; ! ptr1++; ! hsize = stop - start; ! ! if(hsize >= 0) { ! hsize++; ! out2 = start + out; ! ! hsize/=2; ! if(hsize>1) { ! unsigned short int ax; ! bh ^= 1; ! ax = (unsigned short int)(int) out2; ! ax &= 1; ! if(ax ^ bh) ! { ! out2++; ! } ! for (j = 0; j < hsize; j++) ! { ! *(out2) = (unsigned char)color; ! out2+=2; ! } } } + } out+=640; ! currentLine++; }while(--vsize); break; *************** *** 1295,1363 **** { renderLoop = vsize; do { ! unsigned short int startColor = ptr2[0]; ! unsigned short int stopColor = ptr2[480]; ! short int colorSize = stopColor - startColor; ! stop = ptr1[480]; // stop ! start = ptr1[0]; // start ! ptr1++; ! out2 = start + out; ! hsize = stop - start; ! varf2 = ptr2[480]; ! varf3 = ptr2[0]; ! ptr2++; ! varf4 = (float)((int)varf2 - (int)varf3); ! if (hsize == 0) ! { ! *out2 = ((startColor + stopColor) / 2)>>8; // moyenne des 2 couleurs ! } ! else if (hsize > 0) ! { ! if (hsize == 1) ! { ! *(out2 + 1) = stopColor>>8; ! *(out2) = startColor>>8; ! } ! else if (hsize == 2) { ! *(out2 + 2) = stopColor>>8; ! *(out2 + 1) = ((startColor + stopColor) / 2)>>8; ! *(out2) = startColor>>8; } ! else { ! colorSize /= hsize; ! hsize++; ! if(hsize%2) { ! hsize/=2; ! *(out2++)=startColor>>8; ! startColor+=colorSize; } else { ! hsize/=2; ! } ! do ! { ! *(out2)=startColor>>8; ! startColor+=colorSize; ! *(out2+1)=startColor>>8; ! out2+=2; ! startColor+=colorSize; ! }while(--hsize); } } out += 640; }while (--renderLoop); --- 1379,1470 ---- { renderLoop = vsize; + currentLine = vtop; do { ! if(currentLine >=0 && currentLine <480) ! { ! unsigned short int startColor = ptr2[0]; ! unsigned short int stopColor = ptr2[480]; ! short int colorSize = stopColor - startColor; ! stop = ptr1[480]; // stop ! start = ptr1[0]; // start ! ptr1++; ! out2 = start + out; ! hsize = stop - start; ! varf2 = ptr2[480]; ! varf3 = ptr2[0]; ! ptr2++; ! varf4 = (float)((int)varf2 - (int)varf3); ! if (hsize == 0) { ! if(start>=0 && start <640) ! *out2 = ((startColor + stopColor) / 2)>>8; // moyenne des 2 couleurs } ! else if (hsize > 0) { ! if (hsize == 1) ! { ! if(start>=-1 && start <640-1) ! *(out2 + 1) = stopColor>>8; ! if(start>=0 && start <640) ! *(out2) = startColor>>8; ! } ! else if (hsize == 2) { ! if(start>=-2 && start<640-2) ! *(out2 + 2) = stopColor>>8; ! if(start>=-1 && start<640-1) ! *(out2 + 1) = ((startColor + stopColor) / 2)>>8; ! if(start>=0 && start<640) ! *(out2) = startColor>>8; } else { ! int currentXPos = start; ! colorSize /= hsize; ! hsize++; ! if(hsize%2) ! { ! hsize/=2; ! if(currentXPos>=0 && currentXPos<640) ! *(out2)=startColor>>8; ! out2++; ! currentXPos++; ! startColor+=colorSize; ! } ! else ! { ! hsize/=2; ! } ! ! do ! { ! if(currentXPos>=0 && currentXPos<640) ! *(out2)=startColor>>8; ! ! currentXPos++; ! startColor+=colorSize; ! ! if(currentXPos>=0 && currentXPos<640) ! *(out2+1)=startColor>>8; ! ! currentXPos++; ! out2+=2; ! startColor+=colorSize; ! }while(--hsize); ! } } } out += 640; + currentLine++; }while (--renderLoop); *************** *** 1368,1468 **** renderLoop = vsize; do { ! stop = ptr1[480]; // stop ! start = ptr1[0]; // start ! ptr1++; ! hsize = stop - start; ! ! if(hsize>=0) { ! unsigned short int startColor = ptr2[0]; ! unsigned short int stopColor = ptr2[480]; ! ! out2 = start + out; ! ptr2++; ! if(hsize==0) ! { ! *(out2)=(unsigned char)(((startColor + stopColor)/2)>>8); ! } ! else { ! short int colorSize = stopColor - startColor; ! if(hsize==1) ! { ! unsigned short int currentColor = startColor; ! hsize++; ! hsize/=2; ! currentColor&=0xFF; ! currentColor+=startColor; ! *(out2) = currentColor>>8; ! currentColor&=0xFF; ! startColor+=colorSize; ! currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); ! currentColor +=startColor; ! *(out2+1) = currentColor>>8; ! } ! else if(hsize==2) ! { ! unsigned short int currentColor = startColor; ! hsize++; ! hsize/=2; ! ! currentColor&=0xFF; ! colorSize/=2; ! currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); ! currentColor +=startColor; ! *(out2++) = currentColor>>8; ! startColor+=colorSize; ! currentColor&=0xFF; ! currentColor+=startColor; ! *(out2) = currentColor>>8; ! currentColor&=0xFF; ! startColor+=colorSize; ! currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); ! currentColor +=startColor; ! *(out2+1) = currentColor>>8; } else { ! unsigned short int currentColor = startColor; ! colorSize/=hsize; ! hsize++; ! ! ! if(hsize%2) { hsize/=2; currentColor&=0xFF; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor +=startColor; ! *(out2++) = currentColor>>8; } ! else { hsize/=2; ! } - do - { currentColor&=0xFF; currentColor+=startColor; ! *(out2) = currentColor>>8; currentColor&=0xFF; startColor+=colorSize; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor +=startColor; - *(out2+1) = currentColor>>8; ! out2+=2; ! startColor+=colorSize; ! }while(--hsize); } } ! } out += 640; }while(--renderLoop); break; --- 1475,1602 ---- renderLoop = vsize; + currentLine = vtop; do { ! if(currentLine >=0 && currentLine <480) { ! stop = ptr1[480]; // stop ! start = ptr1[0]; // start ! ptr1++; ! hsize = stop - start; ! if(hsize>=0) { ! unsigned short int startColor = ptr2[0]; ! unsigned short int stopColor = ptr2[480]; ! int currentXPos = start; ! out2 = start + out; ! ptr2++; ! if(hsize==0) ! { ! if(currentXPos>=0 && currentXPos<640) ! *(out2)=(unsigned char)(((startColor + stopColor)/2)>>8); } else { ! short int colorSize = stopColor - startColor; ! if(hsize==1) { + unsigned short int currentColor = startColor; + hsize++; hsize/=2; + + currentColor&=0xFF; + currentColor+=startColor; + if(currentXPos>=0 && currentXPos<640) + *(out2) = currentColor>>8; currentColor&=0xFF; + startColor+=colorSize; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor +=startColor; ! currentXPos++; ! if(currentXPos>=0 && currentXPos<640) ! *(out2+1) = currentColor>>8; } ! else if(hsize==2) { + unsigned short int currentColor = startColor; + hsize++; hsize/=2; ! ! currentColor&=0xFF; ! colorSize/=2; ! currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); ! currentColor +=startColor; ! if(currentXPos>=0 && currentXPos<640) ! *(out2) = currentColor>>8; ! ! out2++; ! currentXPos++; ! startColor+=colorSize; currentColor&=0xFF; currentColor+=startColor; ! ! if(currentXPos>=0 && currentXPos<640) ! *(out2) = currentColor>>8; ! currentColor&=0xFF; startColor+=colorSize; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor +=startColor; ! currentXPos++; ! if(currentXPos>=0 && currentXPos<640) ! *(out2+1) = currentColor>>8; ! } ! else ! { ! unsigned short int currentColor = startColor; ! colorSize/=hsize; ! hsize++; ! ! ! if(hsize%2) ! { ! hsize/=2; ! currentColor&=0xFF; ! currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); ! currentColor +=startColor; ! if(currentXPos>=0 && currentXPos<640) ! *(out2) = currentColor>>8; ! out2++; ! currentXPos++; ! } ! else ! { ! hsize/=2; ! } ! ! do ! { ! currentColor&=0xFF; ! currentColor+=startColor; ! if(currentXPos>=0 && currentXPos<640) ! *(out2) = currentColor>>8; ! currentXPos++; ! currentColor&=0xFF; ! startColor+=colorSize; ! currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); ! currentColor +=startColor; ! if(currentXPos>=0 && currentXPos<640) ! *(out2+1) = currentColor>>8; ! ! currentXPos++; ! out2+=2; ! startColor+=colorSize; ! }while(--hsize); ! } } } ! } out += 640; + currentLine++; }while(--renderLoop); break; *************** *** 1528,1532 **** if (vbottom < vtop) return (0); ! if (vleft < textWindowLeft) { --- 1662,1666 ---- if (vbottom < vtop) return (0); ! /* if (vleft < textWindowLeft) { *************** *** 1577,1581 **** printf("ComputePoly_A-> cropped poly !\n"); exit(1); ! } ptr1 = pRenderV1; // on retourne au debut de la liste --- 1711,1715 ---- printf("ComputePoly_A-> cropped poly !\n"); exit(1); ! }*/ ptr1 = pRenderV1; // on retourne au debut de la liste Index: moveActor.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/moveActor.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** moveActor.c 31 Dec 2004 15:16:29 -0000 1.34 --- moveActor.c 26 Jun 2005 18:51:57 -0000 1.35 *************** *** 305,309 **** beta = READ_LE_S16(scriptPtr); ! scriptPtr += 2; lactor->angle = beta; --- 305,309 ---- beta = READ_LE_S16(scriptPtr); ! lactor->positionInMoveScript += 2; lactor->angle = beta; *************** *** 383,387 **** break; case 29: ! printf("skipping actor move opcode 29 (playSound)\n"); lactor->positionInMoveScript += 2; break; --- 383,387 ---- break; case 29: ! HQ_3D_MixSample(READ_LE_S16(scriptPtr), 0x1000, 0, lactor->X, lactor->Z, lactor->Y); lactor->positionInMoveScript += 2; break; Index: fullRedraw.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/fullRedraw.c,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** fullRedraw.c 12 Jun 2005 20:19:29 -0000 1.57 --- fullRedraw.c 26 Jun 2005 18:51:57 -0000 1.58 *************** *** 19,22 **** --- 19,25 ---- #include "lba.h" + extern unsigned char* brickTable[]; + extern unsigned char* brickMaskTable[]; + #ifdef GAME_DEBUG actor* pCurrentActorRender; *************** *** 248,258 **** if (projectedPositionX > -50 && projectedPositionX < 680 && projectedPositionY > -30 && projectedPositionY < 580) { drawList[a12].field_0 = extraList[counter2].X - cameraX + extraList[counter2].Y - cameraY; drawList[a12].field_2 = counter; a12++; ! ! // to not show shadows for stars and explode clouds ! int extraType = extraList[counter2].field_0 & 0x7FFF; // 0 - damage star | 1 - explode cloud ! if (shadowMode == 2 && (extraList[counter2].field_0 & 0x8000) && (extraType!=0) && (extraType!=1)) // cast shadow { --- 251,263 ---- if (projectedPositionX > -50 && projectedPositionX < 680 && projectedPositionY > -30 && projectedPositionY < 580) { + int extraType; + drawList[a12].field_0 = extraList[counter2].X - cameraX + extraList[counter2].Y - cameraY; drawList[a12].field_2 = counter; a12++; ! ! // to not show shadows for stars and explode clouds ! extraType = extraList[counter2].field_0 & 0x7FFF; // 0 - damage star | 1 - explode cloud ! if (shadowMode == 2 && (extraList[counter2].field_0 & 0x8000) && (extraType!=0) && (extraType!=1)) // cast shadow { *************** *** 330,334 **** unsigned int flags; int actorNumber; ! //int positionInDebugBox = 0; do --- 335,341 ---- unsigned int flags; int actorNumber; ! #ifdef GAME_DEBUG ! int positionInDebugBox = 0; ! #endif do *************** *** 1016,1020 **** currentDirtyBoxList[i].bottom = var_4; ! assert(currentDirtyBoxList[i].bottom < 480); return; } --- 1023,1028 ---- currentDirtyBoxList[i].bottom = var_4; ! if(currentDirtyBoxList[i].bottom >= 480) ! currentDirtyBoxList[i].bottom = 479; return; } *************** *** 1028,1032 **** currentDirtyBoxList[i].bottom = arg_C; ! assert(currentDirtyBoxList[i].bottom < 480); numOfRedrawBox++; --- 1036,1041 ---- currentDirtyBoxList[i].bottom = arg_C; ! if(currentDirtyBoxList[i].bottom >= 480) ! currentDirtyBoxList[i].bottom = 479; numOfRedrawBox++; *************** *** 1133,1137 **** #else // draw the background brick ! AffGraph(bx-1, zbufferVar1, zbufferVar2, bufferBrick); #endif --- 1142,1146 ---- #else // draw the background brick ! AffGraph(bx-1, zbufferVar1, zbufferVar2, brickTable); #endif *************** *** 1355,1359 **** assert( textWindowBottom <= 479 ); ! ptr = localBufferBrick + READ_LE_U32(localBufferBrick + num * 4); left = var1 + *(ptr + 2); --- 1364,1375 ---- assert( textWindowBottom <= 479 ); ! if(localBufferBrick != brickTable) ! { ! ptr = localBufferBrick + READ_LE_U32(localBufferBrick + num * 4); ! } ! else ! { ! ptr = brickTable[num]; ! } left = var1 + *(ptr + 2); *************** *** 1776,1780 **** assert( textWindowBottom <= 479 ); ! ptr = localBufferBrick + *(unsigned int *) (localBufferBrick + spriteNum * 4); left = x + *(ptr + 2); --- 1792,1798 ---- assert( textWindowBottom <= 479 ); ! //ptr = localBufferBrick + *(unsigned int *) (localBufferBrick + spriteNum * 4); ! ! ptr = brickMaskTable[spriteNum]; left = x + *(ptr + 2); Index: animAction.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/animAction.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** animAction.c 1 May 2005 15:35:01 -0000 1.12 --- animAction.c 26 Jun 2005 18:51:57 -0000 1.13 *************** *** 304,319 **** case 10: { ebx = edi; - #ifdef GAME_DEBUG - printf("Skipping GereAnimAction opcode 10 (sound)\n"); - #endif break; } case 11: { ebx = edi; - #ifdef GAME_DEBUG - printf("Skipping GereAnimAction opcode 11 (sound)\n"); - #endif break; } --- 304,317 ---- case 10: { + temp = *(ebx++); + ebx = edi; break; } case 11: { + temp = *(ebx++); + ebx = edi; break; } *************** *** 332,337 **** case 13: { ! if(*ebx == lactor->animPosition) ! { int throwX; int throwY; --- 330,335 ---- case 13: { ! if(*ebx == lactor->animPosition) ! { int throwX; int throwY; *************** *** 350,359 **** int strength; ! distanceX = READ_LE_S16(edi); distanceY = READ_LE_S16(edi+2); distanceZ = READ_LE_S16(edi+4); ! Rotate(distanceX, distanceZ, lactor->angle); throwX = destX + lactor->X; --- 348,357 ---- int strength; ! distanceX = READ_LE_S16(edi); distanceY = READ_LE_S16(edi+2); distanceZ = READ_LE_S16(edi+4); ! Rotate(distanceX, distanceZ, lactor->angle); throwX = destX + lactor->X; *************** *** 370,379 **** strength = *(edi+14); ! ThrowExtra(actorNum, throwX, throwY, throwZ, spriteIdx, param1, param2, param3, param4, strength); ! } ! ebx = eax; break; } ! case 14: { if(*ebx == lactor->animPosition) --- 368,377 ---- strength = *(edi+14); ! ThrowExtra(actorNum, throwX, throwY, throwZ, spriteIdx, param1, param2, param3, param4, strength); ! } ! ebx = eax; break; } ! case 14: { if(*ebx == lactor->animPosition) Index: room.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/room.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** room.c 22 Jun 2005 21:55:08 -0000 1.33 --- room.c 26 Jun 2005 18:51:57 -0000 1.34 *************** *** 19,22 **** --- 19,29 ---- #include "lba.h" + #define NUM_MAX_BRICKS 9000 + + unsigned char* brickTable[NUM_MAX_BRICKS]; + unsigned char* brickMaskTable[NUM_MAX_BRICKS]; + unsigned int brickSizeTable[NUM_MAX_BRICKS]; + unsigned char brickUsageTable[NUM_MAX_BRICKS]; + void ChangeCube(void) { *************** *** 1099,1107 **** unsigned int finalSize = 0; ! printf("GridSize=%d\n", gridSize); ! ! bufferPtr = workVideoBuffer + 153800; ! ! RazMem(bufferPtr, 20000); ptrToBllBits = currentGrid + (gridSize - 32); --- 1106,1112 ---- unsigned int finalSize = 0; ! memset(brickTable, 0, sizeof(brickTable)); ! memset(brickSizeTable, 0, sizeof(brickSizeTable)); ! memset(brickUsageTable, 0, sizeof(brickUsageTable)); ptrToBllBits = currentGrid + (gridSize - 32); *************** *** 1140,1144 **** lastBrick = brickIdx; ! WRITE_LE_U16(bufferPtr + brickIdx*2,1); } bllDataPtr += 4; --- 1145,1149 ---- lastBrick = brickIdx; ! brickUsageTable[brickIdx] = 1; } bllDataPtr += 4; *************** *** 1153,1198 **** for(i=firstBrick;i<=lastBrick;i++) { ! if(READ_LE_U16(currentPositionInBuffer)) // was brick noted as used ? ! { ! numUsedBricks++; ! } ! ! currentPositionInBuffer+=2; } ! ! printf("Need to load %d bricks\n", numUsedBricks); ! ! currentPositionInBuffer = bufferPtr + firstBrick * 2; ! ! destinationBrickPtr = bufferBrick + (numUsedBricks+1)*4; ! ! localBufferBrick = bufferBrick; ! ! WRITE_LE_U32(localBufferBrick, (numUsedBricks+1)*4); ! localBufferBrick+=4; ! ! ptrTempDecompression = (firstBrick * 4 + workVideoBuffer); ! ! currentBrickIdx = 0; ! for(i=firstBrick;i<=lastBrick;i++) { ! if(READ_LE_U16(currentPositionInBuffer)) ! { ! WRITE_LE_U16(currentPositionInBuffer, currentBrickIdx); ! ! Load_HQR("LBA_BRK.HQR", destinationBrickPtr, i); ! brickSize = Size_HQR("LBA_BRK.HQR",i); ! ! finalSize += brickSize; ! destinationBrickPtr += brickSize; ! WRITE_LE_U32(localBufferBrick,brickSize); ! localBufferBrick+=4; ! } ! ! ptrTempDecompression+=4; ! currentPositionInBuffer+=2; } ! currentBllEntryIdx = 0; for(i=1;i<256;i++) --- 1158,1177 ---- for(i=firstBrick;i<=lastBrick;i++) { ! if(brickUsageTable[i]) // was brick noted as used ? ! { ! numUsedBricks++; ! } } ! for(i=firstBrick;i<=lastBrick;i++) { ! if(brickUsageTable[i]) ! { ! brickSizeTable[i] = Size_HQR("LBA_BRK.HQR",i); ! brickTable[i] = (unsigned char*)malloc(brickSizeTable[i]); ! Load_HQR("LBA_BRK.HQR", brickTable[i], i); ! } } ! /* currentBllEntryIdx = 0; for(i=1;i<256;i++) *************** *** 1226,1233 **** } currentBllEntryIdx += 4; ! } ! ! return (finalSize); } /* --- 1205,1211 ---- } currentBllEntryIdx += 4; ! }*/ + return (0); } /* *************** *** 1455,1458 **** --- 1433,1453 ---- } */ + + int CreateMaskGph() + { + int i; + + for(i=0;i<NUM_MAX_BRICKS;i++) + { + if(brickUsageTable[i]) + { + brickMaskTable[i] = (unsigned char*)malloc(brickSizeTable[i]); + + CalcGraphMsk(i, brickTable[i], brickMaskTable[i]); + } + } + } + + void RazMem(unsigned char *ptr, int size) { Index: music.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/music.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** music.c 21 Apr 2005 21:29:54 -0000 1.14 --- music.c 26 Jun 2005 18:51:57 -0000 1.15 *************** *** 59,65 **** currentlyPlayingCDTrack = -1; ! if(cdrom!=NULL) if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, trackNumber, 0, 1, 0); unfreezeTime(); --- 59,71 ---- currentlyPlayingCDTrack = -1; ! if(cdrom!=NULL) ! { if(CD_INDRIVE(SDL_CDStatus(cdrom))) SDL_CDPlayTracks(cdrom, trackNumber, 0, 1, 0); + } + else + { + playMidi(trackNumber); + } unfreezeTime(); Index: cube.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/cube.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cube.c 22 Jun 2005 21:55:08 -0000 1.5 --- cube.c 26 Jun 2005 18:51:57 -0000 1.6 *************** *** 51,63 **** brickDataSize = loadBrk(gridSize); ! if (!brickDataSize) ! return (0); ! HQM_Alloc(brickDataSize, &bufferBrick2); ! size = CreateMaskGph((unsigned int *) bufferBrick, (unsigned int *) bufferBrick2); ! HQM_Shrink_Last(bufferBrick2, size); numberOfBll = (READ_LE_U32(currentBll)) >> 2; --- 51,65 ---- brickDataSize = loadBrk(gridSize); ! /* if (!brickDataSize) ! return (0);*/ ! //HQM_Alloc(brickDataSize, &bufferBrick2); ! //size = CreateMaskGph((unsigned int *) bufferBrick, (unsigned int *) bufferBrick2); ! CreateMaskGph(); ! ! //HQM_Shrink_Last(bufferBrick2, size); numberOfBll = (READ_LE_U32(currentBll)) >> 2; *************** *** 232,236 **** }while (--temp1); } ! int CreateMaskGph(unsigned int *buffer1, unsigned int *destBuffer) { --- 234,238 ---- }while (--temp1); } ! /* int CreateMaskGph(unsigned int *buffer1, unsigned int *destBuffer) { *************** *** 262,268 **** return (startOffset); } // build the masks for the bricks ! int CalcGraphMsk(int var, unsigned int *buffer, unsigned int *ptr) { unsigned int *ptrSave = ptr; --- 264,272 ---- return (startOffset); } + */ + // build the masks for the bricks ! int CalcGraphMsk(int var, unsigned char *buffer, unsigned char *ptr) { unsigned int *ptrSave = ptr; *************** *** 273,280 **** int ebx; ! buffer = (unsigned int *) (READ_LE_U32(buffer + var) + (unsigned char *) buffer); ! ebx = READ_LE_U32( buffer++ ); // on ecrit le flag de la brique ! WRITE_LE_U32( ptr++, ebx ); bh = (ebx & 0x0000FF00) >> 8; --- 277,286 ---- int ebx; ! //buffer = (unsigned int *) (READ_LE_U32(buffer + var) + (unsigned char *) buffer); ! ebx = READ_LE_U32( buffer ); // on ecrit le flag de la brique ! buffer+=4; ! WRITE_LE_U32( ptr, ebx ); ! ptr+=4; bh = (ebx & 0x0000FF00) >> 8; Index: vars.h =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/vars.h,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** vars.h 24 Jun 2005 22:48:54 -0000 1.46 --- vars.h 26 Jun 2005 18:51:57 -0000 1.47 *************** *** 23,27 **** --- 23,31 ---- #ifdef PCLIKE + #ifdef WIN32 + #include <SDL.h> + #else #include <SDL/SDL.h> + #endif #endif //PCLIKE *************** *** 1298,1304 **** void HQM_Shrink_Last(unsigned char *bufferBrick2, int size); ! int CalcGraphMsk(int var, unsigned int *ptr1, unsigned int *ptr2); ! int CreateMaskGph(unsigned int *buffer1, unsigned int *buffer2); void RazMem(unsigned char *ptr, int size); --- 1302,1308 ---- void HQM_Shrink_Last(unsigned char *bufferBrick2, int size); ! int CalcGraphMsk(int var, unsigned char *ptr1, unsigned char *ptr2); ! int CreateMaskGph(void); void RazMem(unsigned char *ptr, int size); *************** *** 1519,1522 **** --- 1523,1528 ---- void processTextLine(void); + void CopyMaskLBA(int spriteNum, int x, int y, byte * localBufferBrick, byte * buffer); + //}; #endif Index: images.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/images.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** images.c 18 Jun 2005 16:55:17 -0000 1.14 --- images.c 26 Jun 2005 18:51:57 -0000 1.15 *************** *** 196,209 **** int i; - int *colorDest = (int *) palDest; - - #if 0 - for (i = 0; i < 256; i++) - { - *(colorDest++) = (*(int *) palSource); // little optimisation trick - palSource += 3; - } - #else - #ifdef MACOSX for (i = 0; i < 256; i++) { --- 196,199 ---- *************** *** 214,224 **** palSource+=3; } - #else - for (i = 0; i < 256*3; i++) - { - *(palDest++) = *(palSource++); // little optimisation trick - } - #endif - #endif - } --- 204,206 ---- Index: samples.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/samples.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** samples.c 21 Apr 2005 21:29:54 -0000 1.6 --- samples.c 26 Jun 2005 18:51:57 -0000 1.7 *************** *** 20,24 **** #ifdef PCLIKE ! //#include <SDL_mixer.h> #endif --- 20,24 ---- #ifdef PCLIKE ! #include <SDL_mixer.h> #endif *************** *** 29,53 **** #ifdef PCLIKE ! //sampleStructData sampleTable[16]; #endif void playSample(int sampleNum, int freq, int repeat, int x, int y) { ! /* char filename[256]; - sprintf(filename,"samples/samples%03d.voc",sampleNum+1); ! Mix_Chunk * sample=Mix_LoadWAV(filename); ! Mix_PlayChannel(0,sample,repeat-1);*/ } void playSampleFla(int sampleNum, int freq, int repeat, int x, int y) { ! /* char filename[256]; sprintf(filename,"fla/flasamp/flasamp%02d.voc",sampleNum+1); ! Mix_Chunk * sample=Mix_LoadWAV(filename); ! Mix_PlayChannel(0,sample,repeat-1);*/ } --- 29,61 ---- #ifdef PCLIKE ! struct sampleStructData sampleTable[16]; #endif void playSample(int sampleNum, int freq, int repeat, int x, int y) { ! char filename[256]; ! Mix_Chunk * sample; ! FILE* fhandle; ! sample=Mix_LoadWAV_RW(SDL_RWFromMem(HQR_Get(HQR_Samples,sampleNum), Size_HQR("SAMPLES.HQR", sampleNum)),0); ! ! if(sample == NULL) ! { ! printf("Mix_LoadWAV(\"%s\"): %s\n", filename, Mix_GetError()); ! } ! ! Mix_PlayChannel(0,sample,repeat-1); } void playSampleFla(int sampleNum, int freq, int repeat, int x, int y) { ! char filename[256]; ! Mix_Chunk * sample; sprintf(filename,"fla/flasamp/flasamp%02d.voc",sampleNum+1); ! sample=Mix_LoadWAV(filename); ! Mix_PlayChannel(0,sample,repeat-1); } *************** *** 62,72 **** } void playMidi(int musicNum) { ! /*char filename[256]; ! sprintf(filename,"midi_mi_win/midi_mi_win%02d.mid",musicNum+1); ! Mix_Music * sample=Mix_LoadMUS(filename); ! Mix_PlayMusic(sample,0);*/ } --- 70,120 ---- } + #define midiFileName "Midi_mi_win" + + Mix_Music * sample = NULL; + void playMidi(int musicNum) { ! char filename[256]; ! FILE* fhandle; ! if(sample != NULL) ! { ! Mix_FreeMusic(sample); ! } ! // if(musicNum == 9) ! return; ! ! sprintf(filename,"%s/%s%02d.midi",midiFileName,midiFileName,musicNum); ! ! fhandle = fopen(filename,"rb"); ! ! if(!fhandle) ! { ! char sourceName[256]; ! char* temp; ! unsigned int midiSize; ! ! mkdir(midiFileName); ! fhandle = fopen(filename,"wb+"); ! ! sprintf(sourceName, "%s.hqr", midiFileName); ! ! midiSize = Size_HQR(sourceName, musicNum); ! temp = (char*)malloc(midiSize); ! ! Load_HQR(sourceName, temp, musicNum); ! fwrite(temp, midiSize,1, fhandle); ! fclose(fhandle); ! free(temp); ! } ! ! sample=Mix_LoadMUS(filename); ! ! if(sample == NULL) ! { ! printf("Mix_LoadMUS(\"%s\"): %s\n", filename, Mix_GetError()); ! } ! Mix_PlayMusic(sample,0); } Index: mainSDL.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/mainSDL.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** mainSDL.c 4 May 2005 09:08:10 -0000 1.34 --- mainSDL.c 26 Jun 2005 18:51:57 -0000 1.35 *************** *** 19,26 **** --- 19,35 ---- void studioTick(void); + #define USE_SDL_MIXER true + #define USE_OPENAL false + + #define playSounds true + #include "SDL.h" #include "SDL_thread.h" #include "lba.h" + #ifdef USE_SDL_MIXER + #include "SDL_Mixer.h" + #endif + #ifdef GAME_DEBUG #include <SDL_ttf.h> *************** *** 174,259 **** { /* int rendersolid = 0; ! int renderstyle = 0; int rendertype = 0; */ ! //int ptsize = 11; ! unsigned char *keyboard; ! int size; ! int i; ! Uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN ! rmask = 0xff000000; ! gmask = 0x00ff0000; ! bmask = 0x0000ff00; ! amask = 0x000000ff; #else ! rmask = 0x000000ff; ! gmask = 0x0000ff00; ! bmask = 0x00ff0000; ! amask = 0xff000000; #endif ! if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { ! fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); ! exit(1); } ! atexit(SDL_Quit); #ifdef GAME_DEBUG ! if (TTF_Init() < 0) { ! fprintf(stderr, "Couldn't initialize TTF: %s\n", SDL_GetError()); ! exit(1); } ! atexit(TTF_Quit); ! font = TTF_OpenFont("verdana.ttf", ptsize); ! if (font == NULL) { ! fprintf(stderr, "Couldn't load %d pt font from %s: %s\n", ptsize, "verdana.ttf", ! SDL_GetError()); ! exit(2); } ! TTF_SetFontStyle(font, renderstyle); #endif ! SDL_WM_SetCaption("Little Big Adventure: TwinEngine", "LBA"); ! // SDL_ShowCursor (SDL_DISABLE); ! // SDL_EnableUNICODE (SDL_ENABLE); // not much used in fact ! SDL_PumpEvents(); ! keyboard = SDL_GetKeyState(&size); ! keyboard[SDLK_RETURN] = 0; ! sdl_screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE/*|SDL_FULLSCREEN*/); ! if (sdl_screen == NULL) { ! fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n", SDL_GetError()); ! exit(1); } ! for (i = 0; i < 16; i++) { ! surfaceTable[i] = SDL_CreateRGBSurface(SDL_SWSURFACE, 640, 480, 32, rmask, gmask, bmask, 0); } ! osystem_mouseLeft = 0; ! osystem_mouseRight = 0; ! return 0; } --- 183,317 ---- { /* int rendersolid = 0; ! int rendertype = 0; */ ! #ifdef GAME_DEBUG ! int renderstyle = 0; ! int ptsize = 11; ! #endif ! unsigned char *keyboard; ! int size; ! int i; ! Uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN ! rmask = 0xff000000; ! gmask = 0x00ff0000; ! bmask = 0x0000ff00; ! amask = 0x000000ff; #else ! rmask = 0x000000ff; ! gmask = 0x0000ff00; ! bmask = 0x00ff0000; ! amask = 0xff000000; #endif ! if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { ! fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); ! exit(1); } ! { ! SDL_version compile_version, *link_version; ! SDL_VERSION(&compile_version); ! printf("compiled with SDL version: %d.%d.%d\n", ! compile_version.major, ! compile_version.minor, ! compile_version.patch); ! link_version=SDL_Linked_Version(); ! printf("running with SDL version: %d.%d.%d\n", ! link_version->major, ! link_version->minor, ! link_version->patch); ! } ! ! atexit(SDL_Quit); #ifdef GAME_DEBUG ! if (TTF_Init() < 0) { ! fprintf(stderr, "Couldn't initialize TTF: %s\n", SDL_GetError()); ! exit(1); } ! atexit(TTF_Quit); ! font = TTF_OpenFont("verdana.ttf", ptsize); ! if (font == NULL) { ! fprintf(stderr, "Couldn't load %d pt font from %s: %s\n", ptsize, "verdana.ttf", SDL_GetError()); ! exit(2); } ! TTF_SetFontStyle(font, renderstyle); #endif ! if(playSounds) ! { ! #ifdef USE_SDL_MIXER ! SDL_version compile_version, *link_version; ! MIX_VERSION(&compile_version); ! printf("compiled with SDL_mixer version: %d.%d.%d\n", ! compile_version.major, ! compile_version.minor, ! compile_version.patch); ! link_version=Mix_Linked_Version(); ! printf("running with SDL_mixer version: %d.%d.%d\n", ! link_version->major, ! link_version->minor, ! link_version->patch); ! // start SDL with audio support ! if(SDL_Init(SDL_INIT_AUDIO)==-1) ! { ! printf("SDL_Init: %s\n", SDL_GetError()); ! exit(1); ! } ! // open 44.1KHz, signed 16bit, system byte order, ! // stereo audio, using 1024 byte chunks ! if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)==-1) ! { ! printf("Mix_OpenAudio: %s\n", Mix_GetError()); ! exit(2); ! } ! Mix_AllocateChannels(16); ! #endif ! } ! SDL_WM_SetCaption("Little Big Adventure: TwinEngine", "LBA"); ! // SDL_ShowCursor (SDL_DISABLE); ! // SDL_EnableUNICODE (SDL_ENABLE); // not much used in fact ! SDL_PumpEvents(); ! keyboard = SDL_GetKeyState(&size); ! ! keyboard[SDLK_RETURN] = 0; ! ! sdl_screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE/*|SDL_FULLSCREEN*/); ! ! if (sdl_screen == NULL) { ! fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n", SDL_GetError()); ! exit(1); } ! for (i = 0; i < 16; i++) { ! surfaceTable[i] = SDL_CreateRGBSurface(SDL_SWSURFACE, 640, 480, 32, rmask, gmask, bmask, 0); } ! osystem_mouseLeft = 0; ! osystem_mouseRight = 0; ! return 0; } Index: HQRlib.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/HQRlib.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** HQRlib.c 18 Jun 2005 16:55:16 -0000 1.10 --- HQRlib.c 26 Jun 2005 18:51:57 -0000 1.11 *************** *** 342,346 **** streamReader_get( &fileReader, compressedDataPtr, compressedSize); - printf("DataSize: %d", dataSize); HQR_Expand(dataSize, (unsigned char*)ptr, compressedDataPtr); --- 342,345 ---- |