mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-07 08:01:16 +00:00
Added debug level-warping for testing purposes
This commit is contained in:
parent
c86c7f7280
commit
284ab37406
6 changed files with 145 additions and 27 deletions
|
@ -99,7 +99,7 @@
|
|||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -3930,6 +3930,7 @@
|
|||
<ClCompile Include="..\src\pc\controller\controller_emscripten_keyboard.c" />
|
||||
<ClCompile Include="..\src\pc\controller\controller_entry_point.c" />
|
||||
<ClCompile Include="..\src\pc\controller\controller_keyboard.c" />
|
||||
<ClCompile Include="..\src\pc\controller\controller_keyboard_debug.c" />
|
||||
<ClCompile Include="..\src\pc\controller\controller_recorded_tas.c" />
|
||||
<ClCompile Include="..\src\pc\controller\controller_sdl.c" />
|
||||
<ClCompile Include="..\src\pc\discord\discordrpc.c" />
|
||||
|
@ -4305,6 +4306,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\behavior_table.h" />
|
||||
<ClInclude Include="..\src\pc\controller\controller_keyboard_debug.h" />
|
||||
<ClInclude Include="..\src\pc\debuglog.h" />
|
||||
<ClInclude Include="..\src\pc\network\network.h" />
|
||||
<ClInclude Include="..\src\pc\network\socket\socket.h" />
|
||||
|
|
|
@ -15012,6 +15012,9 @@
|
|||
<ClCompile Include="..\src\pc\network\packets\packet_save_file.c">
|
||||
<Filter>Source Files\src\pc\network\packets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pc\controller\controller_keyboard_debug.c">
|
||||
<Filter>Source Files\src\pc\controller</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\actors\common0.h">
|
||||
|
@ -15931,5 +15934,8 @@
|
|||
<ClInclude Include="..\src\pc\debuglog.h">
|
||||
<Filter>Source Files\src\pc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pc\controller\controller_keyboard_debug.h">
|
||||
<Filter>Source Files\src\pc\controller</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -10,16 +10,24 @@
|
|||
|
||||
#include "../configfile.h"
|
||||
#include "controller_keyboard.h"
|
||||
#include "controller_keyboard_debug.h"
|
||||
|
||||
#include "pc/gfx/gfx_window_manager_api.h"
|
||||
#include "pc/pc_main.h"
|
||||
#include "engine/math_util.h"
|
||||
|
||||
// TODO: use some common lookup header
|
||||
#define SCANCODE_BACKSPACE 0x0E
|
||||
#define SCANCODE_ESCAPE 0x01
|
||||
#define SCANCODE_ENTER 0x1C
|
||||
#define SCANCODE_V 0x2F
|
||||
#define SCANCODE_INSERT 0x152
|
||||
#define SCANCODE_ESCAPE 0x01
|
||||
#define SCANCODE_ENTER 0x1C
|
||||
#define SCANCODE_V 0x2F
|
||||
#define SCANCODE_INSERT 0x152
|
||||
#define SCANCODE_CTRL1 0x1D
|
||||
#define SCANCODE_CTRL2 0x11D
|
||||
#define SCANCODE_SHIFT1 0x2A
|
||||
#define SCANCODE_SHIFT2 0x36
|
||||
#define SCANCODE_ALT1 0x38
|
||||
#define SCANCODE_ALT2 0x138
|
||||
|
||||
static int keyboard_buttons_down;
|
||||
|
||||
|
@ -50,26 +58,29 @@ static int keyboard_map_scancode(int scancode) {
|
|||
static void keyboard_alter_text_input_modifier(int scancode, bool down) {
|
||||
if (down) {
|
||||
switch (scancode) {
|
||||
case 0x1D: held_ctrl |= (1 << 0); break;
|
||||
case 0x11D: held_ctrl |= (1 << 1); break;
|
||||
case 0x2A: held_shift |= (1 << 0); break;
|
||||
case 0x36: held_shift |= (1 << 1); break;
|
||||
case 0x38: held_alt |= (1 << 0); break;
|
||||
case 0x138: held_alt |= (1 << 1); break;
|
||||
case SCANCODE_CTRL1: held_ctrl |= (1 << 0); break;
|
||||
case SCANCODE_CTRL2: held_ctrl |= (1 << 1); break;
|
||||
case SCANCODE_SHIFT1: held_shift |= (1 << 0); break;
|
||||
case SCANCODE_SHIFT2: held_shift |= (1 << 1); break;
|
||||
case SCANCODE_ALT1: held_alt |= (1 << 0); break;
|
||||
case SCANCODE_ALT2: held_alt |= (1 << 1); break;
|
||||
}
|
||||
} else {
|
||||
switch (scancode) {
|
||||
case 0x1D: held_ctrl &= ~(1 << 0); break;
|
||||
case 0x11D: held_ctrl &= ~(1 << 1); break;
|
||||
case 0x2A: held_shift &= ~(1 << 0); break;
|
||||
case 0x36: held_shift &= ~(1 << 1); break;
|
||||
case 0x38: held_alt &= ~(1 << 0); break;
|
||||
case 0x138: held_alt &= ~(1 << 1); break;
|
||||
case SCANCODE_CTRL1: held_ctrl &= ~(1 << 0); break;
|
||||
case SCANCODE_CTRL2: held_ctrl &= ~(1 << 1); break;
|
||||
case SCANCODE_SHIFT1: held_shift &= ~(1 << 0); break;
|
||||
case SCANCODE_SHIFT2: held_shift &= ~(1 << 1); break;
|
||||
case SCANCODE_ALT1: held_alt &= ~(1 << 0); break;
|
||||
case SCANCODE_ALT2: held_alt &= ~(1 << 1); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool keyboard_on_key_down(int scancode) {
|
||||
#ifdef DEBUG
|
||||
debug_keyboard_on_key_down(scancode);
|
||||
#endif
|
||||
if (inTextInput) {
|
||||
// alter the held value of modifier keys
|
||||
keyboard_alter_text_input_modifier(scancode, true);
|
||||
|
@ -234,16 +245,7 @@ static void keyboard_init(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void debug_breakpoint_here(void) {
|
||||
// create easy breakpoint position for debugging
|
||||
}
|
||||
|
||||
static void keyboard_read(OSContPad *pad) {
|
||||
// create easy breakpoint position for debugging
|
||||
if (keyboard_buttons_down & L_TRIG) {
|
||||
debug_breakpoint_here();
|
||||
}
|
||||
|
||||
pad->button |= keyboard_buttons_down;
|
||||
const u32 xstick = keyboard_buttons_down & STICK_XMASK;
|
||||
const u32 ystick = keyboard_buttons_down & STICK_YMASK;
|
||||
|
|
101
src/pc/controller/controller_keyboard_debug.c
Normal file
101
src/pc/controller/controller_keyboard_debug.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include "controller_keyboard_debug.h"
|
||||
#include "game/level_update.h"
|
||||
#include "game/camera.h"
|
||||
#include "pc/network/network.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static u8 warpToLevel = LEVEL_BITDW;
|
||||
|
||||
#define SCANCODE_3 0x04
|
||||
#define SCANCODE_6 0x07
|
||||
#define SCANCODE_7 0x08
|
||||
|
||||
static void debug_breakpoint_here(void) {
|
||||
// create easy breakpoint position for debugging
|
||||
}
|
||||
|
||||
static void debug_warp_level(u8 level) {
|
||||
if (sCurrPlayMode == PLAY_MODE_CHANGE_LEVEL) { return; }
|
||||
if (sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) { return; }
|
||||
|
||||
// find level from painting
|
||||
for (int i = 0; i < 45; i++) {
|
||||
struct WarpNode* node = &gCurrentArea->paintingWarpNodes[i];
|
||||
if (node == NULL) { break; }
|
||||
if (node->destLevel == level) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
sWarpDest.levelNum = node->destLevel;
|
||||
sWarpDest.areaIdx = node->destArea;
|
||||
sWarpDest.nodeId = node->destNode;
|
||||
sWarpDest.arg = 0;
|
||||
|
||||
sCurrPlayMode = (gNetworkType != NT_NONE) ? PLAY_MODE_SYNC_LEVEL : PLAY_MODE_CHANGE_LEVEL;
|
||||
network_send_level_warp_begin();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
struct ObjectWarpNode* objectNode = gCurrentArea->warpNodes;
|
||||
while (objectNode != NULL) {
|
||||
struct WarpNode* node = &objectNode->node;
|
||||
if (node->destLevel == level) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
sWarpDest.levelNum = node->destLevel;
|
||||
sWarpDest.areaIdx = node->destArea;
|
||||
sWarpDest.nodeId = node->destNode;
|
||||
sWarpDest.arg = 0;
|
||||
|
||||
sCurrPlayMode = (gNetworkType != NT_NONE) ? PLAY_MODE_SYNC_LEVEL : PLAY_MODE_CHANGE_LEVEL;
|
||||
network_send_level_warp_begin();
|
||||
return;
|
||||
}
|
||||
objectNode = objectNode->next;
|
||||
}
|
||||
|
||||
// failed, go to main castle area
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
sWarpDest.levelNum = LEVEL_CASTLE;
|
||||
sWarpDest.areaIdx = 1;
|
||||
sWarpDest.nodeId = 0x1F;
|
||||
sWarpDest.arg = 0;
|
||||
sCurrPlayMode = PLAY_MODE_SYNC_LEVEL;
|
||||
D_80339ECA = 0;
|
||||
D_80339EE0 = 0;
|
||||
extern s16 gSavedCourseNum;
|
||||
gSavedCourseNum = 0;
|
||||
network_send_level_warp_begin();
|
||||
}
|
||||
|
||||
static void debug_warp_area() {
|
||||
if (sCurrPlayMode == PLAY_MODE_CHANGE_LEVEL) { return; }
|
||||
if (sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) { return; }
|
||||
|
||||
struct ObjectWarpNode* objectNode = gCurrentArea->warpNodes;
|
||||
while (objectNode != NULL) {
|
||||
struct WarpNode* node = &objectNode->node;
|
||||
if (node->destLevel == gCurrLevelNum && node->destArea != gCurrAreaIndex) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_AREA;
|
||||
sWarpDest.levelNum = node->destLevel;
|
||||
sWarpDest.areaIdx = node->destArea;
|
||||
sWarpDest.nodeId = node->destNode;
|
||||
sWarpDest.arg = 0;
|
||||
|
||||
sCurrPlayMode = (gNetworkType != NT_NONE) ? PLAY_MODE_SYNC_LEVEL : PLAY_MODE_CHANGE_LEVEL;
|
||||
network_send_level_warp_begin();
|
||||
return;
|
||||
}
|
||||
objectNode = objectNode->next;
|
||||
}
|
||||
}
|
||||
|
||||
void debug_keyboard_on_key_down(int scancode) {
|
||||
scancode = scancode;
|
||||
switch (scancode) {
|
||||
case SCANCODE_3: debug_breakpoint_here(); break;
|
||||
case SCANCODE_6: debug_warp_level(warpToLevel); break;
|
||||
case SCANCODE_7: debug_warp_area(); break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
8
src/pc/controller/controller_keyboard_debug.h
Normal file
8
src/pc/controller/controller_keyboard_debug.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef CONTROLLER_KEYBOARD_DEBUG_H
|
||||
#define CONTROLLER_KEYBOARD_DEBUG_H
|
||||
#ifdef DEBUG
|
||||
|
||||
void debug_keyboard_on_key_down(int scancode);
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -44,7 +44,6 @@ static void populate_packet_data(struct PacketLevelWarpData* data, bool done, u8
|
|||
}
|
||||
|
||||
void network_send_level_warp_begin(void) {
|
||||
assert(!isInWarp);
|
||||
isInWarp = TRUE;
|
||||
savedWarpNode = sWarpDest;
|
||||
saved_D_80339EE0 = D_80339EE0;
|
||||
|
|
Loading…
Reference in a new issue