OSDN Git Service

[VM][FMTONWS][DICTIONARY][CMOS] Available to use dictionary ROM.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fmtowns / towns_sysrom.cpp
1 /*
2         FUJITSU FM Towns Emulator 'eFMTowns'
3
4         Author : Kyuma.Ohta <whatisthis.sowhat _at_ gmail.com>
5         Date   : 2019.01.09-
6
7         [ SYSTEM rom & RAM area 0x000f8000 - 0x000fffff]
8         * MEMORY :
9         *   0x000f8000 - 0x000fffff : RAM / DICTIONARY (BANKED)
10         *   0xfffc0000 - 0xffffffff : SYSTEM ROM
11         * I/O : 
12         *   0x0480                         : F8 BANK
13 */
14
15 #include "./towns_common.h"
16 #include "./towns_sysrom.h"
17 #include "./towns_dictionary.h"
18 #include "../../fileio.h"
19
20 namespace FMTOWNS {
21 void SYSROM::initialize()
22 {
23         memset(rom, 0xff, sizeof(rom));
24         
25         FILEIO* fio = new FILEIO();
26         if(fio->Fopen(create_local_path(_T("FMT_SYS.ROM")), FILEIO_READ_BINARY)) { // DICTIONARIES
27                 fio->Fread(rom, sizeof(rom), 1);
28                 fio->Fclose();
29         }
30
31 }
32
33
34 void SYSROM::reset()
35 {
36 }
37         
38 uint32_t SYSROM::read_memory_mapped_io8(uint32_t addr)
39 {
40         uint8_t n_data = 0xff;
41         if(addr < 0xfffc0000) { // Banked (from MSDOS/i86 compatible mode)
42                 if((addr >= 0x000f8000) && (addr < 0x00100000)) {
43                         n_data = rom[(addr & 0x7fff) + 0x38000];
44                 }
45         } else {
46                 n_data = rom[addr & 0x3ffff];
47         }
48         return (uint32_t)n_data;
49 }
50         
51 uint32_t SYSROM::read_memory_mapped_io16(uint32_t addr)
52 {
53         pair16_t nd;
54         int dummy;
55         nd.w = 0x00;
56         // OK?
57         nd.b.l = read_memory_mapped_io8(addr + 0);
58         nd.b.h = read_memory_mapped_io8(addr + 1);
59         return nd.w;
60 }
61
62 uint32_t SYSROM::read_memory_mapped_io32(uint32_t addr)
63 {
64         pair32_t nd;
65         nd.d = 0x00;
66         // OK?
67         nd.b.l  = read_memory_mapped_io8(addr + 0);
68         nd.b.h  = read_memory_mapped_io8(addr + 1);
69         nd.b.h2 = read_memory_mapped_io8(addr + 2);
70         nd.b.h3 = read_memory_mapped_io8(addr + 3);
71         return nd.d;
72 }
73         
74 void SYSROM::write_memory_mapped_io8(uint32_t addr, uint32_t data)
75 {
76         // ADDR >= 0xfffc0000
77         return;
78 }
79
80
81 void SYSROM::write_memory_mapped_io16(uint32_t addr, uint32_t data)
82 {
83         pair16_t nd;
84         nd.w = (uint16_t)data;
85         // OK?
86         write_memory_mapped_io8(addr + 0, nd.b.l);
87         write_memory_mapped_io8(addr + 1, nd.b.h);
88 }
89
90 void SYSROM::write_memory_mapped_io32(uint32_t addr, uint32_t data)
91 {
92         pair32_t nd;
93         nd.d = data;
94         write_memory_mapped_io8(addr + 0, nd.b.l);
95         write_memory_mapped_io8(addr + 1, nd.b.h);
96         write_memory_mapped_io8(addr + 2, nd.b.h2);
97         write_memory_mapped_io8(addr + 3, nd.b.h3);
98 }
99         
100
101 }