1bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUUU 0 2bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_TTTT 1 3bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_FFFF 2 4bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_TTUU 3 5bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_FFUU 4 6bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_TFUU 5 7bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_TUUU 6 8bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_FUUU 7 9bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUTT 8 10bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUTF 9 11bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUTU 10 12bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUFT 11 13bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUFF 12 14bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUFU 13 15bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUUT 14 16bf215546Sopenharmony_ci#define NV_MME_PRED_MODE_UUUF 15 17bf215546Sopenharmony_ci 18bf215546Sopenharmony_ci#define NV_MME_REG_R0 0 19bf215546Sopenharmony_ci#define NV_MME_REG_R1 1 20bf215546Sopenharmony_ci#define NV_MME_REG_R2 2 21bf215546Sopenharmony_ci#define NV_MME_REG_R3 3 22bf215546Sopenharmony_ci#define NV_MME_REG_R4 4 23bf215546Sopenharmony_ci#define NV_MME_REG_R5 5 24bf215546Sopenharmony_ci#define NV_MME_REG_R6 6 25bf215546Sopenharmony_ci#define NV_MME_REG_R7 7 26bf215546Sopenharmony_ci#define NV_MME_REG_R8 8 27bf215546Sopenharmony_ci#define NV_MME_REG_R9 9 28bf215546Sopenharmony_ci#define NV_MME_REG_R10 10 29bf215546Sopenharmony_ci#define NV_MME_REG_R11 11 30bf215546Sopenharmony_ci#define NV_MME_REG_R12 12 31bf215546Sopenharmony_ci#define NV_MME_REG_R13 13 32bf215546Sopenharmony_ci#define NV_MME_REG_R14 14 33bf215546Sopenharmony_ci#define NV_MME_REG_R15 15 34bf215546Sopenharmony_ci#define NV_MME_REG_R16 16 35bf215546Sopenharmony_ci#define NV_MME_REG_R17 17 36bf215546Sopenharmony_ci#define NV_MME_REG_R18 18 37bf215546Sopenharmony_ci#define NV_MME_REG_R19 19 38bf215546Sopenharmony_ci#define NV_MME_REG_R20 20 39bf215546Sopenharmony_ci#define NV_MME_REG_R21 21 40bf215546Sopenharmony_ci#define NV_MME_REG_R22 22 41bf215546Sopenharmony_ci#define NV_MME_REG_R23 23 42bf215546Sopenharmony_ci#define NV_MME_REG_ZERO 24 43bf215546Sopenharmony_ci#define NV_MME_REG_IMMED 25 44bf215546Sopenharmony_ci#define NV_MME_REG_IMMEDPAIR 26 45bf215546Sopenharmony_ci#define NV_MME_REG_IMMED32 27 46bf215546Sopenharmony_ci#define NV_MME_REG_LOAD0 28 47bf215546Sopenharmony_ci#define NV_MME_REG_LOAD1 29 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#define NV_MME_ALU_ADD 0 50bf215546Sopenharmony_ci#define NV_MME_ALU_ADDC 1 51bf215546Sopenharmony_ci#define NV_MME_ALU_SUB 2 52bf215546Sopenharmony_ci#define NV_MME_ALU_SUBB 3 53bf215546Sopenharmony_ci#define NV_MME_ALU_MUL 4 54bf215546Sopenharmony_ci#define NV_MME_ALU_MULH 5 55bf215546Sopenharmony_ci#define NV_MME_ALU_MULU 6 56bf215546Sopenharmony_ci#define NV_MME_ALU_EXTENDED 7 57bf215546Sopenharmony_ci#define NV_MME_ALU_CLZ 8 58bf215546Sopenharmony_ci#define NV_MME_ALU_SLL 9 59bf215546Sopenharmony_ci#define NV_MME_ALU_SRL 10 60bf215546Sopenharmony_ci#define NV_MME_ALU_SRA 11 61bf215546Sopenharmony_ci#define NV_MME_ALU_AND 12 62bf215546Sopenharmony_ci#define NV_MME_ALU_NAND 13 63bf215546Sopenharmony_ci#define NV_MME_ALU_OR 14 64bf215546Sopenharmony_ci#define NV_MME_ALU_XOR 15 65bf215546Sopenharmony_ci#define NV_MME_ALU_MERGE 16 66bf215546Sopenharmony_ci#define NV_MME_ALU_SLT 17 67bf215546Sopenharmony_ci#define NV_MME_ALU_SLTU 18 68bf215546Sopenharmony_ci#define NV_MME_ALU_SLE 19 69bf215546Sopenharmony_ci#define NV_MME_ALU_SLEU 20 70bf215546Sopenharmony_ci#define NV_MME_ALU_SEQ 21 71bf215546Sopenharmony_ci#define NV_MME_ALU_STATE 22 72bf215546Sopenharmony_ci#define NV_MME_ALU_LOOP 23 73bf215546Sopenharmony_ci#define NV_MME_ALU_JAL 24 74bf215546Sopenharmony_ci#define NV_MME_ALU_BLT 25 75bf215546Sopenharmony_ci#define NV_MME_ALU_BLTU 26 76bf215546Sopenharmony_ci#define NV_MME_ALU_BLE 27 77bf215546Sopenharmony_ci#define NV_MME_ALU_BLEU 28 78bf215546Sopenharmony_ci#define NV_MME_ALU_BEQ 29 79bf215546Sopenharmony_ci#define NV_MME_ALU_DREAD 30 80bf215546Sopenharmony_ci#define NV_MME_ALU_DWRITE 31 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci#define NV_MME_OUT_NONE 0 83bf215546Sopenharmony_ci#define NV_MME_OUT_ALU0 1 84bf215546Sopenharmony_ci#define NV_MME_OUT_ALU1 2 85bf215546Sopenharmony_ci#define NV_MME_OUT_LOAD0 3 86bf215546Sopenharmony_ci#define NV_MME_OUT_LOAD1 4 87bf215546Sopenharmony_ci#define NV_MME_OUT_IMMED0 5 88bf215546Sopenharmony_ci#define NV_MME_OUT_IMMED1 6 89bf215546Sopenharmony_ci#define NV_MME_OUT_RESERVED 7 90bf215546Sopenharmony_ci#define NV_MME_OUT_IMMEDHIGH0 8 91bf215546Sopenharmony_ci#define NV_MME_OUT_IMMEDHIGH1 9 92bf215546Sopenharmony_ci#define NV_MME_OUT_IMMED32_0 10 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci#define MME_BITS(en,pm,pr,o0,d0,a0,b0,i0,o1,d1,a1,b1,i1,m0,e0,m1,e1) \ 95bf215546Sopenharmony_ci ((e1) << (92 - 64) | (m1) << (89 - 64) | \ 96bf215546Sopenharmony_ci (e0) << (85 - 64) | (m0) << (82 - 64) | \ 97bf215546Sopenharmony_ci (i1) << (66 - 64) | (b1) >> (64 - 61)), \ 98bf215546Sopenharmony_ci (((b1) & 7) << (61 - 32) | (a1) << (56 - 32) | \ 99bf215546Sopenharmony_ci (d1) << (51 - 32) | (o1) << (46 - 32) | \ 100bf215546Sopenharmony_ci (i0) >> (32 - 30)), \ 101bf215546Sopenharmony_ci (((i0) & 3) << 30 | (b0) << 25 | (a0) << 20 | (d0) << 15 | (o0) << 10 | \ 102bf215546Sopenharmony_ci (pr) << 5 | (pm) << 1 | (en)) 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci#define MME_INSN(en,o0,d0,a0,b0,i0,m0,e0,o1,d1,a1,b1,i1,m1,e1) \ 105bf215546Sopenharmony_ci MME_BITS((en), NV_MME_PRED_MODE_UUUU, NV_MME_REG_ZERO, \ 106bf215546Sopenharmony_ci NV_MME_ALU_##o0, NV_MME_REG_##d0, \ 107bf215546Sopenharmony_ci NV_MME_REG_##a0, NV_MME_REG_##b0, (i0), \ 108bf215546Sopenharmony_ci NV_MME_ALU_##o1, NV_MME_REG_##d1, \ 109bf215546Sopenharmony_ci NV_MME_REG_##a1, NV_MME_REG_##b1, (i1), \ 110bf215546Sopenharmony_ci NV_MME_OUT_##m0, NV_MME_OUT_##e0, \ 111bf215546Sopenharmony_ci NV_MME_OUT_##m1, NV_MME_OUT_##e1) 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ciuint32_t mmec597_per_instance_bf[] = { 114bf215546Sopenharmony_ci// r1 = load(); // count 115bf215546Sopenharmony_ci// r3 = load(); // mask 116bf215546Sopenharmony_ci// mthd(0x1880, 1); // VERTEX_ARRAY_PER_INSTANCE[0] 117bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, (1<<12)|0x1880/4, IMMED0, NONE, 118bf215546Sopenharmony_ci ADD, R3, LOAD1, ZERO, 0, NONE, NONE), 119bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r1) { 120bf215546Sopenharmony_ci// send(r3 & 1); 121bf215546Sopenharmony_ci// r3 >>= 1; 122bf215546Sopenharmony_ci// } 123bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R1, ZERO, 0x0003, NONE, NONE, 124bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 125bf215546Sopenharmony_ci MME_INSN(0, AND, ZERO, R3, IMMED, 1, NONE, ALU0, 126bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 127bf215546Sopenharmony_ci MME_INSN(0, SRL, R3, R3, IMMED, 1, NONE, NONE, 128bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 129bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, 0, NONE, NONE, 130bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 131bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0, NONE, NONE, 132bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 133bf215546Sopenharmony_ci}; 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ciuint32_t mmec597_vertex_array_select[] = { 136bf215546Sopenharmony_ci// r1 = load(); // array 137bf215546Sopenharmony_ci// r2 = load(); // limit hi 138bf215546Sopenharmony_ci// r3 = load(); // limit lo 139bf215546Sopenharmony_ci// r4 = load(); // start hi 140bf215546Sopenharmony_ci// r5 = load(); // start lo 141bf215546Sopenharmony_ci// r6 = (r1 & 0x1f) << 2; 142bf215546Sopenharmony_ci// r7 = (r1 & 0x1f) << 1; 143bf215546Sopenharmony_ci// mthd(0x1c04 + r6, 1); // VERTEX_ARRAY_START_HIGH[] 144bf215546Sopenharmony_ci// send(r4); 145bf215546Sopenharmony_ci// send(r5); 146bf215546Sopenharmony_ci// mthd(0x0600 + r7, 1); // VERTEX_ARRAY_LIMIT_HIGH[] 147bf215546Sopenharmony_ci// send(r2); 148bf215546Sopenharmony_ci// send(r3); 149bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, NONE, NONE, 150bf215546Sopenharmony_ci ADD, R2, LOAD1, ZERO, 0, NONE, NONE), 151bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, LOAD0, ZERO, 0, NONE, NONE, 152bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 0, NONE, NONE), 153bf215546Sopenharmony_ci MME_INSN(0, ADD, R5, LOAD0, ZERO, 0, NONE, NONE, 154bf215546Sopenharmony_ci MERGE, R6, ZERO, R1, (2<<10)|(5<<5)|0, NONE, NONE), 155bf215546Sopenharmony_ci MME_INSN(0, MERGE, R7, ZERO, R1, (1<<10)|(5<<5)|0, ALU1, NONE, 156bf215546Sopenharmony_ci ADD, ZERO, R6, IMMED, (1<<12)|0x1c04/4, NONE, NONE), 157bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0, NONE, ALU0, 158bf215546Sopenharmony_ci ADD, ZERO, R5, ZERO, 0, NONE, ALU1), 159bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, R7, IMMED, (1<<12)|0x0600/4, ALU0, ALU1, 160bf215546Sopenharmony_ci ADD, ZERO, R2, ZERO, 0, NONE, NONE), 161bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R3, ZERO, 0, NONE, ALU0, 162bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 163bf215546Sopenharmony_ci}; 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_ciuint32_t mmec597_blend_enables[] = { 166bf215546Sopenharmony_ci// r1 = load(); // enable mask 167bf215546Sopenharmony_ci// mthd(0x1360, 1); // NVC0_3D_BLEND_ENABLE[] 168bf215546Sopenharmony_ci// send((r1 >> 0) & 1); 169bf215546Sopenharmony_ci// send((r1 >> 1) & 1); 170bf215546Sopenharmony_ci// send((r1 >> 2) & 1); 171bf215546Sopenharmony_ci// send((r1 >> 3) & 1); 172bf215546Sopenharmony_ci// send((r1 >> 4) & 1); 173bf215546Sopenharmony_ci// send((r1 >> 5) & 1); 174bf215546Sopenharmony_ci// send((r1 >> 6) & 1); 175bf215546Sopenharmony_ci// send((r1 >> 7) & 1); 176bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, IMMED1, NONE, 177bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, (1<<12)|0x1360/4, NONE, NONE), 178bf215546Sopenharmony_ci MME_INSN(0, MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|0, NONE, ALU0, 179bf215546Sopenharmony_ci MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|1, NONE, ALU1), 180bf215546Sopenharmony_ci MME_INSN(0, MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|2, NONE, ALU0, 181bf215546Sopenharmony_ci MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|3, NONE, ALU1), 182bf215546Sopenharmony_ci MME_INSN(1, MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|4, NONE, ALU0, 183bf215546Sopenharmony_ci MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|5, NONE, ALU1), 184bf215546Sopenharmony_ci MME_INSN(0, MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|6, NONE, ALU0, 185bf215546Sopenharmony_ci MERGE, ZERO, ZERO, R1, (0<<10)|(1<<5)|7, NONE, ALU1), 186bf215546Sopenharmony_ci}; 187bf215546Sopenharmony_ci 188bf215546Sopenharmony_ciuint32_t mmec597_poly_mode_front[] = { 189bf215546Sopenharmony_ci// r1 = load(); 190bf215546Sopenharmony_ci// mthd(0x0dac,0); // POLYGON_MODE_FRONT 191bf215546Sopenharmony_ci// send(r1); 192bf215546Sopenharmony_ci// r2 = read(0x0db0); // POLYGON_MODE_BACK 193bf215546Sopenharmony_ci// r3 = read(0x20c0); // SP_SELECT[3] 194bf215546Sopenharmony_ci// r7 = r1 | r2; 195bf215546Sopenharmony_ci// r4 = read(0x2100); // SP_SELECT[4] 196bf215546Sopenharmony_ci// r6 = 0x60; 197bf215546Sopenharmony_ci// r7 = r7 & 1; 198bf215546Sopenharmony_ci// if (r7 != 0) 199bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, (0<<12)|0x0dac/4, IMMED0, ALU0, 200bf215546Sopenharmony_ci STATE, R2, IMMED, ZERO, 0x0db0/4, NONE, NONE), 201bf215546Sopenharmony_ci MME_INSN(0, STATE, R3, IMMED, ZERO, 0x20c0/4, NONE, NONE, 202bf215546Sopenharmony_ci OR, R7, R1, R2, 0, NONE, NONE), 203bf215546Sopenharmony_ci MME_INSN(0, STATE, R4, IMMED, ZERO, 0x2100/4, NONE, NONE, 204bf215546Sopenharmony_ci ADD, R6, IMMED, ZERO, 0x60, NONE, NONE), 205bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 206bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 207bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 208bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 209bf215546Sopenharmony_ci// r6 = 0x200; 210bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, IMMED, ZERO, 0x200, NONE, NONE, 211bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 212bf215546Sopenharmony_ci// r7 = r3 | r4; 213bf215546Sopenharmony_ci// r7 = r7 & 1; 214bf215546Sopenharmony_ci// if (r7 != 0) 215bf215546Sopenharmony_ci MME_INSN(0, OR, R7, R3, R4, 0, NONE, NONE, 216bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 217bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 218bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 219bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 220bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 221bf215546Sopenharmony_ci// r6 = 0; 222bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, ZERO, ZERO, 0, NONE, NONE, 223bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 224bf215546Sopenharmony_ci// mthd(0x02ec, 0); 225bf215546Sopenharmony_ci// send(r6); 226bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, (0<<12)|0x02ec/4, IMMED0, NONE, 227bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 228bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R6, ZERO, 0, NONE, ALU0, 229bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 230bf215546Sopenharmony_ci}; 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ciuint32_t mmec597_poly_mode_back[] = { 233bf215546Sopenharmony_ci// r1 = load(); 234bf215546Sopenharmony_ci// mthd(0x0db0,0); // POLYGON_MODE_BACK 235bf215546Sopenharmony_ci// send(r1); 236bf215546Sopenharmony_ci// r2 = read(0x0dac); // POLYGON_MODE_FRONT 237bf215546Sopenharmony_ci// r3 = read(0x20c0); // SP_SELECT[3] 238bf215546Sopenharmony_ci// r7 = r1 | r2; 239bf215546Sopenharmony_ci// r4 = read(0x2100); // SP_SELECT[4] 240bf215546Sopenharmony_ci// r6 = 0x60; 241bf215546Sopenharmony_ci// r7 = r7 & 1; 242bf215546Sopenharmony_ci// if (r7 != 0) 243bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, (0<<12)|0x0db0/4, IMMED0, ALU0, 244bf215546Sopenharmony_ci STATE, R2, IMMED, ZERO, 0x0dac/4, NONE, NONE), 245bf215546Sopenharmony_ci MME_INSN(0, STATE, R3, IMMED, ZERO, 0x20c0/4, NONE, NONE, 246bf215546Sopenharmony_ci OR, R7, R1, R2, 0, NONE, NONE), 247bf215546Sopenharmony_ci MME_INSN(0, STATE, R4, IMMED, ZERO, 0x2100/4, NONE, NONE, 248bf215546Sopenharmony_ci ADD, R6, IMMED, ZERO, 0x60, NONE, NONE), 249bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 250bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 251bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 252bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 253bf215546Sopenharmony_ci// r6 = 0x200; 254bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, IMMED, ZERO, 0x200, NONE, NONE, 255bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 256bf215546Sopenharmony_ci// r7 = r3 | r4; 257bf215546Sopenharmony_ci// r7 = r7 & 1; 258bf215546Sopenharmony_ci// if (r7 != 0) 259bf215546Sopenharmony_ci MME_INSN(0, OR, R7, R3, R4, 0, NONE, NONE, 260bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 261bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 262bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 263bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 264bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 265bf215546Sopenharmony_ci// r6 = 0; 266bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, ZERO, ZERO, 0, NONE, NONE, 267bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 268bf215546Sopenharmony_ci// mthd(0x02ec, 0); 269bf215546Sopenharmony_ci// send(r6); 270bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, (0<<12)|0x02ec/4, IMMED0, NONE, 271bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 272bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R6, ZERO, 0, NONE, ALU0, 273bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 274bf215546Sopenharmony_ci}; 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_ciuint32_t mmec597_gp_select[] = { 277bf215546Sopenharmony_ci// r1 = load(); 278bf215546Sopenharmony_ci// mthd(0x2100,0); // SP_SELECT[4] 279bf215546Sopenharmony_ci// send(r1); 280bf215546Sopenharmony_ci// r2 = read(0x0dac); // POLYGON_MODE_FRONT 281bf215546Sopenharmony_ci// r3 = read(0x0db0); // POLYGON_MODE_BACK 282bf215546Sopenharmony_ci// r7 = r2 | r3; 283bf215546Sopenharmony_ci// r4 = read(0x20c0); // SP_SELECT[3] 284bf215546Sopenharmony_ci// r6 = 0x60; 285bf215546Sopenharmony_ci// r7 = r7 & 1; 286bf215546Sopenharmony_ci// if (r7 != 0) 287bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, (0<<12)|0x2100/4, IMMED0, ALU0, 288bf215546Sopenharmony_ci STATE, R2, IMMED, ZERO, 0x0dac/4, NONE, NONE), 289bf215546Sopenharmony_ci MME_INSN(0, STATE, R3, IMMED, ZERO, 0x0db0/4, NONE, NONE, 290bf215546Sopenharmony_ci OR, R7, R2, R3, 0, NONE, NONE), 291bf215546Sopenharmony_ci MME_INSN(0, STATE, R4, IMMED, ZERO, 0x20c0/4, NONE, NONE, 292bf215546Sopenharmony_ci ADD, R6, IMMED, ZERO, 0x60, NONE, NONE), 293bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 294bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 295bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 296bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 297bf215546Sopenharmony_ci// r6 = 0x200; 298bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, IMMED, ZERO, 0x200, NONE, NONE, 299bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 300bf215546Sopenharmony_ci// r7 = r1 | r4; 301bf215546Sopenharmony_ci// r7 = r7 & 1; 302bf215546Sopenharmony_ci// if (r7 != 0) 303bf215546Sopenharmony_ci MME_INSN(0, OR, R7, R1, R4, 0, NONE, NONE, 304bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 305bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 306bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 307bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 308bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 309bf215546Sopenharmony_ci// r6 = 0; 310bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, ZERO, ZERO, 0, NONE, NONE, 311bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 312bf215546Sopenharmony_ci// mthd(0x02ec, 0); 313bf215546Sopenharmony_ci// send(r6); 314bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, (0<<12)|0x02ec/4, IMMED0, NONE, 315bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 316bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R6, ZERO, 0, NONE, ALU0, 317bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 318bf215546Sopenharmony_ci}; 319bf215546Sopenharmony_ci 320bf215546Sopenharmony_ciuint32_t mmec597_tep_select[] = { 321bf215546Sopenharmony_ci// r1 = load(); 322bf215546Sopenharmony_ci// mthd(0x20c0,0); // SP_SELECT[3] 323bf215546Sopenharmony_ci// send(r1); 324bf215546Sopenharmony_ci// r2 = read(0x0dac); // POLYGON_MODE_FRONT 325bf215546Sopenharmony_ci// r3 = read(0x0db0); // POLYGON_MODE_BACK 326bf215546Sopenharmony_ci// r7 = r2 | r3; 327bf215546Sopenharmony_ci// r4 = read(0x2100); // SP_SELECT[4] 328bf215546Sopenharmony_ci// r6 = 0x60; 329bf215546Sopenharmony_ci// r7 = r7 & 1; 330bf215546Sopenharmony_ci// if (r7 != 0) 331bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, (0<<12)|0x20c0/4, IMMED0, ALU0, 332bf215546Sopenharmony_ci STATE, R2, IMMED, ZERO, 0x0dac/4, NONE, NONE), 333bf215546Sopenharmony_ci MME_INSN(0, STATE, R3, IMMED, ZERO, 0x0db0/4, NONE, NONE, 334bf215546Sopenharmony_ci OR, R7, R2, R3, 0, NONE, NONE), 335bf215546Sopenharmony_ci MME_INSN(0, STATE, R4, IMMED, ZERO, 0x2100/4, NONE, NONE, 336bf215546Sopenharmony_ci ADD, R6, IMMED, ZERO, 0x60, NONE, NONE), 337bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 338bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 339bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 340bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 341bf215546Sopenharmony_ci// r6 = 0x200; 342bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, IMMED, ZERO, 0x200, NONE, NONE, 343bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 344bf215546Sopenharmony_ci// r7 = r1 | r4; 345bf215546Sopenharmony_ci// r7 = r7 & 1; 346bf215546Sopenharmony_ci// if (r7 != 0) 347bf215546Sopenharmony_ci MME_INSN(0, OR, R7, R1, R4, 0, NONE, NONE, 348bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 349bf215546Sopenharmony_ci MME_INSN(0, AND, R7, R7, IMMED, 1, NONE, NONE, 350bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 351bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R7, ZERO, (2<<14)|0x0002, NONE, NONE, 352bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 353bf215546Sopenharmony_ci// r6 = 0; 354bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, ZERO, ZERO, 0, NONE, NONE, 355bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 356bf215546Sopenharmony_ci// mthd(0x02ec, 0); 357bf215546Sopenharmony_ci// send(r6); 358bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, (0<<12)|0x02ec/4, IMMED0, NONE, 359bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 360bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R6, ZERO, 0, NONE, ALU0, 361bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 362bf215546Sopenharmony_ci}; 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_ciuint32_t mmec597_draw_arrays_indirect[] = { 365bf215546Sopenharmony_ci// r1 = load(); // mode 366bf215546Sopenharmony_ci// r5 = read(0x1438); // VB_INSTANCE_BASE 367bf215546Sopenharmony_ci// r6 = load(); // start_drawid 368bf215546Sopenharmony_ci// r7 = load(); // numparams 369bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, NONE, NONE, 370bf215546Sopenharmony_ci ADD, R6, LOAD1, ZERO, 0, NONE, NONE), 371bf215546Sopenharmony_ci MME_INSN(0, ADD, R7, LOAD0, ZERO, 0, NONE, NONE, 372bf215546Sopenharmony_ci STATE, R5, IMMED, ZERO, 0x1438/4, NONE, NONE), 373bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r7) { 374bf215546Sopenharmony_ci// r2 = load(); // count 375bf215546Sopenharmony_ci// r3 = load(); // instance_count 376bf215546Sopenharmony_ci// mthd(0x0d74, 0); // VERTEX_BUFFER_FIRST 377bf215546Sopenharmony_ci// send(load()); // start 378bf215546Sopenharmony_ci// r4 = load(); // start_instance 379bf215546Sopenharmony_ci// if (r3) { 380bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R7, ZERO, 0x000c, NONE, NONE, 381bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 382bf215546Sopenharmony_ci MME_INSN(0, ADD, R2, LOAD0, ZERO, 0x0d74/4, IMMED0, NONE, 383bf215546Sopenharmony_ci ADD, R3, LOAD1, ZERO, 0, NONE, NONE), 384bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, ALU0, 385bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 0, NONE, NONE), 386bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R3, ZERO, (2<<14)|0x0008, NONE, NONE, 387bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 388bf215546Sopenharmony_ci// mthd(0x238c, 1); // CB_POS 389bf215546Sopenharmony_ci// send(256 + 160); 390bf215546Sopenharmony_ci// send(0); // base_vertex 391bf215546Sopenharmony_ci// send(r4); // start_instance 392bf215546Sopenharmony_ci// send(r6); // draw id 393bf215546Sopenharmony_ci// mthd(0x1438, 0); // VB_INSTANCE_BASE 394bf215546Sopenharmony_ci// send(r4); 395bf215546Sopenharmony_ci// r1 = r1 & ~(1<<26); // clear INSTANCE_NEXT 396bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, (1<<12)|0x238c/4, IMMED0, IMMED1, 397bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 256 + 160, NONE, ALU0), 398bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0, NONE, ALU0, 399bf215546Sopenharmony_ci ADD, ZERO, R6, ZERO, 0, NONE, ALU1), 400bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0x1438/4, IMMED0, ALU0, 401bf215546Sopenharmony_ci MERGE, R1, R1, ZERO, (26<<10)|(1<<5)|0, NONE, NONE), 402bf215546Sopenharmony_ci// do { 403bf215546Sopenharmony_ci// mthd(0x1618, 0); // VERTEX_BEGIN_GL 404bf215546Sopenharmony_ci// send(r1); // mode 405bf215546Sopenharmony_ci// mthd(0x0d78, 0); // VERTEX_BUFFER_COUNT 406bf215546Sopenharmony_ci// send(r2); // count 407bf215546Sopenharmony_ci// mthd(0x1614, 0); // VERTEX_END_GL 408bf215546Sopenharmony_ci// send(0); 409bf215546Sopenharmony_ci// r1 |= (1<<26); // set INSTANCE_NEXT 410bf215546Sopenharmony_ci// } while(--r3); 411bf215546Sopenharmony_ci// } 412bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R1, ZERO, 0x1618/4, IMMED0, ALU0, 413bf215546Sopenharmony_ci ADD, ZERO, R2, ZERO, 0x0d78/4, IMMED1, ALU1), 414bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1614/4, IMMED0, ALU0, 415bf215546Sopenharmony_ci ADD, R4, IMMED, ZERO, 1, NONE, NONE), 416bf215546Sopenharmony_ci MME_INSN(0, MERGE, R1, R1, R4, (26<<10)|(1<<5)|0, NONE, NONE, 417bf215546Sopenharmony_ci SUB, R3, R3, IMMED, 1, NONE, NONE), 418bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R3, ZERO, (1<<14)|0x3ffd, NONE, NONE, 419bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 420bf215546Sopenharmony_ci// r6 = r6 + 1; 421bf215546Sopenharmony_ci// }; 422bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, R6, IMMED, 1, NONE, NONE, 423bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 424bf215546Sopenharmony_ci// mthd(0x1438, 0); // restore VB_INSTANCE_BASE 425bf215546Sopenharmony_ci// send(r5); 426bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, 0x1438/4, IMMED0, NONE, 427bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 428bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R5, ZERO, 0, NONE, ALU0, 429bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 430bf215546Sopenharmony_ci}; 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_ciuint32_t mmec597_draw_elts_indirect[] = { 433bf215546Sopenharmony_ci// r1 = load(); // mode 434bf215546Sopenharmony_ci// r8 = read(0x1434); // VB_ELEMENT_BASE 435bf215546Sopenharmony_ci// r9 = read(0x1438); // VB_INSTANCE_BASE 436bf215546Sopenharmony_ci// r6 = load(); // start_drawid 437bf215546Sopenharmony_ci// r7 = load(); // numparams 438bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, NONE, NONE, 439bf215546Sopenharmony_ci STATE, R8, IMMED, ZERO, 0x1434/4, NONE, NONE), 440bf215546Sopenharmony_ci MME_INSN(0, STATE, R9, IMMED, ZERO, 0x1438/4, NONE, NONE, 441bf215546Sopenharmony_ci ADD, R6, LOAD0, ZERO, 0, NONE, NONE), 442bf215546Sopenharmony_ci MME_INSN(0, ADD, R7, LOAD0, ZERO, 0, NONE, NONE, 443bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 444bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r7) { 445bf215546Sopenharmony_ci// r3 = load(); // count 446bf215546Sopenharmony_ci// r2 = load(); // instance_count 447bf215546Sopenharmony_ci// mthd(0x17dc, 0); // INDEX_BATCH_FIRST 448bf215546Sopenharmony_ci// send(load()); // start 449bf215546Sopenharmony_ci// r4 = load(); // index_bias 450bf215546Sopenharmony_ci// mthd(0x238c, 1); // CB_POS 451bf215546Sopenharmony_ci// send(256 + 160); 452bf215546Sopenharmony_ci// send(r4); // index_bias 453bf215546Sopenharmony_ci// r5 = load(); // start_instance 454bf215546Sopenharmony_ci// if (r2) { 455bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R7, ZERO, 0x000d, NONE, NONE, 456bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 457bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, LOAD0, ZERO, 0x17dc/4, IMMED0, NONE, 458bf215546Sopenharmony_ci ADD, R2, LOAD1, ZERO, 0, NONE, NONE), 459bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, ALU0, 460bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 0, NONE, NONE), 461bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, (1<<12)|0x238c/4, IMMED0, IMMED1, 462bf215546Sopenharmony_ci ADD, ZERO, R4, ZERO, 256 + 160, NONE, ALU1), 463bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R2, ZERO, (2<<14)|0x0008, NONE, NONE, 464bf215546Sopenharmony_ci ADD, R5, LOAD0, ZERO, 0, NONE, NONE), 465bf215546Sopenharmony_ci// send(r5); // start_instance 466bf215546Sopenharmony_ci// send(r6); // draw_id 467bf215546Sopenharmony_ci// mthd(0x1434, 1); // VB_ELEMENT_BASE 468bf215546Sopenharmony_ci// send(r4); // index_bias 469bf215546Sopenharmony_ci// send(r5); // start_instance 470bf215546Sopenharmony_ci// mthd(0x1118, 0); // VERTEX_ID_BASE 471bf215546Sopenharmony_ci// send(r4); // index_bias 472bf215546Sopenharmony_ci// r1 &= ~(1 << 26); // clear INSTANCE_NEXT 473bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R5, ZERO, 0, NONE, ALU0, 474bf215546Sopenharmony_ci ADD, ZERO, R6, ZERO, 0, NONE, ALU1), 475bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, (1<<12)|0x1434/4, IMMED0, ALU0, 476bf215546Sopenharmony_ci ADD, ZERO, R5, ZERO, 0, NONE, ALU1), 477bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0x1118/4, IMMED0, ALU0, 478bf215546Sopenharmony_ci MERGE, R1, R1, ZERO, (26<<10)|(1<<5)|0, NONE, NONE), 479bf215546Sopenharmony_ci// do { 480bf215546Sopenharmony_ci// mthd(0x1618, 0); // VERTEX_BEGIN_GL 481bf215546Sopenharmony_ci// send(r1); // mode 482bf215546Sopenharmony_ci// mthd(0x17e0, 0); // INDEX_BATCH_COUNT 483bf215546Sopenharmony_ci// send(r3); // count 484bf215546Sopenharmony_ci// mthd(0x1614, 0); // VERTEX_END_GL 485bf215546Sopenharmony_ci// send(0); 486bf215546Sopenharmony_ci// r1 |= (1 << 26); // set INSTANCE_NEXT 487bf215546Sopenharmony_ci// } while (--r2); 488bf215546Sopenharmony_ci// } 489bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R1, ZERO, 0x1618/4, IMMED0, ALU0, 490bf215546Sopenharmony_ci ADD, ZERO, R3, ZERO, 0x17e0/4, IMMED1, ALU1), 491bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1614/4, IMMED0, ALU0, 492bf215546Sopenharmony_ci ADD, R4, IMMED, ZERO, 1, NONE, NONE), 493bf215546Sopenharmony_ci MME_INSN(0, MERGE, R1, R1, R4, (26<<10)|(1<<5)|0, NONE, NONE, 494bf215546Sopenharmony_ci SUB, R2, R2, IMMED, 1, NONE, NONE), 495bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R2, ZERO, (1<<14)|0x3ffd, NONE, NONE, 496bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 497bf215546Sopenharmony_ci// r6 = r6 + 1; 498bf215546Sopenharmony_ci// }; 499bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, R6, IMMED, 1, NONE, NONE, 500bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 501bf215546Sopenharmony_ci// mthd(0x1434, 1); 502bf215546Sopenharmony_ci// send(r8); // restore VB_ELEMENT_BASE 503bf215546Sopenharmony_ci// send(r9); // restore VB_INSTANCE_BASE 504bf215546Sopenharmony_ci// mthd(0x1118, 0); 505bf215546Sopenharmony_ci// send(r8); // restore VERTEX_ID_BASE 506bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, R8, ZERO, (1<<12)|0x1434/4, IMMED0, ALU0, 507bf215546Sopenharmony_ci ADD, ZERO, R9, ZERO, 0, NONE, ALU1), 508bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R8, ZERO, 0x1118/4, IMMED0, ALU0, 509bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 510bf215546Sopenharmony_ci}; 511bf215546Sopenharmony_ci 512bf215546Sopenharmony_ciuint32_t mmec597_draw_arrays_indirect_count[] = { 513bf215546Sopenharmony_ci// r1 = load(); // mode 514bf215546Sopenharmony_ci// r6 = load(); // start_drawid 515bf215546Sopenharmony_ci// r7 = load(); // numparams 516bf215546Sopenharmony_ci// r5 = load(); // totaldraws 517bf215546Sopenharmony_ci// r8 = read(0x1438); // VB_INSTANCE_BASE 518bf215546Sopenharmony_ci// r5 = r5 - r6; // remaining draws 519bf215546Sopenharmony_ci// if (r5 > r7) 520bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, NONE, NONE, 521bf215546Sopenharmony_ci ADD, R6, LOAD1, ZERO, 0, NONE, NONE), 522bf215546Sopenharmony_ci MME_INSN(0, ADD, R7, LOAD0, ZERO, 0, NONE, NONE, 523bf215546Sopenharmony_ci ADD, R5, LOAD1, ZERO, 0, NONE, NONE), 524bf215546Sopenharmony_ci MME_INSN(0, STATE, R8, IMMED, ZERO, 0x1438/4, NONE, NONE, 525bf215546Sopenharmony_ci SUB, R5, R5, R6, 0, NONE, NONE), 526bf215546Sopenharmony_ci MME_INSN(0, BLE, ZERO, R5, R7, (2<<14)|0x0002, NONE, NONE, 527bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 528bf215546Sopenharmony_ci// r5 = r7; 529bf215546Sopenharmony_ci MME_INSN(0, ADD, R5, R7, ZERO, 0, NONE, NONE, 530bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 531bf215546Sopenharmony_ci// if (r5 >= 0) { 532bf215546Sopenharmony_ci MME_INSN(0, BLT, ZERO, R5, ZERO, (2<<14)|0x000e, NONE, NONE, 533bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 534bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r5) { 535bf215546Sopenharmony_ci// r2 = load(); // count 536bf215546Sopenharmony_ci// r3 = load(); // instance_count 537bf215546Sopenharmony_ci// mthd(0x0d74, 0); // VERTEX_BUFFER_FIRST 538bf215546Sopenharmony_ci// send(load()); // start 539bf215546Sopenharmony_ci// r4 = load(); // start_instance 540bf215546Sopenharmony_ci// if (r3) { 541bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R5, ZERO, 0x000c, NONE, NONE, 542bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 543bf215546Sopenharmony_ci MME_INSN(0, ADD, R2, LOAD0, ZERO, 0x0d74/4, IMMED0, NONE, 544bf215546Sopenharmony_ci ADD, R3, LOAD1, ZERO, 0, NONE, NONE), 545bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, ALU0, 546bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 0, NONE, NONE), 547bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R3, ZERO, (2<<14)|0x0008, NONE, NONE, 548bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 549bf215546Sopenharmony_ci// mthd(0x238c, 1); // CB_POS 550bf215546Sopenharmony_ci// send(256 + 160); 551bf215546Sopenharmony_ci// send(0); // base_vertex 552bf215546Sopenharmony_ci// send(r4); // start_instance 553bf215546Sopenharmony_ci// send(r6); // draw_id 554bf215546Sopenharmony_ci// mthd(0x1438, 0); // VB_INSTANCE_BASE 555bf215546Sopenharmony_ci// send(r4); 556bf215546Sopenharmony_ci// r1 &= ~(1 << 26); // clear INSTANCE_NEXT 557bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, (1<<12)|0x238c/4, IMMED0, IMMED1, 558bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 256+160, NONE, ALU0), 559bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0, NONE, ALU0, 560bf215546Sopenharmony_ci ADD, ZERO, R6, ZERO, 0, NONE, ALU1), 561bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0x1438/4, IMMED0, ALU0, 562bf215546Sopenharmony_ci MERGE, R1, R1, ZERO, (26<<10)|(1<<5)|0, NONE, NONE), 563bf215546Sopenharmony_ci// do { 564bf215546Sopenharmony_ci// mthd(0x1618, 0); // VERTEX_BEGIN_GL 565bf215546Sopenharmony_ci// send(r1); // mode 566bf215546Sopenharmony_ci// mthd(0x0d78, 0); // VERTEX_BUFFER_COUNT 567bf215546Sopenharmony_ci// send(r2); 568bf215546Sopenharmony_ci// mthd(0x1614, 0); // VERTEX_END_GL 569bf215546Sopenharmony_ci// send(0); 570bf215546Sopenharmony_ci// r1 |= (1 << 26); // set INSTANCE_NEXT 571bf215546Sopenharmony_ci// } while (--r3); 572bf215546Sopenharmony_ci// } 573bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R1, ZERO, 0x1618/4, IMMED0, ALU0, 574bf215546Sopenharmony_ci ADD, ZERO, R2, ZERO, 0x0d78/4, IMMED1, ALU1), 575bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1614/4, IMMED0, ALU0, 576bf215546Sopenharmony_ci ADD, R4, IMMED, ZERO, 1, NONE, NONE), 577bf215546Sopenharmony_ci MME_INSN(0, MERGE, R1, R1, R4, (26<<10)|(1<<5)|0, NONE, NONE, 578bf215546Sopenharmony_ci SUB, R3, R3, IMMED, 1, NONE, NONE), 579bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R3, ZERO, (1<<14)|0x3ffd, NONE, NONE, 580bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 581bf215546Sopenharmony_ci// r6 = r6 + 1; // draw_id++ 582bf215546Sopenharmony_ci// } 583bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, R6, IMMED, 1, NONE, NONE, 584bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 585bf215546Sopenharmony_ci// r7 = r7 - r5; // unneeded params 586bf215546Sopenharmony_ci// } 587bf215546Sopenharmony_ci MME_INSN(0, SUB, R7, R7, R5, 0, NONE, NONE, 588bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 589bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r7) { 590bf215546Sopenharmony_ci// load(); 591bf215546Sopenharmony_ci// load(); 592bf215546Sopenharmony_ci// load(); 593bf215546Sopenharmony_ci// load(); 594bf215546Sopenharmony_ci// } 595bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R7, ZERO, 0x0003, NONE, NONE, 596bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 597bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, NONE, 598bf215546Sopenharmony_ci ADD, ZERO, LOAD1, ZERO, 0, NONE, NONE), 599bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, NONE, 600bf215546Sopenharmony_ci ADD, ZERO, LOAD1, ZERO, 0, NONE, NONE), 601bf215546Sopenharmony_ci// exit mthd(0x1438, 0); // VB_INSTANCE_BASE 602bf215546Sopenharmony_ci// send(r8); 603bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, 0x1438/4, IMMED0, NONE, 604bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 605bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R8, ZERO, 0, NONE, ALU0, 606bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 607bf215546Sopenharmony_ci}; 608bf215546Sopenharmony_ci 609bf215546Sopenharmony_ciuint32_t mmec597_draw_elts_indirect_count[] = { 610bf215546Sopenharmony_ci// r8 = read(0x1434); 611bf215546Sopenharmony_ci// r1 = load(); 612bf215546Sopenharmony_ci// r9 = read(0x1438); 613bf215546Sopenharmony_ci// r6 = load(); 614bf215546Sopenharmony_ci// r7 = load(); 615bf215546Sopenharmony_ci// r5 = load(); 616bf215546Sopenharmony_ci// r5 = r5 - r6; 617bf215546Sopenharmony_ci// if (r5 > r7) 618bf215546Sopenharmony_ci MME_INSN(0, STATE, R8, IMMED, ZERO, 0x1434/4, NONE, NONE, 619bf215546Sopenharmony_ci ADD, R1, LOAD0, ZERO, 0, NONE, NONE), 620bf215546Sopenharmony_ci MME_INSN(0, STATE, R9, IMMED, ZERO, 0x1438/4, NONE, NONE, 621bf215546Sopenharmony_ci ADD, R6, LOAD0, ZERO, 0, NONE, NONE), 622bf215546Sopenharmony_ci MME_INSN(0, ADD, R7, LOAD0, ZERO, 0, NONE, NONE, 623bf215546Sopenharmony_ci ADD, R5, LOAD1, ZERO, 0, NONE, NONE), 624bf215546Sopenharmony_ci MME_INSN(0, SUB, R5, R5, R6, 0, NONE, NONE, 625bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 626bf215546Sopenharmony_ci MME_INSN(0, BLE, ZERO, R5, R7, (2<<14)|0x0002, NONE, NONE, 627bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 628bf215546Sopenharmony_ci// r5 = r7; 629bf215546Sopenharmony_ci MME_INSN(0, ADD, R5, R7, ZERO, 0, NONE, NONE, 630bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 631bf215546Sopenharmony_ci// if (r5 >= 0) { 632bf215546Sopenharmony_ci MME_INSN(0, BLT, ZERO, R5, ZERO, (2<<14)|0x000f, NONE, NONE, 633bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 634bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r5) { 635bf215546Sopenharmony_ci// r3 = load(); 636bf215546Sopenharmony_ci// r2 = load(); 637bf215546Sopenharmony_ci// mthd(0x17dc, 0); 638bf215546Sopenharmony_ci// send(load()); 639bf215546Sopenharmony_ci// r4 = load(); 640bf215546Sopenharmony_ci// mthd(0x238c, 1); 641bf215546Sopenharmony_ci// send(256 + 160); 642bf215546Sopenharmony_ci// send(r4); 643bf215546Sopenharmony_ci// r10 = load(); 644bf215546Sopenharmony_ci// if (r2) { 645bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R5, ZERO, 0x000d, NONE, NONE, 646bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 647bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, LOAD0, ZERO, (0<<12)|0x17dc/4, IMMED0, NONE, 648bf215546Sopenharmony_ci ADD, R2, LOAD1, ZERO, 0, NONE, NONE), 649bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, (1<<12)|0x238c/4, NONE, ALU0, 650bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 256 + 160, IMMED0, IMMED1), 651bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, 0, NONE, ALU0, 652bf215546Sopenharmony_ci ADD, R10, LOAD0, ZERO, 0, NONE, NONE), 653bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R2, ZERO, (2<<14)|0x0008, NONE, NONE, 654bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 655bf215546Sopenharmony_ci// send(r10); 656bf215546Sopenharmony_ci// send(r6); 657bf215546Sopenharmony_ci// mthd(0x1434, 1); 658bf215546Sopenharmony_ci// send(r4); 659bf215546Sopenharmony_ci// send(r10); 660bf215546Sopenharmony_ci// mthd(0x1118, 0); 661bf215546Sopenharmony_ci// send(r4); 662bf215546Sopenharmony_ci// r1 &= ~(1 << 26); 663bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R10, ZERO, 0, NONE, ALU0, 664bf215546Sopenharmony_ci ADD, ZERO, R6, ZERO, 0, NONE, ALU1), 665bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, (1<<12)|0x1434/4, IMMED0, ALU0, 666bf215546Sopenharmony_ci ADD, ZERO, R10, ZERO, 0, NONE, ALU1), 667bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, ZERO, (0<<12)|0x1118/4, IMMED0, ALU0, 668bf215546Sopenharmony_ci MERGE, R1, R1, ZERO, (26<<10)|(1<<5)|0, NONE, NONE), 669bf215546Sopenharmony_ci// do { 670bf215546Sopenharmony_ci// mthd(0x1618, 0); 671bf215546Sopenharmony_ci// send(r1); 672bf215546Sopenharmony_ci// mthd(0x17e0, 0); 673bf215546Sopenharmony_ci// send(r3); 674bf215546Sopenharmony_ci// mthd(0x1614, 0); 675bf215546Sopenharmony_ci// send(0); 676bf215546Sopenharmony_ci// r1 |= (1 << 26); 677bf215546Sopenharmony_ci// } while (--r2); 678bf215546Sopenharmony_ci// } 679bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R1, ZERO, 0x1618/4, IMMED0, ALU0, 680bf215546Sopenharmony_ci ADD, ZERO, R3, ZERO, 0x17e0/4, IMMED1, ALU1), 681bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1614/4, IMMED0, ALU0, 682bf215546Sopenharmony_ci ADD, R4, IMMED, ZERO, 1, NONE, NONE), 683bf215546Sopenharmony_ci MME_INSN(0, MERGE, R1, R1, R4, (26<<10)|(1<<5)|0, NONE, NONE, 684bf215546Sopenharmony_ci SUB, R2, R2, IMMED, 1, NONE, NONE), 685bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R2, ZERO, (1<<14)|0x3ffd, NONE, NONE, 686bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 687bf215546Sopenharmony_ci// r6 = r6 + 1; 688bf215546Sopenharmony_ci// } 689bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, R6, IMMED, 1, NONE, NONE, 690bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 691bf215546Sopenharmony_ci// r7 = r7 - r5; // unneeded params 692bf215546Sopenharmony_ci// } 693bf215546Sopenharmony_ci MME_INSN(0, SUB, R7, R7, R5, 0, NONE, NONE, 694bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 695bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r7) { 696bf215546Sopenharmony_ci// r2 = load(); 697bf215546Sopenharmony_ci// r2 = load(); 698bf215546Sopenharmony_ci// r2 = load(); 699bf215546Sopenharmony_ci// r2 = load(); 700bf215546Sopenharmony_ci// r2 = load(); 701bf215546Sopenharmony_ci// } 702bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R7, ZERO, 0x0004, NONE, NONE, 703bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 704bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, NONE, 705bf215546Sopenharmony_ci ADD, ZERO, LOAD1, ZERO, 0, NONE, NONE), 706bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, NONE, 707bf215546Sopenharmony_ci ADD, ZERO, LOAD1, ZERO, 0, NONE, NONE), 708bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, LOAD0, ZERO, 0, NONE, NONE, 709bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 710bf215546Sopenharmony_ci// mthd(0x1434, 1); 711bf215546Sopenharmony_ci// send(r8); 712bf215546Sopenharmony_ci// send(r9); 713bf215546Sopenharmony_ci// exit mthd(0x1118, 0); 714bf215546Sopenharmony_ci// send(r8); 715bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, R8, ZERO, (1<<12)|0x1434/4, IMMED0, ALU0, 716bf215546Sopenharmony_ci ADD, ZERO, R9, ZERO, 0, NONE, ALU1), 717bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R8, ZERO, (0<<12)|0x1118/4, IMMED0, ALU0, 718bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 719bf215546Sopenharmony_ci}; 720bf215546Sopenharmony_ci 721bf215546Sopenharmony_ciuint32_t mmec597_query_buffer_write[] = { 722bf215546Sopenharmony_ci// r1 = load(); // clamp value 723bf215546Sopenharmony_ci// r2 = load(); // end value (lo) 724bf215546Sopenharmony_ci// r3 = load(); // end value (hi) 725bf215546Sopenharmony_ci// r4 = load(); // start value (lo) 726bf215546Sopenharmony_ci// r5 = load(); // start value (hi) 727bf215546Sopenharmony_ci// r8 = load(); // desired sequence 728bf215546Sopenharmony_ci// r9 = load(); // actual sequence 729bf215546Sopenharmony_ci// r7 = load(); // query address (hi) 730bf215546Sopenharmony_ci// r6 = load(); // query address (lo) 731bf215546Sopenharmony_ci// if (r9 >= r8) { 732bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, NONE, NONE, 733bf215546Sopenharmony_ci ADD, R2, LOAD1, ZERO, 0, NONE, NONE), 734bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, LOAD0, ZERO, 0, NONE, NONE, 735bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 0, NONE, NONE), 736bf215546Sopenharmony_ci MME_INSN(0, ADD, R5, LOAD0, ZERO, 0, NONE, NONE, 737bf215546Sopenharmony_ci ADD, R8, LOAD1, ZERO, 0, NONE, NONE), 738bf215546Sopenharmony_ci MME_INSN(0, ADD, R9, LOAD0, ZERO, 0, NONE, NONE, 739bf215546Sopenharmony_ci ADD, R7, LOAD1, ZERO, 0, NONE, NONE), 740bf215546Sopenharmony_ci MME_INSN(0, ADD, R6, LOAD0, ZERO, 0, NONE, NONE, 741bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 742bf215546Sopenharmony_ci MME_INSN(0, BLT, ZERO, R9, R8, (2<<14)|0x000e, NONE, NONE, 743bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 744bf215546Sopenharmony_ci// [r3,r2] = [r3,r2] - [r5,r4]; 745bf215546Sopenharmony_ci// if (r1) { 746bf215546Sopenharmony_ci MME_INSN(0, SUB, R2, R2, R4, 0, NONE, NONE, 747bf215546Sopenharmony_ci SUBB, R3, R3, R5, 0, NONE, NONE), 748bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R1, ZERO, (2<<14)|0x0004, NONE, NONE, 749bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 750bf215546Sopenharmony_ci// if (r3 != 0 || r1 < r2) 751bf215546Sopenharmony_ci// r2 = r1; 752bf215546Sopenharmony_ci// } 753bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R3, ZERO, (1<<14)|0x0002, NONE, NONE, 754bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 755bf215546Sopenharmony_ci MME_INSN(0, BLTU, ZERO, R1, R2, (1<<14)|0x0002, NONE, NONE, 756bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 757bf215546Sopenharmony_ci MME_INSN(0, ADD, R2, R1, ZERO, 0, NONE, NONE, 758bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 759bf215546Sopenharmony_ci// mthd(0x1b00, 1); 760bf215546Sopenharmony_ci// send(r7); 761bf215546Sopenharmony_ci// send(r6); 762bf215546Sopenharmony_ci// send(r2) 763bf215546Sopenharmony_ci// send(0x10000000); 764bf215546Sopenharmony_ci// if (!r1) { 765bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R7, ZERO, (1<<12)|0x1b00/4, IMMED0, ALU0, 766bf215546Sopenharmony_ci ADD, ZERO, R6, ZERO, 0, NONE, ALU1), 767bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R2, ZERO, 0, NONE, ALU0, 768bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 769bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1000, NONE, IMMED32_0, 770bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x0000, NONE, NONE), 771bf215546Sopenharmony_ci MME_INSN(0, BEQ, ZERO, R1, ZERO, (1<<14)|0x0004, NONE, NONE, 772bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 773bf215546Sopenharmony_ci// [r7,r6] = [r7,r6] + 4; 774bf215546Sopenharmony_ci// mthd(0x1b00, 1); 775bf215546Sopenharmony_ci// send(r7); 776bf215546Sopenharmony_ci// send(r6); 777bf215546Sopenharmony_ci// send(r3); 778bf215546Sopenharmony_ci// send(0x10000000); 779bf215546Sopenharmony_ci// } 780bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R6, IMMED, 4, IMMED1, ALU1, 781bf215546Sopenharmony_ci ADDC, ZERO, R7, ZERO, (1<<12)|0x1b00/4, NONE, ALU0), 782bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R3, ZERO, 0, NONE, ALU0, 783bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 784bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1000, NONE, IMMED32_0, 785bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x0000, NONE, NONE), 786bf215546Sopenharmony_ci// mthd(0x0110, 0); 787bf215546Sopenharmony_ci// send(0); 788bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, (0<<12)|0x0110/4, IMMED0, ALU0, 789bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 790bf215546Sopenharmony_ci// } 791bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, 0, NONE, NONE, 792bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 793bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0, NONE, NONE, 794bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 795bf215546Sopenharmony_ci}; 796bf215546Sopenharmony_ci 797bf215546Sopenharmony_ciuint32_t mmec597_conservative_raster_state[] = { 798bf215546Sopenharmony_ci// r1 = load(); 799bf215546Sopenharmony_ci// mthd(0x3400, 1); 800bf215546Sopenharmony_ci// send(0); 801bf215546Sopenharmony_ci// send(((r1 >> 8) & 7) << 23); 802bf215546Sopenharmony_ci// send(0x03800000); 803bf215546Sopenharmony_ci// mthd(0x2310, 1); 804bf215546Sopenharmony_ci// send(0x00418800); 805bf215546Sopenharmony_ci// r2 = r1 & 0xf; 806bf215546Sopenharmony_ci// r3 = 16; 807bf215546Sopenharmony_ci// r2 = r2 | (((r1 >> 4) & 0xf) << 8); 808bf215546Sopenharmony_ci// mthd(0x0a1c, 8); 809bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, (1<<12)|0x3400/4, IMMED0, IMMED1, 810bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 811bf215546Sopenharmony_ci MME_INSN(0, MERGE, ZERO, ZERO, R1, (23<<10)|(3<<5)|8, NONE, ALU0, 812bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 813bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x0380, NONE, IMMED32_0, 814bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x0000, NONE, NONE), 815bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, (1<<12)|0x2310/4, IMMED0, NONE, 816bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x0000, NONE, NONE), 817bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x0041, NONE, IMMED32_0, 818bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x8800, NONE, NONE), 819bf215546Sopenharmony_ci MME_INSN(0, AND, R2, R1, IMMED, 0xf, NONE, NONE, 820bf215546Sopenharmony_ci ADD, R3, ZERO, IMMED, 16, NONE, NONE), 821bf215546Sopenharmony_ci MME_INSN(0, MERGE, R2, R2, R1, (8<<10)|(4<<5)|4, IMMED1, NONE, 822bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, (8<<12)|0x0a1c/4, NONE, NONE), 823bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r3) 824bf215546Sopenharmony_ci// send(r2); 825bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R3, ZERO, 0x0002, NONE, NONE, 826bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 827bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R2, ZERO, 0, NONE, ALU0, 828bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 829bf215546Sopenharmony_ci// mthd(0x1148, 0); 830bf215546Sopenharmony_ci// send(1); 831bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, ZERO, ZERO, (0<<12)|0x1148/4, IMMED0, NONE, 832bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 833bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 1, NONE, IMMED1, 834bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 835bf215546Sopenharmony_ci}; 836bf215546Sopenharmony_ci 837bf215546Sopenharmony_ciuint32_t mmec597_compute_counter[] = { 838bf215546Sopenharmony_ci// r0 = load(); 839bf215546Sopenharmony_ci// r1 = 1; 840bf215546Sopenharmony_ci// r2 = 0; 841bf215546Sopenharmony_ci// while (HW_LOOP_COUNT < r2) { 842bf215546Sopenharmony_ci MME_INSN(0, ADD, R0, LOAD0, ZERO, 0, NONE, NONE, 843bf215546Sopenharmony_ci ADD, R1, IMMED, ZERO, 1, NONE, NONE), 844bf215546Sopenharmony_ci MME_INSN(0, LOOP, ZERO, R0, ZERO, 0x0003, NONE, NONE, 845bf215546Sopenharmony_ci ADD, R2, ZERO, ZERO, 0, NONE, NONE), 846bf215546Sopenharmony_ci// r3 = load(); 847bf215546Sopenharmony_ci// [r1,r0] *= r3; 848bf215546Sopenharmony_ci// } 849bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, LOAD0, ZERO, 0, NONE, NONE, 850bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 851bf215546Sopenharmony_ci MME_INSN(0, MULU, R1, R1, R3, 0, NONE, NONE, 852bf215546Sopenharmony_ci MULH, R2, ZERO, ZERO, 0, NONE, NONE), 853bf215546Sopenharmony_ci// r3 = read(0x3410); 854bf215546Sopenharmony_ci// r4 = read(0x3414); 855bf215546Sopenharmony_ci// [r4,r3] += [r2,r1]; 856bf215546Sopenharmony_ci// mthd(0x3410, 1); 857bf215546Sopenharmony_ci// send(r3); 858bf215546Sopenharmony_ci// send(r4); 859bf215546Sopenharmony_ci MME_INSN(0, STATE, ZERO, ZERO, ZERO, 0x3410/4, NONE, NONE, 860bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 861bf215546Sopenharmony_ci MME_INSN(1, STATE, ZERO, ZERO, ZERO, 0x3414/4, NONE, NONE, 862bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 863bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, R3, R1, (1<<12)|0x3410/4, IMMED0, ALU0, 864bf215546Sopenharmony_ci ADDC, R4, R4, R2, 0, NONE, ALU1), 865bf215546Sopenharmony_ci}; 866bf215546Sopenharmony_ci 867bf215546Sopenharmony_ciuint32_t mmec597_compute_counter_to_query[] = { 868bf215546Sopenharmony_ci// r1 = load(); 869bf215546Sopenharmony_ci// r3 = read(0x3410); 870bf215546Sopenharmony_ci// r2 = load(); 871bf215546Sopenharmony_ci// r4 = read(0x3414); 872bf215546Sopenharmony_ci// [r2,r1] = [r2,r1] + [r4,r3]; 873bf215546Sopenharmony_ci// mthd(0x1b00, 1); 874bf215546Sopenharmony_ci// r3 = load(); 875bf215546Sopenharmony_ci// send(r3); 876bf215546Sopenharmony_ci// r4 = load(); 877bf215546Sopenharmony_ci// send(r4); 878bf215546Sopenharmony_ci// send(r1); 879bf215546Sopenharmony_ci// send(0x10000000); 880bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, LOAD0, ZERO, 0, NONE, NONE, 881bf215546Sopenharmony_ci STATE, R3, IMMED, ZERO, 0x3410/4, NONE, NONE), 882bf215546Sopenharmony_ci MME_INSN(0, ADD, R2, LOAD0, ZERO, 0, NONE, NONE, 883bf215546Sopenharmony_ci STATE, R4, IMMED, ZERO, 0x3414/4, NONE, NONE), 884bf215546Sopenharmony_ci MME_INSN(0, ADD, R1, R1, R3, (1<<12)|0x1b00/4, IMMED0, NONE, 885bf215546Sopenharmony_ci ADDC, R2, R2, R4, 0, NONE, NONE), 886bf215546Sopenharmony_ci MME_INSN(0, ADD, R3, LOAD0, ZERO, 0, NONE, ALU0, 887bf215546Sopenharmony_ci ADD, R4, LOAD1, ZERO, 0, NONE, ALU1), 888bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R1, ZERO, 0, NONE, ALU0, 889bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 890bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1000, NONE, IMMED32_0, 891bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x0000, NONE, NONE), 892bf215546Sopenharmony_ci// [r3,r4] = [r3,r4] + 4; 893bf215546Sopenharmony_ci// mthd(0x1b00, 1); 894bf215546Sopenharmony_ci// send(r3); 895bf215546Sopenharmony_ci// send(r4); 896bf215546Sopenharmony_ci// send(r2); 897bf215546Sopenharmony_ci// send(0x10000000); 898bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, R4, IMMED, 4, IMMED1, ALU1, 899bf215546Sopenharmony_ci ADDC, ZERO, R3, ZERO, (1<<12)|0x1b00/4, NONE, ALU0), 900bf215546Sopenharmony_ci MME_INSN(1, ADD, ZERO, R2, ZERO, 0, NONE, ALU0, 901bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0, NONE, NONE), 902bf215546Sopenharmony_ci MME_INSN(0, ADD, ZERO, ZERO, ZERO, 0x1000, NONE, IMMED32_0, 903bf215546Sopenharmony_ci ADD, ZERO, ZERO, ZERO, 0x0000, NONE, NONE), 904bf215546Sopenharmony_ci}; 905