Merge branch 'master' into romhack

This commit is contained in:
Ariel Antonitis 2021-03-09 01:25:22 -05:00
commit 9f441f4e05
23 changed files with 529 additions and 508 deletions

View File

@ -1,10 +1,5 @@
#!/bin/bash -ex
# Only run this script if it's the master branch build.
if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_PULL_REQUEST" != "false" ]]; then
exit 0
fi
build_name=$1
map_file=$build_name.map
if [ ! -f $map_file ]; then
@ -13,4 +8,4 @@ if [ ! -f $map_file ]; then
fi
output=$(perl $(dirname "$0")/calcrom.pl $build_name.map | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
curl -d "{\"username\": \"$CALCROM_DISCORD_WEBHOOK_USERNAME\", \"avatar_url\": \"$CALCROM_DISCORD_WEBHOOK_AVATAR_URL\", \"content\":\"\`\`\`$build_name progress:\\n$output\`\`\`\"}" -H "Content-Type: application/json" -X POST $CALCROM_DISCORD_WEBHOOK_URL
curl -d "{\"username\": \"$CALCROM_DISCORD_WEBHOOK_USERNAME\", \"avatar_url\": \"$CALCROM_DISCORD_WEBHOOK_AVATAR_URL\", \"content\":\"\`\`\`$build_name progress:\\n$output\`\`\`\"}" -H "Content-Type: application/json" -X POST "$CALCROM_DISCORD_WEBHOOK_URL"

40
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: CI
on:
push:
branches: [ master ]
pull_request:
jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@master
- name: Install binutils
run: sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi
# build-essential, git, and libpng-dev are already installed
# gcc-arm-none-eabi is only needed for the modern build
# as an alternative to dkP
- name: Install agbcc
run: |
git clone https://github.com/pret/agbcc.git
cd agbcc
./build.sh
./install.sh ../
- name: Compare
run: make -j${nproc} compare
- name: Modern
run: make -j${nproc} modern
- name: Webhook
if: ${{ github.event_name == 'push' }}
env:
CALCROM_DISCORD_WEBHOOK_USERNAME: OK
CALCROM_DISCORD_WEBHOOK_AVATAR_URL: https://i.imgur.com/38BQHdd.png
CALCROM_DISCORD_WEBHOOK_URL: ${{ secrets.CALCROM_DISCORD_WEBHOOK_URL }}
run: sh .github/calcrom/webhook.sh pokeemerald

View File

@ -1,39 +0,0 @@
language: generic
dist: bionic
sudo: false
env:
global:
- DEVKITPRO=$HOME
- DEVKITARM=$DEVKITPRO/devkitARM
addons:
apt:
packages:
- gcc-multilib
- linux-libc-dev
cache:
apt: true
install:
- pushd $HOME
- travis_retry wget https://github.com/devkitPro/buildscripts/releases/download/devkitARM_r52/devkitARM_r52-linux.tar.xz
- tar xJf devkitARM*.tar.xz
- travis_retry wget https://github.com/devkitPro/devkitarm-rules/releases/download/v1.0.0/devkitarm-rules-1.0.0.tar.xz
- tar xJf devkitarm-rules-*.tar.xz -C $DEVKITARM
- travis_retry git clone https://github.com/pret/agbcc.git
- cd agbcc && ./build.sh && ./install.sh $TRAVIS_BUILD_DIR
- popd
matrix:
include:
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env: _="Build"
script:
- make -j2 tools CXX=g++-7
- make -j2 compare
- make -j2 modern
after_success:
- .travis/calcrom/webhook.sh pokeemerald

View File

@ -143,7 +143,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_RestoreParty:: @ 8249121
special LoadPlayerParty
frontier_setpartyorder FRONTIER_MULTI_PARTY_SIZE
compare VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_LINK_MULTIS
call_if_eq BattleFrontier_BattleTowerMultiBattleRoom_EventScript_249514
call_if_eq BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ReconnectLink
playfanfare MUS_HEAL
waitfanfare
special HealPlayerParty
@ -383,9 +383,8 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_RetireChallengeLink:: @ 82
goto BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyLost
end
@ Some link function. Sets battle type flags at least
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_249514:: @ 8249514
special sub_813B534
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ReconnectLink:: @ 8249514
special BattleTowerReconnectLink
return
BattleFrontier_BattleTowerMultiBattleRoom_Movement_PlayerEnterRoom: @ 8249518

View File

@ -1,5 +1,5 @@
@ Note: LOCALIDs shared with BattleFrontier_BattlePikeRoomNormal
BattleFrontier_BattlePikeRoomNormal_MapScripts_2C3E1B: @ 82C3E1B
BattleFrontier_BattlePikeRoom_MapScripts: @ 82C3E1B
map_script MAP_SCRIPT_ON_TRANSITION, BattleFrontier_BattlePikeRoom_OnTransition
map_script MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE, BattleFrontier_BattlePikeRoom_OnWarp

View File

@ -1,16 +1,3 @@
@ Unused
EventScript_28CCAA:: @ 828CCAA
setvar VAR_0x8005, 8
special InterviewBefore
compare VAR_RESULT, 1
goto_if_eq EventScript_UnusedRet
setvar VAR_0x8005, 8
special InterviewAfter
return
EventScript_UnusedRet:: @ 828CCC6
return
@ Gabby and Ty always move to the same spots for the first 5 battles
@ From the 6th battle onwards, they move randomly between locations 6-8
@ Note: The local IDs of Gabby and Ty are hard-coded in GabbyAndTySetScriptVarsToObjectEventLocalIds

View File

@ -342,3 +342,16 @@ BattleFrontier_BattleTowerLobby_EventScript_ShowOrHideReporter:: @ 828CC84
BattleFrontier_BattleTowerLobby_EventScript_HideReporter:: @ 828CCA6
setflag FLAG_HIDE_BATTLE_TOWER_REPORTER
return
@ Unused
EventScript_ContestLiveInterview:: @ 828CCAA
setvar VAR_0x8005, TVSHOW_CONTEST_LIVE_UPDATES
special InterviewBefore
compare VAR_RESULT, TRUE
goto_if_eq EventScript_ContestLiveInterviewEnd
setvar VAR_0x8005, TVSHOW_CONTEST_LIVE_UPDATES
special InterviewAfter
return
EventScript_ContestLiveInterviewEnd:: @ 828CCC6
return

View File

@ -157,7 +157,7 @@ SecretBase_EventScript_InitSecretBase:: @ 8275B5B
end
SecretBase_EventScript_FirstEntrance:: @ 8275B81
applymovement OBJ_EVENT_ID_PLAYER, SecretBase_Movement_275BB4
applymovement OBJ_EVENT_ID_PLAYER, SecretBase_Movement_EnterBase
waitmovement 0
setvar VAR_INIT_SECRET_BASE, 1
msgbox SecretBase_Text_WantToMakeYourSecretBaseHere, MSGBOX_YESNO
@ -175,7 +175,7 @@ SecretBase_EventScript_SetAsBase:: @ 8275BAB
waitstate
end
SecretBase_Movement_275BB4: @ 8275BB4
SecretBase_Movement_EnterBase: @ 8275BB4
walk_up
walk_up
step_end

View File

@ -514,7 +514,7 @@ gSpecials:: @ 81DBA64
def_special SetMewAboveGrass
def_special ShouldDistributeEonTicket
def_special LinkRetireStatusWithBattleTowerPartner
def_special sub_813B534
def_special BattleTowerReconnectLink
def_special CallTrainerHillFunction
def_special Script_DoRayquazaScene @ Listed twice
def_special LoopWingFlapSE

View File

@ -1,8 +1,9 @@
gUnknown_0827EA0C:: @ 827EA0C
gContestPaintingCaption:: @ 827EA0C
.string "{STR_VAR_1}\n"
.string "{STR_VAR_2}'s {STR_VAR_3}$"
gUnknown_0827EA17:: @ 827EA17
@ Unused
gContestPaintingContest:: @ 827EA17
.string "CONTEST$"
gContestRankNormal::

View File

@ -9,19 +9,19 @@
struct BgControl
{
struct BgConfig {
u16 visible:1;
u16 unknown_1:1;
u16 screenSize:2;
u16 priority:2;
u16 mosaic:1;
u16 wraparound:1;
u8 visible:1;
u8 unknown_1:1;
u8 screenSize:2;
u8 priority:2;
u8 mosaic:1;
u8 wraparound:1;
u16 charBaseIndex:2;
u16 mapBaseIndex:5;
u16 paletteMode:1;
u8 charBaseIndex:2;
u8 mapBaseIndex:5;
u8 paletteMode:1;
u8 unknown_2;
u8 unknown_3;
u8 unknown_2; // Assigned to but never read
u8 unknown_3; // Assigned to but never read
} configs[NUM_BACKGROUNDS];
u16 bgVisibilityAndMode;
@ -102,17 +102,17 @@ static void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8
{
if (charBaseIndex != 0xFF)
{
sGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3;
sGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex;
}
if (mapBaseIndex != 0xFF)
{
sGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F;
sGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex;
}
if (screenSize != 0xFF)
{
sGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3;
sGpuBgConfigs.configs[bg].screenSize = screenSize;
}
if (paletteMode != 0xFF)
@ -122,12 +122,12 @@ static void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8
if (priority != 0xFF)
{
sGpuBgConfigs.configs[bg].priority = priority & 0x3;
sGpuBgConfigs.configs[bg].priority = priority;
}
if (mosaic != 0xFF)
{
sGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1;
sGpuBgConfigs.configs[bg].mosaic = mosaic;
}
if (wraparound != 0xFF)

View File

@ -8,88 +8,90 @@
#define DMA_REQUEST_COPY16 3
#define DMA_REQUEST_FILL16 4
BSS_DATA struct
struct Dma3Request
{
const u8 *src;
u8 *dest;
u16 size;
u16 mode;
u32 value;
} gDma3Requests[MAX_DMA_REQUESTS];
};
static volatile bool8 gDma3ManagerLocked;
static u8 gDma3RequestCursor;
static struct Dma3Request sDma3Requests[MAX_DMA_REQUESTS];
static vbool8 sDma3ManagerLocked;
static u8 sDma3RequestCursor;
void ClearDma3Requests(void)
{
int i;
gDma3ManagerLocked = TRUE;
gDma3RequestCursor = 0;
sDma3ManagerLocked = TRUE;
sDma3RequestCursor = 0;
for (i = 0; i < MAX_DMA_REQUESTS; i++)
{
gDma3Requests[i].size = 0;
gDma3Requests[i].src = NULL;
gDma3Requests[i].dest = NULL;
sDma3Requests[i].size = 0;
sDma3Requests[i].src = NULL;
sDma3Requests[i].dest = NULL;
}
gDma3ManagerLocked = FALSE;
sDma3ManagerLocked = FALSE;
}
void ProcessDma3Requests(void)
{
u16 bytesTransferred;
if (gDma3ManagerLocked)
if (sDma3ManagerLocked)
return;
bytesTransferred = 0;
// as long as there are DMA requests to process (unless size or vblank is an issue), do not exit
while (gDma3Requests[gDma3RequestCursor].size != 0)
while (sDma3Requests[sDma3RequestCursor].size != 0)
{
bytesTransferred += gDma3Requests[gDma3RequestCursor].size;
bytesTransferred += sDma3Requests[sDma3RequestCursor].size;
if (bytesTransferred > 40 * 1024)
return; // don't transfer more than 40 KiB
if (*(u8 *)REG_ADDR_VCOUNT > 224)
return; // we're about to leave vblank, stop
switch (gDma3Requests[gDma3RequestCursor].mode)
switch (sDma3Requests[sDma3RequestCursor].mode)
{
case DMA_REQUEST_COPY32: // regular 32-bit copy
Dma3CopyLarge32_(gDma3Requests[gDma3RequestCursor].src,
gDma3Requests[gDma3RequestCursor].dest,
gDma3Requests[gDma3RequestCursor].size);
Dma3CopyLarge32_(sDma3Requests[sDma3RequestCursor].src,
sDma3Requests[sDma3RequestCursor].dest,
sDma3Requests[sDma3RequestCursor].size);
break;
case DMA_REQUEST_FILL32: // repeat a single 32-bit value across RAM
Dma3FillLarge32_(gDma3Requests[gDma3RequestCursor].value,
gDma3Requests[gDma3RequestCursor].dest,
gDma3Requests[gDma3RequestCursor].size);
Dma3FillLarge32_(sDma3Requests[sDma3RequestCursor].value,
sDma3Requests[sDma3RequestCursor].dest,
sDma3Requests[sDma3RequestCursor].size);
break;
case DMA_REQUEST_COPY16: // regular 16-bit copy
Dma3CopyLarge16_(gDma3Requests[gDma3RequestCursor].src,
gDma3Requests[gDma3RequestCursor].dest,
gDma3Requests[gDma3RequestCursor].size);
Dma3CopyLarge16_(sDma3Requests[sDma3RequestCursor].src,
sDma3Requests[sDma3RequestCursor].dest,
sDma3Requests[sDma3RequestCursor].size);
break;
case DMA_REQUEST_FILL16: // repeat a single 16-bit value across RAM
Dma3FillLarge16_(gDma3Requests[gDma3RequestCursor].value,
gDma3Requests[gDma3RequestCursor].dest,
gDma3Requests[gDma3RequestCursor].size);
Dma3FillLarge16_(sDma3Requests[sDma3RequestCursor].value,
sDma3Requests[sDma3RequestCursor].dest,
sDma3Requests[sDma3RequestCursor].size);
break;
}
// Free the request
gDma3Requests[gDma3RequestCursor].src = NULL;
gDma3Requests[gDma3RequestCursor].dest = NULL;
gDma3Requests[gDma3RequestCursor].size = 0;
gDma3Requests[gDma3RequestCursor].mode = 0;
gDma3Requests[gDma3RequestCursor].value = 0;
gDma3RequestCursor++;
sDma3Requests[sDma3RequestCursor].src = NULL;
sDma3Requests[sDma3RequestCursor].dest = NULL;
sDma3Requests[sDma3RequestCursor].size = 0;
sDma3Requests[sDma3RequestCursor].mode = 0;
sDma3Requests[sDma3RequestCursor].value = 0;
sDma3RequestCursor++;
if (gDma3RequestCursor >= MAX_DMA_REQUESTS) // loop back to the first DMA request
gDma3RequestCursor = 0;
if (sDma3RequestCursor >= MAX_DMA_REQUESTS) // loop back to the first DMA request
sDma3RequestCursor = 0;
}
}
@ -98,30 +100,30 @@ s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode)
int cursor;
int i = 0;
gDma3ManagerLocked = TRUE;
cursor = gDma3RequestCursor;
sDma3ManagerLocked = TRUE;
cursor = sDma3RequestCursor;
while (i < MAX_DMA_REQUESTS)
{
if (gDma3Requests[cursor].size == 0) // an empty request was found.
if (sDma3Requests[cursor].size == 0) // an empty request was found.
{
gDma3Requests[cursor].src = src;
gDma3Requests[cursor].dest = dest;
gDma3Requests[cursor].size = size;
sDma3Requests[cursor].src = src;
sDma3Requests[cursor].dest = dest;
sDma3Requests[cursor].size = size;
if (mode == 1)
gDma3Requests[cursor].mode = DMA_REQUEST_COPY32;
sDma3Requests[cursor].mode = DMA_REQUEST_COPY32;
else
gDma3Requests[cursor].mode = DMA_REQUEST_COPY16;
sDma3Requests[cursor].mode = DMA_REQUEST_COPY16;
gDma3ManagerLocked = FALSE;
sDma3ManagerLocked = FALSE;
return cursor;
}
if (++cursor >= MAX_DMA_REQUESTS) // loop back to start.
cursor = 0;
i++;
}
gDma3ManagerLocked = FALSE;
sDma3ManagerLocked = FALSE;
return -1; // no free DMA request was found
}
@ -130,31 +132,31 @@ s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode)
int cursor;
int i = 0;
cursor = gDma3RequestCursor;
gDma3ManagerLocked = TRUE;
cursor = sDma3RequestCursor;
sDma3ManagerLocked = TRUE;
while (i < MAX_DMA_REQUESTS)
{
if (gDma3Requests[cursor].size == 0) // an empty request was found.
if (sDma3Requests[cursor].size == 0) // an empty request was found.
{
gDma3Requests[cursor].dest = dest;
gDma3Requests[cursor].size = size;
gDma3Requests[cursor].mode = mode;
gDma3Requests[cursor].value = value;
sDma3Requests[cursor].dest = dest;
sDma3Requests[cursor].size = size;
sDma3Requests[cursor].mode = mode;
sDma3Requests[cursor].value = value;
if(mode == 1)
gDma3Requests[cursor].mode = DMA_REQUEST_FILL32;
sDma3Requests[cursor].mode = DMA_REQUEST_FILL32;
else
gDma3Requests[cursor].mode = DMA_REQUEST_FILL16;
sDma3Requests[cursor].mode = DMA_REQUEST_FILL16;
gDma3ManagerLocked = FALSE;
sDma3ManagerLocked = FALSE;
return cursor;
}
if (++cursor >= MAX_DMA_REQUESTS) // loop back to start.
cursor = 0;
i++;
}
gDma3ManagerLocked = FALSE;
sDma3ManagerLocked = FALSE;
return -1; // no free DMA request was found
}
@ -166,7 +168,7 @@ s16 CheckForSpaceForDma3Request(s16 index)
{
while (i < MAX_DMA_REQUESTS)
{
if (gDma3Requests[i].size != 0)
if (sDma3Requests[i].size != 0)
return -1;
i++;
}
@ -174,7 +176,7 @@ s16 CheckForSpaceForDma3Request(s16 index)
}
else // check the specified request
{
if (gDma3Requests[index].size != 0)
if (sDma3Requests[index].size != 0)
return -1;
return 0;
}

View File

@ -7,7 +7,7 @@ void CreateTask_EnterCableClubSeat(TaskFunc taskFunc);
u8 CreateTask_ReestablishCableClubLink(void);
void CB2_ReturnFromCableClubBattle(void);
bool32 AreBattleTowerLinkSpeciesSame(u16 *speciesList1, u16 *speciesList2);
void sub_80B3AF8(u8 taskId);
void Task_ReconnectWithLinkPlayers(u8 taskId);
void Task_WaitForLinkPlayerConnection(u8 taskId);
bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex);

View File

@ -33,9 +33,9 @@
#define BATTLE_TOWER_LINK_CONTINUE 0
#define BATTLE_TOWER_LINK_RETIRE 1
#define BATTLE_TOWER_LINKSTAT_CONTINUE 0
#define BATTLE_TOWER_LINKSTAT_BOTH_RETIRE 1
#define BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE 2
#define BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE 3
#define BATTLE_TOWER_LINKSTAT_CONTINUE 0
#define BATTLE_TOWER_LINKSTAT_BOTH_RETIRE 1
#define BATTLE_TOWER_LINKSTAT_MEMBER_RETIRE 2
#define BATTLE_TOWER_LINKSTAT_LEADER_RETIRE 3
#endif //GUARD_CONSTANTS_BATTLE_TOWER_H

View File

@ -50,6 +50,15 @@ SECTIONS {
asm/*.o(.text);
} =0
.text.unlikely :
ALIGN(4)
{
src/crt0.o(.text.unlikely);
src/*.o(.text.unlikely);
gflib/*.o(.text.unlikely);
asm/*.o(.text.unlikely);
} =0
script_data :
ALIGN(4)
{

View File

@ -2276,7 +2276,7 @@ static void EndLinkBattleInSteps(void)
}
else if (gReceivedRemoteLinkPlayers == 0)
{
CreateTask(sub_80B3AF8, 5);
CreateTask(Task_ReconnectWithLinkPlayers, 5);
gBattleCommunication[MULTIUSE_STATE]++;
}
else
@ -2307,7 +2307,7 @@ static void EndLinkBattleInSteps(void)
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 5:
if (!FuncIsActiveTask(sub_80B3AF8))
if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers))
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 6:
@ -2430,11 +2430,11 @@ static void sub_803939C(void)
break;
case 1:
if (gMain.field_439_x4 && gReceivedRemoteLinkPlayers == 0)
CreateTask(sub_80B3AF8, 5);
CreateTask(Task_ReconnectWithLinkPlayers, 5);
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 2:
if (!FuncIsActiveTask(sub_80B3AF8))
if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers))
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 3:

File diff suppressed because it is too large Load Diff

View File

@ -1267,7 +1267,8 @@ static void sub_80B3AD0(u8 taskId)
#define tTimer data[1]
void sub_80B3AF8(u8 taskId)
// Confirm that all cabled link players are connected
void Task_ReconnectWithLinkPlayers(u8 taskId)
{
s16 *data = gTasks[taskId].data;

View File

@ -44,7 +44,7 @@ static void PrintContestPaintingCaption(u8, u8);
static void VBlankCB_ContestPainting(void);
static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]);
extern const u8 gUnknown_0827EA0C[];
extern const u8 gContestPaintingCaption[];
extern const u8 gContestCoolness[];
extern const u8 gContestBeauty[];
extern const u8 gContestCuteness[];
@ -297,7 +297,7 @@ static void PrintContestPaintingCaption(u8 contestType, bool8 arg1)
StringCopy(gStringVar2, gContestPaintingWinner->trainerName);
sub_81DB5AC(gStringVar2);
StringCopy(gStringVar3, gContestPaintingWinner->monName);
StringExpandPlaceholders(gStringVar4, gUnknown_0827EA0C);
StringExpandPlaceholders(gStringVar4, gContestPaintingCaption);
}
else
{

View File

@ -3735,14 +3735,17 @@ bool32 ShouldDistributeEonTicket(void)
return TRUE;
}
void sub_813B534(void)
#define tState data[0]
void BattleTowerReconnectLink(void)
{
// Save battle type, restored at end
// of Task_LinkRetireStatusWithBattleTowerPartner
sBattleTowerMultiBattleTypeFlags = gBattleTypeFlags;
gBattleTypeFlags = 0;
if (!gReceivedRemoteLinkPlayers)
{
CreateTask(sub_80B3AF8, 5);
}
CreateTask(Task_ReconnectWithLinkPlayers, 5);
}
void LinkRetireStatusWithBattleTowerPartner(void)
@ -3750,137 +3753,145 @@ void LinkRetireStatusWithBattleTowerPartner(void)
CreateTask(Task_LinkRetireStatusWithBattleTowerPartner, 5);
}
// Communicate with a Battle Tower link partner to tell them
// whether or not the player chose to continue or retire,
// and determine what the partner chose to do
// gSpecialVar_0x8004: Player's choice
// gSpecialVar_0x8005: Partner's choice (read from gBlockRecvBuffer[1][0])
static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId)
{
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
if (!FuncIsActiveTask(sub_80B3AF8))
{
gTasks[taskId].data[0]++;
}
break;
case 1:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() == 0)
{
gTasks[taskId].data[0]++;
}
else
{
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, 2);
gTasks[taskId].data[0]++;
}
}
break;
case 2:
if ((GetBlockReceivedStatus() & 2) != 0)
{
if (GetMultiplayerId() == 0)
{
gSpecialVar_0x8005 = gBlockRecvBuffer[1][0];
ResetBlockReceivedFlag(1);
if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE)
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_BOTH_RETIRE;
}
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_CONTINUE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE)
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE;
}
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_CONTINUE)
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE;
}
else
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_CONTINUE;
}
}
gTasks[taskId].data[0]++;
}
break;
case 3:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() != 0)
{
gTasks[taskId].data[0]++;
}
else
{
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, 2);
gTasks[taskId].data[0]++;
}
}
break;
case 4:
if ((GetBlockReceivedStatus() & 1) != 0)
{
if (GetMultiplayerId() != 0)
{
gSpecialVar_Result = gBlockRecvBuffer[0][0];
ResetBlockReceivedFlag(0);
gTasks[taskId].data[0]++;
}
else
{
gTasks[taskId].data[0]++;
}
}
break;
case 5:
case 0:
if (!FuncIsActiveTask(Task_ReconnectWithLinkPlayers))
{
gTasks[taskId].tState++;
}
break;
case 1:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() == 0)
{
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE)
{
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
}
// Player is link leader, skip sending data
gTasks[taskId].tState++;
}
else
{
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE)
// Send value of gSpecialVar_0x8004 to leader
// Will either be BATTLE_TOWER_LINK_CONTINUE or BATTLE_TOWER_LINK_RETIRE
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, sizeof(gSpecialVar_0x8004));
gTasks[taskId].tState++;
}
}
break;
case 2:
if (GetBlockReceivedStatus() & 2)
{
if (GetMultiplayerId() == 0)
{
// Player is leader, read partner's choice
// and determine if play should continue
gSpecialVar_0x8005 = gBlockRecvBuffer[1][0];
ResetBlockReceivedFlag(1);
if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE)
{
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_BOTH_RETIRE;
}
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_CONTINUE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE)
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_MEMBER_RETIRE;
}
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_CONTINUE)
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_LEADER_RETIRE;
}
else
{
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_CONTINUE;
}
}
gTasks[taskId].data[0]++;
break;
case 6:
if (!IsTextPrinterActive(0))
gTasks[taskId].tState++;
}
break;
case 3:
if (IsLinkTaskFinished() == TRUE)
{
if (GetMultiplayerId() != 0)
{
gTasks[taskId].data[0]++;
// Player is not link leader, wait for leader's response
gTasks[taskId].tState++;
}
break;
case 7:
if (IsLinkTaskFinished() == 1)
else
{
SetLinkStandbyCallback();
gTasks[taskId].data[0]++;
// Send whether or not play should continue
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, sizeof(gSpecialVar_Result));
gTasks[taskId].tState++;
}
break;
case 8:
if (IsLinkTaskFinished() == 1)
}
break;
case 4:
if (GetBlockReceivedStatus() & 1)
{
if (GetMultiplayerId() != 0)
{
gTasks[taskId].data[0]++;
// Player is not link leader, read leader's response
gSpecialVar_Result = gBlockRecvBuffer[0][0];
ResetBlockReceivedFlag(0);
gTasks[taskId].tState++;
}
break;
case 9:
if (gWirelessCommType == 0)
else
{
SetCloseLinkCallback();
gTasks[taskId].tState++;
}
gBattleTypeFlags = sBattleTowerMultiBattleTypeFlags;
EnableBothScriptContexts();
DestroyTask(taskId);
break;
}
break;
case 5:
// Print message if partner chose to retire (and player didn't)
if (GetMultiplayerId() == 0)
{
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_MEMBER_RETIRE)
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
}
else
{
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_LEADER_RETIRE)
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
}
gTasks[taskId].tState++;
break;
case 6:
if (!IsTextPrinterActive(0))
gTasks[taskId].tState++;
break;
case 7:
if (IsLinkTaskFinished() == TRUE)
{
SetLinkStandbyCallback();
gTasks[taskId].tState++;
}
break;
case 8:
if (IsLinkTaskFinished() == TRUE)
gTasks[taskId].tState++;
break;
case 9:
if (gWirelessCommType == 0)
SetCloseLinkCallback();
gBattleTypeFlags = sBattleTowerMultiBattleTypeFlags;
EnableBothScriptContexts();
DestroyTask(taskId);
break;
}
}
#undef tState
void Script_DoRayquazaScene(void)
{
if (!gSpecialVar_0x8004)

View File

@ -1425,35 +1425,36 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize,
sending = ni_or_uni & 0x20;
if (sending || ni_or_uni == 0x40)
{
u8 *dataType_p; // a hack to swap instructions
slotStatus_NI = gRfuSlotStatusNI[bm_slot_id];
slotStatus_UNI = NULL;
slotStatus_NI->send.errorCode = 0;
*slotStatus_NI->send.now_p = dataType_p = &slotStatus_NI->send.dataType;
slotStatus_NI->send.now_p[0] = &slotStatus_NI->send.dataType;
slotStatus_NI->send.remainSize = 7;
slotStatus_NI->send.bmSlotOrg = bmSendSlot;
slotStatus_NI->send.bmSlot = bmSendSlot;
slotStatus_NI->send.payloadSize = subFrameSize - frameSize;
if (sending != 0)
*dataType_p = 0;
slotStatus_NI->send.dataType = 0;
else
*dataType_p = 1;
slotStatus_NI->send.dataType = 1;
slotStatus_NI->send.dataSize = dataSize;
slotStatus_NI->send.src = src;
slotStatus_NI->send.ack = 0;
slotStatus_NI->send.phase = 0;
#ifndef NONMATCHING // to fix r2, r3, r4, r5 register roulette
asm("":::"r2");
#endif
for (i = 0; i < WINDOW_COUNT; ++i)
{
slotStatus_NI->send.recvAckFlag[i] = 0;
slotStatus_NI->send.n[i] = 1;
}
for (bm_slot_id = 0; bm_slot_id < RFU_CHILD_MAX; ++bm_slot_id)
if ((bmSendSlot >> bm_slot_id) & 1)
gRfuSlotStatusNI[bm_slot_id]->send.failCounter = 0;
{
do
{
if ((bmSendSlot >> bm_slot_id) & 1)
gRfuSlotStatusNI[bm_slot_id]->send.failCounter = 0;
} while (0);
}
gRfuLinkStatus->sendSlotNIFlag |= bmSendSlot;
*llFrameSize_p -= subFrameSize;
slotStatus_NI->send.state = SLOT_STATE_SEND_START;

View File

@ -23,6 +23,7 @@
#include "intro.h"
#include "main.h"
#include "trainer_hill.h"
#include "constants/rgb.h"
static void VBlankIntr(void);
static void HBlankIntr(void);
@ -90,7 +91,7 @@ void AgbMain()
#if !MODERN
RegisterRamReset(RESET_ALL);
#endif //MODERN
*(vu16 *)BG_PLTT = 0x7FFF;
*(vu16 *)BG_PLTT = RGB_WHITE; // Set the backdrop to white on startup
InitGpuRegManager();
REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3;
InitKeys();