Skip to content

Commit 272d29e

Browse files
committed
Update to the latest 4DO (mostly whitespace changes besides a 'fix' in DSP.cpp) and fixed audio in core implementation
1 parent 9036ef2 commit 272d29e

File tree

10 files changed

+506
-299
lines changed

10 files changed

+506
-299
lines changed

4DO.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@
5858
575ACC341582D50400EAC45A /* time.c in Sources */ = {isa = PBXBuildFile; fileRef = 575ACBF91582C37400EAC45A /* time.c */; };
5959
575ACC391582D51900EAC45A /* liblibcue.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 575ACC271582D4F000EAC45A /* liblibcue.a */; };
6060
575ACC3A1582D51900EAC45A /* liblibfreedo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 575ACC131582D4BE00EAC45A /* liblibfreedo.a */; };
61-
57C189551581E581007AC24B /* freedoconfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57C189541581E581007AC24B /* freedoconfig.cpp */; };
6261
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
6362
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
6463
942597C515146FF40074E3A3 /* OpenEmuBase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 942597C415146FF40074E3A3 /* OpenEmuBase.framework */; };
64+
94551A1019A570170080929A /* frame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94551A0E19A570170080929A /* frame.cpp */; };
65+
94551A1119A570170080929A /* frame.h in Headers */ = {isa = PBXBuildFile; fileRef = 94551A0F19A570170080929A /* frame.h */; };
6566
94D9257314CA9879008F697D /* FreeDOGameCore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 826FE0F41014D8930023A8E9 /* FreeDOGameCore.mm */; };
6667
/* End PBXBuildFile section */
6768

@@ -166,13 +167,14 @@
166167
578D12401582B03F003F64E5 /* vdlp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vdlp.h; sourceTree = "<group>"; };
167168
578D12411582B03F003F64E5 /* XBUS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBUS.cpp; sourceTree = "<group>"; };
168169
578D12421582B03F003F64E5 /* XBUS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBUS.h; sourceTree = "<group>"; };
169-
57C189541581E581007AC24B /* freedoconfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = freedoconfig.cpp; sourceTree = "<group>"; };
170170
826FE0F31014D8930023A8E9 /* FreeDOGameCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FreeDOGameCore.h; sourceTree = "<group>"; };
171171
826FE0F41014D8930023A8E9 /* FreeDOGameCore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FreeDOGameCore.mm; sourceTree = "<group>"; };
172172
82B91C841015267F007BD6DB /* libco.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libco.a; sourceTree = "<group>"; };
173173
8D5B49B6048680CD000E48DA /* 4DO.oecoreplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = 4DO.oecoreplugin; sourceTree = BUILT_PRODUCTS_DIR; };
174174
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
175175
942597C415146FF40074E3A3 /* OpenEmuBase.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenEmuBase.framework; path = ../OpenEmu/build/Release/OpenEmuBase.framework; sourceTree = "<group>"; };
176+
94551A0E19A570170080929A /* frame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = frame.cpp; sourceTree = "<group>"; };
177+
94551A0F19A570170080929A /* frame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = frame.h; sourceTree = "<group>"; };
176178
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
177179
/* End PBXFileReference section */
178180

@@ -241,7 +243,6 @@
241243
578D12261582B03E003F64E5 /* libfreedo */,
242244
826FE0F31014D8930023A8E9 /* FreeDOGameCore.h */,
243245
826FE0F41014D8930023A8E9 /* FreeDOGameCore.mm */,
244-
57C189541581E581007AC24B /* freedoconfig.cpp */,
245246
37E8246D172B7BEB00E58D77 /* OE3DOSystemResponderClient.h */,
246247
);
247248
name = Classes;
@@ -314,6 +315,8 @@
314315
578D122F1582B03E003F64E5 /* DiagPort.h */,
315316
578D12301582B03E003F64E5 /* DSP.cpp */,
316317
578D12311582B03E003F64E5 /* DSP.h */,
318+
94551A0E19A570170080929A /* frame.cpp */,
319+
94551A0F19A570170080929A /* frame.h */,
317320
578D12321582B03E003F64E5 /* freedoconfig.h */,
318321
578D12331582B03F003F64E5 /* freedocore.h */,
319322
578D12341582B03F003F64E5 /* Iso.cpp */,
@@ -340,6 +343,7 @@
340343
isa = PBXHeadersBuildPhase;
341344
buildActionMask = 2147483647;
342345
files = (
346+
94551A1119A570170080929A /* frame.h in Headers */,
343347
);
344348
runOnlyForDeploymentPostprocessing = 0;
345349
};
@@ -495,6 +499,7 @@
495499
575ACC201582D4E200EAC45A /* SPORT.cpp in Sources */,
496500
575ACC211582D4E200EAC45A /* vdlp.cpp in Sources */,
497501
575ACC221582D4E200EAC45A /* XBUS.cpp in Sources */,
502+
94551A1019A570170080929A /* frame.cpp in Sources */,
498503
);
499504
runOnlyForDeploymentPostprocessing = 0;
500505
};
@@ -518,7 +523,6 @@
518523
buildActionMask = 2147483647;
519524
files = (
520525
94D9257314CA9879008F697D /* FreeDOGameCore.mm in Sources */,
521-
57C189551581E581007AC24B /* freedoconfig.cpp in Sources */,
522526
);
523527
runOnlyForDeploymentPostprocessing = 0;
524528
};

FreeDOGameCore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
@class OERingBuffer;
3232

33-
#define SCREEN_WIDTH 640
34-
#define SCREEN_HEIGHT 480
33+
#define SCREEN_WIDTH 320
34+
#define SCREEN_HEIGHT 240
3535

3636

3737
struct VolumeHeader // 132 bytes

FreeDOGameCore.mm

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
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

8482
static 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

freedoconfig.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)