Control Overview
Una Aventura Inesperada utilizes both Nintendo DS screens:- Top Screen: Game world (tile-based puzzle grid)
- Bottom Screen: HUD, menus, dialogs, and touch controls
The game uses hardware interrupts for responsive input handling via
ConfigurarInterrupciones() (source/main.c:242-260).D-Pad Movement
The D-pad controls player movement on the grid. Movement is handled by theTeclasJugador() interrupt function (source/main.c:271-437).
Movement Keys
Up
D-Pad Up
REG_KEYINPUT == 0x03BFMoves player 2 tiles northDown
D-Pad Down
REG_KEYINPUT == 0x037FMoves player 2 tiles southLeft
D-Pad Left
REG_KEYINPUT == 0x03DFMoves player 2 tiles westRight
D-Pad Right
REG_KEYINPUT == 0x03EFMoves player 2 tiles eastInput Values
TheREG_KEYINPUT register contains button states. Each direction has a unique hexadecimal value:
Understanding REG_KEYINPUT Values
Understanding REG_KEYINPUT Values
The NDS
REG_KEYINPUT register uses inverted logic (0 = pressed, 1 = released):- Bit 0: A button
- Bit 1: B button
- Bit 2: Select
- Bit 3: Start
- Bit 4: Right
- Bit 5: Left
- Bit 6: Up
- Bit 7: Down
- Bits 8-9: R/L triggers
0x03BF, 0x037F, etc. represent specific button combinations where only the directional bit is 0 (pressed).Movement Execution
- Up Movement
- Down Movement
- Left Movement
- Right Movement
Movement Constraints
Every movement input must satisfy these conditions:Touch Screen Controls
The bottom screen provides touch-based navigation for menus and dialogs.Touch Input Detection
Touch input is detected using the NDS touch API:Main Menu Controls
The main menu has three touch buttons:Start Game
Position: (66, 70) to (184, 93)Size: 118×23 pixelsStarts opening cinematic and Level 1
Credits
Position: (66, 134) to (184, 158)Size: 118×24 pixelsDisplays credits screen
Back
Position: (65, 162) to (184, 187)Size: 119×25 pixelsReturns from credits to main menu
Dialog/Quiz Controls
Quiz questions display two answer buttons:Restart Button
During gameplay, the HUD displays a restart button:- Position: (117, 100)
- Size: 119×25 pixels
- Function: Restarts current level immediately
- Availability: Only active when
esActivoBotonReinicio == true
The restart button is disabled during dialogs to prevent accidental level resets while answering quiz questions.
Button Mapping Reference
Hardware Buttons
| Button | REG_KEYINPUT Value | Function | Usage |
|---|---|---|---|
| D-Pad Up | 0x03BF | Move North | Player movement |
| D-Pad Down | 0x037F | Move South | Player movement |
| D-Pad Left | 0x03DF | Move West | Player movement |
| D-Pad Right | 0x03EF | Move East | Player movement |
| Touch Screen | KEY_TOUCH | Select | Menus, dialogs, restart |
Unused Buttons
Unused Buttons
Touch Screen Regions
| Region | Coordinates | Size | Context | Action |
|---|---|---|---|---|
| Start Game | (66,70) → (184,93) | 118×23 | Main Menu | Begin game |
| Credits | (66,134) → (184,158) | 118×24 | Main Menu | View credits |
| Back | (65,162) → (184,187) | 119×25 | Credits | Return to menu |
| Answer 1 | (50,138) → (213,161) | 163×23 | Quiz | Select option 0 |
| Answer 2 | (50,165) → (213,189) | 163×24 | Quiz | Select option 1 |
| Restart | (117,100) → (236,125) | 119×25 | Gameplay | Restart level |
Input Interrupts
The game uses hardware interrupts for responsive controls.Interrupt Configuration
- IRQ_KEYS
- IRQ_TIMER0
- IRQ_TIMER1
Keyboard Interrupt
- Handler:
TeclasJugador()(source/main.c:271) - Purpose: Detect D-pad presses
- Trigger: Any button state change
- Register:
REG_KEYCNT = 0x7FFF(all keys enabled)
Control Flow Diagram
Best Practices
D-Pad Movement:
- Press direction once per move (no holding)
- Wait for stamina bar to update before next move
- Plan route before executing to avoid wasted movements
Touch Controls:
- Tap buttons precisely within defined regions
- Wait for visual feedback before next tap
- Be patient with dialog transitions (debounce timer active)
Accessibility Notes
- Grid Movement: 2-tile increments simplify navigation
- Visual Feedback: Stamina bar provides clear movement tracking
- Touch Regions: Large button areas (100+ pixels) reduce precision requirements
- Input Debouncing: Prevents accidental double-inputs
The game’s interrupt-driven input system ensures responsive controls even during graphical updates, maintaining smooth gameplay on the NDS hardware.