More samples

This commit is contained in:
drmortalwombat 2021-12-25 20:55:15 +01:00
parent a1db507816
commit f91bf21999
8 changed files with 318 additions and 0 deletions

View File

@ -1250,6 +1250,14 @@ void Scanner::Error(const char* error)
{
mErrors->Error(mLocation, EERR_SYNTAX, error);
}
static char p2smap[] = { 0x00, 0x20, 0x00, 0x40, 0x00, 0x60, 0x40, 0x60 };
static inline char p2s(char ch)
{
return (ch & 0x1f) | p2smap[ch >> 5];
}
void Scanner::StringToken(char terminator, char mode)
{
@ -1326,6 +1334,20 @@ void Scanner::StringToken(char terminator, char mode)
mTokenString[i] = (mTokenString[i] ^ 0x20) & 0xdf;
}
break;
case 's':
for (int i = 0; i < n; i++)
{
if (mTokenString[i] >= 'A' && mTokenString[i] <= 'Z' || mTokenString[i] >= 'a' && mTokenString[i] <= 'z')
mTokenString[i] = p2s(mTokenString[i] ^ 0x20);
}
break;
case 'S':
for (int i = 0; i < n; i++)
{
if (mTokenString[i] >= 'A' && mTokenString[i] <= 'Z' || mTokenString[i] >= 'a' && mTokenString[i] <= 'z')
mTokenString[i] = p2s((mTokenString[i] ^ 0x20) & 0xdf);
}
break;
default:
Error("Invalid string literal mode");
}

View File

@ -0,0 +1,4 @@
..\..\bin\oscar64 mbtext.c -n
..\..\bin\oscar64 mbhires.c -n
..\..\bin\oscar64 mbmulti.c -n

View File

@ -0,0 +1,45 @@
#include <string.h>
#include <c64/vic.h>
#include <c64/memmap.h>
#define Screen ((char *)0xe000)
#define Color ((char *)0xc800)
int main(void)
{
mmap_trampoline();
mmap_set(MMAP_NO_ROM);
vic_setmode(VICM_HIRES, Color, Screen);
memset(Screen, 0, 8000);
memset(Color, 0x10, 1000);
int py, px;
for(py=0; py<200; py++)
{
for(px=0; px<320; px++)
{
float xz = (float)px * (3.5 / 320.0)- 2.5;
float yz = (float)py * (2.0 / 200.0) - 1.0;
float x = 0.0, y = 0.0;
int i;
for(i=0; i<32; i++)
{
if (x * x + y * y > 4.0) break;
float xt = x * x - y * y + xz;
y = 2 * x * y + yz;
x = xt;
}
if (i < 32)
Screen[320 * (py >> 3) + (py & 7) + (px & ~7)] |= 0x80 >> (px & 7);
}
}
return 0;
}

View File

@ -0,0 +1,75 @@
#include <string.h>
#include <c64/vic.h>
#include <c64/memmap.h>
#include <conio.h>
#define Screen ((char *)0xe000)
#define Color ((char *)0xc800)
#define Color2 ((char *)0xd800)
char colors[] = {
0xff, 0xff,
0xee, 0xbb,
0xaa, 0xaa,
0x88, 0x22,
0x44, 0x11,
0x55, 0x55,
0xdd, 0x77,
0x33, 0xcc
};
int main(void)
{
mmap_trampoline();
mmap_set(MMAP_NO_ROM);
vic_setmode(VICM_HIRES_MC, Color, Screen);
vic.color_back = 0x00;
memset(Screen, 0, 8000);
memset(Color, 0x27, 1000);
memset(Color2, 0x03, 1000);
int py, px;
for(py=0; py<100; py++)
{
for(px=0; px<160; px++)
{
float xz = (float)px * (3.5 / 160.0)- 2.5;
float yz = (float)py * (2.4 / 100.0) - 1.2;
float x = 0.0, y = 0.0;
int i;
for(i=0; i<32; i++)
{
if (x * x + y * y > 4.0) break;
float xt = x * x - y * y + xz;
y = 2 * x * y + yz;
x = xt;
}
if (i < 32)
{
char * dp = Screen + 320 * (py >> 2) + 2 * (py & 3) + 2 * (px & ~3);
char mask = 0xc0 >> (2 * (px & 3));
char c0 = colors[2 * (i & 7)], c1 = colors[2 * (i & 7) + 1];
dp[0] |= c0 & mask;
dp[1] |= c1 & mask;
}
}
}
mmap_set(MMAP_NO_BASIC);
getch();
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
return 0;
}

36
samples/fractals/mbtext.c Normal file
View File

@ -0,0 +1,36 @@
#include <string.h>
#define Screen ((char *)0x0400)
#define Color ((char *)0xd800)
int main(void)
{
memset(Screen, 160, 1024);
int py, px;
for(py=0; py<25; py++)
{
for(px=0; px<40; px++)
{
float xz = (float)px * (3.5 / 40.0)- 2.5;
float yz = (float)py * (2.0 / 25.0) - 1.0;
float x = 0.0, y = 0.0;
int i;
for(i=0; i<=14; i++)
{
if (x * x + y * y > 4.0) break;
float xt = x * x - y * y + xz;
y = 2 * x * y + yz;
x = xt;
}
i--;
Color[py * 40 + px] = i;
}
}
return 0;
}

View File

@ -1,2 +1,4 @@
..\..\bin\oscar64 colorbars.c
..\..\bin\oscar64 openborder.c
..\..\bin\oscar64 textcrawler.c
..\..\bin\oscar64 movingbars.c -n

View File

@ -0,0 +1,92 @@
#include <c64/vic.h>
#include <c64/rasterirq.h>
#include <string.h>
#include <math.h>
#include <conio.h>
RIRQCode ftop, fbottom, btop, bbottom, final ;
char sintab[256];
int main(void)
{
rirq_init(true);
rirq_build(&ftop, 3);
rirq_delay(&ftop, 10);
rirq_write(&ftop, 1, &vic.color_back, 2);
rirq_write(&ftop, 2, &vic.color_border, 2);
rirq_build(&fbottom, 3);
rirq_delay(&fbottom, 10);
rirq_write(&fbottom, 1, &vic.color_back, 6);
rirq_write(&fbottom, 2, &vic.color_border, 14);
rirq_build(&btop, 3);
rirq_delay(&btop, 10);
rirq_write(&btop, 1, &vic.color_back, 7);
rirq_write(&btop, 2, &vic.color_border, 7);
rirq_build(&bbottom, 3);
rirq_delay(&bbottom, 10);
rirq_write(&bbottom, 1, &vic.color_back, 6);
rirq_write(&bbottom, 2, &vic.color_border, 14);
rirq_build(&final, 0);
char yfront = 100, yback = 200;
rirq_set(0, yfront, &ftop);
rirq_set(1, yfront + 16, &fbottom);
rirq_set(2, yback, &btop);
rirq_set(3, yback + 16, &bbottom);
rirq_set(4, 250, &final);
rirq_sort();
rirq_start();
for(int i=0; i<32; i++)
sintab[i] = (int)(120 + 60 * sin(i * PI / 16)) | 1;
char fi = 3, bi = 0;
for(;;)
{
yfront = sintab[fi & 31];
yback = sintab[bi & 31];
rirq_move(0, yfront);
if (yback == yfront)
{
rirq_move(1, yfront + 16);
rirq_clear(2);
rirq_clear(3);
}
else
{
if (yback < yfront || yback > yfront + 16)
{
rirq_move(1, yfront + 16);
rirq_move(2, yback);
}
else
{
rirq_clear(1);
rirq_move(2, yfront + 16);
}
if (yback < yfront - 16 || yback > yfront)
rirq_move(3, yback + 16);
else
rirq_clear(3);
}
rirq_sort();
rirq_wait();
fi ++;
bi ++;
}
return 0;
}

View File

@ -0,0 +1,42 @@
#include <c64/vic.h>
#include <c64/rasterirq.h>
#include <string.h>
const char * Text =
S"LABORUM RERUM QUO. QUASI IN, SEQUI, TENETUR VOLUPTATEM RERUM "
S"PORRO NON ET MAIORES ALIAS ODIO EST EOS. MAGNAM APERIAM CUM ET "
S"ESSE TEMPORE ITAQUE TEMPORA VOLUPTAS ET IPSAM IPSAM EARUM. ID "
S"SUSCIPIT QUIA RERUM REPREHENDERIT ERROR ET UT. DOLOR ID "
S"CORPORIS, EOS? UNDE VERO ISTE QUIA? EAQUE EAQUE. IN. AUT ID "
S"EXPEDITA ILLUM MOLESTIAS, ";
RIRQCode scroll, bottom;
int main(void)
{
rirq_init(true);
rirq_build(&scroll, 1);
rirq_write(&scroll, 0, &vic.ctrl2, 0);
rirq_set(0, 50 + 24 * 8, &scroll);
rirq_build(&bottom, 1);
rirq_write(&bottom, 0, &vic.ctrl2, VIC_CTRL2_CSEL);
rirq_set(1, 250, &bottom);
rirq_sort();
rirq_start();
int x = 0;
for(;;)
{
rirq_wait();
rirq_data(&scroll, 0, 7 - (x & 7));
if ((x & 7) == 0)
memcpy((char *)0x0400 + 40 * 24, Text + ((x >> 3) & 255), 40);
x++;
}
return 0;
}