aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md40
-rw-r--r--src/main.c6
-rw-r--r--src/uxn/devices/ppu.c19
-rw-r--r--src/uxn/roms/automata.rombin0 -> 255 bytes
-rw-r--r--src/uxn/roms/dvd.rombin0 -> 317 bytes
-rw-r--r--src/uxn/roms/piano.rombin0 -> 2815 bytes
6 files changed, 54 insertions, 11 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..975201c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,40 @@
1# UXNGBA
2
3This is a port of the [UXN virtual machine][uxn] for the GBA. It is currently at
4an early stage, but is capable of running simple demos that make use of the
5screen or console devices, including the beautiful DVD bouncing.
6
7[uxn]: https://wiki.xxiivv.com/site/uxn.html
8
9## Building from source
10
11To build this software you need the [devkitPro][devkitpro] SDK. Once installed,
12You may need to modify the Makefile to set up the path:
13
14```
15DEVKITPRO := /opt/devkitpro
16DEVKITARM := /opt/devkitpro/devkitARM
17PATH := $(DEVKITARM)/bin:$(PATH)
18LIBGBA_DIR := $(DEVKITPRO)/libgba
19LIBGBA_SRC := /opt/devkitpro/libgba/include/
20LIBGBA := $(LIBGBA_DIR)/lib/libgba.a
21LIBGBA += $(LIBGBA_DIR)/lib/libfat.a
22LIBGBA += $(LIBGBA_DIR)/lib/libmm.a
23```
24
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
29the program into a `uxngba.gba` rom. If you have `mgba-qt` installed, you can
30test it with: `make run`.
31
32To use a specific UXN compiled rom, you can pass it as the `ROM_SRC` make
33parameter:
34
35```
36make run ROM_SRC=src/uxn/roms/piano.rom
37```
38
39[devkitpro]: https://devkitpro.org/
40[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) {
142 evaluxn(&u, mempeek16(devscreen->dat, 0)); 142 evaluxn(&u, mempeek16(devscreen->dat, 0));
143 flipbuf(&ppu); 143 flipbuf(&ppu);
144 int eval_cycles = profile_stop(); 144 int eval_cycles = profile_stop();
145 txt_position(0,0); 145 // txt_position(0,0);
146 txt_printf("FRAME: %d \n", frame_counter); 146 // txt_printf("FRAME: %d \n", frame_counter);
147 txt_printf("EVAL: %d \n", eval_cycles); 147 // txt_printf("EVAL: %d \n", eval_cycles);
148 drawing_cycles = 0; 148 drawing_cycles = 0;
149 frame_counter++; 149 frame_counter++;
150 } 150 }
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) {
167 size_t tile_y = y / 8; 167 size_t tile_y = y / 8;
168 size_t start_col = x % 8; 168 size_t start_col = x % 8;
169 size_t start_row = y % 8; 169 size_t start_row = y % 8;
170 Uint32 pos = (start_row + ((tile_x + tile_y * 30) * 8)); 170 size_t pos = (start_row + ((tile_x + tile_y * 30) * 8));
171 Uint32 shift = start_col * 4; 171 size_t shift = start_col * 4;
172 layer[pos] = (layer[pos] & (~(0xF << shift))) | (color << shift); 172 layer[pos] = (layer[pos] & (~(0xF << shift))) | (color << shift);
173 dirty_tiles[tile_y] |= 1 << tile_x; 173 dirty_tiles[tile_y] |= 1 << tile_x;
174} 174}
@@ -180,13 +180,16 @@ puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color,
180 size_t tile_y = y / 8; 180 size_t tile_y = y / 8;
181 size_t start_col = x % 8; 181 size_t start_col = x % 8;
182 size_t start_row = y % 8; 182 size_t start_row = y % 8;
183 Uint32 pos = (start_row + ((tile_x + tile_y * 30) * 8)); 183 size_t shift_left = start_col * 4;
184 Uint32 shift_left = start_col * 4; 184 size_t shift_right = (8 - start_col) * 4;
185 Uint32 shift_right = (8 - start_col) * 4;
186 Uint32 *layer_ptr = &layer[pos];
187 if (flipy) flipy = 7;
188 185
189 Uint32 *lut = flipx ? unpack_icon_lut : unpack_icon_lut_flipx; 186 if (flipy) {
187 flipy = 7;
188 }
189
190 size_t pos = (start_row + ((tile_x + tile_y * 30) * 8));
191 size_t *layer_ptr = &layer[pos];
192 size_t *lut = flipx ? unpack_icon_lut : unpack_icon_lut_flipx;
190 193
191 // There are 4 possible cases: 194 // There are 4 possible cases:
192 // 1. The sprite is exactly at the tile boundary. We can just copy the 195 // 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
--- /dev/null
+++ b/src/uxn/roms/automata.rom
Binary files differ
diff --git a/src/uxn/roms/dvd.rom b/src/uxn/roms/dvd.rom
new file mode 100644
index 0000000..4de8d72
--- /dev/null
+++ b/src/uxn/roms/dvd.rom
Binary files differ
diff --git a/src/uxn/roms/piano.rom b/src/uxn/roms/piano.rom
new file mode 100644
index 0000000..0556ccf
--- /dev/null
+++ b/src/uxn/roms/piano.rom
Binary files differ