├── README.TXT ├── icon.bmp ├── make_cia ├── arm7 ├── source │ ├── s_apu.c │ ├── license.txt │ ├── s_fds.c │ ├── handler.c │ ├── arm7.c │ └── audiosys.c └── include │ ├── logtable.h │ ├── s_apu.h │ ├── s_fds.h │ ├── s_vrc6.h │ ├── arm7.h │ ├── nsdout.h │ ├── nestypes.h │ ├── fdsplugin.h │ ├── handler.h │ ├── nsf6502.h │ └── audiosys.h ├── .gitmodules ├── common ├── readme.txt ├── spinlock.s ├── dswifi │ └── dswifi_license.txt └── spinlock.h ├── arm9 ├── source │ ├── cpu.h │ ├── mappers │ │ ├── mmc1.i │ │ ├── mmc3.i │ │ ├── map0.s │ │ ├── map1.s │ │ ├── map94.s │ │ ├── map30.s │ │ ├── map97.s │ │ ├── map184.s │ │ ├── map240.s │ │ ├── map111.s │ │ ├── map246.s │ │ ├── map87.s │ │ ├── map93.s │ │ ├── map77.s │ │ ├── map78.s │ │ ├── map216.s │ │ ├── map85.s │ │ ├── map118.s │ │ ├── map86.s │ │ ├── map92.s │ │ ├── map72.s │ │ ├── map34.s │ │ ├── map88.s │ │ ├── map32.s │ │ ├── map76.s │ │ ├── map79.s │ │ ├── map99.s │ │ ├── map0237.s │ │ ├── map228.s │ │ ├── map91.s │ │ ├── map80.s │ │ ├── map70152.s │ │ ├── map40.s │ │ ├── map82.s │ │ ├── map17.s │ │ ├── map22.s │ │ ├── map4.s │ │ ├── map245.s │ │ ├── map71_232.s │ │ ├── map1166.s │ │ ├── konami.s │ │ ├── map42.s │ │ ├── map47.s │ │ ├── map159.s │ │ ├── map15.s │ │ ├── map23.s │ │ ├── map37.s │ │ ├── map2426.s │ │ ├── map65.s │ │ ├── map75.s │ │ ├── map255.s │ │ ├── map69.s │ │ ├── map67.s │ │ ├── map2125.s │ │ ├── map253.s │ │ ├── map198.s │ │ ├── map105.s │ │ ├── map73.s │ │ ├── map64.s │ │ ├── map33.s │ │ ├── map18.s │ │ ├── map19.s │ │ ├── map252.s │ │ └── map68.s │ ├── zip │ │ ├── inffast.h │ │ ├── gzclose.c │ │ ├── uncompr.c │ │ ├── compress.c │ │ └── inftrees.h │ ├── NesMachine.h │ ├── romloader_frontend.c │ ├── patch.s │ ├── sound.s │ ├── RP2C02 │ │ ├── RP2C02.h │ │ └── RP2C02.i │ ├── ips.c │ ├── barcode.c │ └── stepdebug.c ├── include │ ├── multi.h │ ├── mess_pal.h │ ├── quor_pal.h │ ├── loopy_pal.h │ ├── 3dsvc_pal.h │ ├── crashman_pal.h │ ├── pasofami_pal.h │ ├── nesvc_pal.h │ ├── asqrealc_pal.h │ ├── chriscovell_pal.h │ ├── firebrandx_pal.h │ ├── mattconte_pal.h │ ├── nesclassic_pal.h │ ├── nespvm_pal.h │ ├── digitalprime_pal.h │ └── menu.h └── data │ ├── font.h │ ├── nespal.h │ ├── fontpal.h │ ├── nespal.c │ └── fontpal.c ├── .gitattributes ├── .gitignore ├── README_ORIGINAL.TXT ├── .github └── workflows │ └── main.yml ├── NOTES.TXT ├── Makefile └── release └── nesDS.ini /README.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/HEAD/README.TXT -------------------------------------------------------------------------------- /icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/HEAD/icon.bmp -------------------------------------------------------------------------------- /make_cia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/HEAD/make_cia -------------------------------------------------------------------------------- /arm7/source/s_apu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DS-Homebrew/NesDS/HEAD/arm7/source/s_apu.c -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "arm9/source/RP2A03"] 2 | path = arm9/source/RP2A03 3 | url = https://github.com/FluBBaOfWard/N2A03.git 4 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/mmc1.i: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .struct mapperData 5 | mmc1Start: 6 | cpuSwitch: .word 0 7 | latch: .byte 0 8 | latchBit: .byte 0 9 | reg0: .byte 0 10 | reg1: .byte 0 11 | reg2: .byte 0 12 | reg3: .byte 0 13 | mmc1padding:.skip 2 14 | mmc1Extra: 15 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/source/mappers/mmc3.i: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .struct mapperData 5 | mmc3Start: 6 | irq_latch: .byte 0 7 | irq_enable: .byte 0 8 | irq_reload: .byte 0 9 | irq_counter: .byte 0 10 | 11 | reg0: .byte 0 12 | reg1: .byte 0 13 | reg2: .byte 0 14 | reg3: .byte 0 15 | 16 | chr01: .byte 0 17 | chr23: .byte 0 18 | chr4: .byte 0 19 | chr5: .byte 0 20 | chr6: .byte 0 21 | chr7: .byte 0 22 | 23 | prg0: .byte 0 24 | prg1: .byte 0 25 | mmc3Extra: 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/mappers/map0.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper0init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | mapper0init: 9 | ;@---------------------------------------------------------------------------- 10 | .word rom_W, rom_W, rom_W, rom_W 11 | 12 | ldr_ r0, romMask 13 | add r0, r0, #1 14 | mov r0, r0, lsr#14 15 | cmp r0, #2 16 | beq m32k 17 | m16k: 18 | stmfd sp!, {lr} 19 | mov r0, #0 20 | bl map89AB_ 21 | ldmfd sp!, {lr} 22 | mov r0, #0 23 | b mapCDEF_ 24 | m32k: 25 | mov r0, #0 26 | b map89ABCDEF_ 27 | -------------------------------------------------------------------------------- /.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 | *.dsi 53 | arm7/build/* 54 | arm9/build/* 55 | -------------------------------------------------------------------------------- /arm9/source/mappers/map1.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc1.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper1init 5 | .global mapper155init 6 | 7 | ;@---------------------------------------------------------------------------- 8 | .section .text,"ax" 9 | ;@---------------------------------------------------------------------------- 10 | mapper1init: 11 | ;@---------------------------------------------------------------------------- 12 | .word mmc1Write0,mmc1Write1,mmc1Write2,mmc1Write3 13 | b mmc1Init 14 | ;@---------------------------------------------------------------------------- 15 | mapper155init: 16 | ;@---------------------------------------------------------------------------- 17 | .word mmc1Write0,mmc1Write1,mmc1Write2,mmc1Write3 18 | stmfd sp!,{lr} 19 | bl mmc1Init 20 | ldr r0,=mmc1ACpuSwitch 21 | str_ r0,cpuSwitch 22 | ldmfd sp!, {pc} 23 | -------------------------------------------------------------------------------- /arm9/source/mappers/map94.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper94init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ HVC-UN1ROM board 9 | ;@ Used in: 10 | ;@ Senjou no Ookami (Japanese version of Commando) 11 | mapper94init: 12 | ;@---------------------------------------------------------------------------- 13 | .word write94,write94,write94,write94 14 | bx lr 15 | ;@---------------------------------------------------------------------------- 16 | write94: 17 | ;@---------------------------------------------------------------------------- 18 | mov r0,r0,lsr#2 19 | b map89AB_ 20 | ;@---------------------------------------------------------------------------- 21 | -------------------------------------------------------------------------------- /arm9/source/mappers/map30.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper30init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ RetroUSB UNROM 512 9 | ;@ Uses 32kB bankable CHR RAM. 10 | mapper30init: 11 | ;@---------------------------------------------------------------------------- 12 | .word mapper30Write,mapper30Write,mapper30Write,mapper30Write 13 | mov r0,#0x8000 14 | sub r0,r0,#1 15 | str_ r0,vmemMask @ vmemMask=vmemSize-1 16 | bx lr 17 | 18 | mapper30Write: 19 | stmfd sp!,{r0,lr} 20 | bl map89AB_ 21 | ldmfd sp,{r0} 22 | mov r0,r0,lsr#5 23 | and r0,r0,#3 24 | bl chr01234567_ ;@ This should use VRAM 25 | ldmfd sp!,{r0,lr} 26 | tst r0,#0x80 27 | b mirror1_ 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/source/mappers/map97.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper97init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Irem TAM-S1 9 | ;@ Used in: 10 | ;@ Kaiketsu Yanchamaru 11 | mapper97init: 12 | ;@---------------------------------------------------------------------------- 13 | .word write97,write97,rom_W,rom_W 14 | 15 | mov r0,#-1 16 | b map89AB_ 17 | ;@---------------------------------------------------------------------------- 18 | write97: 19 | ;@---------------------------------------------------------------------------- 20 | stmfd sp!,{r0,lr} 21 | bl mapCDEF_ 22 | ldmfd sp!,{r0,lr} 23 | tst r0,#0x80 24 | b mirror2V_ 25 | ;@---------------------------------------------------------------------------- 26 | -------------------------------------------------------------------------------- /arm9/source/mappers/map184.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper184init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Sunsoft-1 9 | mapper184init: 10 | ;@---------------------------------------------------------------------------- 11 | .word rom_W,rom_W,rom_W,rom_W 12 | 13 | adr r0,write184 14 | str_ r0,m6502WriteTbl+12 15 | bx lr 16 | ;@---------------------------------------------------------------------------- 17 | write184: 18 | ;@---------------------------------------------------------------------------- 19 | stmfd sp!,{r0,lr} 20 | and r0,r0,#7 21 | bl chr0123_ 22 | ldmfd sp!,{r0,lr} 23 | mov r0,r0,lsr#4 24 | orr r0,r0,#8 25 | b chr4567_ 26 | ;@---------------------------------------------------------------------------- 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map240.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper240init 5 | 6 | .struct mapperData 7 | tmp: .word 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Used in: 12 | ;@ Jing Ke Xin Zhuan 13 | ;@ Sheng Huo Lie Zhuan 14 | mapper240init: 15 | ;@---------------------------------------------------------------------------- 16 | .word rom_W, rom_W, rom_W, rom_W 17 | 18 | adr r1,write0 19 | str_ r1,rp2A03MemWrite 20 | bx lr 21 | 22 | ;@---------------------------------------------------------------------------- 23 | write0: 24 | str_ r0, tmp 25 | stmfd sp!, {r0,lr} 26 | mov r0, r0, lsr#4 27 | bl map89ABCDEF_ 28 | ldmfd sp!, {r0,lr} 29 | b chr01234567_ 30 | ;@---------------------------------------------------------------------------- 31 | -------------------------------------------------------------------------------- /arm9/source/romloader_frontend.c: -------------------------------------------------------------------------------- 1 | #include 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/mappers/map111.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper111init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | mapper111init: 9 | ;@---------------------------------------------------------------------------- 10 | .word rom_W,rom_W,rom_W,rom_W 11 | 12 | adr r0,mapper111write 13 | str_ r0,rp2A03MemWrite 14 | str_ r0,m6502WriteTbl+12 15 | 16 | bx lr 17 | ;@---------------------------------------------------------------------------- 18 | mapper111write: 19 | tst addy,#0x1000 20 | beq rom_W 21 | stmfd sp!,{r0,lr} 22 | bl map89ABCDEF_ 23 | ldmfd sp,{r0} 24 | mov r0,r0,lsr#4 25 | and r0,r0,#1 26 | bl chr01234567_ 27 | ldmfd sp!,{r0,lr} 28 | tst r0,#0x20 29 | b mirror1_ 30 | ;@---------------------------------------------------------------------------- 31 | -------------------------------------------------------------------------------- /arm9/source/mappers/map246.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper246init 5 | 6 | ;@---------------------------------------------------------------------------- 7 | .section .text,"ax" 8 | ;@---------------------------------------------------------------------------- 9 | ;@ Used in Taiwanese game 10 | ;@ 封神榜 (Fēngshénbǎng: Fúmó Sān Tàizǐ). 11 | mapper246init: 12 | ;@---------------------------------------------------------------------------- 13 | .word rom_W, rom_W, rom_W, rom_W 14 | ldr r0, =writel 15 | str_ r0, m6502WriteTbl+12 16 | 17 | bx lr 18 | ;@---------------------------------------------------------------------------- 19 | writel: 20 | ldr r1, =0x6008 21 | cmp addy, r1 22 | bcs sram_W 23 | and r1, addy, #0x7 24 | ldr pc,[pc,r1,lsl#2] 25 | nop 26 | tbl: .word map89_, mapAB_, mapCD_, mapEF_, chr01_, chr23_, chr45_, chr67_ 27 | ;@---------------------------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /arm9/source/mappers/map87.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper87init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Jaleco J87 9 | ;@ Used in: 10 | ;@ Argus (J) 11 | ;@ City Connection (J) 12 | ;@ Ninja Jajamaru Kun 13 | mapper87init: 14 | ;@---------------------------------------------------------------------------- 15 | .word write87,write87,write87,write87 16 | 17 | adr r1,write87 18 | str_ r1,m6502WriteTbl+12 19 | 20 | bx lr 21 | ;@---------------------------------------------------------------------------- 22 | write87: 23 | ;@---------------------------------------------------------------------------- 24 | and r0,r0,#3 25 | movs r0,r0,lsr#1 26 | orrcs r0,r0,#2 27 | b chr01234567_ 28 | ;@---------------------------------------------------------------------------- 29 | -------------------------------------------------------------------------------- /arm9/source/mappers/map93.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper93init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Sunsoft-2 IC, Sunsoft-3R board 9 | ;@ Used in: 10 | ;@ Fantazy Zone (J) 11 | ;@ Shanghai 12 | ;@ Also see mapper 89, 184 13 | mapper93init: 14 | ;@---------------------------------------------------------------------------- 15 | .word write93,write93,write93,write93 16 | 17 | bx lr 18 | ;@---------------------------------------------------------------------------- 19 | write93: 20 | ;@---------------------------------------------------------------------------- 21 | stmfd sp!,{r0,lr} 22 | tst r0,#1 23 | bl mirror2V_ 24 | ldmfd sp!,{r0,lr} 25 | mov r0,r0,lsr#4 26 | b map89AB_ 27 | ;@---------------------------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /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 Ahlström 42 | https://bsky.app/profile/therealflubba.bsky.social 43 | https://www.github.com/FluBBaOfWard 44 | X/Twitter @TheRealFluBBa 45 | 46 | -------------------------------------------------------------------------------- /arm9/source/mappers/map77.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper77init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Irem mapper? 9 | ;@ Used in: 10 | ;@ Napoleon Senki 11 | mapper77init: 12 | ;@---------------------------------------------------------------------------- 13 | .word write0,write0,write0,write0 14 | 15 | mov r0,#0 16 | stmfd sp!, {lr} 17 | bl chr01234567_ 18 | ldmfd sp!, {lr} 19 | mov r0,#0 20 | b map89ABCDEF_ 21 | ;@---------------------------------------------------------------------------- 22 | write0: 23 | ;@---------------------------------------------------------------------------- 24 | stmfd sp!,{r0,lr} 25 | mov r0,r0,lsr#4 26 | bl chr01_ 27 | ldmfd sp!,{r0,lr} 28 | b map89ABCDEF_ 29 | ;@---------------------------------------------------------------------------- 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map78.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper78init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Used in: 9 | ;@ Holy Diver 10 | ;@ Uchuusen - Cosmo Carrier (J) 11 | mapper78init: 12 | ;@---------------------------------------------------------------------------- 13 | .word write78,write78,write78,write78 14 | 15 | bx lr 16 | ;@---------------------------------------------------------------------------- 17 | write78: 18 | ;@---------------------------------------------------------------------------- 19 | stmfd sp!,{r0,lr} 20 | bl map89AB_ 21 | ldmfd sp,{r0} 22 | mov r0,r0,lsr#4 23 | bl chr01234567_ 24 | ldmfd sp!,{r0,lr} 25 | and addy,addy,#0xFE00 26 | cmp addy,#0xFE00 27 | bxeq lr 28 | tst r0,#0x8 29 | b mirror1_ 30 | ;@---------------------------------------------------------------------------- 31 | -------------------------------------------------------------------------------- /arm9/source/mappers/map216.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper216init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Russian mapper (by RCM Group?) 9 | ;@ Used in: 10 | ;@ Bonza 11 | ;@ Videopoker Bonza 12 | ;@ Magic Jewelry II 13 | mapper216init: 14 | ;@---------------------------------------------------------------------------- 15 | .word write, write, write, write 16 | 17 | stmfd sp!, {lr} 18 | mov r0, #0 19 | bl map89ABCDEF_ 20 | ldmfd sp!, {lr} 21 | mov r0, #0 22 | b chr01234567_ 23 | 24 | ;@---------------------------------------------------------------------------- 25 | write: 26 | stmfd sp!, {lr} 27 | mov r0, addy, lsr#1 28 | and r0, r0, #0xE 29 | bl chr01234567_ 30 | ldmfd sp!, {lr} 31 | and r0, addy, #1 32 | b map89ABCDEF_ 33 | ;@---------------------------------------------------------------------------- 34 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/source/mappers/map85.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper85init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Konami VRC7 9 | ;@ Used in: 10 | ;@ Tiny Toon Adventure 2 (J)... 11 | ;@ Lagrange Point, requires CHRRAM swappability =) 12 | mapper85init: 13 | ;@---------------------------------------------------------------------------- 14 | .word write85,write85,write85,write85 15 | b Konami_Init 16 | VRC7: 17 | bx lr 18 | ;@---------------------------------------------------------------------------- 19 | write85: 20 | ;@---------------------------------------------------------------------------- 21 | mov r1,addy,lsr#11 22 | and r1,r1,#0xE 23 | tst addy,#0x18 24 | orrne r1,r1,#1 25 | 26 | ldr pc,[pc,r1,lsl#2] 27 | nop 28 | tbl85: .word map89_,mapAB_,mapCD_,VRC7,chr0_,chr1_,chr2_,chr3_,chr4_,chr5_,chr6_,chr7_,mirrorKonami_,KoLatch,KoIRQEnable,KoIRQack 29 | ;@---------------------------------------------------------------------------- 30 | -------------------------------------------------------------------------------- /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/source/mappers/map118.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc3.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper118init 5 | 6 | ;@---------------------------------------------------------------------------- 7 | .section .text,"ax" 8 | ;@---------------------------------------------------------------------------- 9 | ;@ MMC3 on TKSROM & TLSROM boards 10 | ;@ Used in: 11 | ;@ Armadillo 12 | ;@ Pro Sport Hockey 13 | ;@ Also see mapper 95, 119, 158 & 207 14 | mapper118init: 15 | ;@---------------------------------------------------------------------------- 16 | .word write0, rom_W, mmc3CounterW, mmc3IrqEnableW 17 | b mmc3Init 18 | 19 | ;@---------------------------------------------------------------------------- 20 | write0: ;@ 8000-9FFF 21 | ;@---------------------------------------------------------------------------- 22 | tst addy, #1 23 | beq mmc3Mapping0W 24 | 25 | w8001: 26 | stmfd sp!, {lr} 27 | strb_ r0, reg1 28 | ldrb_ r1, reg0 29 | tst r1, #0x80 30 | and r1, r1, #7 31 | beq 0f 32 | cmp r1, #2 33 | bne 1f 34 | adr lr, 1f 35 | tst r0, #0x80 36 | b mirror1H_ 37 | 0: 38 | cmp r1, #0 39 | bne 1f 40 | tst r0,#0x8 41 | bl mirror1H_ 42 | 1: 43 | ldmfd sp!, {lr} 44 | b mmc3Mapping1W 45 | -------------------------------------------------------------------------------- /arm9/source/mappers/map86.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper86init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Jaleco JF-13 board 9 | ;@ Used in: 10 | ;@ (the Red and Black releases of) Moero!! Pro Yakyuu, the Japanese version of Jaleco's Bases Loaded. 11 | ;@ Urusei Yatsura... 12 | mapper86init: 13 | ;@---------------------------------------------------------------------------- 14 | .word rom_W,rom_W,rom_W,write86 15 | adr r1,write86 16 | str_ r1,m6502WriteTbl+12 17 | mov r0,#0 18 | b map89ABCDEF_ 19 | ;@---------------------------------------------------------------------------- 20 | write86: ;@ 6000-7FFF (& E000-FFFF) 21 | ;@---------------------------------------------------------------------------- 22 | tst addy,#0x1000 23 | bxne lr ;@ 7000-7FFF Handle sound 24 | stmfd sp!,{r0,lr} 25 | mov r0,r0,lsr#4 26 | bl map89ABCDEF_ 27 | ldmfd sp!,{r0,lr} 28 | and r1,r0,#0x40 29 | and r0,r0,#0x03 30 | orr r0,r0,r1,lsr#4 31 | b chr01234567_ 32 | ;@---------------------------------------------------------------------------- 33 | -------------------------------------------------------------------------------- /arm9/source/mappers/map92.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper92init 5 | 6 | .struct mapperData 7 | reg0: .byte 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Jaleco JF-17 board. 12 | ;@ Used in: 13 | ;@ Moero!! Pro Soccer 14 | ;@ Moero!! Pro Yakyuu '88 Kettei Ban... 15 | ;@ Also see mapper 72 16 | mapper92init: 17 | ;@---------------------------------------------------------------------------- 18 | .word write92,write92,write92,write92 19 | mov r0,#0 20 | b map89AB_ 21 | ;@---------------------------------------------------------------------------- 22 | write92: 23 | ;@---------------------------------------------------------------------------- 24 | ldrb_ r1,reg0 25 | strb_ r0,reg0 26 | eor r1,r1,r0 27 | and r1,r1,r0 28 | stmfd sp!,{r0,r1,lr} 29 | // ands r2,r0,#0x30 ;@ Sound bits, 0x20 is reset, 0x10 is select sound with adress bits. 30 | tst r1,#0x80 31 | blne mapCDEF_ 32 | ldmfd sp!,{r0,r1,lr} 33 | tst r1,#0x40 34 | bne chr01234567_ 35 | bx lr 36 | ;@---------------------------------------------------------------------------- 37 | -------------------------------------------------------------------------------- /.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.dsi" --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.dsi nesDS/ 32 | cp nesDS.cia nesDS/ 33 | - name: Publish build to GH Actions 34 | uses: actions/upload-artifact@v4 35 | with: 36 | path: nesDS 37 | name: build 38 | - name: Release 39 | uses: softprops/action-gh-release@v2 40 | if: startsWith(github.ref, 'refs/tags/') 41 | with: 42 | files: | 43 | nesDS/nesDS.nds 44 | nesDS/nesDS.dsi 45 | nesDS/nesDS.cia 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/patch.s: -------------------------------------------------------------------------------- 1 | @--------------------------------------------------------------------------------- 2 | #include "equates.h" 3 | @--------------------------------------------------------------------------------- 4 | .global nespatch 5 | @--------------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | @--------------------------------------------------------------------------------- 8 | nespatch: 9 | @--------------------------------------------------------------------------------- 10 | @patch some games to act smoothly.... 11 | ldr_ r0, prgcrc 12 | 13 | ldr r1, =0x49B3 @TMNT 1 14 | cmp r0, r1 15 | ldreq r2, =362 16 | streq_ r2,cyclesPerScanline 17 | bxeq lr 18 | 19 | ldr r1, =0x33AA @Akumajou Densetsu 20 | cmp r0, r1 21 | ldreq r2, =362 22 | streq_ r2,cyclesPerScanline 23 | bxeq lr 24 | 25 | ldr r1, =0x0A62 @Joe & Mac 26 | cmp r0, r1 27 | ldreq r2, =340 28 | streq_ r2,cyclesPerScanline 29 | bxeq lr 30 | 31 | ldr r1, =0xB2B5 @Three Eyed ONE/Mitsume Ga Tooru 32 | cmp r0, r1 33 | ldreq r2, =360 34 | streq_ r2,cyclesPerScanline 35 | bxeq lr 36 | 37 | ldr r1, =0x8A35 @Feng Shen Bang(Chinese) 38 | cmp r0, r1 39 | ldreq r2, =360 40 | streq_ r2,cyclesPerScanline 41 | bxeq lr 42 | 43 | ldr r1, =0xD796 @Alien Syndrome (J) 44 | cmp r0, r1 45 | ldreqb_ r1,cartFlags 46 | biceq r1, r1, #SCREEN4+VS 47 | streqb_ r1, cartFlags 48 | beq mirror2H_ 49 | 50 | bx lr 51 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map72.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper72init 5 | 6 | .struct mapperData 7 | reg0: .byte 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Jaleco JF-17 board. 12 | ;@ Used in: 13 | ;@ Moero!! Juudou Warroirs... 14 | ;@ Moero!! Pro Tennis 15 | ;@ Pinball Quest 16 | ;@ Also see mapper 92 17 | ;@---------------------------------------------------------------------------- 18 | mapper72init: 19 | ;@---------------------------------------------------------------------------- 20 | .word write72,write72,write72,write72 21 | 22 | bx lr 23 | ;@---------------------------------------------------------------------------- 24 | write72: 25 | ;@---------------------------------------------------------------------------- 26 | ldrb_ r1,reg0 27 | strb_ r0,reg0 28 | eor r1,r1,r0 29 | and r1,r1,r0 30 | stmfd sp!,{r0,r1,lr} 31 | // ands r2,r0,#0x30 ;@ Sound bits, 0x20 is reset, 0x10 is select sound with adress bits. 32 | tst r1,#0x80 33 | blne map89AB_ 34 | ldmfd sp!,{r0,r1,lr} 35 | tst r1,#0x40 36 | bne chr01234567_ 37 | bx lr 38 | ;@---------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map34.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper34init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ BNROM 9 | ;@ Used in: 10 | ;@ Deadly Towers 11 | ;@---------------------------------------------------------------------------- 12 | ;@ NINA-001 13 | ;@ Used in: 14 | ;@ Impossible Mission 2 15 | ;@---------------------------------------------------------------------------- 16 | mapper34init: 17 | ;@---------------------------------------------------------------------------- 18 | .word map89ABCDEF_,map89ABCDEF_,map89ABCDEF_,map89ABCDEF_ ;@ Deadly Towers 19 | 20 | adr r1,write0 21 | str_ r1,m6502WriteTbl+12 22 | 23 | mov r0,#0 24 | b map89ABCDEF_ 25 | ;@---------------------------------------------------------------------------- 26 | write0: ;@ Impossible Mission 2 27 | ;@---------------------------------------------------------------------------- 28 | ldr r1,=0x7fff 29 | cmp addy,r1 ;@ 7FFF 30 | beq chr4567_ 31 | sub r1,r1,#1 32 | cmp addy,r1 ;@ 7FFE 33 | beq chr0123_ 34 | sub r1,r1,#1 35 | cmp addy,r1 ;@ 7FFD 36 | beq map89ABCDEF_ 37 | b sram_W 38 | ;@---------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /arm9/source/mappers/map88.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper88init 5 | 6 | .struct mapperData 7 | cmd: .byte 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Namcot 108 12 | ;@ Quinty (J) 13 | ;@ Namcot Mahjong 3 - Mahjong Tengoku 14 | ;@ Dragon Spirit - Aratanaru Densetsu 15 | ;@ See also mapper 76, 206 16 | mapper88init: 17 | ;@---------------------------------------------------------------------------- 18 | .word write0,rom_W,write1,rom_W 19 | 20 | bx lr 21 | ;@---------------------------------------------------------------------------- 22 | write0: @ $8000-8001 23 | ;@---------------------------------------------------------------------------- 24 | tst addy,#1 25 | streqb_ r0,cmd 26 | bxeq lr 27 | w8001: 28 | ldrb_ r1,cmd 29 | and r1,r1,#7 30 | ldr pc,[pc,r1,lsl#2] 31 | nop 32 | commandList: .word chr01_,chr23_,chr4_,chr5_,chr6_,chr7_,map89_,mapAB_ 33 | ;@---------------------------------------------------------------------------- 34 | write1: ;@ $C000 35 | ;@---------------------------------------------------------------------------- 36 | tst r0,#0 37 | b mirror1_ 38 | ;@---------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /arm9/source/mappers/map32.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper32init 5 | 6 | .struct mapperData 7 | pSwitch: .byte 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Irem G-101 12 | ;@ Used in: 13 | ;@ Image Fight (J) 14 | ;@ Major League 15 | ;@ Kaiketsu Yanchamaru 2 16 | mapper32init: 17 | ;@---------------------------------------------------------------------------- 18 | .word write8000,writeA000,rom_W,rom_W 19 | 20 | bx lr 21 | ;@---------------------------------------------------------------------------- 22 | write8000: 23 | ;@---------------------------------------------------------------------------- 24 | tst addy,#0x1000 25 | bne write9000 26 | ldrb_ r1,pSwitch 27 | tst r1,#0x02 28 | beq map89_ 29 | bne mapCD_ 30 | write9000: 31 | strb_ r0,pSwitch 32 | tst r0,#0x1 33 | b mirror2V_ 34 | ;@---------------------------------------------------------------------------- 35 | writeA000: 36 | ;@---------------------------------------------------------------------------- 37 | tst addy,#0x1000 38 | beq mapAB_ 39 | and addy,addy,#7 40 | ldr r1,=writeCHRTBL 41 | ldr pc,[r1,addy,lsl#2] 42 | ;@---------------------------------------------------------------------------- 43 | -------------------------------------------------------------------------------- /arm9/source/mappers/map76.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper76init 5 | 6 | .struct mapperData 7 | cmd: .byte 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Namcot 108 on NAMCOT-3446 board 12 | ;@ Used in: 13 | ;@ Megami Tensei: Digital Devil Story 14 | ;@ Also see mapper 88, 206 15 | mapper76init: 16 | ;@---------------------------------------------------------------------------- 17 | .word write0,write1,rom_W,rom_W 18 | 19 | bx lr 20 | ;@---------------------------------------------------------------------------- 21 | write0: ;@ $8000-8001 22 | ;@---------------------------------------------------------------------------- 23 | tst addy,#1 24 | streqb_ r0,cmd 25 | bxeq lr 26 | w8001: 27 | ldrb_ r1,cmd 28 | and r1,r1,#7 29 | ldr pc,[pc,r1,lsl#2] 30 | nop 31 | commandList: .word void,void,chr01_,chr23_,chr45_,chr67_,map89_,mapAB_ 32 | ;@---------------------------------------------------------------------------- 33 | write1: ;@ $A000 not used? 34 | ;@---------------------------------------------------------------------------- 35 | tst addy,#1 36 | bxne lr 37 | tst r0,#1 38 | b mirror2V_ 39 | ;@---------------------------------------------------------------------------- 40 | -------------------------------------------------------------------------------- /arm9/source/mappers/map79.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper79init 5 | .global mapper148init 6 | ;@---------------------------------------------------------------------------- 7 | .section .text,"ax" 8 | ;@---------------------------------------------------------------------------- 9 | ;@ American Video Entertainment NINA-03 & NINA-06 10 | ;@ Also see mapper 113 11 | mapper79init: 12 | ;@---------------------------------------------------------------------------- 13 | .word chr01234567_,chr01234567_,chr01234567_,chr01234567_ 14 | 15 | adr r1,write0 16 | str_ r1,rp2A03MemWrite 17 | 18 | mov r0,#0xff 19 | b map89ABCDEF_ 20 | ;@---------------------------------------------------------------------------- 21 | ;@ Sachen SA-008-A and Tengen 800008. 22 | mapper148init: 23 | ;@---------------------------------------------------------------------------- 24 | .word write148,write148,write148,write148 25 | mov r0,#0xff 26 | b map89ABCDEF_ 27 | ;@---------------------------------------------------------------------------- 28 | write0: 29 | ;@---------------------------------------------------------------------------- 30 | and r1,addy,#0xE100 31 | cmp r1,#0x4100 32 | bne empty_W 33 | write148: 34 | stmfd sp!,{r0,lr} 35 | mov r0,r0,lsr#3 36 | bl map89ABCDEF_ 37 | ldmfd sp!,{r0,lr} 38 | b chr01234567_ 39 | ;@---------------------------------------------------------------------------- 40 | -------------------------------------------------------------------------------- /arm9/source/mappers/map99.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper99init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Vs. System 9 | ;@ Used in: 10 | ;@ Vs. Super Mario Bros 11 | ;@ Vs. Ice Climber 12 | mapper99init: 13 | ;@---------------------------------------------------------------------------- 14 | .word rom_W,rom_W,rom_W,rom_W 15 | 16 | ldrb_ r0,cartFlags 17 | orr r0,r0,#VS 18 | strb r0,[r1] 19 | 20 | adr r0,write4016 21 | str_ r0,rp2A03IOWrite 22 | ldr r0,=vsJoy0_R ;@ $4016: controller 1 23 | str_ r0,rp2A03IORead0 24 | ldr r0,=vsJoy1_R ;@ $4017: controller 2 25 | str_ r0,rp2A03IORead1 26 | adr r0,countCoins 27 | str_ r0,rp2A03MemWrite 28 | 29 | bx lr 30 | ;@---------------------------------------------------------------------------- 31 | write4016: 32 | ;@---------------------------------------------------------------------------- 33 | stmfd sp!,{r0,lr} 34 | 35 | mov r0,r0,lsr#2 36 | bl chr01234567_ 37 | 38 | ldmfd sp!,{r0,lr} 39 | b standardJoy_W 40 | ;@---------------------------------------------------------------------------- 41 | countCoins: 42 | ;@---------------------------------------------------------------------------- 43 | bx lr 44 | ;@---------------------------------------------------------------------------- 45 | -------------------------------------------------------------------------------- /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/mappers/map0237.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper2init 5 | .global mapper3init 6 | .global mapper7init 7 | .global mapper180init 8 | 9 | ;@---------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | ;@---------------------------------------------------------------------------- 12 | mapper2init: 13 | ;@---------------------------------------------------------------------------- 14 | .word map89AB_,map89AB_,map89AB_,map89AB_ 15 | bx lr 16 | ;@---------------------------------------------------------------------------- 17 | mapper3init: 18 | ;@---------------------------------------------------------------------------- 19 | .word chr01234567_,chr01234567_,chr01234567_,chr01234567_ 20 | bx lr 21 | ;@---------------------------------------------------------------------------- 22 | mapper7init: 23 | ;@---------------------------------------------------------------------------- 24 | .word write0,write0,write0,write0 25 | bx lr 26 | ;@---------------------------------------------------------------------------- 27 | mapper180init: 28 | ;@---------------------------------------------------------------------------- 29 | .word mapCDEF_,mapCDEF_,mapCDEF_,mapCDEF_ 30 | bx lr 31 | ;@---------------------------------------------------------------------------- 32 | write0: 33 | ;@---------------------------------------------------------------------------- 34 | stmfd sp!,{r0,lr} 35 | tst r0,#0x10 36 | bl mirror1_ 37 | ldmfd sp!,{r0,lr} 38 | b map89ABCDEF_ 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map228.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper228init 5 | 6 | .struct mapperData 7 | mapbyte1: .word 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Action 52 & Cheetahmen 2. PocketNES only support 256k of CHR, Action52 got 512k. 12 | mapper228init: 13 | ;@---------------------------------------------------------------------------- 14 | .word write0,write0,write0,write0 15 | 16 | stmfd sp!, {lr} 17 | mov r0, #0 18 | bl chr01234567_ 19 | 20 | mov r0,#0 21 | bl map89ABCDEF_ 22 | ldmfd sp!, {pc} 23 | ;@---------------------------------------------------------------------------- 24 | write0: 25 | ;@---------------------------------------------------------------------------- 26 | stmfd sp!, {lr} 27 | str_ addy,mapbyte1 28 | and r0,r0,#0x03 29 | orr r0,r0,addy,lsl#2 30 | and r0,r0,#0x3F 31 | 32 | bl chr01234567_ 33 | 34 | ldr_ r0,mapbyte1 35 | tst r0,#0x2000 36 | bl mirror2V_ 37 | 38 | ldr_ r0,mapbyte1 39 | tst r0,#0x1000 40 | bicne r0,r0,#0x800 41 | 42 | tst r0,#0x20 43 | bne swap16k 44 | mov r0,r0,lsr#7 45 | and r0,r0,#0x3f 46 | ldmfd sp!, {lr} 47 | b map89ABCDEF_ 48 | 49 | swap16k: 50 | mov r1,r0,lsr#6 51 | tst r0,#0x40 52 | orrne r1,r1,#1 53 | biceq r1,r1,#1 54 | mov r0,r1,lsl#1 55 | str_ r0,mapbyte1 56 | bl mapCDEF_ 57 | ldmfd sp!, {lr} 58 | ldr_ r0,mapbyte1 59 | b map89AB_ 60 | ;@---------------------------------------------------------------------------- 61 | -------------------------------------------------------------------------------- /arm9/source/mappers/map91.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper91init 5 | 6 | irqEnable = mapperData 7 | ;@---------------------------------------------------------------------------- 8 | .section .text,"ax" 9 | ;@---------------------------------------------------------------------------- 10 | mapper91init: 11 | ;@---------------------------------------------------------------------------- 12 | .word rom_W, rom_W, rom_W, rom_W 13 | 14 | stmfd sp!, {lr} 15 | mov r0, #-1 16 | bl map89AB_ 17 | mov r0, #-1 18 | bl mapCDEF_ 19 | 20 | mov r0, #0 21 | bl chr0_ 22 | mov r0, #0 23 | bl chr1_ 24 | mov r0, #0 25 | bl chr2_ 26 | mov r0, #0 27 | bl chr3_ 28 | mov r0, #0 29 | bl chr4_ 30 | mov r0, #0 31 | bl chr5_ 32 | mov r0, #0 33 | bl chr6_ 34 | mov r0, #0 35 | bl chr7_ 36 | 37 | adr r0, hSync 38 | str_ r0,scanlineHook 39 | 40 | adr r1,writeL 41 | str_ r1,m6502WriteTbl+12 42 | 43 | ldmfd sp!, {pc} 44 | ;@---------------------------------------------------------------------------- 45 | writeL: 46 | ;@---------------------------------------------------------------------------- 47 | cmp addy, #0x7000 48 | bcs addHi 49 | and r1, addy, #3 50 | add r1, r1, r1 51 | b chr2k 52 | 53 | addHi: 54 | ands r2, addy, #3 55 | beq map89_ 56 | cmp r2, #2 57 | bmi mapAB_ 58 | moveq r0,#0 59 | movne r0,#1 60 | strb_ r0,irqEnable 61 | beq rp2A03SetIRQPin 62 | bx lr 63 | 64 | ;@---------------------------------------------------------------------------- 65 | hSync: 66 | ldr_ r0, scanline 67 | cmp r0, #240 68 | bxcs lr 69 | 70 | ands r0, r0, #7 71 | bxne lr 72 | mov r0,#1 73 | b rp2A03SetIRQPin 74 | -------------------------------------------------------------------------------- /arm9/source/mappers/map80.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper80init 5 | 6 | .struct mapperData 7 | patch: .byte 0 8 | ;@---------------------------------------------------------------------------- 9 | .section .text,"ax" 10 | ;@---------------------------------------------------------------------------- 11 | ;@ Taito X1-005 mapper IC 12 | ;@ Used in: 13 | ;@ Kyonshiizu 2 14 | ;@ Minelvaton Saga 15 | ;@ Taito Grand Prix - Eikou heno License 16 | ;@ See also mapper 82, 207 17 | mapper80init: 18 | ;@---------------------------------------------------------------------------- 19 | .word rom_W,rom_W,rom_W,rom_W 20 | 21 | adr r0,write80 22 | str_ r0,m6502WriteTbl+12 23 | ldr_ r0,romMask 24 | tst r0,#0x20000 25 | movne r0,#1 26 | moveq r0,#0 27 | str_ r0,patch 28 | 29 | bx lr 30 | ;@---------------------------------------------------------------------------- 31 | write80: 32 | ;@---------------------------------------------------------------------------- 33 | mov r1,#0x7F0 34 | sub r1,r1,#1 35 | cmp r1,addy,lsr#4 36 | bne handleRAM 37 | 38 | and addy,addy,#0xF 39 | ldr pc,[pc,addy,lsl#2] 40 | nop 41 | write80tbl: .word wF0,wF1,chr4_,chr5_,chr6_,chr7_,wF6,wF6,wF8,wF8,map89_,map89_,mapAB_,mapAB_,mapCD_,mapCD_ 42 | 43 | wF0: 44 | stmfd sp!,{r0,lr} 45 | mov r0,r0,lsr#1 46 | bl chr01_ 47 | ldmfd sp!,{r0,lr} 48 | ldr_ r1,patch 49 | cmp r1,#0 50 | bxeq lr 51 | tst r0,#0x80 52 | b mirror1_ 53 | wF1: 54 | mov r0,r0,lsr#1 55 | b chr23_ 56 | wF6: 57 | ands r0,r0,#1 58 | b mirror2H_ 59 | wF8: 60 | ;@ IRAM permission ($A3 enables reads/writes; any other value disables) 61 | bx lr 62 | 63 | handleRAM: 64 | bxlo lr 65 | @ Write RAM 66 | bx lr 67 | 68 | ;@---------------------------------------------------------------------------- 69 | -------------------------------------------------------------------------------- /arm9/source/mappers/map70152.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper70init 5 | .global mapper152init 6 | ;@---------------------------------------------------------------------------- 7 | .section .text,"ax" 8 | ;@---------------------------------------------------------------------------- 9 | ;@ Bandai mapper 70, no mirroring 10 | ;@ Many of these games use the Family Trainer Mat as an input device. 11 | ;@ Family Trainer - Manhattan Police 12 | ;@ Family Trainer - Meiro Daisakusen 13 | ;@ Kamen Rider Club 14 | ;@ Space Shadow 15 | mapper70init: 16 | ;@---------------------------------------------------------------------------- 17 | .word write70,write70,write70,write70 18 | bx lr 19 | ;@---------------------------------------------------------------------------- 20 | ;@ Bandai mapper 152, mirroring 21 | ;@ Arkanoid 2 (J) 22 | ;@ Gegege no Kitarou 2 23 | ;@ Saint Seiya .. 24 | mapper152init: 25 | ;@---------------------------------------------------------------------------- 26 | .word write152,write152,write152,write152 27 | 28 | movs r0,#1 29 | b mirror1_ 30 | ;@---------------------------------------------------------------------------- 31 | write70: 32 | ;@---------------------------------------------------------------------------- 33 | stmfd sp!,{r0,lr} 34 | bl chr01234567_ 35 | ldmfd sp!,{r0,lr} 36 | mov r0,r0,lsr#4 37 | b map89AB_ 38 | ;@---------------------------------------------------------------------------- 39 | write152: 40 | ;@---------------------------------------------------------------------------- 41 | mov addy,r0,lsr#4 42 | stmfd sp!,{addy,lr} 43 | bl chr01234567_ 44 | tst addy,#0x8 45 | bl mirror1_ 46 | ldmfd sp!,{r0,lr} 47 | b map89AB_ 48 | ;@---------------------------------------------------------------------------- 49 | -------------------------------------------------------------------------------- /arm9/source/mappers/map40.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper40init 5 | 6 | .struct mapperData 7 | countdown: .word 0 8 | irqEn: .byte 0 9 | ;@---------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | ;@---------------------------------------------------------------------------- 12 | mapper40init: ;@ SMB2j 13 | ;@---------------------------------------------------------------------------- 14 | .word write0,write1,rom_W,mapCD_ 15 | 16 | stmfd sp!, {lr} 17 | adr r0,hook 18 | str_ r0,scanlineHook 19 | 20 | ldr r0,=empty_W ;@ Set ROM at $6000-$7FFF. 21 | str_ r0,m6502WriteTbl+12 22 | 23 | bl write0 24 | 25 | mov r0,#-1 26 | bl map89ABCDEF_ 27 | 28 | ldmfd sp!, {lr} 29 | mov r0,#6 30 | b map67_ 31 | ;@---------------------------------------------------------------------------- 32 | write0: ;@ $8000-$9FFF 33 | ;@---------------------------------------------------------------------------- 34 | mov r0,#36 35 | str_ r0,countdown 36 | mov r0,#0 37 | strb_ r0,irqEn 38 | b rp2A03SetIRQPin 39 | ;@---------------------------------------------------------------------------- 40 | write1: ;@ $A000-$BFFF 41 | ;@---------------------------------------------------------------------------- 42 | mov r0,#1 43 | strb_ r0,irqEn 44 | bx lr 45 | ;@---------------------------------------------------------------------------- 46 | hook: 47 | ;@---------------------------------------------------------------------------- 48 | ldrb_ r0,irqEn 49 | cmp r0,#0 50 | bxeq lr 51 | 52 | ldr_ r0,countdown 53 | subs r0,r0,#1 54 | str_ r0,countdown 55 | bxcs lr 56 | 57 | mov r0,#0 58 | strb_ r0,irqEn 59 | mov r0,#1 60 | b rp2A03SetIRQPin 61 | ;@---------------------------------------------------------------------------- 62 | -------------------------------------------------------------------------------- /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 | /** NTSC RGB revision */ 13 | REV_RP2C03 = 0x01, 14 | /** NTSC RGB revision */ 15 | REV_RP2C04 = 0x02, 16 | /** NTSC RGB revision */ 17 | REV_RP2C05 = 0x03, 18 | /** PAL revision */ 19 | REV_RP2C07 = 0x10, 20 | /** UMC UA6528P, Argentina Famiclone */ 21 | REV_UA6528P = 0x23, 22 | /** UMC UA6538, aka Dendy */ 23 | REV_UA6538 = 0x24, 24 | /** UMC UA6548, Brazil Famiclone */ 25 | REV_UA6548 = 0x25, 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 | 49 | u8 ppuCtrl0; 50 | u8 ppuCtrl1; 51 | u8 ppuStat; 52 | u8 ppuOamAdr; 53 | 54 | u8 ppuCtrl0Frame; 55 | u8 readTemp; 56 | u8 rp2C02Revision; 57 | u8 unusedAlign[1]; 58 | 59 | u32 loopy_t; 60 | u32 loopy_x; 61 | u32 loopy_y; 62 | u32 loopy_v; 63 | 64 | u32 vmemMask; 65 | u32 vmemBase; 66 | u32 palSyncLine; 67 | 68 | u32 pixStart; 69 | u32 pixEnd; 70 | u32 unused; 71 | 72 | u16 nesChrMap[8]; 73 | u32 ppuOAMMem[64]; 74 | u8 paletteMem[32]; 75 | 76 | void (*ppuIrqFunc)(bool); 77 | void (*newFrameHook)(void); 78 | void (*endFrameHook)(void); 79 | void (*scanlineHook)(void); 80 | void (*ppuChrLatch)(int tileNr); 81 | u8 unusedAlign2[8]; 82 | } RP2C02; 83 | 84 | void PPU_init(void); 85 | void EMU_VBlank(void); 86 | void paletteinit(void); 87 | void PaletteTxAll(void); 88 | void rescale_nr(u32 scale, u32 start); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif // NESPPU_HEADER 95 | -------------------------------------------------------------------------------- /arm9/source/mappers/map82.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper82init 5 | ;@---------------------------------------------------------------------------- 6 | .section .text,"ax" 7 | ;@---------------------------------------------------------------------------- 8 | ;@ Taito X1-017 mapper IC 9 | ;@ Known games: 10 | ;@ SD Keiji: Blader (SD刑事ブレイダー) 11 | ;@ Kyuukyoku Harikiri Stadium 1989 Edition (究極ハリキリスタジアム平成元年版) 12 | ;@ Kyuukyoku Harikiri Stadium III (究極ハリキリスタジアムIII) 13 | ;@ Kyuukyoku Harikiri Koushien (究極ハリキリ甲子園) 14 | ;@ See also mapper 80 15 | ;@---------------------------------------------------------------------------- 16 | mapper82init: 17 | ;@---------------------------------------------------------------------------- 18 | .word rom_W,rom_W,rom_W,rom_W 19 | 20 | adr r1,write0 21 | str_ r1,m6502WriteTbl+12 22 | bx lr 23 | ;@---------------------------------------------------------------------------- 24 | write0: ;@ $6000-7FFF 25 | ;@---------------------------------------------------------------------------- 26 | mov r1,#0x7F0 27 | sub r1,r1,#1 28 | cmp r1,addy,lsr#4 29 | bne handleRAM 30 | 31 | and addy,addy,#0xF 32 | ldr pc,[pc,addy,lsl#2] 33 | nop 34 | write80tbl: .word wF0,wF1,chr4_,chr5_,chr6_,chr7_,wF6,wF7,wF8,wF9,map89_,mapAB_,mapCD_,irqLatch,irqCtrl,irqReload 35 | 36 | handleRAM: 37 | bxhi lr 38 | @ Write RAM 39 | bx lr 40 | 41 | wF0: 42 | mov r0,r0,lsr#1 43 | b chr01_ 44 | wF1: 45 | mov r0,r0,lsr#1 46 | b chr23_ 47 | wF6: 48 | ands r0,r0,#1 49 | b mirror2H_ 50 | 51 | wF7: @ Write $CA to enable RAM from $6000 to $67FF, write anything else to disable 52 | wF8: @ Write $69 to enable RAM from $6800 to $6FFF, write anything else to disable 53 | wF9: @ Write $84 to enable RAM from $7000 to $73FF, write anything else to disable 54 | irqLatch: 55 | irqCtrl: 56 | irqReload: 57 | bx lr 58 | ;@---------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /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_RP2C03, 0x01 ;@ NTSC RGB revision 10 | .equ REV_RP2C04, 0x02 ;@ NTSC RGB revision 11 | .equ REV_RP2C05, 0x03 ;@ NTSC RGB revision 12 | .equ REV_RP2C07, 0x10 ;@ PAL revision 13 | .equ REV_UA6528P, 0x23 ;@ UMC UA6528P, Argentina Famiclone 14 | .equ REV_UA6538, 0x24 ;@ UMC UA6538, aka Dendy 15 | .equ REV_UA6548, 0x25 ;@ 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 | 41 | ppuCtrl0: .byte 0 ;@ These 4 need to be together 42 | ppuCtrl1: .byte 0 43 | ppuStat: .byte 0 44 | ppuOamAdr: .byte 0 45 | 46 | ppuCtrl0Frame: .byte 0 47 | readTemp: .byte 0 48 | rp2C02Revision: .byte 0 49 | unusedAlign: .skip 1 50 | 51 | loopy_t: .long 0 52 | loopy_x: .long 0 53 | loopy_y: .long 0 54 | loopy_v: .long 0 55 | 56 | vmemMask: .long 0 57 | vmemBase: .long 0 58 | palSyncLine: .long 0 59 | 60 | pixStart: .long 0 61 | pixEnd: .long 0 62 | unused: .long 0 63 | 64 | nesChrMap: .space 8*2 65 | ppuOAMMem: .space 64*4 66 | paletteMem: .space 32 ;@ NES $3F00-$3F1F 67 | 68 | ppuIrqFunc: .long 0 69 | newFrameHook: .long 0 70 | endFrameHook: .long 0 71 | scanlineHook: .long 0 72 | ppuChrLatch: .long 0 73 | unusedAlign2: .skip 8 74 | rp2C02End: 75 | 76 | rp2C02Size = rp2C02End-rp2C02Start 77 | 78 | ;@---------------------------------------------------------------------------- 79 | -------------------------------------------------------------------------------- /arm9/source/mappers/map17.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper17init 5 | 6 | .struct mapperData 7 | counter: .word 0 8 | enable: .byte 0 9 | ;@---------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | ;@---------------------------------------------------------------------------- 12 | ;@ Front Fareast Super Magic Card 13 | mapper17init: 14 | ;@---------------------------------------------------------------------------- 15 | .word rom_W,rom_W,rom_W,rom_W 16 | 17 | adr r1,write0 18 | str_ r1,rp2A03MemWrite 19 | 20 | adr r0,hook 21 | str_ r0,scanlineHook 22 | 23 | bx lr 24 | ;@---------------------------------------------------------------------------- 25 | write0: 26 | ;@---------------------------------------------------------------------------- 27 | cmp addy,#0x4100 28 | blo empty_W 29 | 30 | and r2,addy,#0xff 31 | cmp r2,#0xfe 32 | beq _fe 33 | cmp r2,#0xff 34 | beq _ff 35 | 36 | and r2,r2,#0x17 37 | tst r2,#0x10 38 | subne r2,r2,#8 39 | 40 | ldr pc,[pc,r2,lsl#2] 41 | nop 42 | jmptbl: .word void,_1,_2,_3,map89_,mapAB_,mapCD_,mapEF_ 43 | .word chr0_,chr1_,chr2_,chr3_,chr4_,chr5_,chr6_,chr7_ 44 | 45 | _fe: 46 | tst r0,#0x10 47 | b mirror1_ 48 | _ff: 49 | tst r0,#0x10 50 | b mirror2V_ 51 | _1: 52 | mov r0,#0 53 | strb_ r0,enable 54 | b rp2A03SetIRQPin 55 | _2: 56 | strb_ r0,counter+2 57 | mov r0,#0 58 | b rp2A03SetIRQPin 59 | _3: 60 | strb_ r0,counter+3 61 | mov r1,#1 62 | strb_ r1,enable 63 | mov r0,#0 64 | b rp2A03SetIRQPin 65 | ;@---------------------------------------------------------------------------- 66 | hook: 67 | ;@---------------------------------------------------------------------------- 68 | ldrb_ r0,enable 69 | cmp r0,#0 70 | bxeq lr 71 | 72 | ldr_ r0,counter 73 | adds r0,r0,#0x10000 74 | str_ r0,counter 75 | bxcc lr 76 | mov r0,#1 77 | b rp2A03SetIRQPin 78 | ;@---------------------------------------------------------------------------- 79 | -------------------------------------------------------------------------------- /arm9/source/mappers/map22.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper22init 5 | 6 | .struct mapperData 7 | .skip 4 8 | chrXX: .space 8 9 | ;@---------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | ;@---------------------------------------------------------------------------- 12 | ;@ Konami VRC2a 13 | ;@ Used in: 14 | ;@ Ganbare Penant Race 15 | ;@ Twin Bee 3 16 | ;@ Also see mapper 21, 23 & 25 17 | mapper22init: 18 | ;@---------------------------------------------------------------------------- 19 | .word write8000,writeA000,writeC000,writeE000 20 | 21 | bx lr 22 | ;@---------------------------------------------------------------------------- 23 | write8000: 24 | ;@---------------------------------------------------------------------------- 25 | tst addy,#0x1000 26 | beq map89_ 27 | write9000: 28 | bne mirrorKonami_ 29 | 30 | ;@---------------------------------------------------------------------------- 31 | writeA000: 32 | ;@---------------------------------------------------------------------------- 33 | tst addy,#0x1000 34 | beq mapAB_ 35 | ;@---------------------------------------------------------------------------- 36 | writeC000: @addy=B/C/D/Exxx 37 | ;@---------------------------------------------------------------------------- 38 | sub addy,addy,#0xB000 39 | mov r1,addy,lsr#11 40 | tst addy,#1 41 | orrne r1,r1,#1 42 | tst addy,#2 43 | 44 | adrl_ addy,chrXX 45 | and r0,r0,#0xF 46 | ldrb r2,[addy,r1] 47 | 48 | andeq r2,r2,#0x78 49 | orreq r0,r2,r0,lsr#1 50 | andne r2,r2,#0x7 51 | orrne r0,r2,r0,lsl#3 52 | strb r0,[addy,r1] 53 | 54 | ldr addy,=writeCHRTBL 55 | ldr pc,[addy,r1,lsl#2] 56 | ;@---------------------------------------------------------------------------- 57 | writeE000: 58 | ;@---------------------------------------------------------------------------- 59 | cmp addy,#0xf000 60 | bmi writeC000 61 | bx lr 62 | ;@---------------------------------------------------------------------------- 63 | -------------------------------------------------------------------------------- /arm9/source/mappers/map4.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc3.i" 3 | #define MMC3_IRQ_KLAX 1 4 | #define MMC3_IRQ_SHOUGIMEIKAN 2 5 | #define MMC3_IRQ_DAI2JISUPER 3 6 | #define MMC3_IRQ_DBZ2 4 7 | #define MMC3_IRQ_ROCKMAN3 5 8 | ;@---------------------------------------------------------------------------- 9 | .global mapper4init 10 | 11 | .struct mmc3Extra 12 | vs_patch: .byte 0 13 | vs_index: .byte 0 14 | irq_type: .byte 0 15 | 16 | ;@---------------------------------------------------------------------------- 17 | .section .text,"ax" 18 | ;@---------------------------------------------------------------------------- 19 | ;@ MMC3 & MMC6 20 | mapper4init: 21 | ;@---------------------------------------------------------------------------- 22 | .word mmc3MappingW, mmc3MirrorW, mmc3CounterW, mmc3IrqEnableW 23 | 24 | adr r0, writel 25 | str_ r0, rp2A03MemWrite 26 | adr r0, readl 27 | str_ r0, rp2A03MemRead 28 | 29 | b mmc3Init 30 | 31 | @patch for games... 32 | @ldrb_ r0, irq_type 33 | @cmp r0, #MMC3_IRQ_KLAX 34 | @ldreq r2,=hSyncRAMBO1 35 | @cmp r0, #MMC3_IRQ_ROCKMAN3 36 | @ldreq r2,=hSyncRockman3 37 | @cmp r2, #MMC3_IRQ_DAI2JISUPER 38 | @ldreq r2,=mmc3HSync___ 39 | @str_ r2,scanlineHook 40 | 41 | @ldr_ r0,prgCrc 42 | @ldr r1, =0x5807 @Tenchi o Kurau 2 - Akakabe no Tatakai Chinese Edtion. 43 | @cmp r1, r0 44 | @ldreq_ r2, emuFlags 45 | @orreq r2, r2, #PALTIMING 46 | @streq_ r2, emuFlags 47 | 48 | @bx lr 49 | 50 | ;@---------------------------------------------------------------------------- 51 | writel: ;@ ($4020-$5FFF) 52 | ;@---------------------------------------------------------------------------- 53 | cmp addy, #0x5000 54 | bcc empty_W 55 | sub r2, addy, #0x4000 56 | ldr r1, =NES_XRAM 57 | strb r0, [r1, r2] 58 | bx lr 59 | 60 | ;@---------------------------------------------------------------------------- 61 | readl: ;@ ($4020-$5FFF) 62 | ;@---------------------------------------------------------------------------- 63 | cmp addy, #0x5000 64 | bcc empty_R 65 | sub r2, addy, #0x4000 66 | ldr r1, =NES_XRAM 67 | ldrb r0, [r1, r2] 68 | bx lr 69 | -------------------------------------------------------------------------------- /arm9/source/mappers/map245.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc3.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper245init 5 | 6 | ;@---------------------------------------------------------------------------- 7 | .section .text,"ax" 8 | ;@---------------------------------------------------------------------------- 9 | ;@ Waixing F003 board with MMC3 clone 10 | ;@ Used in: 11 | ;@ 勇者斗恶龙 VII - Dragon Quest (Yǒngzhě dòu è lóng VII - Dragon Quest), 12 | mapper245init: 13 | ;@---------------------------------------------------------------------------- 14 | .word write0, write1, rom_W, rom_W 15 | mov r0, #0 16 | str_ r0, reg0 17 | 18 | mov r0, #0x0 19 | strb_ r0, prg0 @prg0 = 0; prg1 = 1 20 | mov r0, #1 21 | strb_ r0, prg1 22 | 23 | mov r0, #0 24 | str_ r0, irq_enable 25 | 26 | bx lr 27 | 28 | ;@---------------------------------------------------------------------------- 29 | write0: ;@ 8000-9FFF 30 | ;@---------------------------------------------------------------------------- 31 | tst addy, #1 32 | bne w8001 33 | 34 | strb_ r0, reg0 35 | bx lr 36 | 37 | w8001: 38 | stmfd sp!, {lr} 39 | strb_ r0, reg1 40 | ldrb_ r1, reg0 41 | cmp r1, #0 42 | bne 6f 43 | 44 | ands r2, r0, #2 45 | movne r2, #(2 << 5) 46 | strb_ r2, reg3 47 | orr r0, r2, #0x3E 48 | bl mapCD_ 49 | ldrb_ r0, reg3 50 | orr r0, r0, #0x3F 51 | bl mapEF_ 52 | b 0f 53 | 6: 54 | cmp r1, #6 55 | bne 7f 56 | strb_ r0, prg0 57 | b 0f 58 | 7: 59 | cmp r1, #7 60 | bne 0f 61 | strb_ r0, prg1 62 | 0: 63 | ldrb_ r0, prg0 64 | ldrb_ r1, reg3 65 | orr r0, r0, r1 66 | bl map89_ 67 | ldrb_ r0, prg1 68 | ldrb_ r1, reg3 69 | orr r0, r0, r1 70 | ldmfd sp!, {lr} 71 | b mapAB_ 72 | 73 | ;@---------------------------------------------------------------------------- 74 | write1: ;@ A000-BFFF 75 | ;@---------------------------------------------------------------------------- 76 | tst addy, #1 77 | bne wa001 78 | 79 | strb_ r0, reg2 80 | ldrb_ r1, cartFlags 81 | tst r1, #SCREEN4 82 | bxne lr 83 | tst r0, #1 84 | b mirror2V_ 85 | 86 | wa001: 87 | bx lr 88 | -------------------------------------------------------------------------------- /arm9/source/mappers/map71_232.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper71init 5 | .global mapper232init 6 | 7 | .struct mapperData 8 | mapbyte1: .byte 0 9 | mapbyte2: .byte 0 10 | ;@---------------------------------------------------------------------------- 11 | .section .text,"ax" 12 | ;@---------------------------------------------------------------------------- 13 | ;@ Camerica/Codemasters mapper 14 | ;@ Used in: 15 | ;@ MiG 29 - Soviet Fighter 16 | ;@ Fire Hawk 17 | ;@ The Fantastic Adventures of Dizzy 18 | ;@ Bee 52 19 | mapper71init: 20 | ;@---------------------------------------------------------------------------- 21 | .word map71w,rom_W,map89AB_,map89AB_ 22 | bx lr 23 | ;@---------------------------------------------------------------------------- 24 | ;@ Camerica/Codemasters mapper 25 | ;@ Used in: 26 | ;@ Quattro Adventure 27 | ;@ Quattro Sports 28 | ;@ Quattro Arcade 29 | mapper232init: 30 | ;@---------------------------------------------------------------------------- 31 | .word write0,write0,write1,write1 32 | mov r0,#0x18 33 | strb_ r0,mapbyte1 34 | bx lr 35 | ;@---------------------------------------------------------------------------- 36 | map71w: 37 | tst addy,#0x1000 38 | bxeq lr 39 | tst r0,#0x10 40 | b mirror1_ 41 | ;@---------------------------------------------------------------------------- 42 | write0: 43 | ;@---------------------------------------------------------------------------- 44 | and r0,r0,#0x18 45 | strb_ r0,mapbyte1 46 | b prgMap 47 | ;@---------------------------------------------------------------------------- 48 | write1: 49 | ;@---------------------------------------------------------------------------- 50 | and r0,r0,#0x03 51 | strb_ r0,mapbyte2 52 | ldrb_ r0,mapbyte1 53 | prgMap: 54 | stmfd sp!, {lr} 55 | mov r1,#3 56 | orr r0,r1,r0,lsr#1 57 | bl mapCDEF_ 58 | 59 | ldrb_ r0,mapbyte1 60 | ldrb_ r1,mapbyte2 61 | orr r0,r1,r0,lsr#1 62 | ldmfd sp!, {lr} 63 | b map89AB_ 64 | ;@---------------------------------------------------------------------------- 65 | -------------------------------------------------------------------------------- /arm9/source/mappers/map1166.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper11init 5 | .global mapper66init 6 | .global mapper140init 7 | ;@---------------------------------------------------------------------------- 8 | .section .text,"ax" 9 | ;@---------------------------------------------------------------------------- 10 | ;@ Color Dreams 11 | mapper11init: 12 | ;@---------------------------------------------------------------------------- 13 | .word write11,write11,write11,write11 14 | bx lr 15 | ;@---------------------------------------------------------------------------- 16 | ;@ NES-GNROM & NES-MHROM 17 | ;@ Used in: 18 | ;@ Gumshoe 19 | ;@ Super Mario Bros. + Duck Hunt 20 | mapper66init: 21 | ;@---------------------------------------------------------------------------- 22 | .word write66,write66,write66,write66 23 | 24 | ldrb_ r0,cartFlags 25 | orr r0,r0,#MIRROR 26 | strb_ r0,cartFlags 27 | 28 | bx lr 29 | ;@---------------------------------------------------------------------------- 30 | ;@ Jaleco JF-11 & JF-14 31 | ;@ Used in: 32 | ;@ Bio Senshi Dan - Increaser Tono Tatakai 33 | mapper140init: 34 | ;@---------------------------------------------------------------------------- 35 | .word rom_W,rom_W,rom_W,rom_W 36 | 37 | adr r1,write66 38 | str_ r1,m6502WriteTbl+12 39 | 40 | ldrb_ r0,cartFlags 41 | orr r0,r0,#MIRROR 42 | strb_ r0,cartFlags 43 | 44 | bx lr 45 | ;@---------------------------------------------------------------------------- 46 | write11: 47 | ;@---------------------------------------------------------------------------- 48 | stmfd sp!,{r0,lr} 49 | bl map89ABCDEF_ 50 | ldmfd sp!,{r0,lr} 51 | mov r0,r0,lsr#4 52 | b chr01234567_ 53 | ;@---------------------------------------------------------------------------- 54 | write66: 55 | ;@---------------------------------------------------------------------------- 56 | stmfd sp!,{r0,lr} 57 | bl chr01234567_ 58 | ldmfd sp!,{r0,lr} 59 | mov r0,r0,lsr#4 60 | b map89ABCDEF_ 61 | ;@---------------------------------------------------------------------------- 62 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/konami.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global Konami_Init 5 | .global Konami_IRQ_Hook 6 | .global KoLatch 7 | .global KoLatchLo 8 | .global KoLatchHi 9 | .global KoIRQEnable 10 | .global KoIRQack 11 | 12 | .struct mapperData 13 | latch: .byte 0 14 | irqEn: .byte 0 15 | k4Irq: .byte 0 16 | counter: .byte 0 17 | ;@---------------------------------------------------------------------------- 18 | .section .text,"ax" 19 | ;@---------------------------------------------------------------------------- 20 | Konami_Init: 21 | adr r0,Konami_IRQ_Hook 22 | str_ r0,scanlineHook 23 | bx lr 24 | ;@---------------------------------------------------------------------------- 25 | KoLatch: @- - - - - - - - - - - - - - - 26 | strb_ r0,latch 27 | bx lr 28 | KoLatchLo: @- - - - - - - - - - - - - - - 29 | ldrb_ r1,latch 30 | and r1,r1,#0xf0 31 | and r0,r0,#0x0f 32 | orr r0,r1,r0 33 | strb_ r0,latch 34 | bx lr 35 | KoLatchHi: @- - - - - - - - - - - - - - - 36 | ldrb_ r1,latch 37 | and r1,r1,#0x0f 38 | orr r0,r1,r0,lsl#4 39 | strb_ r0,latch 40 | bx lr 41 | KoIRQEnable: @- - - - - - - - - - - - - - - 42 | strb_ r0,irqEn 43 | tst r0,#2 ;@ Timer Enable 44 | ldrneb_ r0,latch 45 | strneb_ r0,counter 46 | mov r0, #0 47 | b rp2A03SetIRQPin 48 | KoIRQack: @- - - - - - - - - - - - - - - 49 | ldrb_ r0,irqEn 50 | bic r0,r0,#2 ;@ Disable Timer 51 | orr r0,r0,r0,lsl#1 ;@ Move repeat bit to Enable bit 52 | strb_ r0,irqEn 53 | mov r0, #0 54 | b rp2A03SetIRQPin 55 | ;@---------------------------------------------------------------------------- 56 | Konami_IRQ_Hook: 57 | ;@---------------------------------------------------------------------------- 58 | ldr_ r0,latch 59 | tst r0,#0x200 ;@ Timer active? 60 | bxeq lr 61 | 62 | mov r1,#1 63 | tst r0,#0x400 ;@ Cycle Mode? 64 | movne r1,#114 ;@ 114 cpu cycles per scanline 65 | adds r0,r0,r1,lsl#24 ;@ Counter++ 66 | bcc h0 67 | 68 | strb_ r0,counter ;@ Copy latch to counter 69 | mov r0,#1 70 | b rp2A03SetIRQPin 71 | h0: 72 | str_ r0,latch 73 | bx lr 74 | ;@---------------------------------------------------------------------------- 75 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map42.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | 4 | .global mapper42init 5 | 6 | .struct mapperData 7 | counter: .word 0 8 | irqEn: .byte 0 9 | ;@---------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | ;@---------------------------------------------------------------------------- 12 | ;@ FDS cart conversions 13 | ;@ Ai Senshi Nicol 14 | ;@ "Mario Baby" (really Bio Miracle Bokutte Upa) 15 | mapper42init: 16 | ;@---------------------------------------------------------------------------- 17 | .word chr01234567_,rom_W,rom_W,write3 18 | stmfd sp!, {lr} 19 | 20 | ldr r1,=mem_R60 ;@ Swap in ROM at $6000-$7FFF. 21 | str_ r1,m6502ReadTbl+12 22 | ldr r1,=empty_W ;@ ROM. 23 | str_ r1,m6502WriteTbl+12 24 | 25 | mov r0,#-1 26 | bl map89ABCDEF_ 27 | 28 | adr r0,map42IrqHook 29 | str_ r0,scanlineHook 30 | 31 | ldmfd sp!, {lr} 32 | mov r0,#0 33 | b map67_ 34 | 35 | ;@---------------------------------------------------------------------------- 36 | write0: ;@ 8000 37 | ;@---------------------------------------------------------------------------- 38 | bx lr 39 | b chr01234567_ 40 | ;@---------------------------------------------------------------------------- 41 | write3: ;@ E000-E003 42 | ;@---------------------------------------------------------------------------- 43 | and r1,addy,#3 44 | ldr pc,[pc,r1,lsl#2] 45 | nothing: 46 | bx lr 47 | ;@---------------------------------------------------------------------------- 48 | commandList: .word map67_,cmd1,cmd2,nothing 49 | cmd1: 50 | tst r0,#0x08 51 | b mirror2V_ 52 | cmd2: 53 | ands r0,r0,#2 54 | strb_ r0,irqEn 55 | streq_ r0,counter 56 | beq rp2A03SetIRQPin 57 | bx lr 58 | ;@---------------------------------------------------------------------------- 59 | map42IrqHook: 60 | ;@---------------------------------------------------------------------------- 61 | ldrb_ r0,irqEn 62 | cmp r0,#0 63 | bxeq lr 64 | ldr_ r1,counter 65 | add r0,r1,#113<<17 66 | str_ r0,counter 67 | eor r1,r1,r0 68 | movs r1,r1,lsr#30 69 | bxeq lr ;@ No change 70 | mvns r0,r0,asr#30 71 | moveq r0,#1 72 | movne r0,#0 73 | b rp2A03SetIRQPin 74 | ;@---------------------------------------------------------------------------- 75 | -------------------------------------------------------------------------------- /arm9/source/mappers/map47.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc3.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper47init 5 | 6 | .struct mmc3Extra 7 | bank_select: .byte 0 8 | 9 | ;@---------------------------------------------------------------------------- 10 | .section .text,"ax" 11 | ;@---------------------------------------------------------------------------- 12 | ;@ Yet another MMC3 multicart. 13 | ;@ Used in: 14 | ;@ Super Spike V'Ball + Nintendo World Cup 15 | mapper47init: 16 | ;@---------------------------------------------------------------------------- 17 | .word write0, mmc3MirrorW, mmc3CounterW, mmc3IrqEnableW 18 | stmfd sp!, {lr} 19 | 20 | mov r0,#0x8 21 | str_ r0,prgSize16k 22 | mov r0, r0, lsl#1 23 | str_ r0,prgSize8k 24 | 25 | bl mmc3Init 26 | 27 | adr r0, writel 28 | str_ r0, m6502WriteTbl+12 29 | 30 | ldmfd sp!, {lr} 31 | bx lr 32 | 33 | ;@---------------------------------------------------------------------------- 34 | writel: @($6000-$7FFF) 35 | ;@---------------------------------------------------------------------------- 36 | ;@ Check for WRAM enable (A001) 37 | ldrb_ r1,reg3 38 | and r1,r1,#0xC0 39 | cmp r1,#0x80 ;@ Enabled and not write protected 40 | bxne lr 41 | 42 | ands r0,r0,#1 43 | strb_ r0,bank_select 44 | moveq r1,#0x8 45 | movne r1,#0x10 46 | str_ r1,prgSize16k 47 | mov r1, r1, lsl#1 48 | str_ r1,prgSize8k 49 | 50 | ldrb_ r1,prg0 51 | and r1,r1,#0xF 52 | orr r1,r1,r0,lsl#4 53 | strb_ r1,prg0 54 | 55 | ldrb_ r1,prg1 56 | and r1,r1,#0xF 57 | orr r1,r1,r0,lsl#4 58 | strb_ r1,prg1 59 | 60 | ldrb_ r0,reg0 61 | b mmc3Mapping0W 62 | 63 | ;@---------------------------------------------------------------------------- 64 | write0: 65 | ;@---------------------------------------------------------------------------- 66 | tst addy, #1 67 | beq mmc3Mapping0W 68 | 69 | w8001: 70 | ldrb_ r1, reg0 71 | and r1, r1, #6 72 | cmp r1, #6 ;@ PRG or CHR? 73 | ldrb_ r1,bank_select 74 | andeq r0,r0,#0xF ;@ PRG, one bank is 128Kb 75 | orreq r0,r0,r1,lsl#4 76 | andne r0,r0,#0x7F ;@ CHR, one bank is 128Kb 77 | orrne r0,r0,r1,lsl#7 78 | b mmc3Mapping1W 79 | ;@---------------------------------------------------------------------------- 80 | -------------------------------------------------------------------------------- /arm9/source/mappers/map159.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper159init 5 | 6 | .struct mapperData 7 | counter: .word 0 8 | latch: .word 0 9 | enable: .byte 0 10 | ;@---------------------------------------------------------------------------- 11 | .section .text,"ax" 12 | ;@---------------------------------------------------------------------------- 13 | ;@ Bandai FCG boards with an LZ93D50 and a 128-byte serial EEPROM (X24C01). 14 | ;@ Used in: 15 | ;@ Dragon Ball Z: Kyoushuu! Saiya-jin 16 | ;@ Magical Taruruuto-kun: Fantastic World!! 17 | ;@ Magical Taruruuto-kun 2: Mahou Daibouken 18 | ;@ SD Gundam Gaiden - Knight Gundam Monogatari 19 | ;@ See also mapper 16, 153 & 157 20 | mapper159init: 21 | ;@---------------------------------------------------------------------------- 22 | .word write0,write0,write0,write0 23 | 24 | ldrb_ r1,cartFlags ;@ Get cartFlags 25 | bic r1,r1,#SRAM ;@ Don't use SRAM on this mapper 26 | strb_ r1,cartFlags ;@ Set cartFlags 27 | ldr r1,mapper159init 28 | str_ r1,m6502WriteTbl+12 29 | 30 | ldr r0,=hook 31 | str_ r0,scanlineHook 32 | 33 | bx lr 34 | ;@---------------------------------------------------------------------------- 35 | write0: 36 | ;@---------------------------------------------------------------------------- 37 | and addy,addy,#0x0f 38 | tst addy,#0x08 39 | ldreq r1,=writeCHRTBL 40 | adrne r1,tbl-8*4 41 | ldr pc,[r1,addy,lsl#2] 42 | tbl: .word map89AB_,mirrorKonami_,wA,wB,wC,void,void,void 43 | ;@--------------------------- 44 | wA: 45 | and r0,r0,#1 46 | strb_ r0,enable 47 | ldr_ r0,latch 48 | str_ r0,counter 49 | mov r0,#0 50 | b rp2A03SetIRQPin 51 | ;@--------------------------- 52 | wB: 53 | strb_ r0,latch 54 | bx lr 55 | ;@--------------------------- 56 | wC: 57 | strb_ r0,latch+1 58 | bx lr 59 | 60 | ;@---------------------------------------------------------------------------- 61 | hook: 62 | ;@---------------------------------------------------------------------------- 63 | ldrb_ r0,enable 64 | cmp r0,#0 65 | bxeq lr 66 | 67 | ldr_ r0,counter 68 | subs r0,r0,#113 69 | str_ r0,counter 70 | mov r0,#1 71 | bcc rp2A03SetIRQPin 72 | bx lr 73 | ;@---------------------------------------------------------------------------- 74 | -------------------------------------------------------------------------------- /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;udevkitARM") 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.1 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 $(TARGET).dsi 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 | $(_ADDFILES) 45 | 46 | #--------------------------------------------------------------------------------- 47 | $(TARGET).dsi : $(NITRO_FILES) arm7/$(TARGET).elf arm9/$(TARGET).elf 48 | ndstool -c $(TARGET).dsi -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ 49 | -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ 50 | -g HNES 00 "HOMEBREW" -u 00030004 \ 51 | $(_ADDFILES) 52 | 53 | #--------------------------------------------------------------------------------- 54 | arm7/$(TARGET).elf: 55 | $(MAKE) -C arm7 56 | 57 | #--------------------------------------------------------------------------------- 58 | arm9/$(TARGET).elf: 59 | $(MAKE) -C arm9 60 | 61 | #--------------------------------------------------------------------------------- 62 | clean: 63 | $(MAKE) -C arm9 clean 64 | $(MAKE) -C arm7 clean 65 | rm -f $(TARGET).nds 66 | rm -f $(TARGET).dsi 67 | -------------------------------------------------------------------------------- /arm9/source/mappers/map23.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper23init 5 | 6 | .struct mapperData 7 | latch: .byte 0 8 | irqEn: .byte 0 9 | k4Irq: .byte 0 10 | counter: .byte 0 11 | k4sel: .byte 0 12 | .skip 3 ;@ Align 13 | chrXX: .space 16 14 | ;@---------------------------------------------------------------------------- 15 | .section .text,"ax" 16 | ;@---------------------------------------------------------------------------- 17 | ;@ Konami VRC2b & VRC4e 18 | ;@ Boku Dracula-kun 19 | ;@ Tiny Toon Adventures (J) 20 | ;@ Wai Wai World 21 | ;@ Also see mapper 21, 22 & 25 22 | mapper23init: 23 | ;@---------------------------------------------------------------------------- 24 | .word write8000,writeA000,writeC000,writeE000 25 | 26 | b Konami_Init 27 | ;@---------------------------------------------------------------------------- 28 | write8000: 29 | ;@---------------------------------------------------------------------------- 30 | cmp addy,#0x9000 31 | bge write9000 32 | ldrb_ r1,k4sel 33 | ands r1,r1,#2 34 | beq map89_ 35 | bne mapCD_ 36 | 37 | write9000: 38 | orr addy,addy,addy,lsr#4 ;@ 0x55=1, 0xAA=2 39 | orr addy,addy,addy,lsr#2 40 | ands addy,addy,#3 41 | beq mirrorKonami_ 42 | w90_: 43 | strb_ r0,k4sel 44 | bx lr 45 | ;@---------------------------------------------------------------------------- 46 | writeA000: 47 | ;@---------------------------------------------------------------------------- 48 | cmp addy,#0xb000 49 | bmi mapAB_ 50 | writeC000: @addy=B/C/D/Exxx 51 | ;@---------------------------------------------------------------------------- 52 | and r0,r0,#0x0f 53 | 54 | sub r2,addy,#0xB000 55 | and r2,r2,#0x3000 56 | tst addy,#0x55 57 | orrne r2,r2,#0x400 58 | tst addy,#0xAA 59 | orrne r2,r2,#0x800 60 | 61 | adrl_ r1,chrXX 62 | 63 | strb r0,[r1,r2,lsr#10] 64 | bic r2,r2,#0x400 65 | ldrb r0,[r1,r2,lsr#10]! ;@ writeback address 66 | ldrb r1,[r1,#1] 67 | orr r0,r0,r1,lsl#4 68 | 69 | ldr r1,=writeCHRTBL 70 | ldr pc,[r1,r2,lsr#9] 71 | ;@---------------------------------------------------------------------------- 72 | writeE000: 73 | ;@---------------------------------------------------------------------------- 74 | cmp addy,#0xf000 75 | bmi writeC000 76 | 77 | orr addy,addy,addy,lsr#4 ;@ 0x55=1, 0xAA=2 78 | orr addy,addy,addy,lsr#2 79 | and addy,addy,#3 80 | ldr pc,[pc,addy,lsl#2] 81 | nop 82 | writeFtbl: .word KoLatchLo,KoLatchHi,KoIRQEnable,KoIRQack 83 | ;@---------------------------------------------------------------------------- 84 | -------------------------------------------------------------------------------- /arm9/source/mappers/map37.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc3.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper37init 5 | 6 | .struct mmc3Extra 7 | outerPpuBank: .byte 0 8 | outerCpuBank: .byte 0 9 | cpuMask: .byte 0 10 | 11 | ;@---------------------------------------------------------------------------- 12 | .section .text,"ax" 13 | ;@---------------------------------------------------------------------------- 14 | ;@ Yet another MMC3 multicart. 15 | ;@ Used in: 16 | ;@ Super Mario Bros. + Tetris + Nintendo World Cup 17 | mapper37init: 18 | ;@---------------------------------------------------------------------------- 19 | .word write0, mmc3MirrorW, mmc3CounterW, mmc3IrqEnableW 20 | stmfd sp!, {lr} 21 | 22 | mov r0,#0 23 | strb_ r0,outerPpuBank 24 | strb_ r0,outerCpuBank 25 | mov r0,#0x7 26 | strb_ r0,cpuMask 27 | mov r0,#0x04 28 | str_ r0,prgSize16k 29 | mov r0, r0, lsl#1 30 | str_ r0,prgSize8k 31 | 32 | bl mmc3Init 33 | 34 | adr r0, writel 35 | str_ r0, m6502WriteTbl+12 36 | 37 | ldmfd sp!, {lr} 38 | bx lr 39 | 40 | ;@---------------------------------------------------------------------------- 41 | writel: @($6000-$7FFF) 42 | ;@---------------------------------------------------------------------------- 43 | ;@ Check for WRAM enable (A001) 44 | ldrb_ r1,reg3 45 | and r1,r1,#0xC0 46 | cmp r1,#0x80 ;@ Enabled and not write protected 47 | bxne lr 48 | 49 | and r2,r0,#4 50 | strb_ r2,outerPpuBank 51 | and r0,r0,#3 52 | cmp r0,#3 53 | orreq r2,r2,#2 54 | strb_ r2,outerCpuBank 55 | cmp r2,#2 56 | mov r1,#0x7 57 | movhi r1,#0xF 58 | strb_ r1,cpuMask 59 | movmi r0,#0x04 60 | moveq r0,#0x08 61 | movhi r0,#0x10 62 | str_ r0,prgSize16k 63 | mov r0, r0, lsl#1 64 | str_ r0,prgSize8k 65 | 66 | ldrb_ r0,prg0 67 | and r0,r0,r1 68 | orr r0,r0,r2,lsl#2 69 | strb_ r0,prg0 70 | 71 | ldrb_ r0,prg1 72 | and r0,r0,r1 73 | orr r0,r0,r2,lsl#2 74 | strb_ r0,prg1 75 | 76 | ldrb_ r0,reg0 77 | b mmc3Mapping0W 78 | 79 | ;@---------------------------------------------------------------------------- 80 | write0: @($8000-$9FFF) 81 | ;@---------------------------------------------------------------------------- 82 | tst addy, #1 83 | beq mmc3Mapping0W 84 | 85 | w8001: 86 | ldrb_ r1, reg0 87 | and r1, r1, #6 88 | cmp r1, #6 ;@ PRG or CHR? 89 | ldrneb_ r1,outerPpuBank 90 | andne r0,r0,#0x7F ;@ CHR, one bank is 128Kb 91 | orrne r0,r0,r1,lsl#5 92 | ldreqb_ r1,cpuMask 93 | andeq r0,r0,r1 ;@ PRG, one bank is 128Kb 94 | ldreqb_ r1,outerCpuBank 95 | orreq r0,r0,r1,lsl#2 96 | b mmc3Mapping1W 97 | ;@---------------------------------------------------------------------------- 98 | -------------------------------------------------------------------------------- /arm9/source/mappers/map2426.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper24init 5 | .global mapper26init 6 | 7 | .struct mapperData 8 | latch: .byte 0 9 | irqEn: .byte 0 10 | k4Irq: .byte 0 11 | counter: .byte 0 12 | m26Sel: .byte 0 13 | ;@---------------------------------------------------------------------------- 14 | .section .text,"ax" 15 | ;@---------------------------------------------------------------------------- 16 | ;@ Konami VRC6a 17 | ;@ Used in: 18 | ;@ Akumajou Densetsu (J)... 19 | mapper24init: 20 | ;@---------------------------------------------------------------------------- 21 | .word write8000,writeA000,writeC000,writeE000 22 | 23 | b Konami_Init 24 | ;@---------------------------------------------------------------------------- 25 | ;@ Konami VRC6b 26 | ;@ Used in: 27 | ;@ Esper Dream 2 28 | ;@ Madara (J) 29 | mapper26init: 30 | ;@---------------------------------------------------------------------------- 31 | .word write8000,writeA000,writeC000,writeE000 32 | 33 | mov r0,#0x02 34 | strb_ r0,m26Sel 35 | b Konami_Init 36 | ;@---------------------------------------------------------------------------- 37 | write8000: 38 | ;@---------------------------------------------------------------------------- 39 | tst addy,#0x1000 40 | andeqs r2,addy,#3 41 | beq map89AB_ 42 | @bxne lr ;@ 0x900x Should really be emulation of the VRC6 soundchip. 43 | bne soundwrite 44 | ;@---------------------------------------------------------------------------- 45 | writeA000: 46 | ;@---------------------------------------------------------------------------- 47 | tst addy,#0x1000 48 | @bxeq lr ;@ 0xA00x Should really be emulation of the VRC6 soundchip. 49 | beq soundwrite 50 | and r1,addy,#0x3 51 | cmp r1,#0x3 ;@ 0xB003 52 | @bxne lr ;@ !0xB003 Should really be emulation of the VRC6 soundchip. 53 | bne soundwrite 54 | 0: 55 | mov r0,r0,lsr#2 56 | b mirrorKonami_ 57 | ;@---------------------------------------------------------------------------- 58 | writeC000: 59 | ;@---------------------------------------------------------------------------- 60 | tst addy,#0x1000 61 | tsteq addy,#0x3 62 | beq mapCD_ 63 | writeD000: ;@ addy=D/E/Fxxx 64 | writeE000: 65 | sub r2,addy,#0xD000 66 | and addy,addy,#3 67 | ldrb_ r1,m26Sel 68 | tst r1,#2 69 | and r1,r1,addy,lsl#1 70 | orrne addy,r1,addy,lsr#1 71 | orr r2,addy,r2,lsr#10 72 | 73 | tst r2,#0x08 74 | ldreq r1,=writeCHRTBL 75 | adrne r1,writeTable-8*4 76 | ldr pc,[r1,r2,lsl#2] 77 | 78 | writeTable: .word KoLatch,KoIRQEnable,KoIRQack,void 79 | ;@---------------------------------------------------------------------------- 80 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/mappers/map65.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper65init 5 | 6 | .struct mapperData 7 | latch: .word 0 8 | counter: .word 0 9 | irqEn: .byte 0 10 | mSwitch: .byte 0 11 | ;@---------------------------------------------------------------------------- 12 | .section .text,"ax" 13 | ;@---------------------------------------------------------------------------- 14 | ;@ Irem H3001 15 | ;@ Used in: 16 | ;@ Daiku no Gen San 2 17 | ;@ Kaiketsu Yanchamaru 3 18 | ;@ Spartan X 2 19 | mapper65init: 20 | ;@---------------------------------------------------------------------------- 21 | .word write8000,writeA000,writeC000,rom_W 22 | 23 | adr r0,hook 24 | str_ r0,scanlineHook 25 | 26 | bx lr 27 | ;@---------------------------------------------------------------------------- 28 | write8000: 29 | ;@---------------------------------------------------------------------------- 30 | tst addy,#0x1000 31 | beq map89_ 32 | 33 | write9000: 34 | and addy,addy,#7 35 | ldr pc,[pc,addy,lsl#2] 36 | nop 37 | write9tbl: .word w90,w91,void,w93,w94,w95,w96,void 38 | 39 | w90: 40 | ldrb_ r1,mSwitch 41 | cmp r1,#0 42 | bxne lr 43 | tst r0,#0x40 44 | b mirror2H_ 45 | w91: 46 | mov r1,#1 47 | strb_ r1,mSwitch 48 | tst r0,#0x80 49 | b mirror2V_ 50 | w93: 51 | and r0,r0,#0x80 52 | strb_ r0,irqEn 53 | mov r0,#0 54 | b rp2A03SetIRQPin 55 | w94: 56 | ldr_ r2,latch 57 | str_ r2,counter 58 | mov r0,#0 59 | b rp2A03SetIRQPin 60 | w95: 61 | strb_ r0,latch+1 62 | bx lr 63 | w96: 64 | strb_ r0,latch 65 | bx lr 66 | 67 | ;@---------------------------------------------------------------------------- 68 | writeA000: 69 | ;@---------------------------------------------------------------------------- 70 | tst addy,#0x1000 71 | beq mapAB_ 72 | writeB000: 73 | and addy,addy,#7 74 | ldr r1,=writeCHRTBL 75 | ldr pc,[r1,addy,lsl#2] 76 | ;@---------------------------------------------------------------------------- 77 | writeC000: 78 | ;@---------------------------------------------------------------------------- 79 | cmp addy,#0xC000 80 | beq mapCD_ 81 | bx lr 82 | ;@---------------------------------------------------------------------------- 83 | hook: 84 | ;@---------------------------------------------------------------------------- 85 | ldrb_ r0,irqEn 86 | cmp r0,#0 ;@ Timer active? 87 | bxeq lr 88 | 89 | ldr_ r0,counter 90 | subs r0,r0,#113 ;@ Counter-A 91 | bhi h0 92 | 93 | mov r0,#0 94 | strb_ r0,irqEn 95 | str_ r0,counter ;@ Clear counter and IRQenable. 96 | mov r0,#1 97 | b rp2A03SetIRQPin 98 | h0: 99 | str_ r0,counter 100 | bx lr 101 | ;@---------------------------------------------------------------------------- 102 | -------------------------------------------------------------------------------- /arm9/source/mappers/map75.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper75init 5 | .global mapper151init 6 | 7 | .struct mapperData 8 | map75ar0: .byte 0 9 | map75ar1: .byte 0 10 | map75sel: .byte 0 11 | ;@---------------------------------------------------------------------------- 12 | .section .text,"ax" 13 | ;@---------------------------------------------------------------------------- 14 | ;@ Konami VRC1 15 | ;@ Used in: 16 | ;@ Exciting Boxing 17 | ;@ Ganbare Goemon! Karakuri Douchuu 18 | ;@ Jajamaru Ninpouchou 19 | ;@ King Kong 2: Ikari no Megaton Punch 20 | ;@ Moero!! Junior Basket: Two on Two 21 | ;@ Tetsuwan Atom 22 | mapper75init: 23 | ;@---------------------------------------------------------------------------- 24 | .word write8000,writeA000,writeC000,writeE000 25 | 26 | bx lr 27 | ;@---------------------------------------------------------------------------- 28 | ;@ Mapper 75 but for VS system, missing mirror capability, allways 4 screen. 29 | mapper151init: 30 | ;@---------------------------------------------------------------------------- 31 | .word write8000,writeA000,writeC000,writeE000 32 | 33 | ldrb_ r0,cartFlags 34 | orr r0,r0,#VS 35 | strb_ r0,cartFlags 36 | 37 | bx lr 38 | ;@---------------------------------------------------------------------------- 39 | write8000: 40 | ;@---------------------------------------------------------------------------- 41 | tst addy,#0x1000 42 | beq map89_ 43 | 44 | write9000: 45 | strb_ r0,map75sel 46 | mov addy,r0 47 | stmfd sp!,{lr} 48 | tst r0,#1 49 | bl mirror2V_ 50 | ldrb_ r1,map75ar0 51 | and r0,addy,#2 52 | orr r0,r1,r0,lsl#3 53 | bl chr0123_ 54 | 55 | ldmfd sp!,{lr} 56 | ldrb_ r1,map75ar1 57 | and r0,addy,#4 58 | orr r0,r1,r0,lsl#2 59 | b chr4567_ 60 | ;@---------------------------------------------------------------------------- 61 | writeA000: 62 | ;@---------------------------------------------------------------------------- 63 | tst addy,#0x1000 64 | beq mapAB_ 65 | 66 | writeB000: 67 | bx lr 68 | ;@---------------------------------------------------------------------------- 69 | writeC000: 70 | ;@---------------------------------------------------------------------------- 71 | tst addy,#0x1000 72 | beq mapCD_ 73 | 74 | writeD000: 75 | bx lr 76 | ;@---------------------------------------------------------------------------- 77 | writeE000: 78 | ;@---------------------------------------------------------------------------- 79 | and r0,r0,#0xF 80 | ldrb_ r1,map75sel 81 | tst addy,#0x1000 82 | bne writeF000 83 | strb_ r0,map75ar0 84 | and r1,r1,#2 85 | orr r0,r0,r1,lsl#3 86 | b chr0123_ 87 | 88 | writeF000: 89 | strb_ r0,map75ar1 90 | and r1,r1,#4 91 | orr r0,r0,r1,lsl#2 92 | b chr4567_ 93 | 94 | bx lr 95 | ;@---------------------------------------------------------------------------- 96 | -------------------------------------------------------------------------------- /arm9/source/mappers/map255.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper225init 5 | .global mapper255init 6 | 7 | .struct mapperData 8 | tmp: .word 0 9 | ram0: .space 4 10 | prgReg: .byte 0 11 | chrReg: .byte 0 12 | ;@---------------------------------------------------------------------------- 13 | .section .text,"ax" 14 | ;@---------------------------------------------------------------------------- 15 | ;@ ET-4310 (60-pin) and K-1010 (72-pin) multicart circuit boards. 16 | ;@ Used in: 17 | ;@ 52 Games 18 | ;@ 58-in-1 19 | ;@ 64-in-1 20 | mapper225init: 21 | ;@---------------------------------------------------------------------------- 22 | .word w255, w255, w255, w255 23 | stmfd sp!, {lr} 24 | mov r0, #0 25 | bl map89ABCDEF_ 26 | cmp r0, r0 27 | bl mirror2V_ 28 | ldmfd sp!, {pc} 29 | 30 | ;@---------------------------------------------------------------------------- 31 | ;@ Same as 225, plus ram. 32 | mapper255init: 33 | ;@---------------------------------------------------------------------------- 34 | .word w255, w255, w255, w255 35 | stmfd sp!, {lr} 36 | mov r0, #0 37 | bl map89ABCDEF_ 38 | cmp r0, r0 39 | bl mirror2V_ 40 | 41 | adr r0, m255RamR 42 | str_ r0, rp2A03MemRead 43 | adr r0, m255RamW 44 | str_ r0, rp2A03MemWrite 45 | ldmfd sp!, {pc} 46 | 47 | ;@---------------------------------------------------------------------------- 48 | w255: 49 | ;@---------------------------------------------------------------------------- 50 | stmfd sp!, {lr} 51 | 52 | str_ addy, tmp 53 | mov r0, addy, lsr#6 54 | and r0, r0, #0x3F 55 | and r1, addy, #0x3f 56 | tst addy, #0x4000 ;@ 7th bit of both chr & prg 57 | orrne r0, r0, #0x40 58 | orrne r1, r1, #0x40 59 | strb_ r1, chrReg 60 | strb_ r0, prgReg 61 | 62 | tst addy, #0x2000 63 | bl mirror2V_ 64 | 65 | ldrb_ r0, chrReg 66 | bl chr01234567_ 67 | 68 | ldrb_ r0, prgReg 69 | ldr_ addy, tmp 70 | tst addy, #0x1000 ;@ Prg mode 71 | beq w255_32k 72 | 73 | bl map89AB_ 74 | ldmfd sp!, {lr} 75 | ldrb_ r0, prgReg 76 | b mapCDEF_ 77 | 78 | w255_32k: 79 | ldmfd sp!, {lr} 80 | mov r0, r0, lsr#1 81 | b map89ABCDEF_ 82 | 83 | ;@---------------------------------------------------------------------------- 84 | m255RamR: 85 | ;@---------------------------------------------------------------------------- 86 | tst addy,#0x1800 87 | beq empty_R 88 | and r1,addy,#3 89 | adr_ r2,ram0 90 | ldrb r0,[r2,r1] 91 | bx lr 92 | ;@---------------------------------------------------------------------------- 93 | m255RamW: 94 | ;@---------------------------------------------------------------------------- 95 | tst addy,#0x1800 96 | beq empty_W 97 | and r1,addy,#3 98 | adr_ r2,ram0 99 | strb r0,[r2,r1] 100 | bx lr 101 | ;@---------------------------------------------------------------------------- 102 | -------------------------------------------------------------------------------- /arm9/source/mappers/map69.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper69init 5 | 6 | .struct mapperData 7 | countdown: .word 0 8 | irqEn: .byte 0 9 | cmd: .byte 0 10 | video: .byte 0 ;@ Number of cycles per scanline 11 | ;@---------------------------------------------------------------------------- 12 | .section .text,"ax" 13 | ;@---------------------------------------------------------------------------- 14 | ;@ Sunsoft FME-7, 5A & 5B 15 | ;@ Used in: 16 | ;@ Barcode World 17 | ;@ Batman ROTJ 18 | ;@ Gimmick 19 | ;@ Gremlins (J) 20 | ;@ Hebereke 21 | mapper69init: 22 | ;@---------------------------------------------------------------------------- 23 | .word write0,write1,rom_W,rom_W ;@ There is a music channel also 24 | 25 | mov r1,#-1 26 | mov r1,r1,lsr#16 27 | str_ r1,countdown 28 | 29 | ldr_ r1,emuFlags 30 | tst r1,#PALTIMING 31 | movne r1,#107 ;@ PAL 32 | moveq r1,#113 ;@ NTSC 33 | strb_ r1,video 34 | 35 | adr r0,hook 36 | str_ r0,scanlineHook 37 | 38 | bx lr 39 | ;@---------------------------------------------------------------------------- 40 | write0: ;@ $8000 41 | ;@---------------------------------------------------------------------------- 42 | strb_ r0,cmd 43 | bx lr 44 | ;@---------------------------------------------------------------------------- 45 | write1: ;@ $A000 46 | ;@---------------------------------------------------------------------------- 47 | ldrb_ r1,cmd 48 | movs r1,r1,lsl#29 49 | ldrcc r2,=writeCHRTBL 50 | adrcs r2,commandList 51 | ldr pc,[r2,r1,lsr#27] 52 | ;@---------------------------------------------------------------------------- 53 | commandList: .word mapJinx,map89_,mapAB_,mapCD_,mirrorKonami_,irqEn69,irqA69,irqB69 54 | ;@---------------------------------------------------------------------------- 55 | 56 | irqEn69: 57 | strb_ r0,irqEn 58 | mov r0,#0 59 | b rp2A03SetIRQPin 60 | irqA69: 61 | strb_ r0,countdown+2 62 | bx lr 63 | irqB69: 64 | strb_ r0,countdown+3 65 | bx lr 66 | ;@---------------------------------------------------------------------------- 67 | mapJinx: 68 | ;@---------------------------------------------------------------------------- 69 | tst r0,#0x40 70 | ldreq r1,=rom_W ;@ Swap in ROM at $6000-$7FFF. 71 | ldrne r1,=sram_W ;@ Swap in sram at $6000-$7FFF. 72 | str_ r1,m6502WriteTbl+12 73 | beq map67_ 74 | ldr r1,=NES_SRAM-0x6000 ;@ sram at $6000. 75 | str_ r1,m6502MemTbl+12 76 | bx lr 77 | ;@---------------------------------------------------------------------------- 78 | hook: 79 | ;@---------------------------------------------------------------------------- 80 | ldrb_ r2,irqEn 81 | tst r2,#0x80 ;@ Timer enabled? 82 | bxeq lr 83 | 84 | ldr_ r0,countdown 85 | ldrb_ r1,video ;@ Number of cycles per scanline. 86 | subs r0,r0,r1,lsl#16 87 | str_ r0,countdown 88 | bxpl lr 89 | 90 | ands r0,r2,#1 ;@ IRQ enabled? 91 | bne rp2A03SetIRQPin 92 | bx lr 93 | -------------------------------------------------------------------------------- /arm9/source/mappers/map67.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper67init 5 | .global map67_IRQ_Hook 6 | 7 | .struct mapperData 8 | countdown: .word 0 9 | irqEn: .byte 0 10 | sunToggle: .byte 0 11 | ;@---------------------------------------------------------------------------- 12 | .section .text,"ax" 13 | ;@---------------------------------------------------------------------------- 14 | ;@ Sunsoft-3 15 | ;@ Used in: 16 | ;@ Fantasy Zone II (J) 17 | ;@ Mito Koumon II - Sekai Manyuu Ki 18 | ;@ Vs. Platoon 19 | mapper67init: 20 | ;@---------------------------------------------------------------------------- 21 | .word write0,write1,write2,write3 22 | 23 | adr r0,map67_IRQ_Hook 24 | str_ r0,scanlineHook 25 | 26 | bx lr 27 | ;@---------------------------------------------------------------------------- 28 | ackIrq: ;@ adr & 0x0800 == 0. 29 | ;@---------------------------------------------------------------------------- 30 | mov r0,#0 ;@ 8000 31 | b rp2A03SetIRQPin 32 | ;@---------------------------------------------------------------------------- 33 | write0: ;@ 8000,8800,9800 34 | ;@---------------------------------------------------------------------------- 35 | ands addy,addy,#0x1800 36 | beq ackIrq 37 | cmp addy,#0x0800 ;@ 8800 38 | beq chr01_ 39 | cmp addy,#0x1800 ;@ 9800 40 | beq chr23_ 41 | b ackIrq 42 | ;@---------------------------------------------------------------------------- 43 | write1: ;@ A800,B800 44 | ;@---------------------------------------------------------------------------- 45 | tst addy,#0x0800 46 | beq ackIrq 47 | tst addy,#0x1000 48 | beq chr45_ 49 | b chr67_ 50 | ;@---------------------------------------------------------------------------- 51 | write2: ;@ C800,D800 52 | ;@---------------------------------------------------------------------------- 53 | tst addy,#0x0800 54 | beq ackIrq 55 | tst addy,#0x1000 56 | movne r1,#0 57 | strneb_ r1,sunToggle 58 | strneb_ r0,irqEn 59 | bxne lr 60 | 61 | ldrb_ r1,sunToggle 62 | eors r1,r1,#1 63 | strb_ r1,sunToggle 64 | strneb_ r0,countdown+1 65 | streqb_ r0,countdown 66 | bx lr 67 | ;@---------------------------------------------------------------------------- 68 | write3: ;@ E800,F800 69 | ;@---------------------------------------------------------------------------- 70 | tst addy,#0x0800 71 | beq ackIrq 72 | tst addy,#0x1000 73 | bne map89AB_ 74 | b mirrorKonami_ 75 | ;@---------------------------------------------------------------------------- 76 | map67_IRQ_Hook: 77 | ;@---------------------------------------------------------------------------- 78 | ldrb_ r1,irqEn 79 | cmp r1,#0 80 | bxeq lr 81 | 82 | ldr_ r0,countdown 83 | subs r0,r0,#113 84 | str_ r0,countdown 85 | bxpl lr 86 | 87 | mov r1,#0 88 | strb_ r1,irqEn 89 | mov r0,r0,lsr#16 90 | str_ r0,countdown 91 | b rp2A03SetIRQPin 92 | ;@---------------------------------------------------------------------------- 93 | -------------------------------------------------------------------------------- /arm9/source/mappers/map2125.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper21init 5 | .global mapper25init 6 | 7 | .struct mapperData 8 | latch: .byte 0 9 | irqEn: .byte 0 10 | k4Irq: .byte 0 11 | counter: .byte 0 12 | k4Sel: .byte 0 13 | k4Map1: .byte 0 14 | .skip 2 ;@ Align 15 | chrXX: .space 16 16 | ;@---------------------------------------------------------------------------- 17 | .section .text,"ax" 18 | ;@---------------------------------------------------------------------------- 19 | ;@ Konami VRC2c & VRC4(a,b,c&d) 20 | ;@ Used in: 21 | ;@ Gradius 2 22 | ;@ Wai Wai World 2 23 | ;@ Also see mapper 22 & 23 24 | mapper21init: 25 | mapper25init: 26 | ;@---------------------------------------------------------------------------- 27 | .word write8000,writeA000,writeC000,writeE000 28 | 29 | b Konami_Init 30 | ;@---------------------------------------------------------------------------- 31 | write8000: 32 | ;@---------------------------------------------------------------------------- 33 | tst addy,#0x1000 34 | bne write9000 35 | strb_ r0,k4Map1 36 | b romswitch 37 | 38 | write9000: 39 | orr addy,addy,addy,lsr#2 40 | ands addy,addy,#3 41 | beq mirrorKonami_ 42 | cmp addy,#1 43 | bxne lr 44 | w91: 45 | strb_ r0,k4Sel 46 | romswitch: 47 | mov addy,lr 48 | ldrb_ r0,k4Sel 49 | tst r0,#2 50 | mov r0,#-2 51 | bne reverseMap 52 | bl mapCD_ 53 | mov lr,addy 54 | ldrb_ r0,k4Map1 55 | b map89_ 56 | reverseMap: 57 | bl map89_ 58 | mov lr,addy 59 | ldrb_ r0,k4Map1 60 | b mapCD_ 61 | ;@---------------------------------------------------------------------------- 62 | writeA000: 63 | ;@---------------------------------------------------------------------------- 64 | tst addy,#0x1000 65 | beq mapAB_ 66 | writeC000: @addy=B/C/D/Exxx 67 | ;@---------------------------------------------------------------------------- 68 | sub r2,addy,#0xB000 69 | and r2,r2,#0x3000 70 | tst addy,#0x85 ;@ 0x01 + 0x04 + 0x80 71 | orrne r2,r2,#0x800 72 | tst addy,#0x4A ;@ 0x02 + 0x08 + 0x40 73 | orrne r2,r2,#0x4000 74 | 75 | adrl_ r1,chrXX 76 | and r0,r0,#0x0f 77 | 78 | strb r0,[r1,r2,lsr#11] 79 | bic r2,r2,#0x4000 80 | ldrb r0,[r1,r2,lsr#11]! 81 | ldrb r1,[r1,#8] 82 | orr r0,r0,r1,lsl#4 83 | 84 | ldr r1,=writeCHRTBL 85 | ldr pc,[r1,r2,lsr#9] 86 | ;@---------------------------------------------------------------------------- 87 | writeE000: 88 | ;@---------------------------------------------------------------------------- 89 | cmp addy,#0xf000 90 | bmi writeC000 91 | 92 | tst addy,#0x85 @0x04 + 0x01 + 0x80 93 | orrne addy,addy,#0x1 94 | tst addy,#0x4A @0x02 + 0x08 + 0x40 95 | orrne addy,addy,#0x2 96 | and addy,addy,#3 97 | ldr pc,[pc,addy,lsl#2] 98 | nop 99 | writeFtbl: .word KoLatchLo,KoIRQEnable,KoLatchHi,KoIRQack 100 | ;@---------------------------------------------------------------------------- 101 | -------------------------------------------------------------------------------- /arm9/source/mappers/map253.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper253init 5 | 6 | .struct mapperData 7 | latch: .byte 8 | irqen: .byte 9 | k4irq: .byte 10 | counter: .byte 11 | reg0: .space 16 12 | ;@---------------------------------------------------------------------------- 13 | .section .text,"ax" 14 | ;@---------------------------------------------------------------------------- 15 | ;@ Waixing VRC4 clone 16 | ;@ Used in: Dragon Ball Z: 強襲! サイヤ人 (Dragon Ball Z: Kyōshū! Saiya-jin) 17 | ;@ See also mapper 252 18 | mapper253init: 19 | ;@---------------------------------------------------------------------------- 20 | .word write89, writeAB, writeCD, writeEF 21 | 22 | ldr r0, =0x0100 23 | str_ r0, reg0 24 | ldr r0, =0x0302 25 | str_ r0, reg0 + 4 26 | ldr r0, =0x0504 27 | str_ r0, reg0 + 8 28 | ldr r0, =0x0706 29 | str_ r0, reg0 + 12 30 | 31 | stmfd sp!, {lr} 32 | bl Konami_Init 33 | 34 | mov r0, #0 35 | bl chr01234567_ 36 | 37 | ldr r0,=VRAM_chr ;@ Enable chr write 38 | ldr r1,=vram_write_tbl 39 | mov r2,#8 40 | bl filler 41 | 42 | adr r0, frameHook 43 | str_ r0, newFrameHook 44 | 45 | ldmfd sp!, {pc} 46 | 47 | ;@---------------------------------------------------------------------------- 48 | write89: 49 | ldr r1, =0x8010 50 | cmp addy, r1 51 | beq map89_ 52 | ldr r1, =0x9400 53 | cmp addy, r1 54 | bxne lr 55 | and r0, r0, #3 56 | tst r0, #2 57 | beq 0f 58 | tst r0, #1 59 | b mirror1_ 60 | 0: 61 | tst r0, #1 62 | b mirror2V_ 63 | 64 | ;@---------------------------------------------------------------------------- 65 | writeAB: 66 | ldr r1, =0xa010 67 | cmp r1, addy 68 | beq mapAB_ 69 | tst addy, #0x1000 70 | bxeq lr 71 | 72 | writePPU: 73 | mov r2, addy, lsr#12 74 | sub r2, r2, #0xb 75 | mov r2, r2, lsl#1 76 | tst addy, #0x8 77 | addne r2, r2, #1 78 | adrl_ r1, reg0 79 | tst addy, #0x4 80 | add addy, r1, r2 81 | ldrb r1, [addy] 82 | andeq r1, #0xF0 83 | andeq r0, #0xF 84 | orreq r0, r0, r1 85 | andne r1, #0xF 86 | orrne r0, r1, r0, lsl#4 87 | strb r0, [addy] 88 | mov r1, r2 89 | b chr1k 90 | 91 | ;@---------------------------------------------------------------------------- 92 | writeCD: 93 | b writePPU 94 | ;@---------------------------------------------------------------------------- 95 | writeEF: 96 | tst addy, #0x1000 ;@ addy=0xF*** 97 | beq writePPU 98 | 99 | and r1, addy, #0xc 100 | ldr pc, [pc, r1] 101 | nop 102 | .word KoLatchLo, KoLatchHi, KoIRQEnable, KoIRQack 103 | 104 | ;@---------------------------------------------------------------------------- 105 | frameHook: 106 | mov r0,#-1 107 | ldr r1,=agb_obj_map 108 | str r0,[r1],#4 109 | str r0,[r1],#4 110 | str r0,[r1],#4 111 | str r0,[r1],#4 112 | 113 | mov r0,#-1 ;@ Code from resetCHR 114 | ldr r1,=agb_bg_map 115 | mov r2,#16 * 2 116 | b filler 117 | ;@---------------------------------------------------------------------------- 118 | -------------------------------------------------------------------------------- /arm9/source/mappers/map198.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc3.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper198init 5 | 6 | ;@---------------------------------------------------------------------------- 7 | .section .text,"ax" 8 | ;@---------------------------------------------------------------------------- 9 | ;@ MMC3 plus more 10 | mapper198init: 11 | ;@---------------------------------------------------------------------------- 12 | .word write0, writeABCDEF, writeABCDEF, writeABCDEF 13 | stmfd sp!, {lr} 14 | 15 | bl mmc3Init 16 | 17 | bl setBankPPU 18 | 19 | adr r0, readl 20 | str_ r0, rp2A03MemRead 21 | adr r0, writel 22 | str_ r0, rp2A03MemWrite 23 | /* 24 | adr r0, readh 25 | str_ r0, m6502ReadTbl+12 26 | adr r0, writeh 27 | str_ r0, m6502WriteTbl+12 28 | */ 29 | ldmfd sp!, {pc} 30 | 31 | ;@---------------------------------------------------------------------------- 32 | writel: 33 | ;@---------------------------------------------------------------------------- 34 | bic r1, addy, #0xE000 35 | ldr r2, =NES_XRAM 36 | strb r0, [r2, r1] 37 | bx lr 38 | ;@---------------------------------------------------------------------------- 39 | readl: 40 | ;@---------------------------------------------------------------------------- 41 | bic r1, addy, #0xE000 42 | ldr r2, =NES_XRAM 43 | ldrb r0, [r2, r1] 44 | bx lr 45 | 46 | ;@---------------------------------------------------------------------------- 47 | writeh: 48 | ldr r1,=NES_SRAM 49 | bic r2, addy, #0xE000 50 | strb r0,[r1,r2] 51 | bx lr 52 | ;@---------------------------------------------------------------------------- 53 | readh: 54 | ldr r1,=NES_SRAM 55 | bic r2, addy, #0xE000 56 | ldrb r0,[r1,r2] 57 | bx lr 58 | ;@---------------------------------------------------------------------------- 59 | setBankPPU: 60 | ;@---------------------------------------------------------------------------- 61 | ldr_ r1, vmemMask 62 | tst r1, #0x80000000 63 | bxne lr 64 | b mmc3SetBankPpu 65 | 66 | ;@---------------------------------------------------------------------------- 67 | write0: ;@ 8000-9FFF 68 | ;@---------------------------------------------------------------------------- 69 | tst addy, #1 70 | bne w8001 71 | 72 | stmfd sp!, {lr} 73 | strb_ r0, reg0 74 | bl mmc3SetBankCpu 75 | ldmfd sp!, {lr} 76 | b setBankPPU 77 | 78 | w8001: 79 | strb_ r0, reg1 80 | ldrb_ r1, reg0 81 | and r1, r1, #7 82 | cmp r1, #6 83 | bcs 6f 84 | 85 | adrl_ r2, chr01 86 | strb r0, [r2, r1] 87 | b setBankPPU 88 | 6: 89 | bne 7f 90 | cmp r0, #0x50 91 | andcs r0, r0, #0x4f 92 | strb_ r0, prg0 93 | b mmc3SetBankCpu 94 | 7: 95 | strb_ r0, prg1 96 | b mmc3SetBankCpu 97 | 98 | ;@---------------------------------------------------------------------------- 99 | writeABCDEF: 100 | mov r1, addy, lsr#12 101 | tst addy, #1 102 | biceq r1, r1, #1 103 | orrne r1, r1, #1 104 | subs r1, r1, #0xa 105 | adrl_ r2, reg2 106 | strb r0, [r2, r1] 107 | bxne lr 108 | tst r0, #1 109 | b mirror2V_ 110 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arm9/source/mappers/map105.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "mmc1.i" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper105init 5 | 6 | .struct mmc1Extra 7 | counter: .word 0 8 | 9 | dip = 0xb @ DIPswitch, for playtime. 6min default. 10 | @ 0x0 - 9.695 11 | @ 0x1 - 9.318 12 | @ 0x2 - 9.070 13 | @ 0x3 - 8.756 14 | @ 0x4 - 8.444 15 | @ 0x5 - 8.131 16 | @ 0x6 - 7.818 17 | @ 0x7 - 7.505 18 | @ 0x8 - 7.193 19 | @ 0x9 - 6.880 20 | @ 0xa - 6.567 21 | @ 0xb - 6.254 22 | @ 0xc - 5.942 23 | @ 0xd - 5.629 24 | @ 0xe - 5.316 25 | @ 0xf - 5.001 26 | ;@---------------------------------------------------------------------------- 27 | .section .text,"ax" 28 | ;@---------------------------------------------------------------------------- 29 | ;@ Board with MMC1 plus timers 30 | ;@ Used in: 31 | ;@ Nintendo World Championships 32 | mapper105init: 33 | ;@---------------------------------------------------------------------------- 34 | .word mmc1Write0,write1,mmc1Write2,mmc1Write3 35 | stmfd sp!,{lr} 36 | 37 | bl mmc1Init 38 | 39 | adr r0,romSwitch 40 | str_ r0,cpuSwitch 41 | adr r0,hook 42 | str_ r0,scanlineHook 43 | 44 | mov r0,#0 45 | bl map89ABCDEF_ 46 | 47 | ldmfd sp!, {pc} 48 | ;@---------------------------------------------------------------------------- 49 | write1: ;@ ($A000-$BFFF) 50 | ;@---------------------------------------------------------------------------- 51 | adr addy,w1 52 | b mmc1WriteLatch 53 | w1: 54 | strb_ r0,reg1 55 | @---- 56 | tst r0,#0x10 57 | 58 | stmfd sp!, {r0,lr} 59 | mov r0,#0 60 | strne_ r0,counter 61 | blne rp2A03SetIRQPin 62 | ldmfd sp!, {r0,lr} 63 | 64 | b romSwitch 65 | ;@---------------------------------------------------------------------------- 66 | romSwitch: 67 | ;@---------------------------------------------------------------------------- 68 | ldrb_ r0,reg1 69 | tst r0,#0x8 70 | beq rs2 71 | ldrb_ r0,reg3 72 | orr r0,r0,#0x8 73 | 74 | ldrb_ r1,reg0 75 | tst r1,#0x08 76 | beq rs1 77 | ;@ Switch 16k / high 128k: 78 | stmfd sp!,{lr} 79 | tst r1,#0x04 80 | beq rs0 81 | 82 | bl map89AB_ ;@ Map low bank 83 | ldmfd sp!,{lr} 84 | mov r0,#0x0f 85 | b mapCDEF_ ;@ Hardwired high bank 86 | rs0: 87 | bl mapCDEF_ ;@ Map high bank 88 | ldmfd sp!,{lr} 89 | mov r0,#0x08 90 | b map89AB_ ;@ Hardwired low bank 91 | rs2: ;@ Switch 32k / low 128k: 92 | and r0,r0,#0x6 93 | rs1: ;@ Switch 32k: 94 | mov r0,r0,lsr#1 95 | b map89ABCDEF_ 96 | ;@---------------------------------------------------------------------------- 97 | hook: 98 | ;@---------------------------------------------------------------------------- 99 | ldrb_ r1,reg1 100 | tst r1,#0x10 101 | bxne lr 102 | 103 | ldr_ r0,counter 104 | add r0,r0,#113 ;@ Cycles per scanline 105 | str_ r0,counter 106 | mov r0,r0,lsr#25 107 | cmp r0,#0x10|dip ;@ DIP switch 108 | bxne lr 109 | 110 | mov r0,#1 111 | b rp2A03SetIRQPin 112 | ;@---------------------------------------------------------------------------- 113 | -------------------------------------------------------------------------------- /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/mappers/map73.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper73init 5 | 6 | .struct mapperData 7 | latch: .word 0 8 | counter: .word 0 9 | irqEn: .byte 0 10 | ;@---------------------------------------------------------------------------- 11 | .section .text,"ax" 12 | ;@---------------------------------------------------------------------------- 13 | ;@ Konami VRC3 14 | ;@ Used in: 15 | ;@ Salamander (J) 16 | mapper73init: 17 | ;@---------------------------------------------------------------------------- 18 | .word write8000,writeA000,writeC000,writeE000 19 | 20 | adr r0,hook 21 | str_ r0,scanlineHook 22 | 23 | bx lr 24 | ;@---------------------------------------------------------------------------- 25 | write8000: 26 | ;@---------------------------------------------------------------------------- 27 | ldr_ r2,latch 28 | and r0,r0,#0xF 29 | tst addy,#0x1000 30 | bne write9000 31 | bic r2,r2,#0x000F0000 32 | orr r0,r2,r0,lsl#16 33 | str_ r0,latch 34 | bx lr 35 | write9000: 36 | bic r2,r2,#0x00F00000 37 | orr r0,r2,r0,lsl#20 38 | str_ r0,latch 39 | bx lr 40 | ;@---------------------------------------------------------------------------- 41 | writeA000: 42 | ;@---------------------------------------------------------------------------- 43 | ldr_ r2,latch 44 | and r0,r0,#0xF 45 | tst addy,#0x1000 46 | bne writeB000 47 | bic r2,r2,#0x0F000000 48 | orr r0,r2,r0,lsl#24 49 | str_ r0,latch 50 | bx lr 51 | writeB000: 52 | bic r2,r2,#0xF0000000 53 | orr r0,r2,r0,lsl#28 54 | str_ r0,latch 55 | bx lr 56 | ;@---------------------------------------------------------------------------- 57 | writeC000: 58 | ;@---------------------------------------------------------------------------- 59 | tst addy,#0x1000 60 | bne writeD000 61 | strb_ r0,irqEn 62 | tst r0,#2 ;@ Timer enabled? 63 | ldrne_ r0,latch 64 | strne_ r0,counter 65 | mov r0, #0 66 | b rp2A03SetIRQPin 67 | writeD000: ;@ irqAck 68 | ldrb_ r0,irqEn 69 | bic r0,r0,#2 ;@ Disable Timer. 70 | orr r0,r0,r0,lsl#1 ;@ Move repeat bit to Enable bit 71 | strb_ r0,irqEn 72 | mov r0, #0 73 | b rp2A03SetIRQPin 74 | ;@---------------------------------------------------------------------------- 75 | writeE000: 76 | ;@---------------------------------------------------------------------------- 77 | tst addy,#0x1000 78 | bne map89AB_ 79 | bx lr 80 | ;@---------------------------------------------------------------------------- 81 | hook: 82 | ;@---------------------------------------------------------------------------- 83 | ldrb_ r0,irqEn 84 | tst r0,#2 ;@ Timer active? 85 | bxeq lr 86 | 87 | ldr_ r2,counter 88 | ldr r1,=0x71aaab ;@ 113.66667 (Cycles per scanline) 89 | tst r0,#4 ;@ 8-bit timer? 90 | bne timer8bit 91 | 92 | adds r2,r2,r1 93 | bcc h0 94 | ldr_ r1,latch 95 | add r2,r2,r1 96 | takeIrq: 97 | str_ r2,counter 98 | mov r0,#1 99 | b rp2A03SetIRQPin 100 | timer8bit: 101 | mov r2,r2,ror#24 102 | adds r2,r2,r1,lsl#8 103 | ldrcs_ r1,latch 104 | addcs r2,r2,r1,lsl#8 105 | mov r2,r2,ror#8 106 | bcs takeIrq 107 | h0: 108 | str_ r2,counter 109 | bx lr 110 | ;@---------------------------------------------------------------------------- 111 | -------------------------------------------------------------------------------- /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/source/mappers/map64.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper64init 5 | 6 | .struct mapperData 7 | latch: .byte 0 8 | irqen: .byte 0 9 | rmode: .byte 0 10 | countdown: .byte 0 11 | cmd: .byte 0 12 | bank0: .byte 0 13 | reload: .byte 0 14 | ;@---------------------------------------------------------------------------- 15 | .section .text,"ax" 16 | ;@---------------------------------------------------------------------------- 17 | ;@ Tengen RAMBO-1 18 | ;@ Used in: 19 | ;@ Hard Drivin' (prototype) 20 | ;@ Klax 21 | ;@ Rolling Thunder 22 | ;@ Shinobi 23 | ;@ Skull and Crossbones 24 | ;@ Also see mapper 158 25 | mapper64init: 26 | ;@---------------------------------------------------------------------------- 27 | .word write0,write1,write2,write3 28 | 29 | adr r0,RAMBO1HSync 30 | str_ r0,scanlineHook 31 | 32 | bx lr 33 | ;@---------------------------------------------------------------------------- 34 | write0: ;@ 8000-8001 35 | ;@---------------------------------------------------------------------------- 36 | tst addy,#1 37 | streqb_ r0,cmd 38 | w8001: 39 | ldrb_ r1,cmd 40 | and r1,r1,#0xF 41 | ldrne pc,[pc,r1,lsl#2] 42 | bx lr 43 | ;@---------------------------------------------------------------------------- 44 | commandlist: .word cmd0,cmd1,chr4_,chr5_,chr6_,chr7_,map89_,mapAB_ 45 | .word cmd0x,cmd1x,void,void,void,void,void,mapCD_ 46 | ;@---------------------------------------------------------------------------- 47 | 48 | cmd0: @0000-07ff 49 | ldrb_ r1,cmd 50 | tst r1,#0x20 51 | bne chr0_ 52 | mov r0,r0,lsr#1 53 | b chr01_ 54 | cmd1: @0800-0fff 55 | ldrb_ r1,cmd 56 | tst r1,#0x20 57 | bne chr2_ 58 | mov r0,r0,lsr#1 59 | b chr23_ 60 | 61 | cmd0x: @1000-17ff 62 | ldrb_ r1,cmd 63 | tst r1,#0x20 64 | bxeq lr 65 | b chr1_ 66 | cmd1x: @1800-1fff 67 | ldrb_ r1,cmd 68 | tst r1,#0x20 69 | bxeq lr 70 | b chr3_ 71 | ;@---------------------------------------------------------------------------- 72 | write1: ;@ A000-A001 73 | ;@---------------------------------------------------------------------------- 74 | tst addy,#1 75 | bxne lr 76 | tst r0,#1 77 | b mirror2V_ 78 | ;@---------------------------------------------------------------------------- 79 | write2: ;@ C000-C001 80 | ;@---------------------------------------------------------------------------- 81 | ands addy,addy,#1 82 | streqb_ r0,latch 83 | strneb_ r0,rmode 84 | movne r0,#0 85 | strneb_ r0,countdown 86 | bx lr 87 | ;@---------------------------------------------------------------------------- 88 | write3: ;@ E000-E001 89 | ;@---------------------------------------------------------------------------- 90 | ands r0,addy,#1 91 | strb_ r0,irqen 92 | beq rp2A03SetIRQPin 93 | bx lr 94 | ;@---------------------------------------------------------------------------- 95 | RAMBO1HSync: 96 | ;@---------------------------------------------------------------------------- 97 | @ ldrb r0,ppuCtrl1 98 | @ tst r0,#0x18 ;@ No sprite/BG enable? 0x18 99 | @ bxeq lr ;@ Bye.. 100 | 101 | ldr_ r0,scanline 102 | cmp r0,#240 ;@ Not rendering? 103 | bxhi lr ;@ Bye.. 104 | 105 | ldrb_ r0,countdown 106 | subs r0,r0,#1 107 | ldrmib_ r0,latch 108 | strb_ r0,countdown 109 | bxne lr 110 | 111 | ldrb_ r0,irqen 112 | cmp r0,#0 113 | bne rp2A03SetIRQPin 114 | bx lr 115 | ;@---------------------------------------------------------------------------- 116 | -------------------------------------------------------------------------------- /arm9/source/mappers/map33.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper33init 5 | .global mapper48init 6 | 7 | .struct mapperData 8 | latch: .byte 0 9 | irqEn: .byte 0 10 | .byte 0 11 | counter: .byte 0 12 | 13 | mSwitch: .byte 0 14 | ;@---------------------------------------------------------------------------- 15 | .section .text,"ax" 16 | ;@---------------------------------------------------------------------------- 17 | ;@ Taito TC0190 18 | ;@ Used in: 19 | ;@ Akira 20 | ;@ Bakushou!! Jinsei Gekijou 21 | ;@ Don Doko Don 22 | ;@ Insector X 23 | mapper33init: 24 | ;@---------------------------------------------------------------------------- 25 | ;@ Taito TC0690 26 | ;@ Used in: 27 | ;@ Bakushou!! Jinsei Gekijou 3 28 | ;@ Bubble Bobble 2 (J) 29 | ;@ Captain Saver (J) 30 | ;@ Don Doko Don 2 31 | ;@ Flintstones, The - The Rescue of Dino & Hoppy (J) 32 | ;@ Jetsons, The - Cogswell's Caper! (J) 33 | mapper48init: 34 | ;@---------------------------------------------------------------------------- 35 | .word write8000,writeA000,writeC000,writeE000 36 | 37 | adr r0,hook 38 | str_ r0,scanlineHook 39 | 40 | bx lr 41 | ;@---------------------------------------------------------------------------- 42 | write8000: 43 | ;@---------------------------------------------------------------------------- 44 | and addy,addy,#3 45 | ldr pc,[pc,addy,lsl#2] 46 | nop 47 | write8tbl: .word w80,mapAB_,chr01_,chr23_ 48 | w80: 49 | ldrb_ r1,mSwitch 50 | tst r1,#0xFF 51 | bne map89_ 52 | stmfd sp!,{r0,lr} 53 | tst r0,#0x40 54 | bl mirror2V_ 55 | ldmfd sp!,{r0,lr} 56 | b map89_ 57 | 58 | ;@---------------------------------------------------------------------------- 59 | writeA000: 60 | ;@---------------------------------------------------------------------------- 61 | and addy,addy,#3 62 | ldr r1,=writeCHRTBL+4*4 @chr4_,chr5_,chr6_,chr7_ 63 | ldr pc,[r1,addy,lsl#2] 64 | ;@---------------------------------------------------------------------------- 65 | writeC000: @ Only mapper 48 66 | ;@---------------------------------------------------------------------------- 67 | ands addy,addy,#3 68 | streqb_ r0,latch 69 | bxeq lr 70 | cmp addy,#2 71 | mov r0,addy 72 | movhi r0,#0 73 | strplb_ r0,irqEn 74 | bhi rp2A03SetIRQPin 75 | ldrmib_ r0,latch 76 | strmib_ r0,counter 77 | bx lr 78 | ;@---------------------------------------------------------------------------- 79 | writeE000: @ Only mapper 48 80 | ;@---------------------------------------------------------------------------- 81 | mov r1,#1 82 | strb_ r1,mSwitch 83 | tst r0,#0x40 84 | b mirror2V_ 85 | ;@---------------------------------------------------------------------------- 86 | hook: 87 | ;@---------------------------------------------------------------------------- 88 | ldrb_ r0,ppuCtrl1 89 | tst r0,#0x18 ;@ No sprite/BG enable? 90 | bxeq lr ;@ Bye.. 91 | 92 | ldr_ r0,scanline 93 | cmp r0,#1 ;@ Not rendering? 94 | bxlt lr ;@ Bye.. 95 | 96 | ldr_ r0,scanline 97 | cmp r0,#240 ;@ Not rendering? 98 | bxhi lr ;@ Bye.. 99 | 100 | ldr_ r0,latch 101 | tst r0,#0x200 ;@ irq timer active? 102 | bxeq lr 103 | 104 | adds r0,r0,#0x01000000 ;@ counter++ 105 | bcc h0 106 | 107 | strb_ r0,counter ;@ Copy latch to counter 108 | mov r0,#1 109 | b rp2A03SetIRQPin 110 | h0: 111 | str_ r0,latch 112 | bx lr 113 | ;@---------------------------------------------------------------------------- 114 | -------------------------------------------------------------------------------- /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 | 101 | void setLightGun(bool enable); 102 | void autofire_fresh(void); 103 | 104 | void menu_shortcut_start(void); 105 | void menu_shortcut_func(void); 106 | 107 | void menu_config_start(void); 108 | void menu_config_func(void); 109 | 110 | void menu_about_start(void); 111 | void menu_about_action(void); 112 | void menu_extra_fds(void); 113 | void menu_extra_barcode(void); 114 | void menu_saveini(void); 115 | void menu_extra_barcode_start(void); 116 | 117 | void show_all_pixel(void); 118 | 119 | void setJoyPort1(int joyType); // From io.s 120 | -------------------------------------------------------------------------------- /arm9/source/mappers/map18.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper18init 5 | 6 | .struct mapperData 7 | prgXX: .word 0 8 | chrXX: .word 0, 0 9 | latch: .word 0 10 | counter: .word 0 11 | irqEn: .byte 0 12 | ;@---------------------------------------------------------------------------- 13 | .section .text,"ax" 14 | ;@---------------------------------------------------------------------------- 15 | ;@ Jaleco SS8806 16 | ;@ Used in: 17 | ;@ The Lord of King 18 | ;@ Magic John 19 | ;@ Pizza Pop 20 | mapper18init: 21 | ;@---------------------------------------------------------------------------- 22 | .word write8000,writeA000,writeC000,writeE000 23 | 24 | adr r0,hook 25 | str_ r0,scanlineHook 26 | 27 | bx lr 28 | ;@---------------------------------------------------------------------------- 29 | write8000: 30 | ;@---------------------------------------------------------------------------- 31 | writeA000: 32 | ;@---------------------------------------------------------------------------- 33 | writeC000: @addy=A/B/C/Dxxx 34 | ;@---------------------------------------------------------------------------- 35 | and r1,addy,#3 36 | and addy,addy,#0x7000 37 | orr r1,r1,addy,lsr#10 38 | movs r1,r1,lsr#1 39 | 40 | adrl_ addy,prgXX 41 | and r0,r0,#0xF 42 | ldrb r2,[addy,r1] 43 | 44 | andcc r2,r2,#0xF0 45 | orrcc r0,r2,r0 46 | andcs r2,r2,#0xF 47 | orrcs r0,r2,r0,lsl#4 48 | strb r0,[addy,r1] 49 | 50 | cmp r1,#4 51 | ldrge addy,=writeCHRTBL-4*4 52 | adrlo addy,write8tbl 53 | ldr pc,[addy,r1,lsl#2] 54 | 55 | 56 | write8tbl: .word map89_,mapAB_,mapCD_,void 57 | ;@---------------------------------------------------------------------------- 58 | writeE000: 59 | ;@---------------------------------------------------------------------------- 60 | and r1,addy,#3 61 | tst addy,#0x1000 62 | orrne r1,r1,#4 63 | 64 | and r0,r0,#0xF 65 | ldr_ r2,latch 66 | ldr pc,[pc,r1,lsl#2] 67 | nop 68 | writeFtbl: .word wE0,wE1,wE2,wE3,wF0,wF1,wF2,void 69 | 70 | wE0: @- - - - - - - - - - - - - - - 71 | bic r2,r2,#0xF 72 | orr r0,r2,r0 73 | str_ r0,latch 74 | bx lr 75 | wE1: @- - - - - - - - - - - - - - - 76 | bic r2,r2,#0xF0 77 | orr r0,r2,r0,lsl#4 78 | str_ r0,latch 79 | bx lr 80 | wE2: @- - - - - - - - - - - - - - - 81 | bic r2,r2,#0xF00 82 | orr r0,r2,r0,lsl#8 83 | str_ r0,latch 84 | bx lr 85 | wE3: @- - - - - - - - - - - - - - - 86 | bic r2,r2,#0xF000 87 | orr r0,r2,r0,lsl#12 88 | str_ r0,latch 89 | bx lr 90 | wF0: @- - - - - - - - - - - - - - - 91 | str_ r2,counter 92 | mov r0,#0 93 | b rp2A03SetIRQPin 94 | wF1: @- - - - - - - - - - - - - - - 95 | strb_ r0,irqEn 96 | mov r0,#0 97 | b rp2A03SetIRQPin 98 | wF2: @- - - - - - - - - - - - - - - 99 | movs r1,r0,lsr#2 100 | tst r0,#1 101 | bcc mirror2H_ 102 | bcs mirror1_ 103 | 104 | ;@---------------------------------------------------------------------------- 105 | hook: 106 | ;@---------------------------------------------------------------------------- 107 | ldrb_ r0,irqEn 108 | tst r0,#1 ;@ Timer active? 109 | bxeq lr 110 | 111 | ldr_ r0,counter 112 | cmp r0,#0 ;@ Timer active? 113 | bxeq lr 114 | subs r0,r0,#113 ;@ counter-A 115 | bhi h0 116 | 117 | mov r0,#0 118 | str_ r0,counter ;@ Clear counter and IRQenable. 119 | strb_ r0,irqEn 120 | mov r0,#1 121 | b rp2A03SetIRQPin 122 | h0: 123 | str_ r0,counter 124 | bx lr 125 | ;@---------------------------------------------------------------------------- 126 | -------------------------------------------------------------------------------- /arm9/source/mappers/map19.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper19init 5 | 6 | .struct mapperData 7 | counter: .word 0 8 | enable: .byte 0 9 | reg0: .byte 0 10 | reg1: .byte 0 11 | ;@---------------------------------------------------------------------------- 12 | .section .text,"ax" 13 | ;@---------------------------------------------------------------------------- 14 | ;@ Namco 129 & Namco 163 15 | ;@ Used in: 16 | ;@ Digital Devil Story: Megami Tensei II 17 | ;@ Final Lap 18 | ;@ Hydlide 3 19 | ;@ Star Wars 20 | mapper19init: 21 | ;@---------------------------------------------------------------------------- 22 | .word map19_8,map19_A,map19_C,map19_E 23 | 24 | adr r1,write0 25 | str_ r1,rp2A03MemWrite 26 | 27 | adr r1,map19_r 28 | str_ r1,rp2A03MemRead 29 | 30 | adr r0,hook 31 | str_ r0,scanlineHook 32 | 33 | ldr r0,=VRAM_chr ;@ Enable chr write 34 | ldr r1,=vram_write_tbl 35 | mov r2,#8 36 | b filler 37 | 38 | ;@---------------------------------------------------------------------------- 39 | write0: 40 | cmp addy,#0x4800 41 | blo empty_W 42 | and r1,addy,#0x7800 43 | cmp r1,#0x5000 44 | streqb_ r0,counter+2 45 | moveq r0,#0 46 | beq rp2A03SetIRQPin 47 | 48 | cmp r1,#0x5800 49 | bxne lr 50 | strb_ r0,counter+3 51 | and r0,r0,#0x80 52 | strb_ r0,enable 53 | mov r0,#0 54 | b rp2A03SetIRQPin 55 | ;@---------------------------------------------------------------------------- 56 | map19_r: 57 | cmp addy,#0x4800 58 | blo empty_R 59 | mov r0, #0 60 | 61 | and r1,addy,#0x7800 62 | 63 | cmp r1,#0x5000 64 | ldreqb_ r0,counter+2 65 | bxeq lr 66 | 67 | cmp r1,#0x5800 68 | ldreqb_ r0,counter+3 69 | biceq r0, r0, #0x80 70 | bx lr 71 | 72 | ;@---------------------------------------------------------------------------- 73 | map19_8: 74 | cmp r0, #0xE0 75 | bcc 0f 76 | ldrb_ r1, reg0 77 | ands r1, r1, r1 78 | beq 1f 79 | 0: 80 | and r1,addy,#0x7800 81 | ldr r2,=writeCHRTBL 82 | ldr pc,[r2,r1,lsr#9] 83 | 84 | map19_A: 85 | cmp r0, #0xE0 86 | bcc 0f 87 | ldrb_ r1, reg1 88 | ands r1, r1, r1 89 | beq 1f 90 | 0: 91 | and r1,addy,#0x7800 92 | ldr r2,=writeCHRTBL 93 | ldr pc,[r2,r1,lsr#9] 94 | 95 | 1: 96 | and r1,addy,#0x7800 97 | and r0, r0, #0x1F 98 | mov r1, r1, lsr#11 99 | b chr1k 100 | 101 | map19_C: ;@ Do NameTable RAMROM change, for mirroring. 102 | cmp r0, #0xE0 103 | bxcc lr 104 | 105 | mov r1, addy, lsr#11 106 | and r0, r0, #1 107 | and r1, r1, #3 108 | ldr r2, =NES_VRAM 109 | add r2, r2, r0, lsl#11 110 | ldr r0, =vram_map+8*4 111 | add r0, r0, r1, lsl#2 112 | str r2, [r0] 113 | bx lr 114 | ;@---------------------------------------------------------------------------- 115 | map19_E: 116 | ;@---------------------------------------------------------------------------- 117 | and r1,addy,#0x7800 118 | cmp r1,#0x6000 119 | beq map89_ 120 | cmp r1,#0x7000 121 | beq mapCD_ 122 | cmp r1,#0x6800 123 | bxne lr 124 | 125 | and r1, r0, #0x40 126 | strb_ r1, reg0 127 | and r1, r0, #0x80 128 | strb_ r1, reg1 129 | b mapAB_ 130 | ;@---------------------------------------------------------------------------- 131 | hook: 132 | ;@---------------------------------------------------------------------------- 133 | @ldr_ r0, scanline 134 | @cmp r0, #100 135 | @bleq sprefresh 136 | 137 | ldrb_ r0,enable 138 | cmp r0,#0 139 | bxeq lr 140 | 141 | ldr_ r0,counter 142 | @ adds r0,r0,#0x71aaab @113.66667 143 | adds r0,r0,#0x720000 144 | str_ r0,counter 145 | bxcc lr 146 | 147 | mov r0,#0 148 | strb_ r0,enable 149 | sub r0,r0,#0x10000 150 | str_ r0,counter 151 | b rp2A03SetIRQPin 152 | -------------------------------------------------------------------------------- /arm9/source/mappers/map252.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper252init 5 | 6 | .struct mapperData 7 | latch: .byte 8 | irqen: .byte 9 | k4irq: .byte 10 | counter: .byte 11 | 12 | reg0: .word 13 | reg2: .word 14 | reg4: .word 15 | reg6: .word 16 | ;@---------------------------------------------------------------------------- 17 | .section .text,"ax" 18 | ;@---------------------------------------------------------------------------- 19 | ;@ Waixing VRC4 clone 20 | ;@ Used in: 三国志: 中原の覇者 (Sangokushi: Chūgen no Hasha) 21 | ;@ See also mapper 253 22 | mapper252init: 23 | ;@---------------------------------------------------------------------------- 24 | .word write89, writeAB, writeCD, writeEF 25 | 26 | ldr r0, =0x0100 27 | str_ r0, reg0 28 | ldr r0, =0x0302 29 | str_ r0, reg2 30 | ldr r0, =0x0504 31 | str_ r0, reg4 32 | ldr r0, =0x0706 33 | str_ r0, reg6 34 | 35 | stmfd sp!, {lr} 36 | bl Konami_Init 37 | 38 | mov r0, #0 39 | bl chr01234567_ 40 | 41 | ldr r0,=VRAM_chr ;@ Enable/disable chr write 42 | ldr r1,=vram_write_tbl 43 | mov r2,#8 44 | bl filler 45 | 46 | adr r0, frameHook 47 | str_ r0, newFrameHook 48 | 49 | ldmfd sp!, {pc} 50 | 51 | ;@-------------- 52 | write89: 53 | tst addy, #0x1000 54 | beq map89_ 55 | bx lr 56 | 57 | ;@---------------------------------------------------------------------------- 58 | writeAB: 59 | tst addy, #0x1000 ;@ addy=0xB*** 60 | beq mapAB_ 61 | 62 | and r0, r0, #0xF 63 | and r1, addy, #0xC 64 | mov r0, r0, lsl r1 65 | mov r2, #0xF 66 | mov r1, r2, lsl r1 67 | ldr_ r2, reg0 68 | bic r2, r2, r1 69 | orr r2, r2, r0 70 | str_ r2, reg0 71 | tst addy, #0x8 72 | movne r0, r2, lsr#8 73 | bne chr1_ 74 | and r0, r2, #0xFF 75 | b chr0_ 76 | 77 | ;@---------------------------------------------------------------------------- 78 | writeCD: 79 | ;@---------------------------------------------------------------------------- 80 | tst addy, #0x1000 ;@ addy=0xD*** 81 | bne d0 82 | 83 | and r0, r0, #0xF 84 | and r1, addy, #0xC 85 | mov r0, r0, lsl r1 86 | mov r2, #0xF 87 | mov r1, r2, lsl r1 88 | ldr_ r2, reg2 89 | bic r2, r2, r1 90 | orr r2, r2, r0 91 | str_ r2, reg2 92 | tst addy, #0x8 93 | movne r0, r2, lsr#8 94 | bne chr3_ 95 | and r0, r2, #0xFF 96 | b chr2_ 97 | 98 | d0: 99 | and r0, r0, #0xF 100 | and r1, addy, #0xC 101 | mov r0, r0, lsl r1 102 | mov r2, #0xF 103 | mov r1, r2, lsl r1 104 | ldr_ r2, reg4 105 | bic r2, r2, r1 106 | orr r2, r2, r0 107 | str_ r2, reg4 108 | tst addy, #0x8 109 | movne r0, r2, lsr#8 110 | bne chr5_ 111 | and r0, r2, #0xFF 112 | b chr4_ 113 | 114 | 115 | ;@---------------------------------------------------------------------------- 116 | writeEF: 117 | tst addy, #0x1000 @addy=0xF*** 118 | bne f0 119 | 120 | and r0, r0, #0xF 121 | and r1, addy, #0xC 122 | mov r0, r0, lsl r1 123 | mov r2, #0xF 124 | mov r1, r2, lsl r1 125 | ldr_ r2, reg6 126 | bic r2, r2, r1 127 | orr r2, r2, r0 128 | str_ r2, reg6 129 | tst addy, #0x8 130 | movne r0, r2, lsr#8 131 | bne chr7_ 132 | and r0, r2, #0xFF 133 | b chr6_ 134 | 135 | f0: 136 | and r1, addy, #0xC 137 | ldr pc, [pc, r1] 138 | nop 139 | .word KoLatchLo, KoLatchHi, KoIRQEnable, KoIRQack 140 | 141 | ;@------------------------ 142 | frameHook: 143 | mov r0,#-1 144 | ldr r1,=agb_obj_map 145 | str r0,[r1],#4 146 | str r0,[r1],#4 147 | str r0,[r1],#4 148 | str r0,[r1],#4 149 | 150 | mov r0,#-1 ;@ Code from resetCHR 151 | ldr r1,=agb_bg_map 152 | mov r2,#16 * 2 153 | b filler 154 | ;@---------------------------------------------------------------------------- 155 | -------------------------------------------------------------------------------- /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/mappers/map68.s: -------------------------------------------------------------------------------- 1 | ;@---------------------------------------------------------------------------- 2 | #include "equates.h" 3 | ;@---------------------------------------------------------------------------- 4 | .global mapper68init 5 | 6 | .struct mapperData 7 | reg0: .byte 0 8 | reg1: .byte 0 9 | reg2: .byte 0 10 | reg3: .byte 0 11 | bankCache: .space 4 12 | ;@---------------------------------------------------------------------------- 13 | .section .text,"ax" 14 | ;@---------------------------------------------------------------------------- 15 | ;@ Sunsoft-4 16 | ;@ Used in: 17 | ;@ After Burner... 18 | mapper68init: 19 | ;@---------------------------------------------------------------------------- 20 | .word write0,write1,write2,write3 21 | mov r0, #-1 22 | str_ r0, bankCache 23 | 24 | bx lr 25 | ;@---------------------------------------------------------------------------- 26 | write0: 27 | ;@---------------------------------------------------------------------------- 28 | tst addy,#0x1000 29 | bne chr23_ 30 | b chr01_ 31 | ;@---------------------------------------------------------------------------- 32 | write1: 33 | ;@---------------------------------------------------------------------------- 34 | tst addy,#0x1000 35 | bne chr67_ 36 | b chr45_ 37 | ;@---------------------------------------------------------------------------- 38 | write2: 39 | ;@---------------------------------------------------------------------------- 40 | tst addy, #0x1000 41 | streqb_ r0, reg2 42 | strneb_ r0, reg3 43 | /* 44 | stmfd sp!, {lr} 45 | add r0, r0, #0x80 46 | moveq r1, #8 47 | movne r1, #9 48 | bl chr1k 49 | ldmfd sp!, {lr} 50 | */ 51 | b setNTManualy 52 | ;@---------------------------------------------------------------------------- 53 | write3: 54 | ;@---------------------------------------------------------------------------- 55 | tst addy,#0x1000 56 | bne map89AB_ 57 | 58 | and r2, r0, #3 59 | strb_ r2, reg1 60 | tst r0,#0x10 61 | bne setNTManualy 62 | b mirrorKonami_ 63 | ;@---------------------- 64 | setNTManualy: 65 | stmfd sp!, {r3-r9, lr} 66 | ldr_ r3, vmemBase 67 | add r3, r3, #(0x80<<10) ;@ Cal the base 68 | ldrb_ r4, reg2 69 | ldrb_ r5, reg3 70 | 71 | @add r4, r3, r4, lsl#10 ;@ First bank 72 | @add r5, r3, r5, lsl#10 ;@ Second bank 73 | 74 | ldr r2, =NDS_BG + 0x2000 ;@ Point to a free Map area. 75 | ldrb_ r0, bankCache 76 | cmp r0, r4 77 | strneb_ r4, bankCache 78 | addne r4, r3, r4, lsl#10 ;@ First bank 79 | blne freshBank 80 | 81 | ldr r2, =NDS_BG + 0x2800 82 | ldrb_ r0, bankCache + 1 83 | cmp r0, r5 84 | strneb_ r5, bankCache +1 85 | addne r4, r3, r5, lsl#10 ;@ Second bank 86 | blne freshBank 87 | 88 | mov r0, #0x1C00 ;@ Change the map base 89 | ldrb_ r1, reg1 90 | cmp r1, #0 91 | addeq r0, r0, #0x4000 92 | cmp r1, #1 93 | addeq r0, r0, #0x8000 94 | cmp r1, #3 95 | addeq r0, r0, #0x0100 96 | str_ r0, bg0Cnt 97 | 98 | ldmfd sp!, {r3-r9, pc} 99 | 100 | ;@------------------------ 101 | freshBank: 102 | add r6, r4, #0x3C0 ;@ The tile attr base. 103 | adr r7, ntData 104 | mov r9, #8*8 105 | 106 | ntLoop: 107 | ldrb r8, [r6], #1 108 | and r0, r8, #3 109 | strb r0, [r7] 110 | mov r8, r8, lsr#2 111 | and r0, r8, #3 112 | strb r0, [r7, #1] 113 | mov r8, r8, lsr#2 114 | and r0, r8, #3 115 | strb r0, [r7, #16] 116 | mov r8, r8, lsr#2 117 | strb r8, [r7, #17] 118 | 119 | subs r9, r9, #1 120 | beq 0f 121 | tst r9, #7 ;@ One row will be 8 bytes 122 | addne r7, r7, #2 123 | addeq r7, r7, #18 124 | b ntLoop 125 | 126 | 0: 127 | mov r6, #0 128 | adr r7, ntData 129 | 130 | tilenumLoop: 131 | mov r1, r6, lsr#6 132 | and r0, r6, #0x1e 133 | mov r0, r0, lsr#1 134 | add r0, r0, r1, lsl#4 135 | 136 | ldrb r1, [r7, r0] 137 | and r1, r1, #3 138 | ldrb r0, [r4], #1 139 | orr r0, r0, r1, lsl#12 140 | strh r0, [r2], #2 141 | add r6, r6, #1 142 | cmp r6, #32*30 143 | bcc tilenumLoop 144 | 145 | bx lr 146 | 147 | ;@---------------------------------------------------------------------------- 148 | ntData: 149 | .space 8*8*2*2 150 | --------------------------------------------------------------------------------