diff --git a/include/macros.h b/include/macros.h index e325ba23e8..4aeaf16abf 100644 --- a/include/macros.h +++ b/include/macros.h @@ -330,4 +330,6 @@ #define DT (1.0f) #endif +#define DMA_COPY_SEGMENT(segment) dma_copy(segment##_ROM_START, segment##_ROM_END, segment##_VRAM) + #endif diff --git a/src/16F740.c b/src/16F740.c index 0a3d71a5d1..d438ba26b0 100644 --- a/src/16F740.c +++ b/src/16F740.c @@ -1536,7 +1536,7 @@ void btl_state_update_prepare_menu(void) { battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER] = -1; battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] = -1; - dma_copy(_415D90_ROM_START, _415D90_ROM_END, _415D90_VRAM); + DMA_COPY_SEGMENT(_415D90); if (battleStatus->flags1 & BS_FLAGS1_PARTNER_ACTING) { btl_set_state(BATTLE_STATE_PARTNER_MENU); diff --git a/src/18C790.c b/src/18C790.c index f5da264e5d..c719c5e6ef 100644 --- a/src/18C790.c +++ b/src/18C790.c @@ -529,7 +529,7 @@ void btl_state_update_celebration(void) { if (CelebrateSubstateTime != 0) { CelebrateSubstateTime--; } else if (btl_cam_is_moving_done()) { - dma_copy(starpoint_ROM_START, starpoint_ROM_END, starpoint_VRAM); + DMA_COPY_SEGMENT(starpoint); script = start_script(&EVS_ShowStarpoints, EVT_PRIORITY_A, 0); EndBattleRewardsDone = FALSE; // divide reward into 20 increments @@ -614,7 +614,7 @@ void btl_state_update_celebration(void) { playerData->level++; btl_cam_use_preset(BTL_CAM_DEFAULT); btl_cam_move(5); - dma_copy(level_up_ROM_START, level_up_ROM_END, level_up_VRAM); + DMA_COPY_SEGMENT(level_up); sfx_play_sound(SOUND_80000008); CelebrateStateTime = 0; gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_BEGIN; diff --git a/src/77480.c b/src/77480.c index c3d490d779..1b05f3a69a 100644 --- a/src/77480.c +++ b/src/77480.c @@ -6,15 +6,15 @@ #include "sprite/player.h" #ifdef SHIFT -#define inspect_icon_VRAM_DEF inspect_icon_VRAM -#define speech_bubble_VRAM_DEF speech_bubble_VRAM -#define pulse_stone_VRAM_DEF pulse_stone_VRAM -#define i_spy_VRAM_DEF i_spy_VRAM +#define inspect_icon_VRAM inspect_icon_VRAM +#define speech_bubble_VRAM speech_bubble_VRAM +#define pulse_stone_VRAM pulse_stone_VRAM +#define i_spy_VRAM i_spy_VRAM #else -#define inspect_icon_VRAM_DEF (void*)0x802B7000 -#define speech_bubble_VRAM_DEF (void*)0x802B7000 -#define pulse_stone_VRAM_DEF (void*)0x802B7000 -#define i_spy_VRAM_DEF (void*)0x802B7000 +#define inspect_icon_VRAM (void*)0x802B7000 +#define speech_bubble_VRAM (void*)0x802B7000 +#define pulse_stone_VRAM (void*)0x802B7000 +#define i_spy_VRAM (void*)0x802B7000 #endif SHIFT_BSS UNK_FUN_PTR(ISpyNotificationCallback); @@ -1005,7 +1005,7 @@ void check_for_ispy(void) { if (gCurrentHiddenPanels.activateISpy && ISpyNotificationCallback == NULL) { if (!(playerStatus->animFlags & (PA_FLAG_SPEECH_PROMPT_AVAILABLE | PA_FLAG_INTERACT_PROMPT_AVAILABLE))) { - dma_copy(i_spy_ROM_START, i_spy_ROM_END, i_spy_VRAM_DEF); + DMA_COPY_SEGMENT(i_spy); ISpyNotificationCallback = ispy_notification_setup; } } @@ -1054,7 +1054,7 @@ void check_for_pulse_stone(void) { } if (!(gPlayerStatus.animFlags & (PA_FLAG_SPEECH_PROMPT_AVAILABLE | PA_FLAG_INTERACT_PROMPT_AVAILABLE))) { - dma_copy(pulse_stone_ROM_START, pulse_stone_ROM_END, pulse_stone_VRAM_DEF); + DMA_COPY_SEGMENT(pulse_stone); PulseStoneNotificationCallback = pulse_stone_notification_setup; } } @@ -1100,7 +1100,7 @@ void check_for_conversation_prompt(void) { if (has_valid_conversation_npc()) { TalkNotificationCallback = NULL; - dma_copy(speech_bubble_ROM_START, speech_bubble_ROM_END, speech_bubble_VRAM_DEF); + DMA_COPY_SEGMENT(speech_bubble); TalkNotificationCallback = interact_speech_setup; } else { TalkNotificationCallback = NULL; @@ -1274,7 +1274,7 @@ void check_for_interactables(void) { } if (InteractNotificationCallback == NULL) { - dma_copy(inspect_icon_ROM_START, inspect_icon_ROM_END, inspect_icon_VRAM_DEF); + DMA_COPY_SEGMENT(inspect_icon); InteractNotificationCallback = interact_inspect_setup; } diff --git a/src/effects.c b/src/effects.c index 3e0c105cc4..93f11042f3 100644 --- a/src/effects.c +++ b/src/effects.c @@ -45,7 +45,7 @@ void clear_effect_data(void) { osUnmapTLBAll(); osMapTLB(0x10, NULL, _325AD0_VRAM, (s32)&D_801A6000 & 0xFFFFFF, -1, -1); - dma_copy(_325AD0_ROM_START, _325AD0_ROM_END, _325AD0_VRAM); + DMA_COPY_SEGMENT(_325AD0); } void func_80059D48(void) { diff --git a/src/entity.c b/src/entity.c index 823cf13e23..7fd193d2a8 100644 --- a/src/entity.c +++ b/src/entity.c @@ -18,13 +18,15 @@ extern Addr WorldEntityHeapBottom; extern Addr WorldEntityHeapBase; #define WORLD_ENTITY_HEAP_BOTTOM (s32) WorldEntityHeapBottom #define WORLD_ENTITY_HEAP_BASE (s32) WorldEntityHeapBase -// TODO this only refers to one of 3 overlays which happen to share the same address space -// but don't necessarily have to -#define AREA_SPECIFIC_ENTITY_VRAM (s32) entity_default_VRAM +#define entity_jan_iwa_VRAM (s32) entity_jan_iwa_VRAM +#define entity_sbk_omo_VRAM (s32) entity_sbk_omo_VRAM +#define entity_default_VRAM (s32) entity_default_VRAM #else #define WORLD_ENTITY_HEAP_BOTTOM 0x80250000 #define WORLD_ENTITY_HEAP_BASE 0x80267FF0 -#define AREA_SPECIFIC_ENTITY_VRAM 0x802BAE00 +#define entity_jan_iwa_VRAM (void*) 0x802BAE00 +#define entity_sbk_omo_VRAM (void*) 0x802BAE00 +#define entity_default_VRAM (void*) 0x802BAE00 #endif s32 D_8014AFB0 = 255; @@ -771,11 +773,11 @@ void entity_reset_collision(Entity* entity) { void load_area_specific_entity_data(void) { if (!isAreaSpecificEntityDataLoaded) { if (gGameStatusPtr->areaID == AREA_JAN || gGameStatusPtr->areaID == AREA_IWA) { - dma_copy(entity_jan_iwa_ROM_START, entity_jan_iwa_ROM_END, (void*)AREA_SPECIFIC_ENTITY_VRAM); + DMA_COPY_SEGMENT(entity_jan_iwa); } else if (gGameStatusPtr->areaID == AREA_SBK || gGameStatusPtr->areaID == AREA_OMO) { - dma_copy(entity_sbk_omo_ROM_START, entity_sbk_omo_ROM_END, (void*)AREA_SPECIFIC_ENTITY_VRAM); + DMA_COPY_SEGMENT(entity_sbk_omo); } else { - dma_copy(entity_default_ROM_START, entity_default_ROM_END, (void*)AREA_SPECIFIC_ENTITY_VRAM); + DMA_COPY_SEGMENT(entity_default); } isAreaSpecificEntityDataLoaded = TRUE; diff --git a/src/filemenu/filemenu_common.c b/src/filemenu/filemenu_common.c index d6ef4aae2c..2b18b2dd2e 100644 --- a/src/filemenu/filemenu_common.c +++ b/src/filemenu/filemenu_common.c @@ -1020,7 +1020,7 @@ void filemenu_init(s32 arg0) { MenuPanel* menu; s32 i; - dma_copy(ui_images_ROM_START, ui_images_ROM_END, ui_images_VRAM); + DMA_COPY_SEGMENT(ui_images); for (i = 0; i < ARRAY_COUNT(filemenu_cursorHudElemID); i++) { filemenu_cursorHudElemID[i] = hud_element_create(filemenu_cursor_hudElemScripts[i]); hud_element_set_flags(filemenu_cursorHudElemID[i], HUD_ELEMENT_FLAG_DROP_SHADOW | HUD_ELEMENT_FLAG_80); diff --git a/src/main_loop.c b/src/main_loop.c index e856db4784..bc91bde355 100644 --- a/src/main_loop.c +++ b/src/main_loop.c @@ -249,12 +249,12 @@ void gfx_draw_frame(void) { void load_engine_data(void) { s32 i; - dma_copy(engine4_ROM_START, engine4_ROM_END, engine4_VRAM); - dma_copy(engine1_ROM_START, engine1_ROM_END, engine1_VRAM); - dma_copy(evt_ROM_START, evt_ROM_END, evt_VRAM); - dma_copy(entity_ROM_START, entity_ROM_END, entity_VRAM); - dma_copy(engine2_ROM_START, engine2_ROM_END, engine2_VRAM); - dma_copy(font_width_ROM_START, font_width_ROM_END, font_width_VRAM); + DMA_COPY_SEGMENT(engine4); + DMA_COPY_SEGMENT(engine1); + DMA_COPY_SEGMENT(evt); + DMA_COPY_SEGMENT(entity); + DMA_COPY_SEGMENT(engine2); + DMA_COPY_SEGMENT(font_width); gOverrideFlags = 0; gGameStatusPtr->unk_79 = 0; diff --git a/src/obfuscation_shims.c b/src/obfuscation_shims.c index 6ab9898326..7f5485216e 100644 --- a/src/obfuscation_shims.c +++ b/src/obfuscation_shims.c @@ -7,37 +7,21 @@ void general_heap_create_obfuscated(void); void battle_heap_create_obfuscated(void); void shim_create_audio_system_obfuscated(void) { - dma_copy( - create_audio_system_obfuscated_ROM_START, - create_audio_system_obfuscated_ROM_END, - create_audio_system_obfuscated_VRAM - ); + DMA_COPY_SEGMENT(create_audio_system_obfuscated); create_audio_system_obfuscated(); } void shim_load_engine_data_obfuscated(void) { - dma_copy( - load_engine_data_obfuscated_ROM_START, - load_engine_data_obfuscated_ROM_END, - load_engine_data_obfuscated_VRAM - ); + DMA_COPY_SEGMENT(load_engine_data_obfuscated); load_engine_data_obfuscated(); } void shim_general_heap_create_obfuscated(void) { - dma_copy( - general_heap_create_obfuscated_ROM_START, - general_heap_create_obfuscated_ROM_END, - general_heap_create_obfuscated_VRAM - ); + DMA_COPY_SEGMENT(general_heap_create_obfuscated); general_heap_create_obfuscated(); } void shim_battle_heap_create_obfuscated(void) { - dma_copy( - battle_heap_create_obfuscated_ROM_START, - battle_heap_create_obfuscated_ROM_END, - battle_heap_create_obfuscated_VRAM - ); + DMA_COPY_SEGMENT(battle_heap_create_obfuscated); battle_heap_create_obfuscated(); } diff --git a/src/pause/pause_main.c b/src/pause/pause_main.c index b1c06e2399..cde6942d5d 100644 --- a/src/pause/pause_main.c +++ b/src/pause/pause_main.c @@ -612,7 +612,7 @@ void pause_init(void) { MenuPanel** menuPanels; s32 i; - dma_copy(ui_images_ROM_START, ui_images_ROM_END, ui_images_VRAM); + DMA_COPY_SEGMENT(ui_images); for (i = 0; i < ARRAY_COUNT(gPauseIconScripts); i++) { gPauseCommonIconIDs[i] = hud_element_create(gPauseIconScripts[i]); diff --git a/src/state_battle.c b/src/state_battle.c index f5a2f63aa3..ef85d15991 100644 --- a/src/state_battle.c +++ b/src/state_battle.c @@ -92,7 +92,7 @@ void state_step_battle(void) { clear_npcs(); clear_entity_data(1); clear_trigger_data(); - dma_copy(battle_code_ROM_START, battle_code_ROM_END, battle_code_VRAM); + DMA_COPY_SEGMENT(battle_code); initialize_battle(); btl_save_world_cameras(); load_battle_section(); diff --git a/src/world/area_dgb/dgb_01/dgb_01_3_bridges.c b/src/world/area_dgb/dgb_01/dgb_01_3_bridges.c index 7d0a092927..42270abbb4 100644 --- a/src/world/area_dgb/dgb_01/dgb_01_3_bridges.c +++ b/src/world/area_dgb/dgb_01/dgb_01_3_bridges.c @@ -3,7 +3,7 @@ #include "sprite/player.h" ApiStatus N(LoadSmashBridgesGraphics)(void) { - dma_copy(dgb_01_smash_bridges_ROM_START, dgb_01_smash_bridges_ROM_END, dgb_01_smash_bridges_VRAM); + DMA_COPY_SEGMENT(dgb_01_smash_bridges); return ApiStatus_DONE2; } diff --git a/src/world/world.c b/src/world/world.c index ca9bfb9395..37bb0087bb 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -68,7 +68,7 @@ void load_map_hit_asset(void); extern ShapeFile gMapShapeData; void load_map_script_lib(void) { - dma_copy(world_script_api_ROM_START, world_script_api_ROM_END, world_script_api_VRAM); + DMA_COPY_SEGMENT(world_script_api); } void load_map_by_IDs(s16 areaID, s16 mapID, s16 loadType) {