OSDN Git Service

[VM][PC9801][MEMBUS] Split update_bios() to functions.
[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         long get_cur_position();
58         int get_sector_size();
59         int get_cylinders();
60         int get_headers();
61         int get_sectors_per_cylinder();
62         int get_sector_num();
63         int get_drive_num();
64                 
65         // device name
66         void set_device_name(const _TCHAR* format, ...)
67         {
68                 if(format != NULL) {
69                         va_list ap;
70                         _TCHAR buffer[1024];
71                         
72                         va_start(ap, format);
73                         my_vstprintf_s(buffer, 1024, format, ap);
74                         va_end(ap);
75                         
76                         my_tcscpy_s(this_device_name, 128, buffer);
77                 }
78         }
79         const _TCHAR *get_device_name()
80         {
81                 return (const _TCHAR *)this_device_name;
82         }
83         _TCHAR this_device_name[128];
84 };
85
86 #endif
87