mirror of
https://github.com/buhman/nds.git
synced 2025-06-18 14:35:38 -04:00
model: enable 4-color and 16-color modes
This commit is contained in:
parent
3aea58f4a9
commit
b49f61292f
@ -461,8 +461,8 @@ void main()
|
||||
while (io_registers.a.GXSTAT & GXSTAT__geometry_engine_busy);
|
||||
|
||||
// wait for the end of the current frame
|
||||
while (io_registers.a.VCOUNT != 262);
|
||||
while (io_registers.a.VCOUNT == 262);
|
||||
//while (io_registers.a.VCOUNT != 262);
|
||||
//while (io_registers.a.VCOUNT == 262);
|
||||
|
||||
// swap buffers
|
||||
io_registers.a.SWAP_BUFFERS = 0;
|
||||
|
@ -66,7 +66,27 @@ if palette is None:
|
||||
convert_colors(f, pixels)
|
||||
else:
|
||||
with open(out_file, 'wb') as f:
|
||||
for pixel in pixels:
|
||||
f.write(struct.pack("<B", pixel))
|
||||
if len(palette) <= 4:
|
||||
for i in range(len(pixels) // 4):
|
||||
a = pixels[i * 4 + 0]
|
||||
b = pixels[i * 4 + 1]
|
||||
c = pixels[i * 4 + 2]
|
||||
d = pixels[i * 4 + 3]
|
||||
assert a <= 3 and b <= 3 and c <= 3 and d <= 3, (a, b, c, d)
|
||||
pixel = (d << 6) | (c << 4) | (b << 2) | (a << 0)
|
||||
f.write(struct.pack("<B", pixel))
|
||||
elif len(palette) <= 16:
|
||||
for i in range(len(pixels) // 2):
|
||||
a = pixels[i * 2 + 0]
|
||||
b = pixels[i * 2 + 1]
|
||||
assert a <= 15 and b <= 15, (a, b)
|
||||
pixel = (b << 4) | (a << 0)
|
||||
f.write(struct.pack("<B", pixel))
|
||||
elif len(palette) <= 256:
|
||||
for pixel in pixels:
|
||||
assert pixel <= 255
|
||||
f.write(struct.pack("<B", pixel))
|
||||
else:
|
||||
assert False, len(palette)
|
||||
with open(out_file + '.pal', 'wb') as f:
|
||||
convert_colors(f, [(*c, 255) for c in palette])
|
||||
|
@ -45,7 +45,6 @@ class Offset:
|
||||
|
||||
def round_up_colors(name, colors):
|
||||
assert colors != 0, (name, colors)
|
||||
return 256
|
||||
if colors <= 4:
|
||||
return 4
|
||||
if colors <= 16:
|
||||
|
@ -102,14 +102,14 @@ struct material_descriptor material[] = {
|
||||
.start = (uint8_t *)&_binary_p_ref_or_data_pal_start,
|
||||
.size = (int)&_binary_p_ref_or_data_pal_size,
|
||||
.vram_offset = 1472,
|
||||
.palette_size = 256,
|
||||
.palette_size = 4,
|
||||
},
|
||||
},
|
||||
[u_lb] = {
|
||||
.pixel = {
|
||||
.start = (uint8_t *)&_binary_u_lb_data_start,
|
||||
.size = (int)&_binary_u_lb_data_size,
|
||||
.vram_offset = 95232,
|
||||
.vram_offset = 92160,
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
},
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user