ハードウェア - 傾きセンサ

Tilt Sensor cartridges (AGB-013)

The tiltsensor is found in at least 2 games:

   * Yoshi's Universal Gravitation / Yoshi Topsy Turvy
   * Wario Ware Twisted 

This info was only tested on the Yoshi game.
Registers

All of the registers are one byte wide, mapped into the top "half" of the SRAM memory range.
SRAM offset Type Description
0x8000 W Write 0x55 to start sampling?
0x8100 W Write 0xAA to start sampling?
0x8200 R Low 8 bits of X axis
0x8300 R High 4 bits of X axis, ready flag (bit 7)
0x8400 R Low 8 bits of Y axis
0x8500 R High 4 bits of Y axis

Notes:

   * SRAM is at 0x0A000000 on the DS, and at 0x0E000000 on the GBA.
   * You must set SRAM wait control to 8 clocks to access it correctly.
   * You must also set the cartridge PHI terminal to 4 MHz to make it work. 

Usage

  1. First set SRAM wait control to 8 clocks and PHI terminal output to 4 MHz. 

For the GBA, this would look like: WAIT_CR = 0x0803; or if you want faster rom speed, something like this: WAIT_CR = 0x4817;

For the DS, fixme fixme fixme!

Sampling routine (typically executed once a frame during VBlank):


bool readTiltSensor(unsigned int timeout, uint16 * tilt_x, uint16 * tilt_y) {
 int x, y;

 // Poll for the ready bit (and fetch the high 4 bits of x)
 while (timeout) {
   x = SRAM[0x8300];
   if (x & 0x80) break;
   timeout--;
 }
 if (!timeout) return false;

 // Read the rest of x and combine it with the high part
 x = SRAM[0x8200] | ((x & 0xF) << 8);

 // Read y
 y = SRAM[0x8500] & 0xF;
 y = SRAM[0x8400] | (y<<8);

 // Start another polling cycle
 SRAM[0x8000] = 0x55;
 SRAM[0x8100] = 0xAA;

 // Return the results
 *tilt_x = x;  
 *tilt_y = y;
 return true;
}


FluBBa obtained the following readings on a Yoshi cartridge:

   * X ranged between 0x2AF to 0x477, center at 0x392.
   * Y ranged between 0x2C3 to 0x480, center at 0x3A0. 

Thanks goes to FluBBa for this information.



タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2007年06月18日 09:36
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。