Referred to Part 1
- Background color
- Screen resolution
- 2d Poligno
--- type
--- line
--- box
--- Box fill
-propriedes
--- position
--- color
--- plan
This example creates three box with blue background screen with 320 x 240 resolution.
Use the arrows to move around and see the plans.
sintax:
boxfill( x,y,tx,ty,plane,color)
tx - horizintal size
ty - vertical size
plane - position in the layer
use too.
box(x,y,tx,ty,plane,color)
line(x,y,tx,ty,l,p,color)
l =line thickness
You will need three programs.
- main.c
- system.h
- makefile.mak
makefile.mak
Code: Select all
CC = ccpsx
ASM = asmpsx
LINK = psylink
CCOPTIONS = -c -g -comments-c++
ASMOPTIONS = /l /o c+,h+,at- /zd
LINKOPTS = -Xo$80010000 /m
TEST_OBJS = main.obj
all : main.cpe
echo Done.
main.obj: main.c
$(CC) $(CCOPTIONS) main.c -omain.obj
main.cpe: $(TEST_OBJS)
ccpsx -Xo$80010000 $(TEST_OBJS) -omain.cpe,main.sym,main.map -l libtap.lib
cpe2x main.cpe
Code: Select all
//Tamanho da tela
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#include "system.h"
int main(){
backgrond("BLUE");
initGrap();
PadInit(0);
while (1){
CurrentBuffer=GsGetActiveBuff();
GsSetWorkBase((PACKET*)GPUOutputPacket[CurrentBuffer]);
RenderView();
display();
ReadPad();
}
ResetGraph(3);
}
void RenderView()
{
CurrentBuffer=GsGetActiveBuff();
GsSetWorkBase((PACKET*)GPUOutputPacket[CurrentBuffer]);
GsClearOt(0, 0, &OT[CurrentBuffer]);
// BOXFILL
boxfill(140,140,20,20,1,"YELLOW");
boxfill(150+kx1,150+ky1,20,20,2,"GREEN");
boxfill(160,160,20,20,3,"RED");
GsDrawOt(&OT[CurrentBuffer]);
GsSwapDispBuff();
GsSortClear(0,0,0,&OT[CurrentBuffer]);
}
Code: Select all
#include <sys/types.h>
#include <libetc.h>
#include <libgte.h>
#include <libgpu.h>
#include <libgs.h>
#include <libcd.h>
#include <kernel.h>
#include <stdio.h>
#include <libcd.h>
#include <kernel.h>
#include <libspu.h>
#include <libsnd.h>
#include <string.h>
#include <libmath.h>
GsOT OT[2];
GsOT_TAG OrderingTable[2][1<<14];
GsGLINE line2[320],line3[40];
GsBOXF mybox[6];
PACKET GPUOutputPacket[2][240000];
#define PACKETMAX 2000
#define OBJECTMAX 10
#define PACKETMAX2 (PACKETMAX*64)
#define OT_LENGTH 8
u_long padd;
int dd1=0,kob1,kob2;
int x1=50, y1=50,tt=0,kx1=0,ky1=0;
int lx1=0,lx2=0;
int lr0=48,lg0=35,lb0=99;
int lr1=48,lg1=35,lb1=99;
int r=0,g=0,b=0;
int bgr=0,bgg=0,bgb=0;
int CurrentBuffer;
u_long Pad=0;
// system
void initGrap();
void display();
void InitFont();
void RenderView();
// function
void ReadPad();
void linebox(int lx,int ly, int lx1,int ly1,int l,int p, char *cor);
void color(char *cor1);
void boxfill(int x,int y, int w, int h,int p,char *cor);
void box(int x,int y, int w,int h,int b, char *cor);
void backgrond(char *cor);
void backgrond(char *cor)
{
color(cor);
bgr=r; bgg=g;bgb=b;
}
void ReadPad(){
Pad=PadRead(0);
if(Pad&PADLup)ky1--;lr0--;
if(Pad&PADLdown)ky1++;lr0++;
if(Pad&PADLleft) kx1--;lb0--;
if(Pad&PADLright) kx1++;lb0++;
lr1=lr0;lb1=lb0;lg1=lg0;
}
//
void initGrap(){
SetVideoMode(MODE_PAL);
GsInitGraph(SCREEN_WIDTH,SCREEN_HEIGHT,GsINTER|GsOFSGPU,1,0);
GsDefDispBuff(bgr,bgg,bgb,SCREEN_HEIGHT);
OT[0].length=14;
OT[1].length=14;
OT[0].org=OrderingTable[0];
OT[1].org=OrderingTable[1];
GsClearOt(0,0,&OT[0]);
GsClearOt(0,0,&OT[1]);
}
void display(){
CurrentBuffer = GsGetActiveBuff();
VSync (0);
GsSwapDispBuff();
GsSortClear(bgr,bgg,bgb,&OT[CurrentBuffer]);
GsDrawOt(&OT[CurrentBuffer]);
}
void linebox(int lx,int ly, int lx1,int ly1,int l,int p, char *cor){
int i=0;
for (i=0; i<l;i++){
line2[i].x0=lx+i;
line2[i].y0=ly;
line2[i].x1=lx1+i;
line2[i].y1=ly1;
color(cor);
lr0=r;lg0=g;lb0=b;
line2[i].r0=lr0;
line2[i].g0=lg0;
line2[i].b0=lb0;
color(cor);
lr0=r;lg0=g;lb0=b;
line2[i].r1=lr1;
line2[i].g1=lg1;
line2[i].b1=lb1;
GsSortGLine(&line2[i],&OT[CurrentBuffer],p);
DrawSync(0);
}}
void box(int x,int y, int w,int h,int p, char *cor){
int i=0;
color(cor);
line3[i].r0=r; line3[i].g0=g; line3[i].b0=b;
line3[i].r1=r; line3[i].g1=g; line3[i].b1=b;
line3[i].x0=x; line3[i].y0=y; line3[i].x1=w; line3[i].y1=y;
GsSortGLine(&line3[i],&OT[CurrentBuffer],p);
DrawSync(0);
i++;
color(cor);
line3[i].r0=r; line3[i].g0=g; line3[i].b0=b;
line3[i].r1=r; line3[i].g1=g; line3[i].b1=b;
line3[i].x0=w; line3[i].y0=y; line3[i].x1=w; line3[i].y1=h;
GsSortGLine(&line3[i],&OT[CurrentBuffer],p);
DrawSync(0);
i++;
color(cor);
line3[i].r0=r; line3[i].g0=g; line3[i].b0=b;
line3[i].r1=r; line3[i].g1=g; line3[i].b1=b;
line3[i].x0=x; line3[i].y0=h; line3[i].x1=w; line3[i].y1=h;
GsSortGLine(&line3[i],&OT[CurrentBuffer],p);
DrawSync(0);
i++;
color(cor);
line3[i].r0=r; line3[i].g0=g; line3[i].b0=b;
line3[i].r1=r; line3[i].g1=g; line3[i].b1=b;
line3[i].x0=x; line3[i].y0=y; line3[i].x1=x; line3[i].y1=h;
GsSortGLine(&line3[i],&OT[CurrentBuffer],p);
DrawSync(0);
}
// boxfill
void boxfill(int x,int y, int w, int h,int p,char *cor){
mybox[p].x=x;
mybox[p].y=y;
mybox[p].w=w;
mybox[p].h=h;
color(cor);
mybox[p].r=r;mybox[p].g=g;mybox[p].b=b;
GsSortBoxFill(&mybox[p],&OT[CurrentBuffer],p);
DrawSync(0);
}
// color
void color(char *cor1){
if (cor1=="BLUE") {r=0;g=0;b=255;}
if (cor1=="YELLOW") {r=255;g=255;b=0;}
if (cor1=="GREEN") {r=0;g=255;b=0;}
if (cor1=="RED") {r=255;g=0;b=0;}
if (cor1=="PINK") {r=255;g=192;b=203;}
if (cor1=="BLACK") {r=0;g=0;b=0;}
if (cor1=="WHITE") {r=255;g=255;b=255;}
if (cor1=="GRAY") {r=55;g=30;b=0;}
if (cor1=="CINZA2") {r=90;g=50;b=0;}
// http://www.mxstudio.com.br/Conteudos/Dreamweaver/Cores.htm
// PUT MORE COLORS
}
compile with:
del *.obj
psymake
---------------
TO YOU DO
- CREATE AN OBJECT TRIANGLE?
- CREATE A PROGRAM TO DRAW THE WORD SDK
BIG WELL IN RESOLUTION 640X480.
POST A PRINT SCREEN.
--------------------------------------------------------------------
LIKED THEN ...
POST A ... LIKE.
--------------------------------------------------------------------
EXPECTED FOR
PART 2
- GRAPHIC TEXT
- OBJECTS
- TEXTURE
- AND SCREEN