Skip to content

Commit

Permalink
A couple more fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
FluBBaOfWard committed May 22, 2024
1 parent c87876d commit 26e8e72
Show file tree
Hide file tree
Showing 43 changed files with 219 additions and 228 deletions.
4 changes: 2 additions & 2 deletions arm9/include/6502mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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,m6502LastBank
add m6502_pc,m6502_pc,r0
Expand Down Expand Up @@ -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=?
Expand Down
46 changes: 20 additions & 26 deletions arm9/include/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -120,9 +117,9 @@ 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_ m6502LastBank,4
Expand Down Expand Up @@ -153,7 +150,7 @@ _m_ ppuCtrl0,1
_m_ ppuCtrl0Frame,1
_m_ ppuCtrl1,1
_m_ ppuOamAdr,1
_m_ nes_chr_map,16
_m_ nesChrMap,16

_m_ vromMask,4
_m_ vromBase,4
Expand All @@ -164,14 +161,13 @@ _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_ romBase,4
_m_ romMask,4
_m_ prgSize8k,4
_m_ prgSize16k,4
_m_ prgSize32k,4
_m_ emuFlags,4
_m_ prgcrc,4

_m_ lightY,4
Expand Down Expand Up @@ -209,11 +205,11 @@ _m_ nsfsongmode, 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
Expand All @@ -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
Expand All @@ -257,12 +253,10 @@ REWIND = 0x40000
ALLPIXELON = 0x80000
NSFFILE = 0x100000
DISKBIOS = 0x200000
@? EQU 64
@? EQU 128


@------------------------multi-players
@in every frame, 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.
Expand Down
20 changes: 9 additions & 11 deletions arm9/source/6502.s
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
.global __lastbank
.global __sp
.global __scanline
.global __nes_chr_map
.global __memmap_tbl
.global __rombase
.global debugstep
Expand Down Expand Up @@ -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]!
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1409,16 +1408,16 @@ 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
Expand All @@ -1427,7 +1426,7 @@ op_table:
.word mem_WA0 @$A000
.word mem_WC0 @$C000
.word mem_WE0 @$E000
@memmap_tbl
@m6502MemTbl
__memmap_tbl:
.word NES_RAM @$0000 0000-7fff
.word NES_XRAM-0x2000 @$2000 should
Expand Down Expand Up @@ -1490,7 +1489,7 @@ ppustate:
.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
Expand All @@ -1514,7 +1513,6 @@ __rombase:

@add others
.word 0 @romMask
.word 0 @romnumber
.word 0 @prgSize8k
__prgsize16k:
.word 0 @prgSize16k
Expand Down Expand Up @@ -1567,7 +1565,7 @@ all_pix_end:
.word 0

__af_state:
.word 0 @af_st
.word 0 @af_state
__af_start:
.word 0x101 @af_start 30 fps
__palsyncline:
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/about.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ int nesds_about()
}

return 0;
}
}
Loading

0 comments on commit 26e8e72

Please sign in to comment.