Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,11 @@ POSITIONS dpos =
void loadexternalpalette();
void initicon();

static inline void setcharcolor(unsigned *dptr, short ch, short color)
static inline void setcharcolor(unsigned *dptr, unsigned char ch, unsigned char color)
{
*dptr = (ch & 0xff) | (color << 16) | (colors.CBKGND << 20);
}

static inline void setcolor(unsigned *dptr, short color)
{
*dptr = (*dptr & 0xffff) | (color << 16) | (colors.CBKGND << 20);
}

bool initscreen()
{
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO))
Expand Down Expand Up @@ -292,8 +287,7 @@ void printblankc(int x, int y, int color, int length)
void drawbox(int x, int y, int color, int sx, int sy)
{
if (!gfxinitted) return;
if (y < 0) return;
if (y >= MAX_ROWS) return;
if ((y < 0) || (y >= MAX_ROWS)) return;
if (y+sy > MAX_ROWS) return;
if ((!sx) || (!sy)) return;

Expand Down Expand Up @@ -343,7 +337,7 @@ void printbg(int x, int y, int color, int length)

while (length--)
{
setcolor(dptr, 15 | (color << 4));
*dptr = (*dptr & 0xffff) | (colors.CBKGND << 16) | (color << 20);
dptr++;
}
}
Expand Down Expand Up @@ -401,11 +395,10 @@ void fliptoscreen()
unsigned char *dptr = (unsigned char*)gfx_screen->pixels + y*fontheight * gfx_screen->pitch + x*fontwidth;
unsigned char bgcolor = (*sptr) >> 20;
unsigned char fgcolor = ((*sptr) >> 16) & 0xf;
int c;

unsigned char e = *chptr++;

for (c = 0; c < 14; c++)
for (int c = 0; c < 14; c++)
{
e = *chptr++;

Expand Down
80 changes: 48 additions & 32 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,25 @@
#include <cstdio>
#include <cstring>

#define CBLACK 0x0
#define CWHITE 0x1
#define CDRED 0x2
#define CCYAN 0x3
#define CPURPLE 0x4
#define CDGREEN 0x5
#define CDBLUE 0x6
#define CYELLOW 0x7
#define CLBROWN 0x8
#define CDBROWN 0x9
#define CLRED 0xA
#define CDGREY 0xB
#define CGREY 0xC
#define CLGREEN 0xD
#define CLBLUE 0xE
#define CLGREY 0xF
enum
{
CBLACK = 0x0,
CWHITE = 0x1,
CDRED = 0x2,
CCYAN = 0x3,
CPURPLE = 0x4,
CDGREEN = 0x5,
CDBLUE = 0x6,
CYELLOW = 0x7,
CLBROWN = 0x8,
CDBROWN = 0x9,
CLRED = 0xA,
CDGREY = 0xB,
CGREY = 0xC,
CLGREEN = 0xD,
CLBLUE = 0xE,
CLGREY = 0xF
};

const char *notename[] =
{"C-0", "C#0", "D-0", "D#0", "E-0", "F-0", "F#0", "G-0", "G#0", "A-0", "A#0", "B-0",
Expand All @@ -73,11 +76,14 @@ int timemin = 0;
int timesec = 0;
unsigned timeframe = 0;

int cursorflash = 0;
int cursorcolortable[] = { CWHITE, CLGREY, CGREY, CLGREY };

void initcolorscheme(bool dark)
{
colors.CBKGND = dark ? CBLACK : CDBLUE;

colors.CNORMAL = (dark ? CGREY : CLBLUE) |(colors.CBKGND<<4);
colors.CNORMAL = (dark ? CGREY : CLBLUE)|(colors.CBKGND<<4);
colors.CMUTE = CDGREY |(colors.CBKGND<<4);
colors.CEDIT = CLGREEN|(colors.CBKGND<<4);
colors.CPLAYING = CLRED |(colors.CBKGND<<4);
Expand All @@ -97,21 +103,31 @@ void printmainscreen()
fliptoscreen();
}

void flashCursor()
{
if (cursorflashdelay >= 6)
{
cursorflashdelay %= 6;
cursorflash++;
cursorflash &= 3;
}
}

int getCursorColor()
{
return cursorcolortable[cursorflash];
}

void displayupdate()
{
if (cursorflashdelay >= 6)
{
cursorflashdelay %= 6;
cursorflash++;
cursorflash &= 3;
}
flashCursor();
printstatus();
fliptoscreen();
}

void printstatus()
{
int cc = cursorcolortable[cursorflash];
int cc = getCursorColor();
int visibleOrderlist = getVisibleOrderlist();
int maxChns = getMaxChannels();

Expand Down Expand Up @@ -301,12 +317,12 @@ void printstatus()
if (epmarkstart <= epmarkend)
{
if ((p >= epmarkstart) && (p <= epmarkend))
printbg(dpos.patternsX+c*13+3, dpos.patternsY+1+d, 8, 9);
printbg(dpos.patternsX+c*13+3, dpos.patternsY+1+d, colors.CHDRBG, 9);
}
else
{
if ((p <= epmarkstart) && (p >= epmarkend))
printbg(dpos.patternsX+c*13+3, dpos.patternsY+1+d, 8, 9);
printbg(dpos.patternsX+c*13+3, dpos.patternsY+1+d, colors.CHDRBG, 9);
}
}
if ((color == colors.CEDIT) && (editmode == EDIT_PATTERN) && (epchn == c))
Expand Down Expand Up @@ -412,19 +428,19 @@ void printstatus()
if ((p >= esmarkstart) && (p <= esmarkend))
{
if (p != esmarkend)
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, 1, 3);
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, colors.CHDRBG, 3);
else
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, 1, 2);
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, colors.CHDRBG, 2);
}
}
else
{
if ((p <= esmarkstart) && (p >= esmarkend))
{
if (p != esmarkstart)
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, 1, 3);
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, colors.CHDRBG, 3);
else
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, 1, 2);
printbg(dpos.orderlistX+4+d*3, dpos.orderlistY+1+c, colors.CHDRBG, 2);
}
}
}
Expand Down Expand Up @@ -516,12 +532,12 @@ void printstatus()
if (etmarkstart <= etmarkend)
{
if ((p >= etmarkstart) && (p <= etmarkend))
printbg(dpos.instrumentsX+10*c+3, dpos.instrumentsY+8+d, 1, 5);
printbg(dpos.instrumentsX+10*c+3, dpos.instrumentsY+8+d, colors.CHDRBG, 5);
}
else
{
if ((p <= etmarkstart) && (p >= etmarkend))
printbg(dpos.instrumentsX+10*c+3, dpos.instrumentsY+8+d, 1, 5);
printbg(dpos.instrumentsX+10*c+3, dpos.instrumentsY+8+d, colors.CHDRBG, 5);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ void displayupdate();
void printstatus();
void resettime();
void incrementtime();
void flashCursor();
int getCursorColor();

#endif
9 changes: 2 additions & 7 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,8 @@ bool fileselector(char *name, char *path, char *filter, const char *title, int f
int exitfilesel = -1;
while (exitfilesel < 0)
{
int cc = cursorcolortable[cursorflash];
if (cursorflashdelay >= 6)
{
cursorflashdelay %= 6;
cursorflash++;
cursorflash &= 3;
}
int cc = getCursorColor();
flashCursor();
fliptoscreen();
getkey();
if (lastclick) lastclick--;
Expand Down
2 changes: 0 additions & 2 deletions src/loadtrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ int editmode = EDIT_PATTERN;
bool recordmode = true;
bool followplay = false;
int hexnybble = -1;
int cursorflash = 0;
int cursorcolortable[] = {1,2,7,2};
bool exitprogram = false;
int eacolumn = 0;
int eamode = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/loadtrk.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ extern int editmode;
extern bool recordmode;
extern bool followplay;
extern int hexnybble;
extern int cursorflash;
extern int cursorcolortable[];
extern bool exitprogram;
extern int eacolumn;
extern int eamode;
Expand Down
Loading