Skip to content

Commit

Permalink
bytecode: Fix pausing the game being allowed server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
sgadrat committed Mar 27, 2024
1 parent de1f7f0 commit 4422130
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
7 changes: 4 additions & 3 deletions documentation/game_modes.rst
Expand Up @@ -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
=================
Expand Down
1 change: 1 addition & 0 deletions game/constants.asm
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions 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_init_msb:
.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_pre_update_msb:
.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

game_modes_gameover_msb:
.byt >game_mode_goto_gameover
.byt >game_mode_online_gameover
.byt >game_mode_arcade_gameover
.byt >game_mode_goto_gameover
8 changes: 8 additions & 0 deletions 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
.)
5 changes: 2 additions & 3 deletions game/logic/server_bytecode_extras.asm
Expand Up @@ -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
Expand Down

0 comments on commit 4422130

Please sign in to comment.