📄 sprites.html
字号:
<HTML>
<HEAD>
<TITLE>Mappy VM SDK - The Joypad</TITLE>
<META NAME="Author" CONTENT="Michael Noland">
<META NAME="Copyright" CONTENT="(C) 2001-2002 Bottled Light, Inc.">
</HEAD>
<BODY BGCOLOR="#FFFFFF" BACKGROUND="bgtile.jpg">
<P>
<H1>Keypad Registers</H1>
There are 10 inputs available, corresponding to a 4 way direction pad, start, select, A, B, and two shoulder buttons L and R.
</P>
<P>
<TABLE BORDER="0"><TR>
<TD WIDTH="50%">
By default, the Mappy VM key bindings are as shown in the table to the right, but they can be changed at any time using the <A HREF="../help/options.html#joypad">Joypad Configuration Dialog</A> in the Options menu.
</TD>
<TD><TABLE BORDER="1" SUMMARY="Default key bindings">
<TR ALIGN="CENTER"><TD>DPad Left</TD><TD>Left cursor</TD></TR>
<TR ALIGN="CENTER"><TD>DPad Right</TD><TD>Right cursor</TD></TR>
<TR ALIGN="CENTER"><TD>DPad Up</TD><TD>Up cursor</TD></TR>
<TR ALIGN="CENTER"><TD>DPad Down</TD><TD>Down cursor</TD></TR>
<TR ALIGN="CENTER"><TD>Start</TD><TD>1</TD></TR>
<TR ALIGN="CENTER"><TD>Select</TD><TD>2</TD></TR>
<TR ALIGN="CENTER"><TD>A button</TD><TD>Z</TD></TR>
<TR ALIGN="CENTER"><TD>B button</TD><TD>X</TD></TR>
<TR ALIGN="CENTER"><TD>L shoulder</TD><TD>A</TD></TR>
<TR ALIGN="CENTER"><TD>R shoulder</TD><TD>S</TD></TR>
</TABLE></TD>
</TR></TABLE>
</P>
<HR><!------------------------------------------------------------------------->
<A NAME="keys">
<H2>Joypad Status Register (KEYS)</H2>
<TABLE BORDER="1" SUMMARY="Joypad Status Register">
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
<TD>Offset</TD><TD>Name</TD><TD>Type</TD>
<TD>F</TD><TD>E</TD><TD>D</TD><TD>C</TD><TD>B</TD><TD>A</TD><TD>9</TD><TD>8</TD>
<TD>7</TD><TD>6</TD><TD>5</TD><TD>4</TD><TD>3</TD><TD>2</TD><TD>1</TD><TD>0</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
<TD>$130</TD>
<TD>KEYS</TD>
<TD BGCOLOR="#D0D0D0">Read Only</TD>
<TD BGCOLOR="#000000" COLSPAN="6"> </TD>
<TD BGCOLOR="#D0D0D0">Left Shoulder</TD>
<TD BGCOLOR="#D0D0D0">Right Shoulder</TD>
<TD BGCOLOR="#D0D0D0">DPad Down</TD>
<TD BGCOLOR="#D0D0D0">DPad Up</TD>
<TD BGCOLOR="#D0D0D0">DPad Left</TD>
<TD BGCOLOR="#D0D0D0">DPad Right</TD>
<TD BGCOLOR="#D0D0D0">Start</TD>
<TD BGCOLOR="#D0D0D0">Select</TD>
<TD BGCOLOR="#D0D0D0">B Button</TD>
<TD BGCOLOR="#D0D0D0">A Button</TD>
</TR>
</TABLE>
<P>
<H3>Details</H3>
<UL>
<LI>Each of the low 10 bits corresponds to a key on the Mappy VM joypad, and indicates when the key is released. Thus, a pressed key will read as 0, and a released key will read as 1.</LI>
<LI>The constants in order for each key are: <CODE>KEY_A, KEY_B, KEY_SELECT, KEY_START, KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN, KEY_RSHOULDER, and KEY_LSHOULDER</CODE></LI>
</UL>
</P>
<P>
<H3>Uses and examples</H3>
<UL>
<LI>The joypad status register is the easiest way to add user input to your project, and it quite simple to use. There are no real debouncing issues, so the register can be used at any time, as shown below.</LI>
</UL>
</P>
<BLOCKQUOTE>
<EM>Example: How to poll the joypad status.</EM>
<HR><TABLE BORDER="1" BGCOLOR="#FFFFFF"><TR><TD><PRE>
uint16 keysPressed;
// Read the joypad status register and invert the bits
keysPressed = (~KEYS) & 0x3FF;
// keysPressed can be tested for any keys like this
if (keysPressed & KEY_A) {
dprintf("The A button has been pressed\n");
}
</PRE></TD></TR></TABLE></BLOCKQUOTE>
<HR><!------------------------------------------------------------------------->
<A NAME="keys_cr">
<H2>Joypad Interrupt Control Register (KEYS_CR)</H2>
<TABLE BORDER="1" SUMMARY="Joypad IRQ Control Register">
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
<TD>Offset</TD><TD>Name</TD><TD>Type</TD>
<TD>F</TD><TD>E</TD><TD>D</TD><TD>C</TD><TD>B</TD><TD>A</TD><TD>9</TD><TD>8</TD>
<TD>7</TD><TD>6</TD><TD>5</TD><TD>4</TD><TD>3</TD><TD>2</TD><TD>1</TD><TD>0</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
<TD>$132</TD>
<TD>KEYS_CR</TD>
<TD BGCOLOR="#C0FF70">Read Write</TD>
<TD BGCOLOR="#C0FF70">Condition</TD>
<TD BGCOLOR="#C0FF70">IRQ enabled</TD>
<TD BGCOLOR="#000000" COLSPAN="4"> </TD>
<TD BGCOLOR="#C0FF70">Left Shoulder</TD>
<TD BGCOLOR="#C0FF70">Right Shoulder</TD>
<TD BGCOLOR="#C0FF70">DPad Down</TD>
<TD BGCOLOR="#C0FF70">DPad Up</TD>
<TD BGCOLOR="#C0FF70">DPad Left</TD>
<TD BGCOLOR="#C0FF70">DPad Right</TD>
<TD BGCOLOR="#C0FF70">Start</TD>
<TD BGCOLOR="#C0FF70">Select</TD>
<TD BGCOLOR="#C0FF70">B Button</TD>
<TD BGCOLOR="#C0FF70">A Button</TD>
</TR>
</TABLE>
<P>
<H3>Details</H3>
<UL>
<LI><STRONG>Bits 0 to 9</STRONG> correspond the the same key in the KEYS register, and if a bit is set, that the key will participate in IRQ generation according to bits 14 and 15</LI>
<LI><STRONG>Bit 14</STRONG> is the local enable for the joypad <A HREF="glossary.html#IRQ">IRQ</A>, it must be set for an <A HREF="glossary.html#IRQ">IRQ</A> to be produced in addition to the corresponding bit in IE. The constant for this is <CODE>KEYS_CR_ENABLE</CODE>.</LI>
<LI><STRONG>Bit 15</STRONG> controls under which conditions an <A HREF="glossary.html#IRQ">IRQ</A> will be triggered.
<UL>
<LI>When 0, any key specified in bits 0 to 9 will trigger an interrupt (OR), the constant for this is <CODE>KEYS_CR_OR</CODE></LI>
<LI>When 1, all keys specified in the low 10 bits must be pressed before an interrupt will occur (AND), the constant for this is <CODE>KEYS_CR_AND</CODE></LI>
</UL>
</LI>
</UL>
</P>
<P>
<H3>Uses and examples</H3>
<UL>
<LI>The joypad interrupt is the <EM>only</EM> way to return from the low-power <A HREF="lowpower.html#stop">Stop mode</A>, which is used in some games to provide a method of preserving power while paused or disabled for a long period.</LI>
<LI>It can also be used as a general input method, using logical OR and specifiying all 10 bits as triggers. This allows event based processing of the joypad rather than a typical polling method.</LI>
</UL>
</P>
<BLOCKQUOTE>
<EM>Example: How to handle joypad input without polling.</EM>
<HR><TABLE BORDER="1" BGCOLOR="#FFFFFF"><TR><TD><PRE>
In the setup code:
// Configure the hardware to generate an interrupt when any key changes
KEYS_CR = KEYS_CR_ENABLED | KEYS_CR_OR | 0x3FF;
IE |= KEY_IRQ;
In the interrupt handler:
if (IF | KEY_IRQ) {
// Do something with the KEYS register
}
</PRE></TD></TR></TABLE></BLOCKQUOTE>
<HR><!------------------------------------------------------------------------->
<P ALIGN="center">Copyright © 2001 to 2002, Bottled Light, Inc.</P>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -