├── .gitattributes ├── .gitignore ├── Makefile ├── NOTES.TXT ├── README.TXT ├── README_ORIGINAL.TXT ├── arm7 ├── Makefile ├── include │ ├── arm7.h │ ├── audiosys.h │ ├── fdsplugin.h │ ├── handler.h │ ├── logtable.h │ ├── nestypes.h │ ├── nsdout.h │ ├── nsf6502.h │ ├── s_apu.h │ ├── s_fds.h │ └── s_vrc6.h └── source │ ├── arm7.c │ ├── arm7main.c │ ├── audiosys.c │ ├── handler.c │ ├── license.txt │ ├── s_apu.c │ ├── s_fds.c │ ├── s_fds1.c │ ├── s_fds2.c │ ├── s_fds3.c │ └── s_vrc6.c ├── arm9 ├── Makefile ├── data │ ├── diskbios.c │ ├── diskbios.h │ ├── font.c │ ├── font.h │ ├── fontpal.c │ ├── fontpal.h │ ├── nespal.c │ └── nespal.h ├── include │ ├── 6502mac.h │ ├── equates.h │ ├── macro.h │ ├── menu.h │ ├── minIni.h │ └── multi.h └── source │ ├── 6502.s │ ├── about.c │ ├── arm9main.c │ ├── barcode.c │ ├── cart.s │ ├── cheat.c │ ├── console.c │ ├── dswifi_arm9 │ └── wifi_arm9.h │ ├── exception.c │ ├── gesture.c │ ├── io.s │ ├── ips.c │ ├── mappers │ ├── eeprom_x24c01.s │ ├── eeprom_x24c02.s │ ├── konami.s │ ├── map0.s │ ├── map023771.s │ ├── map1.s │ ├── map105.s │ ├── map1166.s │ ├── map118.s │ ├── map15.s │ ├── map151.s │ ├── map16.s │ ├── map163.s │ ├── map17.s │ ├── map18.s │ ├── map184.s │ ├── map189.s │ ├── map19.s │ ├── map198.s │ ├── map20.s │ ├── map2125.s │ ├── map216.s │ ├── map22.s │ ├── map225_231.s │ ├── map228.s │ ├── map23.s │ ├── map232.s │ ├── map240.s │ ├── map2426.s │ ├── map245.s │ ├── map246.s │ ├── map252.s │ ├── map253.s │ ├── map255.s │ ├── map32.s │ ├── map33.s │ ├── map34.s │ ├── map4.s │ ├── map40.s │ ├── map5.s │ ├── map64.s │ ├── map65.s │ ├── map67.s │ ├── map68.s │ ├── map69.s │ ├── map70152.s │ ├── map72.s │ ├── map73.s │ ├── map74.s │ ├── map75.s │ ├── map76.s │ ├── map77.s │ ├── map78.s │ ├── map79.s │ ├── map80.s │ ├── map82.s │ ├── map85.s │ ├── map86.s │ ├── map87.s │ ├── map88.s │ ├── map90.s │ ├── map91.s │ ├── map910.s │ ├── map92.s │ ├── map93.s │ ├── map94.s │ ├── map97.s │ ├── map99.s │ └── mapnfs.s │ ├── memory.s │ ├── menu.c │ ├── menu_func.c │ ├── minIni.c │ ├── misc.c │ ├── multi.c │ ├── patch.s │ ├── ppu.s │ ├── render.s │ ├── romloader.c │ ├── romloader_frontend.c │ ├── rompatch.c │ ├── sound.s │ ├── stepdebug.c │ ├── subscreen.c │ └── zip │ ├── adler32.c │ ├── compress.c │ ├── crc32.c │ ├── crc32.h │ ├── deflate.c │ ├── deflate.h │ ├── gzclose.c │ ├── gzguts.h │ ├── gzlib.c │ ├── gzread.c │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── xenofunzip.c │ ├── zconf.h │ ├── zlib.h │ ├── zutil.c │ └── zutil.h ├── common ├── dsregs.h ├── dswifi │ └── dswifi_license.txt ├── readme.txt ├── spinlock.h ├── spinlock.s └── wifi_shared.h ├── icon.bmp ├── include ├── c_defs.h ├── ds_misc.h ├── dswifi7.h ├── dswifi9.h ├── dswifi_version.h ├── netdb.h ├── netinet │ └── in.h ├── sgIP_errno.h └── sys │ └── socket.h └── release ├── nesDS.ini └── nesDS.nds /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | include $(DEVKITARM)/ds_rules 9 | export LIBWIFI := $(DEVKITARM)/libwifi 10 | export LIBFAT := $(DEVKITARM)/libfat 11 | export LIBFILESYSTEM := $(DEVKITARM)/libfilesystem 12 | 13 | export GAME_TITLE := nesDS 14 | export GAME_SUBTITLE1 := Version 1.3c 15 | export GAME_SUBTITLE2 := Enjoy yourself! 16 | export GAME_ICON := $(CURDIR)/icon.bmp 17 | export TARGET := nesDS 18 | export TOPDIR := $(CURDIR) 19 | 20 | 21 | .PHONY: arm7/$(TARGET).elf arm9/$(TARGET).elf 22 | 23 | #--------------------------------------------------------------------------------- 24 | # main targets 25 | #--------------------------------------------------------------------------------- 26 | all: $(TARGET).nds 27 | 28 | #--------------------------------------------------------------------------------- 29 | $(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf 30 | @ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ 31 | -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ 32 | -g NNES 01 "TWL NESDS" -z 80040000 -u 00030004 -a 00000010 -p 0001 33 | @echo built ... $(notdir $@) 34 | 35 | #--------------------------------------------------------------------------------- 36 | arm7/$(TARGET).elf: 37 | $(MAKE) -C arm7 38 | 39 | #--------------------------------------------------------------------------------- 40 | arm9/$(TARGET).elf: 41 | $(MAKE) -C arm9 42 | 43 | #--------------------------------------------------------------------------------- 44 | clean: 45 | $(MAKE) -C arm9 clean 46 | $(MAKE) -C arm7 clean 47 | rm -f $(TARGET).arm7 $(TARGET).arm9 $(TARGET).nds 48 | -------------------------------------------------------------------------------- /NOTES.TXT: -------------------------------------------------------------------------------- 1 | (License) 2 | nesDS is released into the PUBLIC DOMAIN. You may do anything you want with it. 3 | If you make any changes you'd like to see added to the official version, please 4 | let me know. 5 | -- nesds@olimar.fea.st 6 | 7 | 8 | nesDS was compiled with ARM ADS 1.2. 9 | To build it, open the project file (nesDS.mcp) and click Project -> Make. 10 | 11 | 12 | --------------------------------------------------------- 13 | Memory map: 14 | 1ff8000-1ffffff: ITCM (6502 core, etc) 15 | 2000000-23fffff: cached ram 16 | 2400000-27fffff: uncached ram 17 | 2800000-2803fff: DTCM (misc tables and data) 18 | -------------------------- 19 | 20 | misc NES data 23f8000 -> 23fe000 21 | sound and DMA buffers 27fe000 -> 27ffc00 (uncached) 22 | firmware settings 23ffc00 -> ... 23 | IPC 27fff00 -> 2800000 (uncached) 24 | 25 | scratch memory is (Image$$EWRAM$$ZI$$Limit -> 23f8000), used for file list storage, rom storage, game recording 26 | 27 | other ptrs: 28 | rombase = Image$$EWRAM$$ZI$$Limit 29 | freemem_start = end of rom 30 | freemem_end=23f8000 31 | (all of freemem_start -> end is used for recording) 32 | 33 | --------------------------------- 34 | VRAM: 35 | A=MAIN OBJ (128k) 6400000-641ffff 36 | B=MAIN BG (128k) 6040000-605ffff 37 | C=MAIN BG (128k) 6000000-601ffff 38 | D=MAIN BG (128k) 6020000-603ffff 39 | E 40 | F 41 | G 42 | H=SUB BG 6200000-6207fff 43 | I 44 | 45 | 6000000-605e000 MAIN CHR (#? chr banks) 46 | 605e000 MAIN SCR -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApacheThunder/NesDS/9da2efd37e5086f35c4efb13a25009ee3e69c0d7/README.TXT -------------------------------------------------------------------------------- /README_ORIGINAL.TXT: -------------------------------------------------------------------------------- 1 | -=-=-=-=-=-=-=- 2 | nesDS 3 | -=-=-=-=-=-=-=- 4 | 5 | It's a NES emulator for the Nintendo DS. Hooray! 6 | 7 | nesDS must be patched with a DLDI driver to work properly. 8 | For more information, go to http://dldi.drunkencoders.com/ 9 | 10 | Usage 11 | -=-=-=-=-=-=- 12 | 13 | Touch the screen to bring up the ingame menu. 14 | 15 | L,R buttons are rewind / fast forward controls. 16 | 17 | X,A buttons are autofire for Y,B. 18 | 19 | 20 | Credits 21 | -=-=-=-=-=-=-=- 22 | Coding: loopy, FluBBa 23 | More code: Dwedit, tepples, kuwanger, chishm 24 | Sound: Mamiya (http://nezplug.sf.net/) 25 | (Did I miss anyone? let me know...) 26 | 27 | 28 | Additional Thanks 29 | -=-=-=-=-=-=-=-=-=-=-=- 30 | PocketHeaven crew 31 | Everyone who donated money - you know who you are. 32 | 33 | 34 | 35 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 36 | Neal Tew 37 | nesDS@olimar.fea.st 38 | http://www.cs.utah.edu/~tew/nesDS/ 39 | 40 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 41 | Fredrik Olsson 42 | flubba@passagen.se 43 | 44 | -------------------------------------------------------------------------------- /arm7/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | include $(DEVKITARM)/ds_rules 9 | 10 | #--------------------------------------------------------------------------------- 11 | # BUILD is the directory where object files & intermediate files will be placed 12 | # SOURCES is a list of directories containing source code 13 | # INCLUDES is a list of directories containing extra header files 14 | # DATA is a list of directories containing binary files 15 | # all directories are relative to this makefile 16 | #--------------------------------------------------------------------------------- 17 | BUILD := build 18 | SOURCES := source 19 | INCLUDES := include build ../include ../include/nds 20 | DATA := 21 | 22 | #--------------------------------------------------------------------------------- 23 | # options for code generation 24 | #--------------------------------------------------------------------------------- 25 | ARCH := -marm -mthumb-interwork 26 | 27 | CFLAGS := -Wall -O2 \ 28 | -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ 29 | -ffast-math \ 30 | $(ARCH) 31 | 32 | CFLAGS += $(INCLUDE) -DARM7 33 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti 34 | 35 | 36 | ASFLAGS := $(ARCH) 37 | LDFLAGS = -specs=ds_arm7.specs $(ARCH) -Wl,-Map,$(notdir $*).map 38 | 39 | LIBS := -ldswifi7 -lnds7 40 | 41 | #--------------------------------------------------------------------------------- 42 | # list of directories containing libraries, this must be the top level containing 43 | # include and lib 44 | #--------------------------------------------------------------------------------- 45 | LIBDIRS := $(CURDIR) $(LIBNDS) $(LIBWIFI) 46 | 47 | 48 | #--------------------------------------------------------------------------------- 49 | # no real need to edit anything past this point unless you need to add additional 50 | # rules for different file extensions 51 | #--------------------------------------------------------------------------------- 52 | ifneq ($(BUILD),$(notdir $(CURDIR))) 53 | #--------------------------------------------------------------------------------- 54 | 55 | export ARM7ELF := $(CURDIR)/$(TARGET).elf 56 | export DEPSDIR := $(CURDIR)/$(BUILD) 57 | 58 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) 59 | 60 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 61 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 62 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 63 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 64 | 65 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 66 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 67 | 68 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 70 | -I$(CURDIR)/$(BUILD) 71 | 72 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 73 | 74 | #--------------------------------------------------------------------------------- 75 | # use CXX for linking C++ projects, CC for standard C 76 | #--------------------------------------------------------------------------------- 77 | ifeq ($(strip $(CPPFILES)),) 78 | #--------------------------------------------------------------------------------- 79 | export LD := $(CC) 80 | #--------------------------------------------------------------------------------- 81 | else 82 | #--------------------------------------------------------------------------------- 83 | export LD := $(CXX) 84 | #--------------------------------------------------------------------------------- 85 | endif 86 | #--------------------------------------------------------------------------------- 87 | 88 | .PHONY: $(BUILD) clean 89 | 90 | #--------------------------------------------------------------------------------- 91 | $(BUILD): 92 | @[ -d $@ ] || mkdir -p $@ 93 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 94 | 95 | #--------------------------------------------------------------------------------- 96 | clean: 97 | @echo clean ... 98 | @rm -fr $(BUILD) *.elf 99 | 100 | 101 | #--------------------------------------------------------------------------------- 102 | else 103 | 104 | DEPENDS := $(OFILES:.o=.d) 105 | 106 | #--------------------------------------------------------------------------------- 107 | # main targets 108 | #--------------------------------------------------------------------------------- 109 | $(ARM7ELF) : $(OFILES) 110 | @echo linking $(notdir $@) 111 | @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ 112 | 113 | 114 | #--------------------------------------------------------------------------------- 115 | # you need a rule like this for each extension you use as binary data 116 | #--------------------------------------------------------------------------------- 117 | %.bin.o : %.bin 118 | #--------------------------------------------------------------------------------- 119 | @echo $(notdir $<) 120 | @$(bin2o) 121 | 122 | -include $(DEPENDS) 123 | 124 | #--------------------------------------------------------------------------------------- 125 | endif 126 | #--------------------------------------------------------------------------------------- 127 | -------------------------------------------------------------------------------- /arm7/include/arm7.h: -------------------------------------------------------------------------------- 1 | #ifndef arm7snd 2 | #define arm7snd 3 | #define MIXFREQ 0x5e00 4 | #define MIXBUFSIZE 128 5 | #endif 6 | 7 | 8 | #ifdef __cplusplus 9 | extern "C"{ 10 | #endif 11 | 12 | extern volatile s16 buffer[MIXBUFSIZE*20]; 13 | 14 | extern u32 interrupts_to_wait_arm7; 15 | extern int ipc_region; 16 | extern void soundinterrupt(void); 17 | 18 | extern int pcmpos; 19 | extern int APU_paused; 20 | 21 | extern void readAPU(void); 22 | extern void resetAPU(void); 23 | extern void dealrawpcm(unsigned char *out); 24 | 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /arm7/include/audiosys.h: -------------------------------------------------------------------------------- 1 | #ifndef AUDIOSYS_H__ 2 | #define AUDIOSYS_H__ 3 | 4 | #include "nestypes.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef void (__fastcall *AUDIOHANDLER2)(Int32 *p); 11 | typedef Int32 (__fastcall *AUDIOHANDLER)(void); 12 | typedef struct NES_AUDIO_HANDLER_TAG { 13 | Uint fMode; 14 | AUDIOHANDLER Proc; 15 | AUDIOHANDLER2 Proc2; 16 | struct NES_AUDIO_HANDLER_TAG *next; 17 | } NES_AUDIO_HANDLER; 18 | 19 | typedef void (__fastcall *VOLUMEHANDLER)(Uint volume); 20 | typedef struct NES_VOLUME_HANDLER_TAG { 21 | VOLUMEHANDLER Proc; 22 | struct NES_VOLUME_HANDLER_TAG *next; 23 | } NES_VOLUME_HANDLER; 24 | 25 | enum 26 | { 27 | NES_AUDIO_FILTER_NONE, 28 | NES_AUDIO_FILTER_LOWPASS, 29 | NES_AUDIO_FILTER_WEIGHTED 30 | }; 31 | 32 | void APU4015Reg(void); 33 | void APUSoundInstall(void); 34 | void NESAudioRender(Int16 *bufp, Uint buflen); 35 | void NESAudioHandlerInstall(NES_AUDIO_HANDLER *ph); 36 | void NESAudioFrequencySet(Uint freq); 37 | Uint NESAudioFrequencyGet(void); 38 | void NESAudioChannelSet(Uint ch); 39 | Uint NESAudioChannelGet(void); 40 | void NESAudioHandlerInitialize(void); 41 | void NESVolumeHandlerInstall(NES_VOLUME_HANDLER *ph); 42 | void NESVolume(Uint volume); 43 | void NESAudioFilterSet(Uint filter); 44 | extern void (*FDSSoundWriteHandler)(Uint address, Uint value); 45 | void FDSSoundInstall(void); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* AUDIOSYS_H__ */ 52 | -------------------------------------------------------------------------------- /arm7/include/fdsplugin.h: -------------------------------------------------------------------------------- 1 | /* */ 2 | /* FDS souce plug-in */ 3 | /* */ 4 | typedef unsigned char BYTE; 5 | typedef unsigned short WORD; 6 | typedef signed int INT; 7 | typedef void* HFDS; 8 | 9 | /* Function pointer prototypes */ 10 | /* Create */ 11 | typedef HFDS ( *FDSCREATE )(); 12 | /* Close */ 13 | typedef void ( *FDSCLOSE )( HFDS ); 14 | 15 | /* Reset */ 16 | typedef void ( *FDSRESET )( HFDS, INT ); 17 | /* Setup */ 18 | typedef void ( *FDSSETUP )( HFDS, INT ); 19 | /* Write */ 20 | typedef void ( *FDSWRITE )( HFDS, WORD, BYTE ); 21 | /* Read */ 22 | typedef BYTE ( *FDSREAD )( HFDS, WORD ); 23 | 24 | /* Get PCM data */ 25 | typedef INT ( *FDSPROCESS)( HFDS ); 26 | /* Get FDS frequency */ 27 | typedef INT ( *FDSGETFREQ)( HFDS ); 28 | 29 | /* Write */ 30 | typedef void ( *FDSWRITESYNC)( HFDS, WORD, BYTE ); 31 | /* Read */ 32 | typedef BYTE ( *FDSREADSYNC)( HFDS, WORD ); 33 | /* Sync */ 34 | typedef void ( *FDSSYNC )( HFDS, INT ); 35 | 36 | -------------------------------------------------------------------------------- /arm7/include/handler.h: -------------------------------------------------------------------------------- 1 | #ifndef HANDLER_H__ 2 | #define HANDLER_H__ 3 | 4 | #include "nestypes.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef void (__fastcall *RESETHANDLER)(void); 11 | typedef void (__fastcall *TERMINATEHANDLER)(void); 12 | 13 | typedef struct NES_RESET_HANDLER_TAG { 14 | Uint priority; /* 0(first) - 15(last) */ 15 | RESETHANDLER Proc; 16 | struct NES_RESET_HANDLER_TAG *next; 17 | } NES_RESET_HANDLER; 18 | #define NES_RESET_SYS_FIRST 4 19 | #define NES_RESET_SYS_NOMAL 8 20 | #define NES_RESET_SYS_LAST 12 21 | 22 | typedef struct NES_TERMINATE_HANDLER_TAG { 23 | TERMINATEHANDLER Proc; 24 | struct NES_TERMINATE_HANDLER_TAG *next; 25 | } NES_TERMINATE_HANDLER; 26 | 27 | void NESReset(void); 28 | void NESResetHandlerInstall(NES_RESET_HANDLER *ph); 29 | void NESTerminate(void); 30 | void NESTerminateHandlerInstall(NES_TERMINATE_HANDLER *ph); 31 | void NESHandlerInitialize(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* HANDLER_H__ */ 38 | -------------------------------------------------------------------------------- /arm7/include/logtable.h: -------------------------------------------------------------------------------- 1 | #include "nestypes.h" 2 | 3 | #define LOG_BITS 12 4 | #define LIN_BITS 7 5 | #define LOG_LIN_BITS 30 6 | 7 | Uint32 LinearToLog(Int32 l); 8 | Int32 LogToLinear(Uint32 l, Uint32 sft); 9 | void LogTableInitialize(void); 10 | -------------------------------------------------------------------------------- /arm7/include/nestypes.h: -------------------------------------------------------------------------------- 1 | #ifndef NESTYPES_H__ 2 | #define NESTYPES_H__ 3 | 4 | #if defined(_MSC_VER) 5 | #define NEVER_REACH __assume(0); 6 | #elif defined(__BORLANDC__) 7 | #define __fastcall __msfastcall 8 | #elif defined(__GNUC__) 9 | #define __inline __inline__ 10 | #define __fastcall 11 | #else 12 | #define __inline 13 | #define __fastcall 14 | #endif 15 | #ifndef NEVER_REACH 16 | #define NEVER_REACH 17 | #endif 18 | 19 | typedef int Int; 20 | typedef unsigned int Uint; 21 | typedef signed int Int32; 22 | typedef unsigned int Uint32; 23 | typedef signed short Int16; 24 | typedef unsigned short Uint16; 25 | typedef signed char Int8; 26 | typedef unsigned char Uint8; 27 | typedef char Char; 28 | 29 | #define XMEMSET(d,c,n) memset(d,c,n) 30 | 31 | #endif /* NESTYPES_H__ */ 32 | -------------------------------------------------------------------------------- /arm7/include/nsdout.h: -------------------------------------------------------------------------------- 1 | #ifndef NSDOUT_H__ 2 | #define NSDOUT_H__ 3 | 4 | #include "nestypes.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | extern Uint NSD_out_mode; 11 | enum 12 | { 13 | NSD_NSF_MAPPER, 14 | NSD_VSYNC, 15 | NSD_APU, 16 | NSD_VRC6, 17 | NSD_VRC7, 18 | NSD_FDS, 19 | NSD_MMC5, 20 | NSD_N106, 21 | NSD_FME7, 22 | NSD_INITEND, 23 | NSD_MAX 24 | }; 25 | void NSDStart(Uint syncmode); 26 | void NSDWrite(Uint device, Uint address, Uint value); 27 | void NSDTerm(void (*Output)(void *p, Uint l)); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* NSDOUT_H__ */ 34 | -------------------------------------------------------------------------------- /arm7/include/nsf6502.h: -------------------------------------------------------------------------------- 1 | #ifndef NSF6502_H__ 2 | #define NSF6502_H__ 3 | 4 | #include "handler.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef Uint (__fastcall *READHANDLER)(Uint a); 11 | typedef void (__fastcall *WRITEHANDLER)(Uint a, Uint v); 12 | 13 | typedef struct NES_READ_HANDLER_TAG { 14 | Uint min; 15 | Uint max; 16 | READHANDLER Proc; 17 | struct NES_READ_HANDLER_TAG *next; 18 | } NES_READ_HANDLER; 19 | 20 | typedef struct NES_WRITE_HANDLER_TAG { 21 | Uint min; 22 | Uint max; 23 | WRITEHANDLER Proc; 24 | struct NES_WRITE_HANDLER_TAG *next; 25 | } NES_WRITE_HANDLER; 26 | 27 | void NESMemoryHandlerInitialize(void); 28 | void NESReadHandlerInstall(NES_READ_HANDLER *ph); 29 | void NESWriteHandlerInstall(NES_WRITE_HANDLER *ph); 30 | 31 | Uint NSF6502Install(void); 32 | Uint NES6502GetCycles(void); 33 | void NES6502Irq(void); 34 | Uint NES6502ReadDma(Uint A); 35 | Uint NES6502Read(Uint A); 36 | void NES6502Write(Uint A, Uint V); 37 | 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* NSF6502_H__ */ 44 | -------------------------------------------------------------------------------- /arm7/include/s_apu.h: -------------------------------------------------------------------------------- 1 | #ifndef S_APU_H__ 2 | #define S_APU_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void APUSoundInstall(void); 9 | void APU4015Reg(void); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif /* S_APU_H__ */ 16 | -------------------------------------------------------------------------------- /arm7/include/s_fds.h: -------------------------------------------------------------------------------- 1 | #ifndef S_FDS_H__ 2 | #define S_FDS_H__ 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | void FDSSoundInstall(void); 8 | void FDSSelect(unsigned type); 9 | extern void __fastcall (*FDSSoundWriteHandler)(Uint address, Uint value); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | #endif /* S_FDS_H__ */ 15 | -------------------------------------------------------------------------------- /arm7/include/s_vrc6.h: -------------------------------------------------------------------------------- 1 | #ifndef S_VRC6_H__ 2 | #define S_VRC6_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void VRC6SoundInstall(void); 9 | Int32 VRC6SoundRender1(void); 10 | Int32 VRC6SoundRender2(void); 11 | Int32 VRC6SoundRender3(void); 12 | void VRC6SoundWrite9000(Uint address, Uint value); 13 | void VRC6SoundWriteA000(Uint address, Uint value); 14 | void VRC6SoundWriteB000(Uint address, Uint value); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif /* S_VRC6_H__ */ 21 | -------------------------------------------------------------------------------- /arm7/source/arm7.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | derived from the default ARM7 core 3 | ---------------------------------------------------------------------------------*/ 4 | #include 5 | #include 6 | //#include 7 | #include "ds_misc.h" 8 | #include "c_defs.h" 9 | 10 | void nesmain(); 11 | 12 | //--------------------------------------------------------------------------------- 13 | void VblankHandler(void) { 14 | //--------------------------------------------------------------------------------- 15 | Wifi_Update(); 16 | } 17 | 18 | int ipc_region = 0; 19 | 20 | volatile bool exitflag = false; 21 | 22 | u8 *bootstub; 23 | u32 ndstype; 24 | typedef void (*type_void)(); 25 | type_void bootstub_arm7; 26 | static void sys_exit(){ 27 | if(!bootstub_arm7){ 28 | if(ndstype>=2)writePowerManagement(0x10, 1); 29 | else writePowerManagement(0, PM_SYSTEM_PWR); 30 | } 31 | bootstub_arm7(); //won't return 32 | } 33 | 34 | extern int APU_paused; 35 | //--------------------------------------------------------------------------------- 36 | int main() { 37 | //--------------------------------------------------------------------------------- 38 | readUserSettings(); 39 | 40 | irqInit(); 41 | fifoInit(); 42 | touchInit(); 43 | // Start the RTC tracking IRQ 44 | initClockIRQ(); 45 | 46 | installSystemFIFO(); 47 | installWifiFIFO(); 48 | //irqSet(IRQ_VCOUNT, VcountHandler); 49 | irqSet(IRQ_VBLANK, VblankHandler); 50 | 51 | irqEnable(IRQ_TIMER1 | IRQ_VBLANK | IRQ_NETWORK); 52 | 53 | { 54 | ndstype=0; 55 | u32 myself = readPowerManagement(4); //(PM_BACKLIGHT_LEVEL); 56 | if(myself & (1<<6)) 57 | ndstype=(myself==readPowerManagement(5))?1:2; 58 | } 59 | 60 | bootstub=(u8*)0x02ff4000; 61 | bootstub_arm7=(*(u64*)bootstub==0x62757473746F6F62ULL)?(*(type_void*)(bootstub+0x0c)):0; 62 | setPowerButtonCB(sys_exit); 63 | 64 | while(!fifoCheckValue32(FIFO_USER_06)) //wait for the value of ipc_region 65 | swiWaitForVBlank(); 66 | ipc_region = fifoGetValue32(FIFO_USER_06); 67 | 68 | nesmain(); 69 | 70 | // Keep the ARM7 mostly idle 71 | while (1) { 72 | if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) { 73 | sys_exit(); 74 | } 75 | inputGetAndSend(); 76 | swiWaitForVBlank(); 77 | } 78 | //return 0; 79 | } 80 | -------------------------------------------------------------------------------- /arm7/source/handler.c: -------------------------------------------------------------------------------- 1 | #include "handler.h" 2 | #include "nsf6502.h" 3 | 4 | /* --------------- */ 5 | /* Reset Handler */ 6 | /* --------------- */ 7 | 8 | static NES_RESET_HANDLER *(nrh[0x10]) = { 0, }; 9 | void NESReset(void) 10 | { 11 | NES_RESET_HANDLER *ph; 12 | Uint prio; 13 | for (prio = 0; prio < 0x10; prio++) { 14 | for (ph = nrh[prio]; ph; ph = ph->next) ph->Proc(); 15 | } 16 | } 17 | static void InstallPriorityResetHandler(NES_RESET_HANDLER *ph) 18 | { 19 | Uint prio = ph->priority; 20 | if (prio > 0xF) prio = 0xF; 21 | /* Add to tail of list*/ 22 | ph->next = 0; 23 | if (nrh[prio]) 24 | { 25 | NES_RESET_HANDLER *p = nrh[prio]; 26 | while (p->next) p = p->next; 27 | p->next = ph; 28 | } 29 | else 30 | { 31 | nrh[prio] = ph; 32 | } 33 | } 34 | void NESResetHandlerInstall(NES_RESET_HANDLER *ph) 35 | { 36 | for (; ph->Proc; ph++) InstallPriorityResetHandler(ph); 37 | } 38 | static void NESResetHandlerInitialize(void) 39 | { 40 | Uint prio; 41 | for (prio = 0; prio < 0x10; prio++) nrh[prio] = 0; 42 | } 43 | 44 | 45 | /* ------------------- */ 46 | /* Terminate Handler */ 47 | /* ------------------- */ 48 | static NES_TERMINATE_HANDLER *nth = 0; 49 | void NESTerminate(void) 50 | { 51 | NES_TERMINATE_HANDLER *ph; 52 | for (ph = nth; ph; ph = ph->next) ph->Proc(); 53 | NESHandlerInitialize(); 54 | } 55 | void NESTerminateHandlerInstall(NES_TERMINATE_HANDLER *ph) 56 | { 57 | /* Add to head of list*/ 58 | ph->next = nth; 59 | nth = ph; 60 | } 61 | static void NESTerminateHandlerInitialize(void) 62 | { 63 | nth = 0; 64 | } 65 | 66 | 67 | void NESHandlerInitialize(void) 68 | { 69 | NESResetHandlerInitialize(); 70 | NESTerminateHandlerInitialize(); 71 | } 72 | -------------------------------------------------------------------------------- /arm7/source/license.txt: -------------------------------------------------------------------------------- 1 | Portable HES/KSS/NSF/GBR/GBS/AY Player library 2 | Location: http://www.proc.org.tohoku.ac.jp/befis/ 3 | Language: ANSI-C 4 | Author: Mamiya (mamiya@proc.org.tohoku.ac.jp) 5 | License: PDS 6 | -------------------------------------------------------------------------------- /arm7/source/s_apu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApacheThunder/NesDS/9da2efd37e5086f35c4efb13a25009ee3e69c0d7/arm7/source/s_apu.c -------------------------------------------------------------------------------- /arm7/source/s_fds.c: -------------------------------------------------------------------------------- 1 | #include "nestypes.h" 2 | 3 | static unsigned s_type = 2; 4 | extern void FDSSoundInstall1(void); 5 | extern void FDSSoundInstall2(void); 6 | extern void FDSSoundInstall3(void); 7 | extern int FDSSoundInstallExt(void); 8 | void (*FDSSoundWriteHandler)(Uint address, Uint value); 9 | void FDSSoundInstall(void) 10 | { 11 | switch (s_type) 12 | { 13 | case 1: 14 | FDSSoundInstall1(); 15 | break; 16 | case 3: 17 | FDSSoundInstall2(); 18 | break; 19 | case 0: 20 | //if (FDSSoundInstallExt()) break; not supported 21 | break; 22 | /* fall down */ 23 | default: 24 | case 2: 25 | FDSSoundInstall3(); 26 | break; 27 | } 28 | } 29 | 30 | void FDSSelect(unsigned type) 31 | { 32 | s_type = type; 33 | } 34 | -------------------------------------------------------------------------------- /arm9/data/diskbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifndef _diskbios_h_ 8 | #define _diskbios_h_ 9 | //--------------------------------------------------------------------------------- 10 | extern const unsigned char diskbios[]; 11 | extern const int diskbios_size; 12 | //--------------------------------------------------------------------------------- 13 | #endif //_diskbios_h_ 14 | //--------------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /arm9/data/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifndef _font_h_ 8 | #define _font_h_ 9 | //--------------------------------------------------------------------------------- 10 | extern const unsigned char font[]; 11 | extern const int font_size; 12 | //--------------------------------------------------------------------------------- 13 | #endif //_font_h_ 14 | //--------------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /arm9/data/fontpal.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | const unsigned char fontpal[] = { 7 | 0x00, 0x00, 0x63, 0x0c, 0xef, 0x3d, 0x52, 0x4a, 0xd6, 0x5a, 0x39, 0x67, 0x9c, 0x73, 0xde, 0x7b, 8 | 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x00, 0x63, 0x0c, 0x01, 0x69, 0x64, 0x6d, 0xe8, 0x75, 0x4b, 0x7a, 0xaf, 0x7e, 0x14, 0x7f, 10 | 0x9a, 0x7f, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0x5f, 0x6b, 0x9f, 0x52, 0xff, 0x3d, 0x7e, 0x2d, 0x1d, 0x21, 12 | 0x9b, 0x10, 0x3a, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 13 | 0x00, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 14 | 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x63, 0x0c, 0xef, 0x3d, 0x52, 0x4a, 0xd6, 0x5a, 0x39, 0x67, 0x9c, 0x73, 0xde, 0x7b, 20 | 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00, 0x63, 0x0c, 0x5a, 0x05, 0xbb, 0x11, 0xfd, 0x21, 0x5e, 0x2e, 0xbf, 0x3e, 0x1f, 0x53, 22 | 0x9f, 0x6b, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f 39 | 40 | }; 41 | const int fontpal_size = sizeof(fontpal); 42 | -------------------------------------------------------------------------------- /arm9/data/fontpal.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifndef _fontpal_h_ 8 | #define _fontpal_h_ 9 | //--------------------------------------------------------------------------------- 10 | extern const unsigned char fontpal[]; 11 | extern const int fontpal_size; 12 | //--------------------------------------------------------------------------------- 13 | #endif //_fontpal_h_ 14 | //--------------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /arm9/data/nespal.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | const unsigned char nespal[] = { 7 | 0x94, 0x52, 0x0a, 0x59, 0x00, 0x64, 0x0f, 0x60, 0x16, 0x50, 0x19, 0x1c, 0x19, 0x00, 0xb5, 0x00, 8 | 0x8e, 0x01, 0xe0, 0x01, 0x00, 0x02, 0xc0, 0x1d, 0xc8, 0x49, 0x00, 0x00, 0x29, 0x25, 0x00, 0x00, 9 | 0x5a, 0x6b, 0x80, 0x7a, 0xaa, 0x79, 0x15, 0x7c, 0x1b, 0x6c, 0x1e, 0x44, 0x7d, 0x01, 0x1b, 0x1a, 10 | 0x96, 0x02, 0xe0, 0x02, 0x20, 0x03, 0xe0, 0x36, 0xa0, 0x5a, 0x4a, 0x29, 0x00, 0x00, 0x00, 0x00, 11 | 0xff, 0x7f, 0x6e, 0x7f, 0xf2, 0x7e, 0xd9, 0x7e, 0x9f, 0x7e, 0x9f, 0x6a, 0x9f, 0x4a, 0xff, 0x36, 12 | 0x7f, 0x3b, 0x95, 0x1f, 0xb0, 0x3f, 0xf1, 0x5f, 0xc0, 0x77, 0xb5, 0x56, 0x00, 0x00, 0x00, 0x00, 13 | 0xff, 0x7f, 0xd9, 0x7f, 0x9b, 0x7f, 0x7c, 0x7f, 0x7f, 0x7f, 0x7f, 0x77, 0x7f, 0x6b, 0xbf, 0x67, 14 | 0xdf, 0x63, 0xfd, 0x63, 0xf9, 0x6f, 0xfa, 0x73, 0xf8, 0x7f, 0x9c, 0x73, 0x00, 0x00, 0x00, 0x00 15 | 16 | }; 17 | const int nespal_size = sizeof(nespal); 18 | -------------------------------------------------------------------------------- /arm9/data/nespal.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifndef _nespal_h_ 8 | #define _nespal_h_ 9 | //--------------------------------------------------------------------------------- 10 | extern const unsigned char nespal[]; 11 | extern const int nespal_size; 12 | //--------------------------------------------------------------------------------- 13 | #endif //_nespal_h_ 14 | //--------------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /arm9/include/menu.h: -------------------------------------------------------------------------------- 1 | struct menu_item 2 | { 3 | char *name; //name of the menu 4 | int none; //align for button 5 | char x,y,w,h; //for button 6 | int type; //type 7 | struct menu_unit *child; 8 | void (*func)(void); //for function 9 | }; 10 | 11 | struct menu_unit 12 | { 13 | char *top; //name of the menu 14 | int subcnt; //count of items. 15 | void (*start)(void); //when init the menu, call this function... 16 | struct menu_item *item; //point to the submenu or the functions. maybe array. 17 | }; 18 | 19 | struct button 20 | { 21 | char *name; 22 | short type; 23 | short stat; 24 | char x,y,w,h; 25 | }; 26 | 27 | extern struct button top_button[]; 28 | extern int top_bcnt; 29 | extern struct button menu_button[]; 30 | extern int menu_bcnt; 31 | extern struct button user_button[]; 32 | extern int user_bcnt; 33 | 34 | extern struct button *lastbutton; 35 | extern int lastbutton_type; 36 | extern int lastbutton_cnt; 37 | 38 | extern int menu_stat; 39 | extern struct menu_unit *menu_array[16]; 40 | extern int menu_depth; 41 | extern struct menu_unit *last_menu; 42 | extern char last_type; 43 | extern int menu_draw; 44 | 45 | extern void (*menu_func)(void); 46 | 47 | void draw_button(char *text, int x, int y, int w, int h, int color); 48 | int add_buttonp(int group, struct button *adb); 49 | int add_button(int group, char *name, char type, char x, char y, char w, char h); 50 | void show_button_group(int group); 51 | void check_button_group(int group); 52 | 53 | void menu_hide(void); 54 | void menu_file_loadrom(void); 55 | void menu_file_savestate(void); 56 | void menu_file_loadstate(void); 57 | void menu_file_savesram(void); 58 | void menu_file_slot(void); 59 | void menu_file_start(void); 60 | void menu_game_start(void); 61 | void menu_game_pal(void); 62 | void menu_game_ntsc(void); 63 | void menu_game_input(void); 64 | void menu_game_reset(void); 65 | void menu_input_start(void); 66 | void menu_display_start(void); 67 | void menu_display_br(void); 68 | void menu_display_adjust(void); 69 | void menu_adjust_start(void); 70 | void menu_nifi_start(void); 71 | void menu_nifi_action(void); 72 | void menu_extra_start(void); 73 | void menu_extra_action(void); 74 | void menu_cheat_search_start(void); 75 | void menu_cheat_list_start(void); 76 | void menu_search_action(void); 77 | void menu_list_action(void); 78 | void menu_cht_action(void); 79 | void menu_debug_start(void); 80 | void menu_debug_action(void); 81 | void autofire_fresh(void); 82 | 83 | void menu_shortcut_start(void); 84 | void menu_shortcut_func(void); 85 | 86 | void menu_config_func(void); 87 | void menu_about_start(void); 88 | void menu_about_action(void); 89 | void menu_extra_fds(void); 90 | void menu_extra_barcode(void); 91 | void menu_saveini(void); 92 | void menu_extra_barcode_start(void); 93 | 94 | void show_all_pixel(void); 95 | -------------------------------------------------------------------------------- /arm9/include/minIni.h: -------------------------------------------------------------------------------- 1 | /* minIni - Multi-Platform INI file parser, suitable for embedded systems 2 | * 3 | * Copyright (c) ITB CompuPhase, 2008-2009 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy 7 | * of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations 15 | * under the License. 16 | * 17 | * Version: $Id: minIni.h 24 2009-05-06 08:01:53Z thiadmer.riemersma $ 18 | */ 19 | #ifndef MININI_H 20 | #define MININI_H 21 | 22 | #define strnicmp strncasecmp 23 | 24 | 25 | #define INI_ANSIONLY 26 | #define MININI_ANSI 27 | //#define INI_READONLY 28 | 29 | #include 30 | #define ini_openread(filename,file) ((*(file) = fopen((filename),"rt")) != NULL) 31 | #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"wt")) != NULL) 32 | #define ini_close(file) fclose(*(file)) 33 | #define ini_read(buffer,size,file) fgets((buffer),(size),*(file)) 34 | #define ini_write(buffer,file) fputs((buffer),*(file)) 35 | #define ini_rename(source,dest) rename((source),(dest)) 36 | #define ini_remove(filename) unlink(filename) 37 | #define ini_rewind(file) rewind(*(file)) 38 | 39 | #if (defined _UNICODE || defined __UNICODE__ || defined UNICODE) && !defined INI_ANSIONLY 40 | #include 41 | #elif !defined __T 42 | typedef char TCHAR; 43 | #endif 44 | 45 | #if !defined INI_BUFFERSIZE 46 | #define INI_BUFFERSIZE 4096 47 | #endif 48 | 49 | #if defined __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | long ini_getl(const TCHAR *Section, const TCHAR *Key, long DefValue, const TCHAR *Filename); 54 | int ini_gets(const TCHAR *Section, const TCHAR *Key, const TCHAR *DefValue, TCHAR *Buffer, int BufferSize, const TCHAR *Filename); 55 | int ini_putl(const TCHAR *Section, const TCHAR *Key, long Value, const TCHAR *Filename); 56 | int ini_puts(const TCHAR *Section, const TCHAR *Key, const TCHAR *Value, const TCHAR *Filename); 57 | int ini_getsection(int idx, TCHAR *Buffer, int BufferSize, const TCHAR *Filename); 58 | int ini_getkey(const TCHAR *Section, int idx, TCHAR *Buffer, int BufferSize, const TCHAR *Filename); 59 | 60 | #if defined __cplusplus 61 | } 62 | #endif 63 | 64 | #if defined __cplusplus 65 | #include 66 | 67 | /* The C++ class in minIni.h was contributed by Steven Van Ingelgem. */ 68 | class minIni 69 | { 70 | public: 71 | minIni(const std::string& filename) : iniFilename(filename) 72 | { } 73 | 74 | long getl(const std::string& Section, const std::string& Key, long DefValue=0) const 75 | { return ini_getl(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); } 76 | 77 | long geti(const std::string& Section, const std::string& Key, int DefValue=0) const 78 | { return reinterpret_cast( this->getl(Section, Key, DefValue) ); } 79 | 80 | std::string gets(const std::string& Section, const std::string& Key, const std::string& DefValue="") const 81 | { 82 | char buffer[INI_BUFFERSIZE]; 83 | ini_gets(Section.c_str(), Key.c_str(), DefValue.c_str(), buffer, INI_BUFFERSIZE, iniFilename.c_str()); 84 | return buffer; 85 | } 86 | 87 | bool put(const std::string& Section, const std::string& Key, long Value) const 88 | { return ini_putl(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()); } 89 | 90 | bool put(const std::string& Section, const std::string& Key, const std::string& Value) const 91 | { return ini_puts(Section.c_str(), Key.c_str(), Value.c_str(), iniFilename.c_str()); } 92 | 93 | private: 94 | std::string iniFilename; 95 | }; 96 | 97 | #endif /* __cplusplus */ 98 | 99 | #endif /* MININI_H */ 100 | 101 | -------------------------------------------------------------------------------- /arm9/include/multi.h: -------------------------------------------------------------------------------- 1 | #ifndef _multi_nesds__ 2 | #define _multi_nesds__ 3 | 4 | #include "../../common/wifi_shared.h" 5 | 6 | #include 7 | 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | extern "C"{ 12 | #endif 13 | 14 | extern Wifi_MainStruct Wifi_Data_Struct; 15 | extern WifiSyncHandler synchandler; 16 | extern volatile Wifi_MainStruct * WifiData; 17 | extern int Wifi_RawTxFrameNIFI(u16 datalen, u16 rate, u16 * data); 18 | extern void Handler(int packetID, int readlength); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /arm9/source/barcode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ds_misc.h" 3 | #include "c_defs.h" 4 | 5 | char prefix_parity_type[10][6] = { 6 | {0,0,0,0,0,0}, {0,0,1,0,1,1}, {0,0,1,1,0,1}, {0,0,1,1,1,0}, 7 | {0,1,0,0,1,1}, {0,1,1,0,0,1}, {0,1,1,1,0,0}, {0,1,0,1,0,1}, 8 | {0,1,0,1,1,0}, {0,1,1,0,1,0} 9 | }; 10 | char data_left_odd[10][7] = { 11 | {0,0,0,1,1,0,1}, {0,0,1,1,0,0,1}, {0,0,1,0,0,1,1}, {0,1,1,1,1,0,1}, 12 | {0,1,0,0,0,1,1}, {0,1,1,0,0,0,1}, {0,1,0,1,1,1,1}, {0,1,1,1,0,1,1}, 13 | {0,1,1,0,1,1,1}, {0,0,0,1,0,1,1} 14 | }; 15 | char data_left_even[10][7] = { 16 | {0,1,0,0,1,1,1}, {0,1,1,0,0,1,1}, {0,0,1,1,0,1,1}, {0,1,0,0,0,0,1}, 17 | {0,0,1,1,1,0,1}, {0,1,1,1,0,0,1}, {0,0,0,0,1,0,1}, {0,0,1,0,0,0,1}, 18 | {0,0,0,1,0,0,1}, {0,0,1,0,1,1,1} 19 | }; 20 | char data_right[10][7] = { 21 | {1,1,1,0,0,1,0}, {1,1,0,0,1,1,0}, {1,1,0,1,1,0,0}, {1,0,0,0,0,1,0}, 22 | {1,0,1,1,1,0,0}, {1,0,0,1,1,1,0}, {1,0,1,0,0,0,0}, {1,0,0,0,1,0,0}, 23 | {1,0,0,1,0,0,0}, {1,1,1,0,1,0,0} 24 | }; 25 | 26 | unsigned char barcode_data[256]; 27 | void setbarcodedata( char *code, int len ) 28 | { 29 | /* 30 | if( rom->GetPROM_CRC() == 0x67898319 ) { // Barcode World (J) 31 | SetBarcode2Data( code, len ); 32 | return; 33 | }*/ 34 | 35 | int i, j, count = 0; 36 | 37 | for( i = 0; i < len; i++ ) { 38 | code[i] = code[i]-'0'; 39 | } 40 | 41 | for( i = 0; i < 32; i++ ) { 42 | barcode_data[count++] = 0x08; 43 | } 44 | 45 | barcode_data[count++] = 0x00; 46 | barcode_data[count++] = 0x08; 47 | barcode_data[count++] = 0x00; 48 | 49 | if( len == 13 ) { 50 | for( i = 0; i < 6; i++ ) { 51 | if( prefix_parity_type[(int)code[0]][i] ) { 52 | for( j = 0; j < 7; j++ ) { 53 | barcode_data[count++] = data_left_even[(int)code[i+1]][j]?0x00:0x08; 54 | } 55 | } else { 56 | for( j = 0; j < 7; j++ ) { 57 | barcode_data[count++] = data_left_odd[(int)code[i+1]][j]?0x00:0x08; 58 | } 59 | } 60 | } 61 | 62 | barcode_data[count++] = 0x08; 63 | barcode_data[count++] = 0x00; 64 | barcode_data[count++] = 0x08; 65 | barcode_data[count++] = 0x00; 66 | barcode_data[count++] = 0x08; 67 | 68 | for( i = 7; i < 13; i++ ) { 69 | for( j = 0; j < 7; j++ ) { 70 | barcode_data[count++] = data_right[(int)code[i]][j]?0x00:0x08; 71 | } 72 | } 73 | } 74 | else if( len == 8 ) { 75 | int sum = 0; 76 | for( i = 0; i < 7; i++ ) { 77 | sum += (i&1)?code[i]:(code[i]*3); 78 | } 79 | code[7] = (10-(sum%10))%10; 80 | 81 | for( i = 0; i < 4; i++ ) { 82 | for( j = 0; j < 7; j++ ) { 83 | barcode_data[count++] = data_left_odd[(int)code[i]][j]?0x00:0x08; 84 | } 85 | } 86 | 87 | barcode_data[count++] = 0x08; 88 | barcode_data[count++] = 0x00; 89 | barcode_data[count++] = 0x08; 90 | barcode_data[count++] = 0x00; 91 | barcode_data[count++] = 0x08; 92 | 93 | for( i = 4; i < 8; i++ ) { 94 | for( j = 0; j < 7; j++ ) { 95 | barcode_data[count++] = data_right[(int)code[i]][j]?0x00:0x08; 96 | } 97 | } 98 | } 99 | 100 | barcode_data[count++] = 0x00; 101 | barcode_data[count++] = 0x08; 102 | barcode_data[count++] = 0x00; 103 | 104 | for( i = 0; i < 32; i++ ) { 105 | barcode_data[count++] = 0x08; 106 | } 107 | 108 | barcode_data[count++] = 0xFF; 109 | 110 | __barcode = 1; 111 | __barcode_out = 0x08; 112 | } 113 | 114 | /* 115 | unsigned char NES::Barcode2( void ) 116 | { 117 | unsigned char ret = 0x00; 118 | 119 | if( !m_bBarcode2 || m_Barcode2seq < 0 ) 120 | return ret; 121 | 122 | switch( m_Barcode2seq ) { 123 | case 0: 124 | m_Barcode2seq++; 125 | m_Barcode2ptr = 0; 126 | ret = 0x04; // d3 127 | break; 128 | 129 | case 1: 130 | m_Barcode2seq++; 131 | m_Barcode2bit = m_Barcode2data[m_Barcode2ptr]; 132 | m_Barcode2cnt = 0; 133 | ret = 0x04; // d3 134 | break; 135 | 136 | case 2: 137 | ret = (m_Barcode2bit&0x01)?0x00:0x04; // Bit rev. 138 | m_Barcode2bit >>= 1; 139 | if( ++m_Barcode2cnt > 7 ) { 140 | m_Barcode2seq++; 141 | } 142 | break; 143 | case 3: 144 | if( ++m_Barcode2ptr > 19 ) { 145 | m_bBarcode2 = FALSE; 146 | m_Barcode2seq = -1; 147 | } else { 148 | m_Barcode2seq = 1; 149 | } 150 | break; 151 | default: 152 | break; 153 | } 154 | 155 | return ret; 156 | } 157 | 158 | void NES::SetBarcode2Data( LPBYTE code, INT len ) 159 | { 160 | DEBUGOUT( "NES::SetBarcodeData2 code=%s len=%d\n", code, len ); 161 | 162 | if( len < 13 ) 163 | return; 164 | 165 | m_bBarcode2 = TRUE; 166 | m_Barcode2seq = 0; 167 | m_Barcode2ptr = 0; 168 | 169 | ::strcpy( (char*)m_Barcode2data, (char*)code ); 170 | 171 | m_Barcode2data[13] = 'S'; 172 | m_Barcode2data[14] = 'U'; 173 | m_Barcode2data[15] = 'N'; 174 | m_Barcode2data[16] = 'S'; 175 | m_Barcode2data[17] = 'O'; 176 | m_Barcode2data[18] = 'F'; 177 | m_Barcode2data[19] = 'T'; 178 | }*/ -------------------------------------------------------------------------------- /arm9/source/dswifi_arm9/wifi_arm9.h: -------------------------------------------------------------------------------- 1 | // DS Wifi interface code 2 | // Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org 3 | // wifi_arm9.c - arm9 wifi support header 4 | /****************************************************************************** 5 | DSWifi Lib and test materials are licenced under the MIT open source licence: 6 | Copyright (c) 2005-2006 Stephen Stair 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | this software and associated documentation files (the "Software"), to deal in 10 | the Software without restriction, including without limitation the rights to 11 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | of the Software, and to permit persons to whom the Software is furnished to do 13 | so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | ******************************************************************************/ 26 | 27 | 28 | #ifndef WIFI_ARM9_H 29 | #define WIFI_ARM9_H 30 | 31 | 32 | #include 33 | #include "../../../common/wifi_shared.h" 34 | 35 | #define SGIP_DEBUG_MESSAGE(param) 36 | #define SGIP_DEBUG_ERROR(param) 37 | 38 | #ifdef WIFI_USE_TCP_SGIP 39 | 40 | 41 | // Wifi Packet Handler function: (int packetID, int packetlength) - packetID is only valid while the called function is executing. 42 | // call Wifi_RxRawReadPacket while in the packet handler function, to retreive the data to a local buffer. 43 | typedef void (*WifiPacketHandler)(int, int); 44 | 45 | // Wifi Sync Handler function: Callback function that is called when the arm7 needs to be told to synchronize with new fifo data. 46 | // If this callback is used (see Wifi_SetSyncHandler()), it should send a message via the fifo to the arm7, which will call Wifi_Sync() on arm7. 47 | typedef void (*WifiSyncHandler)(); 48 | #endif 49 | 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | 56 | extern volatile Wifi_MainStruct * WifiData; 57 | extern WifiSyncHandler synchandler; 58 | 59 | extern void Wifi_CopyMacAddr(volatile void * dest, volatile void * src); 60 | extern int Wifi_CmpMacAddr(volatile void * mac1, volatile void * mac2); 61 | 62 | extern unsigned long Wifi_Init(int initflags); 63 | extern bool Wifi_InitDefaultCustom(bool useFirmwareSettings); 64 | extern int Wifi_CheckInit(); 65 | 66 | extern int Wifi_RawTxFrame(u16 datalen, u16 rate, u16 * data); 67 | extern void Wifi_SetSyncHandler(WifiSyncHandler wshfunc); 68 | extern void Wifi_RawSetPacketHandler(WifiPacketHandler wphfunc); 69 | extern int Wifi_RxRawReadPacket(s32 packetID, s32 readlength, u16 * data); 70 | 71 | extern void Wifi_DisableWifi(); 72 | extern void Wifi_EnableWifi(); 73 | extern void Wifi_SetPromiscuousMode(int enable); 74 | extern void Wifi_ScanMode(); 75 | extern void Wifi_SetChannel(int channel); 76 | 77 | extern int Wifi_GetNumAP(); 78 | extern int Wifi_GetAPData(int apnum, Wifi_AccessPoint * apdata); 79 | extern int Wifi_FindMatchingAP(int numaps, Wifi_AccessPoint * apdata, Wifi_AccessPoint * match_dest); 80 | extern int Wifi_ConnectAP(Wifi_AccessPoint * apdata, int wepmode, int wepkeyid, u8 * wepkey); 81 | extern void Wifi_AutoConnect(); 82 | 83 | extern int Wifi_AssocStatus(); 84 | extern int Wifi_DisconnectAP(); 85 | extern int Wifi_GetData(int datatype, int bufferlen, unsigned char * buffer); 86 | 87 | 88 | extern void Wifi_Update(); 89 | extern void Wifi_Sync(); 90 | 91 | 92 | #ifdef WIFI_USE_TCP_SGIP 93 | extern void Wifi_Timer(int num_ms); 94 | extern void Wifi_SetIP(u32 IPaddr, u32 gateway, u32 subnetmask, u32 dns1, u32 dns2); 95 | extern u32 Wifi_GetIP(); 96 | #endif 97 | 98 | extern int Wifi_RawTxFrame_NIFI(u16 datalen, u16 rate, u16 * data); 99 | extern void arm9_synctoarm7Custom(); 100 | extern void Timer_50ms(void); 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif -------------------------------------------------------------------------------- /arm9/source/exception.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApacheThunder/NesDS/9da2efd37e5086f35c4efb13a25009ee3e69c0d7/arm9/source/exception.c -------------------------------------------------------------------------------- /arm9/source/gesture.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ds_misc.h" 5 | #include "c_defs.h" 6 | #include "menu.h" 7 | 8 | #define GMARGIN 32 9 | 10 | int gesture = 0; //not active 11 | int gesture_x = 0; //old value 12 | int gesture_y = 0; 13 | int gesture_type = 0; //0 = stop, 1 = start, 4 = Up, 5 = Left, 6 = Down, 7 = Right 14 | char gesture_combo[32] = {0}; 15 | int gesture_pos = 0; 16 | int last_pos = 0; 17 | 18 | void add_combo(void) 19 | { 20 | if(gesture_pos >= 16) 21 | return; 22 | 23 | gesture_x = last_x; 24 | gesture_y = last_y; 25 | 26 | switch(gesture_type) { 27 | case 4: 28 | gesture_combo[gesture_pos++] = 'U'; 29 | break; 30 | case 5: 31 | gesture_combo[gesture_pos++] = 'L'; 32 | break; 33 | case 6: 34 | gesture_combo[gesture_pos++] = 'D'; 35 | break; 36 | case 7: 37 | gesture_combo[gesture_pos++] = 'R'; 38 | break; 39 | } 40 | gesture_combo[gesture_pos] = 0; 41 | } 42 | 43 | void check_motion(void) 44 | { 45 | if(last_y > gesture_y + GMARGIN) { //down motion priority highest. 46 | gesture_type = 6; 47 | } 48 | else if(last_x > gesture_x + GMARGIN) { //right motion 49 | gesture_type = 7; 50 | } 51 | else if(last_x < gesture_x - GMARGIN) { //left motion 52 | gesture_type = 5; 53 | } 54 | else if(last_y < gesture_y - GMARGIN) { //up motion 55 | gesture_type = 4; 56 | } 57 | } 58 | 59 | void do_gesture(void) 60 | { 61 | if(menu_stat !=0) 62 | return; 63 | 64 | if(!(IPC_KEYS & KEY_TOUCH) && touchstate != 4) { 65 | gesture = 0; 66 | gesture_type = 0; 67 | return; 68 | } 69 | 70 | if(gesture_type == 0 && touchstate == 2) { 71 | memset((void *)(SUB_BG),0,64*24); 72 | powerOn(PM_BACKLIGHT_BOTTOM | PM_BACKLIGHT_TOP); 73 | consoletext(64 * 4 + 16, "Gesture Motions:", 0); 74 | gesture_type = 1; 75 | gesture_x = last_x; 76 | gesture_y = last_y; 77 | gesture_pos = 0; 78 | last_pos = 0; 79 | gesture_combo[0] = 0; 80 | return; 81 | } 82 | 83 | if(touchstate > 1 && touchstate < 4) { 84 | switch(gesture_type) { 85 | case 1: 86 | check_motion(); 87 | if(gesture_type != 1) { 88 | add_combo(); 89 | } 90 | break; 91 | case 4: 92 | if(last_y < gesture_y) 93 | gesture_y = last_y; 94 | check_motion(); 95 | if(gesture_type != 4) 96 | add_combo(); 97 | break; 98 | case 5: 99 | if(last_x < gesture_x) 100 | gesture_x = last_x; 101 | check_motion(); 102 | if(gesture_type != 5) 103 | add_combo(); 104 | break; 105 | case 6: 106 | if(last_y > gesture_y) 107 | gesture_y = last_y; 108 | check_motion(); 109 | if(gesture_type != 6) 110 | add_combo(); 111 | break; 112 | case 7: 113 | if(last_x > gesture_x) 114 | gesture_x = last_x; 115 | check_motion(); 116 | if(gesture_type != 7) 117 | add_combo(); 118 | break; 119 | } 120 | } 121 | else if(touchstate == 4) { 122 | if(gesture_pos > 0) { 123 | int i; 124 | 125 | if(!(__emuflags & SCREENSWAP)) { 126 | powerOff(PM_BACKLIGHT_BOTTOM); 127 | } else { 128 | powerOff(PM_BACKLIGHT_TOP); 129 | } 130 | 131 | do_gesture_type = -1; 132 | for(i = 0; i < MAX_SC; i++) { 133 | if(!strcmp(gesture_combo, gestures_tbl[i])) { 134 | do_gesture_type = i; 135 | break; 136 | } 137 | } 138 | 139 | gesture_type = 0; 140 | gesture = 1; 141 | gesture_pos = 0; 142 | last_pos = 0; 143 | hideconsole(); 144 | gesture_combo[0] = 0; 145 | return; 146 | } 147 | else if(__emuflags & LIGHTGUN) { 148 | if(!(__emuflags & SCREENSWAP)) { 149 | powerOff(PM_BACKLIGHT_BOTTOM); 150 | } else { 151 | powerOff(PM_BACKLIGHT_TOP); 152 | } 153 | } 154 | } 155 | 156 | if(last_pos != gesture_pos) { 157 | consoletext(64 * 5 + 16, " ", 0); 158 | consoletext(64 * 5 + 16, gesture_combo, 0x1000); 159 | } 160 | last_pos = gesture_pos; 161 | } 162 | 163 | //get a gesture, shonw at *out*. 164 | int get_gesture(int out) 165 | { 166 | if(!(IPC_KEYS & KEY_TOUCH) && touchstate != 4) { 167 | gesture = 0; 168 | gesture_type = 0; 169 | return 0; 170 | } 171 | 172 | if(gesture_type == 0 && touchstate == 2) { 173 | gesture_type = 1; 174 | gesture_x = last_x; 175 | gesture_y = last_y; 176 | gesture_pos = 0; 177 | last_pos = 0; 178 | gesture_combo[0] = 0; 179 | return 0; 180 | } 181 | 182 | if(touchstate > 1 && touchstate < 4) { 183 | switch(gesture_type) { 184 | case 1: 185 | check_motion(); 186 | if(gesture_type != 1) { 187 | add_combo(); 188 | } 189 | break; 190 | case 4: 191 | if(last_y < gesture_y) 192 | gesture_y = last_y; 193 | check_motion(); 194 | if(gesture_type != 4) 195 | add_combo(); 196 | break; 197 | case 5: 198 | if(last_x < gesture_x) 199 | gesture_x = last_x; 200 | check_motion(); 201 | if(gesture_type != 5) 202 | add_combo(); 203 | break; 204 | case 6: 205 | if(last_y > gesture_y) 206 | gesture_y = last_y; 207 | check_motion(); 208 | if(gesture_type != 6) 209 | add_combo(); 210 | break; 211 | case 7: 212 | if(last_x > gesture_x) 213 | gesture_x = last_x; 214 | check_motion(); 215 | if(gesture_type != 7) 216 | add_combo(); 217 | break; 218 | } 219 | } 220 | else if(touchstate == 4) { 221 | if(gesture_pos > 0) { 222 | return 1; 223 | } 224 | else 225 | return -1; 226 | } 227 | 228 | if(last_pos != gesture_pos) { 229 | consoletext(out, " ", 0); 230 | consoletext(out, gesture_combo, 0x1000); 231 | } 232 | last_pos = gesture_pos; 233 | return 0; 234 | } 235 | 236 | 237 | 238 | 239 | -------------------------------------------------------------------------------- /arm9/source/ips.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ds_misc.h" 5 | #include "c_defs.h" 6 | 7 | int ips_stat = 0; // 0 = no ips, 1 = already has one. 8 | int ips_len = 0; //length of ips patch. 9 | char *ips_start = (char *)rom_start + ROM_MAX_SIZE - MAX_IPS_SIZE; //alloca the ips patch here. 10 | 11 | void load_ips(const char *name) 12 | { 13 | FILE *fp; 14 | 15 | ips_stat = 0; 16 | ips_len = 0; 17 | 18 | fp = fopen(name,"rb"); 19 | if(!fp) 20 | return; 21 | 22 | ips_len = fread(ips_start,1,MAX_IPS_SIZE,fp); 23 | 24 | if(ips_len > 0) 25 | ips_stat = 1; 26 | else 27 | ips_stat = 0; 28 | 29 | fclose(fp); 30 | } 31 | 32 | unsigned int read24(const void *p){ 33 | const unsigned char *x=(const unsigned char*)p; 34 | return x[2]|(x[1]<<8)|(x[0]<<16); 35 | } 36 | 37 | unsigned short read16(const void *p){ 38 | const unsigned char *x=(const unsigned char*)p; 39 | return x[1]|(x[0]<<8); 40 | } 41 | 42 | int ipspatch(char *pfile, int *sizfile, const char *pips, const unsigned int sizips){ //pass pfile=NULL to get sizfile. 43 | unsigned int offset=5,address=0,size=-1,u; 44 | if(sizips<8||memcmp(pips,"PATCH",5))return 2; 45 | if(!pfile)*sizfile=0; 46 | while(1){ 47 | if(offset+3>sizips)return 1;address=read24(pips+offset);offset+=3; 48 | if(address==0x454f46&&offset==sizips)break; 49 | if(offset+2>sizips)return 1;size=read16(pips+offset);offset+=2; 50 | if(size){ 51 | if(offset+size>sizips)return 1; 52 | if(!pfile){ 53 | if(*sizfile*sizfile)return 1; 58 | //fprintf(stderr,"write 0x%06x %dbytes\n",address,size); 59 | memcpy(pfile+address,pips+offset,size); 60 | offset+=size; 61 | }else{ 62 | if(offset+3>sizips)return 1;size=read16(pips+offset);offset+=2; 63 | if(!pfile){ 64 | if(*sizfile*sizfile)return 1; 69 | //fprintf(stderr,"fill 0x%06x %dbytes\n",address,size); 70 | for(u=address;u 2 | #include 3 | #include 4 | 5 | //extern size_t _FAT_directory_ucs2tombs (char* dst, const unsigned short* src, size_t len); //this should not be used, because fat.h does NOT list it. 6 | size_t ucs2tombs(unsigned char* dst, const unsigned short* src, size_t len) { 7 | size_t i=0,j=0; 8 | for (;src[i];i++){ 9 | if(src[i] <= 0x007f){ 10 | if(!dst)j++;else{ 11 | if(len-j<2)break; 12 | dst[j++] = ((src[i] & 0x007f) ); 13 | } 14 | }else if(src[i] <= 0x07ff){ 15 | if(!dst)j+=2;else{ 16 | if(len-j<3)break; 17 | dst[j++] = ((src[i] & 0x07c0) >> 6) | 0xc0; 18 | dst[j++] = ((src[i] & 0x003f) ) | 0x80; 19 | } 20 | }else if((src[i] & 0xdc00) == 0xd800 && (src[i+1] & 0xdc00) == 0xdc00){ 21 | if(!dst)j+=4;else{ 22 | unsigned short z = (src[i]&0x3ff)+0x40; 23 | if(len-j<5)break; 24 | dst[j++] = ((z & 0x0300) >> 8) | 0xf0; //2 25 | dst[j++] = ((z & 0x00fc) >> 2) | 0x80; //6 26 | dst[j++] = ((z & 0x0003) << 4) //2 27 | | ((src[i+1] & 0x03c0) >> 6) | 0x80; //4 28 | dst[j++] = ((src[i+1] & 0x003f) ) | 0x80; //6 29 | }i++; 30 | }else{ 31 | if(!dst)j+=3;else{ 32 | if(len-j<4)break; 33 | dst[j++] = ((src[i] & 0xf000) >> 12) | 0xe0; 34 | dst[j++] = ((src[i] & 0x0fc0) >> 6) | 0x80; 35 | dst[j++] = ((src[i] & 0x003f) ) | 0x80; 36 | } 37 | } 38 | } 39 | if(dst)dst[j]=0; 40 | return j; 41 | } 42 | 43 | static u8 buf[768]; //lol 44 | 45 | typedef u16 UnicodeChar; 46 | #define ExtLinkBody_MaxLength (256) 47 | #define ExtLinkBody_ID (0x30545845) // EXT0 48 | typedef struct { 49 | u32 ID,dummy1,dummy2,dummy3; // dummy is ZERO. 50 | char DataFullPathFilenameAlias[ExtLinkBody_MaxLength]; 51 | char DataPathAlias[ExtLinkBody_MaxLength]; 52 | char DataFilenameAlias[ExtLinkBody_MaxLength]; 53 | char NDSFullPathFilenameAlias[ExtLinkBody_MaxLength]; 54 | char NDSPathAlias[ExtLinkBody_MaxLength]; 55 | char NDSFilenameAlias[ExtLinkBody_MaxLength]; 56 | UnicodeChar DataFullPathFilenameUnicode[ExtLinkBody_MaxLength]; 57 | UnicodeChar DataPathUnicode[ExtLinkBody_MaxLength]; 58 | UnicodeChar DataFilenameUnicode[ExtLinkBody_MaxLength]; 59 | UnicodeChar NDSFullPathFilenameUnicode[ExtLinkBody_MaxLength]; 60 | UnicodeChar NDSPathUnicode[ExtLinkBody_MaxLength]; 61 | UnicodeChar NDSFilenameUnicode[ExtLinkBody_MaxLength]; 62 | } TExtLinkBody; 63 | 64 | char* myfgets(char *buf,int n,FILE *fp){ //accepts LF/CRLF 65 | char *ret=fgets(buf,n,fp); 66 | if(!ret)return NULL; 67 | if(strlen(buf)&&buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0; 68 | if(strlen(buf)&&buf[strlen(buf)-1]=='\r')buf[strlen(buf)-1]=0; 69 | return ret; 70 | } 71 | 72 | void SplitItemFromFullPathAlias(const char *pFullPathAlias,char *pPathAlias,char *pFilenameAlias){ 73 | u32 SplitPos=0; 74 | { 75 | u32 idx=0; 76 | while(1){ 77 | char uc=pFullPathAlias[idx]; 78 | if(uc==0) break; 79 | if(uc=='/') SplitPos=idx+1; 80 | idx++; 81 | } 82 | } 83 | 84 | if(pPathAlias){ 85 | if(SplitPos<=1){ 86 | pPathAlias[0]='/'; 87 | pPathAlias[1]=0; 88 | }else{ 89 | u32 idx=0; 90 | for(;idx1){ 151 | strcpy(target,argv[1]); 152 | }else{ 153 | if(!_readFrontend(target))return false; 154 | } 155 | SplitItemFromFullPathAlias(target,dir,NULL); 156 | chdir(dir); 157 | return true; 158 | } 159 | 160 | -------------------------------------------------------------------------------- /arm9/source/sound.s: -------------------------------------------------------------------------------- 1 | @--------------------------------------------------------------------------------- 2 | #include "equates.h" 3 | @--------------------------------------------------------------------------------- 4 | .global updatesound 5 | .global soundwrite 6 | .global _4015r 7 | pcmirqbakup = mapperdata+24 8 | pcmirqcount = mapperdata+28 9 | @--------------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | @--------------------------------------------------------------------------------- 12 | @Sound_reset moved to junk.c 13 | @--------------------------------------------------------------------------------- 14 | @mov r0,#0x00001000 15 | @str r0,pcmctrl 16 | @ bx lr 17 | @--------------------------------------------------------------------------------- 18 | soundwrite: 19 | @--------------------------------------------------------------------------------- 20 | stmfd sp!,{r3,lr} 21 | 22 | @IMPORT writeAPU 23 | mov r1,addy 24 | bl writeAPU 25 | 26 | ldmfd sp!,{r3,pc} 27 | @--------------------------------------------------------------------------------- 28 | _4015r: 29 | @--------------------------------------------------------------------------------- 30 | ldr r1, =IPC_REG4015 @which is updated by s_apu.c 31 | ldrb r0, [r1] 32 | mov pc, lr 33 | @--------------------------------------------------------------------------------- 34 | updatesound: @called from line 0.. r0-r9 are free to use 35 | @--------------------------------------------------------------------------------- 36 | bx lr 37 | @--------------------------------------------------------------------------------- 38 | -------------------------------------------------------------------------------- /arm9/source/stepdebug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ds_misc.h" 3 | #include "c_defs.h" 4 | 5 | extern u32 __nz; 6 | extern u32 __a; 7 | extern u32 __x; 8 | extern u32 __y; 9 | extern u32 __p; 10 | extern unsigned char *__pc; 11 | extern unsigned char * __lastbank; 12 | extern u32 __scanline; 13 | extern u16 __nes_chr_map[]; 14 | extern u32* __memmap_tbl[]; 15 | extern u32* __rombase; 16 | 17 | unsigned int stepinfo[1024]; 18 | extern unsigned int *pstep; 19 | 20 | unsigned char ptbuf[1024] = 21 | /*1234567890123456789012345678901*/ 22 | "frame: line: " 23 | "pc: " 24 | "A: X: Y: P: SP: " 25 | " " 26 | " " 27 | " " 28 | " " 29 | " " 30 | " " 31 | " " 32 | " " 33 | " " 34 | " " 35 | " " 36 | " " 37 | " " 38 | " " 39 | " " 40 | " " 41 | " " 42 | " " 43 | " " 44 | " " 45 | " " 46 | ; 47 | 48 | void shex(unsigned char *p,int d,int n) { 49 | u16 c; 50 | do { 51 | c=d&0x0f; 52 | if(c<10) c+='0'; 53 | else c=c-10+'A'; 54 | d>>=4; 55 | p[n--]=c; 56 | } while(n>=0); 57 | } 58 | 59 | #define shex8(a,b) shex(a,b,1) 60 | #define shex16(a,b) shex(a,b,3) 61 | #define shex24(a,b) shex(a,b,5) 62 | #define shex32(a,b) shex(a,b,7) 63 | 64 | 65 | void stepdebug() 66 | { 67 | static int framecount = 0; 68 | static int line, keys, oldkeys, opcount = 0; 69 | unsigned int i, count; 70 | i = 0; 71 | opcount++; 72 | if(line == 240 && __scanline == 241) { 73 | framecount++; 74 | swiWaitForVBlank(); 75 | //keys = IPC_KEYS; 76 | keys &= ~KEY_SELECT; 77 | } 78 | if(keys & KEY_SELECT) { 79 | line = __scanline; 80 | //pstep = stepinfo; 81 | return; 82 | } 83 | if(keys & KEY_R && line == __scanline) { 84 | return; 85 | } 86 | line = __scanline; 87 | shex32(ptbuf + 6, framecount); 88 | shex16(ptbuf + 20, __scanline); 89 | shex16(ptbuf + 32 + 3, __pc - __lastbank); 90 | shex8(ptbuf + 32 + 8, *__pc); 91 | shex8(ptbuf + 32 + 11, *(__pc + 1)); 92 | shex8(ptbuf + 32 + 14, *(__pc + 2)); 93 | shex32(ptbuf + 50, opcount); 94 | 95 | shex8(ptbuf + 64 + 2, __a>>24); 96 | shex8(ptbuf + 64 + 7, __x>>24); 97 | shex8(ptbuf + 64 + 12, __y>>24); 98 | shex8(ptbuf + 64 + 17, __p); 99 | 100 | for(i = 0; i < 8; i++) { 101 | shex8(ptbuf + 96 + 3*i, __nes_chr_map[i]); 102 | } 103 | for(i = 0; i < 4; i++) { 104 | shex8(ptbuf + 128 + 3*i, __nes_chr_map[i + 8]); 105 | } 106 | for(i = 4; i < 8; i++) { 107 | shex8(ptbuf + 128 + 3*i, ((__memmap_tbl[i] - __rombase) >> 13) + i); 108 | } 109 | 110 | 111 | consoletext(0, ptbuf, 0); 112 | //memset( ptbuf + 192 + count * 8, 32, (18 * 4 - count) * 8); 113 | 114 | do { 115 | IPC_KEYS = keysCurrent(); 116 | keys = IPC_KEYS; 117 | if(keys & oldkeys & (KEY_SELECT | KEY_R | KEY_L)) { 118 | //pstep = stepinfo; 119 | return; 120 | } 121 | if(keys & (KEY_SELECT | KEY_R | KEY_L)) { 122 | //pstep = stepinfo; 123 | break; 124 | } 125 | swiWaitForVBlank(); 126 | oldkeys = 0; 127 | } 128 | while(1); 129 | oldkeys = keys; 130 | //pstep = stepinfo; 131 | } 132 | -------------------------------------------------------------------------------- /arm9/source/subscreen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ds_misc.h" 3 | #include "c_defs.h" 4 | 5 | extern u32 agb_bg_map[]; 6 | extern u16 __nes_chr_map[]; 7 | u32 debuginfo[48]; 8 | char *debugtxt[]={ 9 | "ERR0","ERR1","READ","WRITE","BRK","BAD OP","VBLS","FPS", 10 | "BGMISS","cartflg","a","b","c","ALIVE","TMP0","TMP1", 11 | "mapper#", "PRGCRC", "diskno", "makeid", "gameid", "emuflag"}; 12 | #define DLINE 4 13 | extern char *__memmap_tbl[]; 14 | extern char *__rombase; 15 | 16 | extern int shortcuts_tbl[]; 17 | extern char *ishortcuts[]; 18 | 19 | char *fdsdbg[]={ 20 | "ienable", "irepeat", "ioccur", "itran", 21 | "denable", "senable", "RWstart", "RWmode", 22 | "motormd", "eject", "ready", "reset", 23 | "faccess", "side", "mountct", "itype", 24 | "startupf", "Throttle", 25 | "Thtime", "disk", "disk_w", "icount", 26 | "ilatch", "bpoint", "bmode", "fsize", 27 | "famount", "point", "sttimer", "sktimer", 28 | "diskno", "makerid", "gameid", 29 | }; 30 | 31 | int debugdump() { 32 | /* 33 | int i; 34 | u32 *p; 35 | char **cc; 36 | 37 | debuginfo[13]=IPC_ALIVE; 38 | debuginfo[14]=IPC_TMP0; 39 | debuginfo[15]=IPC_TMP1; 40 | 41 | p=debuginfo; 42 | cc=debugtxt; 43 | for(i=64*DLINE;i<64*(DLINE+16);i+=64) { 44 | consoletext(i,*cc++,0); 45 | hex32(i+14,*p++); 46 | } 47 | 48 | p=agb_bg_map; 49 | for(i=64*DLINE;i<64*(DLINE+16);i+=64) { 50 | hex32(i+32,*p++); 51 | } 52 | 53 | hex32(64*22,freemem_end-freemem_start); 54 | consoletext(64*22+18,"bytes free",0); 55 | consoletext(64*23,"Built",0); 56 | consoletext(64*23+12,__TIME__,0); 57 | consoletext(64*23+30,__DATE__,0); 58 | */ 59 | 60 | int i;/* 61 | static int count = 0; 62 | if(count++ != 20) 63 | return 0;*/ 64 | 65 | debuginfo[21] = __emuflags; 66 | if(1 && (__emuflags & NSFFILE)) { 67 | u32 *ip=(u32*)&mapperstate; 68 | consoletext (64 * 4 + 0 * 32, "version", 0); 69 | hex8 (64 * 4 + 0 * 32 + 18, nsfheader.Version); 70 | consoletext (64 * 4 + 1 * 32, "startson", 0); 71 | hex8 (64 * 4 + 1 * 32 + 18, nsfheader.StartSong); 72 | consoletext (64 * 4 + 2 * 32, "totalsong", 0); 73 | hex8 (64 * 4 + 2 * 32 + 18, nsfheader.TotalSong); 74 | consoletext (64 * 4 + 3 * 32, "LoadAddr", 0); 75 | hex16 (64 * 4 + 3 * 32 + 18, nsfheader.LoadAddress); 76 | consoletext (64 * 4 + 4 * 32, "InitAddr", 0); 77 | hex16 (64 * 4 + 4 * 32 + 18, nsfheader.InitAddress); 78 | consoletext (64 * 4 + 5 * 32, "PlayAddr", 0); 79 | hex16 (64 * 4 + 5 * 32 + 18, nsfheader.PlayAddress); 80 | for(i=0;i<10;i++) { 81 | hex32(64*7+i*32,ip[i]); 82 | } 83 | 84 | consoletext (64 * 16 + 0 * 32, "songno", 0); 85 | hex16 (64 * 16 + 0 * 32 + 18, __nsfsongno); 86 | consoletext (64 * 16 + 1 * 32, "songmode", 0); 87 | hex16 (64 * 16 + 1 * 32 + 18, __nsfsongmode); 88 | consoletext (64 * 16 + 2 * 32, "play", 0); 89 | hex16 (64 * 16 + 2 * 32 + 18, __nsfplay); 90 | consoletext (64 * 16 + 3 * 32, "init", 0); 91 | hex16 (64 * 16 + 3 * 32 + 18, __nsfinit); 92 | 93 | 94 | for(i = 0; i < 4; i++) { 95 | hex32(64 * 20 + i * 32, (u32)__memmap_tbl[i + 4] + 0x2000 * i + 0x8000); 96 | } 97 | } else if(debuginfo[16] == 20) { 98 | u8 *p=(u8*)&mapperstate;//0x7000000; 99 | u32 *ip=(u32*)&mapperstate;//0x7000000; 100 | for(i=0;i<18;i++) { 101 | consoletext(64 * 4 + i * 32, fdsdbg[i], 0); 102 | hex8(64*4+i*32 + 18,p[i]); 103 | } 104 | for(i=6;i<19;i++) { 105 | consoletext(64*12 + (i-6) * 32, fdsdbg[i + 12], 0); 106 | hex32(64*12 + (i-6) * 32 + 16,ip[i]); 107 | } 108 | } 109 | else { 110 | for(i = 0; i < 22; i++) { 111 | consoletext(64 * 4 + i * 32, debugtxt[i], 0); 112 | hex32(64 * 4 + i * 32 + 14, debuginfo[i]); 113 | } 114 | #if 1 115 | for(i = 0; i < 8; i++) { 116 | hex(64 * 15 + i * 8, __nes_chr_map[i], 2); 117 | } 118 | for(i = 0; i < 4; i++) { 119 | hex(64 * 16 + i * 8, (__memmap_tbl[i + 4] - __rombase)/0x2000 + i + 4, 2); 120 | } 121 | #endif 122 | #if 1 123 | for (i = 0;i < 96; i++) 124 | { 125 | hex8(64*17 + i*8, mapperstate[i]); 126 | } 127 | #endif 128 | } 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /arm9/source/zip/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /arm9/source/zip/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /arm9/source/zip/gzguts.h: -------------------------------------------------------------------------------- 1 | /* gzguts.h -- zlib internal header definitions for gz* operations 2 | * Copyright (C) 2004, 2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef _LARGEFILE64_SOURCE 7 | # ifndef _LARGEFILE_SOURCE 8 | # define _LARGEFILE_SOURCE 1 9 | # endif 10 | # ifdef _FILE_OFFSET_BITS 11 | # undef _FILE_OFFSET_BITS 12 | # endif 13 | #endif 14 | 15 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) 16 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 17 | #else 18 | # define ZLIB_INTERNAL 19 | #endif 20 | 21 | #include 22 | #include "zlib.h" 23 | #ifdef STDC 24 | # include 25 | # include 26 | # include 27 | #endif 28 | #include 29 | 30 | #ifdef NO_DEFLATE /* for compatibility with old definition */ 31 | # define NO_GZCOMPRESS 32 | #endif 33 | 34 | #ifdef _MSC_VER 35 | # include 36 | # define vsnprintf _vsnprintf 37 | #endif 38 | 39 | #ifndef local 40 | # define local static 41 | #endif 42 | /* compile with -Dlocal if your debugger can't find static symbols */ 43 | 44 | /* gz* functions always use library allocation functions */ 45 | #ifndef STDC 46 | extern voidp malloc OF((uInt size)); 47 | extern void free OF((voidpf ptr)); 48 | #endif 49 | 50 | /* get errno and strerror definition */ 51 | #if defined UNDER_CE 52 | # include 53 | # define zstrerror() gz_strwinerror((DWORD)GetLastError()) 54 | #else 55 | # ifdef STDC 56 | # include 57 | # define zstrerror() strerror(errno) 58 | # else 59 | # define zstrerror() "stdio error (consult errno)" 60 | # endif 61 | #endif 62 | 63 | /* provide prototypes for these when building zlib without LFS */ 64 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 65 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 66 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); 67 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); 68 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); 69 | #endif 70 | 71 | /* default i/o buffer size -- double this for output when reading */ 72 | #define GZBUFSIZE 8192 73 | 74 | /* gzip modes, also provide a little integrity check on the passed structure */ 75 | #define GZ_NONE 0 76 | #define GZ_READ 7247 77 | #define GZ_WRITE 31153 78 | #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ 79 | 80 | /* values for gz_state how */ 81 | #define LOOK 0 /* look for a gzip header */ 82 | #define COPY 1 /* copy input directly */ 83 | #define GZIP 2 /* decompress a gzip stream */ 84 | 85 | /* internal gzip file state data structure */ 86 | typedef struct { 87 | /* used for both reading and writing */ 88 | int mode; /* see gzip modes above */ 89 | int fd; /* file descriptor */ 90 | char *path; /* path or fd for error messages */ 91 | z_off64_t pos; /* current position in uncompressed data */ 92 | unsigned size; /* buffer size, zero if not allocated yet */ 93 | unsigned want; /* requested buffer size, default is GZBUFSIZE */ 94 | unsigned char *in; /* input buffer */ 95 | unsigned char *out; /* output buffer (double-sized when reading) */ 96 | unsigned char *next; /* next output data to deliver or write */ 97 | /* just for reading */ 98 | unsigned have; /* amount of output data unused at next */ 99 | int eof; /* true if end of input file reached */ 100 | z_off64_t start; /* where the gzip data started, for rewinding */ 101 | z_off64_t raw; /* where the raw data started, for seeking */ 102 | int how; /* 0: get header, 1: copy, 2: decompress */ 103 | int direct; /* true if last read direct, false if gzip */ 104 | /* just for writing */ 105 | int level; /* compression level */ 106 | int strategy; /* compression strategy */ 107 | /* seek request */ 108 | z_off64_t skip; /* amount to skip (already rewound if backwards) */ 109 | int seek; /* true if seek request pending */ 110 | /* error information */ 111 | int err; /* error code */ 112 | char *msg; /* error message */ 113 | /* zlib inflate or deflate stream */ 114 | z_stream strm; /* stream structure in-place (not a pointer) */ 115 | } gz_state; 116 | typedef gz_state FAR *gz_statep; 117 | 118 | /* shared functions */ 119 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 120 | #if defined UNDER_CE 121 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 122 | #endif 123 | 124 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t 125 | value -- needed when comparing unsigned to z_off64_t, which is signed 126 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ 127 | #ifdef INT_MAX 128 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) 129 | #else 130 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); 131 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) 132 | #endif 133 | -------------------------------------------------------------------------------- /arm9/source/zip/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /arm9/source/zip/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /arm9/source/zip/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (Bytef*)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /common/dswifi/dswifi_license.txt: -------------------------------------------------------------------------------- 1 | DSWifi Project - sgIP Internet Protocol Stack Implementation 2 | 3 | Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org 4 | 5 | http://www.akkit.org 6 | 7 | 8 | DSWifi Lib and test materials are licenced under the MIT open source licence: 9 | Copyright (c) 2005-2006 Stephen Stair 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | this software and associated documentation files (the "Software"), to deal in 13 | the Software without restriction, including without limitation the rights to 14 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | of the Software, and to permit persons to whom the Software is furnished to do 16 | so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | -------------------------------------------------------------------------------- /common/readme.txt: -------------------------------------------------------------------------------- 1 | this wifi code links against devkitARM r45 current dswifi version. If dswifi code is updated, you must reflect these changes here -------------------------------------------------------------------------------- /common/spinlock.h: -------------------------------------------------------------------------------- 1 | // DS Wifi interface code 2 | // Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org 3 | // spinlock.h - code for spinlocking for basic wifi structure memory protection 4 | /****************************************************************************** 5 | DSWifi Lib and test materials are licenced under the MIT open source licence: 6 | Copyright (c) 2005-2006 Stephen Stair 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | this software and associated documentation files (the "Software"), to deal in 10 | the Software without restriction, including without limitation the rights to 11 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | of the Software, and to permit persons to whom the Software is furnished to do 13 | so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | ******************************************************************************/ 26 | 27 | 28 | 29 | /* 30 | 31 | __asm ( 32 | ".GLOBL SLasm_Acquire, SLasm_Release \n" 33 | ".ARM \n" 34 | "SLasm_Acquire: \n" 35 | " ldr r2,[r0] \n" 36 | " cmp r2,#0 \n" 37 | " movne r0,#1 \n" 38 | " bxne lr \n" 39 | " mov r2,r1 \n" 40 | " swp r2,r2,[r0] \n" 41 | " cmp r2,#0 \n" 42 | " cmpne r2,r1 \n" 43 | " moveq r0,#0 \n" 44 | " bxeq lr \n" 45 | " swp r2,r2,[r0] \n" 46 | " mov r0,#1 \n" 47 | " bx lr \n" 48 | "\n\n" 49 | "SLasm_Release: \n" 50 | " ldr r2,[r0] \n" 51 | " cmp r2,r1 \n" 52 | " movne r0,#2 \n" 53 | " bxne lr \n" 54 | " mov r2,#0 \n" 55 | " swp r2,r2,[r0] \n" 56 | " cmp r2,r1 \n" 57 | " moveq r0,#0 \n" 58 | " movne r0,#2 \n" 59 | " bx lr \n" 60 | ); 61 | 62 | */ 63 | 64 | -------------------------------------------------------------------------------- /common/spinlock.s: -------------------------------------------------------------------------------- 1 | @coto: fix compiler warnings by making sure ARM7/ARM9 uses correct SWP opcodes 2 | #ifdef ARM7 3 | .cpu arm7tdmi 4 | #else 5 | #ifdef ARM9 6 | .cpu arm946e-s 7 | #endif 8 | #endif 9 | 10 | .text 11 | .code 32 12 | .ARM 13 | 14 | .GLOBL SLasm_Acquire, SLasm_Release 15 | SLasm_Acquire: 16 | ldr r2,[r0] 17 | cmp r2,#0 18 | movne r0,#1 19 | bxne lr 20 | mov r2,r1 21 | swp r2,r2,[r0] 22 | cmp r2,#0 23 | cmpne r2,r1 24 | moveq r0,#0 25 | bxeq lr 26 | swp r2,r2,[r0] 27 | mov r0,#1 28 | bx lr 29 | 30 | 31 | 32 | SLasm_Release: 33 | ldr r2,[r0] 34 | cmp r2,r1 35 | movne r0,#2 36 | bxne lr 37 | mov r2,#0 38 | swp r2,r2,[r0] 39 | cmp r2,r1 40 | moveq r0,#0 41 | movne r0,#2 42 | bx lr 43 | 44 | 45 | 46 | .pool 47 | .end 48 | -------------------------------------------------------------------------------- /icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApacheThunder/NesDS/9da2efd37e5086f35c4efb13a25009ee3e69c0d7/icon.bmp -------------------------------------------------------------------------------- /include/ds_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | #define PM_SOUND 0x01 4 | #define PM_BOTTOMLIGHT 0x04 5 | #define PM_TOPLIGHT 0x08 6 | #define PM_LED_SLOW 0x10 7 | #define PM_LED_FAST 0x30 8 | #define PM_OFF 0x40 9 | 10 | ///////////////////////// 11 | //FIFO 12 | ////////////////////////// 13 | 14 | #define IRQ_FIFO_SEND 0x20000 15 | #define IRQ_FIFO_RECV 0x40000 16 | 17 | #define FIFO_INTR *(vu16*)0x4000180 18 | #define REG_FIFO_CNT *(vu16*)0x4000184 19 | #define REG_FIFO_SEND *(vu32*)0x4000188 20 | #define REG_FIFO_RECV *(vu32*)0x4100000 21 | 22 | #define FIFO_INTR_I 0x4000 23 | #define FIFO_INTR_IREQ 0x2000 24 | #define FIFO_INTR_STATUS_OUT 0x0f00 25 | #define FIFO_INTR_STATUS_IN 0x000f 26 | 27 | #define FIFO_CNT_ENABLE 0x8000 28 | #define FIFO_CNT_ERR 0x4000 29 | #define FIFO_CNT_RECV_IRQ 0x0400 30 | #define FIFO_CNT_RECV_FULL 0x0200 31 | #define FIFO_CNT_RECV_EMPTY 0x0100 32 | #define FIFO_CNT_SEND_CLEAR 0x0008 33 | #define FIFO_CNT_SEND_IRQ 0x0004 34 | #define FIFO_CNT_SEND_FULL 0x0002 35 | #define FIFO_CNT_SEND_EMPTY 0x0001 36 | 37 | enum errmsg {FAIL_SEND_FULL,FAIL_SEND_ERR,FAIL_RECV_EMPTY,FAIL_RECV_ERR,SUCCESS}; 38 | 39 | static inline void fifo_init() { 40 | REG_FIFO_CNT = FIFO_CNT_SEND_CLEAR | FIFO_CNT_RECV_IRQ | FIFO_CNT_ENABLE | FIFO_CNT_ERR; 41 | } 42 | 43 | #define TOUCH_CNTRL_X1 (*(vu8*)0x027FFCDC) //pixel positions of the two points you click when calibrating 44 | #define TOUCH_CNTRL_Y1 (*(vu8*)0x027FFCDD) 45 | #define TOUCH_CNTRL_X2 (*(vu8*)0x027FFCE2) 46 | #define TOUCH_CNTRL_Y2 (*(vu8*)0x027FFCE3) 47 | 48 | #define TOUCH_CAL_X1 (*(vu16*)0x027FFCD8) //corresponding touchscreen values 49 | #define TOUCH_CAL_Y1 (*(vu16*)0x027FFCDA) 50 | #define TOUCH_CAL_X2 (*(vu16*)0x027FFCDE) 51 | #define TOUCH_CAL_Y2 (*(vu16*)0x027FFCE0) 52 | */ -------------------------------------------------------------------------------- /include/dswifi7.h: -------------------------------------------------------------------------------- 1 | // DSWifi Project - Arm7 Library Header file (dswifi7.h) 2 | // Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org 3 | /****************************************************************************** 4 | DSWifi Lib and test materials are licenced under the MIT open source licence: 5 | Copyright (c) 2005-2006 Stephen Stair 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is furnished to do 12 | so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | ******************************************************************************/ 25 | 26 | #ifndef DSWIFI7_H 27 | #define DSWIFI7_H 28 | 29 | #include "dswifi_version.h" 30 | 31 | // Wifi Sync Handler function: Callback function that is called when the arm9 needs to be told to synchronize with new fifo data. 32 | // If this callback is used (see Wifi_SetSyncHandler()), it should send a message via the fifo to the arm9, which will call Wifi_Sync() on arm9. 33 | typedef void (*WifiSyncHandler)(); 34 | 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | // Read_Flash: Reads an arbitrary amount of data from the firmware flash chip 41 | // int address: Offset to start reading from in the flash chip 42 | // char * destination: Pointer to a memory buffer to hold incoming data 43 | // int length: The number of bytes to read 44 | extern void Read_Flash(int address, char * destination, int length); 45 | 46 | // PowerChip_ReadWrite: Reads or writes a value to the DS's power chip 47 | // int cmp: The byte-long command to send to the chip (top bit 1=read, 0=write - other bits = register ID to read/write) 48 | // int data: The data to write to the chip (if sending a read command, this should be zero) 49 | // Returns: The data read returned by the serial connection; only really useful when reading. 50 | extern int PowerChip_ReadWrite(int cmd, int data); 51 | 52 | // Wifi_Interrupt: Handler for the arm7 wifi interrupt. Should be called by the 53 | // interrupt handler on arm7, and should *not* have multiple interrupts enabled. 54 | extern void Wifi_Interrupt(); 55 | 56 | // Wifi_Update: Sync function to ensure data continues to flow between the two 57 | // CPUs smoothly. Should be called at a periodic interval, such as in vblank. 58 | extern void Wifi_Update(); 59 | 60 | // Wifi_Init: Requires the data returned by the arm9 wifi init call. The arm9 61 | // init call's returned data must be passed to the arm7 and then given to this 62 | // function. (or else very bad things happen) 63 | // This function also enables power to the wifi system, which will shorten 64 | // battery life. 65 | // unsigned long WifiData: You must pass the 32bit value returned by the call to 66 | // Wifi_Init on the ARM9. 67 | extern void Wifi_Init(unsigned long WifiData); 68 | 69 | // Wifi_Deinit: In the case that it is necessary, this function cuts power to 70 | // the wifi system. After this the wifi will be unusable until Wifi_Init is 71 | // called again. 72 | extern void Wifi_Deinit(); 73 | 74 | // Wifi_Sync: Call this function when requested to sync by the arm9 side of the 75 | // wifi lib 76 | extern void Wifi_Sync(); 77 | 78 | // Wifi_SetSyncHandler: Call this function to request notification of when the 79 | // ARM9-side Wifi_Sync function should be called. 80 | // WifiSyncHandler sh: Pointer to the function to be called for notification. 81 | extern void Wifi_SetSyncHandler(WifiSyncHandler sh); 82 | 83 | extern void installWifiFIFO(); 84 | 85 | #ifdef __cplusplus 86 | }; 87 | #endif 88 | 89 | 90 | #endif // DSWIFI7_H 91 | -------------------------------------------------------------------------------- /include/dswifi_version.h: -------------------------------------------------------------------------------- 1 | #ifndef _dswifi_version_h_ 2 | #define _dswifi_version_h_ 3 | 4 | #define DSWIFI_MAJOR 0 5 | #define DSWIFI_MINOR 3 6 | #define DSWIFI_REVISION 13 7 | 8 | #define DSWIFI_VERSION "0.3.13" 9 | 10 | #endif // _dswifi_version_h_ 11 | -------------------------------------------------------------------------------- /include/netdb.h: -------------------------------------------------------------------------------- 1 | // DSWifi Project - socket emulation layer defines/prototypes (netdb.h) 2 | // Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org 3 | /****************************************************************************** 4 | DSWifi Lib and test materials are licenced under the MIT open source licence: 5 | Copyright (c) 2005-2006 Stephen Stair 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is furnished to do 12 | so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | ******************************************************************************/ 25 | 26 | #ifndef NETDB_H 27 | #define NETDB_H 28 | 29 | struct hostent { 30 | char * h_name; 31 | char ** h_aliases; 32 | int h_addrtype; 33 | int h_length; 34 | char ** h_addr_list; 35 | }; 36 | 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | extern struct hostent * gethostbyname(const char * name); 43 | 44 | #ifdef __cplusplus 45 | }; 46 | #endif 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/netinet/in.h: -------------------------------------------------------------------------------- 1 | // DSWifi Project - socket emulation layer defines/prototypes (netinet/in.h) 2 | // Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org 3 | /****************************************************************************** 4 | DSWifi Lib and test materials are licenced under the MIT open source licence: 5 | Copyright (c) 2005-2006 Stephen Stair 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is furnished to do 12 | so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | ******************************************************************************/ 25 | 26 | #ifndef NETINET_IN_H 27 | #define NETINET_IN_H 28 | 29 | #include "sys/socket.h" 30 | 31 | #define INADDR_ANY 0x00000000 32 | #define INADDR_BROADCAST 0xFFFFFFFF 33 | #define INADDR_NONE 0xFFFFFFFF 34 | 35 | 36 | struct in_addr { 37 | unsigned long s_addr; 38 | }; 39 | 40 | struct sockaddr_in { 41 | unsigned short sin_family; 42 | unsigned short sin_port; 43 | struct in_addr sin_addr; 44 | unsigned char sin_zero[8]; 45 | }; 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | // actually from arpa/inet.h - but is included through netinet/in.h 52 | unsigned long inet_addr(const char *cp); 53 | int inet_aton(const char *cp, struct in_addr *inp); 54 | char *inet_ntoa(struct in_addr in); 55 | 56 | #ifdef __cplusplus 57 | }; 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /release/nesDS.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApacheThunder/NesDS/9da2efd37e5086f35c4efb13a25009ee3e69c0d7/release/nesDS.ini -------------------------------------------------------------------------------- /release/nesDS.nds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApacheThunder/NesDS/9da2efd37e5086f35c4efb13a25009ee3e69c0d7/release/nesDS.nds --------------------------------------------------------------------------------