1 /* 2 * tape.h - Tape unit emulation. 3 * 4 * Written by 5 * Jouko Valta <jopi@stekt.oulu.fi> 6 * Andreas Boose <viceteam@t-online.de> 7 * 8 * This file is part of VICE, the Versatile Commodore Emulator. 9 * See README for copyright notice. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 24 * 02111-1307 USA. 25 * 26 */ 27 28 #ifndef VICE_TAPE_H 29 #define VICE_TAPE_H 30 31 #include <stdio.h> 32 33 #include "types.h" 34 35 36 #define TAPE_TYPE_T64 0 37 #define TAPE_TYPE_TAP 1 38 39 #define TAPE_ENCODING_NONE 0 40 #define TAPE_ENCODING_CBM 1 41 #define TAPE_ENCODING_TURBOTAPE 2 42 43 #define TAPE_CAS_TYPE_BAS 1 /* Relocatable Program */ 44 #define TAPE_CAS_TYPE_PRG 3 /* Binary Program */ 45 #define TAPE_CAS_TYPE_DATA 4 /* Data Record */ 46 #define TAPE_CAS_TYPE_EOF 5 /* End of Tape marker */ 47 48 #define TAPE_BEHAVIOUR_NORMAL 0 /* tape interrupt is falling-edge triggered, normal tape blocks end with a long and a short pulse */ 49 #define TAPE_BEHAVIOUR_C16 1 /* tape senses both falling edges and rising edges, normal tape blocks end with a medium and a short pulse */ 50 51 struct trap_s; 52 53 struct tape_image_s { 54 char *name; 55 unsigned int read_only; 56 unsigned int type; 57 void *data; 58 }; 59 typedef struct tape_image_s tape_image_t; 60 61 struct tape_init_s { 62 uint16_t buffer_pointer_addr; 63 uint16_t st_addr; 64 uint16_t verify_flag_addr; 65 uint16_t irqtmp; 66 int irqval; 67 uint16_t stal_addr; 68 uint16_t eal_addr; 69 uint16_t kbd_buf_addr; 70 uint16_t kbd_buf_pending_addr; 71 const struct trap_s *trap_list; 72 int pulse_short_min; 73 int pulse_short_max; 74 int pulse_middle_min; 75 int pulse_middle_max; 76 int pulse_long_min; 77 int pulse_long_max; 78 }; 79 typedef struct tape_init_s tape_init_t; 80 81 struct tape_file_record_s { 82 uint8_t name[17]; 83 uint8_t type, encoding; 84 uint16_t start_addr; 85 uint16_t end_addr; 86 }; 87 typedef struct tape_file_record_s tape_file_record_t; 88 89 90 extern tape_image_t *tape_image_dev1; 91 92 extern int tape_init(const tape_init_t *init); 93 extern int tape_reinit(const tape_init_t *init); 94 extern void tape_shutdown(void); 95 extern int tape_deinstall(void); 96 extern void tape_get_header(tape_image_t *tape_image, uint8_t *name); 97 extern int tape_find_header_trap(void); 98 extern int tape_receive_trap(void); 99 extern int tape_find_header_trap_plus4(void); 100 extern int tape_receive_trap_plus4(void); 101 extern const char *tape_get_file_name(void); 102 extern int tape_tap_attached(void); 103 104 extern void tape_traps_install(void); 105 extern void tape_traps_deinstall(void); 106 107 extern tape_file_record_t *tape_get_current_file_record(tape_image_t *tape_image); 108 extern int tape_seek_start(tape_image_t *tape_image); 109 extern int tape_seek_to_file(tape_image_t *tape_image, unsigned int file_number); 110 extern int tape_seek_to_next_file(tape_image_t *tape_image, unsigned int allow_rewind); 111 extern int tape_read(tape_image_t *tape_image, uint8_t *buf, size_t size); 112 113 extern int tape_internal_close_tape_image(tape_image_t *tape_image); 114 extern tape_image_t *tape_internal_open_tape_image(const char *name, unsigned int read_only); 115 /* External tape image interface. */ 116 extern int tape_image_detach(unsigned int unit); 117 extern int tape_image_detach_internal(unsigned int unit); 118 extern int tape_image_attach(unsigned int unit, const char *name); 119 extern int tape_image_open(tape_image_t *tape_image); 120 extern int tape_image_close(tape_image_t *tape_image); 121 extern int tape_image_create(const char *name, unsigned int type); 122 extern void tape_image_event_playback(unsigned int unit, const char *filename); 123 124 #endif 125