Exemplo n.º 1
0
void os_printchar (char c)
{
  if (Window == 0)
  {
    if (c == '\r')
      c = '\n';
    fputc (c, stdout);
    return;
  }

  if (c == '\r')
  {
    os_flush ();
    ClipBlit (RastPort,
	      Window->BorderLeft,
	      Window->BorderTop + RastPort->TxHeight,
	      RastPort,
	      Window->BorderLeft,
	      Window->BorderTop,
	      Window->Width - Window->BorderLeft - Window->BorderRight,
	      DisplayHeight * RastPort->TxHeight, 0xC0);
    rect (Window->BorderLeft,
	  Window->BorderTop + DisplayHeight * RastPort->TxHeight,
	  Window->Width - Window->BorderRight - 1,
	  Window->BorderTop + (DisplayHeight + 1) * RastPort->TxHeight - 1, 0);
    reset_cursor ();

    if (scriptfile == NULL)
    {
      if (++MoreCount >= DisplayHeight)
      {
	MoreCount = 0;
	text ("[More]", 6);
	cursor (0);
	get_key (0, -1, 1);
	cursor (0);
	rect (Window->BorderLeft,
	      Window->BorderTop + DisplayHeight * RastPort->TxHeight,
	      Window->Width - Window->BorderRight - 1,
	      Window->BorderTop + (DisplayHeight + 1) * RastPort->TxHeight - 1, 0);
        reset_cursor ();
      }
    }

    return;
  }

  if (isprint(c) == 0)
    return;
  if (TextBufferPtr >= TEXTBUFFER_SIZE)
    os_flush ();
  *(TextBuffer + (TextBufferPtr++)) = c;
}
Exemplo n.º 2
0
void os_printchar(char c)
{
	if (c == '\r')
	{
		os_flush();
		putchar('\n');
		Column = 0;
	}
	else if (isprint(c) != 0)
	{
		if (TextBufferPtr >= TEXTBUFFER_SIZE)
			os_flush();
		*(TextBuffer + (TextBufferPtr++)) = c;
	}
}
Exemplo n.º 3
0
/* pause prior to exit */
void os_expause(void)
{
    os_printz("(Strike any key to exit...)");
    os_flush();
    os_waitc();
    os_printz("\n");
}
Exemplo n.º 4
0
L9BOOL os_input(char *ibuff, int size)
{
char *nl;

	os_flush();
	fgets(ibuff, size, stdin);
	nl = strchr(ibuff, '\n');
	if (nl)
		*nl = 0;
	return TRUE;
}
Exemplo n.º 5
0
void cursor (int under)
{
  int size;

  os_flush ();
  size = (under == 0) ? RastPort->TxWidth : char_len (under);

  SetDrMd (RastPort, COMPLEMENT);
  rect (RastPort->cp_x, RastPort->cp_y,
     RastPort->cp_x + size - 1, RastPort->cp_y + RastPort->TxHeight - 1, 0);
  SetDrMd (RastPort, JAM2);
}
Exemplo n.º 6
0
L9BOOL os_get_game_file(char *NewName,int Size)
{
char *nl;

	os_flush();
	printf("Load next game: ");
	fgets(NewName, Size, stdin);
	nl = strchr(NewName, '\n');
	if (nl)
		*nl = 0;
	return TRUE;
}
Exemplo n.º 7
0
FILE* os_open_script_file(void)
{
char name[256];
char *nl;

	os_flush();
	printf("Script file: ");
	fgets(name, 256, stdin);
	nl = strchr(name, '\n');
	if (nl)
		*nl = 0;
	return fopen(name, "rt");
}
Exemplo n.º 8
0
void ramo_write_to(OutStream *os, OutStream *other_o)
{
    int i, len;
    RAMFile *rf = os->file.rf;
    int last_buffer_number;
    int last_buffer_offset;

    os_flush(os);
    last_buffer_number = (int) (rf->len / BUFFER_SIZE);
    last_buffer_offset = rf->len % BUFFER_SIZE;
    for (i = 0; i <= last_buffer_number; i++) {
        len = (i == last_buffer_number ? last_buffer_offset : BUFFER_SIZE);
        os_write_bytes(other_o, rf->buffers[i], len);
    }
}
Exemplo n.º 9
0
L9BOOL os_load_file(L9BYTE *Ptr,int *Bytes,int Max)
{
char name[256];
char *nl;
FILE *f;

	os_flush();
	printf("Load file: ");
	fgets(name, 256, stdin);
	nl = strchr(name, '\n');
	if (nl)
		*nl = 0;
	f = fopen(name, "rb");
	if (!f)
		return FALSE;
	*Bytes = fread(Ptr, 1, Max, f);
	fclose(f);
	return TRUE;
}
Exemplo n.º 10
0
L9BOOL os_save_file(L9BYTE * Ptr, int Bytes)
{
char name[256];
char *nl;
FILE *f;

	os_flush();
	printf("Save file: ");
	fgets(name, 256, stdin);
	nl = strchr(name, '\n');
	if (nl)
		*nl = 0;
	f = fopen(name, "wb");
	if (!f)
		return FALSE;
	fwrite(Ptr, 1, Bytes, f);
	fclose(f);
	return TRUE;
}
Exemplo n.º 11
0
char os_readchar(int millis)
{
	static int count = 0;
	char c;

	os_flush();
	if (millis == 0)
		return 0;

	/* Some of the Level 9 games expect to be able to wait for
	   a character for a short while as a way of pausing, and
	   expect 0 to be returned, while the multiple-choice games
	   (such as The Archers) expect 'proper' keys from this
	   routine.

	   To get round this, we return 0 for the first 1024 calls,
	   and 'proper' keys thereafter. Since The Archers and
	   similar games ignore the returned zeros, this works quite
	   well. A 'correct' port would solve this properly by
	   implementing a timed wait for a key, but this is not
	   possible using only C stdio-functions.
	*/
	if (++count < 1024)
		return 0;
	count = 0;

	c = getc(stdin); /* will require enter key as well */
	if (c != '\n')
	{
		while (getc(stdin) != '\n')
		{
			/* unbuffer input until enter key */
		}
	}

	return c;
}
Exemplo n.º 12
0
int get_key (UWORD * qualifier_addr, int c, int wait)
{
  struct IntuiMessage *imsg;
  ULONG class;
  UWORD code, qualifier;
  int old_height;

  os_flush ();
  while (1)
  {
    while (imsg = (struct IntuiMessage *) GetMsg (Window->UserPort))
    {
      class = imsg->Class;
      code = imsg->Code;
      qualifier = imsg->Qualifier;
      ReplyMsg ((struct Message *) imsg);
      if (qualifier_addr)
	*qualifier_addr = qualifier;
      switch (class)
      {
      case IDCMP_RAWKEY:
	switch (code)
	{
	case 0x4C:
	  return 129;
	case 0x4D:
	  return 130;
	case 0x4F:
	  return 131;
	case 0x4E:
	  return 132;
	case 0x5F:
	  help ();
	  break;
	}
	break;
      case IDCMP_VANILLAKEY:
	switch (code)
	{
	case 8:
	  return 127;
	case 13:
	  return 13;
	case 127:
	  return 260;
	default:
	  if (code >= 32 && code <= 126)
	    return code;
	  break;
	}
	break;
      case IDCMP_CLOSEWINDOW:
	exit (0);
	break;
      case IDCMP_CHANGEWINDOW:
	old_height = DisplayHeight;
	DisplayHeight = ((Window->Height - Window->BorderTop - Window->BorderBottom) / RastPort->TxHeight) - 1;

	if (PreviousHeight > DisplayHeight)
	{
	  rect (Window->BorderLeft,
		Window->BorderTop + (DisplayHeight * RastPort->TxHeight),
		Window->Width - Window->BorderRight - 1,
		Window->Height - Window->BorderBottom - 1, 0);

	  if (RastPort->cp_y + RastPort->TxHeight > Window->Height - Window->BorderBottom)
	  {
	    Move (RastPort, RastPort->cp_x, Window->BorderTop + (DisplayHeight * RastPort->TxHeight));
	    rect (Window->BorderLeft, RastPort->cp_y,
		  Window->Width - Window->BorderRight - 1,
		  RastPort->cp_y + RastPort->TxHeight - 1, 0);
	    PreviousHeight = DisplayHeight;
	    return 264;
	  }
	}
	PreviousHeight = DisplayHeight;
	break;
      case IDCMP_MENUPICK:
	if (code != MENUNULL)
	{
	  if (MENUNUM (code) == 0)
	  {
	    switch (ITEMNUM (code))
	    {
	    case 0:
	      if (c != -1)
	      {
		cursor (c);
		SetAPen (RastPort, 1);
		int r = newgame (0);
		SetAPen (RastPort, 2);
		cursor (c);
		if (r != 0)
		  return r;
	      }
	      break;
	    case 2:
	      if (c != -1)
		return -2;
	      break;
	    case 3:
	      if (c != -1)
		return -3;
	      break;
	    case 5:
	      help ();
	      break;
	    case 6:
	      about ();
	      break;
	    case 8:
	      exit (0);
	      break;
	    }
	  }
	}
	break;
      }
    }
    if (wait)
      WaitPort (Window->UserPort);
    else
      return 0;
  }
}