Beispiel #1
0
void vm_xputs(char x, char y, char attr, char *str)
{
    if (_osmode == DOS_MODE)
    {
        char *p, *cell, *pcell;
        cell = malloc(strlen(str) * 2);
        if (cell)
        {
            pcell = cell;
            p = str;
            while (*p)
            {
                *pcell++ = *p++;
                *pcell++ = attr;
            }
            vi_init();
            v_putline(cell, (int)(x - 1), (int)(y - 1), strlen(str));
            free(cell);
        }
    }
    else
    {
        VioWrtCharStrAtt(str, (USHORT) strlen(str), (USHORT) (y - 1), (USHORT) (x - 1), (PBYTE) &attr, 0);
    }
}
Beispiel #2
0
void vm_init(void)
{
    vi_init();
    vm_getinfo(&vm_startup);
    vm_setattr(vm_startup.attr);
    if (_osmode == DOS_MODE)
    {
        opsysDetect();
    }
}
Beispiel #3
0
void vm_gotoxy(char x, char y)
{
    if (_osmode == DOS_MODE)
    {
        vi_init();
        v_gotoxy((int)(x - 1), (int)(y - 1));
    }
    else
    {
        VioSetCurPos((USHORT) (y - 1), (USHORT) (x - 1), 0);
    }
}
void plugin_init(GeanyData *data)
{
	GeanyDocument *doc = document_get_current();
	GeanyKeyGroup *group;
	GtkWidget *menu;

	load_config();

	/* menu items and keybindings */
	group = plugin_set_key_group(geany_plugin, "vimode", KB_COUNT, NULL);

	menu_items.parent_item = gtk_menu_item_new_with_mnemonic(_("_Vim Mode"));
	gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_items.parent_item);

	menu = gtk_menu_new ();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_items.parent_item), menu);

	menu_items.enable_vim_item = gtk_check_menu_item_new_with_mnemonic(_("Enable _Vim Mode"));
	gtk_container_add(GTK_CONTAINER(menu), menu_items.enable_vim_item);
	g_signal_connect((gpointer) menu_items.enable_vim_item, "activate", G_CALLBACK(on_enable_vim_mode), NULL);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items.enable_vim_item), vi_get_enabled());
	keybindings_set_item_full(group, KB_ENABLE_VIM, 0, 0, "enable_vim",
			_("Enable Vim Mode"), NULL, on_enable_vim_mode_kb, NULL, NULL);

	menu_items.insert_for_dummies_item = gtk_check_menu_item_new_with_mnemonic(_("Insert Mode for _Dummies"));
	gtk_container_add(GTK_CONTAINER(menu), menu_items.insert_for_dummies_item);
	g_signal_connect((gpointer) menu_items.insert_for_dummies_item, "activate",
		G_CALLBACK(on_insert_for_dummies), NULL);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items.insert_for_dummies_item), vi_get_insert_for_dummies());
	keybindings_set_item_full(group, KB_INSERT_FOR_DUMMIES, 0, 0, "insert_for_dummies",
			_("Insert Mode for Dummies"), NULL, on_insert_for_dummies_kb, NULL, NULL);

	menu_items.start_in_insert_item = gtk_check_menu_item_new_with_mnemonic(_("Start in _Insert Mode"));
	gtk_container_add(GTK_CONTAINER(menu), menu_items.start_in_insert_item);
	g_signal_connect((gpointer) menu_items.start_in_insert_item, "activate",
		G_CALLBACK(on_start_in_insert), NULL);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items.start_in_insert_item), start_in_insert);

	gtk_widget_show_all(menu_items.parent_item);

	cb.on_mode_change = on_mode_change;
	cb.on_save = on_save;
	cb.on_save_all = on_save_all;
	cb.on_quit = on_quit;
	vi_init(geany_data->main_widgets->window, &cb);
	vi_set_mode(start_in_insert ? VI_MODE_INSERT : VI_MODE_COMMAND);

	if (doc)
		vi_set_active_sci(doc->editor->sci);
}
Beispiel #5
0
void vm_putattr(char x, char y, char attr)
{
    if (_osmode == DOS_MODE)
    {
        char cell[2];
        vi_init();
        v_getline(cell, (int)(x - 1), (int)(y - 1), 1);
        *(cell + 1) = attr;
        v_putline(cell, (int)(x - 1), (int)(y - 1), 1);
    }
    else
    {
        VioWrtNAttr((PBYTE) &attr, 1, (USHORT) (y - 1), (USHORT) (x - 1), 0);
    }
}
Beispiel #6
0
void vm_xputch(char x, char y, char attr, char ch)
{
    if (_osmode == DOS_MODE)
    {
        char cell[2];
        vi_init();
        *cell = ch;
        *(cell + 1) = attr;
        v_putline(cell, (int)(x - 1), (int)(y - 1), 1);
    }
    else
    {
        VioWrtCharStrAtt(&ch, 1, (USHORT) (y - 1), (USHORT) (x - 1), (PBYTE) &attr, 0);
    }
}
Beispiel #7
0
void vm_putch(char x, char y, char ch)
{
    if (_osmode == DOS_MODE)
    {
        char cell[2];
        vi_init();
        v_getline(cell, (int)(x - 1), (int)(y - 1), 1);
        *cell = ch;
        v_putline(cell, (int)(x - 1), (int)(y - 1), 1);
    }
    else
    {
        VioWrtCharStr(&ch, 1, (USHORT) (y - 1), (USHORT) (x - 1), 0);
    }
}
Beispiel #8
0
char vm_wherex(void)
{
    if (_osmode == DOS_MODE)
    {
        int row, col;
        vi_init();
        v_getxy(&col, &row);
        return (char)(col + 1);
    }
    else
    {
        USHORT row, col;
        VioGetCurPos(&row, &col, 0);
        return (char)(col + 1);
    }
}
Beispiel #9
0
char vm_getscreenheight(void)
{
    if (_osmode == DOS_MODE)
    {
        int width, height;
        vi_init();
        v_dimen(&width, &height);
        return (char)height;
    }
    else
    {
        VIOMODEINFO vi;
        vi.cb = sizeof(VIOMODEINFO);
        VioGetMode(&vi, 0);
        return vi.row;
    }
}
Beispiel #10
0
void vm_puts(char x, char y, char *str)
{
    if (_osmode == DOS_MODE)
    {
        vi_init();
        while (*str)
        {
            vm_putch(x, y, *str);
            str++;
            x++;
        }
    }
    else
    {
        VioWrtCharStr(str, (USHORT) strlen(str), (USHORT) (y - 1), (USHORT) (x - 1), 0);
    }
}
Beispiel #11
0
char vm_getattrxy(char x, char y)
{
    if (_osmode == DOS_MODE)
    {
        char cell[2];
        vi_init();
        v_getline(cell, (int)(x - 1), (int)(y - 1), 1);
        return *(cell + 1);
    }
    else
    {
        char cell[2];
        USHORT len = sizeof cell;
        VioReadCellStr(cell, &len, (USHORT) (y - 1), (USHORT) (x - 1), 0);
        return *(cell + 1);
    }
}
Beispiel #12
0
static void vm_setcursorsize(char start, char end)
{
    if (_osmode == DOS_MODE)
    {
        vi_init();
        v_ctype(start, end);
    }
    else
    {
        VIOCURSORINFO vi;
        vi.yStart = start;
        vi.cEnd = end;
        vi.cx = 0;
        vi.attr = 0;
        VioSetCurType(&vi, 0);
    }
}
Beispiel #13
0
static void vm_getcursorsize(char *start, char *end)
{
    if (_osmode == DOS_MODE)
    {
        int cstart, cend;
        vi_init();
        v_getctype(&cstart, &cend);
        *start = (char)cstart;
        *end = (char)cend;
    }
    else
    {
        VIOCURSORINFO vi;
        VioGetCurType(&vi, 0);
        *start = vi.yStart;
        *end = vi.cEnd;
    }
}
Beispiel #14
0
void vm_xgetchxy(char x, char y, char *attr, char *ch)
{
    if (_osmode == DOS_MODE)
    {
        char cell[2];
        vi_init();
        v_getline(cell, (int)(x - 1), (int)(y - 1), 1);
        *ch = *cell;
        *attr = *(cell + 1);
    }
    else
    {
        char cell[2];
        USHORT len = sizeof cell;
        VioReadCellStr(cell, &len, (USHORT) (y - 1), (USHORT) (x - 1), 0);
        *ch = *cell;
        *attr = *(cell + 1);
    }
}
Beispiel #15
0
// Creates and initializes a device.
struct cen64_device *device_create(struct cen64_device *device,
  const struct rom_file *ddipl, const struct rom_file *ddrom,
  const struct rom_file *pifrom, const struct rom_file *cart,
  const struct save_file *eeprom, const struct save_file *sram,
  const struct save_file *flashram, const struct controller *controller,
  bool no_audio, bool no_video) {

  // Initialize the bus.
  device->bus.ai = &device->ai;
  device->bus.dd = &device->dd;
  device->bus.pi = &device->pi;
  device->bus.ri = &device->ri;
  device->bus.si = &device->si;
  device->bus.vi = &device->vi;

  device->bus.rdp = &device->rdp;
  device->bus.rsp = &device->rsp;
  device->bus.vr4300 = &device->vr4300;

  // Initialize the bus.
  if (bus_init(&device->bus)) {
    debug("create_device: Failed to initialize the bus.\n");
    return NULL;
  }

  // Initialize the AI.
  if (ai_init(&device->ai, &device->bus, no_audio)) {
    debug("create_device: Failed to initialize the AI.\n");
    return NULL;
  }

  // Initialize the DD.
  if (dd_init(&device->dd, &device->bus,
    ddipl->ptr, ddrom->ptr, ddrom->size)) {
    debug("create_device: Failed to initialize the DD.\n");
    return NULL;
  }

  // Initialize the PI.
  if (pi_init(&device->pi, &device->bus, cart->ptr, cart->size, sram, flashram)) {
    debug("create_device: Failed to initialize the PI.\n");
    return NULL;
  }

  // Initialize the RI.
  if (ri_init(&device->ri, &device->bus)) {
    debug("create_device: Failed to initialize the RI.\n");
    return NULL;
  }

  // Initialize the SI.
  if (si_init(&device->si, &device->bus, pifrom->ptr,
    cart->ptr, ddipl->ptr != NULL, eeprom->ptr, eeprom->size,
    controller)) {
    debug("create_device: Failed to initialize the SI.\n");
    return NULL;
  }

  // Initialize the VI.
  if (vi_init(&device->vi, &device->bus, no_video)) {
    debug("create_device: Failed to initialize the VI.\n");
    return NULL;
  }

  // Initialize the RDP.
  if (rdp_init(&device->rdp, &device->bus)) {
    debug("create_device: Failed to initialize the RDP.\n");
    return NULL;
  }

  // Initialize the RSP.
  if (rsp_init(&device->rsp, &device->bus)) {
    debug("create_device: Failed to initialize the RSP.\n");
    return NULL;
  }

  // Initialize the VR4300.
  if (vr4300_init(&device->vr4300, &device->bus)) {
    debug("create_device: Failed to initialize the VR4300.\n");
    return NULL;
  }

  return device;
}