2 * BUBBLE CASETTE for FM-8/7? [bubblecasette.h]
4 * Author: K.Ohta <whatisthis.sowhat _at_ gmail.com>
7 * Mar 22, 2016 : Initial
11 #ifndef _VM_FM_BUBBLECASETTE_H_
12 #define _VM_FM_BUBBLECASETTE_H_
15 #include "../device.h"
16 #include "../../common.h"
33 BUBBLE_TYPE_128KB = 1,
45 class BUBBLECASETTE: public DEVICE
52 bool header_changed; // if change header: e.g:change write protection flag.
62 // FD12(RO) : Positive logic
63 bool cmd_error; // bit7 : Command error
64 bool stat_tdra; // bit6: Ready to write.
65 bool stat_rda; // bit5: Ready to read.
66 bool not_ready; // bit4: Not Ready(Slot empty).
68 bool write_protect; // bit2
69 bool stat_error; // bit 1
70 bool stat_busy; // bit 0
72 // FD13(RO): Maybe positive
73 bool eject_error; // bit7
74 bool povr_error; // bit5 : Page over
75 bool crc_error; // bit4
76 bool transfer_error; // bit3
77 bool bad_loop_over_error; // bit2
78 bool no_marker_error; // bit1
79 bool undefined_cmd_error; // bit0
81 //FD14-FD15: Page address register
82 pair_t page_address; // 16bit, Big ENDIAN
83 // FD16-FD17: Page Count Resister
84 pair_t page_count; // 16bit, Big ENDIAN
90 bbl_header_t bbl_header;
91 uint32_t media_offset;
92 uint32_t media_offset_new;
96 uint8_t bubble_data[0x20000]; // MAX 128KB, normally 32KB at FM-8.
97 _TCHAR image_path[_MAX_PATH];
99 void bubble_command(uint8_t cmd);
100 bool read_header(void);
101 void write_header(void);
102 bool read_one_page(void);
103 bool write_one_page(void);
106 BUBBLECASETTE(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
109 memset(image_path, 0x00, _MAX_PATH * sizeof(_TCHAR));
111 memset(&bbl_header, 0x00, sizeof(bbl_header_t));
112 memset(bubble_data, 0x00, 0x20000);
113 bubble_inserted = false;
114 read_access = write_access = false;
115 set_device_name(_T("Bubble Cassette"));
123 uint32_t read_io8(uint32_t addr);
124 void write_io8(uint32_t addr, uint32_t data);
126 uint32_t read_signal(int id);
127 void write_signal(int id, uint32_t data, uint32_t mask);
128 void event_callback(int event_id, int err);
129 void save_state(FILEIO* state_fio);
130 bool load_state(FILEIO* state_fio);
133 void open(_TCHAR* file_path, int bank);
135 bool is_bubble_inserted()
137 return bubble_inserted;
139 bool is_bubble_protected()
141 return write_protect;
143 void set_bubble_protect(bool flag)
145 if(write_protect != flag) {
146 write_protect = flag;
147 header_changed = true;
150 bool get_access_lamp()
152 return (read_access | write_access);