OSDN Git Service

[VM][M23] Update M23 to upstream.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 18 Jan 2023 05:25:43 +0000 (14:25 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 18 Jan 2023 05:25:43 +0000 (14:25 +0900)
17 files changed:
source/src/vm/m23/apu.cpp
source/src/vm/m23/apu.h
source/src/vm/m23/beep.cpp
source/src/vm/m23/beep.h
source/src/vm/m23/display.cpp
source/src/vm/m23/display.cpp.bak [deleted file]
source/src/vm/m23/display.h
source/src/vm/m23/floppy.cpp
source/src/vm/m23/floppy.h
source/src/vm/m23/iobus.cpp
source/src/vm/m23/iobus.h
source/src/vm/m23/keyboard.cpp
source/src/vm/m23/keyboard.h
source/src/vm/m23/m23.cpp
source/src/vm/m23/m23.h
source/src/vm/m23/membus.cpp
source/src/vm/m23/membus.h

index 0c8f9e1..19c9918 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index 40fe5b5..104d966 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index d6ae76b..be95698 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index 245fcc7..34307b4 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index 6d928d3..83b2db2 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
diff --git a/source/src/vm/m23/display.cpp.bak b/source/src/vm/m23/display.cpp.bak
deleted file mode 100644 (file)
index bbe58fd..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
-       SORD M23 Emulator 'Emu23'
-
-       Author : Takeda.Toshiya
-       Date   : 2022.05.21-
-
-       [ display ]
-*/
-
-#include "display.h"
-
-void DISPLAY::initialize()
-{
-       // load rom image
-       memset(font, 0x00, sizeof(font));
-       FILEIO* fio = new FILEIO();
-       if(fio->Fopen(create_local_path("FONT.ROM"), FILEIO_READ_BINARY)) {
-               fio->Fread(font, 0x800, 1);
-               memcpy(font + 0x800, font, 0x800);
-               fio->Fread(font + 0x800, 0x800, 1);
-               fio->Fclose();
-       }
-       delete fio;
-       
-       // create pc palette
-       for(int i = 1; i < 8; i++) {
-               if(config.monitor_type == 1) {
-                       palette_pc[i] = RGB_COLOR(0, 255, 0);
-               } else {
-                       palette_pc[i] = RGB_COLOR((i & 1) ? 255 : 0, (i & 2) ? 255 : 0, (i & 4) ? 255 : 0);
-               }
-       }
-       palette_pc[0] = 0;
-       
-       // initialize
-       vd_control = 1;
-       
-       // register event
-       register_frame_event(this);
-}
-
-uint32_t DISPLAY::read_io8(uint32_t addr)
-{
-       switch(addr & 0xff) {
-       case 0xd7:
-               return vd_control;
-       }
-       return 0xff;
-}
-
-void DISPLAY::write_io8(uint32_t addr, uint32_t data)
-{
-       switch(addr & 0xff) {
-       case 0xd7:
-               // bit1: 0=25lines,1=20lines
-               // bit2: 0=Text,1=Graph
-               // bit4: R
-               // bit5: G
-               // bit6: B
-               vd_control = data;
-               break;
-       }
-}
-
-void DISPLAY::event_frame()
-{
-       cblink = (cblink + 1) & 0x1f;
-}
-
-void DISPLAY::draw_screen()
-{
-       memset(screen, (vd_control >> 4) & 7, sizeof(screen));
-       
-       if((regs[8] & 0x30) != 0x30 && (vd_control & 1) != 0) {
-               if(vd_control & 4) {
-                       //draw_graph();
-               } else {
-                       draw_text();
-               }
-       }
-       
-       // copy to real screen
-       emu->set_vm_screen_lines(200);
-       
-       for(int y = 0; y < 200; y++) {
-               scrntype_t* dest0 = emu->get_screen_buffer(y * 2 + 0);
-               scrntype_t* dest1 = emu->get_screen_buffer(y * 2 + 1);
-               uint8_t* src = screen[y];
-               
-               for(int x = 0; x < 640; x++) {
-                       dest0[x] = palette_pc[src[x] & 7];
-               }
-               if(config.scan_line) {
-//                     for(int x = 0; x < 640; x++) {
-//                             dest1[x] = palette_pc[0];
-//                     }
-                       memset(dest1, 0, 640 * sizeof(scrntype_t));
-               } else {
-                       my_memcpy(dest1, dest0, 640 * sizeof(scrntype_t));
-               }
-       }
-       emu->screen_skip_line(true);
-}
-
-void DISPLAY::draw_text()
-{
-       uint16_t src = ((regs[12] << 8) | regs[13]) & 0x7ff;
-       int hz = (regs[1] <= 80) ? regs[1] : 80;
-       int vt = (regs[6] <= 25) ? regs[6] : 25;
-       int ht = ((regs[9] <= 9) ? regs[9] : 9) + 1;
-       uint8_t bp = regs[10] & 0x60;
-       int cursor = -1;
-       
-       if((regs[8] & 0xc0) != 0xc0) {
-               cursor = ((regs[14] << 8) | regs[15]) & 0x7ff;
-       }
-       for(int y = 0; y < vt; y++) {
-               for(int x = 0; x < hz; x++) {
-                       uint8_t code = vram_t[src];
-                       uint8_t attr = vram_a[src];
-                       
-                       // check attribute
-                       bool reverse = ((attr & 0x01) != 0);
-                       bool under_line = ((attr & 0x04) != 0);
-                       bool ascii = ((attr & 0x08) != 0);
-                       uint8_t color = (attr >> 4) & 7;
-                       uint8_t pattern;
-                       
-                       // draw pattern
-                       for(int l = 0; l < ht; l++) {
-                               if(under_line && l == ((vd_control & 2) ? 8 : 7)) {
-                                       pattern = 0xff;
-                               } else {
-                                       pattern = (l < 8) ? font[(ascii ? 0x800 : 0) | ((code << 3) + l)] : 0;
-                               }
-                               pattern = reverse ? ~pattern : pattern;
-                               int yy = y * ht + l;
-                               if(yy >= 200) {
-                                       break;
-                               }
-                               uint8_t* dest = &screen[yy][x << 3];
-                               
-                               dest[0] = (pattern & 0x80) ? color : dest[0];
-                               dest[1] = (pattern & 0x40) ? color : dest[1];
-                               dest[2] = (pattern & 0x20) ? color : dest[2];
-                               dest[3] = (pattern & 0x10) ? color : dest[3];
-                               dest[4] = (pattern & 0x08) ? color : dest[4];
-                               dest[5] = (pattern & 0x04) ? color : dest[5];
-                               dest[6] = (pattern & 0x02) ? color : dest[6];
-                               dest[7] = (pattern & 0x01) ? color : dest[7];
-                       }
-                       // draw cursor
-                       if(src == cursor) {
-                               int s = regs[10] & 0x1f;
-                               int e = regs[11] & 0x1f;
-                               if(bp == 0 || (bp == 0x40 && (cblink & 8)) || (bp == 0x60 && (cblink & 0x10))) {
-                                       for(int l = s; l <= e && l < ht; l++) {
-                                               int yy = y * ht + l;
-                                               if(yy < 200) {
-                                                       memset(&screen[yy][x << 3], 7, 8);
-                                               }
-                                       }
-                               }
-                       }
-                       src = (src + 1) & 0x7ff;
-               }
-       }
-}
-
-#define STATE_VERSION  1
-
-bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
-{
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
-               return false;
-       }
-       if(!state_fio->StateCheckInt32(this_device_id)) {
-               return false;
-       }
-       state_fio->StateValue(cblink);
-       state_fio->StateValue(hsync);
-       state_fio->StateValue(vsync);
-       state_fio->StateValue(display);
-       state_fio->StateValue(blink);
-       state_fio->StateValue(vd_control);
-       return true;
-}
-
index 3c9b05d..8b96810 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index ee32a11..c0f111e 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
@@ -14,25 +15,24 @@ namespace M23 {
 void FLOPPY::write_io8(uint32_t addr, uint32_t data)
 {
        switch(addr & 0xff) {
-       case 0xb5:
-       case 0xc5:
        case 0xcd:
                // bit7 : ??? (BASICで操作している 0x10,0x50,0xd0)
                // bit6 : density (0=double, 1=single)
-               // bit5 : side
+               // bit5 : side (M2-FDI-Vのみ)
                // bit4 : 1=ready ????
                // bit3 : 1=drive #4
                // bit2 : 1=drive #3
                // bit1 : 1=drive #2
                // bit0 : 1=drive #1
+               d_fdc->write_signal(SIG_MB8877_SIDEREG, data, 0x20);
+       case 0xb5:
+       case 0xc5:
                for(int drv = 0; drv < MAX_DRIVE; drv++) {
                        if(data & (1 << drv)) {
                                d_fdc->write_signal(SIG_MB8877_DRIVEREG, drv, 3);
                        }
                        d_fdc->set_drive_mfm(drv, ((data & 0x40) == 0));
                }
-               d_fdc->write_signal(SIG_MB8877_SIDEREG, data, 0x20);
-//             d_fdc->write_signal(SIG_MB8877_MOTOR, data, 0x10); // READY
                break;
        }
 }
index 777b114..b84bf39 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index e883df3..0a8fb55 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index e8a137a..cc62f89 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index e52d18f..1e9b5ed 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index dbe20e0..77b2d32 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
index 23a4347..9e4f6e0 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
@@ -53,9 +54,13 @@ using M23::MEMBUS;
 
 VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
 {
+#ifdef _M68
+       config.drive_type = 2;
+#else
        if(!(config.drive_type >= 0 && config.drive_type < 2)) {
                config.drive_type = 0;
        }
+#endif
        
        // create devices
        first_device = last_device = NULL;
@@ -125,6 +130,12 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        ctc->set_constant_clock(1, CPU_CLOCKS / 13);    // (4MHz/13分周) / CTC:2分周 / SIO:16分周 = 9600 baud
        ctc->set_constant_clock(2, 12500);              // 実測 12.49KHz
        ctc->set_constant_clock(3, 2500);               // 実測 2.499KHz
+#ifdef _M68
+       ctc2->set_constant_clock(0, CPU_CLOCKS / 13);   // 実測 307.6KHz
+       ctc2->set_constant_clock(1, CPU_CLOCKS / 13);   // (4MHz/13分周) / CTC:2分周 / SIO:16分周 = 9600 baud
+       ctc2->set_constant_clock(2, 12500);             // 実測 12.49KHz
+       ctc2->set_constant_clock(3, 2500);              // 実測 2.499KHz
+#endif
        dma->set_context_memory(memory);
        dma->set_context_io(io);
 
@@ -198,10 +209,15 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        io->set_iomap_range_rw(0xf8, 0xfb, sio);
        io->set_iomap_range_rw(0xfc, 0xff, ctc);
        
+#if defined(__GIT_REPO_VERSION)
+       set_git_repo_version(__GIT_REPO_VERSION);
+#endif
        // initialize all devices
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               device->initialize();
-       }
+       initialize_devices();
+//
+//     for(DEVICE* device = first_device; device; device = device->next_device) {
+//             device->initialize();
+//     }
        for(int drv = 0; drv < MAX_DRIVE; drv++) {
                static const struct {
                        uint8_t type;
@@ -222,12 +238,14 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
 VM::~VM()
 {
        // delete all devices
-       for(DEVICE* device = first_device; device;) {
-               DEVICE *next_device = device->next_device;
-               device->release();
-               delete device;
-               device = next_device;
-       }
+       release_devices();
+
+//     for(DEVICE* device = first_device; device;) {
+//             DEVICE *next_device = device->next_device;
+//             device->release();
+//             delete device;
+//             device = next_device;
+//     }
 }
 
 DEVICE* VM::get_device(int id)
@@ -408,23 +426,9 @@ void VM::update_config()
 
 bool VM::process_state(FILEIO* state_fio, bool loading)
 {
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+       if(!(VM_TEMPLATE::process_state_core(state_fio, loading, STATE_VERSION))) {
                return false;
        }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               const _TCHAR *name = char_to_tchar(typeid(*device).name() + 6); // skip "class "
-               int len = (int)_tcslen(name);
-               
-               if(!state_fio->StateCheckInt32(len)) {
-                       return false;
-               }
-               if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
-               if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
        return true;
 }
 
index a5f3d98..067234f 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
 #endif
 
 // device informations for virtual machine
+#if defined(_M68)
+#define FRAMES_PER_SEC         56.42
+#define LINES_PER_FRAME        432
+#define CHARS_PER_LINE         108
+#define HD46505_HORIZ_FREQ     24366
+#else
 #define FRAMES_PER_SEC         60
 #define LINES_PER_FRAME        262
 #define CHARS_PER_LINE         114
 #define HD46505_HORIZ_FREQ     15750
+#endif
 #define CPU_CLOCKS             3993600
 #define SCREEN_WIDTH           640
 #define SCREEN_HEIGHT          400
index be9decc..127b83e 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
@@ -126,8 +127,8 @@ void MEMBUS::update_bank()
                set_memory_rw(0x0000, 0xffff, ram);
        }
        if(rom_selected) {
-               set_memory_r(0x0000, 0x07ff, rom);
-               unset_memory_w(0x0000, 0x07ff);
+               set_memory_r(0x0000, sizeof(rom) - 1, rom);
+               unset_memory_w(0x0000, sizeof(rom) - 1);
        }
 }
 
index 5679447..12c3c92 100644 (file)
@@ -1,5 +1,6 @@
 /*
        SORD M23 Emulator 'Emu23'
+       SORD M68 Emulator 'Emu68'
 
        Author : Takeda.Toshiya
        Date   : 2022.05.21-
@@ -17,8 +18,12 @@ class MEMBUS : public MEMORY
 {
 private:
        uint8_t ram[0x20000];
+#if defined(_M68)
+       uint8_t rom[0x1000];
+#else
        uint8_t rom[0x800];
-       
+#endif
+
        bool rom_selected;
        bool page;
        bool page_after_jump, after_jump;