mirror of
https://github.com/nippur72/apple1-videocard-lib.git
synced 2024-06-16 20:29:31 +00:00
commit
78ba730941
|
@ -40,12 +40,12 @@ void ck_init() {
|
||||||
void ck_drawpiece(sprite *pl) {
|
void ck_drawpiece(sprite *pl) {
|
||||||
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
// int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
||||||
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
// int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
||||||
/*
|
|
||||||
int x = pl->x + d->offset_x;
|
int x = pl->x + (int) data->offset_x;
|
||||||
int y = pl->y + d->offset_y;
|
int y = pl->y + (int) data->offset_y;
|
||||||
*/
|
|
||||||
WRITE_BOARD(y,x,pl->piece);
|
WRITE_BOARD(y,x,pl->piece);
|
||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,14 @@ void ck_drawpiece(sprite *pl) {
|
||||||
void ck_erasepiece(sprite *pl) {
|
void ck_erasepiece(sprite *pl) {
|
||||||
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
#ifdef BUG736
|
||||||
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
||||||
/*
|
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
||||||
int x = pl->x + (int) data->offset_x;
|
#else
|
||||||
int y = pl->y + (int) data->offset_y;
|
int x = pl->x + (int) data->offset_x;
|
||||||
*/
|
int y = pl->y + (int) data->offset_y;
|
||||||
|
#endif
|
||||||
|
|
||||||
WRITE_BOARD(y,x,EMPTY);
|
WRITE_BOARD(y,x,EMPTY);
|
||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
|
@ -70,12 +72,14 @@ void ck_erasepiece(sprite *pl) {
|
||||||
void ck_markpiece(sprite *pl) {
|
void ck_markpiece(sprite *pl) {
|
||||||
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
#ifdef BUG736
|
||||||
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
||||||
/*
|
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
||||||
int x = pl->x + (int) data->offset_x;
|
#else
|
||||||
int y = pl->y + (int) data->offset_y;
|
int x = pl->x + (int) data->offset_x;
|
||||||
*/
|
int y = pl->y + (int) data->offset_y;
|
||||||
|
#endif
|
||||||
|
|
||||||
WRITE_BOARD(y,x,MARKED);
|
WRITE_BOARD(y,x,MARKED);
|
||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
|
@ -85,11 +89,13 @@ void ck_markpiece(sprite *pl) {
|
||||||
int collides(sprite *pl) {
|
int collides(sprite *pl) {
|
||||||
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
tile_offset *data = get_piece_offsets(pl->piece, pl->angle);
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
#ifdef BUG736
|
||||||
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
int x = pl->x; byte x1 = data->offset_x; x+= (int) x1;
|
||||||
|
int y = pl->y; byte y1 = data->offset_y; y+= (int) y1;
|
||||||
//int x = pl->x + (int) data->offset_x;
|
#else
|
||||||
//int y = pl->y + (int) data->offset_y;
|
int x = pl->x + (int) data->offset_x;
|
||||||
|
int y = pl->y + (int) data->offset_y;
|
||||||
|
#endif
|
||||||
if(x<0) return 1; // does it collide with left border?
|
if(x<0) return 1; // does it collide with left border?
|
||||||
if(x>=BCOLS) return 1; // does it collide with right border?
|
if(x>=BCOLS) return 1; // does it collide with right border?
|
||||||
if(y>=BROWS) return 1; // does it collide with bottom?
|
if(y>=BROWS) return 1; // does it collide with bottom?
|
||||||
|
|
|
@ -188,8 +188,8 @@ void gr_erasepiece(sprite *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = px + data->offset_x;
|
int x = px + (int) data->offset_x;
|
||||||
int y = py + data->offset_y;
|
int y = py + (int) data->offset_y;
|
||||||
data++;
|
data++;
|
||||||
draw_tile((byte)x,(byte)y,EMPTY_GR_CHAR,EMPTY_GR_COLOR);
|
draw_tile((byte)x,(byte)y,EMPTY_GR_CHAR,EMPTY_GR_COLOR);
|
||||||
}
|
}
|
||||||
|
@ -208,11 +208,19 @@ void gr_erasepiece_unmarked(sprite *p) {
|
||||||
py += STARTBOARD_Y;
|
py += STARTBOARD_Y;
|
||||||
|
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = px; byte x1 = data->offset_x; x+= (int) x1;
|
#ifdef BUG736
|
||||||
int y = py; byte y1 = data->offset_y; y+= (int) y1;
|
int x = px; byte x1 = data->offset_x; x+= (int) x1;
|
||||||
|
int y = py; byte y1 = data->offset_y; y+= (int) y1;
|
||||||
|
|
||||||
int cx = p->x; cx += (int) x1;
|
int cx = p->x; cx += (int) x1;
|
||||||
int cy = p->y; cy += (int) y1;
|
int cy = p->y; cy += (int) y1;
|
||||||
|
#else
|
||||||
|
int x = px + (int) data->offset_x;
|
||||||
|
int y = py + (int) data->offset_y;
|
||||||
|
|
||||||
|
int cx = p->x + (int) data->offset_x;
|
||||||
|
int cy = p->y + (int) data->offset_y;
|
||||||
|
#endif
|
||||||
|
|
||||||
data++;
|
data++;
|
||||||
|
|
||||||
|
@ -240,15 +248,17 @@ void gr_drawpiece(sprite *p) {
|
||||||
|
|
||||||
byte piece = p->piece;
|
byte piece = p->piece;
|
||||||
for(byte t=0; t<4; t++) {
|
for(byte t=0; t<4; t++) {
|
||||||
int x = px; byte x1 = data->offset_x; x+= (int) x1;
|
#ifdef BUG736
|
||||||
int y = py; byte y1 = data->offset_y; y+= (int) y1;
|
int x = px + (int) data->offset_x;
|
||||||
|
int y = py + (int) data->offset_y;
|
||||||
|
else
|
||||||
|
int x = px + (int) data->offset_x;
|
||||||
|
int y = py + (int) data->offset_y;
|
||||||
|
#endif
|
||||||
data++;
|
data++;
|
||||||
/*
|
|
||||||
int x = px + data[t].offset_x;
|
byte ch = piece_chars[piece];
|
||||||
int y = py + data[t].offset_y;
|
byte col = piece_colors[piece];
|
||||||
*/
|
|
||||||
byte ch = piece_chars[piece]; //piece_chars[p->piece];
|
|
||||||
byte col = piece_colors[piece]; //piece_colors[p->piece];
|
|
||||||
draw_tile((byte)x,(byte)y,ch,col);
|
draw_tile((byte)x,(byte)y,ch,col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
// previous implementations for the Laser 310 and Laser 500
|
// previous implementations for the Laser 310 and Laser 500
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// KickC bug waiting to be fixed
|
||||||
|
#define BUG736 1
|
||||||
|
|
||||||
// standard libraries
|
// standard libraries
|
||||||
#include <string.h> // memset, memcopy (memcopy no longer necessary)
|
#include <string.h> // memset, memcopy (memcopy no longer necessary)
|
||||||
#include <stdlib.h> // for sprintf, rand
|
#include <stdlib.h> // for sprintf, rand
|
||||||
|
@ -321,7 +324,6 @@ void initGame() {
|
||||||
generate_new_piece();
|
generate_new_piece();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
// install the start-of-frame interrupt detection
|
// install the start-of-frame interrupt detection
|
||||||
|
|
|
@ -55,8 +55,9 @@ void screen2_puts(char *s, byte x, byte y, byte col) {
|
||||||
|
|
||||||
byte screen2_plot_mode = PLOT_MODE_SET;
|
byte screen2_plot_mode = PLOT_MODE_SET;
|
||||||
|
|
||||||
|
byte pow2_table_reversed[8] = { 128,64,32,16,8,4,2,1 };
|
||||||
|
|
||||||
void screen2_plot(byte x, byte y) {
|
void screen2_plot(byte x, byte y) {
|
||||||
byte pow2_table_reversed[8] = { 128,64,32,16,8,4,2,1 };
|
|
||||||
word paddr = TMS_PATTERN_TABLE + (word)(x & 0b11111000) + (word)(y & 0b11111000)*32 + y%8;
|
word paddr = TMS_PATTERN_TABLE + (word)(x & 0b11111000) + (word)(y & 0b11111000)*32 + y%8;
|
||||||
tms_set_vram_read_addr(paddr);
|
tms_set_vram_read_addr(paddr);
|
||||||
byte data = TMS_READ_DATA_PORT;
|
byte data = TMS_READ_DATA_PORT;
|
||||||
|
@ -76,6 +77,13 @@ void screen2_plot(byte x, byte y) {
|
||||||
TMS_WRITE_DATA_PORT(data);
|
TMS_WRITE_DATA_PORT(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte screen2_point(byte x, byte y) {
|
||||||
|
word paddr = TMS_PATTERN_TABLE + (word)(x & 0b11111000) + (word)(y & 0b11111000)*32 + y%8;
|
||||||
|
tms_set_vram_read_addr(paddr);
|
||||||
|
byte data = TMS_READ_DATA_PORT;
|
||||||
|
byte mask = pow2_table_reversed[x%8];
|
||||||
|
return (data & mask) != 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
signed int math_abs(signed int x) {
|
signed int math_abs(signed int x) {
|
||||||
return x < 0 ? -x : x;
|
return x < 0 ? -x : x;
|
||||||
|
@ -106,11 +114,12 @@ void screen2_line(byte _x0, byte _y0, byte _x1, byte _y1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define mul(a,b) ((signed long)mulf16s((signed int)(a),(signed int)(b)))
|
||||||
|
|
||||||
// http://members.chello.at/~easyfilter/bresenham.html
|
// http://members.chello.at/~easyfilter/bresenham.html
|
||||||
/* TODO: FIX THIS, IT DOES NOT DRAW AN ELLIPSE
|
|
||||||
void screen2_ellipse_rect(byte _x0, byte _y0, byte _x1, byte _y1)
|
void screen2_ellipse_rect(byte _x0, byte _y0, byte _x1, byte _y1)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (tms_global_mulf_initialized == 0) {
|
if (tms_global_mulf_initialized == 0) {
|
||||||
mulf_init();
|
mulf_init();
|
||||||
tms_global_mulf_initialized = 1;
|
tms_global_mulf_initialized = 1;
|
||||||
|
@ -153,9 +162,9 @@ void screen2_ellipse_rect(byte _x0, byte _y0, byte _x1, byte _y1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// http://members.chello.at/~easyfilter/bresenham.html
|
// http://members.chello.at/~easyfilter/bresenham.html
|
||||||
void screen2_circle(byte _xm, byte _ym, byte _r) {
|
void screen2_circle(byte _xm, byte _ym, byte _r) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user