aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: baadcc9f73a4c010a20ad40c06bc9236e701302a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# UXNGBA

This is a port of the [UXN virtual machine][uxn] for the GBA. UXN is a project
created by the artist collective and research studio [100 rabbits][100r]. It can
be used to write small graphical applications, tools and games. Programs written
for UXN are distributed via bytecode compiled roms, akin to classic console
emulators. For this project, uxn roms are embedded directly in the .gba rom.

[uxn]: https://wiki.xxiivv.com/site/uxn.html
[100r]: https://100r.co/

## Building from source

To build this software you need the [devkitPro][devkitpro] SDK. Once installed,
you may need to modify the Makefile to ensure the path is correct, but should
work with the default devikit installation methods on Linux and macOS.

```
DEVKITPRO   := /opt/devkitpro
DEVKITBIN   := $(DEVKITPRO)/devkitARM/bin
DEVKITTOOLS := $(DEVKITPRO)/tools/bin
LIBGBA_DIR  := $(DEVKITPRO)/libgba
LIBGBA_SRC  := $(DEVKITPRO)/libgba/include/
LIBGBA      := $(LIBGBA_DIR)/lib/libgba.a
LIBGBA      += $(LIBGBA_DIR)/lib/libfat.a
LIBGBA      += $(LIBGBA_DIR)/lib/libmm.a
```

If everything is properly installed, you should be able to run `make` to compile
the program into a `uxngba.gba` rom. If you have `mgba-qt` installed, you can
test it with: `make run`.

To use a specific UXN compiled rom, you can pass it as the `UXN_ROM` make
parameter:

```
make run UXN_ROM=roms/noodle.rom
```

[devkitpro]: https://devkitpro.org/

## Configuration

The output .gba files will embed the rom used for installation. Different roms
have different needs, such as the usage of different input methods or the
desired audio quality. These options can be selected by defining the right
macros on compile time as described below.

### Input method order

Uxngba currently supports three different control schemes that can be cycled by
pressing the L or R buttons: `CONTROL_CONTROLLER`, `CONTROL_MOUSE` and
`CONTROL_KEYBOARD`. To select the order and available methods set the
`CONTROL_METHODS` macro on compile time. For example, [noodle][noodle] doesn't
make much use of the controller scheme, and we may want to use the mouse as the
default input method. This can be achieved with the following command:

```
make run UXN_ROM=roms/noodle.rom CONFIG="-DCONTROL_METHODS=CONTROL_MOUSE,CONTROL_KEYBOARD"
```

### Audio quality

Audio processing can be computationally expensive and the GBA has limited
resources. uxngba supports 4 audio channel devices simultaneously, and depending
on the demands of the rest of the program, the audio quality can be increased or
decreased. By default, sounds will play on a 18157 Hz buffer, which offers
a good quality-performance compromise. A high quality and low-fi audio modes can
be selected by setting the `AUDIO_HIFI` or `AUDIO_LOFI` macros:

```
make run UXN_ROM=roms/audio.rom CONFIG="-DAUDIO_HIFI"

  or

make run UXN_ROM=roms/audio.rom CONFIG="-DAUDIO_LOFI"
```

### Text layer

When writing text to the screen (for example using the console device) the text
will be drawn by default on the foreground layer. This can be controlled by
setting the `TEXT_MODE` option to 0 for foreground mode or 1 for background
mode. The text layer can be omitted if using the TEXT_DISABLE macro.

```
make run CONFIG="-DTEXT_MODE=1"

make run CONFIG="-DTEXT_DISABLE=1"
```

### Performance metrics

To enable profiling, the `PROF_ENABLE` macro can be used. This will display the
cycle count for input handling (INPUT), loop uxn evaluation (EVAL), screen
buffer flip (FLIP) and audio mixing (MIX). If `PROF_ENABLE` is set to 0, the
current frame numbers will be displayed, if set to 1, the maximum cycle count
for each section will be used instead. Enabling profiling can have a small
performance impact, so these numbers may not be 100% accurate, but should give
a good indication. Using `PROF_SHOW_X` and `PROF_SHOW_Y` we can control at which
tile the cycle count text will be located.

```
make run CONFIG="-DPROF_ENABLE=0 -DPROF_SHOW_Y=8 -DPROF_SHOW_X=8"
```

[noodle]: https://wiki.xxiivv.com/site/noodle.html