Skip to content

Commit

Permalink
Snap method structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Aug 24, 2024
1 parent cb19df3 commit d312c7f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/data/teeworlds.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ MSG_SYSTEM_INFO equ 1
MSG_SYSTEM_SERVERINFO equ 4
MSG_SYSTEM_CON_READY equ 5
MSG_SYSTEM_SNAP equ 6
MSG_SYSTEM_SNAPEMPTY equ 7
MSG_SYSTEM_SNAPSINGLE equ 8
MSG_SYSTEM_MAP_CHANGE equ 2
MSG_SYSTEM_READY equ 18
Expand Down
15 changes: 15 additions & 0 deletions src/on_snap.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on_snap:
; on_snap [rax] [rdi]
; rax = snapshot payload (only the data field)
; rdi = size
;
; rax should be a full snapshot payload
; and never a partial snapshot
;
; will be called when we get a MSG_SNAPSINGLE, MSG_SNAPEMPTY or the last part of MSG_SNAP
;
push_registers

pop_registers
ret

7 changes: 7 additions & 0 deletions src/on_system.asm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ on_system_message:
je on_system_msg_con_ready
cmp r9d, MSG_SYSTEM_SNAP
je on_system_msg_snap
cmp r9d, MSG_SYSTEM_SNAPEMPTY
je on_system_msg_snapempty
cmp r9d, MSG_SYSTEM_SNAPSINGLE
je on_system_msg_snapsingle

Expand Down Expand Up @@ -65,6 +67,11 @@ on_system_msg_snap:
; rax = message payload
jmp on_system_message_end

on_system_msg_snapempty:
; on_system_msg_snapempty [rax]
; rax = message payload
jmp on_system_message_end

on_system_msg_snapsingle:
; on_system_msg_snapsingle [rax]
; rax = message payload
Expand Down
7 changes: 4 additions & 3 deletions src/teeworlds_asmr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ section .text
%include "src/receive_control.asm"
%include "src/system.asm"
%include "src/packet_header.asm"
%include "src/on_packet.asm"
%include "src/on_system.asm"
%include "src/on_game.asm"
%include "src/packet_packer.asm"
%include "src/pack_int.asm"
%include "src/unpacker.asm"
%include "src/huffman/huffman.asm"
%include "src/on_packet.asm"
%include "src/on_system.asm"
%include "src/on_game.asm"
%include "src/on_snap.asm"

print_udp:
print_label s_got_udp
Expand Down
7 changes: 4 additions & 3 deletions tests/assert.asm
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ section .text
%include "src/receive_control.asm"
%include "src/system.asm"
%include "src/packet_header.asm"
%include "src/on_packet.asm"
%include "src/on_system.asm"
%include "src/on_game.asm"
%include "src/packet_packer.asm"
%include "src/pack_int.asm"
%include "src/unpacker.asm"
%include "src/huffman/huffman.asm"
%include "src/on_packet.asm"
%include "src/on_system.asm"
%include "src/on_game.asm"
%include "src/on_snap.asm"

%macro init_test 1
; init_test [__FILE__]
Expand Down

0 comments on commit d312c7f

Please sign in to comment.