This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches. git-svn-id: svn://svn.cc65.org/cc65/trunk@3 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
7
samples/.cvsignore
Normal file
7
samples/.cvsignore
Normal file
@@ -0,0 +1,7 @@
|
||||
nachtm
|
||||
hello
|
||||
sieve
|
||||
*.map
|
||||
*.d64
|
||||
*.s
|
||||
*.lbl
|
||||
54
samples/Makefile
Normal file
54
samples/Makefile
Normal file
@@ -0,0 +1,54 @@
|
||||
#
|
||||
# Makefile for cc65 samples
|
||||
#
|
||||
|
||||
# Enter the target system here
|
||||
SYS = c64
|
||||
|
||||
CRT0 = ../lib/$(SYS).o
|
||||
CLIB = ../lib/$(SYS).lib
|
||||
CC = ../cc65/cc65
|
||||
CL = ../cl65/cl65
|
||||
AS = ../binutils/ca65/ca65
|
||||
LD = ../binutils/ld65/ld65
|
||||
C1541 = c1541
|
||||
|
||||
|
||||
.c.o:
|
||||
@echo $<
|
||||
@$(CL) -c -Oirs -t $(SYS) -I../include/ $<
|
||||
|
||||
.s.o:
|
||||
@echo $<
|
||||
@$(CL) -c $(basename $<).s
|
||||
|
||||
|
||||
.PHONY: all
|
||||
all: nachtm hello sieve
|
||||
|
||||
nachtm: $(CRT0) nachtm.o $(CLIB)
|
||||
@$(LD) -t $(SYS) -m nachtm.map -Ln nachtm.lbl -o $@ $^
|
||||
|
||||
hello: $(CRT0) hello.o $(CLIB)
|
||||
@$(LD) -t $(SYS) -m hello.map -Ln hello.lbl -o $@ $^
|
||||
|
||||
sieve: $(CRT0) sieve.o $(CLIB)
|
||||
@$(LD) -t $(SYS) -m sieve.map -Ln sieve.lbl -o $@ $^
|
||||
|
||||
.PHONY: disk
|
||||
disk: c64.d64
|
||||
|
||||
c64.d64: all
|
||||
$(C1541) < c1541.rsp
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f *~ *.map *.o *.s *.lbl
|
||||
|
||||
.PHONY: zap
|
||||
zap: clean
|
||||
rm -f nachtm hello
|
||||
|
||||
|
||||
|
||||
|
||||
9
samples/c1541.rsp
Normal file
9
samples/c1541.rsp
Normal file
@@ -0,0 +1,9 @@
|
||||
att c64.d64
|
||||
|
||||
delete nachtm
|
||||
delete hello
|
||||
write nachtm
|
||||
write hello
|
||||
quit
|
||||
|
||||
|
||||
82
samples/hello.c
Normal file
82
samples/hello.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Fancy hello world program using cc65.
|
||||
*
|
||||
* Ullrich von Bassewitz (ullrich@von-bassewitz.de)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <conio.h>
|
||||
#include <dbg.h>
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
static const char Text [] = "Hello world!";
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned char XSize, YSize;
|
||||
|
||||
/* Set screen colors, hide the cursor */
|
||||
textcolor (COLOR_WHITE);
|
||||
bordercolor (COLOR_BLACK);
|
||||
bgcolor (COLOR_BLACK);
|
||||
cursor (0);
|
||||
|
||||
/* Clear the screen, put cursor in upper left corner */
|
||||
clrscr ();
|
||||
|
||||
/* Ask for the screen size */
|
||||
screensize (&XSize, &YSize);
|
||||
|
||||
/* Draw a border around the screen */
|
||||
|
||||
/* Top line */
|
||||
cputc (CH_ULCORNER);
|
||||
chline (XSize - 2);
|
||||
cputc (CH_URCORNER);
|
||||
|
||||
/* Vertical line, left side */
|
||||
cvlinexy (0, 1, YSize - 2);
|
||||
|
||||
/* Bottom line */
|
||||
cputc (CH_LLCORNER);
|
||||
chline (XSize - 2);
|
||||
cputc (CH_LRCORNER);
|
||||
|
||||
/* Vertical line, right side */
|
||||
cvlinexy (XSize - 1, 1, YSize - 2);
|
||||
|
||||
/* Write the greeting in the mid of the screen */
|
||||
gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
|
||||
cprintf ("%s", Text);
|
||||
|
||||
/* Wait for the user to press a key */
|
||||
(void) cgetc ();
|
||||
|
||||
/* Clear the screen again */
|
||||
clrscr ();
|
||||
|
||||
/* Done */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1185
samples/nachtm.c
Normal file
1185
samples/nachtm.c
Normal file
File diff suppressed because it is too large
Load Diff
67
samples/sieve.c
Normal file
67
samples/sieve.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Calculate all primes up to a specific number.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#define COUNT 8192 /* Up to what number? */
|
||||
#define SQRT_COUNT 91 /* Sqrt of COUNT */
|
||||
|
||||
static unsigned char Sieve[COUNT];
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
/* This is an example where register variables make sense */
|
||||
register unsigned char* S;
|
||||
register unsigned I;
|
||||
register unsigned J;
|
||||
|
||||
/* Execute the sieve */
|
||||
I = 2;
|
||||
while (I < SQRT_COUNT) {
|
||||
if (Sieve[I] == 0) {
|
||||
/* Prime number - mark multiples */
|
||||
S = &Sieve[J = I*2];
|
||||
while (J < COUNT) {
|
||||
*S = 1;
|
||||
S += I;
|
||||
J += I;
|
||||
}
|
||||
}
|
||||
++I;
|
||||
}
|
||||
|
||||
/* Print the result */
|
||||
for (I = 2; I < COUNT; ++I) {
|
||||
if (Sieve[I] == 0) {
|
||||
printf ("%4d\n", I);
|
||||
}
|
||||
if (kbhit() && cgetc() == 'q') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user