Cleanup event.c

This commit is contained in:
YohannDR 2024-10-03 12:38:12 +02:00
parent f611c47164
commit b71a739093
3 changed files with 100 additions and 88 deletions

View File

@ -1,84 +1,95 @@
#define EVENT_ACTION_CLEARING 0x0
#define EVENT_ACTION_SETTING 0x1
#define EVENT_ACTION_TOGGLING 0x2
#define EVENT_ACTION_CHECKING 0x3
#ifndef EVENT_CONSTANTS_H
#define EVENT_CONSTANTS_H
#define EVENT_NONE 0x0
#define EVENT_EASY 0x1
#define EVENT_HARD 0x2
#define EVENT_ENTER_NORFAIR_DEMO_PLAYED 0x3
#define EVENT_EXIT_KRAID_DEMO_PLAYED 0x4
#define EVENT_ENTER_RIDLEY_DEMO_PLAYED 0x5
#define EVENT_ENTER_MOTHERSHIP_DEMO_PLAYED 0x6
#define EVENT_ENTER_TOURIAN_DEMO_PLAYED 0x7
#define EVENT_STATUE_LONG_BEAM_GRABBED 0x8
#define EVENT_STATUE_BOMBS_GRABBED 0x9
#define EVENT_STATUE_ICE_BEAM_GRABBED 0xA
#define EVENT_STATUE_SPEEDBOOSTER_GRABBED 0xB
#define EVENT_STATUE_HIGH_JUMP_GRABBED 0xC
#define EVENT_STATUE_VARIA_SUIT_GRABBED 0xD
#define EVENT_STATUE_WAVE_BEAM_GRABBED 0xE
#define EVENT_STATUE_SCREW_ATTACK_GRABBED 0xF
#define EVENT_POWER_GRIP_OBTAINED 0x10
#define EVENT_CHOZO_PILLAR_FULLY_EXTENDED 0x11
#define EVENT_HIGH_JUMP_OBTAINED 0x12
#define EVENT_VARIA_SUIT_OBTAINED 0x13
#define EVENT_CHARGE_BEAM_OBTAINED 0x14
#define EVENT_SCREW_ATTACK_OBTAINED 0x15
#define EVENT_SPACE_JUMP_OBTAINED 0x16
#define EVENT_GRAVITY_SUIT_OBTAINED 0x17
#define EVENT_PLASMA_BEAM_OBTAINED 0x18
#define EVENT_DEOREM_ENCOUNTERED_AT_FIRST_LOCATION_OR_KILLED 0x19
#define EVENT_DEOREM_ENCOUNTERED_AT_SECOND_LOCATION_OR_KILLED 0x1A
#define EVENT_DEOREM_KILLED_AT_SECOND_LOCATION 0x1B
#define EVENT_ACID_WORM_KILLED 0x1C
#define EVENT_KRAID_GADORA_KILLED 0x1D
#define EVENT_KRAID_KILLED 0x1E
#define EVENT_KRAID_ELEVATOR_STATUE_DESTROYED 0x1F
#define EVENT_CATERPILLAR_KILLED 0x20
#define EVENT_IMAGO_TUNNEL_DISCOVERED 0x21
#define EVENT_IMAGO_COCOON_KILLED 0x22
#define EVENT_IMAGO_KILLED 0x23
#define EVENT_RIDLEY_GADORA_KILLED 0x24
#define EVENT_RIDLEY_KILLED 0x25
#define EVENT_RIDLEY_ELEVATOR_STATUE_DESTROYED 0x26
#define EVENT_MOTHER_BRAIN_KILLED 0x27
#define EVENT_CROCOMIRE_KILLED 0x28
#define EVENT_REPEL_MACHINE_KILLED 0x29
#define EVENT_VIEWED_STATUE_ROOM 0x2A
#define EVENT_LONG_BEAM_DESSGEEGA_KILLED 0x2B
#define EVENT_THREE_HIVES_DESTROYED 0x2C
#define EVENT_BUGS_KILLED 0x2D
#define EVENT_ZIPLINES_ACTIVATED 0x2E
#define EVENT_PLANT_DESTROYED_LAVA 0x2F
#define EVENT_PLANT_DESTROYED_POST_VARIA 0x30
#define EVENT_PLANT_DESTROYED_VARIA2 0x31
#define EVENT_PLANT_DESTROYED_VARIA3 0x32
#define EVENT_PLANT_DESTROYED_VARIA1 0x33
#define EVENT_KRAID_BARISTUTES_KILLED 0x34
#define EVENT_KRAID_STATUE_OPENED 0x35
#define EVENT_RIDLEY_STATUE_OPENED 0x36
#define EVENT_FIRST_METROID_ROOM_CLEARED 0x37
#define EVENT_THIRD_METROID_ROOM_CLEARED 0x38
#define EVENT_FIFTH_METROID_ROOM_CLEARED 0x39
#define EVENT_SECOND_METROID_ROOM_CLEARED 0x3A
#define EVENT_SIXTH_METROID_ROOM_CLEARED 0x3B
#define EVENT_FOURTH_METROID_ROOM_CLEARED 0x3C
#define EVENT_ZEBETITE_ONE_DESTROYED 0x3D
#define EVENT_ZEBETITE_TWO_DESTROYED 0x3E
#define EVENT_ZEBETITE_THREE_DESTROYED 0x3F
#define EVENT_ZEBETITE_FOUR_DESTROYED 0x40
#define EVENT_ESCAPED_ZEBES 0x41
#define EVENT_MARKER_BETWEEN_ZEBES_AND_MOTHERSHIP 0x42
#define EVENT_FULLY_POWERED_SUIT_OBTAINED 0x43
#define EVENT_SKIPPED_VARIA_SUIT 0x44
#define EVENT_CHOZOBLOCK 0x45
#define EVENT_POWER_BOMB_STOLEN 0x46
#define EVENT_SPACE_PIRATE_WITH_POWER_BOMB_ONE 0x47
#define EVENT_SPACE_PIRATE_WITH_POWER_BOMB_TWO 0x48
#define EVENT_GLASS_TUBE_BROKEN 0x49
#define EVENT_MECHA_RIDLEY_KILLED 0x4A
#define EVENT_ESCAPED_CHOZODIA 0x4B
#define EVENT_AKI 0x4C
#define EVENT_BOMBATE 0x4D
#define EVENT_END_UNUSED 0x4E
enum Event {
EVENT_NONE,
EVENT_EASY,
EVENT_HARD,
EVENT_ENTER_NORFAIR_DEMO_PLAYED,
EVENT_EXIT_KRAID_DEMO_PLAYED,
EVENT_ENTER_RIDLEY_DEMO_PLAYED,
EVENT_ENTER_MOTHERSHIP_DEMO_PLAYED,
EVENT_ENTER_TOURIAN_DEMO_PLAYED,
EVENT_STATUE_LONG_BEAM_GRABBED,
EVENT_STATUE_BOMBS_GRABBED,
EVENT_STATUE_ICE_BEAM_GRABBED,
EVENT_STATUE_SPEEDBOOSTER_GRABBED,
EVENT_STATUE_HIGH_JUMP_GRABBED,
EVENT_STATUE_VARIA_SUIT_GRABBED,
EVENT_STATUE_WAVE_BEAM_GRABBED,
EVENT_STATUE_SCREW_ATTACK_GRABBED,
EVENT_POWER_GRIP_OBTAINED,
EVENT_CHOZO_PILLAR_FULLY_EXTENDED,
EVENT_HIGH_JUMP_OBTAINED,
EVENT_VARIA_SUIT_OBTAINED,
EVENT_CHARGE_BEAM_OBTAINED,
EVENT_SCREW_ATTACK_OBTAINED,
EVENT_SPACE_JUMP_OBTAINED,
EVENT_GRAVITY_SUIT_OBTAINED,
EVENT_PLASMA_BEAM_OBTAINED,
EVENT_DEOREM_ENCOUNTERED_AT_FIRST_LOCATION_OR_KILLED,
EVENT_DEOREM_ENCOUNTERED_AT_SECOND_LOCATION_OR_KILLED,
EVENT_DEOREM_KILLED_AT_SECOND_LOCATION,
EVENT_ACID_WORM_KILLED,
EVENT_KRAID_GADORA_KILLED,
EVENT_KRAID_KILLED,
EVENT_KRAID_ELEVATOR_STATUE_DESTROYED,
EVENT_CATERPILLAR_KILLED,
EVENT_IMAGO_TUNNEL_DISCOVERED,
EVENT_IMAGO_COCOON_KILLED,
EVENT_IMAGO_KILLED,
EVENT_RIDLEY_GADORA_KILLED,
EVENT_RIDLEY_KILLED,
EVENT_RIDLEY_ELEVATOR_STATUE_DESTROYED,
EVENT_MOTHER_BRAIN_KILLED,
EVENT_CROCOMIRE_KILLED,
EVENT_REPEL_MACHINE_KILLED,
EVENT_VIEWED_STATUE_ROOM,
EVENT_LONG_BEAM_DESSGEEGA_KILLED,
EVENT_THREE_HIVES_DESTROYED,
EVENT_BUGS_KILLED,
EVENT_ZIPLINES_ACTIVATED,
EVENT_PLANT_DESTROYED_LAVA,
EVENT_PLANT_DESTROYED_POST_VARIA,
EVENT_PLANT_DESTROYED_VARIA2,
EVENT_PLANT_DESTROYED_VARIA3,
EVENT_PLANT_DESTROYED_VARIA1,
EVENT_KRAID_BARISTUTES_KILLED,
EVENT_KRAID_STATUE_OPENED,
EVENT_RIDLEY_STATUE_OPENED,
EVENT_FIRST_METROID_ROOM_CLEARED,
EVENT_THIRD_METROID_ROOM_CLEARED,
EVENT_FIFTH_METROID_ROOM_CLEARED,
EVENT_SECOND_METROID_ROOM_CLEARED,
EVENT_SIXTH_METROID_ROOM_CLEARED,
EVENT_FOURTH_METROID_ROOM_CLEARED,
EVENT_ZEBETITE_ONE_DESTROYED,
EVENT_ZEBETITE_TWO_DESTROYED,
EVENT_ZEBETITE_THREE_DESTROYED,
EVENT_ZEBETITE_FOUR_DESTROYED,
EVENT_ESCAPED_ZEBES,
EVENT_MARKER_BETWEEN_ZEBES_AND_MOTHERSHIP,
EVENT_FULLY_POWERED_SUIT_OBTAINED,
EVENT_SKIPPED_VARIA_SUIT,
EVENT_CHOZOBLOCK,
EVENT_POWER_BOMB_STOLEN,
EVENT_SPACE_PIRATE_WITH_POWER_BOMB_ONE,
EVENT_SPACE_PIRATE_WITH_POWER_BOMB_TWO,
EVENT_GLASS_TUBE_BROKEN,
EVENT_MECHA_RIDLEY_KILLED,
EVENT_ESCAPED_CHOZODIA,
EVENT_AKI,
EVENT_BOMBATE,
EVENT_END_UNUSED,
EVENT_COUNT
};
enum {
EVENT_ACTION_CLEARING,
EVENT_ACTION_SETTING,
EVENT_ACTION_TOGGLING,
EVENT_ACTION_CHECKING
};
#endif /* EVENT_CONSTANTS_H */

View File

@ -15,15 +15,16 @@ u32 EventFunction(u8 action, u8 event)
u32 newEvent;
u32 isSet;
if ((u8)(event - 1) > EVENT_BOMBATE)
// Check is a valid event
if (event == EVENT_NONE || event >= EVENT_COUNT)
return FALSE;
// Get event chunk
pEvent = gEventsTriggered;
pEvent += (event / 32);
pEvent += event / 32;
// Get correct bit for the requested event
newEvent = 1 << (event & 31);
newEvent = 1 << (event % 32);
// Get previous event
previous = *pEvent;