From 707b6dac805bcc4f2b5e297ff3ce4b82538bcff0 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 20 May 2021 17:02:47 +0200 Subject: Add README and some example roms --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ src/main.c | 6 +++--- src/uxn/devices/ppu.c | 19 +++++++++++-------- src/uxn/roms/automata.rom | Bin 0 -> 255 bytes src/uxn/roms/dvd.rom | Bin 0 -> 317 bytes src/uxn/roms/piano.rom | Bin 0 -> 2815 bytes 6 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 README.md create mode 100644 src/uxn/roms/automata.rom create mode 100644 src/uxn/roms/dvd.rom create mode 100644 src/uxn/roms/piano.rom diff --git a/README.md b/README.md new file mode 100644 index 0000000..975201c --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# UXNGBA + +This is a port of the [UXN virtual machine][uxn] for the GBA. It is currently at +an early stage, but is capable of running simple demos that make use of the +screen or console devices, including the beautiful DVD bouncing. + +[uxn]: https://wiki.xxiivv.com/site/uxn.html + +## 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: + +``` +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 +``` + +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`. + +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 +``` + +[devkitpro]: https://devkitpro.org/ +[bin2carr]: https://git.badd10de.dev/gba-dev-tools/ diff --git a/src/main.c b/src/main.c index c302480..e91a2f2 100644 --- a/src/main.c +++ b/src/main.c @@ -142,9 +142,9 @@ int main(void) { evaluxn(&u, mempeek16(devscreen->dat, 0)); flipbuf(&ppu); int eval_cycles = profile_stop(); - txt_position(0,0); - txt_printf("FRAME: %d \n", frame_counter); - txt_printf("EVAL: %d \n", eval_cycles); + // txt_position(0,0); + // txt_printf("FRAME: %d \n", frame_counter); + // txt_printf("EVAL: %d \n", eval_cycles); drawing_cycles = 0; frame_counter++; } diff --git a/src/uxn/devices/ppu.c b/src/uxn/devices/ppu.c index 0935329..d70afdd 100644 --- a/src/uxn/devices/ppu.c +++ b/src/uxn/devices/ppu.c @@ -167,8 +167,8 @@ putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { size_t tile_y = y / 8; size_t start_col = x % 8; size_t start_row = y % 8; - Uint32 pos = (start_row + ((tile_x + tile_y * 30) * 8)); - Uint32 shift = start_col * 4; + size_t pos = (start_row + ((tile_x + tile_y * 30) * 8)); + size_t shift = start_col * 4; layer[pos] = (layer[pos] & (~(0xF << shift))) | (color << shift); dirty_tiles[tile_y] |= 1 << tile_x; } @@ -180,13 +180,16 @@ puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, size_t tile_y = y / 8; size_t start_col = x % 8; size_t start_row = y % 8; - Uint32 pos = (start_row + ((tile_x + tile_y * 30) * 8)); - Uint32 shift_left = start_col * 4; - Uint32 shift_right = (8 - start_col) * 4; - Uint32 *layer_ptr = &layer[pos]; - if (flipy) flipy = 7; + size_t shift_left = start_col * 4; + size_t shift_right = (8 - start_col) * 4; - Uint32 *lut = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; + if (flipy) { + flipy = 7; + } + + size_t pos = (start_row + ((tile_x + tile_y * 30) * 8)); + size_t *layer_ptr = &layer[pos]; + size_t *lut = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; // There are 4 possible cases: // 1. The sprite is exactly at the tile boundary. We can just copy the diff --git a/src/uxn/roms/automata.rom b/src/uxn/roms/automata.rom new file mode 100644 index 0000000..57c505c Binary files /dev/null and b/src/uxn/roms/automata.rom differ diff --git a/src/uxn/roms/dvd.rom b/src/uxn/roms/dvd.rom new file mode 100644 index 0000000..4de8d72 Binary files /dev/null and b/src/uxn/roms/dvd.rom differ diff --git a/src/uxn/roms/piano.rom b/src/uxn/roms/piano.rom new file mode 100644 index 0000000..0556ccf Binary files /dev/null and b/src/uxn/roms/piano.rom differ -- cgit v1.2.1