annotate event_log.h @ 2228:0db9dc6a9020

Some minor refresh emulation improvements
author Michael Pavone <pavone@retrodev.com>
date Mon, 05 Sep 2022 23:37:49 -0700
parents a8af8d898a7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #ifndef EVENT_LOG_H_
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #define EVENT_LOG_H_
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 enum {
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 EVENT_FLUSH = 0,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 EVENT_ADJUST = 1,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 EVENT_PSG_REG = 2,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 EVENT_YM_REG = 3,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 EVENT_VDP_REG = 4,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 EVENT_VRAM_BYTE = 5,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 EVENT_VRAM_BYTE_DELTA = 6,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 EVENT_VRAM_BYTE_ONE = 7,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 EVENT_VRAM_BYTE_AUTO = 8,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 EVENT_VRAM_WORD = 9,
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 EVENT_VRAM_WORD_DELTA = 10,
1956
275f1c4bdb25 Netplay protocol size optimization
Michael Pavone <pavone@retrodev.com>
parents: 1947
diff changeset
16 EVENT_VDP_INTRAM = 11,
275f1c4bdb25 Netplay protocol size optimization
Michael Pavone <pavone@retrodev.com>
parents: 1947
diff changeset
17 EVENT_STATE = 12,
275f1c4bdb25 Netplay protocol size optimization
Michael Pavone <pavone@retrodev.com>
parents: 1947
diff changeset
18 EVENT_MULTI = 13
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 //14 and 15 are reserved for header types
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 };
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 #include "serialize.h"
1958
9c01945b5d20 Use zlib to compress event log streams
Mike Pavone <pavone@retrodev.com>
parents: 1957
diff changeset
23 #include "zlib/zlib.h"
2215
a8af8d898a7c Fix windows build for real
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
24 typedef struct event_reader {
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 size_t storage;
1958
9c01945b5d20 Use zlib to compress event log streams
Mike Pavone <pavone@retrodev.com>
parents: 1957
diff changeset
26 uint8_t *socket_buffer;
9c01945b5d20 Use zlib to compress event log streams
Mike Pavone <pavone@retrodev.com>
parents: 1957
diff changeset
27 size_t socket_buffer_size;
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 int socket;
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 uint32_t last_cycle;
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 uint32_t last_word_address;
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 uint32_t last_byte_address;
1956
275f1c4bdb25 Netplay protocol size optimization
Michael Pavone <pavone@retrodev.com>
parents: 1947
diff changeset
32 uint32_t repeat_delta;
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 deserialize_buffer buffer;
1958
9c01945b5d20 Use zlib to compress event log streams
Mike Pavone <pavone@retrodev.com>
parents: 1957
diff changeset
34 z_stream input_stream;
1956
275f1c4bdb25 Netplay protocol size optimization
Michael Pavone <pavone@retrodev.com>
parents: 1947
diff changeset
35 uint8_t repeat_event;
275f1c4bdb25 Netplay protocol size optimization
Michael Pavone <pavone@retrodev.com>
parents: 1947
diff changeset
36 uint8_t repeat_remaining;
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 } event_reader;
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 #include "system.h"
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 #include "render.h"
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 void event_log_file(char *fname);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 void event_log_tcp(char *address, char *port);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 void event_system_start(system_type stype, vid_std video_std, char *name);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 void event_cycle_adjust(uint32_t cycle, uint32_t deduction);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 void event_log(uint8_t type, uint32_t cycle, uint8_t size, uint8_t *payload);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 void event_vram_word(uint32_t cycle, uint32_t address, uint16_t value);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 void event_vram_byte(uint32_t cycle, uint16_t address, uint8_t byte, uint8_t auto_inc);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 void event_state(uint32_t cycle, serialize_buffer *state);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 void event_flush(uint32_t cycle);
1971
80920c21bb52 Add an event log soft flush and call it twice per frame in between hard flushes to netplay latency when there are insufficient hardware updates to flush packets in the middle of a frame
Michael Pavone <pavone@retrodev.com>
parents: 1958
diff changeset
51 void event_soft_flush(uint32_t cycle);
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 void init_event_reader(event_reader *reader, uint8_t *data, size_t size);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 void init_event_reader_tcp(event_reader *reader, char *address, char *port);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 uint8_t reader_next_event(event_reader *reader, uint32_t *cycle_out);
1957
ba06346611a1 Fix some netplay issues
Mike Pavone <pavone@retrodev.com>
parents: 1956
diff changeset
56 void reader_ensure_data(event_reader *reader, size_t bytes);
1947
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 uint8_t reader_system_type(event_reader *reader);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 void reader_send_gamepad_event(event_reader *reader, uint8_t pad, uint8_t button, uint8_t down);
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59
c36102d09351 Add missing netplay files and add in support for sending gamepad commands back to host
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 #endif //EVENT_LOG_H_