Cavestory Mod API
CSMAPI_defines.h
Go to the documentation of this file.
1 /*
2  Cavestory Multiplayer API
3  Copyright (C) 2021 Johnny Ledger
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
26 #pragma once
27 
28 // The sound modes for CSM_PlaySound
29 #define SOUND_MODE_LOOP -1 // Loop the sound.
30 #define SOUND_MODE_STOP 0 // Stop the sound completely. Don't play it.
31 #define SOUND_MODE_STOP_THEN_PLAY 1 // Stop the sound, then play it from the start.
32 #define SOUND_MODE_PLAY 2 // Play the sound immediately; don't stop it first.
33 
34 // Limits
35 #define CSM_MAX_BULLET_FUNCS 64
36 #define CSM_MAX_WEAPON_SHOOT_FUNCS 64
37 #define CSM_MAX_NPC_FUNCS 1024
38 #define CSM_MAX_CUSTOM_SOUNDS 255
39 
40 // Game defines
41 #define CARET_MAX 0x40
42 #define BULLET_MAX 0x200
43 #define ARMS_MAX 8
44 #define ITEM_MAX 32
45 #define PERMIT_STAGE_COUNT 24
46 #define MAX_PERMIT_INDEX 8
47 #define MAX_WHIMSICAL_STARS 3
48 #define ANIM_NPC_MAX 128
49 #define NPC_MAX (0x200 + ANIM_NPC_MAX)
50 #define ANIM_NPC_START_OFFSET (NPC_MAX - ANIM_NPC_MAX)
51 #define BOSS_MAX 20
52 #define MAX_DYNAMIC_SURFACES (SURFACE_ID_ALLOCATABLE_SURFACE_END - SURFACE_ID_ALLOCATABLE_SURFACE_START)
53 #define BASE_WINDOW_WIDTH 426
54 #define BASE_WINDOW_HEIGHT 240
55 #define WINDOW_WIDTH WINDOW_REAL_WIDTH
56 #define WINDOW_HEIGHT WINDOW_REAL_HEIGHT
57 #define PATH_LENGTH 260 // Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash.
58 
59 // Substitutes
60 #define CSM_OUR_GHOST_ID -2 // Use this in place of iGhostId arguments to only affect our player.
61 
62 // Macro helpers
63 #define SubpixelToPixel(X) ((X) / 0x200)
64 #define SCALE_GUI_POINT(POINT, CENTER, SCALAR) (((POINT - CENTER) * SCALAR) + CENTER)
65 #define RECT_WIDTH(RC) ((RC).right - (RC).left)
66 #define RECT_HEIGHT(RC) ((RC).bottom - (RC).top)
67 #define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
68 #define MIN(A, B) ((A) < (B) ? (A) : (B))
69 #define MAX(A, B) ((A) > (B) ? (A) : (B))
70 #define ABS(x) ((x) < 0 ? -(x) : (x))
71 
72 #define SET_RECT(rect, l, t, r, b) \
73  rect.left = l; \
74  rect.top = t; \
75  rect.right = r; \
76  rect.bottom = b;
77 
78 #define CSM_RGB(r,g,b) ((r) | ((g) << 8) | ((b) << 16) | (0xFF << 24))
79 #define CSM_RGBA(r,g,b,a) ((r) | ((g) << 8) | ((b) << 16) | ((a) << 24))
80 #define CSM_GETRED(x) (unsigned char)((x) & 0xFF)
81 #define CSM_GETGREEN(x) (unsigned char)(((x) >> 8) & 0xFF)
82 #define CSM_GETBLUE(x) (unsigned char)(((x) >> 16) & 0xFF)
83 #define CSM_GETALPHA(x) (unsigned char)(((x) >> 24) & 0xFF)
84 
85 #define CSM_TextScript_IsMessageBoxOpen() ((gTS.flags & 0x33) != 0)
86 
87 #define CSM_Error(FORMAT, ...) CSM_Log("[" __FILE__ " @ %d] ERROR: " __FUNCTION__ "() - " FORMAT, __LINE__, __VA_ARGS__);
88 
89 #define SYSTEM_MENU_CREATE_SHORTCUT(VARNAME, SCAN_CODE, USE_CTRL, USE_SHIFT)\
90  Input::KeyShortcut* VARNAME = new Input::KeyShortcut();\
91  VARNAME->SetCombo(SDL_Scancode::SCAN_CODE, USE_CTRL, USE_SHIFT);
92 
93 #define SYSTEM_MENU_ADD_MENU(MENU, VARNAME, ID, TEXT, PARENT_MENU, SHORTCUT)\
94  SystemMenuItem* VARNAME = (MENU)->AddItem(ID, TEXT, PARENT_MENU, SHORTCUT);
95 
96 #define SYSTEM_MENU_ADD_ITEM(MENU, ID, TEXT, PARENT_MENU, SHORTCUT)\
97  (MENU)->AddItem(ID, TEXT, PARENT_MENU, SHORTCUT)->OnClicked = [](SystemMenuInfo* pGui, SystemMenuItem* pItem)
98 
99 #define SYSTEM_MENU_ADD_SEPERATOR(MENU, PARENT_MENU)\
100  (MENU)->AddItem(-1, "", PARENT_MENU)->Seperator = true;
101 
102 #include <CSMAPI_begincode.h>
103 extern CAVESTORY_MOD_API int WINDOW_REAL_WIDTH;
104 extern CAVESTORY_MOD_API int WINDOW_REAL_HEIGHT;
105 #include <CSMAPI_endcode.h>
#define CAVESTORY_MOD_API
Exports / imports Cavestory Mod API functions & classes.
Definition: CSMAPI_begincode.h:30