コード例 #1
0
u32 MK1Input(unsigned short pad) {
	OurHealth = gbReadMemory(0xD695);
	OpponentHealth = gbReadMemory(0xD696);
	OurX = gbReadMemory(0xCF00);
	OpponentX = gbReadMemory(0xCF26);
	//u8 OurChar = gbReadMemory(0xD685);
	//u8 OpponentChar = gbReadMemory(0xD686);
	u8 MenuChar = gbReadMemory(0xD61D)+1;
	static u8 OldMenuChar = 0;
	// Rumble when they change character
	if (MenuChar != OldMenuChar) {
		systemGameRumble(4);
		OldMenuChar = MenuChar;
	}
	u32 J = GetMKInput(pad, 8);
	if (LK || HK || BL) J |= VBA_BUTTON_A;
	if (LP || HP || BL) J |= VBA_BUTTON_B;
	if (Start) J |= VBA_BUTTON_START;
	if (Select) J |= VBA_BUTTON_SELECT;
	// Fix kick controls to what they should be!
	if (!(J & (VBA_UP | VBA_DOWN))) {
		if (B && HK) { // Make B+HK do roundhouse, while B+LK does sweep!
			J &= ~VBA_BACK;
			J |= VBA_FORWARD;
		} else if (F && HK) { // Make F+HK do normal high kick
			J &= ~VBA_FORWARD;
		} else if (F && LK) { // Make F+LK also do normal high kick, since no low kicks
			J &= ~VBA_FORWARD;
		}
	}
	if (Throw) J |= VBA_FORWARD | VBA_BUTTON_B;
	if (CS) J |= VBA_SPEED;
	return J;
}
コード例 #2
0
ファイル: gameinput.cpp プロジェクト: alfromagario/vba-wii
void KD_WeaponToMemory() {
	// If the fourth 8x8 tile of the weapon indicator doesn't contain the "+" icon I made, the weapon has been changed in the game and has to be updated in memory.
	bool hasPlusIcon = true;
	for (int i=48; i<64; i++) {
		if (gbReadMemory(0x9110+i) != KD_BAT[i]) {
			hasPlusIcon = false;
			break;
		}
	}
	if (hasPlusIcon) return;
	
	KD_ActualItem = gbReadMemory(0xC8CB);
	for (int i=0; i<64; i++) {
		KD_ACTUAL[i] = gbReadMemory(0x9110+i);
	}
	for (int i=0; i<128; i++) {
		KD_ACTUAL_GRAPHICS[i] = gbReadMemory(0x8f40+i);
	}
}
コード例 #3
0
u32 MK2Input(unsigned short pad) {
	//u8 OurChar = gbReadMemory(0xDD01);
	//u8 OpponentChar = gbReadMemory(0xDD01+0x40);
	OurX = gbReadMemory(0xDD12) | (gbReadMemory(0xDD13) << 8);
	OpponentX = gbReadMemory(0xDD12+0x40) | (gbReadMemory(0xDD13+0x40) << 8);
	OurHealth = gbReadMemory(0xDD20);
	OpponentHealth = gbReadMemory(0xDD20+0x40);

	u32 J = GetMKInput(pad, 5);
	if (LK || HK) J |= VBA_BUTTON_A;
	if (LP || HP) J |= VBA_BUTTON_B;
	if (BL) J |= VBA_BUTTON_START;
	if (Start || Select) J |= VBA_BUTTON_SELECT;
	// Can't fix kick controls to what they should be! Sorry
	if (Throw) J |= VBA_FORWARD | VBA_BUTTON_B;
	if (CS) J |= VBA_SPEED;
	return J;
}
コード例 #4
0
u32 MK4Input(unsigned short pad)
{
	OurHealth = gbReadMemory(0xC0D6);
	OpponentHealth = gbReadMemory(0xC0D7);
	//u8 OurChar = gbReadMemory(0xC0F0); // also CD00?
	//u8 OpponentChar = gbReadMemory(0xC0F1); // also CD40, D526
	OurX = gbReadMemory(0xCD02) | (gbReadMemory(0xCD03) << 8);
	OpponentX = gbReadMemory(0xCD42) | (gbReadMemory(0xCD43) << 8);
	bool InMenu = false; // CAKTODO

	u32 J = GetMKInput(pad);
	if (LK || HK) J |= VBA_BUTTON_A;
	if (LP || HP) J |= VBA_BUTTON_B;
	if (BL) J |= VBA_BUTTON_START;
	if (Start || Select) J |= VBA_BUTTON_SELECT;
	// Fix kick controls to what they should be!
	if (!InMenu && !(J & (VBA_UP | VBA_DOWN))) {
		if (B && HK && !LK) { // Make B+HK do roundhouse, while B+LK does sweep!
			J &= ~VBA_BACK;
			J |= VBA_FORWARD;
		} else if (F && HK) { // Make F+HK do normal high kick
			J &= ~VBA_FORWARD;
		} else if (F && LK) { // Make F+LK also do normal high kick, since no low kicks
			J &= ~VBA_FORWARD;
		}
	}
	// Fix punch controls to what they should be!
	if ((!InMenu) && (J & VBA_DOWN)) {
		// Make D+LP do crouch punch instead of uppercut
		if (LP && !F && !B && !LK && !HK && !HP) { 
			J &= ~VBA_BACK;
			J |= VBA_FORWARD;
		}
	}
	// Run?
	if (CS) J |= VBA_FORWARD | VBA_BUTTON_A | VBA_BUTTON_B;
	if (Throw) J |= VBA_BUTTON_B;
	return J;
}
コード例 #5
0
ファイル: z80.cpp プロジェクト: RobertSzkutak/mednafenPSP
// Returns the number of cycles this instruction took
int GBZ80_RunOp(void)
{
 int clockTicks;
 uint8 opcode;
 gbRegister tempRegister;
 uint8 tempValue;
 int8 offset;


 // HALT will be exited even when interrupts are disabled by IFF
 if(register_IF & register_IE)
  InHALT = FALSE;

 if(IFF)
 {
  if(register_IF & register_IE & 0x01)
   GBZ80_Interrupt(0);
  else if(register_IF & register_IE & 0x02)
   GBZ80_Interrupt(1);
  else if(register_IF & register_IE & 0x04)
   GBZ80_Interrupt(2);
  else if(register_IF & register_IE & 0x08)
   GBZ80_Interrupt(3);
  else if(register_IF & register_IE & 0x10)
   GBZ80_Interrupt(4);
 }

 if(EI_Delayed)
 {
  IFF = TRUE;
  EI_Delayed = FALSE;
 }

 if(InHALT)
  return(4);

 opcode = gbReadMemory(PC.W++);

 if(RepeatNextByte)
 {
  RepeatNextByte = FALSE;
  PC.W--;
 }

 clockTicks = gbCycles[opcode];

 switch(opcode)
 {
  case 0xCB:
         // extended opcode
         opcode = gbReadMemory(PC.W++);
         clockTicks = gbCyclesCB[opcode];
         switch(opcode)
         {
          #include "gbCodesCB.h"
         }
         break;

         #include "gbCodes.h"
 }

 return(clockTicks);
}
コード例 #6
0
u32 MK3Input(unsigned short pad) {
	OurHealth = gbReadMemory(0xC0D6);
	OpponentHealth = gbReadMemory(0xC0D7);
	//u8 OurChar = gbReadMemory(0xC0F0); // 
	u8 OpponentChar = gbReadMemory(0xC0F1); // also CD40, D526
	OurX = gbReadMemory(0xCD02) | (gbReadMemory(0xCD03) << 8);
	OpponentX = gbReadMemory(0xCD42) | (gbReadMemory(0xCD43) << 8);
	bool InSelectScreen=false, InGame=false;
	if (gbReadMemory(0xC51E)==0x00 && gbReadMemory(0xC522)==0xFF) InSelectScreen = true;
	if (gbReadMemory(0xC080)==0x00 && gbReadMemory(0xC522)==0x00) InGame = true;
	static bool WasInSelectScreen = false;
	static u8 MenuChar = 0;
	static u8 MenuSubChar = 0;
	if (InSelectScreen) MenuChar = gbReadMemory(0xD4CE);
		
	static u8 OldMenuChar = 0;
	// Rumble when they change character
	if (MenuChar != OldMenuChar) {
		if (InSelectScreen && !InGame) {
			systemGameRumble(4);
			MK3SetPal(1,MenuChar);
			MK3RenameEveryoneProperlyExcept(255);
			MenuSubChar=0;
		}
		OldMenuChar = MenuChar;
	}

	// Special Characters in-game
	if (!InSelectScreen) {
		// Set opponent colour
		MK3SetPal(2, OpponentChar);
		// Our colour
		if (MenuSubChar!=0) {
			MK3SetSubchar(MenuChar, MenuSubChar);
		}
	}

	// Get input, and rumble for 2 frames if hurt
	u32 J = GetMKInput(pad, 2);
	if (LK || HK) J |= VBA_BUTTON_A;
	if (LP || HP) J |= VBA_BUTTON_B;
	if (BL) J |= VBA_BUTTON_START;
	if (Throw) {
		if (InGame) J |= VBA_BUTTON_B;
		else J |= VBA_BUTTON_START;
	}
	if (Start) {
		if (InGame) J |= VBA_BUTTON_SELECT;
		else J |= VBA_BUTTON_START;
	}
	if (Select) J |= VBA_BUTTON_SELECT;
	if (InSelectScreen && (Start || Throw || HP || LP || HK || LK || BL)) {
		J |= VBA_BUTTON_START;
	}
	// Fix kick controls to what they should be!
	if (!InSelectScreen && !(J & (VBA_UP | VBA_DOWN))) {
		if (B && HK && !LK) { // Make B+HK do roundhouse, while B+LK does sweep!
			J &= ~VBA_BACK;
			J |= VBA_FORWARD;
		} else if (F && HK) { // Make F+HK do normal high kick
			J &= ~VBA_FORWARD;
		} else if (F && LK) { // Make F+LK also do normal high kick, since no low kicks
			J &= ~VBA_FORWARD;
		}
	}
	// Fix punch controls to what they should be!
	if ((!InSelectScreen) && (J & VBA_DOWN)) {
		// Make D+LP do crouch punch instead of uppercut
		if (LP && !F && !B && !LK && !HK && !HP) { 
			J &= ~VBA_BACK;
			J |= VBA_FORWARD;
		}
	}
	// Run, sometimes does roundhouse kick (Midway's fault, not mine)
	if (CS && InGame) J |= VBA_FORWARD | VBA_BUTTON_A | VBA_BUTTON_B;
	// Allow to choose secret characters from menu
	static bool CancelMovement = false;
	if (InSelectScreen) {
		if ((MenuChar==1 && (J & VBA_DOWN))
		|| (MenuChar==3 && (J & VBA_RIGHT))
		|| (MenuChar==5 && (J & VBA_LEFT))
		|| (MenuChar==7 && (J & VBA_UP))) {
			CancelMovement = true;
			gbWriteMemory(0xD4CE,4);
		} else if (MenuChar==8 && (J & VBA_RIGHT)) {
			gbWriteMemory(0xD4CE,MK3_SHAOKHAN);
		}
		if (CancelMovement) {
			if (J & (VBA_RIGHT | VBA_LEFT | VBA_UP | VBA_DOWN))
				J &= ~(VBA_RIGHT | VBA_LEFT | VBA_UP | VBA_DOWN);
			else CancelMovement = false;
		}
		WasInSelectScreen = true;
	} else {
		CancelMovement = false;
		if (WasInSelectScreen) {
			// We just chose a character, so apply anything special here
			// Cyborg Sub-Zero
			if (MenuChar==MK3_SUBZERO && MenuSubChar==1)
				gbWriteMemory(0xD4CE,MK3_SEKTOR);			
			// Frost
			else if (MenuChar==MK3_SUBZERO && MenuSubChar==3)
				gbWriteMemory(0xD4CE,MK3_SINDEL);			
			// Cyborg Kano
			else if (MenuChar==MK3_KANO && MenuSubChar==1)
				gbWriteMemory(0xD4CE,MK3_SEKTOR);			
			// Cyborg Kabal
			else if (MenuChar==MK3_KABAL && MenuSubChar==1)
				gbWriteMemory(0xD4CE,MK3_SEKTOR);
			// Human Cyrax
			else if (MenuChar==MK3_CYRAX && MenuSubChar==1)
				gbWriteMemory(0xD4CE,MK3_SUBZERO);
			// Human Sektor
			else if (MenuChar==MK3_SEKTOR && MenuSubChar==1)
				gbWriteMemory(0xD4CE,MK3_SUBZERO);
			// Human Smoke, Reptile, Scorpion
			else if (MenuChar==MK3_SMOKE && MenuSubChar>=1)
				gbWriteMemory(0xD4CE,MK3_SUBZERO);
			// Reiko
			else if (MenuChar==MK3_SHAOKHAN && MenuSubChar==1)
				gbWriteMemory(0xD4CE,MK3_SUBZERO);
			WasInSelectScreen = false;
		}
	}

	bool CostumeButton = InSelectScreen && (CS || (J & VBA_BUTTON_SELECT)); // Change Style/Select changes costume
	static bool OldCostumeButton = 0;

	if (CostumeButton && !OldCostumeButton) {
		int OldSubChar = MenuSubChar;
		MenuSubChar = MK3SetSubchar(MenuChar, MenuSubChar+1, true);
		if (MenuSubChar!=OldSubChar) systemGameRumble(8);
	}
	OldCostumeButton = CostumeButton;
	//DebugPrintf("%d,%d C=%d M=%d", MenuChar,MenuSubChar,gbReadMemory(0xC0F0),gbReadMemory(0xCD00));

	return J;
}