├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .gitmodules ├── 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 │ ├── font.c │ ├── font.h │ ├── fontpal.c │ ├── fontpal.h │ ├── nespal.c │ └── nespal.h ├── include │ ├── 3dsvc_pal.h │ ├── asqrealc_pal.h │ ├── chriscovell_pal.h │ ├── crashman_pal.h │ ├── digitalprime_pal.h │ ├── equates.h │ ├── firebrandx_pal.h │ ├── loopy_pal.h │ ├── macro.h │ ├── mattconte_pal.h │ ├── menu.h │ ├── mess_pal.h │ ├── minIni.h │ ├── multi.h │ ├── nesclassic_pal.h │ ├── nespvm_pal.h │ ├── nesvc_pal.h │ ├── pasofami_pal.h │ └── quor_pal.h └── source │ ├── NesMachine.h │ ├── RP2C02 │ ├── RP2C02.h │ ├── RP2C02.i │ ├── RP2C02.s │ └── render.s │ ├── about.c │ ├── arm9main.c │ ├── barcode.c │ ├── cart.s │ ├── cheat.c │ ├── console.c │ ├── cpu.h │ ├── cpu.s │ ├── dswifi_arm9 │ └── wifi_arm9.h │ ├── gesture.c │ ├── io.s │ ├── ips.c │ ├── mappers │ ├── eeprom_x24c01.s │ ├── eeprom_x24c02.s │ ├── konami.s │ ├── map0.s │ ├── map023771.s │ ├── map1.s │ ├── map105.s │ ├── map111.s │ ├── map1166.s │ ├── map118.s │ ├── map15.s │ ├── map159.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 │ ├── map226_231.s │ ├── map228.s │ ├── map23.s │ ├── map232.s │ ├── map240.s │ ├── map2426.s │ ├── map245.s │ ├── map246.s │ ├── map252.s │ ├── map253.s │ ├── map255.s │ ├── map30.s │ ├── map32.s │ ├── map33.s │ ├── map34.s │ ├── map37.s │ ├── map4.s │ ├── map40.s │ ├── map42.s │ ├── map47.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 │ ├── mmc3.i │ └── mmc3.s │ ├── memory.s │ ├── menu.c │ ├── menu_func.c │ ├── minIni.c │ ├── misc.c │ ├── multi.c │ ├── patch.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 ├── make_cia └── release └── nesDS.ini /.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 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build nesDS 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | pull_request: 7 | branches: ["master"] 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | container: devkitpro/devkitarm:20241104 15 | name: Build with Docker using devkitARM 16 | steps: 17 | - name: Checkout repo 18 | uses: actions/checkout@v4 19 | with: 20 | submodules: recursive 21 | - name: Setup environment 22 | run: git config --global safe.directory '*' 23 | - name: Build & Package nesDS 24 | id: build 25 | run: | 26 | make 27 | chmod +x make_cia 28 | ./make_cia --srl="nesDS.nds" --id_0=$(git rev-parse --short=7 HEAD) --tikID=$(git rev-parse --short=16 HEAD) 29 | mkdir nesDS/ 30 | cp nesDS.nds nesDS/ 31 | cp nesDS.cia nesDS/ 32 | - name: Publish build to GH Actions 33 | uses: actions/upload-artifact@v4 34 | with: 35 | path: nesDS 36 | name: build 37 | - name: Release 38 | uses: softprops/action-gh-release@v2 39 | if: startsWith(github.ref, 'refs/tags/') 40 | with: 41 | files: | 42 | nesDS/nesDS.nds 43 | nesDS/nesDS.cia 44 | -------------------------------------------------------------------------------- /.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 | 49 | 50 | *.elf 51 | *.nds 52 | arm7/build/* 53 | arm9/build/* -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "arm9/source/RP2A03"] 2 | path = arm9/source/RP2A03 3 | url = https://github.com/FluBBaOfWard/N2A03.git 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | export TARGET := nesDS 9 | export TOPDIR := $(CURDIR) 10 | 11 | # GAME_ICON is the image used to create the game icon, leave blank to use default rule 12 | GAME_ICON := icon.bmp 13 | 14 | # specify a directory which contains the nitro filesystem 15 | # this is relative to the Makefile 16 | NITRO_FILES := 17 | 18 | # These set the information text in the nds file 19 | GAME_TITLE := nesDS 20 | GAME_SUBTITLE1 := Version 2.0 21 | GAME_SUBTITLE2 := Enjoy yourself! 22 | 23 | include $(DEVKITARM)/ds_rules 24 | 25 | .PHONY: checkarm7 checkarm9 clean 26 | 27 | #--------------------------------------------------------------------------------- 28 | # main targets 29 | #--------------------------------------------------------------------------------- 30 | all: checkarm7 checkarm9 $(TARGET).nds 31 | 32 | #--------------------------------------------------------------------------------- 33 | checkarm7: 34 | $(MAKE) -C arm7 35 | 36 | #--------------------------------------------------------------------------------- 37 | checkarm9: 38 | $(MAKE) -C arm9 39 | 40 | #--------------------------------------------------------------------------------- 41 | $(TARGET).nds : $(NITRO_FILES) arm7/$(TARGET).elf arm9/$(TARGET).elf 42 | ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ 43 | -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ 44 | -g HNES 00 "HOMEBREW" -u 00030004 \ 45 | $(_ADDFILES) 46 | 47 | #--------------------------------------------------------------------------------- 48 | arm7/$(TARGET).elf: 49 | $(MAKE) -C arm7 50 | 51 | #--------------------------------------------------------------------------------- 52 | arm9/$(TARGET).elf: 53 | $(MAKE) -C arm9 54 | 55 | #--------------------------------------------------------------------------------- 56 | clean: 57 | $(MAKE) -C arm9 clean 58 | $(MAKE) -C arm7 clean 59 | rm -f $(TARGET).nds 60 | -------------------------------------------------------------------------------- /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 47 | -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/50f12d87f1ad154b3ac25eaf8c18203f931372bd/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/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 u32 interrupts_to_wait_arm7; 13 | extern int ipc_region; 14 | extern void soundinterrupt(void); 15 | 16 | extern int pcmpos; 17 | extern int APU_paused; 18 | 19 | extern void readAPU(void); 20 | extern void resetAPU(void); 21 | extern void dealrawpcm(unsigned char *out); 22 | 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /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 "c_defs.h" 8 | 9 | void nesmain(); 10 | 11 | //--------------------------------------------------------------------------------- 12 | void VblankHandler(void) { 13 | //--------------------------------------------------------------------------------- 14 | Wifi_Update(); 15 | } 16 | 17 | int ipc_region = 0; 18 | 19 | volatile bool exitflag = false; 20 | 21 | u8 *bootstub; 22 | u32 ndstype; 23 | typedef void (*type_void)(); 24 | type_void bootstub_arm7; 25 | static void sys_exit(){ 26 | if(!bootstub_arm7){ 27 | if(ndstype>=2)writePowerManagement(0x10, 1); 28 | else writePowerManagement(0, PM_SYSTEM_PWR); 29 | } 30 | bootstub_arm7(); //won't return 31 | } 32 | 33 | extern int APU_paused; 34 | //--------------------------------------------------------------------------------- 35 | int main() { 36 | //--------------------------------------------------------------------------------- 37 | readUserSettings(); 38 | 39 | irqInit(); 40 | fifoInit(); 41 | touchInit(); 42 | // Start the RTC tracking IRQ 43 | initClockIRQ(); 44 | 45 | installSystemFIFO(); 46 | installWifiFIFO(); 47 | //irqSet(IRQ_VCOUNT, VcountHandler); 48 | irqSet(IRQ_VBLANK, VblankHandler); 49 | 50 | irqEnable(IRQ_TIMER1 | IRQ_VBLANK | IRQ_NETWORK); 51 | 52 | { 53 | ndstype=0; 54 | u32 myself = readPowerManagement(4); //(PM_BACKLIGHT_LEVEL); 55 | if(myself & (1<<6)) 56 | ndstype=(myself==readPowerManagement(5))?1:2; 57 | } 58 | 59 | bootstub=(u8*)0x02ff4000; 60 | bootstub_arm7=(*(u64*)bootstub==0x62757473746F6F62ULL)?(*(type_void*)(bootstub+0x0c)):0; 61 | setPowerButtonCB(sys_exit); 62 | 63 | while(!fifoCheckValue32(FIFO_USER_06)) //wait for the value of ipc_region 64 | swiWaitForVBlank(); 65 | ipc_region = fifoGetValue32(FIFO_USER_06); 66 | 67 | nesmain(); 68 | 69 | // Keep the ARM7 mostly idle 70 | while (1) { 71 | if ( 0 == (REG_KEYINPUT & (KEY_DOWN | KEY_B | KEY_L | KEY_R))) { 72 | sys_exit(); 73 | } 74 | inputGetAndSend(); 75 | swiWaitForVBlank(); 76 | } 77 | //return 0; 78 | } 79 | -------------------------------------------------------------------------------- /arm7/source/audiosys.c: -------------------------------------------------------------------------------- 1 | #include "audiosys.h" 2 | 3 | /* ---------------------- */ 4 | /* Audio Render Handler */ 5 | /* ---------------------- */ 6 | 7 | #define SHIFT_BITS 8 8 | 9 | static Uint frequency = 44100; 10 | static Uint channel = 1; 11 | 12 | static NES_AUDIO_HANDLER *nah = 0; 13 | static NES_VOLUME_HANDLER *nvh = 0; 14 | 15 | static Uint naf_type = NES_AUDIO_FILTER_LOWPASS; 16 | static Uint32 naf_prev; 17 | 18 | void NESAudioFilterSet(Uint filter) 19 | { 20 | naf_type = filter; 21 | naf_prev = 0x8000; 22 | } 23 | 24 | void NESAudioRender(Int16 *bufp, Uint buflen) 25 | { 26 | NES_AUDIO_HANDLER *ph; 27 | Int32 accum; 28 | Uint32 output; 29 | 30 | while (buflen--) 31 | { 32 | accum=0; 33 | for (ph = nah; ph; ph = ph->next) 34 | accum+=ph->Proc(); 35 | 36 | accum += (0x8000 << SHIFT_BITS); 37 | 38 | if (accum < 0) 39 | output = 0; 40 | else if (accum > (0x10000 << SHIFT_BITS) - 1) 41 | output = (0x10000 << SHIFT_BITS) - 1; 42 | else 43 | output = accum; 44 | output >>= SHIFT_BITS; 45 | 46 | switch (naf_type) 47 | { 48 | case NES_AUDIO_FILTER_LOWPASS: 49 | { 50 | Uint32 prev = naf_prev; 51 | naf_prev = output; 52 | output = (output + prev) >> 1; 53 | naf_prev = output; 54 | } 55 | break; 56 | /* 57 | case NES_AUDIO_FILTER_WEIGHTED: 58 | { 59 | Uint32 prev = naf_prev[ch]; 60 | naf_prev[ch] = output[ch]; 61 | output[ch] = (output[ch] + output[ch] + output[ch] + prev) >> 2; 62 | } 63 | break;*/ 64 | } 65 | *bufp++ = ((Int32)output) - 0x8000; 66 | } 67 | } 68 | 69 | void NESVolume(Uint volume) 70 | { 71 | NES_VOLUME_HANDLER *ph; 72 | for (ph = nvh; ph; ph = ph->next) ph->Proc(volume); 73 | } 74 | 75 | static void NESAudioHandlerInstallOne(NES_AUDIO_HANDLER *ph) 76 | { 77 | /* Add to tail of list*/ 78 | ph->next = 0; 79 | if (nah) 80 | { 81 | NES_AUDIO_HANDLER *p = nah; 82 | while (p->next) p = p->next; 83 | p->next = ph; 84 | } 85 | else 86 | { 87 | nah = ph; 88 | } 89 | } 90 | void NESAudioHandlerInstall(NES_AUDIO_HANDLER *ph) 91 | { 92 | for (;(ph->fMode&2)?(!!ph->Proc2):(!!ph->Proc);ph++) NESAudioHandlerInstallOne(ph); 93 | } 94 | void NESVolumeHandlerInstall(NES_VOLUME_HANDLER *ph) 95 | { 96 | for (;ph->Proc;ph++) 97 | { 98 | /* Add to top of list*/ 99 | ph->next = nvh; 100 | nvh = ph; 101 | } 102 | } 103 | 104 | void NESAudioHandlerInitialize(void) 105 | { 106 | nah = 0; 107 | nvh = 0; 108 | } 109 | 110 | void NESAudioFrequencySet(Uint freq) 111 | { 112 | frequency = freq; 113 | } 114 | Uint NESAudioFrequencyGet(void) 115 | { 116 | return frequency; 117 | } 118 | 119 | void NESAudioChannelSet(Uint ch) 120 | { 121 | channel = ch; 122 | } 123 | Uint NESAudioChannelGet(void) 124 | { 125 | return channel; 126 | } 127 | 128 | -------------------------------------------------------------------------------- /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/DS-Homebrew/NesDS/50f12d87f1ad154b3ac25eaf8c18203f931372bd/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/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/3dsvc_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3DS Virtual Console palette 3 | */ 4 | 5 | #ifndef _3DSVC_PAL_H_ 6 | #define _3DSVC_PAL_H_ 7 | 8 | const u8 nes_rgb_13[] = { 9 | 0x73,0x73,0x73, 0x21,0x18,0x8c, 0x00,0x00,0xad, 0x42,0x00,0x9c, 0x8c,0x00,0x73, 0xad,0x00,0x10, 0xa5,0x00,0x00, 0x7b,0x08,0x00, 10 | 0x42,0x29,0x00, 0x00,0x42,0x00, 0x00,0x52,0x00, 0x00,0x39,0x10, 0x18,0x39,0x5a, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xbd,0xbd,0xbd, 0x00,0x73,0xef, 0x21,0x39,0xef, 0x84,0x00,0xf7, 0xbd,0x00,0xbd, 0xe7,0x00,0x5a, 0xde,0x29,0x00, 0xce,0x4a,0x08, 12 | 0x8c,0x73,0x00, 0x00,0x94,0x00, 0x00,0xad,0x00, 0x00,0x94,0x39, 0x00,0x84,0x8c, 0x10,0x10,0x10, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xff,0xff,0xff, 0x39,0xbd,0xff, 0x5a,0x94,0xff, 0xa5,0x8c,0xff, 0xf7,0x7b,0xff, 0xff,0x73,0xb5, 0xff,0x73,0x63, 0xff,0x9c,0x39, 14 | 0xf7,0xbd,0x39, 0x84,0xd6,0x10, 0x4a,0xde,0x4a, 0x5a,0xff,0x9c, 0x00,0xef,0xde, 0x39,0x39,0x39, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xff,0xff,0xff, 0xad,0xe7,0xff, 0xc6,0xd6,0xff, 0xd6,0xce,0xff, 0xff,0xc6,0xff, 0xff,0xc6,0xde, 0xff,0xbd,0xb5, 0xff,0xde,0xad, 16 | 0xff,0xe7,0xa5, 0xe7,0xff,0xa5, 0xad,0xf7,0xbd, 0xb5,0xff,0xce, 0x9c,0xff,0xf7, 0x8c,0x8c,0x8c, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif -------------------------------------------------------------------------------- /arm9/include/asqrealc_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | AspiringSquire's Real palette 3 | */ 4 | 5 | #ifndef ASQREALC_PAL_H_ 6 | #define ASQREALC_PAL_H_ 7 | 8 | const u8 nes_rgb_1[] = { 9 | 0x6c,0x6c,0x6c, 0x00,0x26,0x8e, 0x00,0x00,0xa8, 0x40,0x00,0x94, 0x70,0x00,0x70, 0x78,0x00,0x40, 0x70,0x00,0x00, 0x62,0x16,0x00, 10 | 0x44,0x24,0x00, 0x34,0x34,0x00, 0x00,0x50,0x00, 0x00,0x44,0x44, 0x00,0x40,0x60, 0x00,0x00,0x00, 0x10,0x10,0x10, 0x10,0x10,0x10, 11 | 0xba,0xba,0xba, 0x20,0x5c,0xdc, 0x38,0x38,0xff, 0x80,0x20,0xf0, 0xc0,0x00,0xc0, 0xd0,0x14,0x74, 0xd0,0x20,0x20, 0xac,0x40,0x14, 12 | 0x7c,0x54,0x00, 0x58,0x64,0x00, 0x00,0x88,0x00, 0x00,0x74,0x68, 0x00,0X74,0x9c, 0x20,0x20,0x20, 0x10,0x10,0x10, 0x10,0x10,0x10, 13 | 0xff,0xff,0xff, 0x4c,0xa0,0xff, 0x88,0x88,0xff, 0xc0,0x6c,0xff, 0xff,0x50,0xff, 0xff,0x64,0xb8, 0xff,0x78,0x78, 0xff,0x96,0x38, 14 | 0xdb,0xab,0x00, 0xa2,0xca,0x20, 0x4a,0xdc,0x4a, 0x2c,0xcc,0xa4, 0x1c,0xc2,0xea, 0x58,0x58,0x58, 0x10,0x10,0x10, 0x10,0x10,0x10, 15 | 0xff,0xff,0xff, 0xb0,0xd4,0xff, 0xc4,0xc4,0xff, 0xe8,0xb8,0xff, 0xff,0xb0,0xff, 0xff,0xb8,0xe8, 0xff,0xc4,0xc4, 0xff,0xd4,0xa8, 16 | 0xff,0xe8,0x90, 0xf0,0xf4,0xa4, 0xc0,0xff,0xc0, 0xac,0xf4,0xf0, 0xa0,0xe8,0xff, 0xc2,0xc2,0xc2, 0x20,0x20,0x20, 0x10,0x10,0x10 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/chriscovell_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Chris Covell's palette 3 | */ 4 | 5 | #ifndef CHRISCOVELL_PAL_H_ 6 | #define CHRISCOVELL_PAL_H_ 7 | 8 | const u8 nes_rgb_2[] = { 9 | 0x80,0x80,0x80, 0x00,0x3D,0xA6, 0x00,0x12,0xB0, 0x44,0x00,0x96, 0xA1,0x00,0x5E, 0xC7,0x00,0x28, 0xBA,0x06,0x00, 0x8C,0x17,0x00, 10 | 0x5C,0x2F,0x00, 0x10,0x45,0x00, 0x05,0x4A,0x00, 0x00,0x47,0x2E, 0x00,0x41,0x66, 0x00,0x00,0x00, 0x05,0x05,0x05, 0x05,0x05,0x05, 11 | 0xC7,0xC7,0xC7, 0x00,0x77,0xFF, 0x21,0x55,0xFF, 0x82,0x37,0xFA, 0xEB,0x2F,0xB5, 0xFF,0x29,0x50, 0xFF,0x22,0x00, 0xD6,0x32,0x00, 12 | 0xC4,0x62,0x00, 0x35,0x80,0x00, 0x05,0x8F,0x00, 0x00,0x8A,0x55, 0x00,0x99,0xCC, 0x21,0x21,0x21, 0x09,0x09,0x09, 0x09,0x09,0x09, 13 | 0xFF,0xFF,0xFF, 0x0F,0xD7,0xFF, 0x69,0xA2,0xFF, 0xD4,0x80,0xFF, 0xFF,0x45,0xF3, 0xFF,0x61,0x8B, 0xFF,0x88,0x33, 0xFF,0x9C,0x12, 14 | 0xFA,0xBC,0x20, 0x9F,0xE3,0x0E, 0x2B,0xF0,0x35, 0x0C,0xF0,0xA4, 0x05,0xFB,0xFF, 0x5E,0x5E,0x5E, 0x0D,0x0D,0x0D, 0x0D,0x0D,0x0D, 15 | 0xFF,0xFF,0xFF, 0xA6,0xFC,0xFF, 0xB3,0xEC,0xFF, 0xDA,0xAB,0xEB, 0xFF,0xA8,0xF9, 0xFF,0xAB,0xB3, 0xFF,0xD2,0xB0, 0xFF,0xEF,0xA6, 16 | 0xFF,0xF7,0x9C, 0xD7,0xE8,0x95, 0xA6,0xED,0xAF, 0xA2,0xF2,0xDA, 0x99,0xFF,0xFC, 0xDD,0xDD,0xDD, 0x11,0x11,0x11, 0x11,0x11,0x11 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/crashman_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | CrashMan's palette 3 | */ 4 | 5 | #ifndef CRASHMAN_PAL_H_ 6 | #define CRASHMAN_PAL_H_ 7 | 8 | const u8 nes_rgb_3[] = { 9 | 0x58,0x58,0x58, 0x00,0x11,0x73, 0x00,0x00,0x62, 0x47,0x2b,0xbf, 0x97,0x00,0x87, 0x91,0x00,0x09, 0x6f,0x11,0x00, 0x4c,0x10,0x08, 10 | 0x37,0x1e,0x00, 0x00,0x2f,0x00, 0x00,0x55,0x00, 0x00,0x4d,0x15, 0x00,0x28,0x40, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xa0,0xa0,0xa0, 0x00,0x44,0x99, 0x2c,0x2c,0xc8, 0x59,0x0d,0xaa, 0xae,0x00,0x6a, 0xb0,0x00,0x40, 0xb8,0x34,0x18, 0x98,0x30,0x10, 12 | 0x70,0x40,0x00, 0x30,0x80,0x00, 0x20,0x78,0x08, 0x00,0x7b,0x33, 0x1c,0x68,0x88, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xf8,0xf8,0xf8, 0x26,0x7b,0xe1, 0x58,0x70,0xf0, 0x98,0x78,0xf8, 0xff,0x73,0xc8, 0xf0,0x60,0xa8, 0xd0,0x7b,0x37, 0xe0,0x90,0x40, 14 | 0xf8,0xb3,0x00, 0x8c,0xbc,0x00, 0x40,0xa8,0x58, 0x58,0xf8,0x98, 0x00,0xb7,0xbf, 0x78,0x78,0x78, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xff,0xff,0xff, 0xa7,0xe7,0xff, 0xb8,0xb8,0xf8, 0xd8,0xb8,0xf8, 0xe6,0xa6,0xff, 0xf2,0x9d,0xc4, 0xf0,0xc0,0xb0, 0xfc,0xe4,0xb0, 16 | 0xe0,0xe0,0x1e, 0xd8,0xf8,0x78, 0xc0,0xe8,0x90, 0x95,0xf7,0xc8, 0x98,0xe0,0xe8, 0xf8,0xd8,0xf8, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/digitalprime_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Firebrandx's Digital Prime palette 3 | */ 4 | 5 | #ifndef FBX_DigitalPrime_PAL_H_ 6 | #define FBX_DigitalPrime_PAL_H_ 7 | 8 | const u8 nes_rgb_9[] = { 9 | 0x69,0x69,0x69, 0x00,0x14,0x8F, 0x1E,0x02,0x9B, 0x3F,0x00,0x8A, 0x60,0x00,0x60, 0x66,0x00,0x17, 0x57,0x0D,0x00, 0x45,0x1B,0x00, 10 | 0x24,0x34,0x00, 0x00,0x42,0x00, 0x00,0x45,0x00, 0x00,0x3C,0x1F, 0x00,0x31,0x5C, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xAF,0xAF,0xAF, 0x0F,0x51,0xDD, 0x44,0x2F,0xF3, 0x72,0x20,0xE2, 0xA3,0x19,0xB3, 0xAE,0x1C,0x51, 0xA4,0x34,0x00, 0x88,0x4D,0x00, 12 | 0x67,0x6D,0x00, 0x20,0x80,0x00, 0x00,0x8B,0x00, 0x00,0x7F,0x42, 0x00,0x6C,0x97, 0x01,0x01,0x01, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xFF,0xFF,0xFF, 0x65,0xAA,0xFF, 0x8C,0x96,0xFF, 0xB9,0x83,0xFF, 0xDD,0x6F,0xFF, 0xEA,0x6F,0xBD, 0xEB,0x84,0x66, 0xDC,0xA2,0x1F, 14 | 0xBA,0xB4,0x03, 0x7E,0xCB,0x07, 0x54,0xD3,0x3E, 0x3C,0xD2,0x84, 0x3E,0xC7,0xCC, 0x4B,0x4B,0x4B, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xFF,0xFF,0xFF, 0xBD,0xE2,0xFF, 0xCE,0xCF,0xFF, 0xE6,0xC2,0xFF, 0xF6,0xBC,0xFF, 0xF9,0xC2,0xED, 0xFA,0xCF,0xC6, 0xF8,0xDE,0xAC, 16 | 0xEE,0xE9,0xA1, 0xD0,0xF5,0x9F, 0xBB,0xF5,0xAF, 0xB3,0xF5,0xCD, 0xB9,0xED,0xF0, 0xB9,0xB9,0xB9, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/firebrandx_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Firebrandx's palette 3 | */ 4 | 5 | #ifndef Firebrandx_PAL_H_ 6 | #define Firebrandx_PAL_H_ 7 | 8 | const u8 nes_rgb_8[] = { 9 | 0x6A,0x6D,0x6A, 0x00,0x13,0x80, 0x1E,0x00,0x8A, 0x39,0x00,0x7A, 0x55,0x00,0x56, 0x5A,0x00,0x18, 0x4F,0x10,0x00, 0x3D,0x1C,0x00, 10 | 0x25,0x32,0x00, 0x00,0x3D,0x00, 0x00,0x40,0x00, 0x00,0x39,0x24, 0x00,0x2E,0x55, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xB9,0xBC,0xB9, 0x18,0x50,0xC7, 0x4B,0x30,0xE3, 0x73,0x22,0xD6, 0x95,0x1F,0xA9, 0x9D,0x28,0x5C, 0x98,0x37,0x00, 0x7F,0x4C,0x00, 12 | 0x5E,0x64,0x00, 0x22,0x77,0x00, 0x02,0x7E,0x02, 0x00,0x76,0x45, 0x00,0x6E,0x8A, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xFF,0xFF,0xFF, 0x68,0xA6,0xFF, 0x8C,0x9C,0xFF, 0xB5,0x86,0xFF, 0xD9,0x75,0xFD, 0xE3,0x77,0xB9, 0xE5,0x8D,0x68, 0xD4,0x9D,0x29, 14 | 0xB3,0xAF,0x0C, 0x7B,0xC2,0x11, 0x55,0xCA,0x47, 0x46,0xCB,0x81, 0x47,0xC1,0xC5, 0x4A,0x4D,0x4A, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xFF,0xFF,0xFF, 0xCC,0xEA,0xFF, 0xDD,0xDE,0xFF, 0xEC,0xDA,0xFF, 0xF8,0xD7,0xFE, 0xFC,0xD6,0xF5, 0xFD,0xDB,0xCF, 0xF9,0xE7,0xB5, 16 | 0xF1,0xF0,0xAA, 0xDA,0xFA,0xA9, 0xC9,0xFF,0xBC, 0xC3,0xFB,0xD7, 0xC4,0xF6,0xF6, 0xBE,0xC1,0xBE, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/loopy_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Loopy's palette 3 | */ 4 | 5 | #ifndef LOOPY_PAL_H_ 6 | #define LOOPY_PAL_H_ 7 | 8 | const u8 nes_rgb_0[] = { 9 | 0x75,0x75,0x75, 0x27,0x1b,0x8f, 0x00,0x00,0xab, 0x47,0x00,0x9f, 0x8f,0x00,0x77, 0xab,0x00,0x13, 0xa7,0x00,0x00, 0x7f,0x0b,0x00, 10 | 0x43,0x2f,0x00, 0x00,0x47,0x00, 0x00,0x51,0x00, 0x00,0x3f,0x17, 0x1b,0x3f,0x5f, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xbc,0xbc,0xbc, 0x00,0x73,0xef, 0x23,0x3b,0xef, 0x83,0x00,0xf3, 0xbf,0x00,0xbf, 0xe7,0x00,0x5b, 0xdb,0x2b,0x00, 0xcb,0x4f,0x0f, 12 | 0x8b,0x73,0x00, 0x00,0x97,0x00, 0x00,0xab,0x00, 0x00,0x93,0x3b, 0x00,0x83,0x8b, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xff,0xff,0xff, 0x3f,0xbf,0xff, 0x5f,0x97,0xff, 0xa7,0x8b,0xfd, 0xf7,0x7b,0xff, 0xff,0x77,0xb7, 0xff,0x77,0x63, 0xff,0x9b,0x3b, 14 | 0xf3,0xbf,0x3f, 0x83,0xd3,0x13, 0x4f,0xdf,0x4b, 0x58,0xf8,0x98, 0x00,0xeb,0xdb, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xff,0xff,0xff, 0xab,0xe7,0xff, 0xc7,0xd7,0xff, 0xd7,0xcb,0xff, 0xff,0xc7,0xff, 0xff,0xc7,0xdb, 0xff,0xbf,0xb3, 0xff,0xdb,0xab, 16 | 0xff,0xe7,0xa3, 0xe3,0xff,0xa3, 0xab,0xf3,0xbf, 0xb3,0xff,0xcf, 0x9f,0xff,0xf3, 0xd1,0xd1,0xd1, 0x11,0x11,0x11, 0x11,0x11,0x11 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/mattconte_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Matthew Conte's palette 3 | */ 4 | 5 | #ifndef MATTCONTE_PAL_H_ 6 | #define MATTCONTE_PAL_H_ 7 | 8 | const u8 nes_rgb_4[] = { 9 | 0x80,0x80,0x80, 0x00,0x00,0xBB, 0x37,0x00,0xBF, 0x84,0x00,0xA6, 0xBB,0x00,0x6A, 0xB7,0x00,0x1E, 0xB3,0x00,0x00, 0x91,0x26,0x00, 10 | 0x7B,0x2B,0x00, 0x00,0x3E,0x00, 0x00,0x48,0x0D, 0x00,0x3C,0x22, 0x00,0x2F,0x66, 0x00,0x00,0x00, 0x05,0x05,0x05, 0x05,0x05,0x05, 11 | 0xC8,0xC8,0xC8, 0x00,0x59,0xFF, 0x44,0x3C,0xFF, 0xB7,0x33,0xCC, 0xFF,0x33,0xAA, 0xFF,0x37,0x5E, 0xFF,0x37,0x1A, 0xD5,0x4B,0x00, 12 | 0xC4,0x62,0x00, 0x3C,0x7B,0x00, 0x1E,0x84,0x15, 0x00,0x95,0x66, 0x00,0x84,0xC4, 0x11,0x11,0x11, 0x09,0x09,0x09, 0x09,0x09,0x09, 13 | 0xFF,0xFF,0xFF, 0x00,0x95,0xFF, 0x6F,0x84,0xFF, 0xD5,0x6F,0xFF, 0xFF,0x77,0xCC, 0xFF,0x6F,0x99, 0xFF,0x7B,0x59, 0xFF,0x91,0x5F, 14 | 0xFF,0xA2,0x33, 0xA6,0xBF,0x00, 0x51,0xD9,0x6A, 0x4D,0xD5,0xAE, 0x00,0xD9,0xFF, 0x66,0x66,0x66, 0x0D,0x0D,0x0D, 0x0D,0x0D,0x0D, 15 | 0xFF,0xFF,0xFF, 0x84,0xBF,0xFF, 0xBB,0xBB,0xFF, 0xD0,0xBB,0xFF, 0xFF,0xBF,0xEA, 0xFF,0xBF,0xCC, 0xFF,0xC4,0xB7, 0xFF,0xCC,0xAE, 16 | 0xFF,0xD9,0xA2, 0xCC,0xE1,0x99, 0xAE,0xEE,0xB7, 0xAA,0xF7,0xEE, 0xB3,0xEE,0xFF, 0xDD,0xDD,0xDD, 0x11,0x11,0x11, 0x11,0x11,0x11 17 | }; 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /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 u8 gammavalue; 28 | extern u8 nes_rgb[192]; 29 | extern const u8 nes_rgb_0[]; 30 | extern const u8 nes_rgb_1[]; 31 | extern const u8 nes_rgb_2[]; 32 | extern const u8 nes_rgb_3[]; 33 | extern const u8 nes_rgb_4[]; 34 | extern const u8 nes_rgb_5[]; 35 | extern const u8 nes_rgb_6[]; 36 | extern const u8 nes_rgb_7[]; 37 | extern const u8 nes_rgb_8[]; 38 | extern const u8 nes_rgb_9[]; 39 | extern const u8 nes_rgb_10[]; 40 | extern const u8 nes_rgb_11[]; 41 | extern const u8 nes_rgb_12[]; 42 | extern const u8 nes_rgb_13[]; 43 | 44 | extern struct button top_button[]; 45 | extern int top_bcnt; 46 | extern struct button menu_button[]; 47 | extern int menu_bcnt; 48 | extern struct button user_button[]; 49 | extern int user_bcnt; 50 | 51 | extern struct button *lastbutton; 52 | extern int lastbutton_type; 53 | extern int lastbutton_cnt; 54 | 55 | extern int menu_stat; 56 | extern struct menu_unit *menu_array[16]; 57 | extern int menu_depth; 58 | extern struct menu_unit *last_menu; 59 | extern char last_type; 60 | extern int menu_draw; 61 | 62 | extern void (*menu_func)(void); 63 | 64 | void draw_button(char *text, int x, int y, int w, int h, int color); 65 | int add_buttonp(int group, struct button *adb); 66 | int add_button(int group, char *name, char type, char x, char y, char w, char h); 67 | void show_button_group(int group); 68 | void check_button_group(int group); 69 | 70 | void menu_hide(void); 71 | void menu_file_loadrom(void); 72 | void menu_file_savestate(void); 73 | void menu_file_loadstate(void); 74 | void menu_file_savesram(void); 75 | void menu_file_slot(void); 76 | void menu_file_start(void); 77 | void menu_game_start(void); 78 | void menu_game_pal(void); 79 | void menu_game_ntsc(void); 80 | void menu_game_input(void); 81 | void menu_game_reset(void); 82 | void menu_input_start(void); 83 | void menu_display_start(void); 84 | void menu_display_br(void); 85 | void brightset(void); 86 | void palset(void); 87 | void menu_display_adjust(void); 88 | void menu_adjust_start(void); 89 | void menu_nifi_start(void); 90 | void menu_nifi_action(void); 91 | void menu_extra_start(void); 92 | void menu_extra_action(void); 93 | void menu_cheat_search_start(void); 94 | void menu_cheat_list_start(void); 95 | void menu_search_action(void); 96 | void menu_list_action(void); 97 | void menu_cht_action(void); 98 | void menu_debug_start(void); 99 | void menu_debug_action(void); 100 | void autofire_fresh(void); 101 | 102 | void menu_shortcut_start(void); 103 | void menu_shortcut_func(void); 104 | 105 | void menu_config_start(void); 106 | void menu_config_func(void); 107 | 108 | void menu_about_start(void); 109 | void menu_about_action(void); 110 | void menu_extra_fds(void); 111 | void menu_extra_barcode(void); 112 | void menu_saveini(void); 113 | void menu_extra_barcode_start(void); 114 | 115 | void show_all_pixel(void); 116 | -------------------------------------------------------------------------------- /arm9/include/mess_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | MESS palette 3 | */ 4 | 5 | #ifndef MESS_PAL_H_ 6 | #define MESS_PAL_H_ 7 | 8 | const u8 nes_rgb_5[] = { 9 | 0x74,0x74,0x74, 0x24,0x18,0x8c, 0x00,0x00,0xa8, 0x44,0x00,0x9c, 0x8c,0x00,0x74, 0xa8,0x00,0x10, 0xa4,0x00,0x00, 0x7c,0x08,0x00, 10 | 0x40,0x2c,0x00, 0x00,0x44,0x00, 0x00,0x50,0x00, 0x00,0x3c,0x14, 0x18,0x3c,0x5c, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xbc,0xbc,0xbc, 0x00,0x70,0xec, 0x20,0x38,0xec, 0x80,0x00,0xf0, 0xbc,0x00,0xbc, 0xe4,0x00,0x58, 0xd8,0x28,0x00, 0xc8,0x4c,0x0c, 12 | 0x88,0x70,0x00, 0x00,0x94,0x00, 0x00,0xa8,0x00, 0x00,0x90,0x38, 0x00,0x80,0x88, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xfc,0xfc,0xfc, 0x3c,0xbc,0xfc, 0x5c,0x94,0xfc, 0x40,0x88,0xfc, 0xf4,0x78,0xfc, 0xfc,0x74,0xb4, 0xfc,0x74,0x60, 0xfc,0x98,0x38, 14 | 0xf0,0xbc,0x3c, 0x80,0xd0,0x10, 0x4c,0xdc,0x48, 0x58,0xf8,0x98, 0x00,0xe8,0xd8, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xfc,0xfc,0xfc, 0xa8,0xe4,0xfc, 0xc4,0xd4,0xfc, 0xd4,0xc8,0xfc, 0xfc,0xc4,0xfc, 0xfc,0xc4,0xd8, 0xfc,0xbc,0xb0, 0xfc,0xd8,0xa8, 16 | 0xfc,0xe4,0xa0, 0xe0,0xfc,0xa0, 0xa8,0xf0,0xbc, 0xb0,0xfc,0xcc, 0x9c,0xfc,0xf0, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /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/include/nesclassic_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | NES Classic palette 3 | */ 4 | 5 | #ifndef NES_Classic_PAL_H_ 6 | #define NES_Classic_PAL_H_ 7 | 8 | const u8 nes_rgb_12[] = { 9 | 0x61,0x61,0x61, 0x00,0x00,0x88, 0x1F,0x0D,0x99, 0x37,0x13,0x79, 0x56,0x12,0x60, 0x5D,0x00,0x10, 0x52,0x0E,0x00, 0x3A,0x23,0x08, 10 | 0x21,0x35,0x0C, 0x0D,0x41,0x0E, 0x17,0x44,0x17, 0x00,0x3A,0x1F, 0x00,0x2F,0x57, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xAA,0xAA,0xAA, 0x0D,0x4D,0xC4, 0x4B,0x24,0xDE, 0x69,0x12,0xCF, 0x90,0x14,0xAD, 0x9D,0x1C,0x48, 0x92,0x34,0x04, 0x73,0x50,0x05, 12 | 0x5D,0x69,0x13, 0x16,0x7A,0x11, 0x13,0x80,0x08, 0x12,0x76,0x49, 0x1C,0x66,0x91, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xFC,0xFC,0xFC, 0x63,0x9A,0xFC, 0x8A,0x7E,0xFC, 0xB0,0x6A,0xFC, 0xDD,0x6D,0xF2, 0xE7,0x71,0xAB, 0xE3,0x86,0x58, 0xCC,0x9E,0x22, 14 | 0xA8,0xB1,0x00, 0x72,0xC1,0x00, 0x5A,0xCD,0x4E, 0x34,0xC2,0x8E, 0x4F,0xBE,0xCE, 0x42,0x42,0x42, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xFC,0xFC,0xFC, 0xBE,0xD4,0xFC, 0xCA,0xCA,0xFC, 0xD9,0xC4,0xFC, 0xEC,0xC1,0xFC, 0xFA,0xC3,0xE7, 0xF7,0xCE,0xC3, 0xE2,0xCD,0xA7, 16 | 0xDA,0xDB,0x9C, 0xC8,0xE3,0x9E, 0xBF,0xE5,0xB8, 0xB2,0xEB,0xC8, 0xB7,0xE5,0xEB, 0xAC,0xAC,0xAC, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif -------------------------------------------------------------------------------- /arm9/include/nespvm_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | NES PVM Style palette 3 | */ 4 | 5 | #ifndef FBX_NES_PVM_Style_PAL_H_ 6 | #define FBX_NES_PVM_Style_PAL_H_ 7 | 8 | const u8 nes_rgb_10[] = { 9 | 0x69,0x6B,0x63, 0x00,0x17,0x74, 0x1E,0x00,0x87, 0x34,0x00,0x73, 0x56,0x00,0x57, 0x5E,0x00,0x13, 0x53,0x1A,0x00, 0x3B,0x24,0x00, 10 | 0x24,0x30,0x00, 0x06,0x3A,0x00, 0x00,0x3F,0x00, 0x00,0x3B,0x1E, 0x00,0x33,0x4E, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xB9,0xBB,0xB3, 0x14,0x53,0xB9, 0x4D,0x2C,0xDA, 0x67,0x1E,0xDE, 0x98,0x18,0x9C, 0x9D,0x23,0x44, 0xA0,0x3E,0x00, 0x8D,0x55,0x00, 12 | 0x65,0x6D,0x00, 0x2C,0x79,0x00, 0x00,0x81,0x00, 0x00,0x7D,0x42, 0x00,0x78,0x8A, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xFF,0xFF,0xFF, 0x69,0xA8,0xFF, 0x96,0x91,0xFF, 0xB2,0x8A,0xFA, 0xEA,0x7D,0xFA, 0xF3,0x7B,0xC7, 0xF2,0x8E,0x59, 0xE6,0xAD,0x27, 14 | 0xD7,0xC8,0x05, 0x90,0xDF,0x07, 0x64,0xE5,0x3C, 0x45,0xE2,0x7D, 0x48,0xD5,0xD9, 0x4E,0x50,0x48, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xFF,0xFF,0xFF, 0xD2,0xEA,0xFF, 0xE2,0xE2,0xFF, 0xE9,0xD8,0xFF, 0xF5,0xD2,0xFF, 0xF8,0xD9,0xEA, 0xFA,0xDE,0xB9, 0xF9,0xE8,0x9B, 16 | 0xF3,0xF2,0x8C, 0xD3,0xFA,0x91, 0xB8,0xFC,0xA8, 0xAE,0xFA,0xCA, 0xCA,0xF3,0xF3, 0xBE,0xC0,0xB8, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif -------------------------------------------------------------------------------- /arm9/include/nesvc_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | NES Virtual Console palette 3 | */ 4 | 5 | #ifndef NES_VC_PAL_H_ 6 | #define NES_VC_PAL_H_ 7 | 8 | const u8 nes_rgb_11[] = { 9 | 0x49,0x49,0x49, 0x00,0x00,0x6a, 0x09,0x00,0x63, 0x29,0x00,0x59, 0x42,0x00,0x4a, 0x49,0x00,0x00, 0x42,0x00,0x00, 0x29,0x11,0x00, 10 | 0x18,0x27,0x00 ,0x00,0x30,0x10 ,0x00,0x30,0x00 ,0x00,0x29,0x10, 0x01,0x20,0x43 ,0x00,0x00,0x00 ,0x00,0x00,0x00 ,0x00,0x00,0x00, 11 | 0x74,0x71,0x74 ,0x00,0x30,0x84 ,0x31,0x01,0xac ,0x4b,0x01,0x94, 0x64,0x00,0x7b ,0x6b,0x00,0x39 ,0x6b,0x21,0x01 ,0x5a,0x2f,0x00, 12 | 0x42,0x49,0x00 ,0x18,0x59,0x01 ,0x10,0x59,0x01 ,0x01,0x59,0x32, 0x01,0x49,0x5a ,0x10,0x10,0x10 ,0x00,0x00,0x00 ,0x00,0x00,0x00, 13 | 0xad,0xad,0xad ,0x4a,0x71,0xb6 ,0x64,0x58,0xd5 ,0x84,0x50,0xe6, 0xa4,0x51,0xad ,0xad,0x49,0x84 ,0xb5,0x62,0x4a ,0x94,0x71,0x32, 14 | 0x7b,0x72,0x2a ,0x5a,0x86,0x01 ,0x38,0x8e,0x31 ,0x31,0x8e,0x5a, 0x39,0x8e,0x8d ,0x38,0x38,0x38 ,0x00,0x00,0x00 ,0x00,0x00,0x00, 15 | 0xb6,0xb6,0xb6 ,0x8c,0x9d,0xb5 ,0x8d,0x8e,0xae ,0x9c,0x8e,0xbc, 0xa6,0x87,0xbc ,0xad,0x8d,0x9d ,0xae,0x96,0x8c ,0x9c,0x8f,0x7c, 16 | 0x9c,0x9e,0x72 ,0x94,0xa6,0x7c ,0x84,0xa7,0x7b ,0x7c,0x9d,0x84, 0x73,0x96,0x8d ,0xde,0xde,0xde ,0x00,0x00,0x00 ,0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/pasofami_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | PasoFami/99 palette 3 | */ 4 | 5 | #ifndef PASOFAMI_PAL_H_ 6 | #define PASOFAMI_PAL_H_ 7 | 8 | const u8 nes_rgb_6[] = { 9 | 0x7f,0x7f,0x7f, 0x00,0x00,0xff, 0x00,0x00,0xbf, 0x47,0x2b,0xbf, 0x97,0x00,0x87, 0xab,0x00,0x23, 0xab,0x13,0x00, 0x8b,0x17,0x00, 10 | 0x53,0x30,0x00, 0x00,0x78,0x00, 0x00,0x6b,0x00, 0x00,0x5b,0x00, 0x00,0x43,0x58, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0xbf,0xbf,0xbf, 0x00,0x78,0xf8, 0x00,0x58,0xf8, 0x6b,0x47,0xff, 0xdb,0x00,0xcd, 0xe7,0x00,0x5b, 0xf8,0x38,0x00, 0xe7,0x5f,0x13, 12 | 0xaf,0x7f,0x00, 0x00,0xb8,0x00, 0x00,0xab,0x00, 0x00,0xab,0x47, 0x00,0x8b,0x8b, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xf8,0xf8,0xf8, 0x3f,0xbf,0xff, 0x6b,0x88,0xff, 0x98,0x78,0xf8, 0xf8,0x78,0xf8, 0xf8,0x58,0x98, 0xf8,0x78,0x58, 0xff,0xa3,0x47, 14 | 0xf8,0xb8,0x00, 0xb8,0xf8,0x18, 0x5b,0xdb,0x57, 0x58,0xf8,0x98, 0x00,0xeb,0xdb, 0x78,0x78,0x78, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xff,0xff,0xff, 0xa7,0xe7,0xff, 0xb8,0xb8,0xf8, 0xd8,0xb8,0xf8, 0xf8,0xb8,0xf8, 0xfb,0xa7,0xc3, 0xf0,0xd0,0xb0, 0xff,0xe3,0xab, 16 | 0xfb,0xdb,0x7b, 0xd8,0xf8,0x78, 0xb8,0xf8,0xb8, 0xb8,0xf8,0xd8, 0x00,0xff,0xff, 0xf8,0xd8,0xf8, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/include/quor_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Quor's palette 3 | */ 4 | 5 | #ifndef QUOR_PAL_H_ 6 | #define QUOR_PAL_H_ 7 | 8 | const u8 nes_rgb_7[] = { 9 | 0x3f,0x3f,0x3f, 0x00,0x1f,0x3f, 0x00,0x00,0x3f, 0x1f,0x00,0x3f, 0x3f,0x00,0x3f, 0x3f,0x00,0x20, 0x3f,0x00,0x00, 0x3f,0x20,0x00, 10 | 0x3f,0x3f,0x00, 0x20,0x3f,0x00, 0x00,0x3f,0x00, 0x00,0x3f,0x20, 0x00,0x3f,0x3f, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 11 | 0x7f,0x7f,0x7f, 0x40,0x5f,0x7f, 0x40,0x40,0x7f, 0x5f,0x40,0x7f, 0x7f,0x40,0x7f, 0x7f,0x40,0x60, 0x7f,0x40,0x40, 0x7f,0x60,0x40, 12 | 0x7f,0x7f,0x40, 0x60,0x7f,0x40, 0x40,0x7f,0x40, 0x40,0x7f,0x60, 0x40,0x7f,0x7f, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 13 | 0xbf,0xbf,0xbf, 0x80,0x9f,0xbf, 0x80,0x80,0xbf, 0x9f,0x80,0xbf, 0xbf,0x80,0xbf, 0xbf,0x80,0xa0, 0xbf,0x80,0x80, 0xbf,0xa0,0x80, 14 | 0xbf,0xbf,0x80, 0xa0,0xbf,0x80, 0x80,0xbf,0x80, 0x80,0xbf,0xa0, 0x80,0xbf,0xbf, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 15 | 0xff,0xff,0xff, 0xc0,0xdf,0xff, 0xc0,0xc0,0xff, 0xdf,0xc0,0xff, 0xff,0xc0,0xff, 0xff,0xc0,0xe0, 0xff,0xc0,0xc0, 0xff,0xe0,0xc0, 16 | 0xff,0xff,0xc0, 0xe0,0xff,0xc0, 0xc0,0xff,0xc0, 0xc0,0xff,0xe0, 0xc0,0xff,0xff, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arm9/source/NesMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef NESMACHINE_HEADER 2 | #define NESMACHINE_HEADER 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "RP2A03.h" 9 | #include "RP2C02.h" 10 | 11 | typedef struct { 12 | RP2A03 cpu; 13 | RP2C02 ppu; 14 | u8 mapperData[96]; 15 | 16 | u8 *romBase; 17 | u32 romMask; 18 | u32 prgSize8k; 19 | u32 prgSize16k; 20 | u32 prgSize32k; 21 | u32 mapperInitPtr; 22 | u32 emuFlags; 23 | u32 prgCrc; 24 | 25 | u32 lightY; 26 | 27 | u32 renderCount; 28 | u32 tempData[20]; 29 | 30 | u8 cartFlags; 31 | u8 padding[3]; 32 | } NESCore; 33 | 34 | extern RP2A03 rp2A03; 35 | extern NESCore globals; 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif // NESMACHINE_HEADER 42 | -------------------------------------------------------------------------------- /arm9/source/RP2C02/RP2C02.h: -------------------------------------------------------------------------------- 1 | #ifndef NESPPU_HEADER 2 | #define NESPPU_HEADER 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /** Revision of PPU chip */ 9 | typedef enum { 10 | /** NTSC first revision(s) */ 11 | REV_RP2C02 = 0x00, 12 | /** PAL revision */ 13 | REV_RP2C07 = 0x01, 14 | /** NTSC RGB revision */ 15 | REV_RP2C03 = 0x02, 16 | /** NTSC RGB revision */ 17 | REV_RP2C04 = 0x02, 18 | /** NTSC RGB revision */ 19 | REV_RP2C05 = 0x02, 20 | /** UMC UA6528P, Argentina Famiclone */ 21 | REV_UA6528P = 0x03, 22 | /** UMC UA6538, aka Dendy */ 23 | REV_UA6538 = 0x04, 24 | /** UMC UA6548, Brazil Famiclone */ 25 | REV_UA6548 = 0x05, 26 | } RP2C03REV; 27 | 28 | typedef struct { 29 | u32 scanline; 30 | u32 nextLineChange; 31 | u32 lineState; 32 | u32 frame; 33 | u32 cyclesPerScanline; 34 | u32 lastScanline; 35 | 36 | // PPU State 37 | u32 vramAddr; 38 | u32 vramAddr2; 39 | u32 scrollX; 40 | u32 scrollY; 41 | u32 scrollYTemp; 42 | u32 sprite0Y; 43 | u32 bg0Cnt; 44 | u8 ppuBusLatch; 45 | u8 sprite0X; 46 | u8 vramAddrInc; 47 | u8 toggle; 48 | u8 ppuCtrl0; 49 | u8 ppuCtrl1; 50 | u8 ppuStat; 51 | u8 ppuOamAdr; 52 | u8 ppuCtrl0Frame; 53 | u8 readTemp; 54 | u8 rp2C02Revision; 55 | u8 unusedAlign[1]; 56 | 57 | u32 loopy_t; 58 | u32 loopy_x; 59 | u32 loopy_y; 60 | u32 loopy_v; 61 | 62 | u32 vromMask; 63 | u32 vromBase; 64 | u32 palSyncLine; 65 | 66 | u32 pixStart; 67 | u32 pixEnd; 68 | u32 unused; 69 | 70 | u16 nesChrMap[8]; 71 | u32 ppuOAMMem[64]; 72 | u8 paletteMem[32]; 73 | 74 | void (*ppuIrqFunc)(bool); 75 | void (*newFrameHook)(void); 76 | void (*endFrameHook)(void); 77 | void (*scanlineHook)(void); 78 | void (*ppuChrLatch)(int tileNr); 79 | u8 unusedAlign2[8]; 80 | } RP2C02; 81 | 82 | void PPU_init(void); 83 | void EMU_VBlank(void); 84 | void paletteinit(void); 85 | void PaletteTxAll(void); 86 | void rescale_nr(u32 scale, u32 start); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif // NESPPU_HEADER 93 | -------------------------------------------------------------------------------- /arm9/source/RP2C02/RP2C02.i: -------------------------------------------------------------------------------- 1 | 2 | globalptr .req r10 ;@ =wram_globals* ptr 3 | addy .req r12 ;@ Keep this at r12 (scratch for APCS) 4 | 5 | NDS_PALETTE = 0x5000000 6 | 7 | /** Revision of chip */ 8 | .equ REV_RP2C02, 0x00 ;@ NTSC first revision(s) 9 | .equ REV_RP2C07, 0x01 ;@ PAL revision 10 | .equ REV_RP2C03, 0x02 ;@ NTSC RGB revision 11 | .equ REV_RP2C04, 0x02 ;@ NTSC RGB revision 12 | .equ REV_RP2C05, 0x02 ;@ NTSC RGB revision 13 | .equ REV_UA6528P, 0x03 ;@ UMC UA6528P, Argentina Famiclone 14 | .equ REV_UA6538, 0x04 ;@ UMC UA6538, aka Dendy 15 | .equ REV_UA6548, 0x05 ;@ UMC UA6548, Brazil Famiclone 16 | 17 | ;@ RP2C02.s 18 | rp2c02ptr .req m6502ptr 19 | .struct rp2A03Size 20 | rp2C02Start: 21 | scanline: .long 0 ;@ These 3 must be first in state. 22 | nextLineChange: .long 0 23 | lineState: .long 0 24 | frame: .long 0 25 | cyclesPerScanline: .long 0 26 | lastScanline: .long 0 27 | 28 | ppuState: 29 | vramAddr: .long 0 30 | vramAddr2: .long 0 31 | scrollX: .long 0 32 | scrollY: .long 0 33 | scrollYTemp: .long 0 34 | sprite0Y: .long 0 35 | bg0Cnt: .long 0 36 | ppuBusLatch: .byte 0 37 | sprite0X: .byte 0 38 | vramAddrInc: .byte 0 39 | toggle: .byte 0 40 | ppuCtrl0: .byte 0 41 | ppuCtrl1: .byte 0 42 | ppuStat: .byte 0 43 | ppuOamAdr: .byte 0 44 | ppuCtrl0Frame: .byte 0 45 | readTemp: .byte 0 46 | rp2C02Revision: .byte 0 47 | unusedAlign: .skip 1 48 | 49 | loopy_t: .long 0 50 | loopy_x: .long 0 51 | loopy_y: .long 0 52 | loopy_v: .long 0 53 | 54 | vromMask: .long 0 55 | vromBase: .long 0 56 | palSyncLine: .long 0 57 | 58 | pixStart: .long 0 59 | pixEnd: .long 0 60 | unused: .long 0 61 | 62 | nesChrMap: .space 8*2 63 | ppuOAMMem: .space 64*4 64 | paletteMem: .space 32 ;@ NES $3F00-$3F1F 65 | 66 | ppuIrqFunc: .long 0 67 | newFrameHook: .long 0 68 | endFrameHook: .long 0 69 | scanlineHook: .long 0 70 | ppuChrLatch: .long 0 71 | unusedAlign2: .skip 8 72 | rp2C02End: 73 | 74 | rp2C02Size = rp2C02End-rp2C02Start 75 | 76 | ;@---------------------------------------------------------------------------- 77 | -------------------------------------------------------------------------------- /arm9/source/barcode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "c_defs.h" 3 | 4 | char prefix_parity_type[10][6] = { 5 | {0,0,0,0,0,0}, {0,0,1,0,1,1}, {0,0,1,1,0,1}, {0,0,1,1,1,0}, 6 | {0,1,0,0,1,1}, {0,1,1,0,0,1}, {0,1,1,1,0,0}, {0,1,0,1,0,1}, 7 | {0,1,0,1,1,0}, {0,1,1,0,1,0} 8 | }; 9 | char data_left_odd[10][7] = { 10 | {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}, 11 | {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}, 12 | {0,1,1,0,1,1,1}, {0,0,0,1,0,1,1} 13 | }; 14 | char data_left_even[10][7] = { 15 | {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}, 16 | {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}, 17 | {0,0,0,1,0,0,1}, {0,0,1,0,1,1,1} 18 | }; 19 | char data_right[10][7] = { 20 | {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}, 21 | {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}, 22 | {1,0,0,1,0,0,0}, {1,1,1,0,1,0,0} 23 | }; 24 | 25 | unsigned char barcode_data[256]; 26 | void setbarcodedata(char *code, int len) { 27 | /* 28 | if( rom->GetPROM_CRC() == 0x67898319 ) { // Barcode World (J) 29 | SetBarcode2Data( code, len ); 30 | return; 31 | }*/ 32 | 33 | int i, j, count = 0; 34 | 35 | for (i = 0; i < len; i++) { 36 | code[i] = code[i]-'0'; 37 | } 38 | 39 | for (i = 0; i < 32; i++) { 40 | barcode_data[count++] = 0x08; 41 | } 42 | 43 | barcode_data[count++] = 0x00; 44 | barcode_data[count++] = 0x08; 45 | barcode_data[count++] = 0x00; 46 | 47 | int sum = 0; 48 | 49 | switch (len) { 50 | case 13: 51 | for (i = 0; i < 6; i++) { 52 | if (prefix_parity_type[(int)code[0]][i]) { 53 | for (j = 0; j < 7; j++) { 54 | barcode_data[count++] = data_left_even[(int)code[i+1]][j]?0x00:0x08; 55 | } 56 | } else { 57 | for (j = 0; j < 7; j++) { 58 | barcode_data[count++] = data_left_odd[(int)code[i+1]][j]?0x00:0x08; 59 | } 60 | } 61 | } 62 | 63 | barcode_data[count++] = 0x08; 64 | barcode_data[count++] = 0x00; 65 | barcode_data[count++] = 0x08; 66 | barcode_data[count++] = 0x00; 67 | barcode_data[count++] = 0x08; 68 | 69 | for (i = 7; i < 13; i++) { 70 | for (j = 0; j < 7; j++) { 71 | barcode_data[count++] = data_right[(int)code[i]][j] ? 0x00 : 0x08; 72 | } 73 | } 74 | break; 75 | case 8: 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 | break; 99 | } 100 | 101 | barcode_data[count++] = 0x00; 102 | barcode_data[count++] = 0x08; 103 | barcode_data[count++] = 0x00; 104 | 105 | for( i = 0; i < 32; i++ ) { 106 | barcode_data[count++] = 0x08; 107 | } 108 | 109 | barcode_data[count++] = 0xFF; 110 | 111 | __barcode = 1; 112 | __barcode_out = 0x08; 113 | } 114 | -------------------------------------------------------------------------------- /arm9/source/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef CPU_HEADER 2 | #define CPU_HEADER 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void cpuInit(void); 9 | void ntsc_pal_reset(int emuflags); 10 | void EMU_Run(void); 11 | void NSF_Run(void); 12 | 13 | #ifdef __cplusplus 14 | } // extern "C" 15 | #endif 16 | 17 | #endif // CPU_HEADER 18 | -------------------------------------------------------------------------------- /arm9/source/ips.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "c_defs.h" 5 | 6 | bool ips_stat = false; 7 | int ips_len = 0; //length of ips patch. 8 | char *ips_start = (char *)rom_start + ROM_MAX_SIZE - MAX_IPS_SIZE; //alloca the ips patch here. 9 | 10 | void load_ips(const char *name) 11 | { 12 | FILE *fp; 13 | 14 | ips_stat = false; 15 | ips_len = 0; 16 | 17 | fp = fopen(name,"rb"); 18 | if(!fp) 19 | return; 20 | 21 | ips_len = fread(ips_start,1,MAX_IPS_SIZE,fp); 22 | ips_stat = (ips_len > 0); 23 | 24 | fclose(fp); 25 | } 26 | 27 | unsigned int read24(const void *p){ 28 | const unsigned char *x=(const unsigned char*)p; 29 | return x[2]|(x[1]<<8)|(x[0]<<16); 30 | } 31 | 32 | unsigned short read16(const void *p){ 33 | const unsigned char *x=(const unsigned char*)p; 34 | return x[1]|(x[0]<<8); 35 | } 36 | 37 | int ipspatch(char *pfile, int *sizfile, const char *pips, const unsigned int sizips){ //pass pfile=NULL to get sizfile. 38 | unsigned int offset=5,address=0,size=-1,u; 39 | if(sizips<8||memcmp(pips,"PATCH",5))return 2; 40 | if(!pfile)*sizfile=0; 41 | while(1){ 42 | if(offset+3>sizips)return 1; 43 | address=read24(pips+offset);offset+=3; 44 | if(address==0x454f46&&offset==sizips)break; 45 | if(offset+2>sizips)return 1; 46 | size=read16(pips+offset);offset+=2; 47 | if(size){ 48 | if(offset+size>sizips)return 1; 49 | if(!pfile){ 50 | if(*sizfile*sizfile)return 1; 55 | //fprintf(stderr,"write 0x%06x %dbytes\n",address,size); 56 | memcpy(pfile+address,pips+offset,size); 57 | offset+=size; 58 | }else{ 59 | if(offset+3>sizips)return 1; 60 | size=read16(pips+offset);offset+=2; 61 | if(!pfile){ 62 | if(*sizfile*sizfile)return 1; 67 | //fprintf(stderr,"fill 0x%06x %dbytes\n",address,size); 68 | for(u=address;u 2 | #include 3 | #include 4 | 5 | void SplitItemFromFullPathAlias(const char *pFullPathAlias,char *pPathAlias,char *pFilenameAlias) { 6 | u32 SplitPos = 0; 7 | { 8 | u32 idx = 0; 9 | while (1) { 10 | char uc = pFullPathAlias[idx]; 11 | if(uc == 0) break; 12 | if(uc == '/') SplitPos = idx + 1; 13 | idx++; 14 | } 15 | } 16 | 17 | if (pPathAlias) { 18 | if (SplitPos <= 1) { 19 | pPathAlias[0] = '/'; 20 | pPathAlias[1] = 0; 21 | } else { 22 | u32 idx = 0; 23 | for(; idx < SplitPos - 1; idx++){ 24 | pPathAlias[idx] = pFullPathAlias[idx]; 25 | } 26 | pPathAlias[SplitPos - 1] = 0; 27 | } 28 | } 29 | 30 | if(pFilenameAlias) 31 | strcpy(pFilenameAlias, &pFullPathAlias[SplitPos]); 32 | } 33 | 34 | extern int argc; 35 | extern char **argv; 36 | bool readFrontend(char *target) 37 | { 38 | char dir[768]; 39 | if (argc < 2) 40 | return false; 41 | 42 | SplitItemFromFullPathAlias(argv[1],dir,target); 43 | chdir(dir); 44 | return true; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /arm9/source/sound.s: -------------------------------------------------------------------------------- 1 | @--------------------------------------------------------------------------------- 2 | #include "equates.h" 3 | @--------------------------------------------------------------------------------- 4 | .global updatesound 5 | .global soundwrite 6 | .global _4015r 7 | @--------------------------------------------------------------------------------- 8 | .section .text,"ax" 9 | @--------------------------------------------------------------------------------- 10 | @Sound_reset moved to junk.c 11 | @--------------------------------------------------------------------------------- 12 | @mov r0,#0x00001000 13 | @str r0,pcmctrl 14 | @ bx lr 15 | @--------------------------------------------------------------------------------- 16 | soundwrite: 17 | @--------------------------------------------------------------------------------- 18 | stmfd sp!,{r3,lr} 19 | 20 | @IMPORT writeAPU 21 | mov r1,addy 22 | bl writeAPU 23 | 24 | ldmfd sp!,{r3,pc} 25 | @--------------------------------------------------------------------------------- 26 | _4015r: 27 | @--------------------------------------------------------------------------------- 28 | ldr r1, =IPC_REG4015 @which is updated by s_apu.c 29 | ldrb r0, [r1] 30 | bx lr 31 | @--------------------------------------------------------------------------------- 32 | updatesound: @called from line 0.. r0-r9 are free to use 33 | @--------------------------------------------------------------------------------- 34 | bx lr 35 | @--------------------------------------------------------------------------------- 36 | -------------------------------------------------------------------------------- /arm9/source/stepdebug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "c_defs.h" 3 | #include "NesMachine.h" 4 | 5 | unsigned int stepinfo[1024]; 6 | extern unsigned int *pstep; 7 | 8 | unsigned char ptbuf[1024] = 9 | /*1234567890123456789012345678901*/ 10 | "frame: line: " 11 | "pc: " 12 | "A: X: Y: P: SP: " 13 | " " 14 | " " 15 | " " 16 | " " 17 | " " 18 | " " 19 | " " 20 | " " 21 | " " 22 | " " 23 | " " 24 | " " 25 | " " 26 | " " 27 | " " 28 | " " 29 | " " 30 | " " 31 | " " 32 | " " 33 | " " 34 | ; 35 | 36 | void shex(unsigned char *p,int d,int n) { 37 | u16 c; 38 | do { 39 | c=d&0x0f; 40 | if(c<10) c+='0'; 41 | else c=c-10+'A'; 42 | d>>=4; 43 | p[n--]=c; 44 | } while(n>=0); 45 | } 46 | 47 | #define shex8(a,b) shex(a,b,1) 48 | #define shex16(a,b) shex(a,b,3) 49 | #define shex24(a,b) shex(a,b,5) 50 | #define shex32(a,b) shex(a,b,7) 51 | 52 | 53 | void stepdebug() 54 | {/* 55 | static int frameCount = 0; 56 | static int line, keys, oldkeys, opCount = 0; 57 | unsigned int i, count; 58 | i = 0; 59 | opCount++; 60 | if(line == 240 && __scanline == 241) { 61 | frameCount++; 62 | swiWaitForVBlank(); 63 | //keys = IPC_KEYS; 64 | keys &= ~KEY_SELECT; 65 | } 66 | if(keys & KEY_SELECT) { 67 | line = __scanline; 68 | //pstep = stepinfo; 69 | return; 70 | } 71 | if(keys & KEY_R && line == __scanline) { 72 | return; 73 | } 74 | line = __scanline; 75 | shex32(ptbuf + 6, frameCount); 76 | shex16(ptbuf + 20, __scanline); 77 | shex16(ptbuf + 32 + 3, rp2A03.m6502.regPc - rp2A03.m6502.lastBank); 78 | shex8(ptbuf + 32 + 8, *rp2A03.m6502.regPc); 79 | shex8(ptbuf + 32 + 11, *(rp2A03.m6502.regPc + 1)); 80 | shex8(ptbuf + 32 + 14, *(rp2A03.m6502.regPc + 2)); 81 | shex32(ptbuf + 50, opCount); 82 | 83 | shex8(ptbuf + 64 + 2, rp2A03.m6502.regA>>24); 84 | shex8(ptbuf + 64 + 7, rp2A03.m6502.regX>>24); 85 | shex8(ptbuf + 64 + 12, rp2A03.m6502.regY>>24); 86 | shex8(ptbuf + 64 + 17, rp2A03.m6502.cycles); 87 | 88 | for(i = 0; i < 8; i++) { 89 | shex8(ptbuf + 96 + 3*i, globals.ppu.nesChrMap[i]); 90 | } 91 | for(i = 0; i < 4; i++) { 92 | shex8(ptbuf + 128 + 3*i, globals.ppu.nesChrMap[i + 8]); 93 | } 94 | for(i = 4; i < 8; i++) { 95 | shex8(ptbuf + 128 + 3*i, ((rp2A03.m6502.memTbl[i] - globals.romBase) >> 13) + i); 96 | } 97 | 98 | count = pstep - stepinfo; 99 | if(count > 18 * 4) { 100 | count = 18 * 4; 101 | } 102 | for(i = 0; i < count; i++) { 103 | shex(ptbuf + 192 + i*8, stepinfo[i] >> 12, 3); 104 | if(stepinfo[i] & 0x100) { 105 | *(ptbuf + 192 + i * 8 + 4) = 'w'; 106 | } else { 107 | *(ptbuf + 192 + i * 8 + 4) = 'r'; 108 | } 109 | shex(ptbuf + 197 + i*8, stepinfo[i], 1); 110 | } 111 | 112 | consoletext(0, ptbuf, 0); 113 | //memset( ptbuf + 192 + count * 8, 32, (18 * 4 - count) * 8); 114 | 115 | do { 116 | IPC_KEYS = keysCurrent(); 117 | keys = IPC_KEYS; 118 | if(keys & oldkeys & (KEY_SELECT | KEY_R | KEY_L)) { 119 | //pstep = stepinfo; 120 | return; 121 | } 122 | if(keys & (KEY_SELECT | KEY_R | KEY_L)) { 123 | //pstep = stepinfo; 124 | break; 125 | } 126 | swiWaitForVBlank(); 127 | oldkeys = 0; 128 | } 129 | while(1); 130 | oldkeys = keys; 131 | //pstep = stepinfo;*/ 132 | } 133 | -------------------------------------------------------------------------------- /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/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 | #ifdef ARM7 2 | .arch armv4t 3 | .cpu arm7tdmi 4 | #else 5 | #ifdef ARM9 6 | .arch armv5te 7 | .cpu arm946e-s 8 | #endif 9 | #endif 10 | .text 11 | .arm 12 | .global SLasm_Acquire 13 | .type SLasm_Acquire STT_FUNC 14 | @--------------------------------------------------------------------------------- 15 | SLasm_Acquire: 16 | @--------------------------------------------------------------------------------- 17 | ldr r2,[r0] 18 | cmp r2,#0 19 | movne r0,#1 20 | bxne lr 21 | mov r2,r1 22 | swp r2,r2,[r0] 23 | cmp r2,#0 24 | cmpne r2,r1 25 | moveq r0,#0 26 | bxeq lr 27 | swp r2,r2,[r0] 28 | mov r0,#1 29 | bx lr 30 | 31 | .global SLasm_Release 32 | .type SLasm_Release STT_FUNC 33 | @--------------------------------------------------------------------------------- 34 | SLasm_Release: 35 | @--------------------------------------------------------------------------------- 36 | ldr r2,[r0] 37 | cmp r2,r1 38 | movne r0,#2 39 | bxne lr 40 | mov r2,#0 41 | swp r2,r2,[r0] 42 | cmp r2,r1 43 | moveq r0,#0 44 | movne r0,#2 45 | bx lr 46 | 47 | .pool 48 | .end 49 | -------------------------------------------------------------------------------- /icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/50f12d87f1ad154b3ac25eaf8c18203f931372bd/icon.bmp -------------------------------------------------------------------------------- /make_cia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/50f12d87f1ad154b3ac25eaf8c18203f931372bd/make_cia -------------------------------------------------------------------------------- /release/nesDS.ini: -------------------------------------------------------------------------------- 1 | [plug setting] 2 | ;DSTWO 3 | icon=fat1:/_dstwoplug/nesDS.bmp 4 | name=nesDS 5 | 6 | [nesDSrev2] 7 | ;Default folder to start with. 8 | ;默认启动的目录 9 | StartIn=/ 10 | ;If the functions of A/B/X/Y exchange. 11 | ;是否切换A、B键的功能 12 | BASwap=0 13 | ;The way to make effect. 0=flicker 1=noflicker 2=alphalerp. 14 | ;画面渲染模拟 15 | Blend=0 16 | ;If the game runs as PAL-Timing(50fps). 17 | ;是否使用pal制式. 18 | PALTiming=0 19 | ;The way rendering the graphic. 0=normal 1=SP-pertile 2=pure-soft. 20 | ;画面渲染模式 21 | Render=1 22 | ;If SRAM saved by auto. 23 | ;是否自动保存SRAM 24 | AutoSRAM=0 25 | ;If top & sub screens swap. 26 | ;是否默认上下屏切换 27 | ScreenSwap=0 28 | ;How the graphic scales. Do NOT change this if you dont know how it works. 29 | ;画面拉伸 30 | Screen_Scale=57344 31 | ;Offset of graphic. Do NOT change this if you dont know how it works. 32 | ;屏幕位移 33 | Screen_Offset=-393216 34 | ;Autofire speed, fps=60/AutoFire, AutoFire range from 2 to 30 35 | ;连发速度,速度为60fps/AutoFire,AutoFire的范围为2~30 36 | AutoFire=2 37 | ;end of global settings... 38 | ;Short-Cuts & Gestures. Short-Cuts should start with sc_ and gestures start with ge_ . 39 | ;快捷键和手势,快捷键以sc_开头,手势以ge_开头. 40 | ;you can use the number or just the string... e.g. 'xxx_short_cut=3' or 'xxx_short_cut=KEY_A, KEY_B' or 'xxx_short_cut=KEY_A | KEY_B' do the same. 41 | ;可以使用键位对应的英文,或者直接使用数字来代表按键组合 42 | ;KEY_A= 1 43 | ;KEY_B= 2 44 | ;KEY_SELECT= 4 45 | ;KEY_START= 8 46 | ;KEY_RIGHT= 16 47 | ;KEY_LEFT= 32 48 | ;KEY_UP= 64 49 | ;KEY_DOWN= 128 50 | ;KEY_RBUTTON= 256 'KEY_R' or 'KEY_L' is now allowed... 51 | ;KEY_LBUTTON= 512 52 | ;KEY_X= 1024 53 | ;KEY_Y= 2048 54 | ;Gestures 55 | ;U = Up, D = Down, L = Left, R = Right 56 | ;U对应上, D对应下, L对应左, R对应右 57 | ;Start from here 58 | ;以下是配置 59 | ;Load from a state 60 | ;读取即时存档 61 | sc_loadstate=0 62 | ge_loadstate= 63 | ;Save to a state 64 | ;保存即时存档 65 | sc_savestate=0 66 | ge_savestate= 67 | ;Show the rom menu 68 | ;选取rom 69 | sc_loadrom="KEY_SELECT, KEY_START, " 70 | ge_loadrom=DU 71 | ;Swap the functions of A/B 72 | ;切换AB 73 | sc_swapab=0 74 | ge_swapab= 75 | ;Auto save SRAM 76 | ;自动保存SRAM 77 | sc_autosramsave=0 78 | ge_autosramsave= 79 | ;Scale left 80 | sc_scaleleft=0 81 | ge_scaleleft= 82 | ;Scale right 83 | sc_scaleright=0 84 | ge_scaleright= 85 | ;Scale up 86 | sc_scaleup=0 87 | ge_scaleup= 88 | ;Scale down 89 | sc_scaledown=0 90 | ge_scaledown= 91 | ;Switch rendering method 92 | ;切换画面模拟方法 93 | sc_swaprender=0 94 | ge_swaprender= 95 | ;Switch blend type 96 | ;切换画面渲染方法 97 | sc_swapblend=0 98 | ge_swapblend= 99 | ;FDS: Switch to DISK A 100 | sc_diska=0 101 | ge_diska= 102 | ;FDS: Switch to DISK B 103 | sc_diskb=0 104 | ge_diskb= 105 | ;FDS: Switch to DISK C 106 | sc_diskc=0 107 | ge_diskc= 108 | ;FDS: Switch to DISK D 109 | sc_diskd=0 110 | ge_diskd= 111 | ;Swap the top/sub screens 112 | ;切换上下屏 113 | sc_swapscreen=0 114 | ge_swapscreen=DUDU 115 | ;Disable LightGun to use menu 116 | ;禁用光枪来恢复菜单使用 117 | sc_lightgunoff="KEY_RBUTTON, KEY_LBUTTON, " 118 | ge_lightgunoff= 119 | ;Fast forward 120 | ;快进 121 | sc_fastforward="KEY_RBUTTON" 122 | ge_fastforward= 123 | ;Rewind 124 | ;倒退 125 | sc_rewind="KEY_LBUTTON" 126 | ge_rewind= 127 | --------------------------------------------------------------------------------