diff options
| author | John Wilbert M. Villamor <lameguy64@gmail.com> | 2020-01-06 09:39:20 +0800 |
|---|---|---|
| committer | John Wilbert M. Villamor <lameguy64@gmail.com> | 2020-01-06 09:39:20 +0800 |
| commit | c98ad0e7dbc48c928aaea0f78214c7ed6556417d (patch) | |
| tree | bcbafb8547eceb867f342bfe504377e13a5533a9 /examples | |
| parent | 87ded2ccb9db9bf3b2ed40a0b02b663179d5868f (diff) | |
| download | psn00bsdk-c98ad0e7dbc48c928aaea0f78214c7ed6556417d.tar.gz | |
Some minor updates, added CD-ROM library documentation
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/hello/main.c | 85 | ||||
| -rw-r--r-- | examples/hello/makefile | 39 | ||||
| -rw-r--r-- | examples/render2tex/textures.tpj | 6 |
3 files changed, 124 insertions, 6 deletions
diff --git a/examples/hello/main.c b/examples/hello/main.c new file mode 100644 index 0000000..6cd03f9 --- /dev/null +++ b/examples/hello/main.c @@ -0,0 +1,85 @@ +#include <stdio.h> +#include <psxgpu.h> +#include <psxgte.h> +#include <psxetc.h> + +#define PAL + +#ifdef PAL + +#define SCREEN_XRES 320 +#define SCREEN_YRES 256 + +#else + +#define SCREEN_XRES 320 +#define SCREEN_YRES 240 + +#endif + +typedef struct DB +{ + DISPENV disp; + DRAWENV draw; +} DB; + +DB db[2]; +int db_active; + +void init(void) +{ + ResetGraph(0); + + SetDefDispEnv(&db[0].disp, 0, 0, SCREEN_XRES, SCREEN_YRES); + SetDefDispEnv(&db[1].disp, 0, SCREEN_YRES, SCREEN_XRES, SCREEN_YRES); + + SetDefDrawEnv(&db[0].draw, 0, SCREEN_YRES, SCREEN_XRES, SCREEN_YRES); + SetDefDrawEnv(&db[1].draw, 0, 0, SCREEN_XRES, SCREEN_YRES); + + db[0].draw.isbg = 1; + setRGB0(&db[0].draw, 63, 0, 127); + db[1].draw.isbg = 1; + setRGB0(&db[1].draw, 63, 0, 127); + +#ifdef PAL + SetVideoMode(MODE_PAL); + db[0].disp.screen.y = 18; + db[1].disp.screen.y = 18; + db[0].disp.screen.h = 256; + db[1].disp.screen.h = 256; +#endif + + PutDispEnv(&db[0].disp); + PutDrawEnv(&db[0].draw); + db_active = 0; + + FntLoad(960, 0); + FntOpen(0, 8, SCREEN_XRES, SCREEN_YRES-16, 0, 100); +} + +void display(void) +{ + FntFlush(-1); + DrawSync(0); + VSync(0); + + db_active = !db_active; + PutDispEnv(&db[db_active].disp); + PutDrawEnv(&db[db_active].draw); + SetDispMask(1); +} + +int main(int argc, const char *argv[]) +{ + int count = 0; + + init(); + + while(1) + { + FntPrint(-1, "HELLO WORLD\n"); + FntPrint(-1, "COUNTER=%d\n", count); + display(); + count++; + } +}
\ No newline at end of file diff --git a/examples/hello/makefile b/examples/hello/makefile new file mode 100644 index 0000000..3350b85 --- /dev/null +++ b/examples/hello/makefile @@ -0,0 +1,39 @@ +include ../sdk-common.mk + +TARGET = hello.elf + +CFILES = $(notdir $(wildcard *.c)) +CPPFILES = $(notdir $(wildcard *.cpp)) +AFILES = $(notdir $(wildcard *.s)) + +OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)) + +INCLUDE += +LIBDIRS += + +LIBS = -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxapi -lc + +CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections +CPPFLAGS = $(CFLAGS) -fno-exceptions +AFLAGS = -g -msoft-float +LDFLAGS = -g -Ttext=0x80010000 -gc-sections -T $(GCC_BASE)/mipsel-unknown-elf/lib/ldscripts/elf32elmip.x + +CC = $(PREFIX)gcc +CXX = $(PREFIX)g++ +AS = $(PREFIX)as +LD = $(PREFIX)ld + +all: $(OFILES) + $(LD) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(LIBS) -o $(TARGET) + elf2x -q $(TARGET) + +build/%.o: %.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +build/%.o: %.s + @mkdir -p $(dir $@) + $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@ + +clean: + rm -rf build $(TARGET) $(TARGET:.elf=.exe) diff --git a/examples/render2tex/textures.tpj b/examples/render2tex/textures.tpj deleted file mode 100644 index b34d4fd..0000000 --- a/examples/render2tex/textures.tpj +++ /dev/null @@ -1,6 +0,0 @@ -<tim_project> - <properties buffer_res="2" buffer_order="4"/> - <tim_group name="global"> - <tim>C:\Users\Lameguy64\Desktop\Projects\psn00bsdk\examples\render2tex\blendpattern-16c.tim</tim> - </tim_group> -</tim_project> |
