version 1.5

main v1.5.0
Nichole Mattera 2 years ago
parent 6a2f610e67
commit 243f523f0e
  1. 13075
      Image.c
  2. 8
      Makefile
  3. 377
      font.c
  4. 4
      framebuffer.c
  5. 8
      framebuffer.h
  6. 493
      graphics.c
  7. 296
      graphics.h
  8. 315
      main.c
  9. 211
      pg.c
  10. 20
      pg.h

13075
Image.c

File diff suppressed because it is too large Load Diff

@ -1,13 +1,17 @@
TARGET = flashmod
OBJS = main.o
OBJS = main.o graphics.o framebuffer.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpng -lz -lm
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_ICON = ICON0.png
PSP_EBOOT_TITLE = FlashMod Version 1.0
PSP_EBOOT_TITLE = FlashMod Version 1.5
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

377
font.c

@ -0,0 +1,377 @@
// font for Hello World PSP
const unsigned char font[]={
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
// ;20 !"#$%&'()*+,-./
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// ;21 !
0x38,0x38,0x38,0x30,0x00,0x30,0x30,0x00,
// ;22 "
0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,
// ;23 #
0x48,0xFE,0x48,0x48,0xFE,0x48,0x48,0x00,
// ;24 $
0x7C,0xAA,0xA8,0x7C,0x2A,0xAA,0x7C,0x00,
// ;25 %
0xC2,0xC4,0x08,0x10,0x20,0x46,0x86,0x00,
// ;26 &
0x38,0x44,0x48,0x30,0x4A,0x84,0x7A,0x00,
// ;27 '
0x18,0x18,0x10,0x00,0x00,0x00,0x00,0x00,
// ;28 (
0x18,0x20,0x20,0x20,0x20,0x20,0x18,0x00,
// ;29 )
0x60,0x10,0x10,0x10,0x10,0x10,0x60,0x00,
// ;2a *
0x92,0x92,0x54,0x38,0x54,0x92,0x92,0x00,
// ;2b +
0x30,0x30,0x30,0xFC,0x30,0x30,0x30,0x00,
// ;2c ,
0x00,0x00,0x00,0x00,0x00,0x18,0x08,0x10,
// ;2d -
0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,
// ;2e .
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,
// ;2f
0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,
// ;30 0123456789:;<=>?
0x7C,0xC6,0xCE,0xD6,0xE6,0xC6,0x7C,0x00,
//
0x18,0x38,0x18,0x18,0x18,0x18,0x18,0x00,
//
0x7C,0xC6,0x06,0x0C,0x30,0xC0,0xFE,0x00,
//
0x7C,0xC6,0x06,0x1C,0x06,0xC6,0x7C,0x00,
//
0x0C,0x1C,0x2C,0x4C,0xCC,0xFE,0x0C,0x00,
//
0xFE,0xC0,0xFC,0xC6,0x06,0xC6,0x7C,0x00,
//
0x7C,0xC6,0xC0,0xFC,0xC6,0xC6,0x7C,0x00,
//
0xFE,0x06,0x06,0x0C,0x18,0x30,0x30,0x00,
//
0x7C,0xC6,0xC6,0x7C,0xC6,0xC6,0x7C,0x00,
//
0x7C,0xC6,0xC6,0x7E,0x06,0xC6,0x7C,0x00,
// ;3a :
0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00,
// ;3b ;
0x00,0x18,0x18,0x00,0x00,0x18,0x08,0x10,
// ;3c <
0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00,
// ;3d =
0x00,0x00,0xFE,0x00,0xFE,0x00,0x00,0x00,
// ;3e >
0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x00,
// ;3f ?
0x3C,0x42,0x02,0x0C,0x18,0x00,0x18,0x00,
// ;40 @ABCDEFGHIJKLMNO
0x7C,0x82,0xB2,0xAA,0xBC,0x80,0x7E,0x00,
//
0x3C,0x62,0xC2,0xFE,0xC2,0xC2,0xC2,0x00,
//
0xFC,0xC2,0xC2,0xFC,0xC2,0xC2,0xFC,0x00,
//
0x7C,0xC2,0xC0,0xC0,0xC0,0xC2,0x7C,0x00,
//
0xF8,0xC4,0xC2,0xC2,0xC2,0xC4,0xF8,0x00,
//
0xFE,0xC0,0xC0,0xFC,0xC0,0xC0,0xFE,0x00,
//
0xFE,0xC0,0xC0,0xFC,0xC0,0xC0,0xC0,0x00,
//
0x7C,0xC0,0xC0,0xCE,0xC2,0xC2,0x7C,0x00,
//
0xC2,0xC2,0xC2,0xFE,0xC2,0xC2,0xC2,0x00,
//
0xFC,0x30,0x30,0x30,0x30,0x30,0xFC,0x00,
//
0x1E,0x0C,0x0C,0x0C,0x0C,0x8C,0x78,0x00,
//
0xC2,0xC4,0xC8,0xD0,0xE8,0xC4,0xC2,0x00,
//
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFE,0x00,
//
0xC2,0xE6,0xDA,0xDA,0xC2,0xC2,0xC2,0x00,
//
0xC2,0xE2,0xD2,0xCA,0xC6,0xC2,0xC2,0x00,
//
0x7C,0xC2,0xC2,0xC2,0xC2,0xC2,0x7C,0x00,
// ;50 PQRSTUVWXYZ[\]^_
0xFC,0xC2,0xC2,0xFC,0xC0,0xC0,0xC0,0x00,
//
0x7C,0xC2,0xC2,0xC2,0xCA,0xC4,0x7A,0x00,
//
0xFC,0xC2,0xC2,0xFC,0xC8,0xC4,0xC2,0x00,
//
0x7C,0xC2,0xC0,0x3C,0x02,0xC2,0x7C,0x00,
//
0xFE,0x38,0x38,0x38,0x38,0x38,0x38,0x00,
//
0xC2,0xC2,0xC2,0xC2,0xC2,0xC2,0x7C,0x00,
//
0xC2,0xC2,0xC2,0xC2,0xC4,0xC8,0x70,0x00,
//
0xC2,0xC2,0xC2,0xD2,0xD2,0xEA,0xC4,0x00,
//
0x86,0x86,0x4C,0x38,0x64,0xC2,0xC2,0x00,
//
0xC2,0xC2,0xC4,0x78,0x30,0x30,0x30,0x00,
//
0xFE,0x06,0x0C,0x18,0x30,0x60,0xFE,0x00,
// ;5B [\]^_
0x78,0x60,0x60,0x60,0x60,0x60,0x78,0x00,
// ;5C \
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x00,
// ;5D ]
0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00,
// ;5E ^
0x18,0x24,0x00,0x00,0x00,0x00,0x00,0x00,
// ;5F _
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,
//60..
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
//
0x7C,0x82,0xB2,0xAA,0xBC,0x80,0x7E,0x00,
//
0x3C,0x62,0xC2,0xFE,0xC2,0xC2,0xC2,0x00,
//
0xFC,0xC2,0xC2,0xFC,0xC2,0xC2,0xFC,0x00,
//
0x7C,0xC2,0xC0,0xC0,0xC0,0xC2,0x7C,0x00,
//
0xF8,0xC4,0xC2,0xC2,0xC2,0xC4,0xF8,0x00,
//
0xFE,0xC0,0xC0,0xFC,0xC0,0xC0,0xFE,0x00,
//
0xFE,0xC0,0xC0,0xFC,0xC0,0xC0,0xC0,0x00,
//
0x7C,0xC0,0xC0,0xCE,0xC2,0xC2,0x7C,0x00,
//
0xC2,0xC2,0xC2,0xFE,0xC2,0xC2,0xC2,0x00,
//
0xFC,0x30,0x30,0x30,0x30,0x30,0xFC,0x00,
//
0x1E,0x0C,0x0C,0x0C,0x0C,0x8C,0x78,0x00,
//
0xC2,0xC4,0xC8,0xD0,0xE8,0xC4,0xC2,0x00,
//
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFE,0x00,
//
0xC2,0xE6,0xDA,0xDA,0xC2,0xC2,0xC2,0x00,
//
0xC2,0xE2,0xD2,0xCA,0xC6,0xC2,0xC2,0x00,
//
0x7C,0xC2,0xC2,0xC2,0xC2,0xC2,0x7C,0x00,
// ;50 PQRSTUVWXYZ[\]^_
0xFC,0xC2,0xC2,0xFC,0xC0,0xC0,0xC0,0x00,
//
0x7C,0xC2,0xC2,0xC2,0xCA,0xC4,0x7A,0x00,
//
0xFC,0xC2,0xC2,0xFC,0xC8,0xC4,0xC2,0x00,
//
0x7C,0xC2,0xC0,0x3C,0x02,0xC2,0x7C,0x00,
//
0xFE,0x38,0x38,0x38,0x38,0x38,0x38,0x00,
//
0xC2,0xC2,0xC2,0xC2,0xC2,0xC2,0x7C,0x00,
//
0xC2,0xC2,0xC2,0xC2,0xC4,0xC8,0x70,0x00,
//
0xC2,0xC2,0xC2,0xD2,0xD2,0xEA,0xC4,0x00,
//
0x86,0x86,0x4C,0x38,0x64,0xC2,0xC2,0x00,
//
0xC2,0xC2,0xC4,0x78,0x30,0x30,0x30,0x00,
//
0xFE,0x06,0x0C,0x18,0x30,0x60,0xFE,0x00,
//7b
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
0xCC,0xCC,0x33,0x33,0xCC,0xCC,0x33,0x33,
};

@ -0,0 +1,4 @@
#include <psptypes.h>
#include "graphics.h"
Color* g_vram_base = (Color*) (0x40000000 | 0x04000000);

@ -0,0 +1,8 @@
#ifndef FRAMEBUFFER_H
#define FRAMEBUFFER_H
#include <psptypes.h>
extern u32* g_vram_base;
#endif

@ -0,0 +1,493 @@
#include <stdlib.h>
#include <malloc.h>
#include <pspdisplay.h>
#include <psputils.h>
#include <png.h>
#include <pspgu.h>
#include "graphics.h"
#include "framebuffer.h"
#define IS_ALPHA(color) (((color)&0xff000000)==0xff000000?0:1)
#define FRAMEBUFFER_SIZE (PSP_LINE_SIZE*SCREEN_HEIGHT*4)
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
typedef struct
{
unsigned short u, v;
short x, y, z;
} Vertex;
extern u8 msx[];
unsigned int __attribute__((aligned(16))) list[262144];
static int dispBufferNumber;
static int initialized = 0;
static int getNextPower2(int width)
{
int b = width;
int n;
for (n = 0; b != 0; n++) b >>= 1;
b = 1 << n;
if (b == 2 * width) b >>= 1;
return b;
}
Color* getVramDrawBuffer()
{
Color* vram = (Color*) g_vram_base;
if (dispBufferNumber == 0) vram += FRAMEBUFFER_SIZE / sizeof(Color);
return vram;
}
Color* getVramDisplayBuffer()
{
Color* vram = (Color*) g_vram_base;
if (dispBufferNumber == 1) vram += FRAMEBUFFER_SIZE / sizeof(Color);
return vram;
}
void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
{
}
Image* loadImage(const char* filename)
{
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type, x, y;
u32* line;
FILE *fp;
Image* image = (Image*) malloc(sizeof(Image));
if (!image) return NULL;
if ((fp = fopen(filename, "rb")) == NULL) return NULL;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) {
free(image);
fclose(fp);
return NULL;;
}
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, user_warning_fn);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return NULL;
}
png_init_io(png_ptr, fp);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL);
if (width > 512 || height > 512) {
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return NULL;
}
image->imageWidth = width;
image->imageHeight = height;
image->textureWidth = getNextPower2(width);
image->textureHeight = getNextPower2(height);
png_set_strip_16(png_ptr);
png_set_packing(png_ptr);
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
image->data = (Color*) memalign(16, image->textureWidth * image->textureHeight * sizeof(Color));
if (!image->data) {
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return NULL;
}
line = (u32*) malloc(width * 4);
if (!line) {
free(image->data);
free(image);
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return NULL;
}
for (y = 0; y < height; y++) {
png_read_row(png_ptr, (u8*) line, png_bytep_NULL);
for (x = 0; x < width; x++) {
u32 color = line[x];
image->data[x + y * image->textureWidth] = color;
}
}
free(line);
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
return image;
}
void blitImageToImage(int sx, int sy, int width, int height, Image* source, int dx, int dy, Image* destination)
{
Color* destinationData = &destination->data[destination->textureWidth * dy + dx];
int destinationSkipX = destination->textureWidth - width;
Color* sourceData = &source->data[source->textureWidth * sy + sx];
int sourceSkipX = source->textureWidth - width;
int x, y;
for (y = 0; y < height; y++, destinationData += destinationSkipX, sourceData += sourceSkipX) {
for (x = 0; x < width; x++, destinationData++, sourceData++) {
*destinationData = *sourceData;
}
}
}
void blitImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy)
{
if (!initialized) return;
Color* vram = getVramDrawBuffer();
sceKernelDcacheWritebackInvalidateAll();
guStart();
sceGuCopyImage(GU_PSM_8888, sx, sy, width, height, source->textureWidth, source->data, dx, dy, PSP_LINE_SIZE, vram);
sceGuFinish();
sceGuSync(0,0);
}
void blitAlphaImageToImage(int sx, int sy, int width, int height, Image* source, int dx, int dy, Image* destination)
{
// TODO Blend!
Color* destinationData = &destination->data[destination->textureWidth * dy + dx];
int destinationSkipX = destination->textureWidth - width;
Color* sourceData = &source->data[source->textureWidth * sy + sx];
int sourceSkipX = source->textureWidth - width;
int x, y;
for (y = 0; y < height; y++, destinationData += destinationSkipX, sourceData += sourceSkipX) {
for (x = 0; x < width; x++, destinationData++, sourceData++) {
Color color = *sourceData;
if (!IS_ALPHA(color)) *destinationData = color;
}
}
}
void blitAlphaImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy)
{
if (!initialized) return;
sceKernelDcacheWritebackInvalidateAll();
guStart();
sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
float u = 1.0f / ((float)source->textureWidth);
float v = 1.0f / ((float)source->textureHeight);
sceGuTexScale(u, v);
int j = 0;
while (j < width) {
Vertex* vertices = (Vertex*) sceGuGetMemory(2 * sizeof(Vertex));
int sliceWidth = 64;
if (j + sliceWidth > width) sliceWidth = width - j;
vertices[0].u = sx + j;
vertices[0].v = sy;
vertices[0].x = dx + j;
vertices[0].y = dy;
vertices[0].z = 0;
vertices[1].u = sx + j + sliceWidth;
vertices[1].v = sy + height;
vertices[1].x = dx + j + sliceWidth;
vertices[1].y = dy + height;
vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
j += sliceWidth;
}
sceGuFinish();
sceGuSync(0, 0);
}
Image* createImage(int width, int height)
{
Image* image = (Image*) malloc(sizeof(Image));
if (!image) return NULL;
image->imageWidth = width;
image->imageHeight = height;
image->textureWidth = getNextPower2(width);
image->textureHeight = getNextPower2(height);
image->data = (Color*) memalign(16, image->textureWidth * image->textureHeight * sizeof(Color));
if (!image->data) return NULL;
memset(image->data, 0, image->textureWidth * image->textureHeight * sizeof(Color));
return image;
}
void freeImage(Image* image)
{
free(image->data);
free(image);
}
void clearImage(Color color, Image* image)
{
int i;
int size = image->textureWidth * image->textureHeight;
Color* data = image->data;
for (i = 0; i < size; i++, data++) *data = color;
}
void clearScreen(Color color)
{
if (!initialized) return;
guStart();
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGuFinish();
sceGuSync(0, 0);
}
void fillImageRect(Color color, int x0, int y0, int width, int height, Image* image)
{
int skipX = image->textureWidth - width;
int x, y;
Color* data = image->data + x0 + y0 * image->textureWidth;
for (y = 0; y < height; y++, data += skipX) {
for (x = 0; x < width; x++, data++) *data = color;
}
}
void fillScreenRect(Color color, int x0, int y0, int width, int height)
{
if (!initialized) return;
int skipX = PSP_LINE_SIZE - width;
int x, y;
Color* data = getVramDrawBuffer() + x0 + y0 * PSP_LINE_SIZE;
for (y = 0; y < height; y++, data += skipX) {
for (x = 0; x < width; x++, data++) *data = color;
}
}
void putPixelScreen(Color color, int x, int y)
{
Color* vram = getVramDrawBuffer();
vram[PSP_LINE_SIZE * y + x] = color;
}
void putPixelImage(Color color, int x, int y, Image* image)
{
image->data[x + y * image->textureWidth] = color;
}
Color getPixelScreen(int x, int y)
{
Color* vram = getVramDrawBuffer();
return vram[PSP_LINE_SIZE * y + x];
}
Color getPixelImage(int x, int y, Image* image)
{
return image->data[x + y * image->textureWidth];
}
void printTextScreen(int x, int y, const char* text, u32 color)
{
int c, i, j, l;
u8 *font;
Color *vram_ptr;
Color *vram;
if (!initialized) return;
for (c = 0; c < strlen(text); c++) {
if (x < 0 || x + 8 > SCREEN_WIDTH || y < 0 || y + 8 > SCREEN_HEIGHT) break;
char ch = text[c];
vram = getVramDrawBuffer() + x + y * PSP_LINE_SIZE;
font = &msx[ (int)ch * 8];
for (i = l = 0; i < 8; i++, l += 8, font++) {
vram_ptr = vram;
for (j = 0; j < 8; j++) {
if ((*font & (128 >> j))) *vram_ptr = color;
vram_ptr++;
}
vram += PSP_LINE_SIZE;
}
x += 8;
}
}
void printTextImage(int x, int y, const char* text, u32 color, Image* image)
{
int c, i, j, l;
u8 *font;
Color *data_ptr;
Color *data;
if (!initialized) return;
for (c = 0; c < strlen(text); c++) {
if (x < 0 || x + 8 > image->imageWidth || y < 0 || y + 8 > image->imageHeight) break;
char ch = text[c];
data = image->data + x + y * image->textureWidth;
font = &msx[ (int)ch * 8];
for (i = l = 0; i < 8; i++, l += 8, font++) {
data_ptr = data;
for (j = 0; j < 8; j++) {
if ((*font & (128 >> j))) *data_ptr = color;
data_ptr++;
}
data += image->textureWidth;
}
x += 8;
}
}
void saveImage(const char* filename, Color* data, int width, int height, int lineSize, int saveAlpha)
{
png_structp png_ptr;
png_infop info_ptr;
FILE* fp;
int i, x, y;
u8* line;
if ((fp = fopen(filename, "wb")) == NULL) return;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) return;
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return;
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, width, height, 8,
saveAlpha ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr, info_ptr);
line = (u8*) malloc(width * (saveAlpha ? 4 : 3));
for (y = 0; y < height; y++) {
for (i = 0, x = 0; x < width; x++) {
Color color = data[x + y * lineSize];
u8 r = color & 0xff;
u8 g = (color >> 8) & 0xff;
u8 b = (color >> 16) & 0xff;
u8 a = saveAlpha ? (color >> 24) & 0xff : 0xff;
line[i++] = r;
line[i++] = g;
line[i++] = b;
if (saveAlpha) line[i++] = a;
}
png_write_row(png_ptr, line);
}
free(line);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fclose(fp);
}
void flipScreen()
{
if (!initialized) return;
sceGuSwapBuffers();
dispBufferNumber ^= 1;
}
static void drawLine(int x0, int y0, int x1, int y1, int color, Color* destination, int width)
{
int dy = y1 - y0;
int dx = x1 - x0;
int stepx, stepy;
if (dy < 0) { dy = -dy; stepy = -width; } else { stepy = width; }
if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
dy <<= 1;
dx <<= 1;
y0 *= width;
y1 *= width;
destination[x0+y0] = color;
if (dx > dy) {
int fraction = dy - (dx >> 1);
while (x0 != x1) {
if (fraction >= 0) {
y0 += stepy;
fraction -= dx;
}
x0 += stepx;
fraction += dy;
destination[x0+y0] = color;
}
} else {
int fraction = dx - (dy >> 1);
while (y0 != y1) {
if (fraction >= 0) {
x0 += stepx;
fraction -= dy;
}
y0 += stepy;
fraction += dx;
destination[x0+y0] = color;
}
}
}
void drawLineScreen(int x0, int y0, int x1, int y1, Color color)
{
drawLine(x0, y0, x1, y1, color, getVramDrawBuffer(), PSP_LINE_SIZE);
}
void drawLineImage(int x0, int y0, int x1, int y1, Color color, Image* image)
{
drawLine(x0, y0, x1, y1, color, image->data, image->textureWidth);
}
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define PIXEL_SIZE (4) /* change this if you change to another screenmode */
#define FRAME_SIZE (BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE)
#define ZBUF_SIZE (BUF_WIDTH SCR_HEIGHT * 2) /* zbuffer seems to be 16-bit? */
void initGraphics()
{
dispBufferNumber = 0;
sceGuInit();
guStart();
sceGuDrawBuffer(GU_PSM_8888, (void*)FRAMEBUFFER_SIZE, PSP_LINE_SIZE);
sceGuDispBuffer(SCREEN_WIDTH, SCREEN_HEIGHT, (void*)0, PSP_LINE_SIZE);
sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
sceGuDepthBuffer((void*) (FRAMEBUFFER_SIZE*2), PSP_LINE_SIZE);
sceGuOffset(2048 - (SCREEN_WIDTH / 2), 2048 - (SCREEN_HEIGHT / 2));
sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuDepthRange(0xc350, 0x2710);
sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuEnable(GU_SCISSOR_TEST);
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
sceGuEnable(GU_ALPHA_TEST);
sceGuDepthFunc(GU_GEQUAL);
sceGuEnable(GU_DEPTH_TEST);
sceGuFrontFace(GU_CW);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_CULL_FACE);
sceGuEnable(GU_TEXTURE_2D);
sceGuEnable(GU_CLIP_PLANES);
sceGuTexMode(GU_PSM_8888, 0, 0, 0);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuAmbientColor(0xffffffff);
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuFinish();
sceGuSync(0, 0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
initialized = 1;
}
void disableGraphics()
{
initialized = 0;
}
void guStart()
{
sceGuStart(GU_DIRECT, list);
}

@ -0,0 +1,296 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <psptypes.h>
#define PSP_LINE_SIZE 512
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 272
typedef u32 Color;
#define A(color) ((u8)(color >> 24 & 0xFF))
#define B(color) ((u8)(color >> 16 & 0xFF))
#define G(color) ((u8)(color >> 8 & 0xFF))
#define R(color) ((u8)(color & 0xFF))
typedef struct
{
int textureWidth; // the real width of data, 2^n with n>=0
int textureHeight; // the real height of data, 2^n with n>=0
int imageWidth; // the image width
int imageHeight;
Color* data;
} Image;
/**
* Load a PNG image.
*
* @pre filename != NULL
* @param filename - filename of the PNG image to load
* @return pointer to a new allocated Image struct, or NULL on failure
*/
extern Image* loadImage(const char* filename);
/**
* Blit a rectangle part of an image to another image.
*
* @pre source != NULL && destination != NULL &&
* sx >= 0 && sy >= 0 &&
* width > 0 && height > 0 &&
* sx + width <= source->width && sy + height <= source->height &&
* dx + width <= destination->width && dy + height <= destination->height
* @param sx - left position of rectangle in source image
* @param sy - top position of rectangle in source image
* @param width - width of rectangle in source image
* @param height - height of rectangle in source image
* @param source - pointer to Image struct of the source image
* @param dx - left target position in destination image
* @param dy - top target position in destination image
* @param destination - pointer to Image struct of the destination image
*/
extern void blitImageToImage(int sx, int sy, int width, int height, Image* source, int dx, int dy, Image* destination);
/**
* Blit a rectangle part of an image to screen.
*
* @pre source != NULL && destination != NULL &&
* sx >= 0 && sy >= 0 &&
* width > 0 && height > 0 &&
* sx + width <= source->width && sy + height <= source->height &&
* dx + width <= SCREEN_WIDTH && dy + height <= SCREEN_HEIGHT
* @param sx - left position of rectangle in source image
* @param sy - top position of rectangle in source image
* @param width - width of rectangle in source image
* @param height - height of rectangle in source image
* @param source - pointer to Image struct of the source image
* @param dx - left target position in destination image
* @param dy - top target position in destination image
*/
extern void blitImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy);
/**
* Blit a rectangle part of an image to another image without alpha pixels in source image.
*
* @pre source != NULL && destination != NULL &&
* sx >= 0 && sy >= 0 &&
* width > 0 && height > 0 &&
* sx + width <= source->width && sy + height <= source->height &&
* dx + width <= destination->width && dy + height <= destination->height
* @param sx - left position of rectangle in source image
* @param sy - top position of rectangle in source image
* @param width - width of rectangle in source image
* @param height - height of rectangle in source image
* @param source - pointer to Image struct of the source image
* @param dx - left target position in destination image
* @param dy - top target position in destination image
* @param destination - pointer to Image struct of the destination image
*/
extern void blitAlphaImageToImage(int sx, int sy, int width, int height, Image* source, int dx, int dy, Image* destination);
/**
* Blit a rectangle part of an image to screen without alpha pixels in source image.
*
* @pre source != NULL && destination != NULL &&
* sx >= 0 && sy >= 0 &&
* width > 0 && height > 0 &&
* sx + width <= source->width && sy + height <= source->height &&
* dx + width <= SCREEN_WIDTH && dy + height <= SCREEN_HEIGHT
* @param sx - left position of rectangle in source image
* @param sy - top position of rectangle in source image
* @param width - width of rectangle in source image
* @param height - height of rectangle in source image
* @param source - pointer to Image struct of the source image
* @param dx - left target position in destination image
* @param dy - top target position in destination image
*/
extern void blitAlphaImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy);
/**
* Create an empty image.
*
* @pre width > 0 && height > 0 && width <= 512 && height <= 512
* @param width - width of the new image
* @param height - height of the new image
* @return pointer to a new allocated Image struct, all pixels initialized to color 0, or NULL on failure
*/
extern Image* createImage(int width, int height);
/**
* Frees an allocated image.
*
* @pre image != null
* @param image a pointer to an image struct
*/
extern void freeImage(Image* image);
/**
* Initialize all pixels of an image with a color.
*
* @pre image != NULL
* @param color - new color for the pixels
* @param image - image to clear
*/
extern void clearImage(Color color, Image* image);
/**
* Initialize all pixels of the screen with a color.
*
* @param color - new color for the pixels
*/
extern void clearScreen(Color color);
/**
* Fill a rectangle of an image with a color.
*
* @pre image != NULL
* @param color - new color for the pixels
* @param x0 - left position of rectangle in image
* @param y0 - top position of rectangle in image
* @param width - width of rectangle in image
* @param height - height of rectangle in image
* @param image - image
*/
extern void fillImageRect(Color color, int x0, int y0, int width, int height, Image* image);
/**
* Fill a rectangle of an image with a color.
*
* @pre image != NULL
* @param color - new color for the pixels
* @param x0 - left position of rectangle in image
* @param y0 - top position of rectangle in image
* @param width - width of rectangle in image
* @param height - height of rectangle in image
*/
extern void fillScreenRect(Color color, int x0, int y0, int width, int height);
/**
* Set a pixel on screen to the specified color.
*
* @pre x >= 0 && x < SCREEN_WIDTH && y >= 0 && y < SCREEN_HEIGHT
* @param color - new color for the pixels
* @param x - left position of the pixel
* @param y - top position of the pixel
*/
extern void putPixelScreen(Color color, int x, int y);
/**
* Set a pixel in an image to the specified color.
*
* @pre x >= 0 && x < image->imageWidth && y >= 0 && y < image->imageHeight && image != NULL
* @param color - new color for the pixels
* @param x - left position of the pixel
* @param y - top position of the pixel
*/
extern void putPixelImage(Color color, int x, int y, Image* image);
/**
* Get the color of a pixel on screen.
*
* @pre x >= 0 && x < SCREEN_WIDTH && y >= 0 && y < SCREEN_HEIGHT
* @param x - left position of the pixel
* @param y - top position of the pixel
* @return the color of the pixel
*/
extern Color getPixelScreen(int x, int y);
/**
* Get the color of a pixel of an image.
*
* @pre x >= 0 && x < image->imageWidth && y >= 0 && y < image->imageHeight && image != NULL
* @param x - left position of the pixel
* @param y - top position of the pixel
* @return the color of the pixel
*/
extern Color getPixelImage(int x, int y, Image* image);
/**
* Print a text (pixels out of the screen or image are clipped).
*
* @param x - left position of text
* @param y - top position of text
* @param text - the text to print
* @param color - new color for the pixels
*/
extern void printTextScreen(int x, int y, const char* text, u32 color);
/**
* Print a text (pixels out of the screen or image are clipped).
*
* @param x - left position of text
* @param y - top position of text
* @param text - the text to print
* @param color - new color for the pixels
* @param image - image
*/
extern void printTextImage(int x, int y, const char* text, u32 color, Image* image);
/**
* Save an image or the screen in PNG format.
*
* @pre filename != NULL
* @param filename - filename of the PNG image
* @param data - start of Color type pixel data (can be getVramDisplayBuffer())
* @param width - logical width of the image or SCREEN_WIDTH
* @param height - height of the image or SCREEN_HEIGHT
* @param lineSize - physical width of the image or PSP_LINE_SIZE
* @param saveAlpha - if 0, image is saved without alpha channel
*/
extern void saveImage(const char* filename, Color* data, int width, int height, int lineSize, int saveAlpha);
/**
* Exchange display buffer and drawing buffer.
*/
extern void flipScreen();
/**
* Initialize the graphics.
*/
extern void initGraphics();
/**
* Disable graphics, used for debug text output.
*/
extern void disableGraphics();
/**
* Draw a line to screen.
*
* @pre x0 >= 0 && x0 < SCREEN_WIDTH && y0 >= 0 && y0 < SCREEN_HEIGHT &&
* x1 >= 0 && x1 < SCREEN_WIDTH && y1 >= 0 && y1 < SCREEN_HEIGHT
* @param x0 - x line start position
* @param y0 - y line start position
* @param x1 - x line end position
* @param y1 - y line end position
*/
void drawLineScreen(int x0, int y0, int x1, int y1, Color color);
/**
* Draw a line to screen.
*
* @pre x0 >= 0 && x0 < image->imageWidth && y0 >= 0 && y0 < image->imageHeight &&
* x1 >= 0 && x1 < image->imageWidth && y1 >= 0 && y1 < image->imageHeight
* @param x0 - x line start position
* @param y0 - y line start position
* @param x1 - x line end position
* @param y1 - y line end position
*/
extern void drawLineImage(int x0, int y0, int x1, int y1, Color color, Image* image);
/**
* Get the current draw buffer for fast unchecked access.
*
* @return the start address of the current draw buffer
*/
extern Color* getVramDrawBuffer();
/**
* Get the current display buffer for fast unchecked access.
*
* @return the start address of the current display buffer
*/
extern Color* getVramDisplayBuffer();
extern void guStart();
#endif

315
main.c

@ -3,14 +3,17 @@
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspiofilemgr.h>
#include <pspgu.h>
#include <png.h>
#include <stdlib.h>
#include <string.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
PSP_MODULE_INFO("FlashMod", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
char write_buffer[128*1024];
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
@ -35,22 +38,18 @@ int SetupCallbacks(void) {
return thid;
}
char write_buffer[128*1024];
void write_file(const char *readpath, const char *writepath)
{
int fdin;
int fdout;
printf("Writing %s\n", writepath);
fdin = sceIoOpen(readpath, PSP_O_RDONLY, 0777);
if(fdin >= 0)
{
int bytesRead = 1;
fdout = sceIoOpen(writepath, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
if(fdout < 0)
{
printf("Couldn't open %s\n", writepath);
}
bytesRead = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
while((bytesRead > 0) && (fdout >= 0))
{
@ -68,18 +67,27 @@ void write_file(const char *readpath, const char *writepath)
sceIoClose(fdin);
}
}
else
{
printf("Couldn't open %s\n", readpath);
}
}
int main() {
SceCtrlData pad;
int i = 0; SceCtrlData pad;
int menu = 1;
char menu_one_buffer[200];
char menu_two_buffer[200];
char menu_three_buffer[200];
char menu_four_buffer[200];
char menu_five_buffer[200];
char flash_complete_buffer[200];
Image* menu_one;
Image* menu_two;
Image* menu_three;
Image* menu_four;
Image* menu_five;
Image* flash_complete;
SetupCallbacks();
pspDebugScreenInit();
initGraphics();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);