2 SHINKO SANGYO YS-6464A Emulator 'eYS-6464A'
4 Author : Takeda.Toshiya
11 #include "../../emu.h"
12 #include "../device.h"
17 #include "../memory.h"
18 #include "../pcm1bit.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 VM::VM(EMU* parent_emu) : emu(parent_emu)
31 first_device = last_device = NULL;
32 dummy = new DEVICE(this, emu); // must be 1st device
33 event = new EVENT(this, emu); // must be 2nd device
35 io = new IO(this, emu);
36 pio = new I8255(this, emu);
37 memory = new MEMORY(this, emu);
38 // pcm = new PCM1BIT(this, emu);
39 cpu = new Z80(this, emu);
41 display = new DISPLAY(this, emu);
42 keyboard = new KEYBOARD(this, emu);
45 event->set_context_cpu(cpu);
46 // event->set_context_sound(pcm);
48 // pio->set_context_port_b(pcm, SIG_PCM1BIT_SIGNAL, 0x01, 0);
49 pio->set_context_port_b(display, SIG_DISPLAY_PORT_B, 0xf0, 0);
50 pio->set_context_port_c(display, SIG_DISPLAY_PORT_C, 0xf0, 0);
51 pio->set_context_port_c(keyboard, SIG_KEYBOARD_PORT_C, 0xf0, 0);
52 keyboard->set_context_pio(pio);
55 cpu->set_context_mem(memory);
56 cpu->set_context_io(io);
57 cpu->set_context_intr(dummy);
60 memset(ram, 0, sizeof(ram));
61 memset(rom, 0xff, sizeof(rom));
63 memory->read_bios(_T("MON.ROM"), rom, sizeof(rom));
65 memory->set_memory_r(0x0000, 0x1fff, rom);
66 memory->set_memory_r(0x2000, 0x3fff, rom);
67 memory->set_memory_r(0x4000, 0x5fff, rom);
68 memory->set_memory_r(0x6000, 0x7fff, rom);
69 memory->set_memory_rw(0x8000, 0x9fff, ram);
70 memory->set_memory_rw(0xa000, 0xbfff, ram);
71 memory->set_memory_rw(0xc000, 0xdfff, ram);
72 memory->set_memory_rw(0xe000, 0xffff, ram);
75 io->set_iomap_range_w(0xf8, 0xfb, pio);
76 io->set_iomap_range_r(0xf8, 0xfb, pio);
78 // initialize all devices
79 for(DEVICE* device = first_device; device; device = device->next_device) {
87 for(DEVICE* device = first_device; device;) {
88 DEVICE *next_device = device->next_device;
95 DEVICE* VM::get_device(int id)
97 for(DEVICE* device = first_device; device; device = device->next_device) {
98 if(device->this_device_id == id) {
105 // ----------------------------------------------------------------------------
106 // drive virtual machine
107 // ----------------------------------------------------------------------------
112 for(DEVICE* device = first_device; device; device = device->next_device) {
122 // ----------------------------------------------------------------------------
124 // ----------------------------------------------------------------------------
126 void VM::draw_screen()
128 display->draw_screen();
131 // ----------------------------------------------------------------------------
133 // ----------------------------------------------------------------------------
135 void VM::initialize_sound(int rate, int samples)
137 // init sound manager
138 event->initialize_sound(rate, samples);
141 // pcm->initialize_sound(rate, 8000);
144 uint16* VM::create_sound(int* extra_frames)
146 return event->create_sound(extra_frames);
149 int VM::get_sound_buffer_ptr()
151 return event->get_sound_buffer_ptr();
154 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
158 void VM::load_binary(int drv, const _TCHAR* file_path)
161 memory->read_image(file_path, ram, sizeof(ram));
165 void VM::save_binary(int drv, const _TCHAR* file_path)
168 memory->write_image(file_path, ram, sizeof(ram));
172 bool VM::is_frame_skippable()
174 return event->is_frame_skippable();
177 void VM::update_config()
179 for(DEVICE* device = first_device; device; device = device->next_device) {
180 device->update_config();