Skip to content

Commit

Permalink
Override _io_dldi_stub from libnds
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Dec 25, 2024
1 parent 140d032 commit 0bfc8fa
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ arm7/$(TARGET).elf:

#---------------------------------------------------------------------------------
arm9/$(TARGET).elf:
@$(MAKE) -C libnds32 release
@$(MAKE) -C arm9

#---------------------------------------------------------------------------------
Expand All @@ -51,7 +50,6 @@ clean:
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds
@rm -fr $(TARGET).arm7.elf
@rm -fr $(TARGET).arm9.elf
@$(MAKE) -C libnds32 clean
@$(MAKE) -C bootloader clean
@$(MAKE) -C bootstub clean
@$(MAKE) -C arm9 clean
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ When loading GodMode9i will try to load `/gm9i/font.frf` on your SD card and if
## Credits
- [RocketRobz](https://github.com/RocketRobz): Main Developer.
- [Evie/Pk11](https://github.com/Epicpkmn11): Contributor.
- [lifehackerhansol](https://github.com/lifehackerhansol): [libnds32](https://github.com/lifehackerhansol/libnds32) fork for 32KB DLDI driver support
- [zacchi4k](https://github.com/zacchi4k): Logo designer.
- [Edo9300](https://github.com/edo9300): Save reading code from his save manager tool.
- [endrift](https://github.com/endrift): GBA ROM dumping code from [duplo](https://github.com/endrift/duplo), used for 64MB ROMs.
Expand Down
8 changes: 3 additions & 5 deletions arm9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,19 @@ CFLAGS := -g -Wall -Wno-psabi -O2\
CFLAGS += $(INCLUDE) -DARM9 -D_NO_BOOTSTUB_
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=gnu++17

ASFLAGS := -g $(ARCH)
ASFLAGS := -g $(ARCH) $(INCLUDE)
LDFLAGS = -specs=../ds_arm9_hi.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#---------------------------------------------------------------------------------
LIBS := -lfat -lnds329
LIBS := -lfat -lnds9

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CURDIR) ../ $(LIBNDS)
LIBDIRS32 := $(CURDIR)/../libnds32

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
Expand Down Expand Up @@ -115,8 +114,7 @@ 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) \
$(foreach dir,$(LIBDIRS32),-L$(dir)/lib)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)


export OUTPUT := $(CURDIR)/$(TARGET)
Expand Down
100 changes: 100 additions & 0 deletions arm9/source/my_dldi.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------------
Copyright (C) 2006 - 2016
Michael Chisholm (Chishm)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/

#include <nds/arm9/dldi_asm.h>

.align 4
.arm
.global _io_dldi_stub
@---------------------------------------------------------------------------------

.equ DLDI_ALLOCATED_SPACE, 32768

_io_dldi_stub:

dldi_start:

@---------------------------------------------------------------------------------
@ Driver patch file standard header -- 16 bytes
.word 0xBF8DA5ED @ Magic number to identify this region
.asciz " Chishm" @ Identifying Magic string (8 bytes with null terminator)
.byte 0x01 @ Version number
.byte DLDI_SIZE_32KB @32KiB @ Log [base-2] of the size of this driver in bytes.
.byte 0x00 @ Sections to fix
.byte DLDI_SIZE_32KB @32KiB @ Log [base-2] of the allocated space in bytes.

@---------------------------------------------------------------------------------
@ Text identifier - can be anything up to 47 chars + terminating null -- 16 bytes
.align 4
.asciz "Default (No interface)"

@---------------------------------------------------------------------------------
@ Offsets to important sections within the data -- 32 bytes
.align 6
.word dldi_start @ data start
.word dldi_end @ data end
.word 0x00000000 @ Interworking glue start -- Needs address fixing
.word 0x00000000 @ Interworking glue end
.word 0x00000000 @ GOT start -- Needs address fixing
.word 0x00000000 @ GOT end
.word 0x00000000 @ bss start -- Needs setting to zero
.word 0x00000000 @ bss end

@---------------------------------------------------------------------------------
@ DISC_INTERFACE data -- 32 bytes
.ascii "DLDI" @ ioType
.word 0x00000000 @ Features
.word _DLDI_startup @
.word _DLDI_isInserted @
.word _DLDI_readSectors @ Function pointers to standard device driver functions
.word _DLDI_writeSectors @
.word _DLDI_clearStatus @
.word _DLDI_shutdown @

@---------------------------------------------------------------------------------

_DLDI_startup:
_DLDI_isInserted:
_DLDI_readSectors:
_DLDI_writeSectors:
_DLDI_clearStatus:
_DLDI_shutdown:
mov r0, #0x00 @ Return false for every function
bx lr



@---------------------------------------------------------------------------------
.align
.pool

dldi_data_end:

@ Pad to end of allocated space
.space DLDI_ALLOCATED_SPACE - (dldi_data_end - dldi_start)

dldi_end:
.end
@---------------------------------------------------------------------------------
1 change: 0 additions & 1 deletion libnds32
Submodule libnds32 deleted from 117e46

0 comments on commit 0bfc8fa

Please sign in to comment.