OSDN Git Service

[VM][DEVICE] Selectable building separating or not separating.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 8 Feb 2017 05:32:28 +0000 (14:32 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 8 Feb 2017 05:32:28 +0000 (14:32 +0900)
source/src/vm/CMakeLists.txt
source/src/vm/device.h
source/src/vm/event.cpp
source/src/vm/event.h
source/src/vm/hd63484.h
source/src/vm/i386.h
source/src/vm/mb8877.cpp

index d006b7d..0aebd84 100644 (file)
@@ -4,5 +4,4 @@ message("* vm")
 
 add_library(vm_vm
   ${VMFILES}
-  device.cpp
   )
index 2a6d74c..468a86b 100644 (file)
@@ -19,6 +19,8 @@
 #define USE_DEVICE_NAME
 #endif
 
+#if defined(USE_DEVICES_SHARED_LIB)
+#include "libcpu_newdev/device.h"
 // max devices connected to the output port
 #define MAX_OUTPUT     16
 
@@ -47,8 +49,6 @@
 #define SIG_SCSI_ACK           309
 #define SIG_SCSI_RST           310
 
-#if defined(USE_DEVICES_SHARED_LIB)
-#include "libcpu_newdev/device.h"
 #else
 class DEVICE
 {
index 5b7df9c..86000d1 100644 (file)
@@ -6,7 +6,10 @@
 
        [ event manager ]
 */
-
+#if defined(USE_DEVICES_SHARED_LIB)
+#include "vm.h"
+#include "../emu.h"
+#endif
 #include "event.h"
 #if defined(_USE_QT)                   
 #include "../qt/gui/csp_logger.h"
@@ -91,7 +94,7 @@ void EVENT::drive()
        for(int i = 0; i < frame_event_count; i++) {
                frame_event[i]->event_pre_frame();
        }
-       
+
        // generate clocks per line
        if(frames_per_sec != next_frames_per_sec || lines_per_frame != next_lines_per_frame) {
                frames_per_sec = next_frames_per_sec;
@@ -187,7 +190,6 @@ void EVENT::drive()
 void EVENT::update_event(int clock)
 {
        uint64_t event_clocks_tmp = event_clocks + clock;
-       
        while(first_fire_event != NULL && first_fire_event->expired_clock <= event_clocks_tmp) {
                event_t *event_handle = first_fire_event;
                uint64_t expired_clock = event_handle->expired_clock;
index 167b882..ee532ea 100644 (file)
 #ifndef _EVENT_H_
 #define _EVENT_H_
 
+#if defined(USE_DEVICES_SHARED_LIB)
 #include "vm.h"
 #include "../emu.h"
+#endif
 #include "device.h"
 
 #define MAX_CPU                8
@@ -112,7 +114,7 @@ public:
                lines_per_frame = 0;
                next_frames_per_sec = FRAMES_PER_SEC;
                next_lines_per_frame = LINES_PER_FRAME;
-               
+
 #ifdef _DEBUG_LOG
                initialize_done = false;
 #endif
@@ -195,6 +197,7 @@ public:
                if(dcount_sound < MAX_SOUND) {
                        d_sound[dcount_sound++] = device;
                }
+               printf("SOUND %d\n", dcount_sound);
        }
        void touch_sound(void)
        {
@@ -204,8 +207,8 @@ public:
                        // Do need mix_sound(remain_samples) before?
                        if(t_s >= (sound_tmp_samples - buffer_ptr)) t_s = sound_tmp_samples - buffer_ptr - 1; 
                        if(t_s > 0) {
-                                       mix_sound(t_s);
-                                       mix_counter = mix_counter - t_s;
+                               mix_sound(t_s);
+                               mix_counter = mix_counter - t_s;
                        }
                        if(mix_counter < 1) mix_counter = 1;
                        sound_touched = true;
index 9f1fbf8..24e039d 100644 (file)
@@ -11,8 +11,8 @@
 #ifndef _HD63484_H_
 #define _HD63484_H_
 
-//#include "vm.h"
-//#include "../emu.h"
+#include "vm.h"
+#include "../emu.h"
 #include "device.h"
 
 class VM;
index e1511c0..6fb684f 100644 (file)
 
 #ifndef _I386_H_ 
 #define _I386_H_
-
+#if defined(USE_DEVICES_SHARED_LIB)
+//#if 0
+#include "libcpu_newdev/i386.h"
+#else
 #include "vm.h"
 #include "../emu.h"
 #include "device.h"
@@ -146,5 +149,5 @@ public:
        void set_shutdown_flag(int shutdown);
        int get_shutdown_flag();
 };
-
+#endif
 #endif
index 5d2cd29..00ccafb 100644 (file)
@@ -1657,7 +1657,7 @@ bool MB8877::load_sound_data(int type, const _TCHAR *pathname)
                        snd_seek_samples_size = dst_size;
                        break;
                case MB8877_SND_TYPE_HEAD: // HEAD
-                       snd_seek_data = (int16_t *)malloc(alloc_size);
+                       snd_head_data = (int16_t *)malloc(alloc_size);
                        memcpy(snd_head_data, data, utl_size);
                        strncpy(snd_head_name, pathname, 511);
                        snd_head_samples_size = dst_size;
@@ -1699,7 +1699,7 @@ bool MB8877::reload_sound_data(int type)
                if(snd_seek_data != NULL) free(snd_seek_data);
                break;
        case MB8877_SND_TYPE_HEAD:
-               if(snd_seek_data != NULL) free(snd_seek_data);
+               if(snd_head_data != NULL) free(snd_head_data);
                break;
        default:
                return false;
@@ -1717,6 +1717,8 @@ void MB8877::mix_main(int32_t *dst, int count, int16_t *src, int *table, int sam
        int i, j, k;
        int32_t data[2];
        int32_t *dst_tmp;
+       if((dst == NULL) || (src == NULL)) return;
+       if((count <= 0) || (samples <= 0)) return;
        for(i=0; i < MB8877_SND_TBL_MAX; i++) {
                ptr = table[i];
                if(ptr >= 0) {