Skip to content

Commit

Permalink
Optimized scroll Y write.
Browse files Browse the repository at this point in the history
Fixed VRAM mirroring of top name tables.
Fixed read buffer when reading from palette.
Fixed sprite dma.
Moved a few things from the cpu to the ppu.
Cleaned up comments in render.s
  • Loading branch information
FluBBaOfWard committed Jun 8, 2024
1 parent 1f6c2d8 commit 4f0356c
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 381 deletions.
29 changes: 0 additions & 29 deletions arm9/source/6502.s
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
.global __prgsize16k
.global all_pix_start
.global all_pix_end
.global ntsc_pal_reset
.global debugwrite
.global debugwrite_c
.global nsfHeader
Expand Down Expand Up @@ -1039,9 +1038,6 @@ line0:
bl ppusync

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
Expand Down Expand Up @@ -1323,34 +1319,11 @@ VecCont:
fiveminutes: .word 5*60*60
sleeptime: .word 5*60*60
dontstop: .word 0
PAL60: .byte 0
.align
@---------------------------------------------------------------------------------
ntsc_pal_reset:
@---------------------------------------------------------------------------------
@---NTSC/PAL
mov r2, globalptr
ldr globalptr,=globals

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
ldreq r1,=261 @NTSC
ldrne r1,=311 @PAL
str_ r1,lastScanline
mov globalptr, r2

bx lr
@---------------------------------------------------------------------------------
CPU_reset: @called by loadcart (r0-r9 are free to use)
@---------------------------------------------------------------------------------
str lr,[sp,#-4]!

@---NTSC/PAL
bl ntsc_pal_reset
@---cpu reset
mov m6502_a,#0
mov m6502_x,#0
Expand All @@ -1361,8 +1334,6 @@ CPU_reset: @called by loadcart (r0-r9 are free to use)
str_ r0,m6502_s @S=0xFD (0x100-3)
mov cycles,#0 @D=0, C=0, V=0, I=1 disable IRQ.

str_ m6502_a,frame @frame count reset

@(clear irq/nmi/res source)...

ldr r12,=RES_VECTOR
Expand Down
44 changes: 19 additions & 25 deletions arm9/source/io.s
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ io_write_tbl:
.word soundwrite @pAPU Delta Modulation D/A Register 0x4011
.word soundwrite @pAPU Delta Modulation Address Register 0x4012
.word soundwrite @pAPU Delta Modulation Data Length Register 0x4013
.word dma_W @$4014: Sprite DMA transfer
.word _4014W @$4014: Sprite DMA transfer
.word soundwrite
joypad_write_ptr:
.word joy0_W @$4016: Joypad 0 write
Expand All @@ -78,34 +78,28 @@ FDS_W:
cmp r2, #0x90
bcs empty_W
b soundwrite
@---------------------------------------------------------------------------------
dma_W: @(4014) sprite DMA transfer
@shell we edit?
@---------------------------------------------------------------------------------
PRIORITY = 0x000 @0x800=AGB OBJ priority 2/3

ldr r1,=3*513*CYCLE @ was 512... 513/514 is the right number...
;@----------------------------------------------------------------------------
_4014W: ;@ Transfer 256 bytes from written page to $2004
;@----------------------------------------------------------------------------
ldr r1,=513*3*CYCLE @ 513/514 is the right number...
sub cycles,cycles,r1
stmfd sp!,{r3-r8,lr}
stmfd sp!,{r3-r4,lr}

and r1,r0,#0xe0
adr_ addy,m6502MemTbl
ldr addy,[addy,r1,lsr#3]
adr_ r2,m6502MemTbl
ldr r2,[r2,r1,lsr#3]
and r0,r0,#0xff
add addy,addy,r0,lsl#8 @addy=DMA source

mov r0, addy
ldr r1, =NES_SPRAM
mov r7, #240/5/4
cpsp:
ldmia r0!, {r2-r6}
stmia r1!, {r2-r6}
subs r7, r7, #1
bne cpsp
ldmia r0!, {r2-r5}
stmia r1!, {r2-r5}

ldmfd sp!,{r3-r8,pc}
add r3,r2,r0,lsl#8 @ r3=DMA source
mov r4,#0x100
dmaLoop:
ldrb r0,[r3],#1
bl ppuOamDataW
subs r4,r4,#1
bne dmaLoop

ldmfd sp!,{r3-r4,lr}
bx lr

@---------------------------------------------------------------------------------
refreshNESjoypads: @call every frame
@used to refresh joypad button status
Expand Down
Loading

0 comments on commit 4f0356c

Please sign in to comment.