|
From: Vincent H. <ya...@us...> - 2005-10-02 22:50:40
|
Update of /cvsroot/twin-e/twin-e/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29856/src Modified Files: HQRlib.c flaplayer.c fullRedraw.c mainLoop.c mainMenu.c renderer.c streamReader.c streamReader.h Log Message: Fix bunch of memory corruption Index: renderer.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/renderer.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** renderer.c 28 Jun 2005 21:55:48 -0000 1.24 --- renderer.c 2 Oct 2005 14:13:30 -0000 1.25 *************** *** 176,179 **** --- 176,181 ---- int temp; + assert(frontVideoBufferbis == frontVideoBuffer); + _numOfPoints = READ_LE_U16(costumePtr); costumePtr += 2; *************** *** 330,333 **** --- 332,337 ---- ptr3 = pri2Ptr2 = _partsPtr2 + 18; + assert(frontVideoBufferbis == frontVideoBuffer); + do { *************** *** 387,390 **** --- 391,395 ---- }while (--_numOfPrimitives); } + assert(frontVideoBufferbis == frontVideoBuffer); return (finishRender((unsigned char *) _shadePtr)); *************** *** 762,765 **** --- 767,772 ---- esi += 2; + assert(frontVideoBufferbis == frontVideoBuffer); + if (temp) // if there is polygones { *************** *** 1031,1034 **** --- 1038,1043 ---- renderTabEntryPtr2 = renderTab; + assert(frontVideoBufferbis == frontVideoBuffer); + renderTabSortedPtr = renderTabSorted; for (i = 0; i < _numOfPrimitives; i++) // then we sort the polygones (FIXME: very slow !) *************** *** 1056,1059 **** --- 1065,1070 ---- renderTabEntryPtr2++;*/ + assert(frontVideoBufferbis == frontVideoBuffer); + if (_numOfPrimitives) { *************** *** 1082,1091 **** color = (READ_LE_S32(&lineCoordinatesPtr->data) & 0xFF00) >> 8; ! x1 = READ_LE_U16((unsigned short int*)&lineCoordinatesPtr->x1); ! y1 = READ_LE_U16((unsigned short int*)&lineCoordinatesPtr->y1); ! x2 = READ_LE_U16((unsigned short int*)&lineCoordinatesPtr->x2); ! y2 = READ_LE_U16((unsigned short int*)&lineCoordinatesPtr->y2); drawLine(x1,y1,x2,y2,color); break; } --- 1093,1106 ---- color = (READ_LE_S32(&lineCoordinatesPtr->data) & 0xFF00) >> 8; ! x1 = READ_LE_S16((unsigned short int*)&lineCoordinatesPtr->x1); ! y1 = READ_LE_S16((unsigned short int*)&lineCoordinatesPtr->y1); ! x2 = READ_LE_S16((unsigned short int*)&lineCoordinatesPtr->x2); ! y2 = READ_LE_S16((unsigned short int*)&lineCoordinatesPtr->y2); + assert(frontVideoBufferbis == frontVideoBuffer); + drawLine(x1,y1,x2,y2,color); + + assert(frontVideoBufferbis == frontVideoBuffer); break; } *************** *** 1111,1116 **** --- 1126,1138 ---- } + assert(frontVideoBufferbis == frontVideoBuffer); + if (ComputePoly_A() != 2) + { + assert(frontVideoBufferbis == frontVideoBuffer); FillVertic_A(FillVertic_AType, color); + } + + assert(frontVideoBufferbis == frontVideoBuffer); break; *************** *** 1170,1174 **** --- 1192,1198 ---- circleParam3-=3; + assert(frontVideoBufferbis == frontVideoBuffer); circle_fill(circleParam4, circleParam5, circleParam3, circleParam1); + assert(frontVideoBufferbis == frontVideoBuffer); /*prepareCircle(circleParam3*/ *************** *** 1224,1229 **** return;*/ ! if(vbottom >= 480) return; out = frontVideoBuffer + 640*vtop; --- 1248,1262 ---- return;*/ ! if(vtop<0) ! { ! return; ! } ! ! if(vbottom >= 479) ! { return; + } + + assert(frontVideoBufferbis == frontVideoBuffer); out = frontVideoBuffer + 640*vtop; *************** *** 1538,1541 **** --- 1571,1576 ---- if(currentXPos>=0 && currentXPos<640) *(out2)=(unsigned char)(((startColor + stopColor)/2)>>8); + + assert(frontVideoBufferbis == frontVideoBuffer); } else *************** *** 1553,1556 **** --- 1588,1593 ---- if(currentXPos>=0 && currentXPos<640) *(out2) = currentColor>>8; + + assert(frontVideoBufferbis == frontVideoBuffer); currentColor&=0xFF; startColor+=colorSize; *************** *** 1561,1564 **** --- 1598,1603 ---- if(currentXPos>=0 && currentXPos<640) *(out2+1) = currentColor>>8; + + assert(frontVideoBufferbis == frontVideoBuffer); } else if(hsize==2) *************** *** 1576,1579 **** --- 1615,1620 ---- *(out2) = currentColor>>8; + assert(frontVideoBufferbis == frontVideoBuffer); + out2++; currentXPos++; *************** *** 1587,1590 **** --- 1628,1633 ---- *(out2) = currentColor>>8; + assert(frontVideoBufferbis == frontVideoBuffer); + currentColor&=0xFF; startColor+=colorSize; *************** *** 1596,1599 **** --- 1639,1644 ---- if(currentXPos>=0 && currentXPos<640) *(out2+1) = currentColor>>8; + + assert(frontVideoBufferbis == frontVideoBuffer); } else *************** *** 1613,1616 **** --- 1658,1663 ---- if(currentXPos>=0 && currentXPos<640) *(out2) = currentColor>>8; + + assert(frontVideoBufferbis == frontVideoBuffer); out2++; currentXPos++; *************** *** 1628,1631 **** --- 1675,1680 ---- if(currentXPos>=0 && currentXPos<640) *(out2) = currentColor>>8; + + assert(frontVideoBufferbis == frontVideoBuffer); currentXPos++; currentColor&=0xFF; *************** *** 1637,1640 **** --- 1686,1690 ---- *(out2+1) = currentColor>>8; + assert(frontVideoBufferbis == frontVideoBuffer); currentXPos++; out2+=2; *************** *** 1648,1651 **** --- 1698,1702 ---- currentLine++; }while(--renderLoop); + assert(frontVideoBufferbis == frontVideoBuffer); break; } *************** *** 1658,1661 **** --- 1709,1714 ---- } }; + + assert(frontVideoBufferbis == frontVideoBuffer); } *************** *** 1707,1764 **** ptr1[1] = pRenderV1[1]; ptr1[2] = pRenderV1[2]; - - if (vbottom < vtop) - return (0); /* ! if (vleft < textWindowLeft) ! { ! if (vright < textWindowLeft) ! return (0); ! // pRenderSub(); ! // printf("3Dcropping...\n"); ! // exit(1); ! // if(vright==textWindowLeft) ! return (2); ! } ! ! if (vright > textWindowRight) ! { ! if (vleft > textWindowRight) ! return (0); ! // pRenderSub2(); ! // printf("3Dcropping...\n"); ! // exit(1); ! // if(vleft==textWindowRight) ! return (2); ! } ! ! if (vtop < textWindowTop) ! { ! if (vbottom < textWindowTop) ! return (0); ! // pRenderSub3(); ! // printf("3Dcropping...\n"); ! // exit(1); ! // if(vbottom==textWindowBottom) ! return (2); ! } ! ! if (vbottom > textWindowBottom) ! { ! if (vtop > textWindowBottom) ! return (0); ! // pRenderSub4(); ! // printf("3Dcropping...\n"); ! // exit(1); ! // if(vtop==textWindowBottom) ! return (2); ! } ! ! if (polyCropped) ! { ! printf("ComputePoly_A-> cropped poly !\n"); ! exit(1); ! }*/ ! ptr1 = pRenderV1; // on retourne au debut de la liste --- 1760,1773 ---- ptr1[1] = pRenderV1[1]; ptr1[2] = pRenderV1[2]; /* ! if(vleft<0) ! return 2; ! if(vright>=640) ! return 2; ! if(vtop<0) ! return 2; ! if(vbottom>=480) ! return 2; ! */ ptr1 = pRenderV1; // on retourne au debut de la liste *************** *** 1837,1841 **** { // *(ptr3)=((temp7&0xFFFF0000)>>16); ! *(ptr3) = (short int) vfloat2; ptr3 += direction; // temp7+=step; --- 1846,1851 ---- { // *(ptr3)=((temp7&0xFFFF0000)>>16); ! if((ptr3-polyTab) < 960) ! *(ptr3) = (short int) vfloat2; ptr3 += direction; // temp7+=step; *************** *** 1891,1895 **** for (i = 0; i < oldVertexX; i++) { ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp += test.temp; --- 1901,1906 ---- for (i = 0; i < oldVertexX; i++) { ! if((ptr3-polyTab2) < 960) ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp += test.temp; *************** *** 1938,1942 **** for (i = 0; i <= oldVertexX; i++) { ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp -= test.temp; --- 1949,1954 ---- for (i = 0; i <= oldVertexX; i++) { ! if((ptr3-polyTab2) < 960) ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp -= test.temp; *************** *** 1999,2003 **** { // *(ptr3)=((temp7&0xFFFF0000)>>16); ! *(ptr3) = (short int) vfloat2; ptr3 += direction; // temp7+=step; --- 2011,2016 ---- { // *(ptr3)=((temp7&0xFFFF0000)>>16); ! if((ptr3-polyTab) < 960) ! *(ptr3) = (short int) vfloat2; ptr3 += direction; // temp7+=step; *************** *** 2053,2057 **** for (i = 0; i < oldVertexX; i++) { ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp += test.temp; --- 2066,2071 ---- for (i = 0; i < oldVertexX; i++) { ! if((ptr3-polyTab2) < 960) ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp += test.temp; *************** *** 2100,2104 **** for (i = 0; i <= oldVertexX; i++) { ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp -= test.temp; --- 2114,2119 ---- for (i = 0; i <= oldVertexX; i++) { ! if((ptr3-polyTab2) < 960) ! *(ptr3) = reste.temp; ptr3 += direction; reste.temp -= test.temp; *************** *** 2192,2195 **** --- 2207,2211 ---- } + assert(frontVideoBufferbis == frontVideoBuffer); out = frontVideoBuffer + screenLockupTable[b] + a; Index: fullRedraw.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/fullRedraw.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** fullRedraw.c 28 Jun 2005 21:55:47 -0000 1.60 --- fullRedraw.c 2 Oct 2005 14:13:30 -0000 1.61 *************** *** 60,63 **** --- 60,65 ---- int spriteHeight; + assert(frontVideoBufferbis == frontVideoBuffer); + temp1 = fullRedrawVar1; temp2 = fullRedrawVar2; *************** *** 1832,1835 **** --- 1834,1839 ---- ptr = brickMaskTable[spriteNum]; + assert(ptr); + left = x + *(ptr + 2); top = y + *(ptr + 3); Index: mainLoop.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/mainLoop.c,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** mainLoop.c 28 Jun 2005 21:55:47 -0000 1.52 --- mainLoop.c 2 Oct 2005 14:13:30 -0000 1.53 *************** *** 470,473 **** --- 470,475 ---- // 2nd boucle de process des acteurs + assert(frontVideoBufferbis == frontVideoBuffer); + for (i = 0; i < numActorInRoom; i++) { *************** *** 587,590 **** --- 589,594 ---- #endif + assert(frontVideoBufferbis == frontVideoBuffer); + if ( !disableScreenRecenter) { Index: streamReader.h =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/streamReader.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** streamReader.h 4 May 2005 08:18:40 -0000 1.5 --- streamReader.h 2 Oct 2005 14:13:30 -0000 1.6 *************** *** 56,60 **** typedef struct streamReader streamReader; ! boolean streamReader_open(streamReader* pThis, const int8* fileName); void streamReader_close(streamReader* pThis); void streamReader_feedBuffer(streamReader* pThis); --- 56,60 ---- typedef struct streamReader streamReader; ! boolean streamReader_open(streamReader* pThis, const int8* fileName, int fatal); void streamReader_close(streamReader* pThis); void streamReader_feedBuffer(streamReader* pThis); Index: flaplayer.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/flaplayer.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** flaplayer.c 21 Jul 2004 19:40:51 -0000 1.19 --- flaplayer.c 2 Oct 2005 14:13:30 -0000 1.20 *************** *** 168,172 **** int i; ! streamReader_open(&fla_streamReader, (const int8*)file); workVideoBufferCopy=workVideoBuffer; --- 168,172 ---- int i; ! streamReader_open(&fla_streamReader, (const int8*)file,0); workVideoBufferCopy=workVideoBuffer; Index: streamReader.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/streamReader.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** streamReader.c 4 May 2005 20:26:21 -0000 1.5 --- streamReader.c 2 Oct 2005 14:13:30 -0000 1.6 *************** *** 102,106 **** #endif ! boolean streamReader_open(streamReader* pThis, const int8* fileName) { #ifndef DREAMCAST --- 102,106 ---- #endif ! boolean streamReader_open(streamReader* pThis, const int8* fileName, int fatal) { #ifndef DREAMCAST *************** *** 122,125 **** --- 122,130 ---- else { + if(fatal) + { + printf("FATAL: Can't find %s\n", fileName); + exit(-1); + } return false; } Index: mainMenu.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/mainMenu.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** mainMenu.c 18 Jun 2005 16:55:17 -0000 1.20 --- mainMenu.c 2 Oct 2005 14:13:30 -0000 1.21 *************** *** 404,409 **** else { ! blitRectangle(left, top, right, bottom, (char *) workVideoBuffer, left, top, ! (char *) frontVideoBuffer); right2 = right; drawBoxInsideTrans(left, top, right2, bottom, 4); --- 404,408 ---- else { ! blitRectangle(left, top, right, bottom, (char *) workVideoBuffer, left, top,(char *)frontVideoBuffer); right2 = right; drawBoxInsideTrans(left, top, right2, bottom, 4); *************** *** 638,679 **** void blitRectangle(int left, int top, int right, int bottom, char *source, int leftDest, int topDest, char *dest) { ! int largeur; ! int hauteur; ! char *s; ! char *d; ! int interligne; ! int temp3; ! int i; ! int j; ! assert(left >= 0); ! assert(right < 640); ! assert(top >= 0); ! assert(bottom < 480); ! s = screenLockupTable[top] + source + left; ! d = screenLockupTable[topDest] + dest + leftDest; ! largeur = right - left + 1; ! hauteur = bottom - top + 1; ! interligne = largeurEcran - largeur; ! temp3 = left; ! left >>= 2; ! temp3 &= 3; ! for(j = 0; j < hauteur; j++) { ! for (i = 0; i < largeur; i++) { ! *(d++) = *(s++); } ! d += interligne; ! s += interligne; } } --- 637,678 ---- void blitRectangle(int left, int top, int right, int bottom, char *source, int leftDest, int topDest, char *dest) { ! int largeur; ! int hauteur; ! char *s; ! char *d; ! int interligne; ! int temp3; ! int i; ! int j; ! assert(left >= 0); ! assert(right < 640); ! assert(top >= 0); ! assert(bottom < 480); ! s = screenLockupTable[top] + source + left; ! d = screenLockupTable[topDest] + dest + leftDest; ! largeur = right - left + 1; ! hauteur = bottom - top + 1; ! interligne = largeurEcran - largeur; ! temp3 = left; ! left >>= 2; ! temp3 &= 3; ! for(j = 0; j < hauteur; j++) { ! for (i = 0; i < largeur; i++) { ! *(d++) = *(s++); } ! d += interligne; ! s += interligne; } } Index: HQRlib.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/HQRlib.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** HQRlib.c 28 Jun 2005 21:55:47 -0000 1.12 --- HQRlib.c 2 Oct 2005 14:13:30 -0000 1.13 *************** *** 305,309 **** unsigned short int mode; ! if(!streamReader_open( &fileReader, (int8*) resourceName )) return 0; --- 305,309 ---- unsigned short int mode; ! if(!streamReader_open( &fileReader, (int8*) resourceName, 1)) return 0; *************** *** 442,446 **** Size_HQR(hqrPtr->fileName, arg_4); ! if(!streamReader_open( &fileReader, (int8*) hqrPtr->fileName )) return 0; --- 442,446 ---- Size_HQR(hqrPtr->fileName, arg_4); ! if(!streamReader_open( &fileReader, (int8*) hqrPtr->fileName, 1 )) return 0; *************** *** 590,594 **** unsigned char *temp; ! if(!streamReader_open( &fileReader, (int8*)fileName )) return(-1); --- 590,594 ---- unsigned char *temp; ! if(!streamReader_open( &fileReader, (int8*)fileName, 1 )) return(-1); *************** *** 647,651 **** unsigned int offToData; ! if(!streamReader_open( &fileReader, (int8*)fileName )) { return 0; --- 647,651 ---- unsigned int offToData; ! if(!streamReader_open( &fileReader, (int8*)fileName, 1 )) { return 0; |