tanks

Blow up enemy tanks using code
git clone https://git.woozle.org/neale/tanks.git

Neale Pickett  ·  2024-12-04

dump.h

 1#pragma once
 2
 3#include <stdio.h>
 4
 5#ifndef TAU
 6#define TAU 6.28318530717958647692
 7#endif
 8
 9/* Debugging */
10#define DUMPf(fmt, args...)                                                    \
11  fprintf(stderr, "%s:%s:%d " fmt "\n", __FILE__, __FUNCTION__, __LINE__,      \
12          ##args)
13#define DUMP() DUMPf("")
14#define DUMP_d(v) DUMPf("%s = %d", #v, v)
15#define DUMP_x(v) DUMPf("%s = 0x%x", #v, v)
16#define DUMP_s(v) DUMPf("%s = %s", #v, v)
17#define DUMP_c(v) DUMPf("%s = %c", #v, v)
18#define DUMP_f(v) DUMPf("%s = %f", #v, v)
19#define DUMP_p(v) DUMPf("%s = %p", #v, v)
20#define DUMP_xy(v) DUMPf("%s = (%f, %f)", #v, v[0], v[1]);
21#define DUMP_angle(v) DUMPf("%s = %.3fτ", #v, (v / TAU));
22
23/* Tektronix 4014 drawing */
24#define TEK_ENABLE "\033[?38h"
25#define TEK_DISABLE "\033\003"
26#define TEK(fmt, args...) fprintf(stderr, TEK_ENABLE fmt TEK_DISABLE, ##args)
27#define TEK_coord(x, y)                                                        \
28  ((int)y / 32) + 32, ((int)y % 32) + 96, ((int)x / 32) + 32, ((int)x % 32) + 64
29
30#define TEK_cls() TEK("\033\014")
31#define TEK_line(x1, y1, x2, y2)                                               \
32  TEK("\035%c%c%c%c%c%c%c%c", TEK_coord(x1, y1), TEK_coord(x2, y2))
33#define TEK_point(x, y) TEK("\034%c%c%c%c", TEK_coord(x, y))
34#define TEK_text(x, y, s) TEK("\035%c%c%c%c\037%s", TEK_coord(x, y), s)