gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/gb/mbc7_accelerometer/Readme.md
1 # GBDK example for using the Accelerometer sensor on the Game Boy MBC7 Cartridge
2 This example demonstrates using data from the accelerometer sensor on MBC7 cartridges
3 such as used by Kirby Tilt 'n' Tumble.
4
5 # Important hardware information
6 Do not use regular `vsync()` or `wait_vbl_done()` for at least `1.2 msec` after
7 triggering a latch of the accelerometer data (in this example with `mbc7_accel_read()`).
8 Doing that will cause the MBC7 accelerometer sensor to return errors in the data.
9
10 This is because `vsync()` puts the CPU into `HALT` (until the next frame)
11 which turns off the cartridge PHI clock. The MBC7 cartridge relies
12 on that clock to accurately sample the accelerometer sensor.
13
14 This example provides an alternative `vsync_no_halt()` that is safe to use
15 without concern for timing limitations. It may result in slightly higher
16 battery usage since the CPU will not enter the `HALT` state.
17
18 # Emulators
19 At present most emulators do not fully emulate the MBC7 cartridge hardware,
20 in particular the latching behavior mentioned above. In some cases the range
21 of outputs data is different. So when testing, if possible, include a MBC7
22 cartridge as part of the process.
23
24 Some example ranges for the sensor data:
25
26 ```
27 Slow rotation, measuring mostly the pull
28 earth's gravity when the sensor not flat.
29 The range is for a full rotation of 90 degrees from flat.
30
31 Note: The ranges below are for regular single-speed
32 processor mode. In GBC Double-speed mode there appears
33 to be an offset of around +440 on the X axis and +480
34 on the Y axis when the cart is flat/centered.
35
36 X: Left Centered Right
37 0x8230 <------- 0x81BC -------> 0x8148
38 +116 0 -116
39
40 Y: Forward Centered Backward
41 0x8253 <------- 0x81DE -------> 0x8170
42 +117 0 -110
43
44
45 Higher end ranges for fast horizontal movements
46
47 X: Left Centered Right
48 0x837E <------- 0x81BC -------> 0x8000
49 +450 0 -444
50
51 Y: Forward Centered Backward
52 0x837D <------- 0x81DE -------> 0x8020
53 +416 0 -446
54 ```
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.