fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/utils/pri/text.h *
7 * Created: 2017-10-28 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2017-2024 Hampa Hug <hampa@hampa.ch> *
9 *****************************************************************************/
10
11/*****************************************************************************
12 * This program is free software. You can redistribute it and / or modify it *
13 * under the terms of the GNU General Public License version 2 as published *
14 * by the Free Software Foundation. *
15 * *
16 * This program is distributed in the hope that it will be useful, but *
17 * WITHOUT ANY WARRANTY, without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
19 * Public License for more details. *
20 *****************************************************************************/
21
22
23#ifndef PRI_TEXT_H
24#define PRI_TEXT_H 1
25
26
27#include <config.h>
28
29#include <stdio.h>
30
31#include <drivers/pri/pri.h>
32#include <lib/text.h>
33
34
35typedef struct {
36 unsigned long pos;
37 char wrap;
38 pri_evt_t *evt;
39} pri_text_pos_t;
40
41
42typedef struct {
43 pce_text_t txt;
44
45 pri_img_t *img;
46 pri_trk_t *trk;
47 unsigned long c;
48 unsigned long h;
49 unsigned s;
50
51 unsigned long track_size;
52
53 unsigned long bit_cnt;
54 unsigned long bit_max;
55
56 unsigned long shift;
57 unsigned shift_cnt;
58
59 char free_track;
60
61 unsigned char last_val;
62
63 unsigned short encoding;
64
65 unsigned long index_position;
66 unsigned long rotate;
67
68 unsigned long offset;
69
70 unsigned column;
71 char need_nl;
72
73 unsigned mac_gap_size;
74 char mac_check_active;
75 unsigned mac_check_cnt;
76 unsigned char mac_check_buf[3];
77 unsigned short mac_check_chk[3];
78 unsigned mac_align;
79 char mac_no_slip;
80 char mac_nibble;
81
82 unsigned short crc;
83} pri_text_t;
84
85
86void txt_save_pos (const pri_text_t *ctx, pri_text_pos_t *pos);
87void txt_restore_pos (pri_text_t *ctx, const pri_text_pos_t *pos);
88
89int txt_dec_match (pri_text_t *ctx, const void *buf, unsigned cnt);
90
91void txt_dec_bits (pri_text_t *ctx, unsigned cnt);
92void txt_dec_event (pri_text_t *ctx, unsigned long type, unsigned long val);
93
94int txt_enc_bits_raw (pri_text_t *ctx, unsigned long val, unsigned cnt);
95
96int txt_raw_dec_track (pri_text_t *ctx);
97int txt_fm_dec_track (pri_text_t *ctx);
98int txt_mfm_dec_track (pri_text_t *ctx);
99int txt_mac_dec_track (pri_text_t *ctx);
100
101int txt_encode_pri0_fm (pri_text_t *ctx);
102int txt_encode_pri0_mfm (pri_text_t *ctx);
103int txt_encode_pri0_mac (pri_text_t *ctx);
104int txt_encode_pri0_raw (pri_text_t *ctx);
105
106
107#endif