font.zip

  • kgame
    了解作者
  • C/C++
    开发工具
  • 1.3MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 4
    下载次数
  • 2009-11-23 22:44
    上传日期
PSP高效能中文字體顯示源代碼 .
font.zip
  • font
  • common
  • log.c
    963B
  • log.o
    2.2KB
  • log.h
    198B
  • datatype.h
    571B
  • vram.o
    1.6KB
  • utils.c
    1KB
  • qsort.o
    1.7KB
  • vram.c
    967B
  • qsort.c
    817B
  • vram.h
    827B
  • utils.h
    234B
  • qsort.h
    220B
  • utils.o
    2KB
  • fonts
  • ASC16
    4KB
  • GBK16
    752.1KB
  • lib
  • bmplib.h
    1.5KB
  • libid3tag.a
    243.4KB
  • mad.h
    26.5KB
  • id3tag.h
    10.4KB
  • libchm.a
    59.9KB
  • zlib.h
    56.4KB
  • libjpeg.a
    197.3KB
  • jconfig.h
    740B
  • libz.a
    84.3KB
  • libtga.a
    17.5KB
  • libgif.a
    134.1KB
  • libmad.a
    130KB
  • png.h
    139KB
  • unzip.a
    13.7KB
  • chm_lib.h
    5.7KB
  • gif_lib.h
    14.1KB
  • unzip.h
    12.7KB
  • pngconf.h
    42.6KB
  • tgaconfig.h
    1.8KB
  • zconf.h
    9.1KB
  • jmorecfg.h
    12.2KB
  • libbmp.a
    6.6KB
  • jpeglib.h
    45.2KB
  • libpng.a
    212.8KB
  • tga.h
    5.7KB
  • gu_font.c
    8.9KB
  • Makefile.bak
    654B
  • girl.o
    544.4KB
  • EBOOT.PBP
    654.1KB
  • font_common.h
    1.5KB
  • main.o
    9.1KB
  • girl.raw
    544KB
  • gu_font.o
    6.2KB
  • main.c
    10.6KB
  • gu_font.h
    600B
  • font.o
    7.3KB
  • Makefile
    647B
  • PARAM.SFO
    256B
  • font.elf
    963.4KB
内容介绍
#include <pspkernel.h> #include <pspdebug.h> #include <pspdisplay.h> #include <pspctrl.h> #include <pspgu.h> #include <pspgum.h> #include <psprtc.h> #include <string.h> #include <stdlib.h> //#include "font.h" #include "common/datatype.h" #include "common/log.h" #include "common/vram.h" #include "gu_font.h" PSP_MODULE_INFO("font example", 0, 1, 1); #define printf pspDebugScreenPrintf #define BUF_WIDTH (512) #define SCR_WIDTH (480) #define SCR_HEIGHT (272) extern int swizzle; int swizzle = 1; static char appdir[256]; extern unsigned int girl_start[]; static unsigned int __attribute__((aligned(16))) list[262144]; extern void swizzle_fast(u8* out, const u8* in, unsigned int width, unsigned int height); const char* modes[] = { "normal, linear", "optimized, linear", "normal, swizzled", "optimized, swizzled" }; //static unsigned short __attribute__((aligned(16))) pixels[BUF_WIDTH*SCR_HEIGHT]; //static unsigned short __attribute__((aligned(16))) swizzled_pixels[BUF_WIDTH*SCR_HEIGHT]; static unsigned int __attribute__((aligned(16))) pixels[BUF_WIDTH*SCR_HEIGHT]; static unsigned int __attribute__((aligned(16))) swizzled_pixels[BUF_WIDTH*SCR_HEIGHT]; struct Vertex { unsigned short u, v; unsigned short color; short x, y, z; }; void simpleBlit(int sx, int sy, int sw, int sh, int dx, int dy) { // simple blit, this just copies A->B, with all the cache-misses that apply struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex)); vertices[0].u = sx; vertices[0].v = sy; vertices[0].color = 0; vertices[0].x = dx; vertices[0].y = dy; vertices[0].z = 0; vertices[1].u = sx+sw; vertices[1].v = sy+sh; vertices[1].color = 0; vertices[1].x = dx+sw; vertices[1].y = dy+sh; vertices[1].z = 0; sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_4444|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices); } void advancedBlit(int sx, int sy, int sw, int sh, int dx, int dy, int slice) { int start, end; // blit maximizing the use of the texture-cache for (start = sx, end = sx+sw; start < end; start += slice, dx += slice) { struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex)); int width = (start + slice) < end ? slice : end-start; vertices[0].u = start; vertices[0].v = sy; vertices[0].color = 0; vertices[0].x = dx; vertices[0].y = dy; vertices[0].z = 0; vertices[1].u = start + width; vertices[1].v = sy + sh; vertices[1].color = 0; vertices[1].x = dx + width; vertices[1].y = dy + sh; vertices[1].z = 0; sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_4444|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices); } } void swizzle_fast(u8* out, const u8* in, unsigned int width, unsigned int height) { unsigned int blockx, blocky; unsigned int j; unsigned int width_blocks = (width / 16); unsigned int height_blocks = (height / 8); unsigned int src_pitch = (width-16)/4; unsigned int src_row = width * 8; const u8* ysrc = in; u32* dst = (u32*)out; for (blocky = 0; blocky < height_blocks; ++blocky) { const u8* xsrc = ysrc; for (blockx = 0; blockx < width_blocks; ++blockx) { const u32* src = (u32*)xsrc; for (j = 0; j < 8; ++j) { *(dst++) = *(src++); *(dst++) = *(src++); *(dst++) = *(src++); *(dst++) = *(src++); src += src_pitch; } xsrc += 16; } ysrc += src_row; } } /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } int main() { unsigned int x,y; byte exit; // exit flag byte vsync; SceCtrlData pad; // contains immediate pad info char fontzipfile[256], efontfile[256], cfontfile[256]; pspDebugScreenInit(); SetupCallbacks(); exit = 0; vsync = 0; getcwd(appdir, 256); strcat(appdir, "/"); strcpy(fontzipfile, appdir); strcpy(efontfile, appdir); strcpy(cfontfile, appdir); strcat(fontzipfile, "fonts.zip"); strcat(efontfile, "fonts/ASC16"); strcat(cfontfile, "fonts/GBK16"); // init raw display function #if 0 disp_init(); #endif // Setup GU void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888); void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888); void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444); sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH); sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH); sceGuDepthBuffer(zbp,BUF_WIDTH); sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); sceGuDepthRange(65535,0); sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); ///// sceGuEnable(GU_BLEND); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); ///// sceGuFrontFace(GU_CW); sceGuEnable(GU_TEXTURE_2D); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(1); // generate dummy image to blit //memcpy( pixels, girl_start, sizeof(int)*BUF_WIDTH*SCR_HEIGHT); for (y = 0; y < SCR_HEIGHT; ++y) { //unsigned short* row = &pixels[y * BUF_WIDTH]; unsigned int* row = &pixels[y * BUF_WIDTH]; for (x = 0; x < SCR_WIDTH; ++x) { //row[x] = x * y; row[x] = girl_start[y * BUF_WIDTH + x]; } } //swizzle_fast((u8*)swizzled_pixels,(const u8*)pixels,BUF_WIDTH*2,SCR_HEIGHT); // 512*2 because swizzle operates in bytes, and each pixel in a 16-bit texture is 2 bytes swizzle_fast((u8*)swizzled_pixels,(const u8*)pixels,BUF_WIDTH*4,SCR_HEIGHT); // 512*2 because swizzle operates in bytes, and each pixel in a 16-bit texture is 2 bytes sceKernelDcacheWritebackAll(); float curr_ms = 1.0f; int blit_method = 1; swizzle = 1; SceCtrlData oldPad; oldPad.Buttons = 0; sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(0); u64 last_tick; sceRtcGetCurrentTick(&last_tick); u32 tick_frequency = sceRtcGetTickResolution(); int frame_count = 0; #if 0 if( disp_load_zipped_font(fontzipfile, "ASC16", "GBK16") || disp_load_font(efontfile, cfontfile)) #else if( gufont_load_zipped_font(fontzipfile, "ASC16", "GBK16") || gufont_load_font(efontfile, cfontfile)) #endif { //pspDebugScreenClear(); //printf("My font example"); // main loop goes here while(1 && !exit) { sceGuStart(GU_DIRECT,list); sceGuClearColor(0xff000000); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); if(sceCtrlPeekBufferPositive(&pad, 1)) { if (pad.Buttons != oldPad.Buttons) { if(pad.Buttons & PSP_CTRL_CROSS) { blit_method ^= 1; } if(pad.Buttons & PSP_CTRL_CIRCLE) { swizzle ^= 1; } if(pad.Buttons & PSP_CTRL_SQUARE) { gufont_toggle_debug_show(); } // press triangle button to exit app if(pad.Buttons & PSP_CTRL_TRIANGLE) exit = 1; } oldPad = pad; } sceGuTexMode(GU_PSM_8888,0,0,swizzle); // 16-bit RGBA sceGuTexImage(0,512,512,512,swizzle ? swizzled_pixels : pixels); // setup texture as a 512x512 texture, even though the buffer is only 512x272 (480 visible) sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA); // don't get influenced by any vertex colors sceGuTexFilter(GU_NEAREST,GU_NEAREST
评论
    相关推荐
    • 数据库课程设计
      一个数据库课程设计,access管理工具实现,用的是窗体!
    • 数据库课程设计
      数据库课程设计十分完整有需要的请下载啊谢谢
    • 数据库课程设计
      广东工业大学数据库课程设计,可视化界面连接数据库,delphi7
    • 数据库课程设计
      数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述
    • 数据库课程设计
      数据库课程设计》由周爱武、汪海威、肖云编著,遵循数据库课程设计的具体要求,独立于具体的数据库教材,从实际应用系统的需求着手,引导读者逐步完成数据库设计全过程,重点讲解数据库系统的需求分析、概念设计、...
    • 数据库课程设计
      数据库课程设计人事管理系统 数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计...
    • 数据库课程设计
      数据库课程设计,基于visual basic自助银行管理系统,界面很清爽,实用。同学都说好,所以就上传了!!!
    • 数据库课程设计
      数据库课程设计 里面有详细的文档资料 包含数据库一切的图 以及生成的数据库表文件 期末得分为优秀
    • 数据库课程设计
      可以作为数据库课程设计,也可以作为Java的课程设计,内容全面。本资源转载的,非本人原创。用于交流学习,特此申明!
    • 数据库课程设计
      数据库课程设计蓝天大学学生管理系统 2.商店信息管理系统 3.实验室机房收费管理系统 4.图书馆资料检索系统 5.企业库存管理系统 6.仓库管理系统 7.工程项目管理系统 8.教材管理系统 9.企业人事管理系统 10.企业财务...