OSDN Git Service

[VM][General] Merge Upstream 20180530.
[csp-qt/common_source_project-fm7.git] / source / src / vm / harddisk.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2006.09.16-
6
7         [ d88 image handler ]
8 */
9
10 #ifndef _HARDDISK_H_
11 #define _HARDDISK_H_
12
13 #include "../common.h"
14 //#include "vm.h"
15 //#include "../emu.h"
16
17 class FILEIO;
18 class EMU;
19 class HARDDISK
20 {
21 protected:
22         EMU* emu;
23 private:
24         FILEIO *fio;
25         int header_size;
26         
27 public:
28         HARDDISK(EMU* parent_emu)
29         {
30                 emu = parent_emu;
31                 fio = NULL;
32                 access = false;
33                 static int num = 0;
34                 drive_num = num++;
35                 set_device_name(_T("Hard Disk Drive #%d"), drive_num + 1);
36         }
37         ~HARDDISK()
38         {
39                 close();
40         }
41         
42         void open(const _TCHAR* file_path, int default_sector_size);
43         void close();
44         bool mounted();
45         bool accessed();
46         bool read_buffer(long position, int length, uint8_t *buffer);
47         bool write_buffer(long position, int length, uint8_t *buffer);
48         
49 //      int cylinders;
50         int surfaces;
51 //      int sectors;
52         int sector_size;
53         int sector_num;
54         int drive_num;
55         bool access;
56         
57         // state
58 //      void save_state(FILEIO* state_fio);
59 //      bool load_state(FILEIO* state_fio);
60         
61         // device name
62         void set_device_name(const _TCHAR* format, ...)
63         {
64                 if(format != NULL) {
65                         va_list ap;
66                         _TCHAR buffer[1024];
67                         
68                         va_start(ap, format);
69                         my_vstprintf_s(buffer, 1024, format, ap);
70                         va_end(ap);
71                         
72                         my_tcscpy_s(this_device_name, 128, buffer);
73                 }
74         }
75         const _TCHAR *get_device_name()
76         {
77                 return (const _TCHAR *)this_device_name;
78         }
79         _TCHAR this_device_name[128];
80 };
81
82 #endif
83