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

Clean mappers #26

Merged
merged 3 commits into from
Jul 20, 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 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) -DARM7SOUND
ASFLAGS := -g $(ARCH) $(INCLUDE) -DCPU_RP2A03 -DARM7SOUND
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
Expand Down
150 changes: 75 additions & 75 deletions arm9/include/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ IPC_TOUCH_Y = IPC+4
IPC_KEYS = IPC+8
IPC_MEMTBL = IPC+16
IPC_REG4015 = IPC+32
IPC_APUIRQ = IPC+33 //not implemented yet.
IPC_APUIRQ = IPC+33 // Not implemented yet.

KEY_A = 1
KEY_B = 2
Expand All @@ -33,51 +33,51 @@ KEY_X = 1024
KEY_Y = 2048
KEY_TOUCH = 4096

@DMA buffers go in high RAM - stay below 27ffc00 (firmware settings)
;@ DMA buffers go in high RAM - stay below 27ffc00 (firmware settings)
DISPCNTBUFF = ct_buffer
BGCNTBUFF = DISPCNTBUFF + 512*4 @size is 240*16
BGCNTBUFF = DISPCNTBUFF + 512*4 ;@ Size is 240*16
BGCNTBUFFB = BGCNTBUFF + 256 * 16

@miscellaneous stuff
;@ Miscellaneous stuff

NES_RAM = nes_region @keep $400 byte aligned for 6502 stack
NES_SRAM = NES_RAM+0x0800 @***!!! also in c_defs.h
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 @mapped NES palette (for VS unisys)
@? EQU MAPPED_RGB+64*3
MAPPED_RGB = CHR_DECODE+0x400 ;@ Mapped NES palette (for VS unisys)
;@? EQU MAPPED_RGB+64*3

NDS_VRAM = 0x6000000
NDS_OAM = 0x7000000
NDS_BG = 0x607C000
NDS_OBJVRAM = 0x6400000
@-----------
;@-----------

REG_BASE = 0x4000000
REG_DISPCNT = 0x00
REG_DISPSTAT = 0x04
REG_DISPSTAT = 0x04
REG_BG0CNT = 0x08
REG_BG0HOFS = 0x10
@REG_BG0VOFS EQU 0x12
@REG_BG1HOFS EQU 0x14
@REG_BG1VOFS EQU= 0x16
REG_BG0VOFS = 0x12
REG_BG1HOFS = 0x14
REG_BG1VOFS = 0x16
REG_DM0SAD = 0xB0
REG_DM0DAD = 0xB4
REG_DM0CNT_L = 0xB8
REG_DM0CNT_H = 0xBA
REG_DM0CNT_L = 0xB8
REG_DM0CNT_H = 0xBA
REG_DM1SAD = 0xBC
REG_DM1DAD = 0xC0
REG_DM1CNT_L = 0xC4
REG_DM1CNT_H = 0xC6
REG_DM1CNT_L = 0xC4
REG_DM1CNT_H = 0xC6
REG_DM2SAD = 0xC8
REG_DM2DAD = 0xCC
REG_DM2CNT_L = 0xD0
REG_DM2CNT_H = 0xD2
REG_DM2CNT_L = 0xD0
REG_DM2CNT_H = 0xD2
REG_DM3SAD = 0xD4
REG_DM3DAD = 0xD8
REG_DM3CNT_L = 0xDC
REG_DM3CNT_H = 0xDE
REG_DM3CNT_L = 0xDC
REG_DM3CNT_H = 0xDE
REG_IME = 0x208
REG_IE = 0x210
REG_IF = 0x214
Expand All @@ -88,53 +88,53 @@ REG_WIN0V = 0x44
REG_WIN1H = 0x42
REG_WIN1V = 0x46
REG_BLDCNT = 0x50
REG_BLDALPHA = 0x52
REG_BLDALPHA = 0x52

@everything in wram_globals* areas:
;@ Everything in wram_globals* areas:

globalptr .req r10 @ =wram_globals* ptr
globalptr .req r10 ;@ =wram_globals* ptr

start_map 0,globalptr @6502.s
_m_ rp2A03struct,rp2A03Size
_m_ rp2C02struct,rp2C02Size
_m_ mapperData,96
.struct 0 ;@ M6502.s
rp2A03struct: .space rp2A03Size
rp2C02struct: .space rp2C02Size
mapperData: .space 96

_m_ romBase,4
_m_ romMask,4
_m_ prgSize8k,4
_m_ prgSize16k,4
_m_ prgSize32k,4
_m_ mapperInitPtr,4
_m_ emuFlags,4
_m_ prgcrc,4
romBase: .word 0
romMask: .word 0
prgSize8k: .word 0
prgSize16k: .word 0
prgSize32k: .word 0
mapperInitPtr: .word 0
emuFlags: .word 0
prgcrc: .word 0

_m_ lightY,4
lightY: .word 0

_m_ renderCount, 4
_m_ tempData, 20*4
renderCount: .word 0
tempData: .space 20*4

_m_ cartFlags,1
_m_ padding,3 @align
_m_ nesMachineSize,0
cartFlags: .byte 0
padding: .skip 3 ;@ Align
nesMachineSize:

@-----------------------joyflags
;@-----------------------joyflags
P1_ENABLE = 0x10000
P2_ENABLE = 0x20000
B_A_SWAP = 0x80000
L_R_DISABLE = 0x100000
AUTOFIRE = 0x1000000
@-----------------------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)

NOFLICKER = 1 @flags&3: 0=flicker 1=noflicker 2=alphalerp
;@-----------------------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)

NOFLICKER = 1 ;@ Flags&3: 0=flicker 1=noflicker 2=alphalerp
ALPHALERP = 2
PALTIMING = 4 @0=NTSC 1=PAL
FOLLOWMEM = 32 @0=follow sprite, 1=follow mem
PALTIMING = 4 ;@ 0=NTSC 1=PAL
FOLLOWMEM = 32 ;@ 0=follow sprite, 1=follow mem
SPLINE = 64
SOFTRENDER = 128
ALLPIXEL = 256
Expand All @@ -154,41 +154,41 @@ NSFFILE = 0x100000
DISKBIOS = 0x200000


@------------------------multi-players
@in every frame, 64bit should be transfered. 32bit = IPC_KEYS, 32bit = CONTROL_BIT
;@------------------------multi-players
;@ 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.
MP_CONN = (1 << 30) @when communicating, kill this bit HIGH.
MP_RESET = (1 << 29) @means that someone want to reset the game.
MP_NFEN = (1 << 28) @nifi is enabled.
MP_KEY_MSK = 0x0CFF ;@ Not all the keys can be transfered.
MP_HOST = (1 << 31) ;@ Whether I am a host.
MP_CONN = (1 << 30) ;@ When communicating, kill this bit HIGH.
MP_RESET = (1 << 29) ;@ Means that someone want to reset the game.
MP_NFEN = (1 << 28) ;@ nifi is enabled.

MP_TIME_MSK = 0xFFFF @to sync the time.
MP_TIME = 16 @16 bits. counting the frames past.
MP_TIME_MSK = 0xFFFF ;@ To sync the time.
MP_TIME = 16 ;@ 16 bits. counting the frames past.


@bits 8-15=scale type
;@ Bits 8-15=scale type

UNSCALED_NOAUTO = 0 @display types
UNSCALED_AUTO = 1
SCALED = 2
SCALED = 2
SCALED_SPRITES = 3

@bits 16-31=sprite follow val
;@ Bits 16-31=sprite follow val

@------------------------------------------------------------------------------
@ [ DEBUG
@ IMPORT debuginfo
@ ]
;@------------------------------------------------------------------------------
;@ [ DEBUG
;@ IMPORT debuginfo
;@ ]

ERR0 = 0
ERR1 = 1
READ = 2
WRITE = 3
BRK = 4
BRK = 4
BADOP = 5
VBLS = 6
FPS = 7
FPS = 7
BGMISS = 8
CARTFLAG= 9

Expand All @@ -201,7 +201,7 @@ GAMEID = 20



@not sure about stuff below, instructions???
;@ Not sure about stuff below, instructions???
.macro DEBUGINFO index,reg
.if DEBUG
stmfd sp!,{r9}
Expand Down Expand Up @@ -237,5 +237,5 @@ GAMEID = 20
.endif
.endm

@----------------
@ END
;@----------------
;@ END
11 changes: 0 additions & 11 deletions arm9/include/macro.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#ifndef MACRO_H
#define MACRO_H
.macro start_map base, register
@GBLA _map_address_
_map_address_ = \base
.endm

.macro _m_ label=0,size
.if \label != 0
\label = _map_address_
.endif
_map_address_ = _map_address_ + \size
.endm

.macro ldr_ reg,label
ldr \reg,[globalptr,#\label]
Expand Down
4 changes: 2 additions & 2 deletions arm9/source/RP2C02/RP2C02.s
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
.global agb_bg_map
.global agb_obj_map
.global nes_palette
.global vromnt1k
.global vromNT1k

;@-----------------------------------------------------------------------------
.section .text,"ax"
Expand Down Expand Up @@ -2276,7 +2276,7 @@ spflick_table16:
.word 0xFFFF

;@-----------------------------------------------------------------------------
vromnt1k: ;@ r1=nt0...3
vromNT1k: ;@ r1=nt0...3
;@-----------------------------------------------------------------------------
adr r2, bankCache
add r2, r2, r1, lsl#1 ;@ Two bytes...
Expand Down
31 changes: 16 additions & 15 deletions arm9/source/mappers/konami.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
#include "equates.h"
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
.global Konami_Init
.global Konami_IRQ_Hook
.global KoLatch
Expand All @@ -9,18 +9,19 @@
.global KoIRQEnable
.global KoIRQack

latch = mapperData+0
irqen = mapperData+1
k4irq = mapperData+2
counter = mapperData+3
@---------------------------------------------------------------------------------
.struct mapperData
latch: .byte 0
irqEn: .byte 0
k4Irq: .byte 0
counter: .byte 0
;@----------------------------------------------------------------------------
.section .text,"ax"
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
Konami_Init:
adr r0,Konami_IRQ_Hook
str_ r0,scanlineHook
bx lr
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
KoLatch: @- - - - - - - - - - - - - - -
strb_ r0,latch
bx lr
Expand All @@ -38,22 +39,22 @@ KoLatchHi: @- - - - - - - - - - - - - - -
strb_ r0,latch
bx lr
KoIRQEnable: @- - - - - - - - - - - - - - -
strb_ r0,irqen
strb_ r0,irqEn
tst r0,#2 ;@ Timer Enable
ldrneb_ r0,latch
strneb_ r0,counter
mov r0, #0
b rp2A03SetIRQPin
KoIRQack: @- - - - - - - - - - - - - - -
ldrb_ r0,irqen
ldrb_ r0,irqEn
bic r0,r0,#2 ;@ Disable Timer
orr r0,r0,r0,lsl#1 ;@ Move repeat bit to Enable bit
strb_ r0,irqen
strb_ r0,irqEn
mov r0, #0
b rp2A03SetIRQPin
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
Konami_IRQ_Hook:
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
ldr_ r0,latch
tst r0,#0x200 ;@ Timer active?
bxeq lr
Expand All @@ -70,4 +71,4 @@ Konami_IRQ_Hook:
h0:
str_ r0,latch
bx lr
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
10 changes: 5 additions & 5 deletions arm9/source/mappers/map0.s
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
#include "equates.h"
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
.global mapper0init
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
.section .text,"ax"
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
mapper0init:
@---------------------------------------------------------------------------------
;@----------------------------------------------------------------------------
.word void, void, void, void

ldr_ r0, romMask
Expand Down
Loading
Loading