void matrix_show(void) { for(uint8_t n = 0; n < 4; ++n) { uint8_t i; for(i = 0; i < 3; ++i) { move_line(i); write_line(pixels + (i * 3), n); wait_ms(1); } } }
static void matrix_int(void) { ++index; if(index >= 3) { ++cycle; index = 0; } move_line(index); write_line(pixels + (index * 3), cycle & 3); }
void move_primitive(PRIMITIVE *p) { switch (p->size) { case 1: move_point(&p->points[0], p->velocity); break; case 2: move_line(&p->points[0], &p->points[1], &p->centroid, p->velocity, p->rotation); break; default: move_polygon(p->points, p->size, &p->centroid, p->velocity, &p->angle, p->rotation, &p->bounding_box); break; } }
bool route(int ch) { /* Keys available in both ESCAPE and REPLACE modes. */ switch (ch) { case CTRL('c'): case CTRL('q'): return false; break; case KEY_SUSPEND: case CTRL('z'): suspend(); break; case CTRL('w'): buf_write(); break; case CTRL('r'): buf_revert(); break; case CTRL('['): set_state(ESCAPE); break; case KEY_LEFT: move_col(-1); break; case KEY_UP: move_line(-1); break; case KEY_RIGHT: move_col(+1); break; case KEY_DOWN: move_line(+1); break; case '\t': toggle_mode(); break; default: if (buf.state == REPLACE) { replace_char(ch); return true; } break; } /* Keys available in only ESCAPE mode. */ switch (ch) { case 'R': set_state(REPLACE); break; case 'h': move_col(-1); break; case 'k': move_line(-1); break; case 'l': move_col(+1); break; case 'j': move_line(+1); break; case 'w': goto_grp_next(); break; case 'b': goto_grp_prev(); break; case 'g': goto_buffer_beg(); break; case 'G': goto_buffer_end(); break; case '^': goto_line_beg(); break; case '$': goto_line_end(); break; case 'd': goto_half_next(); break; case 'u': goto_half_prev(); break; case '?': view.help = !view.help; break; default: break; } return true; }
bool Stinkhorn<CellT, Dimensions>::ToysFingerprint::handleInstruction(CellT instruction, Context& ctx) { StackStackT& stack = ctx.stack(); Cursor& cr = ctx.cursor(); switch(instruction) { case 'C': copy(ctx, true, false); return true; case 'K': copy(ctx, false, false); return true; case 'M': copy(ctx, true, true); return true; case 'V': copy(ctx, false, true); return true; case 'S': chicane(ctx); return true; case 'L': { stack.push(cr.get(cr.position() + cr.leftwards90Z())); return true; } case 'R': { stack.push(cr.get(cr.position() + cr.rightwards90Z())); return true; } case 'I': stack.push(stack.pop() + 1); return true; case 'D': stack.push(stack.pop() - 1); return true; case 'N': stack.push(-stack.pop()); return true; //SPEC: I'm assuming it's meant to push a back onto the stack, even though //the documentation didn't say so. case 'H': { CellT a, b; b = stack.pop(); a = stack.pop(); if(b >= 0) a <<= b; else a >>= -b; stack.push(a); return true; } case 'A': { CellT n = stack.pop(); CellT value = stack.pop(); if(n < 0) cr.reflect(); else while(n--) stack.push(value); return true; } case 'B': { CellT a, b; b = stack.pop(); a = stack.pop(); stack.push(a+b); stack.push(a-b); return true; } case 'E': { CellT sum = 0; while(stack.topStackSize()) sum += stack.pop(); stack.push(sum); return true; } case 'P': { CellT sum = 1; while(stack.topStackSize()) sum *= stack.pop(); stack.push(sum); return true; } //SPEC: I interpreted the spec as saying that j should be implicitly taken from //the size of the stack... but what do I know? //Doing what ccbi does here anyway. case 'F': { Vector least = stack.popVector(Dimensions); Cursor matrix_cursor(cr); CellT j = stack.pop(); CellT i = stack.pop(); if(i <= 0) { cr.reflect(); return true; } CellT y = 0; while(y < j) { for(CellT x = 0; x < i; ++x) { matrix_cursor.position(least + Vector(x, y, 0)); matrix_cursor.put(matrix_cursor.position(), stack.pop()); } ++y; } return true; } //SPEC: Location of j chosen for compatibility with ccbi //(Obviously, j can't be implicit here, unless you terminated on an empty row, but that //would be silly) case 'G': { Vector least = stack.popVector(Dimensions); Cursor matrix_cursor(cr); CellT j = stack.pop(); CellT i = stack.pop(); if(i <= 0) { cr.reflect(); return true; } //SPEC: CCBI does it this way (ie., backwards so that F then G preserves the stack), //but it seems undefined to me. for(CellT y = j - 1; y >= 0; --y) { for(CellT x = i - 1; x >= 0; --x) { matrix_cursor.position(least + Vector(x, y, 0)); stack.push(matrix_cursor.currentCharacter()); } } return true; } case 'Q': cr.put(cr.position() - cr.direction(), stack.pop()); return true; //SPEC: TODO: These should respect hover mode, once it's here... case 'T': { CellT d = stack.pop(); Vector current; /*if(hover) current = cr.direction();*/ switch(d) { case 0: cr.direction(current + (stack.pop() ? Vector(-1, 0, 0) : Vector(1, 0, 0))); break; case 1: cr.direction(current + (stack.pop() ? Vector(0, -1, 0) : Vector(0, 1, 0))); break; case 2: if(Dimensions > 2) cr.direction(current + (stack.pop() ? Vector(0, 0, 1) : Vector(0, 0, -1))); else cr.reflect(); break; default: cr.reflect(); } return true; } //TODO: Low bits of rand() are the least reliable... Should be changed? case 'U': { assert(Dimensions <= 3); CellT result = "<>^vhl"[rand() % (Dimensions * 2)]; cr.put(cr.position(), result); return true; } case 'W': { Vector pos = stack.popVector(Dimensions); CellT value = stack.pop(); CellT actual = cr.get(pos + ctx.storageOffset()); if(actual < value) { stack.push(value); if(Dimensions > 2) stack.push(pos.z); stack.push(pos.y); stack.push(pos.x); cr.position(cr.position() - cr.direction()); } else if(actual > value) { cr.reflect(); } return true; } case 'X': cr.position(cr.position() + Vector(1, 0, 0)); return true; case 'Y': cr.position(cr.position() + Vector(0, 1, 0)); return true; case 'Z': if(Dimensions > 2) cr.position(cr.position() + Vector(0, 0, 1)); else cr.reflect(); return true; case 'O': case 'J': { CellT delta = stack.pop(); if (delta == 0) return true; CellT d = delta > 0 ? 1 : -1; move_line(ctx, instruction == 'O' ? Vector(d, 0, 0) : Vector(0, d, 0), abs(delta)); return true; } } return false; }
/* ------------------------ */ button_click() { register int object; /* 'TOP LINE': oberste Begrenzung aller Zeichen. */ /* 'ASCENT LINE': oberste Zeile aller Gro�buchstaben */ /* 'HALF LINE': oberste Zeile aller Kleinbuchstaben */ /* 'BASE LINE': unterste Zeile aller Zeichen ohne Unterl�nge */ /*'DESCENT LINE': unterste Zeile aller Zeichen mit Unterl�ngen */ /* 'BOTTOM LINE': unterste Begrenzung aller Zeichen. */ object = objc_find(font_back, ROOT, MAX_DEPTH, mousex, mousey); switch(object) { case TOP: case ASCENT: case HALF: case BASE: case BOTTOM: case DESCENT: if (clicks == 1 && object != TOP) move_line(object); else switch(object) { case TOP: form_alert(1, "[1]['TOP LINE':| |oberste Begrenzung aller |Zeichen.][ OK ]"); break; case ASCENT: form_alert(1, "[1]['ASCENT LINE':| |oberste Zeile aller |Gro�buchstaben.][ OK ]"); break; case HALF: form_alert(1, "[1]['HALF LINE':| |oberste Zeile aller |Kleinbuchstaben.][ OK ]"); break; case BASE: form_alert(1, "[1]['BASE LINE':| |unterste Zeile aller |Zeichen ohne Unterl�nge][ OK ]"); break; case BOTTOM: form_alert(1, "[1]['BOTTOM LINE':| |unterste Begrenzung |aller Zeichen.][ OK ]"); break; case DESCENT: form_alert(1, "[1]['DESCENT LINE':| |unterste Zeile aller |Zeichen mit Unterl�ngen.][ OK ]"); break; } break; case F_BKG: /* Editierfeld */ draw_fpoint(); break; case SCL_RGT: /* Skala rechts */ scale_right(); break; case SCL_LFT: /* Skala links */ scale_left(); break; case ROOT: /* Hintergrund */ break; case FONTNAME: /* Fontname */ edit_name(); break; case UP: /* Editorzeile hoch */ edit_up(); break; case DOWN: /* Editorzeile runter */ edit_dwn(); break; case LEFT: /* Editorspalte links */ edit_lft(); break; case RIGHT: /* Editorspalte rechts */ edit_rgt(); break; default: /* FONTLINE */ new_character(); break; } }