texture build process rework

This commit is contained in:
Zack Buhman 2024-09-05 10:39:56 -05:00
parent 140f243ad3
commit 6d464a6d9b
99 changed files with 448 additions and 758 deletions

View File

@ -2,10 +2,7 @@ OPT = -Os
all: cartridge.bin
phony: res
res:
make -C res/
phony:
arm9/%.bin: phony
make -C arm9/ $(notdir $@)
@ -28,4 +25,4 @@ OBJARCH = -O elf32-littlearm -B armv4t
LDSCRIPT = cartridge.lds
include common.mk
.PHONY: phony res
.PHONY: phony

View File

@ -14,6 +14,8 @@ OBJ = \
../res/bowser.data.o \
../res/bowser.data.pal.o
include ../texture/texture.mk
arm9.elf: $(OBJ)
triangle.elf: start.o examples/triangle.o
@ -27,18 +29,20 @@ cube.elf: start.o examples/cube.o ../math/cos_table_fp12.o ../math/cos.o
icosphere.elf: start.o examples/icosphere.o ../math/cos_table_fp12.o ../math/cos.o
MAJORA_RES = \
../res/060067E0.data.pal.o \
../res/060079E0.data.pal.o \
../res/06007DE0.data.pal.o \
../res/060077E0.data.pal.o \
../res/06007BE0.data.pal.o \
../res/06007FE0.data.pal.o \
../res/060067E0.data.o \
../res/060079E0.data.o \
../res/06007DE0.data.o \
../res/060077E0.data.o \
../res/06007BE0.data.o \
../res/06007FE0.data.o
../texture/060067E0.data.pal.o \
../texture/060079E0.data.pal.o \
../texture/06007DE0.data.pal.o \
../texture/060077E0.data.pal.o \
../texture/06007BE0.data.pal.o \
../texture/06007FE0.data.pal.o \
../texture/060067E0.data.o \
../texture/060079E0.data.o \
../texture/06007DE0.data.o \
../texture/060077E0.data.o \
../texture/06007BE0.data.o \
../texture/06007FE0.data.o
examples/majora.c: $(patsubst %.o,%.h,$(MAJORA_RES))
majora.elf: start.o examples/majora.o ../math/cos_table_fp12.o ../math/cos.o $(MAJORA_RES)

View File

@ -3,19 +3,21 @@
#include "math/math.h"
#include "res/060067E0.data.h"
#include "res/060067E0.data.pal.h"
#include "res/060077E0.data.h"
#include "res/060077E0.data.pal.h"
#include "res/060079E0.data.h"
#include "res/060079E0.data.pal.h"
#include "res/06007BE0.data.h"
#include "res/06007BE0.data.pal.h"
#include "res/06007DE0.data.h"
#include "res/06007DE0.data.pal.h"
#include "res/06007FE0.data.h"
#include "res/06007FE0.data.pal.h"
#include "models/majora.h"
#include "texture/060067E0.data.h"
#include "texture/060067E0.data.pal.h"
#include "texture/060077E0.data.h"
#include "texture/060077E0.data.pal.h"
#include "texture/060079E0.data.h"
#include "texture/060079E0.data.pal.h"
#include "texture/06007BE0.data.h"
#include "texture/06007BE0.data.pal.h"
#include "texture/06007DE0.data.h"
#include "texture/06007DE0.data.pal.h"
#include "texture/06007FE0.data.h"
#include "texture/06007FE0.data.pal.h"
#include "res/majora.h"
#include "model/majora.h"
struct object * object[6] = {
&majora_1,
@ -26,43 +28,19 @@ struct object * object[6] = {
&majora_7,
};
int palette_offset[6];
int pixel_dimension[6];
uint32_t teximage_param[6];
int round_up_32(int n)
{
return ((n + 63) / 64) * 64;
}
uint16_t rgb565(const uint8_t * buf)
{
uint8_t r = buf[0] >> 3;
uint8_t g = buf[1] >> 3;
uint8_t g_l = (buf[1] >> 2) & 1;
uint8_t b = buf[2] >> 3;
return (g_l << 15) | (b << 10) | (g << 5) | (r << 0);
}
void copy_palettes()
{
int offset = 0;
volatile uint16_t * vram_f = (volatile uint16_t *)(0x06890000);
int num_pixel_palettes = (sizeof (majora_pixel_palette)) / (sizeof (struct pixel_palette));
for (int i = 0; i < num_pixel_palettes; i++) {
palette_offset[i] = offset;
int colors = majora_pixel_palette[i].palette.size / 3;
uint8_t * pal = majora_pixel_palette[i].palette.start;
int palettes = (sizeof (material)) / (sizeof (material[0]));
for (int i = 0; i < palettes; i++) {
int colors = material[i].palette.size / 2;
uint16_t * pal = (uint16_t *)material[i].palette.start;
int offset = material[i].palette.vram_offset;
for (int c = 0; c < colors; c++) {
vram_f[c + (offset / 2)] = rgb565(&pal[c * 3]);
vram_f[c + offset / 2] = pal[c];
}
offset = round_up_32(offset + colors * 2);
}
}
@ -81,58 +59,64 @@ int pixel_dimension_from_pixels(int pixels)
}
}
uint32_t teximage_size_from_dimension(int dimension)
uint32_t teximage_param__t_size(int height)
{
switch (dimension) {
switch (height) {
default:
case 8: return TEXIMAGE_PARAM__t_size__8_texels
| TEXIMAGE_PARAM__s_size__8_texels;
case 16: return TEXIMAGE_PARAM__t_size__16_texels
| TEXIMAGE_PARAM__s_size__16_texels;
case 32: return TEXIMAGE_PARAM__t_size__32_texels
| TEXIMAGE_PARAM__s_size__32_texels;
case 64: return TEXIMAGE_PARAM__t_size__64_texels
| TEXIMAGE_PARAM__s_size__64_texels;
case 128: return TEXIMAGE_PARAM__t_size__128_texels
| TEXIMAGE_PARAM__s_size__128_texels;
case 256: return TEXIMAGE_PARAM__t_size__256_texels
| TEXIMAGE_PARAM__s_size__256_texels;
case 512: return TEXIMAGE_PARAM__t_size__512_texels
| TEXIMAGE_PARAM__s_size__512_texels;
case 1024: return TEXIMAGE_PARAM__t_size__1024_texels
| TEXIMAGE_PARAM__s_size__1024_texels;
case 8: return TEXIMAGE_PARAM__t_size__8_texels;
case 16: return TEXIMAGE_PARAM__t_size__16_texels;
case 32: return TEXIMAGE_PARAM__t_size__32_texels;
case 64: return TEXIMAGE_PARAM__t_size__64_texels;
case 128: return TEXIMAGE_PARAM__t_size__128_texels;
case 256: return TEXIMAGE_PARAM__t_size__256_texels;
case 512: return TEXIMAGE_PARAM__t_size__512_texels;
case 1024: return TEXIMAGE_PARAM__t_size__1024_texels;
}
}
uint32_t make_teximage_param(int offset, int dimension)
uint32_t teximage_param__s_size(int width)
{
return 0
| TEXIMAGE_PARAM__texture_coordinate_transformation_mode__vertex_source
| TEXIMAGE_PARAM__texture_format__256_color_palette
| teximage_size_from_dimension(dimension)
| TEXIMAGE_PARAM__repeat_t__repeat
| TEXIMAGE_PARAM__repeat_s__repeat
| TEXIMAGE_PARAM__texture_starting_address(offset >> 3);
switch (width) {
default:
case 8: return TEXIMAGE_PARAM__s_size__8_texels;
case 16: return TEXIMAGE_PARAM__s_size__16_texels;
case 32: return TEXIMAGE_PARAM__s_size__32_texels;
case 64: return TEXIMAGE_PARAM__s_size__64_texels;
case 128: return TEXIMAGE_PARAM__s_size__128_texels;
case 256: return TEXIMAGE_PARAM__s_size__256_texels;
case 512: return TEXIMAGE_PARAM__s_size__512_texels;
case 1024: return TEXIMAGE_PARAM__s_size__1024_texels;
}
}
uint32_t teximage_param__color_palette(int palette_size)
{
switch (palette_size) {
default:
case 4: return TEXIMAGE_PARAM__texture_format__4_color_palette;
case 16: return TEXIMAGE_PARAM__texture_format__16_color_palette;
case 256: return TEXIMAGE_PARAM__texture_format__256_color_palette;
}
}
void copy_pixels()
{
int offset = 0;
volatile uint16_t * vram_a = (volatile uint16_t *)(0x06800000);
int num_pixel_palettes = (sizeof (majora_pixel_palette)) / (sizeof (struct pixel_palette));
for (int i = 0; i < num_pixel_palettes; i++) {
int size = majora_pixel_palette[i].pixel.size;
pixel_dimension[i] = pixel_dimension_from_pixels(size);
teximage_param[i] = make_teximage_param(offset, pixel_dimension[i]);
uint8_t * pixel = majora_pixel_palette[i].pixel.start;
int pixels = (sizeof (material)) / (sizeof (material[0]));
*((volatile uint32_t *)0x4440000) = pixels;
for (int i = 0; i < pixels; i++) {
int size = material[i].pixel.size;
uint16_t * pixel = (uint16_t *)material[i].pixel.start;
int offset = material[i].pixel.vram_offset;
for (int p = 0; p < size; p+=2) {
uint16_t texel = (pixel[p + 1] << 8) | (pixel[p + 0] << 0);
vram_a[(p + offset) / 2] = texel;
*((volatile uint32_t *)0x4440000) = size;
for (int t = 0; t < size / 2; t++) {
vram_a[t + offset / 2] = pixel[t];
}
offset += size;
break;
}
}
@ -211,7 +195,6 @@ void main()
| DISP3DCNT__texture_mapping__enable;
copy_texture_data();
copy_texture_data();
// clear matrix stack status
io_registers.a.GXSTAT |= GXSTAT__matrix_stack_status__overflow_or_underflow;
@ -341,7 +324,6 @@ void main()
// multiply by a y-axis rotation
/*
io_registers.a.MTX_MULT_3X3 = cos2;
io_registers.a.MTX_MULT_3X3 = 0;
io_registers.a.MTX_MULT_3X3 = sin2;
@ -353,7 +335,6 @@ void main()
io_registers.a.MTX_MULT_3X3 = -sin2;
io_registers.a.MTX_MULT_3X3 = 0;
io_registers.a.MTX_MULT_3X3 = cos2;
*/
/*
// multiply by a z-axis rotation
@ -425,12 +406,23 @@ void main()
struct object * obj = object[oix];
const int num_triangles = obj->triangle_count;
int material = obj->material;
int material_ix = obj->material;
int pixel_offset = material[material_ix].pixel.vram_offset;
int palette_offset = material[material_ix].palette.vram_offset;
int width = material[material_ix].pixel.width;
int height = material[material_ix].pixel.height;
int palette_size = material[material_ix].palette.palette_size;
io_registers.a.TEXPLTT_BASE = TEXPLTT_BASE__base_address(palette_offset[material] >> 4);
io_registers.a.TEXIMAGE_PARAM = teximage_param[material];
int dimension = pixel_dimension[material];
int shift = palette_size == 4 ? 3 : 4;
io_registers.a.TEXPLTT_BASE = TEXPLTT_BASE__base_address(palette_offset >> shift);
io_registers.a.TEXIMAGE_PARAM = 0
| TEXIMAGE_PARAM__texture_coordinate_transformation_mode__texcoord_source
| teximage_param__color_palette(palette_size)
| TEXIMAGE_PARAM__repeat_t__repeat
| TEXIMAGE_PARAM__repeat_s__repeat
| teximage_param__t_size(height)
| teximage_param__s_size(width)
| TEXIMAGE_PARAM__texture_starting_address(pixel_offset >> 3);
for (int i = 0; i < num_triangles; i++) {
// "When texture mapping, the Geometry Engine works faster if you
@ -440,8 +432,8 @@ void main()
int au = at->u;
int av = at->v;
io_registers.a.TEXCOORD = 0
| TEXCOORD__t_coordinate(v_to_t(av, dimension))
| TEXCOORD__s_coordinate(u_to_s(au, dimension));
| TEXCOORD__t_coordinate(v_to_t(av, height))
| TEXCOORD__s_coordinate(u_to_s(au, width));
struct vertex_normal * an = &majora_normal[obj->triangle[i].a.normal];
io_registers.a.NORMAL = 0
@ -460,8 +452,8 @@ void main()
int bu = bt->u;
int bv = bt->v;
io_registers.a.TEXCOORD = 0
| TEXCOORD__t_coordinate(v_to_t(bv, dimension))
| TEXCOORD__s_coordinate(u_to_s(bu, dimension));
| TEXCOORD__t_coordinate(v_to_t(bv, height))
| TEXCOORD__s_coordinate(u_to_s(bu, width));
struct vertex_normal * bn = &majora_normal[obj->triangle[i].b.normal];
io_registers.a.NORMAL = 0
@ -480,8 +472,8 @@ void main()
int cu = ct->u;
int cv = ct->v;
io_registers.a.TEXCOORD = 0
| TEXCOORD__t_coordinate(v_to_t(cv, dimension))
| TEXCOORD__s_coordinate(u_to_s(cu, dimension));
| TEXCOORD__t_coordinate(v_to_t(cv, height))
| TEXCOORD__s_coordinate(u_to_s(cu, width));
struct vertex_normal * cn = &majora_normal[obj->triangle[i].c.normal];
io_registers.a.NORMAL = 0

View File

@ -31,13 +31,14 @@ OBJDUMP = $(TARGET)objdump
LIBGCC = $(shell $(CC) -print-file-name=libgcc.a)
define BUILD_BINARY_O
cd $(dir $<) ; \
$(OBJCOPY) \
-I binary $(OBJARCH) \
--rename-section .data=.data.$(basename $@) \
$< $@
$(notdir $<) $(notdir $@)
endef
as_obj_binary = _binary_$(subst .,_,$(subst /,_,$(1)))
as_obj_binary = _binary_$(subst .,_,$(subst /,_,$(notdir $(1))))
define BUILD_BINARY_H
@echo gen $@

View File

@ -1,4 +1,4 @@
#include "model.h"
#include "model/model.h"
// .6 fixed-point
struct vertex_position majora_position[] = {
@ -331,90 +331,6 @@ struct vertex_normal majora_normal[] = {
{-14, -212, 466},
};
enum majora_material {
mtl_060067E0,
mtl_060077E0,
mtl_060079E0,
mtl_06007BE0,
mtl_06007DE0,
mtl_06007FE0,
};
struct pixel_palette majora_pixel_palette[] = {
[mtl_060067E0] = {
.pixel = {
.start = (uint8_t *)&_binary_060067E0_data_start,
.end = (uint8_t *)&_binary_060067E0_data_end,
.size = (int)&_binary_060067E0_data_size,
},
.palette = {
.start = (uint8_t *)&_binary_060067E0_data_pal_start,
.end = (uint8_t *)&_binary_060067E0_data_pal_end,
.size = (int)&_binary_060067E0_data_pal_size,
},
},
[mtl_060077E0] = {
.pixel = {
.start = (uint8_t *)&_binary_060077E0_data_start,
.end = (uint8_t *)&_binary_060077E0_data_end,
.size = (int)&_binary_060077E0_data_size,
},
.palette = {
.start = (uint8_t *)&_binary_060077E0_data_pal_start,
.end = (uint8_t *)&_binary_060077E0_data_pal_end,
.size = (int)&_binary_060077E0_data_pal_size,
},
},
[mtl_060079E0] = {
.pixel = {
.start = (uint8_t *)&_binary_060079E0_data_start,
.end = (uint8_t *)&_binary_060079E0_data_end,
.size = (int)&_binary_060079E0_data_size,
},
.palette = {
.start = (uint8_t *)&_binary_060079E0_data_pal_start,
.end = (uint8_t *)&_binary_060079E0_data_pal_end,
.size = (int)&_binary_060079E0_data_pal_size,
},
},
[mtl_06007BE0] = {
.pixel = {
.start = (uint8_t *)&_binary_06007BE0_data_start,
.end = (uint8_t *)&_binary_06007BE0_data_end,
.size = (int)&_binary_06007BE0_data_size,
},
.palette = {
.start = (uint8_t *)&_binary_06007BE0_data_pal_start,
.end = (uint8_t *)&_binary_06007BE0_data_pal_end,
.size = (int)&_binary_06007BE0_data_pal_size,
},
},
[mtl_06007DE0] = {
.pixel = {
.start = (uint8_t *)&_binary_06007DE0_data_start,
.end = (uint8_t *)&_binary_06007DE0_data_end,
.size = (int)&_binary_06007DE0_data_size,
},
.palette = {
.start = (uint8_t *)&_binary_06007DE0_data_pal_start,
.end = (uint8_t *)&_binary_06007DE0_data_pal_end,
.size = (int)&_binary_06007DE0_data_pal_size,
},
},
[mtl_06007FE0] = {
.pixel = {
.start = (uint8_t *)&_binary_06007FE0_data_start,
.end = (uint8_t *)&_binary_06007FE0_data_end,
.size = (int)&_binary_06007FE0_data_size,
},
.palette = {
.start = (uint8_t *)&_binary_06007FE0_data_pal_start,
.end = (uint8_t *)&_binary_06007FE0_data_pal_end,
.size = (int)&_binary_06007FE0_data_pal_size,
},
},
};
struct triangle majora_1_triangle[] = {
{
{2, 0, 0},

View File

@ -61,12 +61,3 @@ d 1.000000
illum 2
map_Kd 06007FE0.png
newmtl mtl_060087E0
Ns 95.999992
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2
map_Kd 060087E0.png

21
model/material.h Normal file
View File

@ -0,0 +1,21 @@
struct pixel_descriptor {
uint8_t * start;
int32_t size;
int32_t vram_offset; // offset into vram texture address space
int16_t width;
int16_t height;
};
struct palette_descriptor {
uint8_t * start;
int32_t size;
int32_t vram_offset; // offset into vram palette address space
int32_t palette_size;
};
struct material_descriptor {
struct pixel_descriptor pixel;
struct palette_descriptor palette;
};

View File

@ -45,14 +45,3 @@ struct object {
int quadrilateral_count;
int material;
};
struct start_size_end {
uint8_t * start;
uint8_t * end;
int size;
};
struct pixel_palette {
struct start_size_end pixel;
struct start_size_end palette;
};

View File

@ -1 +0,0 @@
../registers/generate.py

View File

@ -1,432 +0,0 @@
"register_name","enum_name","bits","bit_name","value","mask","description"
"DISPCNT",,31,"obj_extended_palette",1,,
"DISPCNT",,30,"bg_extended_palette",1,,
"DISPCNT",,"29-27","bg_screen_base_offset",,"0b111",
"DISPCNT",,"26-24","bg_character_base_offset",,"0b111",
"DISPCNT",,23,"obj_processing_during_h_blank_period",1,,
"DISPCNT","obj_vram_capacity",22,"128kb",0,,
"DISPCNT","obj_vram_capacity",22,"256kb",1,,
"DISPCNT","character_vram_capacity","21-20","32kb","0b00",,
"DISPCNT","character_vram_capacity","21-20","64kb","0b01",,
"DISPCNT","character_vram_capacity","21-20","128kb","0b10",,
"DISPCNT","character_vram_capacity","21-20","256kb","0b11",,
"DISPCNT","display_vram_block","19-18","vram_a","0b00",,
"DISPCNT","display_vram_block","19-18","vram_b","0b01",,
"DISPCNT","display_vram_block","19-18","vram_c","0b10",,
"DISPCNT","display_vram_block","19-18","vram_d","0b11",,
"DISPCNT","display_mode","17-16","display_off",0,,
"DISPCNT","display_mode","17-16","graphics_display",1,,
"DISPCNT","display_mode","17-16","vram_display",2,,
"DISPCNT","display_mode","17-16","main_memory_display",3,,
"DISPCNT","obj_window",15,"disable",0,,
"DISPCNT","obj_window",15,"enable",1,,
"DISPCNT","window_1",14,"disable",0,,
"DISPCNT","window_1",14,"enable",1,,
"DISPCNT","window_0",13,"disable",0,,
"DISPCNT","window_0",13,"enable",1,,
"DISPCNT","obj",12,"disable",0,,
"DISPCNT","obj",12,"enable",1,,
"DISPCNT","bg3",11,"disable",0,,
"DISPCNT","bg3",11,"enable",1,,
"DISPCNT","bg2",10,"disable",0,,
"DISPCNT","bg2",10,"enable",1,,
"DISPCNT","bg1",9,"disable",0,,
"DISPCNT","bg1",9,"enable",1,,
"DISPCNT","bg0",8,"disable",0,,
"DISPCNT","bg0",8,"enable",1,,
"DISPCNT",,7,"2d_display_forced_blank",1,,
"DISPCNT","bitmap_obj_mapping_mode","6-5","2d_mapping_with_128_horizontal_dots","0b00",,
"DISPCNT","bitmap_obj_mapping_mode","6-5","2d_mapping_with_256_horizontal_dots","0b01",,
"DISPCNT","bitmap_obj_mapping_mode","6-5","1d_mapping","0b10",,
"DISPCNT","character_obj_mapping_mode",4,"2d_mapping",0,,
"DISPCNT","character_obj_mapping_mode",4,"1d_mapping",1,,
"DISPCNT","display_selection_for_bg0",3,"2d_graphics",0,,
"DISPCNT","display_selection_for_bg0",3,"3d_graphics",1,,
"DISPCNT","bg_mode","2-0","text0_text1_text2_text3",0,,
"DISPCNT","bg_mode","2-0","text0_text1_text2_affine3",1,,
"DISPCNT","bg_mode","2-0","text0_text1_affine2_affine3",2,,
"DISPCNT","bg_mode","2-0","text0_text1_text2_extended3",3,,
"DISPCNT","bg_mode","2-0","text0_text1_affine2_extended3",4,,
"DISPCNT","bg_mode","2-0","text0_text1_extended2_extended3",5,,
"DISPCNT","bg_mode","2-0","3d_large_screen_256_color_bitmap",6,,
,,,,,,
"DISPSTAT","v_counter_match_interrupt_request",5,"disable",0,,
"DISPSTAT","v_counter_match_interrupt_request",5,"enable",1,,
"DISPSTAT","h_blank_interrupt_request",4,"disable",0,,
"DISPSTAT","h_blank_interrupt_request",4,"enable",1,,
"DISPSTAT","v_blank_interrupt_request",3,"disable",0,,
"DISPSTAT","v_blank_interrupt_request",3,"enable",1,,
"DISPSTAT","v_counter_match_detection",2,"outside_a_matching_interval",0,,
"DISPSTAT","v_counter_match_detection",2,"during_a_matching_interval",1,,
"DISPSTAT","h_blank_detection",1,"outside_h_blank_interval",0,,
"DISPSTAT","h_blank_detection",1,"during_h_blank_interval",1,,
"DISPSTAT","v_blank_detection",0,"outside_v_blank_interval",0,,
"DISPSTAT","v_blank_detection",0,"during_v_blank_interval",1,,
,,,,,,
"VCOUNT",,"8-0","v_counter_value",,,
,,,,,,
"BG0CNT","screen_size","15-14","256x256","0b00",,
"BG0CNT","screen_size","15-14","512x256","0b01",,
"BG0CNT","screen_size","15-14","256x512","0b10",,
"BG0CNT","screen_size","15-14","512x512","0b11",,
"BG0CNT","bg_extended_palette_slot",13,"slot_0",0,,
"BG0CNT","bg_extended_palette_slot",13,"slot_2",1,,
"BG0CNT",,"12-8","screen_base_block",,"0b11111",
"BG0CNT","color_mode",7,"16_color_mode",0,,
"BG0CNT","color_mode",7,"256_color_mode",1,,
"BG0CNT","mosaic",6,"disable",0,,
"BG0CNT","mosaic",6,"enable",1,,
"BG0CNT",,"5-2","character_base_block",,"0b1111",
"BG0CNT",,"1-0","priority",,"0b11",
,,,,,,
"BG1CNT","screen_size","15-14","256x256","0b00",,
"BG1CNT","screen_size","15-14","512x256","0b01",,
"BG1CNT","screen_size","15-14","256x512","0b10",,
"BG1CNT","screen_size","15-14","512x512","0b11",,
"BG1CNT","bg_extended_palette_slot",13,"slot_1",0,,
"BG1CNT","bg_extended_palette_slot",13,"slot_3",1,,
"BG1CNT",,"12-8","screen_base_block",,"0b11111",
"BG1CNT","color_mode",7,"16_color_mode",0,,
"BG1CNT","color_mode",7,"256_color_mode",1,,
"BG1CNT","mosaic",6,"disable",0,,
"BG1CNT","mosaic",6,"enable",1,,
"BG1CNT",,"5-2","character_base_block",,"0b1111",
"BG1CNT",,"1-0","priority",,"0b11",
,,,,,,
"BG2CNT","screen_size","15-14","256x256","0b00",,
"BG2CNT","screen_size","15-14","512x256","0b01",,
"BG2CNT","screen_size","15-14","256x512","0b10",,
"BG2CNT","screen_size","15-14","512x512","0b11",,
"BG2CNT","out_of_area_processing",13,"transparent_display",0,,
"BG2CNT","out_of_area_processing",13,"wraparound_display",1,,
"BG2CNT",,"12-8","screen_base_block",,"0b11111",
"BG2CNT","color_mode",7,"16_color_mode",0,,
"BG2CNT","color_mode",7,"256_color_mode",1,,
"BG2CNT","mosaic",6,"disable",0,,
"BG2CNT","mosaic",6,"enable",1,,
"BG2CNT",,"5-2","character_base_block",,"0b1111",
"BG2CNT",,"1-0","priority",,"0b11",
,,,,,,
"BG3CNT","screen_size","15-14","256x256","0b00",,
"BG3CNT","screen_size","15-14","512x256","0b01",,
"BG3CNT","screen_size","15-14","256x512","0b10",,
"BG3CNT","screen_size","15-14","512x512","0b11",,
"BG3CNT","out_of_area_processing",13,"transparent_display",0,,
"BG3CNT","out_of_area_processing",13,"wraparound_display",1,,
"BG3CNT",,"12-8","screen_base_block",,"0b11111",
"BG3CNT","color_mode",7,"16_color_mode",0,,
"BG3CNT","color_mode",7,"256_color_mode",1,,
"BG3CNT","mosaic",6,"disable",0,,
"BG3CNT","mosaic",6,"enable",1,,
"BG3CNT",,"5-2","character_base_block",,"0b1111",
"BG3CNT",,"1-0","priority",,"0b11",
,,,,,,
"VRAMCNT","vram_d",31,"disable",0,,
"VRAMCNT","vram_d",31,"enable",1,,
"VRAMCNT","vram_d","28-27","ofs",,"0b11",
"VRAMCNT","vram_d","26-24","mst",,"0b111",
"VRAMCNT","vram_c",23,"disable",0,,
"VRAMCNT","vram_c",23,"enable",1,,
"VRAMCNT","vram_c","20-19","ofs",,"0b11",
"VRAMCNT","vram_c","18-16","mst",,"0b111",
"VRAMCNT","vram_b",15,"disable",0,,
"VRAMCNT","vram_b",15,"enable",1,,
"VRAMCNT","vram_b","12-11","ofs",,"0b11",
"VRAMCNT","vram_b","9-8","mst",,"0b11",
"VRAMCNT","vram_a",7,"disable",0,,
"VRAMCNT","vram_a",7,"enable",1,,
"VRAMCNT","vram_a","4-3","ofs",,"0b11",
"VRAMCNT","vram_a","1-0","mst",,"0b11",
,,,,,,
"WVRAMCNT","wram","25-24","bank",,"0b11",
"WVRAMCNT","vram_g",23,"disable",0,,
"WVRAMCNT","vram_g",23,"enable",1,,
"WVRAMCNT","vram_g","20-19","ofs",,"0b11",
"WVRAMCNT","vram_g","18-16","mst",,"0b111",
"WVRAMCNT","vram_f",15,"disable",0,,
"WVRAMCNT","vram_f",15,"enable",1,,
"WVRAMCNT","vram_f","12-11","ofs",,"0b11",
"WVRAMCNT","vram_f","10-8","mst",,"0b111",
"WVRAMCNT","vram_e",7,"disable",0,,
"WVRAMCNT","vram_e",7,"enable",1,,
"WVRAMCNT","vram_e","2-0","mst",,"0b111",
,,,,,,
"VRAM_HI_CNT","vram_i",15,"disable",0,,
"VRAM_HI_CNT","vram_i",15,"enable",1,,
"VRAM_HI_CNT","vram_i","9-8","mst",,"0b11",
"VRAM_HI_CNT","vram_h",7,"disable",0,,
"VRAM_HI_CNT","vram_h",7,"enable",1,,
"VRAM_HI_CNT","vram_h","1-0","mst",,"0b11",
,,,,,,
,,,,,,
"POWCNT","lcd_output_destination",15,"a_to_lower__b_to_upper",0,,
"POWCNT","lcd_output_destination",15,"a_to_upper__b_to_lower",1,,
"POWCNT","2d_graphics_engine_b",9,"disable",0,,
"POWCNT","2d_graphics_engine_b",9,"enable",1,,
"POWCNT","geometry_engine",3,"disable",0,,
"POWCNT","geometry_engine",3,"enable",1,,
"POWCNT","rendering_engine",2,"disable",0,,
"POWCNT","rendering_engine",2,"enable",1,,
"POWCNT","2d_graphics_engine_a",1,"disable",0,,
"POWCNT","2d_graphics_engine_a",1,"enable",1,,
"POWCNT","lcd",0,"disable",0,,
"POWCNT","lcd",0,"enable",1,,
,,,,,,
"RDLINES_COUNT",,"5-0","rendered_lines_min",,,
,,,,,,
"ALPHA_TEST_REF",,"4-0","comparison_value",,"0b11111",
,,,,,,
"CLEAR_COLOR",,"29-24","clear_polygon_id",,"0b111111",
"CLEAR_COLOR",,"20-16","alpha_value",,"0b11111",
"CLEAR_COLOR",,15,"fog_enable",1,,
"CLEAR_COLOR",,"14-10","blue",,"0b11111",
"CLEAR_COLOR",,"9-5","green",,"0b11111",
"CLEAR_COLOR",,"4-0","red",,"0b11111",
,,,,,,
"CLEAR_DEPTH",,"14-0","value",,"0x7fff",
,,,,,,
"CLRIMAGE_OFFSET",,"15-8","y_offset",,"0xff",
"CLRIMAGE_OFFSET",,"7-0","x_offset",,"0xff",
,,,,,,
"DISP3DCNT","clear_image",14,"disable",0,,
"DISP3DCNT","clear_image",14,"enable",1,,
"DISP3DCNT",,13,"polygon_list_ram_and_vertex_ram_overflow",1,,
"DISP3DCNT",,12,"color_buffer_underflow",1,,
"DISP3DCNT",,"11-8","fog_shift",,"0b1111",
"DISP3DCNT","fog_master",7,"disable",0,,
"DISP3DCNT","fog_master",7,"enable",1,,
"DISP3DCNT","fog_mode",6,"blending_using_pixel_color_value_and_alpha_value",0,,
"DISP3DCNT","fog_mode",6,"blending_using_only_pixel_alpha_value",1,,
"DISP3DCNT","edge_marking",5,"disable",0,,
"DISP3DCNT","edge_marking",5,"enable",1,,
"DISP3DCNT","anti_aliasing",4,"disable",0,,
"DISP3DCNT","anti_aliasing",4,"enable",1,,
"DISP3DCNT","alpha_blending",3,"disable",0,,
"DISP3DCNT","alpha_blending",3,"enable",1,,
"DISP3DCNT","alpha_test",2,"disable",0,,
"DISP3DCNT","alpha_test",2,"enable",1,,
"DISP3DCNT","toon_highlight",1,"toon_shading",0,,
"DISP3DCNT","toon_highlight",1,"highlight_shading",1,,
"DISP3DCNT","texture_mapping",0,"disable",0,,
"DISP3DCNT","texture_mapping",0,"enable",1,,
,,,,,,
"MTX_MODE","matrix_mode","1-0","projection","0b00",,
"MTX_MODE","matrix_mode","1-0","position","0b01",,
"MTX_MODE","matrix_mode","1-0","position_and_vector","0b10",,
"MTX_MODE","matrix_mode","1-0","texture","0b11",,
,,,,,,
"MTX_POP",,"5-0","number_of_pops",,"0b111111",
,,,,,,
"MTX_STORE",,"4-0","index",,"0b11111",
,,,,,,
"MTX_RESTORE",,"4-0","position",,"0b11111",
,,,,,,
"COLOR",,"14-10","blue",,"0b11111",
"COLOR",,"9-5","green",,"0b11111",
"COLOR",,"4-0","red",,"0b11111",
,,,,,,
"NORMAL",,"29-20","z_component",,"0x7ff",
"NORMAL",,"19-10","y_component",,"0x7ff",
"NORMAL",,"9-0","x_component",,"0x7ff",
,,,,,,
"TEXCOORD",,"31-16","t_coordinate",,"0xffff",
"TEXCOORD",,"15-0","s_coordinate",,"0xffff",
,,,,,,
"VTX_16",0,"31-16","y_coordinate",,"0xffff",
"VTX_16",0,"15-0","x_coordinate",,"0xffff",
"VTX_16",1,"15-0","z_coordinate",,"0xffff",
,,,,,,
"VTX_10",,"29-20","z_coordinate",,"0x7ff",
"VTX_10",,"19-10","y_coordinate",,"0x7ff",
"VTX_10",,"9-0","x_coordinate",,"0x7ff",
,,,,,,
"VTX_XY",,"31-16","y_coordinate",,"0xffff",
"VTX_XY",,"15-0","x_coordinate",,"0xffff",
,,,,,,
"VTX_XZ",,"31-16","z_coordinate",,"0xffff",
"VTX_XZ",,"15-0","x_coordinate",,"0xffff",
,,,,,,
"VTX_YZ",,"31-16","z_coordinate",,"0xffff",
"VTX_YZ",,"15-0","y_coordinate",,"0xffff",
,,,,,,
"VTX_DIFF",,"29-20","z_coordinate",,"0x7ff",
"VTX_DIFF",,"19-10","y_coordinate",,"0x7ff",
"VTX_DIFF",,"9-0","x_coordinate",,"0x7ff",
,,,,,,
"POLYGON_ATTR",,"29-24","polygon_id",,"0b111111",
"POLYGON_ATTR",,"20-16","alpha_value",,"0b11111",
"POLYGON_ATTR","fog",15,"disable",0,,
"POLYGON_ATTR","fog",15,"enable",1,,
"POLYGON_ATTR","depth_test_condition",14,"render_when_depth_value_is_smaller_than_buffer_value",0,,
"POLYGON_ATTR","depth_test_condition",14,"render_when_depth_value_is_equal_to_buffer_value",1,,
"POLYGON_ATTR","one_dot_polygon",13,"do_not_render",0,,
"POLYGON_ATTR","one_dot_polygon",13,"render",1,,
"POLYGON_ATTR","far_plane_intersection",12,"delete",0,,
"POLYGON_ATTR","far_plane_intersection",12,"clip",1,,
"POLYGON_ATTR","translucent_depth_value_update",11,"do_not_update",0,,
"POLYGON_ATTR","translucent_depth_value_update",11,"update",1,,
"POLYGON_ATTR","render_front_surface",7,"disable",0,,
"POLYGON_ATTR","render_front_surface",7,"enable",1,,
"POLYGON_ATTR","render_back_surface",6,"disable",0,,
"POLYGON_ATTR","render_back_surface",6,"enable",1,,
"POLYGON_ATTR","polygon_mode","5-4","modulation","0b00",,
"POLYGON_ATTR","polygon_mode","5-4","decal","0b01",,
"POLYGON_ATTR","polygon_mode","5-4","toon","0b10",,
"POLYGON_ATTR","polygon_mode","5-4","shadow","0b11",,
"POLYGON_ATTR","light_3",3,"disable",0,,
"POLYGON_ATTR","light_3",3,"enable",1,,
"POLYGON_ATTR","light_2",2,"disable",0,,
"POLYGON_ATTR","light_2",2,"enable",1,,
"POLYGON_ATTR","light_1",1,"disable",0,,
"POLYGON_ATTR","light_1",1,"enable",1,,
"POLYGON_ATTR","light_0",0,"disable",0,,
"POLYGON_ATTR","light_0",0,"enable",1,,
,,,,,,
"TEXIMAGE_PARAM","texture_coordinate_transformation_mode","31-30","do_not_transform_texture_coordinates","0b00",,
"TEXIMAGE_PARAM","texture_coordinate_transformation_mode","31-30","texcoord_source","0b01",,
"TEXIMAGE_PARAM","texture_coordinate_transformation_mode","31-30","normal_source","0b10",,
"TEXIMAGE_PARAM","texture_coordinate_transformation_mode","31-30","vertex_source","0b11",,
"TEXIMAGE_PARAM","palette_color0_transparency",29,"palette_setting",0,,
"TEXIMAGE_PARAM","palette_color0_transparency",29,"always_transparent",1,,
"TEXIMAGE_PARAM","texture_format","28-26","no_texture",0,,
"TEXIMAGE_PARAM","texture_format","28-26","a3i5_translucent",1,,
"TEXIMAGE_PARAM","texture_format","28-26","4_color_palette",2,,
"TEXIMAGE_PARAM","texture_format","28-26","16_color_palette",3,,
"TEXIMAGE_PARAM","texture_format","28-26","256_color_palette",4,,
"TEXIMAGE_PARAM","texture_format","28-26","4x4_texel_compressed",5,,
"TEXIMAGE_PARAM","texture_format","28-26","a5i3_translucent",6,,
"TEXIMAGE_PARAM","texture_format","28-26","direct",7,,
"TEXIMAGE_PARAM","t_size","25-23","8_texels",0,,
"TEXIMAGE_PARAM","t_size","25-23","16_texels",1,,
"TEXIMAGE_PARAM","t_size","25-23","32_texels",2,,
"TEXIMAGE_PARAM","t_size","25-23","64_texels",3,,
"TEXIMAGE_PARAM","t_size","25-23","128_texels",4,,
"TEXIMAGE_PARAM","t_size","25-23","256_texels",5,,
"TEXIMAGE_PARAM","t_size","25-23","512_texels",6,,
"TEXIMAGE_PARAM","t_size","25-23","1024_texels",7,,
"TEXIMAGE_PARAM","s_size","22-20","8_texels",0,,
"TEXIMAGE_PARAM","s_size","22-20","16_texels",1,,
"TEXIMAGE_PARAM","s_size","22-20","32_texels",2,,
"TEXIMAGE_PARAM","s_size","22-20","64_texels",3,,
"TEXIMAGE_PARAM","s_size","22-20","128_texels",4,,
"TEXIMAGE_PARAM","s_size","22-20","256_texels",5,,
"TEXIMAGE_PARAM","s_size","22-20","512_texels",6,,
"TEXIMAGE_PARAM","s_size","22-20","1024_texels",7,,
"TEXIMAGE_PARAM","flip_t",19,"do_not_flip",0,,
"TEXIMAGE_PARAM","flip_t",19,"flip",1,,
"TEXIMAGE_PARAM","flip_s",18,"do_not_flip",0,,
"TEXIMAGE_PARAM","flip_s",18,"flip",1,,
"TEXIMAGE_PARAM","repeat_t",17,"do_not_repeat",0,,
"TEXIMAGE_PARAM","repeat_t",17,"repeat",1,,
"TEXIMAGE_PARAM","repeat_s",16,"do_not_repeat",0,,
"TEXIMAGE_PARAM","repeat_s",16,"repeat",1,,
"TEXIMAGE_PARAM",,"15-0","texture_starting_address",,"0xffff",
,,,,,,
"TEXPLTT_BASE",,"12-0","base_address",,"0x1fff",
,,,,,,
"DIF_AMB",,"30-26","ambient_blue",,"0b11111",
"DIF_AMB",,"25-21","ambient_green",,"0b11111",
"DIF_AMB",,"20-16","ambient_red",,"0b11111",
"DIF_AMB","vertex_color",15,"do_not_set_vertex_color",0,,
"DIF_AMB","vertex_color",15,"set_diffuse_reflection_color_as_vertex_color",1,,
"DIF_AMB",,"14-10","diffuse_blue",,"0b11111",
"DIF_AMB",,"9-5","diffuse_green",,"0b11111",
"DIF_AMB",,"4-0","diffuse_red",,"0b11111",
,,,,,,
"SPE_EMI",,"30-26","emission_blue",,"0b11111",
"SPE_EMI",,"25-21","emission_green",,"0b11111",
"SPE_EMI",,"20-16","emission_red",,"0b11111",
"SPE_EMI","shininess",15,"disable",0,,
"SPE_EMI","shininess",15,"enable",1,,
"SPE_EMI",,"14-10","specular_blue",,"0b11111",
"SPE_EMI",,"9-5","specular_green",,"0b11111",
"SPE_EMI",,"4-0","specular_red",,"0b11111",
,,,,,,
"LIGHT_VECTOR",,"31-30","light_number",,"0b11",
"LIGHT_VECTOR",,"29-20","decimal_z",,"0x3ff",
"LIGHT_VECTOR",,"19-10","decimal_y",,"0x3ff",
"LIGHT_VECTOR",,"9-0","decimal_x",,"0x3ff",
,,,,,,
"LIGHT_COLOR",,"31-30","light_number",,"0b11",
"LIGHT_COLOR",,"14-10","blue",,"0b11111",
"LIGHT_COLOR",,"9-5","green",,"0b11111",
"LIGHT_COLOR",,"4-0","red",,"0b11111",
,,,,,,
"SHININESS",,"31-24","4x_3",,"0xff",
"SHININESS",,"23-16","4x_2",,"0xff",
"SHININESS",,"15-8","4x_1",,"0xff",
"SHININESS",,"7-0","4x_0",,"0xff",
,,,,,,
"BEGIN_VTXS","type","1-0","triangle","0b00",,
"BEGIN_VTXS","type","1-0","quadrilateral","0b01",,
"BEGIN_VTXS","type","1-0","triangle_strip","0b10",,
"BEGIN_VTXS","type","1-0","quadrilateral_strip","0b11",,
,,,,,,
"SWAP_BUFFERS","depth_buffering",1,"z_value",0,,
"SWAP_BUFFERS","depth_buffering",1,"w_value",1,,
"SWAP_BUFFERS","translucent_polygon_y_sorting",0,"auto_sort",0,,
"SWAP_BUFFERS","translucent_polygon_y_sorting",0,"manual_sort",1,,
,,,,,,
"VIEWPORT",,"31-24","y2",,"0xff",
"VIEWPORT",,"23-16","x2",,"0xff",
"VIEWPORT",,"15-8","y1",,"0xff",
"VIEWPORT",,"7-0","x1",,"0xff",
,,,,,,
"BOX_TEST",0,"31-16","y_coordinate",,"0xffff",
"BOX_TEST",0,"15-0","x_coordinate",,"0xffff",
"BOX_TEST",1,"31-16","width",,"0xffff",
"BOX_TEST",1,"15-0","z_coordinate",,"0xffff",
"BOX_TEST",2,"31-16","depth",,"0xffff",
"BOX_TEST",2,"15-0","height",,"0xffff",
,,,,,,
"POS_TEST",0,"31-16","y_coordinate",,"0xffff",
"POS_TEST",0,"15-0","x_coordinate",,"0xffff",
"POS_TEST",1,"15-0","z_coordinate",,"0xffff",
,,,,,,
"VEC_TEST",,"29-20","decimal_z",,"0x3ff",
"VEC_TEST",,"19-10","decimal_y",,"0x3ff",
"VEC_TEST",,"9-0","decimal_x",,"0x3ff",
,,,,,,
"GXSTAT","command_fifo_interrupt_condition","31-30","disable","0b00",,
"GXSTAT","command_fifo_interrupt_condition","31-30","half_full","0b01",,
"GXSTAT","command_fifo_interrupt_condition","31-30","empty","0b10",,
"GXSTAT",,27,"geometry_engine_busy",1,,
"GXSTAT","fifo_status",26,"empty",1,,
"GXSTAT","fifo_status",25,"less_than_half_full",1,,
"GXSTAT","fifo_status",24,"full",1,,
"GXSTAT",,"23-16","command_fifo_count",,,
"GXSTAT","matrix_stack_status",15,"overflow_or_underflow",1,,
"GXSTAT","matrix_stack_status",14,"busy",1,,
"GXSTAT","matrix_stack_status",13,"projection_stack_level",,,
"GXSTAT","matrix_stack_status","12-8","position_and_vector_stack_level",,,
"GXSTAT",,1,"test_status",1,,
"GXSTAT",,0,"test_busy",1,,
,,,,,,
"LISTRAM_COUNT",,"11-0","counter",,,
,,,,,,
"VTXRAM_COUNT",,"12-0","counter",,,
,,,,,,
"OBJ_ATTRIBUTE_0","obj_shape","15-14","square","0b00",,
"OBJ_ATTRIBUTE_0","obj_shape","15-14","long_rectangle","0b01",,
"OBJ_ATTRIBUTE_0","obj_shape","15-14","tall_rectangle","0b10",,
"OBJ_ATTRIBUTE_0","color_mode",13,"16_color_mode",0,,
"OBJ_ATTRIBUTE_0","color_mode",13,"256_color_mode",1,,
"OBJ_ATTRIBUTE_0","mosaic",12,"off",0,,
"OBJ_ATTRIBUTE_0","mosaic",12,"on",1,,
"OBJ_ATTRIBUTE_0","obj_mode","11-10","normal","0b00",,
"OBJ_ATTRIBUTE_0","obj_mode","11-10","translucent","0b01",,
"OBJ_ATTRIBUTE_0","obj_mode","11-10","obj_window","0b10",,
"OBJ_ATTRIBUTE_0","obj_mode","11-10","bitmap_obj","0b11",,
"OBJ_ATTRIBUTE_0","double_size",9,"disable",0,,
"OBJ_ATTRIBUTE_0","double_size",9,"enable",1,,
"OBJ_ATTRIBUTE_0","affine_transformation",8,"disable",0,,
"OBJ_ATTRIBUTE_0","affine_transformation",8,"enable",1,,
"OBJ_ATTRIBUTE_0",,"7-0","y_coordinate",,"0xff",
,,,,,,
"OBJ_ATTRIBUTE_1",,"15-14","obj_size",,"0b11",
"OBJ_ATTRIBUTE_1",,"13-9","affine_transformation_parameter",,"0b11111",
"OBJ_ATTRIBUTE_1",,"8-0","x_coordinate",,"0x1ff",
,,,,,,
"OBJ_ATTRIBUTE_2",,"15-12","color_parameter",,"0b1111",
"OBJ_ATTRIBUTE_2",,"11-10","display_priority",,"0b11",
"OBJ_ATTRIBUTE_2",,"9-0","character_name",,"0x3ff",
1 register_name enum_name bits bit_name value mask description
2 DISPCNT 31 obj_extended_palette 1
3 DISPCNT 30 bg_extended_palette 1
4 DISPCNT 29-27 bg_screen_base_offset 0b111
5 DISPCNT 26-24 bg_character_base_offset 0b111
6 DISPCNT 23 obj_processing_during_h_blank_period 1
7 DISPCNT obj_vram_capacity 22 128kb 0
8 DISPCNT obj_vram_capacity 22 256kb 1
9 DISPCNT character_vram_capacity 21-20 32kb 0b00
10 DISPCNT character_vram_capacity 21-20 64kb 0b01
11 DISPCNT character_vram_capacity 21-20 128kb 0b10
12 DISPCNT character_vram_capacity 21-20 256kb 0b11
13 DISPCNT display_vram_block 19-18 vram_a 0b00
14 DISPCNT display_vram_block 19-18 vram_b 0b01
15 DISPCNT display_vram_block 19-18 vram_c 0b10
16 DISPCNT display_vram_block 19-18 vram_d 0b11
17 DISPCNT display_mode 17-16 display_off 0
18 DISPCNT display_mode 17-16 graphics_display 1
19 DISPCNT display_mode 17-16 vram_display 2
20 DISPCNT display_mode 17-16 main_memory_display 3
21 DISPCNT obj_window 15 disable 0
22 DISPCNT obj_window 15 enable 1
23 DISPCNT window_1 14 disable 0
24 DISPCNT window_1 14 enable 1
25 DISPCNT window_0 13 disable 0
26 DISPCNT window_0 13 enable 1
27 DISPCNT obj 12 disable 0
28 DISPCNT obj 12 enable 1
29 DISPCNT bg3 11 disable 0
30 DISPCNT bg3 11 enable 1
31 DISPCNT bg2 10 disable 0
32 DISPCNT bg2 10 enable 1
33 DISPCNT bg1 9 disable 0
34 DISPCNT bg1 9 enable 1
35 DISPCNT bg0 8 disable 0
36 DISPCNT bg0 8 enable 1
37 DISPCNT 7 2d_display_forced_blank 1
38 DISPCNT bitmap_obj_mapping_mode 6-5 2d_mapping_with_128_horizontal_dots 0b00
39 DISPCNT bitmap_obj_mapping_mode 6-5 2d_mapping_with_256_horizontal_dots 0b01
40 DISPCNT bitmap_obj_mapping_mode 6-5 1d_mapping 0b10
41 DISPCNT character_obj_mapping_mode 4 2d_mapping 0
42 DISPCNT character_obj_mapping_mode 4 1d_mapping 1
43 DISPCNT display_selection_for_bg0 3 2d_graphics 0
44 DISPCNT display_selection_for_bg0 3 3d_graphics 1
45 DISPCNT bg_mode 2-0 text0_text1_text2_text3 0
46 DISPCNT bg_mode 2-0 text0_text1_text2_affine3 1
47 DISPCNT bg_mode 2-0 text0_text1_affine2_affine3 2
48 DISPCNT bg_mode 2-0 text0_text1_text2_extended3 3
49 DISPCNT bg_mode 2-0 text0_text1_affine2_extended3 4
50 DISPCNT bg_mode 2-0 text0_text1_extended2_extended3 5
51 DISPCNT bg_mode 2-0 3d_large_screen_256_color_bitmap 6
52
53 DISPSTAT v_counter_match_interrupt_request 5 disable 0
54 DISPSTAT v_counter_match_interrupt_request 5 enable 1
55 DISPSTAT h_blank_interrupt_request 4 disable 0
56 DISPSTAT h_blank_interrupt_request 4 enable 1
57 DISPSTAT v_blank_interrupt_request 3 disable 0
58 DISPSTAT v_blank_interrupt_request 3 enable 1
59 DISPSTAT v_counter_match_detection 2 outside_a_matching_interval 0
60 DISPSTAT v_counter_match_detection 2 during_a_matching_interval 1
61 DISPSTAT h_blank_detection 1 outside_h_blank_interval 0
62 DISPSTAT h_blank_detection 1 during_h_blank_interval 1
63 DISPSTAT v_blank_detection 0 outside_v_blank_interval 0
64 DISPSTAT v_blank_detection 0 during_v_blank_interval 1
65
66 VCOUNT 8-0 v_counter_value
67
68 BG0CNT screen_size 15-14 256x256 0b00
69 BG0CNT screen_size 15-14 512x256 0b01
70 BG0CNT screen_size 15-14 256x512 0b10
71 BG0CNT screen_size 15-14 512x512 0b11
72 BG0CNT bg_extended_palette_slot 13 slot_0 0
73 BG0CNT bg_extended_palette_slot 13 slot_2 1
74 BG0CNT 12-8 screen_base_block 0b11111
75 BG0CNT color_mode 7 16_color_mode 0
76 BG0CNT color_mode 7 256_color_mode 1
77 BG0CNT mosaic 6 disable 0
78 BG0CNT mosaic 6 enable 1
79 BG0CNT 5-2 character_base_block 0b1111
80 BG0CNT 1-0 priority 0b11
81
82 BG1CNT screen_size 15-14 256x256 0b00
83 BG1CNT screen_size 15-14 512x256 0b01
84 BG1CNT screen_size 15-14 256x512 0b10
85 BG1CNT screen_size 15-14 512x512 0b11
86 BG1CNT bg_extended_palette_slot 13 slot_1 0
87 BG1CNT bg_extended_palette_slot 13 slot_3 1
88 BG1CNT 12-8 screen_base_block 0b11111
89 BG1CNT color_mode 7 16_color_mode 0
90 BG1CNT color_mode 7 256_color_mode 1
91 BG1CNT mosaic 6 disable 0
92 BG1CNT mosaic 6 enable 1
93 BG1CNT 5-2 character_base_block 0b1111
94 BG1CNT 1-0 priority 0b11
95
96 BG2CNT screen_size 15-14 256x256 0b00
97 BG2CNT screen_size 15-14 512x256 0b01
98 BG2CNT screen_size 15-14 256x512 0b10
99 BG2CNT screen_size 15-14 512x512 0b11
100 BG2CNT out_of_area_processing 13 transparent_display 0
101 BG2CNT out_of_area_processing 13 wraparound_display 1
102 BG2CNT 12-8 screen_base_block 0b11111
103 BG2CNT color_mode 7 16_color_mode 0
104 BG2CNT color_mode 7 256_color_mode 1
105 BG2CNT mosaic 6 disable 0
106 BG2CNT mosaic 6 enable 1
107 BG2CNT 5-2 character_base_block 0b1111
108 BG2CNT 1-0 priority 0b11
109
110 BG3CNT screen_size 15-14 256x256 0b00
111 BG3CNT screen_size 15-14 512x256 0b01
112 BG3CNT screen_size 15-14 256x512 0b10
113 BG3CNT screen_size 15-14 512x512 0b11
114 BG3CNT out_of_area_processing 13 transparent_display 0
115 BG3CNT out_of_area_processing 13 wraparound_display 1
116 BG3CNT 12-8 screen_base_block 0b11111
117 BG3CNT color_mode 7 16_color_mode 0
118 BG3CNT color_mode 7 256_color_mode 1
119 BG3CNT mosaic 6 disable 0
120 BG3CNT mosaic 6 enable 1
121 BG3CNT 5-2 character_base_block 0b1111
122 BG3CNT 1-0 priority 0b11
123
124 VRAMCNT vram_d 31 disable 0
125 VRAMCNT vram_d 31 enable 1
126 VRAMCNT vram_d 28-27 ofs 0b11
127 VRAMCNT vram_d 26-24 mst 0b111
128 VRAMCNT vram_c 23 disable 0
129 VRAMCNT vram_c 23 enable 1
130 VRAMCNT vram_c 20-19 ofs 0b11
131 VRAMCNT vram_c 18-16 mst 0b111
132 VRAMCNT vram_b 15 disable 0
133 VRAMCNT vram_b 15 enable 1
134 VRAMCNT vram_b 12-11 ofs 0b11
135 VRAMCNT vram_b 9-8 mst 0b11
136 VRAMCNT vram_a 7 disable 0
137 VRAMCNT vram_a 7 enable 1
138 VRAMCNT vram_a 4-3 ofs 0b11
139 VRAMCNT vram_a 1-0 mst 0b11
140
141 WVRAMCNT wram 25-24 bank 0b11
142 WVRAMCNT vram_g 23 disable 0
143 WVRAMCNT vram_g 23 enable 1
144 WVRAMCNT vram_g 20-19 ofs 0b11
145 WVRAMCNT vram_g 18-16 mst 0b111
146 WVRAMCNT vram_f 15 disable 0
147 WVRAMCNT vram_f 15 enable 1
148 WVRAMCNT vram_f 12-11 ofs 0b11
149 WVRAMCNT vram_f 10-8 mst 0b111
150 WVRAMCNT vram_e 7 disable 0
151 WVRAMCNT vram_e 7 enable 1
152 WVRAMCNT vram_e 2-0 mst 0b111
153
154 VRAM_HI_CNT vram_i 15 disable 0
155 VRAM_HI_CNT vram_i 15 enable 1
156 VRAM_HI_CNT vram_i 9-8 mst 0b11
157 VRAM_HI_CNT vram_h 7 disable 0
158 VRAM_HI_CNT vram_h 7 enable 1
159 VRAM_HI_CNT vram_h 1-0 mst 0b11
160
161
162 POWCNT lcd_output_destination 15 a_to_lower__b_to_upper 0
163 POWCNT lcd_output_destination 15 a_to_upper__b_to_lower 1
164 POWCNT 2d_graphics_engine_b 9 disable 0
165 POWCNT 2d_graphics_engine_b 9 enable 1
166 POWCNT geometry_engine 3 disable 0
167 POWCNT geometry_engine 3 enable 1
168 POWCNT rendering_engine 2 disable 0
169 POWCNT rendering_engine 2 enable 1
170 POWCNT 2d_graphics_engine_a 1 disable 0
171 POWCNT 2d_graphics_engine_a 1 enable 1
172 POWCNT lcd 0 disable 0
173 POWCNT lcd 0 enable 1
174
175 RDLINES_COUNT 5-0 rendered_lines_min
176
177 ALPHA_TEST_REF 4-0 comparison_value 0b11111
178
179 CLEAR_COLOR 29-24 clear_polygon_id 0b111111
180 CLEAR_COLOR 20-16 alpha_value 0b11111
181 CLEAR_COLOR 15 fog_enable 1
182 CLEAR_COLOR 14-10 blue 0b11111
183 CLEAR_COLOR 9-5 green 0b11111
184 CLEAR_COLOR 4-0 red 0b11111
185
186 CLEAR_DEPTH 14-0 value 0x7fff
187
188 CLRIMAGE_OFFSET 15-8 y_offset 0xff
189 CLRIMAGE_OFFSET 7-0 x_offset 0xff
190
191 DISP3DCNT clear_image 14 disable 0
192 DISP3DCNT clear_image 14 enable 1
193 DISP3DCNT 13 polygon_list_ram_and_vertex_ram_overflow 1
194 DISP3DCNT 12 color_buffer_underflow 1
195 DISP3DCNT 11-8 fog_shift 0b1111
196 DISP3DCNT fog_master 7 disable 0
197 DISP3DCNT fog_master 7 enable 1
198 DISP3DCNT fog_mode 6 blending_using_pixel_color_value_and_alpha_value 0
199 DISP3DCNT fog_mode 6 blending_using_only_pixel_alpha_value 1
200 DISP3DCNT edge_marking 5 disable 0
201 DISP3DCNT edge_marking 5 enable 1
202 DISP3DCNT anti_aliasing 4 disable 0
203 DISP3DCNT anti_aliasing 4 enable 1
204 DISP3DCNT alpha_blending 3 disable 0
205 DISP3DCNT alpha_blending 3 enable 1
206 DISP3DCNT alpha_test 2 disable 0
207 DISP3DCNT alpha_test 2 enable 1
208 DISP3DCNT toon_highlight 1 toon_shading 0
209 DISP3DCNT toon_highlight 1 highlight_shading 1
210 DISP3DCNT texture_mapping 0 disable 0
211 DISP3DCNT texture_mapping 0 enable 1
212
213 MTX_MODE matrix_mode 1-0 projection 0b00
214 MTX_MODE matrix_mode 1-0 position 0b01
215 MTX_MODE matrix_mode 1-0 position_and_vector 0b10
216 MTX_MODE matrix_mode 1-0 texture 0b11
217
218 MTX_POP 5-0 number_of_pops 0b111111
219
220 MTX_STORE 4-0 index 0b11111
221
222 MTX_RESTORE 4-0 position 0b11111
223
224 COLOR 14-10 blue 0b11111
225 COLOR 9-5 green 0b11111
226 COLOR 4-0 red 0b11111
227
228 NORMAL 29-20 z_component 0x7ff
229 NORMAL 19-10 y_component 0x7ff
230 NORMAL 9-0 x_component 0x7ff
231
232 TEXCOORD 31-16 t_coordinate 0xffff
233 TEXCOORD 15-0 s_coordinate 0xffff
234
235 VTX_16 0 31-16 y_coordinate 0xffff
236 VTX_16 0 15-0 x_coordinate 0xffff
237 VTX_16 1 15-0 z_coordinate 0xffff
238
239 VTX_10 29-20 z_coordinate 0x7ff
240 VTX_10 19-10 y_coordinate 0x7ff
241 VTX_10 9-0 x_coordinate 0x7ff
242
243 VTX_XY 31-16 y_coordinate 0xffff
244 VTX_XY 15-0 x_coordinate 0xffff
245
246 VTX_XZ 31-16 z_coordinate 0xffff
247 VTX_XZ 15-0 x_coordinate 0xffff
248
249 VTX_YZ 31-16 z_coordinate 0xffff
250 VTX_YZ 15-0 y_coordinate 0xffff
251
252 VTX_DIFF 29-20 z_coordinate 0x7ff
253 VTX_DIFF 19-10 y_coordinate 0x7ff
254 VTX_DIFF 9-0 x_coordinate 0x7ff
255
256 POLYGON_ATTR 29-24 polygon_id 0b111111
257 POLYGON_ATTR 20-16 alpha_value 0b11111
258 POLYGON_ATTR fog 15 disable 0
259 POLYGON_ATTR fog 15 enable 1
260 POLYGON_ATTR depth_test_condition 14 render_when_depth_value_is_smaller_than_buffer_value 0
261 POLYGON_ATTR depth_test_condition 14 render_when_depth_value_is_equal_to_buffer_value 1
262 POLYGON_ATTR one_dot_polygon 13 do_not_render 0
263 POLYGON_ATTR one_dot_polygon 13 render 1
264 POLYGON_ATTR far_plane_intersection 12 delete 0
265 POLYGON_ATTR far_plane_intersection 12 clip 1
266 POLYGON_ATTR translucent_depth_value_update 11 do_not_update 0
267 POLYGON_ATTR translucent_depth_value_update 11 update 1
268 POLYGON_ATTR render_front_surface 7 disable 0
269 POLYGON_ATTR render_front_surface 7 enable 1
270 POLYGON_ATTR render_back_surface 6 disable 0
271 POLYGON_ATTR render_back_surface 6 enable 1
272 POLYGON_ATTR polygon_mode 5-4 modulation 0b00
273 POLYGON_ATTR polygon_mode 5-4 decal 0b01
274 POLYGON_ATTR polygon_mode 5-4 toon 0b10
275 POLYGON_ATTR polygon_mode 5-4 shadow 0b11
276 POLYGON_ATTR light_3 3 disable 0
277 POLYGON_ATTR light_3 3 enable 1
278 POLYGON_ATTR light_2 2 disable 0
279 POLYGON_ATTR light_2 2 enable 1
280 POLYGON_ATTR light_1 1 disable 0
281 POLYGON_ATTR light_1 1 enable 1
282 POLYGON_ATTR light_0 0 disable 0
283 POLYGON_ATTR light_0 0 enable 1
284
285 TEXIMAGE_PARAM texture_coordinate_transformation_mode 31-30 do_not_transform_texture_coordinates 0b00
286 TEXIMAGE_PARAM texture_coordinate_transformation_mode 31-30 texcoord_source 0b01
287 TEXIMAGE_PARAM texture_coordinate_transformation_mode 31-30 normal_source 0b10
288 TEXIMAGE_PARAM texture_coordinate_transformation_mode 31-30 vertex_source 0b11
289 TEXIMAGE_PARAM palette_color0_transparency 29 palette_setting 0
290 TEXIMAGE_PARAM palette_color0_transparency 29 always_transparent 1
291 TEXIMAGE_PARAM texture_format 28-26 no_texture 0
292 TEXIMAGE_PARAM texture_format 28-26 a3i5_translucent 1
293 TEXIMAGE_PARAM texture_format 28-26 4_color_palette 2
294 TEXIMAGE_PARAM texture_format 28-26 16_color_palette 3
295 TEXIMAGE_PARAM texture_format 28-26 256_color_palette 4
296 TEXIMAGE_PARAM texture_format 28-26 4x4_texel_compressed 5
297 TEXIMAGE_PARAM texture_format 28-26 a5i3_translucent 6
298 TEXIMAGE_PARAM texture_format 28-26 direct 7
299 TEXIMAGE_PARAM t_size 25-23 8_texels 0
300 TEXIMAGE_PARAM t_size 25-23 16_texels 1
301 TEXIMAGE_PARAM t_size 25-23 32_texels 2
302 TEXIMAGE_PARAM t_size 25-23 64_texels 3
303 TEXIMAGE_PARAM t_size 25-23 128_texels 4
304 TEXIMAGE_PARAM t_size 25-23 256_texels 5
305 TEXIMAGE_PARAM t_size 25-23 512_texels 6
306 TEXIMAGE_PARAM t_size 25-23 1024_texels 7
307 TEXIMAGE_PARAM s_size 22-20 8_texels 0
308 TEXIMAGE_PARAM s_size 22-20 16_texels 1
309 TEXIMAGE_PARAM s_size 22-20 32_texels 2
310 TEXIMAGE_PARAM s_size 22-20 64_texels 3
311 TEXIMAGE_PARAM s_size 22-20 128_texels 4
312 TEXIMAGE_PARAM s_size 22-20 256_texels 5
313 TEXIMAGE_PARAM s_size 22-20 512_texels 6
314 TEXIMAGE_PARAM s_size 22-20 1024_texels 7
315 TEXIMAGE_PARAM flip_t 19 do_not_flip 0
316 TEXIMAGE_PARAM flip_t 19 flip 1
317 TEXIMAGE_PARAM flip_s 18 do_not_flip 0
318 TEXIMAGE_PARAM flip_s 18 flip 1
319 TEXIMAGE_PARAM repeat_t 17 do_not_repeat 0
320 TEXIMAGE_PARAM repeat_t 17 repeat 1
321 TEXIMAGE_PARAM repeat_s 16 do_not_repeat 0
322 TEXIMAGE_PARAM repeat_s 16 repeat 1
323 TEXIMAGE_PARAM 15-0 texture_starting_address 0xffff
324
325 TEXPLTT_BASE 12-0 base_address 0x1fff
326
327 DIF_AMB 30-26 ambient_blue 0b11111
328 DIF_AMB 25-21 ambient_green 0b11111
329 DIF_AMB 20-16 ambient_red 0b11111
330 DIF_AMB vertex_color 15 do_not_set_vertex_color 0
331 DIF_AMB vertex_color 15 set_diffuse_reflection_color_as_vertex_color 1
332 DIF_AMB 14-10 diffuse_blue 0b11111
333 DIF_AMB 9-5 diffuse_green 0b11111
334 DIF_AMB 4-0 diffuse_red 0b11111
335
336 SPE_EMI 30-26 emission_blue 0b11111
337 SPE_EMI 25-21 emission_green 0b11111
338 SPE_EMI 20-16 emission_red 0b11111
339 SPE_EMI shininess 15 disable 0
340 SPE_EMI shininess 15 enable 1
341 SPE_EMI 14-10 specular_blue 0b11111
342 SPE_EMI 9-5 specular_green 0b11111
343 SPE_EMI 4-0 specular_red 0b11111
344
345 LIGHT_VECTOR 31-30 light_number 0b11
346 LIGHT_VECTOR 29-20 decimal_z 0x3ff
347 LIGHT_VECTOR 19-10 decimal_y 0x3ff
348 LIGHT_VECTOR 9-0 decimal_x 0x3ff
349
350 LIGHT_COLOR 31-30 light_number 0b11
351 LIGHT_COLOR 14-10 blue 0b11111
352 LIGHT_COLOR 9-5 green 0b11111
353 LIGHT_COLOR 4-0 red 0b11111
354
355 SHININESS 31-24 4x_3 0xff
356 SHININESS 23-16 4x_2 0xff
357 SHININESS 15-8 4x_1 0xff
358 SHININESS 7-0 4x_0 0xff
359
360 BEGIN_VTXS type 1-0 triangle 0b00
361 BEGIN_VTXS type 1-0 quadrilateral 0b01
362 BEGIN_VTXS type 1-0 triangle_strip 0b10
363 BEGIN_VTXS type 1-0 quadrilateral_strip 0b11
364
365 SWAP_BUFFERS depth_buffering 1 z_value 0
366 SWAP_BUFFERS depth_buffering 1 w_value 1
367 SWAP_BUFFERS translucent_polygon_y_sorting 0 auto_sort 0
368 SWAP_BUFFERS translucent_polygon_y_sorting 0 manual_sort 1
369
370 VIEWPORT 31-24 y2 0xff
371 VIEWPORT 23-16 x2 0xff
372 VIEWPORT 15-8 y1 0xff
373 VIEWPORT 7-0 x1 0xff
374
375 BOX_TEST 0 31-16 y_coordinate 0xffff
376 BOX_TEST 0 15-0 x_coordinate 0xffff
377 BOX_TEST 1 31-16 width 0xffff
378 BOX_TEST 1 15-0 z_coordinate 0xffff
379 BOX_TEST 2 31-16 depth 0xffff
380 BOX_TEST 2 15-0 height 0xffff
381
382 POS_TEST 0 31-16 y_coordinate 0xffff
383 POS_TEST 0 15-0 x_coordinate 0xffff
384 POS_TEST 1 15-0 z_coordinate 0xffff
385
386 VEC_TEST 29-20 decimal_z 0x3ff
387 VEC_TEST 19-10 decimal_y 0x3ff
388 VEC_TEST 9-0 decimal_x 0x3ff
389
390 GXSTAT command_fifo_interrupt_condition 31-30 disable 0b00
391 GXSTAT command_fifo_interrupt_condition 31-30 half_full 0b01
392 GXSTAT command_fifo_interrupt_condition 31-30 empty 0b10
393 GXSTAT 27 geometry_engine_busy 1
394 GXSTAT fifo_status 26 empty 1
395 GXSTAT fifo_status 25 less_than_half_full 1
396 GXSTAT fifo_status 24 full 1
397 GXSTAT 23-16 command_fifo_count
398 GXSTAT matrix_stack_status 15 overflow_or_underflow 1
399 GXSTAT matrix_stack_status 14 busy 1
400 GXSTAT matrix_stack_status 13 projection_stack_level
401 GXSTAT matrix_stack_status 12-8 position_and_vector_stack_level
402 GXSTAT 1 test_status 1
403 GXSTAT 0 test_busy 1
404
405 LISTRAM_COUNT 11-0 counter
406
407 VTXRAM_COUNT 12-0 counter
408
409 OBJ_ATTRIBUTE_0 obj_shape 15-14 square 0b00
410 OBJ_ATTRIBUTE_0 obj_shape 15-14 long_rectangle 0b01
411 OBJ_ATTRIBUTE_0 obj_shape 15-14 tall_rectangle 0b10
412 OBJ_ATTRIBUTE_0 color_mode 13 16_color_mode 0
413 OBJ_ATTRIBUTE_0 color_mode 13 256_color_mode 1
414 OBJ_ATTRIBUTE_0 mosaic 12 off 0
415 OBJ_ATTRIBUTE_0 mosaic 12 on 1
416 OBJ_ATTRIBUTE_0 obj_mode 11-10 normal 0b00
417 OBJ_ATTRIBUTE_0 obj_mode 11-10 translucent 0b01
418 OBJ_ATTRIBUTE_0 obj_mode 11-10 obj_window 0b10
419 OBJ_ATTRIBUTE_0 obj_mode 11-10 bitmap_obj 0b11
420 OBJ_ATTRIBUTE_0 double_size 9 disable 0
421 OBJ_ATTRIBUTE_0 double_size 9 enable 1
422 OBJ_ATTRIBUTE_0 affine_transformation 8 disable 0
423 OBJ_ATTRIBUTE_0 affine_transformation 8 enable 1
424 OBJ_ATTRIBUTE_0 7-0 y_coordinate 0xff
425
426 OBJ_ATTRIBUTE_1 15-14 obj_size 0b11
427 OBJ_ATTRIBUTE_1 13-9 affine_transformation_parameter 0b11111
428 OBJ_ATTRIBUTE_1 8-0 x_coordinate 0x1ff
429
430 OBJ_ATTRIBUTE_2 15-12 color_parameter 0b1111
431 OBJ_ATTRIBUTE_2 11-10 display_priority 0b11
432 OBJ_ATTRIBUTE_2 9-0 character_name 0x3ff

Binary file not shown.

Binary file not shown.

View File

@ -1 +0,0 @@
hX(�h�ィ

Binary file not shown.

View File

@ -1 +0,0 @@
爃h饦橉需

Binary file not shown.

View File

@ -1 +0,0 @@
PHXЈh�и�

Binary file not shown.

View File

@ -1 +0,0 @@
@`€Px Xђ°`ђЁp�°€ёИ�ИШ�Ра Ша Ши

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_060087E0_data_start __asm("_binary_060087E0_data_start");
extern uint32_t _binary_060087E0_data_end __asm("_binary_060087E0_data_end");
extern uint32_t _binary_060087E0_data_size __asm("_binary_060087E0_data_size");

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_060087E0_data_pal_start __asm("_binary_060087E0_data_pal_start");
extern uint32_t _binary_060087E0_data_pal_end __asm("_binary_060087E0_data_pal_end");
extern uint32_t _binary_060087E0_data_pal_size __asm("_binary_060087E0_data_pal_size");

View File

@ -1,18 +0,0 @@
OBJ += $(patsubst %.data,%.data.o,$(wildcard *.data))
OBJ += $(patsubst %.data.pal,%.data.pal.o,$(wildcard *.data.pal))
HEADER += $(patsubst %.data,%.data.h,$(wildcard *.data))
HEADER += $(patsubst %.data.pal,%.data.pal.h,$(wildcard *.data.pal))
TARGET=arm-none-eabi-
OBJARCH=-O elf32-littlearm -B armv5te
all: $(OBJ) $(HEADER)
include ../common.mk
%.data.h: %.data
$(BUILD_BINARY_H)
%.data.pal.h: %.data.pal
$(BUILD_BINARY_H)

View File

@ -0,0 +1,71 @@
import struct
import sys
from PIL import Image
def round_up_palette_size(palette_size):
assert palette_size != 0, (name, palette_size)
if palette_size <= 4:
return 4
elif palette_size <= 16:
return 16
elif palette_size <= 256:
return 256
else:
assert False, palette_size
def pixels_per_byte(palette_size):
if palette_size == 4:
return 4
elif palette_size == 16:
return 2
elif palette_size == 256:
return 1
else:
assert False, palette_size
def pack_one_byte(pixels, index, palette_size):
num = pixels_per_byte(palette_size)
shift = 8 // num
byte = 0
i = 0
while num > 0:
px = pixels[index]
assert px < palette_size
byte |= px << (shift * i)
index += 1
i += 1
num -= 1
return byte, index
def pack_pixels(pixels, width, height, palette_size):
index = 0
with open(sys.argv[2], 'wb') as f:
while index < (width * height):
byte, index = pack_one_byte(pixels, index, palette_size)
f.write(bytes([byte]))
def rgb565(r, g, b):
r5 = (r >> 3) & 31
g6 = (g >> 3) & 31
g6_l = (g >> 2) & 1
b5 = (b >> 3) & 31
return (g6_l << 15) | (b5 << 10) | (g6 << 5) | (r5 << 0)
def pack_palette(colors):
with open(sys.argv[2], 'wb') as f:
for color in colors:
out = rgb565(*color)
f.write(struct.pack('<H', out))
with Image.open(sys.argv[1]) as im:
width, height = im.size
colors = list(im.palette.colors)
pixels = list(im.getdata())
if sys.argv[2].endswith('.data'):
pack_pixels(pixels, width, height, round_up_palette_size(len(colors)))
elif sys.argv[2].endswith('.pal'):
pack_palette(colors)
else:
assert False, sys.argv[2]

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_bowser_data_start __asm("_binary_bowser_data_start");
extern uint32_t _binary_bowser_data_end __asm("_binary_bowser_data_end");
extern uint32_t _binary_bowser_data_size __asm("_binary_bowser_data_size");

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_bowser_data_pal_start __asm("_binary_bowser_data_pal_start");
extern uint32_t _binary_bowser_data_pal_end __asm("_binary_bowser_data_pal_end");
extern uint32_t _binary_bowser_data_pal_size __asm("_binary_bowser_data_pal_size");

Binary file not shown.

1
res/generate.py Symbolic link
View File

@ -0,0 +1 @@
../register/generate.py

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_hotaru_futaba_data_start __asm("_binary_hotaru_futaba_data_start");
extern uint32_t _binary_hotaru_futaba_data_end __asm("_binary_hotaru_futaba_data_end");
extern uint32_t _binary_hotaru_futaba_data_size __asm("_binary_hotaru_futaba_data_size");

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_hotaru_futaba_data_pal_start __asm("_binary_hotaru_futaba_data_pal_start");
extern uint32_t _binary_hotaru_futaba_data_pal_end __asm("_binary_hotaru_futaba_data_pal_end");
extern uint32_t _binary_hotaru_futaba_data_pal_size __asm("_binary_hotaru_futaba_data_pal_size");

108
res/majora.h Normal file
View File

@ -0,0 +1,108 @@
#pragma once
#include <stdint.h>
#include "model/material.h"
enum material {
mtl_060067E0,
mtl_060077E0,
mtl_060079E0,
mtl_06007BE0,
mtl_06007DE0,
mtl_06007FE0,
};
struct material_descriptor material[] = {
[mtl_060067E0] = {
.pixel = {
.start = (uint8_t *)&_binary_060067E0_data_start,
.size = (int)&_binary_060067E0_data_size,
.vram_offset = 0,
.width = 64,
.height = 64,
},
.palette = {
.start = (uint8_t *)&_binary_060067E0_data_pal_start,
.size = (int)&_binary_060067E0_data_pal_size,
.vram_offset = 0,
.palette_size = 256,
},
},
[mtl_060077E0] = {
.pixel = {
.start = (uint8_t *)&_binary_060077E0_data_start,
.size = (int)&_binary_060077E0_data_size,
.vram_offset = 4096,
.width = 16,
.height = 16,
},
.palette = {
.start = (uint8_t *)&_binary_060077E0_data_pal_start,
.size = (int)&_binary_060077E0_data_pal_size,
.vram_offset = 512,
.palette_size = 4,
},
},
[mtl_060079E0] = {
.pixel = {
.start = (uint8_t *)&_binary_060079E0_data_start,
.size = (int)&_binary_060079E0_data_size,
.vram_offset = 4160,
.width = 16,
.height = 16,
},
.palette = {
.start = (uint8_t *)&_binary_060079E0_data_pal_start,
.size = (int)&_binary_060079E0_data_pal_size,
.vram_offset = 528,
.palette_size = 4,
},
},
[mtl_06007BE0] = {
.pixel = {
.start = (uint8_t *)&_binary_06007BE0_data_start,
.size = (int)&_binary_06007BE0_data_size,
.vram_offset = 4224,
.width = 16,
.height = 16,
},
.palette = {
.start = (uint8_t *)&_binary_06007BE0_data_pal_start,
.size = (int)&_binary_06007BE0_data_pal_size,
.vram_offset = 544,
.palette_size = 4,
},
},
[mtl_06007DE0] = {
.pixel = {
.start = (uint8_t *)&_binary_06007DE0_data_start,
.size = (int)&_binary_06007DE0_data_size,
.vram_offset = 4288,
.width = 16,
.height = 16,
},
.palette = {
.start = (uint8_t *)&_binary_06007DE0_data_pal_start,
.size = (int)&_binary_06007DE0_data_pal_size,
.vram_offset = 560,
.palette_size = 16,
},
},
[mtl_06007FE0] = {
.pixel = {
.start = (uint8_t *)&_binary_06007FE0_data_start,
.size = (int)&_binary_06007FE0_data_size,
.vram_offset = 4416,
.width = 32,
.height = 32,
},
.palette = {
.start = (uint8_t *)&_binary_06007FE0_data_pal_start,
.size = (int)&_binary_06007FE0_data_pal_size,
.vram_offset = 592,
.palette_size = 256,
},
},
};

7
res/path.py Normal file
View File

@ -0,0 +1,7 @@
from os import path
def texture_path(s):
return path.join('..', 'texture', s)
def model_path(s):
return path.join('..', 'model', s)

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_player_data_start __asm("_binary_player_data_start");
extern uint32_t _binary_player_data_end __asm("_binary_player_data_end");
extern uint32_t _binary_player_data_size __asm("_binary_player_data_size");

Binary file not shown.

View File

@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
extern uint32_t _binary_player_data_pal_start __asm("_binary_player_data_pal_start");
extern uint32_t _binary_player_data_pal_end __asm("_binary_player_data_pal_end");
extern uint32_t _binary_player_data_pal_size __asm("_binary_player_data_pal_size");

Binary file not shown.

View File

@ -108,35 +108,6 @@ def render_object(prefix, object_name, d, material):
yield "};"
def render_pixel_palette(prefix, newmtl, mapkd):
name, _ext = mapkd.name.rsplit('.', maxsplit=1)
pixel_name = f"{name}_data"
palette_name = f"{name}_data_pal"
yield f"[{newmtl.name}] = {{"
yield ".pixel = {"
yield f".start = (uint8_t *)&_binary_{pixel_name}_start,"
yield f".end = (uint8_t *)&_binary_{pixel_name}_end,"
yield f".size = (int)&_binary_{pixel_name}_size,"
yield "},"
yield ".palette = {"
yield f".start = (uint8_t *)&_binary_{palette_name}_start,"
yield f".end = (uint8_t *)&_binary_{palette_name}_end,"
yield f".size = (int)&_binary_{palette_name}_size,"
yield "},"
yield "},"
def render_materials(prefix, newmtl_mapkd):
yield f"enum {prefix}_material {{"
for newmtl, mapkd in newmtl_mapkd:
yield f"{newmtl.name},";
yield "};"
yield f"struct pixel_palette {prefix}_pixel_palette[] = {{"
for newmtl, mapkd in newmtl_mapkd:
yield from render_pixel_palette(prefix, newmtl, mapkd)
yield "};"
def render_header():
yield '#include "model.h"'
yield ""
@ -152,22 +123,6 @@ render(render_vertex_positions(prefix, vertices[VertexPosition]))
render(render_vertex_texture(prefix, vertices[VertexTexture]))
render(render_vertex_normals(prefix, vertices[VertexNormal]))
materials_by_lib_name = set((m.lib, m.name) for m in materials.values())
material_names = set()
for _, name in materials_by_lib_name:
assert name not in material_names
material_names.add(name)
material_libs = set(lib for lib, _ in materials_by_lib_name)
for material_lib in material_libs:
with open(material_lib) as f:
buf = f.read()
newmtl_mapkd = [
(newmtl, mapkd)
for (newmtl, mapkd) in parse_mtl_file(buf)
if newmtl.name in material_names
]
render(render_materials(prefix, newmtl_mapkd))
for object_name, d in faces.items():
object_prefix = '_'.join((prefix, object_name))

View File

@ -0,0 +1,117 @@
from dataclasses import dataclass
from generate import renderer
from math import log
from path import texture_path
import sys
from PIL import Image
from parse_material import parse_mtl_file
material_filenames = sys.argv[1:]
def render_material_enum(newmtl_mapkd):
yield f"enum material {{"
for newmtl, mapkd in newmtl_mapkd:
yield f"{newmtl.name},";
yield "};"
def render_pixel_descriptor(offset, mapkd, dimensions):
name, _ext = mapkd.name.rsplit('.', maxsplit=1)
pixel_name = f"{name}_data"
width, height = dimensions
yield ".pixel = {"
yield f".start = (uint8_t *)&_binary_{pixel_name}_start,"
yield f".size = (int)&_binary_{pixel_name}_size,"
yield f".vram_offset = {offset.pixel},"
yield f".width = {width},"
yield f".height = {height},"
yield "},"
def render_palette_descriptor(offset, mapkd, palette_size):
name, _ext = mapkd.name.rsplit('.', maxsplit=1)
palette_name = f"{name}_data_pal"
yield ".palette = {"
yield f".start = (uint8_t *)&_binary_{palette_name}_start,"
yield f".size = (int)&_binary_{palette_name}_size,"
yield f".vram_offset = {offset.palette},"
yield f".palette_size = {palette_size},"
yield "},"
@dataclass
class Offset:
pixel: int
palette: int
def round_up_colors(name, colors):
assert colors != 0, (name, colors)
if colors <= 4:
return 4
elif colors <= 16:
return 16
elif colors <= 256:
return 256
else:
assert False, (name, colors)
def image_metadata(mapkd):
path = texture_path(mapkd.name)
with Image.open(path) as im:
dimensions = im.size
colors = len(im.palette.colors)
return dimensions, colors
def round_up_n(x, multiple):
return ((x + multiple - 1) // multiple) * multiple
def bytes_per_pixel(palette_size):
bits_per_pixel = int(log(palette_size)/log(2))
return bits_per_pixel / 8
def render_material(offset, mapkd):
dimensions, colors = image_metadata(mapkd)
palette_size = round_up_colors(mapkd.name, colors)
# pixel descriptor
yield from render_pixel_descriptor(offset, mapkd, dimensions)
pixel_size = bytes_per_pixel(palette_size) * dimensions[0] * dimensions[1]
assert int(pixel_size) == pixel_size
offset.pixel += round_up_n(int(pixel_size), 8)
# palette descriptor
yield from render_palette_descriptor(offset, mapkd, palette_size)
offset.palette += round_up_n(colors * 2, 16)
def render_materials(newmtl_mapkd):
yield "struct material_descriptor material[] = {"
offset = Offset(0, 0)
for newmtl, mapkd in newmtl_mapkd:
yield f"[{newmtl.name}] = {{"
yield from render_material(offset, mapkd)
yield "},"
yield "};"
def render_header():
yield "#pragma once"
yield ""
yield "#include <stdint.h>"
yield ""
yield '#include "model/material.h"'
yield ""
if __name__ == "__main__":
material_filenames = sys.argv[1:]
newmtl_mapkd = []
for material_filename in material_filenames:
with open(material_filename) as f:
buf = f.read()
newmtl_mapkd.extend([
(newmtl, mapkd)
for (newmtl, mapkd) in parse_mtl_file(buf)
])
render, out = renderer()
render(render_header())
render(render_material_enum(newmtl_mapkd))
render(render_materials(newmtl_mapkd))
sys.stdout.write(out.getvalue())

BIN
texture/060067E0.data.pal Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
texture/060077E0.data Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
mż7˙W

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
texture/060079E0.data Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
´5~N^w

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
texture/06007BE0.data Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
D%�6qK

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
texture/06007DE0.data Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
�E�QKZLVnZ�f3oSststw

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
texture/06007FE0.data.pal Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
texture/bowser.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
texture/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

11
texture/texture.mk Normal file
View File

@ -0,0 +1,11 @@
%.data: %.png
python ../res/binary_image_palette.py $< $@
%.data.pal: %.png
python ../res/binary_image_palette.py $< $@
%.data.h: %.data
$(BUILD_BINARY_H)
%.data.pal.h: %.data.pal
$(BUILD_BINARY_H)