commit 6a44a34e0ebb867753df26f1cb0a38f53420a606 Author: Simponic Date: Fri Aug 7 22:40:00 2020 -0600 Added files diff --git a/GBA-Dash.elf b/GBA-Dash.elf new file mode 100755 index 0000000..5722245 Binary files /dev/null and b/GBA-Dash.elf differ diff --git a/GBA-Dash.gba b/GBA-Dash.gba new file mode 100755 index 0000000..67332d6 Binary files /dev/null and b/GBA-Dash.gba differ diff --git a/GBA-Dash.sav b/GBA-Dash.sav new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..98093a7 --- /dev/null +++ b/Makefile @@ -0,0 +1,163 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/gba_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +# DATA is a list of directories containing binary data +# GRAPHICS is a list of directories containing files to be processed by grit +# +# All directories are specified relative to the project directory where +# the makefile is found +# +#--------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source sprites +INCLUDES := include +DATA := +MUSIC := + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O2\ + -mcpu=arm7tdmi -mtune=arm7tdmi\ + $(ARCH) + +CFLAGS += $(INCLUDE) + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lmm -lgba + + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBGBA) + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- + + +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ + $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +ifneq ($(strip $(MUSIC)),) + export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) + BINFILES += soundbank.bin +endif + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba + + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- + +$(OUTPUT).gba : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) + +$(OFILES_SOURCES) : $(HFILES) + +#--------------------------------------------------------------------------------- +# The bin2o rule should be copied and modified +# for each extension used in the data directories +#--------------------------------------------------------------------------------- + +#--------------------------------------------------------------------------------- +# rule to build soundbank from music files +#--------------------------------------------------------------------------------- +soundbank.bin soundbank.h : $(AUDIOFILES) +#--------------------------------------------------------------------------------- + @mmutil $^ -osoundbank.bin -hsoundbank.h + +#--------------------------------------------------------------------------------- +# This rule links in binary data with the .bin extension +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + + +-include $(DEPSDIR)/*.d +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/build/GBA-Dash.map b/build/GBA-Dash.map new file mode 100644 index 0000000..e1b69e4 --- /dev/null +++ b/build/GBA-Dash.map @@ -0,0 +1,499 @@ +Archive member included to satisfy reference by file (symbol) + +/opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o (__libc_init_array) +/opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + main.o (memcpy) +/opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o (fake_heap_end) + +Discarded input sections + + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .data.__dso_handle + 0x0000000000000000 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .data 0x0000000000000000 0x4 main.o + .text 0x0000000000000000 0x0 player.o + .data 0x0000000000000000 0x0 player.o + .bss 0x0000000000000000 0x0 player.o + .data 0x0000000000000000 0x0 toolbox.o + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + .bss.fake_heap_start + 0x0000000000000000 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + .text 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o + .data 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o + .bss 0x0000000000000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o + +Memory Configuration + +Name Origin Length Attributes +rom 0x0000000008000000 0x0000000002000000 +iwram 0x0000000003000000 0x0000000000008000 +ewram 0x0000000002000000 0x0000000000040000 +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + + 0x0000000008000000 __text_start = ORIGIN (rom) + 0x0000000002040000 __eheap_end = (ORIGIN (ewram) + LENGTH (ewram)) + 0x0000000003000000 __iwram_start = ORIGIN (iwram) + 0x0000000003008000 __iwram_top = (ORIGIN (iwram) + LENGTH (iwram)) + 0x0000000003007fa0 __sp_irq = (__iwram_top - 0x60) + 0x0000000003007f00 __sp_usr = (__sp_irq - 0xa0) + 0x0000000003007ff8 __irq_flags = 0x3007ff8 + 0x0000000008000000 . = __text_start + +.crt0 0x0000000008000000 0x210 + *(.crt0) + .crt0 0x0000000008000000 0x210 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + 0x0000000008000000 _start + 0x00000000080000c4 __boot_method + 0x00000000080000c5 __slave_number + 0x00000000080000e0 start_vector + 0x0000000008000210 . = ALIGN (0x4) + +.init 0x0000000008000210 0xc + *(SORT_NONE(.init)) + .init 0x0000000008000210 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o + 0x0000000008000210 _init + .init 0x0000000008000214 0x8 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o + +.plt 0x000000000800021c 0x0 + *(.plt) + 0x000000000800021c . = ALIGN (0x4) + +.text 0x000000000800021c 0x2d0 + *(EXCLUDE_FILE(*.iwram*) .text*) + .text.deregister_tm_clones + 0x000000000800021c 0x2c /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .text.register_tm_clones + 0x0000000008000248 0x34 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .text.__do_global_dtors_aux + 0x000000000800027c 0x30 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .text.frame_dummy + 0x00000000080002ac 0x28 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .text 0x00000000080002d4 0x5c main.o + 0x00000000080002d4 obj_test + .text.startup 0x0000000008000330 0x44 main.o + 0x0000000008000330 main + .text 0x0000000008000374 0x80 toolbox.o + 0x0000000008000374 oam_init + 0x00000000080003b4 oam_copy + 0x00000000080003d4 obj_copy + .text.__libc_init_array + 0x00000000080003f4 0x50 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + 0x00000000080003f4 __libc_init_array + .text.memcpy 0x0000000008000444 0xa8 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + 0x0000000008000444 memcpy + *(.gnu.linkonce.t.*) + *(.text.*personality*) + *(.gnu.warning) + *(.glue_7t) + .glue_7t 0x00000000080004ec 0x0 linker stubs + *(.glue_7) + .glue_7 0x00000000080004ec 0x0 linker stubs + *(.vfp11_veneer) + .vfp11_veneer 0x00000000080004ec 0x0 linker stubs + 0x00000000080004ec . = ALIGN (0x4) + 0x00000000080004ec __text_end = . + +.v4_bx 0x00000000080004ec 0x0 + .v4_bx 0x00000000080004ec 0x0 linker stubs + +.iplt 0x00000000080004ec 0x0 + .iplt 0x00000000080004ec 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + +.fini 0x00000000080004ec 0xc + *(.fini) + .fini 0x00000000080004ec 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o + 0x00000000080004ec _fini + .fini 0x00000000080004f0 0x8 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o + 0x00000000080004f8 . = ALIGN (0x4) + +.rodata 0x00000000080004f8 0x280 + *(.rodata) + .rodata 0x00000000080004f8 0x280 player.o + 0x00000000080004f8 playerTiles + 0x0000000008000578 playerPal + *all.rodata*(*) + *(.roda) + *(.rodata.*) + *(.gnu.linkonce.r*) + 0x0000000008000778 . = ALIGN (0x4) + +.ARM.extab + *(.ARM.extab* .gnu.linkonce.armextab.*) + 0x0000000008000778 __exidx_start = . + +.ARM.exidx + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + 0x0000000008000778 __exidx_end = . + +.ctors 0x0000000008000778 0x0 + *crtbegin.o(.ctors) + *(EXCLUDE_FILE(*crtend.o) .ctors) + *(SORT_BY_NAME(.ctors.*)) + *(.ctors) + 0x0000000008000778 . = ALIGN (0x4) + +.dtors 0x0000000008000778 0x0 + *crtbegin.o(.dtors) + *(EXCLUDE_FILE(*crtend.o) .dtors) + *(SORT_BY_NAME(.dtors.*)) + *(.dtors) + 0x0000000008000778 . = ALIGN (0x4) + +.eh_frame 0x0000000008000778 0x4 + *(.eh_frame) + .eh_frame 0x0000000008000778 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .eh_frame 0x0000000008000778 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + 0x000000000800077c . = ALIGN (0x4) + +.rel.dyn 0x000000000800077c 0x0 + .rel.iplt 0x000000000800077c 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + +.gcc_except_table + 0x000000000800077c 0x0 + *(.gcc_except_table) + 0x000000000800077c . = ALIGN (0x4) + 0x000000000800077c __iwram_lma = . + +.iwram 0x0000000003000000 0x0 load address 0x000000000800077c + 0x0000000003000000 __iwram_start__ = ABSOLUTE (.) + *(.iwram .iwram*) + *iwram.*(.text* .data*) + 0x0000000003000000 . = ALIGN (0x4) + 0x0000000003000000 __iwram_end__ = ABSOLUTE (.) + 0x000000000800077c __data_lma = (__iwram_lma + SIZEOF (.iwram)) + +.bss 0x0000000003000000 0x424 + 0x0000000003000000 __bss_start = ABSOLUTE (.) + 0x0000000003000000 __bss_start__ = ABSOLUTE (.) + *(.dynbss) + *(.gnu.linkonce.b*) + *(.bss*) + .bss.completed.1 + 0x0000000003000000 0x1 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + *fill* 0x0000000003000001 0x3 + .bss.object.0 0x0000000003000004 0x18 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .bss 0x000000000300001c 0x400 main.o + 0x000000000300001c obj_buffer + .bss 0x000000000300041c 0x4 toolbox.o + 0x000000000300041c __key_prev + 0x000000000300041e __key_curr + .bss.fake_heap_end + 0x0000000003000420 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + 0x0000000003000420 fake_heap_end + *(COMMON) + 0x0000000003000424 . = ALIGN (0x4) + 0x0000000003000424 __bss_end__ = ABSOLUTE (.) + +.data 0x0000000003000424 0x0 load address 0x000000000800077c + 0x0000000003000424 __data_start__ = ABSOLUTE (.) + *(.data*) + *(.gnu.linkonce.d*) + 0x0000000003000424 . = ALIGN (0x4) + 0x000000000800077c __preinit_lma = (__data_lma + SIZEOF (.data)) + +.igot.plt 0x0000000003000000 0x0 + .igot.plt 0x0000000003000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + +.tm_clone_table + 0x0000000003000000 0x0 + .tm_clone_table + 0x0000000003000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .tm_clone_table + 0x0000000003000000 0x0 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + +.preinit_array 0x0000000003000424 0x0 load address 0x000000000800077c + 0x0000000003000424 __preinit_array_start = ABSOLUTE (.) + *(.preinit_array) + 0x0000000003000424 __preinit_array_end = ABSOLUTE (.) + 0x000000000800077c __init_lma = (__preinit_lma + SIZEOF (.preinit_array)) + +.init_array 0x0000000003000424 0x4 load address 0x000000000800077c + 0x0000000003000424 __init_array_start = ABSOLUTE (.) + *(SORT_BY_NAME(.init_array.*)) + *(.init_array) + .init_array 0x0000000003000424 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + 0x0000000003000428 __init_array_end = ABSOLUTE (.) + 0x0000000008000780 __fini_lma = (__init_lma + SIZEOF (.init_array)) + +.fini_array 0x0000000003000428 0x4 load address 0x0000000008000780 + 0x0000000003000428 __fini_array_start = ABSOLUTE (.) + *(SORT_BY_NAME(.fini_array.*)) + *(.fini_array) + .fini_array 0x0000000003000428 0x4 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + 0x000000000300042c __fini_array_end = ABSOLUTE (.) + 0x0000000008000784 __jcr_lma = (__fini_lma + SIZEOF (.fini_array)) + +.jcr 0x000000000300042c 0x0 load address 0x0000000008000784 + *(.jcr) + 0x000000000300042c __data_end__ = ABSOLUTE (.) + 0x0000000008000784 __iwram_overlay_lma = (__jcr_lma + SIZEOF (.jcr)) + 0x000000000300042c __iwram_overlay_start = . + +.iwram0 0x000000000300042c 0x0 load address 0x0000000008000784 + *(.iwram0) + 0x000000000300042c . = ALIGN (0x4) + 0x0000000008000784 PROVIDE (__load_start_iwram0 = LOADADDR (.iwram0)) + 0x0000000008000784 PROVIDE (__load_stop_iwram0 = (LOADADDR (.iwram0) + SIZEOF (.iwram0))) + +.iwram1 0x000000000300042c 0x0 + *(.iwram1) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram1 = LOADADDR (.iwram1)) + [!provide] PROVIDE (__load_stop_iwram1 = (LOADADDR (.iwram1) + SIZEOF (.iwram1))) + +.iwram2 0x000000000300042c 0x0 + *(.iwram2) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram2 = LOADADDR (.iwram2)) + [!provide] PROVIDE (__load_stop_iwram2 = (LOADADDR (.iwram2) + SIZEOF (.iwram2))) + +.iwram3 0x000000000300042c 0x0 + *(.iwram3) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram3 = LOADADDR (.iwram3)) + [!provide] PROVIDE (__load_stop_iwram3 = (LOADADDR (.iwram3) + SIZEOF (.iwram3))) + +.iwram4 0x000000000300042c 0x0 + *(.iwram4) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram4 = LOADADDR (.iwram4)) + [!provide] PROVIDE (__load_stop_iwram4 = (LOADADDR (.iwram4) + SIZEOF (.iwram4))) + +.iwram5 0x000000000300042c 0x0 + *(.iwram5) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram5 = LOADADDR (.iwram5)) + [!provide] PROVIDE (__load_stop_iwram5 = (LOADADDR (.iwram5) + SIZEOF (.iwram5))) + +.iwram6 0x000000000300042c 0x0 + *(.iwram6) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram6 = LOADADDR (.iwram6)) + [!provide] PROVIDE (__load_stop_iwram6 = (LOADADDR (.iwram6) + SIZEOF (.iwram6))) + +.iwram7 0x000000000300042c 0x0 + *(.iwram7) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram7 = LOADADDR (.iwram7)) + [!provide] PROVIDE (__load_stop_iwram7 = (LOADADDR (.iwram7) + SIZEOF (.iwram7))) + +.iwram8 0x000000000300042c 0x0 + *(.iwram8) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram8 = LOADADDR (.iwram8)) + [!provide] PROVIDE (__load_stop_iwram8 = (LOADADDR (.iwram8) + SIZEOF (.iwram8))) + +.iwram9 0x000000000300042c 0x0 + *(.iwram9) + 0x000000000300042c . = ALIGN (0x4) + [!provide] PROVIDE (__load_start_iwram9 = LOADADDR (.iwram9)) + [!provide] PROVIDE (__load_stop_iwram9 = (LOADADDR (.iwram9) + SIZEOF (.iwram9))) + 0x000000000300042c __iwram_overlay_end = . + 0x0000000008000784 __ewram_lma = (__iwram_overlay_lma + (__iwram_overlay_end - __iwram_overlay_start)) + 0x000000000300042c __iheap_start = . + 0x0000000002000000 __ewram_start = ORIGIN (ewram) + +.ewram 0x0000000002000000 0x0 load address 0x0000000008000784 + *(.ewram*) + 0x0000000002000000 . = ALIGN (0x4) + 0x0000000002000000 __ewram_end = ABSOLUTE (.) + 0x0000000008000784 __pad_lma = (__ewram_lma + SIZEOF (.ewram)) + +.sbss 0x0000000002000000 0x0 + 0x0000000002000000 __sbss_start__ = ABSOLUTE (.) + *(.sbss*) + 0x0000000002000000 . = ALIGN (0x4) + 0x0000000002000000 __sbss_end__ = ABSOLUTE (.) + 0x0000000002000000 __end__ = ABSOLUTE (.) + 0x0000000002000000 __eheap_start = ABSOLUTE (.) + +.pad 0x0000000002000000 0x8 load address 0x0000000008000784 + 0x0000000002000000 0x4 LONG 0x52416b64 + 0x0000000002000004 0x4 LONG 0x4d + 0x0000000002000008 . = ALIGN (0x4) + 0x000000000800078c __rom_end__ = (__pad_lma + SIZEOF (.pad)) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x23 + *(.comment) + .comment 0x0000000000000000 0x23 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + 0x24 (size before relaxing) + .comment 0x0000000000000023 0x24 main.o + .comment 0x0000000000000023 0x24 player.o + .comment 0x0000000000000023 0x24 toolbox.o + .comment 0x0000000000000023 0x24 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + .comment 0x0000000000000023 0x24 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + .comment 0x0000000000000023 0x24 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + .comment 0x0000000000000023 0x24 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges 0x0000000000000000 0x60 + *(.debug_aranges) + .debug_aranges + 0x0000000000000000 0x28 main.o + .debug_aranges + 0x0000000000000028 0x18 player.o + .debug_aranges + 0x0000000000000040 0x20 toolbox.o + +.debug_pubnames + *(.debug_pubnames) + +.debug_info 0x0000000000000000 0x7e1 + *(.debug_info) + .debug_info 0x0000000000000000 0x4d8 main.o + .debug_info 0x00000000000004d8 0x7f player.o + .debug_info 0x0000000000000557 0x28a toolbox.o + +.debug_abbrev 0x0000000000000000 0x3cb + *(.debug_abbrev) + .debug_abbrev 0x0000000000000000 0x22a main.o + .debug_abbrev 0x000000000000022a 0x47 player.o + .debug_abbrev 0x0000000000000271 0x15a toolbox.o + +.debug_line 0x0000000000000000 0x3c5 + *(.debug_line) + .debug_line 0x0000000000000000 0x1f1 main.o + .debug_line 0x00000000000001f1 0x4a player.o + .debug_line 0x000000000000023b 0x18a toolbox.o + +.debug_frame 0x0000000000000000 0xa8 + *(.debug_frame) + .debug_frame 0x0000000000000000 0x4c main.o + .debug_frame 0x000000000000004c 0x5c toolbox.o + +.debug_str 0x0000000000000000 0x274 + *(.debug_str) + .debug_str 0x0000000000000000 0x210 main.o + 0x250 (size before relaxing) + .debug_str 0x0000000000000210 0x2a player.o + 0xdc (size before relaxing) + .debug_str 0x000000000000023a 0x3a toolbox.o + 0x167 (size before relaxing) + +.debug_loc 0x0000000000000000 0x36a + *(.debug_loc) + .debug_loc 0x0000000000000000 0x90 main.o + .debug_loc 0x0000000000000090 0x2da toolbox.o + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.stack 0x0000000000080000 0x0 + 0x0000000000080000 _stack = . + *(.stack) + +.note.gnu.arm.ident + *(.note.gnu.arm.ident) + +.ARM.attributes + 0x0000000000000000 0x2c + *(.ARM.attributes) + .ARM.attributes + 0x0000000000000000 0x20 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o + .ARM.attributes + 0x0000000000000020 0x1c /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o + .ARM.attributes + 0x000000000000003c 0x2a /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o + .ARM.attributes + 0x0000000000000066 0x2a main.o + .ARM.attributes + 0x0000000000000090 0x30 player.o + .ARM.attributes + 0x00000000000000c0 0x2a toolbox.o + .ARM.attributes + 0x00000000000000ea 0x2a /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-init.o) + .ARM.attributes + 0x0000000000000114 0x2a /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a(lib_a-memcpy-stub.o) + .ARM.attributes + 0x000000000000013e 0x30 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a(malloc_vars.o) + .ARM.attributes + 0x000000000000016e 0x30 /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o + .ARM.attributes + 0x000000000000019e 0x1c /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o + +/DISCARD/ + *(.note.GNU-stack) +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/gba_crt0.o +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crti.o +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtbegin.o +LOAD main.o +LOAD player.o +LOAD toolbox.o +LOAD /opt/devkitpro/libgba/lib/libmm.a +LOAD /opt/devkitpro/libgba/lib/libgba.a +START GROUP +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/libgcc.a +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libg.a +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libc.a +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/lib/thumb/libsysbase.a +END GROUP +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtend.o +LOAD /opt/devkitpro/devkitARM/lib/gcc/arm-none-eabi/10.1.0/thumb/crtn.o +OUTPUT(/home/logan/git/GBA-Dash/GBA-Dash.elf elf32-littlearm) + +.debug_ranges 0x0000000000000000 0x98 + .debug_ranges 0x0000000000000000 0x98 main.o diff --git a/build/main.d b/build/main.d new file mode 100644 index 0000000..78bc462 --- /dev/null +++ b/build/main.d @@ -0,0 +1,21 @@ +main.o: /home/logan/git/GBA-Dash/source/main.c \ + /home/logan/git/GBA-Dash/source/../include/input.h \ + /home/logan/git/GBA-Dash/source/../include/memmap.h \ + /home/logan/git/GBA-Dash/source/../include/types.h \ + /home/logan/git/GBA-Dash/source/../include/memdef.h \ + /home/logan/git/GBA-Dash/source/../include/toolbox.h \ + /home/logan/git/GBA-Dash/source/../include/input.h \ + /home/logan/git/GBA-Dash/source/../include/memmap.h \ + /home/logan/git/GBA-Dash/source/../include/types.h \ + /home/logan/git/GBA-Dash/source/../include/memdef.h \ + /home/logan/git/GBA-Dash/source/../sprites/player.h +/home/logan/git/GBA-Dash/source/../include/input.h: +/home/logan/git/GBA-Dash/source/../include/memmap.h: +/home/logan/git/GBA-Dash/source/../include/types.h: +/home/logan/git/GBA-Dash/source/../include/memdef.h: +/home/logan/git/GBA-Dash/source/../include/toolbox.h: +/home/logan/git/GBA-Dash/source/../include/input.h: +/home/logan/git/GBA-Dash/source/../include/memmap.h: +/home/logan/git/GBA-Dash/source/../include/types.h: +/home/logan/git/GBA-Dash/source/../include/memdef.h: +/home/logan/git/GBA-Dash/source/../sprites/player.h: diff --git a/build/main.o b/build/main.o new file mode 100644 index 0000000..fc8766d Binary files /dev/null and b/build/main.o differ diff --git a/build/player.d b/build/player.d new file mode 100644 index 0000000..d176045 --- /dev/null +++ b/build/player.d @@ -0,0 +1 @@ +player.o: /home/logan/git/GBA-Dash/sprites/player.c diff --git a/build/player.o b/build/player.o new file mode 100644 index 0000000..1c7f918 Binary files /dev/null and b/build/player.o differ diff --git a/build/toolbox.d b/build/toolbox.d new file mode 100644 index 0000000..339b6d5 --- /dev/null +++ b/build/toolbox.d @@ -0,0 +1,11 @@ +toolbox.o: /home/logan/git/GBA-Dash/sprites/toolbox.c \ + /home/logan/git/GBA-Dash/sprites/../include/toolbox.h \ + /home/logan/git/GBA-Dash/sprites/../include/types.h \ + /home/logan/git/GBA-Dash/sprites/../include/memmap.h \ + /home/logan/git/GBA-Dash/sprites/../include/memdef.h \ + /home/logan/git/GBA-Dash/sprites/../include/input.h +/home/logan/git/GBA-Dash/sprites/../include/toolbox.h: +/home/logan/git/GBA-Dash/sprites/../include/types.h: +/home/logan/git/GBA-Dash/sprites/../include/memmap.h: +/home/logan/git/GBA-Dash/sprites/../include/memdef.h: +/home/logan/git/GBA-Dash/sprites/../include/input.h: diff --git a/build/toolbox.o b/build/toolbox.o new file mode 100644 index 0000000..76fa92b Binary files /dev/null and b/build/toolbox.o differ diff --git a/include/input.h b/include/input.h new file mode 100644 index 0000000..70b7a83 --- /dev/null +++ b/include/input.h @@ -0,0 +1,135 @@ +// +// Input header +// +//! \file tonc_input.h +//! \author J Vijn +//! \date 20060508 - 20060924 +// +// === NOTES === +// * This is a _small_ set of typedefs, #defines and inlines that can +// be found in tonclib, and might not represent the +// final forms. + + +#ifndef __INPUT__ +#define __INPUT__ + +#include "memmap.h" +#include "types.h" +#include "memdef.h" + + +INLINE int bit_tribool(u32 x, int plus, int minus); + +// === CONSTANTS ====================================================== + +typedef enum eKeyIndex +{ + KI_A=0, KI_B, KI_SELECT, KI_START, + KI_RIGHT, KI_LEFT, KI_UP, KI_DOWN, + KI_R, KI_L, KI_MAX +} eKeyIndex; + +// === MACROS ========================================================= + +// check which of the specified keys are down or up right now +#define KEY_DOWN_NOW(key) (~(REG_KEYINPUT) & key) +#define KEY_UP_NOW(key) ( (REG_KEYINPUT) & key) + +// test whether all keys are pressed, released, whatever. +// Example use: +// KEY_EQ(key_hit, KEY_L | KEY_R) +// will be true if and only if KEY_L and KEY_R are _both_ being pressed +#define KEY_EQ(key_fun, keys) ( key_fun(keys) == (keys) ) + +// === CLASSES ======================================================== +// === GLOBALS ======================================================== + +extern u16 __key_curr, __key_prev; // in tonc_core.c + +// === PROTOTYPES ===================================================== + +// --- synchronous key states --- +INLINE void key_poll(); +INLINE u32 key_curr_state(); +INLINE u32 key_prev_state(); + +INLINE u32 key_is_down(u32 key); // any of key currently down? +INLINE u32 key_is_up(u32 key); // any of key currently up? + +INLINE u32 key_was_down(u32 key); // any of key previously down? +INLINE u32 key_was_up(u32 key); // any of key previously up? + +INLINE u32 key_transit(u32 key); // any of key changing? +INLINE u32 key_held(u32 key); // any of key held down? +INLINE u32 key_hit(u32 key); // any of key being hit (going down)? +INLINE u32 key_released(u32 key); // any of key being released? + +// --- tribools --- +INLINE int key_tri_horz(); +INLINE int key_tri_vert(); +INLINE int key_tri_shoulder(); +INLINE int key_tri_fire(); + +// === INLINES========================================================= + +// --- keys ----------------------------------------------------------- + +//! Poll for keystates +INLINE void key_poll() +{ __key_prev= __key_curr; __key_curr= ~REG_KEYINPUT & KEY_MASK; } + +//! Get current keystate +INLINE u32 key_curr_state() { return __key_curr; } + +//! Get previous key state +INLINE u32 key_prev_state() { return __key_prev; } + +//! Gives the keys of \a key that are currently down +INLINE u32 key_is_down(u32 key) { return __key_curr & key; } + +//! Gives the keys of \a key that are currently up +INLINE u32 key_is_up(u32 key) { return ~__key_curr & key; } + +//! Gives the keys of \a key that were previously down +INLINE u32 key_was_down(u32 key) { return __key_prev & key; } + +//! Gives the keys of \a key that were previously down +INLINE u32 key_was_up(u32 key) { return ~__key_prev & key; } + +//! Gives the keys of \a key that are different from before +INLINE u32 key_transit(u32 key) +{ return (__key_curr^__key_prev) & key; } + +//! Gives the keys of \a key that are being held down +INLINE u32 key_held(u32 key) +{ return (__key_curr& __key_prev) & key; } + +//! Gives the keys of \a key that are pressed (down now but not before) +INLINE u32 key_hit(u32 key) +{ return (__key_curr&~__key_prev) & key; } + +//! Gives the keys of \a key that are being released +INLINE u32 key_released(u32 key) +{ return (~__key_curr&__key_prev) & key; } + +// --- tribools --- + +//! Horizontal tribool (right,left)=(+,-) +INLINE int key_tri_horz() +{ return bit_tribool(__key_curr, KI_RIGHT, KI_LEFT); } + +//! Vertical tribool (down,up)=(+,-) +INLINE int key_tri_vert() +{ return bit_tribool(__key_curr, KI_DOWN, KI_UP); } + +//! Shoulder-button tribool (R,L)=(+,-) +INLINE int key_tri_shoulder() +{ return bit_tribool(__key_curr, KI_R, KI_L); } + +//! Fire-button tribool (A,B)=(+,-) +INLINE int key_tri_fire() +{ return bit_tribool(__key_curr, KI_A, KI_B); } + + +#endif // __INPUT__ diff --git a/include/memdef.h b/include/memdef.h new file mode 100644 index 0000000..8fe432f --- /dev/null +++ b/include/memdef.h @@ -0,0 +1,212 @@ +// +// Memory map defines. All of them +// +//! \file tonc_memdef.h +//! \author J Vijn +//! \date 20060508 - 20060924 +// +// === NOTES === +// * This is a _small_ set of typedefs, #defines and inlines that can +// be found in tonclib, and might not represent the +// final forms. +// * '0'-defines are prefixed with '_', to indicate their zero-ness +// and presents a safety from things like doing `if(x&0)' + +#ifndef __MEMDEF__ +#define __MEMDEF__ + +// --- Prefixes --- +// REG_DISPCNT : DCNT +// REG_DISPSTAT : DSTAT + +// OAM attr 0 : OA0 +// OAM attr 1 : OA1 +// OAM attr 2 : OA2 + + +// --- REG_DISPCNT ----------------------------------------------------- + +#define DCNT_MODE0 0 //!< Mode 0; bg 0-4: reg +#define DCNT_MODE1 0x0001 //!< Mode 1; bg 0-1: reg; bg 2: affine +#define DCNT_MODE2 0x0002 //!< Mode 2; bg 2-2: affine +#define DCNT_MODE3 0x0003 //!< Mode 3; bg2: 240x160\@16 bitmap +#define DCNT_MODE4 0x0004 //!< Mode 4; bg2: 240x160\@8 bitmap +#define DCNT_MODE5 0x0005 //!< Mode 5; bg2: 160x128\@16 bitmap +#define DCNT_GB 0x0008 //!< (R) GBC indicator +#define DCNT_PAGE 0x0010 //!< Page indicator +#define DCNT_OAM_HBL 0x0020 //!< Allow OAM updates in HBlank +#define DCNT_OBJ_2D 0 //!< OBJ-VRAM as matrix +#define DCNT_OBJ_1D 0x0040 //!< OBJ-VRAM as array +#define DCNT_BLANK 0x0080 //!< Force screen blank +#define DCNT_BG0 0x0100 //!< Enable bg 0 +#define DCNT_BG1 0x0200 //!< Enable bg 1 +#define DCNT_BG2 0x0400 //!< Enable bg 2 +#define DCNT_BG3 0x0800 //!< Enable bg 3 +#define DCNT_OBJ 0x1000 //!< Enable objects +#define DCNT_WIN0 0x2000 //!< Enable window 0 +#define DCNT_WIN1 0x4000 //!< Enable window 1 +#define DCNT_WINOBJ 0x8000 //!< Enable object window + +#define DCNT_MODE_MASK 0x0007 +#define DCNT_MODE_SHIFT 0 +#define DCNT_MODE(n) ((n)<:) +// _x needs shifting +#define BFN_PREP(x, name) ( ((x)<>name##_SHIFT ) +#define BFN_SET(y, x, name) (y = ((y)&~name##_MASK) | BFN_PREP(x,name) ) + +// x already shifted +#define BFN_PREP2(x, name) ( (x) & name##_MASK ) +#define BFN_GET2(y, name) ( (y) & name##_MASK ) +#define BFN_SET2(y, x, name) (y = ((y)&~name##_MASK) | BFN_PREP2(x,name) ) + +//! Gives a tribool (-1, 0, or +1) depending on the state of some bits. +/*! Looks at the \a plus and \a minus bits of \a flags, and subtracts +* their status to give a +1, -1 or 0 result. Useful for direction flags. +* \param plus Bit number for positive result +* \param minus Bit number for negative result +* \return +1 if \a plus bit is set but \a minus bit isn't
+* -1 if \a minus bit is set and \a plus bit isn't
+* 0 if neither or both are set. +*/ +INLINE int bit_tribool(u32 flags, int plus, int minus) +{ return ((flags>>plus)&1) - ((flags>>minus)&1); } + + +// --- (tonc_video.h) ------------------------------------------------- + +//! Wait for next VBlank +INLINE void vid_vsync() +{ + while(REG_VCOUNT >= 160); // wait till VDraw + while(REG_VCOUNT < 160); // wait till VBlank +} + +//! Create a 15bit BGR color. +INLINE COLOR RGB15(u32 red, u32 green, u32 blue) +{ return red | (green<<5) | (blue<<10); } + + +// --- Objects --- + + +//! Set the attributes of an object. +INLINE OBJ_ATTR *obj_set_attr(OBJ_ATTR *obj, u16 a0, u16 a1, u16 a2) +{ + obj->attr0= a0; obj->attr1= a1; obj->attr2= a2; + return obj; +} + +//! Set the position of \a obj +INLINE void obj_set_pos(OBJ_ATTR *obj, int x, int y) +{ + BFN_SET(obj->attr0, y, ATTR0_Y); + BFN_SET(obj->attr1, x, ATTR1_X); +} + +//! Hide an object. +INLINE void obj_hide(OBJ_ATTR *obj) +{ BFN_SET2(obj->attr0, ATTR0_HIDE, ATTR0_MODE); } + +//! Unhide an object. +/*! \param obj Object to unhide. +* \param mode Object mode to unhide to. Necessary because this affects +* the affine-ness of the object. +*/ +INLINE void obj_unhide(OBJ_ATTR *obj, u16 mode) +{ BFN_SET2(obj->attr0, mode, ATTR0_MODE); } + + +#endif // TOOLBOX_H diff --git a/include/types.h b/include/types.h new file mode 100644 index 0000000..5ad8121 --- /dev/null +++ b/include/types.h @@ -0,0 +1,120 @@ +// +// Basic structs and typedefs +// +//! \file tonc_types.h +//! \author J Vijn +//! \date 20060508 - 20060508 +// +// === NOTES === +// * This is a _small_ set of typedefs, #defines and inlines that can +// be found in tonclib, and might not represent the +// final forms. + + +#ifndef __TYPES__ +#define __TYPES__ + + +// === GCC ATTRIBUTES ================================================= + +// alignment boundary +#define ALIGN(_n) __attribute__((aligned(_n))) +#define ALIGN4 __attribute__((aligned(4))) + +// pack aggregate members +#define PACKED __attribute__((packed)) + + +// === TYPES: ========================================================= + +// --- primary typedefs ----------------------------------------------- +typedef unsigned char u8, byte; +typedef unsigned short u16, hword; +typedef unsigned int u32, word; +typedef unsigned long long u64; + +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; + +// and volatiles for registers 'n stuff +typedef volatile u8 vu8; +typedef volatile u16 vu16; +typedef volatile u32 vu32; +typedef volatile u64 vu64; + +typedef volatile s8 vs8; +typedef volatile s16 vs16; +typedef volatile s32 vs32; +typedef volatile s64 vs64; + +// and consts too for parameters *sigh* +typedef const u8 cu8; +typedef const u16 cu16; +typedef const u32 cu32; +typedef const u64 cu64; + +typedef const s8 cs8; +typedef const s16 cs16; +typedef const s32 cs32; +typedef const s64 cs64; + +typedef struct { u32 data[8]; } BLOCK; + +// --- secondary typedefs --------------------------------------------- + +typedef u16 COLOR; + +// NOTE, u32[]! +typedef struct { u32 data[8]; } TILE, TILE4; +typedef struct { u32 data[16]; } TILE8; + + +// --- memory map structs -------------------------------------------- + +// --- PAL types --- +typedef COLOR PALBANK[16]; + +// --- VRAM types --- + +typedef COLOR M3LINE[240]; +typedef u8 M4LINE[240]; // NOTE u8, not u16!! +typedef COLOR M5LINE[160]; + +typedef TILE CHARBLOCK[512]; +typedef TILE8 CHARBLOCK8[256]; + +// --- OAM structs --- +// NOTE: OATR and OAFF are interlaced; when using affine objs, +// struct/DMA/mem copies will give bad results +typedef struct OBJ_ATTR +{ + u16 attr0; + u16 attr1; + u16 attr2; + s16 fill; +} ALIGN4 OBJ_ATTR; + +typedef struct OBJ_AFFINE +{ + u16 fill0[3]; s16 pa; + u16 fill1[3]; s16 pb; + u16 fill2[3]; s16 pc; + u16 fill3[3]; s16 pd; +} ALIGN4 OBJ_AFFINE; + + +// === DEFINES ======================================================== + +#ifndef NULL +#define NULL 0 +#endif + +// `inline' inlines the function when -O > 0 when called, +// but also creates a body for the function itself +// `static' removes the body as well +#define INLINE static inline + + +#endif // __TYPES__ diff --git a/source/main.c b/source/main.c new file mode 100644 index 0000000..a36688d --- /dev/null +++ b/source/main.c @@ -0,0 +1,46 @@ +#include +#include "../include/input.h" +#include "../include/toolbox.h" +#include "../include/memmap.h" +#include "../include/types.h" +#include "../include/memdef.h" +#include "../sprites/player.h" + +OBJ_ATTR obj_buffer[128]; +OBJ_AFFINE *obj_aff_buffer= (OBJ_AFFINE*)obj_buffer; // Object affine-buffer + +void obj_test() { + int x= 96, y= 32; + u32 tid= 0, pb= 0; + OBJ_ATTR *player = &obj_buffer[0]; + + obj_set_attr(player, + ATTR0_SQUARE, + ATTR1_SIZE_16, + ATTR2_PALBANK(pb) | tid + ); + + obj_set_pos(player, x, y); + + while(1) { + vid_vsync(); + key_poll(); + + oam_copy(oam_mem, obj_buffer, 1); + } +} + +int main() { + memcpy(&tile_mem[4][0], playerTiles, playerTilesLen); + memcpy(pal_obj_mem, playerPal, playerPalLen); + + oam_init(obj_buffer, 128); + + REG_DISPCNT= DCNT_OBJ | DCNT_OBJ_1D; + + obj_test(); + + while(1); + + return 0; +} diff --git a/sprites/player.c b/sprites/player.c new file mode 100644 index 0000000..1dafa3a --- /dev/null +++ b/sprites/player.c @@ -0,0 +1,64 @@ +//====================================================================== +// +// player, 16x16@4, +// + palette 256 entries, not compressed +// + 4 tiles not compressed +// Total size: 512 + 128 = 640 +// +// Time-stamp: 2020-08-07, 16:34:01 +// Exported by Cearn's Usenti v1.7.6 +// (comments, kudos, flames to "daytshen@hotmail.com") +// +//====================================================================== + +const unsigned short playerPal[256]= +{ + 0x0000,0x031F,0x7C00,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, +}; + +const unsigned short playerTiles[64]= +{ + 0x0005,0x0000,0x1110,0x1111,0x1110,0x1111,0x1110,0x1111, + 0x1110,0x1222,0x1110,0x1222,0x1110,0x1222,0x1110,0x1111, + 0x0000,0x0000,0x1111,0x0111,0x1111,0x0111,0x1111,0x0111, + 0x2221,0x0111,0x2221,0x0111,0x2221,0x0111,0x1111,0x0111, + 0x1110,0x1111,0x1110,0x1111,0x1110,0x2222,0x1110,0x2221, + 0x1110,0x1111,0x1110,0x1111,0x1110,0x1111,0x0000,0x0000, + 0x1111,0x0111,0x1111,0x0111,0x2222,0x0111,0x1222,0x0111, + 0x1111,0x0111,0x1111,0x0111,0x1111,0x0111,0x0000,0x0000, +}; + diff --git a/sprites/player.h b/sprites/player.h new file mode 100644 index 0000000..65f840a --- /dev/null +++ b/sprites/player.h @@ -0,0 +1,24 @@ +//====================================================================== +// +// player, 16x16@4, +// + palette 256 entries, not compressed +// + 4 tiles not compressed +// Total size: 512 + 128 = 640 +// +// Time-stamp: 2020-08-07, 16:34:01 +// Exported by Cearn's Usenti v1.7.6 +// (comments, kudos, flames to "daytshen@hotmail.com") +// +//====================================================================== + +#ifndef __PLAYER__ +#define __PLAYER__ + +#define playerPalLen 512 +extern const unsigned short playerPal[256]; + +#define playerTilesLen 128 +extern const unsigned short playerTiles[64]; + +#endif // __PLAYER__ + diff --git a/sprites/toolbox.c b/sprites/toolbox.c new file mode 100644 index 0000000..e58687c --- /dev/null +++ b/sprites/toolbox.c @@ -0,0 +1,65 @@ +// +// toolbox.c +// +// Tools source for obj_demo +// +// (20060922-20060924, cearn) +// +// === NOTES === +// * This is a _small_ set of typedefs, #defines and inlines that can +// be found in tonclib, and might not represent the +// final forms. + +#include "../include/toolbox.h" + +// === (tonc_core.c) ================================================== + +u16 __key_curr= 0, __key_prev= 0; + +// === (tonc_oam.c) =================================================== + +void oam_init(OBJ_ATTR *obj, u32 count) +{ + u32 nn= count; + u32 *dst= (u32*)obj; + + // Hide each object + while(nn--) + { + *dst++= ATTR0_HIDE; + *dst++= 0; + } + // init oam + oam_copy(oam_mem, obj, count); +} + +void oam_copy(OBJ_ATTR *dst, const OBJ_ATTR *src, u32 count) +{ + +// NOTE: while struct-copying is the Right Thing to do here, +// there's a strange bug in DKP that sometimes makes it not work +// If you see problems, just use the word-copy version. +#if 1 + while(count--) + *dst++ = *src++; +#else + u32 *dstw= (u32*)dst, *srcw= (u32*)src; + while(count--) + { + *dstw++ = *srcw++; + *dstw++ = *srcw++; + } +#endif + +} + +void obj_copy(OBJ_ATTR *dst, const OBJ_ATTR *src, u32 count) +{ + int ii; + for(ii=0; ii