dreamcast2: add suzanne_triangle_strips

This commit is contained in:
Zack Buhman 2025-09-04 21:28:01 -05:00
parent 403ac12171
commit 35cd182bab
4 changed files with 1338 additions and 2 deletions

View File

@ -1,4 +1,3 @@
#include "memorymap.hpp" #include "memorymap.hpp"
#include "holly/core/object_list_bits.hpp" #include "holly/core/object_list_bits.hpp"
@ -309,7 +308,6 @@ void transfer_ta_cube(uint32_t texture_address)
vertex_perspective_divide( vertex_perspective_divide(
vertex_rotate(cube_vertex_position[ipc]))); vertex_rotate(cube_vertex_position[ipc])));
int ita = cube_faces[face_ix].a.texture; int ita = cube_faces[face_ix].a.texture;
int itb = cube_faces[face_ix].b.texture; int itb = cube_faces[face_ix].b.texture;
int itc = cube_faces[face_ix].c.texture; int itc = cube_faces[face_ix].c.texture;

View File

@ -52,6 +52,13 @@ CUBE_TA_FULLSCREEN_TEXTURED_OBJ = \
example/cube_ta_fullscreen_textured.elf: LDSCRIPT = $(LIB)/main.lds example/cube_ta_fullscreen_textured.elf: LDSCRIPT = $(LIB)/main.lds
example/cube_ta_fullscreen_textured.elf: $(START_OBJ) $(CUBE_TA_FULLSCREEN_TEXTURED_OBJ) example/cube_ta_fullscreen_textured.elf: $(START_OBJ) $(CUBE_TA_FULLSCREEN_TEXTURED_OBJ)
SUZANNE_TRIANGLE_STRIPS_OBJ = \
holly/core/region_array.o \
example/suzanne_triangle_strips.o
example/suzanne_triangle_strips.elf: LDSCRIPT = $(LIB)/main.lds
example/suzanne_triangle_strips.elf: $(START_OBJ) $(SUZANNE_TRIANGLE_STRIPS_OBJ)
TETRAHEDRON_OBJ = \ TETRAHEDRON_OBJ = \
holly/core/region_array.o \ holly/core/region_array.o \
example/tetrahedron.o example/tetrahedron.o

View File

@ -0,0 +1,820 @@
static const int strips[] = {
// strip_0
42, 2, 4, 8, 6, 14, 16, 20, 18, 26, 28, 32, 30, 38, 40, 44, 42, -2,
// strip_1
44, 0, 2, 10, 8, 12, 14, 22, 20, 24, 26, 34, 32, 36, 38, 46, 44, 0,
// strip_2
0, 46, 64, 48, 60, 50, 52, 34, -24,
// strip_3
34, 50, 36, 48, -46,
// strip_4
43, 5, 3, 9, 11, 13, 59, 57, 61, 55, 53, 25, 35, 27, 33, 29, -31,
// strip_5
5, 7, 9, 15, 13, 23, 57, -55,
// strip_6
7, 17, 15, 21, 23, 25, -55,
// strip_7
17, 19, 21, 27, -25,
// strip_8
27, 19, -29,
// strip_9
41, 43, 45, 3, 1, 11, 63, 59, -61,
// strip_10
45, 1, 47, 65, 49, 61, 51, 53, -35,
// strip_11
1, 63, 65, -61,
// strip_12
10, 0, 62, 64, -60,
// strip_13
12, 10, 58, 62, -60,
// strip_14
22, 12, 56, 58, -60,
// strip_15
24, 22, 54, 56, -60,
// strip_16
24, 54, 52, -60,
// strip_17
33, 31, 39, 41, -45,
// strip_18
45, 47, 39, 37, 33, -35,
// strip_19
47, 49, 37, 51, -35,
// strip_20
137, 70, 138, 196, 139, 194, 141, 192, 143, 190, 69, 207, 191, 206, 204, 207, 198, 203, 199, 201, 194, -192,
// strip_21
194, 196, 199, -198,
// strip_22
196, 70, 198, 197, 200, 195, 202, 193, 204, -191,
// strip_23
70, 138, 197, 140, 195, 142, 193, 144, 191, -69,
// strip_24
198, 200, 204, -202,
// strip_25
201, 203, 192, -190,
// strip_26
143, 69, 189, 144, 187, 213, 166, 209, 81, 326, 83, 332, 85, 330, 87, 334, 89, 340, 90, 305, 339, 306, 335, 307, 337, 308, 327, 347, 341, 383, 343, 299, 345, 91, 78, 163, 214, 210, 212, 143, 186, 189, 188, 187, 68, 185, 131, 170, 133, 172, 135, 174, 136, 175, 173, 90, 88, 339, 333, 335, 329, 331, 84, 82, 167, 165, 186, -212,
// strip_27
175, 174, 90, -89,
// strip_28
174, 172, 89, -87,
// strip_29
172, 170, 87, -85,
// strip_30
81, 83, 166, 168, 187, -185,
// strip_31
185, 168, 170, -85,
// strip_32
168, 83, -85,
// strip_33
188, 68, 186, 184, 167, 169, 84, 86, 329, -333,
// strip_34
333, 86, 88, 171, 173, 134, 136, 216, 135, 218, 133, 220, 131, 222, 129, 71, 221, 224, 226, 228, 219, 217, 132, 134, -171,
// strip_35
86, 169, 171, -132,
// strip_36
131, 129, 68, 130, 184, -169,
// strip_37
169, 130, 132, -219,
// strip_38
129, 221, 130, -219,
// strip_39
221, 226, -219,
// strip_40
143, 210, 141, 163, 139, 176, 138, -140,
// strip_41
78, 214, 345, -343,
// strip_42
134, 217, 216, 230, 218, 229, 220, 227, 222, 225, 71, 223, 224, 230, 228, -217,
// strip_43
227, 229, 225, 230, -223,
// strip_44
305, 340, 306, 336, 307, 338, 308, 328, 348, 342, 384, 344, 300, 346, 92, 79, 164, 215, 211, 213, -144,
// strip_45
144, 142, 211, -164,
// strip_46
142, 140, 164, 176, 181, 177, 183, 67, 112, 162, 110, 128, 238, 236, 278, -274,
// strip_47
213, 215, 209, 342, 326, 328, 332, 338, -336,
// strip_48
278, 276, 238, 256, 110, -112,
// strip_49
276, 258, 256, 254, 112, -183,
// strip_50
258, 260, 254, 232, 183, -181,
// strip_51
260, 282, 232, 234, 181, 114, 164, 116, 146, 118, 148, 120, 150, 122, 152, 124, 154, 126, 156, 179, 158, 160, 106, 108, 284, 72, 73, 283, 289, 285, 287, 103, 101, 155, 153, 125, 123, 241, 243, 269, -267,
// strip_52
164, 146, 92, 94, 298, 296, 310, 362, 312, 368, 382, 370, 376, 374, 378, 354, 316, 75, 76, 315, 323, 377, 379, 321, 385, 319, 383, 317, 299, 297, 91, 93, 145, 147, 117, 119, 247, 245, 265, -267,
// strip_53
91, 145, 163, 115, 113, 251, 233, 279, -281,
// strip_54
146, 148, 94, 96, 296, 294, 362, 364, 366, 360, 358, 301, 302, 357, 355, 371, 373, 369, 375, 381, 313, 505, 321, 503, 389, 501, 391, 499, 393, 497, 395, 495, 397, 493, 399, 505, 387, 381, 429, 447, 449, 431, 451, 461, 483, 477, 479, 455, 473, 453, 417, 439, 443, 445, 441, 447, 311, 381, 367, 369, -371,
// strip_55
148, 150, 96, 98, 294, 292, 364, -360,
// strip_56
150, 152, 98, 100, 292, 290, 360, 73, 301, 359, 357, 365, 371, -367,
// strip_57
152, 154, 100, 102, 290, 288, 286, 104, 106, -158,
// strip_58
154, 156, 102, 104, -288,
// strip_59
104, 156, -158,
// strip_60
145, 117, 115, 249, 251, 261, -279,
// strip_61
117, 247, 249, 263, -261,
// strip_62
247, 265, -263,
// strip_63
269, 241, 271, 239, 273, 235, 277, 237, 275, 255, 257, 253, 259, 231, 281, -233,
// strip_64
241, 125, 239, 178, 235, 127, 237, 109, 255, 111, 253, 182, 231, 180, 233, -113,
// strip_65
125, 155, 178, 157, 159, 105, 107, 283, -72,
// strip_66
155, 103, 157, -105,
// strip_67
103, 285, 105, -283,
// strip_68
178, 159, 127, 161, 109, -111,
// strip_69
159, 107, 161, 66, 67, -162,
// strip_70
107, 72, 66, 108, 162, 160, 128, 179, 236, 240, 274, -272,
// strip_71
113, 180, 163, -176,
// strip_72
161, 67, 111, -182,
// strip_73
67, 177, 182, -180,
// strip_74
180, 177, -176,
// strip_75
179, 126, 240, 242, 272, -270,
// strip_76
126, 124, 242, 244, 270, -268,
// strip_77
124, 122, 244, 246, 268, -266,
// strip_78
122, 120, 246, 248, 266, -264,
// strip_79
120, 118, 248, 250, 264, -262,
// strip_80
118, 116, 250, 252, 262, -280,
// strip_81
116, 114, 252, 234, 280, -282,
// strip_82
267, 245, 243, 121, 123, 151, 153, 99, 101, 289, -287,
// strip_83
245, 119, 121, 149, 151, 97, 99, 291, 289, 359, -73,
// strip_84
119, 147, 149, 95, 97, 293, 291, 363, 359, -365,
// strip_85
147, 93, 95, 295, 293, 361, 363, -365,
// strip_86
106, 284, 286, -290,
// strip_87
290, 284, -73,
// strip_88
93, 297, 295, 309, 361, 311, -367,
// strip_89
361, 367, -365,
// strip_90
92, 298, 300, 318, 384, 320, 386, 322, 380, 378, 324, 316, -76,
// strip_91
340, 334, 336, 330, -332,
// strip_92
335, 337, 331, 327, 325, 341, 208, 214, -212,
// strip_93
341, 343, -214,
// strip_94
212, 165, 208, 80, 325, 82, -331,
// strip_95
165, 82, -80,
// strip_96
342, 215, 344, -346,
// strip_97
215, 79, -346,
// strip_98
297, 317, 309, -311,
// strip_99
298, 310, 318, 312, 442, 448, 446, 434, 436, 460, 458, 478, 456, 480, 474, 482, 472, 488, 470, 490, 468, 492, 466, 464, 428, 416, 414, 430, 388, 382, 506, 314, 322, -378,
// strip_100
362, 366, 368, 372, 370, -374,
// strip_101
321, 377, 313, -375,
// strip_102
375, 377, 373, 353, 355, 74, 302, 356, 358, 372, -366,
// strip_103
378, 314, 376, -382,
// strip_104
377, 315, 353, 75, 74, 354, 356, 374, -372,
// strip_105
321, 389, 319, 443, -441,
// strip_106
319, 441, 317, -311,
// strip_107
318, 442, 320, 444, 390, 412, 410, 420, 422, 472, -470,
// strip_108
442, 446, 444, 440, 418, 454, 474, -456,
// strip_109
444, 418, 412, -420,
// strip_110
418, 474, 420, -472,
// strip_111
312, 382, 448, 430, 450, 416, 476, 464, -492,
// strip_112
453, 455, 439, 437, 445, 435, 433, 459, 461, -477,
// strip_113
445, 433, 447, -431,
// strip_114
433, 461, -431,
// strip_115
454, 440, 456, 438, 458, -436,
// strip_116
440, 446, 438, -436,
// strip_117
490, 488, 492, 486, 476, 484, 452, 462, 432, 434, -448,
// strip_118
448, 450, 432, -452,
// strip_119
450, 476, -452,
// strip_120
434, 462, 460, -478,
// strip_121
488, 482, 486, -484,
// strip_122
482, 480, 484, 478, -462,
// strip_123
503, 505, 501, 493, -495,
// strip_124
501, 495, 499, -497,
// strip_125
320, 390, 322, 504, 506, 502, 494, 496, 398, 396, 404, 406, 426, 424, 468, -470,
// strip_126
470, 424, 422, 408, 410, 392, 390, 502, -504,
// strip_127
424, 406, 408, 394, 392, 500, 502, -496,
// strip_128
406, 396, 394, 498, 500, -496,
// strip_129
396, 496, -498,
// strip_130
468, 466, 426, 428, 404, 402, 398, 400, 494, -506,
// strip_131
428, 414, 402, 388, 400, -506,
// strip_132
203, 207, 205, 190, -203,
// strip_133
324, 76, 303, 323, 351, 379, -385,
// strip_134
324, 303, 352, 77, 350, 304, 348, -308,
// strip_135
324, 352, 380, -386,
// strip_136
303, 351, 77, 349, 304, 347, -308,
// strip_137
352, 350, 386, -384,
// strip_138
350, 348, -384,
// strip_139
347, 349, 383, -385,
// strip_140
351, 385, -349,
// strip_141
399, 387, 401, 413, 427, 415, 463, 475, 491, 485, 487, 481, 471, 473, 419, 417, 411, 443, -389,
// strip_142
399, 401, 397, 403, 395, 405, 393, 407, 391, 409, 389, -411,
// strip_143
411, 409, 419, 421, 471, 469, 487, 489, 491, 467, 465, 425, 427, 403, -401,
// strip_144
409, 407, 421, 423, 469, 467, -489,
// strip_145
407, 405, 423, 425, -467,
// strip_146
425, 405, -403,
// strip_147
387, 429, 413, -415,
// strip_148
429, 449, 415, -475,
// strip_149
449, 451, 475, 483, 485, -481,
// strip_150
427, 463, 465, -491,
// strip_151
483, 479, 481, -473,
// strip_152
477, 459, 457, 435, -437,
// strip_153
437, 455, 457, -477,
};
static const vec3 vertices[] = {
{0.4375000, -0.7656250, 0.1640625},
{-0.4375000, -0.7656250, 0.1640625},
{0.5000000, -0.6875000, 0.0937500},
{-0.5000000, -0.6875000, 0.0937500},
{0.5468750, -0.5781250, 0.0546875},
{-0.5468750, -0.5781250, 0.0546875},
{0.3515625, -0.6171875, -0.0234375},
{-0.3515625, -0.6171875, -0.0234375},
{0.3515625, -0.7187500, 0.0312500},
{-0.3515625, -0.7187500, 0.0312500},
{0.3515625, -0.7812500, 0.1328125},
{-0.3515625, -0.7812500, 0.1328125},
{0.2734375, -0.7968750, 0.1640625},
{-0.2734375, -0.7968750, 0.1640625},
{0.2031250, -0.7421875, 0.0937500},
{-0.2031250, -0.7421875, 0.0937500},
{0.1562500, -0.6484375, 0.0546875},
{-0.1562500, -0.6484375, 0.0546875},
{0.0781250, -0.6562500, 0.2421875},
{-0.0781250, -0.6562500, 0.2421875},
{0.1406250, -0.7421875, 0.2421875},
{-0.1406250, -0.7421875, 0.2421875},
{0.2421875, -0.7968750, 0.2421875},
{-0.2421875, -0.7968750, 0.2421875},
{0.2734375, -0.7968750, 0.3281250},
{-0.2734375, -0.7968750, 0.3281250},
{0.2031250, -0.7421875, 0.3906250},
{-0.2031250, -0.7421875, 0.3906250},
{0.1562500, -0.6484375, 0.4375000},
{-0.1562500, -0.6484375, 0.4375000},
{0.3515625, -0.6171875, 0.5156250},
{-0.3515625, -0.6171875, 0.5156250},
{0.3515625, -0.7187500, 0.4531250},
{-0.3515625, -0.7187500, 0.4531250},
{0.3515625, -0.7812500, 0.3593750},
{-0.3515625, -0.7812500, 0.3593750},
{0.4375000, -0.7656250, 0.3281250},
{-0.4375000, -0.7656250, 0.3281250},
{0.5000000, -0.6875000, 0.3906250},
{-0.5000000, -0.6875000, 0.3906250},
{0.5468750, -0.5781250, 0.4375000},
{-0.5468750, -0.5781250, 0.4375000},
{0.6250000, -0.5625000, 0.2421875},
{-0.6250000, -0.5625000, 0.2421875},
{0.5625000, -0.6718750, 0.2421875},
{-0.5625000, -0.6718750, 0.2421875},
{0.4687500, -0.7578125, 0.2421875},
{-0.4687500, -0.7578125, 0.2421875},
{0.4765625, -0.7734375, 0.2421875},
{-0.4765625, -0.7734375, 0.2421875},
{0.4453125, -0.7812500, 0.3359375},
{-0.4453125, -0.7812500, 0.3359375},
{0.3515625, -0.8046875, 0.3750000},
{-0.3515625, -0.8046875, 0.3750000},
{0.2656250, -0.8203125, 0.3359375},
{-0.2656250, -0.8203125, 0.3359375},
{0.2265625, -0.8203125, 0.2421875},
{-0.2265625, -0.8203125, 0.2421875},
{0.2656250, -0.8203125, 0.1562500},
{-0.2656250, -0.8203125, 0.1562500},
{0.3515625, -0.8281250, 0.2421875},
{-0.3515625, -0.8281250, 0.2421875},
{0.3515625, -0.8046875, 0.1171875},
{-0.3515625, -0.8046875, 0.1171875},
{0.4453125, -0.7812500, 0.1562500},
{-0.4453125, -0.7812500, 0.1562500},
{0.0000000, -0.7421875, 0.4296875},
{0.0000000, -0.8203125, 0.3515625},
{0.0000000, -0.7343750, -0.6796875},
{0.0000000, -0.7812500, -0.3203125},
{0.0000000, -0.7968750, -0.1875000},
{0.0000000, -0.7187500, -0.7734375},
{0.0000000, -0.6015625, 0.4062500},
{0.0000000, -0.5703125, 0.5703125},
{0.0000000, 0.5468750, 0.8984375},
{0.0000000, 0.8515625, 0.5625000},
{0.0000000, 0.8281250, 0.0703125},
{0.0000000, 0.3515625, -0.3828125},
{0.2031250, -0.5625000, -0.1875000},
{-0.2031250, -0.5625000, -0.1875000},
{0.3125000, -0.5703125, -0.4375000},
{-0.3125000, -0.5703125, -0.4375000},
{0.3515625, -0.5703125, -0.6953125},
{-0.3515625, -0.5703125, -0.6953125},
{0.3671875, -0.5312500, -0.8906250},
{-0.3671875, -0.5312500, -0.8906250},
{0.3281250, -0.5234375, -0.9453125},
{-0.3281250, -0.5234375, -0.9453125},
{0.1796875, -0.5546875, -0.9687500},
{-0.1796875, -0.5546875, -0.9687500},
{0.0000000, -0.5781250, -0.9843750},
{0.4375000, -0.5312500, -0.1406250},
{-0.4375000, -0.5312500, -0.1406250},
{0.6328125, -0.5390625, -0.0390625},
{-0.6328125, -0.5390625, -0.0390625},
{0.8281250, -0.4453125, 0.1484375},
{-0.8281250, -0.4453125, 0.1484375},
{0.8593750, -0.5937500, 0.4296875},
{-0.8593750, -0.5937500, 0.4296875},
{0.7109375, -0.6250000, 0.4843750},
{-0.7109375, -0.6250000, 0.4843750},
{0.4921875, -0.6875000, 0.6015625},
{-0.4921875, -0.6875000, 0.6015625},
{0.3203125, -0.7343750, 0.7578125},
{-0.3203125, -0.7343750, 0.7578125},
{0.1562500, -0.7578125, 0.7187500},
{-0.1562500, -0.7578125, 0.7187500},
{0.0625000, -0.7500000, 0.4921875},
{-0.0625000, -0.7500000, 0.4921875},
{0.1640625, -0.7734375, 0.4140625},
{-0.1640625, -0.7734375, 0.4140625},
{0.1250000, -0.7656250, 0.3046875},
{-0.1250000, -0.7656250, 0.3046875},
{0.2031250, -0.7421875, 0.0937500},
{-0.2031250, -0.7421875, 0.0937500},
{0.3750000, -0.7031250, 0.0156250},
{-0.3750000, -0.7031250, 0.0156250},
{0.4921875, -0.6718750, 0.0625000},
{-0.4921875, -0.6718750, 0.0625000},
{0.6250000, -0.6484375, 0.1875000},
{-0.6250000, -0.6484375, 0.1875000},
{0.6406250, -0.6484375, 0.2968750},
{-0.6406250, -0.6484375, 0.2968750},
{0.6015625, -0.6640625, 0.3750000},
{-0.6015625, -0.6640625, 0.3750000},
{0.4296875, -0.7187500, 0.4375000},
{-0.4296875, -0.7187500, 0.4375000},
{0.2500000, -0.7578125, 0.4687500},
{-0.2500000, -0.7578125, 0.4687500},
{0.0000000, -0.7343750, -0.7656250},
{0.1093750, -0.7343750, -0.7187500},
{-0.1093750, -0.7343750, -0.7187500},
{0.1171875, -0.7109375, -0.8359375},
{-0.1171875, -0.7109375, -0.8359375},
{0.0625000, -0.6953125, -0.8828125},
{-0.0625000, -0.6953125, -0.8828125},
{0.0000000, -0.6875000, -0.8906250},
{0.0000000, -0.7500000, -0.1953125},
{0.0000000, -0.7421875, -0.1406250},
{0.1015625, -0.7421875, -0.1484375},
{-0.1015625, -0.7421875, -0.1484375},
{0.1250000, -0.7500000, -0.2265625},
{-0.1250000, -0.7500000, -0.2265625},
{0.0859375, -0.7421875, -0.2890625},
{-0.0859375, -0.7421875, -0.2890625},
{0.3984375, -0.6718750, -0.0468750},
{-0.3984375, -0.6718750, -0.0468750},
{0.6171875, -0.6250000, 0.0546875},
{-0.6171875, -0.6250000, 0.0546875},
{0.7265625, -0.6015625, 0.2031250},
{-0.7265625, -0.6015625, 0.2031250},
{0.7421875, -0.6562500, 0.3750000},
{-0.7421875, -0.6562500, 0.3750000},
{0.6875000, -0.7265625, 0.4140625},
{-0.6875000, -0.7265625, 0.4140625},
{0.4375000, -0.7968750, 0.5468750},
{-0.4375000, -0.7968750, 0.5468750},
{0.3125000, -0.8359375, 0.6406250},
{-0.3125000, -0.8359375, 0.6406250},
{0.2031250, -0.8515625, 0.6171875},
{-0.2031250, -0.8515625, 0.6171875},
{0.1015625, -0.8437500, 0.4296875},
{-0.1015625, -0.8437500, 0.4296875},
{0.1250000, -0.8125000, -0.1015625},
{-0.1250000, -0.8125000, -0.1015625},
{0.2109375, -0.7109375, -0.4453125},
{-0.2109375, -0.7109375, -0.4453125},
{0.2500000, -0.6875000, -0.7031250},
{-0.2500000, -0.6875000, -0.7031250},
{0.2656250, -0.6640625, -0.8203125},
{-0.2656250, -0.6640625, -0.8203125},
{0.2343750, -0.6328125, -0.9140625},
{-0.2343750, -0.6328125, -0.9140625},
{0.1640625, -0.6328125, -0.9296875},
{-0.1640625, -0.6328125, -0.9296875},
{0.0000000, -0.6406250, -0.9453125},
{0.0000000, -0.7265625, 0.0468750},
{0.0000000, -0.7656250, 0.2109375},
{0.3281250, -0.7421875, 0.4765625},
{-0.3281250, -0.7421875, 0.4765625},
{0.1640625, -0.7500000, 0.1406250},
{-0.1640625, -0.7500000, 0.1406250},
{0.1328125, -0.7578125, 0.2109375},
{-0.1328125, -0.7578125, 0.2109375},
{0.1171875, -0.7343750, -0.6875000},
{-0.1171875, -0.7343750, -0.6875000},
{0.0781250, -0.7500000, -0.4453125},
{-0.0781250, -0.7500000, -0.4453125},
{0.0000000, -0.7500000, -0.4453125},
{0.0000000, -0.7421875, -0.3281250},
{0.0937500, -0.7812500, -0.2734375},
{-0.0937500, -0.7812500, -0.2734375},
{0.1328125, -0.7968750, -0.2265625},
{-0.1328125, -0.7968750, -0.2265625},
{0.1093750, -0.7812500, -0.1328125},
{-0.1093750, -0.7812500, -0.1328125},
{0.0390625, -0.7812500, -0.1250000},
{-0.0390625, -0.7812500, -0.1250000},
{0.0000000, -0.8281250, -0.2031250},
{0.0468750, -0.8125000, -0.1484375},
{-0.0468750, -0.8125000, -0.1484375},
{0.0937500, -0.8125000, -0.1562500},
{-0.0937500, -0.8125000, -0.1562500},
{0.1093750, -0.8281250, -0.2265625},
{-0.1093750, -0.8281250, -0.2265625},
{0.0781250, -0.8046875, -0.2500000},
{-0.0781250, -0.8046875, -0.2500000},
{0.0000000, -0.8046875, -0.2890625},
{0.2578125, -0.5546875, -0.3125000},
{-0.2578125, -0.5546875, -0.3125000},
{0.1640625, -0.7109375, -0.2421875},
{-0.1640625, -0.7109375, -0.2421875},
{0.1796875, -0.7109375, -0.3125000},
{-0.1796875, -0.7109375, -0.3125000},
{0.2343750, -0.5546875, -0.2500000},
{-0.2343750, -0.5546875, -0.2500000},
{0.0000000, -0.6875000, -0.8750000},
{0.0468750, -0.6875000, -0.8671875},
{-0.0468750, -0.6875000, -0.8671875},
{0.0937500, -0.7109375, -0.8203125},
{-0.0937500, -0.7109375, -0.8203125},
{0.0937500, -0.7265625, -0.7421875},
{-0.0937500, -0.7265625, -0.7421875},
{0.0000000, -0.6562500, -0.7812500},
{0.0937500, -0.6640625, -0.7500000},
{-0.0937500, -0.6640625, -0.7500000},
{0.0937500, -0.6406250, -0.8125000},
{-0.0937500, -0.6406250, -0.8125000},
{0.0468750, -0.6328125, -0.8515625},
{-0.0468750, -0.6328125, -0.8515625},
{0.0000000, -0.6328125, -0.8593750},
{0.1718750, -0.7812500, 0.2187500},
{-0.1718750, -0.7812500, 0.2187500},
{0.1875000, -0.7734375, 0.1562500},
{-0.1875000, -0.7734375, 0.1562500},
{0.3359375, -0.7578125, 0.4296875},
{-0.3359375, -0.7578125, 0.4296875},
{0.2734375, -0.7734375, 0.4218750},
{-0.2734375, -0.7734375, 0.4218750},
{0.4218750, -0.7734375, 0.3984375},
{-0.4218750, -0.7734375, 0.3984375},
{0.5625000, -0.6953125, 0.3515625},
{-0.5625000, -0.6953125, 0.3515625},
{0.5859375, -0.6875000, 0.2890625},
{-0.5859375, -0.6875000, 0.2890625},
{0.5781250, -0.6796875, 0.1953125},
{-0.5781250, -0.6796875, 0.1953125},
{0.4765625, -0.7187500, 0.1015625},
{-0.4765625, -0.7187500, 0.1015625},
{0.3750000, -0.7421875, 0.0625000},
{-0.3750000, -0.7421875, 0.0625000},
{0.2265625, -0.7812500, 0.1093750},
{-0.2265625, -0.7812500, 0.1093750},
{0.1796875, -0.7812500, 0.2968750},
{-0.1796875, -0.7812500, 0.2968750},
{0.2109375, -0.7812500, 0.3750000},
{-0.2109375, -0.7812500, 0.3750000},
{0.2343750, -0.7578125, 0.3593750},
{-0.2343750, -0.7578125, 0.3593750},
{0.1953125, -0.7578125, 0.2968750},
{-0.1953125, -0.7578125, 0.2968750},
{0.2421875, -0.7578125, 0.1250000},
{-0.2421875, -0.7578125, 0.1250000},
{0.3750000, -0.7265625, 0.0859375},
{-0.3750000, -0.7265625, 0.0859375},
{0.4609375, -0.7031250, 0.1171875},
{-0.4609375, -0.7031250, 0.1171875},
{0.5468750, -0.6718750, 0.2109375},
{-0.5468750, -0.6718750, 0.2109375},
{0.5546875, -0.6718750, 0.2812500},
{-0.5546875, -0.6718750, 0.2812500},
{0.5312500, -0.6796875, 0.3359375},
{-0.5312500, -0.6796875, 0.3359375},
{0.4140625, -0.7500000, 0.3906250},
{-0.4140625, -0.7500000, 0.3906250},
{0.2812500, -0.7656250, 0.3984375},
{-0.2812500, -0.7656250, 0.3984375},
{0.3359375, -0.7500000, 0.4062500},
{-0.3359375, -0.7500000, 0.4062500},
{0.2031250, -0.7500000, 0.1718750},
{-0.2031250, -0.7500000, 0.1718750},
{0.1953125, -0.7500000, 0.2265625},
{-0.1953125, -0.7500000, 0.2265625},
{0.1093750, -0.6093750, 0.4609375},
{-0.1093750, -0.6093750, 0.4609375},
{0.1953125, -0.6171875, 0.6640625},
{-0.1953125, -0.6171875, 0.6640625},
{0.3359375, -0.5937500, 0.6875000},
{-0.3359375, -0.5937500, 0.6875000},
{0.4843750, -0.5546875, 0.5546875},
{-0.4843750, -0.5546875, 0.5546875},
{0.6796875, -0.4921875, 0.4531250},
{-0.6796875, -0.4921875, 0.4531250},
{0.7968750, -0.4609375, 0.4062500},
{-0.7968750, -0.4609375, 0.4062500},
{0.7734375, -0.3750000, 0.1640625},
{-0.7734375, -0.3750000, 0.1640625},
{0.6015625, -0.4140625, 0.0000000},
{-0.6015625, -0.4140625, 0.0000000},
{0.4375000, -0.4687500, -0.0937500},
{-0.4375000, -0.4687500, -0.0937500},
{0.0000000, -0.2890625, 0.8984375},
{0.0000000, 0.0781250, 0.9843750},
{0.0000000, 0.6718750, -0.1953125},
{0.0000000, -0.1875000, -0.4609375},
{0.0000000, -0.4609375, -0.9765625},
{0.0000000, -0.3437500, -0.8046875},
{0.0000000, -0.3203125, -0.5703125},
{0.0000000, -0.2812500, -0.4843750},
{0.8515625, -0.0546875, 0.2343750},
{-0.8515625, -0.0546875, 0.2343750},
{0.8593750, 0.0468750, 0.3203125},
{-0.8593750, 0.0468750, 0.3203125},
{0.7734375, 0.4375000, 0.2656250},
{-0.7734375, 0.4375000, 0.2656250},
{0.4609375, 0.7031250, 0.4375000},
{-0.4609375, 0.7031250, 0.4375000},
{0.7343750, -0.0703125, -0.0468750},
{-0.7343750, -0.0703125, -0.0468750},
{0.5937500, 0.1640625, -0.1250000},
{-0.5937500, 0.1640625, -0.1250000},
{0.6406250, 0.4296875, -0.0078125},
{-0.6406250, 0.4296875, -0.0078125},
{0.3359375, 0.6640625, 0.0546875},
{-0.3359375, 0.6640625, 0.0546875},
{0.2343750, -0.4062500, -0.3515625},
{-0.2343750, -0.4062500, -0.3515625},
{0.1796875, -0.2578125, -0.4140625},
{-0.1796875, -0.2578125, -0.4140625},
{0.2890625, -0.3828125, -0.7109375},
{-0.2890625, -0.3828125, -0.7109375},
{0.2500000, -0.3906250, -0.5000000},
{-0.2500000, -0.3906250, -0.5000000},
{0.3281250, -0.3984375, -0.9140625},
{-0.3281250, -0.3984375, -0.9140625},
{0.1406250, -0.3671875, -0.7578125},
{-0.1406250, -0.3671875, -0.7578125},
{0.1250000, -0.3593750, -0.5390625},
{-0.1250000, -0.3593750, -0.5390625},
{0.1640625, -0.4375000, -0.9453125},
{-0.1640625, -0.4375000, -0.9453125},
{0.2187500, -0.4296875, -0.2812500},
{-0.2187500, -0.4296875, -0.2812500},
{0.2109375, -0.4687500, -0.2265625},
{-0.2109375, -0.4687500, -0.2265625},
{0.2031250, -0.5000000, -0.1718750},
{-0.2031250, -0.5000000, -0.1718750},
{0.2109375, -0.1640625, -0.3906250},
{-0.2109375, -0.1640625, -0.3906250},
{0.2968750, 0.2656250, -0.3125000},
{-0.2968750, 0.2656250, -0.3125000},
{0.3437500, 0.5390625, -0.1484375},
{-0.3437500, 0.5390625, -0.1484375},
{0.4531250, 0.3828125, 0.8671875},
{-0.4531250, 0.3828125, 0.8671875},
{0.4531250, 0.0703125, 0.9296875},
{-0.4531250, 0.0703125, 0.9296875},
{0.4531250, -0.2343750, 0.8515625},
{-0.4531250, -0.2343750, 0.8515625},
{0.4609375, -0.4296875, 0.5234375},
{-0.4609375, -0.4296875, 0.5234375},
{0.7265625, -0.3359375, 0.4062500},
{-0.7265625, -0.3359375, 0.4062500},
{0.6328125, -0.2812500, 0.4531250},
{-0.6328125, -0.2812500, 0.4531250},
{0.6406250, -0.0546875, 0.7031250},
{-0.6406250, -0.0546875, 0.7031250},
{0.7968750, -0.1250000, 0.5625000},
{-0.7968750, -0.1250000, 0.5625000},
{0.7968750, 0.1171875, 0.6171875},
{-0.7968750, 0.1171875, 0.6171875},
{0.6406250, 0.1953125, 0.7500000},
{-0.6406250, 0.1953125, 0.7500000},
{0.6406250, 0.4453125, 0.6796875},
{-0.6406250, 0.4453125, 0.6796875},
{0.7968750, 0.3593750, 0.5390625},
{-0.7968750, 0.3593750, 0.5390625},
{0.6171875, 0.5859375, 0.3281250},
{-0.6171875, 0.5859375, 0.3281250},
{0.4843750, 0.5468750, 0.0234375},
{-0.4843750, 0.5468750, 0.0234375},
{0.8203125, 0.2031250, 0.3281250},
{-0.8203125, 0.2031250, 0.3281250},
{0.4062500, -0.1484375, -0.1718750},
{-0.4062500, -0.1484375, -0.1718750},
{0.4296875, 0.2109375, -0.1953125},
{-0.4296875, 0.2109375, -0.1953125},
{0.8906250, 0.2343750, 0.4062500},
{-0.8906250, 0.2343750, 0.4062500},
{0.7734375, 0.1250000, -0.1406250},
{-0.7734375, 0.1250000, -0.1406250},
{1.0390625, 0.3281250, -0.1015625},
{-1.0390625, 0.3281250, -0.1015625},
{1.2812500, 0.4296875, 0.0546875},
{-1.2812500, 0.4296875, 0.0546875},
{1.3515625, 0.4218750, 0.3203125},
{-1.3515625, 0.4218750, 0.3203125},
{1.2343750, 0.4218750, 0.5078125},
{-1.2343750, 0.4218750, 0.5078125},
{1.0234375, 0.3125000, 0.4765625},
{-1.0234375, 0.3125000, 0.4765625},
{1.0156250, 0.2890625, 0.4140625},
{-1.0156250, 0.2890625, 0.4140625},
{1.1875000, 0.3906250, 0.4375000},
{-1.1875000, 0.3906250, 0.4375000},
{1.2656250, 0.4062500, 0.2890625},
{-1.2656250, 0.4062500, 0.2890625},
{1.2109375, 0.4062500, 0.0781250},
{-1.2109375, 0.4062500, 0.0781250},
{1.0312500, 0.3046875, -0.0390625},
{-1.0312500, 0.3046875, -0.0390625},
{0.8281250, 0.1328125, -0.0703125},
{-0.8281250, 0.1328125, -0.0703125},
{0.9218750, 0.2187500, 0.3593750},
{-0.9218750, 0.2187500, 0.3593750},
{0.9453125, 0.2890625, 0.3046875},
{-0.9453125, 0.2890625, 0.3046875},
{0.8828125, 0.2109375, -0.0234375},
{-0.8828125, 0.2109375, -0.0234375},
{1.0390625, 0.3671875, 0.0000000},
{-1.0390625, 0.3671875, 0.0000000},
{1.1875000, 0.4453125, 0.0937500},
{-1.1875000, 0.4453125, 0.0937500},
{1.2343750, 0.4453125, 0.2500000},
{-1.2343750, 0.4453125, 0.2500000},
{1.1718750, 0.4375000, 0.3593750},
{-1.1718750, 0.4375000, 0.3593750},
{1.0234375, 0.3593750, 0.3437500},
{-1.0234375, 0.3593750, 0.3437500},
{0.8437500, 0.2109375, 0.2890625},
{-0.8437500, 0.2109375, 0.2890625},
{0.8359375, 0.2734375, 0.1718750},
{-0.8359375, 0.2734375, 0.1718750},
{0.7578125, 0.2734375, 0.0937500},
{-0.7578125, 0.2734375, 0.0937500},
{0.8203125, 0.2734375, 0.0859375},
{-0.8203125, 0.2734375, 0.0859375},
{0.8437500, 0.2734375, 0.0156250},
{-0.8437500, 0.2734375, 0.0156250},
{0.8125000, 0.2734375, -0.0156250},
{-0.8125000, 0.2734375, -0.0156250},
{0.7265625, 0.0703125, 0.0000000},
{-0.7265625, 0.0703125, 0.0000000},
{0.7187500, 0.1718750, -0.0234375},
{-0.7187500, 0.1718750, -0.0234375},
{0.7187500, 0.1875000, 0.0390625},
{-0.7187500, 0.1875000, 0.0390625},
{0.7968750, 0.2109375, 0.2031250},
{-0.7968750, 0.2109375, 0.2031250},
{0.8906250, 0.2656250, 0.2421875},
{-0.8906250, 0.2656250, 0.2421875},
{0.8906250, 0.3203125, 0.2343750},
{-0.8906250, 0.3203125, 0.2343750},
{0.8125000, 0.3203125, -0.0156250},
{-0.8125000, 0.3203125, -0.0156250},
{0.8515625, 0.3203125, 0.0156250},
{-0.8515625, 0.3203125, 0.0156250},
{0.8281250, 0.3203125, 0.0781250},
{-0.8281250, 0.3203125, 0.0781250},
{0.7656250, 0.3203125, 0.0937500},
{-0.7656250, 0.3203125, 0.0937500},
{0.8437500, 0.3203125, 0.1718750},
{-0.8437500, 0.3203125, 0.1718750},
{1.0390625, 0.4140625, 0.3281250},
{-1.0390625, 0.4140625, 0.3281250},
{1.1875000, 0.4843750, 0.3437500},
{-1.1875000, 0.4843750, 0.3437500},
{1.2578125, 0.4921875, 0.2421875},
{-1.2578125, 0.4921875, 0.2421875},
{1.2109375, 0.4843750, 0.0859375},
{-1.2109375, 0.4843750, 0.0859375},
{1.0468750, 0.4218750, 0.0000000},
{-1.0468750, 0.4218750, 0.0000000},
{0.8828125, 0.2656250, -0.0156250},
{-0.8828125, 0.2656250, -0.0156250},
{0.9531250, 0.3437500, 0.2890625},
{-0.9531250, 0.3437500, 0.2890625},
{0.8906250, 0.3281250, 0.1093750},
{-0.8906250, 0.3281250, 0.1093750},
{0.9375000, 0.3359375, 0.0625000},
{-0.9375000, 0.3359375, 0.0625000},
{1.0000000, 0.3671875, 0.1250000},
{-1.0000000, 0.3671875, 0.1250000},
{0.9609375, 0.3515625, 0.1718750},
{-0.9609375, 0.3515625, 0.1718750},
{1.0156250, 0.3750000, 0.2343750},
{-1.0156250, 0.3750000, 0.2343750},
{1.0546875, 0.3828125, 0.1875000},
{-1.0546875, 0.3828125, 0.1875000},
{1.1093750, 0.3906250, 0.2109375},
{-1.1093750, 0.3906250, 0.2109375},
{1.0859375, 0.3906250, 0.2734375},
{-1.0859375, 0.3906250, 0.2734375},
{1.0234375, 0.4843750, 0.4375000},
{-1.0234375, 0.4843750, 0.4375000},
{1.2500000, 0.5468750, 0.4687500},
{-1.2500000, 0.5468750, 0.4687500},
{1.3671875, 0.5000000, 0.2968750},
{-1.3671875, 0.5000000, 0.2968750},
{1.3125000, 0.5312500, 0.0546875},
{-1.3125000, 0.5312500, 0.0546875},
{1.0390625, 0.4921875, -0.0859375},
{-1.0390625, 0.4921875, -0.0859375},
{0.7890625, 0.3281250, -0.1250000},
{-0.7890625, 0.3281250, -0.1250000},
{0.8593750, 0.3828125, 0.3828125},
{-0.8593750, 0.3828125, 0.3828125},
};

View File

@ -0,0 +1,511 @@
#include "memorymap.hpp"
#include "holly/core/object_list_bits.hpp"
#include "holly/core/region_array.hpp"
#include "holly/core/region_array_bits.hpp"
#include "holly/core/parameter_bits.hpp"
#include "holly/core/parameter.hpp"
#include "holly/ta/global_parameter.hpp"
#include "holly/ta/vertex_parameter.hpp"
#include "holly/ta/parameter_bits.hpp"
#include "holly/holly.hpp"
#include "holly/holly_bits.hpp"
#include "sh7091/sh7091.hpp"
#include "sh7091/sh7091_bits.hpp"
#include "sh7091/pref.hpp"
#include "sh7091/store_queue_transfer.hpp"
#include "systembus/systembus.hpp"
#include "systembus/systembus_bits.hpp"
static inline void character(const char c)
{
using sh7091::sh7091;
using namespace sh7091;
// set the transmit trigger to `1 byte`--this changes the behavior of TDFE
sh7091.SCIF.SCFCR2 = scif::scfcr2::ttrg::trigger_on_1_bytes;
// wait for transmit fifo to become partially empty
while ((sh7091.SCIF.SCFSR2 & scif::scfsr2::tdfe::bit_mask) == 0);
// unset tdfe bit
sh7091.SCIF.SCFSR2 = (uint16_t)(~scif::scfsr2::tdfe::bit_mask);
sh7091.SCIF.SCFTDR2 = c;
}
static void string(const char * s)
{
while (*s != 0) {
character(*s++);
}
}
static void print_base16(uint32_t n, int len)
{
char buf[len];
char * bufi = &buf[len - 1];
while (bufi >= buf) {
uint32_t nib = n & 0xf;
n = n >> 4;
if (nib > 9) {
nib += (97 - 10);
} else {
nib += (48 - 0);
}
*bufi = nib;
bufi -= 1;
}
for (int i = 0; i < len; i++) {
character(buf[i]);
}
}
struct vec3 {
float x;
float y;
float z;
};
#include "model/suzanne.h"
//#include "model/icosphere.h"
void transfer_background_polygon(uint32_t isp_tsp_parameter_start)
{
using namespace holly::core::parameter;
using parameter = isp_tsp_parameter<3>;
volatile parameter * polygon = (volatile parameter *)&texture_memory32[isp_tsp_parameter_start];
polygon->isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::always
| isp_tsp_instruction_word::culling_mode::no_culling;
polygon->tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
polygon->texture_control_word = 0;
polygon->vertex[0].x = 0.0f;
polygon->vertex[0].y = 0.0f;
polygon->vertex[0].z = 0.00001f;
polygon->vertex[0].base_color = 0x000000;
polygon->vertex[1].x = 32.0f;
polygon->vertex[1].y = 0.0f;
polygon->vertex[1].z = 0.00001f;
polygon->vertex[1].base_color = 0x000000;
polygon->vertex[2].x = 32.0f;
polygon->vertex[2].y = 32.0f;
polygon->vertex[2].z = 0.00001f;
polygon->vertex[2].base_color = 0x000000;
}
static inline uint32_t transfer_ta_global_end_of_list(uint32_t store_queue_ix)
{
using namespace holly::ta;
using namespace holly::ta::parameter;
//
// TA "end of list" global transfer
//
volatile global_parameter::end_of_list * end_of_list = (volatile global_parameter::end_of_list *)&store_queue[store_queue_ix];
store_queue_ix += (sizeof (global_parameter::end_of_list));
end_of_list->parameter_control_word = parameter_control_word::para_type::end_of_list;
// start store queue transfer of `end_of_list` to the TA
pref(end_of_list);
return store_queue_ix;
}
static inline uint32_t transfer_ta_global_polygon(uint32_t store_queue_ix)
{
using namespace holly::core::parameter;
using namespace holly::ta;
using namespace holly::ta::parameter;
//
// TA polygon global transfer
//
volatile global_parameter::polygon_type_0 * polygon = (volatile global_parameter::polygon_type_0 *)&store_queue[store_queue_ix];
store_queue_ix += (sizeof (global_parameter::polygon_type_0));
polygon->parameter_control_word = parameter_control_word::para_type::polygon_or_modifier_volume
| parameter_control_word::list_type::opaque
| parameter_control_word::col_type::floating_color;
polygon->isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
| isp_tsp_instruction_word::culling_mode::no_culling;
// Note that it is not possible to use
// ISP_TSP_INSTRUCTION_WORD::GOURAUD_SHADING in this isp_tsp_instruction_word,
// because `gouraud` is one of the bits overwritten by the value in
// parameter_control_word. See DCDBSysArc990907E.pdf page 200.
polygon->tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
| tsp_instruction_word::dst_alpha_instr::zero
| tsp_instruction_word::fog_control::no_fog;
polygon->texture_control_word = 0;
// start store queue transfer of `polygon` to the TA
pref(polygon);
return store_queue_ix;
}
#define abs(n) __builtin_abs(n)
#define cos(n) __builtin_cosf(n)
#define sin(n) __builtin_sinf(n)
static float theta = 0;
static inline vec3 vertex_rotate(vec3 v)
{
// to make the models's appearance more interesting, rotate the vertex on two
// axes
float x0 = v.x;
float y0 = v.y;
float z0 = v.z;
float x1 = x0 * cos(theta) - z0 * sin(theta);
float y1 = y0;
float z1 = x0 * sin(theta) + z0 * cos(theta);
float x2 = x1;
float y2 = y1 * cos(theta) - z1 * sin(theta);
float z2 = y1 * sin(theta) + z1 * cos(theta);
return (vec3){x2, y2, z2};
}
static inline vec3 vertex_perspective_divide(vec3 v)
{
float w = 1.0f / (v.z + 2.0f);
return (vec3){v.x * w, v.y * w, w};
}
static inline vec3 vertex_screen_space(vec3 v)
{
return (vec3){
v.x * 240.f + 320.f,
v.y * 240.f + 240.f,
v.z,
};
}
static inline uint32_t transfer_ta_vertex_triangle(uint32_t store_queue_ix,
float x, float y, float z,
float r, float g, float b,
bool end_of_strip)
{
using namespace holly::ta;
using namespace holly::ta::parameter;
//
// TA polygon vertex transfer
//
volatile vertex_parameter::polygon_type_1 * vertex = (volatile vertex_parameter::polygon_type_1 *)&store_queue[store_queue_ix];
store_queue_ix += (sizeof (vertex_parameter::polygon_type_1)) * 1;
vertex[0].parameter_control_word = parameter_control_word::para_type::vertex_parameter
| (end_of_strip ? parameter_control_word::end_of_strip : 0);
vertex[0].x = x;
vertex[0].y = y;
vertex[0].z = z;
vertex[0].base_color_alpha = 1.0;
vertex[0].base_color_r = r;
vertex[0].base_color_g = g;
vertex[0].base_color_b = b;
pref(vertex);
return store_queue_ix;
}
static const vec3 colors[] = {
{ 1.0, 0.0, 0.0 },
{ 1.0, 0.5454545454545454, 0.0 },
{ 0.9090909090909092, 1.0, 0.0 },
{ 0.36363636363636376, 1.0, 0.0 },
{ 0.0, 1.0, 0.18181818181818166 },
{ 0.0, 1.0, 0.7272727272727271 },
{ 0.0, 0.7272727272727275, 1.0 },
{ 0.0, 0.18181818181818166, 1.0 },
{ 0.3636363636363633, 0.0, 1.0 },
{ 0.9090909090909092, 0.0, 1.0 },
{ 1.0, 0.0, 0.5454545454545459 },
{ 1.0, 0.0, 0.0 },
{ 0.8500000000000001, 0.0, 0.0 },
{ 0.8500000000000001, 0.4636363636363636, 0.0 },
{ 0.7727272727272729, 0.8500000000000001, 0.0 },
{ 0.30909090909090925, 0.8500000000000001, 0.0 },
{ 0.0, 0.8500000000000001, 0.15454545454545443 },
{ 0.0, 0.8500000000000001, 0.618181818181818 },
{ 0.0, 0.6181818181818185, 0.8500000000000001 },
{ 0.0, 0.15454545454545443, 0.8500000000000001 },
{ 0.30909090909090886, 0.0, 0.8500000000000001 },
{ 0.7727272727272729, 0.0, 0.8500000000000001 },
{ 0.8500000000000001, 0.0, 0.463636363636364 },
{ 0.8500000000000001, 0.0, 0.0 },
{ 0.7, 0.0, 0.0 },
{ 0.7, 0.3818181818181818, 0.0 },
{ 0.6363636363636364, 0.7, 0.0 },
{ 0.25454545454545463, 0.7, 0.0 },
{ 0.0, 0.7, 0.12727272727272715 },
{ 0.0, 0.7, 0.5090909090909089 },
{ 0.0, 0.5090909090909093, 0.7 },
{ 0.0, 0.12727272727272715, 0.7 },
{ 0.2545454545454543, 0.0, 0.7 },
{ 0.6363636363636364, 0.0, 0.7 },
{ 0.7, 0.0, 0.38181818181818206 },
{ 0.7, 0.0, 0.0 },
{ 0.55, 0.0, 0.0 },
{ 0.55, 0.3, 0.0 },
{ 0.5000000000000001, 0.55, 0.0 },
{ 0.2000000000000001, 0.55, 0.0 },
{ 0.0, 0.55, 0.09999999999999992 },
{ 0.0, 0.55, 0.3999999999999999 },
{ 0.0, 0.4000000000000002, 0.55 },
{ 0.0, 0.09999999999999992, 0.55 },
{ 0.19999999999999984, 0.0, 0.55 },
{ 0.5000000000000001, 0.0, 0.55 },
{ 0.55, 0.0, 0.30000000000000027 },
{ 0.55, 0.0, 0.0 },
{ 0.39999999999999997, 0.0, 0.0 },
{ 0.39999999999999997, 0.21818181818181814, 0.0 },
{ 0.36363636363636365, 0.39999999999999997, 0.0 },
{ 0.1454545454545455, 0.39999999999999997, 0.0 },
{ 0.0, 0.39999999999999997, 0.07272727272727265 },
{ 0.0, 0.39999999999999997, 0.2909090909090908 },
{ 0.0, 0.290909090909091, 0.39999999999999997 },
{ 0.0, 0.07272727272727265, 0.39999999999999997 },
{ 0.1454545454545453, 0.0, 0.39999999999999997 },
{ 0.36363636363636365, 0.0, 0.39999999999999997 },
{ 0.39999999999999997, 0.0, 0.21818181818181834 },
{ 0.39999999999999997, 0.0, 0.0 },
{ 0.25, 0.0, 0.0 },
{ 0.25, 0.13636363636363635, 0.0 },
{ 0.2272727272727273, 0.25, 0.0 },
{ 0.09090909090909094, 0.25, 0.0 },
};
static const int strips_length = (sizeof (strips)) / (sizeof (strips[0]));
void transfer_ta_strips()
{
{
using namespace sh7091;
using sh7091::sh7091;
// set the store queue destination address to the TA Polygon Converter FIFO
sh7091.CCN.QACR0 = sh7091::ccn::qacr0::address(ta_fifo_polygon_converter);
sh7091.CCN.QACR1 = sh7091::ccn::qacr1::address(ta_fifo_polygon_converter);
}
uint32_t store_queue_ix = 0;
store_queue_ix = transfer_ta_global_polygon(store_queue_ix);
int color_ix = 0;
for (int strip_ix = 0; strip_ix < strips_length; strip_ix++) {
int vertex_ix = strips[strip_ix];
vec3 vp = vertex_screen_space(
vertex_perspective_divide(
vertex_rotate(vertices[abs(vertex_ix)])));
const vec3& c = colors[color_ix];
bool end_of_strip = vertex_ix < 0;
store_queue_ix = transfer_ta_vertex_triangle(store_queue_ix,
vp.x, vp.y, vp.z,
c.x, c.y, c.z,
end_of_strip);
if (end_of_strip) {
color_ix = (color_ix + 1) % 64;
}
}
store_queue_ix = transfer_ta_global_end_of_list(store_queue_ix);
}
void main()
{
/*
a very simple memory map:
the ordering within texture memory is not significant, and could be
anything
*/
uint32_t framebuffer_start = 0x200000; // intentionally the same address that the boot rom used to draw the SEGA logo
uint32_t isp_tsp_parameter_start = 0x400000;
uint32_t region_array_start = 0x500000;
uint32_t object_list_start = 0x100000;
const int tile_y_num = 480 / 32;
const int tile_x_num = 640 / 32;
using namespace holly::core;
region_array::list_block_size list_block_size = {
.opaque = 32 * 4,
};
region_array::transfer(tile_x_num,
tile_y_num,
list_block_size,
region_array_start,
object_list_start);
transfer_background_polygon(isp_tsp_parameter_start);
//////////////////////////////////////////////////////////////////////////////
// configure the TA
//////////////////////////////////////////////////////////////////////////////
using namespace holly;
using holly::holly;
// TA_GLOB_TILE_CLIP restricts which "object pointer blocks" are written
// to.
//
// This can also be used to implement "windowing", as long as the desired
// window size happens to be a multiple of 32 pixels. The "User Tile Clip" TA
// control parameter can also ~equivalently be used as many times as desired
// within a single TA initialization to produce an identical effect.
//
// See DCDBSysArc990907E.pdf page 183.
holly.TA_GLOB_TILE_CLIP = ta_glob_tile_clip::tile_y_num(tile_y_num - 1)
| ta_glob_tile_clip::tile_x_num(tile_x_num - 1);
// While CORE supports arbitrary-length object lists, the TA uses "object
// pointer blocks" as a memory allocation strategy. These fixed-length blocks
// can still have infinite length via "object pointer block links". This
// mechanism is illustrated in DCDBSysArc990907E.pdf page 188.
holly.TA_ALLOC_CTRL = ta_alloc_ctrl::opb_mode::increasing_addresses
| ta_alloc_ctrl::o_opb::_32x4byte;
// While building object lists, the TA contains an internal index (exposed as
// the read-only TA_ITP_CURRENT) for the next address that new ISP/TSP will be
// stored at. The initial value of this index is TA_ISP_BASE.
// reserve space in ISP/TSP parameters for the background parameter
using polygon = holly::core::parameter::isp_tsp_parameter<3>;
uint32_t ta_isp_base_offset = (sizeof (polygon)) * 1;
holly.TA_ISP_BASE = isp_tsp_parameter_start + ta_isp_base_offset;
holly.TA_ISP_LIMIT = isp_tsp_parameter_start + 0x100000;
// Similarly, the TA also contains, for up to 600 tiles, an internal index for
// the next address that an object list entry will be stored for each
// tile. These internal indicies are partially exposed via the read-only
// TA_OL_POINTERS.
holly.TA_OL_BASE = object_list_start;
// TA_OL_LIMIT, DCDBSysArc990907E.pdf page 385:
//
// > Because the TA may automatically store data in the address that is
// > specified by this register, it must not be used for other data. For
// > example, the address specified here must not be the same as the address
// > in the TA_ISP_BASE register.
holly.TA_OL_LIMIT = object_list_start + 0x100000 - 32;
holly.TA_NEXT_OPB_INIT = (object_list_start + 32 * 4 * tile_y_num * tile_x_num);
//////////////////////////////////////////////////////////////////////////////
// configure CORE
//////////////////////////////////////////////////////////////////////////////
// REGION_BASE is the (texture memory-relative) address of the region array.
holly.REGION_BASE = region_array_start;
// PARAM_BASE is the (texture memory-relative) address of ISP/TSP parameters.
// Anything that references an ISP/TSP parameter does so relative to this
// address (and not relative to the beginning of texture memory).
holly.PARAM_BASE = isp_tsp_parameter_start;
// Set the offset of the background ISP/TSP parameter, relative to PARAM_BASE
// SKIP is related to the size of each vertex
uint32_t background_offset = 0;
holly.ISP_BACKGND_T = isp_backgnd_t::tag_address(background_offset / 4)
| isp_backgnd_t::tag_offset(0)
| isp_backgnd_t::skip(1);
// FB_W_SOF1 is the (texture memory-relative) address of the framebuffer that
// will be written to when a tile is rendered/flushed.
holly.FB_W_SOF1 = framebuffer_start;
// without waiting for rendering to actually complete, immediately display the
// framebuffer.
holly.FB_R_SOF1 = framebuffer_start;
// draw 500 frames of cube rotation
for (int i = 0; i < 5000; i++) {
//////////////////////////////////////////////////////////////////////////////
// transfer cube to texture memory via the TA polygon converter FIFO
//////////////////////////////////////////////////////////////////////////////
// TA_LIST_INIT needs to be written (every frame) prior to the first FIFO
// write.
holly.TA_LIST_INIT = ta_list_init::list_init;
// dummy TA_LIST_INIT read; DCDBSysArc990907E.pdf in multiple places says this
// step is required.
(void)holly.TA_LIST_INIT;
transfer_ta_strips();
//////////////////////////////////////////////////////////////////////////////
// wait for vertical synchronization (and the TA)
//////////////////////////////////////////////////////////////////////////////
while (!(spg_status::vsync(holly.SPG_STATUS)));
while (spg_status::vsync(holly.SPG_STATUS));
//////////////////////////////////////////////////////////////////////////////
// start the actual rasterization
//////////////////////////////////////////////////////////////////////////////
// start the actual render--the rendering process begins by interpreting the
// region array
using systembus::systembus;
using namespace systembus;
systembus.ISTERR = 0xffffffff;
holly.STARTRENDER = 1;
while ((systembus.ISTNRM & istnrm::end_of_render_tsp) == 0) {
if (systembus.ISTERR) {
string("ISTERR: ");
print_base16(systembus.ISTERR, 8);
string("\n ");
return;
}
}
systembus.ISTNRM = istnrm::end_of_render_tsp
| istnrm::end_of_render_isp
| istnrm::end_of_render_video;
// increment theta for the cube rotation animation
// (used by the `vertex_rotate` function)
theta += 0.01f;
}
string("return\n ");
// return from main; this will effectively jump back to the serial loader
}