SBSPSS/source/frontend/scrollbg.cpp

153 lines
3.1 KiB
C++
Raw Normal View History

2000-11-09 21:29:28 +01:00
/*=========================================================================
2001-01-05 01:17:57 +01:00
scrollbg.cpp
2000-11-09 21:29:28 +01:00
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "frontend\scrollbg.h"
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
/* Std Lib
------- */
/* Data
---- */
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2000-11-09 21:29:28 +01:00
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CScrollyBackground::init()
{
2000-11-13 18:03:20 +01:00
m_sprites=new ("Scrolly Background sprites") SpriteBank;
2001-04-20 16:53:35 +02:00
m_sprites->load(SPRITES_SPRITES_SPR);
2000-11-13 18:03:20 +01:00
m_xOff=m_yOff=0;
setSpeed(DEFAULT_X_SPEED,DEFAULT_Y_SPEED);
setSpeedScale(DEFAULT_SPEED_SCALE);
setOt(DEFAULT_OT);
2001-07-02 02:40:09 +02:00
setFrame(FRM__BUTX);
2001-06-08 18:13:22 +02:00
setTheDrawMode(DRAWMODE_NORMAL);
setColour(128,128,128);
2001-06-08 20:26:09 +02:00
setScale(NORMAL_SCALE);
2000-11-09 21:29:28 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CScrollyBackground::shutdown()
{
2000-11-13 18:03:20 +01:00
m_sprites->dump(); delete m_sprites; m_sprites=NULL;
2000-11-09 21:29:28 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CScrollyBackground::render()
{
2001-06-08 18:13:22 +02:00
int smode;
2000-11-13 18:03:20 +01:00
POLY_FT4 *ft4;
sFrameHdr *fh;
int x,y,w,h;
2001-06-08 20:30:39 +02:00
smode=m_drawMode;
2001-06-08 18:13:22 +02:00
2001-01-03 17:13:59 +01:00
fh=m_sprites->getFrameHeader(m_frame);
2001-06-08 20:26:09 +02:00
w=(fh->W*m_scale)>>8;
h=(fh->H*m_scale)>>8;
2000-11-13 18:03:20 +01:00
y=(m_yOff>>m_speedScale)-h;
do
{
x=(m_xOff>>m_speedScale)-w;
do
{
2001-06-08 20:26:09 +02:00
if(m_scale==NORMAL_SCALE)
{
ft4=m_sprites->printFT4(fh,x,y,0,0,m_ot);
}
else
{
ft4=m_sprites->printFT4Scaled(fh,x,y,0,0,m_ot,m_scale);
}
2001-06-08 18:13:22 +02:00
setShadeTex(ft4,0);
2000-11-13 18:03:20 +01:00
setSemiTrans(ft4,true);
2001-06-08 18:13:22 +02:00
ft4->tpage|=(smode<<5);
setRGB0(ft4,m_r,m_g,m_b);
2000-11-13 18:03:20 +01:00
x+=w;
}
2001-06-08 20:26:09 +02:00
while(x<512+64);
2000-11-13 18:03:20 +01:00
y+=h;
}
2001-06-08 20:26:09 +02:00
while(y<256+64);
2000-11-09 21:29:28 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CScrollyBackground::think(int _frames)
{
2000-11-13 18:03:20 +01:00
sFrameHdr *fh;
2001-06-08 20:26:09 +02:00
int w,h;
2000-11-13 18:03:20 +01:00
2001-01-03 17:13:59 +01:00
fh=m_sprites->getFrameHeader(m_frame);
2001-06-08 20:26:09 +02:00
w=(fh->W*m_scale)>>8;
h=(fh->H*m_scale)>>8;
2000-11-13 18:03:20 +01:00
2001-06-08 20:26:09 +02:00
m_xOff=(m_xOff+(_frames*m_xSpeed))%(w<<m_speedScale);
m_yOff=(m_yOff+(_frames*m_ySpeed))%(h<<m_speedScale);
2000-11-09 21:29:28 +01:00
}
/*===========================================================================
end */