diff options
Diffstat (limited to 'demo')
-rw-r--r-- | demo/GNUmakefile | 8 | ||||
-rw-r--r-- | demo/demo.c | 14 | ||||
-rw-r--r-- | demo/hdr.s | 2 |
3 files changed, 14 insertions, 10 deletions
diff --git a/demo/GNUmakefile b/demo/GNUmakefile index 18d3083..076b19f 100644 --- a/demo/GNUmakefile +++ b/demo/GNUmakefile @@ -5,7 +5,7 @@ # TOOLS AS := arm-none-eabi-as -CC := clang -target arm-none-eabi +CC := clang --target=arm-none-eabi #CC := arm-none-eabi-gcc LD := arm-none-eabi-ld OBJCOPY := arm-none-eabi-objcopy @@ -29,13 +29,13 @@ OBJS := \ ROMHDR := hdr.o -BIN := demo.gba +IMG := demo.gba # TARGETS .PHONY: clean purge -$(BIN): $(ROMHDR) $(OBJS) +$(IMG): $(ROMHDR) $(OBJS) $(LD) -L../agbx -Tldscript -odemo.elf -znoexecstack $(^) -lagbx $(OBJCOPY) -Obinary demo.elf $(@) agbsum -psi$(@) @@ -44,5 +44,5 @@ clean: $(RM) $(OBJS) $(ROMHDR) demo.elf purge: clean - $(RM) $(BIN) + $(RM) $(IMG) diff --git a/demo/demo.c b/demo/demo.c index 94578f6..012e705 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -6,6 +6,8 @@ agbx_err agbx_main(void) { agbx_set10(0x500'0002u,0x19u); agbx_set10(0x500'0004u,0xFFFFu); agbx_set10(0x400'0000u,0x404u); + agbx_clrscrn4(0x600'0000u,0x0u); + agbx_clrscrn4(0x600'A000u,0x0u); agbx_i10 const cols[] = { 0b11111u, 0b1111100000u, @@ -17,7 +19,9 @@ agbx_err agbx_main(void) { agbx_i8 y; } pos = {.x = 0x0u,.y = 0x0u,}; agbx_setpx1(0x600'0000u,0x0u,0x2u); + agbx_i20 vaddr = 0x600'0000u; for (;;) { + agbx_vsync(); agbx_keymap const keymap = agbx_getkeymap(); if (agbx_chkkey(keymap,agbx_key_b)) { return (agbx_err)(((agbx_i10)pos.x + (agbx_i10)pos.y)/0x2u); @@ -26,9 +30,9 @@ agbx_err agbx_main(void) { return agbx_err_ok; } if (agbx_chkkey(keymap,agbx_key_l)) { - agbx_plot4(pos.x,pos.y,0x1u); - agbx_flip(); - agbx_plot4(pos.x,pos.y,0x2u); + agbx_plot4(vaddr,pos.x,pos.y,0x1u); + vaddr = agbx_flip(); + agbx_plot4(vaddr,pos.x,pos.y,0x2u); while (agbx_chkkey(agbx_getkeymap(),agbx_key_l)) {} continue; } @@ -70,8 +74,8 @@ agbx_err agbx_main(void) { } continue; drw:; - agbx_plot4(prevpos.x,prevpos.y,0x1u); - agbx_plot4(pos.x,pos.y,0x2u); + agbx_plot4(vaddr,prevpos.x,prevpos.y,0x1u); + agbx_plot4(vaddr,pos.x,pos.y,0x2u); while (agbx_chkkey(agbx_getkeymap(),key)) {} } } @@ -68,7 +68,7 @@ _start: @ We define this label to stop the linker from complaining .byte 0x0 @ Complement check (1) -@ Checksum of the header. Use agbhdrsum to patch this in the final image. +@ Checksum of the header. Use agbsum to patch this in the final image. .byte 0x0 @ Reserved area (2) |