Compare commits
5 Commits
0290d3e749
...
c56ae29ce2
Author | SHA1 | Date | |
---|---|---|---|
c56ae29ce2 | |||
7db964b2ec | |||
1a78267bdc | |||
e7fd6fad8b | |||
26d3d94187 |
6
base.mk
@ -108,6 +108,12 @@ endef
|
|||||||
%.mod.o: %.mod
|
%.mod.o: %.mod
|
||||||
$(BUILD_BINARY_O)
|
$(BUILD_BINARY_O)
|
||||||
|
|
||||||
|
%.bsp.h: %.bsp
|
||||||
|
$(BUILD_BINARY_H)
|
||||||
|
|
||||||
|
%.bsp.o: %.bsp
|
||||||
|
$(BUILD_BINARY_O)
|
||||||
|
|
||||||
%.o: %.s
|
%.o: %.s
|
||||||
$(AS) $(AARCH) $(AFLAGS) $(DEBUG) $< -o $@
|
$(AS) $(AARCH) $(AFLAGS) $(DEBUG) $< -o $@
|
||||||
|
|
||||||
|
@ -990,7 +990,6 @@ BOIDS_OBJ = \
|
|||||||
example/boids.elf: LDSCRIPT = $(LIB)/main.lds
|
example/boids.elf: LDSCRIPT = $(LIB)/main.lds
|
||||||
example/boids.elf: $(START_OBJ) $(BOIDS_OBJ)
|
example/boids.elf: $(START_OBJ) $(BOIDS_OBJ)
|
||||||
|
|
||||||
|
|
||||||
MOD_OBJ = \
|
MOD_OBJ = \
|
||||||
example/mod.o \
|
example/mod.o \
|
||||||
holly/core.o \
|
holly/core.o \
|
||||||
@ -1005,3 +1004,46 @@ MOD_OBJ = \
|
|||||||
|
|
||||||
example/mod.elf: LDSCRIPT = $(LIB)/main.lds
|
example/mod.elf: LDSCRIPT = $(LIB)/main.lds
|
||||||
example/mod.elf: $(START_OBJ) $(MOD_OBJ)
|
example/mod.elf: $(START_OBJ) $(MOD_OBJ)
|
||||||
|
|
||||||
|
Q3BSP_OBJ = \
|
||||||
|
example/q3bsp.o \
|
||||||
|
holly/core.o \
|
||||||
|
holly/region_array.o \
|
||||||
|
holly/background.o \
|
||||||
|
holly/ta_fifo_polygon_converter.o \
|
||||||
|
holly/video_output.o \
|
||||||
|
sh7091/serial.o \
|
||||||
|
sh7091/c_serial.o \
|
||||||
|
printf/printf.o \
|
||||||
|
printf/unparse.o \
|
||||||
|
printf/parse.o \
|
||||||
|
pk/maps/20kdm2.bsp.o \
|
||||||
|
interrupt.o \
|
||||||
|
maple/maple.o \
|
||||||
|
font/font_bitmap.o \
|
||||||
|
font/verite_8x16/verite_8x16.data.o \
|
||||||
|
pk/textures/e7/e7walldesign01b.data.o \
|
||||||
|
pk/textures/e7/e7steptop2.data.o \
|
||||||
|
pk/textures/e7/e7dimfloor.data.o \
|
||||||
|
pk/textures/e7/e7brickfloor01.data.o \
|
||||||
|
pk/textures/e7/e7bmtrim.data.o \
|
||||||
|
pk/textures/e7/e7sbrickfloor.data.o \
|
||||||
|
pk/textures/e7/e7brnmetal.data.o \
|
||||||
|
pk/textures/e7/e7beam02_red.data.o \
|
||||||
|
pk/textures/e7/e7swindow.data.o \
|
||||||
|
pk/textures/e7/e7bigwall.data.o \
|
||||||
|
pk/textures/e7/e7panelwood.data.o \
|
||||||
|
pk/textures/e7/e7beam01.data.o \
|
||||||
|
pk/textures/gothic_floor/xstepborder5.data.o \
|
||||||
|
pk/textures/liquids/lavahell.data.o \
|
||||||
|
pk/textures/e7/e7steptop.data.o \
|
||||||
|
pk/textures/gothic_trim/metalblackwave01.data.o \
|
||||||
|
pk/textures/stone/pjrock1.data.o \
|
||||||
|
pk/models/mapobjects/timlamp/timlamp.data.o \
|
||||||
|
pk/textures/sfx/flame2.data.o \
|
||||||
|
pk/models/mapobjects/gratelamp/gratetorch2.data.o \
|
||||||
|
pk/models/mapobjects/gratelamp/gratetorch2b.data.o \
|
||||||
|
$(LIBGCC)
|
||||||
|
|
||||||
|
example/q3bsp.elf: LDSCRIPT = $(LIB)/main.lds
|
||||||
|
example/q3bsp.elf: $(START_OBJ) $(Q3BSP_OBJ)
|
||||||
|
957
example/q3bsp.cpp
Normal file
@ -0,0 +1,957 @@
|
|||||||
|
#include <bit>
|
||||||
|
|
||||||
|
#include "holly/background.hpp"
|
||||||
|
#include "holly/core.hpp"
|
||||||
|
#include "holly/core_bits.hpp"
|
||||||
|
#include "holly/holly.hpp"
|
||||||
|
#include "holly/isp_tsp.hpp"
|
||||||
|
#include "holly/region_array.hpp"
|
||||||
|
#include "holly/ta_bits.hpp"
|
||||||
|
#include "holly/ta_fifo_polygon_converter.hpp"
|
||||||
|
#include "holly/ta_global_parameter.hpp"
|
||||||
|
#include "holly/ta_parameter.hpp"
|
||||||
|
#include "holly/ta_vertex_parameter.hpp"
|
||||||
|
#include "holly/texture_memory_alloc3.hpp"
|
||||||
|
#include "holly/video_output.hpp"
|
||||||
|
|
||||||
|
#include "systembus.hpp"
|
||||||
|
#include "systembus_bits.hpp"
|
||||||
|
|
||||||
|
#include "maple/maple.hpp"
|
||||||
|
#include "maple/maple_host_command_writer.hpp"
|
||||||
|
#include "maple/maple_bus_bits.hpp"
|
||||||
|
#include "maple/maple_bus_commands.hpp"
|
||||||
|
#include "maple/maple_bus_ft0.hpp"
|
||||||
|
|
||||||
|
#include "memorymap.hpp"
|
||||||
|
|
||||||
|
#include "sh7091/sh7091.hpp"
|
||||||
|
#include "sh7091/sh7091_bits.hpp"
|
||||||
|
#include "sh7091/serial.hpp"
|
||||||
|
#include "printf/printf.h"
|
||||||
|
|
||||||
|
#include "q3bsp/q3bsp.h"
|
||||||
|
#include "pk/maps/20kdm2.bsp.h"
|
||||||
|
|
||||||
|
#include "math/vec2.hpp"
|
||||||
|
#include "math/vec3.hpp"
|
||||||
|
#include "math/vec4.hpp"
|
||||||
|
#include "math/mat4x4.hpp"
|
||||||
|
#include "math/geometry.hpp"
|
||||||
|
|
||||||
|
#include "interrupt.hpp"
|
||||||
|
|
||||||
|
#include "pk/textures/e7/e7walldesign01b.data.h"
|
||||||
|
#include "pk/textures/e7/e7steptop2.data.h"
|
||||||
|
#include "pk/textures/e7/e7dimfloor.data.h"
|
||||||
|
#include "pk/textures/e7/e7brickfloor01.data.h"
|
||||||
|
#include "pk/textures/e7/e7bmtrim.data.h"
|
||||||
|
#include "pk/textures/e7/e7sbrickfloor.data.h"
|
||||||
|
#include "pk/textures/e7/e7brnmetal.data.h"
|
||||||
|
#include "pk/textures/e7/e7beam02_red.data.h"
|
||||||
|
#include "pk/textures/e7/e7swindow.data.h"
|
||||||
|
#include "pk/textures/e7/e7bigwall.data.h"
|
||||||
|
#include "pk/textures/e7/e7panelwood.data.h"
|
||||||
|
#include "pk/textures/e7/e7beam01.data.h"
|
||||||
|
#include "pk/textures/gothic_floor/xstepborder5.data.h"
|
||||||
|
#include "pk/textures/liquids/lavahell.data.h"
|
||||||
|
#include "pk/textures/e7/e7steptop.data.h"
|
||||||
|
#include "pk/textures/gothic_trim/metalblackwave01.data.h"
|
||||||
|
#include "pk/textures/stone/pjrock1.data.h"
|
||||||
|
#include "pk/models/mapobjects/timlamp/timlamp.data.h"
|
||||||
|
#include "pk/textures/sfx/flame2.data.h"
|
||||||
|
#include "pk/models/mapobjects/gratelamp/gratetorch2.data.h"
|
||||||
|
#include "pk/models/mapobjects/gratelamp/gratetorch2b.data.h"
|
||||||
|
|
||||||
|
#include "font/font_bitmap.hpp"
|
||||||
|
#include "font/verite_8x16/verite_8x16.data.h"
|
||||||
|
#include "palette.hpp"
|
||||||
|
#include "printf/unparse.h"
|
||||||
|
|
||||||
|
#include "assert.h"
|
||||||
|
|
||||||
|
#include "pk/texture.h"
|
||||||
|
|
||||||
|
constexpr int font_offset = ((0x7f - 0x20) + 1) * 8 * 16 / 2;
|
||||||
|
|
||||||
|
using vec2 = vec<2, float>;
|
||||||
|
using vec3 = vec<3, float>;
|
||||||
|
using vec4 = vec<4, float>;
|
||||||
|
using mat4x4 = mat<4, 4, float>;
|
||||||
|
|
||||||
|
#define _fsrra(n) (1.0f / (__builtin_sqrtf(n)))
|
||||||
|
|
||||||
|
static ft0::data_transfer::data_format data[4];
|
||||||
|
|
||||||
|
uint8_t send_buf[1024] __attribute__((aligned(32)));
|
||||||
|
uint8_t recv_buf[1024] __attribute__((aligned(32)));
|
||||||
|
|
||||||
|
void do_get_condition()
|
||||||
|
{
|
||||||
|
auto writer = maple::host_command_writer(send_buf, recv_buf);
|
||||||
|
|
||||||
|
using command_type = maple::get_condition;
|
||||||
|
using response_type = maple::data_transfer<ft0::data_transfer::data_format>;
|
||||||
|
|
||||||
|
auto [host_command, host_response]
|
||||||
|
= writer.append_command_all_ports<command_type, response_type>();
|
||||||
|
|
||||||
|
for (int port = 0; port < 4; port++) {
|
||||||
|
auto& data_fields = host_command[port].bus_data.data_fields;
|
||||||
|
data_fields.function_type = std::byteswap(function_type::controller);
|
||||||
|
}
|
||||||
|
maple::dma_start(send_buf, writer.send_offset,
|
||||||
|
recv_buf, writer.recv_offset);
|
||||||
|
|
||||||
|
for (uint8_t port = 0; port < 4; port++) {
|
||||||
|
auto& bus_data = host_response[port].bus_data;
|
||||||
|
if (bus_data.command_code != response_type::command_code) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto& data_fields = bus_data.data_fields;
|
||||||
|
if ((std::byteswap(data_fields.function_type) & function_type::controller) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data[port].digital_button = data_fields.data.digital_button;
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
data[port].analog_coordinate_axis[i]
|
||||||
|
= data_fields.data.analog_coordinate_axis[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct position_normal {
|
||||||
|
vec3 position;
|
||||||
|
vec3 normal;
|
||||||
|
};
|
||||||
|
|
||||||
|
static position_normal vertex_cache[16384];
|
||||||
|
|
||||||
|
static inline vec3 normal_transform(mat4x4& trans, vec3 normal)
|
||||||
|
{
|
||||||
|
vec4 n = trans * (vec4){normal.x, normal.y, normal.z, 0.f}; // no translation component
|
||||||
|
return {n.x, n.y, n.z};
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline vec3 screen_transform(vec3 v)
|
||||||
|
{
|
||||||
|
float dim = 480 / 2.0;
|
||||||
|
|
||||||
|
return {
|
||||||
|
v.x / (1.f * v.z) * dim + 640 / 2.0f,
|
||||||
|
v.y / (1.f * v.z) * dim + 480 / 2.0f,
|
||||||
|
1 / v.z,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void global_polygon_type_0(ta_parameter_writer& writer)
|
||||||
|
{
|
||||||
|
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||||
|
| para_control::list_type::translucent
|
||||||
|
| obj_control::col_type::packed_color
|
||||||
|
;
|
||||||
|
|
||||||
|
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
|
||||||
|
| isp_tsp_instruction_word::culling_mode::no_culling;
|
||||||
|
|
||||||
|
const uint32_t tsp_instruction_word = tsp_instruction_word::fog_control::no_fog
|
||||||
|
| tsp_instruction_word::src_alpha_instr::src_alpha
|
||||||
|
| tsp_instruction_word::dst_alpha_instr::inverse_src_alpha
|
||||||
|
| tsp_instruction_word::use_alpha
|
||||||
|
;
|
||||||
|
|
||||||
|
const uint32_t texture_control_word = 0;
|
||||||
|
|
||||||
|
writer.append<ta_global_parameter::polygon_type_0>() =
|
||||||
|
ta_global_parameter::polygon_type_0(parameter_control_word,
|
||||||
|
isp_tsp_instruction_word,
|
||||||
|
tsp_instruction_word,
|
||||||
|
texture_control_word,
|
||||||
|
0, // data_size_for_sort_dma
|
||||||
|
0 // next_address_for_sort_dma
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void global_polygon_type_1(ta_parameter_writer& writer,
|
||||||
|
uint32_t obj_control_texture,
|
||||||
|
uint32_t texture_u_v_size,
|
||||||
|
uint32_t texture_control_word)
|
||||||
|
{
|
||||||
|
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||||
|
| para_control::list_type::opaque
|
||||||
|
| obj_control::col_type::intensity_mode_1
|
||||||
|
| obj_control::gouraud
|
||||||
|
| obj_control_texture
|
||||||
|
;
|
||||||
|
|
||||||
|
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
|
||||||
|
| isp_tsp_instruction_word::culling_mode::cull_if_negative
|
||||||
|
;
|
||||||
|
|
||||||
|
const uint32_t tsp_instruction_word = tsp_instruction_word::fog_control::no_fog
|
||||||
|
| tsp_instruction_word::src_alpha_instr::one
|
||||||
|
| tsp_instruction_word::dst_alpha_instr::zero
|
||||||
|
| tsp_instruction_word::filter_mode::bilinear_filter
|
||||||
|
| tsp_instruction_word::texture_shading_instruction::modulate
|
||||||
|
| texture_u_v_size
|
||||||
|
;
|
||||||
|
|
||||||
|
const float a = 1.0f;
|
||||||
|
const float r = 1.0f;
|
||||||
|
const float g = 1.0f;
|
||||||
|
const float b = 1.0f;
|
||||||
|
|
||||||
|
writer.append<ta_global_parameter::polygon_type_1>() =
|
||||||
|
ta_global_parameter::polygon_type_1(parameter_control_word,
|
||||||
|
isp_tsp_instruction_word,
|
||||||
|
tsp_instruction_word,
|
||||||
|
texture_control_word,
|
||||||
|
a,
|
||||||
|
r,
|
||||||
|
g,
|
||||||
|
b
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void global_texture(ta_parameter_writer& writer, int ix)
|
||||||
|
{
|
||||||
|
struct pk_texture * texture = &textures[ix];
|
||||||
|
|
||||||
|
uint32_t texture_u_v_size = tsp_instruction_word::texture_u_size::from_int(texture->width)
|
||||||
|
| tsp_instruction_word::texture_v_size::from_int(texture->height)
|
||||||
|
;
|
||||||
|
|
||||||
|
uint32_t texture_address = texture_memory_alloc.texture.start + font_offset + texture->offset * 2;
|
||||||
|
uint32_t texture_control_word = texture_control_word::pixel_format::_565
|
||||||
|
| texture_control_word::scan_order::non_twiddled
|
||||||
|
| texture_control_word::texture_address(texture_address / 8)
|
||||||
|
;
|
||||||
|
|
||||||
|
global_polygon_type_1(writer,
|
||||||
|
obj_control::texture,
|
||||||
|
texture_u_v_size,
|
||||||
|
texture_control_word);
|
||||||
|
}
|
||||||
|
|
||||||
|
void transform_vertices(uint8_t * buf, int length, mat4x4& trans)
|
||||||
|
{
|
||||||
|
q3bsp_vertex_t * vert = reinterpret_cast<q3bsp_vertex_t *>(buf);
|
||||||
|
|
||||||
|
int count = length / (sizeof (struct q3bsp_vertex));
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
vec3 v = {vert[i].position[0], vert[i].position[1], vert[i].position[2]};
|
||||||
|
vec3 n = {vert[i].normal[0], vert[i].normal[1], vert[i].normal[2]};
|
||||||
|
|
||||||
|
//printf("%f %f %f\n", v.x, v.y, v.z);
|
||||||
|
|
||||||
|
vertex_cache[i].position = screen_transform(trans * v);
|
||||||
|
vertex_cache[i].normal = normal_transform(trans, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void render_tri_type_2(ta_parameter_writer& writer,
|
||||||
|
vec3 ap,
|
||||||
|
vec3 bp,
|
||||||
|
vec3 cp,
|
||||||
|
float ai,
|
||||||
|
float bi,
|
||||||
|
float ci)
|
||||||
|
{
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_2>() =
|
||||||
|
ta_vertex_parameter::polygon_type_2(polygon_vertex_parameter_control_word(false),
|
||||||
|
ap.x, ap.y, ap.z,
|
||||||
|
ai);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_2>() =
|
||||||
|
ta_vertex_parameter::polygon_type_2(polygon_vertex_parameter_control_word(false),
|
||||||
|
bp.x, bp.y, bp.z,
|
||||||
|
bi);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_2>() =
|
||||||
|
ta_vertex_parameter::polygon_type_2(polygon_vertex_parameter_control_word(true),
|
||||||
|
cp.x, cp.y, cp.z,
|
||||||
|
ci);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void render_tri_type_7(ta_parameter_writer& writer,
|
||||||
|
vec3 ap,
|
||||||
|
vec3 bp,
|
||||||
|
vec3 cp,
|
||||||
|
vec2 at,
|
||||||
|
vec2 bt,
|
||||||
|
vec2 ct,
|
||||||
|
float ai,
|
||||||
|
float bi,
|
||||||
|
float ci)
|
||||||
|
{
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_7>() =
|
||||||
|
ta_vertex_parameter::polygon_type_7(polygon_vertex_parameter_control_word(false),
|
||||||
|
ap.x, ap.y, ap.z,
|
||||||
|
at.x, at.y,
|
||||||
|
ai,
|
||||||
|
0);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_7>() =
|
||||||
|
ta_vertex_parameter::polygon_type_7(polygon_vertex_parameter_control_word(false),
|
||||||
|
bp.x, bp.y, bp.z,
|
||||||
|
bt.x, bt.y,
|
||||||
|
bi,
|
||||||
|
0);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_7>() =
|
||||||
|
ta_vertex_parameter::polygon_type_7(polygon_vertex_parameter_control_word(true),
|
||||||
|
cp.x, cp.y, cp.z,
|
||||||
|
ct.x, ct.y,
|
||||||
|
ci,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float inverse_length(vec3 v)
|
||||||
|
{
|
||||||
|
float f = dot(v, v);
|
||||||
|
return _fsrra(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float light_intensity(vec3 light_vec, vec3 n)
|
||||||
|
{
|
||||||
|
float n_dot_l = dot(n, light_vec);
|
||||||
|
|
||||||
|
float intensity = 0.5f;
|
||||||
|
if (n_dot_l > 0) {
|
||||||
|
intensity += 0.7f * n_dot_l * (inverse_length(n) * inverse_length(light_vec));
|
||||||
|
if (intensity > 1.0f)
|
||||||
|
intensity = 1.0f;
|
||||||
|
}
|
||||||
|
return intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
static vec3 light_vec = {20, -20, -20};
|
||||||
|
|
||||||
|
void transfer_faces(uint8_t * buf, q3bsp_header_t * header, ta_parameter_writer& writer)
|
||||||
|
{
|
||||||
|
q3bsp_direntry * ve = &header->direntries[LUMP_VERTEXES];
|
||||||
|
q3bsp_direntry * me = &header->direntries[LUMP_MESHVERTS];
|
||||||
|
q3bsp_direntry * fe = &header->direntries[LUMP_FACES];
|
||||||
|
|
||||||
|
q3bsp_vertex_t * vert = reinterpret_cast<q3bsp_vertex_t *>(&buf[ve->offset]);
|
||||||
|
q3bsp_meshvert_t * meshvert = reinterpret_cast<q3bsp_meshvert_t *>(&buf[me->offset]);
|
||||||
|
q3bsp_face_t * face = reinterpret_cast<q3bsp_face_t *>(&buf[fe->offset]);
|
||||||
|
|
||||||
|
int face_count = fe->length / (sizeof (struct q3bsp_face));
|
||||||
|
|
||||||
|
int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
||||||
|
int last_texture = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < face_count; i++) {
|
||||||
|
int meshvert_ix = face[i].meshvert;
|
||||||
|
q3bsp_meshvert_t * mv = &meshvert[meshvert_ix];
|
||||||
|
|
||||||
|
int triangles = face[i].n_meshverts / 3;
|
||||||
|
|
||||||
|
bool has_texture = 1 &&
|
||||||
|
(face[i].texture >= 0) &&
|
||||||
|
(face[i].texture < textures_length) &&
|
||||||
|
(textures[face[i].texture].size != 0);
|
||||||
|
|
||||||
|
if (face[i].texture != last_texture) {
|
||||||
|
last_texture = face[i].texture;
|
||||||
|
if (has_texture) {
|
||||||
|
global_texture(writer, face[i].texture);
|
||||||
|
} else {
|
||||||
|
global_polygon_type_1(writer, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < triangles; j++) {
|
||||||
|
|
||||||
|
int aix = mv[j * 3 + 0].offset + face[i].vertex;
|
||||||
|
int bix = mv[j * 3 + 1].offset + face[i].vertex;
|
||||||
|
int cix = mv[j * 3 + 2].offset + face[i].vertex;
|
||||||
|
|
||||||
|
vec3 ap = vertex_cache[aix].position;
|
||||||
|
vec3 bp = vertex_cache[bix].position;
|
||||||
|
vec3 cp = vertex_cache[cix].position;
|
||||||
|
|
||||||
|
if (ap.z < 0 || bp.z < 0 || cp.z < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 n = vertex_cache[aix].normal;
|
||||||
|
float li = light_intensity(light_vec, n);
|
||||||
|
|
||||||
|
/*
|
||||||
|
printf("{%f %f %f} {%f %f %f} {%f %f %f}\n",
|
||||||
|
ap.x, ap.y, ap.z,
|
||||||
|
bp.x, bp.y, bp.z,
|
||||||
|
cp.x, cp.y, cp.z);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (has_texture) {
|
||||||
|
float v_mul = textures[face[i].texture].v_mul;
|
||||||
|
vec2 at = {vert[aix].texcoord[0], vert[aix].texcoord[1] * v_mul};
|
||||||
|
vec2 bt = {vert[bix].texcoord[0], vert[bix].texcoord[1] * v_mul};
|
||||||
|
vec2 ct = {vert[cix].texcoord[0], vert[cix].texcoord[1] * v_mul};
|
||||||
|
//printf("{%f %f} {%f %f} {%f %f}\n", at.x, at.y, bt.x, bt.y, ct.x, ct.y);
|
||||||
|
|
||||||
|
|
||||||
|
render_tri_type_7(writer,
|
||||||
|
ap,
|
||||||
|
bp,
|
||||||
|
cp,
|
||||||
|
at,
|
||||||
|
bt,
|
||||||
|
ct,
|
||||||
|
li,
|
||||||
|
li,
|
||||||
|
li);
|
||||||
|
} else {
|
||||||
|
render_tri_type_2(writer,
|
||||||
|
ap,
|
||||||
|
bp,
|
||||||
|
cp,
|
||||||
|
li,
|
||||||
|
li,
|
||||||
|
li);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void render_quad(ta_parameter_writer& writer,
|
||||||
|
vec3 ap,
|
||||||
|
vec3 bp,
|
||||||
|
vec3 cp,
|
||||||
|
vec3 dp,
|
||||||
|
uint32_t base_color)
|
||||||
|
{
|
||||||
|
if (ap.z < 0 || bp.z < 0 || cp.z < 0 || dp.z < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_0>() =
|
||||||
|
ta_vertex_parameter::polygon_type_0(polygon_vertex_parameter_control_word(false),
|
||||||
|
ap.x, ap.y, ap.z,
|
||||||
|
base_color);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_0>() =
|
||||||
|
ta_vertex_parameter::polygon_type_0(polygon_vertex_parameter_control_word(false),
|
||||||
|
bp.x, bp.y, bp.z,
|
||||||
|
base_color);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_0>() =
|
||||||
|
ta_vertex_parameter::polygon_type_0(polygon_vertex_parameter_control_word(false),
|
||||||
|
dp.x, dp.y, dp.z,
|
||||||
|
base_color);
|
||||||
|
|
||||||
|
writer.append<ta_vertex_parameter::polygon_type_0>() =
|
||||||
|
ta_vertex_parameter::polygon_type_0(polygon_vertex_parameter_control_word(true),
|
||||||
|
cp.x, cp.y, cp.z,
|
||||||
|
base_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_bounding_box(ta_parameter_writer& writer, mat4x4& trans, vec3 max, vec3 min, uint32_t color)
|
||||||
|
{
|
||||||
|
vec3 a = max;
|
||||||
|
vec3 b = min;
|
||||||
|
|
||||||
|
global_polygon_type_0(writer);
|
||||||
|
|
||||||
|
// ax
|
||||||
|
render_quad(writer,
|
||||||
|
screen_transform(trans * (vec3){a.x, a.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, b.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, b.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, a.y, b.z}),
|
||||||
|
color);
|
||||||
|
|
||||||
|
// bx
|
||||||
|
render_quad(writer,
|
||||||
|
screen_transform(trans * (vec3){b.x, a.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, b.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, b.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, a.y, b.z}),
|
||||||
|
color);
|
||||||
|
|
||||||
|
// ay
|
||||||
|
render_quad(writer,
|
||||||
|
screen_transform(trans * (vec3){b.x, a.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, a.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, a.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, a.y, b.z}),
|
||||||
|
color);
|
||||||
|
|
||||||
|
// by
|
||||||
|
render_quad(writer,
|
||||||
|
screen_transform(trans * (vec3){b.x, b.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, b.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, b.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, b.y, b.z}),
|
||||||
|
color);
|
||||||
|
|
||||||
|
// az
|
||||||
|
render_quad(writer,
|
||||||
|
screen_transform(trans * (vec3){b.x, a.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, b.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, b.y, a.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, a.y, a.z}),
|
||||||
|
color);
|
||||||
|
|
||||||
|
// bz
|
||||||
|
render_quad(writer,
|
||||||
|
screen_transform(trans * (vec3){b.x, a.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){b.x, b.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, b.y, b.z}),
|
||||||
|
screen_transform(trans * (vec3){a.x, a.y, b.z}),
|
||||||
|
color);
|
||||||
|
}
|
||||||
|
|
||||||
|
int format_float(char * s, float num, int pad_length)
|
||||||
|
{
|
||||||
|
int offset = 0;
|
||||||
|
bool negative = num < 0;
|
||||||
|
if (negative) num = -num;
|
||||||
|
int32_t whole = num;
|
||||||
|
int digits = digits_base10(whole);
|
||||||
|
offset += unparse_base10_unsigned(&s[offset], whole, pad_length, ' ');
|
||||||
|
if (negative)
|
||||||
|
s[offset - (digits + 1)] = '-';
|
||||||
|
s[offset++] = '.';
|
||||||
|
int32_t fraction = (int32_t)((num - (float)whole) * 1000.0);
|
||||||
|
if (fraction < 0)
|
||||||
|
fraction = -fraction;
|
||||||
|
offset += unparse_base10_unsigned(&s[offset], fraction, 3, '0');
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_matrix(ta_parameter_writer& writer, const mat4x4& trans)
|
||||||
|
{
|
||||||
|
for (int row = 0; row < 4; row++) {
|
||||||
|
char __attribute__((aligned(4))) s[64];
|
||||||
|
for (uint32_t i = 0; i < (sizeof (s)) / 4; i++)
|
||||||
|
reinterpret_cast<uint32_t *>(s)[i] = 0x20202020;
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
offset += format_float(&s[offset], trans[row][0], 7);
|
||||||
|
offset += format_float(&s[offset], trans[row][1], 7);
|
||||||
|
offset += format_float(&s[offset], trans[row][2], 7);
|
||||||
|
offset += format_float(&s[offset], trans[row][3], 7);
|
||||||
|
|
||||||
|
font_bitmap::transform_string(writer,
|
||||||
|
8, 16, // texture
|
||||||
|
8, 16, // glyph
|
||||||
|
16 + 2 * 8, // position x
|
||||||
|
16 + row * 16, // position y
|
||||||
|
s, offset,
|
||||||
|
para_control::list_type::opaque);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int root_ix = 0;
|
||||||
|
|
||||||
|
void render_ix(ta_parameter_writer& writer, int row, char * s, int ix)
|
||||||
|
{
|
||||||
|
int offset = 15;
|
||||||
|
bool is_leaf = ix < 0;
|
||||||
|
if (ix < 0)
|
||||||
|
ix = -(ix - 1);
|
||||||
|
|
||||||
|
offset += unparse_base10_unsigned(&s[offset], ix, 5, ' ');
|
||||||
|
|
||||||
|
if (is_leaf) {
|
||||||
|
s[offset++] = ' ';
|
||||||
|
s[offset++] = '(';
|
||||||
|
s[offset++] = 'l';
|
||||||
|
s[offset++] = 'e';
|
||||||
|
s[offset++] = 'a';
|
||||||
|
s[offset++] = 'f';
|
||||||
|
s[offset++] = ')';
|
||||||
|
} else {
|
||||||
|
s[offset++] = ' ';
|
||||||
|
s[offset++] = '(';
|
||||||
|
s[offset++] = 'n';
|
||||||
|
s[offset++] = 'o';
|
||||||
|
s[offset++] = 'd';
|
||||||
|
s[offset++] = 'e';
|
||||||
|
s[offset++] = ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
font_bitmap::transform_string(writer,
|
||||||
|
8, 16, // texture
|
||||||
|
8, 16, // glyph
|
||||||
|
16 + 50 * 8, // position x
|
||||||
|
16 + row * 16, // position y
|
||||||
|
s, offset,
|
||||||
|
para_control::list_type::opaque);
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_leaf_ix(ta_parameter_writer& writer)
|
||||||
|
{
|
||||||
|
uint8_t * buf = reinterpret_cast<uint8_t *>(&_binary_pk_maps_20kdm2_bsp_start);
|
||||||
|
q3bsp_header_t * header = reinterpret_cast<q3bsp_header_t *>(buf);
|
||||||
|
q3bsp_direntry * ne = &header->direntries[LUMP_NODES];
|
||||||
|
q3bsp_node_t * nodes = reinterpret_cast<q3bsp_node_t *>(&buf[ne->offset]);
|
||||||
|
q3bsp_node_t * root = &nodes[root_ix];
|
||||||
|
|
||||||
|
{
|
||||||
|
char s[32] = "root: ";
|
||||||
|
int row = 0;
|
||||||
|
render_ix(writer, row, s, root_ix);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char s[32] = "root.child[0]: ";
|
||||||
|
int row = 1;
|
||||||
|
render_ix(writer, row, s, root->children[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char s[32] = "root.child[1]: ";
|
||||||
|
int row = 2;
|
||||||
|
render_ix(writer, row, s, root->children[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_bounding_box_mm(ta_parameter_writer& writer, mat4x4& trans, int mins[3], int maxs[3], uint32_t color)
|
||||||
|
{
|
||||||
|
vec3 max = {(float)maxs[0], (float)maxs[1], (float)maxs[2]};
|
||||||
|
vec3 min = {(float)mins[0], (float)mins[1], (float)mins[2]};
|
||||||
|
render_bounding_box(writer, trans, max, min, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_bounding_boxes(ta_parameter_writer& writer, mat4x4& trans)
|
||||||
|
{
|
||||||
|
uint8_t * buf = reinterpret_cast<uint8_t *>(&_binary_pk_maps_20kdm2_bsp_start);
|
||||||
|
q3bsp_header_t * header = reinterpret_cast<q3bsp_header_t *>(buf);
|
||||||
|
|
||||||
|
q3bsp_direntry * le = &header->direntries[LUMP_LEAFS];
|
||||||
|
q3bsp_leaf_t * leafs = reinterpret_cast<q3bsp_leaf_t *>(&buf[le->offset]);
|
||||||
|
|
||||||
|
q3bsp_direntry * ne = &header->direntries[LUMP_NODES];
|
||||||
|
q3bsp_node_t * nodes = reinterpret_cast<q3bsp_node_t *>(&buf[ne->offset]);
|
||||||
|
q3bsp_node_t * root = &nodes[root_ix];
|
||||||
|
|
||||||
|
{
|
||||||
|
if (root->children[0] >= 0) {
|
||||||
|
q3bsp_node_t * a = &nodes[root->children[0]];
|
||||||
|
uint32_t color = 0x80ff00e6;
|
||||||
|
render_bounding_box_mm(writer, trans, a->mins, a->maxs, color);
|
||||||
|
} else {
|
||||||
|
int leaf_ix = -(root->children[0] + 1);
|
||||||
|
q3bsp_leaf_t * leaf = &leafs[leaf_ix];
|
||||||
|
uint32_t color = 0x80ff0016;
|
||||||
|
render_bounding_box_mm(writer, trans, leaf->maxs, leaf->mins, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root->children[1] >= 0) {
|
||||||
|
q3bsp_node_t * b = &nodes[root->children[1]];
|
||||||
|
uint32_t color = 0x8000ffe6;
|
||||||
|
render_bounding_box_mm(writer, trans, b->mins, b->maxs, color);
|
||||||
|
} else {
|
||||||
|
int leaf_ix = -(root->children[1] + 1);
|
||||||
|
q3bsp_leaf_t * leaf = &leafs[leaf_ix];
|
||||||
|
uint32_t color = 0x8000ff16;
|
||||||
|
render_bounding_box_mm(writer, trans, leaf->maxs, leaf->mins, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void transfer_scene(ta_parameter_writer& writer, const mat4x4& screen_trans)
|
||||||
|
{
|
||||||
|
uint8_t * buf = reinterpret_cast<uint8_t *>(&_binary_pk_maps_20kdm2_bsp_start);
|
||||||
|
q3bsp_header_t * header = reinterpret_cast<q3bsp_header_t *>(buf);
|
||||||
|
|
||||||
|
mat4x4 trans = screen_trans;
|
||||||
|
|
||||||
|
q3bsp_direntry * ve = &header->direntries[LUMP_VERTEXES];
|
||||||
|
transform_vertices(&buf[ve->offset], ve->length, trans);
|
||||||
|
|
||||||
|
transfer_faces(buf, header, writer);
|
||||||
|
|
||||||
|
render_matrix(writer, trans);
|
||||||
|
render_leaf_ix(writer);
|
||||||
|
|
||||||
|
writer.append<ta_global_parameter::end_of_list>() =
|
||||||
|
ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||||
|
|
||||||
|
render_bounding_boxes(writer, trans);
|
||||||
|
|
||||||
|
writer.append<ta_global_parameter::end_of_list>() =
|
||||||
|
ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t __attribute__((aligned(32))) ta_parameter_buf[1024 * 1024];
|
||||||
|
|
||||||
|
constexpr inline mat4x4 rotate_x(float t)
|
||||||
|
{
|
||||||
|
mat4x4 r = {
|
||||||
|
1, 0, 0, 0,
|
||||||
|
0, cos(t), -sin(t), 0,
|
||||||
|
0, sin(t), cos(t), 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
};
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline mat4x4 rotate_y(float t)
|
||||||
|
{
|
||||||
|
mat4x4 r = {
|
||||||
|
cos(t), 0, sin(t), 0,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
-sin(t), 0, cos(t), 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
};
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline mat4x4 rotate_z(float t)
|
||||||
|
{
|
||||||
|
mat4x4 r = {
|
||||||
|
cos(t), -sin(t), 0, 0,
|
||||||
|
sin(t), cos(t), 0, 0,
|
||||||
|
0, 0, 1, 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
};
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void transfer_ta_fifo_texture_memory_32byte(void * dst, void * src, int length)
|
||||||
|
{
|
||||||
|
uint32_t out_addr = (uint32_t)dst;
|
||||||
|
sh7091.CCN.QACR0 = ((reinterpret_cast<uint32_t>(out_addr) >> 24) & 0b11100);
|
||||||
|
sh7091.CCN.QACR1 = ((reinterpret_cast<uint32_t>(out_addr) >> 24) & 0b11100);
|
||||||
|
|
||||||
|
volatile uint32_t * base = &store_queue[(out_addr & 0x03ffffc0) / 4];
|
||||||
|
uint32_t * src32 = reinterpret_cast<uint32_t *>(src);
|
||||||
|
|
||||||
|
length = (length + 31) & ~31; // round up to nearest multiple of 32
|
||||||
|
while (length > 0) {
|
||||||
|
base[0] = src32[0];
|
||||||
|
base[1] = src32[1];
|
||||||
|
base[2] = src32[2];
|
||||||
|
base[3] = src32[3];
|
||||||
|
base[4] = src32[4];
|
||||||
|
base[5] = src32[5];
|
||||||
|
base[6] = src32[6];
|
||||||
|
base[7] = src32[7];
|
||||||
|
asm volatile ("pref @%0"
|
||||||
|
: // output
|
||||||
|
: "r" (&base[0]) // input
|
||||||
|
: "memory");
|
||||||
|
length -= 32;
|
||||||
|
base += 8;
|
||||||
|
src32 += 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void transfer_textures()
|
||||||
|
{
|
||||||
|
system.LMMODE0 = 0; // 64-bit address space
|
||||||
|
system.LMMODE1 = 0; // 64-bit address space
|
||||||
|
|
||||||
|
int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
||||||
|
for (int i = 0; i < textures_length; i++) {
|
||||||
|
uint32_t offset = texture_memory_alloc.texture.start + font_offset + textures[i].offset * 2;
|
||||||
|
void * dst = reinterpret_cast<void *>(&ta_fifo_texture_memory[offset / 4]);
|
||||||
|
void * src = textures[i].start;
|
||||||
|
uint32_t size = textures[i].size;
|
||||||
|
transfer_ta_fifo_texture_memory_32byte(dst, src, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool push = false;
|
||||||
|
|
||||||
|
mat4x4 update_analog(mat4x4& screen)
|
||||||
|
{
|
||||||
|
const float x_ = static_cast<float>(data[0].analog_coordinate_axis[2] - 0x80) / 127.f;
|
||||||
|
const float y_ = static_cast<float>(data[0].analog_coordinate_axis[3] - 0x80) / 127.f;
|
||||||
|
|
||||||
|
int ra = ft0::data_transfer::digital_button::ra(data[0].digital_button) == 0;
|
||||||
|
int la = ft0::data_transfer::digital_button::la(data[0].digital_button) == 0;
|
||||||
|
int da = ft0::data_transfer::digital_button::da(data[0].digital_button) == 0;
|
||||||
|
int ua = ft0::data_transfer::digital_button::ua(data[0].digital_button) == 0;
|
||||||
|
|
||||||
|
int db_x = ft0::data_transfer::digital_button::x(data[0].digital_button) == 0;
|
||||||
|
int db_y = ft0::data_transfer::digital_button::y(data[0].digital_button) == 0;
|
||||||
|
|
||||||
|
float x = 0;
|
||||||
|
if (ra && !la) x = -10;
|
||||||
|
if (la && !ra) x = 10;
|
||||||
|
|
||||||
|
float z = 0;
|
||||||
|
if (ua && !da) z = -10;
|
||||||
|
if (da && !ua) z = 10;
|
||||||
|
|
||||||
|
mat4x4 t = {
|
||||||
|
1, 0, 0, x,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
0, 0, 1, z,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
float yt = 0.05f * x_;
|
||||||
|
float xt = 0.05f * y_;
|
||||||
|
|
||||||
|
mat4x4 rx = {
|
||||||
|
1, 0, 0, 0,
|
||||||
|
0, cos(xt), -sin(xt), 0,
|
||||||
|
0, sin(xt), cos(xt), 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
mat4x4 ry = {
|
||||||
|
cos(yt), 0, sin(yt), 0,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
-sin(yt), 0, cos(yt), 0,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t * buf = reinterpret_cast<uint8_t *>(&_binary_pk_maps_20kdm2_bsp_start);
|
||||||
|
q3bsp_header_t * header = reinterpret_cast<q3bsp_header_t *>(buf);
|
||||||
|
//q3bsp_direntry * le = &header->direntries[LUMP_LEAFS];
|
||||||
|
//int num_leaves = le->length / (sizeof (struct q3bsp_leaf));
|
||||||
|
q3bsp_direntry * ne = &header->direntries[LUMP_NODES];
|
||||||
|
q3bsp_node_t * nodes = reinterpret_cast<q3bsp_node_t *>(&buf[ne->offset]);
|
||||||
|
|
||||||
|
if (db_x && !db_y && !push) {
|
||||||
|
push = true;
|
||||||
|
//leaf_ix -= 1;
|
||||||
|
//if (leaf_ix < 0) leaf_ix = num_leaves - 1;
|
||||||
|
|
||||||
|
int ix = nodes[root_ix].children[0];
|
||||||
|
if (ix >= 0)
|
||||||
|
root_ix = ix;
|
||||||
|
}
|
||||||
|
if (db_y && !db_x && !push) {
|
||||||
|
push = true;
|
||||||
|
//leaf_ix += 1;
|
||||||
|
//if (leaf_ix > num_leaves) leaf_ix = 0;
|
||||||
|
int ix = nodes[root_ix].children[1];
|
||||||
|
if (ix >= 0)
|
||||||
|
root_ix = ix;
|
||||||
|
}
|
||||||
|
if (!db_x && !db_y) {
|
||||||
|
push = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rx * ry * t * screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void transfer_font()
|
||||||
|
{
|
||||||
|
const uint8_t * src = reinterpret_cast<const uint8_t *>(&_binary_font_verite_8x16_verite_8x16_data_start);
|
||||||
|
uint32_t offset = font_bitmap::inflate(1, // pitch
|
||||||
|
8, // width
|
||||||
|
16, // height
|
||||||
|
8, // texture_width
|
||||||
|
16, // texture_height
|
||||||
|
src);
|
||||||
|
printf("font_offset %d actual %d\n", font_offset, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
serial::init(0);
|
||||||
|
|
||||||
|
interrupt_init();
|
||||||
|
transfer_textures();
|
||||||
|
transfer_font();
|
||||||
|
palette_data<3>();
|
||||||
|
|
||||||
|
constexpr uint32_t ta_alloc = 0
|
||||||
|
| ta_alloc_ctrl::pt_opb::no_list
|
||||||
|
| ta_alloc_ctrl::tm_opb::no_list
|
||||||
|
| ta_alloc_ctrl::t_opb::_16x4byte
|
||||||
|
| ta_alloc_ctrl::om_opb::no_list
|
||||||
|
| ta_alloc_ctrl::o_opb::_16x4byte;
|
||||||
|
|
||||||
|
constexpr int ta_cont_count = 1;
|
||||||
|
constexpr struct opb_size opb_size[ta_cont_count] = {
|
||||||
|
{
|
||||||
|
.opaque = 16 * 4,
|
||||||
|
.opaque_modifier = 0,
|
||||||
|
.translucent = 16 * 4,
|
||||||
|
.translucent_modifier = 0,
|
||||||
|
.punch_through = 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
holly.SOFTRESET = softreset::pipeline_soft_reset
|
||||||
|
| softreset::ta_soft_reset;
|
||||||
|
holly.SOFTRESET = 0;
|
||||||
|
|
||||||
|
core_init();
|
||||||
|
|
||||||
|
system.IML6NRM = istnrm::end_of_render_tsp;
|
||||||
|
|
||||||
|
const int framebuffer_width = 640;
|
||||||
|
const int framebuffer_height = 480;
|
||||||
|
const int tile_width = framebuffer_width / 32;
|
||||||
|
const int tile_height = framebuffer_height / 32;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
region_array_multipass(tile_width,
|
||||||
|
tile_height,
|
||||||
|
opb_size,
|
||||||
|
ta_cont_count,
|
||||||
|
texture_memory_alloc.region_array[i].start,
|
||||||
|
texture_memory_alloc.object_list[i].start);
|
||||||
|
|
||||||
|
background_parameter2(texture_memory_alloc.background[i].start,
|
||||||
|
0xff202040);
|
||||||
|
}
|
||||||
|
|
||||||
|
ta_parameter_writer writer = ta_parameter_writer(ta_parameter_buf);
|
||||||
|
|
||||||
|
video_output::set_mode_vga();
|
||||||
|
|
||||||
|
int ta = 0;
|
||||||
|
int core = 0;
|
||||||
|
|
||||||
|
mat4x4 trans = {
|
||||||
|
1.0, 0.0, 0.000, -1400.0,
|
||||||
|
0.0, -0.574, -0.818, 981.0,
|
||||||
|
0.0, 0.818, -0.574, 711.0,
|
||||||
|
0.0, 0.000, 0.000, 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
do_get_condition();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
maple::dma_wait_complete();
|
||||||
|
do_get_condition();
|
||||||
|
|
||||||
|
trans = update_analog(trans);
|
||||||
|
|
||||||
|
ta_polygon_converter_init2(texture_memory_alloc.isp_tsp_parameters[ta].start,
|
||||||
|
texture_memory_alloc.isp_tsp_parameters[ta].end,
|
||||||
|
texture_memory_alloc.object_list[ta].start,
|
||||||
|
texture_memory_alloc.object_list[ta].end,
|
||||||
|
opb_size[0].total(),
|
||||||
|
ta_alloc,
|
||||||
|
tile_width,
|
||||||
|
tile_height);
|
||||||
|
|
||||||
|
writer.offset = 0;
|
||||||
|
transfer_scene(writer, trans);
|
||||||
|
ta_polygon_converter_writeback(writer.buf, writer.offset);
|
||||||
|
ta_polygon_converter_transfer(writer.buf, writer.offset);
|
||||||
|
ta_wait_translucent_list();
|
||||||
|
//ta_wait_opaque_list();
|
||||||
|
|
||||||
|
render_done = 0;
|
||||||
|
core_start_render2(texture_memory_alloc.region_array[core].start,
|
||||||
|
texture_memory_alloc.isp_tsp_parameters[core].start,
|
||||||
|
texture_memory_alloc.background[core].start,
|
||||||
|
texture_memory_alloc.framebuffer[core].start,
|
||||||
|
framebuffer_width);
|
||||||
|
while (render_done == 0) {
|
||||||
|
asm volatile ("nop");
|
||||||
|
};
|
||||||
|
|
||||||
|
while (spg_status::vsync(holly.SPG_STATUS));
|
||||||
|
while (!spg_status::vsync(holly.SPG_STATUS));
|
||||||
|
holly.FB_R_SOF1 = texture_memory_alloc.framebuffer[ta].start;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "../holly/holly.hpp"
|
#include "../holly/holly.hpp"
|
||||||
#include "../holly/core_bits.hpp"
|
#include "../holly/core_bits.hpp"
|
||||||
#include "../holly/texture_memory_alloc.hpp"
|
#include "../holly/texture_memory_alloc3.hpp"
|
||||||
#include "../holly/isp_tsp.hpp"
|
#include "../holly/isp_tsp.hpp"
|
||||||
#include "../holly/ta_parameter.hpp"
|
#include "../holly/ta_parameter.hpp"
|
||||||
#include "../holly/ta_global_parameter.hpp"
|
#include "../holly/ta_global_parameter.hpp"
|
||||||
@ -47,7 +47,7 @@ static inline void inflate_character(const uint32_t pitch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto texture = reinterpret_cast<volatile uint32_t *>(&texture_memory64[texture_memory_alloc::texture.start / 4]);
|
auto texture = reinterpret_cast<volatile uint32_t *>(&texture_memory64[texture_memory_alloc.texture.start / 4]);
|
||||||
|
|
||||||
uint8_t temp2[texture_width * texture_height / 2];
|
uint8_t temp2[texture_width * texture_height / 2];
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ void transform_string(ta_parameter_writer& parameter,
|
|||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
if (s[string_ix] == 0) break;
|
if (s[string_ix] == 0) break;
|
||||||
} else if (string_ix >= len) break;
|
} else if (string_ix >= len) break;
|
||||||
const uint32_t texture_address = texture_memory_alloc::texture.start;
|
const uint32_t texture_address = texture_memory_alloc.texture.start;
|
||||||
const uint32_t glyph_address = texture_address + texture_width * texture_height * (s[string_ix] - ' ') / 2;
|
const uint32_t glyph_address = texture_address + texture_width * texture_height * (s[string_ix] - ' ') / 2;
|
||||||
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
|
const uint32_t texture_control_word = texture_control_word::pixel_format::_4bpp_palette
|
||||||
| texture_control_word::scan_order::twiddled
|
| texture_control_word::scan_order::twiddled
|
||||||
|
145
interrupt.cpp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
#include "sh7091/sh7091.hpp"
|
||||||
|
#include "sh7091/sh7091_bits.hpp"
|
||||||
|
#include "sh7091/serial.hpp"
|
||||||
|
#include "sh7091/vbr.hpp"
|
||||||
|
|
||||||
|
#include "systembus.hpp"
|
||||||
|
#include "systembus_bits.hpp"
|
||||||
|
|
||||||
|
void vbr100()
|
||||||
|
{
|
||||||
|
serial::string("vbr100\n");
|
||||||
|
serial::string("expevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
||||||
|
serial::string("intevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
||||||
|
serial::string("tra ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
||||||
|
|
||||||
|
uint32_t spc;
|
||||||
|
uint32_t ssr;
|
||||||
|
asm volatile ("stc spc,%0" : "=r" (spc));
|
||||||
|
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
||||||
|
serial::string("spc ");
|
||||||
|
serial::integer(spc);
|
||||||
|
serial::string("ssr ");
|
||||||
|
serial::integer(ssr);
|
||||||
|
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vbr400()
|
||||||
|
{
|
||||||
|
serial::string("vbr400\n");
|
||||||
|
serial::string("expevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
||||||
|
serial::string("intevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
||||||
|
serial::string("tra ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
||||||
|
|
||||||
|
uint32_t spc;
|
||||||
|
uint32_t ssr;
|
||||||
|
asm volatile ("stc spc,%0" : "=r" (spc));
|
||||||
|
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
||||||
|
serial::string("spc ");
|
||||||
|
serial::integer(spc);
|
||||||
|
serial::string("ssr ");
|
||||||
|
serial::integer(ssr);
|
||||||
|
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int render_done = 0;
|
||||||
|
|
||||||
|
void vbr600()
|
||||||
|
{
|
||||||
|
if (sh7091.CCN.EXPEVT == 0 && sh7091.CCN.INTEVT == 0x320) {
|
||||||
|
uint32_t istnrm = system.ISTNRM;
|
||||||
|
uint32_t isterr = system.ISTERR;
|
||||||
|
|
||||||
|
if (isterr) {
|
||||||
|
serial::string("isterr: ");
|
||||||
|
serial::integer<uint32_t>(system.ISTERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (istnrm & istnrm::end_of_render_tsp) {
|
||||||
|
system.ISTNRM = istnrm::end_of_render_tsp
|
||||||
|
| istnrm::end_of_render_isp
|
||||||
|
| istnrm::end_of_render_video;
|
||||||
|
render_done = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serial::string("vbr600\n");
|
||||||
|
serial::string("expevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.EXPEVT);
|
||||||
|
serial::string("intevt ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.INTEVT);
|
||||||
|
serial::string("tra ");
|
||||||
|
serial::integer<uint16_t>(sh7091.CCN.TRA);
|
||||||
|
|
||||||
|
serial::string("istnrm: ");
|
||||||
|
serial::integer<uint32_t>(system.ISTNRM);
|
||||||
|
serial::string("isterr: ");
|
||||||
|
serial::integer<uint32_t>(system.ISTERR);
|
||||||
|
|
||||||
|
uint32_t spc;
|
||||||
|
uint32_t ssr;
|
||||||
|
asm volatile ("stc spc,%0" : "=r" (spc));
|
||||||
|
asm volatile ("stc ssr,%0" : "=r" (ssr));
|
||||||
|
serial::string("spc ");
|
||||||
|
serial::integer(spc);
|
||||||
|
serial::string("ssr ");
|
||||||
|
serial::integer(ssr);
|
||||||
|
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void interrupt_init()
|
||||||
|
{
|
||||||
|
system.IML2NRM = 0;
|
||||||
|
system.IML2ERR = 0;
|
||||||
|
system.IML2EXT = 0;
|
||||||
|
|
||||||
|
system.IML4NRM = 0;
|
||||||
|
system.IML4ERR = 0;
|
||||||
|
system.IML4EXT = 0;
|
||||||
|
|
||||||
|
system.IML6NRM = 0;
|
||||||
|
system.IML6ERR = 0;
|
||||||
|
system.IML6EXT = 0;
|
||||||
|
|
||||||
|
system.ISTERR = 0xffffffff;
|
||||||
|
system.ISTNRM = 0xffffffff;
|
||||||
|
|
||||||
|
sh7091.CCN.INTEVT = 0;
|
||||||
|
sh7091.CCN.EXPEVT = 0;
|
||||||
|
|
||||||
|
uint32_t vbr = reinterpret_cast<uint32_t>(&__vbr_link_start) - 0x100;
|
||||||
|
serial::string("vbr ");
|
||||||
|
serial::integer<uint32_t>(vbr);
|
||||||
|
serial::string("vbr100 ");
|
||||||
|
serial::integer<uint32_t>(reinterpret_cast<uint32_t>(&vbr100));
|
||||||
|
|
||||||
|
asm volatile ("ldc %0,vbr"
|
||||||
|
:
|
||||||
|
: "r" (vbr));
|
||||||
|
|
||||||
|
uint32_t sr;
|
||||||
|
asm volatile ("stc sr,%0"
|
||||||
|
: "=r" (sr));
|
||||||
|
serial::string("sr ");
|
||||||
|
serial::integer<uint32_t>(sr);
|
||||||
|
|
||||||
|
sr &= ~sh::sr::bl; // BL
|
||||||
|
sr &= ~sh::sr::imask(15); // imask
|
||||||
|
|
||||||
|
serial::string("sr ");
|
||||||
|
serial::integer<uint32_t>(sr);
|
||||||
|
|
||||||
|
asm volatile ("ldc %0,sr"
|
||||||
|
:
|
||||||
|
: "r" (sr));
|
||||||
|
}
|
5
interrupt.hpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern int render_done;
|
||||||
|
|
||||||
|
void interrupt_init();
|
78
model/icosphere/icosphere.obj
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# Blender 4.2.1 LTS
|
||||||
|
# www.blender.org
|
||||||
|
o Icosphere
|
||||||
|
v 0.000000 -1.000000 0.000000
|
||||||
|
v 0.723600 -0.447215 0.525720
|
||||||
|
v -0.276385 -0.447215 0.850640
|
||||||
|
v -0.894425 -0.447215 0.000000
|
||||||
|
v -0.276385 -0.447215 -0.850640
|
||||||
|
v 0.723600 -0.447215 -0.525720
|
||||||
|
v 0.276385 0.447215 0.850640
|
||||||
|
v -0.723600 0.447215 0.525720
|
||||||
|
v -0.723600 0.447215 -0.525720
|
||||||
|
v 0.276385 0.447215 -0.850640
|
||||||
|
v 0.894425 0.447215 0.000000
|
||||||
|
v 0.000000 1.000000 0.000000
|
||||||
|
vn 0.1876 -0.7947 0.5774
|
||||||
|
vn 0.6071 -0.7947 -0.0000
|
||||||
|
vn -0.4911 -0.7947 0.3568
|
||||||
|
vn -0.4911 -0.7947 -0.3568
|
||||||
|
vn 0.1876 -0.7947 -0.5774
|
||||||
|
vn 0.9822 -0.1876 -0.0000
|
||||||
|
vn 0.3035 -0.1876 0.9342
|
||||||
|
vn -0.7946 -0.1876 0.5774
|
||||||
|
vn -0.7946 -0.1876 -0.5774
|
||||||
|
vn 0.3035 -0.1876 -0.9342
|
||||||
|
vn 0.7946 0.1876 0.5774
|
||||||
|
vn -0.3035 0.1876 0.9342
|
||||||
|
vn -0.9822 0.1876 -0.0000
|
||||||
|
vn -0.3035 0.1876 -0.9342
|
||||||
|
vn 0.7946 0.1876 -0.5774
|
||||||
|
vn 0.4911 0.7947 0.3568
|
||||||
|
vn -0.1876 0.7947 0.5774
|
||||||
|
vn -0.6071 0.7947 -0.0000
|
||||||
|
vn -0.1876 0.7947 -0.5774
|
||||||
|
vn 0.4911 0.7947 -0.3568
|
||||||
|
vt 0.181819 0.000000
|
||||||
|
vt 0.272728 0.157461
|
||||||
|
vt 0.090910 0.157461
|
||||||
|
vt 0.363637 0.000000
|
||||||
|
vt 0.454546 0.157461
|
||||||
|
vt 0.909091 0.000000
|
||||||
|
vt 1.000000 0.157461
|
||||||
|
vt 0.818182 0.157461
|
||||||
|
vt 0.727273 0.000000
|
||||||
|
vt 0.636364 0.157461
|
||||||
|
vt 0.545455 0.000000
|
||||||
|
vt 0.363637 0.314921
|
||||||
|
vt 0.181819 0.314921
|
||||||
|
vt 0.909091 0.314921
|
||||||
|
vt 0.727273 0.314921
|
||||||
|
vt 0.545455 0.314921
|
||||||
|
vt 0.000000 0.314921
|
||||||
|
vt 0.272728 0.472382
|
||||||
|
vt 0.090910 0.472382
|
||||||
|
vt 0.818182 0.472382
|
||||||
|
vt 0.636364 0.472382
|
||||||
|
vt 0.454546 0.472382
|
||||||
|
s 0
|
||||||
|
f 1/1/1 2/2/1 3/3/1
|
||||||
|
f 2/2/2 1/4/2 6/5/2
|
||||||
|
f 1/6/3 3/7/3 4/8/3
|
||||||
|
f 1/9/4 4/8/4 5/10/4
|
||||||
|
f 1/11/5 5/10/5 6/5/5
|
||||||
|
f 2/2/6 6/5/6 11/12/6
|
||||||
|
f 3/3/7 2/2/7 7/13/7
|
||||||
|
f 4/8/8 3/7/8 8/14/8
|
||||||
|
f 5/10/9 4/8/9 9/15/9
|
||||||
|
f 6/5/10 5/10/10 10/16/10
|
||||||
|
f 2/2/11 11/12/11 7/13/11
|
||||||
|
f 3/3/12 7/13/12 8/17/12
|
||||||
|
f 4/8/13 8/14/13 9/15/13
|
||||||
|
f 5/10/14 9/15/14 10/16/14
|
||||||
|
f 6/5/15 10/16/15 11/12/15
|
||||||
|
f 7/13/16 11/12/16 12/18/16
|
||||||
|
f 8/17/17 7/13/17 12/19/17
|
||||||
|
f 9/15/18 8/14/18 12/20/18
|
||||||
|
f 10/16/19 9/15/19 12/21/19
|
||||||
|
f 11/12/20 10/16/20 12/22/20
|
42
pk/gen.sh
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
declare -a textures=(
|
||||||
|
"textures/common/caulk"
|
||||||
|
"textures/e7/e7walldesign01b"
|
||||||
|
"textures/e7/e7steptop2"
|
||||||
|
"noshader"
|
||||||
|
"textures/e7/e7dimfloor"
|
||||||
|
"textures/e7/e7brickfloor01"
|
||||||
|
"textures/e7/e7bmtrim"
|
||||||
|
"textures/e7/e7sbrickfloor"
|
||||||
|
"textures/e7/e7brnmetal"
|
||||||
|
"textures/common/clip"
|
||||||
|
"textures/e7/e7beam02_red"
|
||||||
|
"textures/e7/e7swindow"
|
||||||
|
"textures/e7/e7bigwall"
|
||||||
|
"textures/e7/e7panelwood"
|
||||||
|
"textures/e7/e7beam01"
|
||||||
|
"textures/gothic_floor/xstepborder5"
|
||||||
|
"textures/liquids/lavahell"
|
||||||
|
"textures/e7/e7steptop"
|
||||||
|
"textures/gothic_trim/metalblackwave01"
|
||||||
|
"textures/stone/pjrock1"
|
||||||
|
"textures/skies/tim_hell"
|
||||||
|
"textures/common/hint"
|
||||||
|
"models/mapobjects/timlamp/timlamp"
|
||||||
|
"textures/sfx/flame1side"
|
||||||
|
"textures/sfx/flame2"
|
||||||
|
"models/mapobjects/gratelamp/gratetorch2"
|
||||||
|
"models/mapobjects/gratelamp/gratetorch2b"
|
||||||
|
)
|
||||||
|
|
||||||
|
for t in "${textures[@]}"
|
||||||
|
do
|
||||||
|
filename=$(ls "$t".{tga,jpg} 2>/dev/null)
|
||||||
|
if [ -z $filename ]; then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
name="${filename%.*}"
|
||||||
|
data_name="${name}.data"
|
||||||
|
echo $data_name
|
||||||
|
python ~/model_generator/color_convert.py $filename rgb565 non_twiddled $data_name
|
||||||
|
(cd .. ; make pk/${data_name}.h)
|
||||||
|
done
|
1
pk/generate.py
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../regs/gen/generate.py
|
BIN
pk/levelshots/20kdm2.tga
Normal file
BIN
pk/map-20kdm2.pk3
Normal file
BIN
pk/maps/20kdm2.aas
Normal file
BIN
pk/maps/20kdm2.bsp
Normal file
15
pk/maps/20kdm2.bsp.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_maps_20kdm2_bsp_start __asm("_binary_pk_maps_20kdm2_bsp_start");
|
||||||
|
extern uint32_t _binary_pk_maps_20kdm2_bsp_end __asm("_binary_pk_maps_20kdm2_bsp_end");
|
||||||
|
extern uint32_t _binary_pk_maps_20kdm2_bsp_size __asm("_binary_pk_maps_20kdm2_bsp_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/models/mapobjects/gratelamp/gratetorch2.data
Normal file
15
pk/models/mapobjects/gratelamp/gratetorch2.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_gratelamp_gratetorch2_data_start __asm("_binary_pk_models_mapobjects_gratelamp_gratetorch2_data_start");
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_gratelamp_gratetorch2_data_end __asm("_binary_pk_models_mapobjects_gratelamp_gratetorch2_data_end");
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_gratelamp_gratetorch2_data_size __asm("_binary_pk_models_mapobjects_gratelamp_gratetorch2_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/models/mapobjects/gratelamp/gratetorch2.jpg
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
pk/models/mapobjects/gratelamp/gratetorch2b.data
Normal file
15
pk/models/mapobjects/gratelamp/gratetorch2b.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_start __asm("_binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_start");
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_end __asm("_binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_end");
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_size __asm("_binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/models/mapobjects/gratelamp/gratetorch2b.tga
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
pk/models/mapobjects/timlamp/timlamp.data
Normal file
15
pk/models/mapobjects/timlamp/timlamp.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_timlamp_timlamp_data_start __asm("_binary_pk_models_mapobjects_timlamp_timlamp_data_start");
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_timlamp_timlamp_data_end __asm("_binary_pk_models_mapobjects_timlamp_timlamp_data_end");
|
||||||
|
extern uint32_t _binary_pk_models_mapobjects_timlamp_timlamp_data_size __asm("_binary_pk_models_mapobjects_timlamp_timlamp_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/models/mapobjects/timlamp/timlamp.tga
Normal file
After Width: | Height: | Size: 64 KiB |
7
pk/scripts/20kdm2.arena
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
map "20kdm2"
|
||||||
|
bots "Wrack"
|
||||||
|
longname "Return to Castle: Quake"
|
||||||
|
fraglimit 20
|
||||||
|
type "ffa tourney"
|
||||||
|
}
|
11
pk/scripts/common.shader
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
textures/common/clip
|
||||||
|
{
|
||||||
|
qer_trans 0.40
|
||||||
|
surfaceparm nolightmap
|
||||||
|
surfaceparm nomarks
|
||||||
|
surfaceparm nodraw
|
||||||
|
surfaceparm nonsolid
|
||||||
|
//surfaceparm nolightmap //proto_addition 11/08/99
|
||||||
|
surfaceparm playerclip
|
||||||
|
surfaceparm noimpact
|
||||||
|
}
|
274
pk/scripts/e7.shader
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
// e7 shaders by Yves Allaire aka evil lair//
|
||||||
|
// http://www.planetquake.com/hfx //
|
||||||
|
// hfx@planetquake.com //
|
||||||
|
|
||||||
|
//evil jump pad
|
||||||
|
|
||||||
|
textures/e7/e7brickfloor01jump
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7brickfloor01jump.tga
|
||||||
|
q3map_lightimage textures/e7/e7brickfloor01jump_glow.tga
|
||||||
|
surfaceparm nomarks
|
||||||
|
q3map_surfacelight 400
|
||||||
|
{
|
||||||
|
map textures/e7/e7brickfloor01jump.tga
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7brickfloor01jump_glow.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen wave sin 0.5 0.8 0 1.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textures/e7/e7mlight
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7mlight.tga
|
||||||
|
q3map_lightimage textures/e7/e7mlight.blend.tga
|
||||||
|
surfaceparm nomarks
|
||||||
|
q3map_surfacelight 1500
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7mlight.tga
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7mlight.blend.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//small light
|
||||||
|
|
||||||
|
textures/e7/e7slight
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7slight.tga
|
||||||
|
q3map_lightimage textures/e7/e7slight.blend.tga
|
||||||
|
surfaceparm nomarks
|
||||||
|
q3map_surfacelight 2500
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7slight.tga
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7slight.blend.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textures/e7/e7trimlight
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7trimlight.tga
|
||||||
|
q3map_lightimage textures/e7/e7trimlight.blend.tga
|
||||||
|
surfaceparm nomarks
|
||||||
|
q3map_surfacelight 700
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7trimlight.tga
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7trimlight.blend.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//evilgrate
|
||||||
|
|
||||||
|
textures/e7/e7wgrate
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7wgrate.tga
|
||||||
|
surfaceparm alphashadow
|
||||||
|
surfaceparm nomarks
|
||||||
|
surfaceparm metalsteps
|
||||||
|
surfaceparm trans
|
||||||
|
cull disable
|
||||||
|
nopicmip
|
||||||
|
{
|
||||||
|
map textures/e7/e7wgrate.tga
|
||||||
|
rgbGen identity
|
||||||
|
depthWrite
|
||||||
|
alphaFunc GE128
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
depthFunc equal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// evil lava - sorta looks bad ingame - imho
|
||||||
|
|
||||||
|
textures/e7/e7sfx_lava
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7sfx_lava.tga
|
||||||
|
surfaceparm lava
|
||||||
|
surfaceparm noimpact
|
||||||
|
surfaceparm nolightmap
|
||||||
|
surfaceparm trans
|
||||||
|
cull disable
|
||||||
|
deformVertexes wave 100 sin 3 2 0.1 0.1
|
||||||
|
tessSize 128
|
||||||
|
q3map_surfacelight 1500
|
||||||
|
q3map_globaltexture
|
||||||
|
{
|
||||||
|
map textures/e7/e7sfx_lava.tga
|
||||||
|
rgbGen identity
|
||||||
|
tcMod turb 0 0.2 0 0.08
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//evil sky of impending doom :P
|
||||||
|
|
||||||
|
textures/e7/e7evilsky_1
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7evilsky_1.tga
|
||||||
|
surfaceparm noimpact
|
||||||
|
surfaceparm nolightmap
|
||||||
|
surfaceparm nomarks
|
||||||
|
q3map_surfacelight 200
|
||||||
|
q3map_sun 0.9 0.9 1 60 65 68
|
||||||
|
skyParms - 512 -
|
||||||
|
{
|
||||||
|
map textures/e7/e7evilsky_1.tga
|
||||||
|
rgbGen identity
|
||||||
|
tcMod scroll 0.05 0.1
|
||||||
|
tcMod scale 2 2
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7evilsky_2.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
tcMod scroll 0.08 -0.06
|
||||||
|
tcMod scale 3 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textures/e7/e7rain
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7rain.tga
|
||||||
|
surfaceparm nolightmap
|
||||||
|
surfaceparm nomarks
|
||||||
|
surfaceparm nonsolid
|
||||||
|
surfaceparm trans
|
||||||
|
cull disable
|
||||||
|
deformVertexes move 3 1 0 sin 0 5 0 0.2
|
||||||
|
deformVertexes move 0.6 3.3 0 sin 0 5 0 0.4
|
||||||
|
deformVertexes wave 30 sin 0 10 0 0.2
|
||||||
|
qer_trans 0.5
|
||||||
|
{
|
||||||
|
map textures/e7/e7rain.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
tcMod scroll 0.5 -8
|
||||||
|
tcMod turb 0.1 0.25 0 -0.1
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7rain.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
tcMod scroll 0.01 -6.3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//dark redish sky
|
||||||
|
|
||||||
|
textures/e7/e7sky_01
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7sky_01.tga
|
||||||
|
surfaceparm noimpact
|
||||||
|
surfaceparm nolightmap
|
||||||
|
q3map_sun .9 .9 1 65 65 68
|
||||||
|
q3map_surfacelight 150
|
||||||
|
skyparms - 512 -
|
||||||
|
{
|
||||||
|
map textures/e7/e7sky_01.tga
|
||||||
|
rgbGen identity
|
||||||
|
tcMod scroll 0.05 0.03
|
||||||
|
tcMod scale 2 2
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7sky_02.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen identity
|
||||||
|
tcMod scroll 0.01 0.02
|
||||||
|
tcMod scale 3 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//jump pad 2
|
||||||
|
|
||||||
|
textures/e7/e7sbrickfloor_jump
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7sbrickfloor_jump.tga
|
||||||
|
q3map_lightimage textures/e7/e7sbrickfloor_jump_glow.tga
|
||||||
|
surfaceparm nomarks
|
||||||
|
q3map_surfacelight 400
|
||||||
|
{
|
||||||
|
map textures/e7/e7sbrickfloor_jump.tga
|
||||||
|
rgbGen identity
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/e7/e7sbrickfloor_jump_glow.tga
|
||||||
|
blendfunc add
|
||||||
|
rgbGen wave sin 0.5 0.8 0 1.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//small grate
|
||||||
|
|
||||||
|
textures/e7/e7smgrate
|
||||||
|
{
|
||||||
|
qer_editorimage textures/e7/e7smgrate.tga
|
||||||
|
surfaceparm alphashadow
|
||||||
|
surfaceparm metalsteps
|
||||||
|
//surfaceparm trans
|
||||||
|
cull disable
|
||||||
|
nopicmip
|
||||||
|
{
|
||||||
|
map textures/e7/e7smgrate.tga
|
||||||
|
rgbGen identity
|
||||||
|
depthWrite
|
||||||
|
alphaFunc GE128
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map $lightmap
|
||||||
|
blendfunc filter
|
||||||
|
rgbGen identity
|
||||||
|
tcGen lightmap
|
||||||
|
depthFunc equal
|
||||||
|
}
|
||||||
|
}
|
26
pk/scripts/liquid.shader
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
textures/liquids/lavahell
|
||||||
|
{
|
||||||
|
// Added to g3map_global texture on May 11, 1999
|
||||||
|
q3map_globaltexture
|
||||||
|
surfaceparm trans
|
||||||
|
//surfaceparm nonsolid
|
||||||
|
surfaceparm noimpact
|
||||||
|
surfaceparm lava
|
||||||
|
surfaceparm nolightmap
|
||||||
|
q3map_surfacelight 600
|
||||||
|
cull disable
|
||||||
|
|
||||||
|
tesssize 128
|
||||||
|
cull disable
|
||||||
|
deformVertexes wave 100 sin 3 2 .1 0.1
|
||||||
|
|
||||||
|
{
|
||||||
|
map textures/liquids/lavahell.tga
|
||||||
|
tcMod turb 0 .2 0 .1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// END
|
||||||
|
}
|
45
pk/scripts/models.shader
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
models/mapobjects/timlamp/timlamp
|
||||||
|
{
|
||||||
|
cull disable
|
||||||
|
surfaceparm alphashadow
|
||||||
|
{
|
||||||
|
map models/mapobjects/timlamp/timlamp.tga
|
||||||
|
alphaFunc GE128
|
||||||
|
depthWrite
|
||||||
|
rgbGen vertex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
models/mapobjects/gratelamp/gratetorch2b
|
||||||
|
{
|
||||||
|
cull disable
|
||||||
|
{
|
||||||
|
map models/mapobjects/gratelamp/gratetorch2b.tga
|
||||||
|
alphaFunc GE128
|
||||||
|
depthWrite
|
||||||
|
rgbGen vertex
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
models/mapobjects/wallhead/lion_m
|
||||||
|
{
|
||||||
|
{
|
||||||
|
map models/mapobjects/wallhead/lion_m.tga
|
||||||
|
blendFunc GL_ONE GL_ZERO
|
||||||
|
rgbGen vertex
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/sfx/firewalla.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
tcmod scroll 0.1 1
|
||||||
|
//rgbGen wave triangle .5 1 0 .4
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map models/mapobjects/wallhead/lion_m.tga
|
||||||
|
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||||
|
rgbGen vertex
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
71
pk/scripts/sfx.shader
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
textures/sfx/flame1side
|
||||||
|
{
|
||||||
|
|
||||||
|
// *************************************************
|
||||||
|
// * Yellow Flame Side *
|
||||||
|
// * April 30 1999 *
|
||||||
|
// * Please Comment Changes *
|
||||||
|
// *************************************************
|
||||||
|
|
||||||
|
surfaceparm trans
|
||||||
|
surfaceparm nomarks
|
||||||
|
surfaceparm nonsolid
|
||||||
|
|
||||||
|
surfaceparm nolightmap
|
||||||
|
cull none
|
||||||
|
|
||||||
|
{
|
||||||
|
animMap 10 textures/sfx/flame1.tga textures/sfx/flame2.tga textures/sfx/flame3.tga textures/sfx/flame4.tga textures/sfx/flame5.tga textures/sfx/flame6.tga textures/sfx/flame7.tga textures/sfx/flame8.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
rgbGen wave inverseSawtooth 0 1 0 10
|
||||||
|
|
||||||
|
}
|
||||||
|
{
|
||||||
|
animMap 10 textures/sfx/flame2.tga textures/sfx/flame3.tga textures/sfx/flame4.tga textures/sfx/flame5.tga textures/sfx/flame6.tga textures/sfx/flame7.tga textures/sfx/flame8.tga textures/sfx/flame1.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
rgbGen wave sawtooth 0 1 0 10
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
map textures/sfx/flameball.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
rgbGen wave sin .6 .2 0 .6
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
textures/sfx/flame2
|
||||||
|
{
|
||||||
|
|
||||||
|
// *************************************************
|
||||||
|
// * Yellow Flame Surface Light 5500 *
|
||||||
|
// * April 30 1999 *
|
||||||
|
// * Please Comment Changes *
|
||||||
|
// *************************************************
|
||||||
|
|
||||||
|
surfaceparm nomarks
|
||||||
|
surfaceparm nolightmap
|
||||||
|
cull none
|
||||||
|
q3map_surfacelight 5500
|
||||||
|
qer_editorimage textures/sfx/flame1.tga
|
||||||
|
|
||||||
|
{
|
||||||
|
animMap 10 textures/sfx/flame1.tga textures/sfx/flame2.tga textures/sfx/flame3.tga textures/sfx/flame4.tga textures/sfx/flame5.tga textures/sfx/flame6.tga textures/sfx/flame7.tga textures/sfx/flame8.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
rgbGen wave inverseSawtooth 0 1 0 10
|
||||||
|
|
||||||
|
}
|
||||||
|
{
|
||||||
|
animMap 10 textures/sfx/flame2.tga textures/sfx/flame3.tga textures/sfx/flame4.tga textures/sfx/flame5.tga textures/sfx/flame6.tga textures/sfx/flame7.tga textures/sfx/flame8.tga textures/sfx/flame1.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
rgbGen wave sawtooth 0 1 0 10
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
map textures/sfx/flameball.tga
|
||||||
|
blendFunc GL_ONE GL_ONE
|
||||||
|
rgbGen wave sin .6 .2 0 .6
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
pk/scripts/sky.shader
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
textures/skies/tim_hell
|
||||||
|
{
|
||||||
|
qer_editorimage textures/skies/stars_red.tga
|
||||||
|
surfaceparm noimpact
|
||||||
|
surfaceparm nomarks
|
||||||
|
surfaceparm nolightmap
|
||||||
|
surfaceparm sky
|
||||||
|
|
||||||
|
q3map_sun 1 .77 .77 80 315 70
|
||||||
|
//q3map_sun .5 .37 .19 80 315 70
|
||||||
|
|
||||||
|
//q3map_sun 1 .37 .19 85 30 70
|
||||||
|
q3map_surfacelight 130
|
||||||
|
skyparms - 384 -
|
||||||
|
|
||||||
|
//cloudparms 512 full
|
||||||
|
//lightning
|
||||||
|
|
||||||
|
{
|
||||||
|
map textures/skies/killsky_1.tga
|
||||||
|
tcMod scroll 0.05 .1
|
||||||
|
tcMod scale 2 2
|
||||||
|
depthWrite
|
||||||
|
}
|
||||||
|
{
|
||||||
|
map textures/skies/killsky_2.tga
|
||||||
|
blendfunc GL_ONE GL_ONE
|
||||||
|
tcMod scroll 0.05 0.06
|
||||||
|
tcMod scale 3 2
|
||||||
|
}
|
||||||
|
}
|
17
pk/texture.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct pk_texture {
|
||||||
|
void * start;
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t offset;
|
||||||
|
int16_t width;
|
||||||
|
int16_t height;
|
||||||
|
//float u_mul;
|
||||||
|
float v_mul;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pk_texture textures[] = {
|
||||||
|
#include "texture.inc"
|
||||||
|
};
|
216
pk/texture.inc
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
{
|
||||||
|
.start = (void *)0,
|
||||||
|
.size = (uint32_t)0,
|
||||||
|
.offset = 0,
|
||||||
|
.width = 0,
|
||||||
|
.height = 0,
|
||||||
|
.v_mul = 0, // 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7walldesign01b_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7walldesign01b_data_size,
|
||||||
|
.offset = 0,
|
||||||
|
.width = 256,
|
||||||
|
.height = 1024,
|
||||||
|
.v_mul = 0.625, // 640
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7steptop2_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7steptop2_data_size,
|
||||||
|
.offset = 163840,
|
||||||
|
.width = 256,
|
||||||
|
.height = 32,
|
||||||
|
.v_mul = 1.0, // 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)0,
|
||||||
|
.size = (uint32_t)0,
|
||||||
|
.offset = 172032,
|
||||||
|
.width = 0,
|
||||||
|
.height = 0,
|
||||||
|
.v_mul = 0, // 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7dimfloor_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7dimfloor_data_size,
|
||||||
|
.offset = 172032,
|
||||||
|
.width = 128,
|
||||||
|
.height = 128,
|
||||||
|
.v_mul = 1.0, // 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7brickfloor01_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7brickfloor01_data_size,
|
||||||
|
.offset = 188416,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7bmtrim_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7bmtrim_data_size,
|
||||||
|
.offset = 253952,
|
||||||
|
.width = 256,
|
||||||
|
.height = 64,
|
||||||
|
.v_mul = 1.0, // 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7sbrickfloor_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7sbrickfloor_data_size,
|
||||||
|
.offset = 270336,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7brnmetal_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7brnmetal_data_size,
|
||||||
|
.offset = 335872,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)0,
|
||||||
|
.size = (uint32_t)0,
|
||||||
|
.offset = 401408,
|
||||||
|
.width = 0,
|
||||||
|
.height = 0,
|
||||||
|
.v_mul = 0, // 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7beam02_red_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7beam02_red_data_size,
|
||||||
|
.offset = 401408,
|
||||||
|
.width = 64,
|
||||||
|
.height = 128,
|
||||||
|
.v_mul = 1.0, // 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7swindow_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7swindow_data_size,
|
||||||
|
.offset = 409600,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7bigwall_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7bigwall_data_size,
|
||||||
|
.offset = 475136,
|
||||||
|
.width = 256,
|
||||||
|
.height = 1024,
|
||||||
|
.v_mul = 0.75, // 768
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7panelwood_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7panelwood_data_size,
|
||||||
|
.offset = 671744,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7beam01_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7beam01_data_size,
|
||||||
|
.offset = 737280,
|
||||||
|
.width = 64,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_gothic_floor_xstepborder5_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_gothic_floor_xstepborder5_data_size,
|
||||||
|
.offset = 753664,
|
||||||
|
.width = 256,
|
||||||
|
.height = 64,
|
||||||
|
.v_mul = 0.78125, // 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_liquids_lavahell_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_liquids_lavahell_data_size,
|
||||||
|
.offset = 766464,
|
||||||
|
.width = 128,
|
||||||
|
.height = 128,
|
||||||
|
.v_mul = 1.0, // 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_e7_e7steptop_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_e7_e7steptop_data_size,
|
||||||
|
.offset = 782848,
|
||||||
|
.width = 256,
|
||||||
|
.height = 32,
|
||||||
|
.v_mul = 1.0, // 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_gothic_trim_metalblackwave01_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_gothic_trim_metalblackwave01_data_size,
|
||||||
|
.offset = 791040,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_stone_pjrock1_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_stone_pjrock1_data_size,
|
||||||
|
.offset = 856576,
|
||||||
|
.width = 256,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)0,
|
||||||
|
.size = (uint32_t)0,
|
||||||
|
.offset = 922112,
|
||||||
|
.width = 0,
|
||||||
|
.height = 0,
|
||||||
|
.v_mul = 0, // 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)0,
|
||||||
|
.size = (uint32_t)0,
|
||||||
|
.offset = 922112,
|
||||||
|
.width = 0,
|
||||||
|
.height = 0,
|
||||||
|
.v_mul = 0, // 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_models_mapobjects_timlamp_timlamp_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_models_mapobjects_timlamp_timlamp_data_size,
|
||||||
|
.offset = 922112,
|
||||||
|
.width = 128,
|
||||||
|
.height = 128,
|
||||||
|
.v_mul = 1.0, // 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)0,
|
||||||
|
.size = (uint32_t)0,
|
||||||
|
.offset = 938496,
|
||||||
|
.width = 0,
|
||||||
|
.height = 0,
|
||||||
|
.v_mul = 0, // 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_textures_sfx_flame2_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_textures_sfx_flame2_data_size,
|
||||||
|
.offset = 938496,
|
||||||
|
.width = 128,
|
||||||
|
.height = 256,
|
||||||
|
.v_mul = 1.0, // 256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_models_mapobjects_gratelamp_gratetorch2_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_models_mapobjects_gratelamp_gratetorch2_data_size,
|
||||||
|
.offset = 971264,
|
||||||
|
.width = 32,
|
||||||
|
.height = 64,
|
||||||
|
.v_mul = 1.0, // 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.start = (void *)&_binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_start,
|
||||||
|
.size = (uint32_t)&_binary_pk_models_mapobjects_gratelamp_gratetorch2b_data_size,
|
||||||
|
.offset = 973312,
|
||||||
|
.width = 32,
|
||||||
|
.height = 64,
|
||||||
|
.v_mul = 1.0, // 64
|
||||||
|
},
|
103
pk/texture_gen.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
from PIL import Image
|
||||||
|
import sys
|
||||||
|
from glob import glob
|
||||||
|
from generate import renderer
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
def read_texture_names():
|
||||||
|
buf = sys.stdin.read()
|
||||||
|
lines = buf.strip().split('\n')
|
||||||
|
return lines
|
||||||
|
|
||||||
|
def glob_and_filter(name):
|
||||||
|
filenames = glob(f"{name}.tga") + glob(f"{name}.jpg")
|
||||||
|
assert len(filenames) in {0, 1}
|
||||||
|
filename = filenames[0] if filenames else None
|
||||||
|
return filename
|
||||||
|
|
||||||
|
def image_size(filename):
|
||||||
|
if filename is None:
|
||||||
|
return (0, 0)
|
||||||
|
with Image.open(filename) as im:
|
||||||
|
return im.size
|
||||||
|
|
||||||
|
def npot(v):
|
||||||
|
v -= 1
|
||||||
|
v |= v >> 1
|
||||||
|
v |= v >> 2
|
||||||
|
v |= v >> 4
|
||||||
|
v |= v >> 8
|
||||||
|
v |= v >> 16
|
||||||
|
v += 1
|
||||||
|
return v
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Size:
|
||||||
|
w: int
|
||||||
|
h: int
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Texture:
|
||||||
|
name: str
|
||||||
|
filename: str
|
||||||
|
real_size: Size
|
||||||
|
npot_size: Size
|
||||||
|
offset: int
|
||||||
|
|
||||||
|
def texture_metadata():
|
||||||
|
names = read_texture_names()
|
||||||
|
acc = 0
|
||||||
|
for name in names:
|
||||||
|
filename = glob_and_filter(name)
|
||||||
|
w, h = image_size(filename)
|
||||||
|
nw, nh = npot(w), npot(h)
|
||||||
|
|
||||||
|
yield Texture(
|
||||||
|
name,
|
||||||
|
filename,
|
||||||
|
Size(w, h),
|
||||||
|
Size(nw, nh),
|
||||||
|
acc
|
||||||
|
)
|
||||||
|
|
||||||
|
acc += nw * h
|
||||||
|
|
||||||
|
def name_to_bin(filename):
|
||||||
|
if filename is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
name, ext = path.splitext(filename)
|
||||||
|
return "_binary_pk_" + name.replace('/', '_').replace('.', '_') + "_data"
|
||||||
|
|
||||||
|
def uv_mul(texture):
|
||||||
|
u = 0 if texture.npot_size.w == 0 else texture.real_size.w / texture.npot_size.w
|
||||||
|
v = 0 if texture.npot_size.h == 0 else texture.real_size.h / texture.npot_size.h
|
||||||
|
return u, v
|
||||||
|
|
||||||
|
def render_texture_metadata(texture):
|
||||||
|
name = name_to_bin(texture.filename)
|
||||||
|
u, v = uv_mul(texture)
|
||||||
|
assert u == 1.0 or u == 0.0
|
||||||
|
start = "0" if name is None else f"&{name}_start"
|
||||||
|
size = "0" if name is None else f"&{name}_size"
|
||||||
|
yield "{"
|
||||||
|
yield f".start = (void *){start},"
|
||||||
|
yield f".size = (uint32_t){size},"
|
||||||
|
yield f".offset = {texture.offset},"
|
||||||
|
yield f".width = {texture.npot_size.w},"
|
||||||
|
yield f".height = {texture.npot_size.h},"
|
||||||
|
#yield f".u_mul = {u}, // {texture.real_size.w}"
|
||||||
|
yield f".v_mul = {v}, // {texture.real_size.h}"
|
||||||
|
yield "},"
|
||||||
|
|
||||||
|
def render_texture_metadatas():
|
||||||
|
for texture in texture_metadata():
|
||||||
|
yield from render_texture_metadata(texture)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
render, out = renderer()
|
||||||
|
render(render_texture_metadatas())
|
||||||
|
sys.stdout.write(out.getvalue())
|
||||||
|
|
||||||
|
main()
|
27
pk/textures.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
textures/common/caulk
|
||||||
|
textures/e7/e7walldesign01b
|
||||||
|
textures/e7/e7steptop2
|
||||||
|
noshader
|
||||||
|
textures/e7/e7dimfloor
|
||||||
|
textures/e7/e7brickfloor01
|
||||||
|
textures/e7/e7bmtrim
|
||||||
|
textures/e7/e7sbrickfloor
|
||||||
|
textures/e7/e7brnmetal
|
||||||
|
textures/common/clip
|
||||||
|
textures/e7/e7beam02_red
|
||||||
|
textures/e7/e7swindow
|
||||||
|
textures/e7/e7bigwall
|
||||||
|
textures/e7/e7panelwood
|
||||||
|
textures/e7/e7beam01
|
||||||
|
textures/gothic_floor/xstepborder5
|
||||||
|
textures/liquids/lavahell
|
||||||
|
textures/e7/e7steptop
|
||||||
|
textures/gothic_trim/metalblackwave01
|
||||||
|
textures/stone/pjrock1
|
||||||
|
textures/skies/tim_hell
|
||||||
|
textures/common/hint
|
||||||
|
models/mapobjects/timlamp/timlamp
|
||||||
|
textures/sfx/flame1side
|
||||||
|
textures/sfx/flame2
|
||||||
|
models/mapobjects/gratelamp/gratetorch2
|
||||||
|
models/mapobjects/gratelamp/gratetorch2b
|
1
pk/textures/e7/e7beam01.data
Normal file
15
pk/textures/e7/e7beam01.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7beam01_data_start __asm("_binary_pk_textures_e7_e7beam01_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7beam01_data_end __asm("_binary_pk_textures_e7_e7beam01_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7beam01_data_size __asm("_binary_pk_textures_e7_e7beam01_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7beam01.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
pk/textures/e7/e7beam02_red.data
Normal file
15
pk/textures/e7/e7beam02_red.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7beam02_red_data_start __asm("_binary_pk_textures_e7_e7beam02_red_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7beam02_red_data_end __asm("_binary_pk_textures_e7_e7beam02_red_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7beam02_red_data_size __asm("_binary_pk_textures_e7_e7beam02_red_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7beam02_red.jpg
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
pk/textures/e7/e7bigwall.data
Normal file
15
pk/textures/e7/e7bigwall.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7bigwall_data_start __asm("_binary_pk_textures_e7_e7bigwall_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7bigwall_data_end __asm("_binary_pk_textures_e7_e7bigwall_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7bigwall_data_size __asm("_binary_pk_textures_e7_e7bigwall_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7bigwall.jpg
Normal file
After Width: | Height: | Size: 217 KiB |
BIN
pk/textures/e7/e7bmtrim.data
Normal file
15
pk/textures/e7/e7bmtrim.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7bmtrim_data_start __asm("_binary_pk_textures_e7_e7bmtrim_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7bmtrim_data_end __asm("_binary_pk_textures_e7_e7bmtrim_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7bmtrim_data_size __asm("_binary_pk_textures_e7_e7bmtrim_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7bmtrim.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
pk/textures/e7/e7bmtrim2.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
pk/textures/e7/e7brickfloor01.data
Normal file
15
pk/textures/e7/e7brickfloor01.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7brickfloor01_data_start __asm("_binary_pk_textures_e7_e7brickfloor01_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7brickfloor01_data_end __asm("_binary_pk_textures_e7_e7brickfloor01_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7brickfloor01_data_size __asm("_binary_pk_textures_e7_e7brickfloor01_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7brickfloor01.jpg
Normal file
After Width: | Height: | Size: 95 KiB |
1
pk/textures/e7/e7brnmetal.data
Normal file
15
pk/textures/e7/e7brnmetal.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7brnmetal_data_start __asm("_binary_pk_textures_e7_e7brnmetal_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7brnmetal_data_end __asm("_binary_pk_textures_e7_e7brnmetal_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7brnmetal_data_size __asm("_binary_pk_textures_e7_e7brnmetal_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7brnmetal.jpg
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
pk/textures/e7/e7dimfloor.data
Normal file
15
pk/textures/e7/e7dimfloor.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7dimfloor_data_start __asm("_binary_pk_textures_e7_e7dimfloor_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7dimfloor_data_end __asm("_binary_pk_textures_e7_e7dimfloor_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7dimfloor_data_size __asm("_binary_pk_textures_e7_e7dimfloor_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7dimfloor.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
1233
pk/textures/e7/e7panelwood.data
Normal file
15
pk/textures/e7/e7panelwood.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7panelwood_data_start __asm("_binary_pk_textures_e7_e7panelwood_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7panelwood_data_end __asm("_binary_pk_textures_e7_e7panelwood_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7panelwood_data_size __asm("_binary_pk_textures_e7_e7panelwood_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7panelwood.jpg
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
pk/textures/e7/e7sbrickfloor.data
Normal file
15
pk/textures/e7/e7sbrickfloor.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7sbrickfloor_data_start __asm("_binary_pk_textures_e7_e7sbrickfloor_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7sbrickfloor_data_end __asm("_binary_pk_textures_e7_e7sbrickfloor_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7sbrickfloor_data_size __asm("_binary_pk_textures_e7_e7sbrickfloor_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7sbrickfloor.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
1
pk/textures/e7/e7steptop.data
Normal file
15
pk/textures/e7/e7steptop.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7steptop_data_start __asm("_binary_pk_textures_e7_e7steptop_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7steptop_data_end __asm("_binary_pk_textures_e7_e7steptop_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7steptop_data_size __asm("_binary_pk_textures_e7_e7steptop_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7steptop.jpg
Normal file
After Width: | Height: | Size: 9.6 KiB |
1
pk/textures/e7/e7steptop2.data
Normal file
15
pk/textures/e7/e7steptop2.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7steptop2_data_start __asm("_binary_pk_textures_e7_e7steptop2_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7steptop2_data_end __asm("_binary_pk_textures_e7_e7steptop2_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7steptop2_data_size __asm("_binary_pk_textures_e7_e7steptop2_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7steptop2.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
pk/textures/e7/e7swindow.data
Normal file
15
pk/textures/e7/e7swindow.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7swindow_data_start __asm("_binary_pk_textures_e7_e7swindow_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7swindow_data_end __asm("_binary_pk_textures_e7_e7swindow_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7swindow_data_size __asm("_binary_pk_textures_e7_e7swindow_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7swindow.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
pk/textures/e7/e7walldesign01b.data
Normal file
15
pk/textures/e7/e7walldesign01b.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7walldesign01b_data_start __asm("_binary_pk_textures_e7_e7walldesign01b_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7walldesign01b_data_end __asm("_binary_pk_textures_e7_e7walldesign01b_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_e7_e7walldesign01b_data_size __asm("_binary_pk_textures_e7_e7walldesign01b_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/e7/e7walldesign01b.jpg
Normal file
After Width: | Height: | Size: 124 KiB |
BIN
pk/textures/gothic_floor/xstepborder5.data
Normal file
15
pk/textures/gothic_floor/xstepborder5.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_gothic_floor_xstepborder5_data_start __asm("_binary_pk_textures_gothic_floor_xstepborder5_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_gothic_floor_xstepborder5_data_end __asm("_binary_pk_textures_gothic_floor_xstepborder5_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_gothic_floor_xstepborder5_data_size __asm("_binary_pk_textures_gothic_floor_xstepborder5_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/gothic_floor/xstepborder5.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
pk/textures/gothic_trim/metalblackwave01.data
Normal file
15
pk/textures/gothic_trim/metalblackwave01.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_gothic_trim_metalblackwave01_data_start __asm("_binary_pk_textures_gothic_trim_metalblackwave01_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_gothic_trim_metalblackwave01_data_end __asm("_binary_pk_textures_gothic_trim_metalblackwave01_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_gothic_trim_metalblackwave01_data_size __asm("_binary_pk_textures_gothic_trim_metalblackwave01_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/gothic_trim/metalblackwave01.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
pk/textures/liquids/lavahell.data
Normal file
15
pk/textures/liquids/lavahell.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_liquids_lavahell_data_start __asm("_binary_pk_textures_liquids_lavahell_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_liquids_lavahell_data_end __asm("_binary_pk_textures_liquids_lavahell_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_liquids_lavahell_data_size __asm("_binary_pk_textures_liquids_lavahell_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/liquids/lavahell.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pk/textures/sfx/flame1.jpg
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
pk/textures/sfx/flame2.data
Normal file
15
pk/textures/sfx/flame2.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_sfx_flame2_data_start __asm("_binary_pk_textures_sfx_flame2_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_sfx_flame2_data_end __asm("_binary_pk_textures_sfx_flame2_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_sfx_flame2_data_size __asm("_binary_pk_textures_sfx_flame2_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/sfx/flame2.jpg
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
pk/textures/sfx/flame3.jpg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
pk/textures/sfx/flame4.jpg
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
pk/textures/sfx/flame5.jpg
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
pk/textures/sfx/flame6.jpg
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
pk/textures/sfx/flame7.jpg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
pk/textures/sfx/flame8.jpg
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
pk/textures/sfx/flameball.jpg
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
pk/textures/skies/killsky_1.jpg
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
pk/textures/skies/killsky_2.jpg
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
pk/textures/stone/pjrock1.data
Normal file
15
pk/textures/stone/pjrock1.data.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t _binary_pk_textures_stone_pjrock1_data_start __asm("_binary_pk_textures_stone_pjrock1_data_start");
|
||||||
|
extern uint32_t _binary_pk_textures_stone_pjrock1_data_end __asm("_binary_pk_textures_stone_pjrock1_data_end");
|
||||||
|
extern uint32_t _binary_pk_textures_stone_pjrock1_data_size __asm("_binary_pk_textures_stone_pjrock1_data_size");
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
pk/textures/stone/pjrock1.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
@ -14,6 +14,7 @@ enum format_type {
|
|||||||
FORMAT_BASE16,
|
FORMAT_BASE16,
|
||||||
FORMAT_STRING,
|
FORMAT_STRING,
|
||||||
FORMAT_CHAR,
|
FORMAT_CHAR,
|
||||||
|
FORMAT_FLOAT,
|
||||||
FORMAT_PERCENT,
|
FORMAT_PERCENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,6 +64,9 @@ static const char * parse_escape(const char * format, struct format * ft)
|
|||||||
case 'c':
|
case 'c':
|
||||||
ft->type = FORMAT_CHAR;
|
ft->type = FORMAT_CHAR;
|
||||||
return format + 1;
|
return format + 1;
|
||||||
|
case 'f':
|
||||||
|
ft->type = FORMAT_FLOAT;
|
||||||
|
return format + 1;
|
||||||
case '%':
|
case '%':
|
||||||
ft->type = FORMAT_PERCENT;
|
ft->type = FORMAT_PERCENT;
|
||||||
return format + 1;
|
return format + 1;
|
||||||
@ -167,6 +171,21 @@ void _printf(const char * format, ...)
|
|||||||
print_char((char)c);
|
print_char((char)c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case FORMAT_FLOAT:
|
||||||
|
{
|
||||||
|
double num = va_arg(args, double);
|
||||||
|
char s[20];
|
||||||
|
int32_t whole = num;
|
||||||
|
int offset = unparse_base10(s, whole, ft.pad_length, ft.fill_char);
|
||||||
|
print_string(s, offset);
|
||||||
|
print_char('.');
|
||||||
|
int32_t fraction = (int32_t)((num - (float)whole) * 1000.0);
|
||||||
|
if (fraction < 0)
|
||||||
|
fraction = -fraction;
|
||||||
|
offset = unparse_base10(s, fraction, 0, 0);
|
||||||
|
print_string(s, offset);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case FORMAT_PERCENT:
|
case FORMAT_PERCENT:
|
||||||
print_char('%');
|
print_char('%');
|
||||||
break;
|
break;
|
||||||
|