📄 video.c
字号:
/* gameplaySP * * Copyright (C) 2006 Exophase <exophase@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */#include "common.h"#include "font.h"#ifdef PSP_BUILD#include <pspctrl.h>#include <pspkernel.h>#include <pspdebug.h>#include <pspdisplay.h>#include <pspgu.h>#include <psppower.h>#include <psprtc.h>static float *screen_vertex = (float *)0x441FC100;static u32 *ge_cmd = (u32 *)0x441FC000;static u16 *psp_gu_vram_base = (u16 *)(0x44000000);static u32 *ge_cmd_ptr = (u32 *)0x441FC000;static u32 gecbid;static u32 video_direct = 0;static u32 __attribute__((aligned(16))) display_list[32];#define GBA_SCREEN_WIDTH 240#define GBA_SCREEN_HEIGHT 160#define PSP_SCREEN_WIDTH 480#define PSP_SCREEN_HEIGHT 272#define PSP_LINE_SIZE 512#define PSP_ALL_BUTTON_MASK 0xFFFF#define GE_CMD_FBP 0x9C#define GE_CMD_FBW 0x9D#define GE_CMD_TBP0 0xA0#define GE_CMD_TBW0 0xA8#define GE_CMD_TSIZE0 0xB8#define GE_CMD_TFLUSH 0xCB#define GE_CMD_CLEAR 0xD3#define GE_CMD_VTYPE 0x12#define GE_CMD_BASE 0x10#define GE_CMD_VADDR 0x01#define GE_CMD_IADDR 0x02#define GE_CMD_PRIM 0x04#define GE_CMD_FINISH 0x0F#define GE_CMD_SIGNAL 0x0C#define GE_CMD_NOP 0x00#define GE_CMD(cmd, operand) \ *ge_cmd_ptr = (((GE_CMD_##cmd) << 24) | (operand)); \ ge_cmd_ptr++ \static u16 *screen_texture = (u16 *)(0x4000000 + (512 * 272 * 2));static u16 *current_screen_texture = (u16 *)(0x4000000 + (512 * 272 * 2));static u16 *screen_pixels = (u16 *)(0x4000000 + (512 * 272 * 2));static u32 screen_pitch = 240;static void Ge_Finish_Callback(int id, void *arg){}#define get_screen_pixels() \ screen_pixels \#define get_screen_pitch() \ screen_pitch \#elseSDL_Surface *screen;const u32 video_scale = 1;#define get_screen_pixels() \ ((u16 *)screen->pixels) \#define get_screen_pitch() \ (screen->pitch / 2) \#endifvoid render_scanline_conditional_tile(u32 start, u32 end, u16 *scanline, u32 enable_flags, u32 dispcnt, u32 bldcnt, tile_layer_render_struct *layer_renderers);void render_scanline_conditional_bitmap(u32 start, u32 end, u16 *scanline, u32 enable_flags, u32 dispcnt, u32 bldcnt, bitmap_layer_render_struct *layer_renderers);#define no_op \// This old version is not necessary if the palette is either being converted// transparently or the ABGR 1555 format is being used natively. The direct// version (without conversion) is much faster.#define tile_lookup_palette_full(palette, source) \ current_pixel = palette[source]; \ convert_palette(current_pixel) \#define tile_lookup_palette(palette, source) \ current_pixel = palette[source]; \#define tile_expand_base_normal(index) \ tile_lookup_palette(palette, current_pixel); \ dest_ptr[index] = current_pixel \#define tile_expand_transparent_normal(index) \ tile_expand_base_normal(index) \#define tile_expand_copy(index) \ dest_ptr[index] = copy_ptr[index] \#define advance_dest_ptr_base(delta) \ dest_ptr += delta \#define advance_dest_ptr_transparent(delta) \ advance_dest_ptr_base(delta) \#define advance_dest_ptr_copy(delta) \ advance_dest_ptr_base(delta); \ copy_ptr += delta \#define color_combine_mask_a(layer) \ ((io_registers[REG_BLDCNT] >> layer) & 0x01) \// For color blending operations, will create a mask that has in bit// 10 if the layer is target B, and bit 9 if the layer is target A.#define color_combine_mask(layer) \ (color_combine_mask_a(layer) | \ ((io_registers[REG_BLDCNT] >> (layer + 7)) & 0x02)) << 9 \// For alpha blending renderers, draw the palette index (9bpp) and// layer bits rather than the raw RGB. For the base this should write to// the 32bit location directly.#define tile_expand_base_alpha(index) \ dest_ptr[index] = current_pixel | pixel_combine \#define tile_expand_base_bg(index) \ dest_ptr[index] = bg_combine \// For layered (transparent) writes this should shift the "stack" and write// to the bottom. This will preserve the topmost pixel and the most recent// one.#define tile_expand_transparent_alpha(index) \ dest_ptr[index] = (dest_ptr[index] << 16) | current_pixel | pixel_combine \// OBJ should only shift if the top isn't already OBJ#define tile_expand_transparent_alpha_obj(index) \ dest = dest_ptr[index]; \ if(dest & 0x00000100) \ { \ dest_ptr[index] = (dest & 0xFFFF0000) | current_pixel | pixel_combine; \ } \ else \ { \ dest_ptr[index] = (dest << 16) | current_pixel | pixel_combine; \ } \// For color effects that don't need to preserve the previous layer.// The color32 version should be used with 32bit wide dest_ptr so as to be// compatible with alpha combine on top of it.#define tile_expand_base_color16(index) \ dest_ptr[index] = current_pixel | pixel_combine \#define tile_expand_transparent_color16(index) \ tile_expand_base_color16(index) \#define tile_expand_base_color32(index) \ tile_expand_base_color16(index) \#define tile_expand_transparent_color32(index) \ tile_expand_base_color16(index) \// Operations for isolation 8bpp pixels within 32bpp pixel blocks.#define tile_8bpp_pixel_op_mask(op_param) \ current_pixel = current_pixels & 0xFF \#define tile_8bpp_pixel_op_shift_mask(shift) \ current_pixel = (current_pixels >> shift) & 0xFF \#define tile_8bpp_pixel_op_shift(shift) \ current_pixel = current_pixels >> shift \#define tile_8bpp_pixel_op_none(shift) \// Base should always draw raw in 8bpp mode; color 0 will be drawn where// color 0 is.#define tile_8bpp_draw_base_normal(index) \ tile_expand_base_normal(index) \#define tile_8bpp_draw_base_alpha(index) \ if(current_pixel) \ { \ tile_expand_base_alpha(index); \ } \ else \ { \ tile_expand_base_bg(index); \ } \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -