aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-28 21:29:04 +0200
committerBad Diode <bd@badd10de.dev>2021-05-28 21:29:04 +0200
commit9c61e2e75220439e917fa5fba9d59014a2a5c43a (patch)
treeb9b4a4a535163238bd50707c05139a560cc92f71
parent1fabc50056826ba54ad2a613e5509f3047414cae (diff)
downloaduxngba-9c61e2e75220439e917fa5fba9d59014a2a5c43a.tar.gz
uxngba-9c61e2e75220439e917fa5fba9d59014a2a5c43a.zip
Update README
-rw-r--r--README.md67
-rw-r--r--src/apu.c3
-rw-r--r--src/main.c29
3 files changed, 57 insertions, 42 deletions
diff --git a/README.md b/README.md
index 975201c..0988e6e 100644
--- a/README.md
+++ b/README.md
@@ -9,22 +9,20 @@ screen or console devices, including the beautiful DVD bouncing.
9## Building from source 9## Building from source
10 10
11To build this software you need the [devkitPro][devkitpro] SDK. Once installed, 11To build this software you need the [devkitPro][devkitpro] SDK. Once installed,
12You may need to modify the Makefile to set up the path: 12you may need to modify the Makefile to ensure the path is correct, but should
13work with the default devikit installation methods on Linux and macOS.
13 14
14``` 15```
15DEVKITPRO := /opt/devkitpro 16DEVKITPRO := /opt/devkitpro
16DEVKITARM := /opt/devkitpro/devkitARM 17DEVKITBIN := $(DEVKITPRO)/devkitARM/bin
17PATH := $(DEVKITARM)/bin:$(PATH) 18DEVKITTOOLS := $(DEVKITPRO)/tools/bin
18LIBGBA_DIR := $(DEVKITPRO)/libgba 19LIBGBA_DIR := $(DEVKITPRO)/libgba
19LIBGBA_SRC := /opt/devkitpro/libgba/include/ 20LIBGBA_SRC := $(DEVKITPRO)/libgba/include/
20LIBGBA := $(LIBGBA_DIR)/lib/libgba.a 21LIBGBA := $(LIBGBA_DIR)/lib/libgba.a
21LIBGBA += $(LIBGBA_DIR)/lib/libfat.a 22LIBGBA += $(LIBGBA_DIR)/lib/libfat.a
22LIBGBA += $(LIBGBA_DIR)/lib/libmm.a 23LIBGBA += $(LIBGBA_DIR)/lib/libmm.a
23``` 24```
24 25
25An intermediate build step will create a `src/uxn/roms/boot.c` file, for which
26you need the `bin2carr` utility that can be found [here][bin2carr].
27
28If everything is properly installed, you should be able to run `make` to compile 26If everything is properly installed, you should be able to run `make` to compile
29the program into a `uxngba.gba` rom. If you have `mgba-qt` installed, you can 27the program into a `uxngba.gba` rom. If you have `mgba-qt` installed, you can
30test it with: `make run`. 28test it with: `make run`.
@@ -33,8 +31,49 @@ To use a specific UXN compiled rom, you can pass it as the `ROM_SRC` make
33parameter: 31parameter:
34 32
35``` 33```
36make run ROM_SRC=src/uxn/roms/piano.rom 34make run ROM_SRC=roms/noodle.rom
37``` 35```
38 36
37If you have compiled a rom already and want to change it, you probably want to
38use `make clean` beforehand.
39
39[devkitpro]: https://devkitpro.org/ 40[devkitpro]: https://devkitpro.org/
40[bin2carr]: https://git.badd10de.dev/gba-dev-tools/ 41
42## Configuration
43
44The output .gba files will embed the rom used for installation. Different roms
45have different needs, such as the usage of different input methods or the
46desired audio quality. These options can be selected by defining the right
47macros on compile time as described below.
48
49### Input method order
50
51Uxngba currently supports three different control schemes that can be cycled by
52pressing the SELECT button: `CONTROL_CONTROLLER`, `CONTROL_MOUSE` and
53`CONTROL_KEYBOARD`. To select the order and available methods set the
54`CONTROL_METHODS` macro on compile time. For example, [noodle][noodle] doesn't
55make much use of the controller scheme, and we may want to use the mouse as the
56default input method. This can be achieved with the following command:
57
58```
59make run ROM_SRC=roms/noodle.rom CONFIG="-DCONTROL_METHODS=CONTROL_MOUSE,CONTROL_KEYBOARD"
60```
61
62### Audio quality
63
64Audio processing can be computationally expensive and the GBA has limited
65resources. uxngba supports 4 audio channel devices simultaneously, and depending
66on the demands of the rest of the program, the audio quality can be increased or
67decreased. By default, sounds will play on a 18157 Hz buffer, which offers
68a good quality-performance compromise. A high quality and low-fi audio modes can
69be selected by setting the `AUDIO_HIFI` or `AUDIO_LOFI` macros:
70
71```
72make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_HIFI"
73
74 or
75
76make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_LOFI"
77```
78
79[noodle]: https://wiki.xxiivv.com/site/noodle.html
diff --git a/src/apu.c b/src/apu.c
index eb898c1..d107e1e 100644
--- a/src/apu.c
+++ b/src/apu.c
@@ -17,6 +17,7 @@ WITH REGARD TO THIS SOFTWARE.
17// the pitch table is multiplied by the sampling rate of the original sample, 17// the pitch table is multiplied by the sampling rate of the original sample,
18// the resulting value will be the increment per VSYNC, which must be shifted 18// the resulting value will be the increment per VSYNC, which must be shifted
19// AUDIO_INC_PRECISION to obtain a (20.12) fixed-point increment value. 19// AUDIO_INC_PRECISION to obtain a (20.12) fixed-point increment value.
20//
20#if defined(AUDIO_HIFI) 21#if defined(AUDIO_HIFI)
21#define AUDIO_FREQ 40137 22#define AUDIO_FREQ 40137
22#define AUDIO_BUF_LEN 672 23#define AUDIO_BUF_LEN 672
@@ -44,7 +45,7 @@ static u16 pitch_table[120] = {
44#define AUDIO_BUF_LEN 96 45#define AUDIO_BUF_LEN 96
45#define AUDIO_TIMER 62610 46#define AUDIO_TIMER 62610
46#define AUDIO_INC_PRECISION 4 47#define AUDIO_INC_PRECISION 4
47static u16 pitch_table[120] = { 48static u32 pitch_table[120] = {
48 93, 98, 104, 111, 117, 124, 132, 139, 49 93, 98, 104, 111, 117, 124, 132, 139,
49 148, 157, 166, 176, 186, 197, 209, 222, 50 148, 157, 166, 176, 186, 197, 209, 222,
50 235, 249, 264, 279, 296, 314, 332, 352, 51 235, 249, 264, 279, 296, 314, 332, 352,
diff --git a/src/main.c b/src/main.c
index 35bc0cf..7a2c397 100644
--- a/src/main.c
+++ b/src/main.c
@@ -16,12 +16,9 @@ WITH REGARD TO THIS SOFTWARE.
16#include "filesystem.c" 16#include "filesystem.c"
17 17
18#include "rom.c" 18#include "rom.c"
19#include "uxn/uxn.h" 19#include "uxn.c"
20#include "uxn/uxn.c" 20#include "ppu.c"
21#include "uxn/devices/ppu.h"
22#include "uxn/devices/ppu.c"
23#include "apu.c" 21#include "apu.c"
24
25#include "text.h" 22#include "text.h"
26 23
27// 24//
@@ -391,34 +388,12 @@ int main(void) {
391 init_sound(); 388 init_sound();
392 389
393 // Main loop. 390 // Main loop.
394 int frame_counter = 0;
395 evaluxn(&u, 0x0100); 391 evaluxn(&u, 0x0100);
396 u32 flip_cycles = 0;
397 u32 eval_cycles = 0;
398 u32 input_cycles = 0;
399 u32 mix_cycles = 0;
400 while(true) { 392 while(true) {
401 bios_vblank_wait(); 393 bios_vblank_wait();
402 profile_start();
403 handle_input(&u); 394 handle_input(&u);
404 input_cycles = MAX(profile_stop(), input_cycles);
405 profile_start();
406 evaluxn(&u, mempeek16(devscreen->dat, 0)); 395 evaluxn(&u, mempeek16(devscreen->dat, 0));
407 eval_cycles = MAX(profile_stop(), eval_cycles);
408 txt_position(0, 8);
409 profile_start();
410 flip_cycles = profile_stop();
411 frame_counter++;
412 profile_start();
413 sound_mix(); 396 sound_mix();
414 mix_cycles = MAX(profile_stop(), mix_cycles);
415
416 txt_position(0, 15);
417 txt_printf("INPUT: %lu \n", input_cycles);
418 txt_printf("EVAL: %lu \n", eval_cycles);
419 txt_printf("FLIP: %lu \n", flip_cycles);
420 txt_printf("MIX: %lu \n", mix_cycles);
421 txt_printf("FRAME: %lu \n", frame_counter);
422 flipbuf(&ppu); 397 flipbuf(&ppu);
423 } 398 }
424 399