OSDN Git Service

[VM][DEVICE] Use __FASTCALL with interfaces, read_*() ,write_*(), fetch_op() and...
[csp-qt/common_source_project-fm7.git] / source / src / vm / scv / memory.h
1 /*
2         EPOCH Super Cassette Vision Emulator 'eSCV'
3
4         Author : Takeda.Toshiya
5         Date   : 2006.08.21 -
6
7         [ memory ]
8 */
9
10 #ifndef _MEMORY_H_
11 #define _MEMORY_H_
12
13 #include "../vm.h"
14 #include "../../emu.h"
15 #include "../device.h"
16
17 namespace SCV {
18
19 class MEMORY : public DEVICE
20 {
21 private:
22         DEVICE* d_sound;
23         
24         // memory
25         _TCHAR save_path[_MAX_PATH];
26         
27         struct {
28                 // Maybe should *not* be char, should be uint8_t.
29                 // Because sizeof(char) may not be 1 byte at unicode. code.20181023 K.O
30                 uint8_t id[4];  // SCV^Z
31                 uint8_t ctype;  // 0=16KB,32KB,32K+8KB ROM, bankswitched by PC5
32                                 // 1=32KB ROM+8KB SRAM, bank switched by PC5
33                                 // 2=32KB+32KB,32KB+32KB+32KB+32KB ROM, bank switched by PC5,PC6
34                                 // 3=32KB+32KB ROM, bank switched by PC6
35                 uint8_t dummy[11];
36         } header;
37         bool inserted;
38         uint32_t sram_crc32;
39         
40         uint8_t* wbank[0x200];
41         uint8_t* rbank[0x200];
42         uint8_t bios[0x1000];
43         uint8_t vram[0x2000];
44         uint8_t wreg[0x80];
45         uint8_t cart[0x8000*4];
46         uint8_t sram[0x2000];
47         uint8_t wdmy[0x80];
48         uint8_t rdmy[0x80];
49         
50         uint8_t cur_bank;
51         void __FASTCALL set_bank(uint8_t bank);
52         
53 public:
54         MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
55         {
56                 set_device_name(_T("Memory Bus"));
57         }
58         ~MEMORY() {}
59         
60         // common functions
61         void initialize();
62         void release();
63         void reset();
64         void __FASTCALL write_data8(uint32_t addr, uint32_t data);
65         uint32_t __FASTCALL read_data8(uint32_t addr);
66         void __FASTCALL write_data8w(uint32_t addr, uint32_t data, int* wait);
67         uint32_t __FASTCALL read_data8w(uint32_t addr, int* wait);
68         void __FASTCALL write_io8(uint32_t addr, uint32_t data);
69         bool process_state(FILEIO* state_fio, bool loading);
70         
71         // unique functions
72         void open_cart(const _TCHAR* file_path);
73         void close_cart();
74         bool is_cart_inserted()
75         {
76                 return inserted;
77         }
78         void set_context_sound(DEVICE* device)
79         {
80                 d_sound = device;
81         }
82         uint8_t* get_font()
83         {
84                 return bios + 0x200;
85         }
86         uint8_t* get_vram()
87         {
88                 return vram;
89         }
90 };
91
92 }
93 #endif