From 805aa3881b5ba3cca1aaf5542e0bd663bb1f399e Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sat, 16 Dec 2023 08:42:22 +0100 Subject: [PATCH] update ARM7 code --- Makefile.blocksds.arm7 | 2 +- Makefile.blocksds.arm9 | 4 ++-- arm7/source/main.c | 13 +++++++++++-- arm9/source/emulator.c | 2 +- arm9/source/stubs.c | 2 +- source/uxn.h | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Makefile.blocksds.arm7 b/Makefile.blocksds.arm7 index cb3d206..c08c3d2 100644 --- a/Makefile.blocksds.arm7 +++ b/Makefile.blocksds.arm7 @@ -71,7 +71,7 @@ SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp") # Compiler and linker flags # ------------------------- -DEFINES += -D__NDS__ -DARM7 +DEFINES += -D__NDS__ -D__BLOCKSDS__ -DARM7 ARCH := -mcpu=arm7tdmi diff --git a/Makefile.blocksds.arm9 b/Makefile.blocksds.arm9 index c4a8e45..c2f08d9 100644 --- a/Makefile.blocksds.arm9 +++ b/Makefile.blocksds.arm9 @@ -93,7 +93,7 @@ SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -maxdepth 1 -name "*.cpp") # Compiler and linker flags # ------------------------- -DEFINES += -D__NDS__ -DARM9 -DBLOCKSDS +DEFINES += -D__NDS__ -DARM9 -D__BLOCKSDS__ ARCH := -mcpu=arm946e-s+nofp @@ -137,7 +137,7 @@ endif endif LDFLAGS := -Wl,--defsym=vfprintf=__i_vfprintf -Wl,--defsym=vfscanf=__i_vfscanf \ - -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \ + -mthumb -mthumb-interwork $(LIBDIRSFLAGS) $(ARCH) \ -Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \ -T$(BLOCKSDS)/sys/crts/ds_arm9.mem \ -T$(BLOCKSDS)/sys/crts/ds_arm9.ld \ diff --git a/arm7/source/main.c b/arm7/source/main.c index 1ab4c63..8829d9c 100644 --- a/arm7/source/main.c +++ b/arm7/source/main.c @@ -122,17 +122,20 @@ void powerButtonCB() { } int main() { +#ifdef __BLOCKSDS__ + enableSound(); +#else dmaFillWords(0, (void*)0x04000400, 0x100); REG_SOUNDCNT |= SOUND_ENABLE; writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP ); powerOn(POWER_SOUND); +#endif readUserSettings(); ledBlink(0); irqInit(); - initClockIRQ(); fifoInit(); touchInit(); @@ -141,10 +144,16 @@ int main() { fifoSetValue32Handler(UXNDS_FIFO_CHANNEL, fifo_handler, NULL); installSystemFIFO(); - irqSet(IRQ_VCOUNT, VcountHandler); + irqSet(IRQ_VBLANK, VcountHandler); irqSet(IRQ_TIMER0, apu_handler); +#ifdef __BLOCKSDS__ + initClockIRQTimer(3); + irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_TIMER0); +#else + initClockIRQ(); irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK | IRQ_TIMER0); +#endif setPowerButtonCB(powerButtonCB); diff --git a/arm9/source/emulator.c b/arm9/source/emulator.c index e388e6c..92448e0 100644 --- a/arm9/source/emulator.c +++ b/arm9/source/emulator.c @@ -1,5 +1,5 @@ #include -#ifdef BLOCKSDS +#ifdef __BLOCKSDS__ # include #else # include diff --git a/arm9/source/stubs.c b/arm9/source/stubs.c index 22502ba..90ea4ec 100644 --- a/arm9/source/stubs.c +++ b/arm9/source/stubs.c @@ -1,6 +1,6 @@ // Admittedly, this was more useful to reduce filesize before "datetime" device support. #if 0 -#ifdef BLOCKSDS +#ifdef __BLOCKSDS__ #include uint32_t get_fattime(void) { diff --git a/source/uxn.h b/source/uxn.h index ef38308..9244188 100644 --- a/source/uxn.h +++ b/source/uxn.h @@ -21,7 +21,7 @@ WITH REGARD TO THIS SOFTWARE. #define dprintf(...) #endif -#ifdef BLOCKSDS +#ifdef __BLOCKSDS__ #define iprintf printf #define siprintf sprintf #define sniprintf snprintf