Пример #1
0
void GBZ80_Interrupt(int which)
{
 IFF = FALSE;
 EI_Delayed = FALSE;

 register_IF &= ~(1 << which);

 gbWriteMemory(--SP.W, PC.B.B1);
 gbWriteMemory(--SP.W, PC.B.B0);
 PC.W = 0x40 + (which << 3);
}
Пример #2
0
void MK3RandomFemale() {
	if (ChameleonChangeTime>0) {
		ChameleonChangeTime--;
		return;
	} else ChameleonChangeTime = 80;
	switch (rand() % 3) {
		case 0: // Sonya
			MK3SetPal(1, MK3_SONYA);
			gbWriteMemory(0xCD00,MK3_SONYA); // use moves from...
			break;
		case 1: // Sindel
			MK3SetPal(1, MK3_SINDEL);
			gbWriteMemory(0xCD00,MK3_SINDEL); // use moves from...
			break;
		case 2: // Sheeva
			MK3SetPal(1, MK3_SHEEVA);
			gbWriteMemory(0xCD00,MK3_SHEEVA); // use moves from...
			break;
	}
}
Пример #3
0
void MK3RandomNinja() {
	if (ChameleonChangeTime>0) {
		ChameleonChangeTime--;
		return;
	} else ChameleonChangeTime = 80;
	switch (rand() % 4) {
		case 0: // Sub-Zero
			MK3SetPal(1, MK3_SUBZERO);
			gbWriteMemory(0xCD00,MK3_SUBZERO); // use moves from...
			break;
		case 1: // Smoke
			MK3SetPal(1, MK3_SMOKE);
			gbWriteMemory(0xCD00,MK3_SMOKE); // use moves from...
			break;
		case 2: // Sektor
			MK3SetPal(1, MK3_SEKTOR, 1);
			gbWriteMemory(0xCD00,MK3_SEKTOR); // use moves from...
			break;
		case 3: // Cyrax
			MK3SetPal(1, MK3_CYRAX, 1);
			gbWriteMemory(0xCD00,MK3_CYRAX); // use moves from...
			break;
	}
}
Пример #4
0
u32 KidDraculaInput(unsigned short pad) {
	// Only Nunchuk and Classic controls available
	// Wiimote and Gamecube controls depend on user configuration
	u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeWiimote(pad) | DecodeClassic(pad);
	bool JumpButton=0, ShootButton=0, PauseButton=0, SelectButton=0, SpeedButton=0, NorButton=0, BatButton=0;
#ifdef HW_RVL
	WPADData * wp = WPAD_Data(pad);
	if (wp->exp.type == WPAD_EXP_NUNCHUK) {
		JumpButton = wp->btns_h & WPAD_BUTTON_A;
		ShootButton = wp->btns_h & WPAD_BUTTON_B;
		PauseButton = wp->btns_h & WPAD_BUTTON_PLUS;
		SelectButton = wp->btns_h & WPAD_BUTTON_MINUS;
		SpeedButton = wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2;
		NorButton = wp->btns_h & WPAD_NUNCHUK_BUTTON_Z;
		BatButton = wp->btns_h & WPAD_NUNCHUK_BUTTON_C;
	} else if (wp->exp.type == WPAD_EXP_CLASSIC) {
		JumpButton = wp->btns_h & (WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_A);
		ShootButton = wp->btns_h & WPAD_CLASSIC_BUTTON_Y;
		PauseButton = wp->btns_h & WPAD_CLASSIC_BUTTON_PLUS;
		SelectButton = wp->btns_h & WPAD_CLASSIC_BUTTON_MINUS;
		SpeedButton = wp->btns_h & (WPAD_CLASSIC_BUTTON_ZL | WPAD_CLASSIC_BUTTON_FULL_L);
		NorButton = wp->btns_h & WPAD_CLASSIC_BUTTON_X;
		BatButton = wp->btns_h & (WPAD_CLASSIC_BUTTON_ZR | WPAD_CLASSIC_BUTTON_FULL_R);
	}
#endif
	if (JumpButton) J |= VBA_BUTTON_A;
	if (ShootButton && !(KD_WeaponPressed && KD_LastWeapon != -1)) {
		J |= VBA_BUTTON_B;
		KD_LastWeapon = -1;
		// Insert original weapon and graphics
		KD_WeaponToMemory();
		gbWriteMemory(0xC8CB, KD_ActualItem);
		for (int i=0; i<64; i++) {
			gbWriteMemory(0x9110+i, KD_ACTUAL[i]);
		}
		for (int i=0; i<128; i++) {
			gbWriteMemory(0x8f40+i, KD_ACTUAL_GRAPHICS[i]);
		}
	}
	if (NorButton && !(KD_WeaponPressed && KD_LastWeapon != 0)) {
		J |= VBA_BUTTON_B;
		KD_LastWeapon = 0;
		// Insert NOR weapon and graphics
		KD_WeaponToMemory();
		gbWriteMemory(0xC8CB, 0);
		for (int i=0; i<64; i++) {
			gbWriteMemory(0x9110+i, KD_NOR[i]);
		}
		for (int i=0; i<128; i++) {
			gbWriteMemory(0x8f40+i, KD_NOR_GRAPHICS[i]);
		}
	}
	if (BatButton && !(KD_WeaponPressed && KD_LastWeapon != 4)) {
		J |= VBA_BUTTON_B;
		KD_LastWeapon = 4;
		// Insert BAT weapon and graphics
		KD_WeaponToMemory();
		gbWriteMemory(0xC8CB, 4);
		for (int i=0; i<64; i++) {
			gbWriteMemory(0x9110+i, KD_BAT[i]);
		}
	}
	if (PauseButton) J |= VBA_BUTTON_START;
	if (SelectButton) J |= VBA_BUTTON_SELECT;
	if (SpeedButton) J |= VBA_SPEED;
	KD_WeaponPressed = (ShootButton || NorButton || BatButton);
	return J;
}
Пример #5
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;
}
Пример #6
0
void MK3Impersonate(u8 appearance, u8 moves, const char *name, const char *longname = NULL) {
	gbWriteMemory(0xC0F0, appearance);
	MK3Rename(appearance, name, longname);
	if (moves!=MK3_RAND)
		gbWriteMemory(0xCD00, moves);
}
Пример #7
0
void gbWriteByte(u16 addr, u8 value) {
	if (addr>=0x8000) gbWriteMemory(addr, value);
	else gbRom[addr] = value;
}