-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgwdecode.h
144 lines (106 loc) · 2.58 KB
/
gwdecode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef GWDECODE_H
#define GWDECODE_H
#ifdef __cplusplus
extern "C" {
#endif
// All needed?
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include "crc.h"
#include "gw.h"
#include "gwx.h"
#include "gwmedia.h"
#include "secsize.h"
#include "dmk.h"
#include "msg_levels.h"
#include "msg.h"
/*
* Flux decoder
*
* XXX Anything converting flux to bytes goes here.
*/
struct fdecoder
{
uint32_t sample_freq;
uint64_t accum;
uint64_t taccum; /* Transform accumulator for RX02 */
int bit_cnt;
int premark;
unsigned int quirk;
int reverse_sides;
int usr_encoding; /* From user args. */
int first_encoding; /* Encoding to try on the next track */
int cur_encoding;
int mark_after;
int sizecode;
int maxsecsize;
bool awaiting_iam;
bool awaiting_dam;
/* bit counter, >0 if we may be in a write splice */
int write_splice;
int backward_am;
int flippy;
int use_hole; /* From user args. */
uint8_t curcyl;
uint8_t cyl_seen;
uint8_t cyl_prev_seen;
uint16_t crc;
int ibyte; /* Index byte count */
int dbyte; /* Data byte count */
int ebyte; /* Extra CRC byte count */
int index_edge;
unsigned int revs_seen;
uint32_t total_ticks;
uint32_t index[2];
};
/*
* DMK state machine
*
* Anything above byte level goes here.
*/
struct dmk_track_sm {
struct dmk_disk_stats *dds;
struct dmk_header *header;
struct dmk_track *trk_merged;
struct dmk_track_stats *trk_merged_stats;
uint16_t *idam_p;
uint8_t *track_data_p;
uint8_t *track_hole_p;
struct dmk_track trk_working;
struct dmk_track_stats trk_working_stats;
int valid_id;
int dmk_ignored;
int dmk_full;
/* From user args. */
int dmk_iam_pos;
int dmk_ignore;
int accum_sectors;
};
struct flux2dmk_sm {
struct fdecoder fdec;
struct dmk_track_sm dtsm;
};
extern const char *encoding_name(int encoding);
extern void fdecoder_init(struct fdecoder *fdec, uint32_t sample_freq);
extern void dmk_track_sm_init(struct dmk_track_sm *dtsm,
struct dmk_disk_stats *dds,
struct dmk_header *dmkh,
struct dmk_track *trk_merged,
struct dmk_track_stats *trk_merged_stats);
extern int gwflux_decode_pulse(uint32_t pulse,
struct gw_media_encoding *gme,
struct flux2dmk_sm *f2dsm);
extern void gw_decode_flush(struct flux2dmk_sm *f2dsm);
extern int gwflux_decode_index(uint32_t imark, struct flux2dmk_sm *f2dsm);
extern void gw_post_process_track(struct flux2dmk_sm *f2dsm);
#ifdef __cplusplus
}
#endif
#endif