1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-04 20:05:57 +00:00

apple2: fixed cosmic impalas

This commit is contained in:
Steven Hugg 2020-07-23 09:36:43 -05:00
parent 3e8436126b
commit 8b96c82e65

View File

@ -1,4 +1,4 @@

/*
* An Apple ][ port of the Cosmic Impalas game
* described in the book
@ -141,7 +141,7 @@ byte render_sprite(const byte* src, byte x, byte y, byte op) {
// compute graphics operation, write to dest
switch (op) {
case OP_DRAW: *dest++ = next; break;
case OP_XOR: result |= (*dest++ ^= next); break;
case OP_XOR: result |= (*dest++ ^= next) & next; break;
case OP_ERASE: *dest++ &= ~next; break;
}
rest = data >> (7-xs); // save leftover bits
@ -149,7 +149,7 @@ byte render_sprite(const byte* src, byte x, byte y, byte op) {
// compute final byte operation
switch (op) {
case OP_DRAW: *dest = rest; break;
case OP_XOR: result |= (*dest ^= rest); break;
case OP_XOR: result |= (*dest ^= rest) & rest; break;
case OP_ERASE: *dest &= ~rest; break;
}
}
@ -247,11 +247,13 @@ const byte bullet_bitmap[] =
const byte enemy1_bitmap[] =
{2,16,/*{w:16,h:16,bpp:1}*/0x00,0x00,0x70,0x38,0xF8,0x7C,0xFC,0xFC,0xFE,0xFC,0xFE,0xFF,0xFC,0xFF,0xF8,0x7F,0xF0,0x3F,0x88,0x47,0xF0,0x3F,0xF0,0x3F,0xD0,0x2F,0x8C,0xC7,0x48,0x48,0x80,0x04};
const byte enemy2_bitmap[] =
{2,16,/*{w:16,h:16,bpp:1}*/0x00,0x00,0x30,0x0C,0x14,0x28,0x2E,0x74,0x08,0x10,0x20,0x04,0xE0,0x07,0xD0,0x0B,0xB0,0x0D,0xB2,0x4D,0x19,0x98,0x8E,0x71,0x82,0x41,0xB1,0x8D,0x59,0x9A,0x4A,0x52};
{2,16,/*{w:16,h:16,bpp:1}*/0x00,0x00,0x30,0x0C,0x10,0x08,0x3C,0x3D,0x2C,0x35,0x34,0x2D,0x24,0x25,0x50,0x15,0x28,0x0A,0x30,0x0D,0x28,0x15,0x4A,0x50,0x2A,0x55,0x22,0x05,0x0A,0x14,0x0A,0x50};
const byte enemy3_bitmap[] =
{2,16,/*{w:16,h:16,bpp:1}*/0x00,0x00,0x00,0x00,0x04,0x20,0x05,0xA0,0x05,0xA0,0x25,0xA4,0xA7,0xE5,0xF7,0xEF,0xF7,0xEF,0xFE,0x7F,0xFC,0x3F,0xBC,0x3D,0xE4,0x27,0x20,0x00,0x00,0x00,0x00,0x00};
const byte enemy4_bitmap[] =
{2,16,/*{w:16,h:16,bpp:1}*/0x00,0x00,0x00,0x00,0xF0,0x0F,0xF8,0x1F,0xD8,0x1B,0xF8,0x1F,0xF8,0x1F,0xF8,0x1F,0xF0,0x0F,0xA8,0x15,0xCC,0x33,0xE8,0x17,0x66,0x66,0x33,0xCC,0x61,0x86,0x40,0x02};
const byte explosion_bitmap[] =
{2,16,/*{w:16,h:16,bpp:1}*/0x40,0x00,0x02,0x44,0x08,0x20,0x40,0x02,0x28,0x14,0x54,0x2A,0x2A,0x54,0x55,0xAA,0x2A,0x54,0x55,0xAA,0x2A,0x54,0x54,0x2A,0x28,0x14,0x40,0x22,0x04,0x40,0x42,0x04};
const byte* const enemy_bitmaps[4] = {
enemy1_bitmap,
@ -390,10 +392,14 @@ void init_enemies() {
}
void delete_enemy(Enemy* e) {
clear_sprite(e->shape, e->x, e->y);
byte x = e->x;
byte y = e->y;
clear_sprite(e->shape, x, y);
xor_sprite(explosion_bitmap, x, y);
memmove(e, e+1, sizeof(Enemy)*(enemies-e+MAX_ENEMIES-1));
num_enemies--; // update_next_enemy() will check enemy_index
tone(1,10,10);
tone(1,20,10);
xor_sprite(explosion_bitmap, x, y);
}
void update_next_enemy() {
@ -442,7 +448,7 @@ Enemy* find_enemy_at(byte x, byte y) {
byte i;
for (i=0; i<num_enemies; i++) {
Enemy* e = &enemies[i];
if (in_rect(e, x, y, 0, 2)) {
if (in_rect(e, x, y, 6, 2)) {
return e;
}
}
@ -458,7 +464,7 @@ void check_bullet_hit(byte x, byte y) {
}
void fire_bullet() {
bullet_x = player_x + 13;
bullet_x = player_x + 8;
bullet_y = 192-22;
xor_sprite(bullet_bitmap, bullet_x, bullet_y); // draw
}
@ -598,9 +604,7 @@ void attract_mode() {
}
void main() {
// NOTE: initializers don't get run, so we init here
while (1) {
//attract_mode();
play_game();
}
}