Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#23 Fixed MMC3 mappers a bit, added mapper37. #24

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif
export TARGET := nesDS
export TOPDIR := $(CURDIR)

# GMAE_ICON is the image used to create the game icon, leave blank to use default rule
# GAME_ICON is the image used to create the game icon, leave blank to use default rule
GAME_ICON :=

# specify a directory which contains the nitro filesystem
Expand Down
2 changes: 1 addition & 1 deletion arm9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
CFLAGS := -g -Wall -O2 -DNO_VIZ\
$(ARCH) $(INCLUDE) -DARM9
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH) $(INCLUDE)
ASFLAGS := -g $(ARCH) $(INCLUDE) -DARM7SOUND
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions arm9/include/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ _m_ romMask,4
_m_ prgSize8k,4
_m_ prgSize16k,4
_m_ prgSize32k,4
_m_ mapperInitPtr,4
_m_ emuFlags,4
_m_ prgcrc,4

Expand Down
1 change: 1 addition & 0 deletions arm9/source/NesMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef struct {
u32 prgSize8k;
u32 prgSize16k;
u32 prgSize32k;
u32 mapperInitPtr;
u32 emuFlags;
u32 prgCrc;

Expand Down
31 changes: 18 additions & 13 deletions arm9/source/cart.s
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mappertbl:
.word 32,mapper32init
.word 33,mapper33init
.word 34,mapper34init
.word 37,mapper37init
.word 40,mapper40init
.word 42,mapper42init
.word 47,mapper47init
Expand Down Expand Up @@ -201,7 +202,7 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
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)
@DEBUGINFO CARTFLAG, r1
@DEBUGINFO CARTFLAG r1

ldr r0,=void
str_ r0,scanlineHook @ no mapper irq
Expand Down Expand Up @@ -284,11 +285,11 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)

ldrb r1,[r3,#-10] @ get mapper#
ldrb r2,[r3,#-9]
tst r2,#0x0e @ long live DiskDude!
and r1,r1,#0xf0
and r2,r2,#0xf0
orr r0,r2,r1,lsr#4
movne r0,r1,lsr#4 @ ignore high nibble if header looks bad
and r0,r2,#0x0C @ long live DiskDude!
cmp r0,#0x04
moveq r2,#0 @ ignore high nibble if header looks bad
and r0,r2,#0xf0
orr r0,r0,r1,lsr#4
@lookup mapper*init

ldrb r1, [r3, #-16] @ fds, for 'F'
Expand All @@ -307,7 +308,8 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
@---
DEBUGINFO MAPPER r0
@---
lc0: ldr r2,[r1],#8
lc0:
ldr r2,[r1],#8
teq r2,r0
beq lc1
bpl lc0
Expand All @@ -316,11 +318,7 @@ lc1: @ call mapperXXinit
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 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)
str_ r0,mapperInitPtr

bl NES_reset
bl recorder_reset @ init rewind control stuff
Expand Down Expand Up @@ -445,9 +443,16 @@ NES_reset:
@---------------------------------------------------------------------------------
stmfd sp!,{r4-r11,lr}

ldr globalptr,=globals @need this?
ldr globalptr,=globals
ldr m6502zpage,=NES_RAM

ldr_ r0,mapperInitPtr
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)

bl PPU_reset
ldr r0,=rp2A03SetNMIPin
str_ r0,ppuIrqFunc
Expand Down
138 changes: 20 additions & 118 deletions arm9/source/mappers/map118.s
Original file line number Diff line number Diff line change
@@ -1,124 +1,29 @@
@---------------------------------------------------------------------------------
#include "equates.h"
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
#include "mmc3.i"
;@----------------------------------------------------------------------------
.global mapper118init

irq_latch = mapperData+0
irq_enable = mapperData+1
irq_reload = mapperData+2
irq_counter = mapperData+3

reg0 = mapperData+4
reg1 = mapperData+5
reg2 = mapperData+6
reg3 = mapperData+7
reg4 = mapperData+8
reg5 = mapperData+9
reg6 = mapperData+10
reg7 = mapperData+11

chr01 = mapperData+12
chr23 = mapperData+13
chr4 = mapperData+14
chr5 = mapperData+15
chr6 = mapperData+16
chr7 = mapperData+17

prg0 = mapperData+18
prg1 = mapperData+19

@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
.section .text,"ax"
@---------------------------------------------------------------------------------
@ MMC3 on TKSROM & TLSROM boards
@ Used in:
@ Armadillo
@ Pro Sport Hockey
@ Also see mapper 95, 158 & 207
;@----------------------------------------------------------------------------
;@ MMC3 on TKSROM & TLSROM boards
;@ Used in:
;@ Armadillo
;@ Pro Sport Hockey
;@ Also see mapper 95, 158 & 207
mapper118init:
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
.word write0, empty_W, mmc3CounterW, mmc3IrqEnableW
b mapper4init+4*4

@-------------------------------------------------------------------
setbank_ppu:
@-------------------------------------------------------------------
stmfd sp!, {lr}
b mmc3Init

ldrb_ r0, reg0
tst r0, #0x80
beq 0f

mov r1, #0
ldrb_ r0, chr4
bl chr1k
mov r1, #1
ldrb_ r0, chr5
bl chr1k
mov r1, #2
ldrb_ r0, chr6
bl chr1k
mov r1, #3
ldrb_ r0, chr7
bl chr1k
mov r1, #4
ldrb_ r0, chr01
bl chr1k
mov r1, #5
ldrb_ r0, chr01
add r0, r0, #1
bl chr1k
mov r1, #6
ldrb_ r0, chr23
bl chr1k
mov r1, #7
ldrb_ r0, chr23
add r0, r0, #1
bl chr1k
ldmfd sp!, {pc}

0:
mov r1, #0
ldrb_ r0, chr01
bl chr1k
mov r1, #1
ldrb_ r0, chr01
add r0, r0, #1
bl chr1k
mov r1, #2
ldrb_ r0, chr23
bl chr1k
mov r1, #3
ldrb_ r0, chr23
add r0, r0, #1
bl chr1k
mov r1, #4
ldrb_ r0, chr4
bl chr1k
mov r1, #5
ldrb_ r0, chr5
bl chr1k
mov r1, #6
ldrb_ r0, chr6
bl chr1k
mov r1, #7
ldrb_ r0, chr7
bl chr1k
ldmfd sp!, {pc}

@------------------------------------
write0:
@------------------------------------
stmfd sp!, {lr}
;@----------------------------------------------------------------------------
write0: ;@ 8000-9FFF
;@----------------------------------------------------------------------------
tst addy, #1
bne w8001

strb_ r0, reg0
bl mmc3SetBankCpu
bl setbank_ppu
ldmfd sp!, {pc}
beq mmc3MappingW

w8001:
stmfd sp!, {lr}
strb_ r0, reg1
ldrb_ r1, reg0
tst r1, #0x80
Expand All @@ -128,22 +33,19 @@ w8001:
bne 1f
adr lr, 1f
tst r0, #0x80
ldmfd sp!, {lr}
b mirror1H_
0:
cmp r1, #0
bne 1f
tst r0,#0x8
bl mirror1H_
1:
ldrb_ r1, reg0
ldmfd sp!, {lr}
ldrb_ r0, reg1
ldrb_ r1, reg0
and r1, r1, #7
cmp r1, #2
andcc r0, r0, #0xfe
adrl_ r2, chr01
strb r0, [r2, r1]
ldmfd sp!, {lr}
cmp r1, #6
bcc setbank_ppu
bcc mmc3SetBankPpu
b mmc3SetBankCpu
Loading
Loading