-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtap.h
115 lines (85 loc) · 2.86 KB
/
tap.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
/*
* tap.h - TAP file support.
*
* Written by
* Andreas Boose <viceteam@t-online.de>
*
* This file is part of VICE, the Versatile Commodore Emulator.
* See README for copyright notice.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA.
*
*/
#ifndef VICE_TAP_H
#define VICE_TAP_H
#include <stdio.h>
#include "types.h"
#define TAP_HDR_SIZE 20
#define TAP_HDR_MAGIC_OFFSET 0
#define TAP_HDR_VERSION 12
#define TAP_HDR_SYSTEM 13
#define TAP_HDR_LEN 16
struct tape_init_s;
struct tape_file_record_s;
typedef struct tap_s {
/* File name. */
char *file_name;
/* File descriptor. */
FILE *fd;
/* Size of the image. */
int size;
/* The TAP version byte. */
BYTE version;
/* System the image is made for. */
BYTE system;
/* Tape name. */
BYTE name[12];
/* Current file number. */
int current_file_number;
/* Position in the current file. */
int current_file_seek_position;
/* buffer for decoded content of current file */
size_t current_file_data_pos;
size_t current_file_size;
BYTE * current_file_data;
/* Header offset. */
int offset;
/* Pointer to the current file record. */
struct tape_file_record_s *tap_file_record;
/* Tape counter in machine-cycles/8 for even looong tapes */
int cycle_counter;
/* Tape length in machine-cycles/8 */
int cycle_counter_total;
/* Tape counter. */
int counter;
/* Which mode is activated? */
int mode;
/* Is the file opened read only? */
int read_only;
/* Has the tap changed? We correct the size then. */
int has_changed;
} tap_t;
extern void tap_init(const struct tape_init_s *init);
extern tap_t *tap_open(const char *name, unsigned int *read_only);
extern int tap_close(tap_t *tap);
extern int tap_create(const char *name);
extern int tap_seek_start(tap_t *tap);
extern int tap_seek_to_file(tap_t *tap, unsigned int file_number);
extern int tap_seek_to_next_file(tap_t *tap, unsigned int allow_rewind);
extern void tap_get_header(tap_t *tap, BYTE *name);
extern struct tape_file_record_s *tap_get_current_file_record(tap_t *tap);
extern int tap_read(tap_t *tap, BYTE *buf, size_t size);
#endif