initial commit

This commit is contained in:
2026-07-18 20:34:55 +02:00
commit 59ad004c96
474 changed files with 226635 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
../../bin/oscar64 diskdir.c
../../bin/oscar64 filewrite.c
../../bin/oscar64 fileread.c
../../bin/oscar64 charwrite.c
../../bin/oscar64 charread.c
../../bin/oscar64 hireswrite.c
../../bin/oscar64 hiresread.c
+28
View File
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <c64/kernalio.h>
int main(void)
{
// Set name for file and open it on drive 9
krnio_setnam("@0:CHARS,P,R");
if (krnio_open(2, 9, 2))
{
// Read bytes until failure
int ch, k = 0;
while ((ch = krnio_getch(2)) >= 0)
{
// Print the value of the byte
printf("%d : %d\n", k, ch);
k++;
// Exit the loop if this was the last byte of the file
if (ch & 0x100)
break;
}
// Close the file
krnio_close(2);
}
return 0;
}
+22
View File
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <c64/kernalio.h>
int main(void)
{
// Set name for file and open it with replace on drive 9
krnio_setnam("@0:CHARS,P,W");
if (krnio_open(2, 9, 2))
{
// Write 128 bytes to the file, it would be more efficient
// to set the output channel with krnio_chkout() for the file and
// write the bytes using krnio_chrout()
for(char i=0; i<128; i++)
krnio_putch(2, i);
// Close the file again
krnio_close(2);
}
return 0;
}
+64
View File
@@ -0,0 +1,64 @@
#include <stdio.h>
#include <c64/kernalio.h>
int main(void)
{
// Set name for directory
krnio_setnam("$");
// Open #2 on drive 9 (or 8)
if (krnio_open(2, 9, 0))
{
// Switch input to file #2
if (krnio_chkin(2))
{
// Skip BASIC load address
krnio_chrin();
krnio_chrin();
// Loop while we have more lines
int ch;
while((ch = krnio_chrin()) > 0)
{
unsigned line;
char buff[40];
// Skip second basic link byte
krnio_chrin();
// Read line number (size in blocks)
ch = krnio_chrin();
line = ch;
ch = krnio_chrin();
line += 256 * ch;
// Read file name, reading till end of basic line
int n = 0;
while ((ch = krnio_chrin()) > 0)
buff[n++] = ch;
buff[n] = 0;
// Print size and name
printf("%u %s\n", line, buff);
}
// Reset channels
krnio_clrchn();
}
// Close file #2
krnio_close(2);
}
else
printf("FAIL OPEN %d\n", krnio_status());
return 0;
}
+32
View File
@@ -0,0 +1,32 @@
#include <stdio.h>
#include <c64/kernalio.h>
struct Score
{
char name[5];
unsigned score;
};
Score score[4];
int main(void)
{
// Set name for file and open it on drive 9
krnio_setnam("HIGHSCORE,P,R");
if (krnio_open(2, 9, 2))
{
// Read the content of the file into the score arrayx
krnio_read(2, (char*)score, sizeof(score));
// Close the file
krnio_close(2);
}
// Print the result to stdout
for(int i=0; i<4; i++)
{
printf("%s : %u\n", score[i].name, score[i].score);
}
return 0;
}
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <c64/kernalio.h>
struct Score
{
char name[5];
unsigned score;
};
Score score[] = {
{"AAA", 10000},
{"BBB", 9000},
{"CCC", 8000},
{"DDD", 4000}
};
int main(void)
{
// Set name for file and open it with replace on drive 9
krnio_setnam("@0:HIGHSCORE,P,W");
if (krnio_open(2, 9, 2))
{
// Fill the file with the score array
krnio_write(2, (char*)score, sizeof(score));
// Close the file
krnio_close(2);
}
return 0;
}
+53
View File
@@ -0,0 +1,53 @@
#include <c64/kernalio.h>
#include <c64/memmap.h>
#include <c64/vic.h>
#include <c64/flossiec.h>
#include <gfx/bitmap.h>
#include <string.h>
#include <stdio.h>
char * const Hires = (char *)0xe000;
char * const Color = (char *)0xd800;
char * const Screen = (char *)0xcc00;
int main(void)
{
// Prepare fast loader in floppy memory
flosskio_init(8);
// Map filenames to track/sector addresses
floss_blk blks[1];
flosskio_mapdir(p"blumba2", blks);
// Clear screen
memset(Hires, 0x00, 8000);
memset(Screen, 0xff, 1000);
memset(Color, 0x01, 1000);
// Switch to multicolor hires
vic_setmode(VICM_HIRES_MC, Screen, Hires);
vic.color_back = VCOL_BLACK;
vic.color_border = VCOL_BLACK;
// Open file
flosskio_open(blks[0].track, blks[0].sector);
// Read compressed image
flossiec_read_lzo(Hires, 8000);
flossiec_read_lzo(Screen, 1000);
flossiec_read_lzo(Color, 1000);
// Close file
flosskio_close();
// Remove drive code
flosskio_shutdown();
// Wait for a character
getchar();
// Restore VIC
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
return 0;
}
+52
View File
@@ -0,0 +1,52 @@
#include <c64/kernalio.h>
#include <c64/memmap.h>
#include <c64/vic.h>
#include <gfx/bitmap.h>
#include <string.h>
#include <stdio.h>
Bitmap Screen;
#define ScreenMem ((char *)0xe000)
#define ColorMem ((char *)0xd000)
int main(void)
{
// Install the IRQ trampoline
mmap_trampoline();
// Initialize the display bitmap
bm_init(&Screen, ScreenMem, 40, 25);
// Clear the color memory with ROM and IO disabled
mmap_set(MMAP_RAM);
memset(ScreenMem, 0, 8000);
memset(ColorMem, 0x70, 1000);
mmap_set(MMAP_NO_ROM);
// Switch VIC to hires mode
vic_setmode(VICM_HIRES, ColorMem, ScreenMem);
// Reenable the kernal rom
mmap_set(MMAP_ROM);
// Set name for file and open it with replace on drive 9
krnio_setnam("TESTIMAGE,P,R");
if (krnio_open(2, 9, 2))
{
// Read the bitmap image in one go
krnio_read(2, ScreenMem, 8000);
// Close the file
krnio_close(2);
}
// Wait for a character
getchar();
// Restore VIC
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
return 0;
}
+80
View File
@@ -0,0 +1,80 @@
#include <c64/kernalio.h>
#include <c64/memmap.h>
#include <c64/vic.h>
#include <gfx/bitmap.h>
#include <string.h>
#include <stdio.h>
Bitmap Screen, Brush;
char Buffer[200];
#define ScreenMem ((char *)0xe000)
#define ColorMem ((char *)0xd000)
int main(void)
{
// Install the IRQ trampoline
mmap_trampoline();
// Initialize the display bitmap and a brush
bm_init(&Screen, ScreenMem, 40, 25);
bm_alloc(&Brush, 2, 2);
// Clear the color memory with ROM and IO disabled
mmap_set(MMAP_RAM);
memset(ScreenMem, 0, 8000);
memset(ColorMem, 0x70, 1000);
mmap_set(MMAP_NO_ROM);
// Switch VIC to hires mode
vic_setmode(VICM_HIRES, ColorMem, ScreenMem);
// Draw the brush
ClipRect crb = {0, 0, 16, 16};
bm_fill(&Brush, 0);
bm_circle_fill(&Brush, &crb, 7, 7, 6, NineShadesOfGrey[8]);
// Draw the main image
ClipRect crr = {0, 0, 320, 200};
bm_circle_fill(&Screen, &crr, 160, 100, 90, NineShadesOfGrey[8]);
bm_circle_fill(&Screen, &crr, 120, 80, 20, NineShadesOfGrey[0]);
bm_circle_fill(&Screen, &crr, 200, 80, 20, NineShadesOfGrey[0]);
// And a smile
for(int x=-40; x<=40; x+=4)
{
int y = bm_usqrt(50 * 50 - x * x);
bm_bitblit(&Screen, &crr, 160 - 7 + x, 100 + y, &Brush, 0, 0, 15, 15, nullptr, BLTOP_AND_NOT);
}
// Reenable the kernal rom
mmap_set(MMAP_ROM);
// Set name for file and open it with replace on drive 9
krnio_setnam("@0:TESTIMAGE,P,W");
if (krnio_open(2, 9, 2))
{
// Loop in chunks of 200 bytes
for(int i=0; i<8000; i+=200)
{
// Disable ROM
mmap_set(MMAP_NO_ROM);
// Copy chunk into buffer
memcpy(Buffer, ScreenMem + i, 200);
// Reeable the ROM
mmap_set(MMAP_ROM);
// Write the chunk to disk
krnio_write(2, Buffer, 200);
}
// Close the file
krnio_close(2);
}
// Restore the VIC
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
return 0;
}
+8
View File
@@ -0,0 +1,8 @@
call ..\..\bin\oscar64 diskdir.c
call ..\..\bin\oscar64 filewrite.c
call ..\..\bin\oscar64 fileread.c
call ..\..\bin\oscar64 charwrite.c
call ..\..\bin\oscar64 charread.c
call ..\..\bin\oscar64 hireswrite.c
call ..\..\bin\oscar64 hiresread.c
call ..\..\bin\oscar64 hiresfload.c -d64=hiresfload.d64 -fz=../resources/blumba2.bin
+8
View File
@@ -0,0 +1,8 @@
%.prg: %.c
@echo "Compiling sample file" $<
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $<
all: diskdir.prg filewrite.prg fileread.prg charwrite.prg charread.prg hireswrite.prg hiresread.prg
clean:
@$(RM) *.asm *.int *.lbl *.map *.prg *.bcs