annotate ppm.c @ 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
author Michael Pavone <pavone@retrodev.com>
date Fri, 08 May 2020 11:40:30 -0700
parents 5f65a16c23ff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1263
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdint.h>
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdio.h>
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 void save_ppm(FILE *f, uint32_t *buffer, uint32_t width, uint32_t height, uint32_t pitch)
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 {
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 fprintf(f, "P6\n%d %d\n255\n", width, height);
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 for(uint32_t y = 0; y < height; y++)
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 {
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 uint32_t *line = buffer;
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 for (uint32_t x = 0; x < width; x++, line++)
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 {
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 uint8_t buf[3] = {
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 *line >> 16, //red
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 *line >> 8, //green
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 *line //blue
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 };
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 fwrite(buf, 1, sizeof(buf), f);
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 }
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 buffer = buffer + pitch / sizeof(uint32_t);
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 }
5f65a16c23ff Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }