# Macros and Aliases

Minicube64 has some useful aliases and macros that can be used as shorthand for common code tasks.

These are included in each ROM with `include "64cube.inc"` at the top.

{% hint style="success" %}
These aliases and macros are optional but good practise to include them.
{% endhint %}

## Available Aliases

These are aliases to the memory addresses of control registers.

### Graphics and Input

```scheme
VIDEO = $100
COLORS = $101
INPUT = $102
```

### Audio

```scheme
AUDIO = $104
AUDIO_REGS = $110
AUDIO_VOLUME = $111
AUDIO_CHANNEL1 = $112
AUDIO_CHANNEL2 = $112+4
AUDIO_CHANNEL3 = $112+8
AUDIO_CHANNEL3 = $112+12
```

### Interrrupt Vectors

```scheme
NMI_IRQ = $10c
VBLANK_IRQ = $10e
```

{% hint style="warning" %}
`VBLANK`Interrupt vector is`0x010e`unlike`0xfffe`on other 6502 systems.
{% endhint %}

## Current Macros

`_setb value,dest`

Sets a byte value to a destination 8 bit memory address.

```bash
	lda #value
	sta dest 
```

Sets a word value to a destination 16 bit memory address.

`_setw value,dest`

```bash
	lda #<value
	sta dest 
	lda #>value 
	sta dest+1
```

`_movw value,dest`

```bash
	lda value
	sta dest 
	lda value+1 
	sta dest+1
```

`_addw source,addition,dest`

```bash
	clc 
	lda source 
	adc addition
	sta dest 
	lda source+1
	adc addition+1
	sta dest+1
```

`_addwb source,addition,dest`

```bash
	clc 
	lda source 
	adc addition
	sta dest 
	lda source+1
	adc #0
	sta dest+1
```

`_addwi source,addition,dest`

```bash
	clc 
	lda source 
	adc #<addition
	sta dest 
	lda source+1
	adc #>addition
	sta dest+1
```


---

# 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/aliases.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.
