예제 #1
0
static void draw_text_error(void)
{
	int x = 0;
	int y = 0;
	int dx = text_size_x();
	int dy = text_size_y();
	
	text_clear();

	draw_text_center(x, y, dx,
"ERROR! An error occurred in your last action!"
	, COLOR_REVERSE);
	++y;

	++y;
	y = draw_text_para(x, y, dx, dy,
"Your action has generated an error. Probably you have requested an "
"unsupported feature by your hardware or software."
	, COLOR_NORMAL);

	if (*error_get()) {
		y = draw_text_para(x, y, dx, dy-y, "\nThe video software reports this error:", COLOR_NORMAL);
		log_std(("v: error \"%s\"\n", error_get()));
		y = draw_text_para(x, y, dx, dy-y, error_get(), COLOR_ERROR);
	}

	y = draw_text_para(x, y, dx, dy-y, "\nPress ESC", COLOR_NORMAL);

	video_wait_vsync();

	do {
		target_idle();
		os_poll();
	} while (inputb_get()==INPUTB_NONE);
}
예제 #2
0
파일: exit.c 프로젝트: nmlgc/ReC98
void game_exit(void)
{
	pfend();
	graph_clear_both();
	vsync_end();
	mem_unassign();
	text_clear();
	egc_start();
}
예제 #3
0
파일: subtitle.c 프로젝트: iizukanao/picam
/**
 * Call this function before calling text_draw_all().
 */
void subtitle_update() {
  struct timespec ts;

  if (hide_time > 0) {
    clock_gettime(CLOCK_MONOTONIC, &ts);
    int64_t current_time = ts.tv_sec * INT64_C(1000000000) + ts.tv_nsec;
    if (current_time > hide_time) {
      text_clear(text_id);
      hide_time = 0;
    }
  }
}
예제 #4
0
파일: check_text.c 프로젝트: klo99/lvdbg
END_TEST

START_TEST (test_text_line)
{
  text *text;
  int i;
  char buf[128];
  const char *p;
  int ret;
  int len;

  text = text_create ();
  fail_unless (text != NULL);

  for (i = 0; i < 120; i++)
    {
      sprintf (buf, "Line nr %d", i);
      ret = text_add_line (text, buf);
      fail_unless (ret == i + 1);
      fail_unless (text_nr_of_lines (text) == i + 1);
    }

  for (i = 0; i < 120; i++)
    {
      sprintf (buf, "Line nr %d", i);
      p = text_get_line (text, i, &len);
      fail_unless (p != NULL);
      fail_unless (strlen (buf) == len);
      fail_unless (strcmp (p, buf) == 0);
    }
  p = text_get_line (text, 500, &len);
  fail_unless (p == NULL);
  p = text_get_line (text, -50, &len);
  fail_unless (p == NULL);

  text_clear (text);
  fail_unless (text_nr_of_lines (text) == 0);
  ret = text_add_line (text, "\001");
  fail_unless (ret < 0);
  fail_unless (text_nr_of_lines (text) == 0);
  ret = text_add_line (text, "\t");
  fail_unless (ret == 1);
  fail_unless (text_nr_of_lines (text) == 1);
  p = text_get_line (text, 0, &len);
  fail_unless (p != NULL);
  fail_unless (len == 2);
  fail_unless (strcmp (p, "  ") == 0);

  text_free (text);
}
예제 #5
0
파일: newline.c 프로젝트: imuli/prompt
static void
do_kill(int len){
	if(!kill_roll) text_clear(yank);
	kill_roll=2;
	if(len < 0){
		text_shift(line, len);
		len = -len;
		text_shift(yank, -yank->off);
	} else {
		text_shift(yank, yank->buf->c - yank->off);
	}
	text_insert(yank, line->buf->r + line->off, len);
	text_delete(line, len);
}
예제 #6
0
static void draw_text_help(void)
{
	int x = 0;
	int y = 0;
	int dx = text_size_x();
	int dy = text_size_y();

	text_clear();

	y = draw_text_para(x, y, dx, dy,
" HELP"
	, COLOR_REVERSE);

	y = draw_text_para(x, y, dx, dy-y,
"F2    Save the selected modes\n"
"F5    Create a new modeline (favourite modes with the specified size)\n"
"F6    Create a new modeline (favourite modes with the specified clock)\n"
"F7    Duplicate the current mode\n"
"F8    Set an arbitrary clock value\n"
"F9    Show a static test screen for the current video mode\n"
"F10   Show a dynamic test screen for the current video mode\n"
"SPACE Select/Unselect the current video mode\n"
"ENTER Test the current video mode\n"
"TAB   Rename the current video mode\n"
"ESC   Exit\n"
"\n"
"q/a   Increase the x/y Display End register (SHIFT to decrease)\n"
"w/s   Increase the x/y Blank Start register (SHIFT to decrease)\n"
"e/d   Increase the x/y Retrace Start register (SHIFT to decrease)\n"
"r/f   Increase the x/y Retrace End register (SHIFT to decrease)\n"
"t/g   Increase the x/y Blank End register (SHIFT to decrease)\n"
"y/h   Increase the x/y Total End register (SHIFT to decrease)\n"
"u/j   Change the polarization\n"
"i/k   Expand the x/y size (SHIFT to shrink)\n"
"v     Increase the pixel clock (SHIFT to decrease)\n"
"x/c   Change the scan line mode\n"
"n/m   Change the tv mode\n"
"\n"
"Press ESC"
	, COLOR_NORMAL);

	video_wait_vsync();

	do {
		target_idle();
		os_poll();
	} while (inputb_get()==INPUTB_NONE);
}
예제 #7
0
파일: newline.c 프로젝트: imuli/prompt
static void
history_restore(){
	FILE *f;
	int len, i;
	if((f = fopen(history_file, "r")) == NULL) return;
	while(1){
		text_clear(line);
		if((len = fget_rune(f)) == EOF) break;
		for(i = 0; i<len; i++)
			insert_character(fget_rune(f), NULL, 0);
		history_save();
		history_add();
		hist_first++;
	}
	fclose(f);
}
예제 #8
0
int parse_command(char *string, int length) {
	char *command;
	char *origstring = string;
	int parsed=0;

#ifdef DEBUG
	fprintf (logfile, "%s\n", string);
	fflush (logfile);
#endif

	parsed = strlen(string)+1;
	
	if (strcmp(string,"QUIT")==0) {
		return 1;
	}	

	command = strtok(string," ");

	if (strcmp(command,"TEXT")==0) {
		char *line = strtok(NULL,"\0");
		int length = strlen(line);		
		while (length>50) {
			draw_text(line,50);
			line+=50;
			length-=50;
		}
		draw_text(line,length);
	} else if (strcmp(command,"STATUS")==0) {
		draw_status(strtok(NULL,"\0"),0);
	} else if (strcmp(command,"SUCCESS")==0) {
		draw_status(strtok(NULL,"\0"),TEXT_FOREGROUND);
	} else if (strcmp(command,"FAILURE")==0) {
		draw_status(strtok(NULL,"\0"),RED);
	} else if (strcmp(command,"PROGRESS")==0) {
		draw_progress(atoi(strtok(NULL,"\0")));
	} else if (strcmp(command,"CLEAR")==0) {
		text_clear();
	} else if (strcmp(command,"TIMEOUT")==0) {
		timeout=(atoi(strtok(NULL,"\0")));
	} else if (strcmp(command,"QUIT")==0) {
		return 1;
	}

	return 0;
}
예제 #9
0
파일: op_01.c 프로젝트: nmlgc/ReC98
void start_demo(void)
{
    mikoconfig->rem_lives = 2;
    mikoconfig->rem_bombs = 3;
    mikoconfig->start_lives = 2;
    mikoconfig->start_bombs = 3;
    mikoconfig->bgm_mode = snd_bgm_mode;
    mikoconfig->rank = RANK_NORMAL;
    mikoconfig->continues_used = 0;
    mikoconfig->unused_3 = 0;
    mikoconfig->demo_num = demo_num;
    mikoconfig->shottype = 0;
    cfg_save();
    text_clear();
    graph_pi_free(&pi_slot_headers[0], pi_slot_buffers[0]);
    graph_pi_free(&pi_slot_headers[1], pi_slot_buffers[1]);
    graph_pi_free(&pi_slot_headers[2], pi_slot_buffers[2]);
    gaiji_restore();
    super_free();
    game_exit();
    execl("main", "main", 0, 0);
}
예제 #10
0
/*
 * Initialize an IterParser object
 *
 * The Python arguments are:
 *
 *    *fd*: A Python file object or a callable object
 *    *buffersize*: The size of the read buffer
 */
static int
IterParser_init(IterParser *self, PyObject *args, PyObject *kwds)
{
    PyObject* fd              = NULL;
    PyObject* read            = NULL;
    ssize_t   buffersize      = 1 << 14;

    static char *kwlist[] = {"fd", "buffersize", NULL};
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:IterParser.__init__", kwlist,
                                     &fd, &buffersize)) {
        return -1;
    }

    /* Keep the buffersize within a reasonable range */
    self->buffersize = CLAMP(buffersize, (ssize_t)(1 << 10), (ssize_t)(1 << 24));
#ifdef __clang__
    /* Clang can't handle the file descriptors Python gives us,
       so in that case, we just call the object's read method. */
    read = PyObject_GetAttrString(fd, "read");
    if (read != NULL) {
        fd = read;
    }
#else
    self->file = PyObject_AsFileDescriptor(fd);
    if (self->file != -1) {
        /* This is a real C file handle or descriptor.  We therefore
           need to allocate our own read buffer, and get the real C
           object. */
        self->buffer = malloc((size_t)self->buffersize);
        if (self->buffer == NULL) {
            PyErr_SetString(PyExc_MemoryError, "Out of memory");
            goto fail;
        }
        self->fd = fd;   Py_INCREF(self->fd);
        lseek(self->file, 0, SEEK_SET);
    } else
#endif
    if (PyCallable_Check(fd)) {
        /* fd is a Python callable */
        self->fd = fd;   Py_INCREF(self->fd);
        self->read = fd; Py_INCREF(self->read);
    } else {
        PyErr_SetString(
            PyExc_TypeError,
            "Arg 1 to iterparser must be a file object or callable object");
        goto fail;
    }

    PyErr_Clear();

    self->queue_read_idx  = 0;
    self->queue_write_idx = 0;
    self->done            = 0;

    self->text = malloc((size_t)buffersize * sizeof(XML_Char));
    self->text_alloc = buffersize;
    if (self->text == NULL) {
        PyErr_SetString(PyExc_MemoryError, "Out of memory");
        goto fail;
    }
    text_clear(self);

    self->read_args = Py_BuildValue("(n)", buffersize);
    if (self->read_args == NULL) {
        goto fail;
    }

    self->dict_singleton = PyDict_New();
    if (self->dict_singleton == NULL) {
        goto fail;
    }

    self->td_singleton = PyUnicode_FromString("TD");
    if (self->td_singleton == NULL) {
        goto fail;
    }

    if (queue_realloc(self, buffersize)) {
        goto fail;
    }

    /* Set up an expat parser with our callbacks */
    self->parser = XML_ParserCreate(NULL);
    if (self->parser == NULL) {
        PyErr_SetString(PyExc_MemoryError, "Out of memory");
        goto fail;
    }
    XML_SetUserData(self->parser, self);
    XML_SetElementHandler(
        self->parser,
        (XML_StartElementHandler)startElement,
        (XML_EndElementHandler)endElement);
    XML_SetCharacterDataHandler(
        self->parser,
        (XML_CharacterDataHandler)characterData);
    XML_SetXmlDeclHandler(
        self->parser,
        (XML_XmlDeclHandler)xmlDecl);

    Py_XDECREF(read);

    return 0;

 fail:
    Py_XDECREF(read);
    Py_XDECREF(self->fd);
    Py_XDECREF(self->read);
    free(self->text);
    Py_XDECREF(self->dict_singleton);
    Py_XDECREF(self->td_singleton);
    Py_XDECREF(self->read_args);
    free(self->queue);

    return -1;
}
예제 #11
0
/*
 * Handle the expat startElement event.
 */
static void
startElement(IterParser *self, const XML_Char *name, const XML_Char **atts)
{
    PyObject*        pyname = NULL;
    PyObject*        pyatts = NULL;
    const XML_Char** att_ptr = atts;
    const XML_Char*  name_start = NULL;
    PyObject*        tuple = NULL;
    PyObject*        key = NULL;
    PyObject*        val = NULL;
    PyObject*        pos = NULL;

    /* If we've already had an error in a previous call, don't make
       things worse. */
    if (PyErr_Occurred() != NULL) {
        XML_StopParser(self->parser, 0);
        return;
    }

    /* Don't overflow the queue -- in practice this should *never* happen */
    if (self->queue_write_idx < self->queue_size) {
        tuple = PyTuple_New(4);
        if (tuple == NULL) {
            goto fail;
        }

        Py_INCREF(Py_True);
        PyTuple_SET_ITEM(tuple, 0, Py_True);

        /* This is an egregious but effective optimization.  Since by
           far the most frequently occurring element name in a large
           VOTABLE file is TD, we explicitly check for it here with
           integer comparison to avoid the lookup in the interned
           string table in PyString_InternFromString, and return a
           singleton string for "TD" */
        if ((*(int*)name & TD_AS_INT_MASK) == TD_AS_INT) {
            Py_INCREF(self->td_singleton);
            PyTuple_SetItem(tuple, 1, self->td_singleton);
        } else {
            name_start = remove_namespace(name);

            pyname = PyUnicode_FromString(name_start);
            if (pyname == NULL) {
                goto fail;
            }
            PyTuple_SetItem(tuple, 1, pyname);
            pyname = NULL;
        }

        if (*att_ptr) {
            pyatts = PyDict_New();
            if (pyatts == NULL) {
                goto fail;
            }
            do {
                if (*(*(att_ptr + 1)) != 0) {
                    key = PyUnicode_FromString(*att_ptr);
                    if (key == NULL) {
                        goto fail;
                    }
                    val = PyUnicode_FromString(*(att_ptr + 1));
                    if (val == NULL) {
                        Py_DECREF(key);
                        goto fail;
                    }
                    if (PyDict_SetItem(pyatts, key, val)) {
                        Py_DECREF(key);
                        Py_DECREF(val);
                        goto fail;
                    }
                    Py_DECREF(key);
                    Py_DECREF(val);
                    key = val = NULL;
                }
                att_ptr += 2;
            } while (*att_ptr);
        } else {
            Py_INCREF(self->dict_singleton);
            pyatts = self->dict_singleton;
        }

        PyTuple_SetItem(tuple, 2, pyatts);
        pyatts = NULL;

        self->last_line = (unsigned long)XML_GetCurrentLineNumber(
            self->parser);
        self->last_col = (unsigned long)XML_GetCurrentColumnNumber(
            self->parser);

        pos = make_pos(self);
        if (pos == NULL) {
            goto fail;
        }
        PyTuple_SetItem(tuple, 3, pos);
        pos = NULL;

        text_clear(self);

        self->keep_text = 1;

        self->queue[self->queue_write_idx++] = tuple;
    } else {
        PyErr_SetString(
            PyExc_RuntimeError,
            "XML queue overflow in startElement.  This most likely indicates an internal bug.");
        goto fail;
    }

    return;

 fail:
    Py_XDECREF(tuple);
    Py_XDECREF(pyatts);
    XML_StopParser(self->parser, 0);
}
예제 #12
0
파일: check_text.c 프로젝트: klo99/lvdbg
END_TEST

START_TEST (test_text_load)
{
  text *text;
  int i;
  int ret;
  char buf[64];
  const char *p;
  int len;

  text = text_load_file (CONFDIR "/text_WRONG.txt");
  fail_unless (text == NULL);

  text = text_load_file (CONFDIR "/text_test.txt");
  fail_unless (text != NULL);
  for (i = 0; i < 120; i++)
    {
      sprintf (buf, "  Line %d", i);
      p = text_get_line (text, i, &len);
      fail_unless (p != NULL);
      fail_unless (strlen (buf) == len, "%d len = %d != %d", i, len,
		   strlen (buf));
      fail_unless (strcmp (p, buf) == 0);
    }
  fail_unless (text_nr_of_lines (text) == 120);

  text_clear (text);
  fail_unless (text_nr_of_lines (text) == 0);

  ret = text_update_from_file (text, CONFDIR "/text_WRONG.txt");
  fail_unless (ret < 0);

  ret = text_update_from_file (text, CONFDIR "/text_test.txt");
  fail_unless (ret == 0);
  for (i = 0; i < 120; i++)
    {
      sprintf (buf, "  Line %d", i);
      p = text_get_line (text, i, &len);
      fail_unless (p != NULL);
      fail_unless (strlen (buf) == len);
      fail_unless (strcmp (p, buf) == 0);
    }
  fail_unless (text_nr_of_lines (text) == 120);

  ret = text_update_from_file (text, CONFDIR "/text_test.txt");
  fail_unless (ret == 0);
  for (i = 0; i < 120; i++)
    {
      sprintf (buf, "  Line %d", i);
      p = text_get_line (text, i, &len);
      fail_unless (p != NULL);
      fail_unless (strlen (buf) == len);
      fail_unless (strcmp (p, buf) == 0);
    }
  fail_unless (text_nr_of_lines (text) == 120);

  ret = text_update_from_file (text, CONFDIR "/text_test_bad.txt");
  fail_unless (ret < 0);

  text_free (text);
}
예제 #13
0
파일: main.c 프로젝트: DavidKinder/Magnetic
gboolean start_new_game (gchar *game_filename, gchar *graphics_filename,
			 gchar *splash_filename, gchar *music_filename,
			 gchar *hints_filename)
{
    const gchar *filters[] =
	{
	    "Magnetic Scrolls data file (*.mag)", "*.mag",
	    NULL
	};

    if (!game_filename)
	game_filename = file_selector (FALSE, NULL, filters, "Open game file");

    if (!game_filename)
	return TRUE;

    stop_main_loop ();

    if (ms_is_running ())
    {
	ms_stop ();
	ms_freemem ();
    }

    stop_recording (TRUE);
    stop_scripting (TRUE);
    stop_replaying (TRUE);

    if (!graphics_filename)
	graphics_filename = change_file_extension (game_filename, "gfx");

    if (!splash_filename)
	splash_filename = change_file_extension (game_filename, "png");
    
    if (!music_filename)
	music_filename = change_file_extension (game_filename, "mp3");

    if (!hints_filename)
	hints_filename = change_file_extension (game_filename, "hnt");

    display_splash_screen (splash_filename, music_filename);

    text_clear ();
    graphics_clear ();
    hints_clear ();

    if (applicationExiting)
	return FALSE;

    if (!ms_init ((type8s *) game_filename, (type8s *) graphics_filename, (type8s *) hints_filename), NULL)
    {
	GtkWidget *error;
	gchar *basename;
	
	basename = g_path_get_basename (game_filename);
	error = gtk_message_dialog_new (
	    GTK_WINDOW (Gui.main_window),
	    GTK_DIALOG_DESTROY_WITH_PARENT,
	    GTK_MESSAGE_ERROR,
	    GTK_BUTTONS_OK,
	    "Could not start the game! The most likely cause is\n"
	    "that '%s' is not a valid game file.",
	    basename);
	gtk_dialog_run (GTK_DIALOG (error));
	g_free (basename);
	gtk_widget_destroy (error);
    } else
	start_main_loop ();
    
    g_free (game_filename);
    g_free (graphics_filename);
    g_free (splash_filename);
    g_free (music_filename);
    g_free (hints_filename);
    
    gtk_widget_grab_focus (Gui.text_view);
    return TRUE;
}
예제 #14
0
파일: text.c 프로젝트: bentley/puNES
void text_rendering(BYTE render) {
    _txt_element *ele;

    text.on_screen = FALSE;

    if (text.info.count) {
        int pos_x = 8, pos_y = text.h - 8;
        uint8_t i;

        for (i = 0; i < TXT_MAX_LINES; i++) {
            ele = text.info.lines[text.info.index][i];

            if (ele->enabled == TRUE) {
                if (!ele->surface) {
                    gfx_text_create_surface(ele);
                }

                fade_ele(ele, 3);
                pos_y -= font_size[ele->font][1] * ele->factor;
                ele->start_x = 0;
                ele->start_y = 0;
                ele->x = pos_x;
                ele->y = pos_y;

                if ((cfg->scale != X1) && render) {
                    rendering(ele);
                }

                if (!ele->enabled) {
                    text_clear(ele);
                    gfx_text_release_surface(ele);
                    text.single.count--;
                }
            }
        }
    }

    if (text.single.count) {
        uint8_t i;

        for (i = 0; i < TXT_MAX_LINES; i++) {
            ele = text.single.lines[i];

            if (ele != NULL) {
                if (ele->enabled == TRUE) {
                    if (!ele->surface) {
                        gfx_text_create_surface(ele);
                    }

                    fade_ele(ele, 3);
                    if ((cfg->scale != X1) && render) {
                        rendering(ele);
                    }
                } else {
                    text_clear(ele);
                    gfx_text_release_surface(ele);

                    free(text.single.lines[i]);
                    text.single.lines[i] = NULL;

                    text.single.count--;
                }
            }
        }
    }

    if (tas.type) {
        ele = &text.tas.counter_frames;

        /* counter frames */
        {
            int old_w = ele->w;

            int length;
            if (tas.lag_frame) {
                sprintf(ele->text, "%d/%d [red]%d[normal]", tas.frame, tas.total,
                        tas.total_lag_frames);
                length = strlen(ele->text) - 13;
            } else {
                sprintf(ele->text, "%d/%d [green]%d[normal]", tas.frame, tas.total,
                        tas.total_lag_frames);
                length = strlen(ele->text) - 15;
            }

            ele->w = length * font_size[ele->font][0];
            ele->h = font_size[ele->font][1];

            if ((old_w != ele->w) && ele->surface) {
                gfx_text_release_surface(ele);
            }

            if (!ele->surface) {
                gfx_text_create_surface(ele);
            }

            if (render) {
                rendering(ele);
            }
        }

        {
            ele = &text.tas.controllers[0];

            ele->text[0] = 0;
            port_control(port[PORT1], UP, "[up]");
            port_control(port[PORT1], DOWN, "[down]");
            port_control(port[PORT1], LEFT, "[left]");
            port_control(port[PORT1], RIGHT, "[right]");
            port_control(port[PORT1], SELECT, "[select]");
            port_control(port[PORT1], START, "[start]");
            port_control(port[PORT1], BUT_A, "[a]");
            port_control(port[PORT1], BUT_B, "[b]");

            if (!ele->surface) {
                gfx_text_create_surface(ele);
            }

            if (render) {
                rendering(ele);
            }
        }
    }

    if (fds.info.enabled) {
        ele = &text.fds.floppy;

        if ((fds.info.last_operation | fds.drive.disk_ejected)) {
            ele->enabled = TRUE;
            ele->bck = FALSE;
            ele->font = FONT_12X10;
            ele->factor = 1;
            ele->start_x = TXT_RIGHT;
            ele->start_y = TXT_DOWN;
            ele->x = 0;
            ele->y = 0;
            ele->w = font_size[ele->font][0];
            ele->h = font_size[ele->font][1];
            ele->alpha[0] = 180;
            ele->alpha[2] = 0;

            ele->text[0] = 0;

            if (fds.drive.disk_ejected) {
                ele->bck = TRUE;
                ele->bck_color = TXT_RED;
                ele->alpha[0] = 220;
                ele->alpha[2] = 220;
                strcpy(ele->text, "[normal]");
            } else {
                if (fds.info.last_operation == FDS_OP_READ) {
                    strcpy(ele->text, "[green]");
                } else {
                    strcpy(ele->text, "[red]");
                }
                fds.info.last_operation = FDS_OP_NONE;
            }
            strcat(ele->text, "[floppy]");

            if (!ele->surface) {
                gfx_text_create_surface(ele);
            }

            if (render) {
                rendering(ele);
            }
        }
    }

    // save slot
    {
        ele = &text.save_slot.slot;
        char number[5];
        int i;

        if (ele->enabled == TRUE) {
            ele->text[0] = 0;

            fade_ele(ele, 2);

            for (i = 0; i < SAVE_SLOTS; i++) {
                if (save_slot.slot == i) {
                    if (text.save_slot.operation == SAVE_SLOT_SAVE) {
                        strcat(ele->text, "[red]");
                    } else if (text.save_slot.operation == SAVE_SLOT_READ) {
                        strcat(ele->text, "[green]");
                    } else {
                        strcat(ele->text, "[normal]");
                    }
                } else {
                    if (save_slot.state[i]) {
                        strcat(ele->text, "[cyan]");
                    } else {
                        strcat(ele->text, "[gray]");
                    }
                }
                snprintf(number, sizeof(number), "%d", i);
                strcat(ele->text, number);
            }

            if (!ele->surface) {
                gfx_text_create_surface(ele);
            }

            if ((cfg->fullscreen == FULLSCR) && render) {
                rendering(ele);
            }
        }
    }
}
예제 #15
0
파일: text.c 프로젝트: bentley/puNES
void text_add_line(int type, int factor, int font, int alpha, int start_x, int start_y, int x,
                   int y, const char *fmt, ...) {
    uint8_t i, shift_line = !text.info.index;
    _txt_element *ele = NULL;
    va_list ap;

    if (type == TXT_INFO) {
        text.info.count = 1;

        for (i = 0; i < TXT_MAX_LINES; i++) {
            if (text.info.lines[text.info.index][i]->enabled) {
                text_clear(text.info.lines[text.info.index][i]);
            }
            if (i == (TXT_MAX_LINES - 1)) {
                text.info.lines[shift_line][0] = text.info.lines[text.info.index][i];
            } else {
                text.info.lines[shift_line][i + 1] = text.info.lines[text.info.index][i];
                if (text.info.lines[text.info.index][i]->enabled) {
                    text.info.count++;
                }
            }
        }

        text.info.index = shift_line;

        ele = text.info.lines[text.info.index][0];
        ele->enabled = TRUE;
        ele->bck = FALSE;
        ele->font = font;
        ele->factor = factor;
        ele->w = 0;
        ele->h = 0;
        if (!text.info.lines[text.info.index][1]->start) {
            ele->start = time(NULL);
        } else {
            ele->start = text.info.lines[text.info.index][1]->start + 1;
        }
        ele->alpha_start_fade = alpha;
        ele->alpha[0] = alpha;
        ele->alpha[1] = 170;
        ele->alpha[2] = 40;
    }

    if (type == TXT_SINGLE) {
        for (i = 0; i < TXT_MAX_LINES; i++) {
            if (text.single.lines[i] == NULL) {
                text.single.lines[i] = (_txt_element *) malloc(sizeof(_txt_element));
                text.single.count++;

                ele = text.single.lines[i];

                memset(ele, 0, sizeof(_txt_element));

                ele->enabled = TRUE;
                ele->bck = FALSE;
                ele->font = font;
                ele->factor = factor;
                ele->start_x = start_x;
                ele->start_y = start_y;
                ele->x = x;
                ele->y = y;
                ele->start = time(NULL);
                ele->alpha_start_fade = alpha;
                ele->alpha[0] = alpha;
                ele->alpha[1] = 170;
                ele->alpha[2] = 40;
                break;
            }
        }
    }

    va_start(ap, fmt);
    vsnprintf(ele->text, TXT_MAX_MSG, fmt, ap);
    va_end(ap);

    int ch_font = ele->font;

    for (i = 0; i < strlen(ele->text); i++) {
        if (ele->text[i] == '[') {
            unsigned int tag, found = FALSE;

            for (tag = 0; tag < LENGTH(txt_tags); tag++) {
                int len = strlen(txt_tags[tag]);

                if (strncmp(ele->text + i, txt_tags[tag], len) == 0) {
                    if (tag <= TXT_NORMAL) {
                        ch_font = ele->font;
                    } else if ((tag >= TXT_FONT_8) && (tag <= TXT_FONT_12)) {
                        ch_font = tag - TXT_FONT_8;
                    }
                    i += (len - 1);
                    found = TRUE;
                    break;
                }
            }
            if (found) {
                continue;
            }
        }
        ele->w += ele->factor * font_size[ch_font][0];

        if (ele->h < ele->factor * font_size[ch_font][1]) {
            ele->h = ele->factor * font_size[ch_font][1];
        }

        ele->length++;
    }

    if (ele->surface) {
        gfx_text_release_surface(ele);
    }
}
예제 #16
0
파일: op_01.c 프로젝트: nmlgc/ReC98
int main(void)
{
    unsigned char ret;
    if(snd_pmd_resident()) {
        snd_mmd_resident();
        if(game_init_op()) {
            zun_error(ERROR_OUT_OF_MEMORY);
            return 1;
        }
        extra_unlocked = score_cleared_load();
        if(cfg_load() == 1) {
            return 1;
        }
    } else {
        return 1;
    }
    gaiji_backup();
    gaiji_entry_bfnt("MIKOFT.bft");
    if(mikoconfig->demo_num == 0) {
        demo_num = 1;
        snd_kaja_func(KAJA_SONG_STOP, 0);
    } else {
        demo_num = mikoconfig->demo_num + 1;
        if(demo_num > 3) {
            demo_num = 1;
        }
        score_duration = 350;
        score_menu();
        graph_showpage(0);
        graph_accesspage(0);
    }
    input = 0;

    snd_active = snd_bgm_mode;
    if(!mikoconfig->demo_num && snd_midi_possible) {
        char midi_active = snd_midi_active;

        snd_midi_active = 1;
        snd_load("gminit.m", SND_LOAD_SONG);
        snd_kaja_func(KAJA_SONG_PLAY, 0);
        snd_midi_active = midi_active;
    }

    op_animate();
    pi_slot_load(2, "ts3.pi");
    pi_slot_load(1, "ts2.pi");
    input = 0;
    idle_frames = 0;

    while(!quit) {
        input_sense();
        if(in_option == 0) {
            main_update_and_render();
        } else if(in_option == 1) {
            option_update_and_render();
        }
        mikoconfig->frame++;
        idle_frames++;
        frame_delay(1);
    }

    ret = mikoconfig->op_main_retval;
    mikoconfig_sgm = 0;
    cfg_save();
    text_clear();
    graph_clear();
    game_exit_to_dos();
    gaiji_restore();
    return ret;
}
예제 #17
0
파일: op_01.c 프로젝트: nmlgc/ReC98
void main_update_and_render(void)
{
    static char input_allowed;
    static char initialized = 0;
    if(!initialized) {
        int i;
        input_allowed = 0;
        initialized = 1;
        text_clear();
        graph_showpage(1);
        graph_copy_page(0);
        main_put_shadow();
        graph_showpage(0);
        idle_frames = 0;
        for(i = 0; i < 6; i++) {
            main_put(i, menu_sel == i ? TX_WHITE : TX_YELLOW);
        }
        putfunc = main_put;
    }
    if(!input) {
        input_allowed = 1;
    }
    if(input_allowed) {
        if(input & INPUT_UP) {
            menu_sel_move(5, -1);
        }
        if(input & INPUT_DOWN) {
            menu_sel_move(5, 1);
        }
        if(input & INPUT_SHOT || input & INPUT_OK) {
            switch(menu_sel) {
            case 0:
                start_game();
                break;
            case 1:
                start_extra();
                break;
            case 2:
                score_duration = 2000;
                text_clear();
                score_menu();
                graph_accesspage(1);
                graph_showpage(0);
                pi_load_put_free(0, "op2.pi");
                palette_entry_rgb_show("op.rgb");
                graph_copy_page(0);
                graph_accesspage(0);
                initialized = 0;
                break;
            case 3:
                menu_sel = 0;
                in_option = 1;
                initialized = 0;
                break;
            case 4:
                text_clear();
                musicroom();
                initialized = 0;
                break;
            case 5:
                quit = 1;
                break;
            }
        }
        if(input & INPUT_CANCEL) {
            quit = 1;
        }
        if(input) {
            input_allowed = 0;
            idle_frames = 0;
        }
    }
    if(idle_frames > 640) {
        start_demo();
    }
}
예제 #18
0
파일: newline.c 프로젝트: imuli/prompt
static void
history_load(){
	text_clear(line);
	if(hist[hist_cur] != NULL)
		text_insert(line, hist[hist_cur]->r, hist[hist_cur]->c);
}
예제 #19
0
int main (int argc, char** argv) {
	int err;
	void *handle;

#ifdef DEBUG
	logfile = fopen ("/dev/.initramfs/usplash_log","w+");
#endif

	if (argc>1) {
		if (strcmp(argv[1],"-c")==0) 
			switch_console(8);
	}

	chdir("/dev/.initramfs");

	if (mkfifo(USPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
	{
		if (errno!=EEXIST) {
			perror("mkfifo");
			cleanup();
			exit(1);
		}
	}

	pipe_fd = open(USPLASH_FIFO,O_RDONLY|O_NONBLOCK);

	if (pipe_fd==-1) {
		perror("pipe open");
		cleanup();
		exit(2);
	}

	err=bogl_init();

	if (!err) {
		fprintf(stderr,"%d",err);
		cleanup();
		exit (2);
	}

	handle = dlopen("/usr/lib/usplash/usplash-artwork.so", RTLD_LAZY);
	if (!handle) {
		exit(1);
	}
	pixmap_usplash_artwork = (struct bogl_pixmap *)dlsym(handle, "pixmap_usplash_artwork");
	
	bogl_set_palette (0, 16, pixmap_usplash_artwork->palette);

	left_edge = (bogl_xres - 640) / 2;
	top_edge  = (bogl_yres - 400) / 2;

	draw_image(pixmap_usplash_artwork);

	init_progressbar();

	text_clear();

	event_loop();

	bogl_done();

	cleanup();

	return 0;
}
예제 #20
0
파일: op_01.c 프로젝트: nmlgc/ReC98
void option_update_and_render(void)
{
    static char input_allowed = 0;
    static char initialized = 0;

#define OPTION_CHANGE(direction) \
		option_put(menu_sel, TX_YELLOW); \
		switch(menu_sel) { \
		case 0: \
			RING_##direction##(rank, RANK_LUNATIC); \
			break; \
		case 1: \
			RING_##direction##(snd_bgm_mode, SND_BGM_MIDI); \
			snd_bgm_restart(); \
			break; \
		case 2: \
			RING_##direction##(lives, 4); \
			break; \
		case 3: \
			RING_##direction##(bombs, 3); \
			break; \
		case 4: \
			mikoconfig->perf = 1 - mikoconfig->perf; \
			break; \
		} \
		option_put(menu_sel, TX_WHITE);

#define OPTION_QUIT \
		menu_sel = 3; \
		in_option = 0; \
		initialized = 0;

    if(!initialized) {
        int i;
        input_allowed = 0;
        initialized = 1;
        text_clear();
        graph_showpage(1);
        graph_copy_page(0);
        option_put_shadow();
        graph_showpage(0);
        for(i = 0; i < 7; i++) {
            option_put(i, menu_sel == i ? TX_WHITE : TX_YELLOW);
        }
        putfunc = option_put;
    }
    if(!input) {
        input_allowed = 1;
    }
    if(input_allowed) {
        if(input & INPUT_UP) {
            menu_sel_move(6, -1);
        }
        if(input & INPUT_DOWN) {
            menu_sel_move(6, 1);
        }
        if(input & INPUT_RIGHT) {
            OPTION_CHANGE(INC);
        }
        if(input & INPUT_LEFT) {
            OPTION_CHANGE(DEC);
        }
        if(input & INPUT_SHOT || input & INPUT_OK) {
            switch(menu_sel) {
            case 5:
                rank = RANK_NORMAL;
                snd_bgm_mode = SND_BGM_FM;
                snd_kaja_func(KAJA_SONG_STOP, 0);
                snd_midi_active = 0;
                snd_determine_mode();
                snd_kaja_func(KAJA_SONG_PLAY ,0);
                lives = 2;
                bombs = 3;
                mikoconfig->unused_2 = 1;
                mikoconfig->perf = 0;
                option_put(0, TX_YELLOW);
                option_put(1, TX_YELLOW);
                option_put(2, TX_YELLOW);
                option_put(3, TX_YELLOW);
                option_put(4, TX_YELLOW);
                break;
            case 6:
                OPTION_QUIT;
                break;
            }
        }
        if(input & INPUT_CANCEL) {
            OPTION_QUIT;
        }
        if(input) {
            input_allowed = 0;
        }
    }
}
예제 #21
0
파일: subtitle.c 프로젝트: iizukanao/picam
/**
 * Hide the subtitle.
 */
void subtitle_clear() {
  if (text_id != -1) {
    text_clear(text_id);
  }
}
예제 #22
0
파일: op_01.c 프로젝트: nmlgc/ReC98
void text_wipe(void)
{
    text_clear();
    text_fillca(' ', TX_BLACK | TX_REVERSE);
}
예제 #23
0
/*
 * Handle the expat startElement event.
 */
static void
startElement(IterParser *self, const XML_Char *name, const XML_Char **atts)
{
    PyObject*        pyname = NULL;
    PyObject*        pyatts = NULL;
    const XML_Char** att_ptr = atts;
    const XML_Char*  name_start = NULL;
    PyObject*        tuple = NULL;
    PyObject*        key = NULL;
    PyObject*        val = NULL;

    /* If we've already had an error in a previous call, don't make
       things worse. */
    if (PyErr_Occurred() != NULL) {
        XML_StopParser(self->parser, 0);
        return;
    }

    /* Don't overflow the queue -- in practice this should *never* happen */
    if (self->queue_write_idx < self->queue_size) {
        tuple = PyTuple_New(4);
        if (tuple == NULL) {
            XML_StopParser(self->parser, 0);
            return;
        }

        Py_INCREF(Py_True);
        PyTuple_SET_ITEM(tuple, 0, Py_True);

        /* This is an egregious but effective optimization.  Since by
           far the most frequently occurring element name in a large
           VOTABLE file is TD, we explicitly check for it here with
           integer comparison to avoid the lookup in the interned
           string table in PyString_InternFromString, and return a
           singleton string for "TD" */
        if ((*(int*)name & TD_AS_INT_MASK) == TD_AS_INT) {
            Py_INCREF(self->td_singleton);
            PyTuple_SetItem(tuple, 1, self->td_singleton);
        } else {
            name_start = remove_namespace(name);

            pyname = PyUnicode_FromString(name_start);
            if (pyname == NULL) {
                Py_DECREF(tuple);
                XML_StopParser(self->parser, 0);
                return;
            }
            PyTuple_SetItem(tuple, 1, pyname);
        }

        if (*att_ptr) {
            pyatts = PyDict_New();
            if (pyatts == NULL) {
                Py_DECREF(tuple);
                XML_StopParser(self->parser, 0);
                return;
            }
            do {
                if (*(*(att_ptr + 1)) != 0) {
                    /* Python < 2.6.5 can't handle unicode keyword
                       arguments.  Since those were coming from here
                       (the dictionary of attributes), we use byte
                       strings for the keys instead.  Should be fine
                       for VOTable, since it has ascii attribute
                       names, but that's not true of XML in
                       general. */
                    #if PY_VERSION_HEX < 0x02060500
                    /* Due to Python issue #4978 */
                    key = PyBytes_FromString(*att_ptr);
                    #else
                    key = PyUnicode_FromString(*att_ptr);
                    #endif
                    if (key == NULL) {
                        Py_DECREF(tuple);
                        XML_StopParser(self->parser, 0);
                        return;
                    }
                    val = PyUnicode_FromString(*(att_ptr + 1));
                    if (val == NULL) {
                        Py_DECREF(key);
                        Py_DECREF(tuple);
                        XML_StopParser(self->parser, 0);
                        return;
                    }
                    if (PyDict_SetItem(pyatts, key, val)) {
                        Py_DECREF(pyatts);
                        Py_DECREF(tuple);
                        Py_DECREF(key);
                        Py_DECREF(val);
                        XML_StopParser(self->parser, 0);
                        return;
                    }
                    Py_DECREF(key);
                    Py_DECREF(val);
                }
                att_ptr += 2;
            } while (*att_ptr);
        } else {
            Py_INCREF(self->dict_singleton);
            pyatts = self->dict_singleton;
        }

        PyTuple_SetItem(tuple, 2, pyatts);

        self->last_line = (unsigned long)XML_GetCurrentLineNumber(
            self->parser);
        self->last_col = (unsigned long)XML_GetCurrentColumnNumber(
            self->parser);
        PyTuple_SetItem(tuple, 3, make_pos(self));

        text_clear(self);

        self->keep_text = 1;

        self->queue[self->queue_write_idx++] = tuple;
    } else {
        PyErr_SetString(
            PyExc_RuntimeError,
            "XML queue overflow in startElement.  This most likely indicates an internal bug.");
    }
}