move samples that only work for a specific target into subdirs named the same as the target
This commit is contained in:
164
samples/cbm/Makefile
Normal file
164
samples/cbm/Makefile
Normal file
@@ -0,0 +1,164 @@
|
||||
|
||||
# Run 'make SYS=<target>'; or, set a SYS env.
|
||||
# var. to build for another target system.
|
||||
SYS ?= c64
|
||||
|
||||
# Just the usual way to find out if we're
|
||||
# using cmd.exe to execute make rules.
|
||||
ifneq ($(shell echo),)
|
||||
CMD_EXE = 1
|
||||
endif
|
||||
|
||||
ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
DEL = -del /f
|
||||
RMDIR = rmdir /s /q
|
||||
else
|
||||
NULLDEV = /dev/null
|
||||
DEL = $(RM)
|
||||
RMDIR = $(RM) -r
|
||||
endif
|
||||
|
||||
ifdef CC65_HOME
|
||||
AS = $(CC65_HOME)/bin/ca65
|
||||
CC = $(CC65_HOME)/bin/cc65
|
||||
CL = $(CC65_HOME)/bin/cl65
|
||||
LD = $(CC65_HOME)/bin/ld65
|
||||
SP = $(CC65_HOME)/bin/sp65
|
||||
else
|
||||
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
|
||||
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
|
||||
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
|
||||
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
|
||||
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
|
||||
endif
|
||||
|
||||
ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),)
|
||||
ifdef CC65_HOME
|
||||
TARGET_PATH = $(CC65_HOME)/target
|
||||
else
|
||||
TARGET_PATH := $(if $(wildcard ../target),../target,$(shell $(CL) --print-target-path))
|
||||
endif
|
||||
|
||||
# If TARGET_PATH contains spaces then it is presumed to contain escaped spaces. GNU make
|
||||
# has very limited support for paths containing spaces. $(wildcard) is the only function
|
||||
# that is aware of escaped spaces. However, $(wildcard) never returns paths with escaped
|
||||
# spaces !!! So if it e.g. finds 4 files in a path with 2 spaces then one ends up with a
|
||||
# return value consisting of 12 plain words :-((
|
||||
#
|
||||
# Fortunately we can work around that behaviour here because we know that the files we
|
||||
# are looking for have known extensions. So we can $(filter) the in our example above 12
|
||||
# words for file extensions so we come up with 4 path fragments. Then we remove those
|
||||
# path fragments with $(notdir) from the file names.
|
||||
#
|
||||
# So far so good. But here we want to process files from different paths in a single
|
||||
# recipe further down below and therefore want to prepend the paths to the files with
|
||||
# $(addprefix). However, $(foreach) isn't aware of escaped spaces (only $(wildcard) is).
|
||||
# Therefore, we need to replace the spaces with some other character temporarily in order
|
||||
# to have $(foreach) generate one invocation per file. We use the character '?' for that
|
||||
# purpose here, just because it is known to not be part of file names.
|
||||
#
|
||||
# Inside the recipe generated per file we then replace the '?' again with a space. As we
|
||||
# want to be compatible with cmd.exe for execution we're not using an escaped space but
|
||||
# rather double-quote the whole path.
|
||||
#
|
||||
# Note: The "strange" $(wildcard) further down below just serves the purpose to unescape
|
||||
# spaces for cmd.exe. This could have as well been done with another $(subst).
|
||||
|
||||
SUBST_TARGET_PATH := $(subst \$(SPACE),?,$(TARGET_PATH))
|
||||
|
||||
EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
|
||||
MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
|
||||
TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
|
||||
|
||||
EMD := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/emd/,$(notdir $(filter %.emd,$(EMD))))
|
||||
MOU := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/mou/,$(notdir $(filter %.mou,$(MOU))))
|
||||
TGI := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/tgi/,$(notdir $(filter %.tgi,$(TGI))))
|
||||
|
||||
# This one comes with the VICE emulator.
|
||||
# See http://vice-emu.sourceforge.net/
|
||||
C1541 ?= c1541
|
||||
endif
|
||||
|
||||
DISK_c64 = samples.d64
|
||||
|
||||
EXELIST_c64 = \
|
||||
fire \
|
||||
plasma \
|
||||
nachtm
|
||||
|
||||
EXELIST_c128 = \
|
||||
fire \
|
||||
plasma \
|
||||
nachtm
|
||||
|
||||
EXELIST_cbm510 = \
|
||||
fire \
|
||||
plasma \
|
||||
nachtm
|
||||
|
||||
EXELIST_cbm610 = \
|
||||
nachtm
|
||||
|
||||
EXELIST_plus4 = \
|
||||
plasma
|
||||
|
||||
EXELIST_c16 = \
|
||||
notavailable
|
||||
|
||||
EXELIST_pet = \
|
||||
notavailable
|
||||
|
||||
EXELIST_vic20 = \
|
||||
notavailable
|
||||
|
||||
ifneq ($(EXELIST_$(SYS)),)
|
||||
samples: $(EXELIST_$(SYS))
|
||||
else
|
||||
samples: notavailable
|
||||
endif
|
||||
|
||||
disk: $(DISK_$(SYS))
|
||||
|
||||
# empty target used to skip systems that will not work with any program in this dir
|
||||
notavailable:
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
@echo "info: cbm samples not available for" $(SYS)
|
||||
else
|
||||
# suppress the "nothing to be done for 'samples' message
|
||||
@echo > $(NULLDEV)
|
||||
endif
|
||||
|
||||
fire: fire.c
|
||||
$(CL) -t $(SYS) -O -o fire -m fire.map fire.c
|
||||
plasma: plasma.c
|
||||
$(CL) -t $(SYS) -O -o plasma -m plasma.map plasma.c
|
||||
nachtm: nachtm.c
|
||||
$(CL) -t $(SYS) -O -o nachtm -m nachtm.map nachtm.c
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Rule to make a CBM disk with all samples. Needs the c1541 program that comes
|
||||
# with the VICE emulator.
|
||||
|
||||
define D64_WRITE_PRG_recipe
|
||||
|
||||
$(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),p >$(NULLDEV)
|
||||
|
||||
endef # D64_WRITE_PRG_recipe
|
||||
|
||||
define D64_WRITE_SEQ_recipe
|
||||
|
||||
$(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),s >$(NULLDEV)
|
||||
|
||||
endef # D64_WRITE_SEQ_recipe
|
||||
|
||||
samples.d64: samples
|
||||
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
|
||||
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
|
||||
# $(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
|
||||
# $(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_SEQ_recipe))
|
||||
|
||||
clean:
|
||||
@$(DEL) $(EXELIST_$(SYS)) 2>$(NULLDEV)
|
||||
@$(DEL) *.map 2>$(NULLDEV)
|
||||
@$(DEL) $(DISK_$(SYS)) 2>$(NULLDEV)
|
||||
264
samples/cbm/fire.c
Normal file
264
samples/cbm/fire.c
Normal file
@@ -0,0 +1,264 @@
|
||||
/*****************************************************************************\
|
||||
** fire test program for cc65. **
|
||||
** **
|
||||
** (w)2002 by groepaz/hitmen **
|
||||
** **
|
||||
** Cleanup and porting by Ullrich von Bassewitz. **
|
||||
** 2004-06-08, Greg King **
|
||||
** **
|
||||
\*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* sync page-flipping to vertical blank */
|
||||
/* #define DOVSYNC */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* for memset */
|
||||
#include <time.h>
|
||||
#include <conio.h>
|
||||
#include <cbm.h>
|
||||
|
||||
|
||||
|
||||
#if defined(__C64__)
|
||||
# define BUFFER 0x0400
|
||||
# define SCREEN1 0xE000
|
||||
# define SCREEN2 0xE400
|
||||
# define CHARSET 0xE800
|
||||
# define COLORRAM 0xD800
|
||||
# define outb(addr,val) (*(addr) = (val))
|
||||
# define inb(addr) (*(addr))
|
||||
#elif defined(__C128__)
|
||||
# define BUFFER 0x0400
|
||||
# define SCREEN1 0xE000
|
||||
# define SCREEN2 0xE400
|
||||
# define CHARSET 0xE800
|
||||
# define COLORRAM 0xD800
|
||||
# define outb(addr,val) (*(addr) = (val))
|
||||
# define inb(addr) (*(addr))
|
||||
#elif defined(__CBM510__)
|
||||
# define BUFFER 0xF800
|
||||
# define SCREEN1 0xF000
|
||||
# define SCREEN2 0xF400
|
||||
# define CHARSET 0xE000
|
||||
# define COLORRAM 0xD400
|
||||
# define outb(addr,val) pokebsys ((unsigned)(addr), val)
|
||||
# define inb(addr) peekbsys ((unsigned)(addr))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Values for the VIC address register to switch between the two pages */
|
||||
#define PAGE1 ((SCREEN1 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E)
|
||||
#define PAGE2 ((SCREEN2 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E)
|
||||
|
||||
|
||||
|
||||
/* Use static local variables for speed */
|
||||
#pragma static-locals (1);
|
||||
|
||||
|
||||
|
||||
#ifdef DOVSYNC
|
||||
# define WAITVSYNC() waitvsync()
|
||||
#else
|
||||
# define WAITVSYNC()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void makechar (void)
|
||||
{
|
||||
static const unsigned char bittab[8] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
|
||||
};
|
||||
register char *font;
|
||||
register unsigned char i, ii, b, bc;
|
||||
unsigned char c;
|
||||
|
||||
gotoxy (0, 1);
|
||||
|
||||
for (font = (char*)CHARSET; font != (char*)(CHARSET+(1*8)); ++font) {
|
||||
*font = 0x00;
|
||||
}
|
||||
for (font = (char*)(CHARSET+(64*8)); font != (char*)(CHARSET+(256*8)); ++font) {
|
||||
*font = 0xff;
|
||||
}
|
||||
|
||||
|
||||
for (c = 0; c < 0x40; ++c) {
|
||||
bc = 0;
|
||||
for (i = 0; i < 8; i++){
|
||||
b = 0;
|
||||
for (ii = 0; ii < 8; ii++) {
|
||||
bc += c;
|
||||
if (bc > 0x3f) {
|
||||
bc = bc - 0x40;
|
||||
b += bittab[(ii + (i & 1)) & 0x7];
|
||||
}
|
||||
}
|
||||
((unsigned char*)CHARSET + (1 * 8)) [(c * 8) + i] = b;
|
||||
}
|
||||
if ((c & 0x07) == 0) {
|
||||
cputc ('.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void fire (unsigned screenbase)
|
||||
{
|
||||
register char* screen;
|
||||
register char* buffer;
|
||||
register char c;
|
||||
|
||||
screen = (char*) screenbase;
|
||||
buffer = (char*) BUFFER;
|
||||
|
||||
while (buffer != (char*) (BUFFER + (24 * 40))) {
|
||||
c = (buffer[40-1] + buffer[40-1] + buffer[40] + buffer[41]) / 4;
|
||||
if (c > 2) {
|
||||
c -= 3;
|
||||
}
|
||||
*screen = *buffer = c;
|
||||
++screen;
|
||||
++buffer;
|
||||
}
|
||||
|
||||
screen = (char*) (screenbase + (23 * 40));
|
||||
buffer = (char*) (BUFFER + (23 * 40));
|
||||
|
||||
for(; buffer != (char*)(BUFFER+(25*40)); ++screen, ++buffer) {
|
||||
*screen = *buffer = 0x30 + (inb (&SID.noise) >> 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned char border;
|
||||
unsigned char background;
|
||||
unsigned char text;
|
||||
unsigned char v;
|
||||
clock_t t;
|
||||
unsigned long f = 0;
|
||||
unsigned long sec;
|
||||
unsigned sec10;
|
||||
unsigned long fps;
|
||||
unsigned fps10;
|
||||
int i;
|
||||
|
||||
#if defined(__C64__)
|
||||
unsigned char block;
|
||||
#endif
|
||||
#if defined(__C128__)
|
||||
unsigned char block;
|
||||
unsigned char initflag;
|
||||
unsigned char graphflag;
|
||||
#endif
|
||||
|
||||
/* Noise on channel 3 for random numbers */
|
||||
outb (&SID.v3.freq, 0xffff);
|
||||
outb (&SID.v3.ctrl, 0x80);
|
||||
|
||||
clrscr ();
|
||||
cprintf ("Making charset, mompls");
|
||||
makechar ();
|
||||
|
||||
/* Set the border and background colors */
|
||||
border = bordercolor (COLOR_BLACK);
|
||||
background = bgcolor (COLOR_BLACK);
|
||||
text = textcolor (COLOR_BLACK);
|
||||
clrscr ();
|
||||
|
||||
for(i = 0; i != 0x400; i++) {
|
||||
*((char *)(i + BUFFER)) = 0;
|
||||
*((char *)(i + SCREEN1)) = 0;
|
||||
*((char *)(i + SCREEN2)) = 0;
|
||||
outb ((char*)(i + COLORRAM), COLOR_YELLOW);
|
||||
}
|
||||
|
||||
#if defined(__C64__) || defined(__C128__)
|
||||
/* Move the VIC 16K block */
|
||||
block = inb (&CIA2.pra);
|
||||
outb (&CIA2.pra, (block & 0xFC) | ((SCREEN1 >> 14) ^ 0x03));
|
||||
#endif
|
||||
#if defined(__C128__)
|
||||
/* Save and change some flags, so that kernal/basic interrupt handler will
|
||||
** not interfere with our routine.
|
||||
*/
|
||||
initflag = *(unsigned char*) 0xA04;
|
||||
*(unsigned char*) 0xA04 &= 0xFE;
|
||||
graphflag = *(unsigned char*) 0xD8;
|
||||
*(unsigned char*) 0xD8 = 0xFF;
|
||||
#endif
|
||||
|
||||
/* Remember the VIC address register */
|
||||
v = inb (&VIC.addr);
|
||||
|
||||
/* Run the demo until a key was hit */
|
||||
t = clock ();
|
||||
while (!kbhit()) {
|
||||
/* Build page 1, then make it visible */
|
||||
fire (SCREEN1);
|
||||
WAITVSYNC ();
|
||||
outb (&VIC.addr, PAGE1);
|
||||
|
||||
/* Build page 2, then make it visible */
|
||||
fire (SCREEN2);
|
||||
WAITVSYNC ();
|
||||
outb (&VIC.addr, PAGE2);
|
||||
|
||||
/* Count frames */
|
||||
f += 2;
|
||||
}
|
||||
t = clock() - t;
|
||||
|
||||
/* Switch back the VIC screen */
|
||||
outb (&VIC.addr, v);
|
||||
|
||||
#if defined(__C64__) || defined(__C128__)
|
||||
/* Move back the VIC 16K block */
|
||||
outb (&CIA2.pra, block);
|
||||
#endif
|
||||
#if defined(__C128__)
|
||||
/* Restore the flags */
|
||||
*(unsigned char*) 0xA04 = initflag;
|
||||
*(unsigned char*) 0xD8 = graphflag;
|
||||
#endif
|
||||
|
||||
/* Fetch the character from the keyboard buffer and discard it */
|
||||
(void) cgetc();
|
||||
|
||||
/* Reset screen colors */
|
||||
bordercolor (border);
|
||||
bgcolor (background);
|
||||
textcolor (text);
|
||||
clrscr ();
|
||||
|
||||
/* Calculate stats */
|
||||
sec = (t * 10) / CLK_TCK;
|
||||
sec10 = sec % 10;
|
||||
sec /= 10;
|
||||
fps = (f * (CLK_TCK * 10)) / t;
|
||||
fps10 = fps % 10;
|
||||
fps /= 10;
|
||||
|
||||
/* Output stats */
|
||||
gotoxy (0, 0); cprintf ("time : %lu.%us", sec, sec10);
|
||||
gotoxy (0, 1); cprintf ("frames: %lu", f);
|
||||
gotoxy (0, 2); cprintf ("fps : %lu.%u", fps, fps10);
|
||||
|
||||
/* Wait for a key, then end */
|
||||
cputsxy (0, 4, "Press any key when done...");
|
||||
(void) cgetc ();
|
||||
|
||||
/* Done */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1180
samples/cbm/nachtm.c
Normal file
1180
samples/cbm/nachtm.c
Normal file
File diff suppressed because it is too large
Load Diff
300
samples/cbm/plasma.c
Normal file
300
samples/cbm/plasma.c
Normal file
@@ -0,0 +1,300 @@
|
||||
/*****************************************************************************\
|
||||
** plasma test program for cc65. **
|
||||
** **
|
||||
** (w)2001 by groepaz **
|
||||
** **
|
||||
** Cleanup and porting by Ullrich von Bassewitz. **
|
||||
** **
|
||||
\*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <conio.h>
|
||||
#include <cc65.h>
|
||||
|
||||
|
||||
|
||||
#if defined(__C64__) || defined(__C128__)
|
||||
# define SCREEN1 0xE000
|
||||
# define SCREEN2 0xE400
|
||||
# define CHARSET 0xE800
|
||||
# define outb(addr,val) (*(addr)) = (val)
|
||||
# define inb(addr) (*(addr))
|
||||
#elif defined(__CBM510__)
|
||||
# define SCREEN1 0xF000
|
||||
# define SCREEN2 0xF400
|
||||
# define CHARSET 0xE000
|
||||
# define outb(addr,val) pokebsys ((unsigned)(addr), val)
|
||||
# define inb(addr) peekbsys ((unsigned)(addr))
|
||||
#elif defined(__PLUS4__)
|
||||
# define SCREEN1 0x6400
|
||||
# define SCREEN2 0x6C00
|
||||
# define CHARSET 0x7000
|
||||
# define outb(addr,val) (*(addr)) = (val)
|
||||
# define inb(addr) (*(addr))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Values for the VIC address register to switch between the two pages */
|
||||
#if defined(__PLUS4__)
|
||||
#define PAGE1 ((SCREEN1 >> 8) & 0xF8)
|
||||
#define PAGE2 ((SCREEN2 >> 8) & 0xF8)
|
||||
#define CHARADR ((CHARSET >> 8) & 0xFC)
|
||||
#else
|
||||
#define PAGE1 ((SCREEN1 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E)
|
||||
#define PAGE2 ((SCREEN2 >> 6) & 0xF0) | ((CHARSET >> 10) & 0x0E)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Use static local variables for speed */
|
||||
#pragma static-locals (1);
|
||||
|
||||
|
||||
static const unsigned char sinustable[0x100] = {
|
||||
0x80, 0x7d, 0x7a, 0x77, 0x74, 0x70, 0x6d, 0x6a,
|
||||
0x67, 0x64, 0x61, 0x5e, 0x5b, 0x58, 0x55, 0x52,
|
||||
0x4f, 0x4d, 0x4a, 0x47, 0x44, 0x41, 0x3f, 0x3c,
|
||||
0x39, 0x37, 0x34, 0x32, 0x2f, 0x2d, 0x2b, 0x28,
|
||||
0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a, 0x18,
|
||||
0x16, 0x15, 0x13, 0x11, 0x10, 0x0f, 0x0d, 0x0c,
|
||||
0x0b, 0x0a, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
|
||||
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
|
||||
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0a,
|
||||
0x0b, 0x0c, 0x0d, 0x0f, 0x10, 0x11, 0x13, 0x15,
|
||||
0x16, 0x18, 0x1a, 0x1c, 0x1e, 0x20, 0x22, 0x24,
|
||||
0x26, 0x28, 0x2b, 0x2d, 0x2f, 0x32, 0x34, 0x37,
|
||||
0x39, 0x3c, 0x3f, 0x41, 0x44, 0x47, 0x4a, 0x4d,
|
||||
0x4f, 0x52, 0x55, 0x58, 0x5b, 0x5e, 0x61, 0x64,
|
||||
0x67, 0x6a, 0x6d, 0x70, 0x74, 0x77, 0x7a, 0x7d,
|
||||
0x80, 0x83, 0x86, 0x89, 0x8c, 0x90, 0x93, 0x96,
|
||||
0x99, 0x9c, 0x9f, 0xa2, 0xa5, 0xa8, 0xab, 0xae,
|
||||
0xb1, 0xb3, 0xb6, 0xb9, 0xbc, 0xbf, 0xc1, 0xc4,
|
||||
0xc7, 0xc9, 0xcc, 0xce, 0xd1, 0xd3, 0xd5, 0xd8,
|
||||
0xda, 0xdc, 0xde, 0xe0, 0xe2, 0xe4, 0xe6, 0xe8,
|
||||
0xea, 0xeb, 0xed, 0xef, 0xf0, 0xf1, 0xf3, 0xf4,
|
||||
0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfa, 0xfb, 0xfc,
|
||||
0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfd,
|
||||
0xfd, 0xfc, 0xfb, 0xfa, 0xfa, 0xf9, 0xf8, 0xf6,
|
||||
0xf5, 0xf4, 0xf3, 0xf1, 0xf0, 0xef, 0xed, 0xeb,
|
||||
0xea, 0xe8, 0xe6, 0xe4, 0xe2, 0xe0, 0xde, 0xdc,
|
||||
0xda, 0xd8, 0xd5, 0xd3, 0xd1, 0xce, 0xcc, 0xc9,
|
||||
0xc7, 0xc4, 0xc1, 0xbf, 0xbc, 0xb9, 0xb6, 0xb3,
|
||||
0xb1, 0xae, 0xab, 0xa8, 0xa5, 0xa2, 0x9f, 0x9c,
|
||||
0x99, 0x96, 0x93, 0x90, 0x8c, 0x89, 0x86, 0x83
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void doplasma (register unsigned char* scrn)
|
||||
{
|
||||
unsigned char xbuf[40];
|
||||
unsigned char ybuf[25];
|
||||
unsigned char c1a,c1b;
|
||||
unsigned char c2a,c2b;
|
||||
unsigned char c1A,c1B;
|
||||
unsigned char c2A,c2B;
|
||||
register unsigned char i, ii;
|
||||
|
||||
c1a = c1A;
|
||||
c1b = c1B;
|
||||
for (ii = 0; ii < 25; ++ii) {
|
||||
ybuf[ii] = (sinustable[c1a] + sinustable[c1b]);
|
||||
c1a += 4;
|
||||
c1b += 9;
|
||||
}
|
||||
c1A += 3;
|
||||
c1B -= 5;
|
||||
c2a = c2A;
|
||||
c2b = c2B;
|
||||
for (i = 0; i < 40; ++i) {
|
||||
xbuf[i] = (sinustable[c2a] + sinustable[c2b]);
|
||||
c2a += 3;
|
||||
c2b += 7;
|
||||
}
|
||||
c2A += 2;
|
||||
c2B -= 3;
|
||||
for (ii = 0; ii < 25; ++ii) {
|
||||
/* Unrolling the following loop will give a speed increase of
|
||||
** nearly 100% (~24fps), but it will also increase the code
|
||||
** size a lot.
|
||||
*/
|
||||
for (i = 0; i < 40; ++i, ++scrn) {
|
||||
*scrn = (xbuf[i] + ybuf[ii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void makechar (void)
|
||||
{
|
||||
static const unsigned char bittab[8] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
|
||||
};
|
||||
unsigned char i, ii, b, s;
|
||||
unsigned c;
|
||||
|
||||
gotoxy (0, 1);
|
||||
for (c = 0; c < 0x100; ++c) {
|
||||
s = sinustable[c];
|
||||
for (i = 0; i < 8; ++i){
|
||||
b = 0;
|
||||
for (ii = 0; ii < 8; ++ii) {
|
||||
if ((rand() & 0xFFu) > s) {
|
||||
b |= bittab[ii];
|
||||
}
|
||||
}
|
||||
((unsigned char*)CHARSET) [(c*8) + i] = b;
|
||||
}
|
||||
if ((c & 0x07) == 0) {
|
||||
cputc ('.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned char border;
|
||||
unsigned char background;
|
||||
unsigned char text;
|
||||
unsigned char v;
|
||||
clock_t t;
|
||||
unsigned long f = 0;
|
||||
unsigned long sec;
|
||||
unsigned sec10;
|
||||
unsigned long fps;
|
||||
unsigned fps10;
|
||||
|
||||
|
||||
#if defined(__C64__)
|
||||
unsigned char block;
|
||||
#endif
|
||||
#if defined(__C128__)
|
||||
unsigned char block;
|
||||
unsigned char initflag;
|
||||
unsigned char graphflag;
|
||||
#endif
|
||||
#if defined(__PLUS4__)
|
||||
unsigned int i;
|
||||
unsigned char v2;
|
||||
#endif
|
||||
|
||||
clrscr ();
|
||||
cprintf ("Making charset, mompls");
|
||||
makechar();
|
||||
|
||||
/* Set the border and background colors */
|
||||
border = bordercolor (COLOR_BLUE);
|
||||
background = bgcolor (COLOR_BLUE);
|
||||
text = textcolor (COLOR_BLACK);
|
||||
clrscr ();
|
||||
|
||||
#if defined(__C64__) || defined(__C128__)
|
||||
/* Move the VIC 16K block */
|
||||
block = inb (&CIA2.pra);
|
||||
outb (&CIA2.pra, (block & 0xFC) | ((SCREEN1 >> 14) ^ 0x03));
|
||||
#endif
|
||||
#if defined(__C128__)
|
||||
/* Save and change some flags, so that kernal/basic interrupt handler will
|
||||
** not interfere with our routine.
|
||||
*/
|
||||
initflag = *(unsigned char*) 0xA04;
|
||||
*(unsigned char*) 0xA04 &= 0xFE;
|
||||
graphflag = *(unsigned char*) 0xD8;
|
||||
*(unsigned char*) 0xD8 = 0xFF;
|
||||
#endif
|
||||
|
||||
/* Remember the VIC address register */
|
||||
#if defined(__PLUS4__)
|
||||
v = inb (&TED.char_addr);
|
||||
v2 = inb (&TED.video_addr);
|
||||
#else
|
||||
v = inb (&VIC.addr);
|
||||
#endif
|
||||
|
||||
#if defined(__PLUS4__)
|
||||
for (i=0;i<1000;i++) {
|
||||
((unsigned char *) (SCREEN1-0x0400))[i] = 0;
|
||||
((unsigned char *) (SCREEN2-0x0400))[i] = 0;
|
||||
}
|
||||
outb (&TED.char_addr, CHARADR);
|
||||
#endif
|
||||
|
||||
/* Run the demo until a key was hit */
|
||||
t = clock ();
|
||||
while (!kbhit()) {
|
||||
/* Build page 1, then make it visible */
|
||||
doplasma ((unsigned char*)SCREEN1);
|
||||
#if defined(__PLUS4__)
|
||||
outb (&TED.video_addr, PAGE1);
|
||||
#else
|
||||
outb (&VIC.addr, PAGE1);
|
||||
#endif
|
||||
|
||||
/* Build page 2, then make it visible */
|
||||
doplasma ((unsigned char*)SCREEN2);
|
||||
#if defined(__PLUS4__)
|
||||
outb (&TED.video_addr, PAGE2);
|
||||
#else
|
||||
outb (&VIC.addr, PAGE2);
|
||||
#endif
|
||||
|
||||
/* Count frames */
|
||||
f += 2;
|
||||
}
|
||||
t = clock() - t;
|
||||
|
||||
/* Switch back the VIC screen */
|
||||
#if defined(__PLUS4__)
|
||||
outb (&TED.video_addr, v2);
|
||||
outb (&TED.char_addr, v);
|
||||
#else
|
||||
outb (&VIC.addr, v);
|
||||
#endif
|
||||
|
||||
#if defined(__C64__) || defined(__C128__)
|
||||
/* Move back the VIC 16K block */
|
||||
outb (&CIA2.pra, block);
|
||||
#endif
|
||||
#if defined(__C128__)
|
||||
/* Restore the flags */
|
||||
*(unsigned char*) 0xA04 = initflag;
|
||||
*(unsigned char*) 0xD8 = graphflag;
|
||||
#endif
|
||||
|
||||
/* Fetch the character from the keyboard buffer and discard it */
|
||||
(void) cgetc();
|
||||
|
||||
/* Reset screen colors */
|
||||
bordercolor (border);
|
||||
bgcolor (background);
|
||||
textcolor (text);
|
||||
clrscr ();
|
||||
|
||||
/* Calculate stats */
|
||||
sec = (t * 10) / CLK_TCK;
|
||||
sec10 = sec % 10;
|
||||
sec /= 10;
|
||||
fps = (f * (CLK_TCK * 10)) / t;
|
||||
fps10 = fps % 10;
|
||||
fps /= 10;
|
||||
|
||||
/* Output stats */
|
||||
gotoxy (0, 0); cprintf ("time : %lu.%us", sec, sec10);
|
||||
gotoxy (0, 1); cprintf ("frames: %lu", f);
|
||||
gotoxy (0, 2); cprintf ("fps : %lu.%u", fps, fps10);
|
||||
|
||||
if (doesclrscrafterexit ()) {
|
||||
cputsxy (0, 4, "Press any key when done...");
|
||||
(void) cgetc ();
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user