Merge pull request #6 from nippur72/main

Update sprites and more
This commit is contained in:
Francesco Sblendorio 2022-01-01 12:47:22 +01:00 committed by GitHub
commit 11906f933c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1235 additions and 48 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

@ -2,6 +2,7 @@
#include "demo_screen1.h"
#include "demo_screen2.h"
#include "demo_balloon.h"
#include "demo_amiga_hand.h"
#include "demo_interrupt.h"
#include "demo_extvid.h"
@ -14,6 +15,7 @@ void help() {
"=============\r"
"1 SCREEN1\r"
"2 SCREEN2\r"
"3 BALLOON\r"
"A AMIGA HAND\r"
"I INTERRUPT\r"
"E FLIP EXT VIDEO\r"
@ -26,7 +28,7 @@ void help() {
void main() {
#ifdef APPLE1
#ifdef APPLE1_JUKEBOX
apple1_eprom_init();
#endif
@ -34,6 +36,7 @@ void main() {
for(;;) {
if(key == '1') demo_screen1();
else if(key == '2') demo_screen2();
else if(key == '3') demo_balloon();
else if(key == 'A') demo_amiga_hand();
else if(key == 'I') demo_interrupt();
else if(key == 'E') flip_external_input();

136
demos/demo/demo_balloon.h Normal file
View File

@ -0,0 +1,136 @@
#include <font8x8.h>
// the balloon sprite, manually copied from C64 User's guide
#include "cbm_balloon.h"
// a balloon is two 16x16 sprites, one above the other
typedef struct {
int x; // x coordinate of the balloon
int y; // y coordinate of the balloon
int dx; // x velocity of the balloon
int dy; // y velocity of the balloon
byte color; // color of the balloon
byte sprite_number; // sprite number (0-31) of the balloon
tms_sprite upper; // the upper sprite portion of the balloon
tms_sprite lower; // the lower sprite portion of the balloon
} balloon;
// move ballon on the screen by its velocity
// and make it bounce over the borders
void animate_balloon(balloon *b) {
// use temporary variables as KickC has issues dealing with "->" operator
int x = b->x;
int y = b->y;
int dx = b->dx;
int dy = b->dy;
// border collision detection
if(x>=240 || x<=0) dx = -dx;
if(y>=172 || y<=0) dy = -dy;
// move the balloon
x += dx;
y += dy;
// write back temporary variables
b->x = x;
b->y = y;
b->dx = dx;
b->dy = dy;
// update the sprite part of the balloon
b->upper.x = (byte) x;
b->upper.y = (signed char) y;
b->upper.name = 0;
b->upper.color = b->color;
b->lower.x = b->upper.x;
b->lower.y = b->upper.y + 16; // 16 pixels below the upper sprite
b->lower.name = b->upper.name + 4;
b->lower.color = b->color;
tms_set_sprite(b->sprite_number, &(b->upper));
tms_set_sprite(b->sprite_number+1, &(b->lower));
}
void demo_balloon() {
tms_init_regs(SCREEN2_TABLE);
// we use only 4 sprites, two for each ot the two balloons on the screen
tms_set_total_sprites(4);
// fake C64 bootup screen colors
tms_set_color(COLOR_LIGHT_BLUE);
byte text_color = FG_BG(COLOR_GREY,COLOR_DARK_BLUE); // alas, COLOR_LIGHT_BLUE doesn't fit well so we use GREY instead
screen2_init_bitmap(text_color);
// C64-like screen text
screen2_puts("*** COMMODORE-APPLE BASIC V2 ***", 0, 0, text_color);
screen2_puts("38911 BASIC BYTES FREE" , 0, 2, text_color);
screen2_puts("READY." , 0, 4, text_color);
// copy the ballon graphic to VRAM
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(0); // set single pixel sprites
// we have two balloons bouncing around the screen
// first balloon
balloon b1;
b1.x = 20;
b1.y = 20;
b1.dx = 1;
b1.dy = 1;
b1.color = COLOR_LIGHT_YELLOW;
b1.sprite_number = 0;
// second balloon
balloon b2;
b2.x = 150;
b2.y = 150;
b2.dx = -1;
b2.dy = -1;
b2.color = COLOR_LIGHT_RED;
b2.sprite_number = 2;
// counter for a fake blinking cursor
byte blink_counter=0;
for(;;) {
// delay the animation
for(int delay=0; delay<400; delay++) {
delay = delay+1;
delay = delay-1;
}
// RETURN key ends the demo
if(apple1_readkey()==0x0d) break;
// if there's a collision invert the motion of the balloons
if(COLLISION_BIT(TMS_READ_CTRL_PORT)) {
int temp;
temp = b1.dx; b1.dx = -temp; // b1.dx = -b1.dx; // due to KickC issue
temp = b1.dy; b1.dy = -temp; // b1.dy = -b1.dy; // due to KickC issue
temp = b2.dx; b2.dx = -temp; // b2.dx = -b2.dx; // due to KickC issue
temp = b2.dy; b2.dy = -temp; // b2.dy = -b2.dy; // due to KickC issue
}
// move the two balloons
animate_balloon(&b1);
animate_balloon(&b2);
// since a balloon is made of two sprites, sometimes they overlap
// by one line during the move, causing a false collision
// so we clear the collision bit by simply reading the status register
tms_clear_collisions();
// fake a blinking cursor
blink_counter++;
if(blink_counter == 16) { screen2_puts(" ", 0, 5, FG_BG(COLOR_DARK_BLUE,COLOR_GREY)); }
if(blink_counter == 32) { screen2_puts(" ", 0, 5, FG_BG(COLOR_GREY,COLOR_DARK_BLUE)); blink_counter = 0; }
}
}

View File

@ -28,23 +28,6 @@ void demo_screen2() {
screen2_line(18+5+5, 45,232+5+5,187);
screen2_line(18+5+5,187,232+5+5, 45);
screen2_plot_mode = PLOT_MODE_SET;
// define sprites using bitmap fonts
tms_copy_to_vram(&FONT[64*8], 32*8, TMS_SPRITE_PATTERNS);
// set 16x16 sprites
tms_set_sprite_double_size(1);
// set double pixel sprites
tms_set_sprite_magnification(1);
tms_sprite spr;
for(byte t=0;t<32;t++) {
spr.x = 10 + t*32;
spr.y = 5 + t*32;
spr.name = t;
spr.color = t+1;
tms_set_sprite(t, &spr);
}
screen2_plot_mode = PLOT_MODE_SET;
}

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("........");

View File

@ -10,7 +10,7 @@
void main() {
#ifdef APPLE1
#ifdef APPLE1_JUKEBOX
apple1_eprom_init();
#endif

View File

@ -326,7 +326,7 @@ void main() {
// install the start-of-frame interrupt detection
//install_interrupt();
#ifdef APPLE1
#ifdef APPLE1_JUKEBOX
apple1_eprom_init();
#endif

0
lib/c64.ascii.txt Normal file
View File

874
lib/c64font.h Normal file
View File

@ -0,0 +1,874 @@
#ifndef FONT8X8_H
#define FONT8X8_H
// C64 FONTS translated into ASCII
#pragma data_seg(Code)
byte FONT[768] = {
// char $120
0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
// char $121
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00000000
// char $122
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
// char $123
, 0b01100110
, 0b01100110
, 0b11111111
, 0b01100110
, 0b11111111
, 0b01100110
, 0b01100110
, 0b00000000
// char $124
, 0b00011000
, 0b00111110
, 0b01100000
, 0b00111100
, 0b00000110
, 0b01111100
, 0b00011000
, 0b00000000
// char $125
, 0b01100010
, 0b01100110
, 0b00001100
, 0b00011000
, 0b00110000
, 0b01100110
, 0b01000110
, 0b00000000
// char $126
, 0b00111100
, 0b01100110
, 0b00111100
, 0b00111000
, 0b01100111
, 0b01100110
, 0b00111111
, 0b00000000
// char $127
, 0b00000110
, 0b00001100
, 0b00011000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
// char $128
, 0b00001100
, 0b00011000
, 0b00110000
, 0b00110000
, 0b00110000
, 0b00011000
, 0b00001100
, 0b00000000
// char $129
, 0b00110000
, 0b00011000
, 0b00001100
, 0b00001100
, 0b00001100
, 0b00011000
, 0b00110000
, 0b00000000
// char $12a
, 0b00000000
, 0b01100110
, 0b00111100
, 0b11111111
, 0b00111100
, 0b01100110
, 0b00000000
, 0b00000000
// char $12b
, 0b00000000
, 0b00011000
, 0b00011000
, 0b01111110
, 0b00011000
, 0b00011000
, 0b00000000
, 0b00000000
// char $12c
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00011000
, 0b00110000
// char $12d
, 0b00000000
, 0b00000000
, 0b00000000
, 0b01111110
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
// char $12e
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00011000
, 0b00000000
// char $12f
, 0b00000000
, 0b00000011
, 0b00000110
, 0b00001100
, 0b00011000
, 0b00110000
, 0b01100000
, 0b00000000
// char $130
, 0b00111100
, 0b01100110
, 0b01101110
, 0b01110110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $131
, 0b00011000
, 0b00011000
, 0b00111000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b01111110
, 0b00000000
// char $132
, 0b00111100
, 0b01100110
, 0b00000110
, 0b00001100
, 0b00110000
, 0b01100000
, 0b01111110
, 0b00000000
// char $133
, 0b00111100
, 0b01100110
, 0b00000110
, 0b00011100
, 0b00000110
, 0b01100110
, 0b00111100
, 0b00000000
// char $134
, 0b00000110
, 0b00001110
, 0b00011110
, 0b01100110
, 0b01111111
, 0b00000110
, 0b00000110
, 0b00000000
// char $135
, 0b01111110
, 0b01100000
, 0b01111100
, 0b00000110
, 0b00000110
, 0b01100110
, 0b00111100
, 0b00000000
// char $136
, 0b00111100
, 0b01100110
, 0b01100000
, 0b01111100
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $137
, 0b01111110
, 0b01100110
, 0b00001100
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00000000
// char $138
, 0b00111100
, 0b01100110
, 0b01100110
, 0b00111100
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $139
, 0b00111100
, 0b01100110
, 0b01100110
, 0b00111110
, 0b00000110
, 0b01100110
, 0b00111100
, 0b00000000
// char $13a
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00000000
, 0b00000000
// char $13b
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00000000
, 0b00000000
, 0b00011000
, 0b00011000
, 0b00110000
// char $13c
, 0b00001110
, 0b00011000
, 0b00110000
, 0b01100000
, 0b00110000
, 0b00011000
, 0b00001110
, 0b00000000
// char $13d
, 0b00000000
, 0b00000000
, 0b01111110
, 0b00000000
, 0b01111110
, 0b00000000
, 0b00000000
, 0b00000000
// char $13e
, 0b01110000
, 0b00011000
, 0b00001100
, 0b00000110
, 0b00001100
, 0b00011000
, 0b01110000
, 0b00000000
// char $13f
, 0b00111100
, 0b01100110
, 0b00000110
, 0b00001100
, 0b00011000
, 0b00000000
, 0b00011000
, 0b00000000
// char $100
, 0b00111100
, 0b01100110
, 0b01101110
, 0b01101110
, 0b01100000
, 0b01100010
, 0b00111100
, 0b00000000
// char $141
, 0b00011000
, 0b00111100
, 0b01100110
, 0b01111110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00000000
// char $142
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01111100
, 0b00000000
// char $143
, 0b00111100
, 0b01100110
, 0b01100000
, 0b01100000
, 0b01100000
, 0b01100110
, 0b00111100
, 0b00000000
// char $144
, 0b01111000
, 0b01101100
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01101100
, 0b01111000
, 0b00000000
// char $145
, 0b01111110
, 0b01100000
, 0b01100000
, 0b01111000
, 0b01100000
, 0b01100000
, 0b01111110
, 0b00000000
// char $146
, 0b01111110
, 0b01100000
, 0b01100000
, 0b01111000
, 0b01100000
, 0b01100000
, 0b01100000
, 0b00000000
// char $147
, 0b00111100
, 0b01100110
, 0b01100000
, 0b01101110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $148
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01111110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00000000
// char $149
, 0b00111100
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00111100
, 0b00000000
// char $14a
, 0b00011110
, 0b00001100
, 0b00001100
, 0b00001100
, 0b00001100
, 0b01101100
, 0b00111000
, 0b00000000
// char $14b
, 0b01100110
, 0b01101100
, 0b01111000
, 0b01110000
, 0b01111000
, 0b01101100
, 0b01100110
, 0b00000000
// char $14c
, 0b01100000
, 0b01100000
, 0b01100000
, 0b01100000
, 0b01100000
, 0b01100000
, 0b01111110
, 0b00000000
// char $14d
, 0b01100011
, 0b01110111
, 0b01111111
, 0b01101011
, 0b01100011
, 0b01100011
, 0b01100011
, 0b00000000
// char $14e
, 0b01100110
, 0b01110110
, 0b01111110
, 0b01111110
, 0b01101110
, 0b01100110
, 0b01100110
, 0b00000000
// char $14f
, 0b00111100
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $150
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01111100
, 0b01100000
, 0b01100000
, 0b01100000
, 0b00000000
// char $151
, 0b00111100
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00001110
, 0b00000000
// char $152
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01111100
, 0b01111000
, 0b01101100
, 0b01100110
, 0b00000000
// char $153
, 0b00111100
, 0b01100110
, 0b01100000
, 0b00111100
, 0b00000110
, 0b01100110
, 0b00111100
, 0b00000000
// char $154
, 0b01111110
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00000000
// char $155
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $156
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00011000
, 0b00000000
// char $157
, 0b01100011
, 0b01100011
, 0b01100011
, 0b01101011
, 0b01111111
, 0b01110111
, 0b01100011
, 0b00000000
// char $158
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00011000
, 0b00111100
, 0b01100110
, 0b01100110
, 0b00000000
// char $159
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00000000
// char $15a
, 0b01111110
, 0b00000110
, 0b00001100
, 0b00011000
, 0b00110000
, 0b01100000
, 0b01111110
, 0b00000000
// char $11b
, 0b00111100
, 0b00110000
, 0b00110000
, 0b00110000
, 0b00110000
, 0b00110000
, 0b00111100
, 0b00000000
// char $11c
, 0b00001100
, 0b00010010
, 0b00110000
, 0b01111100
, 0b00110000
, 0b01100010
, 0b11111100
, 0b00000000
// char $11d
, 0b00111100
, 0b00001100
, 0b00001100
, 0b00001100
, 0b00001100
, 0b00001100
, 0b00111100
, 0b00000000
// char $11e
, 0b00000000
, 0b00011000
, 0b00111100
, 0b01111110
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
// char $11f
, 0b00000000
, 0b00010000
, 0b00110000
, 0b01111111
, 0b01111111
, 0b00110000
, 0b00010000
, 0b00000000
// char $140
, 0b00000000
, 0b00000000
, 0b00000000
, 0b11111111
, 0b11111111
, 0b00000000
, 0b00000000
, 0b00000000
// char $101
, 0b00000000
, 0b00000000
, 0b00111100
, 0b00000110
, 0b00111110
, 0b01100110
, 0b00111110
, 0b00000000
// char $102
, 0b00000000
, 0b01100000
, 0b01100000
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01111100
, 0b00000000
// char $103
, 0b00000000
, 0b00000000
, 0b00111100
, 0b01100000
, 0b01100000
, 0b01100000
, 0b00111100
, 0b00000000
// char $104
, 0b00000000
, 0b00000110
, 0b00000110
, 0b00111110
, 0b01100110
, 0b01100110
, 0b00111110
, 0b00000000
// char $105
, 0b00000000
, 0b00000000
, 0b00111100
, 0b01100110
, 0b01111110
, 0b01100000
, 0b00111100
, 0b00000000
// char $106
, 0b00000000
, 0b00001110
, 0b00011000
, 0b00111110
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00000000
// char $107
, 0b00000000
, 0b00000000
, 0b00111110
, 0b01100110
, 0b01100110
, 0b00111110
, 0b00000110
, 0b01111100
// char $108
, 0b00000000
, 0b01100000
, 0b01100000
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00000000
// char $109
, 0b00000000
, 0b00011000
, 0b00000000
, 0b00111000
, 0b00011000
, 0b00011000
, 0b00111100
, 0b00000000
// char $10a
, 0b00000000
, 0b00000110
, 0b00000000
, 0b00000110
, 0b00000110
, 0b00000110
, 0b00000110
, 0b00111100
// char $10b
, 0b00000000
, 0b01100000
, 0b01100000
, 0b01101100
, 0b01111000
, 0b01101100
, 0b01100110
, 0b00000000
// char $10c
, 0b00000000
, 0b00111000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00111100
, 0b00000000
// char $10d
, 0b00000000
, 0b00000000
, 0b01100110
, 0b01111111
, 0b01111111
, 0b01101011
, 0b01100011
, 0b00000000
// char $10e
, 0b00000000
, 0b00000000
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00000000
// char $10f
, 0b00000000
, 0b00000000
, 0b00111100
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00000000
// char $110
, 0b00000000
, 0b00000000
, 0b01111100
, 0b01100110
, 0b01100110
, 0b01111100
, 0b01100000
, 0b01100000
// char $111
, 0b00000000
, 0b00000000
, 0b00111110
, 0b01100110
, 0b01100110
, 0b00111110
, 0b00000110
, 0b00000110
// char $112
, 0b00000000
, 0b00000000
, 0b01111100
, 0b01100110
, 0b01100000
, 0b01100000
, 0b01100000
, 0b00000000
// char $113
, 0b00000000
, 0b00000000
, 0b00111110
, 0b01100000
, 0b00111100
, 0b00000110
, 0b01111100
, 0b00000000
// char $114
, 0b00000000
, 0b00011000
, 0b01111110
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00001110
, 0b00000000
// char $115
, 0b00000000
, 0b00000000
, 0b01100110
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111110
, 0b00000000
// char $116
, 0b00000000
, 0b00000000
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111100
, 0b00011000
, 0b00000000
// char $117
, 0b00000000
, 0b00000000
, 0b01100011
, 0b01101011
, 0b01111111
, 0b00111110
, 0b00110110
, 0b00000000
// char $118
, 0b00000000
, 0b00000000
, 0b01100110
, 0b00111100
, 0b00011000
, 0b00111100
, 0b01100110
, 0b00000000
// char $119
, 0b00000000
, 0b00000000
, 0b01100110
, 0b01100110
, 0b01100110
, 0b00111110
, 0b00001100
, 0b01111000
// char $11a
, 0b00000000
, 0b00000000
, 0b01111110
, 0b00001100
, 0b00011000
, 0b00110000
, 0b01111110
, 0b00000000
// char $15b
, 0b00011000
, 0b00011000
, 0b00011000
, 0b11111111
, 0b11111111
, 0b00011000
, 0b00011000
, 0b00011000
// char $15c
, 0b11000000
, 0b11000000
, 0b00110000
, 0b00110000
, 0b11000000
, 0b11000000
, 0b00110000
, 0b00110000
// char $15d
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
, 0b00011000
// char $15e
, 0b00110011
, 0b00110011
, 0b11001100
, 0b11001100
, 0b00110011
, 0b00110011
, 0b11001100
, 0b11001100
// char $15f
, 0b00110011
, 0b10011001
, 0b11001100
, 0b01100110
, 0b00110011
, 0b10011001
, 0b11001100
, 0b01100110
};

View File

@ -48,12 +48,12 @@ void screen1_scroll_up() {
}
void screen1_prepare() {
// clear all the sprites
tms_set_total_sprites(0);
// fill name table with spaces (32)
screen1_cls();
// clear all the sprites
tms_clear_sprites();
// fill pattern table with 0
tms_set_vram_write_addr(TMS_PATTERN_TABLE);
for(word i=256*8;i!=0;i--) {

View File

@ -10,8 +10,8 @@ const word SCREEN2_SIZE = (32*24);
// prepare the screen 2 to be used as a bitmap
void screen2_init_bitmap(byte color) {
// erases all the sprites
tms_clear_sprites();
// clear all the sprites
tms_set_total_sprites(0);
// fill pattern table with 0 (clear screen)
tms_set_vram_write_addr(TMS_PATTERN_TABLE);

View File

@ -2,13 +2,22 @@
#define SPRITES_H
typedef struct {
byte y;
signed char y;
byte x;
byte name;
byte color;
} tms_sprite;
#define SIZEOF_SPRITE 4
#define SPRITE_OFF_MARKER 0xD0
#define EARLY_CLOCK 128
void tms_set_total_sprites(byte num) {
// write the value 0xD0 as Y coordinate of the first unused sprite
word addr = TMS_SPRITE_ATTRS + (word) (num * SIZEOF_SPRITE);
tms_set_vram_write_addr(addr);
TMS_WRITE_DATA_PORT(SPRITE_OFF_MARKER); // 0xD0 oi the sprite off indicator
}
void tms_set_sprite(byte sprite_num, tms_sprite *s) {
word addr = TMS_SPRITE_ATTRS + (word) (sprite_num * SIZEOF_SPRITE);
@ -34,21 +43,8 @@ void tms_set_sprite_magnification(byte m) {
tms_write_reg(1, regval);
}
// clears all the sprites
void tms_clear_sprites() {
// fills first sprite pattern with 0
tms_set_vram_write_addr(TMS_SPRITE_PATTERNS);
for(byte i=0;i<8;i++) {
TMS_WRITE_DATA_PORT(0);
}
// set sprite coordinates to (0,0) and set pattern name 0
tms_set_vram_write_addr(TMS_SPRITE_ATTRS);
for(byte i=0;i<32;i++) {
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // y coordinate
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // x coordinate
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // name
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // color
}
// clear the collision flag by reading the status register
inline void tms_clear_collisions() {
asm { lda VDP_REG };
}
#endif

View File

@ -174,7 +174,8 @@ void tms_copy_to_vram(byte *source, word size, word dest) {
}
#include "apple1.h"
#include "font8x8.h"
//#include "font8x8.h"
#include "c64font.h"
#include "sprites.h"
#include "screen1.h"
#include "screen2.h"

View File

@ -7,12 +7,14 @@
call kickc -includedir %TMS9918%\lib -targetdir %TMS9918%\kickc\ -t vic20_8k %TARGET%.c -o out\%TARGET%_vic20.prg -e
copy out\%TARGET%.prg out\%TARGET%_vic20.prg
@echo ======================== APPLE 1 =================================================
@echo ======================== APPLE 1 JUKEBOX =================================================
call kickc -includedir %TMS9918%\lib -targetdir %TMS9918%\kickc\ -t apple1_jukebox %TARGET%.c -o out\%TARGET%_apple1.prg -e
@rem builds the apple1 eprom file
call node %TMS9918%\tools\mkeprom out out\%TARGET%_apple1.bin
@echo ======================== APPLE 1 JUKEBOX =================================================
call kickc -includedir %TMS9918%\lib -targetdir %TMS9918%\kickc\ -t apple1 %TARGET%.c -o out\%TARGET%_apple1.prg -e
copy out\%TARGET%.prg out\%TARGET%_apple1.prg
@rem clean up files
@del out\apple1_codeseg.bin
@del out\apple1_dataseg.bin