Merge branch 'master' into battle_engine_v2

This commit is contained in:
DizzyEggg 2019-03-01 13:29:50 +01:00
commit bfe95bc4b9
20 changed files with 1622 additions and 1509 deletions

View File

@ -1163,12 +1163,12 @@
.endm
@ Changes the metatile at (x, y) on the current map.
.macro setmetatile x:req, y:req, metatile_number:req, tile_attrib:req
.macro setmetatile x:req, y:req, metatile_number:req, has_collision:req
.byte 0xa2
.2byte \x
.2byte \y
.2byte \metatile_number
.2byte \tile_attrib
.2byte \has_collision
.endm
@ Queues a weather change to the default weather for the map.

176
data/slot_machine.s Normal file → Executable file
View File

@ -10,7 +10,7 @@ gUnknown_085A7A3C:: @ 85A7A3C
.2byte 0
.2byte 0
.2byte 0
gUnknown_085A7A44:: @ 85A7A44
.2byte 0x8000
.2byte 0
@ -22,13 +22,13 @@ gUnknown_085A7A4C:: @ 85A7A4C
.2byte 0x4000
.2byte 0
.2byte 0
gUnknown_085A7A54:: @ 85A7A54
.2byte 0x8000
.2byte 0x8000
.2byte 0
.2byte 0
gUnknown_085A7A5C:: @ 85A7A5C
.2byte 0
.2byte 0x8000
@ -40,7 +40,7 @@ gUnknown_085A7A64:: @ 85A7A64
.2byte 0xC000
.2byte 0
.2byte 0
gUnknown_085A7A6C:: @ 85A7A6C
.2byte 0x4000
.2byte 0xC000
@ -95,7 +95,7 @@ gUnknown_085A7ACC:: @ 85A7ACC
.4byte gSlotMachineReelTimePikaAura
.2byte 0x400
.2byte 0
gUnknown_085A7AD4:: @ 85A7CD4
.4byte gSlotMachineReelTimeExplosion0
.2byte 0x200
@ -111,7 +111,7 @@ gUnknown_085A7AE4:: @ 85A7AE4
gUnknown_085A7AEC:: @ 85A7AEC
.4byte gSlotMachineReelTimeSmoke
.4byte 0x80
gUnknown_085A7AF4:: @ 85A7AF4
.4byte gSlotMachineReelTimeBolt
.4byte 32
@ -123,7 +123,7 @@ gUnknown_085A7AFC:: @ 85A7AFC
gUnknown_085A7B04:: @ 85A7B04
obj_image_anim_frame 0, 1
obj_image_anim_jump 0
gUnknown_085A7B0C:: @ 85A7B0C
obj_image_anim_frame 0, 16
obj_image_anim_end
@ -258,18 +258,18 @@ gUnknown_085A7C30:: @ 85A7C30
gUnknown_085A7C34:: @ 85A7C34
.4byte gUnknown_085A7B88
gUnknown_085A7C38:: @ 85A7C38
.4byte gUnknown_085A7B94
.4byte gUnknown_085A7BA0
gUnknown_085A7C40:: @ 85A7C40
.4byte gUnknown_085A7BA8
gUnknown_085A7C44:: @ 85A7C44
.4byte gUnknown_085A7BB4
.4byte gUnknown_085A7BC8
gUnknown_085A7C4C:: @ 85A7C4C
.4byte gUnknown_085A7BD0
.4byte gUnknown_085A7BD8
@ -283,7 +283,7 @@ gUnknown_085A7C60:: @ 85A7C60
obj_rot_scal_anim_frame 1, 1, 0, 1
obj_rot_scal_anim_loop 0xFF
obj_rot_scal_anim_end
gUnknown_085A7C88:: @ 85A7C88
.4byte gUnknown_085A7C60
@ -301,7 +301,7 @@ gUnknown_085A7C8C:: @ 85A7C8C
gUnknown_085A7CDC:: @ 85A7CDC
.4byte gUnknown_085A7C8C
gSpriteTemplate_83ED414:: @ 85A7CE0
spr_template 0, 0, gUnknown_085A7A5C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, sub_8104F18
@ -346,52 +346,52 @@ gSpriteTemplate_83ED54C:: @ 85A7E18
gSpriteTemplate_83ED564:: @ 85A7E30
spr_template 0xFFFF, 4, gUnknown_085A7A4C, gUnknown_085A7BF8, gUnknown_085A7AEC, gUnknown_085A7C88, sub_8105A38
gUnknown_085A7E48:: @ 85A7E48
spr_template 0xFFFF, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7E60:: @ 85A7E60
spr_template 0xFFFF, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7E78:: @ 85A7E78
spr_template 0xFFFF, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7E90:: @ 85A7E90
spr_template 18, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7EA8:: @ 85A7EA8
spr_template 0xFFFF, 6, gUnknown_085A7A6C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7EC0:: @ 85A7EC0
spr_template 0xFFFF, 6, gUnknown_085A7A6C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7ED8:: @ 85A7ED8
spr_template 19, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7EF0:: @ 85A7EF0
spr_template 20, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7F08:: @ 85A7F08
spr_template 21, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7F20:: @ 85A7F20
spr_template 0xFFFF, 6, gUnknown_085A7A5C, gUnknown_085A7C38, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7F38:: @ 85A7F38
spr_template 0xFFFF, 6, gUnknown_085A7A3C, gUnknown_085A7BF8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7F50:: @ 85A7F50
spr_template 0xFFFF, 6, gUnknown_085A7A4C, gUnknown_085A7C4C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7F68:: @ 85A7F68
spr_template 0xFFFF, 6, gUnknown_085A7A3C, gUnknown_085A7C44, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gUnknown_085A7F80:: @ 85A7F80
spr_template 0xFFFF, 6, gUnknown_085A7A3C, gUnknown_085A7C40, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
gSpriteTemplate_83ED6CC:: @ 85A7F98
spr_template 0xFFFF, 4, gUnknown_085A7A3C, gUnknown_085A7BF8, gUnknown_085A7AF4, gUnknown_085A7CDC, sub_8105B70
gUnknown_085A7FB0:: @ 85A7FB0
subsprite -64, -64, 3, 0, 64x64
subsprite 0, -64, 3, 0, 64x64
@ -400,7 +400,7 @@ gUnknown_085A7FB0:: @ 85A7FB0
gSubspriteTables_83ED704:: @ 85A7FC0
.4byte 4, gUnknown_085A7FB0
gUnknown_085A7FC8:: @ 85A7FC8
subsprite -32, -12, 1, 0, 32x8
subsprite 0, -12, 1, 4, 32x8
@ -416,7 +416,7 @@ gUnknown_085A7FE8:: @ 85A7FE8
subsprite -32, -20, 1, 0, 64x32
subsprite -32, 12, 1, 32, 32x8
subsprite 0, 12, 1, 36, 32x8
gSubspriteTables_83ED75C:: @ 85A7FF4
.4byte 3, gUnknown_085A7FE8
@ -426,10 +426,10 @@ gUnknown_085A7FFC:: @ 85A7FFC
subsprite 0, 8, 1, 36, 32x8
subsprite -32, 16, 1, 40, 32x8
subsprite 0, 16, 1, 44, 32x8
gSubspriteTables_83ED78C:: @ 85A8010
.4byte 5, gUnknown_085A7FFC
gUnknown_085A8018:: @ 85A8018
subsprite -32, -8, 1, 0, 32x8
subsprite 0, -8, 1, 4, 32x8
@ -438,7 +438,7 @@ gUnknown_085A8018:: @ 85A8018
gSubspriteTables_83ED7B4:: @ 85A8028
.4byte 4, gUnknown_085A8018
gUnknown_085A8030:: @ 85A8030
subsprite -8, -12, 1, 0, 16x8
subsprite -8, -4, 1, 0, 16x8
@ -474,7 +474,7 @@ gUnknown_085A8078:: @ 85A8078
gUnknown_085A8088:: @ 85A8088
.4byte 4, gUnknown_085A8078
gUnknown_085A8090:: @ 85A8090
subsprite -32, -8, 3, 0, 32x8
subsprite 0, -8, 3, 4, 32x8
@ -483,7 +483,7 @@ gUnknown_085A8090:: @ 85A8090
gUnknown_085A80A0:: @ 85A80A0
.4byte 4, gUnknown_085A8090
gUnknown_085A80A8:: @ 85A80A8
subsprite -32, -12, 3, 0, 32x8
subsprite 0, -12, 3, 4, 32x8
@ -494,19 +494,19 @@ gUnknown_085A80A8:: @ 85A80A8
gUnknown_085A80C0:: @ 85A80C0
.4byte 6, gUnknown_085A80A8
gUnknown_085A80C8:: @ 85A80C8
subsprite -16, -16, 3, 0, 32x32
gUnknown_085A80CC:: @ 85A80CC
subsprite -8, -8, 3, 16, 16x16
gUnknown_085A80D0:: @ 85A80D0
.4byte 1, gUnknown_085A80C8
gUnknown_085A80D8:: @ 85A80D8
.4byte 1, gUnknown_085A80CC
gUnknown_085A80E0:: @ 85A80E0
subsprite -24, -24, 3, 0, 32x8
subsprite 8, -24, 3, 4, 16x8
@ -523,78 +523,78 @@ gUnknown_085A80E0:: @ 85A80E0
gUnknown_085A8110:: @ 85A8110
.4byte 12, gUnknown_085A80E0
gUnknown_085A8118:: @ 85A8118
subsprite -16, -12, 3, 0, 32x16
subsprite -16, 4, 3, 8, 16x8
subsprite 0, 4, 3, 10, 16x8
gUnknown_085A8124:: @ 85A8124
.4byte 3, gUnknown_085A8118
gUnknown_085A812C:: @ 85A812C
subsprite -8, -8, 3, 0, 16x8
subsprite -8, 0, 3, 8, 16x8
gUnknown_085A8134:: @ 85A8134
.4byte 2, gUnknown_085A812C
gUnknown_085A813C:: @ 85A813C
subsprite -8, -8, 3, 2, 16x8
subsprite -8, 0, 3, 10, 16x8
gUnknown_085A8144:: @ 85A8144
.4byte 2, gUnknown_085A813C
gUnknown_085A814C:: @ 85A814C
subsprite -8, -8, 3, 4, 16x8
subsprite -8, 0, 3, 12, 16x8
gUnknown_085A8154:: @ 85A8154
.4byte 2, gUnknown_085A814C
gUnknown_085A815C:: @ 85A815C
subsprite -8, -8, 3, 6, 16x8
subsprite -8, 0, 3, 14, 16x8
gUnknown_085A8164:: @ 85A8164
.4byte 2, gUnknown_085A815C
gUnknown_085A816C:: @ 85A816C
subsprite -8, -8, 3, 0, 16x8
subsprite -8, 0, 3, 8, 16x8
gUnknown_085A8174:: @ 85A8174
.4byte 2, gUnknown_085A816C
gUnknown_085A817C:: @ 85A817C
subsprite -4, -8, 3, 2, 8x8
subsprite -4, 0, 3, 10, 8x8
gUnknown_085A8184:: @ 85A8184
.4byte 2, gUnknown_085A817C
gUnknown_085A818C:: @ 85A818C
subsprite -8, -8, 3, 3, 16x8
subsprite -8, 0, 3, 11, 16x8
gUnknown_085A8194:: @ 85A8194
.4byte 2, gUnknown_085A818C
gUnknown_085A819C:: @ 85A819C
subsprite -4, -8, 3, 5, 8x8
subsprite -4, 0, 3, 13, 8x8
gUnknown_085A81A4:: @ 85A81A4
.4byte 2, gUnknown_085A819C
gUnknown_085A81AC:: @ 85A81AC
subsprite -8, -8, 3, 6, 16x8
subsprite -8, 0, 3, 14, 16x8
gUnknown_085A81B4:: @ 85A81B4
.4byte 2, gUnknown_085A81AC
gUnknown_085A81BC:: @ 85A81BC
subsprite -12, -12, 3, 0, 16x8
subsprite 4, -12, 3, 2, 8x8
@ -602,18 +602,18 @@ gUnknown_085A81BC:: @ 85A81BC
subsprite 4, -4, 3, 10, 8x8
subsprite -12, 4, 3, 16, 16x8
subsprite 4, 4, 3, 18, 8x8
gUnknown_085A81D4:: @ 85A81D4
.4byte 6, gUnknown_085A81BC
gUnknown_085A81DC:: @ 85A81DC
subsprite -8, -12, 3, 3, 16x8
subsprite -8, -4, 3, 11, 16x8
subsprite -8, 4, 3, 19, 16x8
gUnknown_085A81E8:: @ 85A81E8
.4byte 3, gUnknown_085A81DC
gUnknown_085A81F0:: @ 85A81F0
subsprite -12, -12, 3, 5, 16x8
subsprite 4, -12, 3, 7, 8x8
@ -621,10 +621,10 @@ gUnknown_085A81F0:: @ 85A81F0
subsprite 4, -4, 3, 15, 8x8
subsprite -12, 4, 3, 21, 16x8
subsprite 4, 4, 3, 0x17, 8x8
gUnknown_085A8208:: @ 85A8208
.4byte 6, gUnknown_085A81F0
gUnknown_085A8210:: @ 85A8210
subsprite -12, -12, 3, 0, 16x8
subsprite 4, -12, 3, 2, 8x8
@ -632,18 +632,18 @@ gUnknown_085A8210:: @ 85A8210
subsprite 4, -4, 3, 10, 8x8
subsprite -12, 4, 3, 16, 16x8
subsprite 4, 4, 3, 18, 8x8
gUnknown_085A8228:: @ 85A8228
.4byte 6, gUnknown_085A8210
gUnknown_085A822C:: @ 85A822C
subsprite -8, -12, 3, 3, 16x8
subsprite -8, -4, 3, 11, 16x8
subsprite -8, 4, 3, 19, 16x8
gUnknown_085A823C:: @ 85A823C
.4byte 3, gUnknown_085A822C
gUnknown_085A8244:: @ 85A8244
subsprite -12, -12, 3, 5, 16x8
subsprite 4, -12, 3, 7, 8x8
@ -651,7 +651,7 @@ gUnknown_085A8244:: @ 85A8244
subsprite 4, -4, 3, 15, 8x8
subsprite -12, 4, 3, 21, 16x8
subsprite 4, 4, 3, 23, 8x8
gUnknown_085A825C:: @ 85A825C
.4byte 6, gUnknown_085A8244
@ -712,7 +712,7 @@ gUnknown_083EDBC4:: @ 85A82CC
.4byte NULL
.align 2
sSlotMachineSpriteSheets:: @ 85A8334
gSlotMachineSpriteSheets:: @ 85A8334
obj_tiles gSlotMachineReelSymbol1Tiles, 0x0200, 0x0000
obj_tiles gSlotMachineReelSymbol2Tiles, 0x0200, 0x0001
obj_tiles gSlotMachineReelSymbol3Tiles, 0x0200, 0x0002
@ -738,19 +738,19 @@ gUnknown_083EDCDC:: @ 85A83E4
.4byte gUnknown_08DD19F8
@ might be a palette idk
.byte 0x7B, 0x6F, 0x68, 0x69, 0xAB, 0x36, 0xFF, 0x7F, 0x50, 0x57, 0xC0, 0x7E, 0xBA, 2, 0xBA, 2, 0xFD, 1, 0xFD, 1
gUnknown_085A83FC:: @ 85A83FC
gUnknown_085A83FC:: @ 85A83FC
.byte 0x91, 0x7F
gUnknown_085A83FE:: @ 85A83FE
gUnknown_085A83FE:: @ 85A83FE
.byte 0xBF, 0x43
gUnknown_085A8400:: @ 85A8400
.byte 0xBF, 0x43
gUnknown_085A8402:: @ 85A8402
.byte 0xBF, 0x4A
gUnknown_085A8404:: @ 85A8404
.byte 0xBF, 0x4A, 0, 0
@ -771,20 +771,20 @@ gUnknown_083EDD1C:: @ 85A841C
gUnknown_083EDD30:: @ 85A8430
.byte 0x4A, 0x4B, 0x4C, 0x4E, 0x4D
gUnknown_083EDD35:: @ 85A8435
gBettingTilesId:: @ 85A8435
.byte 0, 0
.byte 1, 2
.byte 3, 4
gUnknown_083EDD3B:: @ 85A843B
gNumberBettingTiles:: @ 85A843B
.byte 1, 2, 2
gUnknown_085A843E:: @ 85A843E
.incbin "graphics/slot_machine/85A843E.gbapal"
gUnknown_085A845E:: @ 85A845E
.incbin "graphics/slot_machine/85A845E.gbapal"
gUnknown_085A847E:: @ 85A847E
.incbin "graphics/slot_machine/85A847E.gbapal"
@ -796,13 +796,13 @@ gUnknown_083EDDA0:: @ 85A84A0
gUnknown_083EDDAC:: @ 85A84AC
.4byte gSlotMachineMenu_Pal + 0x20
gUnknown_085A84B0:: @ 85A84B0
.incbin "graphics/slot_machine/85A84B0.gbapal"
gUnknown_085A84D0:: @ 85A84D0
.incbin "graphics/slot_machine/85A84D0.gbapal"
gUnknown_085A84F0:: @ 85A84F0
.incbin "graphics/slot_machine/85A84F0.gbapal"
@ -830,10 +830,10 @@ gSlotMachineSpritePalettes:: @ 85A8544
obj_pal gUnknown_08DCF1F0, 7
null_obj_pal
sReelTimeGfx:: @ 85A858C
gReelTimeGfx:: @ 85A858C
.incbin "graphics/slot_machine/reel_time_gfx.4bpp.lz"
sReelTimeWindowTilemap:: @ 85A96E0
gReelTimeWindowTilemap:: @ 85A96E0
@if anyone knows what this tilemap is please do share
.incbin "graphics/slot_machine/85A96E0.bin"

View File

@ -1,6 +1,13 @@
#ifndef GUARD_GLOBAL_FIELDMAP_H
#define GUARD_GLOBAL_FIELDMAP_H
#define METATILE_COLLISION_MASK 0x0C00
#define METATILE_ID_MASK 0x03FF
#define METATILE_ID_UNDEFINED 0x03FF
#define METATILE_ELEVATION_SHIFT 12
#define METATILE_COLLISION_SHIFT 10
#define METATILE_ELEVATION_MASK 0xF000
enum
{
CONNECTION_SOUTH = 1,
@ -19,8 +26,8 @@ struct Tileset
/*0x01*/ bool8 isSecondary;
/*0x04*/ void *tiles;
/*0x08*/ void *palettes;
/*0x0c*/ void *metatiles;
/*0x10*/ void *metatileAttributes;
/*0x0c*/ u16 *metatiles;
/*0x10*/ u16 *metatileAttributes;
/*0x14*/ TilesetCB callback;
};

View File

@ -1,6 +1,20 @@
#ifndef GUARD_SLOT_MACHINE_H
#define GUARD_SLOT_MACHINE_H
#define NUM_REELS 3
#define REEL_NUM_TAGS 21
#define REEL_TAG_HEIGHT 24
// Lucky Flags
#define LUCKY_BIAS_REPLAY (1 << 0)
#define LUCKY_BIAS_CHERRY (1 << 1)
#define LUCKY_BIAS_LOTAD (1 << 2)
#define LUCKY_BIAS_AZURILL (1 << 3)
#define LUCKY_BIAS_POWER (1 << 4)
#define LUCKY_BIAS_REELTIME (1 << 5)
#define LUCKY_BIAS_MIXED_777 (1 << 6)
#define LUCKY_BIAS_777 (1 << 7)
void PlaySlotMachine(u8, void (callback)(void));
#endif // GUARD_SLOT_MACHINE_H

View File

@ -1,6 +1,9 @@
#ifndef GUARD_TASK_H
#define GUARD_TASK_H
#define HEAD_SENTINEL 0xFE
#define TAIL_SENTINEL 0xFF
#define NUM_TASKS 16
typedef void (*TaskFunc)(u8 taskId);

View File

@ -1,6 +1,9 @@
#ifndef GUARD_TV_H
#define GUARD_TV_H
#define SLOT_MACHINE 0
#define ROULETTE 1
extern u8 *const gTVStringVarPtrs[3];
void ClearTVShowData(void);
@ -23,9 +26,9 @@ bool8 GetPriceReduction(u8 newsKind);
void sub_80F14F8(TVShow *shows);
size_t CountDigits(int value);
u8 GetRibbonCount(struct Pokemon *pokemon);
void sub_80EDE70(u16 nCoinsSpent);
void sub_80EDE84(u16 nCoinsSpent);
void sub_80EDD78(u16 nCoinsPaidOut);
void AlertTVThatPlayerPlayedSlotMachine(u16 nCoinsSpent);
void AlertTVThatPlayerPlayedRoulette(u16 nCoinsSpent);
void AlertTVOfNewCoinTotal(u16 nCoinsPaidOut);
void sub_80EEA70(void);
void sub_80EDB44(void);
void sub_80EDC60(const u16 *words);

View File

@ -1417,7 +1417,7 @@ static void AnimTask_WithdrawStep(u8 taskId)
}
}
// Animates a "zap of energy" used in KINESIS.
// Animates a "zap of energy" used in KINESIS.
// arg 0: x pixel offset
// arg 1: y pixel offset
// arg 2: vertical flip
@ -1592,7 +1592,7 @@ void sub_8103AA4(struct Sprite *sprite)
sprite->data[3] = sub_8151534(sub_8151534(b, a), sub_8151624(0x1C0));
sprite->data[4] = sub_8151534(sub_8151534(c, a), sub_8151624(0x1C0));
sprite->callback = sub_8103A00;
}
}
}
static void sub_8103BE4(u8 taskId)
@ -3470,7 +3470,7 @@ void AnimOrbitFast(struct Sprite *sprite)
static void AnimOrbitFastStep(struct Sprite *sprite)
{
if ((u16)(sprite->data[1] - 64) < 128)
if (sprite->data[1] >= 64 && sprite->data[1] <= 191)
sprite->subpriority = sprite->data[7] + 1;
else
sprite->subpriority = sprite->data[7] - 1;

View File

@ -1267,7 +1267,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
{
for (x = 0; x < 32; x++)
{
if ((map[x] & 0x3FF) == FLOOR_EXIT_METATILE)
if ((map[x] & METATILE_ID_MASK) == FLOOR_EXIT_METATILE)
{
x += 7 - gEventObjects[gSelectedEventObject].initialCoords.x;
y += 7 - gEventObjects[gSelectedEventObject].initialCoords.y;
@ -1568,7 +1568,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
{
for (x = 0; x < mapLayout->width; x++)
{
if ((layoutMap[x] & 0x3FF) != FLOOR_EXIT_METATILE)
if ((layoutMap[x] & METATILE_ID_MASK) != FLOOR_EXIT_METATILE)
{
map[x] = layoutMap[x];
}

View File

@ -1056,7 +1056,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
for (x16 = x; x16 < (x + width); x16++)
{
CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK);
}
}
break;
@ -1067,7 +1067,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
for (x16 = x; x16 < (x + width); x16++)
{
((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK);
}
}
break;

View File

@ -1158,7 +1158,7 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
u16 i;
u16 j;
u16 behavior;
u16 flags;
u16 impassableFlag;
u16 v0;
u16 v1;
s16 decLeft;
@ -1173,11 +1173,11 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decor].tiles[i * decWidth + j]);
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decor].permission != DECORPERM_PASS_FLOOR && (behavior >> 12)))
{
flags = 0xc00;
impassableFlag = METATILE_COLLISION_MASK;
}
else
{
flags = 0x000;
impassableFlag = 0x000;
}
if (gDecorations[decor].permission != DECORPERM_NA_WALL && MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(decLeft, decBottom)) == TRUE)
{
@ -1190,11 +1190,11 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
v1 = sub_8127B54(gDecorations[decor].id, i * decWidth + j);
if (v1 != 0xFFFF)
{
MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags | v1);
MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | impassableFlag | v1);
}
else
{
MapGridSetMetatileIdAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags);
MapGridSetMetatileIdAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | impassableFlag);
}
}
}
@ -1502,7 +1502,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].data[0] + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000;
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
if (!sub_81284F4(behaviorAt, decoration))
{
return FALSE;
@ -1527,7 +1527,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].data[0] + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000;
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_8128484(behaviorAt, behaviorBy))
{
return FALSE;
@ -1547,7 +1547,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].data[0] + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & 0xf000;
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & METATILE_ELEVATION_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
{
return FALSE;

View File

@ -2620,7 +2620,7 @@ static void sub_80B8874(u16 offs)
dest = (u16 *)(VRAM + 0x140 + offs);
for (i = 0; i < 0x140; i++, dest++)
{
*dest = gFieldMoveStreaksTilemap[i] | 0xf000;
*dest = gFieldMoveStreaksTilemap[i] | METATILE_ELEVATION_MASK;
}
}

View File

@ -887,8 +887,8 @@ static void PetalburgGymFunc(u8 a0, u16 a1)
}
for (i = 0; i < nDoors; i++)
{
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | 0xc00);
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | 0xc00);
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | METATILE_COLLISION_MASK);
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
}
@ -1100,7 +1100,7 @@ static void PCTurnOnEffect_1(s16 flag, s8 dx, s8 dy)
tileId = 0x27e;
}
}
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00);
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
}
void DoPCTurnOffEffect(void)
@ -1141,7 +1141,7 @@ static void PCTurnOffEffect(void)
{
tileId = 0x259;
}
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00);
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
DrawWholeMapView();
}
@ -1892,7 +1892,7 @@ static void sub_8139C80(u8 taskId)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | 0xC00);
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
}
}
@ -1902,7 +1902,7 @@ static void sub_8139C80(u8 taskId)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | 0xC00);
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
}
}

View File

@ -383,15 +383,15 @@ u8 MapGridGetZCoordAt(int x, int y)
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = gMapHeader.mapLayout->border[i];
block |= 0xc00;
block |= METATILE_COLLISION_MASK;
}
if (block == 0x3ff)
if (block == METATILE_ID_UNDEFINED)
{
return 0;
}
return block >> 12;
return block >> METATILE_ELEVATION_SHIFT;
}
u8 MapGridIsImpassableAt(int x, int y)
@ -411,13 +411,13 @@ u8 MapGridIsImpassableAt(int x, int y)
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = gMapHeader.mapLayout->border[i];
block |= 0xc00;
block |= METATILE_COLLISION_MASK;
}
if (block == 0x3ff)
if (block == METATILE_ID_UNDEFINED)
{
return 1;
}
return (block & 0xc00) >> 10;
return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT;
}
u32 MapGridGetMetatileIdAt(int x, int y)
@ -439,18 +439,19 @@ u32 MapGridGetMetatileIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = mapLayout->border[i] | 0xc00;
block = mapLayout->border[i] | METATILE_COLLISION_MASK;
}
if (block == 0x3ff)
if (block == METATILE_ID_UNDEFINED)
{
border = gMapHeader.mapLayout->border;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
block2 = gMapHeader.mapLayout->border[j];
block2 |= 0xc00;
return block2 & block;
// This OR is completely pointless.
block2 |= METATILE_COLLISION_MASK;
return block2 & METATILE_ID_MASK;
}
return block & 0x3ff;
return block & METATILE_ID_MASK;
}
u32 MapGridGetMetatileBehaviorAt(int x, int y)
@ -464,7 +465,7 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
{
u16 metatile;
metatile = MapGridGetMetatileIdAt(x, y);
return (GetBehaviorByMetatileId(metatile) & 0xf000) >> 12;
return (GetBehaviorByMetatileId(metatile) & METATILE_ELEVATION_MASK) >> METATILE_ELEVATION_SHIFT;
}
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
@ -474,7 +475,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
&& y >= 0 && y < gBackupMapLayout.height)
{
i = x + y * gBackupMapLayout.width;
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & 0xf000) | (metatile & 0xfff);
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK);
}
}
@ -654,7 +655,7 @@ int GetMapBorderIdAt(int x, int y)
i = gBackupMapLayout.width;
i *= y;
block = gBackupMapLayout.map[x + i];
if (block == 0x3ff)
if (block == METATILE_ID_UNDEFINED)
{
goto fail;
}
@ -664,8 +665,8 @@ int GetMapBorderIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
block2 = 0xc00 | mapLayout->border[j];
if (block2 == 0x3ff)
block2 = METATILE_COLLISION_MASK | mapLayout->border[j];
if (block2 == METATILE_ID_UNDEFINED)
{
goto fail;
}
@ -921,9 +922,9 @@ void sub_8088B94(int x, int y, int a2)
if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
{
if (a2 != 0)
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= 0xC00;
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK;
else
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK;
}
}
@ -937,7 +938,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth,
else
mapMetatilePtr += mapWidth;
if (sub_80FADE4(*mapMetatilePtr & 0x3FF, yMode) == 1)
if (sub_80FADE4(*mapMetatilePtr & METATILE_ID_MASK, yMode) == 1)
return TRUE;
return FALSE;
}

View File

@ -7,7 +7,7 @@
static EWRAM_DATA u8 sEscalatorAnim_TaskId = 0;
static void sub_80E12E8(u8 taskId, const s16 *list, u16 c)
static void sub_80E12E8(u8 taskId, const s16 *list, u16 isImpassableFlag)
{
s16 r5 = gTasks[taskId].data[4] - 1;
s16 r3 = gTasks[taskId].data[5] - 1;
@ -26,9 +26,9 @@ static void sub_80E12E8(u8 taskId, const s16 *list, u16 c)
if (list[r4] == metatileId)
{
if (r4 != 2)
MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[r4 + 1]);
MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[r4 + 1]);
else
MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[0]);
MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[0]);
}
}
}
@ -44,9 +44,9 @@ static void sub_80E12E8(u8 taskId, const s16 *list, u16 c)
if (list[2 - r4] == metatileId)
{
if (r4 != 2)
MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[1 - r4]);
MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[1 - r4]);
else
MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[2]);
MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[2]);
}
}
}
@ -76,13 +76,13 @@ static void sub_80E1444(u8 taskId)
sub_80E12E8(taskId, gUnknown_08589AC0, 0);
break;
case 2:
sub_80E12E8(taskId, gUnknown_08589AC6, 0xC00);
sub_80E12E8(taskId, gUnknown_08589AC6, METATILE_COLLISION_MASK);
break;
case 3:
sub_80E12E8(taskId, gUnknown_08589ACC, 0);
break;
case 4:
sub_80E12E8(taskId, gUnknown_08589AD2, 0xC00);
sub_80E12E8(taskId, gUnknown_08589AD2, METATILE_COLLISION_MASK);
break;
case 5:
sub_80E12E8(taskId, gUnknown_08589AD8, 0);

View File

@ -996,7 +996,7 @@ static void sub_81405CC(void)
taskId = gUnknown_0203AB88->varA4 = CreateTask(sub_81408A8, 0);
gTasks[taskId].data[6] = 6;
gTasks[taskId].data[13] = GetCoins();
sub_80EDE84(GetCoins());
AlertTVThatPlayerPlayedRoulette(GetCoins());
gUnknown_0203AB88->varA5 = CreateTask(sub_8140814, 1);
SetMainCallback2(sub_8140238);
return;
@ -1964,7 +1964,7 @@ static void sub_8141DE4(u8 taskId)
gSpecialVar_0x8004 = TRUE;
else
gSpecialVar_0x8004 = FALSE;
sub_80EDD78(GetCoins());
AlertTVOfNewCoinTotal(GetCoins());
BeginHardwarePaletteFade(0xFF, 0, 0, 16, 0);
gTasks[taskId].func = sub_8141E7C;
}

View File

@ -2028,14 +2028,14 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
u16 tileId = VarGet(ScriptReadHalfword(ctx));
u16 v8 = VarGet(ScriptReadHalfword(ctx));
u16 isImpassable = VarGet(ScriptReadHalfword(ctx));
x += 7;
y += 7;
if (!v8)
if (!isImpassable)
MapGridSetMetatileIdAt(x, y, tileId);
else
MapGridSetMetatileIdAt(x, y, tileId | 0xC00);
MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
return FALSE;
}

View File

@ -259,7 +259,7 @@ void sub_80E8CB0(s16 *xPtr, s16 *yPtr, u16 tile)
{
for (x = 0; x < mapLayout->width; x ++)
{
if ((mapLayout->map[y * mapLayout->width + x] & 0x3ff) == tile)
if ((mapLayout->map[y * mapLayout->width + x] & METATILE_ID_MASK) == tile)
{
*xPtr = x;
*yPtr = y;
@ -282,7 +282,7 @@ void sub_80E8D4C(void)
{
if (gUnknown_0858CFCC[i].tile1 == tile)
{
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xC00);
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
return;
}
@ -291,7 +291,7 @@ void sub_80E8D4C(void)
{
if (gUnknown_0858CFCC[i].tile2 == tile)
{
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | 0xC00);
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
return;
}
@ -352,7 +352,7 @@ void sub_80E8EE0(struct MapEvents const *events)
{
if (gUnknown_0858CFCC[i].tile1 == tile_id)
{
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xc00);
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | METATILE_COLLISION_MASK);
break;
}
}
@ -434,7 +434,7 @@ void sub_80E9108(void)
sub_80E8CB0(&x, &y, 0x220);
x += 7;
y += 7;
MapGridSetMetatileIdAt(x, y, 0x220 | 0xC00);
MapGridSetMetatileIdAt(x, y, 0x220 | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
pal_fill_black();
CreateTask(sub_80E90C8, 0);
@ -492,12 +492,12 @@ void sub_80E9238(u8 flagIn)
if (curBaseId != 0)
{
sub_80E8CB0(&x, &y, 0x220);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | 0xc00);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | METATILE_COLLISION_MASK);
}
else if (flagIn == 1 && VarGet(VAR_0x4089) == 1)
{
sub_80E8CB0(&x, &y, 0x220);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | 0xc00);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | METATILE_COLLISION_MASK);
}
}
}
@ -791,7 +791,7 @@ void sub_80E9AD0(void)
{
if (gUnknown_0858CFCC[j].tile2 == tile)
{
MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | 0xc00);
MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | METATILE_COLLISION_MASK);
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,6 @@
#include "global.h"
#include "task.h"
#define HEAD_SENTINEL 0xFE
#define TAIL_SENTINEL 0xFF
struct Task gTasks[NUM_TASKS];
static void InsertTask(u8 newTaskId);

View File

@ -39,6 +39,7 @@
#include "tv.h"
#include "data2.h"
#include "constants/layouts.h"
#include "constants/metatile_behaviors.h"
// Static type declarations
@ -62,7 +63,7 @@ IWRAM_DATA s8 sTVShowMixingCurSlot;
EWRAM_DATA u16 sPokemonAnglerSpecies = 0;
EWRAM_DATA u16 sPokemonAnglerAttemptCounters = 0;
EWRAM_DATA u16 sFindThatGamerCoinsSpent = 0;
EWRAM_DATA bool8 sFindThatGamerWhichGame = FALSE;
EWRAM_DATA u8 sFindThatGamerWhichGame = SLOT_MACHINE;
EWRAM_DATA ALIGNED(4) u8 sRecordMixingPartnersWithoutShowsToShare = 0;
EWRAM_DATA ALIGNED(4) u8 sTVShowState = 0;
EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {};
@ -853,9 +854,9 @@ void SetTVMetatilesOnMap(int width, int height, u16 tileId)
{
for (x = 0; x < width; x ++)
{
if (MapGridGetMetatileBehaviorAt(x, y) == 0x86) // is this tile a TV?
if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION)
{
MapGridSetMetatileIdAt(x, y, tileId | 0xc00);
MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
}
}
}
@ -2019,7 +2020,7 @@ void sub_80EDCE8(void)
}
}
void sub_80EDD78(u16 nCoinsPaidOut)
void AlertTVOfNewCoinTotal(u16 nCoinsPaidOut)
{
TVShow *show;
bool8 flag;
@ -2031,7 +2032,7 @@ void sub_80EDD78(u16 nCoinsPaidOut)
flag = FALSE;
switch (sFindThatGamerWhichGame)
{
case FALSE:
case SLOT_MACHINE:
if (nCoinsPaidOut >= sFindThatGamerCoinsSpent + 200)
{
flag = TRUE;
@ -2044,7 +2045,7 @@ void sub_80EDD78(u16 nCoinsPaidOut)
break;
}
return;
case TRUE:
case ROULETTE:
if (nCoinsPaidOut >= sFindThatGamerCoinsSpent + 50)
{
flag = TRUE;
@ -2072,15 +2073,15 @@ void sub_80EDD78(u16 nCoinsPaidOut)
}
}
void sub_80EDE70(u16 nCoinsSpent)
void AlertTVThatPlayerPlayedSlotMachine(u16 nCoinsSpent)
{
sFindThatGamerWhichGame = FALSE;
sFindThatGamerWhichGame = SLOT_MACHINE;
sFindThatGamerCoinsSpent = nCoinsSpent;
}
void sub_80EDE84(u16 nCoinsSpent)
void AlertTVThatPlayerPlayedRoulette(u16 nCoinsSpent)
{
sFindThatGamerWhichGame = TRUE;
sFindThatGamerWhichGame = ROULETTE;
sFindThatGamerCoinsSpent = nCoinsSpent;
}