⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coprtest.c

📁 汇编源代码大全
💻 C
字号:
/*
**  coprtest.c
**  By: Doug Mansell
**  Re: VGA palette changing
**  Link copper.asm with coprtest.c for a little demo...
*/

#include <math.h>

#define SCREENLINES 400             /* suitable for 80x25 text */
#define PALSIZE SCREENLINES+1

struct _rgb 
{
  unsigned char red, green, blue;
} cols[PALSIZE];

void pascal copper(int lines, unsigned char DACnum,
                   void *colours, int count);

void main()
{
  int loop;
  double x, phase;

  /* construct a pretty rainbow colour palette */
  phase = 2 * M_PI / 3;

  for (loop = 0; loop < PALSIZE; loop++) 
  {
     x = 2 * M_PI * loop / PALSIZE;
     cols[loop].red   = 32 * sin(x) + 31;
     cols[loop].green = 32 * sin(x + phase) + 31;
     cols[loop].blue  = 32 * sin(x + 2*phase) + 31;
  }

  /* hold the palette steady for 500 screen refreshes :-) */
  copper(SCREENLINES, 0 ,cols, 500);
  puts("press a key to roll it up the screen"); 
  getch();
  copper(SCREENLINES - 1, 0, cols, 500);
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -