Example #1
0
void clock(int sec)
{
	while(1)
	{
		BEEP(1);
		Delay(100000);
		BEEP(0);
		Delay(100000);	
		if(setTime[5]==sec)
			break;
	}
	
}
Example #2
0
/*
 * Check if the value lies outside the low/high range.  If so, force it in.
 */
static void limitCurrentValue (CDKUSCALE *widget)
{
    if (widget->current < widget->low)
    {
        widget->current = widget->low;
        BEEP();
    }
    else if (widget->current > widget->high)
    {
        widget->current = widget->high;
        BEEP();
    }
}
int mutt_yesorno (const char *msg, int def)
{
  event_t ch;
  unsigned char *yes = (unsigned char *) _("yes");
  unsigned char *no = (unsigned char *) _("no");
  
  CLEARLINE(LINES-1);
  printw("%s ([%c]/%c): ", msg, def ? *yes : *no,
	 def ? *no : *yes);
  FOREVER
  {
    mutt_refresh ();
    ch = mutt_getch ();
    if (ch.ch == -1) return(-1);
    if (CI_is_return (ch.ch))
      break;
    else if (tolower(ch.ch) == tolower(*yes))
    {
      def = 1;
      break;
    }
    else if (tolower(ch.ch) == tolower(*no))
    {
      def = 0;
      break;
    }
    else
    {
      BEEP();
    }
  }
  addstr ((char *) (def ? yes : no));
  mutt_refresh ();
  return (def);
}
Example #4
0
void brandt8641_state::brandt8641(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, XTAL(4'000'000)); // U4 ,4MHz crystal on board
	m_maincpu->set_addrmap(AS_PROGRAM, &brandt8641_state::brandt8641_mem);
	m_maincpu->set_addrmap(AS_IO, &brandt8641_state::brandt8641_io);
	m_maincpu->set_daisy_config(daisy_chain_intf);

	/* sound hardware */
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beep, 2000).add_route(ALL_OUTPUTS, "mono", 0.50);

	// Z80APIO U9
	// Z80APIO U14
	// Z80PIO U7 - unknown which is which
	Z80PIO(config, m_pio1, XTAL(4'000'000));
	m_pio1->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);

	Z80PIO(config, m_pio2, XTAL(4'000'000));
	m_pio2->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
	m_pio2->in_pa_callback().set(FUNC(brandt8641_state::port08_r));
	m_pio2->out_pa_callback().set(FUNC(brandt8641_state::port08_w));
	m_pio2->out_pb_callback().set(FUNC(brandt8641_state::port09_w));

	Z80PIO(config, m_pio3, XTAL(4'000'000));
	m_pio3->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);

	Z80CTC(config, "ctc", XTAL(4'000'000)); // Z80CTC U8
}
Example #5
0
GFXDECODE_END


void mbc200_state::mbc200(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, 8_MHz_XTAL / 2); // NEC D780C-1
	m_maincpu->set_addrmap(AS_PROGRAM, &mbc200_state::mbc200_mem);
	m_maincpu->set_addrmap(AS_IO, &mbc200_state::mbc200_io);

	z80_device &subcpu(Z80(config, "subcpu", 8_MHz_XTAL / 2)); // NEC D780C-1
	subcpu.set_addrmap(AS_PROGRAM, &mbc200_state::mbc200_sub_mem);
	subcpu.set_addrmap(AS_IO, &mbc200_state::mbc200_sub_io);

	/* video hardware */
	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
	screen.set_refresh_hz(50);
	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
	screen.set_size(640, 400);
	screen.set_visarea(0, 640-1, 0, 400-1);
	screen.set_screen_update("crtc", FUNC(hd6845s_device::screen_update));
	GFXDECODE(config, "gfxdecode", m_palette, gfx_mbc200);
	PALETTE(config, m_palette, palette_device::MONOCHROME);

	HD6845S(config, m_crtc, 8_MHz_XTAL / 4); // HD46505SP
	m_crtc->set_screen("screen");
	m_crtc->set_show_border_area(false);
	m_crtc->set_char_width(8);
	m_crtc->set_update_row_callback(FUNC(mbc200_state::update_row), this);

	// sound
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beep, 1000).add_route(ALL_OUTPUTS, "mono", 0.50); // frequency unknown
	SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.50);

	I8255(config, "ppi_1").out_pc_callback().set(FUNC(mbc200_state::p1_portc_w));
	I8255(config, "ppi_2").in_pa_callback().set(FUNC(mbc200_state::p2_porta_r));

	I8255(config, m_ppi_m);
	m_ppi_m->out_pa_callback().set(FUNC(mbc200_state::pm_porta_w));
	m_ppi_m->out_pb_callback().set(FUNC(mbc200_state::pm_portb_w));

	I8251(config, "uart1", 0); // INS8251N

	I8251(config, "uart2", 0); // INS8251A

	MB8876(config, m_fdc, 8_MHz_XTAL / 8); // guess
	FLOPPY_CONNECTOR(config, "fdc:0", mbc200_floppies, "qd", floppy_image_device::default_floppy_formats).enable_sound(true);
	FLOPPY_CONNECTOR(config, "fdc:1", mbc200_floppies, "qd", floppy_image_device::default_floppy_formats).enable_sound(true);

	/* Keyboard */
	generic_keyboard_device &keyboard(GENERIC_KEYBOARD(config, "keyboard", 0));
	keyboard.set_keyboard_callback(FUNC(mbc200_state::kbd_put));

	/* software lists */
	SOFTWARE_LIST(config, "flop_list").set_original("mbc200");
}
Example #6
0
void Accept_to_complete(uint32_t *hour,uint32_t *min)
{
	uint32_t one=0,two=0,three=0,four=0;
	switch(receive[1])
	{
		case '1':
			one = (receive[2]-'0')*10+(receive[3]-'0');
			two = (receive[4]-'0')*10+(receive[5]-'0');
			three = (receive[7]-'0')*10+(receive[6]-'0');
			four = (receive[8]-'0')*10+(receive[9]-'0');
			*hour = one;
			*min = two;
			setTime[3] = three;
			setTime[4] = four;
			USART2_SendStringData("0101");
			break;
		case '2':
			one = (receive[2]-'0')*10+(receive[3]-'0');		
			setPwm = one;
			/***
			设置pwm,改变灯的亮度
			***/
			CCR4_Val= one*100;
			TIM3_Mode_Config();
			printf("0101");
			break;
		case '3':
			one = (receive[2]-'0')*10+(receive[3]-'0');	//一键闹醒
			if(one==1)
			{	
				BEEP(1);
				Delay(500000);
				BEEP(0);
			}
			printf("0101");
			break;
		case '4':
			printf("03%03d55aa",vTemp/1000);
			break;
		default :
			printf("0202"); 
		break;		
	}
}
Example #7
0
/*
 * This injects a single character into the widget.
 */
static int _injectCDKButton (CDKOBJS *object, chtype input)
{
   CDKBUTTON *widget = (CDKBUTTON *)object;
   int ret = unknownInt;
   bool complete = FALSE;

   setExitType (widget, 0);

   /* Check a predefined binding. */
   if (checkCDKObjectBind (vBUTTON, widget, input) != 0)
   {
      checkEarlyExit (widget);
      complete = TRUE;
   }
   else
   {
      switch (input)
      {
      case KEY_ESC:
	 setExitType (widget, input);
	 complete = TRUE;
	 break;

      case KEY_ERROR:
	 setExitType (widget, input);
	 complete = TRUE;
	 break;

      case KEY_ENTER:
      case SPACE:
	 if (widget->callback)
	    widget->callback (widget);
	 setExitType (widget, KEY_ENTER);
	 ret = 0;
	 complete = TRUE;
	 break;

      case CDK_REFRESH:
	 eraseCDKScreen (ScreenOf (widget));
	 refreshCDKScreen (ScreenOf (widget));
	 break;

      default:
	 BEEP ();
	 break;
      }
   }

   if (!complete)
   {
      setExitType (widget, 0);
   }

   ResultOf (widget).valueInt = ret;
   return (ret != unknownInt);
}
Example #8
0
/*
 * Set the edit position.  Normally the cursor is one cell to the right of
 * the editable field.  Moving it left, over the field allows the user to
 * modify cells by typing in replacement characters for the field's value.
 */
static void setEditPosition(CDKUSCALE *widget, int newPosition)
{
    if (newPosition < 0)
    {
        BEEP();
    }
    else if (newPosition == 0)
    {
        widget->fieldEdit = newPosition;
    }
    else if (validEditPosition(widget, newPosition))
    {
        widget->fieldEdit = newPosition;
    }
    else
    {
        BEEP();
    }
}
Example #9
0
/* This displays a message in the host editor's main window.
 * Used mostly for error messages.
 */
void HostWinMsg(const char *msg)
{
	int maxy;

	maxy = getmaxy(gHostWin);
	DrawStrAt(gHostWin, maxy - 2, 0, msg);
	wclrtoeol(gHostWin);
	wmove(gHostWin, maxy - 1, 0);
	wrefresh(gHostWin);
	BEEP(1);
	gNeedToClearMsg = 1;
}	/* HostWinMsg */
Example #10
0
void vt100_keyboard_device::device_add_mconfig(machine_config &config)
{
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_speaker, 786); // 7.945us per serial clock = ~125865.324hz, / 160 clocks per char = ~ 786 hz
	m_speaker->add_route(ALL_OUTPUTS, "mono", 0.50);

	AY31015(config, m_uart);
	m_uart->write_so_callback().set(FUNC(vt100_keyboard_device::signal_out_w));

	RIPPLE_COUNTER(config, m_scan_counter); // 2x 74LS93
	m_scan_counter->set_stages(8);
	m_scan_counter->count_out_cb().set(FUNC(vt100_keyboard_device::key_scan_w));
}
Example #11
0
pgp_key_t pgp_ask_for_key (char *tag, char *whatfor,
                           short abilities, pgp_ring_t keyring)
{
  pgp_key_t key;
  char resp[SHORT_STRING];
  struct pgp_cache *l = NULL;

  mutt_clear_error ();

  resp[0] = 0;
  if (whatfor)
  {

    for (l = id_defaults; l; l = l->next)
      if (!mutt_strcasecmp (whatfor, l->what))
      {
	strfcpy (resp, NONULL (l->dflt), sizeof (resp));
	break;
      }
  }


  FOREVER
  {
    resp[0] = 0;
    if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0)
      return NULL;

    if (whatfor)
    {
      if (l)
	mutt_str_replace (&l->dflt, resp);
      else
      {
	l = safe_malloc (sizeof (struct pgp_cache));
	l->next = id_defaults;
	id_defaults = l;
	l->what = safe_strdup (whatfor);
	l->dflt = safe_strdup (resp);
      }
    }

    if ((key = pgp_getkeybystr (resp, abilities, keyring)))
      return key;

    BEEP ();
  }
  /* not reached */
}
Example #12
0
void a5105_state::a5105(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, XTAL(15'000'000) / 4);
	m_maincpu->set_addrmap(AS_PROGRAM, &a5105_state::a5105_mem);
	m_maincpu->set_addrmap(AS_IO, &a5105_state::a5105_io);
	m_maincpu->set_daisy_config(a5105_daisy_chain);

	/* video hardware */
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_refresh_hz(50);
	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
	m_screen->set_screen_update("upd7220", FUNC(upd7220_device::screen_update));
	m_screen->set_size(40*8, 32*8);
	m_screen->set_visarea(0, 40*8-1, 0, 25*8-1);
	GFXDECODE(config, m_gfxdecode, m_palette, gfx_a5105);
	PALETTE(config, m_palette, FUNC(a5105_state::a5105_palette), 16);

	/* sound hardware */
	SPEAKER(config, "mono").front_center();
	WAVE(config, "wave", "cassette").add_route(ALL_OUTPUTS, "mono", 0.25);
	BEEP(config, "beeper", 500).add_route(ALL_OUTPUTS, "mono", 0.50);

	/* Devices */
	UPD7220(config, m_hgdc, XTAL(15'000'000) / 16); // unk clock
	m_hgdc->set_addrmap(0, &a5105_state::upd7220_map);
	m_hgdc->set_display_pixels(FUNC(a5105_state::hgdc_display_pixels));
	m_hgdc->set_draw_text(FUNC(a5105_state::hgdc_draw_text));

	z80ctc_device& ctc(Z80CTC(config, "z80ctc", XTAL(15'000'000) / 4));
	ctc.intr_callback().set_inputline(m_maincpu, 0);
	ctc.zc_callback<0>().set("z80ctc", FUNC(z80ctc_device::trg2));
	ctc.zc_callback<2>().set("z80ctc", FUNC(z80ctc_device::trg3));

	z80pio_device& pio(Z80PIO(config, "z80pio", XTAL(15'000'000) / 4));
	pio.in_pb_callback().set(FUNC(a5105_state::pio_pb_r));
	pio.out_int_callback().set_inputline(m_maincpu, 0);

	CASSETTE(config, m_cass);

	UPD765A(config, m_fdc, 8'000'000, true, true);
	FLOPPY_CONNECTOR(config, "upd765a:0", a5105_floppies, "525qd", a5105_state::floppy_formats);
	FLOPPY_CONNECTOR(config, "upd765a:1", a5105_floppies, "525qd", a5105_state::floppy_formats);
	FLOPPY_CONNECTOR(config, "upd765a:2", a5105_floppies, "525qd", a5105_state::floppy_formats);
	FLOPPY_CONNECTOR(config, "upd765a:3", a5105_floppies, "525qd", a5105_state::floppy_formats);

	/* internal ram */
	RAM(config, RAM_TAG).set_default_size("64K");
}
Example #13
0
void mephisto_modena_state::modena(machine_config &config)
{
	M65C02(config, m_maincpu, XTAL(4'194'304));          // W65C02SP
	m_maincpu->set_addrmap(AS_PROGRAM, &mephisto_modena_state::modena_mem);
	timer_device &nmi_on(TIMER(config, "nmi_on"));
	nmi_on.configure_periodic(FUNC(mephisto_modena_state::nmi_on), attotime::from_hz(XTAL(4'194'304) / (1 << 13)));
	nmi_on.set_start_delay(attotime::from_hz(XTAL(4'194'304) / (1 << 13)) - attotime::from_usec(975));  // active for 975us
	TIMER(config, "nmi_off").configure_periodic(FUNC(mephisto_modena_state::nmi_off), attotime::from_hz(XTAL(4'194'304) / (1 << 13)));

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

	MEPHISTO_BUTTONS_BOARD(config, m_board, 0);
	m_board->set_disable_leds(true);
	config.set_default_layout(layout_mephisto_modena);

	/* sound hardware */
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beeper, 3250).add_route(ALL_OUTPUTS, "mono", 1.0);
}
Example #14
0
void epson_ex800_device::device_add_mconfig(machine_config &config)
{
	/* basic machine hardware */
	upd7810_device &upd(UPD7810(config, m_maincpu, 12000000)); // 12 MHz?
	upd.set_addrmap(AS_PROGRAM, &epson_ex800_device::ex800_mem);
	upd.pa_in_cb().set(FUNC(epson_ex800_device::porta_r));
	upd.pa_out_cb().set(FUNC(epson_ex800_device::porta_w));
	upd.pb_in_cb().set(FUNC(epson_ex800_device::portb_r));
	upd.pb_out_cb().set(FUNC(epson_ex800_device::portb_w));
	upd.pc_in_cb().set(FUNC(epson_ex800_device::portc_r));
	upd.pc_out_cb().set(FUNC(epson_ex800_device::portc_w));

	config.set_default_layout(layout_ex800);

	/* audio hardware */
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beeper, 4000); // measured at 4000 Hz */
	m_beeper->add_route(ALL_OUTPUTS, "mono", 1.0);
}
Example #15
0
void trs80dt1_state::trs80dt1(machine_config &config)
{
	/* basic machine hardware */
	I8051(config, m_maincpu, 7372800);
	m_maincpu->set_addrmap(AS_PROGRAM, &trs80dt1_state::prg_map);
	m_maincpu->set_addrmap(AS_IO, &trs80dt1_state::io_map);
	m_maincpu->port_out_cb<1>().set(FUNC(trs80dt1_state::port1_w));
	m_maincpu->port_out_cb<3>().set(FUNC(trs80dt1_state::port3_w));

	/* video hardware */
	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
	screen.set_screen_update("crtc", FUNC(i8276_device::screen_update));
	screen.set_refresh_hz(60);
	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
	screen.set_size(40*12, 16*16);
	screen.set_visarea(0, 40*12-1, 0, 16*16-1);

	GFXDECODE(config, "gfxdecode", m_palette, gfx_trs80dt1);

	I8276(config, m_crtc, 12480000 / 8);
	m_crtc->set_character_width(8);
	m_crtc->set_display_callback(FUNC(trs80dt1_state::crtc_update_row), this);
	m_crtc->drq_wr_callback().set_inputline(m_maincpu, MCS51_INT0_LINE); // BRDY pin goes through inverter to /INT0, so we don't invert
	m_crtc->irq_wr_callback().set(m_7474, FUNC(ttl7474_device::clear_w)); // INT pin
	m_crtc->irq_wr_callback().append(m_7474, FUNC(ttl7474_device::d_w));
	m_crtc->vrtc_wr_callback().set(m_7474, FUNC(ttl7474_device::clock_w));
	m_crtc->set_screen("screen");

	PALETTE(config, "palette").set_entries(3);

	X2210(config, "nvram");

	TTL7474(config, m_7474, 0);
	m_7474->comp_output_cb().set_inputline(m_maincpu, MCS51_INT1_LINE).invert(); // /Q connects directly to /INT1, so we need to invert?

	/* sound hardware */
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beep, 2000);
	m_beep->add_route(ALL_OUTPUTS, "mono", 0.50);
}
int mutt_multi_choice (char *prompt, char *letters)
{
  event_t ch;
  int choice;
  char *p;

  mvaddstr (LINES - 1, 0, prompt);
  clrtoeol ();
  FOREVER
  {
    mutt_refresh ();
    ch  = mutt_getch ();
    if (ch.ch == -1 || CI_is_return (ch.ch))
    {
      choice = -1;
      break;
    }
    else
    {
      p = strchr (letters, ch.ch);
      if (p)
      {
	choice = p - letters + 1;
	break;
      }
      else if (ch.ch <= '9' && ch.ch > '0')
      {
	choice = ch.ch - '0';
	if (choice <= mutt_strlen (letters))
	  break;
      }
    }
    BEEP ();
  }
  CLEARLINE (LINES - 1);
  mutt_refresh ();
  return choice;
}
Example #17
0
/***************************************************************************
Child main program
***************************************************************************/
int child_main(Controller* ctlPtrChild) {
   struct timespec lastSleep;
   long PWMcounter;
   long beepCounter;
   int PWM;
      
   //make sure output is not buffered (this program generally a child to a nodejs program) and set signal handler
   setbuf(stdout, NULL);
   setbuf(stderr, NULL);
   signal(SIGINT, sig_handler_child);
   signal(SIGTERM, sig_handler_child);
   
   PWMcounter = 0;
   beepCounter = 0;
   clock_gettime(CLOCK_MONOTONIC, &lastSleep);  //capture current time as time of 'last sleep'
   while (1) {
      sync_clock_delay(PWMCycle_ns, &lastSleep);
      PWM = (int)(ctlPtrChild->out + 0.5);
      PWMcounter++;
      // PWMcounter %= 100;
      if (PWMcounter == 100) {
         // printf("PWM: %d, Out: %f\n",PWM, ctlPtrChild->out);
         PWMcounter = 0;
         pidControl(ctlPtrChild); //run PID algorithm
         printJSON(ctlPtrChild); //send data out formatted as JSON
      }
      if (PWMcounter < PWM) {
         GPIO_SET = 1<<SSR1_GPIO; //turn on SSR pin
      } else {
         GPIO_CLR = 1<<SSR1_GPIO; //turn off SSR pin
         // printf("SSR Off. PWM: %d, PWMcounter: %d, Out: %f\n", PWM, PWMcounter, ctlPtrChild->out);
      }
      //Manage beeper
      ctlPtrChild->beep_mode = BEEP(ctlPtrChild->beep_mode);
   }
}
void mutt_curses_error (const char *fmt, ...)
{
  va_list ap;

  va_start (ap, fmt);
  vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap);
  va_end (ap);
  
  dprint (1, (debugfile, "%s\n", Errorbuf));
  Errorbuf[ (COLS < sizeof (Errorbuf) ? COLS : sizeof (Errorbuf)) - 2 ] = 0;
  clean_error_buf();

  if (!option (OPTKEEPQUIET))
  {
    BEEP ();
    SETCOLOR (MT_COLOR_ERROR);
    mvaddstr (LINES-1, 0, Errorbuf);
    clrtoeol ();
    SETCOLOR (MT_COLOR_NORMAL);
    mutt_refresh ();
  }

  set_option (OPTMSGERR);
}
Example #19
0
int main(void)
{

	BEEP(0);
	sys_Start();
}
Example #20
0
void pve500_state::pve500(machine_config &config)
{
	/* Main CPU */
	TMPZ84C015(config, m_maincpu, 12_MHz_XTAL / 2); // TMPZ84C015BF-6
	m_maincpu->set_addrmap(AS_PROGRAM, &pve500_state::maincpu_prg);
	m_maincpu->set_addrmap(AS_IO, &pve500_state::maincpu_io);
	m_maincpu->set_daisy_config(maincpu_daisy_chain);
	m_maincpu->out_dtra_callback().set(FUNC(pve500_state::GPI_w));
	m_maincpu->out_dtrb_callback().set(m_buzzer, FUNC(beep_device::set_state)).invert();
	m_maincpu->out_txda_callback().set("recorder", FUNC(rs232_port_device::write_txd));
	m_maincpu->out_txdb_callback().set("player1", FUNC(rs232_port_device::write_txd));

	z80ctc_device& ctc(Z80CTC(config, "external_ctc", 12_MHz_XTAL / 2));
	ctc.intr_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);

	z80sio0_device& sio(Z80SIO0(config, "external_sio", 12_MHz_XTAL / 2));
	sio.out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
	sio.out_txda_callback().set("player2", FUNC(rs232_port_device::write_txd));
	sio.out_txdb_callback().set("edl_inout", FUNC(rs232_port_device::write_txd));

	/* Secondary CPU */
	TMPZ84C015(config, m_subcpu, 12_MHz_XTAL / 2); /* TMPZ84C015BF-6 */
	m_subcpu->set_addrmap(AS_PROGRAM, &pve500_state::subcpu_prg);
	m_subcpu->set_addrmap(AS_IO, &pve500_state::subcpu_io);
	m_subcpu->out_dtra_callback().set(FUNC(pve500_state::cxdio_reset_w));
	m_subcpu->out_dtrb_callback().set(FUNC(pve500_state::external_monitor_w));
	m_subcpu->out_txda_callback().set("switcher", FUNC(rs232_port_device::write_txd));
	m_subcpu->out_txdb_callback().set("serial_mixer", FUNC(rs232_port_device::write_txd));

	// PIO callbacks
	m_subcpu->in_pa_callback().set(FUNC(pve500_state::eeprom_r));
	m_subcpu->out_pa_callback().set(FUNC(pve500_state::eeprom_w));

	// ICG3: I/O Expander
	CXD1095(config, m_cxdio, 0);
	m_cxdio->out_porta_cb().set(FUNC(pve500_state::io_sc_w));
	m_cxdio->out_portb_cb().set(FUNC(pve500_state::io_le_w));
	m_cxdio->in_portc_cb().set(FUNC(pve500_state::io_ky_r));
	m_cxdio->out_portd_cb().set(FUNC(pve500_state::io_ld_w));
	m_cxdio->out_porte_cb().set(FUNC(pve500_state::io_sel_w));

	/* Search Dial MCUs */
	MB88201(config, "dial_mcu_left", 4_MHz_XTAL).set_disable(); /* PLAYER DIAL MCU */
	MB88201(config, "dial_mcu_right", 4_MHz_XTAL).set_disable(); /* RECORDER DIAL MCU */

	/* Serial EEPROM (128 bytes, 8-bit data organization) */
	/* The EEPROM stores the setup data */
	EEPROM_MSM16911_8BIT(config, "eeprom");

	/* FIX-ME: These are actually RS422 ports (except EDL IN/OUT which is indeed an RS232 port)*/
	rs232_port_device &recorder(RS232_PORT(config, "recorder", default_rs232_devices, nullptr));
	recorder.rxd_handler().set(m_maincpu, FUNC(tmpz84c015_device::rxa_w));

	rs232_port_device &player1(RS232_PORT(config, "player1", default_rs232_devices, nullptr));
	player1.rxd_handler().set(m_maincpu, FUNC(tmpz84c015_device::rxb_w));

	rs232_port_device &player2(RS232_PORT(config, "player2", default_rs232_devices, nullptr));
	player2.rxd_handler().set("external_sio", FUNC(z80dart_device::rxa_w));

	rs232_port_device &edl_inout(RS232_PORT(config, "edl_inout", default_rs232_devices, nullptr));
	edl_inout.rxd_handler().set("external_sio", FUNC(z80dart_device::rxb_w));

	rs232_port_device &switcher(RS232_PORT(config, "switcher", default_rs232_devices, nullptr));
	switcher.rxd_handler().set(m_subcpu, FUNC(tmpz84c015_device::rxa_w));

	rs232_port_device &serial_mixer(RS232_PORT(config, "serial_mixer", default_rs232_devices, nullptr));
	serial_mixer.rxd_handler().set(m_subcpu, FUNC(tmpz84c015_device::rxb_w));

	clock_device &clk1(CLOCK(config, "clk1", 12_MHz_XTAL / 20));
	clk1.signal_handler().set(m_maincpu, FUNC(tmpz84c015_device::rxca_w));
	clk1.signal_handler().append(m_maincpu, FUNC(tmpz84c015_device::txca_w));
	clk1.signal_handler().append(m_maincpu, FUNC(tmpz84c015_device::rxcb_w));
	clk1.signal_handler().append(m_maincpu, FUNC(tmpz84c015_device::txcb_w));
	clk1.signal_handler().append(m_subcpu, FUNC(tmpz84c015_device::rxca_w));
	clk1.signal_handler().append(m_subcpu, FUNC(tmpz84c015_device::txca_w));
	clk1.signal_handler().append(m_subcpu, FUNC(tmpz84c015_device::rxcb_w));
	clk1.signal_handler().append(m_subcpu, FUNC(tmpz84c015_device::txcb_w));

	/* ICF5: 2kbytes of RAM shared between the two CPUs (dual-port RAM)*/
	mb8421_device &mb8421(MB8421(config, "mb8421"));
	mb8421.intl_callback().set(FUNC(pve500_state::mb8421_intl));
	mb8421.intr_callback().set(FUNC(pve500_state::mb8421_intr));

	/* video hardware */
	config.set_default_layout(layout_pve500);

	/* audio hardware */
	SPEAKER(config, "mono").front_center();
	BEEP(config, "buzzer", 12_MHz_XTAL / 3200).add_route(ALL_OUTPUTS, "mono", 0.05); // 3.75 kHz CLK2 coming out of IC D4 (frequency divider circuitry)
}
Example #21
0
/*
 * This allows the user to use the cursor keys to adjust the
 * position of the widget.
 */
void positionCDKButton (CDKBUTTON *button)
{
   /* Declare some variables. */
   int origX = getbegx (button->win);
   int origY = getbegy (button->win);
   chtype key = (chtype)0;
   boolean functionKey;

   /* Let them move the widget around until they hit return. */
   while (key != KEY_ENTER)
   {
      key = (chtype)getchCDKObject (ObjOf (button), &functionKey);
      if (key == KEY_UP || key == '8')
      {
	 if (getbegy (button->win) > 0)
	 {
	    moveCDKButton (button, 0, -1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == KEY_DOWN || key == '2')
      {
	 if (getbegy (button->win) + getmaxy (button->win) <
	     getmaxy (WindowOf (button)) - 1)
	 {
	    moveCDKButton (button, 0, 1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == KEY_LEFT || key == '4')
      {
	 if (getbegx (button->win) > 0)
	 {
	    moveCDKButton (button, -1, 0, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == KEY_RIGHT || key == '6')
      {
	 if (getbegx (button->win) + getmaxx (button->win) < getmaxx
	     (WindowOf (button)) - 1)
	 {
	    moveCDKButton (button, 1, 0, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == '7')
      {
	 if (getbegy (button->win) > 0 && getbegx (button->win) > 0)
	 {
	    moveCDKButton (button, -1, -1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == '9')
      {
	 if (getbegx (button->win) + getmaxx (button->win) < getmaxx
	     (WindowOf (button)) - 1 &&
	     getbegy (button->win) > 0)
	 {
	    moveCDKButton (button, 1, -1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == '1')
      {
	 if (getbegx (button->win) > 0 && getbegx (button->win) +
	     getmaxx (button->win) < getmaxx (WindowOf (button)) - 1)
	 {
	    moveCDKButton (button, -1, 1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == '3')
      {
	 if (getbegx (button->win) + getmaxx (button->win) <
	     getmaxx (WindowOf (button)) - 1
	     && getbegy (button->win) + getmaxy (button->win) <
	     getmaxy (WindowOf (button)) - 1)
	 {
	    moveCDKButton (button, 1, 1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
      }
      else if (key == '5')
      {
	 moveCDKButton (button, CENTER, CENTER, FALSE, TRUE);
      }
      else if (key == 't')
      {
	 moveCDKButton (button, getbegx (button->win), TOP, FALSE, TRUE);
      }
      else if (key == 'b')
      {
	 moveCDKButton (button, getbegx (button->win), BOTTOM, FALSE, TRUE);
      }
      else if (key == 'l')
      {
	 moveCDKButton (button, LEFT, getbegy (button->win), FALSE, TRUE);
      }
      else if (key == 'r')
      {
	 moveCDKButton (button, RIGHT, getbegy (button->win), FALSE, TRUE);
      }
      else if (key == 'c')
      {
	 moveCDKButton (button, CENTER, getbegy (button->win), FALSE, TRUE);
      }
      else if (key == 'C')
      {
	 moveCDKButton (button, getbegx (button->win), CENTER, FALSE, TRUE);
      }
      else if (key == CDK_REFRESH)
      {
	 eraseCDKScreen (ScreenOf (button));
	 refreshCDKScreen (ScreenOf (button));
      }
      else if (key == KEY_ESC)
      {
	 moveCDKButton (button, origX, origY, FALSE, TRUE);
      }
      else if (key != KEY_ENTER)
      {
	 BEEP ();
      }
   }
}
Example #22
0
/*
 * This allows the user to use the cursor keys to adjust the
 * position of the widget.
 */
void positionCDKObject (CDKOBJS *obj, WINDOW *win)
{
   /* *INDENT-EQLS* */
   CDKSCREEN *screen = ScreenOf (obj);
   WINDOW *parent    = screen->window;
   int origX         = getbegx (win);
   int origY         = getbegy (win);
   int begX          = getbegx (parent);
   int begY          = getbegy (parent);
   int endX          = begX + getmaxx (WindowOf (obj));
   int endY          = begY + getmaxy (WindowOf (obj));

   chtype key;
   boolean functionKey;

   /* Let them move the widget around until they hit return. */
   while ((key = (chtype)getchCDKObject (obj, &functionKey)) != KEY_ENTER)
   {
      switch (key)
      {
      case KEY_UP:
      case '8':
	 if (getbegy (win) > begY)
	 {
	    moveCDKObject (obj, 0, -1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case KEY_DOWN:
      case '2':
	 if (getendy (win) < endY)
	 {
	    moveCDKObject (obj, 0, 1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case KEY_LEFT:
      case '4':
	 if (getbegx (win) > begX)
	 {
	    moveCDKObject (obj, -1, 0, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case KEY_RIGHT:
      case '6':
	 if (getendx (win) < endX)
	 {
	    moveCDKObject (obj, 1, 0, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case '7':
	 if (getbegy (win) > begY && getbegx (win) > begX)
	 {
	    moveCDKObject (obj, -1, -1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case '9':
	 if (getendx (win) < endX && getbegy (win) > begY)
	 {
	    moveCDKObject (obj, 1, -1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case '1':
	 if (getbegx (win) > begX && getendy (win) < endY)
	 {
	    moveCDKObject (obj, -1, 1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case '3':
	 if (getendx (win) < endX && getendy (win) < endY)
	 {
	    moveCDKObject (obj, 1, 1, TRUE, TRUE);
	 }
	 else
	 {
	    BEEP ();
	 }
	 break;
      case '5':
	 moveCDKObject (obj, CENTER, CENTER, FALSE, TRUE);
	 break;
      case 't':
	 moveCDKObject (obj, getbegx (win), TOP, FALSE, TRUE);
	 break;
      case 'b':
	 moveCDKObject (obj, getbegx (win), BOTTOM, FALSE, TRUE);
	 break;
      case 'l':
	 moveCDKObject (obj, LEFT, getbegy (win), FALSE, TRUE);
	 break;
      case 'r':
	 moveCDKObject (obj, RIGHT, getbegy (win), FALSE, TRUE);
	 break;
      case 'c':
	 moveCDKObject (obj, CENTER, getbegy (win), FALSE, TRUE);
	 break;
      case 'C':
	 moveCDKObject (obj, getbegx (win), CENTER, FALSE, TRUE);
	 break;
      case CDK_REFRESH:
	 eraseCDKScreen (ScreenOf (obj));
	 refreshCDKScreen (ScreenOf (obj));
	 break;
      case KEY_ESC:
	 moveCDKObject (obj, origX, origY, FALSE, TRUE);
	 break;
      default:
	 BEEP ();
	 break;
      }
   }
}
Example #23
0
/**
 * mutt_multi_choice - Offer the user a multiple choice question
 * @param prompt  Message prompt
 * @param letters Allowable selection keys
 * @retval >=0 0-based user selection
 * @retval  -1 Selection aborted
 */
int mutt_multi_choice(const char *prompt, const char *letters)
{
  struct Event ch;
  int choice;
  bool redraw = true;
  int prompt_lines = 1;
  char *p = NULL;

  while (true)
  {
    if (redraw || SigWinch)
    {
      redraw = false;
      if (SigWinch)
      {
        SigWinch = 0;
        mutt_resize_screen();
        clearok(stdscr, TRUE);
        mutt_menu_current_redraw();
      }
      if (MuttMessageWindow->cols)
      {
        prompt_lines = (mutt_strwidth(prompt) + MuttMessageWindow->cols - 1) /
                       MuttMessageWindow->cols;
        prompt_lines = MAX(1, MIN(3, prompt_lines));
      }
      if (prompt_lines != MuttMessageWindow->rows)
      {
        mutt_window_reflow_message_rows(prompt_lines);
        mutt_menu_current_redraw();
      }

      SETCOLOR(MT_COLOR_PROMPT);
      mutt_window_mvaddstr(MuttMessageWindow, 0, 0, prompt);
      NORMAL_COLOR;
      mutt_window_clrtoeol(MuttMessageWindow);
    }

    mutt_refresh();
    /* SigWinch is not processed unless timeout is set */
    mutt_getch_timeout(30 * 1000);
    ch = mutt_getch();
    mutt_getch_timeout(-1);
    if (ch.ch == -2)
      continue;
    /* (ch.ch == 0) is technically possible.  Treat the same as < 0 (abort) */
    if ((ch.ch <= 0) || CI_is_return(ch.ch))
    {
      choice = -1;
      break;
    }
    else
    {
      p = strchr(letters, ch.ch);
      if (p)
      {
        choice = p - letters + 1;
        break;
      }
      else if ((ch.ch <= '9') && (ch.ch > '0'))
      {
        choice = ch.ch - '0';
        if (choice <= mutt_str_strlen(letters))
          break;
      }
    }
    BEEP();
  }
  if (MuttMessageWindow->rows != 1)
  {
    mutt_window_reflow_message_rows(1);
    mutt_menu_current_redraw();
  }
  else
    mutt_window_clearline(MuttMessageWindow, 0);
  mutt_refresh();
  return choice;
}
Example #24
0
/**
 * mutt_yesorno - Ask the user a Yes/No question
 * @param msg Prompt
 * @param def Default answer, see #QuadOption
 * @retval num Selection made, see #QuadOption
 */
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
{
  struct Event ch;
  char *yes = _("yes");
  char *no = _("no");
  char *answer_string = NULL;
  int answer_string_wid, msg_wid;
  size_t trunc_msg_len;
  bool redraw = true;
  int prompt_lines = 1;

  char *expr = NULL;
  regex_t reyes;
  regex_t reno;
  char answer[2];

  answer[1] = '\0';

  bool reyes_ok = (expr = nl_langinfo(YESEXPR)) && (expr[0] == '^') &&
                  (REGCOMP(&reyes, expr, REG_NOSUB) == 0);
  bool reno_ok = (expr = nl_langinfo(NOEXPR)) && (expr[0] == '^') &&
                 (REGCOMP(&reno, expr, REG_NOSUB) == 0);

  /* In order to prevent the default answer to the question to wrapped
   * around the screen in the even the question is wider than the screen,
   * ensure there is enough room for the answer and truncate the question
   * to fit.  */
  safe_asprintf(&answer_string, " ([%s]/%s): ", (def == MUTT_YES) ? yes : no,
                (def == MUTT_YES) ? no : yes);
  answer_string_wid = mutt_strwidth(answer_string);
  msg_wid = mutt_strwidth(msg);

  while (true)
  {
    if (redraw || SigWinch)
    {
      redraw = false;
      if (SigWinch)
      {
        SigWinch = 0;
        mutt_resize_screen();
        clearok(stdscr, TRUE);
        mutt_menu_current_redraw();
      }
      if (MuttMessageWindow->cols)
      {
        prompt_lines = (msg_wid + answer_string_wid + MuttMessageWindow->cols - 1) /
                       MuttMessageWindow->cols;
        prompt_lines = MAX(1, MIN(3, prompt_lines));
      }
      if (prompt_lines != MuttMessageWindow->rows)
      {
        mutt_window_reflow_message_rows(prompt_lines);
        mutt_menu_current_redraw();
      }

      /* maxlen here is sort of arbitrary, so pick a reasonable upper bound */
      trunc_msg_len = mutt_wstr_trunc(
          msg, 4 * prompt_lines * MuttMessageWindow->cols,
          prompt_lines * MuttMessageWindow->cols - answer_string_wid, NULL);

      mutt_window_move(MuttMessageWindow, 0, 0);
      SETCOLOR(MT_COLOR_PROMPT);
      addnstr(msg, trunc_msg_len);
      addstr(answer_string);
      NORMAL_COLOR;
      mutt_window_clrtoeol(MuttMessageWindow);
    }

    mutt_refresh();
    /* SigWinch is not processed unless timeout is set */
    mutt_getch_timeout(30 * 1000);
    ch = mutt_getch();
    mutt_getch_timeout(-1);
    if (ch.ch == -2)
      continue;
    if (CI_is_return(ch.ch))
      break;
    if (ch.ch < 0)
    {
      def = MUTT_ABORT;
      break;
    }

    answer[0] = ch.ch;
    if (reyes_ok ? (regexec(&reyes, answer, 0, 0, 0) == 0) : (tolower(ch.ch) == 'y'))
    {
      def = MUTT_YES;
      break;
    }
    else if (reno_ok ? (regexec(&reno, answer, 0, 0, 0) == 0) : (tolower(ch.ch) == 'n'))
    {
      def = MUTT_NO;
      break;
    }
    else
    {
      BEEP();
    }
  }

  FREE(&answer_string);

  if (reyes_ok)
    regfree(&reyes);
  if (reno_ok)
    regfree(&reno);

  if (MuttMessageWindow->rows != 1)
  {
    mutt_window_reflow_message_rows(1);
    mutt_menu_current_redraw();
  }
  else
    mutt_window_clearline(MuttMessageWindow, 0);

  if (def != MUTT_ABORT)
  {
    addstr((char *) ((def == MUTT_YES) ? yes : no));
    mutt_refresh();
  }
  else
  {
    /* when the users cancels with ^G, clear the message stored with
     * mutt_message() so it isn't displayed when the screen is refreshed. */
    mutt_clear_error();
  }
  return def;
}
Example #25
0
/*
 * This function injects a single character into the widget.
 */
static int _injectCDKUScale (CDKOBJS *object, chtype input)
{
    CDKUSCALE *widget = (CDKUSCALE *)object;
    int ppReturn = 1;
    unsigned ret = unknownUnsigned;
    bool complete = FALSE;

    /* Set the exit type. */
    setExitType(widget, 0);

    /* Draw the field. */
    drawCDKUScaleField (widget);

    /* Check if there is a pre-process function to be called. */
    if (PreProcessFuncOf(widget) != 0)
    {
        /* Call the pre-process function. */
        ppReturn = PreProcessFuncOf(widget) (vUSCALE, widget, PreProcessDataOf(widget), input);
    }

    /* Should we continue? */
    if (ppReturn != 0)
    {
        /* Check for a key binding. */
        if (checkCDKObjectBind(vUSCALE, widget, input) != 0)
        {
            checkEarlyExit(widget);
            complete = TRUE;
        }
        else
        {
            switch (input)
            {
            case KEY_LEFT :
                setEditPosition(widget, widget->fieldEdit + 1);
                break;

            case KEY_RIGHT :
                setEditPosition(widget, widget->fieldEdit - 1);
                break;

            case KEY_DOWN :
                Decrement(widget->current, widget->inc);
                break;

            case KEY_UP :
                Increment(widget->current, widget->inc);
                break;

            case KEY_PPAGE :
                Increment(widget->current, widget->fastinc);
                break;

            case KEY_NPAGE :
                Decrement(widget->current, widget->fastinc);
                break;

            case KEY_HOME :
                widget->current = widget->low;
                break;

            case KEY_END :
                widget->current = widget->high;
                break;

            case KEY_TAB :
            case KEY_ENTER :
                setExitType(widget, input);
                ret = (widget->current);
                complete = TRUE;
                break;

            case KEY_ESC :
                setExitType(widget, input);
                complete = TRUE;
                break;

            case CDK_REFRESH :
                eraseCDKScreen (ScreenOf(widget));
                refreshCDKScreen (ScreenOf(widget));
                break;

            default :
                if (widget->fieldEdit)
                {
                    if (!performEdit(widget, input))
                        BEEP();
                }
                else
                {
                    /*
                     * The cursor is not within the editable text.  Interpret
                     * input as commands.
                     */
                    switch (input)
                    {
                    case 'd':
                    case '-':
                        return _injectCDKUScale(object, KEY_DOWN);
                    case '+':
                        return _injectCDKUScale(object, KEY_UP);
                    case 'D':
                        return _injectCDKUScale(object, KEY_NPAGE);
                    case '0':
                        return _injectCDKUScale(object, KEY_HOME);
                    default:
                        BEEP();
                        break;
                    }
                }
                break;
            }
        }
        limitCurrentValue(widget);

        /* Should we call a post-process? */
        if (!complete && (PostProcessFuncOf(widget) != 0))
        {
            PostProcessFuncOf(widget) (vUSCALE, widget, PostProcessDataOf(widget), input);
        }
    }

    if (!complete) {
        drawCDKUScaleField (widget);
        setExitType(widget, 0);
    }

    ResultOf(widget).valueUnsigned = ret;
    return (ret != unknownUnsigned);
}
Example #26
0
File: enter.c Project: 0xAX/muttx
int _mutt_enter_string(char *buf, size_t buflen, int y, int x,
			int flags, int multiple, char ***files, int *numfiles,
			struct enter_state *state)
{
	int width = COLS - x - 1;
	int redraw;
	int pass =(flags & M_PASS);
	int first = 1;
	int ch, w, r;
	size_t i;
	wchar_t *tempbuf = 0;
	size_t templen = 0;
	history_class_t hclass;
	wchar_t wc;
	mbstate_t mbstate;

	int rv = 0;
	memset(&mbstate, 0, sizeof(mbstate));

	if (state->wbuf)
	{
		/* Coming back after return 1 */
		redraw = M_REDRAW_LINE;
		first = 0;
	}
	else
	{
		/* Initialise wbuf from buf */
		state->wbuflen = 0;
		state->lastchar = my_mbstowcs(&state->wbuf, &state->wbuflen, 0, buf);
		redraw = M_REDRAW_INIT;
	}

	if (flags & M_FILE)
		hclass = HC_FILE;
	else if (flags & M_EFILE)
		hclass = HC_MBOX;
	else if (flags & M_CMD)
		hclass = HC_CMD;
	else if (flags & M_ALIAS)
		hclass = HC_ALIAS;
	else if (flags & M_COMMAND)
		hclass = HC_COMMAND;
	else if (flags & M_PATTERN)
		hclass = HC_PATTERN;
	else
		hclass = HC_OTHER;

	for(;;)
	{
		if (redraw && !pass)
		{
			if (redraw == M_REDRAW_INIT)
			{
				/* Go to end of line */
				state->curpos = state->lastchar;
				state->begin = width_ceiling(state->wbuf, state->lastchar, my_wcswidth(state->wbuf, state->lastchar) - width + 1);
			}
			if (state->curpos < state->begin ||
			    my_wcswidth(state->wbuf + state->begin, state->curpos - state->begin) >= width)
				state->begin = width_ceiling(state->wbuf, state->lastchar, my_wcswidth(state->wbuf, state->curpos) - width / 2);
			move(y, x);
			w = 0;
			for(i = state->begin; i < state->lastchar; i++)
			{
				w += my_wcwidth(state->wbuf[i]);
				if (w > width)
					break;
				my_addwch(state->wbuf[i]);
			}
			clrtoeol();
			move(y, x + my_wcswidth(state->wbuf + state->begin, state->curpos - state->begin));
		}
		mutt_refresh();

		if ((ch = km_dokey(MENU_EDITOR)) == -1)
		{
			rv = -1;
			goto bye;
		}

		if (ch != OP_NULL)
		{
			first = 0;
			if (ch != OP_EDITOR_COMPLETE && ch != OP_EDITOR_COMPLETE_QUERY)
				state->tabs = 0;
			redraw = M_REDRAW_LINE;
			switch(ch)
			{
			case OP_EDITOR_HISTORY_UP:
				state->curpos = state->lastchar;
				if (mutt_history_at_scratch(hclass))
				{
					my_wcstombs(buf, buflen, state->wbuf, state->curpos);
					mutt_history_save_scratch(hclass, buf);
				}
				replace_part(state, 0, mutt_history_prev(hclass));
				redraw = M_REDRAW_INIT;
				break;

			case OP_EDITOR_HISTORY_DOWN:
				state->curpos = state->lastchar;
				if (mutt_history_at_scratch(hclass))
				{
					my_wcstombs(buf, buflen, state->wbuf, state->curpos);
					mutt_history_save_scratch(hclass, buf);
				}
				replace_part(state, 0, mutt_history_next(hclass));
				redraw = M_REDRAW_INIT;
				break;

			case OP_EDITOR_BACKSPACE:
				if (state->curpos == 0)
					BEEP();
				else
				{
					i = state->curpos;
					while(i && COMB_CHAR(state->wbuf[i - 1]))
						--i;
					if (i)
						--i;
					memmove(state->wbuf + i, state->wbuf + state->curpos,(state->lastchar - state->curpos) * sizeof(wchar_t));
					state->lastchar -= state->curpos - i;
					state->curpos = i;
				}
				break;

			case OP_EDITOR_BOL:
				state->curpos = 0;
				break;

			case OP_EDITOR_EOL:
				redraw= M_REDRAW_INIT;
				break;

			case OP_EDITOR_KILL_LINE:
				state->curpos = state->lastchar = 0;
				break;

			case OP_EDITOR_KILL_EOL:
				state->lastchar = state->curpos;
				break;

			case OP_EDITOR_BACKWARD_CHAR:
				if (state->curpos == 0)
					BEEP();
				else
				{
					while(state->curpos && COMB_CHAR(state->wbuf[state->curpos - 1]))
						state->curpos--;
					if (state->curpos)
						state->curpos--;
				}
				break;

			case OP_EDITOR_FORWARD_CHAR:
				if (state->curpos == state->lastchar)
					BEEP();
				else
				{
					++state->curpos;
					while(state->curpos < state->lastchar && COMB_CHAR(state->wbuf[state->curpos]))
						++state->curpos;
				}
				break;

			case OP_EDITOR_BACKWARD_WORD:
				if (state->curpos == 0)
					BEEP();
				else
				{
					while(state->curpos && iswspace(state->wbuf[state->curpos - 1]))
						--state->curpos;
					while(state->curpos && !iswspace(state->wbuf[state->curpos - 1]))
						--state->curpos;
				}
				break;

			case OP_EDITOR_FORWARD_WORD:
				if (state->curpos == state->lastchar)
					BEEP();
				else
				{
					while(state->curpos < state->lastchar && iswspace(state->wbuf[state->curpos]))
						++state->curpos;
					while(state->curpos < state->lastchar && !iswspace(state->wbuf[state->curpos]))
						++state->curpos;
				}
				break;

			case OP_EDITOR_CAPITALIZE_WORD:
			case OP_EDITOR_UPCASE_WORD:
			case OP_EDITOR_DOWNCASE_WORD:
				if (state->curpos == state->lastchar)
				{
					BEEP();
					break;
				}
				while(state->curpos && !iswspace(state->wbuf[state->curpos]))
					--state->curpos;
				while(state->curpos < state->lastchar && iswspace(state->wbuf[state->curpos]))
					++state->curpos;
				while(state->curpos < state->lastchar && !iswspace(state->wbuf[state->curpos]))
				{
					if (ch == OP_EDITOR_DOWNCASE_WORD)
						state->wbuf[state->curpos] = towlower(state->wbuf[state->curpos]);
					else
					{
						state->wbuf[state->curpos] = towupper(state->wbuf[state->curpos]);
						if (ch == OP_EDITOR_CAPITALIZE_WORD)
							ch = OP_EDITOR_DOWNCASE_WORD;
					}
					state->curpos++;
				}
				break;

			case OP_EDITOR_DELETE_CHAR:
				if (state->curpos == state->lastchar)
					BEEP();
				else
				{
					i = state->curpos;
					while(i < state->lastchar && COMB_CHAR(state->wbuf[i]))
						++i;
					if (i < state->lastchar)
						++i;
					while(i < state->lastchar && COMB_CHAR(state->wbuf[i]))
						++i;
					memmove(state->wbuf + state->curpos, state->wbuf + i,(state->lastchar - i) * sizeof(wchar_t));
					state->lastchar -= i - state->curpos;
				}
				break;

			case OP_EDITOR_KILL_WORD:
				/* delete to beginning of word */
				if (state->curpos != 0)
				{
					i = state->curpos;
					while(i && iswspace(state->wbuf[i - 1]))
						--i;
					if (i)
					{
						if (iswalnum(state->wbuf[i - 1]))
						{
							for(--i; i && iswalnum(state->wbuf[i - 1]); i--)
								;
						}
						else
							--i;
					}
					memmove(state->wbuf + i, state->wbuf + state->curpos,
						(state->lastchar - state->curpos) * sizeof(wchar_t));
					state->lastchar += i - state->curpos;
					state->curpos = i;
				}
				break;

			case OP_EDITOR_KILL_EOW:
				/* delete to end of word */

				/* first skip over whitespace */
				for(i = state->curpos;
				     i < state->lastchar && iswspace(state->wbuf[i]); i++)
					;

				/* if there are any characters left.. */
				if (i < state->lastchar)
				{
					/* if the current character is alphanumeric.. */
					if (iswalnum(state->wbuf[i]))
					{
						/* skip over the rest of the word consistent of only alphanumerics */
						for(; i < state->lastchar && iswalnum(state->wbuf[i]); i++)
							;
					}
					else
					{
						/* skip over one non-alphanumeric character */
						++i;
					}
				}

				memmove(state->wbuf + state->curpos, state->wbuf + i,
					(state->lastchar - i) * sizeof(wchar_t));
				state->lastchar += state->curpos - i;
				break;

			case OP_EDITOR_BUFFY_CYCLE:
				if (flags & M_EFILE)
				{
					first = 1; /* clear input if user types a real key later */
					my_wcstombs(buf, buflen, state->wbuf, state->curpos);
					mutt_buffy(buf, buflen);
					state->curpos = state->lastchar = my_mbstowcs(&state->wbuf, &state->wbuflen, 0, buf);
					break;
				}
				else if (!(flags & M_FILE))
					goto self_insert;
				/* fall through to completion routine(M_FILE) */

			case OP_EDITOR_COMPLETE:
			case OP_EDITOR_COMPLETE_QUERY:
				state->tabs++;
				if (flags & M_CMD)
				{
					for(i = state->curpos; i && !is_shell_char(state->wbuf[i-1]); i--)
						;
					my_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
					if (tempbuf && templen == state->lastchar - i &&
					    !memcmp(tempbuf, state->wbuf + i,(state->lastchar - i) * sizeof(wchar_t)))
					{
						mutt_select_file(buf, buflen,(flags & M_EFILE) ? M_SEL_FOLDER : 0);
						set_bit(options, OPTNEEDREDRAW);
						if (*buf)
							replace_part(state, i, buf);
						rv = 1;
						goto bye;
					}
					if (!mutt_complete(buf, buflen))
					{
						templen = state->lastchar - i;
						safe_realloc(&tempbuf, templen * sizeof(wchar_t));
					}
					else
						BEEP();

					replace_part(state, i, buf);
				}
				else if (flags & M_ALIAS && ch == OP_EDITOR_COMPLETE)
				{
					/* invoke the alias-menu to get more addresses */
					for(i = state->curpos; i && state->wbuf[i-1] != ',' &&
						     state->wbuf[i-1] != ':'; i--)
						;
					for(; i < state->lastchar && state->wbuf[i] == ' '; i++)
						;
					my_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
					r = mutt_alias_complete(buf, buflen);
					replace_part(state, i, buf);
					if (!r)
					{
						rv = 1;
						goto bye;
					}
					break;
				}
				else if (flags & M_ALIAS && ch == OP_EDITOR_COMPLETE_QUERY)
				{
					/* invoke the query-menu to get more addresses */
					if ((i = state->curpos))
					{
						for(; i && state->wbuf[i - 1] != ','; i--)
							;
						for(; i < state->curpos && state->wbuf[i] == ' '; i++)
							;
					}

					my_wcstombs(buf, buflen, state->wbuf + i, state->curpos - i);
					mutt_query_complete(buf, buflen);
					replace_part(state, i, buf);

					rv = 1;
					goto bye;
				}
				else if (flags & M_COMMAND)
				{
					my_wcstombs(buf, buflen, state->wbuf, state->curpos);
					i = strlen(buf);
					if (i && buf[i - 1] == '=' &&
					    mutt_var_value_complete(buf, buflen, i))
						state->tabs = 0;
					else if (!mutt_command_complete(buf, buflen, i, state->tabs))
						BEEP();
					replace_part(state, 0, buf);
				}
				else if (flags &(M_FILE | M_EFILE))
				{
					my_wcstombs(buf, buflen, state->wbuf, state->curpos);

					/* see if the path has changed from the last time */
					if ((!tempbuf && !state->lastchar) ||(tempbuf && templen == state->lastchar &&
									       !memcmp(tempbuf, state->wbuf, state->lastchar * sizeof(wchar_t))))
					{
						_mutt_select_file(buf, buflen,
								  ((flags & M_EFILE) ? M_SEL_FOLDER : 0) |(multiple ? M_SEL_MULTI : 0),
								   files, numfiles);
						set_bit(options, OPTNEEDREDRAW);
						if (*buf)
						{
							mutt_pretty_mailbox(buf, buflen);
							if (!pass)
								mutt_history_add(hclass, buf, 1);
							rv = 0;
							goto bye;
						}

						/* file selection cancelled */
						rv = 1;
						goto bye;
					}

					if (!mutt_complete(buf, buflen))
					{
						templen = state->lastchar;
						safe_realloc(&tempbuf, templen * sizeof(wchar_t));
						memcpy(tempbuf, state->wbuf, templen * sizeof(wchar_t));
					}
					else
						BEEP(); /* let the user know that nothing matched */
					replace_part(state, 0, buf);
				}
				else
					goto self_insert;
				break;

			case OP_EDITOR_QUOTE_CHAR:
			{
				struct event event;
				/*ADDCH(LastKey);*/
				event = mutt_getch();
				if (event.ch >= 0)
				{
					LastKey = event.ch;
					goto self_insert;
				}
			}

			case OP_EDITOR_TRANSPOSE_CHARS:
				if (state->lastchar < 2)
					BEEP();
				else
				{
					wchar_t t;

					if (state->curpos == 0)
						state->curpos = 2;
					else if (state->curpos < state->lastchar)
						++state->curpos;

					t = state->wbuf[state->curpos - 2];
					state->wbuf[state->curpos - 2] = state->wbuf[state->curpos - 1];
					state->wbuf[state->curpos - 1] = t;
				}
				break;

			default:
				BEEP();
			}
		}
		else
		{

		self_insert:

			state->tabs = 0;
			/* use the raw keypress */
			ch = LastKey;

#if KEY_ENTER
			/* treat ENTER the same as RETURN */
			if (ch == KEY_ENTER)
				ch = '\r';
#endif

			/* quietly ignore all other function keys */
			if (ch & ~0xff)
				continue;

			/* gather the octets into a wide character */
			{
				char c;
				size_t k;

				c = ch;
				k = mbrtowc(&wc, &c, 1, &mbstate);
				if (k ==(size_t)(-2))
					continue;
				else if (k && k != 1)
				{
					memset(&mbstate, 0, sizeof(mbstate));
					continue;
				}
			}

			if (first &&(flags & M_CLEAR))
			{
				first = 0;
				if (IsWPrint(wc)) /* why? */
					state->curpos = state->lastchar = 0;
			}

			if (wc == '\r' || wc == '\n')
			{
				/* Convert from wide characters */
				my_wcstombs(buf, buflen, state->wbuf, state->lastchar);
				if (!pass)
					mutt_history_add(hclass, buf, 1);

				if (multiple)
				{
					char **tfiles;
					*numfiles = 1;
					tfiles = safe_calloc(*numfiles, sizeof(char *));
					mutt_expand_path(buf, buflen);
					tfiles[0] = safe_strdup(buf);
					*files = tfiles;
				}
				rv = 0;
				goto bye;
			}
			else if (wc &&(wc < ' ' || IsWPrint(wc))) /* why? */
			{
				if (state->lastchar >= state->wbuflen)
				{
					state->wbuflen = state->lastchar + 20;
					safe_realloc(&state->wbuf, state->wbuflen * sizeof(wchar_t));
				}
				memmove(state->wbuf + state->curpos + 1, state->wbuf + state->curpos,(state->lastchar - state->curpos) * sizeof(wchar_t));
				state->wbuf[state->curpos++] = wc;
				state->lastchar++;
			}
			else
			{
				mutt_flushinp();
				BEEP();
			}
		}
	}

bye:

	mutt_reset_history_state(hclass);
	safe_free(&tempbuf);
	return rv;
}
Example #27
0
void zorba_state::zorba(machine_config &config)
{
	// basic machine hardware
	Z80(config, m_maincpu, 24_MHz_XTAL / 6);
	m_maincpu->set_addrmap(AS_PROGRAM, &zorba_state::zorba_mem);
	m_maincpu->set_addrmap(AS_IO, &zorba_state::zorba_io);

	/* video hardware */
	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
	screen.set_color(rgb_t::green());
	screen.set_refresh_hz(50);
	screen.set_screen_update("crtc", FUNC(i8275_device::screen_update));
	GFXDECODE(config, "gfxdecode", m_palette, gfx_zorba);
	PALETTE(config, m_palette, palette_device::MONOCHROME_HIGHLIGHT);

	/* sound hardware */
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beep, 800).add_route(ALL_OUTPUTS, "mono", 1.00); // should be horizontal frequency / 16, so depends on CRTC parameters

	INPUT_MERGER_ANY_HIGH(config, "irq0").output_handler().set(FUNC(zorba_state::irq_w<0>));
	INPUT_MERGER_ANY_HIGH(config, "irq1").output_handler().set(FUNC(zorba_state::irq_w<1>));
	INPUT_MERGER_ANY_HIGH(config, "irq2").output_handler().set(FUNC(zorba_state::irq_w<2>));

	/* devices */
	Z80DMA(config, m_dma, 24_MHz_XTAL / 6);
	// busack on cpu connects to bai pin
	m_dma->out_busreq_callback().set(FUNC(zorba_state::busreq_w));  //connects to busreq on cpu
	m_dma->out_int_callback().set("irq0", FUNC(input_merger_device::in_w<0>));
	//ba0 - not connected
	m_dma->in_mreq_callback().set(FUNC(zorba_state::memory_read_byte));
	m_dma->out_mreq_callback().set(FUNC(zorba_state::memory_write_byte));
	m_dma->in_iorq_callback().set(FUNC(zorba_state::io_read_byte));
	m_dma->out_iorq_callback().set(FUNC(zorba_state::io_write_byte));

	I8251(config, m_uart0, 0); // U32 COM port J2
	m_uart0->txd_handler().set("rs232", FUNC(rs232_port_device::write_txd)); // TODO: this line has a LED attached
	m_uart0->dtr_handler().set("rs232", FUNC(rs232_port_device::write_dtr));
	m_uart0->rts_handler().set("rs232", FUNC(rs232_port_device::write_rts));
	m_uart0->rxrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<1>));
	m_uart0->txrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<0>));

	I8251(config, m_uart1, 0); // U31 printer port J3
	m_uart1->txd_handler().set("serprn", FUNC(rs232_port_device::write_txd));
	m_uart1->rts_handler().set("serprn", FUNC(rs232_port_device::write_rts));
	m_uart1->rxrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<3>));
	m_uart1->txrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<2>));

	I8251(config, m_uart2, 0); // U30 serial keyboard J6
	m_uart2->txd_handler().set("keyboard", FUNC(zorba_keyboard_device::txd_w));
	m_uart2->rxrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<5>));
	m_uart2->txrdy_handler().set(FUNC(zorba_state::tx_rx_rdy_w<4>));

	// port A - disk select etc, beeper
	// port B - parallel interface
	PIA6821(config, m_pia0, 0);
	m_pia0->writepa_handler().set(FUNC(zorba_state::pia0_porta_w));
	m_pia0->writepb_handler().set("parprndata", FUNC(output_latch_device::bus_w));
	m_pia0->cb2_handler().set("parprn", FUNC(centronics_device::write_strobe));

	// IEEE488 interface
	PIA6821(config, m_pia1, 0);
	m_pia1->readpa_handler().set(m_ieee, FUNC(ieee488_device::dio_r)); // TODO: gated with PB1
	m_pia1->writepa_handler().set(m_ieee, FUNC(ieee488_device::host_dio_w)); // TODO: gated with PB1
	m_pia1->readpb_handler().set(FUNC(zorba_state::pia1_portb_r));
	m_pia1->writepb_handler().set(FUNC(zorba_state::pia1_portb_w));
	m_pia1->ca2_handler().set(m_ieee, FUNC(ieee488_device::host_ifc_w));
	m_pia1->cb2_handler().set(m_ieee, FUNC(ieee488_device::host_ren_w));
	m_pia1->irqa_handler().set("irq1", FUNC(input_merger_device::in_w<0>));
	m_pia1->irqb_handler().set("irq1", FUNC(input_merger_device::in_w<1>));

	// PIT
	pit8254_device &pit(PIT8254(config, "pit", 0));
	pit.set_clk<0>(24_MHz_XTAL / 3);
	pit.set_clk<1>(24_MHz_XTAL / 3);
	pit.set_clk<2>(24_MHz_XTAL / 3);
	pit.out_handler<0>().set(FUNC(zorba_state::br1_w));
	pit.out_handler<1>().set(m_uart1, FUNC(i8251_device::write_txc));
	pit.out_handler<1>().append(m_uart1, FUNC(i8251_device::write_rxc));
	pit.out_handler<2>().set(m_uart2, FUNC(i8251_device::write_txc));
	pit.out_handler<2>().append(m_uart2, FUNC(i8251_device::write_rxc));

	// CRTC
	I8275(config, m_crtc, 14.318'181_MHz_XTAL / 7);
	m_crtc->set_character_width(8);
	m_crtc->set_display_callback(FUNC(zorba_state::zorba_update_chr), this);
	m_crtc->drq_wr_callback().set(m_dma, FUNC(z80dma_device::rdy_w));
	m_crtc->irq_wr_callback().set("irq0", FUNC(input_merger_device::in_w<1>));
	m_crtc->set_screen("screen");

	// Floppies
	FD1793(config, m_fdc, 24_MHz_XTAL / 24);
	m_fdc->intrq_wr_callback().set("irq2", FUNC(input_merger_device::in_w<0>));
	m_fdc->drq_wr_callback().set("irq2", FUNC(input_merger_device::in_w<1>));
	FLOPPY_CONNECTOR(config, m_floppy0, zorba_floppies, "525dd", floppy_image_device::default_floppy_formats).enable_sound(true);
	FLOPPY_CONNECTOR(config, m_floppy1, zorba_floppies, "525dd", floppy_image_device::default_floppy_formats).enable_sound(true);

	// J1 IEEE-488
	IEEE488(config, m_ieee);
	m_ieee->srq_callback().set(m_pia1, FUNC(pia6821_device::ca2_w)); // TODO: gated with PB1 from PIA

	// J2 EIA RS232/internal modem
	// TODO: this has additional lines compared to a regular RS232 port (TxC in, RxC in, RxC out, speaker in, power)
	rs232_port_device &rs232(RS232_PORT(config, "rs232", default_rs232_devices, nullptr));
	rs232.rxd_handler().set(m_uart0, FUNC(i8251_device::write_rxd)); // TODO: this line has a LED attached
	rs232.cts_handler().set(m_uart0, FUNC(i8251_device::write_cts)); // TODO: this line has a LED attached
	rs232.dsr_handler().set(m_uart0, FUNC(i8251_device::write_dsr));

	// J3 Parallel printer
	centronics_device &parprn(CENTRONICS(config, "parprn", centronics_devices, "printer"));
	parprn.busy_handler().set(m_uart1, FUNC(i8251_device::write_cts));
	parprn.busy_handler().append(m_uart1, FUNC(i8251_device::write_dsr)); // TODO: shared with serial CTS
	parprn.fault_handler().set(FUNC(zorba_state::printer_fault_w));
	parprn.select_handler().set(FUNC(zorba_state::printer_select_w));

	output_latch_device &parprndata(OUTPUT_LATCH(config, "parprndata"));
	parprn.set_output_latch(parprndata);

	// J3 Serial printer
	rs232_port_device &serprn(RS232_PORT(config, "serprn", default_rs232_devices, nullptr));
	serprn.rxd_handler().set(m_uart1, FUNC(i8251_device::write_rxd)); // TODO: this line has a LED attached

	// J6 TTL-level serial keyboard
	ZORBA_KEYBOARD(config, "keyboard").rxd_cb().set(m_uart2, FUNC(i8251_device::write_rxd));

	SOFTWARE_LIST(config, "flop_list").set_original("zorba");
}
Example #28
0
void by133_state::babypac(machine_config &config)
{
	/* basic machine hardware */
	M6800(config, m_maincpu, XTAL(3'579'545)/4); // no xtal, just 2 chips
	m_maincpu->set_addrmap(AS_PROGRAM, &by133_state::main_map);

	MC6809(config, m_videocpu, XTAL(3'579'545));
	m_videocpu->set_addrmap(AS_PROGRAM, &by133_state::video_map);

	M6803(config, m_audiocpu, XTAL(3'579'545));
	m_audiocpu->set_addrmap(AS_PROGRAM, &by133_state::sound_map);
	m_audiocpu->out_p1_cb().set("dac", FUNC(dac_byte_interface::data_w)); // P10-P17
	m_audiocpu->in_p2_cb().set(FUNC(by133_state::m6803_port2_r)); // P20-P24 sound command in
	m_audiocpu->out_p2_cb().set(FUNC(by133_state::m6803_port2_w));

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

	PIA6821(config, m_pia_u7, 0);
	m_pia_u7->readpa_handler().set(FUNC(by133_state::u7_a_r));
	m_pia_u7->writepa_handler().set(FUNC(by133_state::u7_a_w));
	m_pia_u7->readpb_handler().set(FUNC(by133_state::u7_b_r));
	m_pia_u7->writepb_handler().set(FUNC(by133_state::u7_b_w));
	m_pia_u7->ca2_handler().set(FUNC(by133_state::u7_ca2_w));
	m_pia_u7->cb2_handler().set(FUNC(by133_state::u7_cb2_w));
	m_pia_u7->irqa_handler().set_inputline("videocpu", M6809_FIRQ_LINE);
	m_pia_u7->irqa_handler().set_inputline("videocpu", M6809_FIRQ_LINE);

	PIA6821(config, m_pia_u10, 0);
	m_pia_u10->readpa_handler().set(FUNC(by133_state::u10_a_r));
	m_pia_u10->writepa_handler().set(FUNC(by133_state::u10_a_w));
	m_pia_u10->readpb_handler().set(FUNC(by133_state::u10_b_r));
	m_pia_u10->writepb_handler().set(FUNC(by133_state::u10_b_w));
	m_pia_u10->ca2_handler().set(FUNC(by133_state::u10_ca2_w));
	m_pia_u10->cb2_handler().set(FUNC(by133_state::u10_cb2_w));
	m_pia_u10->irqa_handler().set_inputline("maincpu", M6800_IRQ_LINE);
	m_pia_u10->irqb_handler().set_inputline("maincpu", M6800_IRQ_LINE);
	TIMER(config, "babypac1").configure_periodic(FUNC(by133_state::u10_timer), attotime::from_hz(120)); // mains freq*2

	PIA6821(config, m_pia_u11, 0);
	m_pia_u11->readpa_handler().set(FUNC(by133_state::u11_a_r));
	m_pia_u11->writepa_handler().set(FUNC(by133_state::u11_a_w));
	m_pia_u11->readpb_handler().set(FUNC(by133_state::u11_b_r));
	m_pia_u11->writepb_handler().set(FUNC(by133_state::u11_b_w));
	m_pia_u11->ca2_handler().set(FUNC(by133_state::u11_ca2_w));
	m_pia_u11->cb2_handler().set(FUNC(by133_state::u11_cb2_w));
	m_pia_u11->irqa_handler().set_inputline("maincpu", M6800_IRQ_LINE);
	m_pia_u11->irqb_handler().set_inputline("maincpu", M6800_IRQ_LINE);
	TIMER(config, "babypac2").configure_periodic(FUNC(by133_state::u11_timer), attotime::from_hz(634)); // 555 timer*2

	/* video hardware */
	TMS9928A(config, m_crtc, XTAL(10'738'635)).set_screen("screen");
	m_crtc->set_vram_size(0x4000);
	m_crtc->int_callback().set_inputline(m_videocpu, M6809_IRQ_LINE);
	SCREEN(config, "screen", SCREEN_TYPE_RASTER);

	/* sound hardware */
	SPEAKER(config, "speaker").front_center();
	ZN429E(config, "dac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25); // U32 (Vidiot) or U6 (Cheap Squeak)
	voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref"));
	vref.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT);

	SPEAKER(config, "beee").front_center();
	BEEP(config, m_beep, 600).add_route(ALL_OUTPUTS, "beee", 0.10);
}
Example #29
0
int main()
{
	char	str[128];
	char	compiler[128];
	char	fpath[MAX_PATH+1];
	char*	path = ".";
	char*	glob_pattern = "*wrap*";
	int		i;
	int		ch;
	uint	u;
	time_t	t;
	glob_t	g;
	DIR*	dir;
	DIRENT*	dirent;
	thread_data_t thread_data;
	int	fd;
	int	fd2;
	int	canrelock=0;
	clock_t	ticks;

	/* Show platform details */
	DESCRIBE_COMPILER(compiler);
	printf("%-15s: %s\n","Platform",PLATFORM_DESC);
	printf("%-15s: %s\n","Version",os_version(str));
	printf("%-15s: %s\n","Compiler"	,compiler);
	printf("%-15s: %d\n","Random Number",xp_random(1000));

	for(i=0;i<3;i++) {
		if(_beginthread(
			  sopen_child_thread	/* entry point */
			 ,0  					/* stack size (0=auto) */
			 ,(void*)i				/* data */
			 )==(unsigned long)-1)
			printf("_beginthread failed\n");
		else
			SLEEP(1);
	}
	printf("Waiting for all sopen_child_threads to close...\n");
	SLEEP(5000);	/* wait for all threads to quit */

	/* Exclusive sopen test */
	printf("\nsopen() test\n");
	if((fd=sopen(LOCK_FNAME,O_RDWR|O_CREAT,SH_DENYRW,S_IREAD|S_IWRITE))==-1) {
		perror(LOCK_FNAME);
		return(errno);
	}
	printf("%s is opened with an exclusive (read/write) lock\n",LOCK_FNAME);
	getkey();
	if(_beginthread(
		  sopen_test_thread	/* entry point */
		 ,0  				/* stack size (0=auto) */
		 ,NULL				/* data */
		 )==(unsigned long)-1)
		printf("_beginthread failed\n");
	else
		SLEEP(1000);
	close(fd);

	/* sopen()/lock test */
	printf("\nlock() test\n");
	if((fd=sopen(LOCK_FNAME,O_RDWR|O_CREAT,SH_DENYNO,S_IREAD|S_IWRITE))==-1) {
		perror(LOCK_FNAME);
		return(errno);
	}
	write(fd,"lock testing\n",LOCK_LEN);
	if(lock(fd,LOCK_OFFSET,LOCK_LEN)==0)
		printf("lock() succeeds\n");
	else
		printf("!FAILURE: lock() non-functional (or file already locked)\n");
	if(lock(fd,LOCK_OFFSET,LOCK_LEN)==0)  {
		printf("!FAILURE: Subsequent lock of region was allowed (will skip some tests)\n");
		canrelock=1;
	}
		
	if(_beginthread(
		  lock_test_thread	/* entry point */
		 ,0  				/* stack size (0=auto) */
		 ,NULL				/* data */
		 )==(unsigned long)-1)
		printf("_beginthread failed\n");
	else
		SLEEP(1000);
	if(canrelock)
		printf("?? Skipping some tests due to inability to detect own locks\n");
	else  {
		if(lock(fd,LOCK_OFFSET,LOCK_LEN))
			printf("Locks in first thread survive open()/close() in other thread\n");
		else
			printf("!FAILURE: lock() in first thread lost by open()/close() in other thread\n");
		if(lock(fd,LOCK_OFFSET+LOCK_LEN+1,LOCK_LEN))
			printf("!FAILURE: file locking\n");
		else
			printf("Record locking\n");
	}
	if((fd2=sopen(LOCK_FNAME,O_RDWR,SH_DENYRW))==-1) {
		printf("Cannot reopen SH_DENYRW while lock is held\n");
		close(fd2);
	}
	else  {
		printf("!FAILURE: can reopen SH_DENYRW while lock is held\n");
	}
	if(unlock(fd,LOCK_OFFSET,LOCK_LEN))
		printf("!FAILURE: unlock() non-functional\n");
	if(lock(fd,LOCK_OFFSET+LOCK_LEN+1,LOCK_LEN))
		printf("Cannot re-lock after non-overlapping unlock()\n");
	else
		printf("!FAILURE: can re-lock after non-overlappping unlock()\n");
	if(lock(fd,LOCK_OFFSET,LOCK_LEN))
		printf("!FAILURE: cannot re-lock unlocked area\n");
	close(fd);

	/* getch test */
	printf("\ngetch() test (ESC to continue)\n");
	do {
		ch=getch();
		printf("getch() returned %d\n",ch);
	} while(ch!=ESC);

	/* kbhit test */
	printf("\nkbhit() test (any key to continue)\n");
	while(!kbhit()) {
		printf(".");
		fflush(stdout);
		SLEEP(500);
	}
	getch();	/* remove character from keyboard buffer */

	/* BEEP test */
	printf("\nBEEP() test\n");
	getkey();
	for(i=750;i>250;i-=5)
		BEEP(i,15);
	for(;i<1000;i+=5)
		BEEP(i,15);

	/* SLEEP test */
	printf("\nSLEEP(5 second) test\n");
	getkey();
	t=time(NULL);
	printf("sleeping... ");
	fflush(stdout);
	ticks=msclock();
	SLEEP(5000);
	printf("slept %ld seconds (%ld according to msclock)\n",time(NULL)-t,(msclock()-ticks)/MSCLOCKS_PER_SEC);

	/* Thread SLEEP test */
	printf("\nThread SLEEP(5 second) test\n");
	getkey();
	i=0;
	if(_beginthread(
		  sleep_test_thread	/* entry point */
		 ,0					/* stack size (0=auto) */
		 ,&i				/* data */
		 )==(unsigned long)-1)
		printf("_beginthread failed\n");
	else {
		SLEEP(1);			/* yield to child thread */
		while(i==0) {
			printf(".");
			fflush(stdout);
			SLEEP(1000);
		}
	}

	/* glob test */
	printf("\nglob(%s) test\n",glob_pattern);
	getkey();
	i=glob(glob_pattern,GLOB_MARK,NULL,&g);
	if(i==0) {
		for(u=0;u<g.gl_pathc;u++)
			printf("%s\n",g.gl_pathv[u]);
		globfree(&g);
	} else
		printf("glob(%s) returned %d\n",glob_pattern,i);

	/* opendir (and other directory functions) test */
	printf("\nopendir(%s) test\n",path);
	getkey();
	printf("\nDirectory of %s\n\n",FULLPATH(fpath,path,sizeof(fpath)));
	dir=opendir(path);
	while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
		t=fdate(dirent->d_name);
		printf("%.24s %10lu  %06o  %s%c\n"
			,ctime(&t)
			,flength(dirent->d_name)
			,getfattr(dirent->d_name)
			,dirent->d_name
			,isdir(dirent->d_name) ? '/':0
			);
	}
	if(dir!=NULL)
		closedir(dir);
	printf("\nFree disk space: %lu kbytes\n",getfreediskspace(path,1024));

	/* Thread (and inter-process communication) test */
	printf("\nSemaphore test\n");
	getkey();
	if(sem_init(&thread_data.parent_sem
		,0 /* shared between processes */
		,0 /* initial count */
		)) {
		printf("sem_init failed\n");
	}
	if(sem_init(&thread_data.child_sem
		,0	/* shared between processes */
		,0	/* initial count */
		)) {
		printf("sem_init failed\n");
	}
	if(_beginthread(
		  sem_test_thread	/* entry point */
		 ,0					/* stack size (0=auto) */
		 ,&thread_data		/* data */
		 )==(unsigned long)-1)
		printf("_beginthread failed\n");
	else {
		sem_wait(&thread_data.child_sem);	/* wait for thread to begin */
		for(i=0;i<10;i++) {
			printf("<parent>");
			sem_post(&thread_data.parent_sem);
			sem_wait(&thread_data.child_sem);
		}
		sem_wait(&thread_data.child_sem);	/* wait for thread to end */
	}
	sem_destroy(&thread_data.parent_sem);
	sem_destroy(&thread_data.child_sem);

	printf("\nSemaphore blocking test\n");
	getkey();
	sem_init(&thread_data.parent_sem
		,0 /* shared between processes */
		,0 /* initial count */
		);
	sem_init(&thread_data.child_sem
		,0	/* shared between processes */
		,0	/* initial count */
		);
	if(_beginthread(
		  sem_test_thread_block	/* entry point */
		 ,0					/* stack size (0=auto) */
		 ,&thread_data		/* data */
		 )==(unsigned long)-1)
		printf("_beginthread failed\n");
	else {
		sem_wait(&thread_data.child_sem);	/* wait for thread to begin */
		for(i=0;i<10;i++) {
			printf("<parent>");
			SLEEP(5000);
			sem_post(&thread_data.parent_sem);
			sem_wait(&thread_data.child_sem);
		}
		sem_wait(&thread_data.child_sem);	/* wait for thread to end */
	}
	printf("\nsem_trywait_block test...");
	t=time(NULL);
	sem_trywait_block(&thread_data.parent_sem,5000);
	printf("\ntimed-out after %ld seconds (should be 5 seconds)\n",time(NULL)-t);
	sem_destroy(&thread_data.parent_sem);
	sem_destroy(&thread_data.child_sem);
	printf("\nendian check...");
	memcpy(&i,"\x01\x02\x03\x04",4);
	if(LE_LONG(i)==67305985) {
		printf("OK!\n");
	}
	else {
		printf("FAILED!\n");
	}
	return 0;
}