package io.github.applecommander.bastools.api.shapes; /** * Represents all "plot vectors" available in an Applesoft shape table. * * @see * Applesoft BASIC Programming Reference Manual */ public enum VectorCommand { // Order here is specific to the encoding within the shape itself MOVE_UP, MOVE_RIGHT, MOVE_DOWN, MOVE_LEFT, PLOT_UP, PLOT_RIGHT, PLOT_DOWN, PLOT_LEFT; public final boolean plot; public final int xmove; public final int ymove; private VectorCommand() { this.plot = (this.ordinal() & 0b100) != 0; // up 0b00 // right 0b01 // down 0b10 // left 0b11 if ((this.ordinal() & 0b001) == 1) { this.xmove = 2 - (this.ordinal() & 0b011); this.ymove = 0; } else { this.xmove = 0; this.ymove = (this.ordinal() & 0b011) - 1; } } }