Пример #1
0
//static void
void
gpuputc(uint c)
{
    if(c=='\n'){
	cursor_x = 0;
	cursor_y += fontheight;
	if(cursor_y >= frameheight) {
		memmove((u8 *)fbinfo.fbp, (u8 *)fbinfo.fbp+framewidth*fontheight*2, (frameheight - fontheight)*framewidth*2);
		cursor_y = frameheight - fontheight;
		setgpucolour(0);
		while(cursor_x < framewidth) {
		    drawcursor(cursor_x, cursor_y);
		    cursor_x = cursor_x + fontwidth;
		}
		setgpucolour(0xffff);
		cursor_x = 0;
	}
    } else if(c == BACKSPACE) {
	if (cursor_x > 0) {
		cursor_x -= fontwidth;
		setgpucolour(0);
		drawcursor(cursor_x, cursor_y);
		setgpucolour(0xffff);
	}
    } else {
        uartputc('1');
	setgpucolour(0);
        uartputc('2');
	drawcursor(cursor_x, cursor_y);
        uartputc('3');
	setgpucolour(0xffff);
        uartputc('4');
	if(c!=' ') drawcharacter(c, cursor_x, cursor_y);
	cursor_x = cursor_x + fontwidth;
        uartputc('5');

	if(cursor_x >= framewidth) {
	    cursor_x = 0;
	    cursor_y += fontheight;

              uartputc('6');
	    if(cursor_y >= frameheight) {
		memmove((u8 *)fbinfo.fbp, (u8 *)fbinfo.fbp+framewidth*fontheight*2, (frameheight - fontheight)*framewidth*2);
		cursor_y = frameheight - fontheight;
		setgpucolour(0);
                uartputc('7');
		while(cursor_x < framewidth) {
		    drawcursor(cursor_x, cursor_y);
		    cursor_x = cursor_x + fontwidth;
		} 
                uartputc('8');
		setgpucolour(0xffff);
		cursor_x = 0;
	    }
	}

        uartputc('9');
    }

}
Пример #2
0
/******************************************************
 *|F| int handle_devices(void *unused)
 ******************************************************/
int handle_devices(void *unused)
{
  SDL_Event event;
  int c;

  while (vm.ports[0] == 0)
  {
    if (SDL_PollEvent(&event) != 0)
    {
      switch(event.type)
      {
        case SDL_KEYDOWN:
             vm.ports[1] = (int)event.key.keysym.unicode;
             if (event.key.keysym.sym == SDLK_BACKSPACE)
               vm.ports[1] = 8;
             vm.ports[0] = 1;
             break;
        case SDL_KEYUP:
             break;
        case SDL_MOUSEMOTION:
             mousex = event.motion.x;
             mousey = event.motion.y;
             break;
        case SDL_MOUSEBUTTONDOWN:
             mouseb = 1;
             break;
        case SDL_MOUSEBUTTONUP:
             mouseb = 0;
             break;
        case SDL_QUIT:
             vm.ip = IMAGE_SIZE;
             vm.ports[0] = 1;
             break;
      }
    }
    if (vm.ports[2] == 1)
    {
      c = TOS; DROP
      if (c >= 0)
      {
        drawcharacter(tx, ty, c);
        tx += 9;
        if (c == 8)
        {
          tx -= 16;
          drawcharacter(tx, ty, '_');
        }
        if (c == 10)
        {
          tx  = 0;
          ty += 12;
        }
        if (tx > VIDEO_WIDTH - 9)
        {
          tx  = 0;
          ty += 12;
        }
        if (ty > VIDEO_HEIGHT - 12)
        {
          /* Scroll Up */
          gw = 0;
          for (gx = VIDEO_WIDTH * 12; gx < (VIDEO_WIDTH * VIDEO_HEIGHT) - 12; gx++)
          {
            vm.image[VIDEO_BASE + gw] = vm.image[VIDEO_BASE + gx];
            gw++;
          }

          ty = VIDEO_HEIGHT - 12;

          /* Clear bottom line */
          scratch = color;
          color = black;
          gw = VIDEO_WIDTH;     gh = 12;
          gy = ty;              gx = 0;
          for (; gw > 0; gw--)
          {
            line(gx, gy, gx + gw, gy);
            line(gx + gw, gy, gx + gw, gy + gh);
            line(gx + gw, gy + gh, gx, gy + gh);
            line(gx, gy + gh, gx, gy);
          }
          color = scratch;
          vm.ports[3] = 0;
        }
      }
      else
        clear_display();
      vm.ports[2] = 0;
      vm.ports[0] = 1;
    }
    if (vm.ports[4] == 1)
    {
      vm_save_image(vm.filename);
      vm.ports[4] = 0;
      vm.ports[0] = 1;
    }

    /* Capabilities */
    if (vm.ports[5] == -1)
    {
      vm.ports[5] = IMAGE_SIZE;
      vm.ports[0] = 1;
    }
    if (vm.ports[5] == -2)
    {
      vm.ports[5] = -1;
      vm.ports[0] = 1;
    }
    if (vm.ports[5] == -3)
    {
      vm.ports[5] = VIDEO_WIDTH;
      vm.ports[0] = 1;
    }
    if (vm.ports[5] == -4)
    {
      vm.ports[5] = VIDEO_HEIGHT;
      vm.ports[0] = 1;
    }
    if (vm.ports[5] == -5)
    {
      vm.ports[5] = vm.sp;
      vm.ports[0] = 1;
    }
    if (vm.ports[5] == -6)
    {
      vm.ports[5] = vm.rsp;
      vm.ports[0] = 1;
    }
    if (vm.ports[5] == -7)
    {
      vm.ports[5] = -1;
      vm.ports[0] = 1;
    }

    if (vm.ports[6] == 1)
    {
      video_color(TOS); DROP;
      vm.ports[6] = 0;
      vm.ports[0] = 1;
    }
    if (vm.ports[6] == 2)
    {
      gy = TOS; DROP;
      gx = TOS; DROP;
      video_pixel(gx, gy);
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }
    if (vm.ports[6] == 3)
    {
      gw = TOS; DROP;
      gh = TOS; DROP;
      gy = TOS; DROP;
      gx = TOS; DROP;
      line(gx, gy, gx + gw, gy);
      line(gx + gw, gy, gx + gw, gy + gh);
      line(gx + gw, gy + gh, gx, gy + gh);
      line(gx, gy + gh, gx, gy);
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }
    if (vm.ports[6] == 4)
    {
      gw = TOS; DROP;
      gh = TOS; DROP;
      gy = TOS; DROP;
      gx = TOS; DROP;
      for (; gw > 0; gw--)
      {
        line(gx, gy, gx + gw, gy);
        line(gx + gw, gy, gx + gw, gy + gh);
        line(gx + gw, gy + gh, gx, gy + gh);
        line(gx, gy + gh, gx, gy);
      }
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }
    if (vm.ports[6] == 5)
    {
      gh = TOS; DROP;
      gy = TOS; DROP;
      gx = TOS; DROP;
      line(gx, gy, gx, gy + gh);
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }
    if (vm.ports[6] == 6)
    {
      gw = TOS; DROP;
      gy = TOS; DROP;
      gx = TOS; DROP;
      line(gx, gy, gx + gw, gy);
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }
    if (vm.ports[6] == 7)
    {
      gw = TOS; DROP;
      gy = TOS; DROP;
      gx = TOS; DROP;
      video_circle(gx, gy, gw);
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }
    if (vm.ports[6] == 8)
    {
      gw = TOS; DROP;
      gy = TOS; DROP;
      gx = TOS; DROP;
      for (; gw > 0; gw--)
        video_circle(gx, gy, gw);
      vm.ports[6] = 0;
      vm.ports[0] = 1;
      vm.ports[3] = 0;
    }


    if (vm.ports[7] == 1)
    {
      vm.sp++; vm.data[vm.sp] = mousex;
      vm.sp++; vm.data[vm.sp] = mousey;
      vm.ports[7] = 0;
      vm.ports[0] = 1;
    }
    if (vm.ports[7] == 2)
    {
      vm.sp++; vm.data[vm.sp] = mouseb;
      vm.ports[7] = 0;
      vm.ports[0] = 1;
    }
  }