diff --git a/NOTES.TXT b/NOTES.TXT index 0836be7..300c2b8 100644 --- a/NOTES.TXT +++ b/NOTES.TXT @@ -25,7 +25,7 @@ IPC 27fff00 -> 2800000 (uncached) scratch memory is (Image$$EWRAM$$ZI$$Limit -> 23f8000), used for file list storage, rom storage, game recording other ptrs: - rombase = Image$$EWRAM$$ZI$$Limit + romBase = Image$$EWRAM$$ZI$$Limit freemem_start = end of rom freemem_end=23f8000 (all of freemem_start -> end is used for recording) @@ -43,4 +43,4 @@ H=SUB BG 6200000-6207fff I 6000000-605e000 MAIN CHR (#? chr banks) -605e000 MAIN SCR \ No newline at end of file +605e000 MAIN SCR diff --git a/README.TXT b/README.TXT index deec48c..3d6921d 100644 --- a/README.TXT +++ b/README.TXT @@ -105,7 +105,7 @@ dswifix(which is for nifi) src is added. Mapper240 added. fixed the tmpfile. DPCM weakened, sounds better? -A bug with ppustat fixed. e.g.'teenage mutant ninja turtles' +A bug with ppuStat fixed. e.g.'teenage mutant ninja turtles' A bug with palette fixed. Patch update. Battleloads (Europe) added. SRAM can be saved whatever a game supports. @@ -452,7 +452,7 @@ IPC 27fff00 -> 2800000 (uncached) scratch memory is (Image$$EWRAM$$ZI$$Limit -> 23f8000), used for file list storage, rom storage, game recording other ptrs: - rombase = Image$$EWRAM$$ZI$$Limit + romBase = Image$$EWRAM$$ZI$$Limit freemem_start = end of rom freemem_end=23f8000 (all of freemem_start -> end is used for recording) @@ -470,4 +470,4 @@ H=SUB BG 6200000-6207fff I 6000000-605e000 MAIN CHR (#? chr banks) -605e000 MAIN SCR \ No newline at end of file +605e000 MAIN SCR diff --git a/arm7/source/s_apu.c b/arm7/source/s_apu.c index 7ba4ac2..7fac4e9 100644 --- a/arm7/source/s_apu.c +++ b/arm7/source/s_apu.c @@ -159,7 +159,7 @@ static const Uint32 spd_limit_table[8] = 0x787, 0x7C1, 0x7E0, 0x7F0, }; -static Uint32 dpcm_freq_table[16] = +static const Uint32 dpcm_freq_table[16] = { 428, 380, 340, 320, 286, 254, 226, 214, diff --git a/arm9/include/6502mac.h b/arm9/include/6502mac.h index 8756ebf..1e119f9 100644 --- a/arm9/include/6502mac.h +++ b/arm9/include/6502mac.h @@ -27,9 +27,9 @@ N = 0x80 .macro encodePC @translate from 6502 PC to rom offset and r1,m6502_pc,#0xE000 - adr_ r2,memmap_tbl + adr_ r2,m6502ReadTbl ldr r0,[r2,r1,lsr#11] - str_ r0,lastbank + str_ r0,m6502LastBank add m6502_pc,m6502_pc,r0 .endm @@ -127,7 +127,7 @@ N = 0x80 .macro writememabs and r1,addy,#0xe000 - adr_ r2,writemem_tbl + adr_ r2,m6502WriteTbl adr lr,0f ldr pc,[r2,r1,lsr#11] @in: addy,r0=val(bits 8-31=?) 0: @out: r0,r1,r2,addy=? diff --git a/arm9/include/equates.h b/arm9/include/equates.h index 819816e..86afb6d 100644 --- a/arm9/include/equates.h +++ b/arm9/include/equates.h @@ -32,24 +32,21 @@ KEY_Y = 2048 KEY_TOUCH = 4096 @DMA buffers go in high RAM - stay below 27ffc00 (firmware settings) -.global nes_region -.global ct_buffer - DISPCNTBUFF = ct_buffer BGCNTBUFF = DISPCNTBUFF + 512*4 @size is 240*16 BGCNTBUFFB = BGCNTBUFF + 256 * 16 @miscellaneous stuff - + NES_RAM = nes_region @keep $400 byte aligned for 6502 stack NES_SRAM = NES_RAM+0x0800 @***!!! also in c_defs.h NES_VRAM = NES_SRAM+0x2000 NES_XRAM = NES_VRAM+0x3000 CHR_DECODE = NES_XRAM+0x2000 -MAPPED_RGB = CHR_DECODE+0x400 -NES_SPRAM = MAPPED_RGB+0x100 @mapped NES palette (for VS unisys) +MAPPED_RGB = CHR_DECODE+0x400 @mapped NES palette (for VS unisys) +NES_SPRAM = MAPPED_RGB+0x100 @? EQU MAPPED_RGB+64*3 - + NDS_PALETTE = 0x5000000 NDS_VRAM = 0x6000000 NDS_SRAM = 0xA000000 @@ -96,7 +93,7 @@ REG_BLDALPHA = 0x52 @r0,r1,r2=temp regs m6502_nz .req r3 @bit 31=N, Z=1 if bits 0-7=0 -m6502_rmem .req r4 @readmem_tbl +m6502_rmem .req r4 @m6502ReadTbl m6502_a .req r5 @bits 0-23=0, also used to clear bytes in memory m6502_x .req r6 @bits 0-23=0 m6502_y .req r7 @bits 0-23=0 @@ -120,61 +117,60 @@ addy .req r12 @keep this at r12 (scratch for APCS) start_map 0,globalptr @6502.s _m_ opz,256*4 -_m_ readmem_tbl,8*4 -_m_ writemem_tbl,8*4 -_m_ memmap_tbl,8*4 +_m_ m6502ReadTbl,8*4 +_m_ m6502WriteTbl,8*4 +_m_ m6502MemTbl,8*4 _m_ cpuregs,7*4 _m_ m6502_s,4 -_m_ lastbank,4 +_m_ m6502LastBank,4 _m_ nexttimeout,4 _m_ scanline,4 -_m_ scanlinehook,4 +_m_ scanlineHook,4 _m_ frame,4 -_m_ cyclesperscanline,4 -_m_ lastscanline,4 +_m_ cyclesPerScanline,4 +_m_ lastScanline,4 _m_ unused_align,4 @ppu.s -_m_ fpsvalue,4 -_m_ adjustblend,4 +_m_ fpsValue,4 +_m_ adjustBlend,4 @ppustate: -_m_ vramaddr,4 -_m_ vramaddr2,4 +_m_ vramAddr,4 +_m_ vramAddr2,4 _m_ scrollX,4 _m_ scrollY,4 _m_ scrollYtemp,4 _m_ sprite0y,4 -_m_ readtemp,4 -_m_ bg0cnt,4 +_m_ readTemp,4 +_m_ bg0Cnt,4 _m_ sprite0x,1 -_m_ vramaddrinc,1 -_m_ ppustat,1 +_m_ vramAddrInc,1 +_m_ ppuStat,1 _m_ toggle,1 -_m_ ppuctrl0,1 -_m_ ppuctrl0frame,1 -_m_ ppuctrl1,1 -_m_ ppuoamadr,1 -_m_ nes_chr_map,16 +_m_ ppuCtrl0,1 +_m_ ppuCtrl0Frame,1 +_m_ ppuCtrl1,1 +_m_ ppuOamAdr,1 +_m_ nesChrMap,16 -_m_ vrommask,4 -_m_ vrombase,4 +_m_ vromMask,4 +_m_ vromBase,4 @cart.s -_m_ newframehook,4 -_m_ endframehook,4 -_m_ hblankhook,4 -_m_ ppuchrlatch,4 -_m_ mapperdata,96 -_m_ rombase,4 - -_m_ rommask,4 @ADDED -_m_ romnumber,4 @ADDED -_m_ prgsize8k,4 @ADDED -_m_ prgsize16k,4 @ADDED -_m_ prgsize32k,4 @ADDED -_m_ emuflags,4 @ADDED +_m_ newFrameHook,4 +_m_ endFrameHook,4 +_m_ hblankHook,4 +_m_ ppuChrLatch,4 +_m_ mapperData,96 + +_m_ romBase,4 +_m_ romMask,4 +_m_ prgSize8k,4 +_m_ prgSize16k,4 +_m_ prgSize32k,4 +_m_ emuFlags,4 _m_ prgcrc,4 -_m_ lighty,4 +_m_ lightY,4 _m_ loopy_t,4 _m_ loopy_x,4 @@ -182,8 +178,8 @@ _m_ loopy_y,4 _m_ loopy_v,4 _m_ loopy_shift,4 _m_ bglastline, 4 -_m_ rendercount, 4 -_m_ tempdata, 20*4 +_m_ renderCount, 4 +_m_ tempData, 20*4 _m_ nsfid, 5 _m_ nsfversion, 1 @@ -206,14 +202,14 @@ _m_ nsfinit, 4 _m_ nsfsongno, 4 _m_ nsfsongmode, 4 -_m_ pixstart, 4 -_m_ pixend, 4 +_m_ pixStart, 4 +_m_ pixEnd, 4 -_m_ af_st, 4 @auto fire state +_m_ af_state, 4 @auto fire state _m_ af_start, 4 @auto fire start _m_ palsyncline, 4 -_m_ cartflags,1 @ADDED +_m_ cartFlags,1 _m_ barcode, 1 _m_ barcode_out, 1 @_m_ ,1 @align @ADDED @@ -228,13 +224,13 @@ P2_ENABLE = 0x20000 B_A_SWAP = 0x80000 L_R_DISABLE = 0x100000 AUTOFIRE = 0x1000000 -@-----------------------cartflags +@-----------------------cartFlags MIRROR = 0x01 @horizontal mirroring SRAM = 0x02 @save SRAM TRAINER = 0x04 @trainer present SCREEN4 = 0x08 @4way screen layout VS = 0x10 @VS unisystem -@-----------------------emuflags (keep c_defs.h updated) +@-----------------------emuFlags (keep c_defs.h updated) NOFLICKER = 1 @flags&3: 0=flicker 1=noflicker 2=alphalerp ALPHALERP = 2 @@ -257,12 +253,10 @@ REWIND = 0x40000 ALLPIXELON = 0x80000 NSFFILE = 0x100000 DISKBIOS = 0x200000 -@? EQU 64 -@? EQU 128 @------------------------multi-players -@in everyframe, 64bit sould be transfered. 32bit = IPC_KEYS, 32bit = CONTROL_BIT +@in every frame, 64bit should be transfered. 32bit = IPC_KEYS, 32bit = CONTROL_BIT MP_KEY_MSK = 0x0CFF @not all the keys can be transfered. MP_HOST = (1 << 31) @whether I am a host. diff --git a/arm9/source/6502.s b/arm9/source/6502.s index 90c6104..45b133c 100644 --- a/arm9/source/6502.s +++ b/arm9/source/6502.s @@ -33,14 +33,13 @@ .global __lastbank .global __sp .global __scanline - .global __nes_chr_map .global __memmap_tbl .global __rombase .global debugstep .global __rendercount .global __barcode .global __barcode_out - .global __af_st + .global __af_state .global __af_start .global __prgsize16k .global all_pix_start @@ -48,15 +47,15 @@ .global ntsc_pal_reset .global debugwrite .global debugwrite_c - .global nsfheader + .global nsfHeader - .global __nsfplay - .global __nsfinit - .global __nsfsongno - .global __nsfsongmode + .global __nsfPlay + .global __nsfInit + .global __nsfSongNo + .global __nsfSongMode -pcmirqbakup = mapperdata+24 -pcmirqcount = mapperdata+28 +pcmirqbakup = mapperData+24 +pcmirqcount = mapperData+28 @--------------------------------------------------------------------------------- .section .itcm, "ax" @--------------------------------------------------------------------------------- @@ -71,7 +70,7 @@ _00:@ BRK DEBUGCOUNT BRK bl debugstep - ldr_ r0,lastbank + ldr_ r0,m6502LastBank sub r1,m6502_pc,r0 add r0,r1,#1 push16 @save PC @@ -189,7 +188,7 @@ _1E:@ ASL $nnnn,X _20:@ JSR $nnnn @--------------------------------------------------------------------------------- ldrb r2,[m6502_pc],#1 - ldr_ r1,lastbank + ldr_ r1,m6502LastBank sub r0,m6502_pc,r1 ldrb r1,[m6502_pc] orr m6502_pc,r2,r1,lsl#8 @@ -476,7 +475,7 @@ _6A:@ ROR _6C:@ JMP ($nnnn) @--------------------------------------------------------------------------------- doABS - adr_ r1,memmap_tbl + adr_ r1,m6502MemTbl and r2,addy,#0xE000 ldr r1,[r1,r2,lsr#11] ldrb m6502_pc,[r1,addy]! @@ -1031,7 +1030,7 @@ _FE:@ INC $nnnn,X @--------------------------------------------------------------------------------- line0: mov r0,#0 - strb_ r0,ppustat @vbl clear, sprite0 clear + strb_ r0,ppuStat @vbl clear, sprite0 clear str_ r0,scanline @reset scanline count bl newframe @display update @@ -1039,17 +1038,17 @@ line0: mov r0,#0 bl ppusync - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline ldr_ r1,frame tst r1,#1 subeq r0,r0,#CYCLE @Every other frame has 1/3 less CPU cycle. add cycles,cycles,r0 adr r0,line1_to_119 str_ r0,nexttimeout - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook @--------------------------------------------------------------------------------- line1_to_119: - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0 ldr_ r0,scanline @@ -1059,20 +1058,20 @@ line1_to_119: beq line119 bl ppusync - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook @--------------------------------------------------------------------------------- line119: bl ppusync - ldrb_ r0,ppuctrl0 - strb_ r0,ppuctrl0frame @Contra likes this + ldrb_ r0,ppuCtrl0 + strb_ r0,ppuCtrl0Frame @Contra likes this adr addy,line120_to_240 str_ addy,nexttimeout - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook @--------------------------------------------------------------------------------- line120_to_240: - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0 ldr_ r0,scanline @@ -1084,7 +1083,7 @@ line120_to_240: streq_ addy,nexttimeout blne ppusync - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook @--------------------------------------------------------------------------------- line241: NMIDELAY = CYCLE*21 @@ -1092,10 +1091,10 @@ NMIDELAY = CYCLE*21 add cycles,cycles,#NMIDELAY @NMI is delayed a few cycles.. -@ ldrb r1,ppustat +@ ldrb r1,ppuStat @ orr r1,r1,#0x90 @vbl & vram write mov r1,#0x80 @vbl flag - strb_ r1,ppustat + strb_ r1,ppuStat adr addy,line241NMI str_ addy,nexttimeout @@ -1106,7 +1105,7 @@ line241NMI: add r0,r0,#1 str_ r0,frame - ldrb_ r0,ppuctrl0 + ldrb_ r0,ppuCtrl0 tst r0,#0x80 beq 0f @NMI? @@ -1125,7 +1124,7 @@ line241NMI: bl updatesound adr lr, 2f - ldr_ pc, endframehook + ldr_ pc, endFrameHook 2: ldmfd sp!,{m6502_nz-m6502_pc,globalptr,cpu_zpage,pc} @@ -1156,7 +1155,7 @@ NSF_Run: ldr r2, =0x2000/4 bl filler 0: - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0, lsl#14 ldr addy, =0x4015 @@ -1184,33 +1183,33 @@ NSF_Run: mov r0, #0 str_ r0, nsfinit - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook noinit: - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0, lsl#8 - ldr_ r1,lastbank + ldr_ r1,m6502LastBank sub m6502_pc,m6502_pc,r1 cmp m6502_pc, #0x4700 - ldrne_ pc,scanlinehook + ldrne_ pc,scanlineHook ldr m6502_pc, =0x4720 encodePC ldr r0,=NES_RAM+0x100 str_ r0, m6502_s mov m6502_a, #0 - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook noplay: - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0, lsl#8 ldr m6502_pc, =0x4700 encodePC ldr r0,=NES_RAM+0x100 str_ r0, m6502_s - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook nsf_out: adr_ r2,cpuregs @@ -1229,7 +1228,7 @@ EMU_Run: ldmia r0,{m6502_nz-m6502_pc} @restore 6502 state - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0 mov r0,#241 @@ -1238,26 +1237,26 @@ EMU_Run: adr r1,line242_to_end str_ r1,nexttimeout - ldr_ r1,emuflags + ldr_ r1,emuFlags tst r1, #NSFFILE bne NSF_Run - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook @--------------------------------------------------------------------------------- line242_to_end: - ldr_ r0,cyclesperscanline + ldr_ r0,cyclesPerScanline add cycles,cycles,r0 ldr_ r1,scanline - ldr_ r2,lastscanline + ldr_ r2,lastScanline add r1,r1,#1 str_ r1,scanline cmp r1,r2 - ldrne_ pc,scanlinehook + ldrne_ pc,scanlineHook adr addy,line0 str_ addy,nexttimeout - ldr_ pc,scanlinehook + ldr_ pc,scanlineHook @--------------------------------------------------------------------------------- pcm_scanlinehook: @--------------------------------------------------------------------------------- @@ -1268,7 +1267,7 @@ pcm_scanlinehook: b hk0 ldr_ r0,pcmirqcount -@ ldr r1,cyclesperscanline +@ ldr r1,cyclesPerScanline @ subs r0,r0,r1,lsr#4 subs r0,r0,#121 @Fire Hawk=122 str_ r0,pcmirqcount @@ -1302,7 +1301,7 @@ irq6502: @--------------------------------------------------------------------------------- Vec6502: @--------------------------------------------------------------------------------- - ldr_ r0,lastbank + ldr_ r0,m6502LastBank sub r0,m6502_pc,r0 push16 @save PC @@ -1313,7 +1312,7 @@ VecCont: orr cycles,cycles,#CYC_I @disable IRQ @ bic cycles,cycles,#CYC_D @and decimal mode - ldr_ r0,memmap_tbl+7*4 + ldr_ r0,m6502MemTbl+7*4 ldrb m6502_pc,[r0,r12]! ldrb r2,[r0,#1] orr m6502_pc,m6502_pc,r2,lsl#8 @@ -1333,15 +1332,15 @@ ntsc_pal_reset: mov r2, globalptr ldr globalptr,=globals - ldr_ r0,emuflags + ldr_ r0,emuFlags tst r0,#PALTIMING ldreq r1,=341*CYCLE @NTSC (113+2/3)*3 ldrne r1,=320*CYCLE @PAL (106+9/16)*3 - str_ r1,cyclesperscanline + str_ r1,cyclesPerScanline ldreq r1,=261 @NTSC ldrne r1,=311 @PAL - str_ r1,lastscanline + str_ r1,lastScanline mov globalptr, r2 bx lr @@ -1357,7 +1356,7 @@ CPU_reset: @called by loadcart (r0-r9 are free to use) mov m6502_x,#0 mov m6502_y,#0 mov m6502_nz,#0 - adr_ m6502_rmem,readmem_tbl + adr_ m6502_rmem,m6502ReadTbl ldr r0,=NES_RAM+0x100 str_ r0,m6502_s @S=0xFD (0x100-3) mov cycles,#0 @D=0, C=0, V=0, I=1 disable IRQ. @@ -1409,25 +1408,25 @@ op_table: .word _D0,_D1,_xx,_xx,_xx,_D5,_D6,_xx,_D8,_D9,_xx,_xx,_xx,_DD,_DE,_xx .word _E0,_E1,_xx,_xx,_E4,_E5,_E6,_xx,_E8,_E9,_EA,_xx,_EC,_ED,_EE,_xx .word _F0,_F1,_xx,_xx,_xx,_F5,_F6,_xx,_F8,_F9,_xx,_xx,_xx,_FD,_FE,_xx - @readmem_tbl + @m6502ReadTbl .word ram_R @$0000 .word PPU_R @$2000 .word IO_R @$4000 - .word sram_R @$6000 + .word mem_R60 @$6000 .word rom_R80 @$8000 .word rom_RA0 @$A000 .word rom_RC0 @$C000 .word rom_RE0 @$E000 - @writemem_tbl + @m6502WriteTbl .word ram_W @$0000 .word PPU_W @$2000 .word IO_W @$4000 .word sram_W @$6000 - .word rom_W80 @$8000 - .word rom_WA0 @$A000 - .word rom_WC0 @$C000 - .word rom_WE0 @$E000 - @memmap_tbl + .word mem_W80 @$8000 + .word mem_WA0 @$A000 + .word mem_WC0 @$C000 + .word mem_WE0 @$E000 + @m6502MemTbl __memmap_tbl: .word NES_RAM @$0000 0000-7fff .word NES_XRAM-0x2000 @$2000 should @@ -1453,16 +1452,16 @@ __pc: __sp: .word 0 @m6502_s: __lastbank: - .word 0 @lastbank: last memmap added to PC (used to calculate current PC) + .word 0 @m6502LastBank: last memmap added to PC (used to calculate current PC) .word 0 @nexttimeout: jump here when cycles runs out __scanline: .word 0 @scanline - .word 0 @scanlinehook + .word 0 @scanlineHook frametotal: @let ui.c see frame count for savestates .word 0 @frame - .word 0 @cyclesperscanline (341*CYCLE or 320*CYCLE) - .word 0 @lastscanline (261 or 311) + .word 0 @cyclesPerScanline (341*CYCLE or 320*CYCLE) + .word 0 @lastScanline (261 or 311) .word 0 @(unused, for alignment) @@ -1470,60 +1469,59 @@ frametotal: @let ui.c see frame count for savestates FPSValue: .word 0 - .word 0 @adjustblend + .word 0 @adjustBlend ppustate: - .word 0 @vramaddr - .word 0 @vramaddr2 (temp) + .word 0 @vramAddr + .word 0 @vramAddr2 (temp) .word 0 @scrollX .word 0 @scrollY .word 0 @scrollYtemp .word 0 @sprite0y - .word 0 @readtemp - .word 0 @bg0cnt (mirroring control) + .word 0 @readTemp + .word 0 @bg0Cnt (mirroring control) .byte 0 @sprite0x - .byte 1 @vramaddrinc - .byte 0 @ppustat + .byte 1 @vramAddrInc + .byte 0 @ppuStat .byte 0 @toggle - .byte 0 @ppuctrl0 - .byte 0 @ppuctrl0frame ;state of $2000 at frame start - .byte 0 @ppuctrl1 - .byte 0 @ppuoamadr + .byte 0 @ppuCtrl0 + .byte 0 @ppuCtrl0Frame ;state of $2000 at frame start + .byte 0 @ppuCtrl1 + .byte 0 @ppuOamAdr __nes_chr_map: - .skip 16 @nes_chr_map VROM map for 0000-1FFF (1k bank numbers) + .skip 16 @nesChrMap VROM map for 0000-1FFF (1k bank numbers) - .word 0 @vrommask - .word 0 @vrombase + .word 0 @vromMask + .word 0 @vromBase @ppustate end @**!! update load/savestate if you move things around in here @--- cart --- - .word void @newframehook. - .word void @endframehook, for some special VRAM mirrorings. + .word void @newFrameHook. + .word void @endFrameHook, for some special VRAM mirrorings. __hblankhook: - .word void @hblankhook, for games that need to do something when h-blank occurs. - .word void @ppuchrlatch + .word void @hblankHook, for games that need to do something when h-blank occurs. + .word void @ppuChrLatch mapperstate: - .skip 96 @mapperdata + .skip 96 @mapperData romstart: __rombase: - .word 0 @rombase + .word 0 @romBase @add others - .word 0 @rommask - .word 0 @romnumber - .word 0 @prgsize8k + .word 0 @romMask + .word 0 @prgSize8k __prgsize16k: - .word 0 @prgsize16k - .word 0 @prgsize32k + .word 0 @prgSize16k + .word 0 @prgSize32k __emuflags: - .word 0 @emuflags + .word 0 @emuFlags .word 0 @prgcrc - .word 0 @lighty + .word 0 @lightY softrdata: .word 0 @loopy_t @@ -1533,8 +1531,8 @@ softrdata: .word 0 @loopy_shift .word 0 @bglastline __rendercount: - .word 0 @rendercount - @tempdata + .word 0 @renderCount + @tempData .word 0 @tileofs .word 0 @ntbladr .word 0 @attradr @@ -1549,16 +1547,16 @@ __rendercount: .word rev_data @pBit2Rev .skip 4 * (20 - 12) -nsfheader: +nsfHeader: .skip 128 -__nsfplay: +__nsfPlay: .word 0 -__nsfinit: +__nsfInit: .word 0 -__nsfsongno: +__nsfSongNo: .word 0 -__nsfsongmode: +__nsfSongMode: .word 0 all_pix_start: @@ -1566,14 +1564,14 @@ all_pix_start: all_pix_end: .word 0 -__af_st: - .word 0 @af_st +__af_state: + .word 0 @af_state __af_start: .word 0x101 @af_start 30 fps __palsyncline: .word 0 __cartflags: - .byte 0 @cartflags + .byte 0 @cartFlags __barcode: .byte 0 __barcode_out: diff --git a/arm9/source/about.c b/arm9/source/about.c index 8941a89..d1602c0 100644 --- a/arm9/source/about.c +++ b/arm9/source/about.c @@ -215,4 +215,4 @@ int nesds_about() } return 0; -} \ No newline at end of file +} diff --git a/arm9/source/arm9main.c b/arm9/source/arm9main.c index aa14c6f..e8f77b3 100644 --- a/arm9/source/arm9main.c +++ b/arm9/source/arm9main.c @@ -35,7 +35,7 @@ void showversion() * description: NTSC for 60fps, PAL for 50fps. Call this function to sync with NES emulation. ******************************/ void vblankinterrupt() { - debuginfo[6]++; + debuginfo[VBLS]++; EMU_VBlank(); irqDisable(IRQ_VCOUNT); //we should disable this... } @@ -157,8 +157,8 @@ int main(int _argc, char **_argv) { } if(debuginfo[VBLS]>59) { debuginfo[VBLS]-=60; - debuginfo[1] = debuginfo[0]; - debuginfo[0] = 0; + debuginfo[ERR1] = debuginfo[ERR0]; + debuginfo[ERR0] = 0; debuginfo[FPS]=framecount; framecount=0; } @@ -173,23 +173,23 @@ int main(int _argc, char **_argv) { oldkey = IPC_KEYS; if(keydown & KEY_LEFT) { - if(__nsfsongno == 0) { - __nsfsongno = nsfheader.TotalSong-1; + if(__nsfSongNo == 0) { + __nsfSongNo = nsfHeader.TotalSong-1; } else { - __nsfsongno--; + __nsfSongNo--; } } if(keydown & KEY_RIGHT) { - if(++__nsfsongno > nsfheader.TotalSong-1) { - __nsfsongno = 0; + if(++__nsfSongNo > nsfHeader.TotalSong-1) { + __nsfSongNo = 0; } } if(keydown & KEY_UP) { - __nsfplay = 1; - __nsfinit = 1; + __nsfPlay = 1; + __nsfInit = 1; } if(keydown & KEY_DOWN) { - __nsfplay = 0; + __nsfPlay = 0; Sound_reset(); } } @@ -269,7 +269,7 @@ void play() { } } else { if (__emuflags & SOFTRENDER) { - if (!(forward) && (fcount >= debuginfo[6] && fcount - debuginfo[6] < 10) ) // disable VBlank to speed up emulation. + if (!(forward) && (fcount >= debuginfo[VBLS] && fcount - debuginfo[VBLS] < 10) ) // disable VBlank to speed up emulation. swiWaitForVBlank(); } else { if(!(forward)) { @@ -330,4 +330,4 @@ void play() { fcount = 0; __emuflags &= ~(FASTFORWARD | REWIND); -} \ No newline at end of file +} diff --git a/arm9/source/cart.s b/arm9/source/cart.s index 6159de2..fd9d29a 100644 --- a/arm9/source/cart.s +++ b/arm9/source/cart.s @@ -41,6 +41,7 @@ mappertbl: .word 24,mapper24init .word 25,mapper25init .word 26,mapper26init + .word 30,mapper30init .word 32,mapper32init .word 33,mapper33init .word 34,mapper34init @@ -74,6 +75,7 @@ mappertbl: .word 97,mapper97init .word 99,mapper99init .word 105,mapper105init + .word 111,mapper111init .word 118,mapper118init .word 119,mapper119init .word 140,mapper66init @@ -82,7 +84,7 @@ mappertbl: .word 153,mapper16init .word 157,mapper16init .word 158,mapper64init - .word 159,mapper159init + .word 159,mapper159init .word 163,mapper163init .word 180,mapper180init .word 184,mapper184init @@ -112,7 +114,7 @@ mappertbl: @ arguments: none @ description: none -initcart: @called from C: r0=rom, (r1=emuflags?) +initcart: @called from C: r0=rom, (r1=emuFlags?) @ @ (initialize mapper, etc after loading the rom) @--------------------------------------------------------------------------------- @@ -121,26 +123,26 @@ initcart: @called from C: r0=rom, (r1=emuflags?) ldr globalptr,=globals @init ptr regs ldr cpu_zpage,=NES_RAM - ldr_ r1,emuflags + ldr_ r1,emuFlags tst r1, #NSFFILE addeq r3,r0,#16 @skip over iNES header addne r3, r0, #128 @skip nsf file header - str_ r3,rombase @set rom base. r3=rombase til end of initcart + str_ r3,romBase @set rom base. r3=romBase til end of initcart mov r2,#1 ldrb r1,[r3,#-12] @r1 = 16K PRG-ROM page count - movne r0, #1 @nsf has 16k? - str_ r1,prgsize16k @some games' prg rom not == to (2**n), shit... + movne r1, #1 @nsf has 16k? + str_ r1,prgSize16k @some games' prg rom not == to (2**n), shit... mov r0, r1, lsl#1 - str_ r0,prgsize8k + str_ r0,prgSize8k mov r0, r1, lsr#1 - str_ r0,prgsize32k + str_ r0,prgSize32k rsb r0,r2,r1,lsl#14 @r0 = page count * 16K - 1 - str_ r0,rommask @rommask=romsize-1 + str_ r0,romMask @romMask=romSize-1 add r0,r3,r1,lsl#14 @r0 = rom end.(romsize + rom start) - str_ r0,vrombase @set vrom base + str_ r0,vromBase @set vrom base ldrb r4,[r3,#-11] @8K CHR-ROM page count movne r4, #0 @nsf has none? @@ -158,19 +160,19 @@ initcart: @called from C: r0=rom, (r1=emuflags?) cmp r4,#64 movhi r1,#128 rsbs r0,r2,r1,lsl#13 @r0 = VROM page size * 8K - 1 - str_ r0,vrommask @vrommask=vromsize-1 + str_ r0,vromMask @vromMask=vromSize-1 ldrmi r0,=NES_VRAM - strmi_ r0,vrombase @vrombase=NES VRAM if vromsize=0 + strmi_ r0,vromBase @vromBase=NES VRAM if vromSize=0 - stmfd sp!, {r3-r4, r12} + stmfd sp!, {r3, r12} mov r0, #0 @init val, cal crc for prgrom - ldr_ r1, rombase @src - ldr_ r2, prgsize8k @size + ldr_ r1, romBase @src + ldr_ r2, prgSize8k @size mov r2, r2, lsl#13 swi 0x0e0000 @swicrc16 str_ r0, prgcrc DEBUGINFO PRGCRC, r0 - ldmfd sp!, {r3-r4, r12} + ldmfd sp!, {r3, r12} ldr r0,=void ldrmi r0,=VRAM_chr @enable/disable chr write @@ -179,9 +181,9 @@ initcart: @called from C: r0=rom, (r1=emuflags?) bl filler mov m6502_pc,#0 @(eliminates any encodePC errors during mapper*init) - str_ m6502_pc,lastbank + str_ m6502_pc,m6502LastBank - ldr_ r1,emuflags + ldr_ r1,emuFlags tst r1, #NSFFILE bne 0f mov r0,#0 @default ROM mapping @@ -195,11 +197,11 @@ initcart: @called from C: r0=rom, (r1=emuflags?) ldrb r1,[r3,#-9] @rom control byte #2 and r0,r0,#0x0f @exclude mapper orr r1,r0,r1,lsl#4 - strb_ r1,cartflags @set cartflags(upper 4-bits (<<8, ignored) + 0000(should be zero)(<<4) + vTsM) + strb_ r1,cartFlags @set cartFlags(upper 4-bits (<<8, ignored) + 0000(should be zero)(<<4) + vTsM) @DEBUGINFO CARTFLAG, r1 ldr r0,=pcm_scanlinehook - str_ r0,scanlinehook @no mapper irq + str_ r0,scanlineHook @no mapper irq mov r0,#0x0 @clear nes ram reset value changed from 0xFFFFFFFF to 0x0 mov r1,cpu_zpage @cpu_zpage,=NES_RAM @@ -209,7 +211,7 @@ initcart: @called from C: r0=rom, (r1=emuflags?) add r1,cpu_zpage,#0x800 @save ram = SRAM mov r2,#0x2000/4 bl filler - ldr r1,=mapperstate @clear mapperdata so we dont have to do that in every MapperInit. + ldr r1,=mapperstate @clear mapperData so we dont have to do that in every MapperInit. mov r2,#96/4 bl filler @@ -226,29 +228,29 @@ initcart: @called from C: r0=rom, (r1=emuflags?) str r0,[r1] @reset 4016 write (mapper99 messes with it) ldr r1,=void - str_ r1, newframehook - str_ r1, endframehook - @str_ r1, hblankhook - str_ r1, ppuchrlatch + str_ r1, newFrameHook + str_ r1, endFrameHook + @str_ r1, hblankHook + str_ r1, ppuChrLatch ldr r0, =0x4000004 mov r1, #0x8 strh r1, [r0] @disable hblank process. ldr r1,=IO_R @reset other writes.. - str_ r1,readmem_tbl+8 - ldr r1,=sram_R @reset other writes.. - str_ r1,readmem_tbl+12 + str_ r1,m6502ReadTbl+8 + ldr r1,=mem_R60 @reset other writes.. + str_ r1,m6502ReadTbl+12 ldr r1,=IO_W @reset other writes.. - str_ r1,writemem_tbl+8 + str_ r1,m6502WriteTbl+8 ldr r1,=sram_W - str_ r1,writemem_tbl+12 + str_ r1,m6502WriteTbl+12 ldr r1,=NES_RAM-0x5800 @$6000 for mapper 40, 69 & 90 that has rom here. - str_ r1,memmap_tbl+12 + str_ r1,m6502MemTbl+12 ldr r1,=NES_XRAM-0x2000 - str_ r1,memmap_tbl+4 + str_ r1,m6502MemTbl+4 ldr r1,=NES_XRAM-0x4000 - str_ r1,memmap_tbl+8 + str_ r1,m6502MemTbl+8 ldrb r1,[r3,#-10] @get mapper# ldrb r2,[r3,#-9] @@ -267,7 +269,7 @@ initcart: @called from C: r0=rom, (r1=emuflags?) cmpeq r1, #83 moveq r0, #20 @this is a fds file... - ldr_ r1,emuflags + ldr_ r1,emuFlags tst r1, #NSFFILE movne r0, #256 @@ -280,15 +282,15 @@ lc0: ldr r2,[r1],#8 beq lc1 bpl lc0 lc1: @call mapperXXinit - adr_ r5,writemem_tbl+16 + adr_ r5,m6502WriteTbl+16 ldr r0,[r1,#-4] @r0 = mapperxxxinit ldmia r0!,{r1-r4} stmia r5,{r1-r4} @set default (write) operation for NES(0x8000 ~ 0xFFFF), maybe 'void', according to Mapper. - blx r0 @go maper_init + blx r0 @ go mapper_init - ldrb_ r1,cartflags - tst r1,#MIRROR @set default mirror, horizontal mirroring - bl mirror2H_ @(call after mapperinit to allow mappers to set up cartflags first) + ldrb_ r1,cartFlags + tst r1,#MIRROR @set default mirror, horizontal mirroring + bl mirror2H_ @(call after mapperinit to allow mappers to set up cartFlags first) bl NES_reset bl recorder_reset @init rewind control stuff @@ -302,8 +304,8 @@ savestate: ldr globalptr,=globals - ldr_ r2,rombase - rsb r2,r2,#0 @adjust rom maps,etc so they aren't based on rombase + ldr_ r2,romBase + rsb r2,r2,#0 @adjust rom maps,etc so they aren't based on romBase bl fixromptrs mov r6,r0 @r6=where to copy state @@ -311,17 +313,19 @@ savestate: adr r4,savelst @r4=list of stuff to copy mov r3,#(lstend-savelst)/8 @r3=items in list -ss1: ldr r2,[r4],#4 @r2=what to copy +ss1: + ldr r2,[r4],#4 @r2=what to copy ldr r1,[r4],#4 @r1=how much to copy add r0,r0,r1 -ss0: ldr r5,[r2],#4 +ss0: + ldr r5,[r2],#4 str r5,[r6],#4 subs r1,r1,#4 bne ss0 subs r3,r3,#1 bne ss1 - ldr_ r2,rombase @restore pointers + ldr_ r2,romBase @restore pointers bl fixromptrs ldmfd sp!,{r4-r6,globalptr,pc} @@ -339,7 +343,7 @@ lstend: @c_defs: #define SAVESTATESIZE (0x2800+0x3000+96+64+16+96+16+44+48) fixromptrs: @add r2 to some things - adr_ r1,memmap_tbl+16 + adr_ r1,m6502MemTbl+16 ldmia r1,{r3-r6} add r3,r3,r2 add r4,r4,r2 @@ -347,15 +351,15 @@ fixromptrs: @add r2 to some things add r6,r6,r2 stmia r1,{r3-r6} - ldr_ r3,lastbank + ldr_ r3,m6502LastBank add r3,r3,r2 - str_ r3,lastbank + str_ r3,m6502LastBank ldr_ r3,cpuregs+6*4 @6502 PC add r3,r3,r2 str_ r3,cpuregs+6*4 - mov pc,lr + bx lr @--------------------------------------------------------------------------------- loadstate: @void loadstate(u32 *stateptr) (stateptr must be word aligned) @@ -377,7 +381,7 @@ ls0: ldr r5,[r6],#4 subs r0,r0,#1 bne ls1 - ldr_ r2,rombase @adjust ptr shit (see savestate above) + ldr_ r2,romBase @adjust ptr shit (see savestate above) bl fixromptrs @--- ldr r3,=NES_VRAM+0x2000 @write all nametbl + attrib @@ -397,12 +401,12 @@ ls3: mov r1,r3 tst r4,#0x1800 bne ls4 @--- - @ldr r0,nes_chr_map @init BG CHR + @ldr r0,nesChrMap @init BG CHR @bl bg_chr_req - @ldr r0,nes_chr_map+4 + @ldr r0,nesChrMap+4 @bl bg_chr_req bl updateBGCHR - ldrb_ r0,ppuctrl1 + ldrb_ r0,ppuCtrl1 bl ctrl1_W ldmfd sp!,{r4-r7,globalptr,pc} @@ -420,7 +424,7 @@ NES_reset: bl CPU_reset mov r0, #0 - str_ r0, af_st @clear autofire state + str_ r0, af_state @clear autofire state bl nespatch @@ -428,9 +432,9 @@ NES_reset: @--------------------------------------------------------------------------------- map67_: @rom paging.. r0=page# @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0x6000 - ldr_ r2,prgsize8k + ldr_ r2,prgSize8k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -438,14 +442,14 @@ map67_: @rom paging.. r0=page# subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#13 - str_ r0,memmap_tbl+12 + str_ r0,m6502MemTbl+12 b flush @--------------------------------------------------------------------------------- map89_: @rom paging.. r0=page# @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0x8000 - ldr_ r2,prgsize8k + ldr_ r2,prgSize8k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -453,14 +457,14 @@ map89_: @rom paging.. r0=page# subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#13 - str_ r0,memmap_tbl+16 + str_ r0,m6502MemTbl+16 b flush @--------------------------------------------------------------------------------- mapAB_: @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0xa000 - ldr_ r2,prgsize8k + ldr_ r2,prgSize8k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -468,14 +472,14 @@ mapAB_: subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#13 - str_ r0,memmap_tbl+20 + str_ r0,m6502MemTbl+20 b flush @--------------------------------------------------------------------------------- mapCD_: @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0xc000 - ldr_ r2,prgsize8k + ldr_ r2,prgSize8k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -483,14 +487,14 @@ mapCD_: subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#13 - str_ r0,memmap_tbl+24 + str_ r0,m6502MemTbl+24 b flush @--------------------------------------------------------------------------------- mapEF_: @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0xe000 - ldr_ r2,prgsize8k + ldr_ r2,prgSize8k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -498,14 +502,14 @@ mapEF_: subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#13 - str_ r0,memmap_tbl+28 + str_ r0,m6502MemTbl+28 b flush @--------------------------------------------------------------------------------- map89AB_: @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0x8000 - ldr_ r2,prgsize16k + ldr_ r2,prgSize16k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -513,19 +517,19 @@ map89AB_: subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#14 - str_ r0,memmap_tbl+16 - str_ r0,memmap_tbl+20 -flush: @update m6502_pc & lastbank - ldr_ r1,lastbank + str_ r0,m6502MemTbl+16 + str_ r0,m6502MemTbl+20 +flush: @update m6502_pc & m6502LastBank + ldr_ r1,m6502LastBank sub m6502_pc,m6502_pc,r1 encodePC - mov pc,lr + bx lr @--------------------------------------------------------------------------------- mapCDEF_: @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0xc000 - ldr_ r2,prgsize16k + ldr_ r2,prgSize16k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -533,15 +537,15 @@ mapCDEF_: subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#14 - str_ r0,memmap_tbl+24 - str_ r0,memmap_tbl+28 + str_ r0,m6502MemTbl+24 + str_ r0,m6502MemTbl+28 b flush @--------------------------------------------------------------------------------- map89ABCDEF_: @--------------------------------------------------------------------------------- - ldr_ r1,rombase + ldr_ r1,romBase sub r1,r1,#0x8000 - ldr_ r2,prgsize32k + ldr_ r2,prgSize32k tst r0, #0x80000000 addne r0, r0, r2 0: @@ -549,9 +553,9 @@ map89ABCDEF_: subcs r0, r0, r2 bcs 0b add r0,r1,r0,lsl#15 - str_ r0,memmap_tbl+16 - str_ r0,memmap_tbl+20 - str_ r0,memmap_tbl+24 - str_ r0,memmap_tbl+28 + str_ r0,m6502MemTbl+16 + str_ r0,m6502MemTbl+20 + str_ r0,m6502MemTbl+24 + str_ r0,m6502MemTbl+28 b flush @--------------------------------------------------------------------------------- diff --git a/arm9/source/io.s b/arm9/source/io.s index cc4f80c..78cad58 100644 --- a/arm9/source/io.s +++ b/arm9/source/io.s @@ -18,7 +18,7 @@ @--------------------------------------------------------------------------------- IO_reset: @--------------------------------------------------------------------------------- - mov pc,lr + bx lr @--------------------------------------------------------------------------------- IO_R: @I/O read @read a IO register for NES @@ -28,7 +28,7 @@ IO_R: @I/O read bmi empty_R @no readable io register lower than 0x4015 cmp r2,#3 ldrmi pc,[pc,r2,lsl#2] @go (0x4000 + (r2 - 15) * 4) - mov pc, lr + bx lr @b FDS_R io_read_tbl: .word _4015r @4015 (sound) @@ -36,7 +36,7 @@ io_read_tbl: .word joy1_R @4017: controller 2 FDS_R: mov r0, #0 - mov pc, lr + bx lr @--------------------------------------------------------------------------------- IO_W: @I/O write @write a IO register for NES @@ -89,7 +89,7 @@ PRIORITY = 0x000 @0x800=AGB OBJ priority 2/3 stmfd sp!,{r3-r8,lr} and r1,r0,#0xe0 - adr_ addy,memmap_tbl + adr_ addy,m6502MemTbl ldr addy,[addy,r1,lsr#3] and r0,r0,#0xff add addy,addy,r0,lsl#8 @addy=DMA source @@ -105,12 +105,12 @@ cpsp: ldmia r0!, {r2-r5} stmia r1!, {r2-r5} - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #0x40 + SOFTRENDER @sprite render type or pure software beq 0f ldmfd sp!,{r3-r8,pc} 0: - ldr_ r0,emuflags @r7,8=priority flags for scaling type + ldr_ r0,emuFlags @r7,8=priority flags for scaling type tst r0,#ALPHALERP moveq r7,#0x00200000 movne r7,#0 @@ -127,7 +127,7 @@ dm0: addcc r5, r5, #1 add r5, r5, #1 - ldrb_ r0,ppuctrl0frame @8x16? + ldrb_ r0,ppuCtrl0Frame @8x16? tst r0,#0x20 bne dm4 @- - - - - - - - - - - - - 8x8 size @@ -372,13 +372,13 @@ joy2state: .byte 0 joy3state: .byte 0 joy0serial: .word 0 joy1serial: .word 0 -@nrplayers DCD 0 @Number of players in multilink. +@nrplayers .long 0 @Number of players in multilink. @--------------------------------------------------------------------------------- joy0_W: @4016 @writing operation to reset/clear joypad status. @--------------------------------------------------------------------------------- tst r0,#1 @0 for clear; 1 for reset - movne pc,lr + bxne lr @ldr r2,nrplayers @cmp r2,#3 mov r2,#-1 @@ -396,7 +396,7 @@ joy0_W: @4016 orr r0,r0,r2,lsl#8 @for normal joypads. @orrpl r0,r0,#0x00040000 @4player adapter str r0,joy1serial - mov pc,lr + bx lr @--------------------------------------------------------------------------------- joy0_R: @4016 @--------------------------------------------------------------------------------- @@ -405,22 +405,22 @@ joy0_R: @4016 and r0,r0,#1 str r1,joy0serial - ldrb_ r1,cartflags + ldrb_ r1,cartFlags tst r1,#VS orreq r0,r0,#0x40 - moveq pc,lr + bxeq lr ldrb r1,joy0state tst r1,#8 @start=coin (VS) orrne r0,r0,#0x40 - ldr_ r1, emuflags + ldr_ r1, emuFlags tst r1, #MICBIT bic r1, #MICBIT - str_ r1, emuflags + str_ r1, emuFlags orrne r0, r0, #0x4 - mov pc,lr + bx lr @--------------------------------------------------------------------------------- joy1_R: @4017 @--------------------------------------------------------------------------------- @@ -429,7 +429,7 @@ joy1_R: @4017 and r0,r0,#1 str r1,joy1serial - ldr_ r1, emuflags + ldr_ r1, emuFlags tst r1, #LIGHTGUN beq 0f @@ -438,16 +438,16 @@ joy1_R: @4017 ands r2, r2, #KEY_TOUCH orrne r0, r0, #0x10 - ldr r2, =renderdata + ldr r2, =renderData ldr r1, =IPC_TOUCH_X ldrh r1, [r1] add r2, r2, r1 - ldr_ r1, lighty + ldr_ r1, lightY - add r2, r2, r1, lsl#8 @r1 = renderdata + add r2, r2, r1, lsl#8 @r2 = renderData ldrb r2, [r2] adr r1, bright @@ -457,11 +457,11 @@ joy1_R: @4017 orreq r0, r0, #8 0: - ldrb_ r1,cartflags + ldrb_ r1,cartFlags tst r1,#VS orrne r0,r0,#0xf8 @VS dip switches - mov pc,lr + bx lr @------ bright: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -569,27 +569,27 @@ rj5: @--------------------------------- af_fresh: @adjust the frequency of the auto-fire ldr r2,joyflags - ldr_ r1, af_st + ldr_ r1, af_state tst r1, #0xff00 - beq aup + beq aUp sub r1, #0x100 - str_ r1, af_st + str_ r1, af_state orr r2, r2, #AUTOFIRE - b aend -aup: + b aEnd +aUp: tst r1, #0xff - beq afresh + beq aFresh sub r1, r1, #0x1 - str_ r1, af_st + str_ r1, af_state bic r2, r2, #AUTOFIRE - b aend -afresh: + b aEnd +aFresh: ldr_ r1, af_start sub r1, #0x100 - str_ r1, af_st + str_ r1, af_state orr r2, r2, #AUTOFIRE -aend: +aEnd: @eor r2,r2,#AUTOFIRE @toggle autofire state str r2,joyflags - mov pc, lr + bx lr diff --git a/arm9/source/ips.c b/arm9/source/ips.c index b0b8d8f..d0ad30c 100644 --- a/arm9/source/ips.c +++ b/arm9/source/ips.c @@ -39,9 +39,11 @@ int ipspatch(char *pfile, int *sizfile, const char *pips, const unsigned int siz if(sizips<8||memcmp(pips,"PATCH",5))return 2; if(!pfile)*sizfile=0; while(1){ - if(offset+3>sizips)return 1;address=read24(pips+offset);offset+=3; + if(offset+3>sizips)return 1; + address=read24(pips+offset);offset+=3; if(address==0x454f46&&offset==sizips)break; - if(offset+2>sizips)return 1;size=read16(pips+offset);offset+=2; + if(offset+2>sizips)return 1; + size=read16(pips+offset);offset+=2; if(size){ if(offset+size>sizips)return 1; if(!pfile){ @@ -54,7 +56,8 @@ int ipspatch(char *pfile, int *sizfile, const char *pips, const unsigned int siz memcpy(pfile+address,pips+offset,size); offset+=size; }else{ - if(offset+3>sizips)return 1;size=read16(pips+offset);offset+=2; + if(offset+3>sizips)return 1; + size=read16(pips+offset);offset+=2; if(!pfile){ if(*sizfile 0x8000 && (debuginfo[16] == 24 || debuginfo[16] == 26)) || - (addr < 0x4018 || debuginfo[16] == 20))) { + ((addr > 0x8000 && (debuginfo[MAPPER] == 24 || debuginfo[MAPPER] == 26)) || + (addr < 0x4018 || debuginfo[MAPPER] == 20))) { fifoSendValue32(FIFO_USER_07,(addr << 8) | val); IPC_APUW++; } @@ -364,22 +364,22 @@ void do_quickf(int func) } break; case 11: - if(debuginfo[16] == 20) { //16 = MAPPER + if(debuginfo[MAPPER] == 20) { fdscmdwrite(0); } break; case 12: - if(debuginfo[16] == 20) { + if(debuginfo[MAPPER] == 20) { fdscmdwrite(1); } break; case 13: - if(debuginfo[16] == 20) { + if(debuginfo[MAPPER] == 20) { fdscmdwrite(2); } break; case 14: - if(debuginfo[16] == 20) { + if(debuginfo[MAPPER] == 20) { fdscmdwrite(3); } break; diff --git a/arm9/source/multi.c b/arm9/source/multi.c index 144bc9d..204efff 100644 --- a/arm9/source/multi.c +++ b/arm9/source/multi.c @@ -105,7 +105,7 @@ void Handler(int packetID, int readlength) case 3: if(data[34] == 0x81) { //Check the CRC. Make sure that both players are using the same game. int remotecrc = (data[35] | (data[36] << 8)); - if(debuginfo[17] == remotecrc) { //ok. same game + if(debuginfo[PRGCRC] == remotecrc) { //ok. same game nifi_stat = 5; nifi_cmd |= MP_CONN; sendcmd(); @@ -121,7 +121,7 @@ void Handler(int packetID, int readlength) guest_framecount = 0; global_playcount = 0; joyflags &= ~AUTOFIRE; - __af_st = __af_start; + __af_state = __af_start; menu_game_reset(); //menu is closed. } else { //bad crc. disconnect the comm. nifi_stat = 0; @@ -147,7 +147,7 @@ void Handler(int packetID, int readlength) guest_framecount = 0; global_playcount = 0; joyflags &= ~AUTOFIRE; - __af_st = __af_start; + __af_state = __af_start; menu_game_reset(); //menu is closed. } else { //CRC error, the both sides should choose the some game. nifi_stat = 0; @@ -233,8 +233,8 @@ void do_multi() if(!(nifi_cmd & MP_NFEN)) Wifi_EnableWifi(); if(count++ > 30) { //send a connected flag. - nfcrc[3] = debuginfo[17] &0xFF; - nfcrc[4] = (debuginfo[17] >> 8 )&0xFF; + nfcrc[3] = debuginfo[PRGCRC] &0xFF; + nfcrc[4] = (debuginfo[PRGCRC] >> 8 )&0xFF; Wifi_RawTxFrameNIFI(6, 0x0014, (unsigned short *)nfcrc); count = 0; } @@ -373,4 +373,4 @@ int Wifi_RawTxFrameNIFI(u16 datalen, u16 rate, u16 * data) { } if(synchandler) synchandler(); return 0; -} \ No newline at end of file +} diff --git a/arm9/source/patch.s b/arm9/source/patch.s index 0772287..af8b533 100644 --- a/arm9/source/patch.s +++ b/arm9/source/patch.s @@ -7,44 +7,44 @@ @--------------------------------------------------------------------------------- nespatch: @--------------------------------------------------------------------------------- -@patch some games to act smoontly.... +@patch some games to act smoothly.... ldr_ r0, prgcrc ldr r1, =0x49B3 @TMNT 1 cmp r0, r1 ldreq r2, =362*CYCLE - streq_ r2,cyclesperscanline - moveq pc, lr + streq_ r2,cyclesPerScanline + bxeq lr ldr r1, =0x33AA @Akumajou Densetsu cmp r0, r1 ldreq r2, =362*CYCLE - streq_ r2,cyclesperscanline - moveq pc, lr + streq_ r2,cyclesPerScanline + bxeq lr ldr r1, =0x0A62 @Joe & Mac cmp r0, r1 ldreq r2, =340*CYCLE - streq_ r2,cyclesperscanline - moveq pc, lr + streq_ r2,cyclesPerScanline + bxeq lr ldr r1, =0xB2B5 @Three Eyed ONE/Mitsume Ga Tooru cmp r0, r1 ldreq r2, =360*CYCLE - streq_ r2,cyclesperscanline - moveq pc, lr + streq_ r2,cyclesPerScanline + bxeq lr ldr r1, =0x8A35 @Feng Shen Bang(Chinese) cmp r0, r1 ldreq r2, =360*CYCLE - streq_ r2,cyclesperscanline - moveq pc, lr + streq_ r2,cyclesPerScanline + bxeq lr ldr r1, =0xD796 @Alien Syndrome (J) cmp r0, r1 - ldreqb_ r1,cartflags + ldreqb_ r1,cartFlags biceq r1, r1, #SCREEN4+VS - streqb_ r1, cartflags + streqb_ r1, cartFlags beq mirror2H_ - mov pc, lr \ No newline at end of file + bx lr diff --git a/arm9/source/ppu.s b/arm9/source/ppu.s index 8f9d35a..679f719 100644 --- a/arm9/source/ppu.s +++ b/arm9/source/ppu.s @@ -94,7 +94,7 @@ nomap: str r0,[r6],#4 subs r7,r7,#4 bne nomap - mov pc,lr + bx lr .ltorg @--------------------------------------------------------------------------------- paletteinit:@ r0-r3 modified. @@ -155,7 +155,7 @@ PaletteTxAll: stmfd sp!,{r0-r4} @monochrome mode stuff - ldr r4,=ppuctrl1 + ldr r4,=ppuCtrl1 ldrb r4,[r4] mov r2,#0x1F @@ -310,9 +310,9 @@ rs1: movs r4,r1,asr#16 bcc rs1 mov r1,#REG_BASE @change blend control for scaling type - @ldr r0,=emuflags + @ldr r0,=emuFlags @ldr r0,[r0] - ldr_ r0,emuflags + ldr_ r0,emuFlags tst r0,#ALPHALERP ldrne r2,=0x08082241 ldreq r2,=0x10000310 @@ -326,9 +326,9 @@ PPU_reset: stmfd sp!,{lr} mov r0,#0 - strb_ r0,ppuctrl0 @NMI off - strb_ r0,ppuctrl1 @screen off - strb_ r0,ppustat @flags off + strb_ r0,ppuCtrl0 @NMI off + strb_ r0,ppuCtrl1 @screen off + strb_ r0,ppuStat @flags off mov r0,#0 ldr r1,=NES_VRAM @@ -355,20 +355,20 @@ EMU_VBlank: @call every vblank stmfd sp!,{r4-r7,globalptr,lr} ldr globalptr,=globals - ldrb_ r1,cartflags @set cartflags(upper 4-bits (<<8, ignored) + 0000(should be zero)(<<4) + vTsM) + ldrb_ r1,cartFlags @set cartFlags(upper 4-bits (<<8, ignored) + 0000(should be zero)(<<4) + vTsM) DEBUGINFO CARTFLAG, r1 ldr r0, =IPC_MEMTBL - ldr_ r1,memmap_tbl+16 + ldr_ r1,m6502MemTbl+16 add r1, r1, #0x8000 str r1, [r0], #4 - ldr_ r1,memmap_tbl+20 + ldr_ r1,m6502MemTbl+20 add r1, r1, #0xA000 str r1, [r0], #4 - ldr_ r1,memmap_tbl+24 + ldr_ r1,m6502MemTbl+24 add r1, r1, #0xC000 str r1, [r0], #4 - ldr_ r1,memmap_tbl+28 + ldr_ r1,m6502MemTbl+28 add r1, r1, #0xE000 str r1, [r0] @@ -378,13 +378,13 @@ EMU_VBlank: @call every vblank @strh r2,[r2,#REG_DM2CNT_H] @strh r2,[r2,#REG_DM3CNT_H] - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #SOFTRENDER bne svbend - @ldr_ r0,=emuflags + @ldr_ r0,=emuFlags @ldr r0,[r0] - ldr_ r0,emuflags + ldr_ r0,emuFlags mov r3, #0 @reset the scale, a fake one... tst r0,#NOFLICKER bne ev0 @@ -392,7 +392,7 @@ EMU_VBlank: @call every vblank eor r3,r3,#1 str r3,scale ev0: - @ldr r0,emuflags + @ldr r0,emuFlags @tst r0,#PALTIMING @beq nopal60 @ldrb r0,PAL60 @@ -423,7 +423,7 @@ nopal60: ldmfd sp!,{r4-r7,globalptr,pc} svbend: - ldr_ r0,emuflags + ldr_ r0,emuFlags tst r0,#NOFLICKER bne 0f @@ -448,7 +448,7 @@ ppusync: @called on NES scanline 0..239 (r0=line) @--------------------------------------------------------------------------------- stmfd sp!,{r3,lr} - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #SOFTRENDER bne soft_sync @@ -469,7 +469,7 @@ ppusync: @called on NES scanline 0..239 (r0=line) cmp r1, r2 ldreq_ r0, scanline - streq_ r0, lighty + streq_ r0, lightY bleq soft_render bl scanlinenext @@ -477,7 +477,7 @@ ppusync: @called on NES scanline 0..239 (r0=line) 0: ldr_ r0, scanline - adr_ r2,nes_chr_map + adr_ r2,nesChrMap ldr r3,=nes_maps add r3, r3, r0, lsl#4 ldr r1,[r2], #4 @@ -522,7 +522,7 @@ ppusync: @called on NES scanline 0..239 (r0=line) ldr r2,currentBG and r2, r2, #0x7F - ldr_ r3,bg0cnt + ldr_ r3,bg0Cnt orr r2,r3,r2,lsr#1 strh r2,[r12] strh r2,[r12, #2] @nothing happens @@ -555,7 +555,7 @@ ppusync: @called on NES scanline 0..239 (r0=line) str_ r2,scrollY @- - - - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #0x40 @sprite render type beq 0f stmfd sp!, {r4-r12} @@ -563,7 +563,7 @@ ppusync: @called on NES scanline 0..239 (r0=line) ldmfd sp!, {r4-r12} 0: @- - - - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #PALSYNC beq no_sync @@ -620,7 +620,7 @@ no_sync: ldmfd sp!,{r3,pc} @--- soft_sync: - ldr_ r0, emuflags + ldr_ r0, emuFlags DEBUGINFO 20, r0 stmfd sp!, {r4-r12} @@ -672,7 +672,7 @@ PPU_write_tbl: empty_PPU_R: @--------------------------------------------------------------------------------- mov r0,#0 - mov pc,lr + bx lr @--------------------------------------------------------------------------------- ctrl0_W: @(2000) @--------------------------------------------------------------------------------- @@ -684,12 +684,12 @@ ctrl0_W: @(2000) orr r1, r1, r2, lsl#10 str_ r1, loopy_t - strb_ r0,ppuctrl0 + strb_ r0,ppuCtrl0 mov r1,#1 @+1/+32 tst r0,#4 movne r1,#32 - strb_ r1,vramaddrinc + strb_ r1,vramAddrInc mov r1,r0,lsr#1 and r1,r1,#1 @@ -701,14 +701,14 @@ ctrl0_W: @(2000) @--------------------------------------------------------------------------------- ctrl1_W: @(2001) @--------------------------------------------------------------------------------- - strb_ r0,ppuctrl1 + strb_ r0,ppuCtrl1 ldr r1,=DISPCNT_INIT tst r0,#0x08 @bg en? beq cr10 - ldr_ r2,emuflags + ldr_ r2,emuFlags tst r2,#ALPHALERP orrne r1,r1,#0x0300 orreq r1,r1,#0x0100 @@ -722,7 +722,7 @@ cr10: orreq r1,r1,#0x4000 str r1,dispcnt - mov pc,lr + bx lr .ltorg dispcnt: .word DISPCNT_INIT @@ -731,9 +731,9 @@ stat_R: @(2002) @--------------------------------------------------------------------------------- mov r0,#0 strb_ r0,toggle - ldrb_ r2,ppustat + ldrb_ r2,ppuStat - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #SOFTRENDER bne 0f @@ -742,7 +742,7 @@ stat_R: @(2002) cmp r1,r0 @ ble nosprh @ ldrb r0,sprite0x @for extra high resolution sprite0 hit -@ ldr r1,cyclesperscanline @the store is in IO.s +@ ldr r1,cyclesPerScanline @the store is in IO.s @ sub r1,r1,cycles @ cmp r1,r0 bic r2, #0x40 @@ -750,15 +750,15 @@ stat_R: @(2002) @nosprh 0: bic r1,r2,#0x80 @vbl flag clear - strb_ r1,ppustat + strb_ r1,ppuStat mov r0, r2 - ldrb_ r1, ppuctrl1 + ldrb_ r1, ppuCtrl1 tst r1, #0x10 biceq r0, #0x60 - mov pc,lr + bx lr @--------------------------------------------------------------------------------- bgscroll_W: @(2005) @--------------------------------------------------------------------------------- @@ -777,7 +777,7 @@ bgscrollX: orr r1, r1, r0, lsr#3 str_ r1, loopy_t - mov pc,lr + bx lr bgscrollY: strb_ r0,scrollYtemp @@ -790,16 +790,16 @@ bgscrollY: orr r1, r1, r2, lsl#2 str_ r1, loopy_t - ldr_ r1,vramaddr2 @yscroll modifies vramaddrtmp + ldr_ r1,vramAddr2 @yscroll modifies vramAddr2 bic r1,r1,#0x7300 bic r1,r1,#0x00e0 and r2,r0,#0xf8 and r0,r0,#7 orr r1,r1,r2,lsl#2 orr r1,r1,r0,lsl#12 - str_ r1,vramaddr2 + str_ r1,vramAddr2 - mov pc,lr + bx lr @--------------------------------------------------------------------------------- vmaddr_W: @(2006) @--------------------------------------------------------------------------------- @@ -809,9 +809,9 @@ vmaddr_W: @(2006) beq low high: and r0,r0,#0x3f - strb_ r0,vramaddr2+1 + strb_ r0,vramAddr2+1 strb_ r0, loopy_t + 1 - mov pc,lr + bx lr low: strb_ r0, loopy_t ldr_ r1, loopy_t @@ -819,9 +819,9 @@ low: ldr_ r1, loopy_x str_ r1, loopy_shift - strb_ r0,vramaddr2 - ldr_ r1,vramaddr2 - str_ r1,vramaddr + strb_ r0,vramAddr2 + ldr_ r1,vramAddr2 + str_ r1,vramAddr and r0,r1,#0x7000 @r0=fine Y and r2,r1,#0x03e0 @r2=coarse Y @@ -840,15 +840,15 @@ low: orr r0,r0,addy,lsr#2 str_ r0,scrollX - mov pc,lr + bx lr @--------------------------------------------------------------------------------- vmdata_R: @(2007) @--------------------------------------------------------------------------------- - ldr_ r0,vramaddr - ldrb_ r1,vramaddrinc + ldr_ r0,vramAddr + ldrb_ r1,vramAddrInc bic r0,r0,#0xfc000 add r2,r0,r1 - str_ r2,vramaddr + str_ r2,vramAddr cmp r0,#0x3f00 bhs palread @@ -859,22 +859,22 @@ vmdata_R: @(2007) bic r0,r0,#0xfc00 ldrb r1,[r1,r0] - ldrb_ r0,readtemp - str_ r1,readtemp - mov pc,lr + ldrb_ r0,readTemp + str_ r1,readTemp + bx lr palread: and r0,r0,#0x1f adr r1,nes_palette ldrb r0,[r1,r0] - mov pc,lr + bx lr @--------------------------------------------------------------------------------- vmdata_W: @(2007) @Do not change addy... @--------------------------------------------------------------------------------- - ldr_ addy,vramaddr - ldrb_ r1,vramaddrinc + ldr_ addy,vramAddr + ldrb_ r1,vramAddrInc bic addy,addy,#0xfc000 @AND $3fff add r2,addy,r1 - str_ r2,vramaddr + str_ r2,vramAddr and r1,addy,#0x3c00 adr r2,vram_write_tbl @@ -888,7 +888,7 @@ VRAM_chr:@ 0000-1fff bic r1, addy, #0xFC00 strb r0,[r2,r1] @because some games may switch off/in VRAM(0000-1fff) - mov pc,lr + bx lr @--------------------------------------------------------------------------------- VRAM_name0: @(2000-23ff) @--------------------------------------------------------------------------------- @@ -907,7 +907,7 @@ writeBG: @loadcart jumps here strh r1,[r2,addy] @write tile# cmp r0,#0xfd @mapper 9 shit.. bhs mapper9BGcheck - mov pc,lr + bx lr writeattrib: stmfd sp!,{r3,r4,lr} @@ -956,7 +956,7 @@ writeattrib: orr r1,r1,r2,lsl#6 str r1,[addy,#0xc4] ldmfd sp!,{r3,r4,lr} - mov pc, lr + bx lr @--------------------------------------------------------------------------------- VRAM_name1: @(2400-27ff) @--------------------------------------------------------------------------------- @@ -1013,7 +1013,7 @@ VRAM_pal: @($3F00-$3F1F) ldr_ r1, scanline add r1, r1, #2 str_ r1, palsyncline - mov pc, lr + bx lr @------------ .ltorg @--------------------------------------------------------------------------------- @@ -1034,11 +1034,11 @@ newframe: @called at NES scanline 0 (r0-r9 safe to use) mov r0, #0 str_ r0, palsyncline - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #SOFTRENDER bne nfsoft - ldr_ r0, vrombase + ldr_ r0, vromBase ldr r1, =NES_VRAM cmp r0, r1 @means that the game does NOT have any vrom. bne 0f @@ -1059,11 +1059,11 @@ newframe: @called at NES scanline 0 (r0-r9 safe to use) ldr r0,DMAlinestart @init scaling stuff str r0,DMAline - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #0x40 @sprite render type bleq updateOBJCHR @(nes_zpage still valid here) @------------------------ - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #PALSYNC beq 1f ldr r3, =0x4000006 @@ -1091,7 +1091,7 @@ nfsoft: str_ r0,scrollY ldmfd sp!,{r3-r9, lr} - ldr_ pc, newframehook + ldr_ pc, newFrameHook .ltorg @--------------------------------------------------------------------------------- agb_pal: .skip 32*2 @copy this to real AGB palette every frame @@ -1178,23 +1178,23 @@ mirror_xram_0000: mirror4_: adr r0,m0123 mirrorchange: - ldrb_ r1,cartflags + ldrb_ r1,cartFlags tst r1,#SCREEN4+VS ldrne r0,=m0123 @force 4way mirror for SCREEN4 or VS flags stmfd sp!,{r3-r5,lr} ldmia r0!,{r1} - str_ r1,bg0cnt - + str_ r1,bg0Cnt + ldr r1,=nes_nt0 ldmia r0!,{r2-r5} stmia r1,{r2-r5} - + ldr r1,=agb_nt_map ldmia r0!,{r2-r5} stmia r1,{r2-r5} - + ldmfd sp!,{r3-r5,pc} .ltorg @--------------------------------------------------------------------------------- @@ -1220,18 +1220,18 @@ resetCHR: @initialize CHR - used by loadcart str r0,[r1],#4 str r0,[r1],#4 str r0,[r1],#4 - + mov r0,#0 DEBUGINFO BGMISS,r0 str r0,currentBG str r0,nextBG - + + mov r0,#0 + strb_ r0,ppuCtrl0 @BG gets tileset 0 (ensures first banks get cached first for chr-ram) mov r0,#0 - strb_ r0,ppuctrl0 @BG gets tileset 0 (ensures first banks get cached first for chr-ram) - mov r0,#0 bl chr01234567_ @default CHR mapping bl updateBGCHR - + ldmfd sp!,{pc} @--------------------------------------------------------------------------------- writeCHRTBL: .word chr0_,chr1_,chr2_,chr3_,chr4_,chr5_,chr6_,chr7_ @@ -1260,14 +1260,14 @@ chr6_: chr7_: mov r1,#7 chr1k: - ldr_ r2,vrommask + ldr_ r2,vromMask and r0,r0,r2,lsr#10 - adr_ r2,nes_chr_map + adr_ r2,nesChrMap add r2, r2, r1, lsl#1 strh r0,[r2] - ldr_ r2,vrombase + ldr_ r2,vromBase add r0,r2,r0,lsl#10 ldr r2,=vram_map str r0,[r2,r1,lsl#2] @@ -1286,18 +1286,18 @@ chr67_: mov r1,#6 @b chr2k chr2k: - ldr_ r2,vrommask + ldr_ r2,vromMask and r0,r0,r2,lsr#11 mov r0,r0,lsl#1 - adr_ r2,nes_chr_map + adr_ r2,nesChrMap add r2, r2, r1, lsl#1 strh r0,[r2] orr r0,r0,#1 strh r0,[r2,#2] bic r0, r0, #1 - ldr_ r2,vrombase + ldr_ r2,vromBase add r0,r2,r0,lsl#10 ldr r2,=vram_map str r0,[r2,r1,lsl#2]! @@ -1307,18 +1307,18 @@ chr2k: @--------------------------------------------------------------------------------- chr0123_: @--------------------------------------------------------------------------------- - ldr_ r2,vrommask + ldr_ r2,vromMask and r0,r0,r2,lsr#12 orr r1,r0,r0,lsl#16 mov r1, r1, lsl#2 orr r2, r1, #0x00010000 - str_ r2,nes_chr_map + str_ r2,nesChrMap ldr r2,=0x00030002 orr r2,r1,r2 - str_ r2,nes_chr_map+4 + str_ r2,nesChrMap+4 - ldr_ r1,vrombase + ldr_ r1,vromBase add r1,r1,r0,lsl#12 str r1,vram_map add r1,r1,#0x400 @@ -1331,24 +1331,24 @@ chr0123_: @--------------------------------------------------------------------------------- chr01234567_: @--------------------------------------------------------------------------------- - ldr_ r2,vrommask + ldr_ r2,vromMask and r0,r0,r2,lsr#13 orr r1,r0,r0,lsl#16 mov r1, r1, lsl#3 orr r2, r1, #0x00010000 - str_ r2,nes_chr_map + str_ r2,nesChrMap ldr r2,=0x00030002 orr r2,r1,r2 - str_ r2,nes_chr_map+4 + str_ r2,nesChrMap+4 ldr r2,=0x00050004 orr r2,r1,r2 - str_ r2,nes_chr_map+8 + str_ r2,nesChrMap+8 ldr r2,=0x00070006 orr r2,r1,r2 - str_ r2,nes_chr_map+12 + str_ r2,nesChrMap+12 - ldr_ r1,vrombase + ldr_ r1,vromBase add r1,r1,r0,lsl#13 str r1,vram_map add r1,r1,#0x400 @@ -1362,18 +1362,18 @@ chr01234567_: @--------------------------------------------------------------------------------- chr4567_: @--------------------------------------------------------------------------------- - ldr_ r2,vrommask + ldr_ r2,vromMask and r0,r0,r2,lsr#12 orr r1,r0,r0,lsl#16 mov r1, r1, lsl#2 orr r2, r1, #0x00010000 - str_ r2,nes_chr_map+8 + str_ r2,nesChrMap+8 ldr r2,=0x00030002 orr r2,r1,r2 - str_ r2,nes_chr_map+12 + str_ r2,nesChrMap+12 - ldr_ r1,vrombase + ldr_ r1,vromBase add r1,r1,r0,lsl#12 _4567: str r1,vram_map+16 add r1,r1,#0x400 @@ -1387,20 +1387,20 @@ _4567: str r1,vram_map+16 @--------------------------------------------------------------------------------- updateBGCHR: @see if BG CHR needs to change, setup BGxCNTBUFF @--------------------------------------------------------------------------------- - ldrb_ r2,ppuctrl0 + ldrb_ r2,ppuCtrl0 tst r2,#0x10 stmfd sp!,{r2-r9, lr} - ldreq_ r0,nes_chr_map - ldreq_ r8,nes_chr_map+4 - ldrne_ r0,nes_chr_map+8 @r0=new bg chr group - ldrne_ r8,nes_chr_map+12 + ldreq_ r0,nesChrMap + ldreq_ r8,nesChrMap+4 + ldrne_ r0,nesChrMap+8 @r0=new bg chr group + ldrne_ r8,nesChrMap+12 bl bg_chr_req ldmfd sp!,{r2-r9, pc} @--------------------------------------------------------------------------------- updateOBJCHR: @sprite CHR update (r3-r7 killed) @--------------------------------------------------------------------------------- - ldrb_ r2,ppuctrl0frame + ldrb_ r2,ppuCtrl0Frame tst r2,#0x20 @8x16? beq uc3 mov r12,lr @@ -1411,28 +1411,28 @@ uc3: tst r2,#0x08 bne uc2 uc1: - ldr_ r0,nes_chr_map - ldr_ r8,nes_chr_map + 4 + ldr_ r0,nesChrMap + ldr_ r8,nesChrMap + 4 ldr r1,agb_obj_map ldr r9,agb_obj_map + 4 eor r1,r1,r0 eor r9,r9,r8 orrs r2, r1, r9 - moveq pc, lr + bxeq lr str r0,agb_obj_map str r8,agb_obj_map + 4 ldr r5,=NDS_OBJVRAM adr r6,agb_obj_map b unpack_tiles uc2: - ldr_ r0,nes_chr_map+8 - ldr_ r8,nes_chr_map+12 + ldr_ r0,nesChrMap+8 + ldr_ r8,nesChrMap+12 ldr r1,agb_obj_map+8 ldr r9,agb_obj_map+12 eor r9,r9,r8 eor r1,r1,r0 orrs r2, r1, r9 - moveq pc,lr + bxeq lr str r0,agb_obj_map+8 str r8,agb_obj_map+12 ldr r5,=NDS_OBJVRAM+0x2000 @@ -1487,7 +1487,7 @@ bg0: movs r0, r1, lsl#16 addeq agbptr,agbptr,#0x800 beq bg2 mov tilecount,#64 - ldr_ nesptr,vrombase + ldr_ nesptr,vromBase add nesptr,nesptr,r0,lsl#10 @bank#*$400 bg1: ldrb r0,[nesptr],#1 @@ -1510,7 +1510,7 @@ bg0_: movs r0, r9, lsl#16 addeq agbptr,agbptr,#0x800 beq bg2_ mov tilecount,#64 - ldr_ nesptr,vrombase + ldr_ nesptr,vromBase add nesptr,nesptr,r0,lsl#10 @bank#*$400 bg1_: ldrb r0,[nesptr],#1 @@ -1527,13 +1527,13 @@ bg1_: ldrb r0,[nesptr],#1 bg2_: tst bankptr,#3 bne bg0_ - mov pc,lr + bx lr cached: @-------------- sub r2,r2,#8 sub r7,r2,r6 @r7=group#*8 str r7,currentBG - mov pc,lr + bx lr @--------------------------------------------------------------------------------- @@ -1595,13 +1595,13 @@ msplp: str r1, [r0, #239] str r1, [r0, #240] - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #ALLPIXEL beq hidesp - ldr_ r0, pixstart + ldr_ r0, pixStart cmp r0, #0 - moveq pc, lr + bxeq lr hidesp: ldr r3, =NES_SPRAM @@ -1617,17 +1617,17 @@ hidesp_loop: subs r1, r1, #1 bne hidesp_loop - mov pc, lr + bx lr 0: - ldr_ r2, pixstart + ldr_ r2, pixStart cmp r2, #0 bne 1f cmp r3, #239 @r3 = scanline bne 1f - ldr_ r2, emuflags + ldr_ r2, emuFlags tst r2, #ALLPIXEL beq 1f @@ -1636,9 +1636,9 @@ hidesp_loop: mov lr, r5 1: - ldrb_ r0, ppuctrl1 + ldrb_ r0, ppuCtrl1 tst r0, #0x10 - moveq pc, lr + bxeq lr ldr r5, =CHR_DECODE ldr_ r3, scanline @@ -1647,7 +1647,7 @@ hidesp_loop: ldr r1, =spmask ldr r0, [r1, r3] ands r0, r0, r0 - moveq pc, lr + bxeq lr stmfd sp!, {lr} @@ -1667,7 +1667,7 @@ splp: bne 0f @check sprite0 stmfd sp!, {r0-r5, r11} - ldrb_ r3, ppuctrl0 + ldrb_ r3, ppuCtrl0 tst r3, #0x20 bne sp160 sp80: @@ -1774,7 +1774,7 @@ sp0end: tst r2, #0x20 orrne r0, r0, #(1 << 10) - ldrb_ r1, ppuctrl0 + ldrb_ r1, ppuCtrl0 tst r1, #0x20 orrne r0, r0, #0x8000 strh r0, [r12] @set cordinate y @@ -1784,7 +1784,7 @@ sp8: adr lr, 0f adr r12, 1f - ldr_ pc, ppuchrlatch @r4 returns the new ptr r1 = ppuctrl0, r0 = tile# + ldr_ pc, ppuChrLatch @r4 returns the new ptr r1 = ppuCtrl0, r0 = tile# 0: and r2, r1, #0x08 @@ -1939,7 +1939,7 @@ vromnt1k: @r1=nt0...3 add r2, r2, r1, lsl#1 @two bytes... ldrh r2, [r2] cmp r0, r2 - moveq pc, lr + bxeq lr stmfd sp!, {r3-r9, lr} @@ -1947,7 +1947,7 @@ vromnt1k: @r1=nt0...3 add r2, r2, r1, lsl#1 strh r0, [r2] - ldr_ r3, vrombase + ldr_ r3, vromBase ldr r2, =NDS_BG + 0x2000 @point to a free Map area. add r2, r2, r1, lsl#11 add r4, r3, r0, lsl#10 diff --git a/arm9/source/render.s b/arm9/source/render.s index b81fc8f..d2cd312 100644 --- a/arm9/source/render.s +++ b/arm9/source/render.s @@ -1,18 +1,17 @@ #include "equates.h" #include "6502mac.h" + .global soft_render - .global dmaCopy_s .global nes_palette - .global render_fun .global bg_render_bottom .global render_all .global render_sub - .global renderdata + .global renderData .global renderbgdata .global scanlinenext .global scanlinestart .global rev_data - + @for crash check .global normal_sp .global dummy_render @@ -39,13 +38,12 @@ .global bg_render .global BGwrite_data .global SPwrite_data - .global rev_data -@renderdata = 0x6040000 - 4 +@renderData = 0x6040000 - 4 -tileofs = tempdata -ntbladr = tileofs + 4 -attradr = ntbladr + 4 -ntbl_x = attradr + 4 +tileOfs = tempData +ntblAdr = tileOfs + 4 +attrAdr = ntblAdr + 4 +ntbl_x = attrAdr + 4 attrsft = ntbl_x + 4 pNTBL = attrsft + 4 pScn = pNTBL + 4 @@ -59,9 +57,9 @@ Bit2Rev = SPwrite + 4 @--------------------------------------------------------------------------------- scanlinestart: @--------------------------------------------------------------------------------- - ldrb_ r0, ppuctrl1 + ldrb_ r0, ppuCtrl1 tst r0, #0x18 @tst (bgdisp | spdisp) - moveq pc, lr + bxeq lr ldr_ r2, loopy_v ldr_ r1, loopy_t ldr r0, =0xFBE0 @@ -75,14 +73,14 @@ scanlinestart: str_ r2, loopy_y @loopy_y = (loopy_v&0x7000)>>12 ldr_ r0, loopy_x str_ r0, loopy_shift @loopy_shift = loopy_x - mov pc, lr + bx lr @--------------------------------------------------------------------------------- scanlinenext: @--------------------------------------------------------------------------------- - ldrb_ r0, ppuctrl1 + ldrb_ r0, ppuCtrl1 tst r0, #0x18 @tst (bgdisp | spdisp) - moveq pc, lr + bxeq lr ldr_ r2, loopy_v and r1, r2, #0x7000 @@ -107,13 +105,13 @@ lpvend: and r1, r1, #7 str_ r1, loopy_y str_ r2, loopy_v - mov pc, lr + bx lr @-------------------------------------------- soft_render: @r0 for scanline r1=free @-------------------------------------------- - ldr_ r1, emuflags + ldr_ r1, emuFlags tst r1, #SOFTRENDER bne soft_r @@ -122,28 +120,28 @@ soft_render: @for allpixel ldr_ r0, scanline - ldr_ r1, pixstart + ldr_ r1, pixStart cmp r0, r1 - movcc pc, lr - ldr_ r1, pixend + bxcc lr + ldr_ r1, pixEnd cmp r0, r1 - movhi pc, lr + bxhi lr bne normal_sp @wait for vbl sync: - ldr_ r0, emuflags + ldr_ r0, emuFlags tst r0, #FASTFORWARD - movne pc, lr + bxne lr - ldr_ r0, pixstart + ldr_ r0, pixStart cmp r0, #0 - movne pc, lr + bxne lr stmfd sp!, {r3-r4, lr} bl swiWaitForVBlank ldmfd sp!, {r3-r4, pc} soft_r: - ldrb_ r1, rendercount + ldrb_ r1, renderCount cmp r1, #0 bne dummy_render ldrb_ r0, scanline/* @@ -163,11 +161,11 @@ normal_sp: ldr_ r0, scanline bl bg_render - ldrb_ r0, ppustat @PPUREG[2] &= ~PPU_SPMAX_FLAG; + ldrb_ r0, ppuStat @PPUREG[2] &= ~PPU_SPMAX_FLAG; bic r0, #0x20 - strb_ r0, ppustat + strb_ r0, ppuStat - ldrb_ r0, ppuctrl1 + ldrb_ r0, ppuCtrl1 tst r0, #0x10 ldr_ r0, scanline blne sp_render @@ -176,15 +174,15 @@ normal_sp: @-------------------------------------------- dummy_render: @-------------------------------------------- - ldrb_ r0, ppustat + ldrb_ r0, ppuStat bic r0, #0x20 - strb_ r0, ppustat + strb_ r0, ppuStat - ldrb_ r0, ppuctrl1 + ldrb_ r0, ppuCtrl1 tst r0, #0x10 - moveq pc, lr + bxeq lr - ldrb_ r1, ppuctrl0 + ldrb_ r1, ppuCtrl0 tst r1, #0x20 movne r2, #15 moveq r2, #7 @@ -204,19 +202,19 @@ dummy_lp: bne dummy_nt cmp r3, #0 - ldreqb_ r1, ppustat + ldreqb_ r1, ppuStat orreq r1, r1, #0x40 - streqb_ r1, ppustat + streqb_ r1, ppuStat add r6, r6, #1 cmp r6, #8 bne dummy_nt - ldrb_ r0, ppustat + ldrb_ r0, ppuStat orr r0, #0x20 - strb_ r0, ppustat + strb_ r0, ppuStat ldmfd sp!, {r3-r6} - mov pc, lr + bx lr dummy_nt: add r3, r3, #1 @@ -224,20 +222,20 @@ dummy_nt: bne dummy_lp ldmfd sp!, {r3-r6} - mov pc, lr + bx lr @-------------------------------------------- sp_render: @r0 = linenumber @-------------------------------------------- stmfd sp!,{r2-r9, cpu_zpage, addy, lr} - ldr r1, =renderdata - add r1, r1, r0, lsl#8 @r1 = renderdata + ldr r1, =renderData + add r1, r1, r0, lsl#8 @r1 = renderData str_ r1, pScn @store pScn mov r12, #0 @spmax = 0 @r11 = spraddr, r9 = sp_y, r8 = sp_h, r7 = chr_h, r6 = chr_l, r5 = sp, r4 = i ldr r5, =NES_SPRAM @r5 = sp - ldrb_ r1, ppuctrl0 + ldrb_ r1, ppuCtrl0 tst r1, #0x20 movne r8, #15 @r8 = sp_h = (PPUREG[0]&PPU_SP16_BIT)?15:7 moveq r8, #7 @@ -253,7 +251,7 @@ sp_lp: cmp r9, r8 bhi sp_next - ldrb_ r3, ppuctrl0 + ldrb_ r3, ppuCtrl0 tst r3, #0x20 @ PPUREG[0]&PPU_SP16_BIT bne sp16 sp8: @@ -303,8 +301,8 @@ show_sp: mov r0, r11 adr lr, 0f - ldr_ pc, ppuchrlatch -0: + ldr_ pc, ppuChrLatch +0: ldrb r0, [r5, #2] tst r0, #0x40 beq sp_noh @@ -317,7 +315,7 @@ sp_noh: orr r11, r6, r7 @SPpat = chr_l|chr_h cmp r4, #0 bne sp_mask - ldrb_ r3, ppustat + ldrb_ r3, ppuStat tst r3, #0x40 bne sp_mask hitcheck: @@ -334,12 +332,12 @@ hitcheck: ldrb r1, [r2, #1] orr r2, r1, r0, lsl#8 mov r0, r2, lsr r7 @r0 = BGmsk = (((WORD)pBGw[BGpos+0]<<8)|(WORD)pBGw[BGpos+1])>>BGsft - @still r3 = ppustat + @still r3 = ppuStat ands r0, r0, r11 beq hitend orr r3, r3, #0x40 - strb_ r3, ppustat + strb_ r3, ppuStat hitend: ldmfd sp!, {r6, r7} @@ -445,9 +443,9 @@ sp_attr: ldmfd sp!, {r4, r8-r9} add r12, r12, #1 cmp r12, #8 - ldreqb_ r0, ppustat + ldreqb_ r0, ppuStat orreq r0, r0, #0x20 - streqb_ r0, ppustat + streqb_ r0, ppuStat beq sp_end sp_next: @@ -463,11 +461,11 @@ sp_end: bg_render: @r0 = linenumber r1 is free @-------------------------------------------- - ldrb_ r1, ppuctrl1 + ldrb_ r1, ppuCtrl1 tst r1, #0x8 bne bg_normal - - ldr r1, =renderdata + + ldr r1, =renderData add r1, r1, r0, lsl#8 ldr r0, =nes_palette ldrb r0, [r0] @@ -476,49 +474,49 @@ bg_render: mov r2, #256/4 b filler - mov pc, lr + bx lr + - bg_normal: stmfd sp!,{r2-r12, r14} @r2-r9, r10, r11, r12, r14 @Without Extension Latch - - ldr r1, =renderdata - add r1, r1, r0, lsl#8 @r1 = renderdata + + ldr r1, =renderData + add r1, r1, r0, lsl#8 @r1 = renderData ldr_ r2, loopy_shift @r2 = loopy_shift @rsb r2, r2, #8 sub r1, r1, r2 @r1 = pScn = lpScanline+(8-loopy_shift) str_ r1, pScn @store pScn - - ldrb_ r1, ppuctrl0 + + ldrb_ r1, ppuCtrl0 and r1, r1, #0x10 - mov r1, r1, lsl#8 @r1 = tileofs - str_ r1, tileofs @store tileofs - + mov r1, r1, lsl#8 @r1 = tileOfs + str_ r1, tileOfs @store tileOfs + ldr_ r5, loopy_v @r3 = loopy_v bic r2, r5, #0xF000 @r2 = loopy_v&0x0FFF - add r1, r2, #0x2000 @r1 = ntbladr - str_ r1, ntbladr @store ntbladr - - and r2, r1, #0x001F @r2 = ntbl_x = ntbladr&0x001F - and r3, r1, #0x40 - mov r3, r3, lsr#4 @r3 = attrsft = (ntbladr&0x0040)>>4 + add r1, r2, #0x2000 @r1 = ntblAdr + str_ r1, ntblAdr @store ntblAdr + + and r2, r1, #0x001F @r2 = ntbl_x = ntblAdr&0x001F + and r3, r1, #0x40 + mov r3, r3, lsr#4 @r3 = attrsft = (ntblAdr&0x0040)>>4 str_ r2, ntbl_x @store ntbl_x str_ r3, attrsft @store attrsft - + mov r3, r1, lsr#10 ldr r2, =vram_map - ldr r3, [r2, r3, lsl#2] @r3 = pNTBL = PPU_MEM_BANK[ntbladr>>10] + ldr r3, [r2, r3, lsl#2] @r3 = pNTBL = PPU_MEM_BANK[ntblAdr>>10] str_ r3, pNTBL - + and r2, r5, #0xC00 and r4, r5, #0x380 add r1, r2, r4, lsr#4 add r1, r1, #0x2300 - add r1, r1, #0xC0 @r1 = attradr = 0x23C0+(loopy_v&0x0C00)+((loopy_v&0x0380)>>4) - bic r1, r1, #0xFC00 @r1 = attradr &= 0x3FF - str_ r1, attradr - + add r1, r1, #0xC0 @r1 = attrAdr = 0x23C0+(loopy_v&0x0C00)+((loopy_v&0x0380)>>4) + bic r1, r1, #0xFC00 @r1 = attrAdr &= 0x3FF + str_ r1, attrAdr + mov r12, #0xFF @not fixed, r12 = cache_attr add r11, r12, #0xFF00 @not fixed, r11 = cache_tile mov r11, r11, lsl#16 @@ -526,22 +524,22 @@ bg_normal: mov r8, #0 @fixed, r8 = 0 ~ 32 ldr_ r7, pNTBL @fixed, r7 = pNTBL ldr_ r6, attr @fixed, r6 = attr - ldr_ r5, ntbladr @fixed, r5 = ntbladr + ldr_ r5, ntblAdr @fixed, r5 = ntblAdr ldr_ r4, ntbl_x @fixed, r4 = ntbl_x - ldr_ r3, attradr @fixed, r3 = attradr - + ldr_ r3, attrAdr @fixed, r3 = attrAdr + @not fixed, r3 = chr_h @not fixed, r2 = chr_l bglp: - @tileadr = tileofs+pNTBL[ntbladr&0x03FF]*0x10+loopy_y - ldr_ r0, tileofs + @tileadr = tileOfs+pNTBL[ntblAdr&0x03FF]*0x10+loopy_y + ldr_ r0, tileOfs bic r1, r5, #0xFC00 ldr_ r2, loopy_y ldrb r1, [r7, r1] add r9, r0, r2 add r9, r9, r1, lsl#4 @r9 = tileadr, as shown before - - @attr = ((pNTBL[attradr+(ntbl_x>>2)]>>((ntbl_x&2)+attrsft))&3)<<2; + + @attr = ((pNTBL[attrAdr+(ntbl_x>>2)]>>((ntbl_x&2)+attrsft))&3)<<2; add r0, r3, r4, lsr#2 ldrb r0, [r7, r0] and r1, r4, #2 @@ -550,13 +548,13 @@ bglp: mov r0, r0, lsr r1 and r0, r0, #3 mov r6, r0, lsl#2 - + cmp r11, r9 cmpeq r12, r6 cmpeq r8, #0 bne bgnocache - - + + ldr_ r0, pScn sub r2, r0, #8 ldrb r1, [r2], #1 @*(LPDWORD)(pScn+0) = *(LPDWORD)(pScn-8) @@ -591,11 +589,11 @@ bgnocache: ldr r0, [r2, r0, lsl#2] ldrb r11, [r0, r1]! @r11 = chr_l ldrb r12, [r0, #8] @r12 = chr_h - + orr r0, r11, r12 @*pBGw = chr_h|chr_l ldr_ r1, BGwrite strb r0, [r1, r8] - + ldr r5, =nes_palette add r5, r5, r6 @r5 = pBGPAL and r0, r11, #0xAA @@ -604,9 +602,9 @@ bgnocache: and r0, r11, #0x55 and r2, r12, #0x55 orr r4, r0, r2, lsl#1 @r4 = c2 = (chr_l&0x55)|((chr_h<<1)&0xAA) - + ldr_ r2, pScn @r2 = pScn - + cmp r8, #0 bne 0f @normal @@ -620,7 +618,7 @@ bgnocache: strccb r0, [r2, #1] @pScn[1] = pBGPAL[(c2>>6)]; bic r3, r3, #0xC0 @clear bit6 bit7 bic r4, r4, #0xC0 - + cmp r11, #3 ldrccb r0, [r5, r3, lsr#4] @r0 = pBGPAL[(c1>>4)&3] strccb r0, [r2, #2] @pScn[2] = pBGPAL[(c1>>4)&3] @@ -629,7 +627,7 @@ bgnocache: strccb r0, [r2, #3] @pScn[3] = pBGPAL[(c2>>4)&3]; bic r3, r3, #0x30 @clear bit4 bit5 bic r4, r4, #0x30 - + cmp r11, #5 ldrccb r0, [r5, r3, lsr#2] @r0 = pBGPAL[(c1>>2)&3] strccb r0, [r2, #4] @pScn[4] = pBGPAL[(c1>>2)&3] @@ -638,13 +636,13 @@ bgnocache: strccb r0, [r2, #5] @pScn[5] = pBGPAL[(c2>>2)&3]; bic r3, r3, #0xC @clear bit2 bit3 bic r4, r4, #0xC - + cmp r11, #7 ldrccb r0, [r5, r3] @r0 = pBGPAL[c1&3] strccb r0, [r2, #6] @pScn[6] = pBGPAL[c1&3] ldrb r0, [r5, r4] @r0 = pBGPAL[c2&3] strb r0, [r2, #7] @pScn[7] = pBGPAL[c2&3]; - + ldmfd sp!, {r3 - r5, r11 - r12} b bgnext 0: @@ -654,26 +652,26 @@ bgnocache: strb r0, [r2, #1] @pScn[1] = pBGPAL[(c2>>6)]; bic r3, r3, #0xC0 @clear bit6 bit7 bic r4, r4, #0xC0 - + ldrb r0, [r5, r3, lsr#4] @r0 = pBGPAL[(c1>>4)&3] strb r0, [r2, #2] @pScn[2] = pBGPAL[(c1>>4)&3] ldrb r0, [r5, r4, lsr#4] @r0 = pBGPAL[(c2>>4)&3] strb r0, [r2, #3] @pScn[3] = pBGPAL[(c2>>4)&3]; bic r3, r3, #0x30 @clear bit4 bit5 bic r4, r4, #0x30 - + ldrb r0, [r5, r3, lsr#2] @r0 = pBGPAL[(c1>>2)&3] strb r0, [r2, #4] @pScn[4] = pBGPAL[(c1>>2)&3] ldrb r0, [r5, r4, lsr#2] @r0 = pBGPAL[(c2>>2)&3] strb r0, [r2, #5] @pScn[5] = pBGPAL[(c2>>2)&3]; bic r3, r3, #0xC @clear bit2 bit3 bic r4, r4, #0xC - + ldrb r0, [r5, r3] @r0 = pBGPAL[c1&3] strb r0, [r2, #6] @pScn[6] = pBGPAL[c1&3] ldrb r0, [r5, r4] @r0 = pBGPAL[c2&3] strb r0, [r2, #7] @pScn[7] = pBGPAL[c2&3]; - + ldmfd sp!, {r3 - r5, r11 - r12} bgnext: @@ -683,23 +681,23 @@ bgnext: mov r0, r9 adr lr, 0f - ldr_ pc, ppuchrlatch + ldr_ pc, ppuChrLatch 0: add r4, r4, #1 @ntbl_x += 1 cmp r4, #32 - addne r5, r5, #1 @ntbladr++ + addne r5, r5, #1 @ntblAdr++ bne bgnext1 mov r4, #0 eor r5, r5, #0x1F - eor r5, r5, #0x400 @ntbladr ^= 0x41F + eor r5, r5, #0x400 @ntblAdr ^= 0x41F and r2, r5, #0x380 mov r2, r2, lsr#4 - add r3, r2, #0x3C0 @attradr = 0x03C0+((ntbladr&0x0380)>>4) + add r3, r2, #0x3C0 @attrAdr = 0x03C0+((ntblAdr&0x0380)>>4) mov r2, r5, lsr#10 ldr r0, =vram_map - ldr r7, [r0, r2, lsl#2] @pNTBL = PPU_MEM_BANK[ntbladr>>10] - + ldr r7, [r0, r2, lsl#2] @pNTBL = PPU_MEM_BANK[ntblAdr>>10] + bgnext1: add r8, r8, #1 cmp r8, #33 @@ -718,7 +716,7 @@ bg_render_bottom: orr r2, r2, r2, lsl#16 str r2,[r1] - ldr r0, =renderdata + ldr r0, =renderData bl dma_async_fix ldmfd sp!,{r0-r2, pc} @------------ @@ -728,13 +726,13 @@ bg_btm: subs r0, r0, #1 bne bg_btm ldmfd sp!,{r0-r2} - mov pc,lr + bx lr @-------------------------------------------- bg_render_reset: @-------------------------------------------- stmfd sp!,{r0-r1, lr} - ldr r0, =renderdata + ldr r0, =renderData ldr r1, =renderbgdata @mov r2, #256 bl dma_async @@ -746,7 +744,7 @@ render_transfer: stmfd sp!,{r0-r2, lr} ldr r2, =0x6040000 add r0, r2, r0, lsl#8 - ldr r1, =renderdata + ldr r1, =renderData bl dma_async ldmfd sp!, {r0-r2, pc} @@ -755,7 +753,7 @@ render_all: @-------------------------------------------- stmfd sp!,{r0-r2, lr} ldr r0, =0x6000000 - ldr r1, =renderdata@ + 256 * 8 + ldr r1, =renderData@ + 256 * 8 bl dma_async ldmfd sp!, {r0-r2, pc} @@ -764,7 +762,7 @@ render_sub: @-------------------------------------------- stmfd sp!,{r0-r4, lr} ldr r0, =0x6200000 - ldr r1, =renderdata + ldr r1, =renderData ldr r4, =all_pix_start ldr r2, [r4] @@ -786,7 +784,7 @@ render_sub2: @-------------------------------------------- stmfd sp!,{r0-r2, lr} ldr r0, =0x6200000 - ldr r1, =renderdata@ + 256 * 8 + ldr r1, =renderData@ + 256 * 8 bl dma_async ldmfd sp!, {r0-r2, pc} @@ -806,7 +804,7 @@ synclp2: bne synclp2 ldmfd sp!, {r2-r3} - mov pc, lr + bx lr @-------------------------------------------- dma_async: @@ -829,7 +827,7 @@ dma_async: str r0, [r2], #4 str r3, [r2] ldmfd sp!, {r2-r3} - mov pc, lr + bx lr @-------------------------------------------- dma_async_fix: @@ -841,7 +839,7 @@ dma_async_fix: str r0, [r2], #4 str r3, [r2] ldmfd sp!, {r2-r3} - mov pc, lr + bx lr @-------------------------------------------- dma_sync_fix: @@ -858,12 +856,12 @@ synclp: bne synclp ldmfd sp!, {r2-r3} - mov pc, lr + bx lr .section .bss, "aw" .align 4 -renderdata: +renderData: .word 0 .skip 256 * 256 + 16 renderbgdata: diff --git a/arm9/source/romloader.c b/arm9/source/romloader.c index c157998..690464f 100644 --- a/arm9/source/romloader.c +++ b/arm9/source/romloader.c @@ -51,11 +51,11 @@ int is_nsf_file(char *name, char *rom) { //actually the first four chars should be "NESM" if(strstr(name, ".NSF") || strstr(name, ".nsf")) { - memcpy(&nsfheader, rom, sizeof(nsfheader)); + memcpy(&nsfHeader, rom, sizeof(nsfHeader)); __emuflags |= NSFFILE; - __nsfsongno = 0; - __nsfplay = 0; - __nsfinit = 0; + __nsfSongNo = 0; + __nsfPlay = 0; + __nsfInit = 0; IPC_MAPPER = 256; return 1; } @@ -86,9 +86,9 @@ void do_rommenu() { if(!roms) { if(!active_interface) { //another driver is present, but init failed consoletext(64*3,"Device failed.",0); - } else //no DLDI error, no files + } else { //no DLDI error, no files consoletext(64*3,"No roms found.",0); - + } while(1) swiWaitForVBlank(); } showconsole(); @@ -289,7 +289,7 @@ int loadrom() { romcorrect(roms); } initcart(roms); - IPC_MAPPER = debuginfo[16]; + IPC_MAPPER = debuginfo[MAPPER]; load_sram(); //if(autostate) loadstate(..); @@ -337,9 +337,9 @@ int init_rommenu() { struct dirent *cnt = NULL; struct stat statbuf; - if(!active_interface) //DLDI trouble + if(!active_interface) { //DLDI trouble return 0; - + } files = (char**)rom_files; nextfile=(char*)&files[MAXFILES]; dir=opendir("."); //chdir to root @@ -516,9 +516,9 @@ int bootext() { chdir(inibuf); //might be overwritten in readFrontend() // if we didn't have an ini, this'll be blank - if (disksyspath[0] == 0) + if (disksyspath[0] == 0) { strcpy(disksyspath, defaultDisksyspath); - + } FILE* bios = fopen(disksyspath, "r"); if (bios != NULL) { fseek(bios, 0, SEEK_END); diff --git a/arm9/source/rompatch.c b/arm9/source/rompatch.c index 9652f7c..53ffe7f 100644 --- a/arm9/source/rompatch.c +++ b/arm9/source/rompatch.c @@ -3272,7 +3272,7 @@ unsigned int romdb[] = { }; unsigned int crctable[256]; -unsigned int romcrc(unsigned char * c, int size) +unsigned int romcrc(const unsigned char *c, int size) { unsigned int r = 0xFFFFFFFFUL; while( --size >= 0 ) { @@ -3324,4 +3324,4 @@ void romcorrect(char *s) } } } -} \ No newline at end of file +} diff --git a/arm9/source/sound.s b/arm9/source/sound.s index 32a904f..044af66 100644 --- a/arm9/source/sound.s +++ b/arm9/source/sound.s @@ -4,8 +4,8 @@ .global updatesound .global soundwrite .global _4015r -pcmirqbakup = mapperdata+24 -pcmirqcount = mapperdata+28 +pcmirqbakup = mapperData+24 +pcmirqcount = mapperData+28 @--------------------------------------------------------------------------------- .section .text,"ax" @--------------------------------------------------------------------------------- @@ -29,7 +29,7 @@ _4015r: @--------------------------------------------------------------------------------- ldr r1, =IPC_REG4015 @which is updated by s_apu.c ldrb r0, [r1] - mov pc, lr + bx lr @--------------------------------------------------------------------------------- updatesound: @called from line 0.. r0-r9 are free to use @--------------------------------------------------------------------------------- diff --git a/arm9/source/stepdebug.c b/arm9/source/stepdebug.c index a7a150b..79f2d81 100644 --- a/arm9/source/stepdebug.c +++ b/arm9/source/stepdebug.c @@ -63,13 +63,13 @@ void shex(unsigned char *p,int d,int n) { void stepdebug() {/* - static int framecount = 0; - static int line, keys, oldkeys, opcount = 0; + static int frameCount = 0; + static int line, keys, oldkeys, opCount = 0; unsigned int i, count; i = 0; - opcount++; + opCount++; if(line == 240 && __scanline == 241) { - framecount++; + frameCount++; swiWaitForVBlank(); //keys = IPC_KEYS; keys &= ~KEY_SELECT; @@ -83,13 +83,13 @@ void stepdebug() return; } line = __scanline; - shex32(ptbuf + 6, framecount); + shex32(ptbuf + 6, frameCount); shex16(ptbuf + 20, __scanline); shex16(ptbuf + 32 + 3, __pc - __lastbank); shex8(ptbuf + 32 + 8, *__pc); shex8(ptbuf + 32 + 11, *(__pc + 1)); shex8(ptbuf + 32 + 14, *(__pc + 2)); - shex32(ptbuf + 50, opcount); + shex32(ptbuf + 50, opCount); shex8(ptbuf + 64 + 2, __a>>24); shex8(ptbuf + 64 + 7, __x>>24); @@ -107,8 +107,9 @@ void stepdebug() } count = pstep - stepinfo; - if(count > 18 * 4) + if(count > 18 * 4) { count = 18 * 4; + } for(i = 0; i < count; i++) { shex(ptbuf + 192 + i*8, stepinfo[i] >> 12, 3); if(stepinfo[i] & 0x100) { @@ -118,6 +119,7 @@ void stepdebug() } shex(ptbuf + 197 + i*8, stepinfo[i], 1); } + consoletext(0, ptbuf, 0); //memset( ptbuf + 192 + count * 8, 32, (18 * 4 - count) * 8); diff --git a/arm9/source/subscreen.c b/arm9/source/subscreen.c index 683fe3d..559f96e 100644 --- a/arm9/source/subscreen.c +++ b/arm9/source/subscreen.c @@ -33,9 +33,9 @@ int debugdump() { u32 *p; char **cc; - debuginfo[13]=IPC_ALIVE; - debuginfo[14]=IPC_TMP0; - debuginfo[15]=IPC_TMP1; + debuginfo[ALIVE]=IPC_ALIVE; + debuginfo[TMP0]=IPC_TMP0; + debuginfo[TMP1]=IPC_TMP1; p=debuginfo; cc=debugtxt; @@ -61,39 +61,39 @@ int debugdump() { if(count++ != 20) return 0;*/ - debuginfo[21] = __emuflags; + debuginfo[EMUFLAG] = __emuflags; if(1 && (__emuflags & NSFFILE)) { u32 *ip=(u32*)&mapperstate; consoletext (64 * 4 + 0 * 32, "version", 0); - hex8 (64 * 4 + 0 * 32 + 18, nsfheader.Version); + hex8 (64 * 4 + 0 * 32 + 18, nsfHeader.Version); consoletext (64 * 4 + 1 * 32, "startson", 0); - hex8 (64 * 4 + 1 * 32 + 18, nsfheader.StartSong); + hex8 (64 * 4 + 1 * 32 + 18, nsfHeader.StartSong); consoletext (64 * 4 + 2 * 32, "totalsong", 0); - hex8 (64 * 4 + 2 * 32 + 18, nsfheader.TotalSong); + hex8 (64 * 4 + 2 * 32 + 18, nsfHeader.TotalSong); consoletext (64 * 4 + 3 * 32, "LoadAddr", 0); - hex16 (64 * 4 + 3 * 32 + 18, nsfheader.LoadAddress); + hex16 (64 * 4 + 3 * 32 + 18, nsfHeader.LoadAddress); consoletext (64 * 4 + 4 * 32, "InitAddr", 0); - hex16 (64 * 4 + 4 * 32 + 18, nsfheader.InitAddress); + hex16 (64 * 4 + 4 * 32 + 18, nsfHeader.InitAddress); consoletext (64 * 4 + 5 * 32, "PlayAddr", 0); - hex16 (64 * 4 + 5 * 32 + 18, nsfheader.PlayAddress); + hex16 (64 * 4 + 5 * 32 + 18, nsfHeader.PlayAddress); for(i=0;i<10;i++) { hex32(64*7+i*32,ip[i]); } consoletext (64 * 16 + 0 * 32, "songno", 0); - hex16 (64 * 16 + 0 * 32 + 18, __nsfsongno); + hex16 (64 * 16 + 0 * 32 + 18, __nsfSongNo); consoletext (64 * 16 + 1 * 32, "songmode", 0); - hex16 (64 * 16 + 1 * 32 + 18, __nsfsongmode); + hex16 (64 * 16 + 1 * 32 + 18, __nsfSongMode); consoletext (64 * 16 + 2 * 32, "play", 0); - hex16 (64 * 16 + 2 * 32 + 18, __nsfplay); + hex16 (64 * 16 + 2 * 32 + 18, __nsfPlay); consoletext (64 * 16 + 3 * 32, "init", 0); - hex16 (64 * 16 + 3 * 32 + 18, __nsfinit); + hex16 (64 * 16 + 3 * 32 + 18, __nsfInit); for(i = 0; i < 4; i++) { hex32(64 * 20 + i * 32, (u32)__memmap_tbl[i + 4] + 0x2000 * i + 0x8000); } - } else if(debuginfo[16] == 20) { + } else if(debuginfo[MAPPER] == 20) { u8 *p=(u8*)&mapperstate;//0x7000000; u32 *ip=(u32*)&mapperstate;//0x7000000; for(i=0;i<18;i++) { diff --git a/include/c_defs.h b/include/c_defs.h index 935d34f..fef6bc6 100644 --- a/include/c_defs.h +++ b/include/c_defs.h @@ -89,9 +89,27 @@ void showconsole(void); //subscreen.c int debugdump(void); +#define ERR0 0 +#define ERR1 1 +#define READ 2 +#define WRITE 3 +#define BRK 4 +#define BADOP 5 #define VBLS 6 #define FPS 7 -extern u32 debuginfo[]; +#define BGMISS 8 +#define CARTFLAG 9 + +#define ALIVE 13 +#define TMP0 14 +#define TMP1 15 +#define MAPPER 16 +#define PRGCRC 17 +#define DISKNO 18 +#define MAKEID 19 +#define GAMEID 20 +#define EMUFLAG 21 + int debugdump(void); //romloader.c @@ -151,13 +169,13 @@ void fdscmdwrite(u8 diskno); void Sound_reset(); //*.s -//emuflags: +//emuFlags: #define NOFLICKER 1 #define ALPHALERP 2 //joyflags #define B_A_SWAP 0x80000 #define L_R_DISABLE 0x100000 -//cartflags +//cartFlags #undef SRAM #define SRAM 0x02 @@ -172,15 +190,15 @@ extern u8 mapperstate[96]; //6502.s extern u32 __scanline; extern u8 __barcode; extern u8 __barcode_out; -extern u32 __af_st; +extern u32 __af_state; extern u32 __af_start; extern u32 __prgsize16k; -extern u32 __nsfplay; -extern u32 __nsfinit; -extern u32 __nsfsongno; -extern u32 __nsfsongmode; +extern u32 __nsfPlay; +extern u32 __nsfInit; +extern u32 __nsfSongNo; +extern u32 __nsfSongMode; -extern struct nsfheader +extern struct nsfHeader { char ID[5]; char Version; @@ -198,7 +216,7 @@ extern struct nsfheader char NTSC_PALbits; char ExtraChipSelect; char Expansion[4]; // must be 0 -} nsfheader; +} nsfHeader; void EMU_VBlank(void); void EMU_Run(void);