diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/alloc.h | 22 | ||||
-rw-r--r-- | include/bg.h | 85 | ||||
-rw-r--r-- | include/blit.h | 17 | ||||
-rw-r--r-- | include/dma3.h | 55 | ||||
-rw-r--r-- | include/gpu_regs.h | 19 | ||||
-rw-r--r-- | include/sprite.h | 319 | ||||
-rw-r--r-- | include/string_util.h | 46 | ||||
-rw-r--r-- | include/text.h | 297 | ||||
-rw-r--r-- | include/window.h | 78 |
9 files changed, 0 insertions, 938 deletions
diff --git a/include/alloc.h b/include/alloc.h deleted file mode 100644 index f2dcf6d46..000000000 --- a/include/alloc.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GUARD_ALLOC_H -#define GUARD_ALLOC_H - -#define HEAP_SIZE 0x1C000 -#define malloc Alloc -#define calloc(ct, sz) AllocZeroed((ct) * (sz)) -#define free Free - -#define FREE_AND_SET_NULL(ptr) \ -{ \ - free(ptr); \ - ptr = NULL; \ -} - -extern u8 gHeap[]; - -void *Alloc(u32 size); -void *AllocZeroed(u32 size); -void Free(void *pointer); -void InitHeap(void *pointer, u32 size); - -#endif // GUARD_ALLOC_H diff --git a/include/bg.h b/include/bg.h deleted file mode 100644 index 3c7eee292..000000000 --- a/include/bg.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef GUARD_BG_H -#define GUARD_BG_H - -struct BGCntrlBitfield // for the I/O registers -{ - volatile u16 priority:2; - volatile u16 charBaseBlock:2; - volatile u16 field_0_2:4; - volatile u16 field_1_0:5; - volatile u16 areaOverflowMode:1; - volatile u16 screenSize:2; -}; - -enum -{ - BG_ATTR_CHARBASEINDEX = 1, - BG_ATTR_MAPBASEINDEX, - BG_ATTR_SCREENSIZE, - BG_ATTR_PALETTEMODE, - BG_ATTR_MOSAIC, - BG_ATTR_WRAPAROUND, - BG_ATTR_PRIORITY, - BG_ATTR_METRIC, - BG_ATTR_TYPE, - BG_ATTR_BASETILE, -}; - -struct BgTemplate -{ - u16 bg:2; // 0x1, 0x2 -> 0x3 - u16 charBaseIndex:2; // 0x4, 0x8 -> 0xC - u16 mapBaseIndex:5; // 0x10, 0x20, 0x40, 0x80, 0x100 -> 0x1F0 - u16 screenSize:2; // 0x200, 0x400 -> 0x600 - u16 paletteMode:1; // 0x800 - u16 priority:2; // 0x1000, 0x2000 > 0x3000 - u16 baseTile:10; -}; - -void ResetBgs(void); -u8 GetBgMode(void); -void ResetBgControlStructs(void); -void Unused_ResetBgControlStruct(u8 bg); -u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode); -void SetTextModeAndHideBgs(void); -bool8 IsInvalidBg(u8 bg); -int DummiedOutFireRedLeafGreenTileAllocFunc(int a1, int a2, int a3, int a4); -void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable); -void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates); -void InitBgFromTemplate(const struct BgTemplate *template); -void SetBgMode(u8 bgMode); -u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset); -u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset); -u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset); -bool8 IsDma3ManagerBusyWithBgCopy(void); -void ShowBg(u8 bg); -void HideBg(u8 bg); -void SetBgAttribute(u8 bg, u8 attributeId, u8 value); -u16 GetBgAttribute(u8 bg, u8 attributeId); -s32 ChangeBgX(u8 bg, s32 value, u8 op); -s32 GetBgX(u8 bg); -s32 ChangeBgY(u8 bg, s32 value, u8 op); -s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op); -s32 GetBgY(u8 bg); -void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle); -u8 Unused_AdjustBgMosaic(u8 a1, u8 a2); -void SetBgTilemapBuffer(u8 bg, void *tilemap); -void UnsetBgTilemapBuffer(u8 bg); -void* GetBgTilemapBuffer(u8 bg); -void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset); -void CopyBgTilemapBufferToVram(u8 bg); -void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height); -void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette); -void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset); -void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height); -void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette); -void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta); -u16 GetBgMetricTextMode(u8 bg, u8 whichMetric); -u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric); -u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 screenHeight); -void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2); -u32 GetBgType(u8 bg); -bool32 IsInvalidBg32(u8 bg); -bool32 IsTileMapOutsideWram(u8 bg); - -#endif // GUARD_BG_H diff --git a/include/blit.h b/include/blit.h deleted file mode 100644 index 78f67766e..000000000 --- a/include/blit.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GUARD_BLIT_H -#define GUARD_BLIT_H - -struct Bitmap -{ - u8 *pixels; - u32 width:16; - u32 height:16; -}; - -void BlitBitmapRect4BitWithoutColorKey(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height); -void BlitBitmapRect4Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey); -void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 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); -void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue); - -#endif // GUARD_BLIT_H diff --git a/include/dma3.h b/include/dma3.h deleted file mode 100644 index 8eff34f55..000000000 --- a/include/dma3.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef GUARD_DMA3_H -#define GUARD_DMA3_H - -// Maximum amount of data we will transfer in one operation -#define MAX_DMA_BLOCK_SIZE 0x1000 - -#define Dma3CopyLarge_(src, dest, size, bit) \ -{ \ - const void *_src = src; \ - void *_dest = dest; \ - u32 _size = size; \ - while (1) \ - { \ - if (_size <= MAX_DMA_BLOCK_SIZE) \ - { \ - DmaCopy##bit(3, _src, _dest, _size); \ - break; \ - } \ - DmaCopy##bit(3, _src, _dest, MAX_DMA_BLOCK_SIZE); \ - _src += MAX_DMA_BLOCK_SIZE; \ - _dest += MAX_DMA_BLOCK_SIZE; \ - _size -= MAX_DMA_BLOCK_SIZE; \ - } \ -} - -#define Dma3CopyLarge16_(src, dest, size) Dma3CopyLarge_(src, dest, size, 16) -#define Dma3CopyLarge32_(src, dest, size) Dma3CopyLarge_(src, dest, size, 32) - -#define Dma3FillLarge_(value, dest, size, bit) \ -{ \ - void *_dest = dest; \ - u32 _size = size; \ - while (1) \ - { \ - if (_size <= MAX_DMA_BLOCK_SIZE) \ - { \ - DmaFill##bit(3, value, _dest, _size); \ - break; \ - } \ - DmaFill##bit(3, value, _dest, MAX_DMA_BLOCK_SIZE); \ - _dest += MAX_DMA_BLOCK_SIZE; \ - _size -= MAX_DMA_BLOCK_SIZE; \ - } \ -} - -#define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16) -#define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32) - -void ClearDma3Requests(void); -void ProcessDma3Requests(void); -s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode); -s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode); -s16 CheckForSpaceForDma3Request(s16 index); - -#endif // GUARD_DMA3_H diff --git a/include/gpu_regs.h b/include/gpu_regs.h deleted file mode 100644 index 89e0cb64b..000000000 --- a/include/gpu_regs.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef GUARD_GPU_REGS_H -#define GUARD_GPU_REGS_H - -// Exported type declarations - -// Exported RAM declarations - -// Exported ROM declarations -void InitGpuRegManager(void); -void CopyBufferedValuesToGpuRegs(void); -void SetGpuReg(u8 regOffset, u16 value); -void SetGpuReg_ForcedBlank(u8 regOffset, u16 value); -u16 GetGpuReg(u8 regOffset); -void SetGpuRegBits(u8 regOffset, u16 mask); -void ClearGpuRegBits(u8 regOffset, u16 mask); -void EnableInterrupts(u16 mask); -void DisableInterrupts(u16 mask); - -#endif //GUARD_GPU_REGS_H diff --git a/include/sprite.h b/include/sprite.h deleted file mode 100644 index 9753837fd..000000000 --- a/include/sprite.h +++ /dev/null @@ -1,319 +0,0 @@ -#ifndef GUARD_SPRITE_H -#define GUARD_SPRITE_H - -#define MAX_SPRITES 64 -#define SPRITE_INVALID_TAG 0xFFFF - -struct SpriteSheet -{ - const void *data; // Raw uncompressed pixel data - u16 size; - u16 tag; -}; - -struct CompressedSpriteSheet -{ - const u32 *data; // LZ77 compressed pixel data - u16 size; // Uncompressed size of pixel data - u16 tag; -}; - -struct SpriteFrameImage -{ - const void *data; - u16 size; -}; - -#define obj_frame_tiles(ptr) {.data = (u8 *)ptr, .size = sizeof ptr} - -#define overworld_frame(ptr, width, height, frame) {.data = (u8 *)ptr + (width * height * frame * 64)/2, .size = (width * height * 64)/2} - -struct SpritePalette -{ - const u16 *data; // Raw uncompressed palette data - u16 tag; -}; - -struct CompressedSpritePalette -{ - const u32 *data; // LZ77 compressed palette data - u16 tag; -}; - -struct AnimFrameCmd -{ - // If the sprite has an array of images, this is the array index. - // If the sprite has a sheet, this is the tile offset. - u32 imageValue:16; - - u32 duration:6; - u32 hFlip:1; - u32 vFlip:1; -}; - -struct AnimLoopCmd -{ - u32 type:16; - u32 count:6; -}; - -struct AnimJumpCmd -{ - u32 type:16; - u32 target:6; -}; - -// The first halfword of this union specifies the type of command. -// If it -2, then it is a jump command. If it is -1, then it is the end of the script. -// Otherwise, it is the imageValue for a frame command. -union AnimCmd -{ - s16 type; - struct AnimFrameCmd frame; - struct AnimLoopCmd loop; - struct AnimJumpCmd jump; -}; - -#define ANIMCMD_FRAME(...) \ - {.frame = {__VA_ARGS__}} -#define ANIMCMD_LOOP(_count) \ - {.loop = {.type = -3, .count = _count}} -#define ANIMCMD_JUMP(_target) \ - {.jump = {.type = -2, .target = _target}} -#define ANIMCMD_END \ - {.type = -1} - -struct AffineAnimFrameCmd -{ - s16 xScale; - s16 yScale; - u8 rotation; - u8 duration; -}; - -struct AffineAnimLoopCmd -{ - s16 type; - s16 count; -}; - -struct AffineAnimJumpCmd -{ - s16 type; - u16 target; -}; - -struct AffineAnimEndCmdAlt -{ - s16 type; - u16 val; -}; - -union AffineAnimCmd -{ - s16 type; - struct AffineAnimFrameCmd frame; - struct AffineAnimLoopCmd loop; - struct AffineAnimJumpCmd jump; - struct AffineAnimEndCmdAlt end; // unused in code -}; - -#define AFFINEANIMCMDTYPE_LOOP 0x7FFD -#define AFFINEANIMCMDTYPE_JUMP 0x7FFE -#define AFFINEANIMCMDTYPE_END 0x7FFF - -#define AFFINEANIMCMD_FRAME(_xScale, _yScale, _rotation, _duration) \ - {.frame = {.xScale = _xScale, .yScale = _yScale, .rotation = _rotation, .duration = _duration}} -#define AFFINEANIMCMD_LOOP(_count) \ - {.loop = {.type = AFFINEANIMCMDTYPE_LOOP, .count = _count}} -#define AFFINEANIMCMD_JUMP(_target) \ - {.jump = {.type = AFFINEANIMCMDTYPE_JUMP, .target = _target}} -#define AFFINEANIMCMD_END \ - {.type = AFFINEANIMCMDTYPE_END} -#define AFFINEANIMCMD_END_ALT(_val) \ - {.end = {.type = AFFINEANIMCMDTYPE_END, .val = _val}} - -struct AffineAnimState -{ - u8 animNum; - u8 animCmdIndex; - u8 delayCounter; - u8 loopCounter; - s16 xScale; - s16 yScale; - u16 rotation; -}; - -enum -{ - SUBSPRITES_OFF, - SUBSPRITES_ON, - SUBSPRITES_IGNORE_PRIORITY, // on but priority is ignored -}; - -struct Subsprite -{ - s8 x; // was u16 in R/S - s8 y; // was u16 in R/S - u16 shape:2; - u16 size:2; - u16 tileOffset:10; - u16 priority:2; -}; - -struct SubspriteTable -{ - u8 subspriteCount; - const struct Subsprite *subsprites; -}; - -struct Sprite; - -typedef void (*SpriteCallback)(struct Sprite *); - -struct SpriteTemplate -{ - u16 tileTag; - u16 paletteTag; - const struct OamData *oam; - const union AnimCmd *const *anims; - const struct SpriteFrameImage *images; - const union AffineAnimCmd *const *affineAnims; - SpriteCallback callback; -}; - -struct Sprite -{ - /*0x00*/ struct OamData oam; - /*0x08*/ const union AnimCmd *const *anims; - /*0x0C*/ const struct SpriteFrameImage *images; - /*0x10*/ const union AffineAnimCmd *const *affineAnims; - /*0x14*/ const struct SpriteTemplate *template; - /*0x18*/ const struct SubspriteTable *subspriteTables; - /*0x1C*/ SpriteCallback callback; - - /*0x20*/ struct Coords16 pos1; - /*0x24*/ struct Coords16 pos2; - /*0x28*/ s8 centerToCornerVecX; - /*0x29*/ s8 centerToCornerVecY; - - /*0x2A*/ u8 animNum; - /*0x2B*/ u8 animCmdIndex; - /*0x2C*/ u8 animDelayCounter:6; - bool8 animPaused:1; - bool8 affineAnimPaused:1; - /*0x2D*/ u8 animLoopCounter; - - // general purpose data fields - /*0x2E*/ s16 data[8]; - - /*0x3E*/ bool16 inUse:1; //1 - bool16 coordOffsetEnabled:1; //2 - bool16 invisible:1; //4 - bool16 flags_3:1; //8 - bool16 flags_4:1; //0x10 - bool16 flags_5:1; //0x20 - bool16 flags_6:1; //0x40 - bool16 flags_7:1; //0x80 - /*0x3F*/ bool16 hFlip:1; //1 - bool16 vFlip:1; //2 - bool16 animBeginning:1; //4 - bool16 affineAnimBeginning:1; //8 - bool16 animEnded:1; //0x10 - bool16 affineAnimEnded:1; //0x20 - bool16 usingSheet:1; //0x40 - bool16 flags_f:1; //0x80 - - /*0x40*/ u16 sheetTileStart; - - /*0x42*/ u8 subspriteTableNum:6; - u8 subspriteMode:2; - - /*0x43*/ u8 subpriority; -}; - -struct OamMatrix -{ - s16 a; - s16 b; - s16 c; - s16 d; -}; - -extern const struct OamData gDummyOamData; -extern const union AnimCmd *const gDummySpriteAnimTable[]; -extern const union AffineAnimCmd *const gDummySpriteAffineAnimTable[]; -extern const struct SpriteTemplate gDummySpriteTemplate; - -extern u8 gReservedSpritePaletteCount; -extern struct Sprite gSprites[]; -extern u8 gOamLimit; -extern u16 gReservedSpriteTileCount; -extern s16 gSpriteCoordOffsetX; -extern s16 gSpriteCoordOffsetY; -extern struct OamMatrix gOamMatrices[]; -extern bool8 gAffineAnimsDisabled; - -void ResetSpriteData(void); -void AnimateSprites(void); -void BuildOamBuffer(void); -u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); -u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); -u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)); -u8 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); -void DestroySprite(struct Sprite *sprite); -void ResetOamRange(u8 a, u8 b); -void LoadOam(void); -void SetOamMatrix(u8 matrixNum, u16 a, u16 b, u16 c, u16 d); -void CalcCenterToCornerVec(struct Sprite *sprite, u8 shape, u8 size, u8 affineMode); -void SpriteCallbackDummy(struct Sprite *sprite); -void ProcessSpriteCopyRequests(void); -void RequestSpriteCopy(const u8 *src, u8 *dest, u16 size); -void FreeSpriteTiles(struct Sprite *sprite); -void FreeSpritePalette(struct Sprite *sprite); -void FreeSpriteOamMatrix(struct Sprite *sprite); -void DestroySpriteAndFreeResources(struct Sprite *sprite); -void sub_800142C(u32 a1, u32 a2, u16 *a3, u16 a4, u32 a5); -void AnimateSprite(struct Sprite *sprite); -void sub_8007E18(struct Sprite* sprite, s16 a2, s16 a3); -void StartSpriteAnim(struct Sprite *sprite, u8 animNum); -void StartSpriteAnimIfDifferent(struct Sprite *sprite, u8 animNum); -void SeekSpriteAnim(struct Sprite *sprite, u8 animCmdIndex); -void StartSpriteAffineAnim(struct Sprite *sprite, u8 animNum); -void StartSpriteAffineAnimIfDifferent(struct Sprite *sprite, u8 animNum); -void ChangeSpriteAffineAnim(struct Sprite *sprite, u8 animNum); -void ChangeSpriteAffineAnimIfDifferent(struct Sprite *sprite, u8 animNum); -void SetSpriteSheetFrameTileNum(struct Sprite *sprite); -u8 AllocOamMatrix(void); -void FreeOamMatrix(u8 matrixNum); -void InitSpriteAffineAnim(struct Sprite *sprite); -void SetOamMatrixRotationScaling(u8 matrixNum, s16 xScale, s16 yScale, u16 rotation); -u16 LoadSpriteSheet(const struct SpriteSheet *sheet); -void LoadSpriteSheets(const struct SpriteSheet *sheets); -u16 AllocTilesForSpriteSheet(struct SpriteSheet *sheet); -void AllocTilesForSpriteSheets(struct SpriteSheet *sheets); -void LoadTilesForSpriteSheet(const struct SpriteSheet *sheet); -void LoadTilesForSpriteSheets(struct SpriteSheet *sheets); -void FreeSpriteTilesByTag(u16 tag); -void FreeSpriteTileRanges(void); -u16 GetSpriteTileStartByTag(u16 tag); -u16 GetSpriteTileTagByTileStart(u16 start); -void RequestSpriteSheetCopy(const struct SpriteSheet *sheet); -u16 LoadSpriteSheetDeferred(const struct SpriteSheet *sheet); -void FreeAllSpritePalettes(void); -u8 LoadSpritePalette(const struct SpritePalette *palette); -void LoadSpritePalettes(const struct SpritePalette *palettes); -u8 AllocSpritePalette(u16 tag); -u8 IndexOfSpritePaletteTag(u16 tag); -u16 GetSpritePaletteTagByPaletteNum(u8 paletteNum); -void FreeSpritePaletteByTag(u16 tag); -void SetSubspriteTables(struct Sprite *sprite, const struct SubspriteTable *subspriteTables); -bool8 AddSpriteToOamBuffer(struct Sprite *object, u8 *oamIndex); -bool8 AddSubspritesToOamBuffer(struct Sprite *sprite, struct OamData *destOam, u8 *oamIndex); -void CopyToSprites(u8 *src); -void CopyFromSprites(u8 *dest); -u8 SpriteTileAllocBitmapOp(u16 bit, u8 op); -void ClearSpriteCopyRequests(void); -void ResetAffineAnimData(void); - -#endif //GUARD_SPRITE_H diff --git a/include/string_util.h b/include/string_util.h deleted file mode 100644 index b921d2391..000000000 --- a/include/string_util.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef GUARD_STRING_UTIL_H -#define GUARD_STRING_UTIL_H - -extern u8 gStringVar1[]; -extern u8 gStringVar2[]; -extern u8 gStringVar3[]; -extern u8 gStringVar4[]; - -enum StringConvertMode -{ - STR_CONV_MODE_LEFT_ALIGN, - STR_CONV_MODE_RIGHT_ALIGN, - STR_CONV_MODE_LEADING_ZEROS -}; - -u8 *StringCopy10(u8 *dest, const u8 *src); -u8 *StringGetEnd10(u8 *str); -u8 *StringCopy7(u8 *dest, const u8 *src); -u8 *StringCopy(u8 *dest, const u8 *src); -u8 *StringAppend(u8 *dest, const u8 *src); -u8 *StringCopyN(u8 *dest, const u8 *src, u8 n); -u8 *StringAppendN(u8 *dest, const u8 *src, u8 n); -u16 StringLength(const u8 *str); -s32 StringCompare(const u8 *str1, const u8 *str2); -s32 StringCompareN(const u8 *str1, const u8 *str2, u32 n); -bool8 IsStringLengthAtLeast(const u8 *str, s32 n); -u8 *ConvertIntToDecimalStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 n); -u8 *ConvertUIntToDecimalStringN(u8 *dest, u32 value, enum StringConvertMode mode, u8 n); -u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 n); -u8 *StringExpandPlaceholders(u8 *dest, const u8 *src); -u8 *StringBraille(u8 *dest, const u8 *src); -const u8 *GetExpandedPlaceholder(u32 id); -u8 *StringFill(u8 *dest, u8 c, u16 n); -u8 *StringCopyPadded(u8 *dest, const u8 *src, u8 c, u16 n); -u8 *StringFillWithTerminator(u8 *dest, u16 n); -u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n); -u32 StringLength_Multibyte(const u8 *str); -u8 *WriteColorChangeControlCode(u8 *dest, u32 colorType, u8 color); -bool32 IsStringJapanese(u8 *str); -bool32 sub_800924C(u8 *str, s32 n); -u8 GetExtCtrlCodeLength(u8 code); -s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2); -void ConvertInternationalString(u8 *s, u8 language); -void StripExtCtrlCodes(u8 *str); - -#endif // GUARD_STRING_UTIL_H diff --git a/include/text.h b/include/text.h deleted file mode 100644 index d3ff663bb..000000000 --- a/include/text.h +++ /dev/null @@ -1,297 +0,0 @@ -#ifndef GUARD_TEXT_H -#define GUARD_TEXT_H - -#define CHAR_SPACE 0x00 -#define CHAR_PLUS 0x2E -#define CHAR_0 0xA1 -#define CHAR_1 0xA2 -#define CHAR_2 0xA3 -#define CHAR_3 0xA4 -#define CHAR_4 0xA5 -#define CHAR_5 0xA6 -#define CHAR_6 0xA7 -#define CHAR_7 0xA8 -#define CHAR_8 0xA9 -#define CHAR_9 0xAA -#define CHAR_EXCL_MARK 0xAB -#define CHAR_QUESTION_MARK 0xAC -#define CHAR_PERIOD 0xAD -#define CHAR_HYPHEN 0xAE -#define CHAR_ELLIPSIS 0xB0 -#define CHAR_DBL_QUOT_LEFT 0xB1 -#define CHAR_DBL_QUOT_RIGHT 0xB2 -#define CHAR_SGL_QUOT_LEFT 0xB3 -#define CHAR_SGL_QUOT_RIGHT 0xB4 -#define CHAR_MALE 0xB5 -#define CHAR_FEMALE 0xB6 -#define CHAR_CURRENCY 0xB7 -#define CHAR_COMMA 0xB8 -#define CHAR_MULT_SIGN 0xB9 -#define CHAR_SLASH 0xBA -#define CHAR_A 0xBB -#define CHAR_B 0xBC -#define CHAR_C 0xBD -#define CHAR_D 0xBE -#define CHAR_E 0xBF -#define CHAR_F 0xC0 -#define CHAR_G 0xC1 -#define CHAR_H 0xC2 -#define CHAR_I 0xC3 -#define CHAR_J 0xC4 -#define CHAR_K 0xC5 -#define CHAR_L 0xC6 -#define CHAR_M 0xC7 -#define CHAR_N 0xC8 -#define CHAR_O 0xC9 -#define CHAR_P 0xCA -#define CHAR_Q 0xCB -#define CHAR_R 0xCC -#define CHAR_S 0xCD -#define CHAR_T 0xCE -#define CHAR_U 0xCF -#define CHAR_V 0xD0 -#define CHAR_W 0xD1 -#define CHAR_X 0xD2 -#define CHAR_Y 0xD3 -#define CHAR_Z 0xD4 -#define CHAR_a 0xD5 -#define CHAR_b 0xD6 -#define CHAR_c 0xD7 -#define CHAR_d 0xD8 -#define CHAR_e 0xD9 -#define CHAR_f 0xDA -#define CHAR_g 0xDB -#define CHAR_h 0xDC -#define CHAR_i 0xDD -#define CHAR_j 0xDE -#define CHAR_k 0xDF -#define CHAR_l 0xE0 -#define CHAR_m 0xE1 -#define CHAR_n 0xE2 -#define CHAR_o 0xE3 -#define CHAR_p 0xE4 -#define CHAR_q 0xE5 -#define CHAR_r 0xE6 -#define CHAR_s 0xE7 -#define CHAR_t 0xE8 -#define CHAR_u 0xE9 -#define CHAR_v 0xEA -#define CHAR_w 0xEB -#define CHAR_x 0xEC -#define CHAR_y 0xED -#define CHAR_z 0xEE -#define CHAR_SPECIAL_F7 0xF7 -#define CHAR_SPECIAL_F8 0xF8 -#define CHAR_SPECIAL_F9 0xF9 -#define CHAR_COLON 0xF0 -#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog -#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog -#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code -#define PLACEHOLDER_BEGIN 0xFD // string placeholder -#define CHAR_NEWLINE 0xFE -#define EOS 0xFF // end of string - -#define EXT_CTRL_CODE_COLOR 0x1 -#define EXT_CTRL_CODE_HIGHLIGHT 0x2 -#define EXT_CTRL_CODE_SHADOW 0x3 -// -#define EXT_CTRL_CODE_UNKNOWN_7 0x7 -// -#define EXT_CTRL_CODE_CLEAR 0x11 -// -#define EXT_CTRL_CODE_CLEAR_TO 0x13 -#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14 -#define EXT_CTRL_CODE_JPN 0x15 -#define EXT_CTRL_CODE_ENG 0x16 - -#define TEXT_COLOR_TRANSPARENT 0x0 -#define TEXT_COLOR_WHITE 0x1 -#define TEXT_COLOR_DARK_GREY 0x2 -// 0x3 -#define TEXT_COLOR_RED 0x4 -// 0x5 -#define TEXT_COLOR_GREEN 0x6 -// 0x7 -#define TEXT_COLOR_BLUE 0x8 - -// battle placeholders are located in battle_message.h - -#define NUM_TEXT_PRINTERS 32 - -#define TEXT_SPEED_FF 0xFF - -enum -{ - FONTATTR_MAX_LETTER_WIDTH, - FONTATTR_MAX_LETTER_HEIGHT, - FONTATTR_LETTER_SPACING, - FONTATTR_LINE_SPACING, - FONTATTR_UNKNOWN, // dunno what this is yet - FONTATTR_COLOR_FOREGROUND, - FONTATTR_COLOR_BACKGROUND, - FONTATTR_COLOR_SHADOW -}; - -struct TextPrinterSubStruct -{ - u8 glyphId:4; // 0x14 - bool8 hasPrintBeenSpedUp:1; - u8 unk:3; - u8 downArrowDelay:5; - u8 downArrowYPosIdx:2; - bool8 hasGlyphIdBeenSet:1; - u8 autoScrollDelay; -}; - -struct TextPrinterTemplate -{ - const u8* currentChar; - u8 windowId; - u8 fontId; - u8 x; - u8 y; - u8 currentX; // 0x8 - u8 currentY; - u8 letterSpacing; - u8 lineSpacing; - u8 unk:4; // 0xC - u8 fgColor:4; - u8 bgColor:4; - u8 shadowColor:4; -}; - -struct TextPrinter -{ - struct TextPrinterTemplate printerTemplate; - - void (*callback)(struct TextPrinterTemplate *, u16); // 0x10 - - union -#if !MODERN - __attribute__((packed)) -#endif - { - struct TextPrinterSubStruct sub; - u8 fields[7]; - } subUnion; - - u8 active; - u8 state; // 0x1C - u8 textSpeed; - u8 delayCounter; - u8 scrollDistance; - u8 minLetterSpacing; // 0x20 - u8 japanese; -}; - -struct FontInfo -{ - u16 (*fontFunction)(struct TextPrinter *x); - u8 maxLetterWidth; - u8 maxLetterHeight; - u8 letterSpacing; - u8 lineSpacing; - u8 unk:4; - u8 fgColor:4; - u8 bgColor:4; - u8 shadowColor:4; -}; - -extern const struct FontInfo *gFonts; - -struct GlyphWidthFunc -{ - u32 fontId; - u32 (*func)(u16 glyphId, bool32 isJapanese); -}; - -struct KeypadIcon -{ - u16 tileOffset; - u8 width; - u8 height; -}; - -typedef struct { - bool8 canABSpeedUpPrint:1; - bool8 useAlternateDownArrow:1; - bool8 autoScroll:1; - bool8 forceMidTextSpeed:1; -} TextFlags; - -struct Struct_03002F90 -{ - u32 unk0[8]; - u32 unk20[8]; - u32 unk40[8]; - u32 unk60[8]; - u8 unk80; - u8 unk81; -}; - -extern TextFlags gTextFlags; - -extern u8 gUnknown_03002F84; -extern struct Struct_03002F90 gUnknown_03002F90; - -void SetFontsPointer(const struct FontInfo *fonts); -void DeactivateAllTextPrinters(void); -u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); -bool16 AddTextPrinter(struct TextPrinterTemplate *template, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); -void RunTextPrinters(void); -bool16 IsTextPrinterActive(u8 id); -u32 RenderFont(struct TextPrinter *textPrinter); -void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor); -void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor); -void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor); -void DecompressGlyphTile(const void *src_, void *dest_); -u8 GetLastTextColor(u8 colorType); -void CopyGlyphToWindow(struct TextPrinter *x); -void ClearTextSpan(struct TextPrinter *textPrinter, u32 width); -u8 GetMenuCursorDimensionByFont(u8, u8); - -u16 Font0Func(struct TextPrinter *textPrinter); -u16 Font1Func(struct TextPrinter *textPrinter); -u16 Font2Func(struct TextPrinter *textPrinter); -u16 Font3Func(struct TextPrinter *textPrinter); -u16 Font4Func(struct TextPrinter *textPrinter); -u16 Font5Func(struct TextPrinter *textPrinter); -u16 Font7Func(struct TextPrinter *textPrinter); -u16 Font8Func(struct TextPrinter *textPrinter); - -void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter); -void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter); -void TextPrinterClearDownArrow(struct TextPrinter *textPrinter); -bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter); -bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); -bool16 TextPrinterWait(struct TextPrinter *textPrinter); -void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex); -u16 RenderText(struct TextPrinter *textPrinter); -u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing); -u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32); -s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing); -u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str); -u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y); -u8 GetKeypadIconTileOffset(u8 keypadIconId); -u8 GetKeypadIconWidth(u8 keypadIconId); -u8 GetKeypadIconHeight(u8 keypadIconId); -void SetDefaultFontsPointer(void); -u8 GetFontAttribute(u8 fontId, u8 attributeId); -u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension); -void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont7(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont8(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont9(u16 glyphId); - -// unk_text_util_2.c -u16 Font6Func(struct TextPrinter *textPrinter); -u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese); - -#endif // GUARD_TEXT_H diff --git a/include/window.h b/include/window.h deleted file mode 100644 index 10e447789..000000000 --- a/include/window.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef GUARD_WINDOW_H -#define GUARD_WINDOW_H - -#define PIXEL_FILL(num) ((num) | ((num) << 4)) - -enum -{ - WINDOW_BG, - WINDOW_TILEMAP_LEFT, - WINDOW_TILEMAP_TOP, - WINDOW_WIDTH, - WINDOW_HEIGHT, - WINDOW_PALETTE_NUM, - WINDOW_BASE_BLOCK, - WINDOW_TILE_DATA -}; - -struct WindowTemplate -{ - u8 bg; - u8 tilemapLeft; - u8 tilemapTop; - u8 width; - u8 height; - u8 paletteNum; - u16 baseBlock; -}; - -#define DUMMY_WIN_TEMPLATE \ -{ \ - 0xFF, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ -} - -struct Window -{ - struct WindowTemplate window; - u8 *tileData; -}; - -bool16 InitWindows(const struct WindowTemplate *templates); -u16 AddWindow(const struct WindowTemplate *template); -int AddWindowWithoutTileMap(const struct WindowTemplate *template); -void RemoveWindow(u8 windowId); -void FreeAllWindowBuffers(void); -void CopyWindowToVram(u8 windowId, u8 mode); -void CopyWindowRectToVram(u32 windowId, u32 mode, u32 x, u32 y, u32 w, u32 h); -void PutWindowTilemap(u8 windowId); -void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette); -void ClearWindowTilemap(u8 windowId); -void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height); -void BlitBitmapToWindow(u8 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height); -void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight); -void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); -void CopyToWindowPixelBuffer(u8 windowId, const void *src, u16 size, u16 tileOffset); -void FillWindowPixelBuffer(u8 windowId, u8 fillValue); -void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue); -void CallWindowFunction(u8 windowId, void ( *func)(u8, u8, u8, u8, u8, u8)); -bool8 SetWindowAttribute(u8 windowId, u8 attributeId, u32 value); -u32 GetWindowAttribute(u8 windowId, u8 attributeId); -u16 AddWindow8Bit(const struct WindowTemplate *template); -void FillWindowPixelBuffer8Bit(u8 windowId, u8 fillValue); -void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); -void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum); -void CopyWindowToVram8Bit(u8 windowId, u8 mode); - -extern struct Window gWindows[]; -extern void* gUnknown_03002F70[]; -extern u32 filler_03002F58; -extern u32 filler_03002F5C; -extern u32 filler_03002F64; - -#endif // GUARD_WINDOW_H |