void AniArt_GHZ()
{
	if(TimerNeg(v_lani0_time, 5))
	{
		// Waterfall
		auto frame = IncWrap(v_lani0_frame, 1);
		VDP_SetAddr(0x6F00, VDP_VRAM_Write);
		LoadTiles(&Art_GhzWater[frame * 0x100], 8);
	}
	else if(TimerNeg(v_lani1_time, 15))
	{
		// Big Flower
		auto frame = IncWrap(v_lani1_frame, 1);
		VDP_SetAddr(0x6B80, VDP_VRAM_Write);
		LoadTiles(&Art_GhzFlower1[frame * 0x200], 16);
	}
	else if(TimerNeg(v_lani2_time, 7))
	{
		// Small Flower
		auto frame = IncWrap(v_lani2_frame, 3);

		if(frame == 3)
			frame = 1; // 0 1 2 1 0 1 2 1...

		if(frame == 0 || frame == 2)
			v_lani2_time = 0x7F; // longer duration for frames 0 and 2

		VDP_SetAddr(0x6D80, VDP_VRAM_Write);
		LoadTiles(&Art_GhzFlower2[frame * 0x180], 12);
	}
}
void AniArt_MZ()
{
	if(TimerNeg(v_lani0_time, 19))
	{
		// Lava
		auto frame = IncWrap(v_lani0_frame, 2);
		VDP_SetAddr(0x5C40, VDP_VRAM_Write);
		LoadTiles(&Art_MzLava1[frame * 0x100], 8);

	}
	else if(TimerNeg(v_lani1_time, 1))
	{
		// Magma
		VDP_SetAddr(0x5A40, VDP_VRAM_Write);
		ubyte* artBase = &Art_MzLava2[v_lani0_frame * 0x200];

		for(int i = 0, j = v_oscillate[10]; i < 4; i++, j += 4)
		{
			auto art = (uint*)(artBase + (j & 0xF));

			for(int j = 0; j < 32; j++, art += 4)
				VDP_Data(*art);
		}
	}
	else if(TimerNeg(v_lani2_time, 7))
	{
		// Torch
		auto frame = IncWrap(v_lani3_frame, 3);
		VDP_SetAddr(0x5E40, VDP_VRAM_Write);
		LoadTiles(&Art_MzTorch[frame * 0xC00], 6);
	}
}
Example #3
0
void MMXCore::LoadTilesAndPalettes()
{
	// Load Palettes
	DWORD configPointer = snes2pc(SReadWord(p_palett[type] + level*2 + 0x60) | 0x860000);
	BYTE colorsToLoad = rom[configPointer++];
	if (type==2)
		pPalette = snes2pc(ReadWord(configPointer++) | 0x8C0000);
	else
		pPalette = snes2pc(ReadWord(configPointer++) | 0x850000);

	for(int i=0; i<colorsToLoad; i++)
		palCache[i] = Get16Color(pPalette + i*2);
	for(int i=0; i<(colorsToLoad>>4); i++)
		palettesOffset[i] = (DWORD)pPalette + i*0x20;
	
	memcpy(vram, vrambase, 0x200);
	if (type==0) // Only MMX1 is able to do this
	{
		LoadPaletteDynamic();
		LoadGFXs();
		LoadTiles();
	}
	for(int i=0; i<0x400; i++)
		tile4bpp2raw(vram + (i<<5), vramCache + (i<<6));
}
void AniArt_GiantRing()
{
	if(v_gfxbigring)
	{
		v_gfxbigring -= 0x1C0;
		VDP_SetAddr(0x8000 + v_gfxbigring, VDP_VRAM_Write);
		LoadTiles(&Art_BigRing[v_gfxbigring], 14);
	}
}
Example #5
0
Tileset::Tileset(const std::string& filename, const int width, const int height, const int tilesize) :
	m_textures(NULL),
	m_numTiles(0),
	m_width(0),
	m_height(0),
	m_tileDataWidth(0),
	m_tileDataHeight(0)
{
	LoadTiles(filename, width, height, tilesize);
}
void AniArt_Ending()
{
	if(TimerNeg(v_lani1_time, 7))
	{
		// Big Flower
		auto frame = IncWrap(v_lani1_frame, 1);
		VDP_SetAddr(0x6B80, VDP_VRAM_Write);
		LoadTiles(&Art_GhzFlower1[frame * 0x200], 16);
		VDP_SetAddr(0x7200, VDP_VRAM_Write);
		LoadTiles(&0xFFFF9400[frame * 0x200], 16);
	}
	else if(TimerNeg(v_lani2_time, 7))
	{
		// Small Flower
		// Interestingly, it uses a much faster animation cycle than the GHZ versions of this flower.. presumably this
		// was the original animation speed, and they slowed it down in GHZ and forgot to here
		auto frame = FlowerFrames[IncWrap(v_lani2_frame, 7)];
		VDP_SetAddr(0x6D80, VDP_VRAM_Write);
		LoadTiles(&Art_GhzFlower2[frame * 0x180], 12);
	}
	else if(TimerNeg(v_lani4_time, 14))
	{
		auto frame = IncWrap(v_lani4_frame, 3);

		if(frame == 3)
			frame = 1;

		VDP_SetAddr(0x7000, VDP_VRAM_Write);
		LoadTiles(&0xFFFF9800[frame * 0x200], 16);
	}
	else if(TimerNeg(v_lani5_time, 11))
	{
		auto frame = IncWrap(v_lani5_frame, 3);

		if(frame == 3)
			frame = 1;

		VDP_SetAddr(0x6800, VDP_VRAM_Write);
		LoadTiles(&0xFFFF9E00[frame * 0x200], 16);
	}
}
Example #7
0
void Init(HWND hWnd)
{
	// Set our global window handle to our main window
	g_hWnd = hWnd;

	// Create our double buffering for each window
	g_Buffer.CreateDoubleBuffering(hWnd);
	g_ToolBuffer.CreateDoubleBuffering(g_hWndTool);

	// Set the map to default
    g_Map.SetDefault();

	// Load the tiles into the global lists and then get the scroll bar max scroll position
	g_ScrollInfo.nMax = LoadTiles();

	// By default set the current tile type to map tiles
	g_Map.SetCurrentType(TILE_TYPE);

	// Set our current map to ....  our current map :)
	g_pCurrentMap = &g_Map;

	// Initialize the scroll bar information
	g_ScrollInfo.cbSize = sizeof(SCROLLINFO);
	g_ScrollInfo.nMin = 0; 
	g_ScrollInfo.nPage = 1; 
	g_ScrollInfo.fMask = SIF_PAGE | SIF_RANGE;
	SetScrollInfo(g_hWndTool, SB_VERT, &g_ScrollInfo, FALSE);
				

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// Here we initialize our open file information
	g_OpenInfo.lStructSize = sizeof(OPENFILENAME);				// Set the size of the structure
	g_OpenInfo.nMaxFile = MAX_PATH;								// Set the max characters for a file name
	g_OpenInfo.lpstrFile = g_szFileName;						// Give a string to store the file name
	g_OpenInfo.lpstrFilter = "Map Files (*.map)\0*.map";		// Only accept .map files to load
	g_OpenInfo.hwndOwner = g_hWndTool;							// Assign the window owner and give it desired flags
	g_OpenInfo.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


	// Here we set the current pen to red for drawing our exit rectangles
	g_Buffer.SetPen(PS_SOLID,2,RGB(255,0,0));

	// Set the backbuffer to black first (This clears the backbuffer)
	g_Buffer.ClearScreen(BLACK_BRUSH);			
	g_ToolBuffer.ClearScreen(BLACK_BRUSH);			
}
Example #8
0
void TMap::LoadMap(const QString& map) {
    USettings settings;
    settings.Load("maps/" + map + "/config.ini");
    QString color = settings.GetParameter("color");
    Color = QColor(color);
    Width = settings.GetParameter("width");
    Height = settings.GetParameter("height");
    LoadTiles();
    makeBackgroundImage();
    Loaded = true;
    WHRatio = QPointF(1.0, 1.0);
    if( Width && Height ) {
        // 1.0 means max size, other always less than 1
        WHRatio = QPointF(Width > Height ?  1.0 : (qreal)Width / Height,
                          Width > Height ? (qreal)Height / Width : 1.0);
    }
}
Example #9
0
void Init(HWND hWnd)
{
    // Set our global window handle to our main window
    g_hWnd = hWnd;

    // Create our double buffering for each window
    g_Buffer.CreateDoubleBuffering(hWnd);
    g_ToolBuffer.CreateDoubleBuffering(g_hWndTool);

    // Set the map to default
    g_Map.SetDefault();

    // Load the tiles into the global lists and then get the scroll bar max scroll position
    g_ScrollInfo.nMax = LoadTiles();

    // By default set the current tile type to map tiles
    g_Map.SetCurrentType(TILE_TYPE);

    // Set our current map to ....  our current map :)
    g_pCurrentMap = &g_Map;

    // Initialize the scroll bar information
    g_ScrollInfo.cbSize = sizeof(SCROLLINFO);
    g_ScrollInfo.nMin = 0;
    g_ScrollInfo.nPage = 1;
    g_ScrollInfo.fMask = SIF_PAGE | SIF_RANGE;
    SetScrollInfo(g_hWndTool, SB_VERT, &g_ScrollInfo, FALSE);


//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

    // Here we set the current pen to red for drawing our exit rectangles
    g_Buffer.SetPen(PS_SOLID,2,RGB(255,0,0));

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


    // Set the backbuffer to black first (This clears the backbuffer)
    g_Buffer.ClearScreen(BLACK_BRUSH);
    g_ToolBuffer.ClearScreen(BLACK_BRUSH);
}
Example #10
0
//////////////////////////////////////////////////////////////////////////////////
// CDXMap Constructor
//////////////////////////////////////////////////////////////////////////////////
CDXMap::CDXMap(CDXTile *pTiles, CDXScreen *pScreen)
{
    // initialize the class so we have a fresh start
    Init();
    m_Tiles = pTiles;
    m_Screen = pScreen;
    m_TileWidth = m_Tiles->m_BlockWidth;
    m_TileHeight = m_Tiles->m_BlockHeight;
    m_SCREEN_W = pScreen->GetWidth();
    m_SCREEN_H = pScreen->GetHeight();
//  m_SCREEN_TW = (m_SCREEN_W / m_TileWidth) + 1;
//  m_SCREEN_TH = (m_SCREEN_H / m_TileHeight) + 1;
    // fixed reported by [email protected]
    m_SCREEN_TW = (m_SCREEN_W / m_TileWidth);
    m_SCREEN_TH = (m_SCREEN_H / m_TileHeight);

    if (m_SCREEN_W % m_TileWidth) m_SCREEN_TW++;

    if (m_SCREEN_H % m_TileHeight) m_SCREEN_TH++;

    LoadTiles(pTiles);
}
void AniArt_SBZ()
{
	// v_lani2_frame is being abused as a timer here
	if(v_lani2_frame > 0)
		v_lani2_frame--;
	else if(TimerNeg(v_lani0_time, 7))
	{
		VDP_SetAddr(0x8900, VDP_VRAM_Write);
		auto frame = IncWrap(v_lani0_frame, 7);

		if(frame == 0)
		{
			v_lani2_frame = 180;
			LoadTiles(Art_SbzSmoke, 6);
			LoadTiles(Art_SbzSmoke, 6);
		}
		else
			LoadTiles(&Art_SbzSmoke[(frame - 1) & 0x180], 12);

		return;
	}

	if(v_lani2_time > 0)
		v_lani2_time--;
	else if(TimerNeg(v_lani1_time, 7))
	{
		VDP_SetAddr(0x8A80, VDP_VRAM_Write);
		auto frame = IncWrap(v_lani1_frame, 7);

		if(frame == 0)
		{
			v_lani2_time = 120;
			LoadTiles(Art_SbzSmoke, 6);
			LoadTiles(Art_SbzSmoke, 6);
		}
		else
			LoadTiles(&Art_SbzSmoke[(frame - 1) & 0x180], 12);
	}
}
Example #12
0
Map::Map(SharedContext* l_context)
:m_context(l_context), m_defaultTile(l_context), m_maxMapSize(32, 32), m_playerId(-1)
{
    m_context->SetMap(this);
    LoadTiles("tiles.cfg");
}
Example #13
0
void Map::UpdateRaknet() {
	switch (mRaknet.mPacket->data[0]) {
	case ID_ITEM_TAKEN: {
		int itemIndex = 0;

		RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length,
				false);
		bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
		bsIn.Read(itemIndex);

		mMapData.mLayer1[itemIndex].SetActive(false);
		break;
	}
	case ID_DROP_ITEM: {
		int imageNumber = 0;
		int index = 0;

		RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length,
				false);
		bsIn.IgnoreBytes(sizeof(RakNet::MessageID));

		bsIn.Read(imageNumber);
		bsIn.Read(index);

		AddItem(imageNumber, index);
		break;
	}
	case ID_MAP_DATA: {
		int map = 0;
		int width = 0;
		int height = 0;
		int tiles = 0;

		RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length,
				false);
		bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
		bsIn.Read(map);
		bsIn.Read(width);
		bsIn.Read(height);
		bsIn.Read(tiles);

		mMapData.SetWidth(width);
		mMapData.SetHeight(height);
		mMapData.SetNumberOfTiles(tiles);
		mMapData.CreateTiles();

		for (int a = 0; a < tiles; ++a) {
			bsIn.Read(mMapData.mLayer1[a]);
			bsIn.Read(mMapData.mLayer2[a]);
			bsIn.Read(mMapData.mLayer3[a]);
			bsIn.Read(mMapData.mLayer4[a]);
		}

		bsIn.Read(mNumberOfNPCS);

		for (int a = 0; a < mNumberOfNPCS; ++a) {
			NPC* temp = new NPC(mRaknet, a);
			bsIn.Read(temp->GetData());
			mNPCS.push_back(temp);
		}

		// Save map so we dont need to retrieve it every time
		Save();

		// Create are tiles for the map
		mNumberOfItems = IniFile_GetInt("Number_Of_items", 5);

		LoadTiles();
		LoadItems();
		mPathFinding.Init(GetWidth(), GetHeight(), &mMapData.mLayer1[0]);

		// Load npcs
		for (int a = 0; a < mNumberOfNPCS; ++a) {
			NPC* temp = mNPCS[a];
			NPCData& tempData = temp->GetData();

			temp->Init(width, height, mPathFinding.GetGraph());
			temp->ReloadGraphic();

			if (!tempData.mHost) {
				temp->CreatePath();
			}
		}

		int north = 0;
		int east = 0;
		int south = 0;
		int west = 0;

		bsIn.Read(north);
		bsIn.Read(east);
		bsIn.Read(south);
		bsIn.Read(west);

		mMapData.SetNorth(north);
		mMapData.SetEast(east);
		mMapData.SetSouth(south);
		mMapData.SetWest(west);

		break;
	}

	case ID_NPC_NEW_PATH: {
		int npcSlot = 0;
		int endIndex = 0;
		SVector2 position(0.0f, 0.0f);

		RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length,
				false);
		bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
		bsIn.Read(npcSlot);
		bsIn.Read(endIndex);
		bsIn.Read(position);

		NPC* tempNPC = mNPCS[npcSlot];
		tempNPC->SetEndPath(endIndex);
		tempNPC->CreatePath();
		tempNPC->GetData().SetPosition(position);
		break;
	}

	case ID_NPC_HOST: {
		for (int a = 0; a < mNumberOfNPCS; ++a) {
			mNPCS[a]->GetData().SetHost(true);
		}
		break;
	}

	case ID_NPC_STOP: {
		if (!mMemoryCreated)
			break;

		int npcSlot = 0;
		bool stop = false;

		RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length,
				false);
		bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
		bsIn.Read(npcSlot);
		bsIn.Read(stop);

		if (stop) {
			int test = 0;
		}
		mNPCS[npcSlot]->SetStop(stop);
		break;
	}
	}
}
extern "C" void _main()
{

	//make nbg0 invisible,
	*vdp2::regs::prina = 0x0000;

	//turn nbg0 on
	*vdp2::regs::bgon = 0x0001;

	//16x16 tiles (character size is 2x2 cells)
	*vdp2::regs::chctla = 0x0001;

	//plane contains 1x1 pages
	*vdp2::regs::plsz = 0x0000;

	//pattern name data is 2 words
	*vdp2::regs::pncn0 = 0x0000;

	//no zooming
	*vdp2::regs::zmctl = 0;
	*vdp2::regs::zmxin0 = 1;
	*vdp2::regs::zmxin1 = 1;

	*vdp2::regs::mpofn = 0;
	*vdp2::regs::mpabn0 = 0;
	*vdp2::regs::mpcdn0 = 0;

	*vdp2::regs::tvmd = 0x8010;

	//4 banks
	*vdp2::regs::ramctl = 0x0300;

	//we store tile pixel data here
	u32 tile_address = 0x40000;

	WriteNameTables(tile_address);

	int frame_count = 0;

	LoadTiles(tile_address);

	vu32* CYCA0 = (vu32*) 0x25F80010;
	vu32* CYCA1 = (vu32*) 0x25F80014;
	vu32* CYCB0 = (vu32*) 0x25F80018;
	vu32* CYCB1 = (vu32*) 0x25F8001C;

    *CYCA0  = 0x0123FFFF;
    *CYCA1  = 0xCDFFFFFF;
    *CYCB0  = 0x4567FFFF;
    *CYCB1  = 0xFFFFFFFF;

	for(int i = 0; i < 32; i++)
		vdp2::cram[i] = util::MakeColor16(i,i,0,1);

	*vdp2::regs::sfprmd = 2;

	while(1)
	{
		simple::DoNothing();

		frame_count++;

		*vdp2::regs::sfcode = 1 << ((frame_count/30) & 7);//set special function code a to 0xe or 0xf

		*vdp2::regs::scxin0 = frame_count;
		*vdp2::regs::ccrna = tables::kSine5bit[frame_count &tables::kSine5bitMask];

	}
}