graphics.cpp library

Source code of graphics.cpp library (~/libraries/VGA2/graphics.cpp)

#include "VGA.h"


int yyy = 0;

bool order1 = 1;

bool order2 = 1;

bool order3 = 1;



void Vga::clear(int c){

if(mode==VGA_MONO){

for(int y=0;y<ysize;y++){

memset(pb+y*pw,(c&1)?0xff:0,xsize/8);

}

}

else if(mode&VGA_COLOUR){

memset(cb,c,cbsize);

}

}


void Vga::drawPixel(int x, int y, int c)

{

if((x<0)||(x>=xsize)||(y<0)||(y>=ysize))return;

if(mode==VGA_MONO){

if(c>=0) pbb[y*pbw+(x^15)]=c;

else pbb[y*pbw+(x^15)]^=c;

}

else if(mode&VGA_COLOUR){

if(c>=0) cb[y*cw+x]=c;

else cb[y*cw+x]^= -c;

}

}

template <typename T> int _v_sgn(T val) {

return (T(0) < val) - (val < T(0));

}






void Vga::drawLine(int x0, int y0, int x1, int y1,int c)

{

int dx=abs(x1-x0), dy=abs(y1-y0),sx=_v_sgn(x1-x0),sy=_v_sgn(y1-y0);

int err=dx-dy;

if((x0!=x1)||(y0!=y1))drawPixel(x1,y1,c);

do{ drawPixel(x0,y0,c);

int e2=2*err;

if (e2 > -dy){err-=dy;x0+=sx;}

if (e2 < dx){err+=dx;y0+=sy;}

} while ((x0!=x1)||(y0!=y1));

}


void Vga::drawHLine(int y,int x0, int x1, int col)

{

for(int i=x0;i<x0+x1+1;i++)drawPixel(i,y,col);

}


void Vga::drawVLine(int x,int y0, int y1, int col)

{

for(int i=y0;i<=y0+y1;i++)drawPixel(x,i,col);

}


void Vga::drawLinex(int x0, int y0, int x1, int y1,int c)

{ // Draw line, missing the last point

int dx=abs(x1-x0), dy=abs(y1-y0),sx=_v_sgn(x1-x0),sy=_v_sgn(y1-y0);

int err=dx-dy;

while ((x0!=x1)||(y0!=y1)){

drawPixel(x0,y0,c);

int e2=2*err;

if (e2 > -dy){err-=dy;x0+=sx;}

if (e2 < dx){err+=dx;y0+=sy;}

}

}


void Vga::drawLineXa(int x0, int y0, int x1, int y1, int xplanemin, int xplanemax, int yplanemax, int c)

{ // Draw line, missing the last point

int dx=abs(x1-x0), dy=abs(y1-y0),sx=_v_sgn(x1-x0),sy=_v_sgn(y1-y0);

int err=dx-dy;

while ((x0!=x1) and (x0!=xplanemin) and (x0!=xplanemax) and (y0!=y1) and (y0!=yplanemax)){

if(x0>xplanemin and x0<xplanemax) {

if(y0<yplanemax) {

drawPixel(x0,y0,c);

int e2=2*err;

if (e2 > -dy){err-=dy;x0+=sx;}

if (e2 < dx){err+=dx;y0+=sy;}

}

}

}

}


void Vga::drawTri(int x0,int y0,int x1,int y1,int x2,int y2,int col)

{

drawLine(x0,y0,x1,y1,col);

drawLine(x1,y1,x2,y2,col);

drawLine(x2,y2,x0,y0,col);

}

#define _V_P(x,y) if(y>=0 && y<ysize){if(x<xmin[y])xmin[y]=x;if(x>xmax[y])xmax[y]=x;}

void Vga::fillTri(int x0,int y0,int x1,int y1,int x2,int y2,int col)

{ //TODO - this can be done without needing an array

short xmin[ysize],xmax[ysize];

for(int i=0;i<ysize;i++){xmin[i]=xsize;xmax[i]= -1;}

int dx,dy,sx,sy,err,x3=x0,y3=y0;

dx=abs(x1-x0);dy=abs(y1-y0);sx=_v_sgn(x1-x0);sy=_v_sgn(y1-y0);err=dx-dy;

while ((x0!=x1)||(y0!=y1)){

_V_P(x0,y0)

int e2=2*err;

if (e2 > -dy){err-=dy;x0+=sx;}

if (e2 < dx){err+=dx;y0+=sy;}

}

dx=abs(x2-x1);dy=abs(y2-y1);sx=_v_sgn(x2-x1);sy=_v_sgn(y2-y1);err=dx-dy;

while ((x1!=x2)||(y1!=y2)){

_V_P(x1,y1)

int e2=2*err;

if (e2 > -dy){err-=dy;x1+=sx;}

if (e2 < dx){err+=dx;y1+=sy;}

}

dx=abs(x3-x2);dy=abs(y3-y2);sx=_v_sgn(x3-x2);sy=_v_sgn(y3-y2);err=dx-dy;

while ((x2!=x3)||(y2!=y3)){

_V_P(x2,y2)

int e2=2*err;

if (e2 > -dy){err-=dy;x2+=sx;}

if (e2 < dx){err+=dx;y2+=sy;}

}

for(int i=0;i<ysize;i++)if(xmin[i]<=xmax[i])drawHLine(i,xmin[i],xmax[i],col);

}


void Vga::drawRect(int x0, int y0, int x1, int y1, int col)

{

drawLinex(x0,y0,x0,y1,col);

drawLinex(x0,y1,x1,y1,col);

drawLinex(x1,y1,x1,y0,col);

drawLinex(x1,y0,x0,y0,col);

}


void Vga::fillRect(int x0, int y0, int x1, int y1, int col){

for (int i = y0; i < y0+y1+1; i++) {

drawHLine(i,x0,x1,col);

}

}


void Vga::drawRoundRecta(int ax0, int ay0, int ax1, int ay1, int ar0, int acol) {



drawHLine(ay0, (ax0 + ar0), (ax1 - (2 * ar0)), acol);


drawVLine(ax0, (ay0 + ar0), (ay1 - (2 * ar0)), acol);


drawHLine(ay0+ay1, (ax0 + ar0), (ax1 - (2 * ar0)), acol);


drawVLine(ax0+ax1, (ay0 + ar0), (ay1 - (2 * ar0)), acol);


drawArcCircle((ax0 + ar0), (ay0 + ar0), ar0, 0, acol);


drawArcCircle((ax0 + ax1 - ar0), (ay0 + ar0), ar0, 1, acol);


drawArcCircle((ax0 + ar0), (ay0 + ay1 - ar0), ar0, 2, acol);


drawArcCircle((ax0 + ax1 - ar0), (ay0 + ay1 - ar0), ar0, 3, acol);



}


void Vga::fillRoundRecta(int ax0, int ay0, int ax1, int ay1, int ar0, int acol) {



fillRect((ax0 + ar0), ay0, (ax1 - (2 * ar0)), ar0, acol);


fillRect(ax0, (ay0 + ar0), ax1, (ay1 - (2 * ar0)), acol);


fillRect((ax0 + ar0), (ay0 + ay1 - ar0), (ax1 - (2 * ar0)), ar0, acol);


fillCircle((ax0 + ax1 - ar0), (ay0 + ar0), ar0, acol);


fillCircle((ax0 + ar0), (ay0 + ar0), ar0, acol);


fillCircle((ax0 + ar0), (ay0 + ay1 - ar0), ar0, acol);


fillCircle((ax0 + ax1 - ar0), (ay0 + ay1 - ar0), ar0, acol);


}


void Vga::drawArcCircle(int xm, int ym, int r, int quad, int col){

int x = -r, y = 0, err = 2-2*r; /* bottom left to top right */

do {

if(quad == 1) { drawPixel(xm+y, ym+x,col); }

else if(quad == 0) { drawPixel(xm+x, ym-y,col); }

else if(quad == 2) { drawPixel(xm-y, ym-x,col); }

else if(quad == 3) { drawPixel(xm-x, ym+y,col); }


r = err;

if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */

if (r > x || err > y) /* e_xy+e_x > 0 or no 2nd y-step */

err += ++x*2+1; /* -> x-step now */

} while (x < 0);

}



// These circle and ellipse functions taken from

// http://members.chello.at/~easyfilter/bresenham.html

// by Zingl Alois

void Vga::drawCircle(int xm, int ym, int r, int col){

int x = -r, y = 0, err = 2-2*r; /* bottom left to top right */

do {

drawPixel(xm+y, ym+x,col);

drawPixel(xm-x, ym+y,col);

drawPixel(xm+x, ym-y,col);

drawPixel(xm-y, ym-x,col);


r = err;

if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */

if (r > x || err > y) /* e_xy+e_x > 0 or no 2nd y-step */

err += ++x*2+1; /* -> x-step now */

} while (x < 0);

}


void Vga::drawCircla(int xm, int ym, int r, int col){



for(int cx = (xm - r); cx <= (xm + r); cx++) {

for(int cy = (ym - r); cy <= (ym + r); cy++) {


if (sqrt(((cx-xm)*(cx-xm)) + ((cy-ym)*(cy-ym))) <= r+1 and sqrt(((cx-xm)*(cx-xm)) + ((cy-ym)*(cy-ym))) >= r) {

drawPixel(cx,cy,col); // set pixel colour

}


}

}


}


void Vga::fillCircle(int xm, int ym, int r, int col){



for(int cx = (xm - r); cx <= (xm + r); cx++) {

for(int cy = (ym - r); cy <= (ym + r); cy++) {


if (sqrt(((cx-xm)*(cx-xm)) + ((cy-ym)*(cy-ym))) <= r+1) {

drawPixel(cx,cy,col); // set pixel colour

}


}

}


}


void Vga::drawEllipse(int x0, int y0, int x1, int y1, int col)

{ /* rectangular parameter enclosing the ellipse */

long a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* diameter */

double dx = 4*(1.0-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */

double err = dx+dy+b1*a*a, e2; /* error of 1.step */


if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */

if (y0 > y1) y0 = y1; /* .. exchange them */

y0 += (b+1)/2; y1 = y0-b1; /* starting pixel */

a = 8*a*a; b1 = 8*b*b;

do {

drawPixel(x1, y0,col); /* I. Quadrant */

drawPixel(x0, y0,col); /* II. Quadrant */

drawPixel(x0, y1,col); /* III. Quadrant */

drawPixel(x1, y1,col); /* IV. Quadrant */

e2 = 2*err;

if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */

if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */

} while (x0 <= x1);


while (y0-y1 <= b) { /* too early stop of flat ellipses a=1 */

drawPixel(x0-1, y0,col); /* -> finish tip of ellipse */

drawPixel(x1+1, y0++,col);

drawPixel(x0-1, y1,col);

drawPixel(x1+1, y1--,col);

}

}


void Vga::fillEllipse(int x0, int y0, int x1, int y1, int col)

{ /* rectangular parameter enclosing the ellipse */

long a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* diameter */

double dx = 4*(1.0-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */

double err = dx+dy+b1*a*a, e2; /* error of 1.step */

short xmin[ysize],xmax[ysize];

for(int i=0;i<ysize;i++){xmin[i]=xsize;xmax[i]= -1;}


if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped points */

if (y0 > y1) y0 = y1; /* .. exchange them */

y0 += (b+1)/2; y1 = y0-b1; /* starting pixel */

a = 8*a*a; b1 = 8*b*b;

do {

_V_P(x1, y0); /* I. Quadrant */

_V_P(x0, y0); /* II. Quadrant */

_V_P(x0, y1); /* III. Quadrant */

_V_P(x1, y1); /* IV. Quadrant */

e2 = 2*err;

if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */

if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */

} while (x0 <= x1);


while (y0-y1 <= b) { /* too early stop of flat ellipses a=1 */

_V_P(x0-1, y0); /* -> finish tip of ellipse */

_V_P(x1+1, y0++);

_V_P(x0-1, y1);

_V_P(x1+1, y1--);

}

for(int i=0;i<ysize;i++)if(xmin[i]<=xmax[i])drawHLine(i,xmin[i],xmax[i],col);

}



void Vga::drawButton(char* title, int ax0, int ay0, int ax1, int ay1, int ar0, int acol, int tcol, int bgcol) {


drawRoundRecta(ax0,ay0,ax1,ay1,ar0,acol);

String titleStr = title;

int lenght = (int)strlen(title);

VGA.drawText(title, (ax0+(ax1/2)-(lenght*8/2)), ay0+(ay1/2)-4, tcol, bgcol, 0);


}


void Vga::fillButton(char* title, int ax0, int ay0, int ax1, int ay1, int ar0, int acol, int tcol, int bgcol) {


fillRoundRecta(ax0,ay0,ax1,ay1,ar0,acol);

int lenght = strlen(title);

VGA.drawText(title, (ax0+(ax1/2)-(lenght/2)), ay0+(ay1/2)-4, tcol, bgcol, 0);


}



void Vga::linpot_H(char* linpot_title, uint16_t linpot_X, uint16_t linpot_Y, uint16_t linpot_width, uint16_t linpot_Nvalues,uint16_t linpot_value, uint16_t linpot_FGcolour, uint16_t linpot_BGcolour, uint16_t linpot_TFGcolour, uint16_t linpot_TBGcolour, uint16_t linpot_INBGcolour ) {


char stringa2[40] = "";


if(linpot_Nvalues==31){

sprintf(stringa2,"%s%i/%i) = %dHz ", linpot_title, linpot_value+1, linpot_Nvalues+1, hertzValue(linpot_value));

}

else if(linpot_Nvalues==15){

sprintf(stringa2,"%s%i/%i) = %dHz ", linpot_title, linpot_value+1, linpot_Nvalues+1, hertzValue2(linpot_value));

}

else if(linpot_Nvalues==7){

sprintf(stringa2,"%s%i/%i) = %dHz ", linpot_title, linpot_value+1, linpot_Nvalues+1, hertzValue3(linpot_value));

}

VGA.drawText(stringa2, linpot_X+10, linpot_Y-10, linpot_TFGcolour, linpot_TBGcolour, 0); //for the crossover frequency

VGA.drawRoundRecta(linpot_X, linpot_Y, (linpot_width*linpot_Nvalues)+2, 20, 3, linpot_BGcolour);

for (int i = 0; i < linpot_value; i++) {

VGA.fillRect(linpot_X+2+(i*linpot_width), linpot_Y+2, (linpot_width-2), 16, linpot_FGcolour);

}

for (int l = linpot_value; l < linpot_Nvalues; l++) {

VGA.fillRect(linpot_X+2+(l*linpot_width), linpot_Y+2, (linpot_width-2), 16, linpot_INBGcolour);

}

}


void Vga::linpot_HR(char* linpot_title, uint16_t linpot_X, uint16_t linpot_Y, uint16_t linpot_width, uint16_t linpot_Nvalues,uint16_t linpot_value, uint16_t linpot_FGcolour, uint16_t linpot_BGcolour, uint16_t linpot_TFGcolour, uint16_t linpot_TBGcolour, uint16_t linpot_INBGcolour ) {


char stringa2[40] = "";

sprintf(stringa2,"%s%i/%i) = %s", linpot_title, linpot_value+1, linpot_Nvalues+1, resoValue(linpot_value));


VGA.drawText(stringa2, linpot_X-10, linpot_Y-10, linpot_TFGcolour, linpot_TBGcolour, 0); //for the crossover frequency

VGA.drawRoundRecta(linpot_X, linpot_Y, (linpot_width*linpot_Nvalues)+2, 20, 3, linpot_BGcolour);

for (int i = 0; i < linpot_value; i++) {

VGA.fillRect(linpot_X+2+(i*linpot_width), linpot_Y+2, (linpot_width-2), 16, linpot_FGcolour);

}

for (int l = linpot_value; l < linpot_Nvalues; l++) {

VGA.fillRect(linpot_X+2+(l*linpot_width), linpot_Y+2, (linpot_width-2), 16, linpot_INBGcolour);

}

}


void Vga::linpot_V(char* linpot_title, uint16_t linpot_X, uint16_t linpot_Y, uint16_t linpot_height, uint16_t linpot_Nvalues,uint16_t linpot_value, uint16_t linpot_FGcolour, uint16_t linpot_BGcolour, uint16_t linpot_TFGcolour, uint16_t linpot_TBGcolour, uint16_t linpot_INBGcolour ) {


char stringa1[40] = "";

char stringa3[40] = "";


sprintf(stringa1, "%s", linpot_title);



if(linpot_value % 2 == 0) {


sprintf(stringa3, "-%s", dbValue(linpot_value));

VGA.drawText(stringa3, linpot_X-9, linpot_Y+(linpot_height*linpot_Nvalues)+20, linpot_TFGcolour, linpot_TBGcolour, 0); //for the db


} else {


sprintf(stringa3, " -%s ", dbValue(linpot_value));

VGA.drawText(stringa3, linpot_X-9, linpot_Y+(linpot_height*linpot_Nvalues)+20, linpot_TFGcolour, linpot_TBGcolour, 0); //for the db

}


VGA.drawText(stringa1, linpot_X+1, linpot_Y, linpot_TFGcolour, linpot_TBGcolour, 0); //for the db symbol

char dbtext[3]="db";

VGA.drawText(dbtext, linpot_X+1, linpot_Y+(linpot_height*linpot_Nvalues)+32, linpot_TFGcolour, linpot_TBGcolour, 0); //for the title





VGA.drawRoundRecta(linpot_X, linpot_Y+10, 16, ((linpot_height*linpot_Nvalues)+2), 3, linpot_BGcolour);

for (int i = 0; i < linpot_value; i++) {

VGA.fillRect(linpot_X+2, linpot_Y+3+(linpot_height*linpot_Nvalues)-(i*linpot_height), 12, (linpot_height)-2, linpot_FGcolour);

}

for (int l = linpot_value; l < linpot_Nvalues; l++) {

VGA.fillRect(linpot_X+2, linpot_Y+3+(linpot_height*linpot_Nvalues)-(l*linpot_height), 12, (linpot_height)-2, linpot_INBGcolour);

}


}



void Vga::drawLP(uint16_t Xoffset, uint16_t Yoffset, uint16_t Xres, uint16_t Yres, uint8_t cutStep, uint8_t NofCuts, uint8_t volume, uint16_t col, uint16_t ways, bool order){




//------------------LP-plateau---------------------------------//


VGA.drawLinex(Xoffset+1, Yoffset+10+(volume*1), Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts)*cutStep)+15, Yoffset+10+(volume*1), col);


//------------------LP-Ramp+12db---------------------------------//


if(order==0) VGA.drawLineXa(Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts)*cutStep)+15, Yoffset+10+(volume*1), Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts)*cutStep) + ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, (Yoffset+Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------LP-Ramp+24db---------------------------------//


if(order==1) VGA.drawLineXa(Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts)*cutStep)+15, Yoffset+10+(volume*1), Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts)*cutStep) + ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, Yoffset+2*(Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


}



void Vga::drawLM(uint16_t Xoffset, uint16_t Yoffset, uint16_t Xres, uint16_t Yres, uint8_t cutStep1, uint8_t cutStep2, uint8_t NofCuts1, uint8_t NofCuts2, uint8_t volume, uint16_t col, uint16_t ways, bool order1, bool order2){


if(ways==4){


//------------------LM-Ramp+plateau---------------------------------//


VGA.drawLinex(Xoffset+(Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+(2*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2)+15, Yoffset+10+(volume*1), col);


//------------------LM-Ramp-12db------------------------------------//

if(order1==0) VGA.drawLineXa(Xoffset+(Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts1)*cutStep1) - ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, (Yoffset+Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------LM-Ramp-24db------------------------------------//


if(order1==1) VGA.drawLineXa(Xoffset+(Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+(Xres/ways)-5-(((Xres/ways)/NofCuts1)*cutStep1) - ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, Yoffset+2*(Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------LM-Ramp+12db---------------------------------//


if(order2==0) VGA.drawLineXa(Xoffset+(2*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2)+15, Yoffset+10+(volume*1), Xoffset+(2*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2) + ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, (Yoffset+Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------LM-Ramp+24db---------------------------------//


if(order2==1) VGA.drawLineXa(Xoffset+(2*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2)+15, Yoffset+10+(volume*1), Xoffset+(2*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2) + ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, Yoffset+2*(Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


}


}


void Vga::drawMH(uint16_t Xoffset, uint16_t Yoffset, uint16_t Xres, uint16_t Yres, uint8_t cutStep1, uint8_t cutStep2, uint8_t NofCuts1, uint8_t NofCuts2, uint8_t volume, uint16_t col, uint16_t ways, bool order1, bool order2){


if(ways>2){


//------------------MH-Ramp+plateau---------------------------------//


VGA.drawLinex(Xoffset+((ways-2)*Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2)+15, Yoffset+10+(volume*1), col);


//------------------MH-Ramp-12db------------------------------------//

if(order1==0) VGA.drawLineXa(Xoffset+((ways-2)*Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+((ways-2)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep1) - ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, (Yoffset+Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------MH-Ramp-24db------------------------------------//


if(order1==1) VGA.drawLineXa(Xoffset+((ways-2)*Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+((ways-2)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep1) - ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, Yoffset+2*(Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------MH-Ramp+12db---------------------------------//


if(order2==0) VGA.drawLineXa(Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2)+15, Yoffset+10+(volume*1), Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2) + ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, (Yoffset+Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------MH-Ramp+24db---------------------------------//


if(order2==1) VGA.drawLineXa(Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2)+15, Yoffset+10+(volume*1), Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts2)*cutStep2) + ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, Yoffset+2*(Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);

}

}


void Vga::drawHP(uint16_t Xoffset, uint16_t Yoffset, uint16_t Xres, uint16_t Yres, uint8_t cutStep1, uint8_t NofCuts1, uint8_t volume, uint16_t col, uint16_t ways, bool order){




//------------------HP-Ramp+plateau---------------------------------//


VGA.drawLinex(Xoffset+((ways-1)*Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+Xres, Yoffset+10+(volume*1), col);


//------------------HP-Ramp-12db------------------------------------//

if(order==0) VGA.drawLineXa(Xoffset+((ways-1)*Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts1)*cutStep1) - ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, (Yoffset+Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);


//------------------HP-Ramp-24db------------------------------------//


if(order==1) VGA.drawLineXa(Xoffset+((ways-1)*Xres/ways)+5-(((Xres/ways)/NofCuts1)*cutStep1)+15, Yoffset+10+(volume*1), Xoffset+((ways-1)*Xres/ways)-5-(((Xres/ways)/NofCuts1)*cutStep1) - ((Yoffset+Yres)-Yoffset+10+(volume*1))+15, Yoffset+2*(Yres+(volume*1)), Xoffset, Xoffset+Xres, Yoffset+Yres, col);




}




void Vga::scroll(int x, int y, int w, int h, int dx, int dy,int col){

if(mode&VGA_COLOUR){

if(dy<=0){

if(dx<=0){

for(int i=x;i<x+w+dx;i++)for(int j=y;j<y+h+dy;j++)

putCPixelFast(i,j,getCPixelFast(i-dx,j-dy));

}

else{

for(int i=x+w-1;i>=x+dx;i--)for(int j=y;j<y+h+dy;j++)

putCPixelFast(i,j,getCPixelFast(i-dx,j-dy));

}

}

else{

if(dx<=0){

for(int i=x;i<x+w+dx;i++)for(int j=y+h-1;j>=y+dy;j--)

putCPixelFast(i,j,getCPixelFast(i-dx,j-dy));

}

else{

for(int i=x+w-1;i>=x+dx;i--)for(int j=y+h-1;j>=y+dy;j--)

putCPixelFast(i,j,getCPixelFast(i-dx,j-dy));

}

}

}

else

if(mode==VGA_MONO){

if(dy<=0){

if(dx<=0){

for(int i=x;i<x+w+dx;i++)for(int j=y;j<y+h+dy;j++)

putPPixelFast(i,j,getPPixelFast(i-dx,j-dy));

}

else{

for(int i=x+w-1;i>=x+dx;i--)for(int j=y;j<y+h+dy;j++)

putPPixelFast(i,j,getPPixelFast(i-dx,j-dy));

}

}

else{

if(dx<=0){

for(int i=x;i<x+w+dx;i++)for(int j=y+h-1;j>=y+dy;j--)

putPPixelFast(i,j,getPPixelFast(i-dx,j-dy));

}

else{

for(int i=x+w-1;i>=x+dx;i--)for(int j=y+h-1;j>=y+dy;j--)

putPPixelFast(i,j,getPPixelFast(i-dx,j-dy));

}

}

}

if(col== -256)return;

if(dy>0)fillRect(x,y,x+w-1,y+dy-1,col);

else if(dy<0)fillRect(x,y+h+dy,x+w-1,y+h-1,col);

if(dx>0)fillRect(x,y,x+dx-1,y+h-1,col);

else if(dx<0)fillRect(x+w+dx,y,x+w-1,y+h-1,col);

}


int Vga::hertzValue(uint16_t stepNumber) {


if(stepNumber == 0) { return 87; }

if(stepNumber == 1) { return 239; }

if(stepNumber == 2) { return 392; }

if(stepNumber == 3) { return 543; }

if(stepNumber == 4) { return 697; }

if(stepNumber == 5) { return 849; }

if(stepNumber == 6) { return 1001; }

if(stepNumber == 7) { return 1153; }

if(stepNumber == 8) { return 1311; }

if(stepNumber == 9) { return 1463; }

if(stepNumber == 10) { return 1616; }

if(stepNumber == 11) { return 1767; }

if(stepNumber == 12) { return 1921; }

if(stepNumber == 13) { return 2073; }

if(stepNumber == 14) { return 2225; }

if(stepNumber == 15) { return 2377; }

if(stepNumber == 16) { return 2539; }

if(stepNumber == 17) { return 2691; }

if(stepNumber == 18) { return 2844; }

if(stepNumber == 19) { return 2995; }

if(stepNumber == 20) { return 3149; }

if(stepNumber == 21) { return 3301; }

if(stepNumber == 22) { return 3453; }

if(stepNumber == 23) { return 3605; }

if(stepNumber == 24) { return 3763; }

if(stepNumber == 25) { return 3915; }

if(stepNumber == 26) { return 4068; }

if(stepNumber == 27) { return 4219; }

if(stepNumber == 28) { return 4373; }

if(stepNumber == 29) { return 4525; }

if(stepNumber == 30) { return 4677; }

if(stepNumber == 31) { return 4829; }

}


int Vga::hertzValue2(uint16_t stepNumber) {


if(stepNumber == 0) { return 102; }

if(stepNumber == 1) { return 203; }

if(stepNumber == 2) { return 305; }

if(stepNumber == 3) { return 406; }

if(stepNumber == 4) { return 510; }

if(stepNumber == 5) { return 612; }

if(stepNumber == 6) { return 714; }

if(stepNumber == 7) { return 815; }

if(stepNumber == 8) { return 919; }

if(stepNumber == 9) { return 1020; }

if(stepNumber == 10) { return 1122; }

if(stepNumber == 11) { return 1224; }

if(stepNumber == 12) { return 1327; }

if(stepNumber == 13) { return 1429; }

if(stepNumber == 14) { return 1531; }

if(stepNumber == 15) { return 1632; }

}


int Vga::hertzValue3(uint16_t stepNumber) {


if(stepNumber == 0) { return 81; }

if(stepNumber == 1) { return 129; }

if(stepNumber == 2) { return 178; }

if(stepNumber == 3) { return 226; }

if(stepNumber == 4) { return 274; }

if(stepNumber == 5) { return 322; }

if(stepNumber == 6) { return 371; }

if(stepNumber == 7) { return 418; }

}


const char* Vga::dbValue(uint16_t stepNumber) {


if(stepNumber == 0) { return "7.5"; }

if(stepNumber == 1) { return "7"; }

if(stepNumber == 2) { return "6.5"; }

if(stepNumber == 3) { return "6"; }

if(stepNumber == 4) { return "5.5"; }

if(stepNumber == 5) { return "5"; }

if(stepNumber == 6) { return "4.5"; }

if(stepNumber == 7) { return "4"; }

if(stepNumber == 8) { return "3.5"; }

if(stepNumber == 9) { return "3"; }

if(stepNumber == 10) { return "2.5"; }

if(stepNumber == 11) { return "2"; }

if(stepNumber == 12) { return "1.5"; }

if(stepNumber == 13) { return "1"; }

if(stepNumber == 14) { return "0.5"; }

if(stepNumber == 15) { return "0"; }


}


const char* Vga::resoValue(int stepNumber) {


if(stepNumber == 0) { return "Butterworth"; }

if(stepNumber == 1) { return "Bessel-1 "; }

if(stepNumber == 2) { return "Bessel-2 "; }

if(stepNumber == 3) { return "Linkwitz-R."; }



}