From 19e3bbbea31b6ce1bf3b319a70f204fe0b1a3806 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Tue, 14 Nov 2023 10:52:33 -0600 Subject: [PATCH] c64: updated examples --- presets/c64/helloc.c | 16 ++++++++++++++++ presets/c64/screen_ram.c | 29 +++++++++++++++++++++++++++++ src/platform/c64.ts | 12 +++++++----- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 presets/c64/helloc.c create mode 100644 presets/c64/screen_ram.c diff --git a/presets/c64/helloc.c b/presets/c64/helloc.c new file mode 100644 index 00000000..e0817d9c --- /dev/null +++ b/presets/c64/helloc.c @@ -0,0 +1,16 @@ + +#include +#include +#include +#include + +void main(void) { + clrscr(); // clear screen + puts("Hello World!\n"); // write message at cursor + chline(12); // horizontal line + bordercolor(COLOR_LIGHTBLUE); // set color to blue + bgcolor(COLOR_GREEN); // set background color + textcolor(COLOR_YELLOW); // set text color + puts("\nThis text is yellow!\n"); // write message + cgetc(); // wait for input +} diff --git a/presets/c64/screen_ram.c b/presets/c64/screen_ram.c new file mode 100644 index 00000000..1b3aa4aa --- /dev/null +++ b/presets/c64/screen_ram.c @@ -0,0 +1,29 @@ + +#include "common.h" +//#link "common.c" + +#include + +void main(void) { + unsigned int i; + + clrscr(); // clear the screen + + POKE(0x400, 'A'); // write to first byte of screen memory + POKE(0x400, 65); // character code for 'A' + POKE(0x400 + 40*24 + 39, 'Z'); // row 24, column 39 + + // fill with random characters + for (i=0; i<40*25; i++) + POKE(0x400 + i, 205 + (rand() & 1)); + + // set character set to uppercase + graphics characters + SET_VIC_BITMAP(0x1000); + + // set color map underlying characters + for (i=0; i<40*25; i++) + COLOR_RAM[i] = COLOR_GREEN; + + // infinite loop (avoid "ready" prompt) + while (1); +} diff --git a/src/platform/c64.ts b/src/platform/c64.ts index 0274d245..4e8481be 100644 --- a/src/platform/c64.ts +++ b/src/platform/c64.ts @@ -5,11 +5,8 @@ import { PLATFORMS } from "../common/emu"; import { BaseMAME6502Platform } from "../common/mameplatform"; const C64_PRESETS = [ - {id:'hello.dasm', name:'Hello World (ASM)'}, - {id:'23matches.c', name:'23 Matches'}, - {id:'tgidemo.c', name:'TGI Graphics Demo'}, - {id:'upandaway.c', name:'Up, Up and Away'}, - {id:'siegegame.c', name:'Siege Game'}, + {id:'helloc.c', name:'Hello World'}, + {id:'screen_ram.c', name:'Screen RAM'}, {id:'joymove.c', name:'Sprite Movement'}, {id:'sprite_collision.c', name:'Sprite Collision'}, {id:'scroll1.c', name:'Scrolling (Single Buffer)'}, @@ -34,6 +31,11 @@ const C64_PRESETS = [ {id:'test_border_sprites.c', name:'Sprites in the Borders'}, {id:'sprite_stretch.c', name:'Sprite Stretching'}, {id:'plasma.c', name:'Plasma Demo'}, + {id:'siegegame.c', name:'Siege Game'}, + {id:'23matches.c', name:'23 Matches'}, + {id:'tgidemo.c', name:'TGI Graphics Demo'}, + {id:'upandaway.c', name:'Up, Up and Away'}, + {id:'hello.dasm', name:'Hello World (DASM)'}, {id:'hello.wiz', name:'Hello Wiz (Wiz)'}, ];