PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
Loading...
Searching...
No Matches
input/multiplay5/multiplay5.c
/*---------------------------------------------------------------------------------
snes multilplayr 5 demo
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char snesfont, snespal;
u8 i;
unsigned short pad0;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize text console with our font
consoleInitText(0, 16 * 2, &snesfont, &snespal);
// Init background
bgSetGfxPtr(0, 0x2000);
bgSetMapPtr(0, 0x6800, SC_32x32);
// Draw a wonderful text :P
consoleDrawText(7, 1, "MULTIPLAYER 5 TEST");
// Check Multiplayer 5
// if multiplayer 5 connected, need to change vblank function
{
consoleDrawText(5, 5, "USE PADS TO SEE VALUES");
consoleDrawText(0, 7, " P1 P2 P3 P4 P5");
}
// Now Put in 16 color mode
setMode(BG_MODE1, 0);
// Wait for nothing :P
while (1)
{
// if multiplayer 5 connected
{
// Get all pads values
for (i = 0; i < 5; i++)
{
pad0 = padsCurrent(i);
// Update display with current pad
switch (pad0)
{
case KEY_A:
consoleDrawText(i * 6, 8, "A");
break;
case KEY_B:
consoleDrawText(i * 6 + 1, 8, "B");
break;
case KEY_X:
consoleDrawText(i * 6 + 2, 8, "X");
break;
case KEY_Y:
consoleDrawText(i * 6 + 3, 8, "Y");
break;
case KEY_RIGHT:
case KEY_LEFT:
case KEY_DOWN:
case KEY_UP:
consoleDrawText(i * 6 + 4, 8, "D");
break;
case KEY_SELECT:
consoleDrawText(i * 6, 9, "S");
break;
case KEY_START:
consoleDrawText(i * 6 + 1, 9, "T");
break;
case KEY_R:
consoleDrawText(i * 6 + 2, 9, "R");
break;
case KEY_L:
consoleDrawText(i * 6 + 3, 9, "L");
break;
default:
consoleDrawText(i * 6, 8, " ");
consoleDrawText(i * 6, 9, " ");
break;
}
}
}
// no multiplayer 5 :(
else
{
consoleDrawText(3, 7, "NO MULTIPLAYER 5 CONNECTED!");
}
}
return 0;
}
void bgSetGfxPtr(u8 bgNumber, u16 address)
Definition of each background address.
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void bgSetMapPtr(u8 bgNumber, u16 address, u8 mapSize)
Change Background Map address.
void consoleSetTextVramAdr(u16 vramfont)
Change text graphics address (4K aligned)
void consoleInitText(u8 palnum, u8 palsize, u8 *tilfont, u8 *palfont)
Initialize the Text System.
void consoleDrawText(u16 x, u16 y, char *fmt,...)
Output formatted string on a screen (tiles mode)
void consoleSetTextOffset(u16 offsetfont)
Change text Background map address for display (must be BG address)
void consoleSetTextVramBGAdr(u16 offsetfont)
Change text Background map address for display (must be BG address)
u8 snes_mplay5
1 if MultiPlay5 is connected
#define padsCurrent(value)
Return current value of selected pad.
Definition input.h:198
@ KEY_UP
pad UP button.
Definition input.h:58
@ KEY_B
pad B button.
Definition input.h:52
@ KEY_SELECT
pad SELECT button.
Definition input.h:53
@ KEY_X
pad X button.
Definition input.h:61
@ KEY_Y
pad Y button.
Definition input.h:62
@ KEY_LEFT
pad LEFT button.
Definition input.h:56
@ KEY_START
pad START button.
Definition input.h:54
@ KEY_RIGHT
pad RIGHT button.
Definition input.h:55
@ KEY_R
Right shoulder button.
Definition input.h:59
@ KEY_A
pad A button.
Definition input.h:51
@ KEY_DOWN
pad DOWN button.
Definition input.h:57
@ KEY_L
Left shoulder button.
Definition input.h:60
void detectMPlay5(void)
Check if MultiPlayer5 is connected and populate snes_mplay5 (0 or 1 for connected)
void WaitForVBlank(void)
Waits for a VBlank interrupt.
the master include file for snes applications.
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.