Skip to content

Commit

Permalink
Fixed alphablending, added sample in gif/alpablending
Browse files Browse the repository at this point in the history
git-svn-id: http://psp.jim.sh/svn/ps2/trunk@1060 bf8e388e-adfb-0310-9433-acdc3088d20d
  • Loading branch information
lukaszdk committed Apr 27, 2005
1 parent f2685f4 commit abbcb40
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/GifPipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Ito::GifPipe: public GsDriver
void PrimShading(u32 shading);
/** Enable/disable primitive alpablending
\param enable true to enable, false to disable. */
void PrimAlpaBlend(bool enable);
void PrimAlphaBlend(bool enable);
/** Enable/disable primitive antialiasing.
\param enable true to enable, false to disable. */
void PrimAntialias(bool enable);
Expand Down
2 changes: 1 addition & 1 deletion samples/gif/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

SUBDIRS = $(sort textureformats sprite point indirectfb)
SUBDIRS = $(sort alphablending textureformats sprite point indirectfb)

all: $(patsubst %, _dir_%, $(SUBDIRS))

Expand Down
7 changes: 7 additions & 0 deletions samples/gif/alphablending/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

EE_BIN = alphablend.elf
EE_OBJS = main.o

all : $(EE_BIN)

include $(LIBITO)/Makefile.prefab
45 changes: 45 additions & 0 deletions samples/gif/alphablending/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <Ito.h>

using namespace Ito;

int main()
{
GifPipe Gif;

u32 ScreenWidth = 640;
u32 ScreenHeight = 448;
u32 ScreenX = 155;
u32 ScreenY = 70;

if(Gs::GetVideoMode() == VMODE_PAL)
{
ScreenHeight = 512;
ScreenY = 70;
}


Gs::Reset();

Gif.SetupEnv(RGBA16, ScreenWidth, ScreenHeight, 2, VMODE_AUTO, FIELD, ENABLE, ScreenX, ScreenY);

Gif.AlphaBlending(0);

while(1)
{
Gif.SetNextDrawbuffer();

Gif.PrimAlphaBlend(false);
Gif.ClearScreen();
Gif.PrimAlphaBlend(true);


Gif.Sprite(RGBA(0,0,0xFF, 0x80), 64, 64, 128, 128);

Gif.Sprite(RGBA(0xFF,0,0, 0x40), 96, 96, 160, 160);

Gif.Send();
}


return 0;
}
2 changes: 1 addition & 1 deletion samples/gif/sprite/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

EE_BIN = sprite.elf
EE_BIN = alphablend.elf
EE_OBJS = main.o

all : $(EE_BIN)
Expand Down
9 changes: 6 additions & 3 deletions samples/gif/sprite/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ int main()

Gif.SetupEnv(RGBA16, ScreenWidth, ScreenHeight, 2, VMODE_AUTO, FIELD, ENABLE, ScreenX, ScreenY);

u32 x = 0;
Gif.AlphaBlending(0);

while(1)
{
Gif.SetNextDrawbuffer();

Gif.PrimAlphaBlend(false);
Gif.ClearScreen();
Gif.Sprite(RGB(0xFF-x,0xFF-x,0xFF), 64 + x, 64, 128 + x, 128);
Gif.PrimAlphaBlend(true);


x = (x+4) % 255;
Gif.Sprite(RGBA(0,0,0xFF, 0x80), 64, 64, 128, 128);

Gif.Sprite(RGBA(0xFF,0,0, 0x40), 96, 96, 160, 160);

Gif.Send();
}

Expand Down
14 changes: 8 additions & 6 deletions source/GifPipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ void GifPipe::PrimShading(u32 shading)
}
#endif

#ifdef F_PrimAlpaBlend
void PrimAlpaBlend(bool enable)
#ifdef F_PrimAlphaBlend
void GifPipe::PrimAlphaBlend(bool enable)
{


if(enable)
m_PrimMode |= PRIM_ALPHABLEND;
else
m_PrimMode &= ~PRIM_ALPHABLEND;
}
#endif

Expand Down Expand Up @@ -281,7 +283,7 @@ void GifPipe::SetRegister(u64 address, u64 data)
#ifdef F_AlphaBlending2
bool GifPipe::AlphaBlending(u32 mode)
{
uint32 a=0,b=0,c=0,fix=0;
u32 a=0,b=0,c=0,d=0,fix=0;

switch(mode)
{
Expand All @@ -306,7 +308,7 @@ bool GifPipe::AlphaBlending(u32 mode)
c = ALPHA_FIXED;
d = ALPHA_ZERO;
fix = 0x80;
break:
break;

case AlphaBlendLighten:
a = ALPHA_COLOR_DST;
Expand Down
3 changes: 2 additions & 1 deletion source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ GSDRIVER_OBJS := $(GSDRIVER_OBJS:%=$(EE_OBJS_DIR)GsDriver_%)

GIFPIPE_OBJS = Constructor.o Constructor2.o Destructor.o Line4.o Triangle4.o Sprite4.o ClearScreen.o Send.o Finish.o CheckPacket.o
GIFPIPE_OBJS += GifVRHandler.o Point4.o AlphaBlending.o AlphaTest.o ZTest.o SetRegister.o SetTexture.o LoadImageBuffer.o LoadImageFile.o
GIFPIPE_OBJS += UploadTexture.o TextureSprite.o TextureSprite2.o PrimAntialias.o PrimShading.o SetNextDrawBuffer.o
GIFPIPE_OBJS += UploadTexture.o TextureSprite.o TextureSprite2.o PrimAntialias.o PrimShading.o SetNextDrawBuffer.o PrimAlphaBlend.o
GIFPIPE_OBJS += AlphaBlending2.o
GIFPIPE_OBJS := $(GIFPIPE_OBJS:%=$(EE_OBJS_DIR)GifPipe_%)

GS_OBJS = SetBGCOLOR.o SetPMODE.o SetSMODE2.o SetDISPFB1.o SetDISPFB2.o SetDISPLAY1.o SetDISPLAY2.o TextureBufferBase.o
Expand Down

0 comments on commit abbcb40

Please sign in to comment.