Пример #1
0
void Viewer::flipPanelMode() {
	panelMode = !panelMode;
	if (panelMode) {
		currXSize = WINDOW_XSIZE - PANEL_WIDTH;
	}
	else {
		currXSize = WINDOW_XSIZE;
		//If we're in build mode, fix the cursor position
		if (!isViewMode()) {
			currXSize = WINDOW_XSIZE - PANEL_WIDTH;
			int r, c;
			getyx(stdscr, r, c);
			//First, a quick screen check
			
			if (currX + getXSize() > w.getXSize()) {
				int spec = currX + getXSize() - w.getXSize() - 2;
				currX -= spec;
				c += PANEL_WIDTH;
				c -= spec;
			}
			move(r, c);
			currXSize = WINDOW_XSIZE;
			scrollScreen(r, c);
		}
		else if (currX + getXSize() > w.getXSize()) 
			currX = w.getXSize() - getXSize() + 2;
	}
}
Пример #2
0
void incrementCursor()
{
	position++;
	if(position > SCREEN_WIDTH * SCREEN_HEIGHT - 1)
		scrollScreen();
	else
		moveCursorTo();
}
Пример #3
0
void nextLine()
{
	unsigned short x, y;
	getXY(&x, &y);
	setXY(0, y + 1);
	if(position > SCREEN_WIDTH * SCREEN_HEIGHT - 1)
		scrollScreen();
}
Пример #4
0
void Viewer::moveCursor(int& y, int& x, int c) {
	int amnt = 1;
	if (isViewMode())
		amnt = 8;
	//If we're in view mode, just change currY/X
	if (isViewMode()) {
		if (c == KEY_LEFT) {
			currX -= amnt;
			if (currX < 0)
				currX = 0;
		}
		else if (c == KEY_RIGHT) {
			currX += amnt;
			if (currX + getXSize() > w.getXSize())
				currX = w.getXSize() - getXSize() + 2;
		}
		else if (c == KEY_UP) {
			currY -= amnt;
			if (currY < 0)
				currY = 0;
		}
		else if (c == KEY_DOWN) {
			currY += amnt;
			if (currY + getYSize() > w.getYSize())
				currY = w.getYSize() - getYSize() + 2;
		}
	}
	//Otherwise, just change x and y and then scroll
	else {
		if (c == KEY_LEFT) {
			if (x > amnt)
				x-=amnt;
			else
				x = 1;
		}
		else if (c == KEY_RIGHT) {
			if (x < getXSize()-1-amnt)
				x+=amnt;
			else
				x = getXSize()-2;
		}
		else if (c == KEY_UP) {
			if (y > amnt)
				y-=amnt;
			else
				y = 1;
		}
		else if (c == KEY_DOWN) {
			if (y < getYSize()-1-amnt)
				y+=amnt;
			else
				y = getYSize()-2;
		}
		scrollScreen(y, x);
	}
	
}
Пример #5
0
/* int main(int argc, char *argv[]) { */
int main(void) {

   unsigned short drive=8;
   char input;

   do {
      /* a little effect */
      scrollScreen();

      mainMenu();
      input=getchar();

      switch (input) {

         case '1':
                   scrollScreen();
                   drive=baseSetup();
                   break;

         case '2':
                   scrollScreen();
                   boardSetup(drive);
                   break;

         case '3':
                   scrollScreen();
                   networkSetup(drive);
                   break;
 
         case '4':
                   scrollScreen();
                   userSetup(drive);
                   break;
 
         default:
                   break;

      }
 
   } while (input != 'q');

   return 0;
}
Пример #6
0
char kPutChar(char ch) {
    char* vidmem = (char *) VIDEO_ADDR;

    unsigned int offset = getCursorOffset();

    if (ch == '\n') {
        int row = offset / (VIDEO_COLS * 2);
        offset = screenOffset(row + 1, 0);
    } else if (ch == '\b') {
        offset -= 2;
        vidmem[offset] = ' ';
        vidmem[offset+1] = g_attr;
    } else {
        vidmem[offset] = ch;
        vidmem[offset+1] = g_attr;
        offset += 2;
    }

    offset = scrollScreen(offset);

    setCursorOffset(offset);

    return ch;
}
Пример #7
0
void AGOSEngine::displayScreen() {
	if (_fastFadeInFlag == 0 && _paletteFlag == 1) {
		_paletteFlag = 0;
		if (memcmp(_displayPalette, _currentPalette, sizeof(_currentPalette))) {
			memcpy(_currentPalette, _displayPalette, sizeof(_displayPalette));
			_system->getPaletteManager()->setPalette(_displayPalette, 0, 256);
		}
	}

	Graphics::Surface *screen = _system->lockScreen();
	if (getGameType() == GType_PP || getGameType() == GType_FF) {
		byte *src = getBackBuf();
		byte *dst = (byte *)screen->pixels;
		for (int i = 0; i < _screenHeight; i++) {
			memcpy(dst, src, _screenWidth);
			src += _backBuf->pitch;
			dst += screen->pitch;
		}
		if (getGameId() != GID_DIMP)
			fillBackFromBackGround(_screenHeight, _screenWidth);
	} else {
		if (_window4Flag == 2) {
			_window4Flag = 0;

			uint16 srcWidth, width, height;
			byte *dst = (byte *)screen->pixels;

			const byte *src = (const byte *)_window4BackScn->pixels;
			if (_window3Flag == 1) {
				src = getBackGround();
			}

			dst += (_moveYMin + _videoWindows[17]) * screen->pitch;
			dst += (_videoWindows[16] * 16) + _moveXMin;

			src += (_videoWindows[18] * 16 * _moveYMin);
			src += _moveXMin;

			srcWidth = _videoWindows[18] * 16;

			width = _moveXMax - _moveXMin;
			height = _moveYMax - _moveYMin;

			for (; height > 0; height--) {
				memcpy(dst, src, width);
				dst += screen->pitch;
				src += srcWidth;
			}

			_moveXMin = 0xFFFF;
			_moveYMin = 0xFFFF;
			_moveXMax = 0;
			_moveYMax = 0;
		}

		if (_window6Flag == 2) {
			_window6Flag = 0;

			byte *src = (byte *)_window6BackScn->pixels;
			byte *dst = (byte *)screen->pixels + 51 * screen->pitch;
			for (int i = 0; i < 80; i++) {
				memcpy(dst, src, _window6BackScn->w);
				dst += screen->pitch;
				src += _window6BackScn->pitch;
			}
		}
	}

	_system->unlockScreen();

	if (getGameType() == GType_FF && _scrollFlag) {
		scrollScreen();
	}

	if (_fastFadeInFlag) {
		fastFadeIn();
	}
}
Пример #8
0
void AGOSEngine::animateSprites() {
	VgaSprite *vsp;
	VgaPointersEntry *vpe;

	if (_copyScnFlag) {
		_copyScnFlag--;
		_vgaSpriteChanged++;
	}

	if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) {
		const uint8 var = (getGameType() == GType_ELVIRA1) ? 293 : 71;
		if (_wallOn && !_variableArray[var]) {
			_wallOn--;

			VC10_state state;
			state.srcPtr = getBackGround() + 3 * _backGroundBuf->pitch + 3 * 16;
			state.height = state.draw_height = 127;
			state.width = state.draw_width = 14;
			state.y = 0;
			state.x = 0;
			state.palette = 0;
			state.paletteMod = 0;
			state.flags = kDFNonTrans;

			_windowNum = 4;

			_backFlag = true;
			drawImage(&state);
			_backFlag = false;

			_vgaSpriteChanged++;
		}
	}

	if (!_scrollFlag && !_vgaSpriteChanged) {
		return;
	}

	_vgaSpriteChanged = 0;

	if (_paletteFlag == 2)
		_paletteFlag = 1;

	if (getGameType() == GType_SIMON2 && _scrollFlag) {
		scrollScreen();
	}

	if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
		dirtyClips();
	}

	restoreBackGround();

	vsp = _vgaSprites;
	for (; vsp->id !=0; vsp++) {
		if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
			!(vsp->windowNum & 0x8000)) {
			continue;
		}

		vsp->windowNum &= ~0x8000;

		vpe = &_vgaBufferPointers[vsp->zoneNum];
		_curVgaFile1 = vpe->vgaFile1;
		_curVgaFile2 = vpe->vgaFile2;
		_curSfxFile = vpe->sfxFile;
		_windowNum = vsp->windowNum;
		_vgaCurSpriteId = vsp->id;

		saveBackGround(vsp);

		drawImage_init(vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags);
	}

	if (getGameType() == GType_ELVIRA1 && _variableArray[293]) {
		// Used by the Fire Wall and Ice Wall spells
		debug(0, "Using special wall");

		uint8 color, h, len;
		byte *dst = (byte *)_window4BackScn->pixels;

		color = (_variableArray[293] & 1) ? 13 : 15;
		_wallOn = 2;

		h = 127;
		while (h) {
			len = 112;
			while (len--) {
				*dst++ = color;
				dst++;
			}

			h--;
			if (h == 0)
				break;

			len = 112;
			while (len--) {
				dst++;
				*dst++ = color;
			}
			h--;
		}

		_window4Flag = 1;
		setMoveRect(0, 0, 224, 127);
	} else if (getGameType() == GType_ELVIRA2 && _variableArray[71] & 2) {
		// Used by the Unholy Barrier spell
		uint8 color, h, len;
		byte *dst = (byte *)_window4BackScn->pixels;

		color = 1;
		_wallOn = 2;

		h = 43;
		while (h) {
			len = 56;
			while (len--) {
				*dst++ = color;
				dst += 3;
			}

			h--;
			if (h == 0)
				break;

			dst += 448;

			len = 56;
			while (len--) {
				dst += 2;
				*dst++ = color;
				dst += 1;
			}
			dst += 448;
			h--;
		}

		_window4Flag = 1;
		setMoveRect(0, 0, 224, 127);
	}

	if (_window6Flag == 1)
		_window6Flag++;

	if (_window4Flag == 1)
		_window4Flag++;

	_displayFlag++;
}
Пример #9
0
void LAN() {
	PA_ResetBgSys();
	PA_ResetSpriteSys();
	PA_InitText(MAIN_SCREEN, 0);
	PA_SetTextCol(MAIN_SCREEN, 31, 31, 31);

	if(!IPC_Init()) {
		PA_OutputText(MAIN_SCREEN, 0, 0, "IPC INIT FAILED");
		while(true) {}
	}
	IPC_SetChannelCallback(0, &LWIFI_IPC_Callback);
	PA_VBLFunctionInit(customVBL);
	// inits/preps DS <-> DS

	PA_OutputText(MAIN_SCREEN, 1, 3, "Start Game = Start/nJoin Game = Select");

	fadeIn();

	while(playernumber == -1) {
		if(!lobbyinited) {
			LOBBY_Init();
			LOBBY_SetStreamHandler(0x0001, &receive);
			lobbyinited = true;
		} // inits liblobby
		else if(Pad.Newpress.Start) {
			playernumber = 0;
			LOBBY_SetOwnName("Host");
			LOBBY_CreateRoom(ROOM_NAME, MAX_PLAYERS, GAME_CODE, GAME_VER);
		} // creates a new game
		else if(Pad.Newpress.Select) {
			playernumber = 1;
			LOBBY_SetOwnName("Client");
			LOBBY_JoinRoom(LOBBY_GetRoomByGame(0, GAME_CODE));
		} // joins a created game
		PA_WaitForVBL();
	}
	
	int max = LOBBY_GetUsercountInRoom(LOBBY_GetRoomByUser(LOBBY_GetUserByID(USERID_MYSELF)));
	PA_OutputText(MAIN_SCREEN, 1, 3, "                                         ");
	PA_OutputText(MAIN_SCREEN, 1, 4, "                                         ");
	PA_OutputText(MAIN_SCREEN, 1, 3, "Waiting for connection");
	while(max < 2) {
		max = LOBBY_GetUsercountInRoom(LOBBY_GetRoomByUser(LOBBY_GetUserByID(USERID_MYSELF)));
		PA_OutputText(MAIN_SCREEN, 1, 4, "%d", max);
		PA_WaitForVBL();
	}
	
	players.push_back(new Kirby(512/2 -96 -32, 256/3 -32, 1, players, &display));
	Stage stage = setStage(FINALDESTINATION);
	PA_InitText(MAIN_SCREEN, 1); // inits text on the main screen (displays time)
	PA_SetTextCol(MAIN_SCREEN, 31, 31, 31); // text color = white

	PA_OutputText(MAIN_SCREEN, 1, 3, "                                         ");
	PA_OutputText(MAIN_SCREEN, 1, 4, "                                         ");

	while(true) {
		if(playernumber == 0) {
			players[0] -> act();
			dat[0] = (int)(players[0] -> x);
			dat[1] = (int)(players[0] -> y);
			dat[2] = PA_GetSpriteAnimFrame(MAIN_SCREEN, players[0] -> SPRITENUM);
			LOBBY_SendToUser(LOBBY_GetUserByID(0), 0x0001, (unsigned char *)dat, 10);
		}
		scrollScreen();
		PA_WaitForVBL();
	}
}
Пример #10
0
int userSetup(unsigned short drive) {
   unsigned short count=0,user_count=0;
   char input,buff[20];

   BBS_USER_REC mybbsuser;
   ST_FILE file;

   /* enter users */
   printf("\n* BBS user editor\n");

   strcpy(file.szFileName, "user.idx");
   file.ucDeviceNo = drive;

   if(siFileExists(&file) == 62 /*|| user_count == 0*/) {
     user_count = 1;
     memset(&mybbsuser, 0x20, sizeof(BBS_USER_REC));

     printf("\n* Initializing user databases...\n");
     strcpy(file.szFileName, "user.dat");
     ssInitRELFile(&file, &mybbsuser, sizeof(BBS_USER_REC), BBS_MAX_USERS);
     strcpy(file.szFileName, "user.idx");
     ssInitRELFile(&file, &user_count, sizeof(unsigned short), 1);
     writeUserIndex(&user_count, &file);
   }

   printf("\n(A)dd, (E)dit or (L)list users? ");
   input=getchar();

   switch (input) {

      case 'a':
      case 'A': {
          readUserIndex(&user_count, &file);
          enterUserData(&mybbsuser, &user_count);
          writeUserData(&mybbsuser, &file, &user_count);
          user_count += 1;
          writeUserIndex(&user_count, &file);
      }
      break;

      case 'e':
      case 'E': {
             printf("\n\nEnter user #: ");
             gets(buff);
             sscanf(buff, "%d", &count);
             readUserData(&mybbsuser, &file, &count);
             scrollScreen();
             printf("\nUser #     : %03d", count);
             printf("\nUsername   : %s", mybbsuser.user_name);
             printf("\nPassword   : %s\n", mybbsuser.user_pwd);
             printf("\nAccess lvl.: %03d\n", mybbsuser.access_req);
             enterUserData(&mybbsuser, &count);
             writeUserData(&mybbsuser, &file, &count);
      }
      break;

      case 'l':
      case 'L': {
             count = 1;
             scrollScreen();
             printf("\n\nID# |Acc. | Username");
             printf("\n----+-----+----------------------------");

             readUserIndex(&user_count, &file);

             do {
                readUserData(&mybbsuser, &file, &count);
                printf("\n%03d | %03d | %s",  count, mybbsuser.access_req, mybbsuser.user_name);
                count++;
             } while (count < user_count);

             printf("\n\nPress key"); 
             input=getchar();
      }   
      break;

   }
   return 0;
}