TRX/src/util.h

42 lines
1.4 KiB
C
Raw Normal View History

2021-02-18 16:40:32 +01:00
#ifndef TOMB1MAIN_UTIL_H
#define TOMB1MAIN_UTIL_H
2021-02-08 01:18:57 +01:00
2021-02-21 17:50:20 +01:00
#define TOMB1M_FEAT_CHEATS
2021-02-21 10:14:10 +01:00
#define TOMB1M_FEAT_EXTENDED_MEMORY
2021-02-20 23:01:24 +01:00
#define TOMB1M_FEAT_UI
#define TOMB1M_FEAT_GAMEPLAY
#define TOMB1M_FEAT_LEVEL_FIXES
#define TOMB1M_FEAT_NOCD
2021-02-08 01:18:57 +01:00
2021-02-09 20:58:31 +01:00
#include <stdint.h>
2021-02-10 16:03:02 +01:00
#include <stdio.h>
2021-02-08 01:18:57 +01:00
#pragma pack(push, 1)
typedef struct {
2021-02-10 16:03:02 +01:00
uint8_t opcode; // must be 0xE9
2021-02-09 20:58:31 +01:00
uint32_t offset;
2021-02-08 01:18:57 +01:00
} JMP;
#pragma pack(pop)
2021-02-10 16:03:02 +01:00
#define TRACE(...) \
{ \
printf("%s:%d %s ", __FILE__, __LINE__, __func__); \
printf(__VA_ARGS__); \
printf("\n"); \
fflush(stdout); \
}
2021-02-08 01:18:57 +01:00
2021-02-10 16:03:02 +01:00
#define VAR_U_(address, type) (*(type*)(address))
#define VAR_I_(address, type, value) (*(type*)(address))
#define ARRAY_(address, type, length) (*(type(*) length)(address))
2021-02-08 01:18:57 +01:00
2021-02-18 16:40:32 +01:00
void Tomb1MInjectFunc(void* from, void* to);
void Tomb1MPrintStackTrace();
2021-02-08 01:18:57 +01:00
2021-02-10 16:03:02 +01:00
#define INJECT(from, to) \
{ \
2021-02-18 16:40:32 +01:00
Tomb1MInjectFunc((void*)from, (void*)to); \
2021-02-10 16:03:02 +01:00
}
2021-02-08 01:18:57 +01:00
#endif