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

Some small clean up. #21

Merged
merged 1 commit into from
Jul 13, 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
3 changes: 2 additions & 1 deletion arm9/include/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ _m_ opz,256*4
_m_ m6502ReadTbl,8*4
_m_ m6502WriteTbl,8*4
_m_ m6502MemTbl,8*4
_m_ cpuregs,7*4
_m_ cpuregs,6*4
_m_ m6502RegPC,4
_m_ m6502_s,4
_m_ m6502LastBank,4
_m_ nexttimeout,4
Expand Down
134 changes: 67 additions & 67 deletions arm9/source/cart.s
Original file line number Diff line number Diff line change
Expand Up @@ -121,35 +121,35 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
@---------------------------------------------------------------------------------
stmfd sp!,{r4-r11,lr}

ldr globalptr,=globals @init ptr regs
ldr globalptr,=globals @ init ptr regs
ldr m6502zpage,=NES_RAM

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
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

mov r2,#1
ldrb r1,[r3,#-12] @r1 = 16K PRG-ROM page count
movne r1, #1 @nsf has 16k?
str_ r1,prgSize16k @some games' prg rom not == to (2**n), shit...
ldrb r1,[r3,#-12] @ r1 = 16K PRG-ROM page count
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
mov r0, r1, lsr#1
str_ r0,prgSize32k

rsb r0,r2,r1,lsl#14 @r0 = page count * 16K - 1
str_ r0,romMask @romMask=romSize-1
rsb r0,r2,r1,lsl#14 @ r0 = page count * 16K - 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
add r0,r3,r1,lsl#14 @ r0 = rom end.(romsize + rom start)
str_ r0,vromBase @ set vrom base

ldrb r4,[r3,#-11] @8K CHR-ROM page count
movne r4, #0 @nsf has none?
mov r1,r4 @r1=vrom size
cmp r4,#2 @round up
movhi r1,#4 @needs to be power of 2 (stupid zelda2)
ldrb r4,[r3,#-11] @ 8K CHR-ROM page count
movne r4, #0 @ nsf has none?
mov r1,r4 @ r1=vrom size
cmp r4,#2 @ round up
movhi r1,#4 @ needs to be power of 2 (stupid zelda2)
cmp r4,#4
movhi r1,#8
cmp r4,#8
Expand All @@ -160,10 +160,10 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
movhi r1,#64
cmp r4,#64
movhi r1,#128
rsbs r0,r2,r1,lsl#13 @r0 = VROM page size * 8K - 1
str_ r0,vromMask @vromMask=vromSize-1
rsbs r0,r2,r1,lsl#13 @ r0 = VROM page size * 8K - 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

ldr r0,=void
ldrmi r0,=VRAM_chr @ enable/disable chr write
Expand All @@ -172,11 +172,11 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
bl filler

stmfd sp!, {r3, r12}
mov r0, #0 @init val, cal crc for prgrom
ldr_ r1, romBase @src
ldr_ r2, prgSize8k @size
mov r0, #0 @ init val, cal crc for prgrom
ldr_ r1, romBase @ src
ldr_ r2, prgSize8k @ size
mov r2, r2, lsl#13
swi 0x0e0000 @swicrc16
swi 0x0e0000 @ swicrc16
str_ r0, prgcrc
DEBUGINFO PRGCRC, r0
ldmfd sp!, {r3, r12}
Expand All @@ -187,42 +187,42 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
ldr_ r1,emuFlags
tst r1, #NSFFILE
bne 0f
mov r0,#0 @default ROM mapping
bl map89AB_ @89AB=1st 16k
mov r0,#0 @ default ROM mapping
bl map89AB_ @ 89AB=1st 16k
mov r0,#-1
bl mapCDEF_ @CDEF=last 16k
bl mapCDEF_ @ CDEF=last 16k
0:
bl resetCHR @default CHR mapping
bl resetCHR @ default CHR mapping

ldrb r0,[r3,#-10] @rom control byte #1
ldrb r1,[r3,#-9] @rom control byte #2
and r0,r0,#0x0f @exclude mapper
ldrb r0,[r3,#-10] @ rom control byte #1
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,m6502zpage @m6502zpage,=NES_RAM
mov r0,#0x0 @ clear nes ram reset value changed from 0xFFFFFFFF to 0x0
mov r1,m6502zpage @ m6502zpage,=NES_RAM
mov r2,#0x800/4
bl filler @reset NES RAM
mov r0,#0 @clear nes sram
add r1,m6502zpage,#0x800 @save ram = SRAM
bl filler @ reset NES RAM
mov r0,#0 @ clear nes sram
add r1,m6502zpage,#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

mov r0,#0x7c @I didnt like the way below to change the init mem for fixing some games.
mov r0,#0x7c @ I didnt like the way below to change the init mem for fixing some games.
mov r1,m6502zpage
ldr r2,=0x247d @0x7c7d
strb r0,[r1,r2] @for "Low G Man".
ldr r2,=0x247d @ 0x7c7d
strb r0,[r1,r2] @ for "Low G Man".
add r2,r2,#0x100
mov r0,#0x7d
strb r0,[r1,r2] @for "Low G Man".
strb r0,[r1,r2] @ for "Low G Man".

ldr r0,=joy0_W
ldr r1,=joypad_write_ptr
Expand All @@ -236,7 +236,7 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)

ldr r0, =0x4000004
mov r1, #0x8
strh r1, [r0] @disable hblank process.
strh r1, [r0] @ disable hblank process.

ldr r1,=IO_R @reset other writes..
str_ r1,m6502ReadTbl+8
Expand All @@ -246,29 +246,29 @@ initcart: @called from C: r0=rom, (r1=emuFlags?)
str_ r1,m6502WriteTbl+8
ldr r1,=sram_W
str_ r1,m6502WriteTbl+12
ldr r1,=NES_RAM-0x5800 @$6000 for mapper 40, 69 & 90 that has rom here.
ldr r1,=NES_RAM-0x5800 @ $6000 for mapper 40, 69 & 90 that has rom here.
str_ r1,m6502MemTbl+12
ldr r1,=NES_XRAM-0x2000
str_ r1,m6502MemTbl+4
ldr r1,=NES_XRAM-0x4000
str_ r1,m6502MemTbl+8

ldrb r1,[r3,#-10] @get mapper#
ldrb r1,[r3,#-10] @ get mapper#
ldrb r2,[r3,#-9]
tst r2,#0x0e @long live DiskDude!
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
movne r0,r1,lsr#4 @ ignore high nibble if header looks bad
@lookup mapper*init

ldrb r1, [r3, #-16] @fds, for 'F'
ldrb r1, [r3, #-16] @ fds, for 'F'
cmp r1, #70
ldreqb r1, [r3, #-15] @fds, for 'D'
cmpeq r1, #68
ldreqb r1, [r3, #-14] @fds, for 'S'
cmpeq r1, #83
moveq r0, #20 @this is a fds file...
moveq r0, #20 @ this is a fds file...

ldr_ r1,emuFlags
tst r1, #NSFFILE
Expand All @@ -282,19 +282,19 @@ lc0: ldr r2,[r1],#8
teq r2,r0
beq lc1
bpl lc0
lc1: @call mapperXXinit
lc1: @ call mapperXXinit
adr_ r5,m6502WriteTbl+16
ldr r0,[r1,#-4] @r0 = mapperxxxinit
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.
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)
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
bl recorder_reset @ init rewind control stuff

ldmfd sp!,{r4-r11,pc}
@---------------------------------------------------------------------------------
Expand All @@ -306,17 +306,17 @@ savestate:
ldr globalptr,=globals

ldr_ r2,romBase
rsb r2,r2,#0 @adjust rom maps,etc so they aren't based on 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
mov r0,#0 @r0 holds total size (return value)
mov r6,r0 @ r6=where to copy state
mov r0,#0 @ r0 holds total size (return value)

adr r4,savelst @r4=list of stuff to copy
mov r3,#(lstend-savelst)/8 @r3=items in list
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
ldr r1,[r4],#4 @r1=how much to copy
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
Expand All @@ -326,7 +326,7 @@ 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}
Expand All @@ -341,10 +341,10 @@ savelst: .word NES_RAM,0x2800
.word cpustate,44
.word ppustate,64
lstend:
@c_defs: #define SAVESTATESIZE (0x2800+0x3000+96+64+16+96+16+44+48)
@c_defs: #define SAVESTATESIZE (0x2800+0x3000+96+64+16+96+16+44+64)

fixromptrs: @add r2 to some things
adr_ r1,m6502MemTbl+16
adr_ r1,m6502MemTbl+4*4
ldmia r1,{r3-r6}
add r3,r3,r2
add r4,r4,r2
Expand All @@ -356,9 +356,9 @@ fixromptrs: @add r2 to some things
add r3,r3,r2
str_ r3,m6502LastBank

ldr_ r3,cpuregs+6*4 @6502 PC
ldr_ r3,m6502RegPC
add r3,r3,r2
str_ r3,cpuregs+6*4
str_ r3,m6502RegPC

bx lr
@---------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/mappers/map87.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.section .text,"ax"
@---------------------------------------------------------------------------------
@ Jaleco J87
@ USed in:
@ Used in:
@ Argus (J)
@ City Connection (J)
@ Ninja Jajamaru Kun
Expand Down
1 change: 0 additions & 1 deletion arm9/source/mappers/map91.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ addhi:
beq mapAB_
bx lr


@---------------------------------------------------------------------------------
hsync:
ldr_ r0, scanline
Expand Down
24 changes: 12 additions & 12 deletions arm9/source/menu_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern u32 agb_bg_map[];

u8 gammavalue = 0;

u8 nes_rgb[] = {
u8 nes_rgb[] = {
0x75,0x75,0x75, 0x27,0x1b,0x8f, 0x00,0x00,0xab, 0x47,0x00,0x9f, 0x8f,0x00,0x77, 0xab,0x00,0x13, 0xa7,0x00,0x00, 0x7f,0x0b,0x00,
0x43,0x2f,0x00, 0x00,0x47,0x00, 0x00,0x51,0x00, 0x00,0x3f,0x17, 0x1b,0x3f,0x5f, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
0xbc,0xbc,0xbc, 0x00,0x73,0xef, 0x23,0x3b,0xef, 0x83,0x00,0xf3, 0xbf,0x00,0xbf, 0xe7,0x00,0x5b, 0xdb,0x2b,0x00, 0xcb,0x4f,0x0f,
Expand Down Expand Up @@ -125,7 +125,7 @@ void show_all_pixel(void)
menu_stat = 3;
__emuflags ^= ALLPIXELON;
if(__emuflags & ALLPIXELON) {
consoletext(64*18 + 32, "YES", 0x1000);
consoletext(64*18 + 32, "YES", 0x1000);
}
else
consoletext(64*18 + 32, "NO ", 0x1000);
Expand Down Expand Up @@ -332,7 +332,7 @@ void menu_display_start(void)
consoletext(64*4 + 42, "Frame-skip\rPureSoft:", 0);
hex8(64*5 + 30*2, soft_frameskip - 1);
consoletext(64*11 + 23*2, "Palette\rsync:", 0);
consoletext(64*12 + 28*2, __emuflags&PALSYNC ? "On " : "Off", 0x1000);
consoletext(64*12 + 28*2, __emuflags&PALSYNC ? "On " : "Off", 0x1000);
consoletext(64*5 + 32, brightxt[gammavalue], 0x1000);
hex8(64*8 + 36, palette_value);
consoletext(64*10 + 20, paltxt[palette_value], 0x1000);
Expand Down Expand Up @@ -516,7 +516,7 @@ void menu_display_br(void)
int type = lastbutton_cnt - 4;
int i;
__emuflags &= ~(3 << 6);
__emuflags += type << 6;
__emuflags += type << 6;

switch(type) {
case 0:
Expand Down Expand Up @@ -578,7 +578,7 @@ void menu_display_br(void)
__emuflags ^= PALSYNC;
if(__emuflags & (SOFTRENDER | PALTIMING))
__emuflags &= ~PALSYNC;
consoletext(64*12 + 28*2, __emuflags&PALSYNC ? "On " : "Off", 0x1000);
consoletext(64*12 + 28*2, __emuflags&PALSYNC ? "On " : "Off", 0x1000);
}
else if(lastbutton_cnt == 10) {
gammavalue++;
Expand Down Expand Up @@ -620,28 +620,28 @@ void palset(void) {
memcpy(nes_rgb,nes_rgb_2,192);
}
else if(palette_value == 3) {
memcpy(nes_rgb,nes_rgb_3,192);
memcpy(nes_rgb,nes_rgb_3,192);
}
else if(palette_value == 4) {
memcpy(nes_rgb,nes_rgb_4,192);
memcpy(nes_rgb,nes_rgb_4,192);
}
else if(palette_value == 5) {
memcpy(nes_rgb,nes_rgb_5,192);
memcpy(nes_rgb,nes_rgb_5,192);
}
else if(palette_value == 6) {
memcpy(nes_rgb,nes_rgb_6,192);
memcpy(nes_rgb,nes_rgb_6,192);
}
else if(palette_value == 7) {
memcpy(nes_rgb,nes_rgb_7,192);
}
else if(palette_value == 8) {
memcpy(nes_rgb,nes_rgb_8,192);
memcpy(nes_rgb,nes_rgb_8,192);
}
else if(palette_value == 9) {
memcpy(nes_rgb,nes_rgb_9,192);
memcpy(nes_rgb,nes_rgb_9,192);
}
else if(palette_value == 10) {
memcpy(nes_rgb,nes_rgb_10,192);
memcpy(nes_rgb,nes_rgb_10,192);
}
else if(palette_value == 11) {
memcpy(nes_rgb,nes_rgb_11,192);
Expand Down
4 changes: 2 additions & 2 deletions arm9/source/rompatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -3316,8 +3316,8 @@ void romcorrect(char *s)
if(oldmapper == newmapper) {
rom[6] = tmp & 0xff;
rom[7] = (tmp >> 8) & 0xff;
__emuflags &= ~PALTIMING;
if(! (tmp & (1 << 16)))
__emuflags &= ~PALTIMING;
if(! (tmp & (1 << 16)))
__emuflags |= PALTIMING;
}
break;
Expand Down
Loading
Loading