add CBM balloon demo

This commit is contained in:
nino-porcino 2021-12-23 15:37:01 +01:00
parent 5e1618b4de
commit 9572291866
4 changed files with 244 additions and 3 deletions

View File

@ -0,0 +1,65 @@
// file generated automatically by mkfont.js -- do not edit
0b00001111,
0b00111111,
0b01111111,
0b01111100,
0b11111011,
0b11111011,
0b11111011,
0b01111100,
0b01111111,
0b01111111,
0b01011111,
0b00101111,
0b00100111,
0b00010011,
0b00010011,
0b00001001,
0b11100000,
0b11111000,
0b11111100,
0b11111100,
0b00111110,
0b11111110,
0b00111110,
0b11111100,
0b11111100,
0b11111100,
0b11110100,
0b11101000,
0b11001000,
0b10010000,
0b10010000,
0b00100000,
0b00001001,
0b00000111,
0b00000111,
0b00000111,
0b00000011,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00100000,
0b11000000,
0b11000000,
0b11000000,
0b10000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,

7
demos/demo/cbm_balloon.h Normal file
View File

@ -0,0 +1,7 @@
// file generated automatically by mkfont.js -- do not edit
const byte cbm_balloon[] = {
#include "cbm_balloon.data.h"
};

View File

@ -1,5 +1,21 @@
#include <font8x8.h> #include <font8x8.h>
#include "cbm_balloon.h"
void move_balloon(byte x, byte y, byte color) {
tms_sprite spr0,spr1;
spr0.x = x;
spr0.y = y;
spr0.name = 0;
spr0.color = color;
spr1.x = spr0.x;
spr1.y = spr0.y + 32;
spr1.name = spr0.name + 4;
spr1.color = spr0.color;
tms_set_sprite(0, &spr0);
tms_set_sprite(1, &spr1);
}
void demo_screen2() { void demo_screen2() {
tms_init_regs(SCREEN2_TABLE); tms_init_regs(SCREEN2_TABLE);
@ -30,6 +46,7 @@ void demo_screen2() {
screen2_plot_mode = PLOT_MODE_SET; screen2_plot_mode = PLOT_MODE_SET;
/*
// define sprites using bitmap fonts // define sprites using bitmap fonts
tms_copy_to_vram(&FONT[64*8], 32*8, TMS_SPRITE_PATTERNS); tms_copy_to_vram(&FONT[64*8], 32*8, TMS_SPRITE_PATTERNS);
@ -40,11 +57,43 @@ void demo_screen2() {
tms_set_sprite_magnification(1); tms_set_sprite_magnification(1);
tms_sprite spr; tms_sprite spr;
for(byte t=0;t<32;t++) { for(byte t=0;t<4;t++) {
spr.x = 10 + t*32; spr.x = 200;
spr.y = 5 + t*32; spr.y = 5 + t*32;
spr.name = t; spr.name = t*4;
spr.color = t+1; spr.color = t+1;
tms_set_sprite(t, &spr); tms_set_sprite(t, &spr);
} }
*/
// ballon demo
// define sprites using bitmap fonts
tms_copy_to_vram(cbm_balloon, 4*8*2, TMS_SPRITE_PATTERNS);
tms_set_sprite_double_size(1); // set 16x16 sprites
tms_set_sprite_magnification(1); // set double pixel sprites
int x = 200;
int y = 80;
int dx = 1;
int dy = 1;
int delay = 0;
byte sprcolor = COLOR_DARK_BLUE;
for(;;) {
for(delay=0; delay<800; delay++) {
delay = delay+1;
delay = delay-1;
}
if(apple1_readkey()==0x0d) break;
if(x>=228 || x<=0) { dx = -dx; sprcolor++; }
if(y>=148 || y<=0) { dy = -dy; sprcolor++; }
x += dx;
y += dy;
move_balloon((byte)x,(byte)y, sprcolor);
}
} }

120
demos/demo/mk_baloon.js Normal file
View File

@ -0,0 +1,120 @@
function e(s) {
let b = 0;
for(let t=0;t<s.length;t++) {
if(s.charAt(t) != ".") {
b |= 1<<(7-t);
}
}
let msg = `00000000`+b.toString(2);
console.log(` 0b${msg.substr(msg.length-8)},`);
}
console.log("// file generated automatically by mkfont.js -- do not edit");
/*
e("....XXXX"); e("XXX.....");
e("..XXXXXX"); e("XXXXX...");
e(".XXXXXXX"); e("XXXXXX..");
e(".XXXXX.."); e("XXXXXX..");
e("XXXXX.XX"); e("..XXXXX.");
e("XXXXX.XX"); e("XXXXXXX.");
e("XXXXX.XX"); e("..XXXXX.");
e(".XXXXX.."); e(".XXXXX..");
e(".XXXXXXX"); e("XXXXXX.."); //
e(".XXXXXXX"); e("XXXXXX..");
e(".X.XXXXX"); e("XXXX.X..");
e("..X.XXXX"); e("XXX.X...");
e("..X..XXX"); e("XX..X...");
e("...X..XX"); e("X..X....");
e("...X..XX"); e("X..X....");
e("....X..X"); e("..X.....");
e("....X..X"); e("..X....."); //
e(".....XXX"); e("XX......");
e(".....XXX"); e("XX......");
e(".....XXX"); e("XX......");
e("......XX"); e("X.......");
e("........"); e("........");
e("........"); e("........");
e("........"); e("........");
e("........"); e("........"); //
e("........"); e("........");
e("........"); e("........");
e("........"); e("........");
e("........"); e("........");
e("........"); e("........");
e("........"); e("........");
e("........"); e("........");
*/
e("....XXXX");
e("..XXXXXX");
e(".XXXXXXX");
e(".XXXXX..");
e("XXXXX.XX");
e("XXXXX.XX");
e("XXXXX.XX");
e(".XXXXX..");
e(".XXXXXXX"); //
e(".XXXXXXX");
e(".X.XXXXX");
e("..X.XXXX");
e("..X..XXX");
e("...X..XX");
e("...X..XX");
e("....X..X");
e("XXX.....");
e("XXXXX...");
e("XXXXXX..");
e("XXXXXX..");
e("..XXXXX.");
e("XXXXXXX.");
e("..XXXXX.");
e("XXXXXX..");
e("XXXXXX..");
e("XXXXXX..");
e("XXXX.X..");
e("XXX.X...");
e("XX..X...");
e("X..X....");
e("X..X....");
e("..X.....");
e("....X..X"); //
e(".....XXX");
e(".....XXX");
e(".....XXX");
e("......XX");
e("........");
e("........");
e("........");
e("........"); //
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("..X.....");
e("XX......");
e("XX......");
e("XX......");
e("X.......");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");
e("........");