Skip to content

Commit

Permalink
Support zapper, hyper shot and arkanoid controller
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Apr 21, 2015
1 parent 9e543bb commit e9c3efd
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion FCEUGameCore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ @interface FCEUGameCore () <OENESSystemResponderClient>
int32_t *soundBuffer;
int32_t soundSize;
uint32_t pad[2][OENESButtonCount];
uint32_t arkanoid[3];
uint32_t zapper[3];
uint32_t hypershot[4];
}

@end
Expand Down Expand Up @@ -76,6 +79,9 @@ - (void)dealloc
- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
{
memset(pad, 0, sizeof(uint32_t) * OENESButtonCount);
memset(arkanoid, 0, sizeof(arkanoid));
memset(zapper, 0, sizeof(zapper));
memset(hypershot, 0, sizeof(hypershot));

//newppu = 0 default off, set 1 to enable

Expand All @@ -98,7 +104,20 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
//NSLog(@"FPS: %d", FCEUI_GetDesiredFPS() >> 24); // Hz

FCEUI_SetInput(0, SI_GAMEPAD, &pad[0], 0);
FCEUI_SetInput(1, SI_GAMEPAD, &pad[1], 0);

if(FCEUGameInfo->input[1] == SI_ZAPPER)
FCEUI_SetInput(1, SI_ZAPPER, &zapper, 0);
else if(FCEUGameInfo->input[1] == SI_ARKANOID)
FCEUI_SetInput(1, SI_ARKANOID, &arkanoid, 0);
else
FCEUI_SetInput(1, SI_GAMEPAD, &pad[1], 0);

if(FCEUGameInfo->inputfc == SIFC_SHADOW)
FCEUI_SetInputFC(SIFC_SHADOW, &hypershot, 0);
else if(FCEUGameInfo->inputfc == SIFC_ARKANOID)
FCEUI_SetInputFC(SIFC_ARKANOID, &arkanoid, 0);

//FCEUI_SetInputFourscore(true); // TODO

FCEU_ResetPalette();

Expand Down Expand Up @@ -253,6 +272,43 @@ - (oneway void)didReleaseNESButton:(OENESButton)button forPlayer:(NSUInteger)pla
pad[player - 1][0] &= ~NESMap[button] << playerShift;
}

- (oneway void)didTriggerGunAtPoint:(OEIntPoint)aPoint
{
[self mouseMovedAtPoint:aPoint];

arkanoid[2] = 1;

zapper[0] = aPoint.x;
zapper[1] = aPoint.y;
zapper[2] = 1;

hypershot[0] = aPoint.x;
hypershot[1] = aPoint.y;
hypershot[2] = 1;
}

- (oneway void)didReleaseTrigger
{
arkanoid[2] = 0;
zapper[2] = 0;
hypershot[2] = 0;
}

- (oneway void)mouseMovedAtPoint:(OEIntPoint)aPoint
{
arkanoid[0] = aPoint.x;
}

- (oneway void)rightMouseDownAtPoint:(OEIntPoint)point
{
hypershot[3] = 1; // "move" button
}

- (oneway void)rightMouseUp;
{
hypershot[3] = 0;
}

// FCEUX internal functions and stubs
void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b)
{
Expand Down

0 comments on commit e9c3efd

Please sign in to comment.