+static char* read_string(reader_t*r, state_t*state, U8 id, U8 flags)
+{
+ assert(id>=0 && id<16);
+ if(flags&FLAG_SAME_AS_LAST) {
+ assert(state->last_string[id]);
+ return state->last_string[id];
+ }
+ char*s = reader_readString(r);
+ state->last_string[id] = strdup(s);
+ return s;
+}
+static gfxcolor_t read_color(reader_t*r, state_t*s, U8 id, U8 flags)
+{
+ assert(id>=0 && id<16);
+ if(flags&FLAG_SAME_AS_LAST)
+ return s->last_color[id];
+ gfxcolor_t c = readColor(r);
+ s->last_color[id] = c;
+ return c;
+}
+static gfxmatrix_t read_matrix(reader_t*r, state_t*s, U8 id, U8 flags)
+{
+ assert(id>=0 && id<16);
+ if(flags&FLAG_SAME_AS_LAST) {
+ gfxmatrix_t m = s->last_matrix[id];
+ readXY(r, &m);
+ return m;
+ }
+ gfxmatrix_t m = readMatrix(r);
+ s->last_matrix[id] = m;
+ return m;
+}
+