Ejemplo n.º 1
0
static void endGame(void)
{
    videomode(VIDEOMODE_80x24);
    mixedTextMode();
    
    speakNoMoreMoves();
    
    cputsxy(0, 0, "               No more moves  -  GAME OVER!!");
    gotoxy(0,1);
    cprintf(      "               You made it to level %u", getLevel());
    cputsxy(0, 3, "                    Play again (Y/N)?");
    
    while (true) {
        switch (cgetc()) {
            case 'y':
            case 'Y':
                return;
                
            case 'n':
            case 'N':
            case CH_ESC:
            case 'q':
            case 'Q':
                quitGame();
                break;
                
            default:
                badThingHappened();
                break;
        }
    }
}
Ejemplo n.º 2
0
void renderMenu(uint8_t current) {
    uint8_t idx = 0;

    textcolor(1);
    revers(1);
    gotoxy(0, 0);
    for (idx = 0;  idx < menuSize;  idx++) {
        if (idx == current) {
            textcolor(3);
            cputs(menu[idx]);
            
            /*****************/
            cputsxy(0, 1, "\xf0\xc0\xc0\xc0\xc0\xee");
            gotoxy(0, 2);
            cprintf("\xdd%s\xdd", fileMenu[0]);
            gotoxy(0, 3);
            cprintf("\xdd%s\xdd", fileMenu[1]);
            gotoxy(0, 4);
            cprintf("\xdd%s\xdd", fileMenu[2]);
            gotoxy(0, 5);
            cprintf("\xdd%s\xdd", fileMenu[3]);
            cputsxy(0, 6, "\xed\xc0\xc0\xc0\xc0\xfd");
            /*****************/
            
        } else {
            cputs(menu[idx]);
        }
        textcolor(1);
        cputs("  ");
    }
    for (idx = wherex();  idx < 40;  idx++) {
        cputc(' ');
    }
}
Ejemplo n.º 3
0
static unsigned UpdateAsm (void)
/* Update the assembler window starting at the given address */
{
    char buf [MAX_X];
    unsigned char len;
    unsigned char y;
    unsigned char width = AsmFrame.fd_width;
    unsigned char x = AsmFrame.fd_x1 + 1;
    unsigned      m = AsmBack (AsmAddr, 2);

    for (y = AsmFrame.fd_y1+1; y < AsmFrame.fd_y2; ++y) {
        len = DbgDisAsm (m, buf, width);
        if (m == brk_pc) {
            buf [4] = '-';
            buf [5] = '>';
        }
        if (DbgIsBreak (m)) {
            buf [5] = '*';
        }
        if (m == AsmAddr) {
            revers (1);
            cputsxy (1, y, buf);
            revers (0);
        } else {
            cputsxy (1, y, buf);
        }
        m += len;
    }
    return m;
}
Ejemplo n.º 4
0
void __fastcall__ drawMenu(char canReturn)
{
  char i;
  for (i = 0; i < 198; ++i)
  {
    POKE(0x1000 + 242 + i, 32);
    POKE(0x9400 + 242 + i, 7);
  }

  if (!canReturn)
  {
    textcolor(TEXT_COLOR);
    cputsxy(3, 21, "down");
    cputsxy(15, 21, "select");
    textcolor(HILITE_COLOR);
    cputsxy(1, 21, "s");
    cputsxy(8, 21, "return");
  }

  menuSize = 4;
  if (stackDepth == 0 && !canReturn)
  {
    menuSize = 3;
  }
	 
  // draw the menu
  for (i = 0; i < menuSize; ++i)
  {
    drawMenuItem(i);
  }
  textcolor(HILITE_COLOR);
}
Ejemplo n.º 5
0
void __fastcall writePanel(
	unsigned drawBorder,
	unsigned reverse,
	unsigned char color,
	unsigned char x, unsigned char y,
	unsigned char h, unsigned char w,
	unsigned char *title,
	unsigned char *cancel,
	unsigned char *ok)
{
	unsigned int i = 0, okLeft = 0, cancelLeft = 0;
	unsigned char titleBuffer[81];

	saveScreen();

	//textcolor(color);
	revers(reverse);

	if(drawBorder)
	{
		drawBox(x, y, w, h, color, reverse);
	}
	else
	{
		for(i=0; i<h; ++i)
		{
			cclearxy(x,y+i,w);
		}
	}

	if(title != NULL)
	{
		strcpy(titleBuffer, title);
		if(strlen(titleBuffer) > w-4)
		{
			titleBuffer[w-4]='\0';
		}

		gotoxy(x+2, y);
		cprintf("[%s]", titleBuffer);
	}

	revers(false);

	okLeft = x + w - 2;

	if(ok != NULL)
	{
		okLeft -= 4;
		cputsxy(okLeft, y + h - 1, ok);
	}

	cancelLeft = okLeft - 2;
	if(cancel != NULL)
	{
		cancelLeft -= 8;
		cputsxy(cancelLeft, y + h - 1, cancel);
	}
}
Ejemplo n.º 6
0
/**
 * Return the string entered. The maximal length of the string is
 * FILENAME_MAX, i.e. 16+1.
 */
const char* __fastcall__ screenReadInput(const char* pStrTitle,
                                         const char* pStrDefault)
{
    uint8_t len;
    static char strInput[FILENAME_MAX];
    char c;

    screenBing();
    strcpy(strInput, pStrDefault);
    len = strlen(strInput);

    screenPrintBox(2, 6, 36, 12);
    screenPrintSepLine(2, 37, 8);

    cputsxy(3, 7, pStrTitle);

    // the input field
    textcolor(COLOR_LIGHTFRAME);
    screenPrintBox(4, 10, 32, 3);
    textcolor(COLOR_FOREGROUND);

    screenPrintButton(30, 14, "Enter");

    cursor(1);
    do
    {
        cputsxy(5, 11, strInput);
        cputc(' ');
        gotox(5 + len);

        c = cgetc();
        if (len < sizeof(strInput) - 1 &&
                ((c >=  32 && c < 128) ||
                 (c >= 192 && c < 224))
           )
        {
            strInput[len++] = c;
            strInput[len]   = '\0';
        }
        else if (c == CH_DEL)
        {
            if (len)
                strInput[--len] = '\0';
        }
    } while (c != CH_ENTER);

    cursor(0);
    refreshMainScreen();

    return strInput;
}
Ejemplo n.º 7
0
void desenhaJogada(int jogadaAtual,int corAtual,int jogadaAnterior) {
    int posicaoX=0,posicaoY=0;
    textbackground(YELLOW);
    textcolor(BLACK);
    if(jogadaAnterior!=SEM_JOGADA) {
        posicaoDesenho(jogadaAnterior,&posicaoX,&posicaoY);
        cputsxy(posicaoX,posicaoY,"-----");
        posicaoY++;
        cputsxy(posicaoX,posicaoY,"|");
        cputsxy(posicaoX+4,posicaoY,"|");
        posicaoY++;
        cputsxy(posicaoX,posicaoY,"-----");
    }
    posicaoDesenho(jogadaAtual,&posicaoX,&posicaoY);
    textbackground(BROWN);
    cputsxy(posicaoX,posicaoY,"-----");
    cputsxy(posicaoX,posicaoY+1,"|   |");
    cputsxy(posicaoX,posicaoY+2,"-----");
    if(corAtual==BRANCO) {
        textbackground(WHITE);
    }
    if(corAtual==PRETO) {
        textbackground(BLACK);
    }
    cputsxy(posicaoX+1,posicaoY+1,"   ");
    gotoxy(1,1);
}
Ejemplo n.º 8
0
static void DisplayPrompt (char* s)
/* Display a prompt */
{
    unsigned char OldColor;

    /* Remember the current color */
    OldColor = textcolor (COLOR_TEXTHIGH);

    /* Clear the old prompt if there is one */
    if (ActivePrompt) {
        (void) textcolor (PromptColor);
        chlinexy ((MAX_X - PromptLength) / 2, MAX_Y-1, PromptLength);
    }

    /* Get the new prompt data */
    ActivePrompt = s;
    PromptColor  = OldColor;
    PromptLength = strlen (ActivePrompt);

    /* Display the new prompt */
    (void) textcolor (COLOR_TEXTHIGH);
    cputsxy ((MAX_X - PromptLength) / 2, MAX_Y-1, ActivePrompt);

    /* Restore the old color */
    (void) textcolor (PromptColor);
}
Ejemplo n.º 9
0
static void refreshLevel(tLevel level)
{
    bool waiting = true;
    
    videomode(VIDEOMODE_80x24);
    mixedTextMode();
    speakLevelComplete();
    
    gotoxy(0, 0);
    cprintf(      "               Completed level %u!!", level);
    cputsxy(0, 2, "               Press space to continue to the next level...");
    
    while (waiting) {
        switch (cgetc()) {
            case ' ':
                waiting = false;
                break;
                
            default:
                badThingHappened();
                break;
        }
    }
    
    showAndClearDblLoRes();
    speakGetReady();
}
Ejemplo n.º 10
0
unsigned box(tgui_Window *tmp) {


 cleanscrn(tmp);


  //if (tmp->x1<0 || tmp->x1>35)             { return(10);}    // x1 out of bounds
  //if (tmp->x2 < tmp->x1+4 || tmp->x2 > 39) { return(11);}    // x2 out of bounds
  //if (tmp->y1<0 || tmp->y1>20)             { return(20);}    // y1 out of bounds
  //if (tmp->y2>24 || tmp->y2<tmp->y1+3)     { return(21);}    // y2 out of bounnds
  //if (tmp->color < 0 || tmp->color > 15)   { return(30);}    // invalid color


  //if (tmp->parent == 0 ) revers(1);

  drawbox(tmp->x1, tmp->y1, tmp->x2, tmp->y2);


  cputsxy(tmp->x1+1,tmp->y1,tmp->title);



   return(0);

} /* end box */
Ejemplo n.º 11
0
void __fastcall__ drawMenuItem(char i)
{
  char y = MENU_Y + (i<<1);
  char *itemStr = caMenus[menu][i];
  if (i != item)
  {
    textcolor(TEXT_COLOR);
    cputsxy(0, y, "                      ");
  }
  else
  {
    textcolor(HILITE_COLOR);
    cputsxy(0, y, "@                     ");
  }
  printCentered(itemStr, y);
}
Ejemplo n.º 12
0
void tiraFoco(int posicao) {
    int posicaoX=0,posicaoY=0;
    textbackground(YELLOW);
    textcolor(BLACK);
    posicaoDesenho(posicao,&posicaoX,&posicaoY);
    cputsxy(posicaoX+1,posicaoY+1,"   ");
    gotoxy(1,1);
}
Ejemplo n.º 13
0
void poeFoco(int posicao) {
    int posicaoX=0,posicaoY=0;
    textbackground(LIGHTBLUE);
    textcolor(BLACK);
    posicaoDesenho(posicao,&posicaoX,&posicaoY);
    cputsxy(posicaoX+1,posicaoY+1,"   ");
    gotoxy(1,1);
}
Ejemplo n.º 14
0
static void DrawFrame (register FrameDesc* F, char Active)
/* Draw one window frame */
{
    TextDesc* T;
    unsigned char Count;
    unsigned char tl, tr, bl, br;
    unsigned char x1, y1, width;
    unsigned char OldColor;

    /* Determine the characters for the corners, set frame color */
    if (Active) {
        OldColor = textcolor (COLOR_FRAMEHIGH);
        tl = CH_ULCORNER;
        tr = CH_URCORNER;
        bl = CH_LLCORNER;
        br = CH_LRCORNER;
    } else {
        OldColor = textcolor (COLOR_FRAMELOW);
        tl = F->fd_tl;
        tr = F->fd_tr;
        bl = F->fd_bl;
        br = F->fd_br;
    }

    /* Get the coordinates into locals for faster access */
    x1 = F->fd_x1;
    y1 = F->fd_y1;
    width = F->fd_width;

    /* Top line */
    cputcxy (x1, y1, tl);
    chline (width);
    cputc (tr);

    /* Left line */
    cvlinexy (x1, ++y1, F->fd_height);

    /* Bottom line */
    cputc (bl);
    chline (width);
    cputc (br);

    /* Right line */
    cvlinexy (F->fd_x2, y1, F->fd_height);

    /* If the window has static text associated, print the text */
    (void) textcolor (COLOR_TEXTLOW);
    Count = F->fd_textcount;
    T = F->fd_text;
    while (Count--) {
        cputsxy (x1 + T->x, y1 + T->y, T->text);
        ++T;
    }

    /* Set the old color */
    (void) textcolor (OldColor);
}
Ejemplo n.º 15
0
void limpaTela() {
    int y;
    clrscr();
    textbackground(DARKGRAY);
    textcolor(BLACK);
    for(y=1; y<26; y++) {
        cputsxy(1,y,"                                                                                ");
    }
    gotoxy(1,1);
}
Ejemplo n.º 16
0
void showlistbox(tgui_Obj *obj, int x, int y, int color, int startid){
tgui_Listitem *item;
int i;

    //textcolor(color);
    cputsxy(x,y-1,obj->caption);
    drawbox(x, y, x+obj->width, y + obj->height);
    item = obj->firstitem;
    i=0;
	obj->topid=startid;


    while (item->li_id != startid){
		item=item-> next;
	}


    if (startid != 0 ) cputcxy(x+obj->width-1, y, '+');


	    if (item!=NULL ) {
	        do {
	            if (obj->state == item->li_id ) revers(1);
				cputsxy(x+1,y+i+1,item->caption);
				cclearxy(x+strlen(item->caption)+1 ,y+i+1, obj->width - strlen(item->caption)-1);
				if (obj->state == item->li_id){
					//cclearxy(x+strlen(item->caption)+1 ,y+i+1, obj->width - strlen(item->caption)-1);
					revers(0);
                }
					++i;
	            item=item->next;
			} while (item != obj->firstitem && i+1 < obj->height);
	        if (item != obj->firstitem ) {
				cputcxy(x+obj->width-1, y+obj->height, '+');
			}
			else cputcxy(x+obj->width-1, y+obj->height, ' ');

        }



}   // end of showlistbox
Ejemplo n.º 17
0
static char Input (char* Prompt, char* Buf, unsigned char Count)
/* Read input from the user, return 1 on success, 0 if aborted */
{
    int Frame;
    unsigned char OldColor;
    unsigned char OldCursor;
    unsigned char x1;
    unsigned char i;
    unsigned char done;
    char c;

    /* Clear the current prompt line */
    cclearxy (0, MAX_Y-1, MAX_X);

    /* Display the new prompt */
    OldColor = textcolor (COLOR_TEXTHIGH);
    cputsxy (0, MAX_Y-1, Prompt);
    (void) textcolor (COLOR_TEXTLOW);

    /* Remember where we are, enable the cursor */
    x1 = wherex ();
    OldCursor = cursor (1);

    /* Get input and handle it */
    i = done = 0;
    do {
        c = cgetc ();
        if (isalnum (c) && i < Count) {
            Buf [i] = c;
            cputcxy (x1 + i, MAX_Y-1, c);
            ++i;
        } else if (i > 0 && c == CH_DEL) {
            --i;
            cputcxy (x1 + i, MAX_Y-1, ' ');
            gotoxy (x1 + i, MAX_Y-1);
        } else if (c == '\n') {
            Buf [i] = '\0';
            done = 1;
        } else if (IsAbortKey (c)) {
            /* Abort */
            done = 2;
        }
    } while (!done);

    /* Reset settings, display old prompt line */
    cursor (OldCursor);
    (void) textcolor (OldColor);
    DrawFrames ();
    Frame = ActiveFrame;
    ActiveFrame = -1;
    ActivateFrame (Frame, 0);

    return (done == 1);
}
Ejemplo n.º 18
0
void __fastcall__ summaryScreen(void)
{
  // display kills, items, secrets, time
  // like this
  // MAP NAME
  // FINISHED
  // KILLS %
  // ITEMS %
  // SECRET %
  // TIME 00:00
  // PAR 00:00
  
  char kills = p_enemy_getKillPercentage();
  char items = getItemPercentage();
  char secret = (100*getNumVisitedSecrets())/getNumSecrets();
  int time = getMapTime();
  int par = getParTime();

  // clear screen
  clearScreen();
  
  textcolor(1);
  printCentered(caLevelNames[level-1], 1);
  textcolor(2);
  printCentered("finished", 2);
  cputsxy(4, 5, "kills");
  cputsxy(4, 7, "items");
  cputsxy(4, 9, "secret");
  cputsxy(4, 12, "time");
  cputsxy(4, 14, "par");

  setTextColor(2);
  POKE(198, 0);
  rollInPercentage(kills, 0x1000+22*5+14);
  waitASecond();
  rollInPercentage(items, 0x1000+22*7+14);
  waitASecond();
  rollInPercentage(secret, 0x1000+22*9+14);
  waitASecond();
  if (time > 10*60-1)
  {
    cputsxy(13,12,"sucks");
    playSound(SOUND_PISTOL);
  }
  else
  {
    rollInTime(time, 0x1000+22*12+13);
  }
  waitASecond();
  rollInTime(par, 0x1000+22*14+13);
  waitASecond();
  printCentered("press a key", 20);
  POKE(198, 0);
  while (PEEK(198) == 0) ;

  // clear screen
  clearScreen();
}
Ejemplo n.º 19
0
int main(void)
{
    dispBufferOn = ST_WR_FORE;

    GraphicsString(&Table);
    cputsxy(0, 3, CBOLDON "Your Serial Number is:");
    cputhex16(GetSerialNumber());

    DoMenu(&Menu);
    MainLoop();

    // will never reach this point...
    return 0;
}
Ejemplo n.º 20
0
static unsigned UpdateCStack (void)
/* Update the C stack window */
{
    unsigned mem     = CStackAddr;
    unsigned char x  = CStackFrame.fd_x1 + 5;
    unsigned char y;

    for (y = CStackFrame.fd_y2-1; y > CStackFrame.fd_y1; --y) {
        gotoxy (x, y);
        cputhex16 (* (unsigned*)mem);
        mem += 2;
    }
    cputsxy (CStackFrame.fd_x1+1, CStackFrame.fd_y2-1, "->");
    return mem;
}
Ejemplo n.º 21
0
static unsigned UpdateDump (void)
/* Update the dump window */
{
    char Buf [MAX_X];
    unsigned char y;
    unsigned mem = DumpAddr;
    unsigned char x = DumpFrame.fd_x1 + 1;
    unsigned char* p = (unsigned char*) mem;

    for (y = DumpFrame.fd_y1+1; y < DumpFrame.fd_y2; ++y) {
        cputsxy (x, y, DbgMemDump (mem, Buf, DUMP_BYTES));
        mem += DUMP_BYTES;
    }
    return mem;
}
Ejemplo n.º 22
0
void __fastcall writeStatusBar(const char message[])
{
	unsigned char oldX, oldY;

	oldX = wherex();
	oldY = wherey();

	//textcolor(color_text_status);
	revers(true);

	cclearxy(0, 0, size_x);

	cputsxy(0, 0, message);
	
	revers(false);

	gotoxy(oldY, oldY);
}
Ejemplo n.º 23
0
void show_highscores(void){
	char i,j;
	
	screen_off();
	init_msx(0);
	fill();
	txt_mode();

	print2x2_centered("highscores",1,15,0);
	for (i=0;i<10;++i){
		sprintf(str_dummy,"%-10s %06lu-%02d",highscore[i].name,highscore[i].score,highscore[i].level);
		print2x2_centered(str_dummy,hs_coltab1[i],hs_coltab2[i],3+(i<<1));
	}
	revers(1);textcolor(15);
	cputsxy(9,24,"[s] to save highscores");
	screen_on();

	while(*(char*)0xdc00 == 127){
		wait(0x33+24*8-2);
		setgfx(0x0428);
		wait(0);
		setgfx(0x0438);
		
		++j;
		if ((j & 3) == 0){
			++i;
			memset((char*)0xdbc9,hs_coltab3[i&7],22);
		}

		if (getkey() == 's'){
			screen_off();
			save_hs();
			screen_on();
		}
	}
	screen_off();
	fill();
	delay(35);
	screen_on();
}
Ejemplo n.º 24
0
void desenhaMeioDesfazer(int ultimaJogada,int penultimaJogada) {
    int posicaoX=0,posicaoY=0;
    textbackground(YELLOW);
    textcolor(BLACK);
    posicaoDesenho(ultimaJogada,&posicaoX,&posicaoY);
    cputsxy(posicaoX,posicaoY,"-----");
    posicaoY++;
    cputsxy(posicaoX,posicaoY,"|   |");
    posicaoY++;
    cputsxy(posicaoX,posicaoY,"-----");
    posicaoDesenho(penultimaJogada,&posicaoX,&posicaoY);
    textbackground(BROWN);
    cputsxy(posicaoX,posicaoY,"-----");
    posicaoY++;
    cputsxy(posicaoX,posicaoY,"|");
    cputsxy(posicaoX+4,posicaoY,"|");
    posicaoY++;
    cputsxy(posicaoX,posicaoY,"-----");
    gotoxy(1,1);
}
Ejemplo n.º 25
0
void desenhaDesfazer(int ultimaJogada,int penultimaJogada,int antepenultimaJogada) {
    int posicaoX=0,posicaoY=0;
    textbackground(YELLOW);
    textcolor(BLACK);
    posicaoDesenho(ultimaJogada,&posicaoX,&posicaoY);
    cputsxy(posicaoX,posicaoY,"-----");
    posicaoY++;
    cputsxy(posicaoX,posicaoY,"|   |");
    posicaoY++;
    cputsxy(posicaoX,posicaoY,"-----");
    posicaoDesenho(penultimaJogada,&posicaoX,&posicaoY);
    cputsxy(posicaoX+1,posicaoY+1,"   ");
    if(antepenultimaJogada!=SEM_JOGADA) {
        posicaoDesenho(antepenultimaJogada,&posicaoX,&posicaoY);
        textbackground(BROWN);
        cputsxy(posicaoX,posicaoY,"-----");
        posicaoY++;
        cputsxy(posicaoX,posicaoY,"|");
        cputsxy(posicaoX+4,posicaoY,"|");
        posicaoY++;
        cputsxy(posicaoX,posicaoY,"-----");
    }
    gotoxy(1,1);
}
Ejemplo n.º 26
0
int showAddrsBar()
{
  int Len;

  cclearxy(0,0,screenW*2);
  chlinexy(0,1,screenW);
  cputsxy(0,0,"URL:");

  //fflush (stdout);
  fgets (url, sizeof (url), stdin);

  /* Remove trailing white space including the line terminator */
  Len = strlen (url);
  while (Len > 0 && isspace (url[Len-1])) {
      --Len;
  }
  url[Len] = '\0';

  if (Len>0) {
      getData();
  }

  return(Len);
}
Ejemplo n.º 27
0
char process_simpletext(tgui_Window *win, tgui_Obj *obj){

int ox, oy, x, maxx, bctr;
unsigned key;

char *buf = malloc (sizeof(char)*(obj->width+1));


    strcpy(buf, obj->data);


    ox = win->x1 + 1 + obj->x;
    oy = win->y1 + 2 + obj->y;
    x=ox;

	revers(0);
	cputsxy(x,oy, buf);
	revers(1);
	cputc(' ');
	revers(0);

	maxx=x+obj->width;
    x=x+strlen(buf);
    bctr=strlen(buf);
	gotoxy(x, oy);
	cursor(1);

	do {
		key = cgetc();
		//gotoxy(3,22); cprintf("%d",key);
		if (isalnum(key) || ispunct(key) || key==32) {
			if (x<=maxx){
				revers(0);
		        cputcxy(x,oy,key);
				buf[bctr]=key;
				++bctr;
				buf[bctr]='\0';
		        ++x;
				revers(1);
				cputc(' ');
				revers(0);

			}
		}
		if (key == CH_CURS_LEFT|| key == CH_DEL){
			if (x>ox) {

			    if (x<=maxx)cputcxy(x, oy, '_');
			    --bctr;
			    buf[bctr]='\0';
			    --x;
				gotoxy(x,oy);
				revers(1);
				cputc(' ');
				revers(0);
			}

		}

	} while (key!=CH_ENTER && key!=CH_F1 );

	cursor(0);

	if (key==CH_ENTER ) {
	    revers(0);
     	if (x<maxx) cputcxy(x,oy, ' ');

		strcpy(obj->data, buf);
	}

	//ESCAPE
	if (key==CH_F1) {
	   revers(1);
	   cputsxy(ox, oy, obj->data);
	}

	//textcolor(win->color);

	free(buf);
	return key;

} // end of process_simple_text
Ejemplo n.º 28
0
char process_numbox(tgui_Window *win, tgui_Obj *obj){

int ox, oy, x, maxx, bctr, num;
unsigned key;
unsigned min, max;

char *buf = malloc (sizeof(char)*(obj->width+1));


    strcpy(buf, obj->data);
	num=atoi(buf);

    min=obj->state;
	max=obj->height;

	//textcolor(p4color(obj->color));
    ox = win->x1 + 1 + obj->x;
    oy = win->y1 + 2 + obj->y;
    x=ox;

	//revers(1);
	cputsxy(x,oy, buf);
	//revers(0);


	   revers(1);
	   cputcxy(x+obj->width, oy,'^');
	   revers(0);


	maxx=x+obj->width;
    x=x+strlen(buf);
    bctr=strlen(buf);


	cursor(1);

	do {
		gotoxy(ox+obj->width, oy);
		key = cgetc();
		//gotoxy(3,22);  cprintf ("   "); gotoxy(3,22); cprintf("%d",key);

		if (key == CH_CURS_LEFT || key == CH_CURS_DOWN){
			if (num>min) {
			   // revers(1);
			    --num;
				itoa(num,buf,10);
				gotoxy(ox,oy);
				cclearxy(ox,oy, obj->width);
				gotoxy(ox,oy);
				cputs(buf);

			}

		}
			if (key == CH_CURS_RIGHT || key == CH_CURS_UP){
			if (num<max) {
			   // revers(1);
			    ++num;
				itoa(num,buf,10);
				gotoxy(ox,oy);
				cclearxy(ox, oy, obj->width);
				gotoxy(ox,oy);
				cputs(buf);

			}

		}
	} while (key!=CH_ENTER && key!=CH_F1 );

	cursor(0);

	if (key==CH_ENTER ) {
        revers(0);
        strcpy(obj->data, buf);

	}

	if (key==CH_ESC) {
	   revers(1);
	   gotoxy(ox,oy);
	   cclearxy(ox,oy,obj->width);
	   cputsxy(ox, oy, obj->data);
	}
	revers(0);
	cputcxy(ox+obj->width, oy,'^');


	free(buf);
	return key;

} // end of process_num_text
Ejemplo n.º 29
0
/*
** There is a delay between when the VIC sends its signal, and when the display
** shows that signal.  There is another delay between the display and when
** the lightpen says that it saw that signal. Each display and pen is different.
** Therefore, the driver must be calibrated to them.  A white bar is painted on
** the screen; and, a line is drawn down the middle of it.  When the user clicks
** on that line, the difference between its position and where the VIC thinks
** that the pen is pointing becomes an offset that is subtracted from what the
** VIC sees.
*/
void __fastcall__ pen_calibrate (unsigned char *XOffset)
{
    unsigned char oldBg = bgcolor (COLOR_BLUE);
    unsigned char oldText = textcolor (COLOR_GRAY3);
    unsigned char oldRev = revers (1);
    unsigned char sprite0Color = VIC.spr_color[0];
    unsigned char width, width2, height, height4, height8;
    struct mouse_info info;

    screensize (&width, &height);
    width2 = width / 2;
    height4 = height / 4;
    height8 = height4 * 8;

    /* Draw a bar and line. */

    clrscr ();
    cclearxy (0, height4, height4 * width);
    cvlinexy (width2, height4 + 1, height4 - 2);
    revers (0);

    /* Print instructions. */

    cputsxy (width2 - (sizeof COMMAND1) / 2, height / 2 + 1, COMMAND1);
    cputsxy (width2 - (sizeof COMMAND2) / 2, height / 2 + 3, COMMAND2);

    VIC.spr_color[0] = COLOR_GRAY2;
    mouse_show ();
    mouse_move (width2 * 8, height8 / 2);

    for (;;) {
        /* Wait for the main button to be released. */

        do ; while ((mouse_buttons () & MOUSE_BTN_LEFT));

        /* Wait for the main button to be pressed. */

        do {
            mouse_info (&info);
        } while (!(info.buttons & MOUSE_BTN_LEFT));

        /* Find out if the pen is on or off the bar. */

        if (info.pos.y < height8 || info.pos.y >= height8 * 2) {
            break;
        }

        /* On the bar; adjust the offset. */
        /* Characters are eight pixels wide.
        ** The VIC-II sees every other pixel;
        ** so, we use half of the difference.
        */

        *XOffset += (info.pos.x - (width2 * 8 + 8/2)) / 2;
    }

    /* Off the bar; wait for the main button to be released. */

    do ; while ((mouse_buttons () & MOUSE_BTN_LEFT));

    mouse_hide ();
    VIC.spr_color[0] = sprite0Color;
    revers (oldRev);
    textcolor (oldText);
    bgcolor (oldBg);
    clrscr ();
}
Ejemplo n.º 30
0
void process_listbox(tgui_Window *win, tgui_Obj *obj){

tgui_Listitem *li;
int i, ox, oy, y, ostate, maxy;
unsigned key;

    //textcolor(obj->color);
    ox = win->x1 + 2 + obj->x;
    oy = win->y1 + 3 + obj->y;
	maxy=obj->y + obj->height + 1;

    y=oy;
    li = obj->firstitem;
	ostate = obj->state;
	revers(1);
	cputsxy(ox-1,oy-2, obj->caption);
	revers(0);

	for (i=0; i<obj->topid; i++ ) {
		li = li->next;
	}

	for (i=obj->topid; i<obj->state; i++) {
		li = li->next;
		++y;
	}

   	cursor(1);
	gotoxy(ox,y);

	do {
	   key=cgetc();

	   switch(key){
		   case CH_ENTER:
		       //closewindow(miwin);
                revers(0);
	           cputsxy(ox-1,oy-2, obj->caption);
	           revers(1);
		       return;

		   case CH_F1:
		       //closewindow(miwin);
			   obj->state = ostate;
			   // move bar back to orig place
		       return ;   // escape
		   case CH_CURS_LEFT:
		   case CH_CURS_DOWN:
		       if (li->next->li_id==0) { break; }  //y = oy;
		       revers(0);
  		       cputsxy(ox, y, li->caption);
               cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);
			   li=li->next;
			   obj->state = li->li_id;
			   if (y==maxy ) {
				   obj->topid = obj->topid+1;
				   showlistbox(obj, ox-1, oy-1, obj->color, obj->topid);

			   }


			   if (y<maxy) ++y;

			   if (y == maxy && li->next->li_id ==0){
			       cputcxy(obj->x+obj->width, obj->y+obj->height+2, '_');
			   }
			   else if (y==maxy && li->next->li_id !=0) {

				   cputcxy(obj->x+obj->width, obj->y+obj->height+2, '+');
			   }

			   revers(1);
			   cputsxy(ox, y, li->caption);
			   cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);
			   gotoxy(ox,y);
			   revers(0);
			   if(y==maxy && li->li_id >=(obj->height-1))  cputcxy(obj->x+obj->width, oy-1, '+');

			   break;

		   case CH_CURS_RIGHT:
		   case CH_CURS_UP:
		       if (li->li_id==0) {

				   break; }   // y = my+2+mid;
		       revers(0);
		       cputsxy(ox, y, li->caption);
			   cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);

			   li=li->prev;
			   obj->state = li->li_id;
			   if (y==oy) {
				   obj->topid = obj->topid-1;
				   showlistbox(obj, ox-1, oy-1, obj->color, obj->topid);
			    }

			   if (y > oy) --y;

			   if(y == oy && li->next->li_id != 0){
				   cputcxy(obj->x+obj->width, oy-1, '+');
			   }

			   revers(1);
			   cputsxy(ox, y, li->caption);
			   cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);
			   gotoxy(ox,y);
			   revers(0);

			   if (y==oy && li->li_id==0) cputcxy(obj->x+obj->width, oy-1, '_');

			   if (y==oy && (li->li_id +((obj->height)-1) - 1 < obj->lastitem->li_id ) ) {
				  cputcxy(obj->x+obj->width, oy+obj->height-1, '+');
			   }

			   break;

	       } // switch
	       gotoxy(ox,y);
	   } while(1);




}  // end processs_listbox