1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-13 09:31:53 +00:00

File had DOS line endings

git-svn-id: svn://svn.cc65.org/cc65/trunk@1421 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-09-30 21:38:07 +00:00
parent 1f20202239
commit 77132165ce

View File

@ -1,243 +1,243 @@
/***************************************************************************** /*****************************************************************************
* plasma test program for cc65. * * plasma test program for cc65. *
* * * *
* (w)2001 by groepaz/hitmen * * (w)2001 by groepaz/hitmen *
* * * *
* Cleanup and porting by Ullrich von Bassewitz. * * Cleanup and porting by Ullrich von Bassewitz. *
* * * *
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <conio.h> #include <conio.h>
#if defined(__C64__) #if defined(__C64__)
# define SCREEN1 0xE000 # define SCREEN1 0xE000
# define SCREEN2 0xE400 # define SCREEN2 0xE400
# define CHARSET 0xE800 # define CHARSET 0xE800
# define outb(addr,val) (*(addr)) = (val) # define outb(addr,val) (*(addr)) = (val)
# define inb(addr) (*(addr)) # define inb(addr) (*(addr))
#elif defined(__CBM510__) #elif defined(__CBM510__)
# define SCREEN1 0xF000 # define SCREEN1 0xF000
# define SCREEN2 0xF400 # define SCREEN2 0xF400
# define CHARSET 0xE000 # define CHARSET 0xE000
# define outb(addr,val) pokebsys ((unsigned)(addr), val) # define outb(addr,val) pokebsys ((unsigned)(addr), val)
# define inb(addr) peekbsys ((unsigned)(addr)) # define inb(addr) peekbsys ((unsigned)(addr))
#endif #endif
/* Values for the VIC address register to switch between the two pages */ /* Values for the VIC address register to switch between the two pages */
#define PAGE1 ((SCREEN1 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E) #define PAGE1 ((SCREEN1 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E)
#define PAGE2 ((SCREEN2 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E) #define PAGE2 ((SCREEN2 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E)
/* Use static local variables for speed */ /* Use static local variables for speed */
#pragma staticlocals (1); #pragma staticlocals (1);
static const unsigned char sinustable[0x100] = { static const unsigned char sinustable[0x100] = {
0x80, 0x7d, 0x7a, 0x77, 0x74, 0x70, 0x6d, 0x6a, 0x80, 0x7d, 0x7a, 0x77, 0x74, 0x70, 0x6d, 0x6a,
0x67, 0x64, 0x61, 0x5e, 0x5b, 0x58, 0x55, 0x52, 0x67, 0x64, 0x61, 0x5e, 0x5b, 0x58, 0x55, 0x52,
0x4f, 0x4d, 0x4a, 0x47, 0x44, 0x41, 0x3f, 0x3c, 0x4f, 0x4d, 0x4a, 0x47, 0x44, 0x41, 0x3f, 0x3c,
0x39, 0x37, 0x34, 0x32, 0x2f, 0x2d, 0x2b, 0x28, 0x39, 0x37, 0x34, 0x32, 0x2f, 0x2d, 0x2b, 0x28,
0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a, 0x18, 0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a, 0x18,
0x16, 0x15, 0x13, 0x11, 0x10, 0x0f, 0x0d, 0x0c, 0x16, 0x15, 0x13, 0x11, 0x10, 0x0f, 0x0d, 0x0c,
0x0b, 0x0a, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04, 0x0b, 0x0a, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0a, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0a,
0x0b, 0x0c, 0x0d, 0x0f, 0x10, 0x11, 0x13, 0x15, 0x0b, 0x0c, 0x0d, 0x0f, 0x10, 0x11, 0x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fb, 0xfc, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfa, 0xfb, 0xfc,
0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfd,
0xfd, 0xfc, 0xfb, 0xfa, 0xfa, 0xf9, 0xf8, 0xf6, 0xfd, 0xfc, 0xfb, 0xfa, 0xfa, 0xf9, 0xf8, 0xf6,
0xf5, 0xf4, 0xf3, 0xf1, 0xf0, 0xef, 0xed, 0xeb, 0xf5, 0xf4, 0xf3, 0xf1, 0xf0, 0xef, 0xed, 0xeb,
0xea, 0xe8, 0xe6, 0xe4, 0xe2, 0xe0, 0xde, 0xdc, 0xea, 0xe8, 0xe6, 0xe4, 0xe2, 0xe0, 0xde, 0xdc,
0xda, 0xd8, 0xd5, 0xd3, 0xd1, 0xce, 0xcc, 0xc9, 0xda, 0xd8, 0xd5, 0xd3, 0xd1, 0xce, 0xcc, 0xc9,
0xc7, 0xc4, 0xc1, 0xbf, 0xbc, 0xb9, 0xb6, 0xb3, 0xc7, 0xc4, 0xc1, 0xbf, 0xbc, 0xb9, 0xb6, 0xb3,
0xb1, 0xae, 0xab, 0xa8, 0xa5, 0xa2, 0x9f, 0x9c, 0xb1, 0xae, 0xab, 0xa8, 0xa5, 0xa2, 0x9f, 0x9c,
0x99, 0x96, 0x93, 0x90, 0x8c, 0x89, 0x86, 0x83 0x99, 0x96, 0x93, 0x90, 0x8c, 0x89, 0x86, 0x83
}; };
static unsigned char *scrn; static unsigned char *scrn;
static void doplasma (void) static void doplasma (void)
{ {
unsigned char xbuf[40]; unsigned char xbuf[40];
unsigned char ybuf[25]; unsigned char ybuf[25];
unsigned char i,ii; unsigned char i,ii;
unsigned char c1a,c1b; unsigned char c1a,c1b;
unsigned char c2a,c2b; unsigned char c2a,c2b;
unsigned char c1A,c1B; unsigned char c1A,c1B;
unsigned char c2A,c2B; unsigned char c2A,c2B;
c1a = c1A; c1a = c1A;
c1b = c1B; c1b = c1B;
for (ii = 0; ii < 25; ++ii) { for (ii = 0; ii < 25; ++ii) {
ybuf[ii] = (sinustable[c1a] + sinustable[c1b]); ybuf[ii] = (sinustable[c1a] + sinustable[c1b]);
c1a += 4; c1a += 4;
c1b += 9; c1b += 9;
} }
c1A += 3; c1A += 3;
c1B -= 5; c1B -= 5;
c2a = c2A; c2a = c2A;
c2b = c2B; c2b = c2B;
for (i = 0; i < 40; ++i) { for (i = 0; i < 40; ++i) {
xbuf[i] = (sinustable[c2a] + sinustable[c2b]); xbuf[i] = (sinustable[c2a] + sinustable[c2b]);
c2a += 3; c2a += 3;
c2b += 7; c2b += 7;
} }
c2A += 2; c2A += 2;
c2B -= 3; c2B -= 3;
for (ii = 0; ii < 25; ++ii) { for (ii = 0; ii < 25; ++ii) {
/* Unrolling the following loop will give a speed increase of /* Unrolling the following loop will give a speed increase of
* nearly 100% (~24fps), but it will also increase the code * nearly 100% (~24fps), but it will also increase the code
* size a lot. * size a lot.
*/ */
for (i = 0; i < 40; ++i, ++scrn) { for (i = 0; i < 40; ++i, ++scrn) {
*scrn = (xbuf[i] + ybuf[ii]); *scrn = (xbuf[i] + ybuf[ii]);
} }
} }
} }
static void makechar (void) static void makechar (void)
{ {
static const unsigned char bittab[8] = { static const unsigned char bittab[8] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
}; };
unsigned char i, ii, b, s; unsigned char i, ii, b, s;
unsigned c; unsigned c;
gotoxy (0, 1); gotoxy (0, 1);
for (c = 0; c < 0x100; ++c) { for (c = 0; c < 0x100; ++c) {
s = sinustable[c]; s = sinustable[c];
for (i = 0; i < 8; ++i){ for (i = 0; i < 8; ++i){
b = 0; b = 0;
for (ii = 0; ii < 8; ++ii) { for (ii = 0; ii < 8; ++ii) {
if ((rand() & 0xFF) > s) { if ((rand() & 0xFF) > s) {
b |= bittab[ii]; b |= bittab[ii];
} }
} }
((unsigned char*)CHARSET) [(c*8) + i] = b; ((unsigned char*)CHARSET) [(c*8) + i] = b;
} }
if ((c & 0x07) == 0) { if ((c & 0x07) == 0) {
cputc ('.'); cputc ('.');
} }
} }
} }
int main (void) int main (void)
{ {
unsigned char border; unsigned char border;
unsigned char background; unsigned char background;
unsigned char text; unsigned char text;
unsigned char v; unsigned char v;
clock_t t; clock_t t;
unsigned long f = 0; unsigned long f = 0;
unsigned long sec; unsigned long sec;
unsigned sec10; unsigned sec10;
unsigned long fps; unsigned long fps;
unsigned fps10; unsigned fps10;
clrscr (); clrscr ();
cprintf ("Making charset, mompls"); cprintf ("Making charset, mompls");
makechar(); makechar();
/* Set the border and background colors */ /* Set the border and background colors */
border = bordercolor (COLOR_BLUE); border = bordercolor (COLOR_BLUE);
background = bgcolor (COLOR_BLUE); background = bgcolor (COLOR_BLUE);
text = textcolor (COLOR_BLACK); text = textcolor (COLOR_BLACK);
clrscr (); clrscr ();
#if defined(__C64__) #if defined(__C64__)
/* Move the VIC 16K block */ /* Move the VIC 16K block */
outb (&CIA2.pra, 0x00); outb (&CIA2.pra, 0x00);
#endif #endif
/* Remember the VIC address register */ /* Remember the VIC address register */
v = inb (&VIC.addr); v = inb (&VIC.addr);
/* Run the demo until a key was hit */ /* Run the demo until a key was hit */
t = clock (); t = clock ();
while (!kbhit()) { while (!kbhit()) {
/* Build page 1, then make it visible */ /* Build page 1, then make it visible */
scrn = (unsigned char*)SCREEN1; scrn = (unsigned char*)SCREEN1;
doplasma(); doplasma();
outb (&VIC.addr, PAGE1); outb (&VIC.addr, PAGE1);
/* Build page 2, then make it visible */ /* Build page 2, then make it visible */
scrn = (unsigned char*)SCREEN2; scrn = (unsigned char*)SCREEN2;
doplasma(); doplasma();
outb (&VIC.addr, PAGE2); outb (&VIC.addr, PAGE2);
/* Count frames */ /* Count frames */
f += 2; f += 2;
}; };
t = clock() - t; t = clock() - t;
/* Switch back the VIC screen */ /* Switch back the VIC screen */
outb (&VIC.addr, v); outb (&VIC.addr, v);
#if defined(__C64__) #if defined(__C64__)
/* Move back the VIC 16K block */ /* Move back the VIC 16K block */
outb (&CIA2.pra, 0x03); outb (&CIA2.pra, 0x03);
#endif #endif
/* Fetch the character from the keyboard buffer and discard it */ /* Fetch the character from the keyboard buffer and discard it */
(void) cgetc(); (void) cgetc();
/* Reset screen colors */ /* Reset screen colors */
bordercolor (border); bordercolor (border);
bgcolor (background); bgcolor (background);
textcolor (text); textcolor (text);
clrscr(); clrscr();
/* Calculate stats */ /* Calculate stats */
sec = (t * 10) / CLK_TCK; sec = (t * 10) / CLK_TCK;
sec10 = sec % 10; sec10 = sec % 10;
sec /= 10; sec /= 10;
fps = (f * (CLK_TCK * 10)) / t; fps = (f * (CLK_TCK * 10)) / t;
fps10 = fps % 10; fps10 = fps % 10;
fps /= 10; fps /= 10;
/* Output stats */ /* Output stats */
gotoxy (0, 0); cprintf ("time : %lu.%us", sec, sec10); gotoxy (0, 0); cprintf ("time : %lu.%us", sec, sec10);
gotoxy (0, 1); cprintf ("frames: %lu", f); gotoxy (0, 1); cprintf ("frames: %lu", f);
gotoxy (0, 2); cprintf ("fps : %lu.%u", fps, fps10); gotoxy (0, 2); cprintf ("fps : %lu.%u", fps, fps10);
/* Wait for a key, then end */ /* Wait for a key, then end */
cputsxy (0, 4, "Press any key when done..."); cputsxy (0, 4, "Press any key when done...");
(void) cgetc (); (void) cgetc ();
/* Done */ /* Done */
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }