From 85beae1194c7994efb04d8d82e0683c344084879 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Thu, 7 Feb 2019 08:16:46 +0100 Subject: [PATCH] PDP11: Dazzle Dart input box. --- PDP11/pdp11_daz.c | 217 +++++++++++++++++++++++++++++++++++++++++++ PDP11/pdp11_io_lib.c | 2 + PDP11/pdp11_sys.c | 2 + makefile | 2 +- 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 PDP11/pdp11_daz.c diff --git a/PDP11/pdp11_daz.c b/PDP11/pdp11_daz.c new file mode 100644 index 00000000..77f1797d --- /dev/null +++ b/PDP11/pdp11_daz.c @@ -0,0 +1,217 @@ +#ifdef USE_DISPLAY +/* pdp11_daz.c: Control box + + Copyright (c) 2018, Lars Brinkhoff + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the authors shall not be + used in advertising or otherwise to promote the sale, use or other dealings + in this Software without prior written authorization from the authors. +*/ + +#include "pdp11_defs.h" +#include "sim_video.h" + +#define TURN_RIGHT 0001 +#define TURN_LEFT 0002 +#define GO_RIGHT 0004 +#define GO_LEFT 0010 +#define GO_UP 0020 +#define GO_DOWN 0040 +#define PASS 0100 +#define FIRE 0200 + +t_stat daz_rd(int32 *data, int32 PA, int32 access); +t_stat daz_wr(int32 data, int32 PA, int32 access); +t_stat daz_reset(DEVICE *dptr); +t_stat daz_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr); +const char *daz_description (DEVICE *dptr); + +static int devadd = 0; +static int buttons[4] = { ~0, ~0, ~0, ~0 }; + +#define IOLN_DAZ 4 +DIB daz_dib = { + IOBA_AUTO, IOLN_DAZ, &daz_rd, &daz_wr, + 4, 0, VEC_AUTO, {NULL}, IOLN_DAZ +}; + +UNIT daz_unit = { + UDATA (NULL, 0, 0) +}; + +REG daz_reg[] = { + { GRDATAD(DEVADD, devadd, 16, 16, 0, "Box selection"), REG_FIT}, + { NULL } +}; + +MTAB daz_mod[] = { + { MTAB_XTD|MTAB_VDV|MTAB_VALR, 020, "ADDRESS", "ADDRESS", + &set_addr, &show_addr, NULL, "Bus address" }, + { MTAB_XTD|MTAB_VDV|MTAB_VALR, 0, "VECTOR", "VECTOR", + &set_vec, &show_vec, NULL, "Interrupt vector" }, + { MTAB_XTD|MTAB_VDV, 0, NULL, "AUTOCONFIGURE", + &set_addr_flt, NULL, NULL, "Enable autoconfiguration of address & vector" }, + { 0 } }; + +DEVICE daz_dev = { + "DAZ", &daz_unit, daz_reg, daz_mod, + 1, 8, 16, 1, 8, 16, + NULL, NULL, &daz_reset, + NULL, NULL, NULL, + &daz_dib, DEV_DIS | DEV_DISABLE | DEV_UBUS, + 0, NULL, NULL, NULL, NULL, &daz_help, NULL, + &daz_description +}; + +const char *daz_regnam[] = { + "DEVADD", + "DEVICE", +}; + +t_stat +daz_rd(int32 *data, int32 PA, int32 access) +{ + switch (PA & 002) { + case 000: + *data = 0x0000; + break; + case 002: + *data = 0x8000 | buttons[(devadd >> 10) & 3]; + break; + default: + return SCPE_NXM; + } + return SCPE_OK; +} + +t_stat +daz_wr(int32 data, int32 PA, int32 access) +{ + switch (PA & 002) { + case 000: + devadd = data; + return SCPE_OK; + case 002: + return SCPE_OK; + } + return SCPE_NXM; +} + +int daz_keyboard (SIM_KEY_EVENT *kev) +{ + uint32 mask; + int n; + + switch (kev->key) { + case SIM_KEY_1: n = 0; mask = GO_LEFT; break; + case SIM_KEY_2: n = 0; mask = GO_RIGHT; break; + case SIM_KEY_3: n = 0; mask = GO_UP; break; + case SIM_KEY_4: n = 0; mask = GO_DOWN; break; + case SIM_KEY_5: n = 0; mask = TURN_LEFT; break; + case SIM_KEY_6: n = 0; mask = TURN_RIGHT; break; + case SIM_KEY_7: n = 0; mask = FIRE; break; + case SIM_KEY_8: n = 0; mask = PASS; break; + case SIM_KEY_Q: n = 1; mask = GO_LEFT; break; + case SIM_KEY_W: n = 1; mask = GO_RIGHT; break; + case SIM_KEY_E: n = 1; mask = GO_UP; break; + case SIM_KEY_R: n = 1; mask = GO_DOWN; break; + case SIM_KEY_T: n = 1; mask = TURN_LEFT; break; + case SIM_KEY_Y: n = 1; mask = TURN_RIGHT; break; + case SIM_KEY_U: n = 1; mask = FIRE; break; + case SIM_KEY_I: n = 1; mask = PASS; break; + case SIM_KEY_A: n = 2; mask = GO_LEFT; break; + case SIM_KEY_S: n = 2; mask = GO_RIGHT; break; + case SIM_KEY_D: n = 2; mask = GO_UP; break; + case SIM_KEY_F: n = 2; mask = GO_DOWN; break; + case SIM_KEY_G: n = 2; mask = TURN_LEFT; break; + case SIM_KEY_H: n = 2; mask = TURN_RIGHT; break; + case SIM_KEY_J: n = 2; mask = FIRE; break; + case SIM_KEY_K: n = 2; mask = PASS; break; + case SIM_KEY_Z: n = 3; mask = GO_LEFT; break; + case SIM_KEY_X: n = 3; mask = GO_RIGHT; break; + case SIM_KEY_C: n = 3; mask = GO_UP; break; + case SIM_KEY_V: n = 3; mask = GO_DOWN; break; + case SIM_KEY_B: n = 3; mask = TURN_LEFT; break; + case SIM_KEY_N: n = 3; mask = TURN_RIGHT; break; + case SIM_KEY_M: n = 3; mask = FIRE; break; + case SIM_KEY_COMMA: n = 3; mask = PASS; break; + default: return 0; + } + + if (kev->state == SIM_KEYPRESS_UP) + buttons[n] |= mask; + else if (kev->state == SIM_KEYPRESS_DOWN) + buttons[n] &= ~mask; + + return 0; +} + +t_stat +daz_reset(DEVICE *dptr) +{ + DEVICE *ng_dptr; + t_stat r; + + if (dptr->flags & DEV_DIS) { + vid_display_kb_event_process = NULL; + return auto_config ("DAZ", (dptr->flags & DEV_DIS) ? 0 : 1);; + } + + ng_dptr = find_dev ("NG"); + if ((ng_dptr != NULL) && ((ng_dptr->flags & DEV_DIS) != 0)) { + set_cmd (0, "CPU 11/45"); /* Need a Unibus machine. */ + r = set_cmd (0, "NG ENABLED"); /* Need NG display. */ + if (r != SCPE_OK) { + dptr->flags |= DEV_DIS; + return r; + } + set_cmd (0, "DZ DISABLED"); /* DZ is in conflict with NG. */ + } + + r = auto_config ("DAZ", (dptr->flags & DEV_DIS) ? 0 : 1); + if (r != SCPE_OK) + return r; + + vid_display_kb_event_process = &daz_keyboard; + return SCPE_OK; +} + +const char *daz_description (DEVICE *dptr) +{ + return "Input buttons for Dazzle Dart"; +} + +t_stat daz_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr) +{ + /* The '*'s in the next line represent the standard text width of a help line */ + /****************************************************************************/ + fprintf(st, "%s\n\n", daz_description (dptr)); + fprintf(st, "The DAZ is a set of input buttons for the simulation of the MIT Logo\n"); + fprintf(st, "group PDP-11/45. There are four sets of eight buttons. The buttons are:\n"); + fprintf(st, "ROTATE LEFT, ROTATE RIGHT, MOVE LEFT, MOVE RIGHT, MOVE UP, MOVE DOWN,\n"); + fprintf(st, "PASS, and FIRE.\n\n"); + fprintf(st, "The first set is mapped from the keys 1-8. The second set is mapped from\n"); + fprintf(st, "Q-I. The first set is mapped from A-K. The fourth set is mapped\n"); + fprintf(st, "from Z-, (comma).\n"); + return SCPE_OK; +} +#else /* USE_DISPLAY not defined */ +char pdp11_daz_unused; /* sometimes empty object modules cause problems */ +#endif /* USE_DISPLAY not defined */ diff --git a/PDP11/pdp11_io_lib.c b/PDP11/pdp11_io_lib.c index 5ab21328..6125d225 100644 --- a/PDP11/pdp11_io_lib.c +++ b/PDP11/pdp11_io_lib.c @@ -781,6 +781,8 @@ AUTO_CON auto_tab[] = {/*c #v am vm fxa fxv */ {04140}, {0270} }, /* CH11 - CHAOS Net - fx CSR, fx VEC */ { { "NG" }, 1, 1, 0, 0, {04040}, {0270} }, /* NG - vector display */ + { { "DAZ" }, 1, 1, 0, 0, + {00104} }, /* DAZ */ { { NULL }, -1 } /* end table */ }; diff --git a/PDP11/pdp11_sys.c b/PDP11/pdp11_sys.c index 40581e73..c8bbb4d9 100644 --- a/PDP11/pdp11_sys.c +++ b/PDP11/pdp11_sys.c @@ -119,6 +119,7 @@ extern DEVICE uca_dev, ucb_dev; extern DEVICE rom_dev; extern DEVICE ch_dev; extern DEVICE ng_dev; +extern DEVICE daz_dev; extern REG cpu_reg[]; extern int32 saved_PC; @@ -199,6 +200,7 @@ DEVICE *sim_devices[] = { &rom_dev, &ch_dev, &ng_dev, + &daz_dev, #else &clk_dev, &tti_dev, diff --git a/makefile b/makefile index de6db9a8..6cf875b6 100644 --- a/makefile +++ b/makefile @@ -1280,7 +1280,7 @@ PDP11 = ${PDP11D}/pdp11_fp.c ${PDP11D}/pdp11_cpu.c ${PDP11D}/pdp11_dz.c \ ${PDP11D}/pdp11_kmc.c ${PDP11D}/pdp11_dup.c ${PDP11D}/pdp11_rs.c \ ${PDP11D}/pdp11_vt.c ${PDP11D}/pdp11_td.c ${PDP11D}/pdp11_io_lib.c \ ${PDP11D}/pdp11_rom.c ${PDP11D}/pdp11_ch.c $(DISPLAYL) $(DISPLAYVT) \ - ${PDP11D}/pdp11_ng.c $(DISPLAYNG) + ${PDP11D}/pdp11_ng.c ${PDP11D}/pdp11_daz.c $(DISPLAYNG) PDP11_OPT = -DVM_PDP11 -I ${PDP11D} ${NETWORK_OPT} $(DISPLAY_OPT)