From 44221306a4430986d0142c0be42e5e67ad0a7d21 Mon Sep 17 00:00:00 2001 From: Sylvain Gadrat Date: Wed, 27 Mar 2024 22:33:55 +0100 Subject: [PATCH] bytecode: Fix pausing the game being allowed server-side --- documentation/game_modes.rst | 7 ++++--- game/constants.asm | 1 + game/logic/game_states/game/game.asm | 7 +++++++ game/logic/game_states/game/game_mode_server.asm | 8 ++++++++ game/logic/server_bytecode_extras.asm | 5 ++--- 5 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 game/logic/game_states/game/game_mode_server.asm diff --git a/documentation/game_modes.rst b/documentation/game_modes.rst index 1de5e3de..7b95e634 100644 --- a/documentation/game_modes.rst +++ b/documentation/game_modes.rst @@ -8,9 +8,10 @@ Game modes are a series of hooks that can modify ingame state's behavior. Currently implemented game modes ================================ - * ``local``: Handles the pause and the AI - * ``online``: Handles netcode - * ``arcade``: Handles the pause, the AI, break the target, and run to exit + * ``local``: Handles the pause and the AI. + * ``online``: Handles netcode. + * ``arcade``: Handles the pause, the AI, break the target, and run to exit. + * ``server``: Like ``local``, without pause nor AI. Used to simulate an ``online`` game server-side. Memory allocation ================= diff --git a/game/constants.asm b/game/constants.asm index f8712877..ebbab9dd 100644 --- a/game/constants.asm +++ b/game/constants.asm @@ -32,6 +32,7 @@ DEFAULT_GRAVITY = $0200 GAME_MODE_LOCAL = $00 GAME_MODE_ONLINE = $01 GAME_MODE_ARCADE = $02 +GAME_MODE_SERVER = $03 ; States that may be started by external code, they must have a referenced start_routine PLAYER_STATE_THROWN = $00 diff --git a/game/logic/game_states/game/game.asm b/game/logic/game_states/game/game.asm index 0021b366..ab55a908 100644 --- a/game/logic/game_states/game/game.asm +++ b/game/logic/game_states/game/game.asm @@ -1,33 +1,40 @@ #include "game/logic/game_states/game/game_logic.asm" #include "game/logic/game_states/game/game_mode_local.asm" #include "game/logic/game_states/game/game_mode_online.asm" +#include "game/logic/game_states/game/game_mode_server.asm" game_modes_init_lsb: .byt game_mode_local_init .byt >game_mode_online_init .byt >game_mode_arcade_init +.byt >game_mode_server_init game_modes_pre_update_lsb: .byt game_mode_local_pre_update .byt >game_mode_online_pre_update .byt >game_mode_arcade_pre_update +.byt >game_mode_server_pre_update game_modes_gameover_lsb: .byt game_mode_goto_gameover .byt >game_mode_online_gameover .byt >game_mode_arcade_gameover +.byt >game_mode_goto_gameover diff --git a/game/logic/game_states/game/game_mode_server.asm b/game/logic/game_states/game/game_mode_server.asm new file mode 100644 index 00000000..e4dba1c3 --- /dev/null +++ b/game/logic/game_states/game/game_mode_server.asm @@ -0,0 +1,8 @@ +game_mode_server_init = dummy_routine + +game_mode_server_pre_update: +.( + ; Return without skipping the frame + clc + rts +.) diff --git a/game/logic/server_bytecode_extras.asm b/game/logic/server_bytecode_extras.asm index 6c4953a1..af92243c 100644 --- a/game/logic/server_bytecode_extras.asm +++ b/game/logic/server_bytecode_extras.asm @@ -29,9 +29,8 @@ server_bytecode_init: lda #3 sta config_initial_stocks - lda #0 - sta config_ai_level - sta config_game_mode ; 0 is local, we don't want online (1) as it implies input-lag and ignoring controller B + lda #GAME_MODE_SERVER + sta config_game_mode lda #1 sta network_rollback_mode