Code Monkey home page Code Monkey logo

es40-ng's People

Contributors

hackersmacker avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

es40-ng's Issues

8254 emulation bug (in AliM1543C.cpp)

In writing my one emulator, I discovered that there is are a number of bugs in the emulation of the Intel 8254 PIT Chip.

  1. There are 5 modes defined, but 2 of them have the high-bit being a do-not-care. So, a mode value of 2 or 6 represent Mode 2, and a mode value of 3 or 7 represent Mode 3.
  2. Modes 0, 1, 4, and 5 wrap their counters from 0 to the maximum value. Modes 2 and 3 wrap their counters from 0 to the initial value.
  3. BCD (Binary Coded Decimal) is not supported. Not sure if this is an issue in this particular emulator, but thought I'd note it.
  4. There is a PIT_FACTOR defined to 5000. I'm not sure 100% what this represents, but it is used as the decrement value. The code seems to indicate that when the counter is set to 0x0000 that this represents a timer of 18.2Hz. My calculations actually have it at 13.1Hz. Not sure if this is an issue.

Some issues I discovered when trying to build and run these files

FWIW: I'm in the process of writing a new implemenration of es40 DECaxp Emulator
Here are some issues I found (if you are interested):

  1. Using inst.sh seemed to generate code that would not run (some missing qualifiers when running configure)
  2. When running configure that are a couple of FLAGS, LD and CXX, that should probably be specified. Here are the ones I used:
    a. Non-debug: $ ./configure LDFLAGS=-pthread CXXFLAGS='-Wno-unused-result -Wno-literal-suffix -Wno-format -Wno-write-strings'
    b. Debug: $ ./configure LDFLAGS=-pthread CXXFLAGS='-Wno-unused-result -Wno-literal-suffix -Wno-format -Wno-write-strings -ggdb -Og'
  3. Below please find a git diff output to resolve some bugs and clean-up the es40_cfg executable:
diff --git a/src/DMA.cpp b/src/DMA.cpp
index d2e5a92..c263c85 100644
--- a/src/DMA.cpp
+++ b/src/DMA.cpp
@@ -185,8 +185,9 @@ u64 CDMA::ReadMem(int index, u64 address, int dsize)
 #if defined(DEBUG_DMA)
     printf("dma: read %s,%02x: %02x.   \n", DMA_INDEX(index), address, data);
 #endif
-    return data;
+    ret = data;
   }
+  return ret;
 }
 
 void CDMA::WriteMem(int index, u64 address, int dsize, u64 data)
diff --git a/src/base/Thread_POSIX.cpp b/src/base/Thread_POSIX.cpp
index b050e80..af692ae 100644
--- a/src/base/Thread_POSIX.cpp
+++ b/src/base/Thread_POSIX.cpp
@@ -217,7 +217,7 @@ void* CThreadImpl::entry(void* pThread)
        catch (CException& exc)
        {
       printf("Thread has terminated with an unexpected %s exception:\n",exc.className());
-      printf("  %s\n",exc.displayText());
+      printf("  %s\n",exc.displayText().c_str());
        }
        catch (std::exception& exc)
        {
diff --git a/src/es40-cfg.cpp b/src/es40-cfg.cpp
index 8f7ca7f..a610e9b 100644
--- a/src/es40-cfg.cpp
+++ b/src/es40-cfg.cpp
@@ -119,6 +119,7 @@ void add_disks(ShrinkingChoiceQuestion * disk_q, ostream * os)
     *os << "    " << disk_q->getAnswer() << " = " << type_q.ask() << "\n";
     *os << "    {\n";
     
+    MultipleChoiceQuestion cdrom_q;
     if (type_q.getAnswer() == "file" || type_q.getAnswer() == "device")
     {
       /* For a file or device, we need to know what
@@ -128,9 +129,19 @@ void add_disks(ShrinkingChoiceQuestion * disk_q, ostream * os)
       img_q.setQuestion("What " + type_q.getAnswer() + " should " + disk_q->getAnswer() + " use?");
       img_q.setExplanation("Enter the path to the " + type_q.getAnswer() + " to use for this disk.");
       *os << "      " << type_q.getAnswer() << " = \"" << img_q.ask() << "\";\n";
+
+      /* We need to know whether to emulate this as
+       * a cd-rom, or as a hard-disk.
+       */
+      cdrom_q.setQuestion("Should " + disk_q->getAnswer() + " be a disk or a cd-rom device?");
+      cdrom_q.setExplanation("Do you want the OS to see this " + type_q.getAnswer() + " as a hard-disk, or as a cd-rom?");
+      cdrom_q.addAnswer("disk","false","Hard-disk");
+      cdrom_q.addAnswer("cd-rom","true","CD-ROM drive");
+      cdrom_q.setDefault("disk");
+      *os << "      cdrom = " << cdrom_q.ask() << ";\n";
     }
 
-    if (type_q.getAnswer() == "file")
+    if (type_q.getAnswer() == "file" && cdrom_q.getAnswer() != "true")
     {
       /* For a file, we need to know whether to create
        * it when it doesn't exist or not.
@@ -140,6 +151,8 @@ void add_disks(ShrinkingChoiceQuestion * disk_q, ostream * os)
       create_q.setExplanation("The file will be created the first time the emulator runs.");
       create_q.addAnswer("no","no","Don't create this file");
       create_q.addAnswer("yes","yes","Create this file");
+      create_q.setDefault("yes");
+      create_q.ask();
       if (create_q.getAnswer() == "yes")
       {
         /* If we should create the file, we need to
@@ -185,17 +198,6 @@ void add_disks(ShrinkingChoiceQuestion * disk_q, ostream * os)
       *os << "      size = \"" << size_q.getAnswer() << unit_q.getAnswer() << "\";\n";
     }
 
-    /* We need to know whether to emulate this as
-     * a cd-rom, or as a hard-disk.
-     */
-    MultipleChoiceQuestion cdrom_q;
-    cdrom_q.setQuestion("Should " + disk_q->getAnswer() + " be a disk or a cd-rom device?");
-    cdrom_q.setExplanation("Do you want the OS to see this " + type_q.getAnswer() + " as a hard-disk, or as a cd-rom?");
-    cdrom_q.addAnswer("disk","false","Hard-disk");
-    cdrom_q.addAnswer("cd-rom","true","CD-ROM drive");
-    cdrom_q.setDefault("disk");
-    *os << "      cdrom = " << cdrom_q.getAnswer() << ";\n";
-
     /* We also need to know whether this is a
      * writeable or a read-only device.
      */
@@ -206,7 +208,7 @@ void add_disks(ShrinkingChoiceQuestion * disk_q, ostream * os)
     ro_q.addAnswer("yes","true","read-only");
     ro_q.setDefault("no");
 
-    if (cdrom_q.ask() == "true")
+    if (cdrom_q.getAnswer() == "true")
     {
       /* CD-ROMs are always read-only.
        */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.