|
From: Vincent H. <ya...@us...> - 2005-06-18 16:55:32
|
Update of /cvsroot/twin-e/twin-e/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25040 Modified Files: HQRlib.c images.c mainMenu.c room.c type.h Log Message: resync Index: room.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/room.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** room.c 12 Jun 2005 20:19:29 -0000 1.31 --- room.c 18 Jun 2005 16:55:18 -0000 1.32 *************** *** 1080,1331 **** Ptr_HQM_Memory = temp; } ! /* int loadBrk(int gridSize) { ! int firstBrick; ! int lastBrick; ! int currentBrick; ! ! // int tempSize2; ! int counter; ! int counter2; ! int counter3; ! int counter6; ! int counter7; ! int offset; ! int offset2; ! ! unsigned char *endOfGridPtr; ! unsigned char *endOfGridPtr2; ! unsigned char *endOfGridPtr3; ! unsigned char *outPtr; ! unsigned short int *outPtr2; ! unsigned short int *outPtr3; ! unsigned short int *outPtr4; ! unsigned char *destPtr; ! unsigned char *compressedPtr; ! unsigned int *ptrUnk; ! ! byte temp; ! byte temp2; ! int temp3; ! int temp4; ! unsigned char *ptr1; ! unsigned char *ptr2; ! int val1; ! int val2; ! int val3; ! unsigned short int val4; ! int finalSize; ! unsigned int *localBufferBrick; ! ! FILE *file; ! int headerSize; ! int dataSize; ! int compressedSize; ! ! short int mode; ! ! firstBrick = 60000; ! lastBrick = 0; ! counter = 1; ! ! outPtr = workVideoBuffer + 153800; ! outPtr2 = (unsigned short int *) outPtr; ! ! RazMem(outPtr, 20000); ! offset = 4; ! endOfGridPtr2 = endOfGridPtr = currentGrid + (gridSize - 32); ! do { ! temp = *(endOfGridPtr2 + (counter >> 3)); ! temp2 = 7 - (counter & 7); ! ! temp3 = 1 << temp2; ! ! if (temp & temp3) { ! temp4 = *(int *) (currentBll + offset - 4); ! ptr1 = currentBll + temp4; ! ! val1 = *ptr1; ! val2 = *(ptr1 + 1); ! ! val2 *= val1; ! ! val3 = *(char *) (ptr1 + 2); ! ! val3 *= val2; ! ! ptr2 = ptr1 + 5; ! ! counter2 = 0; ! while (counter2++ < val3) { ! val4 = READ_LE_U16( ptr2 ); ! if (val4 != 0) { ! val4--; ! if (val4 <= firstBrick) ! firstBrick = val4; ! if (val4 > lastBrick) ! lastBrick = val4; ! WRITE_LE_U16(outPtr2 + val4) = 1; } ! ! ptr2 += 4; ! } ! ! } ! ! offset += 4; ! } ! while (++counter < 256); ! ! outPtr3 = outPtr2 + firstBrick; ! ! currentBrick = firstBrick; ! ! counter3 = 0; ! ! while (currentBrick <= lastBrick) ! { ! if (READ_LE_U16(outPtr3) != 0) ! counter3++; ! outPtr3++; ! currentBrick++; ! } ! ! printf("Need to load %d bricks\n", counter3); ! ! file = OpenRead("lba_brk.hqr"); ! ! if (!file) ! return (0); ! ! Read(file, (char *) &headerSize, 4); ! ! fseek(file, 0, 0); ! ! Read(file, (char *) workVideoBuffer, headerSize); ! ! counter3 *= 4; ! counter3 += 4; ! ! finalSize = counter3; // car on doit au moins avoir 1 ptr par brique ! ! headerSize = headerSize >> 2; ! ! outPtr4 = outPtr2 + firstBrick; ! ! localBufferBrick = (unsigned int *) bufferBrick; ! ! destPtr = bufferBrick + counter3; ! ! *(int *) localBufferBrick = counter3; ! ! localBufferBrick++; ! ! currentBrick = firstBrick; ! ! ptrUnk = (unsigned int *) (firstBrick * 4 + workVideoBuffer); ! ! counter6 = 0; ! ! while (currentBrick <= lastBrick) ! { ! if (*outPtr4) ! { ! counter6++; ! *outPtr4 = counter6; ! fseek(file, *ptrUnk, 0); ! ! Read(file, (char *) &dataSize, 4); ! Read(file, (char *) &compressedSize, 4); ! ! Read(file, (char *) &mode, 2); ! ! if (mode == 0) ! { ! Read(file, (char *) destPtr, dataSize); ! } ! else if (mode == 1) ! { ! compressedPtr = dataSize + destPtr - compressedSize + 500; ! Read(file, (char *) compressedPtr, compressedSize); ! Expand(dataSize, destPtr, compressedPtr); } - finalSize += dataSize; - destPtr += dataSize; - *localBufferBrick = finalSize; - localBufferBrick++; } ! ! outPtr4++; ! ptrUnk++; ! currentBrick++; } ! ! counter6 = 1; ! ! offset2 = 4; ! ! endOfGridPtr3 = endOfGridPtr = currentGrid + (gridSize - 32); ! ! do { ! temp = *(endOfGridPtr3 + (counter6 >> 3)); ! temp2 = 7 - (counter6 & 7); ! ! temp3 = 1 << temp2; ! ! if (temp & temp3) ! { ! temp4 = *(int *) (currentBll + offset2 - 4); ! ptr1 = currentBll + temp4; ! ! val1 = *ptr1; ! val2 = *(ptr1 + 1); ! ! val2 *= val1; ! ! val3 = *(char *) (ptr1 + 2); ! ! val3 *= val2; ! ! ptr2 = ptr1 + 5; ! ! counter7 = 0; ! ! while (counter7++ < val3) ! { ! val4 = *(unsigned short int *) ptr2; ! if (val4 != 0) ! { ! *(unsigned short int *) ptr2 = *(unsigned short int *) (outPtr + val4 * 2 - 2); ! ! } ! ptr2 += 4; ! } ! ! } ! ! offset2 += 4; } ! while (++counter6 < 256); ! ! Close(file); ! ! return (finalSize); ! } */ ! int loadBrk(int gridSize) { int firstBrick; --- 1080,1163 ---- Ptr_HQM_Memory = temp; } ! int loadBrk(int gridSize) { ! unsigned int firstBrick = 60000; // should be MAX_UINT ! unsigned int lastBrick = 0; // should be MIN_UINT ! unsigned char* bufferPtr; ! unsigned char* currentPositionInBuffer; ! unsigned char* ptrToBllBits; ! unsigned int i; ! unsigned int j; ! unsigned int numUsedBricks; ! unsigned int currentBllEntryIdx = 0; ! ! printf("GridSize=%d\n", gridSize); ! bufferPtr = workVideoBuffer + 153800; ! RazMem(bufferPtr, 20000); ! ptrToBllBits = currentGrid + (gridSize - 32); ! ! // build up a map of all used bricks in the room ! for(i=1;i<256;i++) { ! unsigned char currentBitByte = *(ptrToBllBits + (i/8)); ! unsigned char currentBitMask = 1 << (7-(i&7)); ! ! if(currentBitByte & currentBitMask) { ! unsigned int currentBllOffset = READ_LE_U32(currentBll + currentBllEntryIdx); ! unsigned char* currentBllPtr = currentBll + currentBllOffset; ! unsigned int bllSizeX = currentBllPtr[0]; ! unsigned int bllSizeY = currentBllPtr[1]; ! unsigned int bllSizeZ = currentBllPtr[2]; ! ! unsigned int bllSize = bllSizeX * bllSizeY * bllSizeZ; ! ! unsigned char* bllDataPtr = currentBllPtr + 5; ! ! for(j=0;j<bllSize;j++) { ! unsigned int brickIdx = READ_LE_U16(bllDataPtr); ! ! if(brickIdx) { ! brickIdx--; ! if (brickIdx <= firstBrick) ! firstBrick = brickIdx; ! if (brickIdx > lastBrick) ! lastBrick = brickIdx; ! WRITE_LE_U16(bufferPtr + brickIdx*2,1); } ! bllDataPtr += 4; } } ! currentBllEntryIdx += 4; } ! ! // compute the number of bricks to load ! currentPositionInBuffer = bufferPtr + firstBrick*2; ! numUsedBricks = 0; ! 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); ! } ! /* ! loadBrk(int gridSize) { int firstBrick; *************** *** 1372,1375 **** --- 1204,1209 ---- // short int mode; + printf("GridSize=%d\n", gridSize); + firstBrick = 60000; lastBrick = 0; *************** *** 1455,1540 **** outPtr4 = (outPtr2 + firstBrick*2); - #ifdef DREAMCAST - //DC special - { - int handler; - char name[256]; - - sprintf(name,"brick%d", currentRoom ); - - handler = debug_open( name, SNASM_O_RDONLY | SNASM_O_BINARY ); - - if(handler==-1) - { // brick not dumped yet, need to build - localBufferBrick = bufferBrick; - - destPtr = bufferBrick + counter3; - - WRITE_LE_U32(localBufferBrick,counter3); - - localBufferBrick+=4; - - currentBrick = firstBrick; - - ptrUnk = (firstBrick * 4 + workVideoBuffer); - - counter6 = 0; - - while (currentBrick <= lastBrick) - { - if (READ_LE_U16(outPtr4)) - { - counter6++; - WRITE_LE_U16(outPtr4, counter6); - - Load_HQR("LBA_BRK.HQR",destPtr,currentBrick); - dataSize = Size_HQR("LBA_BRK.HQR",currentBrick); - - finalSize += dataSize; - destPtr += dataSize; - WRITE_LE_U32(localBufferBrick,finalSize); - localBufferBrick+=4; - } - - outPtr4+=2; - ptrUnk+=4; - currentBrick++; - } - - handler = debug_open( name, SNASM_O_CREAT | SNASM_O_BINARY | SNASM_O_WRONLY ); - - debug_write( handler, (char*)&outPtr4, 4 ); - debug_write( handler, (char*)&finalSize, 4 ); - debug_write( handler, (char*)bufferBrick, 361472 ); - debug_write( handler, (char*)workVideoBuffer + 153800, 307700 - 153800 ); - - } - else - { - localBufferBrick = bufferBrick; - - destPtr = bufferBrick + counter3; - - WRITE_LE_U32(localBufferBrick,counter3); - - localBufferBrick+=4; - - currentBrick = firstBrick; - - ptrUnk = (firstBrick * 4 + workVideoBuffer); - - counter6 = 0; - - debug_read( handler, (char*)&outPtr4, 4 ); - debug_read( handler, (char*)&finalSize, 4 ); - debug_read( handler, (char*)bufferBrick, 361472 ); - debug_read( handler, (char*)workVideoBuffer + 153800, 307700 - 153800 ); - } - - debug_close( handler ); - } - - #else - localBufferBrick = bufferBrick; --- 1289,1292 ---- *************** *** 1582,1586 **** osystem_finishBricks(); #endif - #endif counter6 = 1; --- 1334,1337 ---- *************** *** 1630,1634 **** return (finalSize); } ! void RazMem(unsigned char *ptr, int size) { --- 1381,1385 ---- return (finalSize); } ! */ void RazMem(unsigned char *ptr, int size) { Index: images.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/images.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** images.c 12 Jun 2005 20:19:29 -0000 1.13 --- images.c 18 Jun 2005 16:55:17 -0000 1.14 *************** *** 205,208 **** --- 205,218 ---- } #else + #ifdef MACOSX + for (i = 0; i < 256; i++) + { + palDest[0] = palSource[0]; + palDest[1] = palSource[1]; + palDest[2] = palSource[2]; + palDest+=4; + palSource+=3; + } + #else for (i = 0; i < 256*3; i++) { *************** *** 210,213 **** --- 220,224 ---- } #endif + #endif } Index: type.h =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/type.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** type.h 12 Jun 2005 20:19:29 -0000 1.9 --- type.h 18 Jun 2005 16:55:18 -0000 1.10 *************** *** 87,91 **** FORCEINLINE uint16 READ_LE_U16(void *ptr) { ! #ifdef MACOSX return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1]; #else --- 87,91 ---- FORCEINLINE uint16 READ_LE_U16(void *ptr) { ! #ifdef MACOSX2 return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1]; #else *************** *** 96,100 **** FORCEINLINE int16 READ_LE_S16(void *ptr) { ! #ifdef MACOSX return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1]; #else --- 96,100 ---- FORCEINLINE int16 READ_LE_S16(void *ptr) { ! #ifdef MACOSX2 return (((byte*)ptr)[0]<<8)|((byte*)ptr)[1]; #else *************** *** 105,109 **** FORCEINLINE uint32 READ_LE_U32(void *ptr) { ! #ifdef MACOSX return (((byte*)ptr)[0]<<24)|(((byte*)ptr)[1]<<16)|(((byte*)ptr)[2]<<8)|((byte*)ptr)[3]; #else --- 105,109 ---- FORCEINLINE uint32 READ_LE_U32(void *ptr) { ! #ifdef MACOSX2 return (((byte*)ptr)[0]<<24)|(((byte*)ptr)[1]<<16)|(((byte*)ptr)[2]<<8)|((byte*)ptr)[3]; #else *************** *** 114,118 **** FORCEINLINE int32 READ_LE_S32(void *ptr) { ! #ifdef MACOSX return (((byte*)ptr)[0]<<24)|(((byte*)ptr)[1]<<16)|(((byte*)ptr)[2]<<8)|((byte*)ptr)[3]; #else --- 114,118 ---- FORCEINLINE int32 READ_LE_S32(void *ptr) { ! #ifdef MACOSX2 return (((byte*)ptr)[0]<<24)|(((byte*)ptr)[1]<<16)|(((byte*)ptr)[2]<<8)|((byte*)ptr)[3]; #else Index: mainMenu.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/mainMenu.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mainMenu.c 12 Jun 2005 20:19:29 -0000 1.19 --- mainMenu.c 18 Jun 2005 16:55:17 -0000 1.20 *************** *** 173,176 **** --- 173,186 ---- int chooseSave(int param) { + FILE* fHandle; + + fHandle = fopen("SAVE.LBA","rb"); + if(!fHandle) + { + return 0; + } + + fclose(fHandle); + /* var_14 = 1; var_0C = 50; Index: HQRlib.c =================================================================== RCS file: /cvsroot/twin-e/twin-e/src/HQRlib.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** HQRlib.c 12 Jun 2005 20:19:28 -0000 1.9 --- HQRlib.c 18 Jun 2005 16:55:16 -0000 1.10 *************** *** 342,345 **** --- 342,346 ---- streamReader_get( &fileReader, compressedDataPtr, compressedSize); + printf("DataSize: %d", dataSize); HQR_Expand(dataSize, (unsigned char*)ptr, compressedDataPtr); *************** *** 638,644 **** int Size_HQR(char *fileName, int index) { ! int headerSize; ! int dataSize; ! int offToData; if(!streamReader_open( &fileReader, (int8*)fileName )) --- 639,645 ---- int Size_HQR(char *fileName, int index) { ! unsigned int headerSize; ! unsigned int dataSize; ! unsigned int offToData; if(!streamReader_open( &fileReader, (int8*)fileName )) *************** *** 648,651 **** --- 649,653 ---- streamReader_get( &fileReader, &headerSize, 4 ); + headerSize = convertDWFromLE(headerSize); if(index >= headerSize /4 ) *************** *** 657,662 **** --- 659,666 ---- streamReader_seek( &fileReader, index * 4 ); streamReader_get( &fileReader, &offToData, 4 ); + offToData = convertDWFromLE(offToData); streamReader_seek( &fileReader, offToData ); streamReader_get( &fileReader, &dataSize, 4); + dataSize = convertDWFromLE(dataSize); streamReader_close( &fileReader ); |