Merge branch 'master' into fldeff

This commit is contained in:
ultima-soul
2019-04-28 16:55:43 -07:00
523 changed files with 19874 additions and 6922 deletions
+212
View File
@@ -0,0 +1,212 @@
#include "global.h"
#include "blit.h"
void BlitBitmapRect4BitWithoutColorKey(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
{
BlitBitmapRect4Bit(src, dst, srcX, srcY, dstX, dstY, width, height, 0xFF);
}
void BlitBitmapRect4Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey)
{
s32 xEnd;
s32 yEnd;
s32 multiplierSrcY;
s32 multiplierDstY;
s32 loopSrcY, loopDstY;
s32 loopSrcX, loopDstX;
const u8 *pixelsSrc;
u8 *pixelsDst;
s32 toOrr;
s32 toAnd;
s32 toShift;
if (dst->width - dstX < width)
xEnd = (dst->width - dstX) + srcX;
else
xEnd = srcX + width;
if (dst->height - dstY < height)
yEnd = (dst->height - dstY) + srcY;
else
yEnd = height + srcY;
multiplierSrcY = (src->width + (src->width & 7)) >> 3;
multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
if (colorKey == 0xFF)
{
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
{
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
{
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
pixelsDst = dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + (((loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B);
toOrr = ((*pixelsSrc >> ((loopSrcX & 1) << 2)) & 0xF);
toShift = ((loopDstX & 1) << 2);
toOrr <<= toShift;
toAnd = 0xF0 >> (toShift);
*pixelsDst = toOrr | (*pixelsDst & toAnd);
}
}
}
else
{
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
{
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
{
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
pixelsDst = dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + (((loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B);
toOrr = ((*pixelsSrc >> ((loopSrcX & 1) << 2)) & 0xF);
if (toOrr != colorKey)
{
toShift = ((loopDstX & 1) << 2);
toOrr <<= toShift;
toAnd = 0xF0 >> (toShift);
*pixelsDst = toOrr | (*pixelsDst & toAnd);
}
}
}
}
}
void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue)
{
s32 xEnd;
s32 yEnd;
s32 multiplierY;
s32 loopX, loopY;
xEnd = x + width;
if (xEnd > surface->width)
xEnd = surface->width;
yEnd = y + height;
if (yEnd > surface->height)
yEnd = surface->height;
multiplierY = (surface->width + (surface->width & 7)) >> 3;
for (loopY = y; loopY < yEnd; loopY++)
{
for (loopX = x; loopX < xEnd; loopX++)
{
u8 *pixels = surface->pixels + ((loopX >> 1) & 3) + ((loopX >> 3) << 5) + (((loopY >> 3) * multiplierY) << 5) + ((u32)(loopY << 0x1d) >> 0x1B);
if ((loopX & 1) != 0)
{
*pixels &= 0xF;
*pixels |= fillValue << 4;
}
else
{
*pixels &= 0xF0;
*pixels |= fillValue;
}
}
}
}
void BlitBitmapRect4BitTo8Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey, u8 paletteOffset)
{
s32 palOffsetBits;
s32 xEnd;
s32 yEnd;
s32 multiplierSrcY;
s32 multiplierDstY;
s32 loopSrcY, loopDstY;
s32 loopSrcX, loopDstX;
const u8 *pixelsSrc;
u8 *pixelsDst;
s32 colorKeyBits;
palOffsetBits = (u32)(paletteOffset << 0x1C) >> 0x18;
colorKeyBits = (u32)(colorKey << 0x1C) >> 0x18;
if (dst->width - dstX < width)
xEnd = (dst->width - dstX) + srcX;
else
xEnd = width + srcX;
if (dst->height - dstY < height)
yEnd = (srcY + dst->height) - dstY;
else
yEnd = srcY + height;
multiplierSrcY = (src->width + (src->width & 7)) >> 3;
multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
if (colorKey == 0xFF)
{
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
{
pixelsSrc = src->pixels + ((srcX >> 1) & 3) + ((srcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
{
pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
if (loopSrcX & 1)
{
*pixelsDst = palOffsetBits + (*pixelsSrc >> 4);
}
else
{
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
*pixelsDst = palOffsetBits + (*pixelsSrc & 0xF);
}
}
}
}
else
{
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
{
pixelsSrc = src->pixels + ((srcX >> 1) & 3) + ((srcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
{
if (loopSrcX & 1)
{
if ((*pixelsSrc & 0xF0) != colorKeyBits)
{
pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
*pixelsDst = palOffsetBits + (*pixelsSrc >> 4);
}
}
else
{
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
if ((*pixelsSrc & 0xF) != colorKey)
{
pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
*pixelsDst = palOffsetBits + (*pixelsSrc & 0xF);
}
}
}
}
}
}
void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue)
{
s32 xEnd;
s32 yEnd;
s32 multiplierY;
s32 loopX, loopY;
xEnd = x + width;
if (xEnd > surface->width)
xEnd = surface->width;
yEnd = y + height;
if (yEnd > surface->height)
yEnd = surface->height;
multiplierY = (surface->width + (surface->width & 7)) >> 3;
for (loopY = y; loopY < yEnd; loopY++)
{
for (loopX = x; loopX < xEnd; loopX++)
{
u8 *pixels = surface->pixels + (loopX & 7) + ((loopX >> 3) << 6) + (((loopY >> 3) * multiplierY) << 6) + ((u32)(loopY << 0x1d) >> 0x1a);
*pixels = fillValue;
}
}
}
+1779
View File
File diff suppressed because it is too large Load Diff
-912
View File
@@ -1,912 +0,0 @@
#include "gba/m4a_internal.h"
#define BSS_CODE __attribute__((section(".bss.code")))
BSS_CODE ALIGNED(4) char SoundMainRAM_Buffer[0x800] = {0};
struct SoundInfo gSoundInfo;
struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES];
struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES];
void *gMPlayJumpTable[36];
struct CgbChannel gCgbChans[4];
struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2];
struct PokemonCrySong gPokemonCrySong;
struct MusicPlayerInfo gMPlayInfo_BGM;
struct MusicPlayerInfo gMPlayInfo_SE1;
struct MusicPlayerInfo gMPlayInfo_SE2;
struct MusicPlayerInfo gMPlayInfo_SE3;
u8 gMPlayMemAccArea[0x10];
u32 MidiKeyToFreq(struct WaveData *wav, u8 key, u8 fineAdjust)
{
u32 val1;
u32 val2;
u32 fineAdjustShifted = fineAdjust << 24;
if (key > 178)
{
key = 178;
fineAdjustShifted = 255 << 24;
}
val1 = gScaleTable[key];
val1 = gFreqTable[val1 & 0xF] >> (val1 >> 4);
val2 = gScaleTable[key + 1];
val2 = gFreqTable[val2 & 0xF] >> (val2 >> 4);
return umul3232H32(wav->freq, val1 + umul3232H32(val2 - val1, fineAdjustShifted));
}
void UnusedDummyFunc()
{
}
void MPlayContinue(struct MusicPlayerInfo *mplayInfo)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->status &= ~MUSICPLAYER_STATUS_PAUSE;
mplayInfo->ident = ID_NUMBER;
}
}
void MPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->fadeOC = speed;
mplayInfo->fadeOI = speed;
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT);
mplayInfo->ident = ID_NUMBER;
}
}
void m4aSoundInit(void)
{
s32 i;
CpuCopy32((void *)((s32)SoundMainRAM & ~1), SoundMainRAM_Buffer, sizeof(SoundMainRAM_Buffer));
SoundInit(&gSoundInfo);
MPlayExtender(gCgbChans);
m4aSoundMode(SOUND_MODE_DA_BIT_8
| SOUND_MODE_FREQ_13379
| (12 << SOUND_MODE_MASVOL_SHIFT)
| (5 << SOUND_MODE_MAXCHN_SHIFT));
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
{
struct MusicPlayerInfo *mplayInfo = gMPlayTable[i].info;
MPlayOpen(mplayInfo, gMPlayTable[i].track, gMPlayTable[i].unk_8);
mplayInfo->unk_B = gMPlayTable[i].unk_A;
mplayInfo->memAccArea = gMPlayMemAccArea;
}
memcpy(&gPokemonCrySong, &gPokemonCrySongTemplate, sizeof(struct PokemonCrySong));
for (i = 0; i < MAX_POKEMON_CRIES; i++)
{
struct MusicPlayerInfo *mplayInfo = &gPokemonCryMusicPlayers[i];
struct MusicPlayerTrack *track = &gPokemonCryTracks[i * 2];
MPlayOpen(mplayInfo, track, 2);
track->chan = 0;
}
}
void m4aSoundMain(void)
{
SoundMain();
}
void m4aSongNumStart(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
MPlayStart(mplay->info, song->header);
}
void m4aSongNumStartOrChange(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader != song->header)
{
MPlayStart(mplay->info, song->header);
}
else
{
if ((mplay->info->status & MUSICPLAYER_STATUS_TRACK) == 0
|| (mplay->info->status & MUSICPLAYER_STATUS_PAUSE))
{
MPlayStart(mplay->info, song->header);
}
}
}
void m4aSongNumStartOrContinue(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader != song->header)
MPlayStart(mplay->info, song->header);
else if ((mplay->info->status & MUSICPLAYER_STATUS_TRACK) == 0)
MPlayStart(mplay->info, song->header);
else if (mplay->info->status & MUSICPLAYER_STATUS_PAUSE)
MPlayContinue(mplay->info);
}
void m4aSongNumStop(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader == song->header)
m4aMPlayStop(mplay->info);
}
void m4aSongNumContinue(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader == song->header)
MPlayContinue(mplay->info);
}
void m4aMPlayAllStop(void)
{
s32 i;
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
m4aMPlayStop(gMPlayTable[i].info);
for (i = 0; i < MAX_POKEMON_CRIES; i++)
m4aMPlayStop(&gPokemonCryMusicPlayers[i]);
}
void m4aMPlayContinue(struct MusicPlayerInfo *mplayInfo)
{
MPlayContinue(mplayInfo);
}
void m4aMPlayAllContinue(void)
{
s32 i;
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
MPlayContinue(gMPlayTable[i].info);
for (i = 0; i < MAX_POKEMON_CRIES; i++)
MPlayContinue(&gPokemonCryMusicPlayers[i]);
}
void m4aMPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
MPlayFadeOut(mplayInfo, speed);
}
void m4aMPlayFadeOutTemporarily(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->fadeOC = speed;
mplayInfo->fadeOI = speed;
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT) | TEMPORARY_FADE;
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayFadeIn(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->fadeOC = speed;
mplayInfo->fadeOI = speed;
mplayInfo->fadeOV = (0 << FADE_VOL_SHIFT) | FADE_IN;
mplayInfo->status &= ~MUSICPLAYER_STATUS_PAUSE;
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo)
{
s32 trackCount = mplayInfo->trackCount;
struct MusicPlayerTrack *track = mplayInfo->tracks;
while (trackCount > 0)
{
if (track->flags & MPT_FLG_EXIST)
{
if (track->flags & MPT_FLG_START)
{
Clear64byte(track);
track->flags = MPT_FLG_EXIST;
track->bendRange = 2;
track->volX = 64;
track->lfoSpeed = 22;
track->tone.type = 1;
}
}
trackCount--;
track++;
}
}
void MPlayExtender(struct CgbChannel *cgbChans)
{
struct SoundInfo *soundInfo;
u32 ident;
REG_SOUNDCNT_X = SOUND_MASTER_ENABLE
| SOUND_4_ON
| SOUND_3_ON
| SOUND_2_ON
| SOUND_1_ON;
REG_SOUNDCNT_L = 0; // set master volume to zero
REG_NR12 = 0x8;
REG_NR22 = 0x8;
REG_NR42 = 0x8;
REG_NR14 = 0x80;
REG_NR24 = 0x80;
REG_NR44 = 0x80;
REG_NR30 = 0;
REG_NR50 = 0x77;
soundInfo = SOUND_INFO_PTR;
ident = soundInfo->ident;
if (ident != ID_NUMBER)
return;
soundInfo->ident++;
gMPlayJumpTable[8] = ply_memacc;
gMPlayJumpTable[17] = ply_lfos;
gMPlayJumpTable[19] = ply_mod;
gMPlayJumpTable[28] = ply_xcmd;
gMPlayJumpTable[29] = ply_endtie;
gMPlayJumpTable[30] = SampleFreqSet;
gMPlayJumpTable[31] = TrackStop;
gMPlayJumpTable[32] = FadeOutBody;
gMPlayJumpTable[33] = TrkVolPitSet;
soundInfo->cgbChans = (struct CgbChannel *)cgbChans;
soundInfo->CgbSound = CgbSound;
soundInfo->CgbOscOff = CgbOscOff;
soundInfo->MidiKeyToCgbFreq = MidiKeyToCgbFreq;
soundInfo->maxLines = MAX_LINES;
CpuFill32(0, cgbChans, sizeof(struct CgbChannel) * 4);
cgbChans[0].ty = 1;
cgbChans[0].panMask = 0x11;
cgbChans[1].ty = 2;
cgbChans[1].panMask = 0x22;
cgbChans[2].ty = 3;
cgbChans[2].panMask = 0x44;
cgbChans[3].ty = 4;
cgbChans[3].panMask = 0x88;
soundInfo->ident = ident;
}
void MusicPlayerJumpTableCopy(void)
{
asm("swi 0x2A");
}
void ClearChain(void *x)
{
void (*func)(void *) = *(&gMPlayJumpTable[34]);
func(x);
}
void Clear64byte(void *x)
{
void (*func)(void *) = *(&gMPlayJumpTable[35]);
func(x);
}
void SoundInit(struct SoundInfo *soundInfo)
{
soundInfo->ident = 0;
if (REG_DMA1CNT & (DMA_REPEAT << 16))
REG_DMA1CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
if (REG_DMA2CNT & (DMA_REPEAT << 16))
REG_DMA2CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
REG_DMA1CNT_H = DMA_32BIT;
REG_DMA2CNT_H = DMA_32BIT;
REG_SOUNDCNT_X = SOUND_MASTER_ENABLE
| SOUND_4_ON
| SOUND_3_ON
| SOUND_2_ON
| SOUND_1_ON;
REG_SOUNDCNT_H = SOUND_B_FIFO_RESET | SOUND_B_TIMER_0 | SOUND_B_LEFT_OUTPUT
| SOUND_A_FIFO_RESET | SOUND_A_TIMER_0 | SOUND_A_RIGHT_OUTPUT
| SOUND_ALL_MIX_FULL;
REG_SOUNDBIAS_H = (REG_SOUNDBIAS_H & 0x3F) | 0x40;
REG_DMA1SAD = (s32)soundInfo->pcmBuffer;
REG_DMA1DAD = (s32)&REG_FIFO_A;
REG_DMA2SAD = (s32)soundInfo->pcmBuffer + PCM_DMA_BUF_SIZE;
REG_DMA2DAD = (s32)&REG_FIFO_B;
SOUND_INFO_PTR = soundInfo;
CpuFill32(0, soundInfo, sizeof(struct SoundInfo));
soundInfo->maxChans = 8;
soundInfo->masterVolume = 15;
soundInfo->plynote = (u32)ply_note;
soundInfo->CgbSound = DummyFunc;
soundInfo->CgbOscOff = (void (*)(u8))DummyFunc;
soundInfo->MidiKeyToCgbFreq = (u32 (*)(u8, u8, u8))DummyFunc;
soundInfo->ExtVolPit = (u32)DummyFunc;
MPlayJumpTableCopy(gMPlayJumpTable);
soundInfo->MPlayJumpTable = (u32)gMPlayJumpTable;
SampleFreqSet(SOUND_MODE_FREQ_13379);
soundInfo->ident = ID_NUMBER;
}
void SampleFreqSet(u32 freq)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
freq = (freq & 0xF0000) >> 16;
soundInfo->freq = freq;
soundInfo->pcmSamplesPerVBlank = gPcmSamplesPerVBlankTable[freq - 1];
soundInfo->pcmDmaPeriod = PCM_DMA_BUF_SIZE / soundInfo->pcmSamplesPerVBlank;
// LCD refresh rate 59.7275Hz
soundInfo->pcmFreq = (597275 * soundInfo->pcmSamplesPerVBlank + 5000) / 10000;
// CPU frequency 16.78Mhz
soundInfo->divFreq = (16777216 / soundInfo->pcmFreq + 1) >> 1;
// Turn off timer 0.
REG_TM0CNT_H = 0;
// cycles per LCD fresh 280896
REG_TM0CNT_L = -(280896 / soundInfo->pcmSamplesPerVBlank);
m4aSoundVSyncOn();
while (*(vu8 *)REG_ADDR_VCOUNT == 159)
;
while (*(vu8 *)REG_ADDR_VCOUNT != 159)
;
REG_TM0CNT_H = TIMER_ENABLE | TIMER_1CLK;
}
void m4aSoundMode(u32 mode)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
u32 temp;
if (soundInfo->ident != ID_NUMBER)
return;
soundInfo->ident++;
temp = mode & (SOUND_MODE_REVERB_SET | SOUND_MODE_REVERB_VAL);
if (temp)
soundInfo->reverb = temp & SOUND_MODE_REVERB_VAL;
temp = mode & SOUND_MODE_MAXCHN;
if (temp)
{
struct SoundChannel *chan;
soundInfo->maxChans = temp >> SOUND_MODE_MAXCHN_SHIFT;
temp = MAX_DIRECTSOUND_CHANNELS;
chan = &soundInfo->chans[0];
while (temp != 0)
{
chan->status = 0;
temp--;
chan++;
}
}
temp = mode & SOUND_MODE_MASVOL;
if (temp)
soundInfo->masterVolume = temp >> SOUND_MODE_MASVOL_SHIFT;
temp = mode & SOUND_MODE_DA_BIT;
if (temp)
{
temp = (temp & 0x300000) >> 14;
REG_SOUNDBIAS_H = (REG_SOUNDBIAS_H & 0x3F) | temp;
}
temp = mode & SOUND_MODE_FREQ;
if (temp)
{
m4aSoundVSyncOff();
SampleFreqSet(temp);
}
soundInfo->ident = ID_NUMBER;
}
void SoundClear(void)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
s32 i;
void *chan;
if (soundInfo->ident != ID_NUMBER)
return;
soundInfo->ident++;
i = MAX_DIRECTSOUND_CHANNELS;
chan = &soundInfo->chans[0];
while (i > 0)
{
((struct SoundChannel *)chan)->status = 0;
i--;
chan = (void *)((s32)chan + sizeof(struct SoundChannel));
}
chan = soundInfo->cgbChans;
if (chan)
{
i = 1;
while (i <= 4)
{
soundInfo->CgbOscOff(i);
((struct CgbChannel *)chan)->sf = 0;
i++;
chan = (void *)((s32)chan + sizeof(struct CgbChannel));
}
}
soundInfo->ident = ID_NUMBER;
}
void m4aSoundVSyncOff(void)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
if (soundInfo->ident >= ID_NUMBER && soundInfo->ident <= ID_NUMBER + 1)
{
soundInfo->ident += 10;
if (REG_DMA1CNT & (DMA_REPEAT << 16))
REG_DMA1CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
if (REG_DMA2CNT & (DMA_REPEAT << 16))
REG_DMA2CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
REG_DMA1CNT_H = DMA_32BIT;
REG_DMA2CNT_H = DMA_32BIT;
CpuFill32(0, soundInfo->pcmBuffer, sizeof(soundInfo->pcmBuffer));
}
}
void m4aSoundVSyncOn(void)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
u32 ident = soundInfo->ident;
if (ident == ID_NUMBER)
return;
REG_DMA1CNT_H = DMA_ENABLE | DMA_START_SPECIAL | DMA_32BIT | DMA_REPEAT;
REG_DMA2CNT_H = DMA_ENABLE | DMA_START_SPECIAL | DMA_32BIT | DMA_REPEAT;
soundInfo->pcmDmaCounter = 0;
soundInfo->ident = ident - 10;
}
void MPlayOpen(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tracks, u8 trackCount)
{
struct SoundInfo *soundInfo;
if (trackCount == 0)
return;
if (trackCount > MAX_MUSICPLAYER_TRACKS)
trackCount = MAX_MUSICPLAYER_TRACKS;
soundInfo = SOUND_INFO_PTR;
if (soundInfo->ident != ID_NUMBER)
return;
soundInfo->ident++;
Clear64byte(mplayInfo);
mplayInfo->tracks = tracks;
mplayInfo->trackCount = trackCount;
mplayInfo->status = MUSICPLAYER_STATUS_PAUSE;
while (trackCount != 0)
{
tracks->flags = 0;
trackCount--;
tracks++;
}
if (soundInfo->func != 0)
{
mplayInfo->func = soundInfo->func;
mplayInfo->intp = soundInfo->intp;
soundInfo->func = 0;
}
soundInfo->intp = (u32)mplayInfo;
soundInfo->func = (u32)MPlayMain;
soundInfo->ident = ID_NUMBER;
mplayInfo->ident = ID_NUMBER;
}
void MPlayStart(struct MusicPlayerInfo *mplayInfo, struct SongHeader *songHeader)
{
s32 i;
u8 unk_B;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
unk_B = mplayInfo->unk_B;
if (!unk_B
|| ((!mplayInfo->songHeader || !(mplayInfo->tracks[0].flags & MPT_FLG_START))
&& ((mplayInfo->status & MUSICPLAYER_STATUS_TRACK) == 0
|| (mplayInfo->status & MUSICPLAYER_STATUS_PAUSE)))
|| (mplayInfo->priority <= songHeader->priority))
{
mplayInfo->ident++;
mplayInfo->status = 0;
mplayInfo->songHeader = songHeader;
mplayInfo->tone = songHeader->tone;
mplayInfo->priority = songHeader->priority;
mplayInfo->clock = 0;
mplayInfo->tempoD = 150;
mplayInfo->tempoI = 150;
mplayInfo->tempoU = 0x100;
mplayInfo->tempoC = 0;
mplayInfo->fadeOI = 0;
i = 0;
track = mplayInfo->tracks;
while (i < songHeader->trackCount && i < mplayInfo->trackCount)
{
TrackStop(mplayInfo, track);
track->flags = MPT_FLG_EXIST | MPT_FLG_START;
track->chan = 0;
track->cmdPtr = songHeader->part[i];
i++;
track++;
}
while (i < mplayInfo->trackCount)
{
TrackStop(mplayInfo, track);
track->flags = 0;
i++;
track++;
}
if (songHeader->reverb & 0x80)
m4aSoundMode(songHeader->reverb);
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayStop(struct MusicPlayerInfo *mplayInfo)
{
s32 i;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
mplayInfo->status |= MUSICPLAYER_STATUS_PAUSE;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
while (i > 0)
{
TrackStop(mplayInfo, track);
i--;
track++;
}
mplayInfo->ident = ID_NUMBER;
}
void FadeOutBody(struct MusicPlayerInfo *mplayInfo)
{
s32 i;
struct MusicPlayerTrack *track;
u16 fadeOI = mplayInfo->fadeOI;
register u32 temp asm("r3");
register u16 mask asm("r2");
if (fadeOI == 0)
return;
mplayInfo->fadeOC--;
temp = 0xFFFF;
mask = temp;
if (mplayInfo->fadeOC != 0)
return;
mplayInfo->fadeOC = fadeOI;
if (mplayInfo->fadeOV & FADE_IN)
{
mplayInfo->fadeOV += (4 << FADE_VOL_SHIFT);
if ((u16)(mplayInfo->fadeOV & mask) >= (64 << FADE_VOL_SHIFT))
{
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT);
mplayInfo->fadeOI = 0;
}
}
else
{
mplayInfo->fadeOV -= (4 << FADE_VOL_SHIFT);
if ((s16)(mplayInfo->fadeOV & mask) <= 0)
{
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
while (i > 0)
{
register u32 fadeOV asm("r7");
u32 val;
TrackStop(mplayInfo, track);
val = TEMPORARY_FADE;
fadeOV = mplayInfo->fadeOV;
val &= fadeOV;
if (!val)
track->flags = 0;
i--;
track++;
}
if (mplayInfo->fadeOV & TEMPORARY_FADE)
mplayInfo->status |= MUSICPLAYER_STATUS_PAUSE;
else
mplayInfo->status = MUSICPLAYER_STATUS_PAUSE;
mplayInfo->fadeOI = 0;
return;
}
}
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
while (i > 0)
{
if (track->flags & MPT_FLG_EXIST)
{
track->volX = (mplayInfo->fadeOV >> FADE_VOL_SHIFT);
track->flags |= MPT_FLG_VOLCHG;
}
i--;
track++;
}
}
void TrkVolPitSet(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
if (track->flags & MPT_FLG_VOLSET)
{
s32 x;
s32 y;
x = (u32)(track->vol * track->volX) >> 5;
if (track->modT == 1)
x = (u32)(x * (track->modM + 128)) >> 7;
y = 2 * track->pan + track->panX;
if (track->modT == 2)
y += track->modM;
if (y < -128)
y = -128;
else if (y > 127)
y = 127;
track->volMR = (u32)((y + 128) * x) >> 8;
track->volML = (u32)((127 - y) * x) >> 8;
}
if (track->flags & MPT_FLG_PITSET)
{
s32 bend = track->bend * track->bendRange;
register s32 x asm("r1") = track->tune;
x += bend;
x *= 4;
x += (track->keyShift << 8);
x += (track->keyShiftX << 8);
x += track->pitX;
if (track->modT == 0)
x += 16 * track->modM;
track->keyM = x >> 8;
track->pitM = x;
}
track->flags &= ~(MPT_FLG_PITSET | MPT_FLG_VOLSET);
}
u32 MidiKeyToCgbFreq(u8 chanNum, u8 key, u8 fineAdjust)
{
if (chanNum == 4)
{
if (key <= 20)
{
key = 0;
}
else
{
key -= 21;
if (key > 59)
key = 59;
}
return gNoiseTable[key];
}
else
{
s32 val1;
s32 val2;
if (key <= 35)
{
fineAdjust = 0;
key = 0;
}
else
{
key -= 36;
if (key > 130)
{
key = 130;
fineAdjust = 255;
}
}
val1 = gCgbScaleTable[key];
val1 = gCgbFreqTable[val1 & 0xF] >> (val1 >> 4);
val2 = gCgbScaleTable[key + 1];
val2 = gCgbFreqTable[val2 & 0xF] >> (val2 >> 4);
return val1 + ((fineAdjust * (val2 - val1)) >> 8) + 2048;
}
}
void CgbOscOff(u8 chanNum)
{
switch (chanNum)
{
case 1:
REG_NR12 = 8;
REG_NR14 = 0x80;
break;
case 2:
REG_NR22 = 8;
REG_NR24 = 0x80;
break;
case 3:
REG_NR30 = 0;
break;
default:
REG_NR42 = 8;
REG_NR44 = 0x80;
}
}
static inline int CgbPan(struct CgbChannel *chan)
{
u32 rightVolume = chan->rightVolume;
u32 leftVolume = chan->leftVolume;
if ((rightVolume = (u8)rightVolume) >= (leftVolume = (u8)leftVolume))
{
if (rightVolume / 2 >= leftVolume)
{
chan->pan = 0x0F;
return 1;
}
}
else
{
if (leftVolume / 2 >= rightVolume)
{
chan->pan = 0xF0;
return 1;
}
}
return 0;
}
void CgbModVol(struct CgbChannel *chan)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
if ((soundInfo->mode & 1) || !CgbPan(chan))
{
chan->pan = 0xFF;
chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
}
else
{
// Force chan->rightVolume and chan->leftVolume to be read from memory again,
// even though there is no reason to do so.
// The command line option "-fno-gcse" achieves the same result as this.
asm("" : : : "memory");
chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
if (chan->eg > 15)
chan->eg = 15;
}
chan->sg = (chan->eg * chan->su + 15) >> 4;
chan->pan &= chan->panMask;
}
-545
View File
@@ -1,545 +0,0 @@
#include "gba/m4a_internal.h"
void m4aMPlayTempoControl(struct MusicPlayerInfo *mplayInfo, u16 tempo)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->tempoU = tempo;
mplayInfo->tempoI = (mplayInfo->tempoD * mplayInfo->tempoU) >> 8;
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayVolumeControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 volume)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->volX = volume / 4;
track->flags |= MPT_FLG_VOLCHG;
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, s16 pitch)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->keyShiftX = (s16)pitch >> 8;
track->pitX = pitch;
track->flags |= MPT_FLG_PITCHG;
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void m4aMPlayPanpotControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, s8 pan)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->panX = pan;
track->flags |= MPT_FLG_VOLCHG;
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void ClearModM(struct MusicPlayerTrack *track)
{
track->lfoSpeedC = 0;
track->modM = 0;
if (track->modT == 0)
track->flags |= MPT_FLG_PITCHG;
else
track->flags |= MPT_FLG_VOLCHG;
}
void m4aMPlayModDepthSet(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u8 modDepth)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->mod = modDepth;
if (!track->mod)
ClearModM(track);
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void m4aMPlayLFOSpeedSet(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u8 lfoSpeed)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->lfoSpeed = lfoSpeed;
if (!track->lfoSpeed)
ClearModM(track);
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
#define MEMACC_COND_JUMP(cond) \
if (cond) \
goto cond_true; \
else \
goto cond_false; \
void ply_memacc(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 op;
u8 *addr;
u8 data;
op = *track->cmdPtr;
track->cmdPtr++;
addr = mplayInfo->memAccArea + *track->cmdPtr;
track->cmdPtr++;
data = *track->cmdPtr;
track->cmdPtr++;
switch (op)
{
case 0:
*addr = data;
return;
case 1:
*addr += data;
return;
case 2:
*addr -= data;
return;
case 3:
*addr = mplayInfo->memAccArea[data];
return;
case 4:
*addr += mplayInfo->memAccArea[data];
return;
case 5:
*addr -= mplayInfo->memAccArea[data];
return;
case 6:
MEMACC_COND_JUMP(*addr == data)
return;
case 7:
MEMACC_COND_JUMP(*addr != data)
return;
case 8:
MEMACC_COND_JUMP(*addr > data)
return;
case 9:
MEMACC_COND_JUMP(*addr >= data)
return;
case 10:
MEMACC_COND_JUMP(*addr <= data)
return;
case 11:
MEMACC_COND_JUMP(*addr < data)
return;
case 12:
MEMACC_COND_JUMP(*addr == mplayInfo->memAccArea[data])
return;
case 13:
MEMACC_COND_JUMP(*addr != mplayInfo->memAccArea[data])
return;
case 14:
MEMACC_COND_JUMP(*addr > mplayInfo->memAccArea[data])
return;
case 15:
MEMACC_COND_JUMP(*addr >= mplayInfo->memAccArea[data])
return;
case 16:
MEMACC_COND_JUMP(*addr <= mplayInfo->memAccArea[data])
return;
case 17:
MEMACC_COND_JUMP(*addr < mplayInfo->memAccArea[data])
return;
default:
return;
}
cond_true:
{
void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[1]);
func(mplayInfo, track);
return;
}
cond_false:
track->cmdPtr += 4;
}
void ply_xcmd(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 n = *track->cmdPtr;
track->cmdPtr++;
gXcmdTable[n](mplayInfo, track);
}
void ply_xxx(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[0]);
func(mplayInfo, track);
}
#define READ_XCMD_BYTE(var, n) \
{ \
u32 byte = track->cmdPtr[(n)]; \
byte <<= n * 8; \
(var) &= ~(0xFF << (n * 8)); \
(var) |= byte; \
}
void ply_xwave(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 wav;
READ_XCMD_BYTE(wav, 0) // UB: uninitialized variable
READ_XCMD_BYTE(wav, 1)
READ_XCMD_BYTE(wav, 2)
READ_XCMD_BYTE(wav, 3)
track->tone.wav = (struct WaveData *)wav;
track->cmdPtr += 4;
}
void ply_xtype(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.type = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xatta(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.attack = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xdeca(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.decay = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xsust(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.sustain = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xrele(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.release = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xiecv(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->echoVolume = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xiecl(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->echoLength = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xleng(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.length = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xswee(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.pan_sweep = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 unk;
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
READ_XCMD_BYTE(unk, 1)
if (track->unk_3A < (u16)unk)
{
track->unk_3A++;
track->cmdPtr -= 2;
track->wait = 1;
}
else
{
track->unk_3A = 0;
track->cmdPtr += 2;
}
}
void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 unk;
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
READ_XCMD_BYTE(unk, 1)
READ_XCMD_BYTE(unk, 2)
READ_XCMD_BYTE(unk, 3)
track->unk_3C = unk;
track->cmdPtr += 4;
}
void DummyFunc(void)
{
}
struct MusicPlayerInfo *SetPokemonCryTone(struct ToneData *tone)
{
u32 maxClock = 0;
s32 maxClockIndex = 0;
s32 i;
struct MusicPlayerInfo *mplayInfo;
for (i = 0; i < MAX_POKEMON_CRIES; i++)
{
struct MusicPlayerTrack *track = &gPokemonCryTracks[i * 2];
if (!track->flags && (!track->chan || track->chan->track != track))
goto start_song;
if (maxClock < gPokemonCryMusicPlayers[i].clock)
{
maxClock = gPokemonCryMusicPlayers[i].clock;
maxClockIndex = i;
}
}
i = maxClockIndex;
start_song:
mplayInfo = &gPokemonCryMusicPlayers[i];
mplayInfo->ident++;
#define CRY ((s32)&gPokemonCrySongs + i * sizeof(struct PokemonCrySong))
#define CRY_OFS(field) offsetof(struct PokemonCrySong, field)
memcpy((void *)CRY, &gPokemonCrySong, sizeof(struct PokemonCrySong));
*(u32 *)(CRY + CRY_OFS(tone)) = (u32)tone;
*(u32 *)(CRY + CRY_OFS(part)) = CRY + CRY_OFS(part0);
*(u32 *)(CRY + CRY_OFS(part) + 4) = CRY + CRY_OFS(part1);
*(u32 *)(CRY + CRY_OFS(gotoTarget)) = CRY + CRY_OFS(cont);
#undef CRY_OFS
#undef CRY
mplayInfo->ident = ID_NUMBER;
MPlayStart(mplayInfo, (struct SongHeader *)(&gPokemonCrySongs[i]));
return mplayInfo;
}
void SetPokemonCryVolume(u8 val)
{
gPokemonCrySong.volumeValue = val & 0x7F;
}
void SetPokemonCryPanpot(s8 val)
{
gPokemonCrySong.panValue = (val + C_V) & 0x7F;
}
void SetPokemonCryPitch(s16 val)
{
s16 b = val + 0x80;
u8 a = gPokemonCrySong.tuneValue2 - gPokemonCrySong.tuneValue;
gPokemonCrySong.tieKeyValue = (b >> 8) & 0x7F;
gPokemonCrySong.tuneValue = (b >> 1) & 0x7F;
gPokemonCrySong.tuneValue2 = (a + ((b >> 1) & 0x7F)) & 0x7F;
}
void SetPokemonCryLength(u16 val)
{
gPokemonCrySong.unkCmd0CParam = val;
}
void SetPokemonCryRelease(u8 val)
{
gPokemonCrySong.releaseValue = val;
}
void SetPokemonCryProgress(u32 val)
{
gPokemonCrySong.unkCmd0DParam = val;
}
int IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo)
{
struct MusicPlayerTrack *track = mplayInfo->tracks;
if (track->chan && track->chan->track == track)
return 1;
else
return 0;
}
void SetPokemonCryChorus(s8 val)
{
if (val)
{
gPokemonCrySong.trackCount = 2;
gPokemonCrySong.tuneValue2 = (val + gPokemonCrySong.tuneValue) & 0x7F;
}
else
{
gPokemonCrySong.trackCount = 1;
}
}
void SetPokemonCryStereo(u32 val)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
if (val)
{
REG_SOUNDCNT_H = SOUND_B_TIMER_0 | SOUND_B_LEFT_OUTPUT
| SOUND_A_TIMER_0 | SOUND_A_RIGHT_OUTPUT
| SOUND_ALL_MIX_FULL;
soundInfo->mode &= ~1;
}
else
{
REG_SOUNDCNT_H = SOUND_B_TIMER_0 | SOUND_B_LEFT_OUTPUT | SOUND_B_RIGHT_OUTPUT
| SOUND_A_TIMER_0 | SOUND_A_LEFT_OUTPUT | SOUND_A_RIGHT_OUTPUT
| SOUND_B_MIX_HALF | SOUND_A_MIX_HALF | SOUND_CGB_MIX_FULL;
soundInfo->mode |= 1;
}
}
void SetPokemonCryPriority(u8 val)
{
gPokemonCrySong.priority = val;
}
+2 -2
View File
@@ -10,7 +10,7 @@ static u32 sub_8146E0C(struct MysteryEventStruct *);
static void sub_8146DA0(struct MysteryEventStruct *);
static void sub_8146D94(struct MysteryEventStruct *);
void sub_8146C30(u32 a0)
void GenerateRandomNews(u32 a0)
{
struct MysteryEventStruct *r5 = sub_8143D94();
@@ -59,7 +59,7 @@ u16 sub_8146CE8(void)
struct MysteryEventStruct *r4 = sub_8143D94();
u16 r5;
if (!sub_806E2BC() || !sub_8143E1C())
if (!sub_806E2BC() || !ValidateReceivedWonderNews())
return 0;
r5 = sub_8146E0C(r4);
+43 -43
View File
@@ -240,7 +240,7 @@ u32 sub_8143770(u8 * r4, u16 * r5)
return 0;
}
void sub_81438A0(void)
void task_add_00_ereader(void)
{
u8 taskId = CreateTask(sub_8143910, 0);
struct MEventTaskData1 *data = (struct MEventTaskData1 *)gTasks[taskId].data;
@@ -279,7 +279,7 @@ void sub_8143910(u8 taskId)
switch (data->t08)
{
case 0:
if (mevent_0814257C(&data->t09, gUnknown_841DE52))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE52))
data->t08 = 1;
break;
case 1:
@@ -294,16 +294,16 @@ void sub_8143910(u8 taskId)
case 3:
if (!sub_814374C())
{
sub_80098B8();
CloseLink();
data->t08 = 4;
}
else
data->t08 = 13;
break;
case 4:
if (mevent_0814257C(&data->t09, gUnknown_841DE53))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE53))
{
sub_8142504(gUnknown_841DE54);
AddTextPrinterToWindow1(gUnknown_841DE54);
sub_81438E8(&data->t00);
data->t08 = 5;
}
@@ -325,36 +325,36 @@ void sub_8143910(u8 taskId)
if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
sub_80098B8();
CloseLink();
sub_81438E8(&data->t00);
data->t08 = 23;
}
else if (GetLinkPlayerCount_2() > 1)
{
sub_81438E8(&data->t00);
sub_80098B8();
CloseLink();
data->t08 = 7;
}
else if (sub_81436EC())
{
PlaySE(SE_SELECT);
sub_80098B8();
CloseLink();
sub_81438E8(&data->t00);
data->t08 = 8;
}
else if (sub_81438F0(&data->t00, 10))
{
sub_80098B8();
CloseLink();
sub_81436BC();
sub_81438E8(&data->t00);
}
break;
case 7:
if (mevent_0814257C(&data->t09, gUnknown_841DE7C))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE7C))
data->t08 = 4;
break;
case 8:
sub_8142504(gUnknown_841DE95);
AddTextPrinterToWindow1(gUnknown_841DE95);
sub_81435DC(&gUnknown_3005ED0, gUnknownSerialData_End - gUnknownSerialData_Start, gUnknownSerialData_Start);
data->t08 = 9;
break;
@@ -370,7 +370,7 @@ void sub_8143910(u8 taskId)
else if (data->t0E == 1)
{
sub_81438E8(&data->t00);
sub_8142504(gUnknown_841DE9B);
AddTextPrinterToWindow1(gUnknown_841DE9B);
data->t08 = 11;
}
else
@@ -382,7 +382,7 @@ void sub_8143910(u8 taskId)
break;
case 12:
sub_81436BC();
sub_8142504(gUnknown_841DE98);
AddTextPrinterToWindow1(gUnknown_841DE98);
data->t08 = 13;
break;
case 13:
@@ -391,21 +391,21 @@ void sub_8143910(u8 taskId)
case 0:
break;
case 2:
sub_8142504(gUnknown_841DE95);
AddTextPrinterToWindow1(gUnknown_841DE95);
data->t08 = 14;
break;
case 1:
PlaySE(SE_SELECT);
sub_80098B8();
CloseLink();
data->t08 = 23;
break;
case 5:
sub_80098B8();
CloseLink();
data->t08 = 21;
break;
case 3:
case 4:
sub_80098B8();
CloseLink();
data->t08 = 20;
break;
}
@@ -413,7 +413,7 @@ void sub_8143910(u8 taskId)
case 14:
if (HasLinkErrorOccurred())
{
sub_80098B8();
CloseLink();
data->t08 = 20;
}
else if (GetBlockReceivedStatus())
@@ -439,7 +439,7 @@ void sub_8143910(u8 taskId)
case 17:
if (sub_815D794(gDecompressionBuffer))
{
sub_8142504(gUnknown_841DE99);
AddTextPrinterToWindow1(gUnknown_841DE99);
sub_81438E8(&data->t00);
data->t08 = 18;
}
@@ -449,7 +449,7 @@ void sub_8143910(u8 taskId)
case 18:
if (sub_81438F0(&data->t00, 120))
{
sub_8142504(gUnknown_841DE9A);
AddTextPrinterToWindow1(gUnknown_841DE9A);
PlayFanfare(258);
data->t08 = 19;
}
@@ -459,26 +459,26 @@ void sub_8143910(u8 taskId)
data->t08 = 26;
break;
case 23:
if (mevent_0814257C(&data->t09, gUnknown_841DE7D))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE7D))
data->t08 = 26;
break;
case 20:
if (mevent_0814257C(&data->t09, gUnknown_841DE96))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE96))
data->t08 = 0;
break;
case 21:
if (mevent_0814257C(&data->t09, gUnknown_841DE97))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE97))
data->t08 = 0;
break;
case 22:
if (mevent_0814257C(&data->t09, gUnknown_841DE9C))
if (MG_PrintTextOnWindow1AndWaitButton(&data->t09, gUnknown_841DE9C))
data->t08 = 0;
break;
case 26:
sub_812B484();
Free(data->t10);
DestroyTask(taskId);
SetMainCallback2(sub_81422FC);
SetMainCallback2(MainCB_FreeAllBuffersAndReturnToInitTitleScreen);
break;
}
}
@@ -490,12 +490,12 @@ void sub_8143D24(void)
sub_80BDE28();
}
struct MEventBuffer_3120_Sub * sub_8143D58(void)
struct MEventBuffer_3120_Sub * GetSavedWonderNews(void)
{
return &gSaveBlock1Ptr->unk_3120.buffer_000.data;
}
struct MEventBuffer_32E0_Sub * sav1_get_mevent_buffer_1(void)
struct MEventBuffer_32E0_Sub * GetSavedWonderCard(void)
{
return &gSaveBlock1Ptr->unk_3120.buffer_1c0.data;
}
@@ -515,7 +515,7 @@ u16 * sub_8143DA8(void)
return gSaveBlock1Ptr->unk_3120.unk_338;
}
void sub_8143DBC(void)
void DestroyWonderNews(void)
{
sub_8143E9C();
}
@@ -530,7 +530,7 @@ bool32 sub_8143DC8(const struct MEventBuffer_3120_Sub * src)
return TRUE;
}
bool32 sub_8143E1C(void)
bool32 ValidateReceivedWonderNews(void)
{
if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_3120.buffer_000.data, sizeof(struct MEventBuffer_3120_Sub)) != gSaveBlock1Ptr->unk_3120.buffer_000.crc)
return FALSE;
@@ -546,7 +546,7 @@ bool32 sub_8143E64(const struct MEventBuffer_3120_Sub * data)
return TRUE;
}
bool32 sub_8143E78(void)
bool32 WonderNews_Test_Unk_02(void)
{
const struct MEventBuffer_3120_Sub * data = &gSaveBlock1Ptr->unk_3120.buffer_000.data;
if (data->unk_02 == 0)
@@ -556,7 +556,7 @@ bool32 sub_8143E78(void)
void sub_8143E9C(void)
{
CpuFill32(0, sub_8143D58(), sizeof(gSaveBlock1Ptr->unk_3120.buffer_000.data));
CpuFill32(0, GetSavedWonderNews(), sizeof(gSaveBlock1Ptr->unk_3120.buffer_000.data));
gSaveBlock1Ptr->unk_3120.buffer_000.crc = 0;
}
@@ -570,7 +570,7 @@ bool32 sub_8143EF4(const u8 * src)
{
const u8 * r5 = (const u8 *)&gSaveBlock1Ptr->unk_3120.buffer_000.data;
u32 i;
if (!sub_8143E1C())
if (!ValidateReceivedWonderNews())
return FALSE;
for (i = 0; i < sizeof(struct MEventBuffer_3120_Sub); i++)
{
@@ -580,7 +580,7 @@ bool32 sub_8143EF4(const u8 * src)
return TRUE;
}
void sub_8143F38(void)
void DestroyWonderCard(void)
{
sub_814407C();
sub_81440B4();
@@ -597,7 +597,7 @@ bool32 sub_8143F68(const struct MEventBuffer_32E0_Sub * data)
struct MEventBuffer_32E0_Sub * r1;
if (!sub_8144018(data))
return FALSE;
sub_8143F38();
DestroyWonderCard();
memcpy(&gSaveBlock1Ptr->unk_3120.buffer_1c0.data, data, sizeof(struct MEventBuffer_32E0_Sub));
gSaveBlock1Ptr->unk_3120.buffer_1c0.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_3120.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub));
r2 = &gSaveBlock1Ptr->unk_3120.buffer_310.data;
@@ -606,7 +606,7 @@ bool32 sub_8143F68(const struct MEventBuffer_32E0_Sub * data)
return TRUE;
}
bool32 sub_8143FC8(void)
bool32 ValidateReceivedWonderCard(void)
{
if (gSaveBlock1Ptr->unk_3120.buffer_1c0.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_3120.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub)))
return FALSE;
@@ -632,7 +632,7 @@ bool32 sub_8144018(const struct MEventBuffer_32E0_Sub * data)
return TRUE;
}
bool32 sub_8144054(void)
bool32 WonderCard_Test_Unk_08_6(void)
{
const struct MEventBuffer_32E0_Sub * data = &gSaveBlock1Ptr->unk_3120.buffer_1c0.data;
if (data->unk_08_6 == 0)
@@ -654,7 +654,7 @@ void sub_81440B4(void)
u16 sub_81440E8(void)
{
if (sub_8143FC8())
if (ValidateReceivedWonderCard())
return gSaveBlock1Ptr->unk_3120.buffer_1c0.data.unk_00;
return 0;
}
@@ -672,7 +672,7 @@ bool32 sub_8144124(u16 a0)
return FALSE;
}
bool32 sub_8144144(void)
bool32 CheckReceivedGiftFromWonderCard(void)
{
u16 value = sub_81440E8();
if (!sub_8144124(value))
@@ -721,7 +721,7 @@ bool32 sub_81441F0(const u16 * data)
s32 sub_8144218(void)
{
struct MEventBuffer_32E0_Sub * data;
if (!sub_8143FC8())
if (!ValidateReceivedWonderCard())
return 0;
data = &gSaveBlock1Ptr->unk_3120.buffer_1c0.data;
if (data->unk_08_0 != 1)
@@ -759,11 +759,11 @@ void sub_81442CC(struct MEventStruct_Unk1442CC * data)
data->unk_08 = 1;
data->unk_0C = 1;
data->unk_10 = 1;
if (sub_8143FC8())
if (ValidateReceivedWonderCard())
{
data->unk_14 = sav1_get_mevent_buffer_1()->unk_00;
data->unk_14 = GetSavedWonderCard()->unk_00;
data->unk_20 = *sav1_get_mevent_buffer_2();
data->unk_44 = sav1_get_mevent_buffer_1()->unk_09;
data->unk_44 = GetSavedWonderCard()->unk_09;
}
else
data->unk_14 = 0;
@@ -945,7 +945,7 @@ bool32 sub_81446D0(u16 a0)
gUnknown_203F3BC = FALSE;
if (a0 == 0)
return FALSE;
if (!sub_8143FC8())
if (!ValidateReceivedWonderCard())
return FALSE;
if (gSaveBlock1Ptr->unk_3120.buffer_1c0.data.unk_00 != a0)
return FALSE;
+14 -14
View File
@@ -126,7 +126,7 @@ const struct UnkStruct_8467FB8 gUnknown_8467FB8[8] = {
{1, 0, 0, 7, gUnknown_8467A7C, gUnknown_8467CAC, gUnknown_846716C}
};
bool32 sub_8145654(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_Sub * r6)
bool32 InitWonderCardResources(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_Sub * r6)
{
if (r5 == NULL || r6 == NULL)
return FALSE;
@@ -145,7 +145,7 @@ bool32 sub_8145654(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_S
return TRUE;
}
void sub_81456F0(void)
void DestroyWonderCardResources(void)
{
if (gUnknown_203F3C8 != NULL)
{
@@ -155,7 +155,7 @@ void sub_81456F0(void)
}
}
s32 sub_814571C(void)
s32 FadeToWonderCardMenu(void)
{
if (gUnknown_203F3C8 == NULL)
return -1;
@@ -219,7 +219,7 @@ s32 sub_814571C(void)
return 0;
}
s32 sub_814593C(bool32 flag)
s32 FadeOutFromWonderCard(bool32 flag)
{
if (gUnknown_203F3C8 == NULL)
return -1;
@@ -252,7 +252,7 @@ s32 sub_814593C(bool32 flag)
FreeMonIconPalettes();
break;
case 5:
sub_8142344(gUnknown_203F3B8, flag);
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, flag);
break;
case 6:
CopyBgTilemapBufferToVram(0);
@@ -508,7 +508,7 @@ const struct UnkStruct_8467FB8 gUnknown_8468720[] = {
{1, 0, 0, 0, gUnknown_84685B4, gUnknown_8468644, gUnknown_84680A0}
};
bool32 sub_8146288(const struct MEventBuffer_3120_Sub * a0)
bool32 InitWonderNewsResources(const struct MEventBuffer_3120_Sub * a0)
{
if (a0 == NULL)
return FALSE;
@@ -523,7 +523,7 @@ bool32 sub_8146288(const struct MEventBuffer_3120_Sub * a0)
return TRUE;
}
void sub_81462EC(void)
void DestroyWonderNewsResources(void)
{
if (gUnknown_203F3CC != NULL)
{
@@ -533,7 +533,7 @@ void sub_81462EC(void)
}
}
s32 sub_8146318(void)
s32 FadeToWonderNewsMenu(void)
{
if (gUnknown_203F3CC == NULL)
return -1;
@@ -608,7 +608,7 @@ s32 sub_8146318(void)
return 0;
}
s32 sub_8146604(bool32 flag)
s32 FadeOutFromWonderNews(bool32 flag)
{
if (gUnknown_203F3CC == NULL)
return -1;
@@ -653,10 +653,10 @@ s32 sub_8146604(bool32 flag)
}
break;
case 5:
sub_8142344(gUnknown_203F3B8, flag);
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, flag);
break;
case 6:
sub_8142420();
MG_DrawCheckerboardPattern();
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(3);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
@@ -671,7 +671,7 @@ s32 sub_8146604(bool32 flag)
return 0;
}
void sub_81467EC(void)
void MENews_RemoveScrollIndicatorArrowPair(void)
{
if (!gUnknown_203F3CC->unk_01C0_0 && gUnknown_203F3CC->unk_01C1 != 0xFF)
{
@@ -682,7 +682,7 @@ void sub_81467EC(void)
}
void sub_8146834(void)
void MENews_AddScrollIndicatorArrowPair(void)
{
if (gUnknown_203F3CC->unk_01C0_0)
{
@@ -691,7 +691,7 @@ void sub_8146834(void)
}
}
u8 sub_8146884(u16 input)
u32 MENews_GetInput(u16 input)
{
if (gUnknown_203F3CC->unk_01C2_0)
{
+46 -46
View File
@@ -11,12 +11,12 @@
#include "mevent.h"
#include "mevent_server.h"
EWRAM_DATA struct mevent_srv_ish * s_mevent_srv_ish_ptr = NULL;
EWRAM_DATA struct mevent_client * s_mevent_client_ptr = NULL;
EWRAM_DATA struct mevent_srv_common * s_mevent_srv_common_ptr = NULL;
static void mevent_srv_ish_init(struct mevent_srv_ish *, u32, u32);
static u32 mevent_srv_ish_exec(struct mevent_srv_ish *);
static void mevent_srv_ish_free_resources(struct mevent_srv_ish *);
static void mevent_client_init(struct mevent_client *, u32, u32);
static u32 mevent_client_exec(struct mevent_client *);
static void mevent_client_free_resources(struct mevent_client *);
static void mevent_srv_init_common(struct mevent_srv_common *, const void *, u32, u32);
static void mevent_srv_free_resources(struct mevent_srv_common *);
static u32 mevent_srv_exec_common(struct mevent_srv_common *);
@@ -25,44 +25,44 @@ extern const u8 gUnknown_84687E0[];
extern const struct mevent_cmd gUnknown_8468B6C[];
extern const struct mevent_cmd gUnknown_8468BCC[];
void mevent_srv_ish_do_init(void)
void mevent_client_do_init(void)
{
s_mevent_srv_ish_ptr = AllocZeroed(sizeof(struct mevent_srv_ish));
mevent_srv_ish_init(s_mevent_srv_ish_ptr, 1, 0);
s_mevent_client_ptr = AllocZeroed(sizeof(struct mevent_client));
mevent_client_init(s_mevent_client_ptr, 1, 0);
}
u32 mevent_srv_ish_do_exec(u16 * a0)
u32 mevent_client_do_exec(u16 * a0)
{
u32 result;
if (s_mevent_srv_ish_ptr == NULL)
if (s_mevent_client_ptr == NULL)
return 6;
result = mevent_srv_ish_exec(s_mevent_srv_ish_ptr);
result = mevent_client_exec(s_mevent_client_ptr);
if (result == 6)
{
*a0 = s_mevent_srv_ish_ptr->param;
mevent_srv_ish_free_resources(s_mevent_srv_ish_ptr);
Free(s_mevent_srv_ish_ptr);
s_mevent_srv_ish_ptr = NULL;
*a0 = s_mevent_client_ptr->param;
mevent_client_free_resources(s_mevent_client_ptr);
Free(s_mevent_client_ptr);
s_mevent_client_ptr = NULL;
}
return result;
}
void mevent_srv_ish_inc_flag(void)
void mevent_client_inc_flag(void)
{
s_mevent_srv_ish_ptr->flag++;
s_mevent_client_ptr->flag++;
}
void * mevent_srv_ish_get_buffer(void)
void * mevent_client_get_buffer(void)
{
return s_mevent_srv_ish_ptr->buffer;
return s_mevent_client_ptr->buffer;
}
void mevent_srv_ish_set_param(u32 a0)
void mevent_client_set_param(u32 a0)
{
s_mevent_srv_ish_ptr->param = a0;
s_mevent_client_ptr->param = a0;
}
static void mevent_srv_ish_init(struct mevent_srv_ish * svr, u32 sendPlayerNo, u32 recvPlayerNo)
static void mevent_client_init(struct mevent_client * svr, u32 sendPlayerNo, u32 recvPlayerNo)
{
svr->unk_00 = 0;
svr->mainseqno = 0;
@@ -74,7 +74,7 @@ static void mevent_srv_ish_init(struct mevent_srv_ish * svr, u32 sendPlayerNo, u
mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
}
static void mevent_srv_ish_free_resources(struct mevent_srv_ish * svr)
static void mevent_client_free_resources(struct mevent_client * svr)
{
Free(svr->sendBuffer);
Free(svr->recvBuffer);
@@ -82,20 +82,20 @@ static void mevent_srv_ish_free_resources(struct mevent_srv_ish * svr)
Free(svr->buffer);
}
static void mevent_srv_ish_jmp_buffer(struct mevent_srv_ish * svr)
static void mevent_client_jmp_buffer(struct mevent_client * svr)
{
memcpy(svr->cmdBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
svr->cmdidx = 0;
}
static void mevent_srv_ish_send_word(struct mevent_srv_ish * svr, u32 ident, u32 word)
static void mevent_client_send_word(struct mevent_client * svr, u32 ident, u32 word)
{
CpuFill32(0, svr->sendBuffer, ME_SEND_BUF_SIZE);
*(u32 *)svr->sendBuffer = word;
mevent_srv_sub_init_send(&svr->manager, ident, svr->sendBuffer, sizeof(u32));
}
static u32 ish_mainseq_0(struct mevent_srv_ish * svr)
static u32 ish_mainseq_0(struct mevent_client * svr)
{
// init
memcpy(svr->cmdBuffer, gUnknown_84687E0, ME_SEND_BUF_SIZE);
@@ -105,13 +105,13 @@ static u32 ish_mainseq_0(struct mevent_srv_ish * svr)
return 0;
}
static u32 ish_mainseq_1(struct mevent_srv_ish * svr)
static u32 ish_mainseq_1(struct mevent_client * svr)
{
// done
return 6;
}
static u32 ish_mainseq_2(struct mevent_srv_ish * svr)
static u32 ish_mainseq_2(struct mevent_client * svr)
{
// do recv
if (mevent_srv_sub_recv(&svr->manager))
@@ -122,7 +122,7 @@ static u32 ish_mainseq_2(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_3(struct mevent_srv_ish * svr)
static u32 ish_mainseq_3(struct mevent_client * svr)
{
// do send
if (mevent_srv_sub_send(&svr->manager))
@@ -133,7 +133,7 @@ static u32 ish_mainseq_3(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
static u32 ish_mainseq_4(struct mevent_client * svr)
{
// process command
struct mevent_cmd_ish * cmd = &svr->cmdBuffer[svr->cmdidx];
@@ -162,20 +162,20 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
svr->flag = 0;
break;
case 19:
mevent_srv_ish_send_word(svr, 0x12, GetGameStat(cmd->parameter));
mevent_client_send_word(svr, 0x12, GetGameStat(cmd->parameter));
svr->mainseqno = 3;
svr->flag = 0;
break;
case 6:
if (svr->param == 0)
mevent_srv_ish_jmp_buffer(svr);
mevent_client_jmp_buffer(svr);
break;
case 7:
if (svr->param == 1)
mevent_srv_ish_jmp_buffer(svr);
mevent_client_jmp_buffer(svr);
break;
case 4:
mevent_srv_ish_jmp_buffer(svr);
mevent_client_jmp_buffer(svr);
break;
case 5:
memcpy(svr->buffer, svr->recvBuffer, 0x40);
@@ -201,7 +201,7 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
mevent_srv_sub_init_send(&svr->manager, 0x11, svr->sendBuffer, sizeof(struct MEventStruct_Unk1442CC));
break;
case 14:
mevent_srv_ish_send_word(svr, 0x13, svr->param);
mevent_client_send_word(svr, 0x13, svr->param);
break;
case 10:
sub_8143F68(svr->recvBuffer);
@@ -210,10 +210,10 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
if (!sub_8143EF4(svr->recvBuffer))
{
sub_8143DC8(svr->recvBuffer);
mevent_srv_ish_send_word(svr, 0x13, 0);
mevent_client_send_word(svr, 0x13, 0);
}
else
mevent_srv_ish_send_word(svr, 0x13, 1);
mevent_client_send_word(svr, 0x13, 1);
break;
case 15:
svr->mainseqno = 6;
@@ -239,7 +239,7 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_5(struct mevent_srv_ish * svr)
static u32 ish_mainseq_5(struct mevent_client * svr)
{
// wait flag
if (svr->flag)
@@ -250,7 +250,7 @@ static u32 ish_mainseq_5(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_6(struct mevent_srv_ish * svr)
static u32 ish_mainseq_6(struct mevent_client * svr)
{
// ???
switch (svr->flag)
@@ -270,7 +270,7 @@ static u32 ish_mainseq_6(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_7(struct mevent_srv_ish * svr)
static u32 ish_mainseq_7(struct mevent_client * svr)
{
// exec arbitrary code
u32 (*func)(u32 *, struct SaveBlock2 *, struct SaveBlock1 *) = (void *)gDecompressionBuffer;
@@ -282,9 +282,9 @@ static u32 ish_mainseq_7(struct mevent_srv_ish * svr)
return 1;
}
static u32 mevent_srv_ish_exec(struct mevent_srv_ish * svr)
static u32 mevent_client_exec(struct mevent_client * svr)
{
u32 (*funcs[])(struct mevent_srv_ish *) = {
u32 (*funcs[])(struct mevent_client *) = {
ish_mainseq_0,
ish_mainseq_1,
ish_mainseq_2,
@@ -297,19 +297,19 @@ static u32 mevent_srv_ish_exec(struct mevent_srv_ish * svr)
return funcs[svr->mainseqno](svr);
}
void mevent_srv_common_do_init_1(void)
void mevent_srv_init_wnews(void)
{
s_mevent_srv_common_ptr = AllocZeroed(sizeof(struct mevent_srv_common));
mevent_srv_init_common(s_mevent_srv_common_ptr, gUnknown_8468B6C, 0, 1);
}
void mevent_srv_common_do_init_2(void)
void mevent_srv_new_wcard(void)
{
s_mevent_srv_common_ptr = AllocZeroed(sizeof(struct mevent_srv_common));
mevent_srv_init_common(s_mevent_srv_common_ptr, gUnknown_8468BCC, 0, 1);
}
u32 mevent_srv_init_do_exec(u16 * a0)
u32 mevent_srv_common_do_exec(u16 * a0)
{
u32 result;
if (s_mevent_srv_common_ptr == NULL)
@@ -526,12 +526,12 @@ static u32 common_mainseq_4(struct mevent_srv_common * svr)
break;
case 26:
AGB_ASSERT_EX(cmd->flag == FALSE && cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 506);
memcpy(svr->mevent_32e0, sav1_get_mevent_buffer_1(), 332);
memcpy(svr->mevent_32e0, GetSavedWonderCard(), 332);
sub_814410C(svr->mevent_32e0);
break;
case 27:
AGB_ASSERT_EX(cmd->flag == FALSE && cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 512);
memcpy(svr->mevent_3120, sub_8143D58(), 444);
memcpy(svr->mevent_3120, GetSavedWonderNews(), 444);
break;
case 28:
AGB_ASSERT_EX(cmd->flag == FALSE && cmd->parameter == NULL, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/mevent_server.c", 517);
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -9,7 +9,7 @@ extern u8 gUnknown_203ADFA;
extern void sub_80CBDE8(void); // field_specials
extern u16 CalcCRC16WithTable(u8 *data, int length); // util
extern bool32 sub_8143FC8(void); // mevent
extern bool32 ValidateReceivedWonderCard(void); // mevent
enum
{
@@ -525,7 +525,7 @@ bool32 sub_8069DFC(void)
u8 *sub_8069E48(void)
{
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
if (!sub_8143FC8())
if (!ValidateReceivedWonderCard())
return NULL;
if (scriptData->magic != RAM_SCRIPT_MAGIC)
return NULL;
+460
View File
@@ -0,0 +1,460 @@
#include "global.h"
#include "gpu_regs.h"
#include "bg.h"
#include "palette.h"
#include "malloc.h"
#include "scanline_effect.h"
#include "battle_dome_cards.h"
#include "window.h"
#include "text_window.h"
#include "sound.h"
#include "task.h"
#include "help_system.h"
#include "overworld.h"
#include "event_data.h"
#include "field_fadetransition.h"
#include "field_weather.h"
#include "constants/songs.h"
#include "constants/maps.h"
#include "seagallop.h"
#define TILESTAG_FERRY 3000
#define TILESTAG_WAKE 4000
#define PALTAG_FERRY_WAKE 3000
static EWRAM_DATA void * sBg3TilemapBuffer = NULL;
static void CB2_SetUpSeaGallopScene(void);
static void VBlankCB_SeaGallop(void);
static void MainCB2_SeaGallop(void);
static void Task_SeaGallop_0(u8 taskId);
static void Task_SeaGallop_1(u8 taskId);
static void Task_SeaGallop_2(u8 taskId);
static void Task_SeaGallop_3(void);
static void ResetGPU(void);
static void ResetAllAssets(void);
static void SetDispcnt(void);
static void ResetBGPos(void);
static void LoadFerrySpriteResources(void);
static void FreeFerrySpriteResources(void);
static void CreateFerrySprite(void);
static void SpriteCB_Ferry(struct Sprite * sprite);
static void CreateWakeSprite(s16 x);
static void SpriteCB_Wake(struct Sprite * sprite);
static bool8 GetDirectionOfTravel(void);
static const u16 sWaterTiles[] = INCBIN_U16("data/seagallop/water.4bpp");
static const u16 sWaterPal[] = INCBIN_U16("data/seagallop/water.gbapal");
static const u16 sWaterTilemap_WB[] = INCBIN_U16("data/seagallop/wb_tilemap.bin");
static const u16 sWaterTilemap_EB[] = INCBIN_U16("data/seagallop/eb_tilemap.bin");
static const u16 sFerrySpriteTiles[] = INCBIN_U16("data/seagallop/ferry_sprite.4bpp");
static const u16 sFerryAndWakePal[] = INCBIN_U16("data/seagallop/ferry_and_wake.gbapal");
static const u16 sWakeSpriteTiles[] = INCBIN_U16("data/seagallop/wake.4bpp");
static const struct BgTemplate sBGTemplates[] = {
{
.bg = 3,
.charBaseIndex = 3,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0x000
}
};
static const s8 sSeaGallopSpawnTable[][4] = {
// Map X Y
[SEAGALLOP_VERMILION_CITY] = {MAP(VERMILIONCITY), 0x17, 0x20},
[SEAGALLOP_ONE_ISLAND] = {MAP(ONEISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_TWO_ISLAND] = {MAP(TWOISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_THREE_ISLAND] = {MAP(THREEISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_FOUR_ISLAND] = {MAP(FOURISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_FIVE_ISLAND] = {MAP(FIVEISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_SIX_ISLAND] = {MAP(SIXISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_SEVEN_ISLAND] = {MAP(SEVENISLAND_HARBOR), 0x08, 0x05},
[SEAGALLOP_CINNABAR_ISLAND] = {MAP(CINNABARISLAND), 0x15, 0x07},
[SEAGALLOP_NAVEL_ROCK] = {MAP(NAVELROCK_HARBOR), 0x08, 0x05},
[SEAGALLOP_BIRTH_ISLAND] = {MAP(BIRTHISLAND_HARBOR), 0x08, 0x05}
};
// Bitpacked array. In the commented section, right-most bit is the
// flag for traveling from (row port) to Vermilion City, and so on.
// Flags follow these enums:
enum TravelDirections
{
DIRN_WESTBOUND = 0,
DIRN_EASTBOUND = 1
};
static const u16 sTravelDirectionMatrix[] = {
[SEAGALLOP_VERMILION_CITY] = 0x6fe, // 11011111110
[SEAGALLOP_ONE_ISLAND] = 0x6fc, // 11011111100
[SEAGALLOP_TWO_ISLAND] = 0x6f8, // 11011111000
[SEAGALLOP_THREE_ISLAND] = 0x6f0, // 11011110000
[SEAGALLOP_FOUR_ISLAND] = 0x6e0, // 11011100000
[SEAGALLOP_FIVE_ISLAND] = 0x4c0, // 10011000000
[SEAGALLOP_SIX_ISLAND] = 0x400, // 10000000000
[SEAGALLOP_SEVEN_ISLAND] = 0x440, // 10001000000
[SEAGALLOP_CINNABAR_ISLAND] = 0x7ff, // 11111111111
[SEAGALLOP_NAVEL_ROCK] = 0x6e0, // 11011100000
[SEAGALLOP_BIRTH_ISLAND] = 0x000 // 00000000000
};
static const union AnimCmd sSpriteAnims_Ferry_WB[] = {
ANIMCMD_FRAME(0, 10),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnims_Ferry_EB[] = {
ANIMCMD_FRAME(0, 10, .hFlip = TRUE),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_Ferry[] = {
sSpriteAnims_Ferry_WB,
sSpriteAnims_Ferry_EB
};
static const struct OamData sOamData_Ferry = {
.size = 3
};
static const struct SpriteTemplate sFerrySpriteTemplate = {
TILESTAG_FERRY,
PALTAG_FERRY_WAKE,
&sOamData_Ferry,
sSpriteAnimTable_Ferry,
NULL,
gDummySpriteAffineAnimTable,
SpriteCB_Ferry
};
static const struct SpriteSheet sFerryAndWakeSpriteSheets[] = {
{(const void *)sWakeSpriteTiles, sizeof(sWakeSpriteTiles), TILESTAG_WAKE},
{(const void *)sFerrySpriteTiles, sizeof(sFerrySpriteTiles), TILESTAG_FERRY},
{}
};
static const struct SpritePalette sFerryAndWakeSpritePalettes[] = {
{sFerryAndWakePal, PALTAG_FERRY_WAKE},
{}
};
static const union AnimCmd sSpriteAnims_Wake_WB[] = {
ANIMCMD_FRAME(0x00, 0x14),
ANIMCMD_FRAME(0x10, 0x14),
ANIMCMD_FRAME(0x20, 0x0f),
ANIMCMD_END,
};
static const union AnimCmd sSpriteAnims_Wake_EB[] = {
ANIMCMD_FRAME(0x00, 0x14, .hFlip = TRUE),
ANIMCMD_FRAME(0x10, 0x14, .hFlip = TRUE),
ANIMCMD_FRAME(0x20, 0x0f, .hFlip = TRUE),
ANIMCMD_END,
};
static const union AnimCmd *const sSpriteAnimTable_Wake[] = {
sSpriteAnims_Wake_WB,
sSpriteAnims_Wake_EB
};
static const struct OamData sOamData_Wake = {
.size = 2
};
static const struct SpriteTemplate sWakeSpriteTemplate = {
TILESTAG_WAKE,
PALTAG_FERRY_WAKE,
&sOamData_Wake,
sSpriteAnimTable_Wake,
NULL,
gDummySpriteAffineAnimTable,
SpriteCB_Wake
};
void ScrSpecial_SeaGallopFerry(void)
{
SetVBlankCallback(NULL);
sub_812B478();
SetMainCallback2(CB2_SetUpSeaGallopScene);
}
static void CB2_SetUpSeaGallopScene(void)
{
void ** ptr;
switch (gMain.state)
{
case 0:
SetVBlankCallback(NULL); // redundant since the setup routine already did this
ResetGPU();
gMain.state++;
break;
case 1:
ResetAllAssets();
gMain.state++;
break;
case 2:
ptr = &sBg3TilemapBuffer;
*ptr = AllocZeroed(0x800);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sBGTemplates, NELEMS(sBGTemplates));
SetBgTilemapBuffer(3, *ptr);
ResetBGPos();
gMain.state++;
break;
case 3:
LoadBgTiles(3, sWaterTiles, sizeof(sWaterTiles), 0);
if (GetDirectionOfTravel() == DIRN_EASTBOUND)
{
CopyToBgTilemapBufferRect(3, sWaterTilemap_EB, 0, 0, 32, 32);
}
else
{
CopyToBgTilemapBufferRect(3, sWaterTilemap_WB, 0, 0, 32, 32);
}
LoadPalette(sWaterPal, 0x40, 0x20);
LoadPalette(stdpal_get(2), 0xF0, 0x20);
gMain.state++;
break;
case 4:
if (IsDma3ManagerBusyWithBgCopy() != DIRN_EASTBOUND)
{
ShowBg(0);
ShowBg(3);
CopyBgTilemapBufferToVram(3);
gMain.state++;
}
break;
case 5:
LoadFerrySpriteResources();
BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK);
gMain.state++;
break;
case 6:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
gMain.state++;
break;
case 7:
SetDispcnt();
SetVBlankCallback(VBlankCB_SeaGallop);
PlaySE(SE_NAMINORI);
CreateFerrySprite();
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
SetGpuReg(REG_OFFSET_WININ, 0x3F);
SetGpuReg(REG_OFFSET_WINOUT, 0x00);
SetGpuReg(REG_OFFSET_WIN0H, 0x00F0);
SetGpuReg(REG_OFFSET_WIN0V, 0x1888);
CreateTask(Task_SeaGallop_0, 8);
SetMainCallback2(MainCB2_SeaGallop);
gMain.state = 0;
break;
}
}
static void VBlankCB_SeaGallop(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
static void MainCB2_SeaGallop(void)
{
RunTasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
static void Task_SeaGallop_0(u8 taskId)
{
gTasks[taskId].func = Task_SeaGallop_1;
}
static void ScrollBG(void)
{
if (GetDirectionOfTravel() == DIRN_EASTBOUND)
{
ChangeBgX(3, 0x600, 1);
}
else
{
ChangeBgX(3, 0x600, 2);
}
}
static void Task_SeaGallop_1(u8 taskId)
{
struct Task * task = &gTasks[taskId];
ScrollBG();
if (++task->data[1] == 140)
{
Overworld_FadeOutMapMusic();
sub_807DC18();
task->func = Task_SeaGallop_2;
}
}
static void Task_SeaGallop_2(u8 taskId)
{
ScrollBG();
if (sub_8055FC4() && !gPaletteFade.active)
{
Task_SeaGallop_3();
sub_812B484();
DestroyTask(taskId);
}
}
static void Task_SeaGallop_3(void)
{
const s8 * warpInfo;
if (gSpecialVar_0x8006 >= NELEMS(sSeaGallopSpawnTable))
gSpecialVar_0x8006 = 0;
warpInfo = sSeaGallopSpawnTable[gSpecialVar_0x8006];
Overworld_SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]);
play_some_sound();
PlaySE(SE_KAIDAN);
gUnknown_3005020 = sub_807DF64;
warp_in();
SetMainCallback2(sub_805671C);
ResetInitialPlayerAvatarState();
FreeFerrySpriteResources();
Free(sBg3TilemapBuffer);
FreeAllWindowBuffers();
}
static void ResetGPU(void)
{
void * dest = (void *) VRAM;
DmaClearLarge16(3, dest, VRAM_SIZE, 0x1000);
DmaClear32(3, (void *)OAM, OAM_SIZE);
DmaClear16(3, (void *)PLTT, PLTT_SIZE);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1CNT, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG2CNT, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
SetGpuReg(REG_OFFSET_BG3CNT, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
}
static void ResetAllAssets(void)
{
ScanlineEffect_Stop();
ResetTasks();
ResetSpriteData();
dp13_810BB8C();
ResetPaletteFade();
FreeAllSpritePalettes();
}
static void SetDispcnt(void)
{
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON);
}
static void ResetBGPos(void)
{
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(2, 0, 0);
ChangeBgY(2, 0, 0);
ChangeBgX(3, 0, 0);
ChangeBgY(3, 0, 0);
}
static void LoadFerrySpriteResources(void)
{
LoadSpriteSheets(sFerryAndWakeSpriteSheets);
LoadSpritePalettes(sFerryAndWakeSpritePalettes);
}
static void FreeFerrySpriteResources(void)
{
FreeSpriteTilesByTag(TILESTAG_FERRY);
FreeSpriteTilesByTag(TILESTAG_WAKE);
FreeSpritePaletteByTag(PALTAG_FERRY_WAKE);
}
static void CreateFerrySprite(void)
{
u8 spriteId = CreateSprite(&sFerrySpriteTemplate, 0, 92, 0);
gSprites[spriteId].data[0] = 48;
if (GetDirectionOfTravel() == DIRN_EASTBOUND)
{
StartSpriteAnim(&gSprites[spriteId], 1);
}
else
{
gSprites[spriteId].pos1.x = 240;
gSprites[spriteId].data[0] *= -1;
}
}
static void SpriteCB_Ferry(struct Sprite * sprite)
{
sprite->data[1] += sprite->data[0];
sprite->pos2.x = sprite->data[1] >> 4;
if (sprite->data[2] % 5 == 0)
{
CreateWakeSprite(sprite->pos1.x + sprite->pos2.x);
}
sprite->data[2]++;
if ((u16)(300 + sprite->pos2.x) > 600)
{
DestroySprite(sprite);
}
}
static void CreateWakeSprite(s16 x)
{
u8 spriteId = CreateSprite(&sWakeSpriteTemplate, x, 92, 8);
if (spriteId != MAX_SPRITES)
{
if (GetDirectionOfTravel() == DIRN_EASTBOUND)
{
StartSpriteAnim(&gSprites[spriteId], 1);
}
}
}
static void SpriteCB_Wake(struct Sprite * sprite)
{
if (sprite->animEnded)
{
DestroySprite(sprite);
}
}
static bool8 GetDirectionOfTravel(void)
{
if (gSpecialVar_0x8004 >= NELEMS(sTravelDirectionMatrix))
{
return DIRN_EASTBOUND;
}
return (sTravelDirectionMatrix[gSpecialVar_0x8004] >> gSpecialVar_0x8006) & 1;
}
+1 -1
View File
@@ -5,13 +5,13 @@
#include "window.h"
#include "text.h"
#include "sprite.h"
#include "blit.h"
extern u8 gGlyphInfo[0x90];
extern u8 gUnknown_203ADFA;
extern u16 gTMCaseMainWindowPalette[];
extern const struct OamData gOamData_83AC9D0;
extern void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
extern void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height);
extern void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight);
extern u8 GetKeypadIconWidth(u8 keypadIconId);
+1 -5
View File
@@ -2,17 +2,13 @@
#include "window.h"
#include "malloc.h"
#include "bg.h"
#include "blit.h"
u8 gWindowClearTile;
void *gWindowBgTilemapBuffers[4];
EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0};
extern void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dest, u16 srcX, u16 srcY, u16 destX, u16 destY, u16 width, u16 height, u8 colorKey);
extern void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dest, u16 srcX, u16 srcY, u16 destX, u16 destY, u16 width, u16 height, u8 colorKey, u8 paletteNum);
extern void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
extern void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
static u8 GetNumActiveWindowsOnBg(u8 bgId);
static const struct WindowTemplate sDummyWindowTemplate = {0xFF, 0, 0, 0, 0, 0, 0};
+1 -3
View File
@@ -2,13 +2,11 @@
#include "window.h"
#include "malloc.h"
#include "bg.h"
#include "blit.h"
EWRAM_DATA static struct Window* sWindowPtr = NULL;
EWRAM_DATA static u16 sWindowSize = 0;
extern void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dest, u16 srcX, u16 srcY, u16 destX, u16 destY, u16 width, u16 height, u8 colorKey, u8 paletteNum);
extern void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
static u8 GetNumActiveWindowsOnBg8Bit(u8 bgId);
static void nullsub_9(void)