summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
Diffstat (limited to 'demo')
-rw-r--r--demo/GNUmakefile34
-rw-r--r--demo/include/agbx-demo.h2
-rw-r--r--demo/ldscript5
-rw-r--r--demo/script.ld20
-rw-r--r--demo/source/initgfx.c8
-rw-r--r--demo/source/main.c5
6 files changed, 49 insertions, 25 deletions
diff --git a/demo/GNUmakefile b/demo/GNUmakefile
index aed29df..a40d516 100644
--- a/demo/GNUmakefile
+++ b/demo/GNUmakefile
@@ -1,6 +1,6 @@
# Copyright 2022 Gabriel Jensen.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
-# If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
# TOOLS
@@ -12,29 +12,37 @@ OBJCOPY := arm-none-eabi-objcopy
# TOOL FLAGS
-CFLAGS := \
+CFLAGS := \
-I../agbx/include \
- -Iinclude \
- -O3 \
- -Wall \
- -Wextra \
- -Wpedantic \
- -mcpu=arm7tdmi \
- -nostdlib \
+ -Iinclude \
+ -O3 \
+ -Wall \
+ -Wextra \
+ -Wpedantic \
+ -fshort-enums \
+ -mcpu=arm7tdmi \
+ -nostdlib \
-std=c2x
+LDFLAGS := \
+ -L../agbx \
+ -Tscript.ld
+
# BINARIES
-OBJS := \
+OBJS := \
source/chkkeys.o \
- source/chgcol.o \
+ source/chgcol.o \
source/initdat.o \
source/initgfx.o \
- source/loop.o \
+ source/loop.o \
source/main.o
ROMHDR := hdr.o
+LDLIBS := \
+ -lagbx
+
IMG := demo.gba
# TARGETS
@@ -42,7 +50,7 @@ IMG := demo.gba
.PHONY: clean purge
$(IMG): $(ROMHDR) $(OBJS)
- $(LD) -L../agbx -Tldscript -odemo.elf -znoexecstack $(^) -lagbx
+ $(LD) $(LDFLAGS) -odemo.elf -znoexecstack $(^) $(LDLIBS)
$(OBJCOPY) -Obinary demo.elf $(@)
agbsum -psi$(@)
diff --git a/demo/include/agbx-demo.h b/demo/include/agbx-demo.h
index 28d0846..0bb0b22 100644
--- a/demo/include/agbx-demo.h
+++ b/demo/include/agbx-demo.h
@@ -13,7 +13,7 @@ typedef struct {
axd_pos pos;
ax_i8 prevcol;
axd_pos prevpos;
- ax_i20 vaddr;
+ ax_i02 vaddr;
} axd_dat;
typedef struct {
diff --git a/demo/ldscript b/demo/ldscript
deleted file mode 100644
index 614359e..0000000
--- a/demo/ldscript
+++ /dev/null
@@ -1,5 +0,0 @@
-OUTPUT_ARCH(arm)
-
-SECTIONS {
- .text 0x8000000 : {}
-}
diff --git a/demo/script.ld b/demo/script.ld
new file mode 100644
index 0000000..c5dbf9a
--- /dev/null
+++ b/demo/script.ld
@@ -0,0 +1,20 @@
+OUTPUT_ARCH(arm)
+
+MEMORY {
+ bios : ORIGIN = 0x0000000,LENGTH = 0x10K
+ ewram : ORIGIN = 0x2000000,LENGTH = 0x100K
+ iwram : ORIGIN = 0x3000000,LENGTH = 0x20K
+ io : ORIGIN = 0x4000000,LENGTH = 0x3FF
+ pal : ORIGIN = 0x5000000,LENGTH = 0x1K
+ vram : ORIGIN = 0x6000000,LENGTH = 0x60K
+ oam : ORIGIN = 0x7000000,LENGTH = 0x1K
+ rom : ORIGIN = 0x8000000,LENGTH = 0x20M
+ sram : ORIGIN = 0xE000000,LENGTH = 0x40K
+}
+
+SECTIONS {
+ .bss : {*(.bss*)} > ewram
+ .data : {*(.data*)} > ewram
+ .text : {*(.text*)} > rom
+ .rodata : {*(.rodata*)} > rom
+}
diff --git a/demo/source/initgfx.c b/demo/source/initgfx.c
index e2f75d4..31f256f 100644
--- a/demo/source/initgfx.c
+++ b/demo/source/initgfx.c
@@ -3,11 +3,11 @@
#include <ax/gfx.h>
void axd_initgfx(void) {
- ax_set10(0x500'0000u,0b0u);
+ ax_set10(0x500'0000u,0b000000000000000u);
ax_set10(0x500'0002u,0b111111111111111u);
- ax_set10(0x500'0004u,0b11111u);
- ax_set10(0x500'0006u,0b1111111111u);
- ax_set10(0x500'0008u,0b1111100000u);
+ ax_set10(0x500'0004u,0b000000000011111u);
+ ax_set10(0x500'0006u,0b00001111111111u);
+ ax_set10(0x500'0008u,0b00001111100000u);
ax_set10(0x500'000Au,0b111111111100000u);
ax_set10(0x500'000Cu,0b111110000000000u);
ax_set10(0x500'000Eu,0b111110000011111u);
diff --git a/demo/source/main.c b/demo/source/main.c
index 4c838a6..ce0a234 100644
--- a/demo/source/main.c
+++ b/demo/source/main.c
@@ -9,10 +9,11 @@ ax_err ax_main(void) {
axd_initgfx();
bool const err = axd_loop(&dat);
if (err) {
- for (ax_i10 px = 0x0u;px != 0x9600u;++px) {
+ for (ax_i01 px = 0x0u;px != 0x9600u;++px) {
ax_setpx1(dat.vaddr,px,dat.col);
axd_chgcol(&dat,0x1u);
}
+ return ax_err_max;
}
- return err ? ax_err_max : ax_err_ok;
+ return ax_err_ok;
}