From 9c61e2e75220439e917fa5fba9d59014a2a5c43a Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 28 May 2021 21:29:04 +0200 Subject: Update README --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++------------- src/apu.c | 3 ++- src/main.c | 29 ++------------------------- 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. ## Building from source To build this software you need the [devkitPro][devkitpro] SDK. Once installed, -You may need to modify the Makefile to set up the path: +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 -DEVKITARM := /opt/devkitpro/devkitARM -PATH := $(DEVKITARM)/bin:$(PATH) -LIBGBA_DIR := $(DEVKITPRO)/libgba -LIBGBA_SRC := /opt/devkitpro/libgba/include/ -LIBGBA := $(LIBGBA_DIR)/lib/libgba.a -LIBGBA += $(LIBGBA_DIR)/lib/libfat.a -LIBGBA += $(LIBGBA_DIR)/lib/libmm.a +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 ``` -An intermediate build step will create a `src/uxn/roms/boot.c` file, for which -you need the `bin2carr` utility that can be found [here][bin2carr]. - 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`. @@ -33,8 +31,49 @@ To use a specific UXN compiled rom, you can pass it as the `ROM_SRC` make parameter: ``` -make run ROM_SRC=src/uxn/roms/piano.rom +make run ROM_SRC=roms/noodle.rom ``` +If you have compiled a rom already and want to change it, you probably want to +use `make clean` beforehand. + [devkitpro]: https://devkitpro.org/ -[bin2carr]: https://git.badd10de.dev/gba-dev-tools/ + +## 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 SELECT button: `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 ROM_SRC=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 ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_HIFI" + + or + +make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_LOFI" +``` + +[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. // the pitch table is multiplied by the sampling rate of the original sample, // the resulting value will be the increment per VSYNC, which must be shifted // AUDIO_INC_PRECISION to obtain a (20.12) fixed-point increment value. +// #if defined(AUDIO_HIFI) #define AUDIO_FREQ 40137 #define AUDIO_BUF_LEN 672 @@ -44,7 +45,7 @@ static u16 pitch_table[120] = { #define AUDIO_BUF_LEN 96 #define AUDIO_TIMER 62610 #define AUDIO_INC_PRECISION 4 -static u16 pitch_table[120] = { +static u32 pitch_table[120] = { 93, 98, 104, 111, 117, 124, 132, 139, 148, 157, 166, 176, 186, 197, 209, 222, 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. #include "filesystem.c" #include "rom.c" -#include "uxn/uxn.h" -#include "uxn/uxn.c" -#include "uxn/devices/ppu.h" -#include "uxn/devices/ppu.c" +#include "uxn.c" +#include "ppu.c" #include "apu.c" - #include "text.h" // @@ -391,34 +388,12 @@ int main(void) { init_sound(); // Main loop. - int frame_counter = 0; evaluxn(&u, 0x0100); - u32 flip_cycles = 0; - u32 eval_cycles = 0; - u32 input_cycles = 0; - u32 mix_cycles = 0; while(true) { bios_vblank_wait(); - profile_start(); handle_input(&u); - input_cycles = MAX(profile_stop(), input_cycles); - profile_start(); evaluxn(&u, mempeek16(devscreen->dat, 0)); - eval_cycles = MAX(profile_stop(), eval_cycles); - txt_position(0, 8); - profile_start(); - flip_cycles = profile_stop(); - frame_counter++; - profile_start(); sound_mix(); - mix_cycles = MAX(profile_stop(), mix_cycles); - - txt_position(0, 15); - txt_printf("INPUT: %lu \n", input_cycles); - txt_printf("EVAL: %lu \n", eval_cycles); - txt_printf("FLIP: %lu \n", flip_cycles); - txt_printf("MIX: %lu \n", mix_cycles); - txt_printf("FRAME: %lu \n", frame_counter); flipbuf(&ppu); } -- cgit v1.2.1