nc200: Initial pass at NC200 support as well as the NC100
authorAlan Cox <alan@etchedpixels.co.uk>
Fri, 31 Oct 2014 22:59:37 +0000 (22:59 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Fri, 31 Oct 2014 22:59:37 +0000 (22:59 +0000)
Giving the floppy drive a miss as it seems to be completely undocumented
and will need research. May be easier to port CP/M 3 to it first for
investigation.

Kernel/platform-nc100/README
Kernel/platform-nc100/README.NC200 [new file with mode: 0644]
Kernel/platform-nc100/config.h
Kernel/platform-nc100/devtty.c
Kernel/platform-nc100/nc100.s

index 2696edb..988e8e3 100644 (file)
@@ -39,10 +39,14 @@ then
 dd if=myfs of=mycard.img bs=16384 seek=20 conv=notrunc
 
 
+To boot from NC100emu use nc100emu.s. Compile it with zmac and use the
+resulting nc100.cim as the bootscript for the emulator.
+
 TODO
 
 - baud rate/serial mode setting
-- RTC
+- RTC (note: the RTC only works 1900-1999 so must be rejigged to get it to
+  work 1990 - 2099)
 - driver for the power status bits
 - lots of testing
 - control doesn't seem to work ???
diff --git a/Kernel/platform-nc100/README.NC200 b/Kernel/platform-nc100/README.NC200
new file mode 100644 (file)
index 0000000..48387e3
--- /dev/null
@@ -0,0 +1,19 @@
+The NC200 differs from the NC100 in various ways we care about
+
+- Video default is at 0xE000
+- Display height is doubled
+- Display is designed for 80 column x 16 lines in 6x8 characters (we need
+  a 6x8 font and driver for this)
+- Writing 1 to 0x70 bit 0 activates the backlight, 7 deactivates it
+- The keyboard is bit 3 as before but bit 4 is now power switch rather
+  than it causing an NMI (so we can do CP/M emulation)
+- serial interrupts are bit 2 on NC200 and bit 0 on NC100
+- NC200 requires keyboard interrupts are explicitly cleared, NC100
+  doesn't in fact care (but its harmless to do so)
+- Need to mask the serial interrupt when the line driver is off (may
+  need that on NC100 too ideally)
+- The keymap is slightly different (see ZCN)
+- There is a floppy drive, but where/how its wired is undocumented it seems
+  Obvious candidates are 0x80, 0xE0 and 0xF0. All other Amstrad devices use
+  a 765 controller except the PCW16.
+
index 98e9ac0..5b6d6f3 100644 (file)
@@ -1,3 +1,6 @@
+/* NC100 or NC200 - your choice */
+#define CONFIG_NC200
+
 /* Enable to make ^Z dump the inode table for debug */
 #undef CONFIG_IDUMP
 /* Enable to make ^A drop back into the monitor */
 /* As reported to user space - 4 banks, 16K page size */
 #define CONFIG_BANKS   4
 
-/* Vt definitions */
+/* VT definitions */
+#ifdef CONFIG_NC200
+#define VT_WIDTH       120
+#define VT_HEIGHT      21
+#define VT_RIGHT       119
+#define VT_BOTTOM      20
+#else
 #define VT_WIDTH       120
 #define VT_HEIGHT      10
 #define VT_RIGHT       119
 #define VT_BOTTOM      9
+#endif
 
 #define TICKSPERSEC 100   /* Ticks per second */
 #define PROGBASE    ((char *)(0x0100))  /* also data base */
 
 /* Device parameters */
 #define NUM_DEV_TTY 3
-#define NDEVS    1        /* Devices 0..NDEVS-1 are capable of being mounted */
-                          /*  (add new mountable devices to beginning area.) */
 #define TTYDEV   BOOT_TTY /* Device used by kernel for messages, panics */
 #define NBUFS    10       /* Number of block buffers */
+#ifdef CONFIG_NC200
+#define NMOUNTS        2         /* Floppy can also be mounted */
+#else
 #define NMOUNTS         1        /* Number of mounts at a time - nothing mountable! */
+#endif
index 292510a..5c7e2ff 100644 (file)
@@ -12,6 +12,7 @@
 __sfr __at 0xC0 uarta;
 __sfr __at 0xC1 uartb;
 
+__sfr __at 0x60 irqen;
 __sfr __at 0x90 irqmap;
 
 __sfr __at 0xB0 kmap0;
@@ -49,10 +50,12 @@ int nc100_tty_open(uint8_t minor, uint16_t flag)
        err = tty_open(minor, flag);
        if (err)
                return err;
-       if (minor == 2)
+       if (minor == 2) {
                mod_control(0, 0x10);   /* turn on the line driver */
-       nap();
-       mod_control(0x06, 0x01);        /* 9600 baud */
+               nap();
+               mod_control(0x06, 0x01);        /* 9600 baud */
+               irqen = 0x0B;                   /* Allow serial interrupts */
+       }
        return (0);
 }
 
@@ -60,8 +63,10 @@ int nc100_tty_open(uint8_t minor, uint16_t flag)
 int nc100_tty_close(uint8_t minor)
 {
        tty_close(minor);
-       if (minor == 2)
+       if (minor == 2) {
+               irqen = 0x08;           /* mask serial interrupts */
                mod_control(0x10, 0);   /* turn off the line driver */
+       }
        return (0);
 }
 
@@ -95,7 +100,17 @@ void tty_putc(uint8_t minor, unsigned char c)
 /* Called to set baud rate etc */
 void tty_setup(uint8_t minor)
 {
-    minor;
+       uint16_t b;
+       if (minor == 1)
+               return;
+       b = ttydata[2].c_cflags & CBAUD;
+       if (b < B150)
+               b = B150;
+       if (b > B19200
+               b = B19200;
+       /* 0 = B150 .. 7 = B19200 in the same spacing and order as termios,
+          how convenient */
+       mod_control(b - B150, 0x7);
 }
 
 /* For the moment */
@@ -162,6 +177,33 @@ static void keyproc(void)
        }
 }
 
+#ifdef CONFIG_NC200
+static uint8_t keyboard[10][8] = {
+       {0, 0, 0, 10, '?' /*left */ ,'4', 0, 0},
+       {'9', 0, 0, 0, ' ', 27, 0,/*ctrl*/ 0/*func*/},
+       {0, '6', 0, '5', '\t', '1', 0/*sym*/, 0/*capslock*/},
+       {'d', 's', 0, 'e', 'w', 'q', '2', '3'},
+       {'f', 'r', 0, 'a', 'x', 'z', '7', '8'},
+       {'c', 'g', 'y', 't', 'v', 'b', 0, 0},
+       {'n', 'h', '/', '#', '?' /*right */ , 127, '?' /*down */ , '6'},
+       {'k', 'm', 'u', 0, '?' /*up */ , '\\', '=', 0},
+       {',', 'j', 'i', '\'', '[', ']', '-', 0},
+       {'.', 'o', 'l', ';', 'p', 8, '0', 0}
+};
+
+static uint8_t shiftkeyboard[10][8] = {
+       {0, 0, 0, 10, '?' /*left */ , '$', 0, 0},
+       {'(', 0, 0, 0, ' ', 3, 0, 0},
+       {0, '^', 0, '%', '\t', '!', 0, 0},
+       {'D', 'S', 0, 'E', 'W', 'Q', '"', '?' /* pound */ },
+       {'F', 'R', 0, 'A', 'X', 'Z', '&', '*'},
+       {'C', 'G', 'Y', 'T', 'V', 'B', 0, 0},
+       {'N', 'H', '?', '~', '?' /*right */ , 127, '?' /*down */ , '^'},
+       {'K', 'M', 'U', 0, '?' /*up */ , '|', '+', 0},
+       {'<', 'J', 'I', '@', '{', '}', '_', 0},
+       {'>', 'O', 'L', ':', 'P', 8, ')', 0 }
+};
+#else
 static uint8_t keyboard[10][8] = {
        {0, 0, 0, 10, '?' /*left */ , 0, 0, 0},
        {0, '5', 0, 0, ' ', 27, 0, 0},
@@ -187,6 +229,7 @@ static uint8_t shiftkeyboard[10][8] = {
        {'<', 'J', 'I', '@', '{', '}', '_', '*'},
        {'>', 'O', 'L', ':', 'P', 8, '(', ')'}
 };
+#endif
 
 static uint8_t capslock = 0;
 
@@ -252,7 +295,10 @@ void platform_interrupt(void)
                        keydecode();
                timer_interrupt();
        }
-
+       if (!(a & 16)) {
+               /* FIXME: Power button */
+               ;
+       }
        /* clear the mask */
        irqmap = a;
 }
index 050610a..0848583 100644 (file)
@@ -102,7 +102,7 @@ init_hardware:
             call _program_vectors
             pop hl
 
-           ld a, #0x0B                 ; irqs on except for parallel
+           ld a, #0x08                 ; keyboard IRQ only
            out (0x60), a               ; set up
            xor a
            out (0x90), a
@@ -381,7 +381,7 @@ addr_de:
            rr  d       ; roll two bits into D
            srl a
            rr  d
-           add #0x70   ; screen start
+           add #VIDEO_BASE_H   ; screen start (0x7000 or 0x6000 for NC200)
            ld  e, d
            ld  d, a
            ret