# Working with Inputs

Reading the controllers in Minicube64 is super easy.

Controllers are read by using the `INPUT` registers located at memory address `0x0102` and `0x103` for the first and second controllers respectively.

Each controller is mapped to a byte, and each button to a single bit.

{% hint style="info" %}
You can use`INPUT`and`INPUT+1`to read each controller separately.
{% endhint %}

| Bit      |   7   |   6  |   5  |   4  |   3   |   2  |   1  |   0  |
| -------- | :---: | :--: | :--: | :--: | :---: | :--: | :--: | :--: |
| Mask     |  `80` | `40` | `20` | `10` |  `08` | `04` | `02` | `01` |
| Emulated | Right | Left | Down |  Up  | Start |   C  |   B  |   A  |
| Input    | Right | Left | Down |  Up  | Enter |   C  |   X  |   Z  |

Here is an example to test if the Start button on Controller 1 was triggered:

```scheme
CheckStart:
    lda INPUT
    and #%00001000 ;or use #$80
    beq SkipStart
    ;do something
SkipStart:
```

With the and instruction you can test foor any specific bits. This means you can also check for multiple buttons at the same time, for example any button that is not directional:

```scheme
CheckOther:
    lda INPUT
    and #%00001111
    beq SkipStart
    ;do something
SkipOther:
```

{% hint style="danger" %}
Controller 2 is not currently implemented.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aeriform.gitbook.io/minicube64/inputs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
