3131#import < OpenGL/gl.h>
3232
3333#include " freedocore.h"
34+ #include " frame.h"
3435#include " libcue.h"
3536#include " cd.h"
3637
@@ -73,12 +74,9 @@ @implementation FreeDOGameCore
7374
7475 int fver1,fver2;
7576
76- uintptr_t sampleBuffer[TEMP_BUFFER_SIZE];
77+ // uintptr_t sampleBuffer[TEMP_BUFFER_SIZE];
78+ int32_t sampleBuffer[TEMP_BUFFER_SIZE];
7779 uint sampleCurrent;
78-
79- unsigned char FIXED_CLUTR[32 ];
80- unsigned char FIXED_CLUTG[32 ];
81- unsigned char FIXED_CLUTB[32 ];
8280}
8381
8482static void * fdcCallback (int procedure, void * data)
@@ -213,12 +211,7 @@ - (id)init
213211 self = [super init ];
214212 if (self != nil )
215213 {
216- for (int j = 0 ; j < 32 ; j++)
217- {
218- FIXED_CLUTR[j] = (unsigned char )(((j & 0x1f ) << 3 ) | ((j >> 2 ) & 7 ));
219- FIXED_CLUTG[j] = FIXED_CLUTR[j];
220- FIXED_CLUTB[j] = FIXED_CLUTR[j];
221- }
214+
222215 }
223216 current = self;
224217
@@ -258,7 +251,7 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
258251
259252 currentSector = 0 ;
260253 sampleCurrent = 0 ;
261- memset (sampleBuffer, 0 , sizeof (uintptr_t )*TEMP_BUFFER_SIZE);
254+ memset (sampleBuffer, 0 , sizeof (int32_t )*TEMP_BUFFER_SIZE);
262255
263256 NSString * cue = [NSString stringWithContentsOfFile: path encoding: NSUTF8StringEncoding error: &errorCue];
264257
@@ -302,7 +295,10 @@ - (const void *)videoBuffer
302295 if (fver2==fver1)
303296 {
304297 isSwapFrameSignaled = NO ;
305- [self frame: frame toVideoBuffer: (Byte*)videoBuffer];
298+ struct BitmapCrop bmpcrop;
299+ ScalingAlgorithm sca;
300+ int rw, rh;
301+ Get_Frame_Bitmap ((VDLFrame *)frame, videoBuffer, 0 , &bmpcrop, SCREEN_WIDTH, SCREEN_HEIGHT, false , false , false , sca, &rw, &rh);
306302 fver1++;
307303 }
308304 }
@@ -312,10 +308,7 @@ - (const void *)videoBuffer
312308
313309- (OEIntRect)screenRect
314310{
315- // hope this handles hires :/
316- OEIntRect rect = OEIntRectMake (0 ,0 ,SCREEN_WIDTH, SCREEN_HEIGHT);
317- return rect;
318- // return OEIntRectMake(0, 0, frame->srcw*2, frame->srch*2);
311+ return OEIntRectMake (0 , 0 , SCREEN_WIDTH, SCREEN_HEIGHT);
319312}
320313
321314- (OEIntSize)bufferSize
@@ -333,7 +326,7 @@ - (void)setupEmulation
333326
334327 currentSector = 0 ;
335328 sampleCurrent = 0 ;
336- memset (sampleBuffer, 0 , sizeof (uintptr_t )*TEMP_BUFFER_SIZE);
329+ memset (sampleBuffer, 0 , sizeof (int32_t )*TEMP_BUFFER_SIZE);
337330}
338331
339332
@@ -601,8 +594,8 @@ - (void)fdcCallbackPushSample:(uintptr_t)sample
601594 if (sampleCurrent>TEMP_BUFFER_SIZE)
602595 {
603596 sampleCurrent = 0 ;
604- [[self ringBufferAtIndex: 0 ] write: sampleBuffer maxLength: sizeof (uintptr_t )*TEMP_BUFFER_SIZE];
605- memset (sampleBuffer, 0 , sizeof (uintptr_t )*TEMP_BUFFER_SIZE);
597+ [[self ringBufferAtIndex: 0 ] write: sampleBuffer maxLength: sizeof (int32_t )*TEMP_BUFFER_SIZE];
598+ memset (sampleBuffer, 0 , sizeof (int32_t )*TEMP_BUFFER_SIZE);
606599 }
607600}
608601
@@ -664,45 +657,4 @@ static uint32_t reverseBytes(uint32_t value)
664657 return (value & 0x000000FFU ) << 24 | (value & 0x0000FF00U ) << 8 | (value & 0x00FF0000U ) >> 8 | (value & 0xFF000000U ) >> 24 ;
665658}
666659
667- -(void ) frame : (VDLFrame*) framePtr toVideoBuffer : (Byte*) destPtr
668- {
669- int copyHeight = framePtr->srch *2 ;
670- int copyWidth = framePtr->srcw *2 ;
671- for (int line = 0 ; line < copyHeight; line++)
672- {
673- VDLLine* linePtr = &framePtr->lines [line];
674- short * srcPtr = (short *)linePtr;
675- bool allowFixedClut = (linePtr->xOUTCONTROLL & 0x2000000 ) > 0 ;
676- for (int pix = 0 ; pix < copyWidth; pix++)
677- {
678- Byte bPart = 0 ;
679- Byte gPart = 0 ;
680- Byte rPart = 0 ;
681- if (*srcPtr == 0 )
682- {
683- bPart = (Byte)(linePtr->xBACKGROUND & 0x1F );
684- gPart = (Byte)((linePtr->xBACKGROUND >> 5 ) & 0x1F );
685- rPart = (Byte)((linePtr->xBACKGROUND >> 10 ) & 0x1F );
686- }
687- else if (allowFixedClut && (*srcPtr & 0x8000 ) > 0 )
688- {
689- bPart = FIXED_CLUTB[(*srcPtr) & 0x1F ];
690- gPart = FIXED_CLUTG[((*srcPtr) >> 5 ) & 0x1F ];
691- rPart = FIXED_CLUTR[(*srcPtr) >> 10 & 0x1F ];
692- }
693- else
694- {
695- bPart = (Byte)(linePtr->xCLUTB [(*srcPtr) & 0x1F ]);
696- gPart = linePtr->xCLUTG [((*srcPtr) >> 5 ) & 0x1F ];
697- rPart = linePtr->xCLUTR [(*srcPtr) >> 10 & 0x1F ];
698- }
699- *destPtr++ = bPart;
700- *destPtr++ = gPart ;
701- *destPtr++ = rPart;
702-
703- srcPtr++;
704- }
705- }
706- }
707-
708660@end
0 commit comments