implemented some Z80 and randseeding
This commit is contained in:
+12
-1
@@ -4,6 +4,7 @@ PROJNAME=scoundrel
|
||||
CFILES=scoundrel.c
|
||||
PBTDIR=platform-build-tools
|
||||
CCBUILD=cl65 --standard c89 -O -Os
|
||||
Z80BUILD=zcc
|
||||
BUILDDIR=build
|
||||
|
||||
$(PROJNAME): bdir
|
||||
@@ -48,7 +49,17 @@ pet: bdir
|
||||
plus4: bdir
|
||||
$(CCBUILD) -t plus4 -o $(BUILDDIR)/$(PROJNAME)-plus4.bin $(CFILES)
|
||||
|
||||
all: $(PROJNAME) a2 a2e atari8bit c64 c16 c128 pet plus4
|
||||
msx: bdir
|
||||
$(Z80BUILD) +msx -create-app -subtype=rom $(CFILES) -o $(PROJNAME)
|
||||
mv $(PROJNAME).rom $(BUILDDIR)/$(PROJNAME)-msx.rom
|
||||
rm -f $(PROJNAME) *.bin *.img
|
||||
|
||||
zxspec: bdir
|
||||
$(Z80BUILD) +zx -lndos -clib=ansi -pragma-define:ansicolumns=40 -create-app $(CFILES) -o $(PROJNAME)
|
||||
mv $(PROJNAME).tap $(BUILDDIR)/$(PROJNAME)-zxspec.tap
|
||||
rm $(PROJNAME)
|
||||
|
||||
all: $(PROJNAME) a2 a2e atari8bit c64 c16 c128 pet plus4 zxspec msx
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR) *.o
|
||||
|
||||
+30
-6
@@ -8,10 +8,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef __CC65__
|
||||
#if defined(__CC65__) || defined(__Z80__)
|
||||
#define RETRO_IMPL
|
||||
#endif
|
||||
#ifndef RETRO_IMPL
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
char scanchar() {
|
||||
char c;
|
||||
scanf(" %c", &c);
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef RETRO_IMPL
|
||||
void randomize() {
|
||||
int seed = 0, i, x, n = 6;
|
||||
printf("\nType %d characters: ", n);
|
||||
for(i=0;i<n;i++) {
|
||||
x = (int) scanchar();
|
||||
x ^= x << 7;
|
||||
x ^= x >> 9;
|
||||
x ^= x << 8;
|
||||
seed ^= x;
|
||||
}
|
||||
srand(seed);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* UI choices */
|
||||
#define CH1 0
|
||||
#define CH2 1
|
||||
@@ -51,7 +76,7 @@ void print_msg(char *s) {
|
||||
char get_choice() {
|
||||
char c, res;
|
||||
printf("Your choice: ");
|
||||
scanf(" %c", &c);
|
||||
c = scanchar();
|
||||
switch(c) {
|
||||
case 'a':
|
||||
case 'A':
|
||||
@@ -88,8 +113,7 @@ char get_choice() {
|
||||
int confirm(char *prompt) {
|
||||
char c, d;
|
||||
printf("%s", prompt);
|
||||
c = getchar();
|
||||
scanf(" %c", &c);
|
||||
c = scanchar();
|
||||
if(c == 'y' || c == 'Y') d = 1;
|
||||
else d = 0;
|
||||
printf("\n");
|
||||
@@ -322,8 +346,8 @@ int game() {
|
||||
/* Entry point */
|
||||
int main() {
|
||||
int score;
|
||||
#ifdef __CC65__
|
||||
_randomize();
|
||||
#ifdef RETRO_IMPL
|
||||
randomize();
|
||||
#else
|
||||
srand(time(NULL));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user